@@ -7,86 +7,86 @@ 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 | 92 | /** |
@@ -95,48 +95,48 @@ discard block |
||
95 | 95 | * @since 1.0.19 |
96 | 96 | * @return array |
97 | 97 | */ |
98 | -function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) { |
|
98 | +function wpinv_get_invoice_statuses($draft = false, $trashed = false, $invoice = false) { |
|
99 | 99 | $invoice_statuses = array( |
100 | - 'wpi-pending' => _x( 'Pending payment', 'Invoice status', 'invoicing' ), |
|
101 | - 'publish' => _x( 'Paid', 'Invoice status', 'invoicing' ), |
|
102 | - 'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
103 | - 'wpi-onhold' => _x( 'On hold', 'Invoice status', 'invoicing' ), |
|
104 | - 'wpi-cancelled' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
105 | - 'wpi-refunded' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
106 | - 'wpi-failed' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
107 | - 'wpi-renewal' => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ), |
|
100 | + 'wpi-pending' => _x('Pending payment', 'Invoice status', 'invoicing'), |
|
101 | + 'publish' => _x('Paid', 'Invoice status', 'invoicing'), |
|
102 | + 'wpi-processing' => _x('Processing', 'Invoice status', 'invoicing'), |
|
103 | + 'wpi-onhold' => _x('On hold', 'Invoice status', 'invoicing'), |
|
104 | + 'wpi-cancelled' => _x('Cancelled', 'Invoice status', 'invoicing'), |
|
105 | + 'wpi-refunded' => _x('Refunded', 'Invoice status', 'invoicing'), |
|
106 | + 'wpi-failed' => _x('Failed', 'Invoice status', 'invoicing'), |
|
107 | + 'wpi-renewal' => _x('Renewal Payment', 'Invoice status', 'invoicing'), |
|
108 | 108 | ); |
109 | 109 | |
110 | - if ( $draft ) { |
|
111 | - $invoice_statuses['draft'] = __( 'Draft', 'invoicing' ); |
|
110 | + if ($draft) { |
|
111 | + $invoice_statuses['draft'] = __('Draft', 'invoicing'); |
|
112 | 112 | } |
113 | 113 | |
114 | - if ( $trashed ) { |
|
115 | - $invoice_statuses['trash'] = __( 'Trash', 'invoicing' ); |
|
114 | + if ($trashed) { |
|
115 | + $invoice_statuses['trash'] = __('Trash', 'invoicing'); |
|
116 | 116 | } |
117 | 117 | |
118 | - return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice ); |
|
118 | + return apply_filters('wpinv_statuses', $invoice_statuses, $invoice); |
|
119 | 119 | } |
120 | 120 | |
121 | -function wpinv_status_nicename( $status ) { |
|
122 | - $statuses = wpinv_get_invoice_statuses( true, true ); |
|
123 | - $status = isset( $statuses[$status] ) ? $statuses[$status] : __( $status, 'invoicing' ); |
|
121 | +function wpinv_status_nicename($status) { |
|
122 | + $statuses = wpinv_get_invoice_statuses(true, true); |
|
123 | + $status = isset($statuses[$status]) ? $statuses[$status] : __($status, 'invoicing'); |
|
124 | 124 | |
125 | 125 | return $status; |
126 | 126 | } |
127 | 127 | |
128 | 128 | function wpinv_get_currency() { |
129 | - $currency = wpinv_get_option( 'currency', 'USD' ); |
|
129 | + $currency = wpinv_get_option('currency', 'USD'); |
|
130 | 130 | |
131 | - return apply_filters( 'wpinv_currency', $currency ); |
|
131 | + return apply_filters('wpinv_currency', $currency); |
|
132 | 132 | } |
133 | 133 | |
134 | -function wpinv_currency_symbol( $currency = '' ) { |
|
135 | - if ( empty( $currency ) ) { |
|
134 | +function wpinv_currency_symbol($currency = '') { |
|
135 | + if (empty($currency)) { |
|
136 | 136 | $currency = wpinv_get_currency(); |
137 | 137 | } |
138 | 138 | |
139 | - $symbols = apply_filters( 'wpinv_currency_symbols', array( |
|
139 | + $symbols = apply_filters('wpinv_currency_symbols', array( |
|
140 | 140 | 'AED' => 'د.إ', |
141 | 141 | 'AFN' => '؋', |
142 | 142 | 'ALL' => 'L', |
@@ -299,209 +299,209 @@ discard block |
||
299 | 299 | 'YER' => '﷼', |
300 | 300 | 'ZAR' => 'R', |
301 | 301 | 'ZMW' => 'ZK', |
302 | - ) ); |
|
302 | + )); |
|
303 | 303 | |
304 | - $currency_symbol = isset( $symbols[$currency] ) ? $symbols[$currency] : $currency; |
|
304 | + $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency; |
|
305 | 305 | |
306 | - return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency ); |
|
306 | + return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | function wpinv_currency_position() { |
310 | - $position = wpinv_get_option( 'currency_position', 'left' ); |
|
310 | + $position = wpinv_get_option('currency_position', 'left'); |
|
311 | 311 | |
312 | - return apply_filters( 'wpinv_currency_position', $position ); |
|
312 | + return apply_filters('wpinv_currency_position', $position); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | function wpinv_thousands_separator() { |
316 | - $thousand_sep = wpinv_get_option( 'thousands_separator', ',' ); |
|
316 | + $thousand_sep = wpinv_get_option('thousands_separator', ','); |
|
317 | 317 | |
318 | - return apply_filters( 'wpinv_thousands_separator', $thousand_sep ); |
|
318 | + return apply_filters('wpinv_thousands_separator', $thousand_sep); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | function wpinv_decimal_separator() { |
322 | - $decimal_sep = wpinv_get_option( 'decimal_separator', '.' ); |
|
322 | + $decimal_sep = wpinv_get_option('decimal_separator', '.'); |
|
323 | 323 | |
324 | - return apply_filters( 'wpinv_decimal_separator', $decimal_sep ); |
|
324 | + return apply_filters('wpinv_decimal_separator', $decimal_sep); |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | function wpinv_decimals() { |
328 | - $decimals = apply_filters( 'wpinv_decimals', wpinv_get_option( 'decimals', 2 ) ); |
|
328 | + $decimals = apply_filters('wpinv_decimals', wpinv_get_option('decimals', 2)); |
|
329 | 329 | |
330 | - return absint( $decimals ); |
|
330 | + return absint($decimals); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | function wpinv_get_currencies() { |
334 | 334 | $currencies = array( |
335 | - 'USD' => __( 'US Dollar', 'invoicing' ), |
|
336 | - 'EUR' => __( 'Euro', 'invoicing' ), |
|
337 | - 'GBP' => __( 'Pound Sterling', 'invoicing' ), |
|
338 | - 'AED' => __( 'United Arab Emirates', 'invoicing' ), |
|
339 | - 'AFN' => __( 'Afghan Afghani', 'invoicing' ), |
|
340 | - 'ALL' => __( 'Albanian Lek', 'invoicing' ), |
|
341 | - 'AMD' => __( 'Armenian Dram', 'invoicing' ), |
|
342 | - 'ANG' => __( 'Netherlands Antillean Guilder', 'invoicing' ), |
|
343 | - 'AOA' => __( 'Angolan Kwanza', 'invoicing' ), |
|
344 | - 'ARS' => __( 'Argentine Peso', 'invoicing' ), |
|
345 | - 'AUD' => __( 'Australian Dollar', 'invoicing' ), |
|
346 | - 'AWG' => __( 'Aruban Florin', 'invoicing' ), |
|
347 | - 'AZN' => __( 'Azerbaijani Manat', 'invoicing' ), |
|
348 | - 'BAM' => __( 'Bosnia and Herzegovina Convertible Marka', 'invoicing' ), |
|
349 | - 'BBD' => __( 'Barbadian Dollar', 'invoicing' ), |
|
350 | - 'BDT' => __( 'Bangladeshi Taka', 'invoicing' ), |
|
351 | - 'BGN' => __( 'Bulgarian Lev', 'invoicing' ), |
|
352 | - 'BHD' => __( 'Bahraini Dinar', 'invoicing' ), |
|
353 | - 'BIF' => __( 'Burundian Franc', 'invoicing' ), |
|
354 | - 'BMD' => __( 'Bermudian Dollar', 'invoicing' ), |
|
355 | - 'BND' => __( 'Brunei Dollar', 'invoicing' ), |
|
356 | - 'BOB' => __( 'Bolivian Boliviano', 'invoicing' ), |
|
357 | - 'BRL' => __( 'Brazilian Real', 'invoicing' ), |
|
358 | - 'BSD' => __( 'Bahamian Dollar', 'invoicing' ), |
|
359 | - 'BTC' => __( 'Bitcoin', 'invoicing' ), |
|
360 | - 'BTN' => __( 'Bhutanese Ngultrum', 'invoicing' ), |
|
361 | - 'BWP' => __( 'Botswana Pula', 'invoicing' ), |
|
362 | - 'BYN' => __( 'Belarusian Ruble', 'invoicing' ), |
|
363 | - 'BZD' => __( 'Belize Dollar', 'invoicing' ), |
|
364 | - 'CAD' => __( 'Canadian Dollar', 'invoicing' ), |
|
365 | - 'CDF' => __( 'Congolese Franc', 'invoicing' ), |
|
366 | - 'CHF' => __( 'Swiss Franc', 'invoicing' ), |
|
367 | - 'CLP' => __( 'Chilean Peso', 'invoicing' ), |
|
368 | - 'CNY' => __( 'Chinese Yuan', 'invoicing' ), |
|
369 | - 'COP' => __( 'Colombian Peso', 'invoicing' ), |
|
370 | - 'CRC' => __( 'Costa Rican Colon', 'invoicing' ), |
|
371 | - 'CUC' => __( 'Cuban Convertible Peso', 'invoicing' ), |
|
372 | - 'CUP' => __( 'Cuban Peso', 'invoicing' ), |
|
373 | - 'CVE' => __( 'Cape Verdean escudo', 'invoicing' ), |
|
374 | - 'CZK' => __( 'Czech Koruna', 'invoicing' ), |
|
375 | - 'DJF' => __( 'Djiboutian Franc', 'invoicing' ), |
|
376 | - 'DKK' => __( 'Danish Krone', 'invoicing' ), |
|
377 | - 'DOP' => __( 'Dominican Peso', 'invoicing' ), |
|
378 | - 'DZD' => __( 'Algerian Dinar', 'invoicing' ), |
|
379 | - 'EGP' => __( 'Egyptian Pound', 'invoicing' ), |
|
380 | - 'ERN' => __( 'Eritrean Nakfa', 'invoicing' ), |
|
381 | - 'ETB' => __( 'Ethiopian Irr', 'invoicing' ), |
|
382 | - 'FJD' => __( 'Fijian Dollar', 'invoicing' ), |
|
383 | - 'FKP' => __( 'Falkland Islands Pound', 'invoicing' ), |
|
384 | - 'GEL' => __( 'Georgian Lari', 'invoicing' ), |
|
385 | - 'GGP' => __( 'Guernsey Pound', 'invoicing' ), |
|
386 | - 'GHS' => __( 'Ghana Cedi', 'invoicing' ), |
|
387 | - 'GIP' => __( 'Gibraltar Pound', 'invoicing' ), |
|
388 | - 'GMD' => __( 'Gambian Dalasi', 'invoicing' ), |
|
389 | - 'GNF' => __( 'Guinean Franc', 'invoicing' ), |
|
390 | - 'GTQ' => __( 'Guatemalan Quetzal', 'invoicing' ), |
|
391 | - 'GYD' => __( 'Guyanese Dollar', 'invoicing' ), |
|
392 | - 'HKD' => __( 'Hong Kong Dollar', 'invoicing' ), |
|
393 | - 'HNL' => __( 'Honduran Lempira', 'invoicing' ), |
|
394 | - 'HRK' => __( 'Croatian Kuna', 'invoicing' ), |
|
395 | - 'HTG' => __( 'Haitian Gourde', 'invoicing' ), |
|
396 | - 'HUF' => __( 'Hungarian Forint', 'invoicing' ), |
|
397 | - 'IDR' => __( 'Indonesian Rupiah', 'invoicing' ), |
|
398 | - 'ILS' => __( 'Israeli New Shekel', 'invoicing' ), |
|
399 | - 'IMP' => __( 'Manx Pound', 'invoicing' ), |
|
400 | - 'INR' => __( 'Indian Rupee', 'invoicing' ), |
|
401 | - 'IQD' => __( 'Iraqi Dinar', 'invoicing' ), |
|
402 | - 'IRR' => __( 'Iranian Rial', 'invoicing' ), |
|
403 | - 'IRT' => __( 'Iranian Toman', 'invoicing' ), |
|
404 | - 'ISK' => __( 'Icelandic Krona', 'invoicing' ), |
|
405 | - 'JEP' => __( 'Jersey Pound', 'invoicing' ), |
|
406 | - 'JMD' => __( 'Jamaican Dollar', 'invoicing' ), |
|
407 | - 'JOD' => __( 'Jordanian Dinar', 'invoicing' ), |
|
408 | - 'JPY' => __( 'Japanese Yen', 'invoicing' ), |
|
409 | - 'KES' => __( 'Kenyan Shilling', 'invoicing' ), |
|
410 | - 'KGS' => __( 'Kyrgyzstani Som', 'invoicing' ), |
|
411 | - 'KHR' => __( 'Cambodian Riel', 'invoicing' ), |
|
412 | - 'KMF' => __( 'Comorian Franc', 'invoicing' ), |
|
413 | - 'KPW' => __( 'North Korean Won', 'invoicing' ), |
|
414 | - 'KRW' => __( 'South Korean Won', 'invoicing' ), |
|
415 | - 'KWD' => __( 'Kuwaiti Dinar', 'invoicing' ), |
|
416 | - 'KYD' => __( 'Cayman Islands Dollar', 'invoicing' ), |
|
417 | - 'KZT' => __( 'Kazakhstani Tenge', 'invoicing' ), |
|
418 | - 'LAK' => __( 'Lao Kip', 'invoicing' ), |
|
419 | - 'LBP' => __( 'Lebanese Pound', 'invoicing' ), |
|
420 | - 'LKR' => __( 'Sri Lankan Rupee', 'invoicing' ), |
|
421 | - 'LRD' => __( 'Liberian Dollar', 'invoicing' ), |
|
422 | - 'LSL' => __( 'Lesotho Loti', 'invoicing' ), |
|
423 | - 'LYD' => __( 'Libyan Dinar', 'invoicing' ), |
|
424 | - 'MAD' => __( 'Moroccan Dirham', 'invoicing' ), |
|
425 | - 'MDL' => __( 'Moldovan Leu', 'invoicing' ), |
|
426 | - 'MGA' => __( 'Malagasy Ariary', 'invoicing' ), |
|
427 | - 'MKD' => __( 'Macedonian Denar', 'invoicing' ), |
|
428 | - 'MMK' => __( 'Burmese Kyat', 'invoicing' ), |
|
429 | - 'MNT' => __( 'Mongolian Tughrik', 'invoicing' ), |
|
430 | - 'MOP' => __( 'Macanese Pataca', 'invoicing' ), |
|
431 | - 'MRO' => __( 'Mauritanian Ouguiya', 'invoicing' ), |
|
432 | - 'MUR' => __( 'Mauritian Rupee', 'invoicing' ), |
|
433 | - 'MVR' => __( 'Maldivian Rufiyaa', 'invoicing' ), |
|
434 | - 'MWK' => __( 'Malawian Kwacha', 'invoicing' ), |
|
435 | - 'MXN' => __( 'Mexican Peso', 'invoicing' ), |
|
436 | - 'MYR' => __( 'Malaysian Ringgit', 'invoicing' ), |
|
437 | - 'MZN' => __( 'Mozambican Metical', 'invoicing' ), |
|
438 | - 'NAD' => __( 'Namibian Dollar', 'invoicing' ), |
|
439 | - 'NGN' => __( 'Nigerian Naira', 'invoicing' ), |
|
440 | - 'NIO' => __( 'Nicaraguan Cordoba', 'invoicing' ), |
|
441 | - 'NOK' => __( 'Norwegian Krone', 'invoicing' ), |
|
442 | - 'NPR' => __( 'Nepalese Rupee', 'invoicing' ), |
|
443 | - 'NZD' => __( 'New Zealand Dollar', 'invoicing' ), |
|
444 | - 'OMR' => __( 'Omani Rial', 'invoicing' ), |
|
445 | - 'PAB' => __( 'Panamanian Balboa', 'invoicing' ), |
|
446 | - 'PEN' => __( 'Peruvian Nuevo Sol', 'invoicing' ), |
|
447 | - 'PGK' => __( 'Papua New Guinean Kina', 'invoicing' ), |
|
448 | - 'PHP' => __( 'Philippine Peso', 'invoicing' ), |
|
449 | - 'PKR' => __( 'Pakistani Rupee', 'invoicing' ), |
|
450 | - 'PLN' => __( 'Polish Zloty', 'invoicing' ), |
|
451 | - 'PRB' => __( 'Transnistrian Ruble', 'invoicing' ), |
|
452 | - 'PYG' => __( 'Paraguayan Guarani', 'invoicing' ), |
|
453 | - 'QAR' => __( 'Qatari Riyal', 'invoicing' ), |
|
454 | - 'RON' => __( 'Romanian Leu', 'invoicing' ), |
|
455 | - 'RSD' => __( 'Serbian Dinar', 'invoicing' ), |
|
456 | - 'RUB' => __( 'Russian Ruble', 'invoicing' ), |
|
457 | - 'RWF' => __( 'Rwandan Franc', 'invoicing' ), |
|
458 | - 'SAR' => __( 'Saudi Riyal', 'invoicing' ), |
|
459 | - 'SBD' => __( 'Solomon Islands Dollar', 'invoicing' ), |
|
460 | - 'SCR' => __( 'Seychellois Rupee', 'invoicing' ), |
|
461 | - 'SDG' => __( 'Sudanese Pound', 'invoicing' ), |
|
462 | - 'SEK' => __( 'Swedish Krona', 'invoicing' ), |
|
463 | - 'SGD' => __( 'Singapore Dollar', 'invoicing' ), |
|
464 | - 'SHP' => __( 'Saint Helena Pound', 'invoicing' ), |
|
465 | - 'SLL' => __( 'Sierra Leonean Leone', 'invoicing' ), |
|
466 | - 'SOS' => __( 'Somali Shilling', 'invoicing' ), |
|
467 | - 'SRD' => __( 'Surinamese Dollar', 'invoicing' ), |
|
468 | - 'SSP' => __( 'South Sudanese Pound', 'invoicing' ), |
|
469 | - 'STD' => __( 'Sao Tomean Dobra', 'invoicing' ), |
|
470 | - 'SYP' => __( 'Syrian Pound', 'invoicing' ), |
|
471 | - 'SZL' => __( 'Swazi Lilangeni', 'invoicing' ), |
|
472 | - 'THB' => __( 'Thai Baht', 'invoicing' ), |
|
473 | - 'TJS' => __( 'Tajikistani Somoni', 'invoicing' ), |
|
474 | - 'TMT' => __( 'Turkmenistan Manat', 'invoicing' ), |
|
475 | - 'TND' => __( 'Tunisian Dinar', 'invoicing' ), |
|
476 | - 'TOP' => __( 'Tongan Paʻanga', 'invoicing' ), |
|
477 | - 'TRY' => __( 'Turkish Lira', 'invoicing' ), |
|
478 | - 'TTD' => __( 'Trinidad and Tobago Dollar', 'invoicing' ), |
|
479 | - 'TWD' => __( 'New Taiwan Dollar', 'invoicing' ), |
|
480 | - 'TZS' => __( 'Tanzanian Shilling', 'invoicing' ), |
|
481 | - 'UAH' => __( 'Ukrainian Hryvnia', 'invoicing' ), |
|
482 | - 'UGX' => __( 'Ugandan Shilling', 'invoicing' ), |
|
483 | - 'UYU' => __( 'Uruguayan Peso', 'invoicing' ), |
|
484 | - 'UZS' => __( 'Uzbekistani Som', 'invoicing' ), |
|
485 | - 'VEF' => __( 'Venezuelan Bolívar', 'invoicing' ), |
|
486 | - 'VND' => __( 'Vietnamese Dong', 'invoicing' ), |
|
487 | - 'VUV' => __( 'Vanuatu Vatu', 'invoicing' ), |
|
488 | - 'WST' => __( 'Samoan Tala', 'invoicing' ), |
|
489 | - 'XAF' => __( 'Central African CFA Franc', 'invoicing' ), |
|
490 | - 'XCD' => __( 'East Caribbean Dollar', 'invoicing' ), |
|
491 | - 'XOF' => __( 'West African CFA Franc', 'invoicing' ), |
|
492 | - 'XPF' => __( 'CFP Franc', 'invoicing' ), |
|
493 | - 'YER' => __( 'Yemeni Rial', 'invoicing' ), |
|
494 | - 'ZAR' => __( 'South African Rand', 'invoicing' ), |
|
495 | - 'ZMW' => __( 'Zambian Kwacha', 'invoicing' ), |
|
335 | + 'USD' => __('US Dollar', 'invoicing'), |
|
336 | + 'EUR' => __('Euro', 'invoicing'), |
|
337 | + 'GBP' => __('Pound Sterling', 'invoicing'), |
|
338 | + 'AED' => __('United Arab Emirates', 'invoicing'), |
|
339 | + 'AFN' => __('Afghan Afghani', 'invoicing'), |
|
340 | + 'ALL' => __('Albanian Lek', 'invoicing'), |
|
341 | + 'AMD' => __('Armenian Dram', 'invoicing'), |
|
342 | + 'ANG' => __('Netherlands Antillean Guilder', 'invoicing'), |
|
343 | + 'AOA' => __('Angolan Kwanza', 'invoicing'), |
|
344 | + 'ARS' => __('Argentine Peso', 'invoicing'), |
|
345 | + 'AUD' => __('Australian Dollar', 'invoicing'), |
|
346 | + 'AWG' => __('Aruban Florin', 'invoicing'), |
|
347 | + 'AZN' => __('Azerbaijani Manat', 'invoicing'), |
|
348 | + 'BAM' => __('Bosnia and Herzegovina Convertible Marka', 'invoicing'), |
|
349 | + 'BBD' => __('Barbadian Dollar', 'invoicing'), |
|
350 | + 'BDT' => __('Bangladeshi Taka', 'invoicing'), |
|
351 | + 'BGN' => __('Bulgarian Lev', 'invoicing'), |
|
352 | + 'BHD' => __('Bahraini Dinar', 'invoicing'), |
|
353 | + 'BIF' => __('Burundian Franc', 'invoicing'), |
|
354 | + 'BMD' => __('Bermudian Dollar', 'invoicing'), |
|
355 | + 'BND' => __('Brunei Dollar', 'invoicing'), |
|
356 | + 'BOB' => __('Bolivian Boliviano', 'invoicing'), |
|
357 | + 'BRL' => __('Brazilian Real', 'invoicing'), |
|
358 | + 'BSD' => __('Bahamian Dollar', 'invoicing'), |
|
359 | + 'BTC' => __('Bitcoin', 'invoicing'), |
|
360 | + 'BTN' => __('Bhutanese Ngultrum', 'invoicing'), |
|
361 | + 'BWP' => __('Botswana Pula', 'invoicing'), |
|
362 | + 'BYN' => __('Belarusian Ruble', 'invoicing'), |
|
363 | + 'BZD' => __('Belize Dollar', 'invoicing'), |
|
364 | + 'CAD' => __('Canadian Dollar', 'invoicing'), |
|
365 | + 'CDF' => __('Congolese Franc', 'invoicing'), |
|
366 | + 'CHF' => __('Swiss Franc', 'invoicing'), |
|
367 | + 'CLP' => __('Chilean Peso', 'invoicing'), |
|
368 | + 'CNY' => __('Chinese Yuan', 'invoicing'), |
|
369 | + 'COP' => __('Colombian Peso', 'invoicing'), |
|
370 | + 'CRC' => __('Costa Rican Colon', 'invoicing'), |
|
371 | + 'CUC' => __('Cuban Convertible Peso', 'invoicing'), |
|
372 | + 'CUP' => __('Cuban Peso', 'invoicing'), |
|
373 | + 'CVE' => __('Cape Verdean escudo', 'invoicing'), |
|
374 | + 'CZK' => __('Czech Koruna', 'invoicing'), |
|
375 | + 'DJF' => __('Djiboutian Franc', 'invoicing'), |
|
376 | + 'DKK' => __('Danish Krone', 'invoicing'), |
|
377 | + 'DOP' => __('Dominican Peso', 'invoicing'), |
|
378 | + 'DZD' => __('Algerian Dinar', 'invoicing'), |
|
379 | + 'EGP' => __('Egyptian Pound', 'invoicing'), |
|
380 | + 'ERN' => __('Eritrean Nakfa', 'invoicing'), |
|
381 | + 'ETB' => __('Ethiopian Irr', 'invoicing'), |
|
382 | + 'FJD' => __('Fijian Dollar', 'invoicing'), |
|
383 | + 'FKP' => __('Falkland Islands Pound', 'invoicing'), |
|
384 | + 'GEL' => __('Georgian Lari', 'invoicing'), |
|
385 | + 'GGP' => __('Guernsey Pound', 'invoicing'), |
|
386 | + 'GHS' => __('Ghana Cedi', 'invoicing'), |
|
387 | + 'GIP' => __('Gibraltar Pound', 'invoicing'), |
|
388 | + 'GMD' => __('Gambian Dalasi', 'invoicing'), |
|
389 | + 'GNF' => __('Guinean Franc', 'invoicing'), |
|
390 | + 'GTQ' => __('Guatemalan Quetzal', 'invoicing'), |
|
391 | + 'GYD' => __('Guyanese Dollar', 'invoicing'), |
|
392 | + 'HKD' => __('Hong Kong Dollar', 'invoicing'), |
|
393 | + 'HNL' => __('Honduran Lempira', 'invoicing'), |
|
394 | + 'HRK' => __('Croatian Kuna', 'invoicing'), |
|
395 | + 'HTG' => __('Haitian Gourde', 'invoicing'), |
|
396 | + 'HUF' => __('Hungarian Forint', 'invoicing'), |
|
397 | + 'IDR' => __('Indonesian Rupiah', 'invoicing'), |
|
398 | + 'ILS' => __('Israeli New Shekel', 'invoicing'), |
|
399 | + 'IMP' => __('Manx Pound', 'invoicing'), |
|
400 | + 'INR' => __('Indian Rupee', 'invoicing'), |
|
401 | + 'IQD' => __('Iraqi Dinar', 'invoicing'), |
|
402 | + 'IRR' => __('Iranian Rial', 'invoicing'), |
|
403 | + 'IRT' => __('Iranian Toman', 'invoicing'), |
|
404 | + 'ISK' => __('Icelandic Krona', 'invoicing'), |
|
405 | + 'JEP' => __('Jersey Pound', 'invoicing'), |
|
406 | + 'JMD' => __('Jamaican Dollar', 'invoicing'), |
|
407 | + 'JOD' => __('Jordanian Dinar', 'invoicing'), |
|
408 | + 'JPY' => __('Japanese Yen', 'invoicing'), |
|
409 | + 'KES' => __('Kenyan Shilling', 'invoicing'), |
|
410 | + 'KGS' => __('Kyrgyzstani Som', 'invoicing'), |
|
411 | + 'KHR' => __('Cambodian Riel', 'invoicing'), |
|
412 | + 'KMF' => __('Comorian Franc', 'invoicing'), |
|
413 | + 'KPW' => __('North Korean Won', 'invoicing'), |
|
414 | + 'KRW' => __('South Korean Won', 'invoicing'), |
|
415 | + 'KWD' => __('Kuwaiti Dinar', 'invoicing'), |
|
416 | + 'KYD' => __('Cayman Islands Dollar', 'invoicing'), |
|
417 | + 'KZT' => __('Kazakhstani Tenge', 'invoicing'), |
|
418 | + 'LAK' => __('Lao Kip', 'invoicing'), |
|
419 | + 'LBP' => __('Lebanese Pound', 'invoicing'), |
|
420 | + 'LKR' => __('Sri Lankan Rupee', 'invoicing'), |
|
421 | + 'LRD' => __('Liberian Dollar', 'invoicing'), |
|
422 | + 'LSL' => __('Lesotho Loti', 'invoicing'), |
|
423 | + 'LYD' => __('Libyan Dinar', 'invoicing'), |
|
424 | + 'MAD' => __('Moroccan Dirham', 'invoicing'), |
|
425 | + 'MDL' => __('Moldovan Leu', 'invoicing'), |
|
426 | + 'MGA' => __('Malagasy Ariary', 'invoicing'), |
|
427 | + 'MKD' => __('Macedonian Denar', 'invoicing'), |
|
428 | + 'MMK' => __('Burmese Kyat', 'invoicing'), |
|
429 | + 'MNT' => __('Mongolian Tughrik', 'invoicing'), |
|
430 | + 'MOP' => __('Macanese Pataca', 'invoicing'), |
|
431 | + 'MRO' => __('Mauritanian Ouguiya', 'invoicing'), |
|
432 | + 'MUR' => __('Mauritian Rupee', 'invoicing'), |
|
433 | + 'MVR' => __('Maldivian Rufiyaa', 'invoicing'), |
|
434 | + 'MWK' => __('Malawian Kwacha', 'invoicing'), |
|
435 | + 'MXN' => __('Mexican Peso', 'invoicing'), |
|
436 | + 'MYR' => __('Malaysian Ringgit', 'invoicing'), |
|
437 | + 'MZN' => __('Mozambican Metical', 'invoicing'), |
|
438 | + 'NAD' => __('Namibian Dollar', 'invoicing'), |
|
439 | + 'NGN' => __('Nigerian Naira', 'invoicing'), |
|
440 | + 'NIO' => __('Nicaraguan Cordoba', 'invoicing'), |
|
441 | + 'NOK' => __('Norwegian Krone', 'invoicing'), |
|
442 | + 'NPR' => __('Nepalese Rupee', 'invoicing'), |
|
443 | + 'NZD' => __('New Zealand Dollar', 'invoicing'), |
|
444 | + 'OMR' => __('Omani Rial', 'invoicing'), |
|
445 | + 'PAB' => __('Panamanian Balboa', 'invoicing'), |
|
446 | + 'PEN' => __('Peruvian Nuevo Sol', 'invoicing'), |
|
447 | + 'PGK' => __('Papua New Guinean Kina', 'invoicing'), |
|
448 | + 'PHP' => __('Philippine Peso', 'invoicing'), |
|
449 | + 'PKR' => __('Pakistani Rupee', 'invoicing'), |
|
450 | + 'PLN' => __('Polish Zloty', 'invoicing'), |
|
451 | + 'PRB' => __('Transnistrian Ruble', 'invoicing'), |
|
452 | + 'PYG' => __('Paraguayan Guarani', 'invoicing'), |
|
453 | + 'QAR' => __('Qatari Riyal', 'invoicing'), |
|
454 | + 'RON' => __('Romanian Leu', 'invoicing'), |
|
455 | + 'RSD' => __('Serbian Dinar', 'invoicing'), |
|
456 | + 'RUB' => __('Russian Ruble', 'invoicing'), |
|
457 | + 'RWF' => __('Rwandan Franc', 'invoicing'), |
|
458 | + 'SAR' => __('Saudi Riyal', 'invoicing'), |
|
459 | + 'SBD' => __('Solomon Islands Dollar', 'invoicing'), |
|
460 | + 'SCR' => __('Seychellois Rupee', 'invoicing'), |
|
461 | + 'SDG' => __('Sudanese Pound', 'invoicing'), |
|
462 | + 'SEK' => __('Swedish Krona', 'invoicing'), |
|
463 | + 'SGD' => __('Singapore Dollar', 'invoicing'), |
|
464 | + 'SHP' => __('Saint Helena Pound', 'invoicing'), |
|
465 | + 'SLL' => __('Sierra Leonean Leone', 'invoicing'), |
|
466 | + 'SOS' => __('Somali Shilling', 'invoicing'), |
|
467 | + 'SRD' => __('Surinamese Dollar', 'invoicing'), |
|
468 | + 'SSP' => __('South Sudanese Pound', 'invoicing'), |
|
469 | + 'STD' => __('Sao Tomean Dobra', 'invoicing'), |
|
470 | + 'SYP' => __('Syrian Pound', 'invoicing'), |
|
471 | + 'SZL' => __('Swazi Lilangeni', 'invoicing'), |
|
472 | + 'THB' => __('Thai Baht', 'invoicing'), |
|
473 | + 'TJS' => __('Tajikistani Somoni', 'invoicing'), |
|
474 | + 'TMT' => __('Turkmenistan Manat', 'invoicing'), |
|
475 | + 'TND' => __('Tunisian Dinar', 'invoicing'), |
|
476 | + 'TOP' => __('Tongan Paʻanga', 'invoicing'), |
|
477 | + 'TRY' => __('Turkish Lira', 'invoicing'), |
|
478 | + 'TTD' => __('Trinidad and Tobago Dollar', 'invoicing'), |
|
479 | + 'TWD' => __('New Taiwan Dollar', 'invoicing'), |
|
480 | + 'TZS' => __('Tanzanian Shilling', 'invoicing'), |
|
481 | + 'UAH' => __('Ukrainian Hryvnia', 'invoicing'), |
|
482 | + 'UGX' => __('Ugandan Shilling', 'invoicing'), |
|
483 | + 'UYU' => __('Uruguayan Peso', 'invoicing'), |
|
484 | + 'UZS' => __('Uzbekistani Som', 'invoicing'), |
|
485 | + 'VEF' => __('Venezuelan Bolívar', 'invoicing'), |
|
486 | + 'VND' => __('Vietnamese Dong', 'invoicing'), |
|
487 | + 'VUV' => __('Vanuatu Vatu', 'invoicing'), |
|
488 | + 'WST' => __('Samoan Tala', 'invoicing'), |
|
489 | + 'XAF' => __('Central African CFA Franc', 'invoicing'), |
|
490 | + 'XCD' => __('East Caribbean Dollar', 'invoicing'), |
|
491 | + 'XOF' => __('West African CFA Franc', 'invoicing'), |
|
492 | + 'XPF' => __('CFP Franc', 'invoicing'), |
|
493 | + 'YER' => __('Yemeni Rial', 'invoicing'), |
|
494 | + 'ZAR' => __('South African Rand', 'invoicing'), |
|
495 | + 'ZMW' => __('Zambian Kwacha', 'invoicing'), |
|
496 | 496 | ); |
497 | 497 | |
498 | 498 | //asort( $currencies ); // this |
499 | 499 | |
500 | - return apply_filters( 'wpinv_currencies', $currencies ); |
|
500 | + return apply_filters('wpinv_currencies', $currencies); |
|
501 | 501 | } |
502 | 502 | |
503 | -function wpinv_price( $amount = '', $currency = '' ) { |
|
504 | - if( empty( $currency ) ) { |
|
503 | +function wpinv_price($amount = '', $currency = '') { |
|
504 | + if (empty($currency)) { |
|
505 | 505 | $currency = wpinv_get_currency(); |
506 | 506 | } |
507 | 507 | |
@@ -509,14 +509,14 @@ discard block |
||
509 | 509 | |
510 | 510 | $negative = $amount < 0; |
511 | 511 | |
512 | - if ( $negative ) { |
|
513 | - $amount = substr( $amount, 1 ); |
|
512 | + if ($negative) { |
|
513 | + $amount = substr($amount, 1); |
|
514 | 514 | } |
515 | 515 | |
516 | - $symbol = wpinv_currency_symbol( $currency ); |
|
516 | + $symbol = wpinv_currency_symbol($currency); |
|
517 | 517 | |
518 | - if ( $position == 'left' || $position == 'left_space' ) { |
|
519 | - switch ( $currency ) { |
|
518 | + if ($position == 'left' || $position == 'left_space') { |
|
519 | + switch ($currency) { |
|
520 | 520 | case "GBP" : |
521 | 521 | case "BRL" : |
522 | 522 | case "EUR" : |
@@ -528,15 +528,15 @@ discard block |
||
528 | 528 | case "NZD" : |
529 | 529 | case "SGD" : |
530 | 530 | case "JPY" : |
531 | - $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
531 | + $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
532 | 532 | break; |
533 | 533 | default : |
534 | 534 | //$price = $currency . ' ' . $amount; |
535 | - $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
535 | + $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
536 | 536 | break; |
537 | 537 | } |
538 | 538 | } else { |
539 | - switch ( $currency ) { |
|
539 | + switch ($currency) { |
|
540 | 540 | case "GBP" : |
541 | 541 | case "BRL" : |
542 | 542 | case "EUR" : |
@@ -547,83 +547,83 @@ discard block |
||
547 | 547 | case "MXN" : |
548 | 548 | case "SGD" : |
549 | 549 | case "JPY" : |
550 | - $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
550 | + $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
551 | 551 | break; |
552 | 552 | default : |
553 | 553 | //$price = $amount . ' ' . $currency; |
554 | - $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
554 | + $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
555 | 555 | break; |
556 | 556 | } |
557 | 557 | } |
558 | 558 | |
559 | - if ( $negative ) { |
|
559 | + if ($negative) { |
|
560 | 560 | $price = '-' . $price; |
561 | 561 | } |
562 | 562 | |
563 | - $price = apply_filters( 'wpinv_' . strtolower( $currency ) . '_currency_filter_' . $position, $price, $currency, $amount ); |
|
563 | + $price = apply_filters('wpinv_' . strtolower($currency) . '_currency_filter_' . $position, $price, $currency, $amount); |
|
564 | 564 | |
565 | 565 | return $price; |
566 | 566 | } |
567 | 567 | |
568 | -function wpinv_format_amount( $amount, $decimals = NULL, $calculate = false ) { |
|
568 | +function wpinv_format_amount($amount, $decimals = NULL, $calculate = false) { |
|
569 | 569 | $thousands_sep = wpinv_thousands_separator(); |
570 | 570 | $decimal_sep = wpinv_decimal_separator(); |
571 | 571 | |
572 | - if ( $decimals === NULL ) { |
|
572 | + if ($decimals === NULL) { |
|
573 | 573 | $decimals = wpinv_decimals(); |
574 | 574 | } |
575 | 575 | |
576 | - if ( $decimal_sep == ',' && false !== ( $sep_found = strpos( $amount, $decimal_sep ) ) ) { |
|
577 | - $whole = substr( $amount, 0, $sep_found ); |
|
578 | - $part = substr( $amount, $sep_found + 1, ( strlen( $amount ) - 1 ) ); |
|
576 | + if ($decimal_sep == ',' && false !== ($sep_found = strpos($amount, $decimal_sep))) { |
|
577 | + $whole = substr($amount, 0, $sep_found); |
|
578 | + $part = substr($amount, $sep_found + 1, (strlen($amount) - 1)); |
|
579 | 579 | $amount = $whole . '.' . $part; |
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 ( $thousands_sep == ' ' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
587 | - $amount = str_replace( ' ', '', $amount ); |
|
586 | + if ($thousands_sep == ' ' && false !== ($found = strpos($amount, $thousands_sep))) { |
|
587 | + $amount = str_replace(' ', '', $amount); |
|
588 | 588 | } |
589 | 589 | |
590 | - if ( empty( $amount ) ) { |
|
590 | + if (empty($amount)) { |
|
591 | 591 | $amount = 0; |
592 | 592 | } |
593 | 593 | |
594 | - $decimals = apply_filters( 'wpinv_amount_format_decimals', $decimals ? $decimals : 0, $amount, $calculate ); |
|
595 | - $formatted = number_format( (float)$amount, $decimals, $decimal_sep, $thousands_sep ); |
|
594 | + $decimals = apply_filters('wpinv_amount_format_decimals', $decimals ? $decimals : 0, $amount, $calculate); |
|
595 | + $formatted = number_format((float) $amount, $decimals, $decimal_sep, $thousands_sep); |
|
596 | 596 | |
597 | - if ( $calculate ) { |
|
598 | - if ( $thousands_sep === "," ) { |
|
599 | - $formatted = str_replace( ",", "", $formatted ); |
|
597 | + if ($calculate) { |
|
598 | + if ($thousands_sep === ",") { |
|
599 | + $formatted = str_replace(",", "", $formatted); |
|
600 | 600 | } |
601 | 601 | |
602 | - if ( $decimal_sep === "," ) { |
|
603 | - $formatted = str_replace( ",", ".", $formatted ); |
|
602 | + if ($decimal_sep === ",") { |
|
603 | + $formatted = str_replace(",", ".", $formatted); |
|
604 | 604 | } |
605 | 605 | } |
606 | 606 | |
607 | - return apply_filters( 'wpinv_amount_format', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $calculate ); |
|
607 | + return apply_filters('wpinv_amount_format', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $calculate); |
|
608 | 608 | } |
609 | -add_filter( 'wpinv_amount_format_decimals', 'wpinv_currency_decimal_filter', 10, 1 ); |
|
609 | +add_filter('wpinv_amount_format_decimals', 'wpinv_currency_decimal_filter', 10, 1); |
|
610 | 610 | |
611 | -function wpinv_sanitize_key( $key ) { |
|
611 | +function wpinv_sanitize_key($key) { |
|
612 | 612 | $raw_key = $key; |
613 | - $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key ); |
|
613 | + $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key); |
|
614 | 614 | |
615 | - return apply_filters( 'wpinv_sanitize_key', $key, $raw_key ); |
|
615 | + return apply_filters('wpinv_sanitize_key', $key, $raw_key); |
|
616 | 616 | } |
617 | 617 | |
618 | -function wpinv_get_file_extension( $str ) { |
|
619 | - $parts = explode( '.', $str ); |
|
620 | - return end( $parts ); |
|
618 | +function wpinv_get_file_extension($str) { |
|
619 | + $parts = explode('.', $str); |
|
620 | + return end($parts); |
|
621 | 621 | } |
622 | 622 | |
623 | -function wpinv_string_is_image_url( $str ) { |
|
624 | - $ext = wpinv_get_file_extension( $str ); |
|
623 | +function wpinv_string_is_image_url($str) { |
|
624 | + $ext = wpinv_get_file_extension($str); |
|
625 | 625 | |
626 | - switch ( strtolower( $ext ) ) { |
|
626 | + switch (strtolower($ext)) { |
|
627 | 627 | case 'jpeg'; |
628 | 628 | case 'jpg'; |
629 | 629 | $return = true; |
@@ -639,33 +639,33 @@ discard block |
||
639 | 639 | break; |
640 | 640 | } |
641 | 641 | |
642 | - return (bool)apply_filters( 'wpinv_string_is_image', $return, $str ); |
|
642 | + return (bool) apply_filters('wpinv_string_is_image', $return, $str); |
|
643 | 643 | } |
644 | 644 | |
645 | -function wpinv_error_log( $log, $title = '', $file = '', $line = '', $exit = false ) { |
|
646 | - $should_log = apply_filters( 'wpinv_log_errors', WP_DEBUG ); |
|
645 | +function wpinv_error_log($log, $title = '', $file = '', $line = '', $exit = false) { |
|
646 | + $should_log = apply_filters('wpinv_log_errors', WP_DEBUG); |
|
647 | 647 | |
648 | - if ( true === $should_log ) { |
|
648 | + if (true === $should_log) { |
|
649 | 649 | $label = ''; |
650 | - if ( $file && $file !== '' ) { |
|
651 | - $label .= basename( $file ) . ( $line ? '(' . $line . ')' : '' ); |
|
650 | + if ($file && $file !== '') { |
|
651 | + $label .= basename($file) . ($line ? '(' . $line . ')' : ''); |
|
652 | 652 | } |
653 | 653 | |
654 | - if ( $title && $title !== '' ) { |
|
654 | + if ($title && $title !== '') { |
|
655 | 655 | $label = $label !== '' ? $label . ' ' : ''; |
656 | 656 | $label .= $title . ' '; |
657 | 657 | } |
658 | 658 | |
659 | - $label = $label !== '' ? trim( $label ) . ' : ' : ''; |
|
659 | + $label = $label !== '' ? trim($label) . ' : ' : ''; |
|
660 | 660 | |
661 | - if ( is_array( $log ) || is_object( $log ) ) { |
|
662 | - error_log( $label . print_r( $log, true ) ); |
|
661 | + if (is_array($log) || is_object($log)) { |
|
662 | + error_log($label . print_r($log, true)); |
|
663 | 663 | } else { |
664 | - error_log( $label . $log ); |
|
664 | + error_log($label . $log); |
|
665 | 665 | } |
666 | 666 | |
667 | - error_log( wp_debug_backtrace_summary() ); |
|
668 | - if ( $exit ) { |
|
667 | + error_log(wp_debug_backtrace_summary()); |
|
668 | + if ($exit) { |
|
669 | 669 | exit; |
670 | 670 | } |
671 | 671 | } |
@@ -673,32 +673,32 @@ discard block |
||
673 | 673 | |
674 | 674 | function wpinv_is_ajax_disabled() { |
675 | 675 | $retval = false; |
676 | - return apply_filters( 'wpinv_is_ajax_disabled', $retval ); |
|
676 | + return apply_filters('wpinv_is_ajax_disabled', $retval); |
|
677 | 677 | } |
678 | 678 | |
679 | -function wpinv_get_current_page_url( $nocache = false ) { |
|
679 | +function wpinv_get_current_page_url($nocache = false) { |
|
680 | 680 | global $wp; |
681 | 681 | |
682 | - if ( get_option( 'permalink_structure' ) ) { |
|
683 | - $base = trailingslashit( home_url( $wp->request ) ); |
|
682 | + if (get_option('permalink_structure')) { |
|
683 | + $base = trailingslashit(home_url($wp->request)); |
|
684 | 684 | } else { |
685 | - $base = add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) ); |
|
686 | - $base = remove_query_arg( array( 'post_type', 'name' ), $base ); |
|
685 | + $base = add_query_arg($wp->query_string, '', trailingslashit(home_url($wp->request))); |
|
686 | + $base = remove_query_arg(array('post_type', 'name'), $base); |
|
687 | 687 | } |
688 | 688 | |
689 | 689 | $scheme = is_ssl() ? 'https' : 'http'; |
690 | - $uri = set_url_scheme( $base, $scheme ); |
|
690 | + $uri = set_url_scheme($base, $scheme); |
|
691 | 691 | |
692 | - if ( is_front_page() ) { |
|
693 | - $uri = home_url( '/' ); |
|
694 | - } elseif ( wpinv_is_checkout( array(), false ) ) { |
|
692 | + if (is_front_page()) { |
|
693 | + $uri = home_url('/'); |
|
694 | + } elseif (wpinv_is_checkout(array(), false)) { |
|
695 | 695 | $uri = wpinv_get_checkout_uri(); |
696 | 696 | } |
697 | 697 | |
698 | - $uri = apply_filters( 'wpinv_get_current_page_url', $uri ); |
|
698 | + $uri = apply_filters('wpinv_get_current_page_url', $uri); |
|
699 | 699 | |
700 | - if ( $nocache ) { |
|
701 | - $uri = wpinv_add_cache_busting( $uri ); |
|
700 | + if ($nocache) { |
|
701 | + $uri = wpinv_add_cache_busting($uri); |
|
702 | 702 | } |
703 | 703 | |
704 | 704 | return $uri; |
@@ -711,46 +711,46 @@ discard block |
||
711 | 711 | * @param string $name Constant name. |
712 | 712 | * @param mixed $value Value. |
713 | 713 | */ |
714 | -function getpaid_maybe_define_constant( $name, $value ) { |
|
715 | - if ( ! defined( $name ) ) { |
|
716 | - define( $name, $value ); |
|
714 | +function getpaid_maybe_define_constant($name, $value) { |
|
715 | + if (!defined($name)) { |
|
716 | + define($name, $value); |
|
717 | 717 | } |
718 | 718 | } |
719 | 719 | |
720 | 720 | function wpinv_get_php_arg_separator_output() { |
721 | - return ini_get( 'arg_separator.output' ); |
|
721 | + return ini_get('arg_separator.output'); |
|
722 | 722 | } |
723 | 723 | |
724 | -function wpinv_rgb_from_hex( $color ) { |
|
725 | - $color = str_replace( '#', '', $color ); |
|
724 | +function wpinv_rgb_from_hex($color) { |
|
725 | + $color = str_replace('#', '', $color); |
|
726 | 726 | |
727 | 727 | // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF" |
728 | - $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color ); |
|
729 | - if ( empty( $color ) ) { |
|
728 | + $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color); |
|
729 | + if (empty($color)) { |
|
730 | 730 | return NULL; |
731 | 731 | } |
732 | 732 | |
733 | - $color = str_split( $color ); |
|
733 | + $color = str_split($color); |
|
734 | 734 | |
735 | 735 | $rgb = array(); |
736 | - $rgb['R'] = hexdec( $color[0] . $color[1] ); |
|
737 | - $rgb['G'] = hexdec( $color[2] . $color[3] ); |
|
738 | - $rgb['B'] = hexdec( $color[4] . $color[5] ); |
|
736 | + $rgb['R'] = hexdec($color[0] . $color[1]); |
|
737 | + $rgb['G'] = hexdec($color[2] . $color[3]); |
|
738 | + $rgb['B'] = hexdec($color[4] . $color[5]); |
|
739 | 739 | |
740 | 740 | return $rgb; |
741 | 741 | } |
742 | 742 | |
743 | -function wpinv_hex_darker( $color, $factor = 30 ) { |
|
744 | - $base = wpinv_rgb_from_hex( $color ); |
|
743 | +function wpinv_hex_darker($color, $factor = 30) { |
|
744 | + $base = wpinv_rgb_from_hex($color); |
|
745 | 745 | $color = '#'; |
746 | 746 | |
747 | - foreach ( $base as $k => $v ) { |
|
747 | + foreach ($base as $k => $v) { |
|
748 | 748 | $amount = $v / 100; |
749 | - $amount = round( $amount * $factor ); |
|
749 | + $amount = round($amount * $factor); |
|
750 | 750 | $new_decimal = $v - $amount; |
751 | 751 | |
752 | - $new_hex_component = dechex( $new_decimal ); |
|
753 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
752 | + $new_hex_component = dechex($new_decimal); |
|
753 | + if (strlen($new_hex_component) < 2) { |
|
754 | 754 | $new_hex_component = "0" . $new_hex_component; |
755 | 755 | } |
756 | 756 | $color .= $new_hex_component; |
@@ -759,18 +759,18 @@ discard block |
||
759 | 759 | return $color; |
760 | 760 | } |
761 | 761 | |
762 | -function wpinv_hex_lighter( $color, $factor = 30 ) { |
|
763 | - $base = wpinv_rgb_from_hex( $color ); |
|
762 | +function wpinv_hex_lighter($color, $factor = 30) { |
|
763 | + $base = wpinv_rgb_from_hex($color); |
|
764 | 764 | $color = '#'; |
765 | 765 | |
766 | - foreach ( $base as $k => $v ) { |
|
766 | + foreach ($base as $k => $v) { |
|
767 | 767 | $amount = 255 - $v; |
768 | 768 | $amount = $amount / 100; |
769 | - $amount = round( $amount * $factor ); |
|
769 | + $amount = round($amount * $factor); |
|
770 | 770 | $new_decimal = $v + $amount; |
771 | 771 | |
772 | - $new_hex_component = dechex( $new_decimal ); |
|
773 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
772 | + $new_hex_component = dechex($new_decimal); |
|
773 | + if (strlen($new_hex_component) < 2) { |
|
774 | 774 | $new_hex_component = "0" . $new_hex_component; |
775 | 775 | } |
776 | 776 | $color .= $new_hex_component; |
@@ -779,22 +779,22 @@ discard block |
||
779 | 779 | return $color; |
780 | 780 | } |
781 | 781 | |
782 | -function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) { |
|
783 | - $hex = str_replace( '#', '', $color ); |
|
782 | +function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') { |
|
783 | + $hex = str_replace('#', '', $color); |
|
784 | 784 | |
785 | - $c_r = hexdec( substr( $hex, 0, 2 ) ); |
|
786 | - $c_g = hexdec( substr( $hex, 2, 2 ) ); |
|
787 | - $c_b = hexdec( substr( $hex, 4, 2 ) ); |
|
785 | + $c_r = hexdec(substr($hex, 0, 2)); |
|
786 | + $c_g = hexdec(substr($hex, 2, 2)); |
|
787 | + $c_b = hexdec(substr($hex, 4, 2)); |
|
788 | 788 | |
789 | - $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000; |
|
789 | + $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000; |
|
790 | 790 | |
791 | 791 | return $brightness > 155 ? $dark : $light; |
792 | 792 | } |
793 | 793 | |
794 | -function wpinv_format_hex( $hex ) { |
|
795 | - $hex = trim( str_replace( '#', '', $hex ) ); |
|
794 | +function wpinv_format_hex($hex) { |
|
795 | + $hex = trim(str_replace('#', '', $hex)); |
|
796 | 796 | |
797 | - if ( strlen( $hex ) == 3 ) { |
|
797 | + if (strlen($hex) == 3) { |
|
798 | 798 | $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2]; |
799 | 799 | } |
800 | 800 | |
@@ -814,12 +814,12 @@ discard block |
||
814 | 814 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
815 | 815 | * @return string |
816 | 816 | */ |
817 | -function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) { |
|
818 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
819 | - return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding ); |
|
817 | +function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') { |
|
818 | + if (function_exists('mb_strimwidth')) { |
|
819 | + return mb_strimwidth($str, $start, $width, $trimmaker, $encoding); |
|
820 | 820 | } |
821 | 821 | |
822 | - return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker; |
|
822 | + return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker; |
|
823 | 823 | } |
824 | 824 | |
825 | 825 | /** |
@@ -831,28 +831,28 @@ discard block |
||
831 | 831 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
832 | 832 | * @return int Returns the number of characters in string. |
833 | 833 | */ |
834 | -function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) { |
|
835 | - if ( function_exists( 'mb_strlen' ) ) { |
|
836 | - return mb_strlen( $str, $encoding ); |
|
834 | +function wpinv_utf8_strlen($str, $encoding = 'UTF-8') { |
|
835 | + if (function_exists('mb_strlen')) { |
|
836 | + return mb_strlen($str, $encoding); |
|
837 | 837 | } |
838 | 838 | |
839 | - return strlen( $str ); |
|
839 | + return strlen($str); |
|
840 | 840 | } |
841 | 841 | |
842 | -function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) { |
|
843 | - if ( function_exists( 'mb_strtolower' ) ) { |
|
844 | - return mb_strtolower( $str, $encoding ); |
|
842 | +function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') { |
|
843 | + if (function_exists('mb_strtolower')) { |
|
844 | + return mb_strtolower($str, $encoding); |
|
845 | 845 | } |
846 | 846 | |
847 | - return strtolower( $str ); |
|
847 | + return strtolower($str); |
|
848 | 848 | } |
849 | 849 | |
850 | -function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) { |
|
851 | - if ( function_exists( 'mb_strtoupper' ) ) { |
|
852 | - return mb_strtoupper( $str, $encoding ); |
|
850 | +function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') { |
|
851 | + if (function_exists('mb_strtoupper')) { |
|
852 | + return mb_strtoupper($str, $encoding); |
|
853 | 853 | } |
854 | 854 | |
855 | - return strtoupper( $str ); |
|
855 | + return strtoupper($str); |
|
856 | 856 | } |
857 | 857 | |
858 | 858 | /** |
@@ -866,12 +866,12 @@ discard block |
||
866 | 866 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
867 | 867 | * @return int Returns the position of the first occurrence of search in the string. |
868 | 868 | */ |
869 | -function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
870 | - if ( function_exists( 'mb_strpos' ) ) { |
|
871 | - return mb_strpos( $str, $find, $offset, $encoding ); |
|
869 | +function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
870 | + if (function_exists('mb_strpos')) { |
|
871 | + return mb_strpos($str, $find, $offset, $encoding); |
|
872 | 872 | } |
873 | 873 | |
874 | - return strpos( $str, $find, $offset ); |
|
874 | + return strpos($str, $find, $offset); |
|
875 | 875 | } |
876 | 876 | |
877 | 877 | /** |
@@ -885,12 +885,12 @@ discard block |
||
885 | 885 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
886 | 886 | * @return int Returns the position of the last occurrence of search. |
887 | 887 | */ |
888 | -function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
889 | - if ( function_exists( 'mb_strrpos' ) ) { |
|
890 | - return mb_strrpos( $str, $find, $offset, $encoding ); |
|
888 | +function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
889 | + if (function_exists('mb_strrpos')) { |
|
890 | + return mb_strrpos($str, $find, $offset, $encoding); |
|
891 | 891 | } |
892 | 892 | |
893 | - return strrpos( $str, $find, $offset ); |
|
893 | + return strrpos($str, $find, $offset); |
|
894 | 894 | } |
895 | 895 | |
896 | 896 | /** |
@@ -905,16 +905,16 @@ discard block |
||
905 | 905 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
906 | 906 | * @return string |
907 | 907 | */ |
908 | -function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) { |
|
909 | - if ( function_exists( 'mb_substr' ) ) { |
|
910 | - if ( $length === null ) { |
|
911 | - return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
908 | +function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') { |
|
909 | + if (function_exists('mb_substr')) { |
|
910 | + if ($length === null) { |
|
911 | + return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
912 | 912 | } else { |
913 | - return mb_substr( $str, $start, $length, $encoding ); |
|
913 | + return mb_substr($str, $start, $length, $encoding); |
|
914 | 914 | } |
915 | 915 | } |
916 | 916 | |
917 | - return substr( $str, $start, $length ); |
|
917 | + return substr($str, $start, $length); |
|
918 | 918 | } |
919 | 919 | |
920 | 920 | /** |
@@ -926,48 +926,48 @@ discard block |
||
926 | 926 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
927 | 927 | * @return string The width of string. |
928 | 928 | */ |
929 | -function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) { |
|
930 | - if ( function_exists( 'mb_strwidth' ) ) { |
|
931 | - return mb_strwidth( $str, $encoding ); |
|
929 | +function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') { |
|
930 | + if (function_exists('mb_strwidth')) { |
|
931 | + return mb_strwidth($str, $encoding); |
|
932 | 932 | } |
933 | 933 | |
934 | - return wpinv_utf8_strlen( $str, $encoding ); |
|
934 | + return wpinv_utf8_strlen($str, $encoding); |
|
935 | 935 | } |
936 | 936 | |
937 | -function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) { |
|
938 | - if ( function_exists( 'mb_strlen' ) ) { |
|
939 | - $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding ); |
|
937 | +function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') { |
|
938 | + if (function_exists('mb_strlen')) { |
|
939 | + $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding); |
|
940 | 940 | $str_end = ""; |
941 | 941 | |
942 | - if ( $lower_str_end ) { |
|
943 | - $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding ); |
|
942 | + if ($lower_str_end) { |
|
943 | + $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding); |
|
944 | 944 | } else { |
945 | - $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
945 | + $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
946 | 946 | } |
947 | 947 | |
948 | 948 | return $first_letter . $str_end; |
949 | 949 | } |
950 | 950 | |
951 | - return ucfirst( $str ); |
|
951 | + return ucfirst($str); |
|
952 | 952 | } |
953 | 953 | |
954 | -function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) { |
|
955 | - if ( function_exists( 'mb_convert_case' ) ) { |
|
956 | - return mb_convert_case( $str, MB_CASE_TITLE, $encoding ); |
|
954 | +function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') { |
|
955 | + if (function_exists('mb_convert_case')) { |
|
956 | + return mb_convert_case($str, MB_CASE_TITLE, $encoding); |
|
957 | 957 | } |
958 | 958 | |
959 | - return ucwords( $str ); |
|
959 | + return ucwords($str); |
|
960 | 960 | } |
961 | 961 | |
962 | -function wpinv_period_in_days( $period, $unit ) { |
|
963 | - $period = absint( $period ); |
|
962 | +function wpinv_period_in_days($period, $unit) { |
|
963 | + $period = absint($period); |
|
964 | 964 | |
965 | - if ( $period > 0 ) { |
|
966 | - if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) { |
|
965 | + if ($period > 0) { |
|
966 | + if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) { |
|
967 | 967 | $period = $period * 7; |
968 | - } else if ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) { |
|
968 | + } else if (in_array(strtolower($unit), array('m', 'month', 'months'))) { |
|
969 | 969 | $period = $period * 30; |
970 | - } else if ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) { |
|
970 | + } else if (in_array(strtolower($unit), array('y', 'year', 'years'))) { |
|
971 | 971 | $period = $period * 365; |
972 | 972 | } |
973 | 973 | } |
@@ -975,14 +975,14 @@ discard block |
||
975 | 975 | return $period; |
976 | 976 | } |
977 | 977 | |
978 | -function wpinv_cal_days_in_month( $calendar, $month, $year ) { |
|
979 | - if ( function_exists( 'cal_days_in_month' ) ) { |
|
980 | - return cal_days_in_month( $calendar, $month, $year ); |
|
978 | +function wpinv_cal_days_in_month($calendar, $month, $year) { |
|
979 | + if (function_exists('cal_days_in_month')) { |
|
980 | + return cal_days_in_month($calendar, $month, $year); |
|
981 | 981 | } |
982 | 982 | |
983 | 983 | // Fallback in case the calendar extension is not loaded in PHP |
984 | 984 | // Only supports Gregorian calendar |
985 | - return date( 't', mktime( 0, 0, 0, $month, 1, $year ) ); |
|
985 | + return date('t', mktime(0, 0, 0, $month, 1, $year)); |
|
986 | 986 | } |
987 | 987 | |
988 | 988 | /** |
@@ -993,11 +993,11 @@ discard block |
||
993 | 993 | * |
994 | 994 | * @return string |
995 | 995 | */ |
996 | -function wpi_help_tip( $tip, $allow_html = false ) { |
|
997 | - if ( $allow_html ) { |
|
998 | - $tip = wpi_sanitize_tooltip( $tip ); |
|
996 | +function wpi_help_tip($tip, $allow_html = false) { |
|
997 | + if ($allow_html) { |
|
998 | + $tip = wpi_sanitize_tooltip($tip); |
|
999 | 999 | } else { |
1000 | - $tip = esc_attr( $tip ); |
|
1000 | + $tip = esc_attr($tip); |
|
1001 | 1001 | } |
1002 | 1002 | |
1003 | 1003 | return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
@@ -1011,8 +1011,8 @@ discard block |
||
1011 | 1011 | * @param string $var |
1012 | 1012 | * @return string |
1013 | 1013 | */ |
1014 | -function wpi_sanitize_tooltip( $var ) { |
|
1015 | - return htmlspecialchars( wp_kses( html_entity_decode( $var ), array( |
|
1014 | +function wpi_sanitize_tooltip($var) { |
|
1015 | + return htmlspecialchars(wp_kses(html_entity_decode($var), array( |
|
1016 | 1016 | 'br' => array(), |
1017 | 1017 | 'em' => array(), |
1018 | 1018 | 'strong' => array(), |
@@ -1022,7 +1022,7 @@ discard block |
||
1022 | 1022 | 'li' => array(), |
1023 | 1023 | 'ol' => array(), |
1024 | 1024 | 'p' => array(), |
1025 | - ) ) ); |
|
1025 | + ))); |
|
1026 | 1026 | } |
1027 | 1027 | |
1028 | 1028 | /** |
@@ -1032,7 +1032,7 @@ discard block |
||
1032 | 1032 | */ |
1033 | 1033 | function wpinv_get_screen_ids() { |
1034 | 1034 | |
1035 | - $screen_id = sanitize_title( __( 'Invoicing', 'invoicing' ) ); |
|
1035 | + $screen_id = sanitize_title(__('Invoicing', 'invoicing')); |
|
1036 | 1036 | |
1037 | 1037 | $screen_ids = array( |
1038 | 1038 | 'toplevel_page_' . $screen_id, |
@@ -1050,7 +1050,7 @@ discard block |
||
1050 | 1050 | 'invoicing_page_wpi-addons', |
1051 | 1051 | ); |
1052 | 1052 | |
1053 | - return apply_filters( 'wpinv_screen_ids', $screen_ids ); |
|
1053 | + return apply_filters('wpinv_screen_ids', $screen_ids); |
|
1054 | 1054 | } |
1055 | 1055 | |
1056 | 1056 | /** |
@@ -1061,14 +1061,14 @@ discard block |
||
1061 | 1061 | * @param array|string $list List of values. |
1062 | 1062 | * @return array Sanitized array of values. |
1063 | 1063 | */ |
1064 | -function wpinv_parse_list( $list ) { |
|
1064 | +function wpinv_parse_list($list) { |
|
1065 | 1065 | |
1066 | - if ( empty( $list ) ) { |
|
1066 | + if (empty($list)) { |
|
1067 | 1067 | $list = array(); |
1068 | 1068 | } |
1069 | 1069 | |
1070 | - if ( ! is_array( $list ) ) { |
|
1071 | - return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
1070 | + if (!is_array($list)) { |
|
1071 | + return preg_split('/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY); |
|
1072 | 1072 | } |
1073 | 1073 | |
1074 | 1074 | return $list; |
@@ -1082,16 +1082,16 @@ discard block |
||
1082 | 1082 | * @param string $key Type of data to fetch. |
1083 | 1083 | * @return mixed Fetched data. |
1084 | 1084 | */ |
1085 | -function wpinv_get_data( $key ) { |
|
1085 | +function wpinv_get_data($key) { |
|
1086 | 1086 | |
1087 | 1087 | // Try fetching it from the cache. |
1088 | - $data = wp_cache_get( "wpinv-$key", 'wpinv' ); |
|
1089 | - if( $data ) { |
|
1088 | + $data = wp_cache_get("wpinv-$key", 'wpinv'); |
|
1089 | + if ($data) { |
|
1090 | 1090 | return $data; |
1091 | 1091 | } |
1092 | 1092 | |
1093 | - $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" ); |
|
1094 | - wp_cache_set( "wpinv-$key", $data, 'wpinv' ); |
|
1093 | + $data = apply_filters("wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php"); |
|
1094 | + wp_cache_set("wpinv-$key", $data, 'wpinv'); |
|
1095 | 1095 | |
1096 | 1096 | return $data; |
1097 | 1097 | } |
@@ -1105,10 +1105,10 @@ discard block |
||
1105 | 1105 | * @param bool $first_empty Whether or not the first item in the list should be empty |
1106 | 1106 | * @return mixed Fetched data. |
1107 | 1107 | */ |
1108 | -function wpinv_maybe_add_empty_option( $options, $first_empty ) { |
|
1108 | +function wpinv_maybe_add_empty_option($options, $first_empty) { |
|
1109 | 1109 | |
1110 | - if ( ! empty( $options ) && $first_empty ) { |
|
1111 | - return array_merge( array( '' => '' ), $options ); |
|
1110 | + if (!empty($options) && $first_empty) { |
|
1111 | + return array_merge(array('' => ''), $options); |
|
1112 | 1112 | } |
1113 | 1113 | return $options; |
1114 | 1114 | |
@@ -1120,21 +1120,21 @@ discard block |
||
1120 | 1120 | * @param mixed $var Data to sanitize. |
1121 | 1121 | * @return string|array |
1122 | 1122 | */ |
1123 | -function wpinv_clean( $var ) { |
|
1123 | +function wpinv_clean($var) { |
|
1124 | 1124 | |
1125 | - if ( is_array( $var ) ) { |
|
1126 | - return array_map( 'wpinv_clean', $var ); |
|
1125 | + if (is_array($var)) { |
|
1126 | + return array_map('wpinv_clean', $var); |
|
1127 | 1127 | } |
1128 | 1128 | |
1129 | - if ( is_object( $var ) ) { |
|
1130 | - $object_vars = get_object_vars( $var ); |
|
1131 | - foreach ( $object_vars as $property_name => $property_value ) { |
|
1132 | - $var->$property_name = wpinv_clean( $property_value ); |
|
1129 | + if (is_object($var)) { |
|
1130 | + $object_vars = get_object_vars($var); |
|
1131 | + foreach ($object_vars as $property_name => $property_value) { |
|
1132 | + $var->$property_name = wpinv_clean($property_value); |
|
1133 | 1133 | } |
1134 | 1134 | return $var; |
1135 | 1135 | } |
1136 | 1136 | |
1137 | - return is_string( $var ) ? sanitize_text_field( $var ) : $var; |
|
1137 | + return is_string($var) ? sanitize_text_field($var) : $var; |
|
1138 | 1138 | } |
1139 | 1139 | |
1140 | 1140 | /** |
@@ -1143,43 +1143,43 @@ discard block |
||
1143 | 1143 | * @param string $str Data to convert. |
1144 | 1144 | * @return string|array |
1145 | 1145 | */ |
1146 | -function getpaid_convert_price_string_to_options( $str ) { |
|
1146 | +function getpaid_convert_price_string_to_options($str) { |
|
1147 | 1147 | |
1148 | - $raw_options = array_map( 'trim', explode( ',', $str ) ); |
|
1149 | - $options = array(); |
|
1148 | + $raw_options = array_map('trim', explode(',', $str)); |
|
1149 | + $options = array(); |
|
1150 | 1150 | |
1151 | - foreach ( $raw_options as $option ) { |
|
1151 | + foreach ($raw_options as $option) { |
|
1152 | 1152 | |
1153 | - if ( '' == $option ) { |
|
1153 | + if ('' == $option) { |
|
1154 | 1154 | continue; |
1155 | 1155 | } |
1156 | 1156 | |
1157 | - $option = array_map( 'trim', explode( '|', $option ) ); |
|
1157 | + $option = array_map('trim', explode('|', $option)); |
|
1158 | 1158 | |
1159 | 1159 | $price = null; |
1160 | 1160 | $label = null; |
1161 | 1161 | |
1162 | - if ( isset( $option[0] ) && '' != $option[0] ) { |
|
1163 | - $label = $option[0]; |
|
1162 | + if (isset($option[0]) && '' != $option[0]) { |
|
1163 | + $label = $option[0]; |
|
1164 | 1164 | } |
1165 | 1165 | |
1166 | - if ( isset( $option[1] ) && '' != $option[1] ) { |
|
1166 | + if (isset($option[1]) && '' != $option[1]) { |
|
1167 | 1167 | $price = $option[1]; |
1168 | 1168 | } |
1169 | 1169 | |
1170 | - if ( ! isset( $price ) ) { |
|
1170 | + if (!isset($price)) { |
|
1171 | 1171 | $price = $label; |
1172 | 1172 | } |
1173 | 1173 | |
1174 | - if ( ! isset( $price ) || ! is_numeric( $price ) ) { |
|
1174 | + if (!isset($price) || !is_numeric($price)) { |
|
1175 | 1175 | continue; |
1176 | 1176 | } |
1177 | 1177 | |
1178 | - if ( ! isset( $label ) ) { |
|
1178 | + if (!isset($label)) { |
|
1179 | 1179 | $label = $price; |
1180 | 1180 | } |
1181 | 1181 | |
1182 | - $options[ $price ] = $label; |
|
1182 | + $options[$price] = $label; |
|
1183 | 1183 | } |
1184 | 1184 | |
1185 | 1185 | return $options; |
@@ -1188,8 +1188,8 @@ discard block |
||
1188 | 1188 | /** |
1189 | 1189 | * Returns the help tip. |
1190 | 1190 | */ |
1191 | -function getpaid_get_help_tip( $tip, $additional_classes = '' ) { |
|
1192 | - $additional_classes = sanitize_html_class( $additional_classes ); |
|
1193 | - $tip = esc_attr__( $tip ); |
|
1191 | +function getpaid_get_help_tip($tip, $additional_classes = '') { |
|
1192 | + $additional_classes = sanitize_html_class($additional_classes); |
|
1193 | + $tip = esc_attr__($tip); |
|
1194 | 1194 | return "<span class='wpi-help-tip dashicons dashicons-editor-help $additional_classes' title='$tip'></span>"; |
1195 | 1195 | } |
@@ -7,206 +7,206 @@ 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_get_payment_gateways() { |
15 | 15 | // Default, built-in gateways |
16 | 16 | $gateways = array( |
17 | 17 | 'paypal' => array( |
18 | - 'admin_label' => __( 'PayPal Standard', 'invoicing' ), |
|
19 | - 'checkout_label' => __( 'PayPal Standard', 'invoicing' ), |
|
18 | + 'admin_label' => __('PayPal Standard', 'invoicing'), |
|
19 | + 'checkout_label' => __('PayPal Standard', 'invoicing'), |
|
20 | 20 | 'ordering' => 1, |
21 | 21 | ), |
22 | 22 | 'authorizenet' => array( |
23 | - 'admin_label' => __( 'Authorize.Net (AIM)', 'invoicing' ), |
|
24 | - 'checkout_label' => __( 'Authorize.Net - Credit Card / Debit Card', 'invoicing' ), |
|
23 | + 'admin_label' => __('Authorize.Net (AIM)', 'invoicing'), |
|
24 | + 'checkout_label' => __('Authorize.Net - Credit Card / Debit Card', 'invoicing'), |
|
25 | 25 | 'ordering' => 4, |
26 | 26 | ), |
27 | 27 | 'worldpay' => array( |
28 | - 'admin_label' => __( 'Worldpay', 'invoicing' ), |
|
29 | - 'checkout_label' => __( 'Worldpay - Credit Card / Debit Card', 'invoicing' ), |
|
28 | + 'admin_label' => __('Worldpay', 'invoicing'), |
|
29 | + 'checkout_label' => __('Worldpay - Credit Card / Debit Card', 'invoicing'), |
|
30 | 30 | 'ordering' => 5, |
31 | 31 | ), |
32 | 32 | 'bank_transfer' => array( |
33 | - 'admin_label' => __( 'Pre Bank Transfer', 'invoicing' ), |
|
34 | - 'checkout_label' => __( 'Pre Bank Transfer', 'invoicing' ), |
|
33 | + 'admin_label' => __('Pre Bank Transfer', 'invoicing'), |
|
34 | + 'checkout_label' => __('Pre Bank Transfer', 'invoicing'), |
|
35 | 35 | 'ordering' => 11, |
36 | 36 | ), |
37 | 37 | 'manual' => array( |
38 | - 'admin_label' => __( 'Manual Payment', 'invoicing' ), |
|
39 | - 'checkout_label' => __( 'Manual Payment', 'invoicing' ), |
|
38 | + 'admin_label' => __('Manual Payment', 'invoicing'), |
|
39 | + 'checkout_label' => __('Manual Payment', 'invoicing'), |
|
40 | 40 | 'ordering' => 12, |
41 | 41 | ), |
42 | 42 | ); |
43 | 43 | |
44 | - return apply_filters( 'wpinv_payment_gateways', $gateways ); |
|
44 | + return apply_filters('wpinv_payment_gateways', $gateways); |
|
45 | 45 | } |
46 | 46 | |
47 | -function wpinv_payment_gateway_titles( $all_gateways ) { |
|
47 | +function wpinv_payment_gateway_titles($all_gateways) { |
|
48 | 48 | global $wpinv_options; |
49 | 49 | |
50 | 50 | $gateways = array(); |
51 | - foreach ( $all_gateways as $key => $gateway ) { |
|
52 | - if ( !empty( $wpinv_options[$key . '_title'] ) ) { |
|
53 | - $all_gateways[$key]['checkout_label'] = __( $wpinv_options[$key . '_title'], 'invoicing' ); |
|
51 | + foreach ($all_gateways as $key => $gateway) { |
|
52 | + if (!empty($wpinv_options[$key . '_title'])) { |
|
53 | + $all_gateways[$key]['checkout_label'] = __($wpinv_options[$key . '_title'], 'invoicing'); |
|
54 | 54 | } |
55 | 55 | |
56 | - $gateways[$key] = isset( $wpinv_options[$key . '_ordering'] ) ? $wpinv_options[$key . '_ordering'] : ( isset( $gateway['ordering'] ) ? $gateway['ordering'] : '' ); |
|
56 | + $gateways[$key] = isset($wpinv_options[$key . '_ordering']) ? $wpinv_options[$key . '_ordering'] : (isset($gateway['ordering']) ? $gateway['ordering'] : ''); |
|
57 | 57 | } |
58 | 58 | |
59 | - asort( $gateways ); |
|
59 | + asort($gateways); |
|
60 | 60 | |
61 | - foreach ( $gateways as $gateway => $key ) { |
|
61 | + foreach ($gateways as $gateway => $key) { |
|
62 | 62 | $gateways[$gateway] = $all_gateways[$gateway]; |
63 | 63 | } |
64 | 64 | |
65 | 65 | return $gateways; |
66 | 66 | } |
67 | -add_filter( 'wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1 ); |
|
67 | +add_filter('wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1); |
|
68 | 68 | |
69 | -function wpinv_get_enabled_payment_gateways( $sort = false ) { |
|
69 | +function wpinv_get_enabled_payment_gateways($sort = false) { |
|
70 | 70 | $gateways = wpinv_get_payment_gateways(); |
71 | - $enabled = wpinv_get_option( 'gateways', false ); |
|
71 | + $enabled = wpinv_get_option('gateways', false); |
|
72 | 72 | |
73 | 73 | $gateway_list = array(); |
74 | 74 | |
75 | - foreach ( $gateways as $key => $gateway ) { |
|
76 | - if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) { |
|
77 | - $gateway_list[ $key ] = $gateway; |
|
75 | + foreach ($gateways as $key => $gateway) { |
|
76 | + if (isset($enabled[$key]) && $enabled[$key] == 1) { |
|
77 | + $gateway_list[$key] = $gateway; |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
81 | - if ( true === $sort ) { |
|
82 | - uasort( $gateway_list, 'wpinv_sort_gateway_order' ); |
|
81 | + if (true === $sort) { |
|
82 | + uasort($gateway_list, 'wpinv_sort_gateway_order'); |
|
83 | 83 | |
84 | 84 | // Reorder our gateways so the default is first |
85 | 85 | $default_gateway_id = wpinv_get_default_gateway(); |
86 | 86 | |
87 | - if ( wpinv_is_gateway_active( $default_gateway_id ) ) { |
|
88 | - $default_gateway = array( $default_gateway_id => $gateway_list[ $default_gateway_id ] ); |
|
89 | - unset( $gateway_list[ $default_gateway_id ] ); |
|
87 | + if (wpinv_is_gateway_active($default_gateway_id)) { |
|
88 | + $default_gateway = array($default_gateway_id => $gateway_list[$default_gateway_id]); |
|
89 | + unset($gateway_list[$default_gateway_id]); |
|
90 | 90 | |
91 | - $gateway_list = array_merge( $default_gateway, $gateway_list ); |
|
91 | + $gateway_list = array_merge($default_gateway, $gateway_list); |
|
92 | 92 | } |
93 | 93 | } |
94 | 94 | |
95 | - return apply_filters( 'wpinv_enabled_payment_gateways', $gateway_list ); |
|
95 | + return apply_filters('wpinv_enabled_payment_gateways', $gateway_list); |
|
96 | 96 | } |
97 | 97 | |
98 | -function wpinv_sort_gateway_order( $a, $b ) { |
|
98 | +function wpinv_sort_gateway_order($a, $b) { |
|
99 | 99 | return $a['ordering'] - $b['ordering']; |
100 | 100 | } |
101 | 101 | |
102 | -function wpinv_is_gateway_active( $gateway ) { |
|
102 | +function wpinv_is_gateway_active($gateway) { |
|
103 | 103 | $gateways = wpinv_get_enabled_payment_gateways(); |
104 | 104 | |
105 | - $ret = is_array($gateways) && $gateway ? array_key_exists( $gateway, $gateways ) : false; |
|
105 | + $ret = is_array($gateways) && $gateway ? array_key_exists($gateway, $gateways) : false; |
|
106 | 106 | |
107 | - return apply_filters( 'wpinv_is_gateway_active', $ret, $gateway, $gateways ); |
|
107 | + return apply_filters('wpinv_is_gateway_active', $ret, $gateway, $gateways); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | function wpinv_get_default_gateway() { |
111 | - $default = wpinv_get_option( 'default_gateway', 'paypal' ); |
|
111 | + $default = wpinv_get_option('default_gateway', 'paypal'); |
|
112 | 112 | |
113 | - if ( !wpinv_is_gateway_active( $default ) ) { |
|
113 | + if (!wpinv_is_gateway_active($default)) { |
|
114 | 114 | $gateways = wpinv_get_enabled_payment_gateways(); |
115 | - $gateways = array_keys( $gateways ); |
|
116 | - $default = reset( $gateways ); |
|
115 | + $gateways = array_keys($gateways); |
|
116 | + $default = reset($gateways); |
|
117 | 117 | } |
118 | 118 | |
119 | - return apply_filters( 'wpinv_default_gateway', $default ); |
|
119 | + return apply_filters('wpinv_default_gateway', $default); |
|
120 | 120 | } |
121 | 121 | |
122 | -function wpinv_get_gateway_admin_label( $gateway ) { |
|
122 | +function wpinv_get_gateway_admin_label($gateway) { |
|
123 | 123 | $gateways = wpinv_get_payment_gateways(); |
124 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway; |
|
125 | - $payment = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : false; |
|
124 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway; |
|
125 | + $payment = isset($_GET['id']) ? absint($_GET['id']) : false; |
|
126 | 126 | |
127 | - if( $gateway == 'manual' && $payment ) { |
|
128 | - if( !( (float)wpinv_payment_total( $payment ) > 0 ) ) { |
|
129 | - $label = __( 'Free Purchase', 'invoicing' ); |
|
127 | + if ($gateway == 'manual' && $payment) { |
|
128 | + if (!((float) wpinv_payment_total($payment) > 0)) { |
|
129 | + $label = __('Free Purchase', 'invoicing'); |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 | |
133 | - return apply_filters( 'wpinv_gateway_admin_label', $label, $gateway ); |
|
133 | + return apply_filters('wpinv_gateway_admin_label', $label, $gateway); |
|
134 | 134 | } |
135 | 135 | |
136 | -function wpinv_get_gateway_description( $gateway ) { |
|
136 | +function wpinv_get_gateway_description($gateway) { |
|
137 | 137 | global $wpinv_options; |
138 | 138 | |
139 | - $description = isset( $wpinv_options[$gateway . '_desc'] ) ? $wpinv_options[$gateway . '_desc'] : ''; |
|
139 | + $description = isset($wpinv_options[$gateway . '_desc']) ? $wpinv_options[$gateway . '_desc'] : ''; |
|
140 | 140 | |
141 | - return apply_filters( 'wpinv_gateway_description', $description, $gateway ); |
|
141 | + return apply_filters('wpinv_gateway_description', $description, $gateway); |
|
142 | 142 | } |
143 | 143 | |
144 | -function wpinv_get_gateway_button_label( $gateway ) { |
|
145 | - return apply_filters( 'wpinv_gateway_' . $gateway . '_button_label', '' ); |
|
144 | +function wpinv_get_gateway_button_label($gateway) { |
|
145 | + return apply_filters('wpinv_gateway_' . $gateway . '_button_label', ''); |
|
146 | 146 | } |
147 | 147 | |
148 | -function wpinv_get_gateway_checkout_label( $gateway ) { |
|
148 | +function wpinv_get_gateway_checkout_label($gateway) { |
|
149 | 149 | $gateways = wpinv_get_payment_gateways(); |
150 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway; |
|
150 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway; |
|
151 | 151 | |
152 | - if( $gateway == 'manual' ) { |
|
153 | - $label = __( 'Manual Payment', 'invoicing' ); |
|
152 | + if ($gateway == 'manual') { |
|
153 | + $label = __('Manual Payment', 'invoicing'); |
|
154 | 154 | } |
155 | 155 | |
156 | - return apply_filters( 'wpinv_gateway_checkout_label', $label, $gateway ); |
|
156 | + return apply_filters('wpinv_gateway_checkout_label', $label, $gateway); |
|
157 | 157 | } |
158 | 158 | |
159 | -function wpinv_settings_sections_gateways( $settings ) { |
|
159 | +function wpinv_settings_sections_gateways($settings) { |
|
160 | 160 | $gateways = wpinv_get_payment_gateways(); |
161 | 161 | |
162 | 162 | if (!empty($gateways)) { |
163 | - foreach ($gateways as $key => $gateway) { |
|
163 | + foreach ($gateways as $key => $gateway) { |
|
164 | 164 | $settings[$key] = $gateway['admin_label']; |
165 | 165 | } |
166 | 166 | } |
167 | 167 | |
168 | 168 | return $settings; |
169 | 169 | } |
170 | -add_filter( 'wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1 ); |
|
170 | +add_filter('wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1); |
|
171 | 171 | |
172 | -function wpinv_settings_gateways( $settings ) { |
|
172 | +function wpinv_settings_gateways($settings) { |
|
173 | 173 | $gateways = wpinv_get_payment_gateways(); |
174 | 174 | |
175 | 175 | if (!empty($gateways)) { |
176 | - foreach ($gateways as $key => $gateway) { |
|
176 | + foreach ($gateways as $key => $gateway) { |
|
177 | 177 | $setting = array(); |
178 | 178 | $setting[$key . '_header'] = array( |
179 | 179 | 'id' => 'gateway_header', |
180 | - 'name' => '<h3>' . wp_sprintf( __( '%s Settings', 'invoicing' ), $gateway['admin_label'] ) . '</h3>', |
|
180 | + 'name' => '<h3>' . wp_sprintf(__('%s Settings', 'invoicing'), $gateway['admin_label']) . '</h3>', |
|
181 | 181 | 'custom' => $key, |
182 | 182 | 'type' => 'gateway_header', |
183 | 183 | ); |
184 | 184 | $setting[$key . '_active'] = array( |
185 | 185 | 'id' => $key . '_active', |
186 | - 'name' => __( 'Active', 'invoicing' ), |
|
187 | - 'desc' => wp_sprintf( __( 'Enable %s', 'invoicing' ), $gateway['admin_label'] ), |
|
186 | + 'name' => __('Active', 'invoicing'), |
|
187 | + 'desc' => wp_sprintf(__('Enable %s', 'invoicing'), $gateway['admin_label']), |
|
188 | 188 | 'type' => 'checkbox', |
189 | 189 | ); |
190 | 190 | |
191 | 191 | $setting[$key . '_title'] = array( |
192 | 192 | 'id' => $key . '_title', |
193 | - 'name' => __( 'Title', 'invoicing' ), |
|
194 | - 'desc' => __( 'This controls the title which the user sees during checkout.', 'invoicing' ), |
|
193 | + 'name' => __('Title', 'invoicing'), |
|
194 | + 'desc' => __('This controls the title which the user sees during checkout.', 'invoicing'), |
|
195 | 195 | 'type' => 'text', |
196 | 196 | 'std' => isset($gateway['checkout_label']) ? $gateway['checkout_label'] : '' |
197 | 197 | ); |
198 | 198 | |
199 | 199 | $setting[$key . '_desc'] = array( |
200 | 200 | 'id' => $key . '_desc', |
201 | - 'name' => __( 'Description', 'invoicing' ), |
|
202 | - 'desc' => __( 'This controls the description which the user sees during checkout.', 'invoicing' ), |
|
201 | + 'name' => __('Description', 'invoicing'), |
|
202 | + 'desc' => __('This controls the description which the user sees during checkout.', 'invoicing'), |
|
203 | 203 | 'type' => 'text', |
204 | 204 | 'size' => 'large' |
205 | 205 | ); |
206 | 206 | |
207 | 207 | $setting[$key . '_ordering'] = array( |
208 | 208 | 'id' => $key . '_ordering', |
209 | - 'name' => __( 'Display Order', 'invoicing' ), |
|
209 | + 'name' => __('Display Order', 'invoicing'), |
|
210 | 210 | 'type' => 'number', |
211 | 211 | 'size' => 'small', |
212 | 212 | 'std' => isset($gateway['ordering']) ? $gateway['ordering'] : '10', |
@@ -215,8 +215,8 @@ discard block |
||
215 | 215 | 'step' => '1' |
216 | 216 | ); |
217 | 217 | |
218 | - $setting = apply_filters( 'wpinv_gateway_settings', $setting, $key ); |
|
219 | - $setting = apply_filters( 'wpinv_gateway_settings_' . $key, $setting ); |
|
218 | + $setting = apply_filters('wpinv_gateway_settings', $setting, $key); |
|
219 | + $setting = apply_filters('wpinv_gateway_settings_' . $key, $setting); |
|
220 | 220 | |
221 | 221 | $settings[$key] = $setting; |
222 | 222 | } |
@@ -224,106 +224,106 @@ discard block |
||
224 | 224 | |
225 | 225 | return $settings; |
226 | 226 | } |
227 | -add_filter( 'wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1 ); |
|
227 | +add_filter('wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1); |
|
228 | 228 | |
229 | -function wpinv_gateway_header_callback( $args ) { |
|
230 | - echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr( $args['custom'] ) . '" />'; |
|
229 | +function wpinv_gateway_header_callback($args) { |
|
230 | + echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr($args['custom']) . '" />'; |
|
231 | 231 | } |
232 | 232 | |
233 | -function wpinv_get_gateway_supports( $gateway ) { |
|
233 | +function wpinv_get_gateway_supports($gateway) { |
|
234 | 234 | $gateways = wpinv_get_enabled_payment_gateways(); |
235 | - $supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array(); |
|
236 | - return apply_filters( 'wpinv_gateway_supports', $supports, $gateway ); |
|
235 | + $supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array(); |
|
236 | + return apply_filters('wpinv_gateway_supports', $supports, $gateway); |
|
237 | 237 | } |
238 | 238 | |
239 | -function wpinv_gateway_supports_buy_now( $gateway ) { |
|
240 | - $supports = wpinv_get_gateway_supports( $gateway ); |
|
241 | - $ret = in_array( 'buy_now', $supports ); |
|
242 | - return apply_filters( 'wpinv_gateway_supports_buy_now', $ret, $gateway ); |
|
239 | +function wpinv_gateway_supports_buy_now($gateway) { |
|
240 | + $supports = wpinv_get_gateway_supports($gateway); |
|
241 | + $ret = in_array('buy_now', $supports); |
|
242 | + return apply_filters('wpinv_gateway_supports_buy_now', $ret, $gateway); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | function wpinv_shop_supports_buy_now() { |
246 | 246 | $gateways = wpinv_get_enabled_payment_gateways(); |
247 | 247 | $ret = false; |
248 | 248 | |
249 | - if ( !wpinv_use_taxes() && $gateways ) { |
|
250 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
251 | - if ( wpinv_gateway_supports_buy_now( $gateway_id ) ) { |
|
249 | + if (!wpinv_use_taxes() && $gateways) { |
|
250 | + foreach ($gateways as $gateway_id => $gateway) { |
|
251 | + if (wpinv_gateway_supports_buy_now($gateway_id)) { |
|
252 | 252 | $ret = true; |
253 | 253 | break; |
254 | 254 | } |
255 | 255 | } |
256 | 256 | } |
257 | 257 | |
258 | - return apply_filters( 'wpinv_shop_supports_buy_now', $ret ); |
|
258 | + return apply_filters('wpinv_shop_supports_buy_now', $ret); |
|
259 | 259 | } |
260 | 260 | |
261 | -function wpinv_send_to_gateway( $gateway, $payment_data ) { |
|
262 | - $payment_data['gateway_nonce'] = wp_create_nonce( 'wpi-gateway' ); |
|
261 | +function wpinv_send_to_gateway($gateway, $payment_data) { |
|
262 | + $payment_data['gateway_nonce'] = wp_create_nonce('wpi-gateway'); |
|
263 | 263 | |
264 | 264 | // $gateway must match the ID used when registering the gateway |
265 | - do_action( 'wpinv_gateway_' . $gateway, $payment_data ); |
|
265 | + do_action('wpinv_gateway_' . $gateway, $payment_data); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | function wpinv_show_gateways() { |
269 | 269 | $gateways = wpinv_get_enabled_payment_gateways(); |
270 | 270 | $show_gateways = false; |
271 | 271 | |
272 | - $chosen_gateway = isset( $_GET['payment-mode'] ) ? preg_replace('/[^a-zA-Z0-9-_]+/', '', $_GET['payment-mode'] ) : false; |
|
272 | + $chosen_gateway = isset($_GET['payment-mode']) ? preg_replace('/[^a-zA-Z0-9-_]+/', '', $_GET['payment-mode']) : false; |
|
273 | 273 | |
274 | - if ( count( $gateways ) > 1 && empty( $chosen_gateway ) ) { |
|
274 | + if (count($gateways) > 1 && empty($chosen_gateway)) { |
|
275 | 275 | $show_gateways = true; |
276 | - if ( wpinv_get_cart_total() <= 0 ) { |
|
276 | + if (wpinv_get_cart_total() <= 0) { |
|
277 | 277 | $show_gateways = false; |
278 | 278 | } |
279 | 279 | } |
280 | 280 | |
281 | - if ( !$show_gateways && wpinv_cart_has_recurring_item() ) { |
|
281 | + if (!$show_gateways && wpinv_cart_has_recurring_item()) { |
|
282 | 282 | $show_gateways = true; |
283 | 283 | } |
284 | 284 | |
285 | - return apply_filters( 'wpinv_show_gateways', $show_gateways ); |
|
285 | + return apply_filters('wpinv_show_gateways', $show_gateways); |
|
286 | 286 | } |
287 | 287 | |
288 | -function wpinv_get_chosen_gateway( $invoice_id = 0 ) { |
|
289 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
288 | +function wpinv_get_chosen_gateway($invoice_id = 0) { |
|
289 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
290 | 290 | |
291 | 291 | $chosen = false; |
292 | - if ( $invoice_id > 0 && $invoice = wpinv_get_invoice( $invoice_id ) ) { |
|
292 | + if ($invoice_id > 0 && $invoice = wpinv_get_invoice($invoice_id)) { |
|
293 | 293 | $chosen = $invoice->get_gateway(); |
294 | 294 | } |
295 | 295 | |
296 | - $chosen = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen; |
|
296 | + $chosen = isset($_REQUEST['payment-mode']) ? sanitize_text_field($_REQUEST['payment-mode']) : $chosen; |
|
297 | 297 | |
298 | - if ( false !== $chosen ) { |
|
299 | - $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen ); |
|
298 | + if (false !== $chosen) { |
|
299 | + $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen); |
|
300 | 300 | } |
301 | 301 | |
302 | - if ( ! empty ( $chosen ) ) { |
|
303 | - $enabled_gateway = urldecode( $chosen ); |
|
304 | - } else if ( !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) { |
|
302 | + if (!empty ($chosen)) { |
|
303 | + $enabled_gateway = urldecode($chosen); |
|
304 | + } else if (!empty($invoice) && (float) $invoice->get_subtotal() <= 0) { |
|
305 | 305 | $enabled_gateway = 'manual'; |
306 | 306 | } else { |
307 | 307 | $enabled_gateway = wpinv_get_default_gateway(); |
308 | 308 | } |
309 | 309 | |
310 | - if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) { |
|
311 | - if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){ |
|
310 | + if (!wpinv_is_gateway_active($enabled_gateway) && !empty($gateways)) { |
|
311 | + if (wpinv_is_gateway_active(wpinv_get_default_gateway())) { |
|
312 | 312 | $enabled_gateway = wpinv_get_default_gateway(); |
313 | - }else{ |
|
313 | + } else { |
|
314 | 314 | $enabled_gateway = $gateways[0]; |
315 | 315 | } |
316 | 316 | |
317 | 317 | } |
318 | 318 | |
319 | - return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway ); |
|
319 | + return apply_filters('wpinv_chosen_gateway', $enabled_gateway); |
|
320 | 320 | } |
321 | 321 | |
322 | -function wpinv_record_gateway_error( $title = '', $message = '', $parent = 0 ) { |
|
323 | - return wpinv_error_log( $message, $title ); |
|
322 | +function wpinv_record_gateway_error($title = '', $message = '', $parent = 0) { |
|
323 | + return wpinv_error_log($message, $title); |
|
324 | 324 | } |
325 | 325 | |
326 | -function wpinv_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) { |
|
326 | +function wpinv_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') { |
|
327 | 327 | $ret = 0; |
328 | 328 | $args = array( |
329 | 329 | 'meta_key' => '_wpinv_gateway', |
@@ -334,48 +334,48 @@ discard block |
||
334 | 334 | 'fields' => 'ids' |
335 | 335 | ); |
336 | 336 | |
337 | - $payments = new WP_Query( $args ); |
|
337 | + $payments = new WP_Query($args); |
|
338 | 338 | |
339 | - if( $payments ) |
|
339 | + if ($payments) |
|
340 | 340 | $ret = $payments->post_count; |
341 | 341 | return $ret; |
342 | 342 | } |
343 | 343 | |
344 | -function wpinv_settings_update_gateways( $input ) { |
|
344 | +function wpinv_settings_update_gateways($input) { |
|
345 | 345 | global $wpinv_options; |
346 | 346 | |
347 | - if ( !empty( $input['save_gateway'] ) ) { |
|
348 | - $gateways = wpinv_get_option( 'gateways', false ); |
|
347 | + if (!empty($input['save_gateway'])) { |
|
348 | + $gateways = wpinv_get_option('gateways', false); |
|
349 | 349 | $gateways = !empty($gateways) ? $gateways : array(); |
350 | 350 | $gateway = $input['save_gateway']; |
351 | 351 | |
352 | - if ( !empty( $input[$gateway . '_active'] ) ) { |
|
352 | + if (!empty($input[$gateway . '_active'])) { |
|
353 | 353 | $gateways[$gateway] = 1; |
354 | 354 | } else { |
355 | - if ( isset( $gateways[$gateway] ) ) { |
|
356 | - unset( $gateways[$gateway] ); |
|
355 | + if (isset($gateways[$gateway])) { |
|
356 | + unset($gateways[$gateway]); |
|
357 | 357 | } |
358 | 358 | } |
359 | 359 | |
360 | 360 | $input['gateways'] = $gateways; |
361 | 361 | } |
362 | 362 | |
363 | - if ( !empty( $input['default_gateway'] ) ) { |
|
363 | + if (!empty($input['default_gateway'])) { |
|
364 | 364 | $gateways = wpinv_get_payment_gateways(); |
365 | 365 | |
366 | - foreach ( $gateways as $key => $gateway ) { |
|
367 | - $active = 0; |
|
368 | - if ( !empty( $input['gateways'] ) && !empty( $input['gateways'][$key] ) ) { |
|
366 | + foreach ($gateways as $key => $gateway) { |
|
367 | + $active = 0; |
|
368 | + if (!empty($input['gateways']) && !empty($input['gateways'][$key])) { |
|
369 | 369 | $active = 1; |
370 | 370 | } |
371 | 371 | |
372 | 372 | $input[$key . '_active'] = $active; |
373 | 373 | |
374 | - if ( empty( $wpinv_options[$key . '_title'] ) ) { |
|
374 | + if (empty($wpinv_options[$key . '_title'])) { |
|
375 | 375 | $input[$key . '_title'] = $gateway['checkout_label']; |
376 | 376 | } |
377 | 377 | |
378 | - if ( !isset( $wpinv_options[$key . '_ordering'] ) && isset( $gateway['ordering'] ) ) { |
|
378 | + if (!isset($wpinv_options[$key . '_ordering']) && isset($gateway['ordering'])) { |
|
379 | 379 | $input[$key . '_ordering'] = $gateway['ordering']; |
380 | 380 | } |
381 | 381 | } |
@@ -383,27 +383,27 @@ discard block |
||
383 | 383 | |
384 | 384 | return $input; |
385 | 385 | } |
386 | -add_filter( 'wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1 ); |
|
386 | +add_filter('wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1); |
|
387 | 387 | |
388 | 388 | // PayPal Standard settings |
389 | -function wpinv_gateway_settings_paypal( $setting ) { |
|
390 | - $setting['paypal_active']['desc'] = $setting['paypal_active']['desc'] . ' ' . __( '( Supported Currencies: AUD, BRL, CAD, CZK, DKK, EUR, HKD, HUF, ILS, JPY, MYR, MXN, NOK, NZD, PHP, PLN, GBP, SGD, SEK, CHF, TWD, THB, USD )', 'invoicing' ); |
|
391 | - $setting['paypal_desc']['std'] = __( 'Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing' ); |
|
389 | +function wpinv_gateway_settings_paypal($setting) { |
|
390 | + $setting['paypal_active']['desc'] = $setting['paypal_active']['desc'] . ' ' . __('( Supported Currencies: AUD, BRL, CAD, CZK, DKK, EUR, HKD, HUF, ILS, JPY, MYR, MXN, NOK, NZD, PHP, PLN, GBP, SGD, SEK, CHF, TWD, THB, USD )', 'invoicing'); |
|
391 | + $setting['paypal_desc']['std'] = __('Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing'); |
|
392 | 392 | |
393 | 393 | $setting['paypal_sandbox'] = array( |
394 | 394 | 'type' => 'checkbox', |
395 | 395 | 'id' => 'paypal_sandbox', |
396 | - 'name' => __( 'PayPal Sandbox', 'invoicing' ), |
|
397 | - 'desc' => __( 'PayPal sandbox can be used to test payments.', 'invoicing' ), |
|
396 | + 'name' => __('PayPal Sandbox', 'invoicing'), |
|
397 | + 'desc' => __('PayPal sandbox can be used to test payments.', 'invoicing'), |
|
398 | 398 | 'std' => 1 |
399 | 399 | ); |
400 | 400 | |
401 | 401 | $setting['paypal_email'] = array( |
402 | 402 | 'type' => 'text', |
403 | 403 | 'id' => 'paypal_email', |
404 | - 'name' => __( 'PayPal Email', 'invoicing' ), |
|
405 | - 'desc' => __( 'Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing' ), |
|
406 | - 'std' => __( '[email protected]', 'invoicing' ), |
|
404 | + 'name' => __('PayPal Email', 'invoicing'), |
|
405 | + 'desc' => __('Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing'), |
|
406 | + 'std' => __('[email protected]', 'invoicing'), |
|
407 | 407 | ); |
408 | 408 | /* |
409 | 409 | $setting['paypal_ipn_url'] = array( |
@@ -417,139 +417,139 @@ discard block |
||
417 | 417 | |
418 | 418 | return $setting; |
419 | 419 | } |
420 | -add_filter( 'wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1 ); |
|
420 | +add_filter('wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1); |
|
421 | 421 | |
422 | 422 | // Pre Bank Transfer settings |
423 | -function wpinv_gateway_settings_bank_transfer( $setting ) { |
|
424 | - $setting['bank_transfer_desc']['std'] = __( 'Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing' ); |
|
423 | +function wpinv_gateway_settings_bank_transfer($setting) { |
|
424 | + $setting['bank_transfer_desc']['std'] = __('Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing'); |
|
425 | 425 | |
426 | 426 | $setting['bank_transfer_ac_name'] = array( |
427 | 427 | 'type' => 'text', |
428 | 428 | 'id' => 'bank_transfer_ac_name', |
429 | - 'name' => __( 'Account Name', 'invoicing' ), |
|
430 | - 'desc' => __( 'Enter the bank account name to which you want to transfer payment.', 'invoicing' ), |
|
431 | - 'std' => __( 'Mr. John Martin', 'invoicing' ), |
|
429 | + 'name' => __('Account Name', 'invoicing'), |
|
430 | + 'desc' => __('Enter the bank account name to which you want to transfer payment.', 'invoicing'), |
|
431 | + 'std' => __('Mr. John Martin', 'invoicing'), |
|
432 | 432 | ); |
433 | 433 | |
434 | 434 | $setting['bank_transfer_ac_no'] = array( |
435 | 435 | 'type' => 'text', |
436 | 436 | 'id' => 'bank_transfer_ac_no', |
437 | - 'name' => __( 'Account Number', 'invoicing' ), |
|
438 | - 'desc' => __( 'Enter your bank account number.', 'invoicing' ), |
|
439 | - 'std' => __( 'TEST1234567890', 'invoicing' ), |
|
437 | + 'name' => __('Account Number', 'invoicing'), |
|
438 | + 'desc' => __('Enter your bank account number.', 'invoicing'), |
|
439 | + 'std' => __('TEST1234567890', 'invoicing'), |
|
440 | 440 | ); |
441 | 441 | |
442 | 442 | $setting['bank_transfer_bank_name'] = array( |
443 | 443 | 'type' => 'text', |
444 | 444 | 'id' => 'bank_transfer_bank_name', |
445 | - 'name' => __( 'Bank Name', 'invoicing' ), |
|
446 | - 'desc' => __( 'Enter the bank name to which you want to transfer payment.', 'invoicing' ), |
|
447 | - 'std' => __( 'ICICI Bank', 'invoicing' ), |
|
445 | + 'name' => __('Bank Name', 'invoicing'), |
|
446 | + 'desc' => __('Enter the bank name to which you want to transfer payment.', 'invoicing'), |
|
447 | + 'std' => __('ICICI Bank', 'invoicing'), |
|
448 | 448 | ); |
449 | 449 | |
450 | 450 | $setting['bank_transfer_ifsc'] = array( |
451 | 451 | 'type' => 'text', |
452 | 452 | 'id' => 'bank_transfer_ifsc', |
453 | - 'name' => __( 'IFSC Code', 'invoicing' ), |
|
454 | - 'desc' => __( 'Enter your bank IFSC code.', 'invoicing' ), |
|
455 | - 'std' => __( 'ICIC0001234', 'invoicing' ), |
|
453 | + 'name' => __('IFSC Code', 'invoicing'), |
|
454 | + 'desc' => __('Enter your bank IFSC code.', 'invoicing'), |
|
455 | + 'std' => __('ICIC0001234', 'invoicing'), |
|
456 | 456 | ); |
457 | 457 | |
458 | 458 | $setting['bank_transfer_iban'] = array( |
459 | 459 | 'type' => 'text', |
460 | 460 | 'id' => 'bank_transfer_iban', |
461 | - 'name' => __( 'IBAN', 'invoicing' ), |
|
462 | - 'desc' => __( 'Enter your International Bank Account Number(IBAN).', 'invoicing' ), |
|
463 | - 'std' => __( 'GB29NWBK60161331926819', 'invoicing' ), |
|
461 | + 'name' => __('IBAN', 'invoicing'), |
|
462 | + 'desc' => __('Enter your International Bank Account Number(IBAN).', 'invoicing'), |
|
463 | + 'std' => __('GB29NWBK60161331926819', 'invoicing'), |
|
464 | 464 | ); |
465 | 465 | |
466 | 466 | $setting['bank_transfer_bic'] = array( |
467 | 467 | 'type' => 'text', |
468 | 468 | 'id' => 'bank_transfer_bic', |
469 | - 'name' => __( 'BIC/Swift Code', 'invoicing' ), |
|
470 | - 'std' => __( 'ICICGB2L129', 'invoicing' ), |
|
469 | + 'name' => __('BIC/Swift Code', 'invoicing'), |
|
470 | + 'std' => __('ICICGB2L129', 'invoicing'), |
|
471 | 471 | ); |
472 | 472 | |
473 | 473 | $setting['bank_transfer_sort_code'] = array( |
474 | 474 | 'type' => 'text', |
475 | 475 | 'id' => 'bank_transfer_sort_code', |
476 | - 'name' => __( 'Sort Code', 'invoicing' ), |
|
477 | - 'std' => __( '12-34-56', 'invoicing' ), |
|
476 | + 'name' => __('Sort Code', 'invoicing'), |
|
477 | + 'std' => __('12-34-56', 'invoicing'), |
|
478 | 478 | ); |
479 | 479 | |
480 | 480 | $setting['bank_transfer_info'] = array( |
481 | 481 | 'id' => 'bank_transfer_info', |
482 | - 'name' => __( 'Instructions', 'invoicing' ), |
|
483 | - 'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ), |
|
482 | + 'name' => __('Instructions', 'invoicing'), |
|
483 | + 'desc' => __('Instructions that will be added to the thank you page and emails.', 'invoicing'), |
|
484 | 484 | 'type' => 'textarea', |
485 | - 'std' => __( 'Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing' ), |
|
485 | + 'std' => __('Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing'), |
|
486 | 486 | 'cols' => 37, |
487 | 487 | 'rows' => 5 |
488 | 488 | ); |
489 | 489 | |
490 | 490 | return $setting; |
491 | 491 | } |
492 | -add_filter( 'wpinv_gateway_settings_bank_transfer', 'wpinv_gateway_settings_bank_transfer', 10, 1 ); |
|
492 | +add_filter('wpinv_gateway_settings_bank_transfer', 'wpinv_gateway_settings_bank_transfer', 10, 1); |
|
493 | 493 | |
494 | 494 | // Authorize.Net settings |
495 | -function wpinv_gateway_settings_authorizenet( $setting ) { |
|
496 | - $setting['authorizenet_active']['desc'] = $setting['authorizenet_active']['desc'] . ' ' . __( '( Supported Currencies: AUD, CAD, CHF, DKK, EUR, GBP, JPY, NOK, NZD, PLN, SEK, USD, ZAR )', 'invoicing' ); |
|
497 | - $setting['authorizenet_desc']['std'] = __( 'Pay using a Authorize.Net to process Credit card / Debit card transactions.', 'invoicing' ); |
|
495 | +function wpinv_gateway_settings_authorizenet($setting) { |
|
496 | + $setting['authorizenet_active']['desc'] = $setting['authorizenet_active']['desc'] . ' ' . __('( Supported Currencies: AUD, CAD, CHF, DKK, EUR, GBP, JPY, NOK, NZD, PLN, SEK, USD, ZAR )', 'invoicing'); |
|
497 | + $setting['authorizenet_desc']['std'] = __('Pay using a Authorize.Net to process Credit card / Debit card transactions.', 'invoicing'); |
|
498 | 498 | |
499 | 499 | $setting['authorizenet_sandbox'] = array( |
500 | 500 | 'type' => 'checkbox', |
501 | 501 | 'id' => 'authorizenet_sandbox', |
502 | - 'name' => __( 'Authorize.Net Test Mode', 'invoicing' ), |
|
503 | - 'desc' => __( 'Enable Authorize.Net test mode to test payments.', 'invoicing' ), |
|
502 | + 'name' => __('Authorize.Net Test Mode', 'invoicing'), |
|
503 | + 'desc' => __('Enable Authorize.Net test mode to test payments.', 'invoicing'), |
|
504 | 504 | 'std' => 1 |
505 | 505 | ); |
506 | 506 | |
507 | 507 | $setting['authorizenet_login_id'] = array( |
508 | 508 | 'type' => 'text', |
509 | 509 | 'id' => 'authorizenet_login_id', |
510 | - 'name' => __( 'API Login ID', 'invoicing' ), |
|
511 | - 'desc' => __( 'API Login ID can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 2j4rBekUnD', 'invoicing' ), |
|
510 | + 'name' => __('API Login ID', 'invoicing'), |
|
511 | + 'desc' => __('API Login ID can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 2j4rBekUnD', 'invoicing'), |
|
512 | 512 | 'std' => '2j4rBekUnD', |
513 | 513 | ); |
514 | 514 | |
515 | 515 | $setting['authorizenet_transaction_key'] = array( |
516 | 516 | 'type' => 'text', |
517 | 517 | 'id' => 'authorizenet_transaction_key', |
518 | - 'name' => __( 'Transaction Key', 'invoicing' ), |
|
519 | - 'desc' => __( 'Transaction Key can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 4vyBUOJgR74679xa', 'invoicing' ), |
|
518 | + 'name' => __('Transaction Key', 'invoicing'), |
|
519 | + 'desc' => __('Transaction Key can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 4vyBUOJgR74679xa', 'invoicing'), |
|
520 | 520 | 'std' => '4vyBUOJgR74679xa', |
521 | 521 | ); |
522 | 522 | |
523 | 523 | $setting['authorizenet_md5_hash'] = array( |
524 | 524 | 'type' => 'text', |
525 | 525 | 'id' => 'authorizenet_md5_hash', |
526 | - 'name' => __( 'MD5-Hash', 'invoicing' ), |
|
527 | - 'desc' => __( 'The MD5 Hash security feature allows to authenticate transaction responses from the Authorize.Net for recurring payments. It can be obtained from Authorize.Net Account > Settings > Security Settings > General Settings > MD5 Hash.', 'invoicing' ), |
|
526 | + 'name' => __('MD5-Hash', 'invoicing'), |
|
527 | + 'desc' => __('The MD5 Hash security feature allows to authenticate transaction responses from the Authorize.Net for recurring payments. It can be obtained from Authorize.Net Account > Settings > Security Settings > General Settings > MD5 Hash.', 'invoicing'), |
|
528 | 528 | 'std' => '', |
529 | 529 | ); |
530 | 530 | |
531 | 531 | $setting['authorizenet_transaction_type'] = array( |
532 | 532 | 'id' => 'authorizenet_transaction_type', |
533 | - 'name' => __( 'Transaction Type', 'invoicing' ), |
|
534 | - 'desc' => __( 'Choose transaction type.', 'invoicing' ), |
|
533 | + 'name' => __('Transaction Type', 'invoicing'), |
|
534 | + 'desc' => __('Choose transaction type.', 'invoicing'), |
|
535 | 535 | 'type' => 'select', |
536 | 536 | 'class' => 'wpi_select2', |
537 | 537 | 'options' => array( |
538 | - 'authorize_capture' => __( 'Authorize And Capture', 'invoicing' ), |
|
539 | - 'authorize_only' => __( 'Authorize Only', 'invoicing' ), |
|
538 | + 'authorize_capture' => __('Authorize And Capture', 'invoicing'), |
|
539 | + 'authorize_only' => __('Authorize Only', 'invoicing'), |
|
540 | 540 | ), |
541 | 541 | 'std' => 'authorize_capture' |
542 | 542 | ); |
543 | 543 | |
544 | 544 | $setting['authorizenet_transaction_type_recurring'] = array( |
545 | 545 | 'id' => 'authorizenet_transaction_type_recurring', |
546 | - 'name' => __( 'Transaction Type for Recurring', 'invoicing' ), |
|
547 | - 'desc' => __( 'Choose transaction type for recurring payments.', 'invoicing' ), |
|
546 | + 'name' => __('Transaction Type for Recurring', 'invoicing'), |
|
547 | + 'desc' => __('Choose transaction type for recurring payments.', 'invoicing'), |
|
548 | 548 | 'type' => 'select', |
549 | 549 | 'class' => 'wpi_select2', |
550 | 550 | 'options' => array( |
551 | - 'authorize_capture' => __( 'Authorize And Capture', 'invoicing' ), |
|
552 | - 'authorize_only' => __( 'Authorize Only', 'invoicing' ), |
|
551 | + 'authorize_capture' => __('Authorize And Capture', 'invoicing'), |
|
552 | + 'authorize_only' => __('Authorize Only', 'invoicing'), |
|
553 | 553 | ), |
554 | 554 | 'std' => 'authorize_only' |
555 | 555 | ); |
@@ -557,9 +557,9 @@ discard block |
||
557 | 557 | $setting['authorizenet_ipn_url'] = array( |
558 | 558 | 'type' => 'ipn_url', |
559 | 559 | 'id' => 'authorizenet_ipn_url', |
560 | - 'name' => __( 'Silent Post URL', 'invoicing' ), |
|
561 | - 'std' => wpinv_get_ipn_url( 'authorizenet' ), |
|
562 | - 'desc' => __( 'If you are accepting recurring payments then you must set this url at Authorize.Net Account > Settings > Transaction Format Settings > Transaction Response Settings > Silent Post URL.', 'invoicing' ), |
|
560 | + 'name' => __('Silent Post URL', 'invoicing'), |
|
561 | + 'std' => wpinv_get_ipn_url('authorizenet'), |
|
562 | + 'desc' => __('If you are accepting recurring payments then you must set this url at Authorize.Net Account > Settings > Transaction Format Settings > Transaction Response Settings > Silent Post URL.', 'invoicing'), |
|
563 | 563 | 'size' => 'large', |
564 | 564 | 'custom' => 'authorizenet', |
565 | 565 | 'readonly' => true |
@@ -567,26 +567,26 @@ discard block |
||
567 | 567 | |
568 | 568 | return $setting; |
569 | 569 | } |
570 | -add_filter( 'wpinv_gateway_settings_authorizenet', 'wpinv_gateway_settings_authorizenet', 10, 1 ); |
|
570 | +add_filter('wpinv_gateway_settings_authorizenet', 'wpinv_gateway_settings_authorizenet', 10, 1); |
|
571 | 571 | |
572 | 572 | // Worldpay settings |
573 | -function wpinv_gateway_settings_worldpay( $setting ) { |
|
574 | - $setting['worldpay_active']['desc'] = $setting['worldpay_active']['desc'] . ' ' . __( '( Supported Currencies: AUD, ARS, CAD, CHF, DKK, EUR, HKD, MYR, GBP, NZD, NOK, SGD, LKR, SEK, TRY, USD, ZAR )', 'invoicing' ); |
|
575 | - $setting['worldpay_desc']['std'] = __( 'Pay using a Worldpay account to process Credit card / Debit card transactions.', 'invoicing' ); |
|
573 | +function wpinv_gateway_settings_worldpay($setting) { |
|
574 | + $setting['worldpay_active']['desc'] = $setting['worldpay_active']['desc'] . ' ' . __('( Supported Currencies: AUD, ARS, CAD, CHF, DKK, EUR, HKD, MYR, GBP, NZD, NOK, SGD, LKR, SEK, TRY, USD, ZAR )', 'invoicing'); |
|
575 | + $setting['worldpay_desc']['std'] = __('Pay using a Worldpay account to process Credit card / Debit card transactions.', 'invoicing'); |
|
576 | 576 | |
577 | 577 | $setting['worldpay_sandbox'] = array( |
578 | 578 | 'type' => 'checkbox', |
579 | 579 | 'id' => 'worldpay_sandbox', |
580 | - 'name' => __( 'Worldpay Test Mode', 'invoicing' ), |
|
581 | - 'desc' => __( 'This provides a special Test Environment to enable you to test your installation and integration to your website before going live.', 'invoicing' ), |
|
580 | + 'name' => __('Worldpay Test Mode', 'invoicing'), |
|
581 | + 'desc' => __('This provides a special Test Environment to enable you to test your installation and integration to your website before going live.', 'invoicing'), |
|
582 | 582 | 'std' => 1 |
583 | 583 | ); |
584 | 584 | |
585 | 585 | $setting['worldpay_instId'] = array( |
586 | 586 | 'type' => 'text', |
587 | 587 | 'id' => 'worldpay_instId', |
588 | - 'name' => __( 'Installation Id', 'invoicing' ), |
|
589 | - 'desc' => __( 'Your installation id. Ex: 211616', 'invoicing' ), |
|
588 | + 'name' => __('Installation Id', 'invoicing'), |
|
589 | + 'desc' => __('Your installation id. Ex: 211616', 'invoicing'), |
|
590 | 590 | 'std' => '211616', |
591 | 591 | ); |
592 | 592 | /* |
@@ -602,9 +602,9 @@ discard block |
||
602 | 602 | $setting['worldpay_ipn_url'] = array( |
603 | 603 | 'type' => 'ipn_url', |
604 | 604 | 'id' => 'worldpay_ipn_url', |
605 | - 'name' => __( 'Worldpay Callback Url', 'invoicing' ), |
|
606 | - 'std' => wpinv_get_ipn_url( 'worldpay' ), |
|
607 | - 'desc' => wp_sprintf( __( 'Login to your Worldpay Merchant Interface then enable Payment Response & Shopper Response. Next, go to the Payment Response URL field and type "%s" or "%s" for a dynamic payment response.', 'invoicing' ), '<font style="color:#000;font-style:normal">' . wpinv_get_ipn_url( 'worldpay' ) . '</font>', '<font style="color:#000;font-style:normal"><wpdisplay item=MC_callback></font>' ), |
|
605 | + 'name' => __('Worldpay Callback Url', 'invoicing'), |
|
606 | + 'std' => wpinv_get_ipn_url('worldpay'), |
|
607 | + 'desc' => wp_sprintf(__('Login to your Worldpay Merchant Interface then enable Payment Response & Shopper Response. Next, go to the Payment Response URL field and type "%s" or "%s" for a dynamic payment response.', 'invoicing'), '<font style="color:#000;font-style:normal">' . wpinv_get_ipn_url('worldpay') . '</font>', '<font style="color:#000;font-style:normal"><wpdisplay item=MC_callback></font>'), |
|
608 | 608 | 'size' => 'large', |
609 | 609 | 'custom' => 'worldpay', |
610 | 610 | 'readonly' => true |
@@ -612,99 +612,99 @@ discard block |
||
612 | 612 | |
613 | 613 | return $setting; |
614 | 614 | } |
615 | -add_filter( 'wpinv_gateway_settings_worldpay', 'wpinv_gateway_settings_worldpay', 10, 1 ); |
|
615 | +add_filter('wpinv_gateway_settings_worldpay', 'wpinv_gateway_settings_worldpay', 10, 1); |
|
616 | 616 | |
617 | -function wpinv_ipn_url_callback( $args ) { |
|
618 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
617 | +function wpinv_ipn_url_callback($args) { |
|
618 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
619 | 619 | |
620 | 620 | $attrs = $args['readonly'] ? ' readonly' : ''; |
621 | 621 | |
622 | - $html = '<input style="background-color:#fefefe" type="text" ' . $attrs . ' value="' . esc_attr( $args['std'] ) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" class="large-text">'; |
|
623 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>'; |
|
622 | + $html = '<input style="background-color:#fefefe" type="text" ' . $attrs . ' value="' . esc_attr($args['std']) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" class="large-text">'; |
|
623 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>'; |
|
624 | 624 | |
625 | 625 | echo $html; |
626 | 626 | } |
627 | 627 | |
628 | -function wpinv_is_test_mode( $gateway = '' ) { |
|
629 | - if ( empty( $gateway ) ) { |
|
628 | +function wpinv_is_test_mode($gateway = '') { |
|
629 | + if (empty($gateway)) { |
|
630 | 630 | return false; |
631 | 631 | } |
632 | 632 | |
633 | - $is_test_mode = wpinv_get_option( $gateway . '_sandbox', false ); |
|
633 | + $is_test_mode = wpinv_get_option($gateway . '_sandbox', false); |
|
634 | 634 | |
635 | - return apply_filters( 'wpinv_is_test_mode', $is_test_mode, $gateway ); |
|
635 | + return apply_filters('wpinv_is_test_mode', $is_test_mode, $gateway); |
|
636 | 636 | } |
637 | 637 | |
638 | -function wpinv_get_ipn_url( $gateway = '', $args = array() ) { |
|
639 | - $data = array( 'wpi-listener' => 'IPN' ); |
|
638 | +function wpinv_get_ipn_url($gateway = '', $args = array()) { |
|
639 | + $data = array('wpi-listener' => 'IPN'); |
|
640 | 640 | |
641 | - if ( !empty( $gateway ) ) { |
|
642 | - $data['wpi-gateway'] = wpinv_sanitize_key( $gateway ); |
|
641 | + if (!empty($gateway)) { |
|
642 | + $data['wpi-gateway'] = wpinv_sanitize_key($gateway); |
|
643 | 643 | } |
644 | 644 | |
645 | - $args = !empty( $args ) && is_array( $args ) ? array_merge( $data, $args ) : $data; |
|
645 | + $args = !empty($args) && is_array($args) ? array_merge($data, $args) : $data; |
|
646 | 646 | |
647 | - $ipn_url = add_query_arg( $args, home_url( 'index.php' ) ); |
|
647 | + $ipn_url = add_query_arg($args, home_url('index.php')); |
|
648 | 648 | |
649 | - return apply_filters( 'wpinv_ipn_url', $ipn_url ); |
|
649 | + return apply_filters('wpinv_ipn_url', $ipn_url); |
|
650 | 650 | } |
651 | 651 | |
652 | 652 | function wpinv_listen_for_payment_ipn() { |
653 | 653 | // Regular PayPal IPN |
654 | - if ( isset( $_GET['wpi-listener'] ) && $_GET['wpi-listener'] == 'IPN' ) { |
|
655 | - do_action( 'wpinv_verify_payment_ipn' ); |
|
654 | + if (isset($_GET['wpi-listener']) && $_GET['wpi-listener'] == 'IPN') { |
|
655 | + do_action('wpinv_verify_payment_ipn'); |
|
656 | 656 | |
657 | - if ( !empty( $_GET['wpi-gateway'] ) ) { |
|
658 | - wpinv_error_log( sanitize_text_field( $_GET['wpi-gateway'] ), 'WP Invoicing IPN', __FILE__, __LINE__ ); |
|
659 | - do_action( 'wpinv_verify_' . sanitize_text_field( $_GET['wpi-gateway'] ) . '_ipn' ); |
|
657 | + if (!empty($_GET['wpi-gateway'])) { |
|
658 | + wpinv_error_log(sanitize_text_field($_GET['wpi-gateway']), 'WP Invoicing IPN', __FILE__, __LINE__); |
|
659 | + do_action('wpinv_verify_' . sanitize_text_field($_GET['wpi-gateway']) . '_ipn'); |
|
660 | 660 | } |
661 | 661 | } |
662 | 662 | } |
663 | -add_action( 'init', 'wpinv_listen_for_payment_ipn' ); |
|
663 | +add_action('init', 'wpinv_listen_for_payment_ipn'); |
|
664 | 664 | |
665 | 665 | function wpinv_get_bank_instructions() { |
666 | - $bank_instructions = wpinv_get_option( 'bank_transfer_info' ); |
|
666 | + $bank_instructions = wpinv_get_option('bank_transfer_info'); |
|
667 | 667 | |
668 | - return apply_filters( 'wpinv_bank_instructions', $bank_instructions ); |
|
668 | + return apply_filters('wpinv_bank_instructions', $bank_instructions); |
|
669 | 669 | } |
670 | 670 | |
671 | -function wpinv_get_bank_info( $filtered = false ) { |
|
671 | +function wpinv_get_bank_info($filtered = false) { |
|
672 | 672 | $bank_fields = array( |
673 | - 'bank_transfer_ac_name' => __( 'Account Name', 'invoicing' ), |
|
674 | - 'bank_transfer_ac_no' => __( 'Account Number', 'invoicing' ), |
|
675 | - 'bank_transfer_bank_name' => __( 'Bank Name', 'invoicing' ), |
|
676 | - 'bank_transfer_ifsc' => __( 'IFSC code', 'invoicing' ), |
|
677 | - 'bank_transfer_iban' => __( 'IBAN', 'invoicing' ), |
|
678 | - 'bank_transfer_bic' => __( 'BIC/Swift code', 'invoicing' ), |
|
679 | - 'bank_transfer_sort_code' => __( 'Sort Code', 'invoicing' ) |
|
673 | + 'bank_transfer_ac_name' => __('Account Name', 'invoicing'), |
|
674 | + 'bank_transfer_ac_no' => __('Account Number', 'invoicing'), |
|
675 | + 'bank_transfer_bank_name' => __('Bank Name', 'invoicing'), |
|
676 | + 'bank_transfer_ifsc' => __('IFSC code', 'invoicing'), |
|
677 | + 'bank_transfer_iban' => __('IBAN', 'invoicing'), |
|
678 | + 'bank_transfer_bic' => __('BIC/Swift code', 'invoicing'), |
|
679 | + 'bank_transfer_sort_code' => __('Sort Code', 'invoicing') |
|
680 | 680 | ); |
681 | 681 | |
682 | 682 | $bank_info = array(); |
683 | - foreach ( $bank_fields as $field => $label ) { |
|
684 | - if ( $filtered && !( $value = wpinv_get_option( $field ) ) ) { |
|
683 | + foreach ($bank_fields as $field => $label) { |
|
684 | + if ($filtered && !($value = wpinv_get_option($field))) { |
|
685 | 685 | continue; |
686 | 686 | } |
687 | 687 | |
688 | - $bank_info[$field] = array( 'label' => $label, 'value' => $value ); |
|
688 | + $bank_info[$field] = array('label' => $label, 'value' => $value); |
|
689 | 689 | } |
690 | 690 | |
691 | - return apply_filters( 'wpinv_bank_info', $bank_info, $filtered ); |
|
691 | + return apply_filters('wpinv_bank_info', $bank_info, $filtered); |
|
692 | 692 | } |
693 | 693 | |
694 | -function wpinv_get_post_data( $method = 'request' ) { |
|
694 | +function wpinv_get_post_data($method = 'request') { |
|
695 | 695 | $data = array(); |
696 | 696 | $request = $_REQUEST; |
697 | 697 | |
698 | - if ( $method == 'post' ) { |
|
699 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) { |
|
698 | + if ($method == 'post') { |
|
699 | + if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') { |
|
700 | 700 | return $data; |
701 | 701 | } |
702 | 702 | |
703 | 703 | $request = $_POST; |
704 | 704 | } |
705 | 705 | |
706 | - if ( $method == 'get' ) { |
|
707 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'GET' ) { |
|
706 | + if ($method == 'get') { |
|
707 | + if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'GET') { |
|
708 | 708 | return $data; |
709 | 709 | } |
710 | 710 | |
@@ -715,11 +715,11 @@ discard block |
||
715 | 715 | $post_data = ''; |
716 | 716 | |
717 | 717 | // Fallback just in case post_max_size is lower than needed |
718 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
719 | - $post_data = file_get_contents( 'php://input' ); |
|
718 | + if (ini_get('allow_url_fopen')) { |
|
719 | + $post_data = file_get_contents('php://input'); |
|
720 | 720 | } else { |
721 | 721 | // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough |
722 | - ini_set( 'post_max_size', '12M' ); |
|
722 | + ini_set('post_max_size', '12M'); |
|
723 | 723 | } |
724 | 724 | // Start the encoded data collection with notification command |
725 | 725 | $encoded_data = 'cmd=_notify-validate'; |
@@ -728,33 +728,33 @@ discard block |
||
728 | 728 | $arg_separator = wpinv_get_php_arg_separator_output(); |
729 | 729 | |
730 | 730 | // Verify there is a post_data |
731 | - if ( $post_data || strlen( $post_data ) > 0 ) { |
|
731 | + if ($post_data || strlen($post_data) > 0) { |
|
732 | 732 | // Append the data |
733 | 733 | $encoded_data .= $arg_separator . $post_data; |
734 | 734 | } else { |
735 | 735 | // Check if POST is empty |
736 | - if ( empty( $request ) ) { |
|
736 | + if (empty($request)) { |
|
737 | 737 | // Nothing to do |
738 | 738 | return; |
739 | 739 | } else { |
740 | 740 | // Loop through each POST |
741 | - foreach ( $request as $key => $value ) { |
|
741 | + foreach ($request as $key => $value) { |
|
742 | 742 | // Encode the value and append the data |
743 | - $encoded_data .= $arg_separator . "$key=" . urlencode( $value ); |
|
743 | + $encoded_data .= $arg_separator . "$key=" . urlencode($value); |
|
744 | 744 | } |
745 | 745 | } |
746 | 746 | } |
747 | 747 | |
748 | 748 | // Convert collected post data to an array |
749 | - wp_parse_str( $encoded_data, $data ); |
|
749 | + wp_parse_str($encoded_data, $data); |
|
750 | 750 | |
751 | - foreach ( $data as $key => $value ) { |
|
752 | - if ( false !== strpos( $key, 'amp;' ) ) { |
|
753 | - $new_key = str_replace( '&', '&', $key ); |
|
754 | - $new_key = str_replace( 'amp;', '&' , $new_key ); |
|
751 | + foreach ($data as $key => $value) { |
|
752 | + if (false !== strpos($key, 'amp;')) { |
|
753 | + $new_key = str_replace('&', '&', $key); |
|
754 | + $new_key = str_replace('amp;', '&', $new_key); |
|
755 | 755 | |
756 | - unset( $data[ $key ] ); |
|
757 | - $data[ $new_key ] = sanitize_text_field( $value ); |
|
756 | + unset($data[$key]); |
|
757 | + $data[$new_key] = sanitize_text_field($value); |
|
758 | 758 | } |
759 | 759 | } |
760 | 760 | |
@@ -764,26 +764,26 @@ discard block |
||
764 | 764 | /** |
765 | 765 | * Checks if a given gateway supports subscription payments. |
766 | 766 | */ |
767 | -function wpinv_gateway_support_subscription( $gateway ) { |
|
767 | +function wpinv_gateway_support_subscription($gateway) { |
|
768 | 768 | $supports = false; |
769 | 769 | |
770 | - if ( wpinv_is_gateway_active( $gateway ) ) { |
|
771 | - $supports = apply_filters( 'wpinv_' . $gateway . '_support_subscription', $supports ); |
|
772 | - $supports = apply_filters( 'getapid_gateway_support_subscription', $supports, $gateway ); |
|
770 | + if (wpinv_is_gateway_active($gateway)) { |
|
771 | + $supports = apply_filters('wpinv_' . $gateway . '_support_subscription', $supports); |
|
772 | + $supports = apply_filters('getapid_gateway_support_subscription', $supports, $gateway); |
|
773 | 773 | } |
774 | 774 | |
775 | 775 | return $supports; |
776 | 776 | } |
777 | 777 | |
778 | -function wpinv_payment_gateways_on_cart( $gateways = array() ) { |
|
779 | - if ( !empty( $gateways ) && wpinv_cart_has_recurring_item() ) { |
|
780 | - foreach ( $gateways as $gateway => $info ) { |
|
781 | - if ( !wpinv_gateway_support_subscription( $gateway ) ) { |
|
782 | - unset( $gateways[$gateway] ); |
|
778 | +function wpinv_payment_gateways_on_cart($gateways = array()) { |
|
779 | + if (!empty($gateways) && wpinv_cart_has_recurring_item()) { |
|
780 | + foreach ($gateways as $gateway => $info) { |
|
781 | + if (!wpinv_gateway_support_subscription($gateway)) { |
|
782 | + unset($gateways[$gateway]); |
|
783 | 783 | } |
784 | 784 | } |
785 | 785 | } |
786 | 786 | |
787 | 787 | return $gateways; |
788 | 788 | } |
789 | -add_filter( 'wpinv_payment_gateways_on_cart', 'wpinv_payment_gateways_on_cart', 10, 1 ); |
|
790 | 789 | \ No newline at end of file |
790 | +add_filter('wpinv_payment_gateways_on_cart', 'wpinv_payment_gateways_on_cart', 10, 1); |
|
791 | 791 | \ No newline at end of file |
@@ -161,10 +161,10 @@ discard block |
||
161 | 161 | require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' ); |
162 | 162 | |
163 | 163 | // Register autoloader. |
164 | - try { |
|
165 | - spl_autoload_register( array( $this, 'autoload' ), true ); |
|
166 | - } catch ( Exception $e ) { |
|
167 | - wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
|
164 | + try { |
|
165 | + spl_autoload_register( array( $this, 'autoload' ), true ); |
|
166 | + } catch ( Exception $e ) { |
|
167 | + wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | require_once( WPINV_PLUGIN_DIR . 'includes/class-getpaid-post-types.php' ); |
@@ -189,11 +189,11 @@ discard block |
||
189 | 189 | require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
190 | 190 | require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
191 | 191 | require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
192 | - require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
193 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
194 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
195 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
196 | - require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
192 | + require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
193 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
194 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
195 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
196 | + require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
197 | 197 | require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
198 | 198 | require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' ); |
199 | 199 | require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' ); |
@@ -253,47 +253,47 @@ discard block |
||
253 | 253 | } |
254 | 254 | |
255 | 255 | /** |
256 | - * Class autoloader |
|
257 | - * |
|
258 | - * @param string $class_name The name of the class to load. |
|
259 | - * @access public |
|
260 | - * @since 1.0.19 |
|
261 | - * @return void |
|
262 | - */ |
|
263 | - public function autoload( $class_name ) { |
|
264 | - |
|
265 | - // Normalize the class name... |
|
266 | - $class_name = strtolower( $class_name ); |
|
267 | - |
|
268 | - // ... and make sure it is our class. |
|
269 | - if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
270 | - return; |
|
271 | - } |
|
272 | - |
|
273 | - // Next, prepare the file name from the class. |
|
274 | - $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
275 | - |
|
276 | - // And an array of possible locations in order of importance. |
|
277 | - $locations = array( |
|
278 | - 'includes', |
|
279 | - 'includes/data-stores', |
|
256 | + * Class autoloader |
|
257 | + * |
|
258 | + * @param string $class_name The name of the class to load. |
|
259 | + * @access public |
|
260 | + * @since 1.0.19 |
|
261 | + * @return void |
|
262 | + */ |
|
263 | + public function autoload( $class_name ) { |
|
264 | + |
|
265 | + // Normalize the class name... |
|
266 | + $class_name = strtolower( $class_name ); |
|
267 | + |
|
268 | + // ... and make sure it is our class. |
|
269 | + if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
270 | + return; |
|
271 | + } |
|
272 | + |
|
273 | + // Next, prepare the file name from the class. |
|
274 | + $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
275 | + |
|
276 | + // And an array of possible locations in order of importance. |
|
277 | + $locations = array( |
|
278 | + 'includes', |
|
279 | + 'includes/data-stores', |
|
280 | 280 | 'includes/admin', |
281 | 281 | 'includes/admin/meta-boxes' |
282 | - ); |
|
282 | + ); |
|
283 | 283 | |
284 | - // Base path of the classes. |
|
285 | - $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
284 | + // Base path of the classes. |
|
285 | + $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
286 | 286 | |
287 | - foreach ( $locations as $location ) { |
|
287 | + foreach ( $locations as $location ) { |
|
288 | 288 | |
289 | - if ( file_exists( "$plugin_path/$location/$file_name" ) ) { |
|
290 | - include "$plugin_path/$location/$file_name"; |
|
291 | - break; |
|
292 | - } |
|
289 | + if ( file_exists( "$plugin_path/$location/$file_name" ) ) { |
|
290 | + include "$plugin_path/$location/$file_name"; |
|
291 | + break; |
|
292 | + } |
|
293 | 293 | |
294 | - } |
|
294 | + } |
|
295 | 295 | |
296 | - } |
|
296 | + } |
|
297 | 297 | |
298 | 298 | public function init() { |
299 | 299 | } |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' ); |
387 | 387 | wp_enqueue_style( 'jquery-ui-css' ); |
388 | 388 | wp_deregister_style( 'yoast-seo-select2' ); |
389 | - wp_deregister_style( 'yoast-seo-monorepo' ); |
|
389 | + wp_deregister_style( 'yoast-seo-monorepo' ); |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION ); |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | if ( $page == 'wpinv-subscriptions' ) { |
401 | 401 | wp_enqueue_script( 'jquery-ui-datepicker' ); |
402 | 402 | wp_deregister_style( 'yoast-seo-select2' ); |
403 | - wp_deregister_style( 'yoast-seo-monorepo' ); |
|
403 | + wp_deregister_style( 'yoast-seo-monorepo' ); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) { |
@@ -569,19 +569,19 @@ discard block |
||
569 | 569 | require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
570 | 570 | } |
571 | 571 | |
572 | - /** |
|
573 | - * Register widgets |
|
574 | - * |
|
575 | - */ |
|
576 | - public function register_widgets() { |
|
577 | - register_widget( "WPInv_Checkout_Widget" ); |
|
578 | - register_widget( "WPInv_History_Widget" ); |
|
579 | - register_widget( "WPInv_Receipt_Widget" ); |
|
580 | - register_widget( "WPInv_Subscriptions_Widget" ); |
|
581 | - register_widget( "WPInv_Buy_Item_Widget" ); |
|
572 | + /** |
|
573 | + * Register widgets |
|
574 | + * |
|
575 | + */ |
|
576 | + public function register_widgets() { |
|
577 | + register_widget( "WPInv_Checkout_Widget" ); |
|
578 | + register_widget( "WPInv_History_Widget" ); |
|
579 | + register_widget( "WPInv_Receipt_Widget" ); |
|
580 | + register_widget( "WPInv_Subscriptions_Widget" ); |
|
581 | + register_widget( "WPInv_Buy_Item_Widget" ); |
|
582 | 582 | register_widget( "WPInv_Messages_Widget" ); |
583 | 583 | register_widget( 'WPInv_GetPaid_Widget' ); |
584 | - } |
|
584 | + } |
|
585 | 585 | |
586 | 586 | /** |
587 | 587 | * Remove our pages from yoast sitemaps. |
@@ -7,15 +7,15 @@ 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 | class WPInv_Plugin { |
15 | 15 | private static $instance; |
16 | 16 | |
17 | 17 | public static function run() { |
18 | - if ( !isset( self::$instance ) && !( self::$instance instanceof WPInv_Plugin ) ) { |
|
18 | + if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Plugin)) { |
|
19 | 19 | self::$instance = new WPInv_Plugin; |
20 | 20 | self::$instance->includes(); |
21 | 21 | self::$instance->actions(); |
@@ -33,35 +33,35 @@ discard block |
||
33 | 33 | } |
34 | 34 | |
35 | 35 | public function define_constants() { |
36 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
37 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
36 | + define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE)); |
|
37 | + define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE)); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | private function actions() { |
41 | 41 | /* Internationalize the text strings used. */ |
42 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
42 | + add_action('plugins_loaded', array(&$this, 'plugins_loaded')); |
|
43 | 43 | |
44 | 44 | /* Perform actions on admin initialization. */ |
45 | - add_action( 'admin_init', array( &$this, 'admin_init') ); |
|
46 | - add_action( 'init', array( &$this, 'init' ), 3 ); |
|
47 | - add_action( 'init', array( &$this, 'wpinv_actions' ) ); |
|
45 | + add_action('admin_init', array(&$this, 'admin_init')); |
|
46 | + add_action('init', array(&$this, 'init'), 3); |
|
47 | + add_action('init', array(&$this, 'wpinv_actions')); |
|
48 | 48 | |
49 | - if ( class_exists( 'BuddyPress' ) ) { |
|
50 | - add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) ); |
|
49 | + if (class_exists('BuddyPress')) { |
|
50 | + add_action('bp_include', array(&$this, 'bp_invoicing_init')); |
|
51 | 51 | } |
52 | 52 | |
53 | - add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); |
|
54 | - add_action( 'wp_footer', array( &$this, 'wp_footer' ) ); |
|
55 | - add_action( 'widgets_init', array( &$this, 'register_widgets' ) ); |
|
56 | - add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) ); |
|
53 | + add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts')); |
|
54 | + add_action('wp_footer', array(&$this, 'wp_footer')); |
|
55 | + add_action('widgets_init', array(&$this, 'register_widgets')); |
|
56 | + add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids')); |
|
57 | 57 | |
58 | - if ( is_admin() ) { |
|
59 | - add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) ); |
|
60 | - add_filter( 'admin_body_class', array( &$this, 'admin_body_class' ) ); |
|
61 | - add_action( 'admin_init', array( &$this, 'init_ayecode_connect_helper' ) ); |
|
58 | + if (is_admin()) { |
|
59 | + add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts')); |
|
60 | + add_filter('admin_body_class', array(&$this, 'admin_body_class')); |
|
61 | + add_action('admin_init', array(&$this, 'init_ayecode_connect_helper')); |
|
62 | 62 | |
63 | 63 | } else { |
64 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
64 | + add_filter('pre_get_posts', array(&$this, 'pre_get_posts')); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -71,28 +71,28 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference. |
73 | 73 | */ |
74 | - do_action_ref_array( 'wpinv_actions', array( &$this ) ); |
|
74 | + do_action_ref_array('wpinv_actions', array(&$this)); |
|
75 | 75 | |
76 | - add_action( 'admin_init', array( &$this, 'activation_redirect') ); |
|
76 | + add_action('admin_init', array(&$this, 'activation_redirect')); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
80 | 80 | * Maybe show the AyeCode Connect Notice. |
81 | 81 | */ |
82 | - public function init_ayecode_connect_helper(){ |
|
82 | + public function init_ayecode_connect_helper() { |
|
83 | 83 | // AyeCode Connect notice |
84 | - if ( is_admin() ){ |
|
84 | + if (is_admin()) { |
|
85 | 85 | // set the strings so they can be translated |
86 | 86 | $strings = array( |
87 | - 'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), |
|
88 | - 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ), |
|
89 | - '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","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ), |
|
90 | - 'connect_button' => __("Connect Site","invoicing"), |
|
91 | - 'connecting_button' => __("Connecting...","invoicing"), |
|
92 | - 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ), |
|
93 | - 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ), |
|
87 | + 'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"), |
|
88 | + 'connect_external' => __("Please confirm you wish to connect your site?", "invoicing"), |
|
89 | + '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", "invoicing"), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>"), |
|
90 | + 'connect_button' => __("Connect Site", "invoicing"), |
|
91 | + 'connecting_button' => __("Connecting...", "invoicing"), |
|
92 | + 'error_localhost' => __("This service will only work with a live domain, not a localhost.", "invoicing"), |
|
93 | + 'error' => __("Something went wrong, please refresh and try again.", "invoicing"), |
|
94 | 94 | ); |
95 | - new AyeCode_Connect_Helper($strings,array('wpi-addons')); |
|
95 | + new AyeCode_Connect_Helper($strings, array('wpi-addons')); |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
@@ -100,10 +100,10 @@ discard block |
||
100 | 100 | /* Internationalize the text strings used. */ |
101 | 101 | $this->load_textdomain(); |
102 | 102 | |
103 | - do_action( 'wpinv_loaded' ); |
|
103 | + do_action('wpinv_loaded'); |
|
104 | 104 | |
105 | 105 | // Fix oxygen page builder conflict |
106 | - if ( function_exists( 'ct_css_output' ) ) { |
|
106 | + if (function_exists('ct_css_output')) { |
|
107 | 107 | wpinv_oxygen_fix_conflict(); |
108 | 108 | } |
109 | 109 | } |
@@ -113,143 +113,143 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @since 1.0 |
115 | 115 | */ |
116 | - public function load_textdomain( $locale = NULL ) { |
|
117 | - if ( empty( $locale ) ) { |
|
118 | - $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
116 | + public function load_textdomain($locale = NULL) { |
|
117 | + if (empty($locale)) { |
|
118 | + $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale(); |
|
119 | 119 | } |
120 | 120 | |
121 | - $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' ); |
|
121 | + $locale = apply_filters('plugin_locale', $locale, 'invoicing'); |
|
122 | 122 | |
123 | - unload_textdomain( 'invoicing' ); |
|
124 | - load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
|
125 | - load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
123 | + unload_textdomain('invoicing'); |
|
124 | + load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo'); |
|
125 | + load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages'); |
|
126 | 126 | |
127 | 127 | /** |
128 | 128 | * Define language constants. |
129 | 129 | */ |
130 | - require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
130 | + require_once(WPINV_PLUGIN_DIR . 'language.php'); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | public function includes() { |
134 | 134 | global $wpinv_options; |
135 | 135 | |
136 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
136 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php'); |
|
137 | 137 | $wpinv_options = wpinv_get_settings(); |
138 | 138 | |
139 | 139 | // Load composer packages. |
140 | - require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
140 | + require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php'); |
|
141 | 141 | |
142 | 142 | // load AUI |
143 | - require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' ); |
|
143 | + require_once(WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php'); |
|
144 | 144 | |
145 | 145 | // Load the action scheduler. |
146 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php' ); |
|
146 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php'); |
|
147 | 147 | |
148 | 148 | // Load functions. |
149 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
150 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
151 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
152 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
153 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
154 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
155 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' ); |
|
156 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
157 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
158 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
159 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
160 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' ); |
|
161 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' ); |
|
149 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php'); |
|
150 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php'); |
|
151 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php'); |
|
152 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php'); |
|
153 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php'); |
|
154 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php'); |
|
155 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php'); |
|
156 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php'); |
|
157 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php'); |
|
158 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php'); |
|
159 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php'); |
|
160 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php'); |
|
161 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php'); |
|
162 | 162 | |
163 | 163 | // Register autoloader. |
164 | 164 | try { |
165 | - spl_autoload_register( array( $this, 'autoload' ), true ); |
|
166 | - } catch ( Exception $e ) { |
|
167 | - wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
|
168 | - } |
|
169 | - |
|
170 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-getpaid-post-types.php' ); |
|
171 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' ); |
|
172 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' ); |
|
173 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-discount.php' ); |
|
174 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' ); |
|
175 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' ); |
|
176 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
177 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
178 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
179 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
180 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' ); |
|
181 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
182 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
183 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
184 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
185 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php' ); |
|
186 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
187 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php' ); |
|
188 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
189 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
190 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
191 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
192 | - require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
193 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
194 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
195 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
196 | - require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
197 | - require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
198 | - require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' ); |
|
199 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' ); |
|
200 | - |
|
201 | - if ( !class_exists( 'WPInv_EUVat' ) ) { |
|
202 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' ); |
|
165 | + spl_autoload_register(array($this, 'autoload'), true); |
|
166 | + } catch (Exception $e) { |
|
167 | + wpinv_error_log($e->getMessage(), '', __FILE__, 149, true); |
|
168 | + } |
|
169 | + |
|
170 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-getpaid-post-types.php'); |
|
171 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php'); |
|
172 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php'); |
|
173 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-discount.php'); |
|
174 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php'); |
|
175 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php'); |
|
176 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php'); |
|
177 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php'); |
|
178 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php'); |
|
179 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php'); |
|
180 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php'); |
|
181 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php'); |
|
182 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php'); |
|
183 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php'); |
|
184 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php'); |
|
185 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php'); |
|
186 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php'); |
|
187 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php'); |
|
188 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php'); |
|
189 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php'); |
|
190 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php'); |
|
191 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php'); |
|
192 | + require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php'); |
|
193 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php'); |
|
194 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php'); |
|
195 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php'); |
|
196 | + require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php'); |
|
197 | + require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php'); |
|
198 | + require_once(WPINV_PLUGIN_DIR . 'widgets/getpaid.php'); |
|
199 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php'); |
|
200 | + |
|
201 | + if (!class_exists('WPInv_EUVat')) { |
|
202 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php'); |
|
203 | 203 | } |
204 | 204 | |
205 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
206 | - if ( !empty( $gateways ) ) { |
|
207 | - foreach ( $gateways as $gateway ) { |
|
208 | - if ( $gateway == 'manual' ) { |
|
205 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
206 | + if (!empty($gateways)) { |
|
207 | + foreach ($gateways as $gateway) { |
|
208 | + if ($gateway == 'manual') { |
|
209 | 209 | continue; |
210 | 210 | } |
211 | 211 | |
212 | 212 | $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php'; |
213 | 213 | |
214 | - if ( file_exists( $gateway_file ) ) { |
|
215 | - require_once( $gateway_file ); |
|
214 | + if (file_exists($gateway_file)) { |
|
215 | + require_once($gateway_file); |
|
216 | 216 | } |
217 | 217 | } |
218 | 218 | } |
219 | - require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' ); |
|
219 | + require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php'); |
|
220 | 220 | |
221 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
221 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
222 | 222 | GetPaid_Post_Types_Admin::init(); |
223 | 223 | |
224 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' ); |
|
225 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
224 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php'); |
|
225 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php'); |
|
226 | 226 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' ); |
227 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' ); |
|
228 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
229 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
230 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
231 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
232 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' ); |
|
227 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php'); |
|
228 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php'); |
|
229 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'); |
|
230 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php'); |
|
231 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php'); |
|
232 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php'); |
|
233 | 233 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
234 | 234 | // load the user class only on the users.php page |
235 | 235 | global $pagenow; |
236 | - if($pagenow=='users.php'){ |
|
236 | + if ($pagenow == 'users.php') { |
|
237 | 237 | new WPInv_Admin_Users(); |
238 | 238 | } |
239 | 239 | } |
240 | 240 | |
241 | 241 | // Register cli commands |
242 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
243 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
244 | - WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
242 | + if (defined('WP_CLI') && WP_CLI) { |
|
243 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php'); |
|
244 | + WP_CLI::add_command('invoicing', 'WPInv_CLI'); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | // include css inliner |
248 | - if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) { |
|
249 | - include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' ); |
|
248 | + if (!class_exists('Emogrifier') && class_exists('DOMDocument')) { |
|
249 | + include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php'); |
|
250 | 250 | } |
251 | 251 | |
252 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' ); |
|
252 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php'); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /** |
@@ -260,18 +260,18 @@ discard block |
||
260 | 260 | * @since 1.0.19 |
261 | 261 | * @return void |
262 | 262 | */ |
263 | - public function autoload( $class_name ) { |
|
263 | + public function autoload($class_name) { |
|
264 | 264 | |
265 | 265 | // Normalize the class name... |
266 | - $class_name = strtolower( $class_name ); |
|
266 | + $class_name = strtolower($class_name); |
|
267 | 267 | |
268 | 268 | // ... and make sure it is our class. |
269 | - if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
269 | + if (false === strpos($class_name, 'getpaid_') && false === strpos($class_name, 'wpinv_')) { |
|
270 | 270 | return; |
271 | 271 | } |
272 | 272 | |
273 | 273 | // Next, prepare the file name from the class. |
274 | - $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
274 | + $file_name = 'class-' . str_replace('_', '-', $class_name) . '.php'; |
|
275 | 275 | |
276 | 276 | // And an array of possible locations in order of importance. |
277 | 277 | $locations = array( |
@@ -282,11 +282,11 @@ discard block |
||
282 | 282 | ); |
283 | 283 | |
284 | 284 | // Base path of the classes. |
285 | - $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
285 | + $plugin_path = untrailingslashit(WPINV_PLUGIN_DIR); |
|
286 | 286 | |
287 | - foreach ( $locations as $location ) { |
|
287 | + foreach ($locations as $location) { |
|
288 | 288 | |
289 | - if ( file_exists( "$plugin_path/$location/$file_name" ) ) { |
|
289 | + if (file_exists("$plugin_path/$location/$file_name")) { |
|
290 | 290 | include "$plugin_path/$location/$file_name"; |
291 | 291 | break; |
292 | 292 | } |
@@ -300,117 +300,117 @@ discard block |
||
300 | 300 | |
301 | 301 | public function admin_init() { |
302 | 302 | self::$instance->default_payment_form = wpinv_get_default_payment_form(); |
303 | - add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) ); |
|
303 | + add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php')); |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | public function activation_redirect() { |
307 | 307 | // Bail if no activation redirect |
308 | - if ( !get_transient( '_wpinv_activation_redirect' ) ) { |
|
308 | + if (!get_transient('_wpinv_activation_redirect')) { |
|
309 | 309 | return; |
310 | 310 | } |
311 | 311 | |
312 | 312 | // Delete the redirect transient |
313 | - delete_transient( '_wpinv_activation_redirect' ); |
|
313 | + delete_transient('_wpinv_activation_redirect'); |
|
314 | 314 | |
315 | 315 | // Bail if activating from network, or bulk |
316 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
316 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
317 | 317 | return; |
318 | 318 | } |
319 | 319 | |
320 | - wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
|
320 | + wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general')); |
|
321 | 321 | exit; |
322 | 322 | } |
323 | 323 | |
324 | 324 | public function enqueue_scripts() { |
325 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
325 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
326 | 326 | |
327 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' ); |
|
328 | - wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version ); |
|
329 | - wp_enqueue_style( 'wpinv_front_style' ); |
|
327 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css'); |
|
328 | + wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version); |
|
329 | + wp_enqueue_style('wpinv_front_style'); |
|
330 | 330 | |
331 | 331 | // Register scripts |
332 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
333 | - wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ), filemtime( WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js' ) ); |
|
332 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
333 | + wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array('jquery'), filemtime(WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js')); |
|
334 | 334 | |
335 | 335 | $localize = array(); |
336 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
337 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
336 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
337 | + $localize['nonce'] = wp_create_nonce('wpinv-nonce'); |
|
338 | 338 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
339 | 339 | $localize['currency_pos'] = wpinv_currency_position(); |
340 | 340 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
341 | 341 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
342 | 342 | $localize['decimals'] = wpinv_decimals(); |
343 | - $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
343 | + $localize['txtComplete'] = __('Continue', 'invoicing'); |
|
344 | 344 | $localize['UseTaxes'] = wpinv_use_taxes(); |
345 | - $localize['checkoutNonce'] = wp_create_nonce( 'wpinv_checkout_nonce' ); |
|
346 | - $localize['formNonce'] = wp_create_nonce( 'getpaid_form_nonce' ); |
|
347 | - $localize['connectionError'] = __( 'Could not establish a connection to the server.', 'invoicing' ); |
|
345 | + $localize['checkoutNonce'] = wp_create_nonce('wpinv_checkout_nonce'); |
|
346 | + $localize['formNonce'] = wp_create_nonce('getpaid_form_nonce'); |
|
347 | + $localize['connectionError'] = __('Could not establish a connection to the server.', 'invoicing'); |
|
348 | 348 | |
349 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
349 | + $localize = apply_filters('wpinv_front_js_localize', $localize); |
|
350 | 350 | |
351 | - wp_enqueue_script( 'jquery-blockui' ); |
|
351 | + wp_enqueue_script('jquery-blockui'); |
|
352 | 352 | $autofill_api = wpinv_get_option('address_autofill_api'); |
353 | 353 | $autofill_active = wpinv_get_option('address_autofill_active'); |
354 | - if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) { |
|
355 | - if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) { |
|
356 | - wp_dequeue_script( 'google-maps-api' ); |
|
354 | + if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) { |
|
355 | + if (wp_script_is('google-maps-api', 'enqueued')) { |
|
356 | + wp_dequeue_script('google-maps-api'); |
|
357 | 357 | } |
358 | - wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false ); |
|
359 | - wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true ); |
|
358 | + wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false); |
|
359 | + wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true); |
|
360 | 360 | } |
361 | 361 | |
362 | - wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' ); |
|
363 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
362 | + wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all'); |
|
363 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
364 | 364 | |
365 | - wp_enqueue_script( 'wpinv-front-script' ); |
|
366 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
365 | + wp_enqueue_script('wpinv-front-script'); |
|
366 | + wp_localize_script('wpinv-front-script', 'WPInv', $localize); |
|
367 | 367 | |
368 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
369 | - wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ), $version, true ); |
|
368 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js'); |
|
369 | + wp_enqueue_script('wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('wpinv-front-script', 'wp-hooks'), $version, true); |
|
370 | 370 | } |
371 | 371 | |
372 | - public function admin_enqueue_scripts( $hook ) { |
|
372 | + public function admin_enqueue_scripts($hook) { |
|
373 | 373 | global $post, $pagenow; |
374 | 374 | |
375 | 375 | $post_type = wpinv_admin_post_type(); |
376 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
377 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : ''; |
|
376 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
377 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : ''; |
|
378 | 378 | |
379 | 379 | $jquery_ui_css = false; |
380 | - if ( ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount' ) && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) { |
|
380 | + if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
|
381 | 381 | $jquery_ui_css = true; |
382 | - } else if ( $page == 'wpinv-settings' || $page == 'wpinv-reports' ) { |
|
382 | + } else if ($page == 'wpinv-settings' || $page == 'wpinv-reports') { |
|
383 | 383 | $jquery_ui_css = true; |
384 | 384 | } |
385 | - if ( $jquery_ui_css ) { |
|
386 | - wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' ); |
|
387 | - wp_enqueue_style( 'jquery-ui-css' ); |
|
388 | - wp_deregister_style( 'yoast-seo-select2' ); |
|
389 | - wp_deregister_style( 'yoast-seo-monorepo' ); |
|
385 | + if ($jquery_ui_css) { |
|
386 | + wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16'); |
|
387 | + wp_enqueue_style('jquery-ui-css'); |
|
388 | + wp_deregister_style('yoast-seo-select2'); |
|
389 | + wp_deregister_style('yoast-seo-monorepo'); |
|
390 | 390 | } |
391 | 391 | |
392 | - wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION ); |
|
393 | - wp_enqueue_style( 'wpinv_meta_box_style' ); |
|
392 | + wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION); |
|
393 | + wp_enqueue_style('wpinv_meta_box_style'); |
|
394 | 394 | |
395 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' ); |
|
396 | - wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), $version ); |
|
397 | - wp_enqueue_style( 'wpinv_admin_style' ); |
|
395 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css'); |
|
396 | + wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), $version); |
|
397 | + wp_enqueue_style('wpinv_admin_style'); |
|
398 | 398 | |
399 | - $enqueue = ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ); |
|
400 | - if ( $page == 'wpinv-subscriptions' ) { |
|
401 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
402 | - wp_deregister_style( 'yoast-seo-select2' ); |
|
403 | - wp_deregister_style( 'yoast-seo-monorepo' ); |
|
399 | + $enqueue = ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')); |
|
400 | + if ($page == 'wpinv-subscriptions') { |
|
401 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
402 | + wp_deregister_style('yoast-seo-select2'); |
|
403 | + wp_deregister_style('yoast-seo-monorepo'); |
|
404 | 404 | } |
405 | 405 | |
406 | - if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) { |
|
407 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
406 | + if ($enqueue_datepicker = apply_filters('wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue)) { |
|
407 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
408 | 408 | } |
409 | 409 | |
410 | - wp_enqueue_style( 'wp-color-picker' ); |
|
411 | - wp_enqueue_script( 'wp-color-picker' ); |
|
410 | + wp_enqueue_style('wp-color-picker'); |
|
411 | + wp_enqueue_script('wp-color-picker'); |
|
412 | 412 | |
413 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
413 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
414 | 414 | |
415 | 415 | if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
416 | 416 | $autofill_api = wpinv_get_option('address_autofill_api'); |
@@ -421,21 +421,21 @@ discard block |
||
421 | 421 | } |
422 | 422 | } |
423 | 423 | |
424 | - wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' ); |
|
425 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
424 | + wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all'); |
|
425 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
426 | 426 | |
427 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' ); |
|
428 | - wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ), $version ); |
|
429 | - wp_enqueue_script( 'wpinv-admin-script' ); |
|
427 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js'); |
|
428 | + wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), $version); |
|
429 | + wp_enqueue_script('wpinv-admin-script'); |
|
430 | 430 | |
431 | 431 | $localize = array(); |
432 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
433 | - $localize['post_ID'] = isset( $post->ID ) ? $post->ID : ''; |
|
434 | - $localize['wpinv_nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
435 | - $localize['add_invoice_note_nonce'] = wp_create_nonce( 'add-invoice-note' ); |
|
436 | - $localize['delete_invoice_note_nonce'] = wp_create_nonce( 'delete-invoice-note' ); |
|
437 | - $localize['invoice_item_nonce'] = wp_create_nonce( 'invoice-item' ); |
|
438 | - $localize['billing_details_nonce'] = wp_create_nonce( 'get-billing-details' ); |
|
432 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
433 | + $localize['post_ID'] = isset($post->ID) ? $post->ID : ''; |
|
434 | + $localize['wpinv_nonce'] = wp_create_nonce('wpinv-nonce'); |
|
435 | + $localize['add_invoice_note_nonce'] = wp_create_nonce('add-invoice-note'); |
|
436 | + $localize['delete_invoice_note_nonce'] = wp_create_nonce('delete-invoice-note'); |
|
437 | + $localize['invoice_item_nonce'] = wp_create_nonce('invoice-item'); |
|
438 | + $localize['billing_details_nonce'] = wp_create_nonce('get-billing-details'); |
|
439 | 439 | $localize['tax'] = wpinv_tax_amount(); |
440 | 440 | $localize['discount'] = wpinv_discount_amount(); |
441 | 441 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
@@ -443,104 +443,104 @@ discard block |
||
443 | 443 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
444 | 444 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
445 | 445 | $localize['decimals'] = wpinv_decimals(); |
446 | - $localize['save_invoice'] = __( 'Save Invoice', 'invoicing' ); |
|
447 | - $localize['status_publish'] = wpinv_status_nicename( 'publish' ); |
|
448 | - $localize['status_pending'] = wpinv_status_nicename( 'wpi-pending' ); |
|
449 | - $localize['delete_tax_rate'] = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ); |
|
450 | - $localize['OneItemMin'] = __( 'Invoice must contain at least one item', 'invoicing' ); |
|
451 | - $localize['DeleteInvoiceItem'] = __( 'Are you sure you wish to delete this item?', 'invoicing' ); |
|
452 | - $localize['FillBillingDetails'] = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ); |
|
453 | - $localize['confirmCalcTotals'] = __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ); |
|
454 | - $localize['AreYouSure'] = __( 'Are you sure?', 'invoicing' ); |
|
455 | - $localize['emptyInvoice'] = __( 'Add at least one item to save invoice!', 'invoicing' ); |
|
456 | - $localize['errDeleteItem'] = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ); |
|
457 | - $localize['delete_subscription'] = __( 'Are you sure you want to delete this subscription?', 'invoicing' ); |
|
458 | - $localize['action_edit'] = __( 'Edit', 'invoicing' ); |
|
459 | - $localize['action_cancel'] = __( 'Cancel', 'invoicing' ); |
|
460 | - $localize['item_description'] = __( 'Item Description', 'invoicing' ); |
|
461 | - $localize['discount_description'] = __( 'Discount Description', 'invoicing' ); |
|
462 | - $localize['invoice_description'] = __( 'Invoice Description', 'invoicing' ); |
|
463 | - $localize['searching'] = __( 'Searching', 'invoicing' ); |
|
464 | - |
|
465 | - $localize = apply_filters( 'wpinv_admin_js_localize', $localize ); |
|
466 | - |
|
467 | - wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize ); |
|
446 | + $localize['save_invoice'] = __('Save Invoice', 'invoicing'); |
|
447 | + $localize['status_publish'] = wpinv_status_nicename('publish'); |
|
448 | + $localize['status_pending'] = wpinv_status_nicename('wpi-pending'); |
|
449 | + $localize['delete_tax_rate'] = __('Are you sure you wish to delete this tax rate?', 'invoicing'); |
|
450 | + $localize['OneItemMin'] = __('Invoice must contain at least one item', 'invoicing'); |
|
451 | + $localize['DeleteInvoiceItem'] = __('Are you sure you wish to delete this item?', 'invoicing'); |
|
452 | + $localize['FillBillingDetails'] = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'); |
|
453 | + $localize['confirmCalcTotals'] = __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'); |
|
454 | + $localize['AreYouSure'] = __('Are you sure?', 'invoicing'); |
|
455 | + $localize['emptyInvoice'] = __('Add at least one item to save invoice!', 'invoicing'); |
|
456 | + $localize['errDeleteItem'] = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'); |
|
457 | + $localize['delete_subscription'] = __('Are you sure you want to delete this subscription?', 'invoicing'); |
|
458 | + $localize['action_edit'] = __('Edit', 'invoicing'); |
|
459 | + $localize['action_cancel'] = __('Cancel', 'invoicing'); |
|
460 | + $localize['item_description'] = __('Item Description', 'invoicing'); |
|
461 | + $localize['discount_description'] = __('Discount Description', 'invoicing'); |
|
462 | + $localize['invoice_description'] = __('Invoice Description', 'invoicing'); |
|
463 | + $localize['searching'] = __('Searching', 'invoicing'); |
|
464 | + |
|
465 | + $localize = apply_filters('wpinv_admin_js_localize', $localize); |
|
466 | + |
|
467 | + wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize); |
|
468 | 468 | |
469 | 469 | // Load payment form scripts on our admin pages only. |
470 | - if ( ( $hook == 'post-new.php' || $hook == 'post.php' ) && 'wpi_payment_form' === $post->post_type ) { |
|
470 | + if (($hook == 'post-new.php' || $hook == 'post.php') && 'wpi_payment_form' === $post->post_type) { |
|
471 | 471 | |
472 | - wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION ); |
|
473 | - wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
474 | - wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
472 | + wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION); |
|
473 | + wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION); |
|
474 | + wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION); |
|
475 | 475 | |
476 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' ); |
|
477 | - wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ), $version ); |
|
476 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js'); |
|
477 | + wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable'), $version); |
|
478 | 478 | |
479 | - wp_localize_script( 'wpinv-admin-payment-form-script', 'wpinvPaymentFormAdmin', array( |
|
479 | + wp_localize_script('wpinv-admin-payment-form-script', 'wpinvPaymentFormAdmin', array( |
|
480 | 480 | 'elements' => $this->form_elements->get_elements(), |
481 | - 'form_elements' => $this->form_elements->get_form_elements( $post->ID ), |
|
481 | + 'form_elements' => $this->form_elements->get_form_elements($post->ID), |
|
482 | 482 | 'all_items' => $this->form_elements->get_published_items(), |
483 | 483 | 'currency' => wpinv_currency_symbol(), |
484 | 484 | 'position' => wpinv_currency_position(), |
485 | 485 | 'decimals' => (int) wpinv_decimals(), |
486 | 486 | 'thousands_sep' => wpinv_thousands_separator(), |
487 | 487 | 'decimals_sep' => wpinv_decimal_separator(), |
488 | - 'form_items' => $this->form_elements->get_form_items( $post->ID ), |
|
488 | + 'form_items' => $this->form_elements->get_form_items($post->ID), |
|
489 | 489 | 'is_default' => $post->ID == $this->default_payment_form, |
490 | - ) ); |
|
490 | + )); |
|
491 | 491 | |
492 | - wp_enqueue_script( 'wpinv-admin-payment-form-script' ); |
|
492 | + wp_enqueue_script('wpinv-admin-payment-form-script'); |
|
493 | 493 | } |
494 | 494 | |
495 | - if ( $page == 'wpinv-subscriptions' ) { |
|
496 | - wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ), WPINV_VERSION ); |
|
497 | - wp_enqueue_script( 'wpinv-sub-admin-script' ); |
|
495 | + if ($page == 'wpinv-subscriptions') { |
|
496 | + wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array('wpinv-admin-script'), WPINV_VERSION); |
|
497 | + wp_enqueue_script('wpinv-sub-admin-script'); |
|
498 | 498 | } |
499 | 499 | |
500 | - if ( $page == 'wpinv-reports' ) { |
|
501 | - wp_enqueue_script( 'jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array( 'jquery' ), '0.7' ); |
|
500 | + if ($page == 'wpinv-reports') { |
|
501 | + wp_enqueue_script('jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array('jquery'), '0.7'); |
|
502 | 502 | } |
503 | 503 | |
504 | 504 | } |
505 | 505 | |
506 | - public function admin_body_class( $classes ) { |
|
506 | + public function admin_body_class($classes) { |
|
507 | 507 | global $pagenow, $post, $current_screen; |
508 | 508 | |
509 | - if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_payment_form' || $current_screen->post_type == 'wpi_quote' ) ) { |
|
509 | + if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_payment_form' || $current_screen->post_type == 'wpi_quote')) { |
|
510 | 510 | $classes .= ' wpinv-cpt'; |
511 | 511 | } |
512 | 512 | |
513 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
513 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
514 | 514 | |
515 | - $add_class = $page && $pagenow == 'admin.php' && strpos( $page, 'wpinv-' ) === 0 ? true : false; |
|
516 | - if ( $add_class ) { |
|
517 | - $classes .= ' wpi-' . wpinv_sanitize_key( $page ); |
|
515 | + $add_class = $page && $pagenow == 'admin.php' && strpos($page, 'wpinv-') === 0 ? true : false; |
|
516 | + if ($add_class) { |
|
517 | + $classes .= ' wpi-' . wpinv_sanitize_key($page); |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | $settings_class = array(); |
521 | - if ( $page == 'wpinv-settings' ) { |
|
522 | - if ( !empty( $_REQUEST['tab'] ) ) { |
|
523 | - $settings_class[] = sanitize_text_field( $_REQUEST['tab'] ); |
|
521 | + if ($page == 'wpinv-settings') { |
|
522 | + if (!empty($_REQUEST['tab'])) { |
|
523 | + $settings_class[] = sanitize_text_field($_REQUEST['tab']); |
|
524 | 524 | } |
525 | 525 | |
526 | - if ( !empty( $_REQUEST['section'] ) ) { |
|
527 | - $settings_class[] = sanitize_text_field( $_REQUEST['section'] ); |
|
526 | + if (!empty($_REQUEST['section'])) { |
|
527 | + $settings_class[] = sanitize_text_field($_REQUEST['section']); |
|
528 | 528 | } |
529 | 529 | |
530 | - $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main'; |
|
530 | + $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main'; |
|
531 | 531 | } |
532 | 532 | |
533 | - if ( !empty( $settings_class ) ) { |
|
534 | - $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) ); |
|
533 | + if (!empty($settings_class)) { |
|
534 | + $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-')); |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | $post_type = wpinv_admin_post_type(); |
538 | 538 | |
539 | - if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) { |
|
539 | + if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) { |
|
540 | 540 | return $classes .= ' wpinv'; |
541 | 541 | } |
542 | 542 | |
543 | - if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) { |
|
543 | + if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) { |
|
544 | 544 | $classes .= ' wpi-editable-n'; |
545 | 545 | } |
546 | 546 | |
@@ -552,21 +552,21 @@ discard block |
||
552 | 552 | } |
553 | 553 | |
554 | 554 | public function wpinv_actions() { |
555 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
556 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
555 | + if (isset($_REQUEST['wpi_action'])) { |
|
556 | + do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); |
|
557 | 557 | } |
558 | 558 | } |
559 | 559 | |
560 | - public function pre_get_posts( $wp_query ) { |
|
561 | - if ( !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) { |
|
562 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() ); |
|
560 | + public function pre_get_posts($wp_query) { |
|
561 | + if (!empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query()) { |
|
562 | + $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses()); |
|
563 | 563 | } |
564 | 564 | |
565 | 565 | return $wp_query; |
566 | 566 | } |
567 | 567 | |
568 | 568 | public function bp_invoicing_init() { |
569 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
569 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php'); |
|
570 | 570 | } |
571 | 571 | |
572 | 572 | /** |
@@ -574,13 +574,13 @@ discard block |
||
574 | 574 | * |
575 | 575 | */ |
576 | 576 | public function register_widgets() { |
577 | - register_widget( "WPInv_Checkout_Widget" ); |
|
578 | - register_widget( "WPInv_History_Widget" ); |
|
579 | - register_widget( "WPInv_Receipt_Widget" ); |
|
580 | - register_widget( "WPInv_Subscriptions_Widget" ); |
|
581 | - register_widget( "WPInv_Buy_Item_Widget" ); |
|
582 | - register_widget( "WPInv_Messages_Widget" ); |
|
583 | - register_widget( 'WPInv_GetPaid_Widget' ); |
|
577 | + register_widget("WPInv_Checkout_Widget"); |
|
578 | + register_widget("WPInv_History_Widget"); |
|
579 | + register_widget("WPInv_Receipt_Widget"); |
|
580 | + register_widget("WPInv_Subscriptions_Widget"); |
|
581 | + register_widget("WPInv_Buy_Item_Widget"); |
|
582 | + register_widget("WPInv_Messages_Widget"); |
|
583 | + register_widget('WPInv_GetPaid_Widget'); |
|
584 | 584 | } |
585 | 585 | |
586 | 586 | /** |
@@ -589,10 +589,10 @@ discard block |
||
589 | 589 | * @since 1.0.19 |
590 | 590 | * @param int[] $excluded_posts_ids |
591 | 591 | */ |
592 | - public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){ |
|
592 | + public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) { |
|
593 | 593 | |
594 | 594 | // Ensure that we have an array. |
595 | - if ( ! is_array( $excluded_posts_ids ) ) { |
|
595 | + if (!is_array($excluded_posts_ids)) { |
|
596 | 596 | $excluded_posts_ids = array(); |
597 | 597 | } |
598 | 598 | |
@@ -600,24 +600,24 @@ discard block |
||
600 | 600 | $our_pages = array(); |
601 | 601 | |
602 | 602 | // Checkout page. |
603 | - $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
603 | + $our_pages[] = wpinv_get_option('checkout_page', false); |
|
604 | 604 | |
605 | 605 | // Success page. |
606 | - $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
606 | + $our_pages[] = wpinv_get_option('success_page', false); |
|
607 | 607 | |
608 | 608 | // Failure page. |
609 | - $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
609 | + $our_pages[] = wpinv_get_option('failure_page', false); |
|
610 | 610 | |
611 | 611 | // History page. |
612 | - $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
612 | + $our_pages[] = wpinv_get_option('invoice_history_page', false); |
|
613 | 613 | |
614 | 614 | // Subscriptions page. |
615 | - $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
615 | + $our_pages[] = wpinv_get_option('invoice_subscription_page', false); |
|
616 | 616 | |
617 | - $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
617 | + $our_pages = array_map('intval', array_filter($our_pages)); |
|
618 | 618 | |
619 | 619 | $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
620 | - return array_unique( $excluded_posts_ids ); |
|
620 | + return array_unique($excluded_posts_ids); |
|
621 | 621 | |
622 | 622 | } |
623 | 623 |
@@ -14,70 +14,70 @@ discard block |
||
14 | 14 | class WPInv_Ajax { |
15 | 15 | |
16 | 16 | /** |
17 | - * Hook in ajax handlers. |
|
18 | - */ |
|
19 | - public static function init() { |
|
20 | - add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 ); |
|
21 | - add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 ); |
|
22 | - self::add_ajax_events(); |
|
17 | + * Hook in ajax handlers. |
|
18 | + */ |
|
19 | + public static function init() { |
|
20 | + add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 ); |
|
21 | + add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 ); |
|
22 | + self::add_ajax_events(); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
26 | - * Set GetPaid AJAX constant and headers. |
|
27 | - */ |
|
28 | - public static function define_ajax() { |
|
29 | - |
|
30 | - if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
31 | - getpaid_maybe_define_constant( 'DOING_AJAX', true ); |
|
32 | - getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true ); |
|
33 | - if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) { |
|
34 | - /** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 ); |
|
35 | - } |
|
36 | - $GLOBALS['wpdb']->hide_errors(); |
|
37 | - } |
|
26 | + * Set GetPaid AJAX constant and headers. |
|
27 | + */ |
|
28 | + public static function define_ajax() { |
|
29 | + |
|
30 | + if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
31 | + getpaid_maybe_define_constant( 'DOING_AJAX', true ); |
|
32 | + getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true ); |
|
33 | + if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) { |
|
34 | + /** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 ); |
|
35 | + } |
|
36 | + $GLOBALS['wpdb']->hide_errors(); |
|
37 | + } |
|
38 | 38 | |
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
42 | - * Send headers for GetPaid Ajax Requests. |
|
43 | - * |
|
44 | - * @since 1.0.18 |
|
45 | - */ |
|
46 | - private static function wpinv_ajax_headers() { |
|
47 | - if ( ! headers_sent() ) { |
|
48 | - send_origin_headers(); |
|
49 | - send_nosniff_header(); |
|
50 | - nocache_headers(); |
|
51 | - header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
52 | - header( 'X-Robots-Tag: noindex' ); |
|
53 | - status_header( 200 ); |
|
54 | - } |
|
42 | + * Send headers for GetPaid Ajax Requests. |
|
43 | + * |
|
44 | + * @since 1.0.18 |
|
45 | + */ |
|
46 | + private static function wpinv_ajax_headers() { |
|
47 | + if ( ! headers_sent() ) { |
|
48 | + send_origin_headers(); |
|
49 | + send_nosniff_header(); |
|
50 | + nocache_headers(); |
|
51 | + header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
52 | + header( 'X-Robots-Tag: noindex' ); |
|
53 | + status_header( 200 ); |
|
54 | + } |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
58 | - * Check for GetPaid Ajax request and fire action. |
|
59 | - */ |
|
60 | - public static function do_wpinv_ajax() { |
|
61 | - global $wp_query; |
|
58 | + * Check for GetPaid Ajax request and fire action. |
|
59 | + */ |
|
60 | + public static function do_wpinv_ajax() { |
|
61 | + global $wp_query; |
|
62 | 62 | |
63 | - if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
64 | - $wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) ); |
|
65 | - } |
|
63 | + if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
64 | + $wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) ); |
|
65 | + } |
|
66 | 66 | |
67 | - $action = $wp_query->get( 'wpinv-ajax' ); |
|
67 | + $action = $wp_query->get( 'wpinv-ajax' ); |
|
68 | 68 | |
69 | - if ( $action ) { |
|
70 | - self::wpinv_ajax_headers(); |
|
71 | - $action = sanitize_text_field( $action ); |
|
72 | - do_action( 'wpinv_ajax_' . $action ); |
|
73 | - wp_die(); |
|
74 | - } |
|
69 | + if ( $action ) { |
|
70 | + self::wpinv_ajax_headers(); |
|
71 | + $action = sanitize_text_field( $action ); |
|
72 | + do_action( 'wpinv_ajax_' . $action ); |
|
73 | + wp_die(); |
|
74 | + } |
|
75 | 75 | |
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
79 | - * Hook in ajax methods. |
|
80 | - */ |
|
79 | + * Hook in ajax methods. |
|
80 | + */ |
|
81 | 81 | public static function add_ajax_events() { |
82 | 82 | |
83 | 83 | // array( 'event' => is_frontend ) |
@@ -577,24 +577,24 @@ discard block |
||
577 | 577 | } |
578 | 578 | |
579 | 579 | // Is the request set up correctly? |
580 | - if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) { |
|
581 | - echo aui()->alert( |
|
582 | - array( |
|
583 | - 'type' => 'warning', |
|
584 | - 'content' => __( 'No payment form or item provided', 'invoicing' ), |
|
585 | - ) |
|
580 | + if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) { |
|
581 | + echo aui()->alert( |
|
582 | + array( |
|
583 | + 'type' => 'warning', |
|
584 | + 'content' => __( 'No payment form or item provided', 'invoicing' ), |
|
585 | + ) |
|
586 | 586 | ); |
587 | 587 | exit; |
588 | 588 | } |
589 | 589 | |
590 | 590 | // Payment form or button? |
591 | - if ( ! empty( $_GET['form'] ) ) { |
|
591 | + if ( ! empty( $_GET['form'] ) ) { |
|
592 | 592 | echo getpaid_display_payment_form( $_GET['form'] ); |
593 | - } else if( $_GET['invoice'] ) { |
|
594 | - echo getpaid_display_invoice_payment_form( $_GET['invoice'] ); |
|
593 | + } else if( $_GET['invoice'] ) { |
|
594 | + echo getpaid_display_invoice_payment_form( $_GET['invoice'] ); |
|
595 | 595 | } else { |
596 | - $items = getpaid_convert_items_to_array( $_GET['item'] ); |
|
597 | - echo getpaid_display_item_payment_form( $items ); |
|
596 | + $items = getpaid_convert_items_to_array( $_GET['item'] ); |
|
597 | + echo getpaid_display_item_payment_form( $items ); |
|
598 | 598 | } |
599 | 599 | |
600 | 600 | exit; |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * WPInv_Ajax class. |
@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | * Hook in ajax handlers. |
18 | 18 | */ |
19 | 19 | public static function init() { |
20 | - add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 ); |
|
21 | - add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 ); |
|
20 | + add_action('init', array(__CLASS__, 'define_ajax'), 0); |
|
21 | + add_action('template_redirect', array(__CLASS__, 'do_wpinv_ajax'), 0); |
|
22 | 22 | self::add_ajax_events(); |
23 | 23 | } |
24 | 24 | |
@@ -27,11 +27,11 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public static function define_ajax() { |
29 | 29 | |
30 | - if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
31 | - getpaid_maybe_define_constant( 'DOING_AJAX', true ); |
|
32 | - getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true ); |
|
33 | - if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) { |
|
34 | - /** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 ); |
|
30 | + if (!empty($_GET['wpinv-ajax'])) { |
|
31 | + getpaid_maybe_define_constant('DOING_AJAX', true); |
|
32 | + getpaid_maybe_define_constant('WPInv_DOING_AJAX', true); |
|
33 | + if (!WP_DEBUG || (WP_DEBUG && !WP_DEBUG_DISPLAY)) { |
|
34 | + /** @scrutinizer ignore-unhandled */ @ini_set('display_errors', 0); |
|
35 | 35 | } |
36 | 36 | $GLOBALS['wpdb']->hide_errors(); |
37 | 37 | } |
@@ -44,13 +44,13 @@ discard block |
||
44 | 44 | * @since 1.0.18 |
45 | 45 | */ |
46 | 46 | private static function wpinv_ajax_headers() { |
47 | - if ( ! headers_sent() ) { |
|
47 | + if (!headers_sent()) { |
|
48 | 48 | send_origin_headers(); |
49 | 49 | send_nosniff_header(); |
50 | 50 | nocache_headers(); |
51 | - header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
52 | - header( 'X-Robots-Tag: noindex' ); |
|
53 | - status_header( 200 ); |
|
51 | + header('Content-Type: text/html; charset=' . get_option('blog_charset')); |
|
52 | + header('X-Robots-Tag: noindex'); |
|
53 | + status_header(200); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
@@ -60,16 +60,16 @@ discard block |
||
60 | 60 | public static function do_wpinv_ajax() { |
61 | 61 | global $wp_query; |
62 | 62 | |
63 | - if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
64 | - $wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) ); |
|
63 | + if (!empty($_GET['wpinv-ajax'])) { |
|
64 | + $wp_query->set('wpinv-ajax', sanitize_text_field(wp_unslash($_GET['wpinv-ajax']))); |
|
65 | 65 | } |
66 | 66 | |
67 | - $action = $wp_query->get( 'wpinv-ajax' ); |
|
67 | + $action = $wp_query->get('wpinv-ajax'); |
|
68 | 68 | |
69 | - if ( $action ) { |
|
69 | + if ($action) { |
|
70 | 70 | self::wpinv_ajax_headers(); |
71 | - $action = sanitize_text_field( $action ); |
|
72 | - do_action( 'wpinv_ajax_' . $action ); |
|
71 | + $action = sanitize_text_field($action); |
|
72 | + do_action('wpinv_ajax_' . $action); |
|
73 | 73 | wp_die(); |
74 | 74 | } |
75 | 75 | |
@@ -108,36 +108,36 @@ discard block |
||
108 | 108 | 'payment_form_refresh_prices' => true, |
109 | 109 | ); |
110 | 110 | |
111 | - foreach ( $ajax_events as $ajax_event => $nopriv ) { |
|
112 | - add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
113 | - add_action( 'wp_ajax_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
111 | + foreach ($ajax_events as $ajax_event => $nopriv) { |
|
112 | + add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
113 | + add_action('wp_ajax_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
114 | 114 | |
115 | - if ( $nopriv ) { |
|
116 | - add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
117 | - add_action( 'wp_ajax_nopriv_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
118 | - add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
115 | + if ($nopriv) { |
|
116 | + add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
117 | + add_action('wp_ajax_nopriv_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
118 | + add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
119 | 119 | } |
120 | 120 | } |
121 | 121 | } |
122 | 122 | |
123 | 123 | public static function add_note() { |
124 | - check_ajax_referer( 'add-invoice-note', '_nonce' ); |
|
124 | + check_ajax_referer('add-invoice-note', '_nonce'); |
|
125 | 125 | |
126 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
126 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
127 | 127 | die(-1); |
128 | 128 | } |
129 | 129 | |
130 | - $post_id = absint( $_POST['post_id'] ); |
|
131 | - $note = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) ); |
|
132 | - $note_type = sanitize_text_field( $_POST['note_type'] ); |
|
130 | + $post_id = absint($_POST['post_id']); |
|
131 | + $note = wp_kses_post(trim(stripslashes($_POST['note']))); |
|
132 | + $note_type = sanitize_text_field($_POST['note_type']); |
|
133 | 133 | |
134 | 134 | $is_customer_note = $note_type == 'customer' ? 1 : 0; |
135 | 135 | |
136 | - if ( $post_id > 0 ) { |
|
137 | - $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note ); |
|
136 | + if ($post_id > 0) { |
|
137 | + $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note); |
|
138 | 138 | |
139 | - if ( $note_id > 0 && !is_wp_error( $note_id ) ) { |
|
140 | - wpinv_get_invoice_note_line_item( $note_id ); |
|
139 | + if ($note_id > 0 && !is_wp_error($note_id)) { |
|
140 | + wpinv_get_invoice_note_line_item($note_id); |
|
141 | 141 | } |
142 | 142 | } |
143 | 143 | |
@@ -145,16 +145,16 @@ discard block |
||
145 | 145 | } |
146 | 146 | |
147 | 147 | public static function delete_note() { |
148 | - check_ajax_referer( 'delete-invoice-note', '_nonce' ); |
|
148 | + check_ajax_referer('delete-invoice-note', '_nonce'); |
|
149 | 149 | |
150 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
150 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
151 | 151 | die(-1); |
152 | 152 | } |
153 | 153 | |
154 | - $note_id = (int)$_POST['note_id']; |
|
154 | + $note_id = (int) $_POST['note_id']; |
|
155 | 155 | |
156 | - if ( $note_id > 0 ) { |
|
157 | - wp_delete_comment( $note_id, true ); |
|
156 | + if ($note_id > 0) { |
|
157 | + wp_delete_comment($note_id, true); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | die(); |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | } |
168 | 168 | |
169 | 169 | public static function checkout() { |
170 | - if ( ! defined( 'WPINV_CHECKOUT' ) ) { |
|
171 | - define( 'WPINV_CHECKOUT', true ); |
|
170 | + if (!defined('WPINV_CHECKOUT')) { |
|
171 | + define('WPINV_CHECKOUT', true); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | wpinv_process_checkout(); |
@@ -179,34 +179,34 @@ discard block |
||
179 | 179 | public static function remove_invoice_item() { |
180 | 180 | global $wpi_userID, $wpinv_ip_address_country; |
181 | 181 | |
182 | - check_ajax_referer( 'invoice-item', '_nonce' ); |
|
183 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
182 | + check_ajax_referer('invoice-item', '_nonce'); |
|
183 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
184 | 184 | die(-1); |
185 | 185 | } |
186 | 186 | |
187 | - $item_id = sanitize_text_field( $_POST['item_id'] ); |
|
188 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
189 | - $cart_index = isset( $_POST['index'] ) && $_POST['index'] >= 0 ? $_POST['index'] : false; |
|
187 | + $item_id = sanitize_text_field($_POST['item_id']); |
|
188 | + $invoice_id = absint($_POST['invoice_id']); |
|
189 | + $cart_index = isset($_POST['index']) && $_POST['index'] >= 0 ? $_POST['index'] : false; |
|
190 | 190 | |
191 | - if ( !is_numeric( $invoice_id ) || !is_numeric( $item_id ) ) { |
|
191 | + if (!is_numeric($invoice_id) || !is_numeric($item_id)) { |
|
192 | 192 | die(); |
193 | 193 | } |
194 | 194 | |
195 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
196 | - if ( empty( $invoice ) ) { |
|
195 | + $invoice = wpinv_get_invoice($invoice_id); |
|
196 | + if (empty($invoice)) { |
|
197 | 197 | die(); |
198 | 198 | } |
199 | 199 | |
200 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
200 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
201 | 201 | die(); // Don't allow modify items for paid invoice. |
202 | 202 | } |
203 | 203 | |
204 | - if ( !empty( $_POST['user_id'] ) ) { |
|
205 | - $wpi_userID = absint( $_POST['user_id'] ); |
|
204 | + if (!empty($_POST['user_id'])) { |
|
205 | + $wpi_userID = absint($_POST['user_id']); |
|
206 | 206 | } |
207 | 207 | |
208 | - $item = new WPInv_Item( $item_id ); |
|
209 | - if ( !( !empty( $item ) && $item->post_type == 'wpi_item' ) ) { |
|
208 | + $item = new WPInv_Item($item_id); |
|
209 | + if (!(!empty($item) && $item->post_type == 'wpi_item')) { |
|
210 | 210 | die(); |
211 | 211 | } |
212 | 212 | |
@@ -214,9 +214,9 @@ discard block |
||
214 | 214 | |
215 | 215 | $data = array(); |
216 | 216 | $data['invoice_id'] = $invoice_id; |
217 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
217 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
218 | 218 | |
219 | - wpinv_set_checkout_session( $data ); |
|
219 | + wpinv_set_checkout_session($data); |
|
220 | 220 | |
221 | 221 | $args = array( |
222 | 222 | 'id' => $item_id, |
@@ -224,21 +224,21 @@ discard block |
||
224 | 224 | 'cart_index' => $cart_index |
225 | 225 | ); |
226 | 226 | |
227 | - $invoice->remove_item( $item_id, $args ); |
|
227 | + $invoice->remove_item($item_id, $args); |
|
228 | 228 | $invoice->save(); |
229 | 229 | |
230 | - if ( empty( $_POST['country'] ) ) { |
|
230 | + if (empty($_POST['country'])) { |
|
231 | 231 | $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country(); |
232 | 232 | } |
233 | - if ( empty( $_POST['state'] ) ) { |
|
233 | + if (empty($_POST['state'])) { |
|
234 | 234 | $_POST['state'] = $invoice->state; |
235 | 235 | } |
236 | 236 | |
237 | - $invoice->country = sanitize_text_field( $_POST['country'] ); |
|
238 | - $invoice->state = sanitize_text_field( $_POST['state'] ); |
|
237 | + $invoice->country = sanitize_text_field($_POST['country']); |
|
238 | + $invoice->state = sanitize_text_field($_POST['state']); |
|
239 | 239 | |
240 | - $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) ); |
|
241 | - $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) ); |
|
240 | + $invoice->set('country', sanitize_text_field($_POST['country'])); |
|
241 | + $invoice->set('state', sanitize_text_field($_POST['state'])); |
|
242 | 242 | |
243 | 243 | $wpinv_ip_address_country = $invoice->country; |
244 | 244 | |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | |
247 | 247 | $response = array(); |
248 | 248 | $response['success'] = true; |
249 | - $response['data']['items'] = wpinv_admin_get_line_items( $invoice ); |
|
249 | + $response['data']['items'] = wpinv_admin_get_line_items($invoice); |
|
250 | 250 | $response['data']['subtotal'] = $invoice->get_subtotal(); |
251 | 251 | $response['data']['subtotalf'] = $invoice->get_subtotal(true); |
252 | 252 | $response['data']['tax'] = $invoice->get_tax(); |
@@ -258,55 +258,55 @@ discard block |
||
258 | 258 | |
259 | 259 | wpinv_set_checkout_session($checkout_session); |
260 | 260 | |
261 | - wp_send_json( $response ); |
|
261 | + wp_send_json($response); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | public static function create_invoice_item() { |
265 | - check_ajax_referer( 'invoice-item', '_nonce' ); |
|
266 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
265 | + check_ajax_referer('invoice-item', '_nonce'); |
|
266 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
267 | 267 | die(-1); |
268 | 268 | } |
269 | 269 | |
270 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
270 | + $invoice_id = absint($_POST['invoice_id']); |
|
271 | 271 | |
272 | 272 | // Find the item |
273 | - if ( !is_numeric( $invoice_id ) ) { |
|
273 | + if (!is_numeric($invoice_id)) { |
|
274 | 274 | die(); |
275 | 275 | } |
276 | 276 | |
277 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
278 | - if ( empty( $invoice ) ) { |
|
277 | + $invoice = wpinv_get_invoice($invoice_id); |
|
278 | + if (empty($invoice)) { |
|
279 | 279 | die(); |
280 | 280 | } |
281 | 281 | |
282 | 282 | // Validate item before adding to invoice because recurring item must be paid individually. |
283 | - if ( !empty( $invoice->cart_details ) && $invoice->get_recurring() ) { |
|
283 | + if (!empty($invoice->cart_details) && $invoice->get_recurring()) { |
|
284 | 284 | $response = array(); |
285 | 285 | $response['success'] = false; |
286 | - $response['msg'] = __( 'You can not add item because recurring item must be paid individually!', 'invoicing' ); |
|
287 | - wp_send_json( $response ); |
|
286 | + $response['msg'] = __('You can not add item because recurring item must be paid individually!', 'invoicing'); |
|
287 | + wp_send_json($response); |
|
288 | 288 | } |
289 | 289 | |
290 | - $save_item = wp_unslash( $_POST['_wpinv_quick'] ); |
|
290 | + $save_item = wp_unslash($_POST['_wpinv_quick']); |
|
291 | 291 | |
292 | 292 | $meta = array(); |
293 | 293 | $meta['type'] = !empty($save_item['type']) ? sanitize_text_field($save_item['type']) : 'custom'; |
294 | - $meta['price'] = !empty($save_item['price']) ? wpinv_sanitize_amount( $save_item['price'] ) : 0; |
|
294 | + $meta['price'] = !empty($save_item['price']) ? wpinv_sanitize_amount($save_item['price']) : 0; |
|
295 | 295 | $meta['vat_rule'] = !empty($save_item['vat_rule']) ? sanitize_text_field($save_item['vat_rule']) : 'digital'; |
296 | 296 | $meta['vat_class'] = !empty($save_item['vat_class']) ? sanitize_text_field($save_item['vat_class']) : '_standard'; |
297 | 297 | |
298 | 298 | $data = array(); |
299 | 299 | $data['post_title'] = sanitize_text_field($save_item['name']); |
300 | 300 | $data['post_status'] = 'publish'; |
301 | - $data['post_excerpt'] = ! empty( $save_item['excerpt'] ) ? wp_kses_post( $save_item['excerpt'] ) : ''; |
|
301 | + $data['post_excerpt'] = !empty($save_item['excerpt']) ? wp_kses_post($save_item['excerpt']) : ''; |
|
302 | 302 | $data['meta'] = $meta; |
303 | 303 | |
304 | 304 | $item = new WPInv_Item(); |
305 | - $item->create( $data ); |
|
305 | + $item->create($data); |
|
306 | 306 | |
307 | - if ( !empty( $item ) ) { |
|
307 | + if (!empty($item)) { |
|
308 | 308 | $_POST['item_id'] = $item->ID; |
309 | - $_POST['qty'] = !empty($save_item['qty']) && $save_item['qty'] > 0 ? (int)$save_item['qty'] : 1; |
|
309 | + $_POST['qty'] = !empty($save_item['qty']) && $save_item['qty'] > 0 ? (int) $save_item['qty'] : 1; |
|
310 | 310 | |
311 | 311 | self::add_invoice_item(); |
312 | 312 | } |
@@ -319,53 +319,53 @@ discard block |
||
319 | 319 | public static function get_billing_details() { |
320 | 320 | |
321 | 321 | // Verify nonce. |
322 | - check_ajax_referer( 'wpinv-nonce' ); |
|
322 | + check_ajax_referer('wpinv-nonce'); |
|
323 | 323 | |
324 | 324 | // Can the user manage the plugin? |
325 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
325 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
326 | 326 | die(-1); |
327 | 327 | } |
328 | 328 | |
329 | 329 | // Do we have a user id? |
330 | 330 | $user_id = $_GET['user_id']; |
331 | 331 | |
332 | - if ( empty( $user_id ) || ! is_numeric( $user_id ) ) { |
|
332 | + if (empty($user_id) || !is_numeric($user_id)) { |
|
333 | 333 | die(-1); |
334 | 334 | } |
335 | 335 | |
336 | 336 | // Fetch the billing details. |
337 | - $billing_details = wpinv_get_user_address( $user_id ); |
|
338 | - $billing_details = apply_filters( 'wpinv_ajax_billing_details', $billing_details, $user_id ); |
|
337 | + $billing_details = wpinv_get_user_address($user_id); |
|
338 | + $billing_details = apply_filters('wpinv_ajax_billing_details', $billing_details, $user_id); |
|
339 | 339 | |
340 | 340 | // unset the user id and email. |
341 | - $to_ignore = array( 'user_id', 'email' ); |
|
341 | + $to_ignore = array('user_id', 'email'); |
|
342 | 342 | |
343 | - foreach ( $to_ignore as $key ) { |
|
344 | - if ( isset( $billing_details[ $key ] ) ) { |
|
345 | - unset( $billing_details[ $key ] ); |
|
343 | + foreach ($to_ignore as $key) { |
|
344 | + if (isset($billing_details[$key])) { |
|
345 | + unset($billing_details[$key]); |
|
346 | 346 | } |
347 | 347 | } |
348 | 348 | |
349 | - wp_send_json_success( $billing_details ); |
|
349 | + wp_send_json_success($billing_details); |
|
350 | 350 | |
351 | 351 | } |
352 | 352 | |
353 | 353 | public static function admin_apply_discount() { |
354 | 354 | global $wpi_userID; |
355 | 355 | |
356 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
357 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
356 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
357 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
358 | 358 | die(-1); |
359 | 359 | } |
360 | 360 | |
361 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
362 | - $discount_code = sanitize_text_field( $_POST['code'] ); |
|
363 | - if ( empty( $invoice_id ) || empty( $discount_code ) ) { |
|
361 | + $invoice_id = absint($_POST['invoice_id']); |
|
362 | + $discount_code = sanitize_text_field($_POST['code']); |
|
363 | + if (empty($invoice_id) || empty($discount_code)) { |
|
364 | 364 | die(); |
365 | 365 | } |
366 | 366 | |
367 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
368 | - if ( empty( $invoice ) || ( !empty( $invoice ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) ) { |
|
367 | + $invoice = wpinv_get_invoice($invoice_id); |
|
368 | + if (empty($invoice) || (!empty($invoice) && ($invoice->is_paid() || $invoice->is_refunded()))) { |
|
369 | 369 | die(); |
370 | 370 | } |
371 | 371 | |
@@ -373,49 +373,49 @@ discard block |
||
373 | 373 | |
374 | 374 | $data = array(); |
375 | 375 | $data['invoice_id'] = $invoice_id; |
376 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
376 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
377 | 377 | |
378 | - wpinv_set_checkout_session( $data ); |
|
378 | + wpinv_set_checkout_session($data); |
|
379 | 379 | |
380 | 380 | $response = array(); |
381 | 381 | $response['success'] = false; |
382 | - $response['msg'] = __( 'This discount is invalid.', 'invoicing' ); |
|
382 | + $response['msg'] = __('This discount is invalid.', 'invoicing'); |
|
383 | 383 | $response['data']['code'] = $discount_code; |
384 | 384 | |
385 | - if ( wpinv_is_discount_valid( $discount_code, $invoice->get_user_id() ) ) { |
|
386 | - $discounts = wpinv_set_cart_discount( $discount_code ); |
|
385 | + if (wpinv_is_discount_valid($discount_code, $invoice->get_user_id())) { |
|
386 | + $discounts = wpinv_set_cart_discount($discount_code); |
|
387 | 387 | |
388 | 388 | $response['success'] = true; |
389 | - $response['msg'] = __( 'Discount has been applied successfully.', 'invoicing' ); |
|
390 | - } else { |
|
389 | + $response['msg'] = __('Discount has been applied successfully.', 'invoicing'); |
|
390 | + } else { |
|
391 | 391 | $errors = wpinv_get_errors(); |
392 | - if ( !empty( $errors['wpinv-discount-error'] ) ) { |
|
392 | + if (!empty($errors['wpinv-discount-error'])) { |
|
393 | 393 | $response['msg'] = $errors['wpinv-discount-error']; |
394 | 394 | } |
395 | - wpinv_unset_error( 'wpinv-discount-error' ); |
|
395 | + wpinv_unset_error('wpinv-discount-error'); |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | wpinv_set_checkout_session($checkout_session); |
399 | 399 | |
400 | - wp_send_json( $response ); |
|
400 | + wp_send_json($response); |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | public static function admin_remove_discount() { |
404 | 404 | global $wpi_userID; |
405 | 405 | |
406 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
407 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
406 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
407 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
408 | 408 | die(-1); |
409 | 409 | } |
410 | 410 | |
411 | - $invoice_id = absint( $_POST['invoice_id'] ); |
|
412 | - $discount_code = sanitize_text_field( $_POST['code'] ); |
|
413 | - if ( empty( $invoice_id ) || empty( $discount_code ) ) { |
|
411 | + $invoice_id = absint($_POST['invoice_id']); |
|
412 | + $discount_code = sanitize_text_field($_POST['code']); |
|
413 | + if (empty($invoice_id) || empty($discount_code)) { |
|
414 | 414 | die(); |
415 | 415 | } |
416 | 416 | |
417 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
418 | - if ( empty( $invoice ) || ( !empty( $invoice ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) ) { |
|
417 | + $invoice = wpinv_get_invoice($invoice_id); |
|
418 | + if (empty($invoice) || (!empty($invoice) && ($invoice->is_paid() || $invoice->is_refunded()))) { |
|
419 | 419 | die(); |
420 | 420 | } |
421 | 421 | |
@@ -423,21 +423,21 @@ discard block |
||
423 | 423 | |
424 | 424 | $data = array(); |
425 | 425 | $data['invoice_id'] = $invoice_id; |
426 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
426 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
427 | 427 | |
428 | - wpinv_set_checkout_session( $data ); |
|
428 | + wpinv_set_checkout_session($data); |
|
429 | 429 | |
430 | 430 | $response = array(); |
431 | 431 | $response['success'] = false; |
432 | 432 | $response['msg'] = NULL; |
433 | 433 | |
434 | - $discounts = wpinv_unset_cart_discount( $discount_code ); |
|
434 | + $discounts = wpinv_unset_cart_discount($discount_code); |
|
435 | 435 | $response['success'] = true; |
436 | - $response['msg'] = __( 'Discount has been removed successfully.', 'invoicing' ); |
|
436 | + $response['msg'] = __('Discount has been removed successfully.', 'invoicing'); |
|
437 | 437 | |
438 | 438 | wpinv_set_checkout_session($checkout_session); |
439 | 439 | |
440 | - wp_send_json( $response ); |
|
440 | + wp_send_json($response); |
|
441 | 441 | } |
442 | 442 | |
443 | 443 | /** |
@@ -446,80 +446,80 @@ discard block |
||
446 | 446 | public static function check_new_user_email() { |
447 | 447 | |
448 | 448 | // Verify nonce. |
449 | - check_ajax_referer( 'wpinv-nonce' ); |
|
449 | + check_ajax_referer('wpinv-nonce'); |
|
450 | 450 | |
451 | 451 | // Can the user manage the plugin? |
452 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
452 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
453 | 453 | die(-1); |
454 | 454 | } |
455 | 455 | |
456 | 456 | // We need an email address. |
457 | - if ( empty( $_GET['email'] ) ) { |
|
458 | - _e( "Provide the new user's email address", 'invoicing' ); |
|
457 | + if (empty($_GET['email'])) { |
|
458 | + _e("Provide the new user's email address", 'invoicing'); |
|
459 | 459 | exit; |
460 | 460 | } |
461 | 461 | |
462 | 462 | // Ensure the email is valid. |
463 | - $email = sanitize_text_field( $_GET['email'] ); |
|
464 | - if ( ! is_email( $email ) ) { |
|
465 | - _e( 'Invalid email address', 'invoicing' ); |
|
463 | + $email = sanitize_text_field($_GET['email']); |
|
464 | + if (!is_email($email)) { |
|
465 | + _e('Invalid email address', 'invoicing'); |
|
466 | 466 | exit; |
467 | 467 | } |
468 | 468 | |
469 | 469 | // And it does not exist. |
470 | - if ( email_exists( $email ) ) { |
|
471 | - _e( 'A user with this email address already exists', 'invoicing' ); |
|
470 | + if (email_exists($email)) { |
|
471 | + _e('A user with this email address already exists', 'invoicing'); |
|
472 | 472 | exit; |
473 | 473 | } |
474 | 474 | |
475 | - wp_send_json_success( true ); |
|
475 | + wp_send_json_success(true); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | public static function run_tool() { |
479 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
480 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
479 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
480 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
481 | 481 | die(-1); |
482 | 482 | } |
483 | 483 | |
484 | - $tool = sanitize_text_field( $_POST['tool'] ); |
|
484 | + $tool = sanitize_text_field($_POST['tool']); |
|
485 | 485 | |
486 | - do_action( 'wpinv_run_tool' ); |
|
486 | + do_action('wpinv_run_tool'); |
|
487 | 487 | |
488 | - if ( !empty( $tool ) ) { |
|
489 | - do_action( 'wpinv_tool_' . $tool ); |
|
488 | + if (!empty($tool)) { |
|
489 | + do_action('wpinv_tool_' . $tool); |
|
490 | 490 | } |
491 | 491 | } |
492 | 492 | |
493 | 493 | public static function apply_discount() { |
494 | 494 | global $wpi_userID; |
495 | 495 | |
496 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
496 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
497 | 497 | |
498 | 498 | $response = array(); |
499 | 499 | |
500 | - if ( isset( $_POST['code'] ) ) { |
|
501 | - $discount_code = sanitize_text_field( $_POST['code'] ); |
|
500 | + if (isset($_POST['code'])) { |
|
501 | + $discount_code = sanitize_text_field($_POST['code']); |
|
502 | 502 | |
503 | 503 | $response['success'] = false; |
504 | 504 | $response['msg'] = ''; |
505 | 505 | $response['data']['code'] = $discount_code; |
506 | 506 | |
507 | 507 | $invoice = wpinv_get_invoice_cart(); |
508 | - if ( empty( $invoice->ID ) ) { |
|
509 | - $response['msg'] = __( 'Invalid checkout request.', 'invoicing' ); |
|
510 | - wp_send_json( $response ); |
|
508 | + if (empty($invoice->ID)) { |
|
509 | + $response['msg'] = __('Invalid checkout request.', 'invoicing'); |
|
510 | + wp_send_json($response); |
|
511 | 511 | } |
512 | 512 | |
513 | 513 | $wpi_userID = $invoice->get_user_id(); |
514 | 514 | |
515 | - if ( wpinv_is_discount_valid( $discount_code, $wpi_userID ) ) { |
|
516 | - $discount = wpinv_get_discount_by_code( $discount_code ); |
|
517 | - $discounts = wpinv_set_cart_discount( $discount_code ); |
|
518 | - $amount = wpinv_format_discount_rate( wpinv_get_discount_type( $discount->ID ), wpinv_get_discount_amount( $discount->ID ) ); |
|
519 | - $total = wpinv_get_cart_total( null, $discounts ); |
|
520 | - $cart_totals = wpinv_recalculate_tax( true ); |
|
515 | + if (wpinv_is_discount_valid($discount_code, $wpi_userID)) { |
|
516 | + $discount = wpinv_get_discount_by_code($discount_code); |
|
517 | + $discounts = wpinv_set_cart_discount($discount_code); |
|
518 | + $amount = wpinv_format_discount_rate(wpinv_get_discount_type($discount->ID), wpinv_get_discount_amount($discount->ID)); |
|
519 | + $total = wpinv_get_cart_total(null, $discounts); |
|
520 | + $cart_totals = wpinv_recalculate_tax(true); |
|
521 | 521 | |
522 | - if ( !empty( $cart_totals ) ) { |
|
522 | + if (!empty($cart_totals)) { |
|
523 | 523 | $response['success'] = true; |
524 | 524 | $response['data'] = $cart_totals; |
525 | 525 | $response['data']['code'] = $discount_code; |
@@ -528,29 +528,29 @@ discard block |
||
528 | 528 | } |
529 | 529 | } else { |
530 | 530 | $errors = wpinv_get_errors(); |
531 | - $response['msg'] = $errors['wpinv-discount-error']; |
|
532 | - wpinv_unset_error( 'wpinv-discount-error' ); |
|
531 | + $response['msg'] = $errors['wpinv-discount-error']; |
|
532 | + wpinv_unset_error('wpinv-discount-error'); |
|
533 | 533 | } |
534 | 534 | |
535 | 535 | // Allow for custom discount code handling |
536 | - $response = apply_filters( 'wpinv_ajax_discount_response', $response ); |
|
536 | + $response = apply_filters('wpinv_ajax_discount_response', $response); |
|
537 | 537 | } |
538 | 538 | |
539 | - wp_send_json( $response ); |
|
539 | + wp_send_json($response); |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | public static function remove_discount() { |
543 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
543 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
544 | 544 | |
545 | 545 | $response = array(); |
546 | 546 | |
547 | - if ( isset( $_POST['code'] ) ) { |
|
548 | - $discount_code = sanitize_text_field( $_POST['code'] ); |
|
549 | - $discounts = wpinv_unset_cart_discount( $discount_code ); |
|
550 | - $total = wpinv_get_cart_total( null, $discounts ); |
|
551 | - $cart_totals = wpinv_recalculate_tax( true ); |
|
547 | + if (isset($_POST['code'])) { |
|
548 | + $discount_code = sanitize_text_field($_POST['code']); |
|
549 | + $discounts = wpinv_unset_cart_discount($discount_code); |
|
550 | + $total = wpinv_get_cart_total(null, $discounts); |
|
551 | + $cart_totals = wpinv_recalculate_tax(true); |
|
552 | 552 | |
553 | - if ( !empty( $cart_totals ) ) { |
|
553 | + if (!empty($cart_totals)) { |
|
554 | 554 | $response['success'] = true; |
555 | 555 | $response['data'] = $cart_totals; |
556 | 556 | $response['data']['code'] = $discount_code; |
@@ -559,10 +559,10 @@ discard block |
||
559 | 559 | } |
560 | 560 | |
561 | 561 | // Allow for custom discount code handling |
562 | - $response = apply_filters( 'wpinv_ajax_discount_response', $response ); |
|
562 | + $response = apply_filters('wpinv_ajax_discount_response', $response); |
|
563 | 563 | } |
564 | 564 | |
565 | - wp_send_json( $response ); |
|
565 | + wp_send_json($response); |
|
566 | 566 | } |
567 | 567 | |
568 | 568 | /** |
@@ -571,30 +571,30 @@ discard block |
||
571 | 571 | public static function get_payment_form() { |
572 | 572 | |
573 | 573 | // Check nonce. |
574 | - if ( ! isset( $_GET['nonce'] ) || ! wp_verify_nonce( $_GET['nonce'], 'getpaid_ajax_form' ) ) { |
|
575 | - _e( 'Error: Reload the page and try again.', 'invoicing' ); |
|
574 | + if (!isset($_GET['nonce']) || !wp_verify_nonce($_GET['nonce'], 'getpaid_ajax_form')) { |
|
575 | + _e('Error: Reload the page and try again.', 'invoicing'); |
|
576 | 576 | exit; |
577 | 577 | } |
578 | 578 | |
579 | 579 | // Is the request set up correctly? |
580 | - if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) { |
|
580 | + if (empty($_GET['form']) && empty($_GET['item'])) { |
|
581 | 581 | echo aui()->alert( |
582 | 582 | array( |
583 | 583 | 'type' => 'warning', |
584 | - 'content' => __( 'No payment form or item provided', 'invoicing' ), |
|
584 | + 'content' => __('No payment form or item provided', 'invoicing'), |
|
585 | 585 | ) |
586 | 586 | ); |
587 | 587 | exit; |
588 | 588 | } |
589 | 589 | |
590 | 590 | // Payment form or button? |
591 | - if ( ! empty( $_GET['form'] ) ) { |
|
592 | - echo getpaid_display_payment_form( $_GET['form'] ); |
|
593 | - } else if( $_GET['invoice'] ) { |
|
594 | - echo getpaid_display_invoice_payment_form( $_GET['invoice'] ); |
|
591 | + if (!empty($_GET['form'])) { |
|
592 | + echo getpaid_display_payment_form($_GET['form']); |
|
593 | + } else if ($_GET['invoice']) { |
|
594 | + echo getpaid_display_invoice_payment_form($_GET['invoice']); |
|
595 | 595 | } else { |
596 | - $items = getpaid_convert_items_to_array( $_GET['item'] ); |
|
597 | - echo getpaid_display_item_payment_form( $items ); |
|
596 | + $items = getpaid_convert_items_to_array($_GET['item']); |
|
597 | + echo getpaid_display_item_payment_form($items); |
|
598 | 598 | } |
599 | 599 | |
600 | 600 | exit; |
@@ -610,11 +610,11 @@ discard block |
||
610 | 610 | global $invoicing, $wpi_checkout_id, $cart_total; |
611 | 611 | |
612 | 612 | // Check nonce. |
613 | - check_ajax_referer( 'getpaid_form_nonce' ); |
|
613 | + check_ajax_referer('getpaid_form_nonce'); |
|
614 | 614 | |
615 | 615 | // ... form fields... |
616 | - if ( empty( $_POST['getpaid_payment_form_submission'] ) ) { |
|
617 | - _e( 'Error: Reload the page and try again.', 'invoicing' ); |
|
616 | + if (empty($_POST['getpaid_payment_form_submission'])) { |
|
617 | + _e('Error: Reload the page and try again.', 'invoicing'); |
|
618 | 618 | exit; |
619 | 619 | } |
620 | 620 | |
@@ -622,25 +622,25 @@ discard block |
||
622 | 622 | $submission = new GetPaid_Payment_Form_Submission(); |
623 | 623 | |
624 | 624 | // Do we have an error? |
625 | - if ( ! empty( $submission->last_error ) ) { |
|
625 | + if (!empty($submission->last_error)) { |
|
626 | 626 | echo $submission->last_error; |
627 | 627 | exit; |
628 | 628 | } |
629 | 629 | |
630 | 630 | // We need a billing email. |
631 | - if ( ! $submission->has_billing_email() || ! is_email( $submission->get_billing_email() ) ) { |
|
632 | - wp_send_json_error( __( 'Provide a valid billing email.', 'invoicing' ) ); |
|
631 | + if (!$submission->has_billing_email() || !is_email($submission->get_billing_email())) { |
|
632 | + wp_send_json_error(__('Provide a valid billing email.', 'invoicing')); |
|
633 | 633 | } |
634 | 634 | |
635 | 635 | // Prepare items. |
636 | 636 | $items = $submission->get_items(); |
637 | 637 | $prepared_items = array(); |
638 | 638 | |
639 | - if ( ! empty( $items ) ) { |
|
639 | + if (!empty($items)) { |
|
640 | 640 | |
641 | - foreach( $items as $item_id => $item ) { |
|
641 | + foreach ($items as $item_id => $item) { |
|
642 | 642 | |
643 | - if ( $item->can_purchase() ) { |
|
643 | + if ($item->can_purchase()) { |
|
644 | 644 | $prepared_items[] = array( |
645 | 645 | 'id' => $item_id, |
646 | 646 | 'item_price' => $item->get_price(), |
@@ -654,90 +654,90 @@ discard block |
||
654 | 654 | |
655 | 655 | } |
656 | 656 | |
657 | - if ( empty( $prepared_items ) ) { |
|
658 | - wp_send_json_error( __( 'You have not selected any items.', 'invoicing' ) ); |
|
657 | + if (empty($prepared_items)) { |
|
658 | + wp_send_json_error(__('You have not selected any items.', 'invoicing')); |
|
659 | 659 | } |
660 | 660 | |
661 | - if ( $submission->has_recurring && 1 != count( $prepared_items ) ) { |
|
662 | - wp_send_json_error( __( 'Recurring items should be bought individually.', 'invoicing' ) ); |
|
661 | + if ($submission->has_recurring && 1 != count($prepared_items)) { |
|
662 | + wp_send_json_error(__('Recurring items should be bought individually.', 'invoicing')); |
|
663 | 663 | } |
664 | 664 | |
665 | 665 | // Prepare the submission details. |
666 | 666 | $prepared = array( |
667 | - 'billing_email' => sanitize_email( $submission->get_billing_email() ), |
|
668 | - __( 'Billing Email', 'invoicing' ) => sanitize_email( $submission->get_billing_email() ), |
|
669 | - __( 'Form Id', 'invoicing' ) => absint( $submission->payment_form->get_id() ), |
|
667 | + 'billing_email' => sanitize_email($submission->get_billing_email()), |
|
668 | + __('Billing Email', 'invoicing') => sanitize_email($submission->get_billing_email()), |
|
669 | + __('Form Id', 'invoicing') => absint($submission->payment_form->get_id()), |
|
670 | 670 | ); |
671 | 671 | |
672 | 672 | // Address fields. |
673 | 673 | $address_fields = array(); |
674 | 674 | |
675 | 675 | // Add discount code. |
676 | - if ( $submission->has_discount_code() ) { |
|
677 | - $address_fields['discount'] = array( $submission->get_discount_code() ); |
|
676 | + if ($submission->has_discount_code()) { |
|
677 | + $address_fields['discount'] = array($submission->get_discount_code()); |
|
678 | 678 | } |
679 | 679 | |
680 | 680 | // Are all required fields provided? |
681 | 681 | $data = $submission->get_data(); |
682 | 682 | |
683 | - foreach ( $submission->payment_form->get_elements() as $field ) { |
|
683 | + foreach ($submission->payment_form->get_elements() as $field) { |
|
684 | 684 | |
685 | - if ( ! empty( $field['premade'] ) ) { |
|
685 | + if (!empty($field['premade'])) { |
|
686 | 686 | continue; |
687 | 687 | } |
688 | 688 | |
689 | - if ( ! $submission->is_required_field_set( $field ) ) { |
|
690 | - wp_send_json_error( __( 'Fill all required fields.', 'invoicing' ) ); |
|
689 | + if (!$submission->is_required_field_set($field)) { |
|
690 | + wp_send_json_error(__('Fill all required fields.', 'invoicing')); |
|
691 | 691 | } |
692 | 692 | |
693 | - if ( $field['type'] == 'address' ) { |
|
693 | + if ($field['type'] == 'address') { |
|
694 | 694 | |
695 | - foreach ( $field['fields'] as $address_field ) { |
|
695 | + foreach ($field['fields'] as $address_field) { |
|
696 | 696 | |
697 | - if ( empty( $address_field['visible'] ) ) { |
|
697 | + if (empty($address_field['visible'])) { |
|
698 | 698 | continue; |
699 | 699 | } |
700 | 700 | |
701 | - if ( ! empty( $address_field['required'] ) && empty( $data[ $address_field['name'] ] ) ) { |
|
702 | - wp_send_json_error( __( 'Some required fields have not been filled.', 'invoicing' ) ); |
|
701 | + if (!empty($address_field['required']) && empty($data[$address_field['name']])) { |
|
702 | + wp_send_json_error(__('Some required fields have not been filled.', 'invoicing')); |
|
703 | 703 | } |
704 | 704 | |
705 | - if ( isset( $data[ $address_field['name'] ] ) ) { |
|
706 | - $label = str_replace( 'wpinv_', '', $address_field['name'] ); |
|
707 | - $address_fields[ $label ] = wpinv_clean( $data[ $address_field['name'] ] ); |
|
705 | + if (isset($data[$address_field['name']])) { |
|
706 | + $label = str_replace('wpinv_', '', $address_field['name']); |
|
707 | + $address_fields[$label] = wpinv_clean($data[$address_field['name']]); |
|
708 | 708 | } |
709 | 709 | |
710 | 710 | } |
711 | 711 | |
712 | - } else if ( isset( $data[ $field['id'] ] ) ) { |
|
712 | + } else if (isset($data[$field['id']])) { |
|
713 | 713 | $label = $field['id']; |
714 | 714 | |
715 | - if ( isset( $field['label'] ) ) { |
|
715 | + if (isset($field['label'])) { |
|
716 | 716 | $label = $field['label']; |
717 | 717 | } |
718 | 718 | |
719 | - $prepared[ wpinv_clean( $label ) ] = wpinv_clean( $data[ $field['id'] ] ); |
|
719 | + $prepared[wpinv_clean($label)] = wpinv_clean($data[$field['id']]); |
|
720 | 720 | } |
721 | 721 | |
722 | 722 | } |
723 | 723 | |
724 | 724 | // (Maybe) create the user. |
725 | - $user = get_user_by( 'email', $prepared['billing_email'] ); |
|
725 | + $user = get_user_by('email', $prepared['billing_email']); |
|
726 | 726 | |
727 | - if ( empty( $user ) ) { |
|
728 | - $user = wpinv_create_user( $prepared['billing_email'] ); |
|
727 | + if (empty($user)) { |
|
728 | + $user = wpinv_create_user($prepared['billing_email']); |
|
729 | 729 | } |
730 | 730 | |
731 | - if ( is_wp_error( $user ) ) { |
|
732 | - wp_send_json_error( $user->get_error_message() ); |
|
731 | + if (is_wp_error($user)) { |
|
732 | + wp_send_json_error($user->get_error_message()); |
|
733 | 733 | } |
734 | 734 | |
735 | - if ( is_numeric( $user ) ) { |
|
736 | - $user = get_user_by( 'id', $user ); |
|
735 | + if (is_numeric($user)) { |
|
736 | + $user = get_user_by('id', $user); |
|
737 | 737 | } |
738 | 738 | |
739 | 739 | // Create the invoice. |
740 | - if ( ! $submission->has_invoice() ) { |
|
740 | + if (!$submission->has_invoice()) { |
|
741 | 741 | |
742 | 742 | $invoice = wpinv_insert_invoice( |
743 | 743 | array( |
@@ -754,8 +754,8 @@ discard block |
||
754 | 754 | |
755 | 755 | $invoice = $submission->get_invoice(); |
756 | 756 | |
757 | - if ( $invoice->is_paid() ) { |
|
758 | - wp_send_json_error( __( 'This invoice has already been paid for.', 'invoicing' ) ); |
|
757 | + if ($invoice->is_paid()) { |
|
758 | + wp_send_json_error(__('This invoice has already been paid for.', 'invoicing')); |
|
759 | 759 | } |
760 | 760 | |
761 | 761 | $invoice = wpinv_update_invoice( |
@@ -770,34 +770,34 @@ discard block |
||
770 | 770 | |
771 | 771 | } |
772 | 772 | |
773 | - if ( is_wp_error( $invoice ) ) { |
|
774 | - wp_send_json_error( $invoice->get_error_message() ); |
|
773 | + if (is_wp_error($invoice)) { |
|
774 | + wp_send_json_error($invoice->get_error_message()); |
|
775 | 775 | } |
776 | 776 | |
777 | - if ( empty( $invoice ) ) { |
|
778 | - wp_send_json_error( __( 'Could not create your invoice.', 'invoicing' ) ); |
|
777 | + if (empty($invoice)) { |
|
778 | + wp_send_json_error(__('Could not create your invoice.', 'invoicing')); |
|
779 | 779 | } |
780 | 780 | |
781 | - unset( $prepared['billing_email'] ); |
|
782 | - update_post_meta( $invoice->ID, 'payment_form_data', $prepared ); |
|
781 | + unset($prepared['billing_email']); |
|
782 | + update_post_meta($invoice->ID, 'payment_form_data', $prepared); |
|
783 | 783 | |
784 | 784 | $wpi_checkout_id = $invoice->ID; |
785 | 785 | $cart_total = wpinv_price( |
786 | 786 | wpinv_format_amount( |
787 | - wpinv_get_cart_total( $invoice->get_cart_details(), NULL, $invoice ) ), |
|
787 | + wpinv_get_cart_total($invoice->get_cart_details(), NULL, $invoice) ), |
|
788 | 788 | $invoice->get_currency() |
789 | 789 | ); |
790 | 790 | |
791 | 791 | $data = array(); |
792 | 792 | $data['invoice_id'] = $invoice->ID; |
793 | - $data['cart_discounts'] = $invoice->get_discounts( true ); |
|
793 | + $data['cart_discounts'] = $invoice->get_discounts(true); |
|
794 | 794 | |
795 | - wpinv_set_checkout_session( $data ); |
|
796 | - add_filter( 'wp_redirect', array( $invoicing->form_elements, 'send_redirect_response' ) ); |
|
797 | - add_action( 'wpinv_pre_send_back_to_checkout', array( $invoicing->form_elements, 'checkout_error' ) ); |
|
795 | + wpinv_set_checkout_session($data); |
|
796 | + add_filter('wp_redirect', array($invoicing->form_elements, 'send_redirect_response')); |
|
797 | + add_action('wpinv_pre_send_back_to_checkout', array($invoicing->form_elements, 'checkout_error')); |
|
798 | 798 | |
799 | - if ( ! defined( 'WPINV_CHECKOUT' ) ) { |
|
800 | - define( 'WPINV_CHECKOUT', true ); |
|
799 | + if (!defined('WPINV_CHECKOUT')) { |
|
800 | + define('WPINV_CHECKOUT', true); |
|
801 | 801 | } |
802 | 802 | |
803 | 803 | wpinv_process_checkout(); |
@@ -815,51 +815,51 @@ discard block |
||
815 | 815 | public static function get_payment_form_states_field() { |
816 | 816 | global $invoicing; |
817 | 817 | |
818 | - if ( empty( $_GET['country'] ) || empty( $_GET['form'] ) ) { |
|
818 | + if (empty($_GET['country']) || empty($_GET['form'])) { |
|
819 | 819 | exit; |
820 | 820 | } |
821 | 821 | |
822 | - $elements = $invoicing->form_elements->get_form_elements( $_GET['form'] ); |
|
822 | + $elements = $invoicing->form_elements->get_form_elements($_GET['form']); |
|
823 | 823 | |
824 | - if ( empty( $elements ) ) { |
|
824 | + if (empty($elements)) { |
|
825 | 825 | exit; |
826 | 826 | } |
827 | 827 | |
828 | 828 | $address_fields = array(); |
829 | - foreach ( $elements as $element ) { |
|
830 | - if ( 'address' === $element['type'] ) { |
|
829 | + foreach ($elements as $element) { |
|
830 | + if ('address' === $element['type']) { |
|
831 | 831 | $address_fields = $element; |
832 | 832 | break; |
833 | 833 | } |
834 | 834 | } |
835 | 835 | |
836 | - if ( empty( $address_fields ) ) { |
|
836 | + if (empty($address_fields)) { |
|
837 | 837 | exit; |
838 | 838 | } |
839 | 839 | |
840 | - foreach( $address_fields['fields'] as $address_field ) { |
|
840 | + foreach ($address_fields['fields'] as $address_field) { |
|
841 | 841 | |
842 | - if ( 'wpinv_state' == $address_field['name'] ) { |
|
842 | + if ('wpinv_state' == $address_field['name']) { |
|
843 | 843 | |
844 | 844 | $label = $address_field['label']; |
845 | 845 | |
846 | - if ( ! empty( $address_field['required'] ) ) { |
|
846 | + if (!empty($address_field['required'])) { |
|
847 | 847 | $label .= "<span class='text-danger'> *</span>"; |
848 | 848 | } |
849 | 849 | |
850 | - $states = wpinv_get_country_states( $_GET['country'] ); |
|
850 | + $states = wpinv_get_country_states($_GET['country']); |
|
851 | 851 | |
852 | - if ( ! empty( $states ) ) { |
|
852 | + if (!empty($states)) { |
|
853 | 853 | |
854 | 854 | $html = aui()->select( |
855 | 855 | array( |
856 | 856 | 'options' => $states, |
857 | - 'name' => esc_attr( $address_field['name'] ), |
|
858 | - 'id' => esc_attr( $address_field['name'] ), |
|
859 | - 'placeholder' => esc_attr( $address_field['placeholder'] ), |
|
857 | + 'name' => esc_attr($address_field['name']), |
|
858 | + 'id' => esc_attr($address_field['name']), |
|
859 | + 'placeholder' => esc_attr($address_field['placeholder']), |
|
860 | 860 | 'required' => (bool) $address_field['required'], |
861 | 861 | 'no_wrap' => true, |
862 | - 'label' => wp_kses_post( $label ), |
|
862 | + 'label' => wp_kses_post($label), |
|
863 | 863 | 'select2' => false, |
864 | 864 | ) |
865 | 865 | ); |
@@ -868,10 +868,10 @@ discard block |
||
868 | 868 | |
869 | 869 | $html = aui()->input( |
870 | 870 | array( |
871 | - 'name' => esc_attr( $address_field['name'] ), |
|
872 | - 'id' => esc_attr( $address_field['name'] ), |
|
871 | + 'name' => esc_attr($address_field['name']), |
|
872 | + 'id' => esc_attr($address_field['name']), |
|
873 | 873 | 'required' => (bool) $address_field['required'], |
874 | - 'label' => wp_kses_post( $label ), |
|
874 | + 'label' => wp_kses_post($label), |
|
875 | 875 | 'no_wrap' => true, |
876 | 876 | 'type' => 'text', |
877 | 877 | ) |
@@ -879,7 +879,7 @@ discard block |
||
879 | 879 | |
880 | 880 | } |
881 | 881 | |
882 | - wp_send_json_success( str_replace( 'sr-only', '', $html ) ); |
|
882 | + wp_send_json_success(str_replace('sr-only', '', $html)); |
|
883 | 883 | exit; |
884 | 884 | |
885 | 885 | } |
@@ -895,49 +895,49 @@ discard block |
||
895 | 895 | public static function recalculate_invoice_totals() { |
896 | 896 | |
897 | 897 | // Verify nonce. |
898 | - check_ajax_referer( 'wpinv-nonce' ); |
|
898 | + check_ajax_referer('wpinv-nonce'); |
|
899 | 899 | |
900 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
900 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
901 | 901 | exit; |
902 | 902 | } |
903 | 903 | |
904 | 904 | // We need an invoice. |
905 | - if ( empty( $_POST['post_id'] ) ) { |
|
905 | + if (empty($_POST['post_id'])) { |
|
906 | 906 | exit; |
907 | 907 | } |
908 | 908 | |
909 | 909 | // Fetch the invoice. |
910 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
910 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
911 | 911 | |
912 | 912 | // Ensure it exists. |
913 | - if ( ! $invoice->get_id() ) { |
|
913 | + if (!$invoice->get_id()) { |
|
914 | 914 | exit; |
915 | 915 | } |
916 | 916 | |
917 | 917 | // Maybe set the country, state, currency. |
918 | - foreach ( array( 'country', 'state', 'currency' ) as $key ) { |
|
919 | - if ( isset( $_POST[ $key ] ) ) { |
|
918 | + foreach (array('country', 'state', 'currency') as $key) { |
|
919 | + if (isset($_POST[$key])) { |
|
920 | 920 | $method = "set_$key"; |
921 | - $invoice->$method( $_POST[ $key ] ); |
|
921 | + $invoice->$method($_POST[$key]); |
|
922 | 922 | } |
923 | 923 | } |
924 | 924 | |
925 | 925 | // Maybe disable taxes. |
926 | - $invoice->set_disable_taxes( ! empty( $_POST['taxes'] ) ); |
|
926 | + $invoice->set_disable_taxes(!empty($_POST['taxes'])); |
|
927 | 927 | |
928 | 928 | // Recalculate totals. |
929 | 929 | $invoice->recalculate_total(); |
930 | 930 | |
931 | 931 | $totals = array( |
932 | - 'subtotal' => wpinv_price( wpinv_format_amount( $invoice->get_subtotal() ) ), |
|
933 | - 'discount' => wpinv_price( wpinv_format_amount( $invoice->get_total_discount() ) ), |
|
934 | - 'tax' => wpinv_price( wpinv_format_amount( $invoice->get_total_tax() ) ), |
|
935 | - 'total' => wpinv_price( wpinv_format_amount( $invoice->get_total() ) ), |
|
932 | + 'subtotal' => wpinv_price(wpinv_format_amount($invoice->get_subtotal())), |
|
933 | + 'discount' => wpinv_price(wpinv_format_amount($invoice->get_total_discount())), |
|
934 | + 'tax' => wpinv_price(wpinv_format_amount($invoice->get_total_tax())), |
|
935 | + 'total' => wpinv_price(wpinv_format_amount($invoice->get_total())), |
|
936 | 936 | ); |
937 | 937 | |
938 | - $totals = apply_filters( 'getpaid_invoice_totals', $totals, $invoice ); |
|
938 | + $totals = apply_filters('getpaid_invoice_totals', $totals, $invoice); |
|
939 | 939 | |
940 | - wp_send_json_success( compact( 'totals' ) ); |
|
940 | + wp_send_json_success(compact('totals')); |
|
941 | 941 | } |
942 | 942 | |
943 | 943 | /** |
@@ -946,33 +946,33 @@ discard block |
||
946 | 946 | public static function get_invoice_items() { |
947 | 947 | |
948 | 948 | // Verify nonce. |
949 | - check_ajax_referer( 'wpinv-nonce' ); |
|
949 | + check_ajax_referer('wpinv-nonce'); |
|
950 | 950 | |
951 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
951 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
952 | 952 | exit; |
953 | 953 | } |
954 | 954 | |
955 | 955 | // We need an invoice and items. |
956 | - if ( empty( $_POST['post_id'] ) ) { |
|
956 | + if (empty($_POST['post_id'])) { |
|
957 | 957 | exit; |
958 | 958 | } |
959 | 959 | |
960 | 960 | // Fetch the invoice. |
961 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
961 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
962 | 962 | |
963 | 963 | // Ensure it exists. |
964 | - if ( ! $invoice->get_id() ) { |
|
964 | + if (!$invoice->get_id()) { |
|
965 | 965 | exit; |
966 | 966 | } |
967 | 967 | |
968 | 968 | // Return an array of invoice items. |
969 | 969 | $items = array(); |
970 | 970 | |
971 | - foreach ( $invoice->get_items() as $item_id => $item ) { |
|
972 | - $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax(); |
|
971 | + foreach ($invoice->get_items() as $item_id => $item) { |
|
972 | + $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax(); |
|
973 | 973 | } |
974 | 974 | |
975 | - wp_send_json_success( compact( 'items' ) ); |
|
975 | + wp_send_json_success(compact('items')); |
|
976 | 976 | } |
977 | 977 | |
978 | 978 | /** |
@@ -981,48 +981,48 @@ discard block |
||
981 | 981 | public static function edit_invoice_item() { |
982 | 982 | |
983 | 983 | // Verify nonce. |
984 | - check_ajax_referer( 'wpinv-nonce' ); |
|
984 | + check_ajax_referer('wpinv-nonce'); |
|
985 | 985 | |
986 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
986 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
987 | 987 | exit; |
988 | 988 | } |
989 | 989 | |
990 | 990 | // We need an invoice and item details. |
991 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['data'] ) ) { |
|
991 | + if (empty($_POST['post_id']) || empty($_POST['data'])) { |
|
992 | 992 | exit; |
993 | 993 | } |
994 | 994 | |
995 | 995 | // Fetch the invoice. |
996 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
996 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
997 | 997 | |
998 | 998 | // Ensure it exists and its not been paid for. |
999 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
999 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
1000 | 1000 | exit; |
1001 | 1001 | } |
1002 | 1002 | |
1003 | 1003 | // Format the data. |
1004 | - $data = wp_list_pluck( $_POST['data'], 'value', 'field' ); |
|
1004 | + $data = wp_list_pluck($_POST['data'], 'value', 'field'); |
|
1005 | 1005 | |
1006 | 1006 | // Ensure that we have an item id. |
1007 | - if ( empty( $data['id'] ) ) { |
|
1007 | + if (empty($data['id'])) { |
|
1008 | 1008 | exit; |
1009 | 1009 | } |
1010 | 1010 | |
1011 | 1011 | // Abort if the invoice does not have the specified item. |
1012 | - $item = $invoice->get_item( (int) $data['id'] ); |
|
1012 | + $item = $invoice->get_item((int) $data['id']); |
|
1013 | 1013 | |
1014 | - if ( empty( $item ) ) { |
|
1014 | + if (empty($item)) { |
|
1015 | 1015 | exit; |
1016 | 1016 | } |
1017 | 1017 | |
1018 | 1018 | // Update the item. |
1019 | - $item->set_price( $data['price'] ); |
|
1020 | - $item->set_name( $data['name'] ); |
|
1021 | - $item->set_description( $data['description'] ); |
|
1022 | - $item->set_quantity( $data['quantity'] ); |
|
1019 | + $item->set_price($data['price']); |
|
1020 | + $item->set_name($data['name']); |
|
1021 | + $item->set_description($data['description']); |
|
1022 | + $item->set_quantity($data['quantity']); |
|
1023 | 1023 | |
1024 | 1024 | // Add it to the invoice. |
1025 | - $invoice->add_item( $item ); |
|
1025 | + $invoice->add_item($item); |
|
1026 | 1026 | |
1027 | 1027 | // Update totals. |
1028 | 1028 | $invoice->recalculate_total(); |
@@ -1033,11 +1033,11 @@ discard block |
||
1033 | 1033 | // Return an array of invoice items. |
1034 | 1034 | $items = array(); |
1035 | 1035 | |
1036 | - foreach ( $invoice->get_items() as $item_id => $item ) { |
|
1037 | - $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax(); |
|
1036 | + foreach ($invoice->get_items() as $item_id => $item) { |
|
1037 | + $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax(); |
|
1038 | 1038 | } |
1039 | 1039 | |
1040 | - wp_send_json_success( compact( 'items' ) ); |
|
1040 | + wp_send_json_success(compact('items')); |
|
1041 | 1041 | } |
1042 | 1042 | /** |
1043 | 1043 | * Adds a items to an invoice. |
@@ -1045,38 +1045,38 @@ discard block |
||
1045 | 1045 | public static function add_invoice_items() { |
1046 | 1046 | |
1047 | 1047 | // Verify nonce. |
1048 | - check_ajax_referer( 'wpinv-nonce' ); |
|
1048 | + check_ajax_referer('wpinv-nonce'); |
|
1049 | 1049 | |
1050 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
1050 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
1051 | 1051 | exit; |
1052 | 1052 | } |
1053 | 1053 | |
1054 | 1054 | // We need an invoice and items. |
1055 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['items'] ) ) { |
|
1055 | + if (empty($_POST['post_id']) || empty($_POST['items'])) { |
|
1056 | 1056 | exit; |
1057 | 1057 | } |
1058 | 1058 | |
1059 | 1059 | // Fetch the invoice. |
1060 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
1060 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
1061 | 1061 | $alert = false; |
1062 | 1062 | |
1063 | 1063 | // Ensure it exists and its not been paid for. |
1064 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
1064 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
1065 | 1065 | exit; |
1066 | 1066 | } |
1067 | 1067 | |
1068 | 1068 | // Add the items. |
1069 | - foreach ( $_POST['items'] as $data ) { |
|
1069 | + foreach ($_POST['items'] as $data) { |
|
1070 | 1070 | |
1071 | - $item = new GetPaid_Form_Item( $data[ 'id' ] ); |
|
1071 | + $item = new GetPaid_Form_Item($data['id']); |
|
1072 | 1072 | |
1073 | - if ( is_numeric( $data[ 'qty' ] ) && (int) $data[ 'qty' ] > 0 ) { |
|
1074 | - $item->set_quantity( $data[ 'qty' ] ); |
|
1073 | + if (is_numeric($data['qty']) && (int) $data['qty'] > 0) { |
|
1074 | + $item->set_quantity($data['qty']); |
|
1075 | 1075 | } |
1076 | 1076 | |
1077 | - if ( $item->get_id() > 0 ) { |
|
1078 | - if ( ! $invoice->add_item( $item ) ) { |
|
1079 | - $alert = __( 'An invoice can only contain one recurring item', 'invoicing' ); |
|
1077 | + if ($item->get_id() > 0) { |
|
1078 | + if (!$invoice->add_item($item)) { |
|
1079 | + $alert = __('An invoice can only contain one recurring item', 'invoicing'); |
|
1080 | 1080 | } |
1081 | 1081 | } |
1082 | 1082 | |
@@ -1089,11 +1089,11 @@ discard block |
||
1089 | 1089 | // Return an array of invoice items. |
1090 | 1090 | $items = array(); |
1091 | 1091 | |
1092 | - foreach ( $invoice->get_items() as $item_id => $item ) { |
|
1093 | - $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax(); |
|
1092 | + foreach ($invoice->get_items() as $item_id => $item) { |
|
1093 | + $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax(); |
|
1094 | 1094 | } |
1095 | 1095 | |
1096 | - wp_send_json_success( compact( 'items', 'alert' ) ); |
|
1096 | + wp_send_json_success(compact('items', 'alert')); |
|
1097 | 1097 | } |
1098 | 1098 | |
1099 | 1099 | /** |
@@ -1102,15 +1102,15 @@ discard block |
||
1102 | 1102 | public static function get_invoicing_items() { |
1103 | 1103 | |
1104 | 1104 | // Verify nonce. |
1105 | - check_ajax_referer( 'wpinv-nonce' ); |
|
1105 | + check_ajax_referer('wpinv-nonce'); |
|
1106 | 1106 | |
1107 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
1107 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
1108 | 1108 | exit; |
1109 | 1109 | } |
1110 | 1110 | |
1111 | 1111 | // We need a search term. |
1112 | - if ( empty( $_GET['search'] ) ) { |
|
1113 | - wp_send_json_success( array() ); |
|
1112 | + if (empty($_GET['search'])) { |
|
1113 | + wp_send_json_success(array()); |
|
1114 | 1114 | } |
1115 | 1115 | |
1116 | 1116 | // Retrieve items. |
@@ -1119,8 +1119,8 @@ discard block |
||
1119 | 1119 | 'orderby' => 'title', |
1120 | 1120 | 'order' => 'ASC', |
1121 | 1121 | 'posts_per_page' => -1, |
1122 | - 'post_status' => array( 'publish' ), |
|
1123 | - 's' => trim( $_GET['search'] ), |
|
1122 | + 'post_status' => array('publish'), |
|
1123 | + 's' => trim($_GET['search']), |
|
1124 | 1124 | 'meta_query' => array( |
1125 | 1125 | array( |
1126 | 1126 | 'key' => '_wpinv_type', |
@@ -1130,18 +1130,18 @@ discard block |
||
1130 | 1130 | ) |
1131 | 1131 | ); |
1132 | 1132 | |
1133 | - $items = get_posts( apply_filters( 'getpaid_ajax_invoice_items_query_args', $item_args ) ); |
|
1133 | + $items = get_posts(apply_filters('getpaid_ajax_invoice_items_query_args', $item_args)); |
|
1134 | 1134 | $data = array(); |
1135 | 1135 | |
1136 | - foreach ( $items as $item ) { |
|
1137 | - $item = new GetPaid_Form_Item( $item ); |
|
1136 | + foreach ($items as $item) { |
|
1137 | + $item = new GetPaid_Form_Item($item); |
|
1138 | 1138 | $data[] = array( |
1139 | 1139 | 'id' => $item->get_id(), |
1140 | 1140 | 'text' => $item->get_name() |
1141 | 1141 | ); |
1142 | 1142 | } |
1143 | 1143 | |
1144 | - wp_send_json_success( $data ); |
|
1144 | + wp_send_json_success($data); |
|
1145 | 1145 | |
1146 | 1146 | } |
1147 | 1147 | |
@@ -1151,24 +1151,24 @@ discard block |
||
1151 | 1151 | public static function get_aui_states_field() { |
1152 | 1152 | |
1153 | 1153 | // Verify nonce. |
1154 | - check_ajax_referer( 'wpinv-nonce' ); |
|
1154 | + check_ajax_referer('wpinv-nonce'); |
|
1155 | 1155 | |
1156 | 1156 | // We need a country. |
1157 | - if ( empty( $_GET['country'] ) ) { |
|
1157 | + if (empty($_GET['country'])) { |
|
1158 | 1158 | exit; |
1159 | 1159 | } |
1160 | 1160 | |
1161 | - $states = wpinv_get_country_states( trim( $_GET['country'] ) ); |
|
1162 | - $state = isset( $_GET['state'] ) ? trim( $_GET['state'] ) : wpinv_get_default_state(); |
|
1161 | + $states = wpinv_get_country_states(trim($_GET['country'])); |
|
1162 | + $state = isset($_GET['state']) ? trim($_GET['state']) : wpinv_get_default_state(); |
|
1163 | 1163 | |
1164 | - if ( empty( $states ) ) { |
|
1164 | + if (empty($states)) { |
|
1165 | 1165 | |
1166 | 1166 | $html = aui()->input( |
1167 | 1167 | array( |
1168 | 1168 | 'type' => 'text', |
1169 | 1169 | 'id' => 'wpinv_state', |
1170 | 1170 | 'name' => 'wpinv_state', |
1171 | - 'label' => __( 'State', 'invoicing' ), |
|
1171 | + 'label' => __('State', 'invoicing'), |
|
1172 | 1172 | 'label_type' => 'vertical', |
1173 | 1173 | 'placeholder' => 'Liège', |
1174 | 1174 | 'class' => 'form-control-sm', |
@@ -1182,9 +1182,9 @@ discard block |
||
1182 | 1182 | array( |
1183 | 1183 | 'id' => 'wpinv_state', |
1184 | 1184 | 'name' => 'wpinv_state', |
1185 | - 'label' => __( 'State', 'invoicing' ), |
|
1185 | + 'label' => __('State', 'invoicing'), |
|
1186 | 1186 | 'label_type' => 'vertical', |
1187 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
1187 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
1188 | 1188 | 'class' => 'form-control-sm', |
1189 | 1189 | 'value' => $state, |
1190 | 1190 | 'options' => $states, |
@@ -1198,7 +1198,7 @@ discard block |
||
1198 | 1198 | wp_send_json_success( |
1199 | 1199 | array( |
1200 | 1200 | 'html' => $html, |
1201 | - 'select' => ! empty ( $states ) |
|
1201 | + 'select' => !empty ($states) |
|
1202 | 1202 | ) |
1203 | 1203 | ); |
1204 | 1204 | |
@@ -1212,11 +1212,11 @@ discard block |
||
1212 | 1212 | public static function payment_form_refresh_prices() { |
1213 | 1213 | |
1214 | 1214 | // Check nonce. |
1215 | - check_ajax_referer( 'getpaid_form_nonce' ); |
|
1215 | + check_ajax_referer('getpaid_form_nonce'); |
|
1216 | 1216 | |
1217 | 1217 | // ... form fields... |
1218 | - if ( empty( $_POST['getpaid_payment_form_submission'] ) ) { |
|
1219 | - _e( 'Error: Reload the page and try again.', 'invoicing' ); |
|
1218 | + if (empty($_POST['getpaid_payment_form_submission'])) { |
|
1219 | + _e('Error: Reload the page and try again.', 'invoicing'); |
|
1220 | 1220 | exit; |
1221 | 1221 | } |
1222 | 1222 | |
@@ -1224,7 +1224,7 @@ discard block |
||
1224 | 1224 | $submission = new GetPaid_Payment_Form_Submission(); |
1225 | 1225 | |
1226 | 1226 | // Do we have an error? |
1227 | - if ( ! empty( $submission->last_error ) ) { |
|
1227 | + if (!empty($submission->last_error)) { |
|
1228 | 1228 | echo $submission->last_error; |
1229 | 1229 | exit; |
1230 | 1230 | } |
@@ -1235,38 +1235,38 @@ discard block |
||
1235 | 1235 | 'has_recurring' => $submission->has_recurring, |
1236 | 1236 | 'is_free' => $submission->get_payment_details(), |
1237 | 1237 | 'totals' => array( |
1238 | - 'subtotal' => wpinv_price( wpinv_format_amount( $submission->subtotal_amount ), $submission->get_currency() ), |
|
1239 | - 'discount' => wpinv_price( wpinv_format_amount( $submission->get_total_discount() ), $submission->get_currency() ), |
|
1240 | - 'fees' => wpinv_price( wpinv_format_amount( $submission->get_total_fees() ), $submission->get_currency() ), |
|
1241 | - 'tax' => wpinv_price( wpinv_format_amount( $submission->get_total_tax() ), $submission->get_currency() ), |
|
1242 | - 'total' => wpinv_price( wpinv_format_amount( $submission->get_total() ), $submission->get_currency() ), |
|
1238 | + 'subtotal' => wpinv_price(wpinv_format_amount($submission->subtotal_amount), $submission->get_currency()), |
|
1239 | + 'discount' => wpinv_price(wpinv_format_amount($submission->get_total_discount()), $submission->get_currency()), |
|
1240 | + 'fees' => wpinv_price(wpinv_format_amount($submission->get_total_fees()), $submission->get_currency()), |
|
1241 | + 'tax' => wpinv_price(wpinv_format_amount($submission->get_total_tax()), $submission->get_currency()), |
|
1242 | + 'total' => wpinv_price(wpinv_format_amount($submission->get_total()), $submission->get_currency()), |
|
1243 | 1243 | ), |
1244 | 1244 | ); |
1245 | 1245 | |
1246 | 1246 | // Add items. |
1247 | 1247 | $items = $submission->get_items(); |
1248 | - if ( ! empty( $items ) ) { |
|
1248 | + if (!empty($items)) { |
|
1249 | 1249 | $result['items'] = array(); |
1250 | 1250 | |
1251 | - foreach( $items as $item_id => $item ) { |
|
1252 | - $result['items']["$item_id"] = wpinv_price( wpinv_format_amount( $item->get_price() * $item->get_qantity() ) ); |
|
1251 | + foreach ($items as $item_id => $item) { |
|
1252 | + $result['items']["$item_id"] = wpinv_price(wpinv_format_amount($item->get_price() * $item->get_qantity())); |
|
1253 | 1253 | } |
1254 | 1254 | } |
1255 | 1255 | |
1256 | 1256 | // Add invoice. |
1257 | - if ( $submission->has_invoice() ) { |
|
1257 | + if ($submission->has_invoice()) { |
|
1258 | 1258 | $result['invoice'] = $submission->get_invoice()->ID; |
1259 | 1259 | } |
1260 | 1260 | |
1261 | 1261 | // Add discount code. |
1262 | - if ( $submission->has_discount_code() ) { |
|
1262 | + if ($submission->has_discount_code()) { |
|
1263 | 1263 | $result['discount_code'] = $submission->get_discount_code(); |
1264 | 1264 | } |
1265 | 1265 | |
1266 | 1266 | // Filter the result. |
1267 | - $result = apply_filters( 'getpaid_payment_form_ajax_refresh_prices', $result, $submission ); |
|
1267 | + $result = apply_filters('getpaid_payment_form_ajax_refresh_prices', $result, $submission); |
|
1268 | 1268 | |
1269 | - wp_send_json_success( $result ); |
|
1269 | + wp_send_json_success($result); |
|
1270 | 1270 | } |
1271 | 1271 | |
1272 | 1272 | /** |
@@ -1277,53 +1277,53 @@ discard block |
||
1277 | 1277 | public static function buy_items() { |
1278 | 1278 | $user_id = get_current_user_id(); |
1279 | 1279 | |
1280 | - if ( empty( $user_id ) ) { // If not logged in then lets redirect to the login page |
|
1281 | - wp_send_json( array( |
|
1282 | - 'success' => wp_login_url( wp_get_referer() ) |
|
1283 | - ) ); |
|
1280 | + if (empty($user_id)) { // If not logged in then lets redirect to the login page |
|
1281 | + wp_send_json(array( |
|
1282 | + 'success' => wp_login_url(wp_get_referer()) |
|
1283 | + )); |
|
1284 | 1284 | } else { |
1285 | 1285 | // Only check nonce if logged in as it could be cached when logged out. |
1286 | - if ( ! isset( $_POST['wpinv_buy_nonce'] ) || ! wp_verify_nonce( $_POST['wpinv_buy_nonce'], 'wpinv_buy_items' ) ) { |
|
1287 | - wp_send_json( array( |
|
1288 | - 'error' => __( 'Security checks failed.', 'invoicing' ) |
|
1289 | - ) ); |
|
1286 | + if (!isset($_POST['wpinv_buy_nonce']) || !wp_verify_nonce($_POST['wpinv_buy_nonce'], 'wpinv_buy_items')) { |
|
1287 | + wp_send_json(array( |
|
1288 | + 'error' => __('Security checks failed.', 'invoicing') |
|
1289 | + )); |
|
1290 | 1290 | wp_die(); |
1291 | 1291 | } |
1292 | 1292 | |
1293 | 1293 | // allow to set a custom price through post_id |
1294 | 1294 | $items = $_POST['items']; |
1295 | - $related_post_id = isset( $_POST['post_id'] ) ? (int)$_POST['post_id'] : 0; |
|
1296 | - $custom_item_price = $related_post_id ? abs( get_post_meta( $related_post_id, '_wpi_custom_price', true ) ) : 0; |
|
1295 | + $related_post_id = isset($_POST['post_id']) ? (int) $_POST['post_id'] : 0; |
|
1296 | + $custom_item_price = $related_post_id ? abs(get_post_meta($related_post_id, '_wpi_custom_price', true)) : 0; |
|
1297 | 1297 | |
1298 | 1298 | $cart_items = array(); |
1299 | - if ( $items ) { |
|
1300 | - $items = explode( ',', $items ); |
|
1299 | + if ($items) { |
|
1300 | + $items = explode(',', $items); |
|
1301 | 1301 | |
1302 | - foreach( $items as $item ) { |
|
1302 | + foreach ($items as $item) { |
|
1303 | 1303 | $item_id = $item; |
1304 | 1304 | $quantity = 1; |
1305 | 1305 | |
1306 | - if ( strpos( $item, '|' ) !== false ) { |
|
1307 | - $item_parts = explode( '|', $item ); |
|
1306 | + if (strpos($item, '|') !== false) { |
|
1307 | + $item_parts = explode('|', $item); |
|
1308 | 1308 | $item_id = $item_parts[0]; |
1309 | 1309 | $quantity = $item_parts[1]; |
1310 | 1310 | } |
1311 | 1311 | |
1312 | - if ( $item_id && $quantity ) { |
|
1312 | + if ($item_id && $quantity) { |
|
1313 | 1313 | $cart_items_arr = array( |
1314 | - 'id' => (int)$item_id, |
|
1315 | - 'quantity' => (int)$quantity |
|
1314 | + 'id' => (int) $item_id, |
|
1315 | + 'quantity' => (int) $quantity |
|
1316 | 1316 | ); |
1317 | 1317 | |
1318 | 1318 | // If there is a related post id then add it to meta |
1319 | - if ( $related_post_id ) { |
|
1319 | + if ($related_post_id) { |
|
1320 | 1320 | $cart_items_arr['meta'] = array( |
1321 | 1321 | 'post_id' => $related_post_id |
1322 | 1322 | ); |
1323 | 1323 | } |
1324 | 1324 | |
1325 | 1325 | // If there is a custom price then set it. |
1326 | - if ( $custom_item_price ) { |
|
1326 | + if ($custom_item_price) { |
|
1327 | 1327 | $cart_items_arr['custom_price'] = $custom_item_price; |
1328 | 1328 | } |
1329 | 1329 | |
@@ -1339,37 +1339,37 @@ discard block |
||
1339 | 1339 | * @param int $related_post_id The related post id if any. |
1340 | 1340 | * @since 1.0.0 |
1341 | 1341 | */ |
1342 | - $cart_items = apply_filters( 'wpinv_buy_cart_items', $cart_items, $related_post_id ); |
|
1342 | + $cart_items = apply_filters('wpinv_buy_cart_items', $cart_items, $related_post_id); |
|
1343 | 1343 | |
1344 | 1344 | // Make sure its not in the cart already, if it is then redirect to checkout. |
1345 | 1345 | $cart_invoice = wpinv_get_invoice_cart(); |
1346 | 1346 | |
1347 | - if ( isset( $cart_invoice->items ) && !empty( $cart_invoice->items ) && !empty( $cart_items ) && serialize( $cart_invoice->items ) == serialize( $cart_items ) ) { |
|
1348 | - wp_send_json( array( |
|
1347 | + if (isset($cart_invoice->items) && !empty($cart_invoice->items) && !empty($cart_items) && serialize($cart_invoice->items) == serialize($cart_items)) { |
|
1348 | + wp_send_json(array( |
|
1349 | 1349 | 'success' => $cart_invoice->get_checkout_payment_url() |
1350 | - ) ); |
|
1350 | + )); |
|
1351 | 1351 | wp_die(); |
1352 | 1352 | } |
1353 | 1353 | |
1354 | 1354 | // Check if user has invoice with same items waiting to be paid. |
1355 | - $user_invoices = wpinv_get_users_invoices( $user_id , 10 , false , 'wpi-pending' ); |
|
1356 | - if ( !empty( $user_invoices ) ) { |
|
1357 | - foreach( $user_invoices as $user_invoice ) { |
|
1355 | + $user_invoices = wpinv_get_users_invoices($user_id, 10, false, 'wpi-pending'); |
|
1356 | + if (!empty($user_invoices)) { |
|
1357 | + foreach ($user_invoices as $user_invoice) { |
|
1358 | 1358 | $user_cart_details = array(); |
1359 | - $invoice = wpinv_get_invoice( $user_invoice->ID ); |
|
1359 | + $invoice = wpinv_get_invoice($user_invoice->ID); |
|
1360 | 1360 | $cart_details = $invoice->get_cart_details(); |
1361 | 1361 | |
1362 | - if ( !empty( $cart_details ) ) { |
|
1363 | - foreach ( $cart_details as $invoice_item ) { |
|
1362 | + if (!empty($cart_details)) { |
|
1363 | + foreach ($cart_details as $invoice_item) { |
|
1364 | 1364 | $ii_arr = array(); |
1365 | - $ii_arr['id'] = (int)$invoice_item['id']; |
|
1366 | - $ii_arr['quantity'] = (int)$invoice_item['quantity']; |
|
1365 | + $ii_arr['id'] = (int) $invoice_item['id']; |
|
1366 | + $ii_arr['quantity'] = (int) $invoice_item['quantity']; |
|
1367 | 1367 | |
1368 | - if (isset( $invoice_item['meta'] ) && !empty( $invoice_item['meta'] ) ) { |
|
1368 | + if (isset($invoice_item['meta']) && !empty($invoice_item['meta'])) { |
|
1369 | 1369 | $ii_arr['meta'] = $invoice_item['meta']; |
1370 | 1370 | } |
1371 | 1371 | |
1372 | - if ( isset( $invoice_item['custom_price'] ) && !empty( $invoice_item['custom_price'] ) ) { |
|
1372 | + if (isset($invoice_item['custom_price']) && !empty($invoice_item['custom_price'])) { |
|
1373 | 1373 | $ii_arr['custom_price'] = $invoice_item['custom_price']; |
1374 | 1374 | } |
1375 | 1375 | |
@@ -1377,17 +1377,17 @@ discard block |
||
1377 | 1377 | } |
1378 | 1378 | } |
1379 | 1379 | |
1380 | - if ( !empty( $user_cart_details ) && serialize( $cart_items ) == serialize( $user_cart_details ) ) { |
|
1381 | - wp_send_json( array( |
|
1380 | + if (!empty($user_cart_details) && serialize($cart_items) == serialize($user_cart_details)) { |
|
1381 | + wp_send_json(array( |
|
1382 | 1382 | 'success' => $invoice->get_checkout_payment_url() |
1383 | - ) ); |
|
1383 | + )); |
|
1384 | 1384 | wp_die(); |
1385 | 1385 | } |
1386 | 1386 | } |
1387 | 1387 | } |
1388 | 1388 | |
1389 | 1389 | // Create invoice and send user to checkout |
1390 | - if ( !empty( $cart_items ) ) { |
|
1390 | + if (!empty($cart_items)) { |
|
1391 | 1391 | $invoice_data = array( |
1392 | 1392 | 'status' => 'wpi-pending', |
1393 | 1393 | 'created_via' => 'wpi', |
@@ -1395,21 +1395,21 @@ discard block |
||
1395 | 1395 | 'cart_details' => $cart_items, |
1396 | 1396 | ); |
1397 | 1397 | |
1398 | - $invoice = wpinv_insert_invoice( $invoice_data, true ); |
|
1398 | + $invoice = wpinv_insert_invoice($invoice_data, true); |
|
1399 | 1399 | |
1400 | - if ( !empty( $invoice ) && isset( $invoice->ID ) ) { |
|
1401 | - wp_send_json( array( |
|
1400 | + if (!empty($invoice) && isset($invoice->ID)) { |
|
1401 | + wp_send_json(array( |
|
1402 | 1402 | 'success' => $invoice->get_checkout_payment_url() |
1403 | - ) ); |
|
1403 | + )); |
|
1404 | 1404 | } else { |
1405 | - wp_send_json( array( |
|
1406 | - 'error' => __( 'Invoice failed to create', 'invoicing' ) |
|
1407 | - ) ); |
|
1405 | + wp_send_json(array( |
|
1406 | + 'error' => __('Invoice failed to create', 'invoicing') |
|
1407 | + )); |
|
1408 | 1408 | } |
1409 | 1409 | } else { |
1410 | - wp_send_json( array( |
|
1411 | - 'error' => __( 'Items not valid.', 'invoicing' ) |
|
1412 | - ) ); |
|
1410 | + wp_send_json(array( |
|
1411 | + 'error' => __('Items not valid.', 'invoicing') |
|
1412 | + )); |
|
1413 | 1413 | } |
1414 | 1414 | } |
1415 | 1415 |
@@ -7,15 +7,15 @@ 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 | |
15 | 15 | function wpinv_get_default_country() { |
16 | - $country = wpinv_get_option( 'default_country', 'UK' ); |
|
16 | + $country = wpinv_get_option('default_country', 'UK'); |
|
17 | 17 | |
18 | - return apply_filters( 'wpinv_default_country', $country ); |
|
18 | + return apply_filters('wpinv_default_country', $country); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -24,59 +24,59 @@ discard block |
||
24 | 24 | * @param string $country The country code to sanitize |
25 | 25 | * @return array |
26 | 26 | */ |
27 | -function wpinv_sanitize_country( $country ) { |
|
27 | +function wpinv_sanitize_country($country) { |
|
28 | 28 | |
29 | 29 | // Enure the country is specified |
30 | - if ( empty( $country ) ) { |
|
30 | + if (empty($country)) { |
|
31 | 31 | $country = wpinv_get_default_country(); |
32 | 32 | } |
33 | - return trim( wpinv_utf8_strtoupper( $country ) ); |
|
33 | + return trim(wpinv_utf8_strtoupper($country)); |
|
34 | 34 | |
35 | 35 | } |
36 | 36 | |
37 | -function wpinv_is_base_country( $country ) { |
|
37 | +function wpinv_is_base_country($country) { |
|
38 | 38 | $base_country = wpinv_get_default_country(); |
39 | 39 | |
40 | - if ( $base_country === 'UK' ) { |
|
40 | + if ($base_country === 'UK') { |
|
41 | 41 | $base_country = 'GB'; |
42 | 42 | } |
43 | - if ( $country == 'UK' ) { |
|
43 | + if ($country == 'UK') { |
|
44 | 44 | $country = 'GB'; |
45 | 45 | } |
46 | 46 | |
47 | - return ( $country && $country === $base_country ) ? true : false; |
|
47 | + return ($country && $country === $base_country) ? true : false; |
|
48 | 48 | } |
49 | 49 | |
50 | -function wpinv_country_name( $country_code = '' ) { |
|
50 | +function wpinv_country_name($country_code = '') { |
|
51 | 51 | $countries = wpinv_get_country_list(); |
52 | 52 | $country_code = $country_code == 'UK' ? 'GB' : $country_code; |
53 | - $country = isset( $countries[$country_code] ) ? $countries[$country_code] : $country_code; |
|
53 | + $country = isset($countries[$country_code]) ? $countries[$country_code] : $country_code; |
|
54 | 54 | |
55 | - return apply_filters( 'wpinv_country_name', $country, $country_code ); |
|
55 | + return apply_filters('wpinv_country_name', $country, $country_code); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | function wpinv_get_default_state() { |
59 | - $state = wpinv_get_option( 'default_state', false ); |
|
59 | + $state = wpinv_get_option('default_state', false); |
|
60 | 60 | |
61 | - return apply_filters( 'wpinv_default_state', $state ); |
|
61 | + return apply_filters('wpinv_default_state', $state); |
|
62 | 62 | } |
63 | 63 | |
64 | -function wpinv_state_name( $state_code = '', $country_code = '' ) { |
|
64 | +function wpinv_state_name($state_code = '', $country_code = '') { |
|
65 | 65 | $state = $state_code; |
66 | 66 | |
67 | - if ( !empty( $country_code ) ) { |
|
68 | - $states = wpinv_get_country_states( $country_code ); |
|
67 | + if (!empty($country_code)) { |
|
68 | + $states = wpinv_get_country_states($country_code); |
|
69 | 69 | |
70 | - $state = !empty( $states ) && isset( $states[$state_code] ) ? $states[$state_code] : $state; |
|
70 | + $state = !empty($states) && isset($states[$state_code]) ? $states[$state_code] : $state; |
|
71 | 71 | } |
72 | 72 | |
73 | - return apply_filters( 'wpinv_state_name', $state, $state_code, $country_code ); |
|
73 | + return apply_filters('wpinv_state_name', $state, $state_code, $country_code); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | function wpinv_store_address() { |
77 | - $address = wpinv_get_option( 'store_address', '' ); |
|
77 | + $address = wpinv_get_option('store_address', ''); |
|
78 | 78 | |
79 | - return apply_filters( 'wpinv_store_address', $address ); |
|
79 | + return apply_filters('wpinv_store_address', $address); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @param WPInv_Invoice $invoice |
86 | 86 | */ |
87 | -function getpaid_save_invoice_user_address( $invoice ) { |
|
87 | +function getpaid_save_invoice_user_address($invoice) { |
|
88 | 88 | |
89 | 89 | $address_fields = array( |
90 | 90 | 'first_name', |
@@ -99,23 +99,23 @@ discard block |
||
99 | 99 | 'zip' |
100 | 100 | ); |
101 | 101 | |
102 | - foreach ( $address_fields as $field ) { |
|
102 | + foreach ($address_fields as $field) { |
|
103 | 103 | $method = "get_{$field}"; |
104 | 104 | $value = $invoice->$method(); |
105 | 105 | |
106 | 106 | // Only save if it is not empty. |
107 | - if ( ! empty( $value ) ) { |
|
108 | - update_user_meta( $invoice->get_user_id(), '_wpinv_' . $field, $value ); |
|
107 | + if (!empty($value)) { |
|
108 | + update_user_meta($invoice->get_user_id(), '_wpinv_' . $field, $value); |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
112 | 112 | } |
113 | 113 | |
114 | -function wpinv_get_user_address( $user_id = 0, $with_default = true ) { |
|
114 | +function wpinv_get_user_address($user_id = 0, $with_default = true) { |
|
115 | 115 | global $wpi_userID; |
116 | 116 | |
117 | - if( empty( $user_id ) ) { |
|
118 | - $user_id = !empty( $wpi_userID ) ? $wpi_userID : get_current_user_id(); |
|
117 | + if (empty($user_id)) { |
|
118 | + $user_id = !empty($wpi_userID) ? $wpi_userID : get_current_user_id(); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | $address_fields = array( |
@@ -131,29 +131,29 @@ discard block |
||
131 | 131 | 'zip', |
132 | 132 | ); |
133 | 133 | |
134 | - $user_info = get_userdata( $user_id ); |
|
134 | + $user_info = get_userdata($user_id); |
|
135 | 135 | |
136 | 136 | $address = array(); |
137 | 137 | $address['user_id'] = $user_id; |
138 | - $address['email'] = !empty( $user_info ) ? $user_info->user_email : ''; |
|
139 | - foreach ( $address_fields as $field ) { |
|
140 | - $address[$field] = get_user_meta( $user_id, '_wpinv_' . $field, true ); |
|
138 | + $address['email'] = !empty($user_info) ? $user_info->user_email : ''; |
|
139 | + foreach ($address_fields as $field) { |
|
140 | + $address[$field] = get_user_meta($user_id, '_wpinv_' . $field, true); |
|
141 | 141 | } |
142 | 142 | |
143 | - if ( !empty( $user_info ) ) { |
|
144 | - if( empty( $address['first_name'] ) ) |
|
143 | + if (!empty($user_info)) { |
|
144 | + if (empty($address['first_name'])) |
|
145 | 145 | $address['first_name'] = $user_info->first_name; |
146 | 146 | |
147 | - if( empty( $address['last_name'] ) ) |
|
147 | + if (empty($address['last_name'])) |
|
148 | 148 | $address['last_name'] = $user_info->last_name; |
149 | 149 | } |
150 | 150 | |
151 | - $address['name'] = trim( trim( $address['first_name'] . ' ' . $address['last_name'] ), "," ); |
|
151 | + $address['name'] = trim(trim($address['first_name'] . ' ' . $address['last_name']), ","); |
|
152 | 152 | |
153 | - if( empty( $address['state'] ) && $with_default ) |
|
153 | + if (empty($address['state']) && $with_default) |
|
154 | 154 | $address['state'] = wpinv_get_default_state(); |
155 | 155 | |
156 | - if( empty( $address['country'] ) && $with_default ) |
|
156 | + if (empty($address['country']) && $with_default) |
|
157 | 157 | $address['country'] = wpinv_get_default_country(); |
158 | 158 | |
159 | 159 | |
@@ -167,16 +167,16 @@ discard block |
||
167 | 167 | * @param string $return What to return. |
168 | 168 | * @return array |
169 | 169 | */ |
170 | -function wpinv_get_continents( $return = 'all' ) { |
|
170 | +function wpinv_get_continents($return = 'all') { |
|
171 | 171 | |
172 | - $continents = wpinv_get_data( 'continents' ); |
|
172 | + $continents = wpinv_get_data('continents'); |
|
173 | 173 | |
174 | - switch( $return ) { |
|
174 | + switch ($return) { |
|
175 | 175 | case 'name' : |
176 | - return wp_list_pluck( $continents, 'name' ); |
|
176 | + return wp_list_pluck($continents, 'name'); |
|
177 | 177 | break; |
178 | 178 | case 'countries' : |
179 | - return wp_list_pluck( $continents, 'countries' ); |
|
179 | + return wp_list_pluck($continents, 'countries'); |
|
180 | 180 | break; |
181 | 181 | default : |
182 | 182 | return $continents; |
@@ -192,12 +192,12 @@ discard block |
||
192 | 192 | * @param string $country Country code. If no code is specified, defaults to the default country. |
193 | 193 | * @return string |
194 | 194 | */ |
195 | -function wpinv_get_continent_code_for_country( $country = false ) { |
|
195 | +function wpinv_get_continent_code_for_country($country = false) { |
|
196 | 196 | |
197 | - $country = wpinv_sanitize_country( $country ); |
|
197 | + $country = wpinv_sanitize_country($country); |
|
198 | 198 | |
199 | - foreach ( wpinv_get_continents( 'countries' ) as $continent_code => $countries ) { |
|
200 | - if ( false !== array_search( $country, $countries, true ) ) { |
|
199 | + foreach (wpinv_get_continents('countries') as $continent_code => $countries) { |
|
200 | + if (false !== array_search($country, $countries, true)) { |
|
201 | 201 | return $continent_code; |
202 | 202 | } |
203 | 203 | } |
@@ -213,13 +213,13 @@ discard block |
||
213 | 213 | * @param string $country Country code. If no code is specified, defaults to the default country. |
214 | 214 | * @return array |
215 | 215 | */ |
216 | -function wpinv_get_country_calling_code( $country = null) { |
|
216 | +function wpinv_get_country_calling_code($country = null) { |
|
217 | 217 | |
218 | - $country = wpinv_sanitize_country( $country ); |
|
219 | - $codes = wpinv_get_data( 'phone-codes' ); |
|
220 | - $code = isset( $codes[ $country ] ) ? $codes[ $country ] : ''; |
|
218 | + $country = wpinv_sanitize_country($country); |
|
219 | + $codes = wpinv_get_data('phone-codes'); |
|
220 | + $code = isset($codes[$country]) ? $codes[$country] : ''; |
|
221 | 221 | |
222 | - if ( is_array( $code ) ) { |
|
222 | + if (is_array($code)) { |
|
223 | 223 | return $code[0]; |
224 | 224 | } |
225 | 225 | return $code; |
@@ -232,8 +232,8 @@ discard block |
||
232 | 232 | * @param bool $first_empty Whether or not the first item in the list should be empty |
233 | 233 | * @return array |
234 | 234 | */ |
235 | -function wpinv_get_country_list( $first_empty = false ) { |
|
236 | - return wpinv_maybe_add_empty_option( apply_filters( 'wpinv_countries', wpinv_get_data( 'countries' ) ), $first_empty ); |
|
235 | +function wpinv_get_country_list($first_empty = false) { |
|
236 | + return wpinv_maybe_add_empty_option(apply_filters('wpinv_countries', wpinv_get_data('countries')), $first_empty); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | /** |
@@ -243,22 +243,22 @@ discard block |
||
243 | 243 | * @param bool $first_empty Whether or not the first item in the list should be empty |
244 | 244 | * @return array |
245 | 245 | */ |
246 | -function wpinv_get_country_states( $country = null, $first_empty = false ) { |
|
246 | +function wpinv_get_country_states($country = null, $first_empty = false) { |
|
247 | 247 | |
248 | 248 | // Prepare the country. |
249 | - $country = wpinv_sanitize_country( $country ); |
|
249 | + $country = wpinv_sanitize_country($country); |
|
250 | 250 | |
251 | 251 | // Fetch all states. |
252 | - $all_states = wpinv_get_data( 'states' ); |
|
252 | + $all_states = wpinv_get_data('states'); |
|
253 | 253 | |
254 | 254 | // Fetch the specified country's states. |
255 | - $states = isset( $all_states[ $country ] ) ? $all_states[ $country ] : array() ; |
|
256 | - $states = apply_filters( "wpinv_{$country}_states", $states ); |
|
257 | - $states = apply_filters( 'wpinv_country_states', $states, $country ); |
|
255 | + $states = isset($all_states[$country]) ? $all_states[$country] : array(); |
|
256 | + $states = apply_filters("wpinv_{$country}_states", $states); |
|
257 | + $states = apply_filters('wpinv_country_states', $states, $country); |
|
258 | 258 | |
259 | - asort( $states ); |
|
259 | + asort($states); |
|
260 | 260 | |
261 | - return wpinv_maybe_add_empty_option( $states, $first_empty ); |
|
261 | + return wpinv_maybe_add_empty_option($states, $first_empty); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | * @return array |
269 | 269 | */ |
270 | 270 | function wpinv_get_us_states_list() { |
271 | - return apply_filters( 'wpinv_usa_states', wpinv_get_country_states( 'US' ) ); |
|
271 | + return apply_filters('wpinv_usa_states', wpinv_get_country_states('US')); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * @return array |
279 | 279 | */ |
280 | 280 | function wpinv_get_canada_states_list() { |
281 | - return apply_filters( 'wpinv_canada_provinces', wpinv_get_country_states( 'CA' ) ); |
|
281 | + return apply_filters('wpinv_canada_provinces', wpinv_get_country_states('CA')); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | * @return array |
289 | 289 | */ |
290 | 290 | function wpinv_get_australia_states_list() { |
291 | - return apply_filters( 'wpinv_australia_states', wpinv_get_country_states( 'AU' ) ); |
|
291 | + return apply_filters('wpinv_australia_states', wpinv_get_country_states('AU')); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | /** |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | * @return array |
299 | 299 | */ |
300 | 300 | function wpinv_get_bangladesh_states_list() { |
301 | - return apply_filters( 'wpinv_bangladesh_states', wpinv_get_country_states( 'BD' ) ); |
|
301 | + return apply_filters('wpinv_bangladesh_states', wpinv_get_country_states('BD')); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | /** |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | * @return array |
309 | 309 | */ |
310 | 310 | function wpinv_get_brazil_states_list() { |
311 | - return apply_filters( 'wpinv_brazil_states', wpinv_get_country_states( 'BR' ) ); |
|
311 | + return apply_filters('wpinv_brazil_states', wpinv_get_country_states('BR')); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | /** |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | * @return array |
319 | 319 | */ |
320 | 320 | function wpinv_get_bulgaria_states_list() { |
321 | - return apply_filters( 'wpinv_bulgaria_states', wpinv_get_country_states( 'BG' ) ); |
|
321 | + return apply_filters('wpinv_bulgaria_states', wpinv_get_country_states('BG')); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | /** |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | * @return array |
329 | 329 | */ |
330 | 330 | function wpinv_get_hong_kong_states_list() { |
331 | - return apply_filters( 'wpinv_hong_kong_states', wpinv_get_country_states( 'HK' ) ); |
|
331 | + return apply_filters('wpinv_hong_kong_states', wpinv_get_country_states('HK')); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | /** |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | * @return array |
339 | 339 | */ |
340 | 340 | function wpinv_get_hungary_states_list() { |
341 | - return apply_filters( 'wpinv_hungary_states', wpinv_get_country_states( 'HU' ) ); |
|
341 | + return apply_filters('wpinv_hungary_states', wpinv_get_country_states('HU')); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | /** |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | * @return array |
349 | 349 | */ |
350 | 350 | function wpinv_get_japan_states_list() { |
351 | - return apply_filters( 'wpinv_japan_states', wpinv_get_country_states( 'JP' ) ); |
|
351 | + return apply_filters('wpinv_japan_states', wpinv_get_country_states('JP')); |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | /** |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | * @return array |
359 | 359 | */ |
360 | 360 | function wpinv_get_china_states_list() { |
361 | - return apply_filters( 'wpinv_china_states', wpinv_get_country_states( 'CN' ) ); |
|
361 | + return apply_filters('wpinv_china_states', wpinv_get_country_states('CN')); |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | /** |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | * @return array |
369 | 369 | */ |
370 | 370 | function wpinv_get_new_zealand_states_list() { |
371 | - return apply_filters( 'wpinv_new_zealand_states', wpinv_get_country_states( 'NZ' ) ); |
|
371 | + return apply_filters('wpinv_new_zealand_states', wpinv_get_country_states('NZ')); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | /** |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | * @return array |
379 | 379 | */ |
380 | 380 | function wpinv_get_peru_states_list() { |
381 | - return apply_filters( 'wpinv_peru_states', wpinv_get_country_states( 'PE' ) ); |
|
381 | + return apply_filters('wpinv_peru_states', wpinv_get_country_states('PE')); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | /** |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | * @return array |
389 | 389 | */ |
390 | 390 | function wpinv_get_indonesia_states_list() { |
391 | - return apply_filters( 'wpinv_indonesia_states', wpinv_get_country_states( 'ID' ) ); |
|
391 | + return apply_filters('wpinv_indonesia_states', wpinv_get_country_states('ID')); |
|
392 | 392 | } |
393 | 393 | |
394 | 394 | /** |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | * @return array |
399 | 399 | */ |
400 | 400 | function wpinv_get_india_states_list() { |
401 | - return apply_filters( 'wpinv_india_states', wpinv_get_country_states( 'IN' ) ); |
|
401 | + return apply_filters('wpinv_india_states', wpinv_get_country_states('IN')); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | /** |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | * @return array |
409 | 409 | */ |
410 | 410 | function wpinv_get_iran_states_list() { |
411 | - return apply_filters( 'wpinv_iran_states', wpinv_get_country_states( 'IR' ) ); |
|
411 | + return apply_filters('wpinv_iran_states', wpinv_get_country_states('IR')); |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | /** |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | * @return array |
419 | 419 | */ |
420 | 420 | function wpinv_get_italy_states_list() { |
421 | - return apply_filters( 'wpinv_italy_states', wpinv_get_country_states( 'IT' ) ); |
|
421 | + return apply_filters('wpinv_italy_states', wpinv_get_country_states('IT')); |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | /** |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | * @return array |
429 | 429 | */ |
430 | 430 | function wpinv_get_malaysia_states_list() { |
431 | - return apply_filters( 'wpinv_malaysia_states', wpinv_get_country_states( 'MY' ) ); |
|
431 | + return apply_filters('wpinv_malaysia_states', wpinv_get_country_states('MY')); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | /** |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | * @return array |
439 | 439 | */ |
440 | 440 | function wpinv_get_mexico_states_list() { |
441 | - return apply_filters( 'wpinv_mexico_states', wpinv_get_country_states( 'MX' ) ); |
|
441 | + return apply_filters('wpinv_mexico_states', wpinv_get_country_states('MX')); |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | /** |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | * @return array |
449 | 449 | */ |
450 | 450 | function wpinv_get_nepal_states_list() { |
451 | - return apply_filters( 'wpinv_nepal_states', wpinv_get_country_states( 'NP' ) ); |
|
451 | + return apply_filters('wpinv_nepal_states', wpinv_get_country_states('NP')); |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | /** |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | * @return array |
459 | 459 | */ |
460 | 460 | function wpinv_get_south_africa_states_list() { |
461 | - return apply_filters( 'wpinv_south_africa_states', wpinv_get_country_states( 'ZA' ) ); |
|
461 | + return apply_filters('wpinv_south_africa_states', wpinv_get_country_states('ZA')); |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | /** |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | * @return array |
469 | 469 | */ |
470 | 470 | function wpinv_get_thailand_states_list() { |
471 | - return apply_filters( 'wpinv_thailand_states', wpinv_get_country_states( 'TH' ) ); |
|
471 | + return apply_filters('wpinv_thailand_states', wpinv_get_country_states('TH')); |
|
472 | 472 | } |
473 | 473 | |
474 | 474 | /** |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | * @return array |
479 | 479 | */ |
480 | 480 | function wpinv_get_turkey_states_list() { |
481 | - return apply_filters( 'wpinv_turkey_states', wpinv_get_country_states( 'TR' ) ); |
|
481 | + return apply_filters('wpinv_turkey_states', wpinv_get_country_states('TR')); |
|
482 | 482 | } |
483 | 483 | |
484 | 484 | /** |
@@ -488,28 +488,28 @@ discard block |
||
488 | 488 | * @return array |
489 | 489 | */ |
490 | 490 | function wpinv_get_spain_states_list() { |
491 | - return apply_filters( 'wpinv_spain_states', wpinv_get_country_states( 'ES' ) ); |
|
491 | + return apply_filters('wpinv_spain_states', wpinv_get_country_states('ES')); |
|
492 | 492 | } |
493 | 493 | |
494 | 494 | function wpinv_get_states_field() { |
495 | - if( empty( $_POST['country'] ) ) { |
|
495 | + if (empty($_POST['country'])) { |
|
496 | 496 | $_POST['country'] = wpinv_get_default_country(); |
497 | 497 | } |
498 | - $states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) ); |
|
498 | + $states = wpinv_get_country_states(sanitize_text_field($_POST['country'])); |
|
499 | 499 | |
500 | - if( !empty( $states ) ) { |
|
501 | - $sanitized_field_name = sanitize_text_field( $_POST['field_name'] ); |
|
500 | + if (!empty($states)) { |
|
501 | + $sanitized_field_name = sanitize_text_field($_POST['field_name']); |
|
502 | 502 | |
503 | 503 | $args = array( |
504 | 504 | 'name' => $sanitized_field_name, |
505 | 505 | 'id' => $sanitized_field_name, |
506 | 506 | 'class' => $sanitized_field_name . 'custom-select wpinv-select wpi_select2', |
507 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
507 | + 'options' => array_merge(array('' => ''), $states), |
|
508 | 508 | 'show_option_all' => false, |
509 | 509 | 'show_option_none' => false |
510 | 510 | ); |
511 | 511 | |
512 | - $response = wpinv_html_select( $args ); |
|
512 | + $response = wpinv_html_select($args); |
|
513 | 513 | |
514 | 514 | } else { |
515 | 515 | $response = 'nostates'; |
@@ -518,10 +518,10 @@ discard block |
||
518 | 518 | return $response; |
519 | 519 | } |
520 | 520 | |
521 | -function wpinv_default_billing_country( $country = '', $user_id = 0 ) { |
|
522 | - $country = !empty( $country ) ? $country : wpinv_get_default_country(); |
|
521 | +function wpinv_default_billing_country($country = '', $user_id = 0) { |
|
522 | + $country = !empty($country) ? $country : wpinv_get_default_country(); |
|
523 | 523 | |
524 | - return apply_filters( 'wpinv_default_billing_country', $country, $user_id ); |
|
524 | + return apply_filters('wpinv_default_billing_country', $country, $user_id); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | /** |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | */ |
534 | 534 | function wpinv_get_address_formats() { |
535 | 535 | |
536 | - return apply_filters( 'wpinv_localisation_address_formats', |
|
536 | + return apply_filters('wpinv_localisation_address_formats', |
|
537 | 537 | array( |
538 | 538 | 'default' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}\n{{zip}}\n{{country}}", |
539 | 539 | 'AU' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}} {{zip}}\n{{country}}", |
@@ -582,9 +582,9 @@ discard block |
||
582 | 582 | * @see `wpinv_get_invoice_address_replacements` |
583 | 583 | * @return string |
584 | 584 | */ |
585 | -function wpinv_get_full_address_format( $country = false) { |
|
585 | +function wpinv_get_full_address_format($country = false) { |
|
586 | 586 | |
587 | - if( empty( $country ) ) { |
|
587 | + if (empty($country)) { |
|
588 | 588 | $country = wpinv_get_default_country(); |
589 | 589 | } |
590 | 590 | |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | $formats = wpinv_get_address_formats(); |
593 | 593 | |
594 | 594 | // Get format for the specified country. |
595 | - $format = ( $country && isset( $formats[ $country ] ) ) ? $formats[ $country ] : $formats['default']; |
|
595 | + $format = ($country && isset($formats[$country])) ? $formats[$country] : $formats['default']; |
|
596 | 596 | |
597 | 597 | /** |
598 | 598 | * Filters the address format to use on Invoices. |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | * @param string $format The address format to use. |
605 | 605 | * @param string $country The country who's address format is being retrieved. |
606 | 606 | */ |
607 | - return apply_filters( 'wpinv_get_full_address_format', $format, $country ); |
|
607 | + return apply_filters('wpinv_get_full_address_format', $format, $country); |
|
608 | 608 | } |
609 | 609 | |
610 | 610 | /** |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | * @param array $billing_details customer's billing details |
616 | 616 | * @return array |
617 | 617 | */ |
618 | -function wpinv_get_invoice_address_replacements( $billing_details ) { |
|
618 | +function wpinv_get_invoice_address_replacements($billing_details) { |
|
619 | 619 | |
620 | 620 | $default_args = array( |
621 | 621 | 'address' => '', |
@@ -628,22 +628,22 @@ discard block |
||
628 | 628 | 'company' => '', |
629 | 629 | ); |
630 | 630 | |
631 | - $args = map_deep( wp_parse_args( $billing_details, $default_args ), 'trim' ); |
|
631 | + $args = map_deep(wp_parse_args($billing_details, $default_args), 'trim'); |
|
632 | 632 | $state = $args['state']; |
633 | 633 | $country = $args['country']; |
634 | 634 | |
635 | 635 | // Handle full country name. |
636 | - $full_country = empty( $country ) ? $country : wpinv_country_name( $country ); |
|
636 | + $full_country = empty($country) ? $country : wpinv_country_name($country); |
|
637 | 637 | |
638 | 638 | // Handle full state name. |
639 | - $full_state = ( $country && $state ) ? wpinv_state_name( $state, $country ) : $state; |
|
639 | + $full_state = ($country && $state) ? wpinv_state_name($state, $country) : $state; |
|
640 | 640 | |
641 | 641 | $args['postcode'] = $args['zip']; |
642 | 642 | $args['name'] = $args['first_name'] . ' ' . $args['last_name']; |
643 | 643 | $args['state'] = $full_state; |
644 | 644 | $args['state_code'] = $state; |
645 | 645 | $args['country'] = $full_country; |
646 | - $args['country_code']= $country; |
|
646 | + $args['country_code'] = $country; |
|
647 | 647 | |
648 | 648 | /** |
649 | 649 | * Filters the address format replacements to use on Invoices. |
@@ -654,14 +654,14 @@ discard block |
||
654 | 654 | * @param array $replacements The address replacements to use. |
655 | 655 | * @param array $billing_details The billing details to use. |
656 | 656 | */ |
657 | - $replacements = apply_filters( 'wpinv_get_invoice_address_replacements', $args, $billing_details ); |
|
657 | + $replacements = apply_filters('wpinv_get_invoice_address_replacements', $args, $billing_details); |
|
658 | 658 | |
659 | 659 | $return = array(); |
660 | 660 | |
661 | - foreach( $replacements as $key => $value ) { |
|
662 | - $value = is_scalar( $value ) ? trim( sanitize_text_field( $value ) ) : ''; |
|
661 | + foreach ($replacements as $key => $value) { |
|
662 | + $value = is_scalar($value) ? trim(sanitize_text_field($value)) : ''; |
|
663 | 663 | $return['{{' . $key . '}}'] = $value; |
664 | - $return['{{' . $key . '_upper}}'] = wpinv_utf8_strtoupper( $value ); |
|
664 | + $return['{{' . $key . '_upper}}'] = wpinv_utf8_strtoupper($value); |
|
665 | 665 | } |
666 | 666 | |
667 | 667 | return $return; |
@@ -675,6 +675,6 @@ discard block |
||
675 | 675 | * @since 1.0.14 |
676 | 676 | * @return string |
677 | 677 | */ |
678 | -function wpinv_trim_formatted_address_line( $line ) { |
|
679 | - return trim( $line, ', ' ); |
|
678 | +function wpinv_trim_formatted_address_line($line) { |
|
679 | + return trim($line, ', '); |
|
680 | 680 | } |
681 | 681 | \ No newline at end of file |
@@ -15,332 +15,332 @@ |
||
15 | 15 | class GetPaid_Post_Types { |
16 | 16 | |
17 | 17 | /** |
18 | - * Hook in methods. |
|
19 | - */ |
|
20 | - public static function init() { |
|
21 | - add_action( 'init', array( __CLASS__, 'register_post_types' ), 1 ); |
|
22 | - add_action( 'init', array( __CLASS__, 'register_post_status' ), 4 ); |
|
23 | - add_action( 'getpaid_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) ); |
|
24 | - add_action( 'getpaid_after_register_post_types', array( __CLASS__, 'maybe_flush_rewrite_rules' ) ); |
|
25 | - } |
|
18 | + * Hook in methods. |
|
19 | + */ |
|
20 | + public static function init() { |
|
21 | + add_action( 'init', array( __CLASS__, 'register_post_types' ), 1 ); |
|
22 | + add_action( 'init', array( __CLASS__, 'register_post_status' ), 4 ); |
|
23 | + add_action( 'getpaid_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) ); |
|
24 | + add_action( 'getpaid_after_register_post_types', array( __CLASS__, 'maybe_flush_rewrite_rules' ) ); |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * Register core post types. |
|
29 | - */ |
|
30 | - public static function register_post_types() { |
|
27 | + /** |
|
28 | + * Register core post types. |
|
29 | + */ |
|
30 | + public static function register_post_types() { |
|
31 | 31 | |
32 | - if ( ! is_blog_installed() || post_type_exists( 'wpi_item' ) ) { |
|
33 | - return; |
|
34 | - } |
|
32 | + if ( ! is_blog_installed() || post_type_exists( 'wpi_item' ) ) { |
|
33 | + return; |
|
34 | + } |
|
35 | 35 | |
36 | - // Fires before registering post types. |
|
37 | - do_action( 'getpaid_register_post_types' ); |
|
36 | + // Fires before registering post types. |
|
37 | + do_action( 'getpaid_register_post_types' ); |
|
38 | 38 | |
39 | - // Register item post type. |
|
40 | - register_post_type( |
|
41 | - 'wpi_item', |
|
42 | - apply_filters( |
|
43 | - 'wpinv_register_post_type_invoice_item', |
|
44 | - array( |
|
45 | - 'labels' => array( |
|
46 | - 'name' => __( 'Items', 'invoicing' ), |
|
47 | - 'singular_name' => __( 'Item', 'invoicing' ), |
|
48 | - 'all_items' => __( 'All Items', 'invoicing' ), |
|
49 | - 'menu_name' => _x( 'Items', 'Admin menu name', 'invoicing' ), |
|
50 | - 'add_new' => __( 'Add New', 'invoicing' ), |
|
51 | - 'add_new_item' => __( 'Add new item', 'invoicing' ), |
|
52 | - 'edit' => __( 'Edit', 'invoicing' ), |
|
53 | - 'edit_item' => __( 'Edit item', 'invoicing' ), |
|
54 | - 'new_item' => __( 'New item', 'invoicing' ), |
|
55 | - 'view_item' => __( 'View item', 'invoicing' ), |
|
56 | - 'view_items' => __( 'View items', 'invoicing' ), |
|
57 | - 'search_items' => __( 'Search items', 'invoicing' ), |
|
58 | - 'not_found' => __( 'No Items found', 'invoicing' ), |
|
59 | - 'not_found_in_trash' => __( 'No Items found in trash', 'invoicing' ), |
|
60 | - 'parent' => __( 'Parent item', 'invoicing' ), |
|
61 | - 'featured_image' => __( 'item image', 'invoicing' ), |
|
62 | - 'set_featured_image' => __( 'Set item image', 'invoicing' ), |
|
63 | - 'remove_featured_image' => __( 'Remove item image', 'invoicing' ), |
|
64 | - 'use_featured_image' => __( 'Use as item image', 'invoicing' ), |
|
65 | - 'insert_into_item' => __( 'Insert into item', 'invoicing' ), |
|
66 | - 'uploaded_to_this_item' => __( 'Uploaded to this item', 'invoicing' ), |
|
67 | - 'filter_items_list' => __( 'Filter items', 'invoicing' ), |
|
68 | - 'items_list_navigation' => __( 'Items navigation', 'invoicing' ), |
|
69 | - 'items_list' => __( 'Items list', 'invoicing' ), |
|
70 | - ), |
|
71 | - 'description' => __( 'This is where you can add new invoice items.', 'invoicing' ), |
|
72 | - 'public' => false, |
|
73 | - 'has_archive' => false, |
|
74 | - '_builtin' => false, |
|
75 | - 'show_ui' => true, |
|
76 | - 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
77 | - 'show_in_nav_menus' => false, |
|
78 | - 'supports' => array( 'title', 'excerpt' ), |
|
79 | - 'register_meta_box_cb' => 'wpinv_register_item_meta_boxes', |
|
80 | - 'rewrite' => false, |
|
81 | - 'query_var' => false, |
|
82 | - 'capability_type' => 'wpi_item', |
|
83 | - 'map_meta_cap' => true, |
|
84 | - 'show_in_admin_bar' => true, |
|
85 | - 'can_export' => true, |
|
86 | - ) |
|
87 | - ) |
|
88 | - ); |
|
39 | + // Register item post type. |
|
40 | + register_post_type( |
|
41 | + 'wpi_item', |
|
42 | + apply_filters( |
|
43 | + 'wpinv_register_post_type_invoice_item', |
|
44 | + array( |
|
45 | + 'labels' => array( |
|
46 | + 'name' => __( 'Items', 'invoicing' ), |
|
47 | + 'singular_name' => __( 'Item', 'invoicing' ), |
|
48 | + 'all_items' => __( 'All Items', 'invoicing' ), |
|
49 | + 'menu_name' => _x( 'Items', 'Admin menu name', 'invoicing' ), |
|
50 | + 'add_new' => __( 'Add New', 'invoicing' ), |
|
51 | + 'add_new_item' => __( 'Add new item', 'invoicing' ), |
|
52 | + 'edit' => __( 'Edit', 'invoicing' ), |
|
53 | + 'edit_item' => __( 'Edit item', 'invoicing' ), |
|
54 | + 'new_item' => __( 'New item', 'invoicing' ), |
|
55 | + 'view_item' => __( 'View item', 'invoicing' ), |
|
56 | + 'view_items' => __( 'View items', 'invoicing' ), |
|
57 | + 'search_items' => __( 'Search items', 'invoicing' ), |
|
58 | + 'not_found' => __( 'No Items found', 'invoicing' ), |
|
59 | + 'not_found_in_trash' => __( 'No Items found in trash', 'invoicing' ), |
|
60 | + 'parent' => __( 'Parent item', 'invoicing' ), |
|
61 | + 'featured_image' => __( 'item image', 'invoicing' ), |
|
62 | + 'set_featured_image' => __( 'Set item image', 'invoicing' ), |
|
63 | + 'remove_featured_image' => __( 'Remove item image', 'invoicing' ), |
|
64 | + 'use_featured_image' => __( 'Use as item image', 'invoicing' ), |
|
65 | + 'insert_into_item' => __( 'Insert into item', 'invoicing' ), |
|
66 | + 'uploaded_to_this_item' => __( 'Uploaded to this item', 'invoicing' ), |
|
67 | + 'filter_items_list' => __( 'Filter items', 'invoicing' ), |
|
68 | + 'items_list_navigation' => __( 'Items navigation', 'invoicing' ), |
|
69 | + 'items_list' => __( 'Items list', 'invoicing' ), |
|
70 | + ), |
|
71 | + 'description' => __( 'This is where you can add new invoice items.', 'invoicing' ), |
|
72 | + 'public' => false, |
|
73 | + 'has_archive' => false, |
|
74 | + '_builtin' => false, |
|
75 | + 'show_ui' => true, |
|
76 | + 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
77 | + 'show_in_nav_menus' => false, |
|
78 | + 'supports' => array( 'title', 'excerpt' ), |
|
79 | + 'register_meta_box_cb' => 'wpinv_register_item_meta_boxes', |
|
80 | + 'rewrite' => false, |
|
81 | + 'query_var' => false, |
|
82 | + 'capability_type' => 'wpi_item', |
|
83 | + 'map_meta_cap' => true, |
|
84 | + 'show_in_admin_bar' => true, |
|
85 | + 'can_export' => true, |
|
86 | + ) |
|
87 | + ) |
|
88 | + ); |
|
89 | 89 | |
90 | - // Register payment form post type. |
|
91 | - register_post_type( |
|
92 | - 'wpi_payment_form', |
|
93 | - apply_filters( |
|
94 | - 'wpinv_register_post_type_payment_form', |
|
95 | - array( |
|
96 | - 'labels' => array( |
|
97 | - 'name' => _x( 'Payment Forms', 'post type general name', 'invoicing' ), |
|
98 | - 'singular_name' => _x( 'Payment Form', 'post type singular name', 'invoicing' ), |
|
99 | - 'menu_name' => _x( 'Payment Forms', 'admin menu', 'invoicing' ), |
|
100 | - 'name_admin_bar' => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ), |
|
101 | - 'add_new' => _x( 'Add New', 'Payment Form', 'invoicing' ), |
|
102 | - 'add_new_item' => __( 'Add New Payment Form', 'invoicing' ), |
|
103 | - 'new_item' => __( 'New Payment Form', 'invoicing' ), |
|
104 | - 'edit_item' => __( 'Edit Payment Form', 'invoicing' ), |
|
105 | - 'view_item' => __( 'View Payment Form', 'invoicing' ), |
|
106 | - 'all_items' => __( 'Payment Forms', 'invoicing' ), |
|
107 | - 'search_items' => __( 'Search Payment Forms', 'invoicing' ), |
|
108 | - 'parent_item_colon' => __( 'Parent Payment Forms:', 'invoicing' ), |
|
109 | - 'not_found' => __( 'No payment forms found.', 'invoicing' ), |
|
110 | - 'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' ) |
|
111 | - ), |
|
112 | - 'description' => __( 'Add new payment forms.', 'invoicing' ), |
|
113 | - 'public' => false, |
|
114 | - 'show_ui' => true, |
|
115 | - 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : true, |
|
116 | - 'show_in_nav_menus' => false, |
|
117 | - 'query_var' => false, |
|
118 | - 'rewrite' => true, |
|
119 | - 'map_meta_cap' => true, |
|
120 | - 'has_archive' => false, |
|
121 | - 'hierarchical' => false, |
|
122 | - 'menu_position' => null, |
|
123 | - 'supports' => array( 'title' ), |
|
124 | - 'menu_icon' => 'dashicons-media-form', |
|
125 | - ) |
|
126 | - ) |
|
127 | - ); |
|
90 | + // Register payment form post type. |
|
91 | + register_post_type( |
|
92 | + 'wpi_payment_form', |
|
93 | + apply_filters( |
|
94 | + 'wpinv_register_post_type_payment_form', |
|
95 | + array( |
|
96 | + 'labels' => array( |
|
97 | + 'name' => _x( 'Payment Forms', 'post type general name', 'invoicing' ), |
|
98 | + 'singular_name' => _x( 'Payment Form', 'post type singular name', 'invoicing' ), |
|
99 | + 'menu_name' => _x( 'Payment Forms', 'admin menu', 'invoicing' ), |
|
100 | + 'name_admin_bar' => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ), |
|
101 | + 'add_new' => _x( 'Add New', 'Payment Form', 'invoicing' ), |
|
102 | + 'add_new_item' => __( 'Add New Payment Form', 'invoicing' ), |
|
103 | + 'new_item' => __( 'New Payment Form', 'invoicing' ), |
|
104 | + 'edit_item' => __( 'Edit Payment Form', 'invoicing' ), |
|
105 | + 'view_item' => __( 'View Payment Form', 'invoicing' ), |
|
106 | + 'all_items' => __( 'Payment Forms', 'invoicing' ), |
|
107 | + 'search_items' => __( 'Search Payment Forms', 'invoicing' ), |
|
108 | + 'parent_item_colon' => __( 'Parent Payment Forms:', 'invoicing' ), |
|
109 | + 'not_found' => __( 'No payment forms found.', 'invoicing' ), |
|
110 | + 'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' ) |
|
111 | + ), |
|
112 | + 'description' => __( 'Add new payment forms.', 'invoicing' ), |
|
113 | + 'public' => false, |
|
114 | + 'show_ui' => true, |
|
115 | + 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : true, |
|
116 | + 'show_in_nav_menus' => false, |
|
117 | + 'query_var' => false, |
|
118 | + 'rewrite' => true, |
|
119 | + 'map_meta_cap' => true, |
|
120 | + 'has_archive' => false, |
|
121 | + 'hierarchical' => false, |
|
122 | + 'menu_position' => null, |
|
123 | + 'supports' => array( 'title' ), |
|
124 | + 'menu_icon' => 'dashicons-media-form', |
|
125 | + ) |
|
126 | + ) |
|
127 | + ); |
|
128 | 128 | |
129 | - // Register invoice post type. |
|
130 | - register_post_type( |
|
131 | - 'wpi_invoice', |
|
132 | - apply_filters( |
|
133 | - 'wpinv_register_post_type_invoice', |
|
134 | - array( |
|
135 | - 'labels' => array( |
|
136 | - 'name' => __( 'Invoices', 'invoicing' ), |
|
137 | - 'singular_name' => __( 'Invoice', 'invoicing' ), |
|
138 | - 'all_items' => __( 'All Invoices', 'invoicing' ), |
|
139 | - 'menu_name' => _x( 'Invoices', 'Admin menu name', 'invoicing' ), |
|
140 | - 'add_new' => __( 'Add New', 'invoicing' ), |
|
141 | - 'add_new_item' => __( 'Add new invoice', 'invoicing' ), |
|
142 | - 'edit' => __( 'Edit', 'invoicing' ), |
|
143 | - 'edit_item' => __( 'Edit invoice', 'invoicing' ), |
|
144 | - 'new_item' => __( 'New invoice', 'invoicing' ), |
|
145 | - 'view_item' => __( 'View invoice', 'invoicing' ), |
|
146 | - 'view_items' => __( 'View Invoices', 'invoicing' ), |
|
147 | - 'search_items' => __( 'Search invoices', 'invoicing' ), |
|
148 | - 'not_found' => __( 'No invoices found', 'invoicing' ), |
|
149 | - 'not_found_in_trash' => __( 'No invoices found in trash', 'invoicing' ), |
|
150 | - 'parent' => __( 'Parent invoice', 'invoicing' ), |
|
151 | - 'featured_image' => __( 'Invoice image', 'invoicing' ), |
|
152 | - 'set_featured_image' => __( 'Set invoice image', 'invoicing' ), |
|
153 | - 'remove_featured_image' => __( 'Remove invoice image', 'invoicing' ), |
|
154 | - 'use_featured_image' => __( 'Use as invoice image', 'invoicing' ), |
|
155 | - 'insert_into_item' => __( 'Insert into invoice', 'invoicing' ), |
|
156 | - 'uploaded_to_this_item' => __( 'Uploaded to this invoice', 'invoicing' ), |
|
157 | - 'filter_items_list' => __( 'Filter invoices', 'invoicing' ), |
|
158 | - 'items_list_navigation' => __( 'Invoices navigation', 'invoicing' ), |
|
159 | - 'items_list' => __( 'Invoices list', 'invoicing' ), |
|
160 | - ), |
|
161 | - 'description' => __( 'This is where invoices are stored.', 'invoicing' ), |
|
162 | - 'public' => true, |
|
163 | - 'has_archive' => false, |
|
164 | - 'publicly_queryable' => true, |
|
165 | - 'exclude_from_search' => true, |
|
166 | - 'show_ui' => true, |
|
167 | - 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
168 | - 'show_in_nav_menus' => false, |
|
169 | - 'supports' => array( 'title', 'author', 'excerpt' ), |
|
170 | - 'rewrite' => true, |
|
171 | - 'query_var' => false, |
|
172 | - 'capability_type' => 'wpi_invoice', |
|
173 | - 'map_meta_cap' => true, |
|
174 | - 'show_in_admin_bar' => true, |
|
175 | - 'can_export' => true, |
|
176 | - 'hierarchical' => false, |
|
177 | - 'menu_position' => null, |
|
178 | - 'menu_icon' => 'dashicons-media-spreadsheet', |
|
179 | - ) |
|
180 | - ) |
|
181 | - ); |
|
129 | + // Register invoice post type. |
|
130 | + register_post_type( |
|
131 | + 'wpi_invoice', |
|
132 | + apply_filters( |
|
133 | + 'wpinv_register_post_type_invoice', |
|
134 | + array( |
|
135 | + 'labels' => array( |
|
136 | + 'name' => __( 'Invoices', 'invoicing' ), |
|
137 | + 'singular_name' => __( 'Invoice', 'invoicing' ), |
|
138 | + 'all_items' => __( 'All Invoices', 'invoicing' ), |
|
139 | + 'menu_name' => _x( 'Invoices', 'Admin menu name', 'invoicing' ), |
|
140 | + 'add_new' => __( 'Add New', 'invoicing' ), |
|
141 | + 'add_new_item' => __( 'Add new invoice', 'invoicing' ), |
|
142 | + 'edit' => __( 'Edit', 'invoicing' ), |
|
143 | + 'edit_item' => __( 'Edit invoice', 'invoicing' ), |
|
144 | + 'new_item' => __( 'New invoice', 'invoicing' ), |
|
145 | + 'view_item' => __( 'View invoice', 'invoicing' ), |
|
146 | + 'view_items' => __( 'View Invoices', 'invoicing' ), |
|
147 | + 'search_items' => __( 'Search invoices', 'invoicing' ), |
|
148 | + 'not_found' => __( 'No invoices found', 'invoicing' ), |
|
149 | + 'not_found_in_trash' => __( 'No invoices found in trash', 'invoicing' ), |
|
150 | + 'parent' => __( 'Parent invoice', 'invoicing' ), |
|
151 | + 'featured_image' => __( 'Invoice image', 'invoicing' ), |
|
152 | + 'set_featured_image' => __( 'Set invoice image', 'invoicing' ), |
|
153 | + 'remove_featured_image' => __( 'Remove invoice image', 'invoicing' ), |
|
154 | + 'use_featured_image' => __( 'Use as invoice image', 'invoicing' ), |
|
155 | + 'insert_into_item' => __( 'Insert into invoice', 'invoicing' ), |
|
156 | + 'uploaded_to_this_item' => __( 'Uploaded to this invoice', 'invoicing' ), |
|
157 | + 'filter_items_list' => __( 'Filter invoices', 'invoicing' ), |
|
158 | + 'items_list_navigation' => __( 'Invoices navigation', 'invoicing' ), |
|
159 | + 'items_list' => __( 'Invoices list', 'invoicing' ), |
|
160 | + ), |
|
161 | + 'description' => __( 'This is where invoices are stored.', 'invoicing' ), |
|
162 | + 'public' => true, |
|
163 | + 'has_archive' => false, |
|
164 | + 'publicly_queryable' => true, |
|
165 | + 'exclude_from_search' => true, |
|
166 | + 'show_ui' => true, |
|
167 | + 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
168 | + 'show_in_nav_menus' => false, |
|
169 | + 'supports' => array( 'title', 'author', 'excerpt' ), |
|
170 | + 'rewrite' => true, |
|
171 | + 'query_var' => false, |
|
172 | + 'capability_type' => 'wpi_invoice', |
|
173 | + 'map_meta_cap' => true, |
|
174 | + 'show_in_admin_bar' => true, |
|
175 | + 'can_export' => true, |
|
176 | + 'hierarchical' => false, |
|
177 | + 'menu_position' => null, |
|
178 | + 'menu_icon' => 'dashicons-media-spreadsheet', |
|
179 | + ) |
|
180 | + ) |
|
181 | + ); |
|
182 | 182 | |
183 | - // Register discount post type. |
|
184 | - register_post_type( |
|
185 | - 'wpi_discount', |
|
186 | - apply_filters( |
|
187 | - 'wpinv_register_post_type_discount', |
|
188 | - array( |
|
189 | - 'labels' => array( |
|
190 | - 'name' => __( 'Discounts', 'invoicing' ), |
|
191 | - 'singular_name' => __( 'Discount', 'invoicing' ), |
|
192 | - 'all_items' => __( 'All Discounts', 'invoicing' ), |
|
193 | - 'menu_name' => _x( 'Discounts', 'Admin menu name', 'invoicing' ), |
|
194 | - 'add_new' => __( 'Add New', 'invoicing' ), |
|
195 | - 'add_new_item' => __( 'Add new discount', 'invoicing' ), |
|
196 | - 'edit' => __( 'Edit', 'invoicing' ), |
|
197 | - 'edit_item' => __( 'Edit discount', 'invoicing' ), |
|
198 | - 'new_item' => __( 'New discount', 'invoicing' ), |
|
199 | - 'view_item' => __( 'View discount', 'invoicing' ), |
|
200 | - 'view_items' => __( 'View Discounts', 'invoicing' ), |
|
201 | - 'search_items' => __( 'Search discounts', 'invoicing' ), |
|
202 | - 'not_found' => __( 'No discounts found', 'invoicing' ), |
|
203 | - 'not_found_in_trash' => __( 'No discounts found in trash', 'invoicing' ), |
|
204 | - 'parent' => __( 'Parent discount', 'invoicing' ), |
|
205 | - 'featured_image' => __( 'Discount image', 'invoicing' ), |
|
206 | - 'set_featured_image' => __( 'Set discount image', 'invoicing' ), |
|
207 | - 'remove_featured_image' => __( 'Remove discount image', 'invoicing' ), |
|
208 | - 'use_featured_image' => __( 'Use as discount image', 'invoicing' ), |
|
209 | - 'insert_into_item' => __( 'Insert into discount', 'invoicing' ), |
|
210 | - 'uploaded_to_this_item' => __( 'Uploaded to this discount', 'invoicing' ), |
|
211 | - 'filter_items_list' => __( 'Filter discounts', 'invoicing' ), |
|
212 | - 'items_list_navigation' => __( 'Discount navigation', 'invoicing' ), |
|
213 | - 'items_list' => __( 'Discounts list', 'invoicing' ), |
|
214 | - ), |
|
215 | - 'description' => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ), |
|
216 | - 'public' => false, |
|
217 | - 'can_export' => true, |
|
218 | - '_builtin' => false, |
|
219 | - 'publicly_queryable' => false, |
|
220 | - 'exclude_from_search'=> true, |
|
221 | - 'show_ui' => true, |
|
222 | - 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
223 | - 'query_var' => false, |
|
224 | - 'rewrite' => false, |
|
225 | - 'capability_type' => 'wpi_discount', |
|
226 | - 'map_meta_cap' => true, |
|
227 | - 'has_archive' => false, |
|
228 | - 'hierarchical' => false, |
|
229 | - 'supports' => array( 'title', 'excerpt' ), |
|
230 | - 'register_meta_box_cb' => 'wpinv_register_discount_meta_boxes', |
|
231 | - 'show_in_nav_menus' => false, |
|
232 | - 'show_in_admin_bar' => true, |
|
233 | - 'menu_position' => null, |
|
234 | - ) |
|
235 | - ) |
|
236 | - ); |
|
183 | + // Register discount post type. |
|
184 | + register_post_type( |
|
185 | + 'wpi_discount', |
|
186 | + apply_filters( |
|
187 | + 'wpinv_register_post_type_discount', |
|
188 | + array( |
|
189 | + 'labels' => array( |
|
190 | + 'name' => __( 'Discounts', 'invoicing' ), |
|
191 | + 'singular_name' => __( 'Discount', 'invoicing' ), |
|
192 | + 'all_items' => __( 'All Discounts', 'invoicing' ), |
|
193 | + 'menu_name' => _x( 'Discounts', 'Admin menu name', 'invoicing' ), |
|
194 | + 'add_new' => __( 'Add New', 'invoicing' ), |
|
195 | + 'add_new_item' => __( 'Add new discount', 'invoicing' ), |
|
196 | + 'edit' => __( 'Edit', 'invoicing' ), |
|
197 | + 'edit_item' => __( 'Edit discount', 'invoicing' ), |
|
198 | + 'new_item' => __( 'New discount', 'invoicing' ), |
|
199 | + 'view_item' => __( 'View discount', 'invoicing' ), |
|
200 | + 'view_items' => __( 'View Discounts', 'invoicing' ), |
|
201 | + 'search_items' => __( 'Search discounts', 'invoicing' ), |
|
202 | + 'not_found' => __( 'No discounts found', 'invoicing' ), |
|
203 | + 'not_found_in_trash' => __( 'No discounts found in trash', 'invoicing' ), |
|
204 | + 'parent' => __( 'Parent discount', 'invoicing' ), |
|
205 | + 'featured_image' => __( 'Discount image', 'invoicing' ), |
|
206 | + 'set_featured_image' => __( 'Set discount image', 'invoicing' ), |
|
207 | + 'remove_featured_image' => __( 'Remove discount image', 'invoicing' ), |
|
208 | + 'use_featured_image' => __( 'Use as discount image', 'invoicing' ), |
|
209 | + 'insert_into_item' => __( 'Insert into discount', 'invoicing' ), |
|
210 | + 'uploaded_to_this_item' => __( 'Uploaded to this discount', 'invoicing' ), |
|
211 | + 'filter_items_list' => __( 'Filter discounts', 'invoicing' ), |
|
212 | + 'items_list_navigation' => __( 'Discount navigation', 'invoicing' ), |
|
213 | + 'items_list' => __( 'Discounts list', 'invoicing' ), |
|
214 | + ), |
|
215 | + 'description' => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ), |
|
216 | + 'public' => false, |
|
217 | + 'can_export' => true, |
|
218 | + '_builtin' => false, |
|
219 | + 'publicly_queryable' => false, |
|
220 | + 'exclude_from_search'=> true, |
|
221 | + 'show_ui' => true, |
|
222 | + 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
223 | + 'query_var' => false, |
|
224 | + 'rewrite' => false, |
|
225 | + 'capability_type' => 'wpi_discount', |
|
226 | + 'map_meta_cap' => true, |
|
227 | + 'has_archive' => false, |
|
228 | + 'hierarchical' => false, |
|
229 | + 'supports' => array( 'title', 'excerpt' ), |
|
230 | + 'register_meta_box_cb' => 'wpinv_register_discount_meta_boxes', |
|
231 | + 'show_in_nav_menus' => false, |
|
232 | + 'show_in_admin_bar' => true, |
|
233 | + 'menu_position' => null, |
|
234 | + ) |
|
235 | + ) |
|
236 | + ); |
|
237 | 237 | |
238 | - do_action( 'getpaid_after_register_post_types' ); |
|
239 | - } |
|
238 | + do_action( 'getpaid_after_register_post_types' ); |
|
239 | + } |
|
240 | 240 | |
241 | - /** |
|
242 | - * Register our custom post statuses. |
|
243 | - */ |
|
244 | - public static function register_post_status() { |
|
241 | + /** |
|
242 | + * Register our custom post statuses. |
|
243 | + */ |
|
244 | + public static function register_post_status() { |
|
245 | 245 | |
246 | - $invoice_statuses = apply_filters( |
|
247 | - 'getpaid_register_invoice_post_statuses', |
|
248 | - array( |
|
246 | + $invoice_statuses = apply_filters( |
|
247 | + 'getpaid_register_invoice_post_statuses', |
|
248 | + array( |
|
249 | 249 | |
250 | - 'wpi-pending' => array( |
|
251 | - 'label' => _x( 'Pending Payment', 'Invoice status', 'invoicing' ), |
|
252 | - 'public' => true, |
|
253 | - 'exclude_from_search' => true, |
|
254 | - 'show_in_admin_all_list' => true, |
|
255 | - 'show_in_admin_status_list' => true, |
|
256 | - /* translators: %s: number of invoices */ |
|
257 | - 'label_count' => _n_noop( 'Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing' ) |
|
258 | - ), |
|
250 | + 'wpi-pending' => array( |
|
251 | + 'label' => _x( 'Pending Payment', 'Invoice status', 'invoicing' ), |
|
252 | + 'public' => true, |
|
253 | + 'exclude_from_search' => true, |
|
254 | + 'show_in_admin_all_list' => true, |
|
255 | + 'show_in_admin_status_list' => true, |
|
256 | + /* translators: %s: number of invoices */ |
|
257 | + 'label_count' => _n_noop( 'Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing' ) |
|
258 | + ), |
|
259 | 259 | |
260 | - 'wpi-processing' => array( |
|
261 | - 'label' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
262 | - 'public' => true, |
|
263 | - 'exclude_from_search' => true, |
|
264 | - 'show_in_admin_all_list' => true, |
|
265 | - 'show_in_admin_status_list' => true, |
|
266 | - /* translators: %s: number of invoices */ |
|
267 | - 'label_count' => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' ) |
|
268 | - ), |
|
260 | + 'wpi-processing' => array( |
|
261 | + 'label' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
262 | + 'public' => true, |
|
263 | + 'exclude_from_search' => true, |
|
264 | + 'show_in_admin_all_list' => true, |
|
265 | + 'show_in_admin_status_list' => true, |
|
266 | + /* translators: %s: number of invoices */ |
|
267 | + 'label_count' => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' ) |
|
268 | + ), |
|
269 | 269 | |
270 | - 'wpi-onhold' => array( |
|
271 | - 'label' => _x( 'On Hold', 'Invoice status', 'invoicing' ), |
|
272 | - 'public' => true, |
|
273 | - 'exclude_from_search' => true, |
|
274 | - 'show_in_admin_all_list' => true, |
|
275 | - 'show_in_admin_status_list' => true, |
|
276 | - /* translators: %s: number of invoices */ |
|
277 | - 'label_count' => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' ) |
|
278 | - ), |
|
270 | + 'wpi-onhold' => array( |
|
271 | + 'label' => _x( 'On Hold', 'Invoice status', 'invoicing' ), |
|
272 | + 'public' => true, |
|
273 | + 'exclude_from_search' => true, |
|
274 | + 'show_in_admin_all_list' => true, |
|
275 | + 'show_in_admin_status_list' => true, |
|
276 | + /* translators: %s: number of invoices */ |
|
277 | + 'label_count' => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' ) |
|
278 | + ), |
|
279 | 279 | |
280 | - 'wpi-cancelled' => array( |
|
281 | - 'label' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
282 | - 'public' => true, |
|
283 | - 'exclude_from_search' => true, |
|
284 | - 'show_in_admin_all_list' => true, |
|
285 | - 'show_in_admin_status_list' => true, |
|
286 | - /* translators: %s: number of invoices */ |
|
287 | - 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' ) |
|
288 | - ), |
|
280 | + 'wpi-cancelled' => array( |
|
281 | + 'label' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
282 | + 'public' => true, |
|
283 | + 'exclude_from_search' => true, |
|
284 | + 'show_in_admin_all_list' => true, |
|
285 | + 'show_in_admin_status_list' => true, |
|
286 | + /* translators: %s: number of invoices */ |
|
287 | + 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' ) |
|
288 | + ), |
|
289 | 289 | |
290 | - 'wpi-refunded' => array( |
|
291 | - 'label' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
292 | - 'public' => true, |
|
293 | - 'exclude_from_search' => true, |
|
294 | - 'show_in_admin_all_list' => true, |
|
295 | - 'show_in_admin_status_list' => true, |
|
296 | - /* translators: %s: number of invoices */ |
|
297 | - 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' ) |
|
298 | - ), |
|
290 | + 'wpi-refunded' => array( |
|
291 | + 'label' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
292 | + 'public' => true, |
|
293 | + 'exclude_from_search' => true, |
|
294 | + 'show_in_admin_all_list' => true, |
|
295 | + 'show_in_admin_status_list' => true, |
|
296 | + /* translators: %s: number of invoices */ |
|
297 | + 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' ) |
|
298 | + ), |
|
299 | 299 | |
300 | - 'wpi-failed' => array( |
|
301 | - 'label' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
302 | - 'public' => true, |
|
303 | - 'exclude_from_search' => true, |
|
304 | - 'show_in_admin_all_list' => true, |
|
305 | - 'show_in_admin_status_list' => true, |
|
306 | - /* translators: %s: number of invoices */ |
|
307 | - 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' ) |
|
308 | - ), |
|
300 | + 'wpi-failed' => array( |
|
301 | + 'label' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
302 | + 'public' => true, |
|
303 | + 'exclude_from_search' => true, |
|
304 | + 'show_in_admin_all_list' => true, |
|
305 | + 'show_in_admin_status_list' => true, |
|
306 | + /* translators: %s: number of invoices */ |
|
307 | + 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' ) |
|
308 | + ), |
|
309 | 309 | |
310 | - 'wpi-renewal' => array( |
|
311 | - 'label' => _x( 'Renewal', 'Invoice status', 'invoicing' ), |
|
312 | - 'public' => true, |
|
313 | - 'exclude_from_search' => true, |
|
314 | - 'show_in_admin_all_list' => true, |
|
315 | - 'show_in_admin_status_list' => true, |
|
316 | - /* translators: %s: number of invoices */ |
|
317 | - 'label_count' => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' ) |
|
318 | - ) |
|
319 | - ) |
|
320 | - ); |
|
310 | + 'wpi-renewal' => array( |
|
311 | + 'label' => _x( 'Renewal', 'Invoice status', 'invoicing' ), |
|
312 | + 'public' => true, |
|
313 | + 'exclude_from_search' => true, |
|
314 | + 'show_in_admin_all_list' => true, |
|
315 | + 'show_in_admin_status_list' => true, |
|
316 | + /* translators: %s: number of invoices */ |
|
317 | + 'label_count' => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' ) |
|
318 | + ) |
|
319 | + ) |
|
320 | + ); |
|
321 | 321 | |
322 | - foreach ( $invoice_statuses as $invoice_statuse => $args ) { |
|
323 | - register_post_status( $invoice_statuse, $args ); |
|
324 | - } |
|
325 | - } |
|
322 | + foreach ( $invoice_statuses as $invoice_statuse => $args ) { |
|
323 | + register_post_status( $invoice_statuse, $args ); |
|
324 | + } |
|
325 | + } |
|
326 | 326 | |
327 | - /** |
|
328 | - * Flush rewrite rules. |
|
329 | - */ |
|
330 | - public static function flush_rewrite_rules() { |
|
331 | - flush_rewrite_rules(); |
|
332 | - } |
|
327 | + /** |
|
328 | + * Flush rewrite rules. |
|
329 | + */ |
|
330 | + public static function flush_rewrite_rules() { |
|
331 | + flush_rewrite_rules(); |
|
332 | + } |
|
333 | 333 | |
334 | - /** |
|
335 | - * Flush rules to prevent 404. |
|
336 | - * |
|
337 | - */ |
|
338 | - public static function maybe_flush_rewrite_rules() { |
|
339 | - if ( ! get_option( 'getpaid_flushed_rewrite_rules' ) ) { |
|
340 | - update_option( 'getpaid_flushed_rewrite_rules', '1' ); |
|
341 | - self::flush_rewrite_rules(); |
|
342 | - } |
|
343 | - } |
|
334 | + /** |
|
335 | + * Flush rules to prevent 404. |
|
336 | + * |
|
337 | + */ |
|
338 | + public static function maybe_flush_rewrite_rules() { |
|
339 | + if ( ! get_option( 'getpaid_flushed_rewrite_rules' ) ) { |
|
340 | + update_option( 'getpaid_flushed_rewrite_rules', '1' ); |
|
341 | + self::flush_rewrite_rules(); |
|
342 | + } |
|
343 | + } |
|
344 | 344 | |
345 | 345 | } |
346 | 346 | GetPaid_Post_Types::init(); |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Post types Class |
@@ -18,10 +18,10 @@ discard block |
||
18 | 18 | * Hook in methods. |
19 | 19 | */ |
20 | 20 | public static function init() { |
21 | - add_action( 'init', array( __CLASS__, 'register_post_types' ), 1 ); |
|
22 | - add_action( 'init', array( __CLASS__, 'register_post_status' ), 4 ); |
|
23 | - add_action( 'getpaid_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) ); |
|
24 | - add_action( 'getpaid_after_register_post_types', array( __CLASS__, 'maybe_flush_rewrite_rules' ) ); |
|
21 | + add_action('init', array(__CLASS__, 'register_post_types'), 1); |
|
22 | + add_action('init', array(__CLASS__, 'register_post_status'), 4); |
|
23 | + add_action('getpaid_flush_rewrite_rules', array(__CLASS__, 'flush_rewrite_rules')); |
|
24 | + add_action('getpaid_after_register_post_types', array(__CLASS__, 'maybe_flush_rewrite_rules')); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -29,12 +29,12 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public static function register_post_types() { |
31 | 31 | |
32 | - if ( ! is_blog_installed() || post_type_exists( 'wpi_item' ) ) { |
|
32 | + if (!is_blog_installed() || post_type_exists('wpi_item')) { |
|
33 | 33 | return; |
34 | 34 | } |
35 | 35 | |
36 | 36 | // Fires before registering post types. |
37 | - do_action( 'getpaid_register_post_types' ); |
|
37 | + do_action('getpaid_register_post_types'); |
|
38 | 38 | |
39 | 39 | // Register item post type. |
40 | 40 | register_post_type( |
@@ -43,39 +43,39 @@ discard block |
||
43 | 43 | 'wpinv_register_post_type_invoice_item', |
44 | 44 | array( |
45 | 45 | 'labels' => array( |
46 | - 'name' => __( 'Items', 'invoicing' ), |
|
47 | - 'singular_name' => __( 'Item', 'invoicing' ), |
|
48 | - 'all_items' => __( 'All Items', 'invoicing' ), |
|
49 | - 'menu_name' => _x( 'Items', 'Admin menu name', 'invoicing' ), |
|
50 | - 'add_new' => __( 'Add New', 'invoicing' ), |
|
51 | - 'add_new_item' => __( 'Add new item', 'invoicing' ), |
|
52 | - 'edit' => __( 'Edit', 'invoicing' ), |
|
53 | - 'edit_item' => __( 'Edit item', 'invoicing' ), |
|
54 | - 'new_item' => __( 'New item', 'invoicing' ), |
|
55 | - 'view_item' => __( 'View item', 'invoicing' ), |
|
56 | - 'view_items' => __( 'View items', 'invoicing' ), |
|
57 | - 'search_items' => __( 'Search items', 'invoicing' ), |
|
58 | - 'not_found' => __( 'No Items found', 'invoicing' ), |
|
59 | - 'not_found_in_trash' => __( 'No Items found in trash', 'invoicing' ), |
|
60 | - 'parent' => __( 'Parent item', 'invoicing' ), |
|
61 | - 'featured_image' => __( 'item image', 'invoicing' ), |
|
62 | - 'set_featured_image' => __( 'Set item image', 'invoicing' ), |
|
63 | - 'remove_featured_image' => __( 'Remove item image', 'invoicing' ), |
|
64 | - 'use_featured_image' => __( 'Use as item image', 'invoicing' ), |
|
65 | - 'insert_into_item' => __( 'Insert into item', 'invoicing' ), |
|
66 | - 'uploaded_to_this_item' => __( 'Uploaded to this item', 'invoicing' ), |
|
67 | - 'filter_items_list' => __( 'Filter items', 'invoicing' ), |
|
68 | - 'items_list_navigation' => __( 'Items navigation', 'invoicing' ), |
|
69 | - 'items_list' => __( 'Items list', 'invoicing' ), |
|
46 | + 'name' => __('Items', 'invoicing'), |
|
47 | + 'singular_name' => __('Item', 'invoicing'), |
|
48 | + 'all_items' => __('All Items', 'invoicing'), |
|
49 | + 'menu_name' => _x('Items', 'Admin menu name', 'invoicing'), |
|
50 | + 'add_new' => __('Add New', 'invoicing'), |
|
51 | + 'add_new_item' => __('Add new item', 'invoicing'), |
|
52 | + 'edit' => __('Edit', 'invoicing'), |
|
53 | + 'edit_item' => __('Edit item', 'invoicing'), |
|
54 | + 'new_item' => __('New item', 'invoicing'), |
|
55 | + 'view_item' => __('View item', 'invoicing'), |
|
56 | + 'view_items' => __('View items', 'invoicing'), |
|
57 | + 'search_items' => __('Search items', 'invoicing'), |
|
58 | + 'not_found' => __('No Items found', 'invoicing'), |
|
59 | + 'not_found_in_trash' => __('No Items found in trash', 'invoicing'), |
|
60 | + 'parent' => __('Parent item', 'invoicing'), |
|
61 | + 'featured_image' => __('item image', 'invoicing'), |
|
62 | + 'set_featured_image' => __('Set item image', 'invoicing'), |
|
63 | + 'remove_featured_image' => __('Remove item image', 'invoicing'), |
|
64 | + 'use_featured_image' => __('Use as item image', 'invoicing'), |
|
65 | + 'insert_into_item' => __('Insert into item', 'invoicing'), |
|
66 | + 'uploaded_to_this_item' => __('Uploaded to this item', 'invoicing'), |
|
67 | + 'filter_items_list' => __('Filter items', 'invoicing'), |
|
68 | + 'items_list_navigation' => __('Items navigation', 'invoicing'), |
|
69 | + 'items_list' => __('Items list', 'invoicing'), |
|
70 | 70 | ), |
71 | - 'description' => __( 'This is where you can add new invoice items.', 'invoicing' ), |
|
71 | + 'description' => __('This is where you can add new invoice items.', 'invoicing'), |
|
72 | 72 | 'public' => false, |
73 | 73 | 'has_archive' => false, |
74 | 74 | '_builtin' => false, |
75 | 75 | 'show_ui' => true, |
76 | 76 | 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
77 | 77 | 'show_in_nav_menus' => false, |
78 | - 'supports' => array( 'title', 'excerpt' ), |
|
78 | + 'supports' => array('title', 'excerpt'), |
|
79 | 79 | 'register_meta_box_cb' => 'wpinv_register_item_meta_boxes', |
80 | 80 | 'rewrite' => false, |
81 | 81 | 'query_var' => false, |
@@ -94,22 +94,22 @@ discard block |
||
94 | 94 | 'wpinv_register_post_type_payment_form', |
95 | 95 | array( |
96 | 96 | 'labels' => array( |
97 | - 'name' => _x( 'Payment Forms', 'post type general name', 'invoicing' ), |
|
98 | - 'singular_name' => _x( 'Payment Form', 'post type singular name', 'invoicing' ), |
|
99 | - 'menu_name' => _x( 'Payment Forms', 'admin menu', 'invoicing' ), |
|
100 | - 'name_admin_bar' => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ), |
|
101 | - 'add_new' => _x( 'Add New', 'Payment Form', 'invoicing' ), |
|
102 | - 'add_new_item' => __( 'Add New Payment Form', 'invoicing' ), |
|
103 | - 'new_item' => __( 'New Payment Form', 'invoicing' ), |
|
104 | - 'edit_item' => __( 'Edit Payment Form', 'invoicing' ), |
|
105 | - 'view_item' => __( 'View Payment Form', 'invoicing' ), |
|
106 | - 'all_items' => __( 'Payment Forms', 'invoicing' ), |
|
107 | - 'search_items' => __( 'Search Payment Forms', 'invoicing' ), |
|
108 | - 'parent_item_colon' => __( 'Parent Payment Forms:', 'invoicing' ), |
|
109 | - 'not_found' => __( 'No payment forms found.', 'invoicing' ), |
|
110 | - 'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' ) |
|
97 | + 'name' => _x('Payment Forms', 'post type general name', 'invoicing'), |
|
98 | + 'singular_name' => _x('Payment Form', 'post type singular name', 'invoicing'), |
|
99 | + 'menu_name' => _x('Payment Forms', 'admin menu', 'invoicing'), |
|
100 | + 'name_admin_bar' => _x('Payment Form', 'add new on admin bar', 'invoicing'), |
|
101 | + 'add_new' => _x('Add New', 'Payment Form', 'invoicing'), |
|
102 | + 'add_new_item' => __('Add New Payment Form', 'invoicing'), |
|
103 | + 'new_item' => __('New Payment Form', 'invoicing'), |
|
104 | + 'edit_item' => __('Edit Payment Form', 'invoicing'), |
|
105 | + 'view_item' => __('View Payment Form', 'invoicing'), |
|
106 | + 'all_items' => __('Payment Forms', 'invoicing'), |
|
107 | + 'search_items' => __('Search Payment Forms', 'invoicing'), |
|
108 | + 'parent_item_colon' => __('Parent Payment Forms:', 'invoicing'), |
|
109 | + 'not_found' => __('No payment forms found.', 'invoicing'), |
|
110 | + 'not_found_in_trash' => __('No payment forms found in trash.', 'invoicing') |
|
111 | 111 | ), |
112 | - 'description' => __( 'Add new payment forms.', 'invoicing' ), |
|
112 | + 'description' => __('Add new payment forms.', 'invoicing'), |
|
113 | 113 | 'public' => false, |
114 | 114 | 'show_ui' => true, |
115 | 115 | 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : true, |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | 'has_archive' => false, |
121 | 121 | 'hierarchical' => false, |
122 | 122 | 'menu_position' => null, |
123 | - 'supports' => array( 'title' ), |
|
123 | + 'supports' => array('title'), |
|
124 | 124 | 'menu_icon' => 'dashicons-media-form', |
125 | 125 | ) |
126 | 126 | ) |
@@ -133,32 +133,32 @@ discard block |
||
133 | 133 | 'wpinv_register_post_type_invoice', |
134 | 134 | array( |
135 | 135 | 'labels' => array( |
136 | - 'name' => __( 'Invoices', 'invoicing' ), |
|
137 | - 'singular_name' => __( 'Invoice', 'invoicing' ), |
|
138 | - 'all_items' => __( 'All Invoices', 'invoicing' ), |
|
139 | - 'menu_name' => _x( 'Invoices', 'Admin menu name', 'invoicing' ), |
|
140 | - 'add_new' => __( 'Add New', 'invoicing' ), |
|
141 | - 'add_new_item' => __( 'Add new invoice', 'invoicing' ), |
|
142 | - 'edit' => __( 'Edit', 'invoicing' ), |
|
143 | - 'edit_item' => __( 'Edit invoice', 'invoicing' ), |
|
144 | - 'new_item' => __( 'New invoice', 'invoicing' ), |
|
145 | - 'view_item' => __( 'View invoice', 'invoicing' ), |
|
146 | - 'view_items' => __( 'View Invoices', 'invoicing' ), |
|
147 | - 'search_items' => __( 'Search invoices', 'invoicing' ), |
|
148 | - 'not_found' => __( 'No invoices found', 'invoicing' ), |
|
149 | - 'not_found_in_trash' => __( 'No invoices found in trash', 'invoicing' ), |
|
150 | - 'parent' => __( 'Parent invoice', 'invoicing' ), |
|
151 | - 'featured_image' => __( 'Invoice image', 'invoicing' ), |
|
152 | - 'set_featured_image' => __( 'Set invoice image', 'invoicing' ), |
|
153 | - 'remove_featured_image' => __( 'Remove invoice image', 'invoicing' ), |
|
154 | - 'use_featured_image' => __( 'Use as invoice image', 'invoicing' ), |
|
155 | - 'insert_into_item' => __( 'Insert into invoice', 'invoicing' ), |
|
156 | - 'uploaded_to_this_item' => __( 'Uploaded to this invoice', 'invoicing' ), |
|
157 | - 'filter_items_list' => __( 'Filter invoices', 'invoicing' ), |
|
158 | - 'items_list_navigation' => __( 'Invoices navigation', 'invoicing' ), |
|
159 | - 'items_list' => __( 'Invoices list', 'invoicing' ), |
|
136 | + 'name' => __('Invoices', 'invoicing'), |
|
137 | + 'singular_name' => __('Invoice', 'invoicing'), |
|
138 | + 'all_items' => __('All Invoices', 'invoicing'), |
|
139 | + 'menu_name' => _x('Invoices', 'Admin menu name', 'invoicing'), |
|
140 | + 'add_new' => __('Add New', 'invoicing'), |
|
141 | + 'add_new_item' => __('Add new invoice', 'invoicing'), |
|
142 | + 'edit' => __('Edit', 'invoicing'), |
|
143 | + 'edit_item' => __('Edit invoice', 'invoicing'), |
|
144 | + 'new_item' => __('New invoice', 'invoicing'), |
|
145 | + 'view_item' => __('View invoice', 'invoicing'), |
|
146 | + 'view_items' => __('View Invoices', 'invoicing'), |
|
147 | + 'search_items' => __('Search invoices', 'invoicing'), |
|
148 | + 'not_found' => __('No invoices found', 'invoicing'), |
|
149 | + 'not_found_in_trash' => __('No invoices found in trash', 'invoicing'), |
|
150 | + 'parent' => __('Parent invoice', 'invoicing'), |
|
151 | + 'featured_image' => __('Invoice image', 'invoicing'), |
|
152 | + 'set_featured_image' => __('Set invoice image', 'invoicing'), |
|
153 | + 'remove_featured_image' => __('Remove invoice image', 'invoicing'), |
|
154 | + 'use_featured_image' => __('Use as invoice image', 'invoicing'), |
|
155 | + 'insert_into_item' => __('Insert into invoice', 'invoicing'), |
|
156 | + 'uploaded_to_this_item' => __('Uploaded to this invoice', 'invoicing'), |
|
157 | + 'filter_items_list' => __('Filter invoices', 'invoicing'), |
|
158 | + 'items_list_navigation' => __('Invoices navigation', 'invoicing'), |
|
159 | + 'items_list' => __('Invoices list', 'invoicing'), |
|
160 | 160 | ), |
161 | - 'description' => __( 'This is where invoices are stored.', 'invoicing' ), |
|
161 | + 'description' => __('This is where invoices are stored.', 'invoicing'), |
|
162 | 162 | 'public' => true, |
163 | 163 | 'has_archive' => false, |
164 | 164 | 'publicly_queryable' => true, |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | 'show_ui' => true, |
167 | 167 | 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
168 | 168 | 'show_in_nav_menus' => false, |
169 | - 'supports' => array( 'title', 'author', 'excerpt' ), |
|
169 | + 'supports' => array('title', 'author', 'excerpt'), |
|
170 | 170 | 'rewrite' => true, |
171 | 171 | 'query_var' => false, |
172 | 172 | 'capability_type' => 'wpi_invoice', |
@@ -187,32 +187,32 @@ discard block |
||
187 | 187 | 'wpinv_register_post_type_discount', |
188 | 188 | array( |
189 | 189 | 'labels' => array( |
190 | - 'name' => __( 'Discounts', 'invoicing' ), |
|
191 | - 'singular_name' => __( 'Discount', 'invoicing' ), |
|
192 | - 'all_items' => __( 'All Discounts', 'invoicing' ), |
|
193 | - 'menu_name' => _x( 'Discounts', 'Admin menu name', 'invoicing' ), |
|
194 | - 'add_new' => __( 'Add New', 'invoicing' ), |
|
195 | - 'add_new_item' => __( 'Add new discount', 'invoicing' ), |
|
196 | - 'edit' => __( 'Edit', 'invoicing' ), |
|
197 | - 'edit_item' => __( 'Edit discount', 'invoicing' ), |
|
198 | - 'new_item' => __( 'New discount', 'invoicing' ), |
|
199 | - 'view_item' => __( 'View discount', 'invoicing' ), |
|
200 | - 'view_items' => __( 'View Discounts', 'invoicing' ), |
|
201 | - 'search_items' => __( 'Search discounts', 'invoicing' ), |
|
202 | - 'not_found' => __( 'No discounts found', 'invoicing' ), |
|
203 | - 'not_found_in_trash' => __( 'No discounts found in trash', 'invoicing' ), |
|
204 | - 'parent' => __( 'Parent discount', 'invoicing' ), |
|
205 | - 'featured_image' => __( 'Discount image', 'invoicing' ), |
|
206 | - 'set_featured_image' => __( 'Set discount image', 'invoicing' ), |
|
207 | - 'remove_featured_image' => __( 'Remove discount image', 'invoicing' ), |
|
208 | - 'use_featured_image' => __( 'Use as discount image', 'invoicing' ), |
|
209 | - 'insert_into_item' => __( 'Insert into discount', 'invoicing' ), |
|
210 | - 'uploaded_to_this_item' => __( 'Uploaded to this discount', 'invoicing' ), |
|
211 | - 'filter_items_list' => __( 'Filter discounts', 'invoicing' ), |
|
212 | - 'items_list_navigation' => __( 'Discount navigation', 'invoicing' ), |
|
213 | - 'items_list' => __( 'Discounts list', 'invoicing' ), |
|
190 | + 'name' => __('Discounts', 'invoicing'), |
|
191 | + 'singular_name' => __('Discount', 'invoicing'), |
|
192 | + 'all_items' => __('All Discounts', 'invoicing'), |
|
193 | + 'menu_name' => _x('Discounts', 'Admin menu name', 'invoicing'), |
|
194 | + 'add_new' => __('Add New', 'invoicing'), |
|
195 | + 'add_new_item' => __('Add new discount', 'invoicing'), |
|
196 | + 'edit' => __('Edit', 'invoicing'), |
|
197 | + 'edit_item' => __('Edit discount', 'invoicing'), |
|
198 | + 'new_item' => __('New discount', 'invoicing'), |
|
199 | + 'view_item' => __('View discount', 'invoicing'), |
|
200 | + 'view_items' => __('View Discounts', 'invoicing'), |
|
201 | + 'search_items' => __('Search discounts', 'invoicing'), |
|
202 | + 'not_found' => __('No discounts found', 'invoicing'), |
|
203 | + 'not_found_in_trash' => __('No discounts found in trash', 'invoicing'), |
|
204 | + 'parent' => __('Parent discount', 'invoicing'), |
|
205 | + 'featured_image' => __('Discount image', 'invoicing'), |
|
206 | + 'set_featured_image' => __('Set discount image', 'invoicing'), |
|
207 | + 'remove_featured_image' => __('Remove discount image', 'invoicing'), |
|
208 | + 'use_featured_image' => __('Use as discount image', 'invoicing'), |
|
209 | + 'insert_into_item' => __('Insert into discount', 'invoicing'), |
|
210 | + 'uploaded_to_this_item' => __('Uploaded to this discount', 'invoicing'), |
|
211 | + 'filter_items_list' => __('Filter discounts', 'invoicing'), |
|
212 | + 'items_list_navigation' => __('Discount navigation', 'invoicing'), |
|
213 | + 'items_list' => __('Discounts list', 'invoicing'), |
|
214 | 214 | ), |
215 | - 'description' => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ), |
|
215 | + 'description' => __('This is where you can add new discounts that users can use in invoices.', 'invoicing'), |
|
216 | 216 | 'public' => false, |
217 | 217 | 'can_export' => true, |
218 | 218 | '_builtin' => false, |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | 'map_meta_cap' => true, |
227 | 227 | 'has_archive' => false, |
228 | 228 | 'hierarchical' => false, |
229 | - 'supports' => array( 'title', 'excerpt' ), |
|
229 | + 'supports' => array('title', 'excerpt'), |
|
230 | 230 | 'register_meta_box_cb' => 'wpinv_register_discount_meta_boxes', |
231 | 231 | 'show_in_nav_menus' => false, |
232 | 232 | 'show_in_admin_bar' => true, |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | ) |
236 | 236 | ); |
237 | 237 | |
238 | - do_action( 'getpaid_after_register_post_types' ); |
|
238 | + do_action('getpaid_after_register_post_types'); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | /** |
@@ -248,79 +248,79 @@ discard block |
||
248 | 248 | array( |
249 | 249 | |
250 | 250 | 'wpi-pending' => array( |
251 | - 'label' => _x( 'Pending Payment', 'Invoice status', 'invoicing' ), |
|
251 | + 'label' => _x('Pending Payment', 'Invoice status', 'invoicing'), |
|
252 | 252 | 'public' => true, |
253 | 253 | 'exclude_from_search' => true, |
254 | 254 | 'show_in_admin_all_list' => true, |
255 | 255 | 'show_in_admin_status_list' => true, |
256 | 256 | /* translators: %s: number of invoices */ |
257 | - 'label_count' => _n_noop( 'Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing' ) |
|
257 | + 'label_count' => _n_noop('Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing') |
|
258 | 258 | ), |
259 | 259 | |
260 | 260 | 'wpi-processing' => array( |
261 | - 'label' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
261 | + 'label' => _x('Processing', 'Invoice status', 'invoicing'), |
|
262 | 262 | 'public' => true, |
263 | 263 | 'exclude_from_search' => true, |
264 | 264 | 'show_in_admin_all_list' => true, |
265 | 265 | 'show_in_admin_status_list' => true, |
266 | 266 | /* translators: %s: number of invoices */ |
267 | - 'label_count' => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' ) |
|
267 | + 'label_count' => _n_noop('Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing') |
|
268 | 268 | ), |
269 | 269 | |
270 | 270 | 'wpi-onhold' => array( |
271 | - 'label' => _x( 'On Hold', 'Invoice status', 'invoicing' ), |
|
271 | + 'label' => _x('On Hold', 'Invoice status', 'invoicing'), |
|
272 | 272 | 'public' => true, |
273 | 273 | 'exclude_from_search' => true, |
274 | 274 | 'show_in_admin_all_list' => true, |
275 | 275 | 'show_in_admin_status_list' => true, |
276 | 276 | /* translators: %s: number of invoices */ |
277 | - 'label_count' => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' ) |
|
277 | + 'label_count' => _n_noop('On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing') |
|
278 | 278 | ), |
279 | 279 | |
280 | 280 | 'wpi-cancelled' => array( |
281 | - 'label' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
281 | + 'label' => _x('Cancelled', 'Invoice status', 'invoicing'), |
|
282 | 282 | 'public' => true, |
283 | 283 | 'exclude_from_search' => true, |
284 | 284 | 'show_in_admin_all_list' => true, |
285 | 285 | 'show_in_admin_status_list' => true, |
286 | 286 | /* translators: %s: number of invoices */ |
287 | - 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' ) |
|
287 | + 'label_count' => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing') |
|
288 | 288 | ), |
289 | 289 | |
290 | 290 | 'wpi-refunded' => array( |
291 | - 'label' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
291 | + 'label' => _x('Refunded', 'Invoice status', 'invoicing'), |
|
292 | 292 | 'public' => true, |
293 | 293 | 'exclude_from_search' => true, |
294 | 294 | 'show_in_admin_all_list' => true, |
295 | 295 | 'show_in_admin_status_list' => true, |
296 | 296 | /* translators: %s: number of invoices */ |
297 | - 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' ) |
|
297 | + 'label_count' => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing') |
|
298 | 298 | ), |
299 | 299 | |
300 | 300 | 'wpi-failed' => array( |
301 | - 'label' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
301 | + 'label' => _x('Failed', 'Invoice status', 'invoicing'), |
|
302 | 302 | 'public' => true, |
303 | 303 | 'exclude_from_search' => true, |
304 | 304 | 'show_in_admin_all_list' => true, |
305 | 305 | 'show_in_admin_status_list' => true, |
306 | 306 | /* translators: %s: number of invoices */ |
307 | - 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' ) |
|
307 | + 'label_count' => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing') |
|
308 | 308 | ), |
309 | 309 | |
310 | 310 | 'wpi-renewal' => array( |
311 | - 'label' => _x( 'Renewal', 'Invoice status', 'invoicing' ), |
|
311 | + 'label' => _x('Renewal', 'Invoice status', 'invoicing'), |
|
312 | 312 | 'public' => true, |
313 | 313 | 'exclude_from_search' => true, |
314 | 314 | 'show_in_admin_all_list' => true, |
315 | 315 | 'show_in_admin_status_list' => true, |
316 | 316 | /* translators: %s: number of invoices */ |
317 | - 'label_count' => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' ) |
|
317 | + 'label_count' => _n_noop('Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing') |
|
318 | 318 | ) |
319 | 319 | ) |
320 | 320 | ); |
321 | 321 | |
322 | - foreach ( $invoice_statuses as $invoice_statuse => $args ) { |
|
323 | - register_post_status( $invoice_statuse, $args ); |
|
322 | + foreach ($invoice_statuses as $invoice_statuse => $args) { |
|
323 | + register_post_status($invoice_statuse, $args); |
|
324 | 324 | } |
325 | 325 | } |
326 | 326 | |
@@ -336,8 +336,8 @@ discard block |
||
336 | 336 | * |
337 | 337 | */ |
338 | 338 | public static function maybe_flush_rewrite_rules() { |
339 | - if ( ! get_option( 'getpaid_flushed_rewrite_rules' ) ) { |
|
340 | - update_option( 'getpaid_flushed_rewrite_rules', '1' ); |
|
339 | + if (!get_option('getpaid_flushed_rewrite_rules')) { |
|
340 | + update_option('getpaid_flushed_rewrite_rules', '1'); |
|
341 | 341 | self::flush_rewrite_rules(); |
342 | 342 | } |
343 | 343 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | */ |
7 | 7 | |
8 | 8 | if ( ! defined( 'ABSPATH' ) ) { |
9 | - exit; // Exit if accessed directly |
|
9 | + exit; // Exit if accessed directly |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | /** |
@@ -15,10 +15,10 @@ discard block |
||
15 | 15 | class GetPaid_Meta_Box_Resend_Invoice { |
16 | 16 | |
17 | 17 | /** |
18 | - * Output the metabox. |
|
19 | - * |
|
20 | - * @param WP_Post $post |
|
21 | - */ |
|
18 | + * Output the metabox. |
|
19 | + * |
|
20 | + * @param WP_Post $post |
|
21 | + */ |
|
22 | 22 | public static function output( $post ) { |
23 | 23 | |
24 | 24 | // Fetch the invoice. |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * |
6 | 6 | */ |
7 | 7 | |
8 | -if ( ! defined( 'ABSPATH' ) ) { |
|
8 | +if (!defined('ABSPATH')) { |
|
9 | 9 | exit; // Exit if accessed directly |
10 | 10 | } |
11 | 11 | |
@@ -19,12 +19,12 @@ discard block |
||
19 | 19 | * |
20 | 20 | * @param WP_Post $post |
21 | 21 | */ |
22 | - public static function output( $post ) { |
|
22 | + public static function output($post) { |
|
23 | 23 | |
24 | 24 | // Fetch the invoice. |
25 | - $invoice = new WPInv_Invoice( $post ); |
|
25 | + $invoice = new WPInv_Invoice($post); |
|
26 | 26 | |
27 | - do_action( 'wpinv_metabox_resend_invoice_before', $invoice ); |
|
27 | + do_action('wpinv_metabox_resend_invoice_before', $invoice); |
|
28 | 28 | |
29 | 29 | $email_url = esc_url( |
30 | 30 | add_query_arg( |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | ) |
47 | 47 | ); |
48 | 48 | ?> |
49 | - <p class="wpi-meta-row wpi-resend-info"><?php _e( "This will send a copy of the invoice to the customer's email address.", 'invoicing' ); ?></p> |
|
50 | - <p class="wpi-meta-row wpi-resend-email"><a href="<?php echo $email_url; ?>" class="button button-secondary"><?php _e( 'Resend Invoice', 'invoicing' ); ?></a></p> |
|
51 | - <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e( 'Send overdue reminder notification to customer', 'invoicing' ); ?>" href="<?php echo $reminder_url; ?>" class="button button-secondary"><?php esc_attr_e( 'Send Reminder', 'invoicing' ); ?></a></p> |
|
49 | + <p class="wpi-meta-row wpi-resend-info"><?php _e("This will send a copy of the invoice to the customer's email address.", 'invoicing'); ?></p> |
|
50 | + <p class="wpi-meta-row wpi-resend-email"><a href="<?php echo $email_url; ?>" class="button button-secondary"><?php _e('Resend Invoice', 'invoicing'); ?></a></p> |
|
51 | + <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e('Send overdue reminder notification to customer', 'invoicing'); ?>" href="<?php echo $reminder_url; ?>" class="button button-secondary"><?php esc_attr_e('Send Reminder', 'invoicing'); ?></a></p> |
|
52 | 52 | <?php |
53 | 53 | |
54 | - do_action( 'wpinv_metabox_resend_invoice_after', $invoice ); |
|
54 | + do_action('wpinv_metabox_resend_invoice_after', $invoice); |
|
55 | 55 | |
56 | 56 | } |
57 | 57 |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | */ |
7 | 7 | |
8 | 8 | if ( ! defined( 'ABSPATH' ) ) { |
9 | - exit; // Exit if accessed directly |
|
9 | + exit; // Exit if accessed directly |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | /** |
@@ -15,10 +15,10 @@ discard block |
||
15 | 15 | class GetPaid_Meta_Box_Invoice_Subscription { |
16 | 16 | |
17 | 17 | /** |
18 | - * Output the metabox. |
|
19 | - * |
|
20 | - * @param WP_Post $post |
|
21 | - */ |
|
18 | + * Output the metabox. |
|
19 | + * |
|
20 | + * @param WP_Post $post |
|
21 | + */ |
|
22 | 22 | public static function output( $post ) { |
23 | 23 | |
24 | 24 | //Fetch the invoice. |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * |
6 | 6 | */ |
7 | 7 | |
8 | -if ( ! defined( 'ABSPATH' ) ) { |
|
8 | +if (!defined('ABSPATH')) { |
|
9 | 9 | exit; // Exit if accessed directly |
10 | 10 | } |
11 | 11 | |
@@ -19,27 +19,27 @@ discard block |
||
19 | 19 | * |
20 | 20 | * @param WP_Post $post |
21 | 21 | */ |
22 | - public static function output( $post ) { |
|
22 | + public static function output($post) { |
|
23 | 23 | |
24 | 24 | //Fetch the invoice. |
25 | - $invoice = new WPInv_Invoice( $post ); |
|
25 | + $invoice = new WPInv_Invoice($post); |
|
26 | 26 | |
27 | 27 | // Ensure that it is recurring. |
28 | - if ( ! $invoice->is_recurring() ) { |
|
28 | + if (!$invoice->is_recurring()) { |
|
29 | 29 | return; |
30 | 30 | } |
31 | 31 | |
32 | 32 | // Fetch the subscription. |
33 | - $subscription = wpinv_get_subscription( $invoice ); |
|
33 | + $subscription = wpinv_get_subscription($invoice); |
|
34 | 34 | |
35 | 35 | ?> |
36 | - <?php if ( empty( $subscription ) ): ?> |
|
36 | + <?php if (empty($subscription)): ?> |
|
37 | 37 | <p class="wpi-meta-row"> |
38 | 38 | <?php |
39 | 39 | echo |
40 | 40 | wp_sprintf( |
41 | - __( 'A new subscription will be created when the customer checks out and pays the invoice. %sView all subscriptions%s', 'invoicing' ), |
|
42 | - '<a href="' . admin_url( 'admin.php?page=wpinv-subscriptions' ).'">', |
|
41 | + __('A new subscription will be created when the customer checks out and pays the invoice. %sView all subscriptions%s', 'invoicing'), |
|
42 | + '<a href="' . admin_url('admin.php?page=wpinv-subscriptions') . '">', |
|
43 | 43 | '</a>' |
44 | 44 | ); |
45 | 45 | ?> |
@@ -48,30 +48,30 @@ discard block |
||
48 | 48 | return; // If no subscription. |
49 | 49 | endif; |
50 | 50 | |
51 | - $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $subscription->period, $subscription->frequency ); |
|
52 | - $billing = wpinv_price(wpinv_format_amount( $subscription->recurring_amount ), wpinv_get_invoice_currency_code( $subscription->parent_payment_id ) ) . ' / ' . $frequency; |
|
53 | - $initial = wpinv_price(wpinv_format_amount( $subscription->initial_amount ), wpinv_get_invoice_currency_code( $subscription->parent_payment_id ) ); |
|
54 | - $exipired = strtotime( $subscription->expiration, current_time( 'timestamp' ) ) < current_time( 'timestamp' ); |
|
51 | + $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($subscription->period, $subscription->frequency); |
|
52 | + $billing = wpinv_price(wpinv_format_amount($subscription->recurring_amount), wpinv_get_invoice_currency_code($subscription->parent_payment_id)) . ' / ' . $frequency; |
|
53 | + $initial = wpinv_price(wpinv_format_amount($subscription->initial_amount), wpinv_get_invoice_currency_code($subscription->parent_payment_id)); |
|
54 | + $exipired = strtotime($subscription->expiration, current_time('timestamp')) < current_time('timestamp'); |
|
55 | 55 | ?> |
56 | 56 | |
57 | - <p class="wpi-meta-row wpi-sub-label <?php echo 'status-' . esc_attr( $subscription->status ); ?>"> |
|
57 | + <p class="wpi-meta-row wpi-sub-label <?php echo 'status-' . esc_attr($subscription->status); ?>"> |
|
58 | 58 | <?php echo $invoice->is_renewal() ? _e('Renewal Invoice', 'invoicing') : _e('Recurring Invoice', 'invoicing'); ?> |
59 | 59 | </p> |
60 | 60 | |
61 | - <?php if ( ! empty( $subscription->id ) ) : ?> |
|
61 | + <?php if (!empty($subscription->id)) : ?> |
|
62 | 62 | <p class="wpi-meta-row wpi-sub-id"> |
63 | - <label><?php _e( 'Subscription ID:', 'invoicing' ); ?></label> |
|
64 | - <a href="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $subscription->id ) ); ?>" title="<?php esc_attr_e( 'View or edit subscription', 'invoicing' ); ?>" target="_blank"><?php echo $subscription->id; ?></a> |
|
63 | + <label><?php _e('Subscription ID:', 'invoicing'); ?></label> |
|
64 | + <a href="<?php echo esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . $subscription->id)); ?>" title="<?php esc_attr_e('View or edit subscription', 'invoicing'); ?>" target="_blank"><?php echo $subscription->id; ?></a> |
|
65 | 65 | </p> |
66 | 66 | <?php endif; ?> |
67 | 67 | |
68 | 68 | <p class="wpi-meta-row wpi-bill-cycle"> |
69 | - <label><?php _e( 'Billing Cycle:', 'invoicing'); ?> </label> |
|
69 | + <label><?php _e('Billing Cycle:', 'invoicing'); ?> </label> |
|
70 | 70 | <?php |
71 | 71 | |
72 | - if ( $subscription->recurring_amount != $subscription->initial_amount ) { |
|
72 | + if ($subscription->recurring_amount != $subscription->initial_amount) { |
|
73 | 73 | printf( |
74 | - _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), |
|
74 | + _x('%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing'), |
|
75 | 75 | $initial, |
76 | 76 | $billing |
77 | 77 | ); |
@@ -83,38 +83,38 @@ discard block |
||
83 | 83 | </p> |
84 | 84 | |
85 | 85 | <p class="wpi-meta-row wpi-billed-times"> |
86 | - <label><?php _e( 'Times Billed:', 'invoicing' ); ?></label> |
|
87 | - <?php echo $subscription->get_times_billed() . ' / ' . ( ( $subscription->bill_times == 0 ) ? 'Until Cancelled' : $subscription->bill_times ); ?> |
|
86 | + <label><?php _e('Times Billed:', 'invoicing'); ?></label> |
|
87 | + <?php echo $subscription->get_times_billed() . ' / ' . (($subscription->bill_times == 0) ? 'Until Cancelled' : $subscription->bill_times); ?> |
|
88 | 88 | </p> |
89 | 89 | |
90 | 90 | <p class="wpi-meta-row wpi-start-date"> |
91 | - <label><?php _e( 'Start Date:', 'invoicing' ); ?></label> |
|
92 | - <?php echo date_i18n( get_option( 'date_format' ), strtotime( $subscription->created, current_time( 'timestamp' ) ) ); ?> |
|
91 | + <label><?php _e('Start Date:', 'invoicing'); ?></label> |
|
92 | + <?php echo date_i18n(get_option('date_format'), strtotime($subscription->created, current_time('timestamp'))); ?> |
|
93 | 93 | </p> |
94 | 94 | |
95 | 95 | <p class="wpi-meta-row wpi-end-date"> |
96 | - <label><?php echo $exipired ? __( 'Expired On:', 'invoicing' ) : __( 'Renews On:', 'invoicing' ); ?></label> |
|
97 | - <?php echo date_i18n( get_option( 'date_format' ), strtotime( $subscription->expiration, current_time( 'timestamp' ) ) ); ?> |
|
96 | + <label><?php echo $exipired ? __('Expired On:', 'invoicing') : __('Renews On:', 'invoicing'); ?></label> |
|
97 | + <?php echo date_i18n(get_option('date_format'), strtotime($subscription->expiration, current_time('timestamp'))); ?> |
|
98 | 98 | </p> |
99 | 99 | |
100 | - <?php if ( $subscription->status ) { ?> |
|
100 | + <?php if ($subscription->status) { ?> |
|
101 | 101 | <p class="wpi-meta-row wpi-sub-status"> |
102 | - <label><?php _e( 'Subscription Status:', 'invoicing'); ?> </label><?php echo $subscription->get_status_label(); ?> |
|
102 | + <label><?php _e('Subscription Status:', 'invoicing'); ?> </label><?php echo $subscription->get_status_label(); ?> |
|
103 | 103 | </p> |
104 | 104 | <?php } ?> |
105 | 105 | |
106 | - <?php if ( $invoice->is_renewal() ) { ?> |
|
106 | + <?php if ($invoice->is_renewal()) { ?> |
|
107 | 107 | <p class="wpi-meta-row wpi-invoice-parent"> |
108 | - <label><?php _e( 'Parent Invoice:', 'invoicing'); ?></label> |
|
108 | + <label><?php _e('Parent Invoice:', 'invoicing'); ?></label> |
|
109 | 109 | <?php |
110 | 110 | $parent = $invoice->get_parent_payment(); |
111 | 111 | |
112 | - if ( $parent->get_id() ) { |
|
113 | - $parent_url = esc_url( get_edit_post_link( $parent->get_id() ) ); |
|
112 | + if ($parent->get_id()) { |
|
113 | + $parent_url = esc_url(get_edit_post_link($parent->get_id())); |
|
114 | 114 | $parent_id = $parent->get_number(); |
115 | 115 | echo "<a href='$parent_url'>$parent_id</a>"; |
116 | 116 | } else { |
117 | - echo '<del>' . __( 'Deleted', 'invoicing' ) . '</del>'; |
|
117 | + echo '<del>' . __('Deleted', 'invoicing') . '</del>'; |
|
118 | 118 | } |
119 | 119 | ?> |
120 | 120 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | if ( ! defined( 'ABSPATH' ) ) { |
10 | - exit; // Exit if accessed directly |
|
10 | + exit; // Exit if accessed directly |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
@@ -16,10 +16,10 @@ discard block |
||
16 | 16 | class GetPaid_Meta_Box_Payment_Form { |
17 | 17 | |
18 | 18 | /** |
19 | - * Output the metabox. |
|
20 | - * |
|
21 | - * @param WP_Post $post |
|
22 | - */ |
|
19 | + * Output the metabox. |
|
20 | + * |
|
21 | + * @param WP_Post $post |
|
22 | + */ |
|
23 | 23 | public static function output( $post ) { |
24 | 24 | ?> |
25 | 25 | <div id="wpinv-form-builder" class="bsui"> |
@@ -82,11 +82,11 @@ discard block |
||
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
85 | - * Save meta box data. |
|
86 | - * |
|
87 | - * @param int $post_id |
|
88 | - */ |
|
89 | - public static function save( $post_id ) { |
|
85 | + * Save meta box data. |
|
86 | + * |
|
87 | + * @param int $post_id |
|
88 | + */ |
|
89 | + public static function save( $post_id ) { |
|
90 | 90 | |
91 | 91 | // Prepare the form. |
92 | 92 | $form = new GetPaid_Payment_Form( $post_id ); |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * |
7 | 7 | */ |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
9 | +if (!defined('ABSPATH')) { |
|
10 | 10 | exit; // Exit if accessed directly |
11 | 11 | } |
12 | 12 | |
@@ -20,14 +20,14 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @param WP_Post $post |
22 | 22 | */ |
23 | - public static function output( $post ) { |
|
23 | + public static function output($post) { |
|
24 | 24 | ?> |
25 | 25 | <div id="wpinv-form-builder" class="bsui"> |
26 | 26 | <div class="row"> |
27 | 27 | <div class="col-sm-4"> |
28 | 28 | |
29 | 29 | <!-- Builder tabs --> |
30 | - <button class="button button-primary" v-if="active_tab!='new_item'" @click.prevent="active_tab='new_item'"><?php _e( 'Go Back', 'invoicing' ); ?></button> |
|
30 | + <button class="button button-primary" v-if="active_tab!='new_item'" @click.prevent="active_tab='new_item'"><?php _e('Go Back', 'invoicing'); ?></button> |
|
31 | 31 | |
32 | 32 | <!-- Builder tab content --> |
33 | 33 | <div class="mt-4"> |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | <!-- Available builder elements --> |
36 | 36 | <div class="wpinv-form-builder-tab-pane" v-if="active_tab=='new_item'"> |
37 | 37 | <div class="wpinv-form-builder-add-field-types"> |
38 | - <small class='form-text text-muted'><?php _e( 'Add an element by dragging it to the payment form.', 'invoicing' ); ?></small> |
|
38 | + <small class='form-text text-muted'><?php _e('Add an element by dragging it to the payment form.', 'invoicing'); ?></small> |
|
39 | 39 | <draggable class="section mt-2" style="display: flex; flex-flow: wrap; justify-content: space-between;" v-model="elements" :group="{ name: 'fields', pull: 'clone', put: false }" :sort="false" :clone="addDraggedField" tag="ul" filter=".wpinv-undraggable"> |
40 | 40 | <li v-for="element in elements" class= "wpinv-payment-form-left-fields-field" @click.prevent="addField(element)" :class="{ 'd-none': element.defaults.premade }"> |
41 | 41 | <button class="button btn"> |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | <!-- Edit an element --> |
51 | 51 | <div class="wpinv-form-builder-tab-pane" v-if="active_tab=='edit_item'" style="font-size: 16px;"> |
52 | 52 | <div class="wpinv-form-builder-edit-field-wrapper"> |
53 | - <?php do_action( 'wpinv_payment_form_edit_element_template', 'active_form_element', $post ); ?> |
|
53 | + <?php do_action('wpinv_payment_form_edit_element_template', 'active_form_element', $post); ?> |
|
54 | 54 | <div> |
55 | - <button type="button" class="button button-link button-link-delete" @click.prevent="removeField(active_form_element)" v-show="! active_form_element.premade"><?php _e( 'Delete Element', 'invoicing' ); ?></button> |
|
55 | + <button type="button" class="button button-link button-link-delete" @click.prevent="removeField(active_form_element)" v-show="! active_form_element.premade"><?php _e('Delete Element', 'invoicing'); ?></button> |
|
56 | 56 | </div> |
57 | 57 | </div> |
58 | 58 | </div> |
@@ -61,12 +61,12 @@ discard block |
||
61 | 61 | |
62 | 62 | </div> |
63 | 63 | <div class="col-sm-8 border-left"> |
64 | - <small class='form-text text-muted' v-if='form_elements.length'><?php _e( 'Click on any element to edit or delete it.', 'invoicing' ); ?></small> |
|
65 | - <p class='form-text text-muted' v-if='! form_elements.length'><?php _e( 'This form is empty. Add new elements by dragging them from the right.', 'invoicing' ); ?></p> |
|
64 | + <small class='form-text text-muted' v-if='form_elements.length'><?php _e('Click on any element to edit or delete it.', 'invoicing'); ?></small> |
|
65 | + <p class='form-text text-muted' v-if='! form_elements.length'><?php _e('This form is empty. Add new elements by dragging them from the right.', 'invoicing'); ?></p> |
|
66 | 66 | |
67 | 67 | <draggable class="section bsui" v-model="form_elements" @add="highlightLastDroppedField" group="fields" tag="div" style="min-height: 100%; font-size: 16px;"> |
68 | 68 | <div v-for="form_element in form_elements" class="wpinv-form-builder-element-preview" :class="{ active: active_form_element==form_element && active_tab=='edit_item' }" @click="active_tab = 'edit_item'; active_form_element = form_element"> |
69 | - <?php do_action( 'wpinv_payment_form_render_element_template', 'form_element', $post ); ?> |
|
69 | + <?php do_action('wpinv_payment_form_render_element_template', 'form_element', $post); ?> |
|
70 | 70 | </div> |
71 | 71 | </draggable> |
72 | 72 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | </div> |
79 | 79 | <?php |
80 | 80 | |
81 | - wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' ); |
|
81 | + wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce'); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -86,49 +86,49 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @param int $post_id |
88 | 88 | */ |
89 | - public static function save( $post_id ) { |
|
89 | + public static function save($post_id) { |
|
90 | 90 | |
91 | 91 | // Prepare the form. |
92 | - $form = new GetPaid_Payment_Form( $post_id ); |
|
92 | + $form = new GetPaid_Payment_Form($post_id); |
|
93 | 93 | |
94 | 94 | // Fetch form items. |
95 | - $form_items = json_decode( wp_unslash( $_POST['wpinv_form_items'] ), true ); |
|
95 | + $form_items = json_decode(wp_unslash($_POST['wpinv_form_items']), true); |
|
96 | 96 | |
97 | 97 | // Ensure that we have an array... |
98 | - if ( empty( $form_items ) ) { |
|
98 | + if (empty($form_items)) { |
|
99 | 99 | $form_items = array(); |
100 | 100 | } |
101 | 101 | |
102 | 102 | // ... and that new items are saved to the db. |
103 | - $form_items = self::maybe_save_items( $form_items ); |
|
103 | + $form_items = self::maybe_save_items($form_items); |
|
104 | 104 | |
105 | 105 | // Add it to the form. |
106 | - $form->set_items( $form_items ); |
|
106 | + $form->set_items($form_items); |
|
107 | 107 | |
108 | 108 | // Save form elements. |
109 | - $form_elements = json_decode( wp_unslash( $_POST['wpinv_form_elements'] ), true ); |
|
110 | - if ( empty( $form_elements ) ) { |
|
109 | + $form_elements = json_decode(wp_unslash($_POST['wpinv_form_elements']), true); |
|
110 | + if (empty($form_elements)) { |
|
111 | 111 | $form_elements = array(); |
112 | 112 | } |
113 | 113 | |
114 | - $form->set_elements( $form_elements ); |
|
114 | + $form->set_elements($form_elements); |
|
115 | 115 | |
116 | 116 | // Persist data to the datastore. |
117 | 117 | $form->save(); |
118 | - do_action( 'getpaid_payment_form_metabox_save', $post_id, $form ); |
|
118 | + do_action('getpaid_payment_form_metabox_save', $post_id, $form); |
|
119 | 119 | |
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
123 | 123 | * Saves unsaved form items. |
124 | 124 | */ |
125 | - public static function maybe_save_items( $items ) { |
|
125 | + public static function maybe_save_items($items) { |
|
126 | 126 | |
127 | 127 | $saved = array(); |
128 | 128 | |
129 | - foreach( $items as $item ) { |
|
129 | + foreach ($items as $item) { |
|
130 | 130 | |
131 | - if ( is_numeric( $item['id'] ) ) { |
|
131 | + if (is_numeric($item['id'])) { |
|
132 | 132 | $saved[] = $item; |
133 | 133 | continue; |
134 | 134 | } |
@@ -138,32 +138,32 @@ discard block |
||
138 | 138 | // Save post data. |
139 | 139 | $new_item->set_props( |
140 | 140 | array( |
141 | - 'name' => sanitize_text_field( $item['title'] ), |
|
142 | - 'description' => wp_kses_post( $item['description'] ), |
|
141 | + 'name' => sanitize_text_field($item['title']), |
|
142 | + 'description' => wp_kses_post($item['description']), |
|
143 | 143 | 'status' => 'publish', |
144 | - 'type' => empty( $item['type'] ) ? 'custom' : $item['type'], |
|
145 | - 'price' => wpinv_sanitize_amount( $item['price'] ), |
|
146 | - 'vat_rule' => empty( $item['rule'] ) ? 'digital' : $item['rule'], |
|
147 | - 'vat_class' => empty( $item['class'] ) ? '_standard' : $item['class'], |
|
148 | - 'is_dynamic_pricing' => empty( $item['custom_price'] ) ? 0 : (int) $item['custom_price'], |
|
149 | - 'minimum_price' => empty( $item['minimum_price'] ) ? 0 : (float) $item['minimum_price'], |
|
144 | + 'type' => empty($item['type']) ? 'custom' : $item['type'], |
|
145 | + 'price' => wpinv_sanitize_amount($item['price']), |
|
146 | + 'vat_rule' => empty($item['rule']) ? 'digital' : $item['rule'], |
|
147 | + 'vat_class' => empty($item['class']) ? '_standard' : $item['class'], |
|
148 | + 'is_dynamic_pricing' => empty($item['custom_price']) ? 0 : (int) $item['custom_price'], |
|
149 | + 'minimum_price' => empty($item['minimum_price']) ? 0 : (float) $item['minimum_price'], |
|
150 | 150 | ) |
151 | 151 | ); |
152 | 152 | |
153 | 153 | // Save the item. |
154 | 154 | $new_item->save(); |
155 | 155 | |
156 | - if ( $new_item->get_id() ) { |
|
156 | + if ($new_item->get_id()) { |
|
157 | 157 | $item['id'] = $new_item->get_id(); |
158 | 158 | $saved[] = $item; |
159 | 159 | } |
160 | 160 | |
161 | 161 | } |
162 | 162 | |
163 | - foreach ( $saved as $i => $item ) { |
|
164 | - foreach ( array( 'new', 'type', 'class', 'rule', 'price', 'title', 'custom_price', 'minimum_price', 'recurring' ) as $key ) { |
|
165 | - if ( isset( $item[ $key ] ) ) { |
|
166 | - unset( $saved[ $i ][ $key ] ); |
|
163 | + foreach ($saved as $i => $item) { |
|
164 | + foreach (array('new', 'type', 'class', 'rule', 'price', 'title', 'custom_price', 'minimum_price', 'recurring') as $key) { |
|
165 | + if (isset($item[$key])) { |
|
166 | + unset($saved[$i][$key]); |
|
167 | 167 | } |
168 | 168 | } |
169 | 169 | } |