@@ -700,7 +700,7 @@ discard block |
||
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 | 706 | function wpinv_rgb_from_hex( $color ) { |
@@ -1038,11 +1038,11 @@ discard block |
||
1038 | 1038 | * @return array Sanitized array of values. |
1039 | 1039 | */ |
1040 | 1040 | function wpinv_parse_list( $list ) { |
1041 | - if ( ! is_array( $list ) ) { |
|
1042 | - return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
1043 | - } |
|
1041 | + if ( ! is_array( $list ) ) { |
|
1042 | + return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
1043 | + } |
|
1044 | 1044 | |
1045 | - return $list; |
|
1045 | + return $list; |
|
1046 | 1046 | } |
1047 | 1047 | |
1048 | 1048 | /** |
@@ -1062,9 +1062,9 @@ discard block |
||
1062 | 1062 | } |
1063 | 1063 | |
1064 | 1064 | $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" ); |
1065 | - wp_cache_set( "wpinv-$key", $data, 'wpinv' ); |
|
1065 | + wp_cache_set( "wpinv-$key", $data, 'wpinv' ); |
|
1066 | 1066 | |
1067 | - return $data; |
|
1067 | + return $data; |
|
1068 | 1068 | } |
1069 | 1069 | |
1070 | 1070 | /** |
@@ -1093,17 +1093,17 @@ discard block |
||
1093 | 1093 | */ |
1094 | 1094 | function wpinv_clean( $var ) { |
1095 | 1095 | |
1096 | - if ( is_array( $var ) ) { |
|
1097 | - return array_map( 'wpinv_clean', $var ); |
|
1096 | + if ( is_array( $var ) ) { |
|
1097 | + return array_map( 'wpinv_clean', $var ); |
|
1098 | 1098 | } |
1099 | 1099 | |
1100 | 1100 | if ( is_object( $var ) ) { |
1101 | - $object_vars = get_object_vars( $var ); |
|
1102 | - foreach ( $object_vars as $property_name => $property_value ) { |
|
1103 | - $var->$property_name = wpinv_clean( $property_value ); |
|
1101 | + $object_vars = get_object_vars( $var ); |
|
1102 | + foreach ( $object_vars as $property_name => $property_value ) { |
|
1103 | + $var->$property_name = wpinv_clean( $property_value ); |
|
1104 | 1104 | } |
1105 | 1105 | return $var; |
1106 | - } |
|
1106 | + } |
|
1107 | 1107 | |
1108 | 1108 | return is_string( $var ) ? sanitize_text_field( $var ) : $var; |
1109 | 1109 | } |
1110 | 1110 | \ No newline at end of file |
@@ -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 |
@@ -6,32 +6,32 @@ |
||
6 | 6 | |
7 | 7 | class ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5 |
8 | 8 | { |
9 | - public static $files = array ( |
|
9 | + public static $files = array( |
|
10 | 10 | '24583d3588ebda5228dd453cfaa070da' => __DIR__ . '/..' . '/ayecode/wp-font-awesome-settings/wp-font-awesome-settings.php', |
11 | 11 | ); |
12 | 12 | |
13 | - public static $prefixLengthsPsr4 = array ( |
|
13 | + public static $prefixLengthsPsr4 = array( |
|
14 | 14 | 'C' => |
15 | - array ( |
|
15 | + array( |
|
16 | 16 | 'Composer\\Installers\\' => 20, |
17 | 17 | ), |
18 | 18 | ); |
19 | 19 | |
20 | - public static $prefixDirsPsr4 = array ( |
|
20 | + public static $prefixDirsPsr4 = array( |
|
21 | 21 | 'Composer\\Installers\\' => |
22 | - array ( |
|
22 | + array( |
|
23 | 23 | 0 => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers', |
24 | 24 | ), |
25 | 25 | ); |
26 | 26 | |
27 | - public static $classMap = array ( |
|
27 | + public static $classMap = array( |
|
28 | 28 | 'AyeCode_Connect_Helper' => __DIR__ . '/..' . '/ayecode/ayecode-connect-helper/ayecode-connect-helper.php', |
29 | 29 | 'WP_Super_Duper' => __DIR__ . '/..' . '/ayecode/wp-super-duper/wp-super-duper.php', |
30 | 30 | ); |
31 | 31 | |
32 | 32 | public static function getInitializer(ClassLoader $loader) |
33 | 33 | { |
34 | - return \Closure::bind(function () use ($loader) { |
|
34 | + return \Closure::bind(function() use ($loader) { |
|
35 | 35 | $loader->prefixLengthsPsr4 = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$prefixLengthsPsr4; |
36 | 36 | $loader->prefixDirsPsr4 = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$prefixDirsPsr4; |
37 | 37 | $loader->classMap = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$classMap; |
@@ -1,271 +1,271 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | if ( ! defined( 'ABSPATH' ) ) { |
4 | - exit; |
|
4 | + exit; |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | if ( ! class_exists( "AyeCode_Connect_Helper" ) ) { |
8 | - /** |
|
9 | - * Allow the quick setup and connection of our AyeCode Connect plugin. |
|
10 | - * |
|
11 | - * Class AyeCode_Connect_Helper |
|
12 | - */ |
|
13 | - class AyeCode_Connect_Helper { |
|
14 | - |
|
15 | - // Hold the version number |
|
16 | - var $version = "1.0.3"; |
|
17 | - |
|
18 | - // Hold the default strings. |
|
19 | - var $strings = array(); |
|
20 | - |
|
21 | - // Hold the default pages. |
|
22 | - var $pages = array(); |
|
23 | - |
|
24 | - /** |
|
25 | - * The constructor. |
|
26 | - * |
|
27 | - * AyeCode_Connect_Helper constructor. |
|
28 | - * |
|
29 | - * @param array $strings |
|
30 | - * @param array $pages |
|
31 | - */ |
|
32 | - public function __construct( $strings = array(), $pages = array() ) { |
|
33 | - |
|
34 | - // Only fire if not localhost and the current user has the right permissions. |
|
35 | - if ( ! $this->is_localhost() && current_user_can( 'manage_options' ) ) { |
|
36 | - |
|
37 | - |
|
38 | - // set default strings |
|
39 | - $default_strings = array( |
|
40 | - 'connect_title' => __( "Thanks for choosing an AyeCode Product!" ), |
|
41 | - 'connect_external' => __( "Please confirm you wish to connect your site?" ), |
|
42 | - 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s" ), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>" ), |
|
43 | - 'connect_button' => __( "Connect Site" ), |
|
44 | - 'connecting_button' => __( "Connecting..." ), |
|
45 | - 'error_localhost' => __( "This service will only work with a live domain, not a localhost." ), |
|
46 | - 'error' => __( "Something went wrong, please refresh and try again." ), |
|
47 | - ); |
|
48 | - $this->strings = array_merge( $default_strings, $strings ); |
|
49 | - |
|
50 | - |
|
51 | - // set default pages |
|
52 | - $default_pages = array(); |
|
53 | - $this->pages = array_merge( $default_pages, $pages ); |
|
54 | - |
|
55 | - // maybe show connect site notice |
|
56 | - add_action( 'admin_notices', array( $this, 'ayecode_connect_install_notice' ) ); |
|
57 | - |
|
58 | - // add ajax action if not already added |
|
59 | - if ( ! has_action( 'wp_ajax_ayecode_connect_helper' ) ) { |
|
60 | - add_action( 'wp_ajax_ayecode_connect_helper', array( $this, 'ayecode_connect_install' ) ); |
|
61 | - } |
|
62 | - } |
|
63 | - |
|
64 | - // add ajax action if not already added |
|
65 | - if ( ! has_action( 'wp_ajax_nopriv_ayecode_connect_helper_installed' ) ) { |
|
66 | - add_action( 'wp_ajax_nopriv_ayecode_connect_helper_installed', array( $this, 'ayecode_connect_helper_installed' ) ); |
|
67 | - } |
|
68 | - |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * Give a way to check we can connect via a external redirect. |
|
73 | - */ |
|
74 | - public function ayecode_connect_helper_installed(){ |
|
75 | - $active = array( |
|
76 | - 'gd' => defined('GEODIRECTORY_VERSION') && version_compare(GEODIRECTORY_VERSION,'2.0.0.79','>') ? 1 : 0, |
|
77 | - 'uwp' => defined('USERSWP_VERSION') && version_compare(USERSWP_VERSION,'1.2.1.5','>') ? 1 : 0, |
|
78 | - 'wpi' => defined('WPINV_VERSION') && version_compare(WPINV_VERSION,'1.0.14','>') ? 1 : 0, |
|
79 | - ); |
|
80 | - wp_send_json_success( $active ); |
|
81 | - wp_die(); |
|
82 | - } |
|
83 | - |
|
84 | - /** |
|
85 | - * Get slug from path |
|
86 | - * |
|
87 | - * @param string $key |
|
88 | - * |
|
89 | - * @return string |
|
90 | - */ |
|
91 | - private function format_plugin_slug( $key ) { |
|
92 | - $slug = explode( '/', $key ); |
|
93 | - $slug = explode( '.', end( $slug ) ); |
|
94 | - |
|
95 | - return $slug[0]; |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * Install and activate the AyeCode Connect Plugin |
|
100 | - */ |
|
101 | - public function ayecode_connect_install() { |
|
102 | - |
|
103 | - // bail if localhost |
|
104 | - if ( $this->is_localhost() ) { |
|
105 | - wp_send_json_error( $this->strings['error_localhost'] ); |
|
106 | - } |
|
107 | - |
|
108 | - // Explicitly clear the event. |
|
109 | - wp_clear_scheduled_hook( 'geodir_plugin_background_installer', func_get_args() ); |
|
110 | - |
|
111 | - $success = true; |
|
112 | - $plugin_slug = "ayecode-connect"; |
|
113 | - if ( ! empty( $plugin_slug ) ) { |
|
114 | - require_once( ABSPATH . 'wp-admin/includes/file.php' ); |
|
115 | - require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); |
|
116 | - require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); |
|
117 | - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
118 | - |
|
119 | - WP_Filesystem(); |
|
120 | - |
|
121 | - $skin = new Automatic_Upgrader_Skin; |
|
122 | - $upgrader = new WP_Upgrader( $skin ); |
|
123 | - $installed_plugins = array_map( array( $this, 'format_plugin_slug' ), array_keys( get_plugins() ) ); |
|
124 | - $plugin_slug = $plugin_slug; |
|
125 | - $plugin = $plugin_slug . '/' . $plugin_slug . '.php'; |
|
126 | - $installed = false; |
|
127 | - $activate = false; |
|
128 | - |
|
129 | - // See if the plugin is installed already |
|
130 | - if ( in_array( $plugin_slug, $installed_plugins ) ) { |
|
131 | - $installed = true; |
|
132 | - $activate = ! is_plugin_active( $plugin ); |
|
133 | - } |
|
134 | - |
|
135 | - // Install this thing! |
|
136 | - if ( ! $installed ) { |
|
137 | - |
|
138 | - // Suppress feedback |
|
139 | - ob_start(); |
|
140 | - |
|
141 | - try { |
|
142 | - $plugin_information = plugins_api( 'plugin_information', array( |
|
143 | - 'slug' => $plugin_slug, |
|
144 | - 'fields' => array( |
|
145 | - 'short_description' => false, |
|
146 | - 'sections' => false, |
|
147 | - 'requires' => false, |
|
148 | - 'rating' => false, |
|
149 | - 'ratings' => false, |
|
150 | - 'downloaded' => false, |
|
151 | - 'last_updated' => false, |
|
152 | - 'added' => false, |
|
153 | - 'tags' => false, |
|
154 | - 'homepage' => false, |
|
155 | - 'donate_link' => false, |
|
156 | - 'author_profile' => false, |
|
157 | - 'author' => false, |
|
158 | - ), |
|
159 | - ) ); |
|
160 | - |
|
161 | - if ( is_wp_error( $plugin_information ) ) { |
|
162 | - throw new Exception( $plugin_information->get_error_message() ); |
|
163 | - } |
|
164 | - |
|
165 | - $package = $plugin_information->download_link; |
|
166 | - $download = $upgrader->download_package( $package ); |
|
167 | - |
|
168 | - if ( is_wp_error( $download ) ) { |
|
169 | - throw new Exception( $download->get_error_message() ); |
|
170 | - } |
|
171 | - |
|
172 | - $working_dir = $upgrader->unpack_package( $download, true ); |
|
173 | - |
|
174 | - if ( is_wp_error( $working_dir ) ) { |
|
175 | - throw new Exception( $working_dir->get_error_message() ); |
|
176 | - } |
|
177 | - |
|
178 | - $result = $upgrader->install_package( array( |
|
179 | - 'source' => $working_dir, |
|
180 | - 'destination' => WP_PLUGIN_DIR, |
|
181 | - 'clear_destination' => false, |
|
182 | - 'abort_if_destination_exists' => false, |
|
183 | - 'clear_working' => true, |
|
184 | - 'hook_extra' => array( |
|
185 | - 'type' => 'plugin', |
|
186 | - 'action' => 'install', |
|
187 | - ), |
|
188 | - ) ); |
|
189 | - |
|
190 | - if ( is_wp_error( $result ) ) { |
|
191 | - throw new Exception( $result->get_error_message() ); |
|
192 | - } |
|
193 | - |
|
194 | - $activate = true; |
|
195 | - |
|
196 | - } catch ( Exception $e ) { |
|
197 | - $success = false; |
|
198 | - } |
|
199 | - |
|
200 | - // Discard feedback |
|
201 | - ob_end_clean(); |
|
202 | - } |
|
203 | - |
|
204 | - wp_clean_plugins_cache(); |
|
205 | - |
|
206 | - // Activate this thing |
|
207 | - if ( $activate ) { |
|
208 | - try { |
|
209 | - $result = activate_plugin( $plugin ); |
|
210 | - |
|
211 | - if ( is_wp_error( $result ) ) { |
|
212 | - $success = false; |
|
213 | - } else { |
|
214 | - $success = true; |
|
215 | - } |
|
216 | - } catch ( Exception $e ) { |
|
217 | - $success = false; |
|
218 | - } |
|
219 | - } |
|
220 | - } |
|
221 | - |
|
222 | - if ( $success && function_exists( 'ayecode_connect_args' ) ) { |
|
223 | - ayecode_connect();// init |
|
224 | - $args = ayecode_connect_args(); |
|
225 | - $client = new AyeCode_Connect( $args ); |
|
226 | - $redirect_to = ! empty( $_POST['redirect_to'] ) ? esc_url_raw( $_POST['redirect_to'] ) : ''; |
|
227 | - $redirect = $client->build_connect_url( $redirect_to ); |
|
228 | - wp_send_json_success( array( 'connect_url' => $redirect ) ); |
|
229 | - } else { |
|
230 | - wp_send_json_error( $this->strings['error_localhost'] ); |
|
231 | - } |
|
232 | - wp_die(); |
|
233 | - } |
|
234 | - |
|
235 | - /** |
|
236 | - * Check if maybe localhost. |
|
237 | - * |
|
238 | - * @return bool |
|
239 | - */ |
|
240 | - public function is_localhost() { |
|
241 | - $localhost = false; |
|
242 | - |
|
243 | - $host = isset( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : ''; |
|
244 | - $localhost_domains = array( |
|
245 | - 'localhost', |
|
246 | - 'localhost.localdomain', |
|
247 | - '127.0.0.1', |
|
248 | - '::1' |
|
249 | - ); |
|
250 | - |
|
251 | - if ( in_array( $host, $localhost_domains ) ) { |
|
252 | - $localhost = true; |
|
253 | - } |
|
254 | - |
|
255 | - return $localhost; |
|
256 | - } |
|
257 | - |
|
258 | - /** |
|
259 | - * Show notice to connect site. |
|
260 | - */ |
|
261 | - public function ayecode_connect_install_notice() { |
|
262 | - if ( $this->maybe_show() ) { |
|
263 | - $connect_title_string = $this->strings['connect_title']; |
|
264 | - $connect_external_string = $this->strings['connect_external']; |
|
265 | - $connect_string = $this->strings['connect']; |
|
266 | - $connect_button_string = $this->strings['connect_button']; |
|
267 | - $connecting_button_string = $this->strings['connecting_button']; |
|
268 | - ?> |
|
8 | + /** |
|
9 | + * Allow the quick setup and connection of our AyeCode Connect plugin. |
|
10 | + * |
|
11 | + * Class AyeCode_Connect_Helper |
|
12 | + */ |
|
13 | + class AyeCode_Connect_Helper { |
|
14 | + |
|
15 | + // Hold the version number |
|
16 | + var $version = "1.0.3"; |
|
17 | + |
|
18 | + // Hold the default strings. |
|
19 | + var $strings = array(); |
|
20 | + |
|
21 | + // Hold the default pages. |
|
22 | + var $pages = array(); |
|
23 | + |
|
24 | + /** |
|
25 | + * The constructor. |
|
26 | + * |
|
27 | + * AyeCode_Connect_Helper constructor. |
|
28 | + * |
|
29 | + * @param array $strings |
|
30 | + * @param array $pages |
|
31 | + */ |
|
32 | + public function __construct( $strings = array(), $pages = array() ) { |
|
33 | + |
|
34 | + // Only fire if not localhost and the current user has the right permissions. |
|
35 | + if ( ! $this->is_localhost() && current_user_can( 'manage_options' ) ) { |
|
36 | + |
|
37 | + |
|
38 | + // set default strings |
|
39 | + $default_strings = array( |
|
40 | + 'connect_title' => __( "Thanks for choosing an AyeCode Product!" ), |
|
41 | + 'connect_external' => __( "Please confirm you wish to connect your site?" ), |
|
42 | + 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s" ), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>" ), |
|
43 | + 'connect_button' => __( "Connect Site" ), |
|
44 | + 'connecting_button' => __( "Connecting..." ), |
|
45 | + 'error_localhost' => __( "This service will only work with a live domain, not a localhost." ), |
|
46 | + 'error' => __( "Something went wrong, please refresh and try again." ), |
|
47 | + ); |
|
48 | + $this->strings = array_merge( $default_strings, $strings ); |
|
49 | + |
|
50 | + |
|
51 | + // set default pages |
|
52 | + $default_pages = array(); |
|
53 | + $this->pages = array_merge( $default_pages, $pages ); |
|
54 | + |
|
55 | + // maybe show connect site notice |
|
56 | + add_action( 'admin_notices', array( $this, 'ayecode_connect_install_notice' ) ); |
|
57 | + |
|
58 | + // add ajax action if not already added |
|
59 | + if ( ! has_action( 'wp_ajax_ayecode_connect_helper' ) ) { |
|
60 | + add_action( 'wp_ajax_ayecode_connect_helper', array( $this, 'ayecode_connect_install' ) ); |
|
61 | + } |
|
62 | + } |
|
63 | + |
|
64 | + // add ajax action if not already added |
|
65 | + if ( ! has_action( 'wp_ajax_nopriv_ayecode_connect_helper_installed' ) ) { |
|
66 | + add_action( 'wp_ajax_nopriv_ayecode_connect_helper_installed', array( $this, 'ayecode_connect_helper_installed' ) ); |
|
67 | + } |
|
68 | + |
|
69 | + } |
|
70 | + |
|
71 | + /** |
|
72 | + * Give a way to check we can connect via a external redirect. |
|
73 | + */ |
|
74 | + public function ayecode_connect_helper_installed(){ |
|
75 | + $active = array( |
|
76 | + 'gd' => defined('GEODIRECTORY_VERSION') && version_compare(GEODIRECTORY_VERSION,'2.0.0.79','>') ? 1 : 0, |
|
77 | + 'uwp' => defined('USERSWP_VERSION') && version_compare(USERSWP_VERSION,'1.2.1.5','>') ? 1 : 0, |
|
78 | + 'wpi' => defined('WPINV_VERSION') && version_compare(WPINV_VERSION,'1.0.14','>') ? 1 : 0, |
|
79 | + ); |
|
80 | + wp_send_json_success( $active ); |
|
81 | + wp_die(); |
|
82 | + } |
|
83 | + |
|
84 | + /** |
|
85 | + * Get slug from path |
|
86 | + * |
|
87 | + * @param string $key |
|
88 | + * |
|
89 | + * @return string |
|
90 | + */ |
|
91 | + private function format_plugin_slug( $key ) { |
|
92 | + $slug = explode( '/', $key ); |
|
93 | + $slug = explode( '.', end( $slug ) ); |
|
94 | + |
|
95 | + return $slug[0]; |
|
96 | + } |
|
97 | + |
|
98 | + /** |
|
99 | + * Install and activate the AyeCode Connect Plugin |
|
100 | + */ |
|
101 | + public function ayecode_connect_install() { |
|
102 | + |
|
103 | + // bail if localhost |
|
104 | + if ( $this->is_localhost() ) { |
|
105 | + wp_send_json_error( $this->strings['error_localhost'] ); |
|
106 | + } |
|
107 | + |
|
108 | + // Explicitly clear the event. |
|
109 | + wp_clear_scheduled_hook( 'geodir_plugin_background_installer', func_get_args() ); |
|
110 | + |
|
111 | + $success = true; |
|
112 | + $plugin_slug = "ayecode-connect"; |
|
113 | + if ( ! empty( $plugin_slug ) ) { |
|
114 | + require_once( ABSPATH . 'wp-admin/includes/file.php' ); |
|
115 | + require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); |
|
116 | + require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); |
|
117 | + require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
118 | + |
|
119 | + WP_Filesystem(); |
|
120 | + |
|
121 | + $skin = new Automatic_Upgrader_Skin; |
|
122 | + $upgrader = new WP_Upgrader( $skin ); |
|
123 | + $installed_plugins = array_map( array( $this, 'format_plugin_slug' ), array_keys( get_plugins() ) ); |
|
124 | + $plugin_slug = $plugin_slug; |
|
125 | + $plugin = $plugin_slug . '/' . $plugin_slug . '.php'; |
|
126 | + $installed = false; |
|
127 | + $activate = false; |
|
128 | + |
|
129 | + // See if the plugin is installed already |
|
130 | + if ( in_array( $plugin_slug, $installed_plugins ) ) { |
|
131 | + $installed = true; |
|
132 | + $activate = ! is_plugin_active( $plugin ); |
|
133 | + } |
|
134 | + |
|
135 | + // Install this thing! |
|
136 | + if ( ! $installed ) { |
|
137 | + |
|
138 | + // Suppress feedback |
|
139 | + ob_start(); |
|
140 | + |
|
141 | + try { |
|
142 | + $plugin_information = plugins_api( 'plugin_information', array( |
|
143 | + 'slug' => $plugin_slug, |
|
144 | + 'fields' => array( |
|
145 | + 'short_description' => false, |
|
146 | + 'sections' => false, |
|
147 | + 'requires' => false, |
|
148 | + 'rating' => false, |
|
149 | + 'ratings' => false, |
|
150 | + 'downloaded' => false, |
|
151 | + 'last_updated' => false, |
|
152 | + 'added' => false, |
|
153 | + 'tags' => false, |
|
154 | + 'homepage' => false, |
|
155 | + 'donate_link' => false, |
|
156 | + 'author_profile' => false, |
|
157 | + 'author' => false, |
|
158 | + ), |
|
159 | + ) ); |
|
160 | + |
|
161 | + if ( is_wp_error( $plugin_information ) ) { |
|
162 | + throw new Exception( $plugin_information->get_error_message() ); |
|
163 | + } |
|
164 | + |
|
165 | + $package = $plugin_information->download_link; |
|
166 | + $download = $upgrader->download_package( $package ); |
|
167 | + |
|
168 | + if ( is_wp_error( $download ) ) { |
|
169 | + throw new Exception( $download->get_error_message() ); |
|
170 | + } |
|
171 | + |
|
172 | + $working_dir = $upgrader->unpack_package( $download, true ); |
|
173 | + |
|
174 | + if ( is_wp_error( $working_dir ) ) { |
|
175 | + throw new Exception( $working_dir->get_error_message() ); |
|
176 | + } |
|
177 | + |
|
178 | + $result = $upgrader->install_package( array( |
|
179 | + 'source' => $working_dir, |
|
180 | + 'destination' => WP_PLUGIN_DIR, |
|
181 | + 'clear_destination' => false, |
|
182 | + 'abort_if_destination_exists' => false, |
|
183 | + 'clear_working' => true, |
|
184 | + 'hook_extra' => array( |
|
185 | + 'type' => 'plugin', |
|
186 | + 'action' => 'install', |
|
187 | + ), |
|
188 | + ) ); |
|
189 | + |
|
190 | + if ( is_wp_error( $result ) ) { |
|
191 | + throw new Exception( $result->get_error_message() ); |
|
192 | + } |
|
193 | + |
|
194 | + $activate = true; |
|
195 | + |
|
196 | + } catch ( Exception $e ) { |
|
197 | + $success = false; |
|
198 | + } |
|
199 | + |
|
200 | + // Discard feedback |
|
201 | + ob_end_clean(); |
|
202 | + } |
|
203 | + |
|
204 | + wp_clean_plugins_cache(); |
|
205 | + |
|
206 | + // Activate this thing |
|
207 | + if ( $activate ) { |
|
208 | + try { |
|
209 | + $result = activate_plugin( $plugin ); |
|
210 | + |
|
211 | + if ( is_wp_error( $result ) ) { |
|
212 | + $success = false; |
|
213 | + } else { |
|
214 | + $success = true; |
|
215 | + } |
|
216 | + } catch ( Exception $e ) { |
|
217 | + $success = false; |
|
218 | + } |
|
219 | + } |
|
220 | + } |
|
221 | + |
|
222 | + if ( $success && function_exists( 'ayecode_connect_args' ) ) { |
|
223 | + ayecode_connect();// init |
|
224 | + $args = ayecode_connect_args(); |
|
225 | + $client = new AyeCode_Connect( $args ); |
|
226 | + $redirect_to = ! empty( $_POST['redirect_to'] ) ? esc_url_raw( $_POST['redirect_to'] ) : ''; |
|
227 | + $redirect = $client->build_connect_url( $redirect_to ); |
|
228 | + wp_send_json_success( array( 'connect_url' => $redirect ) ); |
|
229 | + } else { |
|
230 | + wp_send_json_error( $this->strings['error_localhost'] ); |
|
231 | + } |
|
232 | + wp_die(); |
|
233 | + } |
|
234 | + |
|
235 | + /** |
|
236 | + * Check if maybe localhost. |
|
237 | + * |
|
238 | + * @return bool |
|
239 | + */ |
|
240 | + public function is_localhost() { |
|
241 | + $localhost = false; |
|
242 | + |
|
243 | + $host = isset( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : ''; |
|
244 | + $localhost_domains = array( |
|
245 | + 'localhost', |
|
246 | + 'localhost.localdomain', |
|
247 | + '127.0.0.1', |
|
248 | + '::1' |
|
249 | + ); |
|
250 | + |
|
251 | + if ( in_array( $host, $localhost_domains ) ) { |
|
252 | + $localhost = true; |
|
253 | + } |
|
254 | + |
|
255 | + return $localhost; |
|
256 | + } |
|
257 | + |
|
258 | + /** |
|
259 | + * Show notice to connect site. |
|
260 | + */ |
|
261 | + public function ayecode_connect_install_notice() { |
|
262 | + if ( $this->maybe_show() ) { |
|
263 | + $connect_title_string = $this->strings['connect_title']; |
|
264 | + $connect_external_string = $this->strings['connect_external']; |
|
265 | + $connect_string = $this->strings['connect']; |
|
266 | + $connect_button_string = $this->strings['connect_button']; |
|
267 | + $connecting_button_string = $this->strings['connecting_button']; |
|
268 | + ?> |
|
269 | 269 | <div class="notice notice-info acch-notice"> |
270 | 270 | <span class="acch-float-left"> |
271 | 271 | <svg width="61px" height="61px" viewBox="0 0 61 61" version="1.1" |
@@ -304,8 +304,8 @@ discard block |
||
304 | 304 | <h3 class="acch-title"><?php echo esc_attr( $connect_title_string ); ?></h3> |
305 | 305 | <p> |
306 | 306 | <?php |
307 | - echo $connect_string; |
|
308 | - ?> |
|
307 | + echo $connect_string; |
|
308 | + ?> |
|
309 | 309 | </p> |
310 | 310 | </span> |
311 | 311 | |
@@ -318,9 +318,9 @@ discard block |
||
318 | 318 | </div> |
319 | 319 | |
320 | 320 | <?php |
321 | - // only include the popup HTML if needed. |
|
322 | - if ( ! empty( $_REQUEST['external-connect-request'] ) ) { |
|
323 | - ?> |
|
321 | + // only include the popup HTML if needed. |
|
322 | + if ( ! empty( $_REQUEST['external-connect-request'] ) ) { |
|
323 | + ?> |
|
324 | 324 | <div id="ayecode-connect-helper-external-confirm" style="display:none;"> |
325 | 325 | <div class="noticex notice-info acch-notice" style="border: none;"> |
326 | 326 | <span class="acch-float-left"> |
@@ -369,23 +369,23 @@ discard block |
||
369 | 369 | </div> |
370 | 370 | </div> |
371 | 371 | <?php |
372 | - } |
|
373 | - |
|
374 | - // add required scripts |
|
375 | - $this->script(); |
|
376 | - } |
|
377 | - } |
|
378 | - |
|
379 | - /** |
|
380 | - * Get the JS Script. |
|
381 | - */ |
|
382 | - public function script() { |
|
383 | - |
|
384 | - // add thickbox if external request is requested |
|
385 | - if ( ! empty( $_REQUEST['external-connect-request'] ) ) { |
|
386 | - add_thickbox(); |
|
387 | - } |
|
388 | - ?> |
|
372 | + } |
|
373 | + |
|
374 | + // add required scripts |
|
375 | + $this->script(); |
|
376 | + } |
|
377 | + } |
|
378 | + |
|
379 | + /** |
|
380 | + * Get the JS Script. |
|
381 | + */ |
|
382 | + public function script() { |
|
383 | + |
|
384 | + // add thickbox if external request is requested |
|
385 | + if ( ! empty( $_REQUEST['external-connect-request'] ) ) { |
|
386 | + add_thickbox(); |
|
387 | + } |
|
388 | + ?> |
|
389 | 389 | <style> |
390 | 390 | .acch-title { |
391 | 391 | margin: 0; |
@@ -454,43 +454,43 @@ discard block |
||
454 | 454 | |
455 | 455 | |
456 | 456 | <?php |
457 | - // add thickbox if external request is requested |
|
458 | - if(! empty( $_REQUEST['external-connect-request'] )) { |
|
459 | - ?> |
|
457 | + // add thickbox if external request is requested |
|
458 | + if(! empty( $_REQUEST['external-connect-request'] )) { |
|
459 | + ?> |
|
460 | 460 | jQuery(function () { |
461 | 461 | setTimeout(function () { |
462 | 462 | tb_show("AyeCode Connect", "?TB_inline?width=300&height=80&inlineId=ayecode-connect-helper-external-confirm"); |
463 | 463 | }, 200); |
464 | 464 | }); |
465 | 465 | <?php |
466 | - } |
|
467 | - ?> |
|
466 | + } |
|
467 | + ?> |
|
468 | 468 | |
469 | 469 | </script> |
470 | 470 | <?php |
471 | - } |
|
472 | - |
|
473 | - /** |
|
474 | - * Decide what pages to show on. |
|
475 | - * |
|
476 | - * @return bool |
|
477 | - */ |
|
478 | - public function maybe_show() { |
|
479 | - $show = false; |
|
480 | - |
|
481 | - // check if on a page set to show |
|
482 | - if ( isset( $_REQUEST['page'] ) && in_array( $_REQUEST['page'], $this->pages ) ) { |
|
483 | - |
|
484 | - // check if not active and connected |
|
485 | - if ( ! defined( 'AYECODE_CONNECT_VERSION' ) || ! get_option( 'ayecode_connect_blog_token' ) ) { |
|
486 | - $show = true; |
|
487 | - } |
|
471 | + } |
|
472 | + |
|
473 | + /** |
|
474 | + * Decide what pages to show on. |
|
475 | + * |
|
476 | + * @return bool |
|
477 | + */ |
|
478 | + public function maybe_show() { |
|
479 | + $show = false; |
|
480 | + |
|
481 | + // check if on a page set to show |
|
482 | + if ( isset( $_REQUEST['page'] ) && in_array( $_REQUEST['page'], $this->pages ) ) { |
|
483 | + |
|
484 | + // check if not active and connected |
|
485 | + if ( ! defined( 'AYECODE_CONNECT_VERSION' ) || ! get_option( 'ayecode_connect_blog_token' ) ) { |
|
486 | + $show = true; |
|
487 | + } |
|
488 | 488 | |
489 | - } |
|
489 | + } |
|
490 | 490 | |
491 | - return $show; |
|
492 | - } |
|
491 | + return $show; |
|
492 | + } |
|
493 | 493 | |
494 | - } |
|
494 | + } |
|
495 | 495 | |
496 | 496 | } |
@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
3 | +if (!defined('ABSPATH')) { |
|
4 | 4 | exit; |
5 | 5 | } |
6 | 6 | |
7 | -if ( ! class_exists( "AyeCode_Connect_Helper" ) ) { |
|
7 | +if (!class_exists("AyeCode_Connect_Helper")) { |
|
8 | 8 | /** |
9 | 9 | * Allow the quick setup and connection of our AyeCode Connect plugin. |
10 | 10 | * |
@@ -29,41 +29,41 @@ discard block |
||
29 | 29 | * @param array $strings |
30 | 30 | * @param array $pages |
31 | 31 | */ |
32 | - public function __construct( $strings = array(), $pages = array() ) { |
|
32 | + public function __construct($strings = array(), $pages = array()) { |
|
33 | 33 | |
34 | 34 | // Only fire if not localhost and the current user has the right permissions. |
35 | - if ( ! $this->is_localhost() && current_user_can( 'manage_options' ) ) { |
|
35 | + if (!$this->is_localhost() && current_user_can('manage_options')) { |
|
36 | 36 | |
37 | 37 | |
38 | 38 | // set default strings |
39 | 39 | $default_strings = array( |
40 | - 'connect_title' => __( "Thanks for choosing an AyeCode Product!" ), |
|
41 | - 'connect_external' => __( "Please confirm you wish to connect your site?" ), |
|
42 | - 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s" ), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>" ), |
|
43 | - 'connect_button' => __( "Connect Site" ), |
|
44 | - 'connecting_button' => __( "Connecting..." ), |
|
45 | - 'error_localhost' => __( "This service will only work with a live domain, not a localhost." ), |
|
46 | - 'error' => __( "Something went wrong, please refresh and try again." ), |
|
40 | + 'connect_title' => __("Thanks for choosing an AyeCode Product!"), |
|
41 | + 'connect_external' => __("Please confirm you wish to connect your site?"), |
|
42 | + 'connect' => sprintf(__("<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s"), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>"), |
|
43 | + 'connect_button' => __("Connect Site"), |
|
44 | + 'connecting_button' => __("Connecting..."), |
|
45 | + 'error_localhost' => __("This service will only work with a live domain, not a localhost."), |
|
46 | + 'error' => __("Something went wrong, please refresh and try again."), |
|
47 | 47 | ); |
48 | - $this->strings = array_merge( $default_strings, $strings ); |
|
48 | + $this->strings = array_merge($default_strings, $strings); |
|
49 | 49 | |
50 | 50 | |
51 | 51 | // set default pages |
52 | 52 | $default_pages = array(); |
53 | - $this->pages = array_merge( $default_pages, $pages ); |
|
53 | + $this->pages = array_merge($default_pages, $pages); |
|
54 | 54 | |
55 | 55 | // maybe show connect site notice |
56 | - add_action( 'admin_notices', array( $this, 'ayecode_connect_install_notice' ) ); |
|
56 | + add_action('admin_notices', array($this, 'ayecode_connect_install_notice')); |
|
57 | 57 | |
58 | 58 | // add ajax action if not already added |
59 | - if ( ! has_action( 'wp_ajax_ayecode_connect_helper' ) ) { |
|
60 | - add_action( 'wp_ajax_ayecode_connect_helper', array( $this, 'ayecode_connect_install' ) ); |
|
59 | + if (!has_action('wp_ajax_ayecode_connect_helper')) { |
|
60 | + add_action('wp_ajax_ayecode_connect_helper', array($this, 'ayecode_connect_install')); |
|
61 | 61 | } |
62 | 62 | } |
63 | 63 | |
64 | 64 | // add ajax action if not already added |
65 | - if ( ! has_action( 'wp_ajax_nopriv_ayecode_connect_helper_installed' ) ) { |
|
66 | - add_action( 'wp_ajax_nopriv_ayecode_connect_helper_installed', array( $this, 'ayecode_connect_helper_installed' ) ); |
|
65 | + if (!has_action('wp_ajax_nopriv_ayecode_connect_helper_installed')) { |
|
66 | + add_action('wp_ajax_nopriv_ayecode_connect_helper_installed', array($this, 'ayecode_connect_helper_installed')); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | } |
@@ -71,13 +71,13 @@ discard block |
||
71 | 71 | /** |
72 | 72 | * Give a way to check we can connect via a external redirect. |
73 | 73 | */ |
74 | - public function ayecode_connect_helper_installed(){ |
|
74 | + public function ayecode_connect_helper_installed() { |
|
75 | 75 | $active = array( |
76 | - 'gd' => defined('GEODIRECTORY_VERSION') && version_compare(GEODIRECTORY_VERSION,'2.0.0.79','>') ? 1 : 0, |
|
77 | - 'uwp' => defined('USERSWP_VERSION') && version_compare(USERSWP_VERSION,'1.2.1.5','>') ? 1 : 0, |
|
78 | - 'wpi' => defined('WPINV_VERSION') && version_compare(WPINV_VERSION,'1.0.14','>') ? 1 : 0, |
|
76 | + 'gd' => defined('GEODIRECTORY_VERSION') && version_compare(GEODIRECTORY_VERSION, '2.0.0.79', '>') ? 1 : 0, |
|
77 | + 'uwp' => defined('USERSWP_VERSION') && version_compare(USERSWP_VERSION, '1.2.1.5', '>') ? 1 : 0, |
|
78 | + 'wpi' => defined('WPINV_VERSION') && version_compare(WPINV_VERSION, '1.0.14', '>') ? 1 : 0, |
|
79 | 79 | ); |
80 | - wp_send_json_success( $active ); |
|
80 | + wp_send_json_success($active); |
|
81 | 81 | wp_die(); |
82 | 82 | } |
83 | 83 | |
@@ -88,9 +88,9 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @return string |
90 | 90 | */ |
91 | - private function format_plugin_slug( $key ) { |
|
92 | - $slug = explode( '/', $key ); |
|
93 | - $slug = explode( '.', end( $slug ) ); |
|
91 | + private function format_plugin_slug($key) { |
|
92 | + $slug = explode('/', $key); |
|
93 | + $slug = explode('.', end($slug)); |
|
94 | 94 | |
95 | 95 | return $slug[0]; |
96 | 96 | } |
@@ -101,45 +101,45 @@ discard block |
||
101 | 101 | public function ayecode_connect_install() { |
102 | 102 | |
103 | 103 | // bail if localhost |
104 | - if ( $this->is_localhost() ) { |
|
105 | - wp_send_json_error( $this->strings['error_localhost'] ); |
|
104 | + if ($this->is_localhost()) { |
|
105 | + wp_send_json_error($this->strings['error_localhost']); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | // Explicitly clear the event. |
109 | - wp_clear_scheduled_hook( 'geodir_plugin_background_installer', func_get_args() ); |
|
109 | + wp_clear_scheduled_hook('geodir_plugin_background_installer', func_get_args()); |
|
110 | 110 | |
111 | 111 | $success = true; |
112 | 112 | $plugin_slug = "ayecode-connect"; |
113 | - if ( ! empty( $plugin_slug ) ) { |
|
114 | - require_once( ABSPATH . 'wp-admin/includes/file.php' ); |
|
115 | - require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); |
|
116 | - require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); |
|
117 | - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
113 | + if (!empty($plugin_slug)) { |
|
114 | + require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
115 | + require_once(ABSPATH . 'wp-admin/includes/plugin-install.php'); |
|
116 | + require_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'); |
|
117 | + require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
118 | 118 | |
119 | 119 | WP_Filesystem(); |
120 | 120 | |
121 | 121 | $skin = new Automatic_Upgrader_Skin; |
122 | - $upgrader = new WP_Upgrader( $skin ); |
|
123 | - $installed_plugins = array_map( array( $this, 'format_plugin_slug' ), array_keys( get_plugins() ) ); |
|
122 | + $upgrader = new WP_Upgrader($skin); |
|
123 | + $installed_plugins = array_map(array($this, 'format_plugin_slug'), array_keys(get_plugins())); |
|
124 | 124 | $plugin_slug = $plugin_slug; |
125 | 125 | $plugin = $plugin_slug . '/' . $plugin_slug . '.php'; |
126 | 126 | $installed = false; |
127 | 127 | $activate = false; |
128 | 128 | |
129 | 129 | // See if the plugin is installed already |
130 | - if ( in_array( $plugin_slug, $installed_plugins ) ) { |
|
130 | + if (in_array($plugin_slug, $installed_plugins)) { |
|
131 | 131 | $installed = true; |
132 | - $activate = ! is_plugin_active( $plugin ); |
|
132 | + $activate = !is_plugin_active($plugin); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | // Install this thing! |
136 | - if ( ! $installed ) { |
|
136 | + if (!$installed) { |
|
137 | 137 | |
138 | 138 | // Suppress feedback |
139 | 139 | ob_start(); |
140 | 140 | |
141 | 141 | try { |
142 | - $plugin_information = plugins_api( 'plugin_information', array( |
|
142 | + $plugin_information = plugins_api('plugin_information', array( |
|
143 | 143 | 'slug' => $plugin_slug, |
144 | 144 | 'fields' => array( |
145 | 145 | 'short_description' => false, |
@@ -156,26 +156,26 @@ discard block |
||
156 | 156 | 'author_profile' => false, |
157 | 157 | 'author' => false, |
158 | 158 | ), |
159 | - ) ); |
|
159 | + )); |
|
160 | 160 | |
161 | - if ( is_wp_error( $plugin_information ) ) { |
|
162 | - throw new Exception( $plugin_information->get_error_message() ); |
|
161 | + if (is_wp_error($plugin_information)) { |
|
162 | + throw new Exception($plugin_information->get_error_message()); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | $package = $plugin_information->download_link; |
166 | - $download = $upgrader->download_package( $package ); |
|
166 | + $download = $upgrader->download_package($package); |
|
167 | 167 | |
168 | - if ( is_wp_error( $download ) ) { |
|
169 | - throw new Exception( $download->get_error_message() ); |
|
168 | + if (is_wp_error($download)) { |
|
169 | + throw new Exception($download->get_error_message()); |
|
170 | 170 | } |
171 | 171 | |
172 | - $working_dir = $upgrader->unpack_package( $download, true ); |
|
172 | + $working_dir = $upgrader->unpack_package($download, true); |
|
173 | 173 | |
174 | - if ( is_wp_error( $working_dir ) ) { |
|
175 | - throw new Exception( $working_dir->get_error_message() ); |
|
174 | + if (is_wp_error($working_dir)) { |
|
175 | + throw new Exception($working_dir->get_error_message()); |
|
176 | 176 | } |
177 | 177 | |
178 | - $result = $upgrader->install_package( array( |
|
178 | + $result = $upgrader->install_package(array( |
|
179 | 179 | 'source' => $working_dir, |
180 | 180 | 'destination' => WP_PLUGIN_DIR, |
181 | 181 | 'clear_destination' => false, |
@@ -185,15 +185,15 @@ discard block |
||
185 | 185 | 'type' => 'plugin', |
186 | 186 | 'action' => 'install', |
187 | 187 | ), |
188 | - ) ); |
|
188 | + )); |
|
189 | 189 | |
190 | - if ( is_wp_error( $result ) ) { |
|
191 | - throw new Exception( $result->get_error_message() ); |
|
190 | + if (is_wp_error($result)) { |
|
191 | + throw new Exception($result->get_error_message()); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | $activate = true; |
195 | 195 | |
196 | - } catch ( Exception $e ) { |
|
196 | + } catch (Exception $e) { |
|
197 | 197 | $success = false; |
198 | 198 | } |
199 | 199 | |
@@ -204,30 +204,30 @@ discard block |
||
204 | 204 | wp_clean_plugins_cache(); |
205 | 205 | |
206 | 206 | // Activate this thing |
207 | - if ( $activate ) { |
|
207 | + if ($activate) { |
|
208 | 208 | try { |
209 | - $result = activate_plugin( $plugin ); |
|
209 | + $result = activate_plugin($plugin); |
|
210 | 210 | |
211 | - if ( is_wp_error( $result ) ) { |
|
211 | + if (is_wp_error($result)) { |
|
212 | 212 | $success = false; |
213 | 213 | } else { |
214 | 214 | $success = true; |
215 | 215 | } |
216 | - } catch ( Exception $e ) { |
|
216 | + } catch (Exception $e) { |
|
217 | 217 | $success = false; |
218 | 218 | } |
219 | 219 | } |
220 | 220 | } |
221 | 221 | |
222 | - if ( $success && function_exists( 'ayecode_connect_args' ) ) { |
|
223 | - ayecode_connect();// init |
|
222 | + if ($success && function_exists('ayecode_connect_args')) { |
|
223 | + ayecode_connect(); // init |
|
224 | 224 | $args = ayecode_connect_args(); |
225 | - $client = new AyeCode_Connect( $args ); |
|
226 | - $redirect_to = ! empty( $_POST['redirect_to'] ) ? esc_url_raw( $_POST['redirect_to'] ) : ''; |
|
227 | - $redirect = $client->build_connect_url( $redirect_to ); |
|
228 | - wp_send_json_success( array( 'connect_url' => $redirect ) ); |
|
225 | + $client = new AyeCode_Connect($args); |
|
226 | + $redirect_to = !empty($_POST['redirect_to']) ? esc_url_raw($_POST['redirect_to']) : ''; |
|
227 | + $redirect = $client->build_connect_url($redirect_to); |
|
228 | + wp_send_json_success(array('connect_url' => $redirect)); |
|
229 | 229 | } else { |
230 | - wp_send_json_error( $this->strings['error_localhost'] ); |
|
230 | + wp_send_json_error($this->strings['error_localhost']); |
|
231 | 231 | } |
232 | 232 | wp_die(); |
233 | 233 | } |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | public function is_localhost() { |
241 | 241 | $localhost = false; |
242 | 242 | |
243 | - $host = isset( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : ''; |
|
243 | + $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ''; |
|
244 | 244 | $localhost_domains = array( |
245 | 245 | 'localhost', |
246 | 246 | 'localhost.localdomain', |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | '::1' |
249 | 249 | ); |
250 | 250 | |
251 | - if ( in_array( $host, $localhost_domains ) ) { |
|
251 | + if (in_array($host, $localhost_domains)) { |
|
252 | 252 | $localhost = true; |
253 | 253 | } |
254 | 254 | |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | * Show notice to connect site. |
260 | 260 | */ |
261 | 261 | public function ayecode_connect_install_notice() { |
262 | - if ( $this->maybe_show() ) { |
|
262 | + if ($this->maybe_show()) { |
|
263 | 263 | $connect_title_string = $this->strings['connect_title']; |
264 | 264 | $connect_external_string = $this->strings['connect_external']; |
265 | 265 | $connect_string = $this->strings['connect']; |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | </svg> |
302 | 302 | </span> |
303 | 303 | <span class="acch-float-left acch-text"> |
304 | - <h3 class="acch-title"><?php echo esc_attr( $connect_title_string ); ?></h3> |
|
304 | + <h3 class="acch-title"><?php echo esc_attr($connect_title_string); ?></h3> |
|
305 | 305 | <p> |
306 | 306 | <?php |
307 | 307 | echo $connect_string; |
@@ -312,14 +312,14 @@ discard block |
||
312 | 312 | <span class="acch-float-left acch-button"> |
313 | 313 | <button onclick="ayecode_connect_helper(this);" id="gd-connect-site" |
314 | 314 | class="button button-primary" |
315 | - data-connecting="<?php echo esc_attr( $connecting_button_string ); ?>"><?php echo esc_attr( $connect_button_string ) ?></button> |
|
315 | + data-connecting="<?php echo esc_attr($connecting_button_string); ?>"><?php echo esc_attr($connect_button_string) ?></button> |
|
316 | 316 | </span> |
317 | 317 | |
318 | 318 | </div> |
319 | 319 | |
320 | 320 | <?php |
321 | 321 | // only include the popup HTML if needed. |
322 | - if ( ! empty( $_REQUEST['external-connect-request'] ) ) { |
|
322 | + if (!empty($_REQUEST['external-connect-request'])) { |
|
323 | 323 | ?> |
324 | 324 | <div id="ayecode-connect-helper-external-confirm" style="display:none;"> |
325 | 325 | <div class="noticex notice-info acch-notice" style="border: none;"> |
@@ -357,13 +357,13 @@ discard block |
||
357 | 357 | </svg> |
358 | 358 | </span> |
359 | 359 | <span class="acch-float-left acch-text"> |
360 | - <h3 class="acch-title"><?php echo esc_attr( $connect_external_string ); ?></h3> |
|
360 | + <h3 class="acch-title"><?php echo esc_attr($connect_external_string); ?></h3> |
|
361 | 361 | </span> |
362 | 362 | |
363 | 363 | <span class="acch-float-left acch-button"> |
364 | 364 | <button onclick="ayecode_connect_helper(this);" id="gd-connect-site" |
365 | 365 | class="button button-primary" |
366 | - data-connecting="<?php echo esc_attr( $connecting_button_string ); ?>"><?php echo esc_attr( $connect_button_string ) ?></button> |
|
366 | + data-connecting="<?php echo esc_attr($connecting_button_string); ?>"><?php echo esc_attr($connect_button_string) ?></button> |
|
367 | 367 | </span> |
368 | 368 | |
369 | 369 | </div> |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | public function script() { |
383 | 383 | |
384 | 384 | // add thickbox if external request is requested |
385 | - if ( ! empty( $_REQUEST['external-connect-request'] ) ) { |
|
385 | + if (!empty($_REQUEST['external-connect-request'])) { |
|
386 | 386 | add_thickbox(); |
387 | 387 | } |
388 | 388 | ?> |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | url: ajaxurl, |
435 | 435 | data: { |
436 | 436 | action: 'ayecode_connect_helper', |
437 | - security: '<?php echo wp_create_nonce( 'ayecode-connect-helper' );?>', |
|
437 | + security: '<?php echo wp_create_nonce('ayecode-connect-helper'); ?>', |
|
438 | 438 | redirect_to: $current_url |
439 | 439 | }, |
440 | 440 | beforeSend: function () { |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | |
456 | 456 | <?php |
457 | 457 | // add thickbox if external request is requested |
458 | - if(! empty( $_REQUEST['external-connect-request'] )) { |
|
458 | + if (!empty($_REQUEST['external-connect-request'])) { |
|
459 | 459 | ?> |
460 | 460 | jQuery(function () { |
461 | 461 | setTimeout(function () { |
@@ -479,10 +479,10 @@ discard block |
||
479 | 479 | $show = false; |
480 | 480 | |
481 | 481 | // check if on a page set to show |
482 | - if ( isset( $_REQUEST['page'] ) && in_array( $_REQUEST['page'], $this->pages ) ) { |
|
482 | + if (isset($_REQUEST['page']) && in_array($_REQUEST['page'], $this->pages)) { |
|
483 | 483 | |
484 | 484 | // check if not active and connected |
485 | - if ( ! defined( 'AYECODE_CONNECT_VERSION' ) || ! get_option( 'ayecode_connect_blog_token' ) ) { |
|
485 | + if (!defined('AYECODE_CONNECT_VERSION') || !get_option('ayecode_connect_blog_token')) { |
|
486 | 486 | $show = true; |
487 | 487 | } |
488 | 488 |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | global $wpdb; |
14 | 14 | |
15 | 15 | $db = new WPInv_Subscriptions_DB; |
16 | -$page = isset($_GET['cpage']) ? abs((int)$_GET['cpage']) : 1; |
|
16 | +$page = isset($_GET['cpage']) ? abs((int) $_GET['cpage']) : 1; |
|
17 | 17 | $items_per_page = get_option('posts_per_page'); |
18 | 18 | $offset = ($page * $items_per_page) - $items_per_page; |
19 | 19 | $args = array('customer_id' => $user_id, 'offset' => $offset); |
@@ -29,16 +29,16 @@ discard block |
||
29 | 29 | <table class="table table-bordered table-hover table-responsive wpi-user-subscriptions"> |
30 | 30 | <thead> |
31 | 31 | <tr> |
32 | - <th class="sub-no"><span class="nobr"><?php _e( 'No.', 'invoicing' ); ?></span></th> |
|
33 | - <th class="sub-amount"><span class="nobr"><?php _e( 'Initial Amount', 'invoicing' ); ?></span></th> |
|
34 | - <th class="sub-cycle"><span class="nobr"><?php _e( 'Billing Cycle', 'invoicing' ); ?></span></th> |
|
35 | - <th class="sub-billed"><span class="nobr"><?php _e( 'Times Billed', 'invoicing' ); ?></span></th> |
|
36 | - <th class="sub-status"><span class="nobr"><?php _e( 'Status', 'invoicing' ); ?></span></th> |
|
37 | - <th class="sub-invoice"><span class="nobr"><?php _e( 'Invoice', 'invoicing' ); ?></span></th> |
|
38 | - <th class="sub-item"><span class="nobr"><?php _e( 'Item', 'invoicing' ); ?></span></th> |
|
39 | - <th class="sub-gateway"><span class="nobr"><?php _e( 'Gateway', 'invoicing' ); ?></span></th> |
|
40 | - <th class="sub-expiry"><span class="nobr"><?php _e( 'Expires On', 'invoicing' ); ?></span></th> |
|
41 | - <th class="sub-actions"><span class="nobr"><?php _e( 'Actions', 'invoicing' ); ?></span></th> |
|
32 | + <th class="sub-no"><span class="nobr"><?php _e('No.', 'invoicing'); ?></span></th> |
|
33 | + <th class="sub-amount"><span class="nobr"><?php _e('Initial Amount', 'invoicing'); ?></span></th> |
|
34 | + <th class="sub-cycle"><span class="nobr"><?php _e('Billing Cycle', 'invoicing'); ?></span></th> |
|
35 | + <th class="sub-billed"><span class="nobr"><?php _e('Times Billed', 'invoicing'); ?></span></th> |
|
36 | + <th class="sub-status"><span class="nobr"><?php _e('Status', 'invoicing'); ?></span></th> |
|
37 | + <th class="sub-invoice"><span class="nobr"><?php _e('Invoice', 'invoicing'); ?></span></th> |
|
38 | + <th class="sub-item"><span class="nobr"><?php _e('Item', 'invoicing'); ?></span></th> |
|
39 | + <th class="sub-gateway"><span class="nobr"><?php _e('Gateway', 'invoicing'); ?></span></th> |
|
40 | + <th class="sub-expiry"><span class="nobr"><?php _e('Expires On', 'invoicing'); ?></span></th> |
|
41 | + <th class="sub-actions"><span class="nobr"><?php _e('Actions', 'invoicing'); ?></span></th> |
|
42 | 42 | </tr> |
43 | 43 | </thead> |
44 | 44 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | <td><?php echo date_i18n(get_option('date_format'), strtotime($sub->expiration, current_time('timestamp'))); ?></td> |
65 | 65 | <td><?php |
66 | 66 | if ($sub->can_cancel()) { |
67 | - $message = esc_attr__( 'Are you sure you want to cancel this subscription?', 'invoicing' ); |
|
67 | + $message = esc_attr__('Are you sure you want to cancel this subscription?', 'invoicing'); |
|
68 | 68 | echo '<a class="btn btn-sm btn-primary" onclick="return confirm(\'' . $message . '\')" href="' . $sub->get_cancel_url() . '" >' . __("Cancel", "invoicing") . '</a>'; |
69 | 69 | } |
70 | 70 | do_action('wpinv_subscription_item_actions', $sub); |
@@ -175,13 +175,13 @@ discard block |
||
175 | 175 | $is_writeable = $is_dir && is_writeable( $this->export_dir ); |
176 | 176 | |
177 | 177 | if ( $is_dir && $is_writeable ) { |
178 | - return true; |
|
178 | + return true; |
|
179 | 179 | } else if ( $is_dir && !$is_writeable ) { |
180 | - if ( !$this->wp_filesystem->chmod( $this->export_dir, FS_CHMOD_DIR ) ) { |
|
181 | - return wp_sprintf( __( 'Filesystem ERROR: Export location %s is not writable, check your file permissions.', 'invoicing' ), $this->export_dir ); |
|
182 | - } |
|
180 | + if ( !$this->wp_filesystem->chmod( $this->export_dir, FS_CHMOD_DIR ) ) { |
|
181 | + return wp_sprintf( __( 'Filesystem ERROR: Export location %s is not writable, check your file permissions.', 'invoicing' ), $this->export_dir ); |
|
182 | + } |
|
183 | 183 | |
184 | - return true; |
|
184 | + return true; |
|
185 | 185 | } else { |
186 | 186 | if ( !$this->wp_filesystem->mkdir( $this->export_dir, FS_CHMOD_DIR ) ) { |
187 | 187 | return wp_sprintf( __( 'Filesystem ERROR: Could not create directory %s. This is usually due to inconsistent file permissions.', 'invoicing' ), $this->export_dir ); |
@@ -276,12 +276,12 @@ discard block |
||
276 | 276 | $output = fopen( 'php://output', 'w' ) or die( 'Unsupported server' ); |
277 | 277 | |
278 | 278 | // Let the browser know what content we're streaming and how it should save the content. |
279 | - $name = time(); |
|
280 | - header( "Content-Type:application/csv" ); |
|
279 | + $name = time(); |
|
280 | + header( "Content-Type:application/csv" ); |
|
281 | 281 | header( "Content-Disposition:attachment;filename=noptin-subscribers-$name.csv" ); |
282 | 282 | |
283 | 283 | // Output the csv column headers. |
284 | - fputcsv( |
|
284 | + fputcsv( |
|
285 | 285 | $output, |
286 | 286 | array( |
287 | 287 | __( 'Discount Id', 'invoicing' ), |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; // Exit if accessed directly |
4 | 4 | } |
5 | 5 | |
@@ -21,175 +21,175 @@ discard block |
||
21 | 21 | public function init() { |
22 | 22 | global $wp_filesystem; |
23 | 23 | |
24 | - if ( empty( $wp_filesystem ) ) { |
|
25 | - require_once( ABSPATH . '/wp-admin/includes/file.php' ); |
|
24 | + if (empty($wp_filesystem)) { |
|
25 | + require_once(ABSPATH . '/wp-admin/includes/file.php'); |
|
26 | 26 | WP_Filesystem(); |
27 | 27 | global $wp_filesystem; |
28 | 28 | } |
29 | 29 | $this->wp_filesystem = $wp_filesystem; |
30 | 30 | |
31 | 31 | $this->export_dir = $this->export_location(); |
32 | - $this->export_url = $this->export_location( true ); |
|
32 | + $this->export_url = $this->export_location(true); |
|
33 | 33 | $this->export = 'invoicing'; |
34 | 34 | $this->filetype = 'csv'; |
35 | 35 | $this->per_page = 20; |
36 | 36 | |
37 | - do_action( 'wpinv_class_reports_init', $this ); |
|
37 | + do_action('wpinv_class_reports_init', $this); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | public function includes() { |
41 | - do_action( 'wpinv_class_reports_includes', $this ); |
|
41 | + do_action('wpinv_class_reports_includes', $this); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | public function actions() { |
45 | - if ( is_admin() ) { |
|
46 | - add_action( 'admin_menu', array( $this, 'add_submenu' ), 10 ); |
|
47 | - add_action( 'wpinv_reports_tab_export', array( $this, 'export' ) ); |
|
48 | - add_action( 'wp_ajax_wpinv_ajax_export', array( $this, 'ajax_export' ) ); |
|
49 | - add_action( 'wp_ajax_wpinv_ajax_discount_use_export', array( $this, 'discount_use_export' ) ); |
|
45 | + if (is_admin()) { |
|
46 | + add_action('admin_menu', array($this, 'add_submenu'), 10); |
|
47 | + add_action('wpinv_reports_tab_export', array($this, 'export')); |
|
48 | + add_action('wp_ajax_wpinv_ajax_export', array($this, 'ajax_export')); |
|
49 | + add_action('wp_ajax_wpinv_ajax_discount_use_export', array($this, 'discount_use_export')); |
|
50 | 50 | |
51 | 51 | // Export Invoices. |
52 | - add_action( 'wpinv_export_set_params_invoices', array( $this, 'set_invoices_export' ) ); |
|
53 | - add_filter( 'wpinv_export_get_columns_invoices', array( $this, 'get_invoices_columns' ) ); |
|
54 | - add_filter( 'wpinv_export_get_data_invoices', array( $this, 'get_invoices_data' ) ); |
|
55 | - add_filter( 'wpinv_get_export_status_invoices', array( $this, 'invoices_export_status' ) ); |
|
52 | + add_action('wpinv_export_set_params_invoices', array($this, 'set_invoices_export')); |
|
53 | + add_filter('wpinv_export_get_columns_invoices', array($this, 'get_invoices_columns')); |
|
54 | + add_filter('wpinv_export_get_data_invoices', array($this, 'get_invoices_data')); |
|
55 | + add_filter('wpinv_get_export_status_invoices', array($this, 'invoices_export_status')); |
|
56 | 56 | } |
57 | - do_action( 'wpinv_class_reports_actions', $this ); |
|
57 | + do_action('wpinv_class_reports_actions', $this); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | public function add_submenu() { |
61 | 61 | global $wpi_reports_page; |
62 | - $wpi_reports_page = add_submenu_page( 'wpinv', __( 'Reports', 'invoicing' ), __( 'Reports', 'invoicing' ), wpinv_get_capability(), 'wpinv-reports', array( $this, 'reports_page' ) ); |
|
62 | + $wpi_reports_page = add_submenu_page('wpinv', __('Reports', 'invoicing'), __('Reports', 'invoicing'), wpinv_get_capability(), 'wpinv-reports', array($this, 'reports_page')); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | public function reports_page() { |
66 | - if ( !wp_script_is( 'postbox', 'enqueued' ) ) { |
|
67 | - wp_enqueue_script( 'postbox' ); |
|
66 | + if (!wp_script_is('postbox', 'enqueued')) { |
|
67 | + wp_enqueue_script('postbox'); |
|
68 | 68 | } |
69 | - if ( !wp_script_is( 'jquery-ui-datepicker', 'enqueued' ) ) { |
|
70 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
69 | + if (!wp_script_is('jquery-ui-datepicker', 'enqueued')) { |
|
70 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
71 | 71 | } |
72 | 72 | |
73 | - $current_page = admin_url( 'admin.php?page=wpinv-reports' ); |
|
74 | - $active_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'export'; |
|
73 | + $current_page = admin_url('admin.php?page=wpinv-reports'); |
|
74 | + $active_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'export'; |
|
75 | 75 | ?> |
76 | 76 | <div class="wrap wpi-reports-wrap"> |
77 | - <h1><?php echo esc_html( __( 'Reports', 'invoicing' ) ); ?></h1> |
|
77 | + <h1><?php echo esc_html(__('Reports', 'invoicing')); ?></h1> |
|
78 | 78 | <h2 class="nav-tab-wrapper wp-clearfix"> |
79 | - <a href="<?php echo add_query_arg( array( 'tab' => 'export', 'settings-updated' => false ), $current_page ); ?>" class="nav-tab <?php echo $active_tab == 'export' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Export', 'invoicing' ); ?></a> |
|
80 | - <?php do_action( 'wpinv_reports_page_tabs' ); ;?> |
|
79 | + <a href="<?php echo add_query_arg(array('tab' => 'export', 'settings-updated' => false), $current_page); ?>" class="nav-tab <?php echo $active_tab == 'export' ? 'nav-tab-active' : ''; ?>"><?php _e('Export', 'invoicing'); ?></a> |
|
80 | + <?php do_action('wpinv_reports_page_tabs'); ;?> |
|
81 | 81 | </h2> |
82 | - <div class="wpi-reports-content wpi-reports-<?php echo esc_attr( $active_tab ); ?>"> |
|
82 | + <div class="wpi-reports-content wpi-reports-<?php echo esc_attr($active_tab); ?>"> |
|
83 | 83 | <?php |
84 | - do_action( 'wpinv_reports_page_top' ); |
|
85 | - do_action( 'wpinv_reports_tab_' . $active_tab ); |
|
86 | - do_action( 'wpinv_reports_page_bottom' ); |
|
84 | + do_action('wpinv_reports_page_top'); |
|
85 | + do_action('wpinv_reports_tab_' . $active_tab); |
|
86 | + do_action('wpinv_reports_page_bottom'); |
|
87 | 87 | ?> |
88 | 88 | </div> |
89 | 89 | <?php |
90 | 90 | } |
91 | 91 | |
92 | 92 | public function export() { |
93 | - $statuses = wpinv_get_invoice_statuses( true ); |
|
94 | - $statuses = array_merge( array( 'any' => __( 'All Statuses', 'invoicing' ) ), $statuses ); |
|
93 | + $statuses = wpinv_get_invoice_statuses(true); |
|
94 | + $statuses = array_merge(array('any' => __('All Statuses', 'invoicing')), $statuses); |
|
95 | 95 | ?> |
96 | 96 | <div class="metabox-holder"> |
97 | 97 | <div id="post-body"> |
98 | 98 | <div id="post-body-content"> |
99 | - <?php do_action( 'wpinv_reports_tab_export_content_top' ); ?> |
|
99 | + <?php do_action('wpinv_reports_tab_export_content_top'); ?> |
|
100 | 100 | |
101 | 101 | <div class="postbox wpi-export-invoices"> |
102 | - <h2 class="hndle ui-sortabled-handle"><span><?php _e( 'Invoices','invoicing' ); ?></span></h2> |
|
102 | + <h2 class="hndle ui-sortabled-handle"><span><?php _e('Invoices', 'invoicing'); ?></span></h2> |
|
103 | 103 | <div class="inside"> |
104 | - <p><?php _e( 'Download a CSV of all payment invoices.', 'invoicing' ); ?></p> |
|
104 | + <p><?php _e('Download a CSV of all payment invoices.', 'invoicing'); ?></p> |
|
105 | 105 | <form id="wpi-export-invoices" class="wpi-export-form" method="post"> |
106 | - <?php echo wpinv_html_date_field( array( |
|
106 | + <?php echo wpinv_html_date_field(array( |
|
107 | 107 | 'id' => 'wpi_export_from_date', |
108 | 108 | 'name' => 'from_date', |
109 | 109 | 'data' => array( |
110 | 110 | 'dateFormat' => 'yy-mm-dd' |
111 | 111 | ), |
112 | - 'placeholder' => __( 'From date', 'invoicing' ) ) |
|
112 | + 'placeholder' => __('From date', 'invoicing') ) |
|
113 | 113 | ); ?> |
114 | - <?php echo wpinv_html_date_field( array( |
|
114 | + <?php echo wpinv_html_date_field(array( |
|
115 | 115 | 'id' => 'wpi_export_to_date', |
116 | 116 | 'name' => 'to_date', |
117 | 117 | 'data' => array( |
118 | 118 | 'dateFormat' => 'yy-mm-dd' |
119 | 119 | ), |
120 | - 'placeholder' => __( 'To date', 'invoicing' ) ) |
|
120 | + 'placeholder' => __('To date', 'invoicing') ) |
|
121 | 121 | ); ?> |
122 | 122 | <span id="wpinv-status-wrap"> |
123 | - <?php echo wpinv_html_select( array( |
|
123 | + <?php echo wpinv_html_select(array( |
|
124 | 124 | 'options' => $statuses, |
125 | 125 | 'name' => 'status', |
126 | 126 | 'id' => 'wpi_export_status', |
127 | 127 | 'show_option_all' => false, |
128 | 128 | 'show_option_none' => false, |
129 | 129 | 'class' => 'wpi_select2', |
130 | - ) ); ?> |
|
131 | - <?php wp_nonce_field( 'wpi_ajax_export', 'wpi_ajax_export' ); ?> |
|
130 | + )); ?> |
|
131 | + <?php wp_nonce_field('wpi_ajax_export', 'wpi_ajax_export'); ?> |
|
132 | 132 | </span> |
133 | 133 | <span id="wpinv-submit-wrap"> |
134 | 134 | <input type="hidden" value="invoices" name="export" /> |
135 | - <input type="submit" value="<?php _e( 'Generate CSV', 'invoicing' ); ?>" class="button-primary" /> |
|
135 | + <input type="submit" value="<?php _e('Generate CSV', 'invoicing'); ?>" class="button-primary" /> |
|
136 | 136 | </span> |
137 | 137 | </form> |
138 | 138 | </div> |
139 | 139 | </div> |
140 | 140 | |
141 | 141 | <div class="postbox wpi-export-discount-uses"> |
142 | - <h2 class="hndle ui-sortabled-handle"><span><?php _e( 'Discount Use','invoicing' ); ?></span></h2> |
|
142 | + <h2 class="hndle ui-sortabled-handle"><span><?php _e('Discount Use', 'invoicing'); ?></span></h2> |
|
143 | 143 | <div class="inside"> |
144 | - <p><?php _e( 'Download a CSV of discount uses.', 'invoicing' ); ?></p> |
|
145 | - <a class="button-primary" href="<?php echo esc_url( wp_nonce_url( admin_url( 'admin-ajax.php?action=wpinv_ajax_discount_use_export' ), 'wpi_discount_ajax_export', 'wpi_discount_ajax_export' ) ); ?>"><?php _e( 'Generate CSV', 'invoicing' ); ?></a> |
|
144 | + <p><?php _e('Download a CSV of discount uses.', 'invoicing'); ?></p> |
|
145 | + <a class="button-primary" href="<?php echo esc_url(wp_nonce_url(admin_url('admin-ajax.php?action=wpinv_ajax_discount_use_export'), 'wpi_discount_ajax_export', 'wpi_discount_ajax_export')); ?>"><?php _e('Generate CSV', 'invoicing'); ?></a> |
|
146 | 146 | </div> |
147 | 147 | </div> |
148 | 148 | |
149 | - <?php do_action( 'wpinv_reports_tab_export_content_bottom' ); ?> |
|
149 | + <?php do_action('wpinv_reports_tab_export_content_bottom'); ?> |
|
150 | 150 | </div> |
151 | 151 | </div> |
152 | 152 | </div> |
153 | 153 | <?php |
154 | 154 | } |
155 | 155 | |
156 | - public function export_location( $relative = false ) { |
|
156 | + public function export_location($relative = false) { |
|
157 | 157 | $upload_dir = wp_upload_dir(); |
158 | - $export_location = $relative ? trailingslashit( $upload_dir['baseurl'] ) . 'cache' : trailingslashit( $upload_dir['basedir'] ) . 'cache'; |
|
159 | - $export_location = apply_filters( 'wpinv_export_location', $export_location, $relative ); |
|
158 | + $export_location = $relative ? trailingslashit($upload_dir['baseurl']) . 'cache' : trailingslashit($upload_dir['basedir']) . 'cache'; |
|
159 | + $export_location = apply_filters('wpinv_export_location', $export_location, $relative); |
|
160 | 160 | |
161 | - return trailingslashit( $export_location ); |
|
161 | + return trailingslashit($export_location); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | public function check_export_location() { |
165 | 165 | try { |
166 | - if ( empty( $this->wp_filesystem ) ) { |
|
167 | - return __( 'Filesystem ERROR: Could not access filesystem.', 'invoicing' ); |
|
166 | + if (empty($this->wp_filesystem)) { |
|
167 | + return __('Filesystem ERROR: Could not access filesystem.', 'invoicing'); |
|
168 | 168 | } |
169 | 169 | |
170 | - if ( is_wp_error( $this->wp_filesystem ) ) { |
|
171 | - return __( 'Filesystem ERROR: ' . $this->wp_filesystem->get_error_message(), 'invoicing' ); |
|
170 | + if (is_wp_error($this->wp_filesystem)) { |
|
171 | + return __('Filesystem ERROR: ' . $this->wp_filesystem->get_error_message(), 'invoicing'); |
|
172 | 172 | } |
173 | 173 | |
174 | - $is_dir = $this->wp_filesystem->is_dir( $this->export_dir ); |
|
175 | - $is_writeable = $is_dir && is_writeable( $this->export_dir ); |
|
174 | + $is_dir = $this->wp_filesystem->is_dir($this->export_dir); |
|
175 | + $is_writeable = $is_dir && is_writeable($this->export_dir); |
|
176 | 176 | |
177 | - if ( $is_dir && $is_writeable ) { |
|
177 | + if ($is_dir && $is_writeable) { |
|
178 | 178 | return true; |
179 | - } else if ( $is_dir && !$is_writeable ) { |
|
180 | - if ( !$this->wp_filesystem->chmod( $this->export_dir, FS_CHMOD_DIR ) ) { |
|
181 | - return wp_sprintf( __( 'Filesystem ERROR: Export location %s is not writable, check your file permissions.', 'invoicing' ), $this->export_dir ); |
|
179 | + } else if ($is_dir && !$is_writeable) { |
|
180 | + if (!$this->wp_filesystem->chmod($this->export_dir, FS_CHMOD_DIR)) { |
|
181 | + return wp_sprintf(__('Filesystem ERROR: Export location %s is not writable, check your file permissions.', 'invoicing'), $this->export_dir); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | return true; |
185 | 185 | } else { |
186 | - if ( !$this->wp_filesystem->mkdir( $this->export_dir, FS_CHMOD_DIR ) ) { |
|
187 | - return wp_sprintf( __( 'Filesystem ERROR: Could not create directory %s. This is usually due to inconsistent file permissions.', 'invoicing' ), $this->export_dir ); |
|
186 | + if (!$this->wp_filesystem->mkdir($this->export_dir, FS_CHMOD_DIR)) { |
|
187 | + return wp_sprintf(__('Filesystem ERROR: Could not create directory %s. This is usually due to inconsistent file permissions.', 'invoicing'), $this->export_dir); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | return true; |
191 | 191 | } |
192 | - } catch ( Exception $e ) { |
|
192 | + } catch (Exception $e) { |
|
193 | 193 | return $e->getMessage(); |
194 | 194 | } |
195 | 195 | } |
@@ -197,59 +197,59 @@ discard block |
||
197 | 197 | public function ajax_export() { |
198 | 198 | $response = array(); |
199 | 199 | $response['success'] = false; |
200 | - $response['msg'] = __( 'Invalid export request found.', 'invoicing' ); |
|
200 | + $response['msg'] = __('Invalid export request found.', 'invoicing'); |
|
201 | 201 | |
202 | - if ( empty( $_POST['data'] ) || ! wpinv_current_user_can_manage_invoicing() ) { |
|
203 | - wp_send_json( $response ); |
|
202 | + if (empty($_POST['data']) || !wpinv_current_user_can_manage_invoicing()) { |
|
203 | + wp_send_json($response); |
|
204 | 204 | } |
205 | 205 | |
206 | - parse_str( $_POST['data'], $data ); |
|
206 | + parse_str($_POST['data'], $data); |
|
207 | 207 | |
208 | - $data['step'] = !empty( $_POST['step'] ) ? absint( $_POST['step'] ) : 1; |
|
208 | + $data['step'] = !empty($_POST['step']) ? absint($_POST['step']) : 1; |
|
209 | 209 | |
210 | - $_REQUEST = (array)$data; |
|
211 | - if ( !( !empty( $_REQUEST['wpi_ajax_export'] ) && wp_verify_nonce( $_REQUEST['wpi_ajax_export'], 'wpi_ajax_export' ) ) ) { |
|
212 | - $response['msg'] = __( 'Security check failed.', 'invoicing' ); |
|
213 | - wp_send_json( $response ); |
|
210 | + $_REQUEST = (array) $data; |
|
211 | + if (!(!empty($_REQUEST['wpi_ajax_export']) && wp_verify_nonce($_REQUEST['wpi_ajax_export'], 'wpi_ajax_export'))) { |
|
212 | + $response['msg'] = __('Security check failed.', 'invoicing'); |
|
213 | + wp_send_json($response); |
|
214 | 214 | } |
215 | 215 | |
216 | - if ( ( $error = $this->check_export_location( true ) ) !== true ) { |
|
217 | - $response['msg'] = __( 'Filesystem ERROR: ' . $error, 'invoicing' ); |
|
218 | - wp_send_json( $response ); |
|
216 | + if (($error = $this->check_export_location(true)) !== true) { |
|
217 | + $response['msg'] = __('Filesystem ERROR: ' . $error, 'invoicing'); |
|
218 | + wp_send_json($response); |
|
219 | 219 | } |
220 | 220 | |
221 | - $this->set_export_params( $_REQUEST ); |
|
221 | + $this->set_export_params($_REQUEST); |
|
222 | 222 | |
223 | 223 | $return = $this->process_export_step(); |
224 | 224 | $done = $this->get_export_status(); |
225 | 225 | |
226 | - if ( $return ) { |
|
226 | + if ($return) { |
|
227 | 227 | $this->step += 1; |
228 | 228 | |
229 | 229 | $response['success'] = true; |
230 | 230 | $response['msg'] = ''; |
231 | 231 | |
232 | - if ( $done >= 100 ) { |
|
232 | + if ($done >= 100) { |
|
233 | 233 | $this->step = 'done'; |
234 | - $new_filename = 'wpi-' . $this->export . '-' . date( 'y-m-d-H-i' ) . '.' . $this->filetype; |
|
234 | + $new_filename = 'wpi-' . $this->export . '-' . date('y-m-d-H-i') . '.' . $this->filetype; |
|
235 | 235 | $new_file = $this->export_dir . $new_filename; |
236 | 236 | |
237 | - if ( file_exists( $this->file ) ) { |
|
238 | - $this->wp_filesystem->move( $this->file, $new_file, true ); |
|
237 | + if (file_exists($this->file)) { |
|
238 | + $this->wp_filesystem->move($this->file, $new_file, true); |
|
239 | 239 | } |
240 | 240 | |
241 | - if ( file_exists( $new_file ) ) { |
|
242 | - $response['data']['file'] = array( 'u' => $this->export_url . $new_filename, 's' => size_format( filesize( $new_file ), 2 ) ); |
|
241 | + if (file_exists($new_file)) { |
|
242 | + $response['data']['file'] = array('u' => $this->export_url . $new_filename, 's' => size_format(filesize($new_file), 2)); |
|
243 | 243 | } |
244 | 244 | } |
245 | 245 | |
246 | 246 | $response['data']['step'] = $this->step; |
247 | 247 | $response['data']['done'] = $done; |
248 | 248 | } else { |
249 | - $response['msg'] = __( 'No data found for export.', 'invoicing' ); |
|
249 | + $response['msg'] = __('No data found for export.', 'invoicing'); |
|
250 | 250 | } |
251 | 251 | |
252 | - wp_send_json( $response ); |
|
252 | + wp_send_json($response); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /** |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | */ |
258 | 258 | public function discount_use_export() { |
259 | 259 | |
260 | - if ( ! wp_verify_nonce( $_GET['wpi_discount_ajax_export'], 'wpi_discount_ajax_export' ) || ! wpinv_current_user_can_manage_invoicing() ) { |
|
260 | + if (!wp_verify_nonce($_GET['wpi_discount_ajax_export'], 'wpi_discount_ajax_export') || !wpinv_current_user_can_manage_invoicing()) { |
|
261 | 261 | wp_die( -1, 403 ); |
262 | 262 | } |
263 | 263 | |
@@ -267,115 +267,115 @@ discard block |
||
267 | 267 | 'posts_per_page' => -1, |
268 | 268 | ); |
269 | 269 | |
270 | - $discounts = get_posts( $args ); |
|
270 | + $discounts = get_posts($args); |
|
271 | 271 | |
272 | - if ( empty( $discounts ) ) { |
|
273 | - die ( __( 'You have not set up any discounts', 'invoicing' ) ); |
|
272 | + if (empty($discounts)) { |
|
273 | + die (__('You have not set up any discounts', 'invoicing')); |
|
274 | 274 | } |
275 | 275 | |
276 | - $output = fopen( 'php://output', 'w' ) or die( 'Unsupported server' ); |
|
276 | + $output = fopen('php://output', 'w') or die('Unsupported server'); |
|
277 | 277 | |
278 | 278 | // Let the browser know what content we're streaming and how it should save the content. |
279 | 279 | $name = time(); |
280 | - header( "Content-Type:application/csv" ); |
|
281 | - header( "Content-Disposition:attachment;filename=noptin-subscribers-$name.csv" ); |
|
280 | + header("Content-Type:application/csv"); |
|
281 | + header("Content-Disposition:attachment;filename=noptin-subscribers-$name.csv"); |
|
282 | 282 | |
283 | 283 | // Output the csv column headers. |
284 | 284 | fputcsv( |
285 | 285 | $output, |
286 | 286 | array( |
287 | - __( 'Discount Id', 'invoicing' ), |
|
288 | - __( 'Discount Code', 'invoicing' ), |
|
289 | - __( 'Discount Type', 'invoicing' ), |
|
290 | - __( 'Discount Amount', 'invoicing' ), |
|
291 | - __( 'Uses', 'invoicing' ), |
|
287 | + __('Discount Id', 'invoicing'), |
|
288 | + __('Discount Code', 'invoicing'), |
|
289 | + __('Discount Type', 'invoicing'), |
|
290 | + __('Discount Amount', 'invoicing'), |
|
291 | + __('Uses', 'invoicing'), |
|
292 | 292 | ) |
293 | 293 | ); |
294 | 294 | |
295 | - foreach ( $discounts as $discount ) { |
|
295 | + foreach ($discounts as $discount) { |
|
296 | 296 | |
297 | 297 | $discount = (int) $discount; |
298 | 298 | $row = array( |
299 | 299 | $discount, |
300 | - get_post_meta( $discount, '_wpi_discount_code', true ), |
|
301 | - get_post_meta( $discount, '_wpi_discount_type', true ), |
|
302 | - get_post_meta( $discount, '_wpi_discount_amount', true ), |
|
303 | - (int) get_post_meta( $discount, '_wpi_discount_uses', true ) |
|
300 | + get_post_meta($discount, '_wpi_discount_code', true), |
|
301 | + get_post_meta($discount, '_wpi_discount_type', true), |
|
302 | + get_post_meta($discount, '_wpi_discount_amount', true), |
|
303 | + (int) get_post_meta($discount, '_wpi_discount_uses', true) |
|
304 | 304 | ); |
305 | - fputcsv( $output, $row ); |
|
305 | + fputcsv($output, $row); |
|
306 | 306 | } |
307 | 307 | |
308 | - fclose( $output ); |
|
308 | + fclose($output); |
|
309 | 309 | exit; |
310 | 310 | |
311 | 311 | } |
312 | 312 | |
313 | - public function set_export_params( $request ) { |
|
313 | + public function set_export_params($request) { |
|
314 | 314 | $this->empty = false; |
315 | - $this->step = !empty( $request['step'] ) ? absint( $request['step'] ) : 1; |
|
316 | - $this->export = !empty( $request['export'] ) ? $request['export'] : $this->export; |
|
315 | + $this->step = !empty($request['step']) ? absint($request['step']) : 1; |
|
316 | + $this->export = !empty($request['export']) ? $request['export'] : $this->export; |
|
317 | 317 | $this->filename = 'wpi-' . $this->export . '-' . $request['wpi_ajax_export'] . '.' . $this->filetype; |
318 | 318 | $this->file = $this->export_dir . $this->filename; |
319 | 319 | |
320 | - do_action( 'wpinv_export_set_params_' . $this->export, $request ); |
|
320 | + do_action('wpinv_export_set_params_' . $this->export, $request); |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | public function get_columns() { |
324 | 324 | $columns = array(); |
325 | 325 | |
326 | - return apply_filters( 'wpinv_export_get_columns_' . $this->export, $columns ); |
|
326 | + return apply_filters('wpinv_export_get_columns_' . $this->export, $columns); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | protected function get_export_file() { |
330 | 330 | $file = ''; |
331 | 331 | |
332 | - if ( $this->wp_filesystem->exists( $this->file ) ) { |
|
333 | - $file = $this->wp_filesystem->get_contents( $this->file ); |
|
332 | + if ($this->wp_filesystem->exists($this->file)) { |
|
333 | + $file = $this->wp_filesystem->get_contents($this->file); |
|
334 | 334 | } else { |
335 | - $this->wp_filesystem->put_contents( $this->file, '' ); |
|
335 | + $this->wp_filesystem->put_contents($this->file, ''); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | return $file; |
339 | 339 | } |
340 | 340 | |
341 | - protected function attach_export_data( $data = '' ) { |
|
342 | - $filedata = $this->get_export_file(); |
|
343 | - $filedata .= $data; |
|
341 | + protected function attach_export_data($data = '') { |
|
342 | + $filedata = $this->get_export_file(); |
|
343 | + $filedata .= $data; |
|
344 | 344 | |
345 | - $this->wp_filesystem->put_contents( $this->file, $filedata ); |
|
345 | + $this->wp_filesystem->put_contents($this->file, $filedata); |
|
346 | 346 | |
347 | - $rows = file( $this->file, FILE_SKIP_EMPTY_LINES ); |
|
347 | + $rows = file($this->file, FILE_SKIP_EMPTY_LINES); |
|
348 | 348 | $columns = $this->get_columns(); |
349 | - $columns = empty( $columns ) ? 0 : 1; |
|
349 | + $columns = empty($columns) ? 0 : 1; |
|
350 | 350 | |
351 | - $this->empty = count( $rows ) == $columns ? true : false; |
|
351 | + $this->empty = count($rows) == $columns ? true : false; |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | public function print_columns() { |
355 | 355 | $column_data = ''; |
356 | 356 | $columns = $this->get_columns(); |
357 | 357 | $i = 1; |
358 | - foreach( $columns as $key => $column ) { |
|
359 | - $column_data .= '"' . addslashes( $column ) . '"'; |
|
360 | - $column_data .= $i == count( $columns ) ? '' : ','; |
|
358 | + foreach ($columns as $key => $column) { |
|
359 | + $column_data .= '"' . addslashes($column) . '"'; |
|
360 | + $column_data .= $i == count($columns) ? '' : ','; |
|
361 | 361 | $i++; |
362 | 362 | } |
363 | 363 | $column_data .= "\r\n"; |
364 | 364 | |
365 | - $this->attach_export_data( $column_data ); |
|
365 | + $this->attach_export_data($column_data); |
|
366 | 366 | |
367 | 367 | return $column_data; |
368 | 368 | } |
369 | 369 | |
370 | 370 | public function process_export_step() { |
371 | - if ( $this->step < 2 ) { |
|
372 | - /** @scrutinizer ignore-unhandled */ @unlink( $this->file ); |
|
371 | + if ($this->step < 2) { |
|
372 | + /** @scrutinizer ignore-unhandled */ @unlink($this->file); |
|
373 | 373 | $this->print_columns(); |
374 | 374 | } |
375 | 375 | |
376 | 376 | $return = $this->print_rows(); |
377 | 377 | |
378 | - if ( $return ) { |
|
378 | + if ($return) { |
|
379 | 379 | return true; |
380 | 380 | } else { |
381 | 381 | return false; |
@@ -384,14 +384,14 @@ discard block |
||
384 | 384 | |
385 | 385 | public function get_export_status() { |
386 | 386 | $status = 100; |
387 | - return apply_filters( 'wpinv_get_export_status_' . $this->export, $status ); |
|
387 | + return apply_filters('wpinv_get_export_status_' . $this->export, $status); |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | public function get_export_data() { |
391 | 391 | $data = array(); |
392 | 392 | |
393 | - $data = apply_filters( 'wpinv_export_get_data', $data ); |
|
394 | - $data = apply_filters( 'wpinv_export_get_data_' . $this->export, $data ); |
|
393 | + $data = apply_filters('wpinv_export_get_data', $data); |
|
394 | + $data = apply_filters('wpinv_export_get_data_' . $this->export, $data); |
|
395 | 395 | |
396 | 396 | return $data; |
397 | 397 | } |
@@ -401,20 +401,20 @@ discard block |
||
401 | 401 | $data = $this->get_export_data(); |
402 | 402 | $columns = $this->get_columns(); |
403 | 403 | |
404 | - if ( $data ) { |
|
405 | - foreach ( $data as $row ) { |
|
404 | + if ($data) { |
|
405 | + foreach ($data as $row) { |
|
406 | 406 | $i = 1; |
407 | - foreach ( $row as $key => $column ) { |
|
408 | - if ( array_key_exists( $key, $columns ) ) { |
|
409 | - $row_data .= '"' . addslashes( preg_replace( "/\"/","'", $column ) ) . '"'; |
|
410 | - $row_data .= $i == count( $columns ) ? '' : ','; |
|
407 | + foreach ($row as $key => $column) { |
|
408 | + if (array_key_exists($key, $columns)) { |
|
409 | + $row_data .= '"' . addslashes(preg_replace("/\"/", "'", $column)) . '"'; |
|
410 | + $row_data .= $i == count($columns) ? '' : ','; |
|
411 | 411 | $i++; |
412 | 412 | } |
413 | 413 | } |
414 | 414 | $row_data .= "\r\n"; |
415 | 415 | } |
416 | 416 | |
417 | - $this->attach_export_data( $row_data ); |
|
417 | + $this->attach_export_data($row_data); |
|
418 | 418 | |
419 | 419 | return $row_data; |
420 | 420 | } |
@@ -423,48 +423,48 @@ discard block |
||
423 | 423 | } |
424 | 424 | |
425 | 425 | // Export Invoices. |
426 | - public function set_invoices_export( $request ) { |
|
427 | - $this->from_date = isset( $request['from_date'] ) ? sanitize_text_field( $request['from_date'] ) : ''; |
|
428 | - $this->to_date = isset( $request['to_date'] ) ? sanitize_text_field( $request['to_date'] ) : ''; |
|
429 | - $this->status = isset( $request['status'] ) ? sanitize_text_field( $request['status'] ) : 'publish'; |
|
426 | + public function set_invoices_export($request) { |
|
427 | + $this->from_date = isset($request['from_date']) ? sanitize_text_field($request['from_date']) : ''; |
|
428 | + $this->to_date = isset($request['to_date']) ? sanitize_text_field($request['to_date']) : ''; |
|
429 | + $this->status = isset($request['status']) ? sanitize_text_field($request['status']) : 'publish'; |
|
430 | 430 | } |
431 | 431 | |
432 | - public function get_invoices_columns( $columns = array() ) { |
|
432 | + public function get_invoices_columns($columns = array()) { |
|
433 | 433 | $columns = array( |
434 | - 'id' => __( 'ID', 'invoicing' ), |
|
435 | - 'number' => __( 'Number', 'invoicing' ), |
|
436 | - 'date' => __( 'Date', 'invoicing' ), |
|
437 | - 'due_date' => __( 'Due Date', 'invoicing' ), |
|
438 | - 'completed_date'=> __( 'Payment Done Date', 'invoicing' ), |
|
439 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
440 | - 'currency' => __( 'Currency', 'invoicing' ), |
|
441 | - 'items' => __( 'Items', 'invoicing' ), |
|
442 | - 'status_nicename' => __( 'Status Nicename', 'invoicing' ), |
|
443 | - 'status' => __( 'Status', 'invoicing' ), |
|
444 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
445 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
446 | - 'user_id' => __( 'User ID', 'invoicing' ), |
|
447 | - 'email' => __( 'Email', 'invoicing' ), |
|
448 | - 'first_name' => __( 'First Name', 'invoicing' ), |
|
449 | - 'last_name' => __( 'Last Name', 'invoicing' ), |
|
450 | - 'address' => __( 'Address', 'invoicing' ), |
|
451 | - 'city' => __( 'City', 'invoicing' ), |
|
452 | - 'state' => __( 'State', 'invoicing' ), |
|
453 | - 'country' => __( 'Country', 'invoicing' ), |
|
454 | - 'zip' => __( 'Zipcode', 'invoicing' ), |
|
455 | - 'phone' => __( 'Phone', 'invoicing' ), |
|
456 | - 'company' => __( 'Company', 'invoicing' ), |
|
457 | - 'vat_number' => __( 'Vat Number', 'invoicing' ), |
|
458 | - 'ip' => __( 'IP', 'invoicing' ), |
|
459 | - 'gateway' => __( 'Gateway', 'invoicing' ), |
|
460 | - 'gateway_nicename' => __( 'Gateway Nicename', 'invoicing' ), |
|
461 | - 'transaction_id'=> __( 'Transaction ID', 'invoicing' ), |
|
434 | + 'id' => __('ID', 'invoicing'), |
|
435 | + 'number' => __('Number', 'invoicing'), |
|
436 | + 'date' => __('Date', 'invoicing'), |
|
437 | + 'due_date' => __('Due Date', 'invoicing'), |
|
438 | + 'completed_date'=> __('Payment Done Date', 'invoicing'), |
|
439 | + 'amount' => __('Amount', 'invoicing'), |
|
440 | + 'currency' => __('Currency', 'invoicing'), |
|
441 | + 'items' => __('Items', 'invoicing'), |
|
442 | + 'status_nicename' => __('Status Nicename', 'invoicing'), |
|
443 | + 'status' => __('Status', 'invoicing'), |
|
444 | + 'tax' => __('Tax', 'invoicing'), |
|
445 | + 'discount' => __('Discount', 'invoicing'), |
|
446 | + 'user_id' => __('User ID', 'invoicing'), |
|
447 | + 'email' => __('Email', 'invoicing'), |
|
448 | + 'first_name' => __('First Name', 'invoicing'), |
|
449 | + 'last_name' => __('Last Name', 'invoicing'), |
|
450 | + 'address' => __('Address', 'invoicing'), |
|
451 | + 'city' => __('City', 'invoicing'), |
|
452 | + 'state' => __('State', 'invoicing'), |
|
453 | + 'country' => __('Country', 'invoicing'), |
|
454 | + 'zip' => __('Zipcode', 'invoicing'), |
|
455 | + 'phone' => __('Phone', 'invoicing'), |
|
456 | + 'company' => __('Company', 'invoicing'), |
|
457 | + 'vat_number' => __('Vat Number', 'invoicing'), |
|
458 | + 'ip' => __('IP', 'invoicing'), |
|
459 | + 'gateway' => __('Gateway', 'invoicing'), |
|
460 | + 'gateway_nicename' => __('Gateway Nicename', 'invoicing'), |
|
461 | + 'transaction_id'=> __('Transaction ID', 'invoicing'), |
|
462 | 462 | ); |
463 | 463 | |
464 | 464 | return $columns; |
465 | 465 | } |
466 | 466 | |
467 | - public function get_invoices_data( $response = array() ) { |
|
467 | + public function get_invoices_data($response = array()) { |
|
468 | 468 | $args = array( |
469 | 469 | 'limit' => $this->per_page, |
470 | 470 | 'page' => $this->step, |
@@ -472,42 +472,42 @@ discard block |
||
472 | 472 | 'orderby' => 'date', |
473 | 473 | ); |
474 | 474 | |
475 | - if ( $this->status != 'any' ) { |
|
475 | + if ($this->status != 'any') { |
|
476 | 476 | $args['status'] = $this->status; |
477 | 477 | } else { |
478 | - $args['status'] = array_keys( wpinv_get_invoice_statuses( true ) ); |
|
478 | + $args['status'] = array_keys(wpinv_get_invoice_statuses(true)); |
|
479 | 479 | } |
480 | 480 | |
481 | - if ( !empty( $this->from_date ) || !empty( $this->to_date ) ) { |
|
481 | + if (!empty($this->from_date) || !empty($this->to_date)) { |
|
482 | 482 | $args['date_query'] = array( |
483 | 483 | array( |
484 | - 'after' => date( 'Y-n-d 00:00:00', strtotime( $this->from_date ) ), |
|
485 | - 'before' => date( 'Y-n-d 23:59:59', strtotime( $this->to_date ) ), |
|
484 | + 'after' => date('Y-n-d 00:00:00', strtotime($this->from_date)), |
|
485 | + 'before' => date('Y-n-d 23:59:59', strtotime($this->to_date)), |
|
486 | 486 | 'inclusive' => true |
487 | 487 | ) |
488 | 488 | ); |
489 | 489 | } |
490 | 490 | |
491 | - $invoices = wpinv_get_invoices( $args ); |
|
491 | + $invoices = wpinv_get_invoices($args); |
|
492 | 492 | |
493 | 493 | $data = array(); |
494 | 494 | |
495 | - if ( !empty( $invoices ) ) { |
|
496 | - foreach ( $invoices as $invoice ) { |
|
495 | + if (!empty($invoices)) { |
|
496 | + foreach ($invoices as $invoice) { |
|
497 | 497 | $items = $this->get_invoice_items($invoice); |
498 | 498 | $row = array( |
499 | 499 | 'id' => $invoice->ID, |
500 | 500 | 'number' => $invoice->get_number(), |
501 | - 'date' => $invoice->get_invoice_date( false ), |
|
502 | - 'due_date' => $invoice->get_due_date( false ), |
|
501 | + 'date' => $invoice->get_invoice_date(false), |
|
502 | + 'due_date' => $invoice->get_due_date(false), |
|
503 | 503 | 'completed_date'=> $invoice->get_completed_date(), |
504 | - 'amount' => wpinv_round_amount( $invoice->get_total() ), |
|
504 | + 'amount' => wpinv_round_amount($invoice->get_total()), |
|
505 | 505 | 'currency' => $invoice->get_currency(), |
506 | 506 | 'items' => $items, |
507 | - 'status_nicename' => $invoice->get_status( true ), |
|
507 | + 'status_nicename' => $invoice->get_status(true), |
|
508 | 508 | 'status' => $invoice->get_status(), |
509 | - 'tax' => $invoice->get_tax() > 0 ? wpinv_round_amount( $invoice->get_tax() ) : '', |
|
510 | - 'discount' => $invoice->get_discount() > 0 ? wpinv_round_amount( $invoice->get_discount() ) : '', |
|
509 | + 'tax' => $invoice->get_tax() > 0 ? wpinv_round_amount($invoice->get_tax()) : '', |
|
510 | + 'discount' => $invoice->get_discount() > 0 ? wpinv_round_amount($invoice->get_discount()) : '', |
|
511 | 511 | 'user_id' => $invoice->get_user_id(), |
512 | 512 | 'email' => $invoice->get_email(), |
513 | 513 | 'first_name' => $invoice->get_first_name(), |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | 'transaction_id'=> $invoice->gateway ? $invoice->get_transaction_id() : '', |
527 | 527 | ); |
528 | 528 | |
529 | - $data[] = apply_filters( 'wpinv_export_invoice_row', $row, $invoice ); |
|
529 | + $data[] = apply_filters('wpinv_export_invoice_row', $row, $invoice); |
|
530 | 530 | } |
531 | 531 | |
532 | 532 | return $data; |
@@ -542,44 +542,44 @@ discard block |
||
542 | 542 | 'return' => 'ids', |
543 | 543 | ); |
544 | 544 | |
545 | - if ( $this->status != 'any' ) { |
|
545 | + if ($this->status != 'any') { |
|
546 | 546 | $args['status'] = $this->status; |
547 | 547 | } else { |
548 | - $args['status'] = array_keys( wpinv_get_invoice_statuses( true ) ); |
|
548 | + $args['status'] = array_keys(wpinv_get_invoice_statuses(true)); |
|
549 | 549 | } |
550 | 550 | |
551 | - if ( !empty( $this->from_date ) || !empty( $this->to_date ) ) { |
|
551 | + if (!empty($this->from_date) || !empty($this->to_date)) { |
|
552 | 552 | $args['date_query'] = array( |
553 | 553 | array( |
554 | - 'after' => date( 'Y-n-d 00:00:00', strtotime( $this->from_date ) ), |
|
555 | - 'before' => date( 'Y-n-d 23:59:59', strtotime( $this->to_date ) ), |
|
554 | + 'after' => date('Y-n-d 00:00:00', strtotime($this->from_date)), |
|
555 | + 'before' => date('Y-n-d 23:59:59', strtotime($this->to_date)), |
|
556 | 556 | 'inclusive' => true |
557 | 557 | ) |
558 | 558 | ); |
559 | 559 | } |
560 | 560 | |
561 | - $invoices = wpinv_get_invoices( $args ); |
|
562 | - $total = !empty( $invoices ) ? count( $invoices ) : 0; |
|
561 | + $invoices = wpinv_get_invoices($args); |
|
562 | + $total = !empty($invoices) ? count($invoices) : 0; |
|
563 | 563 | $status = 100; |
564 | 564 | |
565 | - if ( $total > 0 ) { |
|
566 | - $status = ( ( $this->per_page * $this->step ) / $total ) * 100; |
|
565 | + if ($total > 0) { |
|
566 | + $status = (($this->per_page * $this->step) / $total) * 100; |
|
567 | 567 | } |
568 | 568 | |
569 | - if ( $status > 100 ) { |
|
569 | + if ($status > 100) { |
|
570 | 570 | $status = 100; |
571 | 571 | } |
572 | 572 | |
573 | 573 | return $status; |
574 | 574 | } |
575 | 575 | |
576 | - public function get_invoice_items($invoice){ |
|
577 | - if(!$invoice){ |
|
576 | + public function get_invoice_items($invoice) { |
|
577 | + if (!$invoice) { |
|
578 | 578 | return ''; |
579 | 579 | } |
580 | 580 | |
581 | 581 | $cart_details = $invoice->get_cart_details(); |
582 | - if(!empty($cart_details)){ |
|
582 | + if (!empty($cart_details)) { |
|
583 | 583 | $cart_details = maybe_serialize($cart_details); |
584 | 584 | } else { |
585 | 585 | $cart_details = ''; |
@@ -1,35 +1,35 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | class WPInv_Meta_Box_Billing_Details { |
8 | - public static function output( $post ) { |
|
8 | + public static function output($post) { |
|
9 | 9 | global $user_ID; |
10 | - $post_id = !empty( $post->ID ) ? $post->ID : 0; |
|
11 | - $invoice = new WPInv_Invoice( $post_id ); |
|
10 | + $post_id = !empty($post->ID) ? $post->ID : 0; |
|
11 | + $invoice = new WPInv_Invoice($post_id); |
|
12 | 12 | |
13 | 13 | ?> |
14 | 14 | <div class="gdmbx2-wrap form-table"> |
15 | 15 | <div id="gdmbx2-metabox-wpinv_address" class="gdmbx2-metabox gdmbx-field-list wpinv-address gdmbx-row"> |
16 | 16 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-user-id table-layout"> |
17 | 17 | <div class="gdmbx-th"> |
18 | - <label for="post_author_override"><?php _e( 'Customer', 'invoicing' );?></label> |
|
18 | + <label for="post_author_override"><?php _e('Customer', 'invoicing'); ?></label> |
|
19 | 19 | </div> |
20 | 20 | <div class="gdmbx-td gdmbx-customer-div"> |
21 | - <?php wpinv_dropdown_users( array( |
|
21 | + <?php wpinv_dropdown_users(array( |
|
22 | 22 | 'name' => 'post_author_override', |
23 | 23 | 'selected' => empty($post->ID) ? $user_ID : $post->post_author, |
24 | 24 | 'include_selected' => true, |
25 | 25 | 'show' => 'display_name_with_email', |
26 | 26 | 'orderby' => 'user_email', |
27 | 27 | 'class' => 'gdmbx2-text-large wpi_select2' |
28 | - ) ); ?> |
|
28 | + )); ?> |
|
29 | 29 | </div> |
30 | 30 | </div> |
31 | 31 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-email table-layout" style="display:none"> |
32 | - <div class="gdmbx-th"><label for="wpinv_email"><?php _e( 'Email', 'invoicing' );?> <span class="required">*</span></label> |
|
32 | + <div class="gdmbx-th"><label for="wpinv_email"><?php _e('Email', 'invoicing'); ?> <span class="required">*</span></label> |
|
33 | 33 | </div> |
34 | 34 | <div class="gdmbx-td"> |
35 | 35 | <input type="hidden" id="wpinv_new_user" name="wpinv_new_user" value="" /> |
@@ -37,137 +37,137 @@ discard block |
||
37 | 37 | </div> |
38 | 38 | </div> |
39 | 39 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-btns table-layout"> |
40 | - <div class="gdmbx-th"><label><?php _e( 'Actions', 'invoicing' );?></label> |
|
40 | + <div class="gdmbx-th"><label><?php _e('Actions', 'invoicing'); ?></label> |
|
41 | 41 | </div> |
42 | - <?php if ( $invoice->has_status( array( 'auto-draft', 'draft', 'wpi-pending', 'wpi-quote-pending' ) ) ) { ?> |
|
42 | + <?php if ($invoice->has_status(array('auto-draft', 'draft', 'wpi-pending', 'wpi-quote-pending'))) { ?> |
|
43 | 43 | <div class="gdmbx-td"> |
44 | - <a id="wpinv-fill-user-details" class="button button-small button-secondary" title="<?php esc_attr_e( 'Fill User Details', 'invoicing' );?>" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-refresh"></i><?php _e( 'Fill User Details', 'invoicing' );?></a> |
|
45 | - <a class="wpinv-new-user button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-plus"></i><?php _e( 'Add New User', 'invoicing' );?></a> |
|
46 | - <a style="display:none" class="wpinv-new-cancel button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-close"></i><?php _e( 'Cancel', 'invoicing' );?> </a> |
|
44 | + <a id="wpinv-fill-user-details" class="button button-small button-secondary" title="<?php esc_attr_e('Fill User Details', 'invoicing'); ?>" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-refresh"></i><?php _e('Fill User Details', 'invoicing'); ?></a> |
|
45 | + <a class="wpinv-new-user button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-plus"></i><?php _e('Add New User', 'invoicing'); ?></a> |
|
46 | + <a style="display:none" class="wpinv-new-cancel button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-close"></i><?php _e('Cancel', 'invoicing'); ?> </a> |
|
47 | 47 | </div> |
48 | 48 | <?php } ?> |
49 | 49 | </div> |
50 | 50 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-first-name table-layout"> |
51 | - <div class="gdmbx-th"><label for="wpinv_first_name"><?php _e( 'First Name', 'invoicing' );?></label></div> |
|
51 | + <div class="gdmbx-th"><label for="wpinv_first_name"><?php _e('First Name', 'invoicing'); ?></label></div> |
|
52 | 52 | <div class="gdmbx-td"> |
53 | - <input type="text" class="gdmbx2-text-large" name="wpinv_first_name" id="wpinv_first_name" value="<?php echo esc_attr( $invoice->first_name );?>" /> |
|
53 | + <input type="text" class="gdmbx2-text-large" name="wpinv_first_name" id="wpinv_first_name" value="<?php echo esc_attr($invoice->first_name); ?>" /> |
|
54 | 54 | </div> |
55 | 55 | </div> |
56 | 56 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-last-name table-layout"> |
57 | - <div class="gdmbx-th"><label for="wpinv_last_name"><?php _e( 'Last Name', 'invoicing' );?></label></div> |
|
57 | + <div class="gdmbx-th"><label for="wpinv_last_name"><?php _e('Last Name', 'invoicing'); ?></label></div> |
|
58 | 58 | <div class="gdmbx-td"> |
59 | - <input type="text" class="gdmbx2-text-large" name="wpinv_last_name" id="wpinv_last_name" value="<?php echo esc_attr( $invoice->last_name );?>" /> |
|
59 | + <input type="text" class="gdmbx2-text-large" name="wpinv_last_name" id="wpinv_last_name" value="<?php echo esc_attr($invoice->last_name); ?>" /> |
|
60 | 60 | </div> |
61 | 61 | </div> |
62 | 62 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-company table-layout"> |
63 | - <div class="gdmbx-th"><label for="wpinv_company"><?php _e( 'Company', 'invoicing' );?></label></div> |
|
63 | + <div class="gdmbx-th"><label for="wpinv_company"><?php _e('Company', 'invoicing'); ?></label></div> |
|
64 | 64 | <div class="gdmbx-td"> |
65 | - <input type="text" class="gdmbx2-text-large" name="wpinv_company" id="wpinv_company" value="<?php echo esc_attr( $invoice->company );?>" /> |
|
65 | + <input type="text" class="gdmbx2-text-large" name="wpinv_company" id="wpinv_company" value="<?php echo esc_attr($invoice->company); ?>" /> |
|
66 | 66 | </div> |
67 | 67 | </div> |
68 | 68 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-vat-number table-layout"> |
69 | - <div class="gdmbx-th"><label for="wpinv_vat_number"><?php _e( 'Vat Number', 'invoicing' );?></label></div> |
|
69 | + <div class="gdmbx-th"><label for="wpinv_vat_number"><?php _e('Vat Number', 'invoicing'); ?></label></div> |
|
70 | 70 | <div class="gdmbx-td"> |
71 | - <input type="text" class="gdmbx2-text-large" name="wpinv_vat_number" id="wpinv_vat_number" value="<?php echo esc_attr( $invoice->vat_number );?>" /> |
|
71 | + <input type="text" class="gdmbx2-text-large" name="wpinv_vat_number" id="wpinv_vat_number" value="<?php echo esc_attr($invoice->vat_number); ?>" /> |
|
72 | 72 | </div> |
73 | 73 | </div> |
74 | 74 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-address table-layout"> |
75 | - <div class="gdmbx-th"><label for="wpinv_address"><?php _e( 'Address', 'invoicing' );?></label></div> |
|
75 | + <div class="gdmbx-th"><label for="wpinv_address"><?php _e('Address', 'invoicing'); ?></label></div> |
|
76 | 76 | <div class="gdmbx-td"> |
77 | - <input type="text" class="gdmbx2-text-large" name="wpinv_address" id="wpinv_address" value="<?php echo esc_attr( $invoice->address );?>" /> |
|
77 | + <input type="text" class="gdmbx2-text-large" name="wpinv_address" id="wpinv_address" value="<?php echo esc_attr($invoice->address); ?>" /> |
|
78 | 78 | </div> |
79 | 79 | </div> |
80 | 80 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-city table-layout"> |
81 | - <div class="gdmbx-th"><label for="wpinv_city"><?php _e( 'City', 'invoicing' );?></label></div> |
|
81 | + <div class="gdmbx-th"><label for="wpinv_city"><?php _e('City', 'invoicing'); ?></label></div> |
|
82 | 82 | <div class="gdmbx-td"> |
83 | - <input type="text" class="gdmbx2-text-large" name="wpinv_city" id="wpinv_city" value="<?php echo esc_attr( $invoice->city );?>" /> |
|
83 | + <input type="text" class="gdmbx2-text-large" name="wpinv_city" id="wpinv_city" value="<?php echo esc_attr($invoice->city); ?>" /> |
|
84 | 84 | </div> |
85 | 85 | </div> |
86 | 86 | <div class="gdmbx-row gdmbx-type-select gdmbx-wpinv-country table-layout"> |
87 | - <div class="gdmbx-th"><label for="wpinv_country"><?php _e( 'Country', 'invoicing' );?> <span class="wpi-loader"><i class="fa fa-refresh fa-spin"></i></span></label></div> |
|
87 | + <div class="gdmbx-th"><label for="wpinv_country"><?php _e('Country', 'invoicing'); ?> <span class="wpi-loader"><i class="fa fa-refresh fa-spin"></i></span></label></div> |
|
88 | 88 | <div class="gdmbx-td"> |
89 | 89 | <?php |
90 | - echo wpinv_html_select( array( |
|
91 | - 'options' => array_merge( array( '' => __( 'Choose a country', 'invoicing' ) ), wpinv_get_country_list() ), |
|
90 | + echo wpinv_html_select(array( |
|
91 | + 'options' => array_merge(array('' => __('Choose a country', 'invoicing')), wpinv_get_country_list()), |
|
92 | 92 | 'name' => 'wpinv_country', |
93 | 93 | 'id' => 'wpinv_country', |
94 | 94 | 'selected' => $invoice->country, |
95 | 95 | 'show_option_all' => false, |
96 | 96 | 'show_option_none' => false, |
97 | 97 | 'class' => 'gdmbx2-text-large wpi_select2', |
98 | - 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
98 | + 'placeholder' => __('Choose a country', 'invoicing'), |
|
99 | 99 | 'required' => false, |
100 | - ) ); |
|
100 | + )); |
|
101 | 101 | ?> |
102 | 102 | </div> |
103 | 103 | </div> |
104 | 104 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-state table-layout"> |
105 | - <div class="gdmbx-th"><label for="wpinv_state"><?php _e( 'State', 'invoicing' );?></label></div> |
|
105 | + <div class="gdmbx-th"><label for="wpinv_state"><?php _e('State', 'invoicing'); ?></label></div> |
|
106 | 106 | <div class="gdmbx-td"> |
107 | 107 | <?php |
108 | - $states = wpinv_get_country_states( $invoice->country ); |
|
109 | - if( !empty( $states ) ) { |
|
110 | - echo wpinv_html_select( array( |
|
111 | - 'options' => array_merge( array( '' => __( 'Choose a state', 'invoicing' ) ), $states ), |
|
108 | + $states = wpinv_get_country_states($invoice->country); |
|
109 | + if (!empty($states)) { |
|
110 | + echo wpinv_html_select(array( |
|
111 | + 'options' => array_merge(array('' => __('Choose a state', 'invoicing')), $states), |
|
112 | 112 | 'name' => 'wpinv_state', |
113 | 113 | 'id' => 'wpinv_state', |
114 | 114 | 'selected' => $invoice->state, |
115 | 115 | 'show_option_all' => false, |
116 | 116 | 'show_option_none' => false, |
117 | 117 | 'class' => 'gdmbx2-text-large wpi_select2', |
118 | - 'placeholder' => __( 'Choose a state', 'invoicing' ), |
|
118 | + 'placeholder' => __('Choose a state', 'invoicing'), |
|
119 | 119 | 'required' => false, |
120 | - ) ); |
|
120 | + )); |
|
121 | 121 | } else { |
122 | - echo wpinv_html_text( array( |
|
122 | + echo wpinv_html_text(array( |
|
123 | 123 | 'name' => 'wpinv_state', |
124 | - 'value' => ! empty( $invoice->state ) ? $invoice->state : '', |
|
124 | + 'value' => !empty($invoice->state) ? $invoice->state : '', |
|
125 | 125 | 'id' => 'wpinv_state', |
126 | 126 | 'class' => 'gdmbx2-text-large', |
127 | 127 | 'required' => false, |
128 | - ) ); |
|
128 | + )); |
|
129 | 129 | } |
130 | 130 | ?> |
131 | 131 | </div> |
132 | 132 | </div> |
133 | 133 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-zip table-layout"> |
134 | - <div class="gdmbx-th"><label for="wpinv_zip"><?php _e( 'Zipcode', 'invoicing' );?></label></div> |
|
134 | + <div class="gdmbx-th"><label for="wpinv_zip"><?php _e('Zipcode', 'invoicing'); ?></label></div> |
|
135 | 135 | <div class="gdmbx-td"> |
136 | - <input type="text" class="gdmbx2-text-large" name="wpinv_zip" id="wpinv_zip" value="<?php echo esc_attr( $invoice->zip );?>" /> |
|
136 | + <input type="text" class="gdmbx2-text-large" name="wpinv_zip" id="wpinv_zip" value="<?php echo esc_attr($invoice->zip); ?>" /> |
|
137 | 137 | </div> |
138 | 138 | </div> |
139 | 139 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-phone table-layout"> |
140 | - <div class="gdmbx-th"><label for="wpinv_phone"><?php _e( 'Phone', 'invoicing' );?></label></div> |
|
140 | + <div class="gdmbx-th"><label for="wpinv_phone"><?php _e('Phone', 'invoicing'); ?></label></div> |
|
141 | 141 | <div class="gdmbx-td"> |
142 | - <input type="text" class="gdmbx2-text-large" name="wpinv_phone" id="wpinv_phone" value="<?php echo esc_attr( $invoice->phone );?>" /> |
|
142 | + <input type="text" class="gdmbx2-text-large" name="wpinv_phone" id="wpinv_phone" value="<?php echo esc_attr($invoice->phone); ?>" /> |
|
143 | 143 | </div> |
144 | 144 | </div> |
145 | 145 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-ip table-layout"> |
146 | - <div class="gdmbx-th"><label for="wpinv_ip"><?php _e( 'IP Address', 'invoicing' );?><?php if ($invoice->ip) { ?> |
|
147 | - <a href="<?php echo admin_url( 'admin-ajax.php?action=wpinv_ip_geolocation&ip=' . $invoice->ip ); ?>" title="<?php esc_attr_e( 'View IP information', 'invoicing' );?>" target="_blank"><i class="fa fa-external-link" aria-hidden="true"></i></a> |
|
146 | + <div class="gdmbx-th"><label for="wpinv_ip"><?php _e('IP Address', 'invoicing'); ?><?php if ($invoice->ip) { ?> |
|
147 | + <a href="<?php echo admin_url('admin-ajax.php?action=wpinv_ip_geolocation&ip=' . $invoice->ip); ?>" title="<?php esc_attr_e('View IP information', 'invoicing'); ?>" target="_blank"><i class="fa fa-external-link" aria-hidden="true"></i></a> |
|
148 | 148 | <?php } ?></label></div> |
149 | 149 | <div class="gdmbx-td"> |
150 | - <input type="text" class="gdmbx2-text-large" value="<?php echo esc_attr( $invoice->ip );?>" readonly /> |
|
150 | + <input type="text" class="gdmbx2-text-large" value="<?php echo esc_attr($invoice->ip); ?>" readonly /> |
|
151 | 151 | </div> |
152 | 152 | </div> |
153 | 153 | |
154 | - <?php if( ! $invoice->is_paid() ) { ?> |
|
154 | + <?php if (!$invoice->is_paid()) { ?> |
|
155 | 155 | |
156 | 156 | <div class="gdmbx-row gdmbx-type-select gdmbx-wpinv-currency table-layout"> |
157 | - <div class="gdmbx-th"><label for="wpinv_currency"><?php _e( 'Currency', 'invoicing' );?></label></div> |
|
157 | + <div class="gdmbx-th"><label for="wpinv_currency"><?php _e('Currency', 'invoicing'); ?></label></div> |
|
158 | 158 | <div class="gdmbx-td"> |
159 | 159 | <?php |
160 | - echo wpinv_html_select( array( |
|
161 | - 'options' => array_merge( array( '' => __( 'Currency for the invoice', 'invoicing' ) ), wpinv_get_currencies() ), |
|
160 | + echo wpinv_html_select(array( |
|
161 | + 'options' => array_merge(array('' => __('Currency for the invoice', 'invoicing')), wpinv_get_currencies()), |
|
162 | 162 | 'name' => 'wpinv_currency', |
163 | 163 | 'id' => 'wpinv_currency', |
164 | 164 | 'selected' => $invoice->get_currency(), |
165 | 165 | 'show_option_all' => false, |
166 | 166 | 'show_option_none' => false, |
167 | 167 | 'class' => 'gdmbx2-text-large wpi_select2', |
168 | - 'placeholder' => __( 'Choose a currency', 'invoicing' ), |
|
168 | + 'placeholder' => __('Choose a currency', 'invoicing'), |
|
169 | 169 | 'required' => true, |
170 | - ) ); |
|
170 | + )); |
|
171 | 171 | ?> |
172 | 172 | </div> |
173 | 173 | </div> |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | <?php } ?> |
176 | 176 | </div> |
177 | 177 | </div> |
178 | -<?php wp_nonce_field( 'wpinv_save_invoice', 'wpinv_save_invoice' ) ;?> |
|
178 | +<?php wp_nonce_field('wpinv_save_invoice', 'wpinv_save_invoice'); ?> |
|
179 | 179 | <?php |
180 | 180 | } |
181 | 181 | } |
@@ -12,19 +12,19 @@ |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // MUST have WordPress. |
15 | -if ( !defined( 'WPINC' ) ) { |
|
16 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
15 | +if (!defined('WPINC')) { |
|
16 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
17 | 17 | } |
18 | 18 | |
19 | -if ( !defined( 'WPINV_VERSION' ) ) { |
|
20 | - define( 'WPINV_VERSION', '1.0.17' ); |
|
19 | +if (!defined('WPINV_VERSION')) { |
|
20 | + define('WPINV_VERSION', '1.0.17'); |
|
21 | 21 | } |
22 | 22 | |
23 | -if ( !defined( 'WPINV_PLUGIN_FILE' ) ) { |
|
24 | - define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
23 | +if (!defined('WPINV_PLUGIN_FILE')) { |
|
24 | + define('WPINV_PLUGIN_FILE', __FILE__); |
|
25 | 25 | } |
26 | 26 | |
27 | -require plugin_dir_path( __FILE__ ) . 'includes/class-wpinv.php'; |
|
27 | +require plugin_dir_path(__FILE__) . 'includes/class-wpinv.php'; |
|
28 | 28 | |
29 | 29 | function wpinv_run() { |
30 | 30 | global $invoicing; |
@@ -1,47 +1,47 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | class WPInv_Meta_Box_Items { |
8 | - public static function output( $post ) { |
|
8 | + public static function output($post) { |
|
9 | 9 | global $wpinv_euvat, $ajax_cart_details; |
10 | 10 | |
11 | - $post_id = !empty( $post->ID ) ? $post->ID : 0; |
|
12 | - $invoice = new WPInv_Invoice( $post_id ); |
|
11 | + $post_id = !empty($post->ID) ? $post->ID : 0; |
|
12 | + $invoice = new WPInv_Invoice($post_id); |
|
13 | 13 | $ajax_cart_details = $invoice->get_cart_details(); |
14 | - $subtotal = $invoice->get_subtotal( true ); |
|
14 | + $subtotal = $invoice->get_subtotal(true); |
|
15 | 15 | $discount_raw = $invoice->get_discount(); |
16 | - $discount = wpinv_price( $discount_raw, $invoice->get_currency() ); |
|
16 | + $discount = wpinv_price($discount_raw, $invoice->get_currency()); |
|
17 | 17 | $discounts = $discount_raw > 0 ? $invoice->get_discounts() : ''; |
18 | - $tax = $invoice->get_tax( true ); |
|
19 | - $total = $invoice->get_total( true ); |
|
18 | + $tax = $invoice->get_tax(true); |
|
19 | + $total = $invoice->get_total(true); |
|
20 | 20 | $item_quantities = wpinv_item_quantities_enabled(); |
21 | 21 | $use_taxes = wpinv_use_taxes(); |
22 | - if ( !$use_taxes && (float)$invoice->get_tax() > 0 ) { |
|
22 | + if (!$use_taxes && (float) $invoice->get_tax() > 0) { |
|
23 | 23 | $use_taxes = true; |
24 | 24 | } |
25 | - $item_types = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post ); |
|
25 | + $item_types = apply_filters('wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post); |
|
26 | 26 | $is_recurring = $invoice->is_recurring(); |
27 | 27 | $post_type_object = get_post_type_object($invoice->post_type); |
28 | 28 | $type_title = $post_type_object->labels->singular_name; |
29 | 29 | |
30 | 30 | $cols = 5; |
31 | - if ( $item_quantities ) { |
|
31 | + if ($item_quantities) { |
|
32 | 32 | $cols++; |
33 | 33 | } |
34 | - if ( $use_taxes ) { |
|
34 | + if ($use_taxes) { |
|
35 | 35 | $cols++; |
36 | 36 | } |
37 | 37 | $class = ''; |
38 | - if ( $invoice->is_paid() ) { |
|
38 | + if ($invoice->is_paid()) { |
|
39 | 39 | $class .= ' wpinv-paid'; |
40 | 40 | } |
41 | - if ( $invoice->is_refunded() ) { |
|
41 | + if ($invoice->is_refunded()) { |
|
42 | 42 | $class .= ' wpinv-refunded'; |
43 | 43 | } |
44 | - if ( $is_recurring ) { |
|
44 | + if ($is_recurring) { |
|
45 | 45 | $class .= ' wpi-recurring'; |
46 | 46 | } |
47 | 47 | ?> |
@@ -49,21 +49,21 @@ discard block |
||
49 | 49 | <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0"> |
50 | 50 | <thead> |
51 | 51 | <tr> |
52 | - <th class="id"><?php _e( 'ID', 'invoicing' );?></th> |
|
53 | - <th class="title"><?php _e( 'Item', 'invoicing' );?></th> |
|
54 | - <th class="price"><?php _e( 'Price', 'invoicing' );?></th> |
|
55 | - <?php if ( $item_quantities ) { ?> |
|
56 | - <th class="qty"><?php _e( 'Qty', 'invoicing' );?></th> |
|
52 | + <th class="id"><?php _e('ID', 'invoicing'); ?></th> |
|
53 | + <th class="title"><?php _e('Item', 'invoicing'); ?></th> |
|
54 | + <th class="price"><?php _e('Price', 'invoicing'); ?></th> |
|
55 | + <?php if ($item_quantities) { ?> |
|
56 | + <th class="qty"><?php _e('Qty', 'invoicing'); ?></th> |
|
57 | 57 | <?php } ?> |
58 | - <th class="total"><?php _e( 'Total', 'invoicing' );?></th> |
|
59 | - <?php if ( $use_taxes ) { ?> |
|
60 | - <th class="tax"><?php _e( 'Tax (%)', 'invoicing' );?></th> |
|
58 | + <th class="total"><?php _e('Total', 'invoicing'); ?></th> |
|
59 | + <?php if ($use_taxes) { ?> |
|
60 | + <th class="tax"><?php _e('Tax (%)', 'invoicing'); ?></th> |
|
61 | 61 | <?php } ?> |
62 | 62 | <th class="action"></th> |
63 | 63 | </tr> |
64 | 64 | </thead> |
65 | 65 | <tbody class="wpinv-line-items"> |
66 | - <?php echo wpinv_admin_get_line_items( $invoice ); ?> |
|
66 | + <?php echo wpinv_admin_get_line_items($invoice); ?> |
|
67 | 67 | </tbody> |
68 | 68 | <tfoot class="wpinv-totals"> |
69 | 69 | <tr> |
@@ -74,45 +74,45 @@ discard block |
||
74 | 74 | <td class="id"> |
75 | 75 | </td> |
76 | 76 | <td class="title"> |
77 | - <input type="text" class="regular-text" placeholder="<?php _e( 'Item Name', 'invoicing' ); ?>" value="" name="_wpinv_quick[name]"> |
|
78 | - <?php if ( $wpinv_euvat->allow_vat_rules() ) { ?> |
|
77 | + <input type="text" class="regular-text" placeholder="<?php _e('Item Name', 'invoicing'); ?>" value="" name="_wpinv_quick[name]"> |
|
78 | + <?php if ($wpinv_euvat->allow_vat_rules()) { ?> |
|
79 | 79 | <div class="wp-clearfix"> |
80 | 80 | <label class="wpi-vat-rule"> |
81 | - <span class="title"><?php _e( 'VAT rule type', 'invoicing' );?></span> |
|
81 | + <span class="title"><?php _e('VAT rule type', 'invoicing'); ?></span> |
|
82 | 82 | <span class="input-text-wrap"> |
83 | - <?php echo wpinv_html_select( array( |
|
83 | + <?php echo wpinv_html_select(array( |
|
84 | 84 | 'options' => $wpinv_euvat->get_rules(), |
85 | 85 | 'name' => '_wpinv_quick[vat_rule]', |
86 | 86 | 'id' => '_wpinv_quick_vat_rule', |
87 | 87 | 'show_option_all' => false, |
88 | 88 | 'show_option_none' => false, |
89 | 89 | 'class' => 'gdmbx2-text-medium wpinv-quick-vat-rule wpi_select2', |
90 | - ) ); ?> |
|
90 | + )); ?> |
|
91 | 91 | </span> |
92 | 92 | </label> |
93 | 93 | </div> |
94 | - <?php } if ( $wpinv_euvat->allow_vat_classes() ) { ?> |
|
94 | + <?php } if ($wpinv_euvat->allow_vat_classes()) { ?> |
|
95 | 95 | <div class="wp-clearfix"> |
96 | 96 | <label class="wpi-vat-class"> |
97 | - <span class="title"><?php _e( 'VAT class', 'invoicing' );?></span> |
|
97 | + <span class="title"><?php _e('VAT class', 'invoicing'); ?></span> |
|
98 | 98 | <span class="input-text-wrap"> |
99 | - <?php echo wpinv_html_select( array( |
|
99 | + <?php echo wpinv_html_select(array( |
|
100 | 100 | 'options' => $wpinv_euvat->get_all_classes(), |
101 | 101 | 'name' => '_wpinv_quick[vat_class]', |
102 | 102 | 'id' => '_wpinv_quick_vat_class', |
103 | 103 | 'show_option_all' => false, |
104 | 104 | 'show_option_none' => false, |
105 | 105 | 'class' => 'gdmbx2-text-medium wpinv-quick-vat-class wpi_select2', |
106 | - ) ); ?> |
|
106 | + )); ?> |
|
107 | 107 | </span> |
108 | 108 | </label> |
109 | 109 | </div> |
110 | 110 | <?php } ?> |
111 | 111 | <div class="wp-clearfix"> |
112 | 112 | <label class="wpi-item-type"> |
113 | - <span class="title"><?php _e( 'Item type', 'invoicing' );?></span> |
|
113 | + <span class="title"><?php _e('Item type', 'invoicing'); ?></span> |
|
114 | 114 | <span class="input-text-wrap"> |
115 | - <?php echo wpinv_html_select( array( |
|
115 | + <?php echo wpinv_html_select(array( |
|
116 | 116 | 'options' => $item_types, |
117 | 117 | 'name' => '_wpinv_quick[type]', |
118 | 118 | 'id' => '_wpinv_quick_type', |
@@ -120,37 +120,37 @@ discard block |
||
120 | 120 | 'show_option_all' => false, |
121 | 121 | 'show_option_none' => false, |
122 | 122 | 'class' => 'gdmbx2-text-medium wpinv-quick-type wpi_select2', |
123 | - ) ); ?> |
|
123 | + )); ?> |
|
124 | 124 | </span> |
125 | 125 | </label> |
126 | 126 | </div> |
127 | 127 | |
128 | 128 | <div class="wp-clearfix"> |
129 | 129 | <?php |
130 | - echo wpinv_html_textarea( array( |
|
130 | + echo wpinv_html_textarea(array( |
|
131 | 131 | 'name' => '_wpinv_quick[excerpt]', |
132 | 132 | 'id' => '_wpinv_quick_excerpt', |
133 | 133 | 'value' => '', |
134 | 134 | 'class' => 'large-text', |
135 | - 'label' => __( 'Item description', 'invoicing' ), |
|
136 | - ) ); |
|
135 | + 'label' => __('Item description', 'invoicing'), |
|
136 | + )); |
|
137 | 137 | ?> |
138 | 138 | </div> |
139 | 139 | |
140 | 140 | <div class="wp-clearfix"> |
141 | 141 | <label class="wpi-item-actions"> |
142 | 142 | <span class="input-text-wrap"> |
143 | - <input type="button" value="<?php esc_attr_e( 'Add', 'invoicing' ); ?>" class="button button-primary" id="wpinv-save-item"><input type="button" value="Cancel" class="button button-secondary" id="wpinv-cancel-item"> |
|
143 | + <input type="button" value="<?php esc_attr_e('Add', 'invoicing'); ?>" class="button button-primary" id="wpinv-save-item"><input type="button" value="Cancel" class="button button-secondary" id="wpinv-cancel-item"> |
|
144 | 144 | </span> |
145 | 145 | </label> |
146 | 146 | </div> |
147 | 147 | </td> |
148 | 148 | <td class="price"><input type="text" placeholder="0.00" class="wpi-field-price wpi-price" name="_wpinv_quick[price]" /></td> |
149 | - <?php if ( $item_quantities ) { ?> |
|
149 | + <?php if ($item_quantities) { ?> |
|
150 | 150 | <td class="qty"><input type="number" class="small-text" step="1" min="1" value="1" name="_wpinv_quick[qty]" /></td> |
151 | 151 | <?php } ?> |
152 | 152 | <td class="total"></td> |
153 | - <?php if ( $use_taxes ) { ?> |
|
153 | + <?php if ($use_taxes) { ?> |
|
154 | 154 | <td class="tax"></td> |
155 | 155 | <?php } ?> |
156 | 156 | <td class="action"></td> |
@@ -163,29 +163,29 @@ discard block |
||
163 | 163 | <td colspan="<?php echo $cols; ?>"></td> |
164 | 164 | </tr> |
165 | 165 | <tr class="totals"> |
166 | - <td colspan="<?php echo ( $cols - 4 ); ?>"></td> |
|
166 | + <td colspan="<?php echo ($cols - 4); ?>"></td> |
|
167 | 167 | <td colspan="4"> |
168 | 168 | <table cellspacing="0" cellpadding="0"> |
169 | 169 | <tr class="subtotal"> |
170 | - <td class="name"><?php _e( 'Sub Total:', 'invoicing' );?></td> |
|
171 | - <td class="total"><?php echo $subtotal;?></td> |
|
170 | + <td class="name"><?php _e('Sub Total:', 'invoicing'); ?></td> |
|
171 | + <td class="total"><?php echo $subtotal; ?></td> |
|
172 | 172 | <td class="action"></td> |
173 | 173 | </tr> |
174 | 174 | <tr class="discount"> |
175 | - <td class="name"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice->ID ) ); ?>:</td> |
|
176 | - <td class="total"><?php echo wpinv_discount( $invoice->ID, true, true ); ?></td> |
|
175 | + <td class="name"><?php wpinv_get_discount_label(wpinv_discount_code($invoice->ID)); ?>:</td> |
|
176 | + <td class="total"><?php echo wpinv_discount($invoice->ID, true, true); ?></td> |
|
177 | 177 | <td class="action"></td> |
178 | 178 | </tr> |
179 | - <?php if ( $use_taxes ) { ?> |
|
179 | + <?php if ($use_taxes) { ?> |
|
180 | 180 | <tr class="tax"> |
181 | - <td class="name"><?php _e( 'Tax:', 'invoicing' );?></td> |
|
182 | - <td class="total"><?php echo $tax;?></td> |
|
181 | + <td class="name"><?php _e('Tax:', 'invoicing'); ?></td> |
|
182 | + <td class="total"><?php echo $tax; ?></td> |
|
183 | 183 | <td class="action"></td> |
184 | 184 | </tr> |
185 | 185 | <?php } ?> |
186 | 186 | <tr class="total"> |
187 | - <td class="name"><?php echo apply_filters( 'wpinv_invoice_items_total_label', __( 'Invoice Total:', 'invoicing' ), $invoice );?></td> |
|
188 | - <td class="total"><?php echo $total;?></td> |
|
187 | + <td class="name"><?php echo apply_filters('wpinv_invoice_items_total_label', __('Invoice Total:', 'invoicing'), $invoice); ?></td> |
|
188 | + <td class="total"><?php echo $total; ?></td> |
|
189 | 189 | <td class="action"></td> |
190 | 190 | </tr> |
191 | 191 | </table> |
@@ -196,90 +196,90 @@ discard block |
||
196 | 196 | <div class="wpinv-actions"> |
197 | 197 | <?php ob_start(); ?> |
198 | 198 | <?php |
199 | - if ( !$invoice->is_paid() && !$invoice->is_refunded() ) { |
|
200 | - if ( !$invoice->is_recurring() ) { |
|
201 | - echo wpinv_item_dropdown( array( |
|
199 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
200 | + if (!$invoice->is_recurring()) { |
|
201 | + echo wpinv_item_dropdown(array( |
|
202 | 202 | 'name' => 'wpinv_invoice_item', |
203 | 203 | 'id' => 'wpinv_invoice_item', |
204 | 204 | 'show_recurring' => true, |
205 | 205 | 'class' => 'wpi_select2', |
206 | - ) ); |
|
206 | + )); |
|
207 | 207 | ?> |
208 | - <input type="button" value="<?php echo sprintf(esc_attr__( 'Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e( 'Create new item', 'invoicing' );?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e( 'Recalculate Totals', 'invoicing' );?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals"> |
|
208 | + <input type="button" value="<?php echo sprintf(esc_attr__('Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e('Create new item', 'invoicing'); ?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e('Recalculate Totals', 'invoicing'); ?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals"> |
|
209 | 209 | <?php } ?> |
210 | - <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?> |
|
211 | - <?php $item_actions = ob_get_clean(); echo apply_filters( 'wpinv_invoice_items_actions_content', $item_actions, $invoice, $post ); ?> |
|
210 | + <?php do_action('wpinv_invoice_items_actions', $invoice); ?> |
|
211 | + <?php $item_actions = ob_get_clean(); echo apply_filters('wpinv_invoice_items_actions_content', $item_actions, $invoice, $post); ?> |
|
212 | 212 | </div> |
213 | 213 | </div> |
214 | 214 | <?php |
215 | 215 | } |
216 | 216 | |
217 | - public static function prices( $post ) { |
|
217 | + public static function prices($post) { |
|
218 | 218 | $symbol = wpinv_currency_symbol(); |
219 | 219 | $position = wpinv_currency_position(); |
220 | - $item = new WPInv_Item( $post->ID ); |
|
220 | + $item = new WPInv_Item($post->ID); |
|
221 | 221 | |
222 | 222 | $price = $item->get_price(); |
223 | 223 | $is_dynamic_pricing = $item->get_is_dynamic_pricing(); |
224 | 224 | $minimum_price = $item->get_minimum_price(); |
225 | 225 | $is_recurring = $item->is_recurring(); |
226 | 226 | $period = $item->get_recurring_period(); |
227 | - $interval = absint( $item->get_recurring_interval() ); |
|
228 | - $times = absint( $item->get_recurring_limit() ); |
|
227 | + $interval = absint($item->get_recurring_interval()); |
|
228 | + $times = absint($item->get_recurring_limit()); |
|
229 | 229 | $free_trial = $item->has_free_trial(); |
230 | 230 | $trial_interval = $item->get_trial_interval(); |
231 | 231 | $trial_period = $item->get_trial_period(); |
232 | 232 | |
233 | 233 | $intervals = array(); |
234 | - for ( $i = 1; $i <= 90; $i++ ) { |
|
234 | + for ($i = 1; $i <= 90; $i++) { |
|
235 | 235 | $intervals[$i] = $i; |
236 | 236 | } |
237 | 237 | |
238 | - $interval = $interval > 0 ? $interval : 1; |
|
238 | + $interval = $interval > 0 ? $interval : 1; |
|
239 | 239 | |
240 | 240 | $class = $is_recurring ? 'wpinv-recurring-y' : 'wpinv-recurring-n'; |
241 | 241 | |
242 | 242 | $minimum_price_style = 'margin-left: 24px;'; |
243 | - if(! $is_dynamic_pricing ) { |
|
243 | + if (!$is_dynamic_pricing) { |
|
244 | 244 | $minimum_price_style .= 'display: none;'; |
245 | 245 | } |
246 | 246 | |
247 | 247 | ?> |
248 | - <p class="wpinv-row-prices"><?php echo ( $position != 'right' ? $symbol . ' ' : '' );?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount( 0 ); ?>" value="<?php echo $price;?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled( $item->is_editable(), false ); ?> /><?php echo ( $position == 'right' ? ' ' . $symbol : '' );?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce( 'wpinv_item_meta_box_save' ) ;?>" /> |
|
249 | - <?php do_action( 'wpinv_prices_metabox_price', $item ); ?> |
|
248 | + <p class="wpinv-row-prices"><?php echo ($position != 'right' ? $symbol . ' ' : ''); ?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount(0); ?>" value="<?php echo $price; ?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled($item->is_editable(), false); ?> /><?php echo ($position == 'right' ? ' ' . $symbol : ''); ?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce('wpinv_item_meta_box_save'); ?>" /> |
|
249 | + <?php do_action('wpinv_prices_metabox_price', $item); ?> |
|
250 | 250 | </p> |
251 | 251 | |
252 | - <?php if( $item->supports_dynamic_pricing() ) { ?> |
|
252 | + <?php if ($item->supports_dynamic_pricing()) { ?> |
|
253 | 253 | |
254 | 254 | <p class="wpinv-row-name-your-price"> |
255 | 255 | <label> |
256 | - <input type="checkbox" name="wpinv_name_your_price" id="wpinv_name_your_price" value="1" <?php checked( 1, $is_dynamic_pricing ); ?> /> |
|
257 | - <?php echo apply_filters( 'wpinv_name_your_price_toggle_text', __( 'User can set a custom price', 'invoicing' ) ); ?> |
|
256 | + <input type="checkbox" name="wpinv_name_your_price" id="wpinv_name_your_price" value="1" <?php checked(1, $is_dynamic_pricing); ?> /> |
|
257 | + <?php echo apply_filters('wpinv_name_your_price_toggle_text', __('User can set a custom price', 'invoicing')); ?> |
|
258 | 258 | </label> |
259 | - <?php do_action( 'wpinv_prices_metabox_name_your_price_field', $item ); ?> |
|
259 | + <?php do_action('wpinv_prices_metabox_name_your_price_field', $item); ?> |
|
260 | 260 | </p> |
261 | 261 | |
262 | 262 | <p class="wpinv-row-minimum-price" style="<?php echo $minimum_price_style; ?>"> |
263 | 263 | <label> |
264 | - <?php _e( 'Minimum Price', 'invoicing' ); ?> |
|
265 | - <?php echo ( $position != 'right' ? $symbol . ' ' : '' );?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount( 0 ); ?>" value="<?php echo $minimum_price;?>" id="wpinv_minimum_price" name="wpinv_minimum_price" class="medium-text wpi-field-price" <?php disabled( $item->is_editable(), false ); ?> /><?php echo ( $position == 'right' ? ' ' . $symbol : '' );?> |
|
264 | + <?php _e('Minimum Price', 'invoicing'); ?> |
|
265 | + <?php echo ($position != 'right' ? $symbol . ' ' : ''); ?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount(0); ?>" value="<?php echo $minimum_price; ?>" id="wpinv_minimum_price" name="wpinv_minimum_price" class="medium-text wpi-field-price" <?php disabled($item->is_editable(), false); ?> /><?php echo ($position == 'right' ? ' ' . $symbol : ''); ?> |
|
266 | 266 | </label> |
267 | 267 | |
268 | - <?php do_action( 'wpinv_prices_metabox_minimum_price_field', $item ); ?> |
|
268 | + <?php do_action('wpinv_prices_metabox_minimum_price_field', $item); ?> |
|
269 | 269 | </p> |
270 | 270 | |
271 | 271 | <?php } ?> |
272 | 272 | |
273 | 273 | <p class="wpinv-row-is-recurring"> |
274 | 274 | <label for="wpinv_is_recurring"> |
275 | - <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked( 1, $is_recurring ); ?> /> |
|
276 | - <?php echo apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Is Recurring Item?', 'invoicing' ) ); ?> |
|
275 | + <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked(1, $is_recurring); ?> /> |
|
276 | + <?php echo apply_filters('wpinv_is_recurring_toggle_text', __('Is Recurring Item?', 'invoicing')); ?> |
|
277 | 277 | </label> |
278 | - <?php do_action( 'wpinv_prices_metabox_is_recurring_field', $item ); ?> |
|
278 | + <?php do_action('wpinv_prices_metabox_is_recurring_field', $item); ?> |
|
279 | 279 | </p> |
280 | - <p class="wpinv-row-recurring-fields <?php echo $class;?>"> |
|
281 | - <label class="wpinv-period" for="wpinv_recurring_period"><?php _e( 'Recurring', 'invoicing' );?> <select class="wpinv-select wpi_select2" id="wpinv_recurring_period" name="wpinv_recurring_period"><option value="D" data-text="<?php esc_attr_e( 'day(s)', 'invoicing' ); ?>" <?php selected( 'D', $period );?>><?php _e( 'Daily', 'invoicing' ); ?></option><option value="W" data-text="<?php esc_attr_e( 'week(s)', 'invoicing' ); ?>" <?php selected( 'W', $period );?>><?php _e( 'Weekly', 'invoicing' ); ?></option><option value="M" data-text="<?php esc_attr_e( 'month(s)', 'invoicing' ); ?>" <?php selected( 'M', $period );?>><?php _e( 'Monthly', 'invoicing' ); ?></option><option value="Y" data-text="<?php esc_attr_e( 'year(s)', 'invoicing' ); ?>" <?php selected( 'Y', $period );?>><?php _e( 'Yearly', 'invoicing' ); ?></option></select></label> |
|
282 | - <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e( 'at every', 'invoicing' );?> <?php echo wpinv_html_select( array( |
|
280 | + <p class="wpinv-row-recurring-fields <?php echo $class; ?>"> |
|
281 | + <label class="wpinv-period" for="wpinv_recurring_period"><?php _e('Recurring', 'invoicing'); ?> <select class="wpinv-select wpi_select2" id="wpinv_recurring_period" name="wpinv_recurring_period"><option value="D" data-text="<?php esc_attr_e('day(s)', 'invoicing'); ?>" <?php selected('D', $period); ?>><?php _e('Daily', 'invoicing'); ?></option><option value="W" data-text="<?php esc_attr_e('week(s)', 'invoicing'); ?>" <?php selected('W', $period); ?>><?php _e('Weekly', 'invoicing'); ?></option><option value="M" data-text="<?php esc_attr_e('month(s)', 'invoicing'); ?>" <?php selected('M', $period); ?>><?php _e('Monthly', 'invoicing'); ?></option><option value="Y" data-text="<?php esc_attr_e('year(s)', 'invoicing'); ?>" <?php selected('Y', $period); ?>><?php _e('Yearly', 'invoicing'); ?></option></select></label> |
|
282 | + <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e('at every', 'invoicing'); ?> <?php echo wpinv_html_select(array( |
|
283 | 283 | 'options' => $intervals, |
284 | 284 | 'name' => 'wpinv_recurring_interval', |
285 | 285 | 'id' => 'wpinv_recurring_interval', |
@@ -287,30 +287,30 @@ discard block |
||
287 | 287 | 'show_option_all' => false, |
288 | 288 | 'show_option_none' => false, |
289 | 289 | 'class' => 'wpi_select2', |
290 | - ) ); ?> <span id="wpinv_interval_text"><?php _e( 'day(s)', 'invoicing' );?></span></label> |
|
291 | - <label class="wpinv-times" for="wpinv_recurring_limit"> <?php _e( 'for', 'invoicing' );?> <input class="small-text" type="number" value="<?php echo $times;?>" size="4" id="wpinv_recurring_limit" name="wpinv_recurring_limit" step="1" min="0"> <?php _e( 'time(s) <i>(select 0 for recurring forever until cancelled</i>)', 'invoicing' );?></label> |
|
290 | + )); ?> <span id="wpinv_interval_text"><?php _e('day(s)', 'invoicing'); ?></span></label> |
|
291 | + <label class="wpinv-times" for="wpinv_recurring_limit"> <?php _e('for', 'invoicing'); ?> <input class="small-text" type="number" value="<?php echo $times; ?>" size="4" id="wpinv_recurring_limit" name="wpinv_recurring_limit" step="1" min="0"> <?php _e('time(s) <i>(select 0 for recurring forever until cancelled</i>)', 'invoicing'); ?></label> |
|
292 | 292 | <span class="clear wpi-trial-clr"></span> |
293 | 293 | <label class="wpinv-free-trial" for="wpinv_free_trial"> |
294 | - <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked( true, (bool)$free_trial ); ?> /> |
|
295 | - <?php echo __( 'Offer free trial for', 'invoicing' ); ?> |
|
294 | + <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked(true, (bool) $free_trial); ?> /> |
|
295 | + <?php echo __('Offer free trial for', 'invoicing'); ?> |
|
296 | 296 | </label> |
297 | 297 | <label class="wpinv-trial-interval" for="wpinv_trial_interval"> |
298 | - <input class="small-text" type="number" value="<?php echo $trial_interval;?>" size="4" id="wpinv_trial_interval" name="wpinv_trial_interval" step="1" min="1"> <select class="wpinv-select wpi_select2" id="wpinv_trial_period" name="wpinv_trial_period"><option value="D" <?php selected( 'D', $trial_period );?>><?php _e( 'day(s)', 'invoicing' ); ?></option><option value="W" <?php selected( 'W', $trial_period );?>><?php _e( 'week(s)', 'invoicing' ); ?></option><option value="M" <?php selected( 'M', $trial_period );?>><?php _e( 'month(s)', 'invoicing' ); ?></option><option value="Y" <?php selected( 'Y', $trial_period );?>><?php _e( 'year(s)', 'invoicing' ); ?></option></select> |
|
298 | + <input class="small-text" type="number" value="<?php echo $trial_interval; ?>" size="4" id="wpinv_trial_interval" name="wpinv_trial_interval" step="1" min="1"> <select class="wpinv-select wpi_select2" id="wpinv_trial_period" name="wpinv_trial_period"><option value="D" <?php selected('D', $trial_period); ?>><?php _e('day(s)', 'invoicing'); ?></option><option value="W" <?php selected('W', $trial_period); ?>><?php _e('week(s)', 'invoicing'); ?></option><option value="M" <?php selected('M', $trial_period); ?>><?php _e('month(s)', 'invoicing'); ?></option><option value="Y" <?php selected('Y', $trial_period); ?>><?php _e('year(s)', 'invoicing'); ?></option></select> |
|
299 | 299 | </label> |
300 | - <?php do_action( 'wpinv_prices_metabox_recurring_fields', $item ); ?> |
|
300 | + <?php do_action('wpinv_prices_metabox_recurring_fields', $item); ?> |
|
301 | 301 | </p> |
302 | - <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type( $post->ID ); ?>" /> |
|
303 | - <?php do_action( 'wpinv_item_price_field', $post->ID ); ?> |
|
302 | + <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type($post->ID); ?>" /> |
|
303 | + <?php do_action('wpinv_item_price_field', $post->ID); ?> |
|
304 | 304 | <?php |
305 | 305 | } |
306 | 306 | |
307 | - public static function vat_rules( $post ) { |
|
307 | + public static function vat_rules($post) { |
|
308 | 308 | global $wpinv_euvat; |
309 | 309 | |
310 | - $rule_type = $wpinv_euvat->get_item_rule( $post->ID ); |
|
310 | + $rule_type = $wpinv_euvat->get_item_rule($post->ID); |
|
311 | 311 | ?> |
312 | - <p><label for="wpinv_vat_rules"><strong><?php _e( 'Select how VAT rules will be applied:', 'invoicing' );?></strong></label> |
|
313 | - <?php echo wpinv_html_select( array( |
|
312 | + <p><label for="wpinv_vat_rules"><strong><?php _e('Select how VAT rules will be applied:', 'invoicing'); ?></strong></label> |
|
313 | + <?php echo wpinv_html_select(array( |
|
314 | 314 | 'options' => $wpinv_euvat->get_rules(), |
315 | 315 | 'name' => 'wpinv_vat_rules', |
316 | 316 | 'id' => 'wpinv_vat_rules', |
@@ -318,19 +318,19 @@ discard block |
||
318 | 318 | 'show_option_all' => false, |
319 | 319 | 'show_option_none' => false, |
320 | 320 | 'class' => 'gdmbx2-text-medium wpinv-vat-rules wpi_select2', |
321 | - ) ); ?> |
|
321 | + )); ?> |
|
322 | 322 | </p> |
323 | - <p class="wpi-m0"><?php _e( 'When you select physical product rules, only consumers and businesses in your country will be charged VAT. The VAT rate used will be the rate in your country.', 'invoicing' ); ?></p> |
|
324 | - <p class="wpi-m0"><?php _e( 'If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer. Only businesses in your country will be charged VAT.', 'invoicing' ); ?></p> |
|
323 | + <p class="wpi-m0"><?php _e('When you select physical product rules, only consumers and businesses in your country will be charged VAT. The VAT rate used will be the rate in your country.', 'invoicing'); ?></p> |
|
324 | + <p class="wpi-m0"><?php _e('If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer. Only businesses in your country will be charged VAT.', 'invoicing'); ?></p> |
|
325 | 325 | <?php |
326 | 326 | } |
327 | 327 | |
328 | - public static function vat_classes( $post ) { |
|
328 | + public static function vat_classes($post) { |
|
329 | 329 | global $wpinv_euvat; |
330 | 330 | |
331 | - $vat_class = $wpinv_euvat->get_item_class( $post->ID ); |
|
331 | + $vat_class = $wpinv_euvat->get_item_class($post->ID); |
|
332 | 332 | ?> |
333 | - <p><?php echo wpinv_html_select( array( |
|
333 | + <p><?php echo wpinv_html_select(array( |
|
334 | 334 | 'options' => $wpinv_euvat->get_all_classes(), |
335 | 335 | 'name' => 'wpinv_vat_class', |
336 | 336 | 'id' => 'wpinv_vat_class', |
@@ -338,18 +338,18 @@ discard block |
||
338 | 338 | 'show_option_all' => false, |
339 | 339 | 'show_option_none' => false, |
340 | 340 | 'class' => 'gdmbx2-text-medium wpinv-vat-class wpi_select2', |
341 | - ) ); ?> |
|
341 | + )); ?> |
|
342 | 342 | </p> |
343 | - <p class="wpi-m0"><?php _e( 'Select the VAT rate class to use for this invoice item.', 'invoicing' ); ?></p> |
|
343 | + <p class="wpi-m0"><?php _e('Select the VAT rate class to use for this invoice item.', 'invoicing'); ?></p> |
|
344 | 344 | <?php |
345 | 345 | } |
346 | 346 | |
347 | - public static function item_info( $post ) { |
|
348 | - $item_type = wpinv_get_item_type( $post->ID ); |
|
349 | - do_action( 'wpinv_item_info_metabox_before', $post ); |
|
347 | + public static function item_info($post) { |
|
348 | + $item_type = wpinv_get_item_type($post->ID); |
|
349 | + do_action('wpinv_item_info_metabox_before', $post); |
|
350 | 350 | ?> |
351 | - <p><label for="wpinv_item_type"><strong><?php _e( 'Type:', 'invoicing' );?></strong></label> |
|
352 | - <?php echo wpinv_html_select( array( |
|
351 | + <p><label for="wpinv_item_type"><strong><?php _e('Type:', 'invoicing'); ?></strong></label> |
|
352 | + <?php echo wpinv_html_select(array( |
|
353 | 353 | 'options' => wpinv_get_item_types(), |
354 | 354 | 'name' => 'wpinv_item_type', |
355 | 355 | 'id' => 'wpinv_item_type', |
@@ -357,127 +357,127 @@ discard block |
||
357 | 357 | 'show_option_all' => false, |
358 | 358 | 'show_option_none' => false, |
359 | 359 | 'class' => 'gdmbx2-text-medium wpinv-item-type', |
360 | - ) ); ?> |
|
360 | + )); ?> |
|
361 | 361 | </p> |
362 | - <p class="wpi-m0"><?php _e( 'Select item type.', 'invoicing' );?><br><?php _e( '<b>Standard:</b> Standard item type', 'invoicing' );?><br><?php _e( '<b>Fee:</b> Like Registration Fee, Sign up Fee etc.', 'invoicing' );?></p> |
|
362 | + <p class="wpi-m0"><?php _e('Select item type.', 'invoicing'); ?><br><?php _e('<b>Standard:</b> Standard item type', 'invoicing'); ?><br><?php _e('<b>Fee:</b> Like Registration Fee, Sign up Fee etc.', 'invoicing'); ?></p> |
|
363 | 363 | <?php |
364 | - do_action( 'wpinv_item_info_metabox_after', $post ); |
|
364 | + do_action('wpinv_item_info_metabox_after', $post); |
|
365 | 365 | } |
366 | 366 | |
367 | - public static function meta_values( $post ) { |
|
368 | - $meta_keys = apply_filters( 'wpinv_show_meta_values_for_keys', array( |
|
367 | + public static function meta_values($post) { |
|
368 | + $meta_keys = apply_filters('wpinv_show_meta_values_for_keys', array( |
|
369 | 369 | 'type', |
370 | 370 | 'custom_id' |
371 | - ) ); |
|
371 | + )); |
|
372 | 372 | |
373 | - if ( empty( $meta_keys ) ) { |
|
373 | + if (empty($meta_keys)) { |
|
374 | 374 | return; |
375 | 375 | } |
376 | 376 | |
377 | - do_action( 'wpinv_meta_values_metabox_before', $post ); |
|
377 | + do_action('wpinv_meta_values_metabox_before', $post); |
|
378 | 378 | |
379 | - foreach ( $meta_keys as $meta_key ) { |
|
379 | + foreach ($meta_keys as $meta_key) { |
|
380 | 380 | ?> |
381 | - <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta( $post->ID, '_wpinv_' . $meta_key, true ); ?></label></p> |
|
381 | + <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta($post->ID, '_wpinv_' . $meta_key, true); ?></label></p> |
|
382 | 382 | <?php |
383 | 383 | } |
384 | 384 | |
385 | - do_action( 'wpinv_meta_values_metabox_after', $post ); |
|
385 | + do_action('wpinv_meta_values_metabox_after', $post); |
|
386 | 386 | } |
387 | 387 | |
388 | - public static function save( $post_id, $data, $post ) { |
|
389 | - $invoice = new WPInv_Invoice( $post_id ); |
|
388 | + public static function save($post_id, $data, $post) { |
|
389 | + $invoice = new WPInv_Invoice($post_id); |
|
390 | 390 | |
391 | 391 | // Billing |
392 | - $first_name = sanitize_text_field( $data['wpinv_first_name'] ); |
|
393 | - $last_name = sanitize_text_field( $data['wpinv_last_name'] ); |
|
394 | - $company = sanitize_text_field( $data['wpinv_company'] ); |
|
395 | - $vat_number = sanitize_text_field( $data['wpinv_vat_number'] ); |
|
396 | - $phone = sanitize_text_field( $data['wpinv_phone'] ); |
|
397 | - $address = sanitize_text_field( $data['wpinv_address'] ); |
|
398 | - $city = sanitize_text_field( $data['wpinv_city'] ); |
|
399 | - $zip = sanitize_text_field( $data['wpinv_zip'] ); |
|
400 | - $country = sanitize_text_field( $data['wpinv_country'] ); |
|
401 | - $state = sanitize_text_field( $data['wpinv_state'] ); |
|
392 | + $first_name = sanitize_text_field($data['wpinv_first_name']); |
|
393 | + $last_name = sanitize_text_field($data['wpinv_last_name']); |
|
394 | + $company = sanitize_text_field($data['wpinv_company']); |
|
395 | + $vat_number = sanitize_text_field($data['wpinv_vat_number']); |
|
396 | + $phone = sanitize_text_field($data['wpinv_phone']); |
|
397 | + $address = sanitize_text_field($data['wpinv_address']); |
|
398 | + $city = sanitize_text_field($data['wpinv_city']); |
|
399 | + $zip = sanitize_text_field($data['wpinv_zip']); |
|
400 | + $country = sanitize_text_field($data['wpinv_country']); |
|
401 | + $state = sanitize_text_field($data['wpinv_state']); |
|
402 | 402 | |
403 | 403 | // Details |
404 | - $status = sanitize_text_field( $data['wpinv_status'] ); |
|
405 | - $old_status = !empty( $data['original_post_status'] ) ? sanitize_text_field( $data['original_post_status'] ) : $status; |
|
406 | - $number = sanitize_text_field( $data['wpinv_number'] ); |
|
407 | - $due_date = isset( $data['wpinv_due_date'] ) ? sanitize_text_field( $data['wpinv_due_date'] ) : ''; |
|
404 | + $status = sanitize_text_field($data['wpinv_status']); |
|
405 | + $old_status = !empty($data['original_post_status']) ? sanitize_text_field($data['original_post_status']) : $status; |
|
406 | + $number = sanitize_text_field($data['wpinv_number']); |
|
407 | + $due_date = isset($data['wpinv_due_date']) ? sanitize_text_field($data['wpinv_due_date']) : ''; |
|
408 | 408 | //$discounts = sanitize_text_field( $data['wpinv_discounts'] ); |
409 | 409 | //$discount = sanitize_text_field( $data['wpinv_discount'] ); |
410 | 410 | |
411 | - $ip = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip(); |
|
412 | - |
|
413 | - $invoice->set( 'due_date', $due_date ); |
|
414 | - $invoice->set( 'first_name', $first_name ); |
|
415 | - $invoice->set( 'last_name', $last_name ); |
|
416 | - $invoice->set( 'company', $company ); |
|
417 | - $invoice->set( 'vat_number', $vat_number ); |
|
418 | - $invoice->set( 'phone', $phone ); |
|
419 | - $invoice->set( 'address', $address ); |
|
420 | - $invoice->set( 'city', $city ); |
|
421 | - $invoice->set( 'zip', $zip ); |
|
422 | - $invoice->set( 'country', $country ); |
|
423 | - $invoice->set( 'state', $state ); |
|
424 | - $invoice->set( 'status', $status ); |
|
411 | + $ip = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip(); |
|
412 | + |
|
413 | + $invoice->set('due_date', $due_date); |
|
414 | + $invoice->set('first_name', $first_name); |
|
415 | + $invoice->set('last_name', $last_name); |
|
416 | + $invoice->set('company', $company); |
|
417 | + $invoice->set('vat_number', $vat_number); |
|
418 | + $invoice->set('phone', $phone); |
|
419 | + $invoice->set('address', $address); |
|
420 | + $invoice->set('city', $city); |
|
421 | + $invoice->set('zip', $zip); |
|
422 | + $invoice->set('country', $country); |
|
423 | + $invoice->set('state', $state); |
|
424 | + $invoice->set('status', $status); |
|
425 | 425 | //$invoice->set( 'number', $number ); |
426 | 426 | //$invoice->set( 'discounts', $discounts ); |
427 | 427 | //$invoice->set( 'discount', $discount ); |
428 | - $invoice->set( 'ip', $ip ); |
|
428 | + $invoice->set('ip', $ip); |
|
429 | 429 | $invoice->old_status = $_POST['original_post_status']; |
430 | 430 | |
431 | 431 | $currency = $invoice->get_currency(); |
432 | - if ( ! empty( sanitize_text_field( $data['wpinv_currency'] ) ) ) { |
|
433 | - $currency = sanitize_text_field( $data['wpinv_currency'] ); |
|
432 | + if (!empty(sanitize_text_field($data['wpinv_currency']))) { |
|
433 | + $currency = sanitize_text_field($data['wpinv_currency']); |
|
434 | 434 | } |
435 | 435 | |
436 | - if ( empty( $currency ) ) { |
|
436 | + if (empty($currency)) { |
|
437 | 437 | $currency = wpinv_get_currency(); |
438 | 438 | } |
439 | 439 | |
440 | - if ( ! $invoice->is_paid() ) { |
|
440 | + if (!$invoice->is_paid()) { |
|
441 | 441 | $invoice->currency = $currency; |
442 | 442 | } |
443 | 443 | |
444 | - if ( !empty( $data['wpinv_gateway'] ) ) { |
|
445 | - $invoice->set( 'gateway', sanitize_text_field( $data['wpinv_gateway'] ) ); |
|
444 | + if (!empty($data['wpinv_gateway'])) { |
|
445 | + $invoice->set('gateway', sanitize_text_field($data['wpinv_gateway'])); |
|
446 | 446 | } |
447 | 447 | $saved = $invoice->save(); |
448 | 448 | |
449 | 449 | // Check for payment notes |
450 | - if ( !empty( $data['invoice_note'] ) ) { |
|
451 | - $note = wp_kses( $data['invoice_note'], array() ); |
|
452 | - $note_type = sanitize_text_field( $data['invoice_note_type'] ); |
|
450 | + if (!empty($data['invoice_note'])) { |
|
451 | + $note = wp_kses($data['invoice_note'], array()); |
|
452 | + $note_type = sanitize_text_field($data['invoice_note_type']); |
|
453 | 453 | $is_customer_note = $note_type == 'customer' ? 1 : 0; |
454 | 454 | |
455 | - wpinv_insert_payment_note( $invoice->ID, $note, $is_customer_note ); |
|
455 | + wpinv_insert_payment_note($invoice->ID, $note, $is_customer_note); |
|
456 | 456 | } |
457 | 457 | |
458 | 458 | // Update user address if empty. |
459 | - if ( $saved && !empty( $invoice ) ) { |
|
460 | - if ( $user_id = $invoice->get_user_id() ) { |
|
461 | - $user_address = wpinv_get_user_address( $user_id, false ); |
|
459 | + if ($saved && !empty($invoice)) { |
|
460 | + if ($user_id = $invoice->get_user_id()) { |
|
461 | + $user_address = wpinv_get_user_address($user_id, false); |
|
462 | 462 | |
463 | 463 | if (empty($user_address['first_name'])) { |
464 | - update_user_meta( $user_id, '_wpinv_first_name', $first_name ); |
|
465 | - update_user_meta( $user_id, '_wpinv_last_name', $last_name ); |
|
464 | + update_user_meta($user_id, '_wpinv_first_name', $first_name); |
|
465 | + update_user_meta($user_id, '_wpinv_last_name', $last_name); |
|
466 | 466 | } else if (empty($user_address['last_name']) && $user_address['first_name'] == $first_name) { |
467 | - update_user_meta( $user_id, '_wpinv_last_name', $last_name ); |
|
467 | + update_user_meta($user_id, '_wpinv_last_name', $last_name); |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | if (empty($user_address['address']) || empty($user_address['city']) || empty($user_address['state']) || empty($user_address['country'])) { |
471 | - update_user_meta( $user_id, '_wpinv_address', $address ); |
|
472 | - update_user_meta( $user_id, '_wpinv_city', $city ); |
|
473 | - update_user_meta( $user_id, '_wpinv_state', $state ); |
|
474 | - update_user_meta( $user_id, '_wpinv_country', $country ); |
|
475 | - update_user_meta( $user_id, '_wpinv_zip', $zip ); |
|
476 | - update_user_meta( $user_id, '_wpinv_phone', $phone ); |
|
471 | + update_user_meta($user_id, '_wpinv_address', $address); |
|
472 | + update_user_meta($user_id, '_wpinv_city', $city); |
|
473 | + update_user_meta($user_id, '_wpinv_state', $state); |
|
474 | + update_user_meta($user_id, '_wpinv_country', $country); |
|
475 | + update_user_meta($user_id, '_wpinv_zip', $zip); |
|
476 | + update_user_meta($user_id, '_wpinv_phone', $phone); |
|
477 | 477 | } |
478 | 478 | } |
479 | 479 | |
480 | - do_action( 'wpinv_invoice_metabox_saved', $invoice ); |
|
480 | + do_action('wpinv_invoice_metabox_saved', $invoice); |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | return $saved; |
@@ -1,6 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | // Exit if accessed directly |
3 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
3 | +if ( ! defined( 'ABSPATH' ) ) { |
|
4 | + exit; |
|
5 | +} |
|
4 | 6 | |
5 | 7 | add_action( 'wpinv_manual_cc_form', '__return_false' ); |
6 | 8 | add_filter( 'wpinv_manual_support_subscription', '__return_true' ); |
@@ -1,13 +1,13 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // Exit if accessed directly |
3 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
3 | +if (!defined('ABSPATH')) exit; |
|
4 | 4 | |
5 | -add_action( 'wpinv_manual_cc_form', '__return_false' ); |
|
6 | -add_filter( 'wpinv_manual_support_subscription', '__return_true' ); |
|
5 | +add_action('wpinv_manual_cc_form', '__return_false'); |
|
6 | +add_filter('wpinv_manual_support_subscription', '__return_true'); |
|
7 | 7 | |
8 | -function wpinv_process_manual_payment( $purchase_data ) { |
|
9 | - if( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'wpi-gateway' ) ) { |
|
10 | - wp_die( __( 'Nonce verification has failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
8 | +function wpinv_process_manual_payment($purchase_data) { |
|
9 | + if (!wp_verify_nonce($purchase_data['gateway_nonce'], 'wpi-gateway')) { |
|
10 | + wp_die(__('Nonce verification has failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | /* |
@@ -42,45 +42,45 @@ discard block |
||
42 | 42 | ); |
43 | 43 | |
44 | 44 | // Record the pending payment |
45 | - $invoice = wpinv_get_invoice( $purchase_data['invoice_id'] ); |
|
45 | + $invoice = wpinv_get_invoice($purchase_data['invoice_id']); |
|
46 | 46 | |
47 | - if ( !empty( $invoice ) ) { |
|
48 | - wpinv_set_payment_transaction_id( $invoice->ID, $invoice->generate_key() ); |
|
49 | - wpinv_update_payment_status( $invoice, 'publish' ); |
|
47 | + if (!empty($invoice)) { |
|
48 | + wpinv_set_payment_transaction_id($invoice->ID, $invoice->generate_key()); |
|
49 | + wpinv_update_payment_status($invoice, 'publish'); |
|
50 | 50 | |
51 | 51 | // Empty the shopping cart |
52 | 52 | wpinv_empty_cart(); |
53 | 53 | |
54 | 54 | // (Maybe) set recurring hooks. |
55 | - wpinv_start_manual_subscription_profile( $purchase_data['invoice_id'] ); |
|
55 | + wpinv_start_manual_subscription_profile($purchase_data['invoice_id']); |
|
56 | 56 | |
57 | - do_action( 'wpinv_send_to_success_page', $invoice->ID, $payment_data ); |
|
57 | + do_action('wpinv_send_to_success_page', $invoice->ID, $payment_data); |
|
58 | 58 | |
59 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
59 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
60 | 60 | } else { |
61 | - wpinv_record_gateway_error( __( 'Payment Error', 'invoicing' ), sprintf( __( 'Payment creation failed while processing a manual (free or test) purchase. Payment data: %s', 'invoicing' ), json_encode( $payment_data ) ), $invoice ); |
|
61 | + wpinv_record_gateway_error(__('Payment Error', 'invoicing'), sprintf(__('Payment creation failed while processing a manual (free or test) purchase. Payment data: %s', 'invoicing'), json_encode($payment_data)), $invoice); |
|
62 | 62 | // If errors are present, send the user back to the purchase page so they can be corrected |
63 | - wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] ); |
|
63 | + wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']); |
|
64 | 64 | } |
65 | 65 | } |
66 | -add_action( 'wpinv_gateway_manual', 'wpinv_process_manual_payment' ); |
|
66 | +add_action('wpinv_gateway_manual', 'wpinv_process_manual_payment'); |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * Starts a manual subscription profile. |
70 | 70 | */ |
71 | -function wpinv_start_manual_subscription_profile( $invoice_id ) { |
|
71 | +function wpinv_start_manual_subscription_profile($invoice_id) { |
|
72 | 72 | |
73 | 73 | // Retrieve the subscription. |
74 | - $subscription = wpinv_get_subscription( $invoice_id ); |
|
75 | - if ( empty( $subscription ) ) { |
|
74 | + $subscription = wpinv_get_subscription($invoice_id); |
|
75 | + if (empty($subscription)) { |
|
76 | 76 | return; |
77 | 77 | } |
78 | 78 | |
79 | 79 | // Schedule an action to run when the subscription expires. |
80 | 80 | $action_id = as_schedule_single_action( |
81 | - strtotime( $subscription->expiration ), |
|
81 | + strtotime($subscription->expiration), |
|
82 | 82 | 'wpinv_renew_manual_subscription_profile', |
83 | - array( $invoice_id ), |
|
83 | + array($invoice_id), |
|
84 | 84 | 'invoicing' |
85 | 85 | ); |
86 | 86 | |
@@ -97,11 +97,11 @@ discard block |
||
97 | 97 | /** |
98 | 98 | * Renews a manual subscription profile. |
99 | 99 | */ |
100 | -function wpinv_renew_manual_subscription_profile( $invoice_id ) { |
|
100 | +function wpinv_renew_manual_subscription_profile($invoice_id) { |
|
101 | 101 | |
102 | 102 | // Retrieve the subscription. |
103 | - $subscription = wpinv_get_subscription( $invoice_id ); |
|
104 | - if ( empty( $subscription ) ) { |
|
103 | + $subscription = wpinv_get_subscription($invoice_id); |
|
104 | + if (empty($subscription)) { |
|
105 | 105 | return; |
106 | 106 | } |
107 | 107 | |
@@ -109,29 +109,29 @@ discard block |
||
109 | 109 | $max_bills = $subscription->bill_times; |
110 | 110 | |
111 | 111 | // If we have not maxed out on bill times... |
112 | - if ( empty( $bill_times ) || $times_billed > $max_bills ) { |
|
112 | + if (empty($bill_times) || $times_billed > $max_bills) { |
|
113 | 113 | |
114 | 114 | // Renew the subscription. |
115 | - $subscription->add_payment( array( |
|
115 | + $subscription->add_payment(array( |
|
116 | 116 | 'amount' => $subscription->recurring_amount, |
117 | 117 | 'transaction_id' => time(), |
118 | 118 | 'gateway' => 'manual' |
119 | - ) ); |
|
119 | + )); |
|
120 | 120 | |
121 | 121 | // Calculate the new expiration. |
122 | - $new_expiration = strtotime( "+ {$subscription->frequency} {$subscription->period}", strtotime( $subscription->expiration ) ); |
|
122 | + $new_expiration = strtotime("+ {$subscription->frequency} {$subscription->period}", strtotime($subscription->expiration)); |
|
123 | 123 | |
124 | 124 | // Schedule an action to run when the subscription expires. |
125 | 125 | $action_id = as_schedule_single_action( |
126 | 126 | $new_expiration, |
127 | 127 | 'wpinv_renew_manual_subscription_profile', |
128 | - array( $invoice_id ), |
|
128 | + array($invoice_id), |
|
129 | 129 | 'invoicing' |
130 | 130 | ); |
131 | 131 | |
132 | 132 | $subscription->update( |
133 | 133 | array( |
134 | - 'expiration' => date_i18n( 'Y-m-d H:i:s', $new_expiration ), |
|
134 | + 'expiration' => date_i18n('Y-m-d H:i:s', $new_expiration), |
|
135 | 135 | 'status' => 'active', |
136 | 136 | 'profile_id' => $action_id, |
137 | 137 | ) |
@@ -149,4 +149,4 @@ discard block |
||
149 | 149 | } |
150 | 150 | |
151 | 151 | } |
152 | -add_action( 'wpinv_renew_manual_subscription_profile', 'wpinv_renew_manual_subscription_profile' ); |
|
152 | +add_action('wpinv_renew_manual_subscription_profile', 'wpinv_renew_manual_subscription_profile'); |