Passed
Push — master ( 24d4c3...a419ab )
by Stiofan
12:50
created
includes/wpinv-helper-functions.php 1 patch
Spacing   +380 added lines, -380 removed lines patch added patch discarded remove patch
@@ -7,132 +7,132 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 function wpinv_item_quantities_enabled() {
15
-    $ret = wpinv_get_option( 'item_quantities', true );
15
+    $ret = wpinv_get_option('item_quantities', true);
16 16
 
17
-    return (bool) apply_filters( 'wpinv_item_quantities_enabled', $ret );
17
+    return (bool)apply_filters('wpinv_item_quantities_enabled', $ret);
18 18
 }
19 19
 
20 20
 function wpinv_get_ip() {
21 21
     $ip = '127.0.0.1';
22 22
 
23
-    if ( !empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
24
-        $ip = sanitize_text_field( $_SERVER['HTTP_CLIENT_IP'] );
25
-    } elseif ( !empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
26
-        $ip = sanitize_text_field( $_SERVER['HTTP_X_FORWARDED_FOR'] );
27
-    } elseif( !empty( $_SERVER['REMOTE_ADDR'] ) ) {
28
-        $ip = sanitize_text_field( $_SERVER['REMOTE_ADDR'] );
23
+    if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
24
+        $ip = sanitize_text_field($_SERVER['HTTP_CLIENT_IP']);
25
+    } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
26
+        $ip = sanitize_text_field($_SERVER['HTTP_X_FORWARDED_FOR']);
27
+    } elseif (!empty($_SERVER['REMOTE_ADDR'])) {
28
+        $ip = sanitize_text_field($_SERVER['REMOTE_ADDR']);
29 29
     }
30 30
 
31
-    return apply_filters( 'wpinv_get_ip', $ip );
31
+    return apply_filters('wpinv_get_ip', $ip);
32 32
 }
33 33
 
34 34
 function wpinv_get_user_agent() {
35
-    if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
36
-        $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] );
35
+    if (!empty($_SERVER['HTTP_USER_AGENT'])) {
36
+        $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']);
37 37
     } else {
38 38
         $user_agent = '';
39 39
     }
40 40
 
41
-    return apply_filters( 'wpinv_get_user_agent', $user_agent );
41
+    return apply_filters('wpinv_get_user_agent', $user_agent);
42 42
 }
43 43
 
44
-function wpinv_sanitize_amount( $amount, $decimals = NULL ) {
44
+function wpinv_sanitize_amount($amount, $decimals = NULL) {
45 45
     $is_negative   = false;
46 46
     $thousands_sep = wpinv_thousands_separator();
47 47
     $decimal_sep   = wpinv_decimal_separator();
48
-    if ( $decimals === NULL ) {
48
+    if ($decimals === NULL) {
49 49
         $decimals = wpinv_decimals();
50 50
     }
51 51
 
52 52
     // Sanitize the amount
53
-    if ( $decimal_sep == ',' && false !== ( $found = strpos( $amount, $decimal_sep ) ) ) {
54
-        if ( ( $thousands_sep == '.' || $thousands_sep == ' ' ) && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) {
55
-            $amount = str_replace( $thousands_sep, '', $amount );
56
-        } elseif( empty( $thousands_sep ) && false !== ( $found = strpos( $amount, '.' ) ) ) {
57
-            $amount = str_replace( '.', '', $amount );
53
+    if ($decimal_sep == ',' && false !== ($found = strpos($amount, $decimal_sep))) {
54
+        if (($thousands_sep == '.' || $thousands_sep == ' ') && false !== ($found = strpos($amount, $thousands_sep))) {
55
+            $amount = str_replace($thousands_sep, '', $amount);
56
+        } elseif (empty($thousands_sep) && false !== ($found = strpos($amount, '.'))) {
57
+            $amount = str_replace('.', '', $amount);
58 58
         }
59 59
 
60
-        $amount = str_replace( $decimal_sep, '.', $amount );
61
-    } elseif( $thousands_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) {
62
-        $amount = str_replace( $thousands_sep, '', $amount );
60
+        $amount = str_replace($decimal_sep, '.', $amount);
61
+    } elseif ($thousands_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) {
62
+        $amount = str_replace($thousands_sep, '', $amount);
63 63
     }
64 64
 
65
-    if( $amount < 0 ) {
65
+    if ($amount < 0) {
66 66
         $is_negative = true;
67 67
     }
68 68
 
69
-    $amount   = preg_replace( '/[^0-9\.]/', '', $amount );
69
+    $amount   = preg_replace('/[^0-9\.]/', '', $amount);
70 70
 
71
-    $decimals = apply_filters( 'wpinv_sanitize_amount_decimals', absint( $decimals ), $amount );
72
-    $amount   = number_format( (double) $amount, absint( $decimals ), '.', '' );
71
+    $decimals = apply_filters('wpinv_sanitize_amount_decimals', absint($decimals), $amount);
72
+    $amount   = number_format((double)$amount, absint($decimals), '.', '');
73 73
 
74
-    if( $is_negative ) {
74
+    if ($is_negative) {
75 75
         $amount *= -1;
76 76
     }
77 77
 
78
-    return apply_filters( 'wpinv_sanitize_amount', $amount, $decimals );
78
+    return apply_filters('wpinv_sanitize_amount', $amount, $decimals);
79 79
 }
80
-add_filter( 'wpinv_sanitize_amount_decimals', 'wpinv_currency_decimal_filter', 10, 1 );
80
+add_filter('wpinv_sanitize_amount_decimals', 'wpinv_currency_decimal_filter', 10, 1);
81 81
 
82
-function wpinv_round_amount( $amount, $decimals = NULL ) {
83
-    if ( $decimals === NULL ) {
82
+function wpinv_round_amount($amount, $decimals = NULL) {
83
+    if ($decimals === NULL) {
84 84
         $decimals = wpinv_decimals();
85 85
     }
86 86
     
87
-    $amount = round( (double)$amount, wpinv_currency_decimal_filter( absint( $decimals ) ) );
87
+    $amount = round((double)$amount, wpinv_currency_decimal_filter(absint($decimals)));
88 88
 
89
-    return apply_filters( 'wpinv_round_amount', $amount, $decimals );
89
+    return apply_filters('wpinv_round_amount', $amount, $decimals);
90 90
 }
91 91
 
92
-function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) {
92
+function wpinv_get_invoice_statuses($draft = false, $trashed = false, $invoice = false) {
93 93
     global $post;
94 94
 
95 95
     $invoice_statuses = array(
96
-        'wpi-pending' => __( 'Pending Payment', 'invoicing' ),
97
-        'publish' => __( 'Paid', 'invoicing'),
98
-        'wpi-processing' => __( 'Processing', 'invoicing' ),
99
-        'wpi-onhold' => __( 'On Hold', 'invoicing' ),
100
-        'wpi-refunded' => __( 'Refunded', 'invoicing' ),
101
-        'wpi-cancelled' => __( 'Cancelled', 'invoicing' ),
102
-        'wpi-failed' => __( 'Failed', 'invoicing' ),
103
-        'wpi-renewal' => __( 'Renewal Payment', 'invoicing' )
96
+        'wpi-pending' => __('Pending Payment', 'invoicing'),
97
+        'publish' => __('Paid', 'invoicing'),
98
+        'wpi-processing' => __('Processing', 'invoicing'),
99
+        'wpi-onhold' => __('On Hold', 'invoicing'),
100
+        'wpi-refunded' => __('Refunded', 'invoicing'),
101
+        'wpi-cancelled' => __('Cancelled', 'invoicing'),
102
+        'wpi-failed' => __('Failed', 'invoicing'),
103
+        'wpi-renewal' => __('Renewal Payment', 'invoicing')
104 104
     );
105 105
 
106
-    if ( $draft ) {
107
-        $invoice_statuses['draft'] = __( 'Draft', 'invoicing' );
106
+    if ($draft) {
107
+        $invoice_statuses['draft'] = __('Draft', 'invoicing');
108 108
     }
109 109
 
110
-    if ( $trashed ) {
111
-        $invoice_statuses['trash'] = __( 'Trash', 'invoicing' );
110
+    if ($trashed) {
111
+        $invoice_statuses['trash'] = __('Trash', 'invoicing');
112 112
     }
113 113
 
114
-    return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice );
114
+    return apply_filters('wpinv_statuses', $invoice_statuses, $invoice);
115 115
 }
116 116
 
117
-function wpinv_status_nicename( $status ) {
118
-    $statuses = wpinv_get_invoice_statuses( true, true );
119
-    $status   = isset( $statuses[$status] ) ? $statuses[$status] : __( $status, 'invoicing' );
117
+function wpinv_status_nicename($status) {
118
+    $statuses = wpinv_get_invoice_statuses(true, true);
119
+    $status   = isset($statuses[$status]) ? $statuses[$status] : __($status, 'invoicing');
120 120
 
121 121
     return $status;
122 122
 }
123 123
 
124 124
 function wpinv_get_currency() {
125
-    $currency = wpinv_get_option( 'currency', 'USD' );
125
+    $currency = wpinv_get_option('currency', 'USD');
126 126
     
127
-    return apply_filters( 'wpinv_currency', $currency );
127
+    return apply_filters('wpinv_currency', $currency);
128 128
 }
129 129
 
130
-function wpinv_currency_symbol( $currency = '' ) {
131
-    if ( empty( $currency ) ) {
130
+function wpinv_currency_symbol($currency = '') {
131
+    if (empty($currency)) {
132 132
         $currency = wpinv_get_currency();
133 133
     }
134 134
     
135
-    $symbols = apply_filters( 'wpinv_currency_symbols', array(
135
+    $symbols = apply_filters('wpinv_currency_symbols', array(
136 136
         'AED' => '&#x62f;.&#x625;',
137 137
         'AFN' => '&#x60b;',
138 138
         'ALL' => 'L',
@@ -295,209 +295,209 @@  discard block
 block discarded – undo
295 295
         'YER' => '&#xfdfc;',
296 296
         'ZAR' => '&#82;',
297 297
         'ZMW' => 'ZK',
298
-    ) );
298
+    ));
299 299
 
300
-    $currency_symbol = isset( $symbols[$currency] ) ? $symbols[$currency] : $currency;
300
+    $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency;
301 301
 
302
-    return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency );
302
+    return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency);
303 303
 }
304 304
 
305 305
 function wpinv_currency_position() {
306
-    $position = wpinv_get_option( 'currency_position', 'left' );
306
+    $position = wpinv_get_option('currency_position', 'left');
307 307
     
308
-    return apply_filters( 'wpinv_currency_position', $position );
308
+    return apply_filters('wpinv_currency_position', $position);
309 309
 }
310 310
 
311 311
 function wpinv_thousands_separator() {
312
-    $thousand_sep = wpinv_get_option( 'thousands_separator', ',' );
312
+    $thousand_sep = wpinv_get_option('thousands_separator', ',');
313 313
     
314
-    return apply_filters( 'wpinv_thousands_separator', $thousand_sep );
314
+    return apply_filters('wpinv_thousands_separator', $thousand_sep);
315 315
 }
316 316
 
317 317
 function wpinv_decimal_separator() {
318
-    $decimal_sep = wpinv_get_option( 'decimal_separator', '.' );
318
+    $decimal_sep = wpinv_get_option('decimal_separator', '.');
319 319
     
320
-    return apply_filters( 'wpinv_decimal_separator', $decimal_sep );
320
+    return apply_filters('wpinv_decimal_separator', $decimal_sep);
321 321
 }
322 322
 
323 323
 function wpinv_decimals() {
324
-    $decimals = apply_filters( 'wpinv_decimals', wpinv_get_option( 'decimals', 2 ) );
324
+    $decimals = apply_filters('wpinv_decimals', wpinv_get_option('decimals', 2));
325 325
     
326
-    return absint( $decimals );
326
+    return absint($decimals);
327 327
 }
328 328
 
329 329
 function wpinv_get_currencies() {
330 330
     $currencies = array(
331
-        'USD' => __( 'US Dollar', 'invoicing' ),
332
-        'EUR' => __( 'Euro', 'invoicing' ),
333
-        'GBP' => __( 'Pound Sterling', 'invoicing' ),
334
-        'AED' => __( 'United Arab Emirates', 'invoicing' ),
335
-        'AFN' => __( 'Afghan Afghani', 'invoicing' ),
336
-        'ALL' => __( 'Albanian Lek', 'invoicing' ),
337
-        'AMD' => __( 'Armenian Dram', 'invoicing' ),
338
-        'ANG' => __( 'Netherlands Antillean Guilder', 'invoicing' ),
339
-        'AOA' => __( 'Angolan Kwanza', 'invoicing' ),
340
-        'ARS' => __( 'Argentine Peso', 'invoicing' ),
341
-        'AUD' => __( 'Australian Dollar', 'invoicing' ),
342
-        'AWG' => __( 'Aruban Florin', 'invoicing' ),
343
-        'AZN' => __( 'Azerbaijani Manat', 'invoicing' ),
344
-        'BAM' => __( 'Bosnia and Herzegovina Convertible Marka', 'invoicing' ),
345
-        'BBD' => __( 'Barbadian Dollar', 'invoicing' ),
346
-        'BDT' => __( 'Bangladeshi Taka', 'invoicing' ),
347
-        'BGN' => __( 'Bulgarian Lev', 'invoicing' ),
348
-        'BHD' => __( 'Bahraini Dinar', 'invoicing' ),
349
-        'BIF' => __( 'Burundian Franc', 'invoicing' ),
350
-        'BMD' => __( 'Bermudian Dollar', 'invoicing' ),
351
-        'BND' => __( 'Brunei Dollar', 'invoicing' ),
352
-        'BOB' => __( 'Bolivian Boliviano', 'invoicing' ),
353
-        'BRL' => __( 'Brazilian Real', 'invoicing' ),
354
-        'BSD' => __( 'Bahamian Dollar', 'invoicing' ),
355
-        'BTC' => __( 'Bitcoin', 'invoicing' ),
356
-        'BTN' => __( 'Bhutanese Ngultrum', 'invoicing' ),
357
-        'BWP' => __( 'Botswana Pula', 'invoicing' ),
358
-        'BYN' => __( 'Belarusian Ruble', 'invoicing' ),
359
-        'BZD' => __( 'Belize Dollar', 'invoicing' ),
360
-        'CAD' => __( 'Canadian Dollar', 'invoicing' ),
361
-        'CDF' => __( 'Congolese Franc', 'invoicing' ),
362
-        'CHF' => __( 'Swiss Franc', 'invoicing' ),
363
-        'CLP' => __( 'Chilean Peso', 'invoicing' ),
364
-        'CNY' => __( 'Chinese Yuan', 'invoicing' ),
365
-        'COP' => __( 'Colombian Peso', 'invoicing' ),
366
-        'CRC' => __( 'Costa Rican Colon', 'invoicing' ),
367
-        'CUC' => __( 'Cuban Convertible Peso', 'invoicing' ),
368
-        'CUP' => __( 'Cuban Peso', 'invoicing' ),
369
-        'CVE' => __( 'Cape Verdean escudo', 'invoicing' ),
370
-        'CZK' => __( 'Czech Koruna', 'invoicing' ),
371
-        'DJF' => __( 'Djiboutian Franc', 'invoicing' ),
372
-        'DKK' => __( 'Danish Krone', 'invoicing' ),
373
-        'DOP' => __( 'Dominican Peso', 'invoicing' ),
374
-        'DZD' => __( 'Algerian Dinar', 'invoicing' ),
375
-        'EGP' => __( 'Egyptian Pound', 'invoicing' ),
376
-        'ERN' => __( 'Eritrean Nakfa', 'invoicing' ),
377
-        'ETB' => __( 'Ethiopian irr', 'invoicing' ),
378
-        'FJD' => __( 'Fijian Dollar', 'invoicing' ),
379
-        'FKP' => __( 'Falkland Islands Pound', 'invoicing' ),
380
-        'GEL' => __( 'Georgian lari', 'invoicing' ),
381
-        'GGP' => __( 'Guernsey Pound', 'invoicing' ),
382
-        'GHS' => __( 'Ghana cedi', 'invoicing' ),
383
-        'GIP' => __( 'Gibraltar Pound', 'invoicing' ),
384
-        'GMD' => __( 'Gambian Dalasi', 'invoicing' ),
385
-        'GNF' => __( 'Guinean Franc', 'invoicing' ),
386
-        'GTQ' => __( 'Guatemalan Quetzal', 'invoicing' ),
387
-        'GYD' => __( 'Guyanese Dollar', 'invoicing' ),
388
-        'HKD' => __( 'Hong Kong Dollar', 'invoicing' ),
389
-        'HNL' => __( 'Honduran Lempira', 'invoicing' ),
390
-        'HRK' => __( 'Croatian Kuna', 'invoicing' ),
391
-        'HTG' => __( 'Haitian Gourde', 'invoicing' ),
392
-        'HUF' => __( 'Hungarian Forint', 'invoicing' ),
393
-        'IDR' => __( 'Indonesian Rupiah', 'invoicing' ),
394
-        'ILS' => __( 'Israeli New Shekel', 'invoicing' ),
395
-        'IMP' => __( 'Manx Pound', 'invoicing' ),
396
-        'INR' => __( 'Indian Rupee', 'invoicing' ),
397
-        'IQD' => __( 'Iraqi Dinar', 'invoicing' ),
398
-        'IRR' => __( 'Iranian Rial', 'invoicing' ),
399
-        'IRT' => __( 'Iranian Toman', 'invoicing' ),
400
-        'ISK' => __( 'Icelandic Krona', 'invoicing' ),
401
-        'JEP' => __( 'Jersey Pound', 'invoicing' ),
402
-        'JMD' => __( 'Jamaican Dollar', 'invoicing' ),
403
-        'JOD' => __( 'Jordanian Dinar', 'invoicing' ),
404
-        'JPY' => __( 'Japanese Yen', 'invoicing' ),
405
-        'KES' => __( 'Kenyan Shilling', 'invoicing' ),
406
-        'KGS' => __( 'Kyrgyzstani Som', 'invoicing' ),
407
-        'KHR' => __( 'Cambodian Riel', 'invoicing' ),
408
-        'KMF' => __( 'Comorian Franc', 'invoicing' ),
409
-        'KPW' => __( 'North Korean Won', 'invoicing' ),
410
-        'KRW' => __( 'South Korean Won', 'invoicing' ),
411
-        'KWD' => __( 'Kuwaiti Dinar', 'invoicing' ),
412
-        'KYD' => __( 'Cayman Islands Dollar', 'invoicing' ),
413
-        'KZT' => __( 'Kazakhstani Tenge', 'invoicing' ),
414
-        'LAK' => __( 'Lao Kip', 'invoicing' ),
415
-        'LBP' => __( 'Lebanese Pound', 'invoicing' ),
416
-        'LKR' => __( 'Sri Lankan Rupee', 'invoicing' ),
417
-        'LRD' => __( 'Liberian Dollar', 'invoicing' ),
418
-        'LSL' => __( 'Lesotho Loti', 'invoicing' ),
419
-        'LYD' => __( 'Libyan Dinar', 'invoicing' ),
420
-        'MAD' => __( 'Moroccan Dirham', 'invoicing' ),
421
-        'MDL' => __( 'Moldovan Leu', 'invoicing' ),
422
-        'MGA' => __( 'Malagasy Ariary', 'invoicing' ),
423
-        'MKD' => __( 'Macedonian Denar', 'invoicing' ),
424
-        'MMK' => __( 'Burmese Kyat', 'invoicing' ),
425
-        'MNT' => __( 'Mongolian Tughrik', 'invoicing' ),
426
-        'MOP' => __( 'Macanese Pataca', 'invoicing' ),
427
-        'MRO' => __( 'Mauritanian Ouguiya', 'invoicing' ),
428
-        'MUR' => __( 'Mauritian Rupee', 'invoicing' ),
429
-        'MVR' => __( 'Maldivian Rufiyaa', 'invoicing' ),
430
-        'MWK' => __( 'Malawian Kwacha', 'invoicing' ),
431
-        'MXN' => __( 'Mexican Peso', 'invoicing' ),
432
-        'MYR' => __( 'Malaysian Ringgit', 'invoicing' ),
433
-        'MZN' => __( 'Mozambican Metical', 'invoicing' ),
434
-        'NAD' => __( 'Namibian Dollar', 'invoicing' ),
435
-        'NGN' => __( 'Nigerian Naira', 'invoicing' ),
436
-        'NIO' => __( 'Nicaraguan Cordoba', 'invoicing' ),
437
-        'NOK' => __( 'Norwegian Krone', 'invoicing' ),
438
-        'NPR' => __( 'Nepalese Rupee', 'invoicing' ),
439
-        'NZD' => __( 'New Zealand Dollar', 'invoicing' ),
440
-        'OMR' => __( 'Omani Rial', 'invoicing' ),
441
-        'PAB' => __( 'Panamanian Balboa', 'invoicing' ),
442
-        'PEN' => __( 'Peruvian Nuevo Sol', 'invoicing' ),
443
-        'PGK' => __( 'Papua New Guinean Kina', 'invoicing' ),
444
-        'PHP' => __( 'Philippine Peso', 'invoicing' ),
445
-        'PKR' => __( 'Pakistani Rupee', 'invoicing' ),
446
-        'PLN' => __( 'Polish Zloty', 'invoicing' ),
447
-        'PRB' => __( 'Transnistrian Ruble', 'invoicing' ),
448
-        'PYG' => __( 'Paraguayan Guarani', 'invoicing' ),
449
-        'QAR' => __( 'Qatari Riyal', 'invoicing' ),
450
-        'RON' => __( 'Romanian Leu', 'invoicing' ),
451
-        'RSD' => __( 'Serbian Dinar', 'invoicing' ),
452
-        'RUB' => __( 'Russian Ruble', 'invoicing' ),
453
-        'RWF' => __( 'Rwandan Franc', 'invoicing' ),
454
-        'SAR' => __( 'Saudi Riyal', 'invoicing' ),
455
-        'SBD' => __( 'Solomon Islands Dollar', 'invoicing' ),
456
-        'SCR' => __( 'Seychellois Rupee', 'invoicing' ),
457
-        'SDG' => __( 'Sudanese Pound', 'invoicing' ),
458
-        'SEK' => __( 'Swedish Krona', 'invoicing' ),
459
-        'SGD' => __( 'Singapore Dollar', 'invoicing' ),
460
-        'SHP' => __( 'Saint Helena Pound', 'invoicing' ),
461
-        'SLL' => __( 'Sierra Leonean Leone', 'invoicing' ),
462
-        'SOS' => __( 'Somali Shilling', 'invoicing' ),
463
-        'SRD' => __( 'Surinamese Dollar', 'invoicing' ),
464
-        'SSP' => __( 'South Sudanese Pound', 'invoicing' ),
465
-        'STD' => __( 'Sao Tomean Dobra', 'invoicing' ),
466
-        'SYP' => __( 'Syrian Pound', 'invoicing' ),
467
-        'SZL' => __( 'Swazi Lilangeni', 'invoicing' ),
468
-        'THB' => __( 'Thai Baht', 'invoicing' ),
469
-        'TJS' => __( 'Tajikistani Somoni', 'invoicing' ),
470
-        'TMT' => __( 'Turkmenistan Manat', 'invoicing' ),
471
-        'TND' => __( 'Tunisian Dinar', 'invoicing' ),
472
-        'TOP' => __( 'Tongan Pa&#x2bb;anga', 'invoicing' ),
473
-        'TRY' => __( 'Turkish Lira', 'invoicing' ),
474
-        'TTD' => __( 'Trinidad and Tobago Dollar', 'invoicing' ),
475
-        'TWD' => __( 'New Taiwan Dollar', 'invoicing' ),
476
-        'TZS' => __( 'Tanzanian Shilling', 'invoicing' ),
477
-        'UAH' => __( 'Ukrainian Hryvnia', 'invoicing' ),
478
-        'UGX' => __( 'Ugandan Shilling', 'invoicing' ),
479
-        'UYU' => __( 'Uruguayan Peso', 'invoicing' ),
480
-        'UZS' => __( 'Uzbekistani Som', 'invoicing' ),
481
-        'VEF' => __( 'Venezuelan Bol&iacute;var', 'invoicing' ),
482
-        'VND' => __( 'Vietnamese Dong', 'invoicing' ),
483
-        'VUV' => __( 'Vanuatu Vatu', 'invoicing' ),
484
-        'WST' => __( 'Samoan Tala', 'invoicing' ),
485
-        'XAF' => __( 'Central African CFA Franc', 'invoicing' ),
486
-        'XCD' => __( 'East Caribbean Dollar', 'invoicing' ),
487
-        'XOF' => __( 'West African CFA Franc', 'invoicing' ),
488
-        'XPF' => __( 'CFP Franc', 'invoicing' ),
489
-        'YER' => __( 'Yemeni Rial', 'invoicing' ),
490
-        'ZAR' => __( 'South African Rand', 'invoicing' ),
491
-        'ZMW' => __( 'Zambian Kwacha', 'invoicing' ),
331
+        'USD' => __('US Dollar', 'invoicing'),
332
+        'EUR' => __('Euro', 'invoicing'),
333
+        'GBP' => __('Pound Sterling', 'invoicing'),
334
+        'AED' => __('United Arab Emirates', 'invoicing'),
335
+        'AFN' => __('Afghan Afghani', 'invoicing'),
336
+        'ALL' => __('Albanian Lek', 'invoicing'),
337
+        'AMD' => __('Armenian Dram', 'invoicing'),
338
+        'ANG' => __('Netherlands Antillean Guilder', 'invoicing'),
339
+        'AOA' => __('Angolan Kwanza', 'invoicing'),
340
+        'ARS' => __('Argentine Peso', 'invoicing'),
341
+        'AUD' => __('Australian Dollar', 'invoicing'),
342
+        'AWG' => __('Aruban Florin', 'invoicing'),
343
+        'AZN' => __('Azerbaijani Manat', 'invoicing'),
344
+        'BAM' => __('Bosnia and Herzegovina Convertible Marka', 'invoicing'),
345
+        'BBD' => __('Barbadian Dollar', 'invoicing'),
346
+        'BDT' => __('Bangladeshi Taka', 'invoicing'),
347
+        'BGN' => __('Bulgarian Lev', 'invoicing'),
348
+        'BHD' => __('Bahraini Dinar', 'invoicing'),
349
+        'BIF' => __('Burundian Franc', 'invoicing'),
350
+        'BMD' => __('Bermudian Dollar', 'invoicing'),
351
+        'BND' => __('Brunei Dollar', 'invoicing'),
352
+        'BOB' => __('Bolivian Boliviano', 'invoicing'),
353
+        'BRL' => __('Brazilian Real', 'invoicing'),
354
+        'BSD' => __('Bahamian Dollar', 'invoicing'),
355
+        'BTC' => __('Bitcoin', 'invoicing'),
356
+        'BTN' => __('Bhutanese Ngultrum', 'invoicing'),
357
+        'BWP' => __('Botswana Pula', 'invoicing'),
358
+        'BYN' => __('Belarusian Ruble', 'invoicing'),
359
+        'BZD' => __('Belize Dollar', 'invoicing'),
360
+        'CAD' => __('Canadian Dollar', 'invoicing'),
361
+        'CDF' => __('Congolese Franc', 'invoicing'),
362
+        'CHF' => __('Swiss Franc', 'invoicing'),
363
+        'CLP' => __('Chilean Peso', 'invoicing'),
364
+        'CNY' => __('Chinese Yuan', 'invoicing'),
365
+        'COP' => __('Colombian Peso', 'invoicing'),
366
+        'CRC' => __('Costa Rican Colon', 'invoicing'),
367
+        'CUC' => __('Cuban Convertible Peso', 'invoicing'),
368
+        'CUP' => __('Cuban Peso', 'invoicing'),
369
+        'CVE' => __('Cape Verdean escudo', 'invoicing'),
370
+        'CZK' => __('Czech Koruna', 'invoicing'),
371
+        'DJF' => __('Djiboutian Franc', 'invoicing'),
372
+        'DKK' => __('Danish Krone', 'invoicing'),
373
+        'DOP' => __('Dominican Peso', 'invoicing'),
374
+        'DZD' => __('Algerian Dinar', 'invoicing'),
375
+        'EGP' => __('Egyptian Pound', 'invoicing'),
376
+        'ERN' => __('Eritrean Nakfa', 'invoicing'),
377
+        'ETB' => __('Ethiopian irr', 'invoicing'),
378
+        'FJD' => __('Fijian Dollar', 'invoicing'),
379
+        'FKP' => __('Falkland Islands Pound', 'invoicing'),
380
+        'GEL' => __('Georgian lari', 'invoicing'),
381
+        'GGP' => __('Guernsey Pound', 'invoicing'),
382
+        'GHS' => __('Ghana cedi', 'invoicing'),
383
+        'GIP' => __('Gibraltar Pound', 'invoicing'),
384
+        'GMD' => __('Gambian Dalasi', 'invoicing'),
385
+        'GNF' => __('Guinean Franc', 'invoicing'),
386
+        'GTQ' => __('Guatemalan Quetzal', 'invoicing'),
387
+        'GYD' => __('Guyanese Dollar', 'invoicing'),
388
+        'HKD' => __('Hong Kong Dollar', 'invoicing'),
389
+        'HNL' => __('Honduran Lempira', 'invoicing'),
390
+        'HRK' => __('Croatian Kuna', 'invoicing'),
391
+        'HTG' => __('Haitian Gourde', 'invoicing'),
392
+        'HUF' => __('Hungarian Forint', 'invoicing'),
393
+        'IDR' => __('Indonesian Rupiah', 'invoicing'),
394
+        'ILS' => __('Israeli New Shekel', 'invoicing'),
395
+        'IMP' => __('Manx Pound', 'invoicing'),
396
+        'INR' => __('Indian Rupee', 'invoicing'),
397
+        'IQD' => __('Iraqi Dinar', 'invoicing'),
398
+        'IRR' => __('Iranian Rial', 'invoicing'),
399
+        'IRT' => __('Iranian Toman', 'invoicing'),
400
+        'ISK' => __('Icelandic Krona', 'invoicing'),
401
+        'JEP' => __('Jersey Pound', 'invoicing'),
402
+        'JMD' => __('Jamaican Dollar', 'invoicing'),
403
+        'JOD' => __('Jordanian Dinar', 'invoicing'),
404
+        'JPY' => __('Japanese Yen', 'invoicing'),
405
+        'KES' => __('Kenyan Shilling', 'invoicing'),
406
+        'KGS' => __('Kyrgyzstani Som', 'invoicing'),
407
+        'KHR' => __('Cambodian Riel', 'invoicing'),
408
+        'KMF' => __('Comorian Franc', 'invoicing'),
409
+        'KPW' => __('North Korean Won', 'invoicing'),
410
+        'KRW' => __('South Korean Won', 'invoicing'),
411
+        'KWD' => __('Kuwaiti Dinar', 'invoicing'),
412
+        'KYD' => __('Cayman Islands Dollar', 'invoicing'),
413
+        'KZT' => __('Kazakhstani Tenge', 'invoicing'),
414
+        'LAK' => __('Lao Kip', 'invoicing'),
415
+        'LBP' => __('Lebanese Pound', 'invoicing'),
416
+        'LKR' => __('Sri Lankan Rupee', 'invoicing'),
417
+        'LRD' => __('Liberian Dollar', 'invoicing'),
418
+        'LSL' => __('Lesotho Loti', 'invoicing'),
419
+        'LYD' => __('Libyan Dinar', 'invoicing'),
420
+        'MAD' => __('Moroccan Dirham', 'invoicing'),
421
+        'MDL' => __('Moldovan Leu', 'invoicing'),
422
+        'MGA' => __('Malagasy Ariary', 'invoicing'),
423
+        'MKD' => __('Macedonian Denar', 'invoicing'),
424
+        'MMK' => __('Burmese Kyat', 'invoicing'),
425
+        'MNT' => __('Mongolian Tughrik', 'invoicing'),
426
+        'MOP' => __('Macanese Pataca', 'invoicing'),
427
+        'MRO' => __('Mauritanian Ouguiya', 'invoicing'),
428
+        'MUR' => __('Mauritian Rupee', 'invoicing'),
429
+        'MVR' => __('Maldivian Rufiyaa', 'invoicing'),
430
+        'MWK' => __('Malawian Kwacha', 'invoicing'),
431
+        'MXN' => __('Mexican Peso', 'invoicing'),
432
+        'MYR' => __('Malaysian Ringgit', 'invoicing'),
433
+        'MZN' => __('Mozambican Metical', 'invoicing'),
434
+        'NAD' => __('Namibian Dollar', 'invoicing'),
435
+        'NGN' => __('Nigerian Naira', 'invoicing'),
436
+        'NIO' => __('Nicaraguan Cordoba', 'invoicing'),
437
+        'NOK' => __('Norwegian Krone', 'invoicing'),
438
+        'NPR' => __('Nepalese Rupee', 'invoicing'),
439
+        'NZD' => __('New Zealand Dollar', 'invoicing'),
440
+        'OMR' => __('Omani Rial', 'invoicing'),
441
+        'PAB' => __('Panamanian Balboa', 'invoicing'),
442
+        'PEN' => __('Peruvian Nuevo Sol', 'invoicing'),
443
+        'PGK' => __('Papua New Guinean Kina', 'invoicing'),
444
+        'PHP' => __('Philippine Peso', 'invoicing'),
445
+        'PKR' => __('Pakistani Rupee', 'invoicing'),
446
+        'PLN' => __('Polish Zloty', 'invoicing'),
447
+        'PRB' => __('Transnistrian Ruble', 'invoicing'),
448
+        'PYG' => __('Paraguayan Guarani', 'invoicing'),
449
+        'QAR' => __('Qatari Riyal', 'invoicing'),
450
+        'RON' => __('Romanian Leu', 'invoicing'),
451
+        'RSD' => __('Serbian Dinar', 'invoicing'),
452
+        'RUB' => __('Russian Ruble', 'invoicing'),
453
+        'RWF' => __('Rwandan Franc', 'invoicing'),
454
+        'SAR' => __('Saudi Riyal', 'invoicing'),
455
+        'SBD' => __('Solomon Islands Dollar', 'invoicing'),
456
+        'SCR' => __('Seychellois Rupee', 'invoicing'),
457
+        'SDG' => __('Sudanese Pound', 'invoicing'),
458
+        'SEK' => __('Swedish Krona', 'invoicing'),
459
+        'SGD' => __('Singapore Dollar', 'invoicing'),
460
+        'SHP' => __('Saint Helena Pound', 'invoicing'),
461
+        'SLL' => __('Sierra Leonean Leone', 'invoicing'),
462
+        'SOS' => __('Somali Shilling', 'invoicing'),
463
+        'SRD' => __('Surinamese Dollar', 'invoicing'),
464
+        'SSP' => __('South Sudanese Pound', 'invoicing'),
465
+        'STD' => __('Sao Tomean Dobra', 'invoicing'),
466
+        'SYP' => __('Syrian Pound', 'invoicing'),
467
+        'SZL' => __('Swazi Lilangeni', 'invoicing'),
468
+        'THB' => __('Thai Baht', 'invoicing'),
469
+        'TJS' => __('Tajikistani Somoni', 'invoicing'),
470
+        'TMT' => __('Turkmenistan Manat', 'invoicing'),
471
+        'TND' => __('Tunisian Dinar', 'invoicing'),
472
+        'TOP' => __('Tongan Pa&#x2bb;anga', 'invoicing'),
473
+        'TRY' => __('Turkish Lira', 'invoicing'),
474
+        'TTD' => __('Trinidad and Tobago Dollar', 'invoicing'),
475
+        'TWD' => __('New Taiwan Dollar', 'invoicing'),
476
+        'TZS' => __('Tanzanian Shilling', 'invoicing'),
477
+        'UAH' => __('Ukrainian Hryvnia', 'invoicing'),
478
+        'UGX' => __('Ugandan Shilling', 'invoicing'),
479
+        'UYU' => __('Uruguayan Peso', 'invoicing'),
480
+        'UZS' => __('Uzbekistani Som', 'invoicing'),
481
+        'VEF' => __('Venezuelan Bol&iacute;var', 'invoicing'),
482
+        'VND' => __('Vietnamese Dong', 'invoicing'),
483
+        'VUV' => __('Vanuatu Vatu', 'invoicing'),
484
+        'WST' => __('Samoan Tala', 'invoicing'),
485
+        'XAF' => __('Central African CFA Franc', 'invoicing'),
486
+        'XCD' => __('East Caribbean Dollar', 'invoicing'),
487
+        'XOF' => __('West African CFA Franc', 'invoicing'),
488
+        'XPF' => __('CFP Franc', 'invoicing'),
489
+        'YER' => __('Yemeni Rial', 'invoicing'),
490
+        'ZAR' => __('South African Rand', 'invoicing'),
491
+        'ZMW' => __('Zambian Kwacha', 'invoicing'),
492 492
     );
493 493
     
494 494
     //asort( $currencies ); // this
495 495
 
496
-    return apply_filters( 'wpinv_currencies', $currencies );
496
+    return apply_filters('wpinv_currencies', $currencies);
497 497
 }
498 498
 
499
-function wpinv_price( $amount = '', $currency = '' ) {
500
-    if( empty( $currency ) ) {
499
+function wpinv_price($amount = '', $currency = '') {
500
+    if (empty($currency)) {
501 501
         $currency = wpinv_get_currency();
502 502
     }
503 503
 
@@ -505,14 +505,14 @@  discard block
 block discarded – undo
505 505
 
506 506
     $negative = $amount < 0;
507 507
 
508
-    if ( $negative ) {
509
-        $amount = substr( $amount, 1 );
508
+    if ($negative) {
509
+        $amount = substr($amount, 1);
510 510
     }
511 511
 
512
-    $symbol = wpinv_currency_symbol( $currency );
512
+    $symbol = wpinv_currency_symbol($currency);
513 513
 
514
-    if ( $position == 'left' || $position == 'left_space' ) {
515
-        switch ( $currency ) {
514
+    if ($position == 'left' || $position == 'left_space') {
515
+        switch ($currency) {
516 516
             case "GBP" :
517 517
             case "BRL" :
518 518
             case "EUR" :
@@ -524,15 +524,15 @@  discard block
 block discarded – undo
524 524
             case "NZD" :
525 525
             case "SGD" :
526 526
             case "JPY" :
527
-                $price = $position == 'left_space' ? $symbol . ' ' .  $amount : $symbol . $amount;
527
+                $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount;
528 528
                 break;
529 529
             default :
530 530
                 //$price = $currency . ' ' . $amount;
531
-                $price = $position == 'left_space' ? $symbol . ' ' .  $amount : $symbol . $amount;
531
+                $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount;
532 532
                 break;
533 533
         }
534 534
     } else {
535
-        switch ( $currency ) {
535
+        switch ($currency) {
536 536
             case "GBP" :
537 537
             case "BRL" :
538 538
             case "EUR" :
@@ -543,83 +543,83 @@  discard block
 block discarded – undo
543 543
             case "MXN" :
544 544
             case "SGD" :
545 545
             case "JPY" :
546
-                $price = $position == 'right_space' ? $amount . ' ' .  $symbol : $amount . $symbol;
546
+                $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol;
547 547
                 break;
548 548
             default :
549 549
                 //$price = $amount . ' ' . $currency;
550
-                $price = $position == 'right_space' ? $amount . ' ' .  $symbol : $amount . $symbol;
550
+                $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol;
551 551
                 break;
552 552
         }
553 553
     }
554 554
     
555
-    if ( $negative ) {
555
+    if ($negative) {
556 556
         $price = '-' . $price;
557 557
     }
558 558
     
559
-    $price = apply_filters( 'wpinv_' . strtolower( $currency ) . '_currency_filter_' . $position, $price, $currency, $amount );
559
+    $price = apply_filters('wpinv_' . strtolower($currency) . '_currency_filter_' . $position, $price, $currency, $amount);
560 560
 
561 561
     return $price;
562 562
 }
563 563
 
564
-function wpinv_format_amount( $amount, $decimals = NULL, $calculate = false ) {
564
+function wpinv_format_amount($amount, $decimals = NULL, $calculate = false) {
565 565
     $thousands_sep = wpinv_thousands_separator();
566 566
     $decimal_sep   = wpinv_decimal_separator();
567 567
 
568
-    if ( $decimals === NULL ) {
568
+    if ($decimals === NULL) {
569 569
         $decimals = wpinv_decimals();
570 570
     }
571 571
 
572
-    if ( $decimal_sep == ',' && false !== ( $sep_found = strpos( $amount, $decimal_sep ) ) ) {
573
-        $whole = substr( $amount, 0, $sep_found );
574
-        $part = substr( $amount, $sep_found + 1, ( strlen( $amount ) - 1 ) );
572
+    if ($decimal_sep == ',' && false !== ($sep_found = strpos($amount, $decimal_sep))) {
573
+        $whole = substr($amount, 0, $sep_found);
574
+        $part = substr($amount, $sep_found + 1, (strlen($amount) - 1));
575 575
         $amount = $whole . '.' . $part;
576 576
     }
577 577
 
578
-    if ( $thousands_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) {
579
-        $amount = str_replace( ',', '', $amount );
578
+    if ($thousands_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) {
579
+        $amount = str_replace(',', '', $amount);
580 580
     }
581 581
 
582
-    if ( $thousands_sep == ' ' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) {
583
-        $amount = str_replace( ' ', '', $amount );
582
+    if ($thousands_sep == ' ' && false !== ($found = strpos($amount, $thousands_sep))) {
583
+        $amount = str_replace(' ', '', $amount);
584 584
     }
585 585
 
586
-    if ( empty( $amount ) ) {
586
+    if (empty($amount)) {
587 587
         $amount = 0;
588 588
     }
589 589
     
590
-    $decimals  = apply_filters( 'wpinv_amount_format_decimals', $decimals ? $decimals : 0, $amount, $calculate );
591
-    $formatted = number_format( (float)$amount, $decimals, $decimal_sep, $thousands_sep );
590
+    $decimals  = apply_filters('wpinv_amount_format_decimals', $decimals ? $decimals : 0, $amount, $calculate);
591
+    $formatted = number_format((float)$amount, $decimals, $decimal_sep, $thousands_sep);
592 592
     
593
-    if ( $calculate ) {
594
-        if ( $thousands_sep === "," ) {
595
-            $formatted = str_replace( ",", "", $formatted );
593
+    if ($calculate) {
594
+        if ($thousands_sep === ",") {
595
+            $formatted = str_replace(",", "", $formatted);
596 596
         }
597 597
         
598
-        if ( $decimal_sep === "," ) {
599
-            $formatted = str_replace( ",", ".", $formatted );
598
+        if ($decimal_sep === ",") {
599
+            $formatted = str_replace(",", ".", $formatted);
600 600
         }
601 601
     }
602 602
 
603
-    return apply_filters( 'wpinv_amount_format', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $calculate );
603
+    return apply_filters('wpinv_amount_format', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $calculate);
604 604
 }
605
-add_filter( 'wpinv_amount_format_decimals', 'wpinv_currency_decimal_filter', 10, 1 );
605
+add_filter('wpinv_amount_format_decimals', 'wpinv_currency_decimal_filter', 10, 1);
606 606
 
607
-function wpinv_sanitize_key( $key ) {
607
+function wpinv_sanitize_key($key) {
608 608
     $raw_key = $key;
609
-    $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key );
609
+    $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key);
610 610
 
611
-    return apply_filters( 'wpinv_sanitize_key', $key, $raw_key );
611
+    return apply_filters('wpinv_sanitize_key', $key, $raw_key);
612 612
 }
613 613
 
614
-function wpinv_get_file_extension( $str ) {
615
-    $parts = explode( '.', $str );
616
-    return end( $parts );
614
+function wpinv_get_file_extension($str) {
615
+    $parts = explode('.', $str);
616
+    return end($parts);
617 617
 }
618 618
 
619
-function wpinv_string_is_image_url( $str ) {
620
-    $ext = wpinv_get_file_extension( $str );
619
+function wpinv_string_is_image_url($str) {
620
+    $ext = wpinv_get_file_extension($str);
621 621
 
622
-    switch ( strtolower( $ext ) ) {
622
+    switch (strtolower($ext)) {
623 623
         case 'jpeg';
624 624
         case 'jpg';
625 625
             $return = true;
@@ -635,32 +635,32 @@  discard block
 block discarded – undo
635 635
             break;
636 636
     }
637 637
 
638
-    return (bool)apply_filters( 'wpinv_string_is_image', $return, $str );
638
+    return (bool)apply_filters('wpinv_string_is_image', $return, $str);
639 639
 }
640 640
 
641
-function wpinv_error_log( $log, $title = '', $file = '', $line = '', $exit = false ) {
642
-    $should_log = apply_filters( 'wpinv_log_errors', WP_DEBUG );
641
+function wpinv_error_log($log, $title = '', $file = '', $line = '', $exit = false) {
642
+    $should_log = apply_filters('wpinv_log_errors', WP_DEBUG);
643 643
     
644
-    if ( true === $should_log ) {
644
+    if (true === $should_log) {
645 645
         $label = '';
646
-        if ( $file && $file !== '' ) {
647
-            $label .= basename( $file ) . ( $line ? '(' . $line . ')' : '' );
646
+        if ($file && $file !== '') {
647
+            $label .= basename($file) . ($line ? '(' . $line . ')' : '');
648 648
         }
649 649
         
650
-        if ( $title && $title !== '' ) {
650
+        if ($title && $title !== '') {
651 651
             $label = $label !== '' ? $label . ' ' : '';
652 652
             $label .= $title . ' ';
653 653
         }
654 654
         
655
-        $label = $label !== '' ? trim( $label ) . ' : ' : '';
655
+        $label = $label !== '' ? trim($label) . ' : ' : '';
656 656
         
657
-        if ( is_array( $log ) || is_object( $log ) ) {
658
-            error_log( $label . print_r( $log, true ) );
657
+        if (is_array($log) || is_object($log)) {
658
+            error_log($label . print_r($log, true));
659 659
         } else {
660
-            error_log( $label . $log );
660
+            error_log($label . $log);
661 661
         }
662 662
         
663
-        if ( $exit ) {
663
+        if ($exit) {
664 664
             exit;
665 665
         }
666 666
     }
@@ -668,65 +668,65 @@  discard block
 block discarded – undo
668 668
 
669 669
 function wpinv_is_ajax_disabled() {
670 670
     $retval = false;
671
-    return apply_filters( 'wpinv_is_ajax_disabled', $retval );
671
+    return apply_filters('wpinv_is_ajax_disabled', $retval);
672 672
 }
673 673
 
674
-function wpinv_get_current_page_url( $nocache = false ) {
674
+function wpinv_get_current_page_url($nocache = false) {
675 675
     global $wp;
676 676
 
677
-    if ( get_option( 'permalink_structure' ) ) {
678
-        $base = trailingslashit( home_url( $wp->request ) );
677
+    if (get_option('permalink_structure')) {
678
+        $base = trailingslashit(home_url($wp->request));
679 679
     } else {
680
-        $base = add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) );
681
-        $base = remove_query_arg( array( 'post_type', 'name' ), $base );
680
+        $base = add_query_arg($wp->query_string, '', trailingslashit(home_url($wp->request)));
681
+        $base = remove_query_arg(array('post_type', 'name'), $base);
682 682
     }
683 683
 
684 684
     $scheme = is_ssl() ? 'https' : 'http';
685
-    $uri    = set_url_scheme( $base, $scheme );
685
+    $uri    = set_url_scheme($base, $scheme);
686 686
 
687
-    if ( is_front_page() ) {
688
-        $uri = home_url( '/' );
689
-    } elseif ( wpinv_is_checkout( array(), false ) ) {
687
+    if (is_front_page()) {
688
+        $uri = home_url('/');
689
+    } elseif (wpinv_is_checkout(array(), false)) {
690 690
         $uri = wpinv_get_checkout_uri();
691 691
     }
692 692
 
693
-    $uri = apply_filters( 'wpinv_get_current_page_url', $uri );
693
+    $uri = apply_filters('wpinv_get_current_page_url', $uri);
694 694
 
695
-    if ( $nocache ) {
696
-        $uri = wpinv_add_cache_busting( $uri );
695
+    if ($nocache) {
696
+        $uri = wpinv_add_cache_busting($uri);
697 697
     }
698 698
 
699 699
     return $uri;
700 700
 }
701 701
 
702 702
 function wpinv_get_php_arg_separator_output() {
703
-	return ini_get( 'arg_separator.output' );
703
+	return ini_get('arg_separator.output');
704 704
 }
705 705
 
706
-function wpinv_rgb_from_hex( $color ) {
707
-    $color = str_replace( '#', '', $color );
706
+function wpinv_rgb_from_hex($color) {
707
+    $color = str_replace('#', '', $color);
708 708
     // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF"
709
-    $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color );
709
+    $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color);
710 710
 
711 711
     $rgb      = array();
712
-    $rgb['R'] = hexdec( $color{0}.$color{1} );
713
-    $rgb['G'] = hexdec( $color{2}.$color{3} );
714
-    $rgb['B'] = hexdec( $color{4}.$color{5} );
712
+    $rgb['R'] = hexdec($color{0} . $color{1} );
713
+    $rgb['G'] = hexdec($color{2} . $color{3} );
714
+    $rgb['B'] = hexdec($color{4} . $color{5} );
715 715
 
716 716
     return $rgb;
717 717
 }
718 718
 
719
-function wpinv_hex_darker( $color, $factor = 30 ) {
720
-    $base  = wpinv_rgb_from_hex( $color );
719
+function wpinv_hex_darker($color, $factor = 30) {
720
+    $base  = wpinv_rgb_from_hex($color);
721 721
     $color = '#';
722 722
 
723
-    foreach ( $base as $k => $v ) {
723
+    foreach ($base as $k => $v) {
724 724
         $amount      = $v / 100;
725
-        $amount      = round( $amount * $factor );
725
+        $amount      = round($amount * $factor);
726 726
         $new_decimal = $v - $amount;
727 727
 
728
-        $new_hex_component = dechex( $new_decimal );
729
-        if ( strlen( $new_hex_component ) < 2 ) {
728
+        $new_hex_component = dechex($new_decimal);
729
+        if (strlen($new_hex_component) < 2) {
730 730
             $new_hex_component = "0" . $new_hex_component;
731 731
         }
732 732
         $color .= $new_hex_component;
@@ -735,18 +735,18 @@  discard block
 block discarded – undo
735 735
     return $color;
736 736
 }
737 737
 
738
-function wpinv_hex_lighter( $color, $factor = 30 ) {
739
-    $base  = wpinv_rgb_from_hex( $color );
738
+function wpinv_hex_lighter($color, $factor = 30) {
739
+    $base  = wpinv_rgb_from_hex($color);
740 740
     $color = '#';
741 741
 
742
-    foreach ( $base as $k => $v ) {
742
+    foreach ($base as $k => $v) {
743 743
         $amount      = 255 - $v;
744 744
         $amount      = $amount / 100;
745
-        $amount      = round( $amount * $factor );
745
+        $amount      = round($amount * $factor);
746 746
         $new_decimal = $v + $amount;
747 747
 
748
-        $new_hex_component = dechex( $new_decimal );
749
-        if ( strlen( $new_hex_component ) < 2 ) {
748
+        $new_hex_component = dechex($new_decimal);
749
+        if (strlen($new_hex_component) < 2) {
750 750
             $new_hex_component = "0" . $new_hex_component;
751 751
         }
752 752
         $color .= $new_hex_component;
@@ -755,22 +755,22 @@  discard block
 block discarded – undo
755 755
     return $color;
756 756
 }
757 757
 
758
-function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) {
759
-    $hex = str_replace( '#', '', $color );
758
+function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') {
759
+    $hex = str_replace('#', '', $color);
760 760
 
761
-    $c_r = hexdec( substr( $hex, 0, 2 ) );
762
-    $c_g = hexdec( substr( $hex, 2, 2 ) );
763
-    $c_b = hexdec( substr( $hex, 4, 2 ) );
761
+    $c_r = hexdec(substr($hex, 0, 2));
762
+    $c_g = hexdec(substr($hex, 2, 2));
763
+    $c_b = hexdec(substr($hex, 4, 2));
764 764
 
765
-    $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000;
765
+    $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000;
766 766
 
767 767
     return $brightness > 155 ? $dark : $light;
768 768
 }
769 769
 
770
-function wpinv_format_hex( $hex ) {
771
-    $hex = trim( str_replace( '#', '', $hex ) );
770
+function wpinv_format_hex($hex) {
771
+    $hex = trim(str_replace('#', '', $hex));
772 772
 
773
-    if ( strlen( $hex ) == 3 ) {
773
+    if (strlen($hex) == 3) {
774 774
         $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2];
775 775
     }
776 776
 
@@ -790,12 +790,12 @@  discard block
 block discarded – undo
790 790
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
791 791
  * @return string
792 792
  */
793
-function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) {
794
-    if ( function_exists( 'mb_strimwidth' ) ) {
795
-        return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding );
793
+function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') {
794
+    if (function_exists('mb_strimwidth')) {
795
+        return mb_strimwidth($str, $start, $width, $trimmaker, $encoding);
796 796
     }
797 797
     
798
-    return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker;
798
+    return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker;
799 799
 }
800 800
 
801 801
 /**
@@ -807,28 +807,28 @@  discard block
 block discarded – undo
807 807
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
808 808
  * @return int Returns the number of characters in string.
809 809
  */
810
-function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) {
811
-    if ( function_exists( 'mb_strlen' ) ) {
812
-        return mb_strlen( $str, $encoding );
810
+function wpinv_utf8_strlen($str, $encoding = 'UTF-8') {
811
+    if (function_exists('mb_strlen')) {
812
+        return mb_strlen($str, $encoding);
813 813
     }
814 814
         
815
-    return strlen( $str );
815
+    return strlen($str);
816 816
 }
817 817
 
818
-function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) {
819
-    if ( function_exists( 'mb_strtolower' ) ) {
820
-        return mb_strtolower( $str, $encoding );
818
+function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') {
819
+    if (function_exists('mb_strtolower')) {
820
+        return mb_strtolower($str, $encoding);
821 821
     }
822 822
     
823
-    return strtolower( $str );
823
+    return strtolower($str);
824 824
 }
825 825
 
826
-function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) {
827
-    if ( function_exists( 'mb_strtoupper' ) ) {
828
-        return mb_strtoupper( $str, $encoding );
826
+function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') {
827
+    if (function_exists('mb_strtoupper')) {
828
+        return mb_strtoupper($str, $encoding);
829 829
     }
830 830
     
831
-    return strtoupper( $str );
831
+    return strtoupper($str);
832 832
 }
833 833
 
834 834
 /**
@@ -842,12 +842,12 @@  discard block
 block discarded – undo
842 842
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
843 843
  * @return int Returns the position of the first occurrence of search in the string.
844 844
  */
845
-function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
846
-    if ( function_exists( 'mb_strpos' ) ) {
847
-        return mb_strpos( $str, $find, $offset, $encoding );
845
+function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
846
+    if (function_exists('mb_strpos')) {
847
+        return mb_strpos($str, $find, $offset, $encoding);
848 848
     }
849 849
         
850
-    return strpos( $str, $find, $offset );
850
+    return strpos($str, $find, $offset);
851 851
 }
852 852
 
853 853
 /**
@@ -861,12 +861,12 @@  discard block
 block discarded – undo
861 861
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
862 862
  * @return int Returns the position of the last occurrence of search.
863 863
  */
864
-function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
865
-    if ( function_exists( 'mb_strrpos' ) ) {
866
-        return mb_strrpos( $str, $find, $offset, $encoding );
864
+function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
865
+    if (function_exists('mb_strrpos')) {
866
+        return mb_strrpos($str, $find, $offset, $encoding);
867 867
     }
868 868
         
869
-    return strrpos( $str, $find, $offset );
869
+    return strrpos($str, $find, $offset);
870 870
 }
871 871
 
872 872
 /**
@@ -881,16 +881,16 @@  discard block
 block discarded – undo
881 881
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
882 882
  * @return string
883 883
  */
884
-function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) {
885
-    if ( function_exists( 'mb_substr' ) ) {
886
-        if ( $length === null ) {
887
-            return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding );
884
+function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') {
885
+    if (function_exists('mb_substr')) {
886
+        if ($length === null) {
887
+            return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding);
888 888
         } else {
889
-            return mb_substr( $str, $start, $length, $encoding );
889
+            return mb_substr($str, $start, $length, $encoding);
890 890
         }
891 891
     }
892 892
         
893
-    return substr( $str, $start, $length );
893
+    return substr($str, $start, $length);
894 894
 }
895 895
 
896 896
 /**
@@ -902,48 +902,48 @@  discard block
 block discarded – undo
902 902
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
903 903
  * @return string The width of string.
904 904
  */
905
-function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) {
906
-    if ( function_exists( 'mb_strwidth' ) ) {
907
-        return mb_strwidth( $str, $encoding );
905
+function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') {
906
+    if (function_exists('mb_strwidth')) {
907
+        return mb_strwidth($str, $encoding);
908 908
     }
909 909
     
910
-    return wpinv_utf8_strlen( $str, $encoding );
910
+    return wpinv_utf8_strlen($str, $encoding);
911 911
 }
912 912
 
913
-function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) {
914
-    if ( function_exists( 'mb_strlen' ) ) {
915
-        $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding );
913
+function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') {
914
+    if (function_exists('mb_strlen')) {
915
+        $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding);
916 916
         $str_end = "";
917 917
         
918
-        if ( $lower_str_end ) {
919
-            $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding );
918
+        if ($lower_str_end) {
919
+            $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding);
920 920
         } else {
921
-            $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding );
921
+            $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding);
922 922
         }
923 923
 
924 924
         return $first_letter . $str_end;
925 925
     }
926 926
     
927
-    return ucfirst( $str );
927
+    return ucfirst($str);
928 928
 }
929 929
 
930
-function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) {
931
-    if ( function_exists( 'mb_convert_case' ) ) {
932
-        return mb_convert_case( $str, MB_CASE_TITLE, $encoding );
930
+function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') {
931
+    if (function_exists('mb_convert_case')) {
932
+        return mb_convert_case($str, MB_CASE_TITLE, $encoding);
933 933
     }
934 934
     
935
-    return ucwords( $str );
935
+    return ucwords($str);
936 936
 }
937 937
 
938
-function wpinv_period_in_days( $period, $unit ) {
939
-    $period = absint( $period );
938
+function wpinv_period_in_days($period, $unit) {
939
+    $period = absint($period);
940 940
     
941
-    if ( $period > 0 ) {
942
-        if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) {
941
+    if ($period > 0) {
942
+        if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) {
943 943
             $period = $period * 7;
944
-        } else if ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) {
944
+        } else if (in_array(strtolower($unit), array('m', 'month', 'months'))) {
945 945
             $period = $period * 30;
946
-        } else if ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) {
946
+        } else if (in_array(strtolower($unit), array('y', 'year', 'years'))) {
947 947
             $period = $period * 365;
948 948
         }
949 949
     }
@@ -951,12 +951,12 @@  discard block
 block discarded – undo
951 951
     return $period;
952 952
 }
953 953
 
954
-function wpinv_cal_days_in_month( $calendar, $month, $year ) {
955
-    if ( function_exists( 'cal_days_in_month' ) ) {
956
-        return cal_days_in_month( $calendar, $month, $year );
954
+function wpinv_cal_days_in_month($calendar, $month, $year) {
955
+    if (function_exists('cal_days_in_month')) {
956
+        return cal_days_in_month($calendar, $month, $year);
957 957
     }
958 958
 
959 959
     // Fallback in case the calendar extension is not loaded in PHP
960 960
     // Only supports Gregorian calendar
961
-    return date( 't', mktime( 0, 0, 0, $month, 1, $year ) );
961
+    return date('t', mktime(0, 0, 0, $month, 1, $year));
962 962
 }
Please login to merge, or discard this patch.