Passed
Pull Request — master (#57)
by Kiran
04:16
created
includes/gateways/authorizenet/anet_php_sdk/lib/AuthorizeNetDPM.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
                 else
58 58
                 {
59 59
                     // Redirect to error page.
60
-                    $redirect_url = $url . '?response_code='.$response->response_code . '&response_reason_text=' . $response->response_reason_text;
60
+                    $redirect_url = $url . '?response_code=' . $response->response_code . '&response_reason_text=' . $response->response_reason_text;
61 61
                 }
62 62
                 // Send the Javascript back to AuthorizeNet, which will redirect user back to your site.
63 63
                 echo AuthorizeNetDPM::getRelayResponseSnippet($redirect_url);
@@ -179,54 +179,54 @@  discard block
 block discarded – undo
179 179
             -moz-box-shadow: inset 3px -3px 3px rgba(0,0,0,.5), inset 0 3px 3px rgba(255,255,255,.5), inset -3px 0 3px rgba(255,255,255,.75);
180 180
             box-shadow: inset 3px -3px 3px rgba(0,0,0,.5), inset 0 3px 3px rgba(255,255,255,.5), inset -3px 0 3px rgba(255,255,255,.75); }
181 181
         </style>
182
-        <form method="post" action="'.$post_url.'">
183
-                '.$hidden_fields.'
182
+        <form method="post" action="'.$post_url . '">
183
+                '.$hidden_fields . '
184 184
             <fieldset>
185 185
                 <div>
186 186
                     <label>Credit Card Number</label>
187
-                    <input type="text" class="text" size="15" name="x_card_num" value="'.($prefill ? '6011000000000012' : '').'"></input>
187
+                    <input type="text" class="text" size="15" name="x_card_num" value="'.($prefill ? '6011000000000012' : '') . '"></input>
188 188
                 </div>
189 189
                 <div>
190 190
                     <label>Exp.</label>
191
-                    <input type="text" class="text" size="4" name="x_exp_date" value="'.($prefill ? '04/17' : '').'"></input>
191
+                    <input type="text" class="text" size="4" name="x_exp_date" value="'.($prefill ? '04/17' : '') . '"></input>
192 192
                 </div>
193 193
                 <div>
194 194
                     <label>CCV</label>
195
-                    <input type="text" class="text" size="4" name="x_card_code" value="'.($prefill ? '782' : '').'"></input>
195
+                    <input type="text" class="text" size="4" name="x_card_code" value="'.($prefill ? '782' : '') . '"></input>
196 196
                 </div>
197 197
             </fieldset>
198 198
             <fieldset>
199 199
                 <div>
200 200
                     <label>First Name</label>
201
-                    <input type="text" class="text" size="15" name="x_first_name" value="'.($prefill ? 'John' : '').'"></input>
201
+                    <input type="text" class="text" size="15" name="x_first_name" value="'.($prefill ? 'John' : '') . '"></input>
202 202
                 </div>
203 203
                 <div>
204 204
                     <label>Last Name</label>
205
-                    <input type="text" class="text" size="14" name="x_last_name" value="'.($prefill ? 'Doe' : '').'"></input>
205
+                    <input type="text" class="text" size="14" name="x_last_name" value="'.($prefill ? 'Doe' : '') . '"></input>
206 206
                 </div>
207 207
             </fieldset>
208 208
             <fieldset>
209 209
                 <div>
210 210
                     <label>Address</label>
211
-                    <input type="text" class="text" size="26" name="x_address" value="'.($prefill ? '123 Main Street' : '').'"></input>
211
+                    <input type="text" class="text" size="26" name="x_address" value="'.($prefill ? '123 Main Street' : '') . '"></input>
212 212
                 </div>
213 213
                 <div>
214 214
                     <label>City</label>
215
-                    <input type="text" class="text" size="15" name="x_city" value="'.($prefill ? 'Boston' : '').'"></input>
215
+                    <input type="text" class="text" size="15" name="x_city" value="'.($prefill ? 'Boston' : '') . '"></input>
216 216
                 </div>
217 217
             </fieldset>
218 218
             <fieldset>
219 219
                 <div>
220 220
                     <label>State</label>
221
-                    <input type="text" class="text" size="4" name="x_state" value="'.($prefill ? 'MA' : '').'"></input>
221
+                    <input type="text" class="text" size="4" name="x_state" value="'.($prefill ? 'MA' : '') . '"></input>
222 222
                 </div>
223 223
                 <div>
224 224
                     <label>Zip Code</label>
225
-                    <input type="text" class="text" size="9" name="x_zip" value="'.($prefill ? '02142' : '').'"></input>
225
+                    <input type="text" class="text" size="9" name="x_zip" value="'.($prefill ? '02142' : '') . '"></input>
226 226
                 </div>
227 227
                 <div>
228 228
                     <label>Country</label>
229
-                    <input type="text" class="text" size="22" name="x_country" value="'.($prefill ? 'US' : '').'"></input>
229
+                    <input type="text" class="text" size="22" name="x_country" value="'.($prefill ? 'US' : '') . '"></input>
230 230
                 </div>
231 231
             </fieldset>
232 232
             <input type="submit" value="BUY" class="submit buy">
Please login to merge, or discard this patch.
includes/gateways/manual.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  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
-add_action( 'wpinv_manual_cc_form', '__return_false' );
5
+add_action('wpinv_manual_cc_form', '__return_false');
6 6
 
7
-function wpinv_process_manual_payment( $purchase_data ) {
8
-    if( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'wpi-gateway' ) ) {
9
-        wp_die( __( 'Nonce verification has failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
7
+function wpinv_process_manual_payment($purchase_data) {
8
+    if (!wp_verify_nonce($purchase_data['gateway_nonce'], 'wpi-gateway')) {
9
+        wp_die(__('Nonce verification has failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
10 10
     }
11 11
 
12 12
     /*
@@ -41,20 +41,20 @@  discard block
 block discarded – undo
41 41
     );
42 42
 
43 43
     // Record the pending payment
44
-    $invoice = wpinv_get_invoice( $purchase_data['invoice_id'] );
44
+    $invoice = wpinv_get_invoice($purchase_data['invoice_id']);
45 45
     
46
-    if ( !empty( $invoice ) ) {        
47
-        wpinv_set_payment_transaction_id( $invoice->ID, $invoice->generate_key() );
48
-        wpinv_update_payment_status( $invoice, 'publish' );
46
+    if (!empty($invoice)) {        
47
+        wpinv_set_payment_transaction_id($invoice->ID, $invoice->generate_key());
48
+        wpinv_update_payment_status($invoice, 'publish');
49 49
         
50 50
         // Empty the shopping cart
51 51
         wpinv_empty_cart();
52 52
         
53
-        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
53
+        wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
54 54
     } else {
55
-        wpinv_record_gateway_error( __( 'Payment Error', 'invoicing' ), sprintf( __( 'Payment creation failed while processing a manual (free or test) purchase. Payment data: %s', 'invoicing' ), json_encode( $payment_data ) ), $invoice );
55
+        wpinv_record_gateway_error(__('Payment Error', 'invoicing'), sprintf(__('Payment creation failed while processing a manual (free or test) purchase. Payment data: %s', 'invoicing'), json_encode($payment_data)), $invoice);
56 56
         // If errors are present, send the user back to the purchase page so they can be corrected
57
-        wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] );
57
+        wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']);
58 58
     }
59 59
 }
60
-add_action( 'wpinv_gateway_manual', 'wpinv_process_manual_payment' );
61 60
\ No newline at end of file
61
+add_action('wpinv_gateway_manual', 'wpinv_process_manual_payment');
62 62
\ No newline at end of file
Please login to merge, or discard this patch.
includes/gateways/bank_transfer.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  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
-add_action( 'wpinv_bank_transfer_cc_form', '__return_false' );
5
+add_action('wpinv_bank_transfer_cc_form', '__return_false');
6 6
 
7
-function wpinv_process_bank_transfer_payment( $purchase_data ) {
8
-    if( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'wpi-gateway' ) ) {
9
-        wp_die( __( 'Nonce verification has failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
7
+function wpinv_process_bank_transfer_payment($purchase_data) {
8
+    if (!wp_verify_nonce($purchase_data['gateway_nonce'], 'wpi-gateway')) {
9
+        wp_die(__('Nonce verification has failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
10 10
     }
11 11
 
12 12
     // Collect payment data
@@ -24,37 +24,37 @@  discard block
 block discarded – undo
24 24
     );
25 25
 
26 26
     // Record the pending payment
27
-    $invoice = wpinv_get_invoice( $purchase_data['invoice_id'] );
27
+    $invoice = wpinv_get_invoice($purchase_data['invoice_id']);
28 28
     
29
-    if ( !empty( $invoice ) ) {
30
-        wpinv_set_payment_transaction_id( $invoice->ID, $invoice->generate_key() );
31
-        wpinv_update_payment_status( $invoice, 'pending' );
29
+    if (!empty($invoice)) {
30
+        wpinv_set_payment_transaction_id($invoice->ID, $invoice->generate_key());
31
+        wpinv_update_payment_status($invoice, 'pending');
32 32
         
33 33
         // Empty the shopping cart
34 34
         wpinv_empty_cart();
35 35
         
36
-        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
36
+        wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
37 37
     } else {
38
-        wpinv_record_gateway_error( __( 'Payment Error', 'invoicing' ), sprintf( __( 'Payment creation failed while processing a bank transfer payment. Payment data: %s', 'invoicing' ), json_encode( $payment_data ) ), $invoice );
38
+        wpinv_record_gateway_error(__('Payment Error', 'invoicing'), sprintf(__('Payment creation failed while processing a bank transfer payment. Payment data: %s', 'invoicing'), json_encode($payment_data)), $invoice);
39 39
         // If errors are present, send the user back to the purchase page so they can be corrected
40
-        wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] );
40
+        wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']);
41 41
     }
42 42
 }
43
-add_action( 'wpinv_gateway_bank_transfer', 'wpinv_process_bank_transfer_payment' );
43
+add_action('wpinv_gateway_bank_transfer', 'wpinv_process_bank_transfer_payment');
44 44
 
45
-function wpinv_show_bank_info( $invoice ) {
46
-    if ( !empty( $invoice ) && $invoice->gateway == 'bank_transfer' && $invoice->status == 'pending' ) {
47
-        $bank_info = wpinv_get_bank_info( true );
45
+function wpinv_show_bank_info($invoice) {
46
+    if (!empty($invoice) && $invoice->gateway == 'bank_transfer' && $invoice->status == 'pending') {
47
+        $bank_info = wpinv_get_bank_info(true);
48 48
         ?>
49 49
         <div class="wpinv-bank-details">
50
-            <?php if ( $instructions = wpinv_get_bank_instructions() ) { ?>
51
-            <div class="alert bg-info"><?php echo wpautop( wp_kses_post( $instructions ) ); ?></div>
50
+            <?php if ($instructions = wpinv_get_bank_instructions()) { ?>
51
+            <div class="alert bg-info"><?php echo wpautop(wp_kses_post($instructions)); ?></div>
52 52
             <?php } ?>
53
-            <?php if ( !empty( $bank_info ) ) { ?>
54
-            <h3 class="wpinv-bank-t"><?php echo apply_filters( 'wpinv_receipt_bank_details_title', __( 'Our Bank Details', 'invoicing' ) ); ?></h3>
53
+            <?php if (!empty($bank_info)) { ?>
54
+            <h3 class="wpinv-bank-t"><?php echo apply_filters('wpinv_receipt_bank_details_title', __('Our Bank Details', 'invoicing')); ?></h3>
55 55
             <table class="table table-bordered table-sm wpi-bank-details">
56
-                <?php foreach ( $bank_info as $key => $info ) { ?>
57
-                <tr class="wpi-<?php echo sanitize_html_class( $key );?>"><th class="text-left"><?php echo $info['label'] ;?></th><td><?php echo $info['value'] ;?></td></tr>
56
+                <?php foreach ($bank_info as $key => $info) { ?>
57
+                <tr class="wpi-<?php echo sanitize_html_class($key); ?>"><th class="text-left"><?php echo $info['label']; ?></th><td><?php echo $info['value']; ?></td></tr>
58 58
                 <?php } ?>
59 59
             </table>
60 60
             <?php } ?>
@@ -62,15 +62,15 @@  discard block
 block discarded – undo
62 62
         <?php
63 63
     }
64 64
 }
65
-add_action( 'wpinv_before_receipt_details', 'wpinv_show_bank_info', 10, 1 );
65
+add_action('wpinv_before_receipt_details', 'wpinv_show_bank_info', 10, 1);
66 66
 
67
-function wpinv_invoice_print_bank_info( $invoice ) {
68
-    if ( !empty( $invoice ) && $invoice->gateway == 'bank_transfer' && $invoice->status == 'pending' ) {
67
+function wpinv_invoice_print_bank_info($invoice) {
68
+    if (!empty($invoice) && $invoice->gateway == 'bank_transfer' && $invoice->status == 'pending') {
69 69
         ?>
70 70
         <div class="row wpinv-bank-info">
71
-            <?php echo wpinv_show_bank_info( $invoice ); ?>
71
+            <?php echo wpinv_show_bank_info($invoice); ?>
72 72
         </div>
73 73
         <?php
74 74
     }
75 75
 }
76
-add_action( 'wpinv_invoice_print_after_top_content', 'wpinv_invoice_print_bank_info', 10, 1 );
77 76
\ No newline at end of file
77
+add_action('wpinv_invoice_print_after_top_content', 'wpinv_invoice_print_bank_info', 10, 1);
78 78
\ No newline at end of file
Please login to merge, or discard this patch.
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&aacute;', 'invoicing' ),
659
-        'AM' => __( 'Amazonas', 'invoicing' ),
660
-        'BA' => __( 'Bahia', 'invoicing' ),
661
-        'CE' => __( 'Cear&aacute;', 'invoicing' ),
662
-        'DF' => __( 'Distrito Federal', 'invoicing' ),
663
-        'ES' => __( 'Esp&iacute;rito Santo', 'invoicing' ),
664
-        'GO' => __( 'Goi&aacute;s', 'invoicing' ),
665
-        'MA' => __( 'Maranh&atilde;o', 'invoicing' ),
666
-        'MT' => __( 'Mato Grosso', 'invoicing' ),
667
-        'MS' => __( 'Mato Grosso do Sul', 'invoicing' ),
668
-        'MG' => __( 'Minas Gerais', 'invoicing' ),
669
-        'PA' => __( 'Par&aacute;', 'invoicing' ),
670
-        'PB' => __( 'Para&iacute;ba', 'invoicing' ),
671
-        'PR' => __( 'Paran&aacute;', 'invoicing' ),
672
-        'PE' => __( 'Pernambuco', 'invoicing' ),
673
-        'PI' => __( 'Piau&iacute;', 'invoicing' ),
674
-        'RJ' => __( 'Rio de Janeiro', 'invoicing' ),
675
-        'RN' => __( 'Rio Grande do Norte', 'invoicing' ),
676
-        'RS' => __( 'Rio Grande do Sul', 'invoicing' ),
677
-        'RO' => __( 'Rond&ocirc;nia', 'invoicing' ),
678
-        'RR' => __( 'Roraima', 'invoicing' ),
679
-        'SC' => __( 'Santa Catarina', 'invoicing' ),
680
-        'SP' => __( 'S&atilde;o Paulo', 'invoicing' ),
681
-        'SE' => __( 'Sergipe', 'invoicing' ),
682
-        'TO' => __( 'Tocantins', 'invoicing' )
656
+        'AC' => __('Acre', 'invoicing'),
657
+        'AL' => __('Alagoas', 'invoicing'),
658
+        'AP' => __('Amap&aacute;', 'invoicing'),
659
+        'AM' => __('Amazonas', 'invoicing'),
660
+        'BA' => __('Bahia', 'invoicing'),
661
+        'CE' => __('Cear&aacute;', 'invoicing'),
662
+        'DF' => __('Distrito Federal', 'invoicing'),
663
+        'ES' => __('Esp&iacute;rito Santo', 'invoicing'),
664
+        'GO' => __('Goi&aacute;s', 'invoicing'),
665
+        'MA' => __('Maranh&atilde;o', 'invoicing'),
666
+        'MT' => __('Mato Grosso', 'invoicing'),
667
+        'MS' => __('Mato Grosso do Sul', 'invoicing'),
668
+        'MG' => __('Minas Gerais', 'invoicing'),
669
+        'PA' => __('Par&aacute;', 'invoicing'),
670
+        'PB' => __('Para&iacute;ba', 'invoicing'),
671
+        'PR' => __('Paran&aacute;', 'invoicing'),
672
+        'PE' => __('Pernambuco', 'invoicing'),
673
+        'PI' => __('Piau&iacute;', 'invoicing'),
674
+        'RJ' => __('Rio de Janeiro', 'invoicing'),
675
+        'RN' => __('Rio Grande do Norte', 'invoicing'),
676
+        'RS' => __('Rio Grande do Sul', 'invoicing'),
677
+        'RO' => __('Rond&ocirc;nia', 'invoicing'),
678
+        'RR' => __('Roraima', 'invoicing'),
679
+        'SC' => __('Santa Catarina', 'invoicing'),
680
+        'SP' => __('S&atilde;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 / &#20113;&#21335;', 'invoicing' ),
817
-        'CN2'  => __( 'Beijing / &#21271;&#20140;', 'invoicing' ),
818
-        'CN3'  => __( 'Tianjin / &#22825;&#27941;', 'invoicing' ),
819
-        'CN4'  => __( 'Hebei / &#27827;&#21271;', 'invoicing' ),
820
-        'CN5'  => __( 'Shanxi / &#23665;&#35199;', 'invoicing' ),
821
-        'CN6'  => __( 'Inner Mongolia / &#20839;&#33945;&#21476;', 'invoicing' ),
822
-        'CN7'  => __( 'Liaoning / &#36797;&#23425;', 'invoicing' ),
823
-        'CN8'  => __( 'Jilin / &#21513;&#26519;', 'invoicing' ),
824
-        'CN9'  => __( 'Heilongjiang / &#40657;&#40857;&#27743;', 'invoicing' ),
825
-        'CN10' => __( 'Shanghai / &#19978;&#28023;', 'invoicing' ),
826
-        'CN11' => __( 'Jiangsu / &#27743;&#33487;', 'invoicing' ),
827
-        'CN12' => __( 'Zhejiang / &#27993;&#27743;', 'invoicing' ),
828
-        'CN13' => __( 'Anhui / &#23433;&#24509;', 'invoicing' ),
829
-        'CN14' => __( 'Fujian / &#31119;&#24314;', 'invoicing' ),
830
-        'CN15' => __( 'Jiangxi / &#27743;&#35199;', 'invoicing' ),
831
-        'CN16' => __( 'Shandong / &#23665;&#19996;', 'invoicing' ),
832
-        'CN17' => __( 'Henan / &#27827;&#21335;', 'invoicing' ),
833
-        'CN18' => __( 'Hubei / &#28246;&#21271;', 'invoicing' ),
834
-        'CN19' => __( 'Hunan / &#28246;&#21335;', 'invoicing' ),
835
-        'CN20' => __( 'Guangdong / &#24191;&#19996;', 'invoicing' ),
836
-        'CN21' => __( 'Guangxi Zhuang / &#24191;&#35199;&#22766;&#26063;', 'invoicing' ),
837
-        'CN22' => __( 'Hainan / &#28023;&#21335;', 'invoicing' ),
838
-        'CN23' => __( 'Chongqing / &#37325;&#24198;', 'invoicing' ),
839
-        'CN24' => __( 'Sichuan / &#22235;&#24029;', 'invoicing' ),
840
-        'CN25' => __( 'Guizhou / &#36149;&#24030;', 'invoicing' ),
841
-        'CN26' => __( 'Shaanxi / &#38485;&#35199;', 'invoicing' ),
842
-        'CN27' => __( 'Gansu / &#29976;&#32899;', 'invoicing' ),
843
-        'CN28' => __( 'Qinghai / &#38738;&#28023;', 'invoicing' ),
844
-        'CN29' => __( 'Ningxia Hui / &#23425;&#22799;', 'invoicing' ),
845
-        'CN30' => __( 'Macau / &#28595;&#38376;', 'invoicing' ),
846
-        'CN31' => __( 'Tibet / &#35199;&#34255;', 'invoicing' ),
847
-        'CN32' => __( 'Xinjiang / &#26032;&#30086;', 'invoicing' )
816
+        'CN1'  => __('Yunnan / &#20113;&#21335;', 'invoicing'),
817
+        'CN2'  => __('Beijing / &#21271;&#20140;', 'invoicing'),
818
+        'CN3'  => __('Tianjin / &#22825;&#27941;', 'invoicing'),
819
+        'CN4'  => __('Hebei / &#27827;&#21271;', 'invoicing'),
820
+        'CN5'  => __('Shanxi / &#23665;&#35199;', 'invoicing'),
821
+        'CN6'  => __('Inner Mongolia / &#20839;&#33945;&#21476;', 'invoicing'),
822
+        'CN7'  => __('Liaoning / &#36797;&#23425;', 'invoicing'),
823
+        'CN8'  => __('Jilin / &#21513;&#26519;', 'invoicing'),
824
+        'CN9'  => __('Heilongjiang / &#40657;&#40857;&#27743;', 'invoicing'),
825
+        'CN10' => __('Shanghai / &#19978;&#28023;', 'invoicing'),
826
+        'CN11' => __('Jiangsu / &#27743;&#33487;', 'invoicing'),
827
+        'CN12' => __('Zhejiang / &#27993;&#27743;', 'invoicing'),
828
+        'CN13' => __('Anhui / &#23433;&#24509;', 'invoicing'),
829
+        'CN14' => __('Fujian / &#31119;&#24314;', 'invoicing'),
830
+        'CN15' => __('Jiangxi / &#27743;&#35199;', 'invoicing'),
831
+        'CN16' => __('Shandong / &#23665;&#19996;', 'invoicing'),
832
+        'CN17' => __('Henan / &#27827;&#21335;', 'invoicing'),
833
+        'CN18' => __('Hubei / &#28246;&#21271;', 'invoicing'),
834
+        'CN19' => __('Hunan / &#28246;&#21335;', 'invoicing'),
835
+        'CN20' => __('Guangdong / &#24191;&#19996;', 'invoicing'),
836
+        'CN21' => __('Guangxi Zhuang / &#24191;&#35199;&#22766;&#26063;', 'invoicing'),
837
+        'CN22' => __('Hainan / &#28023;&#21335;', 'invoicing'),
838
+        'CN23' => __('Chongqing / &#37325;&#24198;', 'invoicing'),
839
+        'CN24' => __('Sichuan / &#22235;&#24029;', 'invoicing'),
840
+        'CN25' => __('Guizhou / &#36149;&#24030;', 'invoicing'),
841
+        'CN26' => __('Shaanxi / &#38485;&#35199;', 'invoicing'),
842
+        'CN27' => __('Gansu / &#29976;&#32899;', 'invoicing'),
843
+        'CN28' => __('Qinghai / &#38738;&#28023;', 'invoicing'),
844
+        'CN29' => __('Ningxia Hui / &#23425;&#22799;', 'invoicing'),
845
+        'CN30' => __('Macau / &#28595;&#38376;', 'invoicing'),
846
+        'CN31' => __('Tibet / &#35199;&#34255;', 'invoicing'),
847
+        'CN32' => __('Xinjiang / &#26032;&#30086;', '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&rsquo;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&rsquo;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&iacute;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&aacute;nuco', 'invoicing' ),
889
-        'ICA' => __( 'Ica', 'invoicing' ),
890
-        'JUN' => __( 'Jun&iacute;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&iacute;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&iacute;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&aacute;nuco', 'invoicing'),
889
+        'ICA' => __('Ica', 'invoicing'),
890
+        'JUN' => __('Jun&iacute;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&iacute;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&apos;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&apos;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&oacute;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&eacute;xico', 'invoicing' ),
1189
-        'MIC' => __( 'Michoac&aacute;n', 'invoicing' ),
1190
-        'MOR' => __( 'Morelos', 'invoicing' ),
1191
-        'NAY' => __( 'Nayarit', 'invoicing' ),
1192
-        'OAX' => __( 'Oaxaca', 'invoicing' ),
1193
-        'PUE' => __( 'Puebla', 'invoicing' ),
1194
-        'QUE' => __( 'Quer&eacute;taro', 'invoicing' ),
1195
-        'ROO' => __( 'Quintana Roo', 'invoicing' ),
1196
-        'SLP' => __( 'San Luis Potos&iacute;', '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&aacute;n', 'invoicing' ),
1204
-        'ZAC' => __( 'Zacatecas', 'invoicing' )
1173
+        'DIF' => __('Distrito Federal', 'invoicing'),
1174
+        'JAL' => __('Jalisco', 'invoicing'),
1175
+        'NLE' => __('Nuevo Le&oacute;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&eacute;xico', 'invoicing'),
1189
+        'MIC' => __('Michoac&aacute;n', 'invoicing'),
1190
+        'MOR' => __('Morelos', 'invoicing'),
1191
+        'NAY' => __('Nayarit', 'invoicing'),
1192
+        'OAX' => __('Oaxaca', 'invoicing'),
1193
+        'PUE' => __('Puebla', 'invoicing'),
1194
+        'QUE' => __('Quer&eacute;taro', 'invoicing'),
1195
+        'ROO' => __('Quintana Roo', 'invoicing'),
1196
+        'SLP' => __('San Luis Potos&iacute;', '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&aacute;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 (&#3629;&#3635;&#3609;&#3634;&#3592;&#3648;&#3592;&#3619;&#3636;&#3597;)', 'invoicing' ),
1311
-        'TH-15' => __( 'Ang Thong (&#3629;&#3656;&#3634;&#3591;&#3607;&#3629;&#3591;)', 'invoicing' ),
1312
-        'TH-14' => __( 'Ayutthaya (&#3614;&#3619;&#3632;&#3609;&#3588;&#3619;&#3624;&#3619;&#3637;&#3629;&#3618;&#3640;&#3608;&#3618;&#3634;)', 'invoicing' ),
1313
-        'TH-10' => __( 'Bangkok (&#3585;&#3619;&#3640;&#3591;&#3648;&#3607;&#3614;&#3617;&#3627;&#3634;&#3609;&#3588;&#3619;)', 'invoicing' ),
1314
-        'TH-38' => __( 'Bueng Kan (&#3610;&#3638;&#3591;&#3585;&#3634;&#3628;)', 'invoicing' ),
1315
-        'TH-31' => __( 'Buri Ram (&#3610;&#3640;&#3619;&#3637;&#3619;&#3633;&#3617;&#3618;&#3660;)', 'invoicing' ),
1316
-        'TH-24' => __( 'Chachoengsao (&#3593;&#3632;&#3648;&#3594;&#3636;&#3591;&#3648;&#3607;&#3619;&#3634;)', 'invoicing' ),
1317
-        'TH-18' => __( 'Chai Nat (&#3594;&#3633;&#3618;&#3609;&#3634;&#3607;)', 'invoicing' ),
1318
-        'TH-36' => __( 'Chaiyaphum (&#3594;&#3633;&#3618;&#3616;&#3641;&#3617;&#3636;)', 'invoicing' ),
1319
-        'TH-22' => __( 'Chanthaburi (&#3592;&#3633;&#3609;&#3607;&#3610;&#3640;&#3619;&#3637;)', 'invoicing' ),
1320
-        'TH-50' => __( 'Chiang Mai (&#3648;&#3594;&#3637;&#3618;&#3591;&#3651;&#3627;&#3617;&#3656;)', 'invoicing' ),
1321
-        'TH-57' => __( 'Chiang Rai (&#3648;&#3594;&#3637;&#3618;&#3591;&#3619;&#3634;&#3618;)', 'invoicing' ),
1322
-        'TH-20' => __( 'Chonburi (&#3594;&#3621;&#3610;&#3640;&#3619;&#3637;)', 'invoicing' ),
1323
-        'TH-86' => __( 'Chumphon (&#3594;&#3640;&#3617;&#3614;&#3619;)', 'invoicing' ),
1324
-        'TH-46' => __( 'Kalasin (&#3585;&#3634;&#3628;&#3626;&#3636;&#3609;&#3608;&#3640;&#3660;)', 'invoicing' ),
1325
-        'TH-62' => __( 'Kamphaeng Phet (&#3585;&#3635;&#3649;&#3614;&#3591;&#3648;&#3614;&#3594;&#3619;)', 'invoicing' ),
1326
-        'TH-71' => __( 'Kanchanaburi (&#3585;&#3634;&#3597;&#3592;&#3609;&#3610;&#3640;&#3619;&#3637;)', 'invoicing' ),
1327
-        'TH-40' => __( 'Khon Kaen (&#3586;&#3629;&#3609;&#3649;&#3585;&#3656;&#3609;)', 'invoicing' ),
1328
-        'TH-81' => __( 'Krabi (&#3585;&#3619;&#3632;&#3610;&#3637;&#3656;)', 'invoicing' ),
1329
-        'TH-52' => __( 'Lampang (&#3621;&#3635;&#3611;&#3634;&#3591;)', 'invoicing' ),
1330
-        'TH-51' => __( 'Lamphun (&#3621;&#3635;&#3614;&#3641;&#3609;)', 'invoicing' ),
1331
-        'TH-42' => __( 'Loei (&#3648;&#3621;&#3618;)', 'invoicing' ),
1332
-        'TH-16' => __( 'Lopburi (&#3621;&#3614;&#3610;&#3640;&#3619;&#3637;)', 'invoicing' ),
1333
-        'TH-58' => __( 'Mae Hong Son (&#3649;&#3617;&#3656;&#3630;&#3656;&#3629;&#3591;&#3626;&#3629;&#3609;)', 'invoicing' ),
1334
-        'TH-44' => __( 'Maha Sarakham (&#3617;&#3627;&#3634;&#3626;&#3634;&#3619;&#3588;&#3634;&#3617;)', 'invoicing' ),
1335
-        'TH-49' => __( 'Mukdahan (&#3617;&#3640;&#3585;&#3604;&#3634;&#3627;&#3634;&#3619;)', 'invoicing' ),
1336
-        'TH-26' => __( 'Nakhon Nayok (&#3609;&#3588;&#3619;&#3609;&#3634;&#3618;&#3585;)', 'invoicing' ),
1337
-        'TH-73' => __( 'Nakhon Pathom (&#3609;&#3588;&#3619;&#3611;&#3600;&#3617;)', 'invoicing' ),
1338
-        'TH-48' => __( 'Nakhon Phanom (&#3609;&#3588;&#3619;&#3614;&#3609;&#3617;)', 'invoicing' ),
1339
-        'TH-30' => __( 'Nakhon Ratchasima (&#3609;&#3588;&#3619;&#3619;&#3634;&#3594;&#3626;&#3637;&#3617;&#3634;)', 'invoicing' ),
1340
-        'TH-60' => __( 'Nakhon Sawan (&#3609;&#3588;&#3619;&#3626;&#3623;&#3619;&#3619;&#3588;&#3660;)', 'invoicing' ),
1341
-        'TH-80' => __( 'Nakhon Si Thammarat (&#3609;&#3588;&#3619;&#3624;&#3619;&#3637;&#3608;&#3619;&#3619;&#3617;&#3619;&#3634;&#3594;)', 'invoicing' ),
1342
-        'TH-55' => __( 'Nan (&#3609;&#3656;&#3634;&#3609;)', 'invoicing' ),
1343
-        'TH-96' => __( 'Narathiwat (&#3609;&#3619;&#3634;&#3608;&#3636;&#3623;&#3634;&#3626;)', 'invoicing' ),
1344
-        'TH-39' => __( 'Nong Bua Lam Phu (&#3627;&#3609;&#3629;&#3591;&#3610;&#3633;&#3623;&#3621;&#3635;&#3616;&#3641;)', 'invoicing' ),
1345
-        'TH-43' => __( 'Nong Khai (&#3627;&#3609;&#3629;&#3591;&#3588;&#3634;&#3618;)', 'invoicing' ),
1346
-        'TH-12' => __( 'Nonthaburi (&#3609;&#3609;&#3607;&#3610;&#3640;&#3619;&#3637;)', 'invoicing' ),
1347
-        'TH-13' => __( 'Pathum Thani (&#3611;&#3607;&#3640;&#3617;&#3608;&#3634;&#3609;&#3637;)', 'invoicing' ),
1348
-        'TH-94' => __( 'Pattani (&#3611;&#3633;&#3605;&#3605;&#3634;&#3609;&#3637;)', 'invoicing' ),
1349
-        'TH-82' => __( 'Phang Nga (&#3614;&#3633;&#3591;&#3591;&#3634;)', 'invoicing' ),
1350
-        'TH-93' => __( 'Phatthalung (&#3614;&#3633;&#3607;&#3621;&#3640;&#3591;)', 'invoicing' ),
1351
-        'TH-56' => __( 'Phayao (&#3614;&#3632;&#3648;&#3618;&#3634;)', 'invoicing' ),
1352
-        'TH-67' => __( 'Phetchabun (&#3648;&#3614;&#3594;&#3619;&#3610;&#3641;&#3619;&#3603;&#3660;)', 'invoicing' ),
1353
-        'TH-76' => __( 'Phetchaburi (&#3648;&#3614;&#3594;&#3619;&#3610;&#3640;&#3619;&#3637;)', 'invoicing' ),
1354
-        'TH-66' => __( 'Phichit (&#3614;&#3636;&#3592;&#3636;&#3605;&#3619;)', 'invoicing' ),
1355
-        'TH-65' => __( 'Phitsanulok (&#3614;&#3636;&#3625;&#3603;&#3640;&#3650;&#3621;&#3585;)', 'invoicing' ),
1356
-        'TH-54' => __( 'Phrae (&#3649;&#3614;&#3619;&#3656;)', 'invoicing' ),
1357
-        'TH-83' => __( 'Phuket (&#3616;&#3641;&#3648;&#3585;&#3655;&#3605;)', 'invoicing' ),
1358
-        'TH-25' => __( 'Prachin Buri (&#3611;&#3619;&#3634;&#3592;&#3637;&#3609;&#3610;&#3640;&#3619;&#3637;)', 'invoicing' ),
1359
-        'TH-77' => __( 'Prachuap Khiri Khan (&#3611;&#3619;&#3632;&#3592;&#3623;&#3610;&#3588;&#3637;&#3619;&#3637;&#3586;&#3633;&#3609;&#3608;&#3660;)', 'invoicing' ),
1360
-        'TH-85' => __( 'Ranong (&#3619;&#3632;&#3609;&#3629;&#3591;)', 'invoicing' ),
1361
-        'TH-70' => __( 'Ratchaburi (&#3619;&#3634;&#3594;&#3610;&#3640;&#3619;&#3637;)', 'invoicing' ),
1362
-        'TH-21' => __( 'Rayong (&#3619;&#3632;&#3618;&#3629;&#3591;)', 'invoicing' ),
1363
-        'TH-45' => __( 'Roi Et (&#3619;&#3657;&#3629;&#3618;&#3648;&#3629;&#3655;&#3604;)', 'invoicing' ),
1364
-        'TH-27' => __( 'Sa Kaeo (&#3626;&#3619;&#3632;&#3649;&#3585;&#3657;&#3623;)', 'invoicing' ),
1365
-        'TH-47' => __( 'Sakon Nakhon (&#3626;&#3585;&#3621;&#3609;&#3588;&#3619;)', 'invoicing' ),
1366
-        'TH-11' => __( 'Samut Prakan (&#3626;&#3617;&#3640;&#3607;&#3619;&#3611;&#3619;&#3634;&#3585;&#3634;&#3619;)', 'invoicing' ),
1367
-        'TH-74' => __( 'Samut Sakhon (&#3626;&#3617;&#3640;&#3607;&#3619;&#3626;&#3634;&#3588;&#3619;)', 'invoicing' ),
1368
-        'TH-75' => __( 'Samut Songkhram (&#3626;&#3617;&#3640;&#3607;&#3619;&#3626;&#3591;&#3588;&#3619;&#3634;&#3617;)', 'invoicing' ),
1369
-        'TH-19' => __( 'Saraburi (&#3626;&#3619;&#3632;&#3610;&#3640;&#3619;&#3637;)', 'invoicing' ),
1370
-        'TH-91' => __( 'Satun (&#3626;&#3605;&#3641;&#3621;)', 'invoicing' ),
1371
-        'TH-17' => __( 'Sing Buri (&#3626;&#3636;&#3591;&#3627;&#3660;&#3610;&#3640;&#3619;&#3637;)', 'invoicing' ),
1372
-        'TH-33' => __( 'Sisaket (&#3624;&#3619;&#3637;&#3626;&#3632;&#3648;&#3585;&#3625;)', 'invoicing' ),
1373
-        'TH-90' => __( 'Songkhla (&#3626;&#3591;&#3586;&#3621;&#3634;)', 'invoicing' ),
1374
-        'TH-64' => __( 'Sukhothai (&#3626;&#3640;&#3650;&#3586;&#3607;&#3633;&#3618;)', 'invoicing' ),
1375
-        'TH-72' => __( 'Suphan Buri (&#3626;&#3640;&#3614;&#3619;&#3619;&#3603;&#3610;&#3640;&#3619;&#3637;)', 'invoicing' ),
1376
-        'TH-84' => __( 'Surat Thani (&#3626;&#3640;&#3619;&#3634;&#3625;&#3598;&#3619;&#3660;&#3608;&#3634;&#3609;&#3637;)', 'invoicing' ),
1377
-        'TH-32' => __( 'Surin (&#3626;&#3640;&#3619;&#3636;&#3609;&#3607;&#3619;&#3660;)', 'invoicing' ),
1378
-        'TH-63' => __( 'Tak (&#3605;&#3634;&#3585;)', 'invoicing' ),
1379
-        'TH-92' => __( 'Trang (&#3605;&#3619;&#3633;&#3591;)', 'invoicing' ),
1380
-        'TH-23' => __( 'Trat (&#3605;&#3619;&#3634;&#3604;)', 'invoicing' ),
1381
-        'TH-34' => __( 'Ubon Ratchathani (&#3629;&#3640;&#3610;&#3621;&#3619;&#3634;&#3594;&#3608;&#3634;&#3609;&#3637;)', 'invoicing' ),
1382
-        'TH-41' => __( 'Udon Thani (&#3629;&#3640;&#3604;&#3619;&#3608;&#3634;&#3609;&#3637;)', 'invoicing' ),
1383
-        'TH-61' => __( 'Uthai Thani (&#3629;&#3640;&#3607;&#3633;&#3618;&#3608;&#3634;&#3609;&#3637;)', 'invoicing' ),
1384
-        'TH-53' => __( 'Uttaradit (&#3629;&#3640;&#3605;&#3619;&#3604;&#3636;&#3605;&#3606;&#3660;)', 'invoicing' ),
1385
-        'TH-95' => __( 'Yala (&#3618;&#3632;&#3621;&#3634;)', 'invoicing' ),
1386
-        'TH-35' => __( 'Yasothon (&#3618;&#3650;&#3626;&#3608;&#3619;)', 'invoicing' )
1310
+        'TH-37' => __('Amnat Charoen (&#3629;&#3635;&#3609;&#3634;&#3592;&#3648;&#3592;&#3619;&#3636;&#3597;)', 'invoicing'),
1311
+        'TH-15' => __('Ang Thong (&#3629;&#3656;&#3634;&#3591;&#3607;&#3629;&#3591;)', 'invoicing'),
1312
+        'TH-14' => __('Ayutthaya (&#3614;&#3619;&#3632;&#3609;&#3588;&#3619;&#3624;&#3619;&#3637;&#3629;&#3618;&#3640;&#3608;&#3618;&#3634;)', 'invoicing'),
1313
+        'TH-10' => __('Bangkok (&#3585;&#3619;&#3640;&#3591;&#3648;&#3607;&#3614;&#3617;&#3627;&#3634;&#3609;&#3588;&#3619;)', 'invoicing'),
1314
+        'TH-38' => __('Bueng Kan (&#3610;&#3638;&#3591;&#3585;&#3634;&#3628;)', 'invoicing'),
1315
+        'TH-31' => __('Buri Ram (&#3610;&#3640;&#3619;&#3637;&#3619;&#3633;&#3617;&#3618;&#3660;)', 'invoicing'),
1316
+        'TH-24' => __('Chachoengsao (&#3593;&#3632;&#3648;&#3594;&#3636;&#3591;&#3648;&#3607;&#3619;&#3634;)', 'invoicing'),
1317
+        'TH-18' => __('Chai Nat (&#3594;&#3633;&#3618;&#3609;&#3634;&#3607;)', 'invoicing'),
1318
+        'TH-36' => __('Chaiyaphum (&#3594;&#3633;&#3618;&#3616;&#3641;&#3617;&#3636;)', 'invoicing'),
1319
+        'TH-22' => __('Chanthaburi (&#3592;&#3633;&#3609;&#3607;&#3610;&#3640;&#3619;&#3637;)', 'invoicing'),
1320
+        'TH-50' => __('Chiang Mai (&#3648;&#3594;&#3637;&#3618;&#3591;&#3651;&#3627;&#3617;&#3656;)', 'invoicing'),
1321
+        'TH-57' => __('Chiang Rai (&#3648;&#3594;&#3637;&#3618;&#3591;&#3619;&#3634;&#3618;)', 'invoicing'),
1322
+        'TH-20' => __('Chonburi (&#3594;&#3621;&#3610;&#3640;&#3619;&#3637;)', 'invoicing'),
1323
+        'TH-86' => __('Chumphon (&#3594;&#3640;&#3617;&#3614;&#3619;)', 'invoicing'),
1324
+        'TH-46' => __('Kalasin (&#3585;&#3634;&#3628;&#3626;&#3636;&#3609;&#3608;&#3640;&#3660;)', 'invoicing'),
1325
+        'TH-62' => __('Kamphaeng Phet (&#3585;&#3635;&#3649;&#3614;&#3591;&#3648;&#3614;&#3594;&#3619;)', 'invoicing'),
1326
+        'TH-71' => __('Kanchanaburi (&#3585;&#3634;&#3597;&#3592;&#3609;&#3610;&#3640;&#3619;&#3637;)', 'invoicing'),
1327
+        'TH-40' => __('Khon Kaen (&#3586;&#3629;&#3609;&#3649;&#3585;&#3656;&#3609;)', 'invoicing'),
1328
+        'TH-81' => __('Krabi (&#3585;&#3619;&#3632;&#3610;&#3637;&#3656;)', 'invoicing'),
1329
+        'TH-52' => __('Lampang (&#3621;&#3635;&#3611;&#3634;&#3591;)', 'invoicing'),
1330
+        'TH-51' => __('Lamphun (&#3621;&#3635;&#3614;&#3641;&#3609;)', 'invoicing'),
1331
+        'TH-42' => __('Loei (&#3648;&#3621;&#3618;)', 'invoicing'),
1332
+        'TH-16' => __('Lopburi (&#3621;&#3614;&#3610;&#3640;&#3619;&#3637;)', 'invoicing'),
1333
+        'TH-58' => __('Mae Hong Son (&#3649;&#3617;&#3656;&#3630;&#3656;&#3629;&#3591;&#3626;&#3629;&#3609;)', 'invoicing'),
1334
+        'TH-44' => __('Maha Sarakham (&#3617;&#3627;&#3634;&#3626;&#3634;&#3619;&#3588;&#3634;&#3617;)', 'invoicing'),
1335
+        'TH-49' => __('Mukdahan (&#3617;&#3640;&#3585;&#3604;&#3634;&#3627;&#3634;&#3619;)', 'invoicing'),
1336
+        'TH-26' => __('Nakhon Nayok (&#3609;&#3588;&#3619;&#3609;&#3634;&#3618;&#3585;)', 'invoicing'),
1337
+        'TH-73' => __('Nakhon Pathom (&#3609;&#3588;&#3619;&#3611;&#3600;&#3617;)', 'invoicing'),
1338
+        'TH-48' => __('Nakhon Phanom (&#3609;&#3588;&#3619;&#3614;&#3609;&#3617;)', 'invoicing'),
1339
+        'TH-30' => __('Nakhon Ratchasima (&#3609;&#3588;&#3619;&#3619;&#3634;&#3594;&#3626;&#3637;&#3617;&#3634;)', 'invoicing'),
1340
+        'TH-60' => __('Nakhon Sawan (&#3609;&#3588;&#3619;&#3626;&#3623;&#3619;&#3619;&#3588;&#3660;)', 'invoicing'),
1341
+        'TH-80' => __('Nakhon Si Thammarat (&#3609;&#3588;&#3619;&#3624;&#3619;&#3637;&#3608;&#3619;&#3619;&#3617;&#3619;&#3634;&#3594;)', 'invoicing'),
1342
+        'TH-55' => __('Nan (&#3609;&#3656;&#3634;&#3609;)', 'invoicing'),
1343
+        'TH-96' => __('Narathiwat (&#3609;&#3619;&#3634;&#3608;&#3636;&#3623;&#3634;&#3626;)', 'invoicing'),
1344
+        'TH-39' => __('Nong Bua Lam Phu (&#3627;&#3609;&#3629;&#3591;&#3610;&#3633;&#3623;&#3621;&#3635;&#3616;&#3641;)', 'invoicing'),
1345
+        'TH-43' => __('Nong Khai (&#3627;&#3609;&#3629;&#3591;&#3588;&#3634;&#3618;)', 'invoicing'),
1346
+        'TH-12' => __('Nonthaburi (&#3609;&#3609;&#3607;&#3610;&#3640;&#3619;&#3637;)', 'invoicing'),
1347
+        'TH-13' => __('Pathum Thani (&#3611;&#3607;&#3640;&#3617;&#3608;&#3634;&#3609;&#3637;)', 'invoicing'),
1348
+        'TH-94' => __('Pattani (&#3611;&#3633;&#3605;&#3605;&#3634;&#3609;&#3637;)', 'invoicing'),
1349
+        'TH-82' => __('Phang Nga (&#3614;&#3633;&#3591;&#3591;&#3634;)', 'invoicing'),
1350
+        'TH-93' => __('Phatthalung (&#3614;&#3633;&#3607;&#3621;&#3640;&#3591;)', 'invoicing'),
1351
+        'TH-56' => __('Phayao (&#3614;&#3632;&#3648;&#3618;&#3634;)', 'invoicing'),
1352
+        'TH-67' => __('Phetchabun (&#3648;&#3614;&#3594;&#3619;&#3610;&#3641;&#3619;&#3603;&#3660;)', 'invoicing'),
1353
+        'TH-76' => __('Phetchaburi (&#3648;&#3614;&#3594;&#3619;&#3610;&#3640;&#3619;&#3637;)', 'invoicing'),
1354
+        'TH-66' => __('Phichit (&#3614;&#3636;&#3592;&#3636;&#3605;&#3619;)', 'invoicing'),
1355
+        'TH-65' => __('Phitsanulok (&#3614;&#3636;&#3625;&#3603;&#3640;&#3650;&#3621;&#3585;)', 'invoicing'),
1356
+        'TH-54' => __('Phrae (&#3649;&#3614;&#3619;&#3656;)', 'invoicing'),
1357
+        'TH-83' => __('Phuket (&#3616;&#3641;&#3648;&#3585;&#3655;&#3605;)', 'invoicing'),
1358
+        'TH-25' => __('Prachin Buri (&#3611;&#3619;&#3634;&#3592;&#3637;&#3609;&#3610;&#3640;&#3619;&#3637;)', 'invoicing'),
1359
+        'TH-77' => __('Prachuap Khiri Khan (&#3611;&#3619;&#3632;&#3592;&#3623;&#3610;&#3588;&#3637;&#3619;&#3637;&#3586;&#3633;&#3609;&#3608;&#3660;)', 'invoicing'),
1360
+        'TH-85' => __('Ranong (&#3619;&#3632;&#3609;&#3629;&#3591;)', 'invoicing'),
1361
+        'TH-70' => __('Ratchaburi (&#3619;&#3634;&#3594;&#3610;&#3640;&#3619;&#3637;)', 'invoicing'),
1362
+        'TH-21' => __('Rayong (&#3619;&#3632;&#3618;&#3629;&#3591;)', 'invoicing'),
1363
+        'TH-45' => __('Roi Et (&#3619;&#3657;&#3629;&#3618;&#3648;&#3629;&#3655;&#3604;)', 'invoicing'),
1364
+        'TH-27' => __('Sa Kaeo (&#3626;&#3619;&#3632;&#3649;&#3585;&#3657;&#3623;)', 'invoicing'),
1365
+        'TH-47' => __('Sakon Nakhon (&#3626;&#3585;&#3621;&#3609;&#3588;&#3619;)', 'invoicing'),
1366
+        'TH-11' => __('Samut Prakan (&#3626;&#3617;&#3640;&#3607;&#3619;&#3611;&#3619;&#3634;&#3585;&#3634;&#3619;)', 'invoicing'),
1367
+        'TH-74' => __('Samut Sakhon (&#3626;&#3617;&#3640;&#3607;&#3619;&#3626;&#3634;&#3588;&#3619;)', 'invoicing'),
1368
+        'TH-75' => __('Samut Songkhram (&#3626;&#3617;&#3640;&#3607;&#3619;&#3626;&#3591;&#3588;&#3619;&#3634;&#3617;)', 'invoicing'),
1369
+        'TH-19' => __('Saraburi (&#3626;&#3619;&#3632;&#3610;&#3640;&#3619;&#3637;)', 'invoicing'),
1370
+        'TH-91' => __('Satun (&#3626;&#3605;&#3641;&#3621;)', 'invoicing'),
1371
+        'TH-17' => __('Sing Buri (&#3626;&#3636;&#3591;&#3627;&#3660;&#3610;&#3640;&#3619;&#3637;)', 'invoicing'),
1372
+        'TH-33' => __('Sisaket (&#3624;&#3619;&#3637;&#3626;&#3632;&#3648;&#3585;&#3625;)', 'invoicing'),
1373
+        'TH-90' => __('Songkhla (&#3626;&#3591;&#3586;&#3621;&#3634;)', 'invoicing'),
1374
+        'TH-64' => __('Sukhothai (&#3626;&#3640;&#3650;&#3586;&#3607;&#3633;&#3618;)', 'invoicing'),
1375
+        'TH-72' => __('Suphan Buri (&#3626;&#3640;&#3614;&#3619;&#3619;&#3603;&#3610;&#3640;&#3619;&#3637;)', 'invoicing'),
1376
+        'TH-84' => __('Surat Thani (&#3626;&#3640;&#3619;&#3634;&#3625;&#3598;&#3619;&#3660;&#3608;&#3634;&#3609;&#3637;)', 'invoicing'),
1377
+        'TH-32' => __('Surin (&#3626;&#3640;&#3619;&#3636;&#3609;&#3607;&#3619;&#3660;)', 'invoicing'),
1378
+        'TH-63' => __('Tak (&#3605;&#3634;&#3585;)', 'invoicing'),
1379
+        'TH-92' => __('Trang (&#3605;&#3619;&#3633;&#3591;)', 'invoicing'),
1380
+        'TH-23' => __('Trat (&#3605;&#3619;&#3634;&#3604;)', 'invoicing'),
1381
+        'TH-34' => __('Ubon Ratchathani (&#3629;&#3640;&#3610;&#3621;&#3619;&#3634;&#3594;&#3608;&#3634;&#3609;&#3637;)', 'invoicing'),
1382
+        'TH-41' => __('Udon Thani (&#3629;&#3640;&#3604;&#3619;&#3608;&#3634;&#3609;&#3637;)', 'invoicing'),
1383
+        'TH-61' => __('Uthai Thani (&#3629;&#3640;&#3607;&#3633;&#3618;&#3608;&#3634;&#3609;&#3637;)', 'invoicing'),
1384
+        'TH-53' => __('Uttaradit (&#3629;&#3640;&#3605;&#3619;&#3604;&#3636;&#3605;&#3606;&#3660;)', 'invoicing'),
1385
+        'TH-95' => __('Yala (&#3618;&#3632;&#3621;&#3634;)', 'invoicing'),
1386
+        'TH-35' => __('Yasothon (&#3618;&#3650;&#3626;&#3608;&#3619;)', '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&#305;yaman', 'invoicing' ),
1396
-        'TR03' => __( 'Afyon', 'invoicing' ),
1397
-        'TR04' => __( 'A&#287;r&#305;', 'invoicing' ),
1398
-        'TR05' => __( 'Amasya', 'invoicing' ),
1399
-        'TR06' => __( 'Ankara', 'invoicing' ),
1400
-        'TR07' => __( 'Antalya', 'invoicing' ),
1401
-        'TR08' => __( 'Artvin', 'invoicing' ),
1402
-        'TR09' => __( 'Ayd&#305;n', 'invoicing' ),
1403
-        'TR10' => __( 'Bal&#305;kesir', 'invoicing' ),
1404
-        'TR11' => __( 'Bilecik', 'invoicing' ),
1405
-        'TR12' => __( 'Bing&#246;l', 'invoicing' ),
1406
-        'TR13' => __( 'Bitlis', 'invoicing' ),
1407
-        'TR14' => __( 'Bolu', 'invoicing' ),
1408
-        'TR15' => __( 'Burdur', 'invoicing' ),
1409
-        'TR16' => __( 'Bursa', 'invoicing' ),
1410
-        'TR17' => __( '&#199;anakkale', 'invoicing' ),
1411
-        'TR18' => __( '&#199;ank&#305;kesir', 'invoicing' ),
1412
-        'TR19' => __( '&#199;orum', 'invoicing' ),
1413
-        'TR20' => __( 'Denizli', 'invoicing' ),
1414
-        'TR21' => __( 'Diyarbak&#305;r', 'invoicing' ),
1415
-        'TR22' => __( 'Edirne', 'invoicing' ),
1416
-        'TR23' => __( 'Elaz&#305;&#287;', 'invoicing' ),
1417
-        'TR24' => __( 'Erzincan', 'invoicing' ),
1418
-        'TR25' => __( 'Erzurum', 'invoicing' ),
1419
-        'TR26' => __( 'Eski&#351;ehir', 'invoicing' ),
1420
-        'TR27' => __( 'Gaziantep', 'invoicing' ),
1421
-        'TR28' => __( 'Giresun', 'invoicing' ),
1422
-        'TR29' => __( 'G&#252;m&#252;&#351;hane', 'invoicing' ),
1423
-        'TR30' => __( 'Hakkari', 'invoicing' ),
1424
-        'TR31' => __( 'Hatay', 'invoicing' ),
1425
-        'TR32' => __( 'Isparta', 'invoicing' ),
1426
-        'TR33' => __( '&#304;&#231;el', 'invoicing' ),
1427
-        'TR34' => __( '&#304;stanbul', 'invoicing' ),
1428
-        'TR35' => __( '&#304;zmir', 'invoicing' ),
1429
-        'TR36' => __( 'Kars', 'invoicing' ),
1430
-        'TR37' => __( 'Kastamonu', 'invoicing' ),
1431
-        'TR38' => __( 'Kayseri', 'invoicing' ),
1432
-        'TR39' => __( 'K&#305;rklareli', 'invoicing' ),
1433
-        'TR40' => __( 'K&#305;r&#351;ehir', 'invoicing' ),
1434
-        'TR41' => __( 'Kocaeli', 'invoicing' ),
1435
-        'TR42' => __( 'Konya', 'invoicing' ),
1436
-        'TR43' => __( 'K&#252;tahya', 'invoicing' ),
1437
-        'TR44' => __( 'Malatya', 'invoicing' ),
1438
-        'TR45' => __( 'Manisa', 'invoicing' ),
1439
-        'TR46' => __( 'Kahramanmara&#351;', 'invoicing' ),
1440
-        'TR47' => __( 'Mardin', 'invoicing' ),
1441
-        'TR48' => __( 'Mu&#287;la', 'invoicing' ),
1442
-        'TR49' => __( 'Mu&#351;', 'invoicing' ),
1443
-        'TR50' => __( 'Nev&#351;ehir', 'invoicing' ),
1444
-        'TR51' => __( 'Ni&#287;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&#287;', 'invoicing' ),
1453
-        'TR60' => __( 'Tokat', 'invoicing' ),
1454
-        'TR61' => __( 'Trabzon', 'invoicing' ),
1455
-        'TR62' => __( 'Tunceli', 'invoicing' ),
1456
-        'TR63' => __( '&#350;anl&#305;urfa', 'invoicing' ),
1457
-        'TR64' => __( 'U&#351;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&#305;r&#305;kkale', 'invoicing' ),
1465
-        'TR72' => __( 'Batman', 'invoicing' ),
1466
-        'TR73' => __( '&#350;&#305;rnak', 'invoicing' ),
1467
-        'TR74' => __( 'Bart&#305;n', 'invoicing' ),
1468
-        'TR75' => __( 'Ardahan', 'invoicing' ),
1469
-        'TR76' => __( 'I&#287;d&#305;r', 'invoicing' ),
1470
-        'TR77' => __( 'Yalova', 'invoicing' ),
1471
-        'TR78' => __( 'Karab&#252;k', 'invoicing' ),
1472
-        'TR79' => __( 'Kilis', 'invoicing' ),
1473
-        'TR80' => __( 'Osmaniye', 'invoicing' ),
1474
-        'TR81' => __( 'D&#252;zce', 'invoicing' )
1394
+        'TR01' => __('Adana', 'invoicing'),
1395
+        'TR02' => __('Ad&#305;yaman', 'invoicing'),
1396
+        'TR03' => __('Afyon', 'invoicing'),
1397
+        'TR04' => __('A&#287;r&#305;', 'invoicing'),
1398
+        'TR05' => __('Amasya', 'invoicing'),
1399
+        'TR06' => __('Ankara', 'invoicing'),
1400
+        'TR07' => __('Antalya', 'invoicing'),
1401
+        'TR08' => __('Artvin', 'invoicing'),
1402
+        'TR09' => __('Ayd&#305;n', 'invoicing'),
1403
+        'TR10' => __('Bal&#305;kesir', 'invoicing'),
1404
+        'TR11' => __('Bilecik', 'invoicing'),
1405
+        'TR12' => __('Bing&#246;l', 'invoicing'),
1406
+        'TR13' => __('Bitlis', 'invoicing'),
1407
+        'TR14' => __('Bolu', 'invoicing'),
1408
+        'TR15' => __('Burdur', 'invoicing'),
1409
+        'TR16' => __('Bursa', 'invoicing'),
1410
+        'TR17' => __('&#199;anakkale', 'invoicing'),
1411
+        'TR18' => __('&#199;ank&#305;kesir', 'invoicing'),
1412
+        'TR19' => __('&#199;orum', 'invoicing'),
1413
+        'TR20' => __('Denizli', 'invoicing'),
1414
+        'TR21' => __('Diyarbak&#305;r', 'invoicing'),
1415
+        'TR22' => __('Edirne', 'invoicing'),
1416
+        'TR23' => __('Elaz&#305;&#287;', 'invoicing'),
1417
+        'TR24' => __('Erzincan', 'invoicing'),
1418
+        'TR25' => __('Erzurum', 'invoicing'),
1419
+        'TR26' => __('Eski&#351;ehir', 'invoicing'),
1420
+        'TR27' => __('Gaziantep', 'invoicing'),
1421
+        'TR28' => __('Giresun', 'invoicing'),
1422
+        'TR29' => __('G&#252;m&#252;&#351;hane', 'invoicing'),
1423
+        'TR30' => __('Hakkari', 'invoicing'),
1424
+        'TR31' => __('Hatay', 'invoicing'),
1425
+        'TR32' => __('Isparta', 'invoicing'),
1426
+        'TR33' => __('&#304;&#231;el', 'invoicing'),
1427
+        'TR34' => __('&#304;stanbul', 'invoicing'),
1428
+        'TR35' => __('&#304;zmir', 'invoicing'),
1429
+        'TR36' => __('Kars', 'invoicing'),
1430
+        'TR37' => __('Kastamonu', 'invoicing'),
1431
+        'TR38' => __('Kayseri', 'invoicing'),
1432
+        'TR39' => __('K&#305;rklareli', 'invoicing'),
1433
+        'TR40' => __('K&#305;r&#351;ehir', 'invoicing'),
1434
+        'TR41' => __('Kocaeli', 'invoicing'),
1435
+        'TR42' => __('Konya', 'invoicing'),
1436
+        'TR43' => __('K&#252;tahya', 'invoicing'),
1437
+        'TR44' => __('Malatya', 'invoicing'),
1438
+        'TR45' => __('Manisa', 'invoicing'),
1439
+        'TR46' => __('Kahramanmara&#351;', 'invoicing'),
1440
+        'TR47' => __('Mardin', 'invoicing'),
1441
+        'TR48' => __('Mu&#287;la', 'invoicing'),
1442
+        'TR49' => __('Mu&#351;', 'invoicing'),
1443
+        'TR50' => __('Nev&#351;ehir', 'invoicing'),
1444
+        'TR51' => __('Ni&#287;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&#287;', 'invoicing'),
1453
+        'TR60' => __('Tokat', 'invoicing'),
1454
+        'TR61' => __('Trabzon', 'invoicing'),
1455
+        'TR62' => __('Tunceli', 'invoicing'),
1456
+        'TR63' => __('&#350;anl&#305;urfa', 'invoicing'),
1457
+        'TR64' => __('U&#351;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&#305;r&#305;kkale', 'invoicing'),
1465
+        'TR72' => __('Batman', 'invoicing'),
1466
+        'TR73' => __('&#350;&#305;rnak', 'invoicing'),
1467
+        'TR74' => __('Bart&#305;n', 'invoicing'),
1468
+        'TR75' => __('Ardahan', 'invoicing'),
1469
+        'TR76' => __('I&#287;d&#305;r', 'invoicing'),
1470
+        'TR77' => __('Yalova', 'invoicing'),
1471
+        'TR78' => __('Karab&#252;k', 'invoicing'),
1472
+        'TR79' => __('Kilis', 'invoicing'),
1473
+        'TR80' => __('Osmaniye', 'invoicing'),
1474
+        'TR81' => __('D&#252;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&ntilde;a', 'invoicing' ),
1483
-        'VI' => __( 'Araba', 'invoicing' ),
1484
-        'AB' => __( 'Albacete', 'invoicing' ),
1485
-        'A'  => __( 'Alicante', 'invoicing' ),
1486
-        'AL' => __( 'Almer&iacute;a', 'invoicing' ),
1487
-        'O'  => __( 'Asturias', 'invoicing' ),
1488
-        'AV' => __( '&Aacute;vila', 'invoicing' ),
1489
-        'BA' => __( 'Badajoz', 'invoicing' ),
1490
-        'PM' => __( 'Baleares', 'invoicing' ),
1491
-        'B'  => __( 'Barcelona', 'invoicing' ),
1492
-        'BU' => __( 'Burgos', 'invoicing' ),
1493
-        'CC' => __( 'C&aacute;ceres', 'invoicing' ),
1494
-        'CA' => __( 'C&aacute;diz', 'invoicing' ),
1495
-        'S'  => __( 'Cantabria', 'invoicing' ),
1496
-        'CS' => __( 'Castell&oacute;n', 'invoicing' ),
1497
-        'CE' => __( 'Ceuta', 'invoicing' ),
1498
-        'CR' => __( 'Ciudad Real', 'invoicing' ),
1499
-        'CO' => __( 'C&oacute;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&eacute;n', 'invoicing' ),
1508
-        'LO' => __( 'La Rioja', 'invoicing' ),
1509
-        'GC' => __( 'Las Palmas', 'invoicing' ),
1510
-        'LE' => __( 'Le&oacute;n', 'invoicing' ),
1511
-        'L'  => __( 'Lleida', 'invoicing' ),
1512
-        'LU' => __( 'Lugo', 'invoicing' ),
1513
-        'M'  => __( 'Madrid', 'invoicing' ),
1514
-        'MA' => __( 'M&aacute;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&ntilde;a', 'invoicing'),
1483
+        'VI' => __('Araba', 'invoicing'),
1484
+        'AB' => __('Albacete', 'invoicing'),
1485
+        'A'  => __('Alicante', 'invoicing'),
1486
+        'AL' => __('Almer&iacute;a', 'invoicing'),
1487
+        'O'  => __('Asturias', 'invoicing'),
1488
+        'AV' => __('&Aacute;vila', 'invoicing'),
1489
+        'BA' => __('Badajoz', 'invoicing'),
1490
+        'PM' => __('Baleares', 'invoicing'),
1491
+        'B'  => __('Barcelona', 'invoicing'),
1492
+        'BU' => __('Burgos', 'invoicing'),
1493
+        'CC' => __('C&aacute;ceres', 'invoicing'),
1494
+        'CA' => __('C&aacute;diz', 'invoicing'),
1495
+        'S'  => __('Cantabria', 'invoicing'),
1496
+        'CS' => __('Castell&oacute;n', 'invoicing'),
1497
+        'CE' => __('Ceuta', 'invoicing'),
1498
+        'CR' => __('Ciudad Real', 'invoicing'),
1499
+        'CO' => __('C&oacute;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&eacute;n', 'invoicing'),
1508
+        'LO' => __('La Rioja', 'invoicing'),
1509
+        'GC' => __('Las Palmas', 'invoicing'),
1510
+        'LE' => __('Le&oacute;n', 'invoicing'),
1511
+        'L'  => __('Lleida', 'invoicing'),
1512
+        'LU' => __('Lugo', 'invoicing'),
1513
+        'M'  => __('Madrid', 'invoicing'),
1514
+        'MA' => __('M&aacute;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',
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.
invoicing.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -11,19 +11,19 @@  discard block
 block discarded – undo
11 11
 */
12 12
 
13 13
 // MUST have WordPress.
14
-if ( !defined( 'WPINC' ) ) {
15
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
14
+if (!defined('WPINC')) {
15
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
16 16
 }
17 17
 
18
-if ( !defined( 'WPINV_VERSION' ) ) {
19
-    define( 'WPINV_VERSION', '0.0.4' );
18
+if (!defined('WPINV_VERSION')) {
19
+    define('WPINV_VERSION', '0.0.4');
20 20
 }
21 21
 
22
-if ( !defined( 'WPINV_PLUGIN_FILE' ) ) {
23
-    define( 'WPINV_PLUGIN_FILE', __FILE__ );
22
+if (!defined('WPINV_PLUGIN_FILE')) {
23
+    define('WPINV_PLUGIN_FILE', __FILE__);
24 24
 }
25 25
 
26
-require plugin_dir_path( __FILE__ ) . 'includes/class-wpinv.php';
26
+require plugin_dir_path(__FILE__) . 'includes/class-wpinv.php';
27 27
 
28 28
 function wpinv_run() {
29 29
     global $invoicing;
@@ -40,16 +40,16 @@  discard block
 block discarded – undo
40 40
 /**
41 41
  * Show update plugin admin notification.
42 42
  */
43
-if(is_admin()){
43
+if (is_admin()) {
44 44
     if (!function_exists('ayecode_show_update_plugin_requirement')) {//only load the update file if needed
45 45
         function ayecode_show_update_plugin_requirement() {
46
-            if ( !defined( 'WP_EASY_UPDATES_ACTIVE' ) ) {
46
+            if (!defined('WP_EASY_UPDATES_ACTIVE')) {
47 47
                 ?>
48 48
                 <div class="notice notice-warning is-dismissible">
49 49
                     <p>
50 50
                         <strong>
51 51
                             <?php
52
-                            echo sprintf( __( 'The plugin %sWP Easy Updates%s is required to check for and update some installed plugins, please install it now.', 'geodirectory' ), '<a href="https://wpeasyupdates.com/" target="_blank" title="WP Easy Updates">', '</a>' );
52
+                            echo sprintf(__('The plugin %sWP Easy Updates%s is required to check for and update some installed plugins, please install it now.', 'geodirectory'), '<a href="https://wpeasyupdates.com/" target="_blank" title="WP Easy Updates">', '</a>');
53 53
                             ?>
54 54
                         </strong>
55 55
                     </p>
@@ -58,6 +58,6 @@  discard block
 block discarded – undo
58 58
             }
59 59
         }
60 60
 
61
-        add_action( 'admin_notices', 'ayecode_show_update_plugin_requirement' );
61
+        add_action('admin_notices', 'ayecode_show_update_plugin_requirement');
62 62
     }
63 63
 }
Please login to merge, or discard this patch.
includes/libraries/wpinv-euvat/class-wpinv-euvat.php 1 patch
Spacing   +709 added lines, -709 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,132 +17,132 @@  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
-        $suffix     = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
90
+        $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
91 91
         
92
-        wp_register_script( 'wpinv-vat-validation-script', WPINV_PLUGIN_URL . 'assets/js/jsvat' . $suffix . '.js', array( 'jquery' ),  WPINV_VERSION );
93
-        wp_register_script( 'wpinv-vat-script', WPINV_PLUGIN_URL . 'assets/js/euvat' . $suffix . '.js', array( 'jquery' ),  WPINV_VERSION );
92
+        wp_register_script('wpinv-vat-validation-script', WPINV_PLUGIN_URL . 'assets/js/jsvat' . $suffix . '.js', array('jquery'), WPINV_VERSION);
93
+        wp_register_script('wpinv-vat-script', WPINV_PLUGIN_URL . 'assets/js/euvat' . $suffix . '.js', array('jquery'), WPINV_VERSION);
94 94
         
95
-        $vat_name   = self::get_vat_name();
95
+        $vat_name = self::get_vat_name();
96 96
         
97 97
         $vars = array();
98 98
         $vars['UseTaxes'] = wpinv_use_taxes();
99 99
         $vars['EUStates'] = self::get_eu_states();
100
-        $vars['NoRateSet'] = __( 'You have not set a rate. Do you want to continue?', 'invoicing' );
101
-        $vars['EmptyCompany'] = __( 'Please enter your registered company name!', 'invoicing' );
102
-        $vars['EmptyVAT'] = wp_sprintf( __( 'Please enter your %s number!', 'invoicing' ), $vat_name );
103
-        $vars['TotalsRefreshed'] = wp_sprintf( __( 'The invoice totals will be refreshed to update the %s.', 'invoicing' ), $vat_name );
104
-        $vars['ErrValidateVAT'] = wp_sprintf( __( 'Fail to validate the %s number!', 'invoicing' ), $vat_name );
105
-        $vars['ErrResetVAT'] = wp_sprintf( __( 'Fail to reset the %s number!', 'invoicing' ), $vat_name );
106
-        $vars['ErrInvalidVat'] = wp_sprintf( __( 'The %s number supplied does not have a valid format!', 'invoicing' ), $vat_name );
107
-        $vars['ErrInvalidResponse'] = __( 'An invalid response has been received from the server!', 'invoicing' );
100
+        $vars['NoRateSet'] = __('You have not set a rate. Do you want to continue?', 'invoicing');
101
+        $vars['EmptyCompany'] = __('Please enter your registered company name!', 'invoicing');
102
+        $vars['EmptyVAT'] = wp_sprintf(__('Please enter your %s number!', 'invoicing'), $vat_name);
103
+        $vars['TotalsRefreshed'] = wp_sprintf(__('The invoice totals will be refreshed to update the %s.', 'invoicing'), $vat_name);
104
+        $vars['ErrValidateVAT'] = wp_sprintf(__('Fail to validate the %s number!', 'invoicing'), $vat_name);
105
+        $vars['ErrResetVAT'] = wp_sprintf(__('Fail to reset the %s number!', 'invoicing'), $vat_name);
106
+        $vars['ErrInvalidVat'] = wp_sprintf(__('The %s number supplied does not have a valid format!', 'invoicing'), $vat_name);
107
+        $vars['ErrInvalidResponse'] = __('An invalid response has been received from the server!', 'invoicing');
108 108
         $vars['ApplyVATRules'] = $vars['UseTaxes'] ? self::allow_vat_rules() : false;
109 109
         $vars['HideVatFields'] = $vars['ApplyVATRules'] ? self::hide_vat_fields() : true;
110
-        $vars['ErrResponse'] = __( 'The request response is invalid!', 'invoicing' );
111
-        $vars['ErrRateResponse'] = __( 'The get rate request response is invalid', 'invoicing' );
112
-        $vars['PageRefresh'] = __( 'The page will be refreshed in 10 seconds to show the new options.', 'invoicing' );
113
-        $vars['RequestResponseNotValidJSON'] = __( 'The get rate request response is not valid JSON', 'invoicing' );
114
-        $vars['GetRateRequestFailed'] = __( 'The get rate request failed: ', 'invoicing' );
115
-        $vars['NoRateInformationInResponse'] = __( 'The get rate request response does not contain any rate information', 'invoicing' );
116
-        $vars['RatesUpdated'] = __( 'The rates have been updated. Press the save button to record these new rates.', 'invoicing' );
117
-        $vars['IPAddressInformation'] = __( 'IP Address Information', 'invoicing' );
118
-        $vars['VatValidating'] = wp_sprintf( __( 'Validating %s number...', 'invoicing' ), $vat_name );
119
-        $vars['VatReseting'] = __( 'Reseting...', 'invoicing' );
120
-        $vars['VatValidated'] = wp_sprintf( __( '%s number validated', 'invoicing' ), $vat_name );
121
-        $vars['VatNotValidated'] = wp_sprintf( __( '%s number not validated', 'invoicing' ), $vat_name );
122
-        $vars['ConfirmDeleteClass'] = __( 'Are you sure you wish to delete this rates class?', 'invoicing' );
110
+        $vars['ErrResponse'] = __('The request response is invalid!', 'invoicing');
111
+        $vars['ErrRateResponse'] = __('The get rate request response is invalid', 'invoicing');
112
+        $vars['PageRefresh'] = __('The page will be refreshed in 10 seconds to show the new options.', 'invoicing');
113
+        $vars['RequestResponseNotValidJSON'] = __('The get rate request response is not valid JSON', 'invoicing');
114
+        $vars['GetRateRequestFailed'] = __('The get rate request failed: ', 'invoicing');
115
+        $vars['NoRateInformationInResponse'] = __('The get rate request response does not contain any rate information', 'invoicing');
116
+        $vars['RatesUpdated'] = __('The rates have been updated. Press the save button to record these new rates.', 'invoicing');
117
+        $vars['IPAddressInformation'] = __('IP Address Information', 'invoicing');
118
+        $vars['VatValidating'] = wp_sprintf(__('Validating %s number...', 'invoicing'), $vat_name);
119
+        $vars['VatReseting'] = __('Reseting...', 'invoicing');
120
+        $vars['VatValidated'] = wp_sprintf(__('%s number validated', 'invoicing'), $vat_name);
121
+        $vars['VatNotValidated'] = wp_sprintf(__('%s number not validated', 'invoicing'), $vat_name);
122
+        $vars['ConfirmDeleteClass'] = __('Are you sure you wish to delete this rates class?', 'invoicing');
123 123
         $vars['isFront'] = is_admin() ? false : true;
124
-        $vars['checkoutNonce'] = wp_create_nonce( 'wpinv_checkout_nonce' );
124
+        $vars['checkoutNonce'] = wp_create_nonce('wpinv_checkout_nonce');
125 125
         $vars['baseCountry'] = wpinv_get_default_country();
126
-        $vars['disableVATSameCountry'] = ( self::same_country_rule() == 'no' ? true : false );
127
-        $vars['disableVATSimpleCheck'] = wpinv_get_option( 'vat_offline_check' ) ? true : false;
126
+        $vars['disableVATSameCountry'] = (self::same_country_rule() == 'no' ? true : false);
127
+        $vars['disableVATSimpleCheck'] = wpinv_get_option('vat_offline_check') ? true : false;
128 128
         
129
-        wp_enqueue_script( 'wpinv-vat-validation-script' );
130
-        wp_enqueue_script( 'wpinv-vat-script' );
131
-        wp_localize_script( 'wpinv-vat-script', 'WPInv_VAT_Vars', $vars );
129
+        wp_enqueue_script('wpinv-vat-validation-script');
130
+        wp_enqueue_script('wpinv-vat-script');
131
+        wp_localize_script('wpinv-vat-script', 'WPInv_VAT_Vars', $vars);
132 132
     }
133 133
 
134 134
     public static function enqueue_admin_scripts() {
135
-        if( isset( $_GET['page'] ) && 'wpinv-settings' == $_GET['page'] ) {
135
+        if (isset($_GET['page']) && 'wpinv-settings' == $_GET['page']) {
136 136
             self::enqueue_vat_scripts();
137 137
         }
138 138
     }
139 139
     
140
-    public static function section_vat_settings( $sections ) {
141
-        if ( !empty( $sections ) ) {
142
-            $sections['vat'] = __( 'EU VAT Settings', 'invoicing' );
140
+    public static function section_vat_settings($sections) {
141
+        if (!empty($sections)) {
142
+            $sections['vat'] = __('EU VAT Settings', 'invoicing');
143 143
             
144
-            if ( self::allow_vat_classes() ) {
145
-                $sections['vat_rates'] = __( 'EU VAT Rates', 'invoicing' );
144
+            if (self::allow_vat_classes()) {
145
+                $sections['vat_rates'] = __('EU VAT Rates', 'invoicing');
146 146
             }
147 147
         }
148 148
         return $sections;
@@ -151,52 +151,52 @@  discard block
 block discarded – undo
151 151
     public static function vat_rates_settings() {
152 152
         $vat_classes = self::get_rate_classes();
153 153
         $vat_rates = array();
154
-        $vat_class = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' && isset( $vat_classes[$_REQUEST['wpi_sub']] )? sanitize_text_field( $_REQUEST['wpi_sub'] ) : '_new';
155
-        $current_url = remove_query_arg( 'wpi_sub' );
154
+        $vat_class = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' && isset($vat_classes[$_REQUEST['wpi_sub']]) ? sanitize_text_field($_REQUEST['wpi_sub']) : '_new';
155
+        $current_url = remove_query_arg('wpi_sub');
156 156
         
157 157
         $vat_rates['vat_rates_header'] = array(
158 158
             'id' => 'vat_rates_header',
159
-            'name' => '<h3>' . __( 'Manage VAT Rates', 'invoicing' ) . '</h3>',
159
+            'name' => '<h3>' . __('Manage VAT Rates', 'invoicing') . '</h3>',
160 160
             'desc' => '',
161 161
             'type' => 'header',
162 162
             'size' => 'regular'
163 163
         );
164 164
         $vat_rates['vat_rates_class'] = array(
165 165
             'id'          => 'vat_rates_class',
166
-            'name'        => __( 'Edit VAT Rates', 'invoicing' ),
167
-            'desc'        => __( 'The standard rate will apply where no explicit rate is provided.', 'invoicing' ),
166
+            'name'        => __('Edit VAT Rates', 'invoicing'),
167
+            'desc'        => __('The standard rate will apply where no explicit rate is provided.', 'invoicing'),
168 168
             'type'        => 'select',
169
-            'options'     => array_merge( $vat_classes, array( '_new' => __( 'Add New Rate Class', 'invoicing' ) ) ),
169
+            'options'     => array_merge($vat_classes, array('_new' => __('Add New Rate Class', 'invoicing'))),
170 170
             'chosen'      => true,
171
-            'placeholder' => __( 'Select a VAT Rate', 'invoicing' ),
171
+            'placeholder' => __('Select a VAT Rate', 'invoicing'),
172 172
             'selected'    => $vat_class,
173 173
             'onchange'    => 'document.location.href="' . $current_url . '&wpi_sub=" + this.value;',
174 174
         );
175 175
         
176
-        if ( $vat_class != '_standard' && $vat_class != '_new' ) {
176
+        if ($vat_class != '_standard' && $vat_class != '_new') {
177 177
             $vat_rates['vat_rate_delete'] = array(
178 178
                 'id'   => 'vat_rate_delete',
179 179
                 'type' => 'vat_rate_delete',
180 180
             );
181 181
         }
182 182
                     
183
-        if ( $vat_class == '_new' ) {
183
+        if ($vat_class == '_new') {
184 184
             $vat_rates['vat_rates_settings'] = array(
185 185
                 'id' => 'vat_rates_settings',
186
-                'name' => '<h3>' . __( 'Add New Rate Class', 'invoicing' ) . '</h3>',
186
+                'name' => '<h3>' . __('Add New Rate Class', 'invoicing') . '</h3>',
187 187
                 'type' => 'header',
188 188
             );
189 189
             $vat_rates['vat_rate_name'] = array(
190 190
                 'id'   => 'vat_rate_name',
191
-                'name' => __( 'Name', 'invoicing' ),
192
-                'desc' => __( 'A short name for the new VAT Rate class', 'invoicing' ),
191
+                'name' => __('Name', 'invoicing'),
192
+                'desc' => __('A short name for the new VAT Rate class', 'invoicing'),
193 193
                 'type' => 'text',
194 194
                 'size' => 'regular',
195 195
             );
196 196
             $vat_rates['vat_rate_desc'] = array(
197 197
                 'id'   => 'vat_rate_desc',
198
-                'name' => __( 'Description', 'invoicing' ),
199
-                'desc' => __( 'Manage VAT Rate class', 'invoicing' ),
198
+                'name' => __('Description', 'invoicing'),
199
+                'desc' => __('Manage VAT Rate class', 'invoicing'),
200 200
                 'type' => 'text',
201 201
                 'size' => 'regular',
202 202
             );
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
             $vat_rates['vat_rates'] = array(
209 209
                 'id'   => 'vat_rates',
210 210
                 'name' => '<h3>' . $vat_classes[$vat_class] . '</h3>',
211
-                'desc' => self::get_class_desc( $vat_class ),
211
+                'desc' => self::get_class_desc($vat_class),
212 212
                 'type' => 'vat_rates',
213 213
             );
214 214
         }
@@ -216,12 +216,12 @@  discard block
 block discarded – undo
216 216
         return $vat_rates;
217 217
     }
218 218
     
219
-    public static function vat_settings( $settings ) {
220
-        if ( !empty( $settings ) ) {    
219
+    public static function vat_settings($settings) {
220
+        if (!empty($settings)) {    
221 221
             $vat_settings = array();
222 222
             $vat_settings['vat_company_title'] = array(
223 223
                 'id' => 'vat_company_title',
224
-                'name' => '<h3>' . __( 'Your Company Details', 'invoicing' ) . '</h3>',
224
+                'name' => '<h3>' . __('Your Company Details', 'invoicing') . '</h3>',
225 225
                 'desc' => '',
226 226
                 'type' => 'header',
227 227
                 'size' => 'regular'
@@ -229,22 +229,22 @@  discard block
 block discarded – undo
229 229
             
230 230
             $vat_settings['vat_company_name'] = array(
231 231
                 'id' => 'vat_company_name',
232
-                'name' => __( 'Your Company Name', 'invoicing' ),
233
-                '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>' ),
232
+                'name' => __('Your Company Name', 'invoicing'),
233
+                '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>'),
234 234
                 'type' => 'text',
235 235
                 'size' => 'regular',
236 236
             );
237 237
             
238 238
             $vat_settings['vat_number'] = array(
239 239
                 'id'   => 'vat_number',
240
-                'name' => __( 'Your VAT Number', 'invoicing' ),
240
+                'name' => __('Your VAT Number', 'invoicing'),
241 241
                 'type' => 'vat_number',
242 242
                 'size' => 'regular',
243 243
             );
244 244
 
245 245
             $vat_settings['vat_settings_title'] = array(
246 246
                 'id' => 'vat_settings_title',
247
-                'name' => '<h3>' . __( 'Apply VAT Settings', 'invoicing' ) . '</h3>',
247
+                'name' => '<h3>' . __('Apply VAT Settings', 'invoicing') . '</h3>',
248 248
                 'desc' => '',
249 249
                 'type' => 'header',
250 250
                 'size' => 'regular'
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
 
253 253
             $vat_settings['apply_vat_rules'] = array(
254 254
                 'id' => 'apply_vat_rules',
255
-                'name' => __( 'Enable VAT rules', 'invoicing' ),
256
-                '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>',
255
+                'name' => __('Enable VAT rules', 'invoicing'),
256
+                '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>',
257 257
                 'type' => 'checkbox',
258 258
                 'std' => '1'
259 259
             );
@@ -269,8 +269,8 @@  discard block
 block discarded – undo
269 269
 
270 270
             $vat_settings['vat_prevent_b2c_purchase'] = array(
271 271
                 'id' => 'vat_prevent_b2c_purchase',
272
-                'name' => __( 'Prevent EU B2C sales', 'invoicing' ),
273
-                'desc' => __( 'Enable this option if you are not registered for VAT in the EU.', 'invoicing' ),
272
+                'name' => __('Prevent EU B2C sales', 'invoicing'),
273
+                'desc' => __('Enable this option if you are not registered for VAT in the EU.', 'invoicing'),
274 274
                 'type' => 'checkbox'
275 275
             );
276 276
 
@@ -278,21 +278,21 @@  discard block
 block discarded – undo
278 278
 
279 279
             $vat_settings['vat_same_country_rule'] = array(
280 280
                 'id'          => 'vat_same_country_rule',
281
-                'name'        => __( 'Same country rule', 'invoicing' ),
282
-                'desc'        => __( 'Select how you want handle VAT charge if sales are in the same country as the base country.', 'invoicing' ),
281
+                'name'        => __('Same country rule', 'invoicing'),
282
+                'desc'        => __('Select how you want handle VAT charge if sales are in the same country as the base country.', 'invoicing'),
283 283
                 'type'        => 'select',
284 284
                 'options'     => array(
285
-                    ''          => __( 'Normal', 'invoicing' ),
286
-                    'no'        => __( 'No VAT', 'invoicing' ),
287
-                    'always'    => __( 'Always apply VAT', 'invoicing' ),
285
+                    ''          => __('Normal', 'invoicing'),
286
+                    'no'        => __('No VAT', 'invoicing'),
287
+                    'always'    => __('Always apply VAT', 'invoicing'),
288 288
                 ),
289
-                'placeholder' => __( 'Select a option', 'invoicing' ),
289
+                'placeholder' => __('Select a option', 'invoicing'),
290 290
                 'std'         => ''
291 291
             );
292 292
 
293 293
             $vat_settings['vat_checkout_title'] = array(
294 294
                 'id' => 'vat_checkout_title',
295
-                'name' => '<h3>' . __( 'Checkout Fields', 'invoicing' ) . '</h3>',
295
+                'name' => '<h3>' . __('Checkout Fields', 'invoicing') . '</h3>',
296 296
                 'desc' => '',
297 297
                 'type' => 'header',
298 298
                 'size' => 'regular'
@@ -300,14 +300,14 @@  discard block
 block discarded – undo
300 300
 
301 301
             $vat_settings['vat_disable_fields'] = array(
302 302
                 'id' => 'vat_disable_fields',
303
-                'name' => __( 'Disable VAT fields', 'invoicing' ),
304
-                '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>',
303
+                'name' => __('Disable VAT fields', 'invoicing'),
304
+                '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>',
305 305
                 'type' => 'checkbox'
306 306
             );
307 307
 
308 308
             $vat_settings['vat_ip_lookup'] = array(
309 309
                 'id'   => 'vat_ip_lookup',
310
-                'name' => __( 'IP Country lookup', 'invoicing' ),
310
+                'name' => __('IP Country lookup', 'invoicing'),
311 311
                 'type' => 'vat_ip_lookup',
312 312
                 'size' => 'regular',
313 313
                 'std' => 'default'
@@ -315,21 +315,21 @@  discard block
 block discarded – undo
315 315
 
316 316
             $vat_settings['hide_ip_address'] = array(
317 317
                 'id' => 'hide_ip_address',
318
-                'name' => __( 'Hide IP info at checkout', 'invoicing' ),
319
-                'desc' => __( 'Hide the user IP info at checkout.', 'invoicing' ),
318
+                'name' => __('Hide IP info at checkout', 'invoicing'),
319
+                'desc' => __('Hide the user IP info at checkout.', 'invoicing'),
320 320
                 'type' => 'checkbox'
321 321
             );
322 322
 
323 323
             $vat_settings['vat_ip_country_default'] = array(
324 324
                 'id' => 'vat_ip_country_default',
325
-                'name' => __( 'Enable IP Country as Default', 'invoicing' ),
326
-                'desc' => __( 'Show the country of the users IP as the default country, otherwise the site default country will be used.', 'invoicing' ),
325
+                'name' => __('Enable IP Country as Default', 'invoicing'),
326
+                'desc' => __('Show the country of the users IP as the default country, otherwise the site default country will be used.', 'invoicing'),
327 327
                 'type' => 'checkbox'
328 328
             );
329 329
 
330 330
             $vat_settings['vies_validation_title'] = array(
331 331
                 'id' => 'vies_validation_title',
332
-                'name' => '<h3>' . __( 'VIES Validation', 'invoicing' ) . '</h3>',
332
+                'name' => '<h3>' . __('VIES Validation', 'invoicing') . '</h3>',
333 333
                 'desc' => '',
334 334
                 'type' => 'header',
335 335
                 'size' => 'regular'
@@ -337,37 +337,37 @@  discard block
 block discarded – undo
337 337
 
338 338
             $vat_settings['vat_vies_check'] = array(
339 339
                 'id' => 'vat_vies_check',
340
-                'name' => __( 'Disable VIES VAT ID check', 'invoicing' ),
341
-                '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>' ),
340
+                'name' => __('Disable VIES VAT ID check', 'invoicing'),
341
+                '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>'),
342 342
                 'type' => 'checkbox'
343 343
             );
344 344
 
345 345
             $vat_settings['vat_disable_company_name_check'] = array(
346 346
                 'id' => 'vat_disable_company_name_check',
347
-                'name' => __( 'Disable VIES name check', 'invoicing' ),
348
-                '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>' ),
347
+                'name' => __('Disable VIES name check', 'invoicing'),
348
+                '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>'),
349 349
                 'type' => 'checkbox'
350 350
             );
351 351
 
352 352
             $vat_settings['vat_offline_check'] = array(
353 353
                 'id' => 'vat_offline_check',
354
-                'name' => __( 'Disable basic checks', 'invoicing' ),
355
-                'desc' => __( 'This will disable basic JS correct format validation attempts, it is very rare this should need to be disabled.', 'invoicing' ),
354
+                'name' => __('Disable basic checks', 'invoicing'),
355
+                'desc' => __('This will disable basic JS correct format validation attempts, it is very rare this should need to be disabled.', 'invoicing'),
356 356
                 'type' => 'checkbox'
357 357
             );
358 358
             
359 359
 
360 360
             $settings['vat'] = $vat_settings;
361 361
             
362
-            if ( self::allow_vat_classes() ) {
362
+            if (self::allow_vat_classes()) {
363 363
                 $settings['vat_rates'] = self::vat_rates_settings();
364 364
             }
365 365
             
366 366
             $eu_fallback_rate = array(
367 367
                 'id'   => 'eu_fallback_rate',
368
-                'name' => '<h3>' . __( 'VAT rate for EU member states', 'invoicing' ) . '</h3>',
368
+                'name' => '<h3>' . __('VAT rate for EU member states', 'invoicing') . '</h3>',
369 369
                 'type' => 'eu_fallback_rate',
370
-                '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' ),
370
+                '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'),
371 371
                 'std'  => '20',
372 372
                 'size' => 'small'
373 373
             );
@@ -383,11 +383,11 @@  discard block
 block discarded – undo
383 383
         $database_url       = 'http' . (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] === 'on' ? 's' : '') . '://geolite.maxmind.com/download/geoip/database/';
384 384
         $destination_dir    = $upload_dir['basedir'] . '/invoicing';
385 385
         
386
-        if ( !is_dir( $destination_dir ) ) { 
387
-            mkdir( $destination_dir );
386
+        if (!is_dir($destination_dir)) { 
387
+            mkdir($destination_dir);
388 388
         }
389 389
         
390
-        $database_files     = array(
390
+        $database_files = array(
391 391
             'country'   => array(
392 392
                 'source'        => $database_url . 'GeoLite2-Country.mmdb.gz',
393 393
                 'destination'   => $destination_dir . '/GeoLite2-Country.mmdb',
@@ -398,57 +398,57 @@  discard block
 block discarded – undo
398 398
             )
399 399
         );
400 400
 
401
-        foreach( $database_files as $database => $files ) {
402
-            $result = self::geoip2_download_file( $files['source'], $files['destination'] );
401
+        foreach ($database_files as $database => $files) {
402
+            $result = self::geoip2_download_file($files['source'], $files['destination']);
403 403
             
404
-            if ( empty( $result['success'] ) ) {
404
+            if (empty($result['success'])) {
405 405
                 echo $result['message'];
406 406
                 exit;
407 407
             }
408 408
             
409
-            wpinv_update_option( 'wpinv_geoip2_date_updated', current_time( 'timestamp' ) );
410
-            echo sprintf(__( 'GeoIp2 %s database updated successfully.', 'invoicing' ), $database ) . ' ';
409
+            wpinv_update_option('wpinv_geoip2_date_updated', current_time('timestamp'));
410
+            echo sprintf(__('GeoIp2 %s database updated successfully.', 'invoicing'), $database) . ' ';
411 411
         }
412 412
         
413 413
         exit;
414 414
     }
415 415
     
416
-    public static function geoip2_download_file( $source_url, $destination_file ) {
416
+    public static function geoip2_download_file($source_url, $destination_file) {
417 417
         $success    = false;
418 418
         $message    = '';
419 419
         
420
-        if ( !function_exists( 'download_url' ) ) {
421
-            require_once( ABSPATH . 'wp-admin/includes/file.php' );
420
+        if (!function_exists('download_url')) {
421
+            require_once(ABSPATH . 'wp-admin/includes/file.php');
422 422
         }
423 423
 
424
-        $temp_file  = download_url( $source_url );
424
+        $temp_file = download_url($source_url);
425 425
         
426
-        if ( is_wp_error( $temp_file ) ) {
427
-            $message = sprintf( __( 'Error while downloading GeoIp2 database( %s ): %s', 'invoicing' ), $source_url, $temp_file->get_error_message() );
426
+        if (is_wp_error($temp_file)) {
427
+            $message = sprintf(__('Error while downloading GeoIp2 database( %s ): %s', 'invoicing'), $source_url, $temp_file->get_error_message());
428 428
         } else {
429
-            $handle = gzopen( $temp_file, 'rb' );
429
+            $handle = gzopen($temp_file, 'rb');
430 430
             
431
-            if ( $handle ) {
432
-                $fopen  = fopen( $destination_file, 'wb' );
433
-                if ( $fopen ) {
434
-                    while ( ( $data = gzread( $handle, 4096 ) ) != false ) {
435
-                        fwrite( $fopen, $data );
431
+            if ($handle) {
432
+                $fopen = fopen($destination_file, 'wb');
433
+                if ($fopen) {
434
+                    while (($data = gzread($handle, 4096)) != false) {
435
+                        fwrite($fopen, $data);
436 436
                     }
437 437
 
438
-                    gzclose( $handle );
439
-                    fclose( $fopen );
438
+                    gzclose($handle);
439
+                    fclose($fopen);
440 440
                         
441 441
                     $success = true;
442 442
                 } else {
443
-                    gzclose( $handle );
444
-                    $message = sprintf( __( 'Error could not open destination GeoIp2 database file for writing: %s', 'invoicing' ), $destination_file );
443
+                    gzclose($handle);
444
+                    $message = sprintf(__('Error could not open destination GeoIp2 database file for writing: %s', 'invoicing'), $destination_file);
445 445
                 }
446 446
             } else {
447
-                $message = sprintf( __( 'Error could not open GeoIp2 database file for reading: %s', 'invoicing' ), $temp_file );
447
+                $message = sprintf(__('Error could not open GeoIp2 database file for reading: %s', 'invoicing'), $temp_file);
448 448
             }
449 449
             
450
-            if ( file_exists( $temp_file ) ) {
451
-                unlink( $temp_file );
450
+            if (file_exists($temp_file)) {
451
+                unlink($temp_file);
452 452
             }
453 453
         }
454 454
         
@@ -460,11 +460,11 @@  discard block
 block discarded – undo
460 460
     }
461 461
     
462 462
     public static function load_geoip2() {
463
-        if ( defined( 'WPINV_GEOIP2_LODDED' ) ) {
463
+        if (defined('WPINV_GEOIP2_LODDED')) {
464 464
             return;
465 465
         }
466 466
         
467
-        if ( !class_exists( '\MaxMind\Db\Reader' ) ) {
467
+        if (!class_exists('\MaxMind\Db\Reader')) {
468 468
             $maxmind_db_files = array(
469 469
                 'Reader/Decoder.php',
470 470
                 'Reader/InvalidDatabaseException.php',
@@ -473,12 +473,12 @@  discard block
 block discarded – undo
473 473
                 'Reader.php',
474 474
             );
475 475
             
476
-            foreach ( $maxmind_db_files as $key => $file ) {
477
-                require_once( WPINV_PLUGIN_DIR . 'includes/libraries/MaxMind/Db/' . $file );
476
+            foreach ($maxmind_db_files as $key => $file) {
477
+                require_once(WPINV_PLUGIN_DIR . 'includes/libraries/MaxMind/Db/' . $file);
478 478
             }
479 479
         }
480 480
         
481
-        if ( !class_exists( '\GeoIp2\Database\Reader' ) ) {        
481
+        if (!class_exists('\GeoIp2\Database\Reader')) {        
482 482
             $geoip2_files = array(
483 483
                 'ProviderInterface.php',
484 484
                 'Compat/JsonSerializable.php',
@@ -512,23 +512,23 @@  discard block
 block discarded – undo
512 512
                 'WebService/Client.php',
513 513
             );
514 514
             
515
-            foreach ( $geoip2_files as $key => $file ) {
516
-                require_once( WPINV_PLUGIN_DIR . 'includes/libraries/GeoIp2/' . $file );
515
+            foreach ($geoip2_files as $key => $file) {
516
+                require_once(WPINV_PLUGIN_DIR . 'includes/libraries/GeoIp2/' . $file);
517 517
             }
518 518
         }
519 519
 
520
-        define( 'WPINV_GEOIP2_LODDED', true );
520
+        define('WPINV_GEOIP2_LODDED', true);
521 521
     }
522 522
 
523 523
     public static function geoip2_country_dbfile() {
524 524
         $upload_dir = wp_upload_dir();
525 525
 
526
-        if ( !isset( $upload_dir['basedir'] ) ) {
526
+        if (!isset($upload_dir['basedir'])) {
527 527
             return false;
528 528
         }
529 529
 
530 530
         $filename = $upload_dir['basedir'] . '/invoicing/GeoLite2-Country.mmdb';
531
-        if ( !file_exists( $filename ) ) {
531
+        if (!file_exists($filename)) {
532 532
             return false;
533 533
         }
534 534
         
@@ -538,12 +538,12 @@  discard block
 block discarded – undo
538 538
     public static function geoip2_city_dbfile() {
539 539
         $upload_dir = wp_upload_dir();
540 540
 
541
-        if ( !isset( $upload_dir['basedir'] ) ) {
541
+        if (!isset($upload_dir['basedir'])) {
542 542
             return false;
543 543
         }
544 544
 
545 545
         $filename = $upload_dir['basedir'] . '/invoicing/GeoLite2-City.mmdb';
546
-        if ( !file_exists( $filename ) ) {
546
+        if (!file_exists($filename)) {
547 547
             return false;
548 548
         }
549 549
         
@@ -554,10 +554,10 @@  discard block
 block discarded – undo
554 554
         try {
555 555
             self::load_geoip2();
556 556
 
557
-            if ( $filename = self::geoip2_country_dbfile() ) {
558
-                return new \GeoIp2\Database\Reader( $filename );
557
+            if ($filename = self::geoip2_country_dbfile()) {
558
+                return new \GeoIp2\Database\Reader($filename);
559 559
             }
560
-        } catch( Exception $e ) {
560
+        } catch (Exception $e) {
561 561
             return false;
562 562
         }
563 563
         
@@ -568,173 +568,173 @@  discard block
 block discarded – undo
568 568
         try {
569 569
             self::load_geoip2();
570 570
 
571
-            if ( $filename = self::geoip2_city_dbfile() ) {
572
-                return new \GeoIp2\Database\Reader( $filename );
571
+            if ($filename = self::geoip2_city_dbfile()) {
572
+                return new \GeoIp2\Database\Reader($filename);
573 573
             }
574
-        } catch( Exception $e ) {
574
+        } catch (Exception $e) {
575 575
             return false;
576 576
         }
577 577
         
578 578
         return false;
579 579
     }
580 580
 
581
-    public static function geoip2_country_record( $ip_address ) {
581
+    public static function geoip2_country_record($ip_address) {
582 582
         try {
583 583
             $reader = self::geoip2_country_reader();
584 584
 
585
-            if ( $reader ) {
586
-                $record = $reader->country( $ip_address );
585
+            if ($reader) {
586
+                $record = $reader->country($ip_address);
587 587
                 
588
-                if ( !empty( $record->country->isoCode ) ) {
588
+                if (!empty($record->country->isoCode)) {
589 589
                     return $record;
590 590
                 }
591 591
             }
592
-        } catch(\InvalidArgumentException $e) {
593
-            wpinv_error_log( $e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )' );
592
+        } catch (\InvalidArgumentException $e) {
593
+            wpinv_error_log($e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )');
594 594
             
595 595
             return false;
596
-        } catch(\GeoIp2\Exception\AddressNotFoundException $e) {
597
-            wpinv_error_log( $e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )' );
596
+        } catch (\GeoIp2\Exception\AddressNotFoundException $e) {
597
+            wpinv_error_log($e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )');
598 598
             
599 599
             return false;
600
-        } catch( Exception $e ) {
600
+        } catch (Exception $e) {
601 601
             return false;
602 602
         }
603 603
         
604 604
         return false;
605 605
     }
606 606
 
607
-    public static function geoip2_city_record( $ip_address ) {
607
+    public static function geoip2_city_record($ip_address) {
608 608
         try {
609 609
             $reader = self::geoip2_city_reader();
610 610
 
611
-            if ( $reader ) {
612
-                $record = $reader->city( $ip_address );
611
+            if ($reader) {
612
+                $record = $reader->city($ip_address);
613 613
                 
614
-                if ( !empty( $record->country->isoCode ) ) {
614
+                if (!empty($record->country->isoCode)) {
615 615
                     return $record;
616 616
                 }
617 617
             }
618
-        } catch(\InvalidArgumentException $e) {
619
-            wpinv_error_log( $e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )' );
618
+        } catch (\InvalidArgumentException $e) {
619
+            wpinv_error_log($e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )');
620 620
             
621 621
             return false;
622
-        } catch(\GeoIp2\Exception\AddressNotFoundException $e) {
623
-            wpinv_error_log( $e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )' );
622
+        } catch (\GeoIp2\Exception\AddressNotFoundException $e) {
623
+            wpinv_error_log($e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )');
624 624
             
625 625
             return false;
626
-        } catch( Exception $e ) {
626
+        } catch (Exception $e) {
627 627
             return false;
628 628
         }
629 629
         
630 630
         return false;
631 631
     }
632 632
 
633
-    public static function geoip2_country_code( $ip_address ) {
634
-        $record = self::geoip2_country_record( $ip_address );
635
-        return !empty( $record->country->isoCode ) ? $record->country->isoCode : wpinv_get_default_country();
633
+    public static function geoip2_country_code($ip_address) {
634
+        $record = self::geoip2_country_record($ip_address);
635
+        return !empty($record->country->isoCode) ? $record->country->isoCode : wpinv_get_default_country();
636 636
     }
637 637
 
638 638
     // Find country by IP address.
639
-    public static function get_country_by_ip( $ip = '' ) {
639
+    public static function get_country_by_ip($ip = '') {
640 640
         global $wpinv_ip_address_country;
641 641
         
642
-        if ( !empty( $wpinv_ip_address_country ) ) {
642
+        if (!empty($wpinv_ip_address_country)) {
643 643
             return $wpinv_ip_address_country;
644 644
         }
645 645
         
646
-        if ( empty( $ip ) ) {
646
+        if (empty($ip)) {
647 647
             $ip = wpinv_get_ip();
648 648
         }
649 649
 
650
-        $ip_country_service = wpinv_get_option( 'vat_ip_lookup' );
651
-        $is_default         = empty( $ip_country_service ) || $ip_country_service === 'default' ? true : false;
650
+        $ip_country_service = wpinv_get_option('vat_ip_lookup');
651
+        $is_default         = empty($ip_country_service) || $ip_country_service === 'default' ? true : false;
652 652
 
653
-        if ( !empty( $ip ) && $ip !== '127.0.0.1' ) { // For 127.0.0.1(localhost) use default country.
654
-            if ( function_exists( 'geoip_country_code_by_name') && ( $ip_country_service === 'geoip' || $is_default ) ) {
653
+        if (!empty($ip) && $ip !== '127.0.0.1') { // For 127.0.0.1(localhost) use default country.
654
+            if (function_exists('geoip_country_code_by_name') && ($ip_country_service === 'geoip' || $is_default)) {
655 655
                 try {
656
-                    $wpinv_ip_address_country = geoip_country_code_by_name( $ip );
657
-                } catch( Exception $e ) {
658
-                    wpinv_error_log( $e->getMessage(), 'GeoIP Lookup( ' . $ip . ' )' );
656
+                    $wpinv_ip_address_country = geoip_country_code_by_name($ip);
657
+                } catch (Exception $e) {
658
+                    wpinv_error_log($e->getMessage(), 'GeoIP Lookup( ' . $ip . ' )');
659 659
                 }
660
-            } else if ( self::geoip2_country_dbfile() && ( $ip_country_service === 'geoip2' || $is_default ) ) {
661
-                $wpinv_ip_address_country = self::geoip2_country_code( $ip );
662
-            } else if ( function_exists( 'simplexml_load_file' ) && ( $ip_country_service === 'geoplugin' || $is_default ) ) {
663
-                $load_xml = simplexml_load_file( 'http://www.geoplugin.net/xml.gp?ip=' . $ip );
660
+            } else if (self::geoip2_country_dbfile() && ($ip_country_service === 'geoip2' || $is_default)) {
661
+                $wpinv_ip_address_country = self::geoip2_country_code($ip);
662
+            } else if (function_exists('simplexml_load_file') && ($ip_country_service === 'geoplugin' || $is_default)) {
663
+                $load_xml = simplexml_load_file('http://www.geoplugin.net/xml.gp?ip=' . $ip);
664 664
                 
665
-                if ( !empty( $load_xml ) && !empty( $load_xml->geoplugin_countryCode ) ) {
665
+                if (!empty($load_xml) && !empty($load_xml->geoplugin_countryCode)) {
666 666
                     $wpinv_ip_address_country = (string)$load_xml->geoplugin_countryCode;
667 667
                 }
668 668
             }
669 669
         }
670 670
 
671
-        if ( empty( $wpinv_ip_address_country ) ) {
671
+        if (empty($wpinv_ip_address_country)) {
672 672
             $wpinv_ip_address_country = wpinv_get_default_country();
673 673
         }
674 674
 
675 675
         return $wpinv_ip_address_country;
676 676
     }
677 677
     
678
-    public static function sanitize_vat_settings( $input ) {
678
+    public static function sanitize_vat_settings($input) {
679 679
         global $wpinv_options;
680 680
         
681 681
         $valid      = false;
682 682
         $message    = '';
683 683
         
684
-        if ( !empty( $wpinv_options['vat_vies_check'] ) ) {
685
-            if ( empty( $wpinv_options['vat_offline_check'] ) ) {
686
-                $valid = self::offline_check( $input['vat_number'] );
684
+        if (!empty($wpinv_options['vat_vies_check'])) {
685
+            if (empty($wpinv_options['vat_offline_check'])) {
686
+                $valid = self::offline_check($input['vat_number']);
687 687
             } else {
688 688
                 $valid = true;
689 689
             }
690 690
             
691
-            $message = $valid ? '' : __( 'VAT number not validated', 'invoicing' );
691
+            $message = $valid ? '' : __('VAT number not validated', 'invoicing');
692 692
         } else {
693
-            $result = self::check_vat( $input['vat_number'] );
693
+            $result = self::check_vat($input['vat_number']);
694 694
             
695
-            if ( empty( $result['valid'] ) ) {
695
+            if (empty($result['valid'])) {
696 696
                 $valid      = false;
697 697
                 $message    = $result['message'];
698 698
             } else {
699
-                $valid      = ( isset( $result['company'] ) && ( $result['company'] == '---' || ( strcasecmp( trim( $result['company'] ), trim( $input['vat_company_name'] ) ) == 0 ) ) ) || !empty( $wpinv_options['vat_disable_company_name_check'] );
700
-                $message    = $valid ? '' : __( 'The company name associated with the VAT number provided is not the same as the company name provided.', 'invoicing' );
699
+                $valid      = (isset($result['company']) && ($result['company'] == '---' || (strcasecmp(trim($result['company']), trim($input['vat_company_name'])) == 0))) || !empty($wpinv_options['vat_disable_company_name_check']);
700
+                $message    = $valid ? '' : __('The company name associated with the VAT number provided is not the same as the company name provided.', 'invoicing');
701 701
             }
702 702
         }
703 703
 
704
-        if ( $message && self::is_vat_validated() != $valid ) {
705
-            add_settings_error( 'wpinv-notices', '', $message, ( $valid ? 'updated' : 'error' ) );
704
+        if ($message && self::is_vat_validated() != $valid) {
705
+            add_settings_error('wpinv-notices', '', $message, ($valid ? 'updated' : 'error'));
706 706
         }
707 707
 
708 708
         $input['vat_valid'] = $valid;
709 709
         return $input;
710 710
     }
711 711
     
712
-    public static function sanitize_vat_rates( $input ) {
713
-        if( !current_user_can( 'manage_options' ) ) {
714
-            add_settings_error( 'wpinv-notices', '', __( 'Your account does not have permission to add rate classes.', 'invoicing' ), 'error' );
712
+    public static function sanitize_vat_rates($input) {
713
+        if (!current_user_can('manage_options')) {
714
+            add_settings_error('wpinv-notices', '', __('Your account does not have permission to add rate classes.', 'invoicing'), 'error');
715 715
             return $input;
716 716
         }
717 717
         
718 718
         $vat_classes = self::get_rate_classes();
719
-        $vat_class = !empty( $_REQUEST['wpi_vat_class'] ) && isset( $vat_classes[$_REQUEST['wpi_vat_class']] )? sanitize_text_field( $_REQUEST['wpi_vat_class'] ) : '';
719
+        $vat_class = !empty($_REQUEST['wpi_vat_class']) && isset($vat_classes[$_REQUEST['wpi_vat_class']]) ? sanitize_text_field($_REQUEST['wpi_vat_class']) : '';
720 720
         
721
-        if ( empty( $vat_class ) ) {
722
-            add_settings_error( 'wpinv-notices', '', __( 'No valid VAT rates class contained in the request to save rates.', 'invoicing' ), 'error' );
721
+        if (empty($vat_class)) {
722
+            add_settings_error('wpinv-notices', '', __('No valid VAT rates class contained in the request to save rates.', 'invoicing'), 'error');
723 723
             
724 724
             return $input;
725 725
         }
726 726
 
727
-        $new_rates = ! empty( $_POST['vat_rates'] ) ? array_values( $_POST['vat_rates'] ) : array();
727
+        $new_rates = !empty($_POST['vat_rates']) ? array_values($_POST['vat_rates']) : array();
728 728
 
729
-        if ( $vat_class === '_standard' ) {
729
+        if ($vat_class === '_standard') {
730 730
             // Save the active rates in the invoice settings
731
-            update_option( 'wpinv_tax_rates', $new_rates );
731
+            update_option('wpinv_tax_rates', $new_rates);
732 732
         } else {
733 733
             // Get the existing set of rates
734 734
             $rates = self::get_non_standard_rates();
735 735
             $rates[$vat_class] = $new_rates;
736 736
 
737
-            update_option( 'wpinv_vat_rates', $rates );
737
+            update_option('wpinv_vat_rates', $rates);
738 738
         }
739 739
         
740 740
         return $input;
@@ -744,71 +744,71 @@  discard block
 block discarded – undo
744 744
         $response = array();
745 745
         $response['success'] = false;
746 746
         
747
-        if ( !current_user_can( 'manage_options' ) ) {
748
-            $response['error'] = __( 'Invalid access!', 'invoicing' );
749
-            wp_send_json( $response );
747
+        if (!current_user_can('manage_options')) {
748
+            $response['error'] = __('Invalid access!', 'invoicing');
749
+            wp_send_json($response);
750 750
         }
751 751
         
752
-        $vat_class_name = !empty( $_POST['name'] ) ? sanitize_text_field( $_POST['name'] ) : false;
753
-        $vat_class_desc = !empty( $_POST['desc'] ) ? sanitize_text_field( $_POST['desc'] ) : false;
752
+        $vat_class_name = !empty($_POST['name']) ? sanitize_text_field($_POST['name']) : false;
753
+        $vat_class_desc = !empty($_POST['desc']) ? sanitize_text_field($_POST['desc']) : false;
754 754
         
755
-        if ( empty( $vat_class_name ) ) {
756
-            $response['error'] = __( 'Select the VAT rate name', 'invoicing' );
757
-            wp_send_json( $response );
755
+        if (empty($vat_class_name)) {
756
+            $response['error'] = __('Select the VAT rate name', 'invoicing');
757
+            wp_send_json($response);
758 758
         }
759 759
         
760 760
         $vat_classes = (array)self::get_rate_classes();
761 761
 
762
-        if ( !empty( $vat_classes ) && in_array( strtolower( $vat_class_name ), array_map( 'strtolower', array_values( $vat_classes ) ) ) ) {
763
-            $response['error'] = wp_sprintf( __( 'A VAT Rate name "%s" already exists', 'invoicing' ), $vat_class_name );
764
-            wp_send_json( $response );
762
+        if (!empty($vat_classes) && in_array(strtolower($vat_class_name), array_map('strtolower', array_values($vat_classes)))) {
763
+            $response['error'] = wp_sprintf(__('A VAT Rate name "%s" already exists', 'invoicing'), $vat_class_name);
764
+            wp_send_json($response);
765 765
         }
766 766
         
767
-        $rate_class_key = normalize_whitespace( 'wpi-' . $vat_class_name );
768
-        $rate_class_key = sanitize_key( str_replace( " ", "-", $rate_class_key ) );
767
+        $rate_class_key = normalize_whitespace('wpi-' . $vat_class_name);
768
+        $rate_class_key = sanitize_key(str_replace(" ", "-", $rate_class_key));
769 769
         
770
-        $vat_classes = (array)self::get_rate_classes( true );
771
-        $vat_classes[$rate_class_key] = array( 'name' => $vat_class_name, 'desc' => $vat_class_desc );
770
+        $vat_classes = (array)self::get_rate_classes(true);
771
+        $vat_classes[$rate_class_key] = array('name' => $vat_class_name, 'desc' => $vat_class_desc);
772 772
         
773
-        update_option( '_wpinv_vat_rate_classes', $vat_classes );
773
+        update_option('_wpinv_vat_rate_classes', $vat_classes);
774 774
         
775 775
         $response['success'] = true;
776
-        $response['redirect'] = admin_url( 'admin.php?page=wpinv-settings&tab=taxes&section=vat_rates&wpi_sub=' . $rate_class_key );
776
+        $response['redirect'] = admin_url('admin.php?page=wpinv-settings&tab=taxes&section=vat_rates&wpi_sub=' . $rate_class_key);
777 777
         
778
-        wp_send_json( $response );
778
+        wp_send_json($response);
779 779
     }
780 780
     
781 781
     public static function delete_class() {
782 782
         $response = array();
783 783
         $response['success'] = false;
784 784
         
785
-        if ( !current_user_can( 'manage_options' ) || !isset( $_POST['class'] ) ) {
786
-            $response['error'] = __( 'Invalid access!', 'invoicing' );
787
-            wp_send_json( $response );
785
+        if (!current_user_can('manage_options') || !isset($_POST['class'])) {
786
+            $response['error'] = __('Invalid access!', 'invoicing');
787
+            wp_send_json($response);
788 788
         }
789 789
         
790
-        $vat_class = isset( $_POST['class'] ) && $_POST['class'] !== '' ? sanitize_text_field( $_POST['class'] ) : false;
790
+        $vat_class = isset($_POST['class']) && $_POST['class'] !== '' ? sanitize_text_field($_POST['class']) : false;
791 791
         $vat_classes = (array)self::get_rate_classes();
792 792
 
793
-        if ( !isset( $vat_classes[$vat_class] ) ) {
794
-            $response['error'] = __( 'Requested class does not exists', 'invoicing' );
795
-            wp_send_json( $response );
793
+        if (!isset($vat_classes[$vat_class])) {
794
+            $response['error'] = __('Requested class does not exists', 'invoicing');
795
+            wp_send_json($response);
796 796
         }
797 797
         
798
-        if ( $vat_class == '_new' || $vat_class == '_standard' ) {
799
-            $response['error'] = __( 'You can not delete standard rates class', 'invoicing' );
800
-            wp_send_json( $response );
798
+        if ($vat_class == '_new' || $vat_class == '_standard') {
799
+            $response['error'] = __('You can not delete standard rates class', 'invoicing');
800
+            wp_send_json($response);
801 801
         }
802 802
             
803
-        $vat_classes = (array)self::get_rate_classes( true );
804
-        unset( $vat_classes[$vat_class] );
803
+        $vat_classes = (array)self::get_rate_classes(true);
804
+        unset($vat_classes[$vat_class]);
805 805
         
806
-        update_option( '_wpinv_vat_rate_classes', $vat_classes );
806
+        update_option('_wpinv_vat_rate_classes', $vat_classes);
807 807
         
808 808
         $response['success'] = true;
809
-        $response['redirect'] = admin_url( 'admin.php?page=wpinv-settings&tab=taxes&section=vat_rates&wpi_sub=_new' );
809
+        $response['redirect'] = admin_url('admin.php?page=wpinv-settings&tab=taxes&section=vat_rates&wpi_sub=_new');
810 810
         
811
-        wp_send_json( $response );
811
+        wp_send_json($response);
812 812
     }
813 813
     
814 814
     public static function update_eu_rates() {        
@@ -817,72 +817,72 @@  discard block
 block discarded – undo
817 817
         $response['error']      = null;
818 818
         $response['data']       = null;
819 819
         
820
-        if ( !current_user_can( 'manage_options' ) ) {
821
-            $response['error'] = __( 'Invalid access!', 'invoicing' );
822
-            wp_send_json( $response );
820
+        if (!current_user_can('manage_options')) {
821
+            $response['error'] = __('Invalid access!', 'invoicing');
822
+            wp_send_json($response);
823 823
         }
824 824
         
825
-        $group      = !empty( $_POST['group'] ) ? sanitize_text_field( $_POST['group'] ) : '';
826
-        $euvatrates = self::request_euvatrates( $group );
825
+        $group      = !empty($_POST['group']) ? sanitize_text_field($_POST['group']) : '';
826
+        $euvatrates = self::request_euvatrates($group);
827 827
         
828
-        if ( !empty( $euvatrates ) ) {
829
-            if ( !empty( $euvatrates['success'] ) && !empty( $euvatrates['rates'] ) ) {
828
+        if (!empty($euvatrates)) {
829
+            if (!empty($euvatrates['success']) && !empty($euvatrates['rates'])) {
830 830
                 $response['success']        = true;
831 831
                 $response['data']['rates']  = $euvatrates['rates'];
832
-            } else if ( !empty( $euvatrates['error'] ) ) {
832
+            } else if (!empty($euvatrates['error'])) {
833 833
                 $response['error']          = $euvatrates['error'];
834 834
             }
835 835
         }
836 836
             
837
-        wp_send_json( $response );
837
+        wp_send_json($response);
838 838
     }
839 839
     
840 840
     public static function hide_vat_fields() {
841
-        $hide = wpinv_get_option( 'vat_disable_fields' );
841
+        $hide = wpinv_get_option('vat_disable_fields');
842 842
         
843
-        return apply_filters( 'wpinv_hide_vat_fields', $hide );
843
+        return apply_filters('wpinv_hide_vat_fields', $hide);
844 844
     }
845 845
     
846 846
     public static function same_country_rule() {
847
-        $same_country_rule = wpinv_get_option( 'vat_same_country_rule' );
847
+        $same_country_rule = wpinv_get_option('vat_same_country_rule');
848 848
         
849
-        return apply_filters( 'wpinv_vat_same_country_rule', $same_country_rule );
849
+        return apply_filters('wpinv_vat_same_country_rule', $same_country_rule);
850 850
     }
851 851
     
852 852
     public static function get_vat_name() {
853
-        $vat_name   = wpinv_get_option( 'vat_name' );
854
-        $vat_name   = !empty( $vat_name ) ? $vat_name : 'VAT';
853
+        $vat_name   = wpinv_get_option('vat_name');
854
+        $vat_name   = !empty($vat_name) ? $vat_name : 'VAT';
855 855
         
856
-        return apply_filters( 'wpinv_get_owner_vat_name', $vat_name );
856
+        return apply_filters('wpinv_get_owner_vat_name', $vat_name);
857 857
     }
858 858
     
859 859
     public static function get_company_name() {
860
-        $company_name = wpinv_get_option( 'vat_company_name' );
860
+        $company_name = wpinv_get_option('vat_company_name');
861 861
         
862
-        return apply_filters( 'wpinv_get_owner_company_name', $company_name );
862
+        return apply_filters('wpinv_get_owner_company_name', $company_name);
863 863
     }
864 864
     
865 865
     public static function get_vat_number() {
866
-        $vat_number = wpinv_get_option( 'vat_number' );
866
+        $vat_number = wpinv_get_option('vat_number');
867 867
         
868
-        return apply_filters( 'wpinv_get_owner_vat_number', $vat_number );
868
+        return apply_filters('wpinv_get_owner_vat_number', $vat_number);
869 869
     }
870 870
     
871 871
     public static function is_vat_validated() {
872
-        $validated = self::get_vat_number() && wpinv_get_option( 'vat_valid' );
872
+        $validated = self::get_vat_number() && wpinv_get_option('vat_valid');
873 873
         
874
-        return apply_filters( 'wpinv_is_owner_vat_validated', $validated );
874
+        return apply_filters('wpinv_is_owner_vat_validated', $validated);
875 875
     }
876 876
     
877
-    public static function sanitize_vat( $vat_number, $country_code = '' ) {        
878
-        $vat_number = str_replace( array(' ', '.', '-', '_', ',' ), '', strtoupper( trim( $vat_number ) ) );
877
+    public static function sanitize_vat($vat_number, $country_code = '') {        
878
+        $vat_number = str_replace(array(' ', '.', '-', '_', ','), '', strtoupper(trim($vat_number)));
879 879
         
880
-        if ( empty( $country_code ) ) {
881
-            $country_code = substr( $vat_number, 0, 2 );
880
+        if (empty($country_code)) {
881
+            $country_code = substr($vat_number, 0, 2);
882 882
         }
883 883
         
884
-        if ( strpos( $vat_number , $country_code ) === 0 ) {
885
-            $vat = str_replace( $country_code, '', $vat_number );
884
+        if (strpos($vat_number, $country_code) === 0) {
885
+            $vat = str_replace($country_code, '', $vat_number);
886 886
         } else {
887 887
             $vat = $country_code . $vat_number;
888 888
         }
@@ -895,140 +895,140 @@  discard block
 block discarded – undo
895 895
         return $return;
896 896
     }
897 897
     
898
-    public static function offline_check( $vat_number, $country_code = '', $formatted = false ) {
899
-        $vat            = self::sanitize_vat( $vat_number, $country_code );
898
+    public static function offline_check($vat_number, $country_code = '', $formatted = false) {
899
+        $vat            = self::sanitize_vat($vat_number, $country_code);
900 900
         $vat_number     = $vat['vat_number'];
901 901
         $country_code   = $vat['iso'];
902 902
         $regex          = array();
903 903
         
904
-        switch ( $country_code ) {
904
+        switch ($country_code) {
905 905
             case 'AT':
906
-                $regex[] = '/^(AT)U(\d{8})$/';                           // Austria
906
+                $regex[] = '/^(AT)U(\d{8})$/'; // Austria
907 907
                 break;
908 908
             case 'BE':
909
-                $regex[] = '/^(BE)(0?\d{9})$/';                          // Belgium
909
+                $regex[] = '/^(BE)(0?\d{9})$/'; // Belgium
910 910
                 break;
911 911
             case 'BG':
912
-                $regex[] = '/^(BG)(\d{9,10})$/';                         // Bulgaria
912
+                $regex[] = '/^(BG)(\d{9,10})$/'; // Bulgaria
913 913
                 break;
914 914
             case 'CH':
915 915
             case 'CHE':
916
-                $regex[] = '/^(CHE)(\d{9})MWST$/';                       // Switzerland (Not EU)
916
+                $regex[] = '/^(CHE)(\d{9})MWST$/'; // Switzerland (Not EU)
917 917
                 break;
918 918
             case 'CY':
919
-                $regex[] = '/^(CY)([0-5|9]\d{7}[A-Z])$/';                // Cyprus
919
+                $regex[] = '/^(CY)([0-5|9]\d{7}[A-Z])$/'; // Cyprus
920 920
                 break;
921 921
             case 'CZ':
922
-                $regex[] = '/^(CZ)(\d{8,13})$/';                         // Czech Republic
922
+                $regex[] = '/^(CZ)(\d{8,13})$/'; // Czech Republic
923 923
                 break;
924 924
             case 'DE':
925
-                $regex[] = '/^(DE)([1-9]\d{8})$/';                       // Germany
925
+                $regex[] = '/^(DE)([1-9]\d{8})$/'; // Germany
926 926
                 break;
927 927
             case 'DK':
928
-                $regex[] = '/^(DK)(\d{8})$/';                            // Denmark
928
+                $regex[] = '/^(DK)(\d{8})$/'; // Denmark
929 929
                 break;
930 930
             case 'EE':
931
-                $regex[] = '/^(EE)(10\d{7})$/';                          // Estonia
931
+                $regex[] = '/^(EE)(10\d{7})$/'; // Estonia
932 932
                 break;
933 933
             case 'EL':
934
-                $regex[] = '/^(EL)(\d{9})$/';                            // Greece
934
+                $regex[] = '/^(EL)(\d{9})$/'; // Greece
935 935
                 break;
936 936
             case 'ES':
937
-                $regex[] = '/^(ES)([A-Z]\d{8})$/';                       // Spain (National juridical entities)
938
-                $regex[] = '/^(ES)([A-H|N-S|W]\d{7}[A-J])$/';            // Spain (Other juridical entities)
939
-                $regex[] = '/^(ES)([0-9|Y|Z]\d{7}[A-Z])$/';              // Spain (Personal entities type 1)
940
-                $regex[] = '/^(ES)([K|L|M|X]\d{7}[A-Z])$/';              // Spain (Personal entities type 2)
937
+                $regex[] = '/^(ES)([A-Z]\d{8})$/'; // Spain (National juridical entities)
938
+                $regex[] = '/^(ES)([A-H|N-S|W]\d{7}[A-J])$/'; // Spain (Other juridical entities)
939
+                $regex[] = '/^(ES)([0-9|Y|Z]\d{7}[A-Z])$/'; // Spain (Personal entities type 1)
940
+                $regex[] = '/^(ES)([K|L|M|X]\d{7}[A-Z])$/'; // Spain (Personal entities type 2)
941 941
                 break;
942 942
             case 'EU':
943
-                $regex[] = '/^(EU)(\d{9})$/';                            // EU-type
943
+                $regex[] = '/^(EU)(\d{9})$/'; // EU-type
944 944
                 break;
945 945
             case 'FI':
946
-                $regex[] = '/^(FI)(\d{8})$/';                            // Finland
946
+                $regex[] = '/^(FI)(\d{8})$/'; // Finland
947 947
                 break;
948 948
             case 'FR':
949
-                $regex[] = '/^(FR)(\d{11})$/';                           // France (1)
950
-                $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)](\d{10})$/';        // France (2)
951
-                $regex[] = '/^(FR)\d[(A-H)|(J-N)|(P-Z)](\d{9})$/';       // France (3)
952
-                $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)]{2}(\d{9})$/';      // France (4)
949
+                $regex[] = '/^(FR)(\d{11})$/'; // France (1)
950
+                $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)](\d{10})$/'; // France (2)
951
+                $regex[] = '/^(FR)\d[(A-H)|(J-N)|(P-Z)](\d{9})$/'; // France (3)
952
+                $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)]{2}(\d{9})$/'; // France (4)
953 953
                 break;
954 954
             case 'GB':
955
-                $regex[] = '/^(GB)?(\d{9})$/';                           // UK (Standard)
956
-                $regex[] = '/^(GB)?(\d{12})$/';                          // UK (Branches)
957
-                $regex[] = '/^(GB)?(GD\d{3})$/';                         // UK (Government)
958
-                $regex[] = '/^(GB)?(HA\d{3})$/';                         // UK (Health authority)
955
+                $regex[] = '/^(GB)?(\d{9})$/'; // UK (Standard)
956
+                $regex[] = '/^(GB)?(\d{12})$/'; // UK (Branches)
957
+                $regex[] = '/^(GB)?(GD\d{3})$/'; // UK (Government)
958
+                $regex[] = '/^(GB)?(HA\d{3})$/'; // UK (Health authority)
959 959
                 break;
960 960
             case 'GR':
961
-                $regex[] = '/^(GR)(\d{8,9})$/';                          // Greece
961
+                $regex[] = '/^(GR)(\d{8,9})$/'; // Greece
962 962
                 break;
963 963
             case 'HR':
964
-                $regex[] = '/^(HR)(\d{11})$/';                           // Croatia
964
+                $regex[] = '/^(HR)(\d{11})$/'; // Croatia
965 965
                 break;
966 966
             case 'HU':
967
-                $regex[] = '/^(HU)(\d{8})$/';                            // Hungary
967
+                $regex[] = '/^(HU)(\d{8})$/'; // Hungary
968 968
                 break;
969 969
             case 'IE':
970
-                $regex[] = '/^(IE)(\d{7}[A-W])$/';                       // Ireland (1)
971
-                $regex[] = '/^(IE)([7-9][A-Z\*\+)]\d{5}[A-W])$/';        // Ireland (2)
972
-                $regex[] = '/^(IE)(\d{7}[A-Z][AH])$/';                   // Ireland (3) (new format from 1 Jan 2013)
970
+                $regex[] = '/^(IE)(\d{7}[A-W])$/'; // Ireland (1)
971
+                $regex[] = '/^(IE)([7-9][A-Z\*\+)]\d{5}[A-W])$/'; // Ireland (2)
972
+                $regex[] = '/^(IE)(\d{7}[A-Z][AH])$/'; // Ireland (3) (new format from 1 Jan 2013)
973 973
                 break;
974 974
             case 'IT':
975
-                $regex[] = '/^(IT)(\d{11})$/';                           // Italy
975
+                $regex[] = '/^(IT)(\d{11})$/'; // Italy
976 976
                 break;
977 977
             case 'LV':
978
-                $regex[] = '/^(LV)(\d{11})$/';                           // Latvia
978
+                $regex[] = '/^(LV)(\d{11})$/'; // Latvia
979 979
                 break;
980 980
             case 'LT':
981
-                $regex[] = '/^(LT)(\d{9}|\d{12})$/';                     // Lithuania
981
+                $regex[] = '/^(LT)(\d{9}|\d{12})$/'; // Lithuania
982 982
                 break;
983 983
             case 'LU':
984
-                $regex[] = '/^(LU)(\d{8})$/';                            // Luxembourg
984
+                $regex[] = '/^(LU)(\d{8})$/'; // Luxembourg
985 985
                 break;
986 986
             case 'MT':
987
-                $regex[] = '/^(MT)([1-9]\d{7})$/';                       // Malta
987
+                $regex[] = '/^(MT)([1-9]\d{7})$/'; // Malta
988 988
                 break;
989 989
             case 'NL':
990
-                $regex[] = '/^(NL)(\d{9})B\d{2}$/';                      // Netherlands
990
+                $regex[] = '/^(NL)(\d{9})B\d{2}$/'; // Netherlands
991 991
                 break;
992 992
             case 'NO':
993
-                $regex[] = '/^(NO)(\d{9})$/';                            // Norway (Not EU)
993
+                $regex[] = '/^(NO)(\d{9})$/'; // Norway (Not EU)
994 994
                 break;
995 995
             case 'PL':
996
-                $regex[] = '/^(PL)(\d{10})$/';                           // Poland
996
+                $regex[] = '/^(PL)(\d{10})$/'; // Poland
997 997
                 break;
998 998
             case 'PT':
999
-                $regex[] = '/^(PT)(\d{9})$/';                            // Portugal
999
+                $regex[] = '/^(PT)(\d{9})$/'; // Portugal
1000 1000
                 break;
1001 1001
             case 'RO':
1002
-                $regex[] = '/^(RO)([1-9]\d{1,9})$/';                     // Romania
1002
+                $regex[] = '/^(RO)([1-9]\d{1,9})$/'; // Romania
1003 1003
                 break;
1004 1004
             case 'RS':
1005
-                $regex[] = '/^(RS)(\d{9})$/';                            // Serbia (Not EU)
1005
+                $regex[] = '/^(RS)(\d{9})$/'; // Serbia (Not EU)
1006 1006
                 break;
1007 1007
             case 'SI':
1008
-                $regex[] = '/^(SI)([1-9]\d{7})$/';                       // Slovenia
1008
+                $regex[] = '/^(SI)([1-9]\d{7})$/'; // Slovenia
1009 1009
                 break;
1010 1010
             case 'SK':
1011
-                $regex[] = '/^(SK)([1-9]\d[(2-4)|(6-9)]\d{7})$/';        // Slovakia Republic
1011
+                $regex[] = '/^(SK)([1-9]\d[(2-4)|(6-9)]\d{7})$/'; // Slovakia Republic
1012 1012
                 break;
1013 1013
             case 'SE':
1014
-                $regex[] = '/^(SE)(\d{10}01)$/';                         // Sweden
1014
+                $regex[] = '/^(SE)(\d{10}01)$/'; // Sweden
1015 1015
                 break;
1016 1016
             default:
1017 1017
                 $regex = array();
1018 1018
             break;
1019 1019
         }
1020 1020
         
1021
-        if ( empty( $regex ) ) {
1021
+        if (empty($regex)) {
1022 1022
             return false;
1023 1023
         }
1024 1024
         
1025
-        foreach ( $regex as $pattern ) {
1025
+        foreach ($regex as $pattern) {
1026 1026
             $matches = null;
1027
-            preg_match_all( $pattern, $vat_number, $matches );
1027
+            preg_match_all($pattern, $vat_number, $matches);
1028 1028
             
1029
-            if ( !empty( $matches[1][0] ) && !empty( $matches[2][0] ) ) {
1030
-                if ( $formatted ) {
1031
-                    return array( 'code' => $matches[1][0], 'number' => $matches[2][0] );
1029
+            if (!empty($matches[1][0]) && !empty($matches[2][0])) {
1030
+                if ($formatted) {
1031
+                    return array('code' => $matches[1][0], 'number' => $matches[2][0]);
1032 1032
                 } else {
1033 1033
                     return true;
1034 1034
                 }
@@ -1038,75 +1038,75 @@  discard block
 block discarded – undo
1038 1038
         return false;
1039 1039
     }
1040 1040
     
1041
-    public static function vies_check( $vat_number, $country_code = '', $result = false ) {
1042
-        $vat            = self::sanitize_vat( $vat_number, $country_code );
1041
+    public static function vies_check($vat_number, $country_code = '', $result = false) {
1042
+        $vat            = self::sanitize_vat($vat_number, $country_code);
1043 1043
         $vat_number     = $vat['vat'];
1044 1044
         $iso            = $vat['iso'];
1045 1045
         
1046
-        $url = 'http://ec.europa.eu/taxation_customs/vies/viesquer.do?ms=' . urlencode( $iso ) . '&iso=' . urlencode( $iso ) . '&vat=' . urlencode( $vat_number );
1046
+        $url = 'http://ec.europa.eu/taxation_customs/vies/viesquer.do?ms=' . urlencode($iso) . '&iso=' . urlencode($iso) . '&vat=' . urlencode($vat_number);
1047 1047
         
1048
-        if ( ini_get( 'allow_url_fopen' ) ) {
1049
-            $response = file_get_contents( $url );
1050
-        } else if ( function_exists( 'curl_init' ) ) {
1048
+        if (ini_get('allow_url_fopen')) {
1049
+            $response = file_get_contents($url);
1050
+        } else if (function_exists('curl_init')) {
1051 1051
             $ch = curl_init();
1052 1052
             
1053
-            curl_setopt( $ch, CURLOPT_URL, $url );
1054
-            curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 30 );
1055
-            curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
1056
-            curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0 );
1057
-            curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 );
1053
+            curl_setopt($ch, CURLOPT_URL, $url);
1054
+            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
1055
+            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
1056
+            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
1057
+            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
1058 1058
             
1059
-            $response = curl_exec( $ch );
1059
+            $response = curl_exec($ch);
1060 1060
             
1061
-            if ( curl_errno( $ch ) ) {
1062
-                wpinv_error_log( curl_error( $ch ), 'VIES CHECK ERROR' );
1061
+            if (curl_errno($ch)) {
1062
+                wpinv_error_log(curl_error($ch), 'VIES CHECK ERROR');
1063 1063
                 $response = '';
1064 1064
             }
1065 1065
             
1066
-            curl_close( $ch );
1066
+            curl_close($ch);
1067 1067
         } else {
1068
-            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' );
1068
+            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');
1069 1069
         }
1070 1070
         
1071
-        if ( empty( $response ) ) {
1071
+        if (empty($response)) {
1072 1072
             return $result;
1073 1073
         }
1074 1074
 
1075
-        if ( preg_match( '/invalid VAT number/i', $response ) ) {
1075
+        if (preg_match('/invalid VAT number/i', $response)) {
1076 1076
             return false;
1077
-        } else if ( preg_match( '/valid VAT number/i', $response, $matches ) ) {
1078
-            $content = explode( "valid VAT number", htmlentities( $response ) );
1077
+        } else if (preg_match('/valid VAT number/i', $response, $matches)) {
1078
+            $content = explode("valid VAT number", htmlentities($response));
1079 1079
             
1080
-            if ( !empty( $content[1] ) ) {
1081
-                preg_match_all( '/<tr>(.*?)<td.*?>(.*?)<\/td>(.*?)<\/tr>/si', html_entity_decode( $content[1] ), $matches );
1080
+            if (!empty($content[1])) {
1081
+                preg_match_all('/<tr>(.*?)<td.*?>(.*?)<\/td>(.*?)<\/tr>/si', html_entity_decode($content[1]), $matches);
1082 1082
                 
1083
-                if ( !empty( $matches[2] ) && $matches[3] ) {
1083
+                if (!empty($matches[2]) && $matches[3]) {
1084 1084
                     $return = array();
1085 1085
                     
1086
-                    foreach ( $matches[2] as $key => $label ) {
1087
-                        $label = trim( $label );
1086
+                    foreach ($matches[2] as $key => $label) {
1087
+                        $label = trim($label);
1088 1088
                         
1089
-                        switch ( strtolower( $label ) ) {
1089
+                        switch (strtolower($label)) {
1090 1090
                             case 'member state':
1091
-                                $return['state'] = trim( strip_tags( $matches[3][$key] ) );
1091
+                                $return['state'] = trim(strip_tags($matches[3][$key]));
1092 1092
                             break;
1093 1093
                             case 'vat number':
1094
-                                $return['number'] = trim( strip_tags( $matches[3][$key] ) );
1094
+                                $return['number'] = trim(strip_tags($matches[3][$key]));
1095 1095
                             break;
1096 1096
                             case 'name':
1097
-                                $return['company'] = trim( strip_tags( $matches[3][$key] ) );
1097
+                                $return['company'] = trim(strip_tags($matches[3][$key]));
1098 1098
                             break;
1099 1099
                             case 'address':
1100
-                                $address           = str_replace( array( "<br><br>", "<br /><br />", "<br/><br/>" ), "<br>", html_entity_decode( trim( $matches[3][$key] ) ) );
1101
-                                $return['address'] = trim( strip_tags( $address, '<br>' ) );
1100
+                                $address           = str_replace(array("<br><br>", "<br /><br />", "<br/><br/>"), "<br>", html_entity_decode(trim($matches[3][$key])));
1101
+                                $return['address'] = trim(strip_tags($address, '<br>'));
1102 1102
                             break;
1103 1103
                             case 'consultation number':
1104
-                                $return['consultation'] = trim( strip_tags( $matches[3][$key] ) );
1104
+                                $return['consultation'] = trim(strip_tags($matches[3][$key]));
1105 1105
                             break;
1106 1106
                         }
1107 1107
                     }
1108 1108
                     
1109
-                    if ( !empty( $return ) ) {
1109
+                    if (!empty($return)) {
1110 1110
                         return $return;
1111 1111
                     }
1112 1112
                 }
@@ -1118,55 +1118,55 @@  discard block
 block discarded – undo
1118 1118
         }
1119 1119
     }
1120 1120
     
1121
-    public static function check_vat( $vat_number, $country_code = '' ) {        
1121
+    public static function check_vat($vat_number, $country_code = '') {        
1122 1122
         $vat_name           = self::get_vat_name();
1123 1123
         
1124 1124
         $return             = array();
1125 1125
         $return['valid']    = false;
1126
-        $return['message']  = wp_sprintf( __( '%s number not validated', 'invoicing' ), $vat_name );
1126
+        $return['message']  = wp_sprintf(__('%s number not validated', 'invoicing'), $vat_name);
1127 1127
                 
1128
-        if ( !wpinv_get_option( 'vat_offline_check' ) && !self::offline_check( $vat_number, $country_code ) ) {
1128
+        if (!wpinv_get_option('vat_offline_check') && !self::offline_check($vat_number, $country_code)) {
1129 1129
             return $return;
1130 1130
         }
1131 1131
             
1132
-        $response = self::vies_check( $vat_number, $country_code );
1132
+        $response = self::vies_check($vat_number, $country_code);
1133 1133
         
1134
-        if ( $response ) {
1135
-            $return['valid']    = true;
1134
+        if ($response) {
1135
+            $return['valid'] = true;
1136 1136
             
1137
-            if ( is_array( $response ) ) {
1138
-                $return['company'] = isset( $response['company'] ) ? $response['company'] : '';
1139
-                $return['address'] = isset( $response['address'] ) ? $response['address'] : '';
1137
+            if (is_array($response)) {
1138
+                $return['company'] = isset($response['company']) ? $response['company'] : '';
1139
+                $return['address'] = isset($response['address']) ? $response['address'] : '';
1140 1140
                 $return['message'] = $return['company'] . '<br/>' . $return['address'];
1141 1141
             }
1142 1142
         } else {
1143 1143
             $return['valid']    = false;
1144
-            $return['message']  = wp_sprintf( __( 'Fail to validate the %s number: EU Commission VAT server (VIES) check fails.', 'invoicing' ), $vat_name );
1144
+            $return['message']  = wp_sprintf(__('Fail to validate the %s number: EU Commission VAT server (VIES) check fails.', 'invoicing'), $vat_name);
1145 1145
         }
1146 1146
         
1147 1147
         return $return;
1148 1148
     }
1149 1149
     
1150
-    public static function request_euvatrates( $group ) {
1150
+    public static function request_euvatrates($group) {
1151 1151
         $response               = array();
1152 1152
         $response['success']    = false;
1153 1153
         $response['error']      = null;
1154 1154
         $response['eurates']    = null;
1155 1155
         
1156 1156
         $euvatrates_url = 'https://euvatrates.com/rates.json';
1157
-        $euvatrates_url = apply_filters( 'wpinv_euvatrates_url', $euvatrates_url );
1158
-        $api_response   = wp_remote_get( $euvatrates_url );
1157
+        $euvatrates_url = apply_filters('wpinv_euvatrates_url', $euvatrates_url);
1158
+        $api_response   = wp_remote_get($euvatrates_url);
1159 1159
     
1160 1160
         try {
1161
-            if ( is_wp_error( $api_response ) ) {
1162
-                $response['error']      = __( $api_response->get_error_message(), 'invoicing' );
1161
+            if (is_wp_error($api_response)) {
1162
+                $response['error'] = __($api_response->get_error_message(), 'invoicing');
1163 1163
             } else {
1164
-                $body = json_decode( $api_response['body'] );
1164
+                $body = json_decode($api_response['body']);
1165 1165
                 
1166
-                if ( isset( $body->rates ) ) {
1166
+                if (isset($body->rates)) {
1167 1167
                     $rates = array();
1168 1168
                     
1169
-                    foreach ( $body->rates as $country_code => $rate ) {
1169
+                    foreach ($body->rates as $country_code => $rate) {
1170 1170
                         $vat_rate = array();
1171 1171
                         $vat_rate['country']        = $rate->country;
1172 1172
                         $vat_rate['standard']       = (float)$rate->standard_rate;
@@ -1174,7 +1174,7 @@  discard block
 block discarded – undo
1174 1174
                         $vat_rate['superreduced']   = (float)$rate->super_reduced_rate;
1175 1175
                         $vat_rate['parking']        = (float)$rate->parking_rate;
1176 1176
                         
1177
-                        if ( $group !== '' && in_array( $group, array( 'standard', 'reduced', 'superreduced', 'parking' ) ) ) {
1177
+                        if ($group !== '' && in_array($group, array('standard', 'reduced', 'superreduced', 'parking'))) {
1178 1178
                             $vat_rate_group = array();
1179 1179
                             $vat_rate_group['country'] = $rate->country;
1180 1180
                             $vat_rate_group[$group]    = $vat_rate[$group];
@@ -1186,79 +1186,79 @@  discard block
 block discarded – undo
1186 1186
                     }
1187 1187
                     
1188 1188
                     $response['success']    = true;                                
1189
-                    $response['rates']      = apply_filters( 'wpinv_process_euvatrates', $rates, $api_response, $group );
1189
+                    $response['rates']      = apply_filters('wpinv_process_euvatrates', $rates, $api_response, $group);
1190 1190
                 } else {
1191
-                    $response['error']      = __( 'No EU rates found!', 'invoicing' );
1191
+                    $response['error']      = __('No EU rates found!', 'invoicing');
1192 1192
                 }
1193 1193
             }
1194
-        } catch ( Exception $e ) {
1195
-            $response['error'] = __( $e->getMessage(), 'invoicing' );
1194
+        } catch (Exception $e) {
1195
+            $response['error'] = __($e->getMessage(), 'invoicing');
1196 1196
         }
1197 1197
         
1198
-        return apply_filters( 'wpinv_response_euvatrates', $response, $group );
1198
+        return apply_filters('wpinv_response_euvatrates', $response, $group);
1199 1199
     }    
1200 1200
     
1201
-    public static function requires_vat( $requires_vat = false, $user_id = 0, $is_digital = null ) {
1201
+    public static function requires_vat($requires_vat = false, $user_id = 0, $is_digital = null) {
1202 1202
         global $wpi_item_id, $wpi_country;
1203 1203
         
1204
-        if ( !empty( $_POST['wpinv_country'] ) ) {
1205
-            $country_code = trim( $_POST['wpinv_country'] );
1206
-        } else if ( !empty( $_POST['country'] ) ) {
1207
-            $country_code = trim( $_POST['country'] );
1208
-        } else if ( !empty( $wpi_country ) ) {
1204
+        if (!empty($_POST['wpinv_country'])) {
1205
+            $country_code = trim($_POST['wpinv_country']);
1206
+        } else if (!empty($_POST['country'])) {
1207
+            $country_code = trim($_POST['country']);
1208
+        } else if (!empty($wpi_country)) {
1209 1209
             $country_code = $wpi_country;
1210 1210
         } else {
1211
-            $country_code = self::get_user_country( '', $user_id );
1211
+            $country_code = self::get_user_country('', $user_id);
1212 1212
         }
1213 1213
         
1214
-        if ( $is_digital === null && $wpi_item_id ) {
1215
-            $is_digital = $wpi_item_id ? self::item_has_digital_rule( $wpi_item_id ) : self::allow_vat_rules();
1214
+        if ($is_digital === null && $wpi_item_id) {
1215
+            $is_digital = $wpi_item_id ? self::item_has_digital_rule($wpi_item_id) : self::allow_vat_rules();
1216 1216
         }
1217 1217
         
1218
-        if ( !empty( $country_code ) ) {
1219
-            $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 ) );
1218
+        if (!empty($country_code)) {
1219
+            $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));
1220 1220
         }
1221 1221
         
1222
-        return apply_filters( 'wpinv_requires_vat', $requires_vat, $user_id );
1222
+        return apply_filters('wpinv_requires_vat', $requires_vat, $user_id);
1223 1223
     }
1224 1224
     
1225
-    public static function tax_label( $label = '' ) {
1225
+    public static function tax_label($label = '') {
1226 1226
         global $wpi_requires_vat;
1227 1227
         
1228
-        if ( !( $wpi_requires_vat !== 0 && $wpi_requires_vat ) ) {
1229
-            $wpi_requires_vat = self::requires_vat( 0, false );
1228
+        if (!($wpi_requires_vat !== 0 && $wpi_requires_vat)) {
1229
+            $wpi_requires_vat = self::requires_vat(0, false);
1230 1230
         }
1231 1231
         
1232
-        return $wpi_requires_vat ? __( self::get_vat_name(), 'invoicing' ) : ( $label ? $label : __( 'Tax', 'invoicing' ) );
1232
+        return $wpi_requires_vat ? __(self::get_vat_name(), 'invoicing') : ($label ? $label : __('Tax', 'invoicing'));
1233 1233
     }
1234 1234
     
1235 1235
     public static function standard_rates_label() {
1236
-        return __( 'Standard Rates', 'invoicing' );
1236
+        return __('Standard Rates', 'invoicing');
1237 1237
     }
1238 1238
     
1239
-    public static function get_rate_classes( $with_desc = false ) {        
1240
-        $rate_classes_option = get_option( '_wpinv_vat_rate_classes', true );
1241
-        $classes = maybe_unserialize( $rate_classes_option );
1239
+    public static function get_rate_classes($with_desc = false) {        
1240
+        $rate_classes_option = get_option('_wpinv_vat_rate_classes', true);
1241
+        $classes = maybe_unserialize($rate_classes_option);
1242 1242
         
1243
-        if ( empty( $classes ) || !is_array( $classes ) ) {
1243
+        if (empty($classes) || !is_array($classes)) {
1244 1244
             $classes = array();
1245 1245
         }
1246 1246
 
1247 1247
         $rate_classes = array();
1248
-        if ( !array_key_exists( '_standard', $classes ) ) {
1249
-            if ( $with_desc ) {
1250
-                $rate_classes['_standard'] = array( 'name' => self::standard_rates_label(), 'desc' => __( 'EU member states standard VAT rates', 'invoicing' ) );
1248
+        if (!array_key_exists('_standard', $classes)) {
1249
+            if ($with_desc) {
1250
+                $rate_classes['_standard'] = array('name' => self::standard_rates_label(), 'desc' => __('EU member states standard VAT rates', 'invoicing'));
1251 1251
             } else {
1252 1252
                 $rate_classes['_standard'] = self::standard_rates_label();
1253 1253
             }
1254 1254
         }
1255 1255
         
1256
-        foreach ( $classes as $key => $class ) {
1257
-            $name = !empty( $class['name'] ) ? __( $class['name'], 'invoicing' ) : $key;
1258
-            $desc = !empty( $class['desc'] ) ? __( $class['desc'], 'invoicing' ) : '';
1256
+        foreach ($classes as $key => $class) {
1257
+            $name = !empty($class['name']) ? __($class['name'], 'invoicing') : $key;
1258
+            $desc = !empty($class['desc']) ? __($class['desc'], 'invoicing') : '';
1259 1259
             
1260
-            if ( $with_desc ) {
1261
-                $rate_classes[$key] = array( 'name' => $name, 'desc' => $desc );
1260
+            if ($with_desc) {
1261
+                $rate_classes[$key] = array('name' => $name, 'desc' => $desc);
1262 1262
             } else {
1263 1263
                 $rate_classes[$key] = $name;
1264 1264
             }
@@ -1269,15 +1269,15 @@  discard block
 block discarded – undo
1269 1269
     
1270 1270
     public static function get_all_classes() {        
1271 1271
         $classes            = self::get_rate_classes();
1272
-        $classes['_exempt'] = __( 'Exempt (0%)', 'invoicing' );
1272
+        $classes['_exempt'] = __('Exempt (0%)', 'invoicing');
1273 1273
         
1274
-        return apply_filters( 'wpinv_vat_get_all_classes', $classes );
1274
+        return apply_filters('wpinv_vat_get_all_classes', $classes);
1275 1275
     }
1276 1276
     
1277
-    public static function get_class_desc( $rate_class ) {        
1278
-        $rate_classes = self::get_rate_classes( true );
1277
+    public static function get_class_desc($rate_class) {        
1278
+        $rate_classes = self::get_rate_classes(true);
1279 1279
 
1280
-        if ( !empty( $rate_classes ) && isset( $rate_classes[$rate_class] ) && isset( $rate_classes[$rate_class]['desc'] ) ) {
1280
+        if (!empty($rate_classes) && isset($rate_classes[$rate_class]) && isset($rate_classes[$rate_class]['desc'])) {
1281 1281
             return $rate_classes[$rate_class]['desc'];
1282 1282
         }
1283 1283
         
@@ -1293,106 +1293,106 @@  discard block
 block discarded – undo
1293 1293
             'increased'     => 'Increased'
1294 1294
         );
1295 1295
         
1296
-        return apply_filters( 'wpinv_get_vat_groups', $vat_groups );
1296
+        return apply_filters('wpinv_get_vat_groups', $vat_groups);
1297 1297
     }
1298 1298
 
1299 1299
     public static function get_rules() {
1300 1300
         $vat_rules = array(
1301
-            'digital' => __( 'Digital Product', 'invoicing' ),
1302
-            'physical' => __( 'Physical Product', 'invoicing' )
1301
+            'digital' => __('Digital Product', 'invoicing'),
1302
+            'physical' => __('Physical Product', 'invoicing')
1303 1303
         );
1304
-        return apply_filters( 'wpinv_get_vat_rules', $vat_rules );
1304
+        return apply_filters('wpinv_get_vat_rules', $vat_rules);
1305 1305
     }
1306 1306
 
1307
-    public static function get_vat_rates( $class ) {
1308
-        if ( $class === '_standard' ) {
1307
+    public static function get_vat_rates($class) {
1308
+        if ($class === '_standard') {
1309 1309
             return wpinv_get_tax_rates();
1310 1310
         }
1311 1311
 
1312 1312
         $rates = self::get_non_standard_rates();
1313 1313
 
1314
-        return array_key_exists( $class, $rates ) ? $rates[$class] : array();
1314
+        return array_key_exists($class, $rates) ? $rates[$class] : array();
1315 1315
     }
1316 1316
 
1317 1317
     public static function get_non_standard_rates() {
1318
-        $option = get_option( 'wpinv_vat_rates', array());
1319
-        return is_array( $option ) ? $option : array();
1318
+        $option = get_option('wpinv_vat_rates', array());
1319
+        return is_array($option) ? $option : array();
1320 1320
     }
1321 1321
     
1322 1322
     public static function allow_vat_rules() {
1323
-        return ( wpinv_use_taxes() && wpinv_get_option( 'apply_vat_rules' ) ? true : false );
1323
+        return (wpinv_use_taxes() && wpinv_get_option('apply_vat_rules') ? true : false);
1324 1324
     }
1325 1325
     
1326 1326
     public static function allow_vat_classes() {
1327 1327
         return false; // TODO
1328
-        return ( wpinv_get_option( 'vat_allow_classes' ) ? true : false );
1328
+        return (wpinv_get_option('vat_allow_classes') ? true : false);
1329 1329
     }
1330 1330
     
1331
-    public static function get_item_class( $postID ) {
1332
-        $class = get_post_meta( $postID, '_wpinv_vat_class', true );
1331
+    public static function get_item_class($postID) {
1332
+        $class = get_post_meta($postID, '_wpinv_vat_class', true);
1333 1333
 
1334
-        if ( empty( $class ) ) {
1334
+        if (empty($class)) {
1335 1335
             $class = '_standard';
1336 1336
         }
1337 1337
         
1338
-        return apply_filters( 'wpinv_get_item_vat_class', $class, $postID );
1338
+        return apply_filters('wpinv_get_item_vat_class', $class, $postID);
1339 1339
     }
1340 1340
     
1341
-    public static function item_class_label( $postID ) {        
1341
+    public static function item_class_label($postID) {        
1342 1342
         $vat_classes = self::get_all_classes();
1343 1343
         
1344
-        $class = self::get_item_class( $postID );
1345
-        $class = isset( $vat_classes[$class] ) ? $vat_classes[$class] : __( $class, 'invoicing' );
1344
+        $class = self::get_item_class($postID);
1345
+        $class = isset($vat_classes[$class]) ? $vat_classes[$class] : __($class, 'invoicing');
1346 1346
         
1347
-        return apply_filters( 'wpinv_item_class_label', $class, $postID );
1347
+        return apply_filters('wpinv_item_class_label', $class, $postID);
1348 1348
     }
1349 1349
     
1350
-    public static function get_item_rule( $postID ) {        
1351
-        $rule_type = get_post_meta( $postID, '_wpinv_vat_rule', true );
1350
+    public static function get_item_rule($postID) {        
1351
+        $rule_type = get_post_meta($postID, '_wpinv_vat_rule', true);
1352 1352
         
1353
-        if ( empty( $rule_type ) ) {        
1353
+        if (empty($rule_type)) {        
1354 1354
             $rule_type = self::allow_vat_rules() ? 'digital' : 'physical';
1355 1355
         }
1356 1356
         
1357
-        return apply_filters( 'wpinv_item_get_vat_rule', $rule_type, $postID );
1357
+        return apply_filters('wpinv_item_get_vat_rule', $rule_type, $postID);
1358 1358
     }
1359 1359
     
1360
-    public static function item_rule_label( $postID ) {
1360
+    public static function item_rule_label($postID) {
1361 1361
         $vat_rules  = self::get_rules();
1362
-        $vat_rule   = self::get_item_rule( $postID );
1363
-        $vat_rule   = isset( $vat_rules[$vat_rule] ) ? $vat_rules[$vat_rule] : $vat_rule;
1362
+        $vat_rule   = self::get_item_rule($postID);
1363
+        $vat_rule   = isset($vat_rules[$vat_rule]) ? $vat_rules[$vat_rule] : $vat_rule;
1364 1364
         
1365
-        return apply_filters( 'wpinv_item_rule_label', $vat_rule, $postID );
1365
+        return apply_filters('wpinv_item_rule_label', $vat_rule, $postID);
1366 1366
     }
1367 1367
     
1368
-    public static function item_has_digital_rule( $item_id = 0 ) {        
1369
-        return self::get_item_rule( $item_id ) == 'digital' ? true : false;
1368
+    public static function item_has_digital_rule($item_id = 0) {        
1369
+        return self::get_item_rule($item_id) == 'digital' ? true : false;
1370 1370
     }
1371 1371
     
1372
-    public static function invoice_has_digital_rule( $invoice = 0 ) {        
1373
-        if ( !self::allow_vat_rules() ) {
1372
+    public static function invoice_has_digital_rule($invoice = 0) {        
1373
+        if (!self::allow_vat_rules()) {
1374 1374
             return false;
1375 1375
         }
1376 1376
         
1377
-        if ( empty( $invoice ) ) {
1377
+        if (empty($invoice)) {
1378 1378
             return true;
1379 1379
         }
1380 1380
         
1381
-        if ( is_int( $invoice ) ) {
1382
-            $invoice = new WPInv_Invoice( $invoice );
1381
+        if (is_int($invoice)) {
1382
+            $invoice = new WPInv_Invoice($invoice);
1383 1383
         }
1384 1384
         
1385
-        if ( !( is_object( $invoice ) && is_a( $invoice, 'WPInv_Invoice' ) ) ) {
1385
+        if (!(is_object($invoice) && is_a($invoice, 'WPInv_Invoice'))) {
1386 1386
             return true;
1387 1387
         }
1388 1388
         
1389
-        $cart_items  = $invoice->get_cart_details();
1389
+        $cart_items = $invoice->get_cart_details();
1390 1390
         
1391
-        if ( !empty( $cart_items ) ) {
1391
+        if (!empty($cart_items)) {
1392 1392
             $has_digital_rule = false;
1393 1393
             
1394
-            foreach ( $cart_items as $key => $item ) {
1395
-                if ( self::item_has_digital_rule( $item['id'] ) ) {
1394
+            foreach ($cart_items as $key => $item) {
1395
+                if (self::item_has_digital_rule($item['id'])) {
1396 1396
                     $has_digital_rule = true;
1397 1397
                     break;
1398 1398
                 }
@@ -1404,67 +1404,67 @@  discard block
 block discarded – undo
1404 1404
         return $has_digital_rule;
1405 1405
     }
1406 1406
     
1407
-    public static function item_is_taxable( $item_id = 0, $country = false, $state = false ) {        
1408
-        if ( !wpinv_use_taxes() ) {
1407
+    public static function item_is_taxable($item_id = 0, $country = false, $state = false) {        
1408
+        if (!wpinv_use_taxes()) {
1409 1409
             return false;
1410 1410
         }
1411 1411
         
1412 1412
         $is_taxable = true;
1413 1413
 
1414
-        if ( !empty( $item_id ) && self::get_item_class( $item_id ) == '_exempt' ) {
1414
+        if (!empty($item_id) && self::get_item_class($item_id) == '_exempt') {
1415 1415
             $is_taxable = false;
1416 1416
         }
1417 1417
         
1418
-        return apply_filters( 'wpinv_item_is_taxable', $is_taxable, $item_id, $country , $state );
1418
+        return apply_filters('wpinv_item_is_taxable', $is_taxable, $item_id, $country, $state);
1419 1419
     }
1420 1420
     
1421
-    public static function find_rate( $country, $state, $rate, $class ) {
1421
+    public static function find_rate($country, $state, $rate, $class) {
1422 1422
         global $wpi_zero_tax;
1423 1423
 
1424
-        if ( $class === '_exempt' || $wpi_zero_tax ) {
1424
+        if ($class === '_exempt' || $wpi_zero_tax) {
1425 1425
             return 0;
1426 1426
         }
1427 1427
 
1428
-        $tax_rates   = wpinv_get_tax_rates();
1428
+        $tax_rates = wpinv_get_tax_rates();
1429 1429
         
1430
-        if ( $class !== '_standard' ) {
1431
-            $class_rates = self::get_vat_rates( $class );
1430
+        if ($class !== '_standard') {
1431
+            $class_rates = self::get_vat_rates($class);
1432 1432
             
1433
-            if ( is_array( $class_rates ) ) {
1433
+            if (is_array($class_rates)) {
1434 1434
                 $indexed_class_rates = array();
1435 1435
                 
1436
-                foreach ( $class_rates as $key => $cr ) {
1436
+                foreach ($class_rates as $key => $cr) {
1437 1437
                     $indexed_class_rates[$cr['country']] = $cr;
1438 1438
                 }
1439 1439
 
1440
-                $tax_rates = array_map( function( $tr ) use( $indexed_class_rates ) {
1440
+                $tax_rates = array_map(function($tr) use($indexed_class_rates) {
1441 1441
                     $tr_country = $tr['country'];
1442
-                    if ( !isset( $indexed_class_rates[$tr_country] ) ) {
1442
+                    if (!isset($indexed_class_rates[$tr_country])) {
1443 1443
                         return $tr;
1444 1444
                     }
1445 1445
                     $icr = $indexed_class_rates[$tr_country];
1446
-                    return ( empty( $icr['rate'] ) && $icr['rate'] !== '0' ) ? $tr : $icr;
1446
+                    return (empty($icr['rate']) && $icr['rate'] !== '0') ? $tr : $icr;
1447 1447
 
1448
-                }, $tax_rates, $class_rates );
1448
+                }, $tax_rates, $class_rates);
1449 1449
             }
1450 1450
         }
1451 1451
 
1452
-        if ( !empty( $tax_rates ) ) {
1453
-            foreach ( $tax_rates as $key => $tax_rate ) {
1454
-                if ( $country != $tax_rate['country'] )
1452
+        if (!empty($tax_rates)) {
1453
+            foreach ($tax_rates as $key => $tax_rate) {
1454
+                if ($country != $tax_rate['country'])
1455 1455
                     continue;
1456 1456
 
1457
-                if ( !empty( $tax_rate['global'] ) ) {
1458
-                    if ( 0 !== $tax_rate['rate'] || !empty( $tax_rate['rate'] ) ) {
1459
-                        $rate = number_format( $tax_rate['rate'], 4 );
1457
+                if (!empty($tax_rate['global'])) {
1458
+                    if (0 !== $tax_rate['rate'] || !empty($tax_rate['rate'])) {
1459
+                        $rate = number_format($tax_rate['rate'], 4);
1460 1460
                     }
1461 1461
                 } else {
1462
-                    if ( empty( $tax_rate['state'] ) || strtolower( $state ) != strtolower( $tax_rate['state'] ) )
1462
+                    if (empty($tax_rate['state']) || strtolower($state) != strtolower($tax_rate['state']))
1463 1463
                         continue;
1464 1464
 
1465 1465
                     $state_rate = $tax_rate['rate'];
1466
-                    if ( 0 !== $state_rate || !empty( $state_rate ) ) {
1467
-                        $rate = number_format( $state_rate, 4 );
1466
+                    if (0 !== $state_rate || !empty($state_rate)) {
1467
+                        $rate = number_format($state_rate, 4);
1468 1468
                     }
1469 1469
                 }
1470 1470
             }
@@ -1473,84 +1473,84 @@  discard block
 block discarded – undo
1473 1473
         return $rate;
1474 1474
     }
1475 1475
     
1476
-    public static function get_rate( $rate = 1, $country = '', $state = '', $item_id = 0 ) {
1476
+    public static function get_rate($rate = 1, $country = '', $state = '', $item_id = 0) {
1477 1477
         global $wpinv_options, $wpi_session, $wpi_item_id, $wpi_zero_tax;
1478 1478
         
1479 1479
         $item_id = $item_id > 0 ? $item_id : $wpi_item_id;
1480 1480
         $allow_vat_classes = self::allow_vat_classes();
1481
-        $class = $item_id ? self::get_item_class( $item_id ) : '_standard';
1481
+        $class = $item_id ? self::get_item_class($item_id) : '_standard';
1482 1482
 
1483
-        if ( $class === '_exempt' || $wpi_zero_tax ) {
1483
+        if ($class === '_exempt' || $wpi_zero_tax) {
1484 1484
             return 0;
1485
-        } else if ( !$allow_vat_classes ) {
1485
+        } else if (!$allow_vat_classes) {
1486 1486
             $class = '_standard';
1487 1487
         }
1488 1488
 
1489
-        if( !empty( $_POST['wpinv_country'] ) ) {
1489
+        if (!empty($_POST['wpinv_country'])) {
1490 1490
             $post_country = $_POST['wpinv_country'];
1491
-        } elseif( !empty( $_POST['wpinv_country'] ) ) {
1491
+        } elseif (!empty($_POST['wpinv_country'])) {
1492 1492
             $post_country = $_POST['wpinv_country'];
1493
-        } elseif( !empty( $_POST['country'] ) ) {
1493
+        } elseif (!empty($_POST['country'])) {
1494 1494
             $post_country = $_POST['country'];
1495 1495
         } else {
1496 1496
             $post_country = '';
1497 1497
         }
1498 1498
 
1499
-        $country        = !empty( $post_country ) ? $post_country : wpinv_default_billing_country( $country );
1500
-        $base_country   = wpinv_is_base_country( $country );
1499
+        $country        = !empty($post_country) ? $post_country : wpinv_default_billing_country($country);
1500
+        $base_country   = wpinv_is_base_country($country);
1501 1501
         
1502
-        $requires_vat   = self::requires_vat( 0, false );
1503
-        $is_digital     = self::get_item_rule( $item_id ) == 'digital' ;
1504
-        $rate           = $requires_vat && isset( $wpinv_options['eu_fallback_rate'] ) ? $wpinv_options['eu_fallback_rate'] : $rate;
1502
+        $requires_vat   = self::requires_vat(0, false);
1503
+        $is_digital     = self::get_item_rule($item_id) == 'digital';
1504
+        $rate           = $requires_vat && isset($wpinv_options['eu_fallback_rate']) ? $wpinv_options['eu_fallback_rate'] : $rate;
1505 1505
           
1506
-        if ( self::same_country_rule() == 'no' && $base_country ) { // Disable VAT to same country
1506
+        if (self::same_country_rule() == 'no' && $base_country) { // Disable VAT to same country
1507 1507
             $rate = 0;
1508
-        } else if ( $requires_vat ) {
1509
-            $vat_number = self::get_user_vat_number( '', 0, true );
1508
+        } else if ($requires_vat) {
1509
+            $vat_number = self::get_user_vat_number('', 0, true);
1510 1510
             $vat_info   = self::current_vat_data();
1511 1511
             
1512
-            if ( is_array( $vat_info ) ) {
1513
-                $vat_number = isset( $vat_info['number'] ) && !empty( $vat_info['valid'] ) ? $vat_info['number'] : "";
1512
+            if (is_array($vat_info)) {
1513
+                $vat_number = isset($vat_info['number']) && !empty($vat_info['valid']) ? $vat_info['number'] : "";
1514 1514
             }
1515 1515
             
1516
-            if ( $country == 'UK' ) {
1516
+            if ($country == 'UK') {
1517 1517
                 $country = 'GB';
1518 1518
             }
1519 1519
 
1520
-            if ( !empty( $vat_number ) ) {
1520
+            if (!empty($vat_number)) {
1521 1521
                 $rate = 0;
1522 1522
             } else {
1523
-                $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
1523
+                $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
1524 1524
             }
1525 1525
 
1526
-            if ( empty( $vat_number ) && !$is_digital ) {
1527
-                if ( $base_country ) {
1528
-                    $rate = self::find_rate( $country, null, $rate, $class );
1526
+            if (empty($vat_number) && !$is_digital) {
1527
+                if ($base_country) {
1528
+                    $rate = self::find_rate($country, null, $rate, $class);
1529 1529
                 } else {
1530
-                    if ( empty( $country ) && isset( $wpinv_options['eu_fallback_rate'] ) ) {
1530
+                    if (empty($country) && isset($wpinv_options['eu_fallback_rate'])) {
1531 1531
                         $rate = $wpinv_options['eu_fallback_rate'];
1532
-                    } else if( !empty( $country ) ) {
1533
-                        $rate = self::find_rate( $country, $state, $rate, $class );
1532
+                    } else if (!empty($country)) {
1533
+                        $rate = self::find_rate($country, $state, $rate, $class);
1534 1534
                     }
1535 1535
                 }
1536
-            } else if ( empty( $vat_number ) || ( self::same_country_rule() == 'always' && $base_country ) ) {
1537
-                if ( empty( $country ) && isset( $wpinv_options['eu_fallback_rate'] ) ) {
1536
+            } else if (empty($vat_number) || (self::same_country_rule() == 'always' && $base_country)) {
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 1543
         } else {
1544
-            if ( $is_digital ) {
1544
+            if ($is_digital) {
1545 1545
                 $ip_country_code = self::get_country_by_ip();
1546 1546
                 
1547
-                if ( $ip_country_code && self::is_eu_state( $ip_country_code ) ) {
1548
-                    $rate = self::find_rate( $ip_country_code, '', 0, $class );
1547
+                if ($ip_country_code && self::is_eu_state($ip_country_code)) {
1548
+                    $rate = self::find_rate($ip_country_code, '', 0, $class);
1549 1549
                 } else {
1550
-                    $rate = self::find_rate( $country, $state, $rate, $class );
1550
+                    $rate = self::find_rate($country, $state, $rate, $class);
1551 1551
                 }
1552 1552
             } else {
1553
-                $rate = self::find_rate( $country, $state, $rate, $class );
1553
+                $rate = self::find_rate($country, $state, $rate, $class);
1554 1554
             }
1555 1555
         }
1556 1556
 
@@ -1560,48 +1560,48 @@  discard block
 block discarded – undo
1560 1560
     public static function current_vat_data() {
1561 1561
         global $wpi_session;
1562 1562
         
1563
-        return $wpi_session->get( 'user_vat_data' );
1563
+        return $wpi_session->get('user_vat_data');
1564 1564
     }
1565 1565
     
1566
-    public static function get_user_country( $country = '', $user_id = 0 ) {
1567
-        $user_address = wpinv_get_user_address( $user_id, false );
1566
+    public static function get_user_country($country = '', $user_id = 0) {
1567
+        $user_address = wpinv_get_user_address($user_id, false);
1568 1568
         
1569
-        if ( wpinv_get_option( 'vat_ip_country_default' ) ) {
1569
+        if (wpinv_get_option('vat_ip_country_default')) {
1570 1570
             $country = '';
1571 1571
         }
1572 1572
         
1573
-        $country    = empty( $user_address ) || !isset( $user_address['country'] ) || empty( $user_address['country'] ) ? $country : $user_address['country'];
1574
-        $result     = apply_filters( 'wpinv_get_user_country', $country, $user_id );
1573
+        $country    = empty($user_address) || !isset($user_address['country']) || empty($user_address['country']) ? $country : $user_address['country'];
1574
+        $result     = apply_filters('wpinv_get_user_country', $country, $user_id);
1575 1575
 
1576
-        if ( empty( $result ) ) {
1576
+        if (empty($result)) {
1577 1577
             $result = self::get_country_by_ip();
1578 1578
         }
1579 1579
 
1580 1580
         return $result;
1581 1581
     }
1582 1582
     
1583
-    public static function set_user_country( $country = '', $user_id = 0 ) {
1583
+    public static function set_user_country($country = '', $user_id = 0) {
1584 1584
         global $wpi_userID;
1585 1585
         
1586
-        if ( empty($country) && !empty($wpi_userID) && get_current_user_id() != $wpi_userID ) {
1586
+        if (empty($country) && !empty($wpi_userID) && get_current_user_id() != $wpi_userID) {
1587 1587
             $country = wpinv_get_default_country();
1588 1588
         }
1589 1589
         
1590 1590
         return $country;
1591 1591
     }
1592 1592
     
1593
-    public static function get_user_vat_number( $vat_number = '', $user_id = 0, $is_valid = false ) {
1593
+    public static function get_user_vat_number($vat_number = '', $user_id = 0, $is_valid = false) {
1594 1594
         global $wpi_current_id, $wpi_userID;
1595 1595
         
1596
-        if ( !empty( $_POST['new_user'] ) ) {
1596
+        if (!empty($_POST['new_user'])) {
1597 1597
             return '';
1598 1598
         }
1599 1599
         
1600
-        if ( empty( $user_id ) ) {
1601
-            $user_id = !empty( $wpi_userID ) ? $wpi_userID : ( $wpi_current_id ? wpinv_get_user_id( $wpi_current_id ) : get_current_user_id() );
1600
+        if (empty($user_id)) {
1601
+            $user_id = !empty($wpi_userID) ? $wpi_userID : ($wpi_current_id ? wpinv_get_user_id($wpi_current_id) : get_current_user_id());
1602 1602
         }
1603 1603
 
1604
-        $vat_number = empty( $user_id ) ? '' : get_user_meta( $user_id, '_wpinv_vat_number', true );
1604
+        $vat_number = empty($user_id) ? '' : get_user_meta($user_id, '_wpinv_vat_number', true);
1605 1605
         
1606 1606
         /* TODO
1607 1607
         if ( $is_valid && $vat_number ) {
@@ -1612,36 +1612,36 @@  discard block
 block discarded – undo
1612 1612
         }
1613 1613
         */
1614 1614
 
1615
-        return apply_filters('wpinv_get_user_vat_number', $vat_number, $user_id, $is_valid );
1615
+        return apply_filters('wpinv_get_user_vat_number', $vat_number, $user_id, $is_valid);
1616 1616
     }
1617 1617
     
1618
-    public static function get_user_company( $company = '', $user_id = 0 ) {
1619
-        if ( empty( $user_id ) ) {
1618
+    public static function get_user_company($company = '', $user_id = 0) {
1619
+        if (empty($user_id)) {
1620 1620
             $user_id = get_current_user_id();
1621 1621
         }
1622 1622
 
1623
-        $company = empty( $user_id ) ? "" : get_user_meta( $user_id, '_wpinv_company', true );
1623
+        $company = empty($user_id) ? "" : get_user_meta($user_id, '_wpinv_company', true);
1624 1624
 
1625
-        return apply_filters( 'wpinv_user_company', $company, $user_id );
1625
+        return apply_filters('wpinv_user_company', $company, $user_id);
1626 1626
     }
1627 1627
     
1628
-    public static function save_user_vat_details( $company = '', $vat_number = '' ) {
1629
-        $save = apply_filters( 'wpinv_allow_save_user_vat_details', true );
1628
+    public static function save_user_vat_details($company = '', $vat_number = '') {
1629
+        $save = apply_filters('wpinv_allow_save_user_vat_details', true);
1630 1630
 
1631
-        if ( is_user_logged_in() && $save ) {
1631
+        if (is_user_logged_in() && $save) {
1632 1632
             $user_id = get_current_user_id();
1633 1633
 
1634
-            if ( !empty( $vat_number ) ) {
1635
-                update_user_meta( $user_id, '_wpinv_vat_number', $vat_number );
1634
+            if (!empty($vat_number)) {
1635
+                update_user_meta($user_id, '_wpinv_vat_number', $vat_number);
1636 1636
             } else {
1637
-                delete_user_meta( $user_id, '_wpinv_vat_number');
1637
+                delete_user_meta($user_id, '_wpinv_vat_number');
1638 1638
             }
1639 1639
 
1640
-            if ( !empty( $company ) ) {
1641
-                update_user_meta( $user_id, '_wpinv_company', $company );
1640
+            if (!empty($company)) {
1641
+                update_user_meta($user_id, '_wpinv_company', $company);
1642 1642
             } else {
1643
-                delete_user_meta( $user_id, '_wpinv_company');
1644
-                delete_user_meta( $user_id, '_wpinv_vat_number');
1643
+                delete_user_meta($user_id, '_wpinv_company');
1644
+                delete_user_meta($user_id, '_wpinv_vat_number');
1645 1645
             }
1646 1646
         }
1647 1647
 
@@ -1651,113 +1651,113 @@  discard block
 block discarded – undo
1651 1651
     public static function ajax_vat_validate() {
1652 1652
         global $wpinv_options, $wpi_session;
1653 1653
         
1654
-        $is_checkout            = ( !empty( $_POST['source'] ) && $_POST['source'] == 'checkout' ) ? true : false;
1654
+        $is_checkout            = (!empty($_POST['source']) && $_POST['source'] == 'checkout') ? true : false;
1655 1655
         $response               = array();
1656 1656
         $response['success']    = false;
1657 1657
         
1658
-        if ( empty( $_REQUEST['_wpi_nonce'] ) || ( !empty( $_REQUEST['_wpi_nonce'] ) && !wp_verify_nonce( $_REQUEST['_wpi_nonce'], 'vat_validation' ) ) ) {
1659
-            $response['error'] = __( 'Invalid security nonce', 'invoicing' );
1660
-            wp_send_json( $response );
1658
+        if (empty($_REQUEST['_wpi_nonce']) || (!empty($_REQUEST['_wpi_nonce']) && !wp_verify_nonce($_REQUEST['_wpi_nonce'], 'vat_validation'))) {
1659
+            $response['error'] = __('Invalid security nonce', 'invoicing');
1660
+            wp_send_json($response);
1661 1661
         }
1662 1662
         
1663
-        $vat_name   = self::get_vat_name();
1663
+        $vat_name = self::get_vat_name();
1664 1664
         
1665
-        if ( $is_checkout ) {
1665
+        if ($is_checkout) {
1666 1666
             $invoice = wpinv_get_invoice_cart();
1667 1667
             
1668
-            if ( !self::requires_vat( false, 0, self::invoice_has_digital_rule( $invoice ) ) ) {
1668
+            if (!self::requires_vat(false, 0, self::invoice_has_digital_rule($invoice))) {
1669 1669
                 $vat_info = array();
1670
-                $wpi_session->set( 'user_vat_data', $vat_info );
1670
+                $wpi_session->set('user_vat_data', $vat_info);
1671 1671
 
1672 1672
                 self::save_user_vat_details();
1673 1673
                 
1674 1674
                 $response['success'] = true;
1675
-                $response['message'] = wp_sprintf( __( 'Ignore %s', 'invoicing' ), $vat_name );
1676
-                wp_send_json( $response );
1675
+                $response['message'] = wp_sprintf(__('Ignore %s', 'invoicing'), $vat_name);
1676
+                wp_send_json($response);
1677 1677
             }
1678 1678
         }
1679 1679
         
1680
-        $company    = !empty( $_POST['company'] ) ? sanitize_text_field( $_POST['company'] ) : '';
1681
-        $vat_number = !empty( $_POST['number'] ) ? sanitize_text_field( $_POST['number'] ) : '';
1680
+        $company    = !empty($_POST['company']) ? sanitize_text_field($_POST['company']) : '';
1681
+        $vat_number = !empty($_POST['number']) ? sanitize_text_field($_POST['number']) : '';
1682 1682
         
1683
-        $vat_info = $wpi_session->get( 'user_vat_data' );
1684
-        if ( !is_array( $vat_info ) || empty( $vat_info ) ) {
1685
-            $vat_info = array( 'company'=> $company, 'number' => '', 'valid' => true );
1683
+        $vat_info = $wpi_session->get('user_vat_data');
1684
+        if (!is_array($vat_info) || empty($vat_info)) {
1685
+            $vat_info = array('company'=> $company, 'number' => '', 'valid' => true);
1686 1686
         }
1687 1687
         
1688
-        if ( empty( $vat_number ) ) {
1689
-            if ( $is_checkout ) {
1688
+        if (empty($vat_number)) {
1689
+            if ($is_checkout) {
1690 1690
                 $response['success'] = true;
1691
-                $response['message'] = wp_sprintf( __( 'No %s number has been applied. %s will be added to invoice totals', 'invoicing' ), $vat_name, $vat_name );
1691
+                $response['message'] = wp_sprintf(__('No %s number has been applied. %s will be added to invoice totals', 'invoicing'), $vat_name, $vat_name);
1692 1692
                 
1693
-                $vat_info = $wpi_session->get( 'user_vat_data' );
1693
+                $vat_info = $wpi_session->get('user_vat_data');
1694 1694
                 $vat_info['number'] = "";
1695 1695
                 $vat_info['valid'] = true;
1696 1696
                 
1697
-                self::save_user_vat_details( $company );
1697
+                self::save_user_vat_details($company);
1698 1698
             } else {
1699
-                $response['error'] = wp_sprintf( __( 'Please enter your %s number!', 'invoicing' ), $vat_name );
1699
+                $response['error'] = wp_sprintf(__('Please enter your %s number!', 'invoicing'), $vat_name);
1700 1700
                 
1701 1701
                 $vat_info['valid'] = false;
1702 1702
             }
1703 1703
 
1704
-            $wpi_session->set( 'user_vat_data', $vat_info );
1705
-            wp_send_json( $response );
1704
+            $wpi_session->set('user_vat_data', $vat_info);
1705
+            wp_send_json($response);
1706 1706
         }
1707 1707
         
1708
-        if ( empty( $company ) ) {
1708
+        if (empty($company)) {
1709 1709
             $vat_info['valid'] = false;
1710
-            $wpi_session->set( 'user_vat_data', $vat_info );
1710
+            $wpi_session->set('user_vat_data', $vat_info);
1711 1711
             
1712
-            $response['error'] = __( 'Please enter your registered company name!', 'invoicing' );
1713
-            wp_send_json( $response );
1712
+            $response['error'] = __('Please enter your registered company name!', 'invoicing');
1713
+            wp_send_json($response);
1714 1714
         }
1715 1715
         
1716
-        if ( !empty( $wpinv_options['vat_vies_check'] ) ) {
1717
-            if ( empty( $wpinv_options['vat_offline_check'] ) && !self::offline_check( $vat_number ) ) {
1716
+        if (!empty($wpinv_options['vat_vies_check'])) {
1717
+            if (empty($wpinv_options['vat_offline_check']) && !self::offline_check($vat_number)) {
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'] = wp_sprintf( __( '%s number not validated', 'invoicing' ), $vat_name );
1722
-                wp_send_json( $response );
1721
+                $response['error'] = wp_sprintf(__('%s number not validated', 'invoicing'), $vat_name);
1722
+                wp_send_json($response);
1723 1723
             }
1724 1724
             
1725 1725
             $response['success'] = true;
1726
-            $response['message'] = wp_sprintf( __( '%s number validated', 'invoicing' ), $vat_name );
1726
+            $response['message'] = wp_sprintf(__('%s number validated', 'invoicing'), $vat_name);
1727 1727
         } else {
1728
-            $result = self::check_vat( $vat_number );
1728
+            $result = self::check_vat($vat_number);
1729 1729
             
1730
-            if ( empty( $result['valid'] ) ) {
1730
+            if (empty($result['valid'])) {
1731 1731
                 $response['error'] = $result['message'];
1732
-                wp_send_json( $response );
1732
+                wp_send_json($response);
1733 1733
             }
1734 1734
             
1735
-            $vies_company = !empty( $result['company'] ) ? $result['company'] : '';
1736
-            $vies_company = apply_filters( 'wpinv_vies_company_name', $vies_company );
1735
+            $vies_company = !empty($result['company']) ? $result['company'] : '';
1736
+            $vies_company = apply_filters('wpinv_vies_company_name', $vies_company);
1737 1737
             
1738
-            $valid_company = $vies_company && $company && ( $vies_company == '---' || strcasecmp( trim( $vies_company ), trim( $company ) ) == 0 ) ? true : false;
1738
+            $valid_company = $vies_company && $company && ($vies_company == '---' || strcasecmp(trim($vies_company), trim($company)) == 0) ? true : false;
1739 1739
 
1740
-            if ( !empty( $wpinv_options['vat_disable_company_name_check'] ) || $valid_company ) {
1740
+            if (!empty($wpinv_options['vat_disable_company_name_check']) || $valid_company) {
1741 1741
                 $response['success'] = true;
1742
-                $response['message'] = wp_sprintf( __( '%s number validated', 'invoicing' ), $vat_name );
1742
+                $response['message'] = wp_sprintf(__('%s number validated', 'invoicing'), $vat_name);
1743 1743
             } else {           
1744 1744
                 $vat_info['valid'] = false;
1745
-                $wpi_session->set( 'user_vat_data', $vat_info );
1745
+                $wpi_session->set('user_vat_data', $vat_info);
1746 1746
                 
1747 1747
                 $response['success'] = false;
1748
-                $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 );
1749
-                wp_send_json( $response );
1748
+                $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);
1749
+                wp_send_json($response);
1750 1750
             }
1751 1751
         }
1752 1752
         
1753
-        if ( $is_checkout ) {
1754
-            self::save_user_vat_details( $company, $vat_number );
1753
+        if ($is_checkout) {
1754
+            self::save_user_vat_details($company, $vat_number);
1755 1755
 
1756
-            $vat_info = array('company' => $company, 'number' => $vat_number, 'valid' => true );
1757
-            $wpi_session->set( 'user_vat_data', $vat_info );
1756
+            $vat_info = array('company' => $company, 'number' => $vat_number, 'valid' => true);
1757
+            $wpi_session->set('user_vat_data', $vat_info);
1758 1758
         }
1759 1759
 
1760
-        wp_send_json( $response );
1760
+        wp_send_json($response);
1761 1761
     }
1762 1762
     
1763 1763
     public static function ajax_vat_reset() {
@@ -1766,161 +1766,161 @@  discard block
 block discarded – undo
1766 1766
         $company    = is_user_logged_in() ? self::get_user_company() : '';
1767 1767
         $vat_number = self::get_user_vat_number();
1768 1768
         
1769
-        $vat_info   = array('company' => $company, 'number' => $vat_number, 'valid' => false );
1770
-        $wpi_session->set( 'user_vat_data', $vat_info );
1769
+        $vat_info   = array('company' => $company, 'number' => $vat_number, 'valid' => false);
1770
+        $wpi_session->set('user_vat_data', $vat_info);
1771 1771
         
1772 1772
         $response                       = array();
1773 1773
         $response['success']            = true;
1774 1774
         $response['data']['company']    = $company;
1775 1775
         $response['data']['number']     = $vat_number;
1776 1776
         
1777
-        wp_send_json( $response );
1777
+        wp_send_json($response);
1778 1778
     }
1779 1779
     
1780
-    public static function checkout_vat_validate( $valid_data, $post ) {
1780
+    public static function checkout_vat_validate($valid_data, $post) {
1781 1781
         global $wpinv_options, $wpi_session;
1782 1782
         
1783
-        $vat_name  = __( self::get_vat_name(), 'invoicing' );
1783
+        $vat_name = __(self::get_vat_name(), 'invoicing');
1784 1784
         
1785
-        if ( !isset( $_POST['_wpi_nonce'] ) || !wp_verify_nonce( $_POST['_wpi_nonce'], 'vat_validation' ) ) {
1786
-            wpinv_set_error( 'vat_validation', wp_sprintf( __( "Invalid %s validation request.", 'invoicing' ), $vat_name ) );
1785
+        if (!isset($_POST['_wpi_nonce']) || !wp_verify_nonce($_POST['_wpi_nonce'], 'vat_validation')) {
1786
+            wpinv_set_error('vat_validation', wp_sprintf(__("Invalid %s validation request.", 'invoicing'), $vat_name));
1787 1787
             return;
1788 1788
         }
1789 1789
         
1790
-        $vat_saved = $wpi_session->get( 'user_vat_data' );
1791
-        $wpi_session->set( 'user_vat_data', null );
1790
+        $vat_saved = $wpi_session->get('user_vat_data');
1791
+        $wpi_session->set('user_vat_data', null);
1792 1792
         
1793 1793
         $invoice        = wpinv_get_invoice_cart();
1794 1794
         $amount         = $invoice->get_total();
1795
-        $is_digital     = self::invoice_has_digital_rule( $invoice );
1796
-        $no_vat         = !self::requires_vat( 0, false, $is_digital );
1795
+        $is_digital     = self::invoice_has_digital_rule($invoice);
1796
+        $no_vat         = !self::requires_vat(0, false, $is_digital);
1797 1797
         
1798
-        $company        = !empty( $_POST['wpinv_company'] ) ? $_POST['wpinv_company'] : null;
1799
-        $vat_number     = !empty( $_POST['wpinv_vat_number'] ) ? $_POST['wpinv_vat_number'] : null;
1800
-        $country        = !empty( $_POST['wpinv_country'] ) ? $_POST['wpinv_country'] : $invoice->country;
1801
-        if ( empty( $country ) ) {
1798
+        $company        = !empty($_POST['wpinv_company']) ? $_POST['wpinv_company'] : null;
1799
+        $vat_number     = !empty($_POST['wpinv_vat_number']) ? $_POST['wpinv_vat_number'] : null;
1800
+        $country        = !empty($_POST['wpinv_country']) ? $_POST['wpinv_country'] : $invoice->country;
1801
+        if (empty($country)) {
1802 1802
             $country = wpinv_default_billing_country();
1803 1803
         }
1804 1804
         
1805
-        if ( !$is_digital && $no_vat ) {
1805
+        if (!$is_digital && $no_vat) {
1806 1806
             return;
1807 1807
         }
1808 1808
             
1809
-        $vat_data           = array( 'company' => '', 'number' => '', 'valid' => false );
1809
+        $vat_data           = array('company' => '', 'number' => '', 'valid' => false);
1810 1810
         
1811 1811
         $ip_country_code    = self::get_country_by_ip();
1812
-        $is_eu_state        = self::is_eu_state( $country );
1813
-        $is_eu_state_ip     = self::is_eu_state( $ip_country_code );
1812
+        $is_eu_state        = self::is_eu_state($country);
1813
+        $is_eu_state_ip     = self::is_eu_state($ip_country_code);
1814 1814
         $is_non_eu_user     = !$is_eu_state && !$is_eu_state_ip;
1815 1815
         
1816
-        if ( $is_digital && !$is_non_eu_user && empty( $vat_number ) && apply_filters( 'wpinv_checkout_requires_country', true, $amount ) ) {
1816
+        if ($is_digital && !$is_non_eu_user && empty($vat_number) && apply_filters('wpinv_checkout_requires_country', true, $amount)) {
1817 1817
             $vat_data['adddress_confirmed'] = false;
1818 1818
             
1819
-            if ( !isset( $_POST['wpinv_adddress_confirmed'] ) ) {
1820
-                if ( $ip_country_code != $country ) {
1821
-                    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>' ) );
1819
+            if (!isset($_POST['wpinv_adddress_confirmed'])) {
1820
+                if ($ip_country_code != $country) {
1821
+                    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>'));
1822 1822
                 }
1823 1823
             } else {
1824 1824
                 $vat_data['adddress_confirmed'] = true;
1825 1825
             }
1826 1826
         }
1827 1827
         
1828
-        if ( !empty( $wpinv_options['vat_prevent_b2c_purchase'] ) && !$is_non_eu_user && ( empty( $vat_number ) || $no_vat ) ) {
1829
-            if ( $is_eu_state ) {
1830
-                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 ) );
1831
-            } else if ( $is_digital && $is_eu_state_ip ) {
1832
-                wpinv_set_error( 'vat_validation', wp_sprintf( __( 'Sales to non-EU countries cannot be completed because %s must be applied.', 'invoicing' ), $vat_name ) );
1828
+        if (!empty($wpinv_options['vat_prevent_b2c_purchase']) && !$is_non_eu_user && (empty($vat_number) || $no_vat)) {
1829
+            if ($is_eu_state) {
1830
+                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));
1831
+            } else if ($is_digital && $is_eu_state_ip) {
1832
+                wpinv_set_error('vat_validation', wp_sprintf(__('Sales to non-EU countries cannot be completed because %s must be applied.', 'invoicing'), $vat_name));
1833 1833
             }
1834 1834
         }
1835 1835
         
1836
-        if ( !$is_eu_state || $no_vat || empty( $vat_number ) ) {
1836
+        if (!$is_eu_state || $no_vat || empty($vat_number)) {
1837 1837
             return;
1838 1838
         }
1839 1839
 
1840
-        if ( !empty( $vat_saved ) && isset( $vat_saved['valid'] ) ) {
1841
-            $vat_data['valid']  = $vat_saved['valid'];
1840
+        if (!empty($vat_saved) && isset($vat_saved['valid'])) {
1841
+            $vat_data['valid'] = $vat_saved['valid'];
1842 1842
         }
1843 1843
             
1844
-        if ( $company !== null ) {
1844
+        if ($company !== null) {
1845 1845
             $vat_data['company'] = $company;
1846 1846
         }
1847 1847
 
1848 1848
         $message = '';
1849
-        if ( $vat_number !== null ) {
1849
+        if ($vat_number !== null) {
1850 1850
             $vat_data['number'] = $vat_number;
1851 1851
             
1852
-            if ( !$vat_data['valid'] || ( $vat_saved['number'] !== $vat_data['number'] ) || ( $vat_saved['company'] !== $vat_data['company'] ) ) {
1853
-                if ( !empty( $wpinv_options['vat_vies_check'] ) ) {            
1854
-                    if ( empty( $wpinv_options['vat_offline_check'] ) && !self::offline_check( $vat_number ) ) {
1852
+            if (!$vat_data['valid'] || ($vat_saved['number'] !== $vat_data['number']) || ($vat_saved['company'] !== $vat_data['company'])) {
1853
+                if (!empty($wpinv_options['vat_vies_check'])) {            
1854
+                    if (empty($wpinv_options['vat_offline_check']) && !self::offline_check($vat_number)) {
1855 1855
                         $vat_data['valid'] = false;
1856 1856
                     }
1857 1857
                 } else {
1858
-                    $result = self::check_vat( $vat_number );
1858
+                    $result = self::check_vat($vat_number);
1859 1859
                     
1860
-                    if ( !empty( $result['valid'] ) ) {                
1860
+                    if (!empty($result['valid'])) {                
1861 1861
                         $vat_data['valid'] = true;
1862
-                        $vies_company = !empty( $result['company'] ) ? $result['company'] : '';
1863
-                        $vies_company = apply_filters( 'wpinv_vies_company_name', $vies_company );
1862
+                        $vies_company = !empty($result['company']) ? $result['company'] : '';
1863
+                        $vies_company = apply_filters('wpinv_vies_company_name', $vies_company);
1864 1864
                     
1865
-                        $valid_company = $vies_company && $company && ( $vies_company == '---' || strcasecmp( trim( $vies_company ), trim( $company ) ) == 0 ) ? true : false;
1865
+                        $valid_company = $vies_company && $company && ($vies_company == '---' || strcasecmp(trim($vies_company), trim($company)) == 0) ? true : false;
1866 1866
 
1867
-                        if ( !( !empty( $wpinv_options['vat_disable_company_name_check'] ) || $valid_company ) ) {         
1867
+                        if (!(!empty($wpinv_options['vat_disable_company_name_check']) || $valid_company)) {         
1868 1868
                             $vat_data['valid'] = false;
1869 1869
                             
1870
-                            $message = wp_sprintf( __( 'The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing' ), $vat_name );
1870
+                            $message = wp_sprintf(__('The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing'), $vat_name);
1871 1871
                         }
1872 1872
                     } else {
1873
-                        $message = wp_sprintf( __( 'Fail to validate the %s number: EU Commission VAT server (VIES) check fails.', 'invoicing' ), $vat_name );
1873
+                        $message = wp_sprintf(__('Fail to validate the %s number: EU Commission VAT server (VIES) check fails.', 'invoicing'), $vat_name);
1874 1874
                     }
1875 1875
                 }
1876 1876
                 
1877
-                if ( !$vat_data['valid'] ) {
1878
-                    $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 . ' )' : '' );
1879
-                    wpinv_set_error( 'vat_validation', $error );
1877
+                if (!$vat_data['valid']) {
1878
+                    $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 . ' )' : '');
1879
+                    wpinv_set_error('vat_validation', $error);
1880 1880
                 }
1881 1881
             }
1882 1882
         }
1883 1883
 
1884
-        $wpi_session->set( 'user_vat_data', $vat_data );
1884
+        $wpi_session->set('user_vat_data', $vat_data);
1885 1885
     }
1886 1886
     
1887
-    public static function checkout_vat_fields( $billing_details ) {
1887
+    public static function checkout_vat_fields($billing_details) {
1888 1888
         global $wpi_session, $wpinv_options, $wpi_country, $wpi_requires_vat;
1889 1889
         
1890 1890
         $ip_address         = wpinv_get_ip();
1891 1891
         $ip_country_code    = self::get_country_by_ip();
1892 1892
         
1893
-        $tax_label          = __( self::get_vat_name(), 'invoicing' );
1893
+        $tax_label          = __(self::get_vat_name(), 'invoicing');
1894 1894
         $invoice            = wpinv_get_invoice_cart();
1895
-        $is_digital         = self::invoice_has_digital_rule( $invoice );
1895
+        $is_digital         = self::invoice_has_digital_rule($invoice);
1896 1896
         $wpi_country        = $invoice->country;
1897 1897
         
1898
-        $requires_vat       = !self::hide_vat_fields() && $invoice->get_total() > 0 && self::requires_vat( 0, false, $is_digital );
1898
+        $requires_vat       = !self::hide_vat_fields() && $invoice->get_total() > 0 && self::requires_vat(0, false, $is_digital);
1899 1899
         $wpi_requires_vat   = $requires_vat;
1900 1900
         
1901 1901
         $company            = is_user_logged_in() ? self::get_user_company() : '';
1902 1902
         $vat_number         = self::get_user_vat_number();
1903 1903
         
1904
-        $validated          = $vat_number ? self::get_user_vat_number( '', 0, true ) : 1;
1905
-        $vat_info           = $wpi_session->get( 'user_vat_data' );
1904
+        $validated          = $vat_number ? self::get_user_vat_number('', 0, true) : 1;
1905
+        $vat_info           = $wpi_session->get('user_vat_data');
1906 1906
 
1907
-        if ( is_array( $vat_info ) ) {
1908
-            $company    = isset( $vat_info['company'] ) ? $vat_info['company'] : '';
1909
-            $vat_number = isset( $vat_info['number'] ) ? $vat_info['number'] : '';
1910
-            $validated  = isset( $vat_info['valid'] ) ? $vat_info['valid'] : false;
1907
+        if (is_array($vat_info)) {
1908
+            $company    = isset($vat_info['company']) ? $vat_info['company'] : '';
1909
+            $vat_number = isset($vat_info['number']) ? $vat_info['number'] : '';
1910
+            $validated  = isset($vat_info['valid']) ? $vat_info['valid'] : false;
1911 1911
         }
1912 1912
         
1913 1913
         $selected_country = $invoice->country ? $invoice->country : wpinv_default_billing_country();
1914 1914
 
1915
-        if ( $ip_country_code == 'UK' ) {
1915
+        if ($ip_country_code == 'UK') {
1916 1916
             $ip_country_code = 'GB';
1917 1917
         }
1918 1918
         
1919
-        if ( $selected_country == 'UK' ) {
1919
+        if ($selected_country == 'UK') {
1920 1920
             $selected_country = 'GB';
1921 1921
         }
1922 1922
         
1923
-        if ( $requires_vat && ( self::same_country_rule() == 'no' && wpinv_is_base_country( $selected_country ) || !self::allow_vat_rules() ) ) {
1923
+        if ($requires_vat && (self::same_country_rule() == 'no' && wpinv_is_base_country($selected_country) || !self::allow_vat_rules())) {
1924 1924
             $requires_vat = false;
1925 1925
         }
1926 1926
 
@@ -1928,52 +1928,52 @@  discard block
 block discarded – undo
1928 1928
         $display_validate_btn   = 'none';
1929 1929
         $display_reset_btn      = 'none';
1930 1930
         
1931
-        if ( !empty( $vat_number ) && $validated ) {
1932
-            $vat_vailidated_text    = wp_sprintf( __( '%s number validated', 'invoicing' ), $tax_label );
1931
+        if (!empty($vat_number) && $validated) {
1932
+            $vat_vailidated_text    = wp_sprintf(__('%s number validated', 'invoicing'), $tax_label);
1933 1933
             $vat_vailidated_class   = 'wpinv-vat-stat-1';
1934 1934
             $display_reset_btn      = 'block';
1935 1935
         } else {
1936
-            $vat_vailidated_text    = empty( $vat_number ) ? '' : wp_sprintf( __( '%s number not validated', 'invoicing' ), $tax_label );
1937
-            $vat_vailidated_class   = empty( $vat_number ) ? '' : 'wpinv-vat-stat-0';
1936
+            $vat_vailidated_text    = empty($vat_number) ? '' : wp_sprintf(__('%s number not validated', 'invoicing'), $tax_label);
1937
+            $vat_vailidated_class   = empty($vat_number) ? '' : 'wpinv-vat-stat-0';
1938 1938
             $display_validate_btn   = 'block';
1939 1939
         }
1940 1940
         
1941
-        $show_ip_country        = $is_digital && ( empty( $vat_number ) || !$requires_vat ) && $ip_country_code != $selected_country ? 'block' : 'none';
1941
+        $show_ip_country = $is_digital && (empty($vat_number) || !$requires_vat) && $ip_country_code != $selected_country ? 'block' : 'none';
1942 1942
         ?>
1943 1943
         <div id="wpi-vat-details" class="wpi-vat-details clearfix" style="display:<?php echo $display_vat_details; ?>">
1944 1944
             <div id="wpi_vat_info" class="clearfix panel panel-default">
1945
-                <div class="panel-heading"><h3 class="panel-title"><?php echo wp_sprintf( __( '%s Details', 'invoicing' ), $tax_label );?></h3></div>
1945
+                <div class="panel-heading"><h3 class="panel-title"><?php echo wp_sprintf(__('%s Details', 'invoicing'), $tax_label); ?></h3></div>
1946 1946
                 <div id="wpinv-fields-box" class="panel-body">
1947 1947
                     <p id="wpi_show_vat_note">
1948
-                        <?php echo wp_sprintf( __( 'Validate your registered %s number to exclude tax.', 'invoicing' ), $tax_label ); ?>
1948
+                        <?php echo wp_sprintf(__('Validate your registered %s number to exclude tax.', 'invoicing'), $tax_label); ?>
1949 1949
                     </p>
1950 1950
                     <div id="wpi_vat_fields" class="wpi_vat_info">
1951 1951
                         <p class="wpi-cart-field wpi-col2 wpi-colf">
1952
-                            <label for="wpinv_company" class="wpi-label"><?php _e( 'Company Name', 'invoicing' );?></label>
1952
+                            <label for="wpinv_company" class="wpi-label"><?php _e('Company Name', 'invoicing'); ?></label>
1953 1953
                             <?php
1954
-                            echo wpinv_html_text( array(
1954
+                            echo wpinv_html_text(array(
1955 1955
                                     'id'            => 'wpinv_company',
1956 1956
                                     'name'          => 'wpinv_company',
1957 1957
                                     'value'         => $company,
1958 1958
                                     'class'         => 'wpi-input form-control',
1959
-                                    'placeholder'   => __( 'Company name', 'invoicing' ),
1960
-                                ) );
1959
+                                    'placeholder'   => __('Company name', 'invoicing'),
1960
+                                ));
1961 1961
                             ?>
1962 1962
                         </p>
1963 1963
                         <p class="wpi-cart-field wpi-col2 wpi-coll wpi-cart-field-vat">
1964
-                            <label for="wpinv_vat_number" class="wpi-label"><?php echo wp_sprintf( __( '%s Number', 'invoicing' ), $tax_label );?></label>
1964
+                            <label for="wpinv_vat_number" class="wpi-label"><?php echo wp_sprintf(__('%s Number', 'invoicing'), $tax_label); ?></label>
1965 1965
                             <span id="wpinv_vat_number-wrap">
1966 1966
                                 <label for="wpinv_vat_number" class="wpinv-label"></label>
1967
-                                <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">
1968
-                                <span class="wpinv-vat-stat <?php echo $vat_vailidated_class;?>"><i class="fa"></i>&nbsp;<font><?php echo $vat_vailidated_text;?></font></span>
1967
+                                <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">
1968
+                                <span class="wpinv-vat-stat <?php echo $vat_vailidated_class; ?>"><i class="fa"></i>&nbsp;<font><?php echo $vat_vailidated_text; ?></font></span>
1969 1969
                             </span>
1970 1970
                         </p>
1971 1971
                         <p class="wpi-cart-field wpi-col wpi-colf wpi-cart-field-actions">
1972
-                            <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>
1973
-                            <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>
1972
+                            <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>
1973
+                            <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>
1974 1974
                             <span class="wpi-vat-box wpi-vat-box-info"><span id="text"></span></span>
1975 1975
                             <span class="wpi-vat-box wpi-vat-box-error"><span id="text"></span></span>
1976
-                            <input type="hidden" name="_wpi_nonce" value="<?php echo wp_create_nonce( 'vat_validation' ) ?>" />
1976
+                            <input type="hidden" name="_wpi_nonce" value="<?php echo wp_create_nonce('vat_validation') ?>" />
1977 1977
                         </p>
1978 1978
                     </div>
1979 1979
                 </div>
@@ -1987,32 +1987,32 @@  discard block
 block discarded – undo
1987 1987
                 </span>
1988 1988
             </div>
1989 1989
         </div>
1990
-        <?php if ( empty( $wpinv_options['hide_ip_address'] ) ) { 
1991
-            $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>';
1990
+        <?php if (empty($wpinv_options['hide_ip_address'])) { 
1991
+            $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>';
1992 1992
         ?>
1993 1993
         <div class="wpi-ip-info clearfix panel panel-info">
1994 1994
             <div id="wpinv-fields-box" class="panel-body">
1995
-                <span><?php echo wp_sprintf( __( "Your IP address is: %s", 'invoicing' ), $ip_link ); ?></span>
1995
+                <span><?php echo wp_sprintf(__("Your IP address is: %s", 'invoicing'), $ip_link); ?></span>
1996 1996
             </div>
1997 1997
         </div>
1998 1998
         <?php }
1999 1999
     }
2000 2000
     
2001
-    public static function show_vat_notice( $invoice ) {
2002
-        if ( empty( $invoice ) ) {
2001
+    public static function show_vat_notice($invoice) {
2002
+        if (empty($invoice)) {
2003 2003
             return NULL;
2004 2004
         }
2005 2005
         
2006
-        $label      = wpinv_get_option( 'vat_invoice_notice_label' );
2007
-        $notice     = wpinv_get_option( 'vat_invoice_notice' );
2008
-        if ( $label || $notice ) {
2006
+        $label      = wpinv_get_option('vat_invoice_notice_label');
2007
+        $notice     = wpinv_get_option('vat_invoice_notice');
2008
+        if ($label || $notice) {
2009 2009
         ?>
2010 2010
         <div class="row wpinv-vat-notice">
2011 2011
             <div class="col-sm-12">
2012
-                <?php if ( $label ) { ?>
2013
-                <strong><?php _e( $label, 'invoicing' ); ?></strong>
2014
-                <?php } if ( $notice ) { ?>
2015
-                <?php echo wpautop( wptexturize( __( $notice, 'invoicing' ) ) ) ?>
2012
+                <?php if ($label) { ?>
2013
+                <strong><?php _e($label, 'invoicing'); ?></strong>
2014
+                <?php } if ($notice) { ?>
2015
+                <?php echo wpautop(wptexturize(__($notice, 'invoicing'))) ?>
2016 2016
                 <?php } ?>
2017 2017
             </div>
2018 2018
         </div>
Please login to merge, or discard this patch.
templates/wpinv-invoice-print.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -1,41 +1,41 @@  discard block
 block discarded – undo
1 1
 <?php 
2
-if ( !defined('ABSPATH') ) {
2
+if (!defined('ABSPATH')) {
3 3
     exit;
4 4
 }
5 5
 global $post;
6 6
 $invoice_id = $post->ID;
7
-$invoice = wpinv_get_invoice( $invoice_id );
8
-if ( empty( $invoice ) ) {
7
+$invoice = wpinv_get_invoice($invoice_id);
8
+if (empty($invoice)) {
9 9
     exit;
10 10
 }
11
-$type = $post->post_type == 'wpi_invoice' ? __( 'Invoice', 'invoicing' ): __( 'Quotation', 'invoicing' );
12
-do_action( 'wpinv_invoice_print_before_display', $invoice ); ?><!DOCTYPE html>
11
+$type = $post->post_type == 'wpi_invoice' ? __('Invoice', 'invoicing') : __('Quotation', 'invoicing');
12
+do_action('wpinv_invoice_print_before_display', $invoice); ?><!DOCTYPE html>
13 13
 <html <?php language_attributes(); ?>>
14 14
 <head>
15 15
     <meta charset="UTF-8">
16 16
     <title><?php wp_title() ?></title>
17
-    <meta charset="<?php bloginfo( 'charset' ); ?>" />
17
+    <meta charset="<?php bloginfo('charset'); ?>" />
18 18
     <meta name="viewport" content="width=device-width, initial-scale=1">
19 19
     <meta name="robots" content="noindex,nofollow">
20 20
 
21
-    <?php do_action( 'wpinv_invoice_print_head', $invoice ); ?>
21
+    <?php do_action('wpinv_invoice_print_head', $invoice); ?>
22 22
 </head>
23 23
 <body class="body wpinv wpinv-print">
24
-    <?php do_action( 'wpinv_invoice_print_body_start', $invoice ); ?>
24
+    <?php do_action('wpinv_invoice_print_body_start', $invoice); ?>
25 25
     <div class="container wpinv-wrap">
26
-        <?php if ( $watermark = wpinv_watermark( $invoice_id ) ) { ?>
27
-            <div class="watermark no-print"><p><?php echo esc_html( $watermark ) ?></p></div>
26
+        <?php if ($watermark = wpinv_watermark($invoice_id)) { ?>
27
+            <div class="watermark no-print"><p><?php echo esc_html($watermark) ?></p></div>
28 28
         <?php } ?>
29 29
         <!-- ///// Start PDF header -->
30 30
         <htmlpageheader name="wpinv-pdf-header">
31
-            <?php do_action( 'wpinv_invoice_print_before_header', $invoice ); ?>
31
+            <?php do_action('wpinv_invoice_print_before_header', $invoice); ?>
32 32
             <div class="row wpinv-header">
33 33
                 <div class="col-xs-6 wpinv-business">
34
-                    <a target="_blank" href="<?php echo esc_url( wpinv_get_business_website() ); ?>">
35
-                        <?php if ( $logo = wpinv_get_business_logo() ) { ?>
36
-                        <img class="logo" src="<?php echo esc_url( $logo ); ?>">
34
+                    <a target="_blank" href="<?php echo esc_url(wpinv_get_business_website()); ?>">
35
+                        <?php if ($logo = wpinv_get_business_logo()) { ?>
36
+                        <img class="logo" src="<?php echo esc_url($logo); ?>">
37 37
                         <?php } else { ?>
38
-                        <h1><?php echo esc_html( wpinv_get_business_name() ); ?></h1>
38
+                        <h1><?php echo esc_html(wpinv_get_business_name()); ?></h1>
39 39
                         <?php } ?>
40 40
                     </a>
41 41
                 </div>
@@ -44,56 +44,56 @@  discard block
 block discarded – undo
44 44
                     <h2><?php echo $type; ?></h2>
45 45
                 </div>
46 46
             </div>
47
-            <?php do_action( 'wpinv_invoice_print_after_header', $invoice ); ?>
47
+            <?php do_action('wpinv_invoice_print_after_header', $invoice); ?>
48 48
         </htmlpageheader>
49 49
         <!-- End PDF header ///// -->
50 50
         
51
-        <?php do_action( 'wpinv_invoice_print_before_top_content', $invoice ); ?>
51
+        <?php do_action('wpinv_invoice_print_before_top_content', $invoice); ?>
52 52
         <div class="row wpinv-top-content">
53 53
             <div class="col-xs-12 col-sm-6 wpinv-addresses">
54 54
                 <div class="col-xs-12 wpinv-address wpinv-from-address">
55 55
                     <?php wpinv_display_from_address(); ?>
56 56
                 </div>
57 57
                 <div class="col-xs-12 wpinv-address wpinv-to-address">
58
-                    <?php wpinv_display_to_address( $invoice_id ); ?>
58
+                    <?php wpinv_display_to_address($invoice_id); ?>
59 59
                 </div>
60 60
             </div>
61 61
             <div class="col-xs-12 col-sm-6 wpinv-details">
62 62
                 <div class="col-xs-12 wpinv-line-details">
63
-                    <?php do_action( 'wpinv_invoice_print_before_details', $invoice ); ?>
64
-                    <?php wpinv_display_invoice_details( $invoice ); ?>
65
-                    <?php do_action( 'wpinv_invoice_print_after_details', $invoice ); ?>
63
+                    <?php do_action('wpinv_invoice_print_before_details', $invoice); ?>
64
+                    <?php wpinv_display_invoice_details($invoice); ?>
65
+                    <?php do_action('wpinv_invoice_print_after_details', $invoice); ?>
66 66
                 </div>
67 67
             </div>
68 68
         </div>
69
-        <?php do_action( 'wpinv_invoice_print_after_top_content', $invoice ); ?>
69
+        <?php do_action('wpinv_invoice_print_after_top_content', $invoice); ?>
70 70
 
71
-        <?php do_action( 'wpinv_invoice_print_middle', $invoice ); ?>
71
+        <?php do_action('wpinv_invoice_print_middle', $invoice); ?>
72 72
         
73
-        <?php do_action( 'wpinv_invoice_print_before_line_items', $invoice ); ?>
73
+        <?php do_action('wpinv_invoice_print_before_line_items', $invoice); ?>
74 74
         <div class="row wpinv-items">
75 75
             <div class="col-sm-12 wpinv-line-items">
76
-                <?php wpinv_display_line_items( $invoice_id ); ?>
76
+                <?php wpinv_display_line_items($invoice_id); ?>
77 77
             </div>
78 78
         </div>
79
-        <?php do_action( 'wpinv_invoice_print_after_line_items', $invoice ); ?>
79
+        <?php do_action('wpinv_invoice_print_after_line_items', $invoice); ?>
80 80
         
81 81
         <!-- ///// Start PDF footer -->
82 82
         <htmlpagefooter name="wpinv-pdf-footer">
83
-            <?php do_action( 'wpinv_invoice_print_before_footer', $invoice ); ?>
83
+            <?php do_action('wpinv_invoice_print_before_footer', $invoice); ?>
84 84
             <div class="row wpinv-footer">
85 85
                 <div class="col-sm-12">
86
-                    <?php if ( $term_text = wpinv_get_terms_text() ) { ?>
87
-                    <div class="terms-text"><?php echo wpautop( $term_text ); ?></div>
86
+                    <?php if ($term_text = wpinv_get_terms_text()) { ?>
87
+                    <div class="terms-text"><?php echo wpautop($term_text); ?></div>
88 88
                     <?php } ?>
89 89
                     <div class="footer-text"><?php echo wpinv_get_business_footer(); ?></div>
90
-                    <div class="print-only"><?php _e( 'Page ', 'invoicing' ) ?> {PAGENO}/{nbpg}</div>
90
+                    <div class="print-only"><?php _e('Page ', 'invoicing') ?> {PAGENO}/{nbpg}</div>
91 91
                 </div>
92 92
             </div>
93
-            <?php do_action( 'wpinv_invoice_print_after_footer', $invoice ); ?>
93
+            <?php do_action('wpinv_invoice_print_after_footer', $invoice); ?>
94 94
         </htmlpagefooter>
95 95
         <!-- End PDF footer ///// -->
96 96
     </div><!-- END wpinv-wrap -->
97
-    <?php do_action( 'wpinv_invoice_print_body_end', $invoice ); ?>
97
+    <?php do_action('wpinv_invoice_print_body_end', $invoice); ?>
98 98
 </body>
99 99
 </html>
100 100
\ No newline at end of file
Please login to merge, or discard this patch.
includes/wpinv-post-types.php 1 patch
Spacing   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -7,36 +7,36 @@  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
-add_action( 'init', 'wpinv_register_post_types', 1 );
14
+add_action('init', 'wpinv_register_post_types', 1);
15 15
 function wpinv_register_post_types() {    
16 16
     $labels = array(
17
-        'name'               => _x( 'Invoices', 'post type general name', 'invoicing' ),
18
-        'singular_name'      => _x( 'Invoice', 'post type singular name', 'invoicing' ),
19
-        'menu_name'          => _x( 'Invoices', 'admin menu', 'invoicing' ),
20
-        'name_admin_bar'     => _x( 'Invoice', 'add new on admin bar', 'invoicing' ),
21
-        'add_new'            => _x( 'Add New', 'book', 'invoicing' ),
22
-        'add_new_item'       => __( 'Add New Invoice', 'invoicing' ),
23
-        'new_item'           => __( 'New Invoice', 'invoicing' ),
24
-        'edit_item'          => __( 'Edit Invoice', 'invoicing' ),
25
-        'view_item'          => __( 'View Invoice', 'invoicing' ),
26
-        'all_items'          => __( 'Invoices', 'invoicing' ),
27
-        'search_items'       => __( 'Search Invoices', 'invoicing' ),
28
-        'parent_item_colon'  => __( 'Parent Invoices:', 'invoicing' ),
29
-        'not_found'          => __( 'No invoices found.', 'invoicing' ),
30
-        'not_found_in_trash' => __( 'No invoices found in trash.', 'invoicing' )
17
+        'name'               => _x('Invoices', 'post type general name', 'invoicing'),
18
+        'singular_name'      => _x('Invoice', 'post type singular name', 'invoicing'),
19
+        'menu_name'          => _x('Invoices', 'admin menu', 'invoicing'),
20
+        'name_admin_bar'     => _x('Invoice', 'add new on admin bar', 'invoicing'),
21
+        'add_new'            => _x('Add New', 'book', 'invoicing'),
22
+        'add_new_item'       => __('Add New Invoice', 'invoicing'),
23
+        'new_item'           => __('New Invoice', 'invoicing'),
24
+        'edit_item'          => __('Edit Invoice', 'invoicing'),
25
+        'view_item'          => __('View Invoice', 'invoicing'),
26
+        'all_items'          => __('Invoices', 'invoicing'),
27
+        'search_items'       => __('Search Invoices', 'invoicing'),
28
+        'parent_item_colon'  => __('Parent Invoices:', 'invoicing'),
29
+        'not_found'          => __('No invoices found.', 'invoicing'),
30
+        'not_found_in_trash' => __('No invoices found in trash.', 'invoicing')
31 31
     );
32
-    $labels = apply_filters( 'wpinv_labels', $labels );
32
+    $labels = apply_filters('wpinv_labels', $labels);
33 33
     
34 34
     $menu_icon = WPINV_PLUGIN_URL . '/assets/images/favicon.ico';
35
-    $menu_icon = apply_filters( 'wpinv_menu_icon_invoice', $menu_icon );
35
+    $menu_icon = apply_filters('wpinv_menu_icon_invoice', $menu_icon);
36 36
 
37 37
     $args = array(
38 38
         'labels'             => $labels,
39
-        'description'        => __( 'This is where invoices are stored.', 'invoicing' ),
39
+        'description'        => __('This is where invoices are stored.', 'invoicing'),
40 40
         'public'             => true,
41 41
         'can_export'         => true,
42 42
         '_builtin'           => false,
@@ -50,68 +50,68 @@  discard block
 block discarded – undo
50 50
         'has_archive'        => false,
51 51
         'hierarchical'       => false,
52 52
         'menu_position'      => null,
53
-        'supports'           => array( 'title', 'author' ),
53
+        'supports'           => array('title', 'author'),
54 54
         'menu_icon'          => $menu_icon,
55 55
     );
56 56
             
57
-    $args = apply_filters( 'wpinv_register_post_type_invoice', $args );
57
+    $args = apply_filters('wpinv_register_post_type_invoice', $args);
58 58
     
59
-    register_post_type( 'wpi_invoice', $args );
59
+    register_post_type('wpi_invoice', $args);
60 60
     
61 61
     $items_labels = array(
62
-        'name'               => _x( 'Items', 'post type general name', 'invoicing' ),
63
-        'singular_name'      => _x( 'Item', 'post type singular name', 'invoicing' ),
64
-        'menu_name'          => _x( 'Items', 'admin menu', 'invoicing' ),
65
-        'add_new'            => _x( 'Add New', 'wpi_item', 'invoicing' ),
66
-        'add_new_item'       => __( 'Add New Item', 'invoicing' ),
67
-        'new_item'           => __( 'New Item', 'invoicing' ),
68
-        'edit_item'          => __( 'Edit Item', 'invoicing' ),
69
-        'view_item'          => __( 'View Item', 'invoicing' ),
70
-        'all_items'          => __( 'Items', 'invoicing' ),
71
-        'search_items'       => __( 'Search Items', 'invoicing' ),
62
+        'name'               => _x('Items', 'post type general name', 'invoicing'),
63
+        'singular_name'      => _x('Item', 'post type singular name', 'invoicing'),
64
+        'menu_name'          => _x('Items', 'admin menu', 'invoicing'),
65
+        'add_new'            => _x('Add New', 'wpi_item', 'invoicing'),
66
+        'add_new_item'       => __('Add New Item', 'invoicing'),
67
+        'new_item'           => __('New Item', 'invoicing'),
68
+        'edit_item'          => __('Edit Item', 'invoicing'),
69
+        'view_item'          => __('View Item', 'invoicing'),
70
+        'all_items'          => __('Items', 'invoicing'),
71
+        'search_items'       => __('Search Items', 'invoicing'),
72 72
         'parent_item_colon'  => '',
73
-        'not_found'          => __( 'No items found.', 'invoicing' ),
74
-        'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' )
73
+        'not_found'          => __('No items found.', 'invoicing'),
74
+        'not_found_in_trash' => __('No items found in trash.', 'invoicing')
75 75
     );
76
-    $items_labels = apply_filters( 'wpinv_items_labels', $items_labels );
76
+    $items_labels = apply_filters('wpinv_items_labels', $items_labels);
77 77
     
78 78
     $invoice_item_args = array(
79 79
         'labels'                => $items_labels,
80 80
         'public'                => false,
81 81
         'show_ui'               => true,
82 82
         'show_in_menu'          => 'wpinv',
83
-        'supports'              => array( 'title', 'excerpt' ),
83
+        'supports'              => array('title', 'excerpt'),
84 84
         'register_meta_box_cb'  => 'wpinv_register_item_meta_boxes',
85 85
         'rewrite'               => false,
86 86
         'query_var'             => false,
87 87
         'map_meta_cap'          => true,
88 88
         'can_export'            => true,
89 89
     );
90
-    $invoice_item_args = apply_filters( 'wpinv_register_post_type_invoice_item', $invoice_item_args );
90
+    $invoice_item_args = apply_filters('wpinv_register_post_type_invoice_item', $invoice_item_args);
91 91
 
92
-    register_post_type( 'wpi_item', $invoice_item_args );
92
+    register_post_type('wpi_item', $invoice_item_args);
93 93
     
94 94
     $labels = array(
95
-        'name'               => _x( 'Discounts', 'post type general name', 'invoicing' ),
96
-        'singular_name'      => _x( 'Discount', 'post type singular name', 'invoicing' ),
97
-        'menu_name'          => _x( 'Discounts', 'admin menu', 'invoicing' ),
98
-        'name_admin_bar'     => _x( 'Discount', 'add new on admin bar', 'invoicing' ),
99
-        'add_new'            => _x( 'Add New', 'book', 'invoicing' ),
100
-        'add_new_item'       => __( 'Add New Discount', 'invoicing' ),
101
-        'new_item'           => __( 'New Discount', 'invoicing' ),
102
-        'edit_item'          => __( 'Edit Discount', 'invoicing' ),
103
-        'view_item'          => __( 'View Discount', 'invoicing' ),
104
-        'all_items'          => __( 'Discounts', 'invoicing' ),
105
-        'search_items'       => __( 'Search Discounts', 'invoicing' ),
106
-        'parent_item_colon'  => __( 'Parent Discounts:', 'invoicing' ),
107
-        'not_found'          => __( 'No discounts found.', 'invoicing' ),
108
-        'not_found_in_trash' => __( 'No discounts found in trash.', 'invoicing' )
95
+        'name'               => _x('Discounts', 'post type general name', 'invoicing'),
96
+        'singular_name'      => _x('Discount', 'post type singular name', 'invoicing'),
97
+        'menu_name'          => _x('Discounts', 'admin menu', 'invoicing'),
98
+        'name_admin_bar'     => _x('Discount', 'add new on admin bar', 'invoicing'),
99
+        'add_new'            => _x('Add New', 'book', 'invoicing'),
100
+        'add_new_item'       => __('Add New Discount', 'invoicing'),
101
+        'new_item'           => __('New Discount', 'invoicing'),
102
+        'edit_item'          => __('Edit Discount', 'invoicing'),
103
+        'view_item'          => __('View Discount', 'invoicing'),
104
+        'all_items'          => __('Discounts', 'invoicing'),
105
+        'search_items'       => __('Search Discounts', 'invoicing'),
106
+        'parent_item_colon'  => __('Parent Discounts:', 'invoicing'),
107
+        'not_found'          => __('No discounts found.', 'invoicing'),
108
+        'not_found_in_trash' => __('No discounts found in trash.', 'invoicing')
109 109
     );
110
-    $labels = apply_filters( 'wpinv_discounts_labels', $labels );
110
+    $labels = apply_filters('wpinv_discounts_labels', $labels);
111 111
     
112 112
     $args = array(
113 113
         'labels'             => $labels,
114
-        'description'        => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ),
114
+        'description'        => __('This is where you can add new discounts that users can use in invoices.', 'invoicing'),
115 115
         'public'             => false,
116 116
         'can_export'         => true,
117 117
         '_builtin'           => false,
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
         'map_meta_cap'       => true,
126 126
         'has_archive'        => false,
127 127
         'hierarchical'       => false,
128
-        'supports'           => array( 'title', 'excerpt' ),
128
+        'supports'           => array('title', 'excerpt'),
129 129
         'register_meta_box_cb'  => 'wpinv_register_discount_meta_boxes',
130 130
         'show_in_nav_menus'  => false,
131 131
         'show_in_admin_bar'  => true,
@@ -133,99 +133,99 @@  discard block
 block discarded – undo
133 133
         'menu_position'      => null,
134 134
     );
135 135
             
136
-    $args = apply_filters( 'wpinv_register_post_type_discount', $args );
136
+    $args = apply_filters('wpinv_register_post_type_discount', $args);
137 137
     
138
-    register_post_type( 'wpi_discount', $args );
138
+    register_post_type('wpi_discount', $args);
139 139
 }
140 140
 
141 141
 function wpinv_get_default_labels() {
142 142
     $defaults = array(
143
-       'singular' => __( 'Invoice', 'invoicing' ),
144
-       'plural'   => __( 'Invoices', 'invoicing' )
143
+       'singular' => __('Invoice', 'invoicing'),
144
+       'plural'   => __('Invoices', 'invoicing')
145 145
     );
146 146
     
147
-    return apply_filters( 'wpinv_default_invoices_name', $defaults );
147
+    return apply_filters('wpinv_default_invoices_name', $defaults);
148 148
 }
149 149
 
150
-function wpinv_get_label_singular( $lowercase = false ) {
150
+function wpinv_get_label_singular($lowercase = false) {
151 151
     $defaults = wpinv_get_default_labels();
152 152
     
153
-    return ($lowercase) ? strtolower( $defaults['singular'] ) : $defaults['singular'];
153
+    return ($lowercase) ? strtolower($defaults['singular']) : $defaults['singular'];
154 154
 }
155 155
 
156
-function wpinv_get_label_plural( $lowercase = false ) {
156
+function wpinv_get_label_plural($lowercase = false) {
157 157
     $defaults = wpinv_get_default_labels();
158 158
     
159
-    return ( $lowercase ) ? strtolower( $defaults['plural'] ) : $defaults['plural'];
159
+    return ($lowercase) ? strtolower($defaults['plural']) : $defaults['plural'];
160 160
 }
161 161
 
162
-function wpinv_change_default_title( $title ) {
163
-     if ( !is_admin() ) {
162
+function wpinv_change_default_title($title) {
163
+     if (!is_admin()) {
164 164
         $label = wpinv_get_label_singular();
165
-        $title = sprintf( __( 'Enter %s name here', 'invoicing' ), $label );
165
+        $title = sprintf(__('Enter %s name here', 'invoicing'), $label);
166 166
         return $title;
167 167
      }
168 168
 
169 169
      $screen = get_current_screen();
170 170
 
171
-     if ( 'wpi_invoice' == $screen->post_type ) {
171
+     if ('wpi_invoice' == $screen->post_type) {
172 172
         $label = wpinv_get_label_singular();
173
-        $title = sprintf( __( 'Enter %s name here', 'invoicing' ), $label );
173
+        $title = sprintf(__('Enter %s name here', 'invoicing'), $label);
174 174
      }
175 175
 
176 176
      return $title;
177 177
 }
178
-add_filter( 'enter_title_here', 'wpinv_change_default_title' );
178
+add_filter('enter_title_here', 'wpinv_change_default_title');
179 179
 
180 180
 function wpinv_register_post_status() {
181
-    register_post_status( 'wpi-processing', array(
182
-        'label'                     => _x( 'Processing', 'Invoice status', 'invoicing' ),
181
+    register_post_status('wpi-processing', array(
182
+        'label'                     => _x('Processing', 'Invoice status', 'invoicing'),
183 183
         'public'                    => true,
184 184
         'exclude_from_search'       => true,
185 185
         'show_in_admin_all_list'    => true,
186 186
         'show_in_admin_status_list' => true,
187
-        'label_count'               => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' )
188
-    ) );
189
-    register_post_status( 'wpi-onhold', array(
190
-        'label'                     => _x( 'On Hold', 'Invoice status', 'invoicing' ),
187
+        'label_count'               => _n_noop('Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing')
188
+    ));
189
+    register_post_status('wpi-onhold', array(
190
+        'label'                     => _x('On Hold', 'Invoice status', 'invoicing'),
191 191
         'public'                    => true,
192 192
         'exclude_from_search'       => true,
193 193
         'show_in_admin_all_list'    => true,
194 194
         'show_in_admin_status_list' => true,
195
-        'label_count'               => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' )
196
-    ) );
197
-    register_post_status( 'wpi-cancelled', array(
198
-        'label'                     => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
195
+        'label_count'               => _n_noop('On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing')
196
+    ));
197
+    register_post_status('wpi-cancelled', array(
198
+        'label'                     => _x('Cancelled', 'Invoice status', 'invoicing'),
199 199
         'public'                    => true,
200 200
         'exclude_from_search'       => true,
201 201
         'show_in_admin_all_list'    => true,
202 202
         'show_in_admin_status_list' => true,
203
-        'label_count'               => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' )
204
-    ) );
205
-    register_post_status( 'wpi-refunded', array(
206
-        'label'                     => _x( 'Refunded', 'Invoice status', 'invoicing' ),
203
+        'label_count'               => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing')
204
+    ));
205
+    register_post_status('wpi-refunded', array(
206
+        'label'                     => _x('Refunded', 'Invoice status', 'invoicing'),
207 207
         'public'                    => true,
208 208
         'exclude_from_search'       => true,
209 209
         'show_in_admin_all_list'    => true,
210 210
         'show_in_admin_status_list' => true,
211
-        'label_count'               => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' )
212
-    ) );
213
-    register_post_status( 'wpi-failed', array(
214
-        'label'                     => _x( 'Failed', 'Invoice status', 'invoicing' ),
211
+        'label_count'               => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing')
212
+    ));
213
+    register_post_status('wpi-failed', array(
214
+        'label'                     => _x('Failed', 'Invoice status', 'invoicing'),
215 215
         'public'                    => true,
216 216
         'exclude_from_search'       => true,
217 217
         'show_in_admin_all_list'    => true,
218 218
         'show_in_admin_status_list' => true,
219
-        'label_count'               => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' )
220
-    ) );
221
-    register_post_status( 'wpi-renewal', array(
222
-        'label'                     => _x( 'Renewal', 'Invoice status', 'invoicing' ),
219
+        'label_count'               => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing')
220
+    ));
221
+    register_post_status('wpi-renewal', array(
222
+        'label'                     => _x('Renewal', 'Invoice status', 'invoicing'),
223 223
         'public'                    => true,
224 224
         'exclude_from_search'       => true,
225 225
         'show_in_admin_all_list'    => true,
226 226
         'show_in_admin_status_list' => true,
227
-        'label_count'               => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' )
228
-    ) );
227
+        'label_count'               => _n_noop('Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing')
228
+    ));
229 229
 }
230
-add_action( 'init', 'wpinv_register_post_status', 10 );
230
+add_action('init', 'wpinv_register_post_status', 10);
231 231
 
Please login to merge, or discard this patch.
includes/gateways/worldpay.php 1 patch
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  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
-add_action( 'wpinv_worldpay_cc_form', '__return_false' );
5
+add_action('wpinv_worldpay_cc_form', '__return_false');
6 6
 
7
-function wpinv_process_worldpay_payment( $purchase_data ) {
8
-    if( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'wpi-gateway' ) ) {
9
-        wp_die( __( 'Nonce verification has failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
7
+function wpinv_process_worldpay_payment($purchase_data) {
8
+    if (!wp_verify_nonce($purchase_data['gateway_nonce'], 'wpi-gateway')) {
9
+        wp_die(__('Nonce verification has failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
10 10
     }
11 11
     
12 12
     // Collect payment data
@@ -24,120 +24,120 @@  discard block
 block discarded – undo
24 24
     );
25 25
 
26 26
     // Record the pending payment
27
-    $invoice = wpinv_get_invoice( $purchase_data['invoice_id'] );
27
+    $invoice = wpinv_get_invoice($purchase_data['invoice_id']);
28 28
     
29
-    if ( !empty( $invoice ) ) {
29
+    if (!empty($invoice)) {
30 30
         $quantities_enabled = wpinv_item_quantities_enabled();
31 31
         
32
-        $instId     = wpinv_get_option( 'worldpay_instId', false );
32
+        $instId     = wpinv_get_option('worldpay_instId', false);
33 33
         $cartId     = $invoice->get_number();
34
-        $testMode   = wpinv_is_test_mode( 'worldpay' ) ? 100 : 0;
34
+        $testMode   = wpinv_is_test_mode('worldpay') ? 100 : 0;
35 35
         $name       = $invoice->get_user_full_name();
36
-        $address    = wp_strip_all_tags( $invoice->get_address(), true );
36
+        $address    = wp_strip_all_tags($invoice->get_address(), true);
37 37
         $postcode   = $invoice->zip;
38 38
         $tel        = $invoice->phone;
39 39
         $email      = $invoice->get_email();
40 40
         $country    = $invoice->country;
41
-        $amount     = wpinv_sanitize_amount( $invoice->get_total() );
41
+        $amount     = wpinv_sanitize_amount($invoice->get_total());
42 42
         $currency   = wpinv_get_currency();
43 43
         
44 44
         $items      = array();
45
-        foreach ( $invoice->get_cart_details() as $item ) {
45
+        foreach ($invoice->get_cart_details() as $item) {
46 46
             $item_desc  = $item['name'];
47
-            $quantity   = !empty( $item['quantity'] ) && $item['quantity'] > 0 ? $item['quantity'] : 1;
48
-            $item_desc .= ' (' . ( $quantities_enabled ? $quantity . 'x ' : '' ) . wpinv_price( wpinv_format_amount( $item['item_price'] ) ) . ')';
47
+            $quantity   = !empty($item['quantity']) && $item['quantity'] > 0 ? $item['quantity'] : 1;
48
+            $item_desc .= ' (' . ($quantities_enabled ? $quantity . 'x ' : '') . wpinv_price(wpinv_format_amount($item['item_price'])) . ')';
49 49
             
50 50
             $items[] = $item_desc;
51 51
         }
52 52
         
53
-        $desc = implode( ', ', $items );
54
-        if ( wpinv_use_taxes() && $invoice->get_tax() > 0 ) {
55
-            $desc .= ', ' . wp_sprintf( __( 'Tax: %s', 'invoicing' ), $invoice->get_tax( true ) );
53
+        $desc = implode(', ', $items);
54
+        if (wpinv_use_taxes() && $invoice->get_tax() > 0) {
55
+            $desc .= ', ' . wp_sprintf(__('Tax: %s', 'invoicing'), $invoice->get_tax(true));
56 56
         }
57 57
         
58 58
         $extra_params                   = array();
59 59
         $extra_params['MC_description'] = $desc;
60
-        $extra_params['MC_callback']    = wpinv_get_ipn_url( 'worldpay' );
60
+        $extra_params['MC_callback']    = wpinv_get_ipn_url('worldpay');
61 61
         $extra_params['MC_key']         = $invoice->get_key();
62 62
         $extra_params['MC_invoice_id']  = $invoice->ID;
63 63
         $extra_params['address1']       = $address;
64 64
         $extra_params['town']           = $invoice->city;
65 65
         $extra_params['region']         = $invoice->state;
66
-        $extra_params['amountString']   = $invoice->get_total( true );
67
-        $extra_params['countryString']  = wpinv_country_name( $invoice->country );
66
+        $extra_params['amountString']   = $invoice->get_total(true);
67
+        $extra_params['countryString']  = wpinv_country_name($invoice->country);
68 68
         $extra_params['compName']       = $invoice->company;
69 69
         
70
-        $extra_params   = apply_filters( 'wpinv_worldpay_form_extra_parameters', $extra_params, $invoice );
70
+        $extra_params   = apply_filters('wpinv_worldpay_form_extra_parameters', $extra_params, $invoice);
71 71
         
72
-        $redirect_text  = __( 'Redirecting to Worldpay site, click on button if not redirected.', 'invoicing' );
73
-        $redirect_text  = apply_filters( 'wpinv_worldpay_redirect_text', $redirect_text, $invoice );
72
+        $redirect_text  = __('Redirecting to Worldpay site, click on button if not redirected.', 'invoicing');
73
+        $redirect_text  = apply_filters('wpinv_worldpay_redirect_text', $redirect_text, $invoice);
74 74
         
75 75
         // Empty the shopping cart
76 76
         wpinv_empty_cart();
77 77
         ?>
78 78
 <div class="wpi-worldpay-form" style="padding:20px;font-family:arial,sans-serif;text-align:center;color:#555">
79
-<?php do_action( 'wpinv_worldpay_form_before', $invoice ); ?>
80
-<h3><?php echo $redirect_text ;?></h3>
79
+<?php do_action('wpinv_worldpay_form_before', $invoice); ?>
80
+<h3><?php echo $redirect_text; ?></h3>
81 81
 <form action="<?php echo wpinv_get_worldpay_redirect(); ?>" name="wpi_worldpay_form" method="POST">
82
-    <input type="hidden" value="<?php echo $amount;?>" name="amount">
83
-    <input type="hidden" value="<?php echo esc_attr( $cartId );?>" name="cartId">
84
-    <input type="hidden" value="<?php echo $currency;?>" name="currency">
85
-    <input type="hidden" value="<?php echo $instId;?>" name="instId">
86
-    <input type="hidden" value="<?php echo $testMode;?>" name="testMode">
87
-    <input type="hidden" value="<?php echo esc_attr( $name );?>" name="name">
88
-    <input type="hidden" value="<?php echo esc_attr( $address );?>" name="address">
89
-    <input type="hidden" value="<?php echo esc_attr( $postcode );?>" name="postcode">
90
-    <input type="hidden" value="<?php echo esc_attr( $tel );?>" name="tel">
91
-    <input type="hidden" value="<?php echo esc_attr( $email );?>" name="email">
92
-    <input type="hidden" value="<?php echo esc_attr( $country );?>" name="country">
93
-    <input type="hidden" value="<?php echo esc_attr( $desc );?>" name="desc">
94
-    <?php foreach ( $extra_params as $param => $value ) { ?>
95
-        <?php if ( !empty( $value !== false ) ) { ?>
96
-    <input type="hidden" value="<?php echo esc_attr( $value );?>" name="<?php echo esc_attr( $param );?>">
82
+    <input type="hidden" value="<?php echo $amount; ?>" name="amount">
83
+    <input type="hidden" value="<?php echo esc_attr($cartId); ?>" name="cartId">
84
+    <input type="hidden" value="<?php echo $currency; ?>" name="currency">
85
+    <input type="hidden" value="<?php echo $instId; ?>" name="instId">
86
+    <input type="hidden" value="<?php echo $testMode; ?>" name="testMode">
87
+    <input type="hidden" value="<?php echo esc_attr($name); ?>" name="name">
88
+    <input type="hidden" value="<?php echo esc_attr($address); ?>" name="address">
89
+    <input type="hidden" value="<?php echo esc_attr($postcode); ?>" name="postcode">
90
+    <input type="hidden" value="<?php echo esc_attr($tel); ?>" name="tel">
91
+    <input type="hidden" value="<?php echo esc_attr($email); ?>" name="email">
92
+    <input type="hidden" value="<?php echo esc_attr($country); ?>" name="country">
93
+    <input type="hidden" value="<?php echo esc_attr($desc); ?>" name="desc">
94
+    <?php foreach ($extra_params as $param => $value) { ?>
95
+        <?php if (!empty($value !== false)) { ?>
96
+    <input type="hidden" value="<?php echo esc_attr($value); ?>" name="<?php echo esc_attr($param); ?>">
97 97
         <?php } ?>
98 98
     <?php } ?>
99
-    <?php do_action( 'wpinv_worldpay_form_parameters', $invoice ); ?>
100
-    <input type="submit" name="wpi_worldpay_submit" value="<?php esc_attr_e( 'Pay by Debit/Credit Card (WorldPay)', 'invoicing' ) ;?>">
99
+    <?php do_action('wpinv_worldpay_form_parameters', $invoice); ?>
100
+    <input type="submit" name="wpi_worldpay_submit" value="<?php esc_attr_e('Pay by Debit/Credit Card (WorldPay)', 'invoicing'); ?>">
101 101
 </form>
102 102
 <script type="text/javascript">document.wpi_worldpay_form.submit();</script>
103
-<?php do_action( 'wpinv_worldpay_form_after', $invoice ); ?>
103
+<?php do_action('wpinv_worldpay_form_after', $invoice); ?>
104 104
 </div>
105 105
         <?php
106 106
     } else {
107
-        wpinv_record_gateway_error( __( 'Payment Error', 'invoicing' ), sprintf( __( 'Payment creation failed while processing a worldpay payment. Payment data: %s', 'invoicing' ), json_encode( $payment_data ) ), $invoice );
107
+        wpinv_record_gateway_error(__('Payment Error', 'invoicing'), sprintf(__('Payment creation failed while processing a worldpay payment. Payment data: %s', 'invoicing'), json_encode($payment_data)), $invoice);
108 108
         // If errors are present, send the user back to the purchase page so they can be corrected
109
-        wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] );
109
+        wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']);
110 110
     }
111 111
 }
112
-add_action( 'wpinv_gateway_worldpay', 'wpinv_process_worldpay_payment' );
112
+add_action('wpinv_gateway_worldpay', 'wpinv_process_worldpay_payment');
113 113
 
114 114
 function wpinv_get_worldpay_redirect() {
115
-    $redirect = wpinv_is_test_mode( 'worldpay' ) ? 'https://secure-test.worldpay.com/wcc/purchase' : 'https://secure.worldpay.com/wcc/purchase';
115
+    $redirect = wpinv_is_test_mode('worldpay') ? 'https://secure-test.worldpay.com/wcc/purchase' : 'https://secure.worldpay.com/wcc/purchase';
116 116
     
117
-    return apply_filters( 'wpinv_worldpay_redirect', $redirect );
117
+    return apply_filters('wpinv_worldpay_redirect', $redirect);
118 118
 }
119 119
 
120 120
 function wpinv_process_worldpay_ipn() {
121
-    $request = wpinv_get_post_data( 'post' );
121
+    $request = wpinv_get_post_data('post');
122 122
     
123
-    if ( !empty( $request['cartId'] ) && !empty( $request['transStatus'] ) && !empty( $request['installation'] ) && isset( $request['testMode'] ) && isset( $request['MC_invoice_id'] ) && isset( $request['MC_key'] ) ) {
123
+    if (!empty($request['cartId']) && !empty($request['transStatus']) && !empty($request['installation']) && isset($request['testMode']) && isset($request['MC_invoice_id']) && isset($request['MC_key'])) {
124 124
         $invoice_id = $request['MC_invoice_id'];
125 125
         
126
-        if ( $invoice_id == wpinv_get_invoice_id_by_key( $request['MC_key'] ) && $invoice = wpinv_get_invoice( $invoice_id ) ) {
127
-            if ( $request['transStatus'] == 'Y' ) {                
128
-                wpinv_update_payment_status( $invoice_id, 'publish' );
129
-                wpinv_set_payment_transaction_id( $invoice_id, $request['transId'] );
130
-                wpinv_insert_payment_note( $invoice_id, sprintf( __( 'Worldpay Transaction ID: %s', 'invoicing' ), $request['transId'] ) );
126
+        if ($invoice_id == wpinv_get_invoice_id_by_key($request['MC_key']) && $invoice = wpinv_get_invoice($invoice_id)) {
127
+            if ($request['transStatus'] == 'Y') {                
128
+                wpinv_update_payment_status($invoice_id, 'publish');
129
+                wpinv_set_payment_transaction_id($invoice_id, $request['transId']);
130
+                wpinv_insert_payment_note($invoice_id, sprintf(__('Worldpay Transaction ID: %s', 'invoicing'), $request['transId']));
131 131
                 return;
132
-            } else if ( $request['transStatus'] == 'C' ) {
133
-                wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
134
-                wpinv_insert_payment_note( $invoice_id, __( 'Payment transaction failed while processing Worldpay payment, kindly check IPN log.', 'invoicing' ) );
132
+            } else if ($request['transStatus'] == 'C') {
133
+                wpinv_update_payment_status($invoice_id, 'wpi-failed');
134
+                wpinv_insert_payment_note($invoice_id, __('Payment transaction failed while processing Worldpay payment, kindly check IPN log.', 'invoicing'));
135 135
                 
136
-                wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Payment transaction failed while processing Worldpay payment. IPN data: %s', 'invoicing' ), json_encode( $request ) ), $invoice_id );
136
+                wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Payment transaction failed while processing Worldpay payment. IPN data: %s', 'invoicing'), json_encode($request)), $invoice_id);
137 137
                 return;
138 138
             }
139 139
         }
140 140
     }
141 141
     return;
142 142
 }
143
-add_action( 'wpinv_verify_worldpay_ipn', 'wpinv_process_worldpay_ipn' );
144 143
\ No newline at end of file
144
+add_action('wpinv_verify_worldpay_ipn', 'wpinv_process_worldpay_ipn');
145 145
\ No newline at end of file
Please login to merge, or discard this patch.