@@ -7,132 +7,132 @@ discard block |
||
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' => 'د.إ', |
137 | 137 | 'AFN' => '؋', |
138 | 138 | 'ALL' => 'L', |
@@ -295,209 +295,209 @@ discard block |
||
295 | 295 | 'YER' => '﷼', |
296 | 296 | 'ZAR' => 'R', |
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ʻ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í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ʻ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í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 |
||
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 |
||
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 |
||
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 |
||
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,71 +668,71 @@ discard block |
||
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 | |
709 | 709 | // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF" |
710 | - $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color ); |
|
711 | - if ( empty( $color ) ) { |
|
710 | + $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color); |
|
711 | + if (empty($color)) { |
|
712 | 712 | return NULL; |
713 | 713 | } |
714 | 714 | |
715 | - $color = str_split( $color ); |
|
715 | + $color = str_split($color); |
|
716 | 716 | |
717 | 717 | $rgb = array(); |
718 | - $rgb['R'] = hexdec( $color[0] . $color[1] ); |
|
719 | - $rgb['G'] = hexdec( $color[2] . $color[3] ); |
|
720 | - $rgb['B'] = hexdec( $color[4] . $color[5] ); |
|
718 | + $rgb['R'] = hexdec($color[0] . $color[1]); |
|
719 | + $rgb['G'] = hexdec($color[2] . $color[3]); |
|
720 | + $rgb['B'] = hexdec($color[4] . $color[5]); |
|
721 | 721 | |
722 | 722 | return $rgb; |
723 | 723 | } |
724 | 724 | |
725 | -function wpinv_hex_darker( $color, $factor = 30 ) { |
|
726 | - $base = wpinv_rgb_from_hex( $color ); |
|
725 | +function wpinv_hex_darker($color, $factor = 30) { |
|
726 | + $base = wpinv_rgb_from_hex($color); |
|
727 | 727 | $color = '#'; |
728 | 728 | |
729 | - foreach ( $base as $k => $v ) { |
|
729 | + foreach ($base as $k => $v) { |
|
730 | 730 | $amount = $v / 100; |
731 | - $amount = round( $amount * $factor ); |
|
731 | + $amount = round($amount * $factor); |
|
732 | 732 | $new_decimal = $v - $amount; |
733 | 733 | |
734 | - $new_hex_component = dechex( $new_decimal ); |
|
735 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
734 | + $new_hex_component = dechex($new_decimal); |
|
735 | + if (strlen($new_hex_component) < 2) { |
|
736 | 736 | $new_hex_component = "0" . $new_hex_component; |
737 | 737 | } |
738 | 738 | $color .= $new_hex_component; |
@@ -741,18 +741,18 @@ discard block |
||
741 | 741 | return $color; |
742 | 742 | } |
743 | 743 | |
744 | -function wpinv_hex_lighter( $color, $factor = 30 ) { |
|
745 | - $base = wpinv_rgb_from_hex( $color ); |
|
744 | +function wpinv_hex_lighter($color, $factor = 30) { |
|
745 | + $base = wpinv_rgb_from_hex($color); |
|
746 | 746 | $color = '#'; |
747 | 747 | |
748 | - foreach ( $base as $k => $v ) { |
|
748 | + foreach ($base as $k => $v) { |
|
749 | 749 | $amount = 255 - $v; |
750 | 750 | $amount = $amount / 100; |
751 | - $amount = round( $amount * $factor ); |
|
751 | + $amount = round($amount * $factor); |
|
752 | 752 | $new_decimal = $v + $amount; |
753 | 753 | |
754 | - $new_hex_component = dechex( $new_decimal ); |
|
755 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
754 | + $new_hex_component = dechex($new_decimal); |
|
755 | + if (strlen($new_hex_component) < 2) { |
|
756 | 756 | $new_hex_component = "0" . $new_hex_component; |
757 | 757 | } |
758 | 758 | $color .= $new_hex_component; |
@@ -761,22 +761,22 @@ discard block |
||
761 | 761 | return $color; |
762 | 762 | } |
763 | 763 | |
764 | -function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) { |
|
765 | - $hex = str_replace( '#', '', $color ); |
|
764 | +function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') { |
|
765 | + $hex = str_replace('#', '', $color); |
|
766 | 766 | |
767 | - $c_r = hexdec( substr( $hex, 0, 2 ) ); |
|
768 | - $c_g = hexdec( substr( $hex, 2, 2 ) ); |
|
769 | - $c_b = hexdec( substr( $hex, 4, 2 ) ); |
|
767 | + $c_r = hexdec(substr($hex, 0, 2)); |
|
768 | + $c_g = hexdec(substr($hex, 2, 2)); |
|
769 | + $c_b = hexdec(substr($hex, 4, 2)); |
|
770 | 770 | |
771 | - $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000; |
|
771 | + $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000; |
|
772 | 772 | |
773 | 773 | return $brightness > 155 ? $dark : $light; |
774 | 774 | } |
775 | 775 | |
776 | -function wpinv_format_hex( $hex ) { |
|
777 | - $hex = trim( str_replace( '#', '', $hex ) ); |
|
776 | +function wpinv_format_hex($hex) { |
|
777 | + $hex = trim(str_replace('#', '', $hex)); |
|
778 | 778 | |
779 | - if ( strlen( $hex ) == 3 ) { |
|
779 | + if (strlen($hex) == 3) { |
|
780 | 780 | $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2]; |
781 | 781 | } |
782 | 782 | |
@@ -796,12 +796,12 @@ discard block |
||
796 | 796 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
797 | 797 | * @return string |
798 | 798 | */ |
799 | -function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) { |
|
800 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
801 | - return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding ); |
|
799 | +function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') { |
|
800 | + if (function_exists('mb_strimwidth')) { |
|
801 | + return mb_strimwidth($str, $start, $width, $trimmaker, $encoding); |
|
802 | 802 | } |
803 | 803 | |
804 | - return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker; |
|
804 | + return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker; |
|
805 | 805 | } |
806 | 806 | |
807 | 807 | /** |
@@ -813,28 +813,28 @@ discard block |
||
813 | 813 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
814 | 814 | * @return int Returns the number of characters in string. |
815 | 815 | */ |
816 | -function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) { |
|
817 | - if ( function_exists( 'mb_strlen' ) ) { |
|
818 | - return mb_strlen( $str, $encoding ); |
|
816 | +function wpinv_utf8_strlen($str, $encoding = 'UTF-8') { |
|
817 | + if (function_exists('mb_strlen')) { |
|
818 | + return mb_strlen($str, $encoding); |
|
819 | 819 | } |
820 | 820 | |
821 | - return strlen( $str ); |
|
821 | + return strlen($str); |
|
822 | 822 | } |
823 | 823 | |
824 | -function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) { |
|
825 | - if ( function_exists( 'mb_strtolower' ) ) { |
|
826 | - return mb_strtolower( $str, $encoding ); |
|
824 | +function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') { |
|
825 | + if (function_exists('mb_strtolower')) { |
|
826 | + return mb_strtolower($str, $encoding); |
|
827 | 827 | } |
828 | 828 | |
829 | - return strtolower( $str ); |
|
829 | + return strtolower($str); |
|
830 | 830 | } |
831 | 831 | |
832 | -function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) { |
|
833 | - if ( function_exists( 'mb_strtoupper' ) ) { |
|
834 | - return mb_strtoupper( $str, $encoding ); |
|
832 | +function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') { |
|
833 | + if (function_exists('mb_strtoupper')) { |
|
834 | + return mb_strtoupper($str, $encoding); |
|
835 | 835 | } |
836 | 836 | |
837 | - return strtoupper( $str ); |
|
837 | + return strtoupper($str); |
|
838 | 838 | } |
839 | 839 | |
840 | 840 | /** |
@@ -848,12 +848,12 @@ discard block |
||
848 | 848 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
849 | 849 | * @return int Returns the position of the first occurrence of search in the string. |
850 | 850 | */ |
851 | -function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
852 | - if ( function_exists( 'mb_strpos' ) ) { |
|
853 | - return mb_strpos( $str, $find, $offset, $encoding ); |
|
851 | +function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
852 | + if (function_exists('mb_strpos')) { |
|
853 | + return mb_strpos($str, $find, $offset, $encoding); |
|
854 | 854 | } |
855 | 855 | |
856 | - return strpos( $str, $find, $offset ); |
|
856 | + return strpos($str, $find, $offset); |
|
857 | 857 | } |
858 | 858 | |
859 | 859 | /** |
@@ -867,12 +867,12 @@ discard block |
||
867 | 867 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
868 | 868 | * @return int Returns the position of the last occurrence of search. |
869 | 869 | */ |
870 | -function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
871 | - if ( function_exists( 'mb_strrpos' ) ) { |
|
872 | - return mb_strrpos( $str, $find, $offset, $encoding ); |
|
870 | +function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
871 | + if (function_exists('mb_strrpos')) { |
|
872 | + return mb_strrpos($str, $find, $offset, $encoding); |
|
873 | 873 | } |
874 | 874 | |
875 | - return strrpos( $str, $find, $offset ); |
|
875 | + return strrpos($str, $find, $offset); |
|
876 | 876 | } |
877 | 877 | |
878 | 878 | /** |
@@ -887,16 +887,16 @@ discard block |
||
887 | 887 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
888 | 888 | * @return string |
889 | 889 | */ |
890 | -function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) { |
|
891 | - if ( function_exists( 'mb_substr' ) ) { |
|
892 | - if ( $length === null ) { |
|
893 | - return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
890 | +function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') { |
|
891 | + if (function_exists('mb_substr')) { |
|
892 | + if ($length === null) { |
|
893 | + return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
894 | 894 | } else { |
895 | - return mb_substr( $str, $start, $length, $encoding ); |
|
895 | + return mb_substr($str, $start, $length, $encoding); |
|
896 | 896 | } |
897 | 897 | } |
898 | 898 | |
899 | - return substr( $str, $start, $length ); |
|
899 | + return substr($str, $start, $length); |
|
900 | 900 | } |
901 | 901 | |
902 | 902 | /** |
@@ -908,48 +908,48 @@ discard block |
||
908 | 908 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
909 | 909 | * @return string The width of string. |
910 | 910 | */ |
911 | -function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) { |
|
912 | - if ( function_exists( 'mb_strwidth' ) ) { |
|
913 | - return mb_strwidth( $str, $encoding ); |
|
911 | +function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') { |
|
912 | + if (function_exists('mb_strwidth')) { |
|
913 | + return mb_strwidth($str, $encoding); |
|
914 | 914 | } |
915 | 915 | |
916 | - return wpinv_utf8_strlen( $str, $encoding ); |
|
916 | + return wpinv_utf8_strlen($str, $encoding); |
|
917 | 917 | } |
918 | 918 | |
919 | -function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) { |
|
920 | - if ( function_exists( 'mb_strlen' ) ) { |
|
921 | - $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding ); |
|
919 | +function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') { |
|
920 | + if (function_exists('mb_strlen')) { |
|
921 | + $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding); |
|
922 | 922 | $str_end = ""; |
923 | 923 | |
924 | - if ( $lower_str_end ) { |
|
925 | - $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding ); |
|
924 | + if ($lower_str_end) { |
|
925 | + $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding); |
|
926 | 926 | } else { |
927 | - $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
927 | + $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
928 | 928 | } |
929 | 929 | |
930 | 930 | return $first_letter . $str_end; |
931 | 931 | } |
932 | 932 | |
933 | - return ucfirst( $str ); |
|
933 | + return ucfirst($str); |
|
934 | 934 | } |
935 | 935 | |
936 | -function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) { |
|
937 | - if ( function_exists( 'mb_convert_case' ) ) { |
|
938 | - return mb_convert_case( $str, MB_CASE_TITLE, $encoding ); |
|
936 | +function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') { |
|
937 | + if (function_exists('mb_convert_case')) { |
|
938 | + return mb_convert_case($str, MB_CASE_TITLE, $encoding); |
|
939 | 939 | } |
940 | 940 | |
941 | - return ucwords( $str ); |
|
941 | + return ucwords($str); |
|
942 | 942 | } |
943 | 943 | |
944 | -function wpinv_period_in_days( $period, $unit ) { |
|
945 | - $period = absint( $period ); |
|
944 | +function wpinv_period_in_days($period, $unit) { |
|
945 | + $period = absint($period); |
|
946 | 946 | |
947 | - if ( $period > 0 ) { |
|
948 | - if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) { |
|
947 | + if ($period > 0) { |
|
948 | + if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) { |
|
949 | 949 | $period = $period * 7; |
950 | - } else if ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) { |
|
950 | + } else if (in_array(strtolower($unit), array('m', 'month', 'months'))) { |
|
951 | 951 | $period = $period * 30; |
952 | - } else if ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) { |
|
952 | + } else if (in_array(strtolower($unit), array('y', 'year', 'years'))) { |
|
953 | 953 | $period = $period * 365; |
954 | 954 | } |
955 | 955 | } |
@@ -957,14 +957,14 @@ discard block |
||
957 | 957 | return $period; |
958 | 958 | } |
959 | 959 | |
960 | -function wpinv_cal_days_in_month( $calendar, $month, $year ) { |
|
961 | - if ( function_exists( 'cal_days_in_month' ) ) { |
|
962 | - return cal_days_in_month( $calendar, $month, $year ); |
|
960 | +function wpinv_cal_days_in_month($calendar, $month, $year) { |
|
961 | + if (function_exists('cal_days_in_month')) { |
|
962 | + return cal_days_in_month($calendar, $month, $year); |
|
963 | 963 | } |
964 | 964 | |
965 | 965 | // Fallback in case the calendar extension is not loaded in PHP |
966 | 966 | // Only supports Gregorian calendar |
967 | - return date( 't', mktime( 0, 0, 0, $month, 1, $year ) ); |
|
967 | + return date('t', mktime(0, 0, 0, $month, 1, $year)); |
|
968 | 968 | } |
969 | 969 | |
970 | 970 | /** |
@@ -975,11 +975,11 @@ discard block |
||
975 | 975 | * |
976 | 976 | * @return string |
977 | 977 | */ |
978 | -function wpi_help_tip( $tip, $allow_html = false ) { |
|
979 | - if ( $allow_html ) { |
|
980 | - $tip = wpi_sanitize_tooltip( $tip ); |
|
978 | +function wpi_help_tip($tip, $allow_html = false) { |
|
979 | + if ($allow_html) { |
|
980 | + $tip = wpi_sanitize_tooltip($tip); |
|
981 | 981 | } else { |
982 | - $tip = esc_attr( $tip ); |
|
982 | + $tip = esc_attr($tip); |
|
983 | 983 | } |
984 | 984 | |
985 | 985 | return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
@@ -993,8 +993,8 @@ discard block |
||
993 | 993 | * @param string $var |
994 | 994 | * @return string |
995 | 995 | */ |
996 | -function wpi_sanitize_tooltip( $var ) { |
|
997 | - return htmlspecialchars( wp_kses( html_entity_decode( $var ), array( |
|
996 | +function wpi_sanitize_tooltip($var) { |
|
997 | + return htmlspecialchars(wp_kses(html_entity_decode($var), array( |
|
998 | 998 | 'br' => array(), |
999 | 999 | 'em' => array(), |
1000 | 1000 | 'strong' => array(), |
@@ -1004,7 +1004,7 @@ discard block |
||
1004 | 1004 | 'li' => array(), |
1005 | 1005 | 'ol' => array(), |
1006 | 1006 | 'p' => array(), |
1007 | - ) ) ); |
|
1007 | + ))); |
|
1008 | 1008 | } |
1009 | 1009 | |
1010 | 1010 | /** |
@@ -1014,7 +1014,7 @@ discard block |
||
1014 | 1014 | */ |
1015 | 1015 | function wpinv_get_screen_ids() { |
1016 | 1016 | |
1017 | - $screen_id = sanitize_title( __( 'Invoicing', 'invoicing' ) ); |
|
1017 | + $screen_id = sanitize_title(__('Invoicing', 'invoicing')); |
|
1018 | 1018 | |
1019 | 1019 | $screen_ids = array( |
1020 | 1020 | 'toplevel_page_' . $screen_id, |
@@ -1032,7 +1032,7 @@ discard block |
||
1032 | 1032 | 'invoicing_page_wpi-addons', |
1033 | 1033 | ); |
1034 | 1034 | |
1035 | - return apply_filters( 'wpinv_screen_ids', $screen_ids ); |
|
1035 | + return apply_filters('wpinv_screen_ids', $screen_ids); |
|
1036 | 1036 | } |
1037 | 1037 | |
1038 | 1038 | /** |
@@ -1043,9 +1043,9 @@ discard block |
||
1043 | 1043 | * @param array|string $list List of values. |
1044 | 1044 | * @return array Sanitized array of values. |
1045 | 1045 | */ |
1046 | -function wpinv_parse_list( $list ) { |
|
1047 | - if ( ! is_array( $list ) ) { |
|
1048 | - return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
1046 | +function wpinv_parse_list($list) { |
|
1047 | + if (!is_array($list)) { |
|
1048 | + return preg_split('/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY); |
|
1049 | 1049 | } |
1050 | 1050 | |
1051 | 1051 | return $list; |
@@ -1059,16 +1059,16 @@ discard block |
||
1059 | 1059 | * @param string $key Type of data to fetch. |
1060 | 1060 | * @return mixed Fetched data. |
1061 | 1061 | */ |
1062 | -function wpinv_get_data( $key ) { |
|
1062 | +function wpinv_get_data($key) { |
|
1063 | 1063 | |
1064 | 1064 | // Try fetching it from the cache. |
1065 | - $data = wp_cache_get( "wpinv-$key", 'wpinv' ); |
|
1066 | - if( $data ) { |
|
1065 | + $data = wp_cache_get("wpinv-$key", 'wpinv'); |
|
1066 | + if ($data) { |
|
1067 | 1067 | return $data; |
1068 | 1068 | } |
1069 | 1069 | |
1070 | - $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" ); |
|
1071 | - wp_cache_set( "wpinv-$key", $data, 'wpinv' ); |
|
1070 | + $data = apply_filters("wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php"); |
|
1071 | + wp_cache_set("wpinv-$key", $data, 'wpinv'); |
|
1072 | 1072 | |
1073 | 1073 | return $data; |
1074 | 1074 | } |
@@ -1082,10 +1082,10 @@ discard block |
||
1082 | 1082 | * @param bool $first_empty Whether or not the first item in the list should be empty |
1083 | 1083 | * @return mixed Fetched data. |
1084 | 1084 | */ |
1085 | -function wpinv_maybe_add_empty_option( $options, $first_empty ) { |
|
1085 | +function wpinv_maybe_add_empty_option($options, $first_empty) { |
|
1086 | 1086 | |
1087 | - if ( ! empty( $options ) && $first_empty ) { |
|
1088 | - return array_merge( array( '' => '' ), $options ); |
|
1087 | + if (!empty($options) && $first_empty) { |
|
1088 | + return array_merge(array('' => ''), $options); |
|
1089 | 1089 | } |
1090 | 1090 | return $options; |
1091 | 1091 | |
@@ -1097,19 +1097,19 @@ discard block |
||
1097 | 1097 | * @param mixed $var Data to sanitize. |
1098 | 1098 | * @return string|array |
1099 | 1099 | */ |
1100 | -function wpinv_clean( $var ) { |
|
1100 | +function wpinv_clean($var) { |
|
1101 | 1101 | |
1102 | - if ( is_array( $var ) ) { |
|
1103 | - return array_map( 'wpinv_clean', $var ); |
|
1102 | + if (is_array($var)) { |
|
1103 | + return array_map('wpinv_clean', $var); |
|
1104 | 1104 | } |
1105 | 1105 | |
1106 | - if ( is_object( $var ) ) { |
|
1107 | - $object_vars = get_object_vars( $var ); |
|
1108 | - foreach ( $object_vars as $property_name => $property_value ) { |
|
1109 | - $var->$property_name = wpinv_clean( $property_value ); |
|
1106 | + if (is_object($var)) { |
|
1107 | + $object_vars = get_object_vars($var); |
|
1108 | + foreach ($object_vars as $property_name => $property_value) { |
|
1109 | + $var->$property_name = wpinv_clean($property_value); |
|
1110 | 1110 | } |
1111 | 1111 | return $var; |
1112 | 1112 | } |
1113 | 1113 | |
1114 | - return is_string( $var ) ? sanitize_text_field( $var ) : $var; |
|
1114 | + return is_string($var) ? sanitize_text_field($var) : $var; |
|
1115 | 1115 | } |
1116 | 1116 | \ No newline at end of file |