Passed
Pull Request — master (#450)
by Brian
04:52
created
templates/payment-forms/cart-totals.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -7,16 +7,16 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 // Totals rows.
13 13
 $totals = apply_filters(
14 14
     'getpaid_payment_form_cart_table_totals',
15 15
     array(
16
-        'subtotal' => __( 'Subtotal', 'invoicing' ),
17
-        'tax'      => __( 'Tax', 'invoicing' ),
18
-        'discount' => __( 'Discount', 'invoicing' ),
19
-        'total'    => __( 'Total', 'invoicing' ),
16
+        'subtotal' => __('Subtotal', 'invoicing'),
17
+        'tax'      => __('Tax', 'invoicing'),
18
+        'discount' => __('Discount', 'invoicing'),
19
+        'total'    => __('Total', 'invoicing'),
20 20
     ),
21 21
     $form
22 22
 );
@@ -24,31 +24,31 @@  discard block
 block discarded – undo
24 24
 $currency = $form->get_currency();
25 25
 $country  = wpinv_get_default_country();
26 26
 
27
-if ( ! empty( $form->invoice ) ) {
28
-    $country  = $form->invoice->get_country();
27
+if (!empty($form->invoice)) {
28
+    $country = $form->invoice->get_country();
29 29
 }
30 30
 
31
-if ( ! wpinv_use_taxes() && isset( $totals['tax'] ) ) {
32
-    unset( $totals['tax'] );
31
+if (!wpinv_use_taxes() && isset($totals['tax'])) {
32
+    unset($totals['tax']);
33 33
 }
34 34
 
35
-do_action( 'getpaid_before_payment_form_cart_totals', $form, $totals );
35
+do_action('getpaid_before_payment_form_cart_totals', $form, $totals);
36 36
 
37 37
 ?>
38 38
 <div class='border-top getpaid-payment-form-items-cart-totals'>
39
-    <?php foreach ( $totals as $key => $label ) : ?>
40
-        <div class="getpaid-form-cart-totals-col getpaid-form-cart-totals-<?php echo esc_attr( $key ); ?>">
39
+    <?php foreach ($totals as $key => $label) : ?>
40
+        <div class="getpaid-form-cart-totals-col getpaid-form-cart-totals-<?php echo esc_attr($key); ?>">
41 41
             <div class="row">
42 42
                 <div class="col-12 offset-sm-5 col-sm-3">
43
-                    <?php echo sanitize_text_field( $label ); ?>
43
+                    <?php echo sanitize_text_field($label); ?>
44 44
                 </div>
45
-                <div class="col-12 col-sm-4 getpaid-form-cart-totals-total-<?php echo esc_attr( $key ); ?>">
45
+                <div class="col-12 col-sm-4 getpaid-form-cart-totals-total-<?php echo esc_attr($key); ?>">
46 46
                     <?php
47
-                        do_action( "getpaid_payment_form_cart_totals_$key", $form );
47
+                        do_action("getpaid_payment_form_cart_totals_$key", $form);
48 48
 
49 49
                         // Total tax.
50
-                        if ( in_array( $key, array( 'tax', 'discount', 'subtotal', 'total' ) ) ) {
51
-                            echo wpinv_price( 0, $currency );
50
+                        if (in_array($key, array('tax', 'discount', 'subtotal', 'total'))) {
51
+                            echo wpinv_price(0, $currency);
52 52
                         }
53 53
 
54 54
                     ?>
@@ -59,4 +59,4 @@  discard block
 block discarded – undo
59 59
 </div>
60 60
 
61 61
 <?php
62
-do_action(  'getpaid_payment_form_cart_totals', $form, $totals );
62
+do_action('getpaid_payment_form_cart_totals', $form, $totals);
Please login to merge, or discard this patch.
includes/data/admin-settings.php 1 patch
Spacing   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -8,192 +8,192 @@  discard block
 block discarded – undo
8 8
  * @version 1.0.19
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13
-$pages = wpinv_get_pages( true );
13
+$pages = wpinv_get_pages(true);
14 14
     
15 15
 $currencies = wpinv_get_currencies();
16 16
     
17 17
 $currency_code_options = array();
18
-foreach ( $currencies as $code => $name ) {
19
-    $currency_code_options[ $code ] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol( $code ) . ')';
18
+foreach ($currencies as $code => $name) {
19
+    $currency_code_options[$code] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol($code) . ')';
20 20
 }
21 21
     
22 22
 $due_payment_options       = array();
23
-$due_payment_options[0]    = __( 'Now', 'invoicing' );
24
-for ( $i = 1; $i <= 30; $i++ ) {
23
+$due_payment_options[0]    = __('Now', 'invoicing');
24
+for ($i = 1; $i <= 30; $i++) {
25 25
     $due_payment_options[$i] = $i;
26 26
 }
27 27
     
28 28
 $invoice_number_padd_options = array();
29
-for ( $i = 0; $i <= 20; $i++ ) {
29
+for ($i = 0; $i <= 20; $i++) {
30 30
     $invoice_number_padd_options[$i] = $i;
31 31
 }
32 32
     
33 33
 $currency_symbol = wpinv_currency_symbol();
34 34
     
35 35
 $last_number = $reset_number = '';
36
-if ( $last_invoice_number = get_option( 'wpinv_last_invoice_number' ) ) {
37
-    $last_invoice_number = preg_replace( '/[^0-9]/', '', $last_invoice_number );
36
+if ($last_invoice_number = get_option('wpinv_last_invoice_number')) {
37
+    $last_invoice_number = preg_replace('/[^0-9]/', '', $last_invoice_number);
38 38
 
39
-    if ( !empty( $last_invoice_number ) ) {
40
-        $last_number = ' ' . wp_sprintf( __( "( Last Invoice's sequential number: <b>%s</b> )", 'invoicing' ), $last_invoice_number );
39
+    if (!empty($last_invoice_number)) {
40
+        $last_number = ' ' . wp_sprintf(__("( Last Invoice's sequential number: <b>%s</b> )", 'invoicing'), $last_invoice_number);
41 41
     }
42 42
 
43 43
     $nonce = wp_create_nonce('reset_invoice_count');
44
-    $reset_number = '<a href="'.add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)).'" class="btn button">'.__('Force Reset Sequence', 'invoicing' ). '</a>';
44
+    $reset_number = '<a href="' . add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)) . '" class="btn button">' . __('Force Reset Sequence', 'invoicing') . '</a>';
45 45
 }
46 46
     
47 47
 $alert_wrapper_start = '<p style="color: #F00">';
48 48
 $alert_wrapper_close = '</p>';
49 49
 
50 50
 return array(
51
-    'general' => apply_filters( 'wpinv_settings_general',
51
+    'general' => apply_filters('wpinv_settings_general',
52 52
         array(
53 53
             'main' => array(
54 54
                 'location_settings' => array(
55 55
                     'id'   => 'location_settings',
56
-                    'name' => '<h3>' . __( 'Default Location', 'invoicing' ) . '</h3>',
56
+                    'name' => '<h3>' . __('Default Location', 'invoicing') . '</h3>',
57 57
                     'desc' => '',
58 58
                     'type' => 'header',
59 59
                 ),
60 60
                 'default_country' => array(
61 61
                     'id'      => 'default_country',
62
-                    'name'    => __( 'Default Country', 'invoicing' ),
63
-                    'desc'    => __( 'Where does your store operate from?', 'invoicing' ),
62
+                    'name'    => __('Default Country', 'invoicing'),
63
+                    'desc'    => __('Where does your store operate from?', 'invoicing'),
64 64
                     'type'    => 'select',
65 65
                     'options' => wpinv_get_country_list(),
66 66
                     'std'     => 'GB',
67 67
                     'class'   => 'wpi_select2',
68
-                    'placeholder' => __( 'Select a country', 'invoicing' ),
68
+                    'placeholder' => __('Select a country', 'invoicing'),
69 69
                 ),
70 70
                 'default_state' => array(
71 71
                     'id'      => 'default_state',
72
-                    'name'    => __( 'Default State / Province', 'invoicing' ),
73
-                    'desc'    => __( 'What state / province does your store operate from?', 'invoicing' ),
72
+                    'name'    => __('Default State / Province', 'invoicing'),
73
+                    'desc'    => __('What state / province does your store operate from?', 'invoicing'),
74 74
                     'type'    => 'country_states',
75 75
                     'class'   => 'wpi_select2',
76
-                    'placeholder' => __( 'Select a state', 'invoicing' ),
76
+                    'placeholder' => __('Select a state', 'invoicing'),
77 77
                 ),
78 78
                 'store_name' => array(
79 79
                     'id'   => 'store_name',
80
-                    'name' => __( 'Store Name', 'invoicing' ),
81
-                    'desc' => __( 'Store name to print on invoices.', 'invoicing' ),
80
+                    'name' => __('Store Name', 'invoicing'),
81
+                    'desc' => __('Store name to print on invoices.', 'invoicing'),
82 82
                     'std'     => get_option('blogname'),
83 83
                     'type' => 'text',
84 84
                 ),
85 85
                 'logo' => array(
86 86
                     'id'   => 'logo',
87
-                    'name' => __( 'Logo URL', 'invoicing' ),
88
-                    'desc' => __( 'Store logo to print on invoices.', 'invoicing' ),
87
+                    'name' => __('Logo URL', 'invoicing'),
88
+                    'desc' => __('Store logo to print on invoices.', 'invoicing'),
89 89
                     'type' => 'text',
90 90
                 ),
91 91
                 'store_address' => array(
92 92
                     'id'   => 'store_address',
93
-                    'name' => __( 'Store Address', 'invoicing' ),
94
-                    'desc' => __( 'Enter the store address to display on invoice', 'invoicing' ),
93
+                    'name' => __('Store Address', 'invoicing'),
94
+                    'desc' => __('Enter the store address to display on invoice', 'invoicing'),
95 95
                     'type' => 'textarea',
96 96
                 ),
97 97
                 'page_settings' => array(
98 98
                     'id'   => 'page_settings',
99
-                    'name' => '<h3>' . __( 'Page Settings', 'invoicing' ) . '</h3>',
99
+                    'name' => '<h3>' . __('Page Settings', 'invoicing') . '</h3>',
100 100
                     'desc' => '',
101 101
                     'type' => 'header',
102 102
                 ),
103 103
                 'checkout_page' => array(
104 104
                     'id'          => 'checkout_page',
105
-                    'name'        => __( 'Checkout Page', 'invoicing' ),
106
-                    'desc'        => __( 'This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing' ),
105
+                    'name'        => __('Checkout Page', 'invoicing'),
106
+                    'desc'        => __('This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing'),
107 107
                     'type'        => 'select',
108 108
                     'options'     => $pages,
109 109
                     'class'       => 'wpi_select2',
110
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
110
+                    'placeholder' => __('Select a page', 'invoicing'),
111 111
                 ),
112 112
                 'success_page' => array(
113 113
                     'id'          => 'success_page',
114
-                    'name'        => __( 'Success Page', 'invoicing' ),
115
-                    'desc'        => __( 'This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing' ),
114
+                    'name'        => __('Success Page', 'invoicing'),
115
+                    'desc'        => __('This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing'),
116 116
                     'type'        => 'select',
117 117
                     'options'     => $pages,
118 118
                     'class'       => 'wpi_select2',
119
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
119
+                    'placeholder' => __('Select a page', 'invoicing'),
120 120
                 ),
121 121
                 'failure_page' => array(
122 122
                     'id'          => 'failure_page',
123
-                    'name'        => __( 'Failed Transaction Page', 'invoicing' ),
124
-                    'desc'        => __( 'This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing' ),
123
+                    'name'        => __('Failed Transaction Page', 'invoicing'),
124
+                    'desc'        => __('This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing'),
125 125
                     'type'        => 'select',
126 126
                     'options'     => $pages,
127 127
                     'class'       => 'wpi_select2',
128
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
128
+                    'placeholder' => __('Select a page', 'invoicing'),
129 129
                 ),
130 130
                 'invoice_history_page' => array(
131 131
                     'id'          => 'invoice_history_page',
132
-                    'name'        => __( 'Invoice History Page', 'invoicing' ),
133
-                    'desc'        => __( 'This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing' ),
132
+                    'name'        => __('Invoice History Page', 'invoicing'),
133
+                    'desc'        => __('This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing'),
134 134
                     'type'        => 'select',
135 135
                     'options'     => $pages,
136 136
                     'class'       => 'wpi_select2',
137
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
137
+                    'placeholder' => __('Select a page', 'invoicing'),
138 138
                 ),
139 139
                 'invoice_subscription_page' => array(
140 140
                     'id'          => 'invoice_subscription_page',
141
-                    'name'        => __( 'Invoice Subscriptions Page', 'invoicing' ),
142
-                    'desc'        => __( 'This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing' ),
141
+                    'name'        => __('Invoice Subscriptions Page', 'invoicing'),
142
+                    'desc'        => __('This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing'),
143 143
                     'type'        => 'select',
144 144
                     'options'     => $pages,
145 145
                     'class'       => 'wpi_select2',
146
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
146
+                    'placeholder' => __('Select a page', 'invoicing'),
147 147
                 ),
148 148
             ),
149 149
             'currency_section' => array(
150 150
                 'currency_settings' => array(
151 151
                     'id'   => 'currency_settings',
152
-                    'name' => '<h3>' . __( 'Currency Settings', 'invoicing' ) . '</h3>',
152
+                    'name' => '<h3>' . __('Currency Settings', 'invoicing') . '</h3>',
153 153
                     'desc' => '',
154 154
                     'type' => 'header',
155 155
                 ),
156 156
                 'currency' => array(
157 157
                     'id'      => 'currency',
158
-                    'name'    => __( 'Currency', 'invoicing' ),
159
-                    'desc'    => __( 'Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing' ),
158
+                    'name'    => __('Currency', 'invoicing'),
159
+                    'desc'    => __('Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing'),
160 160
                     'type'    => 'select',
161 161
                     'class'       => 'wpi_select2',
162 162
                     'options' => $currency_code_options,
163 163
                 ),
164 164
                 'currency_position' => array(
165 165
                     'id'      => 'currency_position',
166
-                    'name'    => __( 'Currency Position', 'invoicing' ),
167
-                    'desc'    => __( 'Choose the location of the currency sign.', 'invoicing' ),
166
+                    'name'    => __('Currency Position', 'invoicing'),
167
+                    'desc'    => __('Choose the location of the currency sign.', 'invoicing'),
168 168
                     'type'    => 'select',
169 169
                     'class'   => 'wpi_select2',
170 170
                     'options'  => array(
171
-                        'left'        => __( 'Left', 'invoicing' ) . ' (' . $currency_symbol . wpinv_format_amount( '99.99' ) . ')',
172
-                        'right'       => __( 'Right', 'invoicing' ) . ' ('. wpinv_format_amount( '99.99' ) . $currency_symbol . ')',
173
-                        'left_space'  => __( 'Left with space', 'invoicing' ) . ' (' . $currency_symbol . ' ' . wpinv_format_amount( '99.99' ) . ')',
174
-                        'right_space' => __( 'Right with space', 'invoicing' ) . ' (' . wpinv_format_amount( '99.99' ) . ' ' . $currency_symbol . ')'
171
+                        'left'        => __('Left', 'invoicing') . ' (' . $currency_symbol . wpinv_format_amount('99.99') . ')',
172
+                        'right'       => __('Right', 'invoicing') . ' (' . wpinv_format_amount('99.99') . $currency_symbol . ')',
173
+                        'left_space'  => __('Left with space', 'invoicing') . ' (' . $currency_symbol . ' ' . wpinv_format_amount('99.99') . ')',
174
+                        'right_space' => __('Right with space', 'invoicing') . ' (' . wpinv_format_amount('99.99') . ' ' . $currency_symbol . ')'
175 175
                     )
176 176
                 ),
177 177
                 'thousands_separator' => array(
178 178
                     'id'   => 'thousands_separator',
179
-                    'name' => __( 'Thousands Separator', 'invoicing' ),
180
-                    'desc' => __( 'The symbol (usually , or .) to separate thousands', 'invoicing' ),
179
+                    'name' => __('Thousands Separator', 'invoicing'),
180
+                    'desc' => __('The symbol (usually , or .) to separate thousands', 'invoicing'),
181 181
                     'type' => 'text',
182 182
                     'size' => 'small',
183 183
                     'std'  => ',',
184 184
                 ),
185 185
                 'decimal_separator' => array(
186 186
                     'id'   => 'decimal_separator',
187
-                    'name' => __( 'Decimal Separator', 'invoicing' ),
188
-                    'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'invoicing' ),
187
+                    'name' => __('Decimal Separator', 'invoicing'),
188
+                    'desc' => __('The symbol (usually , or .) to separate decimal points', 'invoicing'),
189 189
                     'type' => 'text',
190 190
                     'size' => 'small',
191 191
                     'std'  => '.',
192 192
                 ),
193 193
                 'decimals' => array(
194 194
                     'id'   => 'decimals',
195
-                    'name' => __( 'Number of Decimals', 'invoicing' ),
196
-                    'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'invoicing' ),
195
+                    'name' => __('Number of Decimals', 'invoicing'),
196
+                    'desc' => __('This sets the number of decimal points shown in displayed prices.', 'invoicing'),
197 197
                     'type' => 'number',
198 198
                     'size' => 'small',
199 199
                     'std'  => '2',
@@ -205,29 +205,29 @@  discard block
 block discarded – undo
205 205
             'labels' => array(
206 206
                 'labels' => array(
207 207
                     'id'   => 'labels_settings',
208
-                    'name' => '<h3>' . __( 'Invoice Labels', 'invoicing' ) . '</h3>',
208
+                    'name' => '<h3>' . __('Invoice Labels', 'invoicing') . '</h3>',
209 209
                     'desc' => '',
210 210
                     'type' => 'header',
211 211
                 ),
212 212
                 'vat_name' => array(
213 213
                     'id' => 'vat_name',
214
-                    'name' => __( 'VAT Name', 'invoicing' ),
215
-                    'desc' => __( 'Enter the VAT name', 'invoicing' ),
214
+                    'name' => __('VAT Name', 'invoicing'),
215
+                    'desc' => __('Enter the VAT name', 'invoicing'),
216 216
                     'type' => 'text',
217 217
                     'size' => 'regular',
218
-                    'std' => __( 'VAT', 'invoicing' ),
218
+                    'std' => __('VAT', 'invoicing'),
219 219
                 ),
220 220
                 'vat_invoice_notice_label' => array(
221 221
                     'id' => 'vat_invoice_notice_label',
222
-                    'name' => __( 'Invoice Notice Label', 'invoicing' ),
223
-                    'desc' => __( 'Use this to add an invoice notice section (label) to your invoices', 'invoicing' ),
222
+                    'name' => __('Invoice Notice Label', 'invoicing'),
223
+                    'desc' => __('Use this to add an invoice notice section (label) to your invoices', 'invoicing'),
224 224
                     'type' => 'text',
225 225
                     'size' => 'regular',
226 226
                 ),
227 227
                 'vat_invoice_notice' => array(
228 228
                     'id' => 'vat_invoice_notice',
229
-                    'name' => __( 'Invoice notice', 'invoicing' ),
230
-                    'desc' =>   __( 'Use this to add an invoice notice section (description) to your invoices', 'invoicing' ),
229
+                    'name' => __('Invoice notice', 'invoicing'),
230
+                    'desc' =>   __('Use this to add an invoice notice section (description) to your invoices', 'invoicing'),
231 231
                     'type' => 'text',
232 232
                     'size' => 'regular',
233 233
                 ),
@@ -239,22 +239,22 @@  discard block
 block discarded – undo
239 239
             'main' => array(
240 240
                 'gateway_settings' => array(
241 241
                     'id'   => 'api_header',
242
-                    'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>',
242
+                    'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>',
243 243
                     'desc' => '',
244 244
                     'type' => 'header',
245 245
                 ),
246 246
                 'gateways' => array(
247 247
                     'id'      => 'gateways',
248
-                    'name'    => __( 'Payment Gateways', 'invoicing' ),
249
-                    'desc'    => __( 'Choose the payment gateways you want to enable.', 'invoicing' ),
248
+                    'name'    => __('Payment Gateways', 'invoicing'),
249
+                    'desc'    => __('Choose the payment gateways you want to enable.', 'invoicing'),
250 250
                     'type'    => 'gateways',
251 251
                     'std'     => array('manual'=>1),
252 252
                     'options' => wpinv_get_payment_gateways(),
253 253
                 ),
254 254
                 'default_gateway' => array(
255 255
                     'id'      => 'default_gateway',
256
-                    'name'    => __( 'Default Gateway', 'invoicing' ),
257
-                    'desc'    => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ),
256
+                    'name'    => __('Default Gateway', 'invoicing'),
257
+                    'desc'    => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'),
258 258
                     'type'    => 'gateway_select',
259 259
                     'std'     => 'manual',
260 260
                     'class'   => 'wpi_select2',
@@ -269,32 +269,32 @@  discard block
 block discarded – undo
269 269
             'main' => array(
270 270
                 'tax_settings' => array(
271 271
                     'id'   => 'tax_settings',
272
-                    'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>',
272
+                    'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>',
273 273
                     'type' => 'header',
274 274
                 ),
275 275
 
276 276
                 'enable_taxes' => array(
277 277
                     'id'       => 'enable_taxes',
278
-                    'name'     => __( 'Enable Taxes', 'invoicing' ),
279
-                    'desc'     => __( 'Enable tax rates and calculations.', 'invoicing' ),
278
+                    'name'     => __('Enable Taxes', 'invoicing'),
279
+                    'desc'     => __('Enable tax rates and calculations.', 'invoicing'),
280 280
                     'type'     => 'checkbox',
281 281
                     'std'      => 0,
282 282
                 ),
283 283
 
284 284
                 'tax_subtotal_rounding' => array(
285 285
                     'id'                => 'tax_subtotal_rounding',
286
-                    'name'              => __( 'Rounding', 'invoicing' ),
287
-                    'desc'              => __( 'Round tax at subtotal level, instead of rounding per tax rate', 'invoicing' ),
286
+                    'name'              => __('Rounding', 'invoicing'),
287
+                    'desc'              => __('Round tax at subtotal level, instead of rounding per tax rate', 'invoicing'),
288 288
                     'type'              => 'checkbox',
289 289
                     'std'               => 1,
290 290
                 ),
291 291
 
292 292
                 'prices_include_tax' => array(
293 293
                     'id'      => 'prices_include_tax',
294
-                    'name'    => __( 'Prices entered with tax', 'invoicing' ),
294
+                    'name'    => __('Prices entered with tax', 'invoicing'),
295 295
                     'options' => array(
296
-                        'yes' => __( 'Yes, I will enter prices inclusive of tax', 'invoicing' ),
297
-                        'no'  => __( 'No, I will enter prices exclusive of tax', 'invoicing' ),
296
+                        'yes' => __('Yes, I will enter prices inclusive of tax', 'invoicing'),
297
+                        'no'  => __('No, I will enter prices exclusive of tax', 'invoicing'),
298 298
                     ),
299 299
                     'type'    => 'select',
300 300
                     'std'     => 'no',
@@ -302,10 +302,10 @@  discard block
 block discarded – undo
302 302
 
303 303
                 'tax_base'              => array(
304 304
                     'id'                => 'tax_base',
305
-                    'name'              => __( 'Calculate tax based on', 'invoicing' ),
305
+                    'name'              => __('Calculate tax based on', 'invoicing'),
306 306
                     'options'           => array(
307
-                        'billing'       => __( 'Customer billing address', 'invoicing' ),
308
-                        'base'          => __( 'Shop base address', 'invoicing' ),
307
+                        'billing'       => __('Customer billing address', 'invoicing'),
308
+                        'base'          => __('Shop base address', 'invoicing'),
309 309
                     ),
310 310
                     'type'              => 'select',
311 311
                     'std'               => 'billing',
@@ -313,10 +313,10 @@  discard block
 block discarded – undo
313 313
 
314 314
                 'tax_display_totals'    => array(
315 315
                     'id'                => 'tax_display_totals',
316
-                    'name'              => __( 'Display tax totals', 'invoicing' ),
316
+                    'name'              => __('Display tax totals', 'invoicing'),
317 317
                     'options'           => array(
318
-                        'single'        => __( 'As a single total', 'invoicing' ),
319
-                        'individual'    => __( 'As individual tax rates', 'invoicing' ),
318
+                        'single'        => __('As a single total', 'invoicing'),
319
+                        'individual'    => __('As individual tax rates', 'invoicing'),
320 320
                     ),
321 321
                     'type'              => 'select',
322 322
                     'std'               => 'individual',
@@ -324,8 +324,8 @@  discard block
 block discarded – undo
324 324
 
325 325
                 'tax_rate' => array(
326 326
                     'id'   => 'tax_rate',
327
-                    'name' => __( 'Fallback Tax Rate', 'invoicing' ),
328
-                    'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ),
327
+                    'name' => __('Fallback Tax Rate', 'invoicing'),
328
+                    'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'),
329 329
                     'type' => 'number',
330 330
                     'size' => 'small',
331 331
                     'min'  => '0',
@@ -337,8 +337,8 @@  discard block
 block discarded – undo
337 337
             'rates' => array(
338 338
                 'tax_rates' => array(
339 339
                     'id'   => 'tax_rates',
340
-                    'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>',
341
-                    'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ),
340
+                    'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>',
341
+                    'desc' => __('Enter tax rates for specific regions.', 'invoicing'),
342 342
                     'type' => 'tax_rates',
343 343
                 ),
344 344
             )
@@ -350,68 +350,68 @@  discard block
 block discarded – undo
350 350
             'main' => array(
351 351
                 'email_settings_header' => array(
352 352
                     'id'   => 'email_settings_header',
353
-                    'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>',
353
+                    'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>',
354 354
                     'type' => 'header',
355 355
                 ),
356 356
                 'email_from_name' => array(
357 357
                     'id'   => 'email_from_name',
358
-                    'name' => __( 'From Name', 'invoicing' ),
359
-                    'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ),
360
-                    'std' => esc_attr( get_bloginfo( 'name', 'display' ) ),
358
+                    'name' => __('From Name', 'invoicing'),
359
+                    'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'),
360
+                    'std' => esc_attr(get_bloginfo('name', 'display')),
361 361
                     'type' => 'text',
362 362
                 ),
363 363
                 'email_from' => array(
364 364
                     'id'   => 'email_from',
365
-                    'name' => __( 'From Email', 'invoicing' ),
366
-                    'desc' => sprintf (__( 'Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing' ), $alert_wrapper_start, $alert_wrapper_close),
367
-                    'std' => get_option( 'admin_email' ),
365
+                    'name' => __('From Email', 'invoicing'),
366
+                    'desc' => sprintf(__('Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing'), $alert_wrapper_start, $alert_wrapper_close),
367
+                    'std' => get_option('admin_email'),
368 368
                     'type' => 'text',
369 369
                 ),
370 370
                 'admin_email' => array(
371 371
                     'id'   => 'admin_email',
372
-                    'name' => __( 'Admin Email', 'invoicing' ),
373
-                    'desc' => __( 'Where should we send admin notifications?', 'invoicing' ),
374
-                    'std' => get_option( 'admin_email' ),
372
+                    'name' => __('Admin Email', 'invoicing'),
373
+                    'desc' => __('Where should we send admin notifications?', 'invoicing'),
374
+                    'std' => get_option('admin_email'),
375 375
                     'type' => 'text',
376 376
                 ),
377 377
                 'overdue_settings_header' => array(
378 378
                     'id'   => 'overdue_settings_header',
379
-                    'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>',
379
+                    'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>',
380 380
                     'type' => 'header',
381 381
                 ),
382 382
                 'overdue_active' => array(
383 383
                     'id'   => 'overdue_active',
384
-                    'name' => __( 'Enable Due Date', 'invoicing' ),
385
-                    'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ),
384
+                    'name' => __('Enable Due Date', 'invoicing'),
385
+                    'desc' => __('Check this to enable due date option for invoices.', 'invoicing'),
386 386
                     'type' => 'checkbox',
387 387
                     'std'  => false,
388 388
                 ),
389 389
                 'overdue_days' => array(
390 390
                     'id'          => 'overdue_days',
391
-                    'name'        => __( 'Default Due Date', 'invoicing' ),
392
-                    'desc'        => __( 'Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing' ),
391
+                    'name'        => __('Default Due Date', 'invoicing'),
392
+                    'desc'        => __('Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing'),
393 393
                     'type'        => 'select',
394 394
                     'options'     => $due_payment_options,
395 395
                     'std'         => 0,
396
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
396
+                    'placeholder' => __('Select a page', 'invoicing'),
397 397
                 ),
398 398
                 'email_template_header' => array(
399 399
                     'id'   => 'email_template_header',
400
-                    'name' => '<h3>' . __( 'Email Template', 'invoicing' ) . '</h3>',
400
+                    'name' => '<h3>' . __('Email Template', 'invoicing') . '</h3>',
401 401
                     'type' => 'header',
402 402
                 ),
403 403
                 'email_header_image' => array(
404 404
                     'id'   => 'email_header_image',
405
-                    'name' => __( 'Header Image', 'invoicing' ),
406
-                    'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing' ),
405
+                    'name' => __('Header Image', 'invoicing'),
406
+                    'desc' => __('URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing'),
407 407
                     'std' => '',
408 408
                     'type' => 'text',
409 409
                 ),
410 410
                 'email_footer_text' => array(
411 411
                     'id'   => 'email_footer_text',
412
-                    'name' => __( 'Footer Text', 'invoicing' ),
413
-                    'desc' => __( 'The text to appear in the footer of all invoice emails.', 'invoicing' ),
414
-                    'std' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GeoDirectory', 'invoicing' ),
412
+                    'name' => __('Footer Text', 'invoicing'),
413
+                    'desc' => __('The text to appear in the footer of all invoice emails.', 'invoicing'),
414
+                    'std' => get_bloginfo('name', 'display') . ' - ' . __('Powered by GeoDirectory', 'invoicing'),
415 415
                     'type' => 'textarea',
416 416
                     'class' => 'regular-text',
417 417
                     'rows' => 2,
@@ -419,29 +419,29 @@  discard block
 block discarded – undo
419 419
                 ),
420 420
                 'email_base_color' => array(
421 421
                     'id'   => 'email_base_color',
422
-                    'name' => __( 'Base Color', 'invoicing' ),
423
-                    'desc' => __( 'The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing' ),
422
+                    'name' => __('Base Color', 'invoicing'),
423
+                    'desc' => __('The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing'),
424 424
                     'std' => '#557da2',
425 425
                     'type' => 'color',
426 426
                 ),
427 427
                 'email_background_color' => array(
428 428
                     'id'   => 'email_background_color',
429
-                    'name' => __( 'Background Color', 'invoicing' ),
430
-                    'desc' => __( 'The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing' ),
429
+                    'name' => __('Background Color', 'invoicing'),
430
+                    'desc' => __('The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing'),
431 431
                     'std' => '#f5f5f5',
432 432
                     'type' => 'color',
433 433
                 ),
434 434
                 'email_body_background_color' => array(
435 435
                     'id'   => 'email_body_background_color',
436
-                    'name' => __( 'Body Background Color', 'invoicing' ),
437
-                    'desc' => __( 'The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing' ),
436
+                    'name' => __('Body Background Color', 'invoicing'),
437
+                    'desc' => __('The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing'),
438 438
                     'std' => '#fdfdfd',
439 439
                     'type' => 'color',
440 440
                 ),
441 441
                 'email_text_color' => array(
442 442
                     'id'   => 'email_text_color',
443
-                    'name' => __( 'Body Text Color', 'invoicing' ),
444
-                    'desc' => __( 'The main body text color. Default <code>#505050</code>.', 'invoicing' ),
443
+                    'name' => __('Body Text Color', 'invoicing'),
444
+                    'desc' => __('The main body text color. Default <code>#505050</code>.', 'invoicing'),
445 445
                     'std' => '#505050',
446 446
                     'type' => 'color',
447 447
                 ),
@@ -460,17 +460,17 @@  discard block
 block discarded – undo
460 460
             'main' => array(
461 461
                 'invoicing_privacy_policy_settings' => array(
462 462
                     'id'   => 'invoicing_privacy_policy_settings',
463
-                    'name' => '<h3>' . __( 'Privacy Policy', 'invoicing' ) . '</h3>',
463
+                    'name' => '<h3>' . __('Privacy Policy', 'invoicing') . '</h3>',
464 464
                     'type' => 'header',
465 465
                 ),
466 466
                 'privacy_page' => array(
467 467
                     'id'          => 'privacy_page',
468
-                    'name'        => __( 'Privacy Page', 'invoicing' ),
469
-                    'desc'        => __( 'If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing' ),
468
+                    'name'        => __('Privacy Page', 'invoicing'),
469
+                    'desc'        => __('If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing'),
470 470
                     'type'        => 'select',
471
-                    'options'     => wpinv_get_pages( true,  __( 'Select a page', 'invoicing' )),
471
+                    'options'     => wpinv_get_pages(true, __('Select a page', 'invoicing')),
472 472
                     'class'       => 'wpi_select2',
473
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
473
+                    'placeholder' => __('Select a page', 'invoicing'),
474 474
                 ),
475 475
             ),
476 476
         )
@@ -481,19 +481,19 @@  discard block
 block discarded – undo
481 481
             'main' => array(
482 482
                 'invoice_number_format_settings' => array(
483 483
                     'id'   => 'invoice_number_format_settings',
484
-                    'name' => '<h3>' . __( 'Invoice Number', 'invoicing' ) . '</h3>',
484
+                    'name' => '<h3>' . __('Invoice Number', 'invoicing') . '</h3>',
485 485
                     'type' => 'header',
486 486
                 ),
487 487
                 'sequential_invoice_number' => array(
488 488
                     'id'   => 'sequential_invoice_number',
489
-                    'name' => __( 'Sequential Invoice Numbers', 'invoicing' ),
490
-                    'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing' ) . $reset_number,
489
+                    'name' => __('Sequential Invoice Numbers', 'invoicing'),
490
+                    'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing') . $reset_number,
491 491
                     'type' => 'checkbox',
492 492
                 ),
493 493
                 'invoice_sequence_start' => array(
494 494
                     'id'   => 'invoice_sequence_start',
495
-                    'name' => __( 'Sequential Starting Number', 'invoicing' ),
496
-                    'desc' => __( 'The number at which the invoice number sequence should begin.', 'invoicing' ) . $last_number,
495
+                    'name' => __('Sequential Starting Number', 'invoicing'),
496
+                    'desc' => __('The number at which the invoice number sequence should begin.', 'invoicing') . $last_number,
497 497
                     'type' => 'number',
498 498
                     'size' => 'small',
499 499
                     'std'  => '1',
@@ -501,8 +501,8 @@  discard block
 block discarded – undo
501 501
                 ),
502 502
                 'invoice_number_padd' => array(
503 503
                     'id'      => 'invoice_number_padd',
504
-                    'name'    => __( 'Minimum Digits', 'invoicing' ),
505
-                    'desc'    => __( 'If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing' ),
504
+                    'name'    => __('Minimum Digits', 'invoicing'),
505
+                    'desc'    => __('If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing'),
506 506
                     'type'    => 'select',
507 507
                     'options' => $invoice_number_padd_options,
508 508
                     'std'     => 5,
@@ -510,8 +510,8 @@  discard block
 block discarded – undo
510 510
                 ),
511 511
                 'invoice_number_prefix' => array(
512 512
                     'id' => 'invoice_number_prefix',
513
-                    'name' => __( 'Invoice Number Prefix', 'invoicing' ),
514
-                    'desc' => __( 'Prefix for all invoice numbers. Ex: INV-', 'invoicing' ),
513
+                    'name' => __('Invoice Number Prefix', 'invoicing'),
514
+                    'desc' => __('Prefix for all invoice numbers. Ex: INV-', 'invoicing'),
515 515
                     'type' => 'text',
516 516
                     'size' => 'regular',
517 517
                     'std' => 'INV-',
@@ -519,41 +519,41 @@  discard block
 block discarded – undo
519 519
                 ),
520 520
                 'invoice_number_postfix' => array(
521 521
                     'id' => 'invoice_number_postfix',
522
-                    'name' => __( 'Invoice Number Postfix', 'invoicing' ),
523
-                    'desc' => __( 'Postfix for all invoice numbers.', 'invoicing' ),
522
+                    'name' => __('Invoice Number Postfix', 'invoicing'),
523
+                    'desc' => __('Postfix for all invoice numbers.', 'invoicing'),
524 524
                     'type' => 'text',
525 525
                     'size' => 'regular',
526 526
                     'std' => ''
527 527
                 ),
528 528
                 'checkout_settings' => array(
529 529
                     'id'   => 'checkout_settings',
530
-                    'name' => '<h3>' . __( 'Checkout Settings', 'invoicing' ) . '</h3>',
530
+                    'name' => '<h3>' . __('Checkout Settings', 'invoicing') . '</h3>',
531 531
                     'type' => 'header',
532 532
                 ),
533 533
                 'login_to_checkout' => array(
534 534
                     'id'   => 'login_to_checkout',
535
-                    'name' => __( 'Require Login To Checkout', 'invoicing' ),
536
-                    'desc' => __( 'If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing' ),
535
+                    'name' => __('Require Login To Checkout', 'invoicing'),
536
+                    'desc' => __('If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing'),
537 537
                     'type' => 'checkbox',
538 538
                 ),
539 539
 
540 540
                 'maxmind_license_key' => array(
541 541
                     'id'   => 'maxmind_license_key',
542
-                    'name' => __( 'MaxMind License Key', 'invoicing' ),
542
+                    'name' => __('MaxMind License Key', 'invoicing'),
543 543
                     'type' => 'text',
544 544
                     'size' => 'regular',
545
-                    'desc' => __( "Enter you license key if you would like to use MaxMind to automatically detect a customer's country.", 'invoicing' ) . ' <a href="https://support.maxmind.com/account-faq/license-keys/how-do-i-generate-a-license-key/">' . __( 'How to generate a free license key.', 'invoicing' ) . '</a>',
545
+                    'desc' => __("Enter you license key if you would like to use MaxMind to automatically detect a customer's country.", 'invoicing') . ' <a href="https://support.maxmind.com/account-faq/license-keys/how-do-i-generate-a-license-key/">' . __('How to generate a free license key.', 'invoicing') . '</a>',
546 546
                 ),
547 547
 
548 548
                 'uninstall_settings' => array(
549 549
                     'id'   => 'uninstall_settings',
550
-                    'name' => '<h3>' . __( 'Uninstall Settings', 'invoicing' ) . '</h3>',
550
+                    'name' => '<h3>' . __('Uninstall Settings', 'invoicing') . '</h3>',
551 551
                     'type' => 'header',
552 552
                 ),
553 553
                 'remove_data_on_unistall' => array(
554 554
                     'id'   => 'remove_data_on_unistall',
555
-                    'name' => __( 'Remove Data on Uninstall?', 'invoicing' ),
556
-                    'desc' => __( 'Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing' ),
555
+                    'name' => __('Remove Data on Uninstall?', 'invoicing'),
556
+                    'desc' => __('Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing'),
557 557
                     'type' => 'checkbox',
558 558
                     'std'  => ''
559 559
                 ),
@@ -562,13 +562,13 @@  discard block
 block discarded – undo
562 562
             'custom-css' => array(
563 563
                 'css_settings' => array(
564 564
                     'id'   => 'css_settings',
565
-                    'name' => '<h3>' . __( 'Custom CSS', 'invoicing' ) . '</h3>',
565
+                    'name' => '<h3>' . __('Custom CSS', 'invoicing') . '</h3>',
566 566
                     'type' => 'header',
567 567
                 ),
568 568
                 'template_custom_css' => array(
569 569
                     'id' => 'template_custom_css',
570
-                    'name' => __( 'Invoice Template CSS', 'invoicing' ),
571
-                    'desc' => __( 'Add CSS to modify appearance of the print invoice page.', 'invoicing' ),
570
+                    'name' => __('Invoice Template CSS', 'invoicing'),
571
+                    'desc' => __('Add CSS to modify appearance of the print invoice page.', 'invoicing'),
572 572
                     'type' => 'textarea',
573 573
                     'class'=> 'regular-text',
574 574
                     'rows' => 10,
@@ -582,8 +582,8 @@  discard block
 block discarded – undo
582 582
             'main' => array(
583 583
                 'tool_settings' => array(
584 584
                     'id'   => 'tool_settings',
585
-                    'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>',
586
-                    'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ),
585
+                    'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>',
586
+                    'desc' => __('Invoicing diagnostic tools', 'invoicing'),
587 587
                     'type' => 'tools',
588 588
                 ),
589 589
             ),
Please login to merge, or discard this patch.
includes/wpinv-tax-functions.php 3 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -192,16 +192,16 @@
 block discarded – undo
192 192
 function getpaid_prepare_item_tax( $item, $tax_name, $tax_amount, $recurring_tax_amount ) {
193 193
 
194 194
     $initial_tax   = $tax_amount;
195
-	$recurring_tax = 0;
195
+    $recurring_tax = 0;
196 196
 
197 197
     if ( $item->is_recurring() ) {
198
-		$recurring_tax = $recurring_tax_amount;
199
-	}
198
+        $recurring_tax = $recurring_tax_amount;
199
+    }
200 200
 
201
-	return array(
202
-		'name'          => sanitize_text_field( $tax_name ),
203
-		'initial_tax'   => $initial_tax,
204
-		'recurring_tax' => $recurring_tax,
201
+    return array(
202
+        'name'          => sanitize_text_field( $tax_name ),
203
+        'initial_tax'   => $initial_tax,
204
+        'recurring_tax' => $recurring_tax,
205 205
     );
206 206
 
207 207
 }
Please login to merge, or discard this patch.
Spacing   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Returns the tax class objet.
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
  * 
21 21
  * @return bool
22 22
  */
23
-function getpaid_is_eu_state( $country ) {
24
-    return WPInv_EUVat::is_eu_state( $country );
23
+function getpaid_is_eu_state($country) {
24
+    return WPInv_EUVat::is_eu_state($country);
25 25
 }
26 26
 
27 27
 /**
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
  * 
30 30
  * @return bool
31 31
  */
32
-function getpaid_is_gst_country( $country ) {
33
-    return WPInv_EUVat::is_gst_country( $country );
32
+function getpaid_is_gst_country($country) {
33
+    return WPInv_EUVat::is_gst_country($country);
34 34
 }
35 35
 
36 36
 /**
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
  */
50 50
 function wpinv_use_taxes() {
51 51
 
52
-    $ret = wpinv_get_option( 'enable_taxes', false );
53
-    return (bool) apply_filters( 'wpinv_use_taxes', ! empty( $ret ) );
52
+    $ret = wpinv_get_option('enable_taxes', false);
53
+    return (bool) apply_filters('wpinv_use_taxes', !empty($ret));
54 54
 
55 55
 }
56 56
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
  * @param WPInv_Invoice $invoice
61 61
  * @return bool
62 62
  */
63
-function wpinv_is_invoice_taxable( $invoice ) {
63
+function wpinv_is_invoice_taxable($invoice) {
64 64
     return $invoice->is_taxable();
65 65
 }
66 66
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
  * @param WPInv_Item|GetPaid_Form_Item $item
71 71
  * @return bool
72 72
  */
73
-function wpinv_is_item_taxable( $item ) {
73
+function wpinv_is_item_taxable($item) {
74 74
     return '_exempt' != $item->get_vat_rule();
75 75
 }
76 76
 
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
  * @return bool
81 81
  */
82 82
 function wpinv_use_store_address_as_tax_base() {
83
-    $use_base = wpinv_get_option( 'tax_base', 'billing' ) == 'base';
84
-    return (bool) apply_filters( 'wpinv_use_store_address_as_tax_base', $use_base );
83
+    $use_base = wpinv_get_option('tax_base', 'billing') == 'base';
84
+    return (bool) apply_filters('wpinv_use_store_address_as_tax_base', $use_base);
85 85
 }
86 86
 
87 87
 /**
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
  * @return bool
91 91
  */
92 92
 function wpinv_prices_include_tax() {
93
-    $is_inclusive = wpinv_get_option( 'prices_include_tax', 'no' ) == 'yes';
94
-    return (bool) apply_filters( 'wpinv_prices_include_tax', $is_inclusive );
93
+    $is_inclusive = wpinv_get_option('prices_include_tax', 'no') == 'yes';
94
+    return (bool) apply_filters('wpinv_prices_include_tax', $is_inclusive);
95 95
 }
96 96
 
97 97
 /**
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
  * @return bool
101 101
  */
102 102
 function wpinv_round_tax_per_tax_rate() {
103
-    $subtotal_rounding = wpinv_get_option( 'tax_subtotal_rounding', 1 );
104
-    return (bool) apply_filters( 'wpinv_round_tax_per_tax_rate', empty( $subtotal_rounding ) );
103
+    $subtotal_rounding = wpinv_get_option('tax_subtotal_rounding', 1);
104
+    return (bool) apply_filters('wpinv_round_tax_per_tax_rate', empty($subtotal_rounding));
105 105
 }
106 106
 
107 107
 /**
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
  * @return bool
111 111
  */
112 112
 function wpinv_display_individual_tax_rates() {
113
-    $individual = wpinv_get_option( 'tax_display_totals', 'single' ) == 'individual';
114
-    return (bool) apply_filters( 'wpinv_display_individual_tax_rates', $individual );
113
+    $individual = wpinv_get_option('tax_display_totals', 'single') == 'individual';
114
+    return (bool) apply_filters('wpinv_display_individual_tax_rates', $individual);
115 115
 }
116 116
 
117 117
 /**
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
  * @return float
121 121
  */
122 122
 function wpinv_get_default_tax_rate() {
123
-    $rate = wpinv_get_option( 'tax_rate', false );
124
-    return (float) apply_filters( 'wpinv_get_default_tax_rate', floatval( $rate ) );
123
+    $rate = wpinv_get_option('tax_rate', false);
124
+    return (float) apply_filters('wpinv_get_default_tax_rate', floatval($rate));
125 125
 }
126 126
 
127 127
 /**
@@ -141,28 +141,28 @@  discard block
 block discarded – undo
141 141
  * @param string $state
142 142
  * @return array
143 143
  */
144
-function getpaid_get_item_tax_rates( $item, $country = '', $state = '' ) {
144
+function getpaid_get_item_tax_rates($item, $country = '', $state = '') {
145 145
 
146 146
     // Abort if the item is not taxable.
147
-    if ( ! wpinv_is_item_taxable( $item ) ) {
147
+    if (!wpinv_is_item_taxable($item)) {
148 148
         return array();
149 149
     }
150 150
 
151 151
     // Maybe use the store address.
152
-    if ( wpinv_use_store_address_as_tax_base() ) {
152
+    if (wpinv_use_store_address_as_tax_base()) {
153 153
         $country = wpinv_get_default_country();
154 154
         $state   = wpinv_get_default_state();
155 155
     }
156 156
 
157 157
     // Retrieve tax rates.
158
-    $tax_rates = GetPaid_Tax::get_address_tax_rates( $country, $state );
158
+    $tax_rates = GetPaid_Tax::get_address_tax_rates($country, $state);
159 159
 
160 160
     // Fallback to the default tax rates if non were found.
161
-    if ( empty( $tax_rates ) ) {
161
+    if (empty($tax_rates)) {
162 162
         $tax_rates = GetPaid_Tax::get_default_tax_rates();
163 163
     }
164 164
 
165
-    return apply_filters( 'getpaid_get_item_tax_rates', $tax_rates, $item, $country, $state );
165
+    return apply_filters('getpaid_get_item_tax_rates', $tax_rates, $item, $country, $state);
166 166
 }
167 167
 
168 168
 /**
@@ -172,12 +172,12 @@  discard block
 block discarded – undo
172 172
  * @param array $rates
173 173
  * @return array
174 174
  */
175
-function getpaid_calculate_item_taxes( $amount, $rates ) {
175
+function getpaid_calculate_item_taxes($amount, $rates) {
176 176
 
177 177
     $is_inclusive = wpinv_prices_include_tax();
178
-    $taxes        = GetPaid_Tax::calc_tax( $amount, $rates, $is_inclusive );
178
+    $taxes        = GetPaid_Tax::calc_tax($amount, $rates, $is_inclusive);
179 179
 
180
-    return apply_filters( 'getpaid_calculate_taxes', $taxes, $amount, $rates );
180
+    return apply_filters('getpaid_calculate_taxes', $taxes, $amount, $rates);
181 181
 }
182 182
 
183 183
 /**
@@ -189,53 +189,53 @@  discard block
 block discarded – undo
189 189
  * @param float $recurring_tax_amount
190 190
  * @return array
191 191
  */
192
-function getpaid_prepare_item_tax( $item, $tax_name, $tax_amount, $recurring_tax_amount ) {
192
+function getpaid_prepare_item_tax($item, $tax_name, $tax_amount, $recurring_tax_amount) {
193 193
 
194
-    $initial_tax   = $tax_amount;
194
+    $initial_tax = $tax_amount;
195 195
 	$recurring_tax = 0;
196 196
 
197
-    if ( $item->is_recurring() ) {
197
+    if ($item->is_recurring()) {
198 198
 		$recurring_tax = $recurring_tax_amount;
199 199
 	}
200 200
 
201 201
 	return array(
202
-		'name'          => sanitize_text_field( $tax_name ),
202
+		'name'          => sanitize_text_field($tax_name),
203 203
 		'initial_tax'   => $initial_tax,
204 204
 		'recurring_tax' => $recurring_tax,
205 205
     );
206 206
 
207 207
 }
208 208
 
209
-function wpinv_sales_tax_for_year( $year = null ) {
210
-    return wpinv_price( wpinv_format_amount( wpinv_get_sales_tax_for_year( $year ) ) );
209
+function wpinv_sales_tax_for_year($year = null) {
210
+    return wpinv_price(wpinv_format_amount(wpinv_get_sales_tax_for_year($year)));
211 211
 }
212 212
 
213
-function wpinv_get_sales_tax_for_year( $year = null ) {
213
+function wpinv_get_sales_tax_for_year($year = null) {
214 214
     global $wpdb;
215 215
 
216 216
     // Start at zero
217 217
     $tax = 0;
218 218
 
219
-    if ( ! empty( $year ) ) {
219
+    if (!empty($year)) {
220 220
         $args = array(
221 221
             'post_type'      => 'wpi_invoice',
222
-            'post_status'    => array( 'publish' ),
222
+            'post_status'    => array('publish'),
223 223
             'posts_per_page' => -1,
224 224
             'year'           => $year,
225 225
             'fields'         => 'ids'
226 226
         );
227 227
 
228
-        $payments    = get_posts( $args );
229
-        $payment_ids = implode( ',', $payments );
228
+        $payments    = get_posts($args);
229
+        $payment_ids = implode(',', $payments);
230 230
 
231
-        if ( count( $payments ) > 0 ) {
231
+        if (count($payments) > 0) {
232 232
             $sql = "SELECT SUM( meta_value ) FROM $wpdb->postmeta WHERE meta_key = '_wpinv_tax' AND post_id IN( $payment_ids )";
233
-            $tax = $wpdb->get_var( $sql );
233
+            $tax = $wpdb->get_var($sql);
234 234
         }
235 235
 
236 236
     }
237 237
 
238
-    return apply_filters( 'wpinv_get_sales_tax_for_year', $tax, $year );
238
+    return apply_filters('wpinv_get_sales_tax_for_year', $tax, $year);
239 239
 }
240 240
 
241 241
 function wpinv_is_cart_taxed() {
@@ -244,33 +244,33 @@  discard block
 block discarded – undo
244 244
 
245 245
 function wpinv_prices_show_tax_on_checkout() {
246 246
     return false; // TODO
247
-    $ret = ( wpinv_get_option( 'checkout_include_tax', false ) == 'yes' && wpinv_use_taxes() );
247
+    $ret = (wpinv_get_option('checkout_include_tax', false) == 'yes' && wpinv_use_taxes());
248 248
 
249
-    return apply_filters( 'wpinv_taxes_on_prices_on_checkout', $ret );
249
+    return apply_filters('wpinv_taxes_on_prices_on_checkout', $ret);
250 250
 }
251 251
 
252 252
 function wpinv_display_tax_rate() {
253
-    $ret = wpinv_use_taxes() && wpinv_get_option( 'display_tax_rate', false );
253
+    $ret = wpinv_use_taxes() && wpinv_get_option('display_tax_rate', false);
254 254
 
255
-    return apply_filters( 'wpinv_display_tax_rate', $ret );
255
+    return apply_filters('wpinv_display_tax_rate', $ret);
256 256
 }
257 257
 
258 258
 function wpinv_cart_needs_tax_address_fields() {
259
-    if( !wpinv_is_cart_taxed() )
259
+    if (!wpinv_is_cart_taxed())
260 260
         return false;
261 261
 
262
-    return ! did_action( 'wpinv_after_cc_fields', 'wpinv_default_cc_address_fields' );
262
+    return !did_action('wpinv_after_cc_fields', 'wpinv_default_cc_address_fields');
263 263
 }
264 264
 
265
-function wpinv_item_is_tax_exclusive( $item_id = 0 ) {
266
-    $ret = (bool)get_post_meta( $item_id, '_wpinv_tax_exclusive', false );
267
-    return apply_filters( 'wpinv_is_tax_exclusive', $ret, $item_id );
265
+function wpinv_item_is_tax_exclusive($item_id = 0) {
266
+    $ret = (bool) get_post_meta($item_id, '_wpinv_tax_exclusive', false);
267
+    return apply_filters('wpinv_is_tax_exclusive', $ret, $item_id);
268 268
 }
269 269
 
270
-function wpinv_currency_decimal_filter( $decimals = 2 ) {
270
+function wpinv_currency_decimal_filter($decimals = 2) {
271 271
     $currency = wpinv_get_currency();
272 272
 
273
-    switch ( $currency ) {
273
+    switch ($currency) {
274 274
         case 'RIAL' :
275 275
         case 'JPY' :
276 276
         case 'TWD' :
@@ -279,50 +279,50 @@  discard block
 block discarded – undo
279 279
             break;
280 280
     }
281 281
 
282
-    return apply_filters( 'wpinv_currency_decimal_count', $decimals, $currency );
282
+    return apply_filters('wpinv_currency_decimal_count', $decimals, $currency);
283 283
 }
284 284
 
285 285
 function wpinv_tax_amount() {
286 286
     $output = 0.00;
287 287
     
288
-    return apply_filters( 'wpinv_tax_amount', $output );
288
+    return apply_filters('wpinv_tax_amount', $output);
289 289
 }
290 290
 
291 291
 // VAT Settings
292
-function wpinv_vat_rate_add_callback( $args ) {
292
+function wpinv_vat_rate_add_callback($args) {
293 293
     ?>
294
-    <p class="wpi-vat-rate-actions"><input id="wpi_vat_rate_add" type="button" value="<?php esc_attr_e( 'Add', 'invoicing' );?>" class="button button-primary" />&nbsp;&nbsp;<i style="display:none;" class="fa fa-refresh fa-spin"></i></p>
294
+    <p class="wpi-vat-rate-actions"><input id="wpi_vat_rate_add" type="button" value="<?php esc_attr_e('Add', 'invoicing'); ?>" class="button button-primary" />&nbsp;&nbsp;<i style="display:none;" class="fa fa-refresh fa-spin"></i></p>
295 295
     <?php
296 296
 }
297 297
 
298
-function wpinv_vat_rate_delete_callback( $args ) {
298
+function wpinv_vat_rate_delete_callback($args) {
299 299
     global $wpinv_euvat;
300 300
     
301 301
     $vat_classes = $wpinv_euvat->get_rate_classes();
302
-    $vat_class = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' && isset( $vat_classes[$_REQUEST['wpi_sub']] )? sanitize_text_field( $_REQUEST['wpi_sub'] ) : '';
303
-    if ( isset( $vat_classes[$vat_class] ) ) {
302
+    $vat_class = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' && isset($vat_classes[$_REQUEST['wpi_sub']]) ? sanitize_text_field($_REQUEST['wpi_sub']) : '';
303
+    if (isset($vat_classes[$vat_class])) {
304 304
     ?>
305
-    <p class="wpi-vat-rate-actions"><input id="wpi_vat_rate_delete" type="button" value="<?php echo wp_sprintf( esc_attr__( 'Delete class "%s"', 'invoicing' ), $vat_classes[$vat_class] );?>" class="button button-primary" />&nbsp;&nbsp;<i style="display:none;" class="fa fa-refresh fa-spin"></i></p>
305
+    <p class="wpi-vat-rate-actions"><input id="wpi_vat_rate_delete" type="button" value="<?php echo wp_sprintf(esc_attr__('Delete class "%s"', 'invoicing'), $vat_classes[$vat_class]); ?>" class="button button-primary" />&nbsp;&nbsp;<i style="display:none;" class="fa fa-refresh fa-spin"></i></p>
306 306
     <?php
307 307
     }
308 308
 }
309 309
 
310
-function wpinv_vat_rates_callback( $args ) {
310
+function wpinv_vat_rates_callback($args) {
311 311
     global $wpinv_euvat;
312 312
     
313 313
     $vat_classes    = $wpinv_euvat->get_rate_classes();
314
-    $vat_class      = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' && isset( $vat_classes[$_REQUEST['wpi_sub']] )? sanitize_text_field( $_REQUEST['wpi_sub'] ) : '_standard';
314
+    $vat_class      = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' && isset($vat_classes[$_REQUEST['wpi_sub']]) ? sanitize_text_field($_REQUEST['wpi_sub']) : '_standard';
315 315
     
316 316
     $eu_states      = $wpinv_euvat->get_eu_states();
317 317
     $countries      = wpinv_get_country_list();
318 318
     $vat_groups     = $wpinv_euvat->get_vat_groups();
319
-    $rates          = $wpinv_euvat->get_vat_rates( $vat_class );
319
+    $rates          = $wpinv_euvat->get_vat_rates($vat_class);
320 320
     ob_start();
321 321
 ?>
322 322
 </td><tr>
323 323
     <td colspan="2" class="wpinv_vat_tdbox">
324
-    <input type="hidden" name="wpi_vat_class" value="<?php echo $vat_class;?>" />
325
-    <p><?php echo ( isset( $args['desc'] ) ? $args['desc'] : '' ); ?></p>
324
+    <input type="hidden" name="wpi_vat_class" value="<?php echo $vat_class; ?>" />
325
+    <p><?php echo (isset($args['desc']) ? $args['desc'] : ''); ?></p>
326 326
     <table id="wpinv_vat_rates" class="wp-list-table widefat fixed posts">
327 327
         <colgroup>
328 328
             <col width="50px" />
@@ -334,43 +334,43 @@  discard block
 block discarded – undo
334 334
         </colgroup>
335 335
         <thead>
336 336
             <tr>
337
-                <th scope="col" colspan="2" class="wpinv_vat_country_name"><?php _e( 'Country', 'invoicing' ); ?></th>
338
-                <th scope="col" class="wpinv_vat_global" title="<?php esc_attr_e( 'Apply rate to whole country', 'invoicing' ); ?>"><?php _e( 'Country Wide', 'invoicing' ); ?></th>
339
-                <th scope="col" class="wpinv_vat_rate"><?php _e( 'Rate %', 'invoicing' ); ?></th> 
340
-                <th scope="col" class="wpinv_vat_name"><?php _e( 'VAT Name', 'invoicing' ); ?></th>
341
-                <th scope="col" class="wpinv_vat_group"><?php _e( 'Tax Group', 'invoicing' ); ?></th>
337
+                <th scope="col" colspan="2" class="wpinv_vat_country_name"><?php _e('Country', 'invoicing'); ?></th>
338
+                <th scope="col" class="wpinv_vat_global" title="<?php esc_attr_e('Apply rate to whole country', 'invoicing'); ?>"><?php _e('Country Wide', 'invoicing'); ?></th>
339
+                <th scope="col" class="wpinv_vat_rate"><?php _e('Rate %', 'invoicing'); ?></th> 
340
+                <th scope="col" class="wpinv_vat_name"><?php _e('VAT Name', 'invoicing'); ?></th>
341
+                <th scope="col" class="wpinv_vat_group"><?php _e('Tax Group', 'invoicing'); ?></th>
342 342
             </tr>
343 343
         </thead>
344 344
         <tbody>
345
-        <?php if( !empty( $eu_states ) ) { ?>
345
+        <?php if (!empty($eu_states)) { ?>
346 346
         <?php 
347
-        foreach ( $eu_states as $state ) { 
348
-            $country_name = isset( $countries[$state] ) ? $countries[$state] : '';
347
+        foreach ($eu_states as $state) { 
348
+            $country_name = isset($countries[$state]) ? $countries[$state] : '';
349 349
             
350 350
             // Filter the rate for each country
351
-            $country_rate = array_filter( $rates, function( $rate ) use( $state ) { return $rate['country'] === $state; } );
351
+            $country_rate = array_filter($rates, function($rate) use($state) { return $rate['country'] === $state; } );
352 352
             
353 353
             // If one does not exist create a default
354
-            $country_rate = is_array( $country_rate ) && count( $country_rate ) > 0 ? reset( $country_rate ) : array();
354
+            $country_rate = is_array($country_rate) && count($country_rate) > 0 ? reset($country_rate) : array();
355 355
             
356
-            $vat_global = isset( $country_rate['global'] ) ? !empty( $country_rate['global'] ) : true;
357
-            $vat_rate = isset( $country_rate['rate'] ) ? $country_rate['rate'] : '';
358
-            $vat_name = !empty( $country_rate['name'] ) ? esc_attr( stripslashes( $country_rate['name'] ) ) : '';
359
-            $vat_group = !empty( $country_rate['group'] ) ? $country_rate['group'] : ( $vat_class === '_standard' ? 'standard' : 'reduced' );
356
+            $vat_global = isset($country_rate['global']) ? !empty($country_rate['global']) : true;
357
+            $vat_rate = isset($country_rate['rate']) ? $country_rate['rate'] : '';
358
+            $vat_name = !empty($country_rate['name']) ? esc_attr(stripslashes($country_rate['name'])) : '';
359
+            $vat_group = !empty($country_rate['group']) ? $country_rate['group'] : ($vat_class === '_standard' ? 'standard' : 'reduced');
360 360
         ?>
361 361
         <tr>
362 362
             <td class="wpinv_vat_country"><?php echo $state; ?><input type="hidden" name="vat_rates[<?php echo $state; ?>][country]" value="<?php echo $state; ?>" /><input type="hidden" name="vat_rates[<?php echo $state; ?>][state]" value="" /></td>
363 363
             <td class="wpinv_vat_country_name"><?php echo $country_name; ?></td>
364 364
             <td class="wpinv_vat_global">
365
-                <input type="checkbox" name="vat_rates[<?php echo $state;?>][global]" id="vat_rates[<?php echo $state;?>][global]" value="1" <?php checked( true, $vat_global );?> disabled="disabled" />
366
-                <label for="tax_rates[<?php echo $state;?>][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label>
367
-                <input type="hidden" name="vat_rates[<?php echo $state;?>][global]" value="1" checked="checked" />
365
+                <input type="checkbox" name="vat_rates[<?php echo $state; ?>][global]" id="vat_rates[<?php echo $state; ?>][global]" value="1" <?php checked(true, $vat_global); ?> disabled="disabled" />
366
+                <label for="tax_rates[<?php echo $state; ?>][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label>
367
+                <input type="hidden" name="vat_rates[<?php echo $state; ?>][global]" value="1" checked="checked" />
368 368
             </td>
369
-            <td class="wpinv_vat_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="vat_rates[<?php echo $state;?>][rate]" value="<?php echo $vat_rate; ?>" /></td>
370
-            <td class="wpinv_vat_name"><input type="text" class="regular-text" name="vat_rates[<?php echo $state;?>][name]" value="<?php echo $vat_name; ?>" /></td>
369
+            <td class="wpinv_vat_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="vat_rates[<?php echo $state; ?>][rate]" value="<?php echo $vat_rate; ?>" /></td>
370
+            <td class="wpinv_vat_name"><input type="text" class="regular-text" name="vat_rates[<?php echo $state; ?>][name]" value="<?php echo $vat_name; ?>" /></td>
371 371
             <td class="wpinv_vat_group">
372 372
             <?php
373
-            echo wpinv_html_select( array(
373
+            echo wpinv_html_select(array(
374 374
                                         'name'             => 'vat_rates[' . $state . '][group]',
375 375
                                         'selected'         => $vat_group,
376 376
                                         'id'               => 'vat_rates[' . $state . '][group]',
@@ -379,14 +379,14 @@  discard block
 block discarded – undo
379 379
                                         'multiple'         => false,
380 380
                                         'show_option_all'  => false,
381 381
                                         'show_option_none' => false
382
-                                    ) );
382
+                                    ));
383 383
             ?>
384 384
             </td>
385 385
         </tr>
386 386
         <?php } ?>
387 387
         <tr>
388 388
             <td colspan="6" style="background-color:#fafafa;">
389
-                <span><input id="wpi_vat_get_rates_group" type="button" class="button-secondary" value="<?php esc_attr_e( 'Update EU VAT Rates', 'invoicing' ); ?>" />&nbsp;&nbsp;<i style="display:none" class="fa fa-refresh fa-spin"></i></span><span id="wpinv-rates-error-wrap" class="wpinv_errors" style="display:none;"></span>
389
+                <span><input id="wpi_vat_get_rates_group" type="button" class="button-secondary" value="<?php esc_attr_e('Update EU VAT Rates', 'invoicing'); ?>" />&nbsp;&nbsp;<i style="display:none" class="fa fa-refresh fa-spin"></i></span><span id="wpinv-rates-error-wrap" class="wpinv_errors" style="display:none;"></span>
390 390
             </td>
391 391
         </tr>
392 392
         <?php } ?>
@@ -398,35 +398,35 @@  discard block
 block discarded – undo
398 398
     echo $content;
399 399
 }
400 400
 
401
-function wpinv_vat_number_callback( $args ) {
401
+function wpinv_vat_number_callback($args) {
402 402
     global $wpinv_euvat;
403 403
     
404 404
     $vat_number     = $wpinv_euvat->get_vat_number();
405 405
     $vat_valid      = $wpinv_euvat->is_vat_validated();
406 406
 
407
-    $size           = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : 'regular';
408
-    $validated_text = $vat_valid ? __( 'VAT number validated', 'invoicing' ) : __( 'VAT number not validated', 'invoicing' );
407
+    $size           = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
408
+    $validated_text = $vat_valid ? __('VAT number validated', 'invoicing') : __('VAT number not validated', 'invoicing');
409 409
     $disabled       = $vat_valid ? 'disabled="disabled"' : " ";
410 410
     
411
-    $html = '<input type="text" class="' . $size . '-text" id="wpinv_settings[' . $args['id'] . ']" name="wpinv_settings[' . $args['id'] . ']" placeholder="GB123456789" value="' . esc_attr( stripslashes( $vat_number ) ) . '"/>';
412
-    $html .= '<span>&nbsp;<input type="button" id="wpinv_vat_validate" class="wpinv_validate_vat_button button-secondary" ' . $disabled . ' value="' . esc_attr__( 'Validate VAT Number', 'invoicing' ) . '" /></span>';
413
-    $html .= '<span class="wpinv-vat-stat wpinv-vat-stat-' . (int)$vat_valid . '"><i class="fa"></i> <font>' . $validated_text . '</font></span>';
414
-    $html .= '<label for="wpinv_settings[' . $args['id'] . ']">' . '<p>' . __( 'Enter your VAT number including country identifier, eg: GB123456789 (Settings must be saved after validation)', 'invoicing' ).'</p>' . '</label>';
415
-    $html .= '<input type="hidden" name="_wpi_nonce" value="' . wp_create_nonce( 'vat_validation' ) . '">';
411
+    $html = '<input type="text" class="' . $size . '-text" id="wpinv_settings[' . $args['id'] . ']" name="wpinv_settings[' . $args['id'] . ']" placeholder="GB123456789" value="' . esc_attr(stripslashes($vat_number)) . '"/>';
412
+    $html .= '<span>&nbsp;<input type="button" id="wpinv_vat_validate" class="wpinv_validate_vat_button button-secondary" ' . $disabled . ' value="' . esc_attr__('Validate VAT Number', 'invoicing') . '" /></span>';
413
+    $html .= '<span class="wpinv-vat-stat wpinv-vat-stat-' . (int) $vat_valid . '"><i class="fa"></i> <font>' . $validated_text . '</font></span>';
414
+    $html .= '<label for="wpinv_settings[' . $args['id'] . ']">' . '<p>' . __('Enter your VAT number including country identifier, eg: GB123456789 (Settings must be saved after validation)', 'invoicing') . '</p>' . '</label>';
415
+    $html .= '<input type="hidden" name="_wpi_nonce" value="' . wp_create_nonce('vat_validation') . '">';
416 416
 
417 417
     echo $html;
418 418
 }
419 419
 
420
-function wpinv_eu_fallback_rate_callback( $args ) {
420
+function wpinv_eu_fallback_rate_callback($args) {
421 421
     global $wpinv_options;
422 422
 
423
-    $value = isset( $wpinv_options[$args['id']] ) ? $wpinv_options[ $args['id'] ] : ( isset( $args['std'] ) ? $args['std'] : '' );
424
-    $size = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : 'small';
423
+    $value = isset($wpinv_options[$args['id']]) ? $wpinv_options[$args['id']] : (isset($args['std']) ? $args['std'] : '');
424
+    $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'small';
425 425
     
426
-    $html = '<input type="number" min="0" max="99" step="any" class="' . $size . '-text" id="wpinv_settings_' . $args['section'] . '_' . $args['id'] . '" name="wpinv_settings[' . $args['id'] . ']" value="' . esc_attr( stripslashes( $value ) ) . '" />';
427
-    $html .= '<span>&nbsp;<input id="wpi_add_eu_states" type="button" class="button-secondary" value="' . esc_attr__( 'Add EU Member States', 'invoicing' ) . '" /></span>';
428
-    $html .= '<span>&nbsp;<input id="wpi_remove_eu_states" type="button" class="button-secondary" value="' . esc_attr__( 'Remove EU Member States', 'invoicing' ) . '" /></span>';
429
-    $html .= '<span>&nbsp;<input id="wpi_vat_get_rates" type="button" class="button-secondary" value="' . esc_attr__( 'Update EU VAT Rates', 'invoicing' ) . '" />&nbsp;&nbsp;<i style="display:none" class="fa fa-refresh fa-spin"></i></span>';
426
+    $html = '<input type="number" min="0" max="99" step="any" class="' . $size . '-text" id="wpinv_settings_' . $args['section'] . '_' . $args['id'] . '" name="wpinv_settings[' . $args['id'] . ']" value="' . esc_attr(stripslashes($value)) . '" />';
427
+    $html .= '<span>&nbsp;<input id="wpi_add_eu_states" type="button" class="button-secondary" value="' . esc_attr__('Add EU Member States', 'invoicing') . '" /></span>';
428
+    $html .= '<span>&nbsp;<input id="wpi_remove_eu_states" type="button" class="button-secondary" value="' . esc_attr__('Remove EU Member States', 'invoicing') . '" /></span>';
429
+    $html .= '<span>&nbsp;<input id="wpi_vat_get_rates" type="button" class="button-secondary" value="' . esc_attr__('Update EU VAT Rates', 'invoicing') . '" />&nbsp;&nbsp;<i style="display:none" class="fa fa-refresh fa-spin"></i></span>';
430 430
     $html .= '<p><label for="wpinv_settings_' . $args['section'] . '_' . $args['id'] . '">' . $args['desc'] . '</label></p>';
431 431
     echo $html;
432 432
     ?>
@@ -439,22 +439,22 @@  discard block
 block discarded – undo
439 439
  * 
440 440
  * @param string|bool|null $vat_rule
441 441
  */
442
-function getpaid_filter_vat_rule( $vat_rule ) {
442
+function getpaid_filter_vat_rule($vat_rule) {
443 443
 
444
-    if ( empty( $vat_rule ) ) {        
444
+    if (empty($vat_rule)) {        
445 445
         return getpaid_tax()->allow_vat_rules() ? 'digital' : 'physical';
446 446
     }
447 447
 
448 448
     return $vat_rule;
449 449
 }
450
-add_filter( 'wpinv_get_item_vat_rule', 'getpaid_filter_vat_rule' );
450
+add_filter('wpinv_get_item_vat_rule', 'getpaid_filter_vat_rule');
451 451
 
452 452
 /**
453 453
  * Filters the VAT class to ensure that each item has a VAT class.
454 454
  * 
455 455
  * @param string|bool|null $vat_rule
456 456
  */
457
-function getpaid_filter_vat_class( $vat_class ) {
458
-    return empty( $vat_class ) ? '_standard' : $vat_class;
457
+function getpaid_filter_vat_class($vat_class) {
458
+    return empty($vat_class) ? '_standard' : $vat_class;
459 459
 }
460
-add_filter( 'wpinv_get_item_vat_class', 'getpaid_filter_vat_class' );
460
+add_filter('wpinv_get_item_vat_class', 'getpaid_filter_vat_class');
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -256,8 +256,9 @@
 block discarded – undo
256 256
 }
257 257
 
258 258
 function wpinv_cart_needs_tax_address_fields() {
259
-    if( !wpinv_is_cart_taxed() )
260
-        return false;
259
+    if( !wpinv_is_cart_taxed() ) {
260
+            return false;
261
+    }
261 262
 
262 263
     return ! did_action( 'wpinv_after_cc_fields', 'wpinv_default_cc_address_fields' );
263 264
 }
Please login to merge, or discard this patch.
includes/class-wpinv-legacy-invoice.php 1 patch
Spacing   +297 added lines, -297 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 /**
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
     /**
20 20
      * Invoice id.
21 21
      */
22
-    public $ID  = 0;
22
+    public $ID = 0;
23 23
 
24 24
     /**
25 25
      * The title of the invoice. Usually the invoice number.
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
     /**
136 136
      * The invoice status.
137 137
      */
138
-    public $status      = 'wpi-pending';
138
+    public $status = 'wpi-pending';
139 139
 
140 140
     /**
141 141
      * Same as self::$status.
@@ -262,17 +262,17 @@  discard block
 block discarded – undo
262 262
      */
263 263
     public $parent_invoice = 0;
264 264
     
265
-    public function __construct( $invoice_id = false ) {
266
-        if( empty( $invoice_id ) ) {
265
+    public function __construct($invoice_id = false) {
266
+        if (empty($invoice_id)) {
267 267
             return false;
268 268
         }
269 269
 
270
-        $this->setup_invoice( $invoice_id );
270
+        $this->setup_invoice($invoice_id);
271 271
     }
272 272
 
273
-    public function get( $key ) {
274
-        if ( method_exists( $this, 'get_' . $key ) ) {
275
-            $value = call_user_func( array( $this, 'get_' . $key ) );
273
+    public function get($key) {
274
+        if (method_exists($this, 'get_' . $key)) {
275
+            $value = call_user_func(array($this, 'get_' . $key));
276 276
         } else {
277 277
             $value = $this->$key;
278 278
         }
@@ -280,43 +280,43 @@  discard block
 block discarded – undo
280 280
         return $value;
281 281
     }
282 282
 
283
-    public function set( $key, $value ) {
284
-        $ignore = array( 'items', 'cart_details', 'fees', '_ID' );
283
+    public function set($key, $value) {
284
+        $ignore = array('items', 'cart_details', 'fees', '_ID');
285 285
 
286
-        if ( $key === 'status' ) {
286
+        if ($key === 'status') {
287 287
             $this->old_status = $this->status;
288 288
         }
289 289
 
290
-        if ( ! in_array( $key, $ignore ) ) {
291
-            $this->pending[ $key ] = $value;
290
+        if (!in_array($key, $ignore)) {
291
+            $this->pending[$key] = $value;
292 292
         }
293 293
 
294
-        if( '_ID' !== $key ) {
294
+        if ('_ID' !== $key) {
295 295
             $this->$key = $value;
296 296
         }
297 297
     }
298 298
 
299
-    public function _isset( $name ) {
300
-        if ( property_exists( $this, $name) ) {
301
-            return false === empty( $this->$name );
299
+    public function _isset($name) {
300
+        if (property_exists($this, $name)) {
301
+            return false === empty($this->$name);
302 302
         } else {
303 303
             return null;
304 304
         }
305 305
     }
306 306
 
307
-    private function setup_invoice( $invoice_id ) {
307
+    private function setup_invoice($invoice_id) {
308 308
         $this->pending = array();
309 309
 
310
-        $invoice = get_post( $invoice_id );
310
+        $invoice = get_post($invoice_id);
311 311
 
312
-        if ( ! $invoice || is_wp_error( $invoice ) ) {
312
+        if (!$invoice || is_wp_error($invoice)) {
313 313
             return false;
314 314
         }
315 315
 
316
-        do_action( 'wpinv_pre_setup_invoice', $this, $invoice_id );
316
+        do_action('wpinv_pre_setup_invoice', $this, $invoice_id);
317 317
 
318 318
         // Primary Identifier
319
-        $this->ID              = absint( $invoice_id );
319
+        $this->ID              = absint($invoice_id);
320 320
         $this->post_type       = $invoice->post_type;
321 321
 
322 322
         // We have a payment, get the generic payment_meta item to reduce calls to it
@@ -326,15 +326,15 @@  discard block
 block discarded – undo
326 326
         $this->completed_date  = $this->setup_completed_date();
327 327
         $this->status          = $invoice->post_status;
328 328
 
329
-        if ( 'future' == $this->status ) {
329
+        if ('future' == $this->status) {
330 330
             $this->status = 'publish';
331 331
         }
332 332
 
333 333
         $this->post_status     = $this->status;
334 334
         $this->mode            = $this->setup_mode();
335 335
         $this->parent_invoice  = $invoice->post_parent;
336
-        $this->post_name       = $this->setup_post_name( $invoice );
337
-        $this->status_nicename = $this->setup_status_nicename( $invoice->post_status );
336
+        $this->post_name       = $this->setup_post_name($invoice);
337
+        $this->status_nicename = $this->setup_status_nicename($invoice->post_status);
338 338
 
339 339
         // Items
340 340
         $this->fees            = $this->setup_fees();
@@ -356,8 +356,8 @@  discard block
 block discarded – undo
356 356
         
357 357
         // User based
358 358
         $this->ip              = $this->setup_ip();
359
-        $this->user_id         = !empty( $invoice->post_author ) ? $invoice->post_author : get_current_user_id();///$this->setup_user_id();
360
-        $this->email           = get_the_author_meta( 'email', $this->user_id );
359
+        $this->user_id         = !empty($invoice->post_author) ? $invoice->post_author : get_current_user_id(); ///$this->setup_user_id();
360
+        $this->email           = get_the_author_meta('email', $this->user_id);
361 361
 
362 362
         $this->user_info       = $this->setup_user_info();
363 363
 
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
         $this->company         = $this->user_info['company'];
367 367
         $this->vat_number      = $this->user_info['vat_number'];
368 368
         $this->vat_rate        = $this->user_info['vat_rate'];
369
-        $this->adddress_confirmed  = $this->user_info['adddress_confirmed'];
369
+        $this->adddress_confirmed = $this->user_info['adddress_confirmed'];
370 370
         $this->address         = $this->user_info['address'];
371 371
         $this->city            = $this->user_info['city'];
372 372
         $this->country         = $this->user_info['country'];
@@ -381,31 +381,31 @@  discard block
 block discarded – undo
381 381
         // Other Identifiers
382 382
         $this->key             = $this->setup_invoice_key();
383 383
         $this->number          = $this->setup_invoice_number();
384
-        $this->title           = !empty( $invoice->post_title ) ? $invoice->post_title : $this->number;
384
+        $this->title           = !empty($invoice->post_title) ? $invoice->post_title : $this->number;
385 385
         
386
-        $this->full_name       = trim( $this->first_name . ' '. $this->last_name );
386
+        $this->full_name       = trim($this->first_name . ' ' . $this->last_name);
387 387
         
388 388
         // Allow extensions to add items to this object via hook
389
-        do_action( 'wpinv_setup_invoice', $this, $invoice_id );
389
+        do_action('wpinv_setup_invoice', $this, $invoice_id);
390 390
 
391 391
         return true;
392 392
     }
393 393
 
394
-    private function setup_status_nicename( $status ) {
394
+    private function setup_status_nicename($status) {
395 395
         return $status;
396 396
     }
397 397
 
398
-    private function setup_post_name( $post ) {
398
+    private function setup_post_name($post) {
399 399
         $this->post_name = $post->post_name;
400 400
     }
401 401
     
402 402
     private function setup_due_date() {
403
-        $due_date = $this->get_meta( '_wpinv_due_date' );
403
+        $due_date = $this->get_meta('_wpinv_due_date');
404 404
         
405
-        if ( empty( $due_date ) ) {
406
-            $overdue_time = strtotime( $this->date ) + ( DAY_IN_SECONDS * absint( wpinv_get_option( 'overdue_days' ) ) );
407
-            $due_date = date_i18n( 'Y-m-d', $overdue_time );
408
-        } else if ( $due_date == 'none' ) {
405
+        if (empty($due_date)) {
406
+            $overdue_time = strtotime($this->date) + (DAY_IN_SECONDS * absint(wpinv_get_option('overdue_days')));
407
+            $due_date = date_i18n('Y-m-d', $overdue_time);
408
+        } else if ($due_date == 'none') {
409 409
             $due_date = '';
410 410
         }
411 411
         
@@ -413,67 +413,67 @@  discard block
 block discarded – undo
413 413
     }
414 414
     
415 415
     private function setup_completed_date() {
416
-        $invoice = get_post( $this->ID );
416
+        $invoice = get_post($this->ID);
417 417
 
418
-        if ( 'wpi-pending' == $invoice->post_status || 'preapproved' == $invoice->post_status ) {
418
+        if ('wpi-pending' == $invoice->post_status || 'preapproved' == $invoice->post_status) {
419 419
             return false; // This invoice was never paid
420 420
         }
421 421
 
422
-        $date = ( $date = $this->get_meta( '_wpinv_completed_date', true ) ) ? $date : $invoice->modified_date;
422
+        $date = ($date = $this->get_meta('_wpinv_completed_date', true)) ? $date : $invoice->modified_date;
423 423
 
424 424
         return $date;
425 425
     }
426 426
     
427 427
     private function setup_cart_details() {
428
-        $cart_details = isset( $this->payment_meta['cart_details'] ) ? maybe_unserialize( $this->payment_meta['cart_details'] ) : array();
428
+        $cart_details = isset($this->payment_meta['cart_details']) ? maybe_unserialize($this->payment_meta['cart_details']) : array();
429 429
         return $cart_details;
430 430
     }
431 431
     
432 432
     public function array_convert() {
433
-        return get_object_vars( $this );
433
+        return get_object_vars($this);
434 434
     }
435 435
     
436 436
     private function setup_items() {
437
-        $items = isset( $this->payment_meta['items'] ) ? maybe_unserialize( $this->payment_meta['items'] ) : array();
437
+        $items = isset($this->payment_meta['items']) ? maybe_unserialize($this->payment_meta['items']) : array();
438 438
         return $items;
439 439
     }
440 440
     
441 441
     private function setup_fees() {
442
-        $payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array();
442
+        $payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array();
443 443
         return $payment_fees;
444 444
     }
445 445
         
446 446
     private function setup_currency() {
447
-        $currency = isset( $this->payment_meta['currency'] ) ? $this->payment_meta['currency'] : apply_filters( 'wpinv_currency_default', wpinv_get_currency(), $this );
447
+        $currency = isset($this->payment_meta['currency']) ? $this->payment_meta['currency'] : apply_filters('wpinv_currency_default', wpinv_get_currency(), $this);
448 448
         return $currency;
449 449
     }
450 450
     
451 451
     private function setup_discount() {
452 452
         //$discount = $this->get_meta( '_wpinv_discount', true );
453
-        $discount = (float)$this->subtotal - ( (float)$this->total - (float)$this->tax - (float)$this->fees_total );
454
-        if ( $discount < 0 ) {
453
+        $discount = (float) $this->subtotal - ((float) $this->total - (float) $this->tax - (float) $this->fees_total);
454
+        if ($discount < 0) {
455 455
             $discount = 0;
456 456
         }
457
-        $discount = wpinv_round_amount( $discount );
457
+        $discount = wpinv_round_amount($discount);
458 458
         
459 459
         return $discount;
460 460
     }
461 461
     
462 462
     private function setup_discount_code() {
463
-        $discount_code = !empty( $this->discounts ) ? $this->discounts : $this->get_meta( '_wpinv_discount_code', true );
463
+        $discount_code = !empty($this->discounts) ? $this->discounts : $this->get_meta('_wpinv_discount_code', true);
464 464
         return $discount_code;
465 465
     }
466 466
     
467 467
     private function setup_tax() {
468 468
 
469
-        $tax = $this->get_meta( '_wpinv_tax', true );
469
+        $tax = $this->get_meta('_wpinv_tax', true);
470 470
 
471 471
         // We don't have tax as it's own meta and no meta was passed
472
-        if ( '' === $tax ) {            
473
-            $tax = isset( $this->payment_meta['tax'] ) ? $this->payment_meta['tax'] : 0;
472
+        if ('' === $tax) {            
473
+            $tax = isset($this->payment_meta['tax']) ? $this->payment_meta['tax'] : 0;
474 474
         }
475 475
         
476
-        if ( $tax < 0 || ! $this->is_taxable() ) {
476
+        if ($tax < 0 || !$this->is_taxable()) {
477 477
             $tax = 0;
478 478
         }
479 479
 
@@ -484,16 +484,16 @@  discard block
 block discarded – undo
484 484
      * If taxes are enabled, allow users to enable/disable taxes per invoice.
485 485
      */
486 486
     private function setup_is_taxable() {
487
-        return (int) $this->get_meta( '_wpinv_disable_taxes', true );
487
+        return (int) $this->get_meta('_wpinv_disable_taxes', true);
488 488
     }
489 489
 
490 490
     private function setup_subtotal() {
491 491
         $subtotal     = 0;
492 492
         $cart_details = $this->cart_details;
493 493
 
494
-        if ( is_array( $cart_details ) ) {
495
-            foreach ( $cart_details as $item ) {
496
-                if ( isset( $item['subtotal'] ) ) {
494
+        if (is_array($cart_details)) {
495
+            foreach ($cart_details as $item) {
496
+                if (isset($item['subtotal'])) {
497 497
                     $subtotal += $item['subtotal'];
498 498
                 }
499 499
             }
@@ -507,23 +507,23 @@  discard block
 block discarded – undo
507 507
     }
508 508
 
509 509
     private function setup_discounts() {
510
-        $discounts = ! empty( $this->payment_meta['user_info']['discount'] ) ? $this->payment_meta['user_info']['discount'] : array();
510
+        $discounts = !empty($this->payment_meta['user_info']['discount']) ? $this->payment_meta['user_info']['discount'] : array();
511 511
         return $discounts;
512 512
     }
513 513
     
514 514
     private function setup_total() {
515
-        $amount = $this->get_meta( '_wpinv_total', true );
515
+        $amount = $this->get_meta('_wpinv_total', true);
516 516
 
517
-        if ( empty( $amount ) && '0.00' != $amount ) {
518
-            $meta   = $this->get_meta( '_wpinv_payment_meta', true );
519
-            $meta   = maybe_unserialize( $meta );
517
+        if (empty($amount) && '0.00' != $amount) {
518
+            $meta   = $this->get_meta('_wpinv_payment_meta', true);
519
+            $meta   = maybe_unserialize($meta);
520 520
 
521
-            if ( isset( $meta['amount'] ) ) {
521
+            if (isset($meta['amount'])) {
522 522
                 $amount = $meta['amount'];
523 523
             }
524 524
         }
525 525
 
526
-        if($amount < 0){
526
+        if ($amount < 0) {
527 527
             $amount = 0;
528 528
         }
529 529
 
@@ -531,13 +531,13 @@  discard block
 block discarded – undo
531 531
     }
532 532
     
533 533
     private function setup_mode() {
534
-        return $this->get_meta( '_wpinv_mode' );
534
+        return $this->get_meta('_wpinv_mode');
535 535
     }
536 536
 
537 537
     private function setup_gateway() {
538
-        $gateway = $this->get_meta( '_wpinv_gateway' );
538
+        $gateway = $this->get_meta('_wpinv_gateway');
539 539
         
540
-        if ( empty( $gateway ) && 'publish' === $this->status ) {
540
+        if (empty($gateway) && 'publish' === $this->status) {
541 541
             $gateway = 'manual';
542 542
         }
543 543
         
@@ -545,23 +545,23 @@  discard block
 block discarded – undo
545 545
     }
546 546
 
547 547
     private function setup_gateway_title() {
548
-        $gateway_title = wpinv_get_gateway_checkout_label( $this->gateway );
548
+        $gateway_title = wpinv_get_gateway_checkout_label($this->gateway);
549 549
         return $gateway_title;
550 550
     }
551 551
 
552 552
     private function setup_transaction_id() {
553
-        $transaction_id = $this->get_meta( '_wpinv_transaction_id' );
553
+        $transaction_id = $this->get_meta('_wpinv_transaction_id');
554 554
 
555
-        if ( empty( $transaction_id ) || (int) $transaction_id === (int) $this->ID ) {
555
+        if (empty($transaction_id) || (int) $transaction_id === (int) $this->ID) {
556 556
             $gateway        = $this->gateway;
557
-            $transaction_id = apply_filters( 'wpinv_get_invoice_transaction_id-' . $gateway, $this->ID );
557
+            $transaction_id = apply_filters('wpinv_get_invoice_transaction_id-' . $gateway, $this->ID);
558 558
         }
559 559
 
560 560
         return $transaction_id;
561 561
     }
562 562
 
563 563
     private function setup_ip() {
564
-        $ip = $this->get_meta( '_wpinv_user_ip' );
564
+        $ip = $this->get_meta('_wpinv_user_ip');
565 565
         return $ip;
566 566
     }
567 567
 
@@ -571,62 +571,62 @@  discard block
 block discarded – undo
571 571
     ///}
572 572
         
573 573
     private function setup_first_name() {
574
-        $first_name = $this->get_meta( '_wpinv_first_name' );
574
+        $first_name = $this->get_meta('_wpinv_first_name');
575 575
         return $first_name;
576 576
     }
577 577
     
578 578
     private function setup_last_name() {
579
-        $last_name = $this->get_meta( '_wpinv_last_name' );
579
+        $last_name = $this->get_meta('_wpinv_last_name');
580 580
         return $last_name;
581 581
     }
582 582
     
583 583
     private function setup_company() {
584
-        $company = $this->get_meta( '_wpinv_company' );
584
+        $company = $this->get_meta('_wpinv_company');
585 585
         return $company;
586 586
     }
587 587
     
588 588
     private function setup_vat_number() {
589
-        $vat_number = $this->get_meta( '_wpinv_vat_number' );
589
+        $vat_number = $this->get_meta('_wpinv_vat_number');
590 590
         return $vat_number;
591 591
     }
592 592
     
593 593
     private function setup_vat_rate() {
594
-        $vat_rate = $this->get_meta( '_wpinv_vat_rate' );
594
+        $vat_rate = $this->get_meta('_wpinv_vat_rate');
595 595
         return $vat_rate;
596 596
     }
597 597
     
598 598
     private function setup_adddress_confirmed() {
599
-        $adddress_confirmed = $this->get_meta( '_wpinv_adddress_confirmed' );
599
+        $adddress_confirmed = $this->get_meta('_wpinv_adddress_confirmed');
600 600
         return $adddress_confirmed;
601 601
     }
602 602
     
603 603
     private function setup_phone() {
604
-        $phone = $this->get_meta( '_wpinv_phone' );
604
+        $phone = $this->get_meta('_wpinv_phone');
605 605
         return $phone;
606 606
     }
607 607
     
608 608
     private function setup_address() {
609
-        $address = $this->get_meta( '_wpinv_address', true );
609
+        $address = $this->get_meta('_wpinv_address', true);
610 610
         return $address;
611 611
     }
612 612
     
613 613
     private function setup_city() {
614
-        $city = $this->get_meta( '_wpinv_city', true );
614
+        $city = $this->get_meta('_wpinv_city', true);
615 615
         return $city;
616 616
     }
617 617
     
618 618
     private function setup_country() {
619
-        $country = $this->get_meta( '_wpinv_country', true );
619
+        $country = $this->get_meta('_wpinv_country', true);
620 620
         return $country;
621 621
     }
622 622
     
623 623
     private function setup_state() {
624
-        $state = $this->get_meta( '_wpinv_state', true );
624
+        $state = $this->get_meta('_wpinv_state', true);
625 625
         return $state;
626 626
     }
627 627
     
628 628
     private function setup_zip() {
629
-        $zip = $this->get_meta( '_wpinv_zip', true );
629
+        $zip = $this->get_meta('_wpinv_zip', true);
630 630
         return $zip;
631 631
     }
632 632
 
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
             'user_id'        => $this->user_id,
636 636
             'first_name'     => $this->first_name,
637 637
             'last_name'      => $this->last_name,
638
-            'email'          => get_the_author_meta( 'email', $this->user_id ),
638
+            'email'          => get_the_author_meta('email', $this->user_id),
639 639
             'phone'          => $this->phone,
640 640
             'address'        => $this->address,
641 641
             'city'           => $this->city,
@@ -650,12 +650,12 @@  discard block
 block discarded – undo
650 650
         );
651 651
         
652 652
         $user_info = array();
653
-        if ( isset( $this->payment_meta['user_info'] ) ) {
654
-            $user_info = maybe_unserialize( $this->payment_meta['user_info'] );
653
+        if (isset($this->payment_meta['user_info'])) {
654
+            $user_info = maybe_unserialize($this->payment_meta['user_info']);
655 655
             
656
-            if ( !empty( $user_info ) && isset( $user_info['user_id'] ) && $post = get_post( $this->ID ) ) {
656
+            if (!empty($user_info) && isset($user_info['user_id']) && $post = get_post($this->ID)) {
657 657
                 $this->user_id = $post->post_author;
658
-                $this->email = get_the_author_meta( 'email', $this->user_id );
658
+                $this->email = get_the_author_meta('email', $this->user_id);
659 659
                 
660 660
                 $user_info['user_id'] = $this->user_id;
661 661
                 $user_info['email'] = $this->email;
@@ -664,13 +664,13 @@  discard block
 block discarded – undo
664 664
             }
665 665
         }
666 666
         
667
-        $user_info    = wp_parse_args( $user_info, $defaults );
667
+        $user_info = wp_parse_args($user_info, $defaults);
668 668
         
669 669
         // Get the user, but only if it's been created
670
-        $user = get_userdata( $this->user_id );
670
+        $user = get_userdata($this->user_id);
671 671
         
672
-        if ( !empty( $user ) && $user->ID > 0 ) {
673
-            if ( empty( $user_info ) ) {
672
+        if (!empty($user) && $user->ID > 0) {
673
+            if (empty($user_info)) {
674 674
                 $user_info = array(
675 675
                     'user_id'    => $user->ID,
676 676
                     'first_name' => $user->first_name,
@@ -679,23 +679,23 @@  discard block
 block discarded – undo
679 679
                     'discount'   => '',
680 680
                 );
681 681
             } else {
682
-                foreach ( $user_info as $key => $value ) {
683
-                    if ( ! empty( $value ) ) {
682
+                foreach ($user_info as $key => $value) {
683
+                    if (!empty($value)) {
684 684
                         continue;
685 685
                     }
686 686
 
687
-                    switch( $key ) {
687
+                    switch ($key) {
688 688
                         case 'user_id':
689
-                            $user_info[ $key ] = $user->ID;
689
+                            $user_info[$key] = $user->ID;
690 690
                             break;
691 691
                         case 'first_name':
692
-                            $user_info[ $key ] = $user->first_name;
692
+                            $user_info[$key] = $user->first_name;
693 693
                             break;
694 694
                         case 'last_name':
695
-                            $user_info[ $key ] = $user->last_name;
695
+                            $user_info[$key] = $user->last_name;
696 696
                             break;
697 697
                         case 'email':
698
-                            $user_info[ $key ] = $user->user_email;
698
+                            $user_info[$key] = $user->user_email;
699 699
                             break;
700 700
                     }
701 701
                 }
@@ -706,25 +706,25 @@  discard block
 block discarded – undo
706 706
     }
707 707
 
708 708
     private function setup_invoice_key() {
709
-        $key = $this->get_meta( '_wpinv_key', true );
709
+        $key = $this->get_meta('_wpinv_key', true);
710 710
         
711 711
         return $key;
712 712
     }
713 713
 
714 714
     private function setup_invoice_number() {
715
-        $number = $this->get_meta( '_wpinv_number', true );
715
+        $number = $this->get_meta('_wpinv_number', true);
716 716
 
717
-        if ( !$number ) {
717
+        if (!$number) {
718 718
             $number = $this->ID;
719 719
 
720
-            if ( $this->status == 'auto-draft' ) {
721
-                if ( wpinv_sequential_number_active( $this->post_type ) ) {
722
-                    $next_number = wpinv_get_next_invoice_number( $this->post_type );
720
+            if ($this->status == 'auto-draft') {
721
+                if (wpinv_sequential_number_active($this->post_type)) {
722
+                    $next_number = wpinv_get_next_invoice_number($this->post_type);
723 723
                     $number      = $next_number;
724 724
                 }
725 725
             }
726 726
             
727
-            $number = wpinv_format_invoice_number( $number, $this->post_type );
727
+            $number = wpinv_format_invoice_number($number, $this->post_type);
728 728
         }
729 729
 
730 730
         return $number;
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
 
733 733
     public function save() {}
734 734
     
735
-    public function add_fee( $args ) {
735
+    public function add_fee($args) {
736 736
         $default_args = array(
737 737
             'label'       => '',
738 738
             'amount'      => 0,
@@ -742,75 +742,75 @@  discard block
 block discarded – undo
742 742
             'item_id'     => 0,
743 743
         );
744 744
 
745
-        $fee = wp_parse_args( $args, $default_args );
745
+        $fee = wp_parse_args($args, $default_args);
746 746
         
747
-        if ( empty( $fee['label'] ) ) {
747
+        if (empty($fee['label'])) {
748 748
             return false;
749 749
         }
750 750
         
751
-        $fee['id']  = sanitize_title( $fee['label'] );
751
+        $fee['id'] = sanitize_title($fee['label']);
752 752
         
753
-        $this->fees[]               = $fee;
753
+        $this->fees[] = $fee;
754 754
         
755 755
         $added_fee               = $fee;
756 756
         $added_fee['action']     = 'add';
757 757
         $this->pending['fees'][] = $added_fee;
758
-        reset( $this->fees );
758
+        reset($this->fees);
759 759
 
760
-        $this->increase_fees( $fee['amount'] );
760
+        $this->increase_fees($fee['amount']);
761 761
         return true;
762 762
     }
763 763
 
764
-    public function remove_fee( $key ) {
764
+    public function remove_fee($key) {
765 765
         $removed = false;
766 766
 
767
-        if ( is_numeric( $key ) ) {
768
-            $removed = $this->remove_fee_by( 'index', $key );
767
+        if (is_numeric($key)) {
768
+            $removed = $this->remove_fee_by('index', $key);
769 769
         }
770 770
 
771 771
         return $removed;
772 772
     }
773 773
 
774
-    public function remove_fee_by( $key, $value, $global = false ) {
775
-        $allowed_fee_keys = apply_filters( 'wpinv_fee_keys', array(
774
+    public function remove_fee_by($key, $value, $global = false) {
775
+        $allowed_fee_keys = apply_filters('wpinv_fee_keys', array(
776 776
             'index', 'label', 'amount', 'type',
777
-        ) );
777
+        ));
778 778
 
779
-        if ( ! in_array( $key, $allowed_fee_keys ) ) {
779
+        if (!in_array($key, $allowed_fee_keys)) {
780 780
             return false;
781 781
         }
782 782
 
783 783
         $removed = false;
784
-        if ( 'index' === $key && array_key_exists( $value, $this->fees ) ) {
785
-            $removed_fee             = $this->fees[ $value ];
784
+        if ('index' === $key && array_key_exists($value, $this->fees)) {
785
+            $removed_fee             = $this->fees[$value];
786 786
             $removed_fee['action']   = 'remove';
787 787
             $this->pending['fees'][] = $removed_fee;
788 788
 
789
-            $this->decrease_fees( $removed_fee['amount'] );
789
+            $this->decrease_fees($removed_fee['amount']);
790 790
 
791
-            unset( $this->fees[ $value ] );
791
+            unset($this->fees[$value]);
792 792
             $removed = true;
793
-        } else if ( 'index' !== $key ) {
794
-            foreach ( $this->fees as $index => $fee ) {
795
-                if ( isset( $fee[ $key ] ) && $fee[ $key ] == $value ) {
793
+        } else if ('index' !== $key) {
794
+            foreach ($this->fees as $index => $fee) {
795
+                if (isset($fee[$key]) && $fee[$key] == $value) {
796 796
                     $removed_fee             = $fee;
797 797
                     $removed_fee['action']   = 'remove';
798 798
                     $this->pending['fees'][] = $removed_fee;
799 799
 
800
-                    $this->decrease_fees( $removed_fee['amount'] );
800
+                    $this->decrease_fees($removed_fee['amount']);
801 801
 
802
-                    unset( $this->fees[ $index ] );
802
+                    unset($this->fees[$index]);
803 803
                     $removed = true;
804 804
 
805
-                    if ( false === $global ) {
805
+                    if (false === $global) {
806 806
                         break;
807 807
                     }
808 808
                 }
809 809
             }
810 810
         }
811 811
 
812
-        if ( true === $removed ) {
813
-            $this->fees = array_values( $this->fees );
812
+        if (true === $removed) {
813
+            $this->fees = array_values($this->fees);
814 814
         }
815 815
 
816 816
         return $removed;
@@ -818,35 +818,35 @@  discard block
 block discarded – undo
818 818
 
819 819
     
820 820
 
821
-    public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
821
+    public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) {
822 822
         // Bail if no note specified
823
-        if( !$note ) {
823
+        if (!$note) {
824 824
             return false;
825 825
         }
826 826
 
827
-        if ( empty( $this->ID ) )
827
+        if (empty($this->ID))
828 828
             return false;
829 829
         
830
-        if ( ( ( is_user_logged_in() && wpinv_current_user_can_manage_invoicing() ) || $added_by_user ) && !$system ) {
831
-            $user                 = get_user_by( 'id', get_current_user_id() );
830
+        if (((is_user_logged_in() && wpinv_current_user_can_manage_invoicing()) || $added_by_user) && !$system) {
831
+            $user                 = get_user_by('id', get_current_user_id());
832 832
             $comment_author       = $user->display_name;
833 833
             $comment_author_email = $user->user_email;
834 834
         } else {
835 835
             $comment_author       = 'System';
836 836
             $comment_author_email = 'system@';
837
-            $comment_author_email .= isset( $_SERVER['HTTP_HOST'] ) ? str_replace( 'www.', '', $_SERVER['HTTP_HOST'] ) : 'noreply.com';
838
-            $comment_author_email = sanitize_email( $comment_author_email );
837
+            $comment_author_email .= isset($_SERVER['HTTP_HOST']) ? str_replace('www.', '', $_SERVER['HTTP_HOST']) : 'noreply.com';
838
+            $comment_author_email = sanitize_email($comment_author_email);
839 839
         }
840 840
 
841
-        do_action( 'wpinv_pre_insert_invoice_note', $this->ID, $note, $customer_type );
841
+        do_action('wpinv_pre_insert_invoice_note', $this->ID, $note, $customer_type);
842 842
 
843
-        $note_id = wp_insert_comment( wp_filter_comment( array(
843
+        $note_id = wp_insert_comment(wp_filter_comment(array(
844 844
             'comment_post_ID'      => $this->ID,
845 845
             'comment_content'      => $note,
846 846
             'comment_agent'        => 'WPInvoicing',
847 847
             'user_id'              => is_admin() ? get_current_user_id() : 0,
848
-            'comment_date'         => current_time( 'mysql' ),
849
-            'comment_date_gmt'     => current_time( 'mysql', 1 ),
848
+            'comment_date'         => current_time('mysql'),
849
+            'comment_date_gmt'     => current_time('mysql', 1),
850 850
             'comment_approved'     => 1,
851 851
             'comment_parent'       => 0,
852 852
             'comment_author'       => $comment_author,
@@ -854,53 +854,53 @@  discard block
 block discarded – undo
854 854
             'comment_author_url'   => '',
855 855
             'comment_author_email' => $comment_author_email,
856 856
             'comment_type'         => 'wpinv_note'
857
-        ) ) );
857
+        )));
858 858
 
859
-        do_action( 'wpinv_insert_payment_note', $note_id, $this->ID, $note );
859
+        do_action('wpinv_insert_payment_note', $note_id, $this->ID, $note);
860 860
         
861
-        if ( $customer_type ) {
862
-            add_comment_meta( $note_id, '_wpi_customer_note', 1 );
861
+        if ($customer_type) {
862
+            add_comment_meta($note_id, '_wpi_customer_note', 1);
863 863
 
864
-            do_action( 'wpinv_new_customer_note', array( 'invoice_id' => $this->ID, 'user_note' => $note ) );
864
+            do_action('wpinv_new_customer_note', array('invoice_id' => $this->ID, 'user_note' => $note));
865 865
         }
866 866
 
867 867
         return $note_id;
868 868
     }
869 869
 
870
-    private function increase_subtotal( $amount = 0.00 ) {
870
+    private function increase_subtotal($amount = 0.00) {
871 871
         $amount          = (float) $amount;
872 872
         $this->subtotal += $amount;
873
-        $this->subtotal  = wpinv_round_amount( $this->subtotal );
873
+        $this->subtotal  = wpinv_round_amount($this->subtotal);
874 874
 
875 875
         $this->recalculate_total();
876 876
     }
877 877
 
878
-    private function decrease_subtotal( $amount = 0.00 ) {
878
+    private function decrease_subtotal($amount = 0.00) {
879 879
         $amount          = (float) $amount;
880 880
         $this->subtotal -= $amount;
881
-        $this->subtotal  = wpinv_round_amount( $this->subtotal );
881
+        $this->subtotal  = wpinv_round_amount($this->subtotal);
882 882
 
883
-        if ( $this->subtotal < 0 ) {
883
+        if ($this->subtotal < 0) {
884 884
             $this->subtotal = 0;
885 885
         }
886 886
 
887 887
         $this->recalculate_total();
888 888
     }
889 889
 
890
-    private function increase_fees( $amount = 0.00 ) {
891
-        $amount            = (float)$amount;
890
+    private function increase_fees($amount = 0.00) {
891
+        $amount            = (float) $amount;
892 892
         $this->fees_total += $amount;
893
-        $this->fees_total  = wpinv_round_amount( $this->fees_total );
893
+        $this->fees_total  = wpinv_round_amount($this->fees_total);
894 894
 
895 895
         $this->recalculate_total();
896 896
     }
897 897
 
898
-    private function decrease_fees( $amount = 0.00 ) {
898
+    private function decrease_fees($amount = 0.00) {
899 899
         $amount            = (float) $amount;
900 900
         $this->fees_total -= $amount;
901
-        $this->fees_total  = wpinv_round_amount( $this->fees_total );
901
+        $this->fees_total  = wpinv_round_amount($this->fees_total);
902 902
 
903
-        if ( $this->fees_total < 0 ) {
903
+        if ($this->fees_total < 0) {
904 904
             $this->fees_total = 0;
905 905
         }
906 906
 
@@ -911,56 +911,56 @@  discard block
 block discarded – undo
911 911
         global $wpi_nosave;
912 912
         
913 913
         $this->total = $this->subtotal + $this->tax + $this->fees_total;
914
-        $this->total = wpinv_round_amount( $this->total );
914
+        $this->total = wpinv_round_amount($this->total);
915 915
         
916
-        do_action( 'wpinv_invoice_recalculate_total', $this, $wpi_nosave );
916
+        do_action('wpinv_invoice_recalculate_total', $this, $wpi_nosave);
917 917
     }
918 918
     
919
-    public function increase_tax( $amount = 0.00 ) {
919
+    public function increase_tax($amount = 0.00) {
920 920
         $amount       = (float) $amount;
921 921
         $this->tax   += $amount;
922 922
 
923 923
         $this->recalculate_total();
924 924
     }
925 925
 
926
-    public function decrease_tax( $amount = 0.00 ) {
926
+    public function decrease_tax($amount = 0.00) {
927 927
         $amount     = (float) $amount;
928 928
         $this->tax -= $amount;
929 929
 
930
-        if ( $this->tax < 0 ) {
930
+        if ($this->tax < 0) {
931 931
             $this->tax = 0;
932 932
         }
933 933
 
934 934
         $this->recalculate_total();
935 935
     }
936 936
 
937
-    public function update_status( $new_status = false, $note = '', $manual = false ) {
938
-        $old_status = ! empty( $this->old_status ) ? $this->old_status : get_post_status( $this->ID );
937
+    public function update_status($new_status = false, $note = '', $manual = false) {
938
+        $old_status = !empty($this->old_status) ? $this->old_status : get_post_status($this->ID);
939 939
 
940
-        if ( $old_status === $new_status && in_array( $new_status, array_keys( wpinv_get_invoice_statuses( true ) ) ) ) {
940
+        if ($old_status === $new_status && in_array($new_status, array_keys(wpinv_get_invoice_statuses(true)))) {
941 941
             return false; // Don't permit status changes that aren't changes
942 942
         }
943 943
 
944
-        $do_change = apply_filters( 'wpinv_should_update_invoice_status', true, $this->ID, $new_status, $old_status );
944
+        $do_change = apply_filters('wpinv_should_update_invoice_status', true, $this->ID, $new_status, $old_status);
945 945
         $updated = false;
946 946
 
947
-        if ( $do_change ) {
948
-            do_action( 'wpinv_before_invoice_status_change', $this->ID, $new_status, $old_status );
947
+        if ($do_change) {
948
+            do_action('wpinv_before_invoice_status_change', $this->ID, $new_status, $old_status);
949 949
 
950 950
             $update_post_data                   = array();
951 951
             $update_post_data['ID']             = $this->ID;
952 952
             $update_post_data['post_status']    = $new_status;
953
-            $update_post_data['edit_date']      = current_time( 'mysql', 0 );
954
-            $update_post_data['edit_date_gmt']  = current_time( 'mysql', 1 );
953
+            $update_post_data['edit_date']      = current_time('mysql', 0);
954
+            $update_post_data['edit_date_gmt']  = current_time('mysql', 1);
955 955
             
956
-            $update_post_data = apply_filters( 'wpinv_update_invoice_status_fields', $update_post_data, $this->ID );
956
+            $update_post_data = apply_filters('wpinv_update_invoice_status_fields', $update_post_data, $this->ID);
957 957
 
958
-            $updated = wp_update_post( $update_post_data );
958
+            $updated = wp_update_post($update_post_data);
959 959
             
960 960
             // Status was changed.
961
-            do_action( 'wpinv_status_' . $new_status, $this->ID, $old_status );
962
-            do_action( 'wpinv_status_' . $old_status . '_to_' . $new_status, $this->ID, $old_status );
963
-            do_action( 'wpinv_update_status', $this->ID, $new_status, $old_status );
961
+            do_action('wpinv_status_' . $new_status, $this->ID, $old_status);
962
+            do_action('wpinv_status_' . $old_status . '_to_' . $new_status, $this->ID, $old_status);
963
+            do_action('wpinv_update_status', $this->ID, $new_status, $old_status);
964 964
         }
965 965
 
966 966
         return $updated;
@@ -977,113 +977,113 @@  discard block
 block discarded – undo
977 977
     public function update_meta() {}
978 978
 
979 979
     // get data
980
-    public function get_meta( $meta_key = '_wpinv_payment_meta', $single = true ) {
981
-        $meta = get_post_meta( $this->ID, $meta_key, $single );
980
+    public function get_meta($meta_key = '_wpinv_payment_meta', $single = true) {
981
+        $meta = get_post_meta($this->ID, $meta_key, $single);
982 982
 
983
-        if ( $meta_key === '_wpinv_payment_meta' ) {
983
+        if ($meta_key === '_wpinv_payment_meta') {
984 984
 
985
-            if(!is_array($meta)){$meta = array();} // we need this to be an array so make sure it is.
985
+            if (!is_array($meta)) {$meta = array(); } // we need this to be an array so make sure it is.
986 986
 
987
-            if ( empty( $meta['key'] ) ) {
987
+            if (empty($meta['key'])) {
988 988
                 $meta['key'] = $this->setup_invoice_key();
989 989
             }
990 990
 
991
-            if ( empty( $meta['date'] ) ) {
992
-                $meta['date'] = get_post_field( 'post_date', $this->ID );
991
+            if (empty($meta['date'])) {
992
+                $meta['date'] = get_post_field('post_date', $this->ID);
993 993
             }
994 994
         }
995 995
 
996
-        $meta = apply_filters( 'wpinv_get_invoice_meta_' . $meta_key, $meta, $this->ID );
996
+        $meta = apply_filters('wpinv_get_invoice_meta_' . $meta_key, $meta, $this->ID);
997 997
 
998
-        return apply_filters( 'wpinv_get_invoice_meta', $meta, $this->ID, $meta_key );
998
+        return apply_filters('wpinv_get_invoice_meta', $meta, $this->ID, $meta_key);
999 999
     }
1000 1000
     
1001 1001
     public function get_description() {
1002
-        $post = get_post( $this->ID );
1002
+        $post = get_post($this->ID);
1003 1003
         
1004
-        $description = !empty( $post ) ? $post->post_content : '';
1005
-        return apply_filters( 'wpinv_get_description', $description, $this->ID, $this );
1004
+        $description = !empty($post) ? $post->post_content : '';
1005
+        return apply_filters('wpinv_get_description', $description, $this->ID, $this);
1006 1006
     }
1007 1007
     
1008
-    public function get_status( $nicename = false ) {
1009
-        if ( !$nicename ) {
1008
+    public function get_status($nicename = false) {
1009
+        if (!$nicename) {
1010 1010
             $status = $this->status;
1011 1011
         } else {
1012 1012
             $status = $this->status_nicename;
1013 1013
         }
1014 1014
         
1015
-        return apply_filters( 'wpinv_get_status', $status, $nicename, $this->ID, $this );
1015
+        return apply_filters('wpinv_get_status', $status, $nicename, $this->ID, $this);
1016 1016
     }
1017 1017
     
1018 1018
     public function get_cart_details() {
1019
-        return apply_filters( 'wpinv_cart_details', $this->cart_details, $this->ID, $this );
1019
+        return apply_filters('wpinv_cart_details', $this->cart_details, $this->ID, $this);
1020 1020
     }
1021 1021
     
1022
-    public function get_subtotal( $currency = false ) {
1023
-        $subtotal = wpinv_round_amount( $this->subtotal );
1022
+    public function get_subtotal($currency = false) {
1023
+        $subtotal = wpinv_round_amount($this->subtotal);
1024 1024
         
1025
-        if ( $currency ) {
1026
-            $subtotal = wpinv_price( wpinv_format_amount( $subtotal, NULL, !$currency ), $this->get_currency() );
1025
+        if ($currency) {
1026
+            $subtotal = wpinv_price(wpinv_format_amount($subtotal, NULL, !$currency), $this->get_currency());
1027 1027
         }
1028 1028
         
1029
-        return apply_filters( 'wpinv_get_invoice_subtotal', $subtotal, $this->ID, $this, $currency );
1029
+        return apply_filters('wpinv_get_invoice_subtotal', $subtotal, $this->ID, $this, $currency);
1030 1030
     }
1031 1031
     
1032
-    public function get_total( $currency = false ) {        
1033
-        if ( $this->is_free_trial() ) {
1034
-            $total = wpinv_round_amount( 0 );
1032
+    public function get_total($currency = false) {        
1033
+        if ($this->is_free_trial()) {
1034
+            $total = wpinv_round_amount(0);
1035 1035
         } else {
1036
-            $total = wpinv_round_amount( $this->total );
1036
+            $total = wpinv_round_amount($this->total);
1037 1037
         }
1038
-        if ( $currency ) {
1039
-            $total = wpinv_price( wpinv_format_amount( $total, NULL, !$currency ), $this->get_currency() );
1038
+        if ($currency) {
1039
+            $total = wpinv_price(wpinv_format_amount($total, NULL, !$currency), $this->get_currency());
1040 1040
         }
1041 1041
 
1042
-        return apply_filters( 'wpinv_get_invoice_total', $total, $this->ID, $this, $currency );
1042
+        return apply_filters('wpinv_get_invoice_total', $total, $this->ID, $this, $currency);
1043 1043
     }
1044 1044
 
1045 1045
     public function get_recurring_details() {}
1046 1046
 
1047
-    public function get_final_tax( $currency = false ) {        
1048
-        $final_total = wpinv_round_amount( $this->tax );
1049
-        if ( $currency ) {
1050
-            $final_total = wpinv_price( wpinv_format_amount( $final_total, NULL, !$currency ), $this->get_currency() );
1047
+    public function get_final_tax($currency = false) {        
1048
+        $final_total = wpinv_round_amount($this->tax);
1049
+        if ($currency) {
1050
+            $final_total = wpinv_price(wpinv_format_amount($final_total, NULL, !$currency), $this->get_currency());
1051 1051
         }
1052 1052
         
1053
-        return apply_filters( 'wpinv_get_invoice_final_total', $final_total, $this, $currency );
1053
+        return apply_filters('wpinv_get_invoice_final_total', $final_total, $this, $currency);
1054 1054
     }
1055 1055
     
1056
-    public function get_discounts( $array = false ) {
1056
+    public function get_discounts($array = false) {
1057 1057
         $discounts = $this->discounts;
1058
-        if ( $array && $discounts ) {
1059
-            $discounts = explode( ',', $discounts );
1058
+        if ($array && $discounts) {
1059
+            $discounts = explode(',', $discounts);
1060 1060
         }
1061
-        return apply_filters( 'wpinv_payment_discounts', $discounts, $this->ID, $this, $array );
1061
+        return apply_filters('wpinv_payment_discounts', $discounts, $this->ID, $this, $array);
1062 1062
     }
1063 1063
     
1064
-    public function get_discount( $currency = false, $dash = false ) {
1065
-        if ( !empty( $this->discounts ) ) {
1064
+    public function get_discount($currency = false, $dash = false) {
1065
+        if (!empty($this->discounts)) {
1066 1066
             global $ajax_cart_details;
1067 1067
             $ajax_cart_details = $this->get_cart_details();
1068 1068
             
1069
-            if ( !empty( $ajax_cart_details ) && count( $ajax_cart_details ) == count( $this->items ) ) {
1069
+            if (!empty($ajax_cart_details) && count($ajax_cart_details) == count($this->items)) {
1070 1070
                 $cart_items = $ajax_cart_details;
1071 1071
             } else {
1072 1072
                 $cart_items = $this->items;
1073 1073
             }
1074 1074
 
1075
-            $this->discount = wpinv_get_cart_items_discount_amount( $cart_items , $this->discounts );
1075
+            $this->discount = wpinv_get_cart_items_discount_amount($cart_items, $this->discounts);
1076 1076
         }
1077
-        $discount   = wpinv_round_amount( $this->discount );
1077
+        $discount   = wpinv_round_amount($this->discount);
1078 1078
         $dash       = $dash && $discount > 0 ? '&ndash;' : '';
1079 1079
         
1080
-        if ( $currency ) {
1081
-            $discount = wpinv_price( wpinv_format_amount( $discount, NULL, !$currency ), $this->get_currency() );
1080
+        if ($currency) {
1081
+            $discount = wpinv_price(wpinv_format_amount($discount, NULL, !$currency), $this->get_currency());
1082 1082
         }
1083 1083
         
1084
-        $discount   = $dash . $discount;
1084
+        $discount = $dash . $discount;
1085 1085
         
1086
-        return apply_filters( 'wpinv_get_invoice_discount', $discount, $this->ID, $this, $currency, $dash );
1086
+        return apply_filters('wpinv_get_invoice_discount', $discount, $this->ID, $this, $currency, $dash);
1087 1087
     }
1088 1088
     
1089 1089
     public function get_discount_code() {
@@ -1095,150 +1095,150 @@  discard block
 block discarded – undo
1095 1095
         return (int) $this->disable_taxes === 0;
1096 1096
     }
1097 1097
 
1098
-    public function get_tax( $currency = false ) {
1099
-        $tax = wpinv_round_amount( $this->tax );
1098
+    public function get_tax($currency = false) {
1099
+        $tax = wpinv_round_amount($this->tax);
1100 1100
 
1101
-        if ( $currency ) {
1102
-            $tax = wpinv_price( wpinv_format_amount( $tax, NULL, !$currency ), $this->get_currency() );
1101
+        if ($currency) {
1102
+            $tax = wpinv_price(wpinv_format_amount($tax, NULL, !$currency), $this->get_currency());
1103 1103
         }
1104 1104
 
1105
-        if ( ! $this->is_taxable() ) {
1106
-            $tax = wpinv_round_amount( 0.00 );
1105
+        if (!$this->is_taxable()) {
1106
+            $tax = wpinv_round_amount(0.00);
1107 1107
         }
1108 1108
 
1109
-        return apply_filters( 'wpinv_get_invoice_tax', $tax, $this->ID, $this, $currency );
1109
+        return apply_filters('wpinv_get_invoice_tax', $tax, $this->ID, $this, $currency);
1110 1110
     }
1111 1111
     
1112
-    public function get_fees( $type = 'all' ) {
1113
-        $fees    = array();
1112
+    public function get_fees($type = 'all') {
1113
+        $fees = array();
1114 1114
 
1115
-        if ( ! empty( $this->fees ) && is_array( $this->fees ) ) {
1116
-            foreach ( $this->fees as $fee ) {
1117
-                if( 'all' != $type && ! empty( $fee['type'] ) && $type != $fee['type'] ) {
1115
+        if (!empty($this->fees) && is_array($this->fees)) {
1116
+            foreach ($this->fees as $fee) {
1117
+                if ('all' != $type && !empty($fee['type']) && $type != $fee['type']) {
1118 1118
                     continue;
1119 1119
                 }
1120 1120
 
1121
-                $fee['label'] = stripslashes( $fee['label'] );
1122
-                $fee['amount_display'] = wpinv_price( $fee['amount'], $this->get_currency() );
1123
-                $fees[]    = $fee;
1121
+                $fee['label'] = stripslashes($fee['label']);
1122
+                $fee['amount_display'] = wpinv_price($fee['amount'], $this->get_currency());
1123
+                $fees[] = $fee;
1124 1124
             }
1125 1125
         }
1126 1126
 
1127
-        return apply_filters( 'wpinv_get_invoice_fees', $fees, $this->ID, $this );
1127
+        return apply_filters('wpinv_get_invoice_fees', $fees, $this->ID, $this);
1128 1128
     }
1129 1129
     
1130 1130
     public function get_fees_total() {
1131 1131
         $fees_total = (float) 0.00;
1132 1132
 
1133
-        $payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array();
1134
-        if ( ! empty( $payment_fees ) ) {
1135
-            foreach ( $payment_fees as $fee ) {
1133
+        $payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array();
1134
+        if (!empty($payment_fees)) {
1135
+            foreach ($payment_fees as $fee) {
1136 1136
                 $fees_total += (float) $fee['amount'];
1137 1137
             }
1138 1138
         }
1139 1139
 
1140
-        return apply_filters( 'wpinv_get_invoice_fees_total', $fees_total, $this->ID, $this );
1140
+        return apply_filters('wpinv_get_invoice_fees_total', $fees_total, $this->ID, $this);
1141 1141
 
1142 1142
     }
1143 1143
 
1144 1144
     public function get_user_id() {
1145
-        return apply_filters( 'wpinv_user_id', $this->user_id, $this->ID, $this );
1145
+        return apply_filters('wpinv_user_id', $this->user_id, $this->ID, $this);
1146 1146
     }
1147 1147
     
1148 1148
     public function get_first_name() {
1149
-        return apply_filters( 'wpinv_first_name', $this->first_name, $this->ID, $this );
1149
+        return apply_filters('wpinv_first_name', $this->first_name, $this->ID, $this);
1150 1150
     }
1151 1151
     
1152 1152
     public function get_last_name() {
1153
-        return apply_filters( 'wpinv_last_name', $this->last_name, $this->ID, $this );
1153
+        return apply_filters('wpinv_last_name', $this->last_name, $this->ID, $this);
1154 1154
     }
1155 1155
     
1156 1156
     public function get_user_full_name() {
1157
-        return apply_filters( 'wpinv_user_full_name', $this->full_name, $this->ID, $this );
1157
+        return apply_filters('wpinv_user_full_name', $this->full_name, $this->ID, $this);
1158 1158
     }
1159 1159
     
1160 1160
     public function get_user_info() {
1161
-        return apply_filters( 'wpinv_user_info', $this->user_info, $this->ID, $this );
1161
+        return apply_filters('wpinv_user_info', $this->user_info, $this->ID, $this);
1162 1162
     }
1163 1163
     
1164 1164
     public function get_email() {
1165
-        return apply_filters( 'wpinv_user_email', $this->email, $this->ID, $this );
1165
+        return apply_filters('wpinv_user_email', $this->email, $this->ID, $this);
1166 1166
     }
1167 1167
     
1168 1168
     public function get_address() {
1169
-        return apply_filters( 'wpinv_address', $this->address, $this->ID, $this );
1169
+        return apply_filters('wpinv_address', $this->address, $this->ID, $this);
1170 1170
     }
1171 1171
     
1172 1172
     public function get_phone() {
1173
-        return apply_filters( 'wpinv_phone', $this->phone, $this->ID, $this );
1173
+        return apply_filters('wpinv_phone', $this->phone, $this->ID, $this);
1174 1174
     }
1175 1175
     
1176 1176
     public function get_number() {
1177
-        return apply_filters( 'wpinv_number', $this->number, $this->ID, $this );
1177
+        return apply_filters('wpinv_number', $this->number, $this->ID, $this);
1178 1178
     }
1179 1179
     
1180 1180
     public function get_items() {
1181
-        return apply_filters( 'wpinv_payment_meta_items', $this->items, $this->ID, $this );
1181
+        return apply_filters('wpinv_payment_meta_items', $this->items, $this->ID, $this);
1182 1182
     }
1183 1183
     
1184 1184
     public function get_key() {
1185
-        return apply_filters( 'wpinv_key', $this->key, $this->ID, $this );
1185
+        return apply_filters('wpinv_key', $this->key, $this->ID, $this);
1186 1186
     }
1187 1187
     
1188 1188
     public function get_transaction_id() {
1189
-        return apply_filters( 'wpinv_get_invoice_transaction_id', $this->transaction_id, $this->ID, $this );
1189
+        return apply_filters('wpinv_get_invoice_transaction_id', $this->transaction_id, $this->ID, $this);
1190 1190
     }
1191 1191
     
1192 1192
     public function get_gateway() {
1193
-        return apply_filters( 'wpinv_gateway', $this->gateway, $this->ID, $this );
1193
+        return apply_filters('wpinv_gateway', $this->gateway, $this->ID, $this);
1194 1194
     }
1195 1195
     
1196 1196
     public function get_gateway_title() {}
1197 1197
     
1198 1198
     public function get_currency() {
1199
-        return apply_filters( 'wpinv_currency_code', $this->currency, $this->ID, $this );
1199
+        return apply_filters('wpinv_currency_code', $this->currency, $this->ID, $this);
1200 1200
     }
1201 1201
     
1202 1202
     public function get_created_date() {
1203
-        return apply_filters( 'wpinv_created_date', $this->date, $this->ID, $this );
1203
+        return apply_filters('wpinv_created_date', $this->date, $this->ID, $this);
1204 1204
     }
1205 1205
     
1206
-    public function get_due_date( $display = false ) {
1207
-        $due_date = apply_filters( 'wpinv_due_date', $this->due_date, $this->ID, $this );
1206
+    public function get_due_date($display = false) {
1207
+        $due_date = apply_filters('wpinv_due_date', $this->due_date, $this->ID, $this);
1208 1208
 
1209
-        if ( ! $display ) {
1209
+        if (!$display) {
1210 1210
             return $due_date;
1211 1211
         }
1212 1212
         
1213
-        return getpaid_format_date( $this->due_date );
1213
+        return getpaid_format_date($this->due_date);
1214 1214
     }
1215 1215
     
1216 1216
     public function get_completed_date() {
1217
-        return apply_filters( 'wpinv_completed_date', $this->completed_date, $this->ID, $this );
1217
+        return apply_filters('wpinv_completed_date', $this->completed_date, $this->ID, $this);
1218 1218
     }
1219 1219
     
1220
-    public function get_invoice_date( $formatted = true ) {
1220
+    public function get_invoice_date($formatted = true) {
1221 1221
         $date_completed = $this->completed_date;
1222 1222
         $invoice_date   = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? $date_completed : '';
1223 1223
         
1224
-        if ( $invoice_date == '' ) {
1224
+        if ($invoice_date == '') {
1225 1225
             $date_created   = $this->date;
1226 1226
             $invoice_date   = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? $date_created : '';
1227 1227
         }
1228 1228
         
1229
-        if ( $formatted && $invoice_date ) {
1230
-            $invoice_date   = getpaid_format_date( $invoice_date );
1229
+        if ($formatted && $invoice_date) {
1230
+            $invoice_date = getpaid_format_date($invoice_date);
1231 1231
         }
1232 1232
 
1233
-        return apply_filters( 'wpinv_get_invoice_date', $invoice_date, $formatted, $this->ID, $this );
1233
+        return apply_filters('wpinv_get_invoice_date', $invoice_date, $formatted, $this->ID, $this);
1234 1234
     }
1235 1235
     
1236 1236
     public function get_ip() {
1237
-        return apply_filters( 'wpinv_user_ip', $this->ip, $this->ID, $this );
1237
+        return apply_filters('wpinv_user_ip', $this->ip, $this->ID, $this);
1238 1238
     }
1239 1239
         
1240
-    public function has_status( $status ) {
1241
-        return apply_filters( 'wpinv_has_status', ( is_array( $status ) && in_array( $this->get_status(), $status ) ) || $this->get_status() === $status ? true : false, $this, $status );
1240
+    public function has_status($status) {
1241
+        return apply_filters('wpinv_has_status', (is_array($status) && in_array($this->get_status(), $status)) || $this->get_status() === $status ? true : false, $this, $status);
1242 1242
     }
1243 1243
 
1244 1244
     public function add_item() {}
@@ -1255,66 +1255,66 @@  discard block
 block discarded – undo
1255 1255
 
1256 1256
     public function get_view_url() {}
1257 1257
 
1258
-    public function generate_key( $string = '' ) {
1259
-        $auth_key  = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
1260
-        return strtolower( md5( $string . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) ) );  // Unique key
1258
+    public function generate_key($string = '') {
1259
+        $auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
1260
+        return strtolower(md5($string . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true))); // Unique key
1261 1261
     }
1262 1262
     
1263 1263
     public function is_recurring() {
1264
-        if ( empty( $this->cart_details ) ) {
1264
+        if (empty($this->cart_details)) {
1265 1265
             return false;
1266 1266
         }
1267 1267
         
1268 1268
         $has_subscription = false;
1269
-        foreach( $this->cart_details as $cart_item ) {
1270
-            if ( !empty( $cart_item['id'] ) && wpinv_is_recurring_item( $cart_item['id'] )  ) {
1269
+        foreach ($this->cart_details as $cart_item) {
1270
+            if (!empty($cart_item['id']) && wpinv_is_recurring_item($cart_item['id'])) {
1271 1271
                 $has_subscription = true;
1272 1272
                 break;
1273 1273
             }
1274 1274
         }
1275 1275
         
1276
-        if ( count( $this->cart_details ) > 1 ) {
1276
+        if (count($this->cart_details) > 1) {
1277 1277
             $has_subscription = false;
1278 1278
         }
1279 1279
 
1280
-        return apply_filters( 'wpinv_invoice_has_recurring_item', $has_subscription, $this->cart_details );
1280
+        return apply_filters('wpinv_invoice_has_recurring_item', $has_subscription, $this->cart_details);
1281 1281
     }
1282 1282
 
1283 1283
     public function is_free_trial() {
1284 1284
         $is_free_trial = false;
1285 1285
         
1286
-        if ( $this->is_parent() && $item = $this->get_recurring( true ) ) {
1287
-            if ( !empty( $item ) && $item->has_free_trial() ) {
1286
+        if ($this->is_parent() && $item = $this->get_recurring(true)) {
1287
+            if (!empty($item) && $item->has_free_trial()) {
1288 1288
                 $is_free_trial = true;
1289 1289
             }
1290 1290
         }
1291 1291
 
1292
-        return apply_filters( 'wpinv_invoice_is_free_trial', $is_free_trial, $this->cart_details, $this );
1292
+        return apply_filters('wpinv_invoice_is_free_trial', $is_free_trial, $this->cart_details, $this);
1293 1293
     }
1294 1294
 
1295 1295
     public function is_initial_free() {}
1296 1296
 
1297
-    public function get_recurring( $object = false ) {
1297
+    public function get_recurring($object = false) {
1298 1298
         $item = NULL;
1299 1299
         
1300
-        if ( empty( $this->cart_details ) ) {
1300
+        if (empty($this->cart_details)) {
1301 1301
             return $item;
1302 1302
         }
1303 1303
         
1304
-        foreach( $this->cart_details as $cart_item ) {
1305
-            if ( !empty( $cart_item['id'] ) && wpinv_is_recurring_item( $cart_item['id'] )  ) {
1304
+        foreach ($this->cart_details as $cart_item) {
1305
+            if (!empty($cart_item['id']) && wpinv_is_recurring_item($cart_item['id'])) {
1306 1306
                 $item = $cart_item['id'];
1307 1307
                 break;
1308 1308
             }
1309 1309
         }
1310 1310
         
1311
-        if ( $object ) {
1312
-            $item = $item ? new WPInv_Item( $item ) : NULL;
1311
+        if ($object) {
1312
+            $item = $item ? new WPInv_Item($item) : NULL;
1313 1313
             
1314
-            apply_filters( 'wpinv_invoice_get_recurring_item', $item, $this );
1314
+            apply_filters('wpinv_invoice_get_recurring_item', $item, $this);
1315 1315
         }
1316 1316
 
1317
-        return apply_filters( 'wpinv_invoice_get_recurring_item_id', $item, $this );
1317
+        return apply_filters('wpinv_invoice_get_recurring_item_id', $item, $this);
1318 1318
     }
1319 1319
 
1320 1320
     public function get_subscription_name() {}
@@ -1322,7 +1322,7 @@  discard block
 block discarded – undo
1322 1322
     public function get_subscription_id() {}
1323 1323
 
1324 1324
     public function is_parent() {
1325
-        return ! empty( $this->parent_invoice );
1325
+        return !empty($this->parent_invoice);
1326 1326
     }
1327 1327
 
1328 1328
     public function is_renewal() {}
@@ -1336,8 +1336,8 @@  discard block
 block discarded – undo
1336 1336
     public function is_refunded() {}
1337 1337
 
1338 1338
     public function is_free() {
1339
-        $total = (float) wpinv_round_amount( $this->get_total() );
1340
-        return $total > 0 && ! $this->is_recurring();
1339
+        $total = (float) wpinv_round_amount($this->get_total());
1340
+        return $total > 0 && !$this->is_recurring();
1341 1341
     }
1342 1342
 
1343 1343
     public function has_vat() {}
Please login to merge, or discard this patch.
includes/class-getpaid-tax.php 2 patches
Indentation   +159 added lines, -159 removed lines patch added patch discarded remove patch
@@ -13,164 +13,164 @@
 block discarded – undo
13 13
  */
14 14
 class GetPaid_Tax {
15 15
 
16
-	/**
17
-	 * Calculates tax for a line item.
18
-	 *
19
-	 * @param  float   $price              The price to calc tax on.
20
-	 * @param  array   $rates              The rates to apply.
21
-	 * @param  boolean $price_includes_tax Whether the passed price has taxes included.
22
-	 * @return array                       Array of tax name => tax amount.
23
-	 */
24
-	public static function calc_tax( $price, $rates, $price_includes_tax = false ) {
25
-
26
-		if ( $price_includes_tax ) {
27
-			$taxes = self::calc_inclusive_tax( $price, $rates );
28
-		} else {
29
-			$taxes = self::calc_exclusive_tax( $price, $rates );
30
-		}
31
-
32
-		return apply_filters( 'getpaid_calc_tax', $taxes, $price, $rates, $price_includes_tax );
33
-
34
-	}
35
-
36
-	/**
37
-	 * Calc tax from inclusive price.
38
-	 *
39
-	 * @param  float $price Price to calculate tax for.
40
-	 * @param  array $rates Array of tax rates.
41
-	 * @return array
42
-	 */
43
-	public static function calc_inclusive_tax( $price, $rates ) {
44
-		$taxes     = array();
45
-		$tax_rates = wp_list_pluck( $rates, 'rate', 'name' );
46
-
47
-		// Add tax rates.
48
-		$tax_rate  = 1 + ( array_sum( $tax_rates ) / 100 );
49
-
50
-		foreach ( $tax_rates as $name => $rate ) {
51
-			$the_rate       = ( $rate / 100 ) / $tax_rate;
52
-			$net_price      = $price - ( $the_rate * $price );
53
-			$tax_amount     = apply_filters( 'getpaid_price_inc_tax_amount', $price - $net_price, $name, $rate, $price );
54
-			$taxes[ $name ] = $tax_amount;
55
-		}
56
-
57
-		// Round all taxes to precision (4DP) before passing them back.
58
-		$taxes = array_map( array( __CLASS__, 'round' ), $taxes );
59
-
60
-		return $taxes;
61
-	}
62
-
63
-	/**
64
-	 * Calc tax from exclusive price.
65
-	 *
66
-	 * @param  float $price Price to calculate tax for.
67
-	 * @param  array $rates Array of tax rates.
68
-	 * @return array
69
-	 */
70
-	public static function calc_exclusive_tax( $price, $rates ) {
71
-		$taxes     = array();
72
-		$tax_rates = wp_list_pluck( $rates, 'rate', 'name' );
73
-
74
-		foreach ( $tax_rates as $name => $rate ) {
75
-
76
-			$tax_amount     = $price * ( $rate / 100 );
77
-			$taxes[ $name ] = apply_filters( 'getpaid_price_ex_tax_amount', $tax_amount, $name, $rate, $price );
78
-
79
-		}
80
-
81
-		// Round all taxes to precision (4DP) before passing them back.
82
-		$taxes = array_map( array( __CLASS__, 'round' ), $taxes );
83
-
84
-		return $taxes;
85
-	}
86
-
87
-	/**
88
-	 * Get's an array of all tax rates.
89
-	 *
90
-	 * @return array
91
-	 */
92
-	public static function get_all_tax_rates() {
93
-
94
-		$rates = get_option( 'wpinv_tax_rates', array() );
95
-
96
-		return apply_filters(
97
-			'getpaid_get_all_tax_rates',
98
-			array_filter( wpinv_parse_list( $rates ) )
99
-		);
100
-
101
-	}
102
-
103
-	/**
104
-	 * Get's an array of default tax rates.
105
-	 *
106
-	 * @return array
107
-	 */
108
-	public static function get_default_tax_rates() {
109
-
110
-		return apply_filters(
111
-			'getpaid_get_default_tax_rates',
112
-			array(
113
-				array(
114
-				'country'   => wpinv_get_default_country(),
115
-				'state'     => wpinv_get_default_state(),
116
-				'global'    => true,
117
-				'rate'      => wpinv_get_default_tax_rate(),
118
-				'name'      => __( 'Base Tax', 'invoicing' ),
119
-				)
120
-			)
121
-		);
122
-
123
-	}
124
-
125
-	/**
126
-	 * Get's an array of tax rates for a given address.
127
-	 *
128
-	 * @param string $country
129
-	 * @param string $state
130
-	 * @return array
131
-	 */
132
-	public static function get_address_tax_rates( $country, $state ) {
133
-
134
-		$all_tax_rates  = self::get_all_tax_rates();
135
-		$matching_rates = wp_list_filter( $all_tax_rates, array( 'country' => $country ) );
136
-
137
-		foreach ( $matching_rates as $i => $rate ) {
138
-
139
-			if ( empty( $rate['global'] ) && $rate['state'] != $state ) {
140
-				unset( $matching_rates[ $i ] );
141
-			}
142
-
143
-		}
144
-
145
-		return apply_filters( 'getpaid_get_address_tax_rates', $matching_rates, $country, $state );
146
-
147
-	}
148
-
149
-	/**
150
-	 * Sums a set of taxes to form a single total. Result is rounded to precision.
151
-	 *
152
-	 * @param  array $taxes Array of taxes.
153
-	 * @return float
154
-	 */
155
-	public static function get_tax_total( $taxes ) {
156
-		return self::round( array_sum( $taxes ) );
157
-	}
158
-
159
-	/**
160
-	 * Round to precision.
161
-	 *
162
-	 * Filter example: to return rounding to .5 cents you'd use:
163
-	 *
164
-	 * function euro_5cent_rounding( $in ) {
165
-	 *      return round( $in / 5, 2 ) * 5;
166
-	 * }
167
-	 * add_filter( 'getpaid_tax_round', 'euro_5cent_rounding' );
168
-	 *
169
-	 * @param float|int $in Value to round.
170
-	 * @return float
171
-	 */
172
-	public static function round( $in ) {
173
-		return apply_filters( 'getpaid_tax_round', round( $in, 4 ), $in );
174
-	}
16
+    /**
17
+     * Calculates tax for a line item.
18
+     *
19
+     * @param  float   $price              The price to calc tax on.
20
+     * @param  array   $rates              The rates to apply.
21
+     * @param  boolean $price_includes_tax Whether the passed price has taxes included.
22
+     * @return array                       Array of tax name => tax amount.
23
+     */
24
+    public static function calc_tax( $price, $rates, $price_includes_tax = false ) {
25
+
26
+        if ( $price_includes_tax ) {
27
+            $taxes = self::calc_inclusive_tax( $price, $rates );
28
+        } else {
29
+            $taxes = self::calc_exclusive_tax( $price, $rates );
30
+        }
31
+
32
+        return apply_filters( 'getpaid_calc_tax', $taxes, $price, $rates, $price_includes_tax );
33
+
34
+    }
35
+
36
+    /**
37
+     * Calc tax from inclusive price.
38
+     *
39
+     * @param  float $price Price to calculate tax for.
40
+     * @param  array $rates Array of tax rates.
41
+     * @return array
42
+     */
43
+    public static function calc_inclusive_tax( $price, $rates ) {
44
+        $taxes     = array();
45
+        $tax_rates = wp_list_pluck( $rates, 'rate', 'name' );
46
+
47
+        // Add tax rates.
48
+        $tax_rate  = 1 + ( array_sum( $tax_rates ) / 100 );
49
+
50
+        foreach ( $tax_rates as $name => $rate ) {
51
+            $the_rate       = ( $rate / 100 ) / $tax_rate;
52
+            $net_price      = $price - ( $the_rate * $price );
53
+            $tax_amount     = apply_filters( 'getpaid_price_inc_tax_amount', $price - $net_price, $name, $rate, $price );
54
+            $taxes[ $name ] = $tax_amount;
55
+        }
56
+
57
+        // Round all taxes to precision (4DP) before passing them back.
58
+        $taxes = array_map( array( __CLASS__, 'round' ), $taxes );
59
+
60
+        return $taxes;
61
+    }
62
+
63
+    /**
64
+     * Calc tax from exclusive price.
65
+     *
66
+     * @param  float $price Price to calculate tax for.
67
+     * @param  array $rates Array of tax rates.
68
+     * @return array
69
+     */
70
+    public static function calc_exclusive_tax( $price, $rates ) {
71
+        $taxes     = array();
72
+        $tax_rates = wp_list_pluck( $rates, 'rate', 'name' );
73
+
74
+        foreach ( $tax_rates as $name => $rate ) {
75
+
76
+            $tax_amount     = $price * ( $rate / 100 );
77
+            $taxes[ $name ] = apply_filters( 'getpaid_price_ex_tax_amount', $tax_amount, $name, $rate, $price );
78
+
79
+        }
80
+
81
+        // Round all taxes to precision (4DP) before passing them back.
82
+        $taxes = array_map( array( __CLASS__, 'round' ), $taxes );
83
+
84
+        return $taxes;
85
+    }
86
+
87
+    /**
88
+     * Get's an array of all tax rates.
89
+     *
90
+     * @return array
91
+     */
92
+    public static function get_all_tax_rates() {
93
+
94
+        $rates = get_option( 'wpinv_tax_rates', array() );
95
+
96
+        return apply_filters(
97
+            'getpaid_get_all_tax_rates',
98
+            array_filter( wpinv_parse_list( $rates ) )
99
+        );
100
+
101
+    }
102
+
103
+    /**
104
+     * Get's an array of default tax rates.
105
+     *
106
+     * @return array
107
+     */
108
+    public static function get_default_tax_rates() {
109
+
110
+        return apply_filters(
111
+            'getpaid_get_default_tax_rates',
112
+            array(
113
+                array(
114
+                'country'   => wpinv_get_default_country(),
115
+                'state'     => wpinv_get_default_state(),
116
+                'global'    => true,
117
+                'rate'      => wpinv_get_default_tax_rate(),
118
+                'name'      => __( 'Base Tax', 'invoicing' ),
119
+                )
120
+            )
121
+        );
122
+
123
+    }
124
+
125
+    /**
126
+     * Get's an array of tax rates for a given address.
127
+     *
128
+     * @param string $country
129
+     * @param string $state
130
+     * @return array
131
+     */
132
+    public static function get_address_tax_rates( $country, $state ) {
133
+
134
+        $all_tax_rates  = self::get_all_tax_rates();
135
+        $matching_rates = wp_list_filter( $all_tax_rates, array( 'country' => $country ) );
136
+
137
+        foreach ( $matching_rates as $i => $rate ) {
138
+
139
+            if ( empty( $rate['global'] ) && $rate['state'] != $state ) {
140
+                unset( $matching_rates[ $i ] );
141
+            }
142
+
143
+        }
144
+
145
+        return apply_filters( 'getpaid_get_address_tax_rates', $matching_rates, $country, $state );
146
+
147
+    }
148
+
149
+    /**
150
+     * Sums a set of taxes to form a single total. Result is rounded to precision.
151
+     *
152
+     * @param  array $taxes Array of taxes.
153
+     * @return float
154
+     */
155
+    public static function get_tax_total( $taxes ) {
156
+        return self::round( array_sum( $taxes ) );
157
+    }
158
+
159
+    /**
160
+     * Round to precision.
161
+     *
162
+     * Filter example: to return rounding to .5 cents you'd use:
163
+     *
164
+     * function euro_5cent_rounding( $in ) {
165
+     *      return round( $in / 5, 2 ) * 5;
166
+     * }
167
+     * add_filter( 'getpaid_tax_round', 'euro_5cent_rounding' );
168
+     *
169
+     * @param float|int $in Value to round.
170
+     * @return float
171
+     */
172
+    public static function round( $in ) {
173
+        return apply_filters( 'getpaid_tax_round', round( $in, 4 ), $in );
174
+    }
175 175
 
176 176
 }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * Class GetPaid_Tax
@@ -21,15 +21,15 @@  discard block
 block discarded – undo
21 21
 	 * @param  boolean $price_includes_tax Whether the passed price has taxes included.
22 22
 	 * @return array                       Array of tax name => tax amount.
23 23
 	 */
24
-	public static function calc_tax( $price, $rates, $price_includes_tax = false ) {
24
+	public static function calc_tax($price, $rates, $price_includes_tax = false) {
25 25
 
26
-		if ( $price_includes_tax ) {
27
-			$taxes = self::calc_inclusive_tax( $price, $rates );
26
+		if ($price_includes_tax) {
27
+			$taxes = self::calc_inclusive_tax($price, $rates);
28 28
 		} else {
29
-			$taxes = self::calc_exclusive_tax( $price, $rates );
29
+			$taxes = self::calc_exclusive_tax($price, $rates);
30 30
 		}
31 31
 
32
-		return apply_filters( 'getpaid_calc_tax', $taxes, $price, $rates, $price_includes_tax );
32
+		return apply_filters('getpaid_calc_tax', $taxes, $price, $rates, $price_includes_tax);
33 33
 
34 34
 	}
35 35
 
@@ -40,22 +40,22 @@  discard block
 block discarded – undo
40 40
 	 * @param  array $rates Array of tax rates.
41 41
 	 * @return array
42 42
 	 */
43
-	public static function calc_inclusive_tax( $price, $rates ) {
43
+	public static function calc_inclusive_tax($price, $rates) {
44 44
 		$taxes     = array();
45
-		$tax_rates = wp_list_pluck( $rates, 'rate', 'name' );
45
+		$tax_rates = wp_list_pluck($rates, 'rate', 'name');
46 46
 
47 47
 		// Add tax rates.
48
-		$tax_rate  = 1 + ( array_sum( $tax_rates ) / 100 );
48
+		$tax_rate  = 1 + (array_sum($tax_rates) / 100);
49 49
 
50
-		foreach ( $tax_rates as $name => $rate ) {
51
-			$the_rate       = ( $rate / 100 ) / $tax_rate;
52
-			$net_price      = $price - ( $the_rate * $price );
53
-			$tax_amount     = apply_filters( 'getpaid_price_inc_tax_amount', $price - $net_price, $name, $rate, $price );
54
-			$taxes[ $name ] = $tax_amount;
50
+		foreach ($tax_rates as $name => $rate) {
51
+			$the_rate       = ($rate / 100) / $tax_rate;
52
+			$net_price      = $price - ($the_rate * $price);
53
+			$tax_amount     = apply_filters('getpaid_price_inc_tax_amount', $price - $net_price, $name, $rate, $price);
54
+			$taxes[$name] = $tax_amount;
55 55
 		}
56 56
 
57 57
 		// Round all taxes to precision (4DP) before passing them back.
58
-		$taxes = array_map( array( __CLASS__, 'round' ), $taxes );
58
+		$taxes = array_map(array(__CLASS__, 'round'), $taxes);
59 59
 
60 60
 		return $taxes;
61 61
 	}
@@ -67,19 +67,19 @@  discard block
 block discarded – undo
67 67
 	 * @param  array $rates Array of tax rates.
68 68
 	 * @return array
69 69
 	 */
70
-	public static function calc_exclusive_tax( $price, $rates ) {
70
+	public static function calc_exclusive_tax($price, $rates) {
71 71
 		$taxes     = array();
72
-		$tax_rates = wp_list_pluck( $rates, 'rate', 'name' );
72
+		$tax_rates = wp_list_pluck($rates, 'rate', 'name');
73 73
 
74
-		foreach ( $tax_rates as $name => $rate ) {
74
+		foreach ($tax_rates as $name => $rate) {
75 75
 
76
-			$tax_amount     = $price * ( $rate / 100 );
77
-			$taxes[ $name ] = apply_filters( 'getpaid_price_ex_tax_amount', $tax_amount, $name, $rate, $price );
76
+			$tax_amount     = $price * ($rate / 100);
77
+			$taxes[$name] = apply_filters('getpaid_price_ex_tax_amount', $tax_amount, $name, $rate, $price);
78 78
 
79 79
 		}
80 80
 
81 81
 		// Round all taxes to precision (4DP) before passing them back.
82
-		$taxes = array_map( array( __CLASS__, 'round' ), $taxes );
82
+		$taxes = array_map(array(__CLASS__, 'round'), $taxes);
83 83
 
84 84
 		return $taxes;
85 85
 	}
@@ -91,11 +91,11 @@  discard block
 block discarded – undo
91 91
 	 */
92 92
 	public static function get_all_tax_rates() {
93 93
 
94
-		$rates = get_option( 'wpinv_tax_rates', array() );
94
+		$rates = get_option('wpinv_tax_rates', array());
95 95
 
96 96
 		return apply_filters(
97 97
 			'getpaid_get_all_tax_rates',
98
-			array_filter( wpinv_parse_list( $rates ) )
98
+			array_filter(wpinv_parse_list($rates))
99 99
 		);
100 100
 
101 101
 	}
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 				'state'     => wpinv_get_default_state(),
116 116
 				'global'    => true,
117 117
 				'rate'      => wpinv_get_default_tax_rate(),
118
-				'name'      => __( 'Base Tax', 'invoicing' ),
118
+				'name'      => __('Base Tax', 'invoicing'),
119 119
 				)
120 120
 			)
121 121
 		);
@@ -129,20 +129,20 @@  discard block
 block discarded – undo
129 129
 	 * @param string $state
130 130
 	 * @return array
131 131
 	 */
132
-	public static function get_address_tax_rates( $country, $state ) {
132
+	public static function get_address_tax_rates($country, $state) {
133 133
 
134 134
 		$all_tax_rates  = self::get_all_tax_rates();
135
-		$matching_rates = wp_list_filter( $all_tax_rates, array( 'country' => $country ) );
135
+		$matching_rates = wp_list_filter($all_tax_rates, array('country' => $country));
136 136
 
137
-		foreach ( $matching_rates as $i => $rate ) {
137
+		foreach ($matching_rates as $i => $rate) {
138 138
 
139
-			if ( empty( $rate['global'] ) && $rate['state'] != $state ) {
140
-				unset( $matching_rates[ $i ] );
139
+			if (empty($rate['global']) && $rate['state'] != $state) {
140
+				unset($matching_rates[$i]);
141 141
 			}
142 142
 
143 143
 		}
144 144
 
145
-		return apply_filters( 'getpaid_get_address_tax_rates', $matching_rates, $country, $state );
145
+		return apply_filters('getpaid_get_address_tax_rates', $matching_rates, $country, $state);
146 146
 
147 147
 	}
148 148
 
@@ -152,8 +152,8 @@  discard block
 block discarded – undo
152 152
 	 * @param  array $taxes Array of taxes.
153 153
 	 * @return float
154 154
 	 */
155
-	public static function get_tax_total( $taxes ) {
156
-		return self::round( array_sum( $taxes ) );
155
+	public static function get_tax_total($taxes) {
156
+		return self::round(array_sum($taxes));
157 157
 	}
158 158
 
159 159
 	/**
@@ -169,8 +169,8 @@  discard block
 block discarded – undo
169 169
 	 * @param float|int $in Value to round.
170 170
 	 * @return float
171 171
 	 */
172
-	public static function round( $in ) {
173
-		return apply_filters( 'getpaid_tax_round', round( $in, 4 ), $in );
172
+	public static function round($in) {
173
+		return apply_filters('getpaid_tax_round', round($in, 4), $in);
174 174
 	}
175 175
 
176 176
 }
Please login to merge, or discard this patch.
includes/wpinv-item-functions.php 1 patch
Spacing   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
  
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Retrieves an item by it's ID.
@@ -14,9 +14,9 @@  discard block
 block discarded – undo
14 14
  * @param int the item ID to retrieve.
15 15
  * @return WPInv_Item|false
16 16
  */
17
-function wpinv_get_item_by_id( $id ) {
18
-    $item = wpinv_get_item( $id );
19
-    return empty( $item ) || $id != $item->get_id() ? false : $item;
17
+function wpinv_get_item_by_id($id) {
18
+    $item = wpinv_get_item($id);
19
+    return empty($item) || $id != $item->get_id() ? false : $item;
20 20
 }
21 21
 
22 22
 /**
@@ -24,14 +24,14 @@  discard block
 block discarded – undo
24 24
  * 
25 25
  * @return WPInv_Item|false
26 26
  */
27
-function wpinv_get_item_by( $field = '', $value = '', $type = '' ) {
27
+function wpinv_get_item_by($field = '', $value = '', $type = '') {
28 28
 
29
-    if ( 'id' == strtolower( $field ) ) {
30
-        return wpinv_get_item_by_id( $field );
29
+    if ('id' == strtolower($field)) {
30
+        return wpinv_get_item_by_id($field);
31 31
     }
32 32
 
33
-    $id = WPInv_Item::get_item_id_by_field( $value, strtolower( $field ), $type );
34
-    return empty( $id ) ? false : wpinv_get_item( $id );
33
+    $id = WPInv_Item::get_item_id_by_field($value, strtolower($field), $type);
34
+    return empty($id) ? false : wpinv_get_item($id);
35 35
 
36 36
 }
37 37
 
@@ -41,22 +41,22 @@  discard block
 block discarded – undo
41 41
  * @param int|WPInv_Item the item to retrieve.
42 42
  * @return WPInv_Item|false
43 43
  */
44
-function wpinv_get_item( $item = 0 ) {
44
+function wpinv_get_item($item = 0) {
45 45
 
46
-    if ( empty( $item ) ) {
46
+    if (empty($item)) {
47 47
         return false;
48 48
     }
49 49
 
50
-    $item = new WPInv_Item( $item );
50
+    $item = new WPInv_Item($item);
51 51
     return $item->exists() ? $item : false;
52 52
 
53 53
 }
54 54
 
55
-function wpinv_get_all_items( $args = array() ) {
55
+function wpinv_get_all_items($args = array()) {
56 56
 
57
-    $args = wp_parse_args( $args, array(
58
-        'status'         => array( 'publish' ),
59
-        'limit'          => get_option( 'posts_per_page' ),
57
+    $args = wp_parse_args($args, array(
58
+        'status'         => array('publish'),
59
+        'limit'          => get_option('posts_per_page'),
60 60
         'page'           => 1,
61 61
         'exclude'        => array(),
62 62
         'orderby'        => 'date',
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
         'meta_query'     => array(),
66 66
         'return'         => 'objects',
67 67
         'paginate'       => false,
68
-    ) );
68
+    ));
69 69
 
70 70
     $wp_query_args = array(
71 71
         'post_type'      => 'wpi_item',
@@ -75,26 +75,26 @@  discard block
 block discarded – undo
75 75
         'fields'         => 'ids',
76 76
         'orderby'        => $args['orderby'],
77 77
         'order'          => $args['order'],
78
-        'paged'          => absint( $args['page'] ),
78
+        'paged'          => absint($args['page']),
79 79
     );
80 80
 
81
-    if ( ! empty( $args['exclude'] ) ) {
82
-        $wp_query_args['post__not_in'] = array_map( 'absint', $args['exclude'] );
81
+    if (!empty($args['exclude'])) {
82
+        $wp_query_args['post__not_in'] = array_map('absint', $args['exclude']);
83 83
     }
84 84
 
85
-    if ( ! $args['paginate' ] ) {
85
+    if (!$args['paginate']) {
86 86
         $wp_query_args['no_found_rows'] = true;
87 87
     }
88 88
 
89
-    if ( ! empty( $args['search'] ) ) {
89
+    if (!empty($args['search'])) {
90 90
         $wp_query_args['s'] = $args['search'];
91 91
     }
92 92
 
93
-    if ( ! empty( $args['type'] ) && $args['type'] !== wpinv_item_types() ) {
94
-        $types = wpinv_parse_list( $args['type'] );
93
+    if (!empty($args['type']) && $args['type'] !== wpinv_item_types()) {
94
+        $types = wpinv_parse_list($args['type']);
95 95
         $wp_query_args['meta_query'][] = array(
96 96
             'key'     => '_wpinv_type',
97
-            'value'   => implode( ',', $types ),
97
+            'value'   => implode(',', $types),
98 98
             'compare' => 'IN',
99 99
         );
100 100
     }
@@ -102,17 +102,17 @@  discard block
 block discarded – undo
102 102
     $wp_query_args = apply_filters('wpinv_get_items_args', $wp_query_args, $args);
103 103
 
104 104
     // Get results.
105
-    $items = new WP_Query( $wp_query_args );
105
+    $items = new WP_Query($wp_query_args);
106 106
 
107
-    if ( 'objects' === $args['return'] ) {
108
-        $return = array_map( 'wpinv_get_item_by_id', $items->posts );
109
-    } elseif ( 'self' === $args['return'] ) {
107
+    if ('objects' === $args['return']) {
108
+        $return = array_map('wpinv_get_item_by_id', $items->posts);
109
+    } elseif ('self' === $args['return']) {
110 110
         return $items;
111 111
     } else {
112 112
         $return = $items->posts;
113 113
     }
114 114
 
115
-    if ( $args['paginate' ] ) {
115
+    if ($args['paginate']) {
116 116
         return (object) array(
117 117
             'items'      => $return,
118 118
             'total'         => $items->found_posts,
@@ -124,12 +124,12 @@  discard block
 block discarded – undo
124 124
 
125 125
 }
126 126
 
127
-function wpinv_is_free_item( $item_id = 0 ) {
128
-    if( empty( $item_id ) ) {
127
+function wpinv_is_free_item($item_id = 0) {
128
+    if (empty($item_id)) {
129 129
         return false;
130 130
     }
131 131
 
132
-    $item = new WPInv_Item( $item_id );
132
+    $item = new WPInv_Item($item_id);
133 133
     
134 134
     return $item->is_free();
135 135
 }
@@ -139,21 +139,21 @@  discard block
 block discarded – undo
139 139
  * 
140 140
  * @param WP_Post|WPInv_Item|Int $item The item to check for.
141 141
  */
142
-function wpinv_item_is_editable( $item = 0 ) {
142
+function wpinv_item_is_editable($item = 0) {
143 143
 
144 144
     // Fetch the item.
145
-    $item = new WPInv_Item( $item );
145
+    $item = new WPInv_Item($item);
146 146
 
147 147
     // Check if it is editable.
148 148
     return $item->is_editable();
149 149
 }
150 150
 
151
-function wpinv_get_item_price( $item_id = 0 ) {
152
-    if( empty( $item_id ) ) {
151
+function wpinv_get_item_price($item_id = 0) {
152
+    if (empty($item_id)) {
153 153
         return false;
154 154
     }
155 155
 
156
-    $item = new WPInv_Item( $item_id );
156
+    $item = new WPInv_Item($item_id);
157 157
     
158 158
     return $item->get_price();
159 159
 }
@@ -163,96 +163,96 @@  discard block
 block discarded – undo
163 163
  *
164 164
  * @param WPInv_Item|int $item
165 165
  */
166
-function wpinv_is_recurring_item( $item = 0 ) {
167
-    $item = new WPInv_Item( $item ); 
166
+function wpinv_is_recurring_item($item = 0) {
167
+    $item = new WPInv_Item($item); 
168 168
     return $item->is_recurring();
169 169
 }
170 170
 
171
-function wpinv_item_price( $item_id = 0 ) {
172
-    if( empty( $item_id ) ) {
171
+function wpinv_item_price($item_id = 0) {
172
+    if (empty($item_id)) {
173 173
         return false;
174 174
     }
175 175
 
176
-    $price = wpinv_get_item_price( $item_id );
177
-    $price = wpinv_price( wpinv_format_amount( $price ) );
176
+    $price = wpinv_get_item_price($item_id);
177
+    $price = wpinv_price(wpinv_format_amount($price));
178 178
     
179
-    return apply_filters( 'wpinv_item_price', $price, $item_id );
179
+    return apply_filters('wpinv_item_price', $price, $item_id);
180 180
 }
181 181
 
182
-function wpinv_get_item_final_price( $item_id = 0, $amount_override = null ) {
183
-    if ( is_null( $amount_override ) ) {
184
-        $original_price = get_post_meta( $item_id, '_wpinv_price', true );
182
+function wpinv_get_item_final_price($item_id = 0, $amount_override = null) {
183
+    if (is_null($amount_override)) {
184
+        $original_price = get_post_meta($item_id, '_wpinv_price', true);
185 185
     } else {
186 186
         $original_price = $amount_override;
187 187
     }
188 188
     
189 189
     $price = $original_price;
190 190
 
191
-    return apply_filters( 'wpinv_get_item_final_price', $price, $item_id );
191
+    return apply_filters('wpinv_get_item_final_price', $price, $item_id);
192 192
 }
193 193
 
194
-function wpinv_item_custom_singular_name( $item_id ) {
195
-    if( empty( $item_id ) ) {
194
+function wpinv_item_custom_singular_name($item_id) {
195
+    if (empty($item_id)) {
196 196
         return false;
197 197
     }
198 198
 
199
-    $item = new WPInv_Item( $item_id );
199
+    $item = new WPInv_Item($item_id);
200 200
     
201 201
     return $item->get_custom_singular_name();
202 202
 }
203 203
 
204 204
 function wpinv_get_item_types() {
205 205
     $item_types = array(
206
-            'custom'    => __( 'Standard', 'invoicing' ),
207
-            'fee'       => __( 'Fee', 'invoicing' ),
206
+            'custom'    => __('Standard', 'invoicing'),
207
+            'fee'       => __('Fee', 'invoicing'),
208 208
         );
209
-    return apply_filters( 'wpinv_get_item_types', $item_types );
209
+    return apply_filters('wpinv_get_item_types', $item_types);
210 210
 }
211 211
 
212 212
 function wpinv_item_types() {
213 213
     $item_types = wpinv_get_item_types();
214 214
     
215
-    return ( !empty( $item_types ) ? array_keys( $item_types ) : array() );
215
+    return (!empty($item_types) ? array_keys($item_types) : array());
216 216
 }
217 217
 
218
-function wpinv_get_item_type( $item_id ) {
219
-    if( empty( $item_id ) ) {
218
+function wpinv_get_item_type($item_id) {
219
+    if (empty($item_id)) {
220 220
         return false;
221 221
     }
222 222
 
223
-    $item = new WPInv_Item( $item_id );
223
+    $item = new WPInv_Item($item_id);
224 224
     
225 225
     return $item->get_type();
226 226
 }
227 227
 
228
-function wpinv_item_type( $item_id ) {
228
+function wpinv_item_type($item_id) {
229 229
     $item_types = wpinv_get_item_types();
230 230
     
231
-    $item_type = wpinv_get_item_type( $item_id );
231
+    $item_type = wpinv_get_item_type($item_id);
232 232
     
233
-    if ( empty( $item_type ) ) {
233
+    if (empty($item_type)) {
234 234
         $item_type = '-';
235 235
     }
236 236
     
237
-    $item_type = isset( $item_types[$item_type] ) ? $item_types[$item_type] : __( $item_type, 'invoicing' );
237
+    $item_type = isset($item_types[$item_type]) ? $item_types[$item_type] : __($item_type, 'invoicing');
238 238
 
239
-    return apply_filters( 'wpinv_item_type', $item_type, $item_id );
239
+    return apply_filters('wpinv_item_type', $item_type, $item_id);
240 240
 }
241 241
 
242
-function wpinv_get_random_item( $post_ids = true ) {
243
-    wpinv_get_random_items( 1, $post_ids );
242
+function wpinv_get_random_item($post_ids = true) {
243
+    wpinv_get_random_items(1, $post_ids);
244 244
 }
245 245
 
246
-function wpinv_get_random_items( $num = 3, $post_ids = true ) {
247
-    if ( $post_ids ) {
248
-        $args = array( 'post_type' => 'wpi_item', 'orderby' => 'rand', 'post_count' => $num, 'fields' => 'ids' );
246
+function wpinv_get_random_items($num = 3, $post_ids = true) {
247
+    if ($post_ids) {
248
+        $args = array('post_type' => 'wpi_item', 'orderby' => 'rand', 'post_count' => $num, 'fields' => 'ids');
249 249
     } else {
250
-        $args = array( 'post_type' => 'wpi_item', 'orderby' => 'rand', 'post_count' => $num );
250
+        $args = array('post_type' => 'wpi_item', 'orderby' => 'rand', 'post_count' => $num);
251 251
     }
252 252
     
253
-    $args  = apply_filters( 'wpinv_get_random_items', $args );
253
+    $args = apply_filters('wpinv_get_random_items', $args);
254 254
     
255
-    return get_posts( $args );
255
+    return get_posts($args);
256 256
 }
257 257
 
258 258
 /**
@@ -261,13 +261,13 @@  discard block
 block discarded – undo
261 261
  * @param WPInv_Item|int $item
262 262
  * @param bool $html
263 263
  */
264
-function wpinv_get_item_suffix( $item, $html = true ) {
264
+function wpinv_get_item_suffix($item, $html = true) {
265 265
 
266
-    $item   = new WPInv_Item( $item );
267
-    $suffix = $item->is_recurring() ? ' <span class="wpi-suffix">' . __( '(r)', 'invoicing' ) . '</span>' : '';
268
-    $suffix = $html ? $suffix : strip_tags( $suffix );
266
+    $item   = new WPInv_Item($item);
267
+    $suffix = $item->is_recurring() ? ' <span class="wpi-suffix">' . __('(r)', 'invoicing') . '</span>' : '';
268
+    $suffix = $html ? $suffix : strip_tags($suffix);
269 269
 
270
-    return apply_filters( 'wpinv_get_item_suffix', $suffix, $item, $html );
270
+    return apply_filters('wpinv_get_item_suffix', $suffix, $item, $html);
271 271
 }
272 272
 
273 273
 /**
@@ -276,9 +276,9 @@  discard block
 block discarded – undo
276 276
  * @param WPInv_Item|int $item
277 277
  * @param bool $force_delete
278 278
  */
279
-function wpinv_remove_item( $item = 0, $force_delete = false ) {
280
-    $item = new WPInv_Item( $item );
281
-    $item->delete( $force_delete );
279
+function wpinv_remove_item($item = 0, $force_delete = false) {
280
+    $item = new WPInv_Item($item);
281
+    $item->delete($force_delete);
282 282
 }
283 283
 
284 284
 /**
@@ -317,45 +317,45 @@  discard block
 block discarded – undo
317 317
  * @param bool $wp_error whether or not to return a WP_Error on failure.
318 318
  * @return bool|WP_Error|WPInv_Item
319 319
  */
320
-function wpinv_create_item( $args = array(), $wp_error = false ) {
320
+function wpinv_create_item($args = array(), $wp_error = false) {
321 321
 
322 322
     // Prepare the item.
323
-    if ( ! empty( $args['custom_id'] ) && empty( $args['ID'] ) ) {
324
-        $type = empty( $args['type'] ) ? 'custom' : $args['type'];
325
-        $item = wpinv_get_item_by( 'custom_id', $args['custom_id'], $type );
323
+    if (!empty($args['custom_id']) && empty($args['ID'])) {
324
+        $type = empty($args['type']) ? 'custom' : $args['type'];
325
+        $item = wpinv_get_item_by('custom_id', $args['custom_id'], $type);
326 326
 
327
-        if ( ! empty( $item ) ) {
327
+        if (!empty($item)) {
328 328
             $args['ID'] = $item->get_id();
329 329
         }
330 330
 
331 331
     }
332 332
 
333 333
     // Do we have an item?
334
-    if ( ! empty( $args['ID'] ) ) {
335
-        $item = new WPInv_Item( $args['ID'] );
334
+    if (!empty($args['ID'])) {
335
+        $item = new WPInv_Item($args['ID']);
336 336
     } else {
337 337
         $item = new WPInv_Item();
338 338
     }
339 339
 
340 340
     // Do we have an error?
341
-    if ( ! empty( $item->last_error ) ) {
342
-        return $wp_error ? new WP_Error( 'invalid_item', $item->last_error ) : false;
341
+    if (!empty($item->last_error)) {
342
+        return $wp_error ? new WP_Error('invalid_item', $item->last_error) : false;
343 343
     }
344 344
 
345 345
     // Update item props.
346
-    $item->set_props( $args );
346
+    $item->set_props($args);
347 347
 
348 348
     // Save the item.
349 349
     $item->save();
350 350
 
351 351
     // Do we have an error?
352
-    if ( ! empty( $item->last_error ) ) {
353
-        return $wp_error ? new WP_Error( 'not_saved', $item->last_error ) : false;
352
+    if (!empty($item->last_error)) {
353
+        return $wp_error ? new WP_Error('not_saved', $item->last_error) : false;
354 354
     }
355 355
 
356 356
     // Was the item saved?
357
-    if ( ! $item->get_id() ) {
358
-        return $wp_error ? new WP_Error( 'not_saved', __( 'An error occured while saving the item', 'invoicing' ) ) : false;
357
+    if (!$item->get_id()) {
358
+        return $wp_error ? new WP_Error('not_saved', __('An error occured while saving the item', 'invoicing')) : false;
359 359
     }
360 360
 
361 361
     return $item;
@@ -367,14 +367,14 @@  discard block
 block discarded – undo
367 367
  * 
368 368
  * @see wpinv_create_item()
369 369
  */
370
-function wpinv_update_item( $args = array(), $wp_error = false ) {
371
-    return wpinv_create_item( $args, $wp_error );
370
+function wpinv_update_item($args = array(), $wp_error = false) {
371
+    return wpinv_create_item($args, $wp_error);
372 372
 }
373 373
 
374 374
 /**
375 375
  * Sanitizes a recurring period
376 376
  */
377
-function getpaid_sanitize_recurring_period( $period, $full = false ) {
377
+function getpaid_sanitize_recurring_period($period, $full = false) {
378 378
 
379 379
     $periods = array(
380 380
         'D' => 'day',
@@ -383,11 +383,11 @@  discard block
 block discarded – undo
383 383
         'Y' => 'year',
384 384
     );
385 385
 
386
-    if ( ! isset( $periods[ $period ] ) ) {
386
+    if (!isset($periods[$period])) {
387 387
         $period = 'D';
388 388
     }
389 389
 
390
-    return $full ? $periods[ $period ] : $period;
390
+    return $full ? $periods[$period] : $period;
391 391
 
392 392
 }
393 393
 
@@ -396,34 +396,34 @@  discard block
 block discarded – undo
396 396
  * 
397 397
  * @param WPInv_Item|GetPaid_Form_Item $item
398 398
  */
399
-function getpaid_item_recurring_price_help_text( $item, $currency = '' ) {
399
+function getpaid_item_recurring_price_help_text($item, $currency = '') {
400 400
 
401 401
     // Abort if it is not recurring.
402
-    if ( ! $item->is_recurring() ) {
402
+    if (!$item->is_recurring()) {
403 403
         return '';
404 404
     }
405 405
 
406
-    $initial_price   = wpinv_price( $item->get_initial_price(), $currency );
407
-    $recurring_price = wpinv_price( $item->get_recurring_price(), $currency );
408
-    $period          = getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' );
406
+    $initial_price   = wpinv_price($item->get_initial_price(), $currency);
407
+    $recurring_price = wpinv_price($item->get_recurring_price(), $currency);
408
+    $period          = getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), '');
409 409
     $initial_class   = 'getpaid-item-initial-price';
410 410
     $recurring_class = 'getpaid-item-recurring-price';
411 411
 
412
-    if ( $item instanceof GetPaid_Form_Item ) {
413
-        $initial_price   = wpinv_price( $item->get_sub_total(), $currency );
414
-        $recurring_price = wpinv_price( $item->get_recurring_sub_total(), $currency );
412
+    if ($item instanceof GetPaid_Form_Item) {
413
+        $initial_price   = wpinv_price($item->get_sub_total(), $currency);
414
+        $recurring_price = wpinv_price($item->get_recurring_sub_total(), $currency);
415 415
     }
416 416
 
417 417
     // For free trial items.
418
-    if ( $item->has_free_trial() ) {
419
-        $trial_period = getpaid_get_subscription_period_label( $item->get_trial_period(), $item->get_trial_interval() );
418
+    if ($item->has_free_trial()) {
419
+        $trial_period = getpaid_get_subscription_period_label($item->get_trial_period(), $item->get_trial_interval());
420 420
 
421
-        if ( 0 == $item->get_initial_price() ) {
421
+        if (0 == $item->get_initial_price()) {
422 422
 
423 423
             return sprintf(
424 424
 
425 425
                 // translators: $1: is the trial period, $2: is the recurring price, $3: is the susbcription period
426
-                _x( 'Free for %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year)', 'invoicing' ),
426
+                _x('Free for %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year)', 'invoicing'),
427 427
                 $trial_period,
428 428
                 "<span class='$recurring_class'>$recurring_price</span>",
429 429
                 $period
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
         return sprintf(
436 436
 
437 437
             // translators: $1: is the initial price, $2: is the trial period, $3: is the recurring price, $4: is the susbcription period
438
-            _x( '%1$s for %2$s then %3$s / %4$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year)', 'invoicing' ),
438
+            _x('%1$s for %2$s then %3$s / %4$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year)', 'invoicing'),
439 439
             "<span class='$initial_class'>$initial_price</span>",
440 440
             $trial_period,
441 441
             "<span class='$recurring_class'>$recurring_price</span>",
@@ -445,12 +445,12 @@  discard block
 block discarded – undo
445 445
 
446 446
     }
447 447
 
448
-    if ( $initial_price == $recurring_price ) {
448
+    if ($initial_price == $recurring_price) {
449 449
 
450 450
         return sprintf(
451 451
 
452 452
             // translators: $1: is the recurring price, $2: is the susbcription period
453
-            _x( '%1$s / %2$s', 'Item subscription amount. (e.g.: $120 / year)', 'invoicing' ),
453
+            _x('%1$s / %2$s', 'Item subscription amount. (e.g.: $120 / year)', 'invoicing'),
454 454
             "<span class='$recurring_class'>$recurring_price</span>",
455 455
             $period
456 456
 
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
     return sprintf(
462 462
 
463 463
         // translators: $1: is the initial price, $2: is the recurring price, $3: is the susbcription period
464
-        _x( 'Initial payment of %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year)', 'invoicing' ),
464
+        _x('Initial payment of %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year)', 'invoicing'),
465 465
         "<span class='$initial_class'>$initial_price</span>",
466 466
         "<span class='$recurring_class'>$recurring_price</span>",
467 467
         $period
Please login to merge, or discard this patch.
includes/admin/register-settings.php 3 patches
Indentation   +339 added lines, -339 removed lines patch added patch discarded remove patch
@@ -196,11 +196,11 @@  discard block
 block discarded – undo
196 196
     $cb      = "wpinv_{$option['type']}_callback";
197 197
     $section = "wpinv_settings_{$tab}_$section";
198 198
 
199
-	if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) {
200
-		$tip   = esc_attr( $option['desc'] );
201
-		$name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
202
-		unset( $option['desc'] );
203
-	}
199
+    if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) {
200
+        $tip   = esc_attr( $option['desc'] );
201
+        $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
202
+        unset( $option['desc'] );
203
+    }
204 204
 
205 205
     // Loop through all tabs.
206 206
     add_settings_field(
@@ -279,10 +279,10 @@  discard block
 block discarded – undo
279 279
         }
280 280
 
281 281
         // General filter
282
-		$input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
282
+        $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
283 283
 
284
-		// Key specific filter.
285
-		$input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
284
+        // Key specific filter.
285
+        $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
286 286
     }
287 287
 
288 288
     // Loop through the whitelist and unset any that are empty for the tab being saved
@@ -338,15 +338,15 @@  discard block
 block discarded – undo
338 338
 
339 339
     foreach ( $new_rates as $rate ) {
340 340
 
341
-		if ( ! empty( $rate['country'] ) ) {
342
-			$rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
343
-			$rate['name']    = sanitize_text_field( $rate['name'] );
344
-			$rate['state']   = sanitize_text_field( $rate['state'] );
345
-			$rate['country'] = sanitize_text_field( $rate['country'] );
346
-			$tax_rates[]     = $rate;
347
-		}
341
+        if ( ! empty( $rate['country'] ) ) {
342
+            $rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
343
+            $rate['name']    = sanitize_text_field( $rate['name'] );
344
+            $rate['state']   = sanitize_text_field( $rate['state'] );
345
+            $rate['country'] = sanitize_text_field( $rate['country'] );
346
+            $tax_rates[]     = $rate;
347
+        }
348 348
 
349
-	}
349
+    }
350 350
 
351 351
     update_option( 'wpinv_tax_rates', $tax_rates );
352 352
 
@@ -426,51 +426,51 @@  discard block
 block discarded – undo
426 426
 }
427 427
 
428 428
 function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
429
-	$pages_options = array();
429
+    $pages_options = array();
430 430
 
431
-	if( $default_label !== NULL && $default_label !== false ) {
432
-		$pages_options = array( '' => $default_label ); // Blank option
433
-	}
431
+    if( $default_label !== NULL && $default_label !== false ) {
432
+        $pages_options = array( '' => $default_label ); // Blank option
433
+    }
434 434
 
435
-	$pages = get_pages();
436
-	if ( $pages ) {
437
-		foreach ( $pages as $page ) {
438
-			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
435
+    $pages = get_pages();
436
+    if ( $pages ) {
437
+        foreach ( $pages as $page ) {
438
+            $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
439 439
             $pages_options[ $page->ID ] = $title;
440
-		}
441
-	}
440
+        }
441
+    }
442 442
 
443
-	return $pages_options;
443
+    return $pages_options;
444 444
 }
445 445
 
446 446
 function wpinv_header_callback( $args ) {
447
-	if ( !empty( $args['desc'] ) ) {
447
+    if ( !empty( $args['desc'] ) ) {
448 448
         echo $args['desc'];
449 449
     }
450 450
 }
451 451
 
452 452
 function wpinv_hidden_callback( $args ) {
453
-	global $wpinv_options;
454
-
455
-	if ( isset( $args['set_value'] ) ) {
456
-		$value = $args['set_value'];
457
-	} elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
458
-		$value = $wpinv_options[ $args['id'] ];
459
-	} else {
460
-		$value = isset( $args['std'] ) ? $args['std'] : '';
461
-	}
462
-
463
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
464
-		$args['readonly'] = true;
465
-		$value = isset( $args['std'] ) ? $args['std'] : '';
466
-		$name  = '';
467
-	} else {
468
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
469
-	}
470
-
471
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
453
+    global $wpinv_options;
454
+
455
+    if ( isset( $args['set_value'] ) ) {
456
+        $value = $args['set_value'];
457
+    } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
458
+        $value = $wpinv_options[ $args['id'] ];
459
+    } else {
460
+        $value = isset( $args['std'] ) ? $args['std'] : '';
461
+    }
462
+
463
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
464
+        $args['readonly'] = true;
465
+        $value = isset( $args['std'] ) ? $args['std'] : '';
466
+        $name  = '';
467
+    } else {
468
+        $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
469
+    }
470
+
471
+    $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
472 472
     
473
-	echo $html;
473
+    echo $html;
474 474
 }
475 475
 
476 476
 /**
@@ -478,12 +478,12 @@  discard block
 block discarded – undo
478 478
  */
479 479
 function wpinv_checkbox_callback( $args ) {
480 480
 
481
-	$std = isset( $args['std'] ) ? $args['std'] : '';
482
-	$std = wpinv_get_option( $args['id'], $std );
483
-	$id  = esc_attr( $args['id'] );
481
+    $std = isset( $args['std'] ) ? $args['std'] : '';
482
+    $std = wpinv_get_option( $args['id'], $std );
483
+    $id  = esc_attr( $args['id'] );
484 484
 
485
-	getpaid_hidden_field( "wpinv_settings[$id]", '0' );
486
-	?>
485
+    getpaid_hidden_field( "wpinv_settings[$id]", '0' );
486
+    ?>
487 487
 		<fieldset>
488 488
 			<label>
489 489
 				<input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox">
@@ -495,77 +495,77 @@  discard block
 block discarded – undo
495 495
 
496 496
 function wpinv_multicheck_callback( $args ) {
497 497
 	
498
-	global $wpinv_options;
498
+    global $wpinv_options;
499 499
 
500
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
501
-	$class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
500
+    $sanitize_id = wpinv_sanitize_key( $args['id'] );
501
+    $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
502 502
 
503
-	if ( ! empty( $args['options'] ) ) {
503
+    if ( ! empty( $args['options'] ) ) {
504 504
 
505
-		$std     = isset( $args['std'] ) ? $args['std'] : array();
506
-		$value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
505
+        $std     = isset( $args['std'] ) ? $args['std'] : array();
506
+        $value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
507 507
 
508
-		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
508
+        echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
509 509
         foreach( $args['options'] as $key => $option ):
510
-			$sanitize_key = wpinv_sanitize_key( $key );
511
-			if ( in_array( $sanitize_key, $value ) ) { 
512
-				$enabled = $sanitize_key;
513
-			} else { 
514
-				$enabled = NULL; 
515
-			}
516
-			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
517
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
518
-		endforeach;
519
-		echo '</div>';
520
-		echo '<p class="description">' . $args['desc'] . '</p>';
521
-	}
510
+            $sanitize_key = wpinv_sanitize_key( $key );
511
+            if ( in_array( $sanitize_key, $value ) ) { 
512
+                $enabled = $sanitize_key;
513
+            } else { 
514
+                $enabled = NULL; 
515
+            }
516
+            echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
517
+            echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
518
+        endforeach;
519
+        echo '</div>';
520
+        echo '<p class="description">' . $args['desc'] . '</p>';
521
+    }
522 522
 }
523 523
 
524 524
 function wpinv_payment_icons_callback( $args ) {
525
-	global $wpinv_options;
525
+    global $wpinv_options;
526 526
     
527 527
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
528 528
 
529
-	if ( ! empty( $args['options'] ) ) {
530
-		foreach( $args['options'] as $key => $option ) {
529
+    if ( ! empty( $args['options'] ) ) {
530
+        foreach( $args['options'] as $key => $option ) {
531 531
             $sanitize_key = wpinv_sanitize_key( $key );
532 532
             
533
-			if( isset( $wpinv_options[$args['id']][$key] ) ) {
534
-				$enabled = $option;
535
-			} else {
536
-				$enabled = NULL;
537
-			}
538
-
539
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
540
-
541
-				echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
542
-
543
-				if ( wpinv_string_is_image_url( $key ) ) {
544
-					echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
545
-				} else {
546
-					$card = strtolower( str_replace( ' ', '', $option ) );
547
-
548
-					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
549
-						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
550
-					} else {
551
-						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
552
-						$content_dir = WP_CONTENT_DIR;
553
-
554
-						if ( function_exists( 'wp_normalize_path' ) ) {
555
-							// Replaces backslashes with forward slashes for Windows systems
556
-							$image = wp_normalize_path( $image );
557
-							$content_dir = wp_normalize_path( $content_dir );
558
-						}
559
-
560
-						$image = str_replace( $content_dir, content_url(), $image );
561
-					}
562
-
563
-					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
564
-				}
565
-			echo $option . '</label>';
566
-		}
567
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
568
-	}
533
+            if( isset( $wpinv_options[$args['id']][$key] ) ) {
534
+                $enabled = $option;
535
+            } else {
536
+                $enabled = NULL;
537
+            }
538
+
539
+            echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
540
+
541
+                echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
542
+
543
+                if ( wpinv_string_is_image_url( $key ) ) {
544
+                    echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
545
+                } else {
546
+                    $card = strtolower( str_replace( ' ', '', $option ) );
547
+
548
+                    if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
549
+                        $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
550
+                    } else {
551
+                        $image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
552
+                        $content_dir = WP_CONTENT_DIR;
553
+
554
+                        if ( function_exists( 'wp_normalize_path' ) ) {
555
+                            // Replaces backslashes with forward slashes for Windows systems
556
+                            $image = wp_normalize_path( $image );
557
+                            $content_dir = wp_normalize_path( $content_dir );
558
+                        }
559
+
560
+                        $image = str_replace( $content_dir, content_url(), $image );
561
+                    }
562
+
563
+                    echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
564
+                }
565
+            echo $option . '</label>';
566
+        }
567
+        echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
568
+    }
569 569
 }
570 570
 
571 571
 /**
@@ -573,9 +573,9 @@  discard block
 block discarded – undo
573 573
  */
574 574
 function wpinv_radio_callback( $args ) {
575 575
 
576
-	$std = isset( $args['std'] ) ? $args['std'] : '';
577
-	$std = wpinv_get_option( $args['id'], $std );
578
-	?>
576
+    $std = isset( $args['std'] ) ? $args['std'] : '';
577
+    $std = wpinv_get_option( $args['id'], $std );
578
+    ?>
579 579
 		<fieldset>
580 580
 			<ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;">
581 581
 				<?php foreach( $args['options'] as $key => $option ) : ?>
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
 			</ul>
590 590
 		</fieldset>
591 591
 	<?php
592
-	getpaid_settings_description_callback( $args );
592
+    getpaid_settings_description_callback( $args );
593 593
 }
594 594
 
595 595
 /**
@@ -597,176 +597,176 @@  discard block
 block discarded – undo
597 597
  */
598 598
 function getpaid_settings_description_callback( $args ) {
599 599
 
600
-	if ( ! empty( $args['desc'] ) ) {
601
-		$description = wp_kses_post( $args['desc'] );
602
-		echo "<p class='description'>$description</p>";
603
-	}
600
+    if ( ! empty( $args['desc'] ) ) {
601
+        $description = wp_kses_post( $args['desc'] );
602
+        echo "<p class='description'>$description</p>";
603
+    }
604 604
 
605 605
 }
606 606
 
607 607
 function wpinv_gateways_callback( $args ) {
608
-	global $wpinv_options;
608
+    global $wpinv_options;
609 609
     
610 610
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
611 611
 
612
-	foreach ( $args['options'] as $key => $option ) :
613
-		$sanitize_key = wpinv_sanitize_key( $key );
612
+    foreach ( $args['options'] as $key => $option ) :
613
+        $sanitize_key = wpinv_sanitize_key( $key );
614 614
         
615 615
         if ( isset( $wpinv_options['gateways'][ $key ] ) )
616
-			$enabled = '1';
617
-		else
618
-			$enabled = null;
616
+            $enabled = '1';
617
+        else
618
+            $enabled = null;
619 619
 
620
-		echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/>&nbsp;';
621
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
622
-	endforeach;
620
+        echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/>&nbsp;';
621
+        echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
622
+    endforeach;
623 623
 }
624 624
 
625 625
 function wpinv_gateway_select_callback($args) {
626
-	global $wpinv_options;
626
+    global $wpinv_options;
627 627
     
628 628
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
629 629
     $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
630 630
 
631
-	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
631
+    echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
632 632
 
633
-	foreach ( $args['options'] as $key => $option ) :
634
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
633
+    foreach ( $args['options'] as $key => $option ) :
634
+        if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
635 635
             $selected = selected( $key, $args['selected'], false );
636 636
         } else {
637 637
             $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : '';
638 638
         }
639
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
640
-	endforeach;
639
+        echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
640
+    endforeach;
641 641
 
642
-	echo '</select>';
643
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
642
+    echo '</select>';
643
+    echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
644 644
 }
645 645
 
646 646
 function wpinv_text_callback( $args ) {
647
-	global $wpinv_options;
647
+    global $wpinv_options;
648 648
     
649 649
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
650 650
 
651
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
652
-		$value = $wpinv_options[ $args['id'] ];
653
-	} else {
654
-		$value = isset( $args['std'] ) ? $args['std'] : '';
655
-	}
656
-
657
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
658
-		$args['readonly'] = true;
659
-		$value = isset( $args['std'] ) ? $args['std'] : '';
660
-		$name  = '';
661
-	} else {
662
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
663
-	}
664
-	$class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
665
-
666
-	$readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
667
-	$size     = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
668
-	$html     = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>';
669
-	$html    .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
670
-
671
-	echo $html;
651
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
652
+        $value = $wpinv_options[ $args['id'] ];
653
+    } else {
654
+        $value = isset( $args['std'] ) ? $args['std'] : '';
655
+    }
656
+
657
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
658
+        $args['readonly'] = true;
659
+        $value = isset( $args['std'] ) ? $args['std'] : '';
660
+        $name  = '';
661
+    } else {
662
+        $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
663
+    }
664
+    $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
665
+
666
+    $readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
667
+    $size     = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
668
+    $html     = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>';
669
+    $html    .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
670
+
671
+    echo $html;
672 672
 }
673 673
 
674 674
 function wpinv_number_callback( $args ) {
675
-	global $wpinv_options;
675
+    global $wpinv_options;
676 676
     
677 677
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
678 678
 
679
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
680
-		$value = $wpinv_options[ $args['id'] ];
681
-	} else {
682
-		$value = isset( $args['std'] ) ? $args['std'] : '';
683
-	}
684
-
685
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
686
-		$args['readonly'] = true;
687
-		$value = isset( $args['std'] ) ? $args['std'] : '';
688
-		$name  = '';
689
-	} else {
690
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
691
-	}
692
-
693
-	$max  = isset( $args['max'] ) ? $args['max'] : 999999;
694
-	$min  = isset( $args['min'] ) ? $args['min'] : 0;
695
-	$step = isset( $args['step'] ) ? $args['step'] : 1;
696
-	$class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
697
-
698
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
699
-	$html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>';
700
-	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
701
-
702
-	echo $html;
679
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
680
+        $value = $wpinv_options[ $args['id'] ];
681
+    } else {
682
+        $value = isset( $args['std'] ) ? $args['std'] : '';
683
+    }
684
+
685
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
686
+        $args['readonly'] = true;
687
+        $value = isset( $args['std'] ) ? $args['std'] : '';
688
+        $name  = '';
689
+    } else {
690
+        $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
691
+    }
692
+
693
+    $max  = isset( $args['max'] ) ? $args['max'] : 999999;
694
+    $min  = isset( $args['min'] ) ? $args['min'] : 0;
695
+    $step = isset( $args['step'] ) ? $args['step'] : 1;
696
+    $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
697
+
698
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
699
+    $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>';
700
+    $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
701
+
702
+    echo $html;
703 703
 }
704 704
 
705 705
 function wpinv_textarea_callback( $args ) {
706
-	global $wpinv_options;
706
+    global $wpinv_options;
707 707
     
708 708
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
709 709
 
710
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
711
-		$value = $wpinv_options[ $args['id'] ];
712
-	} else {
713
-		$value = isset( $args['std'] ) ? $args['std'] : '';
714
-	}
710
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
711
+        $value = $wpinv_options[ $args['id'] ];
712
+    } else {
713
+        $value = isset( $args['std'] ) ? $args['std'] : '';
714
+    }
715 715
     
716 716
     $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
717 717
     $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
718 718
 
719
-	$html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
720
-	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
719
+    $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
720
+    $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
721 721
 
722
-	echo $html;
722
+    echo $html;
723 723
 }
724 724
 
725 725
 function wpinv_password_callback( $args ) {
726
-	global $wpinv_options;
726
+    global $wpinv_options;
727 727
     
728 728
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
729 729
 
730
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
731
-		$value = $wpinv_options[ $args['id'] ];
732
-	} else {
733
-		$value = isset( $args['std'] ) ? $args['std'] : '';
734
-	}
730
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
731
+        $value = $wpinv_options[ $args['id'] ];
732
+    } else {
733
+        $value = isset( $args['std'] ) ? $args['std'] : '';
734
+    }
735 735
 
736
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
737
-	$html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
738
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
736
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
737
+    $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
738
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
739 739
 
740
-	echo $html;
740
+    echo $html;
741 741
 }
742 742
 
743 743
 function wpinv_missing_callback($args) {
744
-	printf(
745
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
746
-		'<strong>' . $args['id'] . '</strong>'
747
-	);
744
+    printf(
745
+        __( 'The callback function used for the %s setting is missing.', 'invoicing' ),
746
+        '<strong>' . $args['id'] . '</strong>'
747
+    );
748 748
 }
749 749
 
750 750
 function wpinv_select_callback($args) {
751
-	global $wpinv_options;
751
+    global $wpinv_options;
752 752
     
753 753
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
754 754
 
755
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
756
-		$value = $wpinv_options[ $args['id'] ];
757
-	} else {
758
-		$value = isset( $args['std'] ) ? $args['std'] : '';
759
-	}
755
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
756
+        $value = $wpinv_options[ $args['id'] ];
757
+    } else {
758
+        $value = isset( $args['std'] ) ? $args['std'] : '';
759
+    }
760 760
     
761 761
     if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
762 762
         $value = $args['selected'];
763 763
     }
764 764
 
765
-	if ( isset( $args['placeholder'] ) ) {
766
-		$placeholder = $args['placeholder'];
767
-	} else {
768
-		$placeholder = '';
769
-	}
765
+    if ( isset( $args['placeholder'] ) ) {
766
+        $placeholder = $args['placeholder'];
767
+    } else {
768
+        $placeholder = '';
769
+    }
770 770
     
771 771
     if( !empty( $args['onchange'] ) ) {
772 772
         $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
@@ -776,142 +776,142 @@  discard block
 block discarded – undo
776 776
 
777 777
     $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
778 778
 
779
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'"  name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />';
779
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'"  name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />';
780 780
 
781
-	foreach ( $args['options'] as $option => $name ) {
782
-		$selected = selected( $option, $value, false );
783
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
784
-	}
781
+    foreach ( $args['options'] as $option => $name ) {
782
+        $selected = selected( $option, $value, false );
783
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
784
+    }
785 785
 
786
-	$html .= '</select>';
787
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
786
+    $html .= '</select>';
787
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
788 788
 
789
-	echo $html;
789
+    echo $html;
790 790
 }
791 791
 
792 792
 function wpinv_color_select_callback( $args ) {
793
-	global $wpinv_options;
793
+    global $wpinv_options;
794 794
     
795 795
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
796 796
 
797
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
798
-		$value = $wpinv_options[ $args['id'] ];
799
-	} else {
800
-		$value = isset( $args['std'] ) ? $args['std'] : '';
801
-	}
797
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
798
+        $value = $wpinv_options[ $args['id'] ];
799
+    } else {
800
+        $value = isset( $args['std'] ) ? $args['std'] : '';
801
+    }
802 802
 
803
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
803
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
804 804
 
805
-	foreach ( $args['options'] as $option => $color ) {
806
-		$selected = selected( $option, $value, false );
807
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
808
-	}
805
+    foreach ( $args['options'] as $option => $color ) {
806
+        $selected = selected( $option, $value, false );
807
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
808
+    }
809 809
 
810
-	$html .= '</select>';
811
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
810
+    $html .= '</select>';
811
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
812 812
 
813
-	echo $html;
813
+    echo $html;
814 814
 }
815 815
 
816 816
 function wpinv_rich_editor_callback( $args ) {
817
-	global $wpinv_options, $wp_version;
817
+    global $wpinv_options, $wp_version;
818 818
     
819 819
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
820 820
 
821
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
822
-		$value = $wpinv_options[ $args['id'] ];
821
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
822
+        $value = $wpinv_options[ $args['id'] ];
823 823
 
824
-		if( empty( $args['allow_blank'] ) && empty( $value ) ) {
825
-			$value = isset( $args['std'] ) ? $args['std'] : '';
826
-		}
827
-	} else {
828
-		$value = isset( $args['std'] ) ? $args['std'] : '';
829
-	}
824
+        if( empty( $args['allow_blank'] ) && empty( $value ) ) {
825
+            $value = isset( $args['std'] ) ? $args['std'] : '';
826
+        }
827
+    } else {
828
+        $value = isset( $args['std'] ) ? $args['std'] : '';
829
+    }
830 830
 
831
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
831
+    $rows = isset( $args['size'] ) ? $args['size'] : 20;
832 832
 
833
-	$html = '<div class="getpaid-settings-editor-input">';
834
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
835
-		ob_start();
836
-		wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) );
837
-		$html .= ob_get_clean();
838
-	} else {
839
-		$html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
840
-	}
833
+    $html = '<div class="getpaid-settings-editor-input">';
834
+    if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
835
+        ob_start();
836
+        wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) );
837
+        $html .= ob_get_clean();
838
+    } else {
839
+        $html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
840
+    }
841 841
 
842
-	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
842
+    $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
843 843
 
844
-	echo $html;
844
+    echo $html;
845 845
 }
846 846
 
847 847
 function wpinv_upload_callback( $args ) {
848
-	global $wpinv_options;
848
+    global $wpinv_options;
849 849
     
850 850
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
851 851
 
852
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
853
-		$value = $wpinv_options[$args['id']];
854
-	} else {
855
-		$value = isset($args['std']) ? $args['std'] : '';
856
-	}
852
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
853
+        $value = $wpinv_options[$args['id']];
854
+    } else {
855
+        $value = isset($args['std']) ? $args['std'] : '';
856
+    }
857 857
 
858
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
859
-	$html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
860
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
861
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
858
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
859
+    $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
860
+    $html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
861
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
862 862
 
863
-	echo $html;
863
+    echo $html;
864 864
 }
865 865
 
866 866
 function wpinv_color_callback( $args ) {
867
-	global $wpinv_options;
867
+    global $wpinv_options;
868 868
     
869 869
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
870 870
 
871
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
872
-		$value = $wpinv_options[ $args['id'] ];
873
-	} else {
874
-		$value = isset( $args['std'] ) ? $args['std'] : '';
875
-	}
871
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
872
+        $value = $wpinv_options[ $args['id'] ];
873
+    } else {
874
+        $value = isset( $args['std'] ) ? $args['std'] : '';
875
+    }
876 876
 
877
-	$default = isset( $args['std'] ) ? $args['std'] : '';
877
+    $default = isset( $args['std'] ) ? $args['std'] : '';
878 878
 
879
-	$html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />';
880
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
879
+    $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />';
880
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
881 881
 
882
-	echo $html;
882
+    echo $html;
883 883
 }
884 884
 
885 885
 function wpinv_country_states_callback($args) {
886
-	global $wpinv_options;
886
+    global $wpinv_options;
887 887
     
888 888
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
889 889
 
890
-	if ( isset( $args['placeholder'] ) ) {
891
-		$placeholder = $args['placeholder'];
892
-	} else {
893
-		$placeholder = '';
894
-	}
890
+    if ( isset( $args['placeholder'] ) ) {
891
+        $placeholder = $args['placeholder'];
892
+    } else {
893
+        $placeholder = '';
894
+    }
895 895
 
896
-	$states = wpinv_get_country_states();
896
+    $states = wpinv_get_country_states();
897 897
 
898
-	$class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
899
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
898
+    $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
899
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
900 900
 
901
-	foreach ( $states as $option => $name ) {
902
-		$selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
903
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
904
-	}
901
+    foreach ( $states as $option => $name ) {
902
+        $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
903
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
904
+    }
905 905
 
906
-	$html .= '</select>';
907
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
906
+    $html .= '</select>';
907
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
908 908
 
909
-	echo $html;
909
+    echo $html;
910 910
 }
911 911
 
912 912
 function wpinv_tax_rates_callback($args) {
913
-	$rates = GetPaid_Tax::get_all_tax_rates();
914
-	ob_start(); ?>
913
+    $rates = GetPaid_Tax::get_all_tax_rates();
914
+    ob_start(); ?>
915 915
     </td><tr>
916 916
     <td colspan="2" class="wpinv_tax_tdbox">
917 917
 	<p><?php echo $args['desc']; ?></p>
@@ -935,40 +935,40 @@  discard block
 block discarded – undo
935 935
 			<tr>
936 936
 				<td class="wpinv_tax_country">
937 937
 					<?php
938
-					echo wpinv_html_select( array(
939
-						'options'          => wpinv_get_country_list( true ),
940
-						'name'             => 'tax_rates[' . $sanitized_key . '][country]',
938
+                    echo wpinv_html_select( array(
939
+                        'options'          => wpinv_get_country_list( true ),
940
+                        'name'             => 'tax_rates[' . $sanitized_key . '][country]',
941 941
                         'id'               => 'tax_rates[' . $sanitized_key . '][country]',
942
-						'selected'         => $rate['country'],
943
-						'show_option_all'  => false,
944
-						'show_option_none' => false,
945
-						'class'            => 'wpinv-tax-country wpi_select2',
946
-						'placeholder'      => __( 'Choose a country', 'invoicing' )
947
-					) );
948
-					?>
942
+                        'selected'         => $rate['country'],
943
+                        'show_option_all'  => false,
944
+                        'show_option_none' => false,
945
+                        'class'            => 'wpinv-tax-country wpi_select2',
946
+                        'placeholder'      => __( 'Choose a country', 'invoicing' )
947
+                    ) );
948
+                    ?>
949 949
 				</td>
950 950
 				<td class="wpinv_tax_state">
951 951
 					<?php
952
-					$states = wpinv_get_country_states( $rate['country'] );
953
-					if( !empty( $states ) ) {
954
-						echo wpinv_html_select( array(
955
-							'options'          => array_merge( array( '' => '' ), $states ),
956
-							'name'             => 'tax_rates[' . $sanitized_key . '][state]',
952
+                    $states = wpinv_get_country_states( $rate['country'] );
953
+                    if( !empty( $states ) ) {
954
+                        echo wpinv_html_select( array(
955
+                            'options'          => array_merge( array( '' => '' ), $states ),
956
+                            'name'             => 'tax_rates[' . $sanitized_key . '][state]',
957 957
                             'id'               => 'tax_rates[' . $sanitized_key . '][state]',
958
-							'selected'         => $rate['state'],
959
-							'show_option_all'  => false,
960
-							'show_option_none' => false,
958
+                            'selected'         => $rate['state'],
959
+                            'show_option_all'  => false,
960
+                            'show_option_none' => false,
961 961
                             'class'            => 'wpi_select2',
962
-							'placeholder'      => __( 'Choose a state', 'invoicing' )
963
-						) );
964
-					} else {
965
-						echo wpinv_html_text( array(
966
-							'name'  => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'],
967
-							'value' => ! empty( $rate['state'] ) ? $rate['state'] : '',
962
+                            'placeholder'      => __( 'Choose a state', 'invoicing' )
963
+                        ) );
964
+                    } else {
965
+                        echo wpinv_html_text( array(
966
+                            'name'  => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'],
967
+                            'value' => ! empty( $rate['state'] ) ? $rate['state'] : '',
968 968
                             'id'    => 'tax_rates[' . $sanitized_key . '][state]',
969
-						) );
970
-					}
971
-					?>
969
+                        ) );
970
+                    }
971
+                    ?>
972 972
 				</td>
973 973
 				<td class="wpinv_tax_global">
974 974
 					<input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked( true, ! empty( $rate['global'] ) ); ?>/>
@@ -983,19 +983,19 @@  discard block
 block discarded – undo
983 983
 			<tr>
984 984
 				<td class="wpinv_tax_country">
985 985
 					<?php
986
-					echo wpinv_html_select( array(
987
-						'options'          => wpinv_get_country_list( true ),
988
-						'name'             => 'tax_rates[0][country]',
989
-						'show_option_all'  => false,
990
-						'show_option_none' => false,
991
-						'class'            => 'wpinv-tax-country wpi_select2',
992
-						'placeholder'      => __( 'Choose a country', 'invoicing' )
993
-					) ); ?>
986
+                    echo wpinv_html_select( array(
987
+                        'options'          => wpinv_get_country_list( true ),
988
+                        'name'             => 'tax_rates[0][country]',
989
+                        'show_option_all'  => false,
990
+                        'show_option_none' => false,
991
+                        'class'            => 'wpinv-tax-country wpi_select2',
992
+                        'placeholder'      => __( 'Choose a country', 'invoicing' )
993
+                    ) ); ?>
994 994
 				</td>
995 995
 				<td class="wpinv_tax_state">
996 996
 					<?php echo wpinv_html_text( array(
997
-						'name' => 'tax_rates[0][state]'
998
-					) ); ?>
997
+                        'name' => 'tax_rates[0][state]'
998
+                    ) ); ?>
999 999
 				</td>
1000 1000
 				<td class="wpinv_tax_global">
1001 1001
 					<input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/>
@@ -1010,7 +1010,7 @@  discard block
 block discarded – undo
1010 1010
         <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e( 'Add Tax Rate', 'invoicing' ); ?></span></td></tr></tfoot>
1011 1011
 	</table>
1012 1012
 	<?php
1013
-	echo ob_get_clean();
1013
+    echo ob_get_clean();
1014 1014
 }
1015 1015
 
1016 1016
 function wpinv_tools_callback($args) {
@@ -1038,15 +1038,15 @@  discard block
 block discarded – undo
1038 1038
 }
1039 1039
 
1040 1040
 function wpinv_descriptive_text_callback( $args ) {
1041
-	echo wp_kses_post( $args['desc'] );
1041
+    echo wp_kses_post( $args['desc'] );
1042 1042
 }
1043 1043
 
1044 1044
 function wpinv_hook_callback( $args ) {
1045
-	do_action( 'wpinv_' . $args['id'], $args );
1045
+    do_action( 'wpinv_' . $args['id'], $args );
1046 1046
 }
1047 1047
 
1048 1048
 function wpinv_set_settings_cap() {
1049
-	return wpinv_get_capability();
1049
+    return wpinv_get_capability();
1050 1050
 }
1051 1051
 add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1052 1052
 
Please login to merge, or discard this patch.
Spacing   +401 added lines, -401 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @since   1.0.0
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Retrieves all default settings.
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
 function wpinv_get_settings() {
17 17
     $defaults = array();
18 18
 
19
-    foreach ( array_values( wpinv_get_registered_settings() ) as $tab_settings ) {
19
+    foreach (array_values(wpinv_get_registered_settings()) as $tab_settings) {
20 20
 
21
-        foreach ( array_values( $tab_settings ) as $section_settings ) {
21
+        foreach (array_values($tab_settings) as $section_settings) {
22 22
 
23
-            foreach ( $section_settings as $key => $setting ) {
24
-                if ( isset( $setting['std'] ) ) {
25
-                    $defaults[ $key ] = $setting['std'];
23
+            foreach ($section_settings as $key => $setting) {
24
+                if (isset($setting['std'])) {
25
+                    $defaults[$key] = $setting['std'];
26 26
                 }
27 27
             }
28 28
 
@@ -43,12 +43,12 @@  discard block
 block discarded – undo
43 43
     global $wpinv_options;
44 44
 
45 45
     // Try fetching the saved options.
46
-    if ( ! is_array( $wpinv_options ) ) {
47
-        $wpinv_options = get_option( 'wpinv_settings' );
46
+    if (!is_array($wpinv_options)) {
47
+        $wpinv_options = get_option('wpinv_settings');
48 48
     }
49 49
 
50 50
     // If that fails, don't fetch the default settings to prevent a loop.
51
-    if ( ! is_array( $wpinv_options ) ) {
51
+    if (!is_array($wpinv_options)) {
52 52
         $wpinv_options = array();
53 53
     }
54 54
 
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
  * @param mixed $default The default value to use if the setting has not been set.
63 63
  * @return mixed
64 64
  */
65
-function wpinv_get_option( $key = '', $default = false ) {
65
+function wpinv_get_option($key = '', $default = false) {
66 66
 
67 67
     $options = wpinv_get_options();
68
-    $value   = isset( $options[ $key ] ) ? $options[ $key ] : $default;
69
-    $value   = apply_filters( 'wpinv_get_option', $value, $key, $default );
68
+    $value   = isset($options[$key]) ? $options[$key] : $default;
69
+    $value   = apply_filters('wpinv_get_option', $value, $key, $default);
70 70
 
71
-    return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default );
71
+    return apply_filters('wpinv_get_option_' . $key, $value, $key, $default);
72 72
 }
73 73
 
74 74
 /**
@@ -77,11 +77,11 @@  discard block
 block discarded – undo
77 77
  * @param array $options the new options.
78 78
  * @return bool
79 79
  */
80
-function wpinv_update_options( $options ) {
80
+function wpinv_update_options($options) {
81 81
     global $wpinv_options;
82 82
 
83 83
     // update the option.
84
-    if ( is_array( $options ) && update_option( 'wpinv_settings', $options ) ) {
84
+    if (is_array($options) && update_option('wpinv_settings', $options)) {
85 85
         $wpinv_options = $options;
86 86
         return true;
87 87
     }
@@ -96,24 +96,24 @@  discard block
 block discarded – undo
96 96
  * @param mixed $value The setting value.
97 97
  * @return bool
98 98
  */
99
-function wpinv_update_option( $key = '', $value = false ) {
99
+function wpinv_update_option($key = '', $value = false) {
100 100
 
101 101
     // If no key, exit.
102
-    if ( empty( $key ) ) {
102
+    if (empty($key)) {
103 103
         return false;
104 104
     }
105 105
 
106 106
     // Maybe delete the option instead.
107
-    if ( is_null( $value ) ) {
108
-        return wpinv_delete_option( $key );
107
+    if (is_null($value)) {
108
+        return wpinv_delete_option($key);
109 109
     }
110 110
 
111 111
     // Prepare the new options.
112 112
     $options         = wpinv_get_options();
113
-    $options[ $key ] = apply_filters( 'wpinv_update_option', $value, $key );
113
+    $options[$key] = apply_filters('wpinv_update_option', $value, $key);
114 114
 
115 115
     // Save the new options.
116
-    return wpinv_update_options( $options );
116
+    return wpinv_update_options($options);
117 117
 
118 118
 }
119 119
 
@@ -123,18 +123,18 @@  discard block
 block discarded – undo
123 123
  * @param string $key the setting key.
124 124
  * @return bool
125 125
  */
126
-function wpinv_delete_option( $key = '' ) {
126
+function wpinv_delete_option($key = '') {
127 127
 
128 128
     // If no key, exit
129
-    if ( empty( $key ) ) {
129
+    if (empty($key)) {
130 130
         return false;
131 131
     }
132 132
 
133 133
     $options = wpinv_get_options();
134 134
 
135
-    if ( isset( $options[ $key ] ) ) {
136
-        unset( $options[ $key ] );
137
-        return wpinv_update_options( $options );
135
+    if (isset($options[$key])) {
136
+        unset($options[$key]);
137
+        return wpinv_update_options($options);
138 138
     }
139 139
 
140 140
     return true;
@@ -148,14 +148,14 @@  discard block
 block discarded – undo
148 148
 function wpinv_register_settings() {
149 149
 
150 150
     // Loop through all tabs.
151
-    foreach ( wpinv_get_registered_settings() as $tab => $sections ) {
151
+    foreach (wpinv_get_registered_settings() as $tab => $sections) {
152 152
 
153 153
         // In each tab, loop through sections.
154
-        foreach ( $sections as $section => $settings ) {
154
+        foreach ($sections as $section => $settings) {
155 155
 
156 156
             // Check for backwards compatibility
157
-            $section_tabs = wpinv_get_settings_tab_sections( $tab );
158
-            if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) {
157
+            $section_tabs = wpinv_get_settings_tab_sections($tab);
158
+            if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) {
159 159
                 $section = 'main';
160 160
                 $settings = $sections;
161 161
             }
@@ -168,9 +168,9 @@  discard block
 block discarded – undo
168 168
                 'wpinv_settings_' . $tab . '_' . $section
169 169
             );
170 170
 
171
-            foreach ( $settings as $option ) {
172
-                if ( ! empty( $option['id'] ) ) {
173
-                    wpinv_register_settings_option( $tab, $section, $option );
171
+            foreach ($settings as $option) {
172
+                if (!empty($option['id'])) {
173
+                    wpinv_register_settings_option($tab, $section, $option);
174 174
                 }
175 175
             }
176 176
 
@@ -178,9 +178,9 @@  discard block
 block discarded – undo
178 178
     }
179 179
 
180 180
     // Creates our settings in the options table.
181
-    register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' );
181
+    register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize');
182 182
 }
183
-add_action( 'admin_init', 'wpinv_register_settings' );
183
+add_action('admin_init', 'wpinv_register_settings');
184 184
 
185 185
 /**
186 186
  * Register a single settings option.
@@ -190,46 +190,46 @@  discard block
 block discarded – undo
190 190
  * @param string $option
191 191
  * 
192 192
  */
193
-function wpinv_register_settings_option( $tab, $section, $option ) {
193
+function wpinv_register_settings_option($tab, $section, $option) {
194 194
 
195
-    $name    = isset( $option['name'] ) ? $option['name'] : '';
195
+    $name    = isset($option['name']) ? $option['name'] : '';
196 196
     $cb      = "wpinv_{$option['type']}_callback";
197 197
     $section = "wpinv_settings_{$tab}_$section";
198 198
 
199
-	if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) {
200
-		$tip   = esc_attr( $option['desc'] );
199
+	if (isset($option['desc']) && !empty($option['help-tip'])) {
200
+		$tip   = esc_attr($option['desc']);
201 201
 		$name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
202
-		unset( $option['desc'] );
202
+		unset($option['desc']);
203 203
 	}
204 204
 
205 205
     // Loop through all tabs.
206 206
     add_settings_field(
207 207
         'wpinv_settings[' . $option['id'] . ']',
208 208
         $name,
209
-        function_exists( $cb ) ? $cb : 'wpinv_missing_callback',
209
+        function_exists($cb) ? $cb : 'wpinv_missing_callback',
210 210
         $section,
211 211
         $section,
212 212
         array(
213 213
             'section'     => $section,
214
-            'id'          => isset( $option['id'] )          ? $option['id']          : null,
215
-            'desc'        => isset( $option['desc'] )        ? $option['desc']        : '',
214
+            'id'          => isset($option['id']) ? $option['id'] : null,
215
+            'desc'        => isset($option['desc']) ? $option['desc'] : '',
216 216
             'name'        => $name,
217
-            'size'        => isset( $option['size'] )        ? $option['size']        : null,
218
-            'options'     => isset( $option['options'] )     ? $option['options']     : '',
219
-            'selected'    => isset( $option['selected'] )    ? $option['selected']    : null,
220
-            'std'         => isset( $option['std'] )         ? $option['std']         : '',
221
-            'min'         => isset( $option['min'] )         ? $option['min']         : null,
222
-            'max'         => isset( $option['max'] )         ? $option['max']         : null,
223
-            'step'        => isset( $option['step'] )        ? $option['step']        : null,
224
-            'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null,
225
-            'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true,
226
-            'readonly'    => isset( $option['readonly'] )    ? $option['readonly']    : false,
227
-            'faux'        => isset( $option['faux'] )        ? $option['faux']        : false,
228
-            'onchange'    => isset( $option['onchange'] )   ? $option['onchange']     : '',
229
-            'custom'      => isset( $option['custom'] )     ? $option['custom']       : '',
230
-            'class'       => isset( $option['class'] )     ? $option['class']         : '',
231
-            'cols'        => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
232
-            'rows'        => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
217
+            'size'        => isset($option['size']) ? $option['size'] : null,
218
+            'options'     => isset($option['options']) ? $option['options'] : '',
219
+            'selected'    => isset($option['selected']) ? $option['selected'] : null,
220
+            'std'         => isset($option['std']) ? $option['std'] : '',
221
+            'min'         => isset($option['min']) ? $option['min'] : null,
222
+            'max'         => isset($option['max']) ? $option['max'] : null,
223
+            'step'        => isset($option['step']) ? $option['step'] : null,
224
+            'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null,
225
+            'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true,
226
+            'readonly'    => isset($option['readonly']) ? $option['readonly'] : false,
227
+            'faux'        => isset($option['faux']) ? $option['faux'] : false,
228
+            'onchange'    => isset($option['onchange']) ? $option['onchange'] : '',
229
+            'custom'      => isset($option['custom']) ? $option['custom'] : '',
230
+            'class'       => isset($option['class']) ? $option['class'] : '',
231
+            'cols'        => isset($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
232
+            'rows'        => isset($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
233 233
         )
234 234
     );
235 235
 
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
  * @return array
242 242
  */
243 243
 function wpinv_get_registered_settings() {
244
-    return apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) );
244
+    return apply_filters('wpinv_registered_settings', wpinv_get_data('admin-settings'));
245 245
 }
246 246
 
247 247
 /**
@@ -249,136 +249,136 @@  discard block
 block discarded – undo
249 249
  * 
250 250
  * @return array
251 251
  */
252
-function wpinv_settings_sanitize( $input = array() ) {
252
+function wpinv_settings_sanitize($input = array()) {
253 253
 
254 254
     $wpinv_options = wpinv_get_options();
255 255
 
256
-    if ( empty( wp_get_raw_referer() ) ) {
256
+    if (empty(wp_get_raw_referer())) {
257 257
         return $input;
258 258
     }
259 259
 
260
-    wp_parse_str( wp_get_raw_referer(), $referrer );
260
+    wp_parse_str(wp_get_raw_referer(), $referrer);
261 261
 
262 262
     $settings = wpinv_get_registered_settings();
263
-    $tab      = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
264
-    $section  = isset( $referrer['section'] ) ? $referrer['section'] : 'main';
263
+    $tab      = isset($referrer['tab']) ? $referrer['tab'] : 'general';
264
+    $section  = isset($referrer['section']) ? $referrer['section'] : 'main';
265 265
 
266 266
     $input = $input ? $input : array();
267
-    $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input );
268
-    $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input );
267
+    $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input);
268
+    $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input);
269 269
 
270 270
     // Loop through each setting being saved and pass it through a sanitization filter
271
-    foreach ( $input as $key => $value ) {
271
+    foreach ($input as $key => $value) {
272 272
 
273 273
         // Get the setting type (checkbox, select, etc)
274
-        $type = isset( $settings[ $tab ][$section][ $key ]['type'] ) ? $settings[ $tab ][$section][ $key ]['type'] : false;
274
+        $type = isset($settings[$tab][$section][$key]['type']) ? $settings[$tab][$section][$key]['type'] : false;
275 275
 
276
-        if ( $type ) {
276
+        if ($type) {
277 277
             // Field type specific filter
278
-            $input[$key] = apply_filters( 'wpinv_settings_sanitize_' . $type, $value, $key );
278
+            $input[$key] = apply_filters('wpinv_settings_sanitize_' . $type, $value, $key);
279 279
         }
280 280
 
281 281
         // General filter
282
-		$input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
282
+		$input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key);
283 283
 
284 284
 		// Key specific filter.
285
-		$input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
285
+		$input[$key] = apply_filters("wpinv_settings_sanitize_$key", $input[$key]);
286 286
     }
287 287
 
288 288
     // Loop through the whitelist and unset any that are empty for the tab being saved
289
-    $main_settings    = $section == 'main' ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections
290
-    $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array();
289
+    $main_settings    = $section == 'main' ? $settings[$tab] : array(); // Check for extensions that aren't using new sections
290
+    $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array();
291 291
 
292
-    $found_settings = array_merge( $main_settings, $section_settings );
292
+    $found_settings = array_merge($main_settings, $section_settings);
293 293
 
294
-    if ( ! empty( $found_settings ) ) {
295
-        foreach ( $found_settings as $key => $value ) {
294
+    if (!empty($found_settings)) {
295
+        foreach ($found_settings as $key => $value) {
296 296
 
297 297
             // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work
298
-            if ( is_numeric( $key ) ) {
298
+            if (is_numeric($key)) {
299 299
                 $key = $value['id'];
300 300
             }
301 301
 
302
-            if ( ! isset( $input[ $key ] ) && isset( $wpinv_options[ $key ] ) ) {
303
-                unset( $wpinv_options[ $key ] );
302
+            if (!isset($input[$key]) && isset($wpinv_options[$key])) {
303
+                unset($wpinv_options[$key]);
304 304
             }
305 305
         }
306 306
     }
307 307
 
308 308
     // Merge our new settings with the existing
309
-    $output = array_merge( $wpinv_options, $input );
309
+    $output = array_merge($wpinv_options, $input);
310 310
 
311
-    add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' );
311
+    add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated');
312 312
 
313 313
     return $output;
314 314
 }
315 315
 
316
-function wpinv_settings_sanitize_misc_accounting( $input ) {
316
+function wpinv_settings_sanitize_misc_accounting($input) {
317 317
 
318
-    if ( ! wpinv_current_user_can_manage_invoicing() ) {
318
+    if (!wpinv_current_user_can_manage_invoicing()) {
319 319
         return $input;
320 320
     }
321 321
 
322
-    if( ! empty( $input['enable_sequential'] ) && !wpinv_get_option( 'enable_sequential' ) ) {
322
+    if (!empty($input['enable_sequential']) && !wpinv_get_option('enable_sequential')) {
323 323
         // Shows an admin notice about upgrading previous order numbers
324
-        getpaid_session()->set( 'upgrade_sequential', '1' );
324
+        getpaid_session()->set('upgrade_sequential', '1');
325 325
     }
326 326
 
327 327
     return $input;
328 328
 }
329
-add_filter( 'wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting' );
329
+add_filter('wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting');
330 330
 
331
-function wpinv_settings_sanitize_tax_rates( $input ) {
332
-    if( ! wpinv_current_user_can_manage_invoicing() ) {
331
+function wpinv_settings_sanitize_tax_rates($input) {
332
+    if (!wpinv_current_user_can_manage_invoicing()) {
333 333
         return $input;
334 334
     }
335 335
 
336
-    $new_rates = ! empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array();
336
+    $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array();
337 337
     $tax_rates = array();
338 338
 
339
-    foreach ( $new_rates as $rate ) {
339
+    foreach ($new_rates as $rate) {
340 340
 
341
-		if ( ! empty( $rate['country'] ) ) {
342
-			$rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
343
-			$rate['name']    = sanitize_text_field( $rate['name'] );
344
-			$rate['state']   = sanitize_text_field( $rate['state'] );
345
-			$rate['country'] = sanitize_text_field( $rate['country'] );
341
+		if (!empty($rate['country'])) {
342
+			$rate['rate']    = wpinv_sanitize_amount($rate['rate']);
343
+			$rate['name']    = sanitize_text_field($rate['name']);
344
+			$rate['state']   = sanitize_text_field($rate['state']);
345
+			$rate['country'] = sanitize_text_field($rate['country']);
346 346
 			$tax_rates[]     = $rate;
347 347
 		}
348 348
 
349 349
 	}
350 350
 
351
-    update_option( 'wpinv_tax_rates', $tax_rates );
351
+    update_option('wpinv_tax_rates', $tax_rates);
352 352
 
353 353
     return $input;
354 354
 }
355
-add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' );
355
+add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates');
356 356
 
357
-function wpinv_sanitize_text_field( $input ) {
358
-    return trim( $input );
357
+function wpinv_sanitize_text_field($input) {
358
+    return trim($input);
359 359
 }
360
-add_filter( 'wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field' );
360
+add_filter('wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field');
361 361
 
362 362
 function wpinv_get_settings_tabs() {
363 363
     $tabs             = array();
364
-    $tabs['general']  = __( 'General', 'invoicing' );
365
-    $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
366
-    $tabs['taxes']    = __( 'Taxes', 'invoicing' );
367
-    $tabs['emails']   = __( 'Emails', 'invoicing' );
368
-    $tabs['privacy']  = __( 'Privacy', 'invoicing' );
369
-    $tabs['misc']     = __( 'Misc', 'invoicing' );
370
-    $tabs['tools']    = __( 'Tools', 'invoicing' );
371
-
372
-    return apply_filters( 'wpinv_settings_tabs', $tabs );
364
+    $tabs['general']  = __('General', 'invoicing');
365
+    $tabs['gateways'] = __('Payment Gateways', 'invoicing');
366
+    $tabs['taxes']    = __('Taxes', 'invoicing');
367
+    $tabs['emails']   = __('Emails', 'invoicing');
368
+    $tabs['privacy']  = __('Privacy', 'invoicing');
369
+    $tabs['misc']     = __('Misc', 'invoicing');
370
+    $tabs['tools']    = __('Tools', 'invoicing');
371
+
372
+    return apply_filters('wpinv_settings_tabs', $tabs);
373 373
 }
374 374
 
375
-function wpinv_get_settings_tab_sections( $tab = false ) {
375
+function wpinv_get_settings_tab_sections($tab = false) {
376 376
     $tabs     = false;
377 377
     $sections = wpinv_get_registered_settings_sections();
378 378
 
379
-    if( $tab && ! empty( $sections[ $tab ] ) ) {
380
-        $tabs = $sections[ $tab ];
381
-    } else if ( $tab ) {
379
+    if ($tab && !empty($sections[$tab])) {
380
+        $tabs = $sections[$tab];
381
+    } else if ($tab) {
382 382
         $tabs = false;
383 383
     }
384 384
 
@@ -388,87 +388,87 @@  discard block
 block discarded – undo
388 388
 function wpinv_get_registered_settings_sections() {
389 389
     static $sections = false;
390 390
 
391
-    if ( false !== $sections ) {
391
+    if (false !== $sections) {
392 392
         return $sections;
393 393
     }
394 394
 
395 395
     $sections = array(
396
-        'general' => apply_filters( 'wpinv_settings_sections_general', array(
397
-            'main' => __( 'General Settings', 'invoicing' ),
398
-            'currency_section' => __( 'Currency Settings', 'invoicing' ),
399
-            'labels' => __( 'Label Texts', 'invoicing' ),
400
-        ) ),
401
-        'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array(
402
-            'main' => __( 'Gateway Settings', 'invoicing' ),
403
-        ) ),
404
-        'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array(
405
-            'main' => __( 'Tax Settings', 'invoicing' ),
406
-            'rates' => __( 'Tax Rates', 'invoicing' ),
407
-        ) ),
408
-        'emails' => apply_filters( 'wpinv_settings_sections_emails', array(
409
-            'main' => __( 'Email Settings', 'invoicing' ),
410
-        ) ),
411
-        'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array(
412
-            'main' => __( 'Privacy policy', 'invoicing' ),
413
-        ) ),
414
-        'misc' => apply_filters( 'wpinv_settings_sections_misc', array(
415
-            'main' => __( 'Miscellaneous', 'invoicing' ),
416
-            'custom-css' => __( 'Custom CSS', 'invoicing' ),
417
-        ) ),
418
-        'tools' => apply_filters( 'wpinv_settings_sections_tools', array(
419
-            'main' => __( 'Diagnostic Tools', 'invoicing' ),
420
-        ) ),
396
+        'general' => apply_filters('wpinv_settings_sections_general', array(
397
+            'main' => __('General Settings', 'invoicing'),
398
+            'currency_section' => __('Currency Settings', 'invoicing'),
399
+            'labels' => __('Label Texts', 'invoicing'),
400
+        )),
401
+        'gateways' => apply_filters('wpinv_settings_sections_gateways', array(
402
+            'main' => __('Gateway Settings', 'invoicing'),
403
+        )),
404
+        'taxes' => apply_filters('wpinv_settings_sections_taxes', array(
405
+            'main' => __('Tax Settings', 'invoicing'),
406
+            'rates' => __('Tax Rates', 'invoicing'),
407
+        )),
408
+        'emails' => apply_filters('wpinv_settings_sections_emails', array(
409
+            'main' => __('Email Settings', 'invoicing'),
410
+        )),
411
+        'privacy' => apply_filters('wpinv_settings_sections_privacy', array(
412
+            'main' => __('Privacy policy', 'invoicing'),
413
+        )),
414
+        'misc' => apply_filters('wpinv_settings_sections_misc', array(
415
+            'main' => __('Miscellaneous', 'invoicing'),
416
+            'custom-css' => __('Custom CSS', 'invoicing'),
417
+        )),
418
+        'tools' => apply_filters('wpinv_settings_sections_tools', array(
419
+            'main' => __('Diagnostic Tools', 'invoicing'),
420
+        )),
421 421
     );
422 422
 
423
-    $sections = apply_filters( 'wpinv_settings_sections', $sections );
423
+    $sections = apply_filters('wpinv_settings_sections', $sections);
424 424
 
425 425
     return $sections;
426 426
 }
427 427
 
428
-function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
428
+function wpinv_get_pages($with_slug = false, $default_label = NULL) {
429 429
 	$pages_options = array();
430 430
 
431
-	if( $default_label !== NULL && $default_label !== false ) {
432
-		$pages_options = array( '' => $default_label ); // Blank option
431
+	if ($default_label !== NULL && $default_label !== false) {
432
+		$pages_options = array('' => $default_label); // Blank option
433 433
 	}
434 434
 
435 435
 	$pages = get_pages();
436
-	if ( $pages ) {
437
-		foreach ( $pages as $page ) {
436
+	if ($pages) {
437
+		foreach ($pages as $page) {
438 438
 			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
439
-            $pages_options[ $page->ID ] = $title;
439
+            $pages_options[$page->ID] = $title;
440 440
 		}
441 441
 	}
442 442
 
443 443
 	return $pages_options;
444 444
 }
445 445
 
446
-function wpinv_header_callback( $args ) {
447
-	if ( !empty( $args['desc'] ) ) {
446
+function wpinv_header_callback($args) {
447
+	if (!empty($args['desc'])) {
448 448
         echo $args['desc'];
449 449
     }
450 450
 }
451 451
 
452
-function wpinv_hidden_callback( $args ) {
452
+function wpinv_hidden_callback($args) {
453 453
 	global $wpinv_options;
454 454
 
455
-	if ( isset( $args['set_value'] ) ) {
455
+	if (isset($args['set_value'])) {
456 456
 		$value = $args['set_value'];
457
-	} elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
458
-		$value = $wpinv_options[ $args['id'] ];
457
+	} elseif (isset($wpinv_options[$args['id']])) {
458
+		$value = $wpinv_options[$args['id']];
459 459
 	} else {
460
-		$value = isset( $args['std'] ) ? $args['std'] : '';
460
+		$value = isset($args['std']) ? $args['std'] : '';
461 461
 	}
462 462
 
463
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
463
+	if (isset($args['faux']) && true === $args['faux']) {
464 464
 		$args['readonly'] = true;
465
-		$value = isset( $args['std'] ) ? $args['std'] : '';
465
+		$value = isset($args['std']) ? $args['std'] : '';
466 466
 		$name  = '';
467 467
 	} else {
468
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
468
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
469 469
 	}
470 470
 
471
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
471
+	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />';
472 472
     
473 473
 	echo $html;
474 474
 }
@@ -476,61 +476,61 @@  discard block
 block discarded – undo
476 476
 /**
477 477
  * Displays a checkbox settings callback.
478 478
  */
479
-function wpinv_checkbox_callback( $args ) {
479
+function wpinv_checkbox_callback($args) {
480 480
 
481
-	$std = isset( $args['std'] ) ? $args['std'] : '';
482
-	$std = wpinv_get_option( $args['id'], $std );
483
-	$id  = esc_attr( $args['id'] );
481
+	$std = isset($args['std']) ? $args['std'] : '';
482
+	$std = wpinv_get_option($args['id'], $std);
483
+	$id  = esc_attr($args['id']);
484 484
 
485
-	getpaid_hidden_field( "wpinv_settings[$id]", '0' );
485
+	getpaid_hidden_field("wpinv_settings[$id]", '0');
486 486
 	?>
487 487
 		<fieldset>
488 488
 			<label>
489
-				<input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox">
490
-				<?php echo wp_kses_post( $args['desc'] ); ?>
489
+				<input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked(empty($std), false); ?> value="1" type="checkbox">
490
+				<?php echo wp_kses_post($args['desc']); ?>
491 491
 			</label>
492 492
 		</fieldset>
493 493
 	<?php
494 494
 }
495 495
 
496
-function wpinv_multicheck_callback( $args ) {
496
+function wpinv_multicheck_callback($args) {
497 497
 	
498 498
 	global $wpinv_options;
499 499
 
500
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
501
-	$class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
500
+	$sanitize_id = wpinv_sanitize_key($args['id']);
501
+	$class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
502 502
 
503
-	if ( ! empty( $args['options'] ) ) {
503
+	if (!empty($args['options'])) {
504 504
 
505
-		$std     = isset( $args['std'] ) ? $args['std'] : array();
506
-		$value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
505
+		$std     = isset($args['std']) ? $args['std'] : array();
506
+		$value   = isset($wpinv_options[$args['id']]) ? $wpinv_options[$args['id']] : $std;
507 507
 
508 508
 		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
509
-        foreach( $args['options'] as $key => $option ):
510
-			$sanitize_key = wpinv_sanitize_key( $key );
511
-			if ( in_array( $sanitize_key, $value ) ) { 
509
+        foreach ($args['options'] as $key => $option):
510
+			$sanitize_key = wpinv_sanitize_key($key);
511
+			if (in_array($sanitize_key, $value)) { 
512 512
 				$enabled = $sanitize_key;
513 513
 			} else { 
514 514
 				$enabled = NULL; 
515 515
 			}
516
-			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
517
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
516
+			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/>&nbsp;';
517
+			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label></div>';
518 518
 		endforeach;
519 519
 		echo '</div>';
520 520
 		echo '<p class="description">' . $args['desc'] . '</p>';
521 521
 	}
522 522
 }
523 523
 
524
-function wpinv_payment_icons_callback( $args ) {
524
+function wpinv_payment_icons_callback($args) {
525 525
 	global $wpinv_options;
526 526
     
527
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
527
+    $sanitize_id = wpinv_sanitize_key($args['id']);
528 528
 
529
-	if ( ! empty( $args['options'] ) ) {
530
-		foreach( $args['options'] as $key => $option ) {
531
-            $sanitize_key = wpinv_sanitize_key( $key );
529
+	if (!empty($args['options'])) {
530
+		foreach ($args['options'] as $key => $option) {
531
+            $sanitize_key = wpinv_sanitize_key($key);
532 532
             
533
-			if( isset( $wpinv_options[$args['id']][$key] ) ) {
533
+			if (isset($wpinv_options[$args['id']][$key])) {
534 534
 				$enabled = $option;
535 535
 			} else {
536 536
 				$enabled = NULL;
@@ -538,211 +538,211 @@  discard block
 block discarded – undo
538 538
 
539 539
 			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
540 540
 
541
-				echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
541
+				echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/>&nbsp;';
542 542
 
543
-				if ( wpinv_string_is_image_url( $key ) ) {
544
-					echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
543
+				if (wpinv_string_is_image_url($key)) {
544
+					echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
545 545
 				} else {
546
-					$card = strtolower( str_replace( ' ', '', $option ) );
546
+					$card = strtolower(str_replace(' ', '', $option));
547 547
 
548
-					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
549
-						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
548
+					if (has_filter('wpinv_accepted_payment_' . $card . '_image')) {
549
+						$image = apply_filters('wpinv_accepted_payment_' . $card . '_image', '');
550 550
 					} else {
551
-						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
551
+						$image       = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false);
552 552
 						$content_dir = WP_CONTENT_DIR;
553 553
 
554
-						if ( function_exists( 'wp_normalize_path' ) ) {
554
+						if (function_exists('wp_normalize_path')) {
555 555
 							// Replaces backslashes with forward slashes for Windows systems
556
-							$image = wp_normalize_path( $image );
557
-							$content_dir = wp_normalize_path( $content_dir );
556
+							$image = wp_normalize_path($image);
557
+							$content_dir = wp_normalize_path($content_dir);
558 558
 						}
559 559
 
560
-						$image = str_replace( $content_dir, content_url(), $image );
560
+						$image = str_replace($content_dir, content_url(), $image);
561 561
 					}
562 562
 
563
-					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
563
+					echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
564 564
 				}
565 565
 			echo $option . '</label>';
566 566
 		}
567
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
567
+		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>';
568 568
 	}
569 569
 }
570 570
 
571 571
 /**
572 572
  * Displays a radio settings field.
573 573
  */
574
-function wpinv_radio_callback( $args ) {
574
+function wpinv_radio_callback($args) {
575 575
 
576
-	$std = isset( $args['std'] ) ? $args['std'] : '';
577
-	$std = wpinv_get_option( $args['id'], $std );
576
+	$std = isset($args['std']) ? $args['std'] : '';
577
+	$std = wpinv_get_option($args['id'], $std);
578 578
 	?>
579 579
 		<fieldset>
580
-			<ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;">
581
-				<?php foreach( $args['options'] as $key => $option ) : ?>
580
+			<ul id="wpinv-settings-<?php echo esc_attr($args['id']); ?>" style="margin-top: 0;">
581
+				<?php foreach ($args['options'] as $key => $option) : ?>
582 582
 					<li>
583 583
 						<label>
584
-							<input name="wpinv_settings[<?php echo esc_attr( $args['id'] ); ?>]" <?php checked( $std, $key ); ?> value="<?php echo esc_attr( $key ); ?>" type="radio">
585
-							<?php echo wp_kses_post( $option ); ?>
584
+							<input name="wpinv_settings[<?php echo esc_attr($args['id']); ?>]" <?php checked($std, $key); ?> value="<?php echo esc_attr($key); ?>" type="radio">
585
+							<?php echo wp_kses_post($option); ?>
586 586
 						</label>
587 587
 					</li>
588 588
 				<?php endforeach; ?>
589 589
 			</ul>
590 590
 		</fieldset>
591 591
 	<?php
592
-	getpaid_settings_description_callback( $args );
592
+	getpaid_settings_description_callback($args);
593 593
 }
594 594
 
595 595
 /**
596 596
  * Displays a description if available.
597 597
  */
598
-function getpaid_settings_description_callback( $args ) {
598
+function getpaid_settings_description_callback($args) {
599 599
 
600
-	if ( ! empty( $args['desc'] ) ) {
601
-		$description = wp_kses_post( $args['desc'] );
600
+	if (!empty($args['desc'])) {
601
+		$description = wp_kses_post($args['desc']);
602 602
 		echo "<p class='description'>$description</p>";
603 603
 	}
604 604
 
605 605
 }
606 606
 
607
-function wpinv_gateways_callback( $args ) {
607
+function wpinv_gateways_callback($args) {
608 608
 	global $wpinv_options;
609 609
     
610
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
610
+    $sanitize_id = wpinv_sanitize_key($args['id']);
611 611
 
612
-	foreach ( $args['options'] as $key => $option ) :
613
-		$sanitize_key = wpinv_sanitize_key( $key );
612
+	foreach ($args['options'] as $key => $option) :
613
+		$sanitize_key = wpinv_sanitize_key($key);
614 614
         
615
-        if ( isset( $wpinv_options['gateways'][ $key ] ) )
615
+        if (isset($wpinv_options['gateways'][$key]))
616 616
 			$enabled = '1';
617 617
 		else
618 618
 			$enabled = null;
619 619
 
620
-		echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/>&nbsp;';
621
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
620
+		echo '<input name="wpinv_settings[' . esc_attr($args['id']) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/>&nbsp;';
621
+		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option['admin_label']) . '</label><br/>';
622 622
 	endforeach;
623 623
 }
624 624
 
625 625
 function wpinv_gateway_select_callback($args) {
626 626
 	global $wpinv_options;
627 627
     
628
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
629
-    $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
628
+    $sanitize_id = wpinv_sanitize_key($args['id']);
629
+    $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
630 630
 
631
-	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
631
+	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '" >';
632 632
 
633
-	foreach ( $args['options'] as $key => $option ) :
634
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
635
-            $selected = selected( $key, $args['selected'], false );
633
+	foreach ($args['options'] as $key => $option) :
634
+		if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
635
+            $selected = selected($key, $args['selected'], false);
636 636
         } else {
637
-            $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : '';
637
+            $selected = isset($wpinv_options[$args['id']]) ? selected($key, $wpinv_options[$args['id']], false) : '';
638 638
         }
639
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
639
+		echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>';
640 640
 	endforeach;
641 641
 
642 642
 	echo '</select>';
643
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
643
+	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
644 644
 }
645 645
 
646
-function wpinv_text_callback( $args ) {
646
+function wpinv_text_callback($args) {
647 647
 	global $wpinv_options;
648 648
     
649
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
649
+    $sanitize_id = wpinv_sanitize_key($args['id']);
650 650
 
651
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
652
-		$value = $wpinv_options[ $args['id'] ];
651
+	if (isset($wpinv_options[$args['id']])) {
652
+		$value = $wpinv_options[$args['id']];
653 653
 	} else {
654
-		$value = isset( $args['std'] ) ? $args['std'] : '';
654
+		$value = isset($args['std']) ? $args['std'] : '';
655 655
 	}
656 656
 
657
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
657
+	if (isset($args['faux']) && true === $args['faux']) {
658 658
 		$args['readonly'] = true;
659
-		$value = isset( $args['std'] ) ? $args['std'] : '';
659
+		$value = isset($args['std']) ? $args['std'] : '';
660 660
 		$name  = '';
661 661
 	} else {
662
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
662
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
663 663
 	}
664
-	$class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
664
+	$class = !empty($args['class']) ? sanitize_html_class($args['class']) : '';
665 665
 
666 666
 	$readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
667
-	$size     = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
668
-	$html     = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>';
669
-	$html    .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
667
+	$size     = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
668
+	$html     = '<input type="text" class="' . sanitize_html_class($size) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"' . $readonly . '/>';
669
+	$html    .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
670 670
 
671 671
 	echo $html;
672 672
 }
673 673
 
674
-function wpinv_number_callback( $args ) {
674
+function wpinv_number_callback($args) {
675 675
 	global $wpinv_options;
676 676
     
677
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
677
+    $sanitize_id = wpinv_sanitize_key($args['id']);
678 678
 
679
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
680
-		$value = $wpinv_options[ $args['id'] ];
679
+	if (isset($wpinv_options[$args['id']])) {
680
+		$value = $wpinv_options[$args['id']];
681 681
 	} else {
682
-		$value = isset( $args['std'] ) ? $args['std'] : '';
682
+		$value = isset($args['std']) ? $args['std'] : '';
683 683
 	}
684 684
 
685
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
685
+	if (isset($args['faux']) && true === $args['faux']) {
686 686
 		$args['readonly'] = true;
687
-		$value = isset( $args['std'] ) ? $args['std'] : '';
687
+		$value = isset($args['std']) ? $args['std'] : '';
688 688
 		$name  = '';
689 689
 	} else {
690
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
690
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
691 691
 	}
692 692
 
693
-	$max  = isset( $args['max'] ) ? $args['max'] : 999999;
694
-	$min  = isset( $args['min'] ) ? $args['min'] : 0;
695
-	$step = isset( $args['step'] ) ? $args['step'] : 1;
696
-	$class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
693
+	$max  = isset($args['max']) ? $args['max'] : 999999;
694
+	$min  = isset($args['min']) ? $args['min'] : 0;
695
+	$step = isset($args['step']) ? $args['step'] : 1;
696
+	$class = !empty($args['class']) ? sanitize_html_class($args['class']) : '';
697 697
 
698
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
699
-	$html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>';
700
-	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
698
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
699
+	$html = '<input type="number" step="' . esc_attr($step) . '" max="' . esc_attr($max) . '" min="' . esc_attr($min) . '" class="' . sanitize_html_class($size) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"/>';
700
+	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
701 701
 
702 702
 	echo $html;
703 703
 }
704 704
 
705
-function wpinv_textarea_callback( $args ) {
705
+function wpinv_textarea_callback($args) {
706 706
 	global $wpinv_options;
707 707
     
708
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
708
+    $sanitize_id = wpinv_sanitize_key($args['id']);
709 709
 
710
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
711
-		$value = $wpinv_options[ $args['id'] ];
710
+	if (isset($wpinv_options[$args['id']])) {
711
+		$value = $wpinv_options[$args['id']];
712 712
 	} else {
713
-		$value = isset( $args['std'] ) ? $args['std'] : '';
713
+		$value = isset($args['std']) ? $args['std'] : '';
714 714
 	}
715 715
     
716
-    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
717
-    $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
716
+    $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
717
+    $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text';
718 718
 
719
-	$html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
720
-	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
719
+	$html = '<textarea class="' . sanitize_html_class($class) . ' txtarea-' . sanitize_html_class($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>';
720
+	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
721 721
 
722 722
 	echo $html;
723 723
 }
724 724
 
725
-function wpinv_password_callback( $args ) {
725
+function wpinv_password_callback($args) {
726 726
 	global $wpinv_options;
727 727
     
728
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
728
+    $sanitize_id = wpinv_sanitize_key($args['id']);
729 729
 
730
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
731
-		$value = $wpinv_options[ $args['id'] ];
730
+	if (isset($wpinv_options[$args['id']])) {
731
+		$value = $wpinv_options[$args['id']];
732 732
 	} else {
733
-		$value = isset( $args['std'] ) ? $args['std'] : '';
733
+		$value = isset($args['std']) ? $args['std'] : '';
734 734
 	}
735 735
 
736
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
737
-	$html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
738
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
736
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
737
+	$html = '<input type="password" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>';
738
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
739 739
 
740 740
 	echo $html;
741 741
 }
742 742
 
743 743
 function wpinv_missing_callback($args) {
744 744
 	printf(
745
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
745
+		__('The callback function used for the %s setting is missing.', 'invoicing'),
746 746
 		'<strong>' . $args['id'] . '</strong>'
747 747
 	);
748 748
 }
@@ -750,134 +750,134 @@  discard block
 block discarded – undo
750 750
 function wpinv_select_callback($args) {
751 751
 	global $wpinv_options;
752 752
     
753
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
753
+    $sanitize_id = wpinv_sanitize_key($args['id']);
754 754
 
755
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
756
-		$value = $wpinv_options[ $args['id'] ];
755
+	if (isset($wpinv_options[$args['id']])) {
756
+		$value = $wpinv_options[$args['id']];
757 757
 	} else {
758
-		$value = isset( $args['std'] ) ? $args['std'] : '';
758
+		$value = isset($args['std']) ? $args['std'] : '';
759 759
 	}
760 760
     
761
-    if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
761
+    if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
762 762
         $value = $args['selected'];
763 763
     }
764 764
 
765
-	if ( isset( $args['placeholder'] ) ) {
765
+	if (isset($args['placeholder'])) {
766 766
 		$placeholder = $args['placeholder'];
767 767
 	} else {
768 768
 		$placeholder = '';
769 769
 	}
770 770
     
771
-    if( !empty( $args['onchange'] ) ) {
772
-        $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
771
+    if (!empty($args['onchange'])) {
772
+        $onchange = ' onchange="' . esc_attr($args['onchange']) . '"';
773 773
     } else {
774 774
         $onchange = '';
775 775
     }
776 776
 
777
-    $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
777
+    $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
778 778
 
779
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'"  name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />';
779
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '"  name="wpinv_settings[' . esc_attr($args['id']) . ']" data-placeholder="' . esc_html($placeholder) . '"' . $onchange . ' />';
780 780
 
781
-	foreach ( $args['options'] as $option => $name ) {
782
-		$selected = selected( $option, $value, false );
783
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
781
+	foreach ($args['options'] as $option => $name) {
782
+		$selected = selected($option, $value, false);
783
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>';
784 784
 	}
785 785
 
786 786
 	$html .= '</select>';
787
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
787
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
788 788
 
789 789
 	echo $html;
790 790
 }
791 791
 
792
-function wpinv_color_select_callback( $args ) {
792
+function wpinv_color_select_callback($args) {
793 793
 	global $wpinv_options;
794 794
     
795
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
795
+    $sanitize_id = wpinv_sanitize_key($args['id']);
796 796
 
797
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
798
-		$value = $wpinv_options[ $args['id'] ];
797
+	if (isset($wpinv_options[$args['id']])) {
798
+		$value = $wpinv_options[$args['id']];
799 799
 	} else {
800
-		$value = isset( $args['std'] ) ? $args['std'] : '';
800
+		$value = isset($args['std']) ? $args['std'] : '';
801 801
 	}
802 802
 
803
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
803
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>';
804 804
 
805
-	foreach ( $args['options'] as $option => $color ) {
806
-		$selected = selected( $option, $value, false );
807
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
805
+	foreach ($args['options'] as $option => $color) {
806
+		$selected = selected($option, $value, false);
807
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>';
808 808
 	}
809 809
 
810 810
 	$html .= '</select>';
811
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
811
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
812 812
 
813 813
 	echo $html;
814 814
 }
815 815
 
816
-function wpinv_rich_editor_callback( $args ) {
816
+function wpinv_rich_editor_callback($args) {
817 817
 	global $wpinv_options, $wp_version;
818 818
     
819
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
819
+    $sanitize_id = wpinv_sanitize_key($args['id']);
820 820
 
821
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
822
-		$value = $wpinv_options[ $args['id'] ];
821
+	if (isset($wpinv_options[$args['id']])) {
822
+		$value = $wpinv_options[$args['id']];
823 823
 
824
-		if( empty( $args['allow_blank'] ) && empty( $value ) ) {
825
-			$value = isset( $args['std'] ) ? $args['std'] : '';
824
+		if (empty($args['allow_blank']) && empty($value)) {
825
+			$value = isset($args['std']) ? $args['std'] : '';
826 826
 		}
827 827
 	} else {
828
-		$value = isset( $args['std'] ) ? $args['std'] : '';
828
+		$value = isset($args['std']) ? $args['std'] : '';
829 829
 	}
830 830
 
831
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
831
+	$rows = isset($args['size']) ? $args['size'] : 20;
832 832
 
833 833
 	$html = '<div class="getpaid-settings-editor-input">';
834
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
834
+	if ($wp_version >= 3.3 && function_exists('wp_editor')) {
835 835
 		ob_start();
836
-		wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) );
836
+		wp_editor(stripslashes($value), 'wpinv_settings_' . esc_attr($args['id']), array('textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', 'textarea_rows' => absint($rows), 'media_buttons' => false));
837 837
 		$html .= ob_get_clean();
838 838
 	} else {
839
-		$html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
839
+		$html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>';
840 840
 	}
841 841
 
842
-	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
842
+	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
843 843
 
844 844
 	echo $html;
845 845
 }
846 846
 
847
-function wpinv_upload_callback( $args ) {
847
+function wpinv_upload_callback($args) {
848 848
 	global $wpinv_options;
849 849
     
850
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
850
+    $sanitize_id = wpinv_sanitize_key($args['id']);
851 851
 
852
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
852
+	if (isset($wpinv_options[$args['id']])) {
853 853
 		$value = $wpinv_options[$args['id']];
854 854
 	} else {
855 855
 		$value = isset($args['std']) ? $args['std'] : '';
856 856
 	}
857 857
 
858
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
859
-	$html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
860
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
861
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
858
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
859
+	$html = '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>';
860
+	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>';
861
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
862 862
 
863 863
 	echo $html;
864 864
 }
865 865
 
866
-function wpinv_color_callback( $args ) {
866
+function wpinv_color_callback($args) {
867 867
 	global $wpinv_options;
868 868
     
869
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
869
+    $sanitize_id = wpinv_sanitize_key($args['id']);
870 870
 
871
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
872
-		$value = $wpinv_options[ $args['id'] ];
871
+	if (isset($wpinv_options[$args['id']])) {
872
+		$value = $wpinv_options[$args['id']];
873 873
 	} else {
874
-		$value = isset( $args['std'] ) ? $args['std'] : '';
874
+		$value = isset($args['std']) ? $args['std'] : '';
875 875
 	}
876 876
 
877
-	$default = isset( $args['std'] ) ? $args['std'] : '';
877
+	$default = isset($args['std']) ? $args['std'] : '';
878 878
 
879
-	$html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />';
880
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
879
+	$html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($default) . '" />';
880
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
881 881
 
882 882
 	echo $html;
883 883
 }
@@ -885,9 +885,9 @@  discard block
 block discarded – undo
885 885
 function wpinv_country_states_callback($args) {
886 886
 	global $wpinv_options;
887 887
     
888
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
888
+    $sanitize_id = wpinv_sanitize_key($args['id']);
889 889
 
890
-	if ( isset( $args['placeholder'] ) ) {
890
+	if (isset($args['placeholder'])) {
891 891
 		$placeholder = $args['placeholder'];
892 892
 	} else {
893 893
 		$placeholder = '';
@@ -895,16 +895,16 @@  discard block
 block discarded – undo
895 895
 
896 896
 	$states = wpinv_get_country_states();
897 897
 
898
-	$class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
899
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
898
+	$class = empty($states) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
899
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>';
900 900
 
901
-	foreach ( $states as $option => $name ) {
902
-		$selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
903
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
901
+	foreach ($states as $option => $name) {
902
+		$selected = isset($wpinv_options[$args['id']]) ? selected($option, $wpinv_options[$args['id']], false) : '';
903
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>';
904 904
 	}
905 905
 
906 906
 	$html .= '</select>';
907
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
907
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
908 908
 
909 909
 	echo $html;
910 910
 }
@@ -918,96 +918,96 @@  discard block
 block discarded – undo
918 918
 	<table id="wpinv_tax_rates" class="wp-list-table widefat fixed posts">
919 919
 		<thead>
920 920
 			<tr>
921
-				<th scope="col" class="wpinv_tax_country"><?php _e( 'Country', 'invoicing' ); ?></th>
922
-				<th scope="col" class="wpinv_tax_state"><?php _e( 'State / Province', 'invoicing' ); ?></th>
923
-                <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e( 'Apply rate to whole country, regardless of state / province', 'invoicing' ); ?>"><?php _e( 'Country Wide', 'invoicing' ); ?></th>
924
-                <th scope="col" class="wpinv_tax_rate"><?php _e( 'Rate %', 'invoicing' ); ?></th> 
925
-                <th scope="col" class="wpinv_tax_name"><?php _e( 'Tax Name', 'invoicing' ); ?></th>
926
-				<th scope="col" class="wpinv_tax_action"><?php _e( 'Remove', 'invoicing' ); ?></th>
921
+				<th scope="col" class="wpinv_tax_country"><?php _e('Country', 'invoicing'); ?></th>
922
+				<th scope="col" class="wpinv_tax_state"><?php _e('State / Province', 'invoicing'); ?></th>
923
+                <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e('Apply rate to whole country, regardless of state / province', 'invoicing'); ?>"><?php _e('Country Wide', 'invoicing'); ?></th>
924
+                <th scope="col" class="wpinv_tax_rate"><?php _e('Rate %', 'invoicing'); ?></th> 
925
+                <th scope="col" class="wpinv_tax_name"><?php _e('Tax Name', 'invoicing'); ?></th>
926
+				<th scope="col" class="wpinv_tax_action"><?php _e('Remove', 'invoicing'); ?></th>
927 927
 			</tr>
928 928
 		</thead>
929 929
         <tbody>
930
-		<?php if( !empty( $rates ) ) : ?>
931
-			<?php foreach( $rates as $key => $rate ) : ?>
930
+		<?php if (!empty($rates)) : ?>
931
+			<?php foreach ($rates as $key => $rate) : ?>
932 932
             <?php 
933
-            $sanitized_key = wpinv_sanitize_key( $key );
933
+            $sanitized_key = wpinv_sanitize_key($key);
934 934
             ?>
935 935
 			<tr>
936 936
 				<td class="wpinv_tax_country">
937 937
 					<?php
938
-					echo wpinv_html_select( array(
939
-						'options'          => wpinv_get_country_list( true ),
938
+					echo wpinv_html_select(array(
939
+						'options'          => wpinv_get_country_list(true),
940 940
 						'name'             => 'tax_rates[' . $sanitized_key . '][country]',
941 941
                         'id'               => 'tax_rates[' . $sanitized_key . '][country]',
942 942
 						'selected'         => $rate['country'],
943 943
 						'show_option_all'  => false,
944 944
 						'show_option_none' => false,
945 945
 						'class'            => 'wpinv-tax-country wpi_select2',
946
-						'placeholder'      => __( 'Choose a country', 'invoicing' )
947
-					) );
946
+						'placeholder'      => __('Choose a country', 'invoicing')
947
+					));
948 948
 					?>
949 949
 				</td>
950 950
 				<td class="wpinv_tax_state">
951 951
 					<?php
952
-					$states = wpinv_get_country_states( $rate['country'] );
953
-					if( !empty( $states ) ) {
954
-						echo wpinv_html_select( array(
955
-							'options'          => array_merge( array( '' => '' ), $states ),
952
+					$states = wpinv_get_country_states($rate['country']);
953
+					if (!empty($states)) {
954
+						echo wpinv_html_select(array(
955
+							'options'          => array_merge(array('' => ''), $states),
956 956
 							'name'             => 'tax_rates[' . $sanitized_key . '][state]',
957 957
                             'id'               => 'tax_rates[' . $sanitized_key . '][state]',
958 958
 							'selected'         => $rate['state'],
959 959
 							'show_option_all'  => false,
960 960
 							'show_option_none' => false,
961 961
                             'class'            => 'wpi_select2',
962
-							'placeholder'      => __( 'Choose a state', 'invoicing' )
963
-						) );
962
+							'placeholder'      => __('Choose a state', 'invoicing')
963
+						));
964 964
 					} else {
965
-						echo wpinv_html_text( array(
965
+						echo wpinv_html_text(array(
966 966
 							'name'  => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'],
967
-							'value' => ! empty( $rate['state'] ) ? $rate['state'] : '',
967
+							'value' => !empty($rate['state']) ? $rate['state'] : '',
968 968
                             'id'    => 'tax_rates[' . $sanitized_key . '][state]',
969
-						) );
969
+						));
970 970
 					}
971 971
 					?>
972 972
 				</td>
973 973
 				<td class="wpinv_tax_global">
974
-					<input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked( true, ! empty( $rate['global'] ) ); ?>/>
975
-					<label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label>
974
+					<input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked(true, !empty($rate['global'])); ?>/>
975
+					<label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label>
976 976
 				</td>
977
-				<td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html( $rate['rate'] ); ?>"/></td>
978
-                <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html( $rate['name'] ); ?>"/></td>
979
-				<td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td>
977
+				<td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html($rate['rate']); ?>"/></td>
978
+                <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html($rate['name']); ?>"/></td>
979
+				<td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td>
980 980
 			</tr>
981 981
 			<?php endforeach; ?>
982 982
 		<?php else : ?>
983 983
 			<tr>
984 984
 				<td class="wpinv_tax_country">
985 985
 					<?php
986
-					echo wpinv_html_select( array(
987
-						'options'          => wpinv_get_country_list( true ),
986
+					echo wpinv_html_select(array(
987
+						'options'          => wpinv_get_country_list(true),
988 988
 						'name'             => 'tax_rates[0][country]',
989 989
 						'show_option_all'  => false,
990 990
 						'show_option_none' => false,
991 991
 						'class'            => 'wpinv-tax-country wpi_select2',
992
-						'placeholder'      => __( 'Choose a country', 'invoicing' )
993
-					) ); ?>
992
+						'placeholder'      => __('Choose a country', 'invoicing')
993
+					)); ?>
994 994
 				</td>
995 995
 				<td class="wpinv_tax_state">
996
-					<?php echo wpinv_html_text( array(
996
+					<?php echo wpinv_html_text(array(
997 997
 						'name' => 'tax_rates[0][state]'
998
-					) ); ?>
998
+					)); ?>
999 999
 				</td>
1000 1000
 				<td class="wpinv_tax_global">
1001 1001
 					<input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/>
1002
-					<label for="tax_rates[0][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label>
1002
+					<label for="tax_rates[0][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label>
1003 1003
 				</td>
1004
-				<td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[0][rate]" placeholder="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>" value="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>"/></td>
1004
+				<td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[0][rate]" placeholder="<?php echo (float) wpinv_get_option('tax_rate', 0); ?>" value="<?php echo (float) wpinv_get_option('tax_rate', 0); ?>"/></td>
1005 1005
                 <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[0][name]" /></td>
1006
-				<td><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td>
1006
+				<td><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td>
1007 1007
 			</tr>
1008 1008
 		<?php endif; ?>
1009 1009
         </tbody>
1010
-        <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e( 'Add Tax Rate', 'invoicing' ); ?></span></td></tr></tfoot>
1010
+        <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e('Add Tax Rate', 'invoicing'); ?></span></td></tr></tfoot>
1011 1011
 	</table>
1012 1012
 	<?php
1013 1013
 	echo ob_get_clean();
@@ -1018,76 +1018,76 @@  discard block
 block discarded – undo
1018 1018
     ob_start(); ?>
1019 1019
     </td><tr>
1020 1020
     <td colspan="2" class="wpinv_tools_tdbox">
1021
-    <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
1022
-    <?php do_action( 'wpinv_tools_before' ); ?>
1021
+    <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
1022
+    <?php do_action('wpinv_tools_before'); ?>
1023 1023
     <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts">
1024 1024
         <thead>
1025 1025
             <tr>
1026
-                <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th>
1027
-                <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th>
1028
-                <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th>
1026
+                <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th>
1027
+                <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th>
1028
+                <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th>
1029 1029
             </tr>
1030 1030
         </thead>
1031
-            <?php do_action( 'wpinv_tools_row' ); ?>
1031
+            <?php do_action('wpinv_tools_row'); ?>
1032 1032
         <tbody>
1033 1033
         </tbody>
1034 1034
     </table>
1035
-    <?php do_action( 'wpinv_tools_after' ); ?>
1035
+    <?php do_action('wpinv_tools_after'); ?>
1036 1036
     <?php
1037 1037
     echo ob_get_clean();
1038 1038
 }
1039 1039
 
1040
-function wpinv_descriptive_text_callback( $args ) {
1041
-	echo wp_kses_post( $args['desc'] );
1040
+function wpinv_descriptive_text_callback($args) {
1041
+	echo wp_kses_post($args['desc']);
1042 1042
 }
1043 1043
 
1044
-function wpinv_hook_callback( $args ) {
1045
-	do_action( 'wpinv_' . $args['id'], $args );
1044
+function wpinv_hook_callback($args) {
1045
+	do_action('wpinv_' . $args['id'], $args);
1046 1046
 }
1047 1047
 
1048 1048
 function wpinv_set_settings_cap() {
1049 1049
 	return wpinv_get_capability();
1050 1050
 }
1051
-add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1051
+add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap');
1052 1052
 
1053
-function wpinv_settings_sanitize_input( $value, $key ) {
1054
-    if ( $key == 'tax_rate' || $key == 'eu_fallback_rate' ) {
1055
-        $value = wpinv_sanitize_amount( $value, 4 );
1053
+function wpinv_settings_sanitize_input($value, $key) {
1054
+    if ($key == 'tax_rate' || $key == 'eu_fallback_rate') {
1055
+        $value = wpinv_sanitize_amount($value, 4);
1056 1056
         $value = $value >= 100 ? 99 : $value;
1057 1057
     }
1058 1058
         
1059 1059
     return $value;
1060 1060
 }
1061
-add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 );
1061
+add_filter('wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2);
1062 1062
 
1063
-function wpinv_on_update_settings( $old_value, $value, $option ) {
1064
-    $old = !empty( $old_value['remove_data_on_unistall'] ) ? 1 : '';
1065
-    $new = !empty( $value['remove_data_on_unistall'] ) ? 1 : '';
1063
+function wpinv_on_update_settings($old_value, $value, $option) {
1064
+    $old = !empty($old_value['remove_data_on_unistall']) ? 1 : '';
1065
+    $new = !empty($value['remove_data_on_unistall']) ? 1 : '';
1066 1066
     
1067
-    if ( $old != $new ) {
1068
-        update_option( 'wpinv_remove_data_on_invoice_unistall', $new );
1067
+    if ($old != $new) {
1068
+        update_option('wpinv_remove_data_on_invoice_unistall', $new);
1069 1069
     }
1070 1070
 }
1071
-add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 );
1072
-add_action( 'wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1073
-add_action( 'wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1074
-add_action( 'wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1075
-add_action( 'wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1076
-add_action( 'wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1077
-add_action( 'wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1078
-add_action( 'wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1079
-add_action( 'wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1080
-add_action( 'wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1081
-add_action( 'wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1082
-
1083
-function wpinv_settings_tab_bottom_emails( $active_tab, $section ) {
1071
+add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3);
1072
+add_action('wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1073
+add_action('wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1074
+add_action('wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1075
+add_action('wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1076
+add_action('wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1077
+add_action('wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1078
+add_action('wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1079
+add_action('wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1080
+add_action('wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2);
1081
+add_action('wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2);
1082
+
1083
+function wpinv_settings_tab_bottom_emails($active_tab, $section) {
1084 1084
     ?>
1085 1085
     <div class="wpinv-email-wc-row ">
1086 1086
         <div class="wpinv-email-wc-td">
1087
-            <h3 class="wpinv-email-wc-title"><?php echo apply_filters( 'wpinv_settings_email_wildcards_title', __( 'Wildcards For Emails', 'invoicing' ) ); ?></h3>
1087
+            <h3 class="wpinv-email-wc-title"><?php echo apply_filters('wpinv_settings_email_wildcards_title', __('Wildcards For Emails', 'invoicing')); ?></h3>
1088 1088
             <p class="wpinv-email-wc-description">
1089 1089
                 <?php
1090
-                $description = __( 'The following wildcards can be used in email subjects, heading and content:<br>
1090
+                $description = __('The following wildcards can be used in email subjects, heading and content:<br>
1091 1091
                     <strong>{site_title} :</strong> Site Title<br>
1092 1092
                     <strong>{name} :</strong> Customer\'s full name<br>
1093 1093
                     <strong>{first_name} :</strong> Customer\'s first name<br>
@@ -1101,7 +1101,7 @@  discard block
 block discarded – undo
1101 1101
                     <strong>{invoice_due_date} :</strong> The date the invoice is due<br>
1102 1102
                     <strong>{date} :</strong> Today\'s date.<br>
1103 1103
                     <strong>{is_was} :</strong> If due date of invoice is past, displays "was" otherwise displays "is"<br>
1104
-                    <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing' );
1104
+                    <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing');
1105 1105
                 echo apply_filters('wpinv_settings_email_wildcards_description', $description, $active_tab, $section);
1106 1106
                 ?>
1107 1107
             </p>
Please login to merge, or discard this patch.
Braces   +10 added lines, -6 removed lines patch added patch discarded remove patch
@@ -612,10 +612,11 @@  discard block
 block discarded – undo
612 612
 	foreach ( $args['options'] as $key => $option ) :
613 613
 		$sanitize_key = wpinv_sanitize_key( $key );
614 614
         
615
-        if ( isset( $wpinv_options['gateways'][ $key ] ) )
616
-			$enabled = '1';
617
-		else
618
-			$enabled = null;
615
+        if ( isset( $wpinv_options['gateways'][ $key ] ) ) {
616
+        			$enabled = '1';
617
+        } else {
618
+					$enabled = null;
619
+		}
619 620
 
620 621
 		echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/>&nbsp;';
621 622
 		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
@@ -979,7 +980,8 @@  discard block
 block discarded – undo
979 980
 				<td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td>
980 981
 			</tr>
981 982
 			<?php endforeach; ?>
982
-		<?php else : ?>
983
+		<?php else {
984
+    : ?>
983 985
 			<tr>
984 986
 				<td class="wpinv_tax_country">
985 987
 					<?php
@@ -990,7 +992,9 @@  discard block
 block discarded – undo
990 992
 						'show_option_none' => false,
991 993
 						'class'            => 'wpinv-tax-country wpi_select2',
992 994
 						'placeholder'      => __( 'Choose a country', 'invoicing' )
993
-					) ); ?>
995
+					) );
996
+}
997
+?>
994 998
 				</td>
995 999
 				<td class="wpinv_tax_state">
996 1000
 					<?php echo wpinv_html_text( array(
Please login to merge, or discard this patch.
includes/wpinv-helper-functions.php 2 patches
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -97,13 +97,13 @@  discard block
 block discarded – undo
97 97
  */
98 98
 function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) {
99 99
 
100
-	$invoice_statuses = array(
101
-		'wpi-pending'    => _x( 'Pending payment', 'Invoice status', 'invoicing' ),
100
+    $invoice_statuses = array(
101
+        'wpi-pending'    => _x( 'Pending payment', 'Invoice status', 'invoicing' ),
102 102
         'publish'        => _x( 'Paid', 'Invoice status', 'invoicing' ),
103 103
         'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ),
104
-		'wpi-onhold'     => _x( 'On hold', 'Invoice status', 'invoicing' ),
105
-		'wpi-cancelled'  => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
106
-		'wpi-refunded'   => _x( 'Refunded', 'Invoice status', 'invoicing' ),
104
+        'wpi-onhold'     => _x( 'On hold', 'Invoice status', 'invoicing' ),
105
+        'wpi-cancelled'  => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
106
+        'wpi-refunded'   => _x( 'Refunded', 'Invoice status', 'invoicing' ),
107 107
         'wpi-failed'     => _x( 'Failed', 'Invoice status', 'invoicing' ),
108 108
         'wpi-renewal'    => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ),
109 109
     );
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
         $invoice = $invoice->get_post_type();
121 121
     }
122 122
 
123
-	return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice );
123
+    return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice );
124 124
 }
125 125
 
126 126
 /**
@@ -238,25 +238,25 @@  discard block
 block discarded – undo
238 238
  * @return string
239 239
  */
240 240
 function getpaid_get_price_format() {
241
-	$currency_pos = wpinv_currency_position();
242
-	$format       = '%1$s%2$s';
243
-
244
-	switch ( $currency_pos ) {
245
-		case 'left':
246
-			$format = '%1$s%2$s';
247
-			break;
248
-		case 'right':
249
-			$format = '%2$s%1$s';
250
-			break;
251
-		case 'left_space':
252
-			$format = '%1$s&nbsp;%2$s';
253
-			break;
254
-		case 'right_space':
255
-			$format = '%2$s&nbsp;%1$s';
256
-			break;
257
-	}
258
-
259
-	return apply_filters( 'getpaid_price_format', $format, $currency_pos );
241
+    $currency_pos = wpinv_currency_position();
242
+    $format       = '%1$s%2$s';
243
+
244
+    switch ( $currency_pos ) {
245
+        case 'left':
246
+            $format = '%1$s%2$s';
247
+            break;
248
+        case 'right':
249
+            $format = '%2$s%1$s';
250
+            break;
251
+        case 'left_space':
252
+            $format = '%1$s&nbsp;%2$s';
253
+            break;
254
+        case 'right_space':
255
+            $format = '%2$s&nbsp;%1$s';
256
+            break;
257
+    }
258
+
259
+    return apply_filters( 'getpaid_price_format', $format, $currency_pos );
260 260
 }
261 261
 
262 262
 /**
@@ -359,13 +359,13 @@  discard block
 block discarded – undo
359 359
  * @param mixed  $value Value.
360 360
  */
361 361
 function getpaid_maybe_define_constant( $name, $value ) {
362
-	if ( ! defined( $name ) ) {
363
-		define( $name, $value );
364
-	}
362
+    if ( ! defined( $name ) ) {
363
+        define( $name, $value );
364
+    }
365 365
 }
366 366
 
367 367
 function wpinv_get_php_arg_separator_output() {
368
-	return ini_get( 'arg_separator.output' );
368
+    return ini_get( 'arg_separator.output' );
369 369
 }
370 370
 
371 371
 function wpinv_rgb_from_hex( $color ) {
@@ -716,11 +716,11 @@  discard block
 block discarded – undo
716 716
         $list = array();
717 717
     }
718 718
 
719
-	if ( ! is_array( $list ) ) {
720
-		return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY );
721
-	}
719
+    if ( ! is_array( $list ) ) {
720
+        return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY );
721
+    }
722 722
 
723
-	return $list;
723
+    return $list;
724 724
 }
725 725
 
726 726
 /**
@@ -740,9 +740,9 @@  discard block
 block discarded – undo
740 740
     }
741 741
 
742 742
     $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" );
743
-	wp_cache_set( "wpinv-data-$key", $data, 'wpinv' );
743
+    wp_cache_set( "wpinv-data-$key", $data, 'wpinv' );
744 744
 
745
-	return $data;
745
+    return $data;
746 746
 }
747 747
 
748 748
 /**
@@ -771,17 +771,17 @@  discard block
 block discarded – undo
771 771
  */
772 772
 function wpinv_clean( $var ) {
773 773
 
774
-	if ( is_array( $var ) ) {
775
-		return array_map( 'wpinv_clean', $var );
774
+    if ( is_array( $var ) ) {
775
+        return array_map( 'wpinv_clean', $var );
776 776
     }
777 777
 
778 778
     if ( is_object( $var ) ) {
779
-		$object_vars = get_object_vars( $var );
780
-		foreach ( $object_vars as $property_name => $property_value ) {
781
-			$var->$property_name = wpinv_clean( $property_value );
779
+        $object_vars = get_object_vars( $var );
780
+        foreach ( $object_vars as $property_name => $property_value ) {
781
+            $var->$property_name = wpinv_clean( $property_value );
782 782
         }
783 783
         return $var;
784
-	}
784
+    }
785 785
     
786 786
     return is_string( $var ) ? sanitize_text_field( $var ) : $var;
787 787
 }
@@ -794,7 +794,7 @@  discard block
 block discarded – undo
794 794
  */
795 795
 function getpaid_convert_price_string_to_options( $str ) {
796 796
 
797
-	$raw_options = array_map( 'trim', explode( ',', $str ) );
797
+    $raw_options = array_map( 'trim', explode( ',', $str ) );
798 798
     $options     = array();
799 799
 
800 800
     foreach ( $raw_options as $option ) {
@@ -872,7 +872,7 @@  discard block
 block discarded – undo
872 872
  * @return string
873 873
  */
874 874
 function getpaid_date_format() {
875
-	return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) );
875
+    return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) );
876 876
 }
877 877
 
878 878
 /**
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
  * @return string
882 882
  */
883 883
 function getpaid_time_format() {
884
-	return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) );
884
+    return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) );
885 885
 }
886 886
 
887 887
 /**
@@ -894,15 +894,15 @@  discard block
 block discarded – undo
894 894
 function getpaid_limit_length( $string, $limit ) {
895 895
     $str_limit = $limit - 3;
896 896
 
897
-	if ( function_exists( 'mb_strimwidth' ) ) {
898
-		if ( mb_strlen( $string ) > $limit ) {
899
-			$string = mb_strimwidth( $string, 0, $str_limit ) . '...';
900
-		}
901
-	} else {
902
-		if ( strlen( $string ) > $limit ) {
903
-			$string = substr( $string, 0, $str_limit ) . '...';
904
-		}
905
-	}
897
+    if ( function_exists( 'mb_strimwidth' ) ) {
898
+        if ( mb_strlen( $string ) > $limit ) {
899
+            $string = mb_strimwidth( $string, 0, $str_limit ) . '...';
900
+        }
901
+    } else {
902
+        if ( strlen( $string ) > $limit ) {
903
+            $string = substr( $string, 0, $str_limit ) . '...';
904
+        }
905
+    }
906 906
     return $string;
907 907
 
908 908
 }
Please login to merge, or discard this patch.
Spacing   +255 added lines, -255 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
  
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Are we supporting item quantities?
@@ -20,35 +20,35 @@  discard block
 block discarded – undo
20 20
  */
21 21
 function wpinv_get_ip() {
22 22
 
23
-    if ( isset( $_SERVER['HTTP_X_REAL_IP'] ) ) {
24
-        return sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_REAL_IP'] ) );
23
+    if (isset($_SERVER['HTTP_X_REAL_IP'])) {
24
+        return sanitize_text_field(wp_unslash($_SERVER['HTTP_X_REAL_IP']));
25 25
     }
26 26
 
27
-    if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
27
+    if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
28 28
         // Proxy servers can send through this header like this: X-Forwarded-For: client1, proxy1, proxy2
29 29
         // Make sure we always only send through the first IP in the list which should always be the client IP.
30
-        return (string) rest_is_ip_address( trim( current( preg_split( '/,/', sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) ) ) ) );
30
+        return (string) rest_is_ip_address(trim(current(preg_split('/,/', sanitize_text_field(wp_unslash($_SERVER['HTTP_X_FORWARDED_FOR']))))));
31 31
     }
32 32
 
33
-    if ( isset( $_SERVER['HTTP_CLIENT_IP'] ) ) {
34
-        return sanitize_text_field( wp_unslash( $_SERVER['HTTP_CLIENT_IP'] ) );
33
+    if (isset($_SERVER['HTTP_CLIENT_IP'])) {
34
+        return sanitize_text_field(wp_unslash($_SERVER['HTTP_CLIENT_IP']));
35 35
     }
36 36
 
37
-    if ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
38
-        return sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) );
37
+    if (isset($_SERVER['REMOTE_ADDR'])) {
38
+        return sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR']));
39 39
     }
40 40
 
41 41
     return '';
42 42
 }
43 43
 
44 44
 function wpinv_get_user_agent() {
45
-    if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
46
-        $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] );
45
+    if (!empty($_SERVER['HTTP_USER_AGENT'])) {
46
+        $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']);
47 47
     } else {
48 48
         $user_agent = '';
49 49
     }
50 50
 
51
-    return apply_filters( 'wpinv_get_user_agent', $user_agent );
51
+    return apply_filters('wpinv_get_user_agent', $user_agent);
52 52
 }
53 53
 
54 54
 /**
@@ -56,16 +56,16 @@  discard block
 block discarded – undo
56 56
  * 
57 57
  * @param string $amount The amount to sanitize.
58 58
  */
59
-function wpinv_sanitize_amount( $amount ) {
59
+function wpinv_sanitize_amount($amount) {
60 60
 
61 61
     // Format decimals.
62
-    $amount = str_replace( wpinv_decimal_separator(), '.', $amount );
62
+    $amount = str_replace(wpinv_decimal_separator(), '.', $amount);
63 63
 
64 64
     // Remove thousands.
65
-    $amount = str_replace( wpinv_thousands_separator(), '', $amount );
65
+    $amount = str_replace(wpinv_thousands_separator(), '', $amount);
66 66
 
67 67
     // Cast the remaining to a float.
68
-    return (float) preg_replace( '/[^0-9\.\-]/', '', $amount );
68
+    return (float) preg_replace('/[^0-9\.\-]/', '', $amount);
69 69
 
70 70
 }
71 71
 
@@ -75,15 +75,15 @@  discard block
 block discarded – undo
75 75
  * @param float $amount
76 76
  * @param int|null $decimals
77 77
  */
78
-function wpinv_round_amount( $amount, $decimals = null ) {
78
+function wpinv_round_amount($amount, $decimals = null) {
79 79
 
80
-    if ( $decimals === null ) {
80
+    if ($decimals === null) {
81 81
         $decimals = wpinv_decimals();
82 82
     }
83 83
     
84
-    $amount = round( (float) $amount, absint( $decimals ) );
84
+    $amount = round((float) $amount, absint($decimals));
85 85
 
86
-    return apply_filters( 'wpinv_round_amount', $amount, $decimals );
86
+    return apply_filters('wpinv_round_amount', $amount, $decimals);
87 87
 }
88 88
 
89 89
 /**
@@ -95,32 +95,32 @@  discard block
 block discarded – undo
95 95
  * @param string|WPInv_Invoice $invoice The invoice object|post type|type
96 96
  * @return array
97 97
  */
98
-function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) {
98
+function wpinv_get_invoice_statuses($draft = false, $trashed = false, $invoice = false) {
99 99
 
100 100
 	$invoice_statuses = array(
101
-		'wpi-pending'    => _x( 'Pending payment', 'Invoice status', 'invoicing' ),
102
-        'publish'        => _x( 'Paid', 'Invoice status', 'invoicing' ),
103
-        'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ),
104
-		'wpi-onhold'     => _x( 'On hold', 'Invoice status', 'invoicing' ),
105
-		'wpi-cancelled'  => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
106
-		'wpi-refunded'   => _x( 'Refunded', 'Invoice status', 'invoicing' ),
107
-        'wpi-failed'     => _x( 'Failed', 'Invoice status', 'invoicing' ),
108
-        'wpi-renewal'    => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ),
101
+		'wpi-pending'    => _x('Pending payment', 'Invoice status', 'invoicing'),
102
+        'publish'        => _x('Paid', 'Invoice status', 'invoicing'),
103
+        'wpi-processing' => _x('Processing', 'Invoice status', 'invoicing'),
104
+		'wpi-onhold'     => _x('On hold', 'Invoice status', 'invoicing'),
105
+		'wpi-cancelled'  => _x('Cancelled', 'Invoice status', 'invoicing'),
106
+		'wpi-refunded'   => _x('Refunded', 'Invoice status', 'invoicing'),
107
+        'wpi-failed'     => _x('Failed', 'Invoice status', 'invoicing'),
108
+        'wpi-renewal'    => _x('Renewal Payment', 'Invoice status', 'invoicing'),
109 109
     );
110 110
 
111
-    if ( $draft ) {
112
-        $invoice_statuses['draft'] = __( 'Draft', 'invoicing' );
111
+    if ($draft) {
112
+        $invoice_statuses['draft'] = __('Draft', 'invoicing');
113 113
     }
114 114
 
115
-    if ( $trashed ) {
116
-        $invoice_statuses['trash'] = __( 'Trash', 'invoicing' );
115
+    if ($trashed) {
116
+        $invoice_statuses['trash'] = __('Trash', 'invoicing');
117 117
     }
118 118
 
119
-    if ( $invoice instanceof WPInv_Invoice ) {
119
+    if ($invoice instanceof WPInv_Invoice) {
120 120
         $invoice = $invoice->get_post_type();
121 121
     }
122 122
 
123
-	return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice );
123
+	return apply_filters('wpinv_statuses', $invoice_statuses, $invoice);
124 124
 }
125 125
 
126 126
 /**
@@ -129,11 +129,11 @@  discard block
 block discarded – undo
129 129
  * @param string $status The raw status
130 130
  * @param string|WPInv_Invoice $invoice The invoice object|post type|type
131 131
  */
132
-function wpinv_status_nicename( $status, $invoice = false ) {
133
-    $statuses = wpinv_get_invoice_statuses( true, true, $invoice );
134
-    $status   = isset( $statuses[$status] ) ? $statuses[$status] : $status;
132
+function wpinv_status_nicename($status, $invoice = false) {
133
+    $statuses = wpinv_get_invoice_statuses(true, true, $invoice);
134
+    $status   = isset($statuses[$status]) ? $statuses[$status] : $status;
135 135
 
136
-    return sanitize_text_field( $status );
136
+    return sanitize_text_field($status);
137 137
 }
138 138
 
139 139
 /**
@@ -141,13 +141,13 @@  discard block
 block discarded – undo
141 141
  * 
142 142
  * @param string $current
143 143
  */
144
-function wpinv_get_currency( $current = '' ) {
144
+function wpinv_get_currency($current = '') {
145 145
 
146
-    if ( empty( $current ) ) {
147
-        $current = apply_filters( 'wpinv_currency', wpinv_get_option( 'currency', 'USD' ) );
146
+    if (empty($current)) {
147
+        $current = apply_filters('wpinv_currency', wpinv_get_option('currency', 'USD'));
148 148
     }
149 149
 
150
-    return trim( strtoupper( $current ) );
150
+    return trim(strtoupper($current));
151 151
 }
152 152
 
153 153
 /**
@@ -155,25 +155,25 @@  discard block
 block discarded – undo
155 155
  * 
156 156
  * @param string|null $currency The currency code. Defaults to the default currency.
157 157
  */
158
-function wpinv_currency_symbol( $currency = null ) {
158
+function wpinv_currency_symbol($currency = null) {
159 159
 
160 160
     // Prepare the currency.
161
-    $currency = empty( $currency ) ? wpinv_get_currency() : wpinv_clean( $currency );
161
+    $currency = empty($currency) ? wpinv_get_currency() : wpinv_clean($currency);
162 162
 
163 163
     // Fetch all symbols.
164 164
     $symbols = wpinv_get_currency_symbols();
165 165
 
166 166
     // Fetch this currencies symbol.
167
-    $currency_symbol = isset( $symbols[$currency] ) ? $symbols[$currency] : $currency;
167
+    $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency;
168 168
 
169 169
     // Filter the symbol.
170
-    return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency );
170
+    return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency);
171 171
 }
172 172
 
173 173
 function wpinv_currency_position() {
174
-    $position = wpinv_get_option( 'currency_position', 'left' );
174
+    $position = wpinv_get_option('currency_position', 'left');
175 175
     
176
-    return apply_filters( 'wpinv_currency_position', $position );
176
+    return apply_filters('wpinv_currency_position', $position);
177 177
 }
178 178
 
179 179
 /**
@@ -181,13 +181,13 @@  discard block
 block discarded – undo
181 181
  * 
182 182
  * @param $string|null $current
183 183
  */
184
-function wpinv_thousands_separator( $current = null ) {
184
+function wpinv_thousands_separator($current = null) {
185 185
 
186
-    if ( null == $current ) {
187
-        $current = wpinv_get_option( 'thousands_separator', '.' );
186
+    if (null == $current) {
187
+        $current = wpinv_get_option('thousands_separator', '.');
188 188
     }
189 189
 
190
-    return trim( $current );
190
+    return trim($current);
191 191
 }
192 192
 
193 193
 /**
@@ -195,13 +195,13 @@  discard block
 block discarded – undo
195 195
  * 
196 196
  * @param $string|null $current
197 197
  */
198
-function wpinv_decimal_separator( $current = null ) {
198
+function wpinv_decimal_separator($current = null) {
199 199
 
200
-    if ( null == $current ) {
201
-        $current = wpinv_get_option( 'decimal_separator', '.' );
200
+    if (null == $current) {
201
+        $current = wpinv_get_option('decimal_separator', '.');
202 202
     }
203 203
     
204
-    return trim( $current );
204
+    return trim($current);
205 205
 }
206 206
 
207 207
 /**
@@ -209,27 +209,27 @@  discard block
 block discarded – undo
209 209
  * 
210 210
  * @param $string|null $current
211 211
  */
212
-function wpinv_decimals( $current = null ) {
212
+function wpinv_decimals($current = null) {
213 213
 
214
-    if ( null == $current ) {
215
-        $current = wpinv_get_option( 'decimals', 2 );
214
+    if (null == $current) {
215
+        $current = wpinv_get_option('decimals', 2);
216 216
     }
217 217
     
218
-    return absint( $current );
218
+    return absint($current);
219 219
 }
220 220
 
221 221
 /**
222 222
  * Retrieves a list of all supported currencies.
223 223
  */
224 224
 function wpinv_get_currencies() {
225
-    return apply_filters( 'wpinv_currencies', wpinv_get_data( 'currencies' ) );
225
+    return apply_filters('wpinv_currencies', wpinv_get_data('currencies'));
226 226
 }
227 227
 
228 228
 /**
229 229
  * Retrieves a list of all currency symbols.
230 230
  */
231 231
 function wpinv_get_currency_symbols() {
232
-    return apply_filters( 'wpinv_currency_symbols', wpinv_get_data( 'currency-symbols' ) );
232
+    return apply_filters('wpinv_currency_symbols', wpinv_get_data('currency-symbols'));
233 233
 }
234 234
 
235 235
 /**
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 	$currency_pos = wpinv_currency_position();
242 242
 	$format       = '%1$s%2$s';
243 243
 
244
-	switch ( $currency_pos ) {
244
+	switch ($currency_pos) {
245 245
 		case 'left':
246 246
 			$format = '%1$s%2$s';
247 247
 			break;
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 			break;
257 257
 	}
258 258
 
259
-	return apply_filters( 'getpaid_price_format', $format, $currency_pos );
259
+	return apply_filters('getpaid_price_format', $format, $currency_pos);
260 260
 }
261 261
 
262 262
 /**
@@ -266,25 +266,25 @@  discard block
 block discarded – undo
266 266
  * @param  string $currency Currency.
267 267
  * @return string
268 268
  */
269
-function wpinv_price( $amount = 0, $currency = '' ) {
269
+function wpinv_price($amount = 0, $currency = '') {
270 270
 
271 271
     // Backwards compatibility.
272
-    $amount             = floatval( wpinv_sanitize_amount( $amount ) );
272
+    $amount             = floatval(wpinv_sanitize_amount($amount));
273 273
 
274 274
     // Prepare variables.
275
-    $currency           = wpinv_get_currency( $currency );
275
+    $currency           = wpinv_get_currency($currency);
276 276
     $amount             = (float) $amount;
277 277
     $unformatted_amount = $amount;
278 278
     $negative           = $amount < 0;
279
-    $amount             = apply_filters( 'getpaid_raw_amount', floatval( $negative ? $amount * -1 : $amount ) );
280
-    $amount             = wpinv_format_amount( $amount );
279
+    $amount             = apply_filters('getpaid_raw_amount', floatval($negative ? $amount * -1 : $amount));
280
+    $amount             = wpinv_format_amount($amount);
281 281
 
282 282
     // Format the amount.
283 283
     $format             = getpaid_get_price_format();
284
-    $formatted_amount   = ( $negative ? '-' : '' ) . sprintf( $format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol( $currency ) . '</span>', $amount );
284
+    $formatted_amount   = ($negative ? '-' : '') . sprintf($format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol($currency) . '</span>', $amount);
285 285
 
286 286
     // Filter the formatting.
287
-    return apply_filters( 'wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount );
287
+    return apply_filters('wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount);
288 288
 }
289 289
 
290 290
 /**
@@ -295,33 +295,33 @@  discard block
 block discarded – undo
295 295
  * @param  bool     $calculate Whether or not to apply separators.
296 296
  * @return string
297 297
  */
298
-function wpinv_format_amount( $amount, $decimals = null, $calculate = false ) {
298
+function wpinv_format_amount($amount, $decimals = null, $calculate = false) {
299 299
     $thousands_sep = wpinv_thousands_separator();
300 300
     $decimal_sep   = wpinv_decimal_separator();
301
-    $decimals      = wpinv_decimals( $decimals );
301
+    $decimals      = wpinv_decimals($decimals);
302 302
 
303 303
     // Format decimals.
304
-    $amount = str_replace( $decimal_sep, '.', $amount );
304
+    $amount = str_replace($decimal_sep, '.', $amount);
305 305
 
306 306
     // Remove thousands.
307
-    $amount = str_replace( $thousands_sep, '', $amount );
307
+    $amount = str_replace($thousands_sep, '', $amount);
308 308
 
309 309
     // Cast the remaining to a float.
310
-    $amount = floatval( $amount );
310
+    $amount = floatval($amount);
311 311
 
312
-    if ( $calculate ) {
312
+    if ($calculate) {
313 313
         return $amount;
314 314
     }
315 315
 
316 316
     // Fomart the amount.
317
-    return number_format( $amount, $decimals, $decimal_sep, $thousands_sep );
317
+    return number_format($amount, $decimals, $decimal_sep, $thousands_sep);
318 318
 }
319 319
 
320
-function wpinv_sanitize_key( $key ) {
320
+function wpinv_sanitize_key($key) {
321 321
     $raw_key = $key;
322
-    $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key );
322
+    $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key);
323 323
 
324
-    return apply_filters( 'wpinv_sanitize_key', $key, $raw_key );
324
+    return apply_filters('wpinv_sanitize_key', $key, $raw_key);
325 325
 }
326 326
 
327 327
 /**
@@ -329,8 +329,8 @@  discard block
 block discarded – undo
329 329
  * 
330 330
  * @param $str the file whose extension should be retrieved.
331 331
  */
332
-function wpinv_get_file_extension( $str ) {
333
-    $filetype = wp_check_filetype( $str );
332
+function wpinv_get_file_extension($str) {
333
+    $filetype = wp_check_filetype($str);
334 334
     return $filetype['ext'];
335 335
 }
336 336
 
@@ -339,16 +339,16 @@  discard block
 block discarded – undo
339 339
  * 
340 340
  * @param string $string
341 341
  */
342
-function wpinv_string_is_image_url( $string ) {
343
-    $extension = strtolower( wpinv_get_file_extension( $string ) );
344
-    return in_array( $extension, array( 'jpeg', 'jpg', 'png', 'gif', 'ico' ), true );
342
+function wpinv_string_is_image_url($string) {
343
+    $extension = strtolower(wpinv_get_file_extension($string));
344
+    return in_array($extension, array('jpeg', 'jpg', 'png', 'gif', 'ico'), true);
345 345
 }
346 346
 
347 347
 /**
348 348
  * Returns the current URL.
349 349
  */
350 350
 function wpinv_get_current_page_url() {
351
-    return ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
351
+    return (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
352 352
 }
353 353
 
354 354
 /**
@@ -358,46 +358,46 @@  discard block
 block discarded – undo
358 358
  * @param string $name  Constant name.
359 359
  * @param mixed  $value Value.
360 360
  */
361
-function getpaid_maybe_define_constant( $name, $value ) {
362
-	if ( ! defined( $name ) ) {
363
-		define( $name, $value );
361
+function getpaid_maybe_define_constant($name, $value) {
362
+	if (!defined($name)) {
363
+		define($name, $value);
364 364
 	}
365 365
 }
366 366
 
367 367
 function wpinv_get_php_arg_separator_output() {
368
-	return ini_get( 'arg_separator.output' );
368
+	return ini_get('arg_separator.output');
369 369
 }
370 370
 
371
-function wpinv_rgb_from_hex( $color ) {
372
-    $color = str_replace( '#', '', $color );
371
+function wpinv_rgb_from_hex($color) {
372
+    $color = str_replace('#', '', $color);
373 373
 
374 374
     // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF"
375
-    $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color );
376
-    if ( empty( $color ) ) {
375
+    $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color);
376
+    if (empty($color)) {
377 377
         return NULL;
378 378
     }
379 379
 
380
-    $color = str_split( $color );
380
+    $color = str_split($color);
381 381
 
382 382
     $rgb      = array();
383
-    $rgb['R'] = hexdec( $color[0] . $color[1] );
384
-    $rgb['G'] = hexdec( $color[2] . $color[3] );
385
-    $rgb['B'] = hexdec( $color[4] . $color[5] );
383
+    $rgb['R'] = hexdec($color[0] . $color[1]);
384
+    $rgb['G'] = hexdec($color[2] . $color[3]);
385
+    $rgb['B'] = hexdec($color[4] . $color[5]);
386 386
 
387 387
     return $rgb;
388 388
 }
389 389
 
390
-function wpinv_hex_darker( $color, $factor = 30 ) {
391
-    $base  = wpinv_rgb_from_hex( $color );
390
+function wpinv_hex_darker($color, $factor = 30) {
391
+    $base  = wpinv_rgb_from_hex($color);
392 392
     $color = '#';
393 393
 
394
-    foreach ( $base as $k => $v ) {
394
+    foreach ($base as $k => $v) {
395 395
         $amount      = $v / 100;
396
-        $amount      = round( $amount * $factor );
396
+        $amount      = round($amount * $factor);
397 397
         $new_decimal = $v - $amount;
398 398
 
399
-        $new_hex_component = dechex( $new_decimal );
400
-        if ( strlen( $new_hex_component ) < 2 ) {
399
+        $new_hex_component = dechex($new_decimal);
400
+        if (strlen($new_hex_component) < 2) {
401 401
             $new_hex_component = "0" . $new_hex_component;
402 402
         }
403 403
         $color .= $new_hex_component;
@@ -406,18 +406,18 @@  discard block
 block discarded – undo
406 406
     return $color;
407 407
 }
408 408
 
409
-function wpinv_hex_lighter( $color, $factor = 30 ) {
410
-    $base  = wpinv_rgb_from_hex( $color );
409
+function wpinv_hex_lighter($color, $factor = 30) {
410
+    $base  = wpinv_rgb_from_hex($color);
411 411
     $color = '#';
412 412
 
413
-    foreach ( $base as $k => $v ) {
413
+    foreach ($base as $k => $v) {
414 414
         $amount      = 255 - $v;
415 415
         $amount      = $amount / 100;
416
-        $amount      = round( $amount * $factor );
416
+        $amount      = round($amount * $factor);
417 417
         $new_decimal = $v + $amount;
418 418
 
419
-        $new_hex_component = dechex( $new_decimal );
420
-        if ( strlen( $new_hex_component ) < 2 ) {
419
+        $new_hex_component = dechex($new_decimal);
420
+        if (strlen($new_hex_component) < 2) {
421 421
             $new_hex_component = "0" . $new_hex_component;
422 422
         }
423 423
         $color .= $new_hex_component;
@@ -426,22 +426,22 @@  discard block
 block discarded – undo
426 426
     return $color;
427 427
 }
428 428
 
429
-function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) {
430
-    $hex = str_replace( '#', '', $color );
429
+function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') {
430
+    $hex = str_replace('#', '', $color);
431 431
 
432
-    $c_r = hexdec( substr( $hex, 0, 2 ) );
433
-    $c_g = hexdec( substr( $hex, 2, 2 ) );
434
-    $c_b = hexdec( substr( $hex, 4, 2 ) );
432
+    $c_r = hexdec(substr($hex, 0, 2));
433
+    $c_g = hexdec(substr($hex, 2, 2));
434
+    $c_b = hexdec(substr($hex, 4, 2));
435 435
 
436
-    $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000;
436
+    $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000;
437 437
 
438 438
     return $brightness > 155 ? $dark : $light;
439 439
 }
440 440
 
441
-function wpinv_format_hex( $hex ) {
442
-    $hex = trim( str_replace( '#', '', $hex ) );
441
+function wpinv_format_hex($hex) {
442
+    $hex = trim(str_replace('#', '', $hex));
443 443
 
444
-    if ( strlen( $hex ) == 3 ) {
444
+    if (strlen($hex) == 3) {
445 445
         $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2];
446 446
     }
447 447
 
@@ -461,12 +461,12 @@  discard block
 block discarded – undo
461 461
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
462 462
  * @return string
463 463
  */
464
-function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) {
465
-    if ( function_exists( 'mb_strimwidth' ) ) {
466
-        return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding );
464
+function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') {
465
+    if (function_exists('mb_strimwidth')) {
466
+        return mb_strimwidth($str, $start, $width, $trimmaker, $encoding);
467 467
     }
468 468
     
469
-    return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker;
469
+    return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker;
470 470
 }
471 471
 
472 472
 /**
@@ -478,28 +478,28 @@  discard block
 block discarded – undo
478 478
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
479 479
  * @return int Returns the number of characters in string.
480 480
  */
481
-function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) {
482
-    if ( function_exists( 'mb_strlen' ) ) {
483
-        return mb_strlen( $str, $encoding );
481
+function wpinv_utf8_strlen($str, $encoding = 'UTF-8') {
482
+    if (function_exists('mb_strlen')) {
483
+        return mb_strlen($str, $encoding);
484 484
     }
485 485
         
486
-    return strlen( $str );
486
+    return strlen($str);
487 487
 }
488 488
 
489
-function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) {
490
-    if ( function_exists( 'mb_strtolower' ) ) {
491
-        return mb_strtolower( $str, $encoding );
489
+function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') {
490
+    if (function_exists('mb_strtolower')) {
491
+        return mb_strtolower($str, $encoding);
492 492
     }
493 493
     
494
-    return strtolower( $str );
494
+    return strtolower($str);
495 495
 }
496 496
 
497
-function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) {
498
-    if ( function_exists( 'mb_strtoupper' ) ) {
499
-        return mb_strtoupper( $str, $encoding );
497
+function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') {
498
+    if (function_exists('mb_strtoupper')) {
499
+        return mb_strtoupper($str, $encoding);
500 500
     }
501 501
     
502
-    return strtoupper( $str );
502
+    return strtoupper($str);
503 503
 }
504 504
 
505 505
 /**
@@ -513,12 +513,12 @@  discard block
 block discarded – undo
513 513
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
514 514
  * @return int Returns the position of the first occurrence of search in the string.
515 515
  */
516
-function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
517
-    if ( function_exists( 'mb_strpos' ) ) {
518
-        return mb_strpos( $str, $find, $offset, $encoding );
516
+function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
517
+    if (function_exists('mb_strpos')) {
518
+        return mb_strpos($str, $find, $offset, $encoding);
519 519
     }
520 520
         
521
-    return strpos( $str, $find, $offset );
521
+    return strpos($str, $find, $offset);
522 522
 }
523 523
 
524 524
 /**
@@ -532,12 +532,12 @@  discard block
 block discarded – undo
532 532
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
533 533
  * @return int Returns the position of the last occurrence of search.
534 534
  */
535
-function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
536
-    if ( function_exists( 'mb_strrpos' ) ) {
537
-        return mb_strrpos( $str, $find, $offset, $encoding );
535
+function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
536
+    if (function_exists('mb_strrpos')) {
537
+        return mb_strrpos($str, $find, $offset, $encoding);
538 538
     }
539 539
         
540
-    return strrpos( $str, $find, $offset );
540
+    return strrpos($str, $find, $offset);
541 541
 }
542 542
 
543 543
 /**
@@ -552,16 +552,16 @@  discard block
 block discarded – undo
552 552
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
553 553
  * @return string
554 554
  */
555
-function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) {
556
-    if ( function_exists( 'mb_substr' ) ) {
557
-        if ( $length === null ) {
558
-            return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding );
555
+function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') {
556
+    if (function_exists('mb_substr')) {
557
+        if ($length === null) {
558
+            return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding);
559 559
         } else {
560
-            return mb_substr( $str, $start, $length, $encoding );
560
+            return mb_substr($str, $start, $length, $encoding);
561 561
         }
562 562
     }
563 563
         
564
-    return substr( $str, $start, $length );
564
+    return substr($str, $start, $length);
565 565
 }
566 566
 
567 567
 /**
@@ -573,48 +573,48 @@  discard block
 block discarded – undo
573 573
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
574 574
  * @return string The width of string.
575 575
  */
576
-function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) {
577
-    if ( function_exists( 'mb_strwidth' ) ) {
578
-        return mb_strwidth( $str, $encoding );
576
+function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') {
577
+    if (function_exists('mb_strwidth')) {
578
+        return mb_strwidth($str, $encoding);
579 579
     }
580 580
     
581
-    return wpinv_utf8_strlen( $str, $encoding );
581
+    return wpinv_utf8_strlen($str, $encoding);
582 582
 }
583 583
 
584
-function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) {
585
-    if ( function_exists( 'mb_strlen' ) ) {
586
-        $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding );
584
+function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') {
585
+    if (function_exists('mb_strlen')) {
586
+        $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding);
587 587
         $str_end = "";
588 588
         
589
-        if ( $lower_str_end ) {
590
-            $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding );
589
+        if ($lower_str_end) {
590
+            $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding);
591 591
         } else {
592
-            $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding );
592
+            $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding);
593 593
         }
594 594
 
595 595
         return $first_letter . $str_end;
596 596
     }
597 597
     
598
-    return ucfirst( $str );
598
+    return ucfirst($str);
599 599
 }
600 600
 
601
-function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) {
602
-    if ( function_exists( 'mb_convert_case' ) ) {
603
-        return mb_convert_case( $str, MB_CASE_TITLE, $encoding );
601
+function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') {
602
+    if (function_exists('mb_convert_case')) {
603
+        return mb_convert_case($str, MB_CASE_TITLE, $encoding);
604 604
     }
605 605
     
606
-    return ucwords( $str );
606
+    return ucwords($str);
607 607
 }
608 608
 
609
-function wpinv_period_in_days( $period, $unit ) {
610
-    $period = absint( $period );
609
+function wpinv_period_in_days($period, $unit) {
610
+    $period = absint($period);
611 611
     
612
-    if ( $period > 0 ) {
613
-        if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) {
612
+    if ($period > 0) {
613
+        if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) {
614 614
             $period = $period * 7;
615
-        } else if ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) {
615
+        } else if (in_array(strtolower($unit), array('m', 'month', 'months'))) {
616 616
             $period = $period * 30;
617
-        } else if ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) {
617
+        } else if (in_array(strtolower($unit), array('y', 'year', 'years'))) {
618 618
             $period = $period * 365;
619 619
         }
620 620
     }
@@ -622,14 +622,14 @@  discard block
 block discarded – undo
622 622
     return $period;
623 623
 }
624 624
 
625
-function wpinv_cal_days_in_month( $calendar, $month, $year ) {
626
-    if ( function_exists( 'cal_days_in_month' ) ) {
627
-        return cal_days_in_month( $calendar, $month, $year );
625
+function wpinv_cal_days_in_month($calendar, $month, $year) {
626
+    if (function_exists('cal_days_in_month')) {
627
+        return cal_days_in_month($calendar, $month, $year);
628 628
     }
629 629
 
630 630
     // Fallback in case the calendar extension is not loaded in PHP
631 631
     // Only supports Gregorian calendar
632
-    return date( 't', mktime( 0, 0, 0, $month, 1, $year ) );
632
+    return date('t', mktime(0, 0, 0, $month, 1, $year));
633 633
 }
634 634
 
635 635
 /**
@@ -640,12 +640,12 @@  discard block
 block discarded – undo
640 640
  *
641 641
  * @return string
642 642
  */
643
-function wpi_help_tip( $tip, $allow_html = false ) {
643
+function wpi_help_tip($tip, $allow_html = false) {
644 644
 
645
-    if ( $allow_html ) {
646
-        $tip = wpi_sanitize_tooltip( $tip );
645
+    if ($allow_html) {
646
+        $tip = wpi_sanitize_tooltip($tip);
647 647
     } else {
648
-        $tip = esc_attr( $tip );
648
+        $tip = esc_attr($tip);
649 649
     }
650 650
 
651 651
     return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
@@ -659,8 +659,8 @@  discard block
 block discarded – undo
659 659
  * @param string $var
660 660
  * @return string
661 661
  */
662
-function wpi_sanitize_tooltip( $var ) {
663
-    return wp_kses( html_entity_decode( $var ), array(
662
+function wpi_sanitize_tooltip($var) {
663
+    return wp_kses(html_entity_decode($var), array(
664 664
         'br'     => array(),
665 665
         'em'     => array(),
666 666
         'strong' => array(),
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
         'li'     => array(),
672 672
         'ol'     => array(),
673 673
         'p'      => array(),
674
-    ) );
674
+    ));
675 675
 }
676 676
 
677 677
 /**
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
  */
682 682
 function wpinv_get_screen_ids() {
683 683
 
684
-    $screen_id = sanitize_title( __( 'Invoicing', 'invoicing' ) );
684
+    $screen_id = sanitize_title(__('Invoicing', 'invoicing'));
685 685
 
686 686
     $screen_ids = array(
687 687
         'toplevel_page_' . $screen_id,
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
         'invoicing_page_wpi-addons',
700 700
     );
701 701
 
702
-    return apply_filters( 'wpinv_screen_ids', $screen_ids );
702
+    return apply_filters('wpinv_screen_ids', $screen_ids);
703 703
 }
704 704
 
705 705
 /**
@@ -710,14 +710,14 @@  discard block
 block discarded – undo
710 710
  * @param array|string $list List of values.
711 711
  * @return array Sanitized array of values.
712 712
  */
713
-function wpinv_parse_list( $list ) {
713
+function wpinv_parse_list($list) {
714 714
 
715
-    if ( empty( $list ) ) {
715
+    if (empty($list)) {
716 716
         $list = array();
717 717
     }
718 718
 
719
-	if ( ! is_array( $list ) ) {
720
-		return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY );
719
+	if (!is_array($list)) {
720
+		return preg_split('/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY);
721 721
 	}
722 722
 
723 723
 	return $list;
@@ -731,16 +731,16 @@  discard block
 block discarded – undo
731 731
  * @param string $key Type of data to fetch.
732 732
  * @return mixed Fetched data.
733 733
  */
734
-function wpinv_get_data( $key ) {
734
+function wpinv_get_data($key) {
735 735
 
736 736
     // Try fetching it from the cache.
737
-    $data = wp_cache_get( "wpinv-data-$key", 'wpinv' );
738
-    if( $data ) {
737
+    $data = wp_cache_get("wpinv-data-$key", 'wpinv');
738
+    if ($data) {
739 739
         return $data;
740 740
     }
741 741
 
742
-    $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" );
743
-	wp_cache_set( "wpinv-data-$key", $data, 'wpinv' );
742
+    $data = apply_filters("wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php");
743
+	wp_cache_set("wpinv-data-$key", $data, 'wpinv');
744 744
 
745 745
 	return $data;
746 746
 }
@@ -754,10 +754,10 @@  discard block
 block discarded – undo
754 754
  * @param bool $first_empty Whether or not the first item in the list should be empty
755 755
  * @return mixed Fetched data.
756 756
  */
757
-function wpinv_maybe_add_empty_option( $options, $first_empty ) {
757
+function wpinv_maybe_add_empty_option($options, $first_empty) {
758 758
 
759
-    if ( ! empty( $options ) && $first_empty ) {
760
-        return array_merge( array( '' => '' ), $options );
759
+    if (!empty($options) && $first_empty) {
760
+        return array_merge(array('' => ''), $options);
761 761
     }
762 762
     return $options;
763 763
 
@@ -769,21 +769,21 @@  discard block
 block discarded – undo
769 769
  * @param mixed $var Data to sanitize.
770 770
  * @return string|array
771 771
  */
772
-function wpinv_clean( $var ) {
772
+function wpinv_clean($var) {
773 773
 
774
-	if ( is_array( $var ) ) {
775
-		return array_map( 'wpinv_clean', $var );
774
+	if (is_array($var)) {
775
+		return array_map('wpinv_clean', $var);
776 776
     }
777 777
 
778
-    if ( is_object( $var ) ) {
779
-		$object_vars = get_object_vars( $var );
780
-		foreach ( $object_vars as $property_name => $property_value ) {
781
-			$var->$property_name = wpinv_clean( $property_value );
778
+    if (is_object($var)) {
779
+		$object_vars = get_object_vars($var);
780
+		foreach ($object_vars as $property_name => $property_value) {
781
+			$var->$property_name = wpinv_clean($property_value);
782 782
         }
783 783
         return $var;
784 784
 	}
785 785
     
786
-    return is_string( $var ) ? sanitize_text_field( $var ) : $var;
786
+    return is_string($var) ? sanitize_text_field($var) : $var;
787 787
 }
788 788
 
789 789
 /**
@@ -792,43 +792,43 @@  discard block
 block discarded – undo
792 792
  * @param string $str Data to convert.
793 793
  * @return string|array
794 794
  */
795
-function getpaid_convert_price_string_to_options( $str ) {
795
+function getpaid_convert_price_string_to_options($str) {
796 796
 
797
-	$raw_options = array_map( 'trim', explode( ',', $str ) );
798
-    $options     = array();
797
+	$raw_options = array_map('trim', explode(',', $str));
798
+    $options = array();
799 799
 
800
-    foreach ( $raw_options as $option ) {
800
+    foreach ($raw_options as $option) {
801 801
 
802
-        if ( '' == $option ) {
802
+        if ('' == $option) {
803 803
             continue;
804 804
         }
805 805
 
806
-        $option = array_map( 'trim', explode( '|', $option ) );
806
+        $option = array_map('trim', explode('|', $option));
807 807
 
808 808
         $price = null;
809 809
         $label = null;
810 810
 
811
-        if ( isset( $option[0] ) && '' !=  $option[0] ) {
812
-            $label  = $option[0];
811
+        if (isset($option[0]) && '' != $option[0]) {
812
+            $label = $option[0];
813 813
         }
814 814
 
815
-        if ( isset( $option[1] ) && '' !=  $option[1] ) {
815
+        if (isset($option[1]) && '' != $option[1]) {
816 816
             $price = $option[1];
817 817
         }
818 818
 
819
-        if ( ! isset( $price ) ) {
819
+        if (!isset($price)) {
820 820
             $price = $label;
821 821
         }
822 822
 
823
-        if ( ! isset( $price ) || ! is_numeric( $price ) ) {
823
+        if (!isset($price) || !is_numeric($price)) {
824 824
             continue;
825 825
         }
826 826
 
827
-        if ( ! isset( $label ) ) {
827
+        if (!isset($label)) {
828 828
             $label = $price;
829 829
         }
830 830
 
831
-        $options[ $price ] = $label;
831
+        $options[$price] = $label;
832 832
     }
833 833
 
834 834
     return $options;
@@ -837,22 +837,22 @@  discard block
 block discarded – undo
837 837
 /**
838 838
  * Returns the help tip.
839 839
  */
840
-function getpaid_get_help_tip( $tip, $additional_classes = '' ) {
841
-    $additional_classes = sanitize_html_class( $additional_classes );
842
-    $tip                = esc_attr__( $tip );
840
+function getpaid_get_help_tip($tip, $additional_classes = '') {
841
+    $additional_classes = sanitize_html_class($additional_classes);
842
+    $tip                = esc_attr__($tip);
843 843
     return "<span class='wpi-help-tip dashicons dashicons-editor-help $additional_classes' title='$tip'></span>";
844 844
 }
845 845
 
846 846
 /**
847 847
  * Formats a date
848 848
  */
849
-function getpaid_format_date( $date ) {
849
+function getpaid_format_date($date) {
850 850
 
851
-    if ( empty( $date ) || $date == '0000-00-00 00:00:00' ) {
851
+    if (empty($date) || $date == '0000-00-00 00:00:00') {
852 852
         return '';
853 853
     }
854 854
 
855
-    return date_i18n( getpaid_date_format(), strtotime( $date ) );
855
+    return date_i18n(getpaid_date_format(), strtotime($date));
856 856
 
857 857
 }
858 858
 
@@ -861,9 +861,9 @@  discard block
 block discarded – undo
861 861
  *
862 862
  * @return string
863 863
  */
864
-function getpaid_format_date_value( $date, $default = "&mdash;" ) {
865
-    $date = getpaid_format_date( $date );
866
-    return empty( $date ) ? $default : $date;
864
+function getpaid_format_date_value($date, $default = "&mdash;") {
865
+    $date = getpaid_format_date($date);
866
+    return empty($date) ? $default : $date;
867 867
 }
868 868
 
869 869
 /**
@@ -872,7 +872,7 @@  discard block
 block discarded – undo
872 872
  * @return string
873 873
  */
874 874
 function getpaid_date_format() {
875
-	return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) );
875
+	return apply_filters('getpaid_date_format', get_option('date_format'));
876 876
 }
877 877
 
878 878
 /**
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
  * @return string
882 882
  */
883 883
 function getpaid_time_format() {
884
-	return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) );
884
+	return apply_filters('getpaid_time_format', get_option('time_format'));
885 885
 }
886 886
 
887 887
 /**
@@ -891,16 +891,16 @@  discard block
 block discarded – undo
891 891
  * @param  integer $limit Limit size in characters.
892 892
  * @return string
893 893
  */
894
-function getpaid_limit_length( $string, $limit ) {
894
+function getpaid_limit_length($string, $limit) {
895 895
     $str_limit = $limit - 3;
896 896
 
897
-	if ( function_exists( 'mb_strimwidth' ) ) {
898
-		if ( mb_strlen( $string ) > $limit ) {
899
-			$string = mb_strimwidth( $string, 0, $str_limit ) . '...';
897
+	if (function_exists('mb_strimwidth')) {
898
+		if (mb_strlen($string) > $limit) {
899
+			$string = mb_strimwidth($string, 0, $str_limit) . '...';
900 900
 		}
901 901
 	} else {
902
-		if ( strlen( $string ) > $limit ) {
903
-			$string = substr( $string, 0, $str_limit ) . '...';
902
+		if (strlen($string) > $limit) {
903
+			$string = substr($string, 0, $str_limit) . '...';
904 904
 		}
905 905
 	}
906 906
     return $string;
@@ -914,7 +914,7 @@  discard block
 block discarded – undo
914 914
  * @since 1.0.19
915 915
  */
916 916
 function getpaid_api() {
917
-    return getpaid()->get( 'api' );
917
+    return getpaid()->get('api');
918 918
 }
919 919
 
920 920
 /**
@@ -924,7 +924,7 @@  discard block
 block discarded – undo
924 924
  * @since 1.0.19
925 925
  */
926 926
 function getpaid_post_types() {
927
-    return getpaid()->get( 'post_types' );
927
+    return getpaid()->get('post_types');
928 928
 }
929 929
 
930 930
 /**
@@ -934,7 +934,7 @@  discard block
 block discarded – undo
934 934
  * @since 1.0.19
935 935
  */
936 936
 function getpaid_session() {
937
-    return getpaid()->get( 'session' );
937
+    return getpaid()->get('session');
938 938
 }
939 939
 
940 940
 /**
@@ -944,7 +944,7 @@  discard block
 block discarded – undo
944 944
  * @since 1.0.19
945 945
  */
946 946
 function getpaid_notes() {
947
-    return getpaid()->get( 'notes' );
947
+    return getpaid()->get('notes');
948 948
 }
949 949
 
950 950
 /**
@@ -953,7 +953,7 @@  discard block
 block discarded – undo
953 953
  * @return GetPaid_Admin
954 954
  */
955 955
 function getpaid_admin() {
956
-    return getpaid()->get( 'admin' );
956
+    return getpaid()->get('admin');
957 957
 }
958 958
 
959 959
 /**
@@ -963,8 +963,8 @@  discard block
 block discarded – undo
963 963
  * @param string $base the base url
964 964
  * @return string
965 965
  */
966
-function getpaid_get_authenticated_action_url( $action, $base = false ) {
967
-    return wp_nonce_url( add_query_arg( 'getpaid-action', $action, $base ), 'getpaid-nonce', 'getpaid-nonce' );
966
+function getpaid_get_authenticated_action_url($action, $base = false) {
967
+    return wp_nonce_url(add_query_arg('getpaid-action', $action, $base), 'getpaid-nonce', 'getpaid-nonce');
968 968
 }
969 969
 
970 970
 /**
@@ -972,11 +972,11 @@  discard block
 block discarded – undo
972 972
  *
973 973
  * @return string
974 974
  */
975
-function getpaid_get_post_type_label( $post_type, $plural = true ) {
975
+function getpaid_get_post_type_label($post_type, $plural = true) {
976 976
 
977
-    $post_type = get_post_type_object( $post_type );
977
+    $post_type = get_post_type_object($post_type);
978 978
 
979
-    if ( ! is_object( $post_type ) ) {
979
+    if (!is_object($post_type)) {
980 980
         return null;
981 981
     }
982 982
 
@@ -989,18 +989,18 @@  discard block
 block discarded – undo
989 989
  *
990 990
  * @return mixed|null
991 991
  */
992
-function getpaid_get_array_field( $array, $key, $secondary_key = null ) {
992
+function getpaid_get_array_field($array, $key, $secondary_key = null) {
993 993
 
994
-    if ( ! is_array( $array ) ) {
994
+    if (!is_array($array)) {
995 995
         return null;
996 996
     }
997 997
 
998
-    if ( ! empty( $secondary_key ) ) {
999
-        $array = isset( $array[ $secondary_key ] ) ? $array[ $secondary_key ] : array();
1000
-        return getpaid_get_array_field( $array, $key );
998
+    if (!empty($secondary_key)) {
999
+        $array = isset($array[$secondary_key]) ? $array[$secondary_key] : array();
1000
+        return getpaid_get_array_field($array, $key);
1001 1001
     }
1002 1002
 
1003
-    return isset( $array[ $key ] ) ? $array[ $key ] : null;
1003
+    return isset($array[$key]) ? $array[$key] : null;
1004 1004
 
1005 1005
 }
1006 1006
 
@@ -1009,12 +1009,12 @@  discard block
 block discarded – undo
1009 1009
  *
1010 1010
  * @return array
1011 1011
  */
1012
-function getpaid_array_merge_if_empty( $args, $defaults ) {
1012
+function getpaid_array_merge_if_empty($args, $defaults) {
1013 1013
 
1014
-    foreach ( $defaults as $key => $value ) {
1014
+    foreach ($defaults as $key => $value) {
1015 1015
 
1016
-        if ( array_key_exists( $key, $args ) && empty( $args[ $key ] ) ) {
1017
-            $args[ $key ] = $value;
1016
+        if (array_key_exists($key, $args) && empty($args[$key])) {
1017
+            $args[$key] = $value;
1018 1018
         }
1019 1019
 
1020 1020
     }
Please login to merge, or discard this patch.
includes/libraries/wpinv-euvat/class-wpinv-euvat.php 1 patch
Spacing   +521 added lines, -521 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 class WPInv_EUVat {
10 10
 
@@ -24,125 +24,125 @@  discard block
 block discarded – undo
24 24
     public function init() {
25 25
 
26 26
         // If this is an admin page...
27
-        if ( is_admin() ) {
27
+        if (is_admin()) {
28 28
 
29 29
             // Register our scripts.
30
-            add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
31
-            add_action( 'wpinv_settings_sections_taxes', array( $this, 'section_vat_settings' ) );
32
-            add_action( 'wpinv_settings_taxes', array( $this, 'vat_settings' ) );
33
-            add_filter( 'wpinv_settings_taxes-vat_sanitize', array( $this, 'sanitize_vat_settings' ) );
34
-            add_filter( 'wpinv_settings_taxes-vat_rates_sanitize', array( $this, 'sanitize_vat_rates' ) );
35
-            add_action( 'wp_ajax_wpinv_add_vat_class', array( $this, 'add_class' ) );
36
-            add_action( 'wp_ajax_nopriv_wpinv_add_vat_class', array( $this, 'add_class' ) );
37
-            add_action( 'wp_ajax_wpinv_delete_vat_class', array( $this, 'delete_class' ) );
38
-            add_action( 'wp_ajax_nopriv_wpinv_delete_vat_class', array( $this, 'delete_class' ) );
39
-            add_action( 'wp_ajax_wpinv_update_vat_rates', array( $this, 'update_eu_rates' ) );
40
-            add_action( 'wp_ajax_nopriv_wpinv_update_vat_rates', array( $this, 'update_eu_rates' ) );
30
+            add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'));
31
+            add_action('wpinv_settings_sections_taxes', array($this, 'section_vat_settings'));
32
+            add_action('wpinv_settings_taxes', array($this, 'vat_settings'));
33
+            add_filter('wpinv_settings_taxes-vat_sanitize', array($this, 'sanitize_vat_settings'));
34
+            add_filter('wpinv_settings_taxes-vat_rates_sanitize', array($this, 'sanitize_vat_rates'));
35
+            add_action('wp_ajax_wpinv_add_vat_class', array($this, 'add_class'));
36
+            add_action('wp_ajax_nopriv_wpinv_add_vat_class', array($this, 'add_class'));
37
+            add_action('wp_ajax_wpinv_delete_vat_class', array($this, 'delete_class'));
38
+            add_action('wp_ajax_nopriv_wpinv_delete_vat_class', array($this, 'delete_class'));
39
+            add_action('wp_ajax_wpinv_update_vat_rates', array($this, 'update_eu_rates'));
40
+            add_action('wp_ajax_nopriv_wpinv_update_vat_rates', array($this, 'update_eu_rates'));
41 41
         }
42 42
 
43
-        add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_vat_scripts' ) );
44
-        add_filter( 'wpinv_default_billing_country', array( $this, 'get_user_country' ), 10 );
45
-        add_filter( 'wpinv_get_user_country', array( $this, 'set_user_country' ), 10 );
46
-        add_action( 'wp_ajax_wpinv_vat_validate', array( $this, 'ajax_vat_validate' ) );
47
-        add_action( 'wp_ajax_nopriv_wpinv_vat_validate', array( $this, 'ajax_vat_validate' ) );
43
+        add_action('wp_enqueue_scripts', array($this, 'enqueue_vat_scripts'));
44
+        add_filter('wpinv_default_billing_country', array($this, 'get_user_country'), 10);
45
+        add_filter('wpinv_get_user_country', array($this, 'set_user_country'), 10);
46
+        add_action('wp_ajax_wpinv_vat_validate', array($this, 'ajax_vat_validate'));
47
+        add_action('wp_ajax_nopriv_wpinv_vat_validate', array($this, 'ajax_vat_validate'));
48 48
 
49
-        if ( wpinv_use_taxes() && self::allow_vat_rules() ) {
50
-            add_filter( 'wpinv_tax_rate', array( $this, 'get_rate' ), 10, 4 );
49
+        if (wpinv_use_taxes() && self::allow_vat_rules()) {
50
+            add_filter('wpinv_tax_rate', array($this, 'get_rate'), 10, 4);
51 51
         }
52 52
     }
53 53
 
54
-    public static function get_eu_states( $sort = true ) {
55
-        $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' );
56
-        if ( $sort ) {
57
-            $sort = sort( $eu_states );
54
+    public static function get_eu_states($sort = true) {
55
+        $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');
56
+        if ($sort) {
57
+            $sort = sort($eu_states);
58 58
         }
59 59
 
60
-        return apply_filters( 'wpinv_get_eu_states', $eu_states, $sort );
60
+        return apply_filters('wpinv_get_eu_states', $eu_states, $sort);
61 61
     }
62 62
 
63
-    public static function get_gst_countries( $sort = true ) {
64
-        $gst_countries  = array( 'AU', 'NZ', 'CA', 'CN' );
63
+    public static function get_gst_countries($sort = true) {
64
+        $gst_countries = array('AU', 'NZ', 'CA', 'CN');
65 65
 
66
-        if ( $sort ) {
67
-            $sort = sort( $gst_countries );
66
+        if ($sort) {
67
+            $sort = sort($gst_countries);
68 68
         }
69 69
 
70
-        return apply_filters( 'wpinv_get_gst_countries', $gst_countries, $sort );
70
+        return apply_filters('wpinv_get_gst_countries', $gst_countries, $sort);
71 71
     }
72 72
 
73
-    public static function is_eu_state( $country_code ) {
74
-        $return = !empty( $country_code ) && in_array( strtoupper( $country_code ), self::get_eu_states() ) ? true : false;
73
+    public static function is_eu_state($country_code) {
74
+        $return = !empty($country_code) && in_array(strtoupper($country_code), self::get_eu_states()) ? true : false;
75 75
 
76
-        return apply_filters( 'wpinv_is_eu_state', $return, $country_code );
76
+        return apply_filters('wpinv_is_eu_state', $return, $country_code);
77 77
     }
78 78
 
79
-    public static function is_gst_country( $country_code ) {
80
-        $return = !empty( $country_code ) && in_array( strtoupper( $country_code ), self::get_gst_countries() ) ? true : false;
79
+    public static function is_gst_country($country_code) {
80
+        $return = !empty($country_code) && in_array(strtoupper($country_code), self::get_gst_countries()) ? true : false;
81 81
 
82
-        return apply_filters( 'wpinv_is_gst_country', $return, $country_code );
82
+        return apply_filters('wpinv_is_gst_country', $return, $country_code);
83 83
     }
84 84
 
85 85
     public function enqueue_vat_scripts() {
86
-        if( wpinv_use_taxes() && wpinv_get_option( 'apply_vat_rules' ) ) {
86
+        if (wpinv_use_taxes() && wpinv_get_option('apply_vat_rules')) {
87 87
             $this->load_vat_scripts();
88 88
         }
89 89
     }
90 90
 
91
-    public function load_vat_scripts(){
92
-        $suffix     = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
91
+    public function load_vat_scripts() {
92
+        $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
93 93
 
94
-        wp_register_script( 'wpinv-vat-validation-script', WPINV_PLUGIN_URL . 'assets/js/jsvat' . $suffix . '.js', array( 'jquery' ),  WPINV_VERSION );
95
-        wp_register_script( 'wpinv-vat-script', WPINV_PLUGIN_URL . 'assets/js/euvat' . $suffix . '.js', array( 'jquery' ),  WPINV_VERSION );
94
+        wp_register_script('wpinv-vat-validation-script', WPINV_PLUGIN_URL . 'assets/js/jsvat' . $suffix . '.js', array('jquery'), WPINV_VERSION);
95
+        wp_register_script('wpinv-vat-script', WPINV_PLUGIN_URL . 'assets/js/euvat' . $suffix . '.js', array('jquery'), WPINV_VERSION);
96 96
 
97
-        $vat_name   = $this->get_vat_name();
97
+        $vat_name = $this->get_vat_name();
98 98
 
99 99
         $vars = array();
100 100
         $vars['UseTaxes'] = wpinv_use_taxes();
101 101
         $vars['EUStates'] = self::get_eu_states();
102
-        $vars['NoRateSet'] = __( 'You have not set a rate. Do you want to continue?', 'invoicing' );
103
-        $vars['EmptyCompany'] = __( 'Please enter your registered company name!', 'invoicing' );
104
-        $vars['EmptyVAT'] = wp_sprintf( __( 'Please enter your %s number!', 'invoicing' ), $vat_name );
105
-        $vars['TotalsRefreshed'] = wp_sprintf( __( 'The invoice totals will be refreshed to update the %s.', 'invoicing' ), $vat_name );
106
-        $vars['ErrValidateVAT'] = wp_sprintf( __( 'Fail to validate the %s number!', 'invoicing' ), $vat_name );
107
-        $vars['ErrResetVAT'] = wp_sprintf( __( 'Fail to reset the %s number!', 'invoicing' ), $vat_name );
108
-        $vars['ErrInvalidVat'] = wp_sprintf( __( 'The %s number supplied does not have a valid format!', 'invoicing' ), $vat_name );
109
-        $vars['ErrInvalidResponse'] = __( 'An invalid response has been received from the server!', 'invoicing' );
102
+        $vars['NoRateSet'] = __('You have not set a rate. Do you want to continue?', 'invoicing');
103
+        $vars['EmptyCompany'] = __('Please enter your registered company name!', 'invoicing');
104
+        $vars['EmptyVAT'] = wp_sprintf(__('Please enter your %s number!', 'invoicing'), $vat_name);
105
+        $vars['TotalsRefreshed'] = wp_sprintf(__('The invoice totals will be refreshed to update the %s.', 'invoicing'), $vat_name);
106
+        $vars['ErrValidateVAT'] = wp_sprintf(__('Fail to validate the %s number!', 'invoicing'), $vat_name);
107
+        $vars['ErrResetVAT'] = wp_sprintf(__('Fail to reset the %s number!', 'invoicing'), $vat_name);
108
+        $vars['ErrInvalidVat'] = wp_sprintf(__('The %s number supplied does not have a valid format!', 'invoicing'), $vat_name);
109
+        $vars['ErrInvalidResponse'] = __('An invalid response has been received from the server!', 'invoicing');
110 110
         $vars['ApplyVATRules'] = $vars['UseTaxes'] ? self::allow_vat_rules() : false;
111
-        $vars['ErrResponse'] = __( 'The request response is invalid!', 'invoicing' );
112
-        $vars['ErrRateResponse'] = __( 'The get rate request response is invalid', 'invoicing' );
113
-        $vars['PageRefresh'] = __( 'The page will be refreshed in 10 seconds to show the new options.', 'invoicing' );
114
-        $vars['RequestResponseNotValidJSON'] = __( 'The get rate request response is not valid JSON', 'invoicing' );
115
-        $vars['GetRateRequestFailed'] = __( 'The get rate request failed: ', 'invoicing' );
116
-        $vars['NoRateInformationInResponse'] = __( 'The get rate request response does not contain any rate information', 'invoicing' );
117
-        $vars['RatesUpdated'] = __( 'The rates have been updated. Press the save button to record these new rates.', 'invoicing' );
118
-        $vars['IPAddressInformation'] = __( 'IP Address Information', 'invoicing' );
119
-        $vars['VatValidating'] = wp_sprintf( __( 'Validating %s number...', 'invoicing' ), $vat_name );
120
-        $vars['VatReseting'] = __( 'Reseting...', 'invoicing' );
121
-        $vars['VatValidated'] = wp_sprintf( __( '%s number validated', 'invoicing' ), $vat_name );
122
-        $vars['VatNotValidated'] = wp_sprintf( __( '%s number not validated', 'invoicing' ), $vat_name );
123
-        $vars['ConfirmDeleteClass'] = __( 'Are you sure you wish to delete this rates class?', 'invoicing' );
111
+        $vars['ErrResponse'] = __('The request response is invalid!', 'invoicing');
112
+        $vars['ErrRateResponse'] = __('The get rate request response is invalid', 'invoicing');
113
+        $vars['PageRefresh'] = __('The page will be refreshed in 10 seconds to show the new options.', 'invoicing');
114
+        $vars['RequestResponseNotValidJSON'] = __('The get rate request response is not valid JSON', 'invoicing');
115
+        $vars['GetRateRequestFailed'] = __('The get rate request failed: ', 'invoicing');
116
+        $vars['NoRateInformationInResponse'] = __('The get rate request response does not contain any rate information', 'invoicing');
117
+        $vars['RatesUpdated'] = __('The rates have been updated. Press the save button to record these new rates.', 'invoicing');
118
+        $vars['IPAddressInformation'] = __('IP Address Information', 'invoicing');
119
+        $vars['VatValidating'] = wp_sprintf(__('Validating %s number...', 'invoicing'), $vat_name);
120
+        $vars['VatReseting'] = __('Reseting...', 'invoicing');
121
+        $vars['VatValidated'] = wp_sprintf(__('%s number validated', 'invoicing'), $vat_name);
122
+        $vars['VatNotValidated'] = wp_sprintf(__('%s number not validated', 'invoicing'), $vat_name);
123
+        $vars['ConfirmDeleteClass'] = __('Are you sure you wish to delete this rates class?', 'invoicing');
124 124
         $vars['isFront'] = is_admin() ? false : true;
125 125
         $vars['baseCountry'] = wpinv_get_default_country();
126
-        $vars['disableVATSameCountry'] = ( self::same_country_rule() == 'no' ? true : false );
127
-        $vars['disableVATSimpleCheck'] = wpinv_get_option( 'vat_offline_check' ) ? true : false;
126
+        $vars['disableVATSameCountry'] = (self::same_country_rule() == 'no' ? true : false);
127
+        $vars['disableVATSimpleCheck'] = wpinv_get_option('vat_offline_check') ? true : false;
128 128
 
129
-        wp_enqueue_script( 'wpinv-vat-validation-script' );
130
-        wp_enqueue_script( 'wpinv-vat-script' );
131
-        wp_localize_script( 'wpinv-vat-script', 'WPInv_VAT_Vars', $vars );
129
+        wp_enqueue_script('wpinv-vat-validation-script');
130
+        wp_enqueue_script('wpinv-vat-script');
131
+        wp_localize_script('wpinv-vat-script', 'WPInv_VAT_Vars', $vars);
132 132
     }
133 133
 
134 134
     public static function enqueue_admin_scripts() {
135
-        if( isset( $_GET['page'] ) && 'wpinv-settings' == $_GET['page'] ) {
135
+        if (isset($_GET['page']) && 'wpinv-settings' == $_GET['page']) {
136 136
             self::load_vat_scripts();
137 137
         }
138 138
     }
139 139
 
140
-    public static function section_vat_settings( $sections ) {
141
-        if ( !empty( $sections ) ) {
142
-            $sections['vat'] = __( 'EU VAT Settings', 'invoicing' );
140
+    public static function section_vat_settings($sections) {
141
+        if (!empty($sections)) {
142
+            $sections['vat'] = __('EU VAT Settings', 'invoicing');
143 143
 
144
-            if ( self::allow_vat_classes() ) {
145
-                $sections['vat_rates'] = __( 'EU VAT Rates', 'invoicing' );
144
+            if (self::allow_vat_classes()) {
145
+                $sections['vat_rates'] = __('EU VAT Rates', 'invoicing');
146 146
             }
147 147
         }
148 148
         return $sections;
@@ -151,52 +151,52 @@  discard block
 block discarded – undo
151 151
     public static function vat_rates_settings() {
152 152
         $vat_classes = self::get_rate_classes();
153 153
         $vat_rates = array();
154
-        $vat_class = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' && isset( $vat_classes[$_REQUEST['wpi_sub']] )? sanitize_text_field( $_REQUEST['wpi_sub'] ) : '_new';
155
-        $current_url = remove_query_arg( 'wpi_sub' );
154
+        $vat_class = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' && isset($vat_classes[$_REQUEST['wpi_sub']]) ? sanitize_text_field($_REQUEST['wpi_sub']) : '_new';
155
+        $current_url = remove_query_arg('wpi_sub');
156 156
 
157 157
         $vat_rates['vat_rates_header'] = array(
158 158
             'id' => 'vat_rates_header',
159
-            'name' => '<h3>' . __( 'Manage VAT Rates', 'invoicing' ) . '</h3>',
159
+            'name' => '<h3>' . __('Manage VAT Rates', 'invoicing') . '</h3>',
160 160
             'desc' => '',
161 161
             'type' => 'header',
162 162
             'size' => 'regular'
163 163
         );
164 164
         $vat_rates['vat_rates_class'] = array(
165 165
             'id'          => 'vat_rates_class',
166
-            'name'        => __( 'Edit VAT Rates', 'invoicing' ),
167
-            'desc'        => __( 'The standard rate will apply where no explicit rate is provided.', 'invoicing' ),
166
+            'name'        => __('Edit VAT Rates', 'invoicing'),
167
+            'desc'        => __('The standard rate will apply where no explicit rate is provided.', 'invoicing'),
168 168
             'type'        => 'select',
169
-            'options'     => array_merge( $vat_classes, array( '_new' => __( 'Add New Rate Class', 'invoicing' ) ) ),
170
-            'placeholder' => __( 'Select a VAT Rate', 'invoicing' ),
169
+            'options'     => array_merge($vat_classes, array('_new' => __('Add New Rate Class', 'invoicing'))),
170
+            'placeholder' => __('Select a VAT Rate', 'invoicing'),
171 171
             'selected'    => $vat_class,
172 172
             'class'       => 'wpi_select2',
173 173
             'onchange'    => 'document.location.href="' . $current_url . '&wpi_sub=" + this.value;',
174 174
         );
175 175
 
176
-        if ( $vat_class != '_standard' && $vat_class != '_new' ) {
176
+        if ($vat_class != '_standard' && $vat_class != '_new') {
177 177
             $vat_rates['vat_rate_delete'] = array(
178 178
                 'id'   => 'vat_rate_delete',
179 179
                 'type' => 'vat_rate_delete',
180 180
             );
181 181
         }
182 182
 
183
-        if ( $vat_class == '_new' ) {
183
+        if ($vat_class == '_new') {
184 184
             $vat_rates['vat_rates_settings'] = array(
185 185
                 'id' => 'vat_rates_settings',
186
-                'name' => '<h3>' . __( 'Add New Rate Class', 'invoicing' ) . '</h3>',
186
+                'name' => '<h3>' . __('Add New Rate Class', 'invoicing') . '</h3>',
187 187
                 'type' => 'header',
188 188
             );
189 189
             $vat_rates['vat_rate_name'] = array(
190 190
                 'id'   => 'vat_rate_name',
191
-                'name' => __( 'Name', 'invoicing' ),
192
-                'desc' => __( 'A short name for the new VAT Rate class', 'invoicing' ),
191
+                'name' => __('Name', 'invoicing'),
192
+                'desc' => __('A short name for the new VAT Rate class', 'invoicing'),
193 193
                 'type' => 'text',
194 194
                 'size' => 'regular',
195 195
             );
196 196
             $vat_rates['vat_rate_desc'] = array(
197 197
                 'id'   => 'vat_rate_desc',
198
-                'name' => __( 'Description', 'invoicing' ),
199
-                'desc' => __( 'Manage VAT Rate class', 'invoicing' ),
198
+                'name' => __('Description', 'invoicing'),
199
+                'desc' => __('Manage VAT Rate class', 'invoicing'),
200 200
                 'type' => 'text',
201 201
                 'size' => 'regular',
202 202
             );
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
             $vat_rates['vat_rates'] = array(
209 209
                 'id'   => 'vat_rates',
210 210
                 'name' => '<h3>' . $vat_classes[$vat_class] . '</h3>',
211
-                'desc' => self::get_class_desc( $vat_class ),
211
+                'desc' => self::get_class_desc($vat_class),
212 212
                 'type' => 'vat_rates',
213 213
             );
214 214
         }
@@ -216,12 +216,12 @@  discard block
 block discarded – undo
216 216
         return $vat_rates;
217 217
     }
218 218
 
219
-    public static function vat_settings( $settings ) {
220
-        if ( !empty( $settings ) ) {
219
+    public static function vat_settings($settings) {
220
+        if (!empty($settings)) {
221 221
             $vat_settings = array();
222 222
             $vat_settings['vat_company_title'] = array(
223 223
                 'id' => 'vat_company_title',
224
-                'name' => '<h3>' . __( 'Your Company Details', 'invoicing' ) . '</h3>',
224
+                'name' => '<h3>' . __('Your Company Details', 'invoicing') . '</h3>',
225 225
                 'desc' => '',
226 226
                 'type' => 'header',
227 227
                 'size' => 'regular'
@@ -229,22 +229,22 @@  discard block
 block discarded – undo
229 229
 
230 230
             $vat_settings['vat_company_name'] = array(
231 231
                 'id' => 'vat_company_name',
232
-                'name' => __( 'Your Company Name', 'invoicing' ),
233
-                'desc' => wp_sprintf(__( 'Your company name as it appears on your VAT return, you can verify it via your VAT ID on the %sEU VIES System.%s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ),
232
+                'name' => __('Your Company Name', 'invoicing'),
233
+                'desc' => wp_sprintf(__('Your company name as it appears on your VAT return, you can verify it via your VAT ID on the %sEU VIES System.%s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'),
234 234
                 'type' => 'text',
235 235
                 'size' => 'regular',
236 236
             );
237 237
 
238 238
             $vat_settings['vat_number'] = array(
239 239
                 'id'   => 'vat_number',
240
-                'name' => __( 'Your VAT Number', 'invoicing' ),
240
+                'name' => __('Your VAT Number', 'invoicing'),
241 241
                 'type' => 'vat_number',
242 242
                 'size' => 'regular',
243 243
             );
244 244
 
245 245
             $vat_settings['vat_settings_title'] = array(
246 246
                 'id' => 'vat_settings_title',
247
-                'name' => '<h3>' . __( 'Apply VAT Settings', 'invoicing' ) . '</h3>',
247
+                'name' => '<h3>' . __('Apply VAT Settings', 'invoicing') . '</h3>',
248 248
                 'desc' => '',
249 249
                 'type' => 'header',
250 250
                 'size' => 'regular'
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
 
253 253
             $vat_settings['apply_vat_rules'] = array(
254 254
                 'id' => 'apply_vat_rules',
255
-                'name' => __( 'Enable VAT Rules', 'invoicing' ),
256
-                'desc' => __( 'Apply VAT to consumer sales from IP addresses within the EU, even if the billing address is outside the EU.', 'invoicing' ) . '<br><font style="color:red">' . __( 'Do not disable unless you know what you are doing.', 'invoicing' ) . '</font>',
255
+                'name' => __('Enable VAT Rules', 'invoicing'),
256
+                'desc' => __('Apply VAT to consumer sales from IP addresses within the EU, even if the billing address is outside the EU.', 'invoicing') . '<br><font style="color:red">' . __('Do not disable unless you know what you are doing.', 'invoicing') . '</font>',
257 257
                 'type' => 'checkbox',
258 258
                 'std' => '1'
259 259
             );
@@ -269,8 +269,8 @@  discard block
 block discarded – undo
269 269
 
270 270
             $vat_settings['vat_prevent_b2c_purchase'] = array(
271 271
                 'id' => 'vat_prevent_b2c_purchase',
272
-                'name' => __( 'Prevent EU B2C Sales', 'invoicing' ),
273
-                'desc' => __( 'Enable this option if you are not registered for VAT in the EU.', 'invoicing' ),
272
+                'name' => __('Prevent EU B2C Sales', 'invoicing'),
273
+                'desc' => __('Enable this option if you are not registered for VAT in the EU.', 'invoicing'),
274 274
                 'type' => 'checkbox'
275 275
             );
276 276
 
@@ -278,22 +278,22 @@  discard block
 block discarded – undo
278 278
 
279 279
             $vat_settings['vat_same_country_rule'] = array(
280 280
                 'id'          => 'vat_same_country_rule',
281
-                'name'        => __( 'Same Country Rule', 'invoicing' ),
282
-                'desc'        => __( 'Select how you want to handle VAT charge if sales are in the same country as the base country.', 'invoicing' ),
281
+                'name'        => __('Same Country Rule', 'invoicing'),
282
+                'desc'        => __('Select how you want to handle VAT charge if sales are in the same country as the base country.', 'invoicing'),
283 283
                 'type'        => 'select',
284 284
                 'options'     => array(
285
-                    ''          => __( 'Normal', 'invoicing' ),
286
-                    'no'        => __( 'No VAT', 'invoicing' ),
287
-                    'always'    => __( 'Always apply VAT', 'invoicing' ),
285
+                    ''          => __('Normal', 'invoicing'),
286
+                    'no'        => __('No VAT', 'invoicing'),
287
+                    'always'    => __('Always apply VAT', 'invoicing'),
288 288
                 ),
289
-                'placeholder' => __( 'Select an option', 'invoicing' ),
289
+                'placeholder' => __('Select an option', 'invoicing'),
290 290
                 'std'         => '',
291 291
                 'class'   => 'wpi_select2',
292 292
             );
293 293
 
294 294
             $vat_settings['vat_checkout_title'] = array(
295 295
                 'id' => 'vat_checkout_title',
296
-                'name' => '<h3>' . __( 'Checkout Fields', 'invoicing' ) . '</h3>',
296
+                'name' => '<h3>' . __('Checkout Fields', 'invoicing') . '</h3>',
297 297
                 'desc' => '',
298 298
                 'type' => 'header',
299 299
                 'size' => 'regular'
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 
302 302
             $vat_settings['vies_validation_title'] = array(
303 303
                 'id' => 'vies_validation_title',
304
-                'name' => '<h3>' . __( 'VIES Validation', 'invoicing' ) . '</h3>',
304
+                'name' => '<h3>' . __('VIES Validation', 'invoicing') . '</h3>',
305 305
                 'desc' => '',
306 306
                 'type' => 'header',
307 307
                 'size' => 'regular'
@@ -309,37 +309,37 @@  discard block
 block discarded – undo
309 309
 
310 310
             $vat_settings['vat_vies_check'] = array(
311 311
                 'id' => 'vat_vies_check',
312
-                'name' => __( 'Disable VIES VAT ID Check', 'invoicing' ),
313
-                '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>' ),
312
+                'name' => __('Disable VIES VAT ID Check', 'invoicing'),
313
+                '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>'),
314 314
                 'type' => 'checkbox'
315 315
             );
316 316
 
317 317
             $vat_settings['vat_disable_company_name_check'] = array(
318 318
                 'id' => 'vat_disable_company_name_check',
319
-                'name' => __( 'Disable VIES Name Check', 'invoicing' ),
320
-                '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>' ),
319
+                'name' => __('Disable VIES Name Check', 'invoicing'),
320
+                '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>'),
321 321
                 'type' => 'checkbox'
322 322
             );
323 323
 
324 324
             $vat_settings['vat_offline_check'] = array(
325 325
                 'id' => 'vat_offline_check',
326
-                'name' => __( 'Disable Basic Checks', 'invoicing' ),
327
-                'desc' => __( 'Disable basic JS checks for correct format of VAT number. (Not Recommended)', 'invoicing' ),
326
+                'name' => __('Disable Basic Checks', 'invoicing'),
327
+                'desc' => __('Disable basic JS checks for correct format of VAT number. (Not Recommended)', 'invoicing'),
328 328
                 'type' => 'checkbox'
329 329
             );
330 330
 
331 331
 
332 332
             $settings['vat'] = $vat_settings;
333 333
 
334
-            if ( self::allow_vat_classes() ) {
334
+            if (self::allow_vat_classes()) {
335 335
                 $settings['vat_rates'] = self::vat_rates_settings();
336 336
             }
337 337
 
338 338
             $eu_fallback_rate = array(
339 339
                 'id'   => 'eu_fallback_rate',
340
-                'name' => '<h3>' . __( 'VAT rate for EU member states', 'invoicing' ) . '</h3>',
340
+                'name' => '<h3>' . __('VAT rate for EU member states', 'invoicing') . '</h3>',
341 341
                 'type' => 'eu_fallback_rate',
342
-                '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' ),
342
+                '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'),
343 343
                 'std'  => '20',
344 344
                 'size' => 'small'
345 345
             );
@@ -430,66 +430,66 @@  discard block
 block discarded – undo
430 430
         return getpaid_get_ip_country();
431 431
     }
432 432
 
433
-    public static function sanitize_vat_settings( $input ) {
433
+    public static function sanitize_vat_settings($input) {
434 434
         global $wpinv_options;
435 435
 
436 436
         $valid      = false;
437 437
         $message    = '';
438 438
 
439
-        if ( !empty( $wpinv_options['vat_vies_check'] ) ) {
440
-            if ( empty( $wpinv_options['vat_offline_check'] ) ) {
441
-                $valid = self::offline_check( $input['vat_number'] );
439
+        if (!empty($wpinv_options['vat_vies_check'])) {
440
+            if (empty($wpinv_options['vat_offline_check'])) {
441
+                $valid = self::offline_check($input['vat_number']);
442 442
             } else {
443 443
                 $valid = true;
444 444
             }
445 445
 
446
-            $message = $valid ? '' : __( 'VAT number not validated', 'invoicing' );
446
+            $message = $valid ? '' : __('VAT number not validated', 'invoicing');
447 447
         } else {
448
-            $result = self::check_vat( $input['vat_number'] );
448
+            $result = self::check_vat($input['vat_number']);
449 449
 
450
-            if ( empty( $result['valid'] ) ) {
450
+            if (empty($result['valid'])) {
451 451
                 $valid      = false;
452 452
                 $message    = $result['message'];
453 453
             } else {
454
-                $valid      = ( isset( $result['company'] ) && ( $result['company'] == '---' || ( strcasecmp( trim( $result['company'] ), trim( $input['vat_company_name'] ) ) == 0 ) ) ) || !empty( $wpinv_options['vat_disable_company_name_check'] );
455
-                $message    = $valid ? '' : __( 'The company name associated with the VAT number provided is not the same as the company name provided.', 'invoicing' );
454
+                $valid      = (isset($result['company']) && ($result['company'] == '---' || (strcasecmp(trim($result['company']), trim($input['vat_company_name'])) == 0))) || !empty($wpinv_options['vat_disable_company_name_check']);
455
+                $message    = $valid ? '' : __('The company name associated with the VAT number provided is not the same as the company name provided.', 'invoicing');
456 456
             }
457 457
         }
458 458
 
459
-        if ( $message && self::is_vat_validated() != $valid ) {
460
-            add_settings_error( 'wpinv-notices', '', $message, ( $valid ? 'updated' : 'error' ) );
459
+        if ($message && self::is_vat_validated() != $valid) {
460
+            add_settings_error('wpinv-notices', '', $message, ($valid ? 'updated' : 'error'));
461 461
         }
462 462
 
463 463
         $input['vat_valid'] = $valid;
464 464
         return $input;
465 465
     }
466 466
 
467
-    public static function sanitize_vat_rates( $input ) {
468
-        if( !wpinv_current_user_can_manage_invoicing() ) {
469
-            add_settings_error( 'wpinv-notices', '', __( 'Your account does not have permission to add rate classes.', 'invoicing' ), 'error' );
467
+    public static function sanitize_vat_rates($input) {
468
+        if (!wpinv_current_user_can_manage_invoicing()) {
469
+            add_settings_error('wpinv-notices', '', __('Your account does not have permission to add rate classes.', 'invoicing'), 'error');
470 470
             return $input;
471 471
         }
472 472
 
473 473
         $vat_classes = self::get_rate_classes();
474
-        $vat_class = !empty( $_REQUEST['wpi_vat_class'] ) && isset( $vat_classes[$_REQUEST['wpi_vat_class']] )? sanitize_text_field( $_REQUEST['wpi_vat_class'] ) : '';
474
+        $vat_class = !empty($_REQUEST['wpi_vat_class']) && isset($vat_classes[$_REQUEST['wpi_vat_class']]) ? sanitize_text_field($_REQUEST['wpi_vat_class']) : '';
475 475
 
476
-        if ( empty( $vat_class ) ) {
477
-            add_settings_error( 'wpinv-notices', '', __( 'No valid VAT rates class contained in the request to save rates.', 'invoicing' ), 'error' );
476
+        if (empty($vat_class)) {
477
+            add_settings_error('wpinv-notices', '', __('No valid VAT rates class contained in the request to save rates.', 'invoicing'), 'error');
478 478
 
479 479
             return $input;
480 480
         }
481 481
 
482
-        $new_rates = ! empty( $_POST['vat_rates'] ) ? array_values( $_POST['vat_rates'] ) : array();
482
+        $new_rates = !empty($_POST['vat_rates']) ? array_values($_POST['vat_rates']) : array();
483 483
 
484
-        if ( $vat_class === '_standard' ) {
484
+        if ($vat_class === '_standard') {
485 485
             // Save the active rates in the invoice settings
486
-            update_option( 'wpinv_tax_rates', $new_rates );
486
+            update_option('wpinv_tax_rates', $new_rates);
487 487
         } else {
488 488
             // Get the existing set of rates
489 489
             $rates = self::get_non_standard_rates();
490 490
             $rates[$vat_class] = $new_rates;
491 491
 
492
-            update_option( 'wpinv_vat_rates', $rates );
492
+            update_option('wpinv_vat_rates', $rates);
493 493
         }
494 494
 
495 495
         return $input;
@@ -499,71 +499,71 @@  discard block
 block discarded – undo
499 499
         $response = array();
500 500
         $response['success'] = false;
501 501
 
502
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
503
-            $response['error'] = __( 'Invalid access!', 'invoicing' );
504
-            wp_send_json( $response );
502
+        if (!wpinv_current_user_can_manage_invoicing()) {
503
+            $response['error'] = __('Invalid access!', 'invoicing');
504
+            wp_send_json($response);
505 505
         }
506 506
 
507
-        $vat_class_name = !empty( $_POST['name'] ) ? sanitize_text_field( $_POST['name'] ) : false;
508
-        $vat_class_desc = !empty( $_POST['desc'] ) ? sanitize_text_field( $_POST['desc'] ) : false;
507
+        $vat_class_name = !empty($_POST['name']) ? sanitize_text_field($_POST['name']) : false;
508
+        $vat_class_desc = !empty($_POST['desc']) ? sanitize_text_field($_POST['desc']) : false;
509 509
 
510
-        if ( empty( $vat_class_name ) ) {
511
-            $response['error'] = __( 'Select the VAT rate name', 'invoicing' );
512
-            wp_send_json( $response );
510
+        if (empty($vat_class_name)) {
511
+            $response['error'] = __('Select the VAT rate name', 'invoicing');
512
+            wp_send_json($response);
513 513
         }
514 514
 
515
-        $vat_classes = (array)self::get_rate_classes();
515
+        $vat_classes = (array) self::get_rate_classes();
516 516
 
517
-        if ( !empty( $vat_classes ) && in_array( strtolower( $vat_class_name ), array_map( 'strtolower', array_values( $vat_classes ) ) ) ) {
518
-            $response['error'] = wp_sprintf( __( 'A VAT Rate name "%s" already exists', 'invoicing' ), $vat_class_name );
519
-            wp_send_json( $response );
517
+        if (!empty($vat_classes) && in_array(strtolower($vat_class_name), array_map('strtolower', array_values($vat_classes)))) {
518
+            $response['error'] = wp_sprintf(__('A VAT Rate name "%s" already exists', 'invoicing'), $vat_class_name);
519
+            wp_send_json($response);
520 520
         }
521 521
 
522
-        $rate_class_key = normalize_whitespace( 'wpi-' . $vat_class_name );
523
-        $rate_class_key = sanitize_key( str_replace( " ", "-", $rate_class_key ) );
522
+        $rate_class_key = normalize_whitespace('wpi-' . $vat_class_name);
523
+        $rate_class_key = sanitize_key(str_replace(" ", "-", $rate_class_key));
524 524
 
525
-        $vat_classes = (array)self::get_rate_classes( true );
526
-        $vat_classes[$rate_class_key] = array( 'name' => $vat_class_name, 'desc' => $vat_class_desc );
525
+        $vat_classes = (array) self::get_rate_classes(true);
526
+        $vat_classes[$rate_class_key] = array('name' => $vat_class_name, 'desc' => $vat_class_desc);
527 527
 
528
-        update_option( '_wpinv_vat_rate_classes', $vat_classes );
528
+        update_option('_wpinv_vat_rate_classes', $vat_classes);
529 529
 
530 530
         $response['success'] = true;
531
-        $response['redirect'] = admin_url( 'admin.php?page=wpinv-settings&tab=taxes&section=vat_rates&wpi_sub=' . $rate_class_key );
531
+        $response['redirect'] = admin_url('admin.php?page=wpinv-settings&tab=taxes&section=vat_rates&wpi_sub=' . $rate_class_key);
532 532
 
533
-        wp_send_json( $response );
533
+        wp_send_json($response);
534 534
     }
535 535
 
536 536
     public static function delete_class() {
537 537
         $response = array();
538 538
         $response['success'] = false;
539 539
 
540
-        if ( !wpinv_current_user_can_manage_invoicing() || !isset( $_POST['class'] ) ) {
541
-            $response['error'] = __( 'Invalid access!', 'invoicing' );
542
-            wp_send_json( $response );
540
+        if (!wpinv_current_user_can_manage_invoicing() || !isset($_POST['class'])) {
541
+            $response['error'] = __('Invalid access!', 'invoicing');
542
+            wp_send_json($response);
543 543
         }
544 544
 
545
-        $vat_class = isset( $_POST['class'] ) && $_POST['class'] !== '' ? sanitize_text_field( $_POST['class'] ) : false;
546
-        $vat_classes = (array)self::get_rate_classes();
545
+        $vat_class = isset($_POST['class']) && $_POST['class'] !== '' ? sanitize_text_field($_POST['class']) : false;
546
+        $vat_classes = (array) self::get_rate_classes();
547 547
 
548
-        if ( !isset( $vat_classes[$vat_class] ) ) {
549
-            $response['error'] = __( 'Requested class does not exists', 'invoicing' );
550
-            wp_send_json( $response );
548
+        if (!isset($vat_classes[$vat_class])) {
549
+            $response['error'] = __('Requested class does not exists', 'invoicing');
550
+            wp_send_json($response);
551 551
         }
552 552
 
553
-        if ( $vat_class == '_new' || $vat_class == '_standard' ) {
554
-            $response['error'] = __( 'You can not delete standard rates class', 'invoicing' );
555
-            wp_send_json( $response );
553
+        if ($vat_class == '_new' || $vat_class == '_standard') {
554
+            $response['error'] = __('You can not delete standard rates class', 'invoicing');
555
+            wp_send_json($response);
556 556
         }
557 557
 
558
-        $vat_classes = (array)self::get_rate_classes( true );
559
-        unset( $vat_classes[$vat_class] );
558
+        $vat_classes = (array) self::get_rate_classes(true);
559
+        unset($vat_classes[$vat_class]);
560 560
 
561
-        update_option( '_wpinv_vat_rate_classes', $vat_classes );
561
+        update_option('_wpinv_vat_rate_classes', $vat_classes);
562 562
 
563 563
         $response['success'] = true;
564
-        $response['redirect'] = admin_url( 'admin.php?page=wpinv-settings&tab=taxes&section=vat_rates&wpi_sub=_new' );
564
+        $response['redirect'] = admin_url('admin.php?page=wpinv-settings&tab=taxes&section=vat_rates&wpi_sub=_new');
565 565
 
566
-        wp_send_json( $response );
566
+        wp_send_json($response);
567 567
     }
568 568
 
569 569
     public static function update_eu_rates() {
@@ -572,24 +572,24 @@  discard block
 block discarded – undo
572 572
         $response['error']      = null;
573 573
         $response['data']       = null;
574 574
 
575
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
576
-            $response['error'] = __( 'Invalid access!', 'invoicing' );
577
-            wp_send_json( $response );
575
+        if (!wpinv_current_user_can_manage_invoicing()) {
576
+            $response['error'] = __('Invalid access!', 'invoicing');
577
+            wp_send_json($response);
578 578
         }
579 579
 
580
-        $group      = !empty( $_POST['group'] ) ? sanitize_text_field( $_POST['group'] ) : '';
581
-        $euvatrates = self::request_euvatrates( $group );
580
+        $group      = !empty($_POST['group']) ? sanitize_text_field($_POST['group']) : '';
581
+        $euvatrates = self::request_euvatrates($group);
582 582
 
583
-        if ( !empty( $euvatrates ) ) {
584
-            if ( !empty( $euvatrates['success'] ) && !empty( $euvatrates['rates'] ) ) {
583
+        if (!empty($euvatrates)) {
584
+            if (!empty($euvatrates['success']) && !empty($euvatrates['rates'])) {
585 585
                 $response['success']        = true;
586 586
                 $response['data']['rates']  = $euvatrates['rates'];
587
-            } else if ( !empty( $euvatrates['error'] ) ) {
587
+            } else if (!empty($euvatrates['error'])) {
588 588
                 $response['error']          = $euvatrates['error'];
589 589
             }
590 590
         }
591 591
 
592
-        wp_send_json( $response );
592
+        wp_send_json($response);
593 593
     }
594 594
 
595 595
     /**
@@ -598,46 +598,46 @@  discard block
 block discarded – undo
598 598
     public static function hide_vat_fields() {}
599 599
 
600 600
     public static function same_country_rule() {
601
-        $same_country_rule = wpinv_get_option( 'vat_same_country_rule' );
601
+        $same_country_rule = wpinv_get_option('vat_same_country_rule');
602 602
 
603
-        return apply_filters( 'wpinv_vat_same_country_rule', $same_country_rule );
603
+        return apply_filters('wpinv_vat_same_country_rule', $same_country_rule);
604 604
     }
605 605
 
606 606
     /**
607 607
      * Retrieves the vat name.
608 608
      */
609 609
     public function get_vat_name() {
610
-        $vat_name = wpinv_get_option( 'vat_name' );
611
-        return empty( $vat_name ) ? __( 'VAT', 'invoicing' ) : sanitize_text_field( $vat_name );
610
+        $vat_name = wpinv_get_option('vat_name');
611
+        return empty($vat_name) ? __('VAT', 'invoicing') : sanitize_text_field($vat_name);
612 612
     }
613 613
 
614 614
     public static function get_company_name() {
615
-        $company_name = wpinv_get_option( 'vat_company_name' );
615
+        $company_name = wpinv_get_option('vat_company_name');
616 616
 
617
-        return apply_filters( 'wpinv_get_owner_company_name', $company_name );
617
+        return apply_filters('wpinv_get_owner_company_name', $company_name);
618 618
     }
619 619
 
620 620
     public static function get_vat_number() {
621
-        $vat_number = wpinv_get_option( 'vat_number' );
621
+        $vat_number = wpinv_get_option('vat_number');
622 622
 
623
-        return apply_filters( 'wpinv_get_owner_vat_number', $vat_number );
623
+        return apply_filters('wpinv_get_owner_vat_number', $vat_number);
624 624
     }
625 625
 
626 626
     public static function is_vat_validated() {
627
-        $validated = self::get_vat_number() && wpinv_get_option( 'vat_valid' );
627
+        $validated = self::get_vat_number() && wpinv_get_option('vat_valid');
628 628
 
629
-        return apply_filters( 'wpinv_is_owner_vat_validated', $validated );
629
+        return apply_filters('wpinv_is_owner_vat_validated', $validated);
630 630
     }
631 631
 
632
-    public static function sanitize_vat( $vat_number, $country_code = '' ) {
633
-        $vat_number = str_replace( array(' ', '.', '-', '_', ',' ), '', strtoupper( trim( $vat_number ) ) );
632
+    public static function sanitize_vat($vat_number, $country_code = '') {
633
+        $vat_number = str_replace(array(' ', '.', '-', '_', ','), '', strtoupper(trim($vat_number)));
634 634
 
635
-        if ( empty( $country_code ) ) {
636
-            $country_code = substr( $vat_number, 0, 2 );
635
+        if (empty($country_code)) {
636
+            $country_code = substr($vat_number, 0, 2);
637 637
         }
638 638
 
639
-        if ( strpos( $vat_number , $country_code ) === 0 ) {
640
-            $vat = str_replace( $country_code, '', $vat_number );
639
+        if (strpos($vat_number, $country_code) === 0) {
640
+            $vat = str_replace($country_code, '', $vat_number);
641 641
         } else {
642 642
             $vat = $country_code . $vat_number;
643 643
         }
@@ -650,140 +650,140 @@  discard block
 block discarded – undo
650 650
         return $return;
651 651
     }
652 652
 
653
-    public static function offline_check( $vat_number, $country_code = '', $formatted = false ) {
654
-        $vat            = self::sanitize_vat( $vat_number, $country_code );
653
+    public static function offline_check($vat_number, $country_code = '', $formatted = false) {
654
+        $vat            = self::sanitize_vat($vat_number, $country_code);
655 655
         $vat_number     = $vat['vat_number'];
656 656
         $country_code   = $vat['iso'];
657 657
         $regex          = array();
658 658
 
659
-        switch ( $country_code ) {
659
+        switch ($country_code) {
660 660
             case 'AT':
661
-                $regex[] = '/^(AT)U(\d{8})$/';                           // Austria
661
+                $regex[] = '/^(AT)U(\d{8})$/'; // Austria
662 662
                 break;
663 663
             case 'BE':
664
-                $regex[] = '/^(BE)(0?\d{9})$/';                          // Belgium
664
+                $regex[] = '/^(BE)(0?\d{9})$/'; // Belgium
665 665
                 break;
666 666
             case 'BG':
667
-                $regex[] = '/^(BG)(\d{9,10})$/';                         // Bulgaria
667
+                $regex[] = '/^(BG)(\d{9,10})$/'; // Bulgaria
668 668
                 break;
669 669
             case 'CH':
670 670
             case 'CHE':
671
-                $regex[] = '/^(CHE)(\d{9})MWST$/';                       // Switzerland (Not EU)
671
+                $regex[] = '/^(CHE)(\d{9})MWST$/'; // Switzerland (Not EU)
672 672
                 break;
673 673
             case 'CY':
674
-                $regex[] = '/^(CY)([0-5|9]\d{7}[A-Z])$/';                // Cyprus
674
+                $regex[] = '/^(CY)([0-5|9]\d{7}[A-Z])$/'; // Cyprus
675 675
                 break;
676 676
             case 'CZ':
677
-                $regex[] = '/^(CZ)(\d{8,13})$/';                         // Czech Republic
677
+                $regex[] = '/^(CZ)(\d{8,13})$/'; // Czech Republic
678 678
                 break;
679 679
             case 'DE':
680
-                $regex[] = '/^(DE)([1-9]\d{8})$/';                       // Germany
680
+                $regex[] = '/^(DE)([1-9]\d{8})$/'; // Germany
681 681
                 break;
682 682
             case 'DK':
683
-                $regex[] = '/^(DK)(\d{8})$/';                            // Denmark
683
+                $regex[] = '/^(DK)(\d{8})$/'; // Denmark
684 684
                 break;
685 685
             case 'EE':
686
-                $regex[] = '/^(EE)(10\d{7})$/';                          // Estonia
686
+                $regex[] = '/^(EE)(10\d{7})$/'; // Estonia
687 687
                 break;
688 688
             case 'EL':
689
-                $regex[] = '/^(EL)(\d{9})$/';                            // Greece
689
+                $regex[] = '/^(EL)(\d{9})$/'; // Greece
690 690
                 break;
691 691
             case 'ES':
692
-                $regex[] = '/^(ES)([A-Z]\d{8})$/';                       // Spain (National juridical entities)
693
-                $regex[] = '/^(ES)([A-H|N-S|W]\d{7}[A-J])$/';            // Spain (Other juridical entities)
694
-                $regex[] = '/^(ES)([0-9|Y|Z]\d{7}[A-Z])$/';              // Spain (Personal entities type 1)
695
-                $regex[] = '/^(ES)([K|L|M|X]\d{7}[A-Z])$/';              // Spain (Personal entities type 2)
692
+                $regex[] = '/^(ES)([A-Z]\d{8})$/'; // Spain (National juridical entities)
693
+                $regex[] = '/^(ES)([A-H|N-S|W]\d{7}[A-J])$/'; // Spain (Other juridical entities)
694
+                $regex[] = '/^(ES)([0-9|Y|Z]\d{7}[A-Z])$/'; // Spain (Personal entities type 1)
695
+                $regex[] = '/^(ES)([K|L|M|X]\d{7}[A-Z])$/'; // Spain (Personal entities type 2)
696 696
                 break;
697 697
             case 'EU':
698
-                $regex[] = '/^(EU)(\d{9})$/';                            // EU-type
698
+                $regex[] = '/^(EU)(\d{9})$/'; // EU-type
699 699
                 break;
700 700
             case 'FI':
701
-                $regex[] = '/^(FI)(\d{8})$/';                            // Finland
701
+                $regex[] = '/^(FI)(\d{8})$/'; // Finland
702 702
                 break;
703 703
             case 'FR':
704
-                $regex[] = '/^(FR)(\d{11})$/';                           // France (1)
705
-                $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)](\d{10})$/';        // France (2)
706
-                $regex[] = '/^(FR)\d[(A-H)|(J-N)|(P-Z)](\d{9})$/';       // France (3)
707
-                $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)]{2}(\d{9})$/';      // France (4)
704
+                $regex[] = '/^(FR)(\d{11})$/'; // France (1)
705
+                $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)](\d{10})$/'; // France (2)
706
+                $regex[] = '/^(FR)\d[(A-H)|(J-N)|(P-Z)](\d{9})$/'; // France (3)
707
+                $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)]{2}(\d{9})$/'; // France (4)
708 708
                 break;
709 709
             case 'GB':
710
-                $regex[] = '/^(GB)?(\d{9})$/';                           // UK (Standard)
711
-                $regex[] = '/^(GB)?(\d{12})$/';                          // UK (Branches)
712
-                $regex[] = '/^(GB)?(GD\d{3})$/';                         // UK (Government)
713
-                $regex[] = '/^(GB)?(HA\d{3})$/';                         // UK (Health authority)
710
+                $regex[] = '/^(GB)?(\d{9})$/'; // UK (Standard)
711
+                $regex[] = '/^(GB)?(\d{12})$/'; // UK (Branches)
712
+                $regex[] = '/^(GB)?(GD\d{3})$/'; // UK (Government)
713
+                $regex[] = '/^(GB)?(HA\d{3})$/'; // UK (Health authority)
714 714
                 break;
715 715
             case 'GR':
716
-                $regex[] = '/^(GR)(\d{8,9})$/';                          // Greece
716
+                $regex[] = '/^(GR)(\d{8,9})$/'; // Greece
717 717
                 break;
718 718
             case 'HR':
719
-                $regex[] = '/^(HR)(\d{11})$/';                           // Croatia
719
+                $regex[] = '/^(HR)(\d{11})$/'; // Croatia
720 720
                 break;
721 721
             case 'HU':
722
-                $regex[] = '/^(HU)(\d{8})$/';                            // Hungary
722
+                $regex[] = '/^(HU)(\d{8})$/'; // Hungary
723 723
                 break;
724 724
             case 'IE':
725
-                $regex[] = '/^(IE)(\d{7}[A-W])$/';                       // Ireland (1)
726
-                $regex[] = '/^(IE)([7-9][A-Z\*\+)]\d{5}[A-W])$/';        // Ireland (2)
727
-                $regex[] = '/^(IE)(\d{7}[A-Z][AH])$/';                   // Ireland (3) (new format from 1 Jan 2013)
725
+                $regex[] = '/^(IE)(\d{7}[A-W])$/'; // Ireland (1)
726
+                $regex[] = '/^(IE)([7-9][A-Z\*\+)]\d{5}[A-W])$/'; // Ireland (2)
727
+                $regex[] = '/^(IE)(\d{7}[A-Z][AH])$/'; // Ireland (3) (new format from 1 Jan 2013)
728 728
                 break;
729 729
             case 'IT':
730
-                $regex[] = '/^(IT)(\d{11})$/';                           // Italy
730
+                $regex[] = '/^(IT)(\d{11})$/'; // Italy
731 731
                 break;
732 732
             case 'LV':
733
-                $regex[] = '/^(LV)(\d{11})$/';                           // Latvia
733
+                $regex[] = '/^(LV)(\d{11})$/'; // Latvia
734 734
                 break;
735 735
             case 'LT':
736
-                $regex[] = '/^(LT)(\d{9}|\d{12})$/';                     // Lithuania
736
+                $regex[] = '/^(LT)(\d{9}|\d{12})$/'; // Lithuania
737 737
                 break;
738 738
             case 'LU':
739
-                $regex[] = '/^(LU)(\d{8})$/';                            // Luxembourg
739
+                $regex[] = '/^(LU)(\d{8})$/'; // Luxembourg
740 740
                 break;
741 741
             case 'MT':
742
-                $regex[] = '/^(MT)([1-9]\d{7})$/';                       // Malta
742
+                $regex[] = '/^(MT)([1-9]\d{7})$/'; // Malta
743 743
                 break;
744 744
             case 'NL':
745
-                $regex[] = '/^(NL)(\d{9})B\d{2}$/';                      // Netherlands
745
+                $regex[] = '/^(NL)(\d{9})B\d{2}$/'; // Netherlands
746 746
                 break;
747 747
             case 'NO':
748
-                $regex[] = '/^(NO)(\d{9})$/';                            // Norway (Not EU)
748
+                $regex[] = '/^(NO)(\d{9})$/'; // Norway (Not EU)
749 749
                 break;
750 750
             case 'PL':
751
-                $regex[] = '/^(PL)(\d{10})$/';                           // Poland
751
+                $regex[] = '/^(PL)(\d{10})$/'; // Poland
752 752
                 break;
753 753
             case 'PT':
754
-                $regex[] = '/^(PT)(\d{9})$/';                            // Portugal
754
+                $regex[] = '/^(PT)(\d{9})$/'; // Portugal
755 755
                 break;
756 756
             case 'RO':
757
-                $regex[] = '/^(RO)([1-9]\d{1,9})$/';                     // Romania
757
+                $regex[] = '/^(RO)([1-9]\d{1,9})$/'; // Romania
758 758
                 break;
759 759
             case 'RS':
760
-                $regex[] = '/^(RS)(\d{9})$/';                            // Serbia (Not EU)
760
+                $regex[] = '/^(RS)(\d{9})$/'; // Serbia (Not EU)
761 761
                 break;
762 762
             case 'SI':
763
-                $regex[] = '/^(SI)([1-9]\d{7})$/';                       // Slovenia
763
+                $regex[] = '/^(SI)([1-9]\d{7})$/'; // Slovenia
764 764
                 break;
765 765
             case 'SK':
766
-                $regex[] = '/^(SK)([1-9]\d[(2-4)|(6-9)]\d{7})$/';        // Slovakia Republic
766
+                $regex[] = '/^(SK)([1-9]\d[(2-4)|(6-9)]\d{7})$/'; // Slovakia Republic
767 767
                 break;
768 768
             case 'SE':
769
-                $regex[] = '/^(SE)(\d{10}01)$/';                         // Sweden
769
+                $regex[] = '/^(SE)(\d{10}01)$/'; // Sweden
770 770
                 break;
771 771
             default:
772 772
                 $regex = array();
773 773
             break;
774 774
         }
775 775
 
776
-        if ( empty( $regex ) ) {
776
+        if (empty($regex)) {
777 777
             return false;
778 778
         }
779 779
 
780
-        foreach ( $regex as $pattern ) {
780
+        foreach ($regex as $pattern) {
781 781
             $matches = null;
782
-            preg_match_all( $pattern, $vat_number, $matches );
782
+            preg_match_all($pattern, $vat_number, $matches);
783 783
 
784
-            if ( !empty( $matches[1][0] ) && !empty( $matches[2][0] ) ) {
785
-                if ( $formatted ) {
786
-                    return array( 'code' => $matches[1][0], 'number' => $matches[2][0] );
784
+            if (!empty($matches[1][0]) && !empty($matches[2][0])) {
785
+                if ($formatted) {
786
+                    return array('code' => $matches[1][0], 'number' => $matches[2][0]);
787 787
                 } else {
788 788
                     return true;
789 789
                 }
@@ -793,76 +793,76 @@  discard block
 block discarded – undo
793 793
         return false;
794 794
     }
795 795
 
796
-    public static function vies_check( $vat_number, $country_code = '', $result = false ) {
797
-        $vat            = self::sanitize_vat( $vat_number, $country_code );
796
+    public static function vies_check($vat_number, $country_code = '', $result = false) {
797
+        $vat            = self::sanitize_vat($vat_number, $country_code);
798 798
         $vat_number     = $vat['vat'];
799 799
         $iso            = $vat['iso'];
800 800
         $response       = false;
801 801
 
802
-        $url = 'http://ec.europa.eu/taxation_customs/vies/viesquer.do?ms=' . urlencode( $iso ) . '&iso=' . urlencode( $iso ) . '&vat=' . urlencode( $vat_number );
802
+        $url = 'http://ec.europa.eu/taxation_customs/vies/viesquer.do?ms=' . urlencode($iso) . '&iso=' . urlencode($iso) . '&vat=' . urlencode($vat_number);
803 803
 
804
-        if ( ini_get( 'allow_url_fopen' ) ) {
805
-            $response = file_get_contents( $url );
806
-        } else if ( function_exists( 'curl_init' ) ) {
804
+        if (ini_get('allow_url_fopen')) {
805
+            $response = file_get_contents($url);
806
+        } else if (function_exists('curl_init')) {
807 807
             $ch = curl_init();
808 808
 
809
-            curl_setopt( $ch, CURLOPT_URL, $url );
810
-            curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 30 );
811
-            curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
812
-            curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0 );
813
-            curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 );
809
+            curl_setopt($ch, CURLOPT_URL, $url);
810
+            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
811
+            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
812
+            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
813
+            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
814 814
 
815
-            $response = curl_exec( $ch );
815
+            $response = curl_exec($ch);
816 816
 
817
-            if ( curl_errno( $ch ) ) {
818
-                wpinv_error_log( curl_error( $ch ), 'VIES CHECK ERROR' );
817
+            if (curl_errno($ch)) {
818
+                wpinv_error_log(curl_error($ch), 'VIES CHECK ERROR');
819 819
                 $response = '';
820 820
             }
821 821
 
822
-            curl_close( $ch );
822
+            curl_close($ch);
823 823
         } else {
824
-            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' );
824
+            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');
825 825
         }
826 826
 
827
-        if ( empty( $response ) ) {
827
+        if (empty($response)) {
828 828
             return $result;
829 829
         }
830 830
 
831
-        if ( preg_match( '/invalid VAT number/i', $response ) ) {
831
+        if (preg_match('/invalid VAT number/i', $response)) {
832 832
             return false;
833
-        } else if ( preg_match( '/valid VAT number/i', $response, $matches ) ) {
834
-            $content = explode( "valid VAT number", htmlentities( $response ) );
833
+        } else if (preg_match('/valid VAT number/i', $response, $matches)) {
834
+            $content = explode("valid VAT number", htmlentities($response));
835 835
 
836
-            if ( !empty( $content[1] ) ) {
837
-                preg_match_all( '/<tr>(.*?)<td.*?>(.*?)<\/td>(.*?)<\/tr>/si', html_entity_decode( $content[1] ), $matches );
836
+            if (!empty($content[1])) {
837
+                preg_match_all('/<tr>(.*?)<td.*?>(.*?)<\/td>(.*?)<\/tr>/si', html_entity_decode($content[1]), $matches);
838 838
 
839
-                if ( !empty( $matches[2] ) && $matches[3] ) {
839
+                if (!empty($matches[2]) && $matches[3]) {
840 840
                     $return = array();
841 841
 
842
-                    foreach ( $matches[2] as $key => $label ) {
843
-                        $label = trim( $label );
842
+                    foreach ($matches[2] as $key => $label) {
843
+                        $label = trim($label);
844 844
 
845
-                        switch ( strtolower( $label ) ) {
845
+                        switch (strtolower($label)) {
846 846
                             case 'member state':
847
-                                $return['state'] = trim( strip_tags( $matches[3][$key] ) );
847
+                                $return['state'] = trim(strip_tags($matches[3][$key]));
848 848
                             break;
849 849
                             case 'vat number':
850
-                                $return['number'] = trim( strip_tags( $matches[3][$key] ) );
850
+                                $return['number'] = trim(strip_tags($matches[3][$key]));
851 851
                             break;
852 852
                             case 'name':
853
-                                $return['company'] = trim( strip_tags( $matches[3][$key] ) );
853
+                                $return['company'] = trim(strip_tags($matches[3][$key]));
854 854
                             break;
855 855
                             case 'address':
856
-                                $address           = str_replace( array( "<br><br>", "<br /><br />", "<br/><br/>" ), "<br>", html_entity_decode( trim( $matches[3][$key] ) ) );
857
-                                $return['address'] = trim( strip_tags( $address, '<br>' ) );
856
+                                $address           = str_replace(array("<br><br>", "<br /><br />", "<br/><br/>"), "<br>", html_entity_decode(trim($matches[3][$key])));
857
+                                $return['address'] = trim(strip_tags($address, '<br>'));
858 858
                             break;
859 859
                             case 'consultation number':
860
-                                $return['consultation'] = trim( strip_tags( $matches[3][$key] ) );
860
+                                $return['consultation'] = trim(strip_tags($matches[3][$key]));
861 861
                             break;
862 862
                         }
863 863
                     }
864 864
 
865
-                    if ( !empty( $return ) ) {
865
+                    if (!empty($return)) {
866 866
                         return $return;
867 867
                     }
868 868
                 }
@@ -874,62 +874,62 @@  discard block
 block discarded – undo
874 874
         }
875 875
     }
876 876
 
877
-    public static function check_vat( $vat_number, $country_code = '' ) {
877
+    public static function check_vat($vat_number, $country_code = '') {
878 878
         $vat_name           = getpaid_vat_name();
879 879
 
880 880
         $return             = array();
881 881
         $return['valid']    = false;
882
-        $return['message']  = wp_sprintf( __( '%s number not validated', 'invoicing' ), $vat_name );
882
+        $return['message']  = wp_sprintf(__('%s number not validated', 'invoicing'), $vat_name);
883 883
 
884
-        if ( !wpinv_get_option( 'vat_offline_check' ) && !self::offline_check( $vat_number, $country_code ) ) {
884
+        if (!wpinv_get_option('vat_offline_check') && !self::offline_check($vat_number, $country_code)) {
885 885
             return $return;
886 886
         }
887 887
 
888
-        $response = self::vies_check( $vat_number, $country_code );
888
+        $response = self::vies_check($vat_number, $country_code);
889 889
 
890
-        if ( $response ) {
891
-            $return['valid']    = true;
890
+        if ($response) {
891
+            $return['valid'] = true;
892 892
 
893
-            if ( is_array( $response ) ) {
894
-                $return['company'] = isset( $response['company'] ) ? $response['company'] : '';
895
-                $return['address'] = isset( $response['address'] ) ? $response['address'] : '';
893
+            if (is_array($response)) {
894
+                $return['company'] = isset($response['company']) ? $response['company'] : '';
895
+                $return['address'] = isset($response['address']) ? $response['address'] : '';
896 896
                 $return['message'] = $return['company'] . '<br/>' . $return['address'];
897 897
             }
898 898
         } else {
899 899
             $return['valid']    = false;
900
-            $return['message']  = wp_sprintf( __( 'Fail to validate the %s number: EU Commission VAT server (VIES) check fails.', 'invoicing' ), $vat_name );
900
+            $return['message']  = wp_sprintf(__('Fail to validate the %s number: EU Commission VAT server (VIES) check fails.', 'invoicing'), $vat_name);
901 901
         }
902 902
 
903 903
         return $return;
904 904
     }
905 905
 
906
-    public static function request_euvatrates( $group ) {
906
+    public static function request_euvatrates($group) {
907 907
         $response               = array();
908 908
         $response['success']    = false;
909 909
         $response['error']      = null;
910 910
         $response['eurates']    = null;
911 911
 
912 912
         $euvatrates_url = 'https://euvatrates.com/rates.json';
913
-        $euvatrates_url = apply_filters( 'wpinv_euvatrates_url', $euvatrates_url );
914
-        $api_response   = wp_remote_get( $euvatrates_url );
913
+        $euvatrates_url = apply_filters('wpinv_euvatrates_url', $euvatrates_url);
914
+        $api_response   = wp_remote_get($euvatrates_url);
915 915
 
916 916
         try {
917
-            if ( is_wp_error( $api_response ) ) {
918
-                $response['error']      = __( $api_response->get_error_message(), 'invoicing' );
917
+            if (is_wp_error($api_response)) {
918
+                $response['error'] = __($api_response->get_error_message(), 'invoicing');
919 919
             } else {
920
-                $body = json_decode( $api_response['body'] );
921
-                if ( isset( $body->rates ) ) {
920
+                $body = json_decode($api_response['body']);
921
+                if (isset($body->rates)) {
922 922
                     $rates = array();
923 923
 
924
-                    foreach ( $body->rates as $country_code => $rate ) {
924
+                    foreach ($body->rates as $country_code => $rate) {
925 925
                         $vat_rate = array();
926 926
                         $vat_rate['country']        = $rate->country;
927
-                        $vat_rate['standard']       = (float)$rate->standard_rate;
928
-                        $vat_rate['reduced']        = (float)$rate->reduced_rate;
929
-                        $vat_rate['superreduced']   = (float)$rate->super_reduced_rate;
930
-                        $vat_rate['parking']        = (float)$rate->parking_rate;
927
+                        $vat_rate['standard']       = (float) $rate->standard_rate;
928
+                        $vat_rate['reduced']        = (float) $rate->reduced_rate;
929
+                        $vat_rate['superreduced']   = (float) $rate->super_reduced_rate;
930
+                        $vat_rate['parking']        = (float) $rate->parking_rate;
931 931
 
932
-                        if ( $group !== '' && in_array( $group, array( 'standard', 'reduced', 'superreduced', 'parking' ) ) ) {
932
+                        if ($group !== '' && in_array($group, array('standard', 'reduced', 'superreduced', 'parking'))) {
933 933
                             $vat_rate_group = array();
934 934
                             $vat_rate_group['country'] = $rate->country;
935 935
                             $vat_rate_group[$group]    = $vat_rate[$group];
@@ -941,79 +941,79 @@  discard block
 block discarded – undo
941 941
                     }
942 942
 
943 943
                     $response['success']    = true;
944
-                    $response['rates']      = apply_filters( 'wpinv_process_euvatrates', $rates, $api_response, $group );
944
+                    $response['rates']      = apply_filters('wpinv_process_euvatrates', $rates, $api_response, $group);
945 945
                 } else {
946
-                    $response['error']      = __( 'No EU rates found!', 'invoicing' );
946
+                    $response['error']      = __('No EU rates found!', 'invoicing');
947 947
                 }
948 948
             }
949
-        } catch ( Exception $e ) {
950
-            $response['error'] = __( $e->getMessage(), 'invoicing' );
949
+        } catch (Exception $e) {
950
+            $response['error'] = __($e->getMessage(), 'invoicing');
951 951
         }
952 952
 
953
-        return apply_filters( 'wpinv_response_euvatrates', $response, $group );
953
+        return apply_filters('wpinv_response_euvatrates', $response, $group);
954 954
     }
955 955
 
956
-    public static function requires_vat( $requires_vat = false, $user_id = 0, $is_digital = null ) {
956
+    public static function requires_vat($requires_vat = false, $user_id = 0, $is_digital = null) {
957 957
         global $wpi_item_id, $wpi_country;
958 958
 
959
-        if ( !empty( $_POST['wpinv_country'] ) ) {
960
-            $country_code = trim( $_POST['wpinv_country'] );
961
-        } else if ( !empty( $_POST['country'] ) ) {
962
-            $country_code = trim( $_POST['country'] );
963
-        } else if ( !empty( $wpi_country ) ) {
959
+        if (!empty($_POST['wpinv_country'])) {
960
+            $country_code = trim($_POST['wpinv_country']);
961
+        } else if (!empty($_POST['country'])) {
962
+            $country_code = trim($_POST['country']);
963
+        } else if (!empty($wpi_country)) {
964 964
             $country_code = $wpi_country;
965 965
         } else {
966
-            $country_code = self::get_user_country( '', $user_id );
966
+            $country_code = self::get_user_country('', $user_id);
967 967
         }
968 968
 
969
-        if ( $is_digital === null && $wpi_item_id ) {
970
-            $is_digital = $wpi_item_id ? self::item_has_digital_rule( $wpi_item_id ) : self::allow_vat_rules();
969
+        if ($is_digital === null && $wpi_item_id) {
970
+            $is_digital = $wpi_item_id ? self::item_has_digital_rule($wpi_item_id) : self::allow_vat_rules();
971 971
         }
972 972
 
973
-        if ( !empty( $country_code ) ) {
974
-            $requires_vat = ( self::is_eu_state( $country_code ) && ( self::is_eu_state( wpinv_get_default_country() ) || $is_digital ) ) || ( self::is_gst_country( $country_code ) && self::is_gst_country( wpinv_get_default_country() ) );
973
+        if (!empty($country_code)) {
974
+            $requires_vat = (self::is_eu_state($country_code) && (self::is_eu_state(wpinv_get_default_country()) || $is_digital)) || (self::is_gst_country($country_code) && self::is_gst_country(wpinv_get_default_country()));
975 975
         }
976 976
 
977
-        return apply_filters( 'wpinv_requires_vat', $requires_vat, $user_id );
977
+        return apply_filters('wpinv_requires_vat', $requires_vat, $user_id);
978 978
     }
979 979
 
980
-    public static function tax_label( $label = '' ) {
980
+    public static function tax_label($label = '') {
981 981
         global $wpi_requires_vat;
982 982
 
983
-        if ( !( $wpi_requires_vat !== 0 && $wpi_requires_vat ) ) {
984
-            $wpi_requires_vat = self::requires_vat( 0, false );
983
+        if (!($wpi_requires_vat !== 0 && $wpi_requires_vat)) {
984
+            $wpi_requires_vat = self::requires_vat(0, false);
985 985
         }
986 986
 
987
-        return $wpi_requires_vat ? __( self::get_vat_name(), 'invoicing' ) : ( $label ? $label : __( 'Tax', 'invoicing' ) );
987
+        return $wpi_requires_vat ? __(self::get_vat_name(), 'invoicing') : ($label ? $label : __('Tax', 'invoicing'));
988 988
     }
989 989
 
990 990
     public static function standard_rates_label() {
991
-        return __( 'Standard Rates', 'invoicing' );
991
+        return __('Standard Rates', 'invoicing');
992 992
     }
993 993
 
994
-    public static function get_rate_classes( $with_desc = false ) {
995
-        $rate_classes_option = get_option( '_wpinv_vat_rate_classes', true );
996
-        $classes = maybe_unserialize( $rate_classes_option );
994
+    public static function get_rate_classes($with_desc = false) {
995
+        $rate_classes_option = get_option('_wpinv_vat_rate_classes', true);
996
+        $classes = maybe_unserialize($rate_classes_option);
997 997
 
998
-        if ( empty( $classes ) || !is_array( $classes ) ) {
998
+        if (empty($classes) || !is_array($classes)) {
999 999
             $classes = array();
1000 1000
         }
1001 1001
 
1002 1002
         $rate_classes = array();
1003
-        if ( !array_key_exists( '_standard', $classes ) ) {
1004
-            if ( $with_desc ) {
1005
-                $rate_classes['_standard'] = array( 'name' => self::standard_rates_label(), 'desc' => __( 'EU member states standard VAT rates', 'invoicing' ) );
1003
+        if (!array_key_exists('_standard', $classes)) {
1004
+            if ($with_desc) {
1005
+                $rate_classes['_standard'] = array('name' => self::standard_rates_label(), 'desc' => __('EU member states standard VAT rates', 'invoicing'));
1006 1006
             } else {
1007 1007
                 $rate_classes['_standard'] = self::standard_rates_label();
1008 1008
             }
1009 1009
         }
1010 1010
 
1011
-        foreach ( $classes as $key => $class ) {
1012
-            $name = !empty( $class['name'] ) ? __( $class['name'], 'invoicing' ) : $key;
1013
-            $desc = !empty( $class['desc'] ) ? __( $class['desc'], 'invoicing' ) : '';
1011
+        foreach ($classes as $key => $class) {
1012
+            $name = !empty($class['name']) ? __($class['name'], 'invoicing') : $key;
1013
+            $desc = !empty($class['desc']) ? __($class['desc'], 'invoicing') : '';
1014 1014
 
1015
-            if ( $with_desc ) {
1016
-                $rate_classes[$key] = array( 'name' => $name, 'desc' => $desc );
1015
+            if ($with_desc) {
1016
+                $rate_classes[$key] = array('name' => $name, 'desc' => $desc);
1017 1017
             } else {
1018 1018
                 $rate_classes[$key] = $name;
1019 1019
             }
@@ -1024,15 +1024,15 @@  discard block
 block discarded – undo
1024 1024
 
1025 1025
     public static function get_all_classes() {
1026 1026
         $classes            = self::get_rate_classes();
1027
-        $classes['_exempt'] = __( 'Exempt (0%)', 'invoicing' );
1027
+        $classes['_exempt'] = __('Exempt (0%)', 'invoicing');
1028 1028
 
1029
-        return apply_filters( 'wpinv_vat_get_all_classes', $classes );
1029
+        return apply_filters('wpinv_vat_get_all_classes', $classes);
1030 1030
     }
1031 1031
 
1032
-    public static function get_class_desc( $rate_class ) {
1033
-        $rate_classes = self::get_rate_classes( true );
1032
+    public static function get_class_desc($rate_class) {
1033
+        $rate_classes = self::get_rate_classes(true);
1034 1034
 
1035
-        if ( !empty( $rate_classes ) && isset( $rate_classes[$rate_class] ) && isset( $rate_classes[$rate_class]['desc'] ) ) {
1035
+        if (!empty($rate_classes) && isset($rate_classes[$rate_class]) && isset($rate_classes[$rate_class]['desc'])) {
1036 1036
             return $rate_classes[$rate_class]['desc'];
1037 1037
         }
1038 1038
 
@@ -1048,107 +1048,107 @@  discard block
 block discarded – undo
1048 1048
             'increased'     => 'Increased'
1049 1049
         );
1050 1050
 
1051
-        return apply_filters( 'wpinv_get_vat_groups', $vat_groups );
1051
+        return apply_filters('wpinv_get_vat_groups', $vat_groups);
1052 1052
     }
1053 1053
 
1054 1054
     public static function get_rules() {
1055 1055
         $vat_rules = array(
1056
-            'digital' => __( 'Digital Product', 'invoicing' ),
1057
-            'physical' => __( 'Physical Product', 'invoicing' ),
1058
-            '_exempt' => __( 'Tax-Free Product', 'invoicing' ),
1056
+            'digital' => __('Digital Product', 'invoicing'),
1057
+            'physical' => __('Physical Product', 'invoicing'),
1058
+            '_exempt' => __('Tax-Free Product', 'invoicing'),
1059 1059
         );
1060
-        return apply_filters( 'wpinv_get_vat_rules', $vat_rules );
1060
+        return apply_filters('wpinv_get_vat_rules', $vat_rules);
1061 1061
     }
1062 1062
 
1063
-    public static function get_vat_rates( $class ) {
1064
-        if ( $class === '_standard' ) {
1063
+    public static function get_vat_rates($class) {
1064
+        if ($class === '_standard') {
1065 1065
             return GetPaid_Tax::get_all_tax_rates();
1066 1066
         }
1067 1067
 
1068 1068
         $rates = self::get_non_standard_rates();
1069 1069
 
1070
-        return array_key_exists( $class, $rates ) ? $rates[$class] : array();
1070
+        return array_key_exists($class, $rates) ? $rates[$class] : array();
1071 1071
     }
1072 1072
 
1073 1073
     public static function get_non_standard_rates() {
1074
-        $option = get_option( 'wpinv_vat_rates', array());
1075
-        return is_array( $option ) ? $option : array();
1074
+        $option = get_option('wpinv_vat_rates', array());
1075
+        return is_array($option) ? $option : array();
1076 1076
     }
1077 1077
 
1078 1078
     public static function allow_vat_rules() {
1079
-        return ( wpinv_use_taxes() && wpinv_get_option( 'apply_vat_rules' ) ? true : false );
1079
+        return (wpinv_use_taxes() && wpinv_get_option('apply_vat_rules') ? true : false);
1080 1080
     }
1081 1081
 
1082 1082
     public static function allow_vat_classes() {
1083 1083
         return false; // TODO
1084
-        return ( wpinv_get_option( 'vat_allow_classes' ) ? true : false );
1084
+        return (wpinv_get_option('vat_allow_classes') ? true : false);
1085 1085
     }
1086 1086
 
1087
-    public static function get_item_class( $postID ) {
1088
-        $class = get_post_meta( $postID, '_wpinv_vat_class', true );
1087
+    public static function get_item_class($postID) {
1088
+        $class = get_post_meta($postID, '_wpinv_vat_class', true);
1089 1089
 
1090
-        if ( empty( $class ) ) {
1090
+        if (empty($class)) {
1091 1091
             $class = '_standard';
1092 1092
         }
1093 1093
 
1094
-        return apply_filters( 'wpinv_get_item_vat_class', $class, $postID );
1094
+        return apply_filters('wpinv_get_item_vat_class', $class, $postID);
1095 1095
     }
1096 1096
 
1097
-    public static function item_class_label( $postID ) {
1097
+    public static function item_class_label($postID) {
1098 1098
         $vat_classes = self::get_all_classes();
1099 1099
 
1100
-        $class = self::get_item_class( $postID );
1101
-        $class = isset( $vat_classes[$class] ) ? $vat_classes[$class] : __( $class, 'invoicing' );
1100
+        $class = self::get_item_class($postID);
1101
+        $class = isset($vat_classes[$class]) ? $vat_classes[$class] : __($class, 'invoicing');
1102 1102
 
1103
-        return apply_filters( 'wpinv_item_class_label', $class, $postID );
1103
+        return apply_filters('wpinv_item_class_label', $class, $postID);
1104 1104
     }
1105 1105
 
1106
-    public static function get_item_rule( $postID ) {
1107
-        $rule_type = get_post_meta( $postID, '_wpinv_vat_rule', true );
1106
+    public static function get_item_rule($postID) {
1107
+        $rule_type = get_post_meta($postID, '_wpinv_vat_rule', true);
1108 1108
 
1109
-        if ( empty( $rule_type ) ) {
1109
+        if (empty($rule_type)) {
1110 1110
             $rule_type = self::allow_vat_rules() ? 'digital' : 'physical';
1111 1111
         }
1112 1112
 
1113
-        return apply_filters( 'wpinv_item_get_vat_rule', $rule_type, $postID );
1113
+        return apply_filters('wpinv_item_get_vat_rule', $rule_type, $postID);
1114 1114
     }
1115 1115
 
1116
-    public static function item_rule_label( $postID ) {
1116
+    public static function item_rule_label($postID) {
1117 1117
         $vat_rules  = self::get_rules();
1118
-        $vat_rule   = self::get_item_rule( $postID );
1119
-        $vat_rule   = isset( $vat_rules[$vat_rule] ) ? $vat_rules[$vat_rule] : $vat_rule;
1118
+        $vat_rule   = self::get_item_rule($postID);
1119
+        $vat_rule   = isset($vat_rules[$vat_rule]) ? $vat_rules[$vat_rule] : $vat_rule;
1120 1120
 
1121
-        return apply_filters( 'wpinv_item_rule_label', $vat_rule, $postID );
1121
+        return apply_filters('wpinv_item_rule_label', $vat_rule, $postID);
1122 1122
     }
1123 1123
 
1124
-    public static function item_has_digital_rule( $item_id = 0 ) {
1125
-        return self::get_item_rule( $item_id ) == 'digital' ? true : false;
1124
+    public static function item_has_digital_rule($item_id = 0) {
1125
+        return self::get_item_rule($item_id) == 'digital' ? true : false;
1126 1126
     }
1127 1127
 
1128
-    public static function invoice_has_digital_rule( $invoice = 0 ) {
1129
-        if ( !self::allow_vat_rules() ) {
1128
+    public static function invoice_has_digital_rule($invoice = 0) {
1129
+        if (!self::allow_vat_rules()) {
1130 1130
             return false;
1131 1131
         }
1132 1132
 
1133
-        if ( empty( $invoice ) ) {
1133
+        if (empty($invoice)) {
1134 1134
             return true;
1135 1135
         }
1136 1136
 
1137
-        if ( is_int( $invoice ) ) {
1138
-            $invoice = new WPInv_Invoice( $invoice );
1137
+        if (is_int($invoice)) {
1138
+            $invoice = new WPInv_Invoice($invoice);
1139 1139
         }
1140 1140
 
1141
-        if ( !( is_object( $invoice ) && is_a( $invoice, 'WPInv_Invoice' ) ) ) {
1141
+        if (!(is_object($invoice) && is_a($invoice, 'WPInv_Invoice'))) {
1142 1142
             return true;
1143 1143
         }
1144 1144
 
1145
-        $cart_items  = $invoice->get_cart_details();
1145
+        $cart_items = $invoice->get_cart_details();
1146 1146
 
1147
-        if ( !empty( $cart_items ) ) {
1147
+        if (!empty($cart_items)) {
1148 1148
             $has_digital_rule = false;
1149 1149
 
1150
-            foreach ( $cart_items as $key => $item ) {
1151
-                if ( self::item_has_digital_rule( $item['id'] ) ) {
1150
+            foreach ($cart_items as $key => $item) {
1151
+                if (self::item_has_digital_rule($item['id'])) {
1152 1152
                     $has_digital_rule = true;
1153 1153
                     break;
1154 1154
                 }
@@ -1160,71 +1160,71 @@  discard block
 block discarded – undo
1160 1160
         return $has_digital_rule;
1161 1161
     }
1162 1162
 
1163
-    public static function item_is_taxable( $item_id = 0, $country = false, $state = false ) {
1164
-        if ( !wpinv_use_taxes() ) {
1163
+    public static function item_is_taxable($item_id = 0, $country = false, $state = false) {
1164
+        if (!wpinv_use_taxes()) {
1165 1165
             return false;
1166 1166
         }
1167 1167
 
1168 1168
         $is_taxable = true;
1169 1169
 
1170
-        if ( !empty( $item_id ) && self::get_item_class( $item_id ) == '_exempt' ) {
1170
+        if (!empty($item_id) && self::get_item_class($item_id) == '_exempt') {
1171 1171
             $is_taxable = false;
1172 1172
         }
1173 1173
 
1174
-        if ( !empty( $item_id ) && self::get_item_rule( $item_id ) == '_exempt' ) {
1174
+        if (!empty($item_id) && self::get_item_rule($item_id) == '_exempt') {
1175 1175
             $is_taxable = false;
1176 1176
         }
1177 1177
 
1178
-        return apply_filters( 'wpinv_item_is_taxable', $is_taxable, $item_id, $country , $state );
1178
+        return apply_filters('wpinv_item_is_taxable', $is_taxable, $item_id, $country, $state);
1179 1179
     }
1180 1180
 
1181
-    public static function find_rate( $country, $state, $rate, $class ) {
1181
+    public static function find_rate($country, $state, $rate, $class) {
1182 1182
         global $wpi_zero_tax;
1183 1183
 
1184
-        if ( $class === '_exempt' || $wpi_zero_tax ) {
1184
+        if ($class === '_exempt' || $wpi_zero_tax) {
1185 1185
             return 0;
1186 1186
         }
1187 1187
 
1188
-        $tax_rates   = GetPaid_Tax::get_all_tax_rates();
1188
+        $tax_rates = GetPaid_Tax::get_all_tax_rates();
1189 1189
 
1190
-        if ( $class !== '_standard' ) {
1191
-            $class_rates = self::get_vat_rates( $class );
1190
+        if ($class !== '_standard') {
1191
+            $class_rates = self::get_vat_rates($class);
1192 1192
 
1193
-            if ( is_array( $class_rates ) ) {
1193
+            if (is_array($class_rates)) {
1194 1194
                 $indexed_class_rates = array();
1195 1195
 
1196
-                foreach ( $class_rates as $key => $cr ) {
1196
+                foreach ($class_rates as $key => $cr) {
1197 1197
                     $indexed_class_rates[$cr['country']] = $cr;
1198 1198
                 }
1199 1199
 
1200
-                $tax_rates = array_map( function( $tr ) use( $indexed_class_rates ) {
1200
+                $tax_rates = array_map(function($tr) use($indexed_class_rates) {
1201 1201
                     $tr_country = $tr['country'];
1202
-                    if ( !isset( $indexed_class_rates[$tr_country] ) ) {
1202
+                    if (!isset($indexed_class_rates[$tr_country])) {
1203 1203
                         return $tr;
1204 1204
                     }
1205 1205
                     $icr = $indexed_class_rates[$tr_country];
1206
-                    return ( empty( $icr['rate'] ) && $icr['rate'] !== '0' ) ? $tr : $icr;
1206
+                    return (empty($icr['rate']) && $icr['rate'] !== '0') ? $tr : $icr;
1207 1207
 
1208
-                }, $tax_rates, $class_rates );
1208
+                }, $tax_rates, $class_rates);
1209 1209
             }
1210 1210
         }
1211 1211
 
1212
-        if ( !empty( $tax_rates ) ) {
1213
-            foreach ( $tax_rates as $key => $tax_rate ) {
1214
-                if ( $country != $tax_rate['country'] )
1212
+        if (!empty($tax_rates)) {
1213
+            foreach ($tax_rates as $key => $tax_rate) {
1214
+                if ($country != $tax_rate['country'])
1215 1215
                     continue;
1216 1216
 
1217
-                if ( !empty( $tax_rate['global'] ) ) {
1218
-                    if ( 0 !== $tax_rate['rate'] || !empty( $tax_rate['rate'] ) ) {
1219
-                        $rate = number_format( $tax_rate['rate'], 4 );
1217
+                if (!empty($tax_rate['global'])) {
1218
+                    if (0 !== $tax_rate['rate'] || !empty($tax_rate['rate'])) {
1219
+                        $rate = number_format($tax_rate['rate'], 4);
1220 1220
                     }
1221 1221
                 } else {
1222
-                    if ( empty( $tax_rate['state'] ) || strtolower( $state ) != strtolower( $tax_rate['state'] ) )
1222
+                    if (empty($tax_rate['state']) || strtolower($state) != strtolower($tax_rate['state']))
1223 1223
                         continue;
1224 1224
 
1225 1225
                     $state_rate = $tax_rate['rate'];
1226
-                    if ( 0 !== $state_rate || !empty( $state_rate ) ) {
1227
-                        $rate = number_format( $state_rate, 4 );
1226
+                    if (0 !== $state_rate || !empty($state_rate)) {
1227
+                        $rate = number_format($state_rate, 4);
1228 1228
                     }
1229 1229
                 }
1230 1230
             }
@@ -1233,84 +1233,84 @@  discard block
 block discarded – undo
1233 1233
         return $rate;
1234 1234
     }
1235 1235
 
1236
-    public static function get_rate( $rate = 1, $country = '', $state = '', $item_id = 0 ) {
1236
+    public static function get_rate($rate = 1, $country = '', $state = '', $item_id = 0) {
1237 1237
         global $wpinv_options, $wpi_item_id, $wpi_zero_tax;
1238 1238
 
1239 1239
         $item_id = $item_id > 0 ? $item_id : $wpi_item_id;
1240 1240
         $allow_vat_classes = self::allow_vat_classes();
1241
-        $class = $item_id ? self::get_item_class( $item_id ) : '_standard';
1241
+        $class = $item_id ? self::get_item_class($item_id) : '_standard';
1242 1242
 
1243
-        if ( $class === '_exempt' || $wpi_zero_tax ) {
1243
+        if ($class === '_exempt' || $wpi_zero_tax) {
1244 1244
             return 0;
1245
-        } else if ( !$allow_vat_classes ) {
1245
+        } else if (!$allow_vat_classes) {
1246 1246
             $class = '_standard';
1247 1247
         }
1248 1248
 
1249
-        if( !empty( $_POST['wpinv_country'] ) ) {
1249
+        if (!empty($_POST['wpinv_country'])) {
1250 1250
             $post_country = $_POST['wpinv_country'];
1251
-        } elseif( !empty( $_POST['wpinv_country'] ) ) {
1251
+        } elseif (!empty($_POST['wpinv_country'])) {
1252 1252
             $post_country = $_POST['wpinv_country'];
1253
-        } elseif( !empty( $_POST['country'] ) ) {
1253
+        } elseif (!empty($_POST['country'])) {
1254 1254
             $post_country = $_POST['country'];
1255 1255
         } else {
1256 1256
             $post_country = '';
1257 1257
         }
1258 1258
 
1259
-        $country        = !empty( $post_country ) ? $post_country : wpinv_default_billing_country( $country );
1260
-        $base_country   = wpinv_is_base_country( $country );
1259
+        $country        = !empty($post_country) ? $post_country : wpinv_default_billing_country($country);
1260
+        $base_country   = wpinv_is_base_country($country);
1261 1261
 
1262
-        $requires_vat   = self::requires_vat( 0, false );
1263
-        $is_digital     = self::get_item_rule( $item_id ) == 'digital' ;
1264
-        $rate           = $requires_vat && isset( $wpinv_options['eu_fallback_rate'] ) ? $wpinv_options['eu_fallback_rate'] : $rate;
1262
+        $requires_vat   = self::requires_vat(0, false);
1263
+        $is_digital     = self::get_item_rule($item_id) == 'digital';
1264
+        $rate           = $requires_vat && isset($wpinv_options['eu_fallback_rate']) ? $wpinv_options['eu_fallback_rate'] : $rate;
1265 1265
 
1266
-        if ( self::same_country_rule() == 'no' && $base_country ) { // Disable VAT to same country
1266
+        if (self::same_country_rule() == 'no' && $base_country) { // Disable VAT to same country
1267 1267
             $rate = 0;
1268
-        } else if ( $requires_vat ) {
1269
-            $vat_number = self::get_user_vat_number( '', 0, true );
1268
+        } else if ($requires_vat) {
1269
+            $vat_number = self::get_user_vat_number('', 0, true);
1270 1270
             $vat_info   = self::current_vat_data();
1271 1271
 
1272
-            if ( is_array( $vat_info ) ) {
1273
-                $vat_number = isset( $vat_info['number'] ) && !empty( $vat_info['valid'] ) ? $vat_info['number'] : "";
1272
+            if (is_array($vat_info)) {
1273
+                $vat_number = isset($vat_info['number']) && !empty($vat_info['valid']) ? $vat_info['number'] : "";
1274 1274
             }
1275 1275
 
1276
-            if ( $country == 'UK' ) {
1276
+            if ($country == 'UK') {
1277 1277
                 $country = 'GB';
1278 1278
             }
1279 1279
 
1280
-            if ( !empty( $vat_number ) ) {
1280
+            if (!empty($vat_number)) {
1281 1281
                 $rate = 0;
1282 1282
             } else {
1283
-                $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
1283
+                $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
1284 1284
             }
1285 1285
 
1286
-            if ( empty( $vat_number ) && !$is_digital ) {
1287
-                if ( $base_country ) {
1288
-                    $rate = self::find_rate( $country, null, $rate, $class );
1286
+            if (empty($vat_number) && !$is_digital) {
1287
+                if ($base_country) {
1288
+                    $rate = self::find_rate($country, null, $rate, $class);
1289 1289
                 } else {
1290
-                    if ( empty( $country ) && isset( $wpinv_options['eu_fallback_rate'] ) ) {
1290
+                    if (empty($country) && isset($wpinv_options['eu_fallback_rate'])) {
1291 1291
                         $rate = $wpinv_options['eu_fallback_rate'];
1292
-                    } else if( !empty( $country ) ) {
1293
-                        $rate = self::find_rate( $country, $state, $rate, $class );
1292
+                    } else if (!empty($country)) {
1293
+                        $rate = self::find_rate($country, $state, $rate, $class);
1294 1294
                     }
1295 1295
                 }
1296
-            } else if ( empty( $vat_number ) || ( self::same_country_rule() == 'always' && $base_country ) ) {
1297
-                if ( empty( $country ) && isset( $wpinv_options['eu_fallback_rate'] ) ) {
1296
+            } else if (empty($vat_number) || (self::same_country_rule() == 'always' && $base_country)) {
1297
+                if (empty($country) && isset($wpinv_options['eu_fallback_rate'])) {
1298 1298
                     $rate = $wpinv_options['eu_fallback_rate'];
1299
-                } else if( !empty( $country ) ) {
1300
-                    $rate = self::find_rate( $country, $state, $rate, $class );
1299
+                } else if (!empty($country)) {
1300
+                    $rate = self::find_rate($country, $state, $rate, $class);
1301 1301
                 }
1302 1302
             }
1303 1303
         } else {
1304
-            if ( $is_digital ) {
1304
+            if ($is_digital) {
1305 1305
                 $ip_country_code = getpaid_get_ip_country();
1306 1306
 
1307
-                if ( $ip_country_code && self::is_eu_state( $ip_country_code ) ) {
1308
-                    $rate = self::find_rate( $ip_country_code, '', 0, $class );
1307
+                if ($ip_country_code && self::is_eu_state($ip_country_code)) {
1308
+                    $rate = self::find_rate($ip_country_code, '', 0, $class);
1309 1309
                 } else {
1310
-                    $rate = self::find_rate( $country, $state, $rate, $class );
1310
+                    $rate = self::find_rate($country, $state, $rate, $class);
1311 1311
                 }
1312 1312
             } else {
1313
-                $rate = self::find_rate( $country, $state, $rate, $class );
1313
+                $rate = self::find_rate($country, $state, $rate, $class);
1314 1314
             }
1315 1315
         }
1316 1316
 
@@ -1318,44 +1318,44 @@  discard block
 block discarded – undo
1318 1318
     }
1319 1319
 
1320 1320
     public static function current_vat_data() {
1321
-        return getpaid_session()->get( 'user_vat_data' );
1321
+        return getpaid_session()->get('user_vat_data');
1322 1322
     }
1323 1323
 
1324
-    public static function get_user_country( $country = '', $user_id = 0 ) {
1325
-        $user_address = wpinv_get_user_address( $user_id, false );
1324
+    public static function get_user_country($country = '', $user_id = 0) {
1325
+        $user_address = wpinv_get_user_address($user_id, false);
1326 1326
 
1327
-        $country    = empty( $user_address ) || !isset( $user_address['country'] ) || empty( $user_address['country'] ) ? $country : $user_address['country'];
1328
-        $result     = apply_filters( 'wpinv_get_user_country', $country, $user_id );
1327
+        $country    = empty($user_address) || !isset($user_address['country']) || empty($user_address['country']) ? $country : $user_address['country'];
1328
+        $result     = apply_filters('wpinv_get_user_country', $country, $user_id);
1329 1329
 
1330
-        if ( empty( $result ) ) {
1330
+        if (empty($result)) {
1331 1331
             $result = getpaid_get_ip_country();
1332 1332
         }
1333 1333
 
1334 1334
         return $result;
1335 1335
     }
1336 1336
 
1337
-    public static function set_user_country( $country = '', $user_id = 0 ) {
1337
+    public static function set_user_country($country = '', $user_id = 0) {
1338 1338
         global $wpi_userID;
1339 1339
 
1340
-        if ( empty($country) && !empty($wpi_userID) && get_current_user_id() != $wpi_userID ) {
1340
+        if (empty($country) && !empty($wpi_userID) && get_current_user_id() != $wpi_userID) {
1341 1341
             $country = wpinv_get_default_country();
1342 1342
         }
1343 1343
 
1344 1344
         return $country;
1345 1345
     }
1346 1346
 
1347
-    public static function get_user_vat_number( $vat_number = '', $user_id = 0, $is_valid = false ) {
1347
+    public static function get_user_vat_number($vat_number = '', $user_id = 0, $is_valid = false) {
1348 1348
         global $wpi_current_id, $wpi_userID;
1349 1349
 
1350
-        if ( !empty( $_POST['new_user'] ) ) {
1350
+        if (!empty($_POST['new_user'])) {
1351 1351
             return '';
1352 1352
         }
1353 1353
 
1354
-        if ( empty( $user_id ) ) {
1355
-            $user_id = !empty( $wpi_userID ) ? $wpi_userID : ( $wpi_current_id ? wpinv_get_user_id( $wpi_current_id ) : get_current_user_id() );
1354
+        if (empty($user_id)) {
1355
+            $user_id = !empty($wpi_userID) ? $wpi_userID : ($wpi_current_id ? wpinv_get_user_id($wpi_current_id) : get_current_user_id());
1356 1356
         }
1357 1357
 
1358
-        $vat_number = empty( $user_id ) ? '' : get_user_meta( $user_id, '_wpinv_vat_number', true );
1358
+        $vat_number = empty($user_id) ? '' : get_user_meta($user_id, '_wpinv_vat_number', true);
1359 1359
 
1360 1360
         /* TODO
1361 1361
         if ( $is_valid && $vat_number ) {
@@ -1366,38 +1366,38 @@  discard block
 block discarded – undo
1366 1366
         }
1367 1367
         */
1368 1368
 
1369
-        return apply_filters('wpinv_get_user_vat_number', $vat_number, $user_id, $is_valid );
1369
+        return apply_filters('wpinv_get_user_vat_number', $vat_number, $user_id, $is_valid);
1370 1370
     }
1371 1371
 
1372
-    public static function get_user_company( $company = '', $user_id = 0 ) {
1372
+    public static function get_user_company($company = '', $user_id = 0) {
1373 1373
         global $wpi_current_id, $wpi_userID;
1374 1374
 
1375
-        if ( empty( $user_id ) ) {
1376
-            $user_id = !empty( $wpi_userID ) ? $wpi_userID : ( $wpi_current_id ? wpinv_get_user_id( $wpi_current_id ) : get_current_user_id() );
1375
+        if (empty($user_id)) {
1376
+            $user_id = !empty($wpi_userID) ? $wpi_userID : ($wpi_current_id ? wpinv_get_user_id($wpi_current_id) : get_current_user_id());
1377 1377
         }
1378 1378
 
1379
-        $company = empty( $user_id ) ? "" : get_user_meta( $user_id, '_wpinv_company', true );
1379
+        $company = empty($user_id) ? "" : get_user_meta($user_id, '_wpinv_company', true);
1380 1380
 
1381
-        return apply_filters( 'wpinv_user_company', $company, $user_id );
1381
+        return apply_filters('wpinv_user_company', $company, $user_id);
1382 1382
     }
1383 1383
 
1384
-    public static function save_user_vat_details( $company = '', $vat_number = '' ) {
1385
-        $save = apply_filters( 'wpinv_allow_save_user_vat_details', true );
1384
+    public static function save_user_vat_details($company = '', $vat_number = '') {
1385
+        $save = apply_filters('wpinv_allow_save_user_vat_details', true);
1386 1386
 
1387
-        if ( is_user_logged_in() && $save ) {
1387
+        if (is_user_logged_in() && $save) {
1388 1388
             $user_id = get_current_user_id();
1389 1389
 
1390
-            if ( !empty( $vat_number ) ) {
1391
-                update_user_meta( $user_id, '_wpinv_vat_number', $vat_number );
1390
+            if (!empty($vat_number)) {
1391
+                update_user_meta($user_id, '_wpinv_vat_number', $vat_number);
1392 1392
             } else {
1393
-                delete_user_meta( $user_id, '_wpinv_vat_number');
1393
+                delete_user_meta($user_id, '_wpinv_vat_number');
1394 1394
             }
1395 1395
 
1396
-            if ( !empty( $company ) ) {
1397
-                update_user_meta( $user_id, '_wpinv_company', $company );
1396
+            if (!empty($company)) {
1397
+                update_user_meta($user_id, '_wpinv_company', $company);
1398 1398
             } else {
1399
-                delete_user_meta( $user_id, '_wpinv_company');
1400
-                delete_user_meta( $user_id, '_wpinv_vat_number');
1399
+                delete_user_meta($user_id, '_wpinv_company');
1400
+                delete_user_meta($user_id, '_wpinv_vat_number');
1401 1401
             }
1402 1402
         }
1403 1403
 
@@ -1410,74 +1410,74 @@  discard block
 block discarded – undo
1410 1410
         $response               = array();
1411 1411
         $response['success']    = false;
1412 1412
 
1413
-        if ( empty( $_REQUEST['_wpi_nonce'] ) || ( !empty( $_REQUEST['_wpi_nonce'] ) && !wp_verify_nonce( $_REQUEST['_wpi_nonce'], 'vat_validation' ) ) ) {
1414
-            $response['error'] = __( 'Invalid security nonce', 'invoicing' );
1415
-            wp_send_json( $response );
1413
+        if (empty($_REQUEST['_wpi_nonce']) || (!empty($_REQUEST['_wpi_nonce']) && !wp_verify_nonce($_REQUEST['_wpi_nonce'], 'vat_validation'))) {
1414
+            $response['error'] = __('Invalid security nonce', 'invoicing');
1415
+            wp_send_json($response);
1416 1416
         }
1417 1417
 
1418 1418
         $vat_name   = self::get_vat_name();
1419 1419
 
1420
-        $company    = !empty( $_POST['company'] ) ? sanitize_text_field( $_POST['company'] ) : '';
1421
-        $vat_number = !empty( $_POST['number'] ) ? sanitize_text_field( $_POST['number'] ) : '';
1420
+        $company    = !empty($_POST['company']) ? sanitize_text_field($_POST['company']) : '';
1421
+        $vat_number = !empty($_POST['number']) ? sanitize_text_field($_POST['number']) : '';
1422 1422
 
1423
-        $vat_info = getpaid_session()->get( 'user_vat_data' );
1424
-        if ( !is_array( $vat_info ) || empty( $vat_info ) ) {
1425
-            $vat_info = array( 'company'=> $company, 'number' => '', 'valid' => true );
1423
+        $vat_info = getpaid_session()->get('user_vat_data');
1424
+        if (!is_array($vat_info) || empty($vat_info)) {
1425
+            $vat_info = array('company'=> $company, 'number' => '', 'valid' => true);
1426 1426
         }
1427 1427
 
1428
-        if ( empty( $vat_number ) ) {
1429
-            $response['error'] = wp_sprintf( __( 'Please enter your %s number!', 'invoicing' ), $vat_name );
1428
+        if (empty($vat_number)) {
1429
+            $response['error'] = wp_sprintf(__('Please enter your %s number!', 'invoicing'), $vat_name);
1430 1430
             $vat_info['valid'] = false;
1431
-            getpaid_session()->set( 'user_vat_data', $vat_info );
1432
-            wp_send_json( $response );
1431
+            getpaid_session()->set('user_vat_data', $vat_info);
1432
+            wp_send_json($response);
1433 1433
         }
1434 1434
 
1435
-        if ( empty( $company ) ) {
1435
+        if (empty($company)) {
1436 1436
             $vat_info['valid'] = false;
1437
-            getpaid_session()->set( 'user_vat_data', $vat_info );
1437
+            getpaid_session()->set('user_vat_data', $vat_info);
1438 1438
 
1439
-            $response['error'] = __( 'Please enter your registered company name!', 'invoicing' );
1440
-            wp_send_json( $response );
1439
+            $response['error'] = __('Please enter your registered company name!', 'invoicing');
1440
+            wp_send_json($response);
1441 1441
         }
1442 1442
 
1443
-        if ( !empty( $wpinv_options['vat_vies_check'] ) ) {
1444
-            if ( empty( $wpinv_options['vat_offline_check'] ) && !self::offline_check( $vat_number ) ) {
1443
+        if (!empty($wpinv_options['vat_vies_check'])) {
1444
+            if (empty($wpinv_options['vat_offline_check']) && !self::offline_check($vat_number)) {
1445 1445
                 $vat_info['valid'] = false;
1446
-                getpaid_session()->set( 'user_vat_data', $vat_info );
1446
+                getpaid_session()->set('user_vat_data', $vat_info);
1447 1447
 
1448
-                $response['error'] = wp_sprintf( __( '%s number not validated', 'invoicing' ), $vat_name );
1449
-                wp_send_json( $response );
1448
+                $response['error'] = wp_sprintf(__('%s number not validated', 'invoicing'), $vat_name);
1449
+                wp_send_json($response);
1450 1450
             }
1451 1451
 
1452 1452
             $response['success'] = true;
1453
-            $response['message'] = wp_sprintf( __( '%s number validated', 'invoicing' ), $vat_name );
1453
+            $response['message'] = wp_sprintf(__('%s number validated', 'invoicing'), $vat_name);
1454 1454
         } else {
1455
-            $result = self::check_vat( $vat_number );
1455
+            $result = self::check_vat($vat_number);
1456 1456
 
1457
-            if ( empty( $result['valid'] ) ) {
1457
+            if (empty($result['valid'])) {
1458 1458
                 $response['error'] = $result['message'];
1459
-                wp_send_json( $response );
1459
+                wp_send_json($response);
1460 1460
             }
1461 1461
 
1462
-            $vies_company = !empty( $result['company'] ) ? $result['company'] : '';
1463
-            $vies_company = apply_filters( 'wpinv_vies_company_name', $vies_company );
1462
+            $vies_company = !empty($result['company']) ? $result['company'] : '';
1463
+            $vies_company = apply_filters('wpinv_vies_company_name', $vies_company);
1464 1464
 
1465
-            $valid_company = $vies_company && $company && ( $vies_company == '---' || strcasecmp( trim( $vies_company ), trim( $company ) ) == 0 ) ? true : false;
1465
+            $valid_company = $vies_company && $company && ($vies_company == '---' || strcasecmp(trim($vies_company), trim($company)) == 0) ? true : false;
1466 1466
 
1467
-            if ( !empty( $wpinv_options['vat_disable_company_name_check'] ) || $valid_company ) {
1467
+            if (!empty($wpinv_options['vat_disable_company_name_check']) || $valid_company) {
1468 1468
                 $response['success'] = true;
1469
-                $response['message'] = wp_sprintf( __( '%s number validated', 'invoicing' ), $vat_name );
1469
+                $response['message'] = wp_sprintf(__('%s number validated', 'invoicing'), $vat_name);
1470 1470
             } else {
1471 1471
                 $vat_info['valid'] = false;
1472
-                getpaid_session()->set( 'user_vat_data', $vat_info );
1472
+                getpaid_session()->set('user_vat_data', $vat_info);
1473 1473
 
1474 1474
                 $response['success'] = false;
1475
-                $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 );
1476
-                wp_send_json( $response );
1475
+                $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);
1476
+                wp_send_json($response);
1477 1477
             }
1478 1478
         }
1479 1479
 
1480
-        wp_send_json( $response );
1480
+        wp_send_json($response);
1481 1481
     }
1482 1482
 
1483 1483
     /**
@@ -1485,16 +1485,16 @@  discard block
 block discarded – undo
1485 1485
      * 
1486 1486
      * @return string
1487 1487
      */
1488
-    public static function validate_vat_number( $vat_number, $company, $country ) {
1488
+    public static function validate_vat_number($vat_number, $company, $country) {
1489 1489
         global $wpinv_options;
1490 1490
 
1491 1491
         // If we are not checking the vat number via view...
1492
-        if ( ! empty( $wpinv_options['vat_vies_check'] ) ) {
1492
+        if (!empty($wpinv_options['vat_vies_check'])) {
1493 1493
 
1494 1494
             // Try validating via regex.
1495
-            if ( empty( $wpinv_options['vat_offline_check'] ) && ! self::offline_check( $vat_number, $country ) ) {
1495
+            if (empty($wpinv_options['vat_offline_check']) && !self::offline_check($vat_number, $country)) {
1496 1496
                 return wp_sprintf(
1497
-                    __( 'Your %s number is invalid', 'invoicing' ),
1497
+                    __('Your %s number is invalid', 'invoicing'),
1498 1498
                     getpaid_vat_name()
1499 1499
                 );
1500 1500
             }
@@ -1503,23 +1503,23 @@  discard block
 block discarded – undo
1503 1503
         }
1504 1504
 
1505 1505
         // Validate the vat number.
1506
-        $result = self::check_vat( $vat_number, $country );
1506
+        $result = self::check_vat($vat_number, $country);
1507 1507
 
1508
-        if ( empty( $result['valid'] ) ) {
1508
+        if (empty($result['valid'])) {
1509 1509
             return wp_sprintf(
1510
-                __( 'Failed to validate the %s number via EU Commission VAT server (VIES).', 'invoicing' ),
1510
+                __('Failed to validate the %s number via EU Commission VAT server (VIES).', 'invoicing'),
1511 1511
                 getpaid_vat_name()
1512 1512
             );
1513 1513
         }
1514 1514
 
1515 1515
         // Validate the company.
1516
-        $vies_company  = ! empty( $result['company'] ) ? $result['company'] : '';
1517
-        $vies_company  = apply_filters( 'wpinv_vies_company_name', $vies_company );
1518
-        $valid_company = $vies_company && $company && ( $vies_company == '---' || strcasecmp( trim( $vies_company ), trim( $company ) ) == 0 ) ? true : false;
1516
+        $vies_company  = !empty($result['company']) ? $result['company'] : '';
1517
+        $vies_company  = apply_filters('wpinv_vies_company_name', $vies_company);
1518
+        $valid_company = $vies_company && $company && ($vies_company == '---' || strcasecmp(trim($vies_company), trim($company)) == 0) ? true : false;
1519 1519
 
1520
-        if ( ! $valid_company && ! empty( $wpinv_options['vat_disable_company_name_check'] ) ) {
1520
+        if (!$valid_company && !empty($wpinv_options['vat_disable_company_name_check'])) {
1521 1521
            return wp_sprintf(
1522
-                __( 'The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing' ),
1522
+                __('The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing'),
1523 1523
                 getpaid_vat_name()
1524 1524
             );
1525 1525
         }
Please login to merge, or discard this patch.