@@ -7,67 +7,67 @@ 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 | -function wpinv_is_base_country( $country ) { |
|
21 | +function wpinv_is_base_country($country) { |
|
22 | 22 | $base_country = wpinv_get_default_country(); |
23 | 23 | |
24 | - if ( $base_country === 'UK' ) { |
|
24 | + if ($base_country === 'UK') { |
|
25 | 25 | $base_country = 'GB'; |
26 | 26 | } |
27 | - if ( $country == 'UK' ) { |
|
27 | + if ($country == 'UK') { |
|
28 | 28 | $country = 'GB'; |
29 | 29 | } |
30 | 30 | |
31 | - return ( $country && $country === $base_country ) ? true : false; |
|
31 | + return ($country && $country === $base_country) ? true : false; |
|
32 | 32 | } |
33 | 33 | |
34 | -function wpinv_country_name( $country_code = '' ) { |
|
34 | +function wpinv_country_name($country_code = '') { |
|
35 | 35 | $countries = wpinv_get_country_list(); |
36 | 36 | $country_code = $country_code == 'UK' ? 'GB' : $country_code; |
37 | - $country = isset( $countries[$country_code] ) ? $countries[$country_code] : $country_code; |
|
37 | + $country = isset($countries[$country_code]) ? $countries[$country_code] : $country_code; |
|
38 | 38 | |
39 | - return apply_filters( 'wpinv_country_name', $country, $country_code ); |
|
39 | + return apply_filters('wpinv_country_name', $country, $country_code); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | function wpinv_get_default_state() { |
43 | - $state = wpinv_get_option( 'default_state', false ); |
|
43 | + $state = wpinv_get_option('default_state', false); |
|
44 | 44 | |
45 | - return apply_filters( 'wpinv_default_state', $state ); |
|
45 | + return apply_filters('wpinv_default_state', $state); |
|
46 | 46 | } |
47 | 47 | |
48 | -function wpinv_state_name( $state_code = '', $country_code = '' ) { |
|
48 | +function wpinv_state_name($state_code = '', $country_code = '') { |
|
49 | 49 | $state = $state_code; |
50 | 50 | |
51 | - if ( !empty( $country_code ) ) { |
|
52 | - $states = wpinv_get_country_states( $country_code ); |
|
51 | + if (!empty($country_code)) { |
|
52 | + $states = wpinv_get_country_states($country_code); |
|
53 | 53 | |
54 | - $state = !empty( $states ) && isset( $states[$state_code] ) ? $states[$state_code] : $state; |
|
54 | + $state = !empty($states) && isset($states[$state_code]) ? $states[$state_code] : $state; |
|
55 | 55 | } |
56 | 56 | |
57 | - return apply_filters( 'wpinv_state_name', $state, $state_code, $country_code ); |
|
57 | + return apply_filters('wpinv_state_name', $state, $state_code, $country_code); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | function wpinv_store_address() { |
61 | - $address = wpinv_get_option( 'store_address', '' ); |
|
61 | + $address = wpinv_get_option('store_address', ''); |
|
62 | 62 | |
63 | - return apply_filters( 'wpinv_store_address', $address ); |
|
63 | + return apply_filters('wpinv_store_address', $address); |
|
64 | 64 | } |
65 | 65 | |
66 | -function wpinv_get_user_address( $user_id = 0, $with_default = true ) { |
|
66 | +function wpinv_get_user_address($user_id = 0, $with_default = true) { |
|
67 | 67 | global $wpi_userID; |
68 | 68 | |
69 | - if( empty( $user_id ) ) { |
|
70 | - $user_id = !empty( $wpi_userID ) ? $wpi_userID : get_current_user_id(); |
|
69 | + if (empty($user_id)) { |
|
70 | + $user_id = !empty($wpi_userID) ? $wpi_userID : get_current_user_id(); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | $address_fields = array( |
@@ -85,36 +85,36 @@ discard block |
||
85 | 85 | 'zip', |
86 | 86 | ); |
87 | 87 | |
88 | - $user_info = get_userdata( $user_id ); |
|
88 | + $user_info = get_userdata($user_id); |
|
89 | 89 | |
90 | 90 | $address = array(); |
91 | 91 | $address['user_id'] = $user_id; |
92 | - $address['email'] = !empty( $user_info ) ? $user_info->user_email : ''; |
|
93 | - foreach ( $address_fields as $field ) { |
|
94 | - $address[$field] = get_user_meta( $user_id, '_wpinv_' . $field, true ); |
|
92 | + $address['email'] = !empty($user_info) ? $user_info->user_email : ''; |
|
93 | + foreach ($address_fields as $field) { |
|
94 | + $address[$field] = get_user_meta($user_id, '_wpinv_' . $field, true); |
|
95 | 95 | } |
96 | 96 | |
97 | - if ( !empty( $user_info ) ) { |
|
98 | - if( empty( $address['first_name'] ) ) |
|
97 | + if (!empty($user_info)) { |
|
98 | + if (empty($address['first_name'])) |
|
99 | 99 | $address['first_name'] = $user_info->first_name; |
100 | 100 | |
101 | - if( empty( $address['last_name'] ) ) |
|
101 | + if (empty($address['last_name'])) |
|
102 | 102 | $address['last_name'] = $user_info->last_name; |
103 | 103 | } |
104 | 104 | |
105 | - $address['name'] = trim( trim( $address['first_name'] . ' ' . $address['last_name'] ), "," ); |
|
105 | + $address['name'] = trim(trim($address['first_name'] . ' ' . $address['last_name']), ","); |
|
106 | 106 | |
107 | - if( empty( $address['state'] ) && $with_default ) |
|
107 | + if (empty($address['state']) && $with_default) |
|
108 | 108 | $address['state'] = wpinv_get_default_state(); |
109 | 109 | |
110 | - if( empty( $address['country'] ) && $with_default ) |
|
110 | + if (empty($address['country']) && $with_default) |
|
111 | 111 | $address['country'] = wpinv_get_default_country(); |
112 | 112 | |
113 | 113 | |
114 | 114 | return $address; |
115 | 115 | } |
116 | 116 | |
117 | -function wpinv_get_country_list( $first_empty = false ) { |
|
117 | +function wpinv_get_country_list($first_empty = false) { |
|
118 | 118 | $countries = array( |
119 | 119 | 'US' => __('United States', 'invoicing'), |
120 | 120 | 'CA' => __('Canada', 'invoicing'), |
@@ -370,23 +370,23 @@ discard block |
||
370 | 370 | 'ZW' => __('Zimbabwe', 'invoicing'), |
371 | 371 | ); |
372 | 372 | |
373 | - if ( $first_empty ) { |
|
374 | - $countries = array_merge( array( '' => '' ), $countries ); |
|
373 | + if ($first_empty) { |
|
374 | + $countries = array_merge(array('' => ''), $countries); |
|
375 | 375 | } |
376 | 376 | |
377 | - $countries = apply_filters( 'wpinv_countries', $countries ); |
|
377 | + $countries = apply_filters('wpinv_countries', $countries); |
|
378 | 378 | |
379 | 379 | asort($countries); |
380 | 380 | |
381 | 381 | return $countries; |
382 | 382 | } |
383 | 383 | |
384 | -function wpinv_get_country_states( $country = null, $first_empty = false ) { |
|
385 | - if ( empty( $country ) ) { |
|
384 | +function wpinv_get_country_states($country = null, $first_empty = false) { |
|
385 | + if (empty($country)) { |
|
386 | 386 | $country = wpinv_get_default_country(); |
387 | 387 | } |
388 | 388 | |
389 | - switch( $country ) { |
|
389 | + switch ($country) { |
|
390 | 390 | case 'US' : |
391 | 391 | $states = wpinv_get_us_states_list(); |
392 | 392 | break; |
@@ -461,11 +461,11 @@ discard block |
||
461 | 461 | break; |
462 | 462 | } |
463 | 463 | |
464 | - if ( !empty( $states ) && $first_empty ) { |
|
465 | - $states = array_merge( array( '' => '' ), $states ); |
|
464 | + if (!empty($states) && $first_empty) { |
|
465 | + $states = array_merge(array('' => ''), $states); |
|
466 | 466 | } |
467 | 467 | |
468 | - $states = apply_filters( 'wpinv_country_states', $states, $country ); |
|
468 | + $states = apply_filters('wpinv_country_states', $states, $country); |
|
469 | 469 | |
470 | 470 | asort($states); |
471 | 471 | |
@@ -474,1087 +474,1087 @@ discard block |
||
474 | 474 | |
475 | 475 | function wpinv_get_us_states_list() { |
476 | 476 | $states = array( |
477 | - 'AL' => __( 'Alabama', 'invoicing' ), |
|
478 | - 'AK' => __( 'Alaska', 'invoicing' ), |
|
479 | - 'AZ' => __( 'Arizona', 'invoicing' ), |
|
480 | - 'AR' => __( 'Arkansas', 'invoicing' ), |
|
481 | - 'CA' => __( 'California', 'invoicing' ), |
|
482 | - 'CO' => __( 'Colorado', 'invoicing' ), |
|
483 | - 'CT' => __( 'Connecticut', 'invoicing' ), |
|
484 | - 'DE' => __( 'Delaware', 'invoicing' ), |
|
485 | - 'DC' => __( 'District of Columbia', 'invoicing' ), |
|
486 | - 'FL' => __( 'Florida', 'invoicing' ), |
|
487 | - 'GA' => __( 'Georgia', 'invoicing' ), |
|
488 | - 'HI' => __( 'Hawaii', 'invoicing' ), |
|
489 | - 'ID' => __( 'Idaho', 'invoicing' ), |
|
490 | - 'IL' => __( 'Illinois', 'invoicing' ), |
|
491 | - 'IN' => __( 'Indiana', 'invoicing' ), |
|
492 | - 'IA' => __( 'Iowa', 'invoicing' ), |
|
493 | - 'KS' => __( 'Kansas', 'invoicing' ), |
|
494 | - 'KY' => __( 'Kentucky', 'invoicing' ), |
|
495 | - 'LA' => __( 'Louisiana', 'invoicing' ), |
|
496 | - 'ME' => __( 'Maine', 'invoicing' ), |
|
497 | - 'MD' => __( 'Maryland', 'invoicing' ), |
|
498 | - 'MA' => __( 'Massachusetts', 'invoicing' ), |
|
499 | - 'MI' => __( 'Michigan', 'invoicing' ), |
|
500 | - 'MN' => __( 'Minnesota', 'invoicing' ), |
|
501 | - 'MS' => __( 'Mississippi', 'invoicing' ), |
|
502 | - 'MO' => __( 'Missouri', 'invoicing' ), |
|
503 | - 'MT' => __( 'Montana', 'invoicing' ), |
|
504 | - 'NE' => __( 'Nebraska', 'invoicing' ), |
|
505 | - 'NV' => __( 'Nevada', 'invoicing' ), |
|
506 | - 'NH' => __( 'New Hampshire', 'invoicing' ), |
|
507 | - 'NJ' => __( 'New Jersey', 'invoicing' ), |
|
508 | - 'NM' => __( 'New Mexico', 'invoicing' ), |
|
509 | - 'NY' => __( 'New York', 'invoicing' ), |
|
510 | - 'NC' => __( 'North Carolina', 'invoicing' ), |
|
511 | - 'ND' => __( 'North Dakota', 'invoicing' ), |
|
512 | - 'OH' => __( 'Ohio', 'invoicing' ), |
|
513 | - 'OK' => __( 'Oklahoma', 'invoicing' ), |
|
514 | - 'OR' => __( 'Oregon', 'invoicing' ), |
|
515 | - 'PA' => __( 'Pennsylvania', 'invoicing' ), |
|
516 | - 'RI' => __( 'Rhode Island', 'invoicing' ), |
|
517 | - 'SC' => __( 'South Carolina', 'invoicing' ), |
|
518 | - 'SD' => __( 'South Dakota', 'invoicing' ), |
|
519 | - 'TN' => __( 'Tennessee', 'invoicing' ), |
|
520 | - 'TX' => __( 'Texas', 'invoicing' ), |
|
521 | - 'UT' => __( 'Utah', 'invoicing' ), |
|
522 | - 'VT' => __( 'Vermont', 'invoicing' ), |
|
523 | - 'VA' => __( 'Virginia', 'invoicing' ), |
|
524 | - 'WA' => __( 'Washington', 'invoicing' ), |
|
525 | - 'WV' => __( 'West Virginia', 'invoicing' ), |
|
526 | - 'WI' => __( 'Wisconsin', 'invoicing' ), |
|
527 | - 'WY' => __( 'Wyoming', 'invoicing' ), |
|
528 | - 'AS' => __( 'American Samoa', 'invoicing' ), |
|
529 | - 'CZ' => __( 'Canal Zone', 'invoicing' ), |
|
530 | - 'CM' => __( 'Commonwealth of the Northern Mariana Islands', 'invoicing' ), |
|
531 | - 'FM' => __( 'Federated States of Micronesia', 'invoicing' ), |
|
532 | - 'GU' => __( 'Guam', 'invoicing' ), |
|
533 | - 'MH' => __( 'Marshall Islands', 'invoicing' ), |
|
534 | - 'MP' => __( 'Northern Mariana Islands', 'invoicing' ), |
|
535 | - 'PW' => __( 'Palau', 'invoicing' ), |
|
536 | - 'PI' => __( 'Philippine Islands', 'invoicing' ), |
|
537 | - 'PR' => __( 'Puerto Rico', 'invoicing' ), |
|
538 | - 'TT' => __( 'Trust Territory of the Pacific Islands', 'invoicing' ), |
|
539 | - 'VI' => __( 'Virgin Islands', 'invoicing' ), |
|
540 | - 'AA' => __( 'Armed Forces - Americas', 'invoicing' ), |
|
541 | - 'AE' => __( 'Armed Forces - Europe, Canada, Middle East, Africa', 'invoicing' ), |
|
542 | - 'AP' => __( 'Armed Forces - Pacific', 'invoicing' ) |
|
477 | + 'AL' => __('Alabama', 'invoicing'), |
|
478 | + 'AK' => __('Alaska', 'invoicing'), |
|
479 | + 'AZ' => __('Arizona', 'invoicing'), |
|
480 | + 'AR' => __('Arkansas', 'invoicing'), |
|
481 | + 'CA' => __('California', 'invoicing'), |
|
482 | + 'CO' => __('Colorado', 'invoicing'), |
|
483 | + 'CT' => __('Connecticut', 'invoicing'), |
|
484 | + 'DE' => __('Delaware', 'invoicing'), |
|
485 | + 'DC' => __('District of Columbia', 'invoicing'), |
|
486 | + 'FL' => __('Florida', 'invoicing'), |
|
487 | + 'GA' => __('Georgia', 'invoicing'), |
|
488 | + 'HI' => __('Hawaii', 'invoicing'), |
|
489 | + 'ID' => __('Idaho', 'invoicing'), |
|
490 | + 'IL' => __('Illinois', 'invoicing'), |
|
491 | + 'IN' => __('Indiana', 'invoicing'), |
|
492 | + 'IA' => __('Iowa', 'invoicing'), |
|
493 | + 'KS' => __('Kansas', 'invoicing'), |
|
494 | + 'KY' => __('Kentucky', 'invoicing'), |
|
495 | + 'LA' => __('Louisiana', 'invoicing'), |
|
496 | + 'ME' => __('Maine', 'invoicing'), |
|
497 | + 'MD' => __('Maryland', 'invoicing'), |
|
498 | + 'MA' => __('Massachusetts', 'invoicing'), |
|
499 | + 'MI' => __('Michigan', 'invoicing'), |
|
500 | + 'MN' => __('Minnesota', 'invoicing'), |
|
501 | + 'MS' => __('Mississippi', 'invoicing'), |
|
502 | + 'MO' => __('Missouri', 'invoicing'), |
|
503 | + 'MT' => __('Montana', 'invoicing'), |
|
504 | + 'NE' => __('Nebraska', 'invoicing'), |
|
505 | + 'NV' => __('Nevada', 'invoicing'), |
|
506 | + 'NH' => __('New Hampshire', 'invoicing'), |
|
507 | + 'NJ' => __('New Jersey', 'invoicing'), |
|
508 | + 'NM' => __('New Mexico', 'invoicing'), |
|
509 | + 'NY' => __('New York', 'invoicing'), |
|
510 | + 'NC' => __('North Carolina', 'invoicing'), |
|
511 | + 'ND' => __('North Dakota', 'invoicing'), |
|
512 | + 'OH' => __('Ohio', 'invoicing'), |
|
513 | + 'OK' => __('Oklahoma', 'invoicing'), |
|
514 | + 'OR' => __('Oregon', 'invoicing'), |
|
515 | + 'PA' => __('Pennsylvania', 'invoicing'), |
|
516 | + 'RI' => __('Rhode Island', 'invoicing'), |
|
517 | + 'SC' => __('South Carolina', 'invoicing'), |
|
518 | + 'SD' => __('South Dakota', 'invoicing'), |
|
519 | + 'TN' => __('Tennessee', 'invoicing'), |
|
520 | + 'TX' => __('Texas', 'invoicing'), |
|
521 | + 'UT' => __('Utah', 'invoicing'), |
|
522 | + 'VT' => __('Vermont', 'invoicing'), |
|
523 | + 'VA' => __('Virginia', 'invoicing'), |
|
524 | + 'WA' => __('Washington', 'invoicing'), |
|
525 | + 'WV' => __('West Virginia', 'invoicing'), |
|
526 | + 'WI' => __('Wisconsin', 'invoicing'), |
|
527 | + 'WY' => __('Wyoming', 'invoicing'), |
|
528 | + 'AS' => __('American Samoa', 'invoicing'), |
|
529 | + 'CZ' => __('Canal Zone', 'invoicing'), |
|
530 | + 'CM' => __('Commonwealth of the Northern Mariana Islands', 'invoicing'), |
|
531 | + 'FM' => __('Federated States of Micronesia', 'invoicing'), |
|
532 | + 'GU' => __('Guam', 'invoicing'), |
|
533 | + 'MH' => __('Marshall Islands', 'invoicing'), |
|
534 | + 'MP' => __('Northern Mariana Islands', 'invoicing'), |
|
535 | + 'PW' => __('Palau', 'invoicing'), |
|
536 | + 'PI' => __('Philippine Islands', 'invoicing'), |
|
537 | + 'PR' => __('Puerto Rico', 'invoicing'), |
|
538 | + 'TT' => __('Trust Territory of the Pacific Islands', 'invoicing'), |
|
539 | + 'VI' => __('Virgin Islands', 'invoicing'), |
|
540 | + 'AA' => __('Armed Forces - Americas', 'invoicing'), |
|
541 | + 'AE' => __('Armed Forces - Europe, Canada, Middle East, Africa', 'invoicing'), |
|
542 | + 'AP' => __('Armed Forces - Pacific', 'invoicing') |
|
543 | 543 | ); |
544 | 544 | |
545 | - return apply_filters( 'wpinv_us_states', $states ); |
|
545 | + return apply_filters('wpinv_us_states', $states); |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | function wpinv_get_canada_states_list() { |
549 | 549 | $states = array( |
550 | - 'AB' => __( 'Alberta', 'invoicing' ), |
|
551 | - 'BC' => __( 'British Columbia', 'invoicing' ), |
|
552 | - 'MB' => __( 'Manitoba', 'invoicing' ), |
|
553 | - 'NB' => __( 'New Brunswick', 'invoicing' ), |
|
554 | - 'NL' => __( 'Newfoundland and Labrador', 'invoicing' ), |
|
555 | - 'NS' => __( 'Nova Scotia', 'invoicing' ), |
|
556 | - 'NT' => __( 'Northwest Territories', 'invoicing' ), |
|
557 | - 'NU' => __( 'Nunavut', 'invoicing' ), |
|
558 | - 'ON' => __( 'Ontario', 'invoicing' ), |
|
559 | - 'PE' => __( 'Prince Edward Island', 'invoicing' ), |
|
560 | - 'QC' => __( 'Quebec', 'invoicing' ), |
|
561 | - 'SK' => __( 'Saskatchewan', 'invoicing' ), |
|
562 | - 'YT' => __( 'Yukon', 'invoicing' ) |
|
550 | + 'AB' => __('Alberta', 'invoicing'), |
|
551 | + 'BC' => __('British Columbia', 'invoicing'), |
|
552 | + 'MB' => __('Manitoba', 'invoicing'), |
|
553 | + 'NB' => __('New Brunswick', 'invoicing'), |
|
554 | + 'NL' => __('Newfoundland and Labrador', 'invoicing'), |
|
555 | + 'NS' => __('Nova Scotia', 'invoicing'), |
|
556 | + 'NT' => __('Northwest Territories', 'invoicing'), |
|
557 | + 'NU' => __('Nunavut', 'invoicing'), |
|
558 | + 'ON' => __('Ontario', 'invoicing'), |
|
559 | + 'PE' => __('Prince Edward Island', 'invoicing'), |
|
560 | + 'QC' => __('Quebec', 'invoicing'), |
|
561 | + 'SK' => __('Saskatchewan', 'invoicing'), |
|
562 | + 'YT' => __('Yukon', 'invoicing') |
|
563 | 563 | ); |
564 | 564 | |
565 | - return apply_filters( 'wpinv_canada_provinces', $states ); |
|
565 | + return apply_filters('wpinv_canada_provinces', $states); |
|
566 | 566 | } |
567 | 567 | |
568 | 568 | function wpinv_get_australia_states_list() { |
569 | 569 | $states = array( |
570 | - 'ACT' => __( 'Australian Capital Territory', 'invoicing' ), |
|
571 | - 'NSW' => __( 'New South Wales', 'invoicing' ), |
|
572 | - 'NT' => __( 'Northern Territory', 'invoicing' ), |
|
573 | - 'QLD' => __( 'Queensland', 'invoicing' ), |
|
574 | - 'SA' => __( 'South Australia', 'invoicing' ), |
|
575 | - 'TAS' => __( 'Tasmania', 'invoicing' ), |
|
576 | - 'VIC' => __( 'Victoria', 'invoicing' ), |
|
577 | - 'WA' => __( 'Western Australia', 'invoicing' ) |
|
570 | + 'ACT' => __('Australian Capital Territory', 'invoicing'), |
|
571 | + 'NSW' => __('New South Wales', 'invoicing'), |
|
572 | + 'NT' => __('Northern Territory', 'invoicing'), |
|
573 | + 'QLD' => __('Queensland', 'invoicing'), |
|
574 | + 'SA' => __('South Australia', 'invoicing'), |
|
575 | + 'TAS' => __('Tasmania', 'invoicing'), |
|
576 | + 'VIC' => __('Victoria', 'invoicing'), |
|
577 | + 'WA' => __('Western Australia', 'invoicing') |
|
578 | 578 | ); |
579 | 579 | |
580 | - return apply_filters( 'wpinv_australia_states', $states ); |
|
580 | + return apply_filters('wpinv_australia_states', $states); |
|
581 | 581 | } |
582 | 582 | |
583 | 583 | function wpinv_get_bangladesh_states_list() { |
584 | 584 | $states = array( |
585 | - 'BAG' => __( 'Bagerhat', 'invoicing' ), |
|
586 | - 'BAN' => __( 'Bandarban', 'invoicing' ), |
|
587 | - 'BAR' => __( 'Barguna', 'invoicing' ), |
|
588 | - 'BARI'=> __( 'Barisal', 'invoicing' ), |
|
589 | - 'BHO' => __( 'Bhola', 'invoicing' ), |
|
590 | - 'BOG' => __( 'Bogra', 'invoicing' ), |
|
591 | - 'BRA' => __( 'Brahmanbaria', 'invoicing' ), |
|
592 | - 'CHA' => __( 'Chandpur', 'invoicing' ), |
|
593 | - 'CHI' => __( 'Chittagong', 'invoicing' ), |
|
594 | - 'CHU' => __( 'Chuadanga', 'invoicing' ), |
|
595 | - 'COM' => __( 'Comilla', 'invoicing' ), |
|
596 | - 'COX' => __( 'Cox\'s Bazar', 'invoicing' ), |
|
597 | - 'DHA' => __( 'Dhaka', 'invoicing' ), |
|
598 | - 'DIN' => __( 'Dinajpur', 'invoicing' ), |
|
599 | - 'FAR' => __( 'Faridpur', 'invoicing' ), |
|
600 | - 'FEN' => __( 'Feni', 'invoicing' ), |
|
601 | - 'GAI' => __( 'Gaibandha', 'invoicing' ), |
|
602 | - 'GAZI'=> __( 'Gazipur', 'invoicing' ), |
|
603 | - 'GOP' => __( 'Gopalganj', 'invoicing' ), |
|
604 | - 'HAB' => __( 'Habiganj', 'invoicing' ), |
|
605 | - 'JAM' => __( 'Jamalpur', 'invoicing' ), |
|
606 | - 'JES' => __( 'Jessore', 'invoicing' ), |
|
607 | - 'JHA' => __( 'Jhalokati', 'invoicing' ), |
|
608 | - 'JHE' => __( 'Jhenaidah', 'invoicing' ), |
|
609 | - 'JOY' => __( 'Joypurhat', 'invoicing' ), |
|
610 | - 'KHA' => __( 'Khagrachhari', 'invoicing' ), |
|
611 | - 'KHU' => __( 'Khulna', 'invoicing' ), |
|
612 | - 'KIS' => __( 'Kishoreganj', 'invoicing' ), |
|
613 | - 'KUR' => __( 'Kurigram', 'invoicing' ), |
|
614 | - 'KUS' => __( 'Kushtia', 'invoicing' ), |
|
615 | - 'LAK' => __( 'Lakshmipur', 'invoicing' ), |
|
616 | - 'LAL' => __( 'Lalmonirhat', 'invoicing' ), |
|
617 | - 'MAD' => __( 'Madaripur', 'invoicing' ), |
|
618 | - 'MAG' => __( 'Magura', 'invoicing' ), |
|
619 | - 'MAN' => __( 'Manikganj', 'invoicing' ), |
|
620 | - 'MEH' => __( 'Meherpur', 'invoicing' ), |
|
621 | - 'MOU' => __( 'Moulvibazar', 'invoicing' ), |
|
622 | - 'MUN' => __( 'Munshiganj', 'invoicing' ), |
|
623 | - 'MYM' => __( 'Mymensingh', 'invoicing' ), |
|
624 | - 'NAO' => __( 'Naogaon', 'invoicing' ), |
|
625 | - 'NAR' => __( 'Narail', 'invoicing' ), |
|
626 | - 'NARG'=> __( 'Narayanganj', 'invoicing' ), |
|
627 | - 'NARD'=> __( 'Narsingdi', 'invoicing' ), |
|
628 | - 'NAT' => __( 'Natore', 'invoicing' ), |
|
629 | - 'NAW' => __( 'Nawabganj', 'invoicing' ), |
|
630 | - 'NET' => __( 'Netrakona', 'invoicing' ), |
|
631 | - 'NIL' => __( 'Nilphamari', 'invoicing' ), |
|
632 | - 'NOA' => __( 'Noakhali', 'invoicing' ), |
|
633 | - 'PAB' => __( 'Pabna', 'invoicing' ), |
|
634 | - 'PAN' => __( 'Panchagarh', 'invoicing' ), |
|
635 | - 'PAT' => __( 'Patuakhali', 'invoicing' ), |
|
636 | - 'PIR' => __( 'Pirojpur', 'invoicing' ), |
|
637 | - 'RAJB'=> __( 'Rajbari', 'invoicing' ), |
|
638 | - 'RAJ' => __( 'Rajshahi', 'invoicing' ), |
|
639 | - 'RAN' => __( 'Rangamati', 'invoicing' ), |
|
640 | - 'RANP'=> __( 'Rangpur', 'invoicing' ), |
|
641 | - 'SAT' => __( 'Satkhira', 'invoicing' ), |
|
642 | - 'SHA' => __( 'Shariatpur', 'invoicing' ), |
|
643 | - 'SHE' => __( 'Sherpur', 'invoicing' ), |
|
644 | - 'SIR' => __( 'Sirajganj', 'invoicing' ), |
|
645 | - 'SUN' => __( 'Sunamganj', 'invoicing' ), |
|
646 | - 'SYL' => __( 'Sylhet', 'invoicing' ), |
|
647 | - 'TAN' => __( 'Tangail', 'invoicing' ), |
|
648 | - 'THA' => __( 'Thakurgaon', 'invoicing' ) |
|
585 | + 'BAG' => __('Bagerhat', 'invoicing'), |
|
586 | + 'BAN' => __('Bandarban', 'invoicing'), |
|
587 | + 'BAR' => __('Barguna', 'invoicing'), |
|
588 | + 'BARI'=> __('Barisal', 'invoicing'), |
|
589 | + 'BHO' => __('Bhola', 'invoicing'), |
|
590 | + 'BOG' => __('Bogra', 'invoicing'), |
|
591 | + 'BRA' => __('Brahmanbaria', 'invoicing'), |
|
592 | + 'CHA' => __('Chandpur', 'invoicing'), |
|
593 | + 'CHI' => __('Chittagong', 'invoicing'), |
|
594 | + 'CHU' => __('Chuadanga', 'invoicing'), |
|
595 | + 'COM' => __('Comilla', 'invoicing'), |
|
596 | + 'COX' => __('Cox\'s Bazar', 'invoicing'), |
|
597 | + 'DHA' => __('Dhaka', 'invoicing'), |
|
598 | + 'DIN' => __('Dinajpur', 'invoicing'), |
|
599 | + 'FAR' => __('Faridpur', 'invoicing'), |
|
600 | + 'FEN' => __('Feni', 'invoicing'), |
|
601 | + 'GAI' => __('Gaibandha', 'invoicing'), |
|
602 | + 'GAZI'=> __('Gazipur', 'invoicing'), |
|
603 | + 'GOP' => __('Gopalganj', 'invoicing'), |
|
604 | + 'HAB' => __('Habiganj', 'invoicing'), |
|
605 | + 'JAM' => __('Jamalpur', 'invoicing'), |
|
606 | + 'JES' => __('Jessore', 'invoicing'), |
|
607 | + 'JHA' => __('Jhalokati', 'invoicing'), |
|
608 | + 'JHE' => __('Jhenaidah', 'invoicing'), |
|
609 | + 'JOY' => __('Joypurhat', 'invoicing'), |
|
610 | + 'KHA' => __('Khagrachhari', 'invoicing'), |
|
611 | + 'KHU' => __('Khulna', 'invoicing'), |
|
612 | + 'KIS' => __('Kishoreganj', 'invoicing'), |
|
613 | + 'KUR' => __('Kurigram', 'invoicing'), |
|
614 | + 'KUS' => __('Kushtia', 'invoicing'), |
|
615 | + 'LAK' => __('Lakshmipur', 'invoicing'), |
|
616 | + 'LAL' => __('Lalmonirhat', 'invoicing'), |
|
617 | + 'MAD' => __('Madaripur', 'invoicing'), |
|
618 | + 'MAG' => __('Magura', 'invoicing'), |
|
619 | + 'MAN' => __('Manikganj', 'invoicing'), |
|
620 | + 'MEH' => __('Meherpur', 'invoicing'), |
|
621 | + 'MOU' => __('Moulvibazar', 'invoicing'), |
|
622 | + 'MUN' => __('Munshiganj', 'invoicing'), |
|
623 | + 'MYM' => __('Mymensingh', 'invoicing'), |
|
624 | + 'NAO' => __('Naogaon', 'invoicing'), |
|
625 | + 'NAR' => __('Narail', 'invoicing'), |
|
626 | + 'NARG'=> __('Narayanganj', 'invoicing'), |
|
627 | + 'NARD'=> __('Narsingdi', 'invoicing'), |
|
628 | + 'NAT' => __('Natore', 'invoicing'), |
|
629 | + 'NAW' => __('Nawabganj', 'invoicing'), |
|
630 | + 'NET' => __('Netrakona', 'invoicing'), |
|
631 | + 'NIL' => __('Nilphamari', 'invoicing'), |
|
632 | + 'NOA' => __('Noakhali', 'invoicing'), |
|
633 | + 'PAB' => __('Pabna', 'invoicing'), |
|
634 | + 'PAN' => __('Panchagarh', 'invoicing'), |
|
635 | + 'PAT' => __('Patuakhali', 'invoicing'), |
|
636 | + 'PIR' => __('Pirojpur', 'invoicing'), |
|
637 | + 'RAJB'=> __('Rajbari', 'invoicing'), |
|
638 | + 'RAJ' => __('Rajshahi', 'invoicing'), |
|
639 | + 'RAN' => __('Rangamati', 'invoicing'), |
|
640 | + 'RANP'=> __('Rangpur', 'invoicing'), |
|
641 | + 'SAT' => __('Satkhira', 'invoicing'), |
|
642 | + 'SHA' => __('Shariatpur', 'invoicing'), |
|
643 | + 'SHE' => __('Sherpur', 'invoicing'), |
|
644 | + 'SIR' => __('Sirajganj', 'invoicing'), |
|
645 | + 'SUN' => __('Sunamganj', 'invoicing'), |
|
646 | + 'SYL' => __('Sylhet', 'invoicing'), |
|
647 | + 'TAN' => __('Tangail', 'invoicing'), |
|
648 | + 'THA' => __('Thakurgaon', 'invoicing') |
|
649 | 649 | ); |
650 | 650 | |
651 | - return apply_filters( 'wpinv_bangladesh_states', $states ); |
|
651 | + return apply_filters('wpinv_bangladesh_states', $states); |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | function wpinv_get_brazil_states_list() { |
655 | 655 | $states = array( |
656 | - 'AC' => __( 'Acre', 'invoicing' ), |
|
657 | - 'AL' => __( 'Alagoas', 'invoicing' ), |
|
658 | - 'AP' => __( 'Amapá', 'invoicing' ), |
|
659 | - 'AM' => __( 'Amazonas', 'invoicing' ), |
|
660 | - 'BA' => __( 'Bahia', 'invoicing' ), |
|
661 | - 'CE' => __( 'Ceará', 'invoicing' ), |
|
662 | - 'DF' => __( 'Distrito Federal', 'invoicing' ), |
|
663 | - 'ES' => __( 'Espírito Santo', 'invoicing' ), |
|
664 | - 'GO' => __( 'Goiás', 'invoicing' ), |
|
665 | - 'MA' => __( 'Maranhão', 'invoicing' ), |
|
666 | - 'MT' => __( 'Mato Grosso', 'invoicing' ), |
|
667 | - 'MS' => __( 'Mato Grosso do Sul', 'invoicing' ), |
|
668 | - 'MG' => __( 'Minas Gerais', 'invoicing' ), |
|
669 | - 'PA' => __( 'Pará', 'invoicing' ), |
|
670 | - 'PB' => __( 'Paraíba', 'invoicing' ), |
|
671 | - 'PR' => __( 'Paraná', 'invoicing' ), |
|
672 | - 'PE' => __( 'Pernambuco', 'invoicing' ), |
|
673 | - 'PI' => __( 'Piauí', 'invoicing' ), |
|
674 | - 'RJ' => __( 'Rio de Janeiro', 'invoicing' ), |
|
675 | - 'RN' => __( 'Rio Grande do Norte', 'invoicing' ), |
|
676 | - 'RS' => __( 'Rio Grande do Sul', 'invoicing' ), |
|
677 | - 'RO' => __( 'Rondônia', 'invoicing' ), |
|
678 | - 'RR' => __( 'Roraima', 'invoicing' ), |
|
679 | - 'SC' => __( 'Santa Catarina', 'invoicing' ), |
|
680 | - 'SP' => __( 'São Paulo', 'invoicing' ), |
|
681 | - 'SE' => __( 'Sergipe', 'invoicing' ), |
|
682 | - 'TO' => __( 'Tocantins', 'invoicing' ) |
|
656 | + 'AC' => __('Acre', 'invoicing'), |
|
657 | + 'AL' => __('Alagoas', 'invoicing'), |
|
658 | + 'AP' => __('Amapá', 'invoicing'), |
|
659 | + 'AM' => __('Amazonas', 'invoicing'), |
|
660 | + 'BA' => __('Bahia', 'invoicing'), |
|
661 | + 'CE' => __('Ceará', 'invoicing'), |
|
662 | + 'DF' => __('Distrito Federal', 'invoicing'), |
|
663 | + 'ES' => __('Espírito Santo', 'invoicing'), |
|
664 | + 'GO' => __('Goiás', 'invoicing'), |
|
665 | + 'MA' => __('Maranhão', 'invoicing'), |
|
666 | + 'MT' => __('Mato Grosso', 'invoicing'), |
|
667 | + 'MS' => __('Mato Grosso do Sul', 'invoicing'), |
|
668 | + 'MG' => __('Minas Gerais', 'invoicing'), |
|
669 | + 'PA' => __('Pará', 'invoicing'), |
|
670 | + 'PB' => __('Paraíba', 'invoicing'), |
|
671 | + 'PR' => __('Paraná', 'invoicing'), |
|
672 | + 'PE' => __('Pernambuco', 'invoicing'), |
|
673 | + 'PI' => __('Piauí', 'invoicing'), |
|
674 | + 'RJ' => __('Rio de Janeiro', 'invoicing'), |
|
675 | + 'RN' => __('Rio Grande do Norte', 'invoicing'), |
|
676 | + 'RS' => __('Rio Grande do Sul', 'invoicing'), |
|
677 | + 'RO' => __('Rondônia', 'invoicing'), |
|
678 | + 'RR' => __('Roraima', 'invoicing'), |
|
679 | + 'SC' => __('Santa Catarina', 'invoicing'), |
|
680 | + 'SP' => __('São Paulo', 'invoicing'), |
|
681 | + 'SE' => __('Sergipe', 'invoicing'), |
|
682 | + 'TO' => __('Tocantins', 'invoicing') |
|
683 | 683 | ); |
684 | 684 | |
685 | - return apply_filters( 'wpinv_brazil_states', $states ); |
|
685 | + return apply_filters('wpinv_brazil_states', $states); |
|
686 | 686 | } |
687 | 687 | |
688 | 688 | function wpinv_get_bulgaria_states_list() { |
689 | 689 | $states = array( |
690 | - 'BG-01' => __( 'Blagoevgrad', 'invoicing' ), |
|
691 | - 'BG-02' => __( 'Burgas', 'invoicing' ), |
|
692 | - 'BG-08' => __( 'Dobrich', 'invoicing' ), |
|
693 | - 'BG-07' => __( 'Gabrovo', 'invoicing' ), |
|
694 | - 'BG-26' => __( 'Haskovo', 'invoicing' ), |
|
695 | - 'BG-09' => __( 'Kardzhali', 'invoicing' ), |
|
696 | - 'BG-10' => __( 'Kyustendil', 'invoicing' ), |
|
697 | - 'BG-11' => __( 'Lovech', 'invoicing' ), |
|
698 | - 'BG-12' => __( 'Montana', 'invoicing' ), |
|
699 | - 'BG-13' => __( 'Pazardzhik', 'invoicing' ), |
|
700 | - 'BG-14' => __( 'Pernik', 'invoicing' ), |
|
701 | - 'BG-15' => __( 'Pleven', 'invoicing' ), |
|
702 | - 'BG-16' => __( 'Plovdiv', 'invoicing' ), |
|
703 | - 'BG-17' => __( 'Razgrad', 'invoicing' ), |
|
704 | - 'BG-18' => __( 'Ruse', 'invoicing' ), |
|
705 | - 'BG-27' => __( 'Shumen', 'invoicing' ), |
|
706 | - 'BG-19' => __( 'Silistra', 'invoicing' ), |
|
707 | - 'BG-20' => __( 'Sliven', 'invoicing' ), |
|
708 | - 'BG-21' => __( 'Smolyan', 'invoicing' ), |
|
709 | - 'BG-23' => __( 'Sofia', 'invoicing' ), |
|
710 | - 'BG-22' => __( 'Sofia-Grad', 'invoicing' ), |
|
711 | - 'BG-24' => __( 'Stara Zagora', 'invoicing' ), |
|
712 | - 'BG-25' => __( 'Targovishte', 'invoicing' ), |
|
713 | - 'BG-03' => __( 'Varna', 'invoicing' ), |
|
714 | - 'BG-04' => __( 'Veliko Tarnovo', 'invoicing' ), |
|
715 | - 'BG-05' => __( 'Vidin', 'invoicing' ), |
|
716 | - 'BG-06' => __( 'Vratsa', 'invoicing' ), |
|
717 | - 'BG-28' => __( 'Yambol', 'invoicing' ) |
|
690 | + 'BG-01' => __('Blagoevgrad', 'invoicing'), |
|
691 | + 'BG-02' => __('Burgas', 'invoicing'), |
|
692 | + 'BG-08' => __('Dobrich', 'invoicing'), |
|
693 | + 'BG-07' => __('Gabrovo', 'invoicing'), |
|
694 | + 'BG-26' => __('Haskovo', 'invoicing'), |
|
695 | + 'BG-09' => __('Kardzhali', 'invoicing'), |
|
696 | + 'BG-10' => __('Kyustendil', 'invoicing'), |
|
697 | + 'BG-11' => __('Lovech', 'invoicing'), |
|
698 | + 'BG-12' => __('Montana', 'invoicing'), |
|
699 | + 'BG-13' => __('Pazardzhik', 'invoicing'), |
|
700 | + 'BG-14' => __('Pernik', 'invoicing'), |
|
701 | + 'BG-15' => __('Pleven', 'invoicing'), |
|
702 | + 'BG-16' => __('Plovdiv', 'invoicing'), |
|
703 | + 'BG-17' => __('Razgrad', 'invoicing'), |
|
704 | + 'BG-18' => __('Ruse', 'invoicing'), |
|
705 | + 'BG-27' => __('Shumen', 'invoicing'), |
|
706 | + 'BG-19' => __('Silistra', 'invoicing'), |
|
707 | + 'BG-20' => __('Sliven', 'invoicing'), |
|
708 | + 'BG-21' => __('Smolyan', 'invoicing'), |
|
709 | + 'BG-23' => __('Sofia', 'invoicing'), |
|
710 | + 'BG-22' => __('Sofia-Grad', 'invoicing'), |
|
711 | + 'BG-24' => __('Stara Zagora', 'invoicing'), |
|
712 | + 'BG-25' => __('Targovishte', 'invoicing'), |
|
713 | + 'BG-03' => __('Varna', 'invoicing'), |
|
714 | + 'BG-04' => __('Veliko Tarnovo', 'invoicing'), |
|
715 | + 'BG-05' => __('Vidin', 'invoicing'), |
|
716 | + 'BG-06' => __('Vratsa', 'invoicing'), |
|
717 | + 'BG-28' => __('Yambol', 'invoicing') |
|
718 | 718 | ); |
719 | 719 | |
720 | - return apply_filters( 'wpinv_bulgaria_states', $states ); |
|
720 | + return apply_filters('wpinv_bulgaria_states', $states); |
|
721 | 721 | } |
722 | 722 | |
723 | 723 | function wpinv_get_hong_kong_states_list() { |
724 | 724 | $states = array( |
725 | - 'HONG KONG' => __( 'Hong Kong Island', 'invoicing' ), |
|
726 | - 'KOWLOON' => __( 'Kowloon', 'invoicing' ), |
|
727 | - 'NEW TERRITORIES' => __( 'New Territories', 'invoicing' ) |
|
725 | + 'HONG KONG' => __('Hong Kong Island', 'invoicing'), |
|
726 | + 'KOWLOON' => __('Kowloon', 'invoicing'), |
|
727 | + 'NEW TERRITORIES' => __('New Territories', 'invoicing') |
|
728 | 728 | ); |
729 | 729 | |
730 | - return apply_filters( 'wpinv_hong_kong_states', $states ); |
|
730 | + return apply_filters('wpinv_hong_kong_states', $states); |
|
731 | 731 | } |
732 | 732 | |
733 | 733 | function wpinv_get_hungary_states_list() { |
734 | 734 | $states = array( |
735 | - 'BK' => __( 'Bács-Kiskun', 'invoicing' ), |
|
736 | - 'BE' => __( 'Békés', 'invoicing' ), |
|
737 | - 'BA' => __( 'Baranya', 'invoicing' ), |
|
738 | - 'BZ' => __( 'Borsod-Abaúj-Zemplén', 'invoicing' ), |
|
739 | - 'BU' => __( 'Budapest', 'invoicing' ), |
|
740 | - 'CS' => __( 'Csongrád', 'invoicing' ), |
|
741 | - 'FE' => __( 'Fejér', 'invoicing' ), |
|
742 | - 'GS' => __( 'Győr-Moson-Sopron', 'invoicing' ), |
|
743 | - 'HB' => __( 'Hajdú-Bihar', 'invoicing' ), |
|
744 | - 'HE' => __( 'Heves', 'invoicing' ), |
|
745 | - 'JN' => __( 'Jász-Nagykun-Szolnok', 'invoicing' ), |
|
746 | - 'KE' => __( 'Komárom-Esztergom', 'invoicing' ), |
|
747 | - 'NO' => __( 'Nógrád', 'invoicing' ), |
|
748 | - 'PE' => __( 'Pest', 'invoicing' ), |
|
749 | - 'SO' => __( 'Somogy', 'invoicing' ), |
|
750 | - 'SZ' => __( 'Szabolcs-Szatmár-Bereg', 'invoicing' ), |
|
751 | - 'TO' => __( 'Tolna', 'invoicing' ), |
|
752 | - 'VA' => __( 'Vas', 'invoicing' ), |
|
753 | - 'VE' => __( 'Veszprém', 'invoicing' ), |
|
754 | - 'ZA' => __( 'Zala', 'invoicing' ) |
|
735 | + 'BK' => __('Bács-Kiskun', 'invoicing'), |
|
736 | + 'BE' => __('Békés', 'invoicing'), |
|
737 | + 'BA' => __('Baranya', 'invoicing'), |
|
738 | + 'BZ' => __('Borsod-Abaúj-Zemplén', 'invoicing'), |
|
739 | + 'BU' => __('Budapest', 'invoicing'), |
|
740 | + 'CS' => __('Csongrád', 'invoicing'), |
|
741 | + 'FE' => __('Fejér', 'invoicing'), |
|
742 | + 'GS' => __('Győr-Moson-Sopron', 'invoicing'), |
|
743 | + 'HB' => __('Hajdú-Bihar', 'invoicing'), |
|
744 | + 'HE' => __('Heves', 'invoicing'), |
|
745 | + 'JN' => __('Jász-Nagykun-Szolnok', 'invoicing'), |
|
746 | + 'KE' => __('Komárom-Esztergom', 'invoicing'), |
|
747 | + 'NO' => __('Nógrád', 'invoicing'), |
|
748 | + 'PE' => __('Pest', 'invoicing'), |
|
749 | + 'SO' => __('Somogy', 'invoicing'), |
|
750 | + 'SZ' => __('Szabolcs-Szatmár-Bereg', 'invoicing'), |
|
751 | + 'TO' => __('Tolna', 'invoicing'), |
|
752 | + 'VA' => __('Vas', 'invoicing'), |
|
753 | + 'VE' => __('Veszprém', 'invoicing'), |
|
754 | + 'ZA' => __('Zala', 'invoicing') |
|
755 | 755 | ); |
756 | 756 | |
757 | - return apply_filters( 'wpinv_hungary_states', $states ); |
|
757 | + return apply_filters('wpinv_hungary_states', $states); |
|
758 | 758 | } |
759 | 759 | |
760 | 760 | function wpinv_get_japan_states_list() { |
761 | 761 | $states = array( |
762 | - 'JP01' => __( 'Hokkaido', 'invoicing' ), |
|
763 | - 'JP02' => __( 'Aomori', 'invoicing' ), |
|
764 | - 'JP03' => __( 'Iwate', 'invoicing' ), |
|
765 | - 'JP04' => __( 'Miyagi', 'invoicing' ), |
|
766 | - 'JP05' => __( 'Akita', 'invoicing' ), |
|
767 | - 'JP06' => __( 'Yamagata', 'invoicing' ), |
|
768 | - 'JP07' => __( 'Fukushima', 'invoicing' ), |
|
769 | - 'JP08' => __( 'Ibaraki', 'invoicing' ), |
|
770 | - 'JP09' => __( 'Tochigi', 'invoicing' ), |
|
771 | - 'JP10' => __( 'Gunma', 'invoicing' ), |
|
772 | - 'JP11' => __( 'Saitama', 'invoicing' ), |
|
773 | - 'JP12' => __( 'Chiba', 'invoicing' ), |
|
774 | - 'JP13' => __( 'Tokyo', 'invoicing' ), |
|
775 | - 'JP14' => __( 'Kanagawa', 'invoicing' ), |
|
776 | - 'JP15' => __( 'Niigata', 'invoicing' ), |
|
777 | - 'JP16' => __( 'Toyama', 'invoicing' ), |
|
778 | - 'JP17' => __( 'Ishikawa', 'invoicing' ), |
|
779 | - 'JP18' => __( 'Fukui', 'invoicing' ), |
|
780 | - 'JP19' => __( 'Yamanashi', 'invoicing' ), |
|
781 | - 'JP20' => __( 'Nagano', 'invoicing' ), |
|
782 | - 'JP21' => __( 'Gifu', 'invoicing' ), |
|
783 | - 'JP22' => __( 'Shizuoka', 'invoicing' ), |
|
784 | - 'JP23' => __( 'Aichi', 'invoicing' ), |
|
785 | - 'JP24' => __( 'Mie', 'invoicing' ), |
|
786 | - 'JP25' => __( 'Shiga', 'invoicing' ), |
|
787 | - 'JP26' => __( 'Kyouto', 'invoicing' ), |
|
788 | - 'JP27' => __( 'Osaka', 'invoicing' ), |
|
789 | - 'JP28' => __( 'Hyougo', 'invoicing' ), |
|
790 | - 'JP29' => __( 'Nara', 'invoicing' ), |
|
791 | - 'JP30' => __( 'Wakayama', 'invoicing' ), |
|
792 | - 'JP31' => __( 'Tottori', 'invoicing' ), |
|
793 | - 'JP32' => __( 'Shimane', 'invoicing' ), |
|
794 | - 'JP33' => __( 'Okayama', 'invoicing' ), |
|
795 | - 'JP34' => __( 'Hiroshima', 'invoicing' ), |
|
796 | - 'JP35' => __( 'Yamaguchi', 'invoicing' ), |
|
797 | - 'JP36' => __( 'Tokushima', 'invoicing' ), |
|
798 | - 'JP37' => __( 'Kagawa', 'invoicing' ), |
|
799 | - 'JP38' => __( 'Ehime', 'invoicing' ), |
|
800 | - 'JP39' => __( 'Kochi', 'invoicing' ), |
|
801 | - 'JP40' => __( 'Fukuoka', 'invoicing' ), |
|
802 | - 'JP41' => __( 'Saga', 'invoicing' ), |
|
803 | - 'JP42' => __( 'Nagasaki', 'invoicing' ), |
|
804 | - 'JP43' => __( 'Kumamoto', 'invoicing' ), |
|
805 | - 'JP44' => __( 'Oita', 'invoicing' ), |
|
806 | - 'JP45' => __( 'Miyazaki', 'invoicing' ), |
|
807 | - 'JP46' => __( 'Kagoshima', 'invoicing' ), |
|
808 | - 'JP47' => __( 'Okinawa', 'invoicing' ) |
|
762 | + 'JP01' => __('Hokkaido', 'invoicing'), |
|
763 | + 'JP02' => __('Aomori', 'invoicing'), |
|
764 | + 'JP03' => __('Iwate', 'invoicing'), |
|
765 | + 'JP04' => __('Miyagi', 'invoicing'), |
|
766 | + 'JP05' => __('Akita', 'invoicing'), |
|
767 | + 'JP06' => __('Yamagata', 'invoicing'), |
|
768 | + 'JP07' => __('Fukushima', 'invoicing'), |
|
769 | + 'JP08' => __('Ibaraki', 'invoicing'), |
|
770 | + 'JP09' => __('Tochigi', 'invoicing'), |
|
771 | + 'JP10' => __('Gunma', 'invoicing'), |
|
772 | + 'JP11' => __('Saitama', 'invoicing'), |
|
773 | + 'JP12' => __('Chiba', 'invoicing'), |
|
774 | + 'JP13' => __('Tokyo', 'invoicing'), |
|
775 | + 'JP14' => __('Kanagawa', 'invoicing'), |
|
776 | + 'JP15' => __('Niigata', 'invoicing'), |
|
777 | + 'JP16' => __('Toyama', 'invoicing'), |
|
778 | + 'JP17' => __('Ishikawa', 'invoicing'), |
|
779 | + 'JP18' => __('Fukui', 'invoicing'), |
|
780 | + 'JP19' => __('Yamanashi', 'invoicing'), |
|
781 | + 'JP20' => __('Nagano', 'invoicing'), |
|
782 | + 'JP21' => __('Gifu', 'invoicing'), |
|
783 | + 'JP22' => __('Shizuoka', 'invoicing'), |
|
784 | + 'JP23' => __('Aichi', 'invoicing'), |
|
785 | + 'JP24' => __('Mie', 'invoicing'), |
|
786 | + 'JP25' => __('Shiga', 'invoicing'), |
|
787 | + 'JP26' => __('Kyouto', 'invoicing'), |
|
788 | + 'JP27' => __('Osaka', 'invoicing'), |
|
789 | + 'JP28' => __('Hyougo', 'invoicing'), |
|
790 | + 'JP29' => __('Nara', 'invoicing'), |
|
791 | + 'JP30' => __('Wakayama', 'invoicing'), |
|
792 | + 'JP31' => __('Tottori', 'invoicing'), |
|
793 | + 'JP32' => __('Shimane', 'invoicing'), |
|
794 | + 'JP33' => __('Okayama', 'invoicing'), |
|
795 | + 'JP34' => __('Hiroshima', 'invoicing'), |
|
796 | + 'JP35' => __('Yamaguchi', 'invoicing'), |
|
797 | + 'JP36' => __('Tokushima', 'invoicing'), |
|
798 | + 'JP37' => __('Kagawa', 'invoicing'), |
|
799 | + 'JP38' => __('Ehime', 'invoicing'), |
|
800 | + 'JP39' => __('Kochi', 'invoicing'), |
|
801 | + 'JP40' => __('Fukuoka', 'invoicing'), |
|
802 | + 'JP41' => __('Saga', 'invoicing'), |
|
803 | + 'JP42' => __('Nagasaki', 'invoicing'), |
|
804 | + 'JP43' => __('Kumamoto', 'invoicing'), |
|
805 | + 'JP44' => __('Oita', 'invoicing'), |
|
806 | + 'JP45' => __('Miyazaki', 'invoicing'), |
|
807 | + 'JP46' => __('Kagoshima', 'invoicing'), |
|
808 | + 'JP47' => __('Okinawa', 'invoicing') |
|
809 | 809 | ); |
810 | 810 | |
811 | - return apply_filters( 'wpinv_japan_states', $states ); |
|
811 | + return apply_filters('wpinv_japan_states', $states); |
|
812 | 812 | } |
813 | 813 | |
814 | 814 | function wpinv_get_china_states_list() { |
815 | 815 | $states = array( |
816 | - 'CN1' => __( 'Yunnan / 云南', 'invoicing' ), |
|
817 | - 'CN2' => __( 'Beijing / 北京', 'invoicing' ), |
|
818 | - 'CN3' => __( 'Tianjin / 天津', 'invoicing' ), |
|
819 | - 'CN4' => __( 'Hebei / 河北', 'invoicing' ), |
|
820 | - 'CN5' => __( 'Shanxi / 山西', 'invoicing' ), |
|
821 | - 'CN6' => __( 'Inner Mongolia / 內蒙古', 'invoicing' ), |
|
822 | - 'CN7' => __( 'Liaoning / 辽宁', 'invoicing' ), |
|
823 | - 'CN8' => __( 'Jilin / 吉林', 'invoicing' ), |
|
824 | - 'CN9' => __( 'Heilongjiang / 黑龙江', 'invoicing' ), |
|
825 | - 'CN10' => __( 'Shanghai / 上海', 'invoicing' ), |
|
826 | - 'CN11' => __( 'Jiangsu / 江苏', 'invoicing' ), |
|
827 | - 'CN12' => __( 'Zhejiang / 浙江', 'invoicing' ), |
|
828 | - 'CN13' => __( 'Anhui / 安徽', 'invoicing' ), |
|
829 | - 'CN14' => __( 'Fujian / 福建', 'invoicing' ), |
|
830 | - 'CN15' => __( 'Jiangxi / 江西', 'invoicing' ), |
|
831 | - 'CN16' => __( 'Shandong / 山东', 'invoicing' ), |
|
832 | - 'CN17' => __( 'Henan / 河南', 'invoicing' ), |
|
833 | - 'CN18' => __( 'Hubei / 湖北', 'invoicing' ), |
|
834 | - 'CN19' => __( 'Hunan / 湖南', 'invoicing' ), |
|
835 | - 'CN20' => __( 'Guangdong / 广东', 'invoicing' ), |
|
836 | - 'CN21' => __( 'Guangxi Zhuang / 广西壮族', 'invoicing' ), |
|
837 | - 'CN22' => __( 'Hainan / 海南', 'invoicing' ), |
|
838 | - 'CN23' => __( 'Chongqing / 重庆', 'invoicing' ), |
|
839 | - 'CN24' => __( 'Sichuan / 四川', 'invoicing' ), |
|
840 | - 'CN25' => __( 'Guizhou / 贵州', 'invoicing' ), |
|
841 | - 'CN26' => __( 'Shaanxi / 陕西', 'invoicing' ), |
|
842 | - 'CN27' => __( 'Gansu / 甘肃', 'invoicing' ), |
|
843 | - 'CN28' => __( 'Qinghai / 青海', 'invoicing' ), |
|
844 | - 'CN29' => __( 'Ningxia Hui / 宁夏', 'invoicing' ), |
|
845 | - 'CN30' => __( 'Macau / 澳门', 'invoicing' ), |
|
846 | - 'CN31' => __( 'Tibet / 西藏', 'invoicing' ), |
|
847 | - 'CN32' => __( 'Xinjiang / 新疆', 'invoicing' ) |
|
816 | + 'CN1' => __('Yunnan / 云南', 'invoicing'), |
|
817 | + 'CN2' => __('Beijing / 北京', 'invoicing'), |
|
818 | + 'CN3' => __('Tianjin / 天津', 'invoicing'), |
|
819 | + 'CN4' => __('Hebei / 河北', 'invoicing'), |
|
820 | + 'CN5' => __('Shanxi / 山西', 'invoicing'), |
|
821 | + 'CN6' => __('Inner Mongolia / 內蒙古', 'invoicing'), |
|
822 | + 'CN7' => __('Liaoning / 辽宁', 'invoicing'), |
|
823 | + 'CN8' => __('Jilin / 吉林', 'invoicing'), |
|
824 | + 'CN9' => __('Heilongjiang / 黑龙江', 'invoicing'), |
|
825 | + 'CN10' => __('Shanghai / 上海', 'invoicing'), |
|
826 | + 'CN11' => __('Jiangsu / 江苏', 'invoicing'), |
|
827 | + 'CN12' => __('Zhejiang / 浙江', 'invoicing'), |
|
828 | + 'CN13' => __('Anhui / 安徽', 'invoicing'), |
|
829 | + 'CN14' => __('Fujian / 福建', 'invoicing'), |
|
830 | + 'CN15' => __('Jiangxi / 江西', 'invoicing'), |
|
831 | + 'CN16' => __('Shandong / 山东', 'invoicing'), |
|
832 | + 'CN17' => __('Henan / 河南', 'invoicing'), |
|
833 | + 'CN18' => __('Hubei / 湖北', 'invoicing'), |
|
834 | + 'CN19' => __('Hunan / 湖南', 'invoicing'), |
|
835 | + 'CN20' => __('Guangdong / 广东', 'invoicing'), |
|
836 | + 'CN21' => __('Guangxi Zhuang / 广西壮族', 'invoicing'), |
|
837 | + 'CN22' => __('Hainan / 海南', 'invoicing'), |
|
838 | + 'CN23' => __('Chongqing / 重庆', 'invoicing'), |
|
839 | + 'CN24' => __('Sichuan / 四川', 'invoicing'), |
|
840 | + 'CN25' => __('Guizhou / 贵州', 'invoicing'), |
|
841 | + 'CN26' => __('Shaanxi / 陕西', 'invoicing'), |
|
842 | + 'CN27' => __('Gansu / 甘肃', 'invoicing'), |
|
843 | + 'CN28' => __('Qinghai / 青海', 'invoicing'), |
|
844 | + 'CN29' => __('Ningxia Hui / 宁夏', 'invoicing'), |
|
845 | + 'CN30' => __('Macau / 澳门', 'invoicing'), |
|
846 | + 'CN31' => __('Tibet / 西藏', 'invoicing'), |
|
847 | + 'CN32' => __('Xinjiang / 新疆', 'invoicing') |
|
848 | 848 | ); |
849 | 849 | |
850 | - return apply_filters( 'wpinv_china_states', $states ); |
|
850 | + return apply_filters('wpinv_china_states', $states); |
|
851 | 851 | } |
852 | 852 | |
853 | 853 | function wpinv_get_new_zealand_states_list() { |
854 | 854 | $states = array( |
855 | - 'AK' => __( 'Auckland', 'invoicing' ), |
|
856 | - 'BP' => __( 'Bay of Plenty', 'invoicing' ), |
|
857 | - 'CT' => __( 'Canterbury', 'invoicing' ), |
|
858 | - 'HB' => __( 'Hawke’s Bay', 'invoicing' ), |
|
859 | - 'MW' => __( 'Manawatu-Wanganui', 'invoicing' ), |
|
860 | - 'MB' => __( 'Marlborough', 'invoicing' ), |
|
861 | - 'NS' => __( 'Nelson', 'invoicing' ), |
|
862 | - 'NL' => __( 'Northland', 'invoicing' ), |
|
863 | - 'OT' => __( 'Otago', 'invoicing' ), |
|
864 | - 'SL' => __( 'Southland', 'invoicing' ), |
|
865 | - 'TK' => __( 'Taranaki', 'invoicing' ), |
|
866 | - 'TM' => __( 'Tasman', 'invoicing' ), |
|
867 | - 'WA' => __( 'Waikato', 'invoicing' ), |
|
868 | - 'WR' => __( 'Wairarapa', 'invoicing' ), |
|
869 | - 'WE' => __( 'Wellington', 'invoicing' ), |
|
870 | - 'WC' => __( 'West Coast', 'invoicing' ) |
|
855 | + 'AK' => __('Auckland', 'invoicing'), |
|
856 | + 'BP' => __('Bay of Plenty', 'invoicing'), |
|
857 | + 'CT' => __('Canterbury', 'invoicing'), |
|
858 | + 'HB' => __('Hawke’s Bay', 'invoicing'), |
|
859 | + 'MW' => __('Manawatu-Wanganui', 'invoicing'), |
|
860 | + 'MB' => __('Marlborough', 'invoicing'), |
|
861 | + 'NS' => __('Nelson', 'invoicing'), |
|
862 | + 'NL' => __('Northland', 'invoicing'), |
|
863 | + 'OT' => __('Otago', 'invoicing'), |
|
864 | + 'SL' => __('Southland', 'invoicing'), |
|
865 | + 'TK' => __('Taranaki', 'invoicing'), |
|
866 | + 'TM' => __('Tasman', 'invoicing'), |
|
867 | + 'WA' => __('Waikato', 'invoicing'), |
|
868 | + 'WR' => __('Wairarapa', 'invoicing'), |
|
869 | + 'WE' => __('Wellington', 'invoicing'), |
|
870 | + 'WC' => __('West Coast', 'invoicing') |
|
871 | 871 | ); |
872 | 872 | |
873 | - return apply_filters( 'wpinv_new_zealand_states', $states ); |
|
873 | + return apply_filters('wpinv_new_zealand_states', $states); |
|
874 | 874 | } |
875 | 875 | |
876 | 876 | function wpinv_get_peru_states_list() { |
877 | 877 | $states = array( |
878 | - 'CAL' => __( 'El Callao', 'invoicing' ), |
|
879 | - 'LMA' => __( 'Municipalidad Metropolitana de Lima', 'invoicing' ), |
|
880 | - 'AMA' => __( 'Amazonas', 'invoicing' ), |
|
881 | - 'ANC' => __( 'Ancash', 'invoicing' ), |
|
882 | - 'APU' => __( 'Apurímac', 'invoicing' ), |
|
883 | - 'ARE' => __( 'Arequipa', 'invoicing' ), |
|
884 | - 'AYA' => __( 'Ayacucho', 'invoicing' ), |
|
885 | - 'CAJ' => __( 'Cajamarca', 'invoicing' ), |
|
886 | - 'CUS' => __( 'Cusco', 'invoicing' ), |
|
887 | - 'HUV' => __( 'Huancavelica', 'invoicing' ), |
|
888 | - 'HUC' => __( 'Huánuco', 'invoicing' ), |
|
889 | - 'ICA' => __( 'Ica', 'invoicing' ), |
|
890 | - 'JUN' => __( 'Junín', 'invoicing' ), |
|
891 | - 'LAL' => __( 'La Libertad', 'invoicing' ), |
|
892 | - 'LAM' => __( 'Lambayeque', 'invoicing' ), |
|
893 | - 'LIM' => __( 'Lima', 'invoicing' ), |
|
894 | - 'LOR' => __( 'Loreto', 'invoicing' ), |
|
895 | - 'MDD' => __( 'Madre de Dios', 'invoicing' ), |
|
896 | - 'MOQ' => __( 'Moquegua', 'invoicing' ), |
|
897 | - 'PAS' => __( 'Pasco', 'invoicing' ), |
|
898 | - 'PIU' => __( 'Piura', 'invoicing' ), |
|
899 | - 'PUN' => __( 'Puno', 'invoicing' ), |
|
900 | - 'SAM' => __( 'San Martín', 'invoicing' ), |
|
901 | - 'TAC' => __( 'Tacna', 'invoicing' ), |
|
902 | - 'TUM' => __( 'Tumbes', 'invoicing' ), |
|
903 | - 'UCA' => __( 'Ucayali', 'invoicing' ) |
|
878 | + 'CAL' => __('El Callao', 'invoicing'), |
|
879 | + 'LMA' => __('Municipalidad Metropolitana de Lima', 'invoicing'), |
|
880 | + 'AMA' => __('Amazonas', 'invoicing'), |
|
881 | + 'ANC' => __('Ancash', 'invoicing'), |
|
882 | + 'APU' => __('Apurímac', 'invoicing'), |
|
883 | + 'ARE' => __('Arequipa', 'invoicing'), |
|
884 | + 'AYA' => __('Ayacucho', 'invoicing'), |
|
885 | + 'CAJ' => __('Cajamarca', 'invoicing'), |
|
886 | + 'CUS' => __('Cusco', 'invoicing'), |
|
887 | + 'HUV' => __('Huancavelica', 'invoicing'), |
|
888 | + 'HUC' => __('Huánuco', 'invoicing'), |
|
889 | + 'ICA' => __('Ica', 'invoicing'), |
|
890 | + 'JUN' => __('Junín', 'invoicing'), |
|
891 | + 'LAL' => __('La Libertad', 'invoicing'), |
|
892 | + 'LAM' => __('Lambayeque', 'invoicing'), |
|
893 | + 'LIM' => __('Lima', 'invoicing'), |
|
894 | + 'LOR' => __('Loreto', 'invoicing'), |
|
895 | + 'MDD' => __('Madre de Dios', 'invoicing'), |
|
896 | + 'MOQ' => __('Moquegua', 'invoicing'), |
|
897 | + 'PAS' => __('Pasco', 'invoicing'), |
|
898 | + 'PIU' => __('Piura', 'invoicing'), |
|
899 | + 'PUN' => __('Puno', 'invoicing'), |
|
900 | + 'SAM' => __('San Martín', 'invoicing'), |
|
901 | + 'TAC' => __('Tacna', 'invoicing'), |
|
902 | + 'TUM' => __('Tumbes', 'invoicing'), |
|
903 | + 'UCA' => __('Ucayali', 'invoicing') |
|
904 | 904 | ); |
905 | 905 | |
906 | - return apply_filters( 'wpinv_peru_states', $states ); |
|
906 | + return apply_filters('wpinv_peru_states', $states); |
|
907 | 907 | } |
908 | 908 | |
909 | 909 | function wpinv_get_indonesia_states_list() { |
910 | - $states = array( |
|
911 | - 'AC' => __( 'Daerah Istimewa Aceh', 'invoicing' ), |
|
912 | - 'SU' => __( 'Sumatera Utara', 'invoicing' ), |
|
913 | - 'SB' => __( 'Sumatera Barat', 'invoicing' ), |
|
914 | - 'RI' => __( 'Riau', 'invoicing' ), |
|
915 | - 'KR' => __( 'Kepulauan Riau', 'invoicing' ), |
|
916 | - 'JA' => __( 'Jambi', 'invoicing' ), |
|
917 | - 'SS' => __( 'Sumatera Selatan', 'invoicing' ), |
|
918 | - 'BB' => __( 'Bangka Belitung', 'invoicing' ), |
|
919 | - 'BE' => __( 'Bengkulu', 'invoicing' ), |
|
920 | - 'LA' => __( 'Lampung', 'invoicing' ), |
|
921 | - 'JK' => __( 'DKI Jakarta', 'invoicing' ), |
|
922 | - 'JB' => __( 'Jawa Barat', 'invoicing' ), |
|
923 | - 'BT' => __( 'Banten', 'invoicing' ), |
|
924 | - 'JT' => __( 'Jawa Tengah', 'invoicing' ), |
|
925 | - 'JI' => __( 'Jawa Timur', 'invoicing' ), |
|
926 | - 'YO' => __( 'Daerah Istimewa Yogyakarta', 'invoicing' ), |
|
927 | - 'BA' => __( 'Bali', 'invoicing' ), |
|
928 | - 'NB' => __( 'Nusa Tenggara Barat', 'invoicing' ), |
|
929 | - 'NT' => __( 'Nusa Tenggara Timur', 'invoicing' ), |
|
930 | - 'KB' => __( 'Kalimantan Barat', 'invoicing' ), |
|
931 | - 'KT' => __( 'Kalimantan Tengah', 'invoicing' ), |
|
932 | - 'KI' => __( 'Kalimantan Timur', 'invoicing' ), |
|
933 | - 'KS' => __( 'Kalimantan Selatan', 'invoicing' ), |
|
934 | - 'KU' => __( 'Kalimantan Utara', 'invoicing' ), |
|
935 | - 'SA' => __( 'Sulawesi Utara', 'invoicing' ), |
|
936 | - 'ST' => __( 'Sulawesi Tengah', 'invoicing' ), |
|
937 | - 'SG' => __( 'Sulawesi Tenggara', 'invoicing' ), |
|
938 | - 'SR' => __( 'Sulawesi Barat', 'invoicing' ), |
|
939 | - 'SN' => __( 'Sulawesi Selatan', 'invoicing' ), |
|
940 | - 'GO' => __( 'Gorontalo', 'invoicing' ), |
|
941 | - 'MA' => __( 'Maluku', 'invoicing' ), |
|
942 | - 'MU' => __( 'Maluku Utara', 'invoicing' ), |
|
943 | - 'PA' => __( 'Papua', 'invoicing' ), |
|
944 | - 'PB' => __( 'Papua Barat', 'invoicing' ) |
|
910 | + $states = array( |
|
911 | + 'AC' => __('Daerah Istimewa Aceh', 'invoicing'), |
|
912 | + 'SU' => __('Sumatera Utara', 'invoicing'), |
|
913 | + 'SB' => __('Sumatera Barat', 'invoicing'), |
|
914 | + 'RI' => __('Riau', 'invoicing'), |
|
915 | + 'KR' => __('Kepulauan Riau', 'invoicing'), |
|
916 | + 'JA' => __('Jambi', 'invoicing'), |
|
917 | + 'SS' => __('Sumatera Selatan', 'invoicing'), |
|
918 | + 'BB' => __('Bangka Belitung', 'invoicing'), |
|
919 | + 'BE' => __('Bengkulu', 'invoicing'), |
|
920 | + 'LA' => __('Lampung', 'invoicing'), |
|
921 | + 'JK' => __('DKI Jakarta', 'invoicing'), |
|
922 | + 'JB' => __('Jawa Barat', 'invoicing'), |
|
923 | + 'BT' => __('Banten', 'invoicing'), |
|
924 | + 'JT' => __('Jawa Tengah', 'invoicing'), |
|
925 | + 'JI' => __('Jawa Timur', 'invoicing'), |
|
926 | + 'YO' => __('Daerah Istimewa Yogyakarta', 'invoicing'), |
|
927 | + 'BA' => __('Bali', 'invoicing'), |
|
928 | + 'NB' => __('Nusa Tenggara Barat', 'invoicing'), |
|
929 | + 'NT' => __('Nusa Tenggara Timur', 'invoicing'), |
|
930 | + 'KB' => __('Kalimantan Barat', 'invoicing'), |
|
931 | + 'KT' => __('Kalimantan Tengah', 'invoicing'), |
|
932 | + 'KI' => __('Kalimantan Timur', 'invoicing'), |
|
933 | + 'KS' => __('Kalimantan Selatan', 'invoicing'), |
|
934 | + 'KU' => __('Kalimantan Utara', 'invoicing'), |
|
935 | + 'SA' => __('Sulawesi Utara', 'invoicing'), |
|
936 | + 'ST' => __('Sulawesi Tengah', 'invoicing'), |
|
937 | + 'SG' => __('Sulawesi Tenggara', 'invoicing'), |
|
938 | + 'SR' => __('Sulawesi Barat', 'invoicing'), |
|
939 | + 'SN' => __('Sulawesi Selatan', 'invoicing'), |
|
940 | + 'GO' => __('Gorontalo', 'invoicing'), |
|
941 | + 'MA' => __('Maluku', 'invoicing'), |
|
942 | + 'MU' => __('Maluku Utara', 'invoicing'), |
|
943 | + 'PA' => __('Papua', 'invoicing'), |
|
944 | + 'PB' => __('Papua Barat', 'invoicing') |
|
945 | 945 | ); |
946 | 946 | |
947 | - return apply_filters( 'wpinv_indonesia_states', $states ); |
|
947 | + return apply_filters('wpinv_indonesia_states', $states); |
|
948 | 948 | } |
949 | 949 | |
950 | 950 | function wpinv_get_india_states_list() { |
951 | 951 | $states = array( |
952 | - 'AP' => __( 'Andhra Pradesh', 'invoicing' ), |
|
953 | - 'AR' => __( 'Arunachal Pradesh', 'invoicing' ), |
|
954 | - 'AS' => __( 'Assam', 'invoicing' ), |
|
955 | - 'BR' => __( 'Bihar', 'invoicing' ), |
|
956 | - 'CT' => __( 'Chhattisgarh', 'invoicing' ), |
|
957 | - 'GA' => __( 'Goa', 'invoicing' ), |
|
958 | - 'GJ' => __( 'Gujarat', 'invoicing' ), |
|
959 | - 'HR' => __( 'Haryana', 'invoicing' ), |
|
960 | - 'HP' => __( 'Himachal Pradesh', 'invoicing' ), |
|
961 | - 'JK' => __( 'Jammu and Kashmir', 'invoicing' ), |
|
962 | - 'JH' => __( 'Jharkhand', 'invoicing' ), |
|
963 | - 'KA' => __( 'Karnataka', 'invoicing' ), |
|
964 | - 'KL' => __( 'Kerala', 'invoicing' ), |
|
965 | - 'MP' => __( 'Madhya Pradesh', 'invoicing' ), |
|
966 | - 'MH' => __( 'Maharashtra', 'invoicing' ), |
|
967 | - 'MN' => __( 'Manipur', 'invoicing' ), |
|
968 | - 'ML' => __( 'Meghalaya', 'invoicing' ), |
|
969 | - 'MZ' => __( 'Mizoram', 'invoicing' ), |
|
970 | - 'NL' => __( 'Nagaland', 'invoicing' ), |
|
971 | - 'OR' => __( 'Orissa', 'invoicing' ), |
|
972 | - 'PB' => __( 'Punjab', 'invoicing' ), |
|
973 | - 'RJ' => __( 'Rajasthan', 'invoicing' ), |
|
974 | - 'SK' => __( 'Sikkim', 'invoicing' ), |
|
975 | - 'TN' => __( 'Tamil Nadu', 'invoicing' ), |
|
976 | - 'TG' => __( 'Telangana', 'invoicing' ), |
|
977 | - 'TR' => __( 'Tripura', 'invoicing' ), |
|
978 | - 'UT' => __( 'Uttarakhand', 'invoicing' ), |
|
979 | - 'UP' => __( 'Uttar Pradesh', 'invoicing' ), |
|
980 | - 'WB' => __( 'West Bengal', 'invoicing' ), |
|
981 | - 'AN' => __( 'Andaman and Nicobar Islands', 'invoicing' ), |
|
982 | - 'CH' => __( 'Chandigarh', 'invoicing' ), |
|
983 | - 'DN' => __( 'Dadar and Nagar Haveli', 'invoicing' ), |
|
984 | - 'DD' => __( 'Daman and Diu', 'invoicing' ), |
|
985 | - 'DL' => __( 'Delhi', 'invoicing' ), |
|
986 | - 'LD' => __( 'Lakshadweep', 'invoicing' ), |
|
987 | - 'PY' => __( 'Pondicherry (Puducherry)', 'invoicing' ) |
|
952 | + 'AP' => __('Andhra Pradesh', 'invoicing'), |
|
953 | + 'AR' => __('Arunachal Pradesh', 'invoicing'), |
|
954 | + 'AS' => __('Assam', 'invoicing'), |
|
955 | + 'BR' => __('Bihar', 'invoicing'), |
|
956 | + 'CT' => __('Chhattisgarh', 'invoicing'), |
|
957 | + 'GA' => __('Goa', 'invoicing'), |
|
958 | + 'GJ' => __('Gujarat', 'invoicing'), |
|
959 | + 'HR' => __('Haryana', 'invoicing'), |
|
960 | + 'HP' => __('Himachal Pradesh', 'invoicing'), |
|
961 | + 'JK' => __('Jammu and Kashmir', 'invoicing'), |
|
962 | + 'JH' => __('Jharkhand', 'invoicing'), |
|
963 | + 'KA' => __('Karnataka', 'invoicing'), |
|
964 | + 'KL' => __('Kerala', 'invoicing'), |
|
965 | + 'MP' => __('Madhya Pradesh', 'invoicing'), |
|
966 | + 'MH' => __('Maharashtra', 'invoicing'), |
|
967 | + 'MN' => __('Manipur', 'invoicing'), |
|
968 | + 'ML' => __('Meghalaya', 'invoicing'), |
|
969 | + 'MZ' => __('Mizoram', 'invoicing'), |
|
970 | + 'NL' => __('Nagaland', 'invoicing'), |
|
971 | + 'OR' => __('Orissa', 'invoicing'), |
|
972 | + 'PB' => __('Punjab', 'invoicing'), |
|
973 | + 'RJ' => __('Rajasthan', 'invoicing'), |
|
974 | + 'SK' => __('Sikkim', 'invoicing'), |
|
975 | + 'TN' => __('Tamil Nadu', 'invoicing'), |
|
976 | + 'TG' => __('Telangana', 'invoicing'), |
|
977 | + 'TR' => __('Tripura', 'invoicing'), |
|
978 | + 'UT' => __('Uttarakhand', 'invoicing'), |
|
979 | + 'UP' => __('Uttar Pradesh', 'invoicing'), |
|
980 | + 'WB' => __('West Bengal', 'invoicing'), |
|
981 | + 'AN' => __('Andaman and Nicobar Islands', 'invoicing'), |
|
982 | + 'CH' => __('Chandigarh', 'invoicing'), |
|
983 | + 'DN' => __('Dadar and Nagar Haveli', 'invoicing'), |
|
984 | + 'DD' => __('Daman and Diu', 'invoicing'), |
|
985 | + 'DL' => __('Delhi', 'invoicing'), |
|
986 | + 'LD' => __('Lakshadweep', 'invoicing'), |
|
987 | + 'PY' => __('Pondicherry (Puducherry)', 'invoicing') |
|
988 | 988 | ); |
989 | 989 | |
990 | - return apply_filters( 'wpinv_india_states', $states ); |
|
990 | + return apply_filters('wpinv_india_states', $states); |
|
991 | 991 | } |
992 | 992 | |
993 | 993 | function wpinv_get_iran_states_list() { |
994 | 994 | $states = array( |
995 | - 'KHZ' => __( 'Khuzestan', 'invoicing' ), |
|
996 | - 'THR' => __( 'Tehran', 'invoicing' ), |
|
997 | - 'ILM' => __( 'Ilaam', 'invoicing' ), |
|
998 | - 'BHR' => __( 'Bushehr', 'invoicing' ), |
|
999 | - 'ADL' => __( 'Ardabil', 'invoicing' ), |
|
1000 | - 'ESF' => __( 'Isfahan', 'invoicing' ), |
|
1001 | - 'YZD' => __( 'Yazd', 'invoicing' ), |
|
1002 | - 'KRH' => __( 'Kermanshah', 'invoicing' ), |
|
1003 | - 'KRN' => __( 'Kerman', 'invoicing' ), |
|
1004 | - 'HDN' => __( 'Hamadan', 'invoicing' ), |
|
1005 | - 'GZN' => __( 'Ghazvin', 'invoicing' ), |
|
1006 | - 'ZJN' => __( 'Zanjan', 'invoicing' ), |
|
1007 | - 'LRS' => __( 'Luristan', 'invoicing' ), |
|
1008 | - 'ABZ' => __( 'Alborz', 'invoicing' ), |
|
1009 | - 'EAZ' => __( 'East Azerbaijan', 'invoicing' ), |
|
1010 | - 'WAZ' => __( 'West Azerbaijan', 'invoicing' ), |
|
1011 | - 'CHB' => __( 'Chaharmahal and Bakhtiari', 'invoicing' ), |
|
1012 | - 'SKH' => __( 'South Khorasan', 'invoicing' ), |
|
1013 | - 'RKH' => __( 'Razavi Khorasan', 'invoicing' ), |
|
1014 | - 'NKH' => __( 'North Khorasan', 'invoicing' ), |
|
1015 | - 'SMN' => __( 'Semnan', 'invoicing' ), |
|
1016 | - 'FRS' => __( 'Fars', 'invoicing' ), |
|
1017 | - 'QHM' => __( 'Qom', 'invoicing' ), |
|
1018 | - 'KRD' => __( 'Kurdistan', 'invoicing' ), |
|
1019 | - 'KBD' => __( 'Kohgiluyeh and BoyerAhmad', 'invoicing' ), |
|
1020 | - 'GLS' => __( 'Golestan', 'invoicing' ), |
|
1021 | - 'GIL' => __( 'Gilan', 'invoicing' ), |
|
1022 | - 'MZN' => __( 'Mazandaran', 'invoicing' ), |
|
1023 | - 'MKZ' => __( 'Markazi', 'invoicing' ), |
|
1024 | - 'HRZ' => __( 'Hormozgan', 'invoicing' ), |
|
1025 | - 'SBN' => __( 'Sistan and Baluchestan', 'invoicing' ) |
|
995 | + 'KHZ' => __('Khuzestan', 'invoicing'), |
|
996 | + 'THR' => __('Tehran', 'invoicing'), |
|
997 | + 'ILM' => __('Ilaam', 'invoicing'), |
|
998 | + 'BHR' => __('Bushehr', 'invoicing'), |
|
999 | + 'ADL' => __('Ardabil', 'invoicing'), |
|
1000 | + 'ESF' => __('Isfahan', 'invoicing'), |
|
1001 | + 'YZD' => __('Yazd', 'invoicing'), |
|
1002 | + 'KRH' => __('Kermanshah', 'invoicing'), |
|
1003 | + 'KRN' => __('Kerman', 'invoicing'), |
|
1004 | + 'HDN' => __('Hamadan', 'invoicing'), |
|
1005 | + 'GZN' => __('Ghazvin', 'invoicing'), |
|
1006 | + 'ZJN' => __('Zanjan', 'invoicing'), |
|
1007 | + 'LRS' => __('Luristan', 'invoicing'), |
|
1008 | + 'ABZ' => __('Alborz', 'invoicing'), |
|
1009 | + 'EAZ' => __('East Azerbaijan', 'invoicing'), |
|
1010 | + 'WAZ' => __('West Azerbaijan', 'invoicing'), |
|
1011 | + 'CHB' => __('Chaharmahal and Bakhtiari', 'invoicing'), |
|
1012 | + 'SKH' => __('South Khorasan', 'invoicing'), |
|
1013 | + 'RKH' => __('Razavi Khorasan', 'invoicing'), |
|
1014 | + 'NKH' => __('North Khorasan', 'invoicing'), |
|
1015 | + 'SMN' => __('Semnan', 'invoicing'), |
|
1016 | + 'FRS' => __('Fars', 'invoicing'), |
|
1017 | + 'QHM' => __('Qom', 'invoicing'), |
|
1018 | + 'KRD' => __('Kurdistan', 'invoicing'), |
|
1019 | + 'KBD' => __('Kohgiluyeh and BoyerAhmad', 'invoicing'), |
|
1020 | + 'GLS' => __('Golestan', 'invoicing'), |
|
1021 | + 'GIL' => __('Gilan', 'invoicing'), |
|
1022 | + 'MZN' => __('Mazandaran', 'invoicing'), |
|
1023 | + 'MKZ' => __('Markazi', 'invoicing'), |
|
1024 | + 'HRZ' => __('Hormozgan', 'invoicing'), |
|
1025 | + 'SBN' => __('Sistan and Baluchestan', 'invoicing') |
|
1026 | 1026 | ); |
1027 | 1027 | |
1028 | - return apply_filters( 'wpinv_iran_states', $states ); |
|
1028 | + return apply_filters('wpinv_iran_states', $states); |
|
1029 | 1029 | } |
1030 | 1030 | |
1031 | 1031 | function wpinv_get_italy_states_list() { |
1032 | 1032 | $states = array( |
1033 | - 'AG' => __( 'Agrigento', 'invoicing' ), |
|
1034 | - 'AL' => __( 'Alessandria', 'invoicing' ), |
|
1035 | - 'AN' => __( 'Ancona', 'invoicing' ), |
|
1036 | - 'AO' => __( 'Aosta', 'invoicing' ), |
|
1037 | - 'AR' => __( 'Arezzo', 'invoicing' ), |
|
1038 | - 'AP' => __( 'Ascoli Piceno', 'invoicing' ), |
|
1039 | - 'AT' => __( 'Asti', 'invoicing' ), |
|
1040 | - 'AV' => __( 'Avellino', 'invoicing' ), |
|
1041 | - 'BA' => __( 'Bari', 'invoicing' ), |
|
1042 | - 'BT' => __( 'Barletta-Andria-Trani', 'invoicing' ), |
|
1043 | - 'BL' => __( 'Belluno', 'invoicing' ), |
|
1044 | - 'BN' => __( 'Benevento', 'invoicing' ), |
|
1045 | - 'BG' => __( 'Bergamo', 'invoicing' ), |
|
1046 | - 'BI' => __( 'Biella', 'invoicing' ), |
|
1047 | - 'BO' => __( 'Bologna', 'invoicing' ), |
|
1048 | - 'BZ' => __( 'Bolzano', 'invoicing' ), |
|
1049 | - 'BS' => __( 'Brescia', 'invoicing' ), |
|
1050 | - 'BR' => __( 'Brindisi', 'invoicing' ), |
|
1051 | - 'CA' => __( 'Cagliari', 'invoicing' ), |
|
1052 | - 'CL' => __( 'Caltanissetta', 'invoicing' ), |
|
1053 | - 'CB' => __( 'Campobasso', 'invoicing' ), |
|
1054 | - 'CI' => __( 'Caltanissetta', 'invoicing' ), |
|
1055 | - 'CE' => __( 'Caserta', 'invoicing' ), |
|
1056 | - 'CT' => __( 'Catania', 'invoicing' ), |
|
1057 | - 'CZ' => __( 'Catanzaro', 'invoicing' ), |
|
1058 | - 'CH' => __( 'Chieti', 'invoicing' ), |
|
1059 | - 'CO' => __( 'Como', 'invoicing' ), |
|
1060 | - 'CS' => __( 'Cosenza', 'invoicing' ), |
|
1061 | - 'CR' => __( 'Cremona', 'invoicing' ), |
|
1062 | - 'KR' => __( 'Crotone', 'invoicing' ), |
|
1063 | - 'CN' => __( 'Cuneo', 'invoicing' ), |
|
1064 | - 'EN' => __( 'Enna', 'invoicing' ), |
|
1065 | - 'FM' => __( 'Fermo', 'invoicing' ), |
|
1066 | - 'FE' => __( 'Ferrara', 'invoicing' ), |
|
1067 | - 'FI' => __( 'Firenze', 'invoicing' ), |
|
1068 | - 'FG' => __( 'Foggia', 'invoicing' ), |
|
1069 | - 'FC' => __( 'Forli-Cesena', 'invoicing' ), |
|
1070 | - 'FR' => __( 'Frosinone', 'invoicing' ), |
|
1071 | - 'GE' => __( 'Genova', 'invoicing' ), |
|
1072 | - 'GO' => __( 'Gorizia', 'invoicing' ), |
|
1073 | - 'GR' => __( 'Grosseto', 'invoicing' ), |
|
1074 | - 'IM' => __( 'Imperia', 'invoicing' ), |
|
1075 | - 'IS' => __( 'Isernia', 'invoicing' ), |
|
1076 | - 'SP' => __( 'La Spezia', 'invoicing' ), |
|
1077 | - 'AQ' => __( 'L'Aquila', 'invoicing' ), |
|
1078 | - 'LT' => __( 'Latina', 'invoicing' ), |
|
1079 | - 'LE' => __( 'Lecce', 'invoicing' ), |
|
1080 | - 'LC' => __( 'Lecco', 'invoicing' ), |
|
1081 | - 'LI' => __( 'Livorno', 'invoicing' ), |
|
1082 | - 'LO' => __( 'Lodi', 'invoicing' ), |
|
1083 | - 'LU' => __( 'Lucca', 'invoicing' ), |
|
1084 | - 'MC' => __( 'Macerata', 'invoicing' ), |
|
1085 | - 'MN' => __( 'Mantova', 'invoicing' ), |
|
1086 | - 'MS' => __( 'Massa-Carrara', 'invoicing' ), |
|
1087 | - 'MT' => __( 'Matera', 'invoicing' ), |
|
1088 | - 'ME' => __( 'Messina', 'invoicing' ), |
|
1089 | - 'MI' => __( 'Milano', 'invoicing' ), |
|
1090 | - 'MO' => __( 'Modena', 'invoicing' ), |
|
1091 | - 'MB' => __( 'Monza e della Brianza', 'invoicing' ), |
|
1092 | - 'NA' => __( 'Napoli', 'invoicing' ), |
|
1093 | - 'NO' => __( 'Novara', 'invoicing' ), |
|
1094 | - 'NU' => __( 'Nuoro', 'invoicing' ), |
|
1095 | - 'OT' => __( 'Olbia-Tempio', 'invoicing' ), |
|
1096 | - 'OR' => __( 'Oristano', 'invoicing' ), |
|
1097 | - 'PD' => __( 'Padova', 'invoicing' ), |
|
1098 | - 'PA' => __( 'Palermo', 'invoicing' ), |
|
1099 | - 'PR' => __( 'Parma', 'invoicing' ), |
|
1100 | - 'PV' => __( 'Pavia', 'invoicing' ), |
|
1101 | - 'PG' => __( 'Perugia', 'invoicing' ), |
|
1102 | - 'PU' => __( 'Pesaro e Urbino', 'invoicing' ), |
|
1103 | - 'PE' => __( 'Pescara', 'invoicing' ), |
|
1104 | - 'PC' => __( 'Piacenza', 'invoicing' ), |
|
1105 | - 'PI' => __( 'Pisa', 'invoicing' ), |
|
1106 | - 'PT' => __( 'Pistoia', 'invoicing' ), |
|
1107 | - 'PN' => __( 'Pordenone', 'invoicing' ), |
|
1108 | - 'PZ' => __( 'Potenza', 'invoicing' ), |
|
1109 | - 'PO' => __( 'Prato', 'invoicing' ), |
|
1110 | - 'RG' => __( 'Ragusa', 'invoicing' ), |
|
1111 | - 'RA' => __( 'Ravenna', 'invoicing' ), |
|
1112 | - 'RC' => __( 'Reggio Calabria', 'invoicing' ), |
|
1113 | - 'RE' => __( 'Reggio Emilia', 'invoicing' ), |
|
1114 | - 'RI' => __( 'Rieti', 'invoicing' ), |
|
1115 | - 'RN' => __( 'Rimini', 'invoicing' ), |
|
1116 | - 'RM' => __( 'Roma', 'invoicing' ), |
|
1117 | - 'RO' => __( 'Rovigo', 'invoicing' ), |
|
1118 | - 'SA' => __( 'Salerno', 'invoicing' ), |
|
1119 | - 'VS' => __( 'Medio Campidano', 'invoicing' ), |
|
1120 | - 'SS' => __( 'Sassari', 'invoicing' ), |
|
1121 | - 'SV' => __( 'Savona', 'invoicing' ), |
|
1122 | - 'SI' => __( 'Siena', 'invoicing' ), |
|
1123 | - 'SR' => __( 'Siracusa', 'invoicing' ), |
|
1124 | - 'SO' => __( 'Sondrio', 'invoicing' ), |
|
1125 | - 'TA' => __( 'Taranto', 'invoicing' ), |
|
1126 | - 'TE' => __( 'Teramo', 'invoicing' ), |
|
1127 | - 'TR' => __( 'Terni', 'invoicing' ), |
|
1128 | - 'TO' => __( 'Torino', 'invoicing' ), |
|
1129 | - 'OG' => __( 'Ogliastra', 'invoicing' ), |
|
1130 | - 'TP' => __( 'Trapani', 'invoicing' ), |
|
1131 | - 'TN' => __( 'Trento', 'invoicing' ), |
|
1132 | - 'TV' => __( 'Treviso', 'invoicing' ), |
|
1133 | - 'TS' => __( 'Trieste', 'invoicing' ), |
|
1134 | - 'UD' => __( 'Udine', 'invoicing' ), |
|
1135 | - 'VA' => __( 'Varesa', 'invoicing' ), |
|
1136 | - 'VE' => __( 'Venezia', 'invoicing' ), |
|
1137 | - 'VB' => __( 'Verbano-Cusio-Ossola', 'invoicing' ), |
|
1138 | - 'VC' => __( 'Vercelli', 'invoicing' ), |
|
1139 | - 'VR' => __( 'Verona', 'invoicing' ), |
|
1140 | - 'VV' => __( 'Vibo Valentia', 'invoicing' ), |
|
1141 | - 'VI' => __( 'Vicenza', 'invoicing' ), |
|
1142 | - 'VT' => __( 'Viterbo', 'invoicing' ) |
|
1033 | + 'AG' => __('Agrigento', 'invoicing'), |
|
1034 | + 'AL' => __('Alessandria', 'invoicing'), |
|
1035 | + 'AN' => __('Ancona', 'invoicing'), |
|
1036 | + 'AO' => __('Aosta', 'invoicing'), |
|
1037 | + 'AR' => __('Arezzo', 'invoicing'), |
|
1038 | + 'AP' => __('Ascoli Piceno', 'invoicing'), |
|
1039 | + 'AT' => __('Asti', 'invoicing'), |
|
1040 | + 'AV' => __('Avellino', 'invoicing'), |
|
1041 | + 'BA' => __('Bari', 'invoicing'), |
|
1042 | + 'BT' => __('Barletta-Andria-Trani', 'invoicing'), |
|
1043 | + 'BL' => __('Belluno', 'invoicing'), |
|
1044 | + 'BN' => __('Benevento', 'invoicing'), |
|
1045 | + 'BG' => __('Bergamo', 'invoicing'), |
|
1046 | + 'BI' => __('Biella', 'invoicing'), |
|
1047 | + 'BO' => __('Bologna', 'invoicing'), |
|
1048 | + 'BZ' => __('Bolzano', 'invoicing'), |
|
1049 | + 'BS' => __('Brescia', 'invoicing'), |
|
1050 | + 'BR' => __('Brindisi', 'invoicing'), |
|
1051 | + 'CA' => __('Cagliari', 'invoicing'), |
|
1052 | + 'CL' => __('Caltanissetta', 'invoicing'), |
|
1053 | + 'CB' => __('Campobasso', 'invoicing'), |
|
1054 | + 'CI' => __('Caltanissetta', 'invoicing'), |
|
1055 | + 'CE' => __('Caserta', 'invoicing'), |
|
1056 | + 'CT' => __('Catania', 'invoicing'), |
|
1057 | + 'CZ' => __('Catanzaro', 'invoicing'), |
|
1058 | + 'CH' => __('Chieti', 'invoicing'), |
|
1059 | + 'CO' => __('Como', 'invoicing'), |
|
1060 | + 'CS' => __('Cosenza', 'invoicing'), |
|
1061 | + 'CR' => __('Cremona', 'invoicing'), |
|
1062 | + 'KR' => __('Crotone', 'invoicing'), |
|
1063 | + 'CN' => __('Cuneo', 'invoicing'), |
|
1064 | + 'EN' => __('Enna', 'invoicing'), |
|
1065 | + 'FM' => __('Fermo', 'invoicing'), |
|
1066 | + 'FE' => __('Ferrara', 'invoicing'), |
|
1067 | + 'FI' => __('Firenze', 'invoicing'), |
|
1068 | + 'FG' => __('Foggia', 'invoicing'), |
|
1069 | + 'FC' => __('Forli-Cesena', 'invoicing'), |
|
1070 | + 'FR' => __('Frosinone', 'invoicing'), |
|
1071 | + 'GE' => __('Genova', 'invoicing'), |
|
1072 | + 'GO' => __('Gorizia', 'invoicing'), |
|
1073 | + 'GR' => __('Grosseto', 'invoicing'), |
|
1074 | + 'IM' => __('Imperia', 'invoicing'), |
|
1075 | + 'IS' => __('Isernia', 'invoicing'), |
|
1076 | + 'SP' => __('La Spezia', 'invoicing'), |
|
1077 | + 'AQ' => __('L'Aquila', 'invoicing'), |
|
1078 | + 'LT' => __('Latina', 'invoicing'), |
|
1079 | + 'LE' => __('Lecce', 'invoicing'), |
|
1080 | + 'LC' => __('Lecco', 'invoicing'), |
|
1081 | + 'LI' => __('Livorno', 'invoicing'), |
|
1082 | + 'LO' => __('Lodi', 'invoicing'), |
|
1083 | + 'LU' => __('Lucca', 'invoicing'), |
|
1084 | + 'MC' => __('Macerata', 'invoicing'), |
|
1085 | + 'MN' => __('Mantova', 'invoicing'), |
|
1086 | + 'MS' => __('Massa-Carrara', 'invoicing'), |
|
1087 | + 'MT' => __('Matera', 'invoicing'), |
|
1088 | + 'ME' => __('Messina', 'invoicing'), |
|
1089 | + 'MI' => __('Milano', 'invoicing'), |
|
1090 | + 'MO' => __('Modena', 'invoicing'), |
|
1091 | + 'MB' => __('Monza e della Brianza', 'invoicing'), |
|
1092 | + 'NA' => __('Napoli', 'invoicing'), |
|
1093 | + 'NO' => __('Novara', 'invoicing'), |
|
1094 | + 'NU' => __('Nuoro', 'invoicing'), |
|
1095 | + 'OT' => __('Olbia-Tempio', 'invoicing'), |
|
1096 | + 'OR' => __('Oristano', 'invoicing'), |
|
1097 | + 'PD' => __('Padova', 'invoicing'), |
|
1098 | + 'PA' => __('Palermo', 'invoicing'), |
|
1099 | + 'PR' => __('Parma', 'invoicing'), |
|
1100 | + 'PV' => __('Pavia', 'invoicing'), |
|
1101 | + 'PG' => __('Perugia', 'invoicing'), |
|
1102 | + 'PU' => __('Pesaro e Urbino', 'invoicing'), |
|
1103 | + 'PE' => __('Pescara', 'invoicing'), |
|
1104 | + 'PC' => __('Piacenza', 'invoicing'), |
|
1105 | + 'PI' => __('Pisa', 'invoicing'), |
|
1106 | + 'PT' => __('Pistoia', 'invoicing'), |
|
1107 | + 'PN' => __('Pordenone', 'invoicing'), |
|
1108 | + 'PZ' => __('Potenza', 'invoicing'), |
|
1109 | + 'PO' => __('Prato', 'invoicing'), |
|
1110 | + 'RG' => __('Ragusa', 'invoicing'), |
|
1111 | + 'RA' => __('Ravenna', 'invoicing'), |
|
1112 | + 'RC' => __('Reggio Calabria', 'invoicing'), |
|
1113 | + 'RE' => __('Reggio Emilia', 'invoicing'), |
|
1114 | + 'RI' => __('Rieti', 'invoicing'), |
|
1115 | + 'RN' => __('Rimini', 'invoicing'), |
|
1116 | + 'RM' => __('Roma', 'invoicing'), |
|
1117 | + 'RO' => __('Rovigo', 'invoicing'), |
|
1118 | + 'SA' => __('Salerno', 'invoicing'), |
|
1119 | + 'VS' => __('Medio Campidano', 'invoicing'), |
|
1120 | + 'SS' => __('Sassari', 'invoicing'), |
|
1121 | + 'SV' => __('Savona', 'invoicing'), |
|
1122 | + 'SI' => __('Siena', 'invoicing'), |
|
1123 | + 'SR' => __('Siracusa', 'invoicing'), |
|
1124 | + 'SO' => __('Sondrio', 'invoicing'), |
|
1125 | + 'TA' => __('Taranto', 'invoicing'), |
|
1126 | + 'TE' => __('Teramo', 'invoicing'), |
|
1127 | + 'TR' => __('Terni', 'invoicing'), |
|
1128 | + 'TO' => __('Torino', 'invoicing'), |
|
1129 | + 'OG' => __('Ogliastra', 'invoicing'), |
|
1130 | + 'TP' => __('Trapani', 'invoicing'), |
|
1131 | + 'TN' => __('Trento', 'invoicing'), |
|
1132 | + 'TV' => __('Treviso', 'invoicing'), |
|
1133 | + 'TS' => __('Trieste', 'invoicing'), |
|
1134 | + 'UD' => __('Udine', 'invoicing'), |
|
1135 | + 'VA' => __('Varesa', 'invoicing'), |
|
1136 | + 'VE' => __('Venezia', 'invoicing'), |
|
1137 | + 'VB' => __('Verbano-Cusio-Ossola', 'invoicing'), |
|
1138 | + 'VC' => __('Vercelli', 'invoicing'), |
|
1139 | + 'VR' => __('Verona', 'invoicing'), |
|
1140 | + 'VV' => __('Vibo Valentia', 'invoicing'), |
|
1141 | + 'VI' => __('Vicenza', 'invoicing'), |
|
1142 | + 'VT' => __('Viterbo', 'invoicing') |
|
1143 | 1143 | ); |
1144 | 1144 | |
1145 | - return apply_filters( 'wpinv_italy_states', $states ); |
|
1145 | + return apply_filters('wpinv_italy_states', $states); |
|
1146 | 1146 | } |
1147 | 1147 | |
1148 | 1148 | function wpinv_get_malaysia_states_list() { |
1149 | 1149 | $states = array( |
1150 | - 'JHR' => __( 'Johor', 'invoicing' ), |
|
1151 | - 'KDH' => __( 'Kedah', 'invoicing' ), |
|
1152 | - 'KTN' => __( 'Kelantan', 'invoicing' ), |
|
1153 | - 'MLK' => __( 'Melaka', 'invoicing' ), |
|
1154 | - 'NSN' => __( 'Negeri Sembilan', 'invoicing' ), |
|
1155 | - 'PHG' => __( 'Pahang', 'invoicing' ), |
|
1156 | - 'PRK' => __( 'Perak', 'invoicing' ), |
|
1157 | - 'PLS' => __( 'Perlis', 'invoicing' ), |
|
1158 | - 'PNG' => __( 'Pulau Pinang', 'invoicing' ), |
|
1159 | - 'SBH' => __( 'Sabah', 'invoicing' ), |
|
1160 | - 'SWK' => __( 'Sarawak', 'invoicing' ), |
|
1161 | - 'SGR' => __( 'Selangor', 'invoicing' ), |
|
1162 | - 'TRG' => __( 'Terengganu', 'invoicing' ), |
|
1163 | - 'KUL' => __( 'W.P. Kuala Lumpur', 'invoicing' ), |
|
1164 | - 'LBN' => __( 'W.P. Labuan', 'invoicing' ), |
|
1165 | - 'PJY' => __( 'W.P. Putrajaya', 'invoicing' ) |
|
1150 | + 'JHR' => __('Johor', 'invoicing'), |
|
1151 | + 'KDH' => __('Kedah', 'invoicing'), |
|
1152 | + 'KTN' => __('Kelantan', 'invoicing'), |
|
1153 | + 'MLK' => __('Melaka', 'invoicing'), |
|
1154 | + 'NSN' => __('Negeri Sembilan', 'invoicing'), |
|
1155 | + 'PHG' => __('Pahang', 'invoicing'), |
|
1156 | + 'PRK' => __('Perak', 'invoicing'), |
|
1157 | + 'PLS' => __('Perlis', 'invoicing'), |
|
1158 | + 'PNG' => __('Pulau Pinang', 'invoicing'), |
|
1159 | + 'SBH' => __('Sabah', 'invoicing'), |
|
1160 | + 'SWK' => __('Sarawak', 'invoicing'), |
|
1161 | + 'SGR' => __('Selangor', 'invoicing'), |
|
1162 | + 'TRG' => __('Terengganu', 'invoicing'), |
|
1163 | + 'KUL' => __('W.P. Kuala Lumpur', 'invoicing'), |
|
1164 | + 'LBN' => __('W.P. Labuan', 'invoicing'), |
|
1165 | + 'PJY' => __('W.P. Putrajaya', 'invoicing') |
|
1166 | 1166 | ); |
1167 | 1167 | |
1168 | - return apply_filters( 'wpinv_malaysia_states', $states ); |
|
1168 | + return apply_filters('wpinv_malaysia_states', $states); |
|
1169 | 1169 | } |
1170 | 1170 | |
1171 | 1171 | function wpinv_get_mexico_states_list() { |
1172 | 1172 | $states = array( |
1173 | - 'DIF' => __( 'Distrito Federal', 'invoicing' ), |
|
1174 | - 'JAL' => __( 'Jalisco', 'invoicing' ), |
|
1175 | - 'NLE' => __( 'Nuevo León', 'invoicing' ), |
|
1176 | - 'AGU' => __( 'Aguascalientes', 'invoicing' ), |
|
1177 | - 'BCN' => __( 'Baja California Norte', 'invoicing' ), |
|
1178 | - 'BCS' => __( 'Baja California Sur', 'invoicing' ), |
|
1179 | - 'CAM' => __( 'Campeche', 'invoicing' ), |
|
1180 | - 'CHP' => __( 'Chiapas', 'invoicing' ), |
|
1181 | - 'CHH' => __( 'Chihuahua', 'invoicing' ), |
|
1182 | - 'COA' => __( 'Coahuila', 'invoicing' ), |
|
1183 | - 'COL' => __( 'Colima', 'invoicing' ), |
|
1184 | - 'DUR' => __( 'Durango', 'invoicing' ), |
|
1185 | - 'GUA' => __( 'Guanajuato', 'invoicing' ), |
|
1186 | - 'GRO' => __( 'Guerrero', 'invoicing' ), |
|
1187 | - 'HID' => __( 'Hidalgo', 'invoicing' ), |
|
1188 | - 'MEX' => __( 'Edo. de México', 'invoicing' ), |
|
1189 | - 'MIC' => __( 'Michoacán', 'invoicing' ), |
|
1190 | - 'MOR' => __( 'Morelos', 'invoicing' ), |
|
1191 | - 'NAY' => __( 'Nayarit', 'invoicing' ), |
|
1192 | - 'OAX' => __( 'Oaxaca', 'invoicing' ), |
|
1193 | - 'PUE' => __( 'Puebla', 'invoicing' ), |
|
1194 | - 'QUE' => __( 'Querétaro', 'invoicing' ), |
|
1195 | - 'ROO' => __( 'Quintana Roo', 'invoicing' ), |
|
1196 | - 'SLP' => __( 'San Luis Potosí', 'invoicing' ), |
|
1197 | - 'SIN' => __( 'Sinaloa', 'invoicing' ), |
|
1198 | - 'SON' => __( 'Sonora', 'invoicing' ), |
|
1199 | - 'TAB' => __( 'Tabasco', 'invoicing' ), |
|
1200 | - 'TAM' => __( 'Tamaulipas', 'invoicing' ), |
|
1201 | - 'TLA' => __( 'Tlaxcala', 'invoicing' ), |
|
1202 | - 'VER' => __( 'Veracruz', 'invoicing' ), |
|
1203 | - 'YUC' => __( 'Yucatán', 'invoicing' ), |
|
1204 | - 'ZAC' => __( 'Zacatecas', 'invoicing' ) |
|
1173 | + 'DIF' => __('Distrito Federal', 'invoicing'), |
|
1174 | + 'JAL' => __('Jalisco', 'invoicing'), |
|
1175 | + 'NLE' => __('Nuevo León', 'invoicing'), |
|
1176 | + 'AGU' => __('Aguascalientes', 'invoicing'), |
|
1177 | + 'BCN' => __('Baja California Norte', 'invoicing'), |
|
1178 | + 'BCS' => __('Baja California Sur', 'invoicing'), |
|
1179 | + 'CAM' => __('Campeche', 'invoicing'), |
|
1180 | + 'CHP' => __('Chiapas', 'invoicing'), |
|
1181 | + 'CHH' => __('Chihuahua', 'invoicing'), |
|
1182 | + 'COA' => __('Coahuila', 'invoicing'), |
|
1183 | + 'COL' => __('Colima', 'invoicing'), |
|
1184 | + 'DUR' => __('Durango', 'invoicing'), |
|
1185 | + 'GUA' => __('Guanajuato', 'invoicing'), |
|
1186 | + 'GRO' => __('Guerrero', 'invoicing'), |
|
1187 | + 'HID' => __('Hidalgo', 'invoicing'), |
|
1188 | + 'MEX' => __('Edo. de México', 'invoicing'), |
|
1189 | + 'MIC' => __('Michoacán', 'invoicing'), |
|
1190 | + 'MOR' => __('Morelos', 'invoicing'), |
|
1191 | + 'NAY' => __('Nayarit', 'invoicing'), |
|
1192 | + 'OAX' => __('Oaxaca', 'invoicing'), |
|
1193 | + 'PUE' => __('Puebla', 'invoicing'), |
|
1194 | + 'QUE' => __('Querétaro', 'invoicing'), |
|
1195 | + 'ROO' => __('Quintana Roo', 'invoicing'), |
|
1196 | + 'SLP' => __('San Luis Potosí', 'invoicing'), |
|
1197 | + 'SIN' => __('Sinaloa', 'invoicing'), |
|
1198 | + 'SON' => __('Sonora', 'invoicing'), |
|
1199 | + 'TAB' => __('Tabasco', 'invoicing'), |
|
1200 | + 'TAM' => __('Tamaulipas', 'invoicing'), |
|
1201 | + 'TLA' => __('Tlaxcala', 'invoicing'), |
|
1202 | + 'VER' => __('Veracruz', 'invoicing'), |
|
1203 | + 'YUC' => __('Yucatán', 'invoicing'), |
|
1204 | + 'ZAC' => __('Zacatecas', 'invoicing') |
|
1205 | 1205 | ); |
1206 | 1206 | |
1207 | - return apply_filters( 'wpinv_mexico_states', $states ); |
|
1207 | + return apply_filters('wpinv_mexico_states', $states); |
|
1208 | 1208 | } |
1209 | 1209 | |
1210 | 1210 | function wpinv_get_nepal_states_list() { |
1211 | 1211 | $states = array( |
1212 | - 'ILL' => __( 'Illam', 'invoicing' ), |
|
1213 | - 'JHA' => __( 'Jhapa', 'invoicing' ), |
|
1214 | - 'PAN' => __( 'Panchthar', 'invoicing' ), |
|
1215 | - 'TAP' => __( 'Taplejung', 'invoicing' ), |
|
1216 | - 'BHO' => __( 'Bhojpur', 'invoicing' ), |
|
1217 | - 'DKA' => __( 'Dhankuta', 'invoicing' ), |
|
1218 | - 'MOR' => __( 'Morang', 'invoicing' ), |
|
1219 | - 'SUN' => __( 'Sunsari', 'invoicing' ), |
|
1220 | - 'SAN' => __( 'Sankhuwa', 'invoicing' ), |
|
1221 | - 'TER' => __( 'Terhathum', 'invoicing' ), |
|
1222 | - 'KHO' => __( 'Khotang', 'invoicing' ), |
|
1223 | - 'OKH' => __( 'Okhaldhunga', 'invoicing' ), |
|
1224 | - 'SAP' => __( 'Saptari', 'invoicing' ), |
|
1225 | - 'SIR' => __( 'Siraha', 'invoicing' ), |
|
1226 | - 'SOL' => __( 'Solukhumbu', 'invoicing' ), |
|
1227 | - 'UDA' => __( 'Udayapur', 'invoicing' ), |
|
1228 | - 'DHA' => __( 'Dhanusa', 'invoicing' ), |
|
1229 | - 'DLK' => __( 'Dolakha', 'invoicing' ), |
|
1230 | - 'MOH' => __( 'Mohottari', 'invoicing' ), |
|
1231 | - 'RAM' => __( 'Ramechha', 'invoicing' ), |
|
1232 | - 'SAR' => __( 'Sarlahi', 'invoicing' ), |
|
1233 | - 'SIN' => __( 'Sindhuli', 'invoicing' ), |
|
1234 | - 'BHA' => __( 'Bhaktapur', 'invoicing' ), |
|
1235 | - 'DHD' => __( 'Dhading', 'invoicing' ), |
|
1236 | - 'KTM' => __( 'Kathmandu', 'invoicing' ), |
|
1237 | - 'KAV' => __( 'Kavrepalanchowk', 'invoicing' ), |
|
1238 | - 'LAL' => __( 'Lalitpur', 'invoicing' ), |
|
1239 | - 'NUW' => __( 'Nuwakot', 'invoicing' ), |
|
1240 | - 'RAS' => __( 'Rasuwa', 'invoicing' ), |
|
1241 | - 'SPC' => __( 'Sindhupalchowk', 'invoicing' ), |
|
1242 | - 'BAR' => __( 'Bara', 'invoicing' ), |
|
1243 | - 'CHI' => __( 'Chitwan', 'invoicing' ), |
|
1244 | - 'MAK' => __( 'Makwanpur', 'invoicing' ), |
|
1245 | - 'PAR' => __( 'Parsa', 'invoicing' ), |
|
1246 | - 'RAU' => __( 'Rautahat', 'invoicing' ), |
|
1247 | - 'GOR' => __( 'Gorkha', 'invoicing' ), |
|
1248 | - 'KAS' => __( 'Kaski', 'invoicing' ), |
|
1249 | - 'LAM' => __( 'Lamjung', 'invoicing' ), |
|
1250 | - 'MAN' => __( 'Manang', 'invoicing' ), |
|
1251 | - 'SYN' => __( 'Syangja', 'invoicing' ), |
|
1252 | - 'TAN' => __( 'Tanahun', 'invoicing' ), |
|
1253 | - 'BAG' => __( 'Baglung', 'invoicing' ), |
|
1254 | - 'PBT' => __( 'Parbat', 'invoicing' ), |
|
1255 | - 'MUS' => __( 'Mustang', 'invoicing' ), |
|
1256 | - 'MYG' => __( 'Myagdi', 'invoicing' ), |
|
1257 | - 'AGR' => __( 'Agrghakanchi', 'invoicing' ), |
|
1258 | - 'GUL' => __( 'Gulmi', 'invoicing' ), |
|
1259 | - 'KAP' => __( 'Kapilbastu', 'invoicing' ), |
|
1260 | - 'NAW' => __( 'Nawalparasi', 'invoicing' ), |
|
1261 | - 'PAL' => __( 'Palpa', 'invoicing' ), |
|
1262 | - 'RUP' => __( 'Rupandehi', 'invoicing' ), |
|
1263 | - 'DAN' => __( 'Dang', 'invoicing' ), |
|
1264 | - 'PYU' => __( 'Pyuthan', 'invoicing' ), |
|
1265 | - 'ROL' => __( 'Rolpa', 'invoicing' ), |
|
1266 | - 'RUK' => __( 'Rukum', 'invoicing' ), |
|
1267 | - 'SAL' => __( 'Salyan', 'invoicing' ), |
|
1268 | - 'BAN' => __( 'Banke', 'invoicing' ), |
|
1269 | - 'BDA' => __( 'Bardiya', 'invoicing' ), |
|
1270 | - 'DAI' => __( 'Dailekh', 'invoicing' ), |
|
1271 | - 'JAJ' => __( 'Jajarkot', 'invoicing' ), |
|
1272 | - 'SUR' => __( 'Surkhet', 'invoicing' ), |
|
1273 | - 'DOL' => __( 'Dolpa', 'invoicing' ), |
|
1274 | - 'HUM' => __( 'Humla', 'invoicing' ), |
|
1275 | - 'JUM' => __( 'Jumla', 'invoicing' ), |
|
1276 | - 'KAL' => __( 'Kalikot', 'invoicing' ), |
|
1277 | - 'MUG' => __( 'Mugu', 'invoicing' ), |
|
1278 | - 'ACH' => __( 'Achham', 'invoicing' ), |
|
1279 | - 'BJH' => __( 'Bajhang', 'invoicing' ), |
|
1280 | - 'BJU' => __( 'Bajura', 'invoicing' ), |
|
1281 | - 'DOT' => __( 'Doti', 'invoicing' ), |
|
1282 | - 'KAI' => __( 'Kailali', 'invoicing' ), |
|
1283 | - 'BAI' => __( 'Baitadi', 'invoicing' ), |
|
1284 | - 'DAD' => __( 'Dadeldhura', 'invoicing' ), |
|
1285 | - 'DAR' => __( 'Darchula', 'invoicing' ), |
|
1286 | - 'KAN' => __( 'Kanchanpur', 'invoicing' ) |
|
1212 | + 'ILL' => __('Illam', 'invoicing'), |
|
1213 | + 'JHA' => __('Jhapa', 'invoicing'), |
|
1214 | + 'PAN' => __('Panchthar', 'invoicing'), |
|
1215 | + 'TAP' => __('Taplejung', 'invoicing'), |
|
1216 | + 'BHO' => __('Bhojpur', 'invoicing'), |
|
1217 | + 'DKA' => __('Dhankuta', 'invoicing'), |
|
1218 | + 'MOR' => __('Morang', 'invoicing'), |
|
1219 | + 'SUN' => __('Sunsari', 'invoicing'), |
|
1220 | + 'SAN' => __('Sankhuwa', 'invoicing'), |
|
1221 | + 'TER' => __('Terhathum', 'invoicing'), |
|
1222 | + 'KHO' => __('Khotang', 'invoicing'), |
|
1223 | + 'OKH' => __('Okhaldhunga', 'invoicing'), |
|
1224 | + 'SAP' => __('Saptari', 'invoicing'), |
|
1225 | + 'SIR' => __('Siraha', 'invoicing'), |
|
1226 | + 'SOL' => __('Solukhumbu', 'invoicing'), |
|
1227 | + 'UDA' => __('Udayapur', 'invoicing'), |
|
1228 | + 'DHA' => __('Dhanusa', 'invoicing'), |
|
1229 | + 'DLK' => __('Dolakha', 'invoicing'), |
|
1230 | + 'MOH' => __('Mohottari', 'invoicing'), |
|
1231 | + 'RAM' => __('Ramechha', 'invoicing'), |
|
1232 | + 'SAR' => __('Sarlahi', 'invoicing'), |
|
1233 | + 'SIN' => __('Sindhuli', 'invoicing'), |
|
1234 | + 'BHA' => __('Bhaktapur', 'invoicing'), |
|
1235 | + 'DHD' => __('Dhading', 'invoicing'), |
|
1236 | + 'KTM' => __('Kathmandu', 'invoicing'), |
|
1237 | + 'KAV' => __('Kavrepalanchowk', 'invoicing'), |
|
1238 | + 'LAL' => __('Lalitpur', 'invoicing'), |
|
1239 | + 'NUW' => __('Nuwakot', 'invoicing'), |
|
1240 | + 'RAS' => __('Rasuwa', 'invoicing'), |
|
1241 | + 'SPC' => __('Sindhupalchowk', 'invoicing'), |
|
1242 | + 'BAR' => __('Bara', 'invoicing'), |
|
1243 | + 'CHI' => __('Chitwan', 'invoicing'), |
|
1244 | + 'MAK' => __('Makwanpur', 'invoicing'), |
|
1245 | + 'PAR' => __('Parsa', 'invoicing'), |
|
1246 | + 'RAU' => __('Rautahat', 'invoicing'), |
|
1247 | + 'GOR' => __('Gorkha', 'invoicing'), |
|
1248 | + 'KAS' => __('Kaski', 'invoicing'), |
|
1249 | + 'LAM' => __('Lamjung', 'invoicing'), |
|
1250 | + 'MAN' => __('Manang', 'invoicing'), |
|
1251 | + 'SYN' => __('Syangja', 'invoicing'), |
|
1252 | + 'TAN' => __('Tanahun', 'invoicing'), |
|
1253 | + 'BAG' => __('Baglung', 'invoicing'), |
|
1254 | + 'PBT' => __('Parbat', 'invoicing'), |
|
1255 | + 'MUS' => __('Mustang', 'invoicing'), |
|
1256 | + 'MYG' => __('Myagdi', 'invoicing'), |
|
1257 | + 'AGR' => __('Agrghakanchi', 'invoicing'), |
|
1258 | + 'GUL' => __('Gulmi', 'invoicing'), |
|
1259 | + 'KAP' => __('Kapilbastu', 'invoicing'), |
|
1260 | + 'NAW' => __('Nawalparasi', 'invoicing'), |
|
1261 | + 'PAL' => __('Palpa', 'invoicing'), |
|
1262 | + 'RUP' => __('Rupandehi', 'invoicing'), |
|
1263 | + 'DAN' => __('Dang', 'invoicing'), |
|
1264 | + 'PYU' => __('Pyuthan', 'invoicing'), |
|
1265 | + 'ROL' => __('Rolpa', 'invoicing'), |
|
1266 | + 'RUK' => __('Rukum', 'invoicing'), |
|
1267 | + 'SAL' => __('Salyan', 'invoicing'), |
|
1268 | + 'BAN' => __('Banke', 'invoicing'), |
|
1269 | + 'BDA' => __('Bardiya', 'invoicing'), |
|
1270 | + 'DAI' => __('Dailekh', 'invoicing'), |
|
1271 | + 'JAJ' => __('Jajarkot', 'invoicing'), |
|
1272 | + 'SUR' => __('Surkhet', 'invoicing'), |
|
1273 | + 'DOL' => __('Dolpa', 'invoicing'), |
|
1274 | + 'HUM' => __('Humla', 'invoicing'), |
|
1275 | + 'JUM' => __('Jumla', 'invoicing'), |
|
1276 | + 'KAL' => __('Kalikot', 'invoicing'), |
|
1277 | + 'MUG' => __('Mugu', 'invoicing'), |
|
1278 | + 'ACH' => __('Achham', 'invoicing'), |
|
1279 | + 'BJH' => __('Bajhang', 'invoicing'), |
|
1280 | + 'BJU' => __('Bajura', 'invoicing'), |
|
1281 | + 'DOT' => __('Doti', 'invoicing'), |
|
1282 | + 'KAI' => __('Kailali', 'invoicing'), |
|
1283 | + 'BAI' => __('Baitadi', 'invoicing'), |
|
1284 | + 'DAD' => __('Dadeldhura', 'invoicing'), |
|
1285 | + 'DAR' => __('Darchula', 'invoicing'), |
|
1286 | + 'KAN' => __('Kanchanpur', 'invoicing') |
|
1287 | 1287 | ); |
1288 | 1288 | |
1289 | - return apply_filters( 'wpinv_nepal_states', $states ); |
|
1289 | + return apply_filters('wpinv_nepal_states', $states); |
|
1290 | 1290 | } |
1291 | 1291 | |
1292 | 1292 | function wpinv_get_south_africa_states_list() { |
1293 | 1293 | $states = array( |
1294 | - 'EC' => __( 'Eastern Cape', 'invoicing' ), |
|
1295 | - 'FS' => __( 'Free State', 'invoicing' ), |
|
1296 | - 'GP' => __( 'Gauteng', 'invoicing' ), |
|
1297 | - 'KZN' => __( 'KwaZulu-Natal', 'invoicing' ), |
|
1298 | - 'LP' => __( 'Limpopo', 'invoicing' ), |
|
1299 | - 'MP' => __( 'Mpumalanga', 'invoicing' ), |
|
1300 | - 'NC' => __( 'Northern Cape', 'invoicing' ), |
|
1301 | - 'NW' => __( 'North West', 'invoicing' ), |
|
1302 | - 'WC' => __( 'Western Cape', 'invoicing' ) |
|
1294 | + 'EC' => __('Eastern Cape', 'invoicing'), |
|
1295 | + 'FS' => __('Free State', 'invoicing'), |
|
1296 | + 'GP' => __('Gauteng', 'invoicing'), |
|
1297 | + 'KZN' => __('KwaZulu-Natal', 'invoicing'), |
|
1298 | + 'LP' => __('Limpopo', 'invoicing'), |
|
1299 | + 'MP' => __('Mpumalanga', 'invoicing'), |
|
1300 | + 'NC' => __('Northern Cape', 'invoicing'), |
|
1301 | + 'NW' => __('North West', 'invoicing'), |
|
1302 | + 'WC' => __('Western Cape', 'invoicing') |
|
1303 | 1303 | ); |
1304 | 1304 | |
1305 | - return apply_filters( 'wpinv_south_africa_states', $states ); |
|
1305 | + return apply_filters('wpinv_south_africa_states', $states); |
|
1306 | 1306 | } |
1307 | 1307 | |
1308 | 1308 | function wpinv_get_thailand_states_list() { |
1309 | 1309 | $states = array( |
1310 | - 'TH-37' => __( 'Amnat Charoen (อำนาจเจริญ)', 'invoicing' ), |
|
1311 | - 'TH-15' => __( 'Ang Thong (อ่างทอง)', 'invoicing' ), |
|
1312 | - 'TH-14' => __( 'Ayutthaya (พระนครศรีอยุธยา)', 'invoicing' ), |
|
1313 | - 'TH-10' => __( 'Bangkok (กรุงเทพมหานคร)', 'invoicing' ), |
|
1314 | - 'TH-38' => __( 'Bueng Kan (บึงกาฬ)', 'invoicing' ), |
|
1315 | - 'TH-31' => __( 'Buri Ram (บุรีรัมย์)', 'invoicing' ), |
|
1316 | - 'TH-24' => __( 'Chachoengsao (ฉะเชิงเทรา)', 'invoicing' ), |
|
1317 | - 'TH-18' => __( 'Chai Nat (ชัยนาท)', 'invoicing' ), |
|
1318 | - 'TH-36' => __( 'Chaiyaphum (ชัยภูมิ)', 'invoicing' ), |
|
1319 | - 'TH-22' => __( 'Chanthaburi (จันทบุรี)', 'invoicing' ), |
|
1320 | - 'TH-50' => __( 'Chiang Mai (เชียงใหม่)', 'invoicing' ), |
|
1321 | - 'TH-57' => __( 'Chiang Rai (เชียงราย)', 'invoicing' ), |
|
1322 | - 'TH-20' => __( 'Chonburi (ชลบุรี)', 'invoicing' ), |
|
1323 | - 'TH-86' => __( 'Chumphon (ชุมพร)', 'invoicing' ), |
|
1324 | - 'TH-46' => __( 'Kalasin (กาฬสินธุ์)', 'invoicing' ), |
|
1325 | - 'TH-62' => __( 'Kamphaeng Phet (กำแพงเพชร)', 'invoicing' ), |
|
1326 | - 'TH-71' => __( 'Kanchanaburi (กาญจนบุรี)', 'invoicing' ), |
|
1327 | - 'TH-40' => __( 'Khon Kaen (ขอนแก่น)', 'invoicing' ), |
|
1328 | - 'TH-81' => __( 'Krabi (กระบี่)', 'invoicing' ), |
|
1329 | - 'TH-52' => __( 'Lampang (ลำปาง)', 'invoicing' ), |
|
1330 | - 'TH-51' => __( 'Lamphun (ลำพูน)', 'invoicing' ), |
|
1331 | - 'TH-42' => __( 'Loei (เลย)', 'invoicing' ), |
|
1332 | - 'TH-16' => __( 'Lopburi (ลพบุรี)', 'invoicing' ), |
|
1333 | - 'TH-58' => __( 'Mae Hong Son (แม่ฮ่องสอน)', 'invoicing' ), |
|
1334 | - 'TH-44' => __( 'Maha Sarakham (มหาสารคาม)', 'invoicing' ), |
|
1335 | - 'TH-49' => __( 'Mukdahan (มุกดาหาร)', 'invoicing' ), |
|
1336 | - 'TH-26' => __( 'Nakhon Nayok (นครนายก)', 'invoicing' ), |
|
1337 | - 'TH-73' => __( 'Nakhon Pathom (นครปฐม)', 'invoicing' ), |
|
1338 | - 'TH-48' => __( 'Nakhon Phanom (นครพนม)', 'invoicing' ), |
|
1339 | - 'TH-30' => __( 'Nakhon Ratchasima (นครราชสีมา)', 'invoicing' ), |
|
1340 | - 'TH-60' => __( 'Nakhon Sawan (นครสวรรค์)', 'invoicing' ), |
|
1341 | - 'TH-80' => __( 'Nakhon Si Thammarat (นครศรีธรรมราช)', 'invoicing' ), |
|
1342 | - 'TH-55' => __( 'Nan (น่าน)', 'invoicing' ), |
|
1343 | - 'TH-96' => __( 'Narathiwat (นราธิวาส)', 'invoicing' ), |
|
1344 | - 'TH-39' => __( 'Nong Bua Lam Phu (หนองบัวลำภู)', 'invoicing' ), |
|
1345 | - 'TH-43' => __( 'Nong Khai (หนองคาย)', 'invoicing' ), |
|
1346 | - 'TH-12' => __( 'Nonthaburi (นนทบุรี)', 'invoicing' ), |
|
1347 | - 'TH-13' => __( 'Pathum Thani (ปทุมธานี)', 'invoicing' ), |
|
1348 | - 'TH-94' => __( 'Pattani (ปัตตานี)', 'invoicing' ), |
|
1349 | - 'TH-82' => __( 'Phang Nga (พังงา)', 'invoicing' ), |
|
1350 | - 'TH-93' => __( 'Phatthalung (พัทลุง)', 'invoicing' ), |
|
1351 | - 'TH-56' => __( 'Phayao (พะเยา)', 'invoicing' ), |
|
1352 | - 'TH-67' => __( 'Phetchabun (เพชรบูรณ์)', 'invoicing' ), |
|
1353 | - 'TH-76' => __( 'Phetchaburi (เพชรบุรี)', 'invoicing' ), |
|
1354 | - 'TH-66' => __( 'Phichit (พิจิตร)', 'invoicing' ), |
|
1355 | - 'TH-65' => __( 'Phitsanulok (พิษณุโลก)', 'invoicing' ), |
|
1356 | - 'TH-54' => __( 'Phrae (แพร่)', 'invoicing' ), |
|
1357 | - 'TH-83' => __( 'Phuket (ภูเก็ต)', 'invoicing' ), |
|
1358 | - 'TH-25' => __( 'Prachin Buri (ปราจีนบุรี)', 'invoicing' ), |
|
1359 | - 'TH-77' => __( 'Prachuap Khiri Khan (ประจวบคีรีขันธ์)', 'invoicing' ), |
|
1360 | - 'TH-85' => __( 'Ranong (ระนอง)', 'invoicing' ), |
|
1361 | - 'TH-70' => __( 'Ratchaburi (ราชบุรี)', 'invoicing' ), |
|
1362 | - 'TH-21' => __( 'Rayong (ระยอง)', 'invoicing' ), |
|
1363 | - 'TH-45' => __( 'Roi Et (ร้อยเอ็ด)', 'invoicing' ), |
|
1364 | - 'TH-27' => __( 'Sa Kaeo (สระแก้ว)', 'invoicing' ), |
|
1365 | - 'TH-47' => __( 'Sakon Nakhon (สกลนคร)', 'invoicing' ), |
|
1366 | - 'TH-11' => __( 'Samut Prakan (สมุทรปราการ)', 'invoicing' ), |
|
1367 | - 'TH-74' => __( 'Samut Sakhon (สมุทรสาคร)', 'invoicing' ), |
|
1368 | - 'TH-75' => __( 'Samut Songkhram (สมุทรสงคราม)', 'invoicing' ), |
|
1369 | - 'TH-19' => __( 'Saraburi (สระบุรี)', 'invoicing' ), |
|
1370 | - 'TH-91' => __( 'Satun (สตูล)', 'invoicing' ), |
|
1371 | - 'TH-17' => __( 'Sing Buri (สิงห์บุรี)', 'invoicing' ), |
|
1372 | - 'TH-33' => __( 'Sisaket (ศรีสะเกษ)', 'invoicing' ), |
|
1373 | - 'TH-90' => __( 'Songkhla (สงขลา)', 'invoicing' ), |
|
1374 | - 'TH-64' => __( 'Sukhothai (สุโขทัย)', 'invoicing' ), |
|
1375 | - 'TH-72' => __( 'Suphan Buri (สุพรรณบุรี)', 'invoicing' ), |
|
1376 | - 'TH-84' => __( 'Surat Thani (สุราษฎร์ธานี)', 'invoicing' ), |
|
1377 | - 'TH-32' => __( 'Surin (สุรินทร์)', 'invoicing' ), |
|
1378 | - 'TH-63' => __( 'Tak (ตาก)', 'invoicing' ), |
|
1379 | - 'TH-92' => __( 'Trang (ตรัง)', 'invoicing' ), |
|
1380 | - 'TH-23' => __( 'Trat (ตราด)', 'invoicing' ), |
|
1381 | - 'TH-34' => __( 'Ubon Ratchathani (อุบลราชธานี)', 'invoicing' ), |
|
1382 | - 'TH-41' => __( 'Udon Thani (อุดรธานี)', 'invoicing' ), |
|
1383 | - 'TH-61' => __( 'Uthai Thani (อุทัยธานี)', 'invoicing' ), |
|
1384 | - 'TH-53' => __( 'Uttaradit (อุตรดิตถ์)', 'invoicing' ), |
|
1385 | - 'TH-95' => __( 'Yala (ยะลา)', 'invoicing' ), |
|
1386 | - 'TH-35' => __( 'Yasothon (ยโสธร)', 'invoicing' ) |
|
1310 | + 'TH-37' => __('Amnat Charoen (อำนาจเจริญ)', 'invoicing'), |
|
1311 | + 'TH-15' => __('Ang Thong (อ่างทอง)', 'invoicing'), |
|
1312 | + 'TH-14' => __('Ayutthaya (พระนครศรีอยุธยา)', 'invoicing'), |
|
1313 | + 'TH-10' => __('Bangkok (กรุงเทพมหานคร)', 'invoicing'), |
|
1314 | + 'TH-38' => __('Bueng Kan (บึงกาฬ)', 'invoicing'), |
|
1315 | + 'TH-31' => __('Buri Ram (บุรีรัมย์)', 'invoicing'), |
|
1316 | + 'TH-24' => __('Chachoengsao (ฉะเชิงเทรา)', 'invoicing'), |
|
1317 | + 'TH-18' => __('Chai Nat (ชัยนาท)', 'invoicing'), |
|
1318 | + 'TH-36' => __('Chaiyaphum (ชัยภูมิ)', 'invoicing'), |
|
1319 | + 'TH-22' => __('Chanthaburi (จันทบุรี)', 'invoicing'), |
|
1320 | + 'TH-50' => __('Chiang Mai (เชียงใหม่)', 'invoicing'), |
|
1321 | + 'TH-57' => __('Chiang Rai (เชียงราย)', 'invoicing'), |
|
1322 | + 'TH-20' => __('Chonburi (ชลบุรี)', 'invoicing'), |
|
1323 | + 'TH-86' => __('Chumphon (ชุมพร)', 'invoicing'), |
|
1324 | + 'TH-46' => __('Kalasin (กาฬสินธุ์)', 'invoicing'), |
|
1325 | + 'TH-62' => __('Kamphaeng Phet (กำแพงเพชร)', 'invoicing'), |
|
1326 | + 'TH-71' => __('Kanchanaburi (กาญจนบุรี)', 'invoicing'), |
|
1327 | + 'TH-40' => __('Khon Kaen (ขอนแก่น)', 'invoicing'), |
|
1328 | + 'TH-81' => __('Krabi (กระบี่)', 'invoicing'), |
|
1329 | + 'TH-52' => __('Lampang (ลำปาง)', 'invoicing'), |
|
1330 | + 'TH-51' => __('Lamphun (ลำพูน)', 'invoicing'), |
|
1331 | + 'TH-42' => __('Loei (เลย)', 'invoicing'), |
|
1332 | + 'TH-16' => __('Lopburi (ลพบุรี)', 'invoicing'), |
|
1333 | + 'TH-58' => __('Mae Hong Son (แม่ฮ่องสอน)', 'invoicing'), |
|
1334 | + 'TH-44' => __('Maha Sarakham (มหาสารคาม)', 'invoicing'), |
|
1335 | + 'TH-49' => __('Mukdahan (มุกดาหาร)', 'invoicing'), |
|
1336 | + 'TH-26' => __('Nakhon Nayok (นครนายก)', 'invoicing'), |
|
1337 | + 'TH-73' => __('Nakhon Pathom (นครปฐม)', 'invoicing'), |
|
1338 | + 'TH-48' => __('Nakhon Phanom (นครพนม)', 'invoicing'), |
|
1339 | + 'TH-30' => __('Nakhon Ratchasima (นครราชสีมา)', 'invoicing'), |
|
1340 | + 'TH-60' => __('Nakhon Sawan (นครสวรรค์)', 'invoicing'), |
|
1341 | + 'TH-80' => __('Nakhon Si Thammarat (นครศรีธรรมราช)', 'invoicing'), |
|
1342 | + 'TH-55' => __('Nan (น่าน)', 'invoicing'), |
|
1343 | + 'TH-96' => __('Narathiwat (นราธิวาส)', 'invoicing'), |
|
1344 | + 'TH-39' => __('Nong Bua Lam Phu (หนองบัวลำภู)', 'invoicing'), |
|
1345 | + 'TH-43' => __('Nong Khai (หนองคาย)', 'invoicing'), |
|
1346 | + 'TH-12' => __('Nonthaburi (นนทบุรี)', 'invoicing'), |
|
1347 | + 'TH-13' => __('Pathum Thani (ปทุมธานี)', 'invoicing'), |
|
1348 | + 'TH-94' => __('Pattani (ปัตตานี)', 'invoicing'), |
|
1349 | + 'TH-82' => __('Phang Nga (พังงา)', 'invoicing'), |
|
1350 | + 'TH-93' => __('Phatthalung (พัทลุง)', 'invoicing'), |
|
1351 | + 'TH-56' => __('Phayao (พะเยา)', 'invoicing'), |
|
1352 | + 'TH-67' => __('Phetchabun (เพชรบูรณ์)', 'invoicing'), |
|
1353 | + 'TH-76' => __('Phetchaburi (เพชรบุรี)', 'invoicing'), |
|
1354 | + 'TH-66' => __('Phichit (พิจิตร)', 'invoicing'), |
|
1355 | + 'TH-65' => __('Phitsanulok (พิษณุโลก)', 'invoicing'), |
|
1356 | + 'TH-54' => __('Phrae (แพร่)', 'invoicing'), |
|
1357 | + 'TH-83' => __('Phuket (ภูเก็ต)', 'invoicing'), |
|
1358 | + 'TH-25' => __('Prachin Buri (ปราจีนบุรี)', 'invoicing'), |
|
1359 | + 'TH-77' => __('Prachuap Khiri Khan (ประจวบคีรีขันธ์)', 'invoicing'), |
|
1360 | + 'TH-85' => __('Ranong (ระนอง)', 'invoicing'), |
|
1361 | + 'TH-70' => __('Ratchaburi (ราชบุรี)', 'invoicing'), |
|
1362 | + 'TH-21' => __('Rayong (ระยอง)', 'invoicing'), |
|
1363 | + 'TH-45' => __('Roi Et (ร้อยเอ็ด)', 'invoicing'), |
|
1364 | + 'TH-27' => __('Sa Kaeo (สระแก้ว)', 'invoicing'), |
|
1365 | + 'TH-47' => __('Sakon Nakhon (สกลนคร)', 'invoicing'), |
|
1366 | + 'TH-11' => __('Samut Prakan (สมุทรปราการ)', 'invoicing'), |
|
1367 | + 'TH-74' => __('Samut Sakhon (สมุทรสาคร)', 'invoicing'), |
|
1368 | + 'TH-75' => __('Samut Songkhram (สมุทรสงคราม)', 'invoicing'), |
|
1369 | + 'TH-19' => __('Saraburi (สระบุรี)', 'invoicing'), |
|
1370 | + 'TH-91' => __('Satun (สตูล)', 'invoicing'), |
|
1371 | + 'TH-17' => __('Sing Buri (สิงห์บุรี)', 'invoicing'), |
|
1372 | + 'TH-33' => __('Sisaket (ศรีสะเกษ)', 'invoicing'), |
|
1373 | + 'TH-90' => __('Songkhla (สงขลา)', 'invoicing'), |
|
1374 | + 'TH-64' => __('Sukhothai (สุโขทัย)', 'invoicing'), |
|
1375 | + 'TH-72' => __('Suphan Buri (สุพรรณบุรี)', 'invoicing'), |
|
1376 | + 'TH-84' => __('Surat Thani (สุราษฎร์ธานี)', 'invoicing'), |
|
1377 | + 'TH-32' => __('Surin (สุรินทร์)', 'invoicing'), |
|
1378 | + 'TH-63' => __('Tak (ตาก)', 'invoicing'), |
|
1379 | + 'TH-92' => __('Trang (ตรัง)', 'invoicing'), |
|
1380 | + 'TH-23' => __('Trat (ตราด)', 'invoicing'), |
|
1381 | + 'TH-34' => __('Ubon Ratchathani (อุบลราชธานี)', 'invoicing'), |
|
1382 | + 'TH-41' => __('Udon Thani (อุดรธานี)', 'invoicing'), |
|
1383 | + 'TH-61' => __('Uthai Thani (อุทัยธานี)', 'invoicing'), |
|
1384 | + 'TH-53' => __('Uttaradit (อุตรดิตถ์)', 'invoicing'), |
|
1385 | + 'TH-95' => __('Yala (ยะลา)', 'invoicing'), |
|
1386 | + 'TH-35' => __('Yasothon (ยโสธร)', 'invoicing') |
|
1387 | 1387 | ); |
1388 | 1388 | |
1389 | - return apply_filters( 'wpinv_thailand_states', $states ); |
|
1389 | + return apply_filters('wpinv_thailand_states', $states); |
|
1390 | 1390 | } |
1391 | 1391 | |
1392 | 1392 | function wpinv_get_turkey_states_list() { |
1393 | 1393 | $states = array( |
1394 | - 'TR01' => __( 'Adana', 'invoicing' ), |
|
1395 | - 'TR02' => __( 'Adıyaman', 'invoicing' ), |
|
1396 | - 'TR03' => __( 'Afyon', 'invoicing' ), |
|
1397 | - 'TR04' => __( 'Ağrı', 'invoicing' ), |
|
1398 | - 'TR05' => __( 'Amasya', 'invoicing' ), |
|
1399 | - 'TR06' => __( 'Ankara', 'invoicing' ), |
|
1400 | - 'TR07' => __( 'Antalya', 'invoicing' ), |
|
1401 | - 'TR08' => __( 'Artvin', 'invoicing' ), |
|
1402 | - 'TR09' => __( 'Aydın', 'invoicing' ), |
|
1403 | - 'TR10' => __( 'Balıkesir', 'invoicing' ), |
|
1404 | - 'TR11' => __( 'Bilecik', 'invoicing' ), |
|
1405 | - 'TR12' => __( 'Bingöl', 'invoicing' ), |
|
1406 | - 'TR13' => __( 'Bitlis', 'invoicing' ), |
|
1407 | - 'TR14' => __( 'Bolu', 'invoicing' ), |
|
1408 | - 'TR15' => __( 'Burdur', 'invoicing' ), |
|
1409 | - 'TR16' => __( 'Bursa', 'invoicing' ), |
|
1410 | - 'TR17' => __( 'Çanakkale', 'invoicing' ), |
|
1411 | - 'TR18' => __( 'Çankıkesir', 'invoicing' ), |
|
1412 | - 'TR19' => __( 'Çorum', 'invoicing' ), |
|
1413 | - 'TR20' => __( 'Denizli', 'invoicing' ), |
|
1414 | - 'TR21' => __( 'Diyarbakır', 'invoicing' ), |
|
1415 | - 'TR22' => __( 'Edirne', 'invoicing' ), |
|
1416 | - 'TR23' => __( 'Elazığ', 'invoicing' ), |
|
1417 | - 'TR24' => __( 'Erzincan', 'invoicing' ), |
|
1418 | - 'TR25' => __( 'Erzurum', 'invoicing' ), |
|
1419 | - 'TR26' => __( 'Eskişehir', 'invoicing' ), |
|
1420 | - 'TR27' => __( 'Gaziantep', 'invoicing' ), |
|
1421 | - 'TR28' => __( 'Giresun', 'invoicing' ), |
|
1422 | - 'TR29' => __( 'Gümüşhane', 'invoicing' ), |
|
1423 | - 'TR30' => __( 'Hakkari', 'invoicing' ), |
|
1424 | - 'TR31' => __( 'Hatay', 'invoicing' ), |
|
1425 | - 'TR32' => __( 'Isparta', 'invoicing' ), |
|
1426 | - 'TR33' => __( 'İçel', 'invoicing' ), |
|
1427 | - 'TR34' => __( 'İstanbul', 'invoicing' ), |
|
1428 | - 'TR35' => __( 'İzmir', 'invoicing' ), |
|
1429 | - 'TR36' => __( 'Kars', 'invoicing' ), |
|
1430 | - 'TR37' => __( 'Kastamonu', 'invoicing' ), |
|
1431 | - 'TR38' => __( 'Kayseri', 'invoicing' ), |
|
1432 | - 'TR39' => __( 'Kırklareli', 'invoicing' ), |
|
1433 | - 'TR40' => __( 'Kırşehir', 'invoicing' ), |
|
1434 | - 'TR41' => __( 'Kocaeli', 'invoicing' ), |
|
1435 | - 'TR42' => __( 'Konya', 'invoicing' ), |
|
1436 | - 'TR43' => __( 'Kütahya', 'invoicing' ), |
|
1437 | - 'TR44' => __( 'Malatya', 'invoicing' ), |
|
1438 | - 'TR45' => __( 'Manisa', 'invoicing' ), |
|
1439 | - 'TR46' => __( 'Kahramanmaraş', 'invoicing' ), |
|
1440 | - 'TR47' => __( 'Mardin', 'invoicing' ), |
|
1441 | - 'TR48' => __( 'Muğla', 'invoicing' ), |
|
1442 | - 'TR49' => __( 'Muş', 'invoicing' ), |
|
1443 | - 'TR50' => __( 'Nevşehir', 'invoicing' ), |
|
1444 | - 'TR51' => __( 'Niğde', 'invoicing' ), |
|
1445 | - 'TR52' => __( 'Ordu', 'invoicing' ), |
|
1446 | - 'TR53' => __( 'Rize', 'invoicing' ), |
|
1447 | - 'TR54' => __( 'Sakarya', 'invoicing' ), |
|
1448 | - 'TR55' => __( 'Samsun', 'invoicing' ), |
|
1449 | - 'TR56' => __( 'Siirt', 'invoicing' ), |
|
1450 | - 'TR57' => __( 'Sinop', 'invoicing' ), |
|
1451 | - 'TR58' => __( 'Sivas', 'invoicing' ), |
|
1452 | - 'TR59' => __( 'Tekirdağ', 'invoicing' ), |
|
1453 | - 'TR60' => __( 'Tokat', 'invoicing' ), |
|
1454 | - 'TR61' => __( 'Trabzon', 'invoicing' ), |
|
1455 | - 'TR62' => __( 'Tunceli', 'invoicing' ), |
|
1456 | - 'TR63' => __( 'Şanlıurfa', 'invoicing' ), |
|
1457 | - 'TR64' => __( 'Uşak', 'invoicing' ), |
|
1458 | - 'TR65' => __( 'Van', 'invoicing' ), |
|
1459 | - 'TR66' => __( 'Yozgat', 'invoicing' ), |
|
1460 | - 'TR67' => __( 'Zonguldak', 'invoicing' ), |
|
1461 | - 'TR68' => __( 'Aksaray', 'invoicing' ), |
|
1462 | - 'TR69' => __( 'Bayburt', 'invoicing' ), |
|
1463 | - 'TR70' => __( 'Karaman', 'invoicing' ), |
|
1464 | - 'TR71' => __( 'Kırıkkale', 'invoicing' ), |
|
1465 | - 'TR72' => __( 'Batman', 'invoicing' ), |
|
1466 | - 'TR73' => __( 'Şırnak', 'invoicing' ), |
|
1467 | - 'TR74' => __( 'Bartın', 'invoicing' ), |
|
1468 | - 'TR75' => __( 'Ardahan', 'invoicing' ), |
|
1469 | - 'TR76' => __( 'Iğdır', 'invoicing' ), |
|
1470 | - 'TR77' => __( 'Yalova', 'invoicing' ), |
|
1471 | - 'TR78' => __( 'Karabük', 'invoicing' ), |
|
1472 | - 'TR79' => __( 'Kilis', 'invoicing' ), |
|
1473 | - 'TR80' => __( 'Osmaniye', 'invoicing' ), |
|
1474 | - 'TR81' => __( 'Düzce', 'invoicing' ) |
|
1394 | + 'TR01' => __('Adana', 'invoicing'), |
|
1395 | + 'TR02' => __('Adıyaman', 'invoicing'), |
|
1396 | + 'TR03' => __('Afyon', 'invoicing'), |
|
1397 | + 'TR04' => __('Ağrı', 'invoicing'), |
|
1398 | + 'TR05' => __('Amasya', 'invoicing'), |
|
1399 | + 'TR06' => __('Ankara', 'invoicing'), |
|
1400 | + 'TR07' => __('Antalya', 'invoicing'), |
|
1401 | + 'TR08' => __('Artvin', 'invoicing'), |
|
1402 | + 'TR09' => __('Aydın', 'invoicing'), |
|
1403 | + 'TR10' => __('Balıkesir', 'invoicing'), |
|
1404 | + 'TR11' => __('Bilecik', 'invoicing'), |
|
1405 | + 'TR12' => __('Bingöl', 'invoicing'), |
|
1406 | + 'TR13' => __('Bitlis', 'invoicing'), |
|
1407 | + 'TR14' => __('Bolu', 'invoicing'), |
|
1408 | + 'TR15' => __('Burdur', 'invoicing'), |
|
1409 | + 'TR16' => __('Bursa', 'invoicing'), |
|
1410 | + 'TR17' => __('Çanakkale', 'invoicing'), |
|
1411 | + 'TR18' => __('Çankıkesir', 'invoicing'), |
|
1412 | + 'TR19' => __('Çorum', 'invoicing'), |
|
1413 | + 'TR20' => __('Denizli', 'invoicing'), |
|
1414 | + 'TR21' => __('Diyarbakır', 'invoicing'), |
|
1415 | + 'TR22' => __('Edirne', 'invoicing'), |
|
1416 | + 'TR23' => __('Elazığ', 'invoicing'), |
|
1417 | + 'TR24' => __('Erzincan', 'invoicing'), |
|
1418 | + 'TR25' => __('Erzurum', 'invoicing'), |
|
1419 | + 'TR26' => __('Eskişehir', 'invoicing'), |
|
1420 | + 'TR27' => __('Gaziantep', 'invoicing'), |
|
1421 | + 'TR28' => __('Giresun', 'invoicing'), |
|
1422 | + 'TR29' => __('Gümüşhane', 'invoicing'), |
|
1423 | + 'TR30' => __('Hakkari', 'invoicing'), |
|
1424 | + 'TR31' => __('Hatay', 'invoicing'), |
|
1425 | + 'TR32' => __('Isparta', 'invoicing'), |
|
1426 | + 'TR33' => __('İçel', 'invoicing'), |
|
1427 | + 'TR34' => __('İstanbul', 'invoicing'), |
|
1428 | + 'TR35' => __('İzmir', 'invoicing'), |
|
1429 | + 'TR36' => __('Kars', 'invoicing'), |
|
1430 | + 'TR37' => __('Kastamonu', 'invoicing'), |
|
1431 | + 'TR38' => __('Kayseri', 'invoicing'), |
|
1432 | + 'TR39' => __('Kırklareli', 'invoicing'), |
|
1433 | + 'TR40' => __('Kırşehir', 'invoicing'), |
|
1434 | + 'TR41' => __('Kocaeli', 'invoicing'), |
|
1435 | + 'TR42' => __('Konya', 'invoicing'), |
|
1436 | + 'TR43' => __('Kütahya', 'invoicing'), |
|
1437 | + 'TR44' => __('Malatya', 'invoicing'), |
|
1438 | + 'TR45' => __('Manisa', 'invoicing'), |
|
1439 | + 'TR46' => __('Kahramanmaraş', 'invoicing'), |
|
1440 | + 'TR47' => __('Mardin', 'invoicing'), |
|
1441 | + 'TR48' => __('Muğla', 'invoicing'), |
|
1442 | + 'TR49' => __('Muş', 'invoicing'), |
|
1443 | + 'TR50' => __('Nevşehir', 'invoicing'), |
|
1444 | + 'TR51' => __('Niğde', 'invoicing'), |
|
1445 | + 'TR52' => __('Ordu', 'invoicing'), |
|
1446 | + 'TR53' => __('Rize', 'invoicing'), |
|
1447 | + 'TR54' => __('Sakarya', 'invoicing'), |
|
1448 | + 'TR55' => __('Samsun', 'invoicing'), |
|
1449 | + 'TR56' => __('Siirt', 'invoicing'), |
|
1450 | + 'TR57' => __('Sinop', 'invoicing'), |
|
1451 | + 'TR58' => __('Sivas', 'invoicing'), |
|
1452 | + 'TR59' => __('Tekirdağ', 'invoicing'), |
|
1453 | + 'TR60' => __('Tokat', 'invoicing'), |
|
1454 | + 'TR61' => __('Trabzon', 'invoicing'), |
|
1455 | + 'TR62' => __('Tunceli', 'invoicing'), |
|
1456 | + 'TR63' => __('Şanlıurfa', 'invoicing'), |
|
1457 | + 'TR64' => __('Uşak', 'invoicing'), |
|
1458 | + 'TR65' => __('Van', 'invoicing'), |
|
1459 | + 'TR66' => __('Yozgat', 'invoicing'), |
|
1460 | + 'TR67' => __('Zonguldak', 'invoicing'), |
|
1461 | + 'TR68' => __('Aksaray', 'invoicing'), |
|
1462 | + 'TR69' => __('Bayburt', 'invoicing'), |
|
1463 | + 'TR70' => __('Karaman', 'invoicing'), |
|
1464 | + 'TR71' => __('Kırıkkale', 'invoicing'), |
|
1465 | + 'TR72' => __('Batman', 'invoicing'), |
|
1466 | + 'TR73' => __('Şırnak', 'invoicing'), |
|
1467 | + 'TR74' => __('Bartın', 'invoicing'), |
|
1468 | + 'TR75' => __('Ardahan', 'invoicing'), |
|
1469 | + 'TR76' => __('Iğdır', 'invoicing'), |
|
1470 | + 'TR77' => __('Yalova', 'invoicing'), |
|
1471 | + 'TR78' => __('Karabük', 'invoicing'), |
|
1472 | + 'TR79' => __('Kilis', 'invoicing'), |
|
1473 | + 'TR80' => __('Osmaniye', 'invoicing'), |
|
1474 | + 'TR81' => __('Düzce', 'invoicing') |
|
1475 | 1475 | ); |
1476 | 1476 | |
1477 | - return apply_filters( 'wpinv_turkey_states', $states ); |
|
1477 | + return apply_filters('wpinv_turkey_states', $states); |
|
1478 | 1478 | } |
1479 | 1479 | |
1480 | 1480 | function wpinv_get_spain_states_list() { |
1481 | 1481 | $states = array( |
1482 | - 'C' => __( 'A Coruña', 'invoicing' ), |
|
1483 | - 'VI' => __( 'Araba', 'invoicing' ), |
|
1484 | - 'AB' => __( 'Albacete', 'invoicing' ), |
|
1485 | - 'A' => __( 'Alicante', 'invoicing' ), |
|
1486 | - 'AL' => __( 'Almería', 'invoicing' ), |
|
1487 | - 'O' => __( 'Asturias', 'invoicing' ), |
|
1488 | - 'AV' => __( 'Ávila', 'invoicing' ), |
|
1489 | - 'BA' => __( 'Badajoz', 'invoicing' ), |
|
1490 | - 'PM' => __( 'Baleares', 'invoicing' ), |
|
1491 | - 'B' => __( 'Barcelona', 'invoicing' ), |
|
1492 | - 'BU' => __( 'Burgos', 'invoicing' ), |
|
1493 | - 'CC' => __( 'Cáceres', 'invoicing' ), |
|
1494 | - 'CA' => __( 'Cádiz', 'invoicing' ), |
|
1495 | - 'S' => __( 'Cantabria', 'invoicing' ), |
|
1496 | - 'CS' => __( 'Castellón', 'invoicing' ), |
|
1497 | - 'CE' => __( 'Ceuta', 'invoicing' ), |
|
1498 | - 'CR' => __( 'Ciudad Real', 'invoicing' ), |
|
1499 | - 'CO' => __( 'Córdoba', 'invoicing' ), |
|
1500 | - 'CU' => __( 'Cuenca', 'invoicing' ), |
|
1501 | - 'GI' => __( 'Girona', 'invoicing' ), |
|
1502 | - 'GR' => __( 'Granada', 'invoicing' ), |
|
1503 | - 'GU' => __( 'Guadalajara', 'invoicing' ), |
|
1504 | - 'SS' => __( 'Gipuzkoa', 'invoicing' ), |
|
1505 | - 'H' => __( 'Huelva', 'invoicing' ), |
|
1506 | - 'HU' => __( 'Huesca', 'invoicing' ), |
|
1507 | - 'J' => __( 'Jaén', 'invoicing' ), |
|
1508 | - 'LO' => __( 'La Rioja', 'invoicing' ), |
|
1509 | - 'GC' => __( 'Las Palmas', 'invoicing' ), |
|
1510 | - 'LE' => __( 'León', 'invoicing' ), |
|
1511 | - 'L' => __( 'Lleida', 'invoicing' ), |
|
1512 | - 'LU' => __( 'Lugo', 'invoicing' ), |
|
1513 | - 'M' => __( 'Madrid', 'invoicing' ), |
|
1514 | - 'MA' => __( 'Málaga', 'invoicing' ), |
|
1515 | - 'ML' => __( 'Melilla', 'invoicing' ), |
|
1516 | - 'MU' => __( 'Murcia', 'invoicing' ), |
|
1517 | - 'NA' => __( 'Navarra', 'invoicing' ), |
|
1518 | - 'OR' => __( 'Ourense', 'invoicing' ), |
|
1519 | - 'P' => __( 'Palencia', 'invoicing' ), |
|
1520 | - 'PO' => __( 'Pontevedra', 'invoicing' ), |
|
1521 | - 'SA' => __( 'Salamanca', 'invoicing' ), |
|
1522 | - 'TF' => __( 'Santa Cruz de Tenerife', 'invoicing' ), |
|
1523 | - 'SG' => __( 'Segovia', 'invoicing' ), |
|
1524 | - 'SE' => __( 'Sevilla', 'invoicing' ), |
|
1525 | - 'SO' => __( 'Soria', 'invoicing' ), |
|
1526 | - 'T' => __( 'Tarragona', 'invoicing' ), |
|
1527 | - 'TE' => __( 'Teruel', 'invoicing' ), |
|
1528 | - 'TO' => __( 'Toledo', 'invoicing' ), |
|
1529 | - 'V' => __( 'Valencia', 'invoicing' ), |
|
1530 | - 'VA' => __( 'Valladolid', 'invoicing' ), |
|
1531 | - 'BI' => __( 'Bizkaia', 'invoicing' ), |
|
1532 | - 'ZA' => __( 'Zamora', 'invoicing' ), |
|
1533 | - 'Z' => __( 'Zaragoza', 'invoicing' ) |
|
1482 | + 'C' => __('A Coruña', 'invoicing'), |
|
1483 | + 'VI' => __('Araba', 'invoicing'), |
|
1484 | + 'AB' => __('Albacete', 'invoicing'), |
|
1485 | + 'A' => __('Alicante', 'invoicing'), |
|
1486 | + 'AL' => __('Almería', 'invoicing'), |
|
1487 | + 'O' => __('Asturias', 'invoicing'), |
|
1488 | + 'AV' => __('Ávila', 'invoicing'), |
|
1489 | + 'BA' => __('Badajoz', 'invoicing'), |
|
1490 | + 'PM' => __('Baleares', 'invoicing'), |
|
1491 | + 'B' => __('Barcelona', 'invoicing'), |
|
1492 | + 'BU' => __('Burgos', 'invoicing'), |
|
1493 | + 'CC' => __('Cáceres', 'invoicing'), |
|
1494 | + 'CA' => __('Cádiz', 'invoicing'), |
|
1495 | + 'S' => __('Cantabria', 'invoicing'), |
|
1496 | + 'CS' => __('Castellón', 'invoicing'), |
|
1497 | + 'CE' => __('Ceuta', 'invoicing'), |
|
1498 | + 'CR' => __('Ciudad Real', 'invoicing'), |
|
1499 | + 'CO' => __('Córdoba', 'invoicing'), |
|
1500 | + 'CU' => __('Cuenca', 'invoicing'), |
|
1501 | + 'GI' => __('Girona', 'invoicing'), |
|
1502 | + 'GR' => __('Granada', 'invoicing'), |
|
1503 | + 'GU' => __('Guadalajara', 'invoicing'), |
|
1504 | + 'SS' => __('Gipuzkoa', 'invoicing'), |
|
1505 | + 'H' => __('Huelva', 'invoicing'), |
|
1506 | + 'HU' => __('Huesca', 'invoicing'), |
|
1507 | + 'J' => __('Jaén', 'invoicing'), |
|
1508 | + 'LO' => __('La Rioja', 'invoicing'), |
|
1509 | + 'GC' => __('Las Palmas', 'invoicing'), |
|
1510 | + 'LE' => __('León', 'invoicing'), |
|
1511 | + 'L' => __('Lleida', 'invoicing'), |
|
1512 | + 'LU' => __('Lugo', 'invoicing'), |
|
1513 | + 'M' => __('Madrid', 'invoicing'), |
|
1514 | + 'MA' => __('Málaga', 'invoicing'), |
|
1515 | + 'ML' => __('Melilla', 'invoicing'), |
|
1516 | + 'MU' => __('Murcia', 'invoicing'), |
|
1517 | + 'NA' => __('Navarra', 'invoicing'), |
|
1518 | + 'OR' => __('Ourense', 'invoicing'), |
|
1519 | + 'P' => __('Palencia', 'invoicing'), |
|
1520 | + 'PO' => __('Pontevedra', 'invoicing'), |
|
1521 | + 'SA' => __('Salamanca', 'invoicing'), |
|
1522 | + 'TF' => __('Santa Cruz de Tenerife', 'invoicing'), |
|
1523 | + 'SG' => __('Segovia', 'invoicing'), |
|
1524 | + 'SE' => __('Sevilla', 'invoicing'), |
|
1525 | + 'SO' => __('Soria', 'invoicing'), |
|
1526 | + 'T' => __('Tarragona', 'invoicing'), |
|
1527 | + 'TE' => __('Teruel', 'invoicing'), |
|
1528 | + 'TO' => __('Toledo', 'invoicing'), |
|
1529 | + 'V' => __('Valencia', 'invoicing'), |
|
1530 | + 'VA' => __('Valladolid', 'invoicing'), |
|
1531 | + 'BI' => __('Bizkaia', 'invoicing'), |
|
1532 | + 'ZA' => __('Zamora', 'invoicing'), |
|
1533 | + 'Z' => __('Zaragoza', 'invoicing') |
|
1534 | 1534 | ); |
1535 | 1535 | |
1536 | - return apply_filters( 'wpinv_spain_states', $states ); |
|
1536 | + return apply_filters('wpinv_spain_states', $states); |
|
1537 | 1537 | } |
1538 | 1538 | |
1539 | 1539 | function wpinv_get_states_field() { |
1540 | - if( empty( $_POST['country'] ) ) { |
|
1540 | + if (empty($_POST['country'])) { |
|
1541 | 1541 | $_POST['country'] = wpinv_get_default_country(); |
1542 | 1542 | } |
1543 | - $states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) ); |
|
1543 | + $states = wpinv_get_country_states(sanitize_text_field($_POST['country'])); |
|
1544 | 1544 | |
1545 | - if( !empty( $states ) ) { |
|
1546 | - $sanitized_field_name = sanitize_text_field( $_POST['field_name'] ); |
|
1545 | + if (!empty($states)) { |
|
1546 | + $sanitized_field_name = sanitize_text_field($_POST['field_name']); |
|
1547 | 1547 | |
1548 | 1548 | $args = array( |
1549 | 1549 | 'name' => $sanitized_field_name, |
1550 | 1550 | 'id' => $sanitized_field_name, |
1551 | 1551 | 'class' => $sanitized_field_name . ' wpinv-select', |
1552 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
1552 | + 'options' => array_merge(array('' => ''), $states), |
|
1553 | 1553 | 'show_option_all' => false, |
1554 | 1554 | 'show_option_none' => false |
1555 | 1555 | ); |
1556 | 1556 | |
1557 | - $response = wpinv_html_select( $args ); |
|
1557 | + $response = wpinv_html_select($args); |
|
1558 | 1558 | |
1559 | 1559 | } else { |
1560 | 1560 | $response = 'nostates'; |
@@ -1563,8 +1563,8 @@ discard block |
||
1563 | 1563 | return $response; |
1564 | 1564 | } |
1565 | 1565 | |
1566 | -function wpinv_default_billing_country( $country = '', $user_id = 0 ) { |
|
1567 | - $country = !empty( $country ) ? $country : wpinv_get_default_country(); |
|
1566 | +function wpinv_default_billing_country($country = '', $user_id = 0) { |
|
1567 | + $country = !empty($country) ? $country : wpinv_get_default_country(); |
|
1568 | 1568 | |
1569 | - return apply_filters( 'wpinv_default_billing_country', $country, $user_id ); |
|
1569 | + return apply_filters('wpinv_default_billing_country', $country, $user_id); |
|
1570 | 1570 | } |
1571 | 1571 | \ No newline at end of file |
@@ -11,19 +11,19 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // MUST have WordPress. |
14 | -if ( !defined( 'WPINC' ) ) { |
|
15 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
14 | +if (!defined('WPINC')) { |
|
15 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
16 | 16 | } |
17 | 17 | |
18 | -if ( !defined( 'WPINV_VERSION' ) ) { |
|
19 | - define( 'WPINV_VERSION', '0.0.4' ); |
|
18 | +if (!defined('WPINV_VERSION')) { |
|
19 | + define('WPINV_VERSION', '0.0.4'); |
|
20 | 20 | } |
21 | 21 | |
22 | -if ( !defined( 'WPINV_PLUGIN_FILE' ) ) { |
|
23 | - define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
22 | +if (!defined('WPINV_PLUGIN_FILE')) { |
|
23 | + define('WPINV_PLUGIN_FILE', __FILE__); |
|
24 | 24 | } |
25 | 25 | |
26 | -require plugin_dir_path( __FILE__ ) . 'includes/class-wpinv.php'; |
|
26 | +require plugin_dir_path(__FILE__) . 'includes/class-wpinv.php'; |
|
27 | 27 | |
28 | 28 | function wpinv_run() { |
29 | 29 | global $invoicing; |
@@ -40,16 +40,16 @@ discard block |
||
40 | 40 | /** |
41 | 41 | * Show update plugin admin notification. |
42 | 42 | */ |
43 | -if(is_admin()){ |
|
43 | +if (is_admin()) { |
|
44 | 44 | if (!function_exists('ayecode_show_update_plugin_requirement')) {//only load the update file if needed |
45 | 45 | function ayecode_show_update_plugin_requirement() { |
46 | - if ( !defined( 'WP_EASY_UPDATES_ACTIVE' ) ) { |
|
46 | + if (!defined('WP_EASY_UPDATES_ACTIVE')) { |
|
47 | 47 | ?> |
48 | 48 | <div class="notice notice-warning is-dismissible"> |
49 | 49 | <p> |
50 | 50 | <strong> |
51 | 51 | <?php |
52 | - echo sprintf( __( 'The plugin %sWP Easy Updates%s is required to check for and update some installed plugins, please install it now.', 'geodirectory' ), '<a href="https://wpeasyupdates.com/" target="_blank" title="WP Easy Updates">', '</a>' ); |
|
52 | + echo sprintf(__('The plugin %sWP Easy Updates%s is required to check for and update some installed plugins, please install it now.', 'geodirectory'), '<a href="https://wpeasyupdates.com/" target="_blank" title="WP Easy Updates">', '</a>'); |
|
53 | 53 | ?> |
54 | 54 | </strong> |
55 | 55 | </p> |
@@ -58,6 +58,6 @@ discard block |
||
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
61 | - add_action( 'admin_notices', 'ayecode_show_update_plugin_requirement' ); |
|
61 | + add_action('admin_notices', 'ayecode_show_update_plugin_requirement'); |
|
62 | 62 | } |
63 | 63 | } |
@@ -1,72 +1,72 @@ |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if (!defined('ABSPATH')) |
|
4 | 4 | die('-1'); |
5 | 5 | |
6 | 6 | global $wpinv_euvat; |
7 | 7 | |
8 | -$sent_to_admin = !empty( $sent_to_admin ) ? true : false; |
|
9 | -if ( $sent_to_admin ) { |
|
10 | - $invoice_url = get_edit_post_link( $invoice->ID ); |
|
8 | +$sent_to_admin = !empty($sent_to_admin) ? true : false; |
|
9 | +if ($sent_to_admin) { |
|
10 | + $invoice_url = get_edit_post_link($invoice->ID); |
|
11 | 11 | } else { |
12 | - $secret = !empty( $email_type ) && $email_type == 'user_invoice' ? true : false; |
|
13 | - $invoice_url = $invoice->get_view_url( $secret ); |
|
12 | + $secret = !empty($email_type) && $email_type == 'user_invoice' ? true : false; |
|
13 | + $invoice_url = $invoice->get_view_url($secret); |
|
14 | 14 | } |
15 | 15 | $use_taxes = wpinv_use_taxes(); |
16 | 16 | $vat_name = $wpinv_euvat->get_vat_name(); |
17 | 17 | |
18 | -do_action( 'wpinv_email_before_invoice_details', $invoice, $sent_to_admin ); ?> |
|
18 | +do_action('wpinv_email_before_invoice_details', $invoice, $sent_to_admin); ?> |
|
19 | 19 | <div id="wpinv-email-details"> |
20 | - <h3 class="wpinv-details-t"><?php echo apply_filters( 'wpinv_email_details_title', __( 'Invoice Details', 'invoicing' ) ); ?></h3> |
|
20 | + <h3 class="wpinv-details-t"><?php echo apply_filters('wpinv_email_details_title', __('Invoice Details', 'invoicing')); ?></h3> |
|
21 | 21 | <table class="table table-bordered table-sm"> |
22 | - <?php if ( $invoice_number = $invoice->get_number() ) { ?> |
|
22 | + <?php if ($invoice_number = $invoice->get_number()) { ?> |
|
23 | 23 | <tr> |
24 | - <td><?php _e( 'Invoice Number', 'invoicing' ); ?></td> |
|
25 | - <td><a href="<?php echo esc_url( $invoice_url ) ;?>"><?php echo $invoice_number; ?></a></td> |
|
24 | + <td><?php _e('Invoice Number', 'invoicing'); ?></td> |
|
25 | + <td><a href="<?php echo esc_url($invoice_url); ?>"><?php echo $invoice_number; ?></a></td> |
|
26 | 26 | </tr> |
27 | 27 | <?php } ?> |
28 | 28 | <tr> |
29 | - <td><?php _e( 'Invoice Status', 'invoicing' ); ?></td> |
|
30 | - <td><?php echo $invoice->get_status( true ); ?></td> |
|
29 | + <td><?php _e('Invoice Status', 'invoicing'); ?></td> |
|
30 | + <td><?php echo $invoice->get_status(true); ?></td> |
|
31 | 31 | </tr> |
32 | - <?php if ( $invoice->is_renewal() ) { ?> |
|
32 | + <?php if ($invoice->is_renewal()) { ?> |
|
33 | 33 | <tr> |
34 | - <td><?php _e( 'Parent Invoice', 'invoicing' ); ?></td> |
|
35 | - <td><?php echo wpinv_invoice_link( $invoice->parent_invoice ); ?></td> |
|
34 | + <td><?php _e('Parent Invoice', 'invoicing'); ?></td> |
|
35 | + <td><?php echo wpinv_invoice_link($invoice->parent_invoice); ?></td> |
|
36 | 36 | </tr> |
37 | 37 | <?php } ?> |
38 | 38 | <tr> |
39 | - <td><?php _e( 'Payment Method', 'invoicing' ); ?></td> |
|
39 | + <td><?php _e('Payment Method', 'invoicing'); ?></td> |
|
40 | 40 | <td><?php echo $invoice->get_gateway_title(); ?></td> |
41 | 41 | </tr> |
42 | - <?php if ( $invoice_date = $invoice->get_invoice_date( false ) ) { ?> |
|
42 | + <?php if ($invoice_date = $invoice->get_invoice_date(false)) { ?> |
|
43 | 43 | <tr> |
44 | - <td><?php _e( 'Invoice Date', 'invoicing' ); ?></td> |
|
45 | - <td><?php echo wp_sprintf( '<time datetime="%s">%s</time>', date_i18n( 'c', strtotime( $invoice_date ) ), $invoice->get_invoice_date() ); ?></td> |
|
44 | + <td><?php _e('Invoice Date', 'invoicing'); ?></td> |
|
45 | + <td><?php echo wp_sprintf('<time datetime="%s">%s</time>', date_i18n('c', strtotime($invoice_date)), $invoice->get_invoice_date()); ?></td> |
|
46 | 46 | </tr> |
47 | 47 | <?php } ?> |
48 | - <?php if ( wpinv_get_option( 'overdue_active' ) && $invoice->needs_payment() && ( $due_date = $invoice->get_due_date() ) ) { ?> |
|
48 | + <?php if (wpinv_get_option('overdue_active') && $invoice->needs_payment() && ($due_date = $invoice->get_due_date())) { ?> |
|
49 | 49 | <tr> |
50 | - <td><?php _e( 'Due Date', 'invoicing' ); ?></td> |
|
51 | - <td><?php echo wp_sprintf( '<time datetime="%s">%s</time>', date_i18n( 'c', strtotime( $due_date ) ), $invoice->get_due_date( true ) ); ?></td> |
|
50 | + <td><?php _e('Due Date', 'invoicing'); ?></td> |
|
51 | + <td><?php echo wp_sprintf('<time datetime="%s">%s</time>', date_i18n('c', strtotime($due_date)), $invoice->get_due_date(true)); ?></td> |
|
52 | 52 | </tr> |
53 | 53 | <?php } ?> |
54 | - <?php if ( empty( $sent_to_admin ) && $owner_vat_number = $wpinv_euvat->get_vat_number() ) { ?> |
|
54 | + <?php if (empty($sent_to_admin) && $owner_vat_number = $wpinv_euvat->get_vat_number()) { ?> |
|
55 | 55 | <tr> |
56 | - <td><?php echo wp_sprintf( __( 'Owner %s Number', 'invoicing' ), $vat_name ); ?></td> |
|
56 | + <td><?php echo wp_sprintf(__('Owner %s Number', 'invoicing'), $vat_name); ?></td> |
|
57 | 57 | <td><?php echo $owner_vat_number; ?></td> |
58 | 58 | </tr> |
59 | 59 | <?php } ?> |
60 | - <?php if ( $use_taxes && $user_vat_number = $invoice->vat_number ) { ?> |
|
60 | + <?php if ($use_taxes && $user_vat_number = $invoice->vat_number) { ?> |
|
61 | 61 | <tr> |
62 | - <td><?php echo wp_sprintf( __( 'Invoice %s Number', 'invoicing' ), $vat_name ); ?></td> |
|
62 | + <td><?php echo wp_sprintf(__('Invoice %s Number', 'invoicing'), $vat_name); ?></td> |
|
63 | 63 | <td><?php echo $user_vat_number; ?></td> |
64 | 64 | </tr> |
65 | 65 | <?php } ?> |
66 | 66 | <tr class="table-active"> |
67 | - <td><strong><?php _e( 'Total Amount', 'invoicing' ) ?></strong></td> |
|
68 | - <td><strong><?php echo $invoice->get_total( true ); ?></strong></td> |
|
67 | + <td><strong><?php _e('Total Amount', 'invoicing') ?></strong></td> |
|
68 | + <td><strong><?php echo $invoice->get_total(true); ?></strong></td> |
|
69 | 69 | </tr> |
70 | 70 | </table> |
71 | 71 | </div> |
72 | -<?php do_action( 'wpinv_email_after_invoice_details', $invoice, $sent_to_admin ); ?> |
|
73 | 72 | \ No newline at end of file |
73 | +<?php do_action('wpinv_email_after_invoice_details', $invoice, $sent_to_admin); ?> |
|
74 | 74 | \ No newline at end of file |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // Exit if accessed directly. |
3 | -if (!defined( 'ABSPATH' ) ) exit; |
|
3 | +if (!defined('ABSPATH')) exit; |
|
4 | 4 | |
5 | 5 | class WPInv_EUVat { |
6 | 6 | private static $is_ajax = false; |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | private static $instance = false; |
9 | 9 | |
10 | 10 | public static function get_instance() { |
11 | - if ( !self::$instance ) { |
|
11 | + if (!self::$instance) { |
|
12 | 12 | self::$instance = new self(); |
13 | 13 | self::$instance->actions(); |
14 | 14 | } |
@@ -17,132 +17,132 @@ discard block |
||
17 | 17 | } |
18 | 18 | |
19 | 19 | public function __construct() { |
20 | - self::$is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
|
20 | + self::$is_ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
21 | 21 | self::$default_country = wpinv_get_default_country(); |
22 | 22 | } |
23 | 23 | |
24 | 24 | public static function actions() { |
25 | - if ( is_admin() ) { |
|
26 | - add_action( 'admin_enqueue_scripts', array( self::$instance, 'enqueue_admin_scripts' ) ); |
|
27 | - add_action( 'wpinv_settings_sections_taxes', array( self::$instance, 'section_vat_settings' ) ); |
|
28 | - add_action( 'wpinv_settings_taxes', array( self::$instance, 'vat_settings' ) ); |
|
29 | - add_filter( 'wpinv_settings_taxes-vat_sanitize', array( self::$instance, 'sanitize_vat_settings' ) ); |
|
30 | - add_filter( 'wpinv_settings_taxes-vat_rates_sanitize', array( self::$instance, 'sanitize_vat_rates' ) ); |
|
31 | - add_action( 'wp_ajax_wpinv_add_vat_class', array( self::$instance, 'add_class' ) ); |
|
32 | - add_action( 'wp_ajax_nopriv_wpinv_add_vat_class', array( self::$instance, 'add_class' ) ); |
|
33 | - add_action( 'wp_ajax_wpinv_delete_vat_class', array( self::$instance, 'delete_class' ) ); |
|
34 | - add_action( 'wp_ajax_nopriv_wpinv_delete_vat_class', array( self::$instance, 'delete_class' ) ); |
|
35 | - add_action( 'wp_ajax_wpinv_update_vat_rates', array( self::$instance, 'update_eu_rates' ) ); |
|
36 | - add_action( 'wp_ajax_nopriv_wpinv_update_vat_rates', array( self::$instance, 'update_eu_rates' ) ); |
|
37 | - add_action( 'wp_ajax_wpinv_geoip2', array( self::$instance, 'geoip2_download_database' ) ); |
|
38 | - add_action( 'wp_ajax_nopriv_wpinv_geoip2', array( self::$instance, 'geoip2_download_database' ) ); |
|
39 | - } |
|
40 | - |
|
41 | - add_action( 'wp_enqueue_scripts', array( self::$instance, 'enqueue_vat_scripts' ) ); |
|
42 | - add_filter( 'wpinv_default_billing_country', array( self::$instance, 'get_user_country' ), 10 ); |
|
43 | - add_filter( 'wpinv_get_user_country', array( self::$instance, 'set_user_country' ), 10 ); |
|
44 | - add_action( 'wp_ajax_wpinv_vat_validate', array( self::$instance, 'ajax_vat_validate' ) ); |
|
45 | - add_action( 'wp_ajax_nopriv_wpinv_vat_validate', array( self::$instance, 'ajax_vat_validate' ) ); |
|
46 | - add_action( 'wp_ajax_wpinv_vat_reset', array( self::$instance, 'ajax_vat_reset' ) ); |
|
47 | - add_action( 'wp_ajax_nopriv_wpinv_vat_reset', array( self::$instance, 'ajax_vat_reset' ) ); |
|
48 | - add_action( 'wpinv_invoice_print_after_line_items', array( self::$instance, 'show_vat_notice' ), 999, 1 ); |
|
49 | - if ( wpinv_use_taxes() ) { |
|
50 | - add_action( 'wpinv_after_billing_fields', array( self::$instance, 'checkout_vat_fields' ) ); |
|
51 | - if ( self::allow_vat_rules() ) { |
|
52 | - add_action( 'wpinv_checkout_error_checks', array( self::$instance, 'checkout_vat_validate' ), 10, 2 ); |
|
53 | - add_filter( 'wpinv_tax_rate', array( self::$instance, 'get_rate' ), 10, 4 ); |
|
25 | + if (is_admin()) { |
|
26 | + add_action('admin_enqueue_scripts', array(self::$instance, 'enqueue_admin_scripts')); |
|
27 | + add_action('wpinv_settings_sections_taxes', array(self::$instance, 'section_vat_settings')); |
|
28 | + add_action('wpinv_settings_taxes', array(self::$instance, 'vat_settings')); |
|
29 | + add_filter('wpinv_settings_taxes-vat_sanitize', array(self::$instance, 'sanitize_vat_settings')); |
|
30 | + add_filter('wpinv_settings_taxes-vat_rates_sanitize', array(self::$instance, 'sanitize_vat_rates')); |
|
31 | + add_action('wp_ajax_wpinv_add_vat_class', array(self::$instance, 'add_class')); |
|
32 | + add_action('wp_ajax_nopriv_wpinv_add_vat_class', array(self::$instance, 'add_class')); |
|
33 | + add_action('wp_ajax_wpinv_delete_vat_class', array(self::$instance, 'delete_class')); |
|
34 | + add_action('wp_ajax_nopriv_wpinv_delete_vat_class', array(self::$instance, 'delete_class')); |
|
35 | + add_action('wp_ajax_wpinv_update_vat_rates', array(self::$instance, 'update_eu_rates')); |
|
36 | + add_action('wp_ajax_nopriv_wpinv_update_vat_rates', array(self::$instance, 'update_eu_rates')); |
|
37 | + add_action('wp_ajax_wpinv_geoip2', array(self::$instance, 'geoip2_download_database')); |
|
38 | + add_action('wp_ajax_nopriv_wpinv_geoip2', array(self::$instance, 'geoip2_download_database')); |
|
39 | + } |
|
40 | + |
|
41 | + add_action('wp_enqueue_scripts', array(self::$instance, 'enqueue_vat_scripts')); |
|
42 | + add_filter('wpinv_default_billing_country', array(self::$instance, 'get_user_country'), 10); |
|
43 | + add_filter('wpinv_get_user_country', array(self::$instance, 'set_user_country'), 10); |
|
44 | + add_action('wp_ajax_wpinv_vat_validate', array(self::$instance, 'ajax_vat_validate')); |
|
45 | + add_action('wp_ajax_nopriv_wpinv_vat_validate', array(self::$instance, 'ajax_vat_validate')); |
|
46 | + add_action('wp_ajax_wpinv_vat_reset', array(self::$instance, 'ajax_vat_reset')); |
|
47 | + add_action('wp_ajax_nopriv_wpinv_vat_reset', array(self::$instance, 'ajax_vat_reset')); |
|
48 | + add_action('wpinv_invoice_print_after_line_items', array(self::$instance, 'show_vat_notice'), 999, 1); |
|
49 | + if (wpinv_use_taxes()) { |
|
50 | + add_action('wpinv_after_billing_fields', array(self::$instance, 'checkout_vat_fields')); |
|
51 | + if (self::allow_vat_rules()) { |
|
52 | + add_action('wpinv_checkout_error_checks', array(self::$instance, 'checkout_vat_validate'), 10, 2); |
|
53 | + add_filter('wpinv_tax_rate', array(self::$instance, 'get_rate'), 10, 4); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
58 | - public static function get_eu_states( $sort = true ) { |
|
59 | - $eu_states = array( 'AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GB', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE' ); |
|
60 | - if ( $sort ) { |
|
61 | - $sort = sort( $eu_states ); |
|
58 | + public static function get_eu_states($sort = true) { |
|
59 | + $eu_states = array('AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GB', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE'); |
|
60 | + if ($sort) { |
|
61 | + $sort = sort($eu_states); |
|
62 | 62 | } |
63 | 63 | |
64 | - return apply_filters( 'wpinv_get_eu_states', $eu_states, $sort ); |
|
64 | + return apply_filters('wpinv_get_eu_states', $eu_states, $sort); |
|
65 | 65 | } |
66 | 66 | |
67 | - public static function get_gst_countries( $sort = true ) { |
|
68 | - $gst_countries = array( 'AU', 'NZ', 'CA', 'CN' ); |
|
67 | + public static function get_gst_countries($sort = true) { |
|
68 | + $gst_countries = array('AU', 'NZ', 'CA', 'CN'); |
|
69 | 69 | |
70 | - if ( $sort ) { |
|
71 | - $sort = sort( $gst_countries ); |
|
70 | + if ($sort) { |
|
71 | + $sort = sort($gst_countries); |
|
72 | 72 | } |
73 | 73 | |
74 | - return apply_filters( 'wpinv_get_gst_countries', $gst_countries, $sort ); |
|
74 | + return apply_filters('wpinv_get_gst_countries', $gst_countries, $sort); |
|
75 | 75 | } |
76 | 76 | |
77 | - public static function is_eu_state( $country_code ) { |
|
78 | - $return = !empty( $country_code ) && in_array( strtoupper( $country_code ), self::get_eu_states() ) ? true : false; |
|
77 | + public static function is_eu_state($country_code) { |
|
78 | + $return = !empty($country_code) && in_array(strtoupper($country_code), self::get_eu_states()) ? true : false; |
|
79 | 79 | |
80 | - return apply_filters( 'wpinv_is_eu_state', $return, $country_code ); |
|
80 | + return apply_filters('wpinv_is_eu_state', $return, $country_code); |
|
81 | 81 | } |
82 | 82 | |
83 | - public static function is_gst_country( $country_code ) { |
|
84 | - $return = !empty( $country_code ) && in_array( strtoupper( $country_code ), self::get_gst_countries() ) ? true : false; |
|
83 | + public static function is_gst_country($country_code) { |
|
84 | + $return = !empty($country_code) && in_array(strtoupper($country_code), self::get_gst_countries()) ? true : false; |
|
85 | 85 | |
86 | - return apply_filters( 'wpinv_is_gst_country', $return, $country_code ); |
|
86 | + return apply_filters('wpinv_is_gst_country', $return, $country_code); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | public static function enqueue_vat_scripts() { |
90 | - $suffix = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
90 | + $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
91 | 91 | |
92 | - wp_register_script( 'wpinv-vat-validation-script', WPINV_PLUGIN_URL . 'assets/js/jsvat' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
93 | - wp_register_script( 'wpinv-vat-script', WPINV_PLUGIN_URL . 'assets/js/euvat' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
92 | + wp_register_script('wpinv-vat-validation-script', WPINV_PLUGIN_URL . 'assets/js/jsvat' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
93 | + wp_register_script('wpinv-vat-script', WPINV_PLUGIN_URL . 'assets/js/euvat' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
94 | 94 | |
95 | - $vat_name = self::get_vat_name(); |
|
95 | + $vat_name = self::get_vat_name(); |
|
96 | 96 | |
97 | 97 | $vars = array(); |
98 | 98 | $vars['UseTaxes'] = wpinv_use_taxes(); |
99 | 99 | $vars['EUStates'] = self::get_eu_states(); |
100 | - $vars['NoRateSet'] = __( 'You have not set a rate. Do you want to continue?', 'invoicing' ); |
|
101 | - $vars['EmptyCompany'] = __( 'Please enter your registered company name!', 'invoicing' ); |
|
102 | - $vars['EmptyVAT'] = wp_sprintf( __( 'Please enter your %s number!', 'invoicing' ), $vat_name ); |
|
103 | - $vars['TotalsRefreshed'] = wp_sprintf( __( 'The invoice totals will be refreshed to update the %s.', 'invoicing' ), $vat_name ); |
|
104 | - $vars['ErrValidateVAT'] = wp_sprintf( __( 'Fail to validate the %s number!', 'invoicing' ), $vat_name ); |
|
105 | - $vars['ErrResetVAT'] = wp_sprintf( __( 'Fail to reset the %s number!', 'invoicing' ), $vat_name ); |
|
106 | - $vars['ErrInvalidVat'] = wp_sprintf( __( 'The %s number supplied does not have a valid format!', 'invoicing' ), $vat_name ); |
|
107 | - $vars['ErrInvalidResponse'] = __( 'An invalid response has been received from the server!', 'invoicing' ); |
|
100 | + $vars['NoRateSet'] = __('You have not set a rate. Do you want to continue?', 'invoicing'); |
|
101 | + $vars['EmptyCompany'] = __('Please enter your registered company name!', 'invoicing'); |
|
102 | + $vars['EmptyVAT'] = wp_sprintf(__('Please enter your %s number!', 'invoicing'), $vat_name); |
|
103 | + $vars['TotalsRefreshed'] = wp_sprintf(__('The invoice totals will be refreshed to update the %s.', 'invoicing'), $vat_name); |
|
104 | + $vars['ErrValidateVAT'] = wp_sprintf(__('Fail to validate the %s number!', 'invoicing'), $vat_name); |
|
105 | + $vars['ErrResetVAT'] = wp_sprintf(__('Fail to reset the %s number!', 'invoicing'), $vat_name); |
|
106 | + $vars['ErrInvalidVat'] = wp_sprintf(__('The %s number supplied does not have a valid format!', 'invoicing'), $vat_name); |
|
107 | + $vars['ErrInvalidResponse'] = __('An invalid response has been received from the server!', 'invoicing'); |
|
108 | 108 | $vars['ApplyVATRules'] = $vars['UseTaxes'] ? self::allow_vat_rules() : false; |
109 | 109 | $vars['HideVatFields'] = $vars['ApplyVATRules'] ? self::hide_vat_fields() : true; |
110 | - $vars['ErrResponse'] = __( 'The request response is invalid!', 'invoicing' ); |
|
111 | - $vars['ErrRateResponse'] = __( 'The get rate request response is invalid', 'invoicing' ); |
|
112 | - $vars['PageRefresh'] = __( 'The page will be refreshed in 10 seconds to show the new options.', 'invoicing' ); |
|
113 | - $vars['RequestResponseNotValidJSON'] = __( 'The get rate request response is not valid JSON', 'invoicing' ); |
|
114 | - $vars['GetRateRequestFailed'] = __( 'The get rate request failed: ', 'invoicing' ); |
|
115 | - $vars['NoRateInformationInResponse'] = __( 'The get rate request response does not contain any rate information', 'invoicing' ); |
|
116 | - $vars['RatesUpdated'] = __( 'The rates have been updated. Press the save button to record these new rates.', 'invoicing' ); |
|
117 | - $vars['IPAddressInformation'] = __( 'IP Address Information', 'invoicing' ); |
|
118 | - $vars['VatValidating'] = wp_sprintf( __( 'Validating %s number...', 'invoicing' ), $vat_name ); |
|
119 | - $vars['VatReseting'] = __( 'Reseting...', 'invoicing' ); |
|
120 | - $vars['VatValidated'] = wp_sprintf( __( '%s number validated', 'invoicing' ), $vat_name ); |
|
121 | - $vars['VatNotValidated'] = wp_sprintf( __( '%s number not validated', 'invoicing' ), $vat_name ); |
|
122 | - $vars['ConfirmDeleteClass'] = __( 'Are you sure you wish to delete this rates class?', 'invoicing' ); |
|
110 | + $vars['ErrResponse'] = __('The request response is invalid!', 'invoicing'); |
|
111 | + $vars['ErrRateResponse'] = __('The get rate request response is invalid', 'invoicing'); |
|
112 | + $vars['PageRefresh'] = __('The page will be refreshed in 10 seconds to show the new options.', 'invoicing'); |
|
113 | + $vars['RequestResponseNotValidJSON'] = __('The get rate request response is not valid JSON', 'invoicing'); |
|
114 | + $vars['GetRateRequestFailed'] = __('The get rate request failed: ', 'invoicing'); |
|
115 | + $vars['NoRateInformationInResponse'] = __('The get rate request response does not contain any rate information', 'invoicing'); |
|
116 | + $vars['RatesUpdated'] = __('The rates have been updated. Press the save button to record these new rates.', 'invoicing'); |
|
117 | + $vars['IPAddressInformation'] = __('IP Address Information', 'invoicing'); |
|
118 | + $vars['VatValidating'] = wp_sprintf(__('Validating %s number...', 'invoicing'), $vat_name); |
|
119 | + $vars['VatReseting'] = __('Reseting...', 'invoicing'); |
|
120 | + $vars['VatValidated'] = wp_sprintf(__('%s number validated', 'invoicing'), $vat_name); |
|
121 | + $vars['VatNotValidated'] = wp_sprintf(__('%s number not validated', 'invoicing'), $vat_name); |
|
122 | + $vars['ConfirmDeleteClass'] = __('Are you sure you wish to delete this rates class?', 'invoicing'); |
|
123 | 123 | $vars['isFront'] = is_admin() ? false : true; |
124 | - $vars['checkoutNonce'] = wp_create_nonce( 'wpinv_checkout_nonce' ); |
|
124 | + $vars['checkoutNonce'] = wp_create_nonce('wpinv_checkout_nonce'); |
|
125 | 125 | $vars['baseCountry'] = wpinv_get_default_country(); |
126 | - $vars['disableVATSameCountry'] = ( self::same_country_rule() == 'no' ? true : false ); |
|
127 | - $vars['disableVATSimpleCheck'] = wpinv_get_option( 'vat_offline_check' ) ? true : false; |
|
126 | + $vars['disableVATSameCountry'] = (self::same_country_rule() == 'no' ? true : false); |
|
127 | + $vars['disableVATSimpleCheck'] = wpinv_get_option('vat_offline_check') ? true : false; |
|
128 | 128 | |
129 | - wp_enqueue_script( 'wpinv-vat-validation-script' ); |
|
130 | - wp_enqueue_script( 'wpinv-vat-script' ); |
|
131 | - wp_localize_script( 'wpinv-vat-script', 'WPInv_VAT_Vars', $vars ); |
|
129 | + wp_enqueue_script('wpinv-vat-validation-script'); |
|
130 | + wp_enqueue_script('wpinv-vat-script'); |
|
131 | + wp_localize_script('wpinv-vat-script', 'WPInv_VAT_Vars', $vars); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | public static function enqueue_admin_scripts() { |
135 | - if( isset( $_GET['page'] ) && 'wpinv-settings' == $_GET['page'] ) { |
|
135 | + if (isset($_GET['page']) && 'wpinv-settings' == $_GET['page']) { |
|
136 | 136 | self::enqueue_vat_scripts(); |
137 | 137 | } |
138 | 138 | } |
139 | 139 | |
140 | - public static function section_vat_settings( $sections ) { |
|
141 | - if ( !empty( $sections ) ) { |
|
142 | - $sections['vat'] = __( 'EU VAT Settings', 'invoicing' ); |
|
140 | + public static function section_vat_settings($sections) { |
|
141 | + if (!empty($sections)) { |
|
142 | + $sections['vat'] = __('EU VAT Settings', 'invoicing'); |
|
143 | 143 | |
144 | - if ( self::allow_vat_classes() ) { |
|
145 | - $sections['vat_rates'] = __( 'EU VAT Rates', 'invoicing' ); |
|
144 | + if (self::allow_vat_classes()) { |
|
145 | + $sections['vat_rates'] = __('EU VAT Rates', 'invoicing'); |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | return $sections; |
@@ -151,52 +151,52 @@ discard block |
||
151 | 151 | public static function vat_rates_settings() { |
152 | 152 | $vat_classes = self::get_rate_classes(); |
153 | 153 | $vat_rates = array(); |
154 | - $vat_class = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' && isset( $vat_classes[$_REQUEST['wpi_sub']] )? sanitize_text_field( $_REQUEST['wpi_sub'] ) : '_new'; |
|
155 | - $current_url = remove_query_arg( 'wpi_sub' ); |
|
154 | + $vat_class = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' && isset($vat_classes[$_REQUEST['wpi_sub']]) ? sanitize_text_field($_REQUEST['wpi_sub']) : '_new'; |
|
155 | + $current_url = remove_query_arg('wpi_sub'); |
|
156 | 156 | |
157 | 157 | $vat_rates['vat_rates_header'] = array( |
158 | 158 | 'id' => 'vat_rates_header', |
159 | - 'name' => '<h3>' . __( 'Manage VAT Rates', 'invoicing' ) . '</h3>', |
|
159 | + 'name' => '<h3>' . __('Manage VAT Rates', 'invoicing') . '</h3>', |
|
160 | 160 | 'desc' => '', |
161 | 161 | 'type' => 'header', |
162 | 162 | 'size' => 'regular' |
163 | 163 | ); |
164 | 164 | $vat_rates['vat_rates_class'] = array( |
165 | 165 | 'id' => 'vat_rates_class', |
166 | - 'name' => __( 'Edit VAT Rates', 'invoicing' ), |
|
167 | - 'desc' => __( 'The standard rate will apply where no explicit rate is provided.', 'invoicing' ), |
|
166 | + 'name' => __('Edit VAT Rates', 'invoicing'), |
|
167 | + 'desc' => __('The standard rate will apply where no explicit rate is provided.', 'invoicing'), |
|
168 | 168 | 'type' => 'select', |
169 | - 'options' => array_merge( $vat_classes, array( '_new' => __( 'Add New Rate Class', 'invoicing' ) ) ), |
|
169 | + 'options' => array_merge($vat_classes, array('_new' => __('Add New Rate Class', 'invoicing'))), |
|
170 | 170 | 'chosen' => true, |
171 | - 'placeholder' => __( 'Select a VAT Rate', 'invoicing' ), |
|
171 | + 'placeholder' => __('Select a VAT Rate', 'invoicing'), |
|
172 | 172 | 'selected' => $vat_class, |
173 | 173 | 'onchange' => 'document.location.href="' . $current_url . '&wpi_sub=" + this.value;', |
174 | 174 | ); |
175 | 175 | |
176 | - if ( $vat_class != '_standard' && $vat_class != '_new' ) { |
|
176 | + if ($vat_class != '_standard' && $vat_class != '_new') { |
|
177 | 177 | $vat_rates['vat_rate_delete'] = array( |
178 | 178 | 'id' => 'vat_rate_delete', |
179 | 179 | 'type' => 'vat_rate_delete', |
180 | 180 | ); |
181 | 181 | } |
182 | 182 | |
183 | - if ( $vat_class == '_new' ) { |
|
183 | + if ($vat_class == '_new') { |
|
184 | 184 | $vat_rates['vat_rates_settings'] = array( |
185 | 185 | 'id' => 'vat_rates_settings', |
186 | - 'name' => '<h3>' . __( 'Add New Rate Class', 'invoicing' ) . '</h3>', |
|
186 | + 'name' => '<h3>' . __('Add New Rate Class', 'invoicing') . '</h3>', |
|
187 | 187 | 'type' => 'header', |
188 | 188 | ); |
189 | 189 | $vat_rates['vat_rate_name'] = array( |
190 | 190 | 'id' => 'vat_rate_name', |
191 | - 'name' => __( 'Name', 'invoicing' ), |
|
192 | - 'desc' => __( 'A short name for the new VAT Rate class', 'invoicing' ), |
|
191 | + 'name' => __('Name', 'invoicing'), |
|
192 | + 'desc' => __('A short name for the new VAT Rate class', 'invoicing'), |
|
193 | 193 | 'type' => 'text', |
194 | 194 | 'size' => 'regular', |
195 | 195 | ); |
196 | 196 | $vat_rates['vat_rate_desc'] = array( |
197 | 197 | 'id' => 'vat_rate_desc', |
198 | - 'name' => __( 'Description', 'invoicing' ), |
|
199 | - 'desc' => __( 'Manage VAT Rate class', 'invoicing' ), |
|
198 | + 'name' => __('Description', 'invoicing'), |
|
199 | + 'desc' => __('Manage VAT Rate class', 'invoicing'), |
|
200 | 200 | 'type' => 'text', |
201 | 201 | 'size' => 'regular', |
202 | 202 | ); |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | $vat_rates['vat_rates'] = array( |
209 | 209 | 'id' => 'vat_rates', |
210 | 210 | 'name' => '<h3>' . $vat_classes[$vat_class] . '</h3>', |
211 | - 'desc' => self::get_class_desc( $vat_class ), |
|
211 | + 'desc' => self::get_class_desc($vat_class), |
|
212 | 212 | 'type' => 'vat_rates', |
213 | 213 | ); |
214 | 214 | } |
@@ -216,12 +216,12 @@ discard block |
||
216 | 216 | return $vat_rates; |
217 | 217 | } |
218 | 218 | |
219 | - public static function vat_settings( $settings ) { |
|
220 | - if ( !empty( $settings ) ) { |
|
219 | + public static function vat_settings($settings) { |
|
220 | + if (!empty($settings)) { |
|
221 | 221 | $vat_settings = array(); |
222 | 222 | $vat_settings['vat_company_title'] = array( |
223 | 223 | 'id' => 'vat_company_title', |
224 | - 'name' => '<h3>' . __( 'Your Company Details', 'invoicing' ) . '</h3>', |
|
224 | + 'name' => '<h3>' . __('Your Company Details', 'invoicing') . '</h3>', |
|
225 | 225 | 'desc' => '', |
226 | 226 | 'type' => 'header', |
227 | 227 | 'size' => 'regular' |
@@ -229,22 +229,22 @@ discard block |
||
229 | 229 | |
230 | 230 | $vat_settings['vat_company_name'] = array( |
231 | 231 | 'id' => 'vat_company_name', |
232 | - 'name' => __( 'Your Company Name', 'invoicing' ), |
|
233 | - 'desc' => wp_sprintf(__( 'Your company name as it appears on your VAT return, you can verify it via your VAT ID on the %sEU VIES System.%s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ), |
|
232 | + 'name' => __('Your Company Name', 'invoicing'), |
|
233 | + 'desc' => wp_sprintf(__('Your company name as it appears on your VAT return, you can verify it via your VAT ID on the %sEU VIES System.%s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'), |
|
234 | 234 | 'type' => 'text', |
235 | 235 | 'size' => 'regular', |
236 | 236 | ); |
237 | 237 | |
238 | 238 | $vat_settings['vat_number'] = array( |
239 | 239 | 'id' => 'vat_number', |
240 | - 'name' => __( 'Your VAT Number', 'invoicing' ), |
|
240 | + 'name' => __('Your VAT Number', 'invoicing'), |
|
241 | 241 | 'type' => 'vat_number', |
242 | 242 | 'size' => 'regular', |
243 | 243 | ); |
244 | 244 | |
245 | 245 | $vat_settings['vat_settings_title'] = array( |
246 | 246 | 'id' => 'vat_settings_title', |
247 | - 'name' => '<h3>' . __( 'Apply VAT Settings', 'invoicing' ) . '</h3>', |
|
247 | + 'name' => '<h3>' . __('Apply VAT Settings', 'invoicing') . '</h3>', |
|
248 | 248 | 'desc' => '', |
249 | 249 | 'type' => 'header', |
250 | 250 | 'size' => 'regular' |
@@ -252,8 +252,8 @@ discard block |
||
252 | 252 | |
253 | 253 | $vat_settings['apply_vat_rules'] = array( |
254 | 254 | 'id' => 'apply_vat_rules', |
255 | - 'name' => __( 'Enable VAT rules', 'invoicing' ), |
|
256 | - 'desc' => __( 'Apply VAT to consumer sales from IP addresses within the EU, even if the billing address is outside the EU.', 'invoicing' ) . '<br><font style="color:red">' . __( 'Do not disable unless you know what you are doing.', 'invoicing' ) . '</font>', |
|
255 | + 'name' => __('Enable VAT rules', 'invoicing'), |
|
256 | + 'desc' => __('Apply VAT to consumer sales from IP addresses within the EU, even if the billing address is outside the EU.', 'invoicing') . '<br><font style="color:red">' . __('Do not disable unless you know what you are doing.', 'invoicing') . '</font>', |
|
257 | 257 | 'type' => 'checkbox', |
258 | 258 | 'std' => '1' |
259 | 259 | ); |
@@ -269,8 +269,8 @@ discard block |
||
269 | 269 | |
270 | 270 | $vat_settings['vat_prevent_b2c_purchase'] = array( |
271 | 271 | 'id' => 'vat_prevent_b2c_purchase', |
272 | - 'name' => __( 'Prevent EU B2C sales', 'invoicing' ), |
|
273 | - 'desc' => __( 'Enable this option if you are not registered for VAT in the EU.', 'invoicing' ), |
|
272 | + 'name' => __('Prevent EU B2C sales', 'invoicing'), |
|
273 | + 'desc' => __('Enable this option if you are not registered for VAT in the EU.', 'invoicing'), |
|
274 | 274 | 'type' => 'checkbox' |
275 | 275 | ); |
276 | 276 | |
@@ -278,21 +278,21 @@ discard block |
||
278 | 278 | |
279 | 279 | $vat_settings['vat_same_country_rule'] = array( |
280 | 280 | 'id' => 'vat_same_country_rule', |
281 | - 'name' => __( 'Same country rule', 'invoicing' ), |
|
282 | - 'desc' => __( 'Select how you want handle VAT charge if sales are in the same country as the base country.', 'invoicing' ), |
|
281 | + 'name' => __('Same country rule', 'invoicing'), |
|
282 | + 'desc' => __('Select how you want handle VAT charge if sales are in the same country as the base country.', 'invoicing'), |
|
283 | 283 | 'type' => 'select', |
284 | 284 | 'options' => array( |
285 | - '' => __( 'Normal', 'invoicing' ), |
|
286 | - 'no' => __( 'No VAT', 'invoicing' ), |
|
287 | - 'always' => __( 'Always apply VAT', 'invoicing' ), |
|
285 | + '' => __('Normal', 'invoicing'), |
|
286 | + 'no' => __('No VAT', 'invoicing'), |
|
287 | + 'always' => __('Always apply VAT', 'invoicing'), |
|
288 | 288 | ), |
289 | - 'placeholder' => __( 'Select a option', 'invoicing' ), |
|
289 | + 'placeholder' => __('Select a option', 'invoicing'), |
|
290 | 290 | 'std' => '' |
291 | 291 | ); |
292 | 292 | |
293 | 293 | $vat_settings['vat_checkout_title'] = array( |
294 | 294 | 'id' => 'vat_checkout_title', |
295 | - 'name' => '<h3>' . __( 'Checkout Fields', 'invoicing' ) . '</h3>', |
|
295 | + 'name' => '<h3>' . __('Checkout Fields', 'invoicing') . '</h3>', |
|
296 | 296 | 'desc' => '', |
297 | 297 | 'type' => 'header', |
298 | 298 | 'size' => 'regular' |
@@ -300,14 +300,14 @@ discard block |
||
300 | 300 | |
301 | 301 | $vat_settings['vat_disable_fields'] = array( |
302 | 302 | 'id' => 'vat_disable_fields', |
303 | - 'name' => __( 'Disable VAT fields', 'invoicing' ), |
|
304 | - 'desc' => __( 'Disable VAT fields if Invoicing is being used for GST.', 'invoicing' ) . '<br><font style="color:red">' . __( 'Do not disable if you have enabled Prevent EU B2C sales, otherwise Prevent EU B2C sales setting will not work.', 'invoicing' ) . '</font>', |
|
303 | + 'name' => __('Disable VAT fields', 'invoicing'), |
|
304 | + 'desc' => __('Disable VAT fields if Invoicing is being used for GST.', 'invoicing') . '<br><font style="color:red">' . __('Do not disable if you have enabled Prevent EU B2C sales, otherwise Prevent EU B2C sales setting will not work.', 'invoicing') . '</font>', |
|
305 | 305 | 'type' => 'checkbox' |
306 | 306 | ); |
307 | 307 | |
308 | 308 | $vat_settings['vat_ip_lookup'] = array( |
309 | 309 | 'id' => 'vat_ip_lookup', |
310 | - 'name' => __( 'IP Country lookup', 'invoicing' ), |
|
310 | + 'name' => __('IP Country lookup', 'invoicing'), |
|
311 | 311 | 'type' => 'vat_ip_lookup', |
312 | 312 | 'size' => 'regular', |
313 | 313 | 'std' => 'default' |
@@ -315,21 +315,21 @@ discard block |
||
315 | 315 | |
316 | 316 | $vat_settings['hide_ip_address'] = array( |
317 | 317 | 'id' => 'hide_ip_address', |
318 | - 'name' => __( 'Hide IP info at checkout', 'invoicing' ), |
|
319 | - 'desc' => __( 'Hide the user IP info at checkout.', 'invoicing' ), |
|
318 | + 'name' => __('Hide IP info at checkout', 'invoicing'), |
|
319 | + 'desc' => __('Hide the user IP info at checkout.', 'invoicing'), |
|
320 | 320 | 'type' => 'checkbox' |
321 | 321 | ); |
322 | 322 | |
323 | 323 | $vat_settings['vat_ip_country_default'] = array( |
324 | 324 | 'id' => 'vat_ip_country_default', |
325 | - 'name' => __( 'Enable IP Country as Default', 'invoicing' ), |
|
326 | - 'desc' => __( 'Show the country of the users IP as the default country, otherwise the site default country will be used.', 'invoicing' ), |
|
325 | + 'name' => __('Enable IP Country as Default', 'invoicing'), |
|
326 | + 'desc' => __('Show the country of the users IP as the default country, otherwise the site default country will be used.', 'invoicing'), |
|
327 | 327 | 'type' => 'checkbox' |
328 | 328 | ); |
329 | 329 | |
330 | 330 | $vat_settings['vies_validation_title'] = array( |
331 | 331 | 'id' => 'vies_validation_title', |
332 | - 'name' => '<h3>' . __( 'VIES Validation', 'invoicing' ) . '</h3>', |
|
332 | + 'name' => '<h3>' . __('VIES Validation', 'invoicing') . '</h3>', |
|
333 | 333 | 'desc' => '', |
334 | 334 | 'type' => 'header', |
335 | 335 | 'size' => 'regular' |
@@ -337,37 +337,37 @@ discard block |
||
337 | 337 | |
338 | 338 | $vat_settings['vat_vies_check'] = array( |
339 | 339 | 'id' => 'vat_vies_check', |
340 | - 'name' => __( 'Disable VIES VAT ID check', 'invoicing' ), |
|
341 | - 'desc' => wp_sprintf( __( 'Prevent VAT numbers from being validated by the %sEU VIES System.%s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ), |
|
340 | + 'name' => __('Disable VIES VAT ID check', 'invoicing'), |
|
341 | + 'desc' => wp_sprintf(__('Prevent VAT numbers from being validated by the %sEU VIES System.%s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'), |
|
342 | 342 | 'type' => 'checkbox' |
343 | 343 | ); |
344 | 344 | |
345 | 345 | $vat_settings['vat_disable_company_name_check'] = array( |
346 | 346 | 'id' => 'vat_disable_company_name_check', |
347 | - 'name' => __( 'Disable VIES name check', 'invoicing' ), |
|
348 | - 'desc' => wp_sprintf( __( 'Prevent company name from being validated by the %sEU VIES System.%s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ), |
|
347 | + 'name' => __('Disable VIES name check', 'invoicing'), |
|
348 | + 'desc' => wp_sprintf(__('Prevent company name from being validated by the %sEU VIES System.%s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'), |
|
349 | 349 | 'type' => 'checkbox' |
350 | 350 | ); |
351 | 351 | |
352 | 352 | $vat_settings['vat_offline_check'] = array( |
353 | 353 | 'id' => 'vat_offline_check', |
354 | - 'name' => __( 'Disable basic checks', 'invoicing' ), |
|
355 | - 'desc' => __( 'This will disable basic JS correct format validation attempts, it is very rare this should need to be disabled.', 'invoicing' ), |
|
354 | + 'name' => __('Disable basic checks', 'invoicing'), |
|
355 | + 'desc' => __('This will disable basic JS correct format validation attempts, it is very rare this should need to be disabled.', 'invoicing'), |
|
356 | 356 | 'type' => 'checkbox' |
357 | 357 | ); |
358 | 358 | |
359 | 359 | |
360 | 360 | $settings['vat'] = $vat_settings; |
361 | 361 | |
362 | - if ( self::allow_vat_classes() ) { |
|
362 | + if (self::allow_vat_classes()) { |
|
363 | 363 | $settings['vat_rates'] = self::vat_rates_settings(); |
364 | 364 | } |
365 | 365 | |
366 | 366 | $eu_fallback_rate = array( |
367 | 367 | 'id' => 'eu_fallback_rate', |
368 | - 'name' => '<h3>' . __( 'VAT rate for EU member states', 'invoicing' ) . '</h3>', |
|
368 | + 'name' => '<h3>' . __('VAT rate for EU member states', 'invoicing') . '</h3>', |
|
369 | 369 | 'type' => 'eu_fallback_rate', |
370 | - 'desc' => __( 'Enter the VAT rate to be charged for EU member states. You can edit the rates for each member state when a country rate has been set up by pressing this button.', 'invoicing' ), |
|
370 | + 'desc' => __('Enter the VAT rate to be charged for EU member states. You can edit the rates for each member state when a country rate has been set up by pressing this button.', 'invoicing'), |
|
371 | 371 | 'std' => '20', |
372 | 372 | 'size' => 'small' |
373 | 373 | ); |
@@ -383,11 +383,11 @@ discard block |
||
383 | 383 | $database_url = 'http' . (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] === 'on' ? 's' : '') . '://geolite.maxmind.com/download/geoip/database/'; |
384 | 384 | $destination_dir = $upload_dir['basedir'] . '/invoicing'; |
385 | 385 | |
386 | - if ( !is_dir( $destination_dir ) ) { |
|
387 | - mkdir( $destination_dir ); |
|
386 | + if (!is_dir($destination_dir)) { |
|
387 | + mkdir($destination_dir); |
|
388 | 388 | } |
389 | 389 | |
390 | - $database_files = array( |
|
390 | + $database_files = array( |
|
391 | 391 | 'country' => array( |
392 | 392 | 'source' => $database_url . 'GeoLite2-Country.mmdb.gz', |
393 | 393 | 'destination' => $destination_dir . '/GeoLite2-Country.mmdb', |
@@ -398,57 +398,57 @@ discard block |
||
398 | 398 | ) |
399 | 399 | ); |
400 | 400 | |
401 | - foreach( $database_files as $database => $files ) { |
|
402 | - $result = self::geoip2_download_file( $files['source'], $files['destination'] ); |
|
401 | + foreach ($database_files as $database => $files) { |
|
402 | + $result = self::geoip2_download_file($files['source'], $files['destination']); |
|
403 | 403 | |
404 | - if ( empty( $result['success'] ) ) { |
|
404 | + if (empty($result['success'])) { |
|
405 | 405 | echo $result['message']; |
406 | 406 | exit; |
407 | 407 | } |
408 | 408 | |
409 | - wpinv_update_option( 'wpinv_geoip2_date_updated', current_time( 'timestamp' ) ); |
|
410 | - echo sprintf(__( 'GeoIp2 %s database updated successfully.', 'invoicing' ), $database ) . ' '; |
|
409 | + wpinv_update_option('wpinv_geoip2_date_updated', current_time('timestamp')); |
|
410 | + echo sprintf(__('GeoIp2 %s database updated successfully.', 'invoicing'), $database) . ' '; |
|
411 | 411 | } |
412 | 412 | |
413 | 413 | exit; |
414 | 414 | } |
415 | 415 | |
416 | - public static function geoip2_download_file( $source_url, $destination_file ) { |
|
416 | + public static function geoip2_download_file($source_url, $destination_file) { |
|
417 | 417 | $success = false; |
418 | 418 | $message = ''; |
419 | 419 | |
420 | - if ( !function_exists( 'download_url' ) ) { |
|
421 | - require_once( ABSPATH . 'wp-admin/includes/file.php' ); |
|
420 | + if (!function_exists('download_url')) { |
|
421 | + require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
422 | 422 | } |
423 | 423 | |
424 | - $temp_file = download_url( $source_url ); |
|
424 | + $temp_file = download_url($source_url); |
|
425 | 425 | |
426 | - if ( is_wp_error( $temp_file ) ) { |
|
427 | - $message = sprintf( __( 'Error while downloading GeoIp2 database( %s ): %s', 'invoicing' ), $source_url, $temp_file->get_error_message() ); |
|
426 | + if (is_wp_error($temp_file)) { |
|
427 | + $message = sprintf(__('Error while downloading GeoIp2 database( %s ): %s', 'invoicing'), $source_url, $temp_file->get_error_message()); |
|
428 | 428 | } else { |
429 | - $handle = gzopen( $temp_file, 'rb' ); |
|
429 | + $handle = gzopen($temp_file, 'rb'); |
|
430 | 430 | |
431 | - if ( $handle ) { |
|
432 | - $fopen = fopen( $destination_file, 'wb' ); |
|
433 | - if ( $fopen ) { |
|
434 | - while ( ( $data = gzread( $handle, 4096 ) ) != false ) { |
|
435 | - fwrite( $fopen, $data ); |
|
431 | + if ($handle) { |
|
432 | + $fopen = fopen($destination_file, 'wb'); |
|
433 | + if ($fopen) { |
|
434 | + while (($data = gzread($handle, 4096)) != false) { |
|
435 | + fwrite($fopen, $data); |
|
436 | 436 | } |
437 | 437 | |
438 | - gzclose( $handle ); |
|
439 | - fclose( $fopen ); |
|
438 | + gzclose($handle); |
|
439 | + fclose($fopen); |
|
440 | 440 | |
441 | 441 | $success = true; |
442 | 442 | } else { |
443 | - gzclose( $handle ); |
|
444 | - $message = sprintf( __( 'Error could not open destination GeoIp2 database file for writing: %s', 'invoicing' ), $destination_file ); |
|
443 | + gzclose($handle); |
|
444 | + $message = sprintf(__('Error could not open destination GeoIp2 database file for writing: %s', 'invoicing'), $destination_file); |
|
445 | 445 | } |
446 | 446 | } else { |
447 | - $message = sprintf( __( 'Error could not open GeoIp2 database file for reading: %s', 'invoicing' ), $temp_file ); |
|
447 | + $message = sprintf(__('Error could not open GeoIp2 database file for reading: %s', 'invoicing'), $temp_file); |
|
448 | 448 | } |
449 | 449 | |
450 | - if ( file_exists( $temp_file ) ) { |
|
451 | - unlink( $temp_file ); |
|
450 | + if (file_exists($temp_file)) { |
|
451 | + unlink($temp_file); |
|
452 | 452 | } |
453 | 453 | } |
454 | 454 | |
@@ -460,11 +460,11 @@ discard block |
||
460 | 460 | } |
461 | 461 | |
462 | 462 | public static function load_geoip2() { |
463 | - if ( defined( 'WPINV_GEOIP2_LODDED' ) ) { |
|
463 | + if (defined('WPINV_GEOIP2_LODDED')) { |
|
464 | 464 | return; |
465 | 465 | } |
466 | 466 | |
467 | - if ( !class_exists( '\MaxMind\Db\Reader' ) ) { |
|
467 | + if (!class_exists('\MaxMind\Db\Reader')) { |
|
468 | 468 | $maxmind_db_files = array( |
469 | 469 | 'Reader/Decoder.php', |
470 | 470 | 'Reader/InvalidDatabaseException.php', |
@@ -473,12 +473,12 @@ discard block |
||
473 | 473 | 'Reader.php', |
474 | 474 | ); |
475 | 475 | |
476 | - foreach ( $maxmind_db_files as $key => $file ) { |
|
477 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/MaxMind/Db/' . $file ); |
|
476 | + foreach ($maxmind_db_files as $key => $file) { |
|
477 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/MaxMind/Db/' . $file); |
|
478 | 478 | } |
479 | 479 | } |
480 | 480 | |
481 | - if ( !class_exists( '\GeoIp2\Database\Reader' ) ) { |
|
481 | + if (!class_exists('\GeoIp2\Database\Reader')) { |
|
482 | 482 | $geoip2_files = array( |
483 | 483 | 'ProviderInterface.php', |
484 | 484 | 'Compat/JsonSerializable.php', |
@@ -512,23 +512,23 @@ discard block |
||
512 | 512 | 'WebService/Client.php', |
513 | 513 | ); |
514 | 514 | |
515 | - foreach ( $geoip2_files as $key => $file ) { |
|
516 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/GeoIp2/' . $file ); |
|
515 | + foreach ($geoip2_files as $key => $file) { |
|
516 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/GeoIp2/' . $file); |
|
517 | 517 | } |
518 | 518 | } |
519 | 519 | |
520 | - define( 'WPINV_GEOIP2_LODDED', true ); |
|
520 | + define('WPINV_GEOIP2_LODDED', true); |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | public static function geoip2_country_dbfile() { |
524 | 524 | $upload_dir = wp_upload_dir(); |
525 | 525 | |
526 | - if ( !isset( $upload_dir['basedir'] ) ) { |
|
526 | + if (!isset($upload_dir['basedir'])) { |
|
527 | 527 | return false; |
528 | 528 | } |
529 | 529 | |
530 | 530 | $filename = $upload_dir['basedir'] . '/invoicing/GeoLite2-Country.mmdb'; |
531 | - if ( !file_exists( $filename ) ) { |
|
531 | + if (!file_exists($filename)) { |
|
532 | 532 | return false; |
533 | 533 | } |
534 | 534 | |
@@ -538,12 +538,12 @@ discard block |
||
538 | 538 | public static function geoip2_city_dbfile() { |
539 | 539 | $upload_dir = wp_upload_dir(); |
540 | 540 | |
541 | - if ( !isset( $upload_dir['basedir'] ) ) { |
|
541 | + if (!isset($upload_dir['basedir'])) { |
|
542 | 542 | return false; |
543 | 543 | } |
544 | 544 | |
545 | 545 | $filename = $upload_dir['basedir'] . '/invoicing/GeoLite2-City.mmdb'; |
546 | - if ( !file_exists( $filename ) ) { |
|
546 | + if (!file_exists($filename)) { |
|
547 | 547 | return false; |
548 | 548 | } |
549 | 549 | |
@@ -554,10 +554,10 @@ discard block |
||
554 | 554 | try { |
555 | 555 | self::load_geoip2(); |
556 | 556 | |
557 | - if ( $filename = self::geoip2_country_dbfile() ) { |
|
558 | - return new \GeoIp2\Database\Reader( $filename ); |
|
557 | + if ($filename = self::geoip2_country_dbfile()) { |
|
558 | + return new \GeoIp2\Database\Reader($filename); |
|
559 | 559 | } |
560 | - } catch( Exception $e ) { |
|
560 | + } catch (Exception $e) { |
|
561 | 561 | return false; |
562 | 562 | } |
563 | 563 | |
@@ -568,173 +568,173 @@ discard block |
||
568 | 568 | try { |
569 | 569 | self::load_geoip2(); |
570 | 570 | |
571 | - if ( $filename = self::geoip2_city_dbfile() ) { |
|
572 | - return new \GeoIp2\Database\Reader( $filename ); |
|
571 | + if ($filename = self::geoip2_city_dbfile()) { |
|
572 | + return new \GeoIp2\Database\Reader($filename); |
|
573 | 573 | } |
574 | - } catch( Exception $e ) { |
|
574 | + } catch (Exception $e) { |
|
575 | 575 | return false; |
576 | 576 | } |
577 | 577 | |
578 | 578 | return false; |
579 | 579 | } |
580 | 580 | |
581 | - public static function geoip2_country_record( $ip_address ) { |
|
581 | + public static function geoip2_country_record($ip_address) { |
|
582 | 582 | try { |
583 | 583 | $reader = self::geoip2_country_reader(); |
584 | 584 | |
585 | - if ( $reader ) { |
|
586 | - $record = $reader->country( $ip_address ); |
|
585 | + if ($reader) { |
|
586 | + $record = $reader->country($ip_address); |
|
587 | 587 | |
588 | - if ( !empty( $record->country->isoCode ) ) { |
|
588 | + if (!empty($record->country->isoCode)) { |
|
589 | 589 | return $record; |
590 | 590 | } |
591 | 591 | } |
592 | - } catch(\InvalidArgumentException $e) { |
|
593 | - wpinv_error_log( $e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )' ); |
|
592 | + } catch (\InvalidArgumentException $e) { |
|
593 | + wpinv_error_log($e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )'); |
|
594 | 594 | |
595 | 595 | return false; |
596 | - } catch(\GeoIp2\Exception\AddressNotFoundException $e) { |
|
597 | - wpinv_error_log( $e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )' ); |
|
596 | + } catch (\GeoIp2\Exception\AddressNotFoundException $e) { |
|
597 | + wpinv_error_log($e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )'); |
|
598 | 598 | |
599 | 599 | return false; |
600 | - } catch( Exception $e ) { |
|
600 | + } catch (Exception $e) { |
|
601 | 601 | return false; |
602 | 602 | } |
603 | 603 | |
604 | 604 | return false; |
605 | 605 | } |
606 | 606 | |
607 | - public static function geoip2_city_record( $ip_address ) { |
|
607 | + public static function geoip2_city_record($ip_address) { |
|
608 | 608 | try { |
609 | 609 | $reader = self::geoip2_city_reader(); |
610 | 610 | |
611 | - if ( $reader ) { |
|
612 | - $record = $reader->city( $ip_address ); |
|
611 | + if ($reader) { |
|
612 | + $record = $reader->city($ip_address); |
|
613 | 613 | |
614 | - if ( !empty( $record->country->isoCode ) ) { |
|
614 | + if (!empty($record->country->isoCode)) { |
|
615 | 615 | return $record; |
616 | 616 | } |
617 | 617 | } |
618 | - } catch(\InvalidArgumentException $e) { |
|
619 | - wpinv_error_log( $e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )' ); |
|
618 | + } catch (\InvalidArgumentException $e) { |
|
619 | + wpinv_error_log($e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )'); |
|
620 | 620 | |
621 | 621 | return false; |
622 | - } catch(\GeoIp2\Exception\AddressNotFoundException $e) { |
|
623 | - wpinv_error_log( $e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )' ); |
|
622 | + } catch (\GeoIp2\Exception\AddressNotFoundException $e) { |
|
623 | + wpinv_error_log($e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )'); |
|
624 | 624 | |
625 | 625 | return false; |
626 | - } catch( Exception $e ) { |
|
626 | + } catch (Exception $e) { |
|
627 | 627 | return false; |
628 | 628 | } |
629 | 629 | |
630 | 630 | return false; |
631 | 631 | } |
632 | 632 | |
633 | - public static function geoip2_country_code( $ip_address ) { |
|
634 | - $record = self::geoip2_country_record( $ip_address ); |
|
635 | - return !empty( $record->country->isoCode ) ? $record->country->isoCode : wpinv_get_default_country(); |
|
633 | + public static function geoip2_country_code($ip_address) { |
|
634 | + $record = self::geoip2_country_record($ip_address); |
|
635 | + return !empty($record->country->isoCode) ? $record->country->isoCode : wpinv_get_default_country(); |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | // Find country by IP address. |
639 | - public static function get_country_by_ip( $ip = '' ) { |
|
639 | + public static function get_country_by_ip($ip = '') { |
|
640 | 640 | global $wpinv_ip_address_country; |
641 | 641 | |
642 | - if ( !empty( $wpinv_ip_address_country ) ) { |
|
642 | + if (!empty($wpinv_ip_address_country)) { |
|
643 | 643 | return $wpinv_ip_address_country; |
644 | 644 | } |
645 | 645 | |
646 | - if ( empty( $ip ) ) { |
|
646 | + if (empty($ip)) { |
|
647 | 647 | $ip = wpinv_get_ip(); |
648 | 648 | } |
649 | 649 | |
650 | - $ip_country_service = wpinv_get_option( 'vat_ip_lookup' ); |
|
651 | - $is_default = empty( $ip_country_service ) || $ip_country_service === 'default' ? true : false; |
|
650 | + $ip_country_service = wpinv_get_option('vat_ip_lookup'); |
|
651 | + $is_default = empty($ip_country_service) || $ip_country_service === 'default' ? true : false; |
|
652 | 652 | |
653 | - if ( !empty( $ip ) && $ip !== '127.0.0.1' ) { // For 127.0.0.1(localhost) use default country. |
|
654 | - if ( function_exists( 'geoip_country_code_by_name') && ( $ip_country_service === 'geoip' || $is_default ) ) { |
|
653 | + if (!empty($ip) && $ip !== '127.0.0.1') { // For 127.0.0.1(localhost) use default country. |
|
654 | + if (function_exists('geoip_country_code_by_name') && ($ip_country_service === 'geoip' || $is_default)) { |
|
655 | 655 | try { |
656 | - $wpinv_ip_address_country = geoip_country_code_by_name( $ip ); |
|
657 | - } catch( Exception $e ) { |
|
658 | - wpinv_error_log( $e->getMessage(), 'GeoIP Lookup( ' . $ip . ' )' ); |
|
656 | + $wpinv_ip_address_country = geoip_country_code_by_name($ip); |
|
657 | + } catch (Exception $e) { |
|
658 | + wpinv_error_log($e->getMessage(), 'GeoIP Lookup( ' . $ip . ' )'); |
|
659 | 659 | } |
660 | - } else if ( self::geoip2_country_dbfile() && ( $ip_country_service === 'geoip2' || $is_default ) ) { |
|
661 | - $wpinv_ip_address_country = self::geoip2_country_code( $ip ); |
|
662 | - } else if ( function_exists( 'simplexml_load_file' ) && ( $ip_country_service === 'geoplugin' || $is_default ) ) { |
|
663 | - $load_xml = simplexml_load_file( 'http://www.geoplugin.net/xml.gp?ip=' . $ip ); |
|
660 | + } else if (self::geoip2_country_dbfile() && ($ip_country_service === 'geoip2' || $is_default)) { |
|
661 | + $wpinv_ip_address_country = self::geoip2_country_code($ip); |
|
662 | + } else if (function_exists('simplexml_load_file') && ($ip_country_service === 'geoplugin' || $is_default)) { |
|
663 | + $load_xml = simplexml_load_file('http://www.geoplugin.net/xml.gp?ip=' . $ip); |
|
664 | 664 | |
665 | - if ( !empty( $load_xml ) && !empty( $load_xml->geoplugin_countryCode ) ) { |
|
665 | + if (!empty($load_xml) && !empty($load_xml->geoplugin_countryCode)) { |
|
666 | 666 | $wpinv_ip_address_country = (string)$load_xml->geoplugin_countryCode; |
667 | 667 | } |
668 | 668 | } |
669 | 669 | } |
670 | 670 | |
671 | - if ( empty( $wpinv_ip_address_country ) ) { |
|
671 | + if (empty($wpinv_ip_address_country)) { |
|
672 | 672 | $wpinv_ip_address_country = wpinv_get_default_country(); |
673 | 673 | } |
674 | 674 | |
675 | 675 | return $wpinv_ip_address_country; |
676 | 676 | } |
677 | 677 | |
678 | - public static function sanitize_vat_settings( $input ) { |
|
678 | + public static function sanitize_vat_settings($input) { |
|
679 | 679 | global $wpinv_options; |
680 | 680 | |
681 | 681 | $valid = false; |
682 | 682 | $message = ''; |
683 | 683 | |
684 | - if ( !empty( $wpinv_options['vat_vies_check'] ) ) { |
|
685 | - if ( empty( $wpinv_options['vat_offline_check'] ) ) { |
|
686 | - $valid = self::offline_check( $input['vat_number'] ); |
|
684 | + if (!empty($wpinv_options['vat_vies_check'])) { |
|
685 | + if (empty($wpinv_options['vat_offline_check'])) { |
|
686 | + $valid = self::offline_check($input['vat_number']); |
|
687 | 687 | } else { |
688 | 688 | $valid = true; |
689 | 689 | } |
690 | 690 | |
691 | - $message = $valid ? '' : __( 'VAT number not validated', 'invoicing' ); |
|
691 | + $message = $valid ? '' : __('VAT number not validated', 'invoicing'); |
|
692 | 692 | } else { |
693 | - $result = self::check_vat( $input['vat_number'] ); |
|
693 | + $result = self::check_vat($input['vat_number']); |
|
694 | 694 | |
695 | - if ( empty( $result['valid'] ) ) { |
|
695 | + if (empty($result['valid'])) { |
|
696 | 696 | $valid = false; |
697 | 697 | $message = $result['message']; |
698 | 698 | } else { |
699 | - $valid = ( isset( $result['company'] ) && ( $result['company'] == '---' || ( strcasecmp( trim( $result['company'] ), trim( $input['vat_company_name'] ) ) == 0 ) ) ) || !empty( $wpinv_options['vat_disable_company_name_check'] ); |
|
700 | - $message = $valid ? '' : __( 'The company name associated with the VAT number provided is not the same as the company name provided.', 'invoicing' ); |
|
699 | + $valid = (isset($result['company']) && ($result['company'] == '---' || (strcasecmp(trim($result['company']), trim($input['vat_company_name'])) == 0))) || !empty($wpinv_options['vat_disable_company_name_check']); |
|
700 | + $message = $valid ? '' : __('The company name associated with the VAT number provided is not the same as the company name provided.', 'invoicing'); |
|
701 | 701 | } |
702 | 702 | } |
703 | 703 | |
704 | - if ( $message && self::is_vat_validated() != $valid ) { |
|
705 | - add_settings_error( 'wpinv-notices', '', $message, ( $valid ? 'updated' : 'error' ) ); |
|
704 | + if ($message && self::is_vat_validated() != $valid) { |
|
705 | + add_settings_error('wpinv-notices', '', $message, ($valid ? 'updated' : 'error')); |
|
706 | 706 | } |
707 | 707 | |
708 | 708 | $input['vat_valid'] = $valid; |
709 | 709 | return $input; |
710 | 710 | } |
711 | 711 | |
712 | - public static function sanitize_vat_rates( $input ) { |
|
713 | - if( !current_user_can( 'manage_options' ) ) { |
|
714 | - add_settings_error( 'wpinv-notices', '', __( 'Your account does not have permission to add rate classes.', 'invoicing' ), 'error' ); |
|
712 | + public static function sanitize_vat_rates($input) { |
|
713 | + if (!current_user_can('manage_options')) { |
|
714 | + add_settings_error('wpinv-notices', '', __('Your account does not have permission to add rate classes.', 'invoicing'), 'error'); |
|
715 | 715 | return $input; |
716 | 716 | } |
717 | 717 | |
718 | 718 | $vat_classes = self::get_rate_classes(); |
719 | - $vat_class = !empty( $_REQUEST['wpi_vat_class'] ) && isset( $vat_classes[$_REQUEST['wpi_vat_class']] )? sanitize_text_field( $_REQUEST['wpi_vat_class'] ) : ''; |
|
719 | + $vat_class = !empty($_REQUEST['wpi_vat_class']) && isset($vat_classes[$_REQUEST['wpi_vat_class']]) ? sanitize_text_field($_REQUEST['wpi_vat_class']) : ''; |
|
720 | 720 | |
721 | - if ( empty( $vat_class ) ) { |
|
722 | - add_settings_error( 'wpinv-notices', '', __( 'No valid VAT rates class contained in the request to save rates.', 'invoicing' ), 'error' ); |
|
721 | + if (empty($vat_class)) { |
|
722 | + add_settings_error('wpinv-notices', '', __('No valid VAT rates class contained in the request to save rates.', 'invoicing'), 'error'); |
|
723 | 723 | |
724 | 724 | return $input; |
725 | 725 | } |
726 | 726 | |
727 | - $new_rates = ! empty( $_POST['vat_rates'] ) ? array_values( $_POST['vat_rates'] ) : array(); |
|
727 | + $new_rates = !empty($_POST['vat_rates']) ? array_values($_POST['vat_rates']) : array(); |
|
728 | 728 | |
729 | - if ( $vat_class === '_standard' ) { |
|
729 | + if ($vat_class === '_standard') { |
|
730 | 730 | // Save the active rates in the invoice settings |
731 | - update_option( 'wpinv_tax_rates', $new_rates ); |
|
731 | + update_option('wpinv_tax_rates', $new_rates); |
|
732 | 732 | } else { |
733 | 733 | // Get the existing set of rates |
734 | 734 | $rates = self::get_non_standard_rates(); |
735 | 735 | $rates[$vat_class] = $new_rates; |
736 | 736 | |
737 | - update_option( 'wpinv_vat_rates', $rates ); |
|
737 | + update_option('wpinv_vat_rates', $rates); |
|
738 | 738 | } |
739 | 739 | |
740 | 740 | return $input; |
@@ -744,71 +744,71 @@ discard block |
||
744 | 744 | $response = array(); |
745 | 745 | $response['success'] = false; |
746 | 746 | |
747 | - if ( !current_user_can( 'manage_options' ) ) { |
|
748 | - $response['error'] = __( 'Invalid access!', 'invoicing' ); |
|
749 | - wp_send_json( $response ); |
|
747 | + if (!current_user_can('manage_options')) { |
|
748 | + $response['error'] = __('Invalid access!', 'invoicing'); |
|
749 | + wp_send_json($response); |
|
750 | 750 | } |
751 | 751 | |
752 | - $vat_class_name = !empty( $_POST['name'] ) ? sanitize_text_field( $_POST['name'] ) : false; |
|
753 | - $vat_class_desc = !empty( $_POST['desc'] ) ? sanitize_text_field( $_POST['desc'] ) : false; |
|
752 | + $vat_class_name = !empty($_POST['name']) ? sanitize_text_field($_POST['name']) : false; |
|
753 | + $vat_class_desc = !empty($_POST['desc']) ? sanitize_text_field($_POST['desc']) : false; |
|
754 | 754 | |
755 | - if ( empty( $vat_class_name ) ) { |
|
756 | - $response['error'] = __( 'Select the VAT rate name', 'invoicing' ); |
|
757 | - wp_send_json( $response ); |
|
755 | + if (empty($vat_class_name)) { |
|
756 | + $response['error'] = __('Select the VAT rate name', 'invoicing'); |
|
757 | + wp_send_json($response); |
|
758 | 758 | } |
759 | 759 | |
760 | 760 | $vat_classes = (array)self::get_rate_classes(); |
761 | 761 | |
762 | - if ( !empty( $vat_classes ) && in_array( strtolower( $vat_class_name ), array_map( 'strtolower', array_values( $vat_classes ) ) ) ) { |
|
763 | - $response['error'] = wp_sprintf( __( 'A VAT Rate name "%s" already exists', 'invoicing' ), $vat_class_name ); |
|
764 | - wp_send_json( $response ); |
|
762 | + if (!empty($vat_classes) && in_array(strtolower($vat_class_name), array_map('strtolower', array_values($vat_classes)))) { |
|
763 | + $response['error'] = wp_sprintf(__('A VAT Rate name "%s" already exists', 'invoicing'), $vat_class_name); |
|
764 | + wp_send_json($response); |
|
765 | 765 | } |
766 | 766 | |
767 | - $rate_class_key = normalize_whitespace( 'wpi-' . $vat_class_name ); |
|
768 | - $rate_class_key = sanitize_key( str_replace( " ", "-", $rate_class_key ) ); |
|
767 | + $rate_class_key = normalize_whitespace('wpi-' . $vat_class_name); |
|
768 | + $rate_class_key = sanitize_key(str_replace(" ", "-", $rate_class_key)); |
|
769 | 769 | |
770 | - $vat_classes = (array)self::get_rate_classes( true ); |
|
771 | - $vat_classes[$rate_class_key] = array( 'name' => $vat_class_name, 'desc' => $vat_class_desc ); |
|
770 | + $vat_classes = (array)self::get_rate_classes(true); |
|
771 | + $vat_classes[$rate_class_key] = array('name' => $vat_class_name, 'desc' => $vat_class_desc); |
|
772 | 772 | |
773 | - update_option( '_wpinv_vat_rate_classes', $vat_classes ); |
|
773 | + update_option('_wpinv_vat_rate_classes', $vat_classes); |
|
774 | 774 | |
775 | 775 | $response['success'] = true; |
776 | - $response['redirect'] = admin_url( 'admin.php?page=wpinv-settings&tab=taxes§ion=vat_rates&wpi_sub=' . $rate_class_key ); |
|
776 | + $response['redirect'] = admin_url('admin.php?page=wpinv-settings&tab=taxes§ion=vat_rates&wpi_sub=' . $rate_class_key); |
|
777 | 777 | |
778 | - wp_send_json( $response ); |
|
778 | + wp_send_json($response); |
|
779 | 779 | } |
780 | 780 | |
781 | 781 | public static function delete_class() { |
782 | 782 | $response = array(); |
783 | 783 | $response['success'] = false; |
784 | 784 | |
785 | - if ( !current_user_can( 'manage_options' ) || !isset( $_POST['class'] ) ) { |
|
786 | - $response['error'] = __( 'Invalid access!', 'invoicing' ); |
|
787 | - wp_send_json( $response ); |
|
785 | + if (!current_user_can('manage_options') || !isset($_POST['class'])) { |
|
786 | + $response['error'] = __('Invalid access!', 'invoicing'); |
|
787 | + wp_send_json($response); |
|
788 | 788 | } |
789 | 789 | |
790 | - $vat_class = isset( $_POST['class'] ) && $_POST['class'] !== '' ? sanitize_text_field( $_POST['class'] ) : false; |
|
790 | + $vat_class = isset($_POST['class']) && $_POST['class'] !== '' ? sanitize_text_field($_POST['class']) : false; |
|
791 | 791 | $vat_classes = (array)self::get_rate_classes(); |
792 | 792 | |
793 | - if ( !isset( $vat_classes[$vat_class] ) ) { |
|
794 | - $response['error'] = __( 'Requested class does not exists', 'invoicing' ); |
|
795 | - wp_send_json( $response ); |
|
793 | + if (!isset($vat_classes[$vat_class])) { |
|
794 | + $response['error'] = __('Requested class does not exists', 'invoicing'); |
|
795 | + wp_send_json($response); |
|
796 | 796 | } |
797 | 797 | |
798 | - if ( $vat_class == '_new' || $vat_class == '_standard' ) { |
|
799 | - $response['error'] = __( 'You can not delete standard rates class', 'invoicing' ); |
|
800 | - wp_send_json( $response ); |
|
798 | + if ($vat_class == '_new' || $vat_class == '_standard') { |
|
799 | + $response['error'] = __('You can not delete standard rates class', 'invoicing'); |
|
800 | + wp_send_json($response); |
|
801 | 801 | } |
802 | 802 | |
803 | - $vat_classes = (array)self::get_rate_classes( true ); |
|
804 | - unset( $vat_classes[$vat_class] ); |
|
803 | + $vat_classes = (array)self::get_rate_classes(true); |
|
804 | + unset($vat_classes[$vat_class]); |
|
805 | 805 | |
806 | - update_option( '_wpinv_vat_rate_classes', $vat_classes ); |
|
806 | + update_option('_wpinv_vat_rate_classes', $vat_classes); |
|
807 | 807 | |
808 | 808 | $response['success'] = true; |
809 | - $response['redirect'] = admin_url( 'admin.php?page=wpinv-settings&tab=taxes§ion=vat_rates&wpi_sub=_new' ); |
|
809 | + $response['redirect'] = admin_url('admin.php?page=wpinv-settings&tab=taxes§ion=vat_rates&wpi_sub=_new'); |
|
810 | 810 | |
811 | - wp_send_json( $response ); |
|
811 | + wp_send_json($response); |
|
812 | 812 | } |
813 | 813 | |
814 | 814 | public static function update_eu_rates() { |
@@ -817,72 +817,72 @@ discard block |
||
817 | 817 | $response['error'] = null; |
818 | 818 | $response['data'] = null; |
819 | 819 | |
820 | - if ( !current_user_can( 'manage_options' ) ) { |
|
821 | - $response['error'] = __( 'Invalid access!', 'invoicing' ); |
|
822 | - wp_send_json( $response ); |
|
820 | + if (!current_user_can('manage_options')) { |
|
821 | + $response['error'] = __('Invalid access!', 'invoicing'); |
|
822 | + wp_send_json($response); |
|
823 | 823 | } |
824 | 824 | |
825 | - $group = !empty( $_POST['group'] ) ? sanitize_text_field( $_POST['group'] ) : ''; |
|
826 | - $euvatrates = self::request_euvatrates( $group ); |
|
825 | + $group = !empty($_POST['group']) ? sanitize_text_field($_POST['group']) : ''; |
|
826 | + $euvatrates = self::request_euvatrates($group); |
|
827 | 827 | |
828 | - if ( !empty( $euvatrates ) ) { |
|
829 | - if ( !empty( $euvatrates['success'] ) && !empty( $euvatrates['rates'] ) ) { |
|
828 | + if (!empty($euvatrates)) { |
|
829 | + if (!empty($euvatrates['success']) && !empty($euvatrates['rates'])) { |
|
830 | 830 | $response['success'] = true; |
831 | 831 | $response['data']['rates'] = $euvatrates['rates']; |
832 | - } else if ( !empty( $euvatrates['error'] ) ) { |
|
832 | + } else if (!empty($euvatrates['error'])) { |
|
833 | 833 | $response['error'] = $euvatrates['error']; |
834 | 834 | } |
835 | 835 | } |
836 | 836 | |
837 | - wp_send_json( $response ); |
|
837 | + wp_send_json($response); |
|
838 | 838 | } |
839 | 839 | |
840 | 840 | public static function hide_vat_fields() { |
841 | - $hide = wpinv_get_option( 'vat_disable_fields' ); |
|
841 | + $hide = wpinv_get_option('vat_disable_fields'); |
|
842 | 842 | |
843 | - return apply_filters( 'wpinv_hide_vat_fields', $hide ); |
|
843 | + return apply_filters('wpinv_hide_vat_fields', $hide); |
|
844 | 844 | } |
845 | 845 | |
846 | 846 | public static function same_country_rule() { |
847 | - $same_country_rule = wpinv_get_option( 'vat_same_country_rule' ); |
|
847 | + $same_country_rule = wpinv_get_option('vat_same_country_rule'); |
|
848 | 848 | |
849 | - return apply_filters( 'wpinv_vat_same_country_rule', $same_country_rule ); |
|
849 | + return apply_filters('wpinv_vat_same_country_rule', $same_country_rule); |
|
850 | 850 | } |
851 | 851 | |
852 | 852 | public static function get_vat_name() { |
853 | - $vat_name = wpinv_get_option( 'vat_name' ); |
|
854 | - $vat_name = !empty( $vat_name ) ? $vat_name : 'VAT'; |
|
853 | + $vat_name = wpinv_get_option('vat_name'); |
|
854 | + $vat_name = !empty($vat_name) ? $vat_name : 'VAT'; |
|
855 | 855 | |
856 | - return apply_filters( 'wpinv_get_owner_vat_name', $vat_name ); |
|
856 | + return apply_filters('wpinv_get_owner_vat_name', $vat_name); |
|
857 | 857 | } |
858 | 858 | |
859 | 859 | public static function get_company_name() { |
860 | - $company_name = wpinv_get_option( 'vat_company_name' ); |
|
860 | + $company_name = wpinv_get_option('vat_company_name'); |
|
861 | 861 | |
862 | - return apply_filters( 'wpinv_get_owner_company_name', $company_name ); |
|
862 | + return apply_filters('wpinv_get_owner_company_name', $company_name); |
|
863 | 863 | } |
864 | 864 | |
865 | 865 | public static function get_vat_number() { |
866 | - $vat_number = wpinv_get_option( 'vat_number' ); |
|
866 | + $vat_number = wpinv_get_option('vat_number'); |
|
867 | 867 | |
868 | - return apply_filters( 'wpinv_get_owner_vat_number', $vat_number ); |
|
868 | + return apply_filters('wpinv_get_owner_vat_number', $vat_number); |
|
869 | 869 | } |
870 | 870 | |
871 | 871 | public static function is_vat_validated() { |
872 | - $validated = self::get_vat_number() && wpinv_get_option( 'vat_valid' ); |
|
872 | + $validated = self::get_vat_number() && wpinv_get_option('vat_valid'); |
|
873 | 873 | |
874 | - return apply_filters( 'wpinv_is_owner_vat_validated', $validated ); |
|
874 | + return apply_filters('wpinv_is_owner_vat_validated', $validated); |
|
875 | 875 | } |
876 | 876 | |
877 | - public static function sanitize_vat( $vat_number, $country_code = '' ) { |
|
878 | - $vat_number = str_replace( array(' ', '.', '-', '_', ',' ), '', strtoupper( trim( $vat_number ) ) ); |
|
877 | + public static function sanitize_vat($vat_number, $country_code = '') { |
|
878 | + $vat_number = str_replace(array(' ', '.', '-', '_', ','), '', strtoupper(trim($vat_number))); |
|
879 | 879 | |
880 | - if ( empty( $country_code ) ) { |
|
881 | - $country_code = substr( $vat_number, 0, 2 ); |
|
880 | + if (empty($country_code)) { |
|
881 | + $country_code = substr($vat_number, 0, 2); |
|
882 | 882 | } |
883 | 883 | |
884 | - if ( strpos( $vat_number , $country_code ) === 0 ) { |
|
885 | - $vat = str_replace( $country_code, '', $vat_number ); |
|
884 | + if (strpos($vat_number, $country_code) === 0) { |
|
885 | + $vat = str_replace($country_code, '', $vat_number); |
|
886 | 886 | } else { |
887 | 887 | $vat = $country_code . $vat_number; |
888 | 888 | } |
@@ -895,140 +895,140 @@ discard block |
||
895 | 895 | return $return; |
896 | 896 | } |
897 | 897 | |
898 | - public static function offline_check( $vat_number, $country_code = '', $formatted = false ) { |
|
899 | - $vat = self::sanitize_vat( $vat_number, $country_code ); |
|
898 | + public static function offline_check($vat_number, $country_code = '', $formatted = false) { |
|
899 | + $vat = self::sanitize_vat($vat_number, $country_code); |
|
900 | 900 | $vat_number = $vat['vat_number']; |
901 | 901 | $country_code = $vat['iso']; |
902 | 902 | $regex = array(); |
903 | 903 | |
904 | - switch ( $country_code ) { |
|
904 | + switch ($country_code) { |
|
905 | 905 | case 'AT': |
906 | - $regex[] = '/^(AT)U(\d{8})$/'; // Austria |
|
906 | + $regex[] = '/^(AT)U(\d{8})$/'; // Austria |
|
907 | 907 | break; |
908 | 908 | case 'BE': |
909 | - $regex[] = '/^(BE)(0?\d{9})$/'; // Belgium |
|
909 | + $regex[] = '/^(BE)(0?\d{9})$/'; // Belgium |
|
910 | 910 | break; |
911 | 911 | case 'BG': |
912 | - $regex[] = '/^(BG)(\d{9,10})$/'; // Bulgaria |
|
912 | + $regex[] = '/^(BG)(\d{9,10})$/'; // Bulgaria |
|
913 | 913 | break; |
914 | 914 | case 'CH': |
915 | 915 | case 'CHE': |
916 | - $regex[] = '/^(CHE)(\d{9})MWST$/'; // Switzerland (Not EU) |
|
916 | + $regex[] = '/^(CHE)(\d{9})MWST$/'; // Switzerland (Not EU) |
|
917 | 917 | break; |
918 | 918 | case 'CY': |
919 | - $regex[] = '/^(CY)([0-5|9]\d{7}[A-Z])$/'; // Cyprus |
|
919 | + $regex[] = '/^(CY)([0-5|9]\d{7}[A-Z])$/'; // Cyprus |
|
920 | 920 | break; |
921 | 921 | case 'CZ': |
922 | - $regex[] = '/^(CZ)(\d{8,13})$/'; // Czech Republic |
|
922 | + $regex[] = '/^(CZ)(\d{8,13})$/'; // Czech Republic |
|
923 | 923 | break; |
924 | 924 | case 'DE': |
925 | - $regex[] = '/^(DE)([1-9]\d{8})$/'; // Germany |
|
925 | + $regex[] = '/^(DE)([1-9]\d{8})$/'; // Germany |
|
926 | 926 | break; |
927 | 927 | case 'DK': |
928 | - $regex[] = '/^(DK)(\d{8})$/'; // Denmark |
|
928 | + $regex[] = '/^(DK)(\d{8})$/'; // Denmark |
|
929 | 929 | break; |
930 | 930 | case 'EE': |
931 | - $regex[] = '/^(EE)(10\d{7})$/'; // Estonia |
|
931 | + $regex[] = '/^(EE)(10\d{7})$/'; // Estonia |
|
932 | 932 | break; |
933 | 933 | case 'EL': |
934 | - $regex[] = '/^(EL)(\d{9})$/'; // Greece |
|
934 | + $regex[] = '/^(EL)(\d{9})$/'; // Greece |
|
935 | 935 | break; |
936 | 936 | case 'ES': |
937 | - $regex[] = '/^(ES)([A-Z]\d{8})$/'; // Spain (National juridical entities) |
|
938 | - $regex[] = '/^(ES)([A-H|N-S|W]\d{7}[A-J])$/'; // Spain (Other juridical entities) |
|
939 | - $regex[] = '/^(ES)([0-9|Y|Z]\d{7}[A-Z])$/'; // Spain (Personal entities type 1) |
|
940 | - $regex[] = '/^(ES)([K|L|M|X]\d{7}[A-Z])$/'; // Spain (Personal entities type 2) |
|
937 | + $regex[] = '/^(ES)([A-Z]\d{8})$/'; // Spain (National juridical entities) |
|
938 | + $regex[] = '/^(ES)([A-H|N-S|W]\d{7}[A-J])$/'; // Spain (Other juridical entities) |
|
939 | + $regex[] = '/^(ES)([0-9|Y|Z]\d{7}[A-Z])$/'; // Spain (Personal entities type 1) |
|
940 | + $regex[] = '/^(ES)([K|L|M|X]\d{7}[A-Z])$/'; // Spain (Personal entities type 2) |
|
941 | 941 | break; |
942 | 942 | case 'EU': |
943 | - $regex[] = '/^(EU)(\d{9})$/'; // EU-type |
|
943 | + $regex[] = '/^(EU)(\d{9})$/'; // EU-type |
|
944 | 944 | break; |
945 | 945 | case 'FI': |
946 | - $regex[] = '/^(FI)(\d{8})$/'; // Finland |
|
946 | + $regex[] = '/^(FI)(\d{8})$/'; // Finland |
|
947 | 947 | break; |
948 | 948 | case 'FR': |
949 | - $regex[] = '/^(FR)(\d{11})$/'; // France (1) |
|
950 | - $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)](\d{10})$/'; // France (2) |
|
951 | - $regex[] = '/^(FR)\d[(A-H)|(J-N)|(P-Z)](\d{9})$/'; // France (3) |
|
952 | - $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)]{2}(\d{9})$/'; // France (4) |
|
949 | + $regex[] = '/^(FR)(\d{11})$/'; // France (1) |
|
950 | + $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)](\d{10})$/'; // France (2) |
|
951 | + $regex[] = '/^(FR)\d[(A-H)|(J-N)|(P-Z)](\d{9})$/'; // France (3) |
|
952 | + $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)]{2}(\d{9})$/'; // France (4) |
|
953 | 953 | break; |
954 | 954 | case 'GB': |
955 | - $regex[] = '/^(GB)?(\d{9})$/'; // UK (Standard) |
|
956 | - $regex[] = '/^(GB)?(\d{12})$/'; // UK (Branches) |
|
957 | - $regex[] = '/^(GB)?(GD\d{3})$/'; // UK (Government) |
|
958 | - $regex[] = '/^(GB)?(HA\d{3})$/'; // UK (Health authority) |
|
955 | + $regex[] = '/^(GB)?(\d{9})$/'; // UK (Standard) |
|
956 | + $regex[] = '/^(GB)?(\d{12})$/'; // UK (Branches) |
|
957 | + $regex[] = '/^(GB)?(GD\d{3})$/'; // UK (Government) |
|
958 | + $regex[] = '/^(GB)?(HA\d{3})$/'; // UK (Health authority) |
|
959 | 959 | break; |
960 | 960 | case 'GR': |
961 | - $regex[] = '/^(GR)(\d{8,9})$/'; // Greece |
|
961 | + $regex[] = '/^(GR)(\d{8,9})$/'; // Greece |
|
962 | 962 | break; |
963 | 963 | case 'HR': |
964 | - $regex[] = '/^(HR)(\d{11})$/'; // Croatia |
|
964 | + $regex[] = '/^(HR)(\d{11})$/'; // Croatia |
|
965 | 965 | break; |
966 | 966 | case 'HU': |
967 | - $regex[] = '/^(HU)(\d{8})$/'; // Hungary |
|
967 | + $regex[] = '/^(HU)(\d{8})$/'; // Hungary |
|
968 | 968 | break; |
969 | 969 | case 'IE': |
970 | - $regex[] = '/^(IE)(\d{7}[A-W])$/'; // Ireland (1) |
|
971 | - $regex[] = '/^(IE)([7-9][A-Z\*\+)]\d{5}[A-W])$/'; // Ireland (2) |
|
972 | - $regex[] = '/^(IE)(\d{7}[A-Z][AH])$/'; // Ireland (3) (new format from 1 Jan 2013) |
|
970 | + $regex[] = '/^(IE)(\d{7}[A-W])$/'; // Ireland (1) |
|
971 | + $regex[] = '/^(IE)([7-9][A-Z\*\+)]\d{5}[A-W])$/'; // Ireland (2) |
|
972 | + $regex[] = '/^(IE)(\d{7}[A-Z][AH])$/'; // Ireland (3) (new format from 1 Jan 2013) |
|
973 | 973 | break; |
974 | 974 | case 'IT': |
975 | - $regex[] = '/^(IT)(\d{11})$/'; // Italy |
|
975 | + $regex[] = '/^(IT)(\d{11})$/'; // Italy |
|
976 | 976 | break; |
977 | 977 | case 'LV': |
978 | - $regex[] = '/^(LV)(\d{11})$/'; // Latvia |
|
978 | + $regex[] = '/^(LV)(\d{11})$/'; // Latvia |
|
979 | 979 | break; |
980 | 980 | case 'LT': |
981 | - $regex[] = '/^(LT)(\d{9}|\d{12})$/'; // Lithuania |
|
981 | + $regex[] = '/^(LT)(\d{9}|\d{12})$/'; // Lithuania |
|
982 | 982 | break; |
983 | 983 | case 'LU': |
984 | - $regex[] = '/^(LU)(\d{8})$/'; // Luxembourg |
|
984 | + $regex[] = '/^(LU)(\d{8})$/'; // Luxembourg |
|
985 | 985 | break; |
986 | 986 | case 'MT': |
987 | - $regex[] = '/^(MT)([1-9]\d{7})$/'; // Malta |
|
987 | + $regex[] = '/^(MT)([1-9]\d{7})$/'; // Malta |
|
988 | 988 | break; |
989 | 989 | case 'NL': |
990 | - $regex[] = '/^(NL)(\d{9})B\d{2}$/'; // Netherlands |
|
990 | + $regex[] = '/^(NL)(\d{9})B\d{2}$/'; // Netherlands |
|
991 | 991 | break; |
992 | 992 | case 'NO': |
993 | - $regex[] = '/^(NO)(\d{9})$/'; // Norway (Not EU) |
|
993 | + $regex[] = '/^(NO)(\d{9})$/'; // Norway (Not EU) |
|
994 | 994 | break; |
995 | 995 | case 'PL': |
996 | - $regex[] = '/^(PL)(\d{10})$/'; // Poland |
|
996 | + $regex[] = '/^(PL)(\d{10})$/'; // Poland |
|
997 | 997 | break; |
998 | 998 | case 'PT': |
999 | - $regex[] = '/^(PT)(\d{9})$/'; // Portugal |
|
999 | + $regex[] = '/^(PT)(\d{9})$/'; // Portugal |
|
1000 | 1000 | break; |
1001 | 1001 | case 'RO': |
1002 | - $regex[] = '/^(RO)([1-9]\d{1,9})$/'; // Romania |
|
1002 | + $regex[] = '/^(RO)([1-9]\d{1,9})$/'; // Romania |
|
1003 | 1003 | break; |
1004 | 1004 | case 'RS': |
1005 | - $regex[] = '/^(RS)(\d{9})$/'; // Serbia (Not EU) |
|
1005 | + $regex[] = '/^(RS)(\d{9})$/'; // Serbia (Not EU) |
|
1006 | 1006 | break; |
1007 | 1007 | case 'SI': |
1008 | - $regex[] = '/^(SI)([1-9]\d{7})$/'; // Slovenia |
|
1008 | + $regex[] = '/^(SI)([1-9]\d{7})$/'; // Slovenia |
|
1009 | 1009 | break; |
1010 | 1010 | case 'SK': |
1011 | - $regex[] = '/^(SK)([1-9]\d[(2-4)|(6-9)]\d{7})$/'; // Slovakia Republic |
|
1011 | + $regex[] = '/^(SK)([1-9]\d[(2-4)|(6-9)]\d{7})$/'; // Slovakia Republic |
|
1012 | 1012 | break; |
1013 | 1013 | case 'SE': |
1014 | - $regex[] = '/^(SE)(\d{10}01)$/'; // Sweden |
|
1014 | + $regex[] = '/^(SE)(\d{10}01)$/'; // Sweden |
|
1015 | 1015 | break; |
1016 | 1016 | default: |
1017 | 1017 | $regex = array(); |
1018 | 1018 | break; |
1019 | 1019 | } |
1020 | 1020 | |
1021 | - if ( empty( $regex ) ) { |
|
1021 | + if (empty($regex)) { |
|
1022 | 1022 | return false; |
1023 | 1023 | } |
1024 | 1024 | |
1025 | - foreach ( $regex as $pattern ) { |
|
1025 | + foreach ($regex as $pattern) { |
|
1026 | 1026 | $matches = null; |
1027 | - preg_match_all( $pattern, $vat_number, $matches ); |
|
1027 | + preg_match_all($pattern, $vat_number, $matches); |
|
1028 | 1028 | |
1029 | - if ( !empty( $matches[1][0] ) && !empty( $matches[2][0] ) ) { |
|
1030 | - if ( $formatted ) { |
|
1031 | - return array( 'code' => $matches[1][0], 'number' => $matches[2][0] ); |
|
1029 | + if (!empty($matches[1][0]) && !empty($matches[2][0])) { |
|
1030 | + if ($formatted) { |
|
1031 | + return array('code' => $matches[1][0], 'number' => $matches[2][0]); |
|
1032 | 1032 | } else { |
1033 | 1033 | return true; |
1034 | 1034 | } |
@@ -1038,75 +1038,75 @@ discard block |
||
1038 | 1038 | return false; |
1039 | 1039 | } |
1040 | 1040 | |
1041 | - public static function vies_check( $vat_number, $country_code = '', $result = false ) { |
|
1042 | - $vat = self::sanitize_vat( $vat_number, $country_code ); |
|
1041 | + public static function vies_check($vat_number, $country_code = '', $result = false) { |
|
1042 | + $vat = self::sanitize_vat($vat_number, $country_code); |
|
1043 | 1043 | $vat_number = $vat['vat']; |
1044 | 1044 | $iso = $vat['iso']; |
1045 | 1045 | |
1046 | - $url = 'http://ec.europa.eu/taxation_customs/vies/viesquer.do?ms=' . urlencode( $iso ) . '&iso=' . urlencode( $iso ) . '&vat=' . urlencode( $vat_number ); |
|
1046 | + $url = 'http://ec.europa.eu/taxation_customs/vies/viesquer.do?ms=' . urlencode($iso) . '&iso=' . urlencode($iso) . '&vat=' . urlencode($vat_number); |
|
1047 | 1047 | |
1048 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
1049 | - $response = file_get_contents( $url ); |
|
1050 | - } else if ( function_exists( 'curl_init' ) ) { |
|
1048 | + if (ini_get('allow_url_fopen')) { |
|
1049 | + $response = file_get_contents($url); |
|
1050 | + } else if (function_exists('curl_init')) { |
|
1051 | 1051 | $ch = curl_init(); |
1052 | 1052 | |
1053 | - curl_setopt( $ch, CURLOPT_URL, $url ); |
|
1054 | - curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 30 ); |
|
1055 | - curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); |
|
1056 | - curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0 ); |
|
1057 | - curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 ); |
|
1053 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
1054 | + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); |
|
1055 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
1056 | + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); |
|
1057 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); |
|
1058 | 1058 | |
1059 | - $response = curl_exec( $ch ); |
|
1059 | + $response = curl_exec($ch); |
|
1060 | 1060 | |
1061 | - if ( curl_errno( $ch ) ) { |
|
1062 | - wpinv_error_log( curl_error( $ch ), 'VIES CHECK ERROR' ); |
|
1061 | + if (curl_errno($ch)) { |
|
1062 | + wpinv_error_log(curl_error($ch), 'VIES CHECK ERROR'); |
|
1063 | 1063 | $response = ''; |
1064 | 1064 | } |
1065 | 1065 | |
1066 | - curl_close( $ch ); |
|
1066 | + curl_close($ch); |
|
1067 | 1067 | } else { |
1068 | - wpinv_error_log( 'To use VIES CHECK you must have allow_url_fopen is ON or cURL installed & active on your server.', 'VIES CHECK ERROR' ); |
|
1068 | + wpinv_error_log('To use VIES CHECK you must have allow_url_fopen is ON or cURL installed & active on your server.', 'VIES CHECK ERROR'); |
|
1069 | 1069 | } |
1070 | 1070 | |
1071 | - if ( empty( $response ) ) { |
|
1071 | + if (empty($response)) { |
|
1072 | 1072 | return $result; |
1073 | 1073 | } |
1074 | 1074 | |
1075 | - if ( preg_match( '/invalid VAT number/i', $response ) ) { |
|
1075 | + if (preg_match('/invalid VAT number/i', $response)) { |
|
1076 | 1076 | return false; |
1077 | - } else if ( preg_match( '/valid VAT number/i', $response, $matches ) ) { |
|
1078 | - $content = explode( "valid VAT number", htmlentities( $response ) ); |
|
1077 | + } else if (preg_match('/valid VAT number/i', $response, $matches)) { |
|
1078 | + $content = explode("valid VAT number", htmlentities($response)); |
|
1079 | 1079 | |
1080 | - if ( !empty( $content[1] ) ) { |
|
1081 | - preg_match_all( '/<tr>(.*?)<td.*?>(.*?)<\/td>(.*?)<\/tr>/si', html_entity_decode( $content[1] ), $matches ); |
|
1080 | + if (!empty($content[1])) { |
|
1081 | + preg_match_all('/<tr>(.*?)<td.*?>(.*?)<\/td>(.*?)<\/tr>/si', html_entity_decode($content[1]), $matches); |
|
1082 | 1082 | |
1083 | - if ( !empty( $matches[2] ) && $matches[3] ) { |
|
1083 | + if (!empty($matches[2]) && $matches[3]) { |
|
1084 | 1084 | $return = array(); |
1085 | 1085 | |
1086 | - foreach ( $matches[2] as $key => $label ) { |
|
1087 | - $label = trim( $label ); |
|
1086 | + foreach ($matches[2] as $key => $label) { |
|
1087 | + $label = trim($label); |
|
1088 | 1088 | |
1089 | - switch ( strtolower( $label ) ) { |
|
1089 | + switch (strtolower($label)) { |
|
1090 | 1090 | case 'member state': |
1091 | - $return['state'] = trim( strip_tags( $matches[3][$key] ) ); |
|
1091 | + $return['state'] = trim(strip_tags($matches[3][$key])); |
|
1092 | 1092 | break; |
1093 | 1093 | case 'vat number': |
1094 | - $return['number'] = trim( strip_tags( $matches[3][$key] ) ); |
|
1094 | + $return['number'] = trim(strip_tags($matches[3][$key])); |
|
1095 | 1095 | break; |
1096 | 1096 | case 'name': |
1097 | - $return['company'] = trim( strip_tags( $matches[3][$key] ) ); |
|
1097 | + $return['company'] = trim(strip_tags($matches[3][$key])); |
|
1098 | 1098 | break; |
1099 | 1099 | case 'address': |
1100 | - $address = str_replace( array( "<br><br>", "<br /><br />", "<br/><br/>" ), "<br>", html_entity_decode( trim( $matches[3][$key] ) ) ); |
|
1101 | - $return['address'] = trim( strip_tags( $address, '<br>' ) ); |
|
1100 | + $address = str_replace(array("<br><br>", "<br /><br />", "<br/><br/>"), "<br>", html_entity_decode(trim($matches[3][$key]))); |
|
1101 | + $return['address'] = trim(strip_tags($address, '<br>')); |
|
1102 | 1102 | break; |
1103 | 1103 | case 'consultation number': |
1104 | - $return['consultation'] = trim( strip_tags( $matches[3][$key] ) ); |
|
1104 | + $return['consultation'] = trim(strip_tags($matches[3][$key])); |
|
1105 | 1105 | break; |
1106 | 1106 | } |
1107 | 1107 | } |
1108 | 1108 | |
1109 | - if ( !empty( $return ) ) { |
|
1109 | + if (!empty($return)) { |
|
1110 | 1110 | return $return; |
1111 | 1111 | } |
1112 | 1112 | } |
@@ -1118,55 +1118,55 @@ discard block |
||
1118 | 1118 | } |
1119 | 1119 | } |
1120 | 1120 | |
1121 | - public static function check_vat( $vat_number, $country_code = '' ) { |
|
1121 | + public static function check_vat($vat_number, $country_code = '') { |
|
1122 | 1122 | $vat_name = self::get_vat_name(); |
1123 | 1123 | |
1124 | 1124 | $return = array(); |
1125 | 1125 | $return['valid'] = false; |
1126 | - $return['message'] = wp_sprintf( __( '%s number not validated', 'invoicing' ), $vat_name ); |
|
1126 | + $return['message'] = wp_sprintf(__('%s number not validated', 'invoicing'), $vat_name); |
|
1127 | 1127 | |
1128 | - if ( !wpinv_get_option( 'vat_offline_check' ) && !self::offline_check( $vat_number, $country_code ) ) { |
|
1128 | + if (!wpinv_get_option('vat_offline_check') && !self::offline_check($vat_number, $country_code)) { |
|
1129 | 1129 | return $return; |
1130 | 1130 | } |
1131 | 1131 | |
1132 | - $response = self::vies_check( $vat_number, $country_code ); |
|
1132 | + $response = self::vies_check($vat_number, $country_code); |
|
1133 | 1133 | |
1134 | - if ( $response ) { |
|
1135 | - $return['valid'] = true; |
|
1134 | + if ($response) { |
|
1135 | + $return['valid'] = true; |
|
1136 | 1136 | |
1137 | - if ( is_array( $response ) ) { |
|
1138 | - $return['company'] = isset( $response['company'] ) ? $response['company'] : ''; |
|
1139 | - $return['address'] = isset( $response['address'] ) ? $response['address'] : ''; |
|
1137 | + if (is_array($response)) { |
|
1138 | + $return['company'] = isset($response['company']) ? $response['company'] : ''; |
|
1139 | + $return['address'] = isset($response['address']) ? $response['address'] : ''; |
|
1140 | 1140 | $return['message'] = $return['company'] . '<br/>' . $return['address']; |
1141 | 1141 | } |
1142 | 1142 | } else { |
1143 | 1143 | $return['valid'] = false; |
1144 | - $return['message'] = wp_sprintf( __( 'Fail to validate the %s number: EU Commission VAT server (VIES) check fails.', 'invoicing' ), $vat_name ); |
|
1144 | + $return['message'] = wp_sprintf(__('Fail to validate the %s number: EU Commission VAT server (VIES) check fails.', 'invoicing'), $vat_name); |
|
1145 | 1145 | } |
1146 | 1146 | |
1147 | 1147 | return $return; |
1148 | 1148 | } |
1149 | 1149 | |
1150 | - public static function request_euvatrates( $group ) { |
|
1150 | + public static function request_euvatrates($group) { |
|
1151 | 1151 | $response = array(); |
1152 | 1152 | $response['success'] = false; |
1153 | 1153 | $response['error'] = null; |
1154 | 1154 | $response['eurates'] = null; |
1155 | 1155 | |
1156 | 1156 | $euvatrates_url = 'https://euvatrates.com/rates.json'; |
1157 | - $euvatrates_url = apply_filters( 'wpinv_euvatrates_url', $euvatrates_url ); |
|
1158 | - $api_response = wp_remote_get( $euvatrates_url ); |
|
1157 | + $euvatrates_url = apply_filters('wpinv_euvatrates_url', $euvatrates_url); |
|
1158 | + $api_response = wp_remote_get($euvatrates_url); |
|
1159 | 1159 | |
1160 | 1160 | try { |
1161 | - if ( is_wp_error( $api_response ) ) { |
|
1162 | - $response['error'] = __( $api_response->get_error_message(), 'invoicing' ); |
|
1161 | + if (is_wp_error($api_response)) { |
|
1162 | + $response['error'] = __($api_response->get_error_message(), 'invoicing'); |
|
1163 | 1163 | } else { |
1164 | - $body = json_decode( $api_response['body'] ); |
|
1164 | + $body = json_decode($api_response['body']); |
|
1165 | 1165 | |
1166 | - if ( isset( $body->rates ) ) { |
|
1166 | + if (isset($body->rates)) { |
|
1167 | 1167 | $rates = array(); |
1168 | 1168 | |
1169 | - foreach ( $body->rates as $country_code => $rate ) { |
|
1169 | + foreach ($body->rates as $country_code => $rate) { |
|
1170 | 1170 | $vat_rate = array(); |
1171 | 1171 | $vat_rate['country'] = $rate->country; |
1172 | 1172 | $vat_rate['standard'] = (float)$rate->standard_rate; |
@@ -1174,7 +1174,7 @@ discard block |
||
1174 | 1174 | $vat_rate['superreduced'] = (float)$rate->super_reduced_rate; |
1175 | 1175 | $vat_rate['parking'] = (float)$rate->parking_rate; |
1176 | 1176 | |
1177 | - if ( $group !== '' && in_array( $group, array( 'standard', 'reduced', 'superreduced', 'parking' ) ) ) { |
|
1177 | + if ($group !== '' && in_array($group, array('standard', 'reduced', 'superreduced', 'parking'))) { |
|
1178 | 1178 | $vat_rate_group = array(); |
1179 | 1179 | $vat_rate_group['country'] = $rate->country; |
1180 | 1180 | $vat_rate_group[$group] = $vat_rate[$group]; |
@@ -1186,79 +1186,79 @@ discard block |
||
1186 | 1186 | } |
1187 | 1187 | |
1188 | 1188 | $response['success'] = true; |
1189 | - $response['rates'] = apply_filters( 'wpinv_process_euvatrates', $rates, $api_response, $group ); |
|
1189 | + $response['rates'] = apply_filters('wpinv_process_euvatrates', $rates, $api_response, $group); |
|
1190 | 1190 | } else { |
1191 | - $response['error'] = __( 'No EU rates found!', 'invoicing' ); |
|
1191 | + $response['error'] = __('No EU rates found!', 'invoicing'); |
|
1192 | 1192 | } |
1193 | 1193 | } |
1194 | - } catch ( Exception $e ) { |
|
1195 | - $response['error'] = __( $e->getMessage(), 'invoicing' ); |
|
1194 | + } catch (Exception $e) { |
|
1195 | + $response['error'] = __($e->getMessage(), 'invoicing'); |
|
1196 | 1196 | } |
1197 | 1197 | |
1198 | - return apply_filters( 'wpinv_response_euvatrates', $response, $group ); |
|
1198 | + return apply_filters('wpinv_response_euvatrates', $response, $group); |
|
1199 | 1199 | } |
1200 | 1200 | |
1201 | - public static function requires_vat( $requires_vat = false, $user_id = 0, $is_digital = null ) { |
|
1201 | + public static function requires_vat($requires_vat = false, $user_id = 0, $is_digital = null) { |
|
1202 | 1202 | global $wpi_item_id, $wpi_country; |
1203 | 1203 | |
1204 | - if ( !empty( $_POST['wpinv_country'] ) ) { |
|
1205 | - $country_code = trim( $_POST['wpinv_country'] ); |
|
1206 | - } else if ( !empty( $_POST['country'] ) ) { |
|
1207 | - $country_code = trim( $_POST['country'] ); |
|
1208 | - } else if ( !empty( $wpi_country ) ) { |
|
1204 | + if (!empty($_POST['wpinv_country'])) { |
|
1205 | + $country_code = trim($_POST['wpinv_country']); |
|
1206 | + } else if (!empty($_POST['country'])) { |
|
1207 | + $country_code = trim($_POST['country']); |
|
1208 | + } else if (!empty($wpi_country)) { |
|
1209 | 1209 | $country_code = $wpi_country; |
1210 | 1210 | } else { |
1211 | - $country_code = self::get_user_country( '', $user_id ); |
|
1211 | + $country_code = self::get_user_country('', $user_id); |
|
1212 | 1212 | } |
1213 | 1213 | |
1214 | - if ( $is_digital === null && $wpi_item_id ) { |
|
1215 | - $is_digital = $wpi_item_id ? self::item_has_digital_rule( $wpi_item_id ) : self::allow_vat_rules(); |
|
1214 | + if ($is_digital === null && $wpi_item_id) { |
|
1215 | + $is_digital = $wpi_item_id ? self::item_has_digital_rule($wpi_item_id) : self::allow_vat_rules(); |
|
1216 | 1216 | } |
1217 | 1217 | |
1218 | - if ( !empty( $country_code ) ) { |
|
1219 | - $requires_vat = ( self::is_eu_state( $country_code ) && ( self::is_eu_state( self::$default_country ) || $is_digital ) ) || ( self::is_gst_country( $country_code ) && self::is_gst_country( self::$default_country ) ); |
|
1218 | + if (!empty($country_code)) { |
|
1219 | + $requires_vat = (self::is_eu_state($country_code) && (self::is_eu_state(self::$default_country) || $is_digital)) || (self::is_gst_country($country_code) && self::is_gst_country(self::$default_country)); |
|
1220 | 1220 | } |
1221 | 1221 | |
1222 | - return apply_filters( 'wpinv_requires_vat', $requires_vat, $user_id ); |
|
1222 | + return apply_filters('wpinv_requires_vat', $requires_vat, $user_id); |
|
1223 | 1223 | } |
1224 | 1224 | |
1225 | - public static function tax_label( $label = '' ) { |
|
1225 | + public static function tax_label($label = '') { |
|
1226 | 1226 | global $wpi_requires_vat; |
1227 | 1227 | |
1228 | - if ( !( $wpi_requires_vat !== 0 && $wpi_requires_vat ) ) { |
|
1229 | - $wpi_requires_vat = self::requires_vat( 0, false ); |
|
1228 | + if (!($wpi_requires_vat !== 0 && $wpi_requires_vat)) { |
|
1229 | + $wpi_requires_vat = self::requires_vat(0, false); |
|
1230 | 1230 | } |
1231 | 1231 | |
1232 | - return $wpi_requires_vat ? __( self::get_vat_name(), 'invoicing' ) : ( $label ? $label : __( 'Tax', 'invoicing' ) ); |
|
1232 | + return $wpi_requires_vat ? __(self::get_vat_name(), 'invoicing') : ($label ? $label : __('Tax', 'invoicing')); |
|
1233 | 1233 | } |
1234 | 1234 | |
1235 | 1235 | public static function standard_rates_label() { |
1236 | - return __( 'Standard Rates', 'invoicing' ); |
|
1236 | + return __('Standard Rates', 'invoicing'); |
|
1237 | 1237 | } |
1238 | 1238 | |
1239 | - public static function get_rate_classes( $with_desc = false ) { |
|
1240 | - $rate_classes_option = get_option( '_wpinv_vat_rate_classes', true ); |
|
1241 | - $classes = maybe_unserialize( $rate_classes_option ); |
|
1239 | + public static function get_rate_classes($with_desc = false) { |
|
1240 | + $rate_classes_option = get_option('_wpinv_vat_rate_classes', true); |
|
1241 | + $classes = maybe_unserialize($rate_classes_option); |
|
1242 | 1242 | |
1243 | - if ( empty( $classes ) || !is_array( $classes ) ) { |
|
1243 | + if (empty($classes) || !is_array($classes)) { |
|
1244 | 1244 | $classes = array(); |
1245 | 1245 | } |
1246 | 1246 | |
1247 | 1247 | $rate_classes = array(); |
1248 | - if ( !array_key_exists( '_standard', $classes ) ) { |
|
1249 | - if ( $with_desc ) { |
|
1250 | - $rate_classes['_standard'] = array( 'name' => self::standard_rates_label(), 'desc' => __( 'EU member states standard VAT rates', 'invoicing' ) ); |
|
1248 | + if (!array_key_exists('_standard', $classes)) { |
|
1249 | + if ($with_desc) { |
|
1250 | + $rate_classes['_standard'] = array('name' => self::standard_rates_label(), 'desc' => __('EU member states standard VAT rates', 'invoicing')); |
|
1251 | 1251 | } else { |
1252 | 1252 | $rate_classes['_standard'] = self::standard_rates_label(); |
1253 | 1253 | } |
1254 | 1254 | } |
1255 | 1255 | |
1256 | - foreach ( $classes as $key => $class ) { |
|
1257 | - $name = !empty( $class['name'] ) ? __( $class['name'], 'invoicing' ) : $key; |
|
1258 | - $desc = !empty( $class['desc'] ) ? __( $class['desc'], 'invoicing' ) : ''; |
|
1256 | + foreach ($classes as $key => $class) { |
|
1257 | + $name = !empty($class['name']) ? __($class['name'], 'invoicing') : $key; |
|
1258 | + $desc = !empty($class['desc']) ? __($class['desc'], 'invoicing') : ''; |
|
1259 | 1259 | |
1260 | - if ( $with_desc ) { |
|
1261 | - $rate_classes[$key] = array( 'name' => $name, 'desc' => $desc ); |
|
1260 | + if ($with_desc) { |
|
1261 | + $rate_classes[$key] = array('name' => $name, 'desc' => $desc); |
|
1262 | 1262 | } else { |
1263 | 1263 | $rate_classes[$key] = $name; |
1264 | 1264 | } |
@@ -1269,15 +1269,15 @@ discard block |
||
1269 | 1269 | |
1270 | 1270 | public static function get_all_classes() { |
1271 | 1271 | $classes = self::get_rate_classes(); |
1272 | - $classes['_exempt'] = __( 'Exempt (0%)', 'invoicing' ); |
|
1272 | + $classes['_exempt'] = __('Exempt (0%)', 'invoicing'); |
|
1273 | 1273 | |
1274 | - return apply_filters( 'wpinv_vat_get_all_classes', $classes ); |
|
1274 | + return apply_filters('wpinv_vat_get_all_classes', $classes); |
|
1275 | 1275 | } |
1276 | 1276 | |
1277 | - public static function get_class_desc( $rate_class ) { |
|
1278 | - $rate_classes = self::get_rate_classes( true ); |
|
1277 | + public static function get_class_desc($rate_class) { |
|
1278 | + $rate_classes = self::get_rate_classes(true); |
|
1279 | 1279 | |
1280 | - if ( !empty( $rate_classes ) && isset( $rate_classes[$rate_class] ) && isset( $rate_classes[$rate_class]['desc'] ) ) { |
|
1280 | + if (!empty($rate_classes) && isset($rate_classes[$rate_class]) && isset($rate_classes[$rate_class]['desc'])) { |
|
1281 | 1281 | return $rate_classes[$rate_class]['desc']; |
1282 | 1282 | } |
1283 | 1283 | |
@@ -1293,106 +1293,106 @@ discard block |
||
1293 | 1293 | 'increased' => 'Increased' |
1294 | 1294 | ); |
1295 | 1295 | |
1296 | - return apply_filters( 'wpinv_get_vat_groups', $vat_groups ); |
|
1296 | + return apply_filters('wpinv_get_vat_groups', $vat_groups); |
|
1297 | 1297 | } |
1298 | 1298 | |
1299 | 1299 | public static function get_rules() { |
1300 | 1300 | $vat_rules = array( |
1301 | - 'digital' => __( 'Digital Product', 'invoicing' ), |
|
1302 | - 'physical' => __( 'Physical Product', 'invoicing' ) |
|
1301 | + 'digital' => __('Digital Product', 'invoicing'), |
|
1302 | + 'physical' => __('Physical Product', 'invoicing') |
|
1303 | 1303 | ); |
1304 | - return apply_filters( 'wpinv_get_vat_rules', $vat_rules ); |
|
1304 | + return apply_filters('wpinv_get_vat_rules', $vat_rules); |
|
1305 | 1305 | } |
1306 | 1306 | |
1307 | - public static function get_vat_rates( $class ) { |
|
1308 | - if ( $class === '_standard' ) { |
|
1307 | + public static function get_vat_rates($class) { |
|
1308 | + if ($class === '_standard') { |
|
1309 | 1309 | return wpinv_get_tax_rates(); |
1310 | 1310 | } |
1311 | 1311 | |
1312 | 1312 | $rates = self::get_non_standard_rates(); |
1313 | 1313 | |
1314 | - return array_key_exists( $class, $rates ) ? $rates[$class] : array(); |
|
1314 | + return array_key_exists($class, $rates) ? $rates[$class] : array(); |
|
1315 | 1315 | } |
1316 | 1316 | |
1317 | 1317 | public static function get_non_standard_rates() { |
1318 | - $option = get_option( 'wpinv_vat_rates', array()); |
|
1319 | - return is_array( $option ) ? $option : array(); |
|
1318 | + $option = get_option('wpinv_vat_rates', array()); |
|
1319 | + return is_array($option) ? $option : array(); |
|
1320 | 1320 | } |
1321 | 1321 | |
1322 | 1322 | public static function allow_vat_rules() { |
1323 | - return ( wpinv_use_taxes() && wpinv_get_option( 'apply_vat_rules' ) ? true : false ); |
|
1323 | + return (wpinv_use_taxes() && wpinv_get_option('apply_vat_rules') ? true : false); |
|
1324 | 1324 | } |
1325 | 1325 | |
1326 | 1326 | public static function allow_vat_classes() { |
1327 | 1327 | return false; // TODO |
1328 | - return ( wpinv_get_option( 'vat_allow_classes' ) ? true : false ); |
|
1328 | + return (wpinv_get_option('vat_allow_classes') ? true : false); |
|
1329 | 1329 | } |
1330 | 1330 | |
1331 | - public static function get_item_class( $postID ) { |
|
1332 | - $class = get_post_meta( $postID, '_wpinv_vat_class', true ); |
|
1331 | + public static function get_item_class($postID) { |
|
1332 | + $class = get_post_meta($postID, '_wpinv_vat_class', true); |
|
1333 | 1333 | |
1334 | - if ( empty( $class ) ) { |
|
1334 | + if (empty($class)) { |
|
1335 | 1335 | $class = '_standard'; |
1336 | 1336 | } |
1337 | 1337 | |
1338 | - return apply_filters( 'wpinv_get_item_vat_class', $class, $postID ); |
|
1338 | + return apply_filters('wpinv_get_item_vat_class', $class, $postID); |
|
1339 | 1339 | } |
1340 | 1340 | |
1341 | - public static function item_class_label( $postID ) { |
|
1341 | + public static function item_class_label($postID) { |
|
1342 | 1342 | $vat_classes = self::get_all_classes(); |
1343 | 1343 | |
1344 | - $class = self::get_item_class( $postID ); |
|
1345 | - $class = isset( $vat_classes[$class] ) ? $vat_classes[$class] : __( $class, 'invoicing' ); |
|
1344 | + $class = self::get_item_class($postID); |
|
1345 | + $class = isset($vat_classes[$class]) ? $vat_classes[$class] : __($class, 'invoicing'); |
|
1346 | 1346 | |
1347 | - return apply_filters( 'wpinv_item_class_label', $class, $postID ); |
|
1347 | + return apply_filters('wpinv_item_class_label', $class, $postID); |
|
1348 | 1348 | } |
1349 | 1349 | |
1350 | - public static function get_item_rule( $postID ) { |
|
1351 | - $rule_type = get_post_meta( $postID, '_wpinv_vat_rule', true ); |
|
1350 | + public static function get_item_rule($postID) { |
|
1351 | + $rule_type = get_post_meta($postID, '_wpinv_vat_rule', true); |
|
1352 | 1352 | |
1353 | - if ( empty( $rule_type ) ) { |
|
1353 | + if (empty($rule_type)) { |
|
1354 | 1354 | $rule_type = self::allow_vat_rules() ? 'digital' : 'physical'; |
1355 | 1355 | } |
1356 | 1356 | |
1357 | - return apply_filters( 'wpinv_item_get_vat_rule', $rule_type, $postID ); |
|
1357 | + return apply_filters('wpinv_item_get_vat_rule', $rule_type, $postID); |
|
1358 | 1358 | } |
1359 | 1359 | |
1360 | - public static function item_rule_label( $postID ) { |
|
1360 | + public static function item_rule_label($postID) { |
|
1361 | 1361 | $vat_rules = self::get_rules(); |
1362 | - $vat_rule = self::get_item_rule( $postID ); |
|
1363 | - $vat_rule = isset( $vat_rules[$vat_rule] ) ? $vat_rules[$vat_rule] : $vat_rule; |
|
1362 | + $vat_rule = self::get_item_rule($postID); |
|
1363 | + $vat_rule = isset($vat_rules[$vat_rule]) ? $vat_rules[$vat_rule] : $vat_rule; |
|
1364 | 1364 | |
1365 | - return apply_filters( 'wpinv_item_rule_label', $vat_rule, $postID ); |
|
1365 | + return apply_filters('wpinv_item_rule_label', $vat_rule, $postID); |
|
1366 | 1366 | } |
1367 | 1367 | |
1368 | - public static function item_has_digital_rule( $item_id = 0 ) { |
|
1369 | - return self::get_item_rule( $item_id ) == 'digital' ? true : false; |
|
1368 | + public static function item_has_digital_rule($item_id = 0) { |
|
1369 | + return self::get_item_rule($item_id) == 'digital' ? true : false; |
|
1370 | 1370 | } |
1371 | 1371 | |
1372 | - public static function invoice_has_digital_rule( $invoice = 0 ) { |
|
1373 | - if ( !self::allow_vat_rules() ) { |
|
1372 | + public static function invoice_has_digital_rule($invoice = 0) { |
|
1373 | + if (!self::allow_vat_rules()) { |
|
1374 | 1374 | return false; |
1375 | 1375 | } |
1376 | 1376 | |
1377 | - if ( empty( $invoice ) ) { |
|
1377 | + if (empty($invoice)) { |
|
1378 | 1378 | return true; |
1379 | 1379 | } |
1380 | 1380 | |
1381 | - if ( is_int( $invoice ) ) { |
|
1382 | - $invoice = new WPInv_Invoice( $invoice ); |
|
1381 | + if (is_int($invoice)) { |
|
1382 | + $invoice = new WPInv_Invoice($invoice); |
|
1383 | 1383 | } |
1384 | 1384 | |
1385 | - if ( !( is_object( $invoice ) && is_a( $invoice, 'WPInv_Invoice' ) ) ) { |
|
1385 | + if (!(is_object($invoice) && is_a($invoice, 'WPInv_Invoice'))) { |
|
1386 | 1386 | return true; |
1387 | 1387 | } |
1388 | 1388 | |
1389 | - $cart_items = $invoice->get_cart_details(); |
|
1389 | + $cart_items = $invoice->get_cart_details(); |
|
1390 | 1390 | |
1391 | - if ( !empty( $cart_items ) ) { |
|
1391 | + if (!empty($cart_items)) { |
|
1392 | 1392 | $has_digital_rule = false; |
1393 | 1393 | |
1394 | - foreach ( $cart_items as $key => $item ) { |
|
1395 | - if ( self::item_has_digital_rule( $item['id'] ) ) { |
|
1394 | + foreach ($cart_items as $key => $item) { |
|
1395 | + if (self::item_has_digital_rule($item['id'])) { |
|
1396 | 1396 | $has_digital_rule = true; |
1397 | 1397 | break; |
1398 | 1398 | } |
@@ -1404,67 +1404,67 @@ discard block |
||
1404 | 1404 | return $has_digital_rule; |
1405 | 1405 | } |
1406 | 1406 | |
1407 | - public static function item_is_taxable( $item_id = 0, $country = false, $state = false ) { |
|
1408 | - if ( !wpinv_use_taxes() ) { |
|
1407 | + public static function item_is_taxable($item_id = 0, $country = false, $state = false) { |
|
1408 | + if (!wpinv_use_taxes()) { |
|
1409 | 1409 | return false; |
1410 | 1410 | } |
1411 | 1411 | |
1412 | 1412 | $is_taxable = true; |
1413 | 1413 | |
1414 | - if ( !empty( $item_id ) && self::get_item_class( $item_id ) == '_exempt' ) { |
|
1414 | + if (!empty($item_id) && self::get_item_class($item_id) == '_exempt') { |
|
1415 | 1415 | $is_taxable = false; |
1416 | 1416 | } |
1417 | 1417 | |
1418 | - return apply_filters( 'wpinv_item_is_taxable', $is_taxable, $item_id, $country , $state ); |
|
1418 | + return apply_filters('wpinv_item_is_taxable', $is_taxable, $item_id, $country, $state); |
|
1419 | 1419 | } |
1420 | 1420 | |
1421 | - public static function find_rate( $country, $state, $rate, $class ) { |
|
1421 | + public static function find_rate($country, $state, $rate, $class) { |
|
1422 | 1422 | global $wpi_zero_tax; |
1423 | 1423 | |
1424 | - if ( $class === '_exempt' || $wpi_zero_tax ) { |
|
1424 | + if ($class === '_exempt' || $wpi_zero_tax) { |
|
1425 | 1425 | return 0; |
1426 | 1426 | } |
1427 | 1427 | |
1428 | - $tax_rates = wpinv_get_tax_rates(); |
|
1428 | + $tax_rates = wpinv_get_tax_rates(); |
|
1429 | 1429 | |
1430 | - if ( $class !== '_standard' ) { |
|
1431 | - $class_rates = self::get_vat_rates( $class ); |
|
1430 | + if ($class !== '_standard') { |
|
1431 | + $class_rates = self::get_vat_rates($class); |
|
1432 | 1432 | |
1433 | - if ( is_array( $class_rates ) ) { |
|
1433 | + if (is_array($class_rates)) { |
|
1434 | 1434 | $indexed_class_rates = array(); |
1435 | 1435 | |
1436 | - foreach ( $class_rates as $key => $cr ) { |
|
1436 | + foreach ($class_rates as $key => $cr) { |
|
1437 | 1437 | $indexed_class_rates[$cr['country']] = $cr; |
1438 | 1438 | } |
1439 | 1439 | |
1440 | - $tax_rates = array_map( function( $tr ) use( $indexed_class_rates ) { |
|
1440 | + $tax_rates = array_map(function($tr) use($indexed_class_rates) { |
|
1441 | 1441 | $tr_country = $tr['country']; |
1442 | - if ( !isset( $indexed_class_rates[$tr_country] ) ) { |
|
1442 | + if (!isset($indexed_class_rates[$tr_country])) { |
|
1443 | 1443 | return $tr; |
1444 | 1444 | } |
1445 | 1445 | $icr = $indexed_class_rates[$tr_country]; |
1446 | - return ( empty( $icr['rate'] ) && $icr['rate'] !== '0' ) ? $tr : $icr; |
|
1446 | + return (empty($icr['rate']) && $icr['rate'] !== '0') ? $tr : $icr; |
|
1447 | 1447 | |
1448 | - }, $tax_rates, $class_rates ); |
|
1448 | + }, $tax_rates, $class_rates); |
|
1449 | 1449 | } |
1450 | 1450 | } |
1451 | 1451 | |
1452 | - if ( !empty( $tax_rates ) ) { |
|
1453 | - foreach ( $tax_rates as $key => $tax_rate ) { |
|
1454 | - if ( $country != $tax_rate['country'] ) |
|
1452 | + if (!empty($tax_rates)) { |
|
1453 | + foreach ($tax_rates as $key => $tax_rate) { |
|
1454 | + if ($country != $tax_rate['country']) |
|
1455 | 1455 | continue; |
1456 | 1456 | |
1457 | - if ( !empty( $tax_rate['global'] ) ) { |
|
1458 | - if ( 0 !== $tax_rate['rate'] || !empty( $tax_rate['rate'] ) ) { |
|
1459 | - $rate = number_format( $tax_rate['rate'], 4 ); |
|
1457 | + if (!empty($tax_rate['global'])) { |
|
1458 | + if (0 !== $tax_rate['rate'] || !empty($tax_rate['rate'])) { |
|
1459 | + $rate = number_format($tax_rate['rate'], 4); |
|
1460 | 1460 | } |
1461 | 1461 | } else { |
1462 | - if ( empty( $tax_rate['state'] ) || strtolower( $state ) != strtolower( $tax_rate['state'] ) ) |
|
1462 | + if (empty($tax_rate['state']) || strtolower($state) != strtolower($tax_rate['state'])) |
|
1463 | 1463 | continue; |
1464 | 1464 | |
1465 | 1465 | $state_rate = $tax_rate['rate']; |
1466 | - if ( 0 !== $state_rate || !empty( $state_rate ) ) { |
|
1467 | - $rate = number_format( $state_rate, 4 ); |
|
1466 | + if (0 !== $state_rate || !empty($state_rate)) { |
|
1467 | + $rate = number_format($state_rate, 4); |
|
1468 | 1468 | } |
1469 | 1469 | } |
1470 | 1470 | } |
@@ -1473,84 +1473,84 @@ discard block |
||
1473 | 1473 | return $rate; |
1474 | 1474 | } |
1475 | 1475 | |
1476 | - public static function get_rate( $rate = 1, $country = '', $state = '', $item_id = 0 ) { |
|
1476 | + public static function get_rate($rate = 1, $country = '', $state = '', $item_id = 0) { |
|
1477 | 1477 | global $wpinv_options, $wpi_session, $wpi_item_id, $wpi_zero_tax; |
1478 | 1478 | |
1479 | 1479 | $item_id = $item_id > 0 ? $item_id : $wpi_item_id; |
1480 | 1480 | $allow_vat_classes = self::allow_vat_classes(); |
1481 | - $class = $item_id ? self::get_item_class( $item_id ) : '_standard'; |
|
1481 | + $class = $item_id ? self::get_item_class($item_id) : '_standard'; |
|
1482 | 1482 | |
1483 | - if ( $class === '_exempt' || $wpi_zero_tax ) { |
|
1483 | + if ($class === '_exempt' || $wpi_zero_tax) { |
|
1484 | 1484 | return 0; |
1485 | - } else if ( !$allow_vat_classes ) { |
|
1485 | + } else if (!$allow_vat_classes) { |
|
1486 | 1486 | $class = '_standard'; |
1487 | 1487 | } |
1488 | 1488 | |
1489 | - if( !empty( $_POST['wpinv_country'] ) ) { |
|
1489 | + if (!empty($_POST['wpinv_country'])) { |
|
1490 | 1490 | $post_country = $_POST['wpinv_country']; |
1491 | - } elseif( !empty( $_POST['wpinv_country'] ) ) { |
|
1491 | + } elseif (!empty($_POST['wpinv_country'])) { |
|
1492 | 1492 | $post_country = $_POST['wpinv_country']; |
1493 | - } elseif( !empty( $_POST['country'] ) ) { |
|
1493 | + } elseif (!empty($_POST['country'])) { |
|
1494 | 1494 | $post_country = $_POST['country']; |
1495 | 1495 | } else { |
1496 | 1496 | $post_country = ''; |
1497 | 1497 | } |
1498 | 1498 | |
1499 | - $country = !empty( $post_country ) ? $post_country : wpinv_default_billing_country( $country ); |
|
1500 | - $base_country = wpinv_is_base_country( $country ); |
|
1499 | + $country = !empty($post_country) ? $post_country : wpinv_default_billing_country($country); |
|
1500 | + $base_country = wpinv_is_base_country($country); |
|
1501 | 1501 | |
1502 | - $requires_vat = self::requires_vat( 0, false ); |
|
1503 | - $is_digital = self::get_item_rule( $item_id ) == 'digital' ; |
|
1504 | - $rate = $requires_vat && isset( $wpinv_options['eu_fallback_rate'] ) ? $wpinv_options['eu_fallback_rate'] : $rate; |
|
1502 | + $requires_vat = self::requires_vat(0, false); |
|
1503 | + $is_digital = self::get_item_rule($item_id) == 'digital'; |
|
1504 | + $rate = $requires_vat && isset($wpinv_options['eu_fallback_rate']) ? $wpinv_options['eu_fallback_rate'] : $rate; |
|
1505 | 1505 | |
1506 | - if ( self::same_country_rule() == 'no' && $base_country ) { // Disable VAT to same country |
|
1506 | + if (self::same_country_rule() == 'no' && $base_country) { // Disable VAT to same country |
|
1507 | 1507 | $rate = 0; |
1508 | - } else if ( $requires_vat ) { |
|
1509 | - $vat_number = self::get_user_vat_number( '', 0, true ); |
|
1508 | + } else if ($requires_vat) { |
|
1509 | + $vat_number = self::get_user_vat_number('', 0, true); |
|
1510 | 1510 | $vat_info = self::current_vat_data(); |
1511 | 1511 | |
1512 | - if ( is_array( $vat_info ) ) { |
|
1513 | - $vat_number = isset( $vat_info['number'] ) && !empty( $vat_info['valid'] ) ? $vat_info['number'] : ""; |
|
1512 | + if (is_array($vat_info)) { |
|
1513 | + $vat_number = isset($vat_info['number']) && !empty($vat_info['valid']) ? $vat_info['number'] : ""; |
|
1514 | 1514 | } |
1515 | 1515 | |
1516 | - if ( $country == 'UK' ) { |
|
1516 | + if ($country == 'UK') { |
|
1517 | 1517 | $country = 'GB'; |
1518 | 1518 | } |
1519 | 1519 | |
1520 | - if ( !empty( $vat_number ) ) { |
|
1520 | + if (!empty($vat_number)) { |
|
1521 | 1521 | $rate = 0; |
1522 | 1522 | } else { |
1523 | - $rate = self::find_rate( $country, $state, $rate, $class ); // Fix if there are no tax rated and you try to pay an invoice it does not add the fallback tax rate |
|
1523 | + $rate = self::find_rate($country, $state, $rate, $class); // Fix if there are no tax rated and you try to pay an invoice it does not add the fallback tax rate |
|
1524 | 1524 | } |
1525 | 1525 | |
1526 | - if ( empty( $vat_number ) && !$is_digital ) { |
|
1527 | - if ( $base_country ) { |
|
1528 | - $rate = self::find_rate( $country, null, $rate, $class ); |
|
1526 | + if (empty($vat_number) && !$is_digital) { |
|
1527 | + if ($base_country) { |
|
1528 | + $rate = self::find_rate($country, null, $rate, $class); |
|
1529 | 1529 | } else { |
1530 | - if ( empty( $country ) && isset( $wpinv_options['eu_fallback_rate'] ) ) { |
|
1530 | + if (empty($country) && isset($wpinv_options['eu_fallback_rate'])) { |
|
1531 | 1531 | $rate = $wpinv_options['eu_fallback_rate']; |
1532 | - } else if( !empty( $country ) ) { |
|
1533 | - $rate = self::find_rate( $country, $state, $rate, $class ); |
|
1532 | + } else if (!empty($country)) { |
|
1533 | + $rate = self::find_rate($country, $state, $rate, $class); |
|
1534 | 1534 | } |
1535 | 1535 | } |
1536 | - } else if ( empty( $vat_number ) || ( self::same_country_rule() == 'always' && $base_country ) ) { |
|
1537 | - if ( empty( $country ) && isset( $wpinv_options['eu_fallback_rate'] ) ) { |
|
1536 | + } else if (empty($vat_number) || (self::same_country_rule() == 'always' && $base_country)) { |
|
1537 | + if (empty($country) && isset($wpinv_options['eu_fallback_rate'])) { |
|
1538 | 1538 | $rate = $wpinv_options['eu_fallback_rate']; |
1539 | - } else if( !empty( $country ) ) { |
|
1540 | - $rate = self::find_rate( $country, $state, $rate, $class ); |
|
1539 | + } else if (!empty($country)) { |
|
1540 | + $rate = self::find_rate($country, $state, $rate, $class); |
|
1541 | 1541 | } |
1542 | 1542 | } |
1543 | 1543 | } else { |
1544 | - if ( $is_digital ) { |
|
1544 | + if ($is_digital) { |
|
1545 | 1545 | $ip_country_code = self::get_country_by_ip(); |
1546 | 1546 | |
1547 | - if ( $ip_country_code && self::is_eu_state( $ip_country_code ) ) { |
|
1548 | - $rate = self::find_rate( $ip_country_code, '', 0, $class ); |
|
1547 | + if ($ip_country_code && self::is_eu_state($ip_country_code)) { |
|
1548 | + $rate = self::find_rate($ip_country_code, '', 0, $class); |
|
1549 | 1549 | } else { |
1550 | - $rate = self::find_rate( $country, $state, $rate, $class ); |
|
1550 | + $rate = self::find_rate($country, $state, $rate, $class); |
|
1551 | 1551 | } |
1552 | 1552 | } else { |
1553 | - $rate = self::find_rate( $country, $state, $rate, $class ); |
|
1553 | + $rate = self::find_rate($country, $state, $rate, $class); |
|
1554 | 1554 | } |
1555 | 1555 | } |
1556 | 1556 | |
@@ -1560,48 +1560,48 @@ discard block |
||
1560 | 1560 | public static function current_vat_data() { |
1561 | 1561 | global $wpi_session; |
1562 | 1562 | |
1563 | - return $wpi_session->get( 'user_vat_data' ); |
|
1563 | + return $wpi_session->get('user_vat_data'); |
|
1564 | 1564 | } |
1565 | 1565 | |
1566 | - public static function get_user_country( $country = '', $user_id = 0 ) { |
|
1567 | - $user_address = wpinv_get_user_address( $user_id, false ); |
|
1566 | + public static function get_user_country($country = '', $user_id = 0) { |
|
1567 | + $user_address = wpinv_get_user_address($user_id, false); |
|
1568 | 1568 | |
1569 | - if ( wpinv_get_option( 'vat_ip_country_default' ) ) { |
|
1569 | + if (wpinv_get_option('vat_ip_country_default')) { |
|
1570 | 1570 | $country = ''; |
1571 | 1571 | } |
1572 | 1572 | |
1573 | - $country = empty( $user_address ) || !isset( $user_address['country'] ) || empty( $user_address['country'] ) ? $country : $user_address['country']; |
|
1574 | - $result = apply_filters( 'wpinv_get_user_country', $country, $user_id ); |
|
1573 | + $country = empty($user_address) || !isset($user_address['country']) || empty($user_address['country']) ? $country : $user_address['country']; |
|
1574 | + $result = apply_filters('wpinv_get_user_country', $country, $user_id); |
|
1575 | 1575 | |
1576 | - if ( empty( $result ) ) { |
|
1576 | + if (empty($result)) { |
|
1577 | 1577 | $result = self::get_country_by_ip(); |
1578 | 1578 | } |
1579 | 1579 | |
1580 | 1580 | return $result; |
1581 | 1581 | } |
1582 | 1582 | |
1583 | - public static function set_user_country( $country = '', $user_id = 0 ) { |
|
1583 | + public static function set_user_country($country = '', $user_id = 0) { |
|
1584 | 1584 | global $wpi_userID; |
1585 | 1585 | |
1586 | - if ( empty($country) && !empty($wpi_userID) && get_current_user_id() != $wpi_userID ) { |
|
1586 | + if (empty($country) && !empty($wpi_userID) && get_current_user_id() != $wpi_userID) { |
|
1587 | 1587 | $country = wpinv_get_default_country(); |
1588 | 1588 | } |
1589 | 1589 | |
1590 | 1590 | return $country; |
1591 | 1591 | } |
1592 | 1592 | |
1593 | - public static function get_user_vat_number( $vat_number = '', $user_id = 0, $is_valid = false ) { |
|
1593 | + public static function get_user_vat_number($vat_number = '', $user_id = 0, $is_valid = false) { |
|
1594 | 1594 | global $wpi_current_id, $wpi_userID; |
1595 | 1595 | |
1596 | - if ( !empty( $_POST['new_user'] ) ) { |
|
1596 | + if (!empty($_POST['new_user'])) { |
|
1597 | 1597 | return ''; |
1598 | 1598 | } |
1599 | 1599 | |
1600 | - if ( empty( $user_id ) ) { |
|
1601 | - $user_id = !empty( $wpi_userID ) ? $wpi_userID : ( $wpi_current_id ? wpinv_get_user_id( $wpi_current_id ) : get_current_user_id() ); |
|
1600 | + if (empty($user_id)) { |
|
1601 | + $user_id = !empty($wpi_userID) ? $wpi_userID : ($wpi_current_id ? wpinv_get_user_id($wpi_current_id) : get_current_user_id()); |
|
1602 | 1602 | } |
1603 | 1603 | |
1604 | - $vat_number = empty( $user_id ) ? '' : get_user_meta( $user_id, '_wpinv_vat_number', true ); |
|
1604 | + $vat_number = empty($user_id) ? '' : get_user_meta($user_id, '_wpinv_vat_number', true); |
|
1605 | 1605 | |
1606 | 1606 | /* TODO |
1607 | 1607 | if ( $is_valid && $vat_number ) { |
@@ -1612,36 +1612,36 @@ discard block |
||
1612 | 1612 | } |
1613 | 1613 | */ |
1614 | 1614 | |
1615 | - return apply_filters('wpinv_get_user_vat_number', $vat_number, $user_id, $is_valid ); |
|
1615 | + return apply_filters('wpinv_get_user_vat_number', $vat_number, $user_id, $is_valid); |
|
1616 | 1616 | } |
1617 | 1617 | |
1618 | - public static function get_user_company( $company = '', $user_id = 0 ) { |
|
1619 | - if ( empty( $user_id ) ) { |
|
1618 | + public static function get_user_company($company = '', $user_id = 0) { |
|
1619 | + if (empty($user_id)) { |
|
1620 | 1620 | $user_id = get_current_user_id(); |
1621 | 1621 | } |
1622 | 1622 | |
1623 | - $company = empty( $user_id ) ? "" : get_user_meta( $user_id, '_wpinv_company', true ); |
|
1623 | + $company = empty($user_id) ? "" : get_user_meta($user_id, '_wpinv_company', true); |
|
1624 | 1624 | |
1625 | - return apply_filters( 'wpinv_user_company', $company, $user_id ); |
|
1625 | + return apply_filters('wpinv_user_company', $company, $user_id); |
|
1626 | 1626 | } |
1627 | 1627 | |
1628 | - public static function save_user_vat_details( $company = '', $vat_number = '' ) { |
|
1629 | - $save = apply_filters( 'wpinv_allow_save_user_vat_details', true ); |
|
1628 | + public static function save_user_vat_details($company = '', $vat_number = '') { |
|
1629 | + $save = apply_filters('wpinv_allow_save_user_vat_details', true); |
|
1630 | 1630 | |
1631 | - if ( is_user_logged_in() && $save ) { |
|
1631 | + if (is_user_logged_in() && $save) { |
|
1632 | 1632 | $user_id = get_current_user_id(); |
1633 | 1633 | |
1634 | - if ( !empty( $vat_number ) ) { |
|
1635 | - update_user_meta( $user_id, '_wpinv_vat_number', $vat_number ); |
|
1634 | + if (!empty($vat_number)) { |
|
1635 | + update_user_meta($user_id, '_wpinv_vat_number', $vat_number); |
|
1636 | 1636 | } else { |
1637 | - delete_user_meta( $user_id, '_wpinv_vat_number'); |
|
1637 | + delete_user_meta($user_id, '_wpinv_vat_number'); |
|
1638 | 1638 | } |
1639 | 1639 | |
1640 | - if ( !empty( $company ) ) { |
|
1641 | - update_user_meta( $user_id, '_wpinv_company', $company ); |
|
1640 | + if (!empty($company)) { |
|
1641 | + update_user_meta($user_id, '_wpinv_company', $company); |
|
1642 | 1642 | } else { |
1643 | - delete_user_meta( $user_id, '_wpinv_company'); |
|
1644 | - delete_user_meta( $user_id, '_wpinv_vat_number'); |
|
1643 | + delete_user_meta($user_id, '_wpinv_company'); |
|
1644 | + delete_user_meta($user_id, '_wpinv_vat_number'); |
|
1645 | 1645 | } |
1646 | 1646 | } |
1647 | 1647 | |
@@ -1651,113 +1651,113 @@ discard block |
||
1651 | 1651 | public static function ajax_vat_validate() { |
1652 | 1652 | global $wpinv_options, $wpi_session; |
1653 | 1653 | |
1654 | - $is_checkout = ( !empty( $_POST['source'] ) && $_POST['source'] == 'checkout' ) ? true : false; |
|
1654 | + $is_checkout = (!empty($_POST['source']) && $_POST['source'] == 'checkout') ? true : false; |
|
1655 | 1655 | $response = array(); |
1656 | 1656 | $response['success'] = false; |
1657 | 1657 | |
1658 | - if ( empty( $_REQUEST['_wpi_nonce'] ) || ( !empty( $_REQUEST['_wpi_nonce'] ) && !wp_verify_nonce( $_REQUEST['_wpi_nonce'], 'vat_validation' ) ) ) { |
|
1659 | - $response['error'] = __( 'Invalid security nonce', 'invoicing' ); |
|
1660 | - wp_send_json( $response ); |
|
1658 | + if (empty($_REQUEST['_wpi_nonce']) || (!empty($_REQUEST['_wpi_nonce']) && !wp_verify_nonce($_REQUEST['_wpi_nonce'], 'vat_validation'))) { |
|
1659 | + $response['error'] = __('Invalid security nonce', 'invoicing'); |
|
1660 | + wp_send_json($response); |
|
1661 | 1661 | } |
1662 | 1662 | |
1663 | - $vat_name = self::get_vat_name(); |
|
1663 | + $vat_name = self::get_vat_name(); |
|
1664 | 1664 | |
1665 | - if ( $is_checkout ) { |
|
1665 | + if ($is_checkout) { |
|
1666 | 1666 | $invoice = wpinv_get_invoice_cart(); |
1667 | 1667 | |
1668 | - if ( !self::requires_vat( false, 0, self::invoice_has_digital_rule( $invoice ) ) ) { |
|
1668 | + if (!self::requires_vat(false, 0, self::invoice_has_digital_rule($invoice))) { |
|
1669 | 1669 | $vat_info = array(); |
1670 | - $wpi_session->set( 'user_vat_data', $vat_info ); |
|
1670 | + $wpi_session->set('user_vat_data', $vat_info); |
|
1671 | 1671 | |
1672 | 1672 | self::save_user_vat_details(); |
1673 | 1673 | |
1674 | 1674 | $response['success'] = true; |
1675 | - $response['message'] = wp_sprintf( __( 'Ignore %s', 'invoicing' ), $vat_name ); |
|
1676 | - wp_send_json( $response ); |
|
1675 | + $response['message'] = wp_sprintf(__('Ignore %s', 'invoicing'), $vat_name); |
|
1676 | + wp_send_json($response); |
|
1677 | 1677 | } |
1678 | 1678 | } |
1679 | 1679 | |
1680 | - $company = !empty( $_POST['company'] ) ? sanitize_text_field( $_POST['company'] ) : ''; |
|
1681 | - $vat_number = !empty( $_POST['number'] ) ? sanitize_text_field( $_POST['number'] ) : ''; |
|
1680 | + $company = !empty($_POST['company']) ? sanitize_text_field($_POST['company']) : ''; |
|
1681 | + $vat_number = !empty($_POST['number']) ? sanitize_text_field($_POST['number']) : ''; |
|
1682 | 1682 | |
1683 | - $vat_info = $wpi_session->get( 'user_vat_data' ); |
|
1684 | - if ( !is_array( $vat_info ) || empty( $vat_info ) ) { |
|
1685 | - $vat_info = array( 'company'=> $company, 'number' => '', 'valid' => true ); |
|
1683 | + $vat_info = $wpi_session->get('user_vat_data'); |
|
1684 | + if (!is_array($vat_info) || empty($vat_info)) { |
|
1685 | + $vat_info = array('company'=> $company, 'number' => '', 'valid' => true); |
|
1686 | 1686 | } |
1687 | 1687 | |
1688 | - if ( empty( $vat_number ) ) { |
|
1689 | - if ( $is_checkout ) { |
|
1688 | + if (empty($vat_number)) { |
|
1689 | + if ($is_checkout) { |
|
1690 | 1690 | $response['success'] = true; |
1691 | - $response['message'] = wp_sprintf( __( 'No %s number has been applied. %s will be added to invoice totals', 'invoicing' ), $vat_name, $vat_name ); |
|
1691 | + $response['message'] = wp_sprintf(__('No %s number has been applied. %s will be added to invoice totals', 'invoicing'), $vat_name, $vat_name); |
|
1692 | 1692 | |
1693 | - $vat_info = $wpi_session->get( 'user_vat_data' ); |
|
1693 | + $vat_info = $wpi_session->get('user_vat_data'); |
|
1694 | 1694 | $vat_info['number'] = ""; |
1695 | 1695 | $vat_info['valid'] = true; |
1696 | 1696 | |
1697 | - self::save_user_vat_details( $company ); |
|
1697 | + self::save_user_vat_details($company); |
|
1698 | 1698 | } else { |
1699 | - $response['error'] = wp_sprintf( __( 'Please enter your %s number!', 'invoicing' ), $vat_name ); |
|
1699 | + $response['error'] = wp_sprintf(__('Please enter your %s number!', 'invoicing'), $vat_name); |
|
1700 | 1700 | |
1701 | 1701 | $vat_info['valid'] = false; |
1702 | 1702 | } |
1703 | 1703 | |
1704 | - $wpi_session->set( 'user_vat_data', $vat_info ); |
|
1705 | - wp_send_json( $response ); |
|
1704 | + $wpi_session->set('user_vat_data', $vat_info); |
|
1705 | + wp_send_json($response); |
|
1706 | 1706 | } |
1707 | 1707 | |
1708 | - if ( empty( $company ) ) { |
|
1708 | + if (empty($company)) { |
|
1709 | 1709 | $vat_info['valid'] = false; |
1710 | - $wpi_session->set( 'user_vat_data', $vat_info ); |
|
1710 | + $wpi_session->set('user_vat_data', $vat_info); |
|
1711 | 1711 | |
1712 | - $response['error'] = __( 'Please enter your registered company name!', 'invoicing' ); |
|
1713 | - wp_send_json( $response ); |
|
1712 | + $response['error'] = __('Please enter your registered company name!', 'invoicing'); |
|
1713 | + wp_send_json($response); |
|
1714 | 1714 | } |
1715 | 1715 | |
1716 | - if ( !empty( $wpinv_options['vat_vies_check'] ) ) { |
|
1717 | - if ( empty( $wpinv_options['vat_offline_check'] ) && !self::offline_check( $vat_number ) ) { |
|
1716 | + if (!empty($wpinv_options['vat_vies_check'])) { |
|
1717 | + if (empty($wpinv_options['vat_offline_check']) && !self::offline_check($vat_number)) { |
|
1718 | 1718 | $vat_info['valid'] = false; |
1719 | - $wpi_session->set( 'user_vat_data', $vat_info ); |
|
1719 | + $wpi_session->set('user_vat_data', $vat_info); |
|
1720 | 1720 | |
1721 | - $response['error'] = wp_sprintf( __( '%s number not validated', 'invoicing' ), $vat_name ); |
|
1722 | - wp_send_json( $response ); |
|
1721 | + $response['error'] = wp_sprintf(__('%s number not validated', 'invoicing'), $vat_name); |
|
1722 | + wp_send_json($response); |
|
1723 | 1723 | } |
1724 | 1724 | |
1725 | 1725 | $response['success'] = true; |
1726 | - $response['message'] = wp_sprintf( __( '%s number validated', 'invoicing' ), $vat_name ); |
|
1726 | + $response['message'] = wp_sprintf(__('%s number validated', 'invoicing'), $vat_name); |
|
1727 | 1727 | } else { |
1728 | - $result = self::check_vat( $vat_number ); |
|
1728 | + $result = self::check_vat($vat_number); |
|
1729 | 1729 | |
1730 | - if ( empty( $result['valid'] ) ) { |
|
1730 | + if (empty($result['valid'])) { |
|
1731 | 1731 | $response['error'] = $result['message']; |
1732 | - wp_send_json( $response ); |
|
1732 | + wp_send_json($response); |
|
1733 | 1733 | } |
1734 | 1734 | |
1735 | - $vies_company = !empty( $result['company'] ) ? $result['company'] : ''; |
|
1736 | - $vies_company = apply_filters( 'wpinv_vies_company_name', $vies_company ); |
|
1735 | + $vies_company = !empty($result['company']) ? $result['company'] : ''; |
|
1736 | + $vies_company = apply_filters('wpinv_vies_company_name', $vies_company); |
|
1737 | 1737 | |
1738 | - $valid_company = $vies_company && $company && ( $vies_company == '---' || strcasecmp( trim( $vies_company ), trim( $company ) ) == 0 ) ? true : false; |
|
1738 | + $valid_company = $vies_company && $company && ($vies_company == '---' || strcasecmp(trim($vies_company), trim($company)) == 0) ? true : false; |
|
1739 | 1739 | |
1740 | - if ( !empty( $wpinv_options['vat_disable_company_name_check'] ) || $valid_company ) { |
|
1740 | + if (!empty($wpinv_options['vat_disable_company_name_check']) || $valid_company) { |
|
1741 | 1741 | $response['success'] = true; |
1742 | - $response['message'] = wp_sprintf( __( '%s number validated', 'invoicing' ), $vat_name ); |
|
1742 | + $response['message'] = wp_sprintf(__('%s number validated', 'invoicing'), $vat_name); |
|
1743 | 1743 | } else { |
1744 | 1744 | $vat_info['valid'] = false; |
1745 | - $wpi_session->set( 'user_vat_data', $vat_info ); |
|
1745 | + $wpi_session->set('user_vat_data', $vat_info); |
|
1746 | 1746 | |
1747 | 1747 | $response['success'] = false; |
1748 | - $response['message'] = wp_sprintf( __( 'The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing' ), $vat_name ); |
|
1749 | - wp_send_json( $response ); |
|
1748 | + $response['message'] = wp_sprintf(__('The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing'), $vat_name); |
|
1749 | + wp_send_json($response); |
|
1750 | 1750 | } |
1751 | 1751 | } |
1752 | 1752 | |
1753 | - if ( $is_checkout ) { |
|
1754 | - self::save_user_vat_details( $company, $vat_number ); |
|
1753 | + if ($is_checkout) { |
|
1754 | + self::save_user_vat_details($company, $vat_number); |
|
1755 | 1755 | |
1756 | - $vat_info = array('company' => $company, 'number' => $vat_number, 'valid' => true ); |
|
1757 | - $wpi_session->set( 'user_vat_data', $vat_info ); |
|
1756 | + $vat_info = array('company' => $company, 'number' => $vat_number, 'valid' => true); |
|
1757 | + $wpi_session->set('user_vat_data', $vat_info); |
|
1758 | 1758 | } |
1759 | 1759 | |
1760 | - wp_send_json( $response ); |
|
1760 | + wp_send_json($response); |
|
1761 | 1761 | } |
1762 | 1762 | |
1763 | 1763 | public static function ajax_vat_reset() { |
@@ -1766,161 +1766,161 @@ discard block |
||
1766 | 1766 | $company = is_user_logged_in() ? self::get_user_company() : ''; |
1767 | 1767 | $vat_number = self::get_user_vat_number(); |
1768 | 1768 | |
1769 | - $vat_info = array('company' => $company, 'number' => $vat_number, 'valid' => false ); |
|
1770 | - $wpi_session->set( 'user_vat_data', $vat_info ); |
|
1769 | + $vat_info = array('company' => $company, 'number' => $vat_number, 'valid' => false); |
|
1770 | + $wpi_session->set('user_vat_data', $vat_info); |
|
1771 | 1771 | |
1772 | 1772 | $response = array(); |
1773 | 1773 | $response['success'] = true; |
1774 | 1774 | $response['data']['company'] = $company; |
1775 | 1775 | $response['data']['number'] = $vat_number; |
1776 | 1776 | |
1777 | - wp_send_json( $response ); |
|
1777 | + wp_send_json($response); |
|
1778 | 1778 | } |
1779 | 1779 | |
1780 | - public static function checkout_vat_validate( $valid_data, $post ) { |
|
1780 | + public static function checkout_vat_validate($valid_data, $post) { |
|
1781 | 1781 | global $wpinv_options, $wpi_session; |
1782 | 1782 | |
1783 | - $vat_name = __( self::get_vat_name(), 'invoicing' ); |
|
1783 | + $vat_name = __(self::get_vat_name(), 'invoicing'); |
|
1784 | 1784 | |
1785 | - if ( !isset( $_POST['_wpi_nonce'] ) || !wp_verify_nonce( $_POST['_wpi_nonce'], 'vat_validation' ) ) { |
|
1786 | - wpinv_set_error( 'vat_validation', wp_sprintf( __( "Invalid %s validation request.", 'invoicing' ), $vat_name ) ); |
|
1785 | + if (!isset($_POST['_wpi_nonce']) || !wp_verify_nonce($_POST['_wpi_nonce'], 'vat_validation')) { |
|
1786 | + wpinv_set_error('vat_validation', wp_sprintf(__("Invalid %s validation request.", 'invoicing'), $vat_name)); |
|
1787 | 1787 | return; |
1788 | 1788 | } |
1789 | 1789 | |
1790 | - $vat_saved = $wpi_session->get( 'user_vat_data' ); |
|
1791 | - $wpi_session->set( 'user_vat_data', null ); |
|
1790 | + $vat_saved = $wpi_session->get('user_vat_data'); |
|
1791 | + $wpi_session->set('user_vat_data', null); |
|
1792 | 1792 | |
1793 | 1793 | $invoice = wpinv_get_invoice_cart(); |
1794 | 1794 | $amount = $invoice->get_total(); |
1795 | - $is_digital = self::invoice_has_digital_rule( $invoice ); |
|
1796 | - $no_vat = !self::requires_vat( 0, false, $is_digital ); |
|
1795 | + $is_digital = self::invoice_has_digital_rule($invoice); |
|
1796 | + $no_vat = !self::requires_vat(0, false, $is_digital); |
|
1797 | 1797 | |
1798 | - $company = !empty( $_POST['wpinv_company'] ) ? $_POST['wpinv_company'] : null; |
|
1799 | - $vat_number = !empty( $_POST['wpinv_vat_number'] ) ? $_POST['wpinv_vat_number'] : null; |
|
1800 | - $country = !empty( $_POST['wpinv_country'] ) ? $_POST['wpinv_country'] : $invoice->country; |
|
1801 | - if ( empty( $country ) ) { |
|
1798 | + $company = !empty($_POST['wpinv_company']) ? $_POST['wpinv_company'] : null; |
|
1799 | + $vat_number = !empty($_POST['wpinv_vat_number']) ? $_POST['wpinv_vat_number'] : null; |
|
1800 | + $country = !empty($_POST['wpinv_country']) ? $_POST['wpinv_country'] : $invoice->country; |
|
1801 | + if (empty($country)) { |
|
1802 | 1802 | $country = wpinv_default_billing_country(); |
1803 | 1803 | } |
1804 | 1804 | |
1805 | - if ( !$is_digital && $no_vat ) { |
|
1805 | + if (!$is_digital && $no_vat) { |
|
1806 | 1806 | return; |
1807 | 1807 | } |
1808 | 1808 | |
1809 | - $vat_data = array( 'company' => '', 'number' => '', 'valid' => false ); |
|
1809 | + $vat_data = array('company' => '', 'number' => '', 'valid' => false); |
|
1810 | 1810 | |
1811 | 1811 | $ip_country_code = self::get_country_by_ip(); |
1812 | - $is_eu_state = self::is_eu_state( $country ); |
|
1813 | - $is_eu_state_ip = self::is_eu_state( $ip_country_code ); |
|
1812 | + $is_eu_state = self::is_eu_state($country); |
|
1813 | + $is_eu_state_ip = self::is_eu_state($ip_country_code); |
|
1814 | 1814 | $is_non_eu_user = !$is_eu_state && !$is_eu_state_ip; |
1815 | 1815 | |
1816 | - if ( $is_digital && !$is_non_eu_user && empty( $vat_number ) && apply_filters( 'wpinv_checkout_requires_country', true, $amount ) ) { |
|
1816 | + if ($is_digital && !$is_non_eu_user && empty($vat_number) && apply_filters('wpinv_checkout_requires_country', true, $amount)) { |
|
1817 | 1817 | $vat_data['adddress_confirmed'] = false; |
1818 | 1818 | |
1819 | - if ( !isset( $_POST['wpinv_adddress_confirmed'] ) ) { |
|
1820 | - if ( $ip_country_code != $country ) { |
|
1821 | - wpinv_set_error( 'vat_validation', sprintf( __( 'The country of your current location must be the same as the country of your billing location or you must %s confirm %s the billing address is your home country.', 'invoicing' ), '<a href="#wpinv_adddress_confirm">', '</a>' ) ); |
|
1819 | + if (!isset($_POST['wpinv_adddress_confirmed'])) { |
|
1820 | + if ($ip_country_code != $country) { |
|
1821 | + wpinv_set_error('vat_validation', sprintf(__('The country of your current location must be the same as the country of your billing location or you must %s confirm %s the billing address is your home country.', 'invoicing'), '<a href="#wpinv_adddress_confirm">', '</a>')); |
|
1822 | 1822 | } |
1823 | 1823 | } else { |
1824 | 1824 | $vat_data['adddress_confirmed'] = true; |
1825 | 1825 | } |
1826 | 1826 | } |
1827 | 1827 | |
1828 | - if ( !empty( $wpinv_options['vat_prevent_b2c_purchase'] ) && !$is_non_eu_user && ( empty( $vat_number ) || $no_vat ) ) { |
|
1829 | - if ( $is_eu_state ) { |
|
1830 | - wpinv_set_error( 'vat_validation', wp_sprintf( __( 'Please enter and validate your %s number to verify your purchase is by an EU business.', 'invoicing' ), $vat_name ) ); |
|
1831 | - } else if ( $is_digital && $is_eu_state_ip ) { |
|
1832 | - wpinv_set_error( 'vat_validation', wp_sprintf( __( 'Sales to non-EU countries cannot be completed because %s must be applied.', 'invoicing' ), $vat_name ) ); |
|
1828 | + if (!empty($wpinv_options['vat_prevent_b2c_purchase']) && !$is_non_eu_user && (empty($vat_number) || $no_vat)) { |
|
1829 | + if ($is_eu_state) { |
|
1830 | + wpinv_set_error('vat_validation', wp_sprintf(__('Please enter and validate your %s number to verify your purchase is by an EU business.', 'invoicing'), $vat_name)); |
|
1831 | + } else if ($is_digital && $is_eu_state_ip) { |
|
1832 | + wpinv_set_error('vat_validation', wp_sprintf(__('Sales to non-EU countries cannot be completed because %s must be applied.', 'invoicing'), $vat_name)); |
|
1833 | 1833 | } |
1834 | 1834 | } |
1835 | 1835 | |
1836 | - if ( !$is_eu_state || $no_vat || empty( $vat_number ) ) { |
|
1836 | + if (!$is_eu_state || $no_vat || empty($vat_number)) { |
|
1837 | 1837 | return; |
1838 | 1838 | } |
1839 | 1839 | |
1840 | - if ( !empty( $vat_saved ) && isset( $vat_saved['valid'] ) ) { |
|
1841 | - $vat_data['valid'] = $vat_saved['valid']; |
|
1840 | + if (!empty($vat_saved) && isset($vat_saved['valid'])) { |
|
1841 | + $vat_data['valid'] = $vat_saved['valid']; |
|
1842 | 1842 | } |
1843 | 1843 | |
1844 | - if ( $company !== null ) { |
|
1844 | + if ($company !== null) { |
|
1845 | 1845 | $vat_data['company'] = $company; |
1846 | 1846 | } |
1847 | 1847 | |
1848 | 1848 | $message = ''; |
1849 | - if ( $vat_number !== null ) { |
|
1849 | + if ($vat_number !== null) { |
|
1850 | 1850 | $vat_data['number'] = $vat_number; |
1851 | 1851 | |
1852 | - if ( !$vat_data['valid'] || ( $vat_saved['number'] !== $vat_data['number'] ) || ( $vat_saved['company'] !== $vat_data['company'] ) ) { |
|
1853 | - if ( !empty( $wpinv_options['vat_vies_check'] ) ) { |
|
1854 | - if ( empty( $wpinv_options['vat_offline_check'] ) && !self::offline_check( $vat_number ) ) { |
|
1852 | + if (!$vat_data['valid'] || ($vat_saved['number'] !== $vat_data['number']) || ($vat_saved['company'] !== $vat_data['company'])) { |
|
1853 | + if (!empty($wpinv_options['vat_vies_check'])) { |
|
1854 | + if (empty($wpinv_options['vat_offline_check']) && !self::offline_check($vat_number)) { |
|
1855 | 1855 | $vat_data['valid'] = false; |
1856 | 1856 | } |
1857 | 1857 | } else { |
1858 | - $result = self::check_vat( $vat_number ); |
|
1858 | + $result = self::check_vat($vat_number); |
|
1859 | 1859 | |
1860 | - if ( !empty( $result['valid'] ) ) { |
|
1860 | + if (!empty($result['valid'])) { |
|
1861 | 1861 | $vat_data['valid'] = true; |
1862 | - $vies_company = !empty( $result['company'] ) ? $result['company'] : ''; |
|
1863 | - $vies_company = apply_filters( 'wpinv_vies_company_name', $vies_company ); |
|
1862 | + $vies_company = !empty($result['company']) ? $result['company'] : ''; |
|
1863 | + $vies_company = apply_filters('wpinv_vies_company_name', $vies_company); |
|
1864 | 1864 | |
1865 | - $valid_company = $vies_company && $company && ( $vies_company == '---' || strcasecmp( trim( $vies_company ), trim( $company ) ) == 0 ) ? true : false; |
|
1865 | + $valid_company = $vies_company && $company && ($vies_company == '---' || strcasecmp(trim($vies_company), trim($company)) == 0) ? true : false; |
|
1866 | 1866 | |
1867 | - if ( !( !empty( $wpinv_options['vat_disable_company_name_check'] ) || $valid_company ) ) { |
|
1867 | + if (!(!empty($wpinv_options['vat_disable_company_name_check']) || $valid_company)) { |
|
1868 | 1868 | $vat_data['valid'] = false; |
1869 | 1869 | |
1870 | - $message = wp_sprintf( __( 'The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing' ), $vat_name ); |
|
1870 | + $message = wp_sprintf(__('The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing'), $vat_name); |
|
1871 | 1871 | } |
1872 | 1872 | } else { |
1873 | - $message = wp_sprintf( __( 'Fail to validate the %s number: EU Commission VAT server (VIES) check fails.', 'invoicing' ), $vat_name ); |
|
1873 | + $message = wp_sprintf(__('Fail to validate the %s number: EU Commission VAT server (VIES) check fails.', 'invoicing'), $vat_name); |
|
1874 | 1874 | } |
1875 | 1875 | } |
1876 | 1876 | |
1877 | - if ( !$vat_data['valid'] ) { |
|
1878 | - $error = wp_sprintf( __( 'The %s %s number %s you have entered has not been validated', 'invoicing' ), '<a href="#wpi-vat-details">', $vat_name, '</a>' ) . ( $message ? ' ( ' . $message . ' )' : '' ); |
|
1879 | - wpinv_set_error( 'vat_validation', $error ); |
|
1877 | + if (!$vat_data['valid']) { |
|
1878 | + $error = wp_sprintf(__('The %s %s number %s you have entered has not been validated', 'invoicing'), '<a href="#wpi-vat-details">', $vat_name, '</a>') . ($message ? ' ( ' . $message . ' )' : ''); |
|
1879 | + wpinv_set_error('vat_validation', $error); |
|
1880 | 1880 | } |
1881 | 1881 | } |
1882 | 1882 | } |
1883 | 1883 | |
1884 | - $wpi_session->set( 'user_vat_data', $vat_data ); |
|
1884 | + $wpi_session->set('user_vat_data', $vat_data); |
|
1885 | 1885 | } |
1886 | 1886 | |
1887 | - public static function checkout_vat_fields( $billing_details ) { |
|
1887 | + public static function checkout_vat_fields($billing_details) { |
|
1888 | 1888 | global $wpi_session, $wpinv_options, $wpi_country, $wpi_requires_vat; |
1889 | 1889 | |
1890 | 1890 | $ip_address = wpinv_get_ip(); |
1891 | 1891 | $ip_country_code = self::get_country_by_ip(); |
1892 | 1892 | |
1893 | - $tax_label = __( self::get_vat_name(), 'invoicing' ); |
|
1893 | + $tax_label = __(self::get_vat_name(), 'invoicing'); |
|
1894 | 1894 | $invoice = wpinv_get_invoice_cart(); |
1895 | - $is_digital = self::invoice_has_digital_rule( $invoice ); |
|
1895 | + $is_digital = self::invoice_has_digital_rule($invoice); |
|
1896 | 1896 | $wpi_country = $invoice->country; |
1897 | 1897 | |
1898 | - $requires_vat = !self::hide_vat_fields() && $invoice->get_total() > 0 && self::requires_vat( 0, false, $is_digital ); |
|
1898 | + $requires_vat = !self::hide_vat_fields() && $invoice->get_total() > 0 && self::requires_vat(0, false, $is_digital); |
|
1899 | 1899 | $wpi_requires_vat = $requires_vat; |
1900 | 1900 | |
1901 | 1901 | $company = is_user_logged_in() ? self::get_user_company() : ''; |
1902 | 1902 | $vat_number = self::get_user_vat_number(); |
1903 | 1903 | |
1904 | - $validated = $vat_number ? self::get_user_vat_number( '', 0, true ) : 1; |
|
1905 | - $vat_info = $wpi_session->get( 'user_vat_data' ); |
|
1904 | + $validated = $vat_number ? self::get_user_vat_number('', 0, true) : 1; |
|
1905 | + $vat_info = $wpi_session->get('user_vat_data'); |
|
1906 | 1906 | |
1907 | - if ( is_array( $vat_info ) ) { |
|
1908 | - $company = isset( $vat_info['company'] ) ? $vat_info['company'] : ''; |
|
1909 | - $vat_number = isset( $vat_info['number'] ) ? $vat_info['number'] : ''; |
|
1910 | - $validated = isset( $vat_info['valid'] ) ? $vat_info['valid'] : false; |
|
1907 | + if (is_array($vat_info)) { |
|
1908 | + $company = isset($vat_info['company']) ? $vat_info['company'] : ''; |
|
1909 | + $vat_number = isset($vat_info['number']) ? $vat_info['number'] : ''; |
|
1910 | + $validated = isset($vat_info['valid']) ? $vat_info['valid'] : false; |
|
1911 | 1911 | } |
1912 | 1912 | |
1913 | 1913 | $selected_country = $invoice->country ? $invoice->country : wpinv_default_billing_country(); |
1914 | 1914 | |
1915 | - if ( $ip_country_code == 'UK' ) { |
|
1915 | + if ($ip_country_code == 'UK') { |
|
1916 | 1916 | $ip_country_code = 'GB'; |
1917 | 1917 | } |
1918 | 1918 | |
1919 | - if ( $selected_country == 'UK' ) { |
|
1919 | + if ($selected_country == 'UK') { |
|
1920 | 1920 | $selected_country = 'GB'; |
1921 | 1921 | } |
1922 | 1922 | |
1923 | - if ( $requires_vat && ( self::same_country_rule() == 'no' && wpinv_is_base_country( $selected_country ) || !self::allow_vat_rules() ) ) { |
|
1923 | + if ($requires_vat && (self::same_country_rule() == 'no' && wpinv_is_base_country($selected_country) || !self::allow_vat_rules())) { |
|
1924 | 1924 | $requires_vat = false; |
1925 | 1925 | } |
1926 | 1926 | |
@@ -1928,52 +1928,52 @@ discard block |
||
1928 | 1928 | $display_validate_btn = 'none'; |
1929 | 1929 | $display_reset_btn = 'none'; |
1930 | 1930 | |
1931 | - if ( !empty( $vat_number ) && $validated ) { |
|
1932 | - $vat_vailidated_text = wp_sprintf( __( '%s number validated', 'invoicing' ), $tax_label ); |
|
1931 | + if (!empty($vat_number) && $validated) { |
|
1932 | + $vat_vailidated_text = wp_sprintf(__('%s number validated', 'invoicing'), $tax_label); |
|
1933 | 1933 | $vat_vailidated_class = 'wpinv-vat-stat-1'; |
1934 | 1934 | $display_reset_btn = 'block'; |
1935 | 1935 | } else { |
1936 | - $vat_vailidated_text = empty( $vat_number ) ? '' : wp_sprintf( __( '%s number not validated', 'invoicing' ), $tax_label ); |
|
1937 | - $vat_vailidated_class = empty( $vat_number ) ? '' : 'wpinv-vat-stat-0'; |
|
1936 | + $vat_vailidated_text = empty($vat_number) ? '' : wp_sprintf(__('%s number not validated', 'invoicing'), $tax_label); |
|
1937 | + $vat_vailidated_class = empty($vat_number) ? '' : 'wpinv-vat-stat-0'; |
|
1938 | 1938 | $display_validate_btn = 'block'; |
1939 | 1939 | } |
1940 | 1940 | |
1941 | - $show_ip_country = $is_digital && ( empty( $vat_number ) || !$requires_vat ) && $ip_country_code != $selected_country ? 'block' : 'none'; |
|
1941 | + $show_ip_country = $is_digital && (empty($vat_number) || !$requires_vat) && $ip_country_code != $selected_country ? 'block' : 'none'; |
|
1942 | 1942 | ?> |
1943 | 1943 | <div id="wpi-vat-details" class="wpi-vat-details clearfix" style="display:<?php echo $display_vat_details; ?>"> |
1944 | 1944 | <div id="wpi_vat_info" class="clearfix panel panel-default"> |
1945 | - <div class="panel-heading"><h3 class="panel-title"><?php echo wp_sprintf( __( '%s Details', 'invoicing' ), $tax_label );?></h3></div> |
|
1945 | + <div class="panel-heading"><h3 class="panel-title"><?php echo wp_sprintf(__('%s Details', 'invoicing'), $tax_label); ?></h3></div> |
|
1946 | 1946 | <div id="wpinv-fields-box" class="panel-body"> |
1947 | 1947 | <p id="wpi_show_vat_note"> |
1948 | - <?php echo wp_sprintf( __( 'Validate your registered %s number to exclude tax.', 'invoicing' ), $tax_label ); ?> |
|
1948 | + <?php echo wp_sprintf(__('Validate your registered %s number to exclude tax.', 'invoicing'), $tax_label); ?> |
|
1949 | 1949 | </p> |
1950 | 1950 | <div id="wpi_vat_fields" class="wpi_vat_info"> |
1951 | 1951 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
1952 | - <label for="wpinv_company" class="wpi-label"><?php _e( 'Company Name', 'invoicing' );?></label> |
|
1952 | + <label for="wpinv_company" class="wpi-label"><?php _e('Company Name', 'invoicing'); ?></label> |
|
1953 | 1953 | <?php |
1954 | - echo wpinv_html_text( array( |
|
1954 | + echo wpinv_html_text(array( |
|
1955 | 1955 | 'id' => 'wpinv_company', |
1956 | 1956 | 'name' => 'wpinv_company', |
1957 | 1957 | 'value' => $company, |
1958 | 1958 | 'class' => 'wpi-input form-control', |
1959 | - 'placeholder' => __( 'Company name', 'invoicing' ), |
|
1960 | - ) ); |
|
1959 | + 'placeholder' => __('Company name', 'invoicing'), |
|
1960 | + )); |
|
1961 | 1961 | ?> |
1962 | 1962 | </p> |
1963 | 1963 | <p class="wpi-cart-field wpi-col2 wpi-coll wpi-cart-field-vat"> |
1964 | - <label for="wpinv_vat_number" class="wpi-label"><?php echo wp_sprintf( __( '%s Number', 'invoicing' ), $tax_label );?></label> |
|
1964 | + <label for="wpinv_vat_number" class="wpi-label"><?php echo wp_sprintf(__('%s Number', 'invoicing'), $tax_label); ?></label> |
|
1965 | 1965 | <span id="wpinv_vat_number-wrap"> |
1966 | 1966 | <label for="wpinv_vat_number" class="wpinv-label"></label> |
1967 | - <input type="text" class="wpi-input form-control" placeholder="<?php echo esc_attr( wp_sprintf( __( '%s number', 'invoicing' ), $tax_label ) );?>" value="<?php esc_attr_e( $vat_number );?>" id="wpinv_vat_number" name="wpinv_vat_number"> |
|
1968 | - <span class="wpinv-vat-stat <?php echo $vat_vailidated_class;?>"><i class="fa"></i> <font><?php echo $vat_vailidated_text;?></font></span> |
|
1967 | + <input type="text" class="wpi-input form-control" placeholder="<?php echo esc_attr(wp_sprintf(__('%s number', 'invoicing'), $tax_label)); ?>" value="<?php esc_attr_e($vat_number); ?>" id="wpinv_vat_number" name="wpinv_vat_number"> |
|
1968 | + <span class="wpinv-vat-stat <?php echo $vat_vailidated_class; ?>"><i class="fa"></i> <font><?php echo $vat_vailidated_text; ?></font></span> |
|
1969 | 1969 | </span> |
1970 | 1970 | </p> |
1971 | 1971 | <p class="wpi-cart-field wpi-col wpi-colf wpi-cart-field-actions"> |
1972 | - <button class="btn btn-success btn-sm wpinv-vat-validate" type="button" id="wpinv_vat_validate" style="display:<?php echo $display_validate_btn; ?>"><?php echo wp_sprintf( __("Validate %s Number", 'invoicing'), $tax_label ); ?></button> |
|
1973 | - <button class="btn btn-danger btn-sm wpinv-vat-reset" type="button" id="wpinv_vat_reset" style="display:<?php echo $display_reset_btn; ?>"><?php echo wp_sprintf( __("Reset %s", 'invoicing'), $tax_label ); ?></button> |
|
1972 | + <button class="btn btn-success btn-sm wpinv-vat-validate" type="button" id="wpinv_vat_validate" style="display:<?php echo $display_validate_btn; ?>"><?php echo wp_sprintf(__("Validate %s Number", 'invoicing'), $tax_label); ?></button> |
|
1973 | + <button class="btn btn-danger btn-sm wpinv-vat-reset" type="button" id="wpinv_vat_reset" style="display:<?php echo $display_reset_btn; ?>"><?php echo wp_sprintf(__("Reset %s", 'invoicing'), $tax_label); ?></button> |
|
1974 | 1974 | <span class="wpi-vat-box wpi-vat-box-info"><span id="text"></span></span> |
1975 | 1975 | <span class="wpi-vat-box wpi-vat-box-error"><span id="text"></span></span> |
1976 | - <input type="hidden" name="_wpi_nonce" value="<?php echo wp_create_nonce( 'vat_validation' ) ?>" /> |
|
1976 | + <input type="hidden" name="_wpi_nonce" value="<?php echo wp_create_nonce('vat_validation') ?>" /> |
|
1977 | 1977 | </p> |
1978 | 1978 | </div> |
1979 | 1979 | </div> |
@@ -1987,32 +1987,32 @@ discard block |
||
1987 | 1987 | </span> |
1988 | 1988 | </div> |
1989 | 1989 | </div> |
1990 | - <?php if ( empty( $wpinv_options['hide_ip_address'] ) ) { |
|
1991 | - $ip_link = '<a title="' . esc_attr( __( 'View more details on map', 'invoicing' ) ) . '" target="_blank" href="' . esc_url( admin_url( 'admin-ajax.php?action=wpinv_ip_geolocation&ip=' . $ip_address ) ) . '" class="wpi-ip-address-link">' . $ip_address . ' <i class="fa fa-external-link-square" aria-hidden="true"></i></a>'; |
|
1990 | + <?php if (empty($wpinv_options['hide_ip_address'])) { |
|
1991 | + $ip_link = '<a title="' . esc_attr(__('View more details on map', 'invoicing')) . '" target="_blank" href="' . esc_url(admin_url('admin-ajax.php?action=wpinv_ip_geolocation&ip=' . $ip_address)) . '" class="wpi-ip-address-link">' . $ip_address . ' <i class="fa fa-external-link-square" aria-hidden="true"></i></a>'; |
|
1992 | 1992 | ?> |
1993 | 1993 | <div class="wpi-ip-info clearfix panel panel-info"> |
1994 | 1994 | <div id="wpinv-fields-box" class="panel-body"> |
1995 | - <span><?php echo wp_sprintf( __( "Your IP address is: %s", 'invoicing' ), $ip_link ); ?></span> |
|
1995 | + <span><?php echo wp_sprintf(__("Your IP address is: %s", 'invoicing'), $ip_link); ?></span> |
|
1996 | 1996 | </div> |
1997 | 1997 | </div> |
1998 | 1998 | <?php } |
1999 | 1999 | } |
2000 | 2000 | |
2001 | - public static function show_vat_notice( $invoice ) { |
|
2002 | - if ( empty( $invoice ) ) { |
|
2001 | + public static function show_vat_notice($invoice) { |
|
2002 | + if (empty($invoice)) { |
|
2003 | 2003 | return NULL; |
2004 | 2004 | } |
2005 | 2005 | |
2006 | - $label = wpinv_get_option( 'vat_invoice_notice_label' ); |
|
2007 | - $notice = wpinv_get_option( 'vat_invoice_notice' ); |
|
2008 | - if ( $label || $notice ) { |
|
2006 | + $label = wpinv_get_option('vat_invoice_notice_label'); |
|
2007 | + $notice = wpinv_get_option('vat_invoice_notice'); |
|
2008 | + if ($label || $notice) { |
|
2009 | 2009 | ?> |
2010 | 2010 | <div class="row wpinv-vat-notice"> |
2011 | 2011 | <div class="col-sm-12"> |
2012 | - <?php if ( $label ) { ?> |
|
2013 | - <strong><?php _e( $label, 'invoicing' ); ?></strong> |
|
2014 | - <?php } if ( $notice ) { ?> |
|
2015 | - <?php echo wpautop( wptexturize( __( $notice, 'invoicing' ) ) ) ?> |
|
2012 | + <?php if ($label) { ?> |
|
2013 | + <strong><?php _e($label, 'invoicing'); ?></strong> |
|
2014 | + <?php } if ($notice) { ?> |
|
2015 | + <?php echo wpautop(wptexturize(__($notice, 'invoicing'))) ?> |
|
2016 | 2016 | <?php } ?> |
2017 | 2017 | </div> |
2018 | 2018 | </div> |
@@ -1,41 +1,41 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( !defined('ABSPATH') ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | global $post; |
6 | 6 | $invoice_id = $post->ID; |
7 | -$invoice = wpinv_get_invoice( $invoice_id ); |
|
8 | -if ( empty( $invoice ) ) { |
|
7 | +$invoice = wpinv_get_invoice($invoice_id); |
|
8 | +if (empty($invoice)) { |
|
9 | 9 | exit; |
10 | 10 | } |
11 | -$type = $post->post_type == 'wpi_invoice' ? __( 'Invoice', 'invoicing' ): __( 'Quotation', 'invoicing' ); |
|
12 | -do_action( 'wpinv_invoice_print_before_display', $invoice ); ?><!DOCTYPE html> |
|
11 | +$type = $post->post_type == 'wpi_invoice' ? __('Invoice', 'invoicing') : __('Quotation', 'invoicing'); |
|
12 | +do_action('wpinv_invoice_print_before_display', $invoice); ?><!DOCTYPE html> |
|
13 | 13 | <html <?php language_attributes(); ?>> |
14 | 14 | <head> |
15 | 15 | <meta charset="UTF-8"> |
16 | 16 | <title><?php wp_title() ?></title> |
17 | - <meta charset="<?php bloginfo( 'charset' ); ?>" /> |
|
17 | + <meta charset="<?php bloginfo('charset'); ?>" /> |
|
18 | 18 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
19 | 19 | <meta name="robots" content="noindex,nofollow"> |
20 | 20 | |
21 | - <?php do_action( 'wpinv_invoice_print_head', $invoice ); ?> |
|
21 | + <?php do_action('wpinv_invoice_print_head', $invoice); ?> |
|
22 | 22 | </head> |
23 | 23 | <body class="body wpinv wpinv-print"> |
24 | - <?php do_action( 'wpinv_invoice_print_body_start', $invoice ); ?> |
|
24 | + <?php do_action('wpinv_invoice_print_body_start', $invoice); ?> |
|
25 | 25 | <div class="container wpinv-wrap"> |
26 | - <?php if ( $watermark = wpinv_watermark( $invoice_id ) ) { ?> |
|
27 | - <div class="watermark no-print"><p><?php echo esc_html( $watermark ) ?></p></div> |
|
26 | + <?php if ($watermark = wpinv_watermark($invoice_id)) { ?> |
|
27 | + <div class="watermark no-print"><p><?php echo esc_html($watermark) ?></p></div> |
|
28 | 28 | <?php } ?> |
29 | 29 | <!-- ///// Start PDF header --> |
30 | 30 | <htmlpageheader name="wpinv-pdf-header"> |
31 | - <?php do_action( 'wpinv_invoice_print_before_header', $invoice ); ?> |
|
31 | + <?php do_action('wpinv_invoice_print_before_header', $invoice); ?> |
|
32 | 32 | <div class="row wpinv-header"> |
33 | 33 | <div class="col-xs-6 wpinv-business"> |
34 | - <a target="_blank" href="<?php echo esc_url( wpinv_get_business_website() ); ?>"> |
|
35 | - <?php if ( $logo = wpinv_get_business_logo() ) { ?> |
|
36 | - <img class="logo" src="<?php echo esc_url( $logo ); ?>"> |
|
34 | + <a target="_blank" href="<?php echo esc_url(wpinv_get_business_website()); ?>"> |
|
35 | + <?php if ($logo = wpinv_get_business_logo()) { ?> |
|
36 | + <img class="logo" src="<?php echo esc_url($logo); ?>"> |
|
37 | 37 | <?php } else { ?> |
38 | - <h1><?php echo esc_html( wpinv_get_business_name() ); ?></h1> |
|
38 | + <h1><?php echo esc_html(wpinv_get_business_name()); ?></h1> |
|
39 | 39 | <?php } ?> |
40 | 40 | </a> |
41 | 41 | </div> |
@@ -44,56 +44,56 @@ discard block |
||
44 | 44 | <h2><?php echo $type; ?></h2> |
45 | 45 | </div> |
46 | 46 | </div> |
47 | - <?php do_action( 'wpinv_invoice_print_after_header', $invoice ); ?> |
|
47 | + <?php do_action('wpinv_invoice_print_after_header', $invoice); ?> |
|
48 | 48 | </htmlpageheader> |
49 | 49 | <!-- End PDF header ///// --> |
50 | 50 | |
51 | - <?php do_action( 'wpinv_invoice_print_before_top_content', $invoice ); ?> |
|
51 | + <?php do_action('wpinv_invoice_print_before_top_content', $invoice); ?> |
|
52 | 52 | <div class="row wpinv-top-content"> |
53 | 53 | <div class="col-xs-12 col-sm-6 wpinv-addresses"> |
54 | 54 | <div class="col-xs-12 wpinv-address wpinv-from-address"> |
55 | 55 | <?php wpinv_display_from_address(); ?> |
56 | 56 | </div> |
57 | 57 | <div class="col-xs-12 wpinv-address wpinv-to-address"> |
58 | - <?php wpinv_display_to_address( $invoice_id ); ?> |
|
58 | + <?php wpinv_display_to_address($invoice_id); ?> |
|
59 | 59 | </div> |
60 | 60 | </div> |
61 | 61 | <div class="col-xs-12 col-sm-6 wpinv-details"> |
62 | 62 | <div class="col-xs-12 wpinv-line-details"> |
63 | - <?php do_action( 'wpinv_invoice_print_before_details', $invoice ); ?> |
|
64 | - <?php wpinv_display_invoice_details( $invoice ); ?> |
|
65 | - <?php do_action( 'wpinv_invoice_print_after_details', $invoice ); ?> |
|
63 | + <?php do_action('wpinv_invoice_print_before_details', $invoice); ?> |
|
64 | + <?php wpinv_display_invoice_details($invoice); ?> |
|
65 | + <?php do_action('wpinv_invoice_print_after_details', $invoice); ?> |
|
66 | 66 | </div> |
67 | 67 | </div> |
68 | 68 | </div> |
69 | - <?php do_action( 'wpinv_invoice_print_after_top_content', $invoice ); ?> |
|
69 | + <?php do_action('wpinv_invoice_print_after_top_content', $invoice); ?> |
|
70 | 70 | |
71 | - <?php do_action( 'wpinv_invoice_print_middle', $invoice ); ?> |
|
71 | + <?php do_action('wpinv_invoice_print_middle', $invoice); ?> |
|
72 | 72 | |
73 | - <?php do_action( 'wpinv_invoice_print_before_line_items', $invoice ); ?> |
|
73 | + <?php do_action('wpinv_invoice_print_before_line_items', $invoice); ?> |
|
74 | 74 | <div class="row wpinv-items"> |
75 | 75 | <div class="col-sm-12 wpinv-line-items"> |
76 | - <?php wpinv_display_line_items( $invoice_id ); ?> |
|
76 | + <?php wpinv_display_line_items($invoice_id); ?> |
|
77 | 77 | </div> |
78 | 78 | </div> |
79 | - <?php do_action( 'wpinv_invoice_print_after_line_items', $invoice ); ?> |
|
79 | + <?php do_action('wpinv_invoice_print_after_line_items', $invoice); ?> |
|
80 | 80 | |
81 | 81 | <!-- ///// Start PDF footer --> |
82 | 82 | <htmlpagefooter name="wpinv-pdf-footer"> |
83 | - <?php do_action( 'wpinv_invoice_print_before_footer', $invoice ); ?> |
|
83 | + <?php do_action('wpinv_invoice_print_before_footer', $invoice); ?> |
|
84 | 84 | <div class="row wpinv-footer"> |
85 | 85 | <div class="col-sm-12"> |
86 | - <?php if ( $term_text = wpinv_get_terms_text() ) { ?> |
|
87 | - <div class="terms-text"><?php echo wpautop( $term_text ); ?></div> |
|
86 | + <?php if ($term_text = wpinv_get_terms_text()) { ?> |
|
87 | + <div class="terms-text"><?php echo wpautop($term_text); ?></div> |
|
88 | 88 | <?php } ?> |
89 | 89 | <div class="footer-text"><?php echo wpinv_get_business_footer(); ?></div> |
90 | - <div class="print-only"><?php _e( 'Page ', 'invoicing' ) ?> {PAGENO}/{nbpg}</div> |
|
90 | + <div class="print-only"><?php _e('Page ', 'invoicing') ?> {PAGENO}/{nbpg}</div> |
|
91 | 91 | </div> |
92 | 92 | </div> |
93 | - <?php do_action( 'wpinv_invoice_print_after_footer', $invoice ); ?> |
|
93 | + <?php do_action('wpinv_invoice_print_after_footer', $invoice); ?> |
|
94 | 94 | </htmlpagefooter> |
95 | 95 | <!-- End PDF footer ///// --> |
96 | 96 | </div><!-- END wpinv-wrap --> |
97 | - <?php do_action( 'wpinv_invoice_print_body_end', $invoice ); ?> |
|
97 | + <?php do_action('wpinv_invoice_print_body_end', $invoice); ?> |
|
98 | 98 | </body> |
99 | 99 | </html> |
100 | 100 | \ No newline at end of file |
@@ -1,65 +1,65 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | -function wpinv_add_meta_boxes( $post_type, $post ) { |
|
7 | +function wpinv_add_meta_boxes($post_type, $post) { |
|
8 | 8 | global $wpi_mb_invoice; |
9 | - if ( $post_type == 'wpi_invoice' && !empty( $post->ID ) ) { |
|
10 | - $wpi_mb_invoice = wpinv_get_invoice( $post->ID ); |
|
9 | + if ($post_type == 'wpi_invoice' && !empty($post->ID)) { |
|
10 | + $wpi_mb_invoice = wpinv_get_invoice($post->ID); |
|
11 | 11 | } |
12 | 12 | |
13 | - if ( !empty( $wpi_mb_invoice ) && !$wpi_mb_invoice->has_status( array( 'draft', 'auto-draft' ) ) ) { |
|
14 | - add_meta_box( 'wpinv-mb-resend-invoice', __( 'Resend Invoice', 'invoicing' ), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high' ); |
|
13 | + if (!empty($wpi_mb_invoice) && !$wpi_mb_invoice->has_status(array('draft', 'auto-draft'))) { |
|
14 | + add_meta_box('wpinv-mb-resend-invoice', __('Resend Invoice', 'invoicing'), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high'); |
|
15 | 15 | } |
16 | 16 | |
17 | - if ( !empty( $wpi_mb_invoice ) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent() ) { |
|
18 | - add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscriptions', 'invoicing' ), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high' ); |
|
17 | + if (!empty($wpi_mb_invoice) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent()) { |
|
18 | + add_meta_box('wpinv-mb-subscriptions', __('Subscriptions', 'invoicing'), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high'); |
|
19 | 19 | } |
20 | 20 | |
21 | - if ( wpinv_is_subscription_payment( $wpi_mb_invoice ) ) { |
|
22 | - add_meta_box( 'wpinv-mb-renewals', __( 'Renewal Payment', 'invoicing' ), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high' ); |
|
21 | + if (wpinv_is_subscription_payment($wpi_mb_invoice)) { |
|
22 | + add_meta_box('wpinv-mb-renewals', __('Renewal Payment', 'invoicing'), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high'); |
|
23 | 23 | } |
24 | 24 | |
25 | - add_meta_box( 'wpinv-details', __( 'Invoice Details', 'invoicing' ), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default' ); |
|
26 | - add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default' ); |
|
25 | + add_meta_box('wpinv-details', __('Invoice Details', 'invoicing'), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default'); |
|
26 | + add_meta_box('wpinv-payment-meta', __('Payment Meta', 'invoicing'), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default'); |
|
27 | 27 | |
28 | - add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high' ); |
|
29 | - add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high' ); |
|
30 | - add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high' ); |
|
28 | + add_meta_box('wpinv-address', __('Billing Details', 'invoicing'), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high'); |
|
29 | + add_meta_box('wpinv-items', __('Invoice Items', 'invoicing'), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high'); |
|
30 | + add_meta_box('wpinv-notes', __('Invoice Notes', 'invoicing'), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high'); |
|
31 | 31 | } |
32 | -add_action( 'add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2 ); |
|
32 | +add_action('add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2); |
|
33 | 33 | |
34 | -function wpinv_save_meta_boxes( $post_id, $post, $update = false ) { |
|
35 | - remove_action( 'save_post', __FUNCTION__ ); |
|
34 | +function wpinv_save_meta_boxes($post_id, $post, $update = false) { |
|
35 | + remove_action('save_post', __FUNCTION__); |
|
36 | 36 | |
37 | 37 | // $post_id and $post are required |
38 | - if ( empty( $post_id ) || empty( $post ) ) { |
|
38 | + if (empty($post_id) || empty($post)) { |
|
39 | 39 | return; |
40 | 40 | } |
41 | 41 | |
42 | - if ( !current_user_can( 'edit_post', $post_id ) || empty( $post->post_type ) ) { |
|
42 | + if (!current_user_can('edit_post', $post_id) || empty($post->post_type)) { |
|
43 | 43 | return; |
44 | 44 | } |
45 | 45 | |
46 | 46 | // Dont' save meta boxes for revisions or autosaves |
47 | - if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
47 | + if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) { |
|
48 | 48 | return; |
49 | 49 | } |
50 | 50 | |
51 | - if ( $post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote' ) { |
|
52 | - if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
51 | + if ($post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote') { |
|
52 | + if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) { |
|
53 | 53 | return; |
54 | 54 | } |
55 | 55 | |
56 | - if ( isset( $_POST['wpinv_save_invoice'] ) && wp_verify_nonce( $_POST['wpinv_save_invoice'], 'wpinv_save_invoice' ) ) { |
|
57 | - WPInv_Meta_Box_Items::save( $post_id, $_POST, $post ); |
|
56 | + if (isset($_POST['wpinv_save_invoice']) && wp_verify_nonce($_POST['wpinv_save_invoice'], 'wpinv_save_invoice')) { |
|
57 | + WPInv_Meta_Box_Items::save($post_id, $_POST, $post); |
|
58 | 58 | } |
59 | - } else if ( $post->post_type == 'wpi_item' ) { |
|
59 | + } else if ($post->post_type == 'wpi_item') { |
|
60 | 60 | // verify nonce |
61 | - if ( isset( $_POST['wpinv_vat_meta_box_nonce'] ) && wp_verify_nonce( $_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save' ) ) { |
|
62 | - $fields = array(); |
|
61 | + if (isset($_POST['wpinv_vat_meta_box_nonce']) && wp_verify_nonce($_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save')) { |
|
62 | + $fields = array(); |
|
63 | 63 | $fields['_wpinv_price'] = 'wpinv_item_price'; |
64 | 64 | $fields['_wpinv_vat_class'] = 'wpinv_vat_class'; |
65 | 65 | $fields['_wpinv_vat_rule'] = 'wpinv_vat_rules'; |
@@ -72,291 +72,291 @@ discard block |
||
72 | 72 | $fields['_wpinv_trial_period'] = 'wpinv_trial_period'; |
73 | 73 | $fields['_wpinv_trial_interval'] = 'wpinv_trial_interval'; |
74 | 74 | |
75 | - if ( !isset( $_POST['wpinv_is_recurring'] ) ) { |
|
75 | + if (!isset($_POST['wpinv_is_recurring'])) { |
|
76 | 76 | $_POST['wpinv_is_recurring'] = 0; |
77 | 77 | } |
78 | 78 | |
79 | - if ( !isset( $_POST['wpinv_free_trial'] ) || empty( $_POST['wpinv_is_recurring'] ) ) { |
|
79 | + if (!isset($_POST['wpinv_free_trial']) || empty($_POST['wpinv_is_recurring'])) { |
|
80 | 80 | $_POST['wpinv_free_trial'] = 0; |
81 | 81 | } |
82 | 82 | |
83 | - foreach ( $fields as $field => $name ) { |
|
84 | - if ( isset( $_POST[ $name ] ) ) { |
|
85 | - if ( $field == '_wpinv_price' ) { |
|
86 | - if ( get_post_meta( $post_id, '_wpinv_type', true ) === 'package' ) { |
|
87 | - $value = wpinv_sanitize_amount( get_post_meta( $post_id, '_wpinv_price', true ) ); // Don't allow edit GD package item price. |
|
83 | + foreach ($fields as $field => $name) { |
|
84 | + if (isset($_POST[$name])) { |
|
85 | + if ($field == '_wpinv_price') { |
|
86 | + if (get_post_meta($post_id, '_wpinv_type', true) === 'package') { |
|
87 | + $value = wpinv_sanitize_amount(get_post_meta($post_id, '_wpinv_price', true)); // Don't allow edit GD package item price. |
|
88 | 88 | } else { |
89 | - $value = wpinv_sanitize_amount( $_POST[ $name ] ); |
|
89 | + $value = wpinv_sanitize_amount($_POST[$name]); |
|
90 | 90 | } |
91 | 91 | } else { |
92 | - $value = is_string( $_POST[ $name ] ) ? sanitize_text_field( $_POST[ $name ] ) : $_POST[ $name ]; |
|
92 | + $value = is_string($_POST[$name]) ? sanitize_text_field($_POST[$name]) : $_POST[$name]; |
|
93 | 93 | } |
94 | 94 | |
95 | - $value = apply_filters( 'wpinv_item_metabox_save_' . $field, $value, $name ); |
|
96 | - update_post_meta( $post_id, $field, $value ); |
|
95 | + $value = apply_filters('wpinv_item_metabox_save_' . $field, $value, $name); |
|
96 | + update_post_meta($post_id, $field, $value); |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | } |
100 | 100 | } |
101 | 101 | } |
102 | -add_action( 'save_post', 'wpinv_save_meta_boxes', 10, 3 ); |
|
102 | +add_action('save_post', 'wpinv_save_meta_boxes', 10, 3); |
|
103 | 103 | |
104 | -function wpinv_bulk_and_quick_edit_save( $post_id, $post, $update = false ) { |
|
105 | - if ( !( !empty( $_POST['action'] ) && $_POST['action'] == 'inline-save' ) ) { |
|
104 | +function wpinv_bulk_and_quick_edit_save($post_id, $post, $update = false) { |
|
105 | + if (!(!empty($_POST['action']) && $_POST['action'] == 'inline-save')) { |
|
106 | 106 | return; |
107 | 107 | } |
108 | 108 | |
109 | 109 | // $post_id and $post are required |
110 | - if ( empty( $post_id ) || empty( $post ) ) { |
|
110 | + if (empty($post_id) || empty($post)) { |
|
111 | 111 | return; |
112 | 112 | } |
113 | 113 | |
114 | - if ( !current_user_can( 'edit_post', $post_id ) || empty( $post->post_type ) ) { |
|
114 | + if (!current_user_can('edit_post', $post_id) || empty($post->post_type)) { |
|
115 | 115 | return; |
116 | 116 | } |
117 | 117 | |
118 | 118 | // Dont' save meta boxes for revisions or autosaves |
119 | - if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
119 | + if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) { |
|
120 | 120 | return; |
121 | 121 | } |
122 | 122 | |
123 | - if ( $post->post_type == 'wpi_item' ) { |
|
123 | + if ($post->post_type == 'wpi_item') { |
|
124 | 124 | // verify nonce |
125 | - if ( isset( $_POST['_wpinv_item_price'] ) && get_post_meta( $post->ID, '_wpinv_type', true ) !== 'package' ) { |
|
126 | - update_post_meta( $post_id, '_wpinv_price', wpinv_sanitize_amount( $_POST['_wpinv_item_price'] ) ); |
|
125 | + if (isset($_POST['_wpinv_item_price']) && get_post_meta($post->ID, '_wpinv_type', true) !== 'package') { |
|
126 | + update_post_meta($post_id, '_wpinv_price', wpinv_sanitize_amount($_POST['_wpinv_item_price'])); |
|
127 | 127 | } |
128 | 128 | |
129 | - if ( isset( $_POST['_wpinv_vat_class'] ) ) { |
|
130 | - update_post_meta( $post_id, '_wpinv_vat_class', sanitize_text_field( $_POST['_wpinv_vat_class'] ) ); |
|
129 | + if (isset($_POST['_wpinv_vat_class'])) { |
|
130 | + update_post_meta($post_id, '_wpinv_vat_class', sanitize_text_field($_POST['_wpinv_vat_class'])); |
|
131 | 131 | } |
132 | 132 | |
133 | - if ( isset( $_POST['_wpinv_vat_rules'] ) ) { |
|
134 | - update_post_meta( $post_id, '_wpinv_vat_rule', sanitize_text_field( $_POST['_wpinv_vat_rules'] ) ); |
|
133 | + if (isset($_POST['_wpinv_vat_rules'])) { |
|
134 | + update_post_meta($post_id, '_wpinv_vat_rule', sanitize_text_field($_POST['_wpinv_vat_rules'])); |
|
135 | 135 | } |
136 | 136 | |
137 | - if ( isset( $_POST['_wpinv_item_type'] ) ) { |
|
138 | - update_post_meta( $post_id, '_wpinv_type', sanitize_text_field( $_POST['_wpinv_item_type'] ) ); |
|
137 | + if (isset($_POST['_wpinv_item_type'])) { |
|
138 | + update_post_meta($post_id, '_wpinv_type', sanitize_text_field($_POST['_wpinv_item_type'])); |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | } |
142 | -add_action( 'save_post', 'wpinv_bulk_and_quick_edit_save', 10, 3 ); |
|
142 | +add_action('save_post', 'wpinv_bulk_and_quick_edit_save', 10, 3); |
|
143 | 143 | |
144 | 144 | function wpinv_register_item_meta_boxes() { |
145 | 145 | global $wpinv_euvat; |
146 | 146 | |
147 | - add_meta_box( 'wpinv_field_prices', __( 'Item Price', 'invoicing' ), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high' ); |
|
147 | + add_meta_box('wpinv_field_prices', __('Item Price', 'invoicing'), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high'); |
|
148 | 148 | |
149 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
150 | - add_meta_box( 'wpinv_field_vat_rules', __( 'VAT rules type to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high' ); |
|
149 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
150 | + add_meta_box('wpinv_field_vat_rules', __('VAT rules type to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high'); |
|
151 | 151 | } |
152 | 152 | |
153 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
154 | - add_meta_box( 'wpinv_field_vat_classes', __( 'VAT rates class to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high' ); |
|
153 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
154 | + add_meta_box('wpinv_field_vat_classes', __('VAT rates class to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high'); |
|
155 | 155 | } |
156 | 156 | |
157 | - add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core' ); |
|
157 | + add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core'); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | function wpinv_register_discount_meta_boxes() { |
161 | - add_meta_box( 'wpinv_discount_fields', __( 'Discount Details', 'invoicing' ), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high' ); |
|
161 | + add_meta_box('wpinv_discount_fields', __('Discount Details', 'invoicing'), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high'); |
|
162 | 162 | } |
163 | 163 | |
164 | -function wpinv_discount_metabox_details( $post ) { |
|
164 | +function wpinv_discount_metabox_details($post) { |
|
165 | 165 | $discount_id = $post->ID; |
166 | - $discount = wpinv_get_discount( $discount_id ); |
|
166 | + $discount = wpinv_get_discount($discount_id); |
|
167 | 167 | |
168 | - $type = wpinv_get_discount_type( $discount_id ); |
|
169 | - $item_reqs = wpinv_get_discount_item_reqs( $discount_id ); |
|
170 | - $excluded_items = wpinv_get_discount_excluded_items( $discount_id ); |
|
171 | - $min_total = wpinv_get_discount_min_total( $discount_id ); |
|
172 | - $max_total = wpinv_get_discount_max_total( $discount_id ); |
|
173 | - $max_uses = wpinv_get_discount_max_uses( $discount_id ); |
|
174 | - $single_use = wpinv_discount_is_single_use( $discount_id ); |
|
175 | - $recurring = (bool)wpinv_discount_is_recurring( $discount_id ); |
|
168 | + $type = wpinv_get_discount_type($discount_id); |
|
169 | + $item_reqs = wpinv_get_discount_item_reqs($discount_id); |
|
170 | + $excluded_items = wpinv_get_discount_excluded_items($discount_id); |
|
171 | + $min_total = wpinv_get_discount_min_total($discount_id); |
|
172 | + $max_total = wpinv_get_discount_max_total($discount_id); |
|
173 | + $max_uses = wpinv_get_discount_max_uses($discount_id); |
|
174 | + $single_use = wpinv_discount_is_single_use($discount_id); |
|
175 | + $recurring = (bool)wpinv_discount_is_recurring($discount_id); |
|
176 | 176 | |
177 | 177 | $min_total = $min_total > 0 ? $min_total : ''; |
178 | 178 | $max_total = $max_total > 0 ? $max_total : ''; |
179 | 179 | $max_uses = $max_uses > 0 ? $max_uses : ''; |
180 | 180 | ?> |
181 | -<?php do_action( 'wpinv_discount_form_top', $post ); ?> |
|
182 | -<?php wp_nonce_field( 'wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce' ); ;?> |
|
181 | +<?php do_action('wpinv_discount_form_top', $post); ?> |
|
182 | +<?php wp_nonce_field('wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce'); ;?> |
|
183 | 183 | <table class="form-table wpi-form-table"> |
184 | 184 | <tbody> |
185 | - <?php do_action( 'wpinv_discount_form_first', $post ); ?> |
|
186 | - <?php do_action( 'wpinv_discount_form_before_code', $post ); ?> |
|
185 | + <?php do_action('wpinv_discount_form_first', $post); ?> |
|
186 | + <?php do_action('wpinv_discount_form_before_code', $post); ?> |
|
187 | 187 | <tr> |
188 | 188 | <th valign="top" scope="row"> |
189 | - <label for="wpinv_discount_code"><?php _e( 'Discount Code', 'invoicing' ); ?></label> |
|
189 | + <label for="wpinv_discount_code"><?php _e('Discount Code', 'invoicing'); ?></label> |
|
190 | 190 | </th> |
191 | 191 | <td> |
192 | - <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr( wpinv_get_discount_code( $discount_id ) ); ?>" required> |
|
193 | - <p class="description"><?php _e( 'Enter a code for this discount, such as 10OFF', 'invoicing' ); ?></p> |
|
192 | + <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr(wpinv_get_discount_code($discount_id)); ?>" required> |
|
193 | + <p class="description"><?php _e('Enter a code for this discount, such as 10OFF', 'invoicing'); ?></p> |
|
194 | 194 | </td> |
195 | 195 | </tr> |
196 | - <?php do_action( 'wpinv_discount_form_before_type', $post ); ?> |
|
196 | + <?php do_action('wpinv_discount_form_before_type', $post); ?> |
|
197 | 197 | <tr> |
198 | 198 | <th valign="top" scope="row"> |
199 | - <label for="wpinv_discount_type"><?php _e( 'Discount Type', 'invoicing' ); ?></label> |
|
199 | + <label for="wpinv_discount_type"><?php _e('Discount Type', 'invoicing'); ?></label> |
|
200 | 200 | </th> |
201 | 201 | <td> |
202 | 202 | <select id="wpinv_discount_type" name="type" class="medium-text"> |
203 | - <?php foreach ( wpinv_get_discount_types() as $value => $label ) { ?> |
|
204 | - <option value="<?php echo $value ;?>" <?php selected( $type, $value ); ?>><?php echo $label; ?></option> |
|
203 | + <?php foreach (wpinv_get_discount_types() as $value => $label) { ?> |
|
204 | + <option value="<?php echo $value; ?>" <?php selected($type, $value); ?>><?php echo $label; ?></option> |
|
205 | 205 | <?php } ?> |
206 | 206 | </select> |
207 | - <p class="description"><?php _e( 'The kind of discount to apply for this discount.', 'invoicing' ); ?></p> |
|
207 | + <p class="description"><?php _e('The kind of discount to apply for this discount.', 'invoicing'); ?></p> |
|
208 | 208 | </td> |
209 | 209 | </tr> |
210 | - <?php do_action( 'wpinv_discount_form_before_amount', $post ); ?> |
|
210 | + <?php do_action('wpinv_discount_form_before_amount', $post); ?> |
|
211 | 211 | <tr> |
212 | 212 | <th valign="top" scope="row"> |
213 | - <label for="wpinv_discount_amount"><?php _e( 'Amount', 'invoicing' ); ?></label> |
|
213 | + <label for="wpinv_discount_amount"><?php _e('Amount', 'invoicing'); ?></label> |
|
214 | 214 | </th> |
215 | 215 | <td> |
216 | - <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr( wpinv_get_discount_amount( $discount_id ) ); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol() ;?></font> |
|
217 | - <p style="display:none;" class="description"><?php _e( 'Enter the discount amount in USD', 'invoicing' ); ?></p> |
|
218 | - <p class="description"><?php _e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?></p> |
|
216 | + <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr(wpinv_get_discount_amount($discount_id)); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol(); ?></font> |
|
217 | + <p style="display:none;" class="description"><?php _e('Enter the discount amount in USD', 'invoicing'); ?></p> |
|
218 | + <p class="description"><?php _e('Enter the discount value. Ex: 10', 'invoicing'); ?></p> |
|
219 | 219 | </td> |
220 | 220 | </tr> |
221 | - <?php do_action( 'wpinv_discount_form_before_items', $post ); ?> |
|
221 | + <?php do_action('wpinv_discount_form_before_items', $post); ?> |
|
222 | 222 | <tr> |
223 | 223 | <th valign="top" scope="row"> |
224 | - <label for="wpinv_discount_items"><?php _e( 'Items', 'invoicing' ); ?></label> |
|
224 | + <label for="wpinv_discount_items"><?php _e('Items', 'invoicing'); ?></label> |
|
225 | 225 | </th> |
226 | 226 | <td> |
227 | - <p><?php echo wpinv_item_dropdown( array( |
|
227 | + <p><?php echo wpinv_item_dropdown(array( |
|
228 | 228 | 'name' => 'items[]', |
229 | 229 | 'id' => 'items', |
230 | 230 | 'selected' => $item_reqs, |
231 | 231 | 'multiple' => true, |
232 | 232 | 'chosen' => true, |
233 | 233 | 'class' => 'medium-text', |
234 | - 'placeholder' => __( 'Select one or more Items', 'invoicing' ), |
|
234 | + 'placeholder' => __('Select one or more Items', 'invoicing'), |
|
235 | 235 | 'show_recurring' => true, |
236 | - ) ); ?> |
|
236 | + )); ?> |
|
237 | 237 | </p> |
238 | - <p class="description"><?php _e( 'Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing' ); ?></p> |
|
238 | + <p class="description"><?php _e('Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing'); ?></p> |
|
239 | 239 | </td> |
240 | 240 | </tr> |
241 | - <?php do_action( 'wpinv_discount_form_before_excluded_items', $post ); ?> |
|
241 | + <?php do_action('wpinv_discount_form_before_excluded_items', $post); ?> |
|
242 | 242 | <tr> |
243 | 243 | <th valign="top" scope="row"> |
244 | - <label for="wpinv_discount_excluded_items"><?php _e( 'Excluded Items', 'invoicing' ); ?></label> |
|
244 | + <label for="wpinv_discount_excluded_items"><?php _e('Excluded Items', 'invoicing'); ?></label> |
|
245 | 245 | </th> |
246 | 246 | <td> |
247 | - <p><?php echo wpinv_item_dropdown( array( |
|
247 | + <p><?php echo wpinv_item_dropdown(array( |
|
248 | 248 | 'name' => 'excluded_items[]', |
249 | 249 | 'id' => 'excluded_items', |
250 | 250 | 'selected' => $excluded_items, |
251 | 251 | 'multiple' => true, |
252 | 252 | 'chosen' => true, |
253 | 253 | 'class' => 'medium-text', |
254 | - 'placeholder' => __( 'Select one or more Items', 'invoicing' ), |
|
254 | + 'placeholder' => __('Select one or more Items', 'invoicing'), |
|
255 | 255 | 'show_recurring' => true, |
256 | - ) ); ?> |
|
256 | + )); ?> |
|
257 | 257 | </p> |
258 | - <p class="description"><?php _e( 'Items which are NOT allowed to use this discount.', 'invoicing' ); ?></p> |
|
258 | + <p class="description"><?php _e('Items which are NOT allowed to use this discount.', 'invoicing'); ?></p> |
|
259 | 259 | </td> |
260 | 260 | </tr> |
261 | - <?php do_action( 'wpinv_discount_form_before_start', $post ); ?> |
|
261 | + <?php do_action('wpinv_discount_form_before_start', $post); ?> |
|
262 | 262 | <tr> |
263 | 263 | <th valign="top" scope="row"> |
264 | - <label for="wpinv_discount_start"><?php _e( 'Start date', 'invoicing' ); ?></label> |
|
264 | + <label for="wpinv_discount_start"><?php _e('Start date', 'invoicing'); ?></label> |
|
265 | 265 | </th> |
266 | 266 | <td> |
267 | - <input type="text" class="medium-text wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr( wpinv_get_discount_start_date( $discount_id ) ); ?>"> |
|
268 | - <p class="description"><?php _e( 'Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing' ); ?></p> |
|
267 | + <input type="text" class="medium-text wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr(wpinv_get_discount_start_date($discount_id)); ?>"> |
|
268 | + <p class="description"><?php _e('Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing'); ?></p> |
|
269 | 269 | </td> |
270 | 270 | </tr> |
271 | - <?php do_action( 'wpinv_discount_form_before_expiration', $post ); ?> |
|
271 | + <?php do_action('wpinv_discount_form_before_expiration', $post); ?> |
|
272 | 272 | <tr> |
273 | 273 | <th valign="top" scope="row"> |
274 | - <label for="wpinv_discount_expiration"><?php _e( 'Expiration date', 'invoicing' ); ?></label> |
|
274 | + <label for="wpinv_discount_expiration"><?php _e('Expiration date', 'invoicing'); ?></label> |
|
275 | 275 | </th> |
276 | 276 | <td> |
277 | - <input type="text" class="medium-text wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr( wpinv_get_discount_expiration( $discount_id ) ); ?>"> |
|
278 | - <p class="description"><?php _e( 'Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing' ); ?></p> |
|
277 | + <input type="text" class="medium-text wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr(wpinv_get_discount_expiration($discount_id)); ?>"> |
|
278 | + <p class="description"><?php _e('Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing'); ?></p> |
|
279 | 279 | </td> |
280 | 280 | </tr> |
281 | - <?php do_action( 'wpinv_discount_form_before_min_total', $post ); ?> |
|
281 | + <?php do_action('wpinv_discount_form_before_min_total', $post); ?> |
|
282 | 282 | <tr> |
283 | 283 | <th valign="top" scope="row"> |
284 | - <label for="wpinv_discount_min_total"><?php _e( 'Minimum Amount', 'invoicing' ); ?></label> |
|
284 | + <label for="wpinv_discount_min_total"><?php _e('Minimum Amount', 'invoicing'); ?></label> |
|
285 | 285 | </th> |
286 | 286 | <td> |
287 | 287 | <input type="text" name="min_total" id="wpinv_discount_min_total" class="wpi-field-price wpi-price" value="<?php echo $min_total; ?>"> |
288 | - <p class="description"><?php _e( 'This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p> |
|
288 | + <p class="description"><?php _e('This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p> |
|
289 | 289 | </td> |
290 | 290 | </tr> |
291 | - <?php do_action( 'wpinv_discount_form_before_max_total', $post ); ?> |
|
291 | + <?php do_action('wpinv_discount_form_before_max_total', $post); ?> |
|
292 | 292 | <tr> |
293 | 293 | <th valign="top" scope="row"> |
294 | - <label for="wpinv_discount_max_total"><?php _e( 'Maximum Amount', 'invoicing' ); ?></label> |
|
294 | + <label for="wpinv_discount_max_total"><?php _e('Maximum Amount', 'invoicing'); ?></label> |
|
295 | 295 | </th> |
296 | 296 | <td> |
297 | 297 | <input type="text" name="max_total" id="wpinv_discount_max_total" class="wpi-field-price wpi-price" value="<?php echo $max_total; ?>"> |
298 | - <p class="description"><?php _e( 'This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p> |
|
298 | + <p class="description"><?php _e('This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p> |
|
299 | 299 | </td> |
300 | 300 | </tr> |
301 | - <?php do_action( 'wpinv_discount_form_before_recurring', $post ); ?> |
|
301 | + <?php do_action('wpinv_discount_form_before_recurring', $post); ?> |
|
302 | 302 | <tr> |
303 | 303 | <th valign="top" scope="row"> |
304 | - <label for="wpinv_discount_recurring"><?php _e( 'For recurring apply to', 'invoicing' ); ?></label> |
|
304 | + <label for="wpinv_discount_recurring"><?php _e('For recurring apply to', 'invoicing'); ?></label> |
|
305 | 305 | </th> |
306 | 306 | <td> |
307 | 307 | <select id="wpinv_discount_recurring" name="recurring" class="medium-text"> |
308 | - <option value="0" <?php selected( false, $recurring ); ?>><?php _e( 'All payments', 'invoicing' ); ?></option> |
|
309 | - <option value="1" <?php selected( true, $recurring ); ?>><?php _e( 'First payment only', 'invoicing' ); ?></option> |
|
308 | + <option value="0" <?php selected(false, $recurring); ?>><?php _e('All payments', 'invoicing'); ?></option> |
|
309 | + <option value="1" <?php selected(true, $recurring); ?>><?php _e('First payment only', 'invoicing'); ?></option> |
|
310 | 310 | </select> |
311 | - <p class="description"><?php _e( '<b>All payments:</b> apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> apply this discount to only first payment of the recurring invoice.', 'invoicing' ); ?></p> |
|
311 | + <p class="description"><?php _e('<b>All payments:</b> apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> apply this discount to only first payment of the recurring invoice.', 'invoicing'); ?></p> |
|
312 | 312 | </td> |
313 | 313 | </tr> |
314 | - <?php do_action( 'wpinv_discount_form_before_max_uses', $post ); ?> |
|
314 | + <?php do_action('wpinv_discount_form_before_max_uses', $post); ?> |
|
315 | 315 | <tr> |
316 | 316 | <th valign="top" scope="row"> |
317 | - <label for="wpinv_discount_max_uses"><?php _e( 'Max Uses', 'invoicing' ); ?></label> |
|
317 | + <label for="wpinv_discount_max_uses"><?php _e('Max Uses', 'invoicing'); ?></label> |
|
318 | 318 | </th> |
319 | 319 | <td> |
320 | 320 | <input type="number" min="0" step="1" id="wpinv_discount_max_uses" name="max_uses" class="medium-text" value="<?php echo $max_uses; ?>"> |
321 | - <p class="description"><?php _e( 'The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing' ); ?></p> |
|
321 | + <p class="description"><?php _e('The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing'); ?></p> |
|
322 | 322 | </td> |
323 | 323 | </tr> |
324 | - <?php do_action( 'wpinv_discount_form_before_single_use', $post ); ?> |
|
324 | + <?php do_action('wpinv_discount_form_before_single_use', $post); ?> |
|
325 | 325 | <tr> |
326 | 326 | <th valign="top" scope="row"> |
327 | - <label for="wpinv_discount_single_use"><?php _e( 'Use Once Per User', 'invoicing' ); ?></label> |
|
327 | + <label for="wpinv_discount_single_use"><?php _e('Use Once Per User', 'invoicing'); ?></label> |
|
328 | 328 | </th> |
329 | 329 | <td> |
330 | - <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked( true, $single_use ); ?>> |
|
331 | - <span class="description"><?php _e( 'Limit this discount to a single use per user?', 'invoicing' ); ?></span> |
|
330 | + <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked(true, $single_use); ?>> |
|
331 | + <span class="description"><?php _e('Limit this discount to a single use per user?', 'invoicing'); ?></span> |
|
332 | 332 | </td> |
333 | 333 | </tr> |
334 | - <?php do_action( 'wpinv_discount_form_last', $post ); ?> |
|
334 | + <?php do_action('wpinv_discount_form_last', $post); ?> |
|
335 | 335 | </tbody> |
336 | 336 | </table> |
337 | -<?php do_action( 'wpinv_discount_form_bottom', $post ); ?> |
|
337 | +<?php do_action('wpinv_discount_form_bottom', $post); ?> |
|
338 | 338 | <?php |
339 | 339 | } |
340 | 340 | |
341 | -function wpinv_discount_metabox_save( $post_id, $post, $update = false ) { |
|
342 | - $post_type = !empty( $post ) ? $post->post_type : ''; |
|
341 | +function wpinv_discount_metabox_save($post_id, $post, $update = false) { |
|
342 | + $post_type = !empty($post) ? $post->post_type : ''; |
|
343 | 343 | |
344 | - if ( $post_type != 'wpi_discount' ) { |
|
344 | + if ($post_type != 'wpi_discount') { |
|
345 | 345 | return; |
346 | 346 | } |
347 | 347 | |
348 | - if ( !isset( $_POST['wpinv_discount_metabox_nonce'] ) || ( isset( $_POST['wpinv_discount_metabox_nonce'] ) && !wp_verify_nonce( $_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce' ) ) ) { |
|
348 | + if (!isset($_POST['wpinv_discount_metabox_nonce']) || (isset($_POST['wpinv_discount_metabox_nonce']) && !wp_verify_nonce($_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce'))) { |
|
349 | 349 | return; |
350 | 350 | } |
351 | 351 | |
352 | - if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
352 | + if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || (defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) { |
|
353 | 353 | return; |
354 | 354 | } |
355 | 355 | |
356 | - if ( !current_user_can( 'manage_options', $post_id ) ) { |
|
356 | + if (!current_user_can('manage_options', $post_id)) { |
|
357 | 357 | return; |
358 | 358 | } |
359 | 359 | |
360 | - return wpinv_store_discount( $post_id, $_POST, $post, $update ); |
|
360 | + return wpinv_store_discount($post_id, $_POST, $post, $update); |
|
361 | 361 | } |
362 | -add_action( 'save_post', 'wpinv_discount_metabox_save', 10, 3 ); |
|
363 | 362 | \ No newline at end of file |
363 | +add_action('save_post', 'wpinv_discount_metabox_save', 10, 3); |
|
364 | 364 | \ No newline at end of file |
@@ -1,66 +1,66 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | -add_action( 'admin_menu', 'wpinv_add_options_link', 10 ); |
|
7 | +add_action('admin_menu', 'wpinv_add_options_link', 10); |
|
8 | 8 | function wpinv_add_options_link() { |
9 | 9 | global $menu; |
10 | 10 | |
11 | - if ( current_user_can( 'manage_options' ) ) { |
|
12 | - $menu[] = array( '', 'read', 'separator-wpinv', '', 'wp-menu-separator wpinv' ); |
|
11 | + if (current_user_can('manage_options')) { |
|
12 | + $menu[] = array('', 'read', 'separator-wpinv', '', 'wp-menu-separator wpinv'); |
|
13 | 13 | } |
14 | 14 | |
15 | - $wpi_invoice = get_post_type_object( 'wpi_invoice' ); |
|
15 | + $wpi_invoice = get_post_type_object('wpi_invoice'); |
|
16 | 16 | |
17 | - add_menu_page( __( 'Invoicing', 'invoicing' ), __( 'Invoicing', 'invoicing' ), 'manage_options', 'wpinv', null, $wpi_invoice->menu_icon, '54.123460' ); |
|
17 | + add_menu_page(__('Invoicing', 'invoicing'), __('Invoicing', 'invoicing'), 'manage_options', 'wpinv', null, $wpi_invoice->menu_icon, '54.123460'); |
|
18 | 18 | |
19 | - $wpi_settings_page = add_submenu_page( 'wpinv', __( 'Invoice Settings', 'invoicing' ), __( 'Settings', 'invoicing' ), 'manage_options', 'wpinv-settings', 'wpinv_options_page' ); |
|
19 | + $wpi_settings_page = add_submenu_page('wpinv', __('Invoice Settings', 'invoicing'), __('Settings', 'invoicing'), 'manage_options', 'wpinv-settings', 'wpinv_options_page'); |
|
20 | 20 | } |
21 | 21 | |
22 | -add_action( 'admin_menu', 'wpinv_remove_admin_submenus', 999 ); |
|
22 | +add_action('admin_menu', 'wpinv_remove_admin_submenus', 999); |
|
23 | 23 | function wpinv_remove_admin_submenus() { |
24 | - remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' ); |
|
24 | + remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice'); |
|
25 | 25 | } |
26 | 26 | |
27 | -add_filter( 'manage_wpi_discount_posts_columns', 'wpinv_discount_columns' ); |
|
28 | -function wpinv_discount_columns( $existing_columns ) { |
|
27 | +add_filter('manage_wpi_discount_posts_columns', 'wpinv_discount_columns'); |
|
28 | +function wpinv_discount_columns($existing_columns) { |
|
29 | 29 | $columns = array(); |
30 | 30 | $columns['cb'] = $existing_columns['cb']; |
31 | - $columns['name'] = __( 'Name', 'invoicing' ); |
|
32 | - $columns['code'] = __( 'Code', 'invoicing' ); |
|
33 | - $columns['amount'] = __( 'Amount', 'invoicing' ); |
|
34 | - $columns['usage'] = __( 'Usage / Limit', 'invoicing' ); |
|
35 | - $columns['expiry_date'] = __( 'Expiry Date', 'invoicing' ); |
|
36 | - $columns['status'] = __( 'Status', 'invoicing' ); |
|
31 | + $columns['name'] = __('Name', 'invoicing'); |
|
32 | + $columns['code'] = __('Code', 'invoicing'); |
|
33 | + $columns['amount'] = __('Amount', 'invoicing'); |
|
34 | + $columns['usage'] = __('Usage / Limit', 'invoicing'); |
|
35 | + $columns['expiry_date'] = __('Expiry Date', 'invoicing'); |
|
36 | + $columns['status'] = __('Status', 'invoicing'); |
|
37 | 37 | |
38 | 38 | return $columns; |
39 | 39 | } |
40 | 40 | |
41 | -add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' ); |
|
42 | -function wpinv_discount_custom_column( $column ) { |
|
41 | +add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column'); |
|
42 | +function wpinv_discount_custom_column($column) { |
|
43 | 43 | global $post; |
44 | 44 | |
45 | 45 | $discount = $post; |
46 | 46 | |
47 | - switch ( $column ) { |
|
47 | + switch ($column) { |
|
48 | 48 | case 'name' : |
49 | - echo get_the_title( $discount->ID ); |
|
49 | + echo get_the_title($discount->ID); |
|
50 | 50 | break; |
51 | 51 | case 'code' : |
52 | - echo wpinv_get_discount_code( $discount->ID ); |
|
52 | + echo wpinv_get_discount_code($discount->ID); |
|
53 | 53 | break; |
54 | 54 | case 'amount' : |
55 | - echo wpinv_format_discount_rate( wpinv_get_discount_type( $discount->ID ), wpinv_get_discount_amount( $discount->ID ) ); |
|
55 | + echo wpinv_format_discount_rate(wpinv_get_discount_type($discount->ID), wpinv_get_discount_amount($discount->ID)); |
|
56 | 56 | break; |
57 | 57 | case 'usage_limit' : |
58 | - echo wpinv_get_discount_uses( $discount->ID ); |
|
58 | + echo wpinv_get_discount_uses($discount->ID); |
|
59 | 59 | break; |
60 | 60 | case 'usage' : |
61 | - $usage = wpinv_get_discount_uses( $discount->ID ) . ' / '; |
|
62 | - if ( wpinv_get_discount_max_uses( $discount->ID ) ) { |
|
63 | - $usage .= wpinv_get_discount_max_uses( $discount->ID ); |
|
61 | + $usage = wpinv_get_discount_uses($discount->ID) . ' / '; |
|
62 | + if (wpinv_get_discount_max_uses($discount->ID)) { |
|
63 | + $usage .= wpinv_get_discount_max_uses($discount->ID); |
|
64 | 64 | } else { |
65 | 65 | $usage .= ' ∞'; |
66 | 66 | } |
@@ -68,162 +68,162 @@ discard block |
||
68 | 68 | echo $usage; |
69 | 69 | break; |
70 | 70 | case 'expiry_date' : |
71 | - if ( wpinv_get_discount_expiration( $discount->ID ) ) { |
|
72 | - $expiration = date_i18n( get_option( 'date_format' ), strtotime( wpinv_get_discount_expiration( $discount->ID ) ) ); |
|
71 | + if (wpinv_get_discount_expiration($discount->ID)) { |
|
72 | + $expiration = date_i18n(get_option('date_format'), strtotime(wpinv_get_discount_expiration($discount->ID))); |
|
73 | 73 | } else { |
74 | - $expiration = __( 'Never', 'invoicing' ); |
|
74 | + $expiration = __('Never', 'invoicing'); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | echo $expiration; |
78 | 78 | break; |
79 | 79 | case 'description' : |
80 | - echo wp_kses_post( $post->post_excerpt ); |
|
80 | + echo wp_kses_post($post->post_excerpt); |
|
81 | 81 | break; |
82 | 82 | case 'status' : |
83 | - $status = wpinv_is_discount_expired( $discount->ID ) ? 'expired' : $discount->post_status; |
|
83 | + $status = wpinv_is_discount_expired($discount->ID) ? 'expired' : $discount->post_status; |
|
84 | 84 | |
85 | - echo wpinv_discount_status( $status ); |
|
85 | + echo wpinv_discount_status($status); |
|
86 | 86 | break; |
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
90 | -add_filter( 'post_row_actions', 'wpinv_post_row_actions', 9999, 2 ); |
|
91 | -function wpinv_post_row_actions( $actions, $post ) { |
|
92 | - $post_type = !empty( $post->post_type ) ? $post->post_type : ''; |
|
90 | +add_filter('post_row_actions', 'wpinv_post_row_actions', 9999, 2); |
|
91 | +function wpinv_post_row_actions($actions, $post) { |
|
92 | + $post_type = !empty($post->post_type) ? $post->post_type : ''; |
|
93 | 93 | |
94 | - if ( $post_type == 'wpi_invoice' ) { |
|
94 | + if ($post_type == 'wpi_invoice') { |
|
95 | 95 | $actions = array(); |
96 | 96 | } |
97 | 97 | |
98 | - if ( $post_type == 'wpi_discount' ) { |
|
99 | - $actions = wpinv_discount_row_actions( $post, $actions ); |
|
98 | + if ($post_type == 'wpi_discount') { |
|
99 | + $actions = wpinv_discount_row_actions($post, $actions); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | return $actions; |
103 | 103 | } |
104 | 104 | |
105 | -function wpinv_discount_row_actions( $discount, $row_actions ) { |
|
106 | - $row_actions = array(); |
|
107 | - $edit_link = get_edit_post_link( $discount->ID ); |
|
108 | - $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>'; |
|
105 | +function wpinv_discount_row_actions($discount, $row_actions) { |
|
106 | + $row_actions = array(); |
|
107 | + $edit_link = get_edit_post_link($discount->ID); |
|
108 | + $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>'; |
|
109 | 109 | |
110 | - if( in_array( strtolower( $discount->post_status ), array( 'publish' ) ) ) { |
|
111 | - $row_actions['deactivate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'deactivate_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Deactivate', 'invoicing' ) . '</a>'; |
|
112 | - } elseif( in_array( strtolower( $discount->post_status ), array( 'pending', 'draft' ) ) ) { |
|
113 | - $row_actions['activate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'activate_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Activate', 'invoicing' ) . '</a>'; |
|
110 | + if (in_array(strtolower($discount->post_status), array('publish'))) { |
|
111 | + $row_actions['deactivate'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'deactivate_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Deactivate', 'invoicing') . '</a>'; |
|
112 | + } elseif (in_array(strtolower($discount->post_status), array('pending', 'draft'))) { |
|
113 | + $row_actions['activate'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'activate_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Activate', 'invoicing') . '</a>'; |
|
114 | 114 | } |
115 | 115 | |
116 | - if ( wpinv_get_discount_uses( $discount->ID ) > 0 ) { |
|
117 | - if ( isset( $row_actions['delete'] ) ) { |
|
118 | - unset( $row_actions['delete'] ); // Don't delete used discounts. |
|
116 | + if (wpinv_get_discount_uses($discount->ID) > 0) { |
|
117 | + if (isset($row_actions['delete'])) { |
|
118 | + unset($row_actions['delete']); // Don't delete used discounts. |
|
119 | 119 | } |
120 | 120 | } else { |
121 | - $row_actions['delete'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'delete_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Delete', 'invoicing' ) . '</a>'; |
|
121 | + $row_actions['delete'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'delete_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Delete', 'invoicing') . '</a>'; |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | |
125 | - $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount ); |
|
125 | + $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount); |
|
126 | 126 | |
127 | 127 | return $row_actions; |
128 | 128 | } |
129 | 129 | |
130 | -add_filter( 'list_table_primary_column', 'wpinv_table_primary_column', 10, 2 ); |
|
131 | -function wpinv_table_primary_column( $default, $screen_id ) { |
|
132 | - if ( 'edit-wpi_invoice' === $screen_id ) { |
|
130 | +add_filter('list_table_primary_column', 'wpinv_table_primary_column', 10, 2); |
|
131 | +function wpinv_table_primary_column($default, $screen_id) { |
|
132 | + if ('edit-wpi_invoice' === $screen_id) { |
|
133 | 133 | return 'name'; |
134 | 134 | } |
135 | 135 | |
136 | 136 | return $default; |
137 | 137 | } |
138 | 138 | |
139 | -function wpinv_discount_bulk_actions( $actions, $display = false ) { |
|
140 | - if ( !$display ) { |
|
139 | +function wpinv_discount_bulk_actions($actions, $display = false) { |
|
140 | + if (!$display) { |
|
141 | 141 | return array(); |
142 | 142 | } |
143 | 143 | |
144 | 144 | $actions = array( |
145 | - 'activate' => __( 'Activate', 'invoicing' ), |
|
146 | - 'deactivate' => __( 'Deactivate', 'invoicing' ), |
|
147 | - 'delete' => __( 'Delete', 'invoicing' ), |
|
145 | + 'activate' => __('Activate', 'invoicing'), |
|
146 | + 'deactivate' => __('Deactivate', 'invoicing'), |
|
147 | + 'delete' => __('Delete', 'invoicing'), |
|
148 | 148 | ); |
149 | 149 | $two = ''; |
150 | 150 | $which = 'top'; |
151 | 151 | echo '</div><div class="alignleft actions bulkactions">'; |
152 | - echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>'; |
|
153 | - echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">"; |
|
154 | - echo '<option value="-1">' . __( 'Bulk Actions' ) . "</option>"; |
|
152 | + echo '<label for="bulk-action-selector-' . esc_attr($which) . '" class="screen-reader-text">' . __('Select bulk action') . '</label>'; |
|
153 | + echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr($which) . "\">"; |
|
154 | + echo '<option value="-1">' . __('Bulk Actions') . "</option>"; |
|
155 | 155 | |
156 | - foreach ( $actions as $name => $title ) { |
|
156 | + foreach ($actions as $name => $title) { |
|
157 | 157 | $class = 'edit' === $name ? ' class="hide-if-no-js"' : ''; |
158 | 158 | |
159 | 159 | echo "" . '<option value="' . $name . '"' . $class . '>' . $title . "</option>"; |
160 | 160 | } |
161 | 161 | echo "</select>"; |
162 | 162 | |
163 | - submit_button( __( 'Apply' ), 'action', '', false, array( 'id' => "doaction$two" ) ); |
|
163 | + submit_button(__('Apply'), 'action', '', false, array('id' => "doaction$two")); |
|
164 | 164 | |
165 | 165 | echo '</div><div class="alignleft actions">'; |
166 | 166 | } |
167 | -add_filter( 'bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10 ); |
|
167 | +add_filter('bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10); |
|
168 | 168 | |
169 | -function wpinv_disable_months_dropdown( $disable, $post_type ) { |
|
170 | - if ( $post_type == 'wpi_discount' ) { |
|
169 | +function wpinv_disable_months_dropdown($disable, $post_type) { |
|
170 | + if ($post_type == 'wpi_discount') { |
|
171 | 171 | $disable = true; |
172 | 172 | } |
173 | 173 | |
174 | 174 | return $disable; |
175 | 175 | } |
176 | -add_filter( 'disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2 ); |
|
176 | +add_filter('disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2); |
|
177 | 177 | |
178 | 178 | function wpinv_restrict_manage_posts() { |
179 | 179 | global $typenow; |
180 | 180 | |
181 | - if( 'wpi_discount' == $typenow ) { |
|
181 | + if ('wpi_discount' == $typenow) { |
|
182 | 182 | wpinv_discount_filters(); |
183 | 183 | } |
184 | 184 | } |
185 | -add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 ); |
|
185 | +add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10); |
|
186 | 186 | |
187 | 187 | function wpinv_discount_filters() { |
188 | - echo wpinv_discount_bulk_actions( array(), true ); |
|
188 | + echo wpinv_discount_bulk_actions(array(), true); |
|
189 | 189 | |
190 | 190 | ?> |
191 | 191 | <select name="discount_type" id="dropdown_wpinv_discount_type"> |
192 | - <option value=""><?php _e( 'Show all types', 'invoicing' ); ?></option> |
|
192 | + <option value=""><?php _e('Show all types', 'invoicing'); ?></option> |
|
193 | 193 | <?php |
194 | 194 | $types = wpinv_get_discount_types(); |
195 | 195 | |
196 | - foreach ( $types as $name => $type ) { |
|
197 | - echo '<option value="' . esc_attr( $name ) . '"'; |
|
196 | + foreach ($types as $name => $type) { |
|
197 | + echo '<option value="' . esc_attr($name) . '"'; |
|
198 | 198 | |
199 | - if ( isset( $_GET['discount_type'] ) ) |
|
200 | - selected( $name, $_GET['discount_type'] ); |
|
199 | + if (isset($_GET['discount_type'])) |
|
200 | + selected($name, $_GET['discount_type']); |
|
201 | 201 | |
202 | - echo '>' . esc_html__( $type, 'invoicing' ) . '</option>'; |
|
202 | + echo '>' . esc_html__($type, 'invoicing') . '</option>'; |
|
203 | 203 | } |
204 | 204 | ?> |
205 | 205 | </select> |
206 | 206 | <?php |
207 | 207 | } |
208 | 208 | |
209 | -function wpinv_request( $vars ) { |
|
209 | +function wpinv_request($vars) { |
|
210 | 210 | global $typenow, $wp_query, $wp_post_statuses; |
211 | 211 | |
212 | - if ( 'wpi_invoice' === $typenow or 'wpi_quote' === $typenow ) { |
|
213 | - if ( !isset( $vars['post_status'] ) ) { |
|
212 | + if ('wpi_invoice' === $typenow or 'wpi_quote' === $typenow) { |
|
213 | + if (!isset($vars['post_status'])) { |
|
214 | 214 | $post_statuses = wpinv_get_invoice_statuses(); |
215 | 215 | |
216 | - foreach ( $post_statuses as $status => $value ) { |
|
217 | - if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) { |
|
218 | - unset( $post_statuses[ $status ] ); |
|
216 | + foreach ($post_statuses as $status => $value) { |
|
217 | + if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) { |
|
218 | + unset($post_statuses[$status]); |
|
219 | 219 | } |
220 | 220 | } |
221 | 221 | |
222 | - $vars['post_status'] = array_keys( $post_statuses ); |
|
222 | + $vars['post_status'] = array_keys($post_statuses); |
|
223 | 223 | } |
224 | 224 | |
225 | - if ( isset( $vars['orderby'] ) ) { |
|
226 | - if ( 'amount' == $vars['orderby'] ) { |
|
225 | + if (isset($vars['orderby'])) { |
|
226 | + if ('amount' == $vars['orderby']) { |
|
227 | 227 | $vars = array_merge( |
228 | 228 | $vars, |
229 | 229 | array( |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | 'orderby' => 'meta_value_num' |
232 | 232 | ) |
233 | 233 | ); |
234 | - } else if ( 'customer' == $vars['orderby'] ) { |
|
234 | + } else if ('customer' == $vars['orderby']) { |
|
235 | 235 | $vars = array_merge( |
236 | 236 | $vars, |
237 | 237 | array( |
@@ -241,9 +241,9 @@ discard block |
||
241 | 241 | ); |
242 | 242 | } |
243 | 243 | } |
244 | - } else if ( 'wpi_item' == $typenow ) { |
|
244 | + } else if ('wpi_item' == $typenow) { |
|
245 | 245 | // Check if 'orderby' is set to "price" |
246 | - if ( isset( $vars['orderby'] ) && 'price' == $vars['orderby'] ) { |
|
246 | + if (isset($vars['orderby']) && 'price' == $vars['orderby']) { |
|
247 | 247 | $vars = array_merge( |
248 | 248 | $vars, |
249 | 249 | array( |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | } |
255 | 255 | |
256 | 256 | // Check if "orderby" is set to "vat_rule" |
257 | - if ( isset( $vars['orderby'] ) && 'vat_rule' == $vars['orderby'] ) { |
|
257 | + if (isset($vars['orderby']) && 'vat_rule' == $vars['orderby']) { |
|
258 | 258 | $vars = array_merge( |
259 | 259 | $vars, |
260 | 260 | array( |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | } |
266 | 266 | |
267 | 267 | // Check if "orderby" is set to "vat_class" |
268 | - if ( isset( $vars['orderby'] ) && 'vat_class' == $vars['orderby'] ) { |
|
268 | + if (isset($vars['orderby']) && 'vat_class' == $vars['orderby']) { |
|
269 | 269 | $vars = array_merge( |
270 | 270 | $vars, |
271 | 271 | array( |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | } |
277 | 277 | |
278 | 278 | // Check if "orderby" is set to "type" |
279 | - if ( isset( $vars['orderby'] ) && 'type' == $vars['orderby'] ) { |
|
279 | + if (isset($vars['orderby']) && 'type' == $vars['orderby']) { |
|
280 | 280 | $vars = array_merge( |
281 | 281 | $vars, |
282 | 282 | array( |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | } |
288 | 288 | |
289 | 289 | // Check if "orderby" is set to "recurring" |
290 | - if ( isset( $vars['orderby'] ) && 'recurring' == $vars['orderby'] ) { |
|
290 | + if (isset($vars['orderby']) && 'recurring' == $vars['orderby']) { |
|
291 | 291 | $vars = array_merge( |
292 | 292 | $vars, |
293 | 293 | array( |
@@ -297,120 +297,120 @@ discard block |
||
297 | 297 | ); |
298 | 298 | } |
299 | 299 | |
300 | - $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array(); |
|
300 | + $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array(); |
|
301 | 301 | // Filter vat rule type |
302 | - if ( isset( $_GET['vat_rule'] ) && $_GET['vat_rule'] !== '' ) { |
|
302 | + if (isset($_GET['vat_rule']) && $_GET['vat_rule'] !== '') { |
|
303 | 303 | $meta_query[] = array( |
304 | 304 | 'key' => '_wpinv_vat_rule', |
305 | - 'value' => sanitize_text_field( $_GET['vat_rule'] ), |
|
305 | + 'value' => sanitize_text_field($_GET['vat_rule']), |
|
306 | 306 | 'compare' => '=' |
307 | 307 | ); |
308 | 308 | } |
309 | 309 | |
310 | 310 | // Filter vat class |
311 | - if ( isset( $_GET['vat_class'] ) && $_GET['vat_class'] !== '' ) { |
|
311 | + if (isset($_GET['vat_class']) && $_GET['vat_class'] !== '') { |
|
312 | 312 | $meta_query[] = array( |
313 | 313 | 'key' => '_wpinv_vat_class', |
314 | - 'value' => sanitize_text_field( $_GET['vat_class'] ), |
|
314 | + 'value' => sanitize_text_field($_GET['vat_class']), |
|
315 | 315 | 'compare' => '=' |
316 | 316 | ); |
317 | 317 | } |
318 | 318 | |
319 | 319 | // Filter item type |
320 | - if ( isset( $_GET['type'] ) && $_GET['type'] !== '' ) { |
|
320 | + if (isset($_GET['type']) && $_GET['type'] !== '') { |
|
321 | 321 | $meta_query[] = array( |
322 | 322 | 'key' => '_wpinv_type', |
323 | - 'value' => sanitize_text_field( $_GET['type'] ), |
|
323 | + 'value' => sanitize_text_field($_GET['type']), |
|
324 | 324 | 'compare' => '=' |
325 | 325 | ); |
326 | 326 | } |
327 | 327 | |
328 | - if ( !empty( $meta_query ) ) { |
|
328 | + if (!empty($meta_query)) { |
|
329 | 329 | $vars['meta_query'] = $meta_query; |
330 | 330 | } |
331 | - } else if ( 'wpi_discount' == $typenow ) { |
|
332 | - $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array(); |
|
331 | + } else if ('wpi_discount' == $typenow) { |
|
332 | + $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array(); |
|
333 | 333 | // Filter vat rule type |
334 | - if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) { |
|
334 | + if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') { |
|
335 | 335 | $meta_query[] = array( |
336 | 336 | 'key' => '_wpi_discount_type', |
337 | - 'value' => sanitize_text_field( $_GET['discount_type'] ), |
|
337 | + 'value' => sanitize_text_field($_GET['discount_type']), |
|
338 | 338 | 'compare' => '=' |
339 | 339 | ); |
340 | 340 | } |
341 | 341 | |
342 | - if ( !empty( $meta_query ) ) { |
|
342 | + if (!empty($meta_query)) { |
|
343 | 343 | $vars['meta_query'] = $meta_query; |
344 | 344 | } |
345 | 345 | } |
346 | 346 | |
347 | 347 | return $vars; |
348 | 348 | } |
349 | -add_filter( 'request', 'wpinv_request' ); |
|
349 | +add_filter('request', 'wpinv_request'); |
|
350 | 350 | |
351 | 351 | function wpinv_options_page() { |
352 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
352 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
353 | 353 | |
354 | - if ( $page !== 'wpinv-settings' ) { |
|
354 | + if ($page !== 'wpinv-settings') { |
|
355 | 355 | return; |
356 | 356 | } |
357 | 357 | |
358 | 358 | $settings_tabs = wpinv_get_settings_tabs(); |
359 | 359 | $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs; |
360 | - $active_tab = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general'; |
|
361 | - $sections = wpinv_get_settings_tab_sections( $active_tab ); |
|
360 | + $active_tab = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general'; |
|
361 | + $sections = wpinv_get_settings_tab_sections($active_tab); |
|
362 | 362 | $key = 'main'; |
363 | 363 | |
364 | - if ( is_array( $sections ) ) { |
|
365 | - $key = key( $sections ); |
|
364 | + if (is_array($sections)) { |
|
365 | + $key = key($sections); |
|
366 | 366 | } |
367 | 367 | |
368 | - $registered_sections = wpinv_get_settings_tab_sections( $active_tab ); |
|
369 | - $section = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? $_GET['section'] : $key; |
|
368 | + $registered_sections = wpinv_get_settings_tab_sections($active_tab); |
|
369 | + $section = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? $_GET['section'] : $key; |
|
370 | 370 | ob_start(); |
371 | 371 | ?> |
372 | 372 | <div class="wrap"> |
373 | 373 | <h1 class="nav-tab-wrapper"> |
374 | 374 | <?php |
375 | - foreach( wpinv_get_settings_tabs() as $tab_id => $tab_name ) { |
|
376 | - $tab_url = add_query_arg( array( |
|
375 | + foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) { |
|
376 | + $tab_url = add_query_arg(array( |
|
377 | 377 | 'settings-updated' => false, |
378 | 378 | 'tab' => $tab_id, |
379 | - ) ); |
|
379 | + )); |
|
380 | 380 | |
381 | 381 | // Remove the section from the tabs so we always end up at the main section |
382 | - $tab_url = remove_query_arg( 'section', $tab_url ); |
|
383 | - $tab_url = remove_query_arg( 'wpi_sub', $tab_url ); |
|
382 | + $tab_url = remove_query_arg('section', $tab_url); |
|
383 | + $tab_url = remove_query_arg('wpi_sub', $tab_url); |
|
384 | 384 | |
385 | 385 | $active = $active_tab == $tab_id ? ' nav-tab-active' : ''; |
386 | 386 | |
387 | - echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">'; |
|
388 | - echo esc_html( $tab_name ); |
|
387 | + echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">'; |
|
388 | + echo esc_html($tab_name); |
|
389 | 389 | echo '</a>'; |
390 | 390 | } |
391 | 391 | ?> |
392 | 392 | </h1> |
393 | 393 | <?php |
394 | - $number_of_sections = count( $sections ); |
|
394 | + $number_of_sections = count($sections); |
|
395 | 395 | $number = 0; |
396 | - if ( $number_of_sections > 1 ) { |
|
396 | + if ($number_of_sections > 1) { |
|
397 | 397 | echo '<div><ul class="subsubsub">'; |
398 | - foreach( $sections as $section_id => $section_name ) { |
|
398 | + foreach ($sections as $section_id => $section_name) { |
|
399 | 399 | echo '<li>'; |
400 | 400 | $number++; |
401 | - $tab_url = add_query_arg( array( |
|
401 | + $tab_url = add_query_arg(array( |
|
402 | 402 | 'settings-updated' => false, |
403 | 403 | 'tab' => $active_tab, |
404 | 404 | 'section' => $section_id |
405 | - ) ); |
|
406 | - $tab_url = remove_query_arg( 'wpi_sub', $tab_url ); |
|
405 | + )); |
|
406 | + $tab_url = remove_query_arg('wpi_sub', $tab_url); |
|
407 | 407 | $class = ''; |
408 | - if ( $section == $section_id ) { |
|
408 | + if ($section == $section_id) { |
|
409 | 409 | $class = 'current'; |
410 | 410 | } |
411 | - echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>'; |
|
411 | + echo '<a class="' . $class . '" href="' . esc_url($tab_url) . '">' . $section_name . '</a>'; |
|
412 | 412 | |
413 | - if ( $number != $number_of_sections ) { |
|
413 | + if ($number != $number_of_sections) { |
|
414 | 414 | echo ' | '; |
415 | 415 | } |
416 | 416 | echo '</li>'; |
@@ -422,19 +422,19 @@ discard block |
||
422 | 422 | <form method="post" action="options.php"> |
423 | 423 | <table class="form-table"> |
424 | 424 | <?php |
425 | - settings_fields( 'wpinv_settings' ); |
|
425 | + settings_fields('wpinv_settings'); |
|
426 | 426 | |
427 | - if ( 'main' === $section ) { |
|
428 | - do_action( 'wpinv_settings_tab_top', $active_tab ); |
|
427 | + if ('main' === $section) { |
|
428 | + do_action('wpinv_settings_tab_top', $active_tab); |
|
429 | 429 | } |
430 | 430 | |
431 | - do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section ); |
|
432 | - do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section ); |
|
433 | - do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section ); |
|
431 | + do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section); |
|
432 | + do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section); |
|
433 | + do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section); |
|
434 | 434 | |
435 | 435 | // For backwards compatibility |
436 | - if ( 'main' === $section ) { |
|
437 | - do_action( 'wpinv_settings_tab_bottom', $active_tab ); |
|
436 | + if ('main' === $section) { |
|
437 | + do_action('wpinv_settings_tab_bottom', $active_tab); |
|
438 | 438 | } |
439 | 439 | ?> |
440 | 440 | </table> |
@@ -447,12 +447,12 @@ discard block |
||
447 | 447 | echo $content; |
448 | 448 | } |
449 | 449 | |
450 | -function wpinv_item_type_class( $classes, $class, $post_id ) { |
|
450 | +function wpinv_item_type_class($classes, $class, $post_id) { |
|
451 | 451 | global $pagenow, $typenow; |
452 | 452 | |
453 | - if ( $pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type( $post_id ) == $typenow && $type = get_post_meta( $post_id, '_wpinv_type', true ) ) { |
|
454 | - $classes[] = 'wpi-type-' . sanitize_html_class( $type ); |
|
453 | + if ($pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type($post_id) == $typenow && $type = get_post_meta($post_id, '_wpinv_type', true)) { |
|
454 | + $classes[] = 'wpi-type-' . sanitize_html_class($type); |
|
455 | 455 | } |
456 | 456 | return $classes; |
457 | 457 | } |
458 | -add_filter( 'post_class', 'wpinv_item_type_class', 10, 3 ); |
|
459 | 458 | \ No newline at end of file |
459 | +add_filter('post_class', 'wpinv_item_type_class', 10, 3); |
|
460 | 460 | \ No newline at end of file |
@@ -11,22 +11,22 @@ |
||
11 | 11 | * @since 1.0.0 |
12 | 12 | */ |
13 | 13 | function wpinv_automatic_upgrade() { |
14 | - $wpi_version = get_option( 'wpinv_version' ); |
|
14 | + $wpi_version = get_option('wpinv_version'); |
|
15 | 15 | |
16 | - if ( $wpi_version == WPINV_VERSION ) { |
|
16 | + if ($wpi_version == WPINV_VERSION) { |
|
17 | 17 | return; |
18 | 18 | } |
19 | 19 | |
20 | - if ( version_compare( $wpi_version, '0.0.5', '<' ) ) { |
|
20 | + if (version_compare($wpi_version, '0.0.5', '<')) { |
|
21 | 21 | wpinv_v005_upgrades(); |
22 | 22 | } |
23 | 23 | |
24 | - update_option( 'wpinv_version', WPINV_VERSION ); |
|
24 | + update_option('wpinv_version', WPINV_VERSION); |
|
25 | 25 | } |
26 | -add_action( 'admin_init', 'wpinv_automatic_upgrade' ); |
|
26 | +add_action('admin_init', 'wpinv_automatic_upgrade'); |
|
27 | 27 | |
28 | 28 | function wpinv_v005_upgrades() { |
29 | 29 | global $wpdb; |
30 | 30 | |
31 | - $wpdb->query( "UPDATE " . $wpdb->posts . " SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" ); |
|
31 | + $wpdb->query("UPDATE " . $wpdb->posts . " SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )"); |
|
32 | 32 | } |
33 | 33 | \ No newline at end of file |
@@ -1,26 +1,26 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // Exit if accessed directly |
3 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
3 | +if (!defined('ABSPATH')) exit; |
|
4 | 4 | |
5 | -function wpinv_user_invoices( $current_page = 1 ) { |
|
5 | +function wpinv_user_invoices($current_page = 1) { |
|
6 | 6 | global $current_page; |
7 | - wpinv_get_template_part( 'wpinv-invoice-history' ); |
|
7 | + wpinv_get_template_part('wpinv-invoice-history'); |
|
8 | 8 | } |
9 | 9 | |
10 | -function wpinv_get_users_invoices( $user = 0, $number = 20, $pagination = false, $status = 'publish' ) { |
|
11 | - if ( empty( $user ) ) { |
|
10 | +function wpinv_get_users_invoices($user = 0, $number = 20, $pagination = false, $status = 'publish') { |
|
11 | + if (empty($user)) { |
|
12 | 12 | $user = get_current_user_id(); |
13 | 13 | } |
14 | 14 | |
15 | - if ( 0 === $user ) { |
|
15 | + if (0 === $user) { |
|
16 | 16 | return false; |
17 | 17 | } |
18 | 18 | |
19 | - if ( $pagination ) { |
|
20 | - if ( get_query_var( 'paged' ) ) |
|
19 | + if ($pagination) { |
|
20 | + if (get_query_var('paged')) |
|
21 | 21 | $paged = get_query_var('paged'); |
22 | - else if ( get_query_var( 'page' ) ) |
|
23 | - $paged = get_query_var( 'page' ); |
|
22 | + else if (get_query_var('page')) |
|
23 | + $paged = get_query_var('page'); |
|
24 | 24 | else |
25 | 25 | $paged = 1; |
26 | 26 | } |
@@ -29,21 +29,21 @@ discard block |
||
29 | 29 | 'post_type' => 'wpi_invoice', |
30 | 30 | 'posts_per_page' => 20, |
31 | 31 | 'paged' => null, |
32 | - 'post_status' => array( 'publish', 'pending' ), |
|
32 | + 'post_status' => array('publish', 'pending'), |
|
33 | 33 | 'user' => $user, |
34 | 34 | 'order' => 'date', |
35 | 35 | ); |
36 | 36 | |
37 | - $invoices = get_posts( $args ); |
|
37 | + $invoices = get_posts($args); |
|
38 | 38 | |
39 | 39 | // No invoices |
40 | - if ( ! $invoices ) |
|
40 | + if (!$invoices) |
|
41 | 41 | return false; |
42 | 42 | |
43 | 43 | return $invoices; |
44 | 44 | } |
45 | 45 | |
46 | -function wpinv_dropdown_users( $args = '' ) { |
|
46 | +function wpinv_dropdown_users($args = '') { |
|
47 | 47 | $defaults = array( |
48 | 48 | 'show_option_all' => '', 'show_option_none' => '', 'hide_if_only_one_author' => '', |
49 | 49 | 'orderby' => 'display_name', 'order' => 'ASC', |
@@ -54,18 +54,18 @@ discard block |
||
54 | 54 | 'option_none_value' => -1 |
55 | 55 | ); |
56 | 56 | |
57 | - $defaults['selected'] = is_author() ? get_query_var( 'author' ) : 0; |
|
57 | + $defaults['selected'] = is_author() ? get_query_var('author') : 0; |
|
58 | 58 | |
59 | - $r = wp_parse_args( $args, $defaults ); |
|
59 | + $r = wp_parse_args($args, $defaults); |
|
60 | 60 | |
61 | - $query_args = wp_array_slice_assoc( $r, array( 'blog_id', 'include', 'exclude', 'orderby', 'order', 'who' ) ); |
|
61 | + $query_args = wp_array_slice_assoc($r, array('blog_id', 'include', 'exclude', 'orderby', 'order', 'who')); |
|
62 | 62 | |
63 | - $fields = array( 'ID', 'user_login', 'user_email' ); |
|
63 | + $fields = array('ID', 'user_login', 'user_email'); |
|
64 | 64 | |
65 | - $show = ! empty( $r['show'] ) ? $r['show'] : 'display_name'; |
|
66 | - if ( 'display_name_with_login' === $show ) { |
|
65 | + $show = !empty($r['show']) ? $r['show'] : 'display_name'; |
|
66 | + if ('display_name_with_login' === $show) { |
|
67 | 67 | $fields[] = 'display_name'; |
68 | - } else if ( 'display_name_with_email' === $show ) { |
|
68 | + } else if ('display_name_with_email' === $show) { |
|
69 | 69 | $fields[] = 'display_name'; |
70 | 70 | } else { |
71 | 71 | $fields[] = $show; |
@@ -77,99 +77,99 @@ discard block |
||
77 | 77 | $show_option_none = $r['show_option_none']; |
78 | 78 | $option_none_value = $r['option_none_value']; |
79 | 79 | |
80 | - $query_args = apply_filters( 'wpinv_dropdown_users_args', $query_args, $r ); |
|
80 | + $query_args = apply_filters('wpinv_dropdown_users_args', $query_args, $r); |
|
81 | 81 | |
82 | - $users = get_users( $query_args ); |
|
82 | + $users = get_users($query_args); |
|
83 | 83 | |
84 | 84 | $output = ''; |
85 | - if ( ! empty( $users ) && ( empty( $r['hide_if_only_one_author'] ) || count( $users ) > 1 ) ) { |
|
86 | - $name = esc_attr( $r['name'] ); |
|
87 | - if ( $r['multi'] && ! $r['id'] ) { |
|
85 | + if (!empty($users) && (empty($r['hide_if_only_one_author']) || count($users) > 1)) { |
|
86 | + $name = esc_attr($r['name']); |
|
87 | + if ($r['multi'] && !$r['id']) { |
|
88 | 88 | $id = ''; |
89 | 89 | } else { |
90 | - $id = $r['id'] ? " id='" . esc_attr( $r['id'] ) . "'" : " id='$name'"; |
|
90 | + $id = $r['id'] ? " id='" . esc_attr($r['id']) . "'" : " id='$name'"; |
|
91 | 91 | } |
92 | 92 | $output = "<select name='{$name}'{$id} class='" . $r['class'] . "'>\n"; |
93 | 93 | |
94 | - if ( $show_option_all ) { |
|
94 | + if ($show_option_all) { |
|
95 | 95 | $output .= "\t<option value='0'>$show_option_all</option>\n"; |
96 | 96 | } |
97 | 97 | |
98 | - if ( $show_option_none ) { |
|
99 | - $_selected = selected( $option_none_value, $r['selected'], false ); |
|
100 | - $output .= "\t<option value='" . esc_attr( $option_none_value ) . "'$_selected>$show_option_none</option>\n"; |
|
98 | + if ($show_option_none) { |
|
99 | + $_selected = selected($option_none_value, $r['selected'], false); |
|
100 | + $output .= "\t<option value='" . esc_attr($option_none_value) . "'$_selected>$show_option_none</option>\n"; |
|
101 | 101 | } |
102 | 102 | |
103 | - if ( $r['include_selected'] && ( $r['selected'] > 0 ) ) { |
|
103 | + if ($r['include_selected'] && ($r['selected'] > 0)) { |
|
104 | 104 | $found_selected = false; |
105 | - $r['selected'] = (int) $r['selected']; |
|
106 | - foreach ( (array) $users as $user ) { |
|
107 | - $user->ID = (int) $user->ID; |
|
108 | - if ( $user->ID === $r['selected'] ) { |
|
105 | + $r['selected'] = (int)$r['selected']; |
|
106 | + foreach ((array)$users as $user) { |
|
107 | + $user->ID = (int)$user->ID; |
|
108 | + if ($user->ID === $r['selected']) { |
|
109 | 109 | $found_selected = true; |
110 | 110 | } |
111 | 111 | } |
112 | 112 | |
113 | - if ( ! $found_selected ) { |
|
114 | - $users[] = get_userdata( $r['selected'] ); |
|
113 | + if (!$found_selected) { |
|
114 | + $users[] = get_userdata($r['selected']); |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
118 | - foreach ( (array) $users as $user ) { |
|
119 | - if ( 'display_name_with_login' === $show ) { |
|
118 | + foreach ((array)$users as $user) { |
|
119 | + if ('display_name_with_login' === $show) { |
|
120 | 120 | /* translators: 1: display name, 2: user_login */ |
121 | - $display = sprintf( _x( '%1$s (%2$s)', 'user dropdown' ), $user->display_name, $user->user_login ); |
|
122 | - } elseif ( 'display_name_with_email' === $show ) { |
|
121 | + $display = sprintf(_x('%1$s (%2$s)', 'user dropdown'), $user->display_name, $user->user_login); |
|
122 | + } elseif ('display_name_with_email' === $show) { |
|
123 | 123 | /* translators: 1: display name, 2: user_email */ |
124 | - if ( $user->display_name == $user->user_email ) { |
|
124 | + if ($user->display_name == $user->user_email) { |
|
125 | 125 | $display = $user->display_name; |
126 | 126 | } else { |
127 | - $display = sprintf( _x( '%1$s (%2$s)', 'user dropdown' ), $user->display_name, $user->user_email ); |
|
127 | + $display = sprintf(_x('%1$s (%2$s)', 'user dropdown'), $user->display_name, $user->user_email); |
|
128 | 128 | } |
129 | - } elseif ( ! empty( $user->$show ) ) { |
|
129 | + } elseif (!empty($user->$show)) { |
|
130 | 130 | $display = $user->$show; |
131 | 131 | } else { |
132 | 132 | $display = '(' . $user->user_login . ')'; |
133 | 133 | } |
134 | 134 | |
135 | - $_selected = selected( $user->ID, $r['selected'], false ); |
|
136 | - $output .= "\t<option value='$user->ID'$_selected>" . esc_html( $display ) . "</option>\n"; |
|
135 | + $_selected = selected($user->ID, $r['selected'], false); |
|
136 | + $output .= "\t<option value='$user->ID'$_selected>" . esc_html($display) . "</option>\n"; |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | $output .= "</select>"; |
140 | 140 | } |
141 | 141 | |
142 | - $html = apply_filters( 'wpinv_dropdown_users', $output ); |
|
142 | + $html = apply_filters('wpinv_dropdown_users', $output); |
|
143 | 143 | |
144 | - if ( $r['echo'] ) { |
|
144 | + if ($r['echo']) { |
|
145 | 145 | echo $html; |
146 | 146 | } |
147 | 147 | return $html; |
148 | 148 | } |
149 | 149 | |
150 | -function wpinv_guest_redirect( $redirect_to, $user_id = 0 ) { |
|
151 | - if ( (int)wpinv_get_option( 'guest_checkout' ) && $user_id > 0 ) { |
|
152 | - wpinv_login_user( $user_id ); |
|
150 | +function wpinv_guest_redirect($redirect_to, $user_id = 0) { |
|
151 | + if ((int)wpinv_get_option('guest_checkout') && $user_id > 0) { |
|
152 | + wpinv_login_user($user_id); |
|
153 | 153 | } else { |
154 | - $redirect_to = wp_login_url( $redirect_to ); |
|
154 | + $redirect_to = wp_login_url($redirect_to); |
|
155 | 155 | } |
156 | 156 | |
157 | - $redirect_to = apply_filters( 'wpinv_invoice_link_guest_redirect', $redirect_to, $user_id ); |
|
157 | + $redirect_to = apply_filters('wpinv_invoice_link_guest_redirect', $redirect_to, $user_id); |
|
158 | 158 | |
159 | - wp_redirect( $redirect_to ); |
|
159 | + wp_redirect($redirect_to); |
|
160 | 160 | } |
161 | 161 | |
162 | -function wpinv_login_user( $user_id ) { |
|
163 | - if ( is_user_logged_in() ) { |
|
162 | +function wpinv_login_user($user_id) { |
|
163 | + if (is_user_logged_in()) { |
|
164 | 164 | return true; |
165 | 165 | } |
166 | 166 | |
167 | - $user = get_user_by( 'id', $user_id ); |
|
167 | + $user = get_user_by('id', $user_id); |
|
168 | 168 | |
169 | - if ( !empty( $user ) && !is_wp_error( $user ) && !empty( $user->user_login ) ) { |
|
170 | - wp_set_current_user( $user_id, $user->user_login ); |
|
171 | - wp_set_auth_cookie( $user_id ); |
|
172 | - do_action( 'wp_login', $user->user_login ); |
|
169 | + if (!empty($user) && !is_wp_error($user) && !empty($user->user_login)) { |
|
170 | + wp_set_current_user($user_id, $user->user_login); |
|
171 | + wp_set_auth_cookie($user_id); |
|
172 | + do_action('wp_login', $user->user_login); |
|
173 | 173 | |
174 | 174 | return true; |
175 | 175 | } |