Passed
Pull Request — master (#236)
by Patrik
03:27
created
includes/wpinv-address-functions.php 1 patch
Spacing   +979 added lines, -979 removed lines patch added patch discarded remove patch
@@ -7,67 +7,67 @@  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
-function wpinv_is_base_country( $country ) {
21
+function wpinv_is_base_country($country) {
22 22
     $base_country = wpinv_get_default_country();
23 23
     
24
-    if ( $base_country === 'UK' ) {
24
+    if ($base_country === 'UK') {
25 25
         $base_country = 'GB';
26 26
     }
27
-    if ( $country == 'UK' ) {
27
+    if ($country == 'UK') {
28 28
         $country = 'GB';
29 29
     }
30 30
 
31
-    return ( $country && $country === $base_country ) ? true : false;
31
+    return ($country && $country === $base_country) ? true : false;
32 32
 }
33 33
 
34
-function wpinv_country_name( $country_code = '' ) { 
34
+function wpinv_country_name($country_code = '') { 
35 35
     $countries = wpinv_get_country_list();
36 36
     $country_code = $country_code == 'UK' ? 'GB' : $country_code;
37
-    $country = isset( $countries[$country_code] ) ? $countries[$country_code] : $country_code;
37
+    $country = isset($countries[$country_code]) ? $countries[$country_code] : $country_code;
38 38
 
39
-    return apply_filters( 'wpinv_country_name', $country, $country_code );
39
+    return apply_filters('wpinv_country_name', $country, $country_code);
40 40
 }
41 41
 
42 42
 function wpinv_get_default_state() {
43
-	$state = wpinv_get_option( 'default_state', false );
43
+	$state = wpinv_get_option('default_state', false);
44 44
 
45
-	return apply_filters( 'wpinv_default_state', $state );
45
+	return apply_filters('wpinv_default_state', $state);
46 46
 }
47 47
 
48
-function wpinv_state_name( $state_code = '', $country_code = '' ) {
48
+function wpinv_state_name($state_code = '', $country_code = '') {
49 49
     $state = $state_code;
50 50
     
51
-    if ( !empty( $country_code ) ) {
52
-        $states = wpinv_get_country_states( $country_code );
51
+    if (!empty($country_code)) {
52
+        $states = wpinv_get_country_states($country_code);
53 53
         
54
-        $state = !empty( $states ) && isset( $states[$state_code] ) ? $states[$state_code] : $state;
54
+        $state = !empty($states) && isset($states[$state_code]) ? $states[$state_code] : $state;
55 55
     }
56 56
 
57
-    return apply_filters( 'wpinv_state_name', $state, $state_code, $country_code );
57
+    return apply_filters('wpinv_state_name', $state, $state_code, $country_code);
58 58
 }
59 59
 
60 60
 function wpinv_store_address() {
61
-    $address = wpinv_get_option( 'store_address', '' );
61
+    $address = wpinv_get_option('store_address', '');
62 62
 
63
-    return apply_filters( 'wpinv_store_address', $address );
63
+    return apply_filters('wpinv_store_address', $address);
64 64
 }
65 65
 
66
-function wpinv_get_user_address( $user_id = 0, $with_default = true ) {
66
+function wpinv_get_user_address($user_id = 0, $with_default = true) {
67 67
     global $wpi_userID;
68 68
     
69
-    if( empty( $user_id ) ) {
70
-        $user_id = !empty( $wpi_userID ) ? $wpi_userID : get_current_user_id();
69
+    if (empty($user_id)) {
70
+        $user_id = !empty($wpi_userID) ? $wpi_userID : get_current_user_id();
71 71
     }
72 72
     
73 73
     $address_fields = array(
@@ -85,36 +85,36 @@  discard block
 block discarded – undo
85 85
         'zip',
86 86
     );
87 87
     
88
-    $user_info = get_userdata( $user_id );
88
+    $user_info = get_userdata($user_id);
89 89
     
90 90
     $address = array();
91 91
     $address['user_id'] = $user_id;
92
-    $address['email'] = !empty( $user_info ) ? $user_info->user_email : '';
93
-    foreach ( $address_fields as $field ) {
94
-        $address[$field] = get_user_meta( $user_id, '_wpinv_' . $field, true );
92
+    $address['email'] = !empty($user_info) ? $user_info->user_email : '';
93
+    foreach ($address_fields as $field) {
94
+        $address[$field] = get_user_meta($user_id, '_wpinv_' . $field, true);
95 95
     }
96 96
 
97
-    if ( !empty( $user_info ) ) {
98
-        if( empty( $address['first_name'] ) )
97
+    if (!empty($user_info)) {
98
+        if (empty($address['first_name']))
99 99
             $address['first_name'] = $user_info->first_name;
100 100
         
101
-        if( empty( $address['last_name'] ) )
101
+        if (empty($address['last_name']))
102 102
             $address['last_name'] = $user_info->last_name;
103 103
     }
104 104
     
105
-    $address['name'] = trim( trim( $address['first_name'] . ' ' . $address['last_name'] ), "," );
105
+    $address['name'] = trim(trim($address['first_name'] . ' ' . $address['last_name']), ",");
106 106
     
107
-    if( empty( $address['state'] ) && $with_default )
107
+    if (empty($address['state']) && $with_default)
108 108
         $address['state'] = wpinv_get_default_state();
109 109
 
110
-    if( empty( $address['country'] ) && $with_default )
110
+    if (empty($address['country']) && $with_default)
111 111
         $address['country'] = wpinv_get_default_country();
112 112
 
113 113
 
114 114
     return $address;
115 115
 }
116 116
 
117
-function wpinv_get_country_list( $first_empty = false ) {
117
+function wpinv_get_country_list($first_empty = false) {
118 118
 	$countries = array(
119 119
 		'US' => __('United States', 'invoicing'),
120 120
 		'CA' => __('Canada', 'invoicing'),
@@ -370,23 +370,23 @@  discard block
 block discarded – undo
370 370
 		'ZW' => __('Zimbabwe', 'invoicing'),
371 371
 	);
372 372
     
373
-    if ( $first_empty ) {
374
-        $countries = array_merge( array( '' => '' ), $countries );
373
+    if ($first_empty) {
374
+        $countries = array_merge(array('' => ''), $countries);
375 375
     }
376 376
     
377
-    $countries = apply_filters( 'wpinv_countries', $countries );
377
+    $countries = apply_filters('wpinv_countries', $countries);
378 378
     
379 379
     asort($countries);
380 380
 
381 381
     return $countries;
382 382
 }
383 383
 
384
-function wpinv_get_country_states( $country = null, $first_empty = false ) {
385
-    if ( empty( $country ) ) {
384
+function wpinv_get_country_states($country = null, $first_empty = false) {
385
+    if (empty($country)) {
386 386
         $country = wpinv_get_default_country();
387 387
     }
388 388
 
389
-    switch( $country ) {
389
+    switch ($country) {
390 390
         case 'US' :
391 391
             $states = wpinv_get_us_states_list();
392 392
             break;
@@ -461,11 +461,11 @@  discard block
 block discarded – undo
461 461
             break;
462 462
     }
463 463
     
464
-    if ( !empty( $states ) && $first_empty ) {
465
-        $states = array_merge( array( '' => '' ), $states );
464
+    if (!empty($states) && $first_empty) {
465
+        $states = array_merge(array('' => ''), $states);
466 466
     }
467 467
     
468
-    $states = apply_filters( 'wpinv_country_states', $states, $country );
468
+    $states = apply_filters('wpinv_country_states', $states, $country);
469 469
     
470 470
     asort($states);
471 471
 
@@ -474,1087 +474,1087 @@  discard block
 block discarded – undo
474 474
 
475 475
 function wpinv_get_us_states_list() {
476 476
     $states = array(
477
-        'AL' => __( 'Alabama', 'invoicing' ),
478
-        'AK' => __( 'Alaska', 'invoicing' ),
479
-        'AZ' => __( 'Arizona', 'invoicing' ),
480
-        'AR' => __( 'Arkansas', 'invoicing' ),
481
-        'CA' => __( 'California', 'invoicing' ),
482
-        'CO' => __( 'Colorado', 'invoicing' ),
483
-        'CT' => __( 'Connecticut', 'invoicing' ),
484
-        'DE' => __( 'Delaware', 'invoicing' ),
485
-        'DC' => __( 'District of Columbia', 'invoicing' ),
486
-        'FL' => __( 'Florida', 'invoicing' ),
487
-        'GA' => __( 'Georgia', 'invoicing' ),
488
-        'HI' => __( 'Hawaii', 'invoicing' ),
489
-        'ID' => __( 'Idaho', 'invoicing' ),
490
-        'IL' => __( 'Illinois', 'invoicing' ),
491
-        'IN' => __( 'Indiana', 'invoicing' ),
492
-        'IA' => __( 'Iowa', 'invoicing' ),
493
-        'KS' => __( 'Kansas', 'invoicing' ),
494
-        'KY' => __( 'Kentucky', 'invoicing' ),
495
-        'LA' => __( 'Louisiana', 'invoicing' ),
496
-        'ME' => __( 'Maine', 'invoicing' ),
497
-        'MD' => __( 'Maryland', 'invoicing' ),
498
-        'MA' => __( 'Massachusetts', 'invoicing' ),
499
-        'MI' => __( 'Michigan', 'invoicing' ),
500
-        'MN' => __( 'Minnesota', 'invoicing' ),
501
-        'MS' => __( 'Mississippi', 'invoicing' ),
502
-        'MO' => __( 'Missouri', 'invoicing' ),
503
-        'MT' => __( 'Montana', 'invoicing' ),
504
-        'NE' => __( 'Nebraska', 'invoicing' ),
505
-        'NV' => __( 'Nevada', 'invoicing' ),
506
-        'NH' => __( 'New Hampshire', 'invoicing' ),
507
-        'NJ' => __( 'New Jersey', 'invoicing' ),
508
-        'NM' => __( 'New Mexico', 'invoicing' ),
509
-        'NY' => __( 'New York', 'invoicing' ),
510
-        'NC' => __( 'North Carolina', 'invoicing' ),
511
-        'ND' => __( 'North Dakota', 'invoicing' ),
512
-        'OH' => __( 'Ohio', 'invoicing' ),
513
-        'OK' => __( 'Oklahoma', 'invoicing' ),
514
-        'OR' => __( 'Oregon', 'invoicing' ),
515
-        'PA' => __( 'Pennsylvania', 'invoicing' ),
516
-        'RI' => __( 'Rhode Island', 'invoicing' ),
517
-        'SC' => __( 'South Carolina', 'invoicing' ),
518
-        'SD' => __( 'South Dakota', 'invoicing' ),
519
-        'TN' => __( 'Tennessee', 'invoicing' ),
520
-        'TX' => __( 'Texas', 'invoicing' ),
521
-        'UT' => __( 'Utah', 'invoicing' ),
522
-        'VT' => __( 'Vermont', 'invoicing' ),
523
-        'VA' => __( 'Virginia', 'invoicing' ),
524
-        'WA' => __( 'Washington', 'invoicing' ),
525
-        'WV' => __( 'West Virginia', 'invoicing' ),
526
-        'WI' => __( 'Wisconsin', 'invoicing' ),
527
-        'WY' => __( 'Wyoming', 'invoicing' ),
528
-        'AS' => __( 'American Samoa', 'invoicing' ),
529
-        'CZ' => __( 'Canal Zone', 'invoicing' ),
530
-        'CM' => __( 'Commonwealth of the Northern Mariana Islands', 'invoicing' ),
531
-        'FM' => __( 'Federated States of Micronesia', 'invoicing' ),
532
-        'GU' => __( 'Guam', 'invoicing' ),
533
-        'MH' => __( 'Marshall Islands', 'invoicing' ),
534
-        'MP' => __( 'Northern Mariana Islands', 'invoicing' ),
535
-        'PW' => __( 'Palau', 'invoicing' ),
536
-        'PI' => __( 'Philippine Islands', 'invoicing' ),
537
-        'PR' => __( 'Puerto Rico', 'invoicing' ),
538
-        'TT' => __( 'Trust Territory of the Pacific Islands', 'invoicing' ),
539
-        'VI' => __( 'Virgin Islands', 'invoicing' ),
540
-        'AA' => __( 'Armed Forces - Americas', 'invoicing' ),
541
-        'AE' => __( 'Armed Forces - Europe, Canada, Middle East, Africa', 'invoicing' ),
542
-        'AP' => __( 'Armed Forces - Pacific', 'invoicing' )
477
+        'AL' => __('Alabama', 'invoicing'),
478
+        'AK' => __('Alaska', 'invoicing'),
479
+        'AZ' => __('Arizona', 'invoicing'),
480
+        'AR' => __('Arkansas', 'invoicing'),
481
+        'CA' => __('California', 'invoicing'),
482
+        'CO' => __('Colorado', 'invoicing'),
483
+        'CT' => __('Connecticut', 'invoicing'),
484
+        'DE' => __('Delaware', 'invoicing'),
485
+        'DC' => __('District of Columbia', 'invoicing'),
486
+        'FL' => __('Florida', 'invoicing'),
487
+        'GA' => __('Georgia', 'invoicing'),
488
+        'HI' => __('Hawaii', 'invoicing'),
489
+        'ID' => __('Idaho', 'invoicing'),
490
+        'IL' => __('Illinois', 'invoicing'),
491
+        'IN' => __('Indiana', 'invoicing'),
492
+        'IA' => __('Iowa', 'invoicing'),
493
+        'KS' => __('Kansas', 'invoicing'),
494
+        'KY' => __('Kentucky', 'invoicing'),
495
+        'LA' => __('Louisiana', 'invoicing'),
496
+        'ME' => __('Maine', 'invoicing'),
497
+        'MD' => __('Maryland', 'invoicing'),
498
+        'MA' => __('Massachusetts', 'invoicing'),
499
+        'MI' => __('Michigan', 'invoicing'),
500
+        'MN' => __('Minnesota', 'invoicing'),
501
+        'MS' => __('Mississippi', 'invoicing'),
502
+        'MO' => __('Missouri', 'invoicing'),
503
+        'MT' => __('Montana', 'invoicing'),
504
+        'NE' => __('Nebraska', 'invoicing'),
505
+        'NV' => __('Nevada', 'invoicing'),
506
+        'NH' => __('New Hampshire', 'invoicing'),
507
+        'NJ' => __('New Jersey', 'invoicing'),
508
+        'NM' => __('New Mexico', 'invoicing'),
509
+        'NY' => __('New York', 'invoicing'),
510
+        'NC' => __('North Carolina', 'invoicing'),
511
+        'ND' => __('North Dakota', 'invoicing'),
512
+        'OH' => __('Ohio', 'invoicing'),
513
+        'OK' => __('Oklahoma', 'invoicing'),
514
+        'OR' => __('Oregon', 'invoicing'),
515
+        'PA' => __('Pennsylvania', 'invoicing'),
516
+        'RI' => __('Rhode Island', 'invoicing'),
517
+        'SC' => __('South Carolina', 'invoicing'),
518
+        'SD' => __('South Dakota', 'invoicing'),
519
+        'TN' => __('Tennessee', 'invoicing'),
520
+        'TX' => __('Texas', 'invoicing'),
521
+        'UT' => __('Utah', 'invoicing'),
522
+        'VT' => __('Vermont', 'invoicing'),
523
+        'VA' => __('Virginia', 'invoicing'),
524
+        'WA' => __('Washington', 'invoicing'),
525
+        'WV' => __('West Virginia', 'invoicing'),
526
+        'WI' => __('Wisconsin', 'invoicing'),
527
+        'WY' => __('Wyoming', 'invoicing'),
528
+        'AS' => __('American Samoa', 'invoicing'),
529
+        'CZ' => __('Canal Zone', 'invoicing'),
530
+        'CM' => __('Commonwealth of the Northern Mariana Islands', 'invoicing'),
531
+        'FM' => __('Federated States of Micronesia', 'invoicing'),
532
+        'GU' => __('Guam', 'invoicing'),
533
+        'MH' => __('Marshall Islands', 'invoicing'),
534
+        'MP' => __('Northern Mariana Islands', 'invoicing'),
535
+        'PW' => __('Palau', 'invoicing'),
536
+        'PI' => __('Philippine Islands', 'invoicing'),
537
+        'PR' => __('Puerto Rico', 'invoicing'),
538
+        'TT' => __('Trust Territory of the Pacific Islands', 'invoicing'),
539
+        'VI' => __('Virgin Islands', 'invoicing'),
540
+        'AA' => __('Armed Forces - Americas', 'invoicing'),
541
+        'AE' => __('Armed Forces - Europe, Canada, Middle East, Africa', 'invoicing'),
542
+        'AP' => __('Armed Forces - Pacific', 'invoicing')
543 543
     );
544 544
 
545
-    return apply_filters( 'wpinv_us_states', $states );
545
+    return apply_filters('wpinv_us_states', $states);
546 546
 }
547 547
 
548 548
 function wpinv_get_canada_states_list() {
549 549
     $states = array(
550
-        'AB' => __( 'Alberta', 'invoicing' ),
551
-        'BC' => __( 'British Columbia', 'invoicing' ),
552
-        'MB' => __( 'Manitoba', 'invoicing' ),
553
-        'NB' => __( 'New Brunswick', 'invoicing' ),
554
-        'NL' => __( 'Newfoundland and Labrador', 'invoicing' ),
555
-        'NS' => __( 'Nova Scotia', 'invoicing' ),
556
-        'NT' => __( 'Northwest Territories', 'invoicing' ),
557
-        'NU' => __( 'Nunavut', 'invoicing' ),
558
-        'ON' => __( 'Ontario', 'invoicing' ),
559
-        'PE' => __( 'Prince Edward Island', 'invoicing' ),
560
-        'QC' => __( 'Quebec', 'invoicing' ),
561
-        'SK' => __( 'Saskatchewan', 'invoicing' ),
562
-        'YT' => __( 'Yukon', 'invoicing' )
550
+        'AB' => __('Alberta', 'invoicing'),
551
+        'BC' => __('British Columbia', 'invoicing'),
552
+        'MB' => __('Manitoba', 'invoicing'),
553
+        'NB' => __('New Brunswick', 'invoicing'),
554
+        'NL' => __('Newfoundland and Labrador', 'invoicing'),
555
+        'NS' => __('Nova Scotia', 'invoicing'),
556
+        'NT' => __('Northwest Territories', 'invoicing'),
557
+        'NU' => __('Nunavut', 'invoicing'),
558
+        'ON' => __('Ontario', 'invoicing'),
559
+        'PE' => __('Prince Edward Island', 'invoicing'),
560
+        'QC' => __('Quebec', 'invoicing'),
561
+        'SK' => __('Saskatchewan', 'invoicing'),
562
+        'YT' => __('Yukon', 'invoicing')
563 563
     );
564 564
 
565
-    return apply_filters( 'wpinv_canada_provinces', $states );
565
+    return apply_filters('wpinv_canada_provinces', $states);
566 566
 }
567 567
 
568 568
 function wpinv_get_australia_states_list() {
569 569
     $states = array(
570
-        'ACT' => __( 'Australian Capital Territory', 'invoicing' ),
571
-        'NSW' => __( 'New South Wales', 'invoicing' ),
572
-        'NT'  => __( 'Northern Territory', 'invoicing' ),
573
-        'QLD' => __( 'Queensland', 'invoicing' ),
574
-        'SA'  => __( 'South Australia', 'invoicing' ),
575
-        'TAS' => __( 'Tasmania', 'invoicing' ),
576
-        'VIC' => __( 'Victoria', 'invoicing' ),
577
-        'WA'  => __( 'Western Australia', 'invoicing' )
570
+        'ACT' => __('Australian Capital Territory', 'invoicing'),
571
+        'NSW' => __('New South Wales', 'invoicing'),
572
+        'NT'  => __('Northern Territory', 'invoicing'),
573
+        'QLD' => __('Queensland', 'invoicing'),
574
+        'SA'  => __('South Australia', 'invoicing'),
575
+        'TAS' => __('Tasmania', 'invoicing'),
576
+        'VIC' => __('Victoria', 'invoicing'),
577
+        'WA'  => __('Western Australia', 'invoicing')
578 578
     );
579 579
 
580
-    return apply_filters( 'wpinv_australia_states', $states );
580
+    return apply_filters('wpinv_australia_states', $states);
581 581
 }
582 582
 
583 583
 function wpinv_get_bangladesh_states_list() {
584 584
     $states = array(
585
-        'BAG' => __( 'Bagerhat', 'invoicing' ),
586
-        'BAN' => __( 'Bandarban', 'invoicing' ),
587
-        'BAR' => __( 'Barguna', 'invoicing' ),
588
-        'BARI'=> __( 'Barisal', 'invoicing' ),
589
-        'BHO' => __( 'Bhola', 'invoicing' ),
590
-        'BOG' => __( 'Bogra', 'invoicing' ),
591
-        'BRA' => __( 'Brahmanbaria', 'invoicing' ),
592
-        'CHA' => __( 'Chandpur', 'invoicing' ),
593
-        'CHI' => __( 'Chittagong', 'invoicing' ),
594
-        'CHU' => __( 'Chuadanga', 'invoicing' ),
595
-        'COM' => __( 'Comilla', 'invoicing' ),
596
-        'COX' => __( 'Cox\'s Bazar', 'invoicing' ),
597
-        'DHA' => __( 'Dhaka', 'invoicing' ),
598
-        'DIN' => __( 'Dinajpur', 'invoicing' ),
599
-        'FAR' => __( 'Faridpur', 'invoicing' ),
600
-        'FEN' => __( 'Feni', 'invoicing' ),
601
-        'GAI' => __( 'Gaibandha', 'invoicing' ),
602
-        'GAZI'=> __( 'Gazipur', 'invoicing' ),
603
-        'GOP' => __( 'Gopalganj', 'invoicing' ),
604
-        'HAB' => __( 'Habiganj', 'invoicing' ),
605
-        'JAM' => __( 'Jamalpur', 'invoicing' ),
606
-        'JES' => __( 'Jessore', 'invoicing' ),
607
-        'JHA' => __( 'Jhalokati', 'invoicing' ),
608
-        'JHE' => __( 'Jhenaidah', 'invoicing' ),
609
-        'JOY' => __( 'Joypurhat', 'invoicing' ),
610
-        'KHA' => __( 'Khagrachhari', 'invoicing' ),
611
-        'KHU' => __( 'Khulna', 'invoicing' ),
612
-        'KIS' => __( 'Kishoreganj', 'invoicing' ),
613
-        'KUR' => __( 'Kurigram', 'invoicing' ),
614
-        'KUS' => __( 'Kushtia', 'invoicing' ),
615
-        'LAK' => __( 'Lakshmipur', 'invoicing' ),
616
-        'LAL' => __( 'Lalmonirhat', 'invoicing' ),
617
-        'MAD' => __( 'Madaripur', 'invoicing' ),
618
-        'MAG' => __( 'Magura', 'invoicing' ),
619
-        'MAN' => __( 'Manikganj', 'invoicing' ),
620
-        'MEH' => __( 'Meherpur', 'invoicing' ),
621
-        'MOU' => __( 'Moulvibazar', 'invoicing' ),
622
-        'MUN' => __( 'Munshiganj', 'invoicing' ),
623
-        'MYM' => __( 'Mymensingh', 'invoicing' ),
624
-        'NAO' => __( 'Naogaon', 'invoicing' ),
625
-        'NAR' => __( 'Narail', 'invoicing' ),
626
-        'NARG'=> __( 'Narayanganj', 'invoicing' ),
627
-        'NARD'=> __( 'Narsingdi', 'invoicing' ),
628
-        'NAT' => __( 'Natore', 'invoicing' ),
629
-        'NAW' => __( 'Nawabganj', 'invoicing' ),
630
-        'NET' => __( 'Netrakona', 'invoicing' ),
631
-        'NIL' => __( 'Nilphamari', 'invoicing' ),
632
-        'NOA' => __( 'Noakhali', 'invoicing' ),
633
-        'PAB' => __( 'Pabna', 'invoicing' ),
634
-        'PAN' => __( 'Panchagarh', 'invoicing' ),
635
-        'PAT' => __( 'Patuakhali', 'invoicing' ),
636
-        'PIR' => __( 'Pirojpur', 'invoicing' ),
637
-        'RAJB'=> __( 'Rajbari', 'invoicing' ),
638
-        'RAJ' => __( 'Rajshahi', 'invoicing' ),
639
-        'RAN' => __( 'Rangamati', 'invoicing' ),
640
-        'RANP'=> __( 'Rangpur', 'invoicing' ),
641
-        'SAT' => __( 'Satkhira', 'invoicing' ),
642
-        'SHA' => __( 'Shariatpur', 'invoicing' ),
643
-        'SHE' => __( 'Sherpur', 'invoicing' ),
644
-        'SIR' => __( 'Sirajganj', 'invoicing' ),
645
-        'SUN' => __( 'Sunamganj', 'invoicing' ),
646
-        'SYL' => __( 'Sylhet', 'invoicing' ),
647
-        'TAN' => __( 'Tangail', 'invoicing' ),
648
-        'THA' => __( 'Thakurgaon', 'invoicing' )
585
+        'BAG' => __('Bagerhat', 'invoicing'),
586
+        'BAN' => __('Bandarban', 'invoicing'),
587
+        'BAR' => __('Barguna', 'invoicing'),
588
+        'BARI'=> __('Barisal', 'invoicing'),
589
+        'BHO' => __('Bhola', 'invoicing'),
590
+        'BOG' => __('Bogra', 'invoicing'),
591
+        'BRA' => __('Brahmanbaria', 'invoicing'),
592
+        'CHA' => __('Chandpur', 'invoicing'),
593
+        'CHI' => __('Chittagong', 'invoicing'),
594
+        'CHU' => __('Chuadanga', 'invoicing'),
595
+        'COM' => __('Comilla', 'invoicing'),
596
+        'COX' => __('Cox\'s Bazar', 'invoicing'),
597
+        'DHA' => __('Dhaka', 'invoicing'),
598
+        'DIN' => __('Dinajpur', 'invoicing'),
599
+        'FAR' => __('Faridpur', 'invoicing'),
600
+        'FEN' => __('Feni', 'invoicing'),
601
+        'GAI' => __('Gaibandha', 'invoicing'),
602
+        'GAZI'=> __('Gazipur', 'invoicing'),
603
+        'GOP' => __('Gopalganj', 'invoicing'),
604
+        'HAB' => __('Habiganj', 'invoicing'),
605
+        'JAM' => __('Jamalpur', 'invoicing'),
606
+        'JES' => __('Jessore', 'invoicing'),
607
+        'JHA' => __('Jhalokati', 'invoicing'),
608
+        'JHE' => __('Jhenaidah', 'invoicing'),
609
+        'JOY' => __('Joypurhat', 'invoicing'),
610
+        'KHA' => __('Khagrachhari', 'invoicing'),
611
+        'KHU' => __('Khulna', 'invoicing'),
612
+        'KIS' => __('Kishoreganj', 'invoicing'),
613
+        'KUR' => __('Kurigram', 'invoicing'),
614
+        'KUS' => __('Kushtia', 'invoicing'),
615
+        'LAK' => __('Lakshmipur', 'invoicing'),
616
+        'LAL' => __('Lalmonirhat', 'invoicing'),
617
+        'MAD' => __('Madaripur', 'invoicing'),
618
+        'MAG' => __('Magura', 'invoicing'),
619
+        'MAN' => __('Manikganj', 'invoicing'),
620
+        'MEH' => __('Meherpur', 'invoicing'),
621
+        'MOU' => __('Moulvibazar', 'invoicing'),
622
+        'MUN' => __('Munshiganj', 'invoicing'),
623
+        'MYM' => __('Mymensingh', 'invoicing'),
624
+        'NAO' => __('Naogaon', 'invoicing'),
625
+        'NAR' => __('Narail', 'invoicing'),
626
+        'NARG'=> __('Narayanganj', 'invoicing'),
627
+        'NARD'=> __('Narsingdi', 'invoicing'),
628
+        'NAT' => __('Natore', 'invoicing'),
629
+        'NAW' => __('Nawabganj', 'invoicing'),
630
+        'NET' => __('Netrakona', 'invoicing'),
631
+        'NIL' => __('Nilphamari', 'invoicing'),
632
+        'NOA' => __('Noakhali', 'invoicing'),
633
+        'PAB' => __('Pabna', 'invoicing'),
634
+        'PAN' => __('Panchagarh', 'invoicing'),
635
+        'PAT' => __('Patuakhali', 'invoicing'),
636
+        'PIR' => __('Pirojpur', 'invoicing'),
637
+        'RAJB'=> __('Rajbari', 'invoicing'),
638
+        'RAJ' => __('Rajshahi', 'invoicing'),
639
+        'RAN' => __('Rangamati', 'invoicing'),
640
+        'RANP'=> __('Rangpur', 'invoicing'),
641
+        'SAT' => __('Satkhira', 'invoicing'),
642
+        'SHA' => __('Shariatpur', 'invoicing'),
643
+        'SHE' => __('Sherpur', 'invoicing'),
644
+        'SIR' => __('Sirajganj', 'invoicing'),
645
+        'SUN' => __('Sunamganj', 'invoicing'),
646
+        'SYL' => __('Sylhet', 'invoicing'),
647
+        'TAN' => __('Tangail', 'invoicing'),
648
+        'THA' => __('Thakurgaon', 'invoicing')
649 649
     );
650 650
 
651
-    return apply_filters( 'wpinv_bangladesh_states', $states );
651
+    return apply_filters('wpinv_bangladesh_states', $states);
652 652
 }
653 653
 
654 654
 function wpinv_get_brazil_states_list() {
655 655
     $states = array(
656
-        'AC' => __( 'Acre', 'invoicing' ),
657
-        'AL' => __( 'Alagoas', 'invoicing' ),
658
-        'AP' => __( 'Amapá', 'invoicing' ),
659
-        'AM' => __( 'Amazonas', 'invoicing' ),
660
-        'BA' => __( 'Bahia', 'invoicing' ),
661
-        'CE' => __( 'Ceará', 'invoicing' ),
662
-        'DF' => __( 'Distrito Federal', 'invoicing' ),
663
-        'ES' => __( 'Espírito Santo', 'invoicing' ),
664
-        'GO' => __( 'Goiás', 'invoicing' ),
665
-        'MA' => __( 'Maranhão', 'invoicing' ),
666
-        'MT' => __( 'Mato Grosso', 'invoicing' ),
667
-        'MS' => __( 'Mato Grosso do Sul', 'invoicing' ),
668
-        'MG' => __( 'Minas Gerais', 'invoicing' ),
669
-        'PA' => __( 'Pará', 'invoicing' ),
670
-        'PB' => __( 'Paraíba', 'invoicing' ),
671
-        'PR' => __( 'Paraná', 'invoicing' ),
672
-        'PE' => __( 'Pernambuco', 'invoicing' ),
673
-        'PI' => __( 'Piauí', 'invoicing' ),
674
-        'RJ' => __( 'Rio de Janeiro', 'invoicing' ),
675
-        'RN' => __( 'Rio Grande do Norte', 'invoicing' ),
676
-        'RS' => __( 'Rio Grande do Sul', 'invoicing' ),
677
-        'RO' => __( 'Rondônia', 'invoicing' ),
678
-        'RR' => __( 'Roraima', 'invoicing' ),
679
-        'SC' => __( 'Santa Catarina', 'invoicing' ),
680
-        'SP' => __( 'São Paulo', 'invoicing' ),
681
-        'SE' => __( 'Sergipe', 'invoicing' ),
682
-        'TO' => __( 'Tocantins', 'invoicing' )
656
+        'AC' => __('Acre', 'invoicing'),
657
+        'AL' => __('Alagoas', 'invoicing'),
658
+        'AP' => __('Amapá', 'invoicing'),
659
+        'AM' => __('Amazonas', 'invoicing'),
660
+        'BA' => __('Bahia', 'invoicing'),
661
+        'CE' => __('Ceará', 'invoicing'),
662
+        'DF' => __('Distrito Federal', 'invoicing'),
663
+        'ES' => __('Espírito Santo', 'invoicing'),
664
+        'GO' => __('Goiás', 'invoicing'),
665
+        'MA' => __('Maranhão', 'invoicing'),
666
+        'MT' => __('Mato Grosso', 'invoicing'),
667
+        'MS' => __('Mato Grosso do Sul', 'invoicing'),
668
+        'MG' => __('Minas Gerais', 'invoicing'),
669
+        'PA' => __('Pará', 'invoicing'),
670
+        'PB' => __('Paraíba', 'invoicing'),
671
+        'PR' => __('Paraná', 'invoicing'),
672
+        'PE' => __('Pernambuco', 'invoicing'),
673
+        'PI' => __('Piauí', 'invoicing'),
674
+        'RJ' => __('Rio de Janeiro', 'invoicing'),
675
+        'RN' => __('Rio Grande do Norte', 'invoicing'),
676
+        'RS' => __('Rio Grande do Sul', 'invoicing'),
677
+        'RO' => __('Rondônia', 'invoicing'),
678
+        'RR' => __('Roraima', 'invoicing'),
679
+        'SC' => __('Santa Catarina', 'invoicing'),
680
+        'SP' => __('São Paulo', 'invoicing'),
681
+        'SE' => __('Sergipe', 'invoicing'),
682
+        'TO' => __('Tocantins', 'invoicing')
683 683
     );
684 684
 
685
-    return apply_filters( 'wpinv_brazil_states', $states );
685
+    return apply_filters('wpinv_brazil_states', $states);
686 686
 }
687 687
 
688 688
 function wpinv_get_bulgaria_states_list() {
689 689
     $states = array(
690
-        'BG-01' => __( 'Blagoevgrad', 'invoicing' ),
691
-        'BG-02' => __( 'Burgas', 'invoicing' ),
692
-        'BG-08' => __( 'Dobrich', 'invoicing' ),
693
-        'BG-07' => __( 'Gabrovo', 'invoicing' ),
694
-        'BG-26' => __( 'Haskovo', 'invoicing' ),
695
-        'BG-09' => __( 'Kardzhali', 'invoicing' ),
696
-        'BG-10' => __( 'Kyustendil', 'invoicing' ),
697
-        'BG-11' => __( 'Lovech', 'invoicing' ),
698
-        'BG-12' => __( 'Montana', 'invoicing' ),
699
-        'BG-13' => __( 'Pazardzhik', 'invoicing' ),
700
-        'BG-14' => __( 'Pernik', 'invoicing' ),
701
-        'BG-15' => __( 'Pleven', 'invoicing' ),
702
-        'BG-16' => __( 'Plovdiv', 'invoicing' ),
703
-        'BG-17' => __( 'Razgrad', 'invoicing' ),
704
-        'BG-18' => __( 'Ruse', 'invoicing' ),
705
-        'BG-27' => __( 'Shumen', 'invoicing' ),
706
-        'BG-19' => __( 'Silistra', 'invoicing' ),
707
-        'BG-20' => __( 'Sliven', 'invoicing' ),
708
-        'BG-21' => __( 'Smolyan', 'invoicing' ),
709
-        'BG-23' => __( 'Sofia', 'invoicing' ),
710
-        'BG-22' => __( 'Sofia-Grad', 'invoicing' ),
711
-        'BG-24' => __( 'Stara Zagora', 'invoicing' ),
712
-        'BG-25' => __( 'Targovishte', 'invoicing' ),
713
-        'BG-03' => __( 'Varna', 'invoicing' ),
714
-        'BG-04' => __( 'Veliko Tarnovo', 'invoicing' ),
715
-        'BG-05' => __( 'Vidin', 'invoicing' ),
716
-        'BG-06' => __( 'Vratsa', 'invoicing' ),
717
-        'BG-28' => __( 'Yambol', 'invoicing' )
690
+        'BG-01' => __('Blagoevgrad', 'invoicing'),
691
+        'BG-02' => __('Burgas', 'invoicing'),
692
+        'BG-08' => __('Dobrich', 'invoicing'),
693
+        'BG-07' => __('Gabrovo', 'invoicing'),
694
+        'BG-26' => __('Haskovo', 'invoicing'),
695
+        'BG-09' => __('Kardzhali', 'invoicing'),
696
+        'BG-10' => __('Kyustendil', 'invoicing'),
697
+        'BG-11' => __('Lovech', 'invoicing'),
698
+        'BG-12' => __('Montana', 'invoicing'),
699
+        'BG-13' => __('Pazardzhik', 'invoicing'),
700
+        'BG-14' => __('Pernik', 'invoicing'),
701
+        'BG-15' => __('Pleven', 'invoicing'),
702
+        'BG-16' => __('Plovdiv', 'invoicing'),
703
+        'BG-17' => __('Razgrad', 'invoicing'),
704
+        'BG-18' => __('Ruse', 'invoicing'),
705
+        'BG-27' => __('Shumen', 'invoicing'),
706
+        'BG-19' => __('Silistra', 'invoicing'),
707
+        'BG-20' => __('Sliven', 'invoicing'),
708
+        'BG-21' => __('Smolyan', 'invoicing'),
709
+        'BG-23' => __('Sofia', 'invoicing'),
710
+        'BG-22' => __('Sofia-Grad', 'invoicing'),
711
+        'BG-24' => __('Stara Zagora', 'invoicing'),
712
+        'BG-25' => __('Targovishte', 'invoicing'),
713
+        'BG-03' => __('Varna', 'invoicing'),
714
+        'BG-04' => __('Veliko Tarnovo', 'invoicing'),
715
+        'BG-05' => __('Vidin', 'invoicing'),
716
+        'BG-06' => __('Vratsa', 'invoicing'),
717
+        'BG-28' => __('Yambol', 'invoicing')
718 718
     );
719 719
 
720
-    return apply_filters( 'wpinv_bulgaria_states', $states );
720
+    return apply_filters('wpinv_bulgaria_states', $states);
721 721
 }
722 722
 
723 723
 function wpinv_get_hong_kong_states_list() {
724 724
     $states = array(
725
-        'HONG KONG'       => __( 'Hong Kong Island', 'invoicing' ),
726
-        'KOWLOON'         => __( 'Kowloon', 'invoicing' ),
727
-        'NEW TERRITORIES' => __( 'New Territories', 'invoicing' )
725
+        'HONG KONG'       => __('Hong Kong Island', 'invoicing'),
726
+        'KOWLOON'         => __('Kowloon', 'invoicing'),
727
+        'NEW TERRITORIES' => __('New Territories', 'invoicing')
728 728
     );
729 729
 
730
-    return apply_filters( 'wpinv_hong_kong_states', $states );
730
+    return apply_filters('wpinv_hong_kong_states', $states);
731 731
 }
732 732
 
733 733
 function wpinv_get_hungary_states_list() {
734 734
     $states = array(
735
-        'BK' => __( 'Bács-Kiskun', 'invoicing' ),
736
-        'BE' => __( 'Békés', 'invoicing' ),
737
-        'BA' => __( 'Baranya', 'invoicing' ),
738
-        'BZ' => __( 'Borsod-Abaúj-Zemplén', 'invoicing' ),
739
-        'BU' => __( 'Budapest', 'invoicing' ),
740
-        'CS' => __( 'Csongrád', 'invoicing' ),
741
-        'FE' => __( 'Fejér', 'invoicing' ),
742
-        'GS' => __( 'Győr-Moson-Sopron', 'invoicing' ),
743
-        'HB' => __( 'Hajdú-Bihar', 'invoicing' ),
744
-        'HE' => __( 'Heves', 'invoicing' ),
745
-        'JN' => __( 'Jász-Nagykun-Szolnok', 'invoicing' ),
746
-        'KE' => __( 'Komárom-Esztergom', 'invoicing' ),
747
-        'NO' => __( 'Nógrád', 'invoicing' ),
748
-        'PE' => __( 'Pest', 'invoicing' ),
749
-        'SO' => __( 'Somogy', 'invoicing' ),
750
-        'SZ' => __( 'Szabolcs-Szatmár-Bereg', 'invoicing' ),
751
-        'TO' => __( 'Tolna', 'invoicing' ),
752
-        'VA' => __( 'Vas', 'invoicing' ),
753
-        'VE' => __( 'Veszprém', 'invoicing' ),
754
-        'ZA' => __( 'Zala', 'invoicing' )
735
+        'BK' => __('Bács-Kiskun', 'invoicing'),
736
+        'BE' => __('Békés', 'invoicing'),
737
+        'BA' => __('Baranya', 'invoicing'),
738
+        'BZ' => __('Borsod-Abaúj-Zemplén', 'invoicing'),
739
+        'BU' => __('Budapest', 'invoicing'),
740
+        'CS' => __('Csongrád', 'invoicing'),
741
+        'FE' => __('Fejér', 'invoicing'),
742
+        'GS' => __('Győr-Moson-Sopron', 'invoicing'),
743
+        'HB' => __('Hajdú-Bihar', 'invoicing'),
744
+        'HE' => __('Heves', 'invoicing'),
745
+        'JN' => __('Jász-Nagykun-Szolnok', 'invoicing'),
746
+        'KE' => __('Komárom-Esztergom', 'invoicing'),
747
+        'NO' => __('Nógrád', 'invoicing'),
748
+        'PE' => __('Pest', 'invoicing'),
749
+        'SO' => __('Somogy', 'invoicing'),
750
+        'SZ' => __('Szabolcs-Szatmár-Bereg', 'invoicing'),
751
+        'TO' => __('Tolna', 'invoicing'),
752
+        'VA' => __('Vas', 'invoicing'),
753
+        'VE' => __('Veszprém', 'invoicing'),
754
+        'ZA' => __('Zala', 'invoicing')
755 755
     );
756 756
 
757
-    return apply_filters( 'wpinv_hungary_states', $states );
757
+    return apply_filters('wpinv_hungary_states', $states);
758 758
 }
759 759
 
760 760
 function wpinv_get_japan_states_list() {
761 761
     $states = array(
762
-        'JP01' => __( 'Hokkaido', 'invoicing' ),
763
-        'JP02' => __( 'Aomori', 'invoicing' ),
764
-        'JP03' => __( 'Iwate', 'invoicing' ),
765
-        'JP04' => __( 'Miyagi', 'invoicing' ),
766
-        'JP05' => __( 'Akita', 'invoicing' ),
767
-        'JP06' => __( 'Yamagata', 'invoicing' ),
768
-        'JP07' => __( 'Fukushima', 'invoicing' ),
769
-        'JP08' => __( 'Ibaraki', 'invoicing' ),
770
-        'JP09' => __( 'Tochigi', 'invoicing' ),
771
-        'JP10' => __( 'Gunma', 'invoicing' ),
772
-        'JP11' => __( 'Saitama', 'invoicing' ),
773
-        'JP12' => __( 'Chiba', 'invoicing' ),
774
-        'JP13' => __( 'Tokyo', 'invoicing' ),
775
-        'JP14' => __( 'Kanagawa', 'invoicing' ),
776
-        'JP15' => __( 'Niigata', 'invoicing' ),
777
-        'JP16' => __( 'Toyama', 'invoicing' ),
778
-        'JP17' => __( 'Ishikawa', 'invoicing' ),
779
-        'JP18' => __( 'Fukui', 'invoicing' ),
780
-        'JP19' => __( 'Yamanashi', 'invoicing' ),
781
-        'JP20' => __( 'Nagano', 'invoicing' ),
782
-        'JP21' => __( 'Gifu', 'invoicing' ),
783
-        'JP22' => __( 'Shizuoka', 'invoicing' ),
784
-        'JP23' => __( 'Aichi', 'invoicing' ),
785
-        'JP24' => __( 'Mie', 'invoicing' ),
786
-        'JP25' => __( 'Shiga', 'invoicing' ),
787
-        'JP26' => __( 'Kyouto', 'invoicing' ),
788
-        'JP27' => __( 'Osaka', 'invoicing' ),
789
-        'JP28' => __( 'Hyougo', 'invoicing' ),
790
-        'JP29' => __( 'Nara', 'invoicing' ),
791
-        'JP30' => __( 'Wakayama', 'invoicing' ),
792
-        'JP31' => __( 'Tottori', 'invoicing' ),
793
-        'JP32' => __( 'Shimane', 'invoicing' ),
794
-        'JP33' => __( 'Okayama', 'invoicing' ),
795
-        'JP34' => __( 'Hiroshima', 'invoicing' ),
796
-        'JP35' => __( 'Yamaguchi', 'invoicing' ),
797
-        'JP36' => __( 'Tokushima', 'invoicing' ),
798
-        'JP37' => __( 'Kagawa', 'invoicing' ),
799
-        'JP38' => __( 'Ehime', 'invoicing' ),
800
-        'JP39' => __( 'Kochi', 'invoicing' ),
801
-        'JP40' => __( 'Fukuoka', 'invoicing' ),
802
-        'JP41' => __( 'Saga', 'invoicing' ),
803
-        'JP42' => __( 'Nagasaki', 'invoicing' ),
804
-        'JP43' => __( 'Kumamoto', 'invoicing' ),
805
-        'JP44' => __( 'Oita', 'invoicing' ),
806
-        'JP45' => __( 'Miyazaki', 'invoicing' ),
807
-        'JP46' => __( 'Kagoshima', 'invoicing' ),
808
-        'JP47' => __( 'Okinawa', 'invoicing' )
762
+        'JP01' => __('Hokkaido', 'invoicing'),
763
+        'JP02' => __('Aomori', 'invoicing'),
764
+        'JP03' => __('Iwate', 'invoicing'),
765
+        'JP04' => __('Miyagi', 'invoicing'),
766
+        'JP05' => __('Akita', 'invoicing'),
767
+        'JP06' => __('Yamagata', 'invoicing'),
768
+        'JP07' => __('Fukushima', 'invoicing'),
769
+        'JP08' => __('Ibaraki', 'invoicing'),
770
+        'JP09' => __('Tochigi', 'invoicing'),
771
+        'JP10' => __('Gunma', 'invoicing'),
772
+        'JP11' => __('Saitama', 'invoicing'),
773
+        'JP12' => __('Chiba', 'invoicing'),
774
+        'JP13' => __('Tokyo', 'invoicing'),
775
+        'JP14' => __('Kanagawa', 'invoicing'),
776
+        'JP15' => __('Niigata', 'invoicing'),
777
+        'JP16' => __('Toyama', 'invoicing'),
778
+        'JP17' => __('Ishikawa', 'invoicing'),
779
+        'JP18' => __('Fukui', 'invoicing'),
780
+        'JP19' => __('Yamanashi', 'invoicing'),
781
+        'JP20' => __('Nagano', 'invoicing'),
782
+        'JP21' => __('Gifu', 'invoicing'),
783
+        'JP22' => __('Shizuoka', 'invoicing'),
784
+        'JP23' => __('Aichi', 'invoicing'),
785
+        'JP24' => __('Mie', 'invoicing'),
786
+        'JP25' => __('Shiga', 'invoicing'),
787
+        'JP26' => __('Kyouto', 'invoicing'),
788
+        'JP27' => __('Osaka', 'invoicing'),
789
+        'JP28' => __('Hyougo', 'invoicing'),
790
+        'JP29' => __('Nara', 'invoicing'),
791
+        'JP30' => __('Wakayama', 'invoicing'),
792
+        'JP31' => __('Tottori', 'invoicing'),
793
+        'JP32' => __('Shimane', 'invoicing'),
794
+        'JP33' => __('Okayama', 'invoicing'),
795
+        'JP34' => __('Hiroshima', 'invoicing'),
796
+        'JP35' => __('Yamaguchi', 'invoicing'),
797
+        'JP36' => __('Tokushima', 'invoicing'),
798
+        'JP37' => __('Kagawa', 'invoicing'),
799
+        'JP38' => __('Ehime', 'invoicing'),
800
+        'JP39' => __('Kochi', 'invoicing'),
801
+        'JP40' => __('Fukuoka', 'invoicing'),
802
+        'JP41' => __('Saga', 'invoicing'),
803
+        'JP42' => __('Nagasaki', 'invoicing'),
804
+        'JP43' => __('Kumamoto', 'invoicing'),
805
+        'JP44' => __('Oita', 'invoicing'),
806
+        'JP45' => __('Miyazaki', 'invoicing'),
807
+        'JP46' => __('Kagoshima', 'invoicing'),
808
+        'JP47' => __('Okinawa', 'invoicing')
809 809
     );
810 810
 
811
-    return apply_filters( 'wpinv_japan_states', $states );
811
+    return apply_filters('wpinv_japan_states', $states);
812 812
 }
813 813
 
814 814
 function wpinv_get_china_states_list() {
815 815
     $states = array(
816
-        'CN1'  => __( 'Yunnan / 云南', 'invoicing' ),
817
-        'CN2'  => __( 'Beijing / 北京', 'invoicing' ),
818
-        'CN3'  => __( 'Tianjin / 天津', 'invoicing' ),
819
-        'CN4'  => __( 'Hebei / 河北', 'invoicing' ),
820
-        'CN5'  => __( 'Shanxi / 山西', 'invoicing' ),
821
-        'CN6'  => __( 'Inner Mongolia / 內蒙古', 'invoicing' ),
822
-        'CN7'  => __( 'Liaoning / 辽宁', 'invoicing' ),
823
-        'CN8'  => __( 'Jilin / 吉林', 'invoicing' ),
824
-        'CN9'  => __( 'Heilongjiang / 黑龙江', 'invoicing' ),
825
-        'CN10' => __( 'Shanghai / 上海', 'invoicing' ),
826
-        'CN11' => __( 'Jiangsu / 江苏', 'invoicing' ),
827
-        'CN12' => __( 'Zhejiang / 浙江', 'invoicing' ),
828
-        'CN13' => __( 'Anhui / 安徽', 'invoicing' ),
829
-        'CN14' => __( 'Fujian / 福建', 'invoicing' ),
830
-        'CN15' => __( 'Jiangxi / 江西', 'invoicing' ),
831
-        'CN16' => __( 'Shandong / 山东', 'invoicing' ),
832
-        'CN17' => __( 'Henan / 河南', 'invoicing' ),
833
-        'CN18' => __( 'Hubei / 湖北', 'invoicing' ),
834
-        'CN19' => __( 'Hunan / 湖南', 'invoicing' ),
835
-        'CN20' => __( 'Guangdong / 广东', 'invoicing' ),
836
-        'CN21' => __( 'Guangxi Zhuang / 广西壮族', 'invoicing' ),
837
-        'CN22' => __( 'Hainan / 海南', 'invoicing' ),
838
-        'CN23' => __( 'Chongqing / 重庆', 'invoicing' ),
839
-        'CN24' => __( 'Sichuan / 四川', 'invoicing' ),
840
-        'CN25' => __( 'Guizhou / 贵州', 'invoicing' ),
841
-        'CN26' => __( 'Shaanxi / 陕西', 'invoicing' ),
842
-        'CN27' => __( 'Gansu / 甘肃', 'invoicing' ),
843
-        'CN28' => __( 'Qinghai / 青海', 'invoicing' ),
844
-        'CN29' => __( 'Ningxia Hui / 宁夏', 'invoicing' ),
845
-        'CN30' => __( 'Macau / 澳门', 'invoicing' ),
846
-        'CN31' => __( 'Tibet / 西藏', 'invoicing' ),
847
-        'CN32' => __( 'Xinjiang / 新疆', 'invoicing' )
816
+        'CN1'  => __('Yunnan / 云南', 'invoicing'),
817
+        'CN2'  => __('Beijing / 北京', 'invoicing'),
818
+        'CN3'  => __('Tianjin / 天津', 'invoicing'),
819
+        'CN4'  => __('Hebei / 河北', 'invoicing'),
820
+        'CN5'  => __('Shanxi / 山西', 'invoicing'),
821
+        'CN6'  => __('Inner Mongolia / 內蒙古', 'invoicing'),
822
+        'CN7'  => __('Liaoning / 辽宁', 'invoicing'),
823
+        'CN8'  => __('Jilin / 吉林', 'invoicing'),
824
+        'CN9'  => __('Heilongjiang / 黑龙江', 'invoicing'),
825
+        'CN10' => __('Shanghai / 上海', 'invoicing'),
826
+        'CN11' => __('Jiangsu / 江苏', 'invoicing'),
827
+        'CN12' => __('Zhejiang / 浙江', 'invoicing'),
828
+        'CN13' => __('Anhui / 安徽', 'invoicing'),
829
+        'CN14' => __('Fujian / 福建', 'invoicing'),
830
+        'CN15' => __('Jiangxi / 江西', 'invoicing'),
831
+        'CN16' => __('Shandong / 山东', 'invoicing'),
832
+        'CN17' => __('Henan / 河南', 'invoicing'),
833
+        'CN18' => __('Hubei / 湖北', 'invoicing'),
834
+        'CN19' => __('Hunan / 湖南', 'invoicing'),
835
+        'CN20' => __('Guangdong / 广东', 'invoicing'),
836
+        'CN21' => __('Guangxi Zhuang / 广西壮族', 'invoicing'),
837
+        'CN22' => __('Hainan / 海南', 'invoicing'),
838
+        'CN23' => __('Chongqing / 重庆', 'invoicing'),
839
+        'CN24' => __('Sichuan / 四川', 'invoicing'),
840
+        'CN25' => __('Guizhou / 贵州', 'invoicing'),
841
+        'CN26' => __('Shaanxi / 陕西', 'invoicing'),
842
+        'CN27' => __('Gansu / 甘肃', 'invoicing'),
843
+        'CN28' => __('Qinghai / 青海', 'invoicing'),
844
+        'CN29' => __('Ningxia Hui / 宁夏', 'invoicing'),
845
+        'CN30' => __('Macau / 澳门', 'invoicing'),
846
+        'CN31' => __('Tibet / 西藏', 'invoicing'),
847
+        'CN32' => __('Xinjiang / 新疆', 'invoicing')
848 848
     );
849 849
 
850
-    return apply_filters( 'wpinv_china_states', $states );
850
+    return apply_filters('wpinv_china_states', $states);
851 851
 }
852 852
 
853 853
 function wpinv_get_new_zealand_states_list() {
854 854
     $states = array(
855
-        'AK' => __( 'Auckland', 'invoicing' ),
856
-        'BP' => __( 'Bay of Plenty', 'invoicing' ),
857
-        'CT' => __( 'Canterbury', 'invoicing' ),
858
-        'HB' => __( 'Hawke’s Bay', 'invoicing' ),
859
-        'MW' => __( 'Manawatu-Wanganui', 'invoicing' ),
860
-        'MB' => __( 'Marlborough', 'invoicing' ),
861
-        'NS' => __( 'Nelson', 'invoicing' ),
862
-        'NL' => __( 'Northland', 'invoicing' ),
863
-        'OT' => __( 'Otago', 'invoicing' ),
864
-        'SL' => __( 'Southland', 'invoicing' ),
865
-        'TK' => __( 'Taranaki', 'invoicing' ),
866
-        'TM' => __( 'Tasman', 'invoicing' ),
867
-        'WA' => __( 'Waikato', 'invoicing' ),
868
-        'WR' => __( 'Wairarapa', 'invoicing' ),
869
-        'WE' => __( 'Wellington', 'invoicing' ),
870
-        'WC' => __( 'West Coast', 'invoicing' )
855
+        'AK' => __('Auckland', 'invoicing'),
856
+        'BP' => __('Bay of Plenty', 'invoicing'),
857
+        'CT' => __('Canterbury', 'invoicing'),
858
+        'HB' => __('Hawke’s Bay', 'invoicing'),
859
+        'MW' => __('Manawatu-Wanganui', 'invoicing'),
860
+        'MB' => __('Marlborough', 'invoicing'),
861
+        'NS' => __('Nelson', 'invoicing'),
862
+        'NL' => __('Northland', 'invoicing'),
863
+        'OT' => __('Otago', 'invoicing'),
864
+        'SL' => __('Southland', 'invoicing'),
865
+        'TK' => __('Taranaki', 'invoicing'),
866
+        'TM' => __('Tasman', 'invoicing'),
867
+        'WA' => __('Waikato', 'invoicing'),
868
+        'WR' => __('Wairarapa', 'invoicing'),
869
+        'WE' => __('Wellington', 'invoicing'),
870
+        'WC' => __('West Coast', 'invoicing')
871 871
     );
872 872
 
873
-    return apply_filters( 'wpinv_new_zealand_states', $states );
873
+    return apply_filters('wpinv_new_zealand_states', $states);
874 874
 }
875 875
 
876 876
 function wpinv_get_peru_states_list() {
877 877
     $states = array(
878
-        'CAL' => __( 'El Callao', 'invoicing' ),
879
-        'LMA' => __( 'Municipalidad Metropolitana de Lima', 'invoicing' ),
880
-        'AMA' => __( 'Amazonas', 'invoicing' ),
881
-        'ANC' => __( 'Ancash', 'invoicing' ),
882
-        'APU' => __( 'Apurímac', 'invoicing' ),
883
-        'ARE' => __( 'Arequipa', 'invoicing' ),
884
-        'AYA' => __( 'Ayacucho', 'invoicing' ),
885
-        'CAJ' => __( 'Cajamarca', 'invoicing' ),
886
-        'CUS' => __( 'Cusco', 'invoicing' ),
887
-        'HUV' => __( 'Huancavelica', 'invoicing' ),
888
-        'HUC' => __( 'Huánuco', 'invoicing' ),
889
-        'ICA' => __( 'Ica', 'invoicing' ),
890
-        'JUN' => __( 'Junín', 'invoicing' ),
891
-        'LAL' => __( 'La Libertad', 'invoicing' ),
892
-        'LAM' => __( 'Lambayeque', 'invoicing' ),
893
-        'LIM' => __( 'Lima', 'invoicing' ),
894
-        'LOR' => __( 'Loreto', 'invoicing' ),
895
-        'MDD' => __( 'Madre de Dios', 'invoicing' ),
896
-        'MOQ' => __( 'Moquegua', 'invoicing' ),
897
-        'PAS' => __( 'Pasco', 'invoicing' ),
898
-        'PIU' => __( 'Piura', 'invoicing' ),
899
-        'PUN' => __( 'Puno', 'invoicing' ),
900
-        'SAM' => __( 'San Martín', 'invoicing' ),
901
-        'TAC' => __( 'Tacna', 'invoicing' ),
902
-        'TUM' => __( 'Tumbes', 'invoicing' ),
903
-        'UCA' => __( 'Ucayali', 'invoicing' )
878
+        'CAL' => __('El Callao', 'invoicing'),
879
+        'LMA' => __('Municipalidad Metropolitana de Lima', 'invoicing'),
880
+        'AMA' => __('Amazonas', 'invoicing'),
881
+        'ANC' => __('Ancash', 'invoicing'),
882
+        'APU' => __('Apurímac', 'invoicing'),
883
+        'ARE' => __('Arequipa', 'invoicing'),
884
+        'AYA' => __('Ayacucho', 'invoicing'),
885
+        'CAJ' => __('Cajamarca', 'invoicing'),
886
+        'CUS' => __('Cusco', 'invoicing'),
887
+        'HUV' => __('Huancavelica', 'invoicing'),
888
+        'HUC' => __('Huánuco', 'invoicing'),
889
+        'ICA' => __('Ica', 'invoicing'),
890
+        'JUN' => __('Junín', 'invoicing'),
891
+        'LAL' => __('La Libertad', 'invoicing'),
892
+        'LAM' => __('Lambayeque', 'invoicing'),
893
+        'LIM' => __('Lima', 'invoicing'),
894
+        'LOR' => __('Loreto', 'invoicing'),
895
+        'MDD' => __('Madre de Dios', 'invoicing'),
896
+        'MOQ' => __('Moquegua', 'invoicing'),
897
+        'PAS' => __('Pasco', 'invoicing'),
898
+        'PIU' => __('Piura', 'invoicing'),
899
+        'PUN' => __('Puno', 'invoicing'),
900
+        'SAM' => __('San Martín', 'invoicing'),
901
+        'TAC' => __('Tacna', 'invoicing'),
902
+        'TUM' => __('Tumbes', 'invoicing'),
903
+        'UCA' => __('Ucayali', 'invoicing')
904 904
     );
905 905
 
906
-    return apply_filters( 'wpinv_peru_states', $states );
906
+    return apply_filters('wpinv_peru_states', $states);
907 907
 }
908 908
 
909 909
 function wpinv_get_indonesia_states_list() {
910
-    $states  = array(
911
-        'AC' => __( 'Daerah Istimewa Aceh', 'invoicing' ),
912
-        'SU' => __( 'Sumatera Utara', 'invoicing' ),
913
-        'SB' => __( 'Sumatera Barat', 'invoicing' ),
914
-        'RI' => __( 'Riau', 'invoicing' ),
915
-        'KR' => __( 'Kepulauan Riau', 'invoicing' ),
916
-        'JA' => __( 'Jambi', 'invoicing' ),
917
-        'SS' => __( 'Sumatera Selatan', 'invoicing' ),
918
-        'BB' => __( 'Bangka Belitung', 'invoicing' ),
919
-        'BE' => __( 'Bengkulu', 'invoicing' ),
920
-        'LA' => __( 'Lampung', 'invoicing' ),
921
-        'JK' => __( 'DKI Jakarta', 'invoicing' ),
922
-        'JB' => __( 'Jawa Barat', 'invoicing' ),
923
-        'BT' => __( 'Banten', 'invoicing' ),
924
-        'JT' => __( 'Jawa Tengah', 'invoicing' ),
925
-        'JI' => __( 'Jawa Timur', 'invoicing' ),
926
-        'YO' => __( 'Daerah Istimewa Yogyakarta', 'invoicing' ),
927
-        'BA' => __( 'Bali', 'invoicing' ),
928
-        'NB' => __( 'Nusa Tenggara Barat', 'invoicing' ),
929
-        'NT' => __( 'Nusa Tenggara Timur', 'invoicing' ),
930
-        'KB' => __( 'Kalimantan Barat', 'invoicing' ),
931
-        'KT' => __( 'Kalimantan Tengah', 'invoicing' ),
932
-        'KI' => __( 'Kalimantan Timur', 'invoicing' ),
933
-        'KS' => __( 'Kalimantan Selatan', 'invoicing' ),
934
-        'KU' => __( 'Kalimantan Utara', 'invoicing' ),
935
-        'SA' => __( 'Sulawesi Utara', 'invoicing' ),
936
-        'ST' => __( 'Sulawesi Tengah', 'invoicing' ),
937
-        'SG' => __( 'Sulawesi Tenggara', 'invoicing' ),
938
-        'SR' => __( 'Sulawesi Barat', 'invoicing' ),
939
-        'SN' => __( 'Sulawesi Selatan', 'invoicing' ),
940
-        'GO' => __( 'Gorontalo', 'invoicing' ),
941
-        'MA' => __( 'Maluku', 'invoicing' ),
942
-        'MU' => __( 'Maluku Utara', 'invoicing' ),
943
-        'PA' => __( 'Papua', 'invoicing' ),
944
-        'PB' => __( 'Papua Barat', 'invoicing' )
910
+    $states = array(
911
+        'AC' => __('Daerah Istimewa Aceh', 'invoicing'),
912
+        'SU' => __('Sumatera Utara', 'invoicing'),
913
+        'SB' => __('Sumatera Barat', 'invoicing'),
914
+        'RI' => __('Riau', 'invoicing'),
915
+        'KR' => __('Kepulauan Riau', 'invoicing'),
916
+        'JA' => __('Jambi', 'invoicing'),
917
+        'SS' => __('Sumatera Selatan', 'invoicing'),
918
+        'BB' => __('Bangka Belitung', 'invoicing'),
919
+        'BE' => __('Bengkulu', 'invoicing'),
920
+        'LA' => __('Lampung', 'invoicing'),
921
+        'JK' => __('DKI Jakarta', 'invoicing'),
922
+        'JB' => __('Jawa Barat', 'invoicing'),
923
+        'BT' => __('Banten', 'invoicing'),
924
+        'JT' => __('Jawa Tengah', 'invoicing'),
925
+        'JI' => __('Jawa Timur', 'invoicing'),
926
+        'YO' => __('Daerah Istimewa Yogyakarta', 'invoicing'),
927
+        'BA' => __('Bali', 'invoicing'),
928
+        'NB' => __('Nusa Tenggara Barat', 'invoicing'),
929
+        'NT' => __('Nusa Tenggara Timur', 'invoicing'),
930
+        'KB' => __('Kalimantan Barat', 'invoicing'),
931
+        'KT' => __('Kalimantan Tengah', 'invoicing'),
932
+        'KI' => __('Kalimantan Timur', 'invoicing'),
933
+        'KS' => __('Kalimantan Selatan', 'invoicing'),
934
+        'KU' => __('Kalimantan Utara', 'invoicing'),
935
+        'SA' => __('Sulawesi Utara', 'invoicing'),
936
+        'ST' => __('Sulawesi Tengah', 'invoicing'),
937
+        'SG' => __('Sulawesi Tenggara', 'invoicing'),
938
+        'SR' => __('Sulawesi Barat', 'invoicing'),
939
+        'SN' => __('Sulawesi Selatan', 'invoicing'),
940
+        'GO' => __('Gorontalo', 'invoicing'),
941
+        'MA' => __('Maluku', 'invoicing'),
942
+        'MU' => __('Maluku Utara', 'invoicing'),
943
+        'PA' => __('Papua', 'invoicing'),
944
+        'PB' => __('Papua Barat', 'invoicing')
945 945
     );
946 946
 
947
-    return apply_filters( 'wpinv_indonesia_states', $states );
947
+    return apply_filters('wpinv_indonesia_states', $states);
948 948
 }
949 949
 
950 950
 function wpinv_get_india_states_list() {
951 951
     $states = array(
952
-        'AP' => __( 'Andhra Pradesh', 'invoicing' ),
953
-        'AR' => __( 'Arunachal Pradesh', 'invoicing' ),
954
-        'AS' => __( 'Assam', 'invoicing' ),
955
-        'BR' => __( 'Bihar', 'invoicing' ),
956
-        'CT' => __( 'Chhattisgarh', 'invoicing' ),
957
-        'GA' => __( 'Goa', 'invoicing' ),
958
-        'GJ' => __( 'Gujarat', 'invoicing' ),
959
-        'HR' => __( 'Haryana', 'invoicing' ),
960
-        'HP' => __( 'Himachal Pradesh', 'invoicing' ),
961
-        'JK' => __( 'Jammu and Kashmir', 'invoicing' ),
962
-        'JH' => __( 'Jharkhand', 'invoicing' ),
963
-        'KA' => __( 'Karnataka', 'invoicing' ),
964
-        'KL' => __( 'Kerala', 'invoicing' ),
965
-        'MP' => __( 'Madhya Pradesh', 'invoicing' ),
966
-        'MH' => __( 'Maharashtra', 'invoicing' ),
967
-        'MN' => __( 'Manipur', 'invoicing' ),
968
-        'ML' => __( 'Meghalaya', 'invoicing' ),
969
-        'MZ' => __( 'Mizoram', 'invoicing' ),
970
-        'NL' => __( 'Nagaland', 'invoicing' ),
971
-        'OR' => __( 'Orissa', 'invoicing' ),
972
-        'PB' => __( 'Punjab', 'invoicing' ),
973
-        'RJ' => __( 'Rajasthan', 'invoicing' ),
974
-        'SK' => __( 'Sikkim', 'invoicing' ),
975
-        'TN' => __( 'Tamil Nadu', 'invoicing' ),
976
-        'TG' => __( 'Telangana', 'invoicing' ),
977
-        'TR' => __( 'Tripura', 'invoicing' ),
978
-        'UT' => __( 'Uttarakhand', 'invoicing' ),
979
-        'UP' => __( 'Uttar Pradesh', 'invoicing' ),
980
-        'WB' => __( 'West Bengal', 'invoicing' ),
981
-        'AN' => __( 'Andaman and Nicobar Islands', 'invoicing' ),
982
-        'CH' => __( 'Chandigarh', 'invoicing' ),
983
-        'DN' => __( 'Dadar and Nagar Haveli', 'invoicing' ),
984
-        'DD' => __( 'Daman and Diu', 'invoicing' ),
985
-        'DL' => __( 'Delhi', 'invoicing' ),
986
-        'LD' => __( 'Lakshadweep', 'invoicing' ),
987
-        'PY' => __( 'Pondicherry (Puducherry)', 'invoicing' )
952
+        'AP' => __('Andhra Pradesh', 'invoicing'),
953
+        'AR' => __('Arunachal Pradesh', 'invoicing'),
954
+        'AS' => __('Assam', 'invoicing'),
955
+        'BR' => __('Bihar', 'invoicing'),
956
+        'CT' => __('Chhattisgarh', 'invoicing'),
957
+        'GA' => __('Goa', 'invoicing'),
958
+        'GJ' => __('Gujarat', 'invoicing'),
959
+        'HR' => __('Haryana', 'invoicing'),
960
+        'HP' => __('Himachal Pradesh', 'invoicing'),
961
+        'JK' => __('Jammu and Kashmir', 'invoicing'),
962
+        'JH' => __('Jharkhand', 'invoicing'),
963
+        'KA' => __('Karnataka', 'invoicing'),
964
+        'KL' => __('Kerala', 'invoicing'),
965
+        'MP' => __('Madhya Pradesh', 'invoicing'),
966
+        'MH' => __('Maharashtra', 'invoicing'),
967
+        'MN' => __('Manipur', 'invoicing'),
968
+        'ML' => __('Meghalaya', 'invoicing'),
969
+        'MZ' => __('Mizoram', 'invoicing'),
970
+        'NL' => __('Nagaland', 'invoicing'),
971
+        'OR' => __('Orissa', 'invoicing'),
972
+        'PB' => __('Punjab', 'invoicing'),
973
+        'RJ' => __('Rajasthan', 'invoicing'),
974
+        'SK' => __('Sikkim', 'invoicing'),
975
+        'TN' => __('Tamil Nadu', 'invoicing'),
976
+        'TG' => __('Telangana', 'invoicing'),
977
+        'TR' => __('Tripura', 'invoicing'),
978
+        'UT' => __('Uttarakhand', 'invoicing'),
979
+        'UP' => __('Uttar Pradesh', 'invoicing'),
980
+        'WB' => __('West Bengal', 'invoicing'),
981
+        'AN' => __('Andaman and Nicobar Islands', 'invoicing'),
982
+        'CH' => __('Chandigarh', 'invoicing'),
983
+        'DN' => __('Dadar and Nagar Haveli', 'invoicing'),
984
+        'DD' => __('Daman and Diu', 'invoicing'),
985
+        'DL' => __('Delhi', 'invoicing'),
986
+        'LD' => __('Lakshadweep', 'invoicing'),
987
+        'PY' => __('Pondicherry (Puducherry)', 'invoicing')
988 988
     );
989 989
 
990
-    return apply_filters( 'wpinv_india_states', $states );
990
+    return apply_filters('wpinv_india_states', $states);
991 991
 }
992 992
 
993 993
 function wpinv_get_iran_states_list() {
994 994
     $states = array(
995
-        'KHZ' => __( 'Khuzestan', 'invoicing' ),
996
-        'THR' => __( 'Tehran', 'invoicing' ),
997
-        'ILM' => __( 'Ilaam', 'invoicing' ),
998
-        'BHR' => __( 'Bushehr', 'invoicing' ),
999
-        'ADL' => __( 'Ardabil', 'invoicing' ),
1000
-        'ESF' => __( 'Isfahan', 'invoicing' ),
1001
-        'YZD' => __( 'Yazd', 'invoicing' ),
1002
-        'KRH' => __( 'Kermanshah', 'invoicing' ),
1003
-        'KRN' => __( 'Kerman', 'invoicing' ),
1004
-        'HDN' => __( 'Hamadan', 'invoicing' ),
1005
-        'GZN' => __( 'Ghazvin', 'invoicing' ),
1006
-        'ZJN' => __( 'Zanjan', 'invoicing' ),
1007
-        'LRS' => __( 'Luristan', 'invoicing' ),
1008
-        'ABZ' => __( 'Alborz', 'invoicing' ),
1009
-        'EAZ' => __( 'East Azerbaijan', 'invoicing' ),
1010
-        'WAZ' => __( 'West Azerbaijan', 'invoicing' ),
1011
-        'CHB' => __( 'Chaharmahal and Bakhtiari', 'invoicing' ),
1012
-        'SKH' => __( 'South Khorasan', 'invoicing' ),
1013
-        'RKH' => __( 'Razavi Khorasan', 'invoicing' ),
1014
-        'NKH' => __( 'North Khorasan', 'invoicing' ),
1015
-        'SMN' => __( 'Semnan', 'invoicing' ),
1016
-        'FRS' => __( 'Fars', 'invoicing' ),
1017
-        'QHM' => __( 'Qom', 'invoicing' ),
1018
-        'KRD' => __( 'Kurdistan', 'invoicing' ),
1019
-        'KBD' => __( 'Kohgiluyeh and BoyerAhmad', 'invoicing' ),
1020
-        'GLS' => __( 'Golestan', 'invoicing' ),
1021
-        'GIL' => __( 'Gilan', 'invoicing' ),
1022
-        'MZN' => __( 'Mazandaran', 'invoicing' ),
1023
-        'MKZ' => __( 'Markazi', 'invoicing' ),
1024
-        'HRZ' => __( 'Hormozgan', 'invoicing' ),
1025
-        'SBN' => __( 'Sistan and Baluchestan', 'invoicing' )
995
+        'KHZ' => __('Khuzestan', 'invoicing'),
996
+        'THR' => __('Tehran', 'invoicing'),
997
+        'ILM' => __('Ilaam', 'invoicing'),
998
+        'BHR' => __('Bushehr', 'invoicing'),
999
+        'ADL' => __('Ardabil', 'invoicing'),
1000
+        'ESF' => __('Isfahan', 'invoicing'),
1001
+        'YZD' => __('Yazd', 'invoicing'),
1002
+        'KRH' => __('Kermanshah', 'invoicing'),
1003
+        'KRN' => __('Kerman', 'invoicing'),
1004
+        'HDN' => __('Hamadan', 'invoicing'),
1005
+        'GZN' => __('Ghazvin', 'invoicing'),
1006
+        'ZJN' => __('Zanjan', 'invoicing'),
1007
+        'LRS' => __('Luristan', 'invoicing'),
1008
+        'ABZ' => __('Alborz', 'invoicing'),
1009
+        'EAZ' => __('East Azerbaijan', 'invoicing'),
1010
+        'WAZ' => __('West Azerbaijan', 'invoicing'),
1011
+        'CHB' => __('Chaharmahal and Bakhtiari', 'invoicing'),
1012
+        'SKH' => __('South Khorasan', 'invoicing'),
1013
+        'RKH' => __('Razavi Khorasan', 'invoicing'),
1014
+        'NKH' => __('North Khorasan', 'invoicing'),
1015
+        'SMN' => __('Semnan', 'invoicing'),
1016
+        'FRS' => __('Fars', 'invoicing'),
1017
+        'QHM' => __('Qom', 'invoicing'),
1018
+        'KRD' => __('Kurdistan', 'invoicing'),
1019
+        'KBD' => __('Kohgiluyeh and BoyerAhmad', 'invoicing'),
1020
+        'GLS' => __('Golestan', 'invoicing'),
1021
+        'GIL' => __('Gilan', 'invoicing'),
1022
+        'MZN' => __('Mazandaran', 'invoicing'),
1023
+        'MKZ' => __('Markazi', 'invoicing'),
1024
+        'HRZ' => __('Hormozgan', 'invoicing'),
1025
+        'SBN' => __('Sistan and Baluchestan', 'invoicing')
1026 1026
     );
1027 1027
 
1028
-    return apply_filters( 'wpinv_iran_states', $states );
1028
+    return apply_filters('wpinv_iran_states', $states);
1029 1029
 }
1030 1030
 
1031 1031
 function wpinv_get_italy_states_list() {
1032 1032
     $states = array(
1033
-        'AG' => __( 'Agrigento', 'invoicing' ),
1034
-        'AL' => __( 'Alessandria', 'invoicing' ),
1035
-        'AN' => __( 'Ancona', 'invoicing' ),
1036
-        'AO' => __( 'Aosta', 'invoicing' ),
1037
-        'AR' => __( 'Arezzo', 'invoicing' ),
1038
-        'AP' => __( 'Ascoli Piceno', 'invoicing' ),
1039
-        'AT' => __( 'Asti', 'invoicing' ),
1040
-        'AV' => __( 'Avellino', 'invoicing' ),
1041
-        'BA' => __( 'Bari', 'invoicing' ),
1042
-        'BT' => __( 'Barletta-Andria-Trani', 'invoicing' ),
1043
-        'BL' => __( 'Belluno', 'invoicing' ),
1044
-        'BN' => __( 'Benevento', 'invoicing' ),
1045
-        'BG' => __( 'Bergamo', 'invoicing' ),
1046
-        'BI' => __( 'Biella', 'invoicing' ),
1047
-        'BO' => __( 'Bologna', 'invoicing' ),
1048
-        'BZ' => __( 'Bolzano', 'invoicing' ),
1049
-        'BS' => __( 'Brescia', 'invoicing' ),
1050
-        'BR' => __( 'Brindisi', 'invoicing' ),
1051
-        'CA' => __( 'Cagliari', 'invoicing' ),
1052
-        'CL' => __( 'Caltanissetta', 'invoicing' ),
1053
-        'CB' => __( 'Campobasso', 'invoicing' ),
1054
-        'CI' => __( 'Caltanissetta', 'invoicing' ),
1055
-        'CE' => __( 'Caserta', 'invoicing' ),
1056
-        'CT' => __( 'Catania', 'invoicing' ),
1057
-        'CZ' => __( 'Catanzaro', 'invoicing' ),
1058
-        'CH' => __( 'Chieti', 'invoicing' ),
1059
-        'CO' => __( 'Como', 'invoicing' ),
1060
-        'CS' => __( 'Cosenza', 'invoicing' ),
1061
-        'CR' => __( 'Cremona', 'invoicing' ),
1062
-        'KR' => __( 'Crotone', 'invoicing' ),
1063
-        'CN' => __( 'Cuneo', 'invoicing' ),
1064
-        'EN' => __( 'Enna', 'invoicing' ),
1065
-        'FM' => __( 'Fermo', 'invoicing' ),
1066
-        'FE' => __( 'Ferrara', 'invoicing' ),
1067
-        'FI' => __( 'Firenze', 'invoicing' ),
1068
-        'FG' => __( 'Foggia', 'invoicing' ),
1069
-        'FC' => __( 'Forli-Cesena', 'invoicing' ),
1070
-        'FR' => __( 'Frosinone', 'invoicing' ),
1071
-        'GE' => __( 'Genova', 'invoicing' ),
1072
-        'GO' => __( 'Gorizia', 'invoicing' ),
1073
-        'GR' => __( 'Grosseto', 'invoicing' ),
1074
-        'IM' => __( 'Imperia', 'invoicing' ),
1075
-        'IS' => __( 'Isernia', 'invoicing' ),
1076
-        'SP' => __( 'La Spezia', 'invoicing' ),
1077
-        'AQ' => __( 'L'Aquila', 'invoicing' ),
1078
-        'LT' => __( 'Latina', 'invoicing' ),
1079
-        'LE' => __( 'Lecce', 'invoicing' ),
1080
-        'LC' => __( 'Lecco', 'invoicing' ),
1081
-        'LI' => __( 'Livorno', 'invoicing' ),
1082
-        'LO' => __( 'Lodi', 'invoicing' ),
1083
-        'LU' => __( 'Lucca', 'invoicing' ),
1084
-        'MC' => __( 'Macerata', 'invoicing' ),
1085
-        'MN' => __( 'Mantova', 'invoicing' ),
1086
-        'MS' => __( 'Massa-Carrara', 'invoicing' ),
1087
-        'MT' => __( 'Matera', 'invoicing' ),
1088
-        'ME' => __( 'Messina', 'invoicing' ),
1089
-        'MI' => __( 'Milano', 'invoicing' ),
1090
-        'MO' => __( 'Modena', 'invoicing' ),
1091
-        'MB' => __( 'Monza e della Brianza', 'invoicing' ),
1092
-        'NA' => __( 'Napoli', 'invoicing' ),
1093
-        'NO' => __( 'Novara', 'invoicing' ),
1094
-        'NU' => __( 'Nuoro', 'invoicing' ),
1095
-        'OT' => __( 'Olbia-Tempio', 'invoicing' ),
1096
-        'OR' => __( 'Oristano', 'invoicing' ),
1097
-        'PD' => __( 'Padova', 'invoicing' ),
1098
-        'PA' => __( 'Palermo', 'invoicing' ),
1099
-        'PR' => __( 'Parma', 'invoicing' ),
1100
-        'PV' => __( 'Pavia', 'invoicing' ),
1101
-        'PG' => __( 'Perugia', 'invoicing' ),
1102
-        'PU' => __( 'Pesaro e Urbino', 'invoicing' ),
1103
-        'PE' => __( 'Pescara', 'invoicing' ),
1104
-        'PC' => __( 'Piacenza', 'invoicing' ),
1105
-        'PI' => __( 'Pisa', 'invoicing' ),
1106
-        'PT' => __( 'Pistoia', 'invoicing' ),
1107
-        'PN' => __( 'Pordenone', 'invoicing' ),
1108
-        'PZ' => __( 'Potenza', 'invoicing' ),
1109
-        'PO' => __( 'Prato', 'invoicing' ),
1110
-        'RG' => __( 'Ragusa', 'invoicing' ),
1111
-        'RA' => __( 'Ravenna', 'invoicing' ),
1112
-        'RC' => __( 'Reggio Calabria', 'invoicing' ),
1113
-        'RE' => __( 'Reggio Emilia', 'invoicing' ),
1114
-        'RI' => __( 'Rieti', 'invoicing' ),
1115
-        'RN' => __( 'Rimini', 'invoicing' ),
1116
-        'RM' => __( 'Roma', 'invoicing' ),
1117
-        'RO' => __( 'Rovigo', 'invoicing' ),
1118
-        'SA' => __( 'Salerno', 'invoicing' ),
1119
-        'VS' => __( 'Medio Campidano', 'invoicing' ),
1120
-        'SS' => __( 'Sassari', 'invoicing' ),
1121
-        'SV' => __( 'Savona', 'invoicing' ),
1122
-        'SI' => __( 'Siena', 'invoicing' ),
1123
-        'SR' => __( 'Siracusa', 'invoicing' ),
1124
-        'SO' => __( 'Sondrio', 'invoicing' ),
1125
-        'TA' => __( 'Taranto', 'invoicing' ),
1126
-        'TE' => __( 'Teramo', 'invoicing' ),
1127
-        'TR' => __( 'Terni', 'invoicing' ),
1128
-        'TO' => __( 'Torino', 'invoicing' ),
1129
-        'OG' => __( 'Ogliastra', 'invoicing' ),
1130
-        'TP' => __( 'Trapani', 'invoicing' ),
1131
-        'TN' => __( 'Trento', 'invoicing' ),
1132
-        'TV' => __( 'Treviso', 'invoicing' ),
1133
-        'TS' => __( 'Trieste', 'invoicing' ),
1134
-        'UD' => __( 'Udine', 'invoicing' ),
1135
-        'VA' => __( 'Varesa', 'invoicing' ),
1136
-        'VE' => __( 'Venezia', 'invoicing' ),
1137
-        'VB' => __( 'Verbano-Cusio-Ossola', 'invoicing' ),
1138
-        'VC' => __( 'Vercelli', 'invoicing' ),
1139
-        'VR' => __( 'Verona', 'invoicing' ),
1140
-        'VV' => __( 'Vibo Valentia', 'invoicing' ),
1141
-        'VI' => __( 'Vicenza', 'invoicing' ),
1142
-        'VT' => __( 'Viterbo', 'invoicing' )
1033
+        'AG' => __('Agrigento', 'invoicing'),
1034
+        'AL' => __('Alessandria', 'invoicing'),
1035
+        'AN' => __('Ancona', 'invoicing'),
1036
+        'AO' => __('Aosta', 'invoicing'),
1037
+        'AR' => __('Arezzo', 'invoicing'),
1038
+        'AP' => __('Ascoli Piceno', 'invoicing'),
1039
+        'AT' => __('Asti', 'invoicing'),
1040
+        'AV' => __('Avellino', 'invoicing'),
1041
+        'BA' => __('Bari', 'invoicing'),
1042
+        'BT' => __('Barletta-Andria-Trani', 'invoicing'),
1043
+        'BL' => __('Belluno', 'invoicing'),
1044
+        'BN' => __('Benevento', 'invoicing'),
1045
+        'BG' => __('Bergamo', 'invoicing'),
1046
+        'BI' => __('Biella', 'invoicing'),
1047
+        'BO' => __('Bologna', 'invoicing'),
1048
+        'BZ' => __('Bolzano', 'invoicing'),
1049
+        'BS' => __('Brescia', 'invoicing'),
1050
+        'BR' => __('Brindisi', 'invoicing'),
1051
+        'CA' => __('Cagliari', 'invoicing'),
1052
+        'CL' => __('Caltanissetta', 'invoicing'),
1053
+        'CB' => __('Campobasso', 'invoicing'),
1054
+        'CI' => __('Caltanissetta', 'invoicing'),
1055
+        'CE' => __('Caserta', 'invoicing'),
1056
+        'CT' => __('Catania', 'invoicing'),
1057
+        'CZ' => __('Catanzaro', 'invoicing'),
1058
+        'CH' => __('Chieti', 'invoicing'),
1059
+        'CO' => __('Como', 'invoicing'),
1060
+        'CS' => __('Cosenza', 'invoicing'),
1061
+        'CR' => __('Cremona', 'invoicing'),
1062
+        'KR' => __('Crotone', 'invoicing'),
1063
+        'CN' => __('Cuneo', 'invoicing'),
1064
+        'EN' => __('Enna', 'invoicing'),
1065
+        'FM' => __('Fermo', 'invoicing'),
1066
+        'FE' => __('Ferrara', 'invoicing'),
1067
+        'FI' => __('Firenze', 'invoicing'),
1068
+        'FG' => __('Foggia', 'invoicing'),
1069
+        'FC' => __('Forli-Cesena', 'invoicing'),
1070
+        'FR' => __('Frosinone', 'invoicing'),
1071
+        'GE' => __('Genova', 'invoicing'),
1072
+        'GO' => __('Gorizia', 'invoicing'),
1073
+        'GR' => __('Grosseto', 'invoicing'),
1074
+        'IM' => __('Imperia', 'invoicing'),
1075
+        'IS' => __('Isernia', 'invoicing'),
1076
+        'SP' => __('La Spezia', 'invoicing'),
1077
+        'AQ' => __('L'Aquila', 'invoicing'),
1078
+        'LT' => __('Latina', 'invoicing'),
1079
+        'LE' => __('Lecce', 'invoicing'),
1080
+        'LC' => __('Lecco', 'invoicing'),
1081
+        'LI' => __('Livorno', 'invoicing'),
1082
+        'LO' => __('Lodi', 'invoicing'),
1083
+        'LU' => __('Lucca', 'invoicing'),
1084
+        'MC' => __('Macerata', 'invoicing'),
1085
+        'MN' => __('Mantova', 'invoicing'),
1086
+        'MS' => __('Massa-Carrara', 'invoicing'),
1087
+        'MT' => __('Matera', 'invoicing'),
1088
+        'ME' => __('Messina', 'invoicing'),
1089
+        'MI' => __('Milano', 'invoicing'),
1090
+        'MO' => __('Modena', 'invoicing'),
1091
+        'MB' => __('Monza e della Brianza', 'invoicing'),
1092
+        'NA' => __('Napoli', 'invoicing'),
1093
+        'NO' => __('Novara', 'invoicing'),
1094
+        'NU' => __('Nuoro', 'invoicing'),
1095
+        'OT' => __('Olbia-Tempio', 'invoicing'),
1096
+        'OR' => __('Oristano', 'invoicing'),
1097
+        'PD' => __('Padova', 'invoicing'),
1098
+        'PA' => __('Palermo', 'invoicing'),
1099
+        'PR' => __('Parma', 'invoicing'),
1100
+        'PV' => __('Pavia', 'invoicing'),
1101
+        'PG' => __('Perugia', 'invoicing'),
1102
+        'PU' => __('Pesaro e Urbino', 'invoicing'),
1103
+        'PE' => __('Pescara', 'invoicing'),
1104
+        'PC' => __('Piacenza', 'invoicing'),
1105
+        'PI' => __('Pisa', 'invoicing'),
1106
+        'PT' => __('Pistoia', 'invoicing'),
1107
+        'PN' => __('Pordenone', 'invoicing'),
1108
+        'PZ' => __('Potenza', 'invoicing'),
1109
+        'PO' => __('Prato', 'invoicing'),
1110
+        'RG' => __('Ragusa', 'invoicing'),
1111
+        'RA' => __('Ravenna', 'invoicing'),
1112
+        'RC' => __('Reggio Calabria', 'invoicing'),
1113
+        'RE' => __('Reggio Emilia', 'invoicing'),
1114
+        'RI' => __('Rieti', 'invoicing'),
1115
+        'RN' => __('Rimini', 'invoicing'),
1116
+        'RM' => __('Roma', 'invoicing'),
1117
+        'RO' => __('Rovigo', 'invoicing'),
1118
+        'SA' => __('Salerno', 'invoicing'),
1119
+        'VS' => __('Medio Campidano', 'invoicing'),
1120
+        'SS' => __('Sassari', 'invoicing'),
1121
+        'SV' => __('Savona', 'invoicing'),
1122
+        'SI' => __('Siena', 'invoicing'),
1123
+        'SR' => __('Siracusa', 'invoicing'),
1124
+        'SO' => __('Sondrio', 'invoicing'),
1125
+        'TA' => __('Taranto', 'invoicing'),
1126
+        'TE' => __('Teramo', 'invoicing'),
1127
+        'TR' => __('Terni', 'invoicing'),
1128
+        'TO' => __('Torino', 'invoicing'),
1129
+        'OG' => __('Ogliastra', 'invoicing'),
1130
+        'TP' => __('Trapani', 'invoicing'),
1131
+        'TN' => __('Trento', 'invoicing'),
1132
+        'TV' => __('Treviso', 'invoicing'),
1133
+        'TS' => __('Trieste', 'invoicing'),
1134
+        'UD' => __('Udine', 'invoicing'),
1135
+        'VA' => __('Varesa', 'invoicing'),
1136
+        'VE' => __('Venezia', 'invoicing'),
1137
+        'VB' => __('Verbano-Cusio-Ossola', 'invoicing'),
1138
+        'VC' => __('Vercelli', 'invoicing'),
1139
+        'VR' => __('Verona', 'invoicing'),
1140
+        'VV' => __('Vibo Valentia', 'invoicing'),
1141
+        'VI' => __('Vicenza', 'invoicing'),
1142
+        'VT' => __('Viterbo', 'invoicing')
1143 1143
     );
1144 1144
 
1145
-    return apply_filters( 'wpinv_italy_states', $states );
1145
+    return apply_filters('wpinv_italy_states', $states);
1146 1146
 }
1147 1147
 
1148 1148
 function wpinv_get_malaysia_states_list() {
1149 1149
     $states = array(
1150
-        'JHR' => __( 'Johor', 'invoicing' ),
1151
-        'KDH' => __( 'Kedah', 'invoicing' ),
1152
-        'KTN' => __( 'Kelantan', 'invoicing' ),
1153
-        'MLK' => __( 'Melaka', 'invoicing' ),
1154
-        'NSN' => __( 'Negeri Sembilan', 'invoicing' ),
1155
-        'PHG' => __( 'Pahang', 'invoicing' ),
1156
-        'PRK' => __( 'Perak', 'invoicing' ),
1157
-        'PLS' => __( 'Perlis', 'invoicing' ),
1158
-        'PNG' => __( 'Pulau Pinang', 'invoicing' ),
1159
-        'SBH' => __( 'Sabah', 'invoicing' ),
1160
-        'SWK' => __( 'Sarawak', 'invoicing' ),
1161
-        'SGR' => __( 'Selangor', 'invoicing' ),
1162
-        'TRG' => __( 'Terengganu', 'invoicing' ),
1163
-        'KUL' => __( 'W.P. Kuala Lumpur', 'invoicing' ),
1164
-        'LBN' => __( 'W.P. Labuan', 'invoicing' ),
1165
-        'PJY' => __( 'W.P. Putrajaya', 'invoicing' )
1150
+        'JHR' => __('Johor', 'invoicing'),
1151
+        'KDH' => __('Kedah', 'invoicing'),
1152
+        'KTN' => __('Kelantan', 'invoicing'),
1153
+        'MLK' => __('Melaka', 'invoicing'),
1154
+        'NSN' => __('Negeri Sembilan', 'invoicing'),
1155
+        'PHG' => __('Pahang', 'invoicing'),
1156
+        'PRK' => __('Perak', 'invoicing'),
1157
+        'PLS' => __('Perlis', 'invoicing'),
1158
+        'PNG' => __('Pulau Pinang', 'invoicing'),
1159
+        'SBH' => __('Sabah', 'invoicing'),
1160
+        'SWK' => __('Sarawak', 'invoicing'),
1161
+        'SGR' => __('Selangor', 'invoicing'),
1162
+        'TRG' => __('Terengganu', 'invoicing'),
1163
+        'KUL' => __('W.P. Kuala Lumpur', 'invoicing'),
1164
+        'LBN' => __('W.P. Labuan', 'invoicing'),
1165
+        'PJY' => __('W.P. Putrajaya', 'invoicing')
1166 1166
     );
1167 1167
 
1168
-    return apply_filters( 'wpinv_malaysia_states', $states );
1168
+    return apply_filters('wpinv_malaysia_states', $states);
1169 1169
 }
1170 1170
 
1171 1171
 function wpinv_get_mexico_states_list() {
1172 1172
     $states = array(
1173
-        'DIF' => __( 'Distrito Federal', 'invoicing' ),
1174
-        'JAL' => __( 'Jalisco', 'invoicing' ),
1175
-        'NLE' => __( 'Nuevo León', 'invoicing' ),
1176
-        'AGU' => __( 'Aguascalientes', 'invoicing' ),
1177
-        'BCN' => __( 'Baja California Norte', 'invoicing' ),
1178
-        'BCS' => __( 'Baja California Sur', 'invoicing' ),
1179
-        'CAM' => __( 'Campeche', 'invoicing' ),
1180
-        'CHP' => __( 'Chiapas', 'invoicing' ),
1181
-        'CHH' => __( 'Chihuahua', 'invoicing' ),
1182
-        'COA' => __( 'Coahuila', 'invoicing' ),
1183
-        'COL' => __( 'Colima', 'invoicing' ),
1184
-        'DUR' => __( 'Durango', 'invoicing' ),
1185
-        'GUA' => __( 'Guanajuato', 'invoicing' ),
1186
-        'GRO' => __( 'Guerrero', 'invoicing' ),
1187
-        'HID' => __( 'Hidalgo', 'invoicing' ),
1188
-        'MEX' => __( 'Edo. de México', 'invoicing' ),
1189
-        'MIC' => __( 'Michoacán', 'invoicing' ),
1190
-        'MOR' => __( 'Morelos', 'invoicing' ),
1191
-        'NAY' => __( 'Nayarit', 'invoicing' ),
1192
-        'OAX' => __( 'Oaxaca', 'invoicing' ),
1193
-        'PUE' => __( 'Puebla', 'invoicing' ),
1194
-        'QUE' => __( 'Querétaro', 'invoicing' ),
1195
-        'ROO' => __( 'Quintana Roo', 'invoicing' ),
1196
-        'SLP' => __( 'San Luis Potosí', 'invoicing' ),
1197
-        'SIN' => __( 'Sinaloa', 'invoicing' ),
1198
-        'SON' => __( 'Sonora', 'invoicing' ),
1199
-        'TAB' => __( 'Tabasco', 'invoicing' ),
1200
-        'TAM' => __( 'Tamaulipas', 'invoicing' ),
1201
-        'TLA' => __( 'Tlaxcala', 'invoicing' ),
1202
-        'VER' => __( 'Veracruz', 'invoicing' ),
1203
-        'YUC' => __( 'Yucatán', 'invoicing' ),
1204
-        'ZAC' => __( 'Zacatecas', 'invoicing' )
1173
+        'DIF' => __('Distrito Federal', 'invoicing'),
1174
+        'JAL' => __('Jalisco', 'invoicing'),
1175
+        'NLE' => __('Nuevo León', 'invoicing'),
1176
+        'AGU' => __('Aguascalientes', 'invoicing'),
1177
+        'BCN' => __('Baja California Norte', 'invoicing'),
1178
+        'BCS' => __('Baja California Sur', 'invoicing'),
1179
+        'CAM' => __('Campeche', 'invoicing'),
1180
+        'CHP' => __('Chiapas', 'invoicing'),
1181
+        'CHH' => __('Chihuahua', 'invoicing'),
1182
+        'COA' => __('Coahuila', 'invoicing'),
1183
+        'COL' => __('Colima', 'invoicing'),
1184
+        'DUR' => __('Durango', 'invoicing'),
1185
+        'GUA' => __('Guanajuato', 'invoicing'),
1186
+        'GRO' => __('Guerrero', 'invoicing'),
1187
+        'HID' => __('Hidalgo', 'invoicing'),
1188
+        'MEX' => __('Edo. de México', 'invoicing'),
1189
+        'MIC' => __('Michoacán', 'invoicing'),
1190
+        'MOR' => __('Morelos', 'invoicing'),
1191
+        'NAY' => __('Nayarit', 'invoicing'),
1192
+        'OAX' => __('Oaxaca', 'invoicing'),
1193
+        'PUE' => __('Puebla', 'invoicing'),
1194
+        'QUE' => __('Querétaro', 'invoicing'),
1195
+        'ROO' => __('Quintana Roo', 'invoicing'),
1196
+        'SLP' => __('San Luis Potosí', 'invoicing'),
1197
+        'SIN' => __('Sinaloa', 'invoicing'),
1198
+        'SON' => __('Sonora', 'invoicing'),
1199
+        'TAB' => __('Tabasco', 'invoicing'),
1200
+        'TAM' => __('Tamaulipas', 'invoicing'),
1201
+        'TLA' => __('Tlaxcala', 'invoicing'),
1202
+        'VER' => __('Veracruz', 'invoicing'),
1203
+        'YUC' => __('Yucatán', 'invoicing'),
1204
+        'ZAC' => __('Zacatecas', 'invoicing')
1205 1205
     );
1206 1206
 
1207
-    return apply_filters( 'wpinv_mexico_states', $states );
1207
+    return apply_filters('wpinv_mexico_states', $states);
1208 1208
 }
1209 1209
 
1210 1210
 function wpinv_get_nepal_states_list() {
1211 1211
     $states = array(
1212
-        'ILL' => __( 'Illam', 'invoicing' ),
1213
-        'JHA' => __( 'Jhapa', 'invoicing' ),
1214
-        'PAN' => __( 'Panchthar', 'invoicing' ),
1215
-        'TAP' => __( 'Taplejung', 'invoicing' ),
1216
-        'BHO' => __( 'Bhojpur', 'invoicing' ),
1217
-        'DKA' => __( 'Dhankuta', 'invoicing' ),
1218
-        'MOR' => __( 'Morang', 'invoicing' ),
1219
-        'SUN' => __( 'Sunsari', 'invoicing' ),
1220
-        'SAN' => __( 'Sankhuwa', 'invoicing' ),
1221
-        'TER' => __( 'Terhathum', 'invoicing' ),
1222
-        'KHO' => __( 'Khotang', 'invoicing' ),
1223
-        'OKH' => __( 'Okhaldhunga', 'invoicing' ),
1224
-        'SAP' => __( 'Saptari', 'invoicing' ),
1225
-        'SIR' => __( 'Siraha', 'invoicing' ),
1226
-        'SOL' => __( 'Solukhumbu', 'invoicing' ),
1227
-        'UDA' => __( 'Udayapur', 'invoicing' ),
1228
-        'DHA' => __( 'Dhanusa', 'invoicing' ),
1229
-        'DLK' => __( 'Dolakha', 'invoicing' ),
1230
-        'MOH' => __( 'Mohottari', 'invoicing' ),
1231
-        'RAM' => __( 'Ramechha', 'invoicing' ),
1232
-        'SAR' => __( 'Sarlahi', 'invoicing' ),
1233
-        'SIN' => __( 'Sindhuli', 'invoicing' ),
1234
-        'BHA' => __( 'Bhaktapur', 'invoicing' ),
1235
-        'DHD' => __( 'Dhading', 'invoicing' ),
1236
-        'KTM' => __( 'Kathmandu', 'invoicing' ),
1237
-        'KAV' => __( 'Kavrepalanchowk', 'invoicing' ),
1238
-        'LAL' => __( 'Lalitpur', 'invoicing' ),
1239
-        'NUW' => __( 'Nuwakot', 'invoicing' ),
1240
-        'RAS' => __( 'Rasuwa', 'invoicing' ),
1241
-        'SPC' => __( 'Sindhupalchowk', 'invoicing' ),
1242
-        'BAR' => __( 'Bara', 'invoicing' ),
1243
-        'CHI' => __( 'Chitwan', 'invoicing' ),
1244
-        'MAK' => __( 'Makwanpur', 'invoicing' ),
1245
-        'PAR' => __( 'Parsa', 'invoicing' ),
1246
-        'RAU' => __( 'Rautahat', 'invoicing' ),
1247
-        'GOR' => __( 'Gorkha', 'invoicing' ),
1248
-        'KAS' => __( 'Kaski', 'invoicing' ),
1249
-        'LAM' => __( 'Lamjung', 'invoicing' ),
1250
-        'MAN' => __( 'Manang', 'invoicing' ),
1251
-        'SYN' => __( 'Syangja', 'invoicing' ),
1252
-        'TAN' => __( 'Tanahun', 'invoicing' ),
1253
-        'BAG' => __( 'Baglung', 'invoicing' ),
1254
-        'PBT' => __( 'Parbat', 'invoicing' ),
1255
-        'MUS' => __( 'Mustang', 'invoicing' ),
1256
-        'MYG' => __( 'Myagdi', 'invoicing' ),
1257
-        'AGR' => __( 'Agrghakanchi', 'invoicing' ),
1258
-        'GUL' => __( 'Gulmi', 'invoicing' ),
1259
-        'KAP' => __( 'Kapilbastu', 'invoicing' ),
1260
-        'NAW' => __( 'Nawalparasi', 'invoicing' ),
1261
-        'PAL' => __( 'Palpa', 'invoicing' ),
1262
-        'RUP' => __( 'Rupandehi', 'invoicing' ),
1263
-        'DAN' => __( 'Dang', 'invoicing' ),
1264
-        'PYU' => __( 'Pyuthan', 'invoicing' ),
1265
-        'ROL' => __( 'Rolpa', 'invoicing' ),
1266
-        'RUK' => __( 'Rukum', 'invoicing' ),
1267
-        'SAL' => __( 'Salyan', 'invoicing' ),
1268
-        'BAN' => __( 'Banke', 'invoicing' ),
1269
-        'BDA' => __( 'Bardiya', 'invoicing' ),
1270
-        'DAI' => __( 'Dailekh', 'invoicing' ),
1271
-        'JAJ' => __( 'Jajarkot', 'invoicing' ),
1272
-        'SUR' => __( 'Surkhet', 'invoicing' ),
1273
-        'DOL' => __( 'Dolpa', 'invoicing' ),
1274
-        'HUM' => __( 'Humla', 'invoicing' ),
1275
-        'JUM' => __( 'Jumla', 'invoicing' ),
1276
-        'KAL' => __( 'Kalikot', 'invoicing' ),
1277
-        'MUG' => __( 'Mugu', 'invoicing' ),
1278
-        'ACH' => __( 'Achham', 'invoicing' ),
1279
-        'BJH' => __( 'Bajhang', 'invoicing' ),
1280
-        'BJU' => __( 'Bajura', 'invoicing' ),
1281
-        'DOT' => __( 'Doti', 'invoicing' ),
1282
-        'KAI' => __( 'Kailali', 'invoicing' ),
1283
-        'BAI' => __( 'Baitadi', 'invoicing' ),
1284
-        'DAD' => __( 'Dadeldhura', 'invoicing' ),
1285
-        'DAR' => __( 'Darchula', 'invoicing' ),
1286
-        'KAN' => __( 'Kanchanpur', 'invoicing' )
1212
+        'ILL' => __('Illam', 'invoicing'),
1213
+        'JHA' => __('Jhapa', 'invoicing'),
1214
+        'PAN' => __('Panchthar', 'invoicing'),
1215
+        'TAP' => __('Taplejung', 'invoicing'),
1216
+        'BHO' => __('Bhojpur', 'invoicing'),
1217
+        'DKA' => __('Dhankuta', 'invoicing'),
1218
+        'MOR' => __('Morang', 'invoicing'),
1219
+        'SUN' => __('Sunsari', 'invoicing'),
1220
+        'SAN' => __('Sankhuwa', 'invoicing'),
1221
+        'TER' => __('Terhathum', 'invoicing'),
1222
+        'KHO' => __('Khotang', 'invoicing'),
1223
+        'OKH' => __('Okhaldhunga', 'invoicing'),
1224
+        'SAP' => __('Saptari', 'invoicing'),
1225
+        'SIR' => __('Siraha', 'invoicing'),
1226
+        'SOL' => __('Solukhumbu', 'invoicing'),
1227
+        'UDA' => __('Udayapur', 'invoicing'),
1228
+        'DHA' => __('Dhanusa', 'invoicing'),
1229
+        'DLK' => __('Dolakha', 'invoicing'),
1230
+        'MOH' => __('Mohottari', 'invoicing'),
1231
+        'RAM' => __('Ramechha', 'invoicing'),
1232
+        'SAR' => __('Sarlahi', 'invoicing'),
1233
+        'SIN' => __('Sindhuli', 'invoicing'),
1234
+        'BHA' => __('Bhaktapur', 'invoicing'),
1235
+        'DHD' => __('Dhading', 'invoicing'),
1236
+        'KTM' => __('Kathmandu', 'invoicing'),
1237
+        'KAV' => __('Kavrepalanchowk', 'invoicing'),
1238
+        'LAL' => __('Lalitpur', 'invoicing'),
1239
+        'NUW' => __('Nuwakot', 'invoicing'),
1240
+        'RAS' => __('Rasuwa', 'invoicing'),
1241
+        'SPC' => __('Sindhupalchowk', 'invoicing'),
1242
+        'BAR' => __('Bara', 'invoicing'),
1243
+        'CHI' => __('Chitwan', 'invoicing'),
1244
+        'MAK' => __('Makwanpur', 'invoicing'),
1245
+        'PAR' => __('Parsa', 'invoicing'),
1246
+        'RAU' => __('Rautahat', 'invoicing'),
1247
+        'GOR' => __('Gorkha', 'invoicing'),
1248
+        'KAS' => __('Kaski', 'invoicing'),
1249
+        'LAM' => __('Lamjung', 'invoicing'),
1250
+        'MAN' => __('Manang', 'invoicing'),
1251
+        'SYN' => __('Syangja', 'invoicing'),
1252
+        'TAN' => __('Tanahun', 'invoicing'),
1253
+        'BAG' => __('Baglung', 'invoicing'),
1254
+        'PBT' => __('Parbat', 'invoicing'),
1255
+        'MUS' => __('Mustang', 'invoicing'),
1256
+        'MYG' => __('Myagdi', 'invoicing'),
1257
+        'AGR' => __('Agrghakanchi', 'invoicing'),
1258
+        'GUL' => __('Gulmi', 'invoicing'),
1259
+        'KAP' => __('Kapilbastu', 'invoicing'),
1260
+        'NAW' => __('Nawalparasi', 'invoicing'),
1261
+        'PAL' => __('Palpa', 'invoicing'),
1262
+        'RUP' => __('Rupandehi', 'invoicing'),
1263
+        'DAN' => __('Dang', 'invoicing'),
1264
+        'PYU' => __('Pyuthan', 'invoicing'),
1265
+        'ROL' => __('Rolpa', 'invoicing'),
1266
+        'RUK' => __('Rukum', 'invoicing'),
1267
+        'SAL' => __('Salyan', 'invoicing'),
1268
+        'BAN' => __('Banke', 'invoicing'),
1269
+        'BDA' => __('Bardiya', 'invoicing'),
1270
+        'DAI' => __('Dailekh', 'invoicing'),
1271
+        'JAJ' => __('Jajarkot', 'invoicing'),
1272
+        'SUR' => __('Surkhet', 'invoicing'),
1273
+        'DOL' => __('Dolpa', 'invoicing'),
1274
+        'HUM' => __('Humla', 'invoicing'),
1275
+        'JUM' => __('Jumla', 'invoicing'),
1276
+        'KAL' => __('Kalikot', 'invoicing'),
1277
+        'MUG' => __('Mugu', 'invoicing'),
1278
+        'ACH' => __('Achham', 'invoicing'),
1279
+        'BJH' => __('Bajhang', 'invoicing'),
1280
+        'BJU' => __('Bajura', 'invoicing'),
1281
+        'DOT' => __('Doti', 'invoicing'),
1282
+        'KAI' => __('Kailali', 'invoicing'),
1283
+        'BAI' => __('Baitadi', 'invoicing'),
1284
+        'DAD' => __('Dadeldhura', 'invoicing'),
1285
+        'DAR' => __('Darchula', 'invoicing'),
1286
+        'KAN' => __('Kanchanpur', 'invoicing')
1287 1287
     );
1288 1288
 
1289
-    return apply_filters( 'wpinv_nepal_states', $states );
1289
+    return apply_filters('wpinv_nepal_states', $states);
1290 1290
 }
1291 1291
 
1292 1292
 function wpinv_get_south_africa_states_list() {
1293 1293
     $states = array(
1294
-        'EC'  => __( 'Eastern Cape', 'invoicing' ),
1295
-        'FS'  => __( 'Free State', 'invoicing' ),
1296
-        'GP'  => __( 'Gauteng', 'invoicing' ),
1297
-        'KZN' => __( 'KwaZulu-Natal', 'invoicing' ),
1298
-        'LP'  => __( 'Limpopo', 'invoicing' ),
1299
-        'MP'  => __( 'Mpumalanga', 'invoicing' ),
1300
-        'NC'  => __( 'Northern Cape', 'invoicing' ),
1301
-        'NW'  => __( 'North West', 'invoicing' ),
1302
-        'WC'  => __( 'Western Cape', 'invoicing' )
1294
+        'EC'  => __('Eastern Cape', 'invoicing'),
1295
+        'FS'  => __('Free State', 'invoicing'),
1296
+        'GP'  => __('Gauteng', 'invoicing'),
1297
+        'KZN' => __('KwaZulu-Natal', 'invoicing'),
1298
+        'LP'  => __('Limpopo', 'invoicing'),
1299
+        'MP'  => __('Mpumalanga', 'invoicing'),
1300
+        'NC'  => __('Northern Cape', 'invoicing'),
1301
+        'NW'  => __('North West', 'invoicing'),
1302
+        'WC'  => __('Western Cape', 'invoicing')
1303 1303
     );
1304 1304
 
1305
-    return apply_filters( 'wpinv_south_africa_states', $states );
1305
+    return apply_filters('wpinv_south_africa_states', $states);
1306 1306
 }
1307 1307
 
1308 1308
 function wpinv_get_thailand_states_list() {
1309 1309
     $states = array(
1310
-        'TH-37' => __( 'Amnat Charoen (อำนาจเจริญ)', 'invoicing' ),
1311
-        'TH-15' => __( 'Ang Thong (อ่างทอง)', 'invoicing' ),
1312
-        'TH-14' => __( 'Ayutthaya (พระนครศรีอยุธยา)', 'invoicing' ),
1313
-        'TH-10' => __( 'Bangkok (กรุงเทพมหานคร)', 'invoicing' ),
1314
-        'TH-38' => __( 'Bueng Kan (บึงกาฬ)', 'invoicing' ),
1315
-        'TH-31' => __( 'Buri Ram (บุรีรัมย์)', 'invoicing' ),
1316
-        'TH-24' => __( 'Chachoengsao (ฉะเชิงเทรา)', 'invoicing' ),
1317
-        'TH-18' => __( 'Chai Nat (ชัยนาท)', 'invoicing' ),
1318
-        'TH-36' => __( 'Chaiyaphum (ชัยภูมิ)', 'invoicing' ),
1319
-        'TH-22' => __( 'Chanthaburi (จันทบุรี)', 'invoicing' ),
1320
-        'TH-50' => __( 'Chiang Mai (เชียงใหม่)', 'invoicing' ),
1321
-        'TH-57' => __( 'Chiang Rai (เชียงราย)', 'invoicing' ),
1322
-        'TH-20' => __( 'Chonburi (ชลบุรี)', 'invoicing' ),
1323
-        'TH-86' => __( 'Chumphon (ชุมพร)', 'invoicing' ),
1324
-        'TH-46' => __( 'Kalasin (กาฬสินธุ์)', 'invoicing' ),
1325
-        'TH-62' => __( 'Kamphaeng Phet (กำแพงเพชร)', 'invoicing' ),
1326
-        'TH-71' => __( 'Kanchanaburi (กาญจนบุรี)', 'invoicing' ),
1327
-        'TH-40' => __( 'Khon Kaen (ขอนแก่น)', 'invoicing' ),
1328
-        'TH-81' => __( 'Krabi (กระบี่)', 'invoicing' ),
1329
-        'TH-52' => __( 'Lampang (ลำปาง)', 'invoicing' ),
1330
-        'TH-51' => __( 'Lamphun (ลำพูน)', 'invoicing' ),
1331
-        'TH-42' => __( 'Loei (เลย)', 'invoicing' ),
1332
-        'TH-16' => __( 'Lopburi (ลพบุรี)', 'invoicing' ),
1333
-        'TH-58' => __( 'Mae Hong Son (แม่ฮ่องสอน)', 'invoicing' ),
1334
-        'TH-44' => __( 'Maha Sarakham (มหาสารคาม)', 'invoicing' ),
1335
-        'TH-49' => __( 'Mukdahan (มุกดาหาร)', 'invoicing' ),
1336
-        'TH-26' => __( 'Nakhon Nayok (นครนายก)', 'invoicing' ),
1337
-        'TH-73' => __( 'Nakhon Pathom (นครปฐม)', 'invoicing' ),
1338
-        'TH-48' => __( 'Nakhon Phanom (นครพนม)', 'invoicing' ),
1339
-        'TH-30' => __( 'Nakhon Ratchasima (นครราชสีมา)', 'invoicing' ),
1340
-        'TH-60' => __( 'Nakhon Sawan (นครสวรรค์)', 'invoicing' ),
1341
-        'TH-80' => __( 'Nakhon Si Thammarat (นครศรีธรรมราช)', 'invoicing' ),
1342
-        'TH-55' => __( 'Nan (น่าน)', 'invoicing' ),
1343
-        'TH-96' => __( 'Narathiwat (นราธิวาส)', 'invoicing' ),
1344
-        'TH-39' => __( 'Nong Bua Lam Phu (หนองบัวลำภู)', 'invoicing' ),
1345
-        'TH-43' => __( 'Nong Khai (หนองคาย)', 'invoicing' ),
1346
-        'TH-12' => __( 'Nonthaburi (นนทบุรี)', 'invoicing' ),
1347
-        'TH-13' => __( 'Pathum Thani (ปทุมธานี)', 'invoicing' ),
1348
-        'TH-94' => __( 'Pattani (ปัตตานี)', 'invoicing' ),
1349
-        'TH-82' => __( 'Phang Nga (พังงา)', 'invoicing' ),
1350
-        'TH-93' => __( 'Phatthalung (พัทลุง)', 'invoicing' ),
1351
-        'TH-56' => __( 'Phayao (พะเยา)', 'invoicing' ),
1352
-        'TH-67' => __( 'Phetchabun (เพชรบูรณ์)', 'invoicing' ),
1353
-        'TH-76' => __( 'Phetchaburi (เพชรบุรี)', 'invoicing' ),
1354
-        'TH-66' => __( 'Phichit (พิจิตร)', 'invoicing' ),
1355
-        'TH-65' => __( 'Phitsanulok (พิษณุโลก)', 'invoicing' ),
1356
-        'TH-54' => __( 'Phrae (แพร่)', 'invoicing' ),
1357
-        'TH-83' => __( 'Phuket (ภูเก็ต)', 'invoicing' ),
1358
-        'TH-25' => __( 'Prachin Buri (ปราจีนบุรี)', 'invoicing' ),
1359
-        'TH-77' => __( 'Prachuap Khiri Khan (ประจวบคีรีขันธ์)', 'invoicing' ),
1360
-        'TH-85' => __( 'Ranong (ระนอง)', 'invoicing' ),
1361
-        'TH-70' => __( 'Ratchaburi (ราชบุรี)', 'invoicing' ),
1362
-        'TH-21' => __( 'Rayong (ระยอง)', 'invoicing' ),
1363
-        'TH-45' => __( 'Roi Et (ร้อยเอ็ด)', 'invoicing' ),
1364
-        'TH-27' => __( 'Sa Kaeo (สระแก้ว)', 'invoicing' ),
1365
-        'TH-47' => __( 'Sakon Nakhon (สกลนคร)', 'invoicing' ),
1366
-        'TH-11' => __( 'Samut Prakan (สมุทรปราการ)', 'invoicing' ),
1367
-        'TH-74' => __( 'Samut Sakhon (สมุทรสาคร)', 'invoicing' ),
1368
-        'TH-75' => __( 'Samut Songkhram (สมุทรสงคราม)', 'invoicing' ),
1369
-        'TH-19' => __( 'Saraburi (สระบุรี)', 'invoicing' ),
1370
-        'TH-91' => __( 'Satun (สตูล)', 'invoicing' ),
1371
-        'TH-17' => __( 'Sing Buri (สิงห์บุรี)', 'invoicing' ),
1372
-        'TH-33' => __( 'Sisaket (ศรีสะเกษ)', 'invoicing' ),
1373
-        'TH-90' => __( 'Songkhla (สงขลา)', 'invoicing' ),
1374
-        'TH-64' => __( 'Sukhothai (สุโขทัย)', 'invoicing' ),
1375
-        'TH-72' => __( 'Suphan Buri (สุพรรณบุรี)', 'invoicing' ),
1376
-        'TH-84' => __( 'Surat Thani (สุราษฎร์ธานี)', 'invoicing' ),
1377
-        'TH-32' => __( 'Surin (สุรินทร์)', 'invoicing' ),
1378
-        'TH-63' => __( 'Tak (ตาก)', 'invoicing' ),
1379
-        'TH-92' => __( 'Trang (ตรัง)', 'invoicing' ),
1380
-        'TH-23' => __( 'Trat (ตราด)', 'invoicing' ),
1381
-        'TH-34' => __( 'Ubon Ratchathani (อุบลราชธานี)', 'invoicing' ),
1382
-        'TH-41' => __( 'Udon Thani (อุดรธานี)', 'invoicing' ),
1383
-        'TH-61' => __( 'Uthai Thani (อุทัยธานี)', 'invoicing' ),
1384
-        'TH-53' => __( 'Uttaradit (อุตรดิตถ์)', 'invoicing' ),
1385
-        'TH-95' => __( 'Yala (ยะลา)', 'invoicing' ),
1386
-        'TH-35' => __( 'Yasothon (ยโสธร)', 'invoicing' )
1310
+        'TH-37' => __('Amnat Charoen (อำนาจเจริญ)', 'invoicing'),
1311
+        'TH-15' => __('Ang Thong (อ่างทอง)', 'invoicing'),
1312
+        'TH-14' => __('Ayutthaya (พระนครศรีอยุธยา)', 'invoicing'),
1313
+        'TH-10' => __('Bangkok (กรุงเทพมหานคร)', 'invoicing'),
1314
+        'TH-38' => __('Bueng Kan (บึงกาฬ)', 'invoicing'),
1315
+        'TH-31' => __('Buri Ram (บุรีรัมย์)', 'invoicing'),
1316
+        'TH-24' => __('Chachoengsao (ฉะเชิงเทรา)', 'invoicing'),
1317
+        'TH-18' => __('Chai Nat (ชัยนาท)', 'invoicing'),
1318
+        'TH-36' => __('Chaiyaphum (ชัยภูมิ)', 'invoicing'),
1319
+        'TH-22' => __('Chanthaburi (จันทบุรี)', 'invoicing'),
1320
+        'TH-50' => __('Chiang Mai (เชียงใหม่)', 'invoicing'),
1321
+        'TH-57' => __('Chiang Rai (เชียงราย)', 'invoicing'),
1322
+        'TH-20' => __('Chonburi (ชลบุรี)', 'invoicing'),
1323
+        'TH-86' => __('Chumphon (ชุมพร)', 'invoicing'),
1324
+        'TH-46' => __('Kalasin (กาฬสินธุ์)', 'invoicing'),
1325
+        'TH-62' => __('Kamphaeng Phet (กำแพงเพชร)', 'invoicing'),
1326
+        'TH-71' => __('Kanchanaburi (กาญจนบุรี)', 'invoicing'),
1327
+        'TH-40' => __('Khon Kaen (ขอนแก่น)', 'invoicing'),
1328
+        'TH-81' => __('Krabi (กระบี่)', 'invoicing'),
1329
+        'TH-52' => __('Lampang (ลำปาง)', 'invoicing'),
1330
+        'TH-51' => __('Lamphun (ลำพูน)', 'invoicing'),
1331
+        'TH-42' => __('Loei (เลย)', 'invoicing'),
1332
+        'TH-16' => __('Lopburi (ลพบุรี)', 'invoicing'),
1333
+        'TH-58' => __('Mae Hong Son (แม่ฮ่องสอน)', 'invoicing'),
1334
+        'TH-44' => __('Maha Sarakham (มหาสารคาม)', 'invoicing'),
1335
+        'TH-49' => __('Mukdahan (มุกดาหาร)', 'invoicing'),
1336
+        'TH-26' => __('Nakhon Nayok (นครนายก)', 'invoicing'),
1337
+        'TH-73' => __('Nakhon Pathom (นครปฐม)', 'invoicing'),
1338
+        'TH-48' => __('Nakhon Phanom (นครพนม)', 'invoicing'),
1339
+        'TH-30' => __('Nakhon Ratchasima (นครราชสีมา)', 'invoicing'),
1340
+        'TH-60' => __('Nakhon Sawan (นครสวรรค์)', 'invoicing'),
1341
+        'TH-80' => __('Nakhon Si Thammarat (นครศรีธรรมราช)', 'invoicing'),
1342
+        'TH-55' => __('Nan (น่าน)', 'invoicing'),
1343
+        'TH-96' => __('Narathiwat (นราธิวาส)', 'invoicing'),
1344
+        'TH-39' => __('Nong Bua Lam Phu (หนองบัวลำภู)', 'invoicing'),
1345
+        'TH-43' => __('Nong Khai (หนองคาย)', 'invoicing'),
1346
+        'TH-12' => __('Nonthaburi (นนทบุรี)', 'invoicing'),
1347
+        'TH-13' => __('Pathum Thani (ปทุมธานี)', 'invoicing'),
1348
+        'TH-94' => __('Pattani (ปัตตานี)', 'invoicing'),
1349
+        'TH-82' => __('Phang Nga (พังงา)', 'invoicing'),
1350
+        'TH-93' => __('Phatthalung (พัทลุง)', 'invoicing'),
1351
+        'TH-56' => __('Phayao (พะเยา)', 'invoicing'),
1352
+        'TH-67' => __('Phetchabun (เพชรบูรณ์)', 'invoicing'),
1353
+        'TH-76' => __('Phetchaburi (เพชรบุรี)', 'invoicing'),
1354
+        'TH-66' => __('Phichit (พิจิตร)', 'invoicing'),
1355
+        'TH-65' => __('Phitsanulok (พิษณุโลก)', 'invoicing'),
1356
+        'TH-54' => __('Phrae (แพร่)', 'invoicing'),
1357
+        'TH-83' => __('Phuket (ภูเก็ต)', 'invoicing'),
1358
+        'TH-25' => __('Prachin Buri (ปราจีนบุรี)', 'invoicing'),
1359
+        'TH-77' => __('Prachuap Khiri Khan (ประจวบคีรีขันธ์)', 'invoicing'),
1360
+        'TH-85' => __('Ranong (ระนอง)', 'invoicing'),
1361
+        'TH-70' => __('Ratchaburi (ราชบุรี)', 'invoicing'),
1362
+        'TH-21' => __('Rayong (ระยอง)', 'invoicing'),
1363
+        'TH-45' => __('Roi Et (ร้อยเอ็ด)', 'invoicing'),
1364
+        'TH-27' => __('Sa Kaeo (สระแก้ว)', 'invoicing'),
1365
+        'TH-47' => __('Sakon Nakhon (สกลนคร)', 'invoicing'),
1366
+        'TH-11' => __('Samut Prakan (สมุทรปราการ)', 'invoicing'),
1367
+        'TH-74' => __('Samut Sakhon (สมุทรสาคร)', 'invoicing'),
1368
+        'TH-75' => __('Samut Songkhram (สมุทรสงคราม)', 'invoicing'),
1369
+        'TH-19' => __('Saraburi (สระบุรี)', 'invoicing'),
1370
+        'TH-91' => __('Satun (สตูล)', 'invoicing'),
1371
+        'TH-17' => __('Sing Buri (สิงห์บุรี)', 'invoicing'),
1372
+        'TH-33' => __('Sisaket (ศรีสะเกษ)', 'invoicing'),
1373
+        'TH-90' => __('Songkhla (สงขลา)', 'invoicing'),
1374
+        'TH-64' => __('Sukhothai (สุโขทัย)', 'invoicing'),
1375
+        'TH-72' => __('Suphan Buri (สุพรรณบุรี)', 'invoicing'),
1376
+        'TH-84' => __('Surat Thani (สุราษฎร์ธานี)', 'invoicing'),
1377
+        'TH-32' => __('Surin (สุรินทร์)', 'invoicing'),
1378
+        'TH-63' => __('Tak (ตาก)', 'invoicing'),
1379
+        'TH-92' => __('Trang (ตรัง)', 'invoicing'),
1380
+        'TH-23' => __('Trat (ตราด)', 'invoicing'),
1381
+        'TH-34' => __('Ubon Ratchathani (อุบลราชธานี)', 'invoicing'),
1382
+        'TH-41' => __('Udon Thani (อุดรธานี)', 'invoicing'),
1383
+        'TH-61' => __('Uthai Thani (อุทัยธานี)', 'invoicing'),
1384
+        'TH-53' => __('Uttaradit (อุตรดิตถ์)', 'invoicing'),
1385
+        'TH-95' => __('Yala (ยะลา)', 'invoicing'),
1386
+        'TH-35' => __('Yasothon (ยโสธร)', 'invoicing')
1387 1387
     );
1388 1388
 
1389
-    return apply_filters( 'wpinv_thailand_states', $states );
1389
+    return apply_filters('wpinv_thailand_states', $states);
1390 1390
 }
1391 1391
 
1392 1392
 function wpinv_get_turkey_states_list() {
1393 1393
     $states = array(
1394
-        'TR01' => __( 'Adana', 'invoicing' ),
1395
-        'TR02' => __( 'Adıyaman', 'invoicing' ),
1396
-        'TR03' => __( 'Afyon', 'invoicing' ),
1397
-        'TR04' => __( 'Ağrı', 'invoicing' ),
1398
-        'TR05' => __( 'Amasya', 'invoicing' ),
1399
-        'TR06' => __( 'Ankara', 'invoicing' ),
1400
-        'TR07' => __( 'Antalya', 'invoicing' ),
1401
-        'TR08' => __( 'Artvin', 'invoicing' ),
1402
-        'TR09' => __( 'Aydın', 'invoicing' ),
1403
-        'TR10' => __( 'Balıkesir', 'invoicing' ),
1404
-        'TR11' => __( 'Bilecik', 'invoicing' ),
1405
-        'TR12' => __( 'Bingöl', 'invoicing' ),
1406
-        'TR13' => __( 'Bitlis', 'invoicing' ),
1407
-        'TR14' => __( 'Bolu', 'invoicing' ),
1408
-        'TR15' => __( 'Burdur', 'invoicing' ),
1409
-        'TR16' => __( 'Bursa', 'invoicing' ),
1410
-        'TR17' => __( 'Çanakkale', 'invoicing' ),
1411
-        'TR18' => __( 'Çankıkesir', 'invoicing' ),
1412
-        'TR19' => __( 'Çorum', 'invoicing' ),
1413
-        'TR20' => __( 'Denizli', 'invoicing' ),
1414
-        'TR21' => __( 'Diyarbakır', 'invoicing' ),
1415
-        'TR22' => __( 'Edirne', 'invoicing' ),
1416
-        'TR23' => __( 'Elazığ', 'invoicing' ),
1417
-        'TR24' => __( 'Erzincan', 'invoicing' ),
1418
-        'TR25' => __( 'Erzurum', 'invoicing' ),
1419
-        'TR26' => __( 'Eskişehir', 'invoicing' ),
1420
-        'TR27' => __( 'Gaziantep', 'invoicing' ),
1421
-        'TR28' => __( 'Giresun', 'invoicing' ),
1422
-        'TR29' => __( 'Gümüşhane', 'invoicing' ),
1423
-        'TR30' => __( 'Hakkari', 'invoicing' ),
1424
-        'TR31' => __( 'Hatay', 'invoicing' ),
1425
-        'TR32' => __( 'Isparta', 'invoicing' ),
1426
-        'TR33' => __( 'İçel', 'invoicing' ),
1427
-        'TR34' => __( 'İstanbul', 'invoicing' ),
1428
-        'TR35' => __( 'İzmir', 'invoicing' ),
1429
-        'TR36' => __( 'Kars', 'invoicing' ),
1430
-        'TR37' => __( 'Kastamonu', 'invoicing' ),
1431
-        'TR38' => __( 'Kayseri', 'invoicing' ),
1432
-        'TR39' => __( 'Kırklareli', 'invoicing' ),
1433
-        'TR40' => __( 'Kırşehir', 'invoicing' ),
1434
-        'TR41' => __( 'Kocaeli', 'invoicing' ),
1435
-        'TR42' => __( 'Konya', 'invoicing' ),
1436
-        'TR43' => __( 'Kütahya', 'invoicing' ),
1437
-        'TR44' => __( 'Malatya', 'invoicing' ),
1438
-        'TR45' => __( 'Manisa', 'invoicing' ),
1439
-        'TR46' => __( 'Kahramanmaraş', 'invoicing' ),
1440
-        'TR47' => __( 'Mardin', 'invoicing' ),
1441
-        'TR48' => __( 'Muğla', 'invoicing' ),
1442
-        'TR49' => __( 'Muş', 'invoicing' ),
1443
-        'TR50' => __( 'Nevşehir', 'invoicing' ),
1444
-        'TR51' => __( 'Niğde', 'invoicing' ),
1445
-        'TR52' => __( 'Ordu', 'invoicing' ),
1446
-        'TR53' => __( 'Rize', 'invoicing' ),
1447
-        'TR54' => __( 'Sakarya', 'invoicing' ),
1448
-        'TR55' => __( 'Samsun', 'invoicing' ),
1449
-        'TR56' => __( 'Siirt', 'invoicing' ),
1450
-        'TR57' => __( 'Sinop', 'invoicing' ),
1451
-        'TR58' => __( 'Sivas', 'invoicing' ),
1452
-        'TR59' => __( 'Tekirdağ', 'invoicing' ),
1453
-        'TR60' => __( 'Tokat', 'invoicing' ),
1454
-        'TR61' => __( 'Trabzon', 'invoicing' ),
1455
-        'TR62' => __( 'Tunceli', 'invoicing' ),
1456
-        'TR63' => __( 'Şanlıurfa', 'invoicing' ),
1457
-        'TR64' => __( 'Uşak', 'invoicing' ),
1458
-        'TR65' => __( 'Van', 'invoicing' ),
1459
-        'TR66' => __( 'Yozgat', 'invoicing' ),
1460
-        'TR67' => __( 'Zonguldak', 'invoicing' ),
1461
-        'TR68' => __( 'Aksaray', 'invoicing' ),
1462
-        'TR69' => __( 'Bayburt', 'invoicing' ),
1463
-        'TR70' => __( 'Karaman', 'invoicing' ),
1464
-        'TR71' => __( 'Kırıkkale', 'invoicing' ),
1465
-        'TR72' => __( 'Batman', 'invoicing' ),
1466
-        'TR73' => __( 'Şırnak', 'invoicing' ),
1467
-        'TR74' => __( 'Bartın', 'invoicing' ),
1468
-        'TR75' => __( 'Ardahan', 'invoicing' ),
1469
-        'TR76' => __( 'Iğdır', 'invoicing' ),
1470
-        'TR77' => __( 'Yalova', 'invoicing' ),
1471
-        'TR78' => __( 'Karabük', 'invoicing' ),
1472
-        'TR79' => __( 'Kilis', 'invoicing' ),
1473
-        'TR80' => __( 'Osmaniye', 'invoicing' ),
1474
-        'TR81' => __( 'Düzce', 'invoicing' )
1394
+        'TR01' => __('Adana', 'invoicing'),
1395
+        'TR02' => __('Adıyaman', 'invoicing'),
1396
+        'TR03' => __('Afyon', 'invoicing'),
1397
+        'TR04' => __('Ağrı', 'invoicing'),
1398
+        'TR05' => __('Amasya', 'invoicing'),
1399
+        'TR06' => __('Ankara', 'invoicing'),
1400
+        'TR07' => __('Antalya', 'invoicing'),
1401
+        'TR08' => __('Artvin', 'invoicing'),
1402
+        'TR09' => __('Aydın', 'invoicing'),
1403
+        'TR10' => __('Balıkesir', 'invoicing'),
1404
+        'TR11' => __('Bilecik', 'invoicing'),
1405
+        'TR12' => __('Bingöl', 'invoicing'),
1406
+        'TR13' => __('Bitlis', 'invoicing'),
1407
+        'TR14' => __('Bolu', 'invoicing'),
1408
+        'TR15' => __('Burdur', 'invoicing'),
1409
+        'TR16' => __('Bursa', 'invoicing'),
1410
+        'TR17' => __('Çanakkale', 'invoicing'),
1411
+        'TR18' => __('Çankıkesir', 'invoicing'),
1412
+        'TR19' => __('Çorum', 'invoicing'),
1413
+        'TR20' => __('Denizli', 'invoicing'),
1414
+        'TR21' => __('Diyarbakır', 'invoicing'),
1415
+        'TR22' => __('Edirne', 'invoicing'),
1416
+        'TR23' => __('Elazığ', 'invoicing'),
1417
+        'TR24' => __('Erzincan', 'invoicing'),
1418
+        'TR25' => __('Erzurum', 'invoicing'),
1419
+        'TR26' => __('Eskişehir', 'invoicing'),
1420
+        'TR27' => __('Gaziantep', 'invoicing'),
1421
+        'TR28' => __('Giresun', 'invoicing'),
1422
+        'TR29' => __('Gümüşhane', 'invoicing'),
1423
+        'TR30' => __('Hakkari', 'invoicing'),
1424
+        'TR31' => __('Hatay', 'invoicing'),
1425
+        'TR32' => __('Isparta', 'invoicing'),
1426
+        'TR33' => __('İçel', 'invoicing'),
1427
+        'TR34' => __('İstanbul', 'invoicing'),
1428
+        'TR35' => __('İzmir', 'invoicing'),
1429
+        'TR36' => __('Kars', 'invoicing'),
1430
+        'TR37' => __('Kastamonu', 'invoicing'),
1431
+        'TR38' => __('Kayseri', 'invoicing'),
1432
+        'TR39' => __('Kırklareli', 'invoicing'),
1433
+        'TR40' => __('Kırşehir', 'invoicing'),
1434
+        'TR41' => __('Kocaeli', 'invoicing'),
1435
+        'TR42' => __('Konya', 'invoicing'),
1436
+        'TR43' => __('Kütahya', 'invoicing'),
1437
+        'TR44' => __('Malatya', 'invoicing'),
1438
+        'TR45' => __('Manisa', 'invoicing'),
1439
+        'TR46' => __('Kahramanmaraş', 'invoicing'),
1440
+        'TR47' => __('Mardin', 'invoicing'),
1441
+        'TR48' => __('Muğla', 'invoicing'),
1442
+        'TR49' => __('Muş', 'invoicing'),
1443
+        'TR50' => __('Nevşehir', 'invoicing'),
1444
+        'TR51' => __('Niğde', 'invoicing'),
1445
+        'TR52' => __('Ordu', 'invoicing'),
1446
+        'TR53' => __('Rize', 'invoicing'),
1447
+        'TR54' => __('Sakarya', 'invoicing'),
1448
+        'TR55' => __('Samsun', 'invoicing'),
1449
+        'TR56' => __('Siirt', 'invoicing'),
1450
+        'TR57' => __('Sinop', 'invoicing'),
1451
+        'TR58' => __('Sivas', 'invoicing'),
1452
+        'TR59' => __('Tekirdağ', 'invoicing'),
1453
+        'TR60' => __('Tokat', 'invoicing'),
1454
+        'TR61' => __('Trabzon', 'invoicing'),
1455
+        'TR62' => __('Tunceli', 'invoicing'),
1456
+        'TR63' => __('Şanlıurfa', 'invoicing'),
1457
+        'TR64' => __('Uşak', 'invoicing'),
1458
+        'TR65' => __('Van', 'invoicing'),
1459
+        'TR66' => __('Yozgat', 'invoicing'),
1460
+        'TR67' => __('Zonguldak', 'invoicing'),
1461
+        'TR68' => __('Aksaray', 'invoicing'),
1462
+        'TR69' => __('Bayburt', 'invoicing'),
1463
+        'TR70' => __('Karaman', 'invoicing'),
1464
+        'TR71' => __('Kırıkkale', 'invoicing'),
1465
+        'TR72' => __('Batman', 'invoicing'),
1466
+        'TR73' => __('Şırnak', 'invoicing'),
1467
+        'TR74' => __('Bartın', 'invoicing'),
1468
+        'TR75' => __('Ardahan', 'invoicing'),
1469
+        'TR76' => __('Iğdır', 'invoicing'),
1470
+        'TR77' => __('Yalova', 'invoicing'),
1471
+        'TR78' => __('Karabük', 'invoicing'),
1472
+        'TR79' => __('Kilis', 'invoicing'),
1473
+        'TR80' => __('Osmaniye', 'invoicing'),
1474
+        'TR81' => __('Düzce', 'invoicing')
1475 1475
     );
1476 1476
 
1477
-    return apply_filters( 'wpinv_turkey_states', $states );
1477
+    return apply_filters('wpinv_turkey_states', $states);
1478 1478
 }
1479 1479
 
1480 1480
 function wpinv_get_spain_states_list() {
1481 1481
     $states = array(
1482
-        'C'  => __( 'A Coruña', 'invoicing' ),
1483
-        'VI' => __( 'Araba', 'invoicing' ),
1484
-        'AB' => __( 'Albacete', 'invoicing' ),
1485
-        'A'  => __( 'Alicante', 'invoicing' ),
1486
-        'AL' => __( 'Almería', 'invoicing' ),
1487
-        'O'  => __( 'Asturias', 'invoicing' ),
1488
-        'AV' => __( 'Ávila', 'invoicing' ),
1489
-        'BA' => __( 'Badajoz', 'invoicing' ),
1490
-        'PM' => __( 'Baleares', 'invoicing' ),
1491
-        'B'  => __( 'Barcelona', 'invoicing' ),
1492
-        'BU' => __( 'Burgos', 'invoicing' ),
1493
-        'CC' => __( 'Cáceres', 'invoicing' ),
1494
-        'CA' => __( 'Cádiz', 'invoicing' ),
1495
-        'S'  => __( 'Cantabria', 'invoicing' ),
1496
-        'CS' => __( 'Castellón', 'invoicing' ),
1497
-        'CE' => __( 'Ceuta', 'invoicing' ),
1498
-        'CR' => __( 'Ciudad Real', 'invoicing' ),
1499
-        'CO' => __( 'Córdoba', 'invoicing' ),
1500
-        'CU' => __( 'Cuenca', 'invoicing' ),
1501
-        'GI' => __( 'Girona', 'invoicing' ),
1502
-        'GR' => __( 'Granada', 'invoicing' ),
1503
-        'GU' => __( 'Guadalajara', 'invoicing' ),
1504
-        'SS' => __( 'Gipuzkoa', 'invoicing' ),
1505
-        'H'  => __( 'Huelva', 'invoicing' ),
1506
-        'HU' => __( 'Huesca', 'invoicing' ),
1507
-        'J'  => __( 'Jaén', 'invoicing' ),
1508
-        'LO' => __( 'La Rioja', 'invoicing' ),
1509
-        'GC' => __( 'Las Palmas', 'invoicing' ),
1510
-        'LE' => __( 'León', 'invoicing' ),
1511
-        'L'  => __( 'Lleida', 'invoicing' ),
1512
-        'LU' => __( 'Lugo', 'invoicing' ),
1513
-        'M'  => __( 'Madrid', 'invoicing' ),
1514
-        'MA' => __( 'Málaga', 'invoicing' ),
1515
-        'ML' => __( 'Melilla', 'invoicing' ),
1516
-        'MU' => __( 'Murcia', 'invoicing' ),
1517
-        'NA' => __( 'Navarra', 'invoicing' ),
1518
-        'OR' => __( 'Ourense', 'invoicing' ),
1519
-        'P'  => __( 'Palencia', 'invoicing' ),
1520
-        'PO' => __( 'Pontevedra', 'invoicing' ),
1521
-        'SA' => __( 'Salamanca', 'invoicing' ),
1522
-        'TF' => __( 'Santa Cruz de Tenerife', 'invoicing' ),
1523
-        'SG' => __( 'Segovia', 'invoicing' ),
1524
-        'SE' => __( 'Sevilla', 'invoicing' ),
1525
-        'SO' => __( 'Soria', 'invoicing' ),
1526
-        'T'  => __( 'Tarragona', 'invoicing' ),
1527
-        'TE' => __( 'Teruel', 'invoicing' ),
1528
-        'TO' => __( 'Toledo', 'invoicing' ),
1529
-        'V'  => __( 'Valencia', 'invoicing' ),
1530
-        'VA' => __( 'Valladolid', 'invoicing' ),
1531
-        'BI' => __( 'Bizkaia', 'invoicing' ),
1532
-        'ZA' => __( 'Zamora', 'invoicing' ),
1533
-        'Z'  => __( 'Zaragoza', 'invoicing' )
1482
+        'C'  => __('A Coruña', 'invoicing'),
1483
+        'VI' => __('Araba', 'invoicing'),
1484
+        'AB' => __('Albacete', 'invoicing'),
1485
+        'A'  => __('Alicante', 'invoicing'),
1486
+        'AL' => __('Almería', 'invoicing'),
1487
+        'O'  => __('Asturias', 'invoicing'),
1488
+        'AV' => __('Ávila', 'invoicing'),
1489
+        'BA' => __('Badajoz', 'invoicing'),
1490
+        'PM' => __('Baleares', 'invoicing'),
1491
+        'B'  => __('Barcelona', 'invoicing'),
1492
+        'BU' => __('Burgos', 'invoicing'),
1493
+        'CC' => __('Cáceres', 'invoicing'),
1494
+        'CA' => __('Cádiz', 'invoicing'),
1495
+        'S'  => __('Cantabria', 'invoicing'),
1496
+        'CS' => __('Castellón', 'invoicing'),
1497
+        'CE' => __('Ceuta', 'invoicing'),
1498
+        'CR' => __('Ciudad Real', 'invoicing'),
1499
+        'CO' => __('Córdoba', 'invoicing'),
1500
+        'CU' => __('Cuenca', 'invoicing'),
1501
+        'GI' => __('Girona', 'invoicing'),
1502
+        'GR' => __('Granada', 'invoicing'),
1503
+        'GU' => __('Guadalajara', 'invoicing'),
1504
+        'SS' => __('Gipuzkoa', 'invoicing'),
1505
+        'H'  => __('Huelva', 'invoicing'),
1506
+        'HU' => __('Huesca', 'invoicing'),
1507
+        'J'  => __('Jaén', 'invoicing'),
1508
+        'LO' => __('La Rioja', 'invoicing'),
1509
+        'GC' => __('Las Palmas', 'invoicing'),
1510
+        'LE' => __('León', 'invoicing'),
1511
+        'L'  => __('Lleida', 'invoicing'),
1512
+        'LU' => __('Lugo', 'invoicing'),
1513
+        'M'  => __('Madrid', 'invoicing'),
1514
+        'MA' => __('Málaga', 'invoicing'),
1515
+        'ML' => __('Melilla', 'invoicing'),
1516
+        'MU' => __('Murcia', 'invoicing'),
1517
+        'NA' => __('Navarra', 'invoicing'),
1518
+        'OR' => __('Ourense', 'invoicing'),
1519
+        'P'  => __('Palencia', 'invoicing'),
1520
+        'PO' => __('Pontevedra', 'invoicing'),
1521
+        'SA' => __('Salamanca', 'invoicing'),
1522
+        'TF' => __('Santa Cruz de Tenerife', 'invoicing'),
1523
+        'SG' => __('Segovia', 'invoicing'),
1524
+        'SE' => __('Sevilla', 'invoicing'),
1525
+        'SO' => __('Soria', 'invoicing'),
1526
+        'T'  => __('Tarragona', 'invoicing'),
1527
+        'TE' => __('Teruel', 'invoicing'),
1528
+        'TO' => __('Toledo', 'invoicing'),
1529
+        'V'  => __('Valencia', 'invoicing'),
1530
+        'VA' => __('Valladolid', 'invoicing'),
1531
+        'BI' => __('Bizkaia', 'invoicing'),
1532
+        'ZA' => __('Zamora', 'invoicing'),
1533
+        'Z'  => __('Zaragoza', 'invoicing')
1534 1534
     );
1535 1535
 
1536
-    return apply_filters( 'wpinv_spain_states', $states );
1536
+    return apply_filters('wpinv_spain_states', $states);
1537 1537
 }
1538 1538
 
1539 1539
 function wpinv_get_states_field() {
1540
-	if( empty( $_POST['country'] ) ) {
1540
+	if (empty($_POST['country'])) {
1541 1541
 		$_POST['country'] = wpinv_get_default_country();
1542 1542
 	}
1543
-	$states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) );
1543
+	$states = wpinv_get_country_states(sanitize_text_field($_POST['country']));
1544 1544
 
1545
-	if( !empty( $states ) ) {
1546
-		$sanitized_field_name = sanitize_text_field( $_POST['field_name'] );
1545
+	if (!empty($states)) {
1546
+		$sanitized_field_name = sanitize_text_field($_POST['field_name']);
1547 1547
         
1548 1548
         $args = array(
1549 1549
 			'name'    => $sanitized_field_name,
1550 1550
 			'id'      => $sanitized_field_name,
1551 1551
 			'class'   => $sanitized_field_name . ' wpinv-select wpi_select2',
1552
-			'options' => array_merge( array( '' => '' ), $states ),
1552
+			'options' => array_merge(array('' => ''), $states),
1553 1553
 			'show_option_all'  => false,
1554 1554
 			'show_option_none' => false
1555 1555
 		);
1556 1556
 
1557
-		$response = wpinv_html_select( $args );
1557
+		$response = wpinv_html_select($args);
1558 1558
 
1559 1559
 	} else {
1560 1560
 		$response = 'nostates';
@@ -1563,8 +1563,8 @@  discard block
 block discarded – undo
1563 1563
 	return $response;
1564 1564
 }
1565 1565
 
1566
-function wpinv_default_billing_country( $country = '', $user_id = 0 ) {
1567
-    $country = !empty( $country ) ? $country : wpinv_get_default_country();
1566
+function wpinv_default_billing_country($country = '', $user_id = 0) {
1567
+    $country = !empty($country) ? $country : wpinv_get_default_country();
1568 1568
     
1569
-    return apply_filters( 'wpinv_default_billing_country', $country, $user_id );
1569
+    return apply_filters('wpinv_default_billing_country', $country, $user_id);
1570 1570
 }
1571 1571
\ No newline at end of file
Please login to merge, or discard this patch.
includes/wpinv-gateway-functions.php 1 patch
Spacing   +258 added lines, -258 removed lines patch added patch discarded remove patch
@@ -7,206 +7,206 @@  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
 function wpinv_get_payment_gateways() {
15 15
     // Default, built-in gateways
16 16
     $gateways = array(
17 17
         'paypal' => array(
18
-            'admin_label'    => __( 'PayPal Standard', 'invoicing' ),
19
-            'checkout_label' => __( 'PayPal Standard', 'invoicing' ),
18
+            'admin_label'    => __('PayPal Standard', 'invoicing'),
19
+            'checkout_label' => __('PayPal Standard', 'invoicing'),
20 20
             'ordering'       => 1,
21 21
         ),
22 22
         'authorizenet' => array(
23
-            'admin_label'    => __( 'Authorize.Net (AIM)', 'invoicing' ),
24
-            'checkout_label' => __( 'Authorize.Net - Credit Card / Debit Card', 'invoicing' ),
23
+            'admin_label'    => __('Authorize.Net (AIM)', 'invoicing'),
24
+            'checkout_label' => __('Authorize.Net - Credit Card / Debit Card', 'invoicing'),
25 25
             'ordering'       => 4,
26 26
         ),
27 27
         'worldpay' => array(
28
-            'admin_label'    => __( 'Worldpay', 'invoicing' ),
29
-            'checkout_label' => __( 'Worldpay - Credit Card / Debit Card', 'invoicing' ),
28
+            'admin_label'    => __('Worldpay', 'invoicing'),
29
+            'checkout_label' => __('Worldpay - Credit Card / Debit Card', 'invoicing'),
30 30
             'ordering'       => 5,
31 31
         ),
32 32
         'bank_transfer' => array(
33
-            'admin_label'    => __( 'Pre Bank Transfer', 'invoicing' ),
34
-            'checkout_label' => __( 'Pre Bank Transfer', 'invoicing' ),
33
+            'admin_label'    => __('Pre Bank Transfer', 'invoicing'),
34
+            'checkout_label' => __('Pre Bank Transfer', 'invoicing'),
35 35
             'ordering'       => 11,
36 36
         ),
37 37
         'manual' => array(
38
-            'admin_label'    => __( 'Test Payment', 'invoicing' ),
39
-            'checkout_label' => __( 'Test Payment', 'invoicing' ),
38
+            'admin_label'    => __('Test Payment', 'invoicing'),
39
+            'checkout_label' => __('Test Payment', 'invoicing'),
40 40
             'ordering'       => 12,
41 41
         ),
42 42
     );
43 43
 
44
-    return apply_filters( 'wpinv_payment_gateways', $gateways );
44
+    return apply_filters('wpinv_payment_gateways', $gateways);
45 45
 }
46 46
 
47
-function wpinv_payment_gateway_titles( $all_gateways ) {
47
+function wpinv_payment_gateway_titles($all_gateways) {
48 48
     global $wpinv_options;
49 49
     
50 50
     $gateways = array();
51
-    foreach ( $all_gateways as $key => $gateway ) {
52
-        if ( !empty( $wpinv_options[$key . '_title'] ) ) {
53
-            $all_gateways[$key]['checkout_label'] = __( $wpinv_options[$key . '_title'], 'invoicing' );
51
+    foreach ($all_gateways as $key => $gateway) {
52
+        if (!empty($wpinv_options[$key . '_title'])) {
53
+            $all_gateways[$key]['checkout_label'] = __($wpinv_options[$key . '_title'], 'invoicing');
54 54
         }
55 55
         
56
-        $gateways[$key] = isset( $wpinv_options[$key . '_ordering'] ) ? $wpinv_options[$key . '_ordering'] : ( isset( $gateway['ordering'] ) ? $gateway['ordering'] : '' );
56
+        $gateways[$key] = isset($wpinv_options[$key . '_ordering']) ? $wpinv_options[$key . '_ordering'] : (isset($gateway['ordering']) ? $gateway['ordering'] : '');
57 57
     }
58 58
 
59
-    asort( $gateways );
59
+    asort($gateways);
60 60
     
61
-    foreach ( $gateways as $gateway => $key ) {
61
+    foreach ($gateways as $gateway => $key) {
62 62
         $gateways[$gateway] = $all_gateways[$gateway];
63 63
     }
64 64
     
65 65
     return $gateways;
66 66
 }
67
-add_filter( 'wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1 );
67
+add_filter('wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1);
68 68
 
69
-function wpinv_get_enabled_payment_gateways( $sort = false ) {
69
+function wpinv_get_enabled_payment_gateways($sort = false) {
70 70
     $gateways = wpinv_get_payment_gateways();
71
-    $enabled  = wpinv_get_option( 'gateways', false );
71
+    $enabled  = wpinv_get_option('gateways', false);
72 72
 
73 73
     $gateway_list = array();
74 74
 
75
-    foreach ( $gateways as $key => $gateway ) {
76
-        if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) {
77
-            $gateway_list[ $key ] = $gateway;
75
+    foreach ($gateways as $key => $gateway) {
76
+        if (isset($enabled[$key]) && $enabled[$key] == 1) {
77
+            $gateway_list[$key] = $gateway;
78 78
         }
79 79
     }
80 80
 
81
-    if ( true === $sort ) {
82
-        uasort( $gateway_list, 'wpinv_sort_gateway_order' );
81
+    if (true === $sort) {
82
+        uasort($gateway_list, 'wpinv_sort_gateway_order');
83 83
         
84 84
         // Reorder our gateways so the default is first
85 85
         $default_gateway_id = wpinv_get_default_gateway();
86 86
 
87
-        if ( wpinv_is_gateway_active( $default_gateway_id ) ) {
88
-            $default_gateway    = array( $default_gateway_id => $gateway_list[ $default_gateway_id ] );
89
-            unset( $gateway_list[ $default_gateway_id ] );
87
+        if (wpinv_is_gateway_active($default_gateway_id)) {
88
+            $default_gateway = array($default_gateway_id => $gateway_list[$default_gateway_id]);
89
+            unset($gateway_list[$default_gateway_id]);
90 90
 
91
-            $gateway_list = array_merge( $default_gateway, $gateway_list );
91
+            $gateway_list = array_merge($default_gateway, $gateway_list);
92 92
         }
93 93
     }
94 94
 
95
-    return apply_filters( 'wpinv_enabled_payment_gateways', $gateway_list );
95
+    return apply_filters('wpinv_enabled_payment_gateways', $gateway_list);
96 96
 }
97 97
 
98
-function wpinv_sort_gateway_order( $a, $b ) {
98
+function wpinv_sort_gateway_order($a, $b) {
99 99
     return $a['ordering'] - $b['ordering'];
100 100
 }
101 101
 
102
-function wpinv_is_gateway_active( $gateway ) {
102
+function wpinv_is_gateway_active($gateway) {
103 103
     $gateways = wpinv_get_enabled_payment_gateways();
104 104
 
105
-    $ret = is_array($gateways) && $gateway ?  array_key_exists( $gateway, $gateways ) : false;
105
+    $ret = is_array($gateways) && $gateway ?  array_key_exists($gateway, $gateways) : false;
106 106
 
107
-    return apply_filters( 'wpinv_is_gateway_active', $ret, $gateway, $gateways );
107
+    return apply_filters('wpinv_is_gateway_active', $ret, $gateway, $gateways);
108 108
 }
109 109
 
110 110
 function wpinv_get_default_gateway() {
111
-    $default = wpinv_get_option( 'default_gateway', 'paypal' );
111
+    $default = wpinv_get_option('default_gateway', 'paypal');
112 112
 
113
-    if ( !wpinv_is_gateway_active( $default ) ) {
113
+    if (!wpinv_is_gateway_active($default)) {
114 114
         $gateways = wpinv_get_enabled_payment_gateways();
115
-        $gateways = array_keys( $gateways );
116
-        $default  = reset( $gateways );
115
+        $gateways = array_keys($gateways);
116
+        $default  = reset($gateways);
117 117
     }
118 118
 
119
-    return apply_filters( 'wpinv_default_gateway', $default );
119
+    return apply_filters('wpinv_default_gateway', $default);
120 120
 }
121 121
 
122
-function wpinv_get_gateway_admin_label( $gateway ) {
122
+function wpinv_get_gateway_admin_label($gateway) {
123 123
     $gateways = wpinv_get_payment_gateways();
124
-    $label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway;
125
-    $payment  = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : false;
124
+    $label    = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway;
125
+    $payment  = isset($_GET['id']) ? absint($_GET['id']) : false;
126 126
 
127
-    if( $gateway == 'manual' && $payment ) {
128
-        if( !( (float)wpinv_payment_total( $payment ) > 0 ) ) {
129
-            $label = __( 'Free Purchase', 'invoicing' );
127
+    if ($gateway == 'manual' && $payment) {
128
+        if (!((float)wpinv_payment_total($payment) > 0)) {
129
+            $label = __('Free Purchase', 'invoicing');
130 130
         }
131 131
     }
132 132
 
133
-    return apply_filters( 'wpinv_gateway_admin_label', $label, $gateway );
133
+    return apply_filters('wpinv_gateway_admin_label', $label, $gateway);
134 134
 }
135 135
 
136
-function wpinv_get_gateway_description( $gateway ) {
136
+function wpinv_get_gateway_description($gateway) {
137 137
     global $wpinv_options;
138 138
 
139
-    $description = isset( $wpinv_options[$gateway . '_desc'] ) ? $wpinv_options[$gateway . '_desc'] : '';
139
+    $description = isset($wpinv_options[$gateway . '_desc']) ? $wpinv_options[$gateway . '_desc'] : '';
140 140
 
141
-    return apply_filters( 'wpinv_gateway_description', $description, $gateway );
141
+    return apply_filters('wpinv_gateway_description', $description, $gateway);
142 142
 }
143 143
 
144
-function wpinv_get_gateway_button_label( $gateway ) {
145
-    return apply_filters( 'wpinv_gateway_' . $gateway . '_button_label', '' );
144
+function wpinv_get_gateway_button_label($gateway) {
145
+    return apply_filters('wpinv_gateway_' . $gateway . '_button_label', '');
146 146
 }
147 147
 
148
-function wpinv_get_gateway_checkout_label( $gateway ) {
148
+function wpinv_get_gateway_checkout_label($gateway) {
149 149
     $gateways = wpinv_get_payment_gateways();
150
-    $label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway;
150
+    $label    = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway;
151 151
 
152
-    if( $gateway == 'manual' ) {
153
-        $label = __( 'Manual Payment', 'invoicing' );
152
+    if ($gateway == 'manual') {
153
+        $label = __('Manual Payment', 'invoicing');
154 154
     }
155 155
 
156
-    return apply_filters( 'wpinv_gateway_checkout_label', $label, $gateway );
156
+    return apply_filters('wpinv_gateway_checkout_label', $label, $gateway);
157 157
 }
158 158
 
159
-function wpinv_settings_sections_gateways( $settings ) {
159
+function wpinv_settings_sections_gateways($settings) {
160 160
     $gateways = wpinv_get_payment_gateways();
161 161
     
162 162
     if (!empty($gateways)) {
163
-        foreach  ($gateways as $key => $gateway) {
163
+        foreach ($gateways as $key => $gateway) {
164 164
             $settings[$key] = $gateway['admin_label'];
165 165
         }
166 166
     }
167 167
     
168 168
     return $settings;    
169 169
 }
170
-add_filter( 'wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1 );
170
+add_filter('wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1);
171 171
 
172
-function wpinv_settings_gateways( $settings ) {
172
+function wpinv_settings_gateways($settings) {
173 173
     $gateways = wpinv_get_payment_gateways();
174 174
     
175 175
     if (!empty($gateways)) {
176
-        foreach  ($gateways as $key => $gateway) {
176
+        foreach ($gateways as $key => $gateway) {
177 177
             $setting = array();
178 178
             $setting[$key . '_header'] = array(
179 179
                     'id'   => 'gateway_header',
180
-                    'name' => '<h3>' . wp_sprintf( __( '%s Settings', 'invoicing' ), $gateway['admin_label'] ) . '</h3>',
180
+                    'name' => '<h3>' . wp_sprintf(__('%s Settings', 'invoicing'), $gateway['admin_label']) . '</h3>',
181 181
                     'custom' => $key,
182 182
                     'type' => 'gateway_header',
183 183
                 );
184 184
             $setting[$key . '_active'] = array(
185 185
                     'id'   => $key . '_active',
186
-                    'name' => __( 'Active', 'invoicing' ),
187
-                    'desc' => wp_sprintf( __( 'Enable %s', 'invoicing' ), $gateway['admin_label'] ),
186
+                    'name' => __('Active', 'invoicing'),
187
+                    'desc' => wp_sprintf(__('Enable %s', 'invoicing'), $gateway['admin_label']),
188 188
                     'type' => 'checkbox',
189 189
                 );
190 190
                 
191 191
             $setting[$key . '_title'] = array(
192 192
                     'id'   => $key . '_title',
193
-                    'name' => __( 'Title', 'invoicing' ),
194
-                    'desc' => __( 'This controls the title which the user sees during checkout.', 'invoicing' ),
193
+                    'name' => __('Title', 'invoicing'),
194
+                    'desc' => __('This controls the title which the user sees during checkout.', 'invoicing'),
195 195
                     'type' => 'text',
196 196
                     'std' => isset($gateway['checkout_label']) ? $gateway['checkout_label'] : ''
197 197
                 );
198 198
             
199 199
             $setting[$key . '_desc'] = array(
200 200
                     'id'   => $key . '_desc',
201
-                    'name' => __( 'Description', 'invoicing' ),
202
-                    'desc' => __( 'This controls the description which the user sees during checkout.', 'invoicing' ),
201
+                    'name' => __('Description', 'invoicing'),
202
+                    'desc' => __('This controls the description which the user sees during checkout.', 'invoicing'),
203 203
                     'type' => 'text',
204 204
                     'size' => 'large'
205 205
                 );
206 206
                 
207 207
             $setting[$key . '_ordering'] = array(
208 208
                     'id'   => $key . '_ordering',
209
-                    'name' => __( 'Display Order', 'invoicing' ),
209
+                    'name' => __('Display Order', 'invoicing'),
210 210
                     'type' => 'number',
211 211
                     'size' => 'small',
212 212
                     'std'  => isset($gateway['ordering']) ? $gateway['ordering'] : '10',
@@ -215,8 +215,8 @@  discard block
 block discarded – undo
215 215
                     'step' => '1'
216 216
                 );
217 217
                 
218
-            $setting = apply_filters( 'wpinv_gateway_settings', $setting, $key );
219
-            $setting = apply_filters( 'wpinv_gateway_settings_' . $key, $setting );
218
+            $setting = apply_filters('wpinv_gateway_settings', $setting, $key);
219
+            $setting = apply_filters('wpinv_gateway_settings_' . $key, $setting);
220 220
             
221 221
             $settings[$key] = $setting;
222 222
         }
@@ -224,106 +224,106 @@  discard block
 block discarded – undo
224 224
     
225 225
     return $settings;    
226 226
 }
227
-add_filter( 'wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1 );
227
+add_filter('wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1);
228 228
 
229
-function wpinv_gateway_header_callback( $args ) {
230
-    echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr( $args['custom'] ) . '" />';
229
+function wpinv_gateway_header_callback($args) {
230
+    echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr($args['custom']) . '" />';
231 231
 }
232 232
 
233
-function wpinv_get_gateway_supports( $gateway ) {
233
+function wpinv_get_gateway_supports($gateway) {
234 234
     $gateways = wpinv_get_enabled_payment_gateways();
235
-    $supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array();
236
-    return apply_filters( 'wpinv_gateway_supports', $supports, $gateway );
235
+    $supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array();
236
+    return apply_filters('wpinv_gateway_supports', $supports, $gateway);
237 237
 }
238 238
 
239
-function wpinv_gateway_supports_buy_now( $gateway ) {
240
-    $supports = wpinv_get_gateway_supports( $gateway );
241
-    $ret = in_array( 'buy_now', $supports );
242
-    return apply_filters( 'wpinv_gateway_supports_buy_now', $ret, $gateway );
239
+function wpinv_gateway_supports_buy_now($gateway) {
240
+    $supports = wpinv_get_gateway_supports($gateway);
241
+    $ret = in_array('buy_now', $supports);
242
+    return apply_filters('wpinv_gateway_supports_buy_now', $ret, $gateway);
243 243
 }
244 244
 
245 245
 function wpinv_shop_supports_buy_now() {
246 246
     $gateways = wpinv_get_enabled_payment_gateways();
247 247
     $ret      = false;
248 248
 
249
-    if ( !wpinv_use_taxes()  && $gateways ) {
250
-        foreach ( $gateways as $gateway_id => $gateway ) {
251
-            if ( wpinv_gateway_supports_buy_now( $gateway_id ) ) {
249
+    if (!wpinv_use_taxes() && $gateways) {
250
+        foreach ($gateways as $gateway_id => $gateway) {
251
+            if (wpinv_gateway_supports_buy_now($gateway_id)) {
252 252
                 $ret = true;
253 253
                 break;
254 254
             }
255 255
         }
256 256
     }
257 257
 
258
-    return apply_filters( 'wpinv_shop_supports_buy_now', $ret );
258
+    return apply_filters('wpinv_shop_supports_buy_now', $ret);
259 259
 }
260 260
 
261
-function wpinv_send_to_gateway( $gateway, $payment_data ) {
262
-    $payment_data['gateway_nonce'] = wp_create_nonce( 'wpi-gateway' );
261
+function wpinv_send_to_gateway($gateway, $payment_data) {
262
+    $payment_data['gateway_nonce'] = wp_create_nonce('wpi-gateway');
263 263
 
264 264
     // $gateway must match the ID used when registering the gateway
265
-    do_action( 'wpinv_gateway_' . $gateway, $payment_data );
265
+    do_action('wpinv_gateway_' . $gateway, $payment_data);
266 266
 }
267 267
 
268 268
 function wpinv_show_gateways() {
269 269
     $gateways = wpinv_get_enabled_payment_gateways();
270 270
     $show_gateways = false;
271 271
 
272
-    $chosen_gateway = isset( $_GET['payment-mode'] ) ? preg_replace('/[^a-zA-Z0-9-_]+/', '', $_GET['payment-mode'] ) : false;
272
+    $chosen_gateway = isset($_GET['payment-mode']) ? preg_replace('/[^a-zA-Z0-9-_]+/', '', $_GET['payment-mode']) : false;
273 273
 
274
-    if ( count( $gateways ) > 1 && empty( $chosen_gateway ) ) {
274
+    if (count($gateways) > 1 && empty($chosen_gateway)) {
275 275
         $show_gateways = true;
276
-        if ( wpinv_get_cart_total() <= 0 ) {
276
+        if (wpinv_get_cart_total() <= 0) {
277 277
             $show_gateways = false;
278 278
         }
279 279
     }
280 280
     
281
-    if ( !$show_gateways && wpinv_cart_has_recurring_item() ) {
281
+    if (!$show_gateways && wpinv_cart_has_recurring_item()) {
282 282
         $show_gateways = true;
283 283
     }
284 284
 
285
-    return apply_filters( 'wpinv_show_gateways', $show_gateways );
285
+    return apply_filters('wpinv_show_gateways', $show_gateways);
286 286
 }
287 287
 
288
-function wpinv_get_chosen_gateway( $invoice_id = 0 ) {
289
-	$gateways = array_keys( wpinv_get_enabled_payment_gateways() );
288
+function wpinv_get_chosen_gateway($invoice_id = 0) {
289
+	$gateways = array_keys(wpinv_get_enabled_payment_gateways());
290 290
 
291 291
     $chosen = false;
292
-    if ( $invoice_id > 0 && $invoice = wpinv_get_invoice( $invoice_id ) ) {
292
+    if ($invoice_id > 0 && $invoice = wpinv_get_invoice($invoice_id)) {
293 293
         $chosen = $invoice->get_gateway();
294 294
     }
295 295
 
296
-	$chosen   = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen;
296
+	$chosen = isset($_REQUEST['payment-mode']) ? sanitize_text_field($_REQUEST['payment-mode']) : $chosen;
297 297
 
298
-	if ( false !== $chosen ) {
299
-		$chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen );
298
+	if (false !== $chosen) {
299
+		$chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen);
300 300
 	}
301 301
 
302
-	if ( ! empty ( $chosen ) ) {
303
-		$enabled_gateway = urldecode( $chosen );
304
-	} else if (  !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) {
302
+	if (!empty ($chosen)) {
303
+		$enabled_gateway = urldecode($chosen);
304
+	} else if (!empty($invoice) && (float)$invoice->get_subtotal() <= 0) {
305 305
 		$enabled_gateway = 'manual';
306 306
 	} else {
307 307
 		$enabled_gateway = wpinv_get_default_gateway();
308 308
 	}
309 309
     
310
-    if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) {
311
-        if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){
310
+    if (!wpinv_is_gateway_active($enabled_gateway) && !empty($gateways)) {
311
+        if (wpinv_is_gateway_active(wpinv_get_default_gateway())) {
312 312
             $enabled_gateway = wpinv_get_default_gateway();
313
-        }else{
313
+        } else {
314 314
             $enabled_gateway = $gateways[0];
315 315
         }
316 316
 
317 317
     }
318 318
 
319
-	return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway );
319
+	return apply_filters('wpinv_chosen_gateway', $enabled_gateway);
320 320
 }
321 321
 
322
-function wpinv_record_gateway_error( $title = '', $message = '', $parent = 0 ) {
323
-    return wpinv_error_log( $message, $title );
322
+function wpinv_record_gateway_error($title = '', $message = '', $parent = 0) {
323
+    return wpinv_error_log($message, $title);
324 324
 }
325 325
 
326
-function wpinv_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) {
326
+function wpinv_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') {
327 327
 	$ret  = 0;
328 328
 	$args = array(
329 329
 		'meta_key'    => '_wpinv_gateway',
@@ -334,48 +334,48 @@  discard block
 block discarded – undo
334 334
 		'fields'      => 'ids'
335 335
 	);
336 336
 
337
-	$payments = new WP_Query( $args );
337
+	$payments = new WP_Query($args);
338 338
 
339
-	if( $payments )
339
+	if ($payments)
340 340
 		$ret = $payments->post_count;
341 341
 	return $ret;
342 342
 }
343 343
 
344
-function wpinv_settings_update_gateways( $input ) {
344
+function wpinv_settings_update_gateways($input) {
345 345
     global $wpinv_options;
346 346
     
347
-    if ( !empty( $input['save_gateway'] ) ) {
348
-        $gateways = wpinv_get_option( 'gateways', false );
347
+    if (!empty($input['save_gateway'])) {
348
+        $gateways = wpinv_get_option('gateways', false);
349 349
         $gateways = !empty($gateways) ? $gateways : array();
350 350
         $gateway = $input['save_gateway'];
351 351
         
352
-        if ( !empty( $input[$gateway . '_active'] ) ) {
352
+        if (!empty($input[$gateway . '_active'])) {
353 353
             $gateways[$gateway] = 1;
354 354
         } else {
355
-            if ( isset( $gateways[$gateway] ) ) {
356
-                unset( $gateways[$gateway] );
355
+            if (isset($gateways[$gateway])) {
356
+                unset($gateways[$gateway]);
357 357
             }
358 358
         }
359 359
         
360 360
         $input['gateways'] = $gateways;
361 361
     }
362 362
     
363
-    if ( !empty( $input['default_gateway'] ) ) {
363
+    if (!empty($input['default_gateway'])) {
364 364
         $gateways = wpinv_get_payment_gateways();
365 365
         
366
-        foreach ( $gateways as $key => $gateway ) {
367
-            $active   = 0;
368
-            if ( !empty( $input['gateways'] ) && !empty( $input['gateways'][$key] ) ) {
366
+        foreach ($gateways as $key => $gateway) {
367
+            $active = 0;
368
+            if (!empty($input['gateways']) && !empty($input['gateways'][$key])) {
369 369
                 $active = 1;
370 370
             }
371 371
             
372 372
             $input[$key . '_active'] = $active;
373 373
             
374
-            if ( empty( $wpinv_options[$key . '_title'] ) ) {
374
+            if (empty($wpinv_options[$key . '_title'])) {
375 375
                 $input[$key . '_title'] = $gateway['checkout_label'];
376 376
             }
377 377
             
378
-            if ( !isset( $wpinv_options[$key . '_ordering'] ) && isset( $gateway['ordering'] ) ) {
378
+            if (!isset($wpinv_options[$key . '_ordering']) && isset($gateway['ordering'])) {
379 379
                 $input[$key . '_ordering'] = $gateway['ordering'];
380 380
             }
381 381
         }
@@ -383,27 +383,27 @@  discard block
 block discarded – undo
383 383
     
384 384
     return $input;
385 385
 }
386
-add_filter( 'wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1 );
386
+add_filter('wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1);
387 387
 
388 388
 // PayPal Standard settings
389
-function wpinv_gateway_settings_paypal( $setting ) {    
390
-    $setting['paypal_active']['desc'] = $setting['paypal_active']['desc'] . ' ' . __( '( Supported Currencies: AUD, BRL, CAD, CZK, DKK, EUR, HKD, HUF, ILS, JPY, MYR, MXN, NOK, NZD, PHP, PLN, GBP, SGD, SEK, CHF, TWD, THB, USD )', 'invoicing' );
391
-    $setting['paypal_desc']['std'] = __( 'Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing' );
389
+function wpinv_gateway_settings_paypal($setting) {    
390
+    $setting['paypal_active']['desc'] = $setting['paypal_active']['desc'] . ' ' . __('( Supported Currencies: AUD, BRL, CAD, CZK, DKK, EUR, HKD, HUF, ILS, JPY, MYR, MXN, NOK, NZD, PHP, PLN, GBP, SGD, SEK, CHF, TWD, THB, USD )', 'invoicing');
391
+    $setting['paypal_desc']['std'] = __('Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing');
392 392
     
393 393
     $setting['paypal_sandbox'] = array(
394 394
             'type' => 'checkbox',
395 395
             'id'   => 'paypal_sandbox',
396
-            'name' => __( 'PayPal Sandbox', 'invoicing' ),
397
-            'desc' => __( 'PayPal sandbox can be used to test payments.', 'invoicing' ),
396
+            'name' => __('PayPal Sandbox', 'invoicing'),
397
+            'desc' => __('PayPal sandbox can be used to test payments.', 'invoicing'),
398 398
             'std'  => 1
399 399
         );
400 400
         
401 401
     $setting['paypal_email'] = array(
402 402
             'type' => 'text',
403 403
             'id'   => 'paypal_email',
404
-            'name' => __( 'PayPal Email', 'invoicing' ),
405
-            'desc' => __( 'Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing' ),
406
-            'std' => __( '[email protected]', 'invoicing' ),
404
+            'name' => __('PayPal Email', 'invoicing'),
405
+            'desc' => __('Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing'),
406
+            'std' => __('[email protected]', 'invoicing'),
407 407
         );
408 408
     /*
409 409
     $setting['paypal_ipn_url'] = array(
@@ -417,139 +417,139 @@  discard block
 block discarded – undo
417 417
         
418 418
     return $setting;
419 419
 }
420
-add_filter( 'wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1 );
420
+add_filter('wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1);
421 421
 
422 422
 // Pre Bank Transfer settings
423
-function wpinv_gateway_settings_bank_transfer( $setting ) {
424
-    $setting['bank_transfer_desc']['std'] = __( 'Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing' );
423
+function wpinv_gateway_settings_bank_transfer($setting) {
424
+    $setting['bank_transfer_desc']['std'] = __('Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing');
425 425
     
426 426
     $setting['bank_transfer_ac_name'] = array(
427 427
             'type' => 'text',
428 428
             'id' => 'bank_transfer_ac_name',
429
-            'name' => __( 'Account Name', 'invoicing' ),
430
-            'desc' => __( 'Enter the bank account name to which you want to transfer payment.', 'invoicing' ),
431
-            'std'  =>  __( 'Mr. John Martin', 'invoicing' ),
429
+            'name' => __('Account Name', 'invoicing'),
430
+            'desc' => __('Enter the bank account name to which you want to transfer payment.', 'invoicing'),
431
+            'std'  =>  __('Mr. John Martin', 'invoicing'),
432 432
         );
433 433
     
434 434
     $setting['bank_transfer_ac_no'] = array(
435 435
             'type' => 'text',
436 436
             'id' => 'bank_transfer_ac_no',
437
-            'name' => __( 'Account Number', 'invoicing' ),
438
-            'desc' => __( 'Enter your bank account number.', 'invoicing' ),
439
-            'std'  =>  __( 'TEST1234567890', 'invoicing' ),
437
+            'name' => __('Account Number', 'invoicing'),
438
+            'desc' => __('Enter your bank account number.', 'invoicing'),
439
+            'std'  =>  __('TEST1234567890', 'invoicing'),
440 440
         );
441 441
     
442 442
     $setting['bank_transfer_bank_name'] = array(
443 443
             'type' => 'text',
444 444
             'id'   => 'bank_transfer_bank_name',
445
-            'name' => __( 'Bank Name', 'invoicing' ),
446
-            'desc' => __( 'Enter the bank name to which you want to transfer payment.', 'invoicing' ),
447
-            'std' => __( 'ICICI Bank', 'invoicing' ),
445
+            'name' => __('Bank Name', 'invoicing'),
446
+            'desc' => __('Enter the bank name to which you want to transfer payment.', 'invoicing'),
447
+            'std' => __('ICICI Bank', 'invoicing'),
448 448
         );
449 449
     
450 450
     $setting['bank_transfer_ifsc'] = array(
451 451
             'type' => 'text',
452 452
             'id'   => 'bank_transfer_ifsc',
453
-            'name' => __( 'IFSC Code', 'invoicing' ),
454
-            'desc' => __( 'Enter your bank IFSC code.', 'invoicing' ),
455
-            'std'  =>  __( 'ICIC0001234', 'invoicing' ),
453
+            'name' => __('IFSC Code', 'invoicing'),
454
+            'desc' => __('Enter your bank IFSC code.', 'invoicing'),
455
+            'std'  =>  __('ICIC0001234', 'invoicing'),
456 456
         );
457 457
         
458 458
     $setting['bank_transfer_iban'] = array(
459 459
             'type' => 'text',
460 460
             'id'   => 'bank_transfer_iban',
461
-            'name' => __( 'IBAN', 'invoicing' ),
462
-            'desc' => __( 'Enter your International Bank Account Number(IBAN).', 'invoicing' ),
463
-            'std'  =>  __( 'GB29NWBK60161331926819', 'invoicing' ),
461
+            'name' => __('IBAN', 'invoicing'),
462
+            'desc' => __('Enter your International Bank Account Number(IBAN).', 'invoicing'),
463
+            'std'  =>  __('GB29NWBK60161331926819', 'invoicing'),
464 464
         );
465 465
         
466 466
     $setting['bank_transfer_bic'] = array(
467 467
             'type' => 'text',
468 468
             'id'   => 'bank_transfer_bic',
469
-            'name' => __( 'BIC/Swift Code', 'invoicing' ),
470
-            'std'  =>  __( 'ICICGB2L129', 'invoicing' ),
469
+            'name' => __('BIC/Swift Code', 'invoicing'),
470
+            'std'  =>  __('ICICGB2L129', 'invoicing'),
471 471
         );
472 472
 
473 473
     $setting['bank_transfer_sort_code'] = array(
474 474
         'type' => 'text',
475 475
         'id'   => 'bank_transfer_sort_code',
476
-        'name' => __( 'Sort Code', 'invoicing' ),
477
-        'std'  =>  __( '12-34-56', 'invoicing' ),
476
+        'name' => __('Sort Code', 'invoicing'),
477
+        'std'  =>  __('12-34-56', 'invoicing'),
478 478
     );
479 479
         
480 480
     $setting['bank_transfer_info'] = array(
481 481
             'id'   => 'bank_transfer_info',
482
-            'name' => __( 'Instructions', 'invoicing' ),
483
-            'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ),
482
+            'name' => __('Instructions', 'invoicing'),
483
+            'desc' => __('Instructions that will be added to the thank you page and emails.', 'invoicing'),
484 484
             'type' => 'textarea',
485
-            'std' => __( 'Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing' ),
485
+            'std' => __('Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing'),
486 486
             'cols' => 37,
487 487
             'rows' => 5
488 488
         );
489 489
         
490 490
     return $setting;
491 491
 }
492
-add_filter( 'wpinv_gateway_settings_bank_transfer', 'wpinv_gateway_settings_bank_transfer', 10, 1 );
492
+add_filter('wpinv_gateway_settings_bank_transfer', 'wpinv_gateway_settings_bank_transfer', 10, 1);
493 493
 
494 494
 // Authorize.Net settings
495
-function wpinv_gateway_settings_authorizenet( $setting ) {
496
-    $setting['authorizenet_active']['desc'] = $setting['authorizenet_active']['desc'] . ' ' . __( '( Supported Currencies: AUD, CAD, CHF, DKK, EUR, GBP, JPY, NOK, NZD, PLN, SEK, USD, ZAR )', 'invoicing' );
497
-    $setting['authorizenet_desc']['std'] = __( 'Pay using a Authorize.Net to process Credit card / Debit card transactions.', 'invoicing' );
495
+function wpinv_gateway_settings_authorizenet($setting) {
496
+    $setting['authorizenet_active']['desc'] = $setting['authorizenet_active']['desc'] . ' ' . __('( Supported Currencies: AUD, CAD, CHF, DKK, EUR, GBP, JPY, NOK, NZD, PLN, SEK, USD, ZAR )', 'invoicing');
497
+    $setting['authorizenet_desc']['std'] = __('Pay using a Authorize.Net to process Credit card / Debit card transactions.', 'invoicing');
498 498
     
499 499
     $setting['authorizenet_sandbox'] = array(
500 500
             'type' => 'checkbox',
501 501
             'id'   => 'authorizenet_sandbox',
502
-            'name' => __( 'Authorize.Net Test Mode', 'invoicing' ),
503
-            'desc' => __( 'Enable Authorize.Net test mode to test payments.', 'invoicing' ),
502
+            'name' => __('Authorize.Net Test Mode', 'invoicing'),
503
+            'desc' => __('Enable Authorize.Net test mode to test payments.', 'invoicing'),
504 504
             'std'  => 1
505 505
         );
506 506
         
507 507
     $setting['authorizenet_login_id'] = array(
508 508
             'type' => 'text',
509 509
             'id'   => 'authorizenet_login_id',
510
-            'name' => __( 'API Login ID', 'invoicing' ),
511
-            'desc' => __( 'API Login ID can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 2j4rBekUnD', 'invoicing' ),
510
+            'name' => __('API Login ID', 'invoicing'),
511
+            'desc' => __('API Login ID can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 2j4rBekUnD', 'invoicing'),
512 512
             'std' => '2j4rBekUnD',
513 513
         );
514 514
     
515 515
     $setting['authorizenet_transaction_key'] = array(
516 516
             'type' => 'text',
517 517
             'id'   => 'authorizenet_transaction_key',
518
-            'name' => __( 'Transaction Key', 'invoicing' ),
519
-            'desc' => __( 'Transaction Key can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 4vyBUOJgR74679xa', 'invoicing' ),
518
+            'name' => __('Transaction Key', 'invoicing'),
519
+            'desc' => __('Transaction Key can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 4vyBUOJgR74679xa', 'invoicing'),
520 520
             'std' => '4vyBUOJgR74679xa',
521 521
         );
522 522
         
523 523
     $setting['authorizenet_md5_hash'] = array(
524 524
             'type' => 'text',
525 525
             'id'   => 'authorizenet_md5_hash',
526
-            'name' => __( 'MD5-Hash', 'invoicing' ),
527
-            'desc' => __( 'The MD5 Hash security feature allows to authenticate transaction responses from the Authorize.Net for recurring payments. It can be obtained from Authorize.Net Account > Settings > Security Settings > General Settings > MD5 Hash.', 'invoicing' ),
526
+            'name' => __('MD5-Hash', 'invoicing'),
527
+            'desc' => __('The MD5 Hash security feature allows to authenticate transaction responses from the Authorize.Net for recurring payments. It can be obtained from Authorize.Net Account > Settings > Security Settings > General Settings > MD5 Hash.', 'invoicing'),
528 528
             'std' => '',
529 529
         );
530 530
 
531 531
     $setting['authorizenet_transaction_type'] = array(
532 532
         'id'          => 'authorizenet_transaction_type',
533
-        'name'        => __( 'Transaction Type', 'invoicing' ),
534
-        'desc'        => __( 'Choose transaction type.', 'invoicing' ),
533
+        'name'        => __('Transaction Type', 'invoicing'),
534
+        'desc'        => __('Choose transaction type.', 'invoicing'),
535 535
         'type'        => 'select',
536 536
         'class'       => 'wpi_select2',
537 537
         'options'     => array(
538
-            'authorize_capture' => __( 'Authorize And Capture', 'invoicing' ),
539
-            'authorize_only' => __( 'Authorize Only', 'invoicing' ),
538
+            'authorize_capture' => __('Authorize And Capture', 'invoicing'),
539
+            'authorize_only' => __('Authorize Only', 'invoicing'),
540 540
         ),
541 541
         'std'         => 'authorize_capture'
542 542
     );
543 543
 
544 544
     $setting['authorizenet_transaction_type_recurring'] = array(
545 545
         'id'          => 'authorizenet_transaction_type_recurring',
546
-        'name'        => __( 'Transaction Type for Recurring', 'invoicing' ),
547
-        'desc'        => __( 'Choose transaction type for recurring payments.', 'invoicing' ),
546
+        'name'        => __('Transaction Type for Recurring', 'invoicing'),
547
+        'desc'        => __('Choose transaction type for recurring payments.', 'invoicing'),
548 548
         'type'        => 'select',
549 549
         'class'       => 'wpi_select2',
550 550
         'options'     => array(
551
-            'authorize_capture' => __( 'Authorize And Capture', 'invoicing' ),
552
-            'authorize_only' => __( 'Authorize Only', 'invoicing' ),
551
+            'authorize_capture' => __('Authorize And Capture', 'invoicing'),
552
+            'authorize_only' => __('Authorize Only', 'invoicing'),
553 553
         ),
554 554
         'std'         => 'authorize_only'
555 555
     );
@@ -557,9 +557,9 @@  discard block
 block discarded – undo
557 557
     $setting['authorizenet_ipn_url'] = array(
558 558
             'type' => 'ipn_url',
559 559
             'id'   => 'authorizenet_ipn_url',
560
-            'name' => __( 'Silent Post URL', 'invoicing' ),
561
-            'std' => wpinv_get_ipn_url( 'authorizenet' ),
562
-            'desc' => __( 'If you are accepting recurring payments then you must set this url at Authorize.Net Account > Settings > Transaction Format Settings > Transaction Response Settings > Silent Post URL.', 'invoicing' ),
560
+            'name' => __('Silent Post URL', 'invoicing'),
561
+            'std' => wpinv_get_ipn_url('authorizenet'),
562
+            'desc' => __('If you are accepting recurring payments then you must set this url at Authorize.Net Account > Settings > Transaction Format Settings > Transaction Response Settings > Silent Post URL.', 'invoicing'),
563 563
             'size' => 'large',
564 564
             'custom' => 'authorizenet',
565 565
             'readonly' => true
@@ -567,26 +567,26 @@  discard block
 block discarded – undo
567 567
         
568 568
     return $setting;
569 569
 }
570
-add_filter( 'wpinv_gateway_settings_authorizenet', 'wpinv_gateway_settings_authorizenet', 10, 1 );
570
+add_filter('wpinv_gateway_settings_authorizenet', 'wpinv_gateway_settings_authorizenet', 10, 1);
571 571
 
572 572
 // Worldpay settings
573
-function wpinv_gateway_settings_worldpay( $setting ) {
574
-    $setting['worldpay_active']['desc'] = $setting['worldpay_active']['desc'] . ' ' . __( '( Supported Currencies: AUD, ARS, CAD, CHF, DKK, EUR, HKD, MYR, GBP, NZD, NOK, SGD, LKR, SEK, TRY, USD, ZAR )', 'invoicing' );
575
-    $setting['worldpay_desc']['std'] = __( 'Pay using a Worldpay account to process Credit card / Debit card transactions.', 'invoicing' );
573
+function wpinv_gateway_settings_worldpay($setting) {
574
+    $setting['worldpay_active']['desc'] = $setting['worldpay_active']['desc'] . ' ' . __('( Supported Currencies: AUD, ARS, CAD, CHF, DKK, EUR, HKD, MYR, GBP, NZD, NOK, SGD, LKR, SEK, TRY, USD, ZAR )', 'invoicing');
575
+    $setting['worldpay_desc']['std'] = __('Pay using a Worldpay account to process Credit card / Debit card transactions.', 'invoicing');
576 576
     
577 577
     $setting['worldpay_sandbox'] = array(
578 578
             'type' => 'checkbox',
579 579
             'id'   => 'worldpay_sandbox',
580
-            'name' => __( 'Worldpay Test Mode', 'invoicing' ),
581
-            'desc' => __( 'This provides a special Test Environment to enable you to test your installation and integration to your website before going live.', 'invoicing' ),
580
+            'name' => __('Worldpay Test Mode', 'invoicing'),
581
+            'desc' => __('This provides a special Test Environment to enable you to test your installation and integration to your website before going live.', 'invoicing'),
582 582
             'std'  => 1
583 583
         );
584 584
         
585 585
     $setting['worldpay_instId'] = array(
586 586
             'type' => 'text',
587 587
             'id'   => 'worldpay_instId',
588
-            'name' => __( 'Installation Id', 'invoicing' ),
589
-            'desc' => __( 'Your installation id. Ex: 211616', 'invoicing' ),
588
+            'name' => __('Installation Id', 'invoicing'),
589
+            'desc' => __('Your installation id. Ex: 211616', 'invoicing'),
590 590
             'std' => '211616',
591 591
         );
592 592
     /*
@@ -602,9 +602,9 @@  discard block
 block discarded – undo
602 602
     $setting['worldpay_ipn_url'] = array(
603 603
             'type' => 'ipn_url',
604 604
             'id'   => 'worldpay_ipn_url',
605
-            'name' => __( 'Worldpay Callback Url', 'invoicing' ),
606
-            'std' => wpinv_get_ipn_url( 'worldpay' ),
607
-            'desc' => wp_sprintf( __( 'Login to your Worldpay Merchant Interface then enable Payment Response & Shopper Response. Next, go to the Payment Response URL field and type "%s" or "%s" for a dynamic payment response.', 'invoicing' ), '<font style="color:#000;font-style:normal">' . wpinv_get_ipn_url( 'worldpay' ) . '</font>', '<font style="color:#000;font-style:normal">&lt;wpdisplay item=MC_callback&gt;</font>' ),
605
+            'name' => __('Worldpay Callback Url', 'invoicing'),
606
+            'std' => wpinv_get_ipn_url('worldpay'),
607
+            'desc' => wp_sprintf(__('Login to your Worldpay Merchant Interface then enable Payment Response & Shopper Response. Next, go to the Payment Response URL field and type "%s" or "%s" for a dynamic payment response.', 'invoicing'), '<font style="color:#000;font-style:normal">' . wpinv_get_ipn_url('worldpay') . '</font>', '<font style="color:#000;font-style:normal">&lt;wpdisplay item=MC_callback&gt;</font>'),
608 608
             'size' => 'large',
609 609
             'custom' => 'worldpay',
610 610
             'readonly' => true
@@ -612,99 +612,99 @@  discard block
 block discarded – undo
612 612
         
613 613
     return $setting;
614 614
 }
615
-add_filter( 'wpinv_gateway_settings_worldpay', 'wpinv_gateway_settings_worldpay', 10, 1 );
615
+add_filter('wpinv_gateway_settings_worldpay', 'wpinv_gateway_settings_worldpay', 10, 1);
616 616
 
617
-function wpinv_ipn_url_callback( $args ) {    
618
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
617
+function wpinv_ipn_url_callback($args) {    
618
+    $sanitize_id = wpinv_sanitize_key($args['id']);
619 619
     
620 620
     $attrs = $args['readonly'] ? ' readonly' : '';
621 621
 
622
-    $html = '<input style="background-color:#fefefe" type="text" ' . $attrs . ' value="' . esc_attr( $args['std'] ) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" class="large-text">';
623
-    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">'  . $args['desc'] . '</label>';
622
+    $html = '<input style="background-color:#fefefe" type="text" ' . $attrs . ' value="' . esc_attr($args['std']) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" class="large-text">';
623
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>';
624 624
 
625 625
     echo $html;
626 626
 }
627 627
 
628
-function wpinv_is_test_mode( $gateway = '' ) {
629
-    if ( empty( $gateway ) ) {
628
+function wpinv_is_test_mode($gateway = '') {
629
+    if (empty($gateway)) {
630 630
         return false;
631 631
     }
632 632
     
633
-    $is_test_mode = wpinv_get_option( $gateway . '_sandbox', false );
633
+    $is_test_mode = wpinv_get_option($gateway . '_sandbox', false);
634 634
     
635
-    return apply_filters( 'wpinv_is_test_mode', $is_test_mode, $gateway );
635
+    return apply_filters('wpinv_is_test_mode', $is_test_mode, $gateway);
636 636
 }
637 637
 
638
-function wpinv_get_ipn_url( $gateway = '', $args = array() ) {
639
-    $data = array( 'wpi-listener' => 'IPN' );
638
+function wpinv_get_ipn_url($gateway = '', $args = array()) {
639
+    $data = array('wpi-listener' => 'IPN');
640 640
     
641
-    if ( !empty( $gateway ) ) {
642
-        $data['wpi-gateway'] = wpinv_sanitize_key( $gateway );
641
+    if (!empty($gateway)) {
642
+        $data['wpi-gateway'] = wpinv_sanitize_key($gateway);
643 643
     }
644 644
     
645
-    $args = !empty( $args ) && is_array( $args ) ? array_merge( $data, $args ) : $data;
645
+    $args = !empty($args) && is_array($args) ? array_merge($data, $args) : $data;
646 646
     
647
-    $ipn_url = add_query_arg( $args,  home_url( 'index.php' ) );
647
+    $ipn_url = add_query_arg($args, home_url('index.php'));
648 648
     
649
-    return apply_filters( 'wpinv_ipn_url', $ipn_url );
649
+    return apply_filters('wpinv_ipn_url', $ipn_url);
650 650
 }
651 651
 
652 652
 function wpinv_listen_for_payment_ipn() {
653 653
     // Regular PayPal IPN
654
-    if ( isset( $_GET['wpi-listener'] ) && $_GET['wpi-listener'] == 'IPN' ) {
655
-        do_action( 'wpinv_verify_payment_ipn' );
654
+    if (isset($_GET['wpi-listener']) && $_GET['wpi-listener'] == 'IPN') {
655
+        do_action('wpinv_verify_payment_ipn');
656 656
         
657
-        if ( !empty( $_GET['wpi-gateway'] ) ) {
658
-            wpinv_error_log( sanitize_text_field( $_GET['wpi-gateway'] ), 'WP Invoicing IPN', __FILE__, __LINE__ );
659
-            do_action( 'wpinv_verify_' . sanitize_text_field( $_GET['wpi-gateway'] ) . '_ipn' );
657
+        if (!empty($_GET['wpi-gateway'])) {
658
+            wpinv_error_log(sanitize_text_field($_GET['wpi-gateway']), 'WP Invoicing IPN', __FILE__, __LINE__);
659
+            do_action('wpinv_verify_' . sanitize_text_field($_GET['wpi-gateway']) . '_ipn');
660 660
         }
661 661
     }
662 662
 }
663
-add_action( 'init', 'wpinv_listen_for_payment_ipn' );
663
+add_action('init', 'wpinv_listen_for_payment_ipn');
664 664
 
665 665
 function wpinv_get_bank_instructions() {
666
-    $bank_instructions = wpinv_get_option( 'bank_transfer_info' );
666
+    $bank_instructions = wpinv_get_option('bank_transfer_info');
667 667
     
668
-    return apply_filters( 'wpinv_bank_instructions', $bank_instructions );
668
+    return apply_filters('wpinv_bank_instructions', $bank_instructions);
669 669
 }
670 670
 
671
-function wpinv_get_bank_info( $filtered = false ) {
671
+function wpinv_get_bank_info($filtered = false) {
672 672
     $bank_fields = array(
673
-        'bank_transfer_ac_name'     => __( 'Account Name', 'invoicing' ),
674
-        'bank_transfer_ac_no'       => __( 'Account Number', 'invoicing' ),
675
-        'bank_transfer_bank_name'   => __( 'Bank Name', 'invoicing' ),
676
-        'bank_transfer_ifsc'        => __( 'IFSC code', 'invoicing' ),
677
-        'bank_transfer_iban'        => __( 'IBAN', 'invoicing' ),
678
-        'bank_transfer_bic'         => __( 'BIC/Swift code', 'invoicing' ),
679
-        'bank_transfer_sort_code'   => __( 'Sort Code', 'invoicing' )
673
+        'bank_transfer_ac_name'     => __('Account Name', 'invoicing'),
674
+        'bank_transfer_ac_no'       => __('Account Number', 'invoicing'),
675
+        'bank_transfer_bank_name'   => __('Bank Name', 'invoicing'),
676
+        'bank_transfer_ifsc'        => __('IFSC code', 'invoicing'),
677
+        'bank_transfer_iban'        => __('IBAN', 'invoicing'),
678
+        'bank_transfer_bic'         => __('BIC/Swift code', 'invoicing'),
679
+        'bank_transfer_sort_code'   => __('Sort Code', 'invoicing')
680 680
     );
681 681
     
682 682
     $bank_info = array();
683
-    foreach ( $bank_fields as $field => $label ) {
684
-        if ( $filtered && !( $value = wpinv_get_option( $field ) ) ) {
683
+    foreach ($bank_fields as $field => $label) {
684
+        if ($filtered && !($value = wpinv_get_option($field))) {
685 685
             continue;
686 686
         }
687 687
         
688
-        $bank_info[$field] = array( 'label' => $label, 'value' => $value );
688
+        $bank_info[$field] = array('label' => $label, 'value' => $value);
689 689
     }
690 690
     
691
-    return apply_filters( 'wpinv_bank_info', $bank_info, $filtered );
691
+    return apply_filters('wpinv_bank_info', $bank_info, $filtered);
692 692
 }
693 693
 
694
-function wpinv_get_post_data( $method = 'request' ) {
694
+function wpinv_get_post_data($method = 'request') {
695 695
     $data       = array();
696 696
     $request    = $_REQUEST;
697 697
     
698
-    if ( $method == 'post' ) {
699
-        if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) {
698
+    if ($method == 'post') {
699
+        if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') {
700 700
             return $data;
701 701
         }
702 702
         
703 703
         $request = $_POST;
704 704
     }
705 705
     
706
-    if ( $method == 'get' ) {
707
-        if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'GET' ) {
706
+    if ($method == 'get') {
707
+        if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'GET') {
708 708
             return $data;
709 709
         }
710 710
         
@@ -715,11 +715,11 @@  discard block
 block discarded – undo
715 715
     $post_data = '';
716 716
     
717 717
     // Fallback just in case post_max_size is lower than needed
718
-    if ( ini_get( 'allow_url_fopen' ) ) {
719
-        $post_data = file_get_contents( 'php://input' );
718
+    if (ini_get('allow_url_fopen')) {
719
+        $post_data = file_get_contents('php://input');
720 720
     } else {
721 721
         // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough
722
-        ini_set( 'post_max_size', '12M' );
722
+        ini_set('post_max_size', '12M');
723 723
     }
724 724
     // Start the encoded data collection with notification command
725 725
     $encoded_data = 'cmd=_notify-validate';
@@ -728,58 +728,58 @@  discard block
 block discarded – undo
728 728
     $arg_separator = wpinv_get_php_arg_separator_output();
729 729
 
730 730
     // Verify there is a post_data
731
-    if ( $post_data || strlen( $post_data ) > 0 ) {
731
+    if ($post_data || strlen($post_data) > 0) {
732 732
         // Append the data
733 733
         $encoded_data .= $arg_separator . $post_data;
734 734
     } else {
735 735
         // Check if POST is empty
736
-        if ( empty( $request ) ) {
736
+        if (empty($request)) {
737 737
             // Nothing to do
738 738
             return;
739 739
         } else {
740 740
             // Loop through each POST
741
-            foreach ( $request as $key => $value ) {
741
+            foreach ($request as $key => $value) {
742 742
                 // Encode the value and append the data
743
-                $encoded_data .= $arg_separator . "$key=" . urlencode( $value );
743
+                $encoded_data .= $arg_separator . "$key=" . urlencode($value);
744 744
             }
745 745
         }
746 746
     }
747 747
 
748 748
     // Convert collected post data to an array
749
-    parse_str( $encoded_data, $data );
749
+    parse_str($encoded_data, $data);
750 750
 
751
-    foreach ( $data as $key => $value ) {
752
-        if ( false !== strpos( $key, 'amp;' ) ) {
753
-            $new_key = str_replace( '&amp;', '&', $key );
754
-            $new_key = str_replace( 'amp;', '&' , $new_key );
751
+    foreach ($data as $key => $value) {
752
+        if (false !== strpos($key, 'amp;')) {
753
+            $new_key = str_replace('&amp;', '&', $key);
754
+            $new_key = str_replace('amp;', '&', $new_key);
755 755
 
756
-            unset( $data[ $key ] );
757
-            $data[ $new_key ] = sanitize_text_field( $value );
756
+            unset($data[$key]);
757
+            $data[$new_key] = sanitize_text_field($value);
758 758
         }
759 759
     }
760 760
     
761 761
     return $data;
762 762
 }
763 763
 
764
-function wpinv_gateway_support_subscription( $gateway ) {
764
+function wpinv_gateway_support_subscription($gateway) {
765 765
     $return = false;
766 766
     
767
-    if ( wpinv_is_gateway_active( $gateway ) ) {
768
-        $return = apply_filters( 'wpinv_' . $gateway . '_support_subscription', false );
767
+    if (wpinv_is_gateway_active($gateway)) {
768
+        $return = apply_filters('wpinv_' . $gateway . '_support_subscription', false);
769 769
     }
770 770
     
771 771
     return $return;
772 772
 }
773 773
 
774
-function wpinv_payment_gateways_on_cart( $gateways = array() ) {
775
-    if ( !empty( $gateways ) && wpinv_cart_has_recurring_item() ) {
776
-        foreach ( $gateways as $gateway => $info ) {
777
-            if ( !wpinv_gateway_support_subscription( $gateway ) ) {
778
-                unset( $gateways[$gateway] );
774
+function wpinv_payment_gateways_on_cart($gateways = array()) {
775
+    if (!empty($gateways) && wpinv_cart_has_recurring_item()) {
776
+        foreach ($gateways as $gateway => $info) {
777
+            if (!wpinv_gateway_support_subscription($gateway)) {
778
+                unset($gateways[$gateway]);
779 779
             }
780 780
         }
781 781
     }
782 782
     
783 783
     return $gateways;
784 784
 }
785
-add_filter( 'wpinv_payment_gateways_on_cart', 'wpinv_payment_gateways_on_cart', 10, 1 );
786 785
\ No newline at end of file
786
+add_filter('wpinv_payment_gateways_on_cart', 'wpinv_payment_gateways_on_cart', 10, 1);
787 787
\ No newline at end of file
Please login to merge, or discard this patch.
includes/libraries/wpinv-euvat/class-wpinv-euvat.php 1 patch
Spacing   +711 added lines, -711 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly.
3
-if (!defined( 'ABSPATH' ) ) exit;
3
+if (!defined('ABSPATH')) exit;
4 4
 
5 5
 class WPInv_EUVat {
6 6
     private static $is_ajax = false;
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
     private static $instance = false;
9 9
     
10 10
     public static function get_instance() {
11
-        if ( !self::$instance ) {
11
+        if (!self::$instance) {
12 12
             self::$instance = new self();
13 13
             self::$instance->actions();
14 14
         }
@@ -17,137 +17,137 @@  discard block
 block discarded – undo
17 17
     }
18 18
     
19 19
     public function __construct() {
20
-        self::$is_ajax          = defined( 'DOING_AJAX' ) && DOING_AJAX;
20
+        self::$is_ajax          = defined('DOING_AJAX') && DOING_AJAX;
21 21
         self::$default_country  = wpinv_get_default_country();
22 22
     }
23 23
     
24 24
     public static function actions() {
25
-        if ( is_admin() ) {
26
-            add_action( 'admin_enqueue_scripts', array( self::$instance, 'enqueue_admin_scripts' ) );
27
-            add_action( 'wpinv_settings_sections_taxes', array( self::$instance, 'section_vat_settings' ) ); 
28
-            add_action( 'wpinv_settings_taxes', array( self::$instance, 'vat_settings' ) );
29
-            add_filter( 'wpinv_settings_taxes-vat_sanitize', array( self::$instance, 'sanitize_vat_settings' ) );
30
-            add_filter( 'wpinv_settings_taxes-vat_rates_sanitize', array( self::$instance, 'sanitize_vat_rates' ) );
31
-            add_action( 'wp_ajax_wpinv_add_vat_class', array( self::$instance, 'add_class' ) );
32
-            add_action( 'wp_ajax_nopriv_wpinv_add_vat_class', array( self::$instance, 'add_class' ) );
33
-            add_action( 'wp_ajax_wpinv_delete_vat_class', array( self::$instance, 'delete_class' ) );
34
-            add_action( 'wp_ajax_nopriv_wpinv_delete_vat_class', array( self::$instance, 'delete_class' ) );
35
-            add_action( 'wp_ajax_wpinv_update_vat_rates', array( self::$instance, 'update_eu_rates' ) );
36
-            add_action( 'wp_ajax_nopriv_wpinv_update_vat_rates', array( self::$instance, 'update_eu_rates' ) );
37
-            add_action( 'wp_ajax_wpinv_geoip2', array( self::$instance, 'geoip2_download_database' ) );
38
-            add_action( 'wp_ajax_nopriv_wpinv_geoip2', array( self::$instance, 'geoip2_download_database' ) );
39
-        }
40
-        
41
-        add_action( 'wp_enqueue_scripts', array( self::$instance, 'enqueue_vat_scripts' ) );
42
-        add_filter( 'wpinv_default_billing_country', array( self::$instance, 'get_user_country' ), 10 );
43
-        add_filter( 'wpinv_get_user_country', array( self::$instance, 'set_user_country' ), 10 );
44
-        add_action( 'wp_ajax_wpinv_vat_validate', array( self::$instance, 'ajax_vat_validate' ) );
45
-        add_action( 'wp_ajax_nopriv_wpinv_vat_validate', array( self::$instance, 'ajax_vat_validate' ) );
46
-        add_action( 'wp_ajax_wpinv_vat_reset', array( self::$instance, 'ajax_vat_reset' ) );
47
-        add_action( 'wp_ajax_nopriv_wpinv_vat_reset', array( self::$instance, 'ajax_vat_reset' ) );
48
-        add_action( 'wpinv_invoice_print_after_line_items', array( self::$instance, 'show_vat_notice' ), 999, 1 );
49
-        if ( wpinv_use_taxes() ) {
50
-            add_action( 'wpinv_after_billing_fields', array( self::$instance, 'checkout_vat_fields' ) );
51
-            if ( self::allow_vat_rules() ) {
52
-                add_action( 'wpinv_checkout_error_checks', array( self::$instance, 'checkout_vat_validate' ), 10, 2 );
53
-                add_filter( 'wpinv_tax_rate', array( self::$instance, 'get_rate' ), 10, 4 );
25
+        if (is_admin()) {
26
+            add_action('admin_enqueue_scripts', array(self::$instance, 'enqueue_admin_scripts'));
27
+            add_action('wpinv_settings_sections_taxes', array(self::$instance, 'section_vat_settings')); 
28
+            add_action('wpinv_settings_taxes', array(self::$instance, 'vat_settings'));
29
+            add_filter('wpinv_settings_taxes-vat_sanitize', array(self::$instance, 'sanitize_vat_settings'));
30
+            add_filter('wpinv_settings_taxes-vat_rates_sanitize', array(self::$instance, 'sanitize_vat_rates'));
31
+            add_action('wp_ajax_wpinv_add_vat_class', array(self::$instance, 'add_class'));
32
+            add_action('wp_ajax_nopriv_wpinv_add_vat_class', array(self::$instance, 'add_class'));
33
+            add_action('wp_ajax_wpinv_delete_vat_class', array(self::$instance, 'delete_class'));
34
+            add_action('wp_ajax_nopriv_wpinv_delete_vat_class', array(self::$instance, 'delete_class'));
35
+            add_action('wp_ajax_wpinv_update_vat_rates', array(self::$instance, 'update_eu_rates'));
36
+            add_action('wp_ajax_nopriv_wpinv_update_vat_rates', array(self::$instance, 'update_eu_rates'));
37
+            add_action('wp_ajax_wpinv_geoip2', array(self::$instance, 'geoip2_download_database'));
38
+            add_action('wp_ajax_nopriv_wpinv_geoip2', array(self::$instance, 'geoip2_download_database'));
39
+        }
40
+        
41
+        add_action('wp_enqueue_scripts', array(self::$instance, 'enqueue_vat_scripts'));
42
+        add_filter('wpinv_default_billing_country', array(self::$instance, 'get_user_country'), 10);
43
+        add_filter('wpinv_get_user_country', array(self::$instance, 'set_user_country'), 10);
44
+        add_action('wp_ajax_wpinv_vat_validate', array(self::$instance, 'ajax_vat_validate'));
45
+        add_action('wp_ajax_nopriv_wpinv_vat_validate', array(self::$instance, 'ajax_vat_validate'));
46
+        add_action('wp_ajax_wpinv_vat_reset', array(self::$instance, 'ajax_vat_reset'));
47
+        add_action('wp_ajax_nopriv_wpinv_vat_reset', array(self::$instance, 'ajax_vat_reset'));
48
+        add_action('wpinv_invoice_print_after_line_items', array(self::$instance, 'show_vat_notice'), 999, 1);
49
+        if (wpinv_use_taxes()) {
50
+            add_action('wpinv_after_billing_fields', array(self::$instance, 'checkout_vat_fields'));
51
+            if (self::allow_vat_rules()) {
52
+                add_action('wpinv_checkout_error_checks', array(self::$instance, 'checkout_vat_validate'), 10, 2);
53
+                add_filter('wpinv_tax_rate', array(self::$instance, 'get_rate'), 10, 4);
54 54
             }
55 55
         }
56 56
     }        
57 57
     
58
-    public static function get_eu_states( $sort = true ) {
59
-        $eu_states = array( 'AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GB', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE' );
60
-        if ( $sort ) {
61
-            $sort = sort( $eu_states );
58
+    public static function get_eu_states($sort = true) {
59
+        $eu_states = array('AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GB', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE');
60
+        if ($sort) {
61
+            $sort = sort($eu_states);
62 62
         }
63 63
         
64
-        return apply_filters( 'wpinv_get_eu_states', $eu_states, $sort );
64
+        return apply_filters('wpinv_get_eu_states', $eu_states, $sort);
65 65
     }
66 66
     
67
-    public static function get_gst_countries( $sort = true ) {
68
-        $gst_countries  = array( 'AU', 'NZ', 'CA', 'CN' );
67
+    public static function get_gst_countries($sort = true) {
68
+        $gst_countries = array('AU', 'NZ', 'CA', 'CN');
69 69
         
70
-        if ( $sort ) {
71
-            $sort = sort( $gst_countries );
70
+        if ($sort) {
71
+            $sort = sort($gst_countries);
72 72
         }
73 73
         
74
-        return apply_filters( 'wpinv_get_gst_countries', $gst_countries, $sort );
74
+        return apply_filters('wpinv_get_gst_countries', $gst_countries, $sort);
75 75
     }
76 76
     
77
-    public static function is_eu_state( $country_code ) {
78
-        $return = !empty( $country_code ) && in_array( strtoupper( $country_code ), self::get_eu_states() ) ? true : false;
77
+    public static function is_eu_state($country_code) {
78
+        $return = !empty($country_code) && in_array(strtoupper($country_code), self::get_eu_states()) ? true : false;
79 79
                 
80
-        return apply_filters( 'wpinv_is_eu_state', $return, $country_code );
80
+        return apply_filters('wpinv_is_eu_state', $return, $country_code);
81 81
     }
82 82
     
83
-    public static function is_gst_country( $country_code ) {
84
-        $return = !empty( $country_code ) && in_array( strtoupper( $country_code ), self::get_gst_countries() ) ? true : false;
83
+    public static function is_gst_country($country_code) {
84
+        $return = !empty($country_code) && in_array(strtoupper($country_code), self::get_gst_countries()) ? true : false;
85 85
                 
86
-        return apply_filters( 'wpinv_is_gst_country', $return, $country_code );
86
+        return apply_filters('wpinv_is_gst_country', $return, $country_code);
87 87
     }
88 88
     
89 89
     public static function enqueue_vat_scripts() {
90
-        if( wpinv_use_taxes() && wpinv_get_option( 'apply_vat_rules' ) ) {
90
+        if (wpinv_use_taxes() && wpinv_get_option('apply_vat_rules')) {
91 91
             self::load_vat_scripts();
92 92
         }
93 93
     }
94 94
 
95
-    public static function load_vat_scripts(){
96
-        $suffix     = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
95
+    public static function load_vat_scripts() {
96
+        $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
97 97
 
98
-        wp_register_script( 'wpinv-vat-validation-script', WPINV_PLUGIN_URL . 'assets/js/jsvat' . $suffix . '.js', array( 'jquery' ),  WPINV_VERSION );
99
-        wp_register_script( 'wpinv-vat-script', WPINV_PLUGIN_URL . 'assets/js/euvat' . $suffix . '.js', array( 'jquery' ),  WPINV_VERSION );
98
+        wp_register_script('wpinv-vat-validation-script', WPINV_PLUGIN_URL . 'assets/js/jsvat' . $suffix . '.js', array('jquery'), WPINV_VERSION);
99
+        wp_register_script('wpinv-vat-script', WPINV_PLUGIN_URL . 'assets/js/euvat' . $suffix . '.js', array('jquery'), WPINV_VERSION);
100 100
 
101
-        $vat_name   = self::get_vat_name();
101
+        $vat_name = self::get_vat_name();
102 102
 
103 103
         $vars = array();
104 104
         $vars['UseTaxes'] = wpinv_use_taxes();
105 105
         $vars['EUStates'] = self::get_eu_states();
106
-        $vars['NoRateSet'] = __( 'You have not set a rate. Do you want to continue?', 'invoicing' );
107
-        $vars['EmptyCompany'] = __( 'Please enter your registered company name!', 'invoicing' );
108
-        $vars['EmptyVAT'] = wp_sprintf( __( 'Please enter your %s number!', 'invoicing' ), $vat_name );
109
-        $vars['TotalsRefreshed'] = wp_sprintf( __( 'The invoice totals will be refreshed to update the %s.', 'invoicing' ), $vat_name );
110
-        $vars['ErrValidateVAT'] = wp_sprintf( __( 'Fail to validate the %s number!', 'invoicing' ), $vat_name );
111
-        $vars['ErrResetVAT'] = wp_sprintf( __( 'Fail to reset the %s number!', 'invoicing' ), $vat_name );
112
-        $vars['ErrInvalidVat'] = wp_sprintf( __( 'The %s number supplied does not have a valid format!', 'invoicing' ), $vat_name );
113
-        $vars['ErrInvalidResponse'] = __( 'An invalid response has been received from the server!', 'invoicing' );
106
+        $vars['NoRateSet'] = __('You have not set a rate. Do you want to continue?', 'invoicing');
107
+        $vars['EmptyCompany'] = __('Please enter your registered company name!', 'invoicing');
108
+        $vars['EmptyVAT'] = wp_sprintf(__('Please enter your %s number!', 'invoicing'), $vat_name);
109
+        $vars['TotalsRefreshed'] = wp_sprintf(__('The invoice totals will be refreshed to update the %s.', 'invoicing'), $vat_name);
110
+        $vars['ErrValidateVAT'] = wp_sprintf(__('Fail to validate the %s number!', 'invoicing'), $vat_name);
111
+        $vars['ErrResetVAT'] = wp_sprintf(__('Fail to reset the %s number!', 'invoicing'), $vat_name);
112
+        $vars['ErrInvalidVat'] = wp_sprintf(__('The %s number supplied does not have a valid format!', 'invoicing'), $vat_name);
113
+        $vars['ErrInvalidResponse'] = __('An invalid response has been received from the server!', 'invoicing');
114 114
         $vars['ApplyVATRules'] = $vars['UseTaxes'] ? self::allow_vat_rules() : false;
115 115
         $vars['HideVatFields'] = $vars['ApplyVATRules'] ? self::hide_vat_fields() : true;
116
-        $vars['ErrResponse'] = __( 'The request response is invalid!', 'invoicing' );
117
-        $vars['ErrRateResponse'] = __( 'The get rate request response is invalid', 'invoicing' );
118
-        $vars['PageRefresh'] = __( 'The page will be refreshed in 10 seconds to show the new options.', 'invoicing' );
119
-        $vars['RequestResponseNotValidJSON'] = __( 'The get rate request response is not valid JSON', 'invoicing' );
120
-        $vars['GetRateRequestFailed'] = __( 'The get rate request failed: ', 'invoicing' );
121
-        $vars['NoRateInformationInResponse'] = __( 'The get rate request response does not contain any rate information', 'invoicing' );
122
-        $vars['RatesUpdated'] = __( 'The rates have been updated. Press the save button to record these new rates.', 'invoicing' );
123
-        $vars['IPAddressInformation'] = __( 'IP Address Information', 'invoicing' );
124
-        $vars['VatValidating'] = wp_sprintf( __( 'Validating %s number...', 'invoicing' ), $vat_name );
125
-        $vars['VatReseting'] = __( 'Reseting...', 'invoicing' );
126
-        $vars['VatValidated'] = wp_sprintf( __( '%s number validated', 'invoicing' ), $vat_name );
127
-        $vars['VatNotValidated'] = wp_sprintf( __( '%s number not validated', 'invoicing' ), $vat_name );
128
-        $vars['ConfirmDeleteClass'] = __( 'Are you sure you wish to delete this rates class?', 'invoicing' );
116
+        $vars['ErrResponse'] = __('The request response is invalid!', 'invoicing');
117
+        $vars['ErrRateResponse'] = __('The get rate request response is invalid', 'invoicing');
118
+        $vars['PageRefresh'] = __('The page will be refreshed in 10 seconds to show the new options.', 'invoicing');
119
+        $vars['RequestResponseNotValidJSON'] = __('The get rate request response is not valid JSON', 'invoicing');
120
+        $vars['GetRateRequestFailed'] = __('The get rate request failed: ', 'invoicing');
121
+        $vars['NoRateInformationInResponse'] = __('The get rate request response does not contain any rate information', 'invoicing');
122
+        $vars['RatesUpdated'] = __('The rates have been updated. Press the save button to record these new rates.', 'invoicing');
123
+        $vars['IPAddressInformation'] = __('IP Address Information', 'invoicing');
124
+        $vars['VatValidating'] = wp_sprintf(__('Validating %s number...', 'invoicing'), $vat_name);
125
+        $vars['VatReseting'] = __('Reseting...', 'invoicing');
126
+        $vars['VatValidated'] = wp_sprintf(__('%s number validated', 'invoicing'), $vat_name);
127
+        $vars['VatNotValidated'] = wp_sprintf(__('%s number not validated', 'invoicing'), $vat_name);
128
+        $vars['ConfirmDeleteClass'] = __('Are you sure you wish to delete this rates class?', 'invoicing');
129 129
         $vars['isFront'] = is_admin() ? false : true;
130 130
         $vars['baseCountry'] = wpinv_get_default_country();
131
-        $vars['disableVATSameCountry'] = ( self::same_country_rule() == 'no' ? true : false );
132
-        $vars['disableVATSimpleCheck'] = wpinv_get_option( 'vat_offline_check' ) ? true : false;
131
+        $vars['disableVATSameCountry'] = (self::same_country_rule() == 'no' ? true : false);
132
+        $vars['disableVATSimpleCheck'] = wpinv_get_option('vat_offline_check') ? true : false;
133 133
 
134
-        wp_enqueue_script( 'wpinv-vat-validation-script' );
135
-        wp_enqueue_script( 'wpinv-vat-script' );
136
-        wp_localize_script( 'wpinv-vat-script', 'WPInv_VAT_Vars', $vars );
134
+        wp_enqueue_script('wpinv-vat-validation-script');
135
+        wp_enqueue_script('wpinv-vat-script');
136
+        wp_localize_script('wpinv-vat-script', 'WPInv_VAT_Vars', $vars);
137 137
     }
138 138
 
139 139
     public static function enqueue_admin_scripts() {
140
-        if( isset( $_GET['page'] ) && 'wpinv-settings' == $_GET['page'] ) {
140
+        if (isset($_GET['page']) && 'wpinv-settings' == $_GET['page']) {
141 141
             self::load_vat_scripts();
142 142
         }
143 143
     }
144 144
     
145
-    public static function section_vat_settings( $sections ) {
146
-        if ( !empty( $sections ) ) {
147
-            $sections['vat'] = __( 'EU VAT Settings', 'invoicing' );
145
+    public static function section_vat_settings($sections) {
146
+        if (!empty($sections)) {
147
+            $sections['vat'] = __('EU VAT Settings', 'invoicing');
148 148
             
149
-            if ( self::allow_vat_classes() ) {
150
-                $sections['vat_rates'] = __( 'EU VAT Rates', 'invoicing' );
149
+            if (self::allow_vat_classes()) {
150
+                $sections['vat_rates'] = __('EU VAT Rates', 'invoicing');
151 151
             }
152 152
         }
153 153
         return $sections;
@@ -156,52 +156,52 @@  discard block
 block discarded – undo
156 156
     public static function vat_rates_settings() {
157 157
         $vat_classes = self::get_rate_classes();
158 158
         $vat_rates = array();
159
-        $vat_class = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' && isset( $vat_classes[$_REQUEST['wpi_sub']] )? sanitize_text_field( $_REQUEST['wpi_sub'] ) : '_new';
160
-        $current_url = remove_query_arg( 'wpi_sub' );
159
+        $vat_class = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' && isset($vat_classes[$_REQUEST['wpi_sub']]) ? sanitize_text_field($_REQUEST['wpi_sub']) : '_new';
160
+        $current_url = remove_query_arg('wpi_sub');
161 161
         
162 162
         $vat_rates['vat_rates_header'] = array(
163 163
             'id' => 'vat_rates_header',
164
-            'name' => '<h3>' . __( 'Manage VAT Rates', 'invoicing' ) . '</h3>',
164
+            'name' => '<h3>' . __('Manage VAT Rates', 'invoicing') . '</h3>',
165 165
             'desc' => '',
166 166
             'type' => 'header',
167 167
             'size' => 'regular'
168 168
         );
169 169
         $vat_rates['vat_rates_class'] = array(
170 170
             'id'          => 'vat_rates_class',
171
-            'name'        => __( 'Edit VAT Rates', 'invoicing' ),
172
-            'desc'        => __( 'The standard rate will apply where no explicit rate is provided.', 'invoicing' ),
171
+            'name'        => __('Edit VAT Rates', 'invoicing'),
172
+            'desc'        => __('The standard rate will apply where no explicit rate is provided.', 'invoicing'),
173 173
             'type'        => 'select',
174
-            'options'     => array_merge( $vat_classes, array( '_new' => __( 'Add New Rate Class', 'invoicing' ) ) ),
175
-            'placeholder' => __( 'Select a VAT Rate', 'invoicing' ),
174
+            'options'     => array_merge($vat_classes, array('_new' => __('Add New Rate Class', 'invoicing'))),
175
+            'placeholder' => __('Select a VAT Rate', 'invoicing'),
176 176
             'selected'    => $vat_class,
177 177
             'class'       => 'wpi_select2',
178 178
             'onchange'    => 'document.location.href="' . $current_url . '&wpi_sub=" + this.value;',
179 179
         );
180 180
         
181
-        if ( $vat_class != '_standard' && $vat_class != '_new' ) {
181
+        if ($vat_class != '_standard' && $vat_class != '_new') {
182 182
             $vat_rates['vat_rate_delete'] = array(
183 183
                 'id'   => 'vat_rate_delete',
184 184
                 'type' => 'vat_rate_delete',
185 185
             );
186 186
         }
187 187
                     
188
-        if ( $vat_class == '_new' ) {
188
+        if ($vat_class == '_new') {
189 189
             $vat_rates['vat_rates_settings'] = array(
190 190
                 'id' => 'vat_rates_settings',
191
-                'name' => '<h3>' . __( 'Add New Rate Class', 'invoicing' ) . '</h3>',
191
+                'name' => '<h3>' . __('Add New Rate Class', 'invoicing') . '</h3>',
192 192
                 'type' => 'header',
193 193
             );
194 194
             $vat_rates['vat_rate_name'] = array(
195 195
                 'id'   => 'vat_rate_name',
196
-                'name' => __( 'Name', 'invoicing' ),
197
-                'desc' => __( 'A short name for the new VAT Rate class', 'invoicing' ),
196
+                'name' => __('Name', 'invoicing'),
197
+                'desc' => __('A short name for the new VAT Rate class', 'invoicing'),
198 198
                 'type' => 'text',
199 199
                 'size' => 'regular',
200 200
             );
201 201
             $vat_rates['vat_rate_desc'] = array(
202 202
                 'id'   => 'vat_rate_desc',
203
-                'name' => __( 'Description', 'invoicing' ),
204
-                'desc' => __( 'Manage VAT Rate class', 'invoicing' ),
203
+                'name' => __('Description', 'invoicing'),
204
+                'desc' => __('Manage VAT Rate class', 'invoicing'),
205 205
                 'type' => 'text',
206 206
                 'size' => 'regular',
207 207
             );
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
             $vat_rates['vat_rates'] = array(
214 214
                 'id'   => 'vat_rates',
215 215
                 'name' => '<h3>' . $vat_classes[$vat_class] . '</h3>',
216
-                'desc' => self::get_class_desc( $vat_class ),
216
+                'desc' => self::get_class_desc($vat_class),
217 217
                 'type' => 'vat_rates',
218 218
             );
219 219
         }
@@ -221,12 +221,12 @@  discard block
 block discarded – undo
221 221
         return $vat_rates;
222 222
     }
223 223
     
224
-    public static function vat_settings( $settings ) {
225
-        if ( !empty( $settings ) ) {    
224
+    public static function vat_settings($settings) {
225
+        if (!empty($settings)) {    
226 226
             $vat_settings = array();
227 227
             $vat_settings['vat_company_title'] = array(
228 228
                 'id' => 'vat_company_title',
229
-                'name' => '<h3>' . __( 'Your Company Details', 'invoicing' ) . '</h3>',
229
+                'name' => '<h3>' . __('Your Company Details', 'invoicing') . '</h3>',
230 230
                 'desc' => '',
231 231
                 'type' => 'header',
232 232
                 'size' => 'regular'
@@ -234,22 +234,22 @@  discard block
 block discarded – undo
234 234
             
235 235
             $vat_settings['vat_company_name'] = array(
236 236
                 'id' => 'vat_company_name',
237
-                'name' => __( 'Your Company Name', 'invoicing' ),
238
-                'desc' => wp_sprintf(__( 'Your company name as it appears on your VAT return, you can verify it via your VAT ID on the %sEU VIES System.%s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ),
237
+                'name' => __('Your Company Name', 'invoicing'),
238
+                'desc' => wp_sprintf(__('Your company name as it appears on your VAT return, you can verify it via your VAT ID on the %sEU VIES System.%s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'),
239 239
                 'type' => 'text',
240 240
                 'size' => 'regular',
241 241
             );
242 242
             
243 243
             $vat_settings['vat_number'] = array(
244 244
                 'id'   => 'vat_number',
245
-                'name' => __( 'Your VAT Number', 'invoicing' ),
245
+                'name' => __('Your VAT Number', 'invoicing'),
246 246
                 'type' => 'vat_number',
247 247
                 'size' => 'regular',
248 248
             );
249 249
 
250 250
             $vat_settings['vat_settings_title'] = array(
251 251
                 'id' => 'vat_settings_title',
252
-                'name' => '<h3>' . __( 'Apply VAT Settings', 'invoicing' ) . '</h3>',
252
+                'name' => '<h3>' . __('Apply VAT Settings', 'invoicing') . '</h3>',
253 253
                 'desc' => '',
254 254
                 'type' => 'header',
255 255
                 'size' => 'regular'
@@ -257,8 +257,8 @@  discard block
 block discarded – undo
257 257
 
258 258
             $vat_settings['apply_vat_rules'] = array(
259 259
                 'id' => 'apply_vat_rules',
260
-                'name' => __( 'Enable VAT Rules', 'invoicing' ),
261
-                'desc' => __( 'Apply VAT to consumer sales from IP addresses within the EU, even if the billing address is outside the EU.', 'invoicing' ) . '<br><font style="color:red">' . __( 'Do not disable unless you know what you are doing.', 'invoicing' ) . '</font>',
260
+                'name' => __('Enable VAT Rules', 'invoicing'),
261
+                'desc' => __('Apply VAT to consumer sales from IP addresses within the EU, even if the billing address is outside the EU.', 'invoicing') . '<br><font style="color:red">' . __('Do not disable unless you know what you are doing.', 'invoicing') . '</font>',
262 262
                 'type' => 'checkbox',
263 263
                 'std' => '1'
264 264
             );
@@ -274,8 +274,8 @@  discard block
 block discarded – undo
274 274
 
275 275
             $vat_settings['vat_prevent_b2c_purchase'] = array(
276 276
                 'id' => 'vat_prevent_b2c_purchase',
277
-                'name' => __( 'Prevent EU B2C Sales', 'invoicing' ),
278
-                'desc' => __( 'Enable this option if you are not registered for VAT in the EU.', 'invoicing' ),
277
+                'name' => __('Prevent EU B2C Sales', 'invoicing'),
278
+                'desc' => __('Enable this option if you are not registered for VAT in the EU.', 'invoicing'),
279 279
                 'type' => 'checkbox'
280 280
             );
281 281
 
@@ -283,22 +283,22 @@  discard block
 block discarded – undo
283 283
 
284 284
             $vat_settings['vat_same_country_rule'] = array(
285 285
                 'id'          => 'vat_same_country_rule',
286
-                'name'        => __( 'Same Country Rule', 'invoicing' ),
287
-                'desc'        => __( 'Select how you want to handle VAT charge if sales are in the same country as the base country.', 'invoicing' ),
286
+                'name'        => __('Same Country Rule', 'invoicing'),
287
+                'desc'        => __('Select how you want to handle VAT charge if sales are in the same country as the base country.', 'invoicing'),
288 288
                 'type'        => 'select',
289 289
                 'options'     => array(
290
-                    ''          => __( 'Normal', 'invoicing' ),
291
-                    'no'        => __( 'No VAT', 'invoicing' ),
292
-                    'always'    => __( 'Always apply VAT', 'invoicing' ),
290
+                    ''          => __('Normal', 'invoicing'),
291
+                    'no'        => __('No VAT', 'invoicing'),
292
+                    'always'    => __('Always apply VAT', 'invoicing'),
293 293
                 ),
294
-                'placeholder' => __( 'Select an option', 'invoicing' ),
294
+                'placeholder' => __('Select an option', 'invoicing'),
295 295
                 'std'         => '',
296 296
                 'class'   => 'wpi_select2',
297 297
             );
298 298
 
299 299
             $vat_settings['vat_checkout_title'] = array(
300 300
                 'id' => 'vat_checkout_title',
301
-                'name' => '<h3>' . __( 'Checkout Fields', 'invoicing' ) . '</h3>',
301
+                'name' => '<h3>' . __('Checkout Fields', 'invoicing') . '</h3>',
302 302
                 'desc' => '',
303 303
                 'type' => 'header',
304 304
                 'size' => 'regular'
@@ -306,14 +306,14 @@  discard block
 block discarded – undo
306 306
 
307 307
             $vat_settings['vat_disable_fields'] = array(
308 308
                 'id' => 'vat_disable_fields',
309
-                'name' => __( 'Disable VAT Fields', 'invoicing' ),
310
-                'desc' => __( 'Disable VAT fields if Invoicing is being used for GST.', 'invoicing' ) . '<br><font style="color:red">' . __( 'Do not disable if you have enabled Prevent EU B2C sales, otherwise Prevent EU B2C sales setting will not work.', 'invoicing' ) . '</font>',
309
+                'name' => __('Disable VAT Fields', 'invoicing'),
310
+                'desc' => __('Disable VAT fields if Invoicing is being used for GST.', 'invoicing') . '<br><font style="color:red">' . __('Do not disable if you have enabled Prevent EU B2C sales, otherwise Prevent EU B2C sales setting will not work.', 'invoicing') . '</font>',
311 311
                 'type' => 'checkbox'
312 312
             );
313 313
 
314 314
             $vat_settings['vat_ip_lookup'] = array(
315 315
                 'id'   => 'vat_ip_lookup',
316
-                'name' => __( 'IP Country Look-up', 'invoicing' ),
316
+                'name' => __('IP Country Look-up', 'invoicing'),
317 317
                 'type' => 'vat_ip_lookup',
318 318
                 'size' => 'regular',
319 319
                 'std' => 'default',
@@ -322,21 +322,21 @@  discard block
 block discarded – undo
322 322
 
323 323
             $vat_settings['hide_ip_address'] = array(
324 324
                 'id' => 'hide_ip_address',
325
-                'name' => __( 'Hide IP Info at Checkout', 'invoicing' ),
326
-                'desc' => __( 'Hide the user IP info at checkout.', 'invoicing' ),
325
+                'name' => __('Hide IP Info at Checkout', 'invoicing'),
326
+                'desc' => __('Hide the user IP info at checkout.', 'invoicing'),
327 327
                 'type' => 'checkbox'
328 328
             );
329 329
 
330 330
             $vat_settings['vat_ip_country_default'] = array(
331 331
                 'id' => 'vat_ip_country_default',
332
-                'name' => __( 'Enable IP Country as Default', 'invoicing' ),
333
-                'desc' => __( 'Show the country of the users IP as the default country, otherwise the site default country will be used.', 'invoicing' ),
332
+                'name' => __('Enable IP Country as Default', 'invoicing'),
333
+                'desc' => __('Show the country of the users IP as the default country, otherwise the site default country will be used.', 'invoicing'),
334 334
                 'type' => 'checkbox'
335 335
             );
336 336
 
337 337
             $vat_settings['vies_validation_title'] = array(
338 338
                 'id' => 'vies_validation_title',
339
-                'name' => '<h3>' . __( 'VIES Validation', 'invoicing' ) . '</h3>',
339
+                'name' => '<h3>' . __('VIES Validation', 'invoicing') . '</h3>',
340 340
                 'desc' => '',
341 341
                 'type' => 'header',
342 342
                 'size' => 'regular'
@@ -344,37 +344,37 @@  discard block
 block discarded – undo
344 344
 
345 345
             $vat_settings['vat_vies_check'] = array(
346 346
                 'id' => 'vat_vies_check',
347
-                'name' => __( 'Disable VIES VAT ID Check', 'invoicing' ),
348
-                'desc' => wp_sprintf( __( 'Prevent VAT numbers from being validated by the %sEU VIES System.%s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ),
347
+                'name' => __('Disable VIES VAT ID Check', 'invoicing'),
348
+                'desc' => wp_sprintf(__('Prevent VAT numbers from being validated by the %sEU VIES System.%s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'),
349 349
                 'type' => 'checkbox'
350 350
             );
351 351
 
352 352
             $vat_settings['vat_disable_company_name_check'] = array(
353 353
                 'id' => 'vat_disable_company_name_check',
354
-                'name' => __( 'Disable VIES Name Check', 'invoicing' ),
355
-                'desc' => wp_sprintf( __( 'Prevent company name from being validated by the %sEU VIES System.%s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ),
354
+                'name' => __('Disable VIES Name Check', 'invoicing'),
355
+                'desc' => wp_sprintf(__('Prevent company name from being validated by the %sEU VIES System.%s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'),
356 356
                 'type' => 'checkbox'
357 357
             );
358 358
 
359 359
             $vat_settings['vat_offline_check'] = array(
360 360
                 'id' => 'vat_offline_check',
361
-                'name' => __( 'Disable Basic Checks', 'invoicing' ),
362
-                'desc' => __( 'Disable basic JS checks for correct format of VAT number. (Not Recommended)', 'invoicing' ),
361
+                'name' => __('Disable Basic Checks', 'invoicing'),
362
+                'desc' => __('Disable basic JS checks for correct format of VAT number. (Not Recommended)', 'invoicing'),
363 363
                 'type' => 'checkbox'
364 364
             );
365 365
             
366 366
 
367 367
             $settings['vat'] = $vat_settings;
368 368
             
369
-            if ( self::allow_vat_classes() ) {
369
+            if (self::allow_vat_classes()) {
370 370
                 $settings['vat_rates'] = self::vat_rates_settings();
371 371
             }
372 372
             
373 373
             $eu_fallback_rate = array(
374 374
                 'id'   => 'eu_fallback_rate',
375
-                'name' => '<h3>' . __( 'VAT rate for EU member states', 'invoicing' ) . '</h3>',
375
+                'name' => '<h3>' . __('VAT rate for EU member states', 'invoicing') . '</h3>',
376 376
                 'type' => 'eu_fallback_rate',
377
-                'desc' => __( 'Enter the VAT rate to be charged for EU member states. You can edit the rates for each member state when a country rate has been set up by pressing this button.', 'invoicing' ),
377
+                'desc' => __('Enter the VAT rate to be charged for EU member states. You can edit the rates for each member state when a country rate has been set up by pressing this button.', 'invoicing'),
378 378
                 'std'  => '20',
379 379
                 'size' => 'small'
380 380
             );
@@ -390,11 +390,11 @@  discard block
 block discarded – undo
390 390
         $database_url       = 'http' . (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] === 'on' ? 's' : '') . '://geolite.maxmind.com/download/geoip/database/';
391 391
         $destination_dir    = $upload_dir['basedir'] . '/invoicing';
392 392
         
393
-        if ( !is_dir( $destination_dir ) ) { 
394
-            mkdir( $destination_dir );
393
+        if (!is_dir($destination_dir)) { 
394
+            mkdir($destination_dir);
395 395
         }
396 396
         
397
-        $database_files     = array(
397
+        $database_files = array(
398 398
             'country'   => array(
399 399
                 'source'        => $database_url . 'GeoLite2-Country.mmdb.gz',
400 400
                 'destination'   => $destination_dir . '/GeoLite2-Country.mmdb',
@@ -405,57 +405,57 @@  discard block
 block discarded – undo
405 405
             )
406 406
         );
407 407
 
408
-        foreach( $database_files as $database => $files ) {
409
-            $result = self::geoip2_download_file( $files['source'], $files['destination'] );
408
+        foreach ($database_files as $database => $files) {
409
+            $result = self::geoip2_download_file($files['source'], $files['destination']);
410 410
             
411
-            if ( empty( $result['success'] ) ) {
411
+            if (empty($result['success'])) {
412 412
                 echo $result['message'];
413 413
                 exit;
414 414
             }
415 415
             
416
-            wpinv_update_option( 'wpinv_geoip2_date_updated', current_time( 'timestamp' ) );
417
-            echo sprintf(__( 'GeoIP2 %s database updated successfully.', 'invoicing' ), $database ) . ' ';
416
+            wpinv_update_option('wpinv_geoip2_date_updated', current_time('timestamp'));
417
+            echo sprintf(__('GeoIP2 %s database updated successfully.', 'invoicing'), $database) . ' ';
418 418
         }
419 419
         
420 420
         exit;
421 421
     }
422 422
     
423
-    public static function geoip2_download_file( $source_url, $destination_file ) {
423
+    public static function geoip2_download_file($source_url, $destination_file) {
424 424
         $success    = false;
425 425
         $message    = '';
426 426
         
427
-        if ( !function_exists( 'download_url' ) ) {
428
-            require_once( ABSPATH . 'wp-admin/includes/file.php' );
427
+        if (!function_exists('download_url')) {
428
+            require_once(ABSPATH . 'wp-admin/includes/file.php');
429 429
         }
430 430
 
431
-        $temp_file  = download_url( $source_url );
431
+        $temp_file = download_url($source_url);
432 432
         
433
-        if ( is_wp_error( $temp_file ) ) {
434
-            $message = sprintf( __( 'Error while downloading GeoIp2 database( %s ): %s', 'invoicing' ), $source_url, $temp_file->get_error_message() );
433
+        if (is_wp_error($temp_file)) {
434
+            $message = sprintf(__('Error while downloading GeoIp2 database( %s ): %s', 'invoicing'), $source_url, $temp_file->get_error_message());
435 435
         } else {
436
-            $handle = gzopen( $temp_file, 'rb' );
436
+            $handle = gzopen($temp_file, 'rb');
437 437
             
438
-            if ( $handle ) {
439
-                $fopen  = fopen( $destination_file, 'wb' );
440
-                if ( $fopen ) {
441
-                    while ( ( $data = gzread( $handle, 4096 ) ) != false ) {
442
-                        fwrite( $fopen, $data );
438
+            if ($handle) {
439
+                $fopen = fopen($destination_file, 'wb');
440
+                if ($fopen) {
441
+                    while (($data = gzread($handle, 4096)) != false) {
442
+                        fwrite($fopen, $data);
443 443
                     }
444 444
 
445
-                    gzclose( $handle );
446
-                    fclose( $fopen );
445
+                    gzclose($handle);
446
+                    fclose($fopen);
447 447
                         
448 448
                     $success = true;
449 449
                 } else {
450
-                    gzclose( $handle );
451
-                    $message = sprintf( __( 'Error could not open destination GeoIp2 database file for writing: %s', 'invoicing' ), $destination_file );
450
+                    gzclose($handle);
451
+                    $message = sprintf(__('Error could not open destination GeoIp2 database file for writing: %s', 'invoicing'), $destination_file);
452 452
                 }
453 453
             } else {
454
-                $message = sprintf( __( 'Error could not open GeoIp2 database file for reading: %s', 'invoicing' ), $temp_file );
454
+                $message = sprintf(__('Error could not open GeoIp2 database file for reading: %s', 'invoicing'), $temp_file);
455 455
             }
456 456
             
457
-            if ( file_exists( $temp_file ) ) {
458
-                unlink( $temp_file );
457
+            if (file_exists($temp_file)) {
458
+                unlink($temp_file);
459 459
             }
460 460
         }
461 461
         
@@ -467,11 +467,11 @@  discard block
 block discarded – undo
467 467
     }
468 468
     
469 469
     public static function load_geoip2() {
470
-        if ( defined( 'WPINV_GEOIP2_LODDED' ) ) {
470
+        if (defined('WPINV_GEOIP2_LODDED')) {
471 471
             return;
472 472
         }
473 473
         
474
-        if ( !class_exists( '\MaxMind\Db\Reader' ) ) {
474
+        if (!class_exists('\MaxMind\Db\Reader')) {
475 475
             $maxmind_db_files = array(
476 476
                 'Reader/Decoder.php',
477 477
                 'Reader/InvalidDatabaseException.php',
@@ -480,12 +480,12 @@  discard block
 block discarded – undo
480 480
                 'Reader.php',
481 481
             );
482 482
             
483
-            foreach ( $maxmind_db_files as $key => $file ) {
484
-                require_once( WPINV_PLUGIN_DIR . 'includes/libraries/MaxMind/Db/' . $file );
483
+            foreach ($maxmind_db_files as $key => $file) {
484
+                require_once(WPINV_PLUGIN_DIR . 'includes/libraries/MaxMind/Db/' . $file);
485 485
             }
486 486
         }
487 487
         
488
-        if ( !class_exists( '\GeoIp2\Database\Reader' ) ) {        
488
+        if (!class_exists('\GeoIp2\Database\Reader')) {        
489 489
             $geoip2_files = array(
490 490
                 'ProviderInterface.php',
491 491
                 'Compat/JsonSerializable.php',
@@ -519,23 +519,23 @@  discard block
 block discarded – undo
519 519
                 'WebService/Client.php',
520 520
             );
521 521
             
522
-            foreach ( $geoip2_files as $key => $file ) {
523
-                require_once( WPINV_PLUGIN_DIR . 'includes/libraries/GeoIp2/' . $file );
522
+            foreach ($geoip2_files as $key => $file) {
523
+                require_once(WPINV_PLUGIN_DIR . 'includes/libraries/GeoIp2/' . $file);
524 524
             }
525 525
         }
526 526
 
527
-        define( 'WPINV_GEOIP2_LODDED', true );
527
+        define('WPINV_GEOIP2_LODDED', true);
528 528
     }
529 529
 
530 530
     public static function geoip2_country_dbfile() {
531 531
         $upload_dir = wp_upload_dir();
532 532
 
533
-        if ( !isset( $upload_dir['basedir'] ) ) {
533
+        if (!isset($upload_dir['basedir'])) {
534 534
             return false;
535 535
         }
536 536
 
537 537
         $filename = $upload_dir['basedir'] . '/invoicing/GeoLite2-Country.mmdb';
538
-        if ( !file_exists( $filename ) ) {
538
+        if (!file_exists($filename)) {
539 539
             return false;
540 540
         }
541 541
         
@@ -545,12 +545,12 @@  discard block
 block discarded – undo
545 545
     public static function geoip2_city_dbfile() {
546 546
         $upload_dir = wp_upload_dir();
547 547
 
548
-        if ( !isset( $upload_dir['basedir'] ) ) {
548
+        if (!isset($upload_dir['basedir'])) {
549 549
             return false;
550 550
         }
551 551
 
552 552
         $filename = $upload_dir['basedir'] . '/invoicing/GeoLite2-City.mmdb';
553
-        if ( !file_exists( $filename ) ) {
553
+        if (!file_exists($filename)) {
554 554
             return false;
555 555
         }
556 556
         
@@ -561,10 +561,10 @@  discard block
 block discarded – undo
561 561
         try {
562 562
             self::load_geoip2();
563 563
 
564
-            if ( $filename = self::geoip2_country_dbfile() ) {
565
-                return new \GeoIp2\Database\Reader( $filename );
564
+            if ($filename = self::geoip2_country_dbfile()) {
565
+                return new \GeoIp2\Database\Reader($filename);
566 566
             }
567
-        } catch( Exception $e ) {
567
+        } catch (Exception $e) {
568 568
             return false;
569 569
         }
570 570
         
@@ -575,173 +575,173 @@  discard block
 block discarded – undo
575 575
         try {
576 576
             self::load_geoip2();
577 577
 
578
-            if ( $filename = self::geoip2_city_dbfile() ) {
579
-                return new \GeoIp2\Database\Reader( $filename );
578
+            if ($filename = self::geoip2_city_dbfile()) {
579
+                return new \GeoIp2\Database\Reader($filename);
580 580
             }
581
-        } catch( Exception $e ) {
581
+        } catch (Exception $e) {
582 582
             return false;
583 583
         }
584 584
         
585 585
         return false;
586 586
     }
587 587
 
588
-    public static function geoip2_country_record( $ip_address ) {
588
+    public static function geoip2_country_record($ip_address) {
589 589
         try {
590 590
             $reader = self::geoip2_country_reader();
591 591
 
592
-            if ( $reader ) {
593
-                $record = $reader->country( $ip_address );
592
+            if ($reader) {
593
+                $record = $reader->country($ip_address);
594 594
                 
595
-                if ( !empty( $record->country->isoCode ) ) {
595
+                if (!empty($record->country->isoCode)) {
596 596
                     return $record;
597 597
                 }
598 598
             }
599
-        } catch(\InvalidArgumentException $e) {
600
-            wpinv_error_log( $e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )' );
599
+        } catch (\InvalidArgumentException $e) {
600
+            wpinv_error_log($e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )');
601 601
             
602 602
             return false;
603
-        } catch(\GeoIp2\Exception\AddressNotFoundException $e) {
604
-            wpinv_error_log( $e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )' );
603
+        } catch (\GeoIp2\Exception\AddressNotFoundException $e) {
604
+            wpinv_error_log($e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )');
605 605
             
606 606
             return false;
607
-        } catch( Exception $e ) {
607
+        } catch (Exception $e) {
608 608
             return false;
609 609
         }
610 610
         
611 611
         return false;
612 612
     }
613 613
 
614
-    public static function geoip2_city_record( $ip_address ) {
614
+    public static function geoip2_city_record($ip_address) {
615 615
         try {
616 616
             $reader = self::geoip2_city_reader();
617 617
 
618
-            if ( $reader ) {
619
-                $record = $reader->city( $ip_address );
618
+            if ($reader) {
619
+                $record = $reader->city($ip_address);
620 620
                 
621
-                if ( !empty( $record->country->isoCode ) ) {
621
+                if (!empty($record->country->isoCode)) {
622 622
                     return $record;
623 623
                 }
624 624
             }
625
-        } catch(\InvalidArgumentException $e) {
626
-            wpinv_error_log( $e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )' );
625
+        } catch (\InvalidArgumentException $e) {
626
+            wpinv_error_log($e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )');
627 627
             
628 628
             return false;
629
-        } catch(\GeoIp2\Exception\AddressNotFoundException $e) {
630
-            wpinv_error_log( $e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )' );
629
+        } catch (\GeoIp2\Exception\AddressNotFoundException $e) {
630
+            wpinv_error_log($e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )');
631 631
             
632 632
             return false;
633
-        } catch( Exception $e ) {
633
+        } catch (Exception $e) {
634 634
             return false;
635 635
         }
636 636
         
637 637
         return false;
638 638
     }
639 639
 
640
-    public static function geoip2_country_code( $ip_address ) {
641
-        $record = self::geoip2_country_record( $ip_address );
642
-        return !empty( $record->country->isoCode ) ? $record->country->isoCode : wpinv_get_default_country();
640
+    public static function geoip2_country_code($ip_address) {
641
+        $record = self::geoip2_country_record($ip_address);
642
+        return !empty($record->country->isoCode) ? $record->country->isoCode : wpinv_get_default_country();
643 643
     }
644 644
 
645 645
     // Find country by IP address.
646
-    public static function get_country_by_ip( $ip = '' ) {
646
+    public static function get_country_by_ip($ip = '') {
647 647
         global $wpinv_ip_address_country;
648 648
         
649
-        if ( !empty( $wpinv_ip_address_country ) ) {
649
+        if (!empty($wpinv_ip_address_country)) {
650 650
             return $wpinv_ip_address_country;
651 651
         }
652 652
         
653
-        if ( empty( $ip ) ) {
653
+        if (empty($ip)) {
654 654
             $ip = wpinv_get_ip();
655 655
         }
656 656
 
657
-        $ip_country_service = wpinv_get_option( 'vat_ip_lookup' );
658
-        $is_default         = empty( $ip_country_service ) || $ip_country_service === 'default' ? true : false;
657
+        $ip_country_service = wpinv_get_option('vat_ip_lookup');
658
+        $is_default         = empty($ip_country_service) || $ip_country_service === 'default' ? true : false;
659 659
 
660
-        if ( !empty( $ip ) && $ip !== '127.0.0.1' ) { // For 127.0.0.1(localhost) use default country.
661
-            if ( function_exists( 'geoip_country_code_by_name') && ( $ip_country_service === 'geoip' || $is_default ) ) {
660
+        if (!empty($ip) && $ip !== '127.0.0.1') { // For 127.0.0.1(localhost) use default country.
661
+            if (function_exists('geoip_country_code_by_name') && ($ip_country_service === 'geoip' || $is_default)) {
662 662
                 try {
663
-                    $wpinv_ip_address_country = geoip_country_code_by_name( $ip );
664
-                } catch( Exception $e ) {
665
-                    wpinv_error_log( $e->getMessage(), 'GeoIP Lookup( ' . $ip . ' )' );
663
+                    $wpinv_ip_address_country = geoip_country_code_by_name($ip);
664
+                } catch (Exception $e) {
665
+                    wpinv_error_log($e->getMessage(), 'GeoIP Lookup( ' . $ip . ' )');
666 666
                 }
667
-            } else if ( self::geoip2_country_dbfile() && ( $ip_country_service === 'geoip2' || $is_default ) ) {
668
-                $wpinv_ip_address_country = self::geoip2_country_code( $ip );
669
-            } else if ( function_exists( 'simplexml_load_file' ) && ( $ip_country_service === 'geoplugin' || $is_default ) ) {
670
-                $load_xml = simplexml_load_file( 'http://www.geoplugin.net/xml.gp?ip=' . $ip );
667
+            } else if (self::geoip2_country_dbfile() && ($ip_country_service === 'geoip2' || $is_default)) {
668
+                $wpinv_ip_address_country = self::geoip2_country_code($ip);
669
+            } else if (function_exists('simplexml_load_file') && ($ip_country_service === 'geoplugin' || $is_default)) {
670
+                $load_xml = simplexml_load_file('http://www.geoplugin.net/xml.gp?ip=' . $ip);
671 671
                 
672
-                if ( !empty( $load_xml ) && !empty( $load_xml->geoplugin_countryCode ) ) {
672
+                if (!empty($load_xml) && !empty($load_xml->geoplugin_countryCode)) {
673 673
                     $wpinv_ip_address_country = (string)$load_xml->geoplugin_countryCode;
674 674
                 }
675 675
             }
676 676
         }
677 677
 
678
-        if ( empty( $wpinv_ip_address_country ) ) {
678
+        if (empty($wpinv_ip_address_country)) {
679 679
             $wpinv_ip_address_country = wpinv_get_default_country();
680 680
         }
681 681
 
682 682
         return $wpinv_ip_address_country;
683 683
     }
684 684
     
685
-    public static function sanitize_vat_settings( $input ) {
685
+    public static function sanitize_vat_settings($input) {
686 686
         global $wpinv_options;
687 687
         
688 688
         $valid      = false;
689 689
         $message    = '';
690 690
         
691
-        if ( !empty( $wpinv_options['vat_vies_check'] ) ) {
692
-            if ( empty( $wpinv_options['vat_offline_check'] ) ) {
693
-                $valid = self::offline_check( $input['vat_number'] );
691
+        if (!empty($wpinv_options['vat_vies_check'])) {
692
+            if (empty($wpinv_options['vat_offline_check'])) {
693
+                $valid = self::offline_check($input['vat_number']);
694 694
             } else {
695 695
                 $valid = true;
696 696
             }
697 697
             
698
-            $message = $valid ? '' : __( 'VAT number not validated', 'invoicing' );
698
+            $message = $valid ? '' : __('VAT number not validated', 'invoicing');
699 699
         } else {
700
-            $result = self::check_vat( $input['vat_number'] );
700
+            $result = self::check_vat($input['vat_number']);
701 701
             
702
-            if ( empty( $result['valid'] ) ) {
702
+            if (empty($result['valid'])) {
703 703
                 $valid      = false;
704 704
                 $message    = $result['message'];
705 705
             } else {
706
-                $valid      = ( isset( $result['company'] ) && ( $result['company'] == '---' || ( strcasecmp( trim( $result['company'] ), trim( $input['vat_company_name'] ) ) == 0 ) ) ) || !empty( $wpinv_options['vat_disable_company_name_check'] );
707
-                $message    = $valid ? '' : __( 'The company name associated with the VAT number provided is not the same as the company name provided.', 'invoicing' );
706
+                $valid      = (isset($result['company']) && ($result['company'] == '---' || (strcasecmp(trim($result['company']), trim($input['vat_company_name'])) == 0))) || !empty($wpinv_options['vat_disable_company_name_check']);
707
+                $message    = $valid ? '' : __('The company name associated with the VAT number provided is not the same as the company name provided.', 'invoicing');
708 708
             }
709 709
         }
710 710
 
711
-        if ( $message && self::is_vat_validated() != $valid ) {
712
-            add_settings_error( 'wpinv-notices', '', $message, ( $valid ? 'updated' : 'error' ) );
711
+        if ($message && self::is_vat_validated() != $valid) {
712
+            add_settings_error('wpinv-notices', '', $message, ($valid ? 'updated' : 'error'));
713 713
         }
714 714
 
715 715
         $input['vat_valid'] = $valid;
716 716
         return $input;
717 717
     }
718 718
     
719
-    public static function sanitize_vat_rates( $input ) {
720
-        if( !current_user_can( 'manage_options' ) ) {
721
-            add_settings_error( 'wpinv-notices', '', __( 'Your account does not have permission to add rate classes.', 'invoicing' ), 'error' );
719
+    public static function sanitize_vat_rates($input) {
720
+        if (!current_user_can('manage_options')) {
721
+            add_settings_error('wpinv-notices', '', __('Your account does not have permission to add rate classes.', 'invoicing'), 'error');
722 722
             return $input;
723 723
         }
724 724
         
725 725
         $vat_classes = self::get_rate_classes();
726
-        $vat_class = !empty( $_REQUEST['wpi_vat_class'] ) && isset( $vat_classes[$_REQUEST['wpi_vat_class']] )? sanitize_text_field( $_REQUEST['wpi_vat_class'] ) : '';
726
+        $vat_class = !empty($_REQUEST['wpi_vat_class']) && isset($vat_classes[$_REQUEST['wpi_vat_class']]) ? sanitize_text_field($_REQUEST['wpi_vat_class']) : '';
727 727
         
728
-        if ( empty( $vat_class ) ) {
729
-            add_settings_error( 'wpinv-notices', '', __( 'No valid VAT rates class contained in the request to save rates.', 'invoicing' ), 'error' );
728
+        if (empty($vat_class)) {
729
+            add_settings_error('wpinv-notices', '', __('No valid VAT rates class contained in the request to save rates.', 'invoicing'), 'error');
730 730
             
731 731
             return $input;
732 732
         }
733 733
 
734
-        $new_rates = ! empty( $_POST['vat_rates'] ) ? array_values( $_POST['vat_rates'] ) : array();
734
+        $new_rates = !empty($_POST['vat_rates']) ? array_values($_POST['vat_rates']) : array();
735 735
 
736
-        if ( $vat_class === '_standard' ) {
736
+        if ($vat_class === '_standard') {
737 737
             // Save the active rates in the invoice settings
738
-            update_option( 'wpinv_tax_rates', $new_rates );
738
+            update_option('wpinv_tax_rates', $new_rates);
739 739
         } else {
740 740
             // Get the existing set of rates
741 741
             $rates = self::get_non_standard_rates();
742 742
             $rates[$vat_class] = $new_rates;
743 743
 
744
-            update_option( 'wpinv_vat_rates', $rates );
744
+            update_option('wpinv_vat_rates', $rates);
745 745
         }
746 746
         
747 747
         return $input;
@@ -751,71 +751,71 @@  discard block
 block discarded – undo
751 751
         $response = array();
752 752
         $response['success'] = false;
753 753
         
754
-        if ( !current_user_can( 'manage_options' ) ) {
755
-            $response['error'] = __( 'Invalid access!', 'invoicing' );
756
-            wp_send_json( $response );
754
+        if (!current_user_can('manage_options')) {
755
+            $response['error'] = __('Invalid access!', 'invoicing');
756
+            wp_send_json($response);
757 757
         }
758 758
         
759
-        $vat_class_name = !empty( $_POST['name'] ) ? sanitize_text_field( $_POST['name'] ) : false;
760
-        $vat_class_desc = !empty( $_POST['desc'] ) ? sanitize_text_field( $_POST['desc'] ) : false;
759
+        $vat_class_name = !empty($_POST['name']) ? sanitize_text_field($_POST['name']) : false;
760
+        $vat_class_desc = !empty($_POST['desc']) ? sanitize_text_field($_POST['desc']) : false;
761 761
         
762
-        if ( empty( $vat_class_name ) ) {
763
-            $response['error'] = __( 'Select the VAT rate name', 'invoicing' );
764
-            wp_send_json( $response );
762
+        if (empty($vat_class_name)) {
763
+            $response['error'] = __('Select the VAT rate name', 'invoicing');
764
+            wp_send_json($response);
765 765
         }
766 766
         
767 767
         $vat_classes = (array)self::get_rate_classes();
768 768
 
769
-        if ( !empty( $vat_classes ) && in_array( strtolower( $vat_class_name ), array_map( 'strtolower', array_values( $vat_classes ) ) ) ) {
770
-            $response['error'] = wp_sprintf( __( 'A VAT Rate name "%s" already exists', 'invoicing' ), $vat_class_name );
771
-            wp_send_json( $response );
769
+        if (!empty($vat_classes) && in_array(strtolower($vat_class_name), array_map('strtolower', array_values($vat_classes)))) {
770
+            $response['error'] = wp_sprintf(__('A VAT Rate name "%s" already exists', 'invoicing'), $vat_class_name);
771
+            wp_send_json($response);
772 772
         }
773 773
         
774
-        $rate_class_key = normalize_whitespace( 'wpi-' . $vat_class_name );
775
-        $rate_class_key = sanitize_key( str_replace( " ", "-", $rate_class_key ) );
774
+        $rate_class_key = normalize_whitespace('wpi-' . $vat_class_name);
775
+        $rate_class_key = sanitize_key(str_replace(" ", "-", $rate_class_key));
776 776
         
777
-        $vat_classes = (array)self::get_rate_classes( true );
778
-        $vat_classes[$rate_class_key] = array( 'name' => $vat_class_name, 'desc' => $vat_class_desc );
777
+        $vat_classes = (array)self::get_rate_classes(true);
778
+        $vat_classes[$rate_class_key] = array('name' => $vat_class_name, 'desc' => $vat_class_desc);
779 779
         
780
-        update_option( '_wpinv_vat_rate_classes', $vat_classes );
780
+        update_option('_wpinv_vat_rate_classes', $vat_classes);
781 781
         
782 782
         $response['success'] = true;
783
-        $response['redirect'] = admin_url( 'admin.php?page=wpinv-settings&tab=taxes&section=vat_rates&wpi_sub=' . $rate_class_key );
783
+        $response['redirect'] = admin_url('admin.php?page=wpinv-settings&tab=taxes&section=vat_rates&wpi_sub=' . $rate_class_key);
784 784
         
785
-        wp_send_json( $response );
785
+        wp_send_json($response);
786 786
     }
787 787
     
788 788
     public static function delete_class() {
789 789
         $response = array();
790 790
         $response['success'] = false;
791 791
         
792
-        if ( !current_user_can( 'manage_options' ) || !isset( $_POST['class'] ) ) {
793
-            $response['error'] = __( 'Invalid access!', 'invoicing' );
794
-            wp_send_json( $response );
792
+        if (!current_user_can('manage_options') || !isset($_POST['class'])) {
793
+            $response['error'] = __('Invalid access!', 'invoicing');
794
+            wp_send_json($response);
795 795
         }
796 796
         
797
-        $vat_class = isset( $_POST['class'] ) && $_POST['class'] !== '' ? sanitize_text_field( $_POST['class'] ) : false;
797
+        $vat_class = isset($_POST['class']) && $_POST['class'] !== '' ? sanitize_text_field($_POST['class']) : false;
798 798
         $vat_classes = (array)self::get_rate_classes();
799 799
 
800
-        if ( !isset( $vat_classes[$vat_class] ) ) {
801
-            $response['error'] = __( 'Requested class does not exists', 'invoicing' );
802
-            wp_send_json( $response );
800
+        if (!isset($vat_classes[$vat_class])) {
801
+            $response['error'] = __('Requested class does not exists', 'invoicing');
802
+            wp_send_json($response);
803 803
         }
804 804
         
805
-        if ( $vat_class == '_new' || $vat_class == '_standard' ) {
806
-            $response['error'] = __( 'You can not delete standard rates class', 'invoicing' );
807
-            wp_send_json( $response );
805
+        if ($vat_class == '_new' || $vat_class == '_standard') {
806
+            $response['error'] = __('You can not delete standard rates class', 'invoicing');
807
+            wp_send_json($response);
808 808
         }
809 809
             
810
-        $vat_classes = (array)self::get_rate_classes( true );
811
-        unset( $vat_classes[$vat_class] );
810
+        $vat_classes = (array)self::get_rate_classes(true);
811
+        unset($vat_classes[$vat_class]);
812 812
         
813
-        update_option( '_wpinv_vat_rate_classes', $vat_classes );
813
+        update_option('_wpinv_vat_rate_classes', $vat_classes);
814 814
         
815 815
         $response['success'] = true;
816
-        $response['redirect'] = admin_url( 'admin.php?page=wpinv-settings&tab=taxes&section=vat_rates&wpi_sub=_new' );
816
+        $response['redirect'] = admin_url('admin.php?page=wpinv-settings&tab=taxes&section=vat_rates&wpi_sub=_new');
817 817
         
818
-        wp_send_json( $response );
818
+        wp_send_json($response);
819 819
     }
820 820
     
821 821
     public static function update_eu_rates() {        
@@ -824,72 +824,72 @@  discard block
 block discarded – undo
824 824
         $response['error']      = null;
825 825
         $response['data']       = null;
826 826
         
827
-        if ( !current_user_can( 'manage_options' ) ) {
828
-            $response['error'] = __( 'Invalid access!', 'invoicing' );
829
-            wp_send_json( $response );
827
+        if (!current_user_can('manage_options')) {
828
+            $response['error'] = __('Invalid access!', 'invoicing');
829
+            wp_send_json($response);
830 830
         }
831 831
         
832
-        $group      = !empty( $_POST['group'] ) ? sanitize_text_field( $_POST['group'] ) : '';
833
-        $euvatrates = self::request_euvatrates( $group );
832
+        $group      = !empty($_POST['group']) ? sanitize_text_field($_POST['group']) : '';
833
+        $euvatrates = self::request_euvatrates($group);
834 834
         
835
-        if ( !empty( $euvatrates ) ) {
836
-            if ( !empty( $euvatrates['success'] ) && !empty( $euvatrates['rates'] ) ) {
835
+        if (!empty($euvatrates)) {
836
+            if (!empty($euvatrates['success']) && !empty($euvatrates['rates'])) {
837 837
                 $response['success']        = true;
838 838
                 $response['data']['rates']  = $euvatrates['rates'];
839
-            } else if ( !empty( $euvatrates['error'] ) ) {
839
+            } else if (!empty($euvatrates['error'])) {
840 840
                 $response['error']          = $euvatrates['error'];
841 841
             }
842 842
         }
843 843
             
844
-        wp_send_json( $response );
844
+        wp_send_json($response);
845 845
     }
846 846
     
847 847
     public static function hide_vat_fields() {
848
-        $hide = wpinv_get_option( 'vat_disable_fields' );
848
+        $hide = wpinv_get_option('vat_disable_fields');
849 849
         
850
-        return apply_filters( 'wpinv_hide_vat_fields', $hide );
850
+        return apply_filters('wpinv_hide_vat_fields', $hide);
851 851
     }
852 852
     
853 853
     public static function same_country_rule() {
854
-        $same_country_rule = wpinv_get_option( 'vat_same_country_rule' );
854
+        $same_country_rule = wpinv_get_option('vat_same_country_rule');
855 855
         
856
-        return apply_filters( 'wpinv_vat_same_country_rule', $same_country_rule );
856
+        return apply_filters('wpinv_vat_same_country_rule', $same_country_rule);
857 857
     }
858 858
     
859 859
     public static function get_vat_name() {
860
-        $vat_name   = wpinv_get_option( 'vat_name' );
861
-        $vat_name   = !empty( $vat_name ) ? $vat_name : 'VAT';
860
+        $vat_name   = wpinv_get_option('vat_name');
861
+        $vat_name   = !empty($vat_name) ? $vat_name : 'VAT';
862 862
         
863
-        return apply_filters( 'wpinv_get_owner_vat_name', $vat_name );
863
+        return apply_filters('wpinv_get_owner_vat_name', $vat_name);
864 864
     }
865 865
     
866 866
     public static function get_company_name() {
867
-        $company_name = wpinv_get_option( 'vat_company_name' );
867
+        $company_name = wpinv_get_option('vat_company_name');
868 868
         
869
-        return apply_filters( 'wpinv_get_owner_company_name', $company_name );
869
+        return apply_filters('wpinv_get_owner_company_name', $company_name);
870 870
     }
871 871
     
872 872
     public static function get_vat_number() {
873
-        $vat_number = wpinv_get_option( 'vat_number' );
873
+        $vat_number = wpinv_get_option('vat_number');
874 874
         
875
-        return apply_filters( 'wpinv_get_owner_vat_number', $vat_number );
875
+        return apply_filters('wpinv_get_owner_vat_number', $vat_number);
876 876
     }
877 877
     
878 878
     public static function is_vat_validated() {
879
-        $validated = self::get_vat_number() && wpinv_get_option( 'vat_valid' );
879
+        $validated = self::get_vat_number() && wpinv_get_option('vat_valid');
880 880
         
881
-        return apply_filters( 'wpinv_is_owner_vat_validated', $validated );
881
+        return apply_filters('wpinv_is_owner_vat_validated', $validated);
882 882
     }
883 883
     
884
-    public static function sanitize_vat( $vat_number, $country_code = '' ) {        
885
-        $vat_number = str_replace( array(' ', '.', '-', '_', ',' ), '', strtoupper( trim( $vat_number ) ) );
884
+    public static function sanitize_vat($vat_number, $country_code = '') {        
885
+        $vat_number = str_replace(array(' ', '.', '-', '_', ','), '', strtoupper(trim($vat_number)));
886 886
         
887
-        if ( empty( $country_code ) ) {
888
-            $country_code = substr( $vat_number, 0, 2 );
887
+        if (empty($country_code)) {
888
+            $country_code = substr($vat_number, 0, 2);
889 889
         }
890 890
         
891
-        if ( strpos( $vat_number , $country_code ) === 0 ) {
892
-            $vat = str_replace( $country_code, '', $vat_number );
891
+        if (strpos($vat_number, $country_code) === 0) {
892
+            $vat = str_replace($country_code, '', $vat_number);
893 893
         } else {
894 894
             $vat = $country_code . $vat_number;
895 895
         }
@@ -902,140 +902,140 @@  discard block
 block discarded – undo
902 902
         return $return;
903 903
     }
904 904
     
905
-    public static function offline_check( $vat_number, $country_code = '', $formatted = false ) {
906
-        $vat            = self::sanitize_vat( $vat_number, $country_code );
905
+    public static function offline_check($vat_number, $country_code = '', $formatted = false) {
906
+        $vat            = self::sanitize_vat($vat_number, $country_code);
907 907
         $vat_number     = $vat['vat_number'];
908 908
         $country_code   = $vat['iso'];
909 909
         $regex          = array();
910 910
         
911
-        switch ( $country_code ) {
911
+        switch ($country_code) {
912 912
             case 'AT':
913
-                $regex[] = '/^(AT)U(\d{8})$/';                           // Austria
913
+                $regex[] = '/^(AT)U(\d{8})$/'; // Austria
914 914
                 break;
915 915
             case 'BE':
916
-                $regex[] = '/^(BE)(0?\d{9})$/';                          // Belgium
916
+                $regex[] = '/^(BE)(0?\d{9})$/'; // Belgium
917 917
                 break;
918 918
             case 'BG':
919
-                $regex[] = '/^(BG)(\d{9,10})$/';                         // Bulgaria
919
+                $regex[] = '/^(BG)(\d{9,10})$/'; // Bulgaria
920 920
                 break;
921 921
             case 'CH':
922 922
             case 'CHE':
923
-                $regex[] = '/^(CHE)(\d{9})MWST$/';                       // Switzerland (Not EU)
923
+                $regex[] = '/^(CHE)(\d{9})MWST$/'; // Switzerland (Not EU)
924 924
                 break;
925 925
             case 'CY':
926
-                $regex[] = '/^(CY)([0-5|9]\d{7}[A-Z])$/';                // Cyprus
926
+                $regex[] = '/^(CY)([0-5|9]\d{7}[A-Z])$/'; // Cyprus
927 927
                 break;
928 928
             case 'CZ':
929
-                $regex[] = '/^(CZ)(\d{8,13})$/';                         // Czech Republic
929
+                $regex[] = '/^(CZ)(\d{8,13})$/'; // Czech Republic
930 930
                 break;
931 931
             case 'DE':
932
-                $regex[] = '/^(DE)([1-9]\d{8})$/';                       // Germany
932
+                $regex[] = '/^(DE)([1-9]\d{8})$/'; // Germany
933 933
                 break;
934 934
             case 'DK':
935
-                $regex[] = '/^(DK)(\d{8})$/';                            // Denmark
935
+                $regex[] = '/^(DK)(\d{8})$/'; // Denmark
936 936
                 break;
937 937
             case 'EE':
938
-                $regex[] = '/^(EE)(10\d{7})$/';                          // Estonia
938
+                $regex[] = '/^(EE)(10\d{7})$/'; // Estonia
939 939
                 break;
940 940
             case 'EL':
941
-                $regex[] = '/^(EL)(\d{9})$/';                            // Greece
941
+                $regex[] = '/^(EL)(\d{9})$/'; // Greece
942 942
                 break;
943 943
             case 'ES':
944
-                $regex[] = '/^(ES)([A-Z]\d{8})$/';                       // Spain (National juridical entities)
945
-                $regex[] = '/^(ES)([A-H|N-S|W]\d{7}[A-J])$/';            // Spain (Other juridical entities)
946
-                $regex[] = '/^(ES)([0-9|Y|Z]\d{7}[A-Z])$/';              // Spain (Personal entities type 1)
947
-                $regex[] = '/^(ES)([K|L|M|X]\d{7}[A-Z])$/';              // Spain (Personal entities type 2)
944
+                $regex[] = '/^(ES)([A-Z]\d{8})$/'; // Spain (National juridical entities)
945
+                $regex[] = '/^(ES)([A-H|N-S|W]\d{7}[A-J])$/'; // Spain (Other juridical entities)
946
+                $regex[] = '/^(ES)([0-9|Y|Z]\d{7}[A-Z])$/'; // Spain (Personal entities type 1)
947
+                $regex[] = '/^(ES)([K|L|M|X]\d{7}[A-Z])$/'; // Spain (Personal entities type 2)
948 948
                 break;
949 949
             case 'EU':
950
-                $regex[] = '/^(EU)(\d{9})$/';                            // EU-type
950
+                $regex[] = '/^(EU)(\d{9})$/'; // EU-type
951 951
                 break;
952 952
             case 'FI':
953
-                $regex[] = '/^(FI)(\d{8})$/';                            // Finland
953
+                $regex[] = '/^(FI)(\d{8})$/'; // Finland
954 954
                 break;
955 955
             case 'FR':
956
-                $regex[] = '/^(FR)(\d{11})$/';                           // France (1)
957
-                $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)](\d{10})$/';        // France (2)
958
-                $regex[] = '/^(FR)\d[(A-H)|(J-N)|(P-Z)](\d{9})$/';       // France (3)
959
-                $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)]{2}(\d{9})$/';      // France (4)
956
+                $regex[] = '/^(FR)(\d{11})$/'; // France (1)
957
+                $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)](\d{10})$/'; // France (2)
958
+                $regex[] = '/^(FR)\d[(A-H)|(J-N)|(P-Z)](\d{9})$/'; // France (3)
959
+                $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)]{2}(\d{9})$/'; // France (4)
960 960
                 break;
961 961
             case 'GB':
962
-                $regex[] = '/^(GB)?(\d{9})$/';                           // UK (Standard)
963
-                $regex[] = '/^(GB)?(\d{12})$/';                          // UK (Branches)
964
-                $regex[] = '/^(GB)?(GD\d{3})$/';                         // UK (Government)
965
-                $regex[] = '/^(GB)?(HA\d{3})$/';                         // UK (Health authority)
962
+                $regex[] = '/^(GB)?(\d{9})$/'; // UK (Standard)
963
+                $regex[] = '/^(GB)?(\d{12})$/'; // UK (Branches)
964
+                $regex[] = '/^(GB)?(GD\d{3})$/'; // UK (Government)
965
+                $regex[] = '/^(GB)?(HA\d{3})$/'; // UK (Health authority)
966 966
                 break;
967 967
             case 'GR':
968
-                $regex[] = '/^(GR)(\d{8,9})$/';                          // Greece
968
+                $regex[] = '/^(GR)(\d{8,9})$/'; // Greece
969 969
                 break;
970 970
             case 'HR':
971
-                $regex[] = '/^(HR)(\d{11})$/';                           // Croatia
971
+                $regex[] = '/^(HR)(\d{11})$/'; // Croatia
972 972
                 break;
973 973
             case 'HU':
974
-                $regex[] = '/^(HU)(\d{8})$/';                            // Hungary
974
+                $regex[] = '/^(HU)(\d{8})$/'; // Hungary
975 975
                 break;
976 976
             case 'IE':
977
-                $regex[] = '/^(IE)(\d{7}[A-W])$/';                       // Ireland (1)
978
-                $regex[] = '/^(IE)([7-9][A-Z\*\+)]\d{5}[A-W])$/';        // Ireland (2)
979
-                $regex[] = '/^(IE)(\d{7}[A-Z][AH])$/';                   // Ireland (3) (new format from 1 Jan 2013)
977
+                $regex[] = '/^(IE)(\d{7}[A-W])$/'; // Ireland (1)
978
+                $regex[] = '/^(IE)([7-9][A-Z\*\+)]\d{5}[A-W])$/'; // Ireland (2)
979
+                $regex[] = '/^(IE)(\d{7}[A-Z][AH])$/'; // Ireland (3) (new format from 1 Jan 2013)
980 980
                 break;
981 981
             case 'IT':
982
-                $regex[] = '/^(IT)(\d{11})$/';                           // Italy
982
+                $regex[] = '/^(IT)(\d{11})$/'; // Italy
983 983
                 break;
984 984
             case 'LV':
985
-                $regex[] = '/^(LV)(\d{11})$/';                           // Latvia
985
+                $regex[] = '/^(LV)(\d{11})$/'; // Latvia
986 986
                 break;
987 987
             case 'LT':
988
-                $regex[] = '/^(LT)(\d{9}|\d{12})$/';                     // Lithuania
988
+                $regex[] = '/^(LT)(\d{9}|\d{12})$/'; // Lithuania
989 989
                 break;
990 990
             case 'LU':
991
-                $regex[] = '/^(LU)(\d{8})$/';                            // Luxembourg
991
+                $regex[] = '/^(LU)(\d{8})$/'; // Luxembourg
992 992
                 break;
993 993
             case 'MT':
994
-                $regex[] = '/^(MT)([1-9]\d{7})$/';                       // Malta
994
+                $regex[] = '/^(MT)([1-9]\d{7})$/'; // Malta
995 995
                 break;
996 996
             case 'NL':
997
-                $regex[] = '/^(NL)(\d{9})B\d{2}$/';                      // Netherlands
997
+                $regex[] = '/^(NL)(\d{9})B\d{2}$/'; // Netherlands
998 998
                 break;
999 999
             case 'NO':
1000
-                $regex[] = '/^(NO)(\d{9})$/';                            // Norway (Not EU)
1000
+                $regex[] = '/^(NO)(\d{9})$/'; // Norway (Not EU)
1001 1001
                 break;
1002 1002
             case 'PL':
1003
-                $regex[] = '/^(PL)(\d{10})$/';                           // Poland
1003
+                $regex[] = '/^(PL)(\d{10})$/'; // Poland
1004 1004
                 break;
1005 1005
             case 'PT':
1006
-                $regex[] = '/^(PT)(\d{9})$/';                            // Portugal
1006
+                $regex[] = '/^(PT)(\d{9})$/'; // Portugal
1007 1007
                 break;
1008 1008
             case 'RO':
1009
-                $regex[] = '/^(RO)([1-9]\d{1,9})$/';                     // Romania
1009
+                $regex[] = '/^(RO)([1-9]\d{1,9})$/'; // Romania
1010 1010
                 break;
1011 1011
             case 'RS':
1012
-                $regex[] = '/^(RS)(\d{9})$/';                            // Serbia (Not EU)
1012
+                $regex[] = '/^(RS)(\d{9})$/'; // Serbia (Not EU)
1013 1013
                 break;
1014 1014
             case 'SI':
1015
-                $regex[] = '/^(SI)([1-9]\d{7})$/';                       // Slovenia
1015
+                $regex[] = '/^(SI)([1-9]\d{7})$/'; // Slovenia
1016 1016
                 break;
1017 1017
             case 'SK':
1018
-                $regex[] = '/^(SK)([1-9]\d[(2-4)|(6-9)]\d{7})$/';        // Slovakia Republic
1018
+                $regex[] = '/^(SK)([1-9]\d[(2-4)|(6-9)]\d{7})$/'; // Slovakia Republic
1019 1019
                 break;
1020 1020
             case 'SE':
1021
-                $regex[] = '/^(SE)(\d{10}01)$/';                         // Sweden
1021
+                $regex[] = '/^(SE)(\d{10}01)$/'; // Sweden
1022 1022
                 break;
1023 1023
             default:
1024 1024
                 $regex = array();
1025 1025
             break;
1026 1026
         }
1027 1027
         
1028
-        if ( empty( $regex ) ) {
1028
+        if (empty($regex)) {
1029 1029
             return false;
1030 1030
         }
1031 1031
         
1032
-        foreach ( $regex as $pattern ) {
1032
+        foreach ($regex as $pattern) {
1033 1033
             $matches = null;
1034
-            preg_match_all( $pattern, $vat_number, $matches );
1034
+            preg_match_all($pattern, $vat_number, $matches);
1035 1035
             
1036
-            if ( !empty( $matches[1][0] ) && !empty( $matches[2][0] ) ) {
1037
-                if ( $formatted ) {
1038
-                    return array( 'code' => $matches[1][0], 'number' => $matches[2][0] );
1036
+            if (!empty($matches[1][0]) && !empty($matches[2][0])) {
1037
+                if ($formatted) {
1038
+                    return array('code' => $matches[1][0], 'number' => $matches[2][0]);
1039 1039
                 } else {
1040 1040
                     return true;
1041 1041
                 }
@@ -1045,75 +1045,75 @@  discard block
 block discarded – undo
1045 1045
         return false;
1046 1046
     }
1047 1047
     
1048
-    public static function vies_check( $vat_number, $country_code = '', $result = false ) {
1049
-        $vat            = self::sanitize_vat( $vat_number, $country_code );
1048
+    public static function vies_check($vat_number, $country_code = '', $result = false) {
1049
+        $vat            = self::sanitize_vat($vat_number, $country_code);
1050 1050
         $vat_number     = $vat['vat'];
1051 1051
         $iso            = $vat['iso'];
1052 1052
         
1053
-        $url = 'http://ec.europa.eu/taxation_customs/vies/viesquer.do?ms=' . urlencode( $iso ) . '&iso=' . urlencode( $iso ) . '&vat=' . urlencode( $vat_number );
1053
+        $url = 'http://ec.europa.eu/taxation_customs/vies/viesquer.do?ms=' . urlencode($iso) . '&iso=' . urlencode($iso) . '&vat=' . urlencode($vat_number);
1054 1054
         
1055
-        if ( ini_get( 'allow_url_fopen' ) ) {
1056
-            $response = file_get_contents( $url );
1057
-        } else if ( function_exists( 'curl_init' ) ) {
1055
+        if (ini_get('allow_url_fopen')) {
1056
+            $response = file_get_contents($url);
1057
+        } else if (function_exists('curl_init')) {
1058 1058
             $ch = curl_init();
1059 1059
             
1060
-            curl_setopt( $ch, CURLOPT_URL, $url );
1061
-            curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 30 );
1062
-            curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
1063
-            curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0 );
1064
-            curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 );
1060
+            curl_setopt($ch, CURLOPT_URL, $url);
1061
+            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
1062
+            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
1063
+            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
1064
+            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
1065 1065
             
1066
-            $response = curl_exec( $ch );
1066
+            $response = curl_exec($ch);
1067 1067
             
1068
-            if ( curl_errno( $ch ) ) {
1069
-                wpinv_error_log( curl_error( $ch ), 'VIES CHECK ERROR' );
1068
+            if (curl_errno($ch)) {
1069
+                wpinv_error_log(curl_error($ch), 'VIES CHECK ERROR');
1070 1070
                 $response = '';
1071 1071
             }
1072 1072
             
1073
-            curl_close( $ch );
1073
+            curl_close($ch);
1074 1074
         } else {
1075
-            wpinv_error_log( 'To use VIES CHECK you must have allow_url_fopen is ON or cURL installed & active on your server.', 'VIES CHECK ERROR' );
1075
+            wpinv_error_log('To use VIES CHECK you must have allow_url_fopen is ON or cURL installed & active on your server.', 'VIES CHECK ERROR');
1076 1076
         }
1077 1077
         
1078
-        if ( empty( $response ) ) {
1078
+        if (empty($response)) {
1079 1079
             return $result;
1080 1080
         }
1081 1081
 
1082
-        if ( preg_match( '/invalid VAT number/i', $response ) ) {
1082
+        if (preg_match('/invalid VAT number/i', $response)) {
1083 1083
             return false;
1084
-        } else if ( preg_match( '/valid VAT number/i', $response, $matches ) ) {
1085
-            $content = explode( "valid VAT number", htmlentities( $response ) );
1084
+        } else if (preg_match('/valid VAT number/i', $response, $matches)) {
1085
+            $content = explode("valid VAT number", htmlentities($response));
1086 1086
             
1087
-            if ( !empty( $content[1] ) ) {
1088
-                preg_match_all( '/<tr>(.*?)<td.*?>(.*?)<\/td>(.*?)<\/tr>/si', html_entity_decode( $content[1] ), $matches );
1087
+            if (!empty($content[1])) {
1088
+                preg_match_all('/<tr>(.*?)<td.*?>(.*?)<\/td>(.*?)<\/tr>/si', html_entity_decode($content[1]), $matches);
1089 1089
                 
1090
-                if ( !empty( $matches[2] ) && $matches[3] ) {
1090
+                if (!empty($matches[2]) && $matches[3]) {
1091 1091
                     $return = array();
1092 1092
                     
1093
-                    foreach ( $matches[2] as $key => $label ) {
1094
-                        $label = trim( $label );
1093
+                    foreach ($matches[2] as $key => $label) {
1094
+                        $label = trim($label);
1095 1095
                         
1096
-                        switch ( strtolower( $label ) ) {
1096
+                        switch (strtolower($label)) {
1097 1097
                             case 'member state':
1098
-                                $return['state'] = trim( strip_tags( $matches[3][$key] ) );
1098
+                                $return['state'] = trim(strip_tags($matches[3][$key]));
1099 1099
                             break;
1100 1100
                             case 'vat number':
1101
-                                $return['number'] = trim( strip_tags( $matches[3][$key] ) );
1101
+                                $return['number'] = trim(strip_tags($matches[3][$key]));
1102 1102
                             break;
1103 1103
                             case 'name':
1104
-                                $return['company'] = trim( strip_tags( $matches[3][$key] ) );
1104
+                                $return['company'] = trim(strip_tags($matches[3][$key]));
1105 1105
                             break;
1106 1106
                             case 'address':
1107
-                                $address           = str_replace( array( "<br><br>", "<br /><br />", "<br/><br/>" ), "<br>", html_entity_decode( trim( $matches[3][$key] ) ) );
1108
-                                $return['address'] = trim( strip_tags( $address, '<br>' ) );
1107
+                                $address           = str_replace(array("<br><br>", "<br /><br />", "<br/><br/>"), "<br>", html_entity_decode(trim($matches[3][$key])));
1108
+                                $return['address'] = trim(strip_tags($address, '<br>'));
1109 1109
                             break;
1110 1110
                             case 'consultation number':
1111
-                                $return['consultation'] = trim( strip_tags( $matches[3][$key] ) );
1111
+                                $return['consultation'] = trim(strip_tags($matches[3][$key]));
1112 1112
                             break;
1113 1113
                         }
1114 1114
                     }
1115 1115
                     
1116
-                    if ( !empty( $return ) ) {
1116
+                    if (!empty($return)) {
1117 1117
                         return $return;
1118 1118
                     }
1119 1119
                 }
@@ -1125,55 +1125,55 @@  discard block
 block discarded – undo
1125 1125
         }
1126 1126
     }
1127 1127
     
1128
-    public static function check_vat( $vat_number, $country_code = '' ) {        
1128
+    public static function check_vat($vat_number, $country_code = '') {        
1129 1129
         $vat_name           = self::get_vat_name();
1130 1130
         
1131 1131
         $return             = array();
1132 1132
         $return['valid']    = false;
1133
-        $return['message']  = wp_sprintf( __( '%s number not validated', 'invoicing' ), $vat_name );
1133
+        $return['message']  = wp_sprintf(__('%s number not validated', 'invoicing'), $vat_name);
1134 1134
                 
1135
-        if ( !wpinv_get_option( 'vat_offline_check' ) && !self::offline_check( $vat_number, $country_code ) ) {
1135
+        if (!wpinv_get_option('vat_offline_check') && !self::offline_check($vat_number, $country_code)) {
1136 1136
             return $return;
1137 1137
         }
1138 1138
             
1139
-        $response = self::vies_check( $vat_number, $country_code );
1139
+        $response = self::vies_check($vat_number, $country_code);
1140 1140
         
1141
-        if ( $response ) {
1142
-            $return['valid']    = true;
1141
+        if ($response) {
1142
+            $return['valid'] = true;
1143 1143
             
1144
-            if ( is_array( $response ) ) {
1145
-                $return['company'] = isset( $response['company'] ) ? $response['company'] : '';
1146
-                $return['address'] = isset( $response['address'] ) ? $response['address'] : '';
1144
+            if (is_array($response)) {
1145
+                $return['company'] = isset($response['company']) ? $response['company'] : '';
1146
+                $return['address'] = isset($response['address']) ? $response['address'] : '';
1147 1147
                 $return['message'] = $return['company'] . '<br/>' . $return['address'];
1148 1148
             }
1149 1149
         } else {
1150 1150
             $return['valid']    = false;
1151
-            $return['message']  = wp_sprintf( __( 'Fail to validate the %s number: EU Commission VAT server (VIES) check fails.', 'invoicing' ), $vat_name );
1151
+            $return['message']  = wp_sprintf(__('Fail to validate the %s number: EU Commission VAT server (VIES) check fails.', 'invoicing'), $vat_name);
1152 1152
         }
1153 1153
         
1154 1154
         return $return;
1155 1155
     }
1156 1156
     
1157
-    public static function request_euvatrates( $group ) {
1157
+    public static function request_euvatrates($group) {
1158 1158
         $response               = array();
1159 1159
         $response['success']    = false;
1160 1160
         $response['error']      = null;
1161 1161
         $response['eurates']    = null;
1162 1162
         
1163 1163
         $euvatrates_url = 'https://euvatrates.com/rates.json';
1164
-        $euvatrates_url = apply_filters( 'wpinv_euvatrates_url', $euvatrates_url );
1165
-        $api_response   = wp_remote_get( $euvatrates_url );
1164
+        $euvatrates_url = apply_filters('wpinv_euvatrates_url', $euvatrates_url);
1165
+        $api_response   = wp_remote_get($euvatrates_url);
1166 1166
     
1167 1167
         try {
1168
-            if ( is_wp_error( $api_response ) ) {
1169
-                $response['error']      = __( $api_response->get_error_message(), 'invoicing' );
1168
+            if (is_wp_error($api_response)) {
1169
+                $response['error'] = __($api_response->get_error_message(), 'invoicing');
1170 1170
             } else {
1171
-                $body = json_decode( $api_response['body'] );
1171
+                $body = json_decode($api_response['body']);
1172 1172
                 
1173
-                if ( isset( $body->rates ) ) {
1173
+                if (isset($body->rates)) {
1174 1174
                     $rates = array();
1175 1175
                     
1176
-                    foreach ( $body->rates as $country_code => $rate ) {
1176
+                    foreach ($body->rates as $country_code => $rate) {
1177 1177
                         $vat_rate = array();
1178 1178
                         $vat_rate['country']        = $rate->country;
1179 1179
                         $vat_rate['standard']       = (float)$rate->standard_rate;
@@ -1181,7 +1181,7 @@  discard block
 block discarded – undo
1181 1181
                         $vat_rate['superreduced']   = (float)$rate->super_reduced_rate;
1182 1182
                         $vat_rate['parking']        = (float)$rate->parking_rate;
1183 1183
                         
1184
-                        if ( $group !== '' && in_array( $group, array( 'standard', 'reduced', 'superreduced', 'parking' ) ) ) {
1184
+                        if ($group !== '' && in_array($group, array('standard', 'reduced', 'superreduced', 'parking'))) {
1185 1185
                             $vat_rate_group = array();
1186 1186
                             $vat_rate_group['country'] = $rate->country;
1187 1187
                             $vat_rate_group[$group]    = $vat_rate[$group];
@@ -1193,79 +1193,79 @@  discard block
 block discarded – undo
1193 1193
                     }
1194 1194
                     
1195 1195
                     $response['success']    = true;                                
1196
-                    $response['rates']      = apply_filters( 'wpinv_process_euvatrates', $rates, $api_response, $group );
1196
+                    $response['rates']      = apply_filters('wpinv_process_euvatrates', $rates, $api_response, $group);
1197 1197
                 } else {
1198
-                    $response['error']      = __( 'No EU rates found!', 'invoicing' );
1198
+                    $response['error']      = __('No EU rates found!', 'invoicing');
1199 1199
                 }
1200 1200
             }
1201
-        } catch ( Exception $e ) {
1202
-            $response['error'] = __( $e->getMessage(), 'invoicing' );
1201
+        } catch (Exception $e) {
1202
+            $response['error'] = __($e->getMessage(), 'invoicing');
1203 1203
         }
1204 1204
         
1205
-        return apply_filters( 'wpinv_response_euvatrates', $response, $group );
1205
+        return apply_filters('wpinv_response_euvatrates', $response, $group);
1206 1206
     }    
1207 1207
     
1208
-    public static function requires_vat( $requires_vat = false, $user_id = 0, $is_digital = null ) {
1208
+    public static function requires_vat($requires_vat = false, $user_id = 0, $is_digital = null) {
1209 1209
         global $wpi_item_id, $wpi_country;
1210 1210
         
1211
-        if ( !empty( $_POST['wpinv_country'] ) ) {
1212
-            $country_code = trim( $_POST['wpinv_country'] );
1213
-        } else if ( !empty( $_POST['country'] ) ) {
1214
-            $country_code = trim( $_POST['country'] );
1215
-        } else if ( !empty( $wpi_country ) ) {
1211
+        if (!empty($_POST['wpinv_country'])) {
1212
+            $country_code = trim($_POST['wpinv_country']);
1213
+        } else if (!empty($_POST['country'])) {
1214
+            $country_code = trim($_POST['country']);
1215
+        } else if (!empty($wpi_country)) {
1216 1216
             $country_code = $wpi_country;
1217 1217
         } else {
1218
-            $country_code = self::get_user_country( '', $user_id );
1218
+            $country_code = self::get_user_country('', $user_id);
1219 1219
         }
1220 1220
         
1221
-        if ( $is_digital === null && $wpi_item_id ) {
1222
-            $is_digital = $wpi_item_id ? self::item_has_digital_rule( $wpi_item_id ) : self::allow_vat_rules();
1221
+        if ($is_digital === null && $wpi_item_id) {
1222
+            $is_digital = $wpi_item_id ? self::item_has_digital_rule($wpi_item_id) : self::allow_vat_rules();
1223 1223
         }
1224 1224
         
1225
-        if ( !empty( $country_code ) ) {
1226
-            $requires_vat = ( self::is_eu_state( $country_code ) && ( self::is_eu_state( self::$default_country ) || $is_digital ) ) || ( self::is_gst_country( $country_code ) && self::is_gst_country( self::$default_country ) );
1225
+        if (!empty($country_code)) {
1226
+            $requires_vat = (self::is_eu_state($country_code) && (self::is_eu_state(self::$default_country) || $is_digital)) || (self::is_gst_country($country_code) && self::is_gst_country(self::$default_country));
1227 1227
         }
1228 1228
         
1229
-        return apply_filters( 'wpinv_requires_vat', $requires_vat, $user_id );
1229
+        return apply_filters('wpinv_requires_vat', $requires_vat, $user_id);
1230 1230
     }
1231 1231
     
1232
-    public static function tax_label( $label = '' ) {
1232
+    public static function tax_label($label = '') {
1233 1233
         global $wpi_requires_vat;
1234 1234
         
1235
-        if ( !( $wpi_requires_vat !== 0 && $wpi_requires_vat ) ) {
1236
-            $wpi_requires_vat = self::requires_vat( 0, false );
1235
+        if (!($wpi_requires_vat !== 0 && $wpi_requires_vat)) {
1236
+            $wpi_requires_vat = self::requires_vat(0, false);
1237 1237
         }
1238 1238
         
1239
-        return $wpi_requires_vat ? __( self::get_vat_name(), 'invoicing' ) : ( $label ? $label : __( 'Tax', 'invoicing' ) );
1239
+        return $wpi_requires_vat ? __(self::get_vat_name(), 'invoicing') : ($label ? $label : __('Tax', 'invoicing'));
1240 1240
     }
1241 1241
     
1242 1242
     public static function standard_rates_label() {
1243
-        return __( 'Standard Rates', 'invoicing' );
1243
+        return __('Standard Rates', 'invoicing');
1244 1244
     }
1245 1245
     
1246
-    public static function get_rate_classes( $with_desc = false ) {        
1247
-        $rate_classes_option = get_option( '_wpinv_vat_rate_classes', true );
1248
-        $classes = maybe_unserialize( $rate_classes_option );
1246
+    public static function get_rate_classes($with_desc = false) {        
1247
+        $rate_classes_option = get_option('_wpinv_vat_rate_classes', true);
1248
+        $classes = maybe_unserialize($rate_classes_option);
1249 1249
         
1250
-        if ( empty( $classes ) || !is_array( $classes ) ) {
1250
+        if (empty($classes) || !is_array($classes)) {
1251 1251
             $classes = array();
1252 1252
         }
1253 1253
 
1254 1254
         $rate_classes = array();
1255
-        if ( !array_key_exists( '_standard', $classes ) ) {
1256
-            if ( $with_desc ) {
1257
-                $rate_classes['_standard'] = array( 'name' => self::standard_rates_label(), 'desc' => __( 'EU member states standard VAT rates', 'invoicing' ) );
1255
+        if (!array_key_exists('_standard', $classes)) {
1256
+            if ($with_desc) {
1257
+                $rate_classes['_standard'] = array('name' => self::standard_rates_label(), 'desc' => __('EU member states standard VAT rates', 'invoicing'));
1258 1258
             } else {
1259 1259
                 $rate_classes['_standard'] = self::standard_rates_label();
1260 1260
             }
1261 1261
         }
1262 1262
         
1263
-        foreach ( $classes as $key => $class ) {
1264
-            $name = !empty( $class['name'] ) ? __( $class['name'], 'invoicing' ) : $key;
1265
-            $desc = !empty( $class['desc'] ) ? __( $class['desc'], 'invoicing' ) : '';
1263
+        foreach ($classes as $key => $class) {
1264
+            $name = !empty($class['name']) ? __($class['name'], 'invoicing') : $key;
1265
+            $desc = !empty($class['desc']) ? __($class['desc'], 'invoicing') : '';
1266 1266
             
1267
-            if ( $with_desc ) {
1268
-                $rate_classes[$key] = array( 'name' => $name, 'desc' => $desc );
1267
+            if ($with_desc) {
1268
+                $rate_classes[$key] = array('name' => $name, 'desc' => $desc);
1269 1269
             } else {
1270 1270
                 $rate_classes[$key] = $name;
1271 1271
             }
@@ -1276,15 +1276,15 @@  discard block
 block discarded – undo
1276 1276
     
1277 1277
     public static function get_all_classes() {        
1278 1278
         $classes            = self::get_rate_classes();
1279
-        $classes['_exempt'] = __( 'Exempt (0%)', 'invoicing' );
1279
+        $classes['_exempt'] = __('Exempt (0%)', 'invoicing');
1280 1280
         
1281
-        return apply_filters( 'wpinv_vat_get_all_classes', $classes );
1281
+        return apply_filters('wpinv_vat_get_all_classes', $classes);
1282 1282
     }
1283 1283
     
1284
-    public static function get_class_desc( $rate_class ) {        
1285
-        $rate_classes = self::get_rate_classes( true );
1284
+    public static function get_class_desc($rate_class) {        
1285
+        $rate_classes = self::get_rate_classes(true);
1286 1286
 
1287
-        if ( !empty( $rate_classes ) && isset( $rate_classes[$rate_class] ) && isset( $rate_classes[$rate_class]['desc'] ) ) {
1287
+        if (!empty($rate_classes) && isset($rate_classes[$rate_class]) && isset($rate_classes[$rate_class]['desc'])) {
1288 1288
             return $rate_classes[$rate_class]['desc'];
1289 1289
         }
1290 1290
         
@@ -1300,106 +1300,106 @@  discard block
 block discarded – undo
1300 1300
             'increased'     => 'Increased'
1301 1301
         );
1302 1302
         
1303
-        return apply_filters( 'wpinv_get_vat_groups', $vat_groups );
1303
+        return apply_filters('wpinv_get_vat_groups', $vat_groups);
1304 1304
     }
1305 1305
 
1306 1306
     public static function get_rules() {
1307 1307
         $vat_rules = array(
1308
-            'digital' => __( 'Digital Product', 'invoicing' ),
1309
-            'physical' => __( 'Physical Product', 'invoicing' )
1308
+            'digital' => __('Digital Product', 'invoicing'),
1309
+            'physical' => __('Physical Product', 'invoicing')
1310 1310
         );
1311
-        return apply_filters( 'wpinv_get_vat_rules', $vat_rules );
1311
+        return apply_filters('wpinv_get_vat_rules', $vat_rules);
1312 1312
     }
1313 1313
 
1314
-    public static function get_vat_rates( $class ) {
1315
-        if ( $class === '_standard' ) {
1314
+    public static function get_vat_rates($class) {
1315
+        if ($class === '_standard') {
1316 1316
             return wpinv_get_tax_rates();
1317 1317
         }
1318 1318
 
1319 1319
         $rates = self::get_non_standard_rates();
1320 1320
 
1321
-        return array_key_exists( $class, $rates ) ? $rates[$class] : array();
1321
+        return array_key_exists($class, $rates) ? $rates[$class] : array();
1322 1322
     }
1323 1323
 
1324 1324
     public static function get_non_standard_rates() {
1325
-        $option = get_option( 'wpinv_vat_rates', array());
1326
-        return is_array( $option ) ? $option : array();
1325
+        $option = get_option('wpinv_vat_rates', array());
1326
+        return is_array($option) ? $option : array();
1327 1327
     }
1328 1328
     
1329 1329
     public static function allow_vat_rules() {
1330
-        return ( wpinv_use_taxes() && wpinv_get_option( 'apply_vat_rules' ) ? true : false );
1330
+        return (wpinv_use_taxes() && wpinv_get_option('apply_vat_rules') ? true : false);
1331 1331
     }
1332 1332
     
1333 1333
     public static function allow_vat_classes() {
1334 1334
         return false; // TODO
1335
-        return ( wpinv_get_option( 'vat_allow_classes' ) ? true : false );
1335
+        return (wpinv_get_option('vat_allow_classes') ? true : false);
1336 1336
     }
1337 1337
     
1338
-    public static function get_item_class( $postID ) {
1339
-        $class = get_post_meta( $postID, '_wpinv_vat_class', true );
1338
+    public static function get_item_class($postID) {
1339
+        $class = get_post_meta($postID, '_wpinv_vat_class', true);
1340 1340
 
1341
-        if ( empty( $class ) ) {
1341
+        if (empty($class)) {
1342 1342
             $class = '_standard';
1343 1343
         }
1344 1344
         
1345
-        return apply_filters( 'wpinv_get_item_vat_class', $class, $postID );
1345
+        return apply_filters('wpinv_get_item_vat_class', $class, $postID);
1346 1346
     }
1347 1347
     
1348
-    public static function item_class_label( $postID ) {        
1348
+    public static function item_class_label($postID) {        
1349 1349
         $vat_classes = self::get_all_classes();
1350 1350
         
1351
-        $class = self::get_item_class( $postID );
1352
-        $class = isset( $vat_classes[$class] ) ? $vat_classes[$class] : __( $class, 'invoicing' );
1351
+        $class = self::get_item_class($postID);
1352
+        $class = isset($vat_classes[$class]) ? $vat_classes[$class] : __($class, 'invoicing');
1353 1353
         
1354
-        return apply_filters( 'wpinv_item_class_label', $class, $postID );
1354
+        return apply_filters('wpinv_item_class_label', $class, $postID);
1355 1355
     }
1356 1356
     
1357
-    public static function get_item_rule( $postID ) {        
1358
-        $rule_type = get_post_meta( $postID, '_wpinv_vat_rule', true );
1357
+    public static function get_item_rule($postID) {        
1358
+        $rule_type = get_post_meta($postID, '_wpinv_vat_rule', true);
1359 1359
         
1360
-        if ( empty( $rule_type ) ) {        
1360
+        if (empty($rule_type)) {        
1361 1361
             $rule_type = self::allow_vat_rules() ? 'digital' : 'physical';
1362 1362
         }
1363 1363
         
1364
-        return apply_filters( 'wpinv_item_get_vat_rule', $rule_type, $postID );
1364
+        return apply_filters('wpinv_item_get_vat_rule', $rule_type, $postID);
1365 1365
     }
1366 1366
     
1367
-    public static function item_rule_label( $postID ) {
1367
+    public static function item_rule_label($postID) {
1368 1368
         $vat_rules  = self::get_rules();
1369
-        $vat_rule   = self::get_item_rule( $postID );
1370
-        $vat_rule   = isset( $vat_rules[$vat_rule] ) ? $vat_rules[$vat_rule] : $vat_rule;
1369
+        $vat_rule   = self::get_item_rule($postID);
1370
+        $vat_rule   = isset($vat_rules[$vat_rule]) ? $vat_rules[$vat_rule] : $vat_rule;
1371 1371
         
1372
-        return apply_filters( 'wpinv_item_rule_label', $vat_rule, $postID );
1372
+        return apply_filters('wpinv_item_rule_label', $vat_rule, $postID);
1373 1373
     }
1374 1374
     
1375
-    public static function item_has_digital_rule( $item_id = 0 ) {        
1376
-        return self::get_item_rule( $item_id ) == 'digital' ? true : false;
1375
+    public static function item_has_digital_rule($item_id = 0) {        
1376
+        return self::get_item_rule($item_id) == 'digital' ? true : false;
1377 1377
     }
1378 1378
     
1379
-    public static function invoice_has_digital_rule( $invoice = 0 ) {        
1380
-        if ( !self::allow_vat_rules() ) {
1379
+    public static function invoice_has_digital_rule($invoice = 0) {        
1380
+        if (!self::allow_vat_rules()) {
1381 1381
             return false;
1382 1382
         }
1383 1383
         
1384
-        if ( empty( $invoice ) ) {
1384
+        if (empty($invoice)) {
1385 1385
             return true;
1386 1386
         }
1387 1387
         
1388
-        if ( is_int( $invoice ) ) {
1389
-            $invoice = new WPInv_Invoice( $invoice );
1388
+        if (is_int($invoice)) {
1389
+            $invoice = new WPInv_Invoice($invoice);
1390 1390
         }
1391 1391
         
1392
-        if ( !( is_object( $invoice ) && is_a( $invoice, 'WPInv_Invoice' ) ) ) {
1392
+        if (!(is_object($invoice) && is_a($invoice, 'WPInv_Invoice'))) {
1393 1393
             return true;
1394 1394
         }
1395 1395
         
1396
-        $cart_items  = $invoice->get_cart_details();
1396
+        $cart_items = $invoice->get_cart_details();
1397 1397
         
1398
-        if ( !empty( $cart_items ) ) {
1398
+        if (!empty($cart_items)) {
1399 1399
             $has_digital_rule = false;
1400 1400
             
1401
-            foreach ( $cart_items as $key => $item ) {
1402
-                if ( self::item_has_digital_rule( $item['id'] ) ) {
1401
+            foreach ($cart_items as $key => $item) {
1402
+                if (self::item_has_digital_rule($item['id'])) {
1403 1403
                     $has_digital_rule = true;
1404 1404
                     break;
1405 1405
                 }
@@ -1411,67 +1411,67 @@  discard block
 block discarded – undo
1411 1411
         return $has_digital_rule;
1412 1412
     }
1413 1413
     
1414
-    public static function item_is_taxable( $item_id = 0, $country = false, $state = false ) {        
1415
-        if ( !wpinv_use_taxes() ) {
1414
+    public static function item_is_taxable($item_id = 0, $country = false, $state = false) {        
1415
+        if (!wpinv_use_taxes()) {
1416 1416
             return false;
1417 1417
         }
1418 1418
         
1419 1419
         $is_taxable = true;
1420 1420
 
1421
-        if ( !empty( $item_id ) && self::get_item_class( $item_id ) == '_exempt' ) {
1421
+        if (!empty($item_id) && self::get_item_class($item_id) == '_exempt') {
1422 1422
             $is_taxable = false;
1423 1423
         }
1424 1424
         
1425
-        return apply_filters( 'wpinv_item_is_taxable', $is_taxable, $item_id, $country , $state );
1425
+        return apply_filters('wpinv_item_is_taxable', $is_taxable, $item_id, $country, $state);
1426 1426
     }
1427 1427
     
1428
-    public static function find_rate( $country, $state, $rate, $class ) {
1428
+    public static function find_rate($country, $state, $rate, $class) {
1429 1429
         global $wpi_zero_tax;
1430 1430
 
1431
-        if ( $class === '_exempt' || $wpi_zero_tax ) {
1431
+        if ($class === '_exempt' || $wpi_zero_tax) {
1432 1432
             return 0;
1433 1433
         }
1434 1434
 
1435
-        $tax_rates   = wpinv_get_tax_rates();
1435
+        $tax_rates = wpinv_get_tax_rates();
1436 1436
         
1437
-        if ( $class !== '_standard' ) {
1438
-            $class_rates = self::get_vat_rates( $class );
1437
+        if ($class !== '_standard') {
1438
+            $class_rates = self::get_vat_rates($class);
1439 1439
             
1440
-            if ( is_array( $class_rates ) ) {
1440
+            if (is_array($class_rates)) {
1441 1441
                 $indexed_class_rates = array();
1442 1442
                 
1443
-                foreach ( $class_rates as $key => $cr ) {
1443
+                foreach ($class_rates as $key => $cr) {
1444 1444
                     $indexed_class_rates[$cr['country']] = $cr;
1445 1445
                 }
1446 1446
 
1447
-                $tax_rates = array_map( function( $tr ) use( $indexed_class_rates ) {
1447
+                $tax_rates = array_map(function($tr) use($indexed_class_rates) {
1448 1448
                     $tr_country = $tr['country'];
1449
-                    if ( !isset( $indexed_class_rates[$tr_country] ) ) {
1449
+                    if (!isset($indexed_class_rates[$tr_country])) {
1450 1450
                         return $tr;
1451 1451
                     }
1452 1452
                     $icr = $indexed_class_rates[$tr_country];
1453
-                    return ( empty( $icr['rate'] ) && $icr['rate'] !== '0' ) ? $tr : $icr;
1453
+                    return (empty($icr['rate']) && $icr['rate'] !== '0') ? $tr : $icr;
1454 1454
 
1455
-                }, $tax_rates, $class_rates );
1455
+                }, $tax_rates, $class_rates);
1456 1456
             }
1457 1457
         }
1458 1458
 
1459
-        if ( !empty( $tax_rates ) ) {
1460
-            foreach ( $tax_rates as $key => $tax_rate ) {
1461
-                if ( $country != $tax_rate['country'] )
1459
+        if (!empty($tax_rates)) {
1460
+            foreach ($tax_rates as $key => $tax_rate) {
1461
+                if ($country != $tax_rate['country'])
1462 1462
                     continue;
1463 1463
 
1464
-                if ( !empty( $tax_rate['global'] ) ) {
1465
-                    if ( 0 !== $tax_rate['rate'] || !empty( $tax_rate['rate'] ) ) {
1466
-                        $rate = number_format( $tax_rate['rate'], 4 );
1464
+                if (!empty($tax_rate['global'])) {
1465
+                    if (0 !== $tax_rate['rate'] || !empty($tax_rate['rate'])) {
1466
+                        $rate = number_format($tax_rate['rate'], 4);
1467 1467
                     }
1468 1468
                 } else {
1469
-                    if ( empty( $tax_rate['state'] ) || strtolower( $state ) != strtolower( $tax_rate['state'] ) )
1469
+                    if (empty($tax_rate['state']) || strtolower($state) != strtolower($tax_rate['state']))
1470 1470
                         continue;
1471 1471
 
1472 1472
                     $state_rate = $tax_rate['rate'];
1473
-                    if ( 0 !== $state_rate || !empty( $state_rate ) ) {
1474
-                        $rate = number_format( $state_rate, 4 );
1473
+                    if (0 !== $state_rate || !empty($state_rate)) {
1474
+                        $rate = number_format($state_rate, 4);
1475 1475
                     }
1476 1476
                 }
1477 1477
             }
@@ -1480,84 +1480,84 @@  discard block
 block discarded – undo
1480 1480
         return $rate;
1481 1481
     }
1482 1482
     
1483
-    public static function get_rate( $rate = 1, $country = '', $state = '', $item_id = 0 ) {
1483
+    public static function get_rate($rate = 1, $country = '', $state = '', $item_id = 0) {
1484 1484
         global $wpinv_options, $wpi_session, $wpi_item_id, $wpi_zero_tax;
1485 1485
         
1486 1486
         $item_id = $item_id > 0 ? $item_id : $wpi_item_id;
1487 1487
         $allow_vat_classes = self::allow_vat_classes();
1488
-        $class = $item_id ? self::get_item_class( $item_id ) : '_standard';
1488
+        $class = $item_id ? self::get_item_class($item_id) : '_standard';
1489 1489
 
1490
-        if ( $class === '_exempt' || $wpi_zero_tax ) {
1490
+        if ($class === '_exempt' || $wpi_zero_tax) {
1491 1491
             return 0;
1492
-        } else if ( !$allow_vat_classes ) {
1492
+        } else if (!$allow_vat_classes) {
1493 1493
             $class = '_standard';
1494 1494
         }
1495 1495
 
1496
-        if( !empty( $_POST['wpinv_country'] ) ) {
1496
+        if (!empty($_POST['wpinv_country'])) {
1497 1497
             $post_country = $_POST['wpinv_country'];
1498
-        } elseif( !empty( $_POST['wpinv_country'] ) ) {
1498
+        } elseif (!empty($_POST['wpinv_country'])) {
1499 1499
             $post_country = $_POST['wpinv_country'];
1500
-        } elseif( !empty( $_POST['country'] ) ) {
1500
+        } elseif (!empty($_POST['country'])) {
1501 1501
             $post_country = $_POST['country'];
1502 1502
         } else {
1503 1503
             $post_country = '';
1504 1504
         }
1505 1505
 
1506
-        $country        = !empty( $post_country ) ? $post_country : wpinv_default_billing_country( $country );
1507
-        $base_country   = wpinv_is_base_country( $country );
1506
+        $country        = !empty($post_country) ? $post_country : wpinv_default_billing_country($country);
1507
+        $base_country   = wpinv_is_base_country($country);
1508 1508
         
1509
-        $requires_vat   = self::requires_vat( 0, false );
1510
-        $is_digital     = self::get_item_rule( $item_id ) == 'digital' ;
1511
-        $rate           = $requires_vat && isset( $wpinv_options['eu_fallback_rate'] ) ? $wpinv_options['eu_fallback_rate'] : $rate;
1509
+        $requires_vat   = self::requires_vat(0, false);
1510
+        $is_digital     = self::get_item_rule($item_id) == 'digital';
1511
+        $rate           = $requires_vat && isset($wpinv_options['eu_fallback_rate']) ? $wpinv_options['eu_fallback_rate'] : $rate;
1512 1512
           
1513
-        if ( self::same_country_rule() == 'no' && $base_country ) { // Disable VAT to same country
1513
+        if (self::same_country_rule() == 'no' && $base_country) { // Disable VAT to same country
1514 1514
             $rate = 0;
1515
-        } else if ( $requires_vat ) {
1516
-            $vat_number = self::get_user_vat_number( '', 0, true );
1515
+        } else if ($requires_vat) {
1516
+            $vat_number = self::get_user_vat_number('', 0, true);
1517 1517
             $vat_info   = self::current_vat_data();
1518 1518
             
1519
-            if ( is_array( $vat_info ) ) {
1520
-                $vat_number = isset( $vat_info['number'] ) && !empty( $vat_info['valid'] ) ? $vat_info['number'] : "";
1519
+            if (is_array($vat_info)) {
1520
+                $vat_number = isset($vat_info['number']) && !empty($vat_info['valid']) ? $vat_info['number'] : "";
1521 1521
             }
1522 1522
             
1523
-            if ( $country == 'UK' ) {
1523
+            if ($country == 'UK') {
1524 1524
                 $country = 'GB';
1525 1525
             }
1526 1526
 
1527
-            if ( !empty( $vat_number ) ) {
1527
+            if (!empty($vat_number)) {
1528 1528
                 $rate = 0;
1529 1529
             } else {
1530
-                $rate = self::find_rate( $country, $state, $rate, $class ); // Fix if there are no tax rated and you try to pay an invoice it does not add the fallback tax rate
1530
+                $rate = self::find_rate($country, $state, $rate, $class); // Fix if there are no tax rated and you try to pay an invoice it does not add the fallback tax rate
1531 1531
             }
1532 1532
 
1533
-            if ( empty( $vat_number ) && !$is_digital ) {
1534
-                if ( $base_country ) {
1535
-                    $rate = self::find_rate( $country, null, $rate, $class );
1533
+            if (empty($vat_number) && !$is_digital) {
1534
+                if ($base_country) {
1535
+                    $rate = self::find_rate($country, null, $rate, $class);
1536 1536
                 } else {
1537
-                    if ( empty( $country ) && isset( $wpinv_options['eu_fallback_rate'] ) ) {
1537
+                    if (empty($country) && isset($wpinv_options['eu_fallback_rate'])) {
1538 1538
                         $rate = $wpinv_options['eu_fallback_rate'];
1539
-                    } else if( !empty( $country ) ) {
1540
-                        $rate = self::find_rate( $country, $state, $rate, $class );
1539
+                    } else if (!empty($country)) {
1540
+                        $rate = self::find_rate($country, $state, $rate, $class);
1541 1541
                     }
1542 1542
                 }
1543
-            } else if ( empty( $vat_number ) || ( self::same_country_rule() == 'always' && $base_country ) ) {
1544
-                if ( empty( $country ) && isset( $wpinv_options['eu_fallback_rate'] ) ) {
1543
+            } else if (empty($vat_number) || (self::same_country_rule() == 'always' && $base_country)) {
1544
+                if (empty($country) && isset($wpinv_options['eu_fallback_rate'])) {
1545 1545
                     $rate = $wpinv_options['eu_fallback_rate'];
1546
-                } else if( !empty( $country ) ) {
1547
-                    $rate = self::find_rate( $country, $state, $rate, $class );
1546
+                } else if (!empty($country)) {
1547
+                    $rate = self::find_rate($country, $state, $rate, $class);
1548 1548
                 }
1549 1549
             }
1550 1550
         } else {
1551
-            if ( $is_digital ) {
1551
+            if ($is_digital) {
1552 1552
                 $ip_country_code = self::get_country_by_ip();
1553 1553
                 
1554
-                if ( $ip_country_code && self::is_eu_state( $ip_country_code ) ) {
1555
-                    $rate = self::find_rate( $ip_country_code, '', 0, $class );
1554
+                if ($ip_country_code && self::is_eu_state($ip_country_code)) {
1555
+                    $rate = self::find_rate($ip_country_code, '', 0, $class);
1556 1556
                 } else {
1557
-                    $rate = self::find_rate( $country, $state, $rate, $class );
1557
+                    $rate = self::find_rate($country, $state, $rate, $class);
1558 1558
                 }
1559 1559
             } else {
1560
-                $rate = self::find_rate( $country, $state, $rate, $class );
1560
+                $rate = self::find_rate($country, $state, $rate, $class);
1561 1561
             }
1562 1562
         }
1563 1563
 
@@ -1567,48 +1567,48 @@  discard block
 block discarded – undo
1567 1567
     public static function current_vat_data() {
1568 1568
         global $wpi_session;
1569 1569
         
1570
-        return $wpi_session->get( 'user_vat_data' );
1570
+        return $wpi_session->get('user_vat_data');
1571 1571
     }
1572 1572
     
1573
-    public static function get_user_country( $country = '', $user_id = 0 ) {
1574
-        $user_address = wpinv_get_user_address( $user_id, false );
1573
+    public static function get_user_country($country = '', $user_id = 0) {
1574
+        $user_address = wpinv_get_user_address($user_id, false);
1575 1575
         
1576
-        if ( wpinv_get_option( 'vat_ip_country_default' ) ) {
1576
+        if (wpinv_get_option('vat_ip_country_default')) {
1577 1577
             $country = '';
1578 1578
         }
1579 1579
         
1580
-        $country    = empty( $user_address ) || !isset( $user_address['country'] ) || empty( $user_address['country'] ) ? $country : $user_address['country'];
1581
-        $result     = apply_filters( 'wpinv_get_user_country', $country, $user_id );
1580
+        $country    = empty($user_address) || !isset($user_address['country']) || empty($user_address['country']) ? $country : $user_address['country'];
1581
+        $result     = apply_filters('wpinv_get_user_country', $country, $user_id);
1582 1582
 
1583
-        if ( empty( $result ) ) {
1583
+        if (empty($result)) {
1584 1584
             $result = self::get_country_by_ip();
1585 1585
         }
1586 1586
 
1587 1587
         return $result;
1588 1588
     }
1589 1589
     
1590
-    public static function set_user_country( $country = '', $user_id = 0 ) {
1590
+    public static function set_user_country($country = '', $user_id = 0) {
1591 1591
         global $wpi_userID;
1592 1592
         
1593
-        if ( empty($country) && !empty($wpi_userID) && get_current_user_id() != $wpi_userID ) {
1593
+        if (empty($country) && !empty($wpi_userID) && get_current_user_id() != $wpi_userID) {
1594 1594
             $country = wpinv_get_default_country();
1595 1595
         }
1596 1596
         
1597 1597
         return $country;
1598 1598
     }
1599 1599
     
1600
-    public static function get_user_vat_number( $vat_number = '', $user_id = 0, $is_valid = false ) {
1600
+    public static function get_user_vat_number($vat_number = '', $user_id = 0, $is_valid = false) {
1601 1601
         global $wpi_current_id, $wpi_userID;
1602 1602
         
1603
-        if ( !empty( $_POST['new_user'] ) ) {
1603
+        if (!empty($_POST['new_user'])) {
1604 1604
             return '';
1605 1605
         }
1606 1606
         
1607
-        if ( empty( $user_id ) ) {
1608
-            $user_id = !empty( $wpi_userID ) ? $wpi_userID : ( $wpi_current_id ? wpinv_get_user_id( $wpi_current_id ) : get_current_user_id() );
1607
+        if (empty($user_id)) {
1608
+            $user_id = !empty($wpi_userID) ? $wpi_userID : ($wpi_current_id ? wpinv_get_user_id($wpi_current_id) : get_current_user_id());
1609 1609
         }
1610 1610
 
1611
-        $vat_number = empty( $user_id ) ? '' : get_user_meta( $user_id, '_wpinv_vat_number', true );
1611
+        $vat_number = empty($user_id) ? '' : get_user_meta($user_id, '_wpinv_vat_number', true);
1612 1612
         
1613 1613
         /* TODO
1614 1614
         if ( $is_valid && $vat_number ) {
@@ -1619,38 +1619,38 @@  discard block
 block discarded – undo
1619 1619
         }
1620 1620
         */
1621 1621
 
1622
-        return apply_filters('wpinv_get_user_vat_number', $vat_number, $user_id, $is_valid );
1622
+        return apply_filters('wpinv_get_user_vat_number', $vat_number, $user_id, $is_valid);
1623 1623
     }
1624 1624
     
1625
-    public static function get_user_company( $company = '', $user_id = 0 ) {
1625
+    public static function get_user_company($company = '', $user_id = 0) {
1626 1626
         global $wpi_current_id, $wpi_userID;
1627 1627
         
1628
-        if ( empty( $user_id ) ) {
1629
-            $user_id = !empty( $wpi_userID ) ? $wpi_userID : ( $wpi_current_id ? wpinv_get_user_id( $wpi_current_id ) : get_current_user_id() );
1628
+        if (empty($user_id)) {
1629
+            $user_id = !empty($wpi_userID) ? $wpi_userID : ($wpi_current_id ? wpinv_get_user_id($wpi_current_id) : get_current_user_id());
1630 1630
         }
1631 1631
 
1632
-        $company = empty( $user_id ) ? "" : get_user_meta( $user_id, '_wpinv_company', true );
1632
+        $company = empty($user_id) ? "" : get_user_meta($user_id, '_wpinv_company', true);
1633 1633
 
1634
-        return apply_filters( 'wpinv_user_company', $company, $user_id );
1634
+        return apply_filters('wpinv_user_company', $company, $user_id);
1635 1635
     }
1636 1636
     
1637
-    public static function save_user_vat_details( $company = '', $vat_number = '' ) {
1638
-        $save = apply_filters( 'wpinv_allow_save_user_vat_details', true );
1637
+    public static function save_user_vat_details($company = '', $vat_number = '') {
1638
+        $save = apply_filters('wpinv_allow_save_user_vat_details', true);
1639 1639
 
1640
-        if ( is_user_logged_in() && $save ) {
1640
+        if (is_user_logged_in() && $save) {
1641 1641
             $user_id = get_current_user_id();
1642 1642
 
1643
-            if ( !empty( $vat_number ) ) {
1644
-                update_user_meta( $user_id, '_wpinv_vat_number', $vat_number );
1643
+            if (!empty($vat_number)) {
1644
+                update_user_meta($user_id, '_wpinv_vat_number', $vat_number);
1645 1645
             } else {
1646
-                delete_user_meta( $user_id, '_wpinv_vat_number');
1646
+                delete_user_meta($user_id, '_wpinv_vat_number');
1647 1647
             }
1648 1648
 
1649
-            if ( !empty( $company ) ) {
1650
-                update_user_meta( $user_id, '_wpinv_company', $company );
1649
+            if (!empty($company)) {
1650
+                update_user_meta($user_id, '_wpinv_company', $company);
1651 1651
             } else {
1652
-                delete_user_meta( $user_id, '_wpinv_company');
1653
-                delete_user_meta( $user_id, '_wpinv_vat_number');
1652
+                delete_user_meta($user_id, '_wpinv_company');
1653
+                delete_user_meta($user_id, '_wpinv_vat_number');
1654 1654
             }
1655 1655
         }
1656 1656
 
@@ -1660,113 +1660,113 @@  discard block
 block discarded – undo
1660 1660
     public static function ajax_vat_validate() {
1661 1661
         global $wpinv_options, $wpi_session;
1662 1662
         
1663
-        $is_checkout            = ( !empty( $_POST['source'] ) && $_POST['source'] == 'checkout' ) ? true : false;
1663
+        $is_checkout            = (!empty($_POST['source']) && $_POST['source'] == 'checkout') ? true : false;
1664 1664
         $response               = array();
1665 1665
         $response['success']    = false;
1666 1666
         
1667
-        if ( empty( $_REQUEST['_wpi_nonce'] ) || ( !empty( $_REQUEST['_wpi_nonce'] ) && !wp_verify_nonce( $_REQUEST['_wpi_nonce'], 'vat_validation' ) ) ) {
1668
-            $response['error'] = __( 'Invalid security nonce', 'invoicing' );
1669
-            wp_send_json( $response );
1667
+        if (empty($_REQUEST['_wpi_nonce']) || (!empty($_REQUEST['_wpi_nonce']) && !wp_verify_nonce($_REQUEST['_wpi_nonce'], 'vat_validation'))) {
1668
+            $response['error'] = __('Invalid security nonce', 'invoicing');
1669
+            wp_send_json($response);
1670 1670
         }
1671 1671
         
1672
-        $vat_name   = self::get_vat_name();
1672
+        $vat_name = self::get_vat_name();
1673 1673
         
1674
-        if ( $is_checkout ) {
1674
+        if ($is_checkout) {
1675 1675
             $invoice = wpinv_get_invoice_cart();
1676 1676
             
1677
-            if ( !self::requires_vat( false, 0, self::invoice_has_digital_rule( $invoice ) ) ) {
1677
+            if (!self::requires_vat(false, 0, self::invoice_has_digital_rule($invoice))) {
1678 1678
                 $vat_info = array();
1679
-                $wpi_session->set( 'user_vat_data', $vat_info );
1679
+                $wpi_session->set('user_vat_data', $vat_info);
1680 1680
 
1681 1681
                 self::save_user_vat_details();
1682 1682
                 
1683 1683
                 $response['success'] = true;
1684
-                $response['message'] = wp_sprintf( __( 'Ignore %s', 'invoicing' ), $vat_name );
1685
-                wp_send_json( $response );
1684
+                $response['message'] = wp_sprintf(__('Ignore %s', 'invoicing'), $vat_name);
1685
+                wp_send_json($response);
1686 1686
             }
1687 1687
         }
1688 1688
         
1689
-        $company    = !empty( $_POST['company'] ) ? sanitize_text_field( $_POST['company'] ) : '';
1690
-        $vat_number = !empty( $_POST['number'] ) ? sanitize_text_field( $_POST['number'] ) : '';
1689
+        $company    = !empty($_POST['company']) ? sanitize_text_field($_POST['company']) : '';
1690
+        $vat_number = !empty($_POST['number']) ? sanitize_text_field($_POST['number']) : '';
1691 1691
         
1692
-        $vat_info = $wpi_session->get( 'user_vat_data' );
1693
-        if ( !is_array( $vat_info ) || empty( $vat_info ) ) {
1694
-            $vat_info = array( 'company'=> $company, 'number' => '', 'valid' => true );
1692
+        $vat_info = $wpi_session->get('user_vat_data');
1693
+        if (!is_array($vat_info) || empty($vat_info)) {
1694
+            $vat_info = array('company'=> $company, 'number' => '', 'valid' => true);
1695 1695
         }
1696 1696
         
1697
-        if ( empty( $vat_number ) ) {
1698
-            if ( $is_checkout ) {
1697
+        if (empty($vat_number)) {
1698
+            if ($is_checkout) {
1699 1699
                 $response['success'] = true;
1700
-                $response['message'] = wp_sprintf( __( 'No %s number has been applied. %s will be added to invoice totals', 'invoicing' ), $vat_name, $vat_name );
1700
+                $response['message'] = wp_sprintf(__('No %s number has been applied. %s will be added to invoice totals', 'invoicing'), $vat_name, $vat_name);
1701 1701
                 
1702
-                $vat_info = $wpi_session->get( 'user_vat_data' );
1702
+                $vat_info = $wpi_session->get('user_vat_data');
1703 1703
                 $vat_info['number'] = "";
1704 1704
                 $vat_info['valid'] = true;
1705 1705
                 
1706
-                self::save_user_vat_details( $company );
1706
+                self::save_user_vat_details($company);
1707 1707
             } else {
1708
-                $response['error'] = wp_sprintf( __( 'Please enter your %s number!', 'invoicing' ), $vat_name );
1708
+                $response['error'] = wp_sprintf(__('Please enter your %s number!', 'invoicing'), $vat_name);
1709 1709
                 
1710 1710
                 $vat_info['valid'] = false;
1711 1711
             }
1712 1712
 
1713
-            $wpi_session->set( 'user_vat_data', $vat_info );
1714
-            wp_send_json( $response );
1713
+            $wpi_session->set('user_vat_data', $vat_info);
1714
+            wp_send_json($response);
1715 1715
         }
1716 1716
         
1717
-        if ( empty( $company ) ) {
1717
+        if (empty($company)) {
1718 1718
             $vat_info['valid'] = false;
1719
-            $wpi_session->set( 'user_vat_data', $vat_info );
1719
+            $wpi_session->set('user_vat_data', $vat_info);
1720 1720
             
1721
-            $response['error'] = __( 'Please enter your registered company name!', 'invoicing' );
1722
-            wp_send_json( $response );
1721
+            $response['error'] = __('Please enter your registered company name!', 'invoicing');
1722
+            wp_send_json($response);
1723 1723
         }
1724 1724
         
1725
-        if ( !empty( $wpinv_options['vat_vies_check'] ) ) {
1726
-            if ( empty( $wpinv_options['vat_offline_check'] ) && !self::offline_check( $vat_number ) ) {
1725
+        if (!empty($wpinv_options['vat_vies_check'])) {
1726
+            if (empty($wpinv_options['vat_offline_check']) && !self::offline_check($vat_number)) {
1727 1727
                 $vat_info['valid'] = false;
1728
-                $wpi_session->set( 'user_vat_data', $vat_info );
1728
+                $wpi_session->set('user_vat_data', $vat_info);
1729 1729
                 
1730
-                $response['error'] = wp_sprintf( __( '%s number not validated', 'invoicing' ), $vat_name );
1731
-                wp_send_json( $response );
1730
+                $response['error'] = wp_sprintf(__('%s number not validated', 'invoicing'), $vat_name);
1731
+                wp_send_json($response);
1732 1732
             }
1733 1733
             
1734 1734
             $response['success'] = true;
1735
-            $response['message'] = wp_sprintf( __( '%s number validated', 'invoicing' ), $vat_name );
1735
+            $response['message'] = wp_sprintf(__('%s number validated', 'invoicing'), $vat_name);
1736 1736
         } else {
1737
-            $result = self::check_vat( $vat_number );
1737
+            $result = self::check_vat($vat_number);
1738 1738
             
1739
-            if ( empty( $result['valid'] ) ) {
1739
+            if (empty($result['valid'])) {
1740 1740
                 $response['error'] = $result['message'];
1741
-                wp_send_json( $response );
1741
+                wp_send_json($response);
1742 1742
             }
1743 1743
             
1744
-            $vies_company = !empty( $result['company'] ) ? $result['company'] : '';
1745
-            $vies_company = apply_filters( 'wpinv_vies_company_name', $vies_company );
1744
+            $vies_company = !empty($result['company']) ? $result['company'] : '';
1745
+            $vies_company = apply_filters('wpinv_vies_company_name', $vies_company);
1746 1746
             
1747
-            $valid_company = $vies_company && $company && ( $vies_company == '---' || strcasecmp( trim( $vies_company ), trim( $company ) ) == 0 ) ? true : false;
1747
+            $valid_company = $vies_company && $company && ($vies_company == '---' || strcasecmp(trim($vies_company), trim($company)) == 0) ? true : false;
1748 1748
 
1749
-            if ( !empty( $wpinv_options['vat_disable_company_name_check'] ) || $valid_company ) {
1749
+            if (!empty($wpinv_options['vat_disable_company_name_check']) || $valid_company) {
1750 1750
                 $response['success'] = true;
1751
-                $response['message'] = wp_sprintf( __( '%s number validated', 'invoicing' ), $vat_name );
1751
+                $response['message'] = wp_sprintf(__('%s number validated', 'invoicing'), $vat_name);
1752 1752
             } else {           
1753 1753
                 $vat_info['valid'] = false;
1754
-                $wpi_session->set( 'user_vat_data', $vat_info );
1754
+                $wpi_session->set('user_vat_data', $vat_info);
1755 1755
                 
1756 1756
                 $response['success'] = false;
1757
-                $response['message'] = wp_sprintf( __( 'The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing' ), $vat_name );
1758
-                wp_send_json( $response );
1757
+                $response['message'] = wp_sprintf(__('The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing'), $vat_name);
1758
+                wp_send_json($response);
1759 1759
             }
1760 1760
         }
1761 1761
         
1762
-        if ( $is_checkout ) {
1763
-            self::save_user_vat_details( $company, $vat_number );
1762
+        if ($is_checkout) {
1763
+            self::save_user_vat_details($company, $vat_number);
1764 1764
 
1765
-            $vat_info = array('company' => $company, 'number' => $vat_number, 'valid' => true );
1766
-            $wpi_session->set( 'user_vat_data', $vat_info );
1765
+            $vat_info = array('company' => $company, 'number' => $vat_number, 'valid' => true);
1766
+            $wpi_session->set('user_vat_data', $vat_info);
1767 1767
         }
1768 1768
 
1769
-        wp_send_json( $response );
1769
+        wp_send_json($response);
1770 1770
     }
1771 1771
     
1772 1772
     public static function ajax_vat_reset() {
@@ -1775,161 +1775,161 @@  discard block
 block discarded – undo
1775 1775
         $company    = is_user_logged_in() ? self::get_user_company() : '';
1776 1776
         $vat_number = self::get_user_vat_number();
1777 1777
         
1778
-        $vat_info   = array('company' => $company, 'number' => $vat_number, 'valid' => false );
1779
-        $wpi_session->set( 'user_vat_data', $vat_info );
1778
+        $vat_info   = array('company' => $company, 'number' => $vat_number, 'valid' => false);
1779
+        $wpi_session->set('user_vat_data', $vat_info);
1780 1780
         
1781 1781
         $response                       = array();
1782 1782
         $response['success']            = true;
1783 1783
         $response['data']['company']    = $company;
1784 1784
         $response['data']['number']     = $vat_number;
1785 1785
         
1786
-        wp_send_json( $response );
1786
+        wp_send_json($response);
1787 1787
     }
1788 1788
     
1789
-    public static function checkout_vat_validate( $valid_data, $post ) {
1789
+    public static function checkout_vat_validate($valid_data, $post) {
1790 1790
         global $wpinv_options, $wpi_session;
1791 1791
         
1792
-        $vat_name  = __( self::get_vat_name(), 'invoicing' );
1792
+        $vat_name = __(self::get_vat_name(), 'invoicing');
1793 1793
         
1794
-        if ( !isset( $_POST['_wpi_nonce'] ) || !wp_verify_nonce( $_POST['_wpi_nonce'], 'vat_validation' ) ) {
1795
-            wpinv_set_error( 'vat_validation', wp_sprintf( __( "Invalid %s validation request.", 'invoicing' ), $vat_name ) );
1794
+        if (!isset($_POST['_wpi_nonce']) || !wp_verify_nonce($_POST['_wpi_nonce'], 'vat_validation')) {
1795
+            wpinv_set_error('vat_validation', wp_sprintf(__("Invalid %s validation request.", 'invoicing'), $vat_name));
1796 1796
             return;
1797 1797
         }
1798 1798
         
1799
-        $vat_saved = $wpi_session->get( 'user_vat_data' );
1800
-        $wpi_session->set( 'user_vat_data', null );
1799
+        $vat_saved = $wpi_session->get('user_vat_data');
1800
+        $wpi_session->set('user_vat_data', null);
1801 1801
         
1802 1802
         $invoice        = wpinv_get_invoice_cart();
1803 1803
         $amount         = $invoice->get_total();
1804
-        $is_digital     = self::invoice_has_digital_rule( $invoice );
1805
-        $no_vat         = !self::requires_vat( 0, false, $is_digital );
1804
+        $is_digital     = self::invoice_has_digital_rule($invoice);
1805
+        $no_vat         = !self::requires_vat(0, false, $is_digital);
1806 1806
         
1807
-        $company        = !empty( $_POST['wpinv_company'] ) ? $_POST['wpinv_company'] : null;
1808
-        $vat_number     = !empty( $_POST['wpinv_vat_number'] ) ? $_POST['wpinv_vat_number'] : null;
1809
-        $country        = !empty( $_POST['wpinv_country'] ) ? $_POST['wpinv_country'] : $invoice->country;
1810
-        if ( empty( $country ) ) {
1807
+        $company        = !empty($_POST['wpinv_company']) ? $_POST['wpinv_company'] : null;
1808
+        $vat_number     = !empty($_POST['wpinv_vat_number']) ? $_POST['wpinv_vat_number'] : null;
1809
+        $country        = !empty($_POST['wpinv_country']) ? $_POST['wpinv_country'] : $invoice->country;
1810
+        if (empty($country)) {
1811 1811
             $country = wpinv_default_billing_country();
1812 1812
         }
1813 1813
         
1814
-        if ( !$is_digital && $no_vat ) {
1814
+        if (!$is_digital && $no_vat) {
1815 1815
             return;
1816 1816
         }
1817 1817
             
1818
-        $vat_data           = array( 'company' => '', 'number' => '', 'valid' => false );
1818
+        $vat_data           = array('company' => '', 'number' => '', 'valid' => false);
1819 1819
         
1820 1820
         $ip_country_code    = self::get_country_by_ip();
1821
-        $is_eu_state        = self::is_eu_state( $country );
1822
-        $is_eu_state_ip     = self::is_eu_state( $ip_country_code );
1821
+        $is_eu_state        = self::is_eu_state($country);
1822
+        $is_eu_state_ip     = self::is_eu_state($ip_country_code);
1823 1823
         $is_non_eu_user     = !$is_eu_state && !$is_eu_state_ip;
1824 1824
         
1825
-        if ( $is_digital && !$is_non_eu_user && empty( $vat_number ) && apply_filters( 'wpinv_checkout_requires_country', true, $amount ) ) {
1825
+        if ($is_digital && !$is_non_eu_user && empty($vat_number) && apply_filters('wpinv_checkout_requires_country', true, $amount)) {
1826 1826
             $vat_data['adddress_confirmed'] = false;
1827 1827
             
1828
-            if ( !isset( $_POST['wpinv_adddress_confirmed'] ) ) {
1829
-                if ( $ip_country_code != $country ) {
1830
-                    wpinv_set_error( 'vat_validation', sprintf( __( 'The country of your current location must be the same as the country of your billing location or you must %s confirm %s the billing address is your home country.', 'invoicing' ), '<a href="#wpinv_adddress_confirm">', '</a>' ) );
1828
+            if (!isset($_POST['wpinv_adddress_confirmed'])) {
1829
+                if ($ip_country_code != $country) {
1830
+                    wpinv_set_error('vat_validation', sprintf(__('The country of your current location must be the same as the country of your billing location or you must %s confirm %s the billing address is your home country.', 'invoicing'), '<a href="#wpinv_adddress_confirm">', '</a>'));
1831 1831
                 }
1832 1832
             } else {
1833 1833
                 $vat_data['adddress_confirmed'] = true;
1834 1834
             }
1835 1835
         }
1836 1836
         
1837
-        if ( !empty( $wpinv_options['vat_prevent_b2c_purchase'] ) && !$is_non_eu_user && ( empty( $vat_number ) || $no_vat ) ) {
1838
-            if ( $is_eu_state ) {
1839
-                wpinv_set_error( 'vat_validation', wp_sprintf( __( 'Please enter and validate your %s number to verify your purchase is by an EU business.', 'invoicing' ), $vat_name ) );
1840
-            } else if ( $is_digital && $is_eu_state_ip ) {
1841
-                wpinv_set_error( 'vat_validation', wp_sprintf( __( 'Sales to non-EU countries cannot be completed because %s must be applied.', 'invoicing' ), $vat_name ) );
1837
+        if (!empty($wpinv_options['vat_prevent_b2c_purchase']) && !$is_non_eu_user && (empty($vat_number) || $no_vat)) {
1838
+            if ($is_eu_state) {
1839
+                wpinv_set_error('vat_validation', wp_sprintf(__('Please enter and validate your %s number to verify your purchase is by an EU business.', 'invoicing'), $vat_name));
1840
+            } else if ($is_digital && $is_eu_state_ip) {
1841
+                wpinv_set_error('vat_validation', wp_sprintf(__('Sales to non-EU countries cannot be completed because %s must be applied.', 'invoicing'), $vat_name));
1842 1842
             }
1843 1843
         }
1844 1844
         
1845
-        if ( !$is_eu_state || $no_vat || empty( $vat_number ) ) {
1845
+        if (!$is_eu_state || $no_vat || empty($vat_number)) {
1846 1846
             return;
1847 1847
         }
1848 1848
 
1849
-        if ( !empty( $vat_saved ) && isset( $vat_saved['valid'] ) ) {
1850
-            $vat_data['valid']  = $vat_saved['valid'];
1849
+        if (!empty($vat_saved) && isset($vat_saved['valid'])) {
1850
+            $vat_data['valid'] = $vat_saved['valid'];
1851 1851
         }
1852 1852
             
1853
-        if ( $company !== null ) {
1853
+        if ($company !== null) {
1854 1854
             $vat_data['company'] = $company;
1855 1855
         }
1856 1856
 
1857 1857
         $message = '';
1858
-        if ( $vat_number !== null ) {
1858
+        if ($vat_number !== null) {
1859 1859
             $vat_data['number'] = $vat_number;
1860 1860
             
1861
-            if ( !$vat_data['valid'] || ( $vat_saved['number'] !== $vat_data['number'] ) || ( $vat_saved['company'] !== $vat_data['company'] ) ) {
1862
-                if ( !empty( $wpinv_options['vat_vies_check'] ) ) {            
1863
-                    if ( empty( $wpinv_options['vat_offline_check'] ) && !self::offline_check( $vat_number ) ) {
1861
+            if (!$vat_data['valid'] || ($vat_saved['number'] !== $vat_data['number']) || ($vat_saved['company'] !== $vat_data['company'])) {
1862
+                if (!empty($wpinv_options['vat_vies_check'])) {            
1863
+                    if (empty($wpinv_options['vat_offline_check']) && !self::offline_check($vat_number)) {
1864 1864
                         $vat_data['valid'] = false;
1865 1865
                     }
1866 1866
                 } else {
1867
-                    $result = self::check_vat( $vat_number );
1867
+                    $result = self::check_vat($vat_number);
1868 1868
                     
1869
-                    if ( !empty( $result['valid'] ) ) {                
1869
+                    if (!empty($result['valid'])) {                
1870 1870
                         $vat_data['valid'] = true;
1871
-                        $vies_company = !empty( $result['company'] ) ? $result['company'] : '';
1872
-                        $vies_company = apply_filters( 'wpinv_vies_company_name', $vies_company );
1871
+                        $vies_company = !empty($result['company']) ? $result['company'] : '';
1872
+                        $vies_company = apply_filters('wpinv_vies_company_name', $vies_company);
1873 1873
                     
1874
-                        $valid_company = $vies_company && $company && ( $vies_company == '---' || strcasecmp( trim( $vies_company ), trim( $company ) ) == 0 ) ? true : false;
1874
+                        $valid_company = $vies_company && $company && ($vies_company == '---' || strcasecmp(trim($vies_company), trim($company)) == 0) ? true : false;
1875 1875
 
1876
-                        if ( !( !empty( $wpinv_options['vat_disable_company_name_check'] ) || $valid_company ) ) {         
1876
+                        if (!(!empty($wpinv_options['vat_disable_company_name_check']) || $valid_company)) {         
1877 1877
                             $vat_data['valid'] = false;
1878 1878
                             
1879
-                            $message = wp_sprintf( __( 'The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing' ), $vat_name );
1879
+                            $message = wp_sprintf(__('The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing'), $vat_name);
1880 1880
                         }
1881 1881
                     } else {
1882
-                        $message = wp_sprintf( __( 'Fail to validate the %s number: EU Commission VAT server (VIES) check fails.', 'invoicing' ), $vat_name );
1882
+                        $message = wp_sprintf(__('Fail to validate the %s number: EU Commission VAT server (VIES) check fails.', 'invoicing'), $vat_name);
1883 1883
                     }
1884 1884
                 }
1885 1885
                 
1886
-                if ( !$vat_data['valid'] ) {
1887
-                    $error = wp_sprintf( __( 'The %s %s number %s you have entered has not been validated', 'invoicing' ), '<a href="#wpi-vat-details">', $vat_name, '</a>' ) . ( $message ? ' ( ' . $message . ' )' : '' );
1888
-                    wpinv_set_error( 'vat_validation', $error );
1886
+                if (!$vat_data['valid']) {
1887
+                    $error = wp_sprintf(__('The %s %s number %s you have entered has not been validated', 'invoicing'), '<a href="#wpi-vat-details">', $vat_name, '</a>') . ($message ? ' ( ' . $message . ' )' : '');
1888
+                    wpinv_set_error('vat_validation', $error);
1889 1889
                 }
1890 1890
             }
1891 1891
         }
1892 1892
 
1893
-        $wpi_session->set( 'user_vat_data', $vat_data );
1893
+        $wpi_session->set('user_vat_data', $vat_data);
1894 1894
     }
1895 1895
     
1896
-    public static function checkout_vat_fields( $billing_details ) {
1896
+    public static function checkout_vat_fields($billing_details) {
1897 1897
         global $wpi_session, $wpinv_options, $wpi_country, $wpi_requires_vat;
1898 1898
         
1899 1899
         $ip_address         = wpinv_get_ip();
1900 1900
         $ip_country_code    = self::get_country_by_ip();
1901 1901
         
1902
-        $tax_label          = __( self::get_vat_name(), 'invoicing' );
1902
+        $tax_label          = __(self::get_vat_name(), 'invoicing');
1903 1903
         $invoice            = wpinv_get_invoice_cart();
1904
-        $is_digital         = self::invoice_has_digital_rule( $invoice );
1904
+        $is_digital         = self::invoice_has_digital_rule($invoice);
1905 1905
         $wpi_country        = $invoice->country;
1906 1906
         
1907
-        $requires_vat       = !self::hide_vat_fields() && !$invoice->is_free() && self::requires_vat( 0, false, $is_digital );
1907
+        $requires_vat       = !self::hide_vat_fields() && !$invoice->is_free() && self::requires_vat(0, false, $is_digital);
1908 1908
         $wpi_requires_vat   = $requires_vat;
1909 1909
         
1910 1910
         $company            = self::get_user_company();
1911 1911
         $vat_number         = self::get_user_vat_number();
1912 1912
         
1913
-        $validated          = $vat_number ? self::get_user_vat_number( '', 0, true ) : 1;
1914
-        $vat_info           = $wpi_session->get( 'user_vat_data' );
1913
+        $validated          = $vat_number ? self::get_user_vat_number('', 0, true) : 1;
1914
+        $vat_info           = $wpi_session->get('user_vat_data');
1915 1915
 
1916
-        if ( is_array( $vat_info ) ) {
1917
-            $company    = isset( $vat_info['company'] ) ? $vat_info['company'] : '';
1918
-            $vat_number = isset( $vat_info['number'] ) ? $vat_info['number'] : '';
1919
-            $validated  = isset( $vat_info['valid'] ) ? $vat_info['valid'] : false;
1916
+        if (is_array($vat_info)) {
1917
+            $company    = isset($vat_info['company']) ? $vat_info['company'] : '';
1918
+            $vat_number = isset($vat_info['number']) ? $vat_info['number'] : '';
1919
+            $validated  = isset($vat_info['valid']) ? $vat_info['valid'] : false;
1920 1920
         }
1921 1921
         
1922 1922
         $selected_country = $invoice->country ? $invoice->country : wpinv_default_billing_country();
1923 1923
 
1924
-        if ( $ip_country_code == 'UK' ) {
1924
+        if ($ip_country_code == 'UK') {
1925 1925
             $ip_country_code = 'GB';
1926 1926
         }
1927 1927
         
1928
-        if ( $selected_country == 'UK' ) {
1928
+        if ($selected_country == 'UK') {
1929 1929
             $selected_country = 'GB';
1930 1930
         }
1931 1931
         
1932
-        if ( $requires_vat && ( self::same_country_rule() == 'no' && wpinv_is_base_country( $selected_country ) || !self::allow_vat_rules() ) ) {
1932
+        if ($requires_vat && (self::same_country_rule() == 'no' && wpinv_is_base_country($selected_country) || !self::allow_vat_rules())) {
1933 1933
             $requires_vat = false;
1934 1934
         }
1935 1935
 
@@ -1937,52 +1937,52 @@  discard block
 block discarded – undo
1937 1937
         $display_validate_btn   = 'none';
1938 1938
         $display_reset_btn      = 'none';
1939 1939
         
1940
-        if ( !empty( $vat_number ) && $validated ) {
1941
-            $vat_vailidated_text    = wp_sprintf( __( '%s number validated', 'invoicing' ), $tax_label );
1940
+        if (!empty($vat_number) && $validated) {
1941
+            $vat_vailidated_text    = wp_sprintf(__('%s number validated', 'invoicing'), $tax_label);
1942 1942
             $vat_vailidated_class   = 'wpinv-vat-stat-1';
1943 1943
             $display_reset_btn      = 'block';
1944 1944
         } else {
1945
-            $vat_vailidated_text    = empty( $vat_number ) ? '' : wp_sprintf( __( '%s number not validated', 'invoicing' ), $tax_label );
1946
-            $vat_vailidated_class   = empty( $vat_number ) ? '' : 'wpinv-vat-stat-0';
1945
+            $vat_vailidated_text    = empty($vat_number) ? '' : wp_sprintf(__('%s number not validated', 'invoicing'), $tax_label);
1946
+            $vat_vailidated_class   = empty($vat_number) ? '' : 'wpinv-vat-stat-0';
1947 1947
             $display_validate_btn   = 'block';
1948 1948
         }
1949 1949
         
1950
-        $show_ip_country        = $is_digital && ( empty( $vat_number ) || !$requires_vat ) && $ip_country_code != $selected_country ? 'block' : 'none';
1950
+        $show_ip_country = $is_digital && (empty($vat_number) || !$requires_vat) && $ip_country_code != $selected_country ? 'block' : 'none';
1951 1951
         ?>
1952 1952
         <div id="wpi-vat-details" class="wpi-vat-details clearfix" style="display:<?php echo $display_vat_details; ?>">
1953 1953
             <div id="wpi_vat_info" class="clearfix panel panel-default">
1954
-                <div class="panel-heading"><h3 class="panel-title"><?php echo wp_sprintf( __( '%s Details', 'invoicing' ), $tax_label );?></h3></div>
1954
+                <div class="panel-heading"><h3 class="panel-title"><?php echo wp_sprintf(__('%s Details', 'invoicing'), $tax_label); ?></h3></div>
1955 1955
                 <div id="wpinv-fields-box" class="panel-body">
1956 1956
                     <p id="wpi_show_vat_note">
1957
-                        <?php echo wp_sprintf( __( 'Validate your registered %s number to exclude tax.', 'invoicing' ), $tax_label ); ?>
1957
+                        <?php echo wp_sprintf(__('Validate your registered %s number to exclude tax.', 'invoicing'), $tax_label); ?>
1958 1958
                     </p>
1959 1959
                     <div id="wpi_vat_fields" class="wpi_vat_info">
1960 1960
                         <p class="wpi-cart-field wpi-col2 wpi-colf">
1961
-                            <label for="wpinv_company" class="wpi-label"><?php _e( 'Company Name', 'invoicing' );?></label>
1961
+                            <label for="wpinv_company" class="wpi-label"><?php _e('Company Name', 'invoicing'); ?></label>
1962 1962
                             <?php
1963
-                            echo wpinv_html_text( array(
1963
+                            echo wpinv_html_text(array(
1964 1964
                                     'id'            => 'wpinv_company',
1965 1965
                                     'name'          => 'wpinv_company',
1966 1966
                                     'value'         => $company,
1967 1967
                                     'class'         => 'wpi-input form-control',
1968
-                                    'placeholder'   => __( 'Company name', 'invoicing' ),
1969
-                                ) );
1968
+                                    'placeholder'   => __('Company name', 'invoicing'),
1969
+                                ));
1970 1970
                             ?>
1971 1971
                         </p>
1972 1972
                         <p class="wpi-cart-field wpi-col2 wpi-coll wpi-cart-field-vat">
1973
-                            <label for="wpinv_vat_number" class="wpi-label"><?php echo wp_sprintf( __( '%s Number', 'invoicing' ), $tax_label );?></label>
1973
+                            <label for="wpinv_vat_number" class="wpi-label"><?php echo wp_sprintf(__('%s Number', 'invoicing'), $tax_label); ?></label>
1974 1974
                             <span id="wpinv_vat_number-wrap">
1975 1975
                                 <label for="wpinv_vat_number" class="wpinv-label"></label>
1976
-                                <input type="text" class="wpi-input form-control" placeholder="<?php echo esc_attr( wp_sprintf( __( '%s number', 'invoicing' ), $tax_label ) );?>" value="<?php esc_attr_e( $vat_number );?>" id="wpinv_vat_number" name="wpinv_vat_number">
1977
-                                <span class="wpinv-vat-stat <?php echo $vat_vailidated_class;?>"><i class="fa"></i>&nbsp;<font><?php echo $vat_vailidated_text;?></font></span>
1976
+                                <input type="text" class="wpi-input form-control" placeholder="<?php echo esc_attr(wp_sprintf(__('%s number', 'invoicing'), $tax_label)); ?>" value="<?php esc_attr_e($vat_number); ?>" id="wpinv_vat_number" name="wpinv_vat_number">
1977
+                                <span class="wpinv-vat-stat <?php echo $vat_vailidated_class; ?>"><i class="fa"></i>&nbsp;<font><?php echo $vat_vailidated_text; ?></font></span>
1978 1978
                             </span>
1979 1979
                         </p>
1980 1980
                         <p class="wpi-cart-field wpi-col wpi-colf wpi-cart-field-actions">
1981
-                            <button class="btn btn-success btn-sm wpinv-vat-validate" type="button" id="wpinv_vat_validate" style="display:<?php echo $display_validate_btn; ?>"><?php echo wp_sprintf( __("Validate %s Number", 'invoicing'), $tax_label ); ?></button>
1982
-                            <button class="btn btn-danger btn-sm wpinv-vat-reset" type="button" id="wpinv_vat_reset" style="display:<?php echo $display_reset_btn; ?>"><?php echo wp_sprintf( __("Reset %s", 'invoicing'), $tax_label ); ?></button>
1981
+                            <button class="btn btn-success btn-sm wpinv-vat-validate" type="button" id="wpinv_vat_validate" style="display:<?php echo $display_validate_btn; ?>"><?php echo wp_sprintf(__("Validate %s Number", 'invoicing'), $tax_label); ?></button>
1982
+                            <button class="btn btn-danger btn-sm wpinv-vat-reset" type="button" id="wpinv_vat_reset" style="display:<?php echo $display_reset_btn; ?>"><?php echo wp_sprintf(__("Reset %s", 'invoicing'), $tax_label); ?></button>
1983 1983
                             <span class="wpi-vat-box wpi-vat-box-info"><span id="text"></span></span>
1984 1984
                             <span class="wpi-vat-box wpi-vat-box-error"><span id="text"></span></span>
1985
-                            <input type="hidden" name="_wpi_nonce" value="<?php echo wp_create_nonce( 'vat_validation' ) ?>" />
1985
+                            <input type="hidden" name="_wpi_nonce" value="<?php echo wp_create_nonce('vat_validation') ?>" />
1986 1986
                         </p>
1987 1987
                     </div>
1988 1988
                 </div>
@@ -1996,32 +1996,32 @@  discard block
 block discarded – undo
1996 1996
                 </span>
1997 1997
             </div>
1998 1998
         </div>
1999
-        <?php if ( empty( $wpinv_options['hide_ip_address'] ) ) { 
2000
-            $ip_link = '<a title="' . esc_attr( __( 'View more details on map', 'invoicing' ) ) . '" target="_blank" href="' . esc_url( admin_url( 'admin-ajax.php?action=wpinv_ip_geolocation&ip=' . $ip_address ) ) . '" class="wpi-ip-address-link">' . $ip_address . '&nbsp;&nbsp;<i class="fa fa-external-link-square" aria-hidden="true"></i></a>';
1999
+        <?php if (empty($wpinv_options['hide_ip_address'])) { 
2000
+            $ip_link = '<a title="' . esc_attr(__('View more details on map', 'invoicing')) . '" target="_blank" href="' . esc_url(admin_url('admin-ajax.php?action=wpinv_ip_geolocation&ip=' . $ip_address)) . '" class="wpi-ip-address-link">' . $ip_address . '&nbsp;&nbsp;<i class="fa fa-external-link-square" aria-hidden="true"></i></a>';
2001 2001
         ?>
2002 2002
         <div class="wpi-ip-info clearfix panel panel-info">
2003 2003
             <div id="wpinv-fields-box" class="panel-body">
2004
-                <span><?php echo wp_sprintf( __( "Your IP address is: %s", 'invoicing' ), $ip_link ); ?></span>
2004
+                <span><?php echo wp_sprintf(__("Your IP address is: %s", 'invoicing'), $ip_link); ?></span>
2005 2005
             </div>
2006 2006
         </div>
2007 2007
         <?php }
2008 2008
     }
2009 2009
     
2010
-    public static function show_vat_notice( $invoice ) {
2011
-        if ( empty( $invoice ) ) {
2010
+    public static function show_vat_notice($invoice) {
2011
+        if (empty($invoice)) {
2012 2012
             return NULL;
2013 2013
         }
2014 2014
         
2015
-        $label      = wpinv_get_option( 'vat_invoice_notice_label' );
2016
-        $notice     = wpinv_get_option( 'vat_invoice_notice' );
2017
-        if ( $label || $notice ) {
2015
+        $label      = wpinv_get_option('vat_invoice_notice_label');
2016
+        $notice     = wpinv_get_option('vat_invoice_notice');
2017
+        if ($label || $notice) {
2018 2018
         ?>
2019 2019
         <div class="row wpinv-vat-notice">
2020 2020
             <div class="col-sm-12">
2021
-                <?php if ( $label ) { ?>
2022
-                <strong><?php _e( $label, 'invoicing' ); ?></strong>
2023
-                <?php } if ( $notice ) { ?>
2024
-                <?php echo wpautop( wptexturize( __( $notice, 'invoicing' ) ) ) ?>
2021
+                <?php if ($label) { ?>
2022
+                <strong><?php _e($label, 'invoicing'); ?></strong>
2023
+                <?php } if ($notice) { ?>
2024
+                <?php echo wpautop(wptexturize(__($notice, 'invoicing'))) ?>
2025 2025
                 <?php } ?>
2026 2026
             </div>
2027 2027
         </div>
Please login to merge, or discard this patch.
includes/libraries/class-ayecode-addons.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly
3
-if ( ! defined( 'ABSPATH' ) ) exit;
4
-if(!class_exists('Ayecode_Addons')) {
3
+if (!defined('ABSPATH')) exit;
4
+if (!class_exists('Ayecode_Addons')) {
5 5
 
6 6
     abstract class Ayecode_Addons
7 7
     {
Please login to merge, or discard this patch.
vendor/ayecode/wp-font-awesome-settings/wp-font-awesome-settings.php 1 patch
Spacing   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -12,14 +12,14 @@  discard block
 block discarded – undo
12 12
 /**
13 13
  * Bail if we are not in WP.
14 14
  */
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if (!defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
19 19
 /**
20 20
  * Only add if the class does not already exist.
21 21
  */
22
-if ( ! class_exists( 'WP_Font_Awesome_Settings' ) ) {
22
+if (!class_exists('WP_Font_Awesome_Settings')) {
23 23
 
24 24
 	/**
25 25
 	 * A Class to be able to change settings for Font Awesome.
@@ -87,17 +87,17 @@  discard block
 block discarded – undo
87 87
 		 * @return WP_Font_Awesome_Settings - Main instance.
88 88
 		 */
89 89
 		public static function instance() {
90
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) {
90
+			if (!isset(self::$instance) && !(self::$instance instanceof WP_Font_Awesome_Settings)) {
91 91
 				self::$instance = new WP_Font_Awesome_Settings;
92 92
 
93
-				add_action( 'init', array( self::$instance, 'init' ) ); // set settings
93
+				add_action('init', array(self::$instance, 'init')); // set settings
94 94
 
95
-				if ( is_admin() ) {
96
-					add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
97
-					add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
95
+				if (is_admin()) {
96
+					add_action('admin_menu', array(self::$instance, 'menu_item'));
97
+					add_action('admin_init', array(self::$instance, 'register_settings'));
98 98
 				}
99 99
 
100
-				do_action( 'wp_font_awesome_settings_loaded' );
100
+				do_action('wp_font_awesome_settings_loaded');
101 101
 			}
102 102
 
103 103
 			return self::$instance;
@@ -111,30 +111,30 @@  discard block
 block discarded – undo
111 111
 		public function init() {
112 112
 			$this->settings = $this->get_settings();
113 113
 
114
-			if ( $this->settings['type'] == 'CSS' ) {
114
+			if ($this->settings['type'] == 'CSS') {
115 115
 
116
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
117
-					add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
116
+				if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend') {
117
+					add_action('wp_enqueue_scripts', array($this, 'enqueue_style'), 5000);
118 118
 				}
119 119
 
120
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
121
-					add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
120
+				if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend') {
121
+					add_action('admin_enqueue_scripts', array($this, 'enqueue_style'), 5000);
122 122
 				}
123 123
 
124 124
 			} else {
125 125
 
126
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
127
-					add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
126
+				if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend') {
127
+					add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 5000);
128 128
 				}
129 129
 
130
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
131
-					add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
130
+				if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend') {
131
+					add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'), 5000);
132 132
 				}
133 133
 			}
134 134
 
135 135
 			// remove font awesome if set to do so
136
-			if ( $this->settings['dequeue'] == '1' ) {
137
-				add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 );
136
+			if ($this->settings['dequeue'] == '1') {
137
+				add_action('clean_url', array($this, 'remove_font_awesome'), 5000, 3);
138 138
 			}
139 139
 
140 140
 		}
@@ -146,15 +146,15 @@  discard block
 block discarded – undo
146 146
 			// build url
147 147
 			$url = $this->get_url();
148 148
 
149
-			wp_deregister_style( 'font-awesome' ); // deregister in case its already there
150
-			wp_register_style( 'font-awesome', $url, array(), null );
151
-			wp_enqueue_style( 'font-awesome' );
149
+			wp_deregister_style('font-awesome'); // deregister in case its already there
150
+			wp_register_style('font-awesome', $url, array(), null);
151
+			wp_enqueue_style('font-awesome');
152 152
 
153
-			if ( $this->settings['shims'] ) {
154
-				$url = $this->get_url( true );
155
-				wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there
156
-				wp_register_style( 'font-awesome-shims', $url, array(), null );
157
-				wp_enqueue_style( 'font-awesome-shims' );
153
+			if ($this->settings['shims']) {
154
+				$url = $this->get_url(true);
155
+				wp_deregister_style('font-awesome-shims'); // deregister in case its already there
156
+				wp_register_style('font-awesome-shims', $url, array(), null);
157
+				wp_enqueue_style('font-awesome-shims');
158 158
 			}
159 159
 		}
160 160
 
@@ -166,15 +166,15 @@  discard block
 block discarded – undo
166 166
 			$url = $this->get_url();
167 167
 
168 168
 			$deregister_function = 'wp' . '_' . 'deregister' . '_' . 'script';
169
-			call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there
170
-			wp_register_script( 'font-awesome', $url, array(), null );
171
-			wp_enqueue_script( 'font-awesome' );
172
-
173
-			if ( $this->settings['shims'] ) {
174
-				$url = $this->get_url( true );
175
-				call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there
176
-				wp_register_script( 'font-awesome-shims', $url, array(), null );
177
-				wp_enqueue_script( 'font-awesome-shims' );
169
+			call_user_func($deregister_function, 'font-awesome'); // deregister in case its already there
170
+			wp_register_script('font-awesome', $url, array(), null);
171
+			wp_enqueue_script('font-awesome');
172
+
173
+			if ($this->settings['shims']) {
174
+				$url = $this->get_url(true);
175
+				call_user_func($deregister_function, 'font-awesome-shims'); // deregister in case its already there
176
+				wp_register_script('font-awesome-shims', $url, array(), null);
177
+				wp_enqueue_script('font-awesome-shims');
178 178
 			}
179 179
 		}
180 180
 
@@ -185,16 +185,16 @@  discard block
 block discarded – undo
185 185
 		 *
186 186
 		 * @return string The url to the file.
187 187
 		 */
188
-		public function get_url( $shims = false ) {
188
+		public function get_url($shims = false) {
189 189
 			$script  = $shims ? 'v4-shims' : 'all';
190 190
 			$sub     = $this->settings['pro'] ? 'pro' : 'use';
191 191
 			$type    = $this->settings['type'];
192 192
 			$version = $this->settings['version'];
193
-			$kit_url = $this->settings['kit-url'] ? esc_url( $this->settings['kit-url'] ) : '';
193
+			$kit_url = $this->settings['kit-url'] ? esc_url($this->settings['kit-url']) : '';
194 194
 			$url     = '';
195 195
 
196
-			if ( $type == 'KIT' && $kit_url ) {
197
-				if ( $shims ) {
196
+			if ($type == 'KIT' && $kit_url) {
197
+				if ($shims) {
198 198
 					// if its a kit then we don't add shims here
199 199
 					return '';
200 200
 				}
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 				$url .= "?wpfas=true"; // set our var so our version is not removed
203 203
 			} else {
204 204
 				$url .= "https://$sub.fontawesome.com/releases/"; // CDN
205
-				$url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
205
+				$url .= !empty($version) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
206 206
 				$url .= $type == 'CSS' ? 'css/' : 'js/'; // type
207 207
 				$url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
208 208
 				$url .= "?wpfas=true"; // set our var so our version is not removed
@@ -222,16 +222,16 @@  discard block
 block discarded – undo
222 222
 		 *
223 223
 		 * @return string The filtered url.
224 224
 		 */
225
-		public function remove_font_awesome( $url, $original_url, $_context ) {
225
+		public function remove_font_awesome($url, $original_url, $_context) {
226 226
 
227
-			if ( $_context == 'display'
228
-			     && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
229
-			     && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
227
+			if ($_context == 'display'
228
+			     && (strstr($url, "fontawesome") !== false || strstr($url, "font-awesome") !== false)
229
+			     && (strstr($url, ".js") !== false || strstr($url, ".css") !== false)
230 230
 			) {// it's a font-awesome-url (probably)
231 231
 
232
-				if ( strstr( $url, "wpfas=true" ) !== false ) {
233
-					if ( $this->settings['type'] == 'JS' ) {
234
-						if ( $this->settings['js-pseudo'] ) {
232
+				if (strstr($url, "wpfas=true") !== false) {
233
+					if ($this->settings['type'] == 'JS') {
234
+						if ($this->settings['js-pseudo']) {
235 235
 							$url .= "' data-search-pseudo-elements defer='defer";
236 236
 						} else {
237 237
 							$url .= "' defer='defer";
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 		 * Register the database settings with WordPress.
251 251
 		 */
252 252
 		public function register_settings() {
253
-			register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
253
+			register_setting('wp-font-awesome-settings', 'wp-font-awesome-settings');
254 254
 		}
255 255
 
256 256
 		/**
@@ -259,10 +259,10 @@  discard block
 block discarded – undo
259 259
 		 */
260 260
 		public function menu_item() {
261 261
 			$menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
262
-			call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
262
+			call_user_func($menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
263 263
 				$this,
264 264
 				'settings_page'
265
-			) );
265
+			));
266 266
 		}
267 267
 
268 268
 		/**
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 		 */
273 273
 		public function get_settings() {
274 274
 
275
-			$db_settings = get_option( 'wp-font-awesome-settings' );
275
+			$db_settings = get_option('wp-font-awesome-settings');
276 276
 
277 277
 			$defaults = array(
278 278
 				'type'      => 'CSS', // type to use, CSS or JS or KIT
@@ -285,14 +285,14 @@  discard block
 block discarded – undo
285 285
 				'kit-url'   => '', // the kit url
286 286
 			);
287 287
 
288
-			$settings = wp_parse_args( $db_settings, $defaults );
288
+			$settings = wp_parse_args($db_settings, $defaults);
289 289
 
290 290
 			/**
291 291
 			 * Filter the Font Awesome settings.
292 292
 			 *
293 293
 			 * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
294 294
 			 */
295
-			return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
295
+			return $this->settings = apply_filters('wp-font-awesome-settings', $settings, $db_settings, $defaults);
296 296
 		}
297 297
 
298 298
 
@@ -300,13 +300,13 @@  discard block
 block discarded – undo
300 300
 		 * The settings page html output.
301 301
 		 */
302 302
 		public function settings_page() {
303
-			if ( ! current_user_can( 'manage_options' ) ) {
304
-				wp_die( __( 'You do not have sufficient permissions to access this page.', 'font-awesome-settings' ) );
303
+			if (!current_user_can('manage_options')) {
304
+				wp_die(__('You do not have sufficient permissions to access this page.', 'font-awesome-settings'));
305 305
 			}
306 306
 
307 307
 			// a hidden way to force the update of the verison number vai api instead of waiting the 48 hours
308
-			if ( isset( $_REQUEST['force-version-check'] ) ) {
309
-				$this->get_latest_version( $force_api = true );
308
+			if (isset($_REQUEST['force-version-check'])) {
309
+				$this->get_latest_version($force_api = true);
310 310
 			}
311 311
 			?>
312 312
 			<style>
@@ -326,37 +326,37 @@  discard block
 block discarded – undo
326 326
 				<h1><?php echo $this->name; ?></h1>
327 327
 				<form method="post" action="options.php">
328 328
 					<?php
329
-					settings_fields( 'wp-font-awesome-settings' );
330
-					do_settings_sections( 'wp-font-awesome-settings' );
329
+					settings_fields('wp-font-awesome-settings');
330
+					do_settings_sections('wp-font-awesome-settings');
331 331
 					$kit_set = $this->settings['type'] == 'KIT' ? 'wpfas-kit-set' : '';
332 332
 					?>
333
-					<table class="form-table wpfas-table-settings <?php echo esc_attr( $kit_set ); ?>">
333
+					<table class="form-table wpfas-table-settings <?php echo esc_attr($kit_set); ?>">
334 334
 						<tr valign="top">
335 335
 							<th scope="row"><label
336
-									for="wpfas-type"><?php _e( 'Type', 'font-awesome-settings' ); ?></label></th>
336
+									for="wpfas-type"><?php _e('Type', 'font-awesome-settings'); ?></label></th>
337 337
 							<td>
338 338
 								<select name="wp-font-awesome-settings[type]" id="wpfas-type"
339 339
 								        onchange="if(this.value=='KIT'){jQuery('.wpfas-table-settings').addClass('wpfas-kit-set');}else{jQuery('.wpfas-table-settings').removeClass('wpfas-kit-set');}">
340 340
 									<option
341
-										value="CSS" <?php selected( $this->settings['type'], 'CSS' ); ?>><?php _e( 'CSS (default)', 'font-awesome-settings' ); ?></option>
342
-									<option value="JS" <?php selected( $this->settings['type'], 'JS' ); ?>>JS</option>
341
+										value="CSS" <?php selected($this->settings['type'], 'CSS'); ?>><?php _e('CSS (default)', 'font-awesome-settings'); ?></option>
342
+									<option value="JS" <?php selected($this->settings['type'], 'JS'); ?>>JS</option>
343 343
 									<option
344
-										value="KIT" <?php selected( $this->settings['type'], 'KIT' ); ?>><?php _e( 'Kits (settings managed on fontawesome.com)', 'font-awesome-settings' ); ?></option>
344
+										value="KIT" <?php selected($this->settings['type'], 'KIT'); ?>><?php _e('Kits (settings managed on fontawesome.com)', 'font-awesome-settings'); ?></option>
345 345
 								</select>
346 346
 							</td>
347 347
 						</tr>
348 348
 
349 349
 						<tr valign="top" class="wpfas-kit-show">
350 350
 							<th scope="row"><label
351
-									for="wpfas-kit-url"><?php _e( 'Kit URL', 'font-awesome-settings' ); ?></label></th>
351
+									for="wpfas-kit-url"><?php _e('Kit URL', 'font-awesome-settings'); ?></label></th>
352 352
 							<td>
353 353
 								<input class="regular-text" id="wpfas-kit-url" type="url"
354 354
 								       name="wp-font-awesome-settings[kit-url]"
355
-								       value="<?php echo esc_attr( $this->settings['kit-url'] ); ?>"
355
+								       value="<?php echo esc_attr($this->settings['kit-url']); ?>"
356 356
 								       placeholder="https://kit.fontawesome.com/123abc.js"/>
357 357
 								<span><?php
358 358
 									echo sprintf(
359
-										__( 'Requires a free account with Font Awesome. %sGet kit url%s', 'font-awesome-settings' ),
359
+										__('Requires a free account with Font Awesome. %sGet kit url%s', 'font-awesome-settings'),
360 360
 										'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/kits"><i class="fas fa-external-link-alt"></i>',
361 361
 										'</a>'
362 362
 									);
@@ -366,31 +366,31 @@  discard block
 block discarded – undo
366 366
 
367 367
 						<tr valign="top" class="wpfas-kit-hide">
368 368
 							<th scope="row"><label
369
-									for="wpfas-version"><?php _e( 'Version', 'font-awesome-settings' ); ?></label></th>
369
+									for="wpfas-version"><?php _e('Version', 'font-awesome-settings'); ?></label></th>
370 370
 							<td>
371 371
 								<select name="wp-font-awesome-settings[version]" id="wpfas-version">
372 372
 									<option
373
-										value="" <?php selected( $this->settings['version'], '' ); ?>><?php echo sprintf( __( 'Latest - %s (default)', 'font-awesome-settings' ), $this->get_latest_version() ); ?>
373
+										value="" <?php selected($this->settings['version'], ''); ?>><?php echo sprintf(__('Latest - %s (default)', 'font-awesome-settings'), $this->get_latest_version()); ?>
374 374
 									</option>
375
-									<option value="5.6.0" <?php selected( $this->settings['version'], '5.6.0' ); ?>>
375
+									<option value="5.6.0" <?php selected($this->settings['version'], '5.6.0'); ?>>
376 376
 										5.6.0
377 377
 									</option>
378
-									<option value="5.5.0" <?php selected( $this->settings['version'], '5.5.0' ); ?>>
378
+									<option value="5.5.0" <?php selected($this->settings['version'], '5.5.0'); ?>>
379 379
 										5.5.0
380 380
 									</option>
381
-									<option value="5.4.0" <?php selected( $this->settings['version'], '5.4.0' ); ?>>
381
+									<option value="5.4.0" <?php selected($this->settings['version'], '5.4.0'); ?>>
382 382
 										5.4.0
383 383
 									</option>
384
-									<option value="5.3.0" <?php selected( $this->settings['version'], '5.3.0' ); ?>>
384
+									<option value="5.3.0" <?php selected($this->settings['version'], '5.3.0'); ?>>
385 385
 										5.3.0
386 386
 									</option>
387
-									<option value="5.2.0" <?php selected( $this->settings['version'], '5.2.0' ); ?>>
387
+									<option value="5.2.0" <?php selected($this->settings['version'], '5.2.0'); ?>>
388 388
 										5.2.0
389 389
 									</option>
390
-									<option value="5.1.0" <?php selected( $this->settings['version'], '5.1.0' ); ?>>
390
+									<option value="5.1.0" <?php selected($this->settings['version'], '5.1.0'); ?>>
391 391
 										5.1.0
392 392
 									</option>
393
-									<option value="4.7.0" <?php selected( $this->settings['version'], '4.7.0' ); ?>>
393
+									<option value="4.7.0" <?php selected($this->settings['version'], '4.7.0'); ?>>
394 394
 										4.7.1 (CSS only)
395 395
 									</option>
396 396
 								</select>
@@ -399,29 +399,29 @@  discard block
 block discarded – undo
399 399
 
400 400
 						<tr valign="top">
401 401
 							<th scope="row"><label
402
-									for="wpfas-enqueue"><?php _e( 'Enqueue', 'font-awesome-settings' ); ?></label></th>
402
+									for="wpfas-enqueue"><?php _e('Enqueue', 'font-awesome-settings'); ?></label></th>
403 403
 							<td>
404 404
 								<select name="wp-font-awesome-settings[enqueue]" id="wpfas-enqueue">
405 405
 									<option
406
-										value="" <?php selected( $this->settings['enqueue'], '' ); ?>><?php _e( 'Frontend + Backend (default)', 'font-awesome-settings' ); ?></option>
406
+										value="" <?php selected($this->settings['enqueue'], ''); ?>><?php _e('Frontend + Backend (default)', 'font-awesome-settings'); ?></option>
407 407
 									<option
408
-										value="frontend" <?php selected( $this->settings['enqueue'], 'frontend' ); ?>><?php _e( 'Frontend', 'font-awesome-settings' ); ?></option>
408
+										value="frontend" <?php selected($this->settings['enqueue'], 'frontend'); ?>><?php _e('Frontend', 'font-awesome-settings'); ?></option>
409 409
 									<option
410
-										value="backend" <?php selected( $this->settings['enqueue'], 'backend' ); ?>><?php _e( 'Backend', 'font-awesome-settings' ); ?></option>
410
+										value="backend" <?php selected($this->settings['enqueue'], 'backend'); ?>><?php _e('Backend', 'font-awesome-settings'); ?></option>
411 411
 								</select>
412 412
 							</td>
413 413
 						</tr>
414 414
 
415 415
 						<tr valign="top" class="wpfas-kit-hide">
416 416
 							<th scope="row"><label
417
-									for="wpfas-pro"><?php _e( 'Enable pro', 'font-awesome-settings' ); ?></label></th>
417
+									for="wpfas-pro"><?php _e('Enable pro', 'font-awesome-settings'); ?></label></th>
418 418
 							<td>
419 419
 								<input type="hidden" name="wp-font-awesome-settings[pro]" value="0"/>
420 420
 								<input type="checkbox" name="wp-font-awesome-settings[pro]"
421
-								       value="1" <?php checked( $this->settings['pro'], '1' ); ?> id="wpfas-pro"/>
421
+								       value="1" <?php checked($this->settings['pro'], '1'); ?> id="wpfas-pro"/>
422 422
 								<span><?php
423 423
 									echo sprintf(
424
-										__( 'Requires a subscription. %sLearn more%s %sManage my allowed domains%s', 'font-awesome-settings' ),
424
+										__('Requires a subscription. %sLearn more%s %sManage my allowed domains%s', 'font-awesome-settings'),
425 425
 										'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/pro"><i class="fas fa-external-link-alt"></i>',
426 426
 										'</a>',
427 427
 										'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/account/cdn"><i class="fas fa-external-link-alt"></i>',
@@ -433,38 +433,38 @@  discard block
 block discarded – undo
433 433
 
434 434
 						<tr valign="top" class="wpfas-kit-hide">
435 435
 							<th scope="row"><label
436
-									for="wpfas-shims"><?php _e( 'Enable v4 shims compatibility', 'font-awesome-settings' ); ?></label>
436
+									for="wpfas-shims"><?php _e('Enable v4 shims compatibility', 'font-awesome-settings'); ?></label>
437 437
 							</th>
438 438
 							<td>
439 439
 								<input type="hidden" name="wp-font-awesome-settings[shims]" value="0"/>
440 440
 								<input type="checkbox" name="wp-font-awesome-settings[shims]"
441
-								       value="1" <?php checked( $this->settings['shims'], '1' ); ?> id="wpfas-shims"/>
442
-								<span><?php _e( 'This enables v4 classes to work with v5, sort of like a band-aid until everyone has updated everything to v5.', 'font-awesome-settings' ); ?></span>
441
+								       value="1" <?php checked($this->settings['shims'], '1'); ?> id="wpfas-shims"/>
442
+								<span><?php _e('This enables v4 classes to work with v5, sort of like a band-aid until everyone has updated everything to v5.', 'font-awesome-settings'); ?></span>
443 443
 							</td>
444 444
 						</tr>
445 445
 
446 446
 						<tr valign="top" class="wpfas-kit-hide">
447 447
 							<th scope="row"><label
448
-									for="wpfas-js-pseudo"><?php _e( 'Enable JS pseudo elements (not recommended)', 'font-awesome-settings' ); ?></label>
448
+									for="wpfas-js-pseudo"><?php _e('Enable JS pseudo elements (not recommended)', 'font-awesome-settings'); ?></label>
449 449
 							</th>
450 450
 							<td>
451 451
 								<input type="hidden" name="wp-font-awesome-settings[js-pseudo]" value="0"/>
452 452
 								<input type="checkbox" name="wp-font-awesome-settings[js-pseudo]"
453
-								       value="1" <?php checked( $this->settings['js-pseudo'], '1' ); ?>
453
+								       value="1" <?php checked($this->settings['js-pseudo'], '1'); ?>
454 454
 								       id="wpfas-js-pseudo"/>
455
-								<span><?php _e( 'Used only with the JS version, this will make pseudo-elements work but can be CPU intensive on some sites.', 'font-awesome-settings' ); ?></span>
455
+								<span><?php _e('Used only with the JS version, this will make pseudo-elements work but can be CPU intensive on some sites.', 'font-awesome-settings'); ?></span>
456 456
 							</td>
457 457
 						</tr>
458 458
 
459 459
 						<tr valign="top">
460 460
 							<th scope="row"><label
461
-									for="wpfas-dequeue"><?php _e( 'Dequeue', 'font-awesome-settings' ); ?></label></th>
461
+									for="wpfas-dequeue"><?php _e('Dequeue', 'font-awesome-settings'); ?></label></th>
462 462
 							<td>
463 463
 								<input type="hidden" name="wp-font-awesome-settings[dequeue]" value="0"/>
464 464
 								<input type="checkbox" name="wp-font-awesome-settings[dequeue]"
465
-								       value="1" <?php checked( $this->settings['dequeue'], '1' ); ?>
465
+								       value="1" <?php checked($this->settings['dequeue'], '1'); ?>
466 466
 								       id="wpfas-dequeue"/>
467
-								<span><?php _e( 'This will try to dequeue any other Font Awesome versions loaded by other sources if they are added with `font-awesome` or `fontawesome` in the name.', 'font-awesome-settings' ); ?></span>
467
+								<span><?php _e('This will try to dequeue any other Font Awesome versions loaded by other sources if they are added with `font-awesome` or `fontawesome` in the name.', 'font-awesome-settings'); ?></span>
468 468
 							</td>
469 469
 						</tr>
470 470
 
@@ -489,12 +489,12 @@  discard block
 block discarded – undo
489 489
 		 *
490 490
 		 * @return string Either a valid version number or an empty string.
491 491
 		 */
492
-		public function validate_version_number( $version ) {
492
+		public function validate_version_number($version) {
493 493
 
494
-			if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
494
+			if (version_compare($version, '0.0.1', '>=') >= 0) {
495 495
 				// valid
496 496
 			} else {
497
-				$version = '';// not validated
497
+				$version = ''; // not validated
498 498
 			}
499 499
 
500 500
 			return $version;
@@ -509,19 +509,19 @@  discard block
 block discarded – undo
509 509
 		 * @since 1.0.7
510 510
 		 * @return mixed|string The latest version number found.
511 511
 		 */
512
-		public function get_latest_version( $force_api = false ) {
512
+		public function get_latest_version($force_api = false) {
513 513
 			$latest_version = $this->latest;
514 514
 
515
-			$cache = get_transient( 'wp-font-awesome-settings-version' );
515
+			$cache = get_transient('wp-font-awesome-settings-version');
516 516
 
517
-			if ( $cache === false || $force_api ) { // its not set
517
+			if ($cache === false || $force_api) { // its not set
518 518
 				$api_ver = $this->get_latest_version_from_api();
519
-				if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
519
+				if (version_compare($api_ver, $this->latest, '>=') >= 0) {
520 520
 					$latest_version = $api_ver;
521
-					set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
521
+					set_transient('wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS);
522 522
 				}
523
-			} elseif ( $this->validate_version_number( $cache ) ) {
524
-				if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
523
+			} elseif ($this->validate_version_number($cache)) {
524
+				if (version_compare($cache, $this->latest, '>=') >= 0) {
525 525
 					$latest_version = $cache;
526 526
 				}
527 527
 			}
@@ -537,10 +537,10 @@  discard block
 block discarded – undo
537 537
 		 */
538 538
 		public function get_latest_version_from_api() {
539 539
 			$version  = "0";
540
-			$response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" );
541
-			if ( ! is_wp_error( $response ) && is_array( $response ) ) {
542
-				$api_response = json_decode( wp_remote_retrieve_body( $response ), true );
543
-				if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) {
540
+			$response = wp_remote_get("https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest");
541
+			if (!is_wp_error($response) && is_array($response)) {
542
+				$api_response = json_decode(wp_remote_retrieve_body($response), true);
543
+				if (isset($api_response['tag_name']) && version_compare($api_response['tag_name'], $this->latest, '>=') >= 0 && empty($api_response['prerelease'])) {
544 544
 					$version = $api_response['tag_name'];
545 545
 				}
546 546
 			}
Please login to merge, or discard this patch.
includes/wpinv-helper-functions.php 1 patch
Spacing   +389 added lines, -389 removed lines patch added patch discarded remove patch
@@ -7,132 +7,132 @@  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
 function wpinv_item_quantities_enabled() {
15
-    $ret = wpinv_get_option( 'item_quantities', true );
15
+    $ret = wpinv_get_option('item_quantities', true);
16 16
 
17
-    return (bool) apply_filters( 'wpinv_item_quantities_enabled', $ret );
17
+    return (bool)apply_filters('wpinv_item_quantities_enabled', $ret);
18 18
 }
19 19
 
20 20
 function wpinv_get_ip() {
21 21
     $ip = '127.0.0.1';
22 22
 
23
-    if ( !empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
24
-        $ip = sanitize_text_field( $_SERVER['HTTP_CLIENT_IP'] );
25
-    } elseif ( !empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
26
-        $ip = sanitize_text_field( $_SERVER['HTTP_X_FORWARDED_FOR'] );
27
-    } elseif( !empty( $_SERVER['REMOTE_ADDR'] ) ) {
28
-        $ip = sanitize_text_field( $_SERVER['REMOTE_ADDR'] );
23
+    if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
24
+        $ip = sanitize_text_field($_SERVER['HTTP_CLIENT_IP']);
25
+    } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
26
+        $ip = sanitize_text_field($_SERVER['HTTP_X_FORWARDED_FOR']);
27
+    } elseif (!empty($_SERVER['REMOTE_ADDR'])) {
28
+        $ip = sanitize_text_field($_SERVER['REMOTE_ADDR']);
29 29
     }
30 30
 
31
-    return apply_filters( 'wpinv_get_ip', $ip );
31
+    return apply_filters('wpinv_get_ip', $ip);
32 32
 }
33 33
 
34 34
 function wpinv_get_user_agent() {
35
-    if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
36
-        $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] );
35
+    if (!empty($_SERVER['HTTP_USER_AGENT'])) {
36
+        $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']);
37 37
     } else {
38 38
         $user_agent = '';
39 39
     }
40 40
 
41
-    return apply_filters( 'wpinv_get_user_agent', $user_agent );
41
+    return apply_filters('wpinv_get_user_agent', $user_agent);
42 42
 }
43 43
 
44
-function wpinv_sanitize_amount( $amount, $decimals = NULL ) {
44
+function wpinv_sanitize_amount($amount, $decimals = NULL) {
45 45
     $is_negative   = false;
46 46
     $thousands_sep = wpinv_thousands_separator();
47 47
     $decimal_sep   = wpinv_decimal_separator();
48
-    if ( $decimals === NULL ) {
48
+    if ($decimals === NULL) {
49 49
         $decimals = wpinv_decimals();
50 50
     }
51 51
 
52 52
     // Sanitize the amount
53
-    if ( $decimal_sep == ',' && false !== ( $found = strpos( $amount, $decimal_sep ) ) ) {
54
-        if ( ( $thousands_sep == '.' || $thousands_sep == ' ' ) && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) {
55
-            $amount = str_replace( $thousands_sep, '', $amount );
56
-        } elseif( empty( $thousands_sep ) && false !== ( $found = strpos( $amount, '.' ) ) ) {
57
-            $amount = str_replace( '.', '', $amount );
53
+    if ($decimal_sep == ',' && false !== ($found = strpos($amount, $decimal_sep))) {
54
+        if (($thousands_sep == '.' || $thousands_sep == ' ') && false !== ($found = strpos($amount, $thousands_sep))) {
55
+            $amount = str_replace($thousands_sep, '', $amount);
56
+        } elseif (empty($thousands_sep) && false !== ($found = strpos($amount, '.'))) {
57
+            $amount = str_replace('.', '', $amount);
58 58
         }
59 59
 
60
-        $amount = str_replace( $decimal_sep, '.', $amount );
61
-    } elseif( $thousands_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) {
62
-        $amount = str_replace( $thousands_sep, '', $amount );
60
+        $amount = str_replace($decimal_sep, '.', $amount);
61
+    } elseif ($thousands_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) {
62
+        $amount = str_replace($thousands_sep, '', $amount);
63 63
     }
64 64
 
65
-    if( $amount < 0 ) {
65
+    if ($amount < 0) {
66 66
         $is_negative = true;
67 67
     }
68 68
 
69
-    $amount   = preg_replace( '/[^0-9\.]/', '', $amount );
69
+    $amount   = preg_replace('/[^0-9\.]/', '', $amount);
70 70
 
71
-    $decimals = apply_filters( 'wpinv_sanitize_amount_decimals', absint( $decimals ), $amount );
72
-    $amount   = number_format( (double) $amount, absint( $decimals ), '.', '' );
71
+    $decimals = apply_filters('wpinv_sanitize_amount_decimals', absint($decimals), $amount);
72
+    $amount   = number_format((double)$amount, absint($decimals), '.', '');
73 73
 
74
-    if( $is_negative ) {
74
+    if ($is_negative) {
75 75
         $amount *= -1;
76 76
     }
77 77
 
78
-    return apply_filters( 'wpinv_sanitize_amount', $amount, $decimals );
78
+    return apply_filters('wpinv_sanitize_amount', $amount, $decimals);
79 79
 }
80
-add_filter( 'wpinv_sanitize_amount_decimals', 'wpinv_currency_decimal_filter', 10, 1 );
80
+add_filter('wpinv_sanitize_amount_decimals', 'wpinv_currency_decimal_filter', 10, 1);
81 81
 
82
-function wpinv_round_amount( $amount, $decimals = NULL ) {
83
-    if ( $decimals === NULL ) {
82
+function wpinv_round_amount($amount, $decimals = NULL) {
83
+    if ($decimals === NULL) {
84 84
         $decimals = wpinv_decimals();
85 85
     }
86 86
     
87
-    $amount = round( (double)$amount, wpinv_currency_decimal_filter( absint( $decimals ) ) );
87
+    $amount = round((double)$amount, wpinv_currency_decimal_filter(absint($decimals)));
88 88
 
89
-    return apply_filters( 'wpinv_round_amount', $amount, $decimals );
89
+    return apply_filters('wpinv_round_amount', $amount, $decimals);
90 90
 }
91 91
 
92
-function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) {
92
+function wpinv_get_invoice_statuses($draft = false, $trashed = false, $invoice = false) {
93 93
     global $post;
94 94
 
95 95
     $invoice_statuses = array(
96
-        'wpi-pending' => __( 'Pending Payment', 'invoicing' ),
97
-        'publish' => __( 'Paid', 'invoicing'),
98
-        'wpi-processing' => __( 'Processing', 'invoicing' ),
99
-        'wpi-onhold' => __( 'On Hold', 'invoicing' ),
100
-        'wpi-refunded' => __( 'Refunded', 'invoicing' ),
101
-        'wpi-cancelled' => __( 'Cancelled', 'invoicing' ),
102
-        'wpi-failed' => __( 'Failed', 'invoicing' ),
103
-        'wpi-renewal' => __( 'Renewal Payment', 'invoicing' )
96
+        'wpi-pending' => __('Pending Payment', 'invoicing'),
97
+        'publish' => __('Paid', 'invoicing'),
98
+        'wpi-processing' => __('Processing', 'invoicing'),
99
+        'wpi-onhold' => __('On Hold', 'invoicing'),
100
+        'wpi-refunded' => __('Refunded', 'invoicing'),
101
+        'wpi-cancelled' => __('Cancelled', 'invoicing'),
102
+        'wpi-failed' => __('Failed', 'invoicing'),
103
+        'wpi-renewal' => __('Renewal Payment', 'invoicing')
104 104
     );
105 105
 
106
-    if ( $draft ) {
107
-        $invoice_statuses['draft'] = __( 'Draft', 'invoicing' );
106
+    if ($draft) {
107
+        $invoice_statuses['draft'] = __('Draft', 'invoicing');
108 108
     }
109 109
 
110
-    if ( $trashed ) {
111
-        $invoice_statuses['trash'] = __( 'Trash', 'invoicing' );
110
+    if ($trashed) {
111
+        $invoice_statuses['trash'] = __('Trash', 'invoicing');
112 112
     }
113 113
 
114
-    return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice );
114
+    return apply_filters('wpinv_statuses', $invoice_statuses, $invoice);
115 115
 }
116 116
 
117
-function wpinv_status_nicename( $status ) {
118
-    $statuses = wpinv_get_invoice_statuses( true, true );
119
-    $status   = isset( $statuses[$status] ) ? $statuses[$status] : __( $status, 'invoicing' );
117
+function wpinv_status_nicename($status) {
118
+    $statuses = wpinv_get_invoice_statuses(true, true);
119
+    $status   = isset($statuses[$status]) ? $statuses[$status] : __($status, 'invoicing');
120 120
 
121 121
     return $status;
122 122
 }
123 123
 
124 124
 function wpinv_get_currency() {
125
-    $currency = wpinv_get_option( 'currency', 'USD' );
125
+    $currency = wpinv_get_option('currency', 'USD');
126 126
     
127
-    return apply_filters( 'wpinv_currency', $currency );
127
+    return apply_filters('wpinv_currency', $currency);
128 128
 }
129 129
 
130
-function wpinv_currency_symbol( $currency = '' ) {
131
-    if ( empty( $currency ) ) {
130
+function wpinv_currency_symbol($currency = '') {
131
+    if (empty($currency)) {
132 132
         $currency = wpinv_get_currency();
133 133
     }
134 134
     
135
-    $symbols = apply_filters( 'wpinv_currency_symbols', array(
135
+    $symbols = apply_filters('wpinv_currency_symbols', array(
136 136
         'AED' => '&#x62f;.&#x625;',
137 137
         'AFN' => '&#x60b;',
138 138
         'ALL' => 'L',
@@ -295,209 +295,209 @@  discard block
 block discarded – undo
295 295
         'YER' => '&#xfdfc;',
296 296
         'ZAR' => '&#82;',
297 297
         'ZMW' => 'ZK',
298
-    ) );
298
+    ));
299 299
 
300
-    $currency_symbol = isset( $symbols[$currency] ) ? $symbols[$currency] : $currency;
300
+    $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency;
301 301
 
302
-    return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency );
302
+    return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency);
303 303
 }
304 304
 
305 305
 function wpinv_currency_position() {
306
-    $position = wpinv_get_option( 'currency_position', 'left' );
306
+    $position = wpinv_get_option('currency_position', 'left');
307 307
     
308
-    return apply_filters( 'wpinv_currency_position', $position );
308
+    return apply_filters('wpinv_currency_position', $position);
309 309
 }
310 310
 
311 311
 function wpinv_thousands_separator() {
312
-    $thousand_sep = wpinv_get_option( 'thousands_separator', ',' );
312
+    $thousand_sep = wpinv_get_option('thousands_separator', ',');
313 313
     
314
-    return apply_filters( 'wpinv_thousands_separator', $thousand_sep );
314
+    return apply_filters('wpinv_thousands_separator', $thousand_sep);
315 315
 }
316 316
 
317 317
 function wpinv_decimal_separator() {
318
-    $decimal_sep = wpinv_get_option( 'decimal_separator', '.' );
318
+    $decimal_sep = wpinv_get_option('decimal_separator', '.');
319 319
     
320
-    return apply_filters( 'wpinv_decimal_separator', $decimal_sep );
320
+    return apply_filters('wpinv_decimal_separator', $decimal_sep);
321 321
 }
322 322
 
323 323
 function wpinv_decimals() {
324
-    $decimals = apply_filters( 'wpinv_decimals', wpinv_get_option( 'decimals', 2 ) );
324
+    $decimals = apply_filters('wpinv_decimals', wpinv_get_option('decimals', 2));
325 325
     
326
-    return absint( $decimals );
326
+    return absint($decimals);
327 327
 }
328 328
 
329 329
 function wpinv_get_currencies() {
330 330
     $currencies = array(
331
-        'USD' => __( 'US Dollar', 'invoicing' ),
332
-        'EUR' => __( 'Euro', 'invoicing' ),
333
-        'GBP' => __( 'Pound Sterling', 'invoicing' ),
334
-        'AED' => __( 'United Arab Emirates', 'invoicing' ),
335
-        'AFN' => __( 'Afghan Afghani', 'invoicing' ),
336
-        'ALL' => __( 'Albanian Lek', 'invoicing' ),
337
-        'AMD' => __( 'Armenian Dram', 'invoicing' ),
338
-        'ANG' => __( 'Netherlands Antillean Guilder', 'invoicing' ),
339
-        'AOA' => __( 'Angolan Kwanza', 'invoicing' ),
340
-        'ARS' => __( 'Argentine Peso', 'invoicing' ),
341
-        'AUD' => __( 'Australian Dollar', 'invoicing' ),
342
-        'AWG' => __( 'Aruban Florin', 'invoicing' ),
343
-        'AZN' => __( 'Azerbaijani Manat', 'invoicing' ),
344
-        'BAM' => __( 'Bosnia and Herzegovina Convertible Marka', 'invoicing' ),
345
-        'BBD' => __( 'Barbadian Dollar', 'invoicing' ),
346
-        'BDT' => __( 'Bangladeshi Taka', 'invoicing' ),
347
-        'BGN' => __( 'Bulgarian Lev', 'invoicing' ),
348
-        'BHD' => __( 'Bahraini Dinar', 'invoicing' ),
349
-        'BIF' => __( 'Burundian Franc', 'invoicing' ),
350
-        'BMD' => __( 'Bermudian Dollar', 'invoicing' ),
351
-        'BND' => __( 'Brunei Dollar', 'invoicing' ),
352
-        'BOB' => __( 'Bolivian Boliviano', 'invoicing' ),
353
-        'BRL' => __( 'Brazilian Real', 'invoicing' ),
354
-        'BSD' => __( 'Bahamian Dollar', 'invoicing' ),
355
-        'BTC' => __( 'Bitcoin', 'invoicing' ),
356
-        'BTN' => __( 'Bhutanese Ngultrum', 'invoicing' ),
357
-        'BWP' => __( 'Botswana Pula', 'invoicing' ),
358
-        'BYN' => __( 'Belarusian Ruble', 'invoicing' ),
359
-        'BZD' => __( 'Belize Dollar', 'invoicing' ),
360
-        'CAD' => __( 'Canadian Dollar', 'invoicing' ),
361
-        'CDF' => __( 'Congolese Franc', 'invoicing' ),
362
-        'CHF' => __( 'Swiss Franc', 'invoicing' ),
363
-        'CLP' => __( 'Chilean Peso', 'invoicing' ),
364
-        'CNY' => __( 'Chinese Yuan', 'invoicing' ),
365
-        'COP' => __( 'Colombian Peso', 'invoicing' ),
366
-        'CRC' => __( 'Costa Rican Colon', 'invoicing' ),
367
-        'CUC' => __( 'Cuban Convertible Peso', 'invoicing' ),
368
-        'CUP' => __( 'Cuban Peso', 'invoicing' ),
369
-        'CVE' => __( 'Cape Verdean escudo', 'invoicing' ),
370
-        'CZK' => __( 'Czech Koruna', 'invoicing' ),
371
-        'DJF' => __( 'Djiboutian Franc', 'invoicing' ),
372
-        'DKK' => __( 'Danish Krone', 'invoicing' ),
373
-        'DOP' => __( 'Dominican Peso', 'invoicing' ),
374
-        'DZD' => __( 'Algerian Dinar', 'invoicing' ),
375
-        'EGP' => __( 'Egyptian Pound', 'invoicing' ),
376
-        'ERN' => __( 'Eritrean Nakfa', 'invoicing' ),
377
-        'ETB' => __( 'Ethiopian Irr', 'invoicing' ),
378
-        'FJD' => __( 'Fijian Dollar', 'invoicing' ),
379
-        'FKP' => __( 'Falkland Islands Pound', 'invoicing' ),
380
-        'GEL' => __( 'Georgian Lari', 'invoicing' ),
381
-        'GGP' => __( 'Guernsey Pound', 'invoicing' ),
382
-        'GHS' => __( 'Ghana Cedi', 'invoicing' ),
383
-        'GIP' => __( 'Gibraltar Pound', 'invoicing' ),
384
-        'GMD' => __( 'Gambian Dalasi', 'invoicing' ),
385
-        'GNF' => __( 'Guinean Franc', 'invoicing' ),
386
-        'GTQ' => __( 'Guatemalan Quetzal', 'invoicing' ),
387
-        'GYD' => __( 'Guyanese Dollar', 'invoicing' ),
388
-        'HKD' => __( 'Hong Kong Dollar', 'invoicing' ),
389
-        'HNL' => __( 'Honduran Lempira', 'invoicing' ),
390
-        'HRK' => __( 'Croatian Kuna', 'invoicing' ),
391
-        'HTG' => __( 'Haitian Gourde', 'invoicing' ),
392
-        'HUF' => __( 'Hungarian Forint', 'invoicing' ),
393
-        'IDR' => __( 'Indonesian Rupiah', 'invoicing' ),
394
-        'ILS' => __( 'Israeli New Shekel', 'invoicing' ),
395
-        'IMP' => __( 'Manx Pound', 'invoicing' ),
396
-        'INR' => __( 'Indian Rupee', 'invoicing' ),
397
-        'IQD' => __( 'Iraqi Dinar', 'invoicing' ),
398
-        'IRR' => __( 'Iranian Rial', 'invoicing' ),
399
-        'IRT' => __( 'Iranian Toman', 'invoicing' ),
400
-        'ISK' => __( 'Icelandic Krona', 'invoicing' ),
401
-        'JEP' => __( 'Jersey Pound', 'invoicing' ),
402
-        'JMD' => __( 'Jamaican Dollar', 'invoicing' ),
403
-        'JOD' => __( 'Jordanian Dinar', 'invoicing' ),
404
-        'JPY' => __( 'Japanese Yen', 'invoicing' ),
405
-        'KES' => __( 'Kenyan Shilling', 'invoicing' ),
406
-        'KGS' => __( 'Kyrgyzstani Som', 'invoicing' ),
407
-        'KHR' => __( 'Cambodian Riel', 'invoicing' ),
408
-        'KMF' => __( 'Comorian Franc', 'invoicing' ),
409
-        'KPW' => __( 'North Korean Won', 'invoicing' ),
410
-        'KRW' => __( 'South Korean Won', 'invoicing' ),
411
-        'KWD' => __( 'Kuwaiti Dinar', 'invoicing' ),
412
-        'KYD' => __( 'Cayman Islands Dollar', 'invoicing' ),
413
-        'KZT' => __( 'Kazakhstani Tenge', 'invoicing' ),
414
-        'LAK' => __( 'Lao Kip', 'invoicing' ),
415
-        'LBP' => __( 'Lebanese Pound', 'invoicing' ),
416
-        'LKR' => __( 'Sri Lankan Rupee', 'invoicing' ),
417
-        'LRD' => __( 'Liberian Dollar', 'invoicing' ),
418
-        'LSL' => __( 'Lesotho Loti', 'invoicing' ),
419
-        'LYD' => __( 'Libyan Dinar', 'invoicing' ),
420
-        'MAD' => __( 'Moroccan Dirham', 'invoicing' ),
421
-        'MDL' => __( 'Moldovan Leu', 'invoicing' ),
422
-        'MGA' => __( 'Malagasy Ariary', 'invoicing' ),
423
-        'MKD' => __( 'Macedonian Denar', 'invoicing' ),
424
-        'MMK' => __( 'Burmese Kyat', 'invoicing' ),
425
-        'MNT' => __( 'Mongolian Tughrik', 'invoicing' ),
426
-        'MOP' => __( 'Macanese Pataca', 'invoicing' ),
427
-        'MRO' => __( 'Mauritanian Ouguiya', 'invoicing' ),
428
-        'MUR' => __( 'Mauritian Rupee', 'invoicing' ),
429
-        'MVR' => __( 'Maldivian Rufiyaa', 'invoicing' ),
430
-        'MWK' => __( 'Malawian Kwacha', 'invoicing' ),
431
-        'MXN' => __( 'Mexican Peso', 'invoicing' ),
432
-        'MYR' => __( 'Malaysian Ringgit', 'invoicing' ),
433
-        'MZN' => __( 'Mozambican Metical', 'invoicing' ),
434
-        'NAD' => __( 'Namibian Dollar', 'invoicing' ),
435
-        'NGN' => __( 'Nigerian Naira', 'invoicing' ),
436
-        'NIO' => __( 'Nicaraguan Cordoba', 'invoicing' ),
437
-        'NOK' => __( 'Norwegian Krone', 'invoicing' ),
438
-        'NPR' => __( 'Nepalese Rupee', 'invoicing' ),
439
-        'NZD' => __( 'New Zealand Dollar', 'invoicing' ),
440
-        'OMR' => __( 'Omani Rial', 'invoicing' ),
441
-        'PAB' => __( 'Panamanian Balboa', 'invoicing' ),
442
-        'PEN' => __( 'Peruvian Nuevo Sol', 'invoicing' ),
443
-        'PGK' => __( 'Papua New Guinean Kina', 'invoicing' ),
444
-        'PHP' => __( 'Philippine Peso', 'invoicing' ),
445
-        'PKR' => __( 'Pakistani Rupee', 'invoicing' ),
446
-        'PLN' => __( 'Polish Zloty', 'invoicing' ),
447
-        'PRB' => __( 'Transnistrian Ruble', 'invoicing' ),
448
-        'PYG' => __( 'Paraguayan Guarani', 'invoicing' ),
449
-        'QAR' => __( 'Qatari Riyal', 'invoicing' ),
450
-        'RON' => __( 'Romanian Leu', 'invoicing' ),
451
-        'RSD' => __( 'Serbian Dinar', 'invoicing' ),
452
-        'RUB' => __( 'Russian Ruble', 'invoicing' ),
453
-        'RWF' => __( 'Rwandan Franc', 'invoicing' ),
454
-        'SAR' => __( 'Saudi Riyal', 'invoicing' ),
455
-        'SBD' => __( 'Solomon Islands Dollar', 'invoicing' ),
456
-        'SCR' => __( 'Seychellois Rupee', 'invoicing' ),
457
-        'SDG' => __( 'Sudanese Pound', 'invoicing' ),
458
-        'SEK' => __( 'Swedish Krona', 'invoicing' ),
459
-        'SGD' => __( 'Singapore Dollar', 'invoicing' ),
460
-        'SHP' => __( 'Saint Helena Pound', 'invoicing' ),
461
-        'SLL' => __( 'Sierra Leonean Leone', 'invoicing' ),
462
-        'SOS' => __( 'Somali Shilling', 'invoicing' ),
463
-        'SRD' => __( 'Surinamese Dollar', 'invoicing' ),
464
-        'SSP' => __( 'South Sudanese Pound', 'invoicing' ),
465
-        'STD' => __( 'Sao Tomean Dobra', 'invoicing' ),
466
-        'SYP' => __( 'Syrian Pound', 'invoicing' ),
467
-        'SZL' => __( 'Swazi Lilangeni', 'invoicing' ),
468
-        'THB' => __( 'Thai Baht', 'invoicing' ),
469
-        'TJS' => __( 'Tajikistani Somoni', 'invoicing' ),
470
-        'TMT' => __( 'Turkmenistan Manat', 'invoicing' ),
471
-        'TND' => __( 'Tunisian Dinar', 'invoicing' ),
472
-        'TOP' => __( 'Tongan Pa&#x2bb;anga', 'invoicing' ),
473
-        'TRY' => __( 'Turkish Lira', 'invoicing' ),
474
-        'TTD' => __( 'Trinidad and Tobago Dollar', 'invoicing' ),
475
-        'TWD' => __( 'New Taiwan Dollar', 'invoicing' ),
476
-        'TZS' => __( 'Tanzanian Shilling', 'invoicing' ),
477
-        'UAH' => __( 'Ukrainian Hryvnia', 'invoicing' ),
478
-        'UGX' => __( 'Ugandan Shilling', 'invoicing' ),
479
-        'UYU' => __( 'Uruguayan Peso', 'invoicing' ),
480
-        'UZS' => __( 'Uzbekistani Som', 'invoicing' ),
481
-        'VEF' => __( 'Venezuelan Bol&iacute;var', 'invoicing' ),
482
-        'VND' => __( 'Vietnamese Dong', 'invoicing' ),
483
-        'VUV' => __( 'Vanuatu Vatu', 'invoicing' ),
484
-        'WST' => __( 'Samoan Tala', 'invoicing' ),
485
-        'XAF' => __( 'Central African CFA Franc', 'invoicing' ),
486
-        'XCD' => __( 'East Caribbean Dollar', 'invoicing' ),
487
-        'XOF' => __( 'West African CFA Franc', 'invoicing' ),
488
-        'XPF' => __( 'CFP Franc', 'invoicing' ),
489
-        'YER' => __( 'Yemeni Rial', 'invoicing' ),
490
-        'ZAR' => __( 'South African Rand', 'invoicing' ),
491
-        'ZMW' => __( 'Zambian Kwacha', 'invoicing' ),
331
+        'USD' => __('US Dollar', 'invoicing'),
332
+        'EUR' => __('Euro', 'invoicing'),
333
+        'GBP' => __('Pound Sterling', 'invoicing'),
334
+        'AED' => __('United Arab Emirates', 'invoicing'),
335
+        'AFN' => __('Afghan Afghani', 'invoicing'),
336
+        'ALL' => __('Albanian Lek', 'invoicing'),
337
+        'AMD' => __('Armenian Dram', 'invoicing'),
338
+        'ANG' => __('Netherlands Antillean Guilder', 'invoicing'),
339
+        'AOA' => __('Angolan Kwanza', 'invoicing'),
340
+        'ARS' => __('Argentine Peso', 'invoicing'),
341
+        'AUD' => __('Australian Dollar', 'invoicing'),
342
+        'AWG' => __('Aruban Florin', 'invoicing'),
343
+        'AZN' => __('Azerbaijani Manat', 'invoicing'),
344
+        'BAM' => __('Bosnia and Herzegovina Convertible Marka', 'invoicing'),
345
+        'BBD' => __('Barbadian Dollar', 'invoicing'),
346
+        'BDT' => __('Bangladeshi Taka', 'invoicing'),
347
+        'BGN' => __('Bulgarian Lev', 'invoicing'),
348
+        'BHD' => __('Bahraini Dinar', 'invoicing'),
349
+        'BIF' => __('Burundian Franc', 'invoicing'),
350
+        'BMD' => __('Bermudian Dollar', 'invoicing'),
351
+        'BND' => __('Brunei Dollar', 'invoicing'),
352
+        'BOB' => __('Bolivian Boliviano', 'invoicing'),
353
+        'BRL' => __('Brazilian Real', 'invoicing'),
354
+        'BSD' => __('Bahamian Dollar', 'invoicing'),
355
+        'BTC' => __('Bitcoin', 'invoicing'),
356
+        'BTN' => __('Bhutanese Ngultrum', 'invoicing'),
357
+        'BWP' => __('Botswana Pula', 'invoicing'),
358
+        'BYN' => __('Belarusian Ruble', 'invoicing'),
359
+        'BZD' => __('Belize Dollar', 'invoicing'),
360
+        'CAD' => __('Canadian Dollar', 'invoicing'),
361
+        'CDF' => __('Congolese Franc', 'invoicing'),
362
+        'CHF' => __('Swiss Franc', 'invoicing'),
363
+        'CLP' => __('Chilean Peso', 'invoicing'),
364
+        'CNY' => __('Chinese Yuan', 'invoicing'),
365
+        'COP' => __('Colombian Peso', 'invoicing'),
366
+        'CRC' => __('Costa Rican Colon', 'invoicing'),
367
+        'CUC' => __('Cuban Convertible Peso', 'invoicing'),
368
+        'CUP' => __('Cuban Peso', 'invoicing'),
369
+        'CVE' => __('Cape Verdean escudo', 'invoicing'),
370
+        'CZK' => __('Czech Koruna', 'invoicing'),
371
+        'DJF' => __('Djiboutian Franc', 'invoicing'),
372
+        'DKK' => __('Danish Krone', 'invoicing'),
373
+        'DOP' => __('Dominican Peso', 'invoicing'),
374
+        'DZD' => __('Algerian Dinar', 'invoicing'),
375
+        'EGP' => __('Egyptian Pound', 'invoicing'),
376
+        'ERN' => __('Eritrean Nakfa', 'invoicing'),
377
+        'ETB' => __('Ethiopian Irr', 'invoicing'),
378
+        'FJD' => __('Fijian Dollar', 'invoicing'),
379
+        'FKP' => __('Falkland Islands Pound', 'invoicing'),
380
+        'GEL' => __('Georgian Lari', 'invoicing'),
381
+        'GGP' => __('Guernsey Pound', 'invoicing'),
382
+        'GHS' => __('Ghana Cedi', 'invoicing'),
383
+        'GIP' => __('Gibraltar Pound', 'invoicing'),
384
+        'GMD' => __('Gambian Dalasi', 'invoicing'),
385
+        'GNF' => __('Guinean Franc', 'invoicing'),
386
+        'GTQ' => __('Guatemalan Quetzal', 'invoicing'),
387
+        'GYD' => __('Guyanese Dollar', 'invoicing'),
388
+        'HKD' => __('Hong Kong Dollar', 'invoicing'),
389
+        'HNL' => __('Honduran Lempira', 'invoicing'),
390
+        'HRK' => __('Croatian Kuna', 'invoicing'),
391
+        'HTG' => __('Haitian Gourde', 'invoicing'),
392
+        'HUF' => __('Hungarian Forint', 'invoicing'),
393
+        'IDR' => __('Indonesian Rupiah', 'invoicing'),
394
+        'ILS' => __('Israeli New Shekel', 'invoicing'),
395
+        'IMP' => __('Manx Pound', 'invoicing'),
396
+        'INR' => __('Indian Rupee', 'invoicing'),
397
+        'IQD' => __('Iraqi Dinar', 'invoicing'),
398
+        'IRR' => __('Iranian Rial', 'invoicing'),
399
+        'IRT' => __('Iranian Toman', 'invoicing'),
400
+        'ISK' => __('Icelandic Krona', 'invoicing'),
401
+        'JEP' => __('Jersey Pound', 'invoicing'),
402
+        'JMD' => __('Jamaican Dollar', 'invoicing'),
403
+        'JOD' => __('Jordanian Dinar', 'invoicing'),
404
+        'JPY' => __('Japanese Yen', 'invoicing'),
405
+        'KES' => __('Kenyan Shilling', 'invoicing'),
406
+        'KGS' => __('Kyrgyzstani Som', 'invoicing'),
407
+        'KHR' => __('Cambodian Riel', 'invoicing'),
408
+        'KMF' => __('Comorian Franc', 'invoicing'),
409
+        'KPW' => __('North Korean Won', 'invoicing'),
410
+        'KRW' => __('South Korean Won', 'invoicing'),
411
+        'KWD' => __('Kuwaiti Dinar', 'invoicing'),
412
+        'KYD' => __('Cayman Islands Dollar', 'invoicing'),
413
+        'KZT' => __('Kazakhstani Tenge', 'invoicing'),
414
+        'LAK' => __('Lao Kip', 'invoicing'),
415
+        'LBP' => __('Lebanese Pound', 'invoicing'),
416
+        'LKR' => __('Sri Lankan Rupee', 'invoicing'),
417
+        'LRD' => __('Liberian Dollar', 'invoicing'),
418
+        'LSL' => __('Lesotho Loti', 'invoicing'),
419
+        'LYD' => __('Libyan Dinar', 'invoicing'),
420
+        'MAD' => __('Moroccan Dirham', 'invoicing'),
421
+        'MDL' => __('Moldovan Leu', 'invoicing'),
422
+        'MGA' => __('Malagasy Ariary', 'invoicing'),
423
+        'MKD' => __('Macedonian Denar', 'invoicing'),
424
+        'MMK' => __('Burmese Kyat', 'invoicing'),
425
+        'MNT' => __('Mongolian Tughrik', 'invoicing'),
426
+        'MOP' => __('Macanese Pataca', 'invoicing'),
427
+        'MRO' => __('Mauritanian Ouguiya', 'invoicing'),
428
+        'MUR' => __('Mauritian Rupee', 'invoicing'),
429
+        'MVR' => __('Maldivian Rufiyaa', 'invoicing'),
430
+        'MWK' => __('Malawian Kwacha', 'invoicing'),
431
+        'MXN' => __('Mexican Peso', 'invoicing'),
432
+        'MYR' => __('Malaysian Ringgit', 'invoicing'),
433
+        'MZN' => __('Mozambican Metical', 'invoicing'),
434
+        'NAD' => __('Namibian Dollar', 'invoicing'),
435
+        'NGN' => __('Nigerian Naira', 'invoicing'),
436
+        'NIO' => __('Nicaraguan Cordoba', 'invoicing'),
437
+        'NOK' => __('Norwegian Krone', 'invoicing'),
438
+        'NPR' => __('Nepalese Rupee', 'invoicing'),
439
+        'NZD' => __('New Zealand Dollar', 'invoicing'),
440
+        'OMR' => __('Omani Rial', 'invoicing'),
441
+        'PAB' => __('Panamanian Balboa', 'invoicing'),
442
+        'PEN' => __('Peruvian Nuevo Sol', 'invoicing'),
443
+        'PGK' => __('Papua New Guinean Kina', 'invoicing'),
444
+        'PHP' => __('Philippine Peso', 'invoicing'),
445
+        'PKR' => __('Pakistani Rupee', 'invoicing'),
446
+        'PLN' => __('Polish Zloty', 'invoicing'),
447
+        'PRB' => __('Transnistrian Ruble', 'invoicing'),
448
+        'PYG' => __('Paraguayan Guarani', 'invoicing'),
449
+        'QAR' => __('Qatari Riyal', 'invoicing'),
450
+        'RON' => __('Romanian Leu', 'invoicing'),
451
+        'RSD' => __('Serbian Dinar', 'invoicing'),
452
+        'RUB' => __('Russian Ruble', 'invoicing'),
453
+        'RWF' => __('Rwandan Franc', 'invoicing'),
454
+        'SAR' => __('Saudi Riyal', 'invoicing'),
455
+        'SBD' => __('Solomon Islands Dollar', 'invoicing'),
456
+        'SCR' => __('Seychellois Rupee', 'invoicing'),
457
+        'SDG' => __('Sudanese Pound', 'invoicing'),
458
+        'SEK' => __('Swedish Krona', 'invoicing'),
459
+        'SGD' => __('Singapore Dollar', 'invoicing'),
460
+        'SHP' => __('Saint Helena Pound', 'invoicing'),
461
+        'SLL' => __('Sierra Leonean Leone', 'invoicing'),
462
+        'SOS' => __('Somali Shilling', 'invoicing'),
463
+        'SRD' => __('Surinamese Dollar', 'invoicing'),
464
+        'SSP' => __('South Sudanese Pound', 'invoicing'),
465
+        'STD' => __('Sao Tomean Dobra', 'invoicing'),
466
+        'SYP' => __('Syrian Pound', 'invoicing'),
467
+        'SZL' => __('Swazi Lilangeni', 'invoicing'),
468
+        'THB' => __('Thai Baht', 'invoicing'),
469
+        'TJS' => __('Tajikistani Somoni', 'invoicing'),
470
+        'TMT' => __('Turkmenistan Manat', 'invoicing'),
471
+        'TND' => __('Tunisian Dinar', 'invoicing'),
472
+        'TOP' => __('Tongan Pa&#x2bb;anga', 'invoicing'),
473
+        'TRY' => __('Turkish Lira', 'invoicing'),
474
+        'TTD' => __('Trinidad and Tobago Dollar', 'invoicing'),
475
+        'TWD' => __('New Taiwan Dollar', 'invoicing'),
476
+        'TZS' => __('Tanzanian Shilling', 'invoicing'),
477
+        'UAH' => __('Ukrainian Hryvnia', 'invoicing'),
478
+        'UGX' => __('Ugandan Shilling', 'invoicing'),
479
+        'UYU' => __('Uruguayan Peso', 'invoicing'),
480
+        'UZS' => __('Uzbekistani Som', 'invoicing'),
481
+        'VEF' => __('Venezuelan Bol&iacute;var', 'invoicing'),
482
+        'VND' => __('Vietnamese Dong', 'invoicing'),
483
+        'VUV' => __('Vanuatu Vatu', 'invoicing'),
484
+        'WST' => __('Samoan Tala', 'invoicing'),
485
+        'XAF' => __('Central African CFA Franc', 'invoicing'),
486
+        'XCD' => __('East Caribbean Dollar', 'invoicing'),
487
+        'XOF' => __('West African CFA Franc', 'invoicing'),
488
+        'XPF' => __('CFP Franc', 'invoicing'),
489
+        'YER' => __('Yemeni Rial', 'invoicing'),
490
+        'ZAR' => __('South African Rand', 'invoicing'),
491
+        'ZMW' => __('Zambian Kwacha', 'invoicing'),
492 492
     );
493 493
     
494 494
     //asort( $currencies ); // this
495 495
 
496
-    return apply_filters( 'wpinv_currencies', $currencies );
496
+    return apply_filters('wpinv_currencies', $currencies);
497 497
 }
498 498
 
499
-function wpinv_price( $amount = '', $currency = '' ) {
500
-    if( empty( $currency ) ) {
499
+function wpinv_price($amount = '', $currency = '') {
500
+    if (empty($currency)) {
501 501
         $currency = wpinv_get_currency();
502 502
     }
503 503
 
@@ -505,14 +505,14 @@  discard block
 block discarded – undo
505 505
 
506 506
     $negative = $amount < 0;
507 507
 
508
-    if ( $negative ) {
509
-        $amount = substr( $amount, 1 );
508
+    if ($negative) {
509
+        $amount = substr($amount, 1);
510 510
     }
511 511
 
512
-    $symbol = wpinv_currency_symbol( $currency );
512
+    $symbol = wpinv_currency_symbol($currency);
513 513
 
514
-    if ( $position == 'left' || $position == 'left_space' ) {
515
-        switch ( $currency ) {
514
+    if ($position == 'left' || $position == 'left_space') {
515
+        switch ($currency) {
516 516
             case "GBP" :
517 517
             case "BRL" :
518 518
             case "EUR" :
@@ -524,15 +524,15 @@  discard block
 block discarded – undo
524 524
             case "NZD" :
525 525
             case "SGD" :
526 526
             case "JPY" :
527
-                $price = $position == 'left_space' ? $symbol . ' ' .  $amount : $symbol . $amount;
527
+                $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount;
528 528
                 break;
529 529
             default :
530 530
                 //$price = $currency . ' ' . $amount;
531
-                $price = $position == 'left_space' ? $symbol . ' ' .  $amount : $symbol . $amount;
531
+                $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount;
532 532
                 break;
533 533
         }
534 534
     } else {
535
-        switch ( $currency ) {
535
+        switch ($currency) {
536 536
             case "GBP" :
537 537
             case "BRL" :
538 538
             case "EUR" :
@@ -543,83 +543,83 @@  discard block
 block discarded – undo
543 543
             case "MXN" :
544 544
             case "SGD" :
545 545
             case "JPY" :
546
-                $price = $position == 'right_space' ? $amount . ' ' .  $symbol : $amount . $symbol;
546
+                $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol;
547 547
                 break;
548 548
             default :
549 549
                 //$price = $amount . ' ' . $currency;
550
-                $price = $position == 'right_space' ? $amount . ' ' .  $symbol : $amount . $symbol;
550
+                $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol;
551 551
                 break;
552 552
         }
553 553
     }
554 554
     
555
-    if ( $negative ) {
555
+    if ($negative) {
556 556
         $price = '-' . $price;
557 557
     }
558 558
     
559
-    $price = apply_filters( 'wpinv_' . strtolower( $currency ) . '_currency_filter_' . $position, $price, $currency, $amount );
559
+    $price = apply_filters('wpinv_' . strtolower($currency) . '_currency_filter_' . $position, $price, $currency, $amount);
560 560
 
561 561
     return $price;
562 562
 }
563 563
 
564
-function wpinv_format_amount( $amount, $decimals = NULL, $calculate = false ) {
564
+function wpinv_format_amount($amount, $decimals = NULL, $calculate = false) {
565 565
     $thousands_sep = wpinv_thousands_separator();
566 566
     $decimal_sep   = wpinv_decimal_separator();
567 567
 
568
-    if ( $decimals === NULL ) {
568
+    if ($decimals === NULL) {
569 569
         $decimals = wpinv_decimals();
570 570
     }
571 571
 
572
-    if ( $decimal_sep == ',' && false !== ( $sep_found = strpos( $amount, $decimal_sep ) ) ) {
573
-        $whole = substr( $amount, 0, $sep_found );
574
-        $part = substr( $amount, $sep_found + 1, ( strlen( $amount ) - 1 ) );
572
+    if ($decimal_sep == ',' && false !== ($sep_found = strpos($amount, $decimal_sep))) {
573
+        $whole = substr($amount, 0, $sep_found);
574
+        $part = substr($amount, $sep_found + 1, (strlen($amount) - 1));
575 575
         $amount = $whole . '.' . $part;
576 576
     }
577 577
 
578
-    if ( $thousands_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) {
579
-        $amount = str_replace( ',', '', $amount );
578
+    if ($thousands_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) {
579
+        $amount = str_replace(',', '', $amount);
580 580
     }
581 581
 
582
-    if ( $thousands_sep == ' ' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) {
583
-        $amount = str_replace( ' ', '', $amount );
582
+    if ($thousands_sep == ' ' && false !== ($found = strpos($amount, $thousands_sep))) {
583
+        $amount = str_replace(' ', '', $amount);
584 584
     }
585 585
 
586
-    if ( empty( $amount ) ) {
586
+    if (empty($amount)) {
587 587
         $amount = 0;
588 588
     }
589 589
     
590
-    $decimals  = apply_filters( 'wpinv_amount_format_decimals', $decimals ? $decimals : 0, $amount, $calculate );
591
-    $formatted = number_format( (float)$amount, $decimals, $decimal_sep, $thousands_sep );
590
+    $decimals  = apply_filters('wpinv_amount_format_decimals', $decimals ? $decimals : 0, $amount, $calculate);
591
+    $formatted = number_format((float)$amount, $decimals, $decimal_sep, $thousands_sep);
592 592
     
593
-    if ( $calculate ) {
594
-        if ( $thousands_sep === "," ) {
595
-            $formatted = str_replace( ",", "", $formatted );
593
+    if ($calculate) {
594
+        if ($thousands_sep === ",") {
595
+            $formatted = str_replace(",", "", $formatted);
596 596
         }
597 597
         
598
-        if ( $decimal_sep === "," ) {
599
-            $formatted = str_replace( ",", ".", $formatted );
598
+        if ($decimal_sep === ",") {
599
+            $formatted = str_replace(",", ".", $formatted);
600 600
         }
601 601
     }
602 602
 
603
-    return apply_filters( 'wpinv_amount_format', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $calculate );
603
+    return apply_filters('wpinv_amount_format', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $calculate);
604 604
 }
605
-add_filter( 'wpinv_amount_format_decimals', 'wpinv_currency_decimal_filter', 10, 1 );
605
+add_filter('wpinv_amount_format_decimals', 'wpinv_currency_decimal_filter', 10, 1);
606 606
 
607
-function wpinv_sanitize_key( $key ) {
607
+function wpinv_sanitize_key($key) {
608 608
     $raw_key = $key;
609
-    $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key );
609
+    $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key);
610 610
 
611
-    return apply_filters( 'wpinv_sanitize_key', $key, $raw_key );
611
+    return apply_filters('wpinv_sanitize_key', $key, $raw_key);
612 612
 }
613 613
 
614
-function wpinv_get_file_extension( $str ) {
615
-    $parts = explode( '.', $str );
616
-    return end( $parts );
614
+function wpinv_get_file_extension($str) {
615
+    $parts = explode('.', $str);
616
+    return end($parts);
617 617
 }
618 618
 
619
-function wpinv_string_is_image_url( $str ) {
620
-    $ext = wpinv_get_file_extension( $str );
619
+function wpinv_string_is_image_url($str) {
620
+    $ext = wpinv_get_file_extension($str);
621 621
 
622
-    switch ( strtolower( $ext ) ) {
622
+    switch (strtolower($ext)) {
623 623
         case 'jpeg';
624 624
         case 'jpg';
625 625
             $return = true;
@@ -635,32 +635,32 @@  discard block
 block discarded – undo
635 635
             break;
636 636
     }
637 637
 
638
-    return (bool)apply_filters( 'wpinv_string_is_image', $return, $str );
638
+    return (bool)apply_filters('wpinv_string_is_image', $return, $str);
639 639
 }
640 640
 
641
-function wpinv_error_log( $log, $title = '', $file = '', $line = '', $exit = false ) {
642
-    $should_log = apply_filters( 'wpinv_log_errors', WP_DEBUG );
641
+function wpinv_error_log($log, $title = '', $file = '', $line = '', $exit = false) {
642
+    $should_log = apply_filters('wpinv_log_errors', WP_DEBUG);
643 643
     
644
-    if ( true === $should_log ) {
644
+    if (true === $should_log) {
645 645
         $label = '';
646
-        if ( $file && $file !== '' ) {
647
-            $label .= basename( $file ) . ( $line ? '(' . $line . ')' : '' );
646
+        if ($file && $file !== '') {
647
+            $label .= basename($file) . ($line ? '(' . $line . ')' : '');
648 648
         }
649 649
         
650
-        if ( $title && $title !== '' ) {
650
+        if ($title && $title !== '') {
651 651
             $label = $label !== '' ? $label . ' ' : '';
652 652
             $label .= $title . ' ';
653 653
         }
654 654
         
655
-        $label = $label !== '' ? trim( $label ) . ' : ' : '';
655
+        $label = $label !== '' ? trim($label) . ' : ' : '';
656 656
         
657
-        if ( is_array( $log ) || is_object( $log ) ) {
658
-            error_log( $label . print_r( $log, true ) );
657
+        if (is_array($log) || is_object($log)) {
658
+            error_log($label . print_r($log, true));
659 659
         } else {
660
-            error_log( $label . $log );
660
+            error_log($label . $log);
661 661
         }
662 662
         
663
-        if ( $exit ) {
663
+        if ($exit) {
664 664
             exit;
665 665
         }
666 666
     }
@@ -668,65 +668,65 @@  discard block
 block discarded – undo
668 668
 
669 669
 function wpinv_is_ajax_disabled() {
670 670
     $retval = false;
671
-    return apply_filters( 'wpinv_is_ajax_disabled', $retval );
671
+    return apply_filters('wpinv_is_ajax_disabled', $retval);
672 672
 }
673 673
 
674
-function wpinv_get_current_page_url( $nocache = false ) {
674
+function wpinv_get_current_page_url($nocache = false) {
675 675
     global $wp;
676 676
 
677
-    if ( get_option( 'permalink_structure' ) ) {
678
-        $base = trailingslashit( home_url( $wp->request ) );
677
+    if (get_option('permalink_structure')) {
678
+        $base = trailingslashit(home_url($wp->request));
679 679
     } else {
680
-        $base = add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) );
681
-        $base = remove_query_arg( array( 'post_type', 'name' ), $base );
680
+        $base = add_query_arg($wp->query_string, '', trailingslashit(home_url($wp->request)));
681
+        $base = remove_query_arg(array('post_type', 'name'), $base);
682 682
     }
683 683
 
684 684
     $scheme = is_ssl() ? 'https' : 'http';
685
-    $uri    = set_url_scheme( $base, $scheme );
685
+    $uri    = set_url_scheme($base, $scheme);
686 686
 
687
-    if ( is_front_page() ) {
688
-        $uri = home_url( '/' );
689
-    } elseif ( wpinv_is_checkout( array(), false ) ) {
687
+    if (is_front_page()) {
688
+        $uri = home_url('/');
689
+    } elseif (wpinv_is_checkout(array(), false)) {
690 690
         $uri = wpinv_get_checkout_uri();
691 691
     }
692 692
 
693
-    $uri = apply_filters( 'wpinv_get_current_page_url', $uri );
693
+    $uri = apply_filters('wpinv_get_current_page_url', $uri);
694 694
 
695
-    if ( $nocache ) {
696
-        $uri = wpinv_add_cache_busting( $uri );
695
+    if ($nocache) {
696
+        $uri = wpinv_add_cache_busting($uri);
697 697
     }
698 698
 
699 699
     return $uri;
700 700
 }
701 701
 
702 702
 function wpinv_get_php_arg_separator_output() {
703
-	return ini_get( 'arg_separator.output' );
703
+	return ini_get('arg_separator.output');
704 704
 }
705 705
 
706
-function wpinv_rgb_from_hex( $color ) {
707
-    $color = str_replace( '#', '', $color );
706
+function wpinv_rgb_from_hex($color) {
707
+    $color = str_replace('#', '', $color);
708 708
     // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF"
709
-    $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color );
709
+    $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color);
710 710
 
711 711
     $rgb      = array();
712
-    $rgb['R'] = hexdec( $color{0}.$color{1} );
713
-    $rgb['G'] = hexdec( $color{2}.$color{3} );
714
-    $rgb['B'] = hexdec( $color{4}.$color{5} );
712
+    $rgb['R'] = hexdec($color{0} . $color{1} );
713
+    $rgb['G'] = hexdec($color{2} . $color{3} );
714
+    $rgb['B'] = hexdec($color{4} . $color{5} );
715 715
 
716 716
     return $rgb;
717 717
 }
718 718
 
719
-function wpinv_hex_darker( $color, $factor = 30 ) {
720
-    $base  = wpinv_rgb_from_hex( $color );
719
+function wpinv_hex_darker($color, $factor = 30) {
720
+    $base  = wpinv_rgb_from_hex($color);
721 721
     $color = '#';
722 722
 
723
-    foreach ( $base as $k => $v ) {
723
+    foreach ($base as $k => $v) {
724 724
         $amount      = $v / 100;
725
-        $amount      = round( $amount * $factor );
725
+        $amount      = round($amount * $factor);
726 726
         $new_decimal = $v - $amount;
727 727
 
728
-        $new_hex_component = dechex( $new_decimal );
729
-        if ( strlen( $new_hex_component ) < 2 ) {
728
+        $new_hex_component = dechex($new_decimal);
729
+        if (strlen($new_hex_component) < 2) {
730 730
             $new_hex_component = "0" . $new_hex_component;
731 731
         }
732 732
         $color .= $new_hex_component;
@@ -735,18 +735,18 @@  discard block
 block discarded – undo
735 735
     return $color;
736 736
 }
737 737
 
738
-function wpinv_hex_lighter( $color, $factor = 30 ) {
739
-    $base  = wpinv_rgb_from_hex( $color );
738
+function wpinv_hex_lighter($color, $factor = 30) {
739
+    $base  = wpinv_rgb_from_hex($color);
740 740
     $color = '#';
741 741
 
742
-    foreach ( $base as $k => $v ) {
742
+    foreach ($base as $k => $v) {
743 743
         $amount      = 255 - $v;
744 744
         $amount      = $amount / 100;
745
-        $amount      = round( $amount * $factor );
745
+        $amount      = round($amount * $factor);
746 746
         $new_decimal = $v + $amount;
747 747
 
748
-        $new_hex_component = dechex( $new_decimal );
749
-        if ( strlen( $new_hex_component ) < 2 ) {
748
+        $new_hex_component = dechex($new_decimal);
749
+        if (strlen($new_hex_component) < 2) {
750 750
             $new_hex_component = "0" . $new_hex_component;
751 751
         }
752 752
         $color .= $new_hex_component;
@@ -755,22 +755,22 @@  discard block
 block discarded – undo
755 755
     return $color;
756 756
 }
757 757
 
758
-function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) {
759
-    $hex = str_replace( '#', '', $color );
758
+function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') {
759
+    $hex = str_replace('#', '', $color);
760 760
 
761
-    $c_r = hexdec( substr( $hex, 0, 2 ) );
762
-    $c_g = hexdec( substr( $hex, 2, 2 ) );
763
-    $c_b = hexdec( substr( $hex, 4, 2 ) );
761
+    $c_r = hexdec(substr($hex, 0, 2));
762
+    $c_g = hexdec(substr($hex, 2, 2));
763
+    $c_b = hexdec(substr($hex, 4, 2));
764 764
 
765
-    $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000;
765
+    $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000;
766 766
 
767 767
     return $brightness > 155 ? $dark : $light;
768 768
 }
769 769
 
770
-function wpinv_format_hex( $hex ) {
771
-    $hex = trim( str_replace( '#', '', $hex ) );
770
+function wpinv_format_hex($hex) {
771
+    $hex = trim(str_replace('#', '', $hex));
772 772
 
773
-    if ( strlen( $hex ) == 3 ) {
773
+    if (strlen($hex) == 3) {
774 774
         $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2];
775 775
     }
776 776
 
@@ -790,12 +790,12 @@  discard block
 block discarded – undo
790 790
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
791 791
  * @return string
792 792
  */
793
-function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) {
794
-    if ( function_exists( 'mb_strimwidth' ) ) {
795
-        return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding );
793
+function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') {
794
+    if (function_exists('mb_strimwidth')) {
795
+        return mb_strimwidth($str, $start, $width, $trimmaker, $encoding);
796 796
     }
797 797
     
798
-    return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker;
798
+    return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker;
799 799
 }
800 800
 
801 801
 /**
@@ -807,28 +807,28 @@  discard block
 block discarded – undo
807 807
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
808 808
  * @return int Returns the number of characters in string.
809 809
  */
810
-function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) {
811
-    if ( function_exists( 'mb_strlen' ) ) {
812
-        return mb_strlen( $str, $encoding );
810
+function wpinv_utf8_strlen($str, $encoding = 'UTF-8') {
811
+    if (function_exists('mb_strlen')) {
812
+        return mb_strlen($str, $encoding);
813 813
     }
814 814
         
815
-    return strlen( $str );
815
+    return strlen($str);
816 816
 }
817 817
 
818
-function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) {
819
-    if ( function_exists( 'mb_strtolower' ) ) {
820
-        return mb_strtolower( $str, $encoding );
818
+function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') {
819
+    if (function_exists('mb_strtolower')) {
820
+        return mb_strtolower($str, $encoding);
821 821
     }
822 822
     
823
-    return strtolower( $str );
823
+    return strtolower($str);
824 824
 }
825 825
 
826
-function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) {
827
-    if ( function_exists( 'mb_strtoupper' ) ) {
828
-        return mb_strtoupper( $str, $encoding );
826
+function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') {
827
+    if (function_exists('mb_strtoupper')) {
828
+        return mb_strtoupper($str, $encoding);
829 829
     }
830 830
     
831
-    return strtoupper( $str );
831
+    return strtoupper($str);
832 832
 }
833 833
 
834 834
 /**
@@ -842,12 +842,12 @@  discard block
 block discarded – undo
842 842
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
843 843
  * @return int Returns the position of the first occurrence of search in the string.
844 844
  */
845
-function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
846
-    if ( function_exists( 'mb_strpos' ) ) {
847
-        return mb_strpos( $str, $find, $offset, $encoding );
845
+function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
846
+    if (function_exists('mb_strpos')) {
847
+        return mb_strpos($str, $find, $offset, $encoding);
848 848
     }
849 849
         
850
-    return strpos( $str, $find, $offset );
850
+    return strpos($str, $find, $offset);
851 851
 }
852 852
 
853 853
 /**
@@ -861,12 +861,12 @@  discard block
 block discarded – undo
861 861
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
862 862
  * @return int Returns the position of the last occurrence of search.
863 863
  */
864
-function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
865
-    if ( function_exists( 'mb_strrpos' ) ) {
866
-        return mb_strrpos( $str, $find, $offset, $encoding );
864
+function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
865
+    if (function_exists('mb_strrpos')) {
866
+        return mb_strrpos($str, $find, $offset, $encoding);
867 867
     }
868 868
         
869
-    return strrpos( $str, $find, $offset );
869
+    return strrpos($str, $find, $offset);
870 870
 }
871 871
 
872 872
 /**
@@ -881,16 +881,16 @@  discard block
 block discarded – undo
881 881
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
882 882
  * @return string
883 883
  */
884
-function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) {
885
-    if ( function_exists( 'mb_substr' ) ) {
886
-        if ( $length === null ) {
887
-            return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding );
884
+function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') {
885
+    if (function_exists('mb_substr')) {
886
+        if ($length === null) {
887
+            return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding);
888 888
         } else {
889
-            return mb_substr( $str, $start, $length, $encoding );
889
+            return mb_substr($str, $start, $length, $encoding);
890 890
         }
891 891
     }
892 892
         
893
-    return substr( $str, $start, $length );
893
+    return substr($str, $start, $length);
894 894
 }
895 895
 
896 896
 /**
@@ -902,48 +902,48 @@  discard block
 block discarded – undo
902 902
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
903 903
  * @return string The width of string.
904 904
  */
905
-function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) {
906
-    if ( function_exists( 'mb_strwidth' ) ) {
907
-        return mb_strwidth( $str, $encoding );
905
+function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') {
906
+    if (function_exists('mb_strwidth')) {
907
+        return mb_strwidth($str, $encoding);
908 908
     }
909 909
     
910
-    return wpinv_utf8_strlen( $str, $encoding );
910
+    return wpinv_utf8_strlen($str, $encoding);
911 911
 }
912 912
 
913
-function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) {
914
-    if ( function_exists( 'mb_strlen' ) ) {
915
-        $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding );
913
+function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') {
914
+    if (function_exists('mb_strlen')) {
915
+        $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding);
916 916
         $str_end = "";
917 917
         
918
-        if ( $lower_str_end ) {
919
-            $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding );
918
+        if ($lower_str_end) {
919
+            $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding);
920 920
         } else {
921
-            $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding );
921
+            $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding);
922 922
         }
923 923
 
924 924
         return $first_letter . $str_end;
925 925
     }
926 926
     
927
-    return ucfirst( $str );
927
+    return ucfirst($str);
928 928
 }
929 929
 
930
-function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) {
931
-    if ( function_exists( 'mb_convert_case' ) ) {
932
-        return mb_convert_case( $str, MB_CASE_TITLE, $encoding );
930
+function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') {
931
+    if (function_exists('mb_convert_case')) {
932
+        return mb_convert_case($str, MB_CASE_TITLE, $encoding);
933 933
     }
934 934
     
935
-    return ucwords( $str );
935
+    return ucwords($str);
936 936
 }
937 937
 
938
-function wpinv_period_in_days( $period, $unit ) {
939
-    $period = absint( $period );
938
+function wpinv_period_in_days($period, $unit) {
939
+    $period = absint($period);
940 940
     
941
-    if ( $period > 0 ) {
942
-        if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) {
941
+    if ($period > 0) {
942
+        if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) {
943 943
             $period = $period * 7;
944
-        } else if ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) {
944
+        } else if (in_array(strtolower($unit), array('m', 'month', 'months'))) {
945 945
             $period = $period * 30;
946
-        } else if ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) {
946
+        } else if (in_array(strtolower($unit), array('y', 'year', 'years'))) {
947 947
             $period = $period * 365;
948 948
         }
949 949
     }
@@ -951,14 +951,14 @@  discard block
 block discarded – undo
951 951
     return $period;
952 952
 }
953 953
 
954
-function wpinv_cal_days_in_month( $calendar, $month, $year ) {
955
-    if ( function_exists( 'cal_days_in_month' ) ) {
956
-        return cal_days_in_month( $calendar, $month, $year );
954
+function wpinv_cal_days_in_month($calendar, $month, $year) {
955
+    if (function_exists('cal_days_in_month')) {
956
+        return cal_days_in_month($calendar, $month, $year);
957 957
     }
958 958
 
959 959
     // Fallback in case the calendar extension is not loaded in PHP
960 960
     // Only supports Gregorian calendar
961
-    return date( 't', mktime( 0, 0, 0, $month, 1, $year ) );
961
+    return date('t', mktime(0, 0, 0, $month, 1, $year));
962 962
 }
963 963
 
964 964
 /**
@@ -969,11 +969,11 @@  discard block
 block discarded – undo
969 969
  *
970 970
  * @return string
971 971
  */
972
-function wpi_help_tip( $tip, $allow_html = false ) {
973
-    if ( $allow_html ) {
974
-        $tip = wpi_sanitize_tooltip( $tip );
972
+function wpi_help_tip($tip, $allow_html = false) {
973
+    if ($allow_html) {
974
+        $tip = wpi_sanitize_tooltip($tip);
975 975
     } else {
976
-        $tip = esc_attr( $tip );
976
+        $tip = esc_attr($tip);
977 977
     }
978 978
 
979 979
     return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
@@ -987,8 +987,8 @@  discard block
 block discarded – undo
987 987
  * @param string $var
988 988
  * @return string
989 989
  */
990
-function wpi_sanitize_tooltip( $var ) {
991
-    return htmlspecialchars( wp_kses( html_entity_decode( $var ), array(
990
+function wpi_sanitize_tooltip($var) {
991
+    return htmlspecialchars(wp_kses(html_entity_decode($var), array(
992 992
         'br'     => array(),
993 993
         'em'     => array(),
994 994
         'strong' => array(),
@@ -998,7 +998,7 @@  discard block
 block discarded – undo
998 998
         'li'     => array(),
999 999
         'ol'     => array(),
1000 1000
         'p'      => array(),
1001
-    ) ) );
1001
+    )));
1002 1002
 }
1003 1003
 
1004 1004
 /**
@@ -1008,7 +1008,7 @@  discard block
 block discarded – undo
1008 1008
  */
1009 1009
 function wpinv_get_screen_ids() {
1010 1010
 
1011
-    $screen_id = sanitize_title( __( 'Invoicing', 'invoicing' ) );
1011
+    $screen_id = sanitize_title(__('Invoicing', 'invoicing'));
1012 1012
 
1013 1013
     $screen_ids = array(
1014 1014
         'toplevel_page_' . $screen_id,
@@ -1026,5 +1026,5 @@  discard block
 block discarded – undo
1026 1026
         'invoicing_page_wpi-addons',
1027 1027
     );
1028 1028
 
1029
-    return apply_filters( 'wpinv_screen_ids', $screen_ids );
1029
+    return apply_filters('wpinv_screen_ids', $screen_ids);
1030 1030
 }
1031 1031
\ No newline at end of file
Please login to merge, or discard this patch.
includes/wpinv-email-functions.php 1 patch
Spacing   +582 added lines, -582 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@  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
 function wpinv_init_transactional_emails() {
15
-    $email_actions = apply_filters( 'wpinv_email_actions', array(
15
+    $email_actions = apply_filters('wpinv_email_actions', array(
16 16
         'wpinv_status_wpi-pending_to_wpi-processing',
17 17
         'wpinv_status_wpi-pending_to_publish',
18 18
         'wpinv_status_wpi-pending_to_wpi-cancelled',
@@ -30,381 +30,381 @@  discard block
 block discarded – undo
30 30
         'wpinv_fully_refunded',
31 31
         'wpinv_partially_refunded',
32 32
         'wpinv_new_invoice_note'
33
-    ) );
33
+    ));
34 34
 
35
-    foreach ( $email_actions as $action ) {
36
-        add_action( $action, 'wpinv_send_transactional_email', 10, 10 );
35
+    foreach ($email_actions as $action) {
36
+        add_action($action, 'wpinv_send_transactional_email', 10, 10);
37 37
     }
38 38
 }
39
-add_action( 'init', 'wpinv_init_transactional_emails' );
39
+add_action('init', 'wpinv_init_transactional_emails');
40 40
 
41 41
 // New invoice email
42
-add_action( 'wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_new_invoice_notification' );
43
-add_action( 'wpinv_status_wpi-pending_to_publish_notification', 'wpinv_new_invoice_notification' );
44
-add_action( 'wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_new_invoice_notification' );
45
-add_action( 'wpinv_status_wpi-failed_to_wpi-processing_notification', 'wpinv_new_invoice_notification' );
46
-add_action( 'wpinv_status_wpi-failed_to_publish_notification', 'wpinv_new_invoice_notification' );
47
-add_action( 'wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_new_invoice_notification' );
42
+add_action('wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_new_invoice_notification');
43
+add_action('wpinv_status_wpi-pending_to_publish_notification', 'wpinv_new_invoice_notification');
44
+add_action('wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_new_invoice_notification');
45
+add_action('wpinv_status_wpi-failed_to_wpi-processing_notification', 'wpinv_new_invoice_notification');
46
+add_action('wpinv_status_wpi-failed_to_publish_notification', 'wpinv_new_invoice_notification');
47
+add_action('wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_new_invoice_notification');
48 48
 
49 49
 // Cancelled invoice email
50
-add_action( 'wpinv_status_wpi-pending_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification' );
51
-add_action( 'wpinv_status_wpi-onhold_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification' );
50
+add_action('wpinv_status_wpi-pending_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification');
51
+add_action('wpinv_status_wpi-onhold_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification');
52 52
 
53 53
 // Failed invoice email
54
-add_action( 'wpinv_status_wpi-pending_to_wpi-failed_notification', 'wpinv_failed_invoice_notification' );
55
-add_action( 'wpinv_status_wpi-onhold_to_wpi-failed_notification', 'wpinv_failed_invoice_notification' );
54
+add_action('wpinv_status_wpi-pending_to_wpi-failed_notification', 'wpinv_failed_invoice_notification');
55
+add_action('wpinv_status_wpi-onhold_to_wpi-failed_notification', 'wpinv_failed_invoice_notification');
56 56
 
57 57
 // On hold invoice email
58
-add_action( 'wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification' );
59
-add_action( 'wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification' );
58
+add_action('wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification');
59
+add_action('wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification');
60 60
 
61 61
 // Processing invoice email
62
-add_action( 'wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_processing_invoice_notification' );
62
+add_action('wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_processing_invoice_notification');
63 63
 
64 64
 // Paid invoice email
65
-add_action( 'wpinv_status_publish_notification', 'wpinv_completed_invoice_notification' );
65
+add_action('wpinv_status_publish_notification', 'wpinv_completed_invoice_notification');
66 66
 
67 67
 // Refunded invoice email
68
-add_action( 'wpinv_fully_refunded_notification', 'wpinv_fully_refunded_notification' );
69
-add_action( 'wpinv_partially_refunded_notification', 'wpinv_partially_refunded_notification' );
70
-add_action( 'wpinv_status_publish_to_wpi-refunded_notification', 'wpinv_fully_refunded_notification' );
71
-add_action( 'wpinv_status_wpi-processing_to_wpi-refunded_notification', 'wpinv_fully_refunded_notification' );
68
+add_action('wpinv_fully_refunded_notification', 'wpinv_fully_refunded_notification');
69
+add_action('wpinv_partially_refunded_notification', 'wpinv_partially_refunded_notification');
70
+add_action('wpinv_status_publish_to_wpi-refunded_notification', 'wpinv_fully_refunded_notification');
71
+add_action('wpinv_status_wpi-processing_to_wpi-refunded_notification', 'wpinv_fully_refunded_notification');
72 72
 
73 73
 // Invoice note
74
-add_action( 'wpinv_new_invoice_note_notification', 'wpinv_new_invoice_note_notification' );
74
+add_action('wpinv_new_invoice_note_notification', 'wpinv_new_invoice_note_notification');
75 75
 
76
-add_action( 'wpinv_email_header', 'wpinv_email_header' );
77
-add_action( 'wpinv_email_footer', 'wpinv_email_footer' );
78
-add_action( 'wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3 );
79
-add_action( 'wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3 );
80
-add_action( 'wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3 );
76
+add_action('wpinv_email_header', 'wpinv_email_header');
77
+add_action('wpinv_email_footer', 'wpinv_email_footer');
78
+add_action('wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3);
79
+add_action('wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3);
80
+add_action('wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3);
81 81
 
82 82
 function wpinv_send_transactional_email() {
83 83
     $args       = func_get_args();
84 84
     $function   = current_filter() . '_notification';
85
-    do_action_ref_array( $function, $args );
85
+    do_action_ref_array($function, $args);
86 86
 }
87 87
 
88
-function wpinv_new_invoice_notification( $invoice_id, $new_status = '' ) {
88
+function wpinv_new_invoice_notification($invoice_id, $new_status = '') {
89 89
     $email_type = 'new_invoice';
90
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
90
+    if (!wpinv_email_is_enabled($email_type)) {
91 91
         return false;
92 92
     }
93 93
 
94
-    $invoice = wpinv_get_invoice( $invoice_id );
95
-    if ( empty( $invoice ) ) {
94
+    $invoice = wpinv_get_invoice($invoice_id);
95
+    if (empty($invoice)) {
96 96
         return false;
97 97
     }
98 98
 
99
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
99
+    if (!("wpi_invoice" === $invoice->post_type)) {
100 100
         return false;
101 101
     }
102 102
 
103
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
104
-    if ( !is_email( $recipient ) ) {
103
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
104
+    if (!is_email($recipient)) {
105 105
         return false;
106 106
     }
107 107
 
108
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type, true );
108
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type, true);
109 109
 
110
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
111
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
112
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
113
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
114
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
110
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
111
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
112
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
113
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
114
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
115 115
 
116
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
116
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
117 117
             'invoice'       => $invoice,
118 118
             'email_type'    => $email_type,
119 119
             'email_heading' => $email_heading,
120 120
             'sent_to_admin' => true,
121 121
             'plain_text'    => false,
122 122
             'message_body'  => $message_body,
123
-        ) );
123
+        ));
124 124
 
125
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
125
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
126 126
 
127
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type, true );
127
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type, true);
128 128
 
129 129
     return $sent;
130 130
 }
131 131
 
132
-function wpinv_cancelled_invoice_notification( $invoice_id, $new_status = '' ) {
132
+function wpinv_cancelled_invoice_notification($invoice_id, $new_status = '') {
133 133
     $email_type = 'cancelled_invoice';
134
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
134
+    if (!wpinv_email_is_enabled($email_type)) {
135 135
         return false;
136 136
     }
137 137
 
138
-    $invoice = wpinv_get_invoice( $invoice_id );
139
-    if ( empty( $invoice ) ) {
138
+    $invoice = wpinv_get_invoice($invoice_id);
139
+    if (empty($invoice)) {
140 140
         return false;
141 141
     }
142 142
 
143
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
143
+    if (!("wpi_invoice" === $invoice->post_type)) {
144 144
         return false;
145 145
     }
146 146
 
147
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
148
-    if ( !is_email( $recipient ) ) {
147
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
148
+    if (!is_email($recipient)) {
149 149
         return false;
150 150
     }
151 151
 
152
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type, true );
152
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type, true);
153 153
 
154
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
155
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
156
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
157
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
158
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
154
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
155
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
156
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
157
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
158
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
159 159
 
160
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
160
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
161 161
             'invoice'       => $invoice,
162 162
             'email_type'    => $email_type,
163 163
             'email_heading' => $email_heading,
164 164
             'sent_to_admin' => true,
165 165
             'plain_text'    => false,
166 166
             'message_body'  => $message_body,
167
-        ) );
167
+        ));
168 168
 
169
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
169
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
170 170
 
171
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type, true );
171
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type, true);
172 172
 
173 173
     return $sent;
174 174
 }
175 175
 
176
-function wpinv_failed_invoice_notification( $invoice_id, $new_status = '' ) {
176
+function wpinv_failed_invoice_notification($invoice_id, $new_status = '') {
177 177
     $email_type = 'failed_invoice';
178
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
178
+    if (!wpinv_email_is_enabled($email_type)) {
179 179
         return false;
180 180
     }
181 181
     
182
-    $invoice = wpinv_get_invoice( $invoice_id );
183
-    if ( empty( $invoice ) ) {
182
+    $invoice = wpinv_get_invoice($invoice_id);
183
+    if (empty($invoice)) {
184 184
         return false;
185 185
     }
186 186
 
187
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
187
+    if (!("wpi_invoice" === $invoice->post_type)) {
188 188
         return false;
189 189
     }
190 190
 
191
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
192
-    if ( !is_email( $recipient ) ) {
191
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
192
+    if (!is_email($recipient)) {
193 193
         return false;
194 194
     }
195 195
 
196
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type, true );
196
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type, true);
197 197
 
198
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
199
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
200
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
201
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
202
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
198
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
199
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
200
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
201
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
202
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
203 203
     
204
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
204
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
205 205
             'invoice'       => $invoice,
206 206
             'email_type'    => $email_type,
207 207
             'email_heading' => $email_heading,
208 208
             'sent_to_admin' => true,
209 209
             'plain_text'    => false,
210 210
             'message_body'  => $message_body,
211
-        ) );
211
+        ));
212 212
 
213
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
213
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
214 214
 
215
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type, true );
215
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type, true);
216 216
 
217 217
     return $sent;
218 218
 }
219 219
 
220
-function wpinv_onhold_invoice_notification( $invoice_id, $new_status = '' ) {
220
+function wpinv_onhold_invoice_notification($invoice_id, $new_status = '') {
221 221
     $email_type = 'onhold_invoice';
222
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
222
+    if (!wpinv_email_is_enabled($email_type)) {
223 223
         return false;
224 224
     }
225 225
 
226
-    $invoice = wpinv_get_invoice( $invoice_id );
227
-    if ( empty( $invoice ) ) {
226
+    $invoice = wpinv_get_invoice($invoice_id);
227
+    if (empty($invoice)) {
228 228
         return false;
229 229
     }
230 230
 
231
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
231
+    if (!("wpi_invoice" === $invoice->post_type)) {
232 232
         return false;
233 233
     }
234 234
 
235
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
236
-    if ( !is_email( $recipient ) ) {
235
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
236
+    if (!is_email($recipient)) {
237 237
         return false;
238 238
     }
239 239
 
240
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type );
240
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type);
241 241
 
242
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
243
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
244
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
245
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
246
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
242
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
243
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
244
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
245
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
246
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
247 247
     
248
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
248
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
249 249
             'invoice'       => $invoice,
250 250
             'email_type'    => $email_type,
251 251
             'email_heading' => $email_heading,
252 252
             'sent_to_admin' => false,
253 253
             'plain_text'    => false,
254 254
             'message_body'  => $message_body,
255
-        ) );
255
+        ));
256 256
     
257
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
257
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
258 258
     
259
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
260
-        $recipient  = wpinv_get_admin_email();
261
-        $subject    .= ' - ADMIN BCC COPY';
262
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
259
+    if (wpinv_mail_admin_bcc_active($email_type)) {
260
+        $recipient = wpinv_get_admin_email();
261
+        $subject .= ' - ADMIN BCC COPY';
262
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
263 263
     }
264 264
 
265
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type );
265
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type);
266 266
 
267 267
     return $sent;
268 268
 }
269 269
 
270
-function wpinv_processing_invoice_notification( $invoice_id, $new_status = '' ) {
270
+function wpinv_processing_invoice_notification($invoice_id, $new_status = '') {
271 271
     $email_type = 'processing_invoice';
272
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
272
+    if (!wpinv_email_is_enabled($email_type)) {
273 273
         return false;
274 274
     }
275 275
 
276
-    $invoice = wpinv_get_invoice( $invoice_id );
277
-    if ( empty( $invoice ) ) {
276
+    $invoice = wpinv_get_invoice($invoice_id);
277
+    if (empty($invoice)) {
278 278
         return false;
279 279
     }
280 280
 
281
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
281
+    if (!("wpi_invoice" === $invoice->post_type)) {
282 282
         return false;
283 283
     }
284 284
 
285
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
286
-    if ( !is_email( $recipient ) ) {
285
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
286
+    if (!is_email($recipient)) {
287 287
         return false;
288 288
     }
289 289
 
290
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type );
290
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type);
291 291
 
292 292
     $search                     = array();
293 293
     $search['invoice_number']   = '{invoice_number}';
294 294
     $search['invoice_date']     = '{invoice_date}';
295 295
     $search['name']             = '{name}';
296 296
 
297
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
298
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
299
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
300
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
301
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
297
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
298
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
299
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
300
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
301
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
302 302
     
303
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
303
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
304 304
             'invoice'       => $invoice,
305 305
             'email_type'    => $email_type,
306 306
             'email_heading' => $email_heading,
307 307
             'sent_to_admin' => false,
308 308
             'plain_text'    => false,
309 309
             'message_body'  => $message_body,
310
-        ) );
310
+        ));
311 311
 
312
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
312
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
313 313
 
314
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
315
-        $recipient  = wpinv_get_admin_email();
316
-        $subject    .= ' - ADMIN BCC COPY';
317
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
314
+    if (wpinv_mail_admin_bcc_active($email_type)) {
315
+        $recipient = wpinv_get_admin_email();
316
+        $subject .= ' - ADMIN BCC COPY';
317
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
318 318
     }
319 319
 
320
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type );
320
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type);
321 321
 
322 322
     return $sent;
323 323
 }
324 324
 
325
-function wpinv_completed_invoice_notification( $invoice_id, $new_status = '' ) {
325
+function wpinv_completed_invoice_notification($invoice_id, $new_status = '') {
326 326
     $email_type = 'completed_invoice';
327
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
327
+    if (!wpinv_email_is_enabled($email_type)) {
328 328
         return false;
329 329
     }
330 330
 
331
-    $invoice = wpinv_get_invoice( $invoice_id );
332
-    if ( empty( $invoice ) ) {
331
+    $invoice = wpinv_get_invoice($invoice_id);
332
+    if (empty($invoice)) {
333 333
         return false;
334 334
     }
335 335
 
336
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
336
+    if (!("wpi_invoice" === $invoice->post_type)) {
337 337
         return false;
338 338
     }
339 339
 
340
-    if($invoice->is_renewal() && wpinv_email_is_enabled( 'completed_invoice_renewal' )){
340
+    if ($invoice->is_renewal() && wpinv_email_is_enabled('completed_invoice_renewal')) {
341 341
         return false;
342 342
     }
343 343
 
344
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
345
-    if ( !is_email( $recipient ) ) {
344
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
345
+    if (!is_email($recipient)) {
346 346
         return false;
347 347
     }
348 348
 
349
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type );
349
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type);
350 350
 
351
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
352
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
353
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
354
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
355
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
351
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
352
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
353
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
354
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
355
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
356 356
 
357
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
357
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
358 358
             'invoice'       => $invoice,
359 359
             'email_type'    => $email_type,
360 360
             'email_heading' => $email_heading,
361 361
             'sent_to_admin' => false,
362 362
             'plain_text'    => false,
363 363
             'message_body'  => $message_body,
364
-        ) );
364
+        ));
365 365
 
366
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
366
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
367 367
 
368
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
369
-        $recipient  = wpinv_get_admin_email();
370
-        $subject    .= ' - ADMIN BCC COPY';
371
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
368
+    if (wpinv_mail_admin_bcc_active($email_type)) {
369
+        $recipient = wpinv_get_admin_email();
370
+        $subject .= ' - ADMIN BCC COPY';
371
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
372 372
     }
373 373
 
374
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type );
374
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type);
375 375
 
376 376
     return $sent;
377 377
 }
378 378
 
379
-function wpinv_fully_refunded_notification( $invoice_id, $new_status = '' ) {
379
+function wpinv_fully_refunded_notification($invoice_id, $new_status = '') {
380 380
     $email_type = 'refunded_invoice';
381
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
381
+    if (!wpinv_email_is_enabled($email_type)) {
382 382
         return false;
383 383
     }
384 384
 
385
-    $invoice = wpinv_get_invoice( $invoice_id );
386
-    if ( empty( $invoice ) ) {
385
+    $invoice = wpinv_get_invoice($invoice_id);
386
+    if (empty($invoice)) {
387 387
         return false;
388 388
     }
389 389
 
390
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
390
+    if (!("wpi_invoice" === $invoice->post_type)) {
391 391
         return false;
392 392
     }
393 393
 
394
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
395
-    if ( !is_email( $recipient ) ) {
394
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
395
+    if (!is_email($recipient)) {
396 396
         return false;
397 397
     }
398 398
 
399
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type );
399
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type);
400 400
 
401
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
402
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
403
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
404
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
405
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
401
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
402
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
403
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
404
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
405
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
406 406
 
407
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
407
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
408 408
             'invoice'           => $invoice,
409 409
             'email_type'        => $email_type,
410 410
             'email_heading'     => $email_heading,
@@ -412,50 +412,50 @@  discard block
 block discarded – undo
412 412
             'plain_text'        => false,
413 413
             'partial_refund'    => false,
414 414
             'message_body'      => $message_body,
415
-        ) );
415
+        ));
416 416
 
417
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
417
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
418 418
 
419
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
420
-        $recipient  = wpinv_get_admin_email();
421
-        $subject    .= ' - ADMIN BCC COPY';
422
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
419
+    if (wpinv_mail_admin_bcc_active($email_type)) {
420
+        $recipient = wpinv_get_admin_email();
421
+        $subject .= ' - ADMIN BCC COPY';
422
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
423 423
     }
424 424
 
425
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type );
425
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type);
426 426
 
427 427
     return $sent;
428 428
 }
429 429
 
430
-function wpinv_partially_refunded_notification( $invoice_id, $new_status = '' ) {
430
+function wpinv_partially_refunded_notification($invoice_id, $new_status = '') {
431 431
     $email_type = 'refunded_invoice';
432
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
432
+    if (!wpinv_email_is_enabled($email_type)) {
433 433
         return false;
434 434
     }
435 435
 
436
-    $invoice = wpinv_get_invoice( $invoice_id );
437
-    if ( empty( $invoice ) ) {
436
+    $invoice = wpinv_get_invoice($invoice_id);
437
+    if (empty($invoice)) {
438 438
         return false;
439 439
     }
440 440
 
441
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
441
+    if (!("wpi_invoice" === $invoice->post_type)) {
442 442
         return false;
443 443
     }
444 444
 
445
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
446
-    if ( !is_email( $recipient ) ) {
445
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
446
+    if (!is_email($recipient)) {
447 447
         return false;
448 448
     }
449 449
 
450
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type );
450
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type);
451 451
 
452
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
453
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
454
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
455
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
456
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
452
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
453
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
454
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
455
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
456
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
457 457
 
458
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
458
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
459 459
             'invoice'           => $invoice,
460 460
             'email_type'        => $email_type,
461 461
             'email_heading'     => $email_heading,
@@ -463,95 +463,95 @@  discard block
 block discarded – undo
463 463
             'plain_text'        => false,
464 464
             'partial_refund'    => true,
465 465
             'message_body'      => $message_body,
466
-        ) );
466
+        ));
467 467
 
468
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
468
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
469 469
 
470
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
471
-        $recipient  = wpinv_get_admin_email();
472
-        $subject    .= ' - ADMIN BCC COPY';
473
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
470
+    if (wpinv_mail_admin_bcc_active($email_type)) {
471
+        $recipient = wpinv_get_admin_email();
472
+        $subject .= ' - ADMIN BCC COPY';
473
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
474 474
     }
475 475
 
476
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type );
476
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type);
477 477
 
478 478
     return $sent;
479 479
 }
480 480
 
481
-function wpinv_new_invoice_note_notification( $invoice_id, $new_status = '' ) {
481
+function wpinv_new_invoice_note_notification($invoice_id, $new_status = '') {
482 482
 }
483 483
 
484
-function wpinv_user_invoice_notification( $invoice_id ) {
484
+function wpinv_user_invoice_notification($invoice_id) {
485 485
     $email_type = 'user_invoice';
486
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
486
+    if (!wpinv_email_is_enabled($email_type)) {
487 487
         return -1;
488 488
     }
489 489
 
490
-    $invoice = wpinv_get_invoice( $invoice_id );
491
-    if ( empty( $invoice ) ) {
490
+    $invoice = wpinv_get_invoice($invoice_id);
491
+    if (empty($invoice)) {
492 492
         return false;
493 493
     }
494 494
 
495
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
495
+    if (!("wpi_invoice" === $invoice->post_type)) {
496 496
         return false;
497 497
     }
498 498
 
499
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
500
-    if ( !is_email( $recipient ) ) {
499
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
500
+    if (!is_email($recipient)) {
501 501
         return false;
502 502
     }
503 503
 
504
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type );
504
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type);
505 505
 
506
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
507
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
508
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
509
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
510
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
506
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
507
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
508
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
509
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
510
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
511 511
     
512
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
512
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
513 513
             'invoice'       => $invoice,
514 514
             'email_type'    => $email_type,
515 515
             'email_heading' => $email_heading,
516 516
             'sent_to_admin' => false,
517 517
             'plain_text'    => false,
518 518
             'message_body'  => $message_body,
519
-        ) );
519
+        ));
520 520
 
521
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
521
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
522 522
 
523
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
524
-        $recipient  = wpinv_get_admin_email();
525
-        $subject    .= ' - ADMIN BCC COPY';
526
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
523
+    if (wpinv_mail_admin_bcc_active($email_type)) {
524
+        $recipient = wpinv_get_admin_email();
525
+        $subject .= ' - ADMIN BCC COPY';
526
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
527 527
     }
528 528
 
529
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type );
529
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type);
530 530
 
531
-    if ( $sent ) {
532
-        $note = __( 'Invoice has been emailed to the user.', 'invoicing' );
531
+    if ($sent) {
532
+        $note = __('Invoice has been emailed to the user.', 'invoicing');
533 533
     } else {
534
-        $note = __( 'Fail to send invoice to the user!', 'invoicing' );
534
+        $note = __('Fail to send invoice to the user!', 'invoicing');
535 535
     }
536 536
 
537
-    $invoice->add_note( $note, '', '', true ); // Add system note.
537
+    $invoice->add_note($note, '', '', true); // Add system note.
538 538
 
539 539
     return $sent;
540 540
 }
541 541
 
542
-function wpinv_user_note_notification( $invoice_id, $args = array() ) {
542
+function wpinv_user_note_notification($invoice_id, $args = array()) {
543 543
     $email_type = 'user_note';
544
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
544
+    if (!wpinv_email_is_enabled($email_type)) {
545 545
         return false;
546 546
     }
547 547
 
548
-    $invoice = wpinv_get_invoice( $invoice_id );
549
-    if ( empty( $invoice ) ) {
548
+    $invoice = wpinv_get_invoice($invoice_id);
549
+    if (empty($invoice)) {
550 550
         return false;
551 551
     }
552 552
 
553
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
554
-    if ( !is_email( $recipient ) ) {
553
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
554
+    if (!is_email($recipient)) {
555 555
         return false;
556 556
     }
557 557
 
@@ -559,19 +559,19 @@  discard block
 block discarded – undo
559 559
         'user_note' => ''
560 560
     );
561 561
 
562
-    $args = wp_parse_args( $args, $defaults );
562
+    $args = wp_parse_args($args, $defaults);
563 563
 
564
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type );
564
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type);
565 565
 
566
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
567
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
568
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
569
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
570
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
566
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
567
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
568
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
569
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
570
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
571 571
 
572
-    $message_body   = str_replace( '{customer_note}', $args['user_note'], $message_body );
572
+    $message_body   = str_replace('{customer_note}', $args['user_note'], $message_body);
573 573
 
574
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
574
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
575 575
             'invoice'       => $invoice,
576 576
             'email_type'    => $email_type,
577 577
             'email_heading' => $email_heading,
@@ -579,36 +579,36 @@  discard block
 block discarded – undo
579 579
             'plain_text'    => false,
580 580
             'message_body'  => $message_body,
581 581
             'customer_note' => $args['user_note']
582
-        ) );
582
+        ));
583 583
 
584
-    $content        = wpinv_email_format_text( $content, $invoice );
584
+    $content = wpinv_email_format_text($content, $invoice);
585 585
 
586
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
586
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
587 587
 
588
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type );
588
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type);
589 589
 
590 590
     return $sent;
591 591
 }
592 592
 
593 593
 function wpinv_mail_get_from_address() {
594
-    $from_address = apply_filters( 'wpinv_mail_from_address', wpinv_get_option( 'email_from' ) );
595
-    return sanitize_email( $from_address );
594
+    $from_address = apply_filters('wpinv_mail_from_address', wpinv_get_option('email_from'));
595
+    return sanitize_email($from_address);
596 596
 }
597 597
 
598 598
 function wpinv_mail_get_from_name() {
599
-    $from_name = apply_filters( 'wpinv_mail_from_name', wpinv_get_option( 'email_from_name' ) );
600
-    return wp_specialchars_decode( esc_html( $from_name ), ENT_QUOTES );
599
+    $from_name = apply_filters('wpinv_mail_from_name', wpinv_get_option('email_from_name'));
600
+    return wp_specialchars_decode(esc_html($from_name), ENT_QUOTES);
601 601
 }
602 602
 
603
-function wpinv_mail_admin_bcc_active( $mail_type = '' ) {
604
-    $active = apply_filters( 'wpinv_mail_admin_bcc_active', wpinv_get_option( 'email_' . $mail_type . '_admin_bcc' ) );
605
-    return ( $active ? true : false );
603
+function wpinv_mail_admin_bcc_active($mail_type = '') {
604
+    $active = apply_filters('wpinv_mail_admin_bcc_active', wpinv_get_option('email_' . $mail_type . '_admin_bcc'));
605
+    return ($active ? true : false);
606 606
 }
607 607
     
608
-function wpinv_mail_get_content_type(  $content_type = 'text/html', $email_type = 'html' ) {
609
-    $email_type = apply_filters( 'wpinv_mail_content_type', $email_type );
608
+function wpinv_mail_get_content_type($content_type = 'text/html', $email_type = 'html') {
609
+    $email_type = apply_filters('wpinv_mail_content_type', $email_type);
610 610
 
611
-    switch ( $email_type ) {
611
+    switch ($email_type) {
612 612
         case 'html' :
613 613
             $content_type = 'text/html';
614 614
             break;
@@ -623,35 +623,35 @@  discard block
 block discarded – undo
623 623
     return $content_type;
624 624
 }
625 625
     
626
-function wpinv_mail_send( $to, $subject, $message, $headers, $attachments ) {
627
-    add_filter( 'wp_mail_from', 'wpinv_mail_get_from_address' );
628
-    add_filter( 'wp_mail_from_name', 'wpinv_mail_get_from_name' );
629
-    add_filter( 'wp_mail_content_type', 'wpinv_mail_get_content_type' );
626
+function wpinv_mail_send($to, $subject, $message, $headers, $attachments) {
627
+    add_filter('wp_mail_from', 'wpinv_mail_get_from_address');
628
+    add_filter('wp_mail_from_name', 'wpinv_mail_get_from_name');
629
+    add_filter('wp_mail_content_type', 'wpinv_mail_get_content_type');
630 630
 
631
-    $message = wpinv_email_style_body( $message );
632
-    $message = apply_filters( 'wpinv_mail_content', $message );
631
+    $message = wpinv_email_style_body($message);
632
+    $message = apply_filters('wpinv_mail_content', $message);
633 633
 
634
-    $sent  = wp_mail( $to, $subject, $message, $headers, $attachments );
634
+    $sent = wp_mail($to, $subject, $message, $headers, $attachments);
635 635
 
636
-    if ( !$sent ) {
637
-        $log_message = wp_sprintf( __( "\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing' ), date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), ( is_array( $to ) ? implode( ', ', $to ) : $to ), $subject );
638
-        wpinv_error_log( $log_message, __( "Email from Invoicing plugin failed to send", 'invoicing' ), __FILE__, __LINE__ );
636
+    if (!$sent) {
637
+        $log_message = wp_sprintf(__("\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing'), date_i18n('F j Y H:i:s', current_time('timestamp')), (is_array($to) ? implode(', ', $to) : $to), $subject);
638
+        wpinv_error_log($log_message, __("Email from Invoicing plugin failed to send", 'invoicing'), __FILE__, __LINE__);
639 639
     }
640 640
 
641
-    remove_filter( 'wp_mail_from', 'wpinv_mail_get_from_address' );
642
-    remove_filter( 'wp_mail_from_name', 'wpinv_mail_get_from_name' );
643
-    remove_filter( 'wp_mail_content_type', 'wpinv_mail_get_content_type' );
641
+    remove_filter('wp_mail_from', 'wpinv_mail_get_from_address');
642
+    remove_filter('wp_mail_from_name', 'wpinv_mail_get_from_name');
643
+    remove_filter('wp_mail_content_type', 'wpinv_mail_get_content_type');
644 644
 
645 645
     return $sent;
646 646
 }
647 647
     
648 648
 function wpinv_get_emails() {
649 649
     $overdue_days_options       = array();
650
-    $overdue_days_options[0]    = __( 'On the Due Date', 'invoicing' );
651
-    $overdue_days_options[1]    = __( '1 day after Due Date', 'invoicing' );
650
+    $overdue_days_options[0]    = __('On the Due Date', 'invoicing');
651
+    $overdue_days_options[1]    = __('1 day after Due Date', 'invoicing');
652 652
 
653
-    for ( $i = 2; $i <= 10; $i++ ) {
654
-        $overdue_days_options[$i]   = wp_sprintf( __( '%d days after Due Date', 'invoicing' ), $i );
653
+    for ($i = 2; $i <= 10; $i++) {
654
+        $overdue_days_options[$i] = wp_sprintf(__('%d days after Due Date', 'invoicing'), $i);
655 655
     }
656 656
 
657 657
     // Default, built-in gateways
@@ -659,39 +659,39 @@  discard block
 block discarded – undo
659 659
             'new_invoice' => array(
660 660
             'email_new_invoice_header' => array(
661 661
                 'id'   => 'email_new_invoice_header',
662
-                'name' => '<h3>' . __( 'New Invoice', 'invoicing' ) . '</h3>',
663
-                'desc' => __( 'New invoice emails are sent to admin when a new invoice is received.', 'invoicing' ),
662
+                'name' => '<h3>' . __('New Invoice', 'invoicing') . '</h3>',
663
+                'desc' => __('New invoice emails are sent to admin when a new invoice is received.', 'invoicing'),
664 664
                 'type' => 'header',
665 665
             ),
666 666
             'email_new_invoice_active' => array(
667 667
                 'id'   => 'email_new_invoice_active',
668
-                'name' => __( 'Enable/Disable', 'invoicing' ),
669
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
668
+                'name' => __('Enable/Disable', 'invoicing'),
669
+                'desc' => __('Enable this email notification', 'invoicing'),
670 670
                 'type' => 'checkbox',
671 671
                 'std'  => 1
672 672
             ),
673 673
             'email_new_invoice_subject' => array(
674 674
                 'id'   => 'email_new_invoice_subject',
675
-                'name' => __( 'Subject', 'invoicing' ),
676
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
675
+                'name' => __('Subject', 'invoicing'),
676
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
677 677
                 'type' => 'text',
678
-                'std'  => __( '[{site_title}] New payment invoice ({invoice_number}) - {invoice_date}', 'invoicing' ),
678
+                'std'  => __('[{site_title}] New payment invoice ({invoice_number}) - {invoice_date}', 'invoicing'),
679 679
                 'size' => 'large'
680 680
             ),
681 681
             'email_new_invoice_heading' => array(
682 682
                 'id'   => 'email_new_invoice_heading',
683
-                'name' => __( 'Email Heading', 'invoicing' ),
684
-                'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
683
+                'name' => __('Email Heading', 'invoicing'),
684
+                'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
685 685
                 'type' => 'text',
686
-                'std'  => __( 'New payment invoice', 'invoicing' ),
686
+                'std'  => __('New payment invoice', 'invoicing'),
687 687
                 'size' => 'large'
688 688
             ),
689 689
             'email_new_invoice_body' => array(
690 690
                 'id'   => 'email_new_invoice_body',
691
-                'name' => __( 'Email Content', 'invoicing' ),
692
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
691
+                'name' => __('Email Content', 'invoicing'),
692
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
693 693
                 'type' => 'rich_editor',
694
-                'std'  => __( '<p>Hi Admin,</p><p>You have received payment invoice from {name}.</p>', 'invoicing' ),
694
+                'std'  => __('<p>Hi Admin,</p><p>You have received payment invoice from {name}.</p>', 'invoicing'),
695 695
                 'class' => 'large',
696 696
                 'size' => '10'
697 697
             ),
@@ -699,39 +699,39 @@  discard block
 block discarded – undo
699 699
         'cancelled_invoice' => array(
700 700
             'email_cancelled_invoice_header' => array(
701 701
                 'id'   => 'email_cancelled_invoice_header',
702
-                'name' => '<h3>' . __( 'Cancelled Invoice', 'invoicing' ) . '</h3>',
703
-                'desc' => __( 'Cancelled invoice emails are sent to admin when invoices have been marked cancelled.', 'invoicing' ),
702
+                'name' => '<h3>' . __('Cancelled Invoice', 'invoicing') . '</h3>',
703
+                'desc' => __('Cancelled invoice emails are sent to admin when invoices have been marked cancelled.', 'invoicing'),
704 704
                 'type' => 'header',
705 705
             ),
706 706
             'email_cancelled_invoice_active' => array(
707 707
                 'id'   => 'email_cancelled_invoice_active',
708
-                'name' => __( 'Enable/Disable', 'invoicing' ),
709
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
708
+                'name' => __('Enable/Disable', 'invoicing'),
709
+                'desc' => __('Enable this email notification', 'invoicing'),
710 710
                 'type' => 'checkbox',
711 711
                 'std'  => 1
712 712
             ),
713 713
             'email_cancelled_invoice_subject' => array(
714 714
                 'id'   => 'email_cancelled_invoice_subject',
715
-                'name' => __( 'Subject', 'invoicing' ),
716
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
715
+                'name' => __('Subject', 'invoicing'),
716
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
717 717
                 'type' => 'text',
718
-                'std'  => __( '[{site_title}] Cancelled invoice ({invoice_number})', 'invoicing' ),
718
+                'std'  => __('[{site_title}] Cancelled invoice ({invoice_number})', 'invoicing'),
719 719
                 'size' => 'large'
720 720
             ),
721 721
             'email_cancelled_invoice_heading' => array(
722 722
                 'id'   => 'email_cancelled_invoice_heading',
723
-                'name' => __( 'Email Heading', 'invoicing' ),
724
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
723
+                'name' => __('Email Heading', 'invoicing'),
724
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
725 725
                 'type' => 'text',
726
-                'std'  => __( 'Cancelled invoice', 'invoicing' ),
726
+                'std'  => __('Cancelled invoice', 'invoicing'),
727 727
                 'size' => 'large'
728 728
             ),
729 729
             'email_cancelled_invoice_body' => array(
730 730
                 'id'   => 'email_cancelled_invoice_body',
731
-                'name' => __( 'Email Content', 'invoicing' ),
732
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
731
+                'name' => __('Email Content', 'invoicing'),
732
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
733 733
                 'type' => 'rich_editor',
734
-                'std'  => __( '<p>Hi Admin,</p><p>The invoice #{invoice_number} from {site_title} has been cancelled.</p>', 'invoicing' ),
734
+                'std'  => __('<p>Hi Admin,</p><p>The invoice #{invoice_number} from {site_title} has been cancelled.</p>', 'invoicing'),
735 735
                 'class' => 'large',
736 736
                 'size' => '10'
737 737
             ),
@@ -739,39 +739,39 @@  discard block
 block discarded – undo
739 739
         'failed_invoice' => array(
740 740
             'email_failed_invoice_header' => array(
741 741
                 'id'   => 'email_failed_invoice_header',
742
-                'name' => '<h3>' . __( 'Failed Invoice', 'invoicing' ) . '</h3>',
743
-                'desc' => __( 'Failed invoice emails are sent to admin when invoices have been marked failed (if they were previously processing or on-hold).', 'invoicing' ),
742
+                'name' => '<h3>' . __('Failed Invoice', 'invoicing') . '</h3>',
743
+                'desc' => __('Failed invoice emails are sent to admin when invoices have been marked failed (if they were previously processing or on-hold).', 'invoicing'),
744 744
                 'type' => 'header',
745 745
             ),
746 746
             'email_failed_invoice_active' => array(
747 747
                 'id'   => 'email_failed_invoice_active',
748
-                'name' => __( 'Enable/Disable', 'invoicing' ),
749
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
748
+                'name' => __('Enable/Disable', 'invoicing'),
749
+                'desc' => __('Enable this email notification', 'invoicing'),
750 750
                 'type' => 'checkbox',
751 751
                 'std'  => 1
752 752
             ),
753 753
             'email_failed_invoice_subject' => array(
754 754
                 'id'   => 'email_failed_invoice_subject',
755
-                'name' => __( 'Subject', 'invoicing' ),
756
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
755
+                'name' => __('Subject', 'invoicing'),
756
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
757 757
                 'type' => 'text',
758
-                'std'  => __( '[{site_title}] Failed invoice ({invoice_number})', 'invoicing' ),
758
+                'std'  => __('[{site_title}] Failed invoice ({invoice_number})', 'invoicing'),
759 759
                 'size' => 'large'
760 760
             ),
761 761
             'email_failed_invoice_heading' => array(
762 762
                 'id'   => 'email_failed_invoice_heading',
763
-                'name' => __( 'Email Heading', 'invoicing' ),
764
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
763
+                'name' => __('Email Heading', 'invoicing'),
764
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
765 765
                 'type' => 'text',
766
-                'std'  => __( 'Failed invoice', 'invoicing' ),
766
+                'std'  => __('Failed invoice', 'invoicing'),
767 767
                 'size' => 'large'
768 768
             ),
769 769
             'email_failed_invoice_body' => array(
770 770
                 'id'   => 'email_failed_invoice_body',
771
-                'name' => __( 'Email Content', 'invoicing' ),
772
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
771
+                'name' => __('Email Content', 'invoicing'),
772
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
773 773
                 'type' => 'rich_editor',
774
-                'std'  => __( '<p>Hi Admin,</p><p>Payment for invoice #{invoice_number} from {site_title} has been failed.</p>', 'invoicing' ),
774
+                'std'  => __('<p>Hi Admin,</p><p>Payment for invoice #{invoice_number} from {site_title} has been failed.</p>', 'invoicing'),
775 775
                 'class' => 'large',
776 776
                 'size' => '10'
777 777
             ),
@@ -779,46 +779,46 @@  discard block
 block discarded – undo
779 779
         'onhold_invoice' => array(
780 780
             'email_onhold_invoice_header' => array(
781 781
                 'id'   => 'email_onhold_invoice_header',
782
-                'name' => '<h3>' . __( 'On Hold Invoice', 'invoicing' ) . '</h3>',
783
-                'desc' => __( 'This is an invoice notification sent to users containing invoice details after an invoice is placed on-hold.', 'invoicing' ),
782
+                'name' => '<h3>' . __('On Hold Invoice', 'invoicing') . '</h3>',
783
+                'desc' => __('This is an invoice notification sent to users containing invoice details after an invoice is placed on-hold.', 'invoicing'),
784 784
                 'type' => 'header',
785 785
             ),
786 786
             'email_onhold_invoice_active' => array(
787 787
                 'id'   => 'email_onhold_invoice_active',
788
-                'name' => __( 'Enable/Disable', 'invoicing' ),
789
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
788
+                'name' => __('Enable/Disable', 'invoicing'),
789
+                'desc' => __('Enable this email notification', 'invoicing'),
790 790
                 'type' => 'checkbox',
791 791
                 'std'  => 1
792 792
             ),
793 793
             'email_onhold_invoice_subject' => array(
794 794
                 'id'   => 'email_onhold_invoice_subject',
795
-                'name' => __( 'Subject', 'invoicing' ),
796
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
795
+                'name' => __('Subject', 'invoicing'),
796
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
797 797
                 'type' => 'text',
798
-                'std'  => __( '[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing' ),
798
+                'std'  => __('[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing'),
799 799
                 'size' => 'large'
800 800
             ),
801 801
             'email_onhold_invoice_heading' => array(
802 802
                 'id'   => 'email_onhold_invoice_heading',
803
-                'name' => __( 'Email Heading', 'invoicing' ),
804
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
803
+                'name' => __('Email Heading', 'invoicing'),
804
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
805 805
                 'type' => 'text',
806
-                'std'  => __( 'Thank you for your invoice', 'invoicing' ),
806
+                'std'  => __('Thank you for your invoice', 'invoicing'),
807 807
                 'size' => 'large'
808 808
             ),
809 809
             'email_onhold_invoice_admin_bcc' => array(
810 810
                 'id'   => 'email_onhold_invoice_admin_bcc',
811
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
812
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
811
+                'name' => __('Enable Admin BCC', 'invoicing'),
812
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
813 813
                 'type' => 'checkbox',
814 814
                 'std'  => 1
815 815
             ),
816 816
             'email_onhold_invoice_body' => array(
817 817
                 'id'   => 'email_onhold_invoice_body',
818
-                'name' => __( 'Email Content', 'invoicing' ),
819
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
818
+                'name' => __('Email Content', 'invoicing'),
819
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
820 820
                 'type' => 'rich_editor',
821
-                'std'  => __( '<p>Hi {name},</p><p>Your invoice is on-hold until we confirm your payment has been received.</p>', 'invoicing' ),
821
+                'std'  => __('<p>Hi {name},</p><p>Your invoice is on-hold until we confirm your payment has been received.</p>', 'invoicing'),
822 822
                 'class' => 'large',
823 823
                 'size' => '10'
824 824
             ),
@@ -826,46 +826,46 @@  discard block
 block discarded – undo
826 826
         'processing_invoice' => array(
827 827
             'email_processing_invoice_header' => array(
828 828
                 'id'   => 'email_processing_invoice_header',
829
-                'name' => '<h3>' . __( 'Processing Invoice', 'invoicing' ) . '</h3>',
830
-                'desc' => __( 'This is an invoice notification sent to users containing invoice details after payment.', 'invoicing' ),
829
+                'name' => '<h3>' . __('Processing Invoice', 'invoicing') . '</h3>',
830
+                'desc' => __('This is an invoice notification sent to users containing invoice details after payment.', 'invoicing'),
831 831
                 'type' => 'header',
832 832
             ),
833 833
             'email_processing_invoice_active' => array(
834 834
                 'id'   => 'email_processing_invoice_active',
835
-                'name' => __( 'Enable/Disable', 'invoicing' ),
836
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
835
+                'name' => __('Enable/Disable', 'invoicing'),
836
+                'desc' => __('Enable this email notification', 'invoicing'),
837 837
                 'type' => 'checkbox',
838 838
                 'std'  => 1
839 839
             ),
840 840
             'email_processing_invoice_subject' => array(
841 841
                 'id'   => 'email_processing_invoice_subject',
842
-                'name' => __( 'Subject', 'invoicing' ),
843
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
842
+                'name' => __('Subject', 'invoicing'),
843
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
844 844
                 'type' => 'text',
845
-                'std'  => __( '[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing' ),
845
+                'std'  => __('[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing'),
846 846
                 'size' => 'large'
847 847
             ),
848 848
             'email_processing_invoice_heading' => array(
849 849
                 'id'   => 'email_processing_invoice_heading',
850
-                'name' => __( 'Email Heading', 'invoicing' ),
851
-                'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
850
+                'name' => __('Email Heading', 'invoicing'),
851
+                'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
852 852
                 'type' => 'text',
853
-                'std'  => __( 'Thank you for your invoice', 'invoicing' ),
853
+                'std'  => __('Thank you for your invoice', 'invoicing'),
854 854
                 'size' => 'large'
855 855
             ),
856 856
             'email_processing_invoice_admin_bcc' => array(
857 857
                 'id'   => 'email_processing_invoice_admin_bcc',
858
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
859
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
858
+                'name' => __('Enable Admin BCC', 'invoicing'),
859
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
860 860
                 'type' => 'checkbox',
861 861
                 'std'  => 1
862 862
             ),
863 863
             'email_processing_invoice_body' => array(
864 864
                 'id'   => 'email_processing_invoice_body',
865
-                'name' => __( 'Email Content', 'invoicing' ),
866
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
865
+                'name' => __('Email Content', 'invoicing'),
866
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
867 867
                 'type' => 'rich_editor',
868
-                'std'  => __( '<p>Hi {name},</p><p>Your invoice has been received at {site_title} and is now being processed.</p>', 'invoicing' ),
868
+                'std'  => __('<p>Hi {name},</p><p>Your invoice has been received at {site_title} and is now being processed.</p>', 'invoicing'),
869 869
                 'class' => 'large',
870 870
                 'size' => '10'
871 871
             ),
@@ -873,52 +873,52 @@  discard block
 block discarded – undo
873 873
         'completed_invoice' => array(
874 874
             'email_completed_invoice_header' => array(
875 875
                 'id'   => 'email_completed_invoice_header',
876
-                'name' => '<h3>' . __( 'Paid Invoice', 'invoicing' ) . '</h3>',
877
-                'desc' => __( 'Invoice paid emails are sent to users when their invoices are marked paid and usually indicate that their payment has been done.', 'invoicing' ),
876
+                'name' => '<h3>' . __('Paid Invoice', 'invoicing') . '</h3>',
877
+                'desc' => __('Invoice paid emails are sent to users when their invoices are marked paid and usually indicate that their payment has been done.', 'invoicing'),
878 878
                 'type' => 'header',
879 879
             ),
880 880
             'email_completed_invoice_active' => array(
881 881
                 'id'   => 'email_completed_invoice_active',
882
-                'name' => __( 'Enable/Disable', 'invoicing' ),
883
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
882
+                'name' => __('Enable/Disable', 'invoicing'),
883
+                'desc' => __('Enable this email notification', 'invoicing'),
884 884
                 'type' => 'checkbox',
885 885
                 'std'  => 1
886 886
             ),
887 887
             'email_completed_invoice_renewal_active' => array(
888 888
                 'id'   => 'email_completed_invoice_renewal_active',
889
-                'name' => __( 'Enable renewal notification', 'invoicing' ),
890
-                'desc' => __( 'Enable renewal invoice email notification. This notification will be sent on renewal.', 'invoicing' ),
889
+                'name' => __('Enable renewal notification', 'invoicing'),
890
+                'desc' => __('Enable renewal invoice email notification. This notification will be sent on renewal.', 'invoicing'),
891 891
                 'type' => 'checkbox',
892 892
                 'std'  => 0
893 893
             ),
894 894
             'email_completed_invoice_subject' => array(
895 895
                 'id'   => 'email_completed_invoice_subject',
896
-                'name' => __( 'Subject', 'invoicing' ),
897
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
896
+                'name' => __('Subject', 'invoicing'),
897
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
898 898
                 'type' => 'text',
899
-                'std'  => __( '[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing' ),
899
+                'std'  => __('[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing'),
900 900
                 'size' => 'large'
901 901
             ),
902 902
             'email_completed_invoice_heading' => array(
903 903
                 'id'   => 'email_completed_invoice_heading',
904
-                'name' => __( 'Email Heading', 'invoicing' ),
905
-                'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
904
+                'name' => __('Email Heading', 'invoicing'),
905
+                'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
906 906
                 'type' => 'text',
907
-                'std'  => __( 'Your invoice has been paid', 'invoicing' ),
907
+                'std'  => __('Your invoice has been paid', 'invoicing'),
908 908
                 'size' => 'large'
909 909
             ),
910 910
             'email_completed_invoice_admin_bcc' => array(
911 911
                 'id'   => 'email_completed_invoice_admin_bcc',
912
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
913
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
912
+                'name' => __('Enable Admin BCC', 'invoicing'),
913
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
914 914
                 'type' => 'checkbox',
915 915
             ),
916 916
             'email_completed_invoice_body' => array(
917 917
                 'id'   => 'email_completed_invoice_body',
918
-                'name' => __( 'Email Content', 'invoicing' ),
919
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
918
+                'name' => __('Email Content', 'invoicing'),
919
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
920 920
                 'type' => 'rich_editor',
921
-                'std'  => __( '<p>Hi {name},</p><p>Your recent invoice on {site_title} has been paid.</p>', 'invoicing' ),
921
+                'std'  => __('<p>Hi {name},</p><p>Your recent invoice on {site_title} has been paid.</p>', 'invoicing'),
922 922
                 'class' => 'large',
923 923
                 'size' => '10'
924 924
             ),
@@ -927,46 +927,46 @@  discard block
 block discarded – undo
927 927
         'refunded_invoice' => array(
928 928
             'email_refunded_invoice_header' => array(
929 929
                 'id'   => 'email_refunded_invoice_header',
930
-                'name' => '<h3>' . __( 'Refunded Invoice', 'invoicing' ) . '</h3>',
931
-                'desc' => __( 'Invoice refunded emails are sent to users when their invoices are marked refunded.', 'invoicing' ),
930
+                'name' => '<h3>' . __('Refunded Invoice', 'invoicing') . '</h3>',
931
+                'desc' => __('Invoice refunded emails are sent to users when their invoices are marked refunded.', 'invoicing'),
932 932
                 'type' => 'header',
933 933
             ),
934 934
             'email_refunded_invoice_active' => array(
935 935
                 'id'   => 'email_refunded_invoice_active',
936
-                'name' => __( 'Enable/Disable', 'invoicing' ),
937
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
936
+                'name' => __('Enable/Disable', 'invoicing'),
937
+                'desc' => __('Enable this email notification', 'invoicing'),
938 938
                 'type' => 'checkbox',
939 939
                 'std'  => 1
940 940
             ),
941 941
             'email_refunded_invoice_subject' => array(
942 942
                 'id'   => 'email_refunded_invoice_subject',
943
-                'name' => __( 'Subject', 'invoicing' ),
944
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
943
+                'name' => __('Subject', 'invoicing'),
944
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
945 945
                 'type' => 'text',
946
-                'std'  => __( '[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing' ),
946
+                'std'  => __('[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing'),
947 947
                 'size' => 'large'
948 948
             ),
949 949
             'email_refunded_invoice_heading' => array(
950 950
                 'id'   => 'email_refunded_invoice_heading',
951
-                'name' => __( 'Email Heading', 'invoicing' ),
952
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
951
+                'name' => __('Email Heading', 'invoicing'),
952
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
953 953
                 'type' => 'text',
954
-                'std'  => __( 'Your invoice has been refunded', 'invoicing' ),
954
+                'std'  => __('Your invoice has been refunded', 'invoicing'),
955 955
                 'size' => 'large'
956 956
             ),
957 957
             'email_refunded_invoice_admin_bcc' => array(
958 958
                 'id'   => 'email_refunded_invoice_admin_bcc',
959
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
960
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
959
+                'name' => __('Enable Admin BCC', 'invoicing'),
960
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
961 961
                 'type' => 'checkbox',
962 962
                 'std'  => 1
963 963
             ),
964 964
             'email_refunded_invoice_body' => array(
965 965
                 'id'   => 'email_refunded_invoice_body',
966
-                'name' => __( 'Email Content', 'invoicing' ),
967
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
966
+                'name' => __('Email Content', 'invoicing'),
967
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
968 968
                 'type' => 'rich_editor',
969
-                'std'  => __( '<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded.</p>', 'invoicing' ),
969
+                'std'  => __('<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded.</p>', 'invoicing'),
970 970
                 'class' => 'large',
971 971
                 'size' => '10'
972 972
             ),
@@ -974,46 +974,46 @@  discard block
 block discarded – undo
974 974
         'user_invoice' => array(
975 975
             'email_user_invoice_header' => array(
976 976
                 'id'   => 'email_user_invoice_header',
977
-                'name' => '<h3>' . __( 'Customer Invoice', 'invoicing' ) . '</h3>',
978
-                'desc' => __( 'Customer invoice emails can be sent to customers containing their invoice information and payment links.', 'invoicing' ),
977
+                'name' => '<h3>' . __('Customer Invoice', 'invoicing') . '</h3>',
978
+                'desc' => __('Customer invoice emails can be sent to customers containing their invoice information and payment links.', 'invoicing'),
979 979
                 'type' => 'header',
980 980
             ),
981 981
             'email_user_invoice_active' => array(
982 982
                 'id'   => 'email_user_invoice_active',
983
-                'name' => __( 'Enable/Disable', 'invoicing' ),
984
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
983
+                'name' => __('Enable/Disable', 'invoicing'),
984
+                'desc' => __('Enable this email notification', 'invoicing'),
985 985
                 'type' => 'checkbox',
986 986
                 'std'  => 1
987 987
             ),
988 988
             'email_user_invoice_subject' => array(
989 989
                 'id'   => 'email_user_invoice_subject',
990
-                'name' => __( 'Subject', 'invoicing' ),
991
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
990
+                'name' => __('Subject', 'invoicing'),
991
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
992 992
                 'type' => 'text',
993
-                'std'  => __( '[{site_title}] Your invoice from {invoice_date}', 'invoicing' ),
993
+                'std'  => __('[{site_title}] Your invoice from {invoice_date}', 'invoicing'),
994 994
                 'size' => 'large'
995 995
             ),
996 996
             'email_user_invoice_heading' => array(
997 997
                 'id'   => 'email_user_invoice_heading',
998
-                'name' => __( 'Email Heading', 'invoicing' ),
999
-                'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
998
+                'name' => __('Email Heading', 'invoicing'),
999
+                'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
1000 1000
                 'type' => 'text',
1001
-                'std'  => __( 'Your invoice {invoice_number} details', 'invoicing' ),
1001
+                'std'  => __('Your invoice {invoice_number} details', 'invoicing'),
1002 1002
                 'size' => 'large'
1003 1003
             ),
1004 1004
             'email_user_invoice_admin_bcc' => array(
1005 1005
                 'id'   => 'email_user_invoice_admin_bcc',
1006
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
1007
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
1006
+                'name' => __('Enable Admin BCC', 'invoicing'),
1007
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
1008 1008
                 'type' => 'checkbox',
1009 1009
                 'std'  => 1
1010 1010
             ),
1011 1011
             'email_user_invoice_body' => array(
1012 1012
                 'id'   => 'email_user_invoice_body',
1013
-                'name' => __( 'Email Content', 'invoicing' ),
1014
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
1013
+                'name' => __('Email Content', 'invoicing'),
1014
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
1015 1015
                 'type' => 'rich_editor',
1016
-                'std'  => __( '<p>Hi {name},</p><p>An invoice has been created for you on {site_title}. To view / pay for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing' ),
1016
+                'std'  => __('<p>Hi {name},</p><p>An invoice has been created for you on {site_title}. To view / pay for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing'),
1017 1017
                 'class' => 'large',
1018 1018
                 'size' => '10'
1019 1019
             ),
@@ -1021,39 +1021,39 @@  discard block
 block discarded – undo
1021 1021
         'user_note' => array(
1022 1022
             'email_user_note_header' => array(
1023 1023
                 'id'   => 'email_user_note_header',
1024
-                'name' => '<h3>' . __( 'Customer Note', 'invoicing' ) . '</h3>',
1025
-                'desc' => __( 'Customer note emails are sent when you add a note to an invoice/quote.', 'invoicing' ),
1024
+                'name' => '<h3>' . __('Customer Note', 'invoicing') . '</h3>',
1025
+                'desc' => __('Customer note emails are sent when you add a note to an invoice/quote.', 'invoicing'),
1026 1026
                 'type' => 'header',
1027 1027
             ),
1028 1028
             'email_user_note_active' => array(
1029 1029
                 'id'   => 'email_user_note_active',
1030
-                'name' => __( 'Enable/Disable', 'invoicing' ),
1031
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
1030
+                'name' => __('Enable/Disable', 'invoicing'),
1031
+                'desc' => __('Enable this email notification', 'invoicing'),
1032 1032
                 'type' => 'checkbox',
1033 1033
                 'std'  => 1
1034 1034
             ),
1035 1035
             'email_user_note_subject' => array(
1036 1036
                 'id'   => 'email_user_note_subject',
1037
-                'name' => __( 'Subject', 'invoicing' ),
1038
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
1037
+                'name' => __('Subject', 'invoicing'),
1038
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
1039 1039
                 'type' => 'text',
1040
-                'std'  => __( '[{site_title}] Note added to your {invoice_label} #{invoice_number} from {invoice_date}', 'invoicing' ),
1040
+                'std'  => __('[{site_title}] Note added to your {invoice_label} #{invoice_number} from {invoice_date}', 'invoicing'),
1041 1041
                 'size' => 'large'
1042 1042
             ),
1043 1043
             'email_user_note_heading' => array(
1044 1044
                 'id'   => 'email_user_note_heading',
1045
-                'name' => __( 'Email Heading', 'invoicing' ),
1046
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
1045
+                'name' => __('Email Heading', 'invoicing'),
1046
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
1047 1047
                 'type' => 'text',
1048
-                'std'  => __( 'A note has been added to your {invoice_label}', 'invoicing' ),
1048
+                'std'  => __('A note has been added to your {invoice_label}', 'invoicing'),
1049 1049
                 'size' => 'large'
1050 1050
             ),
1051 1051
             'email_user_note_body' => array(
1052 1052
                 'id'   => 'email_user_note_body',
1053
-                'name' => __( 'Email Content', 'invoicing' ),
1054
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
1053
+                'name' => __('Email Content', 'invoicing'),
1054
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
1055 1055
                 'type' => 'rich_editor',
1056
-                'std'  => __( '<p>Hi {name},</p><p>Following note has been added to your {invoice_label}:</p><blockquote class="wpinv-note">{customer_note}</blockquote>', 'invoicing' ),
1056
+                'std'  => __('<p>Hi {name},</p><p>Following note has been added to your {invoice_label}:</p><blockquote class="wpinv-note">{customer_note}</blockquote>', 'invoicing'),
1057 1057
                 'class' => 'large',
1058 1058
                 'size' => '10'
1059 1059
             ),
@@ -1061,158 +1061,158 @@  discard block
 block discarded – undo
1061 1061
         'overdue' => array(
1062 1062
             'email_overdue_header' => array(
1063 1063
                 'id'   => 'email_overdue_header',
1064
-                'name' => '<h3>' . __( 'Payment Reminder', 'invoicing' ) . '</h3>',
1065
-                'desc' => __( 'Payment reminder emails are sent to user automatically.', 'invoicing' ),
1064
+                'name' => '<h3>' . __('Payment Reminder', 'invoicing') . '</h3>',
1065
+                'desc' => __('Payment reminder emails are sent to user automatically.', 'invoicing'),
1066 1066
                 'type' => 'header',
1067 1067
             ),
1068 1068
             'email_overdue_active' => array(
1069 1069
                 'id'   => 'email_overdue_active',
1070
-                'name' => __( 'Enable/Disable', 'invoicing' ),
1071
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
1070
+                'name' => __('Enable/Disable', 'invoicing'),
1071
+                'desc' => __('Enable this email notification', 'invoicing'),
1072 1072
                 'type' => 'checkbox',
1073 1073
                 'std'  => 1
1074 1074
             ),
1075 1075
             'email_due_reminder_days' => array(
1076 1076
                 'id'        => 'email_due_reminder_days',
1077
-                'name'      => __( 'When to Send', 'invoicing' ),
1078
-                'desc'      => __( 'Check when you would like payment reminders sent out.', 'invoicing' ),
1077
+                'name'      => __('When to Send', 'invoicing'),
1078
+                'desc'      => __('Check when you would like payment reminders sent out.', 'invoicing'),
1079 1079
                 'default'   => '',
1080 1080
                 'type'      => 'multicheck',
1081 1081
                 'options'   => $overdue_days_options,
1082 1082
             ),
1083 1083
             'email_overdue_subject' => array(
1084 1084
                 'id'   => 'email_overdue_subject',
1085
-                'name' => __( 'Subject', 'invoicing' ),
1086
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
1085
+                'name' => __('Subject', 'invoicing'),
1086
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
1087 1087
                 'type' => 'text',
1088
-                'std'  => __( '[{site_title}] Payment Reminder', 'invoicing' ),
1088
+                'std'  => __('[{site_title}] Payment Reminder', 'invoicing'),
1089 1089
                 'size' => 'large'
1090 1090
             ),
1091 1091
             'email_overdue_heading' => array(
1092 1092
                 'id'   => 'email_overdue_heading',
1093
-                'name' => __( 'Email Heading', 'invoicing' ),
1094
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
1093
+                'name' => __('Email Heading', 'invoicing'),
1094
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
1095 1095
                 'type' => 'text',
1096
-                'std'  => __( 'Payment reminder for your invoice', 'invoicing' ),
1096
+                'std'  => __('Payment reminder for your invoice', 'invoicing'),
1097 1097
                 'size' => 'large'
1098 1098
             ),
1099 1099
             'email_overdue_body' => array(
1100 1100
                 'id'   => 'email_overdue_body',
1101
-                'name' => __( 'Email Content', 'invoicing' ),
1102
-                'desc' => __( 'The content of the email.', 'invoicing' ),
1101
+                'name' => __('Email Content', 'invoicing'),
1102
+                'desc' => __('The content of the email.', 'invoicing'),
1103 1103
                 'type' => 'rich_editor',
1104
-                'std'  => __( '<p>Hi {full_name},</p><p>This is just a friendly reminder that your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing' ),
1104
+                'std'  => __('<p>Hi {full_name},</p><p>This is just a friendly reminder that your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing'),
1105 1105
                 'class' => 'large',
1106 1106
                 'size'  => 10,
1107 1107
             ),
1108 1108
         ),
1109 1109
     );
1110 1110
 
1111
-    return apply_filters( 'wpinv_get_emails', $emails );
1111
+    return apply_filters('wpinv_get_emails', $emails);
1112 1112
 }
1113 1113
 
1114
-function wpinv_settings_emails( $settings = array() ) {
1114
+function wpinv_settings_emails($settings = array()) {
1115 1115
     $emails = wpinv_get_emails();
1116 1116
 
1117
-    if ( !empty( $emails ) ) {
1118
-        foreach ( $emails as $key => $email ) {
1117
+    if (!empty($emails)) {
1118
+        foreach ($emails as $key => $email) {
1119 1119
             $settings[$key] = $email;
1120 1120
         }
1121 1121
     }
1122 1122
 
1123
-    return apply_filters( 'wpinv_settings_get_emails', $settings );
1123
+    return apply_filters('wpinv_settings_get_emails', $settings);
1124 1124
 }
1125
-add_filter( 'wpinv_settings_emails', 'wpinv_settings_emails', 10, 1 );
1125
+add_filter('wpinv_settings_emails', 'wpinv_settings_emails', 10, 1);
1126 1126
 
1127
-function wpinv_settings_sections_emails( $settings ) {
1127
+function wpinv_settings_sections_emails($settings) {
1128 1128
     $emails = wpinv_get_emails();
1129 1129
 
1130 1130
     if (!empty($emails)) {
1131
-        foreach  ($emails as $key => $email) {
1132
-            $settings[$key] = !empty( $email['email_' . $key . '_header']['name'] ) ? strip_tags( $email['email_' . $key . '_header']['name'] ) : $key;
1131
+        foreach ($emails as $key => $email) {
1132
+            $settings[$key] = !empty($email['email_' . $key . '_header']['name']) ? strip_tags($email['email_' . $key . '_header']['name']) : $key;
1133 1133
         }
1134 1134
     }
1135 1135
 
1136 1136
     return $settings;    
1137 1137
 }
1138
-add_filter( 'wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1 );
1138
+add_filter('wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1);
1139 1139
 
1140
-function wpinv_email_is_enabled( $email_type ) {
1140
+function wpinv_email_is_enabled($email_type) {
1141 1141
     $emails = wpinv_get_emails();
1142
-    $enabled = isset( $emails[$email_type] ) && wpinv_get_option( 'email_'. $email_type . '_active', 0 ) ? true : false;
1142
+    $enabled = isset($emails[$email_type]) && wpinv_get_option('email_' . $email_type . '_active', 0) ? true : false;
1143 1143
 
1144
-    return apply_filters( 'wpinv_email_is_enabled', $enabled, $email_type );
1144
+    return apply_filters('wpinv_email_is_enabled', $enabled, $email_type);
1145 1145
 }
1146 1146
 
1147
-function wpinv_email_get_recipient( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1148
-    switch ( $email_type ) {
1147
+function wpinv_email_get_recipient($email_type = '', $invoice_id = 0, $invoice = array()) {
1148
+    switch ($email_type) {
1149 1149
         case 'new_invoice':
1150 1150
         case 'cancelled_invoice':
1151 1151
         case 'failed_invoice':
1152 1152
             $recipient  = wpinv_get_admin_email();
1153 1153
         break;
1154 1154
         default:
1155
-            $invoice    = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL );
1156
-            $recipient  = !empty( $invoice ) ? $invoice->get_email() : '';
1155
+            $invoice    = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL);
1156
+            $recipient  = !empty($invoice) ? $invoice->get_email() : '';
1157 1157
         break;
1158 1158
     }
1159 1159
 
1160
-    return apply_filters( 'wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice );
1160
+    return apply_filters('wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice);
1161 1161
 }
1162 1162
 
1163
-function wpinv_email_get_subject( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1164
-    $subject    = wpinv_get_option( 'email_' . $email_type . '_subject' );
1165
-    $subject    = __( $subject, 'invoicing' );
1163
+function wpinv_email_get_subject($email_type = '', $invoice_id = 0, $invoice = array()) {
1164
+    $subject    = wpinv_get_option('email_' . $email_type . '_subject');
1165
+    $subject    = __($subject, 'invoicing');
1166 1166
 
1167
-    $subject    = wpinv_email_format_text( $subject, $invoice );
1167
+    $subject    = wpinv_email_format_text($subject, $invoice);
1168 1168
 
1169
-    return apply_filters( 'wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice );
1169
+    return apply_filters('wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice);
1170 1170
 }
1171 1171
 
1172
-function wpinv_email_get_heading( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1173
-    $email_heading = wpinv_get_option( 'email_' . $email_type . '_heading' );
1174
-    $email_heading = __( $email_heading, 'invoicing' );
1172
+function wpinv_email_get_heading($email_type = '', $invoice_id = 0, $invoice = array()) {
1173
+    $email_heading = wpinv_get_option('email_' . $email_type . '_heading');
1174
+    $email_heading = __($email_heading, 'invoicing');
1175 1175
 
1176
-    $email_heading = wpinv_email_format_text( $email_heading, $invoice );
1176
+    $email_heading = wpinv_email_format_text($email_heading, $invoice);
1177 1177
 
1178
-    return apply_filters( 'wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice );
1178
+    return apply_filters('wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice);
1179 1179
 }
1180 1180
 
1181
-function wpinv_email_get_content( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1182
-    $content    = wpinv_get_option( 'email_' . $email_type . '_body' );
1183
-    $content    = __( $content, 'invoicing' );
1181
+function wpinv_email_get_content($email_type = '', $invoice_id = 0, $invoice = array()) {
1182
+    $content    = wpinv_get_option('email_' . $email_type . '_body');
1183
+    $content    = __($content, 'invoicing');
1184 1184
 
1185
-    $content    = wpinv_email_format_text( $content, $invoice );
1185
+    $content    = wpinv_email_format_text($content, $invoice);
1186 1186
 
1187
-    return apply_filters( 'wpinv_email_content', $content, $email_type, $invoice_id, $invoice );
1187
+    return apply_filters('wpinv_email_content', $content, $email_type, $invoice_id, $invoice);
1188 1188
 }
1189 1189
 
1190
-function wpinv_email_get_headers( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1190
+function wpinv_email_get_headers($email_type = '', $invoice_id = 0, $invoice = array()) {
1191 1191
     $from_name = wpinv_mail_get_from_address();
1192 1192
     $from_email = wpinv_mail_get_from_address();
1193 1193
     
1194
-    $invoice    = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL );
1194
+    $invoice    = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL);
1195 1195
     
1196
-    $headers    = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n";
1197
-    $headers    .= "Reply-To: ". $from_email . "\r\n";
1196
+    $headers    = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <$from_email>\r\n";
1197
+    $headers    .= "Reply-To: " . $from_email . "\r\n";
1198 1198
     $headers    .= "Content-Type: " . wpinv_mail_get_content_type() . "\r\n";
1199 1199
     
1200
-    return apply_filters( 'wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice );
1200
+    return apply_filters('wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice);
1201 1201
 }
1202 1202
 
1203
-function wpinv_email_get_attachments( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1203
+function wpinv_email_get_attachments($email_type = '', $invoice_id = 0, $invoice = array()) {
1204 1204
     $attachments = array();
1205 1205
     
1206
-    return apply_filters( 'wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice );
1206
+    return apply_filters('wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice);
1207 1207
 }
1208 1208
 
1209
-function wpinv_email_format_text( $content, $invoice ) {
1209
+function wpinv_email_format_text($content, $invoice) {
1210 1210
     $replace_array = array(
1211 1211
         '{site_title}'      => wpinv_get_blogname(),
1212
-        '{date}'            => date_i18n( get_option( 'date_format' ), (int) current_time( 'timestamp' ) ),
1212
+        '{date}'            => date_i18n(get_option('date_format'), (int)current_time('timestamp')),
1213 1213
     );
1214 1214
     
1215
-    if ( !empty( $invoice->ID ) ) {
1215
+    if (!empty($invoice->ID)) {
1216 1216
         $replace_array = array_merge(
1217 1217
             $replace_array, 
1218 1218
             array(
@@ -1222,65 +1222,65 @@  discard block
 block discarded – undo
1222 1222
                 '{last_name}'       => $invoice->get_last_name(),
1223 1223
                 '{email}'           => $invoice->get_email(),
1224 1224
                 '{invoice_number}'  => $invoice->get_number(),
1225
-                '{invoice_total}'   => $invoice->get_total( true ),
1226
-                '{invoice_link}'    => $invoice->get_view_url( true ),
1227
-                '{invoice_pay_link}'=> $invoice->get_view_url( true ),
1228
-                '{invoice_date}'    => $invoice->get_invoice_date( true ),
1229
-                '{invoice_due_date}'=> $invoice->get_due_date( true ),
1230
-                '{invoice_quote}'   => $invoice->get_invoice_quote_type( $invoice->ID ),
1231
-                '{invoice_label}'   => $invoice->get_invoice_quote_type( $invoice->ID ),
1232
-                '{is_was}'          => strtotime( $invoice->get_due_date() ) < strtotime( date_i18n( 'Y-m-d' ) ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ),
1225
+                '{invoice_total}'   => $invoice->get_total(true),
1226
+                '{invoice_link}'    => $invoice->get_view_url(true),
1227
+                '{invoice_pay_link}'=> $invoice->get_view_url(true),
1228
+                '{invoice_date}'    => $invoice->get_invoice_date(true),
1229
+                '{invoice_due_date}'=> $invoice->get_due_date(true),
1230
+                '{invoice_quote}'   => $invoice->get_invoice_quote_type($invoice->ID),
1231
+                '{invoice_label}'   => $invoice->get_invoice_quote_type($invoice->ID),
1232
+                '{is_was}'          => strtotime($invoice->get_due_date()) < strtotime(date_i18n('Y-m-d')) ? __('was', 'invoicing') : __('is', 'invoicing'),
1233 1233
             )
1234 1234
         );
1235 1235
     }
1236 1236
 
1237
-    $replace_array = apply_filters( 'wpinv_email_format_text', $replace_array, $content, $invoice );
1237
+    $replace_array = apply_filters('wpinv_email_format_text', $replace_array, $content, $invoice);
1238 1238
 
1239
-    foreach ( $replace_array as $key => $value ) {
1240
-        $content = str_replace( $key, $value, $content );
1239
+    foreach ($replace_array as $key => $value) {
1240
+        $content = str_replace($key, $value, $content);
1241 1241
     }
1242 1242
 
1243
-    return apply_filters( 'wpinv_email_content_replace', $content );
1243
+    return apply_filters('wpinv_email_content_replace', $content);
1244 1244
 }
1245 1245
 
1246
-function wpinv_email_style_body( $content ) {
1246
+function wpinv_email_style_body($content) {
1247 1247
     // make sure we only inline CSS for html emails
1248
-    if ( in_array( wpinv_mail_get_content_type(), array( 'text/html', 'multipart/alternative' ) ) && class_exists( 'DOMDocument' ) ) {
1248
+    if (in_array(wpinv_mail_get_content_type(), array('text/html', 'multipart/alternative')) && class_exists('DOMDocument')) {
1249 1249
         ob_start();
1250
-        wpinv_get_template( 'emails/wpinv-email-styles.php' );
1251
-        $css = apply_filters( 'wpinv_email_styles', ob_get_clean() );
1250
+        wpinv_get_template('emails/wpinv-email-styles.php');
1251
+        $css = apply_filters('wpinv_email_styles', ob_get_clean());
1252 1252
 
1253 1253
         // apply CSS styles inline for picky email clients
1254 1254
         try {
1255
-            $emogrifier = new Emogrifier( $content, $css );
1255
+            $emogrifier = new Emogrifier($content, $css);
1256 1256
             $content    = $emogrifier->emogrify();
1257
-        } catch ( Exception $e ) {
1258
-            wpinv_error_log( $e->getMessage(), 'emogrifier' );
1257
+        } catch (Exception $e) {
1258
+            wpinv_error_log($e->getMessage(), 'emogrifier');
1259 1259
         }
1260 1260
     }
1261 1261
     return $content;
1262 1262
 }
1263 1263
 
1264
-function wpinv_email_header( $email_heading = '', $invoice = array(), $email_type = '', $sent_to_admin = false ) {
1265
-    wpinv_get_template( 'emails/wpinv-email-header.php', array( 'email_heading' => $email_heading, 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1264
+function wpinv_email_header($email_heading = '', $invoice = array(), $email_type = '', $sent_to_admin = false) {
1265
+    wpinv_get_template('emails/wpinv-email-header.php', array('email_heading' => $email_heading, 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1266 1266
 }
1267 1267
 
1268 1268
 /**
1269 1269
  * Get the email footer.
1270 1270
  */
1271
-function wpinv_email_footer( $invoice = array(), $email_type = '', $sent_to_admin = false ) {
1272
-    wpinv_get_template( 'emails/wpinv-email-footer.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1271
+function wpinv_email_footer($invoice = array(), $email_type = '', $sent_to_admin = false) {
1272
+    wpinv_get_template('emails/wpinv-email-footer.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1273 1273
 }
1274 1274
 
1275
-function wpinv_email_wrap_message( $message ) {
1275
+function wpinv_email_wrap_message($message) {
1276 1276
     // Buffer
1277 1277
     ob_start();
1278 1278
 
1279
-    do_action( 'wpinv_email_header' );
1279
+    do_action('wpinv_email_header');
1280 1280
 
1281
-    echo wpautop( wptexturize( $message ) );
1281
+    echo wpautop(wptexturize($message));
1282 1282
 
1283
-    do_action( 'wpinv_email_footer' );
1283
+    do_action('wpinv_email_footer');
1284 1284
 
1285 1285
     // Get contents
1286 1286
     $message = ob_get_clean();
@@ -1288,92 +1288,92 @@  discard block
 block discarded – undo
1288 1288
     return $message;
1289 1289
 }
1290 1290
 
1291
-function wpinv_email_invoice_details( $invoice, $email_type = '', $sent_to_admin = false ) {
1292
-    wpinv_get_template( 'emails/wpinv-email-invoice-details.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1291
+function wpinv_email_invoice_details($invoice, $email_type = '', $sent_to_admin = false) {
1292
+    wpinv_get_template('emails/wpinv-email-invoice-details.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1293 1293
 }
1294 1294
 
1295
-function wpinv_email_invoice_items( $invoice, $email_type = '', $sent_to_admin = false ) {
1296
-    wpinv_get_template( 'emails/wpinv-email-invoice-items.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1295
+function wpinv_email_invoice_items($invoice, $email_type = '', $sent_to_admin = false) {
1296
+    wpinv_get_template('emails/wpinv-email-invoice-items.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1297 1297
 }
1298 1298
 
1299
-function wpinv_email_billing_details( $invoice, $email_type = '', $sent_to_admin = false ) {
1300
-    wpinv_get_template( 'emails/wpinv-email-billing-details.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1299
+function wpinv_email_billing_details($invoice, $email_type = '', $sent_to_admin = false) {
1300
+    wpinv_get_template('emails/wpinv-email-billing-details.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1301 1301
 }
1302 1302
 
1303
-function wpinv_send_customer_invoice( $data = array() ) {
1304
-    $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL;
1303
+function wpinv_send_customer_invoice($data = array()) {
1304
+    $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL;
1305 1305
 
1306
-    if ( empty( $invoice_id ) ) {
1306
+    if (empty($invoice_id)) {
1307 1307
         return;
1308 1308
     }
1309 1309
 
1310
-    if ( !current_user_can( 'manage_options' ) ) {
1311
-        wp_die( __( 'You do not have permission to send invoice notification', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
1310
+    if (!current_user_can('manage_options')) {
1311
+        wp_die(__('You do not have permission to send invoice notification', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
1312 1312
     }
1313 1313
     
1314
-    $sent = wpinv_user_invoice_notification( $invoice_id );
1314
+    $sent = wpinv_user_invoice_notification($invoice_id);
1315 1315
 
1316 1316
     if ( -1 === $sent ) {
1317 1317
         $status = 'email_disabled';
1318
-    } elseif ( $sent ) {
1318
+    } elseif ($sent) {
1319 1319
         $status = 'email_sent';
1320 1320
     } else {
1321 1321
         $status = 'email_fail';
1322 1322
     }
1323 1323
 
1324
-    $redirect = add_query_arg( array( 'wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false ) );
1325
-    wp_redirect( $redirect );
1324
+    $redirect = add_query_arg(array('wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false));
1325
+    wp_redirect($redirect);
1326 1326
     exit;
1327 1327
 }
1328
-add_action( 'wpinv_send_invoice', 'wpinv_send_customer_invoice' );
1328
+add_action('wpinv_send_invoice', 'wpinv_send_customer_invoice');
1329 1329
 
1330
-function wpinv_send_overdue_reminder( $data = array() ) {
1331
-    $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL;
1330
+function wpinv_send_overdue_reminder($data = array()) {
1331
+    $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL;
1332 1332
 
1333
-    if ( empty( $invoice_id ) ) {
1333
+    if (empty($invoice_id)) {
1334 1334
         return;
1335 1335
     }
1336 1336
 
1337
-    if ( !current_user_can( 'manage_options' ) ) {
1338
-        wp_die( __( 'You do not have permission to send reminder notification', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
1337
+    if (!current_user_can('manage_options')) {
1338
+        wp_die(__('You do not have permission to send reminder notification', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
1339 1339
     }
1340 1340
 
1341
-    $sent = wpinv_send_payment_reminder_notification( $invoice_id );
1341
+    $sent = wpinv_send_payment_reminder_notification($invoice_id);
1342 1342
     
1343 1343
     $status = $sent ? 'email_sent' : 'email_fail';
1344 1344
 
1345
-    $redirect = add_query_arg( array( 'wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false ) );
1346
-    wp_redirect( $redirect );
1345
+    $redirect = add_query_arg(array('wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false));
1346
+    wp_redirect($redirect);
1347 1347
     exit;
1348 1348
 }
1349
-add_action( 'wpinv_send_reminder', 'wpinv_send_overdue_reminder' );
1349
+add_action('wpinv_send_reminder', 'wpinv_send_overdue_reminder');
1350 1350
 
1351
-function wpinv_send_customer_note_email( $data ) {
1352
-    $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL;
1351
+function wpinv_send_customer_note_email($data) {
1352
+    $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL;
1353 1353
 
1354
-    if ( empty( $invoice_id ) ) {
1354
+    if (empty($invoice_id)) {
1355 1355
         return;
1356 1356
     }
1357 1357
 
1358
-    $sent = wpinv_user_note_notification( $invoice_id, $data );
1358
+    $sent = wpinv_user_note_notification($invoice_id, $data);
1359 1359
 }
1360
-add_action( 'wpinv_new_customer_note', 'wpinv_send_customer_note_email', 10, 1 );
1360
+add_action('wpinv_new_customer_note', 'wpinv_send_customer_note_email', 10, 1);
1361 1361
 
1362
-function wpinv_add_notes_to_invoice_email( $invoice, $email_type, $sent_to_admin ) {
1363
-    if ( !empty( $invoice ) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes( $invoice->ID, true ) ) {
1364
-        $date_format = get_option( 'date_format' );
1365
-        $time_format = get_option( 'time_format' );
1362
+function wpinv_add_notes_to_invoice_email($invoice, $email_type, $sent_to_admin) {
1363
+    if (!empty($invoice) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes($invoice->ID, true)) {
1364
+        $date_format = get_option('date_format');
1365
+        $time_format = get_option('time_format');
1366 1366
         ?>
1367 1367
         <div id="wpinv-email-notes">
1368
-            <h3 class="wpinv-notes-t"><?php echo apply_filters( 'wpinv_email_invoice_notes_title', __( 'Invoice Notes', 'invoicing' ) ); ?></h3>
1368
+            <h3 class="wpinv-notes-t"><?php echo apply_filters('wpinv_email_invoice_notes_title', __('Invoice Notes', 'invoicing')); ?></h3>
1369 1369
             <ol class="wpinv-notes-lists">
1370 1370
         <?php
1371
-        foreach ( $invoice_notes as $note ) {
1372
-            $note_time = strtotime( $note->comment_date );
1371
+        foreach ($invoice_notes as $note) {
1372
+            $note_time = strtotime($note->comment_date);
1373 1373
             ?>
1374 1374
             <li class="comment wpinv-note">
1375
-            <p class="wpinv-note-date meta"><?php printf( __( '%2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( $date_format, $note_time ), date_i18n( $time_format, $note_time ), $note_time ); ?></p>
1376
-            <div class="wpinv-note-desc description"><?php echo wpautop( wptexturize( $note->comment_content ) ); ?></div>
1375
+            <p class="wpinv-note-date meta"><?php printf(__('%2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n($date_format, $note_time), date_i18n($time_format, $note_time), $note_time); ?></p>
1376
+            <div class="wpinv-note-desc description"><?php echo wpautop(wptexturize($note->comment_content)); ?></div>
1377 1377
             </li>
1378 1378
             <?php
1379 1379
         }
@@ -1382,21 +1382,21 @@  discard block
 block discarded – undo
1382 1382
         <?php
1383 1383
     }
1384 1384
 }
1385
-add_action( 'wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3 );
1385
+add_action('wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3);
1386 1386
 
1387 1387
 function wpinv_email_payment_reminders() {
1388 1388
     global $wpi_auto_reminder;
1389
-    if ( !wpinv_get_option( 'email_overdue_active' ) ) {
1389
+    if (!wpinv_get_option('email_overdue_active')) {
1390 1390
         return;
1391 1391
     }
1392 1392
 
1393
-    if ( $reminder_days = wpinv_get_option( 'email_due_reminder_days' ) ) {
1394
-        $reminder_days  = is_array( $reminder_days ) ? array_values( $reminder_days ) : '';
1393
+    if ($reminder_days = wpinv_get_option('email_due_reminder_days')) {
1394
+        $reminder_days  = is_array($reminder_days) ? array_values($reminder_days) : '';
1395 1395
 
1396
-        if ( empty( $reminder_days ) ) {
1396
+        if (empty($reminder_days)) {
1397 1397
             return;
1398 1398
         }
1399
-        $reminder_days  = array_unique( array_map( 'absint', $reminder_days ) );
1399
+        $reminder_days = array_unique(array_map('absint', $reminder_days));
1400 1400
 
1401 1401
         $args = array(
1402 1402
             'post_type'     => 'wpi_invoice',
@@ -1406,7 +1406,7 @@  discard block
 block discarded – undo
1406 1406
             'meta_query'    => array(
1407 1407
                 array(
1408 1408
                     'key'       =>  '_wpinv_due_date',
1409
-                    'value'     =>  array( '', 'none' ),
1409
+                    'value'     =>  array('', 'none'),
1410 1410
                     'compare'   =>  'NOT IN',
1411 1411
                 )
1412 1412
             ),
@@ -1415,143 +1415,143 @@  discard block
 block discarded – undo
1415 1415
             'order'         => 'ASC',
1416 1416
         );
1417 1417
 
1418
-        $invoices = get_posts( $args );
1418
+        $invoices = get_posts($args);
1419 1419
 
1420
-        if ( empty( $invoices ) ) {
1420
+        if (empty($invoices)) {
1421 1421
             return;
1422 1422
         }
1423 1423
 
1424
-        $date_to_send   = array();
1424
+        $date_to_send = array();
1425 1425
 
1426
-        foreach ( $invoices as $id ) {
1427
-            $due_date = get_post_meta( $id, '_wpinv_due_date', true );
1426
+        foreach ($invoices as $id) {
1427
+            $due_date = get_post_meta($id, '_wpinv_due_date', true);
1428 1428
 
1429
-            foreach ( $reminder_days as $key => $days ) {
1430
-                if ( $days !== '' ) {
1431
-                    $date_to_send[$id][] = date_i18n( 'Y-m-d', strtotime( $due_date ) + ( $days * DAY_IN_SECONDS ) );
1429
+            foreach ($reminder_days as $key => $days) {
1430
+                if ($days !== '') {
1431
+                    $date_to_send[$id][] = date_i18n('Y-m-d', strtotime($due_date) + ($days * DAY_IN_SECONDS));
1432 1432
                 }
1433 1433
             }
1434 1434
         }
1435 1435
 
1436
-        $today              = date_i18n( 'Y-m-d' );
1436
+        $today              = date_i18n('Y-m-d');
1437 1437
         $wpi_auto_reminder  = true;
1438 1438
 
1439
-        foreach ( $date_to_send as $id => $values ) {
1440
-            if ( in_array( $today, $values ) ) {
1441
-                $sent = get_post_meta( $id, '_wpinv_reminder_sent', true );
1439
+        foreach ($date_to_send as $id => $values) {
1440
+            if (in_array($today, $values)) {
1441
+                $sent = get_post_meta($id, '_wpinv_reminder_sent', true);
1442 1442
 
1443
-                if ( isset( $sent ) && !empty( $sent ) ) {
1444
-                    if ( !in_array( $today, $sent ) ) {
1445
-                        do_action( 'wpinv_send_payment_reminder_notification', $id );
1443
+                if (isset($sent) && !empty($sent)) {
1444
+                    if (!in_array($today, $sent)) {
1445
+                        do_action('wpinv_send_payment_reminder_notification', $id);
1446 1446
                     }
1447 1447
                 } else {
1448
-                    do_action( 'wpinv_send_payment_reminder_notification', $id );
1448
+                    do_action('wpinv_send_payment_reminder_notification', $id);
1449 1449
                 }
1450 1450
             }
1451 1451
         }
1452 1452
 
1453
-        $wpi_auto_reminder  = false;
1453
+        $wpi_auto_reminder = false;
1454 1454
     }
1455 1455
 }
1456 1456
 
1457
-function wpinv_send_payment_reminder_notification( $invoice_id ) {
1457
+function wpinv_send_payment_reminder_notification($invoice_id) {
1458 1458
     $email_type = 'overdue';
1459
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
1459
+    if (!wpinv_email_is_enabled($email_type)) {
1460 1460
         return false;
1461 1461
     }
1462 1462
 
1463
-    $invoice    = wpinv_get_invoice( $invoice_id );
1464
-    if ( empty( $invoice ) ) {
1463
+    $invoice = wpinv_get_invoice($invoice_id);
1464
+    if (empty($invoice)) {
1465 1465
         return false;
1466 1466
     }
1467 1467
 
1468
-    if ( !$invoice->needs_payment() ) {
1468
+    if (!$invoice->needs_payment()) {
1469 1469
         return false;
1470 1470
     }
1471 1471
 
1472
-    $recipient  = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
1473
-    if ( !is_email( $recipient ) ) {
1472
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
1473
+    if (!is_email($recipient)) {
1474 1474
         return false;
1475 1475
     }
1476 1476
 
1477
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type );
1477
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type);
1478 1478
 
1479
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
1480
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
1481
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
1482
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
1483
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
1479
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
1480
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
1481
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
1482
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
1483
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
1484 1484
 
1485
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
1485
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
1486 1486
             'invoice'       => $invoice,
1487 1487
             'email_type'    => $email_type,
1488 1488
             'email_heading' => $email_heading,
1489 1489
             'sent_to_admin' => false,
1490 1490
             'plain_text'    => false,
1491 1491
             'message_body'  => $message_body
1492
-        ) );
1492
+        ));
1493 1493
 
1494
-    $content        = wpinv_email_format_text( $content, $invoice );
1494
+    $content = wpinv_email_format_text($content, $invoice);
1495 1495
 
1496
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
1497
-    if ( $sent ) {
1498
-        do_action( 'wpinv_payment_reminder_sent', $invoice_id, $invoice );
1496
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
1497
+    if ($sent) {
1498
+        do_action('wpinv_payment_reminder_sent', $invoice_id, $invoice);
1499 1499
     }
1500 1500
 
1501
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type );
1501
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type);
1502 1502
 
1503 1503
     return $sent;
1504 1504
 }
1505
-add_action( 'wpinv_send_payment_reminder_notification', 'wpinv_send_payment_reminder_notification', 10, 1 );
1505
+add_action('wpinv_send_payment_reminder_notification', 'wpinv_send_payment_reminder_notification', 10, 1);
1506 1506
 
1507
-function wpinv_payment_reminder_sent( $invoice_id, $invoice ) {
1507
+function wpinv_payment_reminder_sent($invoice_id, $invoice) {
1508 1508
     global $wpi_auto_reminder;
1509 1509
 
1510
-    $sent = get_post_meta( $invoice_id, '_wpinv_reminder_sent', true );
1510
+    $sent = get_post_meta($invoice_id, '_wpinv_reminder_sent', true);
1511 1511
 
1512
-    if ( empty( $sent ) ) {
1512
+    if (empty($sent)) {
1513 1513
         $sent = array();
1514 1514
     }
1515
-    $sent[] = date_i18n( 'Y-m-d' );
1515
+    $sent[] = date_i18n('Y-m-d');
1516 1516
 
1517
-    update_post_meta( $invoice_id, '_wpinv_reminder_sent', $sent );
1517
+    update_post_meta($invoice_id, '_wpinv_reminder_sent', $sent);
1518 1518
 
1519
-    if ( $wpi_auto_reminder ) { // Auto reminder note.
1520
-        $note = __( 'Automated reminder sent to the user.', 'invoicing' );
1521
-        $invoice->add_note( $note, false, false, true );
1519
+    if ($wpi_auto_reminder) { // Auto reminder note.
1520
+        $note = __('Automated reminder sent to the user.', 'invoicing');
1521
+        $invoice->add_note($note, false, false, true);
1522 1522
     } else { // Menual reminder note.
1523
-        $note = __( 'Manual reminder sent to the user.', 'invoicing' );
1524
-        $invoice->add_note( $note );
1523
+        $note = __('Manual reminder sent to the user.', 'invoicing');
1524
+        $invoice->add_note($note);
1525 1525
     }
1526 1526
 }
1527
-add_action( 'wpinv_payment_reminder_sent', 'wpinv_payment_reminder_sent', 10, 2 );
1527
+add_action('wpinv_payment_reminder_sent', 'wpinv_payment_reminder_sent', 10, 2);
1528 1528
 
1529
-function wpinv_invoice_notification_set_locale( $invoice, $email_type, $site = false ) {
1530
-    if ( empty( $invoice ) ) {
1529
+function wpinv_invoice_notification_set_locale($invoice, $email_type, $site = false) {
1530
+    if (empty($invoice)) {
1531 1531
         return;
1532 1532
     }
1533 1533
 
1534
-    if ( is_int( $invoice ) ) {
1535
-        $invoice = new wpinv_get_invoice( $invoice );
1534
+    if (is_int($invoice)) {
1535
+        $invoice = new wpinv_get_invoice($invoice);
1536 1536
     }
1537 1537
 
1538
-    if ( ! empty( $invoice ) && is_object( $invoice ) ) {
1539
-        if ( ! $site && function_exists( 'get_user_locale' ) ) {
1540
-            $locale = get_user_locale( $invoice->get_user_id() );
1538
+    if (!empty($invoice) && is_object($invoice)) {
1539
+        if (!$site && function_exists('get_user_locale')) {
1540
+            $locale = get_user_locale($invoice->get_user_id());
1541 1541
         } else {
1542 1542
             $locale = get_locale();
1543 1543
         }
1544 1544
 
1545
-        wpinv_switch_to_locale( $locale );
1545
+        wpinv_switch_to_locale($locale);
1546 1546
     }
1547 1547
 }
1548
-add_action( 'wpinv_pre_send_invoice_notification', 'wpinv_invoice_notification_set_locale', 10, 3 );
1548
+add_action('wpinv_pre_send_invoice_notification', 'wpinv_invoice_notification_set_locale', 10, 3);
1549 1549
 
1550
-function wpinv_invoice_notification_restore_locale( $invoice, $email_type, $site = false ) {
1551
-    if ( empty( $invoice ) ) {
1550
+function wpinv_invoice_notification_restore_locale($invoice, $email_type, $site = false) {
1551
+    if (empty($invoice)) {
1552 1552
         return;
1553 1553
     }
1554 1554
 
1555 1555
     wpinv_restore_locale();
1556 1556
 }
1557
-add_action( 'wpinv_post_send_invoice_notification', 'wpinv_invoice_notification_restore_locale', 10, 3 );
1557
+add_action('wpinv_post_send_invoice_notification', 'wpinv_invoice_notification_restore_locale', 10, 3);
Please login to merge, or discard this patch.
includes/class-wpinv-bp-core.php 1 patch
Spacing   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
     exit; // Exit if accessed directly
4 4
 }
5 5
 
@@ -9,42 +9,42 @@  discard block
 block discarded – undo
9 9
     
10 10
     public function __construct() {
11 11
 
12
-        if ( !defined( 'WPINV_BP_SLUG' ) ) {
13
-            define( 'WPINV_BP_SLUG', 'invoices' );
12
+        if (!defined('WPINV_BP_SLUG')) {
13
+            define('WPINV_BP_SLUG', 'invoices');
14 14
         }
15 15
 
16
-        add_action( 'wp_ajax_invoicing_filter', array( $this, 'invoices_content' ) );
17
-        add_action( 'wp_ajax_nopriv_invoicing_filter', array( $this, 'invoices_content' ) );
18
-        add_filter( 'wpinv_settings_sections_general', array( $this, 'bp_section' ), 10, 1 );
19
-        add_filter( 'wpinv_settings_general', array( $this, 'bp_settings' ), 10, 1 );
20
-        add_filter( 'wp_nav_menu_objects', array( $this, 'wp_nav_menu_objects' ), 10, 2 );
16
+        add_action('wp_ajax_invoicing_filter', array($this, 'invoices_content'));
17
+        add_action('wp_ajax_nopriv_invoicing_filter', array($this, 'invoices_content'));
18
+        add_filter('wpinv_settings_sections_general', array($this, 'bp_section'), 10, 1);
19
+        add_filter('wpinv_settings_general', array($this, 'bp_settings'), 10, 1);
20
+        add_filter('wp_nav_menu_objects', array($this, 'wp_nav_menu_objects'), 10, 2);
21 21
         add_action('bp_setup_nav', array($this, 'setup_nav'), 15);
22 22
         
23
-        $position       = wpinv_get_option( 'wpinv_menu_position' );
23
+        $position       = wpinv_get_option('wpinv_menu_position');
24 24
         $position       = $position !== '' && $position !== false ? $position : 91;
25
-        $this->position = apply_filters( 'wpinv_bp_nav_position', $position );
26
-        $this->id     = WPINV_BP_SLUG;
25
+        $this->position = apply_filters('wpinv_bp_nav_position', $position);
26
+        $this->id = WPINV_BP_SLUG;
27 27
     }
28 28
 
29 29
     public function setup_nav() {
30 30
 
31
-        if ( wpinv_get_option( 'wpinv_bp_hide_menu' ) || !is_user_logged_in()) {
31
+        if (wpinv_get_option('wpinv_bp_hide_menu') || !is_user_logged_in()) {
32 32
             return;
33 33
         }
34 34
 
35
-        if(bp_displayed_user_id() != bp_loggedin_user_id() && !current_user_can('administrator')){
35
+        if (bp_displayed_user_id() != bp_loggedin_user_id() && !current_user_can('administrator')) {
36 36
             return;
37 37
         }
38 38
 
39 39
         $count = $this->get_invoice_count();
40
-        $class = ( 0 === $count ) ? 'no-count' : 'count';
40
+        $class = (0 === $count) ? 'no-count' : 'count';
41 41
 
42 42
         $main_nav_name = sprintf(
43
-            __( 'My Invoices %s', 'invoicing' ),
43
+            __('My Invoices %s', 'invoicing'),
44 44
             sprintf(
45 45
                 '<span class="%s">%s</span>',
46
-                esc_attr( $class ),
47
-                bp_core_number_format( $count )
46
+                esc_attr($class),
47
+                bp_core_number_format($count)
48 48
             )
49 49
         );
50 50
 
@@ -52,31 +52,31 @@  discard block
 block discarded – undo
52 52
             'name'                => $main_nav_name,
53 53
             'slug'                => WPINV_BP_SLUG,
54 54
             'position'            => $this->position,
55
-            'screen_function'     => array( $this, 'invoices_screen' ),
55
+            'screen_function'     => array($this, 'invoices_screen'),
56 56
             'default_subnav_slug' => 'invoices',
57 57
             'item_css_id'         => $this->id
58 58
         );
59 59
 
60
-        bp_core_new_nav_item( $main_nav );
60
+        bp_core_new_nav_item($main_nav);
61 61
     }
62 62
     
63 63
     public function invoices_screen() {
64
-        if ( wpinv_get_option( 'wpinv_bp_hide_menu' ) ) {
64
+        if (wpinv_get_option('wpinv_bp_hide_menu')) {
65 65
             return;
66 66
         }
67 67
         
68
-        add_action( 'bp_template_content', array( $this, 'invoices_content' ) );
68
+        add_action('bp_template_content', array($this, 'invoices_content'));
69 69
 
70
-        $template = apply_filters( 'bp_core_template_plugin', 'members/single/plugins' );
70
+        $template = apply_filters('bp_core_template_plugin', 'members/single/plugins');
71 71
         
72
-        bp_core_load_template( apply_filters( 'wpinv_bp_core_template_plugin', $template ) );
72
+        bp_core_load_template(apply_filters('wpinv_bp_core_template_plugin', $template));
73 73
     }
74 74
     
75 75
     public function invoices_content() {
76
-        if ( $this->has_invoices( bp_ajax_querystring( 'invoices' ) ) ) {
76
+        if ($this->has_invoices(bp_ajax_querystring('invoices'))) {
77 77
             global $invoices_template;
78 78
             
79
-            do_action( 'wpinv_bp_invoices_before_content' );
79
+            do_action('wpinv_bp_invoices_before_content');
80 80
             ?>
81 81
             <div class="wpi-g wpi-bp-invoices invoices invoicing" style="position:relative">
82 82
                 <div id="pag-top" class="pagination">
@@ -90,61 +90,61 @@  discard block
 block discarded – undo
90 90
                 <table class="table table-bordered table-hover table-responsive wpi-user-invoices" style="margin:0">
91 91
                     <thead>
92 92
                         <tr>
93
-                            <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?>
94
-                                <th class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>"><span class="nobr"><?php echo esc_html( $column_name['title'] ); ?></span></th>
93
+                            <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?>
94
+                                <th class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : ''); ?>"><span class="nobr"><?php echo esc_html($column_name['title']); ?></span></th>
95 95
                             <?php endforeach; ?>
96 96
                         </tr>
97 97
                     </thead>
98 98
                     <tbody>
99
-                        <?php foreach ( $invoices_template->invoices as $invoice ) {
99
+                        <?php foreach ($invoices_template->invoices as $invoice) {
100 100
                             ?>
101 101
                             <tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>">
102
-                                <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?>
103
-                                    <td class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>" data-title="<?php echo esc_attr( $column_name['title'] ); ?>">
104
-                                        <?php if ( has_action( 'wpinv_user_invoices_column_' . $column_id ) ) : ?>
105
-                                            <?php do_action( 'wpinv_user_invoices_column_' . $column_id, $invoice ); ?>
106
-
107
-                                        <?php elseif ( 'invoice-number' === $column_id ) : ?>
108
-                                            <a href="<?php echo esc_url( $invoice->get_view_url() ); ?>">
109
-                                                <?php echo _x( '#', 'hash before invoice number', 'invoicing' ) . $invoice->get_number(); ?>
102
+                                <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?>
103
+                                    <td class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : ''); ?>" data-title="<?php echo esc_attr($column_name['title']); ?>">
104
+                                        <?php if (has_action('wpinv_user_invoices_column_' . $column_id)) : ?>
105
+                                            <?php do_action('wpinv_user_invoices_column_' . $column_id, $invoice); ?>
106
+
107
+                                        <?php elseif ('invoice-number' === $column_id) : ?>
108
+                                            <a href="<?php echo esc_url($invoice->get_view_url()); ?>">
109
+                                                <?php echo _x('#', 'hash before invoice number', 'invoicing') . $invoice->get_number(); ?>
110 110
                                             </a>
111 111
 
112
-                                        <?php elseif ( 'created-date' === $column_id ) : $date = wpinv_get_date_created( $invoice->ID ); $dateYMD = wpinv_get_date_created( $invoice->ID, 'Y-m-d H:i:s' ); ?>
113
-                                            <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
112
+                                        <?php elseif ('created-date' === $column_id) : $date = wpinv_get_date_created($invoice->ID); $dateYMD = wpinv_get_date_created($invoice->ID, 'Y-m-d H:i:s'); ?>
113
+                                            <time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
114 114
 
115
-                                        <?php elseif ( 'payment-date' === $column_id ) : $date = wpinv_get_invoice_date( $invoice->ID, '', false ); $dateYMD = wpinv_get_invoice_date( $invoice->ID, 'Y-m-d H:i:s', false ); ?>
116
-                                            <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
115
+                                        <?php elseif ('payment-date' === $column_id) : $date = wpinv_get_invoice_date($invoice->ID, '', false); $dateYMD = wpinv_get_invoice_date($invoice->ID, 'Y-m-d H:i:s', false); ?>
116
+                                            <time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
117 117
 
118
-                                        <?php elseif ( 'invoice-status' === $column_id ) : ?>
119
-                                            <?php echo wpinv_invoice_status_label( $invoice_status, $invoice->get_status( true ) ) ; ?>
118
+                                        <?php elseif ('invoice-status' === $column_id) : ?>
119
+                                            <?php echo wpinv_invoice_status_label($invoice_status, $invoice->get_status(true)); ?>
120 120
 
121
-                                        <?php elseif ( 'invoice-total' === $column_id ) : ?>
122
-                                            <?php echo $invoice->get_total( true ); ?>
121
+                                        <?php elseif ('invoice-total' === $column_id) : ?>
122
+                                            <?php echo $invoice->get_total(true); ?>
123 123
 
124
-                                        <?php elseif ( 'invoice-actions' === $column_id ) : ?>
124
+                                        <?php elseif ('invoice-actions' === $column_id) : ?>
125 125
                                             <?php
126 126
                                                 $actions = array(
127 127
                                                     'pay'    => array(
128 128
                                                         'url'  => $invoice->get_checkout_payment_url(),
129
-                                                        'name' => __( 'Pay Now', 'invoicing' ),
129
+                                                        'name' => __('Pay Now', 'invoicing'),
130 130
                                                         'class' => 'btn-success'
131 131
                                                     ),
132 132
                                                     'print'   => array(
133 133
                                                         'url'  => $invoice->get_view_url(),
134
-                                                        'name' => __( 'Print', 'invoicing' ),
134
+                                                        'name' => __('Print', 'invoicing'),
135 135
                                                         'class' => 'btn-primary',
136 136
                                                         'attrs' => 'target="_blank"'
137 137
                                                     )
138 138
                                                 );
139 139
 
140
-                                                if ( ! $invoice->needs_payment() ) {
141
-                                                    unset( $actions['pay'] );
140
+                                                if (!$invoice->needs_payment()) {
141
+                                                    unset($actions['pay']);
142 142
                                                 }
143 143
 
144
-                                                if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) {
145
-                                                    foreach ( $actions as $key => $action ) {
144
+                                                if ($actions = apply_filters('wpinv_user_invoices_actions', $actions, $invoice)) {
145
+                                                    foreach ($actions as $key => $action) {
146 146
                                                         $class = !empty($action['class']) ? sanitize_html_class($action['class']) : '';
147
-                                                        echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>';
147
+                                                        echo '<a href="' . esc_url($action['url']) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class($key) . '" ' . (!empty($action['attrs']) ? $action['attrs'] : '') . '>' . $action['name'] . '</a>';
148 148
                                                     }
149 149
                                                 }
150 150
                                             ?>
@@ -172,64 +172,64 @@  discard block
 block discarded – undo
172 172
             </div>
173 173
             <?php
174 174
         
175
-            do_action( 'wpinv_bp_invoices_after_content' );
175
+            do_action('wpinv_bp_invoices_after_content');
176 176
         } else {
177 177
             ?>
178 178
             <div id="message" class="info">
179
-                <p><?php _e( 'No invoice has been made yet.', 'invoicing' ); ?></p>
179
+                <p><?php _e('No invoice has been made yet.', 'invoicing'); ?></p>
180 180
             </div>
181 181
             <?php
182 182
         }
183 183
         
184
-        if ( defined( 'DOING_AJAX' ) ) {
184
+        if (defined('DOING_AJAX')) {
185 185
             exit;
186 186
         }
187 187
     }
188 188
     
189
-    public function has_invoices( $args = '' ) {
189
+    public function has_invoices($args = '') {
190 190
         global $invoices_template;
191 191
 
192
-        $per_page = absint( wpinv_get_option( 'wpinv_bp_per_page' ) );
192
+        $per_page = absint(wpinv_get_option('wpinv_bp_per_page'));
193 193
         // Parse arguments.
194
-        $r = bp_parse_args( $args, array(
194
+        $r = bp_parse_args($args, array(
195 195
             'status'            => 'all',
196 196
             'page_arg'          => 'bpage',
197 197
             'page'              => 1,
198 198
             'per_page'          => $per_page > 0 ? $per_page : 20,
199 199
             'max'               => false,
200 200
             'user_id'           => bp_displayed_user_id(),
201
-        ), 'has_invoices' );
201
+        ), 'has_invoices');
202 202
 
203 203
 
204
-        if ( ! empty( $r['max'] ) && ( (int)$r['per_page'] > (int)$r['max'] ) ) {
204
+        if (!empty($r['max']) && ((int)$r['per_page'] > (int)$r['max'])) {
205 205
             $r['per_page'] = (int)$r['max'];
206 206
         }
207 207
 
208 208
         // Get the invoices.
209
-        $invoices_template = new WPInv_BP_Invoices_Template( $r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg'] );
209
+        $invoices_template = new WPInv_BP_Invoices_Template($r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg']);
210 210
 
211
-        return apply_filters( 'wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r );
211
+        return apply_filters('wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r);
212 212
     }
213 213
     
214 214
     public function get_invoice_count() {
215
-        $query      = apply_filters( 'wpinv_user_invoices_count_query', array( 'status' => 'all','user' => bp_displayed_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false ) );
216
-        $invoices   = wpinv_get_invoices( $query );
215
+        $query      = apply_filters('wpinv_user_invoices_count_query', array('status' => 'all', 'user' => bp_displayed_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false));
216
+        $invoices   = wpinv_get_invoices($query);
217 217
         
218
-        return !empty( $invoices ) ? count( $invoices ) : 0;
218
+        return !empty($invoices) ? count($invoices) : 0;
219 219
     }
220 220
     
221 221
     public function pagination_count() {
222 222
         global $invoices_template;
223 223
 
224
-        $start_num = intval( ( $invoices_template->pag_page - 1 ) * $invoices_template->pag_num ) + 1;
225
-        $from_num  = bp_core_number_format( $start_num );
226
-        $to_num    = bp_core_number_format( ( $start_num + ( $invoices_template->pag_num - 1 ) > $invoices_template->total_invoice_count ) ? $invoices_template->total_invoice_count : $start_num + ( $invoices_template->pag_num - 1 ) );
227
-        $total     = bp_core_number_format( $invoices_template->total_invoice_count );
224
+        $start_num = intval(($invoices_template->pag_page - 1) * $invoices_template->pag_num) + 1;
225
+        $from_num  = bp_core_number_format($start_num);
226
+        $to_num    = bp_core_number_format(($start_num + ($invoices_template->pag_num - 1) > $invoices_template->total_invoice_count) ? $invoices_template->total_invoice_count : $start_num + ($invoices_template->pag_num - 1));
227
+        $total     = bp_core_number_format($invoices_template->total_invoice_count);
228 228
 
229
-        if ( 1 == $invoices_template->total_invoice_count ) {
230
-            $message = __( 'Viewing 1 invoice', 'invoicing' );
229
+        if (1 == $invoices_template->total_invoice_count) {
230
+            $message = __('Viewing 1 invoice', 'invoicing');
231 231
         } else {
232
-            $message = sprintf( _n( 'Viewing %1$s - %2$s of %3$s invoice', 'Viewing %1$s - %2$s of %3$s invoices', $invoices_template->total_invoice_count, 'invoicing' ), $from_num, $to_num, $total );
232
+            $message = sprintf(_n('Viewing %1$s - %2$s of %3$s invoice', 'Viewing %1$s - %2$s of %3$s invoices', $invoices_template->total_invoice_count, 'invoicing'), $from_num, $to_num, $total);
233 233
         }
234 234
 
235 235
         return $message;
@@ -238,32 +238,32 @@  discard block
 block discarded – undo
238 238
     function pagination_links() {
239 239
         global $invoices_template;
240 240
 
241
-        return apply_filters( 'wpinv_bp_get_pagination_links', $invoices_template->pag_links );
241
+        return apply_filters('wpinv_bp_get_pagination_links', $invoices_template->pag_links);
242 242
     }
243 243
     
244
-    public function bp_section( $settings = array() ) {
245
-        $settings['wpinv_bp'] = __( 'BuddyPress Integration', 'invoicing' );
244
+    public function bp_section($settings = array()) {
245
+        $settings['wpinv_bp'] = __('BuddyPress Integration', 'invoicing');
246 246
         return $settings;
247 247
     }
248 248
     
249
-    public function bp_settings( $settings = array() ) {
249
+    public function bp_settings($settings = array()) {
250 250
         $settings['wpinv_bp'] = array(
251 251
             'wpinv_bp_labels' => array(
252 252
                 'id'   => 'wpinv_bp_settings',
253
-                'name' => '<h3>' . __( 'BuddyPress Integration', 'invoicing' ) . '</h3>',
253
+                'name' => '<h3>' . __('BuddyPress Integration', 'invoicing') . '</h3>',
254 254
                 'desc' => '',
255 255
                 'type' => 'header',
256 256
             ),
257 257
             'wpinv_bp_hide_menu' => array(
258 258
                 'id'   => 'wpinv_bp_hide_menu',
259
-                'name' => __( 'Hide Invoices link', 'invoicing' ),
260
-                'desc' => __( 'Hide Invoices link from BP Profile menu.', 'invoicing' ),
259
+                'name' => __('Hide Invoices link', 'invoicing'),
260
+                'desc' => __('Hide Invoices link from BP Profile menu.', 'invoicing'),
261 261
                 'type' => 'checkbox',
262 262
             ),
263 263
             'wpinv_menu_position' => array(
264 264
                 'id'   => 'wpinv_menu_position',
265
-                'name' => __( 'Menu position', 'invoicing' ),
266
-                'desc' => __( 'Menu position for the Invoices link in BP Profile menu.', 'invoicing' ),
265
+                'name' => __('Menu position', 'invoicing'),
266
+                'desc' => __('Menu position for the Invoices link in BP Profile menu.', 'invoicing'),
267 267
                 'type' => 'number',
268 268
                 'size' => 'small',
269 269
                 'min'  => '1',
@@ -273,8 +273,8 @@  discard block
 block discarded – undo
273 273
             ),
274 274
             'wpinv_bp_per_page' => array(
275 275
                 'id'   => 'wpinv_bp_per_page',
276
-                'name' => __( 'Max invoices per page', 'invoicing' ),
277
-                'desc' => __( 'Enter a number to lists the invoices for each page.', 'invoicing' ),
276
+                'name' => __('Max invoices per page', 'invoicing'),
277
+                'desc' => __('Enter a number to lists the invoices for each page.', 'invoicing'),
278 278
                 'type' => 'number',
279 279
                 'size' => 'small',
280 280
                 'min'  => '1',
@@ -287,20 +287,20 @@  discard block
 block discarded – undo
287 287
         return $settings;
288 288
     }
289 289
 
290
-    public function wp_nav_menu_objects($items, $args){
291
-        if(!is_user_logged_in()){
290
+    public function wp_nav_menu_objects($items, $args) {
291
+        if (!is_user_logged_in()) {
292 292
             return $items;
293 293
         }
294 294
 
295
-        if(!apply_filters('wpinv_bp_invoice_history_redirect', true, $items, $args)){
295
+        if (!apply_filters('wpinv_bp_invoice_history_redirect', true, $items, $args)) {
296 296
             return $items;
297 297
         }
298 298
 
299 299
         $user_id = get_current_user_id();
300
-        $link = bp_core_get_user_domain( $user_id ).WPINV_BP_SLUG;
300
+        $link = bp_core_get_user_domain($user_id) . WPINV_BP_SLUG;
301 301
         $history_link = wpinv_get_history_page_uri();
302
-        foreach ( $items as $item ) {
303
-            $item->url = str_replace( $history_link, $link, $item->url );
302
+        foreach ($items as $item) {
303
+            $item->url = str_replace($history_link, $link, $item->url);
304 304
         }
305 305
 
306 306
         return $items;
@@ -318,25 +318,25 @@  discard block
 block discarded – undo
318 318
     public $pag_links = '';
319 319
     public $total_invoice_count = 0;
320 320
     
321
-    public function __construct( $status, $page, $per_page, $max, $user_id, $page_arg = 'bpage' ) {
322
-        $this->invoices = array( 'invoices' => array(), 'total' => 0 );
321
+    public function __construct($status, $page, $per_page, $max, $user_id, $page_arg = 'bpage') {
322
+        $this->invoices = array('invoices' => array(), 'total' => 0);
323 323
         
324
-        $this->pag_arg  = sanitize_key( $page_arg );
325
-        $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $page );
326
-        $this->pag_num  = bp_sanitize_pagination_arg( 'num', $per_page );
324
+        $this->pag_arg  = sanitize_key($page_arg);
325
+        $this->pag_page = bp_sanitize_pagination_arg($this->pag_arg, $page);
326
+        $this->pag_num  = bp_sanitize_pagination_arg('num', $per_page);
327 327
 
328
-        $query_args     = array( 'user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true );
329
-        if ( !empty( $status ) && $status != 'all' ) {
328
+        $query_args     = array('user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true);
329
+        if (!empty($status) && $status != 'all') {
330 330
            $query_args['status'] = $status;
331 331
         }
332
-        $invoices  = wpinv_get_invoices( apply_filters( 'wpinv_bp_user_invoices_query', $query_args ) );
332
+        $invoices = wpinv_get_invoices(apply_filters('wpinv_bp_user_invoices_query', $query_args));
333 333
         
334
-        if ( !empty( $invoices ) && !empty( $invoices->found_posts ) ) {
335
-            $this->invoices['invoices'] = array_map( 'wpinv_get_invoice', $invoices->posts );
334
+        if (!empty($invoices) && !empty($invoices->found_posts)) {
335
+            $this->invoices['invoices'] = array_map('wpinv_get_invoice', $invoices->posts);
336 336
             $this->invoices['total']    = $invoices->found_posts;
337 337
         }
338 338
 
339
-        if ( empty( $max ) || ( $max >= (int)$this->invoices['total'] ) ) {
339
+        if (empty($max) || ($max >= (int)$this->invoices['total'])) {
340 340
             $this->total_invoice_count = (int)$this->invoices['total'];
341 341
         } else {
342 342
             $this->total_invoice_count = (int)$max;
@@ -344,52 +344,52 @@  discard block
 block discarded – undo
344 344
 
345 345
         $this->invoices = $this->invoices['invoices'];
346 346
 
347
-        $invoice_count = count( $this->invoices );
347
+        $invoice_count = count($this->invoices);
348 348
 
349
-        if ( empty( $max ) || ( $max >= (int)$invoice_count ) ) {
349
+        if (empty($max) || ($max >= (int)$invoice_count)) {
350 350
             $this->invoice_count = (int)$invoice_count;
351 351
         } else {
352 352
             $this->invoice_count = (int)$max;
353 353
         }
354 354
         
355
-        if ( ! empty( $this->total_invoice_count ) && ! empty( $this->pag_num ) ) {
356
-            $this->pag_links = paginate_links( array(
357
-                'base'      => add_query_arg( $this->pag_arg, '%#%' ),
355
+        if (!empty($this->total_invoice_count) && !empty($this->pag_num)) {
356
+            $this->pag_links = paginate_links(array(
357
+                'base'      => add_query_arg($this->pag_arg, '%#%'),
358 358
                 'format'    => '',
359
-                'total'     => ceil( (int)$this->total_invoice_count / (int)$this->pag_num ),
359
+                'total'     => ceil((int)$this->total_invoice_count / (int)$this->pag_num),
360 360
                 'current'   => (int)$this->pag_page,
361
-                'prev_text' => _x( '&larr;', 'Invoice pagination previous text', 'invoicing' ),
362
-                'next_text' => _x( '&rarr;', 'Invoice pagination next text',     'invoicing' ),
361
+                'prev_text' => _x('&larr;', 'Invoice pagination previous text', 'invoicing'),
362
+                'next_text' => _x('&rarr;', 'Invoice pagination next text', 'invoicing'),
363 363
                 'mid_size'  => 1,
364 364
                 'add_args'  => array(),
365
-            ) );
365
+            ));
366 366
         }
367 367
     }
368 368
 
369 369
     public function has_invoices() {
370
-        return (bool) ! empty( $this->invoice_count );
370
+        return (bool)!empty($this->invoice_count);
371 371
     }
372 372
 
373 373
     public function next_invoice() {
374 374
         $this->current_invoice++;
375
-        $this->invoice = $this->invoices[ $this->current_invoice ];
375
+        $this->invoice = $this->invoices[$this->current_invoice];
376 376
 
377 377
         return $this->invoice;
378 378
     }
379 379
 
380 380
     public function rewind_invoices() {
381 381
         $this->current_invoice = -1;
382
-        if ( $this->invoice_count > 0 ) {
382
+        if ($this->invoice_count > 0) {
383 383
             $this->invoice = $this->invoices[0];
384 384
         }
385 385
     }
386 386
 
387 387
     public function invoices() {
388
-        if ( ( $this->current_invoice + 1 ) < $this->invoice_count ) {
388
+        if (($this->current_invoice + 1) < $this->invoice_count) {
389 389
             return true;
390
-        } elseif ( ( $this->current_invoice + 1 ) === $this->invoice_count ) {
390
+        } elseif (($this->current_invoice + 1) === $this->invoice_count) {
391 391
 
392
-            do_action( 'wpinv_bp_invoice_loop_end' );
392
+            do_action('wpinv_bp_invoice_loop_end');
393 393
             
394 394
             $this->rewind_invoices();
395 395
         }
@@ -403,19 +403,19 @@  discard block
 block discarded – undo
403 403
         $this->in_the_loop = true;
404 404
         $this->invoice     = $this->next_invoice();
405 405
 
406
-        if ( 0 === $this->current_invoice ) {
407
-            do_action( 'wpinv_bp_invoice_loop_start' );
406
+        if (0 === $this->current_invoice) {
407
+            do_action('wpinv_bp_invoice_loop_start');
408 408
         }
409 409
     }
410 410
 }
411 411
 
412 412
 function wpinv_bp_setup_component() {
413 413
 
414
-    if(!class_exists( 'BuddyPress' )){
414
+    if (!class_exists('BuddyPress')) {
415 415
         return;
416 416
     }
417 417
 
418 418
     new WPInv_BP_Component();
419 419
 
420 420
 }
421
-add_action( 'bp_loaded', 'wpinv_bp_setup_component' );
422 421
\ No newline at end of file
422
+add_action('bp_loaded', 'wpinv_bp_setup_component');
423 423
\ No newline at end of file
Please login to merge, or discard this patch.
templates/wpinv-checkout-cart.php 1 patch
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -5,138 +5,138 @@
 block discarded – undo
5 5
 
6 6
 global $wpinv_euvat, $post, $ajax_cart_details, $wpi_cart_columns;
7 7
 $invoice            = wpinv_get_invoice_cart();
8
-$cart_items         = !empty( $ajax_cart_details ) ? $ajax_cart_details : wpinv_get_cart_content_details();
8
+$cart_items         = !empty($ajax_cart_details) ? $ajax_cart_details : wpinv_get_cart_content_details();
9 9
 $quantities_enabled = wpinv_item_quantities_enabled();
10 10
 $use_taxes          = wpinv_use_taxes();
11 11
 $tax_label          = $wpinv_euvat->tax_label();
12
-$tax_title          = $use_taxes ? ( wpinv_prices_include_tax() ? wp_sprintf( __( '(%s Incl.)', 'invoicing' ), $tax_label ) : wp_sprintf( __( '(%s Excl.)', 'invoicing' ), $tax_label ) ) : '';
12
+$tax_title          = $use_taxes ? (wpinv_prices_include_tax() ? wp_sprintf(__('(%s Incl.)', 'invoicing'), $tax_label) : wp_sprintf(__('(%s Excl.)', 'invoicing'), $tax_label)) : '';
13 13
 ?>
14 14
 <table id="wpinv_checkout_cart" class="table table-bordered table-hover">
15 15
     <thead>
16 16
         <tr class="wpinv_cart_header_row">
17
-            <?php do_action( 'wpinv_checkout_table_header_first' ); ?>
18
-            <th class="wpinv_cart_item_name text-left"><?php _e( 'Item Name', 'invoicing' ); ?></th>
19
-            <th class="wpinv_cart_item_price text-right"><?php _e( 'Item Price', 'invoicing' ); ?></th>
20
-            <?php if ( $quantities_enabled ) { ?>
21
-            <th class="wpinv_cart_item_qty text-right"><?php _e( 'Qty', 'invoicing' ); ?></th>
17
+            <?php do_action('wpinv_checkout_table_header_first'); ?>
18
+            <th class="wpinv_cart_item_name text-left"><?php _e('Item Name', 'invoicing'); ?></th>
19
+            <th class="wpinv_cart_item_price text-right"><?php _e('Item Price', 'invoicing'); ?></th>
20
+            <?php if ($quantities_enabled) { ?>
21
+            <th class="wpinv_cart_item_qty text-right"><?php _e('Qty', 'invoicing'); ?></th>
22 22
             <?php } ?>
23
-            <?php if ( $use_taxes ) { ?>
23
+            <?php if ($use_taxes) { ?>
24 24
             <th class="wpinv_cart_item_tax text-right"><?php echo $tax_label . ' <span class="normal small">(%)</span>'; ?></th>
25 25
             <?php } ?>
26
-            <th class="wpinv_cart_item_subtotal text-right"><?php echo __( 'Item Total', 'invoicing' ) . ' <span class="normal small">' . $tax_title . '<span>'; ?></th>
27
-            <?php do_action( 'wpinv_checkout_table_header_last' ); ?>
26
+            <th class="wpinv_cart_item_subtotal text-right"><?php echo __('Item Total', 'invoicing') . ' <span class="normal small">' . $tax_title . '<span>'; ?></th>
27
+            <?php do_action('wpinv_checkout_table_header_last'); ?>
28 28
         </tr>
29 29
     </thead>
30 30
     <tbody>
31 31
         <?php
32
-            do_action( 'wpinv_cart_items_before' );
32
+            do_action('wpinv_cart_items_before');
33 33
             
34
-            if ( $cart_items ) {
35
-                foreach ( $cart_items as $key => $item ) {
36
-                    $wpi_item = !empty( $item['id'] ) ? new WPInv_Item( $item['id'] ) : NULL;
34
+            if ($cart_items) {
35
+                foreach ($cart_items as $key => $item) {
36
+                    $wpi_item = !empty($item['id']) ? new WPInv_Item($item['id']) : NULL;
37 37
                 ?>
38
-                <tr class="wpinv_cart_item" id="wpinv_cart_item_<?php echo esc_attr( $key ) . '_' . esc_attr( $item['id'] ); ?>" data-item-id="<?php echo esc_attr( $item['id'] ); ?>">
39
-                    <?php do_action( 'wpinv_checkout_table_body_first', $item ); ?>
38
+                <tr class="wpinv_cart_item" id="wpinv_cart_item_<?php echo esc_attr($key) . '_' . esc_attr($item['id']); ?>" data-item-id="<?php echo esc_attr($item['id']); ?>">
39
+                    <?php do_action('wpinv_checkout_table_body_first', $item); ?>
40 40
                     <td class="wpinv_cart_item_name text-left">
41 41
                         <?php
42
-                            if ( current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail( $item['id'] ) ) {
42
+                            if (current_theme_supports('post-thumbnails') && has_post_thumbnail($item['id'])) {
43 43
                                 echo '<div class="wpinv_cart_item_image">';
44
-                                    echo get_the_post_thumbnail( $item['id'], apply_filters( 'wpinv_checkout_image_size', array( 25,25 ) ) );
44
+                                    echo get_the_post_thumbnail($item['id'], apply_filters('wpinv_checkout_image_size', array(25, 25)));
45 45
                                 echo '</div>';
46 46
                             }
47
-                            $item_title = esc_html( wpinv_get_cart_item_name( $item ) ) . wpinv_get_item_suffix( $wpi_item );
47
+                            $item_title = esc_html(wpinv_get_cart_item_name($item)) . wpinv_get_item_suffix($wpi_item);
48 48
                             echo '<span class="wpinv_checkout_cart_item_title">' . $item_title . '</span>';
49
-                            $summary = apply_filters( 'wpinv_checkout_cart_line_item_summary', '', $item, $wpi_item, $invoice );
50
-                            if ( !empty( $summary ) ) {
49
+                            $summary = apply_filters('wpinv_checkout_cart_line_item_summary', '', $item, $wpi_item, $invoice);
50
+                            if (!empty($summary)) {
51 51
                                 echo $summary;
52 52
                             }
53 53
                         ?>
54 54
                     </td>
55 55
                     <td class="wpinv_cart_item_price text-right">
56 56
                         <?php 
57
-                        echo wpinv_cart_item_price( $item );
58
-                        do_action( 'wpinv_checkout_cart_item_price_after', $item, $key );
57
+                        echo wpinv_cart_item_price($item);
58
+                        do_action('wpinv_checkout_cart_item_price_after', $item, $key);
59 59
                         ?>
60 60
                     </td>
61
-                    <?php if ( $quantities_enabled ) { ?>
61
+                    <?php if ($quantities_enabled) { ?>
62 62
                     <td class="wpinv_cart_item_qty text-right">
63 63
                         <?php
64
-                        echo wpinv_get_cart_item_quantity( $item );
65
-                        do_action( 'wpinv_cart_item_quantitiy', $item, $key );
64
+                        echo wpinv_get_cart_item_quantity($item);
65
+                        do_action('wpinv_cart_item_quantitiy', $item, $key);
66 66
                         ?>
67 67
                     </td>
68 68
                     <?php } ?>
69
-                    <?php if ( $use_taxes ) { ?>
69
+                    <?php if ($use_taxes) { ?>
70 70
                     <td class="wpinv_cart_item_tax text-right">
71 71
                         <?php
72
-                        echo wpinv_cart_item_tax( $item );
72
+                        echo wpinv_cart_item_tax($item);
73 73
                         //echo wpinv_get_cart_item_tax( $wpi_item->ID, $subtotal = '', $options = array() );
74
-                        do_action( 'wpinv_cart_item_tax', $item, $key );
74
+                        do_action('wpinv_cart_item_tax', $item, $key);
75 75
                         ?>
76 76
                     </td>
77 77
                     <?php } ?>
78 78
                     <td class="wpinv_cart_item_subtotal text-right">
79 79
                         <?php
80
-                        echo wpinv_cart_item_subtotal( $item );
81
-                        do_action( 'wpinv_cart_item_subtotal', $item, $key );
80
+                        echo wpinv_cart_item_subtotal($item);
81
+                        do_action('wpinv_cart_item_subtotal', $item, $key);
82 82
                         ?>
83 83
                     </td>
84
-                    <?php do_action( 'wpinv_checkout_table_body_last', $item, $key ); ?>
84
+                    <?php do_action('wpinv_checkout_table_body_last', $item, $key); ?>
85 85
                 </tr>
86 86
             <?php } ?>
87 87
         <?php } ?>
88
-        <?php do_action( 'wpinv_cart_items_middle' ); ?>
89
-        <?php do_action( 'wpinv_cart_items_after' ); ?>
88
+        <?php do_action('wpinv_cart_items_middle'); ?>
89
+        <?php do_action('wpinv_cart_items_after'); ?>
90 90
     </tbody>
91 91
     <tfoot>
92 92
         <?php $cart_columns = wpinv_checkout_cart_columns(); ?>
93
-        <?php if ( has_action( 'wpinv_cart_footer_buttons' ) ) { ?>
93
+        <?php if (has_action('wpinv_cart_footer_buttons')) { ?>
94 94
             <tr class="wpinv_cart_footer_row">
95
-                <?php do_action( 'wpinv_checkout_table_buttons_first', $cart_items ); ?>
96
-                <td colspan="<?php echo ( $cart_columns ); ?>">
97
-                    <?php do_action( 'wpinv_cart_footer_buttons' ); ?>
95
+                <?php do_action('wpinv_checkout_table_buttons_first', $cart_items); ?>
96
+                <td colspan="<?php echo ($cart_columns); ?>">
97
+                    <?php do_action('wpinv_cart_footer_buttons'); ?>
98 98
                 </td>
99
-                <?php do_action( 'wpinv_checkout_table_buttons_first', $cart_items ); ?>
99
+                <?php do_action('wpinv_checkout_table_buttons_first', $cart_items); ?>
100 100
             </tr>
101 101
         <?php } ?>
102 102
 
103
-        <?php if ( $use_taxes && !wpinv_prices_include_tax() ) { ?>
104
-            <tr class="wpinv_cart_footer_row wpinv_cart_subtotal_row"<?php if ( !wpinv_is_cart_taxed() ) echo ' style="display:none;"'; ?>>
105
-                <?php do_action( 'wpinv_checkout_table_subtotal_first', $cart_items ); ?>
106
-                <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_subtotal_label text-right">
107
-                    <strong><?php _e( 'Sub-Total', 'invoicing' ); ?>:</strong>
103
+        <?php if ($use_taxes && !wpinv_prices_include_tax()) { ?>
104
+            <tr class="wpinv_cart_footer_row wpinv_cart_subtotal_row"<?php if (!wpinv_is_cart_taxed()) echo ' style="display:none;"'; ?>>
105
+                <?php do_action('wpinv_checkout_table_subtotal_first', $cart_items); ?>
106
+                <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_subtotal_label text-right">
107
+                    <strong><?php _e('Sub-Total', 'invoicing'); ?>:</strong>
108 108
                 </td>
109 109
                 <td class="wpinv_cart_subtotal text-right">
110
-                    <span class="wpinv_cart_subtotal_amount bold"><?php echo wpinv_cart_subtotal( $cart_items ); ?></span>
110
+                    <span class="wpinv_cart_subtotal_amount bold"><?php echo wpinv_cart_subtotal($cart_items); ?></span>
111 111
                 </td>
112
-                <?php do_action( 'wpinv_checkout_table_subtotal_last', $cart_items ); ?>
112
+                <?php do_action('wpinv_checkout_table_subtotal_last', $cart_items); ?>
113 113
             </tr>
114 114
         <?php } ?>
115 115
         
116
-        <?php $wpi_cart_columns = $cart_columns - 1; wpinv_cart_discounts_html( $cart_items ); ?>
116
+        <?php $wpi_cart_columns = $cart_columns - 1; wpinv_cart_discounts_html($cart_items); ?>
117 117
 
118
-        <?php if ( $use_taxes ) { ?>
119
-            <tr class="wpinv_cart_footer_row wpinv_cart_tax_row"<?php if( !wpinv_is_cart_taxed() ) echo ' style="display:none;"'; ?>>
120
-                <?php do_action( 'wpinv_checkout_table_tax_first' ); ?>
121
-                <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_tax_label text-right">
118
+        <?php if ($use_taxes) { ?>
119
+            <tr class="wpinv_cart_footer_row wpinv_cart_tax_row"<?php if (!wpinv_is_cart_taxed()) echo ' style="display:none;"'; ?>>
120
+                <?php do_action('wpinv_checkout_table_tax_first'); ?>
121
+                <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_tax_label text-right">
122 122
                     <strong><?php echo $tax_label; ?>:</strong>
123 123
                 </td>
124 124
                 <td class="wpinv_cart_tax text-right">
125
-                    <span class="wpinv_cart_tax_amount" data-tax="<?php echo wpinv_get_cart_tax( $cart_items ); ?>"><?php echo esc_html( wpinv_cart_tax( $cart_items ) ); ?></span>
125
+                    <span class="wpinv_cart_tax_amount" data-tax="<?php echo wpinv_get_cart_tax($cart_items); ?>"><?php echo esc_html(wpinv_cart_tax($cart_items)); ?></span>
126 126
                 </td>
127
-                <?php do_action( 'wpinv_checkout_table_tax_last' ); ?>
127
+                <?php do_action('wpinv_checkout_table_tax_last'); ?>
128 128
             </tr>
129 129
         <?php } ?>
130 130
 
131 131
         <tr class="wpinv_cart_footer_row wpinv_cart_total_row">
132
-            <?php do_action( 'wpinv_checkout_table_footer_first' ); ?>
133
-            <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_total_label text-right">
134
-                <?php echo apply_filters( 'wpinv_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?>
132
+            <?php do_action('wpinv_checkout_table_footer_first'); ?>
133
+            <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_total_label text-right">
134
+                <?php echo apply_filters('wpinv_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?>
135 135
             </td>
136 136
             <td class="wpinv_cart_total text-right">
137
-                <span class="wpinv_cart_amount bold" data-subtotal="<?php echo wpinv_get_cart_total( $cart_items ); ?>" data-total="<?php echo wpinv_get_cart_total( NULL, NULL, $invoice ); ?>"><?php wpinv_cart_total( $cart_items, true, $invoice ); ?></span>
137
+                <span class="wpinv_cart_amount bold" data-subtotal="<?php echo wpinv_get_cart_total($cart_items); ?>" data-total="<?php echo wpinv_get_cart_total(NULL, NULL, $invoice); ?>"><?php wpinv_cart_total($cart_items, true, $invoice); ?></span>
138 138
             </td>
139
-            <?php do_action( 'wpinv_checkout_table_footer_last' ); ?>
139
+            <?php do_action('wpinv_checkout_table_footer_last'); ?>
140 140
         </tr>
141 141
     </tfoot>
142 142
 </table>
Please login to merge, or discard this patch.