Passed
Push — master ( 47b6fc...99ae46 )
by Brian
05:46 queued 20s
created
includes/wpinv-tax-functions.php 1 patch
Spacing   +120 added lines, -120 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 && 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 && 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', 0 );
138
-    return (float) apply_filters( 'wpinv_get_default_tax_rate', floatval( $rate ) );
137
+    $rate = wpinv_get_option('tax_rate', 0);
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', 'vat_too' );
147
+    return 'no' == wpinv_get_option('vat_same_country_rule', 'vat_too');
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,22 +195,22 @@  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
-    return apply_filters( 'getpaid_filter_item_tax_rates', $rates, $item );
213
+    return apply_filters('getpaid_filter_item_tax_rates', $rates, $item);
214 214
 }
215 215
 
216 216
 /**
@@ -220,12 +220,12 @@  discard block
 block discarded – undo
220 220
  * @param array $rates
221 221
  * @return array
222 222
  */
223
-function getpaid_calculate_item_taxes( $amount, $rates ) {
223
+function getpaid_calculate_item_taxes($amount, $rates) {
224 224
 
225 225
     $is_inclusive = wpinv_prices_include_tax();
226
-    $taxes        = GetPaid_Tax::calc_tax( $amount, $rates, $is_inclusive );
226
+    $taxes        = GetPaid_Tax::calc_tax($amount, $rates, $is_inclusive);
227 227
 
228
-    return apply_filters( 'getpaid_calculate_taxes', $taxes, $amount, $rates );
228
+    return apply_filters('getpaid_calculate_taxes', $taxes, $amount, $rates);
229 229
 }
230 230
 
231 231
 /**
@@ -237,17 +237,17 @@  discard block
 block discarded – undo
237 237
  * @param float $recurring_tax_amount
238 238
  * @return array
239 239
  */
240
-function getpaid_prepare_item_tax( $item, $tax_name, $tax_amount, $recurring_tax_amount ) {
240
+function getpaid_prepare_item_tax($item, $tax_name, $tax_amount, $recurring_tax_amount) {
241 241
 
242
-    $initial_tax   = $tax_amount;
242
+    $initial_tax = $tax_amount;
243 243
 	$recurring_tax = 0;
244 244
 
245
-    if ( $item->is_recurring() ) {
245
+    if ($item->is_recurring()) {
246 246
 		$recurring_tax = $recurring_tax_amount;
247 247
 	}
248 248
 
249 249
 	return array(
250
-		'name'          => sanitize_text_field( $tax_name ),
250
+		'name'          => sanitize_text_field($tax_name),
251 251
 		'initial_tax'   => $initial_tax,
252 252
 		'recurring_tax' => $recurring_tax,
253 253
     );
@@ -260,8 +260,8 @@  discard block
 block discarded – undo
260 260
  * @param string $vat_number
261 261
  * @return string
262 262
  */
263
-function wpinv_sanitize_vat_number( $vat_number ) {
264
-    return str_replace( array( ' ', '.', '-', '_', ',' ), '', strtoupper( trim( $vat_number ) ) );
263
+function wpinv_sanitize_vat_number($vat_number) {
264
+    return str_replace(array(' ', '.', '-', '_', ','), '', strtoupper(trim($vat_number)));
265 265
 }
266 266
 
267 267
 /**
@@ -270,22 +270,22 @@  discard block
 block discarded – undo
270 270
  * @param string $vat_number
271 271
  * @return bool
272 272
  */
273
-function wpinv_regex_validate_vat_number( $vat_number ) {
273
+function wpinv_regex_validate_vat_number($vat_number) {
274 274
 
275
-    $country    = substr( $vat_number, 0, 2 );
276
-    $vatin      = substr( $vat_number, 2 );
277
-    $regexes    = wpinv_get_data( 'vat-number-regexes' );
275
+    $country    = substr($vat_number, 0, 2);
276
+    $vatin      = substr($vat_number, 2);
277
+    $regexes    = wpinv_get_data('vat-number-regexes');
278 278
 
279
-    if ( isset( $regexes[ $country ] ) ) {
279
+    if (isset($regexes[$country])) {
280 280
 
281
-        $regex = $regexes[ $country ];
281
+        $regex = $regexes[$country];
282 282
         $regex = '/^(?:' . $regex . ')$/';
283
-        return 1 === preg_match( $regex, $vatin );
283
+        return 1 === preg_match($regex, $vatin);
284 284
 
285 285
     }
286 286
 
287 287
     // Not an EU state, use filters to validate the number.
288
-    return apply_filters( 'wpinv_regex_validate_vat_number', true, $vat_number );
288
+    return apply_filters('wpinv_regex_validate_vat_number', true, $vat_number);
289 289
 }
290 290
 
291 291
 /**
@@ -294,29 +294,29 @@  discard block
 block discarded – undo
294 294
  * @param string $vat_number
295 295
  * @return bool
296 296
  */
297
-function wpinv_vies_validate_vat_number( $vat_number ) {
297
+function wpinv_vies_validate_vat_number($vat_number) {
298 298
 
299
-    $country    = substr( $vat_number, 0, 2 );
300
-    $vatin      = substr( $vat_number, 2 );
299
+    $country    = substr($vat_number, 0, 2);
300
+    $vatin      = substr($vat_number, 2);
301 301
 
302 302
     $url        = add_query_arg(
303 303
         array(
304
-            'ms'  => urlencode( $country ),
305
-            'iso' => urlencode( $country ),
306
-            'vat' => urlencode( $vatin ),
304
+            'ms'  => urlencode($country),
305
+            'iso' => urlencode($country),
306
+            'vat' => urlencode($vatin),
307 307
         ),
308 308
         'http://ec.europa.eu/taxation_customs/vies/viesquer.do'
309 309
     );
310 310
 
311
-    $response   = wp_remote_get( $url );
312
-    $response   = wp_remote_retrieve_body( $response );
311
+    $response   = wp_remote_get($url);
312
+    $response   = wp_remote_retrieve_body($response);
313 313
 
314 314
     // Fallback gracefully if the VIES website is down.
315
-    if ( empty( $response ) ) {
315
+    if (empty($response)) {
316 316
         return true;
317 317
     }
318 318
 
319
-    return 1 !== preg_match( '/invalid VAT number/i', $response );
319
+    return 1 !== preg_match('/invalid VAT number/i', $response);
320 320
 
321 321
 }
322 322
 
@@ -327,18 +327,18 @@  discard block
 block discarded – undo
327 327
  * @param string $country
328 328
  * @return bool
329 329
  */
330
-function wpinv_validate_vat_number( $vat_number, $country ) {
330
+function wpinv_validate_vat_number($vat_number, $country) {
331 331
 
332 332
     // In case the vat number does not have a country code...
333
-    $vat_number = wpinv_sanitize_vat_number( $vat_number );
334
-    $_country   = substr( $vat_number, 0, 2 );
335
-    $_country   = $_country == wpinv_country_name( $_country );
333
+    $vat_number = wpinv_sanitize_vat_number($vat_number);
334
+    $_country   = substr($vat_number, 0, 2);
335
+    $_country   = $_country == wpinv_country_name($_country);
336 336
 
337
-    if ( $_country ) {
338
-        $vat_number = strtoupper( $country ) . $vat_number;
337
+    if ($_country) {
338
+        $vat_number = strtoupper($country) . $vat_number;
339 339
     }
340 340
 
341
-    return wpinv_regex_validate_vat_number( $vat_number ) && wpinv_vies_validate_vat_number( $vat_number );
341
+    return wpinv_regex_validate_vat_number($vat_number) && wpinv_vies_validate_vat_number($vat_number);
342 342
 }
343 343
 
344 344
 /**
@@ -347,39 +347,39 @@  discard block
 block discarded – undo
347 347
  * @return bool
348 348
  */
349 349
 function wpinv_should_validate_vat_number() {
350
-    $validate = wpinv_get_option( 'validate_vat_number' );
351
-	return ! empty( $validate );
350
+    $validate = wpinv_get_option('validate_vat_number');
351
+	return !empty($validate);
352 352
 }
353 353
 
354
-function wpinv_sales_tax_for_year( $year = null ) {
355
-    return wpinv_price( wpinv_get_sales_tax_for_year( $year ) );
354
+function wpinv_sales_tax_for_year($year = null) {
355
+    return wpinv_price(wpinv_get_sales_tax_for_year($year));
356 356
 }
357 357
 
358
-function wpinv_get_sales_tax_for_year( $year = null ) {
358
+function wpinv_get_sales_tax_for_year($year = null) {
359 359
     global $wpdb;
360 360
 
361 361
     // Start at zero
362 362
     $tax = 0;
363 363
 
364
-    if ( ! empty( $year ) ) {
364
+    if (!empty($year)) {
365 365
         $args = array(
366 366
             'post_type'      => 'wpi_invoice',
367
-            'post_status'    => array( 'publish' ),
367
+            'post_status'    => array('publish'),
368 368
             'posts_per_page' => -1,
369 369
             'year'           => $year,
370 370
             'fields'         => 'ids',
371 371
         );
372 372
 
373
-        $payments    = get_posts( $args );
374
-        $payment_ids = implode( ',', $payments );
373
+        $payments    = get_posts($args);
374
+        $payment_ids = implode(',', $payments);
375 375
 
376
-        if ( count( $payments ) > 0 ) {
376
+        if (count($payments) > 0) {
377 377
             $sql = "SELECT SUM( meta_value ) FROM $wpdb->postmeta WHERE meta_key = '_wpinv_tax' AND post_id IN( $payment_ids )";
378
-            $tax = $wpdb->get_var( $sql );
378
+            $tax = $wpdb->get_var($sql);
379 379
         }
380 380
 }
381 381
 
382
-    return apply_filters( 'wpinv_get_sales_tax_for_year', $tax, $year );
382
+    return apply_filters('wpinv_get_sales_tax_for_year', $tax, $year);
383 383
 }
384 384
 
385 385
 function wpinv_is_cart_taxed() {
@@ -388,34 +388,34 @@  discard block
 block discarded – undo
388 388
 
389 389
 function wpinv_prices_show_tax_on_checkout() {
390 390
     return false; // TODO
391
-    $ret = ( wpinv_get_option( 'checkout_include_tax', false ) == 'yes' && wpinv_use_taxes() );
391
+    $ret = (wpinv_get_option('checkout_include_tax', false) == 'yes' && wpinv_use_taxes());
392 392
 
393
-    return apply_filters( 'wpinv_taxes_on_prices_on_checkout', $ret );
393
+    return apply_filters('wpinv_taxes_on_prices_on_checkout', $ret);
394 394
 }
395 395
 
396 396
 function wpinv_display_tax_rate() {
397
-    $ret = wpinv_use_taxes() && wpinv_get_option( 'display_tax_rate', false );
397
+    $ret = wpinv_use_taxes() && wpinv_get_option('display_tax_rate', false);
398 398
 
399
-    return apply_filters( 'wpinv_display_tax_rate', $ret );
399
+    return apply_filters('wpinv_display_tax_rate', $ret);
400 400
 }
401 401
 
402 402
 function wpinv_cart_needs_tax_address_fields() {
403
-    if ( ! wpinv_is_cart_taxed() ) {
403
+    if (!wpinv_is_cart_taxed()) {
404 404
         return false;
405 405
     }
406 406
 
407
-    return ! did_action( 'wpinv_after_cc_fields', 'wpinv_default_cc_address_fields' );
407
+    return !did_action('wpinv_after_cc_fields', 'wpinv_default_cc_address_fields');
408 408
 }
409 409
 
410
-function wpinv_item_is_tax_exclusive( $item_id = 0 ) {
411
-    $ret = (bool)get_post_meta( $item_id, '_wpinv_tax_exclusive', false );
412
-    return apply_filters( 'wpinv_is_tax_exclusive', $ret, $item_id );
410
+function wpinv_item_is_tax_exclusive($item_id = 0) {
411
+    $ret = (bool) get_post_meta($item_id, '_wpinv_tax_exclusive', false);
412
+    return apply_filters('wpinv_is_tax_exclusive', $ret, $item_id);
413 413
 }
414 414
 
415
-function wpinv_currency_decimal_filter( $decimals = 2 ) {
415
+function wpinv_currency_decimal_filter($decimals = 2) {
416 416
     $currency = wpinv_get_currency();
417 417
 
418
-    switch ( $currency ) {
418
+    switch ($currency) {
419 419
         case 'RIAL':
420 420
         case 'JPY':
421 421
         case 'TWD':
@@ -424,13 +424,13 @@  discard block
 block discarded – undo
424 424
             break;
425 425
     }
426 426
 
427
-    return apply_filters( 'wpinv_currency_decimal_count', $decimals, $currency );
427
+    return apply_filters('wpinv_currency_decimal_count', $decimals, $currency);
428 428
 }
429 429
 
430 430
 function wpinv_tax_amount() {
431 431
     $output = 0.00;
432 432
 
433
-    return apply_filters( 'wpinv_tax_amount', $output );
433
+    return apply_filters('wpinv_tax_amount', $output);
434 434
 }
435 435
 
436 436
 /**
@@ -438,25 +438,25 @@  discard block
 block discarded – undo
438 438
  *
439 439
  * @param string|bool|null $vat_rule
440 440
  */
441
-function getpaid_filter_vat_rule( $vat_rule ) {
441
+function getpaid_filter_vat_rule($vat_rule) {
442 442
 
443
-    if ( empty( $vat_rule ) ) {
443
+    if (empty($vat_rule)) {
444 444
         return 'digital';
445 445
     }
446 446
 
447 447
     return $vat_rule;
448 448
 }
449
-add_filter( 'wpinv_get_item_vat_rule', 'getpaid_filter_vat_rule' );
449
+add_filter('wpinv_get_item_vat_rule', 'getpaid_filter_vat_rule');
450 450
 
451 451
 /**
452 452
  * Filters the VAT class to ensure that each item has a VAT class.
453 453
  *
454 454
  * @param string|bool|null $vat_rule
455 455
  */
456
-function getpaid_filter_vat_class( $vat_class ) {
457
-    return empty( $vat_class ) ? '_standard' : $vat_class;
456
+function getpaid_filter_vat_class($vat_class) {
457
+    return empty($vat_class) ? '_standard' : $vat_class;
458 458
 }
459
-add_filter( 'wpinv_get_item_vat_class', 'getpaid_filter_vat_class' );
459
+add_filter('wpinv_get_item_vat_class', 'getpaid_filter_vat_class');
460 460
 
461 461
 /**
462 462
  * Returns a list of all tax classes.
@@ -468,9 +468,9 @@  discard block
 block discarded – undo
468 468
     return apply_filters(
469 469
         'getpaid_tax_classes',
470 470
         array(
471
-            '_standard' => __( 'Standard Tax Rate', 'invoicing' ),
472
-            '_reduced'  => __( 'Reduced Tax Rate', 'invoicing' ),
473
-            '_exempt'   => __( 'Tax Exempt', 'invoicing' ),
471
+            '_standard' => __('Standard Tax Rate', 'invoicing'),
472
+            '_reduced'  => __('Reduced Tax Rate', 'invoicing'),
473
+            '_exempt'   => __('Tax Exempt', 'invoicing'),
474 474
         )
475 475
     );
476 476
 
@@ -486,8 +486,8 @@  discard block
 block discarded – undo
486 486
     return apply_filters(
487 487
         'getpaid_tax_rules',
488 488
         array(
489
-            'physical' => __( 'Physical Item', 'invoicing' ),
490
-            'digital'  => __( 'Digital Item', 'invoicing' ),
489
+            'physical' => __('Physical Item', 'invoicing'),
490
+            'digital'  => __('Digital Item', 'invoicing'),
491 491
         )
492 492
     );
493 493
 
@@ -499,15 +499,15 @@  discard block
 block discarded – undo
499 499
  * @param string $tax_class
500 500
  * @return string
501 501
  */
502
-function getpaid_get_tax_class_label( $tax_class ) {
502
+function getpaid_get_tax_class_label($tax_class) {
503 503
 
504 504
     $classes = getpaid_get_tax_classes();
505 505
 
506
-    if ( isset( $classes[ $tax_class ] ) ) {
507
-        return sanitize_text_field( $classes[ $tax_class ] );
506
+    if (isset($classes[$tax_class])) {
507
+        return sanitize_text_field($classes[$tax_class]);
508 508
     }
509 509
 
510
-    return sanitize_text_field( $tax_class );
510
+    return sanitize_text_field($tax_class);
511 511
 
512 512
 }
513 513
 
@@ -517,15 +517,15 @@  discard block
 block discarded – undo
517 517
  * @param string $tax_rule
518 518
  * @return string
519 519
  */
520
-function getpaid_get_tax_rule_label( $tax_rule ) {
520
+function getpaid_get_tax_rule_label($tax_rule) {
521 521
 
522 522
     $rules = getpaid_get_tax_rules();
523 523
 
524
-    if ( isset( $rules[ $tax_rule ] ) ) {
525
-        return sanitize_text_field( $rules[ $tax_rule ] );
524
+    if (isset($rules[$tax_rule])) {
525
+        return sanitize_text_field($rules[$tax_rule]);
526 526
     }
527 527
 
528
-    return sanitize_text_field( $tax_rule );
528
+    return sanitize_text_field($tax_rule);
529 529
 
530 530
 }
531 531
 
@@ -536,11 +536,11 @@  discard block
 block discarded – undo
536 536
  * @param string $recurring
537 537
  * @return string
538 538
  */
539
-function getpaid_get_taxable_amount( $item, $recurring = false ) {
539
+function getpaid_get_taxable_amount($item, $recurring = false) {
540 540
 
541 541
     $taxable_amount  = $recurring ? $item->get_recurring_sub_total() : $item->get_sub_total();
542 542
     $taxable_amount -= $recurring ? $item->recurring_item_discount : $item->item_discount;
543
-    $taxable_amount  = max( 0, $taxable_amount );
544
-    return apply_filters( 'getpaid_taxable_amount', $taxable_amount, $item, $recurring );
543
+    $taxable_amount  = max(0, $taxable_amount);
544
+    return apply_filters('getpaid_taxable_amount', $taxable_amount, $item, $recurring);
545 545
 
546 546
 }
Please login to merge, or discard this patch.
includes/geolocation/class-getpaid-geolocation.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  *
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * GetPaid_Geolocation Class.
@@ -64,30 +64,30 @@  discard block
 block discarded – undo
64 64
 
65 65
 		$transient_name = 'external_ip_address_0.0.0.0';
66 66
 
67
-		if ( '' !== self::get_ip_address() ) {
68
-			$transient_name      = 'external_ip_address_' . self::get_ip_address();
67
+		if ('' !== self::get_ip_address()) {
68
+			$transient_name = 'external_ip_address_' . self::get_ip_address();
69 69
 		}
70 70
 
71 71
 		// Try retrieving from cache.
72
-		$external_ip_address = get_transient( $transient_name );
72
+		$external_ip_address = get_transient($transient_name);
73 73
 
74
-		if ( false === $external_ip_address ) {
74
+		if (false === $external_ip_address) {
75 75
 			$external_ip_address     = '0.0.0.0';
76
-			$ip_lookup_services      = apply_filters( 'getpaid_geolocation_ip_lookup_apis', self::$ip_lookup_apis );
77
-			$ip_lookup_services_keys = array_keys( $ip_lookup_services );
78
-			shuffle( $ip_lookup_services_keys );
76
+			$ip_lookup_services      = apply_filters('getpaid_geolocation_ip_lookup_apis', self::$ip_lookup_apis);
77
+			$ip_lookup_services_keys = array_keys($ip_lookup_services);
78
+			shuffle($ip_lookup_services_keys);
79 79
 
80
-			foreach ( $ip_lookup_services_keys as $service_name ) {
81
-				$service_endpoint = $ip_lookup_services[ $service_name ];
82
-				$response         = wp_safe_remote_get( $service_endpoint, array( 'timeout' => 2 ) );
80
+			foreach ($ip_lookup_services_keys as $service_name) {
81
+				$service_endpoint = $ip_lookup_services[$service_name];
82
+				$response         = wp_safe_remote_get($service_endpoint, array('timeout' => 2));
83 83
 
84
-				if ( ! is_wp_error( $response ) && rest_is_ip_address( $response['body'] ) ) {
85
-					$external_ip_address = apply_filters( 'getpaid_geolocation_ip_lookup_api_response', wpinv_clean( $response['body'] ), $service_name );
84
+				if (!is_wp_error($response) && rest_is_ip_address($response['body'])) {
85
+					$external_ip_address = apply_filters('getpaid_geolocation_ip_lookup_api_response', wpinv_clean($response['body']), $service_name);
86 86
 					break;
87 87
 				}
88 88
 }
89 89
 
90
-			set_transient( $transient_name, $external_ip_address, WEEK_IN_SECONDS );
90
+			set_transient($transient_name, $external_ip_address, WEEK_IN_SECONDS);
91 91
 		}
92 92
 
93 93
 		return $external_ip_address;
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
 	 * @param  bool   $api_fallback If true, uses geolocation APIs if the database file doesn't exist (can be slower).
102 102
 	 * @return array
103 103
 	 */
104
-	public static function geolocate_ip( $ip_address = '', $fallback = false, $api_fallback = true ) {
104
+	public static function geolocate_ip($ip_address = '', $fallback = false, $api_fallback = true) {
105 105
 
106
-		if ( empty( $ip_address ) ) {
106
+		if (empty($ip_address)) {
107 107
 			$ip_address = self::get_ip_address();
108 108
 		}
109 109
 
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
 		self::$current_user_ip = $ip_address;
112 112
 
113 113
 		// Filter to allow custom geolocation of the IP address.
114
-		$country_code = apply_filters( 'getpaid_geolocate_ip', false, $ip_address, $fallback, $api_fallback );
114
+		$country_code = apply_filters('getpaid_geolocate_ip', false, $ip_address, $fallback, $api_fallback);
115 115
 
116
-		if ( false !== $country_code ) {
116
+		if (false !== $country_code) {
117 117
 
118 118
 			return array(
119 119
 				'country'  => $country_code,
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 		 * @param array  $geolocation Geolocation data, including country, state, city, and postcode.
134 134
 		 * @param string $ip_address  IP Address.
135 135
 		 */
136
-		$geolocation  = apply_filters(
136
+		$geolocation = apply_filters(
137 137
 			'getpaid_get_geolocation',
138 138
 			array(
139 139
 				'country'  => $country_code,
@@ -145,18 +145,18 @@  discard block
 block discarded – undo
145 145
 		);
146 146
 
147 147
 		// If we still haven't found a country code, let's consider doing an API lookup.
148
-		if ( '' === $geolocation['country'] && $api_fallback ) {
149
-			$geolocation['country'] = self::geolocate_via_api( $ip_address );
148
+		if ('' === $geolocation['country'] && $api_fallback) {
149
+			$geolocation['country'] = self::geolocate_via_api($ip_address);
150 150
 		}
151 151
 
152 152
 		// It's possible that we're in a local environment, in which case the geolocation needs to be done from the
153 153
 		// external address.
154
-		if ( '' === $geolocation['country'] && $fallback ) {
154
+		if ('' === $geolocation['country'] && $fallback) {
155 155
 			$external_ip_address = self::get_external_ip_address();
156 156
 
157 157
 			// Only bother with this if the external IP differs.
158
-			if ( '0.0.0.0' !== $external_ip_address && $external_ip_address !== $ip_address ) {
159
-				return self::geolocate_ip( $external_ip_address, false, $api_fallback );
158
+			if ('0.0.0.0' !== $external_ip_address && $external_ip_address !== $ip_address) {
159
+				return self::geolocate_ip($external_ip_address, false, $api_fallback);
160 160
 			}
161 161
 }
162 162
 
@@ -185,12 +185,12 @@  discard block
 block discarded – undo
185 185
 			'HTTP_X_COUNTRY_CODE',
186 186
 		);
187 187
 
188
-		foreach ( $headers as $header ) {
189
-			if ( empty( $_SERVER[ $header ] ) ) {
188
+		foreach ($headers as $header) {
189
+			if (empty($_SERVER[$header])) {
190 190
 				continue;
191 191
 			}
192 192
 
193
-			$country_code = strtoupper( sanitize_text_field( wp_unslash( $_SERVER[ $header ] ) ) );
193
+			$country_code = strtoupper(sanitize_text_field(wp_unslash($_SERVER[$header])));
194 194
 			break;
195 195
 		}
196 196
 
@@ -209,35 +209,35 @@  discard block
 block discarded – undo
209 209
 	 * @param  string $ip_address IP address.
210 210
 	 * @return string
211 211
 	 */
212
-	protected static function geolocate_via_api( $ip_address ) {
212
+	protected static function geolocate_via_api($ip_address) {
213 213
 
214 214
 		// Retrieve from cache...
215
-		$country_code = get_transient( 'geoip_' . $ip_address );
215
+		$country_code = get_transient('geoip_' . $ip_address);
216 216
 
217 217
 		// If missing, retrieve from the API.
218
-		if ( false === $country_code ) {
219
-			$geoip_services = apply_filters( 'getpaid_geolocation_geoip_apis', self::$geoip_apis );
218
+		if (false === $country_code) {
219
+			$geoip_services = apply_filters('getpaid_geolocation_geoip_apis', self::$geoip_apis);
220 220
 
221
-			if ( empty( $geoip_services ) ) {
221
+			if (empty($geoip_services)) {
222 222
 				return '';
223 223
 			}
224 224
 
225
-			$geoip_services_keys = array_keys( $geoip_services );
225
+			$geoip_services_keys = array_keys($geoip_services);
226 226
 
227
-			shuffle( $geoip_services_keys );
227
+			shuffle($geoip_services_keys);
228 228
 
229
-			foreach ( $geoip_services_keys as $service_name ) {
229
+			foreach ($geoip_services_keys as $service_name) {
230 230
 
231
-				$service_endpoint = $geoip_services[ $service_name ];
232
-				$response         = wp_safe_remote_get( sprintf( $service_endpoint, $ip_address ), array( 'timeout' => 2 ) );
233
-				$country_code     = sanitize_text_field( strtoupper( self::handle_geolocation_response( $response, $service_name ) ) );
231
+				$service_endpoint = $geoip_services[$service_name];
232
+				$response         = wp_safe_remote_get(sprintf($service_endpoint, $ip_address), array('timeout' => 2));
233
+				$country_code     = sanitize_text_field(strtoupper(self::handle_geolocation_response($response, $service_name)));
234 234
 
235
-				if ( ! empty( $country_code ) ) {
235
+				if (!empty($country_code)) {
236 236
 					break;
237 237
 				}
238 238
 }
239 239
 
240
-			set_transient( 'geoip_' . $ip_address, $country_code, WEEK_IN_SECONDS );
240
+			set_transient('geoip_' . $ip_address, $country_code, WEEK_IN_SECONDS);
241 241
 		}
242 242
 
243 243
 		return $country_code;
@@ -250,23 +250,23 @@  discard block
 block discarded – undo
250 250
 	 * @param  String $geolocation_service
251 251
 	 * @return string Country code
252 252
 	 */
253
-	protected static function handle_geolocation_response( $geolocation_response, $geolocation_service ) {
253
+	protected static function handle_geolocation_response($geolocation_response, $geolocation_service) {
254 254
 
255
-		if ( is_wp_error( $geolocation_response ) || empty( $geolocation_response['body'] ) ) {
255
+		if (is_wp_error($geolocation_response) || empty($geolocation_response['body'])) {
256 256
 			return '';
257 257
 		}
258 258
 
259
-		if ( $geolocation_service === 'ipinfo.io' ) {
260
-			$data = json_decode( $geolocation_response['body'] );
261
-			return empty( $data ) || empty( $data->country ) ? '' : $data->country;
259
+		if ($geolocation_service === 'ipinfo.io') {
260
+			$data = json_decode($geolocation_response['body']);
261
+			return empty($data) || empty($data->country) ? '' : $data->country;
262 262
 		}
263 263
 
264
-		if ( $geolocation_service === 'ip-api.com' ) {
265
-			$data = json_decode( $geolocation_response['body'] );
266
-			return empty( $data ) || empty( $data->countryCode ) ? '' : $data->countryCode;
264
+		if ($geolocation_service === 'ip-api.com') {
265
+			$data = json_decode($geolocation_response['body']);
266
+			return empty($data) || empty($data->countryCode) ? '' : $data->countryCode;
267 267
 		}
268 268
 
269
-		return apply_filters( 'getpaid_geolocation_geoip_response_' . $geolocation_service, '', $geolocation_response['body'] );
269
+		return apply_filters('getpaid_geolocation_geoip_response_' . $geolocation_service, '', $geolocation_response['body']);
270 270
 
271 271
 	}
272 272
 
Please login to merge, or discard this patch.
includes/class-wpinv-discount.php 1 patch
Spacing   +292 added lines, -292 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * @since   1.0.15
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * Discount class.
@@ -80,34 +80,34 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @param int|array|string|WPInv_Discount|WP_Post $discount discount data, object, ID or code.
82 82
 	 */
83
-	public function __construct( $discount = 0 ) {
84
-		parent::__construct( $discount );
83
+	public function __construct($discount = 0) {
84
+		parent::__construct($discount);
85 85
 
86
-		if ( is_numeric( $discount ) && 'wpi_discount' === get_post_type( $discount ) ) {
87
-			$this->set_id( $discount );
88
-		} elseif ( $discount instanceof self ) {
89
-			$this->set_id( $discount->get_id() );
90
-		} elseif ( ! empty( $discount->ID ) ) {
91
-			$this->set_id( $discount->ID );
92
-		} elseif ( is_array( $discount ) ) {
93
-			$this->set_props( $discount );
86
+		if (is_numeric($discount) && 'wpi_discount' === get_post_type($discount)) {
87
+			$this->set_id($discount);
88
+		} elseif ($discount instanceof self) {
89
+			$this->set_id($discount->get_id());
90
+		} elseif (!empty($discount->ID)) {
91
+			$this->set_id($discount->ID);
92
+		} elseif (is_array($discount)) {
93
+			$this->set_props($discount);
94 94
 
95
-			if ( isset( $discount['ID'] ) ) {
96
-				$this->set_id( $discount['ID'] );
95
+			if (isset($discount['ID'])) {
96
+				$this->set_id($discount['ID']);
97 97
 			}
98
-} elseif ( is_scalar( $discount ) && $discount = self::get_discount_id_by_code( $discount ) ) {
99
-			$this->set_id( $discount );
98
+} elseif (is_scalar($discount) && $discount = self::get_discount_id_by_code($discount)) {
99
+			$this->set_id($discount);
100 100
 		} else {
101
-			$this->set_object_read( true );
101
+			$this->set_object_read(true);
102 102
 		}
103 103
 
104 104
         // Load the datastore.
105
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
105
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
106 106
 
107
-		if ( $this->get_id() > 0 ) {
108
-            $this->post = get_post( $this->get_id() );
107
+		if ($this->get_id() > 0) {
108
+            $this->post = get_post($this->get_id());
109 109
             $this->ID   = $this->get_id();
110
-			$this->data_store->read( $this );
110
+			$this->data_store->read($this);
111 111
         }
112 112
 
113 113
 	}
@@ -123,36 +123,36 @@  discard block
 block discarded – undo
123 123
 	 * @since 1.0.15
124 124
 	 * @return array|bool array of discount details on success. False otherwise.
125 125
 	 */
126
-	public static function get_data_by( $field, $value ) {
126
+	public static function get_data_by($field, $value) {
127 127
 
128
-		if ( 'id' == strtolower( $field ) ) {
128
+		if ('id' == strtolower($field)) {
129 129
 			// Make sure the value is numeric to avoid casting objects, for example,
130 130
 			// to int 1.
131
-			if ( ! is_numeric( $value ) ) {
131
+			if (!is_numeric($value)) {
132 132
 				return false;
133 133
             }
134
-			$value = intval( $value );
135
-			if ( $value < 1 ) {
134
+			$value = intval($value);
135
+			if ($value < 1) {
136 136
 				return false;
137 137
             }
138 138
 		}
139 139
 
140
-		if ( ! $value || ! is_string( $field ) ) {
140
+		if (!$value || !is_string($field)) {
141 141
 			return false;
142 142
 		}
143 143
 
144
-		$field = trim( $field );
144
+		$field = trim($field);
145 145
 
146 146
 		// prepare query args
147
-		switch ( strtolower( $field ) ) {
147
+		switch (strtolower($field)) {
148 148
 			case 'id':
149 149
 				$discount_id = $value;
150
-				$args        = array( 'include' => array( $value ) );
150
+				$args        = array('include' => array($value));
151 151
 				break;
152 152
 			case 'discount_code':
153 153
 			case 'code':
154
-				$value       = trim( $value );
155
-				$discount_id = wp_cache_get( $value, 'WPInv_Discount_Codes' );
154
+				$value       = trim($value);
155
+				$discount_id = wp_cache_get($value, 'WPInv_Discount_Codes');
156 156
 				$args        = array(
157 157
 					'meta_key'   => '_wpi_discount_code',
158 158
 					'meta_value' => $value,
@@ -160,17 +160,17 @@  discard block
 block discarded – undo
160 160
 				break;
161 161
 			case 'name':
162 162
 				$discount_id = 0;
163
-				$args        = array( 'name' => trim( $value ) );
163
+				$args        = array('name' => trim($value));
164 164
 				break;
165 165
 			default:
166
-				$args        = apply_filters( "wpinv_discount_get_data_by_{$field}_args", null, $value );
167
-				if ( ! is_array( $args ) ) {
168
-					return apply_filters( "wpinv_discount_get_data_by_$field", false, $value );
166
+				$args        = apply_filters("wpinv_discount_get_data_by_{$field}_args", null, $value);
167
+				if (!is_array($args)) {
168
+					return apply_filters("wpinv_discount_get_data_by_$field", false, $value);
169 169
 				}
170 170
 }
171 171
 
172 172
 		// Check if there is a cached value.
173
-		if ( ! empty( $discount_id ) && $discount = wp_cache_get( (int) $discount_id, 'WPInv_Discounts' ) ) {
173
+		if (!empty($discount_id) && $discount = wp_cache_get((int) $discount_id, 'WPInv_Discounts')) {
174 174
 			return $discount;
175 175
 		}
176 176
 
@@ -179,13 +179,13 @@  discard block
 block discarded – undo
179 179
 			array(
180 180
 				'post_type'      => 'wpi_discount',
181 181
 				'posts_per_page' => 1,
182
-				'post_status'    => array( 'publish', 'pending', 'draft', 'expired' ),
182
+				'post_status'    => array('publish', 'pending', 'draft', 'expired'),
183 183
 			)
184 184
 		);
185 185
 
186
-		$discount = get_posts( $args );
186
+		$discount = get_posts($args);
187 187
 
188
-		if ( empty( $discount ) ) {
188
+		if (empty($discount)) {
189 189
 			return false;
190 190
 		}
191 191
 
@@ -194,31 +194,31 @@  discard block
 block discarded – undo
194 194
 		// Prepare the return data.
195 195
 		$return = array(
196 196
             'ID'             => $discount->ID,
197
-            'code'           => get_post_meta( $discount->ID, '_wpi_discount_code', true ),
198
-            'amount'         => get_post_meta( $discount->ID, '_wpi_discount_amount', true ),
197
+            'code'           => get_post_meta($discount->ID, '_wpi_discount_code', true),
198
+            'amount'         => get_post_meta($discount->ID, '_wpi_discount_amount', true),
199 199
             'date_created'   => $discount->post_date,
200 200
 			'date_modified'  => $discount->post_modified,
201 201
 			'status'         => $discount->post_status,
202
-			'start'          => get_post_meta( $discount->ID, '_wpi_discount_start', true ),
203
-            'expiration'     => get_post_meta( $discount->ID, '_wpi_discount_expiration', true ),
204
-            'type'           => get_post_meta( $discount->ID, '_wpi_discount_type', true ),
202
+			'start'          => get_post_meta($discount->ID, '_wpi_discount_start', true),
203
+            'expiration'     => get_post_meta($discount->ID, '_wpi_discount_expiration', true),
204
+            'type'           => get_post_meta($discount->ID, '_wpi_discount_type', true),
205 205
             'description'    => $discount->post_excerpt,
206
-            'uses'           => get_post_meta( $discount->ID, '_wpi_discount_uses', true ),
207
-            'is_single_use'  => get_post_meta( $discount->ID, '_wpi_discount_is_single_use', true ),
208
-            'items'          => get_post_meta( $discount->ID, '_wpi_discount_items', true ),
209
-            'excluded_items' => get_post_meta( $discount->ID, '_wpi_discount_excluded_items', true ),
210
-			'required_items' => get_post_meta( $discount->ID, '_wpi_discount_required_items', true ),
211
-            'max_uses'       => get_post_meta( $discount->ID, '_wpi_discount_max_uses', true ),
212
-            'is_recurring'   => get_post_meta( $discount->ID, '_wpi_discount_is_recurring', true ),
213
-            'min_total'      => get_post_meta( $discount->ID, '_wpi_discount_min_total', true ),
214
-            'max_total'      => get_post_meta( $discount->ID, '_wpi_discount_max_total', true ),
206
+            'uses'           => get_post_meta($discount->ID, '_wpi_discount_uses', true),
207
+            'is_single_use'  => get_post_meta($discount->ID, '_wpi_discount_is_single_use', true),
208
+            'items'          => get_post_meta($discount->ID, '_wpi_discount_items', true),
209
+            'excluded_items' => get_post_meta($discount->ID, '_wpi_discount_excluded_items', true),
210
+			'required_items' => get_post_meta($discount->ID, '_wpi_discount_required_items', true),
211
+            'max_uses'       => get_post_meta($discount->ID, '_wpi_discount_max_uses', true),
212
+            'is_recurring'   => get_post_meta($discount->ID, '_wpi_discount_is_recurring', true),
213
+            'min_total'      => get_post_meta($discount->ID, '_wpi_discount_min_total', true),
214
+            'max_total'      => get_post_meta($discount->ID, '_wpi_discount_max_total', true),
215 215
         );
216 216
 
217
-		$return = apply_filters( 'wpinv_discount_properties', $return );
217
+		$return = apply_filters('wpinv_discount_properties', $return);
218 218
 
219 219
 		// Update the cache with our data
220
-		wp_cache_add( $discount->ID, $return, 'WPInv_Discounts' );
221
-		wp_cache_add( $return['code'], $discount->ID, 'WPInv_Discount_Codes' );
220
+		wp_cache_add($discount->ID, $return, 'WPInv_Discounts');
221
+		wp_cache_add($return['code'], $discount->ID, 'WPInv_Discount_Codes');
222 222
 
223 223
 		return $return;
224 224
 	}
@@ -232,19 +232,19 @@  discard block
 block discarded – undo
232 232
 	 * @since 1.0.15
233 233
 	 * @return int
234 234
 	 */
235
-	public static function get_discount_id_by_code( $discount_code ) {
235
+	public static function get_discount_id_by_code($discount_code) {
236 236
 
237 237
 		// Trim the code.
238
-		$discount_code = trim( $discount_code );
238
+		$discount_code = trim($discount_code);
239 239
 
240 240
 		// Ensure a value has been passed.
241
-		if ( empty( $discount_code ) ) {
241
+		if (empty($discount_code)) {
242 242
 			return 0;
243 243
 		}
244 244
 
245 245
 		// Maybe retrieve from the cache.
246
-		$discount_id   = wp_cache_get( $discount_code, 'getpaid_discount_codes' );
247
-		if ( ! empty( $discount_id ) ) {
246
+		$discount_id = wp_cache_get($discount_code, 'getpaid_discount_codes');
247
+		if (!empty($discount_id)) {
248 248
 			return $discount_id;
249 249
 		}
250 250
 
@@ -255,19 +255,19 @@  discard block
 block discarded – undo
255 255
 				'meta_value'     => $discount_code,
256 256
 				'post_type'      => 'wpi_discount',
257 257
 				'posts_per_page' => 1,
258
-				'post_status'    => array( 'publish', 'pending', 'draft', 'expired' ),
258
+				'post_status'    => array('publish', 'pending', 'draft', 'expired'),
259 259
 				'fields'         => 'ids',
260 260
 			)
261 261
 		);
262 262
 
263
-		if ( empty( $discounts ) ) {
263
+		if (empty($discounts)) {
264 264
 			return 0;
265 265
 		}
266 266
 
267 267
 		$discount_id = $discounts[0];
268 268
 
269 269
 		// Update the cache with our data
270
-		wp_cache_add( get_post_meta( $discount_id, '_wpi_discount_code', true ), $discount_id, 'getpaid_discount_codes' );
270
+		wp_cache_add(get_post_meta($discount_id, '_wpi_discount_code', true), $discount_id, 'getpaid_discount_codes');
271 271
 
272 272
 		return $discount_id;
273 273
 	}
@@ -280,8 +280,8 @@  discard block
 block discarded – undo
280 280
 	 *
281 281
 	 * @return bool Whether the given discount field is set.
282 282
 	 */
283
-	public function __isset( $key ) {
284
-		return isset( $this->data[ $key ] ) || method_exists( $this, "get_$key" );
283
+	public function __isset($key) {
284
+		return isset($this->data[$key]) || method_exists($this, "get_$key");
285 285
 	}
286 286
 
287 287
 	/*
@@ -306,8 +306,8 @@  discard block
 block discarded – undo
306 306
 	 * @param  string $context View or edit context.
307 307
 	 * @return string
308 308
 	 */
309
-	public function get_status( $context = 'view' ) {
310
-		return $this->get_prop( 'status', $context );
309
+	public function get_status($context = 'view') {
310
+		return $this->get_prop('status', $context);
311 311
     }
312 312
 
313 313
     /**
@@ -317,8 +317,8 @@  discard block
 block discarded – undo
317 317
 	 * @param  string $context View or edit context.
318 318
 	 * @return string
319 319
 	 */
320
-	public function get_version( $context = 'view' ) {
321
-		return $this->get_prop( 'version', $context );
320
+	public function get_version($context = 'view') {
321
+		return $this->get_prop('version', $context);
322 322
     }
323 323
 
324 324
     /**
@@ -328,8 +328,8 @@  discard block
 block discarded – undo
328 328
 	 * @param  string $context View or edit context.
329 329
 	 * @return string
330 330
 	 */
331
-	public function get_date_created( $context = 'view' ) {
332
-		return $this->get_prop( 'date_created', $context );
331
+	public function get_date_created($context = 'view') {
332
+		return $this->get_prop('date_created', $context);
333 333
     }
334 334
 
335 335
     /**
@@ -339,11 +339,11 @@  discard block
 block discarded – undo
339 339
 	 * @param  string $context View or edit context.
340 340
 	 * @return string
341 341
 	 */
342
-	public function get_date_created_gmt( $context = 'view' ) {
343
-        $date = $this->get_date_created( $context );
342
+	public function get_date_created_gmt($context = 'view') {
343
+        $date = $this->get_date_created($context);
344 344
 
345
-        if ( $date ) {
346
-            $date = get_gmt_from_date( $date );
345
+        if ($date) {
346
+            $date = get_gmt_from_date($date);
347 347
         }
348 348
 		return $date;
349 349
     }
@@ -355,8 +355,8 @@  discard block
 block discarded – undo
355 355
 	 * @param  string $context View or edit context.
356 356
 	 * @return string
357 357
 	 */
358
-	public function get_date_modified( $context = 'view' ) {
359
-		return $this->get_prop( 'date_modified', $context );
358
+	public function get_date_modified($context = 'view') {
359
+		return $this->get_prop('date_modified', $context);
360 360
     }
361 361
 
362 362
     /**
@@ -366,11 +366,11 @@  discard block
 block discarded – undo
366 366
 	 * @param  string $context View or edit context.
367 367
 	 * @return string
368 368
 	 */
369
-	public function get_date_modified_gmt( $context = 'view' ) {
370
-        $date = $this->get_date_modified( $context );
369
+	public function get_date_modified_gmt($context = 'view') {
370
+        $date = $this->get_date_modified($context);
371 371
 
372
-        if ( $date ) {
373
-            $date = get_gmt_from_date( $date );
372
+        if ($date) {
373
+            $date = get_gmt_from_date($date);
374 374
         }
375 375
 		return $date;
376 376
     }
@@ -382,8 +382,8 @@  discard block
 block discarded – undo
382 382
 	 * @param  string $context View or edit context.
383 383
 	 * @return string
384 384
 	 */
385
-	public function get_name( $context = 'view' ) {
386
-		return $this->get_prop( 'name', $context );
385
+	public function get_name($context = 'view') {
386
+		return $this->get_prop('name', $context);
387 387
     }
388 388
 
389 389
     /**
@@ -393,8 +393,8 @@  discard block
 block discarded – undo
393 393
 	 * @param  string $context View or edit context.
394 394
 	 * @return string
395 395
 	 */
396
-	public function get_title( $context = 'view' ) {
397
-		return $this->get_name( $context );
396
+	public function get_title($context = 'view') {
397
+		return $this->get_name($context);
398 398
     }
399 399
 
400 400
     /**
@@ -404,8 +404,8 @@  discard block
 block discarded – undo
404 404
 	 * @param  string $context View or edit context.
405 405
 	 * @return string
406 406
 	 */
407
-	public function get_description( $context = 'view' ) {
408
-		return $this->get_prop( 'description', $context );
407
+	public function get_description($context = 'view') {
408
+		return $this->get_prop('description', $context);
409 409
     }
410 410
 
411 411
     /**
@@ -415,8 +415,8 @@  discard block
 block discarded – undo
415 415
 	 * @param  string $context View or edit context.
416 416
 	 * @return string
417 417
 	 */
418
-	public function get_excerpt( $context = 'view' ) {
419
-		return $this->get_description( $context );
418
+	public function get_excerpt($context = 'view') {
419
+		return $this->get_description($context);
420 420
     }
421 421
 
422 422
     /**
@@ -426,8 +426,8 @@  discard block
 block discarded – undo
426 426
 	 * @param  string $context View or edit context.
427 427
 	 * @return string
428 428
 	 */
429
-	public function get_summary( $context = 'view' ) {
430
-		return $this->get_description( $context );
429
+	public function get_summary($context = 'view') {
430
+		return $this->get_description($context);
431 431
     }
432 432
 
433 433
     /**
@@ -437,8 +437,8 @@  discard block
 block discarded – undo
437 437
 	 * @param  string $context View or edit context.
438 438
 	 * @return string
439 439
 	 */
440
-	public function get_author( $context = 'view' ) {
441
-		return (int) $this->get_prop( 'author', $context );
440
+	public function get_author($context = 'view') {
441
+		return (int) $this->get_prop('author', $context);
442 442
 	}
443 443
 
444 444
 	/**
@@ -448,8 +448,8 @@  discard block
 block discarded – undo
448 448
 	 * @param  string $context View or edit context.
449 449
 	 * @return string
450 450
 	 */
451
-	public function get_code( $context = 'view' ) {
452
-		return $this->get_prop( 'code', $context );
451
+	public function get_code($context = 'view') {
452
+		return $this->get_prop('code', $context);
453 453
 	}
454 454
 
455 455
 	/**
@@ -459,8 +459,8 @@  discard block
 block discarded – undo
459 459
 	 * @param  string $context View or edit context.
460 460
 	 * @return string
461 461
 	 */
462
-	public function get_coupon_code( $context = 'view' ) {
463
-		return $this->get_code( $context );
462
+	public function get_coupon_code($context = 'view') {
463
+		return $this->get_code($context);
464 464
 	}
465 465
 
466 466
 	/**
@@ -470,8 +470,8 @@  discard block
 block discarded – undo
470 470
 	 * @param  string $context View or edit context.
471 471
 	 * @return string
472 472
 	 */
473
-	public function get_discount_code( $context = 'view' ) {
474
-		return $this->get_code( $context );
473
+	public function get_discount_code($context = 'view') {
474
+		return $this->get_code($context);
475 475
 	}
476 476
 
477 477
 	/**
@@ -481,8 +481,8 @@  discard block
 block discarded – undo
481 481
 	 * @param  string $context View or edit context.
482 482
 	 * @return float
483 483
 	 */
484
-	public function get_amount( $context = 'view' ) {
485
-		return $context == 'view' ? floatval( $this->get_prop( 'amount', $context ) ) : $this->get_prop( 'amount', $context );
484
+	public function get_amount($context = 'view') {
485
+		return $context == 'view' ? floatval($this->get_prop('amount', $context)) : $this->get_prop('amount', $context);
486 486
 	}
487 487
 
488 488
 	/**
@@ -493,13 +493,13 @@  discard block
 block discarded – undo
493 493
 	 */
494 494
 	public function get_formatted_amount() {
495 495
 
496
-		if ( $this->is_type( 'flat' ) ) {
497
-			$rate = wpinv_price( $this->get_amount() );
496
+		if ($this->is_type('flat')) {
497
+			$rate = wpinv_price($this->get_amount());
498 498
 		} else {
499 499
 			$rate = $this->get_amount() . '%';
500 500
 		}
501 501
 
502
-		return apply_filters( 'wpinv_format_discount_rate', $rate, $this->get_type(), $this->get_amount() );
502
+		return apply_filters('wpinv_format_discount_rate', $rate, $this->get_type(), $this->get_amount());
503 503
 	}
504 504
 
505 505
 	/**
@@ -509,8 +509,8 @@  discard block
 block discarded – undo
509 509
 	 * @param  string $context View or edit context.
510 510
 	 * @return string
511 511
 	 */
512
-	public function get_start( $context = 'view' ) {
513
-		return $this->get_prop( 'start', $context );
512
+	public function get_start($context = 'view') {
513
+		return $this->get_prop('start', $context);
514 514
 	}
515 515
 
516 516
 	/**
@@ -520,8 +520,8 @@  discard block
 block discarded – undo
520 520
 	 * @param  string $context View or edit context.
521 521
 	 * @return string
522 522
 	 */
523
-	public function get_start_date( $context = 'view' ) {
524
-		return $this->get_start( $context );
523
+	public function get_start_date($context = 'view') {
524
+		return $this->get_start($context);
525 525
 	}
526 526
 
527 527
 	/**
@@ -531,8 +531,8 @@  discard block
 block discarded – undo
531 531
 	 * @param  string $context View or edit context.
532 532
 	 * @return string
533 533
 	 */
534
-	public function get_expiration( $context = 'view' ) {
535
-		return $this->get_prop( 'expiration', $context );
534
+	public function get_expiration($context = 'view') {
535
+		return $this->get_prop('expiration', $context);
536 536
 	}
537 537
 
538 538
 	/**
@@ -542,8 +542,8 @@  discard block
 block discarded – undo
542 542
 	 * @param  string $context View or edit context.
543 543
 	 * @return string
544 544
 	 */
545
-	public function get_expiration_date( $context = 'view' ) {
546
-		return $this->get_expiration( $context );
545
+	public function get_expiration_date($context = 'view') {
546
+		return $this->get_expiration($context);
547 547
 	}
548 548
 
549 549
 	/**
@@ -553,8 +553,8 @@  discard block
 block discarded – undo
553 553
 	 * @param  string $context View or edit context.
554 554
 	 * @return string
555 555
 	 */
556
-	public function get_end_date( $context = 'view' ) {
557
-		return $this->get_expiration( $context );
556
+	public function get_end_date($context = 'view') {
557
+		return $this->get_expiration($context);
558 558
 	}
559 559
 
560 560
 	/**
@@ -564,8 +564,8 @@  discard block
 block discarded – undo
564 564
 	 * @param  string $context View or edit context.
565 565
 	 * @return string
566 566
 	 */
567
-	public function get_type( $context = 'view' ) {
568
-		return $this->get_prop( 'type', $context );
567
+	public function get_type($context = 'view') {
568
+		return $this->get_prop('type', $context);
569 569
 	}
570 570
 
571 571
 	/**
@@ -575,8 +575,8 @@  discard block
 block discarded – undo
575 575
 	 * @param  string $context View or edit context.
576 576
 	 * @return int
577 577
 	 */
578
-	public function get_uses( $context = 'view' ) {
579
-		return (int) $this->get_prop( 'uses', $context );
578
+	public function get_uses($context = 'view') {
579
+		return (int) $this->get_prop('uses', $context);
580 580
 	}
581 581
 
582 582
 	/**
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
 	 */
588 588
 	public function get_usage() {
589 589
 
590
-		if ( ! $this->has_limit() ) {
590
+		if (!$this->has_limit()) {
591 591
 			return $this->get_uses() . ' / ' . ' &infin;';
592 592
 		}
593 593
 
@@ -602,9 +602,9 @@  discard block
 block discarded – undo
602 602
 	 * @param  string $context View or edit context.
603 603
 	 * @return int
604 604
 	 */
605
-	public function get_max_uses( $context = 'view' ) {
606
-		$max_uses = $this->get_prop( 'max_uses', $context );
607
-		return empty( $max_uses ) ? null : $max_uses;
605
+	public function get_max_uses($context = 'view') {
606
+		$max_uses = $this->get_prop('max_uses', $context);
607
+		return empty($max_uses) ? null : $max_uses;
608 608
 	}
609 609
 
610 610
 	/**
@@ -614,8 +614,8 @@  discard block
 block discarded – undo
614 614
 	 * @param  string $context View or edit context.
615 615
 	 * @return bool
616 616
 	 */
617
-	public function get_is_single_use( $context = 'view' ) {
618
-		return $this->get_prop( 'is_single_use', $context );
617
+	public function get_is_single_use($context = 'view') {
618
+		return $this->get_prop('is_single_use', $context);
619 619
 	}
620 620
 
621 621
 	/**
@@ -625,8 +625,8 @@  discard block
 block discarded – undo
625 625
 	 * @param  string $context View or edit context.
626 626
 	 * @return array
627 627
 	 */
628
-	public function get_items( $context = 'view' ) {
629
-		return array_filter( wp_parse_id_list( $this->get_prop( 'items', $context ) ) );
628
+	public function get_items($context = 'view') {
629
+		return array_filter(wp_parse_id_list($this->get_prop('items', $context)));
630 630
 	}
631 631
 
632 632
 	/**
@@ -636,8 +636,8 @@  discard block
 block discarded – undo
636 636
 	 * @param  string $context View or edit context.
637 637
 	 * @return array
638 638
 	 */
639
-	public function get_allowed_items( $context = 'view' ) {
640
-		return $this->get_items( $context );
639
+	public function get_allowed_items($context = 'view') {
640
+		return $this->get_items($context);
641 641
 	}
642 642
 
643 643
 	/**
@@ -647,8 +647,8 @@  discard block
 block discarded – undo
647 647
 	 * @param  string $context View or edit context.
648 648
 	 * @return array
649 649
 	 */
650
-	public function get_excluded_items( $context = 'view' ) {
651
-		return array_filter( wp_parse_id_list( $this->get_prop( 'excluded_items', $context ) ) );
650
+	public function get_excluded_items($context = 'view') {
651
+		return array_filter(wp_parse_id_list($this->get_prop('excluded_items', $context)));
652 652
 	}
653 653
 
654 654
 	/**
@@ -658,8 +658,8 @@  discard block
 block discarded – undo
658 658
 	 * @param  string $context View or edit context.
659 659
 	 * @return array
660 660
 	 */
661
-	public function get_required_items( $context = 'view' ) {
662
-		return array_filter( wp_parse_id_list( $this->get_prop( 'required_items', $context ) ) );
661
+	public function get_required_items($context = 'view') {
662
+		return array_filter(wp_parse_id_list($this->get_prop('required_items', $context)));
663 663
 	}
664 664
 
665 665
 	/**
@@ -669,8 +669,8 @@  discard block
 block discarded – undo
669 669
 	 * @param  string $context View or edit context.
670 670
 	 * @return int|string|bool
671 671
 	 */
672
-	public function get_is_recurring( $context = 'view' ) {
673
-		return $this->get_prop( 'is_recurring', $context );
672
+	public function get_is_recurring($context = 'view') {
673
+		return $this->get_prop('is_recurring', $context);
674 674
 	}
675 675
 
676 676
 	/**
@@ -680,9 +680,9 @@  discard block
 block discarded – undo
680 680
 	 * @param  string $context View or edit context.
681 681
 	 * @return float
682 682
 	 */
683
-	public function get_min_total( $context = 'view' ) {
684
-		$minimum = $this->get_prop( 'min_total', $context );
685
-		return empty( $minimum ) ? null : $minimum;
683
+	public function get_min_total($context = 'view') {
684
+		$minimum = $this->get_prop('min_total', $context);
685
+		return empty($minimum) ? null : $minimum;
686 686
 	}
687 687
 
688 688
 	/**
@@ -692,8 +692,8 @@  discard block
 block discarded – undo
692 692
 	 * @param  string $context View or edit context.
693 693
 	 * @return float
694 694
 	 */
695
-	public function get_minimum_total( $context = 'view' ) {
696
-		return $this->get_min_total( $context );
695
+	public function get_minimum_total($context = 'view') {
696
+		return $this->get_min_total($context);
697 697
 	}
698 698
 
699 699
 	/**
@@ -703,9 +703,9 @@  discard block
 block discarded – undo
703 703
 	 * @param  string $context View or edit context.
704 704
 	 * @return float
705 705
 	 */
706
-	public function get_max_total( $context = 'view' ) {
707
-		$maximum = $this->get_prop( 'max_total', $context );
708
-		return empty( $maximum ) ? null : $maximum;
706
+	public function get_max_total($context = 'view') {
707
+		$maximum = $this->get_prop('max_total', $context);
708
+		return empty($maximum) ? null : $maximum;
709 709
 	}
710 710
 
711 711
 	/**
@@ -715,8 +715,8 @@  discard block
 block discarded – undo
715 715
 	 * @param  string $context View or edit context.
716 716
 	 * @return float
717 717
 	 */
718
-	public function get_maximum_total( $context = 'view' ) {
719
-		return $this->get_max_total( $context );
718
+	public function get_maximum_total($context = 'view') {
719
+		return $this->get_max_total($context);
720 720
 	}
721 721
 
722 722
 	/**
@@ -729,8 +729,8 @@  discard block
 block discarded – undo
729 729
 	 * @param  string $context View or edit context.
730 730
 	 * @return mixed Value of the given discount property (if set).
731 731
 	 */
732
-	public function get( $key, $context = 'view' ) {
733
-        return $this->get_prop( $key, $context );
732
+	public function get($key, $context = 'view') {
733
+        return $this->get_prop($key, $context);
734 734
 	}
735 735
 
736 736
 	/*
@@ -750,10 +750,10 @@  discard block
 block discarded – undo
750 750
 	 * @param  string $status New status.
751 751
 	 * @return array details of change.
752 752
 	 */
753
-	public function set_status( $status ) {
753
+	public function set_status($status) {
754 754
         $old_status = $this->get_status();
755 755
 
756
-        $this->set_prop( 'status', $status );
756
+        $this->set_prop('status', $status);
757 757
 
758 758
 		return array(
759 759
 			'from' => $old_status,
@@ -766,8 +766,8 @@  discard block
 block discarded – undo
766 766
 	 *
767 767
 	 * @since 1.0.19
768 768
 	 */
769
-	public function set_version( $value ) {
770
-		$this->set_prop( 'version', $value );
769
+	public function set_version($value) {
770
+		$this->set_prop('version', $value);
771 771
     }
772 772
 
773 773
     /**
@@ -777,11 +777,11 @@  discard block
 block discarded – undo
777 777
 	 * @param string $value Value to set.
778 778
      * @return bool Whether or not the date was set.
779 779
 	 */
780
-	public function set_date_created( $value ) {
781
-        $date = strtotime( $value );
780
+	public function set_date_created($value) {
781
+        $date = strtotime($value);
782 782
 
783
-        if ( $date ) {
784
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
783
+        if ($date) {
784
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
785 785
             return true;
786 786
         }
787 787
 
@@ -796,11 +796,11 @@  discard block
 block discarded – undo
796 796
 	 * @param string $value Value to set.
797 797
      * @return bool Whether or not the date was set.
798 798
 	 */
799
-	public function set_date_modified( $value ) {
800
-        $date = strtotime( $value );
799
+	public function set_date_modified($value) {
800
+        $date = strtotime($value);
801 801
 
802
-        if ( $date ) {
803
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
802
+        if ($date) {
803
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
804 804
             return true;
805 805
         }
806 806
 
@@ -814,9 +814,9 @@  discard block
 block discarded – undo
814 814
 	 * @since 1.0.19
815 815
 	 * @param  string $value New name.
816 816
 	 */
817
-	public function set_name( $value ) {
818
-        $name = sanitize_text_field( $value );
819
-		$this->set_prop( 'name', $name );
817
+	public function set_name($value) {
818
+        $name = sanitize_text_field($value);
819
+		$this->set_prop('name', $name);
820 820
     }
821 821
 
822 822
     /**
@@ -825,8 +825,8 @@  discard block
 block discarded – undo
825 825
 	 * @since 1.0.19
826 826
 	 * @param  string $value New name.
827 827
 	 */
828
-	public function set_title( $value ) {
829
-		$this->set_name( $value );
828
+	public function set_title($value) {
829
+		$this->set_name($value);
830 830
     }
831 831
 
832 832
     /**
@@ -835,9 +835,9 @@  discard block
 block discarded – undo
835 835
 	 * @since 1.0.19
836 836
 	 * @param  string $value New description.
837 837
 	 */
838
-	public function set_description( $value ) {
839
-        $description = wp_kses_post( $value );
840
-		return $this->set_prop( 'description', $description );
838
+	public function set_description($value) {
839
+        $description = wp_kses_post($value);
840
+		return $this->set_prop('description', $description);
841 841
     }
842 842
 
843 843
     /**
@@ -846,8 +846,8 @@  discard block
 block discarded – undo
846 846
 	 * @since 1.0.19
847 847
 	 * @param  string $value New description.
848 848
 	 */
849
-	public function set_excerpt( $value ) {
850
-		$this->set_description( $value );
849
+	public function set_excerpt($value) {
850
+		$this->set_description($value);
851 851
     }
852 852
 
853 853
     /**
@@ -856,8 +856,8 @@  discard block
 block discarded – undo
856 856
 	 * @since 1.0.19
857 857
 	 * @param  string $value New description.
858 858
 	 */
859
-	public function set_summary( $value ) {
860
-		$this->set_description( $value );
859
+	public function set_summary($value) {
860
+		$this->set_description($value);
861 861
     }
862 862
 
863 863
     /**
@@ -866,8 +866,8 @@  discard block
 block discarded – undo
866 866
 	 * @since 1.0.19
867 867
 	 * @param  int $value New author.
868 868
 	 */
869
-	public function set_author( $value ) {
870
-		$this->set_prop( 'author', (int) $value );
869
+	public function set_author($value) {
870
+		$this->set_prop('author', (int) $value);
871 871
 	}
872 872
 
873 873
 	/**
@@ -876,9 +876,9 @@  discard block
 block discarded – undo
876 876
 	 * @since 1.0.19
877 877
 	 * @param string $value New discount code.
878 878
 	 */
879
-	public function set_code( $value ) {
880
-		$code = sanitize_text_field( $value );
881
-		$this->set_prop( 'code', $code );
879
+	public function set_code($value) {
880
+		$code = sanitize_text_field($value);
881
+		$this->set_prop('code', $code);
882 882
 	}
883 883
 
884 884
 	/**
@@ -887,8 +887,8 @@  discard block
 block discarded – undo
887 887
 	 * @since 1.0.19
888 888
 	 * @param string $value New discount code.
889 889
 	 */
890
-	public function set_coupon_code( $value ) {
891
-		$this->set_code( $value );
890
+	public function set_coupon_code($value) {
891
+		$this->set_code($value);
892 892
 	}
893 893
 
894 894
 	/**
@@ -897,8 +897,8 @@  discard block
 block discarded – undo
897 897
 	 * @since 1.0.19
898 898
 	 * @param string $value New discount code.
899 899
 	 */
900
-	public function set_discount_code( $value ) {
901
-		$this->set_code( $value );
900
+	public function set_discount_code($value) {
901
+		$this->set_code($value);
902 902
 	}
903 903
 
904 904
 	/**
@@ -907,9 +907,9 @@  discard block
 block discarded – undo
907 907
 	 * @since 1.0.19
908 908
 	 * @param float $value New discount code.
909 909
 	 */
910
-	public function set_amount( $value ) {
911
-		$amount = floatval( wpinv_sanitize_amount( $value ) );
912
-		$this->set_prop( 'amount', $amount );
910
+	public function set_amount($value) {
911
+		$amount = floatval(wpinv_sanitize_amount($value));
912
+		$this->set_prop('amount', $amount);
913 913
 	}
914 914
 
915 915
 	/**
@@ -918,15 +918,15 @@  discard block
 block discarded – undo
918 918
 	 * @since 1.0.19
919 919
 	 * @param float $value New start date.
920 920
 	 */
921
-	public function set_start( $value ) {
922
-		$date = strtotime( $value );
921
+	public function set_start($value) {
922
+		$date = strtotime($value);
923 923
 
924
-        if ( $date ) {
925
-            $this->set_prop( 'start', date( 'Y-m-d H:i', $date ) );
924
+        if ($date) {
925
+            $this->set_prop('start', date('Y-m-d H:i', $date));
926 926
             return true;
927 927
 		}
928 928
 
929
-		$this->set_prop( 'start', '' );
929
+		$this->set_prop('start', '');
930 930
 
931 931
         return false;
932 932
 	}
@@ -937,8 +937,8 @@  discard block
 block discarded – undo
937 937
 	 * @since 1.0.19
938 938
 	 * @param string $value New start date.
939 939
 	 */
940
-	public function set_start_date( $value ) {
941
-		$this->set_start( $value );
940
+	public function set_start_date($value) {
941
+		$this->set_start($value);
942 942
 	}
943 943
 
944 944
 	/**
@@ -947,15 +947,15 @@  discard block
 block discarded – undo
947 947
 	 * @since 1.0.19
948 948
 	 * @param float $value New expiration date.
949 949
 	 */
950
-	public function set_expiration( $value ) {
951
-		$date = strtotime( $value );
950
+	public function set_expiration($value) {
951
+		$date = strtotime($value);
952 952
 
953
-        if ( $date ) {
954
-            $this->set_prop( 'expiration', date( 'Y-m-d H:i', $date ) );
953
+        if ($date) {
954
+            $this->set_prop('expiration', date('Y-m-d H:i', $date));
955 955
             return true;
956 956
         }
957 957
 
958
-		$this->set_prop( 'expiration', '' );
958
+		$this->set_prop('expiration', '');
959 959
         return false;
960 960
 	}
961 961
 
@@ -965,8 +965,8 @@  discard block
 block discarded – undo
965 965
 	 * @since 1.0.19
966 966
 	 * @param string $value New expiration date.
967 967
 	 */
968
-	public function set_expiration_date( $value ) {
969
-		$this->set_expiration( $value );
968
+	public function set_expiration_date($value) {
969
+		$this->set_expiration($value);
970 970
 	}
971 971
 
972 972
 	/**
@@ -975,8 +975,8 @@  discard block
 block discarded – undo
975 975
 	 * @since 1.0.19
976 976
 	 * @param string $value New expiration date.
977 977
 	 */
978
-	public function set_end_date( $value ) {
979
-		$this->set_expiration( $value );
978
+	public function set_end_date($value) {
979
+		$this->set_expiration($value);
980 980
 	}
981 981
 
982 982
 	/**
@@ -985,9 +985,9 @@  discard block
 block discarded – undo
985 985
 	 * @since 1.0.19
986 986
 	 * @param string $value New discount type.
987 987
 	 */
988
-	public function set_type( $value ) {
989
-		if ( $value && array_key_exists( sanitize_text_field( $value ), wpinv_get_discount_types() ) ) {
990
-			$this->set_prop( 'type', sanitize_text_field( $value ) );
988
+	public function set_type($value) {
989
+		if ($value && array_key_exists(sanitize_text_field($value), wpinv_get_discount_types())) {
990
+			$this->set_prop('type', sanitize_text_field($value));
991 991
 		}
992 992
 	}
993 993
 
@@ -997,15 +997,15 @@  discard block
 block discarded – undo
997 997
 	 * @since 1.0.19
998 998
 	 * @param int $value usage count.
999 999
 	 */
1000
-	public function set_uses( $value ) {
1000
+	public function set_uses($value) {
1001 1001
 
1002 1002
 		$value = (int) $value;
1003 1003
 
1004
-		if ( $value < 0 ) {
1004
+		if ($value < 0) {
1005 1005
 			$value = 0;
1006 1006
 		}
1007 1007
 
1008
-		$this->set_prop( 'uses', (int) $value );
1008
+		$this->set_prop('uses', (int) $value);
1009 1009
 	}
1010 1010
 
1011 1011
 	/**
@@ -1014,8 +1014,8 @@  discard block
 block discarded – undo
1014 1014
 	 * @since 1.0.19
1015 1015
 	 * @param int $value maximum usage count.
1016 1016
 	 */
1017
-	public function set_max_uses( $value ) {
1018
-		$this->set_prop( 'max_uses', absint( $value ) );
1017
+	public function set_max_uses($value) {
1018
+		$this->set_prop('max_uses', absint($value));
1019 1019
 	}
1020 1020
 
1021 1021
 	/**
@@ -1024,8 +1024,8 @@  discard block
 block discarded – undo
1024 1024
 	 * @since 1.0.19
1025 1025
 	 * @param int|bool $value is single use.
1026 1026
 	 */
1027
-	public function set_is_single_use( $value ) {
1028
-		$this->set_prop( 'is_single_use', (bool) $value );
1027
+	public function set_is_single_use($value) {
1028
+		$this->set_prop('is_single_use', (bool) $value);
1029 1029
 	}
1030 1030
 
1031 1031
 	/**
@@ -1034,8 +1034,8 @@  discard block
 block discarded – undo
1034 1034
 	 * @since 1.0.19
1035 1035
 	 * @param array $value items.
1036 1036
 	 */
1037
-	public function set_items( $value ) {
1038
-		$this->set_prop( 'items', array_filter( wp_parse_id_list( $value ) ) );
1037
+	public function set_items($value) {
1038
+		$this->set_prop('items', array_filter(wp_parse_id_list($value)));
1039 1039
 	}
1040 1040
 
1041 1041
 	/**
@@ -1044,8 +1044,8 @@  discard block
 block discarded – undo
1044 1044
 	 * @since 1.0.19
1045 1045
 	 * @param array $value items.
1046 1046
 	 */
1047
-	public function set_allowed_items( $value ) {
1048
-		$this->set_items( $value );
1047
+	public function set_allowed_items($value) {
1048
+		$this->set_items($value);
1049 1049
 	}
1050 1050
 
1051 1051
 	/**
@@ -1054,8 +1054,8 @@  discard block
 block discarded – undo
1054 1054
 	 * @since 1.0.19
1055 1055
 	 * @param array $value items.
1056 1056
 	 */
1057
-	public function set_excluded_items( $value ) {
1058
-		$this->set_prop( 'excluded_items', array_filter( wp_parse_id_list( $value ) ) );
1057
+	public function set_excluded_items($value) {
1058
+		$this->set_prop('excluded_items', array_filter(wp_parse_id_list($value)));
1059 1059
 	}
1060 1060
 
1061 1061
 	/**
@@ -1064,8 +1064,8 @@  discard block
 block discarded – undo
1064 1064
 	 * @since 1.0.19
1065 1065
 	 * @param array $value items.
1066 1066
 	 */
1067
-	public function set_required_items( $value ) {
1068
-		$this->set_prop( 'required_items', array_filter( wp_parse_id_list( $value ) ) );
1067
+	public function set_required_items($value) {
1068
+		$this->set_prop('required_items', array_filter(wp_parse_id_list($value)));
1069 1069
 	}
1070 1070
 
1071 1071
 	/**
@@ -1074,8 +1074,8 @@  discard block
 block discarded – undo
1074 1074
 	 * @since 1.0.19
1075 1075
 	 * @param int|bool $value is recurring.
1076 1076
 	 */
1077
-	public function set_is_recurring( $value ) {
1078
-		$this->set_prop( 'is_recurring', (bool) $value );
1077
+	public function set_is_recurring($value) {
1078
+		$this->set_prop('is_recurring', (bool) $value);
1079 1079
 	}
1080 1080
 
1081 1081
 	/**
@@ -1084,8 +1084,8 @@  discard block
 block discarded – undo
1084 1084
 	 * @since 1.0.19
1085 1085
 	 * @param float $value minimum total.
1086 1086
 	 */
1087
-	public function set_min_total( $value ) {
1088
-		$this->set_prop( 'min_total', (float) wpinv_sanitize_amount( $value ) );
1087
+	public function set_min_total($value) {
1088
+		$this->set_prop('min_total', (float) wpinv_sanitize_amount($value));
1089 1089
 	}
1090 1090
 
1091 1091
 	/**
@@ -1094,8 +1094,8 @@  discard block
 block discarded – undo
1094 1094
 	 * @since 1.0.19
1095 1095
 	 * @param float $value minimum total.
1096 1096
 	 */
1097
-	public function set_minimum_total( $value ) {
1098
-		$this->set_min_total( $value );
1097
+	public function set_minimum_total($value) {
1098
+		$this->set_min_total($value);
1099 1099
 	}
1100 1100
 
1101 1101
 	/**
@@ -1104,8 +1104,8 @@  discard block
 block discarded – undo
1104 1104
 	 * @since 1.0.19
1105 1105
 	 * @param float $value maximum total.
1106 1106
 	 */
1107
-	public function set_max_total( $value ) {
1108
-		$this->set_prop( 'max_total', (float) wpinv_sanitize_amount( $value ) );
1107
+	public function set_max_total($value) {
1108
+		$this->set_prop('max_total', (float) wpinv_sanitize_amount($value));
1109 1109
 	}
1110 1110
 
1111 1111
 	/**
@@ -1114,23 +1114,23 @@  discard block
 block discarded – undo
1114 1114
 	 * @since 1.0.19
1115 1115
 	 * @param float $value maximum total.
1116 1116
 	 */
1117
-	public function set_maximum_total( $value ) {
1118
-		$this->set_max_total( $value );
1117
+	public function set_maximum_total($value) {
1118
+		$this->set_max_total($value);
1119 1119
 	}
1120 1120
 
1121 1121
 	/**
1122 1122
 	 * @deprecated
1123 1123
 	 */
1124
-	public function refresh(){}
1124
+	public function refresh() {}
1125 1125
 
1126 1126
 	/**
1127 1127
 	 * @deprecated
1128 1128
 	 *
1129 1129
 	 */
1130
-	public function update_status( $status = 'publish' ) {
1130
+	public function update_status($status = 'publish') {
1131 1131
 
1132
-		if ( $this->exists() && $this->get_status() != $status ) {
1133
-			$this->set_status( $status );
1132
+		if ($this->exists() && $this->get_status() != $status) {
1133
+			$this->set_status($status);
1134 1134
 			$this->save();
1135 1135
 		}
1136 1136
 
@@ -1152,7 +1152,7 @@  discard block
 block discarded – undo
1152 1152
 	 */
1153 1153
 	public function exists() {
1154 1154
 		$id = $this->get_id();
1155
-		return ! empty( $id );
1155
+		return !empty($id);
1156 1156
 	}
1157 1157
 
1158 1158
 	/**
@@ -1163,7 +1163,7 @@  discard block
 block discarded – undo
1163 1163
 	 * @since 1.0.15
1164 1164
 	 * @return bool
1165 1165
 	 */
1166
-	public function is_type( $type ) {
1166
+	public function is_type($type) {
1167 1167
 		return $this->get_type() == $type;
1168 1168
 	}
1169 1169
 
@@ -1185,7 +1185,7 @@  discard block
 block discarded – undo
1185 1185
 	 */
1186 1186
 	public function has_limit() {
1187 1187
 		$limit = $this->get_max_uses();
1188
-		return ! empty( $limit );
1188
+		return !empty($limit);
1189 1189
 	}
1190 1190
 
1191 1191
 	/**
@@ -1206,13 +1206,13 @@  discard block
 block discarded – undo
1206 1206
 	 */
1207 1207
 	public function has_exceeded_limit() {
1208 1208
 
1209
-		if ( ! $this->has_limit() || ! $this->has_uses() ) {
1209
+		if (!$this->has_limit() || !$this->has_uses()) {
1210 1210
 			$exceeded = false;
1211 1211
 		} else {
1212 1212
 			$exceeded = (int) $this->get_max_uses() <= $this->get_uses();
1213 1213
 		}
1214 1214
 
1215
-		return apply_filters( 'wpinv_is_discount_maxed_out', $exceeded, $this->get_id(), $this, $this->get_code() );
1215
+		return apply_filters('wpinv_is_discount_maxed_out', $exceeded, $this->get_id(), $this, $this->get_code());
1216 1216
 	}
1217 1217
 
1218 1218
 	/**
@@ -1223,7 +1223,7 @@  discard block
 block discarded – undo
1223 1223
 	 */
1224 1224
 	public function has_expiration_date() {
1225 1225
 		$date = $this->get_expiration_date();
1226
-		return ! empty( $date );
1226
+		return !empty($date);
1227 1227
 	}
1228 1228
 
1229 1229
 	/**
@@ -1233,8 +1233,8 @@  discard block
 block discarded – undo
1233 1233
 	 * @return bool
1234 1234
 	 */
1235 1235
 	public function is_expired() {
1236
-		$expired = $this->has_expiration_date() ? current_time( 'timestamp' ) > strtotime( $this->get_expiration_date() ) : false;
1237
-		return apply_filters( 'wpinv_is_discount_expired', $expired, $this->get_id(), $this, $this->get_code() );
1236
+		$expired = $this->has_expiration_date() ? current_time('timestamp') > strtotime($this->get_expiration_date()) : false;
1237
+		return apply_filters('wpinv_is_discount_expired', $expired, $this->get_id(), $this, $this->get_code());
1238 1238
 	}
1239 1239
 
1240 1240
 	/**
@@ -1245,7 +1245,7 @@  discard block
 block discarded – undo
1245 1245
 	 */
1246 1246
 	public function has_start_date() {
1247 1247
 		$date = $this->get_start_date();
1248
-		return ! empty( $date );
1248
+		return !empty($date);
1249 1249
 	}
1250 1250
 
1251 1251
 	/**
@@ -1255,8 +1255,8 @@  discard block
 block discarded – undo
1255 1255
 	 * @return bool
1256 1256
 	 */
1257 1257
 	public function has_started() {
1258
-		$started = $this->has_start_date() ? true : current_time( 'timestamp' ) > strtotime( $this->get_start_date() );
1259
-		return apply_filters( 'wpinv_is_discount_started', $started, $this->get_id(), $this, $this->get_code() );
1258
+		$started = $this->has_start_date() ? true : current_time('timestamp') > strtotime($this->get_start_date());
1259
+		return apply_filters('wpinv_is_discount_started', $started, $this->get_id(), $this, $this->get_code());
1260 1260
 	}
1261 1261
 
1262 1262
 	/**
@@ -1267,7 +1267,7 @@  discard block
 block discarded – undo
1267 1267
 	 */
1268 1268
 	public function has_allowed_items() {
1269 1269
 		$allowed_items = $this->get_allowed_items();
1270
-		return ! empty( $allowed_items );
1270
+		return !empty($allowed_items);
1271 1271
 	}
1272 1272
 
1273 1273
 	/**
@@ -1278,7 +1278,7 @@  discard block
 block discarded – undo
1278 1278
 	 */
1279 1279
 	public function has_excluded_items() {
1280 1280
 		$excluded_items = $this->get_excluded_items();
1281
-		return ! empty( $excluded_items );
1281
+		return !empty($excluded_items);
1282 1282
 	}
1283 1283
 
1284 1284
 	/**
@@ -1288,17 +1288,17 @@  discard block
 block discarded – undo
1288 1288
 	 * @since 1.0.15
1289 1289
 	 * @return boolean
1290 1290
 	 */
1291
-	public function is_valid_for_items( $item_ids ) {
1291
+	public function is_valid_for_items($item_ids) {
1292 1292
 
1293
-		$item_ids = array_filter( wp_parse_id_list( $item_ids ) );
1294
-		$included = array_intersect( $item_ids, $this->get_allowed_items() );
1295
-		$excluded = array_intersect( $item_ids, $this->get_excluded_items() );
1293
+		$item_ids = array_filter(wp_parse_id_list($item_ids));
1294
+		$included = array_intersect($item_ids, $this->get_allowed_items());
1295
+		$excluded = array_intersect($item_ids, $this->get_excluded_items());
1296 1296
 
1297
-		if ( $this->has_excluded_items() && ! empty( $excluded ) ) {
1297
+		if ($this->has_excluded_items() && !empty($excluded)) {
1298 1298
 			return false;
1299 1299
 		}
1300 1300
 
1301
-		if ( $this->has_allowed_items() && empty( $included ) ) {
1301
+		if ($this->has_allowed_items() && empty($included)) {
1302 1302
 			return false;
1303 1303
 		}
1304 1304
 
@@ -1313,7 +1313,7 @@  discard block
 block discarded – undo
1313 1313
 	 */
1314 1314
 	public function has_required_items() {
1315 1315
 		$required_items = $this->get_required_items();
1316
-		return ! empty( $required_items );
1316
+		return !empty($required_items);
1317 1317
 	}
1318 1318
 
1319 1319
 	/**
@@ -1323,13 +1323,13 @@  discard block
 block discarded – undo
1323 1323
 	 * @since 1.0.15
1324 1324
 	 * @return boolean
1325 1325
 	 */
1326
-	public function is_required_items_met( $item_ids ) {
1326
+	public function is_required_items_met($item_ids) {
1327 1327
 
1328
-		if ( ! $this->has_required_items() ) {
1328
+		if (!$this->has_required_items()) {
1329 1329
 			return true;
1330 1330
 		}
1331 1331
 
1332
-		return ! array_diff( $this->get_required_items(), array_filter( wp_parse_id_list( $item_ids ) ) );
1332
+		return !array_diff($this->get_required_items(), array_filter(wp_parse_id_list($item_ids)));
1333 1333
 	}
1334 1334
 
1335 1335
 	/**
@@ -1339,8 +1339,8 @@  discard block
 block discarded – undo
1339 1339
 	 * @since 1.0.15
1340 1340
 	 * @return boolean
1341 1341
 	 */
1342
-	public function is_valid_for_amount( $amount ) {
1343
-		return $this->is_minimum_amount_met( $amount ) && $this->is_maximum_amount_met( $amount );
1342
+	public function is_valid_for_amount($amount) {
1343
+		return $this->is_minimum_amount_met($amount) && $this->is_maximum_amount_met($amount);
1344 1344
 	}
1345 1345
 
1346 1346
 	/**
@@ -1351,7 +1351,7 @@  discard block
 block discarded – undo
1351 1351
 	 */
1352 1352
 	public function has_minimum_amount() {
1353 1353
 		$minimum = $this->get_minimum_total();
1354
-		return ! empty( $minimum );
1354
+		return !empty($minimum);
1355 1355
 	}
1356 1356
 
1357 1357
 	/**
@@ -1361,10 +1361,10 @@  discard block
 block discarded – undo
1361 1361
 	 * @since 1.0.15
1362 1362
 	 * @return boolean
1363 1363
 	 */
1364
-	public function is_minimum_amount_met( $amount ) {
1365
-		$amount = floatval( wpinv_sanitize_amount( $amount ) );
1366
-		$min_met = ! ( $this->has_minimum_amount() && $amount < floatval( wpinv_sanitize_amount( $this->get_minimum_total() ) ) );
1367
-		return apply_filters( 'wpinv_is_discount_min_met', $min_met, $this->get_id(), $this, $this->get_code(), $amount );
1364
+	public function is_minimum_amount_met($amount) {
1365
+		$amount = floatval(wpinv_sanitize_amount($amount));
1366
+		$min_met = !($this->has_minimum_amount() && $amount < floatval(wpinv_sanitize_amount($this->get_minimum_total())));
1367
+		return apply_filters('wpinv_is_discount_min_met', $min_met, $this->get_id(), $this, $this->get_code(), $amount);
1368 1368
 	}
1369 1369
 
1370 1370
 	/**
@@ -1375,7 +1375,7 @@  discard block
 block discarded – undo
1375 1375
 	 */
1376 1376
 	public function has_maximum_amount() {
1377 1377
 		$maximum = $this->get_maximum_total();
1378
-		return ! empty( $maximum );
1378
+		return !empty($maximum);
1379 1379
 	}
1380 1380
 
1381 1381
 	/**
@@ -1385,10 +1385,10 @@  discard block
 block discarded – undo
1385 1385
 	 * @since 1.0.15
1386 1386
 	 * @return boolean
1387 1387
 	 */
1388
-	public function is_maximum_amount_met( $amount ) {
1389
-		$amount = floatval( wpinv_sanitize_amount( $amount ) );
1390
-		$max_met = ! ( $this->has_maximum_amount() && $amount > floatval( wpinv_sanitize_amount( $this->get_maximum_total() ) ) );
1391
-		return apply_filters( 'wpinv_is_discount_max_met', $max_met, $this->get_id(), $this, $this->get_code(), $amount );
1388
+	public function is_maximum_amount_met($amount) {
1389
+		$amount = floatval(wpinv_sanitize_amount($amount));
1390
+		$max_met = !($this->has_maximum_amount() && $amount > floatval(wpinv_sanitize_amount($this->get_maximum_total())));
1391
+		return apply_filters('wpinv_is_discount_max_met', $max_met, $this->get_id(), $this, $this->get_code(), $amount);
1392 1392
 	}
1393 1393
 
1394 1394
 	/**
@@ -1399,7 +1399,7 @@  discard block
 block discarded – undo
1399 1399
 	 */
1400 1400
 	public function is_recurring() {
1401 1401
 		$recurring = $this->get_is_recurring();
1402
-		return ! empty( $recurring );
1402
+		return !empty($recurring);
1403 1403
 	}
1404 1404
 
1405 1405
 	/**
@@ -1410,7 +1410,7 @@  discard block
 block discarded – undo
1410 1410
 	 */
1411 1411
 	public function is_single_use() {
1412 1412
 		$usage = $this->get_is_single_use();
1413
-		return ! empty( $usage );
1413
+		return !empty($usage);
1414 1414
 	}
1415 1415
 
1416 1416
 	/**
@@ -1420,25 +1420,25 @@  discard block
 block discarded – undo
1420 1420
 	 * @since 1.0.15
1421 1421
 	 * @return boolean
1422 1422
 	 */
1423
-	public function is_valid_for_user( $user ) {
1423
+	public function is_valid_for_user($user) {
1424 1424
 
1425 1425
 		// Ensure that the discount is single use.
1426
-		if ( empty( $user ) || ! $this->is_single_use() ) {
1426
+		if (empty($user) || !$this->is_single_use()) {
1427 1427
 			return true;
1428 1428
 		}
1429 1429
 
1430 1430
 		// Prepare the user id.
1431 1431
 		$user_id = 0;
1432
-        if ( is_numeric( $user ) ) {
1433
-            $user_id = absint( $user );
1434
-        } elseif ( is_email( $user ) && $user_data = get_user_by( 'email', $user ) ) {
1432
+        if (is_numeric($user)) {
1433
+            $user_id = absint($user);
1434
+        } elseif (is_email($user) && $user_data = get_user_by('email', $user)) {
1435 1435
             $user_id = $user_data->ID;
1436
-        } elseif ( $user_data = get_user_by( 'login', $user ) ) {
1436
+        } elseif ($user_data = get_user_by('login', $user)) {
1437 1437
             $user_id = $user_data->ID;
1438 1438
         }
1439 1439
 
1440 1440
 		// Ensure that we have a user.
1441
-		if ( empty( $user_id ) ) {
1441
+		if (empty($user_id)) {
1442 1442
 			return true;
1443 1443
 		}
1444 1444
 
@@ -1450,13 +1450,13 @@  discard block
 block discarded – undo
1450 1450
 				'paginate' => false,
1451 1451
             )
1452 1452
         );
1453
-		$code     = strtolower( $this->get_code() );
1453
+		$code = strtolower($this->get_code());
1454 1454
 
1455 1455
 		// For each payment...
1456
-		foreach ( $payments as $payment ) {
1456
+		foreach ($payments as $payment) {
1457 1457
 
1458 1458
 			// Only check for paid invoices.
1459
-			if ( $payment->is_paid() && strtolower( $payment->get_discount_code() ) == $code ) {
1459
+			if ($payment->is_paid() && strtolower($payment->get_discount_code()) == $code) {
1460 1460
 				return false;
1461 1461
 			}
1462 1462
 }
@@ -1481,24 +1481,24 @@  discard block
 block discarded – undo
1481 1481
 	 * @param int $by The number of usages to increas by.
1482 1482
 	 * @return int
1483 1483
 	 */
1484
-	public function increase_usage( $by = 1 ) {
1484
+	public function increase_usage($by = 1) {
1485 1485
 
1486 1486
 		// Abort if zero.
1487
-		if ( empty( $by ) ) {
1487
+		if (empty($by)) {
1488 1488
 			return;
1489 1489
 		}
1490 1490
 
1491 1491
 		// Increase the usage.
1492
-		$this->set_uses( $this->get_uses() + (int) $by );
1492
+		$this->set_uses($this->get_uses() + (int) $by);
1493 1493
 
1494 1494
 		// Save the discount.
1495 1495
 		$this->save();
1496 1496
 
1497 1497
 		// Fire relevant hooks.
1498
-		if ( (int) $by > 0 ) {
1499
-			do_action( 'wpinv_discount_increase_use_count', $this->get_uses(), $this->get_id(), $this->get_code(), absint( $by ) );
1498
+		if ((int) $by > 0) {
1499
+			do_action('wpinv_discount_increase_use_count', $this->get_uses(), $this->get_id(), $this->get_code(), absint($by));
1500 1500
 		} else {
1501
-			do_action( 'wpinv_discount_decrease_use_count', $this->get_uses(), $this->get_id(), $this->get_code(), absint( $by ) );
1501
+			do_action('wpinv_discount_decrease_use_count', $this->get_uses(), $this->get_id(), $this->get_code(), absint($by));
1502 1502
 		}
1503 1503
 
1504 1504
 		// Return the number of times the discount has been used.
@@ -1522,7 +1522,7 @@  discard block
 block discarded – undo
1522 1522
 	 * @param float $amount
1523 1523
 	 * @return float
1524 1524
 	 */
1525
-	public function get_discounted_amount( $amount ) {
1525
+	public function get_discounted_amount($amount) {
1526 1526
 
1527 1527
 		// Convert amount to float.
1528 1528
 		$amount = (float) $amount;
@@ -1530,29 +1530,29 @@  discard block
 block discarded – undo
1530 1530
 		// Get discount amount.
1531 1531
 		$discount_amount = $this->get_amount();
1532 1532
 
1533
-		if ( empty( $discount_amount ) ) {
1533
+		if (empty($discount_amount)) {
1534 1534
 			return 0;
1535 1535
 		}
1536 1536
 
1537 1537
 		// Format the amount.
1538
-		$discount_amount = floatval( wpinv_sanitize_amount( $discount_amount ) );
1538
+		$discount_amount = floatval(wpinv_sanitize_amount($discount_amount));
1539 1539
 
1540 1540
 		// If this is a percentage discount.
1541
-		if ( $this->is_type( 'percent' ) ) {
1542
-            $discount_amount = $amount * ( $discount_amount / 100 );
1541
+		if ($this->is_type('percent')) {
1542
+            $discount_amount = $amount * ($discount_amount / 100);
1543 1543
 		}
1544 1544
 
1545 1545
 		// Discount can not be less than zero...
1546
-		if ( $discount_amount < 0 ) {
1546
+		if ($discount_amount < 0) {
1547 1547
 			$discount_amount = 0;
1548 1548
 		}
1549 1549
 
1550 1550
 		// ... or more than the amount.
1551
-		if ( $discount_amount > $amount ) {
1551
+		if ($discount_amount > $amount) {
1552 1552
 			$discount_amount = $amount;
1553 1553
 		}
1554 1554
 
1555
-		return apply_filters( 'wpinv_discount_total_discount_amount', $discount_amount, $amount, $this );
1555
+		return apply_filters('wpinv_discount_total_discount_amount', $discount_amount, $amount, $this);
1556 1556
 	}
1557 1557
 
1558 1558
 }
Please login to merge, or discard this patch.
templates/payment-forms/elements/separator.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 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
 
13 13
 <hr class="featurette-divider" />
Please login to merge, or discard this patch.
includes/reports/class-getpaid-reports.php 1 patch
Spacing   +31 added lines, -31 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_Reports Class.
@@ -17,11 +17,11 @@  discard block
 block discarded – undo
17 17
 	 *
18 18
 	 */
19 19
 	public function __construct() {
20
-		add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 );
21
-		add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) );
22
-		add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) );
23
-		add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) );
24
-		add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) );
20
+		add_action('admin_menu', array($this, 'register_reports_page'), 20);
21
+		add_action('wpinv_reports_tab_reports', array($this, 'display_reports_tab'));
22
+		add_action('wpinv_reports_tab_export', array($this, 'display_exports_tab'));
23
+		add_action('getpaid_authenticated_admin_action_download_graph', array($this, 'download_graph'));
24
+		add_action('getpaid_authenticated_admin_action_export_invoices', array($this, 'export_invoices'));
25 25
 
26 26
 	}
27 27
 
@@ -33,11 +33,11 @@  discard block
 block discarded – undo
33 33
 
34 34
 		add_submenu_page(
35 35
             'wpinv',
36
-            __( 'Reports', 'invoicing' ),
37
-            __( 'Reports', 'invoicing' ),
36
+            __('Reports', 'invoicing'),
37
+            __('Reports', 'invoicing'),
38 38
             wpinv_get_capability(),
39 39
             'wpinv-reports',
40
-            array( $this, 'display_reports_page' )
40
+            array($this, 'display_reports_page')
41 41
 		);
42 42
 
43 43
 	}
@@ -50,26 +50,26 @@  discard block
 block discarded – undo
50 50
 
51 51
 		// Prepare variables.
52 52
 		$tabs        = $this->get_tabs();
53
-		$current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports';
54
-		$current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports';
53
+		$current_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'reports';
54
+		$current_tab = array_key_exists($current_tab, $tabs) ? $current_tab : 'reports';
55 55
 
56 56
 		// Display the current tab.
57 57
 		?>
58 58
 
59 59
         <div class="wrap">
60 60
 
61
-			<h1><?php echo esc_html( $tabs[ $current_tab ] ); ?></h1>
61
+			<h1><?php echo esc_html($tabs[$current_tab]); ?></h1>
62 62
 
63 63
 			<nav class="nav-tab-wrapper">
64 64
 
65 65
 				<?php
66
-					foreach ( $tabs as $key => $label ) {
66
+					foreach ($tabs as $key => $label) {
67 67
 
68
-					$key   = sanitize_key( $key );
69
-					$label = esc_html( $label );
68
+					$key   = sanitize_key($key);
69
+					$label = esc_html($label);
70 70
 					$class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab';
71 71
 					$url   = esc_url(
72
-                        add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) )
72
+                        add_query_arg('tab', $key, admin_url('admin.php?page=wpinv-reports'))
73 73
                     );
74 74
 
75 75
 				echo "\n\t\t\t<a href='$url' class='$class'>$label</a>";
@@ -79,17 +79,17 @@  discard block
 block discarded – undo
79 79
 
80 80
 			</nav>
81 81
 
82
-			<div class="bsui <?php echo esc_attr( $current_tab ); ?>">
83
-				<?php do_action( "wpinv_reports_tab_{$current_tab}" ); ?>
82
+			<div class="bsui <?php echo esc_attr($current_tab); ?>">
83
+				<?php do_action("wpinv_reports_tab_{$current_tab}"); ?>
84 84
 			</div>
85 85
 
86 86
         </div>
87 87
 		<?php
88 88
 
89 89
 			// Wordfence loads an unsupported version of chart js on our page.
90
-			wp_deregister_style( 'chart-js' );
91
-			wp_deregister_script( 'chart-js' );
92
-			wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array( 'jquery' ), '3.7.1', true );
90
+			wp_deregister_style('chart-js');
91
+			wp_deregister_script('chart-js');
92
+			wp_enqueue_script('chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array('jquery'), '3.7.1', true);
93 93
 
94 94
 	}
95 95
 
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
 	public function get_tabs() {
102 102
 
103 103
 		$tabs = array(
104
-			'reports' => __( 'Reports', 'invoicing' ),
105
-			'export'  => __( 'Export', 'invoicing' ),
104
+			'reports' => __('Reports', 'invoicing'),
105
+			'export'  => __('Export', 'invoicing'),
106 106
 		);
107 107
 
108
-		return apply_filters( 'getpaid_report_tabs', $tabs );
108
+		return apply_filters('getpaid_report_tabs', $tabs);
109 109
 	}
110 110
 
111 111
 	/**
@@ -135,11 +135,11 @@  discard block
 block discarded – undo
135 135
 	 *
136 136
 	 * @param array $args
137 137
 	 */
138
-	public function download_graph( $args ) {
138
+	public function download_graph($args) {
139 139
 
140
-		if ( ! empty( $args['graph'] ) ) {
140
+		if (!empty($args['graph'])) {
141 141
 			$downloader = new GetPaid_Graph_Downloader();
142
-			$downloader->download( $args['graph'] );
142
+			$downloader->download($args['graph']);
143 143
 		}
144 144
 
145 145
 	}
@@ -149,17 +149,17 @@  discard block
 block discarded – undo
149 149
 	 *
150 150
 	 * @param array $args
151 151
 	 */
152
-	public function export_invoices( $args ) {
152
+	public function export_invoices($args) {
153 153
 
154
-		if ( ! empty( $args['post_type'] ) ) {
154
+		if (!empty($args['post_type'])) {
155 155
 
156
-			if ( 'subscriptions' === $args['post_type'] ) {
156
+			if ('subscriptions' === $args['post_type']) {
157 157
 				$downloader = new GetPaid_Subscription_Exporter();
158 158
 			} else {
159 159
 				$downloader = new GetPaid_Invoice_Exporter();
160 160
 			}
161 161
 
162
-			$downloader->export( $args['post_type'], $args );
162
+			$downloader->export($args['post_type'], $args);
163 163
 		}
164 164
 
165 165
 	}
Please login to merge, or discard this patch.
templates/payment-forms/cart-item.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -9,50 +9,50 @@  discard block
 block discarded – undo
9 9
  * @var GetPaid_Form_Item $item
10 10
  */
11 11
 
12
-defined( 'ABSPATH' ) || exit;
12
+defined('ABSPATH') || exit;
13 13
 
14
-do_action( 'getpaid_before_payment_form_cart_item', $form, $item );
14
+do_action('getpaid_before_payment_form_cart_item', $form, $item);
15 15
 
16 16
 $currency = $form->get_currency();
17
-$max_qty  = wpinv_item_max_buyable_quantity( $item->get_id() );
17
+$max_qty  = wpinv_item_max_buyable_quantity($item->get_id());
18 18
 ?>
19 19
 <div class='getpaid-payment-form-items-cart-item getpaid-<?php echo $item->is_required() ? 'required' : 'selectable'; ?> item-<?php echo (int) $item->get_id(); ?> border-bottom py-2 px-3'>
20 20
 
21 21
 	<div class="form-row needs-validation">
22 22
 
23
-		<?php foreach ( array_keys( $columns ) as $key ) : ?>
23
+		<?php foreach (array_keys($columns) as $key) : ?>
24 24
 
25
-			<div class="<?php echo 'name' == $key ? 'col-6' : 'col'; ?> <?php echo ( in_array( $key, array( 'subtotal', 'quantity', 'tax_rate' ) ) ) ? 'd-none d-sm-block' : ''; ?> position-relative getpaid-form-cart-item-<?php echo sanitize_html_class( $key ); ?> getpaid-form-cart-item-<?php echo sanitize_html_class( $key ); ?>-<?php echo (int) $item->get_id(); ?>">
25
+			<div class="<?php echo 'name' == $key ? 'col-6' : 'col'; ?> <?php echo (in_array($key, array('subtotal', 'quantity', 'tax_rate'))) ? 'd-none d-sm-block' : ''; ?> position-relative getpaid-form-cart-item-<?php echo sanitize_html_class($key); ?> getpaid-form-cart-item-<?php echo sanitize_html_class($key); ?>-<?php echo (int) $item->get_id(); ?>">
26 26
 
27 27
 				<?php
28 28
 
29 29
 					// Fires before printing a line item column.
30
-					do_action( "getpaid_form_cart_item_before_$key", $item, $form );
30
+					do_action("getpaid_form_cart_item_before_$key", $item, $form);
31 31
 
32 32
 					// Item name.
33
-					if ( 'name' == $key ) {
33
+					if ('name' == $key) {
34 34
 
35 35
 					ob_start();
36 36
 					// And an optional description.
37 37
 					$description = $item->get_description();
38 38
 
39
-					if ( ! empty( $description ) ) {
40
-						$description = wp_kses_post( $description );
39
+					if (!empty($description)) {
40
+						$description = wp_kses_post($description);
41 41
 						echo "<small class='form-text text-muted pr-2 m-0'>$description</small>";
42 42
 						}
43 43
 
44 44
 					// Price help text.
45
-					$description = getpaid_item_recurring_price_help_text( $item, $currency );
46
-					if ( $description ) {
45
+					$description = getpaid_item_recurring_price_help_text($item, $currency);
46
+					if ($description) {
47 47
 						echo "<small class='getpaid-form-item-price-desc form-text text-muted pr-2 m-0'>$description</small>";
48 48
 						}
49 49
 
50
-					do_action( 'getpaid_payment_form_cart_item_description', $item, $form );
50
+					do_action('getpaid_payment_form_cart_item_description', $item, $form);
51 51
 
52
-					if ( wpinv_current_user_can_manage_invoicing() ) {
52
+					if (wpinv_current_user_can_manage_invoicing()) {
53 53
 
54 54
 						edit_post_link(
55
-							__( 'Edit this item.', 'invoicing' ),
55
+							__('Edit this item.', 'invoicing'),
56 56
 							'<small class="form-text text-muted">',
57 57
 							'</small>',
58 58
 							$item->get_id(),
@@ -64,18 +64,18 @@  discard block
 block discarded – undo
64 64
 					$description = ob_get_clean();
65 65
 
66 66
 					// Display the name.
67
-					$tootip = empty( $description ) ? '' : '&nbsp;' . '<i class="fas fa-xs fa-info gp-tooltip d-sm-none text-muted"></i>';
68
-					echo '<div class="mb-1">' . esc_html( $item->get_name() ) . wp_kses_post( $tootip ) . '</div>';
67
+					$tootip = empty($description) ? '' : '&nbsp;' . '<i class="fas fa-xs fa-info gp-tooltip d-sm-none text-muted"></i>';
68
+					echo '<div class="mb-1">' . esc_html($item->get_name()) . wp_kses_post($tootip) . '</div>';
69 69
 
70
-					if ( ! empty( $description ) ) {
71
-						printf( '<span class="d-none d-sm-block getpaid-item-desc">%s</span>', $description );
70
+					if (!empty($description)) {
71
+						printf('<span class="d-none d-sm-block getpaid-item-desc">%s</span>', $description);
72 72
 						}
73 73
 
74
-					if ( $item->allows_quantities() ) {
74
+					if ($item->allows_quantities()) {
75 75
 						printf(
76 76
 							'<small class="d-sm-none text-muted form-text">%s</small>',
77 77
 							sprintf(
78
-								__( 'Qty %s', 'invoicing' ),
78
+								__('Qty %s', 'invoicing'),
79 79
 								sprintf(
80 80
 									'<input
81 81
 											type="number"
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 						printf(
95 95
 							'<small class="d-sm-none text-muted form-text">%s</small>',
96 96
 							sprintf(
97
-								__( 'Qty %s', 'invoicing' ),
97
+								__('Qty %s', 'invoicing'),
98 98
 								(float) $item->get_quantity()
99 99
 							)
100 100
 						);
@@ -102,56 +102,56 @@  discard block
 block discarded – undo
102 102
 }
103 103
 
104 104
 					// Item price.
105
-					if ( 'price' == $key ) {
105
+					if ('price' == $key) {
106 106
 
107 107
 					// Set the currency position.
108 108
 					$position = wpinv_currency_position();
109 109
 
110
-					if ( $position == 'left_space' ) {
110
+					if ($position == 'left_space') {
111 111
 						$position = 'left';
112 112
 						}
113 113
 
114
-					if ( $position == 'right_space' ) {
114
+					if ($position == 'right_space') {
115 115
 						$position = 'right';
116 116
 						}
117 117
 
118
-					if ( $item->user_can_set_their_price() ) {
119
-						$price            = max( (float) $item->get_price(), (float) $item->get_minimum_price() );
118
+					if ($item->user_can_set_their_price()) {
119
+						$price            = max((float) $item->get_price(), (float) $item->get_minimum_price());
120 120
 						$minimum          = (float) $item->get_minimum_price();
121 121
 						$validate_minimum = '';
122 122
 						$class            = '';
123 123
 						$data_minimum     = '';
124 124
 
125
-						if ( $minimum > 0 ) {
125
+						if ($minimum > 0) {
126 126
 							$validate_minimum = sprintf(
127
-								esc_attr__( 'The minimum allowed amount is %s', 'invoicing' ),
128
-								strip_tags( wpinv_price( $minimum, $currency ) )
127
+								esc_attr__('The minimum allowed amount is %s', 'invoicing'),
128
+								strip_tags(wpinv_price($minimum, $currency))
129 129
 							);
130 130
 
131 131
 							$class = 'getpaid-validate-minimum-amount';
132 132
 
133
-							$data_minimum     = "data-minimum-amount='" . esc_attr( getpaid_unstandardize_amount( $minimum ) ) . "'";
133
+							$data_minimum = "data-minimum-amount='" . esc_attr(getpaid_unstandardize_amount($minimum)) . "'";
134 134
 						}
135 135
 
136 136
 						?>
137 137
 								<div class="input-group input-group-sm">
138
-								<?php if ( 'left' == $position ) : ?>
138
+								<?php if ('left' == $position) : ?>
139 139
 										<div class="input-group-prepend">
140
-											<span class="input-group-text"><?php echo wpinv_currency_symbol( $currency ); ?></span>
140
+											<span class="input-group-text"><?php echo wpinv_currency_symbol($currency); ?></span>
141 141
 										</div>
142 142
 									<?php endif; ?>
143 143
 
144
-									<input type="text" <?php echo $data_minimum; ?> name="getpaid-items[<?php echo (int) $item->get_id(); ?>][price]" value="<?php echo esc_attr( getpaid_unstandardize_amount( $price ) ); ?>" placeholder="<?php echo esc_attr( getpaid_unstandardize_amount( $item->get_minimum_price() ) ); ?>" class="getpaid-item-price-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border <?php echo $class; ?>" style="width: 64px; line-height: 1; min-height: 35px;">
144
+									<input type="text" <?php echo $data_minimum; ?> name="getpaid-items[<?php echo (int) $item->get_id(); ?>][price]" value="<?php echo esc_attr(getpaid_unstandardize_amount($price)); ?>" placeholder="<?php echo esc_attr(getpaid_unstandardize_amount($item->get_minimum_price())); ?>" class="getpaid-item-price-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border <?php echo $class; ?>" style="width: 64px; line-height: 1; min-height: 35px;">
145 145
 
146
-								<?php if ( ! empty( $validate_minimum ) ) : ?>
146
+								<?php if (!empty($validate_minimum)) : ?>
147 147
 										<div class="invalid-tooltip">
148 148
 											<?php echo $validate_minimum; ?>
149 149
 										</div>
150 150
 									<?php endif; ?>
151 151
 
152
-								<?php if ( 'left' != $position ) : ?>
152
+								<?php if ('left' != $position) : ?>
153 153
 										<div class="input-group-append">
154
-											<span class="input-group-text"><?php echo wpinv_currency_symbol( $currency ); ?></span>
154
+											<span class="input-group-text"><?php echo wpinv_currency_symbol($currency); ?></span>
155 155
 										</div>
156 156
 									<?php endif; ?>
157 157
 								</div>
@@ -159,23 +159,23 @@  discard block
 block discarded – undo
159 159
 							<?php
160 160
 
161 161
 						} else {
162
-						echo wpinv_price( $item->get_price(), $currency );
162
+						echo wpinv_price($item->get_price(), $currency);
163 163
 
164 164
 						?>
165
-								<input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][price]' type='hidden' class='getpaid-item-price-input' value='<?php echo esc_attr( $item->get_price() ); ?>'>
165
+								<input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][price]' type='hidden' class='getpaid-item-price-input' value='<?php echo esc_attr($item->get_price()); ?>'>
166 166
 						<?php
167 167
 						}
168 168
 
169 169
 					printf(
170 170
                         '<small class="d-sm-none text-muted form-text getpaid-mobile-item-subtotal">%s</small>',
171
-                        sprintf( __( 'Subtotal: %s', 'invoicing' ), wpinv_price( $item->get_sub_total(), $currency ) )
171
+                        sprintf(__('Subtotal: %s', 'invoicing'), wpinv_price($item->get_sub_total(), $currency))
172 172
                     );
173 173
 					}
174 174
 
175 175
 					// Item quantity.
176
-					if ( 'quantity' == $key ) {
176
+					if ('quantity' == $key) {
177 177
 
178
-					if ( $item->allows_quantities() ) {
178
+					if ($item->allows_quantities()) {
179 179
 						?>
180 180
 								<input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][quantity]' type="number" step="0.01" style='width: 64px; line-height: 1; min-height: 35px;' class='getpaid-item-quantity-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border' value='<?php echo (float) $item->get_quantity() == 0 ? 1 : (float) $item->get_quantity(); ?>' min='1' <?php echo null !== $max_qty ? 'max="' . (float) $max_qty . '"' : ''; ?> required>
181 181
 							<?php
@@ -189,11 +189,11 @@  discard block
 block discarded – undo
189 189
 }
190 190
 
191 191
 					// Item sub total.
192
-					if ( 'subtotal' == $key ) {
193
-					echo wpinv_price( $item->get_sub_total(), $currency );
192
+					if ('subtotal' == $key) {
193
+					echo wpinv_price($item->get_sub_total(), $currency);
194 194
 					}
195 195
 
196
-					do_action( "getpaid_payment_form_cart_item_$key", $item, $form );
196
+					do_action("getpaid_payment_form_cart_item_$key", $item, $form);
197 197
 				?>
198 198
 
199 199
 			</div>
@@ -204,4 +204,4 @@  discard block
 block discarded – undo
204 204
 
205 205
 </div>
206 206
 <?php
207
-do_action( 'getpaid_payment_form_cart_item', $form, $item );
207
+do_action('getpaid_payment_form_cart_item', $form, $item);
Please login to merge, or discard this patch.
templates/payment-forms/embed.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 	// Is the request set up correctly?
4
-	if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) {
4
+	if (empty($_GET['form']) && empty($_GET['item'])) {
5 5
 	return aui()->alert(
6 6
         array(
7 7
 	'type'    => 'warning',
8
-	'content' => __( 'No payment form or item selected', 'invoicing' ),
8
+	'content' => __('No payment form or item selected', 'invoicing'),
9 9
         )
10 10
 );
11
-wp_die( __( 'No payment form or item selected', 'invoicing' ), 400 );
11
+wp_die(__('No payment form or item selected', 'invoicing'), 400);
12 12
 	}
13 13
 
14 14
 	// Payment form or button?
15
-	if ( ! empty( $_GET['form'] ) ) {
15
+	if (!empty($_GET['form'])) {
16 16
 
17 17
 	$shortcode = sprintf(
18 18
         '[getpaid form=%s]',
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 
24 24
 	$shortcode = sprintf(
25 25
         '[getpaid item=%s]',
26
-        esc_attr( urldecode( $_GET['item'] ) )
26
+        esc_attr(urldecode($_GET['item']))
27 27
 	);
28 28
 
29 29
 	}
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 
36 36
 	<head>
37 37
 
38
-		<meta charset="<?php bloginfo( 'charset' ); ?>">
38
+		<meta charset="<?php bloginfo('charset'); ?>">
39 39
         <meta name="viewport" content="width=device-width, initial-scale=1.0" >
40 40
 
41 41
         <meta name="robots" content="noindex,nofollow">
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 			wp_print_styles();
49 49
 			wp_print_head_scripts();
50 50
 			wp_custom_css_cb();
51
-			wpinv_get_template( 'frontend-head.php' );
51
+			wpinv_get_template('frontend-head.php');
52 52
 		?>
53 53
 
54 54
 		<style type="text/css">
@@ -83,10 +83,10 @@  discard block
 block discarded – undo
83 83
 	<body class="body page-template-default page">
84 84
 		<div id="getpaid-form-embed" class="container my-5 page type-page status-publish hentry post post-content">
85 85
 			<?php
86
-				do_action( 'getpaid_payment_form_embed_top' );
87
-				echo do_shortcode( $shortcode );
88
-				do_action( 'getpaid_payment_form_embed_bottom' );
89
-				wpinv_get_template( 'frontend-footer.php' );
86
+				do_action('getpaid_payment_form_embed_top');
87
+				echo do_shortcode($shortcode);
88
+				do_action('getpaid_payment_form_embed_bottom');
89
+				wpinv_get_template('frontend-footer.php');
90 90
 			?>
91 91
 		</div>
92 92
 		<?php wp_footer(); ?>
Please login to merge, or discard this patch.
templates/payment-forms/elements/file_upload.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -7,33 +7,33 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
11
-
12
-$label        = empty( $label ) ? '' : wp_kses_post( $label );
13
-$label_class  = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) );
14
-$id           = esc_attr( $id );
15
-$_id          = $id . uniqid( '_' );
16
-$max_file_num = empty( $max_file_num ) ? 1 : absint( $max_file_num );
17
-$file_types   = empty( $file_types ) ? array( 'jpg|jpeg|jpe', 'gif', 'png' ) : $file_types;
10
+defined('ABSPATH') || exit;
11
+
12
+$label        = empty($label) ? '' : wp_kses_post($label);
13
+$label_class  = sanitize_key(preg_replace('/[^A-Za-z0-9_-]/', '-', $label));
14
+$id           = esc_attr($id);
15
+$_id          = $id . uniqid('_');
16
+$max_file_num = empty($max_file_num) ? 1 : absint($max_file_num);
17
+$file_types   = empty($file_types) ? array('jpg|jpeg|jpe', 'gif', 'png') : $file_types;
18 18
 $all_types    = getpaid_get_allowed_mime_types();
19 19
 $types        = array();
20 20
 $_types       = array();
21 21
 
22
-foreach ( $file_types as $file_type ) {
22
+foreach ($file_types as $file_type) {
23 23
 
24
-	if ( isset( $all_types[ $file_type ] ) ) {
25
-		$types[]   = $all_types[ $file_type ];
26
-		$file_type = explode( '|', $file_type );
24
+	if (isset($all_types[$file_type])) {
25
+		$types[]   = $all_types[$file_type];
26
+		$file_type = explode('|', $file_type);
27 27
 
28
-		foreach ( $file_type as $type ) {
29
-			$type     = trim( $type );
28
+		foreach ($file_type as $type) {
29
+			$type     = trim($type);
30 30
 			$types[]  = ".$type";
31 31
 			$_types[] = $type;
32 32
 		}
33 33
 }
34 34
 }
35 35
 
36
-if ( ! empty( $required ) ) {
36
+if (!empty($required)) {
37 37
 	$label .= "<span class='text-danger'> *</span>";
38 38
 }
39 39
 
@@ -41,16 +41,16 @@  discard block
 block discarded – undo
41 41
 
42 42
 <label><span v-html="form_element.label"></span></label>
43 43
 
44
-<div class="form-group <?php echo sanitize_html_class( $label_class ); ?>" data-name="<?php echo esc_attr( $id ); ?>" data-max="<?php echo esc_attr( $max_file_num ); ?>">
45
-	<label for="<?php echo esc_attr( $id ); ?>"><?php echo wp_kses_post( $label ); ?></label>
46
-	<input type="file" class="sr-only getpaid-files-input" id="<?php echo esc_attr( $id ); ?>" accept="<?php echo esc_attr( implode( ', ', $types ) ); ?>" data-extensions="<?php echo esc_attr( wp_json_encode( $_types ) ); ?>" <?php echo $max_file_num == 1 ? '' : 'multiple="multiple"'; ?>>
44
+<div class="form-group <?php echo sanitize_html_class($label_class); ?>" data-name="<?php echo esc_attr($id); ?>" data-max="<?php echo esc_attr($max_file_num); ?>">
45
+	<label for="<?php echo esc_attr($id); ?>"><?php echo wp_kses_post($label); ?></label>
46
+	<input type="file" class="sr-only getpaid-files-input" id="<?php echo esc_attr($id); ?>" accept="<?php echo esc_attr(implode(', ', $types)); ?>" data-extensions="<?php echo esc_attr(wp_json_encode($_types)); ?>" <?php echo $max_file_num == 1 ? '' : 'multiple="multiple"'; ?>>
47 47
 
48
-	<label for="<?php echo esc_attr( $id ); ?>" class="getpaid-file-upload-element d-flex w-100 flex-column align-items-center justify-content-center p-2 mb-2">
48
+	<label for="<?php echo esc_attr($id); ?>" class="getpaid-file-upload-element d-flex w-100 flex-column align-items-center justify-content-center p-2 mb-2">
49 49
 		<div class="h5 text-dark">
50
-			<?php echo _n( 'Drag your file to this area or click to upload', 'Drag files to this area or click to upload', $max_file_num, 'invoicing' ); ?>
50
+			<?php echo _n('Drag your file to this area or click to upload', 'Drag files to this area or click to upload', $max_file_num, 'invoicing'); ?>
51 51
 		</div>
52
-		<?php if ( ! empty( $description ) ) : ?>
53
-			<small class="form-text text-muted"><?php echo wp_kses_post( $description ); ?></small>
52
+		<?php if (!empty($description)) : ?>
53
+			<small class="form-text text-muted"><?php echo wp_kses_post($description); ?></small>
54 54
 		<?php endif; ?>
55 55
 	</label>
56 56
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	<div class="form-row mb-3 d-none getpaid-progress-template">
60 60
 
61 61
 		<div class="overflow-hidden text-nowrap col-7 col-sm-4">
62
-			<a href="" class="close float-none" title="<?php esc_attr_e( 'Remove File', 'invoicing' ); ?>">&times;<span class="sr-only"><?php esc_html_e( 'Close', 'invoicing' ); ?></span></a>&nbsp;
62
+			<a href="" class="close float-none" title="<?php esc_attr_e('Remove File', 'invoicing'); ?>">&times;<span class="sr-only"><?php esc_html_e('Close', 'invoicing'); ?></span></a>&nbsp;
63 63
 			<i class="fa fa-file" aria-hidden="true"></i>&nbsp; <span class="getpaid-progress-file-name"></span>&nbsp;
64 64
 		</div>
65 65
 
Please login to merge, or discard this patch.
templates/payment-forms/elements/discount.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -8,20 +8,20 @@  discard block
 block discarded – undo
8 8
  * @var GetPaid_Payment_Form $form The current payment form
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13
-if ( ! getpaid_has_published_discount() ) {
13
+if (!getpaid_has_published_discount()) {
14 14
     return;
15 15
 }
16 16
 
17
-if ( ! empty( $description ) ) {
17
+if (!empty($description)) {
18 18
     $description = "<small class='form-text text-muted'>$description</small>";
19 19
 } else {
20 20
     $description = '';
21 21
 }
22 22
 
23 23
 $discount_code = '';
24
-if ( ! empty( $form->invoice ) ) {
24
+if (!empty($form->invoice)) {
25 25
     $discount_code = $form->invoice->get_discount_code();
26 26
 }
27 27
 
@@ -30,12 +30,12 @@  discard block
 block discarded – undo
30 30
 <div class="form-group">
31 31
     <div class="getpaid-discount-field  border rounded p-3">
32 32
         <div class="getpaid-discount-field-inner d-flex flex-column flex-md-row">
33
-            <input name="discount" placeholder="<?php echo esc_attr( $input_label ); ?>" value="<?php echo esc_attr( $discount_code ); ?>" class="form-control mr-2 mb-2 getpaid-discount-field-input" style="flex: 1;" type="text">
34
-            <a href="#" class="btn btn-secondary submit-button mb-2 getpaid-discount-button"><?php echo esc_html( $button_label ); ?></a>
33
+            <input name="discount" placeholder="<?php echo esc_attr($input_label); ?>" value="<?php echo esc_attr($discount_code); ?>" class="form-control mr-2 mb-2 getpaid-discount-field-input" style="flex: 1;" type="text">
34
+            <a href="#" class="btn btn-secondary submit-button mb-2 getpaid-discount-button"><?php echo esc_html($button_label); ?></a>
35 35
         </div>
36
-        <?php echo wp_kses_post( $description ); ?>
36
+        <?php echo wp_kses_post($description); ?>
37 37
         <div class="getpaid-custom-payment-form-errors alert alert-danger d-none"></div>
38
-        <div class="getpaid-custom-payment-form-success alert alert-success d-none"><?php esc_html_e( 'Discount code applied!', 'invoicing' ); ?></div>
38
+        <div class="getpaid-custom-payment-form-success alert alert-success d-none"><?php esc_html_e('Discount code applied!', 'invoicing'); ?></div>
39 39
     </div>
40 40
 </div>
41 41
 
Please login to merge, or discard this patch.