Passed
Pull Request — master (#217)
by Patrik
03:42 queued 13s
created
includes/admin/meta-boxes/class-mb-invoice-items.php 1 patch
Spacing   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -1,47 +1,47 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7 7
 class WPInv_Meta_Box_Items {
8
-    public static function output( $post ) {
8
+    public static function output($post) {
9 9
         global $wpinv_euvat, $ajax_cart_details;
10 10
 
11
-        $post_id            = !empty( $post->ID ) ? $post->ID : 0;
12
-        $invoice            = new WPInv_Invoice( $post_id );
11
+        $post_id            = !empty($post->ID) ? $post->ID : 0;
12
+        $invoice            = new WPInv_Invoice($post_id);
13 13
         $ajax_cart_details  = $invoice->get_cart_details();
14
-        $subtotal           = $invoice->get_subtotal( true );
14
+        $subtotal           = $invoice->get_subtotal(true);
15 15
         $discount_raw       = $invoice->get_discount();
16
-        $discount           = wpinv_price( $discount_raw, $invoice->get_currency() );
16
+        $discount           = wpinv_price($discount_raw, $invoice->get_currency());
17 17
         $discounts          = $discount_raw > 0 ? $invoice->get_discounts() : '';
18
-        $tax                = $invoice->get_tax( true );
19
-        $total              = $invoice->get_total( true );
18
+        $tax                = $invoice->get_tax(true);
19
+        $total              = $invoice->get_total(true);
20 20
         $item_quantities    = wpinv_item_quantities_enabled();
21 21
         $use_taxes          = wpinv_use_taxes();
22
-        if ( !$use_taxes && (float)$invoice->get_tax() > 0 ) {
22
+        if (!$use_taxes && (float)$invoice->get_tax() > 0) {
23 23
             $use_taxes = true;
24 24
         }
25
-        $item_types         = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post );
25
+        $item_types         = apply_filters('wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post);
26 26
         $is_recurring       = $invoice->is_recurring();
27 27
         $post_type_object   = get_post_type_object($invoice->post_type);
28 28
         $type_title         = $post_type_object->labels->singular_name;
29 29
 
30 30
         $cols = 5;
31
-        if ( $item_quantities ) {
31
+        if ($item_quantities) {
32 32
             $cols++;
33 33
         }
34
-        if ( $use_taxes ) {
34
+        if ($use_taxes) {
35 35
             $cols++;
36 36
         }
37 37
         $class = '';
38
-        if ( $invoice->is_paid() ) {
38
+        if ($invoice->is_paid()) {
39 39
             $class .= ' wpinv-paid';
40 40
         }
41
-        if ( $invoice->is_refunded() ) {
41
+        if ($invoice->is_refunded()) {
42 42
             $class .= ' wpinv-refunded';
43 43
         }
44
-        if ( $is_recurring ) {
44
+        if ($is_recurring) {
45 45
             $class .= ' wpi-recurring';
46 46
         }
47 47
         ?>
@@ -49,21 +49,21 @@  discard block
 block discarded – undo
49 49
             <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0">
50 50
                 <thead>
51 51
                     <tr>
52
-                        <th class="id"><?php _e( 'ID', 'invoicing' );?></th>
53
-                        <th class="title"><?php _e( 'Item', 'invoicing' );?></th>
54
-                        <th class="price"><?php _e( 'Price', 'invoicing' );?></th>
55
-                        <?php if ( $item_quantities ) { ?>
56
-                        <th class="qty"><?php _e( 'Qty', 'invoicing' );?></th>
52
+                        <th class="id"><?php _e('ID', 'invoicing'); ?></th>
53
+                        <th class="title"><?php _e('Item', 'invoicing'); ?></th>
54
+                        <th class="price"><?php _e('Price', 'invoicing'); ?></th>
55
+                        <?php if ($item_quantities) { ?>
56
+                        <th class="qty"><?php _e('Qty', 'invoicing'); ?></th>
57 57
                         <?php } ?>
58
-                        <th class="total"><?php _e( 'Total', 'invoicing' );?></th>
59
-                        <?php if ( $use_taxes ) { ?>
60
-                        <th class="tax"><?php _e( 'Tax (%)', 'invoicing' );?></th>
58
+                        <th class="total"><?php _e('Total', 'invoicing'); ?></th>
59
+                        <?php if ($use_taxes) { ?>
60
+                        <th class="tax"><?php _e('Tax (%)', 'invoicing'); ?></th>
61 61
                         <?php } ?>
62 62
                         <th class="action"></th>
63 63
                     </tr>
64 64
                 </thead>
65 65
                 <tbody class="wpinv-line-items">
66
-                    <?php echo wpinv_admin_get_line_items( $invoice ); ?>
66
+                    <?php echo wpinv_admin_get_line_items($invoice); ?>
67 67
                 </tbody>
68 68
                 <tfoot class="wpinv-totals">
69 69
                     <tr>
@@ -74,45 +74,45 @@  discard block
 block discarded – undo
74 74
                                         <td class="id">
75 75
                                         </td>
76 76
                                         <td class="title">
77
-                                            <input type="text" class="regular-text" placeholder="<?php _e( 'Item Name', 'invoicing' ); ?>" value="" name="_wpinv_quick[name]">
78
-                                            <?php if ( $wpinv_euvat->allow_vat_rules() ) { ?>
77
+                                            <input type="text" class="regular-text" placeholder="<?php _e('Item Name', 'invoicing'); ?>" value="" name="_wpinv_quick[name]">
78
+                                            <?php if ($wpinv_euvat->allow_vat_rules()) { ?>
79 79
                                             <div class="wp-clearfix">
80 80
                                                 <label class="wpi-vat-rule">
81
-                                                    <span class="title"><?php _e( 'VAT rule type', 'invoicing' );?></span>
81
+                                                    <span class="title"><?php _e('VAT rule type', 'invoicing'); ?></span>
82 82
                                                     <span class="input-text-wrap">
83
-                                                        <?php echo wpinv_html_select( array(
83
+                                                        <?php echo wpinv_html_select(array(
84 84
                                                             'options'          => $wpinv_euvat->get_rules(),
85 85
                                                             'name'             => '_wpinv_quick[vat_rule]',
86 86
                                                             'id'               => '_wpinv_quick_vat_rule',
87 87
                                                             'show_option_all'  => false,
88 88
                                                             'show_option_none' => false,
89 89
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-vat-rule wpi_select2',
90
-                                                        ) ); ?>
90
+                                                        )); ?>
91 91
                                                     </span>
92 92
                                                 </label>
93 93
                                             </div>
94
-                                            <?php } if ( $wpinv_euvat->allow_vat_classes() ) { ?>
94
+                                            <?php } if ($wpinv_euvat->allow_vat_classes()) { ?>
95 95
                                             <div class="wp-clearfix">
96 96
                                                 <label class="wpi-vat-class">
97
-                                                    <span class="title"><?php _e( 'VAT class', 'invoicing' );?></span>
97
+                                                    <span class="title"><?php _e('VAT class', 'invoicing'); ?></span>
98 98
                                                     <span class="input-text-wrap">
99
-                                                        <?php echo wpinv_html_select( array(
99
+                                                        <?php echo wpinv_html_select(array(
100 100
                                                             'options'          => $wpinv_euvat->get_all_classes(),
101 101
                                                             'name'             => '_wpinv_quick[vat_class]',
102 102
                                                             'id'               => '_wpinv_quick_vat_class',
103 103
                                                             'show_option_all'  => false,
104 104
                                                             'show_option_none' => false,
105 105
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-vat-class wpi_select2',
106
-                                                        ) ); ?>
106
+                                                        )); ?>
107 107
                                                     </span>
108 108
                                                 </label>
109 109
                                             </div>
110 110
                                             <?php } ?>
111 111
                                             <div class="wp-clearfix">
112 112
                                                 <label class="wpi-item-type">
113
-                                                    <span class="title"><?php _e( 'Item type', 'invoicing' );?></span>
113
+                                                    <span class="title"><?php _e('Item type', 'invoicing'); ?></span>
114 114
                                                     <span class="input-text-wrap">
115
-                                                        <?php echo wpinv_html_select( array(
115
+                                                        <?php echo wpinv_html_select(array(
116 116
                                                             'options'          => $item_types,
117 117
                                                             'name'             => '_wpinv_quick[type]',
118 118
                                                             'id'               => '_wpinv_quick_type',
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
                                                             'show_option_all'  => false,
121 121
                                                             'show_option_none' => false,
122 122
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-type wpi_select2',
123
-                                                        ) ); ?>
123
+                                                        )); ?>
124 124
                                                     </span>
125 125
                                                 </label>
126 126
                                             </div>
@@ -133,11 +133,11 @@  discard block
 block discarded – undo
133 133
                                             </div>
134 134
                                         </td>
135 135
                                         <td class="price"><input type="text" placeholder="0.00" class="wpi-field-price wpi-price" name="_wpinv_quick[price]" /></td>
136
-                                        <?php if ( $item_quantities ) { ?>
136
+                                        <?php if ($item_quantities) { ?>
137 137
                                         <td class="qty"><input type="number" class="small-text" step="1" min="1" value="1" name="_wpinv_quick[qty]" /></td>
138 138
                                         <?php } ?>
139 139
                                         <td class="total"></td>
140
-                                        <?php if ( $use_taxes ) { ?>
140
+                                        <?php if ($use_taxes) { ?>
141 141
                                         <td class="tax"></td>
142 142
                                         <?php } ?>
143 143
                                         <td class="action"></td>
@@ -150,29 +150,29 @@  discard block
 block discarded – undo
150 150
                         <td colspan="<?php echo $cols; ?>"></td>
151 151
                     </tr>
152 152
                     <tr class="totals">
153
-                        <td colspan="<?php echo ( $cols - 4 ); ?>"></td>
153
+                        <td colspan="<?php echo ($cols - 4); ?>"></td>
154 154
                         <td colspan="4">
155 155
                             <table cellspacing="0" cellpadding="0">
156 156
                                 <tr class="subtotal">
157
-                                    <td class="name"><?php _e( 'Sub Total:', 'invoicing' );?></td>
158
-                                    <td class="total"><?php echo $subtotal;?></td>
157
+                                    <td class="name"><?php _e('Sub Total:', 'invoicing'); ?></td>
158
+                                    <td class="total"><?php echo $subtotal; ?></td>
159 159
                                     <td class="action"></td>
160 160
                                 </tr>
161 161
                                 <tr class="discount">
162
-                                    <td class="name"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice->ID ) ); ?>:</td>
163
-                                    <td class="total"><?php echo wpinv_discount( $invoice->ID, true, true ); ?></td>
162
+                                    <td class="name"><?php wpinv_get_discount_label(wpinv_discount_code($invoice->ID)); ?>:</td>
163
+                                    <td class="total"><?php echo wpinv_discount($invoice->ID, true, true); ?></td>
164 164
                                     <td class="action"></td>
165 165
                                 </tr>
166
-                                <?php if ( $use_taxes ) { ?>
166
+                                <?php if ($use_taxes) { ?>
167 167
                                 <tr class="tax">
168
-                                    <td class="name"><?php _e( 'Tax:', 'invoicing' );?></td>
169
-                                    <td class="total"><?php echo $tax;?></td>
168
+                                    <td class="name"><?php _e('Tax:', 'invoicing'); ?></td>
169
+                                    <td class="total"><?php echo $tax; ?></td>
170 170
                                     <td class="action"></td>
171 171
                                 </tr>
172 172
                                 <?php } ?>
173 173
                                 <tr class="total">
174
-                                    <td class="name"><?php echo apply_filters( 'wpinv_invoice_items_total_label', __( 'Invoice Total:', 'invoicing' ), $invoice );?></td>
175
-                                    <td class="total"><?php echo $total;?></td>
174
+                                    <td class="name"><?php echo apply_filters('wpinv_invoice_items_total_label', __('Invoice Total:', 'invoicing'), $invoice); ?></td>
175
+                                    <td class="total"><?php echo $total; ?></td>
176 176
                                     <td class="action"></td>
177 177
                                 </tr>
178 178
                             </table>
@@ -183,60 +183,60 @@  discard block
 block discarded – undo
183 183
             <div class="wpinv-actions">
184 184
                 <?php ob_start(); ?>
185 185
                 <?php
186
-                    if ( !$invoice->is_paid() && !$invoice->is_refunded() ) {
187
-                        if ( !$invoice->is_recurring() ) {
188
-                            echo wpinv_item_dropdown( array(
186
+                    if (!$invoice->is_paid() && !$invoice->is_refunded()) {
187
+                        if (!$invoice->is_recurring()) {
188
+                            echo wpinv_item_dropdown(array(
189 189
                                 'name'             => 'wpinv_invoice_item',
190 190
                                 'id'               => 'wpinv_invoice_item',
191 191
                                 'show_recurring'   => true,
192 192
                                 'class'            => 'wpi_select2',
193
-                            ) );
193
+                            ));
194 194
                     ?>
195
-                <input type="button" value="<?php echo sprintf(esc_attr__( 'Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e( 'Create new item', 'invoicing' );?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e( 'Recalculate Totals', 'invoicing' );?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals">
195
+                <input type="button" value="<?php echo sprintf(esc_attr__('Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e('Create new item', 'invoicing'); ?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e('Recalculate Totals', 'invoicing'); ?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals">
196 196
                     <?php } ?>
197
-                <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?>
198
-                <?php $item_actions = ob_get_clean(); echo apply_filters( 'wpinv_invoice_items_actions_content', $item_actions, $invoice, $post ); ?>
197
+                <?php do_action('wpinv_invoice_items_actions', $invoice); ?>
198
+                <?php $item_actions = ob_get_clean(); echo apply_filters('wpinv_invoice_items_actions_content', $item_actions, $invoice, $post); ?>
199 199
             </div>
200 200
         </div>
201 201
         <?php
202 202
     }
203 203
 
204
-    public static function prices( $post ) {        
204
+    public static function prices($post) {        
205 205
         $symbol         = wpinv_currency_symbol();
206 206
         $position       = wpinv_currency_position();
207
-        $item           = new WPInv_Item( $post->ID );
207
+        $item           = new WPInv_Item($post->ID);
208 208
 
209 209
         $price          = $item->get_price();
210 210
         $is_recurring   = $item->is_recurring();
211 211
         $period         = $item->get_recurring_period();
212
-        $interval       = absint( $item->get_recurring_interval() );
213
-        $times          = absint( $item->get_recurring_limit() );
212
+        $interval       = absint($item->get_recurring_interval());
213
+        $times          = absint($item->get_recurring_limit());
214 214
         $free_trial     = $item->has_free_trial();
215 215
         $trial_interval = $item->get_trial_interval();
216 216
         $trial_period   = $item->get_trial_period();
217 217
 
218 218
         $intervals      = array();
219
-        for ( $i = 1; $i <= 90; $i++ ) {
219
+        for ($i = 1; $i <= 90; $i++) {
220 220
             $intervals[$i] = $i;
221 221
         }
222 222
 
223
-        $interval       = $interval > 0 ? $interval : 1;
223
+        $interval = $interval > 0 ? $interval : 1;
224 224
 
225 225
         $class = $is_recurring ? 'wpinv-recurring-y' : 'wpinv-recurring-n';
226 226
         ?>
227
-        <p class="wpinv-row-prices"><?php echo ( $position != 'right' ? $symbol . '&nbsp;' : '' );?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount( 0 ); ?>" value="<?php echo $price;?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled( $item->is_editable(), false ); ?> /><?php echo ( $position == 'right' ? '&nbsp;' . $symbol : '' );?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce( 'wpinv_item_meta_box_save' ) ;?>" />
228
-        <?php do_action( 'wpinv_prices_metabox_price', $item ); ?>
227
+        <p class="wpinv-row-prices"><?php echo ($position != 'right' ? $symbol . '&nbsp;' : ''); ?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount(0); ?>" value="<?php echo $price; ?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled($item->is_editable(), false); ?> /><?php echo ($position == 'right' ? '&nbsp;' . $symbol : ''); ?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce('wpinv_item_meta_box_save'); ?>" />
228
+        <?php do_action('wpinv_prices_metabox_price', $item); ?>
229 229
         </p>
230 230
         <p class="wpinv-row-is-recurring">
231 231
             <label for="wpinv_is_recurring">
232
-                <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked( 1, $is_recurring ); ?> />
233
-                <?php echo apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Is Recurring Item?', 'invoicing' ) ); ?>
232
+                <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked(1, $is_recurring); ?> />
233
+                <?php echo apply_filters('wpinv_is_recurring_toggle_text', __('Is Recurring Item?', 'invoicing')); ?>
234 234
             </label>
235
-            <?php do_action( 'wpinv_prices_metabox_is_recurring_field', $item ); ?>
235
+            <?php do_action('wpinv_prices_metabox_is_recurring_field', $item); ?>
236 236
         </p>
237
-        <p class="wpinv-row-recurring-fields <?php echo $class;?>">
238
-            <label class="wpinv-period" for="wpinv_recurring_period"><?php _e( 'Recurring', 'invoicing' );?> <select class="wpinv-select wpi_select2" id="wpinv_recurring_period" name="wpinv_recurring_period"><option value="D" data-text="<?php esc_attr_e( 'day(s)', 'invoicing' ); ?>" <?php selected( 'D', $period );?>><?php _e( 'Daily', 'invoicing' ); ?></option><option value="W" data-text="<?php esc_attr_e( 'week(s)', 'invoicing' ); ?>" <?php selected( 'W', $period );?>><?php _e( 'Weekly', 'invoicing' ); ?></option><option value="M" data-text="<?php esc_attr_e( 'month(s)', 'invoicing' ); ?>" <?php selected( 'M', $period );?>><?php _e( 'Monthly', 'invoicing' ); ?></option><option value="Y" data-text="<?php esc_attr_e( 'year(s)', 'invoicing' ); ?>" <?php selected( 'Y', $period );?>><?php _e( 'Yearly', 'invoicing' ); ?></option></select></label>
239
-            <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e( 'at every', 'invoicing' );?> <?php echo wpinv_html_select( array(
237
+        <p class="wpinv-row-recurring-fields <?php echo $class; ?>">
238
+            <label class="wpinv-period" for="wpinv_recurring_period"><?php _e('Recurring', 'invoicing'); ?> <select class="wpinv-select wpi_select2" id="wpinv_recurring_period" name="wpinv_recurring_period"><option value="D" data-text="<?php esc_attr_e('day(s)', 'invoicing'); ?>" <?php selected('D', $period); ?>><?php _e('Daily', 'invoicing'); ?></option><option value="W" data-text="<?php esc_attr_e('week(s)', 'invoicing'); ?>" <?php selected('W', $period); ?>><?php _e('Weekly', 'invoicing'); ?></option><option value="M" data-text="<?php esc_attr_e('month(s)', 'invoicing'); ?>" <?php selected('M', $period); ?>><?php _e('Monthly', 'invoicing'); ?></option><option value="Y" data-text="<?php esc_attr_e('year(s)', 'invoicing'); ?>" <?php selected('Y', $period); ?>><?php _e('Yearly', 'invoicing'); ?></option></select></label>
239
+            <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e('at every', 'invoicing'); ?> <?php echo wpinv_html_select(array(
240 240
                 'options'          => $intervals,
241 241
                 'name'             => 'wpinv_recurring_interval',
242 242
                 'id'               => 'wpinv_recurring_interval',
@@ -244,30 +244,30 @@  discard block
 block discarded – undo
244 244
                 'show_option_all'  => false,
245 245
                 'show_option_none' => false,
246 246
                 'class'            => 'wpi_select2',
247
-            ) ); ?> <span id="wpinv_interval_text"><?php _e( 'day(s)', 'invoicing' );?></span></label>
248
-            <label class="wpinv-times" for="wpinv_recurring_limit"> <?php _e( 'for', 'invoicing' );?> <input class="small-text" type="number" value="<?php echo $times;?>" size="4" id="wpinv_recurring_limit" name="wpinv_recurring_limit" step="1" min="0"> <?php _e( 'time(s) <i>(select 0 for recurring forever until cancelled</i>)', 'invoicing' );?></label>
247
+            )); ?> <span id="wpinv_interval_text"><?php _e('day(s)', 'invoicing'); ?></span></label>
248
+            <label class="wpinv-times" for="wpinv_recurring_limit"> <?php _e('for', 'invoicing'); ?> <input class="small-text" type="number" value="<?php echo $times; ?>" size="4" id="wpinv_recurring_limit" name="wpinv_recurring_limit" step="1" min="0"> <?php _e('time(s) <i>(select 0 for recurring forever until cancelled</i>)', 'invoicing'); ?></label>
249 249
             <span class="clear wpi-trial-clr"></span>
250 250
             <label class="wpinv-free-trial" for="wpinv_free_trial">
251
-                <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked( true, (bool)$free_trial ); ?> /> 
252
-                <?php echo __( 'Offer free trial for', 'invoicing' ); ?>
251
+                <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked(true, (bool)$free_trial); ?> /> 
252
+                <?php echo __('Offer free trial for', 'invoicing'); ?>
253 253
             </label>
254 254
             <label class="wpinv-trial-interval" for="wpinv_trial_interval">
255
-                <input class="small-text" type="number" value="<?php echo $trial_interval;?>" size="4" id="wpinv_trial_interval" name="wpinv_trial_interval" step="1" min="1"> <select class="wpinv-select wpi_select2" id="wpinv_trial_period" name="wpinv_trial_period"><option value="D" <?php selected( 'D', $trial_period );?>><?php _e( 'day(s)', 'invoicing' ); ?></option><option value="W" <?php selected( 'W', $trial_period );?>><?php _e( 'week(s)', 'invoicing' ); ?></option><option value="M" <?php selected( 'M', $trial_period );?>><?php _e( 'month(s)', 'invoicing' ); ?></option><option value="Y" <?php selected( 'Y', $trial_period );?>><?php _e( 'year(s)', 'invoicing' ); ?></option></select>
255
+                <input class="small-text" type="number" value="<?php echo $trial_interval; ?>" size="4" id="wpinv_trial_interval" name="wpinv_trial_interval" step="1" min="1"> <select class="wpinv-select wpi_select2" id="wpinv_trial_period" name="wpinv_trial_period"><option value="D" <?php selected('D', $trial_period); ?>><?php _e('day(s)', 'invoicing'); ?></option><option value="W" <?php selected('W', $trial_period); ?>><?php _e('week(s)', 'invoicing'); ?></option><option value="M" <?php selected('M', $trial_period); ?>><?php _e('month(s)', 'invoicing'); ?></option><option value="Y" <?php selected('Y', $trial_period); ?>><?php _e('year(s)', 'invoicing'); ?></option></select>
256 256
             </label>
257
-            <?php do_action( 'wpinv_prices_metabox_recurring_fields', $item ); ?>
257
+            <?php do_action('wpinv_prices_metabox_recurring_fields', $item); ?>
258 258
         </p>
259
-        <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type( $post->ID ); ?>" />
260
-        <?php do_action( 'wpinv_item_price_field', $post->ID ); ?>
259
+        <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type($post->ID); ?>" />
260
+        <?php do_action('wpinv_item_price_field', $post->ID); ?>
261 261
         <?php
262 262
     }
263 263
 
264
-    public static function vat_rules( $post ) {
264
+    public static function vat_rules($post) {
265 265
         global $wpinv_euvat;
266 266
 
267
-        $rule_type = $wpinv_euvat->get_item_rule( $post->ID );
267
+        $rule_type = $wpinv_euvat->get_item_rule($post->ID);
268 268
         ?>
269
-        <p><label for="wpinv_vat_rules"><strong><?php _e( 'Select how VAT rules will be applied:', 'invoicing' );?></strong></label>&nbsp;&nbsp;&nbsp;
270
-        <?php echo wpinv_html_select( array(
269
+        <p><label for="wpinv_vat_rules"><strong><?php _e('Select how VAT rules will be applied:', 'invoicing'); ?></strong></label>&nbsp;&nbsp;&nbsp;
270
+        <?php echo wpinv_html_select(array(
271 271
                     'options'          => $wpinv_euvat->get_rules(),
272 272
                     'name'             => 'wpinv_vat_rules',
273 273
                     'id'               => 'wpinv_vat_rules',
@@ -275,19 +275,19 @@  discard block
 block discarded – undo
275 275
                     'show_option_all'  => false,
276 276
                     'show_option_none' => false,
277 277
                     'class'            => 'gdmbx2-text-medium wpinv-vat-rules wpi_select2',
278
-                ) ); ?>
278
+                )); ?>
279 279
         </p>
280
-        <p class="wpi-m0"><?php _e( 'When you select physical product rules, only consumers and businesses in your country will be charged VAT.  The VAT rate used will be the rate in your country.', 'invoicing' ); ?></p>
281
-        <p class="wpi-m0"><?php _e( 'If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer.  Only businesses in your country will be charged VAT.', 'invoicing' ); ?></p>
280
+        <p class="wpi-m0"><?php _e('When you select physical product rules, only consumers and businesses in your country will be charged VAT.  The VAT rate used will be the rate in your country.', 'invoicing'); ?></p>
281
+        <p class="wpi-m0"><?php _e('If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer.  Only businesses in your country will be charged VAT.', 'invoicing'); ?></p>
282 282
         <?php
283 283
     }
284 284
 
285
-    public static function vat_classes( $post ) {
285
+    public static function vat_classes($post) {
286 286
         global $wpinv_euvat;
287 287
         
288
-        $vat_class = $wpinv_euvat->get_item_class( $post->ID );
288
+        $vat_class = $wpinv_euvat->get_item_class($post->ID);
289 289
         ?>
290
-        <p><?php echo wpinv_html_select( array(
290
+        <p><?php echo wpinv_html_select(array(
291 291
                     'options'          => $wpinv_euvat->get_all_classes(),
292 292
                     'name'             => 'wpinv_vat_class',
293 293
                     'id'               => 'wpinv_vat_class',
@@ -295,18 +295,18 @@  discard block
 block discarded – undo
295 295
                     'show_option_all'  => false,
296 296
                     'show_option_none' => false,
297 297
                     'class'            => 'gdmbx2-text-medium wpinv-vat-class wpi_select2',
298
-                ) ); ?>
298
+                )); ?>
299 299
         </p>
300
-        <p class="wpi-m0"><?php _e( 'Select the VAT rate class to use for this invoice item.', 'invoicing' ); ?></p>
300
+        <p class="wpi-m0"><?php _e('Select the VAT rate class to use for this invoice item.', 'invoicing'); ?></p>
301 301
         <?php
302 302
     }
303 303
 
304
-    public static function item_info( $post ) {
305
-        $item_type = wpinv_get_item_type( $post->ID );
306
-        do_action( 'wpinv_item_info_metabox_before', $post );
304
+    public static function item_info($post) {
305
+        $item_type = wpinv_get_item_type($post->ID);
306
+        do_action('wpinv_item_info_metabox_before', $post);
307 307
         ?>
308
-        <p><label for="wpinv_item_type"><strong><?php _e( 'Type:', 'invoicing' );?></strong></label>&nbsp;&nbsp;&nbsp;
309
-        <?php echo wpinv_html_select( array(
308
+        <p><label for="wpinv_item_type"><strong><?php _e('Type:', 'invoicing'); ?></strong></label>&nbsp;&nbsp;&nbsp;
309
+        <?php echo wpinv_html_select(array(
310 310
                     'options'          => wpinv_get_item_types(),
311 311
                     'name'             => 'wpinv_item_type',
312 312
                     'id'               => 'wpinv_item_type',
@@ -314,114 +314,114 @@  discard block
 block discarded – undo
314 314
                     'show_option_all'  => false,
315 315
                     'show_option_none' => false,
316 316
                     'class'            => 'gdmbx2-text-medium wpinv-item-type wpi_select2',
317
-                ) ); ?>
317
+                )); ?>
318 318
         </p>
319
-        <p class="wpi-m0"><?php _e( 'Select item type.', 'invoicing' );?><br><?php _e( '<b>Standard:</b> Standard item type', 'invoicing' );?><br><?php _e( '<b>Fee:</b> Like Registration Fee, Sign up Fee etc.', 'invoicing' );?></p>
319
+        <p class="wpi-m0"><?php _e('Select item type.', 'invoicing'); ?><br><?php _e('<b>Standard:</b> Standard item type', 'invoicing'); ?><br><?php _e('<b>Fee:</b> Like Registration Fee, Sign up Fee etc.', 'invoicing'); ?></p>
320 320
         <?php
321
-        do_action( 'wpinv_item_info_metabox_after', $post );
321
+        do_action('wpinv_item_info_metabox_after', $post);
322 322
     }
323 323
 
324
-    public static function meta_values( $post ) {
325
-        $meta_keys = apply_filters( 'wpinv_show_meta_values_for_keys', array(
324
+    public static function meta_values($post) {
325
+        $meta_keys = apply_filters('wpinv_show_meta_values_for_keys', array(
326 326
             'type',
327 327
             'custom_id'
328
-        ) );
328
+        ));
329 329
 
330
-        if ( empty( $meta_keys ) ) {
330
+        if (empty($meta_keys)) {
331 331
             return;
332 332
         }
333 333
 
334
-        do_action( 'wpinv_meta_values_metabox_before', $post );
334
+        do_action('wpinv_meta_values_metabox_before', $post);
335 335
 
336
-        foreach ( $meta_keys as $meta_key ) {
336
+        foreach ($meta_keys as $meta_key) {
337 337
             ?>
338
-            <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta( $post->ID, '_wpinv_' . $meta_key, true ); ?></label></p>
338
+            <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta($post->ID, '_wpinv_' . $meta_key, true); ?></label></p>
339 339
             <?php 
340 340
         }
341 341
 
342
-        do_action( 'wpinv_meta_values_metabox_after', $post );
342
+        do_action('wpinv_meta_values_metabox_after', $post);
343 343
     }
344 344
 
345
-    public static function save( $post_id, $data, $post ) {
346
-        $invoice        = new WPInv_Invoice( $post_id );
345
+    public static function save($post_id, $data, $post) {
346
+        $invoice        = new WPInv_Invoice($post_id);
347 347
 
348 348
         // Billing
349
-        $first_name     = sanitize_text_field( $data['wpinv_first_name'] );
350
-        $last_name      = sanitize_text_field( $data['wpinv_last_name'] );
351
-        $company        = sanitize_text_field( $data['wpinv_company'] );
352
-        $vat_number     = sanitize_text_field( $data['wpinv_vat_number'] );
353
-        $phone          = sanitize_text_field( $data['wpinv_phone'] );
354
-        $address        = sanitize_text_field( $data['wpinv_address'] );
355
-        $city           = sanitize_text_field( $data['wpinv_city'] );
356
-        $zip            = sanitize_text_field( $data['wpinv_zip'] );
357
-        $country        = sanitize_text_field( $data['wpinv_country'] );
358
-        $state          = sanitize_text_field( $data['wpinv_state'] );
349
+        $first_name     = sanitize_text_field($data['wpinv_first_name']);
350
+        $last_name      = sanitize_text_field($data['wpinv_last_name']);
351
+        $company        = sanitize_text_field($data['wpinv_company']);
352
+        $vat_number     = sanitize_text_field($data['wpinv_vat_number']);
353
+        $phone          = sanitize_text_field($data['wpinv_phone']);
354
+        $address        = sanitize_text_field($data['wpinv_address']);
355
+        $city           = sanitize_text_field($data['wpinv_city']);
356
+        $zip            = sanitize_text_field($data['wpinv_zip']);
357
+        $country        = sanitize_text_field($data['wpinv_country']);
358
+        $state          = sanitize_text_field($data['wpinv_state']);
359 359
 
360 360
         // Details
361
-        $status         = sanitize_text_field( $data['wpinv_status'] );
362
-        $old_status     = !empty( $data['original_post_status'] ) ? sanitize_text_field( $data['original_post_status'] ) : $status;
363
-        $number         = sanitize_text_field( $data['wpinv_number'] );
364
-        $due_date       = isset( $data['wpinv_due_date'] ) ? sanitize_text_field( $data['wpinv_due_date'] ) : '';
361
+        $status         = sanitize_text_field($data['wpinv_status']);
362
+        $old_status     = !empty($data['original_post_status']) ? sanitize_text_field($data['original_post_status']) : $status;
363
+        $number         = sanitize_text_field($data['wpinv_number']);
364
+        $due_date       = isset($data['wpinv_due_date']) ? sanitize_text_field($data['wpinv_due_date']) : '';
365 365
         //$discounts      = sanitize_text_field( $data['wpinv_discounts'] );
366 366
         //$discount       = sanitize_text_field( $data['wpinv_discount'] );
367 367
 
368
-        $ip             = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip();
368
+        $ip = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip();
369 369
 
370
-        $invoice->set( 'due_date', $due_date );
371
-        $invoice->set( 'first_name', $first_name );
372
-        $invoice->set( 'last_name', $last_name );
373
-        $invoice->set( 'company', $company );
374
-        $invoice->set( 'vat_number', $vat_number );
375
-        $invoice->set( 'phone', $phone );
376
-        $invoice->set( 'address', $address );
377
-        $invoice->set( 'city', $city );
378
-        $invoice->set( 'zip', $zip );
379
-        $invoice->set( 'country', $country );
380
-        $invoice->set( 'state', $state );
381
-        $invoice->set( 'status', $status );
370
+        $invoice->set('due_date', $due_date);
371
+        $invoice->set('first_name', $first_name);
372
+        $invoice->set('last_name', $last_name);
373
+        $invoice->set('company', $company);
374
+        $invoice->set('vat_number', $vat_number);
375
+        $invoice->set('phone', $phone);
376
+        $invoice->set('address', $address);
377
+        $invoice->set('city', $city);
378
+        $invoice->set('zip', $zip);
379
+        $invoice->set('country', $country);
380
+        $invoice->set('state', $state);
381
+        $invoice->set('status', $status);
382 382
         //$invoice->set( 'number', $number );
383 383
         //$invoice->set( 'discounts', $discounts );
384 384
         //$invoice->set( 'discount', $discount );
385
-        $invoice->set( 'ip', $ip );
385
+        $invoice->set('ip', $ip);
386 386
         $invoice->old_status = $_POST['original_post_status'];
387 387
         $invoice->currency = wpinv_get_currency();
388
-        if ( !empty( $data['wpinv_gateway'] ) ) {
389
-            $invoice->set( 'gateway', sanitize_text_field( $data['wpinv_gateway'] ) );
388
+        if (!empty($data['wpinv_gateway'])) {
389
+            $invoice->set('gateway', sanitize_text_field($data['wpinv_gateway']));
390 390
         }
391 391
         $saved = $invoice->save();
392 392
 
393 393
         // Check for payment notes
394
-        if ( !empty( $data['invoice_note'] ) ) {
395
-            $note               = wp_kses( $data['invoice_note'], array() );
396
-            $note_type          = sanitize_text_field( $data['invoice_note_type'] );
394
+        if (!empty($data['invoice_note'])) {
395
+            $note               = wp_kses($data['invoice_note'], array());
396
+            $note_type          = sanitize_text_field($data['invoice_note_type']);
397 397
             $is_customer_note   = $note_type == 'customer' ? 1 : 0;
398 398
 
399
-            wpinv_insert_payment_note( $invoice->ID, $note, $is_customer_note );
399
+            wpinv_insert_payment_note($invoice->ID, $note, $is_customer_note);
400 400
         }
401 401
 
402 402
         // Update user address if empty.
403
-        if ( $saved && !empty( $invoice ) ) {
404
-            if ( $user_id = $invoice->get_user_id() ) {
405
-                $user_address = wpinv_get_user_address( $user_id, false );
403
+        if ($saved && !empty($invoice)) {
404
+            if ($user_id = $invoice->get_user_id()) {
405
+                $user_address = wpinv_get_user_address($user_id, false);
406 406
 
407 407
                 if (empty($user_address['first_name'])) {
408
-                    update_user_meta( $user_id, '_wpinv_first_name', $first_name );
409
-                    update_user_meta( $user_id, '_wpinv_last_name', $last_name );
408
+                    update_user_meta($user_id, '_wpinv_first_name', $first_name);
409
+                    update_user_meta($user_id, '_wpinv_last_name', $last_name);
410 410
                 } else if (empty($user_address['last_name']) && $user_address['first_name'] == $first_name) {
411
-                    update_user_meta( $user_id, '_wpinv_last_name', $last_name );
411
+                    update_user_meta($user_id, '_wpinv_last_name', $last_name);
412 412
                 }
413 413
 
414 414
                 if (empty($user_address['address']) || empty($user_address['city']) || empty($user_address['state']) || empty($user_address['country'])) {
415
-                    update_user_meta( $user_id, '_wpinv_address', $address );
416
-                    update_user_meta( $user_id, '_wpinv_city', $city );
417
-                    update_user_meta( $user_id, '_wpinv_state', $state );
418
-                    update_user_meta( $user_id, '_wpinv_country', $country );
419
-                    update_user_meta( $user_id, '_wpinv_zip', $zip );
420
-                    update_user_meta( $user_id, '_wpinv_phone', $phone );
415
+                    update_user_meta($user_id, '_wpinv_address', $address);
416
+                    update_user_meta($user_id, '_wpinv_city', $city);
417
+                    update_user_meta($user_id, '_wpinv_state', $state);
418
+                    update_user_meta($user_id, '_wpinv_country', $country);
419
+                    update_user_meta($user_id, '_wpinv_zip', $zip);
420
+                    update_user_meta($user_id, '_wpinv_phone', $phone);
421 421
                 }
422 422
             }
423 423
 
424
-            do_action( 'wpinv_invoice_metabox_saved', $invoice );
424
+            do_action('wpinv_invoice_metabox_saved', $invoice);
425 425
         }
426 426
 
427 427
         return $saved;
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-mb-invoice-notes.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,39 +1,39 @@
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7 7
 class WPInv_Meta_Box_Notes {
8
-    public static function output( $post ) {
8
+    public static function output($post) {
9 9
         global $post;
10 10
 
11
-        $notes = wpinv_get_invoice_notes( $post->ID );
11
+        $notes = wpinv_get_invoice_notes($post->ID);
12 12
 
13 13
         echo '<ul class="invoice_notes">';
14 14
 
15
-        if ( $notes ) {
16
-            foreach( $notes as $note ) {
17
-                wpinv_get_invoice_note_line_item( $note );
15
+        if ($notes) {
16
+            foreach ($notes as $note) {
17
+                wpinv_get_invoice_note_line_item($note);
18 18
             }
19 19
 
20 20
         } else {
21
-            echo '<li>' . __( 'There are no notes yet.', 'invoicing' ) . '</li>';
21
+            echo '<li>' . __('There are no notes yet.', 'invoicing') . '</li>';
22 22
         }
23 23
 
24 24
         echo '</ul>';
25 25
         ?>
26 26
         <div class="add_note">
27
-            <h4><?php _e( 'Add note', 'invoicing' ); ?></h4>
27
+            <h4><?php _e('Add note', 'invoicing'); ?></h4>
28 28
             <p>
29 29
                 <textarea type="text" name="invoice_note" id="add_invoice_note" class="input-text" cols="20" rows="5"></textarea>
30 30
             </p>
31 31
             <p>
32 32
                 <select name="invoice_note_type" id="invoice_note_type" class="wpi_select2">
33
-                    <option value=""><?php _e( 'Private note', 'invoicing' ); ?></option>
34
-                    <option value="customer"><?php _e( 'Note to customer', 'invoicing' ); ?></option>
33
+                    <option value=""><?php _e('Private note', 'invoicing'); ?></option>
34
+                    <option value="customer"><?php _e('Note to customer', 'invoicing'); ?></option>
35 35
                 </select>
36
-                <a href="#" class="add_note button"><?php _e( 'Add', 'invoicing' ); ?></a> <span class="description"><?php _e( 'Add a note for your reference, or add a customer note (the user will be notified).', 'invoicing' ); ?></span>
36
+                <a href="#" class="add_note button"><?php _e('Add', 'invoicing'); ?></a> <span class="description"><?php _e('Add a note for your reference, or add a customer note (the user will be notified).', 'invoicing'); ?></span>
37 37
             </p>
38 38
         </div>
39 39
         <?php
Please login to merge, or discard this patch.
includes/admin/subscriptions.php 1 patch
Spacing   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 function wpinv_subscriptions_page() {
10 10
 
11
-	if ( ! empty( $_GET['id'] ) ) {
11
+	if (!empty($_GET['id'])) {
12 12
 
13 13
         wpinv_recurring_subscription_details();
14 14
 
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 	<div class="wrap">
20 20
 
21 21
 		<h1>
22
-			<?php _e( 'Subscriptions', 'invoicing' ); ?>
22
+			<?php _e('Subscriptions', 'invoicing'); ?>
23 23
 		</h1>
24 24
 		<?php
25 25
 		$subscribers_table = new WPInv_Subscription_Reports_Table();
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 			<input type="hidden" name="post_type" value="download" />
32 32
 			<input type="hidden" name="page" value="wpinv-subscriptions" />
33 33
 			<?php $subscribers_table->views(); ?>
34
-			<?php $subscribers_table->search_box( __( 'Search', 'wpinvoicing' ), 'subscriptions' ); ?>
34
+			<?php $subscribers_table->search_box(__('Search', 'wpinvoicing'), 'subscriptions'); ?>
35 35
 			<?php $subscribers_table->display(); ?>
36 36
 
37 37
 		</form>
@@ -49,34 +49,34 @@  discard block
 block discarded – undo
49 49
 
50 50
 	$render = true;
51 51
 
52
-	if ( ! current_user_can( 'manage_invoicing' ) ) {
53
-		die( __( 'You are not permitted to view this data.', 'invoicing' ) );
52
+	if (!current_user_can('manage_invoicing')) {
53
+		die(__('You are not permitted to view this data.', 'invoicing'));
54 54
 	}
55 55
 
56
-	if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
57
-        die( __( 'Invalid subscription ID Provided.', 'invoicing' ) );
56
+	if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
57
+        die(__('Invalid subscription ID Provided.', 'invoicing'));
58 58
 	}
59 59
 
60
-	$sub_id  = (int) $_GET['id'];
61
-	$sub     = new WPInv_Subscription( $sub_id );
60
+	$sub_id  = (int)$_GET['id'];
61
+	$sub     = new WPInv_Subscription($sub_id);
62 62
 
63
-	if ( empty( $sub ) ) {
64
-		die( __( 'Invalid subscription ID Provided.', 'invoicing' ) );
63
+	if (empty($sub)) {
64
+		die(__('Invalid subscription ID Provided.', 'invoicing'));
65 65
 	}
66 66
 
67 67
 	?>
68 68
 	<div class="wrap">
69
-		<h2><?php _e( 'Subscription Details', 'invoicing' ); ?></h2>
69
+		<h2><?php _e('Subscription Details', 'invoicing'); ?></h2>
70 70
 
71
-		<?php if ( $sub ) : ?>
71
+		<?php if ($sub) : ?>
72 72
 
73 73
 			<div id="wpinv-item-card-wrapper">
74 74
 
75
-				<?php do_action( 'wpinv_subscription_card_top', $sub ); ?>
75
+				<?php do_action('wpinv_subscription_card_top', $sub); ?>
76 76
 
77 77
 				<div class="info-wrapper item-section">
78 78
 
79
-					<form id="edit-item-info" method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $sub->id ); ?>">
79
+					<form id="edit-item-info" method="post" action="<?php echo admin_url('admin.php?page=wpinv-subscriptions&id=' . $sub->id); ?>">
80 80
 
81 81
 						<div class="item-info">
82 82
 
@@ -84,124 +84,124 @@  discard block
 block discarded – undo
84 84
 								<tbody>
85 85
 									<tr>
86 86
 										<td class="row-title">
87
-											<label for="tablecell"><?php _e( 'Billing Cycle:', 'invoicing' ); ?></label>
87
+											<label for="tablecell"><?php _e('Billing Cycle:', 'invoicing'); ?></label>
88 88
 										</td>
89 89
 										<td>
90 90
 											<?php
91
-											$frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $sub->period, $sub->frequency );
92
-											$billing   = wpinv_price( wpinv_format_amount( $sub->recurring_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ) . ' / ' . $frequency;
93
-											$initial   = wpinv_price( wpinv_format_amount( $sub->initial_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) );
94
-											printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing );
91
+											$frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($sub->period, $sub->frequency);
92
+											$billing   = wpinv_price(wpinv_format_amount($sub->recurring_amount), wpinv_get_invoice_currency_code($sub->parent_payment_id)) . ' / ' . $frequency;
93
+											$initial   = wpinv_price(wpinv_format_amount($sub->initial_amount), wpinv_get_invoice_currency_code($sub->parent_payment_id));
94
+											printf(_x('%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing'), $initial, $billing);
95 95
 											?>
96 96
 										</td>
97 97
 									</tr>
98 98
 									<tr>
99 99
 										<td class="row-title">
100
-											<label for="tablecell"><?php _e( 'Times Billed:', 'invoicing' ); ?></label>
100
+											<label for="tablecell"><?php _e('Times Billed:', 'invoicing'); ?></label>
101 101
 										</td>
102
-										<td><?php echo $sub->get_times_billed() . ' / ' . ( ( $sub->bill_times == 0 ) ? 'Until Cancelled' : $sub->bill_times ); ?></td>
102
+										<td><?php echo $sub->get_times_billed() . ' / ' . (($sub->bill_times == 0) ? 'Until Cancelled' : $sub->bill_times); ?></td>
103 103
 									</tr>
104 104
 									<tr>
105 105
 										<td class="row-title">
106
-											<label for="tablecell"><?php _e( 'Customer:', 'invoicing' ); ?></label>
106
+											<label for="tablecell"><?php _e('Customer:', 'invoicing'); ?></label>
107 107
 										</td>
108 108
 										<td>
109
-											<?php $subscriber = get_userdata( $sub->customer_id ); ?>
110
-											<a href="<?php echo esc_url( get_edit_user_link( $sub->customer_id ) ); ?>" target="_blank"><?php echo ! empty( $subscriber->display_name ) ? $subscriber->display_name : $subscriber->user_email; ?></a>
109
+											<?php $subscriber = get_userdata($sub->customer_id); ?>
110
+											<a href="<?php echo esc_url(get_edit_user_link($sub->customer_id)); ?>" target="_blank"><?php echo !empty($subscriber->display_name) ? $subscriber->display_name : $subscriber->user_email; ?></a>
111 111
 										</td>
112 112
 									</tr>
113 113
 									<tr>
114 114
 										<td class="row-title">
115
-											<label for="tablecell"><?php _e( 'Initial Invoice:', 'invoicing' ); ?></label>
115
+											<label for="tablecell"><?php _e('Initial Invoice:', 'invoicing'); ?></label>
116 116
 										</td>
117 117
 										<td>
118
-                                            <a target="_blank" title="<?php _e( 'View invoice', 'invoicing' ); ?>" href="<?php echo esc_url( get_permalink( $sub->parent_payment_id ) ); ?>"><?php echo wpinv_get_invoice_number( $sub->parent_payment_id ); ?></a>&nbsp;&nbsp;&nbsp;<?php echo wp_sprintf( __( '( ID: %s )', 'invoicing' ), '<a title="' . esc_attr( __( 'View invoice details', 'invoicing' ) ) . '" href="' . get_edit_post_link( $sub->parent_payment_id ) . '" target="_blank">' . $sub->parent_payment_id . '</a>' ); ?></td>
118
+                                            <a target="_blank" title="<?php _e('View invoice', 'invoicing'); ?>" href="<?php echo esc_url(get_permalink($sub->parent_payment_id)); ?>"><?php echo wpinv_get_invoice_number($sub->parent_payment_id); ?></a>&nbsp;&nbsp;&nbsp;<?php echo wp_sprintf(__('( ID: %s )', 'invoicing'), '<a title="' . esc_attr(__('View invoice details', 'invoicing')) . '" href="' . get_edit_post_link($sub->parent_payment_id) . '" target="_blank">' . $sub->parent_payment_id . '</a>'); ?></td>
119 119
 									</tr>
120 120
 									<tr>
121 121
 										<td class="row-title">
122
-											<label for="tablecell"><?php _e( 'Item:', 'invoicing' ); ?></label>
122
+											<label for="tablecell"><?php _e('Item:', 'invoicing'); ?></label>
123 123
 										</td>
124 124
 										<td>
125 125
 											<?php
126
-                                            echo wpinv_item_dropdown( array(
126
+                                            echo wpinv_item_dropdown(array(
127 127
                                                 'name'              => 'product_id',
128 128
                                                 'id'                => 'wpinv_invoice_item',
129 129
                                                 'with_packages'     => false,
130 130
                                                 'show_recurring'    => true,
131 131
                                                 'selected'          => $sub->product_id,
132 132
                                                 'class'             => 'wpinv-sub-product-id wpi_select2',
133
-                                            ) );
133
+                                            ));
134 134
 
135 135
                                             ?>
136
-											<a href="<?php echo esc_url( add_query_arg( array(
136
+											<a href="<?php echo esc_url(add_query_arg(array(
137 137
 													'post'   => $sub->product_id,
138 138
 													'action' => 'edit'
139
-												), admin_url( 'post.php' ) ) ); ?>" target="_blank"><?php _e( 'View Item', 'invoicing' ) ; ?></a>
139
+												), admin_url('post.php'))); ?>" target="_blank"><?php _e('View Item', 'invoicing'); ?></a>
140 140
 										</td>
141 141
 									</tr>
142 142
 									<tr>
143 143
 										<td class="row-title">
144
-											<label for="tablecell"><?php _e( 'Payment Method:', 'invoicing' ); ?></label>
144
+											<label for="tablecell"><?php _e('Payment Method:', 'invoicing'); ?></label>
145 145
 										</td>
146
-										<td><?php echo wpinv_get_gateway_admin_label( wpinv_get_payment_gateway( $sub->parent_payment_id ) ); ?></td>
146
+										<td><?php echo wpinv_get_gateway_admin_label(wpinv_get_payment_gateway($sub->parent_payment_id)); ?></td>
147 147
 									</tr>
148 148
 									<tr>
149 149
 										<td class="row-title">
150
-											<label for="tablecell"><?php _e( 'Profile ID:', 'invoicing' ); ?></label>
150
+											<label for="tablecell"><?php _e('Profile ID:', 'invoicing'); ?></label>
151 151
 										</td>
152 152
 										<td>
153 153
 											<span class="wpinv-sub-profile-id">
154
-												<?php echo apply_filters( 'wpinv_subscription_profile_link_' . $sub->gateway, $sub->profile_id, $sub ); ?>
154
+												<?php echo apply_filters('wpinv_subscription_profile_link_' . $sub->gateway, $sub->profile_id, $sub); ?>
155 155
 											</span>
156
-											<input type="text" name="profile_id" class="hidden wpinv-sub-profile-id" value="<?php echo esc_attr( $sub->profile_id ); ?>" />
156
+											<input type="text" name="profile_id" class="hidden wpinv-sub-profile-id" value="<?php echo esc_attr($sub->profile_id); ?>" />
157 157
 											<span>&nbsp;&ndash;&nbsp;</span>
158
-											<a href="#" class="wpinv-edit-sub-profile-id"><?php _e( 'Edit', 'invoicing' ); ?></a>
158
+											<a href="#" class="wpinv-edit-sub-profile-id"><?php _e('Edit', 'invoicing'); ?></a>
159 159
 										</td>
160 160
 									</tr>
161 161
 									<tr>
162 162
 										<td class="row-title">
163
-											<label for="tablecell"><?php _e( 'Transaction ID:', 'invoicing' ); ?></label>
163
+											<label for="tablecell"><?php _e('Transaction ID:', 'invoicing'); ?></label>
164 164
 										</td>
165 165
 										<td>
166
-											<span class="wpinv-sub-transaction-id"><?php echo apply_filters( 'wpinv_subscription_transaction_link_' . $sub->gateway, $sub->get_transaction_id(), $sub ); ?></span>
167
-											<input type="text" name="transaction_id" class="hidden wpinv-sub-transaction-id" value="<?php echo esc_attr( $sub->get_transaction_id() ); ?>" />
166
+											<span class="wpinv-sub-transaction-id"><?php echo apply_filters('wpinv_subscription_transaction_link_' . $sub->gateway, $sub->get_transaction_id(), $sub); ?></span>
167
+											<input type="text" name="transaction_id" class="hidden wpinv-sub-transaction-id" value="<?php echo esc_attr($sub->get_transaction_id()); ?>" />
168 168
 											<span>&nbsp;&ndash;&nbsp;</span>
169
-											<a href="#" class="wpinv-edit-sub-transaction-id"><?php _e( 'Edit', 'invoicing' ); ?></a>
169
+											<a href="#" class="wpinv-edit-sub-transaction-id"><?php _e('Edit', 'invoicing'); ?></a>
170 170
 										</td>
171 171
 									</tr>
172 172
 									<tr>
173 173
 										<td class="row-title">
174
-											<label for="tablecell"><?php _e( 'Date Created:', 'invoicing' ); ?></label>
174
+											<label for="tablecell"><?php _e('Date Created:', 'invoicing'); ?></label>
175 175
 										</td>
176
-										<td><?php echo date_i18n( get_option( 'date_format' ), strtotime( $sub->created, current_time( 'timestamp' ) ) ); ?></td>
176
+										<td><?php echo date_i18n(get_option('date_format'), strtotime($sub->created, current_time('timestamp'))); ?></td>
177 177
 									</tr>
178 178
 									<tr>
179 179
 										<td class="row-title">
180 180
 											<label for="tablecell">
181
-												<?php if( 'trialling' == $sub->status ) : ?>
182
-													<?php _e( 'Trialling Until:', 'invoicing' ); ?>
181
+												<?php if ('trialling' == $sub->status) : ?>
182
+													<?php _e('Trialling Until:', 'invoicing'); ?>
183 183
 												<?php else: ?>
184
-													<?php _e( 'Expiration Date:', 'invoicing' ); ?>
184
+													<?php _e('Expiration Date:', 'invoicing'); ?>
185 185
 												<?php endif; ?>
186 186
 											</label>
187 187
 										</td>
188 188
 										<td>
189
-											<span class="wpinv-sub-expiration"><?php echo date_i18n( get_option( 'date_format' ), strtotime( $sub->expiration, current_time( 'timestamp' ) ) ); ?></span>
189
+											<span class="wpinv-sub-expiration"><?php echo date_i18n(get_option('date_format'), strtotime($sub->expiration, current_time('timestamp'))); ?></span>
190 190
 										</td>
191 191
 									</tr>
192 192
 									<tr>
193 193
 										<td class="row-title">
194
-											<label for="tablecell"><?php _e( 'Subscription Status:', 'invoicing' ); ?></label>
194
+											<label for="tablecell"><?php _e('Subscription Status:', 'invoicing'); ?></label>
195 195
 										</td>
196 196
 										<td>
197 197
 											<select name="status" class="wpi_select2">
198
-												<option value="pending"<?php selected( 'pending', $sub->status ); ?>><?php _e( 'Pending', 'invoicing' ); ?></option>
199
-												<option value="active"<?php selected( 'active', $sub->status ); ?>><?php _e( 'Active', 'invoicing' ); ?></option>
200
-												<option value="cancelled"<?php selected( 'cancelled', $sub->status ); ?>><?php _e( 'Cancelled', 'invoicing' ); ?></option>
201
-												<option value="expired"<?php selected( 'expired', $sub->status ); ?>><?php _e( 'Expired', 'invoicing' ); ?></option>
202
-												<option value="trialling"<?php selected( 'trialling', $sub->status ); ?>><?php _e( 'Trialling', 'invoicing' ); ?></option>
203
-												<option value="failing"<?php selected( 'failing', $sub->status ); ?>><?php _e( 'Failing', 'invoicing' ); ?></option>
204
-												<option value="completed"<?php selected( 'completed', $sub->status ); ?>><?php _e( 'Completed', 'invoicing' ); ?></option>
198
+												<option value="pending"<?php selected('pending', $sub->status); ?>><?php _e('Pending', 'invoicing'); ?></option>
199
+												<option value="active"<?php selected('active', $sub->status); ?>><?php _e('Active', 'invoicing'); ?></option>
200
+												<option value="cancelled"<?php selected('cancelled', $sub->status); ?>><?php _e('Cancelled', 'invoicing'); ?></option>
201
+												<option value="expired"<?php selected('expired', $sub->status); ?>><?php _e('Expired', 'invoicing'); ?></option>
202
+												<option value="trialling"<?php selected('trialling', $sub->status); ?>><?php _e('Trialling', 'invoicing'); ?></option>
203
+												<option value="failing"<?php selected('failing', $sub->status); ?>><?php _e('Failing', 'invoicing'); ?></option>
204
+												<option value="completed"<?php selected('completed', $sub->status); ?>><?php _e('Completed', 'invoicing'); ?></option>
205 205
 											</select>
206 206
 										</td>
207 207
 									</tr>
@@ -209,79 +209,79 @@  discard block
 block discarded – undo
209 209
 							</table>
210 210
 						</div>
211 211
 						<div id="wpinv-sub-notices">
212
-							<div class="notice notice-info inline hidden" id="wpinv-sub-product-update-notice"><p><?php _e( 'Changing the product assigned will not automatically adjust any pricing.', 'invoicing' ); ?></p></div>
213
-							<div class="notice notice-warning inline hidden" id="wpinv-sub-profile-id-update-notice"><p><?php _e( 'Changing the profile ID can result in renewals not being processed. Do this with caution.', 'invoicing' ); ?></p></div>
212
+							<div class="notice notice-info inline hidden" id="wpinv-sub-product-update-notice"><p><?php _e('Changing the product assigned will not automatically adjust any pricing.', 'invoicing'); ?></p></div>
213
+							<div class="notice notice-warning inline hidden" id="wpinv-sub-profile-id-update-notice"><p><?php _e('Changing the profile ID can result in renewals not being processed. Do this with caution.', 'invoicing'); ?></p></div>
214 214
 						</div>
215 215
 						<div id="item-edit-actions" class="edit-item" style="float:right; margin: 10px 0 0; display: block;">
216
-							<?php wp_nonce_field( 'wpinv-recurring-update', 'wpinv-recurring-update-nonce', false, true ); ?>
217
-							<input type="submit" name="wpinv_update_subscription" id="wpinv_update_subscription" class="button button-primary" value="<?php _e( 'Update Subscription', 'invoicing' ); ?>"/>
218
-							<input type="hidden" name="sub_id" value="<?php echo absint( $sub->id ); ?>" />
219
-							<?php if( $sub->can_cancel() ) : ?>
220
-								<a class="button button-primary" href="<?php echo $sub->get_cancel_url(); ?>" ><?php _e( 'Cancel Subscription', 'invoicing' ); ?></a>
216
+							<?php wp_nonce_field('wpinv-recurring-update', 'wpinv-recurring-update-nonce', false, true); ?>
217
+							<input type="submit" name="wpinv_update_subscription" id="wpinv_update_subscription" class="button button-primary" value="<?php _e('Update Subscription', 'invoicing'); ?>"/>
218
+							<input type="hidden" name="sub_id" value="<?php echo absint($sub->id); ?>" />
219
+							<?php if ($sub->can_cancel()) : ?>
220
+								<a class="button button-primary" href="<?php echo $sub->get_cancel_url(); ?>" ><?php _e('Cancel Subscription', 'invoicing'); ?></a>
221 221
 							<?php endif; ?>
222
-							&nbsp;<input type="submit" name="wpinv_delete_subscription" class="wpinv-delete-subscription button" value="<?php _e( 'Delete Subscription', 'invoicing' ); ?>"/>
222
+							&nbsp;<input type="submit" name="wpinv_delete_subscription" class="wpinv-delete-subscription button" value="<?php _e('Delete Subscription', 'invoicing'); ?>"/>
223 223
 						</div>
224 224
 
225 225
 					</form>
226 226
 				</div>
227 227
 
228
-				<?php do_action( 'wpinv_subscription_before_stats', $sub ); ?>
228
+				<?php do_action('wpinv_subscription_before_stats', $sub); ?>
229 229
 
230
-				<?php do_action( 'wpinv_subscription_before_tables_wrapper', $sub ); ?>
230
+				<?php do_action('wpinv_subscription_before_tables_wrapper', $sub); ?>
231 231
 
232 232
 				<div id="item-tables-wrapper" class="item-section">
233 233
 
234
-					<?php do_action( 'wpinv_subscription_before_tables', $sub ); ?>
234
+					<?php do_action('wpinv_subscription_before_tables', $sub); ?>
235 235
 
236
-					<h3><?php _e( 'Renewal Payments:', 'invoicing' ); ?></h3>
236
+					<h3><?php _e('Renewal Payments:', 'invoicing'); ?></h3>
237 237
 					<?php $payments = $sub->get_child_payments(); ?>
238
-					<?php if ( 'manual' == $sub->gateway ) : ?>
239
-						<p><strong><?php _e( 'Note:', 'invoicing' ); ?></strong> <?php _e( 'Subscriptions purchased with the Test Payment gateway will not renew automatically.', 'invoicing' ); ?></p>
238
+					<?php if ('manual' == $sub->gateway) : ?>
239
+						<p><strong><?php _e('Note:', 'invoicing'); ?></strong> <?php _e('Subscriptions purchased with the Test Payment gateway will not renew automatically.', 'invoicing'); ?></p>
240 240
 					<?php endif; ?>
241 241
 					<table class="wp-list-table widefat striped payments">
242 242
 						<thead>
243 243
 						<tr>
244
-							<th><?php _e( 'ID', 'invoicing' ); ?></th>
245
-							<th><?php _e( 'Amount', 'invoicing' ); ?></th>
246
-							<th><?php _e( 'Date', 'invoicing' ); ?></th>
247
-							<th><?php _e( 'Status', 'invoicing' ); ?></th>
248
-                            <th><?php _e( 'Invoice', 'invoicing' ); ?></th>
249
-							<th class="column-wpi_actions"><?php _e( 'Actions', 'invoicing' ); ?></th>
244
+							<th><?php _e('ID', 'invoicing'); ?></th>
245
+							<th><?php _e('Amount', 'invoicing'); ?></th>
246
+							<th><?php _e('Date', 'invoicing'); ?></th>
247
+							<th><?php _e('Status', 'invoicing'); ?></th>
248
+                            <th><?php _e('Invoice', 'invoicing'); ?></th>
249
+							<th class="column-wpi_actions"><?php _e('Actions', 'invoicing'); ?></th>
250 250
 						</tr>
251 251
 						</thead>
252 252
 						<tbody>
253
-						<?php if ( ! empty( $payments ) ) : ?>
254
-							<?php foreach ( $payments as $payment ) : $invoice = wpinv_get_invoice( $payment->ID ); if ( empty( $invoice->ID ) ) continue; ?>
253
+						<?php if (!empty($payments)) : ?>
254
+							<?php foreach ($payments as $payment) : $invoice = wpinv_get_invoice($payment->ID); if (empty($invoice->ID)) continue; ?>
255 255
 								<tr>
256 256
 									<td><?php echo $payment->ID; ?></td>
257
-									<td><?php echo $invoice->get_total( true ); ?></td>
257
+									<td><?php echo $invoice->get_total(true); ?></td>
258 258
 									<td><?php echo $invoice->get_invoice_date(); ?></td>
259
-									<td><?php echo $invoice->get_status( true ); ?></td>
259
+									<td><?php echo $invoice->get_status(true); ?></td>
260 260
 									<td>
261
-										<a target="_blank" title="<?php _e( 'View invoice', 'invoicing' ); ?>" href="<?php echo esc_url( get_permalink( $payment->ID ) ); ?>"><?php echo $invoice->get_number(); ?></a>
262
-										<?php do_action( 'wpinv_subscription_payments_actions', $sub, $payment ); ?>
261
+										<a target="_blank" title="<?php _e('View invoice', 'invoicing'); ?>" href="<?php echo esc_url(get_permalink($payment->ID)); ?>"><?php echo $invoice->get_number(); ?></a>
262
+										<?php do_action('wpinv_subscription_payments_actions', $sub, $payment); ?>
263 263
 									</td>
264 264
 									<td class="column-wpi_actions">
265
-										<a title="<?php echo esc_attr( wp_sprintf( __( 'View details for invoice: %s', 'invoicing' ), $invoice->get_number() ) ); ?>" href="<?php echo get_edit_post_link( $payment->ID ); ?>"><?php _e( 'View Details', 'invoicing' ); ?>
265
+										<a title="<?php echo esc_attr(wp_sprintf(__('View details for invoice: %s', 'invoicing'), $invoice->get_number())); ?>" href="<?php echo get_edit_post_link($payment->ID); ?>"><?php _e('View Details', 'invoicing'); ?>
266 266
 										</a>
267
-										<?php do_action( 'wpinv_subscription_payments_actions', $sub, $payment ); ?>
267
+										<?php do_action('wpinv_subscription_payments_actions', $sub, $payment); ?>
268 268
 									</td>
269 269
 								</tr>
270 270
 							<?php endforeach; ?>
271 271
 						<?php else: ?>
272 272
 							<tr>
273
-								<td colspan="5"><?php _e( 'No Invoices Found.', 'invoicing' ); ?></td>
273
+								<td colspan="5"><?php _e('No Invoices Found.', 'invoicing'); ?></td>
274 274
 							</tr>
275 275
 						<?php endif; ?>
276 276
 						</tbody>
277 277
 						<tfoot></tfoot>
278 278
 					</table>
279 279
 
280
-					<?php do_action( 'wpinv_subscription_after_tables', $sub ); ?>
280
+					<?php do_action('wpinv_subscription_after_tables', $sub); ?>
281 281
 
282 282
 				</div>
283 283
 
284
-				<?php do_action( 'wpinv_subscription_card_bottom', $sub ); ?>
284
+				<?php do_action('wpinv_subscription_card_bottom', $sub); ?>
285 285
 			</div>
286 286
 
287 287
 		<?php endif; ?>
@@ -299,36 +299,36 @@  discard block
 block discarded – undo
299 299
  */
300 300
 function wpinv_recurring_process_subscription_update() {
301 301
 
302
-	if( empty( $_POST['sub_id'] ) ) {
302
+	if (empty($_POST['sub_id'])) {
303 303
 		return;
304 304
 	}
305 305
 
306
-	if( empty( $_POST['wpinv_update_subscription'] ) ) {
306
+	if (empty($_POST['wpinv_update_subscription'])) {
307 307
 		return;
308 308
 	}
309 309
 
310
-	if( ! current_user_can( 'manage_invoicing') ) {
310
+	if (!current_user_can('manage_invoicing')) {
311 311
 		return;
312 312
 	}
313 313
 
314
-	if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) {
315
-		wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
314
+	if (!wp_verify_nonce($_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update')) {
315
+		wp_die(__('Nonce verification failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
316 316
 	}
317 317
 
318
-	$profile_id      = sanitize_text_field( $_POST['profile_id'] );
319
-	$transaction_id  = sanitize_text_field( $_POST['transaction_id'] );
320
-	$product_id      = absint( $_POST['product_id'] );
321
-	$subscription    = new WPInv_Subscription( absint( $_POST['sub_id'] ) );
322
-	$subscription->update( array(
323
-		'status'         => sanitize_text_field( $_POST['status'] ),
318
+	$profile_id      = sanitize_text_field($_POST['profile_id']);
319
+	$transaction_id  = sanitize_text_field($_POST['transaction_id']);
320
+	$product_id      = absint($_POST['product_id']);
321
+	$subscription    = new WPInv_Subscription(absint($_POST['sub_id']));
322
+	$subscription->update(array(
323
+		'status'         => sanitize_text_field($_POST['status']),
324 324
 		'profile_id'     => $profile_id,
325 325
 		'product_id'     => $product_id,
326 326
 		'transaction_id' => $transaction_id,
327
-	) );
327
+	));
328 328
 
329
-	$status = sanitize_text_field( $_POST['status'] );
329
+	$status = sanitize_text_field($_POST['status']);
330 330
 
331
-	switch( $status ) {
331
+	switch ($status) {
332 332
 
333 333
 		case 'cancelled' :
334 334
 
@@ -347,11 +347,11 @@  discard block
 block discarded – undo
347 347
 
348 348
 	}
349 349
 
350
-	wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id ) );
350
+	wp_redirect(admin_url('admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id));
351 351
 	exit;
352 352
 
353 353
 }
354
-add_action( 'admin_init', 'wpinv_recurring_process_subscription_update', 1 );
354
+add_action('admin_init', 'wpinv_recurring_process_subscription_update', 1);
355 355
 
356 356
 /**
357 357
  * Handles subscription deletion
@@ -362,30 +362,30 @@  discard block
 block discarded – undo
362 362
  */
363 363
 function wpinv_recurring_process_subscription_deletion() {
364 364
 
365
-	if( empty( $_POST['sub_id'] ) ) {
365
+	if (empty($_POST['sub_id'])) {
366 366
 		return;
367 367
 	}
368 368
 
369
-	if( empty( $_POST['wpinv_delete_subscription'] ) ) {
369
+	if (empty($_POST['wpinv_delete_subscription'])) {
370 370
 		return;
371 371
 	}
372 372
 
373
-	if( ! current_user_can( 'manage_invoicing') ) {
373
+	if (!current_user_can('manage_invoicing')) {
374 374
 		return;
375 375
 	}
376 376
 
377
-	if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) {
378
-		wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
377
+	if (!wp_verify_nonce($_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update')) {
378
+		wp_die(__('Nonce verification failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
379 379
 	}
380 380
 
381
-	$subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) );
381
+	$subscription = new WPInv_Subscription(absint($_POST['sub_id']));
382 382
 
383
-	delete_post_meta( $subscription->parent_payment_id, '_wpinv_subscription_payment' );
383
+	delete_post_meta($subscription->parent_payment_id, '_wpinv_subscription_payment');
384 384
 
385 385
 	$subscription->delete();
386 386
 
387
-	wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=deleted' ) );
387
+	wp_redirect(admin_url('admin.php?page=wpinv-subscriptions&wpinv-message=deleted'));
388 388
 	exit;
389 389
 
390 390
 }
391
-add_action( 'admin_init', 'wpinv_recurring_process_subscription_deletion', 2 );
391
+add_action('admin_init', 'wpinv_recurring_process_subscription_deletion', 2);
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 wpi_select2',
1552
-			'options' => array_merge( array( '' => '' ), $states ),
1552
+			'options' => array_merge(array('' => ''), $states),
1553 1553
 			'show_option_all'  => false,
1554 1554
 			'show_option_none' => false
1555 1555
 		);
1556 1556
 
1557
-		$response = wpinv_html_select( $args );
1557
+		$response = wpinv_html_select($args);
1558 1558
 
1559 1559
 	} else {
1560 1560
 		$response = 'nostates';
@@ -1563,8 +1563,8 @@  discard block
 block discarded – undo
1563 1563
 	return $response;
1564 1564
 }
1565 1565
 
1566
-function wpinv_default_billing_country( $country = '', $user_id = 0 ) {
1567
-    $country = !empty( $country ) ? $country : wpinv_get_default_country();
1566
+function wpinv_default_billing_country($country = '', $user_id = 0) {
1567
+    $country = !empty($country) ? $country : wpinv_get_default_country();
1568 1568
     
1569
-    return apply_filters( 'wpinv_default_billing_country', $country, $user_id );
1569
+    return apply_filters('wpinv_default_billing_country', $country, $user_id);
1570 1570
 }
1571 1571
\ No newline at end of file
Please login to merge, or discard this patch.
includes/wpinv-gateway-functions.php 1 patch
Spacing   +258 added lines, -258 removed lines patch added patch discarded remove patch
@@ -7,206 +7,206 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 function wpinv_get_payment_gateways() {
15 15
     // Default, built-in gateways
16 16
     $gateways = array(
17 17
         'paypal' => array(
18
-            'admin_label'    => __( 'PayPal Standard', 'invoicing' ),
19
-            'checkout_label' => __( 'PayPal Standard', 'invoicing' ),
18
+            'admin_label'    => __('PayPal Standard', 'invoicing'),
19
+            'checkout_label' => __('PayPal Standard', 'invoicing'),
20 20
             'ordering'       => 1,
21 21
         ),
22 22
         'authorizenet' => array(
23
-            'admin_label'    => __( 'Authorize.Net (AIM)', 'invoicing' ),
24
-            'checkout_label' => __( 'Authorize.Net - Credit Card / Debit Card', 'invoicing' ),
23
+            'admin_label'    => __('Authorize.Net (AIM)', 'invoicing'),
24
+            'checkout_label' => __('Authorize.Net - Credit Card / Debit Card', 'invoicing'),
25 25
             'ordering'       => 4,
26 26
         ),
27 27
         'worldpay' => array(
28
-            'admin_label'    => __( 'Worldpay', 'invoicing' ),
29
-            'checkout_label' => __( 'Worldpay - Credit Card / Debit Card', 'invoicing' ),
28
+            'admin_label'    => __('Worldpay', 'invoicing'),
29
+            'checkout_label' => __('Worldpay - Credit Card / Debit Card', 'invoicing'),
30 30
             'ordering'       => 5,
31 31
         ),
32 32
         'bank_transfer' => array(
33
-            'admin_label'    => __( 'Pre Bank Transfer', 'invoicing' ),
34
-            'checkout_label' => __( 'Pre Bank Transfer', 'invoicing' ),
33
+            'admin_label'    => __('Pre Bank Transfer', 'invoicing'),
34
+            'checkout_label' => __('Pre Bank Transfer', 'invoicing'),
35 35
             'ordering'       => 11,
36 36
         ),
37 37
         'manual' => array(
38
-            'admin_label'    => __( 'Test Payment', 'invoicing' ),
39
-            'checkout_label' => __( 'Test Payment', 'invoicing' ),
38
+            'admin_label'    => __('Test Payment', 'invoicing'),
39
+            'checkout_label' => __('Test Payment', 'invoicing'),
40 40
             'ordering'       => 12,
41 41
         ),
42 42
     );
43 43
 
44
-    return apply_filters( 'wpinv_payment_gateways', $gateways );
44
+    return apply_filters('wpinv_payment_gateways', $gateways);
45 45
 }
46 46
 
47
-function wpinv_payment_gateway_titles( $all_gateways ) {
47
+function wpinv_payment_gateway_titles($all_gateways) {
48 48
     global $wpinv_options;
49 49
     
50 50
     $gateways = array();
51
-    foreach ( $all_gateways as $key => $gateway ) {
52
-        if ( !empty( $wpinv_options[$key . '_title'] ) ) {
53
-            $all_gateways[$key]['checkout_label'] = __( $wpinv_options[$key . '_title'], 'invoicing' );
51
+    foreach ($all_gateways as $key => $gateway) {
52
+        if (!empty($wpinv_options[$key . '_title'])) {
53
+            $all_gateways[$key]['checkout_label'] = __($wpinv_options[$key . '_title'], 'invoicing');
54 54
         }
55 55
         
56
-        $gateways[$key] = isset( $wpinv_options[$key . '_ordering'] ) ? $wpinv_options[$key . '_ordering'] : ( isset( $gateway['ordering'] ) ? $gateway['ordering'] : '' );
56
+        $gateways[$key] = isset($wpinv_options[$key . '_ordering']) ? $wpinv_options[$key . '_ordering'] : (isset($gateway['ordering']) ? $gateway['ordering'] : '');
57 57
     }
58 58
 
59
-    asort( $gateways );
59
+    asort($gateways);
60 60
     
61
-    foreach ( $gateways as $gateway => $key ) {
61
+    foreach ($gateways as $gateway => $key) {
62 62
         $gateways[$gateway] = $all_gateways[$gateway];
63 63
     }
64 64
     
65 65
     return $gateways;
66 66
 }
67
-add_filter( 'wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1 );
67
+add_filter('wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1);
68 68
 
69
-function wpinv_get_enabled_payment_gateways( $sort = false ) {
69
+function wpinv_get_enabled_payment_gateways($sort = false) {
70 70
     $gateways = wpinv_get_payment_gateways();
71
-    $enabled  = wpinv_get_option( 'gateways', false );
71
+    $enabled  = wpinv_get_option('gateways', false);
72 72
 
73 73
     $gateway_list = array();
74 74
 
75
-    foreach ( $gateways as $key => $gateway ) {
76
-        if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) {
77
-            $gateway_list[ $key ] = $gateway;
75
+    foreach ($gateways as $key => $gateway) {
76
+        if (isset($enabled[$key]) && $enabled[$key] == 1) {
77
+            $gateway_list[$key] = $gateway;
78 78
         }
79 79
     }
80 80
 
81
-    if ( true === $sort ) {
82
-        uasort( $gateway_list, 'wpinv_sort_gateway_order' );
81
+    if (true === $sort) {
82
+        uasort($gateway_list, 'wpinv_sort_gateway_order');
83 83
         
84 84
         // Reorder our gateways so the default is first
85 85
         $default_gateway_id = wpinv_get_default_gateway();
86 86
 
87
-        if ( wpinv_is_gateway_active( $default_gateway_id ) ) {
88
-            $default_gateway    = array( $default_gateway_id => $gateway_list[ $default_gateway_id ] );
89
-            unset( $gateway_list[ $default_gateway_id ] );
87
+        if (wpinv_is_gateway_active($default_gateway_id)) {
88
+            $default_gateway = array($default_gateway_id => $gateway_list[$default_gateway_id]);
89
+            unset($gateway_list[$default_gateway_id]);
90 90
 
91
-            $gateway_list = array_merge( $default_gateway, $gateway_list );
91
+            $gateway_list = array_merge($default_gateway, $gateway_list);
92 92
         }
93 93
     }
94 94
 
95
-    return apply_filters( 'wpinv_enabled_payment_gateways', $gateway_list );
95
+    return apply_filters('wpinv_enabled_payment_gateways', $gateway_list);
96 96
 }
97 97
 
98
-function wpinv_sort_gateway_order( $a, $b ) {
98
+function wpinv_sort_gateway_order($a, $b) {
99 99
     return $a['ordering'] - $b['ordering'];
100 100
 }
101 101
 
102
-function wpinv_is_gateway_active( $gateway ) {
102
+function wpinv_is_gateway_active($gateway) {
103 103
     $gateways = wpinv_get_enabled_payment_gateways();
104 104
 
105
-    $ret = is_array($gateways) && $gateway ?  array_key_exists( $gateway, $gateways ) : false;
105
+    $ret = is_array($gateways) && $gateway ?  array_key_exists($gateway, $gateways) : false;
106 106
 
107
-    return apply_filters( 'wpinv_is_gateway_active', $ret, $gateway, $gateways );
107
+    return apply_filters('wpinv_is_gateway_active', $ret, $gateway, $gateways);
108 108
 }
109 109
 
110 110
 function wpinv_get_default_gateway() {
111
-    $default = wpinv_get_option( 'default_gateway', 'paypal' );
111
+    $default = wpinv_get_option('default_gateway', 'paypal');
112 112
 
113
-    if ( !wpinv_is_gateway_active( $default ) ) {
113
+    if (!wpinv_is_gateway_active($default)) {
114 114
         $gateways = wpinv_get_enabled_payment_gateways();
115
-        $gateways = array_keys( $gateways );
116
-        $default  = reset( $gateways );
115
+        $gateways = array_keys($gateways);
116
+        $default  = reset($gateways);
117 117
     }
118 118
 
119
-    return apply_filters( 'wpinv_default_gateway', $default );
119
+    return apply_filters('wpinv_default_gateway', $default);
120 120
 }
121 121
 
122
-function wpinv_get_gateway_admin_label( $gateway ) {
122
+function wpinv_get_gateway_admin_label($gateway) {
123 123
     $gateways = wpinv_get_payment_gateways();
124
-    $label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway;
125
-    $payment  = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : false;
124
+    $label    = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway;
125
+    $payment  = isset($_GET['id']) ? absint($_GET['id']) : false;
126 126
 
127
-    if( $gateway == 'manual' && $payment ) {
128
-        if( !( (float)wpinv_payment_total( $payment ) > 0 ) ) {
129
-            $label = __( 'Free Purchase', 'invoicing' );
127
+    if ($gateway == 'manual' && $payment) {
128
+        if (!((float)wpinv_payment_total($payment) > 0)) {
129
+            $label = __('Free Purchase', 'invoicing');
130 130
         }
131 131
     }
132 132
 
133
-    return apply_filters( 'wpinv_gateway_admin_label', $label, $gateway );
133
+    return apply_filters('wpinv_gateway_admin_label', $label, $gateway);
134 134
 }
135 135
 
136
-function wpinv_get_gateway_description( $gateway ) {
136
+function wpinv_get_gateway_description($gateway) {
137 137
     global $wpinv_options;
138 138
 
139
-    $description = isset( $wpinv_options[$gateway . '_desc'] ) ? $wpinv_options[$gateway . '_desc'] : '';
139
+    $description = isset($wpinv_options[$gateway . '_desc']) ? $wpinv_options[$gateway . '_desc'] : '';
140 140
 
141
-    return apply_filters( 'wpinv_gateway_description', $description, $gateway );
141
+    return apply_filters('wpinv_gateway_description', $description, $gateway);
142 142
 }
143 143
 
144
-function wpinv_get_gateway_button_label( $gateway ) {
145
-    return apply_filters( 'wpinv_gateway_' . $gateway . '_button_label', '' );
144
+function wpinv_get_gateway_button_label($gateway) {
145
+    return apply_filters('wpinv_gateway_' . $gateway . '_button_label', '');
146 146
 }
147 147
 
148
-function wpinv_get_gateway_checkout_label( $gateway ) {
148
+function wpinv_get_gateway_checkout_label($gateway) {
149 149
     $gateways = wpinv_get_payment_gateways();
150
-    $label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway;
150
+    $label    = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway;
151 151
 
152
-    if( $gateway == 'manual' ) {
153
-        $label = __( 'Manual Payment', 'invoicing' );
152
+    if ($gateway == 'manual') {
153
+        $label = __('Manual Payment', 'invoicing');
154 154
     }
155 155
 
156
-    return apply_filters( 'wpinv_gateway_checkout_label', $label, $gateway );
156
+    return apply_filters('wpinv_gateway_checkout_label', $label, $gateway);
157 157
 }
158 158
 
159
-function wpinv_settings_sections_gateways( $settings ) {
159
+function wpinv_settings_sections_gateways($settings) {
160 160
     $gateways = wpinv_get_payment_gateways();
161 161
     
162 162
     if (!empty($gateways)) {
163
-        foreach  ($gateways as $key => $gateway) {
163
+        foreach ($gateways as $key => $gateway) {
164 164
             $settings[$key] = $gateway['admin_label'];
165 165
         }
166 166
     }
167 167
     
168 168
     return $settings;    
169 169
 }
170
-add_filter( 'wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1 );
170
+add_filter('wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1);
171 171
 
172
-function wpinv_settings_gateways( $settings ) {
172
+function wpinv_settings_gateways($settings) {
173 173
     $gateways = wpinv_get_payment_gateways();
174 174
     
175 175
     if (!empty($gateways)) {
176
-        foreach  ($gateways as $key => $gateway) {
176
+        foreach ($gateways as $key => $gateway) {
177 177
             $setting = array();
178 178
             $setting[$key . '_header'] = array(
179 179
                     'id'   => 'gateway_header',
180
-                    'name' => '<h3>' . wp_sprintf( __( '%s Settings', 'invoicing' ), $gateway['admin_label'] ) . '</h3>',
180
+                    'name' => '<h3>' . wp_sprintf(__('%s Settings', 'invoicing'), $gateway['admin_label']) . '</h3>',
181 181
                     'custom' => $key,
182 182
                     'type' => 'gateway_header',
183 183
                 );
184 184
             $setting[$key . '_active'] = array(
185 185
                     'id'   => $key . '_active',
186
-                    'name' => __( 'Active', 'invoicing' ),
187
-                    'desc' => wp_sprintf( __( 'Enable %s', 'invoicing' ), $gateway['admin_label'] ),
186
+                    'name' => __('Active', 'invoicing'),
187
+                    'desc' => wp_sprintf(__('Enable %s', 'invoicing'), $gateway['admin_label']),
188 188
                     'type' => 'checkbox',
189 189
                 );
190 190
                 
191 191
             $setting[$key . '_title'] = array(
192 192
                     'id'   => $key . '_title',
193
-                    'name' => __( 'Title', 'invoicing' ),
194
-                    'desc' => __( 'This controls the title which the user sees during checkout.', 'invoicing' ),
193
+                    'name' => __('Title', 'invoicing'),
194
+                    'desc' => __('This controls the title which the user sees during checkout.', 'invoicing'),
195 195
                     'type' => 'text',
196 196
                     'std' => isset($gateway['checkout_label']) ? $gateway['checkout_label'] : ''
197 197
                 );
198 198
             
199 199
             $setting[$key . '_desc'] = array(
200 200
                     'id'   => $key . '_desc',
201
-                    'name' => __( 'Description', 'invoicing' ),
202
-                    'desc' => __( 'This controls the description which the user sees during checkout.', 'invoicing' ),
201
+                    'name' => __('Description', 'invoicing'),
202
+                    'desc' => __('This controls the description which the user sees during checkout.', 'invoicing'),
203 203
                     'type' => 'text',
204 204
                     'size' => 'large'
205 205
                 );
206 206
                 
207 207
             $setting[$key . '_ordering'] = array(
208 208
                     'id'   => $key . '_ordering',
209
-                    'name' => __( 'Display Order', 'invoicing' ),
209
+                    'name' => __('Display Order', 'invoicing'),
210 210
                     'type' => 'number',
211 211
                     'size' => 'small',
212 212
                     'std'  => isset($gateway['ordering']) ? $gateway['ordering'] : '10',
@@ -215,8 +215,8 @@  discard block
 block discarded – undo
215 215
                     'step' => '1'
216 216
                 );
217 217
                 
218
-            $setting = apply_filters( 'wpinv_gateway_settings', $setting, $key );
219
-            $setting = apply_filters( 'wpinv_gateway_settings_' . $key, $setting );
218
+            $setting = apply_filters('wpinv_gateway_settings', $setting, $key);
219
+            $setting = apply_filters('wpinv_gateway_settings_' . $key, $setting);
220 220
             
221 221
             $settings[$key] = $setting;
222 222
         }
@@ -224,106 +224,106 @@  discard block
 block discarded – undo
224 224
     
225 225
     return $settings;    
226 226
 }
227
-add_filter( 'wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1 );
227
+add_filter('wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1);
228 228
 
229
-function wpinv_gateway_header_callback( $args ) {
230
-    echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr( $args['custom'] ) . '" />';
229
+function wpinv_gateway_header_callback($args) {
230
+    echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr($args['custom']) . '" />';
231 231
 }
232 232
 
233
-function wpinv_get_gateway_supports( $gateway ) {
233
+function wpinv_get_gateway_supports($gateway) {
234 234
     $gateways = wpinv_get_enabled_payment_gateways();
235
-    $supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array();
236
-    return apply_filters( 'wpinv_gateway_supports', $supports, $gateway );
235
+    $supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array();
236
+    return apply_filters('wpinv_gateway_supports', $supports, $gateway);
237 237
 }
238 238
 
239
-function wpinv_gateway_supports_buy_now( $gateway ) {
240
-    $supports = wpinv_get_gateway_supports( $gateway );
241
-    $ret = in_array( 'buy_now', $supports );
242
-    return apply_filters( 'wpinv_gateway_supports_buy_now', $ret, $gateway );
239
+function wpinv_gateway_supports_buy_now($gateway) {
240
+    $supports = wpinv_get_gateway_supports($gateway);
241
+    $ret = in_array('buy_now', $supports);
242
+    return apply_filters('wpinv_gateway_supports_buy_now', $ret, $gateway);
243 243
 }
244 244
 
245 245
 function wpinv_shop_supports_buy_now() {
246 246
     $gateways = wpinv_get_enabled_payment_gateways();
247 247
     $ret      = false;
248 248
 
249
-    if ( !wpinv_use_taxes()  && $gateways ) {
250
-        foreach ( $gateways as $gateway_id => $gateway ) {
251
-            if ( wpinv_gateway_supports_buy_now( $gateway_id ) ) {
249
+    if (!wpinv_use_taxes() && $gateways) {
250
+        foreach ($gateways as $gateway_id => $gateway) {
251
+            if (wpinv_gateway_supports_buy_now($gateway_id)) {
252 252
                 $ret = true;
253 253
                 break;
254 254
             }
255 255
         }
256 256
     }
257 257
 
258
-    return apply_filters( 'wpinv_shop_supports_buy_now', $ret );
258
+    return apply_filters('wpinv_shop_supports_buy_now', $ret);
259 259
 }
260 260
 
261
-function wpinv_send_to_gateway( $gateway, $payment_data ) {
262
-    $payment_data['gateway_nonce'] = wp_create_nonce( 'wpi-gateway' );
261
+function wpinv_send_to_gateway($gateway, $payment_data) {
262
+    $payment_data['gateway_nonce'] = wp_create_nonce('wpi-gateway');
263 263
 
264 264
     // $gateway must match the ID used when registering the gateway
265
-    do_action( 'wpinv_gateway_' . $gateway, $payment_data );
265
+    do_action('wpinv_gateway_' . $gateway, $payment_data);
266 266
 }
267 267
 
268 268
 function wpinv_show_gateways() {
269 269
     $gateways = wpinv_get_enabled_payment_gateways();
270 270
     $show_gateways = false;
271 271
 
272
-    $chosen_gateway = isset( $_GET['payment-mode'] ) ? preg_replace('/[^a-zA-Z0-9-_]+/', '', $_GET['payment-mode'] ) : false;
272
+    $chosen_gateway = isset($_GET['payment-mode']) ? preg_replace('/[^a-zA-Z0-9-_]+/', '', $_GET['payment-mode']) : false;
273 273
 
274
-    if ( count( $gateways ) > 1 && empty( $chosen_gateway ) ) {
274
+    if (count($gateways) > 1 && empty($chosen_gateway)) {
275 275
         $show_gateways = true;
276
-        if ( wpinv_get_cart_total() <= 0 ) {
276
+        if (wpinv_get_cart_total() <= 0) {
277 277
             $show_gateways = false;
278 278
         }
279 279
     }
280 280
     
281
-    if ( !$show_gateways && wpinv_cart_has_recurring_item() ) {
281
+    if (!$show_gateways && wpinv_cart_has_recurring_item()) {
282 282
         $show_gateways = true;
283 283
     }
284 284
 
285
-    return apply_filters( 'wpinv_show_gateways', $show_gateways );
285
+    return apply_filters('wpinv_show_gateways', $show_gateways);
286 286
 }
287 287
 
288
-function wpinv_get_chosen_gateway( $invoice_id = 0 ) {
289
-	$gateways = array_keys( wpinv_get_enabled_payment_gateways() );
288
+function wpinv_get_chosen_gateway($invoice_id = 0) {
289
+	$gateways = array_keys(wpinv_get_enabled_payment_gateways());
290 290
 
291 291
     $chosen = false;
292
-    if ( $invoice_id > 0 && $invoice = wpinv_get_invoice( $invoice_id ) ) {
292
+    if ($invoice_id > 0 && $invoice = wpinv_get_invoice($invoice_id)) {
293 293
         $chosen = $invoice->get_gateway();
294 294
     }
295 295
 
296
-	$chosen   = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen;
296
+	$chosen = isset($_REQUEST['payment-mode']) ? sanitize_text_field($_REQUEST['payment-mode']) : $chosen;
297 297
 
298
-	if ( false !== $chosen ) {
299
-		$chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen );
298
+	if (false !== $chosen) {
299
+		$chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen);
300 300
 	}
301 301
 
302
-	if ( ! empty ( $chosen ) ) {
303
-		$enabled_gateway = urldecode( $chosen );
304
-	} else if (  !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) {
302
+	if (!empty ($chosen)) {
303
+		$enabled_gateway = urldecode($chosen);
304
+	} else if (!empty($invoice) && (float)$invoice->get_subtotal() <= 0) {
305 305
 		$enabled_gateway = 'manual';
306 306
 	} else {
307 307
 		$enabled_gateway = wpinv_get_default_gateway();
308 308
 	}
309 309
     
310
-    if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) {
311
-        if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){
310
+    if (!wpinv_is_gateway_active($enabled_gateway) && !empty($gateways)) {
311
+        if (wpinv_is_gateway_active(wpinv_get_default_gateway())) {
312 312
             $enabled_gateway = wpinv_get_default_gateway();
313
-        }else{
313
+        } else {
314 314
             $enabled_gateway = $gateways[0];
315 315
         }
316 316
 
317 317
     }
318 318
 
319
-	return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway );
319
+	return apply_filters('wpinv_chosen_gateway', $enabled_gateway);
320 320
 }
321 321
 
322
-function wpinv_record_gateway_error( $title = '', $message = '', $parent = 0 ) {
323
-    return wpinv_error_log( $message, $title );
322
+function wpinv_record_gateway_error($title = '', $message = '', $parent = 0) {
323
+    return wpinv_error_log($message, $title);
324 324
 }
325 325
 
326
-function wpinv_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) {
326
+function wpinv_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') {
327 327
 	$ret  = 0;
328 328
 	$args = array(
329 329
 		'meta_key'    => '_wpinv_gateway',
@@ -334,48 +334,48 @@  discard block
 block discarded – undo
334 334
 		'fields'      => 'ids'
335 335
 	);
336 336
 
337
-	$payments = new WP_Query( $args );
337
+	$payments = new WP_Query($args);
338 338
 
339
-	if( $payments )
339
+	if ($payments)
340 340
 		$ret = $payments->post_count;
341 341
 	return $ret;
342 342
 }
343 343
 
344
-function wpinv_settings_update_gateways( $input ) {
344
+function wpinv_settings_update_gateways($input) {
345 345
     global $wpinv_options;
346 346
     
347
-    if ( !empty( $input['save_gateway'] ) ) {
348
-        $gateways = wpinv_get_option( 'gateways', false );
347
+    if (!empty($input['save_gateway'])) {
348
+        $gateways = wpinv_get_option('gateways', false);
349 349
         $gateways = !empty($gateways) ? $gateways : array();
350 350
         $gateway = $input['save_gateway'];
351 351
         
352
-        if ( !empty( $input[$gateway . '_active'] ) ) {
352
+        if (!empty($input[$gateway . '_active'])) {
353 353
             $gateways[$gateway] = 1;
354 354
         } else {
355
-            if ( isset( $gateways[$gateway] ) ) {
356
-                unset( $gateways[$gateway] );
355
+            if (isset($gateways[$gateway])) {
356
+                unset($gateways[$gateway]);
357 357
             }
358 358
         }
359 359
         
360 360
         $input['gateways'] = $gateways;
361 361
     }
362 362
     
363
-    if ( !empty( $input['default_gateway'] ) ) {
363
+    if (!empty($input['default_gateway'])) {
364 364
         $gateways = wpinv_get_payment_gateways();
365 365
         
366
-        foreach ( $gateways as $key => $gateway ) {
367
-            $active   = 0;
368
-            if ( !empty( $input['gateways'] ) && !empty( $input['gateways'][$key] ) ) {
366
+        foreach ($gateways as $key => $gateway) {
367
+            $active = 0;
368
+            if (!empty($input['gateways']) && !empty($input['gateways'][$key])) {
369 369
                 $active = 1;
370 370
             }
371 371
             
372 372
             $input[$key . '_active'] = $active;
373 373
             
374
-            if ( empty( $wpinv_options[$key . '_title'] ) ) {
374
+            if (empty($wpinv_options[$key . '_title'])) {
375 375
                 $input[$key . '_title'] = $gateway['checkout_label'];
376 376
             }
377 377
             
378
-            if ( !isset( $wpinv_options[$key . '_ordering'] ) && isset( $gateway['ordering'] ) ) {
378
+            if (!isset($wpinv_options[$key . '_ordering']) && isset($gateway['ordering'])) {
379 379
                 $input[$key . '_ordering'] = $gateway['ordering'];
380 380
             }
381 381
         }
@@ -383,27 +383,27 @@  discard block
 block discarded – undo
383 383
     
384 384
     return $input;
385 385
 }
386
-add_filter( 'wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1 );
386
+add_filter('wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1);
387 387
 
388 388
 // PayPal Standard settings
389
-function wpinv_gateway_settings_paypal( $setting ) {    
390
-    $setting['paypal_active']['desc'] = $setting['paypal_active']['desc'] . ' ' . __( '( Supported Currencies: AUD, BRL, CAD, CZK, DKK, EUR, HKD, HUF, ILS, JPY, MYR, MXN, NOK, NZD, PHP, PLN, GBP, SGD, SEK, CHF, TWD, THB, USD )', 'invoicing' );
391
-    $setting['paypal_desc']['std'] = __( 'Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing' );
389
+function wpinv_gateway_settings_paypal($setting) {    
390
+    $setting['paypal_active']['desc'] = $setting['paypal_active']['desc'] . ' ' . __('( Supported Currencies: AUD, BRL, CAD, CZK, DKK, EUR, HKD, HUF, ILS, JPY, MYR, MXN, NOK, NZD, PHP, PLN, GBP, SGD, SEK, CHF, TWD, THB, USD )', 'invoicing');
391
+    $setting['paypal_desc']['std'] = __('Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing');
392 392
     
393 393
     $setting['paypal_sandbox'] = array(
394 394
             'type' => 'checkbox',
395 395
             'id'   => 'paypal_sandbox',
396
-            'name' => __( 'PayPal Sandbox', 'invoicing' ),
397
-            'desc' => __( 'PayPal sandbox can be used to test payments.', 'invoicing' ),
396
+            'name' => __('PayPal Sandbox', 'invoicing'),
397
+            'desc' => __('PayPal sandbox can be used to test payments.', 'invoicing'),
398 398
             'std'  => 1
399 399
         );
400 400
         
401 401
     $setting['paypal_email'] = array(
402 402
             'type' => 'text',
403 403
             'id'   => 'paypal_email',
404
-            'name' => __( 'PayPal Email', 'invoicing' ),
405
-            'desc' => __( 'Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing' ),
406
-            'std' => __( '[email protected]', 'invoicing' ),
404
+            'name' => __('PayPal Email', 'invoicing'),
405
+            'desc' => __('Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing'),
406
+            'std' => __('[email protected]', 'invoicing'),
407 407
         );
408 408
     /*
409 409
     $setting['paypal_ipn_url'] = array(
@@ -417,139 +417,139 @@  discard block
 block discarded – undo
417 417
         
418 418
     return $setting;
419 419
 }
420
-add_filter( 'wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1 );
420
+add_filter('wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1);
421 421
 
422 422
 // Pre Bank Transfer settings
423
-function wpinv_gateway_settings_bank_transfer( $setting ) {
424
-    $setting['bank_transfer_desc']['std'] = __( 'Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing' );
423
+function wpinv_gateway_settings_bank_transfer($setting) {
424
+    $setting['bank_transfer_desc']['std'] = __('Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing');
425 425
     
426 426
     $setting['bank_transfer_ac_name'] = array(
427 427
             'type' => 'text',
428 428
             'id' => 'bank_transfer_ac_name',
429
-            'name' => __( 'Account Name', 'invoicing' ),
430
-            'desc' => __( 'Enter the bank account name to which you want to transfer payment.', 'invoicing' ),
431
-            'std'  =>  __( 'Mr. John Martin', 'invoicing' ),
429
+            'name' => __('Account Name', 'invoicing'),
430
+            'desc' => __('Enter the bank account name to which you want to transfer payment.', 'invoicing'),
431
+            'std'  =>  __('Mr. John Martin', 'invoicing'),
432 432
         );
433 433
     
434 434
     $setting['bank_transfer_ac_no'] = array(
435 435
             'type' => 'text',
436 436
             'id' => 'bank_transfer_ac_no',
437
-            'name' => __( 'Account Number', 'invoicing' ),
438
-            'desc' => __( 'Enter your bank account number.', 'invoicing' ),
439
-            'std'  =>  __( 'TEST1234567890', 'invoicing' ),
437
+            'name' => __('Account Number', 'invoicing'),
438
+            'desc' => __('Enter your bank account number.', 'invoicing'),
439
+            'std'  =>  __('TEST1234567890', 'invoicing'),
440 440
         );
441 441
     
442 442
     $setting['bank_transfer_bank_name'] = array(
443 443
             'type' => 'text',
444 444
             'id'   => 'bank_transfer_bank_name',
445
-            'name' => __( 'Bank Name', 'invoicing' ),
446
-            'desc' => __( 'Enter the bank name to which you want to transfer payment.', 'invoicing' ),
447
-            'std' => __( 'ICICI Bank', 'invoicing' ),
445
+            'name' => __('Bank Name', 'invoicing'),
446
+            'desc' => __('Enter the bank name to which you want to transfer payment.', 'invoicing'),
447
+            'std' => __('ICICI Bank', 'invoicing'),
448 448
         );
449 449
     
450 450
     $setting['bank_transfer_ifsc'] = array(
451 451
             'type' => 'text',
452 452
             'id'   => 'bank_transfer_ifsc',
453
-            'name' => __( 'IFSC Code', 'invoicing' ),
454
-            'desc' => __( 'Enter your bank IFSC code.', 'invoicing' ),
455
-            'std'  =>  __( 'ICIC0001234', 'invoicing' ),
453
+            'name' => __('IFSC Code', 'invoicing'),
454
+            'desc' => __('Enter your bank IFSC code.', 'invoicing'),
455
+            'std'  =>  __('ICIC0001234', 'invoicing'),
456 456
         );
457 457
         
458 458
     $setting['bank_transfer_iban'] = array(
459 459
             'type' => 'text',
460 460
             'id'   => 'bank_transfer_iban',
461
-            'name' => __( 'IBAN', 'invoicing' ),
462
-            'desc' => __( 'Enter your International Bank Account Number(IBAN).', 'invoicing' ),
463
-            'std'  =>  __( 'GB29NWBK60161331926819', 'invoicing' ),
461
+            'name' => __('IBAN', 'invoicing'),
462
+            'desc' => __('Enter your International Bank Account Number(IBAN).', 'invoicing'),
463
+            'std'  =>  __('GB29NWBK60161331926819', 'invoicing'),
464 464
         );
465 465
         
466 466
     $setting['bank_transfer_bic'] = array(
467 467
             'type' => 'text',
468 468
             'id'   => 'bank_transfer_bic',
469
-            'name' => __( 'BIC/Swift Code', 'invoicing' ),
470
-            'std'  =>  __( 'ICICGB2L129', 'invoicing' ),
469
+            'name' => __('BIC/Swift Code', 'invoicing'),
470
+            'std'  =>  __('ICICGB2L129', 'invoicing'),
471 471
         );
472 472
 
473 473
     $setting['bank_transfer_sort_code'] = array(
474 474
         'type' => 'text',
475 475
         'id'   => 'bank_transfer_sort_code',
476
-        'name' => __( 'Sort Code', 'invoicing' ),
477
-        'std'  =>  __( '12-34-56', 'invoicing' ),
476
+        'name' => __('Sort Code', 'invoicing'),
477
+        'std'  =>  __('12-34-56', 'invoicing'),
478 478
     );
479 479
         
480 480
     $setting['bank_transfer_info'] = array(
481 481
             'id'   => 'bank_transfer_info',
482
-            'name' => __( 'Instructions', 'invoicing' ),
483
-            'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ),
482
+            'name' => __('Instructions', 'invoicing'),
483
+            'desc' => __('Instructions that will be added to the thank you page and emails.', 'invoicing'),
484 484
             'type' => 'textarea',
485
-            'std' => __( 'Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing' ),
485
+            'std' => __('Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing'),
486 486
             'cols' => 37,
487 487
             'rows' => 5
488 488
         );
489 489
         
490 490
     return $setting;
491 491
 }
492
-add_filter( 'wpinv_gateway_settings_bank_transfer', 'wpinv_gateway_settings_bank_transfer', 10, 1 );
492
+add_filter('wpinv_gateway_settings_bank_transfer', 'wpinv_gateway_settings_bank_transfer', 10, 1);
493 493
 
494 494
 // Authorize.Net settings
495
-function wpinv_gateway_settings_authorizenet( $setting ) {
496
-    $setting['authorizenet_active']['desc'] = $setting['authorizenet_active']['desc'] . ' ' . __( '( Supported Currencies: AUD, CAD, CHF, DKK, EUR, GBP, JPY, NOK, NZD, PLN, SEK, USD, ZAR )', 'invoicing' );
497
-    $setting['authorizenet_desc']['std'] = __( 'Pay using a Authorize.Net to process Credit card / Debit card transactions.', 'invoicing' );
495
+function wpinv_gateway_settings_authorizenet($setting) {
496
+    $setting['authorizenet_active']['desc'] = $setting['authorizenet_active']['desc'] . ' ' . __('( Supported Currencies: AUD, CAD, CHF, DKK, EUR, GBP, JPY, NOK, NZD, PLN, SEK, USD, ZAR )', 'invoicing');
497
+    $setting['authorizenet_desc']['std'] = __('Pay using a Authorize.Net to process Credit card / Debit card transactions.', 'invoicing');
498 498
     
499 499
     $setting['authorizenet_sandbox'] = array(
500 500
             'type' => 'checkbox',
501 501
             'id'   => 'authorizenet_sandbox',
502
-            'name' => __( 'Authorize.Net Test Mode', 'invoicing' ),
503
-            'desc' => __( 'Enable Authorize.Net test mode to test payments.', 'invoicing' ),
502
+            'name' => __('Authorize.Net Test Mode', 'invoicing'),
503
+            'desc' => __('Enable Authorize.Net test mode to test payments.', 'invoicing'),
504 504
             'std'  => 1
505 505
         );
506 506
         
507 507
     $setting['authorizenet_login_id'] = array(
508 508
             'type' => 'text',
509 509
             'id'   => 'authorizenet_login_id',
510
-            'name' => __( 'API Login ID', 'invoicing' ),
511
-            'desc' => __( 'API Login ID can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 2j4rBekUnD', 'invoicing' ),
510
+            'name' => __('API Login ID', 'invoicing'),
511
+            'desc' => __('API Login ID can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 2j4rBekUnD', 'invoicing'),
512 512
             'std' => '2j4rBekUnD',
513 513
         );
514 514
     
515 515
     $setting['authorizenet_transaction_key'] = array(
516 516
             'type' => 'text',
517 517
             'id'   => 'authorizenet_transaction_key',
518
-            'name' => __( 'Transaction Key', 'invoicing' ),
519
-            'desc' => __( 'Transaction Key can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 4vyBUOJgR74679xa', 'invoicing' ),
518
+            'name' => __('Transaction Key', 'invoicing'),
519
+            'desc' => __('Transaction Key can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 4vyBUOJgR74679xa', 'invoicing'),
520 520
             'std' => '4vyBUOJgR74679xa',
521 521
         );
522 522
         
523 523
     $setting['authorizenet_md5_hash'] = array(
524 524
             'type' => 'text',
525 525
             'id'   => 'authorizenet_md5_hash',
526
-            'name' => __( 'MD5-Hash', 'invoicing' ),
527
-            'desc' => __( 'The MD5 Hash security feature allows to authenticate transaction responses from the Authorize.Net for recurring payments. It can be obtained from Authorize.Net Account > Settings > Security Settings > General Settings > MD5 Hash.', 'invoicing' ),
526
+            'name' => __('MD5-Hash', 'invoicing'),
527
+            'desc' => __('The MD5 Hash security feature allows to authenticate transaction responses from the Authorize.Net for recurring payments. It can be obtained from Authorize.Net Account > Settings > Security Settings > General Settings > MD5 Hash.', 'invoicing'),
528 528
             'std' => '',
529 529
         );
530 530
 
531 531
     $setting['authorizenet_transaction_type'] = array(
532 532
         'id'          => 'authorizenet_transaction_type',
533
-        'name'        => __( 'Transaction Type', 'invoicing' ),
534
-        'desc'        => __( 'Choose transaction type.', 'invoicing' ),
533
+        'name'        => __('Transaction Type', 'invoicing'),
534
+        'desc'        => __('Choose transaction type.', 'invoicing'),
535 535
         'type'        => 'select',
536 536
         'class'       => 'wpi_select2',
537 537
         'options'     => array(
538
-            'authorize_capture' => __( 'Authorize And Capture', 'invoicing' ),
539
-            'authorize_only' => __( 'Authorize Only', 'invoicing' ),
538
+            'authorize_capture' => __('Authorize And Capture', 'invoicing'),
539
+            'authorize_only' => __('Authorize Only', 'invoicing'),
540 540
         ),
541 541
         'std'         => 'authorize_capture'
542 542
     );
543 543
 
544 544
     $setting['authorizenet_transaction_type_recurring'] = array(
545 545
         'id'          => 'authorizenet_transaction_type_recurring',
546
-        'name'        => __( 'Transaction Type for Recurring', 'invoicing' ),
547
-        'desc'        => __( 'Choose transaction type for recurring payments.', 'invoicing' ),
546
+        'name'        => __('Transaction Type for Recurring', 'invoicing'),
547
+        'desc'        => __('Choose transaction type for recurring payments.', 'invoicing'),
548 548
         'type'        => 'select',
549 549
         'class'       => 'wpi_select2',
550 550
         'options'     => array(
551
-            'authorize_capture' => __( 'Authorize And Capture', 'invoicing' ),
552
-            'authorize_only' => __( 'Authorize Only', 'invoicing' ),
551
+            'authorize_capture' => __('Authorize And Capture', 'invoicing'),
552
+            'authorize_only' => __('Authorize Only', 'invoicing'),
553 553
         ),
554 554
         'std'         => 'authorize_only'
555 555
     );
@@ -557,9 +557,9 @@  discard block
 block discarded – undo
557 557
     $setting['authorizenet_ipn_url'] = array(
558 558
             'type' => 'ipn_url',
559 559
             'id'   => 'authorizenet_ipn_url',
560
-            'name' => __( 'Silent Post URL', 'invoicing' ),
561
-            'std' => wpinv_get_ipn_url( 'authorizenet' ),
562
-            'desc' => __( 'If you are accepting recurring payments then you must set this url at Authorize.Net Account > Settings > Transaction Format Settings > Transaction Response Settings > Silent Post URL.', 'invoicing' ),
560
+            'name' => __('Silent Post URL', 'invoicing'),
561
+            'std' => wpinv_get_ipn_url('authorizenet'),
562
+            'desc' => __('If you are accepting recurring payments then you must set this url at Authorize.Net Account > Settings > Transaction Format Settings > Transaction Response Settings > Silent Post URL.', 'invoicing'),
563 563
             'size' => 'large',
564 564
             'custom' => 'authorizenet',
565 565
             'readonly' => true
@@ -567,26 +567,26 @@  discard block
 block discarded – undo
567 567
         
568 568
     return $setting;
569 569
 }
570
-add_filter( 'wpinv_gateway_settings_authorizenet', 'wpinv_gateway_settings_authorizenet', 10, 1 );
570
+add_filter('wpinv_gateway_settings_authorizenet', 'wpinv_gateway_settings_authorizenet', 10, 1);
571 571
 
572 572
 // Worldpay settings
573
-function wpinv_gateway_settings_worldpay( $setting ) {
574
-    $setting['worldpay_active']['desc'] = $setting['worldpay_active']['desc'] . ' ' . __( '( Supported Currencies: AUD, ARS, CAD, CHF, DKK, EUR, HKD, MYR, GBP, NZD, NOK, SGD, LKR, SEK, TRY, USD, ZAR )', 'invoicing' );
575
-    $setting['worldpay_desc']['std'] = __( 'Pay using a Worldpay account to process Credit card / Debit card transactions.', 'invoicing' );
573
+function wpinv_gateway_settings_worldpay($setting) {
574
+    $setting['worldpay_active']['desc'] = $setting['worldpay_active']['desc'] . ' ' . __('( Supported Currencies: AUD, ARS, CAD, CHF, DKK, EUR, HKD, MYR, GBP, NZD, NOK, SGD, LKR, SEK, TRY, USD, ZAR )', 'invoicing');
575
+    $setting['worldpay_desc']['std'] = __('Pay using a Worldpay account to process Credit card / Debit card transactions.', 'invoicing');
576 576
     
577 577
     $setting['worldpay_sandbox'] = array(
578 578
             'type' => 'checkbox',
579 579
             'id'   => 'worldpay_sandbox',
580
-            'name' => __( 'Worldpay Test Mode', 'invoicing' ),
581
-            'desc' => __( 'This provides a special Test Environment to enable you to test your installation and integration to your website before going live.', 'invoicing' ),
580
+            'name' => __('Worldpay Test Mode', 'invoicing'),
581
+            'desc' => __('This provides a special Test Environment to enable you to test your installation and integration to your website before going live.', 'invoicing'),
582 582
             'std'  => 1
583 583
         );
584 584
         
585 585
     $setting['worldpay_instId'] = array(
586 586
             'type' => 'text',
587 587
             'id'   => 'worldpay_instId',
588
-            'name' => __( 'Installation Id', 'invoicing' ),
589
-            'desc' => __( 'Your installation id. Ex: 211616', 'invoicing' ),
588
+            'name' => __('Installation Id', 'invoicing'),
589
+            'desc' => __('Your installation id. Ex: 211616', 'invoicing'),
590 590
             'std' => '211616',
591 591
         );
592 592
     /*
@@ -602,9 +602,9 @@  discard block
 block discarded – undo
602 602
     $setting['worldpay_ipn_url'] = array(
603 603
             'type' => 'ipn_url',
604 604
             'id'   => 'worldpay_ipn_url',
605
-            'name' => __( 'Worldpay Callback Url', 'invoicing' ),
606
-            'std' => wpinv_get_ipn_url( 'worldpay' ),
607
-            'desc' => wp_sprintf( __( 'Login to your Worldpay Merchant Interface then enable Payment Response & Shopper Response. Next, go to the Payment Response URL field and type "%s" or "%s" for a dynamic payment response.', 'invoicing' ), '<font style="color:#000;font-style:normal">' . wpinv_get_ipn_url( 'worldpay' ) . '</font>', '<font style="color:#000;font-style:normal">&lt;wpdisplay item=MC_callback&gt;</font>' ),
605
+            'name' => __('Worldpay Callback Url', 'invoicing'),
606
+            'std' => wpinv_get_ipn_url('worldpay'),
607
+            'desc' => wp_sprintf(__('Login to your Worldpay Merchant Interface then enable Payment Response & Shopper Response. Next, go to the Payment Response URL field and type "%s" or "%s" for a dynamic payment response.', 'invoicing'), '<font style="color:#000;font-style:normal">' . wpinv_get_ipn_url('worldpay') . '</font>', '<font style="color:#000;font-style:normal">&lt;wpdisplay item=MC_callback&gt;</font>'),
608 608
             'size' => 'large',
609 609
             'custom' => 'worldpay',
610 610
             'readonly' => true
@@ -612,99 +612,99 @@  discard block
 block discarded – undo
612 612
         
613 613
     return $setting;
614 614
 }
615
-add_filter( 'wpinv_gateway_settings_worldpay', 'wpinv_gateway_settings_worldpay', 10, 1 );
615
+add_filter('wpinv_gateway_settings_worldpay', 'wpinv_gateway_settings_worldpay', 10, 1);
616 616
 
617
-function wpinv_ipn_url_callback( $args ) {    
618
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
617
+function wpinv_ipn_url_callback($args) {    
618
+    $sanitize_id = wpinv_sanitize_key($args['id']);
619 619
     
620 620
     $attrs = $args['readonly'] ? ' readonly' : '';
621 621
 
622
-    $html = '<input style="background-color:#fefefe" type="text" ' . $attrs . ' value="' . esc_attr( $args['std'] ) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" class="large-text">';
623
-    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">'  . $args['desc'] . '</label>';
622
+    $html = '<input style="background-color:#fefefe" type="text" ' . $attrs . ' value="' . esc_attr($args['std']) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" class="large-text">';
623
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>';
624 624
 
625 625
     echo $html;
626 626
 }
627 627
 
628
-function wpinv_is_test_mode( $gateway = '' ) {
629
-    if ( empty( $gateway ) ) {
628
+function wpinv_is_test_mode($gateway = '') {
629
+    if (empty($gateway)) {
630 630
         return false;
631 631
     }
632 632
     
633
-    $is_test_mode = wpinv_get_option( $gateway . '_sandbox', false );
633
+    $is_test_mode = wpinv_get_option($gateway . '_sandbox', false);
634 634
     
635
-    return apply_filters( 'wpinv_is_test_mode', $is_test_mode, $gateway );
635
+    return apply_filters('wpinv_is_test_mode', $is_test_mode, $gateway);
636 636
 }
637 637
 
638
-function wpinv_get_ipn_url( $gateway = '', $args = array() ) {
639
-    $data = array( 'wpi-listener' => 'IPN' );
638
+function wpinv_get_ipn_url($gateway = '', $args = array()) {
639
+    $data = array('wpi-listener' => 'IPN');
640 640
     
641
-    if ( !empty( $gateway ) ) {
642
-        $data['wpi-gateway'] = wpinv_sanitize_key( $gateway );
641
+    if (!empty($gateway)) {
642
+        $data['wpi-gateway'] = wpinv_sanitize_key($gateway);
643 643
     }
644 644
     
645
-    $args = !empty( $args ) && is_array( $args ) ? array_merge( $data, $args ) : $data;
645
+    $args = !empty($args) && is_array($args) ? array_merge($data, $args) : $data;
646 646
     
647
-    $ipn_url = add_query_arg( $args,  home_url( 'index.php' ) );
647
+    $ipn_url = add_query_arg($args, home_url('index.php'));
648 648
     
649
-    return apply_filters( 'wpinv_ipn_url', $ipn_url );
649
+    return apply_filters('wpinv_ipn_url', $ipn_url);
650 650
 }
651 651
 
652 652
 function wpinv_listen_for_payment_ipn() {
653 653
     // Regular PayPal IPN
654
-    if ( isset( $_GET['wpi-listener'] ) && $_GET['wpi-listener'] == 'IPN' ) {
655
-        do_action( 'wpinv_verify_payment_ipn' );
654
+    if (isset($_GET['wpi-listener']) && $_GET['wpi-listener'] == 'IPN') {
655
+        do_action('wpinv_verify_payment_ipn');
656 656
         
657
-        if ( !empty( $_GET['wpi-gateway'] ) ) {
658
-            wpinv_error_log( sanitize_text_field( $_GET['wpi-gateway'] ), 'WP Invoicing IPN', __FILE__, __LINE__ );
659
-            do_action( 'wpinv_verify_' . sanitize_text_field( $_GET['wpi-gateway'] ) . '_ipn' );
657
+        if (!empty($_GET['wpi-gateway'])) {
658
+            wpinv_error_log(sanitize_text_field($_GET['wpi-gateway']), 'WP Invoicing IPN', __FILE__, __LINE__);
659
+            do_action('wpinv_verify_' . sanitize_text_field($_GET['wpi-gateway']) . '_ipn');
660 660
         }
661 661
     }
662 662
 }
663
-add_action( 'init', 'wpinv_listen_for_payment_ipn' );
663
+add_action('init', 'wpinv_listen_for_payment_ipn');
664 664
 
665 665
 function wpinv_get_bank_instructions() {
666
-    $bank_instructions = wpinv_get_option( 'bank_transfer_info' );
666
+    $bank_instructions = wpinv_get_option('bank_transfer_info');
667 667
     
668
-    return apply_filters( 'wpinv_bank_instructions', $bank_instructions );
668
+    return apply_filters('wpinv_bank_instructions', $bank_instructions);
669 669
 }
670 670
 
671
-function wpinv_get_bank_info( $filtered = false ) {
671
+function wpinv_get_bank_info($filtered = false) {
672 672
     $bank_fields = array(
673
-        'bank_transfer_ac_name'     => __( 'Account Name', 'invoicing' ),
674
-        'bank_transfer_ac_no'       => __( 'Account Number', 'invoicing' ),
675
-        'bank_transfer_bank_name'   => __( 'Bank Name', 'invoicing' ),
676
-        'bank_transfer_ifsc'        => __( 'IFSC code', 'invoicing' ),
677
-        'bank_transfer_iban'        => __( 'IBAN', 'invoicing' ),
678
-        'bank_transfer_bic'         => __( 'BIC/Swift code', 'invoicing' ),
679
-        'bank_transfer_sort_code'   => __( 'Sort Code', 'invoicing' )
673
+        'bank_transfer_ac_name'     => __('Account Name', 'invoicing'),
674
+        'bank_transfer_ac_no'       => __('Account Number', 'invoicing'),
675
+        'bank_transfer_bank_name'   => __('Bank Name', 'invoicing'),
676
+        'bank_transfer_ifsc'        => __('IFSC code', 'invoicing'),
677
+        'bank_transfer_iban'        => __('IBAN', 'invoicing'),
678
+        'bank_transfer_bic'         => __('BIC/Swift code', 'invoicing'),
679
+        'bank_transfer_sort_code'   => __('Sort Code', 'invoicing')
680 680
     );
681 681
     
682 682
     $bank_info = array();
683
-    foreach ( $bank_fields as $field => $label ) {
684
-        if ( $filtered && !( $value = wpinv_get_option( $field ) ) ) {
683
+    foreach ($bank_fields as $field => $label) {
684
+        if ($filtered && !($value = wpinv_get_option($field))) {
685 685
             continue;
686 686
         }
687 687
         
688
-        $bank_info[$field] = array( 'label' => $label, 'value' => $value );
688
+        $bank_info[$field] = array('label' => $label, 'value' => $value);
689 689
     }
690 690
     
691
-    return apply_filters( 'wpinv_bank_info', $bank_info, $filtered );
691
+    return apply_filters('wpinv_bank_info', $bank_info, $filtered);
692 692
 }
693 693
 
694
-function wpinv_get_post_data( $method = 'request' ) {
694
+function wpinv_get_post_data($method = 'request') {
695 695
     $data       = array();
696 696
     $request    = $_REQUEST;
697 697
     
698
-    if ( $method == 'post' ) {
699
-        if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) {
698
+    if ($method == 'post') {
699
+        if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') {
700 700
             return $data;
701 701
         }
702 702
         
703 703
         $request = $_POST;
704 704
     }
705 705
     
706
-    if ( $method == 'get' ) {
707
-        if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'GET' ) {
706
+    if ($method == 'get') {
707
+        if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'GET') {
708 708
             return $data;
709 709
         }
710 710
         
@@ -715,11 +715,11 @@  discard block
 block discarded – undo
715 715
     $post_data = '';
716 716
     
717 717
     // Fallback just in case post_max_size is lower than needed
718
-    if ( ini_get( 'allow_url_fopen' ) ) {
719
-        $post_data = file_get_contents( 'php://input' );
718
+    if (ini_get('allow_url_fopen')) {
719
+        $post_data = file_get_contents('php://input');
720 720
     } else {
721 721
         // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough
722
-        ini_set( 'post_max_size', '12M' );
722
+        ini_set('post_max_size', '12M');
723 723
     }
724 724
     // Start the encoded data collection with notification command
725 725
     $encoded_data = 'cmd=_notify-validate';
@@ -728,58 +728,58 @@  discard block
 block discarded – undo
728 728
     $arg_separator = wpinv_get_php_arg_separator_output();
729 729
 
730 730
     // Verify there is a post_data
731
-    if ( $post_data || strlen( $post_data ) > 0 ) {
731
+    if ($post_data || strlen($post_data) > 0) {
732 732
         // Append the data
733 733
         $encoded_data .= $arg_separator . $post_data;
734 734
     } else {
735 735
         // Check if POST is empty
736
-        if ( empty( $request ) ) {
736
+        if (empty($request)) {
737 737
             // Nothing to do
738 738
             return;
739 739
         } else {
740 740
             // Loop through each POST
741
-            foreach ( $request as $key => $value ) {
741
+            foreach ($request as $key => $value) {
742 742
                 // Encode the value and append the data
743
-                $encoded_data .= $arg_separator . "$key=" . urlencode( $value );
743
+                $encoded_data .= $arg_separator . "$key=" . urlencode($value);
744 744
             }
745 745
         }
746 746
     }
747 747
 
748 748
     // Convert collected post data to an array
749
-    parse_str( $encoded_data, $data );
749
+    parse_str($encoded_data, $data);
750 750
 
751
-    foreach ( $data as $key => $value ) {
752
-        if ( false !== strpos( $key, 'amp;' ) ) {
753
-            $new_key = str_replace( '&amp;', '&', $key );
754
-            $new_key = str_replace( 'amp;', '&' , $new_key );
751
+    foreach ($data as $key => $value) {
752
+        if (false !== strpos($key, 'amp;')) {
753
+            $new_key = str_replace('&amp;', '&', $key);
754
+            $new_key = str_replace('amp;', '&', $new_key);
755 755
 
756
-            unset( $data[ $key ] );
757
-            $data[ $new_key ] = sanitize_text_field( $value );
756
+            unset($data[$key]);
757
+            $data[$new_key] = sanitize_text_field($value);
758 758
         }
759 759
     }
760 760
     
761 761
     return $data;
762 762
 }
763 763
 
764
-function wpinv_gateway_support_subscription( $gateway ) {
764
+function wpinv_gateway_support_subscription($gateway) {
765 765
     $return = false;
766 766
     
767
-    if ( wpinv_is_gateway_active( $gateway ) ) {
768
-        $return = apply_filters( 'wpinv_' . $gateway . '_support_subscription', false );
767
+    if (wpinv_is_gateway_active($gateway)) {
768
+        $return = apply_filters('wpinv_' . $gateway . '_support_subscription', false);
769 769
     }
770 770
     
771 771
     return $return;
772 772
 }
773 773
 
774
-function wpinv_payment_gateways_on_cart( $gateways = array() ) {
775
-    if ( !empty( $gateways ) && wpinv_cart_has_recurring_item() ) {
776
-        foreach ( $gateways as $gateway => $info ) {
777
-            if ( !wpinv_gateway_support_subscription( $gateway ) ) {
778
-                unset( $gateways[$gateway] );
774
+function wpinv_payment_gateways_on_cart($gateways = array()) {
775
+    if (!empty($gateways) && wpinv_cart_has_recurring_item()) {
776
+        foreach ($gateways as $gateway => $info) {
777
+            if (!wpinv_gateway_support_subscription($gateway)) {
778
+                unset($gateways[$gateway]);
779 779
             }
780 780
         }
781 781
     }
782 782
     
783 783
     return $gateways;
784 784
 }
785
-add_filter( 'wpinv_payment_gateways_on_cart', 'wpinv_payment_gateways_on_cart', 10, 1 );
786 785
\ No newline at end of file
786
+add_filter('wpinv_payment_gateways_on_cart', 'wpinv_payment_gateways_on_cart', 10, 1);
787 787
\ No newline at end of file
Please login to merge, or discard this patch.
includes/libraries/wpinv-euvat/class-wpinv-euvat.php 1 patch
Spacing   +711 added lines, -711 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly.
3
-if (!defined( 'ABSPATH' ) ) exit;
3
+if (!defined('ABSPATH')) exit;
4 4
 
5 5
 class WPInv_EUVat {
6 6
     private static $is_ajax = false;
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
     private static $instance = false;
9 9
     
10 10
     public static function get_instance() {
11
-        if ( !self::$instance ) {
11
+        if (!self::$instance) {
12 12
             self::$instance = new self();
13 13
             self::$instance->actions();
14 14
         }
@@ -17,137 +17,137 @@  discard block
 block discarded – undo
17 17
     }
18 18
     
19 19
     public function __construct() {
20
-        self::$is_ajax          = defined( 'DOING_AJAX' ) && DOING_AJAX;
20
+        self::$is_ajax          = defined('DOING_AJAX') && DOING_AJAX;
21 21
         self::$default_country  = wpinv_get_default_country();
22 22
     }
23 23
     
24 24
     public static function actions() {
25
-        if ( is_admin() ) {
26
-            add_action( 'admin_enqueue_scripts', array( self::$instance, 'enqueue_admin_scripts' ) );
27
-            add_action( 'wpinv_settings_sections_taxes', array( self::$instance, 'section_vat_settings' ) ); 
28
-            add_action( 'wpinv_settings_taxes', array( self::$instance, 'vat_settings' ) );
29
-            add_filter( 'wpinv_settings_taxes-vat_sanitize', array( self::$instance, 'sanitize_vat_settings' ) );
30
-            add_filter( 'wpinv_settings_taxes-vat_rates_sanitize', array( self::$instance, 'sanitize_vat_rates' ) );
31
-            add_action( 'wp_ajax_wpinv_add_vat_class', array( self::$instance, 'add_class' ) );
32
-            add_action( 'wp_ajax_nopriv_wpinv_add_vat_class', array( self::$instance, 'add_class' ) );
33
-            add_action( 'wp_ajax_wpinv_delete_vat_class', array( self::$instance, 'delete_class' ) );
34
-            add_action( 'wp_ajax_nopriv_wpinv_delete_vat_class', array( self::$instance, 'delete_class' ) );
35
-            add_action( 'wp_ajax_wpinv_update_vat_rates', array( self::$instance, 'update_eu_rates' ) );
36
-            add_action( 'wp_ajax_nopriv_wpinv_update_vat_rates', array( self::$instance, 'update_eu_rates' ) );
37
-            add_action( 'wp_ajax_wpinv_geoip2', array( self::$instance, 'geoip2_download_database' ) );
38
-            add_action( 'wp_ajax_nopriv_wpinv_geoip2', array( self::$instance, 'geoip2_download_database' ) );
39
-        }
40
-        
41
-        add_action( 'wp_enqueue_scripts', array( self::$instance, 'enqueue_vat_scripts' ) );
42
-        add_filter( 'wpinv_default_billing_country', array( self::$instance, 'get_user_country' ), 10 );
43
-        add_filter( 'wpinv_get_user_country', array( self::$instance, 'set_user_country' ), 10 );
44
-        add_action( 'wp_ajax_wpinv_vat_validate', array( self::$instance, 'ajax_vat_validate' ) );
45
-        add_action( 'wp_ajax_nopriv_wpinv_vat_validate', array( self::$instance, 'ajax_vat_validate' ) );
46
-        add_action( 'wp_ajax_wpinv_vat_reset', array( self::$instance, 'ajax_vat_reset' ) );
47
-        add_action( 'wp_ajax_nopriv_wpinv_vat_reset', array( self::$instance, 'ajax_vat_reset' ) );
48
-        add_action( 'wpinv_invoice_print_after_line_items', array( self::$instance, 'show_vat_notice' ), 999, 1 );
49
-        if ( wpinv_use_taxes() ) {
50
-            add_action( 'wpinv_after_billing_fields', array( self::$instance, 'checkout_vat_fields' ) );
51
-            if ( self::allow_vat_rules() ) {
52
-                add_action( 'wpinv_checkout_error_checks', array( self::$instance, 'checkout_vat_validate' ), 10, 2 );
53
-                add_filter( 'wpinv_tax_rate', array( self::$instance, 'get_rate' ), 10, 4 );
25
+        if (is_admin()) {
26
+            add_action('admin_enqueue_scripts', array(self::$instance, 'enqueue_admin_scripts'));
27
+            add_action('wpinv_settings_sections_taxes', array(self::$instance, 'section_vat_settings')); 
28
+            add_action('wpinv_settings_taxes', array(self::$instance, 'vat_settings'));
29
+            add_filter('wpinv_settings_taxes-vat_sanitize', array(self::$instance, 'sanitize_vat_settings'));
30
+            add_filter('wpinv_settings_taxes-vat_rates_sanitize', array(self::$instance, 'sanitize_vat_rates'));
31
+            add_action('wp_ajax_wpinv_add_vat_class', array(self::$instance, 'add_class'));
32
+            add_action('wp_ajax_nopriv_wpinv_add_vat_class', array(self::$instance, 'add_class'));
33
+            add_action('wp_ajax_wpinv_delete_vat_class', array(self::$instance, 'delete_class'));
34
+            add_action('wp_ajax_nopriv_wpinv_delete_vat_class', array(self::$instance, 'delete_class'));
35
+            add_action('wp_ajax_wpinv_update_vat_rates', array(self::$instance, 'update_eu_rates'));
36
+            add_action('wp_ajax_nopriv_wpinv_update_vat_rates', array(self::$instance, 'update_eu_rates'));
37
+            add_action('wp_ajax_wpinv_geoip2', array(self::$instance, 'geoip2_download_database'));
38
+            add_action('wp_ajax_nopriv_wpinv_geoip2', array(self::$instance, 'geoip2_download_database'));
39
+        }
40
+        
41
+        add_action('wp_enqueue_scripts', array(self::$instance, 'enqueue_vat_scripts'));
42
+        add_filter('wpinv_default_billing_country', array(self::$instance, 'get_user_country'), 10);
43
+        add_filter('wpinv_get_user_country', array(self::$instance, 'set_user_country'), 10);
44
+        add_action('wp_ajax_wpinv_vat_validate', array(self::$instance, 'ajax_vat_validate'));
45
+        add_action('wp_ajax_nopriv_wpinv_vat_validate', array(self::$instance, 'ajax_vat_validate'));
46
+        add_action('wp_ajax_wpinv_vat_reset', array(self::$instance, 'ajax_vat_reset'));
47
+        add_action('wp_ajax_nopriv_wpinv_vat_reset', array(self::$instance, 'ajax_vat_reset'));
48
+        add_action('wpinv_invoice_print_after_line_items', array(self::$instance, 'show_vat_notice'), 999, 1);
49
+        if (wpinv_use_taxes()) {
50
+            add_action('wpinv_after_billing_fields', array(self::$instance, 'checkout_vat_fields'));
51
+            if (self::allow_vat_rules()) {
52
+                add_action('wpinv_checkout_error_checks', array(self::$instance, 'checkout_vat_validate'), 10, 2);
53
+                add_filter('wpinv_tax_rate', array(self::$instance, 'get_rate'), 10, 4);
54 54
             }
55 55
         }
56 56
     }        
57 57
     
58
-    public static function get_eu_states( $sort = true ) {
59
-        $eu_states = array( 'AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GB', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE' );
60
-        if ( $sort ) {
61
-            $sort = sort( $eu_states );
58
+    public static function get_eu_states($sort = true) {
59
+        $eu_states = array('AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GB', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE');
60
+        if ($sort) {
61
+            $sort = sort($eu_states);
62 62
         }
63 63
         
64
-        return apply_filters( 'wpinv_get_eu_states', $eu_states, $sort );
64
+        return apply_filters('wpinv_get_eu_states', $eu_states, $sort);
65 65
     }
66 66
     
67
-    public static function get_gst_countries( $sort = true ) {
68
-        $gst_countries  = array( 'AU', 'NZ', 'CA', 'CN' );
67
+    public static function get_gst_countries($sort = true) {
68
+        $gst_countries = array('AU', 'NZ', 'CA', 'CN');
69 69
         
70
-        if ( $sort ) {
71
-            $sort = sort( $gst_countries );
70
+        if ($sort) {
71
+            $sort = sort($gst_countries);
72 72
         }
73 73
         
74
-        return apply_filters( 'wpinv_get_gst_countries', $gst_countries, $sort );
74
+        return apply_filters('wpinv_get_gst_countries', $gst_countries, $sort);
75 75
     }
76 76
     
77
-    public static function is_eu_state( $country_code ) {
78
-        $return = !empty( $country_code ) && in_array( strtoupper( $country_code ), self::get_eu_states() ) ? true : false;
77
+    public static function is_eu_state($country_code) {
78
+        $return = !empty($country_code) && in_array(strtoupper($country_code), self::get_eu_states()) ? true : false;
79 79
                 
80
-        return apply_filters( 'wpinv_is_eu_state', $return, $country_code );
80
+        return apply_filters('wpinv_is_eu_state', $return, $country_code);
81 81
     }
82 82
     
83
-    public static function is_gst_country( $country_code ) {
84
-        $return = !empty( $country_code ) && in_array( strtoupper( $country_code ), self::get_gst_countries() ) ? true : false;
83
+    public static function is_gst_country($country_code) {
84
+        $return = !empty($country_code) && in_array(strtoupper($country_code), self::get_gst_countries()) ? true : false;
85 85
                 
86
-        return apply_filters( 'wpinv_is_gst_country', $return, $country_code );
86
+        return apply_filters('wpinv_is_gst_country', $return, $country_code);
87 87
     }
88 88
     
89 89
     public static function enqueue_vat_scripts() {
90
-        if( wpinv_use_taxes() && wpinv_get_option( 'apply_vat_rules' ) ) {
90
+        if (wpinv_use_taxes() && wpinv_get_option('apply_vat_rules')) {
91 91
             self::load_vat_scripts();
92 92
         }
93 93
     }
94 94
 
95
-    public static function load_vat_scripts(){
96
-        $suffix     = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
95
+    public static function load_vat_scripts() {
96
+        $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
97 97
 
98
-        wp_register_script( 'wpinv-vat-validation-script', WPINV_PLUGIN_URL . 'assets/js/jsvat' . $suffix . '.js', array( 'jquery' ),  WPINV_VERSION );
99
-        wp_register_script( 'wpinv-vat-script', WPINV_PLUGIN_URL . 'assets/js/euvat' . $suffix . '.js', array( 'jquery' ),  WPINV_VERSION );
98
+        wp_register_script('wpinv-vat-validation-script', WPINV_PLUGIN_URL . 'assets/js/jsvat' . $suffix . '.js', array('jquery'), WPINV_VERSION);
99
+        wp_register_script('wpinv-vat-script', WPINV_PLUGIN_URL . 'assets/js/euvat' . $suffix . '.js', array('jquery'), WPINV_VERSION);
100 100
 
101
-        $vat_name   = self::get_vat_name();
101
+        $vat_name = self::get_vat_name();
102 102
 
103 103
         $vars = array();
104 104
         $vars['UseTaxes'] = wpinv_use_taxes();
105 105
         $vars['EUStates'] = self::get_eu_states();
106
-        $vars['NoRateSet'] = __( 'You have not set a rate. Do you want to continue?', 'invoicing' );
107
-        $vars['EmptyCompany'] = __( 'Please enter your registered company name!', 'invoicing' );
108
-        $vars['EmptyVAT'] = wp_sprintf( __( 'Please enter your %s number!', 'invoicing' ), $vat_name );
109
-        $vars['TotalsRefreshed'] = wp_sprintf( __( 'The invoice totals will be refreshed to update the %s.', 'invoicing' ), $vat_name );
110
-        $vars['ErrValidateVAT'] = wp_sprintf( __( 'Fail to validate the %s number!', 'invoicing' ), $vat_name );
111
-        $vars['ErrResetVAT'] = wp_sprintf( __( 'Fail to reset the %s number!', 'invoicing' ), $vat_name );
112
-        $vars['ErrInvalidVat'] = wp_sprintf( __( 'The %s number supplied does not have a valid format!', 'invoicing' ), $vat_name );
113
-        $vars['ErrInvalidResponse'] = __( 'An invalid response has been received from the server!', 'invoicing' );
106
+        $vars['NoRateSet'] = __('You have not set a rate. Do you want to continue?', 'invoicing');
107
+        $vars['EmptyCompany'] = __('Please enter your registered company name!', 'invoicing');
108
+        $vars['EmptyVAT'] = wp_sprintf(__('Please enter your %s number!', 'invoicing'), $vat_name);
109
+        $vars['TotalsRefreshed'] = wp_sprintf(__('The invoice totals will be refreshed to update the %s.', 'invoicing'), $vat_name);
110
+        $vars['ErrValidateVAT'] = wp_sprintf(__('Fail to validate the %s number!', 'invoicing'), $vat_name);
111
+        $vars['ErrResetVAT'] = wp_sprintf(__('Fail to reset the %s number!', 'invoicing'), $vat_name);
112
+        $vars['ErrInvalidVat'] = wp_sprintf(__('The %s number supplied does not have a valid format!', 'invoicing'), $vat_name);
113
+        $vars['ErrInvalidResponse'] = __('An invalid response has been received from the server!', 'invoicing');
114 114
         $vars['ApplyVATRules'] = $vars['UseTaxes'] ? self::allow_vat_rules() : false;
115 115
         $vars['HideVatFields'] = $vars['ApplyVATRules'] ? self::hide_vat_fields() : true;
116
-        $vars['ErrResponse'] = __( 'The request response is invalid!', 'invoicing' );
117
-        $vars['ErrRateResponse'] = __( 'The get rate request response is invalid', 'invoicing' );
118
-        $vars['PageRefresh'] = __( 'The page will be refreshed in 10 seconds to show the new options.', 'invoicing' );
119
-        $vars['RequestResponseNotValidJSON'] = __( 'The get rate request response is not valid JSON', 'invoicing' );
120
-        $vars['GetRateRequestFailed'] = __( 'The get rate request failed: ', 'invoicing' );
121
-        $vars['NoRateInformationInResponse'] = __( 'The get rate request response does not contain any rate information', 'invoicing' );
122
-        $vars['RatesUpdated'] = __( 'The rates have been updated. Press the save button to record these new rates.', 'invoicing' );
123
-        $vars['IPAddressInformation'] = __( 'IP Address Information', 'invoicing' );
124
-        $vars['VatValidating'] = wp_sprintf( __( 'Validating %s number...', 'invoicing' ), $vat_name );
125
-        $vars['VatReseting'] = __( 'Reseting...', 'invoicing' );
126
-        $vars['VatValidated'] = wp_sprintf( __( '%s number validated', 'invoicing' ), $vat_name );
127
-        $vars['VatNotValidated'] = wp_sprintf( __( '%s number not validated', 'invoicing' ), $vat_name );
128
-        $vars['ConfirmDeleteClass'] = __( 'Are you sure you wish to delete this rates class?', 'invoicing' );
116
+        $vars['ErrResponse'] = __('The request response is invalid!', 'invoicing');
117
+        $vars['ErrRateResponse'] = __('The get rate request response is invalid', 'invoicing');
118
+        $vars['PageRefresh'] = __('The page will be refreshed in 10 seconds to show the new options.', 'invoicing');
119
+        $vars['RequestResponseNotValidJSON'] = __('The get rate request response is not valid JSON', 'invoicing');
120
+        $vars['GetRateRequestFailed'] = __('The get rate request failed: ', 'invoicing');
121
+        $vars['NoRateInformationInResponse'] = __('The get rate request response does not contain any rate information', 'invoicing');
122
+        $vars['RatesUpdated'] = __('The rates have been updated. Press the save button to record these new rates.', 'invoicing');
123
+        $vars['IPAddressInformation'] = __('IP Address Information', 'invoicing');
124
+        $vars['VatValidating'] = wp_sprintf(__('Validating %s number...', 'invoicing'), $vat_name);
125
+        $vars['VatReseting'] = __('Reseting...', 'invoicing');
126
+        $vars['VatValidated'] = wp_sprintf(__('%s number validated', 'invoicing'), $vat_name);
127
+        $vars['VatNotValidated'] = wp_sprintf(__('%s number not validated', 'invoicing'), $vat_name);
128
+        $vars['ConfirmDeleteClass'] = __('Are you sure you wish to delete this rates class?', 'invoicing');
129 129
         $vars['isFront'] = is_admin() ? false : true;
130 130
         $vars['baseCountry'] = wpinv_get_default_country();
131
-        $vars['disableVATSameCountry'] = ( self::same_country_rule() == 'no' ? true : false );
132
-        $vars['disableVATSimpleCheck'] = wpinv_get_option( 'vat_offline_check' ) ? true : false;
131
+        $vars['disableVATSameCountry'] = (self::same_country_rule() == 'no' ? true : false);
132
+        $vars['disableVATSimpleCheck'] = wpinv_get_option('vat_offline_check') ? true : false;
133 133
 
134
-        wp_enqueue_script( 'wpinv-vat-validation-script' );
135
-        wp_enqueue_script( 'wpinv-vat-script' );
136
-        wp_localize_script( 'wpinv-vat-script', 'WPInv_VAT_Vars', $vars );
134
+        wp_enqueue_script('wpinv-vat-validation-script');
135
+        wp_enqueue_script('wpinv-vat-script');
136
+        wp_localize_script('wpinv-vat-script', 'WPInv_VAT_Vars', $vars);
137 137
     }
138 138
 
139 139
     public static function enqueue_admin_scripts() {
140
-        if( isset( $_GET['page'] ) && 'wpinv-settings' == $_GET['page'] ) {
140
+        if (isset($_GET['page']) && 'wpinv-settings' == $_GET['page']) {
141 141
             self::load_vat_scripts();
142 142
         }
143 143
     }
144 144
     
145
-    public static function section_vat_settings( $sections ) {
146
-        if ( !empty( $sections ) ) {
147
-            $sections['vat'] = __( 'EU VAT Settings', 'invoicing' );
145
+    public static function section_vat_settings($sections) {
146
+        if (!empty($sections)) {
147
+            $sections['vat'] = __('EU VAT Settings', 'invoicing');
148 148
             
149
-            if ( self::allow_vat_classes() ) {
150
-                $sections['vat_rates'] = __( 'EU VAT Rates', 'invoicing' );
149
+            if (self::allow_vat_classes()) {
150
+                $sections['vat_rates'] = __('EU VAT Rates', 'invoicing');
151 151
             }
152 152
         }
153 153
         return $sections;
@@ -156,52 +156,52 @@  discard block
 block discarded – undo
156 156
     public static function vat_rates_settings() {
157 157
         $vat_classes = self::get_rate_classes();
158 158
         $vat_rates = array();
159
-        $vat_class = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' && isset( $vat_classes[$_REQUEST['wpi_sub']] )? sanitize_text_field( $_REQUEST['wpi_sub'] ) : '_new';
160
-        $current_url = remove_query_arg( 'wpi_sub' );
159
+        $vat_class = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' && isset($vat_classes[$_REQUEST['wpi_sub']]) ? sanitize_text_field($_REQUEST['wpi_sub']) : '_new';
160
+        $current_url = remove_query_arg('wpi_sub');
161 161
         
162 162
         $vat_rates['vat_rates_header'] = array(
163 163
             'id' => 'vat_rates_header',
164
-            'name' => '<h3>' . __( 'Manage VAT Rates', 'invoicing' ) . '</h3>',
164
+            'name' => '<h3>' . __('Manage VAT Rates', 'invoicing') . '</h3>',
165 165
             'desc' => '',
166 166
             'type' => 'header',
167 167
             'size' => 'regular'
168 168
         );
169 169
         $vat_rates['vat_rates_class'] = array(
170 170
             'id'          => 'vat_rates_class',
171
-            'name'        => __( 'Edit VAT Rates', 'invoicing' ),
172
-            'desc'        => __( 'The standard rate will apply where no explicit rate is provided.', 'invoicing' ),
171
+            'name'        => __('Edit VAT Rates', 'invoicing'),
172
+            'desc'        => __('The standard rate will apply where no explicit rate is provided.', 'invoicing'),
173 173
             'type'        => 'select',
174
-            'options'     => array_merge( $vat_classes, array( '_new' => __( 'Add New Rate Class', 'invoicing' ) ) ),
175
-            'placeholder' => __( 'Select a VAT Rate', 'invoicing' ),
174
+            'options'     => array_merge($vat_classes, array('_new' => __('Add New Rate Class', 'invoicing'))),
175
+            'placeholder' => __('Select a VAT Rate', 'invoicing'),
176 176
             'selected'    => $vat_class,
177 177
             'class'       => 'wpi_select2',
178 178
             'onchange'    => 'document.location.href="' . $current_url . '&wpi_sub=" + this.value;',
179 179
         );
180 180
         
181
-        if ( $vat_class != '_standard' && $vat_class != '_new' ) {
181
+        if ($vat_class != '_standard' && $vat_class != '_new') {
182 182
             $vat_rates['vat_rate_delete'] = array(
183 183
                 'id'   => 'vat_rate_delete',
184 184
                 'type' => 'vat_rate_delete',
185 185
             );
186 186
         }
187 187
                     
188
-        if ( $vat_class == '_new' ) {
188
+        if ($vat_class == '_new') {
189 189
             $vat_rates['vat_rates_settings'] = array(
190 190
                 'id' => 'vat_rates_settings',
191
-                'name' => '<h3>' . __( 'Add New Rate Class', 'invoicing' ) . '</h3>',
191
+                'name' => '<h3>' . __('Add New Rate Class', 'invoicing') . '</h3>',
192 192
                 'type' => 'header',
193 193
             );
194 194
             $vat_rates['vat_rate_name'] = array(
195 195
                 'id'   => 'vat_rate_name',
196
-                'name' => __( 'Name', 'invoicing' ),
197
-                'desc' => __( 'A short name for the new VAT Rate class', 'invoicing' ),
196
+                'name' => __('Name', 'invoicing'),
197
+                'desc' => __('A short name for the new VAT Rate class', 'invoicing'),
198 198
                 'type' => 'text',
199 199
                 'size' => 'regular',
200 200
             );
201 201
             $vat_rates['vat_rate_desc'] = array(
202 202
                 'id'   => 'vat_rate_desc',
203
-                'name' => __( 'Description', 'invoicing' ),
204
-                'desc' => __( 'Manage VAT Rate class', 'invoicing' ),
203
+                'name' => __('Description', 'invoicing'),
204
+                'desc' => __('Manage VAT Rate class', 'invoicing'),
205 205
                 'type' => 'text',
206 206
                 'size' => 'regular',
207 207
             );
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
             $vat_rates['vat_rates'] = array(
214 214
                 'id'   => 'vat_rates',
215 215
                 'name' => '<h3>' . $vat_classes[$vat_class] . '</h3>',
216
-                'desc' => self::get_class_desc( $vat_class ),
216
+                'desc' => self::get_class_desc($vat_class),
217 217
                 'type' => 'vat_rates',
218 218
             );
219 219
         }
@@ -221,12 +221,12 @@  discard block
 block discarded – undo
221 221
         return $vat_rates;
222 222
     }
223 223
     
224
-    public static function vat_settings( $settings ) {
225
-        if ( !empty( $settings ) ) {    
224
+    public static function vat_settings($settings) {
225
+        if (!empty($settings)) {    
226 226
             $vat_settings = array();
227 227
             $vat_settings['vat_company_title'] = array(
228 228
                 'id' => 'vat_company_title',
229
-                'name' => '<h3>' . __( 'Your Company Details', 'invoicing' ) . '</h3>',
229
+                'name' => '<h3>' . __('Your Company Details', 'invoicing') . '</h3>',
230 230
                 'desc' => '',
231 231
                 'type' => 'header',
232 232
                 'size' => 'regular'
@@ -234,22 +234,22 @@  discard block
 block discarded – undo
234 234
             
235 235
             $vat_settings['vat_company_name'] = array(
236 236
                 'id' => 'vat_company_name',
237
-                'name' => __( 'Your Company Name', 'invoicing' ),
238
-                'desc' => wp_sprintf(__( 'Your company name as it appears on your VAT return, you can verify it via your VAT ID on the %sEU VIES System.%s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ),
237
+                'name' => __('Your Company Name', 'invoicing'),
238
+                'desc' => wp_sprintf(__('Your company name as it appears on your VAT return, you can verify it via your VAT ID on the %sEU VIES System.%s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'),
239 239
                 'type' => 'text',
240 240
                 'size' => 'regular',
241 241
             );
242 242
             
243 243
             $vat_settings['vat_number'] = array(
244 244
                 'id'   => 'vat_number',
245
-                'name' => __( 'Your VAT Number', 'invoicing' ),
245
+                'name' => __('Your VAT Number', 'invoicing'),
246 246
                 'type' => 'vat_number',
247 247
                 'size' => 'regular',
248 248
             );
249 249
 
250 250
             $vat_settings['vat_settings_title'] = array(
251 251
                 'id' => 'vat_settings_title',
252
-                'name' => '<h3>' . __( 'Apply VAT Settings', 'invoicing' ) . '</h3>',
252
+                'name' => '<h3>' . __('Apply VAT Settings', 'invoicing') . '</h3>',
253 253
                 'desc' => '',
254 254
                 'type' => 'header',
255 255
                 'size' => 'regular'
@@ -257,8 +257,8 @@  discard block
 block discarded – undo
257 257
 
258 258
             $vat_settings['apply_vat_rules'] = array(
259 259
                 'id' => 'apply_vat_rules',
260
-                'name' => __( 'Enable VAT Rules', 'invoicing' ),
261
-                'desc' => __( 'Apply VAT to consumer sales from IP addresses within the EU, even if the billing address is outside the EU.', 'invoicing' ) . '<br><font style="color:red">' . __( 'Do not disable unless you know what you are doing.', 'invoicing' ) . '</font>',
260
+                'name' => __('Enable VAT Rules', 'invoicing'),
261
+                'desc' => __('Apply VAT to consumer sales from IP addresses within the EU, even if the billing address is outside the EU.', 'invoicing') . '<br><font style="color:red">' . __('Do not disable unless you know what you are doing.', 'invoicing') . '</font>',
262 262
                 'type' => 'checkbox',
263 263
                 'std' => '1'
264 264
             );
@@ -274,8 +274,8 @@  discard block
 block discarded – undo
274 274
 
275 275
             $vat_settings['vat_prevent_b2c_purchase'] = array(
276 276
                 'id' => 'vat_prevent_b2c_purchase',
277
-                'name' => __( 'Prevent EU B2C Sales', 'invoicing' ),
278
-                'desc' => __( 'Enable this option if you are not registered for VAT in the EU.', 'invoicing' ),
277
+                'name' => __('Prevent EU B2C Sales', 'invoicing'),
278
+                'desc' => __('Enable this option if you are not registered for VAT in the EU.', 'invoicing'),
279 279
                 'type' => 'checkbox'
280 280
             );
281 281
 
@@ -283,22 +283,22 @@  discard block
 block discarded – undo
283 283
 
284 284
             $vat_settings['vat_same_country_rule'] = array(
285 285
                 'id'          => 'vat_same_country_rule',
286
-                'name'        => __( 'Same Country Rule', 'invoicing' ),
287
-                'desc'        => __( 'Select how you want to handle VAT charge if sales are in the same country as the base country.', 'invoicing' ),
286
+                'name'        => __('Same Country Rule', 'invoicing'),
287
+                'desc'        => __('Select how you want to handle VAT charge if sales are in the same country as the base country.', 'invoicing'),
288 288
                 'type'        => 'select',
289 289
                 'options'     => array(
290
-                    ''          => __( 'Normal', 'invoicing' ),
291
-                    'no'        => __( 'No VAT', 'invoicing' ),
292
-                    'always'    => __( 'Always apply VAT', 'invoicing' ),
290
+                    ''          => __('Normal', 'invoicing'),
291
+                    'no'        => __('No VAT', 'invoicing'),
292
+                    'always'    => __('Always apply VAT', 'invoicing'),
293 293
                 ),
294
-                'placeholder' => __( 'Select an option', 'invoicing' ),
294
+                'placeholder' => __('Select an option', 'invoicing'),
295 295
                 'std'         => '',
296 296
                 'class'   => 'wpi_select2',
297 297
             );
298 298
 
299 299
             $vat_settings['vat_checkout_title'] = array(
300 300
                 'id' => 'vat_checkout_title',
301
-                'name' => '<h3>' . __( 'Checkout Fields', 'invoicing' ) . '</h3>',
301
+                'name' => '<h3>' . __('Checkout Fields', 'invoicing') . '</h3>',
302 302
                 'desc' => '',
303 303
                 'type' => 'header',
304 304
                 'size' => 'regular'
@@ -306,14 +306,14 @@  discard block
 block discarded – undo
306 306
 
307 307
             $vat_settings['vat_disable_fields'] = array(
308 308
                 'id' => 'vat_disable_fields',
309
-                'name' => __( 'Disable VAT Fields', 'invoicing' ),
310
-                'desc' => __( 'Disable VAT fields if Invoicing is being used for GST.', 'invoicing' ) . '<br><font style="color:red">' . __( 'Do not disable if you have enabled Prevent EU B2C sales, otherwise Prevent EU B2C sales setting will not work.', 'invoicing' ) . '</font>',
309
+                'name' => __('Disable VAT Fields', 'invoicing'),
310
+                'desc' => __('Disable VAT fields if Invoicing is being used for GST.', 'invoicing') . '<br><font style="color:red">' . __('Do not disable if you have enabled Prevent EU B2C sales, otherwise Prevent EU B2C sales setting will not work.', 'invoicing') . '</font>',
311 311
                 'type' => 'checkbox'
312 312
             );
313 313
 
314 314
             $vat_settings['vat_ip_lookup'] = array(
315 315
                 'id'   => 'vat_ip_lookup',
316
-                'name' => __( 'IP Country Look-up', 'invoicing' ),
316
+                'name' => __('IP Country Look-up', 'invoicing'),
317 317
                 'type' => 'vat_ip_lookup',
318 318
                 'size' => 'regular',
319 319
                 'std' => 'default',
@@ -322,21 +322,21 @@  discard block
 block discarded – undo
322 322
 
323 323
             $vat_settings['hide_ip_address'] = array(
324 324
                 'id' => 'hide_ip_address',
325
-                'name' => __( 'Hide IP Info at Checkout', 'invoicing' ),
326
-                'desc' => __( 'Hide the user IP info at checkout.', 'invoicing' ),
325
+                'name' => __('Hide IP Info at Checkout', 'invoicing'),
326
+                'desc' => __('Hide the user IP info at checkout.', 'invoicing'),
327 327
                 'type' => 'checkbox'
328 328
             );
329 329
 
330 330
             $vat_settings['vat_ip_country_default'] = array(
331 331
                 'id' => 'vat_ip_country_default',
332
-                'name' => __( 'Enable IP Country as Default', 'invoicing' ),
333
-                'desc' => __( 'Show the country of the users IP as the default country, otherwise the site default country will be used.', 'invoicing' ),
332
+                'name' => __('Enable IP Country as Default', 'invoicing'),
333
+                'desc' => __('Show the country of the users IP as the default country, otherwise the site default country will be used.', 'invoicing'),
334 334
                 'type' => 'checkbox'
335 335
             );
336 336
 
337 337
             $vat_settings['vies_validation_title'] = array(
338 338
                 'id' => 'vies_validation_title',
339
-                'name' => '<h3>' . __( 'VIES Validation', 'invoicing' ) . '</h3>',
339
+                'name' => '<h3>' . __('VIES Validation', 'invoicing') . '</h3>',
340 340
                 'desc' => '',
341 341
                 'type' => 'header',
342 342
                 'size' => 'regular'
@@ -344,37 +344,37 @@  discard block
 block discarded – undo
344 344
 
345 345
             $vat_settings['vat_vies_check'] = array(
346 346
                 'id' => 'vat_vies_check',
347
-                'name' => __( 'Disable VIES VAT ID Check', 'invoicing' ),
348
-                'desc' => wp_sprintf( __( 'Prevent VAT numbers from being validated by the %sEU VIES System.%s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ),
347
+                'name' => __('Disable VIES VAT ID Check', 'invoicing'),
348
+                'desc' => wp_sprintf(__('Prevent VAT numbers from being validated by the %sEU VIES System.%s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'),
349 349
                 'type' => 'checkbox'
350 350
             );
351 351
 
352 352
             $vat_settings['vat_disable_company_name_check'] = array(
353 353
                 'id' => 'vat_disable_company_name_check',
354
-                'name' => __( 'Disable VIES Name Check', 'invoicing' ),
355
-                'desc' => wp_sprintf( __( 'Prevent company name from being validated by the %sEU VIES System.%s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ),
354
+                'name' => __('Disable VIES Name Check', 'invoicing'),
355
+                'desc' => wp_sprintf(__('Prevent company name from being validated by the %sEU VIES System.%s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'),
356 356
                 'type' => 'checkbox'
357 357
             );
358 358
 
359 359
             $vat_settings['vat_offline_check'] = array(
360 360
                 'id' => 'vat_offline_check',
361
-                'name' => __( 'Disable Basic Checks', 'invoicing' ),
362
-                'desc' => __( 'Disable basic JS checks for correct format of VAT number. (Not Recommended)', 'invoicing' ),
361
+                'name' => __('Disable Basic Checks', 'invoicing'),
362
+                'desc' => __('Disable basic JS checks for correct format of VAT number. (Not Recommended)', 'invoicing'),
363 363
                 'type' => 'checkbox'
364 364
             );
365 365
             
366 366
 
367 367
             $settings['vat'] = $vat_settings;
368 368
             
369
-            if ( self::allow_vat_classes() ) {
369
+            if (self::allow_vat_classes()) {
370 370
                 $settings['vat_rates'] = self::vat_rates_settings();
371 371
             }
372 372
             
373 373
             $eu_fallback_rate = array(
374 374
                 'id'   => 'eu_fallback_rate',
375
-                'name' => '<h3>' . __( 'VAT rate for EU member states', 'invoicing' ) . '</h3>',
375
+                'name' => '<h3>' . __('VAT rate for EU member states', 'invoicing') . '</h3>',
376 376
                 'type' => 'eu_fallback_rate',
377
-                'desc' => __( 'Enter the VAT rate to be charged for EU member states. You can edit the rates for each member state when a country rate has been set up by pressing this button.', 'invoicing' ),
377
+                'desc' => __('Enter the VAT rate to be charged for EU member states. You can edit the rates for each member state when a country rate has been set up by pressing this button.', 'invoicing'),
378 378
                 'std'  => '20',
379 379
                 'size' => 'small'
380 380
             );
@@ -390,11 +390,11 @@  discard block
 block discarded – undo
390 390
         $database_url       = 'http' . (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] === 'on' ? 's' : '') . '://geolite.maxmind.com/download/geoip/database/';
391 391
         $destination_dir    = $upload_dir['basedir'] . '/invoicing';
392 392
         
393
-        if ( !is_dir( $destination_dir ) ) { 
394
-            mkdir( $destination_dir );
393
+        if (!is_dir($destination_dir)) { 
394
+            mkdir($destination_dir);
395 395
         }
396 396
         
397
-        $database_files     = array(
397
+        $database_files = array(
398 398
             'country'   => array(
399 399
                 'source'        => $database_url . 'GeoLite2-Country.mmdb.gz',
400 400
                 'destination'   => $destination_dir . '/GeoLite2-Country.mmdb',
@@ -405,57 +405,57 @@  discard block
 block discarded – undo
405 405
             )
406 406
         );
407 407
 
408
-        foreach( $database_files as $database => $files ) {
409
-            $result = self::geoip2_download_file( $files['source'], $files['destination'] );
408
+        foreach ($database_files as $database => $files) {
409
+            $result = self::geoip2_download_file($files['source'], $files['destination']);
410 410
             
411
-            if ( empty( $result['success'] ) ) {
411
+            if (empty($result['success'])) {
412 412
                 echo $result['message'];
413 413
                 exit;
414 414
             }
415 415
             
416
-            wpinv_update_option( 'wpinv_geoip2_date_updated', current_time( 'timestamp' ) );
417
-            echo sprintf(__( 'GeoIP2 %s database updated successfully.', 'invoicing' ), $database ) . ' ';
416
+            wpinv_update_option('wpinv_geoip2_date_updated', current_time('timestamp'));
417
+            echo sprintf(__('GeoIP2 %s database updated successfully.', 'invoicing'), $database) . ' ';
418 418
         }
419 419
         
420 420
         exit;
421 421
     }
422 422
     
423
-    public static function geoip2_download_file( $source_url, $destination_file ) {
423
+    public static function geoip2_download_file($source_url, $destination_file) {
424 424
         $success    = false;
425 425
         $message    = '';
426 426
         
427
-        if ( !function_exists( 'download_url' ) ) {
428
-            require_once( ABSPATH . 'wp-admin/includes/file.php' );
427
+        if (!function_exists('download_url')) {
428
+            require_once(ABSPATH . 'wp-admin/includes/file.php');
429 429
         }
430 430
 
431
-        $temp_file  = download_url( $source_url );
431
+        $temp_file = download_url($source_url);
432 432
         
433
-        if ( is_wp_error( $temp_file ) ) {
434
-            $message = sprintf( __( 'Error while downloading GeoIp2 database( %s ): %s', 'invoicing' ), $source_url, $temp_file->get_error_message() );
433
+        if (is_wp_error($temp_file)) {
434
+            $message = sprintf(__('Error while downloading GeoIp2 database( %s ): %s', 'invoicing'), $source_url, $temp_file->get_error_message());
435 435
         } else {
436
-            $handle = gzopen( $temp_file, 'rb' );
436
+            $handle = gzopen($temp_file, 'rb');
437 437
             
438
-            if ( $handle ) {
439
-                $fopen  = fopen( $destination_file, 'wb' );
440
-                if ( $fopen ) {
441
-                    while ( ( $data = gzread( $handle, 4096 ) ) != false ) {
442
-                        fwrite( $fopen, $data );
438
+            if ($handle) {
439
+                $fopen = fopen($destination_file, 'wb');
440
+                if ($fopen) {
441
+                    while (($data = gzread($handle, 4096)) != false) {
442
+                        fwrite($fopen, $data);
443 443
                     }
444 444
 
445
-                    gzclose( $handle );
446
-                    fclose( $fopen );
445
+                    gzclose($handle);
446
+                    fclose($fopen);
447 447
                         
448 448
                     $success = true;
449 449
                 } else {
450
-                    gzclose( $handle );
451
-                    $message = sprintf( __( 'Error could not open destination GeoIp2 database file for writing: %s', 'invoicing' ), $destination_file );
450
+                    gzclose($handle);
451
+                    $message = sprintf(__('Error could not open destination GeoIp2 database file for writing: %s', 'invoicing'), $destination_file);
452 452
                 }
453 453
             } else {
454
-                $message = sprintf( __( 'Error could not open GeoIp2 database file for reading: %s', 'invoicing' ), $temp_file );
454
+                $message = sprintf(__('Error could not open GeoIp2 database file for reading: %s', 'invoicing'), $temp_file);
455 455
             }
456 456
             
457
-            if ( file_exists( $temp_file ) ) {
458
-                unlink( $temp_file );
457
+            if (file_exists($temp_file)) {
458
+                unlink($temp_file);
459 459
             }
460 460
         }
461 461
         
@@ -467,11 +467,11 @@  discard block
 block discarded – undo
467 467
     }
468 468
     
469 469
     public static function load_geoip2() {
470
-        if ( defined( 'WPINV_GEOIP2_LODDED' ) ) {
470
+        if (defined('WPINV_GEOIP2_LODDED')) {
471 471
             return;
472 472
         }
473 473
         
474
-        if ( !class_exists( '\MaxMind\Db\Reader' ) ) {
474
+        if (!class_exists('\MaxMind\Db\Reader')) {
475 475
             $maxmind_db_files = array(
476 476
                 'Reader/Decoder.php',
477 477
                 'Reader/InvalidDatabaseException.php',
@@ -480,12 +480,12 @@  discard block
 block discarded – undo
480 480
                 'Reader.php',
481 481
             );
482 482
             
483
-            foreach ( $maxmind_db_files as $key => $file ) {
484
-                require_once( WPINV_PLUGIN_DIR . 'includes/libraries/MaxMind/Db/' . $file );
483
+            foreach ($maxmind_db_files as $key => $file) {
484
+                require_once(WPINV_PLUGIN_DIR . 'includes/libraries/MaxMind/Db/' . $file);
485 485
             }
486 486
         }
487 487
         
488
-        if ( !class_exists( '\GeoIp2\Database\Reader' ) ) {        
488
+        if (!class_exists('\GeoIp2\Database\Reader')) {        
489 489
             $geoip2_files = array(
490 490
                 'ProviderInterface.php',
491 491
                 'Compat/JsonSerializable.php',
@@ -519,23 +519,23 @@  discard block
 block discarded – undo
519 519
                 'WebService/Client.php',
520 520
             );
521 521
             
522
-            foreach ( $geoip2_files as $key => $file ) {
523
-                require_once( WPINV_PLUGIN_DIR . 'includes/libraries/GeoIp2/' . $file );
522
+            foreach ($geoip2_files as $key => $file) {
523
+                require_once(WPINV_PLUGIN_DIR . 'includes/libraries/GeoIp2/' . $file);
524 524
             }
525 525
         }
526 526
 
527
-        define( 'WPINV_GEOIP2_LODDED', true );
527
+        define('WPINV_GEOIP2_LODDED', true);
528 528
     }
529 529
 
530 530
     public static function geoip2_country_dbfile() {
531 531
         $upload_dir = wp_upload_dir();
532 532
 
533
-        if ( !isset( $upload_dir['basedir'] ) ) {
533
+        if (!isset($upload_dir['basedir'])) {
534 534
             return false;
535 535
         }
536 536
 
537 537
         $filename = $upload_dir['basedir'] . '/invoicing/GeoLite2-Country.mmdb';
538
-        if ( !file_exists( $filename ) ) {
538
+        if (!file_exists($filename)) {
539 539
             return false;
540 540
         }
541 541
         
@@ -545,12 +545,12 @@  discard block
 block discarded – undo
545 545
     public static function geoip2_city_dbfile() {
546 546
         $upload_dir = wp_upload_dir();
547 547
 
548
-        if ( !isset( $upload_dir['basedir'] ) ) {
548
+        if (!isset($upload_dir['basedir'])) {
549 549
             return false;
550 550
         }
551 551
 
552 552
         $filename = $upload_dir['basedir'] . '/invoicing/GeoLite2-City.mmdb';
553
-        if ( !file_exists( $filename ) ) {
553
+        if (!file_exists($filename)) {
554 554
             return false;
555 555
         }
556 556
         
@@ -561,10 +561,10 @@  discard block
 block discarded – undo
561 561
         try {
562 562
             self::load_geoip2();
563 563
 
564
-            if ( $filename = self::geoip2_country_dbfile() ) {
565
-                return new \GeoIp2\Database\Reader( $filename );
564
+            if ($filename = self::geoip2_country_dbfile()) {
565
+                return new \GeoIp2\Database\Reader($filename);
566 566
             }
567
-        } catch( Exception $e ) {
567
+        } catch (Exception $e) {
568 568
             return false;
569 569
         }
570 570
         
@@ -575,173 +575,173 @@  discard block
 block discarded – undo
575 575
         try {
576 576
             self::load_geoip2();
577 577
 
578
-            if ( $filename = self::geoip2_city_dbfile() ) {
579
-                return new \GeoIp2\Database\Reader( $filename );
578
+            if ($filename = self::geoip2_city_dbfile()) {
579
+                return new \GeoIp2\Database\Reader($filename);
580 580
             }
581
-        } catch( Exception $e ) {
581
+        } catch (Exception $e) {
582 582
             return false;
583 583
         }
584 584
         
585 585
         return false;
586 586
     }
587 587
 
588
-    public static function geoip2_country_record( $ip_address ) {
588
+    public static function geoip2_country_record($ip_address) {
589 589
         try {
590 590
             $reader = self::geoip2_country_reader();
591 591
 
592
-            if ( $reader ) {
593
-                $record = $reader->country( $ip_address );
592
+            if ($reader) {
593
+                $record = $reader->country($ip_address);
594 594
                 
595
-                if ( !empty( $record->country->isoCode ) ) {
595
+                if (!empty($record->country->isoCode)) {
596 596
                     return $record;
597 597
                 }
598 598
             }
599
-        } catch(\InvalidArgumentException $e) {
600
-            wpinv_error_log( $e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )' );
599
+        } catch (\InvalidArgumentException $e) {
600
+            wpinv_error_log($e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )');
601 601
             
602 602
             return false;
603
-        } catch(\GeoIp2\Exception\AddressNotFoundException $e) {
604
-            wpinv_error_log( $e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )' );
603
+        } catch (\GeoIp2\Exception\AddressNotFoundException $e) {
604
+            wpinv_error_log($e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )');
605 605
             
606 606
             return false;
607
-        } catch( Exception $e ) {
607
+        } catch (Exception $e) {
608 608
             return false;
609 609
         }
610 610
         
611 611
         return false;
612 612
     }
613 613
 
614
-    public static function geoip2_city_record( $ip_address ) {
614
+    public static function geoip2_city_record($ip_address) {
615 615
         try {
616 616
             $reader = self::geoip2_city_reader();
617 617
 
618
-            if ( $reader ) {
619
-                $record = $reader->city( $ip_address );
618
+            if ($reader) {
619
+                $record = $reader->city($ip_address);
620 620
                 
621
-                if ( !empty( $record->country->isoCode ) ) {
621
+                if (!empty($record->country->isoCode)) {
622 622
                     return $record;
623 623
                 }
624 624
             }
625
-        } catch(\InvalidArgumentException $e) {
626
-            wpinv_error_log( $e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )' );
625
+        } catch (\InvalidArgumentException $e) {
626
+            wpinv_error_log($e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )');
627 627
             
628 628
             return false;
629
-        } catch(\GeoIp2\Exception\AddressNotFoundException $e) {
630
-            wpinv_error_log( $e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )' );
629
+        } catch (\GeoIp2\Exception\AddressNotFoundException $e) {
630
+            wpinv_error_log($e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )');
631 631
             
632 632
             return false;
633
-        } catch( Exception $e ) {
633
+        } catch (Exception $e) {
634 634
             return false;
635 635
         }
636 636
         
637 637
         return false;
638 638
     }
639 639
 
640
-    public static function geoip2_country_code( $ip_address ) {
641
-        $record = self::geoip2_country_record( $ip_address );
642
-        return !empty( $record->country->isoCode ) ? $record->country->isoCode : wpinv_get_default_country();
640
+    public static function geoip2_country_code($ip_address) {
641
+        $record = self::geoip2_country_record($ip_address);
642
+        return !empty($record->country->isoCode) ? $record->country->isoCode : wpinv_get_default_country();
643 643
     }
644 644
 
645 645
     // Find country by IP address.
646
-    public static function get_country_by_ip( $ip = '' ) {
646
+    public static function get_country_by_ip($ip = '') {
647 647
         global $wpinv_ip_address_country;
648 648
         
649
-        if ( !empty( $wpinv_ip_address_country ) ) {
649
+        if (!empty($wpinv_ip_address_country)) {
650 650
             return $wpinv_ip_address_country;
651 651
         }
652 652
         
653
-        if ( empty( $ip ) ) {
653
+        if (empty($ip)) {
654 654
             $ip = wpinv_get_ip();
655 655
         }
656 656
 
657
-        $ip_country_service = wpinv_get_option( 'vat_ip_lookup' );
658
-        $is_default         = empty( $ip_country_service ) || $ip_country_service === 'default' ? true : false;
657
+        $ip_country_service = wpinv_get_option('vat_ip_lookup');
658
+        $is_default         = empty($ip_country_service) || $ip_country_service === 'default' ? true : false;
659 659
 
660
-        if ( !empty( $ip ) && $ip !== '127.0.0.1' ) { // For 127.0.0.1(localhost) use default country.
661
-            if ( function_exists( 'geoip_country_code_by_name') && ( $ip_country_service === 'geoip' || $is_default ) ) {
660
+        if (!empty($ip) && $ip !== '127.0.0.1') { // For 127.0.0.1(localhost) use default country.
661
+            if (function_exists('geoip_country_code_by_name') && ($ip_country_service === 'geoip' || $is_default)) {
662 662
                 try {
663
-                    $wpinv_ip_address_country = geoip_country_code_by_name( $ip );
664
-                } catch( Exception $e ) {
665
-                    wpinv_error_log( $e->getMessage(), 'GeoIP Lookup( ' . $ip . ' )' );
663
+                    $wpinv_ip_address_country = geoip_country_code_by_name($ip);
664
+                } catch (Exception $e) {
665
+                    wpinv_error_log($e->getMessage(), 'GeoIP Lookup( ' . $ip . ' )');
666 666
                 }
667
-            } else if ( self::geoip2_country_dbfile() && ( $ip_country_service === 'geoip2' || $is_default ) ) {
668
-                $wpinv_ip_address_country = self::geoip2_country_code( $ip );
669
-            } else if ( function_exists( 'simplexml_load_file' ) && ( $ip_country_service === 'geoplugin' || $is_default ) ) {
670
-                $load_xml = simplexml_load_file( 'http://www.geoplugin.net/xml.gp?ip=' . $ip );
667
+            } else if (self::geoip2_country_dbfile() && ($ip_country_service === 'geoip2' || $is_default)) {
668
+                $wpinv_ip_address_country = self::geoip2_country_code($ip);
669
+            } else if (function_exists('simplexml_load_file') && ($ip_country_service === 'geoplugin' || $is_default)) {
670
+                $load_xml = simplexml_load_file('http://www.geoplugin.net/xml.gp?ip=' . $ip);
671 671
                 
672
-                if ( !empty( $load_xml ) && !empty( $load_xml->geoplugin_countryCode ) ) {
672
+                if (!empty($load_xml) && !empty($load_xml->geoplugin_countryCode)) {
673 673
                     $wpinv_ip_address_country = (string)$load_xml->geoplugin_countryCode;
674 674
                 }
675 675
             }
676 676
         }
677 677
 
678
-        if ( empty( $wpinv_ip_address_country ) ) {
678
+        if (empty($wpinv_ip_address_country)) {
679 679
             $wpinv_ip_address_country = wpinv_get_default_country();
680 680
         }
681 681
 
682 682
         return $wpinv_ip_address_country;
683 683
     }
684 684
     
685
-    public static function sanitize_vat_settings( $input ) {
685
+    public static function sanitize_vat_settings($input) {
686 686
         global $wpinv_options;
687 687
         
688 688
         $valid      = false;
689 689
         $message    = '';
690 690
         
691
-        if ( !empty( $wpinv_options['vat_vies_check'] ) ) {
692
-            if ( empty( $wpinv_options['vat_offline_check'] ) ) {
693
-                $valid = self::offline_check( $input['vat_number'] );
691
+        if (!empty($wpinv_options['vat_vies_check'])) {
692
+            if (empty($wpinv_options['vat_offline_check'])) {
693
+                $valid = self::offline_check($input['vat_number']);
694 694
             } else {
695 695
                 $valid = true;
696 696
             }
697 697
             
698
-            $message = $valid ? '' : __( 'VAT number not validated', 'invoicing' );
698
+            $message = $valid ? '' : __('VAT number not validated', 'invoicing');
699 699
         } else {
700
-            $result = self::check_vat( $input['vat_number'] );
700
+            $result = self::check_vat($input['vat_number']);
701 701
             
702
-            if ( empty( $result['valid'] ) ) {
702
+            if (empty($result['valid'])) {
703 703
                 $valid      = false;
704 704
                 $message    = $result['message'];
705 705
             } else {
706
-                $valid      = ( isset( $result['company'] ) && ( $result['company'] == '---' || ( strcasecmp( trim( $result['company'] ), trim( $input['vat_company_name'] ) ) == 0 ) ) ) || !empty( $wpinv_options['vat_disable_company_name_check'] );
707
-                $message    = $valid ? '' : __( 'The company name associated with the VAT number provided is not the same as the company name provided.', 'invoicing' );
706
+                $valid      = (isset($result['company']) && ($result['company'] == '---' || (strcasecmp(trim($result['company']), trim($input['vat_company_name'])) == 0))) || !empty($wpinv_options['vat_disable_company_name_check']);
707
+                $message    = $valid ? '' : __('The company name associated with the VAT number provided is not the same as the company name provided.', 'invoicing');
708 708
             }
709 709
         }
710 710
 
711
-        if ( $message && self::is_vat_validated() != $valid ) {
712
-            add_settings_error( 'wpinv-notices', '', $message, ( $valid ? 'updated' : 'error' ) );
711
+        if ($message && self::is_vat_validated() != $valid) {
712
+            add_settings_error('wpinv-notices', '', $message, ($valid ? 'updated' : 'error'));
713 713
         }
714 714
 
715 715
         $input['vat_valid'] = $valid;
716 716
         return $input;
717 717
     }
718 718
     
719
-    public static function sanitize_vat_rates( $input ) {
720
-        if( !current_user_can( 'manage_options' ) ) {
721
-            add_settings_error( 'wpinv-notices', '', __( 'Your account does not have permission to add rate classes.', 'invoicing' ), 'error' );
719
+    public static function sanitize_vat_rates($input) {
720
+        if (!current_user_can('manage_options')) {
721
+            add_settings_error('wpinv-notices', '', __('Your account does not have permission to add rate classes.', 'invoicing'), 'error');
722 722
             return $input;
723 723
         }
724 724
         
725 725
         $vat_classes = self::get_rate_classes();
726
-        $vat_class = !empty( $_REQUEST['wpi_vat_class'] ) && isset( $vat_classes[$_REQUEST['wpi_vat_class']] )? sanitize_text_field( $_REQUEST['wpi_vat_class'] ) : '';
726
+        $vat_class = !empty($_REQUEST['wpi_vat_class']) && isset($vat_classes[$_REQUEST['wpi_vat_class']]) ? sanitize_text_field($_REQUEST['wpi_vat_class']) : '';
727 727
         
728
-        if ( empty( $vat_class ) ) {
729
-            add_settings_error( 'wpinv-notices', '', __( 'No valid VAT rates class contained in the request to save rates.', 'invoicing' ), 'error' );
728
+        if (empty($vat_class)) {
729
+            add_settings_error('wpinv-notices', '', __('No valid VAT rates class contained in the request to save rates.', 'invoicing'), 'error');
730 730
             
731 731
             return $input;
732 732
         }
733 733
 
734
-        $new_rates = ! empty( $_POST['vat_rates'] ) ? array_values( $_POST['vat_rates'] ) : array();
734
+        $new_rates = !empty($_POST['vat_rates']) ? array_values($_POST['vat_rates']) : array();
735 735
 
736
-        if ( $vat_class === '_standard' ) {
736
+        if ($vat_class === '_standard') {
737 737
             // Save the active rates in the invoice settings
738
-            update_option( 'wpinv_tax_rates', $new_rates );
738
+            update_option('wpinv_tax_rates', $new_rates);
739 739
         } else {
740 740
             // Get the existing set of rates
741 741
             $rates = self::get_non_standard_rates();
742 742
             $rates[$vat_class] = $new_rates;
743 743
 
744
-            update_option( 'wpinv_vat_rates', $rates );
744
+            update_option('wpinv_vat_rates', $rates);
745 745
         }
746 746
         
747 747
         return $input;
@@ -751,71 +751,71 @@  discard block
 block discarded – undo
751 751
         $response = array();
752 752
         $response['success'] = false;
753 753
         
754
-        if ( !current_user_can( 'manage_options' ) ) {
755
-            $response['error'] = __( 'Invalid access!', 'invoicing' );
756
-            wp_send_json( $response );
754
+        if (!current_user_can('manage_options')) {
755
+            $response['error'] = __('Invalid access!', 'invoicing');
756
+            wp_send_json($response);
757 757
         }
758 758
         
759
-        $vat_class_name = !empty( $_POST['name'] ) ? sanitize_text_field( $_POST['name'] ) : false;
760
-        $vat_class_desc = !empty( $_POST['desc'] ) ? sanitize_text_field( $_POST['desc'] ) : false;
759
+        $vat_class_name = !empty($_POST['name']) ? sanitize_text_field($_POST['name']) : false;
760
+        $vat_class_desc = !empty($_POST['desc']) ? sanitize_text_field($_POST['desc']) : false;
761 761
         
762
-        if ( empty( $vat_class_name ) ) {
763
-            $response['error'] = __( 'Select the VAT rate name', 'invoicing' );
764
-            wp_send_json( $response );
762
+        if (empty($vat_class_name)) {
763
+            $response['error'] = __('Select the VAT rate name', 'invoicing');
764
+            wp_send_json($response);
765 765
         }
766 766
         
767 767
         $vat_classes = (array)self::get_rate_classes();
768 768
 
769
-        if ( !empty( $vat_classes ) && in_array( strtolower( $vat_class_name ), array_map( 'strtolower', array_values( $vat_classes ) ) ) ) {
770
-            $response['error'] = wp_sprintf( __( 'A VAT Rate name "%s" already exists', 'invoicing' ), $vat_class_name );
771
-            wp_send_json( $response );
769
+        if (!empty($vat_classes) && in_array(strtolower($vat_class_name), array_map('strtolower', array_values($vat_classes)))) {
770
+            $response['error'] = wp_sprintf(__('A VAT Rate name "%s" already exists', 'invoicing'), $vat_class_name);
771
+            wp_send_json($response);
772 772
         }
773 773
         
774
-        $rate_class_key = normalize_whitespace( 'wpi-' . $vat_class_name );
775
-        $rate_class_key = sanitize_key( str_replace( " ", "-", $rate_class_key ) );
774
+        $rate_class_key = normalize_whitespace('wpi-' . $vat_class_name);
775
+        $rate_class_key = sanitize_key(str_replace(" ", "-", $rate_class_key));
776 776
         
777
-        $vat_classes = (array)self::get_rate_classes( true );
778
-        $vat_classes[$rate_class_key] = array( 'name' => $vat_class_name, 'desc' => $vat_class_desc );
777
+        $vat_classes = (array)self::get_rate_classes(true);
778
+        $vat_classes[$rate_class_key] = array('name' => $vat_class_name, 'desc' => $vat_class_desc);
779 779
         
780
-        update_option( '_wpinv_vat_rate_classes', $vat_classes );
780
+        update_option('_wpinv_vat_rate_classes', $vat_classes);
781 781
         
782 782
         $response['success'] = true;
783
-        $response['redirect'] = admin_url( 'admin.php?page=wpinv-settings&tab=taxes&section=vat_rates&wpi_sub=' . $rate_class_key );
783
+        $response['redirect'] = admin_url('admin.php?page=wpinv-settings&tab=taxes&section=vat_rates&wpi_sub=' . $rate_class_key);
784 784
         
785
-        wp_send_json( $response );
785
+        wp_send_json($response);
786 786
     }
787 787
     
788 788
     public static function delete_class() {
789 789
         $response = array();
790 790
         $response['success'] = false;
791 791
         
792
-        if ( !current_user_can( 'manage_options' ) || !isset( $_POST['class'] ) ) {
793
-            $response['error'] = __( 'Invalid access!', 'invoicing' );
794
-            wp_send_json( $response );
792
+        if (!current_user_can('manage_options') || !isset($_POST['class'])) {
793
+            $response['error'] = __('Invalid access!', 'invoicing');
794
+            wp_send_json($response);
795 795
         }
796 796
         
797
-        $vat_class = isset( $_POST['class'] ) && $_POST['class'] !== '' ? sanitize_text_field( $_POST['class'] ) : false;
797
+        $vat_class = isset($_POST['class']) && $_POST['class'] !== '' ? sanitize_text_field($_POST['class']) : false;
798 798
         $vat_classes = (array)self::get_rate_classes();
799 799
 
800
-        if ( !isset( $vat_classes[$vat_class] ) ) {
801
-            $response['error'] = __( 'Requested class does not exists', 'invoicing' );
802
-            wp_send_json( $response );
800
+        if (!isset($vat_classes[$vat_class])) {
801
+            $response['error'] = __('Requested class does not exists', 'invoicing');
802
+            wp_send_json($response);
803 803
         }
804 804
         
805
-        if ( $vat_class == '_new' || $vat_class == '_standard' ) {
806
-            $response['error'] = __( 'You can not delete standard rates class', 'invoicing' );
807
-            wp_send_json( $response );
805
+        if ($vat_class == '_new' || $vat_class == '_standard') {
806
+            $response['error'] = __('You can not delete standard rates class', 'invoicing');
807
+            wp_send_json($response);
808 808
         }
809 809
             
810
-        $vat_classes = (array)self::get_rate_classes( true );
811
-        unset( $vat_classes[$vat_class] );
810
+        $vat_classes = (array)self::get_rate_classes(true);
811
+        unset($vat_classes[$vat_class]);
812 812
         
813
-        update_option( '_wpinv_vat_rate_classes', $vat_classes );
813
+        update_option('_wpinv_vat_rate_classes', $vat_classes);
814 814
         
815 815
         $response['success'] = true;
816
-        $response['redirect'] = admin_url( 'admin.php?page=wpinv-settings&tab=taxes&section=vat_rates&wpi_sub=_new' );
816
+        $response['redirect'] = admin_url('admin.php?page=wpinv-settings&tab=taxes&section=vat_rates&wpi_sub=_new');
817 817
         
818
-        wp_send_json( $response );
818
+        wp_send_json($response);
819 819
     }
820 820
     
821 821
     public static function update_eu_rates() {        
@@ -824,72 +824,72 @@  discard block
 block discarded – undo
824 824
         $response['error']      = null;
825 825
         $response['data']       = null;
826 826
         
827
-        if ( !current_user_can( 'manage_options' ) ) {
828
-            $response['error'] = __( 'Invalid access!', 'invoicing' );
829
-            wp_send_json( $response );
827
+        if (!current_user_can('manage_options')) {
828
+            $response['error'] = __('Invalid access!', 'invoicing');
829
+            wp_send_json($response);
830 830
         }
831 831
         
832
-        $group      = !empty( $_POST['group'] ) ? sanitize_text_field( $_POST['group'] ) : '';
833
-        $euvatrates = self::request_euvatrates( $group );
832
+        $group      = !empty($_POST['group']) ? sanitize_text_field($_POST['group']) : '';
833
+        $euvatrates = self::request_euvatrates($group);
834 834
         
835
-        if ( !empty( $euvatrates ) ) {
836
-            if ( !empty( $euvatrates['success'] ) && !empty( $euvatrates['rates'] ) ) {
835
+        if (!empty($euvatrates)) {
836
+            if (!empty($euvatrates['success']) && !empty($euvatrates['rates'])) {
837 837
                 $response['success']        = true;
838 838
                 $response['data']['rates']  = $euvatrates['rates'];
839
-            } else if ( !empty( $euvatrates['error'] ) ) {
839
+            } else if (!empty($euvatrates['error'])) {
840 840
                 $response['error']          = $euvatrates['error'];
841 841
             }
842 842
         }
843 843
             
844
-        wp_send_json( $response );
844
+        wp_send_json($response);
845 845
     }
846 846
     
847 847
     public static function hide_vat_fields() {
848
-        $hide = wpinv_get_option( 'vat_disable_fields' );
848
+        $hide = wpinv_get_option('vat_disable_fields');
849 849
         
850
-        return apply_filters( 'wpinv_hide_vat_fields', $hide );
850
+        return apply_filters('wpinv_hide_vat_fields', $hide);
851 851
     }
852 852
     
853 853
     public static function same_country_rule() {
854
-        $same_country_rule = wpinv_get_option( 'vat_same_country_rule' );
854
+        $same_country_rule = wpinv_get_option('vat_same_country_rule');
855 855
         
856
-        return apply_filters( 'wpinv_vat_same_country_rule', $same_country_rule );
856
+        return apply_filters('wpinv_vat_same_country_rule', $same_country_rule);
857 857
     }
858 858
     
859 859
     public static function get_vat_name() {
860
-        $vat_name   = wpinv_get_option( 'vat_name' );
861
-        $vat_name   = !empty( $vat_name ) ? $vat_name : 'VAT';
860
+        $vat_name   = wpinv_get_option('vat_name');
861
+        $vat_name   = !empty($vat_name) ? $vat_name : 'VAT';
862 862
         
863
-        return apply_filters( 'wpinv_get_owner_vat_name', $vat_name );
863
+        return apply_filters('wpinv_get_owner_vat_name', $vat_name);
864 864
     }
865 865
     
866 866
     public static function get_company_name() {
867
-        $company_name = wpinv_get_option( 'vat_company_name' );
867
+        $company_name = wpinv_get_option('vat_company_name');
868 868
         
869
-        return apply_filters( 'wpinv_get_owner_company_name', $company_name );
869
+        return apply_filters('wpinv_get_owner_company_name', $company_name);
870 870
     }
871 871
     
872 872
     public static function get_vat_number() {
873
-        $vat_number = wpinv_get_option( 'vat_number' );
873
+        $vat_number = wpinv_get_option('vat_number');
874 874
         
875
-        return apply_filters( 'wpinv_get_owner_vat_number', $vat_number );
875
+        return apply_filters('wpinv_get_owner_vat_number', $vat_number);
876 876
     }
877 877
     
878 878
     public static function is_vat_validated() {
879
-        $validated = self::get_vat_number() && wpinv_get_option( 'vat_valid' );
879
+        $validated = self::get_vat_number() && wpinv_get_option('vat_valid');
880 880
         
881
-        return apply_filters( 'wpinv_is_owner_vat_validated', $validated );
881
+        return apply_filters('wpinv_is_owner_vat_validated', $validated);
882 882
     }
883 883
     
884
-    public static function sanitize_vat( $vat_number, $country_code = '' ) {        
885
-        $vat_number = str_replace( array(' ', '.', '-', '_', ',' ), '', strtoupper( trim( $vat_number ) ) );
884
+    public static function sanitize_vat($vat_number, $country_code = '') {        
885
+        $vat_number = str_replace(array(' ', '.', '-', '_', ','), '', strtoupper(trim($vat_number)));
886 886
         
887
-        if ( empty( $country_code ) ) {
888
-            $country_code = substr( $vat_number, 0, 2 );
887
+        if (empty($country_code)) {
888
+            $country_code = substr($vat_number, 0, 2);
889 889
         }
890 890
         
891
-        if ( strpos( $vat_number , $country_code ) === 0 ) {
892
-            $vat = str_replace( $country_code, '', $vat_number );
891
+        if (strpos($vat_number, $country_code) === 0) {
892
+            $vat = str_replace($country_code, '', $vat_number);
893 893
         } else {
894 894
             $vat = $country_code . $vat_number;
895 895
         }
@@ -902,140 +902,140 @@  discard block
 block discarded – undo
902 902
         return $return;
903 903
     }
904 904
     
905
-    public static function offline_check( $vat_number, $country_code = '', $formatted = false ) {
906
-        $vat            = self::sanitize_vat( $vat_number, $country_code );
905
+    public static function offline_check($vat_number, $country_code = '', $formatted = false) {
906
+        $vat            = self::sanitize_vat($vat_number, $country_code);
907 907
         $vat_number     = $vat['vat_number'];
908 908
         $country_code   = $vat['iso'];
909 909
         $regex          = array();
910 910
         
911
-        switch ( $country_code ) {
911
+        switch ($country_code) {
912 912
             case 'AT':
913
-                $regex[] = '/^(AT)U(\d{8})$/';                           // Austria
913
+                $regex[] = '/^(AT)U(\d{8})$/'; // Austria
914 914
                 break;
915 915
             case 'BE':
916
-                $regex[] = '/^(BE)(0?\d{9})$/';                          // Belgium
916
+                $regex[] = '/^(BE)(0?\d{9})$/'; // Belgium
917 917
                 break;
918 918
             case 'BG':
919
-                $regex[] = '/^(BG)(\d{9,10})$/';                         // Bulgaria
919
+                $regex[] = '/^(BG)(\d{9,10})$/'; // Bulgaria
920 920
                 break;
921 921
             case 'CH':
922 922
             case 'CHE':
923
-                $regex[] = '/^(CHE)(\d{9})MWST$/';                       // Switzerland (Not EU)
923
+                $regex[] = '/^(CHE)(\d{9})MWST$/'; // Switzerland (Not EU)
924 924
                 break;
925 925
             case 'CY':
926
-                $regex[] = '/^(CY)([0-5|9]\d{7}[A-Z])$/';                // Cyprus
926
+                $regex[] = '/^(CY)([0-5|9]\d{7}[A-Z])$/'; // Cyprus
927 927
                 break;
928 928
             case 'CZ':
929
-                $regex[] = '/^(CZ)(\d{8,13})$/';                         // Czech Republic
929
+                $regex[] = '/^(CZ)(\d{8,13})$/'; // Czech Republic
930 930
                 break;
931 931
             case 'DE':
932
-                $regex[] = '/^(DE)([1-9]\d{8})$/';                       // Germany
932
+                $regex[] = '/^(DE)([1-9]\d{8})$/'; // Germany
933 933
                 break;
934 934
             case 'DK':
935
-                $regex[] = '/^(DK)(\d{8})$/';                            // Denmark
935
+                $regex[] = '/^(DK)(\d{8})$/'; // Denmark
936 936
                 break;
937 937
             case 'EE':
938
-                $regex[] = '/^(EE)(10\d{7})$/';                          // Estonia
938
+                $regex[] = '/^(EE)(10\d{7})$/'; // Estonia
939 939
                 break;
940 940
             case 'EL':
941
-                $regex[] = '/^(EL)(\d{9})$/';                            // Greece
941
+                $regex[] = '/^(EL)(\d{9})$/'; // Greece
942 942
                 break;
943 943
             case 'ES':
944
-                $regex[] = '/^(ES)([A-Z]\d{8})$/';                       // Spain (National juridical entities)
945
-                $regex[] = '/^(ES)([A-H|N-S|W]\d{7}[A-J])$/';            // Spain (Other juridical entities)
946
-                $regex[] = '/^(ES)([0-9|Y|Z]\d{7}[A-Z])$/';              // Spain (Personal entities type 1)
947
-                $regex[] = '/^(ES)([K|L|M|X]\d{7}[A-Z])$/';              // Spain (Personal entities type 2)
944
+                $regex[] = '/^(ES)([A-Z]\d{8})$/'; // Spain (National juridical entities)
945
+                $regex[] = '/^(ES)([A-H|N-S|W]\d{7}[A-J])$/'; // Spain (Other juridical entities)
946
+                $regex[] = '/^(ES)([0-9|Y|Z]\d{7}[A-Z])$/'; // Spain (Personal entities type 1)
947
+                $regex[] = '/^(ES)([K|L|M|X]\d{7}[A-Z])$/'; // Spain (Personal entities type 2)
948 948
                 break;
949 949
             case 'EU':
950
-                $regex[] = '/^(EU)(\d{9})$/';                            // EU-type
950
+                $regex[] = '/^(EU)(\d{9})$/'; // EU-type
951 951
                 break;
952 952
             case 'FI':
953
-                $regex[] = '/^(FI)(\d{8})$/';                            // Finland
953
+                $regex[] = '/^(FI)(\d{8})$/'; // Finland
954 954
                 break;
955 955
             case 'FR':
956
-                $regex[] = '/^(FR)(\d{11})$/';                           // France (1)
957
-                $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)](\d{10})$/';        // France (2)
958
-                $regex[] = '/^(FR)\d[(A-H)|(J-N)|(P-Z)](\d{9})$/';       // France (3)
959
-                $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)]{2}(\d{9})$/';      // France (4)
956
+                $regex[] = '/^(FR)(\d{11})$/'; // France (1)
957
+                $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)](\d{10})$/'; // France (2)
958
+                $regex[] = '/^(FR)\d[(A-H)|(J-N)|(P-Z)](\d{9})$/'; // France (3)
959
+                $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)]{2}(\d{9})$/'; // France (4)
960 960
                 break;
961 961
             case 'GB':
962
-                $regex[] = '/^(GB)?(\d{9})$/';                           // UK (Standard)
963
-                $regex[] = '/^(GB)?(\d{12})$/';                          // UK (Branches)
964
-                $regex[] = '/^(GB)?(GD\d{3})$/';                         // UK (Government)
965
-                $regex[] = '/^(GB)?(HA\d{3})$/';                         // UK (Health authority)
962
+                $regex[] = '/^(GB)?(\d{9})$/'; // UK (Standard)
963
+                $regex[] = '/^(GB)?(\d{12})$/'; // UK (Branches)
964
+                $regex[] = '/^(GB)?(GD\d{3})$/'; // UK (Government)
965
+                $regex[] = '/^(GB)?(HA\d{3})$/'; // UK (Health authority)
966 966
                 break;
967 967
             case 'GR':
968
-                $regex[] = '/^(GR)(\d{8,9})$/';                          // Greece
968
+                $regex[] = '/^(GR)(\d{8,9})$/'; // Greece
969 969
                 break;
970 970
             case 'HR':
971
-                $regex[] = '/^(HR)(\d{11})$/';                           // Croatia
971
+                $regex[] = '/^(HR)(\d{11})$/'; // Croatia
972 972
                 break;
973 973
             case 'HU':
974
-                $regex[] = '/^(HU)(\d{8})$/';                            // Hungary
974
+                $regex[] = '/^(HU)(\d{8})$/'; // Hungary
975 975
                 break;
976 976
             case 'IE':
977
-                $regex[] = '/^(IE)(\d{7}[A-W])$/';                       // Ireland (1)
978
-                $regex[] = '/^(IE)([7-9][A-Z\*\+)]\d{5}[A-W])$/';        // Ireland (2)
979
-                $regex[] = '/^(IE)(\d{7}[A-Z][AH])$/';                   // Ireland (3) (new format from 1 Jan 2013)
977
+                $regex[] = '/^(IE)(\d{7}[A-W])$/'; // Ireland (1)
978
+                $regex[] = '/^(IE)([7-9][A-Z\*\+)]\d{5}[A-W])$/'; // Ireland (2)
979
+                $regex[] = '/^(IE)(\d{7}[A-Z][AH])$/'; // Ireland (3) (new format from 1 Jan 2013)
980 980
                 break;
981 981
             case 'IT':
982
-                $regex[] = '/^(IT)(\d{11})$/';                           // Italy
982
+                $regex[] = '/^(IT)(\d{11})$/'; // Italy
983 983
                 break;
984 984
             case 'LV':
985
-                $regex[] = '/^(LV)(\d{11})$/';                           // Latvia
985
+                $regex[] = '/^(LV)(\d{11})$/'; // Latvia
986 986
                 break;
987 987
             case 'LT':
988
-                $regex[] = '/^(LT)(\d{9}|\d{12})$/';                     // Lithuania
988
+                $regex[] = '/^(LT)(\d{9}|\d{12})$/'; // Lithuania
989 989
                 break;
990 990
             case 'LU':
991
-                $regex[] = '/^(LU)(\d{8})$/';                            // Luxembourg
991
+                $regex[] = '/^(LU)(\d{8})$/'; // Luxembourg
992 992
                 break;
993 993
             case 'MT':
994
-                $regex[] = '/^(MT)([1-9]\d{7})$/';                       // Malta
994
+                $regex[] = '/^(MT)([1-9]\d{7})$/'; // Malta
995 995
                 break;
996 996
             case 'NL':
997
-                $regex[] = '/^(NL)(\d{9})B\d{2}$/';                      // Netherlands
997
+                $regex[] = '/^(NL)(\d{9})B\d{2}$/'; // Netherlands
998 998
                 break;
999 999
             case 'NO':
1000
-                $regex[] = '/^(NO)(\d{9})$/';                            // Norway (Not EU)
1000
+                $regex[] = '/^(NO)(\d{9})$/'; // Norway (Not EU)
1001 1001
                 break;
1002 1002
             case 'PL':
1003
-                $regex[] = '/^(PL)(\d{10})$/';                           // Poland
1003
+                $regex[] = '/^(PL)(\d{10})$/'; // Poland
1004 1004
                 break;
1005 1005
             case 'PT':
1006
-                $regex[] = '/^(PT)(\d{9})$/';                            // Portugal
1006
+                $regex[] = '/^(PT)(\d{9})$/'; // Portugal
1007 1007
                 break;
1008 1008
             case 'RO':
1009
-                $regex[] = '/^(RO)([1-9]\d{1,9})$/';                     // Romania
1009
+                $regex[] = '/^(RO)([1-9]\d{1,9})$/'; // Romania
1010 1010
                 break;
1011 1011
             case 'RS':
1012
-                $regex[] = '/^(RS)(\d{9})$/';                            // Serbia (Not EU)
1012
+                $regex[] = '/^(RS)(\d{9})$/'; // Serbia (Not EU)
1013 1013
                 break;
1014 1014
             case 'SI':
1015
-                $regex[] = '/^(SI)([1-9]\d{7})$/';                       // Slovenia
1015
+                $regex[] = '/^(SI)([1-9]\d{7})$/'; // Slovenia
1016 1016
                 break;
1017 1017
             case 'SK':
1018
-                $regex[] = '/^(SK)([1-9]\d[(2-4)|(6-9)]\d{7})$/';        // Slovakia Republic
1018
+                $regex[] = '/^(SK)([1-9]\d[(2-4)|(6-9)]\d{7})$/'; // Slovakia Republic
1019 1019
                 break;
1020 1020
             case 'SE':
1021
-                $regex[] = '/^(SE)(\d{10}01)$/';                         // Sweden
1021
+                $regex[] = '/^(SE)(\d{10}01)$/'; // Sweden
1022 1022
                 break;
1023 1023
             default:
1024 1024
                 $regex = array();
1025 1025
             break;
1026 1026
         }
1027 1027
         
1028
-        if ( empty( $regex ) ) {
1028
+        if (empty($regex)) {
1029 1029
             return false;
1030 1030
         }
1031 1031
         
1032
-        foreach ( $regex as $pattern ) {
1032
+        foreach ($regex as $pattern) {
1033 1033
             $matches = null;
1034
-            preg_match_all( $pattern, $vat_number, $matches );
1034
+            preg_match_all($pattern, $vat_number, $matches);
1035 1035
             
1036
-            if ( !empty( $matches[1][0] ) && !empty( $matches[2][0] ) ) {
1037
-                if ( $formatted ) {
1038
-                    return array( 'code' => $matches[1][0], 'number' => $matches[2][0] );
1036
+            if (!empty($matches[1][0]) && !empty($matches[2][0])) {
1037
+                if ($formatted) {
1038
+                    return array('code' => $matches[1][0], 'number' => $matches[2][0]);
1039 1039
                 } else {
1040 1040
                     return true;
1041 1041
                 }
@@ -1045,75 +1045,75 @@  discard block
 block discarded – undo
1045 1045
         return false;
1046 1046
     }
1047 1047
     
1048
-    public static function vies_check( $vat_number, $country_code = '', $result = false ) {
1049
-        $vat            = self::sanitize_vat( $vat_number, $country_code );
1048
+    public static function vies_check($vat_number, $country_code = '', $result = false) {
1049
+        $vat            = self::sanitize_vat($vat_number, $country_code);
1050 1050
         $vat_number     = $vat['vat'];
1051 1051
         $iso            = $vat['iso'];
1052 1052
         
1053
-        $url = 'http://ec.europa.eu/taxation_customs/vies/viesquer.do?ms=' . urlencode( $iso ) . '&iso=' . urlencode( $iso ) . '&vat=' . urlencode( $vat_number );
1053
+        $url = 'http://ec.europa.eu/taxation_customs/vies/viesquer.do?ms=' . urlencode($iso) . '&iso=' . urlencode($iso) . '&vat=' . urlencode($vat_number);
1054 1054
         
1055
-        if ( ini_get( 'allow_url_fopen' ) ) {
1056
-            $response = file_get_contents( $url );
1057
-        } else if ( function_exists( 'curl_init' ) ) {
1055
+        if (ini_get('allow_url_fopen')) {
1056
+            $response = file_get_contents($url);
1057
+        } else if (function_exists('curl_init')) {
1058 1058
             $ch = curl_init();
1059 1059
             
1060
-            curl_setopt( $ch, CURLOPT_URL, $url );
1061
-            curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 30 );
1062
-            curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
1063
-            curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0 );
1064
-            curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 );
1060
+            curl_setopt($ch, CURLOPT_URL, $url);
1061
+            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
1062
+            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
1063
+            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
1064
+            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
1065 1065
             
1066
-            $response = curl_exec( $ch );
1066
+            $response = curl_exec($ch);
1067 1067
             
1068
-            if ( curl_errno( $ch ) ) {
1069
-                wpinv_error_log( curl_error( $ch ), 'VIES CHECK ERROR' );
1068
+            if (curl_errno($ch)) {
1069
+                wpinv_error_log(curl_error($ch), 'VIES CHECK ERROR');
1070 1070
                 $response = '';
1071 1071
             }
1072 1072
             
1073
-            curl_close( $ch );
1073
+            curl_close($ch);
1074 1074
         } else {
1075
-            wpinv_error_log( 'To use VIES CHECK you must have allow_url_fopen is ON or cURL installed & active on your server.', 'VIES CHECK ERROR' );
1075
+            wpinv_error_log('To use VIES CHECK you must have allow_url_fopen is ON or cURL installed & active on your server.', 'VIES CHECK ERROR');
1076 1076
         }
1077 1077
         
1078
-        if ( empty( $response ) ) {
1078
+        if (empty($response)) {
1079 1079
             return $result;
1080 1080
         }
1081 1081
 
1082
-        if ( preg_match( '/invalid VAT number/i', $response ) ) {
1082
+        if (preg_match('/invalid VAT number/i', $response)) {
1083 1083
             return false;
1084
-        } else if ( preg_match( '/valid VAT number/i', $response, $matches ) ) {
1085
-            $content = explode( "valid VAT number", htmlentities( $response ) );
1084
+        } else if (preg_match('/valid VAT number/i', $response, $matches)) {
1085
+            $content = explode("valid VAT number", htmlentities($response));
1086 1086
             
1087
-            if ( !empty( $content[1] ) ) {
1088
-                preg_match_all( '/<tr>(.*?)<td.*?>(.*?)<\/td>(.*?)<\/tr>/si', html_entity_decode( $content[1] ), $matches );
1087
+            if (!empty($content[1])) {
1088
+                preg_match_all('/<tr>(.*?)<td.*?>(.*?)<\/td>(.*?)<\/tr>/si', html_entity_decode($content[1]), $matches);
1089 1089
                 
1090
-                if ( !empty( $matches[2] ) && $matches[3] ) {
1090
+                if (!empty($matches[2]) && $matches[3]) {
1091 1091
                     $return = array();
1092 1092
                     
1093
-                    foreach ( $matches[2] as $key => $label ) {
1094
-                        $label = trim( $label );
1093
+                    foreach ($matches[2] as $key => $label) {
1094
+                        $label = trim($label);
1095 1095
                         
1096
-                        switch ( strtolower( $label ) ) {
1096
+                        switch (strtolower($label)) {
1097 1097
                             case 'member state':
1098
-                                $return['state'] = trim( strip_tags( $matches[3][$key] ) );
1098
+                                $return['state'] = trim(strip_tags($matches[3][$key]));
1099 1099
                             break;
1100 1100
                             case 'vat number':
1101
-                                $return['number'] = trim( strip_tags( $matches[3][$key] ) );
1101
+                                $return['number'] = trim(strip_tags($matches[3][$key]));
1102 1102
                             break;
1103 1103
                             case 'name':
1104
-                                $return['company'] = trim( strip_tags( $matches[3][$key] ) );
1104
+                                $return['company'] = trim(strip_tags($matches[3][$key]));
1105 1105
                             break;
1106 1106
                             case 'address':
1107
-                                $address           = str_replace( array( "<br><br>", "<br /><br />", "<br/><br/>" ), "<br>", html_entity_decode( trim( $matches[3][$key] ) ) );
1108
-                                $return['address'] = trim( strip_tags( $address, '<br>' ) );
1107
+                                $address           = str_replace(array("<br><br>", "<br /><br />", "<br/><br/>"), "<br>", html_entity_decode(trim($matches[3][$key])));
1108
+                                $return['address'] = trim(strip_tags($address, '<br>'));
1109 1109
                             break;
1110 1110
                             case 'consultation number':
1111
-                                $return['consultation'] = trim( strip_tags( $matches[3][$key] ) );
1111
+                                $return['consultation'] = trim(strip_tags($matches[3][$key]));
1112 1112
                             break;
1113 1113
                         }
1114 1114
                     }
1115 1115
                     
1116
-                    if ( !empty( $return ) ) {
1116
+                    if (!empty($return)) {
1117 1117
                         return $return;
1118 1118
                     }
1119 1119
                 }
@@ -1125,55 +1125,55 @@  discard block
 block discarded – undo
1125 1125
         }
1126 1126
     }
1127 1127
     
1128
-    public static function check_vat( $vat_number, $country_code = '' ) {        
1128
+    public static function check_vat($vat_number, $country_code = '') {        
1129 1129
         $vat_name           = self::get_vat_name();
1130 1130
         
1131 1131
         $return             = array();
1132 1132
         $return['valid']    = false;
1133
-        $return['message']  = wp_sprintf( __( '%s number not validated', 'invoicing' ), $vat_name );
1133
+        $return['message']  = wp_sprintf(__('%s number not validated', 'invoicing'), $vat_name);
1134 1134
                 
1135
-        if ( !wpinv_get_option( 'vat_offline_check' ) && !self::offline_check( $vat_number, $country_code ) ) {
1135
+        if (!wpinv_get_option('vat_offline_check') && !self::offline_check($vat_number, $country_code)) {
1136 1136
             return $return;
1137 1137
         }
1138 1138
             
1139
-        $response = self::vies_check( $vat_number, $country_code );
1139
+        $response = self::vies_check($vat_number, $country_code);
1140 1140
         
1141
-        if ( $response ) {
1142
-            $return['valid']    = true;
1141
+        if ($response) {
1142
+            $return['valid'] = true;
1143 1143
             
1144
-            if ( is_array( $response ) ) {
1145
-                $return['company'] = isset( $response['company'] ) ? $response['company'] : '';
1146
-                $return['address'] = isset( $response['address'] ) ? $response['address'] : '';
1144
+            if (is_array($response)) {
1145
+                $return['company'] = isset($response['company']) ? $response['company'] : '';
1146
+                $return['address'] = isset($response['address']) ? $response['address'] : '';
1147 1147
                 $return['message'] = $return['company'] . '<br/>' . $return['address'];
1148 1148
             }
1149 1149
         } else {
1150 1150
             $return['valid']    = false;
1151
-            $return['message']  = wp_sprintf( __( 'Fail to validate the %s number: EU Commission VAT server (VIES) check fails.', 'invoicing' ), $vat_name );
1151
+            $return['message']  = wp_sprintf(__('Fail to validate the %s number: EU Commission VAT server (VIES) check fails.', 'invoicing'), $vat_name);
1152 1152
         }
1153 1153
         
1154 1154
         return $return;
1155 1155
     }
1156 1156
     
1157
-    public static function request_euvatrates( $group ) {
1157
+    public static function request_euvatrates($group) {
1158 1158
         $response               = array();
1159 1159
         $response['success']    = false;
1160 1160
         $response['error']      = null;
1161 1161
         $response['eurates']    = null;
1162 1162
         
1163 1163
         $euvatrates_url = 'https://euvatrates.com/rates.json';
1164
-        $euvatrates_url = apply_filters( 'wpinv_euvatrates_url', $euvatrates_url );
1165
-        $api_response   = wp_remote_get( $euvatrates_url );
1164
+        $euvatrates_url = apply_filters('wpinv_euvatrates_url', $euvatrates_url);
1165
+        $api_response   = wp_remote_get($euvatrates_url);
1166 1166
     
1167 1167
         try {
1168
-            if ( is_wp_error( $api_response ) ) {
1169
-                $response['error']      = __( $api_response->get_error_message(), 'invoicing' );
1168
+            if (is_wp_error($api_response)) {
1169
+                $response['error'] = __($api_response->get_error_message(), 'invoicing');
1170 1170
             } else {
1171
-                $body = json_decode( $api_response['body'] );
1171
+                $body = json_decode($api_response['body']);
1172 1172
                 
1173
-                if ( isset( $body->rates ) ) {
1173
+                if (isset($body->rates)) {
1174 1174
                     $rates = array();
1175 1175
                     
1176
-                    foreach ( $body->rates as $country_code => $rate ) {
1176
+                    foreach ($body->rates as $country_code => $rate) {
1177 1177
                         $vat_rate = array();
1178 1178
                         $vat_rate['country']        = $rate->country;
1179 1179
                         $vat_rate['standard']       = (float)$rate->standard_rate;
@@ -1181,7 +1181,7 @@  discard block
 block discarded – undo
1181 1181
                         $vat_rate['superreduced']   = (float)$rate->super_reduced_rate;
1182 1182
                         $vat_rate['parking']        = (float)$rate->parking_rate;
1183 1183
                         
1184
-                        if ( $group !== '' && in_array( $group, array( 'standard', 'reduced', 'superreduced', 'parking' ) ) ) {
1184
+                        if ($group !== '' && in_array($group, array('standard', 'reduced', 'superreduced', 'parking'))) {
1185 1185
                             $vat_rate_group = array();
1186 1186
                             $vat_rate_group['country'] = $rate->country;
1187 1187
                             $vat_rate_group[$group]    = $vat_rate[$group];
@@ -1193,79 +1193,79 @@  discard block
 block discarded – undo
1193 1193
                     }
1194 1194
                     
1195 1195
                     $response['success']    = true;                                
1196
-                    $response['rates']      = apply_filters( 'wpinv_process_euvatrates', $rates, $api_response, $group );
1196
+                    $response['rates']      = apply_filters('wpinv_process_euvatrates', $rates, $api_response, $group);
1197 1197
                 } else {
1198
-                    $response['error']      = __( 'No EU rates found!', 'invoicing' );
1198
+                    $response['error']      = __('No EU rates found!', 'invoicing');
1199 1199
                 }
1200 1200
             }
1201
-        } catch ( Exception $e ) {
1202
-            $response['error'] = __( $e->getMessage(), 'invoicing' );
1201
+        } catch (Exception $e) {
1202
+            $response['error'] = __($e->getMessage(), 'invoicing');
1203 1203
         }
1204 1204
         
1205
-        return apply_filters( 'wpinv_response_euvatrates', $response, $group );
1205
+        return apply_filters('wpinv_response_euvatrates', $response, $group);
1206 1206
     }    
1207 1207
     
1208
-    public static function requires_vat( $requires_vat = false, $user_id = 0, $is_digital = null ) {
1208
+    public static function requires_vat($requires_vat = false, $user_id = 0, $is_digital = null) {
1209 1209
         global $wpi_item_id, $wpi_country;
1210 1210
         
1211
-        if ( !empty( $_POST['wpinv_country'] ) ) {
1212
-            $country_code = trim( $_POST['wpinv_country'] );
1213
-        } else if ( !empty( $_POST['country'] ) ) {
1214
-            $country_code = trim( $_POST['country'] );
1215
-        } else if ( !empty( $wpi_country ) ) {
1211
+        if (!empty($_POST['wpinv_country'])) {
1212
+            $country_code = trim($_POST['wpinv_country']);
1213
+        } else if (!empty($_POST['country'])) {
1214
+            $country_code = trim($_POST['country']);
1215
+        } else if (!empty($wpi_country)) {
1216 1216
             $country_code = $wpi_country;
1217 1217
         } else {
1218
-            $country_code = self::get_user_country( '', $user_id );
1218
+            $country_code = self::get_user_country('', $user_id);
1219 1219
         }
1220 1220
         
1221
-        if ( $is_digital === null && $wpi_item_id ) {
1222
-            $is_digital = $wpi_item_id ? self::item_has_digital_rule( $wpi_item_id ) : self::allow_vat_rules();
1221
+        if ($is_digital === null && $wpi_item_id) {
1222
+            $is_digital = $wpi_item_id ? self::item_has_digital_rule($wpi_item_id) : self::allow_vat_rules();
1223 1223
         }
1224 1224
         
1225
-        if ( !empty( $country_code ) ) {
1226
-            $requires_vat = ( self::is_eu_state( $country_code ) && ( self::is_eu_state( self::$default_country ) || $is_digital ) ) || ( self::is_gst_country( $country_code ) && self::is_gst_country( self::$default_country ) );
1225
+        if (!empty($country_code)) {
1226
+            $requires_vat = (self::is_eu_state($country_code) && (self::is_eu_state(self::$default_country) || $is_digital)) || (self::is_gst_country($country_code) && self::is_gst_country(self::$default_country));
1227 1227
         }
1228 1228
         
1229
-        return apply_filters( 'wpinv_requires_vat', $requires_vat, $user_id );
1229
+        return apply_filters('wpinv_requires_vat', $requires_vat, $user_id);
1230 1230
     }
1231 1231
     
1232
-    public static function tax_label( $label = '' ) {
1232
+    public static function tax_label($label = '') {
1233 1233
         global $wpi_requires_vat;
1234 1234
         
1235
-        if ( !( $wpi_requires_vat !== 0 && $wpi_requires_vat ) ) {
1236
-            $wpi_requires_vat = self::requires_vat( 0, false );
1235
+        if (!($wpi_requires_vat !== 0 && $wpi_requires_vat)) {
1236
+            $wpi_requires_vat = self::requires_vat(0, false);
1237 1237
         }
1238 1238
         
1239
-        return $wpi_requires_vat ? __( self::get_vat_name(), 'invoicing' ) : ( $label ? $label : __( 'Tax', 'invoicing' ) );
1239
+        return $wpi_requires_vat ? __(self::get_vat_name(), 'invoicing') : ($label ? $label : __('Tax', 'invoicing'));
1240 1240
     }
1241 1241
     
1242 1242
     public static function standard_rates_label() {
1243
-        return __( 'Standard Rates', 'invoicing' );
1243
+        return __('Standard Rates', 'invoicing');
1244 1244
     }
1245 1245
     
1246
-    public static function get_rate_classes( $with_desc = false ) {        
1247
-        $rate_classes_option = get_option( '_wpinv_vat_rate_classes', true );
1248
-        $classes = maybe_unserialize( $rate_classes_option );
1246
+    public static function get_rate_classes($with_desc = false) {        
1247
+        $rate_classes_option = get_option('_wpinv_vat_rate_classes', true);
1248
+        $classes = maybe_unserialize($rate_classes_option);
1249 1249
         
1250
-        if ( empty( $classes ) || !is_array( $classes ) ) {
1250
+        if (empty($classes) || !is_array($classes)) {
1251 1251
             $classes = array();
1252 1252
         }
1253 1253
 
1254 1254
         $rate_classes = array();
1255
-        if ( !array_key_exists( '_standard', $classes ) ) {
1256
-            if ( $with_desc ) {
1257
-                $rate_classes['_standard'] = array( 'name' => self::standard_rates_label(), 'desc' => __( 'EU member states standard VAT rates', 'invoicing' ) );
1255
+        if (!array_key_exists('_standard', $classes)) {
1256
+            if ($with_desc) {
1257
+                $rate_classes['_standard'] = array('name' => self::standard_rates_label(), 'desc' => __('EU member states standard VAT rates', 'invoicing'));
1258 1258
             } else {
1259 1259
                 $rate_classes['_standard'] = self::standard_rates_label();
1260 1260
             }
1261 1261
         }
1262 1262
         
1263
-        foreach ( $classes as $key => $class ) {
1264
-            $name = !empty( $class['name'] ) ? __( $class['name'], 'invoicing' ) : $key;
1265
-            $desc = !empty( $class['desc'] ) ? __( $class['desc'], 'invoicing' ) : '';
1263
+        foreach ($classes as $key => $class) {
1264
+            $name = !empty($class['name']) ? __($class['name'], 'invoicing') : $key;
1265
+            $desc = !empty($class['desc']) ? __($class['desc'], 'invoicing') : '';
1266 1266
             
1267
-            if ( $with_desc ) {
1268
-                $rate_classes[$key] = array( 'name' => $name, 'desc' => $desc );
1267
+            if ($with_desc) {
1268
+                $rate_classes[$key] = array('name' => $name, 'desc' => $desc);
1269 1269
             } else {
1270 1270
                 $rate_classes[$key] = $name;
1271 1271
             }
@@ -1276,15 +1276,15 @@  discard block
 block discarded – undo
1276 1276
     
1277 1277
     public static function get_all_classes() {        
1278 1278
         $classes            = self::get_rate_classes();
1279
-        $classes['_exempt'] = __( 'Exempt (0%)', 'invoicing' );
1279
+        $classes['_exempt'] = __('Exempt (0%)', 'invoicing');
1280 1280
         
1281
-        return apply_filters( 'wpinv_vat_get_all_classes', $classes );
1281
+        return apply_filters('wpinv_vat_get_all_classes', $classes);
1282 1282
     }
1283 1283
     
1284
-    public static function get_class_desc( $rate_class ) {        
1285
-        $rate_classes = self::get_rate_classes( true );
1284
+    public static function get_class_desc($rate_class) {        
1285
+        $rate_classes = self::get_rate_classes(true);
1286 1286
 
1287
-        if ( !empty( $rate_classes ) && isset( $rate_classes[$rate_class] ) && isset( $rate_classes[$rate_class]['desc'] ) ) {
1287
+        if (!empty($rate_classes) && isset($rate_classes[$rate_class]) && isset($rate_classes[$rate_class]['desc'])) {
1288 1288
             return $rate_classes[$rate_class]['desc'];
1289 1289
         }
1290 1290
         
@@ -1300,106 +1300,106 @@  discard block
 block discarded – undo
1300 1300
             'increased'     => 'Increased'
1301 1301
         );
1302 1302
         
1303
-        return apply_filters( 'wpinv_get_vat_groups', $vat_groups );
1303
+        return apply_filters('wpinv_get_vat_groups', $vat_groups);
1304 1304
     }
1305 1305
 
1306 1306
     public static function get_rules() {
1307 1307
         $vat_rules = array(
1308
-            'digital' => __( 'Digital Product', 'invoicing' ),
1309
-            'physical' => __( 'Physical Product', 'invoicing' )
1308
+            'digital' => __('Digital Product', 'invoicing'),
1309
+            'physical' => __('Physical Product', 'invoicing')
1310 1310
         );
1311
-        return apply_filters( 'wpinv_get_vat_rules', $vat_rules );
1311
+        return apply_filters('wpinv_get_vat_rules', $vat_rules);
1312 1312
     }
1313 1313
 
1314
-    public static function get_vat_rates( $class ) {
1315
-        if ( $class === '_standard' ) {
1314
+    public static function get_vat_rates($class) {
1315
+        if ($class === '_standard') {
1316 1316
             return wpinv_get_tax_rates();
1317 1317
         }
1318 1318
 
1319 1319
         $rates = self::get_non_standard_rates();
1320 1320
 
1321
-        return array_key_exists( $class, $rates ) ? $rates[$class] : array();
1321
+        return array_key_exists($class, $rates) ? $rates[$class] : array();
1322 1322
     }
1323 1323
 
1324 1324
     public static function get_non_standard_rates() {
1325
-        $option = get_option( 'wpinv_vat_rates', array());
1326
-        return is_array( $option ) ? $option : array();
1325
+        $option = get_option('wpinv_vat_rates', array());
1326
+        return is_array($option) ? $option : array();
1327 1327
     }
1328 1328
     
1329 1329
     public static function allow_vat_rules() {
1330
-        return ( wpinv_use_taxes() && wpinv_get_option( 'apply_vat_rules' ) ? true : false );
1330
+        return (wpinv_use_taxes() && wpinv_get_option('apply_vat_rules') ? true : false);
1331 1331
     }
1332 1332
     
1333 1333
     public static function allow_vat_classes() {
1334 1334
         return false; // TODO
1335
-        return ( wpinv_get_option( 'vat_allow_classes' ) ? true : false );
1335
+        return (wpinv_get_option('vat_allow_classes') ? true : false);
1336 1336
     }
1337 1337
     
1338
-    public static function get_item_class( $postID ) {
1339
-        $class = get_post_meta( $postID, '_wpinv_vat_class', true );
1338
+    public static function get_item_class($postID) {
1339
+        $class = get_post_meta($postID, '_wpinv_vat_class', true);
1340 1340
 
1341
-        if ( empty( $class ) ) {
1341
+        if (empty($class)) {
1342 1342
             $class = '_standard';
1343 1343
         }
1344 1344
         
1345
-        return apply_filters( 'wpinv_get_item_vat_class', $class, $postID );
1345
+        return apply_filters('wpinv_get_item_vat_class', $class, $postID);
1346 1346
     }
1347 1347
     
1348
-    public static function item_class_label( $postID ) {        
1348
+    public static function item_class_label($postID) {        
1349 1349
         $vat_classes = self::get_all_classes();
1350 1350
         
1351
-        $class = self::get_item_class( $postID );
1352
-        $class = isset( $vat_classes[$class] ) ? $vat_classes[$class] : __( $class, 'invoicing' );
1351
+        $class = self::get_item_class($postID);
1352
+        $class = isset($vat_classes[$class]) ? $vat_classes[$class] : __($class, 'invoicing');
1353 1353
         
1354
-        return apply_filters( 'wpinv_item_class_label', $class, $postID );
1354
+        return apply_filters('wpinv_item_class_label', $class, $postID);
1355 1355
     }
1356 1356
     
1357
-    public static function get_item_rule( $postID ) {        
1358
-        $rule_type = get_post_meta( $postID, '_wpinv_vat_rule', true );
1357
+    public static function get_item_rule($postID) {        
1358
+        $rule_type = get_post_meta($postID, '_wpinv_vat_rule', true);
1359 1359
         
1360
-        if ( empty( $rule_type ) ) {        
1360
+        if (empty($rule_type)) {        
1361 1361
             $rule_type = self::allow_vat_rules() ? 'digital' : 'physical';
1362 1362
         }
1363 1363
         
1364
-        return apply_filters( 'wpinv_item_get_vat_rule', $rule_type, $postID );
1364
+        return apply_filters('wpinv_item_get_vat_rule', $rule_type, $postID);
1365 1365
     }
1366 1366
     
1367
-    public static function item_rule_label( $postID ) {
1367
+    public static function item_rule_label($postID) {
1368 1368
         $vat_rules  = self::get_rules();
1369
-        $vat_rule   = self::get_item_rule( $postID );
1370
-        $vat_rule   = isset( $vat_rules[$vat_rule] ) ? $vat_rules[$vat_rule] : $vat_rule;
1369
+        $vat_rule   = self::get_item_rule($postID);
1370
+        $vat_rule   = isset($vat_rules[$vat_rule]) ? $vat_rules[$vat_rule] : $vat_rule;
1371 1371
         
1372
-        return apply_filters( 'wpinv_item_rule_label', $vat_rule, $postID );
1372
+        return apply_filters('wpinv_item_rule_label', $vat_rule, $postID);
1373 1373
     }
1374 1374
     
1375
-    public static function item_has_digital_rule( $item_id = 0 ) {        
1376
-        return self::get_item_rule( $item_id ) == 'digital' ? true : false;
1375
+    public static function item_has_digital_rule($item_id = 0) {        
1376
+        return self::get_item_rule($item_id) == 'digital' ? true : false;
1377 1377
     }
1378 1378
     
1379
-    public static function invoice_has_digital_rule( $invoice = 0 ) {        
1380
-        if ( !self::allow_vat_rules() ) {
1379
+    public static function invoice_has_digital_rule($invoice = 0) {        
1380
+        if (!self::allow_vat_rules()) {
1381 1381
             return false;
1382 1382
         }
1383 1383
         
1384
-        if ( empty( $invoice ) ) {
1384
+        if (empty($invoice)) {
1385 1385
             return true;
1386 1386
         }
1387 1387
         
1388
-        if ( is_int( $invoice ) ) {
1389
-            $invoice = new WPInv_Invoice( $invoice );
1388
+        if (is_int($invoice)) {
1389
+            $invoice = new WPInv_Invoice($invoice);
1390 1390
         }
1391 1391
         
1392
-        if ( !( is_object( $invoice ) && is_a( $invoice, 'WPInv_Invoice' ) ) ) {
1392
+        if (!(is_object($invoice) && is_a($invoice, 'WPInv_Invoice'))) {
1393 1393
             return true;
1394 1394
         }
1395 1395
         
1396
-        $cart_items  = $invoice->get_cart_details();
1396
+        $cart_items = $invoice->get_cart_details();
1397 1397
         
1398
-        if ( !empty( $cart_items ) ) {
1398
+        if (!empty($cart_items)) {
1399 1399
             $has_digital_rule = false;
1400 1400
             
1401
-            foreach ( $cart_items as $key => $item ) {
1402
-                if ( self::item_has_digital_rule( $item['id'] ) ) {
1401
+            foreach ($cart_items as $key => $item) {
1402
+                if (self::item_has_digital_rule($item['id'])) {
1403 1403
                     $has_digital_rule = true;
1404 1404
                     break;
1405 1405
                 }
@@ -1411,67 +1411,67 @@  discard block
 block discarded – undo
1411 1411
         return $has_digital_rule;
1412 1412
     }
1413 1413
     
1414
-    public static function item_is_taxable( $item_id = 0, $country = false, $state = false ) {        
1415
-        if ( !wpinv_use_taxes() ) {
1414
+    public static function item_is_taxable($item_id = 0, $country = false, $state = false) {        
1415
+        if (!wpinv_use_taxes()) {
1416 1416
             return false;
1417 1417
         }
1418 1418
         
1419 1419
         $is_taxable = true;
1420 1420
 
1421
-        if ( !empty( $item_id ) && self::get_item_class( $item_id ) == '_exempt' ) {
1421
+        if (!empty($item_id) && self::get_item_class($item_id) == '_exempt') {
1422 1422
             $is_taxable = false;
1423 1423
         }
1424 1424
         
1425
-        return apply_filters( 'wpinv_item_is_taxable', $is_taxable, $item_id, $country , $state );
1425
+        return apply_filters('wpinv_item_is_taxable', $is_taxable, $item_id, $country, $state);
1426 1426
     }
1427 1427
     
1428
-    public static function find_rate( $country, $state, $rate, $class ) {
1428
+    public static function find_rate($country, $state, $rate, $class) {
1429 1429
         global $wpi_zero_tax;
1430 1430
 
1431
-        if ( $class === '_exempt' || $wpi_zero_tax ) {
1431
+        if ($class === '_exempt' || $wpi_zero_tax) {
1432 1432
             return 0;
1433 1433
         }
1434 1434
 
1435
-        $tax_rates   = wpinv_get_tax_rates();
1435
+        $tax_rates = wpinv_get_tax_rates();
1436 1436
         
1437
-        if ( $class !== '_standard' ) {
1438
-            $class_rates = self::get_vat_rates( $class );
1437
+        if ($class !== '_standard') {
1438
+            $class_rates = self::get_vat_rates($class);
1439 1439
             
1440
-            if ( is_array( $class_rates ) ) {
1440
+            if (is_array($class_rates)) {
1441 1441
                 $indexed_class_rates = array();
1442 1442
                 
1443
-                foreach ( $class_rates as $key => $cr ) {
1443
+                foreach ($class_rates as $key => $cr) {
1444 1444
                     $indexed_class_rates[$cr['country']] = $cr;
1445 1445
                 }
1446 1446
 
1447
-                $tax_rates = array_map( function( $tr ) use( $indexed_class_rates ) {
1447
+                $tax_rates = array_map(function($tr) use($indexed_class_rates) {
1448 1448
                     $tr_country = $tr['country'];
1449
-                    if ( !isset( $indexed_class_rates[$tr_country] ) ) {
1449
+                    if (!isset($indexed_class_rates[$tr_country])) {
1450 1450
                         return $tr;
1451 1451
                     }
1452 1452
                     $icr = $indexed_class_rates[$tr_country];
1453
-                    return ( empty( $icr['rate'] ) && $icr['rate'] !== '0' ) ? $tr : $icr;
1453
+                    return (empty($icr['rate']) && $icr['rate'] !== '0') ? $tr : $icr;
1454 1454
 
1455
-                }, $tax_rates, $class_rates );
1455
+                }, $tax_rates, $class_rates);
1456 1456
             }
1457 1457
         }
1458 1458
 
1459
-        if ( !empty( $tax_rates ) ) {
1460
-            foreach ( $tax_rates as $key => $tax_rate ) {
1461
-                if ( $country != $tax_rate['country'] )
1459
+        if (!empty($tax_rates)) {
1460
+            foreach ($tax_rates as $key => $tax_rate) {
1461
+                if ($country != $tax_rate['country'])
1462 1462
                     continue;
1463 1463
 
1464
-                if ( !empty( $tax_rate['global'] ) ) {
1465
-                    if ( 0 !== $tax_rate['rate'] || !empty( $tax_rate['rate'] ) ) {
1466
-                        $rate = number_format( $tax_rate['rate'], 4 );
1464
+                if (!empty($tax_rate['global'])) {
1465
+                    if (0 !== $tax_rate['rate'] || !empty($tax_rate['rate'])) {
1466
+                        $rate = number_format($tax_rate['rate'], 4);
1467 1467
                     }
1468 1468
                 } else {
1469
-                    if ( empty( $tax_rate['state'] ) || strtolower( $state ) != strtolower( $tax_rate['state'] ) )
1469
+                    if (empty($tax_rate['state']) || strtolower($state) != strtolower($tax_rate['state']))
1470 1470
                         continue;
1471 1471
 
1472 1472
                     $state_rate = $tax_rate['rate'];
1473
-                    if ( 0 !== $state_rate || !empty( $state_rate ) ) {
1474
-                        $rate = number_format( $state_rate, 4 );
1473
+                    if (0 !== $state_rate || !empty($state_rate)) {
1474
+                        $rate = number_format($state_rate, 4);
1475 1475
                     }
1476 1476
                 }
1477 1477
             }
@@ -1480,84 +1480,84 @@  discard block
 block discarded – undo
1480 1480
         return $rate;
1481 1481
     }
1482 1482
     
1483
-    public static function get_rate( $rate = 1, $country = '', $state = '', $item_id = 0 ) {
1483
+    public static function get_rate($rate = 1, $country = '', $state = '', $item_id = 0) {
1484 1484
         global $wpinv_options, $wpi_session, $wpi_item_id, $wpi_zero_tax;
1485 1485
         
1486 1486
         $item_id = $item_id > 0 ? $item_id : $wpi_item_id;
1487 1487
         $allow_vat_classes = self::allow_vat_classes();
1488
-        $class = $item_id ? self::get_item_class( $item_id ) : '_standard';
1488
+        $class = $item_id ? self::get_item_class($item_id) : '_standard';
1489 1489
 
1490
-        if ( $class === '_exempt' || $wpi_zero_tax ) {
1490
+        if ($class === '_exempt' || $wpi_zero_tax) {
1491 1491
             return 0;
1492
-        } else if ( !$allow_vat_classes ) {
1492
+        } else if (!$allow_vat_classes) {
1493 1493
             $class = '_standard';
1494 1494
         }
1495 1495
 
1496
-        if( !empty( $_POST['wpinv_country'] ) ) {
1496
+        if (!empty($_POST['wpinv_country'])) {
1497 1497
             $post_country = $_POST['wpinv_country'];
1498
-        } elseif( !empty( $_POST['wpinv_country'] ) ) {
1498
+        } elseif (!empty($_POST['wpinv_country'])) {
1499 1499
             $post_country = $_POST['wpinv_country'];
1500
-        } elseif( !empty( $_POST['country'] ) ) {
1500
+        } elseif (!empty($_POST['country'])) {
1501 1501
             $post_country = $_POST['country'];
1502 1502
         } else {
1503 1503
             $post_country = '';
1504 1504
         }
1505 1505
 
1506
-        $country        = !empty( $post_country ) ? $post_country : wpinv_default_billing_country( $country );
1507
-        $base_country   = wpinv_is_base_country( $country );
1506
+        $country        = !empty($post_country) ? $post_country : wpinv_default_billing_country($country);
1507
+        $base_country   = wpinv_is_base_country($country);
1508 1508
         
1509
-        $requires_vat   = self::requires_vat( 0, false );
1510
-        $is_digital     = self::get_item_rule( $item_id ) == 'digital' ;
1511
-        $rate           = $requires_vat && isset( $wpinv_options['eu_fallback_rate'] ) ? $wpinv_options['eu_fallback_rate'] : $rate;
1509
+        $requires_vat   = self::requires_vat(0, false);
1510
+        $is_digital     = self::get_item_rule($item_id) == 'digital';
1511
+        $rate           = $requires_vat && isset($wpinv_options['eu_fallback_rate']) ? $wpinv_options['eu_fallback_rate'] : $rate;
1512 1512
           
1513
-        if ( self::same_country_rule() == 'no' && $base_country ) { // Disable VAT to same country
1513
+        if (self::same_country_rule() == 'no' && $base_country) { // Disable VAT to same country
1514 1514
             $rate = 0;
1515
-        } else if ( $requires_vat ) {
1516
-            $vat_number = self::get_user_vat_number( '', 0, true );
1515
+        } else if ($requires_vat) {
1516
+            $vat_number = self::get_user_vat_number('', 0, true);
1517 1517
             $vat_info   = self::current_vat_data();
1518 1518
             
1519
-            if ( is_array( $vat_info ) ) {
1520
-                $vat_number = isset( $vat_info['number'] ) && !empty( $vat_info['valid'] ) ? $vat_info['number'] : "";
1519
+            if (is_array($vat_info)) {
1520
+                $vat_number = isset($vat_info['number']) && !empty($vat_info['valid']) ? $vat_info['number'] : "";
1521 1521
             }
1522 1522
             
1523
-            if ( $country == 'UK' ) {
1523
+            if ($country == 'UK') {
1524 1524
                 $country = 'GB';
1525 1525
             }
1526 1526
 
1527
-            if ( !empty( $vat_number ) ) {
1527
+            if (!empty($vat_number)) {
1528 1528
                 $rate = 0;
1529 1529
             } else {
1530
-                $rate = self::find_rate( $country, $state, $rate, $class ); // Fix if there are no tax rated and you try to pay an invoice it does not add the fallback tax rate
1530
+                $rate = self::find_rate($country, $state, $rate, $class); // Fix if there are no tax rated and you try to pay an invoice it does not add the fallback tax rate
1531 1531
             }
1532 1532
 
1533
-            if ( empty( $vat_number ) && !$is_digital ) {
1534
-                if ( $base_country ) {
1535
-                    $rate = self::find_rate( $country, null, $rate, $class );
1533
+            if (empty($vat_number) && !$is_digital) {
1534
+                if ($base_country) {
1535
+                    $rate = self::find_rate($country, null, $rate, $class);
1536 1536
                 } else {
1537
-                    if ( empty( $country ) && isset( $wpinv_options['eu_fallback_rate'] ) ) {
1537
+                    if (empty($country) && isset($wpinv_options['eu_fallback_rate'])) {
1538 1538
                         $rate = $wpinv_options['eu_fallback_rate'];
1539
-                    } else if( !empty( $country ) ) {
1540
-                        $rate = self::find_rate( $country, $state, $rate, $class );
1539
+                    } else if (!empty($country)) {
1540
+                        $rate = self::find_rate($country, $state, $rate, $class);
1541 1541
                     }
1542 1542
                 }
1543
-            } else if ( empty( $vat_number ) || ( self::same_country_rule() == 'always' && $base_country ) ) {
1544
-                if ( empty( $country ) && isset( $wpinv_options['eu_fallback_rate'] ) ) {
1543
+            } else if (empty($vat_number) || (self::same_country_rule() == 'always' && $base_country)) {
1544
+                if (empty($country) && isset($wpinv_options['eu_fallback_rate'])) {
1545 1545
                     $rate = $wpinv_options['eu_fallback_rate'];
1546
-                } else if( !empty( $country ) ) {
1547
-                    $rate = self::find_rate( $country, $state, $rate, $class );
1546
+                } else if (!empty($country)) {
1547
+                    $rate = self::find_rate($country, $state, $rate, $class);
1548 1548
                 }
1549 1549
             }
1550 1550
         } else {
1551
-            if ( $is_digital ) {
1551
+            if ($is_digital) {
1552 1552
                 $ip_country_code = self::get_country_by_ip();
1553 1553
                 
1554
-                if ( $ip_country_code && self::is_eu_state( $ip_country_code ) ) {
1555
-                    $rate = self::find_rate( $ip_country_code, '', 0, $class );
1554
+                if ($ip_country_code && self::is_eu_state($ip_country_code)) {
1555
+                    $rate = self::find_rate($ip_country_code, '', 0, $class);
1556 1556
                 } else {
1557
-                    $rate = self::find_rate( $country, $state, $rate, $class );
1557
+                    $rate = self::find_rate($country, $state, $rate, $class);
1558 1558
                 }
1559 1559
             } else {
1560
-                $rate = self::find_rate( $country, $state, $rate, $class );
1560
+                $rate = self::find_rate($country, $state, $rate, $class);
1561 1561
             }
1562 1562
         }
1563 1563
 
@@ -1567,48 +1567,48 @@  discard block
 block discarded – undo
1567 1567
     public static function current_vat_data() {
1568 1568
         global $wpi_session;
1569 1569
         
1570
-        return $wpi_session->get( 'user_vat_data' );
1570
+        return $wpi_session->get('user_vat_data');
1571 1571
     }
1572 1572
     
1573
-    public static function get_user_country( $country = '', $user_id = 0 ) {
1574
-        $user_address = wpinv_get_user_address( $user_id, false );
1573
+    public static function get_user_country($country = '', $user_id = 0) {
1574
+        $user_address = wpinv_get_user_address($user_id, false);
1575 1575
         
1576
-        if ( wpinv_get_option( 'vat_ip_country_default' ) ) {
1576
+        if (wpinv_get_option('vat_ip_country_default')) {
1577 1577
             $country = '';
1578 1578
         }
1579 1579
         
1580
-        $country    = empty( $user_address ) || !isset( $user_address['country'] ) || empty( $user_address['country'] ) ? $country : $user_address['country'];
1581
-        $result     = apply_filters( 'wpinv_get_user_country', $country, $user_id );
1580
+        $country    = empty($user_address) || !isset($user_address['country']) || empty($user_address['country']) ? $country : $user_address['country'];
1581
+        $result     = apply_filters('wpinv_get_user_country', $country, $user_id);
1582 1582
 
1583
-        if ( empty( $result ) ) {
1583
+        if (empty($result)) {
1584 1584
             $result = self::get_country_by_ip();
1585 1585
         }
1586 1586
 
1587 1587
         return $result;
1588 1588
     }
1589 1589
     
1590
-    public static function set_user_country( $country = '', $user_id = 0 ) {
1590
+    public static function set_user_country($country = '', $user_id = 0) {
1591 1591
         global $wpi_userID;
1592 1592
         
1593
-        if ( empty($country) && !empty($wpi_userID) && get_current_user_id() != $wpi_userID ) {
1593
+        if (empty($country) && !empty($wpi_userID) && get_current_user_id() != $wpi_userID) {
1594 1594
             $country = wpinv_get_default_country();
1595 1595
         }
1596 1596
         
1597 1597
         return $country;
1598 1598
     }
1599 1599
     
1600
-    public static function get_user_vat_number( $vat_number = '', $user_id = 0, $is_valid = false ) {
1600
+    public static function get_user_vat_number($vat_number = '', $user_id = 0, $is_valid = false) {
1601 1601
         global $wpi_current_id, $wpi_userID;
1602 1602
         
1603
-        if ( !empty( $_POST['new_user'] ) ) {
1603
+        if (!empty($_POST['new_user'])) {
1604 1604
             return '';
1605 1605
         }
1606 1606
         
1607
-        if ( empty( $user_id ) ) {
1608
-            $user_id = !empty( $wpi_userID ) ? $wpi_userID : ( $wpi_current_id ? wpinv_get_user_id( $wpi_current_id ) : get_current_user_id() );
1607
+        if (empty($user_id)) {
1608
+            $user_id = !empty($wpi_userID) ? $wpi_userID : ($wpi_current_id ? wpinv_get_user_id($wpi_current_id) : get_current_user_id());
1609 1609
         }
1610 1610
 
1611
-        $vat_number = empty( $user_id ) ? '' : get_user_meta( $user_id, '_wpinv_vat_number', true );
1611
+        $vat_number = empty($user_id) ? '' : get_user_meta($user_id, '_wpinv_vat_number', true);
1612 1612
         
1613 1613
         /* TODO
1614 1614
         if ( $is_valid && $vat_number ) {
@@ -1619,38 +1619,38 @@  discard block
 block discarded – undo
1619 1619
         }
1620 1620
         */
1621 1621
 
1622
-        return apply_filters('wpinv_get_user_vat_number', $vat_number, $user_id, $is_valid );
1622
+        return apply_filters('wpinv_get_user_vat_number', $vat_number, $user_id, $is_valid);
1623 1623
     }
1624 1624
     
1625
-    public static function get_user_company( $company = '', $user_id = 0 ) {
1625
+    public static function get_user_company($company = '', $user_id = 0) {
1626 1626
         global $wpi_current_id, $wpi_userID;
1627 1627
         
1628
-        if ( empty( $user_id ) ) {
1629
-            $user_id = !empty( $wpi_userID ) ? $wpi_userID : ( $wpi_current_id ? wpinv_get_user_id( $wpi_current_id ) : get_current_user_id() );
1628
+        if (empty($user_id)) {
1629
+            $user_id = !empty($wpi_userID) ? $wpi_userID : ($wpi_current_id ? wpinv_get_user_id($wpi_current_id) : get_current_user_id());
1630 1630
         }
1631 1631
 
1632
-        $company = empty( $user_id ) ? "" : get_user_meta( $user_id, '_wpinv_company', true );
1632
+        $company = empty($user_id) ? "" : get_user_meta($user_id, '_wpinv_company', true);
1633 1633
 
1634
-        return apply_filters( 'wpinv_user_company', $company, $user_id );
1634
+        return apply_filters('wpinv_user_company', $company, $user_id);
1635 1635
     }
1636 1636
     
1637
-    public static function save_user_vat_details( $company = '', $vat_number = '' ) {
1638
-        $save = apply_filters( 'wpinv_allow_save_user_vat_details', true );
1637
+    public static function save_user_vat_details($company = '', $vat_number = '') {
1638
+        $save = apply_filters('wpinv_allow_save_user_vat_details', true);
1639 1639
 
1640
-        if ( is_user_logged_in() && $save ) {
1640
+        if (is_user_logged_in() && $save) {
1641 1641
             $user_id = get_current_user_id();
1642 1642
 
1643
-            if ( !empty( $vat_number ) ) {
1644
-                update_user_meta( $user_id, '_wpinv_vat_number', $vat_number );
1643
+            if (!empty($vat_number)) {
1644
+                update_user_meta($user_id, '_wpinv_vat_number', $vat_number);
1645 1645
             } else {
1646
-                delete_user_meta( $user_id, '_wpinv_vat_number');
1646
+                delete_user_meta($user_id, '_wpinv_vat_number');
1647 1647
             }
1648 1648
 
1649
-            if ( !empty( $company ) ) {
1650
-                update_user_meta( $user_id, '_wpinv_company', $company );
1649
+            if (!empty($company)) {
1650
+                update_user_meta($user_id, '_wpinv_company', $company);
1651 1651
             } else {
1652
-                delete_user_meta( $user_id, '_wpinv_company');
1653
-                delete_user_meta( $user_id, '_wpinv_vat_number');
1652
+                delete_user_meta($user_id, '_wpinv_company');
1653
+                delete_user_meta($user_id, '_wpinv_vat_number');
1654 1654
             }
1655 1655
         }
1656 1656
 
@@ -1660,113 +1660,113 @@  discard block
 block discarded – undo
1660 1660
     public static function ajax_vat_validate() {
1661 1661
         global $wpinv_options, $wpi_session;
1662 1662
         
1663
-        $is_checkout            = ( !empty( $_POST['source'] ) && $_POST['source'] == 'checkout' ) ? true : false;
1663
+        $is_checkout            = (!empty($_POST['source']) && $_POST['source'] == 'checkout') ? true : false;
1664 1664
         $response               = array();
1665 1665
         $response['success']    = false;
1666 1666
         
1667
-        if ( empty( $_REQUEST['_wpi_nonce'] ) || ( !empty( $_REQUEST['_wpi_nonce'] ) && !wp_verify_nonce( $_REQUEST['_wpi_nonce'], 'vat_validation' ) ) ) {
1668
-            $response['error'] = __( 'Invalid security nonce', 'invoicing' );
1669
-            wp_send_json( $response );
1667
+        if (empty($_REQUEST['_wpi_nonce']) || (!empty($_REQUEST['_wpi_nonce']) && !wp_verify_nonce($_REQUEST['_wpi_nonce'], 'vat_validation'))) {
1668
+            $response['error'] = __('Invalid security nonce', 'invoicing');
1669
+            wp_send_json($response);
1670 1670
         }
1671 1671
         
1672
-        $vat_name   = self::get_vat_name();
1672
+        $vat_name = self::get_vat_name();
1673 1673
         
1674
-        if ( $is_checkout ) {
1674
+        if ($is_checkout) {
1675 1675
             $invoice = wpinv_get_invoice_cart();
1676 1676
             
1677
-            if ( !self::requires_vat( false, 0, self::invoice_has_digital_rule( $invoice ) ) ) {
1677
+            if (!self::requires_vat(false, 0, self::invoice_has_digital_rule($invoice))) {
1678 1678
                 $vat_info = array();
1679
-                $wpi_session->set( 'user_vat_data', $vat_info );
1679
+                $wpi_session->set('user_vat_data', $vat_info);
1680 1680
 
1681 1681
                 self::save_user_vat_details();
1682 1682
                 
1683 1683
                 $response['success'] = true;
1684
-                $response['message'] = wp_sprintf( __( 'Ignore %s', 'invoicing' ), $vat_name );
1685
-                wp_send_json( $response );
1684
+                $response['message'] = wp_sprintf(__('Ignore %s', 'invoicing'), $vat_name);
1685
+                wp_send_json($response);
1686 1686
             }
1687 1687
         }
1688 1688
         
1689
-        $company    = !empty( $_POST['company'] ) ? sanitize_text_field( $_POST['company'] ) : '';
1690
-        $vat_number = !empty( $_POST['number'] ) ? sanitize_text_field( $_POST['number'] ) : '';
1689
+        $company    = !empty($_POST['company']) ? sanitize_text_field($_POST['company']) : '';
1690
+        $vat_number = !empty($_POST['number']) ? sanitize_text_field($_POST['number']) : '';
1691 1691
         
1692
-        $vat_info = $wpi_session->get( 'user_vat_data' );
1693
-        if ( !is_array( $vat_info ) || empty( $vat_info ) ) {
1694
-            $vat_info = array( 'company'=> $company, 'number' => '', 'valid' => true );
1692
+        $vat_info = $wpi_session->get('user_vat_data');
1693
+        if (!is_array($vat_info) || empty($vat_info)) {
1694
+            $vat_info = array('company'=> $company, 'number' => '', 'valid' => true);
1695 1695
         }
1696 1696
         
1697
-        if ( empty( $vat_number ) ) {
1698
-            if ( $is_checkout ) {
1697
+        if (empty($vat_number)) {
1698
+            if ($is_checkout) {
1699 1699
                 $response['success'] = true;
1700
-                $response['message'] = wp_sprintf( __( 'No %s number has been applied. %s will be added to invoice totals', 'invoicing' ), $vat_name, $vat_name );
1700
+                $response['message'] = wp_sprintf(__('No %s number has been applied. %s will be added to invoice totals', 'invoicing'), $vat_name, $vat_name);
1701 1701
                 
1702
-                $vat_info = $wpi_session->get( 'user_vat_data' );
1702
+                $vat_info = $wpi_session->get('user_vat_data');
1703 1703
                 $vat_info['number'] = "";
1704 1704
                 $vat_info['valid'] = true;
1705 1705
                 
1706
-                self::save_user_vat_details( $company );
1706
+                self::save_user_vat_details($company);
1707 1707
             } else {
1708
-                $response['error'] = wp_sprintf( __( 'Please enter your %s number!', 'invoicing' ), $vat_name );
1708
+                $response['error'] = wp_sprintf(__('Please enter your %s number!', 'invoicing'), $vat_name);
1709 1709
                 
1710 1710
                 $vat_info['valid'] = false;
1711 1711
             }
1712 1712
 
1713
-            $wpi_session->set( 'user_vat_data', $vat_info );
1714
-            wp_send_json( $response );
1713
+            $wpi_session->set('user_vat_data', $vat_info);
1714
+            wp_send_json($response);
1715 1715
         }
1716 1716
         
1717
-        if ( empty( $company ) ) {
1717
+        if (empty($company)) {
1718 1718
             $vat_info['valid'] = false;
1719
-            $wpi_session->set( 'user_vat_data', $vat_info );
1719
+            $wpi_session->set('user_vat_data', $vat_info);
1720 1720
             
1721
-            $response['error'] = __( 'Please enter your registered company name!', 'invoicing' );
1722
-            wp_send_json( $response );
1721
+            $response['error'] = __('Please enter your registered company name!', 'invoicing');
1722
+            wp_send_json($response);
1723 1723
         }
1724 1724
         
1725
-        if ( !empty( $wpinv_options['vat_vies_check'] ) ) {
1726
-            if ( empty( $wpinv_options['vat_offline_check'] ) && !self::offline_check( $vat_number ) ) {
1725
+        if (!empty($wpinv_options['vat_vies_check'])) {
1726
+            if (empty($wpinv_options['vat_offline_check']) && !self::offline_check($vat_number)) {
1727 1727
                 $vat_info['valid'] = false;
1728
-                $wpi_session->set( 'user_vat_data', $vat_info );
1728
+                $wpi_session->set('user_vat_data', $vat_info);
1729 1729
                 
1730
-                $response['error'] = wp_sprintf( __( '%s number not validated', 'invoicing' ), $vat_name );
1731
-                wp_send_json( $response );
1730
+                $response['error'] = wp_sprintf(__('%s number not validated', 'invoicing'), $vat_name);
1731
+                wp_send_json($response);
1732 1732
             }
1733 1733
             
1734 1734
             $response['success'] = true;
1735
-            $response['message'] = wp_sprintf( __( '%s number validated', 'invoicing' ), $vat_name );
1735
+            $response['message'] = wp_sprintf(__('%s number validated', 'invoicing'), $vat_name);
1736 1736
         } else {
1737
-            $result = self::check_vat( $vat_number );
1737
+            $result = self::check_vat($vat_number);
1738 1738
             
1739
-            if ( empty( $result['valid'] ) ) {
1739
+            if (empty($result['valid'])) {
1740 1740
                 $response['error'] = $result['message'];
1741
-                wp_send_json( $response );
1741
+                wp_send_json($response);
1742 1742
             }
1743 1743
             
1744
-            $vies_company = !empty( $result['company'] ) ? $result['company'] : '';
1745
-            $vies_company = apply_filters( 'wpinv_vies_company_name', $vies_company );
1744
+            $vies_company = !empty($result['company']) ? $result['company'] : '';
1745
+            $vies_company = apply_filters('wpinv_vies_company_name', $vies_company);
1746 1746
             
1747
-            $valid_company = $vies_company && $company && ( $vies_company == '---' || strcasecmp( trim( $vies_company ), trim( $company ) ) == 0 ) ? true : false;
1747
+            $valid_company = $vies_company && $company && ($vies_company == '---' || strcasecmp(trim($vies_company), trim($company)) == 0) ? true : false;
1748 1748
 
1749
-            if ( !empty( $wpinv_options['vat_disable_company_name_check'] ) || $valid_company ) {
1749
+            if (!empty($wpinv_options['vat_disable_company_name_check']) || $valid_company) {
1750 1750
                 $response['success'] = true;
1751
-                $response['message'] = wp_sprintf( __( '%s number validated', 'invoicing' ), $vat_name );
1751
+                $response['message'] = wp_sprintf(__('%s number validated', 'invoicing'), $vat_name);
1752 1752
             } else {           
1753 1753
                 $vat_info['valid'] = false;
1754
-                $wpi_session->set( 'user_vat_data', $vat_info );
1754
+                $wpi_session->set('user_vat_data', $vat_info);
1755 1755
                 
1756 1756
                 $response['success'] = false;
1757
-                $response['message'] = wp_sprintf( __( 'The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing' ), $vat_name );
1758
-                wp_send_json( $response );
1757
+                $response['message'] = wp_sprintf(__('The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing'), $vat_name);
1758
+                wp_send_json($response);
1759 1759
             }
1760 1760
         }
1761 1761
         
1762
-        if ( $is_checkout ) {
1763
-            self::save_user_vat_details( $company, $vat_number );
1762
+        if ($is_checkout) {
1763
+            self::save_user_vat_details($company, $vat_number);
1764 1764
 
1765
-            $vat_info = array('company' => $company, 'number' => $vat_number, 'valid' => true );
1766
-            $wpi_session->set( 'user_vat_data', $vat_info );
1765
+            $vat_info = array('company' => $company, 'number' => $vat_number, 'valid' => true);
1766
+            $wpi_session->set('user_vat_data', $vat_info);
1767 1767
         }
1768 1768
 
1769
-        wp_send_json( $response );
1769
+        wp_send_json($response);
1770 1770
     }
1771 1771
     
1772 1772
     public static function ajax_vat_reset() {
@@ -1775,161 +1775,161 @@  discard block
 block discarded – undo
1775 1775
         $company    = is_user_logged_in() ? self::get_user_company() : '';
1776 1776
         $vat_number = self::get_user_vat_number();
1777 1777
         
1778
-        $vat_info   = array('company' => $company, 'number' => $vat_number, 'valid' => false );
1779
-        $wpi_session->set( 'user_vat_data', $vat_info );
1778
+        $vat_info   = array('company' => $company, 'number' => $vat_number, 'valid' => false);
1779
+        $wpi_session->set('user_vat_data', $vat_info);
1780 1780
         
1781 1781
         $response                       = array();
1782 1782
         $response['success']            = true;
1783 1783
         $response['data']['company']    = $company;
1784 1784
         $response['data']['number']     = $vat_number;
1785 1785
         
1786
-        wp_send_json( $response );
1786
+        wp_send_json($response);
1787 1787
     }
1788 1788
     
1789
-    public static function checkout_vat_validate( $valid_data, $post ) {
1789
+    public static function checkout_vat_validate($valid_data, $post) {
1790 1790
         global $wpinv_options, $wpi_session;
1791 1791
         
1792
-        $vat_name  = __( self::get_vat_name(), 'invoicing' );
1792
+        $vat_name = __(self::get_vat_name(), 'invoicing');
1793 1793
         
1794
-        if ( !isset( $_POST['_wpi_nonce'] ) || !wp_verify_nonce( $_POST['_wpi_nonce'], 'vat_validation' ) ) {
1795
-            wpinv_set_error( 'vat_validation', wp_sprintf( __( "Invalid %s validation request.", 'invoicing' ), $vat_name ) );
1794
+        if (!isset($_POST['_wpi_nonce']) || !wp_verify_nonce($_POST['_wpi_nonce'], 'vat_validation')) {
1795
+            wpinv_set_error('vat_validation', wp_sprintf(__("Invalid %s validation request.", 'invoicing'), $vat_name));
1796 1796
             return;
1797 1797
         }
1798 1798
         
1799
-        $vat_saved = $wpi_session->get( 'user_vat_data' );
1800
-        $wpi_session->set( 'user_vat_data', null );
1799
+        $vat_saved = $wpi_session->get('user_vat_data');
1800
+        $wpi_session->set('user_vat_data', null);
1801 1801
         
1802 1802
         $invoice        = wpinv_get_invoice_cart();
1803 1803
         $amount         = $invoice->get_total();
1804
-        $is_digital     = self::invoice_has_digital_rule( $invoice );
1805
-        $no_vat         = !self::requires_vat( 0, false, $is_digital );
1804
+        $is_digital     = self::invoice_has_digital_rule($invoice);
1805
+        $no_vat         = !self::requires_vat(0, false, $is_digital);
1806 1806
         
1807
-        $company        = !empty( $_POST['wpinv_company'] ) ? $_POST['wpinv_company'] : null;
1808
-        $vat_number     = !empty( $_POST['wpinv_vat_number'] ) ? $_POST['wpinv_vat_number'] : null;
1809
-        $country        = !empty( $_POST['wpinv_country'] ) ? $_POST['wpinv_country'] : $invoice->country;
1810
-        if ( empty( $country ) ) {
1807
+        $company        = !empty($_POST['wpinv_company']) ? $_POST['wpinv_company'] : null;
1808
+        $vat_number     = !empty($_POST['wpinv_vat_number']) ? $_POST['wpinv_vat_number'] : null;
1809
+        $country        = !empty($_POST['wpinv_country']) ? $_POST['wpinv_country'] : $invoice->country;
1810
+        if (empty($country)) {
1811 1811
             $country = wpinv_default_billing_country();
1812 1812
         }
1813 1813
         
1814
-        if ( !$is_digital && $no_vat ) {
1814
+        if (!$is_digital && $no_vat) {
1815 1815
             return;
1816 1816
         }
1817 1817
             
1818
-        $vat_data           = array( 'company' => '', 'number' => '', 'valid' => false );
1818
+        $vat_data           = array('company' => '', 'number' => '', 'valid' => false);
1819 1819
         
1820 1820
         $ip_country_code    = self::get_country_by_ip();
1821
-        $is_eu_state        = self::is_eu_state( $country );
1822
-        $is_eu_state_ip     = self::is_eu_state( $ip_country_code );
1821
+        $is_eu_state        = self::is_eu_state($country);
1822
+        $is_eu_state_ip     = self::is_eu_state($ip_country_code);
1823 1823
         $is_non_eu_user     = !$is_eu_state && !$is_eu_state_ip;
1824 1824
         
1825
-        if ( $is_digital && !$is_non_eu_user && empty( $vat_number ) && apply_filters( 'wpinv_checkout_requires_country', true, $amount ) ) {
1825
+        if ($is_digital && !$is_non_eu_user && empty($vat_number) && apply_filters('wpinv_checkout_requires_country', true, $amount)) {
1826 1826
             $vat_data['adddress_confirmed'] = false;
1827 1827
             
1828
-            if ( !isset( $_POST['wpinv_adddress_confirmed'] ) ) {
1829
-                if ( $ip_country_code != $country ) {
1830
-                    wpinv_set_error( 'vat_validation', sprintf( __( 'The country of your current location must be the same as the country of your billing location or you must %s confirm %s the billing address is your home country.', 'invoicing' ), '<a href="#wpinv_adddress_confirm">', '</a>' ) );
1828
+            if (!isset($_POST['wpinv_adddress_confirmed'])) {
1829
+                if ($ip_country_code != $country) {
1830
+                    wpinv_set_error('vat_validation', sprintf(__('The country of your current location must be the same as the country of your billing location or you must %s confirm %s the billing address is your home country.', 'invoicing'), '<a href="#wpinv_adddress_confirm">', '</a>'));
1831 1831
                 }
1832 1832
             } else {
1833 1833
                 $vat_data['adddress_confirmed'] = true;
1834 1834
             }
1835 1835
         }
1836 1836
         
1837
-        if ( !empty( $wpinv_options['vat_prevent_b2c_purchase'] ) && !$is_non_eu_user && ( empty( $vat_number ) || $no_vat ) ) {
1838
-            if ( $is_eu_state ) {
1839
-                wpinv_set_error( 'vat_validation', wp_sprintf( __( 'Please enter and validate your %s number to verify your purchase is by an EU business.', 'invoicing' ), $vat_name ) );
1840
-            } else if ( $is_digital && $is_eu_state_ip ) {
1841
-                wpinv_set_error( 'vat_validation', wp_sprintf( __( 'Sales to non-EU countries cannot be completed because %s must be applied.', 'invoicing' ), $vat_name ) );
1837
+        if (!empty($wpinv_options['vat_prevent_b2c_purchase']) && !$is_non_eu_user && (empty($vat_number) || $no_vat)) {
1838
+            if ($is_eu_state) {
1839
+                wpinv_set_error('vat_validation', wp_sprintf(__('Please enter and validate your %s number to verify your purchase is by an EU business.', 'invoicing'), $vat_name));
1840
+            } else if ($is_digital && $is_eu_state_ip) {
1841
+                wpinv_set_error('vat_validation', wp_sprintf(__('Sales to non-EU countries cannot be completed because %s must be applied.', 'invoicing'), $vat_name));
1842 1842
             }
1843 1843
         }
1844 1844
         
1845
-        if ( !$is_eu_state || $no_vat || empty( $vat_number ) ) {
1845
+        if (!$is_eu_state || $no_vat || empty($vat_number)) {
1846 1846
             return;
1847 1847
         }
1848 1848
 
1849
-        if ( !empty( $vat_saved ) && isset( $vat_saved['valid'] ) ) {
1850
-            $vat_data['valid']  = $vat_saved['valid'];
1849
+        if (!empty($vat_saved) && isset($vat_saved['valid'])) {
1850
+            $vat_data['valid'] = $vat_saved['valid'];
1851 1851
         }
1852 1852
             
1853
-        if ( $company !== null ) {
1853
+        if ($company !== null) {
1854 1854
             $vat_data['company'] = $company;
1855 1855
         }
1856 1856
 
1857 1857
         $message = '';
1858
-        if ( $vat_number !== null ) {
1858
+        if ($vat_number !== null) {
1859 1859
             $vat_data['number'] = $vat_number;
1860 1860
             
1861
-            if ( !$vat_data['valid'] || ( $vat_saved['number'] !== $vat_data['number'] ) || ( $vat_saved['company'] !== $vat_data['company'] ) ) {
1862
-                if ( !empty( $wpinv_options['vat_vies_check'] ) ) {            
1863
-                    if ( empty( $wpinv_options['vat_offline_check'] ) && !self::offline_check( $vat_number ) ) {
1861
+            if (!$vat_data['valid'] || ($vat_saved['number'] !== $vat_data['number']) || ($vat_saved['company'] !== $vat_data['company'])) {
1862
+                if (!empty($wpinv_options['vat_vies_check'])) {            
1863
+                    if (empty($wpinv_options['vat_offline_check']) && !self::offline_check($vat_number)) {
1864 1864
                         $vat_data['valid'] = false;
1865 1865
                     }
1866 1866
                 } else {
1867
-                    $result = self::check_vat( $vat_number );
1867
+                    $result = self::check_vat($vat_number);
1868 1868
                     
1869
-                    if ( !empty( $result['valid'] ) ) {                
1869
+                    if (!empty($result['valid'])) {                
1870 1870
                         $vat_data['valid'] = true;
1871
-                        $vies_company = !empty( $result['company'] ) ? $result['company'] : '';
1872
-                        $vies_company = apply_filters( 'wpinv_vies_company_name', $vies_company );
1871
+                        $vies_company = !empty($result['company']) ? $result['company'] : '';
1872
+                        $vies_company = apply_filters('wpinv_vies_company_name', $vies_company);
1873 1873
                     
1874
-                        $valid_company = $vies_company && $company && ( $vies_company == '---' || strcasecmp( trim( $vies_company ), trim( $company ) ) == 0 ) ? true : false;
1874
+                        $valid_company = $vies_company && $company && ($vies_company == '---' || strcasecmp(trim($vies_company), trim($company)) == 0) ? true : false;
1875 1875
 
1876
-                        if ( !( !empty( $wpinv_options['vat_disable_company_name_check'] ) || $valid_company ) ) {         
1876
+                        if (!(!empty($wpinv_options['vat_disable_company_name_check']) || $valid_company)) {         
1877 1877
                             $vat_data['valid'] = false;
1878 1878
                             
1879
-                            $message = wp_sprintf( __( 'The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing' ), $vat_name );
1879
+                            $message = wp_sprintf(__('The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing'), $vat_name);
1880 1880
                         }
1881 1881
                     } else {
1882
-                        $message = wp_sprintf( __( 'Fail to validate the %s number: EU Commission VAT server (VIES) check fails.', 'invoicing' ), $vat_name );
1882
+                        $message = wp_sprintf(__('Fail to validate the %s number: EU Commission VAT server (VIES) check fails.', 'invoicing'), $vat_name);
1883 1883
                     }
1884 1884
                 }
1885 1885
                 
1886
-                if ( !$vat_data['valid'] ) {
1887
-                    $error = wp_sprintf( __( 'The %s %s number %s you have entered has not been validated', 'invoicing' ), '<a href="#wpi-vat-details">', $vat_name, '</a>' ) . ( $message ? ' ( ' . $message . ' )' : '' );
1888
-                    wpinv_set_error( 'vat_validation', $error );
1886
+                if (!$vat_data['valid']) {
1887
+                    $error = wp_sprintf(__('The %s %s number %s you have entered has not been validated', 'invoicing'), '<a href="#wpi-vat-details">', $vat_name, '</a>') . ($message ? ' ( ' . $message . ' )' : '');
1888
+                    wpinv_set_error('vat_validation', $error);
1889 1889
                 }
1890 1890
             }
1891 1891
         }
1892 1892
 
1893
-        $wpi_session->set( 'user_vat_data', $vat_data );
1893
+        $wpi_session->set('user_vat_data', $vat_data);
1894 1894
     }
1895 1895
     
1896
-    public static function checkout_vat_fields( $billing_details ) {
1896
+    public static function checkout_vat_fields($billing_details) {
1897 1897
         global $wpi_session, $wpinv_options, $wpi_country, $wpi_requires_vat;
1898 1898
         
1899 1899
         $ip_address         = wpinv_get_ip();
1900 1900
         $ip_country_code    = self::get_country_by_ip();
1901 1901
         
1902
-        $tax_label          = __( self::get_vat_name(), 'invoicing' );
1902
+        $tax_label          = __(self::get_vat_name(), 'invoicing');
1903 1903
         $invoice            = wpinv_get_invoice_cart();
1904
-        $is_digital         = self::invoice_has_digital_rule( $invoice );
1904
+        $is_digital         = self::invoice_has_digital_rule($invoice);
1905 1905
         $wpi_country        = $invoice->country;
1906 1906
         
1907
-        $requires_vat       = !self::hide_vat_fields() && !$invoice->is_free() && self::requires_vat( 0, false, $is_digital );
1907
+        $requires_vat       = !self::hide_vat_fields() && !$invoice->is_free() && self::requires_vat(0, false, $is_digital);
1908 1908
         $wpi_requires_vat   = $requires_vat;
1909 1909
         
1910 1910
         $company            = self::get_user_company();
1911 1911
         $vat_number         = self::get_user_vat_number();
1912 1912
         
1913
-        $validated          = $vat_number ? self::get_user_vat_number( '', 0, true ) : 1;
1914
-        $vat_info           = $wpi_session->get( 'user_vat_data' );
1913
+        $validated          = $vat_number ? self::get_user_vat_number('', 0, true) : 1;
1914
+        $vat_info           = $wpi_session->get('user_vat_data');
1915 1915
 
1916
-        if ( is_array( $vat_info ) ) {
1917
-            $company    = isset( $vat_info['company'] ) ? $vat_info['company'] : '';
1918
-            $vat_number = isset( $vat_info['number'] ) ? $vat_info['number'] : '';
1919
-            $validated  = isset( $vat_info['valid'] ) ? $vat_info['valid'] : false;
1916
+        if (is_array($vat_info)) {
1917
+            $company    = isset($vat_info['company']) ? $vat_info['company'] : '';
1918
+            $vat_number = isset($vat_info['number']) ? $vat_info['number'] : '';
1919
+            $validated  = isset($vat_info['valid']) ? $vat_info['valid'] : false;
1920 1920
         }
1921 1921
         
1922 1922
         $selected_country = $invoice->country ? $invoice->country : wpinv_default_billing_country();
1923 1923
 
1924
-        if ( $ip_country_code == 'UK' ) {
1924
+        if ($ip_country_code == 'UK') {
1925 1925
             $ip_country_code = 'GB';
1926 1926
         }
1927 1927
         
1928
-        if ( $selected_country == 'UK' ) {
1928
+        if ($selected_country == 'UK') {
1929 1929
             $selected_country = 'GB';
1930 1930
         }
1931 1931
         
1932
-        if ( $requires_vat && ( self::same_country_rule() == 'no' && wpinv_is_base_country( $selected_country ) || !self::allow_vat_rules() ) ) {
1932
+        if ($requires_vat && (self::same_country_rule() == 'no' && wpinv_is_base_country($selected_country) || !self::allow_vat_rules())) {
1933 1933
             $requires_vat = false;
1934 1934
         }
1935 1935
 
@@ -1937,52 +1937,52 @@  discard block
 block discarded – undo
1937 1937
         $display_validate_btn   = 'none';
1938 1938
         $display_reset_btn      = 'none';
1939 1939
         
1940
-        if ( !empty( $vat_number ) && $validated ) {
1941
-            $vat_vailidated_text    = wp_sprintf( __( '%s number validated', 'invoicing' ), $tax_label );
1940
+        if (!empty($vat_number) && $validated) {
1941
+            $vat_vailidated_text    = wp_sprintf(__('%s number validated', 'invoicing'), $tax_label);
1942 1942
             $vat_vailidated_class   = 'wpinv-vat-stat-1';
1943 1943
             $display_reset_btn      = 'block';
1944 1944
         } else {
1945
-            $vat_vailidated_text    = empty( $vat_number ) ? '' : wp_sprintf( __( '%s number not validated', 'invoicing' ), $tax_label );
1946
-            $vat_vailidated_class   = empty( $vat_number ) ? '' : 'wpinv-vat-stat-0';
1945
+            $vat_vailidated_text    = empty($vat_number) ? '' : wp_sprintf(__('%s number not validated', 'invoicing'), $tax_label);
1946
+            $vat_vailidated_class   = empty($vat_number) ? '' : 'wpinv-vat-stat-0';
1947 1947
             $display_validate_btn   = 'block';
1948 1948
         }
1949 1949
         
1950
-        $show_ip_country        = $is_digital && ( empty( $vat_number ) || !$requires_vat ) && $ip_country_code != $selected_country ? 'block' : 'none';
1950
+        $show_ip_country = $is_digital && (empty($vat_number) || !$requires_vat) && $ip_country_code != $selected_country ? 'block' : 'none';
1951 1951
         ?>
1952 1952
         <div id="wpi-vat-details" class="wpi-vat-details clearfix" style="display:<?php echo $display_vat_details; ?>">
1953 1953
             <div id="wpi_vat_info" class="clearfix panel panel-default">
1954
-                <div class="panel-heading"><h3 class="panel-title"><?php echo wp_sprintf( __( '%s Details', 'invoicing' ), $tax_label );?></h3></div>
1954
+                <div class="panel-heading"><h3 class="panel-title"><?php echo wp_sprintf(__('%s Details', 'invoicing'), $tax_label); ?></h3></div>
1955 1955
                 <div id="wpinv-fields-box" class="panel-body">
1956 1956
                     <p id="wpi_show_vat_note">
1957
-                        <?php echo wp_sprintf( __( 'Validate your registered %s number to exclude tax.', 'invoicing' ), $tax_label ); ?>
1957
+                        <?php echo wp_sprintf(__('Validate your registered %s number to exclude tax.', 'invoicing'), $tax_label); ?>
1958 1958
                     </p>
1959 1959
                     <div id="wpi_vat_fields" class="wpi_vat_info">
1960 1960
                         <p class="wpi-cart-field wpi-col2 wpi-colf">
1961
-                            <label for="wpinv_company" class="wpi-label"><?php _e( 'Company Name', 'invoicing' );?></label>
1961
+                            <label for="wpinv_company" class="wpi-label"><?php _e('Company Name', 'invoicing'); ?></label>
1962 1962
                             <?php
1963
-                            echo wpinv_html_text( array(
1963
+                            echo wpinv_html_text(array(
1964 1964
                                     'id'            => 'wpinv_company',
1965 1965
                                     'name'          => 'wpinv_company',
1966 1966
                                     'value'         => $company,
1967 1967
                                     'class'         => 'wpi-input form-control',
1968
-                                    'placeholder'   => __( 'Company name', 'invoicing' ),
1969
-                                ) );
1968
+                                    'placeholder'   => __('Company name', 'invoicing'),
1969
+                                ));
1970 1970
                             ?>
1971 1971
                         </p>
1972 1972
                         <p class="wpi-cart-field wpi-col2 wpi-coll wpi-cart-field-vat">
1973
-                            <label for="wpinv_vat_number" class="wpi-label"><?php echo wp_sprintf( __( '%s Number', 'invoicing' ), $tax_label );?></label>
1973
+                            <label for="wpinv_vat_number" class="wpi-label"><?php echo wp_sprintf(__('%s Number', 'invoicing'), $tax_label); ?></label>
1974 1974
                             <span id="wpinv_vat_number-wrap">
1975 1975
                                 <label for="wpinv_vat_number" class="wpinv-label"></label>
1976
-                                <input type="text" class="wpi-input form-control" placeholder="<?php echo esc_attr( wp_sprintf( __( '%s number', 'invoicing' ), $tax_label ) );?>" value="<?php esc_attr_e( $vat_number );?>" id="wpinv_vat_number" name="wpinv_vat_number">
1977
-                                <span class="wpinv-vat-stat <?php echo $vat_vailidated_class;?>"><i class="fa"></i>&nbsp;<font><?php echo $vat_vailidated_text;?></font></span>
1976
+                                <input type="text" class="wpi-input form-control" placeholder="<?php echo esc_attr(wp_sprintf(__('%s number', 'invoicing'), $tax_label)); ?>" value="<?php esc_attr_e($vat_number); ?>" id="wpinv_vat_number" name="wpinv_vat_number">
1977
+                                <span class="wpinv-vat-stat <?php echo $vat_vailidated_class; ?>"><i class="fa"></i>&nbsp;<font><?php echo $vat_vailidated_text; ?></font></span>
1978 1978
                             </span>
1979 1979
                         </p>
1980 1980
                         <p class="wpi-cart-field wpi-col wpi-colf wpi-cart-field-actions">
1981
-                            <button class="btn btn-success btn-sm wpinv-vat-validate" type="button" id="wpinv_vat_validate" style="display:<?php echo $display_validate_btn; ?>"><?php echo wp_sprintf( __("Validate %s Number", 'invoicing'), $tax_label ); ?></button>
1982
-                            <button class="btn btn-danger btn-sm wpinv-vat-reset" type="button" id="wpinv_vat_reset" style="display:<?php echo $display_reset_btn; ?>"><?php echo wp_sprintf( __("Reset %s", 'invoicing'), $tax_label ); ?></button>
1981
+                            <button class="btn btn-success btn-sm wpinv-vat-validate" type="button" id="wpinv_vat_validate" style="display:<?php echo $display_validate_btn; ?>"><?php echo wp_sprintf(__("Validate %s Number", 'invoicing'), $tax_label); ?></button>
1982
+                            <button class="btn btn-danger btn-sm wpinv-vat-reset" type="button" id="wpinv_vat_reset" style="display:<?php echo $display_reset_btn; ?>"><?php echo wp_sprintf(__("Reset %s", 'invoicing'), $tax_label); ?></button>
1983 1983
                             <span class="wpi-vat-box wpi-vat-box-info"><span id="text"></span></span>
1984 1984
                             <span class="wpi-vat-box wpi-vat-box-error"><span id="text"></span></span>
1985
-                            <input type="hidden" name="_wpi_nonce" value="<?php echo wp_create_nonce( 'vat_validation' ) ?>" />
1985
+                            <input type="hidden" name="_wpi_nonce" value="<?php echo wp_create_nonce('vat_validation') ?>" />
1986 1986
                         </p>
1987 1987
                     </div>
1988 1988
                 </div>
@@ -1996,32 +1996,32 @@  discard block
 block discarded – undo
1996 1996
                 </span>
1997 1997
             </div>
1998 1998
         </div>
1999
-        <?php if ( empty( $wpinv_options['hide_ip_address'] ) ) { 
2000
-            $ip_link = '<a title="' . esc_attr( __( 'View more details on map', 'invoicing' ) ) . '" target="_blank" href="' . esc_url( admin_url( 'admin-ajax.php?action=wpinv_ip_geolocation&ip=' . $ip_address ) ) . '" class="wpi-ip-address-link">' . $ip_address . '&nbsp;&nbsp;<i class="fa fa-external-link-square" aria-hidden="true"></i></a>';
1999
+        <?php if (empty($wpinv_options['hide_ip_address'])) { 
2000
+            $ip_link = '<a title="' . esc_attr(__('View more details on map', 'invoicing')) . '" target="_blank" href="' . esc_url(admin_url('admin-ajax.php?action=wpinv_ip_geolocation&ip=' . $ip_address)) . '" class="wpi-ip-address-link">' . $ip_address . '&nbsp;&nbsp;<i class="fa fa-external-link-square" aria-hidden="true"></i></a>';
2001 2001
         ?>
2002 2002
         <div class="wpi-ip-info clearfix panel panel-info">
2003 2003
             <div id="wpinv-fields-box" class="panel-body">
2004
-                <span><?php echo wp_sprintf( __( "Your IP address is: %s", 'invoicing' ), $ip_link ); ?></span>
2004
+                <span><?php echo wp_sprintf(__("Your IP address is: %s", 'invoicing'), $ip_link); ?></span>
2005 2005
             </div>
2006 2006
         </div>
2007 2007
         <?php }
2008 2008
     }
2009 2009
     
2010
-    public static function show_vat_notice( $invoice ) {
2011
-        if ( empty( $invoice ) ) {
2010
+    public static function show_vat_notice($invoice) {
2011
+        if (empty($invoice)) {
2012 2012
             return NULL;
2013 2013
         }
2014 2014
         
2015
-        $label      = wpinv_get_option( 'vat_invoice_notice_label' );
2016
-        $notice     = wpinv_get_option( 'vat_invoice_notice' );
2017
-        if ( $label || $notice ) {
2015
+        $label      = wpinv_get_option('vat_invoice_notice_label');
2016
+        $notice     = wpinv_get_option('vat_invoice_notice');
2017
+        if ($label || $notice) {
2018 2018
         ?>
2019 2019
         <div class="row wpinv-vat-notice">
2020 2020
             <div class="col-sm-12">
2021
-                <?php if ( $label ) { ?>
2022
-                <strong><?php _e( $label, 'invoicing' ); ?></strong>
2023
-                <?php } if ( $notice ) { ?>
2024
-                <?php echo wpautop( wptexturize( __( $notice, 'invoicing' ) ) ) ?>
2021
+                <?php if ($label) { ?>
2022
+                <strong><?php _e($label, 'invoicing'); ?></strong>
2023
+                <?php } if ($notice) { ?>
2024
+                <?php echo wpautop(wptexturize(__($notice, 'invoicing'))) ?>
2025 2025
                 <?php } ?>
2026 2026
             </div>
2027 2027
         </div>
Please login to merge, or discard this patch.
vendor/ayecode/wp-super-duper/wp-super-duper.php 1 patch
Spacing   +366 added lines, -366 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
6
-if ( ! class_exists( 'WP_Super_Duper' ) ) {
6
+if (!class_exists('WP_Super_Duper')) {
7 7
 
8 8
 
9 9
 	/**
@@ -39,27 +39,27 @@  discard block
 block discarded – undo
39 39
 		/**
40 40
 		 * Take the array options and use them to build.
41 41
 		 */
42
-		public function __construct( $options ) {
42
+		public function __construct($options) {
43 43
 			global $sd_widgets;
44 44
 
45
-			$sd_widgets[ $options['base_id'] ] = array(
45
+			$sd_widgets[$options['base_id']] = array(
46 46
 				'name'       => $options['name'],
47 47
 				'class_name' => $options['class_name']
48 48
 			);
49
-			$this->base_id                     = $options['base_id'];
49
+			$this->base_id = $options['base_id'];
50 50
 			// lets filter the options before we do anything
51
-			$options       = apply_filters( "wp_super_duper_options", $options );
52
-			$options       = apply_filters( "wp_super_duper_options_{$this->base_id}", $options );
53
-			$options       = $this->add_name_from_key( $options );
51
+			$options       = apply_filters("wp_super_duper_options", $options);
52
+			$options       = apply_filters("wp_super_duper_options_{$this->base_id}", $options);
53
+			$options       = $this->add_name_from_key($options);
54 54
 			$this->options = $options;
55 55
 
56 56
 			$this->base_id   = $options['base_id'];
57
-			$this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array();
57
+			$this->arguments = isset($options['arguments']) ? $options['arguments'] : array();
58 58
 
59 59
 			// init parent
60
-			parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] );
60
+			parent::__construct($options['base_id'], $options['name'], $options['widget_ops']);
61 61
 
62
-			if ( isset( $options['class_name'] ) ) {
62
+			if (isset($options['class_name'])) {
63 63
 				// register widget
64 64
 				$this->class_name = $options['class_name'];
65 65
 
@@ -67,47 +67,47 @@  discard block
 block discarded – undo
67 67
 				$this->register_shortcode();
68 68
 
69 69
 				// register block
70
-				add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) );
70
+				add_action('admin_enqueue_scripts', array($this, 'register_block'));
71 71
 			}
72 72
 
73 73
 			// add the CSS and JS we need ONCE
74 74
 			global $sd_widget_scripts;
75 75
 
76
-			if ( ! $sd_widget_scripts ) {
77
-				wp_add_inline_script( 'admin-widgets', $this->widget_js() );
78
-				wp_add_inline_script( 'customize-controls', $this->widget_js() );
79
-				wp_add_inline_style( 'widgets', $this->widget_css() );
76
+			if (!$sd_widget_scripts) {
77
+				wp_add_inline_script('admin-widgets', $this->widget_js());
78
+				wp_add_inline_script('customize-controls', $this->widget_js());
79
+				wp_add_inline_style('widgets', $this->widget_css());
80 80
 
81 81
 				$sd_widget_scripts = true;
82 82
 
83 83
 				// add shortcode insert button once
84
-				add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) );
85
-				if ( $this->is_preview() ) {
86
-					add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) );
84
+				add_action('media_buttons', array($this, 'shortcode_insert_button'));
85
+				if ($this->is_preview()) {
86
+					add_action('wp_footer', array($this, 'shortcode_insert_button_script'));
87 87
 					// this makes the insert button work for elementor
88
-					add_action( 'elementor/editor/after_enqueue_scripts', array(
88
+					add_action('elementor/editor/after_enqueue_scripts', array(
89 89
 						$this,
90 90
 						'shortcode_insert_button_script'
91
-					) ); // for elementor
91
+					)); // for elementor
92 92
 				}
93 93
 				// this makes the insert button work for cornerstone
94
-				add_action('wp_print_footer_scripts',array( __CLASS__, 'maybe_cornerstone_builder' ));
94
+				add_action('wp_print_footer_scripts', array(__CLASS__, 'maybe_cornerstone_builder'));
95 95
 
96
-				add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) );
97
-				add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) );
96
+				add_action('wp_ajax_super_duper_get_widget_settings', array(__CLASS__, 'get_widget_settings'));
97
+				add_action('wp_ajax_super_duper_get_picker', array(__CLASS__, 'get_picker'));
98 98
 
99 99
 				// add generator text to admin head
100
-				add_action( 'admin_head', array( $this, 'generator' ) );
100
+				add_action('admin_head', array($this, 'generator'));
101 101
 			}
102 102
 
103
-			do_action( 'wp_super_duper_widget_init', $options, $this );
103
+			do_action('wp_super_duper_widget_init', $options, $this);
104 104
 		}
105 105
 
106 106
 		/**
107 107
 		 * Maybe insert the shortcode inserter button in the footer if we are in the cornerstone builder
108 108
 		 */
109
-		public static function maybe_cornerstone_builder(){
110
-			if(did_action('cornerstone_before_boot_app')){
109
+		public static function maybe_cornerstone_builder() {
110
+			if (did_action('cornerstone_before_boot_app')) {
111 111
 				self::shortcode_insert_button_script();
112 112
 			}
113 113
 		}
@@ -119,12 +119,12 @@  discard block
 block discarded – undo
119 119
 		 *
120 120
 		 * @return string
121 121
 		 */
122
-		public static function get_picker( $editor_id = '' ) {
122
+		public static function get_picker($editor_id = '') {
123 123
 
124 124
 			ob_start();
125
-			if ( isset( $_POST['editor_id'] ) ) {
126
-				$editor_id = esc_attr( $_POST['editor_id'] );
127
-			} elseif ( isset( $_REQUEST['et_fb'] ) ) {
125
+			if (isset($_POST['editor_id'])) {
126
+				$editor_id = esc_attr($_POST['editor_id']);
127
+			} elseif (isset($_REQUEST['et_fb'])) {
128 128
 				$editor_id = 'main_content_content_vb_tiny_mce';
129 129
 			}
130 130
 
@@ -133,12 +133,12 @@  discard block
 block discarded – undo
133 133
 
134 134
 			<div class="sd-shortcode-left-wrap">
135 135
 				<?php
136
-				asort( $sd_widgets );
137
-				if ( ! empty( $sd_widgets ) ) {
136
+				asort($sd_widgets);
137
+				if (!empty($sd_widgets)) {
138 138
 					echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">';
139
-					echo "<option>" . __( 'Select shortcode' ) . "</option>";
140
-					foreach ( $sd_widgets as $shortcode => $class ) {
141
-						echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>";
139
+					echo "<option>" . __('Select shortcode') . "</option>";
140
+					foreach ($sd_widgets as $shortcode => $class) {
141
+						echo "<option value='" . esc_attr($shortcode) . "'>" . esc_attr($shortcode) . " (" . esc_attr($class['name']) . ")</option>";
142 142
 					}
143 143
 					echo "</select>";
144 144
 
@@ -151,37 +151,37 @@  discard block
 block discarded – undo
151 151
 			<div class="sd-shortcode-right-wrap">
152 152
 				<textarea id='sd-shortcode-output' disabled></textarea>
153 153
 				<div id='sd-shortcode-output-actions'>
154
-					<?php if ( $editor_id != '' ) { ?>
154
+					<?php if ($editor_id != '') { ?>
155 155
 						<button class="button sd-insert-shortcode-button"
156
-						        onclick="sd_insert_shortcode(<?php if ( ! empty( $editor_id ) ) {
156
+						        onclick="sd_insert_shortcode(<?php if (!empty($editor_id)) {
157 157
 							        echo "'" . $editor_id . "'";
158
-						        } ?>)"><?php _e( 'Insert shortcode' ); ?></button>
158
+						        } ?>)"><?php _e('Insert shortcode'); ?></button>
159 159
 					<?php } ?>
160 160
 					<button class="button"
161
-					        onclick="sd_copy_to_clipboard()"><?php _e( 'Copy shortcode' ); ?></button>
161
+					        onclick="sd_copy_to_clipboard()"><?php _e('Copy shortcode'); ?></button>
162 162
 				</div>
163 163
 			</div>
164 164
 			<?php
165 165
 
166 166
 			$html = ob_get_clean();
167 167
 
168
-			if ( wp_doing_ajax() ) {
168
+			if (wp_doing_ajax()) {
169 169
 				echo $html;
170 170
 				$should_die = true;
171 171
 
172 172
 				// some builder get the editor via ajax so we should not die on those ocasions
173 173
 				$dont_die = array(
174
-					'parent_tag',// WP Bakery
174
+					'parent_tag', // WP Bakery
175 175
 					'avia_request' // enfold
176 176
 				);
177 177
 
178
-				foreach ( $dont_die as $request ) {
179
-					if ( isset( $_REQUEST[ $request ] ) ) {
178
+				foreach ($dont_die as $request) {
179
+					if (isset($_REQUEST[$request])) {
180 180
 						$should_die = false;
181 181
 					}
182 182
 				}
183 183
 
184
-				if ( $should_die ) {
184
+				if ($should_die) {
185 185
 					wp_die();
186 186
 				}
187 187
 
@@ -208,16 +208,16 @@  discard block
 block discarded – undo
208 208
 		public static function get_widget_settings() {
209 209
 			global $sd_widgets;
210 210
 
211
-			$shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : '';
212
-			if ( ! $shortcode ) {
211
+			$shortcode = isset($_REQUEST['shortcode']) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes($_REQUEST['shortcode']) : '';
212
+			if (!$shortcode) {
213 213
 				wp_die();
214 214
 			}
215
-			$widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : '';
216
-			if ( ! $widget_args ) {
215
+			$widget_args = isset($sd_widgets[$shortcode]) ? $sd_widgets[$shortcode] : '';
216
+			if (!$widget_args) {
217 217
 				wp_die();
218 218
 			}
219
-			$class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : '';
220
-			if ( ! $class_name ) {
219
+			$class_name = isset($widget_args['class_name']) && $widget_args['class_name'] ? $widget_args['class_name'] : '';
220
+			if (!$class_name) {
221 221
 				wp_die();
222 222
 			}
223 223
 
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 			$widget = new $class_name;
226 226
 
227 227
 			ob_start();
228
-			$widget->form( array() );
228
+			$widget->form(array());
229 229
 			$form = ob_get_clean();
230 230
 			echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>";
231 231
 			echo "<style>" . $widget->widget_css() . "</style>";
@@ -243,9 +243,9 @@  discard block
 block discarded – undo
243 243
 		 * @param string $editor_id Optional. Shortcode editor id. Default null.
244 244
 		 * @param string $insert_shortcode_function Optional. Insert shotcode function. Default null.
245 245
 		 */
246
-		public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) {
246
+		public static function shortcode_insert_button($editor_id = '', $insert_shortcode_function = '') {
247 247
 			global $sd_widgets, $shortcode_insert_button_once;
248
-			if ( $shortcode_insert_button_once ) {
248
+			if ($shortcode_insert_button_once) {
249 249
 				return;
250 250
 			}
251 251
 			add_thickbox();
@@ -255,18 +255,18 @@  discard block
 block discarded – undo
255 255
 			 * Cornerstone makes us play dirty tricks :/
256 256
 			 * All media_buttons are removed via JS unless they are two specific id's so we wrap our content in this ID so it is not removed.
257 257
 			 */
258
-			if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
258
+			if (function_exists('cornerstone_plugin_init') && !is_admin()) {
259 259
 				echo '<span id="insert-media-button">';
260 260
 			}
261 261
 
262
-			echo self::shortcode_button( 'this', 'true' );
262
+			echo self::shortcode_button('this', 'true');
263 263
 
264 264
 			// see opening note
265
-			if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
265
+			if (function_exists('cornerstone_plugin_init') && !is_admin()) {
266 266
 				echo '</span>'; // end #insert-media-button
267 267
 			}
268 268
 
269
-			self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function );
269
+			self::shortcode_insert_button_script($editor_id, $insert_shortcode_function);
270 270
 			$shortcode_insert_button_once = true;
271 271
 		}
272 272
 
@@ -278,12 +278,12 @@  discard block
 block discarded – undo
278 278
 		 *
279 279
 		 * @return mixed
280 280
 		 */
281
-		public static function shortcode_button( $id = '', $search_for_id = '' ) {
281
+		public static function shortcode_button($id = '', $search_for_id = '') {
282 282
 			ob_start();
283 283
 			?>
284 284
 			<span class="sd-lable-shortcode-inserter">
285 285
 				<a onclick="sd_ajax_get_picker(<?php echo $id;
286
-				if ( $search_for_id ) {
286
+				if ($search_for_id) {
287 287
 					echo "," . $search_for_id;
288 288
 				} ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed"
289 289
 				   class="thickbox button super-duper-content-open" title="Add Shortcode">
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 			$html = ob_get_clean();
300 300
 
301 301
 			// remove line breaks so we can use it in js
302
-			return preg_replace( "/\r|\n/", "", trim( $html ) );
302
+			return preg_replace("/\r|\n/", "", trim($html));
303 303
 		}
304 304
 
305 305
 		/**
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 						jQuery($this).data('sd-widget-enabled', true);
358 358
 					}
359 359
 
360
-					var $button = '<button title="<?php _e( 'Advanced Settings' );?>" class="button button-primary right sd-advanced-button" onclick="sd_so_toggle_advanced(this);return false;"><i class="fas fa-sliders-h" aria-hidden="true"></i></button>';
360
+					var $button = '<button title="<?php _e('Advanced Settings'); ?>" class="button button-primary right sd-advanced-button" onclick="sd_so_toggle_advanced(this);return false;"><i class="fas fa-sliders-h" aria-hidden="true"></i></button>';
361 361
 					var form = jQuery($this).parents('' + $selector + '');
362 362
 
363 363
 					if (jQuery($this).val() == '1' && jQuery(form).find('.sd-advanced-button').length == 0) {
@@ -394,10 +394,10 @@  discard block
 block discarded – undo
394 394
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
395 395
 			 */
396 396
 
397
-			return str_replace( array(
397
+			return str_replace(array(
398 398
 				'<script>',
399 399
 				'</script>'
400
-			), '', $output );
400
+			), '', $output);
401 401
 		}
402 402
 
403 403
 		/**
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
 		 * @param string $editor_id
409 409
 		 * @param string $insert_shortcode_function
410 410
 		 */
411
-		public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) {
411
+		public static function shortcode_insert_button_script($editor_id = '', $insert_shortcode_function = '') {
412 412
 			?>
413 413
 			<style>
414 414
 				.sd-shortcode-left-wrap {
@@ -528,15 +528,15 @@  discard block
 block discarded – undo
528 528
 				}
529 529
 			</style>
530 530
 			<?php
531
-			if ( class_exists( 'SiteOrigin_Panels' ) ) {
531
+			if (class_exists('SiteOrigin_Panels')) {
532 532
 				echo "<script>" . self::siteorigin_js() . "</script>";
533 533
 			}
534 534
 			?>
535 535
 			<script>
536 536
 				<?php
537
-				if(! empty( $insert_shortcode_function )){
537
+				if (!empty($insert_shortcode_function)) {
538 538
 					echo $insert_shortcode_function;
539
-				}else{
539
+				} else {
540 540
 
541 541
 				/**
542 542
 				 * Function for super duper insert shortcode.
@@ -551,9 +551,9 @@  discard block
 block discarded – undo
551 551
 						if (!$editor_id) {
552 552
 
553 553
 							<?php
554
-							if ( isset( $_REQUEST['et_fb'] ) ) {
554
+							if (isset($_REQUEST['et_fb'])) {
555 555
 								echo '$editor_id = "#main_content_content_vb_tiny_mce";';
556
-							} elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) {
556
+							} elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor') {
557 557
 								echo '$editor_id = "#elementor-controls .wp-editor-container textarea";';
558 558
 							} else {
559 559
 								echo '$editor_id = "#wp-content-editor-container textarea";';
@@ -633,11 +633,11 @@  discard block
 block discarded – undo
633 633
 							'shortcode': $short_code,
634 634
 							'attributes': 123,
635 635
 							'post_id': 321,
636
-							'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>'
636
+							'_ajax_nonce': '<?php echo wp_create_nonce('super_duper_output_shortcode'); ?>'
637 637
 						};
638 638
 
639 639
 						if (typeof ajaxurl === 'undefined') {
640
-							var ajaxurl = "<?php echo admin_url( 'admin-ajax.php' );?>";
640
+							var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
641 641
 						}
642 642
 
643 643
 						jQuery.post(ajaxurl, data, function (response) {
@@ -835,11 +835,11 @@  discard block
 block discarded – undo
835 835
 					var data = {
836 836
 						'action': 'super_duper_get_picker',
837 837
 						'editor_id': $id,
838
-						'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_picker' );?>'
838
+						'_ajax_nonce': '<?php echo wp_create_nonce('super_duper_picker'); ?>'
839 839
 					};
840 840
 
841 841
 					if (!ajaxurl) {
842
-						var ajaxurl = "<?php echo admin_url( 'admin-ajax.php' ); ?>";
842
+						var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
843 843
 					}
844 844
 
845 845
 					jQuery.post(ajaxurl, data, function (response) {
@@ -860,9 +860,9 @@  discard block
 block discarded – undo
860 860
 				 */
861 861
 				function sd_shortcode_button($id) {
862 862
 					if ($id) {
863
-						return '<?php echo self::shortcode_button( "\\''+\$id+'\\'" );?>';
863
+						return '<?php echo self::shortcode_button("\\''+\$id+'\\'"); ?>';
864 864
 					} else {
865
-						return '<?php echo self::shortcode_button();?>';
865
+						return '<?php echo self::shortcode_button(); ?>';
866 866
 					}
867 867
 				}
868 868
 
@@ -904,10 +904,10 @@  discard block
 block discarded – undo
904 904
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
905 905
 			 */
906 906
 
907
-			return str_replace( array(
907
+			return str_replace(array(
908 908
 				'<style>',
909 909
 				'</style>'
910
-			), '', $output );
910
+			), '', $output);
911 911
 		}
912 912
 
913 913
 		/**
@@ -977,7 +977,7 @@  discard block
 block discarded – undo
977 977
 						jQuery($this).data('sd-widget-enabled', true);
978 978
 					}
979 979
 
980
-					var $button = '<button title="<?php _e( 'Advanced Settings' );?>" class="button button-primary right sd-advanced-button" onclick="sd_toggle_advanced(this);return false;"><span class="dashicons dashicons-admin-settings" style="width: 28px;font-size: 28px;"></span></button>';
980
+					var $button = '<button title="<?php _e('Advanced Settings'); ?>" class="button button-primary right sd-advanced-button" onclick="sd_toggle_advanced(this);return false;"><span class="dashicons dashicons-admin-settings" style="width: 28px;font-size: 28px;"></span></button>';
981 981
 					var form = jQuery($this).parents('' + $selector + '');
982 982
 
983 983
 					if (jQuery($this).val() == '1' && jQuery(form).find('.sd-advanced-button').length == 0) {
@@ -1069,7 +1069,7 @@  discard block
 block discarded – undo
1069 1069
 					});
1070 1070
 
1071 1071
 				}
1072
-				<?php do_action( 'wp_super_duper_widget_js', $this ); ?>
1072
+				<?php do_action('wp_super_duper_widget_js', $this); ?>
1073 1073
 			</script>
1074 1074
 			<?php
1075 1075
 			$output = ob_get_clean();
@@ -1078,10 +1078,10 @@  discard block
 block discarded – undo
1078 1078
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1079 1079
 			 */
1080 1080
 
1081
-			return str_replace( array(
1081
+			return str_replace(array(
1082 1082
 				'<script>',
1083 1083
 				'</script>'
1084
-			), '', $output );
1084
+			), '', $output);
1085 1085
 		}
1086 1086
 
1087 1087
 
@@ -1092,14 +1092,14 @@  discard block
 block discarded – undo
1092 1092
 		 *
1093 1093
 		 * @return mixed
1094 1094
 		 */
1095
-		private function add_name_from_key( $options, $arguments = false ) {
1096
-			if ( ! empty( $options['arguments'] ) ) {
1097
-				foreach ( $options['arguments'] as $key => $val ) {
1098
-					$options['arguments'][ $key ]['name'] = $key;
1095
+		private function add_name_from_key($options, $arguments = false) {
1096
+			if (!empty($options['arguments'])) {
1097
+				foreach ($options['arguments'] as $key => $val) {
1098
+					$options['arguments'][$key]['name'] = $key;
1099 1099
 				}
1100
-			} elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) {
1101
-				foreach ( $options as $key => $val ) {
1102
-					$options[ $key ]['name'] = $key;
1100
+			} elseif ($arguments && is_array($options) && !empty($options)) {
1101
+				foreach ($options as $key => $val) {
1102
+					$options[$key]['name'] = $key;
1103 1103
 				}
1104 1104
 			}
1105 1105
 
@@ -1112,8 +1112,8 @@  discard block
 block discarded – undo
1112 1112
 		 * @since 1.0.0
1113 1113
 		 */
1114 1114
 		public function register_shortcode() {
1115
-			add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) );
1116
-			add_action( 'wp_ajax_super_duper_output_shortcode', array( __CLASS__, 'render_shortcode' ) );
1115
+			add_shortcode($this->base_id, array($this, 'shortcode_output'));
1116
+			add_action('wp_ajax_super_duper_output_shortcode', array(__CLASS__, 'render_shortcode'));
1117 1117
 		}
1118 1118
 
1119 1119
 		/**
@@ -1123,33 +1123,33 @@  discard block
 block discarded – undo
1123 1123
 		 */
1124 1124
 		public static function render_shortcode() {
1125 1125
 
1126
-			check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true );
1127
-			if ( ! current_user_can( 'manage_options' ) ) {
1126
+			check_ajax_referer('super_duper_output_shortcode', '_ajax_nonce', true);
1127
+			if (!current_user_can('manage_options')) {
1128 1128
 				wp_die();
1129 1129
 			}
1130 1130
 
1131 1131
 			// we might need the $post value here so lets set it.
1132
-			if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) {
1133
-				$post_obj = get_post( absint( $_POST['post_id'] ) );
1134
-				if ( ! empty( $post_obj ) && empty( $post ) ) {
1132
+			if (isset($_POST['post_id']) && $_POST['post_id']) {
1133
+				$post_obj = get_post(absint($_POST['post_id']));
1134
+				if (!empty($post_obj) && empty($post)) {
1135 1135
 					global $post;
1136 1136
 					$post = $post_obj;
1137 1137
 				}
1138 1138
 			}
1139 1139
 
1140
-			if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) {
1141
-				$shortcode_name   = sanitize_title_with_dashes( $_POST['shortcode'] );
1142
-				$attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array();
1140
+			if (isset($_POST['shortcode']) && $_POST['shortcode']) {
1141
+				$shortcode_name   = sanitize_title_with_dashes($_POST['shortcode']);
1142
+				$attributes_array = isset($_POST['attributes']) && $_POST['attributes'] ? $_POST['attributes'] : array();
1143 1143
 				$attributes       = '';
1144
-				if ( ! empty( $attributes_array ) ) {
1145
-					foreach ( $attributes_array as $key => $value ) {
1146
-						$attributes .= " " . sanitize_title_with_dashes( $key ) . "='" . wp_slash( $value ) . "' ";
1144
+				if (!empty($attributes_array)) {
1145
+					foreach ($attributes_array as $key => $value) {
1146
+						$attributes .= " " . sanitize_title_with_dashes($key) . "='" . wp_slash($value) . "' ";
1147 1147
 					}
1148 1148
 				}
1149 1149
 
1150 1150
 				$shortcode = "[" . $shortcode_name . " " . $attributes . "]";
1151 1151
 
1152
-				echo do_shortcode( $shortcode );
1152
+				echo do_shortcode($shortcode);
1153 1153
 
1154 1154
 			}
1155 1155
 			wp_die();
@@ -1163,37 +1163,37 @@  discard block
 block discarded – undo
1163 1163
 		 *
1164 1164
 		 * @return string
1165 1165
 		 */
1166
-		public function shortcode_output( $args = array(), $content = '' ) {
1167
-			$args = self::argument_values( $args );
1166
+		public function shortcode_output($args = array(), $content = '') {
1167
+			$args = self::argument_values($args);
1168 1168
 
1169 1169
 			// add extra argument so we know its a output to gutenberg
1170 1170
 			//$args
1171
-			$args = $this->string_to_bool( $args );
1171
+			$args = $this->string_to_bool($args);
1172 1172
 
1173 1173
 
1174
-			$calss = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : '';
1174
+			$calss = isset($this->options['widget_ops']['classname']) ? esc_attr($this->options['widget_ops']['classname']) : '';
1175 1175
 
1176
-			$calss = apply_filters( 'wp_super_duper_div_classname', $calss, $args, $this );
1177
-			$calss = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $calss, $args, $this );
1176
+			$calss = apply_filters('wp_super_duper_div_classname', $calss, $args, $this);
1177
+			$calss = apply_filters('wp_super_duper_div_classname_' . $this->base_id, $calss, $args, $this);
1178 1178
 
1179
-			$attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
1180
-			$attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
1179
+			$attrs = apply_filters('wp_super_duper_div_attrs', '', $args, $this);
1180
+			$attrs = apply_filters('wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this);
1181 1181
 
1182 1182
 			$shortcode_args = array();
1183 1183
 			$output         = '';
1184
-			$no_wrap        = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
1185
-			$main_content   = $this->output( $args, $shortcode_args, $content );
1186
-			if ( $main_content && ! $no_wrap ) {
1184
+			$no_wrap        = isset($this->options['no_wrap']) && $this->options['no_wrap'] ? true : false;
1185
+			$main_content   = $this->output($args, $shortcode_args, $content);
1186
+			if ($main_content && !$no_wrap) {
1187 1187
 				// wrap the shortcode in a dive with the same class as the widget
1188 1188
 				$output .= '<div class="' . $calss . '" ' . $attrs . '>';
1189
-				if ( ! empty( $args['title'] ) ) {
1189
+				if (!empty($args['title'])) {
1190 1190
 					// if its a shortcode and there is a title try to grab the title wrappers
1191
-					$shortcode_args = array( 'before_title' => '', 'after_title' => '' );
1192
-					if ( empty( $instance ) ) {
1191
+					$shortcode_args = array('before_title' => '', 'after_title' => '');
1192
+					if (empty($instance)) {
1193 1193
 						global $wp_registered_sidebars;
1194
-						if ( ! empty( $wp_registered_sidebars ) ) {
1195
-							foreach ( $wp_registered_sidebars as $sidebar ) {
1196
-								if ( ! empty( $sidebar['before_title'] ) ) {
1194
+						if (!empty($wp_registered_sidebars)) {
1195
+							foreach ($wp_registered_sidebars as $sidebar) {
1196
+								if (!empty($sidebar['before_title'])) {
1197 1197
 									$shortcode_args['before_title'] = $sidebar['before_title'];
1198 1198
 									$shortcode_args['after_title']  = $sidebar['after_title'];
1199 1199
 									break;
@@ -1201,17 +1201,17 @@  discard block
 block discarded – undo
1201 1201
 							}
1202 1202
 						}
1203 1203
 					}
1204
-					$output .= $this->output_title( $shortcode_args, $args );
1204
+					$output .= $this->output_title($shortcode_args, $args);
1205 1205
 				}
1206 1206
 				$output .= $main_content;
1207 1207
 				$output .= '</div>';
1208
-			} elseif ( $main_content && $no_wrap ) {
1208
+			} elseif ($main_content && $no_wrap) {
1209 1209
 				$output .= $main_content;
1210 1210
 			}
1211 1211
 
1212 1212
 			// if preview show a placeholder if empty
1213
-			if ( $this->is_preview() && $output == '' ) {
1214
-				$output = $this->preview_placeholder_text( "[{" . $this->base_id . "}]" );
1213
+			if ($this->is_preview() && $output == '') {
1214
+				$output = $this->preview_placeholder_text("[{" . $this->base_id . "}]");
1215 1215
 			}
1216 1216
 
1217 1217
 			return $output;
@@ -1224,8 +1224,8 @@  discard block
 block discarded – undo
1224 1224
 		 *
1225 1225
 		 * @return string
1226 1226
 		 */
1227
-		public function preview_placeholder_text( $name = '' ) {
1228
-			return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf( __( 'Placeholder for: %s' ), $name ) . "</div>";
1227
+		public function preview_placeholder_text($name = '') {
1228
+			return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf(__('Placeholder for: %s'), $name) . "</div>";
1229 1229
 		}
1230 1230
 
1231 1231
 		/**
@@ -1235,13 +1235,13 @@  discard block
 block discarded – undo
1235 1235
 		 *
1236 1236
 		 * @return mixed
1237 1237
 		 */
1238
-		public function string_to_bool( $options ) {
1238
+		public function string_to_bool($options) {
1239 1239
 			// convert bool strings to booleans
1240
-			foreach ( $options as $key => $val ) {
1241
-				if ( $val == 'false' ) {
1242
-					$options[ $key ] = false;
1243
-				} elseif ( $val == 'true' ) {
1244
-					$options[ $key ] = true;
1240
+			foreach ($options as $key => $val) {
1241
+				if ($val == 'false') {
1242
+					$options[$key] = false;
1243
+				} elseif ($val == 'true') {
1244
+					$options[$key] = true;
1245 1245
 				}
1246 1246
 			}
1247 1247
 
@@ -1257,27 +1257,27 @@  discard block
 block discarded – undo
1257 1257
 		 *
1258 1258
 		 * @return array
1259 1259
 		 */
1260
-		public function argument_values( $instance ) {
1260
+		public function argument_values($instance) {
1261 1261
 			$argument_values = array();
1262 1262
 
1263 1263
 			// set widget instance
1264 1264
 			$this->instance = $instance;
1265 1265
 
1266
-			if ( empty( $this->arguments ) ) {
1266
+			if (empty($this->arguments)) {
1267 1267
 				$this->arguments = $this->get_arguments();
1268 1268
 			}
1269 1269
 
1270
-			if ( ! empty( $this->arguments ) ) {
1271
-				foreach ( $this->arguments as $key => $args ) {
1270
+			if (!empty($this->arguments)) {
1271
+				foreach ($this->arguments as $key => $args) {
1272 1272
 					// set the input name from the key
1273 1273
 					$args['name'] = $key;
1274 1274
 					//
1275
-					$argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : '';
1276
-					if($args['type']=='checkbox' && $argument_values[ $key ] == ''){
1275
+					$argument_values[$key] = isset($instance[$key]) ? $instance[$key] : '';
1276
+					if ($args['type'] == 'checkbox' && $argument_values[$key] == '') {
1277 1277
 						// don't set default for an empty checkbox
1278 1278
 					}
1279
-					elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) {
1280
-						$argument_values[ $key ] = $args['default'];
1279
+					elseif ($argument_values[$key] == '' && isset($args['default'])) {
1280
+						$argument_values[$key] = $args['default'];
1281 1281
 					}
1282 1282
 				}
1283 1283
 			}
@@ -1304,12 +1304,12 @@  discard block
 block discarded – undo
1304 1304
 		 * @return array Get arguments.
1305 1305
 		 */
1306 1306
 		public function get_arguments() {
1307
-			if ( empty( $this->arguments ) ) {
1307
+			if (empty($this->arguments)) {
1308 1308
 				$this->arguments = $this->set_arguments();
1309 1309
 			}
1310 1310
 
1311
-			$this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance );
1312
-			$this->arguments = $this->add_name_from_key( $this->arguments, true );
1311
+			$this->arguments = apply_filters('wp_super_duper_arguments', $this->arguments, $this->options, $this->instance);
1312
+			$this->arguments = $this->add_name_from_key($this->arguments, true);
1313 1313
 
1314 1314
 			return $this->arguments;
1315 1315
 		}
@@ -1321,7 +1321,7 @@  discard block
 block discarded – undo
1321 1321
 		 * @param array $widget_args
1322 1322
 		 * @param string $content
1323 1323
 		 */
1324
-		public function output( $args = array(), $widget_args = array(), $content = '' ) {
1324
+		public function output($args = array(), $widget_args = array(), $content = '') {
1325 1325
 
1326 1326
 		}
1327 1327
 
@@ -1329,10 +1329,10 @@  discard block
 block discarded – undo
1329 1329
 		 * Add the dynamic block code inline when the wp-block in enqueued.
1330 1330
 		 */
1331 1331
 		public function register_block() {
1332
-			wp_add_inline_script( 'wp-blocks', $this->block() );
1333
-			if ( class_exists( 'SiteOrigin_Panels' ) ) {
1332
+			wp_add_inline_script('wp-blocks', $this->block());
1333
+			if (class_exists('SiteOrigin_Panels')) {
1334 1334
 
1335
-				wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() );
1335
+				wp_add_inline_script('wp-blocks', $this->siteorigin_js());
1336 1336
 
1337 1337
 			}
1338 1338
 		}
@@ -1347,13 +1347,13 @@  discard block
 block discarded – undo
1347 1347
 			$show      = false;
1348 1348
 			$arguments = $this->arguments;
1349 1349
 
1350
-			if ( empty( $arguments ) ) {
1350
+			if (empty($arguments)) {
1351 1351
 				$arguments = $this->get_arguments();
1352 1352
 			}
1353 1353
 
1354
-			if ( ! empty( $arguments ) ) {
1355
-				foreach ( $arguments as $argument ) {
1356
-					if ( isset( $argument['advanced'] ) && $argument['advanced'] ) {
1354
+			if (!empty($arguments)) {
1355
+				foreach ($arguments as $argument) {
1356
+					if (isset($argument['advanced']) && $argument['advanced']) {
1357 1357
 						$show = true;
1358 1358
 					}
1359 1359
 				}
@@ -1405,12 +1405,12 @@  discard block
 block discarded – undo
1405 1405
 					 * @return {?WPBlock}          The block, if it has been successfully
1406 1406
 					 *                             registered; otherwise `undefined`.
1407 1407
 					 */
1408
-					registerBlockType('<?php echo str_replace( "_", "-", sanitize_title_with_dashes( $this->options['textdomain'] ) . '/' . sanitize_title_with_dashes( $this->options['class_name'] ) );  ?>', { // Block name. Block names must be string that contains a namespace prefix. Example: my-plugin/my-custom-block.
1409
-						title: '<?php echo $this->options['name'];?>', // Block title.
1410
-						description: '<?php echo esc_attr( $this->options['widget_ops']['description'] )?>', // Block title.
1411
-						icon: '<?php echo isset( $this->options['block-icon'] ) ? esc_attr( $this->options['block-icon'] ) : 'shield-alt';?>', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/.
1412
-						category: '<?php echo isset( $this->options['block-category'] ) ? esc_attr( $this->options['block-category'] ) : 'common';?>', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed.
1413
-						<?php if ( isset( $this->options['block-keywords'] ) ) {
1408
+					registerBlockType('<?php echo str_replace("_", "-", sanitize_title_with_dashes($this->options['textdomain']) . '/' . sanitize_title_with_dashes($this->options['class_name'])); ?>', { // Block name. Block names must be string that contains a namespace prefix. Example: my-plugin/my-custom-block.
1409
+						title: '<?php echo $this->options['name']; ?>', // Block title.
1410
+						description: '<?php echo esc_attr($this->options['widget_ops']['description'])?>', // Block title.
1411
+						icon: '<?php echo isset($this->options['block-icon']) ? esc_attr($this->options['block-icon']) : 'shield-alt'; ?>', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/.
1412
+						category: '<?php echo isset($this->options['block-category']) ? esc_attr($this->options['block-category']) : 'common'; ?>', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed.
1413
+						<?php if (isset($this->options['block-keywords'])) {
1414 1414
 						echo "keywords : " . $this->options['block-keywords'] . ",";
1415 1415
 					}?>
1416 1416
 
@@ -1420,10 +1420,10 @@  discard block
 block discarded – undo
1420 1420
 
1421 1421
 						$show_alignment = false;
1422 1422
 
1423
-						if ( ! empty( $this->arguments ) ) {
1423
+						if (!empty($this->arguments)) {
1424 1424
 							echo "attributes : {";
1425 1425
 
1426
-							if ( $show_advanced ) {
1426
+							if ($show_advanced) {
1427 1427
 								echo "show_advanced: {";
1428 1428
 								echo "	type: 'boolean',";
1429 1429
 								echo "  default: false,";
@@ -1431,42 +1431,42 @@  discard block
 block discarded – undo
1431 1431
 							}
1432 1432
 
1433 1433
 							// block wrap element
1434
-							if ( isset( $this->options['block-wrap'] ) ) { //@todo we should validate this?
1434
+							if (isset($this->options['block-wrap'])) { //@todo we should validate this?
1435 1435
 								echo "block_wrap: {";
1436 1436
 								echo "	type: 'string',";
1437
-								echo "  default: '" . esc_attr( $this->options['block-wrap'] ) . "',";
1437
+								echo "  default: '" . esc_attr($this->options['block-wrap']) . "',";
1438 1438
 								echo "},";
1439 1439
 							}
1440 1440
 
1441 1441
 
1442
-							foreach ( $this->arguments as $key => $args ) {
1442
+							foreach ($this->arguments as $key => $args) {
1443 1443
 
1444 1444
 								// set if we should show alignment
1445
-								if ( $key == 'alignment' ) {
1445
+								if ($key == 'alignment') {
1446 1446
 									$show_alignment = true;
1447 1447
 								}
1448 1448
 
1449 1449
 								$extra = '';
1450 1450
 
1451
-								if ( $args['type'] == 'checkbox' ) {
1451
+								if ($args['type'] == 'checkbox') {
1452 1452
 									$type    = 'boolean';
1453
-									$default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false';
1454
-								} elseif ( $args['type'] == 'number' ) {
1453
+									$default = isset($args['default']) && $args['default'] ? 'true' : 'false';
1454
+								} elseif ($args['type'] == 'number') {
1455 1455
 									$type    = 'number';
1456
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1457
-								} elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) {
1456
+									$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
1457
+								} elseif ($args['type'] == 'select' && !empty($args['multiple'])) {
1458 1458
 									$type = 'array';
1459
-									if ( is_array( $args['default'] ) ) {
1460
-										$default = isset( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]";
1459
+									if (is_array($args['default'])) {
1460
+										$default = isset($args['default']) ? "['" . implode("','", $args['default']) . "']" : "[]";
1461 1461
 									} else {
1462
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1462
+										$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
1463 1463
 									}
1464
-								} elseif ( $args['type'] == 'multiselect' ) {
1464
+								} elseif ($args['type'] == 'multiselect') {
1465 1465
 									$type    = 'array';
1466
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1466
+									$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
1467 1467
 								} else {
1468 1468
 									$type    = 'string';
1469
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1469
+									$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
1470 1470
 								}
1471 1471
 								echo $key . " : {";
1472 1472
 								echo "type : '$type',";
@@ -1496,12 +1496,12 @@  discard block
 block discarded – undo
1496 1496
 									is_fetching = true;
1497 1497
 									var data = {
1498 1498
 										'action': 'super_duper_output_shortcode',
1499
-										'shortcode': '<?php echo $this->options['base_id'];?>',
1499
+										'shortcode': '<?php echo $this->options['base_id']; ?>',
1500 1500
 										'attributes': props.attributes,
1501
-										'post_id': <?php global $post; if ( isset( $post->ID ) ) {
1501
+										'post_id': <?php global $post; if (isset($post->ID)) {
1502 1502
 										echo $post->ID;
1503 1503
 									}?>,
1504
-										'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>'
1504
+										'_ajax_nonce': '<?php echo wp_create_nonce('super_duper_output_shortcode'); ?>'
1505 1505
 									};
1506 1506
 
1507 1507
 									jQuery.post(ajaxurl, data, function (response) {
@@ -1510,7 +1510,7 @@  discard block
 block discarded – undo
1510 1510
 
1511 1511
 										// if the content is empty then we place some placeholder text
1512 1512
 										if (env == '') {
1513
-											env = "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" + "<?php _e( 'Placeholder for: ' );?>" + props.name + "</div>";
1513
+											env = "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" + "<?php _e('Placeholder for: '); ?>" + props.name + "</div>";
1514 1514
 										}
1515 1515
 
1516 1516
 										props.setAttributes({content: env});
@@ -1529,7 +1529,7 @@  discard block
 block discarded – undo
1529 1529
 
1530 1530
 								el(wp.editor.BlockControls, {key: 'controls'},
1531 1531
 
1532
-									<?php if($show_alignment){?>
1532
+									<?php if ($show_alignment) {?>
1533 1533
 									el(
1534 1534
 										wp.editor.AlignmentToolbar,
1535 1535
 										{
@@ -1547,9 +1547,9 @@  discard block
 block discarded – undo
1547 1547
 
1548 1548
 									<?php
1549 1549
 
1550
-									if(! empty( $this->arguments )){
1550
+									if (!empty($this->arguments)) {
1551 1551
 
1552
-									if ( $show_advanced ) {
1552
+									if ($show_advanced) {
1553 1553
 									?>
1554 1554
 									el(
1555 1555
 										wp.components.ToggleControl,
@@ -1565,76 +1565,76 @@  discard block
 block discarded – undo
1565 1565
 
1566 1566
 									}
1567 1567
 
1568
-									foreach($this->arguments as $key => $args){
1569
-									$custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : '';
1568
+									foreach ($this->arguments as $key => $args) {
1569
+									$custom_attributes = !empty($args['custom_attributes']) ? $this->array_to_attributes($args['custom_attributes']) : '';
1570 1570
 									$options = '';
1571 1571
 									$extra = '';
1572 1572
 									$require = '';
1573 1573
 									$onchange = "props.setAttributes({ $key: $key } )";
1574 1574
 									$value = "props.attributes.$key";
1575
-									$text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'color' );
1576
-									if ( in_array( $args['type'], $text_type ) ) {
1575
+									$text_type = array('text', 'password', 'number', 'email', 'tel', 'url', 'color');
1576
+									if (in_array($args['type'], $text_type)) {
1577 1577
 										$type = 'TextControl';
1578 1578
 										// Save numbers as numbers and not strings
1579
-										if ( $args['type'] == 'number' ) {
1579
+										if ($args['type'] == 'number') {
1580 1580
 											$onchange = "props.setAttributes({ $key: Number($key) } )";
1581 1581
 										}
1582 1582
 									}
1583 1583
 //									elseif ( $args['type'] == 'color' ) { //@todo ColorPicker labels are not shown yet, we may have to add our own https://github.com/WordPress/gutenberg/issues/14378
1584 1584
 //										$type = 'ColorPicker';
1585 1585
 //									}
1586
-									elseif ( $args['type'] == 'checkbox' ) {
1586
+									elseif ($args['type'] == 'checkbox') {
1587 1587
 										$type = 'CheckboxControl';
1588 1588
 										$extra .= "checked: props.attributes.$key,";
1589 1589
 										$onchange = "props.setAttributes({ $key: ! props.attributes.$key } )";
1590
-									} elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) {
1590
+									} elseif ($args['type'] == 'select' || $args['type'] == 'multiselect') {
1591 1591
 										$type = 'SelectControl';
1592
-										if ( ! empty( $args['options'] ) ) {
1592
+										if (!empty($args['options'])) {
1593 1593
 											$options .= "options  : [";
1594
-											foreach ( $args['options'] as $option_val => $option_label ) {
1595
-												$options .= "{ value : '" . esc_attr( $option_val ) . "',     label : '" . esc_attr( $option_label ) . "'     },";
1594
+											foreach ($args['options'] as $option_val => $option_label) {
1595
+												$options .= "{ value : '" . esc_attr($option_val) . "',     label : '" . esc_attr($option_label) . "'     },";
1596 1596
 											}
1597 1597
 											$options .= "],";
1598 1598
 										}
1599
-										if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
1599
+										if (isset($args['multiple']) && $args['multiple']) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
1600 1600
 											$extra .= ' multiple: true, ';
1601 1601
 											//$onchange = "props.setAttributes({ $key: ['edit'] } )";
1602 1602
 											//$value = "['edit', 'delete']";
1603 1603
 										}
1604
-									} elseif ( $args['type'] == 'alignment' ) {
1604
+									} elseif ($args['type'] == 'alignment') {
1605 1605
 										$type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example
1606 1606
 									} else {
1607
-										continue;// if we have not implemented the control then don't break the JS.
1607
+										continue; // if we have not implemented the control then don't break the JS.
1608 1608
 									}
1609 1609
 
1610 1610
 									// add show only if advanced
1611
-									if ( ! empty( $args['advanced'] ) ) {
1611
+									if (!empty($args['advanced'])) {
1612 1612
 										echo "props.attributes.show_advanced && ";
1613 1613
 									}
1614 1614
 									// add setting require if defined
1615
-									if ( ! empty( $args['element_require'] ) ) {
1616
-										echo $this->block_props_replace( $args['element_require'], true ) . " && ";
1615
+									if (!empty($args['element_require'])) {
1616
+										echo $this->block_props_replace($args['element_require'], true) . " && ";
1617 1617
 									}
1618 1618
 									?>
1619 1619
 									el(
1620
-										wp.components.<?php echo esc_attr( $type );?>,
1620
+										wp.components.<?php echo esc_attr($type); ?>,
1621 1621
 										{
1622
-											label: '<?php echo esc_attr( $args['title'] );?>',
1623
-											help: '<?php if ( isset( $args['desc'] ) ) {
1624
-												echo esc_attr( $args['desc'] );
1622
+											label: '<?php echo esc_attr($args['title']); ?>',
1623
+											help: '<?php if (isset($args['desc'])) {
1624
+												echo esc_attr($args['desc']);
1625 1625
 											}?>',
1626
-											value: <?php echo $value;?>,
1627
-											<?php if ( $type == 'TextControl' && $args['type'] != 'text' ) {
1628
-											echo "type: '" . esc_attr( $args['type'] ) . "',";
1626
+											value: <?php echo $value; ?>,
1627
+											<?php if ($type == 'TextControl' && $args['type'] != 'text') {
1628
+											echo "type: '" . esc_attr($args['type']) . "',";
1629 1629
 										}?>
1630
-											<?php if ( ! empty( $args['placeholder'] ) ) {
1631
-											echo "placeholder: '" . esc_attr( $args['placeholder'] ) . "',";
1630
+											<?php if (!empty($args['placeholder'])) {
1631
+											echo "placeholder: '" . esc_attr($args['placeholder']) . "',";
1632 1632
 										}?>
1633
-											<?php echo $options;?>
1634
-											<?php echo $extra;?>
1635
-											<?php echo $custom_attributes;?>
1636
-											onChange: function ( <?php echo $key;?> ) {
1637
-												<?php echo $onchange;?>
1633
+											<?php echo $options; ?>
1634
+											<?php echo $extra; ?>
1635
+											<?php echo $custom_attributes; ?>
1636
+											onChange: function ( <?php echo $key; ?> ) {
1637
+												<?php echo $onchange; ?>
1638 1638
 											}
1639 1639
 										}
1640 1640
 									),
@@ -1647,9 +1647,9 @@  discard block
 block discarded – undo
1647 1647
 
1648 1648
 								<?php
1649 1649
 								// If the user sets block-output array then build it
1650
-								if ( ! empty( $this->options['block-output'] ) ) {
1651
-								$this->block_element( $this->options['block-output'] );
1652
-							}else{
1650
+								if (!empty($this->options['block-output'])) {
1651
+								$this->block_element($this->options['block-output']);
1652
+							} else {
1653 1653
 								// if no block-output is set then we try and get the shortcode html output via ajax.
1654 1654
 								?>
1655 1655
 								el('div', {
@@ -1673,14 +1673,14 @@  discard block
 block discarded – undo
1673 1673
 							var align = '';
1674 1674
 
1675 1675
 							// build the shortcode.
1676
-							var content = "[<?php echo $this->options['base_id'];?>";
1676
+							var content = "[<?php echo $this->options['base_id']; ?>";
1677 1677
 							<?php
1678 1678
 
1679
-							if(! empty( $this->arguments )){
1680
-							foreach($this->arguments as $key => $args){
1679
+							if (!empty($this->arguments)) {
1680
+							foreach ($this->arguments as $key => $args) {
1681 1681
 							?>
1682
-							if (attr.hasOwnProperty("<?php echo esc_attr( $key );?>")) {
1683
-								content += " <?php echo esc_attr( $key );?>='" + attr.<?php echo esc_attr( $key );?>+ "' ";
1682
+							if (attr.hasOwnProperty("<?php echo esc_attr($key); ?>")) {
1683
+								content += " <?php echo esc_attr($key); ?>='" + attr.<?php echo esc_attr($key); ?>+ "' ";
1684 1684
 							}
1685 1685
 							<?php
1686 1686
 							}
@@ -1721,10 +1721,10 @@  discard block
 block discarded – undo
1721 1721
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1722 1722
 			 */
1723 1723
 
1724
-			return str_replace( array(
1724
+			return str_replace(array(
1725 1725
 				'<script>',
1726 1726
 				'</script>'
1727
-			), '', $output );
1727
+			), '', $output);
1728 1728
 		}
1729 1729
 
1730 1730
 		/**
@@ -1736,16 +1736,16 @@  discard block
 block discarded – undo
1736 1736
 		 *
1737 1737
 		 * @return string
1738 1738
 		 */
1739
-		public function array_to_attributes( $custom_attributes, $html = false ) {
1739
+		public function array_to_attributes($custom_attributes, $html = false) {
1740 1740
 			$attributes = '';
1741
-			if ( ! empty( $custom_attributes ) ) {
1741
+			if (!empty($custom_attributes)) {
1742 1742
 
1743
-				if ( $html ) {
1744
-					foreach ( $custom_attributes as $key => $val ) {
1743
+				if ($html) {
1744
+					foreach ($custom_attributes as $key => $val) {
1745 1745
 						$attributes .= " $key='$val' ";
1746 1746
 					}
1747 1747
 				} else {
1748
-					foreach ( $custom_attributes as $key => $val ) {
1748
+					foreach ($custom_attributes as $key => $val) {
1749 1749
 						$attributes .= "'$key': '$val',";
1750 1750
 					}
1751 1751
 				}
@@ -1761,86 +1761,86 @@  discard block
 block discarded – undo
1761 1761
 		 *
1762 1762
 		 * @param $args
1763 1763
 		 */
1764
-		public function block_element( $args ) {
1764
+		public function block_element($args) {
1765 1765
 
1766 1766
 
1767
-			if ( ! empty( $args ) ) {
1768
-				foreach ( $args as $element => $new_args ) {
1767
+			if (!empty($args)) {
1768
+				foreach ($args as $element => $new_args) {
1769 1769
 
1770
-					if ( is_array( $new_args ) ) { // its an element
1770
+					if (is_array($new_args)) { // its an element
1771 1771
 
1772 1772
 
1773
-						if ( isset( $new_args['element'] ) ) {
1773
+						if (isset($new_args['element'])) {
1774 1774
 
1775
-							if ( isset( $new_args['element_require'] ) ) {
1776
-								echo str_replace( array(
1775
+							if (isset($new_args['element_require'])) {
1776
+								echo str_replace(array(
1777 1777
 										"'+",
1778 1778
 										"+'"
1779
-									), '', $this->block_props_replace( $new_args['element_require'] ) ) . " &&  ";
1780
-								unset( $new_args['element_require'] );
1779
+									), '', $this->block_props_replace($new_args['element_require'])) . " &&  ";
1780
+								unset($new_args['element_require']);
1781 1781
 							}
1782 1782
 
1783 1783
 							echo "\n el( '" . $new_args['element'] . "', {";
1784 1784
 
1785 1785
 							// get the attributes
1786
-							foreach ( $new_args as $new_key => $new_value ) {
1786
+							foreach ($new_args as $new_key => $new_value) {
1787 1787
 
1788 1788
 
1789
-								if ( $new_key == 'element' || $new_key == 'content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) {
1789
+								if ($new_key == 'element' || $new_key == 'content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array($new_value)) {
1790 1790
 									// do nothing
1791 1791
 								} else {
1792
-									echo $this->block_element( array( $new_key => $new_value ) );
1792
+									echo $this->block_element(array($new_key => $new_value));
1793 1793
 								}
1794 1794
 							}
1795 1795
 
1796
-							echo "},";// end attributes
1796
+							echo "},"; // end attributes
1797 1797
 
1798 1798
 							// get the content
1799 1799
 							$first_item = 0;
1800
-							foreach ( $new_args as $new_key => $new_value ) {
1801
-								if ( $new_key === 'content' || is_array( $new_value ) ) {
1800
+							foreach ($new_args as $new_key => $new_value) {
1801
+								if ($new_key === 'content' || is_array($new_value)) {
1802 1802
 
1803
-									if ( $new_key === 'content' ) {
1804
-										echo "'" . $this->block_props_replace( $new_value ) . "'";
1803
+									if ($new_key === 'content') {
1804
+										echo "'" . $this->block_props_replace($new_value) . "'";
1805 1805
 									}
1806 1806
 
1807
-									if ( is_array( $new_value ) ) {
1807
+									if (is_array($new_value)) {
1808 1808
 
1809
-										if ( isset( $new_value['element_require'] ) ) {
1810
-											echo str_replace( array(
1809
+										if (isset($new_value['element_require'])) {
1810
+											echo str_replace(array(
1811 1811
 													"'+",
1812 1812
 													"+'"
1813
-												), '', $this->block_props_replace( $new_value['element_require'] ) ) . " &&  ";
1814
-											unset( $new_value['element_require'] );
1813
+												), '', $this->block_props_replace($new_value['element_require'])) . " &&  ";
1814
+											unset($new_value['element_require']);
1815 1815
 										}
1816 1816
 
1817
-										if ( isset( $new_value['element_repeat'] ) ) {
1817
+										if (isset($new_value['element_repeat'])) {
1818 1818
 											$x = 1;
1819
-											while ( $x <= absint( $new_value['element_repeat'] ) ) {
1820
-												$this->block_element( array( '' => $new_value ) );
1821
-												$x ++;
1819
+											while ($x <= absint($new_value['element_repeat'])) {
1820
+												$this->block_element(array('' => $new_value));
1821
+												$x++;
1822 1822
 											}
1823 1823
 										} else {
1824
-											$this->block_element( array( '' => $new_value ) );
1824
+											$this->block_element(array('' => $new_value));
1825 1825
 										}
1826 1826
 									}
1827
-									$first_item ++;
1827
+									$first_item++;
1828 1828
 								}
1829 1829
 							}
1830 1830
 
1831
-							echo ")";// end content
1831
+							echo ")"; // end content
1832 1832
 
1833 1833
 							echo ", \n";
1834 1834
 
1835 1835
 						}
1836 1836
 					} else {
1837 1837
 
1838
-						if ( substr( $element, 0, 3 ) === "if_" ) {
1839
-							echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ",";
1840
-						} elseif ( $element == 'style' ) {
1841
-							echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
1838
+						if (substr($element, 0, 3) === "if_") {
1839
+							echo str_replace("if_", "", $element) . ": " . $this->block_props_replace($new_args, true) . ",";
1840
+						} elseif ($element == 'style') {
1841
+							echo $element . ": " . $this->block_props_replace($new_args) . ",";
1842 1842
 						} else {
1843
-							echo $element . ": '" . $this->block_props_replace( $new_args ) . "',";
1843
+							echo $element . ": '" . $this->block_props_replace($new_args) . "',";
1844 1844
 						}
1845 1845
 
1846 1846
 					}
@@ -1855,12 +1855,12 @@  discard block
 block discarded – undo
1855 1855
 		 *
1856 1856
 		 * @return mixed
1857 1857
 		 */
1858
-		public function block_props_replace( $string, $no_wrap = false ) {
1858
+		public function block_props_replace($string, $no_wrap = false) {
1859 1859
 
1860
-			if ( $no_wrap ) {
1861
-				$string = str_replace( array( "[%", "%]" ), array( "props.attributes.", "" ), $string );
1860
+			if ($no_wrap) {
1861
+				$string = str_replace(array("[%", "%]"), array("props.attributes.", ""), $string);
1862 1862
 			} else {
1863
-				$string = str_replace( array( "[%", "%]" ), array( "'+props.attributes.", "+'" ), $string );
1863
+				$string = str_replace(array("[%", "%]"), array("'+props.attributes.", "+'"), $string);
1864 1864
 			}
1865 1865
 
1866 1866
 			return $string;
@@ -1872,37 +1872,37 @@  discard block
 block discarded – undo
1872 1872
 		 * @param array $args
1873 1873
 		 * @param array $instance
1874 1874
 		 */
1875
-		public function widget( $args, $instance ) {
1875
+		public function widget($args, $instance) {
1876 1876
 
1877 1877
 			// get the filtered values
1878
-			$argument_values = $this->argument_values( $instance );
1879
-			$argument_values = $this->string_to_bool( $argument_values );
1880
-			$output          = $this->output( $argument_values, $args );
1878
+			$argument_values = $this->argument_values($instance);
1879
+			$argument_values = $this->string_to_bool($argument_values);
1880
+			$output          = $this->output($argument_values, $args);
1881 1881
 
1882
-			if ( $output ) {
1882
+			if ($output) {
1883 1883
 				// Before widget
1884 1884
 				$before_widget = $args['before_widget'];
1885
-				$before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this );
1886
-				$before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this );
1885
+				$before_widget = apply_filters('wp_super_duper_before_widget', $before_widget, $args, $instance, $this);
1886
+				$before_widget = apply_filters('wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this);
1887 1887
 
1888 1888
 				// After widget
1889 1889
 				$after_widget = $args['after_widget'];
1890
-				$after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this );
1891
-				$after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this );
1890
+				$after_widget = apply_filters('wp_super_duper_after_widget', $after_widget, $args, $instance, $this);
1891
+				$after_widget = apply_filters('wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this);
1892 1892
 
1893 1893
 				echo $before_widget;
1894 1894
 				// elementor strips the widget wrapping div so we check for and add it back if needed
1895
-				if ( $this->is_elementor_widget_output() ) {
1896
-					echo ! empty( $this->options['widget_ops']['classname'] ) ? "<span class='" . esc_attr( $this->options['widget_ops']['classname'] ) . "'>" : '';
1895
+				if ($this->is_elementor_widget_output()) {
1896
+					echo !empty($this->options['widget_ops']['classname']) ? "<span class='" . esc_attr($this->options['widget_ops']['classname']) . "'>" : '';
1897 1897
 				}
1898
-				echo $this->output_title( $args, $instance );
1898
+				echo $this->output_title($args, $instance);
1899 1899
 				echo $output;
1900
-				if ( $this->is_elementor_widget_output() ) {
1901
-					echo ! empty( $this->options['widget_ops']['classname'] ) ? "</span>" : '';
1900
+				if ($this->is_elementor_widget_output()) {
1901
+					echo !empty($this->options['widget_ops']['classname']) ? "</span>" : '';
1902 1902
 				}
1903 1903
 				echo $after_widget;
1904
-			} elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty
1905
-				$output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
1904
+			} elseif ($this->is_preview() && $output == '') {// if preview show a placeholder if empty
1905
+				$output = $this->preview_placeholder_text("{{" . $this->base_id . "}}");
1906 1906
 				echo $output;
1907 1907
 			}
1908 1908
 		}
@@ -1915,7 +1915,7 @@  discard block
 block discarded – undo
1915 1915
 		 */
1916 1916
 		public function is_elementor_widget_output() {
1917 1917
 			$result = false;
1918
-			if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) {
1918
+			if (defined('ELEMENTOR_VERSION') && isset($this->number) && $this->number == 'REPLACE_TO_ID') {
1919 1919
 				$result = true;
1920 1920
 			}
1921 1921
 
@@ -1930,7 +1930,7 @@  discard block
 block discarded – undo
1930 1930
 		 */
1931 1931
 		public function is_elementor_preview() {
1932 1932
 			$result = false;
1933
-			if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) {
1933
+			if (isset($_REQUEST['elementor-preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor') || (isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor_ajax')) {
1934 1934
 				$result = true;
1935 1935
 			}
1936 1936
 
@@ -1945,7 +1945,7 @@  discard block
 block discarded – undo
1945 1945
 		 */
1946 1946
 		public function is_divi_preview() {
1947 1947
 			$result = false;
1948
-			if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) {
1948
+			if (isset($_REQUEST['et_fb']) || isset($_REQUEST['et_pb_preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor')) {
1949 1949
 				$result = true;
1950 1950
 			}
1951 1951
 
@@ -1960,7 +1960,7 @@  discard block
 block discarded – undo
1960 1960
 		 */
1961 1961
 		public function is_beaver_preview() {
1962 1962
 			$result = false;
1963
-			if ( isset( $_REQUEST['fl_builder'] ) ) {
1963
+			if (isset($_REQUEST['fl_builder'])) {
1964 1964
 				$result = true;
1965 1965
 			}
1966 1966
 
@@ -1975,7 +1975,7 @@  discard block
 block discarded – undo
1975 1975
 		 */
1976 1976
 		public function is_siteorigin_preview() {
1977 1977
 			$result = false;
1978
-			if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) {
1978
+			if (!empty($_REQUEST['siteorigin_panels_live_editor'])) {
1979 1979
 				$result = true;
1980 1980
 			}
1981 1981
 
@@ -1990,7 +1990,7 @@  discard block
 block discarded – undo
1990 1990
 		 */
1991 1991
 		public function is_cornerstone_preview() {
1992 1992
 			$result = false;
1993
-			if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) {
1993
+			if (!empty($_REQUEST['cornerstone_preview']) || basename($_SERVER['REQUEST_URI']) == 'cornerstone-endpoint') {
1994 1994
 				$result = true;
1995 1995
 			}
1996 1996
 
@@ -2005,15 +2005,15 @@  discard block
 block discarded – undo
2005 2005
 		 */
2006 2006
 		public function is_preview() {
2007 2007
 			$preview = false;
2008
-			if ( $this->is_divi_preview() ) {
2008
+			if ($this->is_divi_preview()) {
2009 2009
 				$preview = true;
2010
-			} elseif ( $this->is_elementor_preview() ) {
2010
+			} elseif ($this->is_elementor_preview()) {
2011 2011
 				$preview = true;
2012
-			} elseif ( $this->is_beaver_preview() ) {
2012
+			} elseif ($this->is_beaver_preview()) {
2013 2013
 				$preview = true;
2014
-			} elseif ( $this->is_siteorigin_preview() ) {
2014
+			} elseif ($this->is_siteorigin_preview()) {
2015 2015
 				$preview = true;
2016
-			} elseif ( $this->is_cornerstone_preview() ) {
2016
+			} elseif ($this->is_cornerstone_preview()) {
2017 2017
 				$preview = true;
2018 2018
 			}
2019 2019
 
@@ -2028,11 +2028,11 @@  discard block
 block discarded – undo
2028 2028
 		 *
2029 2029
 		 * @return string
2030 2030
 		 */
2031
-		public function output_title( $args, $instance = array() ) {
2031
+		public function output_title($args, $instance = array()) {
2032 2032
 			$output = '';
2033
-			if ( ! empty( $instance['title'] ) ) {
2033
+			if (!empty($instance['title'])) {
2034 2034
 				/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
2035
-				$title  = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
2035
+				$title  = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
2036 2036
 				$output = $args['before_title'] . $title . $args['after_title'];
2037 2037
 			}
2038 2038
 
@@ -2044,7 +2044,7 @@  discard block
 block discarded – undo
2044 2044
 		 *
2045 2045
 		 * @param array $instance The widget options.
2046 2046
 		 */
2047
-		public function form( $instance ) {
2047
+		public function form($instance) {
2048 2048
 
2049 2049
 			// set widget instance
2050 2050
 			$this->instance = $instance;
@@ -2052,12 +2052,12 @@  discard block
 block discarded – undo
2052 2052
 			// set it as a SD widget
2053 2053
 			echo $this->widget_advanced_toggle();
2054 2054
 
2055
-			echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>";
2055
+			echo "<p>" . esc_attr($this->options['widget_ops']['description']) . "</p>";
2056 2056
 			$arguments = $this->get_arguments();
2057 2057
 
2058
-			if ( is_array( $arguments ) ) {
2059
-				foreach ( $arguments as $key => $args ) {
2060
-					$this->widget_inputs( $args, $instance );
2058
+			if (is_array($arguments)) {
2059
+				foreach ($arguments as $key => $args) {
2060
+					$this->widget_inputs($args, $instance);
2061 2061
 				}
2062 2062
 			}
2063 2063
 		}
@@ -2070,7 +2070,7 @@  discard block
 block discarded – undo
2070 2070
 		public function widget_advanced_toggle() {
2071 2071
 
2072 2072
 			$output = '';
2073
-			if ( $this->block_show_advanced() ) {
2073
+			if ($this->block_show_advanced()) {
2074 2074
 				$val = 1;
2075 2075
 			} else {
2076 2076
 				$val = 0;
@@ -2090,14 +2090,14 @@  discard block
 block discarded – undo
2090 2090
 		 *
2091 2091
 		 * @return string $output
2092 2092
 		 */
2093
-		public function convert_element_require( $input ) {
2093
+		public function convert_element_require($input) {
2094 2094
 
2095
-			$input = str_replace( "'", '"', $input );// we only want double quotes
2095
+			$input = str_replace("'", '"', $input); // we only want double quotes
2096 2096
 
2097
-			$output = esc_attr( str_replace( array( "[%", "%]" ), array(
2097
+			$output = esc_attr(str_replace(array("[%", "%]"), array(
2098 2098
 				"jQuery(form).find('[data-argument=\"",
2099 2099
 				"\"]').find('input,select').val()"
2100
-			), $input ) );
2100
+			), $input));
2101 2101
 
2102 2102
 			return $output;
2103 2103
 		}
@@ -2108,54 +2108,54 @@  discard block
 block discarded – undo
2108 2108
 		 * @param $args
2109 2109
 		 * @param $instance
2110 2110
 		 */
2111
-		public function widget_inputs( $args, $instance ) {
2111
+		public function widget_inputs($args, $instance) {
2112 2112
 
2113 2113
 			$class             = "";
2114 2114
 			$element_require   = "";
2115 2115
 			$custom_attributes = "";
2116 2116
 
2117 2117
 			// get value
2118
-			if ( isset( $instance[ $args['name'] ] ) ) {
2119
-				$value = $instance[ $args['name'] ];
2120
-			} elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) {
2121
-				$value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] );
2118
+			if (isset($instance[$args['name']])) {
2119
+				$value = $instance[$args['name']];
2120
+			} elseif (!isset($instance[$args['name']]) && !empty($args['default'])) {
2121
+				$value = is_array($args['default']) ? array_map("esc_html", $args['default']) : esc_html($args['default']);
2122 2122
 			} else {
2123 2123
 				$value = '';
2124 2124
 			}
2125 2125
 
2126 2126
 			// get placeholder
2127
-			if ( ! empty( $args['placeholder'] ) ) {
2128
-				$placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'";
2127
+			if (!empty($args['placeholder'])) {
2128
+				$placeholder = "placeholder='" . esc_html($args['placeholder']) . "'";
2129 2129
 			} else {
2130 2130
 				$placeholder = '';
2131 2131
 			}
2132 2132
 
2133 2133
 			// get if advanced
2134
-			if ( isset( $args['advanced'] ) && $args['advanced'] ) {
2134
+			if (isset($args['advanced']) && $args['advanced']) {
2135 2135
 				$class .= " sd-advanced-setting ";
2136 2136
 			}
2137 2137
 
2138 2138
 			// element_require
2139
-			if ( isset( $args['element_require'] ) && $args['element_require'] ) {
2139
+			if (isset($args['element_require']) && $args['element_require']) {
2140 2140
 				$element_require = $args['element_require'];
2141 2141
 			}
2142 2142
 
2143 2143
 			// custom_attributes
2144
-			if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) {
2145
-				$custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true );
2144
+			if (isset($args['custom_attributes']) && $args['custom_attributes']) {
2145
+				$custom_attributes = $this->array_to_attributes($args['custom_attributes'], true);
2146 2146
 			}
2147 2147
 
2148 2148
 			// before wrapper
2149 2149
 			?>
2150
-			<p class="sd-argument <?php echo esc_attr( $class ); ?>"
2151
-			   data-argument='<?php echo esc_attr( $args['name'] ); ?>'
2152
-			   data-element_require='<?php if ( $element_require ) {
2153
-				   echo $this->convert_element_require( $element_require );
2150
+			<p class="sd-argument <?php echo esc_attr($class); ?>"
2151
+			   data-argument='<?php echo esc_attr($args['name']); ?>'
2152
+			   data-element_require='<?php if ($element_require) {
2153
+				   echo $this->convert_element_require($element_require);
2154 2154
 			   } ?>'
2155 2155
 			>
2156 2156
 				<?php
2157 2157
 
2158
-				switch ( $args['type'] ) {
2158
+				switch ($args['type']) {
2159 2159
 					//array('text','password','number','email','tel','url','color')
2160 2160
 					case "text":
2161 2161
 					case "password":
@@ -2166,46 +2166,46 @@  discard block
 block discarded – undo
2166 2166
 					case "color":
2167 2167
 						?>
2168 2168
 						<label
2169
-							for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
2169
+							for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo esc_attr($args['title']); ?><?php echo $this->widget_field_desc($args); ?></label>
2170 2170
 						<input <?php echo $placeholder; ?> class="widefat"
2171 2171
 							<?php echo $custom_attributes; ?>
2172
-							                               id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
2173
-							                               name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>"
2174
-							                               type="<?php echo esc_attr( $args['type'] ); ?>"
2175
-							                               value="<?php echo esc_attr( $value ); ?>">
2172
+							                               id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"
2173
+							                               name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>"
2174
+							                               type="<?php echo esc_attr($args['type']); ?>"
2175
+							                               value="<?php echo esc_attr($value); ?>">
2176 2176
 						<?php
2177 2177
 
2178 2178
 						break;
2179 2179
 					case "select":
2180
-						$multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false;
2181
-						if ( $multiple ) {
2182
-							if ( empty( $value ) ) {
2180
+						$multiple = isset($args['multiple']) && $args['multiple'] ? true : false;
2181
+						if ($multiple) {
2182
+							if (empty($value)) {
2183 2183
 								$value = array();
2184 2184
 							}
2185 2185
 						}
2186 2186
 						?>
2187 2187
 						<label
2188
-							for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
2188
+							for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo esc_attr($args['title']); ?><?php echo $this->widget_field_desc($args); ?></label>
2189 2189
 						<select <?php echo $placeholder; ?> class="widefat"
2190 2190
 							<?php echo $custom_attributes; ?>
2191
-							                                id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
2192
-							                                name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) );
2193
-							                                if ( $multiple ) {
2191
+							                                id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"
2192
+							                                name="<?php echo esc_attr($this->get_field_name($args['name']));
2193
+							                                if ($multiple) {
2194 2194
 								                                echo "[]";
2195 2195
 							                                } ?>"
2196
-							<?php if ( $multiple ) {
2196
+							<?php if ($multiple) {
2197 2197
 								echo "multiple";
2198 2198
 							} //@todo not implemented yet due to gutenberg not supporting it
2199 2199
 							?>
2200 2200
 						>
2201 2201
 							<?php
2202 2202
 
2203
-							if ( ! empty( $args['options'] ) ) {
2204
-								foreach ( $args['options'] as $val => $label ) {
2205
-									if ( $multiple ) {
2206
-										$selected = in_array( $val, $value ) ? 'selected="selected"' : '';
2203
+							if (!empty($args['options'])) {
2204
+								foreach ($args['options'] as $val => $label) {
2205
+									if ($multiple) {
2206
+										$selected = in_array($val, $value) ? 'selected="selected"' : '';
2207 2207
 									} else {
2208
-										$selected = selected( $value, $val, false );
2208
+										$selected = selected($value, $val, false);
2209 2209
 									}
2210 2210
 									echo "<option value='$val' " . $selected . ">$label</option>";
2211 2211
 								}
@@ -2217,20 +2217,20 @@  discard block
 block discarded – undo
2217 2217
 					case "checkbox":
2218 2218
 						?>
2219 2219
 						<input <?php echo $placeholder; ?>
2220
-							<?php checked( 1, $value, true ) ?>
2220
+							<?php checked(1, $value, true) ?>
2221 2221
 							<?php echo $custom_attributes; ?>
2222
-							class="widefat" id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
2223
-							name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="checkbox"
2222
+							class="widefat" id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"
2223
+							name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" type="checkbox"
2224 2224
 							value="1">
2225 2225
 						<label
2226
-							for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
2226
+							for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo esc_attr($args['title']); ?><?php echo $this->widget_field_desc($args); ?></label>
2227 2227
 						<?php
2228 2228
 						break;
2229 2229
 					case "hidden":
2230 2230
 						?>
2231
-						<input id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
2232
-						       name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="hidden"
2233
-						       value="<?php echo esc_attr( $value ); ?>">
2231
+						<input id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"
2232
+						       name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" type="hidden"
2233
+						       value="<?php echo esc_attr($value); ?>">
2234 2234
 						<?php
2235 2235
 						break;
2236 2236
 					default:
@@ -2252,14 +2252,14 @@  discard block
 block discarded – undo
2252 2252
 		 * @return string
2253 2253
 		 * @todo, need to make its own tooltip script
2254 2254
 		 */
2255
-		public function widget_field_desc( $args ) {
2255
+		public function widget_field_desc($args) {
2256 2256
 
2257 2257
 			$description = '';
2258
-			if ( isset( $args['desc'] ) && $args['desc'] ) {
2259
-				if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) {
2260
-					$description = $this->desc_tip( $args['desc'] );
2258
+			if (isset($args['desc']) && $args['desc']) {
2259
+				if (isset($args['desc_tip']) && $args['desc_tip']) {
2260
+					$description = $this->desc_tip($args['desc']);
2261 2261
 				} else {
2262
-					$description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>';
2262
+					$description = '<span class="description">' . wp_kses_post($args['desc']) . '</span>';
2263 2263
 				}
2264 2264
 			}
2265 2265
 
@@ -2274,11 +2274,11 @@  discard block
 block discarded – undo
2274 2274
 		 *
2275 2275
 		 * @return string
2276 2276
 		 */
2277
-		function desc_tip( $tip, $allow_html = false ) {
2278
-			if ( $allow_html ) {
2279
-				$tip = $this->sanitize_tooltip( $tip );
2277
+		function desc_tip($tip, $allow_html = false) {
2278
+			if ($allow_html) {
2279
+				$tip = $this->sanitize_tooltip($tip);
2280 2280
 			} else {
2281
-				$tip = esc_attr( $tip );
2281
+				$tip = esc_attr($tip);
2282 2282
 			}
2283 2283
 
2284 2284
 			return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
@@ -2291,8 +2291,8 @@  discard block
 block discarded – undo
2291 2291
 		 *
2292 2292
 		 * @return string
2293 2293
 		 */
2294
-		public function sanitize_tooltip( $var ) {
2295
-			return htmlspecialchars( wp_kses( html_entity_decode( $var ), array(
2294
+		public function sanitize_tooltip($var) {
2295
+			return htmlspecialchars(wp_kses(html_entity_decode($var), array(
2296 2296
 				'br'     => array(),
2297 2297
 				'em'     => array(),
2298 2298
 				'strong' => array(),
@@ -2302,7 +2302,7 @@  discard block
 block discarded – undo
2302 2302
 				'li'     => array(),
2303 2303
 				'ol'     => array(),
2304 2304
 				'p'      => array(),
2305
-			) ) );
2305
+			)));
2306 2306
 		}
2307 2307
 
2308 2308
 		/**
@@ -2314,23 +2314,23 @@  discard block
 block discarded – undo
2314 2314
 		 * @return array
2315 2315
 		 * @todo we should add some sanitation here.
2316 2316
 		 */
2317
-		public function update( $new_instance, $old_instance ) {
2317
+		public function update($new_instance, $old_instance) {
2318 2318
 
2319 2319
 			//save the widget
2320
-			$instance = array_merge( (array) $old_instance, (array) $new_instance );
2320
+			$instance = array_merge((array)$old_instance, (array)$new_instance);
2321 2321
 
2322 2322
 			// set widget instance
2323 2323
 			$this->instance = $instance;
2324 2324
 
2325
-			if ( empty( $this->arguments ) ) {
2325
+			if (empty($this->arguments)) {
2326 2326
 				$this->get_arguments();
2327 2327
 			}
2328 2328
 
2329 2329
 			// check for checkboxes
2330
-			if ( ! empty( $this->arguments ) ) {
2331
-				foreach ( $this->arguments as $argument ) {
2332
-					if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) {
2333
-						$instance[ $argument['name'] ] = '0';
2330
+			if (!empty($this->arguments)) {
2331
+				foreach ($this->arguments as $argument) {
2332
+					if (isset($argument['type']) && $argument['type'] == 'checkbox' && !isset($new_instance[$argument['name']])) {
2333
+						$instance[$argument['name']] = '0';
2334 2334
 					}
2335 2335
 				}
2336 2336
 			}
@@ -2348,7 +2348,7 @@  discard block
 block discarded – undo
2348 2348
 		 */
2349 2349
 		public function is_block_content_call() {
2350 2350
 			$result = false;
2351
-			if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) {
2351
+			if (wp_doing_ajax() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'super_duper_output_shortcode') {
2352 2352
 				$result = true;
2353 2353
 			}
2354 2354
 
Please login to merge, or discard this patch.
includes/admin/wpinv-admin-functions.php 1 patch
Spacing   +235 added lines, -235 removed lines patch added patch discarded remove patch
@@ -7,245 +7,245 @@  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
-function wpinv_columns( $columns ) {
14
+function wpinv_columns($columns) {
15 15
     $columns = array(
16 16
         'cb'                => $columns['cb'],
17
-        'number'            => __( 'Number', 'invoicing' ),
18
-        'customer'          => __( 'Customer', 'invoicing' ),
19
-        'amount'            => __( 'Amount', 'invoicing' ),
20
-        'invoice_date'      => __( 'Created Date', 'invoicing' ),
21
-        'payment_date'      => __( 'Payment Date', 'invoicing' ),
22
-        'status'            => __( 'Status', 'invoicing' ),
23
-        'ID'                => __( 'ID', 'invoicing' ),
24
-        'wpi_actions'       => __( 'Actions', 'invoicing' ),
17
+        'number'            => __('Number', 'invoicing'),
18
+        'customer'          => __('Customer', 'invoicing'),
19
+        'amount'            => __('Amount', 'invoicing'),
20
+        'invoice_date'      => __('Created Date', 'invoicing'),
21
+        'payment_date'      => __('Payment Date', 'invoicing'),
22
+        'status'            => __('Status', 'invoicing'),
23
+        'ID'                => __('ID', 'invoicing'),
24
+        'wpi_actions'       => __('Actions', 'invoicing'),
25 25
     );
26 26
 
27
-    return apply_filters( 'wpi_invoice_table_columns', $columns );
27
+    return apply_filters('wpi_invoice_table_columns', $columns);
28 28
 }
29
-add_filter( 'manage_wpi_invoice_posts_columns', 'wpinv_columns' );
29
+add_filter('manage_wpi_invoice_posts_columns', 'wpinv_columns');
30 30
 
31
-function wpinv_bulk_actions( $actions ) {
32
-    if ( isset( $actions['edit'] ) ) {
33
-        unset( $actions['edit'] );
31
+function wpinv_bulk_actions($actions) {
32
+    if (isset($actions['edit'])) {
33
+        unset($actions['edit']);
34 34
     }
35 35
 
36 36
     return $actions;
37 37
 }
38
-add_filter( 'bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions' );
39
-add_filter( 'bulk_actions-edit-wpi_item', 'wpinv_bulk_actions' );
38
+add_filter('bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions');
39
+add_filter('bulk_actions-edit-wpi_item', 'wpinv_bulk_actions');
40 40
 
41
-function wpinv_sortable_columns( $columns ) {
41
+function wpinv_sortable_columns($columns) {
42 42
     $columns = array(
43
-        'ID'            => array( 'ID', true ),
44
-        'number'        => array( 'number', false ),
45
-        'amount'        => array( 'amount', false ),
46
-        'invoice_date'  => array( 'date', false ),
47
-        'payment_date'  => array( 'payment_date', true ),
48
-        'customer'      => array( 'customer', false ),
49
-        'status'        => array( 'status', false ),
43
+        'ID'            => array('ID', true),
44
+        'number'        => array('number', false),
45
+        'amount'        => array('amount', false),
46
+        'invoice_date'  => array('date', false),
47
+        'payment_date'  => array('payment_date', true),
48
+        'customer'      => array('customer', false),
49
+        'status'        => array('status', false),
50 50
     );
51 51
     
52
-    return apply_filters( 'wpi_invoice_table_sortable_columns', $columns );
52
+    return apply_filters('wpi_invoice_table_sortable_columns', $columns);
53 53
 }
54
-add_filter( 'manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns' );
54
+add_filter('manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns');
55 55
 
56
-add_action( 'manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column');
57
-function wpinv_posts_custom_column( $column_name, $post_id = 0 ) {
56
+add_action('manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column');
57
+function wpinv_posts_custom_column($column_name, $post_id = 0) {
58 58
     global $post, $wpi_invoice;
59 59
     
60
-    if ( empty( $wpi_invoice ) || ( !empty( $wpi_invoice ) && $post->ID != $wpi_invoice->ID ) ) {
61
-        $wpi_invoice = new WPInv_Invoice( $post->ID );
60
+    if (empty($wpi_invoice) || (!empty($wpi_invoice) && $post->ID != $wpi_invoice->ID)) {
61
+        $wpi_invoice = new WPInv_Invoice($post->ID);
62 62
     }
63 63
 
64 64
     $value = NULL;
65 65
     
66
-    switch ( $column_name ) {
66
+    switch ($column_name) {
67 67
         case 'email' :
68
-            $value   = $wpi_invoice->get_email();
68
+            $value = $wpi_invoice->get_email();
69 69
             break;
70 70
         case 'customer' :
71 71
             $customer_name = $wpi_invoice->get_user_full_name();
72
-            $customer_name = $customer_name != '' ? $customer_name : __( 'Customer', 'invoicing' );
73
-            $value = '<a href="' . esc_url( get_edit_user_link( $wpi_invoice->get_user_id() ) ) . '">' . $customer_name . '</a>';
74
-            if ( $email = $wpi_invoice->get_email() ) {
72
+            $customer_name = $customer_name != '' ? $customer_name : __('Customer', 'invoicing');
73
+            $value = '<a href="' . esc_url(get_edit_user_link($wpi_invoice->get_user_id())) . '">' . $customer_name . '</a>';
74
+            if ($email = $wpi_invoice->get_email()) {
75 75
                 $value .= '<br><a class="email" href="mailto:' . $email . '">' . $email . '</a>';
76 76
             }
77 77
             break;
78 78
         case 'amount' :
79
-            echo $wpi_invoice->get_total( true );
79
+            echo $wpi_invoice->get_total(true);
80 80
             break;
81 81
         case 'invoice_date' :
82
-            $date_format = get_option( 'date_format' );
83
-            $time_format = get_option( 'time_format' );
84
-            $date_time_format = $date_format . ' '. $time_format;
82
+            $date_format = get_option('date_format');
83
+            $time_format = get_option('time_format');
84
+            $date_time_format = $date_format . ' ' . $time_format;
85 85
             
86 86
             $m_time = $post->post_date;
87
-            $h_time = mysql2date( $date_format, $m_time );
87
+            $h_time = mysql2date($date_format, $m_time);
88 88
             
89
-            $value   = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>';
89
+            $value = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>';
90 90
             break;
91 91
         case 'payment_date' :
92
-            if ( $date_completed = $wpi_invoice->get_meta( '_wpinv_completed_date', true ) ) {
93
-                $date_format = get_option( 'date_format' );
94
-                $time_format = get_option( 'time_format' );
95
-                $date_time_format = $date_format . ' '. $time_format;
92
+            if ($date_completed = $wpi_invoice->get_meta('_wpinv_completed_date', true)) {
93
+                $date_format = get_option('date_format');
94
+                $time_format = get_option('time_format');
95
+                $date_time_format = $date_format . ' ' . $time_format;
96 96
                 
97 97
                 $m_time = $date_completed;
98
-                $h_time = mysql2date( $date_format, $m_time );
98
+                $h_time = mysql2date($date_format, $m_time);
99 99
                 
100
-                $value   = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>';
100
+                $value = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>';
101 101
             } else {
102 102
                 $value = '-';
103 103
             }
104 104
             break;
105 105
         case 'status' :
106
-            $value   = $wpi_invoice->get_status( true ) . ( $wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __( '(r)', 'invoicing' ) . '</span>' : '' );
107
-            $is_viewed = wpinv_is_invoice_viewed( $wpi_invoice->ID );
108
-            if ( 1 == $is_viewed ) {
109
-                $value .= '&nbsp;&nbsp;<i class="fa fa-eye" title="'.__( 'Viewed by Customer', 'invoicing' ).'"></i>';
106
+            $value = $wpi_invoice->get_status(true) . ($wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __('(r)', 'invoicing') . '</span>' : '');
107
+            $is_viewed = wpinv_is_invoice_viewed($wpi_invoice->ID);
108
+            if (1 == $is_viewed) {
109
+                $value .= '&nbsp;&nbsp;<i class="fa fa-eye" title="' . __('Viewed by Customer', 'invoicing') . '"></i>';
110 110
             }
111
-            if ( ( $wpi_invoice->is_paid() || $wpi_invoice->is_refunded() ) && ( $gateway_title = wpinv_get_gateway_admin_label( $wpi_invoice->get_gateway() ) ) ) {
112
-                $value .= '<br><small class="meta gateway">' . wp_sprintf( __( 'Via %s', 'invoicing' ), $gateway_title ) . '</small>';
111
+            if (($wpi_invoice->is_paid() || $wpi_invoice->is_refunded()) && ($gateway_title = wpinv_get_gateway_admin_label($wpi_invoice->get_gateway()))) {
112
+                $value .= '<br><small class="meta gateway">' . wp_sprintf(__('Via %s', 'invoicing'), $gateway_title) . '</small>';
113 113
             }
114 114
             break;
115 115
         case 'number' :
116
-            $edit_link = get_edit_post_link( $post->ID );
117
-            $value = '<a title="' . esc_attr__( 'View Invoice Details', 'invoicing' ) . '" href="' . esc_url( $edit_link ) . '">' . $wpi_invoice->get_number() . '</a>';
116
+            $edit_link = get_edit_post_link($post->ID);
117
+            $value = '<a title="' . esc_attr__('View Invoice Details', 'invoicing') . '" href="' . esc_url($edit_link) . '">' . $wpi_invoice->get_number() . '</a>';
118 118
             break;
119 119
         case 'wpi_actions' :
120 120
             $value = '';
121
-            if ( !empty( $post->post_name ) ) {
122
-                $value .= '<a title="' . esc_attr__( 'Print invoice', 'invoicing' ) . '" href="' . esc_url( get_permalink( $post->ID ) ) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>';
121
+            if (!empty($post->post_name)) {
122
+                $value .= '<a title="' . esc_attr__('Print invoice', 'invoicing') . '" href="' . esc_url(get_permalink($post->ID)) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>';
123 123
             }
124 124
             
125
-            if ( $email = $wpi_invoice->get_email() ) {
126
-                $value .= '<a title="' . esc_attr__( 'Send invoice to customer', 'invoicing' ) . '" href="' . esc_url( add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) ) ) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>';
125
+            if ($email = $wpi_invoice->get_email()) {
126
+                $value .= '<a title="' . esc_attr__('Send invoice to customer', 'invoicing') . '" href="' . esc_url(add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID))) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>';
127 127
             }
128 128
             
129 129
             break;
130 130
         default:
131
-            $value = isset( $post->$column_name ) ? $post->$column_name : '';
131
+            $value = isset($post->$column_name) ? $post->$column_name : '';
132 132
             break;
133 133
 
134 134
     }
135
-    $value = apply_filters( 'wpinv_payments_table_column', $value, $post->ID, $column_name );
135
+    $value = apply_filters('wpinv_payments_table_column', $value, $post->ID, $column_name);
136 136
     
137
-    if ( $value !== NULL ) {
137
+    if ($value !== NULL) {
138 138
         echo $value;
139 139
     }
140 140
 }
141 141
 
142
-function wpinv_admin_post_id( $id = 0 ) {
142
+function wpinv_admin_post_id($id = 0) {
143 143
     global $post;
144 144
 
145
-    if ( isset( $id ) && ! empty( $id ) ) {
145
+    if (isset($id) && !empty($id)) {
146 146
         return (int)$id;
147
-    } else if ( get_the_ID() ) {
148
-        return (int) get_the_ID();
149
-    } else if ( isset( $post->ID ) && !empty( $post->ID ) ) {
150
-        return (int) $post->ID;
151
-    } else if ( isset( $_GET['post'] ) && !empty( $_GET['post'] ) ) {
152
-        return (int) $_GET['post'];
153
-    } else if ( isset( $_GET['id'] ) && !empty( $_GET['id'] ) ) {
154
-        return (int) $_GET['id'];
155
-    } else if ( isset( $_POST['id'] ) && !empty( $_POST['id'] ) ) {
156
-        return (int) $_POST['id'];
147
+    } else if (get_the_ID()) {
148
+        return (int)get_the_ID();
149
+    } else if (isset($post->ID) && !empty($post->ID)) {
150
+        return (int)$post->ID;
151
+    } else if (isset($_GET['post']) && !empty($_GET['post'])) {
152
+        return (int)$_GET['post'];
153
+    } else if (isset($_GET['id']) && !empty($_GET['id'])) {
154
+        return (int)$_GET['id'];
155
+    } else if (isset($_POST['id']) && !empty($_POST['id'])) {
156
+        return (int)$_POST['id'];
157 157
     } 
158 158
 
159 159
     return null;
160 160
 }
161 161
     
162
-function wpinv_admin_post_type( $id = 0 ) {
163
-    if ( !$id ) {
162
+function wpinv_admin_post_type($id = 0) {
163
+    if (!$id) {
164 164
         $id = wpinv_admin_post_id();
165 165
     }
166 166
     
167
-    $type = get_post_type( $id );
167
+    $type = get_post_type($id);
168 168
     
169
-    if ( !$type ) {
170
-        $type = isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) ? $_GET['post_type'] : null;
169
+    if (!$type) {
170
+        $type = isset($_GET['post_type']) && !empty($_GET['post_type']) ? $_GET['post_type'] : null;
171 171
     }
172 172
     
173
-    return apply_filters( 'wpinv_admin_post_type', $type, $id );
173
+    return apply_filters('wpinv_admin_post_type', $type, $id);
174 174
 }
175 175
 
176 176
 function wpinv_admin_messages() {
177 177
 	global $wpinv_options, $pagenow, $post;
178 178
 
179
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
180
-		 add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' );
179
+	if (isset($_GET['wpinv-message']) && 'discount_added' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
180
+		 add_settings_error('wpinv-notices', 'wpinv-discount-added', __('Discount code added.', 'invoicing'), 'updated');
181 181
 	}
182 182
 
183
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
184
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' );
183
+	if (isset($_GET['wpinv-message']) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
184
+		add_settings_error('wpinv-notices', 'wpinv-discount-add-fail', __('There was a problem adding your discount code, please try again.', 'invoicing'), 'error');
185 185
 	}
186 186
 
187
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
188
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' );
187
+	if (isset($_GET['wpinv-message']) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
188
+		add_settings_error('wpinv-notices', 'wpinv-discount-exists', __('A discount with that code already exists, please use a different code.', 'invoicing'), 'error');
189 189
 	}
190 190
 
191
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
192
-		 add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' );
191
+	if (isset($_GET['wpinv-message']) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
192
+		 add_settings_error('wpinv-notices', 'wpinv-discount-updated', __('Discount code updated.', 'invoicing'), 'updated');
193 193
 	}
194 194
 
195
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
196
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' );
195
+	if (isset($_GET['wpinv-message']) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
196
+		add_settings_error('wpinv-notices', 'wpinv-discount-updated-fail', __('There was a problem updating your discount code, please try again.', 'invoicing'), 'error');
197 197
 	}
198 198
 
199
-	if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
200
-		add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' );
199
+	if (isset($_GET['wpinv-message']) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
200
+		add_settings_error('wpinv-notices', 'wpinv-deleted', __('The invoice has been deleted.', 'invoicing'), 'updated');
201 201
 	}
202 202
 
203
-	if ( isset( $_GET['wpinv-message'] ) && 'email_disabled' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
204
-		add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Email notification is disabled. Please check settings.', 'invoicing' ), 'error' );
203
+	if (isset($_GET['wpinv-message']) && 'email_disabled' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
204
+		add_settings_error('wpinv-notices', 'wpinv-sent-fail', __('Email notification is disabled. Please check settings.', 'invoicing'), 'error');
205 205
 	}
206 206
 
207
-	if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
208
-		add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' );
207
+	if (isset($_GET['wpinv-message']) && 'email_sent' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
208
+		add_settings_error('wpinv-notices', 'wpinv-sent', __('The email has been sent to customer.', 'invoicing'), 'updated');
209 209
     }
210 210
     
211
-    if ( isset( $_GET['wpinv-message'] ) && 'email_fail' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
212
-		add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' );
211
+    if (isset($_GET['wpinv-message']) && 'email_fail' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
212
+		add_settings_error('wpinv-notices', 'wpinv-sent-fail', __('Fail to send email to the customer.', 'invoicing'), 'error');
213 213
     }
214 214
 
215
-    if ( isset( $_GET['wpinv-message'] ) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
216
-        add_settings_error( 'wpinv-notices', 'wpinv-note-deleted', __( 'The invoice note has been deleted.', 'invoicing' ), 'updated' );
215
+    if (isset($_GET['wpinv-message']) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
216
+        add_settings_error('wpinv-notices', 'wpinv-note-deleted', __('The invoice note has been deleted.', 'invoicing'), 'updated');
217 217
     }
218 218
 
219
-	if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
220
-		add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' );
219
+	if (isset($_GET['wpinv-message']) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
220
+		add_settings_error('wpinv-notices', 'wpinv-settings-imported', __('The settings have been imported.', 'invoicing'), 'updated');
221 221
 	}
222 222
 
223
-	if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
224
-		add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' );
223
+	if (isset($_GET['wpinv-message']) && 'note-added' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
224
+		add_settings_error('wpinv-notices', 'wpinv-note-added', __('The invoice note has been added successfully.', 'invoicing'), 'updated');
225 225
 	}
226 226
 
227
-	if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
228
-		add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' );
227
+	if (isset($_GET['wpinv-message']) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
228
+		add_settings_error('wpinv-notices', 'wpinv-updated', __('The invoice has been successfully updated.', 'invoicing'), 'updated');
229 229
 	}
230 230
     
231
-	if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) {
232
-		$message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID );
231
+	if ($pagenow == 'post.php' && !empty($post->post_type) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable($post)) {
232
+		$message = apply_filters('wpinv_item_non_editable_message', __('This item in not editable.', 'invoicing'), $post->ID);
233 233
 
234
-		if ( !empty( $message ) ) {
235
-			add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' );
234
+		if (!empty($message)) {
235
+			add_settings_error('wpinv-notices', 'wpinv-edit-n', $message, 'updated');
236 236
 		}
237 237
 	}
238 238
 
239
-	settings_errors( 'wpinv-notices' );
239
+	settings_errors('wpinv-notices');
240 240
 }
241
-add_action( 'admin_notices', 'wpinv_admin_messages' );
241
+add_action('admin_notices', 'wpinv_admin_messages');
242 242
 
243
-add_action( 'admin_init', 'wpinv_show_test_payment_gateway_notice' );
244
-function wpinv_show_test_payment_gateway_notice(){
245
-    add_action( 'admin_notices', 'wpinv_test_payment_gateway_messages' );
243
+add_action('admin_init', 'wpinv_show_test_payment_gateway_notice');
244
+function wpinv_show_test_payment_gateway_notice() {
245
+    add_action('admin_notices', 'wpinv_test_payment_gateway_messages');
246 246
 }
247 247
 
248
-function wpinv_test_payment_gateway_messages(){
248
+function wpinv_test_payment_gateway_messages() {
249 249
     $gateways = wpinv_get_enabled_payment_gateways();
250 250
     $name = array(); $test_gateways = '';
251 251
     if ($gateways) {
@@ -256,9 +256,9 @@  discard block
 block discarded – undo
256 256
         }
257 257
         $test_gateways = implode(', ', $name);
258 258
     }
259
-    if(isset($test_gateways) && !empty($test_gateways)){
259
+    if (isset($test_gateways) && !empty($test_gateways)) {
260 260
         $link = admin_url('admin.php?page=wpinv-settings&tab=gateways');
261
-        $notice = wp_sprintf( __('<strong>Important:</strong> Payment Gateway(s) %s are in testing mode and will not receive real payments. Go to <a href="%s"> Gateway Settings</a>.', 'invoicing'), $test_gateways, $link );
261
+        $notice = wp_sprintf(__('<strong>Important:</strong> Payment Gateway(s) %s are in testing mode and will not receive real payments. Go to <a href="%s"> Gateway Settings</a>.', 'invoicing'), $test_gateways, $link);
262 262
         ?>
263 263
         <div class="notice notice-warning is-dismissible">
264 264
             <p><?php echo $notice; ?></p>
@@ -267,29 +267,29 @@  discard block
 block discarded – undo
267 267
     }
268 268
 }
269 269
 
270
-function wpinv_items_columns( $existing_columns ) {
270
+function wpinv_items_columns($existing_columns) {
271 271
     global $wpinv_euvat;
272 272
     
273 273
     $columns                = array();
274 274
     $columns['cb']          = $existing_columns['cb'];
275
-    $columns['title']       = __( 'Title', 'invoicing' );
276
-    $columns['price']       = __( 'Price', 'invoicing' );
277
-    if ( $wpinv_euvat->allow_vat_rules() ) {
278
-        $columns['vat_rule']    = __( 'VAT rule type', 'invoicing' );
275
+    $columns['title']       = __('Title', 'invoicing');
276
+    $columns['price']       = __('Price', 'invoicing');
277
+    if ($wpinv_euvat->allow_vat_rules()) {
278
+        $columns['vat_rule']    = __('VAT rule type', 'invoicing');
279 279
     }
280
-    if ( $wpinv_euvat->allow_vat_classes() ) {
281
-        $columns['vat_class']   = __( 'VAT class', 'invoicing' );
280
+    if ($wpinv_euvat->allow_vat_classes()) {
281
+        $columns['vat_class']   = __('VAT class', 'invoicing');
282 282
     }
283
-    $columns['type']        = __( 'Type', 'invoicing' );
284
-    $columns['recurring']   = __( 'Recurring', 'invoicing' );
285
-    $columns['date']        = __( 'Date', 'invoicing' );
286
-    $columns['id']          = __( 'ID', 'invoicing' );
283
+    $columns['type']        = __('Type', 'invoicing');
284
+    $columns['recurring']   = __('Recurring', 'invoicing');
285
+    $columns['date']        = __('Date', 'invoicing');
286
+    $columns['id']          = __('ID', 'invoicing');
287 287
 
288
-    return apply_filters( 'wpinv_items_columns', $columns );
288
+    return apply_filters('wpinv_items_columns', $columns);
289 289
 }
290
-add_filter( 'manage_wpi_item_posts_columns', 'wpinv_items_columns' );
290
+add_filter('manage_wpi_item_posts_columns', 'wpinv_items_columns');
291 291
 
292
-function wpinv_items_sortable_columns( $columns ) {
292
+function wpinv_items_sortable_columns($columns) {
293 293
     $columns['price']       = 'price';
294 294
     $columns['vat_rule']    = 'vat_rule';
295 295
     $columns['vat_class']   = 'vat_class';
@@ -299,151 +299,151 @@  discard block
 block discarded – undo
299 299
 
300 300
     return $columns;
301 301
 }
302
-add_filter( 'manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns' );
302
+add_filter('manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns');
303 303
 
304
-function wpinv_items_table_custom_column( $column ) {
304
+function wpinv_items_table_custom_column($column) {
305 305
     global $wpinv_euvat, $post, $wpi_item;
306 306
     
307
-    if ( empty( $wpi_item ) || ( !empty( $wpi_item ) && $post->ID != $wpi_item->ID ) ) {
308
-        $wpi_item = new WPInv_Item( $post->ID );
307
+    if (empty($wpi_item) || (!empty($wpi_item) && $post->ID != $wpi_item->ID)) {
308
+        $wpi_item = new WPInv_Item($post->ID);
309 309
     }
310 310
 
311
-    switch ( $column ) {
311
+    switch ($column) {
312 312
         case 'price' :
313
-            echo wpinv_item_price( $post->ID );
313
+            echo wpinv_item_price($post->ID);
314 314
         break;
315 315
         case 'vat_rule' :
316
-            echo $wpinv_euvat->item_rule_label( $post->ID );
316
+            echo $wpinv_euvat->item_rule_label($post->ID);
317 317
         break;
318 318
         case 'vat_class' :
319
-            echo $wpinv_euvat->item_class_label( $post->ID );
319
+            echo $wpinv_euvat->item_class_label($post->ID);
320 320
         break;
321 321
         case 'type' :
322
-            echo wpinv_item_type( $post->ID ) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>';
322
+            echo wpinv_item_type($post->ID) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>';
323 323
         break;
324 324
         case 'recurring' :
325
-            echo ( wpinv_is_recurring_item( $post->ID ) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>' );
325
+            echo (wpinv_is_recurring_item($post->ID) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>');
326 326
         break;
327 327
         case 'id' :
328 328
            echo $post->ID;
329 329
            echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '">
330
-                    <div class="price">' . wpinv_get_item_price( $post->ID ) . '</div>';
331
-                    if ( $wpinv_euvat->allow_vat_rules() ) {
332
-                        echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule( $post->ID ) . '</div>';
330
+                    <div class="price">' . wpinv_get_item_price($post->ID) . '</div>';
331
+                    if ($wpinv_euvat->allow_vat_rules()) {
332
+                        echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule($post->ID) . '</div>';
333 333
                     }
334
-                    if ( $wpinv_euvat->allow_vat_classes() ) {
335
-                        echo '<div class="vat_class">' . $wpinv_euvat->get_item_class( $post->ID ) . '</div>';
334
+                    if ($wpinv_euvat->allow_vat_classes()) {
335
+                        echo '<div class="vat_class">' . $wpinv_euvat->get_item_class($post->ID) . '</div>';
336 336
                     }
337
-                    echo '<div class="type">' . wpinv_get_item_type( $post->ID ) . '</div>
337
+                    echo '<div class="type">' . wpinv_get_item_type($post->ID) . '</div>
338 338
                 </div>';
339 339
         break;
340 340
     }
341 341
     
342
-    do_action( 'wpinv_items_table_column_item_' . $column, $wpi_item, $post );
342
+    do_action('wpinv_items_table_column_item_' . $column, $wpi_item, $post);
343 343
 }
344
-add_action( 'manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column' );
344
+add_action('manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column');
345 345
 
346 346
 function wpinv_add_items_filters() {
347 347
     global $wpinv_euvat, $typenow;
348 348
 
349 349
     // Checks if the current post type is 'item'
350
-    if ( $typenow == 'wpi_item') {
351
-        if ( $wpinv_euvat->allow_vat_rules() ) {
352
-            echo wpinv_html_select( array(
353
-                    'options'          => array_merge( array( '' => __( 'All VAT rules', 'invoicing' ) ), $wpinv_euvat->get_rules() ),
350
+    if ($typenow == 'wpi_item') {
351
+        if ($wpinv_euvat->allow_vat_rules()) {
352
+            echo wpinv_html_select(array(
353
+                    'options'          => array_merge(array('' => __('All VAT rules', 'invoicing')), $wpinv_euvat->get_rules()),
354 354
                     'name'             => 'vat_rule',
355 355
                     'id'               => 'vat_rule',
356
-                    'selected'         => ( isset( $_GET['vat_rule'] ) ? $_GET['vat_rule'] : '' ),
356
+                    'selected'         => (isset($_GET['vat_rule']) ? $_GET['vat_rule'] : ''),
357 357
                     'show_option_all'  => false,
358 358
                     'show_option_none' => false,
359 359
                     'class'            => 'gdmbx2-text-medium wpi_select2',
360
-                ) );
360
+                ));
361 361
         }
362 362
         
363
-        if ( $wpinv_euvat->allow_vat_classes() ) {
364
-            echo wpinv_html_select( array(
365
-                    'options'          => array_merge( array( '' => __( 'All VAT classes', 'invoicing' ) ), $wpinv_euvat->get_all_classes() ),
363
+        if ($wpinv_euvat->allow_vat_classes()) {
364
+            echo wpinv_html_select(array(
365
+                    'options'          => array_merge(array('' => __('All VAT classes', 'invoicing')), $wpinv_euvat->get_all_classes()),
366 366
                     'name'             => 'vat_class',
367 367
                     'id'               => 'vat_class',
368
-                    'selected'         => ( isset( $_GET['vat_class'] ) ? $_GET['vat_class'] : '' ),
368
+                    'selected'         => (isset($_GET['vat_class']) ? $_GET['vat_class'] : ''),
369 369
                     'show_option_all'  => false,
370 370
                     'show_option_none' => false,
371 371
                     'class'            => 'gdmbx2-text-medium wpi_select2',
372
-                ) );
372
+                ));
373 373
         }
374 374
             
375
-        echo wpinv_html_select( array(
376
-                'options'          => array_merge( array( '' => __( 'All item types', 'invoicing' ) ), wpinv_get_item_types() ),
375
+        echo wpinv_html_select(array(
376
+                'options'          => array_merge(array('' => __('All item types', 'invoicing')), wpinv_get_item_types()),
377 377
                 'name'             => 'type',
378 378
                 'id'               => 'type',
379
-                'selected'         => ( isset( $_GET['type'] ) ? $_GET['type'] : '' ),
379
+                'selected'         => (isset($_GET['type']) ? $_GET['type'] : ''),
380 380
                 'show_option_all'  => false,
381 381
                 'show_option_none' => false,
382 382
                 'class'            => 'gdmbx2-text-medium',
383
-            ) );
383
+            ));
384 384
 
385
-        if ( isset( $_REQUEST['all_posts'] ) && '1' === $_REQUEST['all_posts'] ) {
385
+        if (isset($_REQUEST['all_posts']) && '1' === $_REQUEST['all_posts']) {
386 386
             echo '<input type="hidden" name="all_posts" value="1" />';
387 387
         }
388 388
     }
389 389
 }
390
-add_action( 'restrict_manage_posts', 'wpinv_add_items_filters', 100 );
390
+add_action('restrict_manage_posts', 'wpinv_add_items_filters', 100);
391 391
 
392
-function wpinv_send_invoice_after_save( $invoice ) {
393
-    if ( empty( $_POST['wpi_save_send'] ) ) {
392
+function wpinv_send_invoice_after_save($invoice) {
393
+    if (empty($_POST['wpi_save_send'])) {
394 394
         return;
395 395
     }
396 396
     
397
-    if ( !empty( $invoice->ID ) && !empty( $invoice->post_type ) && 'wpi_invoice' == $invoice->post_type ) {
398
-        wpinv_user_invoice_notification( $invoice->ID );
397
+    if (!empty($invoice->ID) && !empty($invoice->post_type) && 'wpi_invoice' == $invoice->post_type) {
398
+        wpinv_user_invoice_notification($invoice->ID);
399 399
     }
400 400
 }
401
-add_action( 'wpinv_invoice_metabox_saved', 'wpinv_send_invoice_after_save', 100, 1 );
401
+add_action('wpinv_invoice_metabox_saved', 'wpinv_send_invoice_after_save', 100, 1);
402 402
 
403
-function wpinv_send_register_new_user( $data, $postarr ) {
404
-    if ( current_user_can( 'manage_options' ) && !empty( $data['post_type'] ) && ( 'wpi_invoice' == $data['post_type'] || 'wpi_quote' == $data['post_type'] ) ) {
405
-        $is_new_user = !empty( $postarr['wpinv_new_user'] ) ? true : false;
406
-        $email = !empty( $postarr['wpinv_email'] ) && $postarr['wpinv_email'] && is_email( $postarr['wpinv_email'] ) ? $postarr['wpinv_email'] : NULL;
403
+function wpinv_send_register_new_user($data, $postarr) {
404
+    if (current_user_can('manage_options') && !empty($data['post_type']) && ('wpi_invoice' == $data['post_type'] || 'wpi_quote' == $data['post_type'])) {
405
+        $is_new_user = !empty($postarr['wpinv_new_user']) ? true : false;
406
+        $email = !empty($postarr['wpinv_email']) && $postarr['wpinv_email'] && is_email($postarr['wpinv_email']) ? $postarr['wpinv_email'] : NULL;
407 407
         
408
-        if ( $is_new_user && $email && !email_exists( $email ) ) {
409
-            $first_name = !empty( $postarr['wpinv_first_name'] ) ? sanitize_text_field( $postarr['wpinv_first_name'] ) : '';
410
-            $last_name = !empty( $postarr['wpinv_last_name'] ) ? sanitize_text_field( $postarr['wpinv_last_name'] ) : '';
411
-            $display_name = $first_name || $last_name ? trim( $first_name . ' ' . $last_name ) : '';
412
-            $user_nicename = $display_name ? trim( $display_name ) : $email;
413
-            $user_company = !empty( $postarr['wpinv_company'] ) ? sanitize_text_field( $postarr['wpinv_company'] ) : '';
408
+        if ($is_new_user && $email && !email_exists($email)) {
409
+            $first_name = !empty($postarr['wpinv_first_name']) ? sanitize_text_field($postarr['wpinv_first_name']) : '';
410
+            $last_name = !empty($postarr['wpinv_last_name']) ? sanitize_text_field($postarr['wpinv_last_name']) : '';
411
+            $display_name = $first_name || $last_name ? trim($first_name . ' ' . $last_name) : '';
412
+            $user_nicename = $display_name ? trim($display_name) : $email;
413
+            $user_company = !empty($postarr['wpinv_company']) ? sanitize_text_field($postarr['wpinv_company']) : '';
414 414
             
415
-            $user_login = sanitize_user( str_replace( ' ', '', $display_name ), true );
416
-            if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) {
415
+            $user_login = sanitize_user(str_replace(' ', '', $display_name), true);
416
+            if (!(validate_username($user_login) && !username_exists($user_login))) {
417 417
                 $new_user_login = strstr($email, '@', true);
418
-                if ( validate_username( $user_login ) && username_exists( $user_login ) ) {
419
-                    $user_login = sanitize_user($new_user_login, true );
418
+                if (validate_username($user_login) && username_exists($user_login)) {
419
+                    $user_login = sanitize_user($new_user_login, true);
420 420
                 }
421
-                if ( validate_username( $user_login ) && username_exists( $user_login ) ) {
422
-                    $user_append_text = rand(10,1000);
423
-                    $user_login = sanitize_user($new_user_login.$user_append_text, true );
421
+                if (validate_username($user_login) && username_exists($user_login)) {
422
+                    $user_append_text = rand(10, 1000);
423
+                    $user_login = sanitize_user($new_user_login . $user_append_text, true);
424 424
                 }
425 425
                 
426
-                if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) {
426
+                if (!(validate_username($user_login) && !username_exists($user_login))) {
427 427
                     $user_login = $email;
428 428
                 }
429 429
             }
430 430
             
431 431
             $userdata = array(
432 432
                 'user_login' => $user_login,
433
-                'user_pass' => wp_generate_password( 12, false ),
434
-                'user_email' => sanitize_text_field( $email ),
433
+                'user_pass' => wp_generate_password(12, false),
434
+                'user_email' => sanitize_text_field($email),
435 435
                 'first_name' => $first_name,
436 436
                 'last_name' => $last_name,
437
-                'user_nicename' => wpinv_utf8_substr( $user_nicename, 0, 50 ),
437
+                'user_nicename' => wpinv_utf8_substr($user_nicename, 0, 50),
438 438
                 'nickname' => $display_name,
439 439
                 'display_name' => $display_name,
440 440
             );
441 441
 
442
-            $userdata = apply_filters( 'wpinv_register_new_user_data', $userdata );
442
+            $userdata = apply_filters('wpinv_register_new_user_data', $userdata);
443 443
             
444
-            $new_user_id = wp_insert_user( $userdata );
444
+            $new_user_id = wp_insert_user($userdata);
445 445
             
446
-            if ( !is_wp_error( $new_user_id ) ) {
446
+            if (!is_wp_error($new_user_id)) {
447 447
                 $data['post_author'] = $new_user_id;
448 448
                 $_POST['post_author'] = $new_user_id;
449 449
                 $_POST['post_author_override'] = $new_user_id;
@@ -464,72 +464,72 @@  discard block
 block discarded – undo
464 464
                 
465 465
                 $meta = array();
466 466
                 ///$meta['_wpinv_user_id'] = $new_user_id;
467
-                foreach ( $meta_fields as $field ) {
468
-                    $meta['_wpinv_' . $field] = isset( $postarr['wpinv_' . $field] ) ? sanitize_text_field( $postarr['wpinv_' . $field] ) : '';
467
+                foreach ($meta_fields as $field) {
468
+                    $meta['_wpinv_' . $field] = isset($postarr['wpinv_' . $field]) ? sanitize_text_field($postarr['wpinv_' . $field]) : '';
469 469
                 }
470 470
                 
471
-                $meta = apply_filters( 'wpinv_register_new_user_meta', $meta, $new_user_id );
471
+                $meta = apply_filters('wpinv_register_new_user_meta', $meta, $new_user_id);
472 472
 
473 473
                 // Update user meta.
474
-                foreach ( $meta as $key => $value ) {
475
-                    update_user_meta( $new_user_id, $key, $value );
474
+                foreach ($meta as $key => $value) {
475
+                    update_user_meta($new_user_id, $key, $value);
476 476
                 }
477 477
                 
478
-                if ( function_exists( 'wp_send_new_user_notifications' ) ) {
478
+                if (function_exists('wp_send_new_user_notifications')) {
479 479
                     // Send email notifications related to the creation of new user.
480
-                    wp_send_new_user_notifications( $new_user_id, 'user' );
480
+                    wp_send_new_user_notifications($new_user_id, 'user');
481 481
                 }
482 482
             } else {
483
-                wpinv_error_log( $new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__ );
483
+                wpinv_error_log($new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__);
484 484
             }
485 485
         }
486 486
     }
487 487
     
488 488
     return $data;
489 489
 }
490
-add_filter( 'wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2 );
490
+add_filter('wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2);
491 491
 
492
-function wpinv_show_recurring_supported_gateways( $item_ID ) {
492
+function wpinv_show_recurring_supported_gateways($item_ID) {
493 493
     $all_gateways = wpinv_get_payment_gateways();
494 494
 
495
-    if ( !empty( $all_gateways ) ) {
495
+    if (!empty($all_gateways)) {
496 496
         $gateways = array();
497 497
 
498
-        foreach ( $all_gateways as $key => $gateway ) {
499
-            if ( wpinv_gateway_support_subscription( $key ) ) {
498
+        foreach ($all_gateways as $key => $gateway) {
499
+            if (wpinv_gateway_support_subscription($key)) {
500 500
                 $gateways[] = $gateway['admin_label'];
501 501
             }
502 502
         }
503 503
 
504
-        if ( !empty( $gateways ) ) {
504
+        if (!empty($gateways)) {
505 505
             ?>
506
-            <span class="description"><?php echo wp_sprintf( __( 'Recurring payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ); ?></span>
506
+            <span class="description"><?php echo wp_sprintf(__('Recurring payments only supported by: %s', 'invoicing'), implode(', ', $gateways)); ?></span>
507 507
             <?php
508 508
         }
509 509
     }
510 510
 }
511
-add_action( 'wpinv_item_price_field', 'wpinv_show_recurring_supported_gateways', -10, 1 );
511
+add_action('wpinv_item_price_field', 'wpinv_show_recurring_supported_gateways', -10, 1);
512 512
 
513
-function wpinv_post_updated_messages( $messages ) {
513
+function wpinv_post_updated_messages($messages) {
514 514
     global $post, $post_ID;
515 515
 
516 516
     $messages['wpi_discount'] = array(
517 517
         0   => '',
518
-        1   => __( 'Discount updated.', 'invoicing' ),
519
-        2   => __( 'Custom field updated.', 'invoicing' ),
520
-        3   => __( 'Custom field deleted.', 'invoicing' ),
521
-        4   => __( 'Discount updated.', 'invoicing' ),
522
-        5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
523
-        6   => __( 'Discount updated.', 'invoicing' ),
524
-        7   => __( 'Discount saved.', 'invoicing' ),
525
-        8   => __( 'Discount submitted.', 'invoicing' ),
526
-        9   => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
527
-        10  => __( 'Discount draft updated.', 'invoicing' ),
518
+        1   => __('Discount updated.', 'invoicing'),
519
+        2   => __('Custom field updated.', 'invoicing'),
520
+        3   => __('Custom field deleted.', 'invoicing'),
521
+        4   => __('Discount updated.', 'invoicing'),
522
+        5   => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int)$_GET['revision'], false)) : false,
523
+        6   => __('Discount updated.', 'invoicing'),
524
+        7   => __('Discount saved.', 'invoicing'),
525
+        8   => __('Discount submitted.', 'invoicing'),
526
+        9   => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))),
527
+        10  => __('Discount draft updated.', 'invoicing'),
528 528
     );
529 529
 
530 530
     return $messages;
531 531
 }
532
-add_filter( 'post_updated_messages', 'wpinv_post_updated_messages', 10, 1 );
532
+add_filter('post_updated_messages', 'wpinv_post_updated_messages', 10, 1);
533 533
 
534 534
 add_action('admin_init', 'admin_init_example_type');
535 535
 
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
 function admin_init_example_type() {
540 540
     global $typenow;
541 541
 
542
-    if ($typenow === 'wpi_invoice' || $typenow === 'wpi_quote' ) {
542
+    if ($typenow === 'wpi_invoice' || $typenow === 'wpi_quote') {
543 543
         add_filter('posts_search', 'posts_search_example_type', 10, 2);
544 544
     }
545 545
 }
@@ -554,9 +554,9 @@  discard block
 block discarded – undo
554 554
     global $wpdb;
555 555
 
556 556
     if ($query->is_main_query() && !empty($query->query['s'])) {
557
-        $conditions_str = "{$wpdb->posts}.post_author IN ( SELECT ID FROM {$wpdb->users} WHERE user_email LIKE '%" . esc_sql( $query->query['s'] ) . "%' )";
558
-        if ( ! empty( $search ) ) {
559
-            $search = preg_replace( '/^ AND /', '', $search );
557
+        $conditions_str = "{$wpdb->posts}.post_author IN ( SELECT ID FROM {$wpdb->users} WHERE user_email LIKE '%" . esc_sql($query->query['s']) . "%' )";
558
+        if (!empty($search)) {
559
+            $search = preg_replace('/^ AND /', '', $search);
560 560
             $search = " AND ( {$search} OR ( {$conditions_str} ) )";
561 561
         } else {
562 562
             $search = " AND ( {$conditions_str} )";
@@ -566,9 +566,9 @@  discard block
 block discarded – undo
566 566
     return $search;
567 567
 }
568 568
 
569
-add_action( 'admin_init', 'wpinv_reset_invoice_count' );
570
-function wpinv_reset_invoice_count(){
571
-    if(isset($_GET['reset_invoice_count']) && 1 == $_GET['reset_invoice_count'] && isset($_GET['_nonce']) && wp_verify_nonce($_GET['_nonce'], 'reset_invoice_count')) {
569
+add_action('admin_init', 'wpinv_reset_invoice_count');
570
+function wpinv_reset_invoice_count() {
571
+    if (isset($_GET['reset_invoice_count']) && 1 == $_GET['reset_invoice_count'] && isset($_GET['_nonce']) && wp_verify_nonce($_GET['_nonce'], 'reset_invoice_count')) {
572 572
         wpinv_update_option('invoice_sequence_start', 1);
573 573
         delete_option('wpinv_last_invoice_number');
574 574
         $url = add_query_arg(array('reset_invoice_done' => 1));
@@ -579,8 +579,8 @@  discard block
 block discarded – undo
579 579
 }
580 580
 
581 581
 add_action('admin_notices', 'wpinv_invoice_count_reset_message');
582
-function wpinv_invoice_count_reset_message(){
583
-    if(isset($_GET['reset_invoice_done']) && 1 == $_GET['reset_invoice_done']) {
582
+function wpinv_invoice_count_reset_message() {
583
+    if (isset($_GET['reset_invoice_done']) && 1 == $_GET['reset_invoice_done']) {
584 584
         $notice = __('Invoice number sequence reset successfully.', 'invoicing');
585 585
         ?>
586 586
         <div class="notice notice-success is-dismissible">
Please login to merge, or discard this patch.
includes/admin/class-wpinv-admin-menus.php 1 patch
Spacing   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Setup menus in WP admin.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * WC_Admin_Menus Class.
@@ -13,34 +13,34 @@  discard block
 block discarded – undo
13 13
      * Hook in tabs.
14 14
      */
15 15
     public function __construct() {
16
-        add_action( 'admin_menu', array( $this, 'admin_menu' ), 10 );
17
-        add_action( 'admin_menu', array( $this, 'add_addons_menu' ), 99 );
18
-        add_action( 'admin_menu', array( $this, 'remove_admin_submenus' ), 10 );
19
-        add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) );
16
+        add_action('admin_menu', array($this, 'admin_menu'), 10);
17
+        add_action('admin_menu', array($this, 'add_addons_menu'), 99);
18
+        add_action('admin_menu', array($this, 'remove_admin_submenus'), 10);
19
+        add_action('admin_head-nav-menus.php', array($this, 'add_nav_menu_meta_boxes'));
20 20
     }
21 21
 
22 22
     public function admin_menu() {
23 23
         global $menu;
24 24
 
25
-        if ( !(current_user_can( 'manage_invoicing' ) || current_user_can( 'manage_options' )) ) {
25
+        if (!(current_user_can('manage_invoicing') || current_user_can('manage_options'))) {
26 26
             return;
27 27
         }
28 28
 
29
-        $capability = apply_filters( 'invoicing_capability', 'manage_invoicing' );
29
+        $capability = apply_filters('invoicing_capability', 'manage_invoicing');
30 30
 
31
-        if ( current_user_can( 'manage_options' ) ) {
32
-            $menu[] = array( '', 'read', 'separator-wpinv', '', 'wp-menu-separator wpinv' );
31
+        if (current_user_can('manage_options')) {
32
+            $menu[] = array('', 'read', 'separator-wpinv', '', 'wp-menu-separator wpinv');
33 33
         }
34 34
 
35
-        $wpi_invoice = get_post_type_object( 'wpi_invoice' );
35
+        $wpi_invoice = get_post_type_object('wpi_invoice');
36 36
 
37
-        add_menu_page( __( 'Invoicing', 'invoicing' ), __( 'Invoicing', 'invoicing' ), $capability, 'wpinv', null, $wpi_invoice->menu_icon, '54.123460' );
37
+        add_menu_page(__('Invoicing', 'invoicing'), __('Invoicing', 'invoicing'), $capability, 'wpinv', null, $wpi_invoice->menu_icon, '54.123460');
38 38
 
39
-        add_submenu_page( 'wpinv', __( 'Invoice Settings', 'invoicing' ), __( 'Settings', 'invoicing' ), $capability, 'wpinv-settings', array( $this, 'options_page' ));
39
+        add_submenu_page('wpinv', __('Invoice Settings', 'invoicing'), __('Settings', 'invoicing'), $capability, 'wpinv-settings', array($this, 'options_page'));
40 40
     }
41 41
 
42
-    public function add_addons_menu(){
43
-        if ( !apply_filters( 'wpi_show_addons_page', true ) ) {
42
+    public function add_addons_menu() {
43
+        if (!apply_filters('wpi_show_addons_page', true)) {
44 44
             return;
45 45
         }
46 46
 
@@ -50,78 +50,78 @@  discard block
 block discarded – undo
50 50
             __('Extensions', 'userswp'),
51 51
             'manage_options',
52 52
             'wpi-addons',
53
-            array( $this, 'addons_page' )
53
+            array($this, 'addons_page')
54 54
         );
55 55
     }
56 56
 
57
-    public function addons_page(){
57
+    public function addons_page() {
58 58
         $addon_obj = new WPInv_Admin_Addons();
59 59
         $addon_obj->output();
60 60
     }
61 61
 
62 62
     function options_page() {
63
-        $page       = isset( $_GET['page'] )                ? strtolower( $_GET['page'] )               : false;
63
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
64 64
 
65
-        if ( $page !== 'wpinv-settings' ) {
65
+        if ($page !== 'wpinv-settings') {
66 66
             return;
67 67
         }
68 68
 
69 69
         $settings_tabs = wpinv_get_settings_tabs();
70 70
         $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs;
71
-        $active_tab    = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general';
72
-        $sections      = wpinv_get_settings_tab_sections( $active_tab );
71
+        $active_tab    = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general';
72
+        $sections      = wpinv_get_settings_tab_sections($active_tab);
73 73
         $key           = 'main';
74 74
 
75
-        if ( is_array( $sections ) ) {
76
-            $key = key( $sections );
75
+        if (is_array($sections)) {
76
+            $key = key($sections);
77 77
         }
78 78
 
79
-        $registered_sections = wpinv_get_settings_tab_sections( $active_tab );
80
-        $section             = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? $_GET['section'] : $key;
79
+        $registered_sections = wpinv_get_settings_tab_sections($active_tab);
80
+        $section             = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? $_GET['section'] : $key;
81 81
         ob_start();
82 82
         ?>
83 83
         <div class="wrap">
84 84
             <h1 class="nav-tab-wrapper">
85 85
                 <?php
86
-                foreach( wpinv_get_settings_tabs() as $tab_id => $tab_name ) {
87
-                    $tab_url = add_query_arg( array(
86
+                foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) {
87
+                    $tab_url = add_query_arg(array(
88 88
                         'settings-updated' => false,
89 89
                         'tab' => $tab_id,
90
-                    ) );
90
+                    ));
91 91
 
92 92
                     // Remove the section from the tabs so we always end up at the main section
93
-                    $tab_url = remove_query_arg( 'section', $tab_url );
94
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
93
+                    $tab_url = remove_query_arg('section', $tab_url);
94
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
95 95
 
96 96
                     $active = $active_tab == $tab_id ? ' nav-tab-active' : '';
97 97
 
98
-                    echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">';
99
-                    echo esc_html( $tab_name );
98
+                    echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">';
99
+                    echo esc_html($tab_name);
100 100
                     echo '</a>';
101 101
                 }
102 102
                 ?>
103 103
             </h1>
104 104
             <?php
105
-            $number_of_sections = count( $sections );
105
+            $number_of_sections = count($sections);
106 106
             $number = 0;
107
-            if ( $number_of_sections > 1 ) {
107
+            if ($number_of_sections > 1) {
108 108
                 echo '<div><ul class="subsubsub">';
109
-                foreach( $sections as $section_id => $section_name ) {
109
+                foreach ($sections as $section_id => $section_name) {
110 110
                     echo '<li>';
111 111
                     $number++;
112
-                    $tab_url = add_query_arg( array(
112
+                    $tab_url = add_query_arg(array(
113 113
                         'settings-updated' => false,
114 114
                         'tab' => $active_tab,
115 115
                         'section' => $section_id
116
-                    ) );
117
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
116
+                    ));
117
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
118 118
                     $class = '';
119
-                    if ( $section == $section_id ) {
119
+                    if ($section == $section_id) {
120 120
                         $class = 'current';
121 121
                     }
122
-                    echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>';
122
+                    echo '<a class="' . $class . '" href="' . esc_url($tab_url) . '">' . $section_name . '</a>';
123 123
 
124
-                    if ( $number != $number_of_sections ) {
124
+                    if ($number != $number_of_sections) {
125 125
                         echo ' | ';
126 126
                     }
127 127
                     echo '</li>';
@@ -133,19 +133,19 @@  discard block
 block discarded – undo
133 133
                 <form method="post" action="options.php">
134 134
                     <table class="form-table">
135 135
                         <?php
136
-                        settings_fields( 'wpinv_settings' );
136
+                        settings_fields('wpinv_settings');
137 137
 
138
-                        if ( 'main' === $section ) {
139
-                            do_action( 'wpinv_settings_tab_top', $active_tab );
138
+                        if ('main' === $section) {
139
+                            do_action('wpinv_settings_tab_top', $active_tab);
140 140
                         }
141 141
 
142
-                        do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section );
143
-                        do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section );
144
-                        do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section );
142
+                        do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section);
143
+                        do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section);
144
+                        do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section);
145 145
 
146 146
                         // For backwards compatibility
147
-                        if ( 'main' === $section ) {
148
-                            do_action( 'wpinv_settings_tab_bottom', $active_tab );
147
+                        if ('main' === $section) {
148
+                            do_action('wpinv_settings_tab_bottom', $active_tab);
149 149
                         }
150 150
                         ?>
151 151
                     </table>
@@ -159,52 +159,52 @@  discard block
 block discarded – undo
159 159
     }
160 160
 
161 161
     public function remove_admin_submenus() {
162
-        remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' );
162
+        remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice');
163 163
     }
164 164
 
165
-    public function add_nav_menu_meta_boxes(){
166
-        add_meta_box( 'wpinv_endpoints_nav_link', __( 'Invoicing Pages', 'invoicing' ), array( $this, 'nav_menu_links' ), 'nav-menus', 'side', 'low' );
165
+    public function add_nav_menu_meta_boxes() {
166
+        add_meta_box('wpinv_endpoints_nav_link', __('Invoicing Pages', 'invoicing'), array($this, 'nav_menu_links'), 'nav-menus', 'side', 'low');
167 167
     }
168 168
 
169
-    public function nav_menu_links(){
169
+    public function nav_menu_links() {
170 170
         $endpoints = $this->get_menu_items();
171 171
         ?>
172 172
         <div id="invoicing-endpoints" class="posttypediv">
173
-        <?php if(!empty($endpoints['pages'])){ ?>
173
+        <?php if (!empty($endpoints['pages'])) { ?>
174 174
             <div id="tabs-panel-invoicing-endpoints" class="tabs-panel tabs-panel-active">
175 175
                 <ul id="invoicing-endpoints-checklist" class="categorychecklist form-no-clear">
176 176
                     <?php
177 177
                     $walker = new Walker_Nav_Menu_Checklist(array());
178
-                    echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $endpoints['pages']), 0, (object) array('walker' => $walker));
178
+                    echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $endpoints['pages']), 0, (object)array('walker' => $walker));
179 179
                     ?>
180 180
                 </ul>
181 181
             </div>
182 182
         <?php } ?>
183 183
         <p class="button-controls">
184 184
         <span class="list-controls">
185
-            <a href="<?php echo admin_url( 'nav-menus.php?page-tab=all&selectall=1#invoicing-endpoints' ); ?>" class="select-all"><?php _e( 'Select all', 'invoicing' ); ?></a>
185
+            <a href="<?php echo admin_url('nav-menus.php?page-tab=all&selectall=1#invoicing-endpoints'); ?>" class="select-all"><?php _e('Select all', 'invoicing'); ?></a>
186 186
         </span>
187 187
             <span class="add-to-menu">
188
-            <input type="submit" class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to menu', 'invoicing' ); ?>" name="add-post-type-menu-item" id="submit-invoicing-endpoints">
188
+            <input type="submit" class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to menu', 'invoicing'); ?>" name="add-post-type-menu-item" id="submit-invoicing-endpoints">
189 189
             <span class="spinner"></span>
190 190
         </span>
191 191
         </p>
192 192
         <?php
193 193
     }
194 194
 
195
-    public function get_menu_items(){
195
+    public function get_menu_items() {
196 196
         $items = array();
197 197
 
198
-        $wpinv_history_page_id = (int)wpinv_get_option( 'invoice_history_page' );
199
-        if($wpinv_history_page_id > 0){
198
+        $wpinv_history_page_id = (int)wpinv_get_option('invoice_history_page');
199
+        if ($wpinv_history_page_id > 0) {
200 200
             $item = new stdClass();
201 201
             $item->object_id = $wpinv_history_page_id;
202 202
             $item->db_id = 0;
203
-            $item->object =  'page';
203
+            $item->object = 'page';
204 204
             $item->menu_item_parent = 0;
205 205
             $item->type = 'post_type';
206
-            $item->title = __('Invoice History Page','invoicing');
207
-            $item->url = get_permalink( $wpinv_history_page_id );
206
+            $item->title = __('Invoice History Page', 'invoicing');
207
+            $item->url = get_permalink($wpinv_history_page_id);
208 208
             $item->target = '';
209 209
             $item->attr_title = '';
210 210
             $item->classes = array('wpinv-menu-item');
@@ -213,16 +213,16 @@  discard block
 block discarded – undo
213 213
             $items['pages'][] = $item;
214 214
         }
215 215
 
216
-        $wpinv_sub_history_page_id = (int)wpinv_get_option( 'invoice_subscription_page' );
217
-        if($wpinv_sub_history_page_id > 0){
216
+        $wpinv_sub_history_page_id = (int)wpinv_get_option('invoice_subscription_page');
217
+        if ($wpinv_sub_history_page_id > 0) {
218 218
             $item = new stdClass();
219 219
             $item->object_id = $wpinv_sub_history_page_id;
220 220
             $item->db_id = 0;
221
-            $item->object =  'page';
221
+            $item->object = 'page';
222 222
             $item->menu_item_parent = 0;
223 223
             $item->type = 'post_type';
224
-            $item->title = __('Invoice Subscriptions Page','invoicing');
225
-            $item->url = get_permalink( $wpinv_sub_history_page_id );
224
+            $item->title = __('Invoice Subscriptions Page', 'invoicing');
225
+            $item->url = get_permalink($wpinv_sub_history_page_id);
226 226
             $item->target = '';
227 227
             $item->attr_title = '';
228 228
             $item->classes = array('wpinv-menu-item');
@@ -231,16 +231,16 @@  discard block
 block discarded – undo
231 231
             $items['pages'][] = $item;
232 232
         }
233 233
 
234
-        $wpinv_checkout_page_id = (int)wpinv_get_option( 'checkout_page' );
235
-        if($wpinv_checkout_page_id > 0){
234
+        $wpinv_checkout_page_id = (int)wpinv_get_option('checkout_page');
235
+        if ($wpinv_checkout_page_id > 0) {
236 236
             $item = new stdClass();
237 237
             $item->object_id = $wpinv_checkout_page_id;
238 238
             $item->db_id = 0;
239
-            $item->object =  'page';
239
+            $item->object = 'page';
240 240
             $item->menu_item_parent = 0;
241 241
             $item->type = 'post_type';
242
-            $item->title = __('Checkout Page','invoicing');
243
-            $item->url = get_permalink( $wpinv_checkout_page_id );
242
+            $item->title = __('Checkout Page', 'invoicing');
243
+            $item->url = get_permalink($wpinv_checkout_page_id);
244 244
             $item->target = '';
245 245
             $item->attr_title = '';
246 246
             $item->classes = array('wpinv-menu-item');
@@ -249,16 +249,16 @@  discard block
 block discarded – undo
249 249
             $items['pages'][] = $item;
250 250
         }
251 251
 
252
-        $wpinv_tandc_page_id = (int)wpinv_get_option( 'tandc_page' );
253
-        if($wpinv_tandc_page_id > 0){
252
+        $wpinv_tandc_page_id = (int)wpinv_get_option('tandc_page');
253
+        if ($wpinv_tandc_page_id > 0) {
254 254
             $item = new stdClass();
255 255
             $item->object_id = $wpinv_tandc_page_id;
256 256
             $item->db_id = 0;
257
-            $item->object =  'page';
257
+            $item->object = 'page';
258 258
             $item->menu_item_parent = 0;
259 259
             $item->type = 'post_type';
260
-            $item->title = __('Terms & Conditions','invoicing');
261
-            $item->url = get_permalink( $wpinv_tandc_page_id );
260
+            $item->title = __('Terms & Conditions', 'invoicing');
261
+            $item->url = get_permalink($wpinv_tandc_page_id);
262 262
             $item->target = '';
263 263
             $item->attr_title = '';
264 264
             $item->classes = array('wpinv-menu-item');
@@ -267,16 +267,16 @@  discard block
 block discarded – undo
267 267
             $items['pages'][] = $item;
268 268
         }
269 269
 
270
-        $wpinv_success_page_id = (int)wpinv_get_option( 'success_page' );
271
-        if($wpinv_success_page_id > 0){
270
+        $wpinv_success_page_id = (int)wpinv_get_option('success_page');
271
+        if ($wpinv_success_page_id > 0) {
272 272
             $item = new stdClass();
273 273
             $item->object_id = $wpinv_success_page_id;
274 274
             $item->db_id = 0;
275
-            $item->object =  'page';
275
+            $item->object = 'page';
276 276
             $item->menu_item_parent = 0;
277 277
             $item->type = 'post_type';
278
-            $item->title = __('Success Page','invoicing');
279
-            $item->url = get_permalink( $wpinv_success_page_id );
278
+            $item->title = __('Success Page', 'invoicing');
279
+            $item->url = get_permalink($wpinv_success_page_id);
280 280
             $item->target = '';
281 281
             $item->attr_title = '';
282 282
             $item->classes = array('wpinv-menu-item');
@@ -285,16 +285,16 @@  discard block
 block discarded – undo
285 285
             $items['pages'][] = $item;
286 286
         }
287 287
 
288
-        $wpinv_failure_page_id = (int)wpinv_get_option( 'failure_page' );
289
-        if($wpinv_failure_page_id > 0){
288
+        $wpinv_failure_page_id = (int)wpinv_get_option('failure_page');
289
+        if ($wpinv_failure_page_id > 0) {
290 290
             $item = new stdClass();
291 291
             $item->object_id = $wpinv_failure_page_id;
292 292
             $item->db_id = 0;
293
-            $item->object =  'page';
293
+            $item->object = 'page';
294 294
             $item->menu_item_parent = 0;
295 295
             $item->type = 'post_type';
296
-            $item->title = __('Failed Transaction Page','invoicing');
297
-            $item->url = get_permalink( $wpinv_failure_page_id );
296
+            $item->title = __('Failed Transaction Page', 'invoicing');
297
+            $item->url = get_permalink($wpinv_failure_page_id);
298 298
             $item->target = '';
299 299
             $item->attr_title = '';
300 300
             $item->classes = array('wpinv-menu-item');
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
             $items['pages'][] = $item;
304 304
         }
305 305
 
306
-        return apply_filters( 'wpinv_menu_items', $items );
306
+        return apply_filters('wpinv_menu_items', $items);
307 307
     }
308 308
 
309 309
 }
Please login to merge, or discard this patch.