Passed
Push — master ( e33f3a...6fa934 )
by Stiofan
04:49
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/wpinv-tax-functions.php 3 patches
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.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -215,16 +215,16 @@  discard block
 block discarded – undo
215 215
 function getpaid_prepare_item_tax( $item, $tax_name, $tax_amount, $recurring_tax_amount ) {
216 216
 
217 217
     $initial_tax   = $tax_amount;
218
-	$recurring_tax = 0;
218
+    $recurring_tax = 0;
219 219
 
220 220
     if ( $item->is_recurring() ) {
221
-		$recurring_tax = $recurring_tax_amount;
222
-	}
221
+        $recurring_tax = $recurring_tax_amount;
222
+    }
223 223
 
224
-	return array(
225
-		'name'          => sanitize_text_field( $tax_name ),
226
-		'initial_tax'   => $initial_tax,
227
-		'recurring_tax' => $recurring_tax,
224
+    return array(
225
+        'name'          => sanitize_text_field( $tax_name ),
226
+        'initial_tax'   => $initial_tax,
227
+        'recurring_tax' => $recurring_tax,
228 228
     );
229 229
 
230 230
 }
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
  */
329 329
 function wpinv_should_validate_vat_number() {
330 330
     $validate = wpinv_get_option( 'validate_vat_number' );
331
-	return ! empty( $validate );
331
+    return ! empty( $validate );
332 332
 }
333 333
 
334 334
 function wpinv_sales_tax_for_year( $year = null ) {
Please login to merge, or discard this patch.
Spacing   +118 added lines, -118 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 an array of eu states.
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  * @return array
13 13
  */
14 14
 function getpaid_get_eu_states() {
15
-    return wpinv_get_data( 'eu-states' );
15
+    return wpinv_get_data('eu-states');
16 16
 }
17 17
 
18 18
 /**
@@ -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 ! empty( $country ) && in_array( strtoupper( $country ), getpaid_get_eu_states() ) ? true : false;
23
+function getpaid_is_eu_state($country) {
24
+    return !empty($country) && in_array(strtoupper($country), getpaid_get_eu_states()) ? true : false;
25 25
 }
26 26
 
27 27
 /**
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
  * @return array
31 31
  */
32 32
 function getpaid_get_gst_states() {
33
-    return array( 'AU', 'NZ', 'CA', 'CN' );
33
+    return array('AU', 'NZ', 'CA', 'CN');
34 34
 }
35 35
 
36 36
 /**
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
  * 
39 39
  * @return bool
40 40
  */
41
-function getpaid_is_gst_country( $country ) {
42
-    return ! empty( $country ) && in_array( strtoupper( $country ), getpaid_get_gst_states() ) ? true : false;
41
+function getpaid_is_gst_country($country) {
42
+    return !empty($country) && in_array(strtoupper($country), getpaid_get_gst_states()) ? true : false;
43 43
 }
44 44
 
45 45
 /**
@@ -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,11 +70,11 @@  discard block
 block discarded – undo
70 70
  * @param string $country
71 71
  * @return bool
72 72
  */
73
-function wpinv_is_country_taxable( $country ) {
74
-    $is_eu     = getpaid_is_eu_state( $country );
75
-    $is_exempt = $is_eu && $country == wpinv_is_base_country( $country ) && wpinv_same_country_exempt_vat();
73
+function wpinv_is_country_taxable($country) {
74
+    $is_eu     = getpaid_is_eu_state($country);
75
+    $is_exempt = $is_eu && $country == wpinv_is_base_country($country) && wpinv_same_country_exempt_vat();
76 76
 
77
-    return (bool) apply_filters( 'wpinv_is_country_taxable', ! $is_exempt, $country ); 
77
+    return (bool) apply_filters('wpinv_is_country_taxable', !$is_exempt, $country); 
78 78
 
79 79
 }
80 80
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
  * @param WPInv_Item|GetPaid_Form_Item $item
85 85
  * @return bool
86 86
  */
87
-function wpinv_is_item_taxable( $item ) {
87
+function wpinv_is_item_taxable($item) {
88 88
     return '_exempt' != $item->get_vat_rule();
89 89
 }
90 90
 
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
  * @return bool
95 95
  */
96 96
 function wpinv_use_store_address_as_tax_base() {
97
-    $use_base = wpinv_get_option( 'tax_base', 'billing' ) == 'base';
98
-    return (bool) apply_filters( 'wpinv_use_store_address_as_tax_base', $use_base );
97
+    $use_base = wpinv_get_option('tax_base', 'billing') == 'base';
98
+    return (bool) apply_filters('wpinv_use_store_address_as_tax_base', $use_base);
99 99
 }
100 100
 
101 101
 /**
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
  * @return bool
105 105
  */
106 106
 function wpinv_prices_include_tax() {
107
-    $is_inclusive = wpinv_get_option( 'prices_include_tax', 'no' ) == 'yes';
108
-    return (bool) apply_filters( 'wpinv_prices_include_tax', $is_inclusive );
107
+    $is_inclusive = wpinv_get_option('prices_include_tax', 'no') == 'yes';
108
+    return (bool) apply_filters('wpinv_prices_include_tax', $is_inclusive);
109 109
 }
110 110
 
111 111
 /**
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
  * @return bool
115 115
  */
116 116
 function wpinv_round_tax_per_tax_rate() {
117
-    $subtotal_rounding = wpinv_get_option( 'tax_subtotal_rounding', 1 );
118
-    return (bool) apply_filters( 'wpinv_round_tax_per_tax_rate', empty( $subtotal_rounding ) );
117
+    $subtotal_rounding = wpinv_get_option('tax_subtotal_rounding', 1);
118
+    return (bool) apply_filters('wpinv_round_tax_per_tax_rate', empty($subtotal_rounding));
119 119
 }
120 120
 
121 121
 /**
@@ -124,8 +124,8 @@  discard block
 block discarded – undo
124 124
  * @return bool
125 125
  */
126 126
 function wpinv_display_individual_tax_rates() {
127
-    $individual = wpinv_get_option( 'tax_display_totals', 'single' ) == 'individual';
128
-    return (bool) apply_filters( 'wpinv_display_individual_tax_rates', $individual );
127
+    $individual = wpinv_get_option('tax_display_totals', 'single') == 'individual';
128
+    return (bool) apply_filters('wpinv_display_individual_tax_rates', $individual);
129 129
 }
130 130
 
131 131
 /**
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
  * @return float
135 135
  */
136 136
 function wpinv_get_default_tax_rate() {
137
-    $rate = wpinv_get_option( 'tax_rate', false );
138
-    return (float) apply_filters( 'wpinv_get_default_tax_rate', floatval( $rate ) );
137
+    $rate = wpinv_get_option('tax_rate', false);
138
+    return (float) apply_filters('wpinv_get_default_tax_rate', floatval($rate));
139 139
 }
140 140
 
141 141
 /**
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
  * @return bool
145 145
  */
146 146
 function wpinv_same_country_exempt_vat() {
147
-    return 'no' == wpinv_get_option( 'vat_same_country_rule' );
147
+    return 'no' == wpinv_get_option('vat_same_country_rule');
148 148
 }
149 149
 
150 150
 /**
@@ -164,28 +164,28 @@  discard block
 block discarded – undo
164 164
  * @param string $state
165 165
  * @return array
166 166
  */
167
-function getpaid_get_item_tax_rates( $item, $country = '', $state = '' ) {
167
+function getpaid_get_item_tax_rates($item, $country = '', $state = '') {
168 168
 
169 169
     // Abort if the item is not taxable.
170
-    if ( ! wpinv_is_item_taxable( $item ) ) {
170
+    if (!wpinv_is_item_taxable($item)) {
171 171
         return array();
172 172
     }
173 173
 
174 174
     // Maybe use the store address.
175
-    if ( wpinv_use_store_address_as_tax_base() ) {
175
+    if (wpinv_use_store_address_as_tax_base()) {
176 176
         $country = wpinv_get_default_country();
177 177
         $state   = wpinv_get_default_state();
178 178
     }
179 179
 
180 180
     // Retrieve tax rates.
181
-    $tax_rates = GetPaid_Tax::get_address_tax_rates( $country, $state );
181
+    $tax_rates = GetPaid_Tax::get_address_tax_rates($country, $state);
182 182
 
183 183
     // Fallback to the default tax rates if non were found.
184
-    if ( empty( $tax_rates ) ) {
184
+    if (empty($tax_rates)) {
185 185
         $tax_rates = GetPaid_Tax::get_default_tax_rates();
186 186
     }
187 187
 
188
-    return apply_filters( 'getpaid_get_item_tax_rates', $tax_rates, $item, $country, $state );
188
+    return apply_filters('getpaid_get_item_tax_rates', $tax_rates, $item, $country, $state);
189 189
 }
190 190
 
191 191
 /**
@@ -195,23 +195,23 @@  discard block
 block discarded – undo
195 195
  * @param array $rates
196 196
  * @return array
197 197
  */
198
-function getpaid_filter_item_tax_rates( $item, $rates ) {
198
+function getpaid_filter_item_tax_rates($item, $rates) {
199 199
 
200 200
     $tax_class = $item->get_vat_class();
201 201
 
202
-    foreach ( $rates as $i => $rate ) {
202
+    foreach ($rates as $i => $rate) {
203 203
 
204
-        if ( $tax_class == '_reduced' ) {
205
-            $rates[ $i ]['rate'] = empty( $rate['reduced_rate'] ) ? 0 : $rate['reduced_rate'];
204
+        if ($tax_class == '_reduced') {
205
+            $rates[$i]['rate'] = empty($rate['reduced_rate']) ? 0 : $rate['reduced_rate'];
206 206
         }
207 207
 
208
-        if ( $tax_class == '_exempt' ) {
209
-            $rates[ $i ]['rate'] = 0;
208
+        if ($tax_class == '_exempt') {
209
+            $rates[$i]['rate'] = 0;
210 210
         }
211 211
 
212 212
     }
213 213
 
214
-    return apply_filters( 'getpaid_filter_item_tax_rates', $rates, $item );
214
+    return apply_filters('getpaid_filter_item_tax_rates', $rates, $item);
215 215
 }
216 216
 
217 217
 /**
@@ -221,12 +221,12 @@  discard block
 block discarded – undo
221 221
  * @param array $rates
222 222
  * @return array
223 223
  */
224
-function getpaid_calculate_item_taxes( $amount, $rates ) {
224
+function getpaid_calculate_item_taxes($amount, $rates) {
225 225
 
226 226
     $is_inclusive = wpinv_prices_include_tax();
227
-    $taxes        = GetPaid_Tax::calc_tax( $amount, $rates, $is_inclusive );
227
+    $taxes        = GetPaid_Tax::calc_tax($amount, $rates, $is_inclusive);
228 228
 
229
-    return apply_filters( 'getpaid_calculate_taxes', $taxes, $amount, $rates );
229
+    return apply_filters('getpaid_calculate_taxes', $taxes, $amount, $rates);
230 230
 }
231 231
 
232 232
 /**
@@ -238,17 +238,17 @@  discard block
 block discarded – undo
238 238
  * @param float $recurring_tax_amount
239 239
  * @return array
240 240
  */
241
-function getpaid_prepare_item_tax( $item, $tax_name, $tax_amount, $recurring_tax_amount ) {
241
+function getpaid_prepare_item_tax($item, $tax_name, $tax_amount, $recurring_tax_amount) {
242 242
 
243
-    $initial_tax   = $tax_amount;
243
+    $initial_tax = $tax_amount;
244 244
 	$recurring_tax = 0;
245 245
 
246
-    if ( $item->is_recurring() ) {
246
+    if ($item->is_recurring()) {
247 247
 		$recurring_tax = $recurring_tax_amount;
248 248
 	}
249 249
 
250 250
 	return array(
251
-		'name'          => sanitize_text_field( $tax_name ),
251
+		'name'          => sanitize_text_field($tax_name),
252 252
 		'initial_tax'   => $initial_tax,
253 253
 		'recurring_tax' => $recurring_tax,
254 254
     );
@@ -261,8 +261,8 @@  discard block
 block discarded – undo
261 261
  * @param string $vat_number
262 262
  * @return string
263 263
  */
264
-function wpinv_sanitize_vat_number( $vat_number ) {
265
-    return str_replace( array(' ', '.', '-', '_', ',' ), '', strtoupper( trim( $vat_number ) ) );
264
+function wpinv_sanitize_vat_number($vat_number) {
265
+    return str_replace(array(' ', '.', '-', '_', ','), '', strtoupper(trim($vat_number)));
266 266
 }
267 267
 
268 268
 /**
@@ -271,22 +271,22 @@  discard block
 block discarded – undo
271 271
  * @param string $vat_number
272 272
  * @return bool
273 273
  */
274
-function wpinv_regex_validate_vat_number( $vat_number ) {
274
+function wpinv_regex_validate_vat_number($vat_number) {
275 275
 
276
-    $country    = substr( $vat_number, 0, 2 );
277
-    $vatin      = substr( $vat_number, 2 );
278
-    $regexes    = wpinv_get_data( 'vat-number-regexes' );
276
+    $country    = substr($vat_number, 0, 2);
277
+    $vatin      = substr($vat_number, 2);
278
+    $regexes    = wpinv_get_data('vat-number-regexes');
279 279
 
280
-    if ( isset( $regexes[ $country ] ) ) {
280
+    if (isset($regexes[$country])) {
281 281
 
282
-        $regex = $regexes[ $country ];
282
+        $regex = $regexes[$country];
283 283
         $regex = '/^(?:' . $regex . ')$/';
284
-        return 1 === preg_match( $regex, $vatin );
284
+        return 1 === preg_match($regex, $vatin);
285 285
 
286 286
     }
287 287
 
288 288
     // Not an EU state, use filters to validate the number.
289
-    return apply_filters( 'wpinv_regex_validate_vat_number', true, $vat_number );
289
+    return apply_filters('wpinv_regex_validate_vat_number', true, $vat_number);
290 290
 }
291 291
 
292 292
 /**
@@ -295,29 +295,29 @@  discard block
 block discarded – undo
295 295
  * @param string $vat_number
296 296
  * @return bool
297 297
  */
298
-function wpinv_vies_validate_vat_number( $vat_number ) {
298
+function wpinv_vies_validate_vat_number($vat_number) {
299 299
 
300
-    $country    = substr( $vat_number, 0, 2 );
301
-    $vatin      = substr( $vat_number, 2 );
300
+    $country    = substr($vat_number, 0, 2);
301
+    $vatin      = substr($vat_number, 2);
302 302
 
303 303
     $url        = add_query_arg(
304 304
         array(
305
-            'ms'  => urlencode( $country ),
306
-            'iso' => urlencode( $country ),
307
-            'vat' => urlencode( $vatin ),
305
+            'ms'  => urlencode($country),
306
+            'iso' => urlencode($country),
307
+            'vat' => urlencode($vatin),
308 308
         ),
309 309
         'http://ec.europa.eu/taxation_customs/vies/viesquer.do'
310 310
     );
311 311
 
312
-    $response   = wp_remote_get( $url );
313
-    $response   = wp_remote_retrieve_body( $response );
312
+    $response   = wp_remote_get($url);
313
+    $response   = wp_remote_retrieve_body($response);
314 314
 
315 315
     // Fallback gracefully if the VIES website is down.
316
-    if ( empty( $response ) ) {
316
+    if (empty($response)) {
317 317
         return true;
318 318
     }
319 319
 
320
-    return 1 !== preg_match( '/invalid VAT number/i', $response );
320
+    return 1 !== preg_match('/invalid VAT number/i', $response);
321 321
 
322 322
 }
323 323
 
@@ -328,23 +328,23 @@  discard block
 block discarded – undo
328 328
  * @param string $country
329 329
  * @return bool
330 330
  */
331
-function wpinv_validate_vat_number( $vat_number, $country ) {
331
+function wpinv_validate_vat_number($vat_number, $country) {
332 332
 
333 333
     // Abort if we are not validating this.
334
-    if ( ! wpinv_should_validate_vat_number() || empty( $vat_number ) ) {
334
+    if (!wpinv_should_validate_vat_number() || empty($vat_number)) {
335 335
         return true;
336 336
     }
337 337
 
338 338
     // In case the vat number does not have a country code...
339
-    $vat_number = wpinv_sanitize_vat_number( $vat_number );
340
-    $_country   = substr( $vat_number, 0, 2 );
341
-    $_country   = $_country == wpinv_country_name( $_country );
339
+    $vat_number = wpinv_sanitize_vat_number($vat_number);
340
+    $_country   = substr($vat_number, 0, 2);
341
+    $_country   = $_country == wpinv_country_name($_country);
342 342
 
343
-    if ( $_country ) {
344
-        $vat_number = strtoupper( $country ) . $vat_number;
343
+    if ($_country) {
344
+        $vat_number = strtoupper($country) . $vat_number;
345 345
     }
346 346
 
347
-    return wpinv_regex_validate_vat_number( $vat_number ) && wpinv_vies_validate_vat_number( $vat_number );
347
+    return wpinv_regex_validate_vat_number($vat_number) && wpinv_vies_validate_vat_number($vat_number);
348 348
 }
349 349
 
350 350
 /**
@@ -353,40 +353,40 @@  discard block
 block discarded – undo
353 353
  * @return bool
354 354
  */
355 355
 function wpinv_should_validate_vat_number() {
356
-    $validate = wpinv_get_option( 'validate_vat_number' );
357
-	return ! empty( $validate );
356
+    $validate = wpinv_get_option('validate_vat_number');
357
+	return !empty($validate);
358 358
 }
359 359
 
360
-function wpinv_sales_tax_for_year( $year = null ) {
361
-    return wpinv_price( wpinv_format_amount( wpinv_get_sales_tax_for_year( $year ) ) );
360
+function wpinv_sales_tax_for_year($year = null) {
361
+    return wpinv_price(wpinv_format_amount(wpinv_get_sales_tax_for_year($year)));
362 362
 }
363 363
 
364
-function wpinv_get_sales_tax_for_year( $year = null ) {
364
+function wpinv_get_sales_tax_for_year($year = null) {
365 365
     global $wpdb;
366 366
 
367 367
     // Start at zero
368 368
     $tax = 0;
369 369
 
370
-    if ( ! empty( $year ) ) {
370
+    if (!empty($year)) {
371 371
         $args = array(
372 372
             'post_type'      => 'wpi_invoice',
373
-            'post_status'    => array( 'publish' ),
373
+            'post_status'    => array('publish'),
374 374
             'posts_per_page' => -1,
375 375
             'year'           => $year,
376 376
             'fields'         => 'ids'
377 377
         );
378 378
 
379
-        $payments    = get_posts( $args );
380
-        $payment_ids = implode( ',', $payments );
379
+        $payments    = get_posts($args);
380
+        $payment_ids = implode(',', $payments);
381 381
 
382
-        if ( count( $payments ) > 0 ) {
382
+        if (count($payments) > 0) {
383 383
             $sql = "SELECT SUM( meta_value ) FROM $wpdb->postmeta WHERE meta_key = '_wpinv_tax' AND post_id IN( $payment_ids )";
384
-            $tax = $wpdb->get_var( $sql );
384
+            $tax = $wpdb->get_var($sql);
385 385
         }
386 386
 
387 387
     }
388 388
 
389
-    return apply_filters( 'wpinv_get_sales_tax_for_year', $tax, $year );
389
+    return apply_filters('wpinv_get_sales_tax_for_year', $tax, $year);
390 390
 }
391 391
 
392 392
 function wpinv_is_cart_taxed() {
@@ -395,33 +395,33 @@  discard block
 block discarded – undo
395 395
 
396 396
 function wpinv_prices_show_tax_on_checkout() {
397 397
     return false; // TODO
398
-    $ret = ( wpinv_get_option( 'checkout_include_tax', false ) == 'yes' && wpinv_use_taxes() );
398
+    $ret = (wpinv_get_option('checkout_include_tax', false) == 'yes' && wpinv_use_taxes());
399 399
 
400
-    return apply_filters( 'wpinv_taxes_on_prices_on_checkout', $ret );
400
+    return apply_filters('wpinv_taxes_on_prices_on_checkout', $ret);
401 401
 }
402 402
 
403 403
 function wpinv_display_tax_rate() {
404
-    $ret = wpinv_use_taxes() && wpinv_get_option( 'display_tax_rate', false );
404
+    $ret = wpinv_use_taxes() && wpinv_get_option('display_tax_rate', false);
405 405
 
406
-    return apply_filters( 'wpinv_display_tax_rate', $ret );
406
+    return apply_filters('wpinv_display_tax_rate', $ret);
407 407
 }
408 408
 
409 409
 function wpinv_cart_needs_tax_address_fields() {
410
-    if( !wpinv_is_cart_taxed() )
410
+    if (!wpinv_is_cart_taxed())
411 411
         return false;
412 412
 
413
-    return ! did_action( 'wpinv_after_cc_fields', 'wpinv_default_cc_address_fields' );
413
+    return !did_action('wpinv_after_cc_fields', 'wpinv_default_cc_address_fields');
414 414
 }
415 415
 
416
-function wpinv_item_is_tax_exclusive( $item_id = 0 ) {
417
-    $ret = (bool)get_post_meta( $item_id, '_wpinv_tax_exclusive', false );
418
-    return apply_filters( 'wpinv_is_tax_exclusive', $ret, $item_id );
416
+function wpinv_item_is_tax_exclusive($item_id = 0) {
417
+    $ret = (bool) get_post_meta($item_id, '_wpinv_tax_exclusive', false);
418
+    return apply_filters('wpinv_is_tax_exclusive', $ret, $item_id);
419 419
 }
420 420
 
421
-function wpinv_currency_decimal_filter( $decimals = 2 ) {
421
+function wpinv_currency_decimal_filter($decimals = 2) {
422 422
     $currency = wpinv_get_currency();
423 423
 
424
-    switch ( $currency ) {
424
+    switch ($currency) {
425 425
         case 'RIAL' :
426 426
         case 'JPY' :
427 427
         case 'TWD' :
@@ -430,13 +430,13 @@  discard block
 block discarded – undo
430 430
             break;
431 431
     }
432 432
 
433
-    return apply_filters( 'wpinv_currency_decimal_count', $decimals, $currency );
433
+    return apply_filters('wpinv_currency_decimal_count', $decimals, $currency);
434 434
 }
435 435
 
436 436
 function wpinv_tax_amount() {
437 437
     $output = 0.00;
438 438
     
439
-    return apply_filters( 'wpinv_tax_amount', $output );
439
+    return apply_filters('wpinv_tax_amount', $output);
440 440
 }
441 441
 
442 442
 /**
@@ -444,25 +444,25 @@  discard block
 block discarded – undo
444 444
  * 
445 445
  * @param string|bool|null $vat_rule
446 446
  */
447
-function getpaid_filter_vat_rule( $vat_rule ) {
447
+function getpaid_filter_vat_rule($vat_rule) {
448 448
 
449
-    if ( empty( $vat_rule ) ) {        
449
+    if (empty($vat_rule)) {        
450 450
         return 'digital';
451 451
     }
452 452
 
453 453
     return $vat_rule;
454 454
 }
455
-add_filter( 'wpinv_get_item_vat_rule', 'getpaid_filter_vat_rule' );
455
+add_filter('wpinv_get_item_vat_rule', 'getpaid_filter_vat_rule');
456 456
 
457 457
 /**
458 458
  * Filters the VAT class to ensure that each item has a VAT class.
459 459
  * 
460 460
  * @param string|bool|null $vat_rule
461 461
  */
462
-function getpaid_filter_vat_class( $vat_class ) {
463
-    return empty( $vat_class ) ? '_standard' : $vat_class;
462
+function getpaid_filter_vat_class($vat_class) {
463
+    return empty($vat_class) ? '_standard' : $vat_class;
464 464
 }
465
-add_filter( 'wpinv_get_item_vat_class', 'getpaid_filter_vat_class' );
465
+add_filter('wpinv_get_item_vat_class', 'getpaid_filter_vat_class');
466 466
 
467 467
 /**
468 468
  * Returns a list of all tax classes.
@@ -474,9 +474,9 @@  discard block
 block discarded – undo
474 474
     return apply_filters(
475 475
         'getpaid_tax_classes',
476 476
         array(
477
-            '_standard' => __( 'Standard Tax Rate', 'invoicing' ),
478
-            '_reduced'  => __( 'Reduced Tax Rate', 'invoicing' ),
479
-            '_exempt'   => __( 'Tax Exempt', 'invoicing' ),
477
+            '_standard' => __('Standard Tax Rate', 'invoicing'),
478
+            '_reduced'  => __('Reduced Tax Rate', 'invoicing'),
479
+            '_exempt'   => __('Tax Exempt', 'invoicing'),
480 480
         )
481 481
     );
482 482
 
@@ -492,8 +492,8 @@  discard block
 block discarded – undo
492 492
     return apply_filters(
493 493
         'getpaid_tax_rules',
494 494
         array(
495
-            'physical' => __( 'Physical Item', 'invoicing' ),
496
-            'digital'  => __( 'Digital Item', 'invoicing' ),
495
+            'physical' => __('Physical Item', 'invoicing'),
496
+            'digital'  => __('Digital Item', 'invoicing'),
497 497
         )
498 498
     );
499 499
 
@@ -505,15 +505,15 @@  discard block
 block discarded – undo
505 505
  * @param string $tax_class
506 506
  * @return string
507 507
  */
508
-function getpaid_get_tax_class_label( $tax_class ) {
508
+function getpaid_get_tax_class_label($tax_class) {
509 509
 
510 510
     $classes = getpaid_get_tax_classes();
511 511
 
512
-    if ( isset( $classes[ $tax_class ] ) ) {
513
-        return sanitize_text_field( $classes[ $tax_class ] );
512
+    if (isset($classes[$tax_class])) {
513
+        return sanitize_text_field($classes[$tax_class]);
514 514
     }
515 515
 
516
-    return sanitize_text_field( $tax_class );
516
+    return sanitize_text_field($tax_class);
517 517
 
518 518
 }
519 519
 
@@ -523,14 +523,14 @@  discard block
 block discarded – undo
523 523
  * @param string $tax_rule
524 524
  * @return string
525 525
  */
526
-function getpaid_get_tax_rule_label( $tax_rule ) {
526
+function getpaid_get_tax_rule_label($tax_rule) {
527 527
 
528 528
     $rules = getpaid_get_tax_rules();
529 529
 
530
-    if ( isset( $rules[ $tax_rule ] ) ) {
531
-        return sanitize_text_field( $rules[ $tax_rule ] );
530
+    if (isset($rules[$tax_rule])) {
531
+        return sanitize_text_field($rules[$tax_rule]);
532 532
     }
533 533
 
534
-    return sanitize_text_field( $tax_rule );
534
+    return sanitize_text_field($tax_rule);
535 535
 
536 536
 }
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/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/payments/class-getpaid-payment-form-submission-refresh-prices.php 2 patches
Indentation   +184 added lines, -184 removed lines patch added patch discarded remove patch
@@ -12,224 +12,224 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Payment_Form_Submission_Refresh_Prices {
14 14
 
15
-	/**
16
-	 * Contains the response for refreshing prices.
17
-	 * @var array
18
-	 */
19
-	public $response = array();
15
+    /**
16
+     * Contains the response for refreshing prices.
17
+     * @var array
18
+     */
19
+    public $response = array();
20 20
 
21 21
     /**
22
-	 * Class constructor
23
-	 *
24
-	 * @param GetPaid_Payment_Form_Submission $submission
25
-	 */
26
-	public function __construct( $submission ) {
27
-
28
-		$this->response = array(
29
-			'submission_id' => $submission->id,
22
+     * Class constructor
23
+     *
24
+     * @param GetPaid_Payment_Form_Submission $submission
25
+     */
26
+    public function __construct( $submission ) {
27
+
28
+        $this->response = array(
29
+            'submission_id' => $submission->id,
30 30
             'has_recurring' => $submission->has_recurring,
31 31
             'is_free'       => ! $submission->should_collect_payment_details(),
32
-		);
33
-
34
-		$this->add_totals( $submission );
35
-		$this->add_texts( $submission );
36
-		$this->add_items( $submission );
37
-		$this->add_fees( $submission );
38
-		$this->add_discounts( $submission );
39
-		$this->add_taxes( $submission );
40
-		$this->add_gateways( $submission );
41
-
42
-	}
43
-
44
-	/**
45
-	 * Adds totals to a response for submission refresh prices.
46
-	 *
47
-	 * @param GetPaid_Payment_Form_Submission $submission
48
-	 */
49
-	public function add_totals( $submission ) {
50
-
51
-		$this->response = array_merge(
52
-			$this->response,
53
-			array(
54
-
55
-				'totals'        => array(
56
-					'subtotal'  => $submission->format_amount( $submission->get_subtotal() ),
57
-					'discount'  => $submission->format_amount( $submission->get_discount() ),
58
-					'fees'      => $submission->format_amount( $submission->get_fee() ),
59
-					'tax'       => $submission->format_amount( $submission->get_tax() ),
60
-					'total'     => $submission->format_amount( $submission->get_total() ),
61
-					'raw_total' => html_entity_decode( sanitize_text_field( $submission->format_amount( $submission->get_total() ) ), ENT_QUOTES ),
62
-				),
63
-
64
-				'recurring'     => array(
65
-					'subtotal'  => $submission->format_amount( $submission->get_recurring_subtotal() ),
66
-					'discount'  => $submission->format_amount( $submission->get_recurring_discount() ),
67
-					'fees'      => $submission->format_amount( $submission->get_recurring_fee() ),
68
-					'tax'       => $submission->format_amount( $submission->get_recurring_tax() ),
69
-					'total'     => $submission->format_amount( $submission->get_recurring_total() ),
70
-				),
71
-
72
-			)
73
-		);
74
-
75
-	}
76
-
77
-	/**
78
-	 * Adds texts to a response for submission refresh prices.
79
-	 *
80
-	 * @param GetPaid_Payment_Form_Submission $submission
81
-	 */
82
-	public function add_texts( $submission ) {
83
-
84
-		$payable = $submission->format_amount( $submission->get_total() );
85
-
86
-		if ( $submission->has_recurring != 0 ) {
87
-
88
-			$recurring = new WPInv_Item( $submission->has_recurring );
89
-			$period    = getpaid_get_subscription_period_label( $recurring->get_recurring_period( true ), $recurring->get_recurring_interval(), '' );
90
-
91
-			if ( $submission->get_total() == $submission->get_recurring_total() ) {
92
-				$payable = "$payable / $period";
93
-			} else {
94
-				$payable = sprintf(
95
-					__( '%1$s (renews at %2$s / %3$s)'),
96
-					$submission->format_amount( $submission->get_total() ),
97
-					$submission->format_amount( $submission->get_recurring_total() ),
98
-					$period
99
-				);
100
-			}
101
-
102
-		}
103
-
104
-		$texts = array(
105
-			'.getpaid-checkout-total-payable' => $payable,
106
-		);
107
-
108
-		foreach ( $submission->get_items() as $item_id => $item ) {
109
-			$texts[".item-$item_id .getpaid-item-initial-price"]   = $submission->format_amount( $item->get_sub_total() );
110
-			$texts[".item-$item_id .getpaid-item-recurring-price"] = $submission->format_amount( $item->get_recurring_sub_total() );
111
-		}
112
-
113
-		$this->response = array_merge( $this->response, array( 'texts' => $texts ) );
114
-
115
-	}
116
-
117
-	/**
118
-	 * Adds items to a response for submission refresh prices.
119
-	 *
120
-	 * @param GetPaid_Payment_Form_Submission $submission
121
-	 */
122
-	public function add_items( $submission ) {
123
-
124
-		// Add items.
125
-		$items = array();
32
+        );
33
+
34
+        $this->add_totals( $submission );
35
+        $this->add_texts( $submission );
36
+        $this->add_items( $submission );
37
+        $this->add_fees( $submission );
38
+        $this->add_discounts( $submission );
39
+        $this->add_taxes( $submission );
40
+        $this->add_gateways( $submission );
41
+
42
+    }
43
+
44
+    /**
45
+     * Adds totals to a response for submission refresh prices.
46
+     *
47
+     * @param GetPaid_Payment_Form_Submission $submission
48
+     */
49
+    public function add_totals( $submission ) {
50
+
51
+        $this->response = array_merge(
52
+            $this->response,
53
+            array(
54
+
55
+                'totals'        => array(
56
+                    'subtotal'  => $submission->format_amount( $submission->get_subtotal() ),
57
+                    'discount'  => $submission->format_amount( $submission->get_discount() ),
58
+                    'fees'      => $submission->format_amount( $submission->get_fee() ),
59
+                    'tax'       => $submission->format_amount( $submission->get_tax() ),
60
+                    'total'     => $submission->format_amount( $submission->get_total() ),
61
+                    'raw_total' => html_entity_decode( sanitize_text_field( $submission->format_amount( $submission->get_total() ) ), ENT_QUOTES ),
62
+                ),
63
+
64
+                'recurring'     => array(
65
+                    'subtotal'  => $submission->format_amount( $submission->get_recurring_subtotal() ),
66
+                    'discount'  => $submission->format_amount( $submission->get_recurring_discount() ),
67
+                    'fees'      => $submission->format_amount( $submission->get_recurring_fee() ),
68
+                    'tax'       => $submission->format_amount( $submission->get_recurring_tax() ),
69
+                    'total'     => $submission->format_amount( $submission->get_recurring_total() ),
70
+                ),
71
+
72
+            )
73
+        );
74
+
75
+    }
76
+
77
+    /**
78
+     * Adds texts to a response for submission refresh prices.
79
+     *
80
+     * @param GetPaid_Payment_Form_Submission $submission
81
+     */
82
+    public function add_texts( $submission ) {
83
+
84
+        $payable = $submission->format_amount( $submission->get_total() );
85
+
86
+        if ( $submission->has_recurring != 0 ) {
87
+
88
+            $recurring = new WPInv_Item( $submission->has_recurring );
89
+            $period    = getpaid_get_subscription_period_label( $recurring->get_recurring_period( true ), $recurring->get_recurring_interval(), '' );
90
+
91
+            if ( $submission->get_total() == $submission->get_recurring_total() ) {
92
+                $payable = "$payable / $period";
93
+            } else {
94
+                $payable = sprintf(
95
+                    __( '%1$s (renews at %2$s / %3$s)'),
96
+                    $submission->format_amount( $submission->get_total() ),
97
+                    $submission->format_amount( $submission->get_recurring_total() ),
98
+                    $period
99
+                );
100
+            }
101
+
102
+        }
103
+
104
+        $texts = array(
105
+            '.getpaid-checkout-total-payable' => $payable,
106
+        );
126 107
 
127 108
         foreach ( $submission->get_items() as $item_id => $item ) {
128
-			$items["$item_id"] = $submission->format_amount( $item->get_sub_total() );
129
-		}
109
+            $texts[".item-$item_id .getpaid-item-initial-price"]   = $submission->format_amount( $item->get_sub_total() );
110
+            $texts[".item-$item_id .getpaid-item-recurring-price"] = $submission->format_amount( $item->get_recurring_sub_total() );
111
+        }
130 112
 
131
-		$this->response = array_merge(
132
-			$this->response,
133
-			array( 'items' => $items )
134
-		);
113
+        $this->response = array_merge( $this->response, array( 'texts' => $texts ) );
135 114
 
136
-	}
115
+    }
137 116
 
138
-	/**
139
-	 * Adds fees to a response for submission refresh prices.
140
-	 *
141
-	 * @param GetPaid_Payment_Form_Submission $submission
142
-	 */
143
-	public function add_fees( $submission ) {
117
+    /**
118
+     * Adds items to a response for submission refresh prices.
119
+     *
120
+     * @param GetPaid_Payment_Form_Submission $submission
121
+     */
122
+    public function add_items( $submission ) {
123
+
124
+        // Add items.
125
+        $items = array();
126
+
127
+        foreach ( $submission->get_items() as $item_id => $item ) {
128
+            $items["$item_id"] = $submission->format_amount( $item->get_sub_total() );
129
+        }
130
+
131
+        $this->response = array_merge(
132
+            $this->response,
133
+            array( 'items' => $items )
134
+        );
135
+
136
+    }
144 137
 
145
-		$fees = array();
138
+    /**
139
+     * Adds fees to a response for submission refresh prices.
140
+     *
141
+     * @param GetPaid_Payment_Form_Submission $submission
142
+     */
143
+    public function add_fees( $submission ) {
144
+
145
+        $fees = array();
146 146
 
147 147
         foreach ( $submission->get_fees() as $name => $data ) {
148
-			$fees[$name] = $submission->format_amount( $data['initial_fee'] );
149
-		}
148
+            $fees[$name] = $submission->format_amount( $data['initial_fee'] );
149
+        }
150 150
 
151
-		$this->response = array_merge(
152
-			$this->response,
153
-			array( 'fees' => $fees )
154
-		);
151
+        $this->response = array_merge(
152
+            $this->response,
153
+            array( 'fees' => $fees )
154
+        );
155 155
 
156
-	}
156
+    }
157 157
 
158
-	/**
159
-	 * Adds discounts to a response for submission refresh prices.
160
-	 *
161
-	 * @param GetPaid_Payment_Form_Submission $submission
162
-	 */
163
-	public function add_discounts( $submission ) {
158
+    /**
159
+     * Adds discounts to a response for submission refresh prices.
160
+     *
161
+     * @param GetPaid_Payment_Form_Submission $submission
162
+     */
163
+    public function add_discounts( $submission ) {
164 164
 
165
-		$discounts = array();
165
+        $discounts = array();
166 166
 
167 167
         foreach ( $submission->get_discounts() as $name => $data ) {
168
-			$discounts[$name] = $submission->format_amount( $data['initial_discount'] );
169
-		}
168
+            $discounts[$name] = $submission->format_amount( $data['initial_discount'] );
169
+        }
170 170
 
171
-		$this->response = array_merge(
172
-			$this->response,
173
-			array( 'discounts' => $discounts )
174
-		);
171
+        $this->response = array_merge(
172
+            $this->response,
173
+            array( 'discounts' => $discounts )
174
+        );
175 175
 
176
-	}
176
+    }
177 177
 
178
-	/**
179
-	 * Adds taxes to a response for submission refresh prices.
180
-	 *
181
-	 * @param GetPaid_Payment_Form_Submission $submission
182
-	 */
183
-	public function add_taxes( $submission ) {
184
-
185
-		$taxes  = array();
186
-		$markup = '';
178
+    /**
179
+     * Adds taxes to a response for submission refresh prices.
180
+     *
181
+     * @param GetPaid_Payment_Form_Submission $submission
182
+     */
183
+    public function add_taxes( $submission ) {
184
+
185
+        $taxes  = array();
186
+        $markup = '';
187 187
         foreach ( $submission->get_taxes() as $name => $data ) {
188
-			$name          = sanitize_text_field( $name );
189
-			$amount        = $submission->format_amount( $data['initial_tax'] );
190
-			$taxes[$name]  = $amount;
191
-			$markup       .= "<small class='form-text'>$name : $amount</small>";
192
-		}
188
+            $name          = sanitize_text_field( $name );
189
+            $amount        = $submission->format_amount( $data['initial_tax'] );
190
+            $taxes[$name]  = $amount;
191
+            $markup       .= "<small class='form-text'>$name : $amount</small>";
192
+        }
193 193
 
194
-		if ( wpinv_display_individual_tax_rates() ) {
195
-			$this->response['texts']['.getpaid-form-cart-totals-total-tax'] = $markup;
196
-		}
194
+        if ( wpinv_display_individual_tax_rates() ) {
195
+            $this->response['texts']['.getpaid-form-cart-totals-total-tax'] = $markup;
196
+        }
197 197
 
198
-		$this->response = array_merge(
199
-			$this->response,
200
-			array( 'taxes' => $taxes )
201
-		);
198
+        $this->response = array_merge(
199
+            $this->response,
200
+            array( 'taxes' => $taxes )
201
+        );
202 202
 
203
-	}
203
+    }
204 204
 
205
-	/**
206
-	 * Adds gateways to a response for submission refresh prices.
207
-	 *
208
-	 * @param GetPaid_Payment_Form_Submission $submission
209
-	 */
210
-	public function add_gateways( $submission ) {
205
+    /**
206
+     * Adds gateways to a response for submission refresh prices.
207
+     *
208
+     * @param GetPaid_Payment_Form_Submission $submission
209
+     */
210
+    public function add_gateways( $submission ) {
211 211
 
212
-		$gateways = array_keys( wpinv_get_enabled_payment_gateways() );
212
+        $gateways = array_keys( wpinv_get_enabled_payment_gateways() );
213 213
 
214
-		if ( $this->response['has_recurring'] ) {
214
+        if ( $this->response['has_recurring'] ) {
215 215
 
216
-			foreach ( $gateways as $i => $gateway ) {
216
+            foreach ( $gateways as $i => $gateway ) {
217 217
 
218
-				if ( ! wpinv_gateway_support_subscription( $gateway ) ) {
219
-					unset( $gateways[ $i ] );
220
-				}
218
+                if ( ! wpinv_gateway_support_subscription( $gateway ) ) {
219
+                    unset( $gateways[ $i ] );
220
+                }
221 221
 
222
-			}
222
+            }
223 223
 
224
-		}
224
+        }
225 225
 
226 226
 
227
-		$gateways = apply_filters( 'getpaid_submission_gateways', $gateways, $submission );
228
-		$this->response = array_merge(
229
-			$this->response,
230
-			array( 'gateways' => $gateways )
231
-		);
227
+        $gateways = apply_filters( 'getpaid_submission_gateways', $gateways, $submission );
228
+        $this->response = array_merge(
229
+            $this->response,
230
+            array( 'gateways' => $gateways )
231
+        );
232 232
 
233
-	}
233
+    }
234 234
 
235 235
 }
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 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
  * Payment form submission refresh prices class
@@ -23,21 +23,21 @@  discard block
 block discarded – undo
23 23
 	 *
24 24
 	 * @param GetPaid_Payment_Form_Submission $submission
25 25
 	 */
26
-	public function __construct( $submission ) {
26
+	public function __construct($submission) {
27 27
 
28 28
 		$this->response = array(
29 29
 			'submission_id' => $submission->id,
30 30
             'has_recurring' => $submission->has_recurring,
31
-            'is_free'       => ! $submission->should_collect_payment_details(),
31
+            'is_free'       => !$submission->should_collect_payment_details(),
32 32
 		);
33 33
 
34
-		$this->add_totals( $submission );
35
-		$this->add_texts( $submission );
36
-		$this->add_items( $submission );
37
-		$this->add_fees( $submission );
38
-		$this->add_discounts( $submission );
39
-		$this->add_taxes( $submission );
40
-		$this->add_gateways( $submission );
34
+		$this->add_totals($submission);
35
+		$this->add_texts($submission);
36
+		$this->add_items($submission);
37
+		$this->add_fees($submission);
38
+		$this->add_discounts($submission);
39
+		$this->add_taxes($submission);
40
+		$this->add_gateways($submission);
41 41
 
42 42
 	}
43 43
 
@@ -46,27 +46,27 @@  discard block
 block discarded – undo
46 46
 	 *
47 47
 	 * @param GetPaid_Payment_Form_Submission $submission
48 48
 	 */
49
-	public function add_totals( $submission ) {
49
+	public function add_totals($submission) {
50 50
 
51 51
 		$this->response = array_merge(
52 52
 			$this->response,
53 53
 			array(
54 54
 
55 55
 				'totals'        => array(
56
-					'subtotal'  => $submission->format_amount( $submission->get_subtotal() ),
57
-					'discount'  => $submission->format_amount( $submission->get_discount() ),
58
-					'fees'      => $submission->format_amount( $submission->get_fee() ),
59
-					'tax'       => $submission->format_amount( $submission->get_tax() ),
60
-					'total'     => $submission->format_amount( $submission->get_total() ),
61
-					'raw_total' => html_entity_decode( sanitize_text_field( $submission->format_amount( $submission->get_total() ) ), ENT_QUOTES ),
56
+					'subtotal'  => $submission->format_amount($submission->get_subtotal()),
57
+					'discount'  => $submission->format_amount($submission->get_discount()),
58
+					'fees'      => $submission->format_amount($submission->get_fee()),
59
+					'tax'       => $submission->format_amount($submission->get_tax()),
60
+					'total'     => $submission->format_amount($submission->get_total()),
61
+					'raw_total' => html_entity_decode(sanitize_text_field($submission->format_amount($submission->get_total())), ENT_QUOTES),
62 62
 				),
63 63
 
64 64
 				'recurring'     => array(
65
-					'subtotal'  => $submission->format_amount( $submission->get_recurring_subtotal() ),
66
-					'discount'  => $submission->format_amount( $submission->get_recurring_discount() ),
67
-					'fees'      => $submission->format_amount( $submission->get_recurring_fee() ),
68
-					'tax'       => $submission->format_amount( $submission->get_recurring_tax() ),
69
-					'total'     => $submission->format_amount( $submission->get_recurring_total() ),
65
+					'subtotal'  => $submission->format_amount($submission->get_recurring_subtotal()),
66
+					'discount'  => $submission->format_amount($submission->get_recurring_discount()),
67
+					'fees'      => $submission->format_amount($submission->get_recurring_fee()),
68
+					'tax'       => $submission->format_amount($submission->get_recurring_tax()),
69
+					'total'     => $submission->format_amount($submission->get_recurring_total()),
70 70
 				),
71 71
 
72 72
 			)
@@ -79,22 +79,22 @@  discard block
 block discarded – undo
79 79
 	 *
80 80
 	 * @param GetPaid_Payment_Form_Submission $submission
81 81
 	 */
82
-	public function add_texts( $submission ) {
82
+	public function add_texts($submission) {
83 83
 
84
-		$payable = $submission->format_amount( $submission->get_total() );
84
+		$payable = $submission->format_amount($submission->get_total());
85 85
 
86
-		if ( $submission->has_recurring != 0 ) {
86
+		if ($submission->has_recurring != 0) {
87 87
 
88
-			$recurring = new WPInv_Item( $submission->has_recurring );
89
-			$period    = getpaid_get_subscription_period_label( $recurring->get_recurring_period( true ), $recurring->get_recurring_interval(), '' );
88
+			$recurring = new WPInv_Item($submission->has_recurring);
89
+			$period    = getpaid_get_subscription_period_label($recurring->get_recurring_period(true), $recurring->get_recurring_interval(), '');
90 90
 
91
-			if ( $submission->get_total() == $submission->get_recurring_total() ) {
91
+			if ($submission->get_total() == $submission->get_recurring_total()) {
92 92
 				$payable = "$payable / $period";
93 93
 			} else {
94 94
 				$payable = sprintf(
95
-					__( '%1$s (renews at %2$s / %3$s)'),
96
-					$submission->format_amount( $submission->get_total() ),
97
-					$submission->format_amount( $submission->get_recurring_total() ),
95
+					__('%1$s (renews at %2$s / %3$s)'),
96
+					$submission->format_amount($submission->get_total()),
97
+					$submission->format_amount($submission->get_recurring_total()),
98 98
 					$period
99 99
 				);
100 100
 			}
@@ -105,12 +105,12 @@  discard block
 block discarded – undo
105 105
 			'.getpaid-checkout-total-payable' => $payable,
106 106
 		);
107 107
 
108
-		foreach ( $submission->get_items() as $item_id => $item ) {
109
-			$texts[".item-$item_id .getpaid-item-initial-price"]   = $submission->format_amount( $item->get_sub_total() );
110
-			$texts[".item-$item_id .getpaid-item-recurring-price"] = $submission->format_amount( $item->get_recurring_sub_total() );
108
+		foreach ($submission->get_items() as $item_id => $item) {
109
+			$texts[".item-$item_id .getpaid-item-initial-price"]   = $submission->format_amount($item->get_sub_total());
110
+			$texts[".item-$item_id .getpaid-item-recurring-price"] = $submission->format_amount($item->get_recurring_sub_total());
111 111
 		}
112 112
 
113
-		$this->response = array_merge( $this->response, array( 'texts' => $texts ) );
113
+		$this->response = array_merge($this->response, array('texts' => $texts));
114 114
 
115 115
 	}
116 116
 
@@ -119,18 +119,18 @@  discard block
 block discarded – undo
119 119
 	 *
120 120
 	 * @param GetPaid_Payment_Form_Submission $submission
121 121
 	 */
122
-	public function add_items( $submission ) {
122
+	public function add_items($submission) {
123 123
 
124 124
 		// Add items.
125 125
 		$items = array();
126 126
 
127
-        foreach ( $submission->get_items() as $item_id => $item ) {
128
-			$items["$item_id"] = $submission->format_amount( $item->get_sub_total() );
127
+        foreach ($submission->get_items() as $item_id => $item) {
128
+			$items["$item_id"] = $submission->format_amount($item->get_sub_total());
129 129
 		}
130 130
 
131 131
 		$this->response = array_merge(
132 132
 			$this->response,
133
-			array( 'items' => $items )
133
+			array('items' => $items)
134 134
 		);
135 135
 
136 136
 	}
@@ -140,17 +140,17 @@  discard block
 block discarded – undo
140 140
 	 *
141 141
 	 * @param GetPaid_Payment_Form_Submission $submission
142 142
 	 */
143
-	public function add_fees( $submission ) {
143
+	public function add_fees($submission) {
144 144
 
145 145
 		$fees = array();
146 146
 
147
-        foreach ( $submission->get_fees() as $name => $data ) {
148
-			$fees[$name] = $submission->format_amount( $data['initial_fee'] );
147
+        foreach ($submission->get_fees() as $name => $data) {
148
+			$fees[$name] = $submission->format_amount($data['initial_fee']);
149 149
 		}
150 150
 
151 151
 		$this->response = array_merge(
152 152
 			$this->response,
153
-			array( 'fees' => $fees )
153
+			array('fees' => $fees)
154 154
 		);
155 155
 
156 156
 	}
@@ -160,17 +160,17 @@  discard block
 block discarded – undo
160 160
 	 *
161 161
 	 * @param GetPaid_Payment_Form_Submission $submission
162 162
 	 */
163
-	public function add_discounts( $submission ) {
163
+	public function add_discounts($submission) {
164 164
 
165 165
 		$discounts = array();
166 166
 
167
-        foreach ( $submission->get_discounts() as $name => $data ) {
168
-			$discounts[$name] = $submission->format_amount( $data['initial_discount'] );
167
+        foreach ($submission->get_discounts() as $name => $data) {
168
+			$discounts[$name] = $submission->format_amount($data['initial_discount']);
169 169
 		}
170 170
 
171 171
 		$this->response = array_merge(
172 172
 			$this->response,
173
-			array( 'discounts' => $discounts )
173
+			array('discounts' => $discounts)
174 174
 		);
175 175
 
176 176
 	}
@@ -180,24 +180,24 @@  discard block
 block discarded – undo
180 180
 	 *
181 181
 	 * @param GetPaid_Payment_Form_Submission $submission
182 182
 	 */
183
-	public function add_taxes( $submission ) {
183
+	public function add_taxes($submission) {
184 184
 
185 185
 		$taxes  = array();
186 186
 		$markup = '';
187
-        foreach ( $submission->get_taxes() as $name => $data ) {
188
-			$name          = sanitize_text_field( $name );
189
-			$amount        = $submission->format_amount( $data['initial_tax'] );
187
+        foreach ($submission->get_taxes() as $name => $data) {
188
+			$name          = sanitize_text_field($name);
189
+			$amount        = $submission->format_amount($data['initial_tax']);
190 190
 			$taxes[$name]  = $amount;
191 191
 			$markup       .= "<small class='form-text'>$name : $amount</small>";
192 192
 		}
193 193
 
194
-		if ( wpinv_display_individual_tax_rates() ) {
194
+		if (wpinv_display_individual_tax_rates()) {
195 195
 			$this->response['texts']['.getpaid-form-cart-totals-total-tax'] = $markup;
196 196
 		}
197 197
 
198 198
 		$this->response = array_merge(
199 199
 			$this->response,
200
-			array( 'taxes' => $taxes )
200
+			array('taxes' => $taxes)
201 201
 		);
202 202
 
203 203
 	}
@@ -207,16 +207,16 @@  discard block
 block discarded – undo
207 207
 	 *
208 208
 	 * @param GetPaid_Payment_Form_Submission $submission
209 209
 	 */
210
-	public function add_gateways( $submission ) {
210
+	public function add_gateways($submission) {
211 211
 
212
-		$gateways = array_keys( wpinv_get_enabled_payment_gateways() );
212
+		$gateways = array_keys(wpinv_get_enabled_payment_gateways());
213 213
 
214
-		if ( $this->response['has_recurring'] ) {
214
+		if ($this->response['has_recurring']) {
215 215
 
216
-			foreach ( $gateways as $i => $gateway ) {
216
+			foreach ($gateways as $i => $gateway) {
217 217
 
218
-				if ( ! wpinv_gateway_support_subscription( $gateway ) ) {
219
-					unset( $gateways[ $i ] );
218
+				if (!wpinv_gateway_support_subscription($gateway)) {
219
+					unset($gateways[$i]);
220 220
 				}
221 221
 
222 222
 			}
@@ -224,10 +224,10 @@  discard block
 block discarded – undo
224 224
 		}
225 225
 
226 226
 
227
-		$gateways = apply_filters( 'getpaid_submission_gateways', $gateways, $submission );
227
+		$gateways = apply_filters('getpaid_submission_gateways', $gateways, $submission);
228 228
 		$this->response = array_merge(
229 229
 			$this->response,
230
-			array( 'gateways' => $gateways )
230
+			array('gateways' => $gateways)
231 231
 		);
232 232
 
233 233
 	}
Please login to merge, or discard this patch.
includes/reports/class-getpaid-invoice-exporter.php 2 patches
Indentation   +189 added lines, -189 removed lines patch added patch discarded remove patch
@@ -12,194 +12,194 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Invoice_Exporter extends GetPaid_Graph_Downloader {
14 14
 
15
-	/**
16
-	 * Retrieves invoices query args.
17
-	 * 
18
-	 * @param string $post_type post type to retrieve.
19
-	 * @param array $args Args to search for.
20
-	 * @return array
21
-	 */
22
-	public function get_invoice_query_args( $post_type, $args ) {
23
-
24
-		$query_args = array(
25
-			'post_type'              => $post_type,
26
-			'post_status'            => array_keys( wpinv_get_invoice_statuses( true, false, $post_type ) ),
27
-			'posts_per_page'         => -1,
28
-			'no_found_rows'          => true,
29
-			'update_post_term_cache' => false,
30
-			'fields'                 => 'ids',
31
-		);
32
-
33
-		if ( ! empty( $args['status'] ) && in_array( $args['status'], $query_args['post_status'], true ) ) {
34
-			$query_args['post_status'] = wpinv_clean( wpinv_parse_list( $args['status'] ) );
35
-		}
36
-
37
-		$date_query = array();
38
-		if ( ! empty( $args['to_date'] ) ) {
39
-			$date_query['before'] = wpinv_clean( $args['to_date'] );
40
-		}
41
-
42
-		if ( ! empty( $args['from_date'] ) ) {
43
-			$date_query['after'] = wpinv_clean( $args['from_date'] );
44
-		}
45
-
46
-		if ( ! empty( $date_query ) ) {
47
-			$date_query['inclusive']  = true;
48
-			$query_args['date_query'] = array( $date_query );
49
-		}
50
-
51
-		return $query_args;
52
-	}
53
-
54
-	/**
55
-	 * Retrieves invoices.
56
-	 * 
57
-	 * @param array $query_args WP_Query args.
58
-	 * @return WPInv_Invoice[]
59
-	 */
60
-	public function get_invoices( $query_args ) {
61
-
62
-		// Get invoices.
63
-		$invoices = new WP_Query( $query_args );
64
-
65
-		// Prepare the results.
66
-		return array_map( 'wpinv_get_invoice', $invoices->posts );
67
-
68
-	}
69
-
70
-	/**
71
-	 * Handles the actual download.
72
-	 *
73
-	 */
74
-	public function export( $post_type, $args ) {
75
-
76
-		$invoices  = $this->get_invoices( $this->get_invoice_query_args( $post_type, $args ) );
77
-		$stream    = $this->prepare_output();
78
-		$headers   = $this->get_export_fields( $post_type );
79
-		$file_type = $this->prepare_file_type( strtolower( getpaid_get_post_type_label( $post_type ) ) );
80
-
81
-		if ( 'csv' == $file_type ) {
82
-			$this->download_csv( $invoices, $stream, $headers );
83
-		} else if( 'xml' == $file_type ) {
84
-			$this->download_xml( $invoices, $stream, $headers );
85
-		} else {
86
-			$this->download_json( $invoices, $stream, $headers );
87
-		}
88
-
89
-		fclose( $stream );
90
-		exit;
91
-	}
92
-
93
-	/**
94
-	 * Prepares a single invoice for download.
95
-	 *
96
-	 * @param WPInv_Invoice $invoice The invoice to prepare..
97
-	 * @param array $fields The fields to stream.
98
-	 * @since       1.0.19
99
-	 * @return array
100
-	 */
101
-	public function prepare_row( $invoice, $fields ) {
102
-
103
-		$prepared      = array();
104
-		$amount_fields = $this->get_amount_fields( $invoice->get_post_type() );
105
-
106
-		foreach ( $fields as $field ) {
107
-
108
-			$value  = '';
109
-			$method = "get_$field";
110
-
111
-			if ( method_exists( $invoice, $method ) ) {
112
-				$value  = $invoice->$method();
113
-			}
114
-
115
-			if ( in_array( $field, $amount_fields ) ) {
116
-				$value  = wpinv_round_amount( wpinv_sanitize_amount( $value ) );
117
-			}
118
-
119
-			$prepared[ $field ] = wpinv_clean( $value );
120
-
121
-		}
122
-
123
-		return $prepared;
124
-	}
125
-
126
-	/**
127
-	 * Retrieves export fields.
128
-	 *
129
-	 * @param string $post_type
130
-	 * @since       1.0.19
131
-	 * @return array
132
-	 */
133
-	public function get_export_fields( $post_type ) {
134
-
135
-		$fields = array(
136
-			'id',
137
-			'parent_id',
138
-			'status',
139
-			'date_created',
140
-			'date_modified',
141
-			'date_due',
142
-			'date_completed',
143
-			'number',
144
-			'key',
145
-			'description',
146
-			'post_type',
147
-			'mode',
148
-			'customer_id',
149
-			'customer_first_name',
150
-			'customer_last_name',
151
-			'customer_phone',
152
-			'customer_email',
153
-			'customer_country',
154
-			'customer_city',
155
-			'customer_state',
156
-			'customer_zip',
157
-			'customer_company',
158
-			'customer_vat_number',
159
-			'customer_address',
160
-			'subtotal',
161
-			'total_discount',
162
-			'total_tax',
163
-			'total_fees',
164
-			'fees',
165
-			'discounts',
166
-			'taxes',
167
-			'cart_details',
168
-			'item_ids',
169
-			'payment_form',
170
-			'discount_code',
171
-			'gateway',
172
-			'transaction_id',
173
-			'currency',
174
-			'disable_taxes',
175
-			'subscription_id',
176
-			'remote_subscription_id',
177
-			'is_viewed',
178
-			'email_cc',
179
-			'template',
180
-			'created_via'
181
-    	);
182
-
183
-		return apply_filters( 'getpaid_invoice_exporter_get_fields', $fields, $post_type );
184
-	}
185
-
186
-	/**
187
-	 * Retrieves amount fields.
188
-	 *
189
-	 * @param string $post_type
190
-	 * @since       1.0.19
191
-	 * @return array
192
-	 */
193
-	public function get_amount_fields( $post_type ) {
194
-
195
-		$fields = array(
196
-			'subtotal',
197
-			'total_discount',
198
-			'total_tax',
199
-			'total_fees'
200
-    	);
201
-
202
-		return apply_filters( 'getpaid_invoice_exporter_get_amount_fields', $fields, $post_type );
203
-	}
15
+    /**
16
+     * Retrieves invoices query args.
17
+     * 
18
+     * @param string $post_type post type to retrieve.
19
+     * @param array $args Args to search for.
20
+     * @return array
21
+     */
22
+    public function get_invoice_query_args( $post_type, $args ) {
23
+
24
+        $query_args = array(
25
+            'post_type'              => $post_type,
26
+            'post_status'            => array_keys( wpinv_get_invoice_statuses( true, false, $post_type ) ),
27
+            'posts_per_page'         => -1,
28
+            'no_found_rows'          => true,
29
+            'update_post_term_cache' => false,
30
+            'fields'                 => 'ids',
31
+        );
32
+
33
+        if ( ! empty( $args['status'] ) && in_array( $args['status'], $query_args['post_status'], true ) ) {
34
+            $query_args['post_status'] = wpinv_clean( wpinv_parse_list( $args['status'] ) );
35
+        }
36
+
37
+        $date_query = array();
38
+        if ( ! empty( $args['to_date'] ) ) {
39
+            $date_query['before'] = wpinv_clean( $args['to_date'] );
40
+        }
41
+
42
+        if ( ! empty( $args['from_date'] ) ) {
43
+            $date_query['after'] = wpinv_clean( $args['from_date'] );
44
+        }
45
+
46
+        if ( ! empty( $date_query ) ) {
47
+            $date_query['inclusive']  = true;
48
+            $query_args['date_query'] = array( $date_query );
49
+        }
50
+
51
+        return $query_args;
52
+    }
53
+
54
+    /**
55
+     * Retrieves invoices.
56
+     * 
57
+     * @param array $query_args WP_Query args.
58
+     * @return WPInv_Invoice[]
59
+     */
60
+    public function get_invoices( $query_args ) {
61
+
62
+        // Get invoices.
63
+        $invoices = new WP_Query( $query_args );
64
+
65
+        // Prepare the results.
66
+        return array_map( 'wpinv_get_invoice', $invoices->posts );
67
+
68
+    }
69
+
70
+    /**
71
+     * Handles the actual download.
72
+     *
73
+     */
74
+    public function export( $post_type, $args ) {
75
+
76
+        $invoices  = $this->get_invoices( $this->get_invoice_query_args( $post_type, $args ) );
77
+        $stream    = $this->prepare_output();
78
+        $headers   = $this->get_export_fields( $post_type );
79
+        $file_type = $this->prepare_file_type( strtolower( getpaid_get_post_type_label( $post_type ) ) );
80
+
81
+        if ( 'csv' == $file_type ) {
82
+            $this->download_csv( $invoices, $stream, $headers );
83
+        } else if( 'xml' == $file_type ) {
84
+            $this->download_xml( $invoices, $stream, $headers );
85
+        } else {
86
+            $this->download_json( $invoices, $stream, $headers );
87
+        }
88
+
89
+        fclose( $stream );
90
+        exit;
91
+    }
92
+
93
+    /**
94
+     * Prepares a single invoice for download.
95
+     *
96
+     * @param WPInv_Invoice $invoice The invoice to prepare..
97
+     * @param array $fields The fields to stream.
98
+     * @since       1.0.19
99
+     * @return array
100
+     */
101
+    public function prepare_row( $invoice, $fields ) {
102
+
103
+        $prepared      = array();
104
+        $amount_fields = $this->get_amount_fields( $invoice->get_post_type() );
105
+
106
+        foreach ( $fields as $field ) {
107
+
108
+            $value  = '';
109
+            $method = "get_$field";
110
+
111
+            if ( method_exists( $invoice, $method ) ) {
112
+                $value  = $invoice->$method();
113
+            }
114
+
115
+            if ( in_array( $field, $amount_fields ) ) {
116
+                $value  = wpinv_round_amount( wpinv_sanitize_amount( $value ) );
117
+            }
118
+
119
+            $prepared[ $field ] = wpinv_clean( $value );
120
+
121
+        }
122
+
123
+        return $prepared;
124
+    }
125
+
126
+    /**
127
+     * Retrieves export fields.
128
+     *
129
+     * @param string $post_type
130
+     * @since       1.0.19
131
+     * @return array
132
+     */
133
+    public function get_export_fields( $post_type ) {
134
+
135
+        $fields = array(
136
+            'id',
137
+            'parent_id',
138
+            'status',
139
+            'date_created',
140
+            'date_modified',
141
+            'date_due',
142
+            'date_completed',
143
+            'number',
144
+            'key',
145
+            'description',
146
+            'post_type',
147
+            'mode',
148
+            'customer_id',
149
+            'customer_first_name',
150
+            'customer_last_name',
151
+            'customer_phone',
152
+            'customer_email',
153
+            'customer_country',
154
+            'customer_city',
155
+            'customer_state',
156
+            'customer_zip',
157
+            'customer_company',
158
+            'customer_vat_number',
159
+            'customer_address',
160
+            'subtotal',
161
+            'total_discount',
162
+            'total_tax',
163
+            'total_fees',
164
+            'fees',
165
+            'discounts',
166
+            'taxes',
167
+            'cart_details',
168
+            'item_ids',
169
+            'payment_form',
170
+            'discount_code',
171
+            'gateway',
172
+            'transaction_id',
173
+            'currency',
174
+            'disable_taxes',
175
+            'subscription_id',
176
+            'remote_subscription_id',
177
+            'is_viewed',
178
+            'email_cc',
179
+            'template',
180
+            'created_via'
181
+        );
182
+
183
+        return apply_filters( 'getpaid_invoice_exporter_get_fields', $fields, $post_type );
184
+    }
185
+
186
+    /**
187
+     * Retrieves amount fields.
188
+     *
189
+     * @param string $post_type
190
+     * @since       1.0.19
191
+     * @return array
192
+     */
193
+    public function get_amount_fields( $post_type ) {
194
+
195
+        $fields = array(
196
+            'subtotal',
197
+            'total_discount',
198
+            'total_tax',
199
+            'total_fees'
200
+        );
201
+
202
+        return apply_filters( 'getpaid_invoice_exporter_get_amount_fields', $fields, $post_type );
203
+    }
204 204
 
205 205
 }
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 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
  * GetPaid_Invoice_Exporter Class.
@@ -19,33 +19,33 @@  discard block
 block discarded – undo
19 19
 	 * @param array $args Args to search for.
20 20
 	 * @return array
21 21
 	 */
22
-	public function get_invoice_query_args( $post_type, $args ) {
22
+	public function get_invoice_query_args($post_type, $args) {
23 23
 
24 24
 		$query_args = array(
25 25
 			'post_type'              => $post_type,
26
-			'post_status'            => array_keys( wpinv_get_invoice_statuses( true, false, $post_type ) ),
26
+			'post_status'            => array_keys(wpinv_get_invoice_statuses(true, false, $post_type)),
27 27
 			'posts_per_page'         => -1,
28 28
 			'no_found_rows'          => true,
29 29
 			'update_post_term_cache' => false,
30 30
 			'fields'                 => 'ids',
31 31
 		);
32 32
 
33
-		if ( ! empty( $args['status'] ) && in_array( $args['status'], $query_args['post_status'], true ) ) {
34
-			$query_args['post_status'] = wpinv_clean( wpinv_parse_list( $args['status'] ) );
33
+		if (!empty($args['status']) && in_array($args['status'], $query_args['post_status'], true)) {
34
+			$query_args['post_status'] = wpinv_clean(wpinv_parse_list($args['status']));
35 35
 		}
36 36
 
37 37
 		$date_query = array();
38
-		if ( ! empty( $args['to_date'] ) ) {
39
-			$date_query['before'] = wpinv_clean( $args['to_date'] );
38
+		if (!empty($args['to_date'])) {
39
+			$date_query['before'] = wpinv_clean($args['to_date']);
40 40
 		}
41 41
 
42
-		if ( ! empty( $args['from_date'] ) ) {
43
-			$date_query['after'] = wpinv_clean( $args['from_date'] );
42
+		if (!empty($args['from_date'])) {
43
+			$date_query['after'] = wpinv_clean($args['from_date']);
44 44
 		}
45 45
 
46
-		if ( ! empty( $date_query ) ) {
46
+		if (!empty($date_query)) {
47 47
 			$date_query['inclusive']  = true;
48
-			$query_args['date_query'] = array( $date_query );
48
+			$query_args['date_query'] = array($date_query);
49 49
 		}
50 50
 
51 51
 		return $query_args;
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
 	 * @param array $query_args WP_Query args.
58 58
 	 * @return WPInv_Invoice[]
59 59
 	 */
60
-	public function get_invoices( $query_args ) {
60
+	public function get_invoices($query_args) {
61 61
 
62 62
 		// Get invoices.
63
-		$invoices = new WP_Query( $query_args );
63
+		$invoices = new WP_Query($query_args);
64 64
 
65 65
 		// Prepare the results.
66
-		return array_map( 'wpinv_get_invoice', $invoices->posts );
66
+		return array_map('wpinv_get_invoice', $invoices->posts);
67 67
 
68 68
 	}
69 69
 
@@ -71,22 +71,22 @@  discard block
 block discarded – undo
71 71
 	 * Handles the actual download.
72 72
 	 *
73 73
 	 */
74
-	public function export( $post_type, $args ) {
74
+	public function export($post_type, $args) {
75 75
 
76
-		$invoices  = $this->get_invoices( $this->get_invoice_query_args( $post_type, $args ) );
76
+		$invoices  = $this->get_invoices($this->get_invoice_query_args($post_type, $args));
77 77
 		$stream    = $this->prepare_output();
78
-		$headers   = $this->get_export_fields( $post_type );
79
-		$file_type = $this->prepare_file_type( strtolower( getpaid_get_post_type_label( $post_type ) ) );
78
+		$headers   = $this->get_export_fields($post_type);
79
+		$file_type = $this->prepare_file_type(strtolower(getpaid_get_post_type_label($post_type)));
80 80
 
81
-		if ( 'csv' == $file_type ) {
82
-			$this->download_csv( $invoices, $stream, $headers );
83
-		} else if( 'xml' == $file_type ) {
84
-			$this->download_xml( $invoices, $stream, $headers );
81
+		if ('csv' == $file_type) {
82
+			$this->download_csv($invoices, $stream, $headers);
83
+		} else if ('xml' == $file_type) {
84
+			$this->download_xml($invoices, $stream, $headers);
85 85
 		} else {
86
-			$this->download_json( $invoices, $stream, $headers );
86
+			$this->download_json($invoices, $stream, $headers);
87 87
 		}
88 88
 
89
-		fclose( $stream );
89
+		fclose($stream);
90 90
 		exit;
91 91
 	}
92 92
 
@@ -98,25 +98,25 @@  discard block
 block discarded – undo
98 98
 	 * @since       1.0.19
99 99
 	 * @return array
100 100
 	 */
101
-	public function prepare_row( $invoice, $fields ) {
101
+	public function prepare_row($invoice, $fields) {
102 102
 
103 103
 		$prepared      = array();
104
-		$amount_fields = $this->get_amount_fields( $invoice->get_post_type() );
104
+		$amount_fields = $this->get_amount_fields($invoice->get_post_type());
105 105
 
106
-		foreach ( $fields as $field ) {
106
+		foreach ($fields as $field) {
107 107
 
108 108
 			$value  = '';
109 109
 			$method = "get_$field";
110 110
 
111
-			if ( method_exists( $invoice, $method ) ) {
112
-				$value  = $invoice->$method();
111
+			if (method_exists($invoice, $method)) {
112
+				$value = $invoice->$method();
113 113
 			}
114 114
 
115
-			if ( in_array( $field, $amount_fields ) ) {
116
-				$value  = wpinv_round_amount( wpinv_sanitize_amount( $value ) );
115
+			if (in_array($field, $amount_fields)) {
116
+				$value = wpinv_round_amount(wpinv_sanitize_amount($value));
117 117
 			}
118 118
 
119
-			$prepared[ $field ] = wpinv_clean( $value );
119
+			$prepared[$field] = wpinv_clean($value);
120 120
 
121 121
 		}
122 122
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 * @since       1.0.19
131 131
 	 * @return array
132 132
 	 */
133
-	public function get_export_fields( $post_type ) {
133
+	public function get_export_fields($post_type) {
134 134
 
135 135
 		$fields = array(
136 136
 			'id',
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 			'created_via'
181 181
     	);
182 182
 
183
-		return apply_filters( 'getpaid_invoice_exporter_get_fields', $fields, $post_type );
183
+		return apply_filters('getpaid_invoice_exporter_get_fields', $fields, $post_type);
184 184
 	}
185 185
 
186 186
 	/**
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	 * @since       1.0.19
191 191
 	 * @return array
192 192
 	 */
193
-	public function get_amount_fields( $post_type ) {
193
+	public function get_amount_fields($post_type) {
194 194
 
195 195
 		$fields = array(
196 196
 			'subtotal',
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 			'total_fees'
200 200
     	);
201 201
 
202
-		return apply_filters( 'getpaid_invoice_exporter_get_amount_fields', $fields, $post_type );
202
+		return apply_filters('getpaid_invoice_exporter_get_amount_fields', $fields, $post_type);
203 203
 	}
204 204
 
205 205
 }
Please login to merge, or discard this patch.
includes/admin/views/html-tax-rates-edit.php 1 patch
Spacing   +20 added lines, -20 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
 $tax_rates  = GetPaid_Tax::get_all_tax_rates();
10 10
 $dummy_rate = array(
@@ -13,12 +13,12 @@  discard block
 block discarded – undo
13 13
     'global'       => true,
14 14
     'rate'         => wpinv_get_default_tax_rate(),
15 15
     'reduced_rate' => 5,
16
-    'name'         => __( 'VAT', 'invoicing' ),
16
+    'name'         => __('VAT', 'invoicing'),
17 17
 );
18 18
 
19 19
 $reset_url = esc_url(
20 20
     wp_nonce_url(
21
-        add_query_arg( 'getpaid-admin-action', 'reset_tax_rates' ),
21
+        add_query_arg('getpaid-admin-action', 'reset_tax_rates'),
22 22
         'getpaid-nonce',
23 23
         'getpaid-nonce'
24 24
     )
@@ -27,34 +27,34 @@  discard block
 block discarded – undo
27 27
 ?>
28 28
 <div class="table-responsive">
29 29
     <table id="wpinv_tax_rates" class="widefat fixed table">
30
-        <caption><?php echo esc_html_e( 'Enter tax rates for specific regions.', 'invoicing' ); ?></caption>
30
+        <caption><?php echo esc_html_e('Enter tax rates for specific regions.', 'invoicing'); ?></caption>
31 31
 
32 32
         <thead>
33 33
             <tr class="table-light">
34 34
 
35 35
                 <th scope="col" class="border-bottom border-top">
36
-                    <?php _e( 'Country', 'invoicing' ); ?>
37
-                    <?php echo getpaid_get_help_tip( __( 'Optionally limit this tax rate to a specific country.', 'invoicing' ), 'position-static' ); ?>
36
+                    <?php _e('Country', 'invoicing'); ?>
37
+                    <?php echo getpaid_get_help_tip(__('Optionally limit this tax rate to a specific country.', 'invoicing'), 'position-static'); ?>
38 38
                 </th>
39 39
 
40 40
                 <th scope="col" class="border-bottom border-top">
41
-                    <?php _e( 'State', 'invoicing' ); ?>
42
-                    <?php echo getpaid_get_help_tip( __( 'Separate state codes using a comma or leave blank to apply country wide.', 'invoicing' ), 'position-static' ); ?>
41
+                    <?php _e('State', 'invoicing'); ?>
42
+                    <?php echo getpaid_get_help_tip(__('Separate state codes using a comma or leave blank to apply country wide.', 'invoicing'), 'position-static'); ?>
43 43
                 </th>
44 44
 
45 45
                 <th scope="col" class="border-bottom border-top">
46
-                    <?php _e( 'Standard Rate %', 'invoicing' ); ?>
47
-                    <?php echo getpaid_get_help_tip( __( 'The tax rate (percentage) to charge on items that use the "Standard rate" tax class.', 'invoicing' ), 'position-static' ); ?>
46
+                    <?php _e('Standard Rate %', 'invoicing'); ?>
47
+                    <?php echo getpaid_get_help_tip(__('The tax rate (percentage) to charge on items that use the "Standard rate" tax class.', 'invoicing'), 'position-static'); ?>
48 48
                 </th>
49 49
 
50 50
                 <th scope="col" class="border-bottom border-top">
51
-                    <?php _e( 'Reduced Rate %', 'invoicing' ); ?>
52
-                    <?php echo getpaid_get_help_tip( __( 'The tax rate (percentage) to charge on items that use the "Reduced rate" tax class.', 'invoicing' ), 'position-static' ); ?>
51
+                    <?php _e('Reduced Rate %', 'invoicing'); ?>
52
+                    <?php echo getpaid_get_help_tip(__('The tax rate (percentage) to charge on items that use the "Reduced rate" tax class.', 'invoicing'), 'position-static'); ?>
53 53
                 </th>
54 54
 
55 55
                 <th scope="col" class="border-bottom border-top">
56
-                    <?php _e( 'Tax Name', 'invoicing' ); ?>
57
-                    <?php echo getpaid_get_help_tip( __( 'The name of this tax, e.g VAT.', 'invoicing' ), 'position-static' ); ?>
56
+                    <?php _e('Tax Name', 'invoicing'); ?>
57
+                    <?php echo getpaid_get_help_tip(__('The name of this tax, e.g VAT.', 'invoicing'), 'position-static'); ?>
58 58
                 </th>
59 59
 
60 60
                 <th scope="col" class="border-bottom border-top" style="width:32px">&nbsp;</th>
@@ -63,19 +63,19 @@  discard block
 block discarded – undo
63 63
         </thead>
64 64
 
65 65
         <tbody>
66
-            <?php array_walk( $tax_rates, 'wpinv_tax_rate_callback' ); ?>
66
+            <?php array_walk($tax_rates, 'wpinv_tax_rate_callback'); ?>
67 67
         </tbody>
68 68
 
69 69
         <tfoot>
70 70
             <tr class="table-light">
71 71
                 <td colspan="6" class="border-top">
72 72
 
73
-                    <button type="button" class="button button-secondary wpinv_add_tax_rate" aria-label="<?php esc_attr_e( 'Add Tax Rate', 'invoicing' ); ?>">
74
-                        <span><?php _e( 'Add Tax Rate', 'invoicing' ); ?></span>
73
+                    <button type="button" class="button button-secondary wpinv_add_tax_rate" aria-label="<?php esc_attr_e('Add Tax Rate', 'invoicing'); ?>">
74
+                        <span><?php _e('Add Tax Rate', 'invoicing'); ?></span>
75 75
                     </button>
76 76
 
77
-                    <a href="<?php echo $reset_url; ?>" class="button button-secondary wpinv_reset_tax_rates" aria-label="<?php esc_attr_e( 'Reset Tax Rates', 'invoicing' ); ?>">
78
-                        <span><?php _e( 'Reset Tax Rates', 'invoicing' ); ?></span>
77
+                    <a href="<?php echo $reset_url; ?>" class="button button-secondary wpinv_reset_tax_rates" aria-label="<?php esc_attr_e('Reset Tax Rates', 'invoicing'); ?>">
78
+                        <span><?php _e('Reset Tax Rates', 'invoicing'); ?></span>
79 79
                     </a>
80 80
                 </td>
81 81
             </tr>
@@ -84,6 +84,6 @@  discard block
 block discarded – undo
84 84
 </div>
85 85
 
86 86
 <script type="text/html" id="tmpl-wpinv-tax-rate-row">
87
-    <?php echo wpinv_tax_rate_callback( $dummy_rate, 0, false ); ?>
87
+    <?php echo wpinv_tax_rate_callback($dummy_rate, 0, false); ?>
88 88
 </script>
89 89
 
Please login to merge, or discard this patch.
includes/admin/views/html-tax-rate-edit.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @var array $tax_rate
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 ?>
12 12
 
@@ -18,54 +18,54 @@  discard block
 block discarded – undo
18 18
             $country = aui()->select(
19 19
                 array(
20 20
                     'options'     => array_merge(
21
-                        array( '' => __( 'All Countries', 'invoicing' ) ),
21
+                        array('' => __('All Countries', 'invoicing')),
22 22
                         wpinv_get_country_list()
23 23
                     ),
24 24
                     'name'        => "tax_rates[$key][country]",
25
-                    'id'          => uniqid( 'tax_rate_country' ),
26
-                    'value'       => sanitize_text_field( $tax_rate['country'] ),
27
-                    'label'       => __( 'Country', 'invoicing' ),
25
+                    'id'          => uniqid('tax_rate_country'),
26
+                    'value'       => sanitize_text_field($tax_rate['country']),
27
+                    'label'       => __('Country', 'invoicing'),
28 28
                     'class'       => 'wpinv_country',
29 29
                     'no_wrap'     => true,
30 30
                 )
31 31
             );
32 32
 
33
-            echo str_replace( 'custom-select', '', $country );
33
+            echo str_replace('custom-select', '', $country);
34 34
         ?>
35 35
     </td>
36 36
 
37 37
     <td class="wpinv_tax_state">
38 38
 
39 39
         <label class="w-100">
40
-            <span class="screen-reader-text"><?php _e( 'States', 'invoicing' ); ?></span>
41
-            <input type="text" placeholder="<?php esc_attr_e( 'Apply to whole country', 'invoicing' ); ?>" name="tax_rates[<?php echo $key ?>][state]" value="<?php echo empty( $tax_rate['global'] ) ? sanitize_text_field( $tax_rate['state'] ) : ''; ?>"/>
40
+            <span class="screen-reader-text"><?php _e('States', 'invoicing'); ?></span>
41
+            <input type="text" placeholder="<?php esc_attr_e('Apply to whole country', 'invoicing'); ?>" name="tax_rates[<?php echo $key ?>][state]" value="<?php echo empty($tax_rate['global']) ? sanitize_text_field($tax_rate['state']) : ''; ?>"/>
42 42
         </label>
43 43
 
44 44
     </td>
45 45
 
46 46
     <td class="wpinv_standard_rate">
47 47
         <label class="w-100">
48
-            <span class="screen-reader-text"><?php _e( 'Standard Rate', 'invoicing' ); ?></span>
49
-            <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo $key ?>][rate]" value="<?php echo wpinv_sanitize_amount( $tax_rate['rate'] ); ?>"/>
48
+            <span class="screen-reader-text"><?php _e('Standard Rate', 'invoicing'); ?></span>
49
+            <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo $key ?>][rate]" value="<?php echo wpinv_sanitize_amount($tax_rate['rate']); ?>"/>
50 50
         </label>
51 51
     </td>
52 52
 
53 53
     <td class="wpinv_reduced_rate">
54 54
         <label class="w-100">
55
-            <span class="screen-reader-text"><?php _e( 'Reduced Rate', 'invoicing' ); ?></span>
56
-            <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo $key ?>][reduced_rate]" value="<?php echo wpinv_sanitize_amount( $tax_rate['reduced_rate'] ); ?>"/>
55
+            <span class="screen-reader-text"><?php _e('Reduced Rate', 'invoicing'); ?></span>
56
+            <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo $key ?>][reduced_rate]" value="<?php echo wpinv_sanitize_amount($tax_rate['reduced_rate']); ?>"/>
57 57
         </label>
58 58
     </td>
59 59
 
60 60
     <td class="wpinv_tax_name">
61 61
         <label class="w-100">
62
-            <span class="screen-reader-text"><?php _e( 'Tax Name', 'invoicing' ); ?></span>
63
-            <input type="text" name="tax_rates[<?php echo $key ?>][name]" value="<?php echo sanitize_text_field( $tax_rate['name'] ); ?>"/>
62
+            <span class="screen-reader-text"><?php _e('Tax Name', 'invoicing'); ?></span>
63
+            <input type="text" name="tax_rates[<?php echo $key ?>][name]" value="<?php echo sanitize_text_field($tax_rate['name']); ?>"/>
64 64
         </label>
65 65
     </td>
66 66
 
67 67
     <td class="wpinv_tax_remove">
68
-        <button type="button" class="close wpinv_remove_tax_rate" aria-label="<?php esc_attr_e( 'Delete', 'invoicing' ); ?>" title="<?php esc_attr_e( 'Delete', 'invoicing' ); ?>">
68
+        <button type="button" class="close wpinv_remove_tax_rate" aria-label="<?php esc_attr_e('Delete', 'invoicing'); ?>" title="<?php esc_attr_e('Delete', 'invoicing'); ?>">
69 69
             <span aria-hidden="true">&times;</span>
70 70
         </button>
71 71
     </td>
Please login to merge, or discard this patch.
includes/admin/register-settings.php 3 patches
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -611,10 +611,11 @@
 block discarded – undo
611 611
 	foreach ( $args['options'] as $key => $option ) :
612 612
 		$sanitize_key = wpinv_sanitize_key( $key );
613 613
         
614
-        if ( isset( $wpinv_options['gateways'][ $key ] ) )
615
-			$enabled = '1';
616
-		else
617
-			$enabled = null;
614
+        if ( isset( $wpinv_options['gateways'][ $key ] ) ) {
615
+        			$enabled = '1';
616
+        } else {
617
+					$enabled = null;
618
+		}
618 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;';
620 621
 		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
Please login to merge, or discard this patch.
Indentation   +288 added lines, -288 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(
@@ -227,8 +227,8 @@  discard block
 block discarded – undo
227 227
             'faux'        => isset( $option['faux'] )        ? $option['faux']        : false,
228 228
             'onchange'    => isset( $option['onchange'] )   ? $option['onchange']     : '',
229 229
             'custom'      => isset( $option['custom'] )     ? $option['custom']       : '',
230
-			'class'       => isset( $option['class'] )     ? $option['class']         : '',
231
-			'style'       => isset( $option['style'] )     ? $option['style']         : '',
230
+            'class'       => isset( $option['class'] )     ? $option['class']         : '',
231
+            'style'       => isset( $option['style'] )     ? $option['style']         : '',
232 232
             'cols'        => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
233 233
             'rows'        => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
234 234
         )
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
  * @return array
243 243
  */
244 244
 function wpinv_get_registered_settings() {
245
-	return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
245
+    return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
246 246
 }
247 247
 
248 248
 /**
@@ -289,10 +289,10 @@  discard block
 block discarded – undo
289 289
         }
290 290
 
291 291
         // General filter
292
-		$input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
292
+        $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
293 293
 
294
-		// Key specific filter.
295
-		$input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
294
+        // Key specific filter.
295
+        $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
296 296
     }
297 297
 
298 298
     // Loop through the whitelist and unset any that are empty for the tab being saved
@@ -348,14 +348,14 @@  discard block
 block discarded – undo
348 348
 
349 349
     foreach ( $new_rates as $rate ) {
350 350
 
351
-		$rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
352
-		$rate['name']    = sanitize_text_field( $rate['name'] );
353
-		$rate['state']   = sanitize_text_field( $rate['state'] );
354
-		$rate['country'] = sanitize_text_field( $rate['country'] );
355
-		$rate['global']  = empty( $rate['state'] );
356
-		$tax_rates[]     = $rate;
351
+        $rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
352
+        $rate['name']    = sanitize_text_field( $rate['name'] );
353
+        $rate['state']   = sanitize_text_field( $rate['state'] );
354
+        $rate['country'] = sanitize_text_field( $rate['country'] );
355
+        $rate['global']  = empty( $rate['state'] );
356
+        $tax_rates[]     = $rate;
357 357
 
358
-	}
358
+    }
359 359
 
360 360
     update_option( 'wpinv_tax_rates', $tax_rates );
361 361
 
@@ -373,11 +373,11 @@  discard block
 block discarded – undo
373 373
     $tabs['general']  = __( 'General', 'invoicing' );
374 374
     $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
375 375
     $tabs['taxes']    = __( 'Taxes', 'invoicing' );
376
-	$tabs['emails']   = __( 'Emails', 'invoicing' );
376
+    $tabs['emails']   = __( 'Emails', 'invoicing' );
377 377
 
378
-	if ( count( getpaid_get_integration_settings() ) > 0 ) {
379
-		$tabs['integrations'] = __( 'Integrations', 'invoicing' );
380
-	}
378
+    if ( count( getpaid_get_integration_settings() ) > 0 ) {
379
+        $tabs['integrations'] = __( 'Integrations', 'invoicing' );
380
+    }
381 381
 
382 382
     $tabs['privacy']  = __( 'Privacy', 'invoicing' );
383 383
     $tabs['misc']     = __( 'Misc', 'invoicing' );
@@ -417,14 +417,14 @@  discard block
 block discarded – undo
417 417
         ) ),
418 418
         'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array(
419 419
             'main'  => __( 'Tax Settings', 'invoicing' ),
420
-			'rates' => __( 'Tax Rates', 'invoicing' ),
421
-			'vat'   => __( 'EU VAT Settings', 'invoicing' )
420
+            'rates' => __( 'Tax Rates', 'invoicing' ),
421
+            'vat'   => __( 'EU VAT Settings', 'invoicing' )
422 422
         ) ),
423 423
         'emails' => apply_filters( 'wpinv_settings_sections_emails', array(
424 424
             'main' => __( 'Email Settings', 'invoicing' ),
425
-		) ),
425
+        ) ),
426 426
 
427
-		'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
427
+        'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
428 428
 
429 429
         'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array(
430 430
             'main' => __( 'Privacy policy', 'invoicing' ),
@@ -444,51 +444,51 @@  discard block
 block discarded – undo
444 444
 }
445 445
 
446 446
 function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
447
-	$pages_options = array();
447
+    $pages_options = array();
448 448
 
449
-	if( $default_label !== NULL && $default_label !== false ) {
450
-		$pages_options = array( '' => $default_label ); // Blank option
451
-	}
449
+    if( $default_label !== NULL && $default_label !== false ) {
450
+        $pages_options = array( '' => $default_label ); // Blank option
451
+    }
452 452
 
453
-	$pages = get_pages();
454
-	if ( $pages ) {
455
-		foreach ( $pages as $page ) {
456
-			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
453
+    $pages = get_pages();
454
+    if ( $pages ) {
455
+        foreach ( $pages as $page ) {
456
+            $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
457 457
             $pages_options[ $page->ID ] = $title;
458
-		}
459
-	}
458
+        }
459
+    }
460 460
 
461
-	return $pages_options;
461
+    return $pages_options;
462 462
 }
463 463
 
464 464
 function wpinv_header_callback( $args ) {
465
-	if ( !empty( $args['desc'] ) ) {
465
+    if ( !empty( $args['desc'] ) ) {
466 466
         echo $args['desc'];
467 467
     }
468 468
 }
469 469
 
470 470
 function wpinv_hidden_callback( $args ) {
471
-	global $wpinv_options;
472
-
473
-	if ( isset( $args['set_value'] ) ) {
474
-		$value = $args['set_value'];
475
-	} elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
476
-		$value = $wpinv_options[ $args['id'] ];
477
-	} else {
478
-		$value = isset( $args['std'] ) ? $args['std'] : '';
479
-	}
480
-
481
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
482
-		$args['readonly'] = true;
483
-		$value = isset( $args['std'] ) ? $args['std'] : '';
484
-		$name  = '';
485
-	} else {
486
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
487
-	}
488
-
489
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
471
+    global $wpinv_options;
472
+
473
+    if ( isset( $args['set_value'] ) ) {
474
+        $value = $args['set_value'];
475
+    } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
476
+        $value = $wpinv_options[ $args['id'] ];
477
+    } else {
478
+        $value = isset( $args['std'] ) ? $args['std'] : '';
479
+    }
480
+
481
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
482
+        $args['readonly'] = true;
483
+        $value = isset( $args['std'] ) ? $args['std'] : '';
484
+        $name  = '';
485
+    } else {
486
+        $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
487
+    }
488
+
489
+    $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
490 490
     
491
-	echo $html;
491
+    echo $html;
492 492
 }
493 493
 
494 494
 /**
@@ -496,12 +496,12 @@  discard block
 block discarded – undo
496 496
  */
497 497
 function wpinv_checkbox_callback( $args ) {
498 498
 
499
-	$std = isset( $args['std'] ) ? $args['std'] : '';
500
-	$std = wpinv_get_option( $args['id'], $std );
501
-	$id  = esc_attr( $args['id'] );
499
+    $std = isset( $args['std'] ) ? $args['std'] : '';
500
+    $std = wpinv_get_option( $args['id'], $std );
501
+    $id  = esc_attr( $args['id'] );
502 502
 
503
-	getpaid_hidden_field( "wpinv_settings[$id]", '0' );
504
-	?>
503
+    getpaid_hidden_field( "wpinv_settings[$id]", '0' );
504
+    ?>
505 505
 		<fieldset>
506 506
 			<label>
507 507
 				<input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox">
@@ -513,77 +513,77 @@  discard block
 block discarded – undo
513 513
 
514 514
 function wpinv_multicheck_callback( $args ) {
515 515
 	
516
-	global $wpinv_options;
516
+    global $wpinv_options;
517 517
 
518
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
519
-	$class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
518
+    $sanitize_id = wpinv_sanitize_key( $args['id'] );
519
+    $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
520 520
 
521
-	if ( ! empty( $args['options'] ) ) {
521
+    if ( ! empty( $args['options'] ) ) {
522 522
 
523
-		$std     = isset( $args['std'] ) ? $args['std'] : array();
524
-		$value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
523
+        $std     = isset( $args['std'] ) ? $args['std'] : array();
524
+        $value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
525 525
 
526
-		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
526
+        echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
527 527
         foreach( $args['options'] as $key => $option ):
528
-			$sanitize_key = wpinv_sanitize_key( $key );
529
-			if ( in_array( $sanitize_key, $value ) ) { 
530
-				$enabled = $sanitize_key;
531
-			} else { 
532
-				$enabled = NULL; 
533
-			}
534
-			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;';
535
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
536
-		endforeach;
537
-		echo '</div>';
538
-		echo '<p class="description">' . $args['desc'] . '</p>';
539
-	}
528
+            $sanitize_key = wpinv_sanitize_key( $key );
529
+            if ( in_array( $sanitize_key, $value ) ) { 
530
+                $enabled = $sanitize_key;
531
+            } else { 
532
+                $enabled = NULL; 
533
+            }
534
+            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;';
535
+            echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
536
+        endforeach;
537
+        echo '</div>';
538
+        echo '<p class="description">' . $args['desc'] . '</p>';
539
+    }
540 540
 }
541 541
 
542 542
 function wpinv_payment_icons_callback( $args ) {
543
-	global $wpinv_options;
543
+    global $wpinv_options;
544 544
     
545 545
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
546 546
 
547
-	if ( ! empty( $args['options'] ) ) {
548
-		foreach( $args['options'] as $key => $option ) {
547
+    if ( ! empty( $args['options'] ) ) {
548
+        foreach( $args['options'] as $key => $option ) {
549 549
             $sanitize_key = wpinv_sanitize_key( $key );
550 550
             
551
-			if( isset( $wpinv_options[$args['id']][$key] ) ) {
552
-				$enabled = $option;
553
-			} else {
554
-				$enabled = NULL;
555
-			}
556
-
557
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
558
-
559
-				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;';
560
-
561
-				if ( wpinv_string_is_image_url( $key ) ) {
562
-					echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
563
-				} else {
564
-					$card = strtolower( str_replace( ' ', '', $option ) );
565
-
566
-					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
567
-						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
568
-					} else {
569
-						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
570
-						$content_dir = WP_CONTENT_DIR;
571
-
572
-						if ( function_exists( 'wp_normalize_path' ) ) {
573
-							// Replaces backslashes with forward slashes for Windows systems
574
-							$image = wp_normalize_path( $image );
575
-							$content_dir = wp_normalize_path( $content_dir );
576
-						}
577
-
578
-						$image = str_replace( $content_dir, content_url(), $image );
579
-					}
580
-
581
-					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
582
-				}
583
-			echo $option . '</label>';
584
-		}
585
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
586
-	}
551
+            if( isset( $wpinv_options[$args['id']][$key] ) ) {
552
+                $enabled = $option;
553
+            } else {
554
+                $enabled = NULL;
555
+            }
556
+
557
+            echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
558
+
559
+                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;';
560
+
561
+                if ( wpinv_string_is_image_url( $key ) ) {
562
+                    echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
563
+                } else {
564
+                    $card = strtolower( str_replace( ' ', '', $option ) );
565
+
566
+                    if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
567
+                        $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
568
+                    } else {
569
+                        $image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
570
+                        $content_dir = WP_CONTENT_DIR;
571
+
572
+                        if ( function_exists( 'wp_normalize_path' ) ) {
573
+                            // Replaces backslashes with forward slashes for Windows systems
574
+                            $image = wp_normalize_path( $image );
575
+                            $content_dir = wp_normalize_path( $content_dir );
576
+                        }
577
+
578
+                        $image = str_replace( $content_dir, content_url(), $image );
579
+                    }
580
+
581
+                    echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
582
+                }
583
+            echo $option . '</label>';
584
+        }
585
+        echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
586
+    }
587 587
 }
588 588
 
589 589
 /**
@@ -591,9 +591,9 @@  discard block
 block discarded – undo
591 591
  */
592 592
 function wpinv_radio_callback( $args ) {
593 593
 
594
-	$std = isset( $args['std'] ) ? $args['std'] : '';
595
-	$std = wpinv_get_option( $args['id'], $std );
596
-	?>
594
+    $std = isset( $args['std'] ) ? $args['std'] : '';
595
+    $std = wpinv_get_option( $args['id'], $std );
596
+    ?>
597 597
 		<fieldset>
598 598
 			<ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;">
599 599
 				<?php foreach( $args['options'] as $key => $option ) : ?>
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 			</ul>
608 608
 		</fieldset>
609 609
 	<?php
610
-	getpaid_settings_description_callback( $args );
610
+    getpaid_settings_description_callback( $args );
611 611
 }
612 612
 
613 613
 /**
@@ -615,50 +615,50 @@  discard block
 block discarded – undo
615 615
  */
616 616
 function getpaid_settings_description_callback( $args ) {
617 617
 
618
-	if ( ! empty( $args['desc'] ) ) {
619
-		$description = wp_kses_post( $args['desc'] );
620
-		echo "<p class='description'>$description</p>";
621
-	}
618
+    if ( ! empty( $args['desc'] ) ) {
619
+        $description = wp_kses_post( $args['desc'] );
620
+        echo "<p class='description'>$description</p>";
621
+    }
622 622
 
623 623
 }
624 624
 
625 625
 function wpinv_gateways_callback( $args ) {
626
-	global $wpinv_options;
626
+    global $wpinv_options;
627 627
     
628 628
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
629 629
 
630
-	foreach ( $args['options'] as $key => $option ) :
631
-		$sanitize_key = wpinv_sanitize_key( $key );
630
+    foreach ( $args['options'] as $key => $option ) :
631
+        $sanitize_key = wpinv_sanitize_key( $key );
632 632
         
633 633
         if ( isset( $wpinv_options['gateways'][ $key ] ) )
634
-			$enabled = '1';
635
-		else
636
-			$enabled = null;
634
+            $enabled = '1';
635
+        else
636
+            $enabled = null;
637 637
 
638
-		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;';
639
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
640
-	endforeach;
638
+        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;';
639
+        echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
640
+    endforeach;
641 641
 }
642 642
 
643 643
 function wpinv_gateway_select_callback($args) {
644
-	global $wpinv_options;
644
+    global $wpinv_options;
645 645
     
646 646
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
647 647
     $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
648 648
 
649
-	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
649
+    echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
650 650
 
651
-	foreach ( $args['options'] as $key => $option ) :
652
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
651
+    foreach ( $args['options'] as $key => $option ) :
652
+        if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
653 653
             $selected = selected( $key, $args['selected'], false );
654 654
         } else {
655 655
             $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : '';
656 656
         }
657
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
658
-	endforeach;
657
+        echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
658
+    endforeach;
659 659
 
660
-	echo '</select>';
661
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
660
+    echo '</select>';
661
+    echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
662 662
 }
663 663
 
664 664
 /**
@@ -669,29 +669,29 @@  discard block
 block discarded – undo
669 669
  */
670 670
 function wpinv_settings_attrs_helper( $args ) {
671 671
 
672
-	$value        = isset( $args['std'] ) ? $args['std'] : '';
673
-	$id           = esc_attr( $args['id'] );
674
-	$placeholder  = esc_attr( $args['placeholder'] );
672
+    $value        = isset( $args['std'] ) ? $args['std'] : '';
673
+    $id           = esc_attr( $args['id'] );
674
+    $placeholder  = esc_attr( $args['placeholder'] );
675 675
 
676
-	if ( ! empty( $args['faux'] ) ) {
677
-		$args['readonly'] = true;
678
-		$name             = '';
679
-	} else {
680
-		$value  = wpinv_get_option( $args['id'], $value );
681
-		$name   = "wpinv_settings[$id]";
682
-	}
676
+    if ( ! empty( $args['faux'] ) ) {
677
+        $args['readonly'] = true;
678
+        $name             = '';
679
+    } else {
680
+        $value  = wpinv_get_option( $args['id'], $value );
681
+        $name   = "wpinv_settings[$id]";
682
+    }
683 683
 
684
-	$value    = is_scalar( $value ) ? esc_attr( $value ) : '';
685
-	$class    = esc_attr( $args['class'] );
686
-	$style    = esc_attr( $args['style'] );
687
-	$readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"';
684
+    $value    = is_scalar( $value ) ? esc_attr( $value ) : '';
685
+    $class    = esc_attr( $args['class'] );
686
+    $style    = esc_attr( $args['style'] );
687
+    $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"';
688 688
 
689
-	$onchange = '';
689
+    $onchange = '';
690 690
     if ( ! empty( $args['onchange'] ) ) {
691 691
         $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
692
-	}
692
+    }
693 693
 
694
-	return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly";
694
+    return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly";
695 695
 }
696 696
 
697 697
 /**
@@ -699,11 +699,11 @@  discard block
 block discarded – undo
699 699
  */
700 700
 function wpinv_text_callback( $args ) {
701 701
 
702
-	$desc = wp_kses_post( $args['desc'] );
703
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
704
-	$attr = wpinv_settings_attrs_helper( $args );
702
+    $desc = wp_kses_post( $args['desc'] );
703
+    $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
704
+    $attr = wpinv_settings_attrs_helper( $args );
705 705
 
706
-	?>
706
+    ?>
707 707
 		<label style="width: 100%;">
708 708
 			<input type="text" <?php echo $attr; ?>>
709 709
 			<?php echo $desc; ?>
@@ -717,14 +717,14 @@  discard block
 block discarded – undo
717 717
  */
718 718
 function wpinv_number_callback( $args ) {
719 719
 
720
-	$desc = wp_kses_post( $args['desc'] );
721
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
722
-	$attr = wpinv_settings_attrs_helper( $args );
723
-	$max  = absint( $args['max'] );
724
-	$min  = absint( $args['min'] );
725
-	$step = floatval( $args['step'] );
720
+    $desc = wp_kses_post( $args['desc'] );
721
+    $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
722
+    $attr = wpinv_settings_attrs_helper( $args );
723
+    $max  = absint( $args['max'] );
724
+    $min  = absint( $args['min'] );
725
+    $step = floatval( $args['step'] );
726 726
 
727
-	?>
727
+    ?>
728 728
 		<label style="width: 100%;">
729 729
 			<input type="number" step="<?php echo $step; ?>" max="<?php echo $max; ?>" min="<?php echo $min; ?>" <?php echo $attr; ?>>
730 730
 			<?php echo $desc; ?>
@@ -734,48 +734,48 @@  discard block
 block discarded – undo
734 734
 }
735 735
 
736 736
 function wpinv_textarea_callback( $args ) {
737
-	global $wpinv_options;
737
+    global $wpinv_options;
738 738
     
739 739
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
740 740
 
741
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
742
-		$value = $wpinv_options[ $args['id'] ];
743
-	} else {
744
-		$value = isset( $args['std'] ) ? $args['std'] : '';
745
-	}
741
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
742
+        $value = $wpinv_options[ $args['id'] ];
743
+    } else {
744
+        $value = isset( $args['std'] ) ? $args['std'] : '';
745
+    }
746 746
     
747 747
     $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
748 748
     $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
749 749
 
750
-	$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>';
751
-	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
750
+    $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>';
751
+    $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
752 752
 
753
-	echo $html;
753
+    echo $html;
754 754
 }
755 755
 
756 756
 function wpinv_password_callback( $args ) {
757
-	global $wpinv_options;
757
+    global $wpinv_options;
758 758
     
759 759
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
760 760
 
761
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
762
-		$value = $wpinv_options[ $args['id'] ];
763
-	} else {
764
-		$value = isset( $args['std'] ) ? $args['std'] : '';
765
-	}
761
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
762
+        $value = $wpinv_options[ $args['id'] ];
763
+    } else {
764
+        $value = isset( $args['std'] ) ? $args['std'] : '';
765
+    }
766 766
 
767
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
768
-	$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 ) . '"/>';
769
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
767
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
768
+    $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 ) . '"/>';
769
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
770 770
 
771
-	echo $html;
771
+    echo $html;
772 772
 }
773 773
 
774 774
 function wpinv_missing_callback($args) {
775
-	printf(
776
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
777
-		'<strong>' . $args['id'] . '</strong>'
778
-	);
775
+    printf(
776
+        __( 'The callback function used for the %s setting is missing.', 'invoicing' ),
777
+        '<strong>' . $args['id'] . '</strong>'
778
+    );
779 779
 }
780 780
 
781 781
 /**
@@ -783,13 +783,13 @@  discard block
 block discarded – undo
783 783
  */
784 784
 function wpinv_select_callback( $args ) {
785 785
 
786
-	$desc   = wp_kses_post( $args['desc'] );
787
-	$desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
788
-	$attr   = wpinv_settings_attrs_helper( $args );
789
-	$value  = isset( $args['std'] ) ? $args['std'] : '';
790
-	$value  = wpinv_get_option( $args['id'], $value );
786
+    $desc   = wp_kses_post( $args['desc'] );
787
+    $desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
788
+    $attr   = wpinv_settings_attrs_helper( $args );
789
+    $value  = isset( $args['std'] ) ? $args['std'] : '';
790
+    $value  = wpinv_get_option( $args['id'], $value );
791 791
 
792
-	?>
792
+    ?>
793 793
 		<label style="width: 100%;">
794 794
 			<select <?php echo $attr; ?>>
795 795
 				<?php foreach ( $args['options'] as $option => $name ) : ?>
@@ -803,123 +803,123 @@  discard block
 block discarded – undo
803 803
 }
804 804
 
805 805
 function wpinv_color_select_callback( $args ) {
806
-	global $wpinv_options;
806
+    global $wpinv_options;
807 807
     
808 808
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
809 809
 
810
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
811
-		$value = $wpinv_options[ $args['id'] ];
812
-	} else {
813
-		$value = isset( $args['std'] ) ? $args['std'] : '';
814
-	}
810
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
811
+        $value = $wpinv_options[ $args['id'] ];
812
+    } else {
813
+        $value = isset( $args['std'] ) ? $args['std'] : '';
814
+    }
815 815
 
816
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
816
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
817 817
 
818
-	foreach ( $args['options'] as $option => $color ) {
819
-		$selected = selected( $option, $value, false );
820
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
821
-	}
818
+    foreach ( $args['options'] as $option => $color ) {
819
+        $selected = selected( $option, $value, false );
820
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
821
+    }
822 822
 
823
-	$html .= '</select>';
824
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
823
+    $html .= '</select>';
824
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
825 825
 
826
-	echo $html;
826
+    echo $html;
827 827
 }
828 828
 
829 829
 function wpinv_rich_editor_callback( $args ) {
830
-	global $wpinv_options, $wp_version;
830
+    global $wpinv_options, $wp_version;
831 831
     
832 832
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
833 833
 
834
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
835
-		$value = $wpinv_options[ $args['id'] ];
834
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
835
+        $value = $wpinv_options[ $args['id'] ];
836 836
 
837
-		if( empty( $args['allow_blank'] ) && empty( $value ) ) {
838
-			$value = isset( $args['std'] ) ? $args['std'] : '';
839
-		}
840
-	} else {
841
-		$value = isset( $args['std'] ) ? $args['std'] : '';
842
-	}
837
+        if( empty( $args['allow_blank'] ) && empty( $value ) ) {
838
+            $value = isset( $args['std'] ) ? $args['std'] : '';
839
+        }
840
+    } else {
841
+        $value = isset( $args['std'] ) ? $args['std'] : '';
842
+    }
843 843
 
844
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
844
+    $rows = isset( $args['size'] ) ? $args['size'] : 20;
845 845
 
846
-	$html = '<div class="getpaid-settings-editor-input">';
847
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
848
-		ob_start();
849
-		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 ) );
850
-		$html .= ob_get_clean();
851
-	} else {
852
-		$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>';
853
-	}
846
+    $html = '<div class="getpaid-settings-editor-input">';
847
+    if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
848
+        ob_start();
849
+        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 ) );
850
+        $html .= ob_get_clean();
851
+    } else {
852
+        $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>';
853
+    }
854 854
 
855
-	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
855
+    $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
856 856
 
857
-	echo $html;
857
+    echo $html;
858 858
 }
859 859
 
860 860
 function wpinv_upload_callback( $args ) {
861
-	global $wpinv_options;
861
+    global $wpinv_options;
862 862
     
863 863
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
864 864
 
865
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
866
-		$value = $wpinv_options[$args['id']];
867
-	} else {
868
-		$value = isset($args['std']) ? $args['std'] : '';
869
-	}
865
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
866
+        $value = $wpinv_options[$args['id']];
867
+    } else {
868
+        $value = isset($args['std']) ? $args['std'] : '';
869
+    }
870 870
 
871
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
872
-	$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 ) ) . '"/>';
873
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
874
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
871
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
872
+    $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 ) ) . '"/>';
873
+    $html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
874
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
875 875
 
876
-	echo $html;
876
+    echo $html;
877 877
 }
878 878
 
879 879
 function wpinv_color_callback( $args ) {
880
-	global $wpinv_options;
880
+    global $wpinv_options;
881 881
     
882 882
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
883 883
 
884
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
885
-		$value = $wpinv_options[ $args['id'] ];
886
-	} else {
887
-		$value = isset( $args['std'] ) ? $args['std'] : '';
888
-	}
884
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
885
+        $value = $wpinv_options[ $args['id'] ];
886
+    } else {
887
+        $value = isset( $args['std'] ) ? $args['std'] : '';
888
+    }
889 889
 
890
-	$default = isset( $args['std'] ) ? $args['std'] : '';
890
+    $default = isset( $args['std'] ) ? $args['std'] : '';
891 891
 
892
-	$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 ) . '" />';
893
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
892
+    $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 ) . '" />';
893
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
894 894
 
895
-	echo $html;
895
+    echo $html;
896 896
 }
897 897
 
898 898
 function wpinv_country_states_callback($args) {
899
-	global $wpinv_options;
899
+    global $wpinv_options;
900 900
     
901 901
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
902 902
 
903
-	if ( isset( $args['placeholder'] ) ) {
904
-		$placeholder = $args['placeholder'];
905
-	} else {
906
-		$placeholder = '';
907
-	}
903
+    if ( isset( $args['placeholder'] ) ) {
904
+        $placeholder = $args['placeholder'];
905
+    } else {
906
+        $placeholder = '';
907
+    }
908 908
 
909
-	$states = wpinv_get_country_states();
909
+    $states = wpinv_get_country_states();
910 910
 
911
-	$class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
912
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
911
+    $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
912
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
913 913
 
914
-	foreach ( $states as $option => $name ) {
915
-		$selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
916
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
917
-	}
914
+    foreach ( $states as $option => $name ) {
915
+        $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
916
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
917
+    }
918 918
 
919
-	$html .= '</select>';
920
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
919
+    $html .= '</select>';
920
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
921 921
 
922
-	echo $html;
922
+    echo $html;
923 923
 }
924 924
 
925 925
 /**
@@ -927,7 +927,7 @@  discard block
 block discarded – undo
927 927
  */
928 928
 function wpinv_tax_rates_callback() {
929 929
 	
930
-	?>
930
+    ?>
931 931
 		</td>
932 932
 	</tr>
933 933
 	<tr class="bsui">
@@ -942,17 +942,17 @@  discard block
 block discarded – undo
942 942
  * Displays a tax rate' edit row.
943 943
  */
944 944
 function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) {
945
-	ob_start();
945
+    ob_start();
946 946
 
947
-	$key                      = sanitize_key( $key );
948
-	$tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
949
-	include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
947
+    $key                      = sanitize_key( $key );
948
+    $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
949
+    include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
950 950
 
951
-	if ( $echo ) {
952
-		echo ob_get_clean();
953
-	} else {
954
-		return ob_get_clean(); 
955
-	}
951
+    if ( $echo ) {
952
+        echo ob_get_clean();
953
+    } else {
954
+        return ob_get_clean(); 
955
+    }
956 956
 
957 957
 }
958 958
 
@@ -980,19 +980,19 @@  discard block
 block discarded – undo
980 980
 }
981 981
 
982 982
 function wpinv_descriptive_text_callback( $args ) {
983
-	echo wp_kses_post( $args['desc'] );
983
+    echo wp_kses_post( $args['desc'] );
984 984
 }
985 985
 
986 986
 function wpinv_raw_html_callback( $args ) {
987
-	echo $args['desc'];
987
+    echo $args['desc'];
988 988
 }
989 989
 
990 990
 function wpinv_hook_callback( $args ) {
991
-	do_action( 'wpinv_' . $args['id'], $args );
991
+    do_action( 'wpinv_' . $args['id'], $args );
992 992
 }
993 993
 
994 994
 function wpinv_set_settings_cap() {
995
-	return wpinv_get_capability();
995
+    return wpinv_get_capability();
996 996
 }
997 997
 add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
998 998
 
Please login to merge, or discard this patch.
Spacing   +369 added lines, -369 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,47 +190,47 @@  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']          : uniqid( 'wpinv-' ),
215
-            'desc'        => isset( $option['desc'] )        ? $option['desc']        : '',
214
+            'id'          => isset($option['id']) ? $option['id'] : uniqid('wpinv-'),
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']         : 0,
222
-            'max'         => isset( $option['max'] )         ? $option['max']         : 999999,
223
-            'step'        => isset( $option['step'] )        ? $option['step']        : 1,
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
-			'style'       => isset( $option['style'] )     ? $option['style']         : '',
232
-            'cols'        => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
233
-            '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'] : 0,
222
+            'max'         => isset($option['max']) ? $option['max'] : 999999,
223
+            'step'        => isset($option['step']) ? $option['step'] : 1,
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
+			'style'       => isset($option['style']) ? $option['style'] : '',
232
+            'cols'        => isset($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
233
+            'rows'        => isset($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
234 234
         )
235 235
     );
236 236
 
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
  * @return array
243 243
  */
244 244
 function wpinv_get_registered_settings() {
245
-	return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
245
+	return array_filter(apply_filters('wpinv_registered_settings', wpinv_get_data('admin-settings')));
246 246
 }
247 247
 
248 248
 /**
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
  * @return array
252 252
  */
253 253
 function getpaid_get_integration_settings() {
254
-    return apply_filters( 'getpaid_integration_settings', array() );
254
+    return apply_filters('getpaid_integration_settings', array());
255 255
 }
256 256
 
257 257
 /**
@@ -259,140 +259,140 @@  discard block
 block discarded – undo
259 259
  * 
260 260
  * @return array
261 261
  */
262
-function wpinv_settings_sanitize( $input = array() ) {
262
+function wpinv_settings_sanitize($input = array()) {
263 263
 
264 264
     $wpinv_options = wpinv_get_options();
265 265
 
266
-    if ( empty( wp_get_raw_referer() ) ) {
266
+    if (empty(wp_get_raw_referer())) {
267 267
         return $input;
268 268
     }
269 269
 
270
-    wp_parse_str( wp_get_raw_referer(), $referrer );
270
+    wp_parse_str(wp_get_raw_referer(), $referrer);
271 271
 
272 272
     $settings = wpinv_get_registered_settings();
273
-    $tab      = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
274
-    $section  = isset( $referrer['section'] ) ? $referrer['section'] : 'main';
273
+    $tab      = isset($referrer['tab']) ? $referrer['tab'] : 'general';
274
+    $section  = isset($referrer['section']) ? $referrer['section'] : 'main';
275 275
 
276 276
     $input = $input ? $input : array();
277
-    $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input );
278
-    $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input );
277
+    $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input);
278
+    $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input);
279 279
 
280 280
     // Loop through each setting being saved and pass it through a sanitization filter
281
-    foreach ( $input as $key => $value ) {
281
+    foreach ($input as $key => $value) {
282 282
 
283 283
         // Get the setting type (checkbox, select, etc)
284
-        $type = isset( $settings[ $tab ][$section][ $key ]['type'] ) ? $settings[ $tab ][$section][ $key ]['type'] : false;
284
+        $type = isset($settings[$tab][$section][$key]['type']) ? $settings[$tab][$section][$key]['type'] : false;
285 285
 
286
-        if ( $type ) {
286
+        if ($type) {
287 287
             // Field type specific filter
288
-            $input[$key] = apply_filters( 'wpinv_settings_sanitize_' . $type, $value, $key );
288
+            $input[$key] = apply_filters('wpinv_settings_sanitize_' . $type, $value, $key);
289 289
         }
290 290
 
291 291
         // General filter
292
-		$input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
292
+		$input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key);
293 293
 
294 294
 		// Key specific filter.
295
-		$input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
295
+		$input[$key] = apply_filters("wpinv_settings_sanitize_$key", $input[$key]);
296 296
     }
297 297
 
298 298
     // Loop through the whitelist and unset any that are empty for the tab being saved
299
-    $main_settings    = $section == 'main' ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections
300
-    $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array();
299
+    $main_settings    = $section == 'main' ? $settings[$tab] : array(); // Check for extensions that aren't using new sections
300
+    $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array();
301 301
 
302
-    $found_settings = array_merge( $main_settings, $section_settings );
302
+    $found_settings = array_merge($main_settings, $section_settings);
303 303
 
304
-    if ( ! empty( $found_settings ) ) {
305
-        foreach ( $found_settings as $key => $value ) {
304
+    if (!empty($found_settings)) {
305
+        foreach ($found_settings as $key => $value) {
306 306
 
307 307
             // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work
308
-            if ( is_numeric( $key ) ) {
308
+            if (is_numeric($key)) {
309 309
                 $key = $value['id'];
310 310
             }
311 311
 
312
-            if ( ! isset( $input[ $key ] ) && isset( $wpinv_options[ $key ] ) ) {
313
-                unset( $wpinv_options[ $key ] );
312
+            if (!isset($input[$key]) && isset($wpinv_options[$key])) {
313
+                unset($wpinv_options[$key]);
314 314
             }
315 315
         }
316 316
     }
317 317
 
318 318
     // Merge our new settings with the existing
319
-    $output = array_merge( $wpinv_options, $input );
319
+    $output = array_merge($wpinv_options, $input);
320 320
 
321
-    add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' );
321
+    add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated');
322 322
 
323 323
     return $output;
324 324
 }
325 325
 
326
-function wpinv_settings_sanitize_misc_accounting( $input ) {
326
+function wpinv_settings_sanitize_misc_accounting($input) {
327 327
 
328
-    if ( ! wpinv_current_user_can_manage_invoicing() ) {
328
+    if (!wpinv_current_user_can_manage_invoicing()) {
329 329
         return $input;
330 330
     }
331 331
 
332
-    if( ! empty( $input['enable_sequential'] ) && !wpinv_get_option( 'enable_sequential' ) ) {
332
+    if (!empty($input['enable_sequential']) && !wpinv_get_option('enable_sequential')) {
333 333
         // Shows an admin notice about upgrading previous order numbers
334
-        getpaid_session()->set( 'upgrade_sequential', '1' );
334
+        getpaid_session()->set('upgrade_sequential', '1');
335 335
     }
336 336
 
337 337
     return $input;
338 338
 }
339
-add_filter( 'wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting' );
339
+add_filter('wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting');
340 340
 
341
-function wpinv_settings_sanitize_tax_rates( $input ) {
342
-    if( ! wpinv_current_user_can_manage_invoicing() ) {
341
+function wpinv_settings_sanitize_tax_rates($input) {
342
+    if (!wpinv_current_user_can_manage_invoicing()) {
343 343
         return $input;
344 344
     }
345 345
 
346
-    $new_rates = ! empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array();
346
+    $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array();
347 347
     $tax_rates = array();
348 348
 
349
-    foreach ( $new_rates as $rate ) {
349
+    foreach ($new_rates as $rate) {
350 350
 
351
-		$rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
352
-		$rate['name']    = sanitize_text_field( $rate['name'] );
353
-		$rate['state']   = sanitize_text_field( $rate['state'] );
354
-		$rate['country'] = sanitize_text_field( $rate['country'] );
355
-		$rate['global']  = empty( $rate['state'] );
351
+		$rate['rate']    = wpinv_sanitize_amount($rate['rate']);
352
+		$rate['name']    = sanitize_text_field($rate['name']);
353
+		$rate['state']   = sanitize_text_field($rate['state']);
354
+		$rate['country'] = sanitize_text_field($rate['country']);
355
+		$rate['global']  = empty($rate['state']);
356 356
 		$tax_rates[]     = $rate;
357 357
 
358 358
 	}
359 359
 
360
-    update_option( 'wpinv_tax_rates', $tax_rates );
360
+    update_option('wpinv_tax_rates', $tax_rates);
361 361
 
362 362
     return $input;
363 363
 }
364
-add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' );
364
+add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates');
365 365
 
366
-function wpinv_sanitize_text_field( $input ) {
367
-    return trim( $input );
366
+function wpinv_sanitize_text_field($input) {
367
+    return trim($input);
368 368
 }
369
-add_filter( 'wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field' );
369
+add_filter('wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field');
370 370
 
371 371
 function wpinv_get_settings_tabs() {
372 372
     $tabs             = array();
373
-    $tabs['general']  = __( 'General', 'invoicing' );
374
-    $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
375
-    $tabs['taxes']    = __( 'Taxes', 'invoicing' );
376
-	$tabs['emails']   = __( 'Emails', 'invoicing' );
373
+    $tabs['general']  = __('General', 'invoicing');
374
+    $tabs['gateways'] = __('Payment Gateways', 'invoicing');
375
+    $tabs['taxes']    = __('Taxes', 'invoicing');
376
+	$tabs['emails'] = __('Emails', 'invoicing');
377 377
 
378
-	if ( count( getpaid_get_integration_settings() ) > 0 ) {
379
-		$tabs['integrations'] = __( 'Integrations', 'invoicing' );
378
+	if (count(getpaid_get_integration_settings()) > 0) {
379
+		$tabs['integrations'] = __('Integrations', 'invoicing');
380 380
 	}
381 381
 
382
-    $tabs['privacy']  = __( 'Privacy', 'invoicing' );
383
-    $tabs['misc']     = __( 'Misc', 'invoicing' );
384
-    $tabs['tools']    = __( 'Tools', 'invoicing' );
382
+    $tabs['privacy']  = __('Privacy', 'invoicing');
383
+    $tabs['misc']     = __('Misc', 'invoicing');
384
+    $tabs['tools']    = __('Tools', 'invoicing');
385 385
 
386
-    return apply_filters( 'wpinv_settings_tabs', $tabs );
386
+    return apply_filters('wpinv_settings_tabs', $tabs);
387 387
 }
388 388
 
389
-function wpinv_get_settings_tab_sections( $tab = false ) {
389
+function wpinv_get_settings_tab_sections($tab = false) {
390 390
     $tabs     = false;
391 391
     $sections = wpinv_get_registered_settings_sections();
392 392
 
393
-    if( $tab && ! empty( $sections[ $tab ] ) ) {
394
-        $tabs = $sections[ $tab ];
395
-    } else if ( $tab ) {
393
+    if ($tab && !empty($sections[$tab])) {
394
+        $tabs = $sections[$tab];
395
+    } else if ($tab) {
396 396
         $tabs = false;
397 397
     }
398 398
 
@@ -402,91 +402,91 @@  discard block
 block discarded – undo
402 402
 function wpinv_get_registered_settings_sections() {
403 403
     static $sections = false;
404 404
 
405
-    if ( false !== $sections ) {
405
+    if (false !== $sections) {
406 406
         return $sections;
407 407
     }
408 408
 
409 409
     $sections = array(
410
-        'general' => apply_filters( 'wpinv_settings_sections_general', array(
411
-            'main' => __( 'General Settings', 'invoicing' ),
412
-            'currency_section' => __( 'Currency Settings', 'invoicing' ),
413
-            'labels' => __( 'Label Texts', 'invoicing' ),
414
-        ) ),
415
-        'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array(
416
-            'main' => __( 'Gateway Settings', 'invoicing' ),
417
-        ) ),
418
-        'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array(
419
-            'main'  => __( 'Tax Settings', 'invoicing' ),
420
-			'rates' => __( 'Tax Rates', 'invoicing' ),
421
-			'vat'   => __( 'EU VAT Settings', 'invoicing' )
422
-        ) ),
423
-        'emails' => apply_filters( 'wpinv_settings_sections_emails', array(
424
-            'main' => __( 'Email Settings', 'invoicing' ),
425
-		) ),
426
-
427
-		'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
428
-
429
-        'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array(
430
-            'main' => __( 'Privacy policy', 'invoicing' ),
431
-        ) ),
432
-        'misc' => apply_filters( 'wpinv_settings_sections_misc', array(
433
-            'main' => __( 'Miscellaneous', 'invoicing' ),
434
-            'custom-css' => __( 'Custom CSS', 'invoicing' ),
435
-        ) ),
436
-        'tools' => apply_filters( 'wpinv_settings_sections_tools', array(
437
-            'main' => __( 'Diagnostic Tools', 'invoicing' ),
438
-        ) ),
410
+        'general' => apply_filters('wpinv_settings_sections_general', array(
411
+            'main' => __('General Settings', 'invoicing'),
412
+            'currency_section' => __('Currency Settings', 'invoicing'),
413
+            'labels' => __('Label Texts', 'invoicing'),
414
+        )),
415
+        'gateways' => apply_filters('wpinv_settings_sections_gateways', array(
416
+            'main' => __('Gateway Settings', 'invoicing'),
417
+        )),
418
+        'taxes' => apply_filters('wpinv_settings_sections_taxes', array(
419
+            'main'  => __('Tax Settings', 'invoicing'),
420
+			'rates' => __('Tax Rates', 'invoicing'),
421
+			'vat'   => __('EU VAT Settings', 'invoicing')
422
+        )),
423
+        'emails' => apply_filters('wpinv_settings_sections_emails', array(
424
+            'main' => __('Email Settings', 'invoicing'),
425
+		)),
426
+
427
+		'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'label', 'id'),
428
+
429
+        'privacy' => apply_filters('wpinv_settings_sections_privacy', array(
430
+            'main' => __('Privacy policy', 'invoicing'),
431
+        )),
432
+        'misc' => apply_filters('wpinv_settings_sections_misc', array(
433
+            'main' => __('Miscellaneous', 'invoicing'),
434
+            'custom-css' => __('Custom CSS', 'invoicing'),
435
+        )),
436
+        'tools' => apply_filters('wpinv_settings_sections_tools', array(
437
+            'main' => __('Diagnostic Tools', 'invoicing'),
438
+        )),
439 439
     );
440 440
 
441
-    $sections = apply_filters( 'wpinv_settings_sections', $sections );
441
+    $sections = apply_filters('wpinv_settings_sections', $sections);
442 442
 
443 443
     return $sections;
444 444
 }
445 445
 
446
-function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
446
+function wpinv_get_pages($with_slug = false, $default_label = NULL) {
447 447
 	$pages_options = array();
448 448
 
449
-	if( $default_label !== NULL && $default_label !== false ) {
450
-		$pages_options = array( '' => $default_label ); // Blank option
449
+	if ($default_label !== NULL && $default_label !== false) {
450
+		$pages_options = array('' => $default_label); // Blank option
451 451
 	}
452 452
 
453 453
 	$pages = get_pages();
454
-	if ( $pages ) {
455
-		foreach ( $pages as $page ) {
454
+	if ($pages) {
455
+		foreach ($pages as $page) {
456 456
 			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
457
-            $pages_options[ $page->ID ] = $title;
457
+            $pages_options[$page->ID] = $title;
458 458
 		}
459 459
 	}
460 460
 
461 461
 	return $pages_options;
462 462
 }
463 463
 
464
-function wpinv_header_callback( $args ) {
465
-	if ( !empty( $args['desc'] ) ) {
464
+function wpinv_header_callback($args) {
465
+	if (!empty($args['desc'])) {
466 466
         echo $args['desc'];
467 467
     }
468 468
 }
469 469
 
470
-function wpinv_hidden_callback( $args ) {
470
+function wpinv_hidden_callback($args) {
471 471
 	global $wpinv_options;
472 472
 
473
-	if ( isset( $args['set_value'] ) ) {
473
+	if (isset($args['set_value'])) {
474 474
 		$value = $args['set_value'];
475
-	} elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
476
-		$value = $wpinv_options[ $args['id'] ];
475
+	} elseif (isset($wpinv_options[$args['id']])) {
476
+		$value = $wpinv_options[$args['id']];
477 477
 	} else {
478
-		$value = isset( $args['std'] ) ? $args['std'] : '';
478
+		$value = isset($args['std']) ? $args['std'] : '';
479 479
 	}
480 480
 
481
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
481
+	if (isset($args['faux']) && true === $args['faux']) {
482 482
 		$args['readonly'] = true;
483
-		$value = isset( $args['std'] ) ? $args['std'] : '';
483
+		$value = isset($args['std']) ? $args['std'] : '';
484 484
 		$name  = '';
485 485
 	} else {
486
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
486
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
487 487
 	}
488 488
 
489
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
489
+	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />';
490 490
     
491 491
 	echo $html;
492 492
 }
@@ -494,61 +494,61 @@  discard block
 block discarded – undo
494 494
 /**
495 495
  * Displays a checkbox settings callback.
496 496
  */
497
-function wpinv_checkbox_callback( $args ) {
497
+function wpinv_checkbox_callback($args) {
498 498
 
499
-	$std = isset( $args['std'] ) ? $args['std'] : '';
500
-	$std = wpinv_get_option( $args['id'], $std );
501
-	$id  = esc_attr( $args['id'] );
499
+	$std = isset($args['std']) ? $args['std'] : '';
500
+	$std = wpinv_get_option($args['id'], $std);
501
+	$id  = esc_attr($args['id']);
502 502
 
503
-	getpaid_hidden_field( "wpinv_settings[$id]", '0' );
503
+	getpaid_hidden_field("wpinv_settings[$id]", '0');
504 504
 	?>
505 505
 		<fieldset>
506 506
 			<label>
507
-				<input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox">
508
-				<?php echo wp_kses_post( $args['desc'] ); ?>
507
+				<input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked(empty($std), false); ?> value="1" type="checkbox">
508
+				<?php echo wp_kses_post($args['desc']); ?>
509 509
 			</label>
510 510
 		</fieldset>
511 511
 	<?php
512 512
 }
513 513
 
514
-function wpinv_multicheck_callback( $args ) {
514
+function wpinv_multicheck_callback($args) {
515 515
 	
516 516
 	global $wpinv_options;
517 517
 
518
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
519
-	$class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
518
+	$sanitize_id = wpinv_sanitize_key($args['id']);
519
+	$class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
520 520
 
521
-	if ( ! empty( $args['options'] ) ) {
521
+	if (!empty($args['options'])) {
522 522
 
523
-		$std     = isset( $args['std'] ) ? $args['std'] : array();
524
-		$value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
523
+		$std     = isset($args['std']) ? $args['std'] : array();
524
+		$value   = isset($wpinv_options[$args['id']]) ? $wpinv_options[$args['id']] : $std;
525 525
 
526 526
 		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
527
-        foreach( $args['options'] as $key => $option ):
528
-			$sanitize_key = wpinv_sanitize_key( $key );
529
-			if ( in_array( $sanitize_key, $value ) ) { 
527
+        foreach ($args['options'] as $key => $option):
528
+			$sanitize_key = wpinv_sanitize_key($key);
529
+			if (in_array($sanitize_key, $value)) { 
530 530
 				$enabled = $sanitize_key;
531 531
 			} else { 
532 532
 				$enabled = NULL; 
533 533
 			}
534
-			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;';
535
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
534
+			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;';
535
+			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label></div>';
536 536
 		endforeach;
537 537
 		echo '</div>';
538 538
 		echo '<p class="description">' . $args['desc'] . '</p>';
539 539
 	}
540 540
 }
541 541
 
542
-function wpinv_payment_icons_callback( $args ) {
542
+function wpinv_payment_icons_callback($args) {
543 543
 	global $wpinv_options;
544 544
     
545
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
545
+    $sanitize_id = wpinv_sanitize_key($args['id']);
546 546
 
547
-	if ( ! empty( $args['options'] ) ) {
548
-		foreach( $args['options'] as $key => $option ) {
549
-            $sanitize_key = wpinv_sanitize_key( $key );
547
+	if (!empty($args['options'])) {
548
+		foreach ($args['options'] as $key => $option) {
549
+            $sanitize_key = wpinv_sanitize_key($key);
550 550
             
551
-			if( isset( $wpinv_options[$args['id']][$key] ) ) {
551
+			if (isset($wpinv_options[$args['id']][$key])) {
552 552
 				$enabled = $option;
553 553
 			} else {
554 554
 				$enabled = NULL;
@@ -556,109 +556,109 @@  discard block
 block discarded – undo
556 556
 
557 557
 			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
558 558
 
559
-				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;';
559
+				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;';
560 560
 
561
-				if ( wpinv_string_is_image_url( $key ) ) {
562
-					echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
561
+				if (wpinv_string_is_image_url($key)) {
562
+					echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
563 563
 				} else {
564
-					$card = strtolower( str_replace( ' ', '', $option ) );
564
+					$card = strtolower(str_replace(' ', '', $option));
565 565
 
566
-					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
567
-						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
566
+					if (has_filter('wpinv_accepted_payment_' . $card . '_image')) {
567
+						$image = apply_filters('wpinv_accepted_payment_' . $card . '_image', '');
568 568
 					} else {
569
-						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
569
+						$image       = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false);
570 570
 						$content_dir = WP_CONTENT_DIR;
571 571
 
572
-						if ( function_exists( 'wp_normalize_path' ) ) {
572
+						if (function_exists('wp_normalize_path')) {
573 573
 							// Replaces backslashes with forward slashes for Windows systems
574
-							$image = wp_normalize_path( $image );
575
-							$content_dir = wp_normalize_path( $content_dir );
574
+							$image = wp_normalize_path($image);
575
+							$content_dir = wp_normalize_path($content_dir);
576 576
 						}
577 577
 
578
-						$image = str_replace( $content_dir, content_url(), $image );
578
+						$image = str_replace($content_dir, content_url(), $image);
579 579
 					}
580 580
 
581
-					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
581
+					echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
582 582
 				}
583 583
 			echo $option . '</label>';
584 584
 		}
585
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
585
+		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>';
586 586
 	}
587 587
 }
588 588
 
589 589
 /**
590 590
  * Displays a radio settings field.
591 591
  */
592
-function wpinv_radio_callback( $args ) {
592
+function wpinv_radio_callback($args) {
593 593
 
594
-	$std = isset( $args['std'] ) ? $args['std'] : '';
595
-	$std = wpinv_get_option( $args['id'], $std );
594
+	$std = isset($args['std']) ? $args['std'] : '';
595
+	$std = wpinv_get_option($args['id'], $std);
596 596
 	?>
597 597
 		<fieldset>
598
-			<ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;">
599
-				<?php foreach( $args['options'] as $key => $option ) : ?>
598
+			<ul id="wpinv-settings-<?php echo esc_attr($args['id']); ?>" style="margin-top: 0;">
599
+				<?php foreach ($args['options'] as $key => $option) : ?>
600 600
 					<li>
601 601
 						<label>
602
-							<input name="wpinv_settings[<?php echo esc_attr( $args['id'] ); ?>]" <?php checked( $std, $key ); ?> value="<?php echo esc_attr( $key ); ?>" type="radio">
603
-							<?php echo wp_kses_post( $option ); ?>
602
+							<input name="wpinv_settings[<?php echo esc_attr($args['id']); ?>]" <?php checked($std, $key); ?> value="<?php echo esc_attr($key); ?>" type="radio">
603
+							<?php echo wp_kses_post($option); ?>
604 604
 						</label>
605 605
 					</li>
606 606
 				<?php endforeach; ?>
607 607
 			</ul>
608 608
 		</fieldset>
609 609
 	<?php
610
-	getpaid_settings_description_callback( $args );
610
+	getpaid_settings_description_callback($args);
611 611
 }
612 612
 
613 613
 /**
614 614
  * Displays a description if available.
615 615
  */
616
-function getpaid_settings_description_callback( $args ) {
616
+function getpaid_settings_description_callback($args) {
617 617
 
618
-	if ( ! empty( $args['desc'] ) ) {
619
-		$description = wp_kses_post( $args['desc'] );
618
+	if (!empty($args['desc'])) {
619
+		$description = wp_kses_post($args['desc']);
620 620
 		echo "<p class='description'>$description</p>";
621 621
 	}
622 622
 
623 623
 }
624 624
 
625
-function wpinv_gateways_callback( $args ) {
625
+function wpinv_gateways_callback($args) {
626 626
 	global $wpinv_options;
627 627
     
628
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
628
+    $sanitize_id = wpinv_sanitize_key($args['id']);
629 629
 
630
-	foreach ( $args['options'] as $key => $option ) :
631
-		$sanitize_key = wpinv_sanitize_key( $key );
630
+	foreach ($args['options'] as $key => $option) :
631
+		$sanitize_key = wpinv_sanitize_key($key);
632 632
         
633
-        if ( isset( $wpinv_options['gateways'][ $key ] ) )
633
+        if (isset($wpinv_options['gateways'][$key]))
634 634
 			$enabled = '1';
635 635
 		else
636 636
 			$enabled = null;
637 637
 
638
-		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;';
639
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
638
+		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;';
639
+		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option['admin_label']) . '</label><br/>';
640 640
 	endforeach;
641 641
 }
642 642
 
643 643
 function wpinv_gateway_select_callback($args) {
644 644
 	global $wpinv_options;
645 645
     
646
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
647
-    $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
646
+    $sanitize_id = wpinv_sanitize_key($args['id']);
647
+    $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
648 648
 
649
-	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
649
+	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '" >';
650 650
 
651
-	foreach ( $args['options'] as $key => $option ) :
652
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
653
-            $selected = selected( $key, $args['selected'], false );
651
+	foreach ($args['options'] as $key => $option) :
652
+		if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
653
+            $selected = selected($key, $args['selected'], false);
654 654
         } else {
655
-            $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : '';
655
+            $selected = isset($wpinv_options[$args['id']]) ? selected($key, $wpinv_options[$args['id']], false) : '';
656 656
         }
657
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
657
+		echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>';
658 658
 	endforeach;
659 659
 
660 660
 	echo '</select>';
661
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
661
+	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
662 662
 }
663 663
 
664 664
 /**
@@ -667,28 +667,28 @@  discard block
 block discarded – undo
667 667
  * @param array $args
668 668
  * @return string
669 669
  */
670
-function wpinv_settings_attrs_helper( $args ) {
670
+function wpinv_settings_attrs_helper($args) {
671 671
 
672
-	$value        = isset( $args['std'] ) ? $args['std'] : '';
673
-	$id           = esc_attr( $args['id'] );
674
-	$placeholder  = esc_attr( $args['placeholder'] );
672
+	$value        = isset($args['std']) ? $args['std'] : '';
673
+	$id           = esc_attr($args['id']);
674
+	$placeholder  = esc_attr($args['placeholder']);
675 675
 
676
-	if ( ! empty( $args['faux'] ) ) {
676
+	if (!empty($args['faux'])) {
677 677
 		$args['readonly'] = true;
678 678
 		$name             = '';
679 679
 	} else {
680
-		$value  = wpinv_get_option( $args['id'], $value );
680
+		$value  = wpinv_get_option($args['id'], $value);
681 681
 		$name   = "wpinv_settings[$id]";
682 682
 	}
683 683
 
684
-	$value    = is_scalar( $value ) ? esc_attr( $value ) : '';
685
-	$class    = esc_attr( $args['class'] );
686
-	$style    = esc_attr( $args['style'] );
687
-	$readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"';
684
+	$value    = is_scalar($value) ? esc_attr($value) : '';
685
+	$class    = esc_attr($args['class']);
686
+	$style    = esc_attr($args['style']);
687
+	$readonly = empty($args['readonly']) ? '' : 'readonly onclick="this.select()"';
688 688
 
689 689
 	$onchange = '';
690
-    if ( ! empty( $args['onchange'] ) ) {
691
-        $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
690
+    if (!empty($args['onchange'])) {
691
+        $onchange = ' onchange="' . esc_attr($args['onchange']) . '"';
692 692
 	}
693 693
 
694 694
 	return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly";
@@ -697,11 +697,11 @@  discard block
 block discarded – undo
697 697
 /**
698 698
  * Displays a text input settings callback.
699 699
  */
700
-function wpinv_text_callback( $args ) {
700
+function wpinv_text_callback($args) {
701 701
 
702
-	$desc = wp_kses_post( $args['desc'] );
703
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
704
-	$attr = wpinv_settings_attrs_helper( $args );
702
+	$desc = wp_kses_post($args['desc']);
703
+	$desc = empty($desc) ? '' : "<p class='description'>$desc</p>";
704
+	$attr = wpinv_settings_attrs_helper($args);
705 705
 
706 706
 	?>
707 707
 		<label style="width: 100%;">
@@ -715,14 +715,14 @@  discard block
 block discarded – undo
715 715
 /**
716 716
  * Displays a number input settings callback.
717 717
  */
718
-function wpinv_number_callback( $args ) {
718
+function wpinv_number_callback($args) {
719 719
 
720
-	$desc = wp_kses_post( $args['desc'] );
721
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
722
-	$attr = wpinv_settings_attrs_helper( $args );
723
-	$max  = absint( $args['max'] );
724
-	$min  = absint( $args['min'] );
725
-	$step = floatval( $args['step'] );
720
+	$desc = wp_kses_post($args['desc']);
721
+	$desc = empty($desc) ? '' : "<p class='description'>$desc</p>";
722
+	$attr = wpinv_settings_attrs_helper($args);
723
+	$max  = absint($args['max']);
724
+	$min  = absint($args['min']);
725
+	$step = floatval($args['step']);
726 726
 
727 727
 	?>
728 728
 		<label style="width: 100%;">
@@ -733,47 +733,47 @@  discard block
 block discarded – undo
733 733
 
734 734
 }
735 735
 
736
-function wpinv_textarea_callback( $args ) {
736
+function wpinv_textarea_callback($args) {
737 737
 	global $wpinv_options;
738 738
     
739
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
739
+    $sanitize_id = wpinv_sanitize_key($args['id']);
740 740
 
741
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
742
-		$value = $wpinv_options[ $args['id'] ];
741
+	if (isset($wpinv_options[$args['id']])) {
742
+		$value = $wpinv_options[$args['id']];
743 743
 	} else {
744
-		$value = isset( $args['std'] ) ? $args['std'] : '';
744
+		$value = isset($args['std']) ? $args['std'] : '';
745 745
 	}
746 746
     
747
-    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
748
-    $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
747
+    $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
748
+    $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text';
749 749
 
750
-	$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>';
751
-	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
750
+	$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>';
751
+	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
752 752
 
753 753
 	echo $html;
754 754
 }
755 755
 
756
-function wpinv_password_callback( $args ) {
756
+function wpinv_password_callback($args) {
757 757
 	global $wpinv_options;
758 758
     
759
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
759
+    $sanitize_id = wpinv_sanitize_key($args['id']);
760 760
 
761
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
762
-		$value = $wpinv_options[ $args['id'] ];
761
+	if (isset($wpinv_options[$args['id']])) {
762
+		$value = $wpinv_options[$args['id']];
763 763
 	} else {
764
-		$value = isset( $args['std'] ) ? $args['std'] : '';
764
+		$value = isset($args['std']) ? $args['std'] : '';
765 765
 	}
766 766
 
767
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
768
-	$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 ) . '"/>';
769
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
767
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
768
+	$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) . '"/>';
769
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
770 770
 
771 771
 	echo $html;
772 772
 }
773 773
 
774 774
 function wpinv_missing_callback($args) {
775 775
 	printf(
776
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
776
+		__('The callback function used for the %s setting is missing.', 'invoicing'),
777 777
 		'<strong>' . $args['id'] . '</strong>'
778 778
 	);
779 779
 }
@@ -781,20 +781,20 @@  discard block
 block discarded – undo
781 781
 /**
782 782
  * Displays a number input settings callback.
783 783
  */
784
-function wpinv_select_callback( $args ) {
784
+function wpinv_select_callback($args) {
785 785
 
786
-	$desc   = wp_kses_post( $args['desc'] );
787
-	$desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
788
-	$attr   = wpinv_settings_attrs_helper( $args );
789
-	$value  = isset( $args['std'] ) ? $args['std'] : '';
790
-	$value  = wpinv_get_option( $args['id'], $value );
786
+	$desc   = wp_kses_post($args['desc']);
787
+	$desc   = empty($desc) ? '' : "<p class='description'>$desc</p>";
788
+	$attr   = wpinv_settings_attrs_helper($args);
789
+	$value  = isset($args['std']) ? $args['std'] : '';
790
+	$value  = wpinv_get_option($args['id'], $value);
791 791
 
792 792
 	?>
793 793
 		<label style="width: 100%;">
794 794
 			<select <?php echo $attr; ?>>
795
-				<?php foreach ( $args['options'] as $option => $name ) : ?>
796
-					<option value="<?php echo esc_attr( $option ); ?>" <?php echo selected( is_array( $value ) ? in_array( $option, $value, true ) : $option === $value ); ?>><?php echo wpinv_clean( $name ); ?></option>
797
-				<?php endforeach;?>
795
+				<?php foreach ($args['options'] as $option => $name) : ?>
796
+					<option value="<?php echo esc_attr($option); ?>" <?php echo selected(is_array($value) ? in_array($option, $value, true) : $option === $value); ?>><?php echo wpinv_clean($name); ?></option>
797
+				<?php endforeach; ?>
798 798
 			</select>
799 799
 			<?php echo $desc; ?>
800 800
 		</label>
@@ -802,95 +802,95 @@  discard block
 block discarded – undo
802 802
 
803 803
 }
804 804
 
805
-function wpinv_color_select_callback( $args ) {
805
+function wpinv_color_select_callback($args) {
806 806
 	global $wpinv_options;
807 807
     
808
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
808
+    $sanitize_id = wpinv_sanitize_key($args['id']);
809 809
 
810
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
811
-		$value = $wpinv_options[ $args['id'] ];
810
+	if (isset($wpinv_options[$args['id']])) {
811
+		$value = $wpinv_options[$args['id']];
812 812
 	} else {
813
-		$value = isset( $args['std'] ) ? $args['std'] : '';
813
+		$value = isset($args['std']) ? $args['std'] : '';
814 814
 	}
815 815
 
816
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
816
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>';
817 817
 
818
-	foreach ( $args['options'] as $option => $color ) {
819
-		$selected = selected( $option, $value, false );
820
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
818
+	foreach ($args['options'] as $option => $color) {
819
+		$selected = selected($option, $value, false);
820
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>';
821 821
 	}
822 822
 
823 823
 	$html .= '</select>';
824
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
824
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
825 825
 
826 826
 	echo $html;
827 827
 }
828 828
 
829
-function wpinv_rich_editor_callback( $args ) {
829
+function wpinv_rich_editor_callback($args) {
830 830
 	global $wpinv_options, $wp_version;
831 831
     
832
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
832
+    $sanitize_id = wpinv_sanitize_key($args['id']);
833 833
 
834
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
835
-		$value = $wpinv_options[ $args['id'] ];
834
+	if (isset($wpinv_options[$args['id']])) {
835
+		$value = $wpinv_options[$args['id']];
836 836
 
837
-		if( empty( $args['allow_blank'] ) && empty( $value ) ) {
838
-			$value = isset( $args['std'] ) ? $args['std'] : '';
837
+		if (empty($args['allow_blank']) && empty($value)) {
838
+			$value = isset($args['std']) ? $args['std'] : '';
839 839
 		}
840 840
 	} else {
841
-		$value = isset( $args['std'] ) ? $args['std'] : '';
841
+		$value = isset($args['std']) ? $args['std'] : '';
842 842
 	}
843 843
 
844
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
844
+	$rows = isset($args['size']) ? $args['size'] : 20;
845 845
 
846 846
 	$html = '<div class="getpaid-settings-editor-input">';
847
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
847
+	if ($wp_version >= 3.3 && function_exists('wp_editor')) {
848 848
 		ob_start();
849
-		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 ) );
849
+		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));
850 850
 		$html .= ob_get_clean();
851 851
 	} else {
852
-		$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>';
852
+		$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>';
853 853
 	}
854 854
 
855
-	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
855
+	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
856 856
 
857 857
 	echo $html;
858 858
 }
859 859
 
860
-function wpinv_upload_callback( $args ) {
860
+function wpinv_upload_callback($args) {
861 861
 	global $wpinv_options;
862 862
     
863
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
863
+    $sanitize_id = wpinv_sanitize_key($args['id']);
864 864
 
865
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
865
+	if (isset($wpinv_options[$args['id']])) {
866 866
 		$value = $wpinv_options[$args['id']];
867 867
 	} else {
868 868
 		$value = isset($args['std']) ? $args['std'] : '';
869 869
 	}
870 870
 
871
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
872
-	$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 ) ) . '"/>';
873
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
874
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
871
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
872
+	$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)) . '"/>';
873
+	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>';
874
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
875 875
 
876 876
 	echo $html;
877 877
 }
878 878
 
879
-function wpinv_color_callback( $args ) {
879
+function wpinv_color_callback($args) {
880 880
 	global $wpinv_options;
881 881
     
882
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
882
+    $sanitize_id = wpinv_sanitize_key($args['id']);
883 883
 
884
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
885
-		$value = $wpinv_options[ $args['id'] ];
884
+	if (isset($wpinv_options[$args['id']])) {
885
+		$value = $wpinv_options[$args['id']];
886 886
 	} else {
887
-		$value = isset( $args['std'] ) ? $args['std'] : '';
887
+		$value = isset($args['std']) ? $args['std'] : '';
888 888
 	}
889 889
 
890
-	$default = isset( $args['std'] ) ? $args['std'] : '';
890
+	$default = isset($args['std']) ? $args['std'] : '';
891 891
 
892
-	$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 ) . '" />';
893
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
892
+	$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) . '" />';
893
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
894 894
 
895 895
 	echo $html;
896 896
 }
@@ -898,9 +898,9 @@  discard block
 block discarded – undo
898 898
 function wpinv_country_states_callback($args) {
899 899
 	global $wpinv_options;
900 900
     
901
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
901
+    $sanitize_id = wpinv_sanitize_key($args['id']);
902 902
 
903
-	if ( isset( $args['placeholder'] ) ) {
903
+	if (isset($args['placeholder'])) {
904 904
 		$placeholder = $args['placeholder'];
905 905
 	} else {
906 906
 		$placeholder = '';
@@ -908,16 +908,16 @@  discard block
 block discarded – undo
908 908
 
909 909
 	$states = wpinv_get_country_states();
910 910
 
911
-	$class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
912
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
911
+	$class = empty($states) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
912
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>';
913 913
 
914
-	foreach ( $states as $option => $name ) {
915
-		$selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
916
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
914
+	foreach ($states as $option => $name) {
915
+		$selected = isset($wpinv_options[$args['id']]) ? selected($option, $wpinv_options[$args['id']], false) : '';
916
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>';
917 917
 	}
918 918
 
919 919
 	$html .= '</select>';
920
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
920
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
921 921
 
922 922
 	echo $html;
923 923
 }
@@ -932,7 +932,7 @@  discard block
 block discarded – undo
932 932
 	</tr>
933 933
 	<tr class="bsui">
934 934
     	<td colspan="2" class="p-0">
935
-			<?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rates-edit.php'; ?>
935
+			<?php include plugin_dir_path(__FILE__) . 'views/html-tax-rates-edit.php'; ?>
936 936
 
937 937
 	<?php
938 938
 
@@ -941,14 +941,14 @@  discard block
 block discarded – undo
941 941
 /**
942 942
  * Displays a tax rate' edit row.
943 943
  */
944
-function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) {
944
+function wpinv_tax_rate_callback($tax_rate, $key, $echo = true) {
945 945
 	ob_start();
946 946
 
947
-	$key                      = sanitize_key( $key );
948
-	$tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
949
-	include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
947
+	$key                      = sanitize_key($key);
948
+	$tax_rate['reduced_rate'] = empty($tax_rate['reduced_rate']) ? 0 : $tax_rate['reduced_rate'];
949
+	include plugin_dir_path(__FILE__) . 'views/html-tax-rate-edit.php';
950 950
 
951
-	if ( $echo ) {
951
+	if ($echo) {
952 952
 		echo ob_get_clean();
953 953
 	} else {
954 954
 		return ob_get_clean(); 
@@ -960,81 +960,81 @@  discard block
 block discarded – undo
960 960
     ob_start(); ?>
961 961
     </td><tr>
962 962
     <td colspan="2" class="wpinv_tools_tdbox">
963
-    <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
964
-    <?php do_action( 'wpinv_tools_before' ); ?>
963
+    <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
964
+    <?php do_action('wpinv_tools_before'); ?>
965 965
     <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts">
966 966
         <thead>
967 967
             <tr>
968
-                <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th>
969
-                <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th>
970
-                <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th>
968
+                <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th>
969
+                <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th>
970
+                <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th>
971 971
             </tr>
972 972
         </thead>
973
-            <?php do_action( 'wpinv_tools_row' ); ?>
973
+            <?php do_action('wpinv_tools_row'); ?>
974 974
         <tbody>
975 975
         </tbody>
976 976
     </table>
977
-    <?php do_action( 'wpinv_tools_after' ); ?>
977
+    <?php do_action('wpinv_tools_after'); ?>
978 978
     <?php
979 979
     echo ob_get_clean();
980 980
 }
981 981
 
982
-function wpinv_descriptive_text_callback( $args ) {
983
-	echo wp_kses_post( $args['desc'] );
982
+function wpinv_descriptive_text_callback($args) {
983
+	echo wp_kses_post($args['desc']);
984 984
 }
985 985
 
986
-function wpinv_raw_html_callback( $args ) {
986
+function wpinv_raw_html_callback($args) {
987 987
 	echo $args['desc'];
988 988
 }
989 989
 
990
-function wpinv_hook_callback( $args ) {
991
-	do_action( 'wpinv_' . $args['id'], $args );
990
+function wpinv_hook_callback($args) {
991
+	do_action('wpinv_' . $args['id'], $args);
992 992
 }
993 993
 
994 994
 function wpinv_set_settings_cap() {
995 995
 	return wpinv_get_capability();
996 996
 }
997
-add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
997
+add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap');
998 998
 
999
-function wpinv_settings_sanitize_input( $value, $key ) {
999
+function wpinv_settings_sanitize_input($value, $key) {
1000 1000
 
1001
-    if ( $key == 'tax_rate' ) {
1002
-        $value = wpinv_sanitize_amount( $value );
1001
+    if ($key == 'tax_rate') {
1002
+        $value = wpinv_sanitize_amount($value);
1003 1003
         $value = $value >= 100 ? 99 : $value;
1004 1004
     }
1005 1005
 
1006 1006
     return $value;
1007 1007
 }
1008
-add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 );
1008
+add_filter('wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2);
1009 1009
 
1010
-function wpinv_on_update_settings( $old_value, $value, $option ) {
1011
-    $old = !empty( $old_value['remove_data_on_unistall'] ) ? 1 : '';
1012
-    $new = !empty( $value['remove_data_on_unistall'] ) ? 1 : '';
1010
+function wpinv_on_update_settings($old_value, $value, $option) {
1011
+    $old = !empty($old_value['remove_data_on_unistall']) ? 1 : '';
1012
+    $new = !empty($value['remove_data_on_unistall']) ? 1 : '';
1013 1013
     
1014
-    if ( $old != $new ) {
1015
-        update_option( 'wpinv_remove_data_on_invoice_unistall', $new );
1014
+    if ($old != $new) {
1015
+        update_option('wpinv_remove_data_on_invoice_unistall', $new);
1016 1016
     }
1017 1017
 }
1018
-add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 );
1019
-add_action( 'wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1020
-add_action( 'wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1021
-add_action( 'wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1022
-add_action( 'wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1023
-add_action( 'wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1024
-add_action( 'wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1025
-add_action( 'wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1026
-add_action( 'wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1027
-add_action( 'wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1028
-add_action( 'wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1029
-
1030
-function wpinv_settings_tab_bottom_emails( $active_tab, $section ) {
1018
+add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3);
1019
+add_action('wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1020
+add_action('wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1021
+add_action('wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1022
+add_action('wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1023
+add_action('wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1024
+add_action('wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1025
+add_action('wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1026
+add_action('wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1027
+add_action('wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2);
1028
+add_action('wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2);
1029
+
1030
+function wpinv_settings_tab_bottom_emails($active_tab, $section) {
1031 1031
     ?>
1032 1032
     <div class="wpinv-email-wc-row ">
1033 1033
         <div class="wpinv-email-wc-td">
1034
-            <h3 class="wpinv-email-wc-title"><?php echo apply_filters( 'wpinv_settings_email_wildcards_title', __( 'Wildcards For Emails', 'invoicing' ) ); ?></h3>
1034
+            <h3 class="wpinv-email-wc-title"><?php echo apply_filters('wpinv_settings_email_wildcards_title', __('Wildcards For Emails', 'invoicing')); ?></h3>
1035 1035
             <p class="wpinv-email-wc-description">
1036 1036
                 <?php
1037
-                $description = __( 'The following wildcards can be used in email subjects, heading and content:<br>
1037
+                $description = __('The following wildcards can be used in email subjects, heading and content:<br>
1038 1038
                     <strong>{site_title} :</strong> Site Title<br>
1039 1039
                     <strong>{name} :</strong> Customer\'s full name<br>
1040 1040
                     <strong>{first_name} :</strong> Customer\'s first name<br>
@@ -1048,7 +1048,7 @@  discard block
 block discarded – undo
1048 1048
                     <strong>{invoice_due_date} :</strong> The date the invoice is due<br>
1049 1049
                     <strong>{date} :</strong> Today\'s date.<br>
1050 1050
                     <strong>{is_was} :</strong> If due date of invoice is past, displays "was" otherwise displays "is"<br>
1051
-                    <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing' );
1051
+                    <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing');
1052 1052
                 echo apply_filters('wpinv_settings_email_wildcards_description', $description, $active_tab, $section);
1053 1053
                 ?>
1054 1054
             </p>
Please login to merge, or discard this patch.