@@ -12,231 +12,231 @@ |
||
12 | 12 | */ |
13 | 13 | class GetPaid_Payment_Form_Submission_Taxes { |
14 | 14 | |
15 | - /** |
|
16 | - * Submission taxes. |
|
17 | - * @var array |
|
18 | - */ |
|
19 | - public $taxes = array(); |
|
20 | - |
|
21 | - /** |
|
22 | - * Initial tax. |
|
23 | - * @var float |
|
24 | - */ |
|
25 | - protected $initial_tax = 0; |
|
26 | - |
|
27 | - /** |
|
28 | - * Recurring tax. |
|
29 | - * @var float |
|
30 | - */ |
|
31 | - protected $recurring_tax = 0; |
|
15 | + /** |
|
16 | + * Submission taxes. |
|
17 | + * @var array |
|
18 | + */ |
|
19 | + public $taxes = array(); |
|
20 | + |
|
21 | + /** |
|
22 | + * Initial tax. |
|
23 | + * @var float |
|
24 | + */ |
|
25 | + protected $initial_tax = 0; |
|
26 | + |
|
27 | + /** |
|
28 | + * Recurring tax. |
|
29 | + * @var float |
|
30 | + */ |
|
31 | + protected $recurring_tax = 0; |
|
32 | + |
|
33 | + /** |
|
34 | + * Class constructor |
|
35 | + * |
|
36 | + * @param GetPaid_Payment_Form_Submission $submission |
|
37 | + */ |
|
38 | + public function __construct( $submission ) { |
|
39 | + |
|
40 | + // Validate VAT number. |
|
41 | + $this->validate_vat( $submission ); |
|
42 | + |
|
43 | + foreach ( $submission->get_items() as $item ) { |
|
44 | + $this->process_item_tax( $item, $submission ); |
|
45 | + } |
|
46 | + |
|
47 | + // Process any existing invoice taxes. |
|
48 | + if ( $submission->has_invoice() ) { |
|
49 | + $this->taxes = $submission->get_invoice()->get_taxes(); |
|
50 | + } |
|
51 | + |
|
52 | + // Add VAT. |
|
53 | + $this->taxes['vat'] = array( |
|
54 | + 'name' => 'vat', |
|
55 | + 'initial_tax' => $this->initial_tax, |
|
56 | + 'recurring_tax' => $this->recurring_tax, |
|
57 | + ); |
|
58 | + |
|
59 | + } |
|
60 | + |
|
61 | + /** |
|
62 | + * Maybe process tax. |
|
63 | + * |
|
64 | + * @since 1.0.19 |
|
65 | + * @param GetPaid_Form_Item $item |
|
66 | + * @param GetPaid_Payment_Form_Submission $submission |
|
67 | + */ |
|
68 | + public function process_item_tax( $item, $submission ) { |
|
69 | + |
|
70 | + $rate = wpinv_get_tax_rate( $submission->country, $submission->state, $item->get_id() ); |
|
71 | + $price = $item->get_sub_total(); |
|
72 | + $item_tax = $price * $rate * 0.01; |
|
73 | + |
|
74 | + if ( wpinv_prices_include_tax() ) { |
|
75 | + $item_tax = $price - ( $price - $price * $rate * 0.01 ); |
|
76 | + } |
|
77 | + |
|
78 | + $this->initial_tax += $item_tax; |
|
79 | + |
|
80 | + if ( $item->is_recurring() ) { |
|
81 | + $this->recurring_tax += $item_tax; |
|
82 | + } |
|
83 | + |
|
84 | + } |
|
85 | + |
|
86 | + /** |
|
87 | + * Checks if the submission has a digital item. |
|
88 | + * |
|
89 | + * @param GetPaid_Payment_Form_Submission $submission |
|
90 | + * @since 1.0.19 |
|
91 | + * @return bool |
|
92 | + */ |
|
93 | + public function has_digital_item( $submission ) { |
|
94 | + |
|
95 | + foreach ( $submission->get_items() as $item ) { |
|
96 | + |
|
97 | + if ( 'digital' == $item->get_vat_rule() ) { |
|
98 | + return true; |
|
99 | + } |
|
100 | + |
|
101 | + } |
|
102 | + |
|
103 | + return false; |
|
104 | + } |
|
105 | + |
|
106 | + /** |
|
107 | + * Checks if this is an eu store. |
|
108 | + * |
|
109 | + * @since 1.0.19 |
|
110 | + * @return bool |
|
111 | + */ |
|
112 | + public function is_eu_store() { |
|
113 | + return $this->is_eu_country( wpinv_get_default_country() ); |
|
114 | + } |
|
115 | + |
|
116 | + /** |
|
117 | + * Checks if this is an eu country. |
|
118 | + * |
|
119 | + * @param string $country |
|
120 | + * @since 1.0.19 |
|
121 | + * @return bool |
|
122 | + */ |
|
123 | + public function is_eu_country( $country ) { |
|
124 | + return getpaid_is_eu_state( $country ) || getpaid_is_gst_country( $country ); |
|
125 | + } |
|
126 | + |
|
127 | + /** |
|
128 | + * Checks if this is an eu purchase. |
|
129 | + * |
|
130 | + * @param string $customer_country |
|
131 | + * @since 1.0.19 |
|
132 | + * @return bool |
|
133 | + */ |
|
134 | + public function is_eu_transaction( $customer_country ) { |
|
135 | + return $this->is_eu_country( $customer_country ) && $this->is_eu_store(); |
|
136 | + } |
|
137 | + |
|
138 | + /** |
|
139 | + * Retrieves the vat number. |
|
140 | + * |
|
141 | + * @param GetPaid_Payment_Form_Submission $submission |
|
142 | + * @since 1.0.19 |
|
143 | + * @return string |
|
144 | + */ |
|
145 | + public function get_vat_number( $submission ) { |
|
146 | + |
|
147 | + // Retrieve from the posted number. |
|
148 | + $vat_number = $submission->get_field( 'wpinv_vat_number' ); |
|
149 | + if ( ! empty( $vat_number ) ) { |
|
150 | + return wpinv_clean( $vat_number ); |
|
151 | + } |
|
152 | + |
|
153 | + // Retrieve from the invoice. |
|
154 | + return $submission->has_invoice() ? $submission->get_invoice()->get_vat_number() : ''; |
|
155 | + } |
|
156 | + |
|
157 | + /** |
|
158 | + * Retrieves the company. |
|
159 | + * |
|
160 | + * @param GetPaid_Payment_Form_Submission $submission |
|
161 | + * @since 1.0.19 |
|
162 | + * @return string |
|
163 | + */ |
|
164 | + public function get_company( $submission ) { |
|
165 | + |
|
166 | + // Retrieve from the posted data. |
|
167 | + $company = $submission->get_field( 'wpinv_company' ); |
|
168 | + if ( ! empty( $company ) ) { |
|
169 | + return wpinv_clean( $company ); |
|
170 | + } |
|
171 | + |
|
172 | + // Retrieve from the invoice. |
|
173 | + return $submission->has_invoice() ? $submission->get_invoice()->get_company() : ''; |
|
174 | + } |
|
175 | + |
|
176 | + /** |
|
177 | + * Checks if we requires a VAT number. |
|
178 | + * |
|
179 | + * @param bool $ip_in_eu Whether the customer IP is from the EU |
|
180 | + * @param bool $country_in_eu Whether the customer country is from the EU |
|
181 | + * @since 1.0.19 |
|
182 | + * @return string |
|
183 | + */ |
|
184 | + public function requires_vat( $ip_in_eu, $country_in_eu ) { |
|
185 | + |
|
186 | + $prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' ); |
|
187 | + $prevent_b2c = ! empty( $prevent_b2c ); |
|
188 | + $is_eu = $ip_in_eu || $country_in_eu; |
|
189 | + |
|
190 | + return $prevent_b2c && $is_eu; |
|
191 | + } |
|
32 | 192 | |
33 | 193 | /** |
34 | - * Class constructor |
|
35 | - * |
|
36 | - * @param GetPaid_Payment_Form_Submission $submission |
|
37 | - */ |
|
38 | - public function __construct( $submission ) { |
|
39 | - |
|
40 | - // Validate VAT number. |
|
41 | - $this->validate_vat( $submission ); |
|
42 | - |
|
43 | - foreach ( $submission->get_items() as $item ) { |
|
44 | - $this->process_item_tax( $item, $submission ); |
|
45 | - } |
|
46 | - |
|
47 | - // Process any existing invoice taxes. |
|
48 | - if ( $submission->has_invoice() ) { |
|
49 | - $this->taxes = $submission->get_invoice()->get_taxes(); |
|
50 | - } |
|
51 | - |
|
52 | - // Add VAT. |
|
53 | - $this->taxes['vat'] = array( |
|
54 | - 'name' => 'vat', |
|
55 | - 'initial_tax' => $this->initial_tax, |
|
56 | - 'recurring_tax' => $this->recurring_tax, |
|
57 | - ); |
|
58 | - |
|
59 | - } |
|
60 | - |
|
61 | - /** |
|
62 | - * Maybe process tax. |
|
63 | - * |
|
64 | - * @since 1.0.19 |
|
65 | - * @param GetPaid_Form_Item $item |
|
66 | - * @param GetPaid_Payment_Form_Submission $submission |
|
67 | - */ |
|
68 | - public function process_item_tax( $item, $submission ) { |
|
69 | - |
|
70 | - $rate = wpinv_get_tax_rate( $submission->country, $submission->state, $item->get_id() ); |
|
71 | - $price = $item->get_sub_total(); |
|
72 | - $item_tax = $price * $rate * 0.01; |
|
73 | - |
|
74 | - if ( wpinv_prices_include_tax() ) { |
|
75 | - $item_tax = $price - ( $price - $price * $rate * 0.01 ); |
|
76 | - } |
|
77 | - |
|
78 | - $this->initial_tax += $item_tax; |
|
79 | - |
|
80 | - if ( $item->is_recurring() ) { |
|
81 | - $this->recurring_tax += $item_tax; |
|
82 | - } |
|
83 | - |
|
84 | - } |
|
85 | - |
|
86 | - /** |
|
87 | - * Checks if the submission has a digital item. |
|
88 | - * |
|
89 | - * @param GetPaid_Payment_Form_Submission $submission |
|
90 | - * @since 1.0.19 |
|
91 | - * @return bool |
|
92 | - */ |
|
93 | - public function has_digital_item( $submission ) { |
|
94 | - |
|
95 | - foreach ( $submission->get_items() as $item ) { |
|
96 | - |
|
97 | - if ( 'digital' == $item->get_vat_rule() ) { |
|
98 | - return true; |
|
99 | - } |
|
100 | - |
|
101 | - } |
|
102 | - |
|
103 | - return false; |
|
104 | - } |
|
105 | - |
|
106 | - /** |
|
107 | - * Checks if this is an eu store. |
|
108 | - * |
|
109 | - * @since 1.0.19 |
|
110 | - * @return bool |
|
111 | - */ |
|
112 | - public function is_eu_store() { |
|
113 | - return $this->is_eu_country( wpinv_get_default_country() ); |
|
114 | - } |
|
115 | - |
|
116 | - /** |
|
117 | - * Checks if this is an eu country. |
|
118 | - * |
|
119 | - * @param string $country |
|
120 | - * @since 1.0.19 |
|
121 | - * @return bool |
|
122 | - */ |
|
123 | - public function is_eu_country( $country ) { |
|
124 | - return getpaid_is_eu_state( $country ) || getpaid_is_gst_country( $country ); |
|
125 | - } |
|
126 | - |
|
127 | - /** |
|
128 | - * Checks if this is an eu purchase. |
|
129 | - * |
|
130 | - * @param string $customer_country |
|
131 | - * @since 1.0.19 |
|
132 | - * @return bool |
|
133 | - */ |
|
134 | - public function is_eu_transaction( $customer_country ) { |
|
135 | - return $this->is_eu_country( $customer_country ) && $this->is_eu_store(); |
|
136 | - } |
|
137 | - |
|
138 | - /** |
|
139 | - * Retrieves the vat number. |
|
140 | - * |
|
141 | - * @param GetPaid_Payment_Form_Submission $submission |
|
142 | - * @since 1.0.19 |
|
143 | - * @return string |
|
144 | - */ |
|
145 | - public function get_vat_number( $submission ) { |
|
146 | - |
|
147 | - // Retrieve from the posted number. |
|
148 | - $vat_number = $submission->get_field( 'wpinv_vat_number' ); |
|
149 | - if ( ! empty( $vat_number ) ) { |
|
150 | - return wpinv_clean( $vat_number ); |
|
151 | - } |
|
152 | - |
|
153 | - // Retrieve from the invoice. |
|
154 | - return $submission->has_invoice() ? $submission->get_invoice()->get_vat_number() : ''; |
|
155 | - } |
|
156 | - |
|
157 | - /** |
|
158 | - * Retrieves the company. |
|
159 | - * |
|
160 | - * @param GetPaid_Payment_Form_Submission $submission |
|
161 | - * @since 1.0.19 |
|
162 | - * @return string |
|
163 | - */ |
|
164 | - public function get_company( $submission ) { |
|
165 | - |
|
166 | - // Retrieve from the posted data. |
|
167 | - $company = $submission->get_field( 'wpinv_company' ); |
|
168 | - if ( ! empty( $company ) ) { |
|
169 | - return wpinv_clean( $company ); |
|
170 | - } |
|
171 | - |
|
172 | - // Retrieve from the invoice. |
|
173 | - return $submission->has_invoice() ? $submission->get_invoice()->get_company() : ''; |
|
174 | - } |
|
175 | - |
|
176 | - /** |
|
177 | - * Checks if we requires a VAT number. |
|
178 | - * |
|
179 | - * @param bool $ip_in_eu Whether the customer IP is from the EU |
|
180 | - * @param bool $country_in_eu Whether the customer country is from the EU |
|
181 | - * @since 1.0.19 |
|
182 | - * @return string |
|
183 | - */ |
|
184 | - public function requires_vat( $ip_in_eu, $country_in_eu ) { |
|
185 | - |
|
186 | - $prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' ); |
|
187 | - $prevent_b2c = ! empty( $prevent_b2c ); |
|
188 | - $is_eu = $ip_in_eu || $country_in_eu; |
|
189 | - |
|
190 | - return $prevent_b2c && $is_eu; |
|
191 | - } |
|
192 | - |
|
193 | - /** |
|
194 | - * Validate VAT data. |
|
195 | - * |
|
196 | - * @param GetPaid_Payment_Form_Submission $submission |
|
197 | - * @since 1.0.19 |
|
198 | - */ |
|
199 | - public function validate_vat( $submission ) { |
|
200 | - |
|
201 | - $has_digital = $this->has_digital_item( $submission ); |
|
202 | - $in_eu = $this->is_eu_transaction( $submission->country ); |
|
203 | - |
|
204 | - // Abort if we are not validating vat numbers. |
|
205 | - if ( ! $has_digital && ! $in_eu ) { |
|
194 | + * Validate VAT data. |
|
195 | + * |
|
196 | + * @param GetPaid_Payment_Form_Submission $submission |
|
197 | + * @since 1.0.19 |
|
198 | + */ |
|
199 | + public function validate_vat( $submission ) { |
|
200 | + |
|
201 | + $has_digital = $this->has_digital_item( $submission ); |
|
202 | + $in_eu = $this->is_eu_transaction( $submission->country ); |
|
203 | + |
|
204 | + // Abort if we are not validating vat numbers. |
|
205 | + if ( ! $has_digital && ! $in_eu ) { |
|
206 | 206 | return; |
207 | - } |
|
207 | + } |
|
208 | 208 | |
209 | - // Prepare variables. |
|
210 | - $vat_number = $this->get_vat_number( $submission ); |
|
211 | - $company = $this->get_company( $submission ); |
|
212 | - $ip_country = getpaid_get_ip_country(); |
|
209 | + // Prepare variables. |
|
210 | + $vat_number = $this->get_vat_number( $submission ); |
|
211 | + $company = $this->get_company( $submission ); |
|
212 | + $ip_country = getpaid_get_ip_country(); |
|
213 | 213 | $is_eu = $this->is_eu_country( $submission->country ); |
214 | 214 | $is_ip_eu = $this->is_eu_country( $ip_country ); |
215 | 215 | |
216 | - // If we're preventing business to consumer purchases, ensure |
|
217 | - if ( $this->requires_vat( $is_ip_eu, $is_eu ) && empty( $vat_number ) ) { |
|
216 | + // If we're preventing business to consumer purchases, ensure |
|
217 | + if ( $this->requires_vat( $is_ip_eu, $is_eu ) && empty( $vat_number ) ) { |
|
218 | 218 | |
219 | - // Ensure that a vat number has been specified. |
|
220 | - throw new Exception( |
|
221 | - wp_sprintf( |
|
222 | - __( 'Please enter your %s number to verify your purchase is by an EU business.', 'invoicing' ), |
|
223 | - getpaid_vat_name() |
|
224 | - ) |
|
225 | - ); |
|
219 | + // Ensure that a vat number has been specified. |
|
220 | + throw new Exception( |
|
221 | + wp_sprintf( |
|
222 | + __( 'Please enter your %s number to verify your purchase is by an EU business.', 'invoicing' ), |
|
223 | + getpaid_vat_name() |
|
224 | + ) |
|
225 | + ); |
|
226 | 226 | |
227 | - } |
|
227 | + } |
|
228 | 228 | |
229 | - // Abort if we are not validating vat (vat number should exist, user should be in eu and business too). |
|
230 | - if ( ! $is_eu || ! $in_eu || empty( $vat_number ) ) { |
|
229 | + // Abort if we are not validating vat (vat number should exist, user should be in eu and business too). |
|
230 | + if ( ! $is_eu || ! $in_eu || empty( $vat_number ) ) { |
|
231 | 231 | return; |
232 | - } |
|
232 | + } |
|
233 | 233 | |
234 | - $is_valid = WPInv_EUVat::validate_vat_number( $vat_number, $company, $submission->country ); |
|
234 | + $is_valid = WPInv_EUVat::validate_vat_number( $vat_number, $company, $submission->country ); |
|
235 | 235 | |
236 | - if ( is_string( $is_valid ) ) { |
|
237 | - throw new Exception( $is_valid ); |
|
238 | - } |
|
236 | + if ( is_string( $is_valid ) ) { |
|
237 | + throw new Exception( $is_valid ); |
|
238 | + } |
|
239 | 239 | |
240 | - } |
|
240 | + } |
|
241 | 241 | |
242 | 242 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Payment form submission taxes class |
@@ -35,17 +35,17 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @param GetPaid_Payment_Form_Submission $submission |
37 | 37 | */ |
38 | - public function __construct( $submission ) { |
|
38 | + public function __construct($submission) { |
|
39 | 39 | |
40 | 40 | // Validate VAT number. |
41 | - $this->validate_vat( $submission ); |
|
41 | + $this->validate_vat($submission); |
|
42 | 42 | |
43 | - foreach ( $submission->get_items() as $item ) { |
|
44 | - $this->process_item_tax( $item, $submission ); |
|
43 | + foreach ($submission->get_items() as $item) { |
|
44 | + $this->process_item_tax($item, $submission); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | // Process any existing invoice taxes. |
48 | - if ( $submission->has_invoice() ) { |
|
48 | + if ($submission->has_invoice()) { |
|
49 | 49 | $this->taxes = $submission->get_invoice()->get_taxes(); |
50 | 50 | } |
51 | 51 | |
@@ -65,19 +65,19 @@ discard block |
||
65 | 65 | * @param GetPaid_Form_Item $item |
66 | 66 | * @param GetPaid_Payment_Form_Submission $submission |
67 | 67 | */ |
68 | - public function process_item_tax( $item, $submission ) { |
|
68 | + public function process_item_tax($item, $submission) { |
|
69 | 69 | |
70 | - $rate = wpinv_get_tax_rate( $submission->country, $submission->state, $item->get_id() ); |
|
70 | + $rate = wpinv_get_tax_rate($submission->country, $submission->state, $item->get_id()); |
|
71 | 71 | $price = $item->get_sub_total(); |
72 | 72 | $item_tax = $price * $rate * 0.01; |
73 | 73 | |
74 | - if ( wpinv_prices_include_tax() ) { |
|
75 | - $item_tax = $price - ( $price - $price * $rate * 0.01 ); |
|
74 | + if (wpinv_prices_include_tax()) { |
|
75 | + $item_tax = $price - ($price - $price * $rate * 0.01); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | $this->initial_tax += $item_tax; |
79 | 79 | |
80 | - if ( $item->is_recurring() ) { |
|
80 | + if ($item->is_recurring()) { |
|
81 | 81 | $this->recurring_tax += $item_tax; |
82 | 82 | } |
83 | 83 | |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | * @since 1.0.19 |
91 | 91 | * @return bool |
92 | 92 | */ |
93 | - public function has_digital_item( $submission ) { |
|
93 | + public function has_digital_item($submission) { |
|
94 | 94 | |
95 | - foreach ( $submission->get_items() as $item ) { |
|
95 | + foreach ($submission->get_items() as $item) { |
|
96 | 96 | |
97 | - if ( 'digital' == $item->get_vat_rule() ) { |
|
97 | + if ('digital' == $item->get_vat_rule()) { |
|
98 | 98 | return true; |
99 | 99 | } |
100 | 100 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * @return bool |
111 | 111 | */ |
112 | 112 | public function is_eu_store() { |
113 | - return $this->is_eu_country( wpinv_get_default_country() ); |
|
113 | + return $this->is_eu_country(wpinv_get_default_country()); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | * @since 1.0.19 |
121 | 121 | * @return bool |
122 | 122 | */ |
123 | - public function is_eu_country( $country ) { |
|
124 | - return getpaid_is_eu_state( $country ) || getpaid_is_gst_country( $country ); |
|
123 | + public function is_eu_country($country) { |
|
124 | + return getpaid_is_eu_state($country) || getpaid_is_gst_country($country); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | * @since 1.0.19 |
132 | 132 | * @return bool |
133 | 133 | */ |
134 | - public function is_eu_transaction( $customer_country ) { |
|
135 | - return $this->is_eu_country( $customer_country ) && $this->is_eu_store(); |
|
134 | + public function is_eu_transaction($customer_country) { |
|
135 | + return $this->is_eu_country($customer_country) && $this->is_eu_store(); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -142,12 +142,12 @@ discard block |
||
142 | 142 | * @since 1.0.19 |
143 | 143 | * @return string |
144 | 144 | */ |
145 | - public function get_vat_number( $submission ) { |
|
145 | + public function get_vat_number($submission) { |
|
146 | 146 | |
147 | 147 | // Retrieve from the posted number. |
148 | - $vat_number = $submission->get_field( 'wpinv_vat_number' ); |
|
149 | - if ( ! empty( $vat_number ) ) { |
|
150 | - return wpinv_clean( $vat_number ); |
|
148 | + $vat_number = $submission->get_field('wpinv_vat_number'); |
|
149 | + if (!empty($vat_number)) { |
|
150 | + return wpinv_clean($vat_number); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | // Retrieve from the invoice. |
@@ -161,12 +161,12 @@ discard block |
||
161 | 161 | * @since 1.0.19 |
162 | 162 | * @return string |
163 | 163 | */ |
164 | - public function get_company( $submission ) { |
|
164 | + public function get_company($submission) { |
|
165 | 165 | |
166 | 166 | // Retrieve from the posted data. |
167 | - $company = $submission->get_field( 'wpinv_company' ); |
|
168 | - if ( ! empty( $company ) ) { |
|
169 | - return wpinv_clean( $company ); |
|
167 | + $company = $submission->get_field('wpinv_company'); |
|
168 | + if (!empty($company)) { |
|
169 | + return wpinv_clean($company); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | // Retrieve from the invoice. |
@@ -181,10 +181,10 @@ discard block |
||
181 | 181 | * @since 1.0.19 |
182 | 182 | * @return string |
183 | 183 | */ |
184 | - public function requires_vat( $ip_in_eu, $country_in_eu ) { |
|
184 | + public function requires_vat($ip_in_eu, $country_in_eu) { |
|
185 | 185 | |
186 | - $prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' ); |
|
187 | - $prevent_b2c = ! empty( $prevent_b2c ); |
|
186 | + $prevent_b2c = wpinv_get_option('vat_prevent_b2c_purchase'); |
|
187 | + $prevent_b2c = !empty($prevent_b2c); |
|
188 | 188 | $is_eu = $ip_in_eu || $country_in_eu; |
189 | 189 | |
190 | 190 | return $prevent_b2c && $is_eu; |
@@ -196,30 +196,30 @@ discard block |
||
196 | 196 | * @param GetPaid_Payment_Form_Submission $submission |
197 | 197 | * @since 1.0.19 |
198 | 198 | */ |
199 | - public function validate_vat( $submission ) { |
|
199 | + public function validate_vat($submission) { |
|
200 | 200 | |
201 | - $has_digital = $this->has_digital_item( $submission ); |
|
202 | - $in_eu = $this->is_eu_transaction( $submission->country ); |
|
201 | + $has_digital = $this->has_digital_item($submission); |
|
202 | + $in_eu = $this->is_eu_transaction($submission->country); |
|
203 | 203 | |
204 | 204 | // Abort if we are not validating vat numbers. |
205 | - if ( ! $has_digital && ! $in_eu ) { |
|
205 | + if (!$has_digital && !$in_eu) { |
|
206 | 206 | return; |
207 | 207 | } |
208 | 208 | |
209 | 209 | // Prepare variables. |
210 | - $vat_number = $this->get_vat_number( $submission ); |
|
211 | - $company = $this->get_company( $submission ); |
|
210 | + $vat_number = $this->get_vat_number($submission); |
|
211 | + $company = $this->get_company($submission); |
|
212 | 212 | $ip_country = getpaid_get_ip_country(); |
213 | - $is_eu = $this->is_eu_country( $submission->country ); |
|
214 | - $is_ip_eu = $this->is_eu_country( $ip_country ); |
|
213 | + $is_eu = $this->is_eu_country($submission->country); |
|
214 | + $is_ip_eu = $this->is_eu_country($ip_country); |
|
215 | 215 | |
216 | 216 | // If we're preventing business to consumer purchases, ensure |
217 | - if ( $this->requires_vat( $is_ip_eu, $is_eu ) && empty( $vat_number ) ) { |
|
217 | + if ($this->requires_vat($is_ip_eu, $is_eu) && empty($vat_number)) { |
|
218 | 218 | |
219 | 219 | // Ensure that a vat number has been specified. |
220 | 220 | throw new Exception( |
221 | 221 | wp_sprintf( |
222 | - __( 'Please enter your %s number to verify your purchase is by an EU business.', 'invoicing' ), |
|
222 | + __('Please enter your %s number to verify your purchase is by an EU business.', 'invoicing'), |
|
223 | 223 | getpaid_vat_name() |
224 | 224 | ) |
225 | 225 | ); |
@@ -227,14 +227,14 @@ discard block |
||
227 | 227 | } |
228 | 228 | |
229 | 229 | // Abort if we are not validating vat (vat number should exist, user should be in eu and business too). |
230 | - if ( ! $is_eu || ! $in_eu || empty( $vat_number ) ) { |
|
230 | + if (!$is_eu || !$in_eu || empty($vat_number)) { |
|
231 | 231 | return; |
232 | 232 | } |
233 | 233 | |
234 | - $is_valid = WPInv_EUVat::validate_vat_number( $vat_number, $company, $submission->country ); |
|
234 | + $is_valid = WPInv_EUVat::validate_vat_number($vat_number, $company, $submission->country); |
|
235 | 235 | |
236 | - if ( is_string( $is_valid ) ) { |
|
237 | - throw new Exception( $is_valid ); |
|
236 | + if (is_string($is_valid)) { |
|
237 | + throw new Exception($is_valid); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | } |
@@ -350,23 +350,23 @@ discard block |
||
350 | 350 | } |
351 | 351 | |
352 | 352 | /** |
353 | - * |
|
354 | - * @deprecated |
|
355 | - */ |
|
353 | + * |
|
354 | + * @deprecated |
|
355 | + */ |
|
356 | 356 | public static function maxmind_folder() { |
357 | 357 | return false; |
358 | 358 | } |
359 | 359 | |
360 | 360 | /** |
361 | - * |
|
362 | - * @deprecated |
|
363 | - */ |
|
361 | + * |
|
362 | + * @deprecated |
|
363 | + */ |
|
364 | 364 | public static function geoip2_download_database() {} |
365 | 365 | |
366 | 366 | /** |
367 | - * |
|
368 | - * @deprecated |
|
369 | - */ |
|
367 | + * |
|
368 | + * @deprecated |
|
369 | + */ |
|
370 | 370 | public static function geoip2_download_file() {} |
371 | 371 | |
372 | 372 | /** |
@@ -1517,7 +1517,7 @@ discard block |
||
1517 | 1517 | $valid_company = $vies_company && $company && ( $vies_company == '---' || strcasecmp( trim( $vies_company ), trim( $company ) ) == 0 ) ? true : false; |
1518 | 1518 | |
1519 | 1519 | if ( ! $valid_company && ! empty( $wpinv_options['vat_disable_company_name_check'] ) ) { |
1520 | - return wp_sprintf( |
|
1520 | + return wp_sprintf( |
|
1521 | 1521 | __( 'The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing' ), |
1522 | 1522 | getpaid_vat_name() |
1523 | 1523 | ); |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | class WPInv_EUVat { |
10 | 10 | |
@@ -24,125 +24,125 @@ discard block |
||
24 | 24 | public function init() { |
25 | 25 | |
26 | 26 | // If this is an admin page... |
27 | - if ( is_admin() ) { |
|
27 | + if (is_admin()) { |
|
28 | 28 | |
29 | 29 | // Register our scripts. |
30 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) ); |
|
31 | - add_action( 'wpinv_settings_sections_taxes', array( $this, 'section_vat_settings' ) ); |
|
32 | - add_action( 'wpinv_settings_taxes', array( $this, 'vat_settings' ) ); |
|
33 | - add_filter( 'wpinv_settings_taxes-vat_sanitize', array( $this, 'sanitize_vat_settings' ) ); |
|
34 | - add_filter( 'wpinv_settings_taxes-vat_rates_sanitize', array( $this, 'sanitize_vat_rates' ) ); |
|
35 | - add_action( 'wp_ajax_wpinv_add_vat_class', array( $this, 'add_class' ) ); |
|
36 | - add_action( 'wp_ajax_nopriv_wpinv_add_vat_class', array( $this, 'add_class' ) ); |
|
37 | - add_action( 'wp_ajax_wpinv_delete_vat_class', array( $this, 'delete_class' ) ); |
|
38 | - add_action( 'wp_ajax_nopriv_wpinv_delete_vat_class', array( $this, 'delete_class' ) ); |
|
39 | - add_action( 'wp_ajax_wpinv_update_vat_rates', array( $this, 'update_eu_rates' ) ); |
|
40 | - add_action( 'wp_ajax_nopriv_wpinv_update_vat_rates', array( $this, 'update_eu_rates' ) ); |
|
30 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts')); |
|
31 | + add_action('wpinv_settings_sections_taxes', array($this, 'section_vat_settings')); |
|
32 | + add_action('wpinv_settings_taxes', array($this, 'vat_settings')); |
|
33 | + add_filter('wpinv_settings_taxes-vat_sanitize', array($this, 'sanitize_vat_settings')); |
|
34 | + add_filter('wpinv_settings_taxes-vat_rates_sanitize', array($this, 'sanitize_vat_rates')); |
|
35 | + add_action('wp_ajax_wpinv_add_vat_class', array($this, 'add_class')); |
|
36 | + add_action('wp_ajax_nopriv_wpinv_add_vat_class', array($this, 'add_class')); |
|
37 | + add_action('wp_ajax_wpinv_delete_vat_class', array($this, 'delete_class')); |
|
38 | + add_action('wp_ajax_nopriv_wpinv_delete_vat_class', array($this, 'delete_class')); |
|
39 | + add_action('wp_ajax_wpinv_update_vat_rates', array($this, 'update_eu_rates')); |
|
40 | + add_action('wp_ajax_nopriv_wpinv_update_vat_rates', array($this, 'update_eu_rates')); |
|
41 | 41 | } |
42 | 42 | |
43 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_vat_scripts' ) ); |
|
44 | - add_filter( 'wpinv_default_billing_country', array( $this, 'get_user_country' ), 10 ); |
|
45 | - add_filter( 'wpinv_get_user_country', array( $this, 'set_user_country' ), 10 ); |
|
46 | - add_action( 'wp_ajax_wpinv_vat_validate', array( $this, 'ajax_vat_validate' ) ); |
|
47 | - add_action( 'wp_ajax_nopriv_wpinv_vat_validate', array( $this, 'ajax_vat_validate' ) ); |
|
43 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_vat_scripts')); |
|
44 | + add_filter('wpinv_default_billing_country', array($this, 'get_user_country'), 10); |
|
45 | + add_filter('wpinv_get_user_country', array($this, 'set_user_country'), 10); |
|
46 | + add_action('wp_ajax_wpinv_vat_validate', array($this, 'ajax_vat_validate')); |
|
47 | + add_action('wp_ajax_nopriv_wpinv_vat_validate', array($this, 'ajax_vat_validate')); |
|
48 | 48 | |
49 | - if ( wpinv_use_taxes() && self::allow_vat_rules() ) { |
|
50 | - add_filter( 'wpinv_tax_rate', array( $this, 'get_rate' ), 10, 4 ); |
|
49 | + if (wpinv_use_taxes() && self::allow_vat_rules()) { |
|
50 | + add_filter('wpinv_tax_rate', array($this, 'get_rate'), 10, 4); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
54 | - public static function get_eu_states( $sort = true ) { |
|
55 | - $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' ); |
|
56 | - if ( $sort ) { |
|
57 | - $sort = sort( $eu_states ); |
|
54 | + public static function get_eu_states($sort = true) { |
|
55 | + $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'); |
|
56 | + if ($sort) { |
|
57 | + $sort = sort($eu_states); |
|
58 | 58 | } |
59 | 59 | |
60 | - return apply_filters( 'wpinv_get_eu_states', $eu_states, $sort ); |
|
60 | + return apply_filters('wpinv_get_eu_states', $eu_states, $sort); |
|
61 | 61 | } |
62 | 62 | |
63 | - public static function get_gst_countries( $sort = true ) { |
|
64 | - $gst_countries = array( 'AU', 'NZ', 'CA', 'CN' ); |
|
63 | + public static function get_gst_countries($sort = true) { |
|
64 | + $gst_countries = array('AU', 'NZ', 'CA', 'CN'); |
|
65 | 65 | |
66 | - if ( $sort ) { |
|
67 | - $sort = sort( $gst_countries ); |
|
66 | + if ($sort) { |
|
67 | + $sort = sort($gst_countries); |
|
68 | 68 | } |
69 | 69 | |
70 | - return apply_filters( 'wpinv_get_gst_countries', $gst_countries, $sort ); |
|
70 | + return apply_filters('wpinv_get_gst_countries', $gst_countries, $sort); |
|
71 | 71 | } |
72 | 72 | |
73 | - public static function is_eu_state( $country_code ) { |
|
74 | - $return = !empty( $country_code ) && in_array( strtoupper( $country_code ), self::get_eu_states() ) ? true : false; |
|
73 | + public static function is_eu_state($country_code) { |
|
74 | + $return = !empty($country_code) && in_array(strtoupper($country_code), self::get_eu_states()) ? true : false; |
|
75 | 75 | |
76 | - return apply_filters( 'wpinv_is_eu_state', $return, $country_code ); |
|
76 | + return apply_filters('wpinv_is_eu_state', $return, $country_code); |
|
77 | 77 | } |
78 | 78 | |
79 | - public static function is_gst_country( $country_code ) { |
|
80 | - $return = !empty( $country_code ) && in_array( strtoupper( $country_code ), self::get_gst_countries() ) ? true : false; |
|
79 | + public static function is_gst_country($country_code) { |
|
80 | + $return = !empty($country_code) && in_array(strtoupper($country_code), self::get_gst_countries()) ? true : false; |
|
81 | 81 | |
82 | - return apply_filters( 'wpinv_is_gst_country', $return, $country_code ); |
|
82 | + return apply_filters('wpinv_is_gst_country', $return, $country_code); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | public function enqueue_vat_scripts() { |
86 | - if( wpinv_use_taxes() && wpinv_get_option( 'apply_vat_rules' ) ) { |
|
86 | + if (wpinv_use_taxes() && wpinv_get_option('apply_vat_rules')) { |
|
87 | 87 | $this->load_vat_scripts(); |
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
91 | - public function load_vat_scripts(){ |
|
92 | - $suffix = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
91 | + public function load_vat_scripts() { |
|
92 | + $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
93 | 93 | |
94 | - wp_register_script( 'wpinv-vat-validation-script', WPINV_PLUGIN_URL . 'assets/js/jsvat' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
95 | - wp_register_script( 'wpinv-vat-script', WPINV_PLUGIN_URL . 'assets/js/euvat' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
94 | + wp_register_script('wpinv-vat-validation-script', WPINV_PLUGIN_URL . 'assets/js/jsvat' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
95 | + wp_register_script('wpinv-vat-script', WPINV_PLUGIN_URL . 'assets/js/euvat' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
96 | 96 | |
97 | - $vat_name = $this->get_vat_name(); |
|
97 | + $vat_name = $this->get_vat_name(); |
|
98 | 98 | |
99 | 99 | $vars = array(); |
100 | 100 | $vars['UseTaxes'] = wpinv_use_taxes(); |
101 | 101 | $vars['EUStates'] = self::get_eu_states(); |
102 | - $vars['NoRateSet'] = __( 'You have not set a rate. Do you want to continue?', 'invoicing' ); |
|
103 | - $vars['EmptyCompany'] = __( 'Please enter your registered company name!', 'invoicing' ); |
|
104 | - $vars['EmptyVAT'] = wp_sprintf( __( 'Please enter your %s number!', 'invoicing' ), $vat_name ); |
|
105 | - $vars['TotalsRefreshed'] = wp_sprintf( __( 'The invoice totals will be refreshed to update the %s.', 'invoicing' ), $vat_name ); |
|
106 | - $vars['ErrValidateVAT'] = wp_sprintf( __( 'Fail to validate the %s number!', 'invoicing' ), $vat_name ); |
|
107 | - $vars['ErrResetVAT'] = wp_sprintf( __( 'Fail to reset the %s number!', 'invoicing' ), $vat_name ); |
|
108 | - $vars['ErrInvalidVat'] = wp_sprintf( __( 'The %s number supplied does not have a valid format!', 'invoicing' ), $vat_name ); |
|
109 | - $vars['ErrInvalidResponse'] = __( 'An invalid response has been received from the server!', 'invoicing' ); |
|
102 | + $vars['NoRateSet'] = __('You have not set a rate. Do you want to continue?', 'invoicing'); |
|
103 | + $vars['EmptyCompany'] = __('Please enter your registered company name!', 'invoicing'); |
|
104 | + $vars['EmptyVAT'] = wp_sprintf(__('Please enter your %s number!', 'invoicing'), $vat_name); |
|
105 | + $vars['TotalsRefreshed'] = wp_sprintf(__('The invoice totals will be refreshed to update the %s.', 'invoicing'), $vat_name); |
|
106 | + $vars['ErrValidateVAT'] = wp_sprintf(__('Fail to validate the %s number!', 'invoicing'), $vat_name); |
|
107 | + $vars['ErrResetVAT'] = wp_sprintf(__('Fail to reset the %s number!', 'invoicing'), $vat_name); |
|
108 | + $vars['ErrInvalidVat'] = wp_sprintf(__('The %s number supplied does not have a valid format!', 'invoicing'), $vat_name); |
|
109 | + $vars['ErrInvalidResponse'] = __('An invalid response has been received from the server!', 'invoicing'); |
|
110 | 110 | $vars['ApplyVATRules'] = $vars['UseTaxes'] ? self::allow_vat_rules() : false; |
111 | - $vars['ErrResponse'] = __( 'The request response is invalid!', 'invoicing' ); |
|
112 | - $vars['ErrRateResponse'] = __( 'The get rate request response is invalid', 'invoicing' ); |
|
113 | - $vars['PageRefresh'] = __( 'The page will be refreshed in 10 seconds to show the new options.', 'invoicing' ); |
|
114 | - $vars['RequestResponseNotValidJSON'] = __( 'The get rate request response is not valid JSON', 'invoicing' ); |
|
115 | - $vars['GetRateRequestFailed'] = __( 'The get rate request failed: ', 'invoicing' ); |
|
116 | - $vars['NoRateInformationInResponse'] = __( 'The get rate request response does not contain any rate information', 'invoicing' ); |
|
117 | - $vars['RatesUpdated'] = __( 'The rates have been updated. Press the save button to record these new rates.', 'invoicing' ); |
|
118 | - $vars['IPAddressInformation'] = __( 'IP Address Information', 'invoicing' ); |
|
119 | - $vars['VatValidating'] = wp_sprintf( __( 'Validating %s number...', 'invoicing' ), $vat_name ); |
|
120 | - $vars['VatReseting'] = __( 'Reseting...', 'invoicing' ); |
|
121 | - $vars['VatValidated'] = wp_sprintf( __( '%s number validated', 'invoicing' ), $vat_name ); |
|
122 | - $vars['VatNotValidated'] = wp_sprintf( __( '%s number not validated', 'invoicing' ), $vat_name ); |
|
123 | - $vars['ConfirmDeleteClass'] = __( 'Are you sure you wish to delete this rates class?', 'invoicing' ); |
|
111 | + $vars['ErrResponse'] = __('The request response is invalid!', 'invoicing'); |
|
112 | + $vars['ErrRateResponse'] = __('The get rate request response is invalid', 'invoicing'); |
|
113 | + $vars['PageRefresh'] = __('The page will be refreshed in 10 seconds to show the new options.', 'invoicing'); |
|
114 | + $vars['RequestResponseNotValidJSON'] = __('The get rate request response is not valid JSON', 'invoicing'); |
|
115 | + $vars['GetRateRequestFailed'] = __('The get rate request failed: ', 'invoicing'); |
|
116 | + $vars['NoRateInformationInResponse'] = __('The get rate request response does not contain any rate information', 'invoicing'); |
|
117 | + $vars['RatesUpdated'] = __('The rates have been updated. Press the save button to record these new rates.', 'invoicing'); |
|
118 | + $vars['IPAddressInformation'] = __('IP Address Information', 'invoicing'); |
|
119 | + $vars['VatValidating'] = wp_sprintf(__('Validating %s number...', 'invoicing'), $vat_name); |
|
120 | + $vars['VatReseting'] = __('Reseting...', 'invoicing'); |
|
121 | + $vars['VatValidated'] = wp_sprintf(__('%s number validated', 'invoicing'), $vat_name); |
|
122 | + $vars['VatNotValidated'] = wp_sprintf(__('%s number not validated', 'invoicing'), $vat_name); |
|
123 | + $vars['ConfirmDeleteClass'] = __('Are you sure you wish to delete this rates class?', 'invoicing'); |
|
124 | 124 | $vars['isFront'] = is_admin() ? false : true; |
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::load_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' ) ) ), |
|
170 | - 'placeholder' => __( 'Select a VAT Rate', 'invoicing' ), |
|
169 | + 'options' => array_merge($vat_classes, array('_new' => __('Add New Rate Class', 'invoicing'))), |
|
170 | + 'placeholder' => __('Select a VAT Rate', 'invoicing'), |
|
171 | 171 | 'selected' => $vat_class, |
172 | 172 | 'class' => 'wpi_select2', |
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,22 +278,22 @@ 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 to 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 to 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 an option', 'invoicing' ), |
|
289 | + 'placeholder' => __('Select an option', 'invoicing'), |
|
290 | 290 | 'std' => '', |
291 | 291 | 'class' => 'wpi_select2', |
292 | 292 | ); |
293 | 293 | |
294 | 294 | $vat_settings['vat_checkout_title'] = array( |
295 | 295 | 'id' => 'vat_checkout_title', |
296 | - 'name' => '<h3>' . __( 'Checkout Fields', 'invoicing' ) . '</h3>', |
|
296 | + 'name' => '<h3>' . __('Checkout Fields', 'invoicing') . '</h3>', |
|
297 | 297 | 'desc' => '', |
298 | 298 | 'type' => 'header', |
299 | 299 | 'size' => 'regular' |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | |
302 | 302 | $vat_settings['vies_validation_title'] = array( |
303 | 303 | 'id' => 'vies_validation_title', |
304 | - 'name' => '<h3>' . __( 'VIES Validation', 'invoicing' ) . '</h3>', |
|
304 | + 'name' => '<h3>' . __('VIES Validation', 'invoicing') . '</h3>', |
|
305 | 305 | 'desc' => '', |
306 | 306 | 'type' => 'header', |
307 | 307 | 'size' => 'regular' |
@@ -309,37 +309,37 @@ discard block |
||
309 | 309 | |
310 | 310 | $vat_settings['vat_vies_check'] = array( |
311 | 311 | 'id' => 'vat_vies_check', |
312 | - 'name' => __( 'Disable VIES VAT ID Check', 'invoicing' ), |
|
313 | - '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>' ), |
|
312 | + 'name' => __('Disable VIES VAT ID Check', 'invoicing'), |
|
313 | + '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>'), |
|
314 | 314 | 'type' => 'checkbox' |
315 | 315 | ); |
316 | 316 | |
317 | 317 | $vat_settings['vat_disable_company_name_check'] = array( |
318 | 318 | 'id' => 'vat_disable_company_name_check', |
319 | - 'name' => __( 'Disable VIES Name Check', 'invoicing' ), |
|
320 | - '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>' ), |
|
319 | + 'name' => __('Disable VIES Name Check', 'invoicing'), |
|
320 | + '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>'), |
|
321 | 321 | 'type' => 'checkbox' |
322 | 322 | ); |
323 | 323 | |
324 | 324 | $vat_settings['vat_offline_check'] = array( |
325 | 325 | 'id' => 'vat_offline_check', |
326 | - 'name' => __( 'Disable Basic Checks', 'invoicing' ), |
|
327 | - 'desc' => __( 'Disable basic JS checks for correct format of VAT number. (Not Recommended)', 'invoicing' ), |
|
326 | + 'name' => __('Disable Basic Checks', 'invoicing'), |
|
327 | + 'desc' => __('Disable basic JS checks for correct format of VAT number. (Not Recommended)', 'invoicing'), |
|
328 | 328 | 'type' => 'checkbox' |
329 | 329 | ); |
330 | 330 | |
331 | 331 | |
332 | 332 | $settings['vat'] = $vat_settings; |
333 | 333 | |
334 | - if ( self::allow_vat_classes() ) { |
|
334 | + if (self::allow_vat_classes()) { |
|
335 | 335 | $settings['vat_rates'] = self::vat_rates_settings(); |
336 | 336 | } |
337 | 337 | |
338 | 338 | $eu_fallback_rate = array( |
339 | 339 | 'id' => 'eu_fallback_rate', |
340 | - 'name' => '<h3>' . __( 'VAT rate for EU member states', 'invoicing' ) . '</h3>', |
|
340 | + 'name' => '<h3>' . __('VAT rate for EU member states', 'invoicing') . '</h3>', |
|
341 | 341 | 'type' => 'eu_fallback_rate', |
342 | - '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' ), |
|
342 | + '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'), |
|
343 | 343 | 'std' => '20', |
344 | 344 | 'size' => 'small' |
345 | 345 | ); |
@@ -430,66 +430,66 @@ discard block |
||
430 | 430 | return getpaid_get_ip_country(); |
431 | 431 | } |
432 | 432 | |
433 | - public static function sanitize_vat_settings( $input ) { |
|
433 | + public static function sanitize_vat_settings($input) { |
|
434 | 434 | global $wpinv_options; |
435 | 435 | |
436 | 436 | $valid = false; |
437 | 437 | $message = ''; |
438 | 438 | |
439 | - if ( !empty( $wpinv_options['vat_vies_check'] ) ) { |
|
440 | - if ( empty( $wpinv_options['vat_offline_check'] ) ) { |
|
441 | - $valid = self::offline_check( $input['vat_number'] ); |
|
439 | + if (!empty($wpinv_options['vat_vies_check'])) { |
|
440 | + if (empty($wpinv_options['vat_offline_check'])) { |
|
441 | + $valid = self::offline_check($input['vat_number']); |
|
442 | 442 | } else { |
443 | 443 | $valid = true; |
444 | 444 | } |
445 | 445 | |
446 | - $message = $valid ? '' : __( 'VAT number not validated', 'invoicing' ); |
|
446 | + $message = $valid ? '' : __('VAT number not validated', 'invoicing'); |
|
447 | 447 | } else { |
448 | - $result = self::check_vat( $input['vat_number'] ); |
|
448 | + $result = self::check_vat($input['vat_number']); |
|
449 | 449 | |
450 | - if ( empty( $result['valid'] ) ) { |
|
450 | + if (empty($result['valid'])) { |
|
451 | 451 | $valid = false; |
452 | 452 | $message = $result['message']; |
453 | 453 | } else { |
454 | - $valid = ( isset( $result['company'] ) && ( $result['company'] == '---' || ( strcasecmp( trim( $result['company'] ), trim( $input['vat_company_name'] ) ) == 0 ) ) ) || !empty( $wpinv_options['vat_disable_company_name_check'] ); |
|
455 | - $message = $valid ? '' : __( 'The company name associated with the VAT number provided is not the same as the company name provided.', 'invoicing' ); |
|
454 | + $valid = (isset($result['company']) && ($result['company'] == '---' || (strcasecmp(trim($result['company']), trim($input['vat_company_name'])) == 0))) || !empty($wpinv_options['vat_disable_company_name_check']); |
|
455 | + $message = $valid ? '' : __('The company name associated with the VAT number provided is not the same as the company name provided.', 'invoicing'); |
|
456 | 456 | } |
457 | 457 | } |
458 | 458 | |
459 | - if ( $message && self::is_vat_validated() != $valid ) { |
|
460 | - add_settings_error( 'wpinv-notices', '', $message, ( $valid ? 'updated' : 'error' ) ); |
|
459 | + if ($message && self::is_vat_validated() != $valid) { |
|
460 | + add_settings_error('wpinv-notices', '', $message, ($valid ? 'updated' : 'error')); |
|
461 | 461 | } |
462 | 462 | |
463 | 463 | $input['vat_valid'] = $valid; |
464 | 464 | return $input; |
465 | 465 | } |
466 | 466 | |
467 | - public static function sanitize_vat_rates( $input ) { |
|
468 | - if( !wpinv_current_user_can_manage_invoicing() ) { |
|
469 | - add_settings_error( 'wpinv-notices', '', __( 'Your account does not have permission to add rate classes.', 'invoicing' ), 'error' ); |
|
467 | + public static function sanitize_vat_rates($input) { |
|
468 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
469 | + add_settings_error('wpinv-notices', '', __('Your account does not have permission to add rate classes.', 'invoicing'), 'error'); |
|
470 | 470 | return $input; |
471 | 471 | } |
472 | 472 | |
473 | 473 | $vat_classes = self::get_rate_classes(); |
474 | - $vat_class = !empty( $_REQUEST['wpi_vat_class'] ) && isset( $vat_classes[$_REQUEST['wpi_vat_class']] )? sanitize_text_field( $_REQUEST['wpi_vat_class'] ) : ''; |
|
474 | + $vat_class = !empty($_REQUEST['wpi_vat_class']) && isset($vat_classes[$_REQUEST['wpi_vat_class']]) ? sanitize_text_field($_REQUEST['wpi_vat_class']) : ''; |
|
475 | 475 | |
476 | - if ( empty( $vat_class ) ) { |
|
477 | - add_settings_error( 'wpinv-notices', '', __( 'No valid VAT rates class contained in the request to save rates.', 'invoicing' ), 'error' ); |
|
476 | + if (empty($vat_class)) { |
|
477 | + add_settings_error('wpinv-notices', '', __('No valid VAT rates class contained in the request to save rates.', 'invoicing'), 'error'); |
|
478 | 478 | |
479 | 479 | return $input; |
480 | 480 | } |
481 | 481 | |
482 | - $new_rates = ! empty( $_POST['vat_rates'] ) ? array_values( $_POST['vat_rates'] ) : array(); |
|
482 | + $new_rates = !empty($_POST['vat_rates']) ? array_values($_POST['vat_rates']) : array(); |
|
483 | 483 | |
484 | - if ( $vat_class === '_standard' ) { |
|
484 | + if ($vat_class === '_standard') { |
|
485 | 485 | // Save the active rates in the invoice settings |
486 | - update_option( 'wpinv_tax_rates', $new_rates ); |
|
486 | + update_option('wpinv_tax_rates', $new_rates); |
|
487 | 487 | } else { |
488 | 488 | // Get the existing set of rates |
489 | 489 | $rates = self::get_non_standard_rates(); |
490 | 490 | $rates[$vat_class] = $new_rates; |
491 | 491 | |
492 | - update_option( 'wpinv_vat_rates', $rates ); |
|
492 | + update_option('wpinv_vat_rates', $rates); |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | return $input; |
@@ -499,71 +499,71 @@ discard block |
||
499 | 499 | $response = array(); |
500 | 500 | $response['success'] = false; |
501 | 501 | |
502 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
503 | - $response['error'] = __( 'Invalid access!', 'invoicing' ); |
|
504 | - wp_send_json( $response ); |
|
502 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
503 | + $response['error'] = __('Invalid access!', 'invoicing'); |
|
504 | + wp_send_json($response); |
|
505 | 505 | } |
506 | 506 | |
507 | - $vat_class_name = !empty( $_POST['name'] ) ? sanitize_text_field( $_POST['name'] ) : false; |
|
508 | - $vat_class_desc = !empty( $_POST['desc'] ) ? sanitize_text_field( $_POST['desc'] ) : false; |
|
507 | + $vat_class_name = !empty($_POST['name']) ? sanitize_text_field($_POST['name']) : false; |
|
508 | + $vat_class_desc = !empty($_POST['desc']) ? sanitize_text_field($_POST['desc']) : false; |
|
509 | 509 | |
510 | - if ( empty( $vat_class_name ) ) { |
|
511 | - $response['error'] = __( 'Select the VAT rate name', 'invoicing' ); |
|
512 | - wp_send_json( $response ); |
|
510 | + if (empty($vat_class_name)) { |
|
511 | + $response['error'] = __('Select the VAT rate name', 'invoicing'); |
|
512 | + wp_send_json($response); |
|
513 | 513 | } |
514 | 514 | |
515 | - $vat_classes = (array)self::get_rate_classes(); |
|
515 | + $vat_classes = (array) self::get_rate_classes(); |
|
516 | 516 | |
517 | - if ( !empty( $vat_classes ) && in_array( strtolower( $vat_class_name ), array_map( 'strtolower', array_values( $vat_classes ) ) ) ) { |
|
518 | - $response['error'] = wp_sprintf( __( 'A VAT Rate name "%s" already exists', 'invoicing' ), $vat_class_name ); |
|
519 | - wp_send_json( $response ); |
|
517 | + if (!empty($vat_classes) && in_array(strtolower($vat_class_name), array_map('strtolower', array_values($vat_classes)))) { |
|
518 | + $response['error'] = wp_sprintf(__('A VAT Rate name "%s" already exists', 'invoicing'), $vat_class_name); |
|
519 | + wp_send_json($response); |
|
520 | 520 | } |
521 | 521 | |
522 | - $rate_class_key = normalize_whitespace( 'wpi-' . $vat_class_name ); |
|
523 | - $rate_class_key = sanitize_key( str_replace( " ", "-", $rate_class_key ) ); |
|
522 | + $rate_class_key = normalize_whitespace('wpi-' . $vat_class_name); |
|
523 | + $rate_class_key = sanitize_key(str_replace(" ", "-", $rate_class_key)); |
|
524 | 524 | |
525 | - $vat_classes = (array)self::get_rate_classes( true ); |
|
526 | - $vat_classes[$rate_class_key] = array( 'name' => $vat_class_name, 'desc' => $vat_class_desc ); |
|
525 | + $vat_classes = (array) self::get_rate_classes(true); |
|
526 | + $vat_classes[$rate_class_key] = array('name' => $vat_class_name, 'desc' => $vat_class_desc); |
|
527 | 527 | |
528 | - update_option( '_wpinv_vat_rate_classes', $vat_classes ); |
|
528 | + update_option('_wpinv_vat_rate_classes', $vat_classes); |
|
529 | 529 | |
530 | 530 | $response['success'] = true; |
531 | - $response['redirect'] = admin_url( 'admin.php?page=wpinv-settings&tab=taxes§ion=vat_rates&wpi_sub=' . $rate_class_key ); |
|
531 | + $response['redirect'] = admin_url('admin.php?page=wpinv-settings&tab=taxes§ion=vat_rates&wpi_sub=' . $rate_class_key); |
|
532 | 532 | |
533 | - wp_send_json( $response ); |
|
533 | + wp_send_json($response); |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | public static function delete_class() { |
537 | 537 | $response = array(); |
538 | 538 | $response['success'] = false; |
539 | 539 | |
540 | - if ( !wpinv_current_user_can_manage_invoicing() || !isset( $_POST['class'] ) ) { |
|
541 | - $response['error'] = __( 'Invalid access!', 'invoicing' ); |
|
542 | - wp_send_json( $response ); |
|
540 | + if (!wpinv_current_user_can_manage_invoicing() || !isset($_POST['class'])) { |
|
541 | + $response['error'] = __('Invalid access!', 'invoicing'); |
|
542 | + wp_send_json($response); |
|
543 | 543 | } |
544 | 544 | |
545 | - $vat_class = isset( $_POST['class'] ) && $_POST['class'] !== '' ? sanitize_text_field( $_POST['class'] ) : false; |
|
546 | - $vat_classes = (array)self::get_rate_classes(); |
|
545 | + $vat_class = isset($_POST['class']) && $_POST['class'] !== '' ? sanitize_text_field($_POST['class']) : false; |
|
546 | + $vat_classes = (array) self::get_rate_classes(); |
|
547 | 547 | |
548 | - if ( !isset( $vat_classes[$vat_class] ) ) { |
|
549 | - $response['error'] = __( 'Requested class does not exists', 'invoicing' ); |
|
550 | - wp_send_json( $response ); |
|
548 | + if (!isset($vat_classes[$vat_class])) { |
|
549 | + $response['error'] = __('Requested class does not exists', 'invoicing'); |
|
550 | + wp_send_json($response); |
|
551 | 551 | } |
552 | 552 | |
553 | - if ( $vat_class == '_new' || $vat_class == '_standard' ) { |
|
554 | - $response['error'] = __( 'You can not delete standard rates class', 'invoicing' ); |
|
555 | - wp_send_json( $response ); |
|
553 | + if ($vat_class == '_new' || $vat_class == '_standard') { |
|
554 | + $response['error'] = __('You can not delete standard rates class', 'invoicing'); |
|
555 | + wp_send_json($response); |
|
556 | 556 | } |
557 | 557 | |
558 | - $vat_classes = (array)self::get_rate_classes( true ); |
|
559 | - unset( $vat_classes[$vat_class] ); |
|
558 | + $vat_classes = (array) self::get_rate_classes(true); |
|
559 | + unset($vat_classes[$vat_class]); |
|
560 | 560 | |
561 | - update_option( '_wpinv_vat_rate_classes', $vat_classes ); |
|
561 | + update_option('_wpinv_vat_rate_classes', $vat_classes); |
|
562 | 562 | |
563 | 563 | $response['success'] = true; |
564 | - $response['redirect'] = admin_url( 'admin.php?page=wpinv-settings&tab=taxes§ion=vat_rates&wpi_sub=_new' ); |
|
564 | + $response['redirect'] = admin_url('admin.php?page=wpinv-settings&tab=taxes§ion=vat_rates&wpi_sub=_new'); |
|
565 | 565 | |
566 | - wp_send_json( $response ); |
|
566 | + wp_send_json($response); |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | public static function update_eu_rates() { |
@@ -572,24 +572,24 @@ discard block |
||
572 | 572 | $response['error'] = null; |
573 | 573 | $response['data'] = null; |
574 | 574 | |
575 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
576 | - $response['error'] = __( 'Invalid access!', 'invoicing' ); |
|
577 | - wp_send_json( $response ); |
|
575 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
576 | + $response['error'] = __('Invalid access!', 'invoicing'); |
|
577 | + wp_send_json($response); |
|
578 | 578 | } |
579 | 579 | |
580 | - $group = !empty( $_POST['group'] ) ? sanitize_text_field( $_POST['group'] ) : ''; |
|
581 | - $euvatrates = self::request_euvatrates( $group ); |
|
580 | + $group = !empty($_POST['group']) ? sanitize_text_field($_POST['group']) : ''; |
|
581 | + $euvatrates = self::request_euvatrates($group); |
|
582 | 582 | |
583 | - if ( !empty( $euvatrates ) ) { |
|
584 | - if ( !empty( $euvatrates['success'] ) && !empty( $euvatrates['rates'] ) ) { |
|
583 | + if (!empty($euvatrates)) { |
|
584 | + if (!empty($euvatrates['success']) && !empty($euvatrates['rates'])) { |
|
585 | 585 | $response['success'] = true; |
586 | 586 | $response['data']['rates'] = $euvatrates['rates']; |
587 | - } else if ( !empty( $euvatrates['error'] ) ) { |
|
587 | + } else if (!empty($euvatrates['error'])) { |
|
588 | 588 | $response['error'] = $euvatrates['error']; |
589 | 589 | } |
590 | 590 | } |
591 | 591 | |
592 | - wp_send_json( $response ); |
|
592 | + wp_send_json($response); |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | /** |
@@ -598,46 +598,46 @@ discard block |
||
598 | 598 | public static function hide_vat_fields() {} |
599 | 599 | |
600 | 600 | public static function same_country_rule() { |
601 | - $same_country_rule = wpinv_get_option( 'vat_same_country_rule' ); |
|
601 | + $same_country_rule = wpinv_get_option('vat_same_country_rule'); |
|
602 | 602 | |
603 | - return apply_filters( 'wpinv_vat_same_country_rule', $same_country_rule ); |
|
603 | + return apply_filters('wpinv_vat_same_country_rule', $same_country_rule); |
|
604 | 604 | } |
605 | 605 | |
606 | 606 | /** |
607 | 607 | * Retrieves the vat name. |
608 | 608 | */ |
609 | 609 | public function get_vat_name() { |
610 | - $vat_name = wpinv_get_option( 'vat_name' ); |
|
611 | - return empty( $vat_name ) ? __( 'VAT', 'invoicing' ) : sanitize_text_field( $vat_name ); |
|
610 | + $vat_name = wpinv_get_option('vat_name'); |
|
611 | + return empty($vat_name) ? __('VAT', 'invoicing') : sanitize_text_field($vat_name); |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | public static function get_company_name() { |
615 | - $company_name = wpinv_get_option( 'vat_company_name' ); |
|
615 | + $company_name = wpinv_get_option('vat_company_name'); |
|
616 | 616 | |
617 | - return apply_filters( 'wpinv_get_owner_company_name', $company_name ); |
|
617 | + return apply_filters('wpinv_get_owner_company_name', $company_name); |
|
618 | 618 | } |
619 | 619 | |
620 | 620 | public static function get_vat_number() { |
621 | - $vat_number = wpinv_get_option( 'vat_number' ); |
|
621 | + $vat_number = wpinv_get_option('vat_number'); |
|
622 | 622 | |
623 | - return apply_filters( 'wpinv_get_owner_vat_number', $vat_number ); |
|
623 | + return apply_filters('wpinv_get_owner_vat_number', $vat_number); |
|
624 | 624 | } |
625 | 625 | |
626 | 626 | public static function is_vat_validated() { |
627 | - $validated = self::get_vat_number() && wpinv_get_option( 'vat_valid' ); |
|
627 | + $validated = self::get_vat_number() && wpinv_get_option('vat_valid'); |
|
628 | 628 | |
629 | - return apply_filters( 'wpinv_is_owner_vat_validated', $validated ); |
|
629 | + return apply_filters('wpinv_is_owner_vat_validated', $validated); |
|
630 | 630 | } |
631 | 631 | |
632 | - public static function sanitize_vat( $vat_number, $country_code = '' ) { |
|
633 | - $vat_number = str_replace( array(' ', '.', '-', '_', ',' ), '', strtoupper( trim( $vat_number ) ) ); |
|
632 | + public static function sanitize_vat($vat_number, $country_code = '') { |
|
633 | + $vat_number = str_replace(array(' ', '.', '-', '_', ','), '', strtoupper(trim($vat_number))); |
|
634 | 634 | |
635 | - if ( empty( $country_code ) ) { |
|
636 | - $country_code = substr( $vat_number, 0, 2 ); |
|
635 | + if (empty($country_code)) { |
|
636 | + $country_code = substr($vat_number, 0, 2); |
|
637 | 637 | } |
638 | 638 | |
639 | - if ( strpos( $vat_number , $country_code ) === 0 ) { |
|
640 | - $vat = str_replace( $country_code, '', $vat_number ); |
|
639 | + if (strpos($vat_number, $country_code) === 0) { |
|
640 | + $vat = str_replace($country_code, '', $vat_number); |
|
641 | 641 | } else { |
642 | 642 | $vat = $country_code . $vat_number; |
643 | 643 | } |
@@ -650,140 +650,140 @@ discard block |
||
650 | 650 | return $return; |
651 | 651 | } |
652 | 652 | |
653 | - public static function offline_check( $vat_number, $country_code = '', $formatted = false ) { |
|
654 | - $vat = self::sanitize_vat( $vat_number, $country_code ); |
|
653 | + public static function offline_check($vat_number, $country_code = '', $formatted = false) { |
|
654 | + $vat = self::sanitize_vat($vat_number, $country_code); |
|
655 | 655 | $vat_number = $vat['vat_number']; |
656 | 656 | $country_code = $vat['iso']; |
657 | 657 | $regex = array(); |
658 | 658 | |
659 | - switch ( $country_code ) { |
|
659 | + switch ($country_code) { |
|
660 | 660 | case 'AT': |
661 | - $regex[] = '/^(AT)U(\d{8})$/'; // Austria |
|
661 | + $regex[] = '/^(AT)U(\d{8})$/'; // Austria |
|
662 | 662 | break; |
663 | 663 | case 'BE': |
664 | - $regex[] = '/^(BE)(0?\d{9})$/'; // Belgium |
|
664 | + $regex[] = '/^(BE)(0?\d{9})$/'; // Belgium |
|
665 | 665 | break; |
666 | 666 | case 'BG': |
667 | - $regex[] = '/^(BG)(\d{9,10})$/'; // Bulgaria |
|
667 | + $regex[] = '/^(BG)(\d{9,10})$/'; // Bulgaria |
|
668 | 668 | break; |
669 | 669 | case 'CH': |
670 | 670 | case 'CHE': |
671 | - $regex[] = '/^(CHE)(\d{9})MWST$/'; // Switzerland (Not EU) |
|
671 | + $regex[] = '/^(CHE)(\d{9})MWST$/'; // Switzerland (Not EU) |
|
672 | 672 | break; |
673 | 673 | case 'CY': |
674 | - $regex[] = '/^(CY)([0-5|9]\d{7}[A-Z])$/'; // Cyprus |
|
674 | + $regex[] = '/^(CY)([0-5|9]\d{7}[A-Z])$/'; // Cyprus |
|
675 | 675 | break; |
676 | 676 | case 'CZ': |
677 | - $regex[] = '/^(CZ)(\d{8,13})$/'; // Czech Republic |
|
677 | + $regex[] = '/^(CZ)(\d{8,13})$/'; // Czech Republic |
|
678 | 678 | break; |
679 | 679 | case 'DE': |
680 | - $regex[] = '/^(DE)([1-9]\d{8})$/'; // Germany |
|
680 | + $regex[] = '/^(DE)([1-9]\d{8})$/'; // Germany |
|
681 | 681 | break; |
682 | 682 | case 'DK': |
683 | - $regex[] = '/^(DK)(\d{8})$/'; // Denmark |
|
683 | + $regex[] = '/^(DK)(\d{8})$/'; // Denmark |
|
684 | 684 | break; |
685 | 685 | case 'EE': |
686 | - $regex[] = '/^(EE)(10\d{7})$/'; // Estonia |
|
686 | + $regex[] = '/^(EE)(10\d{7})$/'; // Estonia |
|
687 | 687 | break; |
688 | 688 | case 'EL': |
689 | - $regex[] = '/^(EL)(\d{9})$/'; // Greece |
|
689 | + $regex[] = '/^(EL)(\d{9})$/'; // Greece |
|
690 | 690 | break; |
691 | 691 | case 'ES': |
692 | - $regex[] = '/^(ES)([A-Z]\d{8})$/'; // Spain (National juridical entities) |
|
693 | - $regex[] = '/^(ES)([A-H|N-S|W]\d{7}[A-J])$/'; // Spain (Other juridical entities) |
|
694 | - $regex[] = '/^(ES)([0-9|Y|Z]\d{7}[A-Z])$/'; // Spain (Personal entities type 1) |
|
695 | - $regex[] = '/^(ES)([K|L|M|X]\d{7}[A-Z])$/'; // Spain (Personal entities type 2) |
|
692 | + $regex[] = '/^(ES)([A-Z]\d{8})$/'; // Spain (National juridical entities) |
|
693 | + $regex[] = '/^(ES)([A-H|N-S|W]\d{7}[A-J])$/'; // Spain (Other juridical entities) |
|
694 | + $regex[] = '/^(ES)([0-9|Y|Z]\d{7}[A-Z])$/'; // Spain (Personal entities type 1) |
|
695 | + $regex[] = '/^(ES)([K|L|M|X]\d{7}[A-Z])$/'; // Spain (Personal entities type 2) |
|
696 | 696 | break; |
697 | 697 | case 'EU': |
698 | - $regex[] = '/^(EU)(\d{9})$/'; // EU-type |
|
698 | + $regex[] = '/^(EU)(\d{9})$/'; // EU-type |
|
699 | 699 | break; |
700 | 700 | case 'FI': |
701 | - $regex[] = '/^(FI)(\d{8})$/'; // Finland |
|
701 | + $regex[] = '/^(FI)(\d{8})$/'; // Finland |
|
702 | 702 | break; |
703 | 703 | case 'FR': |
704 | - $regex[] = '/^(FR)(\d{11})$/'; // France (1) |
|
705 | - $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)](\d{10})$/'; // France (2) |
|
706 | - $regex[] = '/^(FR)\d[(A-H)|(J-N)|(P-Z)](\d{9})$/'; // France (3) |
|
707 | - $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)]{2}(\d{9})$/'; // France (4) |
|
704 | + $regex[] = '/^(FR)(\d{11})$/'; // France (1) |
|
705 | + $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)](\d{10})$/'; // France (2) |
|
706 | + $regex[] = '/^(FR)\d[(A-H)|(J-N)|(P-Z)](\d{9})$/'; // France (3) |
|
707 | + $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)]{2}(\d{9})$/'; // France (4) |
|
708 | 708 | break; |
709 | 709 | case 'GB': |
710 | - $regex[] = '/^(GB)?(\d{9})$/'; // UK (Standard) |
|
711 | - $regex[] = '/^(GB)?(\d{12})$/'; // UK (Branches) |
|
712 | - $regex[] = '/^(GB)?(GD\d{3})$/'; // UK (Government) |
|
713 | - $regex[] = '/^(GB)?(HA\d{3})$/'; // UK (Health authority) |
|
710 | + $regex[] = '/^(GB)?(\d{9})$/'; // UK (Standard) |
|
711 | + $regex[] = '/^(GB)?(\d{12})$/'; // UK (Branches) |
|
712 | + $regex[] = '/^(GB)?(GD\d{3})$/'; // UK (Government) |
|
713 | + $regex[] = '/^(GB)?(HA\d{3})$/'; // UK (Health authority) |
|
714 | 714 | break; |
715 | 715 | case 'GR': |
716 | - $regex[] = '/^(GR)(\d{8,9})$/'; // Greece |
|
716 | + $regex[] = '/^(GR)(\d{8,9})$/'; // Greece |
|
717 | 717 | break; |
718 | 718 | case 'HR': |
719 | - $regex[] = '/^(HR)(\d{11})$/'; // Croatia |
|
719 | + $regex[] = '/^(HR)(\d{11})$/'; // Croatia |
|
720 | 720 | break; |
721 | 721 | case 'HU': |
722 | - $regex[] = '/^(HU)(\d{8})$/'; // Hungary |
|
722 | + $regex[] = '/^(HU)(\d{8})$/'; // Hungary |
|
723 | 723 | break; |
724 | 724 | case 'IE': |
725 | - $regex[] = '/^(IE)(\d{7}[A-W])$/'; // Ireland (1) |
|
726 | - $regex[] = '/^(IE)([7-9][A-Z\*\+)]\d{5}[A-W])$/'; // Ireland (2) |
|
727 | - $regex[] = '/^(IE)(\d{7}[A-Z][AH])$/'; // Ireland (3) (new format from 1 Jan 2013) |
|
725 | + $regex[] = '/^(IE)(\d{7}[A-W])$/'; // Ireland (1) |
|
726 | + $regex[] = '/^(IE)([7-9][A-Z\*\+)]\d{5}[A-W])$/'; // Ireland (2) |
|
727 | + $regex[] = '/^(IE)(\d{7}[A-Z][AH])$/'; // Ireland (3) (new format from 1 Jan 2013) |
|
728 | 728 | break; |
729 | 729 | case 'IT': |
730 | - $regex[] = '/^(IT)(\d{11})$/'; // Italy |
|
730 | + $regex[] = '/^(IT)(\d{11})$/'; // Italy |
|
731 | 731 | break; |
732 | 732 | case 'LV': |
733 | - $regex[] = '/^(LV)(\d{11})$/'; // Latvia |
|
733 | + $regex[] = '/^(LV)(\d{11})$/'; // Latvia |
|
734 | 734 | break; |
735 | 735 | case 'LT': |
736 | - $regex[] = '/^(LT)(\d{9}|\d{12})$/'; // Lithuania |
|
736 | + $regex[] = '/^(LT)(\d{9}|\d{12})$/'; // Lithuania |
|
737 | 737 | break; |
738 | 738 | case 'LU': |
739 | - $regex[] = '/^(LU)(\d{8})$/'; // Luxembourg |
|
739 | + $regex[] = '/^(LU)(\d{8})$/'; // Luxembourg |
|
740 | 740 | break; |
741 | 741 | case 'MT': |
742 | - $regex[] = '/^(MT)([1-9]\d{7})$/'; // Malta |
|
742 | + $regex[] = '/^(MT)([1-9]\d{7})$/'; // Malta |
|
743 | 743 | break; |
744 | 744 | case 'NL': |
745 | - $regex[] = '/^(NL)(\d{9})B\d{2}$/'; // Netherlands |
|
745 | + $regex[] = '/^(NL)(\d{9})B\d{2}$/'; // Netherlands |
|
746 | 746 | break; |
747 | 747 | case 'NO': |
748 | - $regex[] = '/^(NO)(\d{9})$/'; // Norway (Not EU) |
|
748 | + $regex[] = '/^(NO)(\d{9})$/'; // Norway (Not EU) |
|
749 | 749 | break; |
750 | 750 | case 'PL': |
751 | - $regex[] = '/^(PL)(\d{10})$/'; // Poland |
|
751 | + $regex[] = '/^(PL)(\d{10})$/'; // Poland |
|
752 | 752 | break; |
753 | 753 | case 'PT': |
754 | - $regex[] = '/^(PT)(\d{9})$/'; // Portugal |
|
754 | + $regex[] = '/^(PT)(\d{9})$/'; // Portugal |
|
755 | 755 | break; |
756 | 756 | case 'RO': |
757 | - $regex[] = '/^(RO)([1-9]\d{1,9})$/'; // Romania |
|
757 | + $regex[] = '/^(RO)([1-9]\d{1,9})$/'; // Romania |
|
758 | 758 | break; |
759 | 759 | case 'RS': |
760 | - $regex[] = '/^(RS)(\d{9})$/'; // Serbia (Not EU) |
|
760 | + $regex[] = '/^(RS)(\d{9})$/'; // Serbia (Not EU) |
|
761 | 761 | break; |
762 | 762 | case 'SI': |
763 | - $regex[] = '/^(SI)([1-9]\d{7})$/'; // Slovenia |
|
763 | + $regex[] = '/^(SI)([1-9]\d{7})$/'; // Slovenia |
|
764 | 764 | break; |
765 | 765 | case 'SK': |
766 | - $regex[] = '/^(SK)([1-9]\d[(2-4)|(6-9)]\d{7})$/'; // Slovakia Republic |
|
766 | + $regex[] = '/^(SK)([1-9]\d[(2-4)|(6-9)]\d{7})$/'; // Slovakia Republic |
|
767 | 767 | break; |
768 | 768 | case 'SE': |
769 | - $regex[] = '/^(SE)(\d{10}01)$/'; // Sweden |
|
769 | + $regex[] = '/^(SE)(\d{10}01)$/'; // Sweden |
|
770 | 770 | break; |
771 | 771 | default: |
772 | 772 | $regex = array(); |
773 | 773 | break; |
774 | 774 | } |
775 | 775 | |
776 | - if ( empty( $regex ) ) { |
|
776 | + if (empty($regex)) { |
|
777 | 777 | return false; |
778 | 778 | } |
779 | 779 | |
780 | - foreach ( $regex as $pattern ) { |
|
780 | + foreach ($regex as $pattern) { |
|
781 | 781 | $matches = null; |
782 | - preg_match_all( $pattern, $vat_number, $matches ); |
|
782 | + preg_match_all($pattern, $vat_number, $matches); |
|
783 | 783 | |
784 | - if ( !empty( $matches[1][0] ) && !empty( $matches[2][0] ) ) { |
|
785 | - if ( $formatted ) { |
|
786 | - return array( 'code' => $matches[1][0], 'number' => $matches[2][0] ); |
|
784 | + if (!empty($matches[1][0]) && !empty($matches[2][0])) { |
|
785 | + if ($formatted) { |
|
786 | + return array('code' => $matches[1][0], 'number' => $matches[2][0]); |
|
787 | 787 | } else { |
788 | 788 | return true; |
789 | 789 | } |
@@ -793,75 +793,75 @@ discard block |
||
793 | 793 | return false; |
794 | 794 | } |
795 | 795 | |
796 | - public static function vies_check( $vat_number, $country_code = '', $result = false ) { |
|
797 | - $vat = self::sanitize_vat( $vat_number, $country_code ); |
|
796 | + public static function vies_check($vat_number, $country_code = '', $result = false) { |
|
797 | + $vat = self::sanitize_vat($vat_number, $country_code); |
|
798 | 798 | $vat_number = $vat['vat']; |
799 | 799 | $iso = $vat['iso']; |
800 | 800 | |
801 | - $url = 'http://ec.europa.eu/taxation_customs/vies/viesquer.do?ms=' . urlencode( $iso ) . '&iso=' . urlencode( $iso ) . '&vat=' . urlencode( $vat_number ); |
|
801 | + $url = 'http://ec.europa.eu/taxation_customs/vies/viesquer.do?ms=' . urlencode($iso) . '&iso=' . urlencode($iso) . '&vat=' . urlencode($vat_number); |
|
802 | 802 | |
803 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
804 | - $response = file_get_contents( $url ); |
|
805 | - } else if ( function_exists( 'curl_init' ) ) { |
|
803 | + if (ini_get('allow_url_fopen')) { |
|
804 | + $response = file_get_contents($url); |
|
805 | + } else if (function_exists('curl_init')) { |
|
806 | 806 | $ch = curl_init(); |
807 | 807 | |
808 | - curl_setopt( $ch, CURLOPT_URL, $url ); |
|
809 | - curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 30 ); |
|
810 | - curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); |
|
811 | - curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0 ); |
|
812 | - curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 ); |
|
808 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
809 | + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); |
|
810 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
811 | + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); |
|
812 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); |
|
813 | 813 | |
814 | - $response = curl_exec( $ch ); |
|
814 | + $response = curl_exec($ch); |
|
815 | 815 | |
816 | - if ( curl_errno( $ch ) ) { |
|
817 | - wpinv_error_log( curl_error( $ch ), 'VIES CHECK ERROR' ); |
|
816 | + if (curl_errno($ch)) { |
|
817 | + wpinv_error_log(curl_error($ch), 'VIES CHECK ERROR'); |
|
818 | 818 | $response = ''; |
819 | 819 | } |
820 | 820 | |
821 | - curl_close( $ch ); |
|
821 | + curl_close($ch); |
|
822 | 822 | } else { |
823 | - 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' ); |
|
823 | + 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'); |
|
824 | 824 | } |
825 | 825 | |
826 | - if ( empty( $response ) ) { |
|
826 | + if (empty($response)) { |
|
827 | 827 | return $result; |
828 | 828 | } |
829 | 829 | |
830 | - if ( preg_match( '/invalid VAT number/i', $response ) ) { |
|
830 | + if (preg_match('/invalid VAT number/i', $response)) { |
|
831 | 831 | return false; |
832 | - } else if ( preg_match( '/valid VAT number/i', $response, $matches ) ) { |
|
833 | - $content = explode( "valid VAT number", htmlentities( $response ) ); |
|
832 | + } else if (preg_match('/valid VAT number/i', $response, $matches)) { |
|
833 | + $content = explode("valid VAT number", htmlentities($response)); |
|
834 | 834 | |
835 | - if ( !empty( $content[1] ) ) { |
|
836 | - preg_match_all( '/<tr>(.*?)<td.*?>(.*?)<\/td>(.*?)<\/tr>/si', html_entity_decode( $content[1] ), $matches ); |
|
835 | + if (!empty($content[1])) { |
|
836 | + preg_match_all('/<tr>(.*?)<td.*?>(.*?)<\/td>(.*?)<\/tr>/si', html_entity_decode($content[1]), $matches); |
|
837 | 837 | |
838 | - if ( !empty( $matches[2] ) && $matches[3] ) { |
|
838 | + if (!empty($matches[2]) && $matches[3]) { |
|
839 | 839 | $return = array(); |
840 | 840 | |
841 | - foreach ( $matches[2] as $key => $label ) { |
|
842 | - $label = trim( $label ); |
|
841 | + foreach ($matches[2] as $key => $label) { |
|
842 | + $label = trim($label); |
|
843 | 843 | |
844 | - switch ( strtolower( $label ) ) { |
|
844 | + switch (strtolower($label)) { |
|
845 | 845 | case 'member state': |
846 | - $return['state'] = trim( strip_tags( $matches[3][$key] ) ); |
|
846 | + $return['state'] = trim(strip_tags($matches[3][$key])); |
|
847 | 847 | break; |
848 | 848 | case 'vat number': |
849 | - $return['number'] = trim( strip_tags( $matches[3][$key] ) ); |
|
849 | + $return['number'] = trim(strip_tags($matches[3][$key])); |
|
850 | 850 | break; |
851 | 851 | case 'name': |
852 | - $return['company'] = trim( strip_tags( $matches[3][$key] ) ); |
|
852 | + $return['company'] = trim(strip_tags($matches[3][$key])); |
|
853 | 853 | break; |
854 | 854 | case 'address': |
855 | - $address = str_replace( array( "<br><br>", "<br /><br />", "<br/><br/>" ), "<br>", html_entity_decode( trim( $matches[3][$key] ) ) ); |
|
856 | - $return['address'] = trim( strip_tags( $address, '<br>' ) ); |
|
855 | + $address = str_replace(array("<br><br>", "<br /><br />", "<br/><br/>"), "<br>", html_entity_decode(trim($matches[3][$key]))); |
|
856 | + $return['address'] = trim(strip_tags($address, '<br>')); |
|
857 | 857 | break; |
858 | 858 | case 'consultation number': |
859 | - $return['consultation'] = trim( strip_tags( $matches[3][$key] ) ); |
|
859 | + $return['consultation'] = trim(strip_tags($matches[3][$key])); |
|
860 | 860 | break; |
861 | 861 | } |
862 | 862 | } |
863 | 863 | |
864 | - if ( !empty( $return ) ) { |
|
864 | + if (!empty($return)) { |
|
865 | 865 | return $return; |
866 | 866 | } |
867 | 867 | } |
@@ -873,62 +873,62 @@ discard block |
||
873 | 873 | } |
874 | 874 | } |
875 | 875 | |
876 | - public static function check_vat( $vat_number, $country_code = '' ) { |
|
876 | + public static function check_vat($vat_number, $country_code = '') { |
|
877 | 877 | $vat_name = getpaid_vat_name(); |
878 | 878 | |
879 | 879 | $return = array(); |
880 | 880 | $return['valid'] = false; |
881 | - $return['message'] = wp_sprintf( __( '%s number not validated', 'invoicing' ), $vat_name ); |
|
881 | + $return['message'] = wp_sprintf(__('%s number not validated', 'invoicing'), $vat_name); |
|
882 | 882 | |
883 | - if ( !wpinv_get_option( 'vat_offline_check' ) && !self::offline_check( $vat_number, $country_code ) ) { |
|
883 | + if (!wpinv_get_option('vat_offline_check') && !self::offline_check($vat_number, $country_code)) { |
|
884 | 884 | return $return; |
885 | 885 | } |
886 | 886 | |
887 | - $response = self::vies_check( $vat_number, $country_code ); |
|
887 | + $response = self::vies_check($vat_number, $country_code); |
|
888 | 888 | |
889 | - if ( $response ) { |
|
890 | - $return['valid'] = true; |
|
889 | + if ($response) { |
|
890 | + $return['valid'] = true; |
|
891 | 891 | |
892 | - if ( is_array( $response ) ) { |
|
893 | - $return['company'] = isset( $response['company'] ) ? $response['company'] : ''; |
|
894 | - $return['address'] = isset( $response['address'] ) ? $response['address'] : ''; |
|
892 | + if (is_array($response)) { |
|
893 | + $return['company'] = isset($response['company']) ? $response['company'] : ''; |
|
894 | + $return['address'] = isset($response['address']) ? $response['address'] : ''; |
|
895 | 895 | $return['message'] = $return['company'] . '<br/>' . $return['address']; |
896 | 896 | } |
897 | 897 | } else { |
898 | 898 | $return['valid'] = false; |
899 | - $return['message'] = wp_sprintf( __( 'Fail to validate the %s number: EU Commission VAT server (VIES) check fails.', 'invoicing' ), $vat_name ); |
|
899 | + $return['message'] = wp_sprintf(__('Fail to validate the %s number: EU Commission VAT server (VIES) check fails.', 'invoicing'), $vat_name); |
|
900 | 900 | } |
901 | 901 | |
902 | 902 | return $return; |
903 | 903 | } |
904 | 904 | |
905 | - public static function request_euvatrates( $group ) { |
|
905 | + public static function request_euvatrates($group) { |
|
906 | 906 | $response = array(); |
907 | 907 | $response['success'] = false; |
908 | 908 | $response['error'] = null; |
909 | 909 | $response['eurates'] = null; |
910 | 910 | |
911 | 911 | $euvatrates_url = 'https://euvatrates.com/rates.json'; |
912 | - $euvatrates_url = apply_filters( 'wpinv_euvatrates_url', $euvatrates_url ); |
|
913 | - $api_response = wp_remote_get( $euvatrates_url ); |
|
912 | + $euvatrates_url = apply_filters('wpinv_euvatrates_url', $euvatrates_url); |
|
913 | + $api_response = wp_remote_get($euvatrates_url); |
|
914 | 914 | |
915 | 915 | try { |
916 | - if ( is_wp_error( $api_response ) ) { |
|
917 | - $response['error'] = __( $api_response->get_error_message(), 'invoicing' ); |
|
916 | + if (is_wp_error($api_response)) { |
|
917 | + $response['error'] = __($api_response->get_error_message(), 'invoicing'); |
|
918 | 918 | } else { |
919 | - $body = json_decode( $api_response['body'] ); |
|
920 | - if ( isset( $body->rates ) ) { |
|
919 | + $body = json_decode($api_response['body']); |
|
920 | + if (isset($body->rates)) { |
|
921 | 921 | $rates = array(); |
922 | 922 | |
923 | - foreach ( $body->rates as $country_code => $rate ) { |
|
923 | + foreach ($body->rates as $country_code => $rate) { |
|
924 | 924 | $vat_rate = array(); |
925 | 925 | $vat_rate['country'] = $rate->country; |
926 | - $vat_rate['standard'] = (float)$rate->standard_rate; |
|
927 | - $vat_rate['reduced'] = (float)$rate->reduced_rate; |
|
928 | - $vat_rate['superreduced'] = (float)$rate->super_reduced_rate; |
|
929 | - $vat_rate['parking'] = (float)$rate->parking_rate; |
|
926 | + $vat_rate['standard'] = (float) $rate->standard_rate; |
|
927 | + $vat_rate['reduced'] = (float) $rate->reduced_rate; |
|
928 | + $vat_rate['superreduced'] = (float) $rate->super_reduced_rate; |
|
929 | + $vat_rate['parking'] = (float) $rate->parking_rate; |
|
930 | 930 | |
931 | - if ( $group !== '' && in_array( $group, array( 'standard', 'reduced', 'superreduced', 'parking' ) ) ) { |
|
931 | + if ($group !== '' && in_array($group, array('standard', 'reduced', 'superreduced', 'parking'))) { |
|
932 | 932 | $vat_rate_group = array(); |
933 | 933 | $vat_rate_group['country'] = $rate->country; |
934 | 934 | $vat_rate_group[$group] = $vat_rate[$group]; |
@@ -940,79 +940,79 @@ discard block |
||
940 | 940 | } |
941 | 941 | |
942 | 942 | $response['success'] = true; |
943 | - $response['rates'] = apply_filters( 'wpinv_process_euvatrates', $rates, $api_response, $group ); |
|
943 | + $response['rates'] = apply_filters('wpinv_process_euvatrates', $rates, $api_response, $group); |
|
944 | 944 | } else { |
945 | - $response['error'] = __( 'No EU rates found!', 'invoicing' ); |
|
945 | + $response['error'] = __('No EU rates found!', 'invoicing'); |
|
946 | 946 | } |
947 | 947 | } |
948 | - } catch ( Exception $e ) { |
|
949 | - $response['error'] = __( $e->getMessage(), 'invoicing' ); |
|
948 | + } catch (Exception $e) { |
|
949 | + $response['error'] = __($e->getMessage(), 'invoicing'); |
|
950 | 950 | } |
951 | 951 | |
952 | - return apply_filters( 'wpinv_response_euvatrates', $response, $group ); |
|
952 | + return apply_filters('wpinv_response_euvatrates', $response, $group); |
|
953 | 953 | } |
954 | 954 | |
955 | - public static function requires_vat( $requires_vat = false, $user_id = 0, $is_digital = null ) { |
|
955 | + public static function requires_vat($requires_vat = false, $user_id = 0, $is_digital = null) { |
|
956 | 956 | global $wpi_item_id, $wpi_country; |
957 | 957 | |
958 | - if ( !empty( $_POST['wpinv_country'] ) ) { |
|
959 | - $country_code = trim( $_POST['wpinv_country'] ); |
|
960 | - } else if ( !empty( $_POST['country'] ) ) { |
|
961 | - $country_code = trim( $_POST['country'] ); |
|
962 | - } else if ( !empty( $wpi_country ) ) { |
|
958 | + if (!empty($_POST['wpinv_country'])) { |
|
959 | + $country_code = trim($_POST['wpinv_country']); |
|
960 | + } else if (!empty($_POST['country'])) { |
|
961 | + $country_code = trim($_POST['country']); |
|
962 | + } else if (!empty($wpi_country)) { |
|
963 | 963 | $country_code = $wpi_country; |
964 | 964 | } else { |
965 | - $country_code = self::get_user_country( '', $user_id ); |
|
965 | + $country_code = self::get_user_country('', $user_id); |
|
966 | 966 | } |
967 | 967 | |
968 | - if ( $is_digital === null && $wpi_item_id ) { |
|
969 | - $is_digital = $wpi_item_id ? self::item_has_digital_rule( $wpi_item_id ) : self::allow_vat_rules(); |
|
968 | + if ($is_digital === null && $wpi_item_id) { |
|
969 | + $is_digital = $wpi_item_id ? self::item_has_digital_rule($wpi_item_id) : self::allow_vat_rules(); |
|
970 | 970 | } |
971 | 971 | |
972 | - if ( !empty( $country_code ) ) { |
|
973 | - $requires_vat = ( self::is_eu_state( $country_code ) && ( self::is_eu_state( wpinv_get_default_country() ) || $is_digital ) ) || ( self::is_gst_country( $country_code ) && self::is_gst_country( wpinv_get_default_country() ) ); |
|
972 | + if (!empty($country_code)) { |
|
973 | + $requires_vat = (self::is_eu_state($country_code) && (self::is_eu_state(wpinv_get_default_country()) || $is_digital)) || (self::is_gst_country($country_code) && self::is_gst_country(wpinv_get_default_country())); |
|
974 | 974 | } |
975 | 975 | |
976 | - return apply_filters( 'wpinv_requires_vat', $requires_vat, $user_id ); |
|
976 | + return apply_filters('wpinv_requires_vat', $requires_vat, $user_id); |
|
977 | 977 | } |
978 | 978 | |
979 | - public static function tax_label( $label = '' ) { |
|
979 | + public static function tax_label($label = '') { |
|
980 | 980 | global $wpi_requires_vat; |
981 | 981 | |
982 | - if ( !( $wpi_requires_vat !== 0 && $wpi_requires_vat ) ) { |
|
983 | - $wpi_requires_vat = self::requires_vat( 0, false ); |
|
982 | + if (!($wpi_requires_vat !== 0 && $wpi_requires_vat)) { |
|
983 | + $wpi_requires_vat = self::requires_vat(0, false); |
|
984 | 984 | } |
985 | 985 | |
986 | - return $wpi_requires_vat ? __( self::get_vat_name(), 'invoicing' ) : ( $label ? $label : __( 'Tax', 'invoicing' ) ); |
|
986 | + return $wpi_requires_vat ? __(self::get_vat_name(), 'invoicing') : ($label ? $label : __('Tax', 'invoicing')); |
|
987 | 987 | } |
988 | 988 | |
989 | 989 | public static function standard_rates_label() { |
990 | - return __( 'Standard Rates', 'invoicing' ); |
|
990 | + return __('Standard Rates', 'invoicing'); |
|
991 | 991 | } |
992 | 992 | |
993 | - public static function get_rate_classes( $with_desc = false ) { |
|
994 | - $rate_classes_option = get_option( '_wpinv_vat_rate_classes', true ); |
|
995 | - $classes = maybe_unserialize( $rate_classes_option ); |
|
993 | + public static function get_rate_classes($with_desc = false) { |
|
994 | + $rate_classes_option = get_option('_wpinv_vat_rate_classes', true); |
|
995 | + $classes = maybe_unserialize($rate_classes_option); |
|
996 | 996 | |
997 | - if ( empty( $classes ) || !is_array( $classes ) ) { |
|
997 | + if (empty($classes) || !is_array($classes)) { |
|
998 | 998 | $classes = array(); |
999 | 999 | } |
1000 | 1000 | |
1001 | 1001 | $rate_classes = array(); |
1002 | - if ( !array_key_exists( '_standard', $classes ) ) { |
|
1003 | - if ( $with_desc ) { |
|
1004 | - $rate_classes['_standard'] = array( 'name' => self::standard_rates_label(), 'desc' => __( 'EU member states standard VAT rates', 'invoicing' ) ); |
|
1002 | + if (!array_key_exists('_standard', $classes)) { |
|
1003 | + if ($with_desc) { |
|
1004 | + $rate_classes['_standard'] = array('name' => self::standard_rates_label(), 'desc' => __('EU member states standard VAT rates', 'invoicing')); |
|
1005 | 1005 | } else { |
1006 | 1006 | $rate_classes['_standard'] = self::standard_rates_label(); |
1007 | 1007 | } |
1008 | 1008 | } |
1009 | 1009 | |
1010 | - foreach ( $classes as $key => $class ) { |
|
1011 | - $name = !empty( $class['name'] ) ? __( $class['name'], 'invoicing' ) : $key; |
|
1012 | - $desc = !empty( $class['desc'] ) ? __( $class['desc'], 'invoicing' ) : ''; |
|
1010 | + foreach ($classes as $key => $class) { |
|
1011 | + $name = !empty($class['name']) ? __($class['name'], 'invoicing') : $key; |
|
1012 | + $desc = !empty($class['desc']) ? __($class['desc'], 'invoicing') : ''; |
|
1013 | 1013 | |
1014 | - if ( $with_desc ) { |
|
1015 | - $rate_classes[$key] = array( 'name' => $name, 'desc' => $desc ); |
|
1014 | + if ($with_desc) { |
|
1015 | + $rate_classes[$key] = array('name' => $name, 'desc' => $desc); |
|
1016 | 1016 | } else { |
1017 | 1017 | $rate_classes[$key] = $name; |
1018 | 1018 | } |
@@ -1023,15 +1023,15 @@ discard block |
||
1023 | 1023 | |
1024 | 1024 | public static function get_all_classes() { |
1025 | 1025 | $classes = self::get_rate_classes(); |
1026 | - $classes['_exempt'] = __( 'Exempt (0%)', 'invoicing' ); |
|
1026 | + $classes['_exempt'] = __('Exempt (0%)', 'invoicing'); |
|
1027 | 1027 | |
1028 | - return apply_filters( 'wpinv_vat_get_all_classes', $classes ); |
|
1028 | + return apply_filters('wpinv_vat_get_all_classes', $classes); |
|
1029 | 1029 | } |
1030 | 1030 | |
1031 | - public static function get_class_desc( $rate_class ) { |
|
1032 | - $rate_classes = self::get_rate_classes( true ); |
|
1031 | + public static function get_class_desc($rate_class) { |
|
1032 | + $rate_classes = self::get_rate_classes(true); |
|
1033 | 1033 | |
1034 | - if ( !empty( $rate_classes ) && isset( $rate_classes[$rate_class] ) && isset( $rate_classes[$rate_class]['desc'] ) ) { |
|
1034 | + if (!empty($rate_classes) && isset($rate_classes[$rate_class]) && isset($rate_classes[$rate_class]['desc'])) { |
|
1035 | 1035 | return $rate_classes[$rate_class]['desc']; |
1036 | 1036 | } |
1037 | 1037 | |
@@ -1047,107 +1047,107 @@ discard block |
||
1047 | 1047 | 'increased' => 'Increased' |
1048 | 1048 | ); |
1049 | 1049 | |
1050 | - return apply_filters( 'wpinv_get_vat_groups', $vat_groups ); |
|
1050 | + return apply_filters('wpinv_get_vat_groups', $vat_groups); |
|
1051 | 1051 | } |
1052 | 1052 | |
1053 | 1053 | public static function get_rules() { |
1054 | 1054 | $vat_rules = array( |
1055 | - 'digital' => __( 'Digital Product', 'invoicing' ), |
|
1056 | - 'physical' => __( 'Physical Product', 'invoicing' ), |
|
1057 | - '_exempt' => __( 'Tax-Free Product', 'invoicing' ), |
|
1055 | + 'digital' => __('Digital Product', 'invoicing'), |
|
1056 | + 'physical' => __('Physical Product', 'invoicing'), |
|
1057 | + '_exempt' => __('Tax-Free Product', 'invoicing'), |
|
1058 | 1058 | ); |
1059 | - return apply_filters( 'wpinv_get_vat_rules', $vat_rules ); |
|
1059 | + return apply_filters('wpinv_get_vat_rules', $vat_rules); |
|
1060 | 1060 | } |
1061 | 1061 | |
1062 | - public static function get_vat_rates( $class ) { |
|
1063 | - if ( $class === '_standard' ) { |
|
1062 | + public static function get_vat_rates($class) { |
|
1063 | + if ($class === '_standard') { |
|
1064 | 1064 | return wpinv_get_tax_rates(); |
1065 | 1065 | } |
1066 | 1066 | |
1067 | 1067 | $rates = self::get_non_standard_rates(); |
1068 | 1068 | |
1069 | - return array_key_exists( $class, $rates ) ? $rates[$class] : array(); |
|
1069 | + return array_key_exists($class, $rates) ? $rates[$class] : array(); |
|
1070 | 1070 | } |
1071 | 1071 | |
1072 | 1072 | public static function get_non_standard_rates() { |
1073 | - $option = get_option( 'wpinv_vat_rates', array()); |
|
1074 | - return is_array( $option ) ? $option : array(); |
|
1073 | + $option = get_option('wpinv_vat_rates', array()); |
|
1074 | + return is_array($option) ? $option : array(); |
|
1075 | 1075 | } |
1076 | 1076 | |
1077 | 1077 | public static function allow_vat_rules() { |
1078 | - return ( wpinv_use_taxes() && wpinv_get_option( 'apply_vat_rules' ) ? true : false ); |
|
1078 | + return (wpinv_use_taxes() && wpinv_get_option('apply_vat_rules') ? true : false); |
|
1079 | 1079 | } |
1080 | 1080 | |
1081 | 1081 | public static function allow_vat_classes() { |
1082 | 1082 | return false; // TODO |
1083 | - return ( wpinv_get_option( 'vat_allow_classes' ) ? true : false ); |
|
1083 | + return (wpinv_get_option('vat_allow_classes') ? true : false); |
|
1084 | 1084 | } |
1085 | 1085 | |
1086 | - public static function get_item_class( $postID ) { |
|
1087 | - $class = get_post_meta( $postID, '_wpinv_vat_class', true ); |
|
1086 | + public static function get_item_class($postID) { |
|
1087 | + $class = get_post_meta($postID, '_wpinv_vat_class', true); |
|
1088 | 1088 | |
1089 | - if ( empty( $class ) ) { |
|
1089 | + if (empty($class)) { |
|
1090 | 1090 | $class = '_standard'; |
1091 | 1091 | } |
1092 | 1092 | |
1093 | - return apply_filters( 'wpinv_get_item_vat_class', $class, $postID ); |
|
1093 | + return apply_filters('wpinv_get_item_vat_class', $class, $postID); |
|
1094 | 1094 | } |
1095 | 1095 | |
1096 | - public static function item_class_label( $postID ) { |
|
1096 | + public static function item_class_label($postID) { |
|
1097 | 1097 | $vat_classes = self::get_all_classes(); |
1098 | 1098 | |
1099 | - $class = self::get_item_class( $postID ); |
|
1100 | - $class = isset( $vat_classes[$class] ) ? $vat_classes[$class] : __( $class, 'invoicing' ); |
|
1099 | + $class = self::get_item_class($postID); |
|
1100 | + $class = isset($vat_classes[$class]) ? $vat_classes[$class] : __($class, 'invoicing'); |
|
1101 | 1101 | |
1102 | - return apply_filters( 'wpinv_item_class_label', $class, $postID ); |
|
1102 | + return apply_filters('wpinv_item_class_label', $class, $postID); |
|
1103 | 1103 | } |
1104 | 1104 | |
1105 | - public static function get_item_rule( $postID ) { |
|
1106 | - $rule_type = get_post_meta( $postID, '_wpinv_vat_rule', true ); |
|
1105 | + public static function get_item_rule($postID) { |
|
1106 | + $rule_type = get_post_meta($postID, '_wpinv_vat_rule', true); |
|
1107 | 1107 | |
1108 | - if ( empty( $rule_type ) ) { |
|
1108 | + if (empty($rule_type)) { |
|
1109 | 1109 | $rule_type = self::allow_vat_rules() ? 'digital' : 'physical'; |
1110 | 1110 | } |
1111 | 1111 | |
1112 | - return apply_filters( 'wpinv_item_get_vat_rule', $rule_type, $postID ); |
|
1112 | + return apply_filters('wpinv_item_get_vat_rule', $rule_type, $postID); |
|
1113 | 1113 | } |
1114 | 1114 | |
1115 | - public static function item_rule_label( $postID ) { |
|
1115 | + public static function item_rule_label($postID) { |
|
1116 | 1116 | $vat_rules = self::get_rules(); |
1117 | - $vat_rule = self::get_item_rule( $postID ); |
|
1118 | - $vat_rule = isset( $vat_rules[$vat_rule] ) ? $vat_rules[$vat_rule] : $vat_rule; |
|
1117 | + $vat_rule = self::get_item_rule($postID); |
|
1118 | + $vat_rule = isset($vat_rules[$vat_rule]) ? $vat_rules[$vat_rule] : $vat_rule; |
|
1119 | 1119 | |
1120 | - return apply_filters( 'wpinv_item_rule_label', $vat_rule, $postID ); |
|
1120 | + return apply_filters('wpinv_item_rule_label', $vat_rule, $postID); |
|
1121 | 1121 | } |
1122 | 1122 | |
1123 | - public static function item_has_digital_rule( $item_id = 0 ) { |
|
1124 | - return self::get_item_rule( $item_id ) == 'digital' ? true : false; |
|
1123 | + public static function item_has_digital_rule($item_id = 0) { |
|
1124 | + return self::get_item_rule($item_id) == 'digital' ? true : false; |
|
1125 | 1125 | } |
1126 | 1126 | |
1127 | - public static function invoice_has_digital_rule( $invoice = 0 ) { |
|
1128 | - if ( !self::allow_vat_rules() ) { |
|
1127 | + public static function invoice_has_digital_rule($invoice = 0) { |
|
1128 | + if (!self::allow_vat_rules()) { |
|
1129 | 1129 | return false; |
1130 | 1130 | } |
1131 | 1131 | |
1132 | - if ( empty( $invoice ) ) { |
|
1132 | + if (empty($invoice)) { |
|
1133 | 1133 | return true; |
1134 | 1134 | } |
1135 | 1135 | |
1136 | - if ( is_int( $invoice ) ) { |
|
1137 | - $invoice = new WPInv_Invoice( $invoice ); |
|
1136 | + if (is_int($invoice)) { |
|
1137 | + $invoice = new WPInv_Invoice($invoice); |
|
1138 | 1138 | } |
1139 | 1139 | |
1140 | - if ( !( is_object( $invoice ) && is_a( $invoice, 'WPInv_Invoice' ) ) ) { |
|
1140 | + if (!(is_object($invoice) && is_a($invoice, 'WPInv_Invoice'))) { |
|
1141 | 1141 | return true; |
1142 | 1142 | } |
1143 | 1143 | |
1144 | - $cart_items = $invoice->get_cart_details(); |
|
1144 | + $cart_items = $invoice->get_cart_details(); |
|
1145 | 1145 | |
1146 | - if ( !empty( $cart_items ) ) { |
|
1146 | + if (!empty($cart_items)) { |
|
1147 | 1147 | $has_digital_rule = false; |
1148 | 1148 | |
1149 | - foreach ( $cart_items as $key => $item ) { |
|
1150 | - if ( self::item_has_digital_rule( $item['id'] ) ) { |
|
1149 | + foreach ($cart_items as $key => $item) { |
|
1150 | + if (self::item_has_digital_rule($item['id'])) { |
|
1151 | 1151 | $has_digital_rule = true; |
1152 | 1152 | break; |
1153 | 1153 | } |
@@ -1159,71 +1159,71 @@ discard block |
||
1159 | 1159 | return $has_digital_rule; |
1160 | 1160 | } |
1161 | 1161 | |
1162 | - public static function item_is_taxable( $item_id = 0, $country = false, $state = false ) { |
|
1163 | - if ( !wpinv_use_taxes() ) { |
|
1162 | + public static function item_is_taxable($item_id = 0, $country = false, $state = false) { |
|
1163 | + if (!wpinv_use_taxes()) { |
|
1164 | 1164 | return false; |
1165 | 1165 | } |
1166 | 1166 | |
1167 | 1167 | $is_taxable = true; |
1168 | 1168 | |
1169 | - if ( !empty( $item_id ) && self::get_item_class( $item_id ) == '_exempt' ) { |
|
1169 | + if (!empty($item_id) && self::get_item_class($item_id) == '_exempt') { |
|
1170 | 1170 | $is_taxable = false; |
1171 | 1171 | } |
1172 | 1172 | |
1173 | - if ( !empty( $item_id ) && self::get_item_rule( $item_id ) == '_exempt' ) { |
|
1173 | + if (!empty($item_id) && self::get_item_rule($item_id) == '_exempt') { |
|
1174 | 1174 | $is_taxable = false; |
1175 | 1175 | } |
1176 | 1176 | |
1177 | - return apply_filters( 'wpinv_item_is_taxable', $is_taxable, $item_id, $country , $state ); |
|
1177 | + return apply_filters('wpinv_item_is_taxable', $is_taxable, $item_id, $country, $state); |
|
1178 | 1178 | } |
1179 | 1179 | |
1180 | - public static function find_rate( $country, $state, $rate, $class ) { |
|
1180 | + public static function find_rate($country, $state, $rate, $class) { |
|
1181 | 1181 | global $wpi_zero_tax; |
1182 | 1182 | |
1183 | - if ( $class === '_exempt' || $wpi_zero_tax ) { |
|
1183 | + if ($class === '_exempt' || $wpi_zero_tax) { |
|
1184 | 1184 | return 0; |
1185 | 1185 | } |
1186 | 1186 | |
1187 | - $tax_rates = wpinv_get_tax_rates(); |
|
1187 | + $tax_rates = wpinv_get_tax_rates(); |
|
1188 | 1188 | |
1189 | - if ( $class !== '_standard' ) { |
|
1190 | - $class_rates = self::get_vat_rates( $class ); |
|
1189 | + if ($class !== '_standard') { |
|
1190 | + $class_rates = self::get_vat_rates($class); |
|
1191 | 1191 | |
1192 | - if ( is_array( $class_rates ) ) { |
|
1192 | + if (is_array($class_rates)) { |
|
1193 | 1193 | $indexed_class_rates = array(); |
1194 | 1194 | |
1195 | - foreach ( $class_rates as $key => $cr ) { |
|
1195 | + foreach ($class_rates as $key => $cr) { |
|
1196 | 1196 | $indexed_class_rates[$cr['country']] = $cr; |
1197 | 1197 | } |
1198 | 1198 | |
1199 | - $tax_rates = array_map( function( $tr ) use( $indexed_class_rates ) { |
|
1199 | + $tax_rates = array_map(function($tr) use($indexed_class_rates) { |
|
1200 | 1200 | $tr_country = $tr['country']; |
1201 | - if ( !isset( $indexed_class_rates[$tr_country] ) ) { |
|
1201 | + if (!isset($indexed_class_rates[$tr_country])) { |
|
1202 | 1202 | return $tr; |
1203 | 1203 | } |
1204 | 1204 | $icr = $indexed_class_rates[$tr_country]; |
1205 | - return ( empty( $icr['rate'] ) && $icr['rate'] !== '0' ) ? $tr : $icr; |
|
1205 | + return (empty($icr['rate']) && $icr['rate'] !== '0') ? $tr : $icr; |
|
1206 | 1206 | |
1207 | - }, $tax_rates, $class_rates ); |
|
1207 | + }, $tax_rates, $class_rates); |
|
1208 | 1208 | } |
1209 | 1209 | } |
1210 | 1210 | |
1211 | - if ( !empty( $tax_rates ) ) { |
|
1212 | - foreach ( $tax_rates as $key => $tax_rate ) { |
|
1213 | - if ( $country != $tax_rate['country'] ) |
|
1211 | + if (!empty($tax_rates)) { |
|
1212 | + foreach ($tax_rates as $key => $tax_rate) { |
|
1213 | + if ($country != $tax_rate['country']) |
|
1214 | 1214 | continue; |
1215 | 1215 | |
1216 | - if ( !empty( $tax_rate['global'] ) ) { |
|
1217 | - if ( 0 !== $tax_rate['rate'] || !empty( $tax_rate['rate'] ) ) { |
|
1218 | - $rate = number_format( $tax_rate['rate'], 4 ); |
|
1216 | + if (!empty($tax_rate['global'])) { |
|
1217 | + if (0 !== $tax_rate['rate'] || !empty($tax_rate['rate'])) { |
|
1218 | + $rate = number_format($tax_rate['rate'], 4); |
|
1219 | 1219 | } |
1220 | 1220 | } else { |
1221 | - if ( empty( $tax_rate['state'] ) || strtolower( $state ) != strtolower( $tax_rate['state'] ) ) |
|
1221 | + if (empty($tax_rate['state']) || strtolower($state) != strtolower($tax_rate['state'])) |
|
1222 | 1222 | continue; |
1223 | 1223 | |
1224 | 1224 | $state_rate = $tax_rate['rate']; |
1225 | - if ( 0 !== $state_rate || !empty( $state_rate ) ) { |
|
1226 | - $rate = number_format( $state_rate, 4 ); |
|
1225 | + if (0 !== $state_rate || !empty($state_rate)) { |
|
1226 | + $rate = number_format($state_rate, 4); |
|
1227 | 1227 | } |
1228 | 1228 | } |
1229 | 1229 | } |
@@ -1232,84 +1232,84 @@ discard block |
||
1232 | 1232 | return $rate; |
1233 | 1233 | } |
1234 | 1234 | |
1235 | - public static function get_rate( $rate = 1, $country = '', $state = '', $item_id = 0 ) { |
|
1235 | + public static function get_rate($rate = 1, $country = '', $state = '', $item_id = 0) { |
|
1236 | 1236 | global $wpinv_options, $wpi_item_id, $wpi_zero_tax; |
1237 | 1237 | |
1238 | 1238 | $item_id = $item_id > 0 ? $item_id : $wpi_item_id; |
1239 | 1239 | $allow_vat_classes = self::allow_vat_classes(); |
1240 | - $class = $item_id ? self::get_item_class( $item_id ) : '_standard'; |
|
1240 | + $class = $item_id ? self::get_item_class($item_id) : '_standard'; |
|
1241 | 1241 | |
1242 | - if ( $class === '_exempt' || $wpi_zero_tax ) { |
|
1242 | + if ($class === '_exempt' || $wpi_zero_tax) { |
|
1243 | 1243 | return 0; |
1244 | - } else if ( !$allow_vat_classes ) { |
|
1244 | + } else if (!$allow_vat_classes) { |
|
1245 | 1245 | $class = '_standard'; |
1246 | 1246 | } |
1247 | 1247 | |
1248 | - if( !empty( $_POST['wpinv_country'] ) ) { |
|
1248 | + if (!empty($_POST['wpinv_country'])) { |
|
1249 | 1249 | $post_country = $_POST['wpinv_country']; |
1250 | - } elseif( !empty( $_POST['wpinv_country'] ) ) { |
|
1250 | + } elseif (!empty($_POST['wpinv_country'])) { |
|
1251 | 1251 | $post_country = $_POST['wpinv_country']; |
1252 | - } elseif( !empty( $_POST['country'] ) ) { |
|
1252 | + } elseif (!empty($_POST['country'])) { |
|
1253 | 1253 | $post_country = $_POST['country']; |
1254 | 1254 | } else { |
1255 | 1255 | $post_country = ''; |
1256 | 1256 | } |
1257 | 1257 | |
1258 | - $country = !empty( $post_country ) ? $post_country : wpinv_default_billing_country( $country ); |
|
1259 | - $base_country = wpinv_is_base_country( $country ); |
|
1258 | + $country = !empty($post_country) ? $post_country : wpinv_default_billing_country($country); |
|
1259 | + $base_country = wpinv_is_base_country($country); |
|
1260 | 1260 | |
1261 | - $requires_vat = self::requires_vat( 0, false ); |
|
1262 | - $is_digital = self::get_item_rule( $item_id ) == 'digital' ; |
|
1263 | - $rate = $requires_vat && isset( $wpinv_options['eu_fallback_rate'] ) ? $wpinv_options['eu_fallback_rate'] : $rate; |
|
1261 | + $requires_vat = self::requires_vat(0, false); |
|
1262 | + $is_digital = self::get_item_rule($item_id) == 'digital'; |
|
1263 | + $rate = $requires_vat && isset($wpinv_options['eu_fallback_rate']) ? $wpinv_options['eu_fallback_rate'] : $rate; |
|
1264 | 1264 | |
1265 | - if ( self::same_country_rule() == 'no' && $base_country ) { // Disable VAT to same country |
|
1265 | + if (self::same_country_rule() == 'no' && $base_country) { // Disable VAT to same country |
|
1266 | 1266 | $rate = 0; |
1267 | - } else if ( $requires_vat ) { |
|
1268 | - $vat_number = self::get_user_vat_number( '', 0, true ); |
|
1267 | + } else if ($requires_vat) { |
|
1268 | + $vat_number = self::get_user_vat_number('', 0, true); |
|
1269 | 1269 | $vat_info = self::current_vat_data(); |
1270 | 1270 | |
1271 | - if ( is_array( $vat_info ) ) { |
|
1272 | - $vat_number = isset( $vat_info['number'] ) && !empty( $vat_info['valid'] ) ? $vat_info['number'] : ""; |
|
1271 | + if (is_array($vat_info)) { |
|
1272 | + $vat_number = isset($vat_info['number']) && !empty($vat_info['valid']) ? $vat_info['number'] : ""; |
|
1273 | 1273 | } |
1274 | 1274 | |
1275 | - if ( $country == 'UK' ) { |
|
1275 | + if ($country == 'UK') { |
|
1276 | 1276 | $country = 'GB'; |
1277 | 1277 | } |
1278 | 1278 | |
1279 | - if ( !empty( $vat_number ) ) { |
|
1279 | + if (!empty($vat_number)) { |
|
1280 | 1280 | $rate = 0; |
1281 | 1281 | } else { |
1282 | - $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 |
|
1282 | + $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 |
|
1283 | 1283 | } |
1284 | 1284 | |
1285 | - if ( empty( $vat_number ) && !$is_digital ) { |
|
1286 | - if ( $base_country ) { |
|
1287 | - $rate = self::find_rate( $country, null, $rate, $class ); |
|
1285 | + if (empty($vat_number) && !$is_digital) { |
|
1286 | + if ($base_country) { |
|
1287 | + $rate = self::find_rate($country, null, $rate, $class); |
|
1288 | 1288 | } else { |
1289 | - if ( empty( $country ) && isset( $wpinv_options['eu_fallback_rate'] ) ) { |
|
1289 | + if (empty($country) && isset($wpinv_options['eu_fallback_rate'])) { |
|
1290 | 1290 | $rate = $wpinv_options['eu_fallback_rate']; |
1291 | - } else if( !empty( $country ) ) { |
|
1292 | - $rate = self::find_rate( $country, $state, $rate, $class ); |
|
1291 | + } else if (!empty($country)) { |
|
1292 | + $rate = self::find_rate($country, $state, $rate, $class); |
|
1293 | 1293 | } |
1294 | 1294 | } |
1295 | - } else if ( empty( $vat_number ) || ( self::same_country_rule() == 'always' && $base_country ) ) { |
|
1296 | - if ( empty( $country ) && isset( $wpinv_options['eu_fallback_rate'] ) ) { |
|
1295 | + } else if (empty($vat_number) || (self::same_country_rule() == 'always' && $base_country)) { |
|
1296 | + if (empty($country) && isset($wpinv_options['eu_fallback_rate'])) { |
|
1297 | 1297 | $rate = $wpinv_options['eu_fallback_rate']; |
1298 | - } else if( !empty( $country ) ) { |
|
1299 | - $rate = self::find_rate( $country, $state, $rate, $class ); |
|
1298 | + } else if (!empty($country)) { |
|
1299 | + $rate = self::find_rate($country, $state, $rate, $class); |
|
1300 | 1300 | } |
1301 | 1301 | } |
1302 | 1302 | } else { |
1303 | - if ( $is_digital ) { |
|
1303 | + if ($is_digital) { |
|
1304 | 1304 | $ip_country_code = getpaid_get_ip_country(); |
1305 | 1305 | |
1306 | - if ( $ip_country_code && self::is_eu_state( $ip_country_code ) ) { |
|
1307 | - $rate = self::find_rate( $ip_country_code, '', 0, $class ); |
|
1306 | + if ($ip_country_code && self::is_eu_state($ip_country_code)) { |
|
1307 | + $rate = self::find_rate($ip_country_code, '', 0, $class); |
|
1308 | 1308 | } else { |
1309 | - $rate = self::find_rate( $country, $state, $rate, $class ); |
|
1309 | + $rate = self::find_rate($country, $state, $rate, $class); |
|
1310 | 1310 | } |
1311 | 1311 | } else { |
1312 | - $rate = self::find_rate( $country, $state, $rate, $class ); |
|
1312 | + $rate = self::find_rate($country, $state, $rate, $class); |
|
1313 | 1313 | } |
1314 | 1314 | } |
1315 | 1315 | |
@@ -1317,44 +1317,44 @@ discard block |
||
1317 | 1317 | } |
1318 | 1318 | |
1319 | 1319 | public static function current_vat_data() { |
1320 | - return getpaid_session()->get( 'user_vat_data' ); |
|
1320 | + return getpaid_session()->get('user_vat_data'); |
|
1321 | 1321 | } |
1322 | 1322 | |
1323 | - public static function get_user_country( $country = '', $user_id = 0 ) { |
|
1324 | - $user_address = wpinv_get_user_address( $user_id, false ); |
|
1323 | + public static function get_user_country($country = '', $user_id = 0) { |
|
1324 | + $user_address = wpinv_get_user_address($user_id, false); |
|
1325 | 1325 | |
1326 | - $country = empty( $user_address ) || !isset( $user_address['country'] ) || empty( $user_address['country'] ) ? $country : $user_address['country']; |
|
1327 | - $result = apply_filters( 'wpinv_get_user_country', $country, $user_id ); |
|
1326 | + $country = empty($user_address) || !isset($user_address['country']) || empty($user_address['country']) ? $country : $user_address['country']; |
|
1327 | + $result = apply_filters('wpinv_get_user_country', $country, $user_id); |
|
1328 | 1328 | |
1329 | - if ( empty( $result ) ) { |
|
1329 | + if (empty($result)) { |
|
1330 | 1330 | $result = getpaid_get_ip_country(); |
1331 | 1331 | } |
1332 | 1332 | |
1333 | 1333 | return $result; |
1334 | 1334 | } |
1335 | 1335 | |
1336 | - public static function set_user_country( $country = '', $user_id = 0 ) { |
|
1336 | + public static function set_user_country($country = '', $user_id = 0) { |
|
1337 | 1337 | global $wpi_userID; |
1338 | 1338 | |
1339 | - if ( empty($country) && !empty($wpi_userID) && get_current_user_id() != $wpi_userID ) { |
|
1339 | + if (empty($country) && !empty($wpi_userID) && get_current_user_id() != $wpi_userID) { |
|
1340 | 1340 | $country = wpinv_get_default_country(); |
1341 | 1341 | } |
1342 | 1342 | |
1343 | 1343 | return $country; |
1344 | 1344 | } |
1345 | 1345 | |
1346 | - public static function get_user_vat_number( $vat_number = '', $user_id = 0, $is_valid = false ) { |
|
1346 | + public static function get_user_vat_number($vat_number = '', $user_id = 0, $is_valid = false) { |
|
1347 | 1347 | global $wpi_current_id, $wpi_userID; |
1348 | 1348 | |
1349 | - if ( !empty( $_POST['new_user'] ) ) { |
|
1349 | + if (!empty($_POST['new_user'])) { |
|
1350 | 1350 | return ''; |
1351 | 1351 | } |
1352 | 1352 | |
1353 | - if ( empty( $user_id ) ) { |
|
1354 | - $user_id = !empty( $wpi_userID ) ? $wpi_userID : ( $wpi_current_id ? wpinv_get_user_id( $wpi_current_id ) : get_current_user_id() ); |
|
1353 | + if (empty($user_id)) { |
|
1354 | + $user_id = !empty($wpi_userID) ? $wpi_userID : ($wpi_current_id ? wpinv_get_user_id($wpi_current_id) : get_current_user_id()); |
|
1355 | 1355 | } |
1356 | 1356 | |
1357 | - $vat_number = empty( $user_id ) ? '' : get_user_meta( $user_id, '_wpinv_vat_number', true ); |
|
1357 | + $vat_number = empty($user_id) ? '' : get_user_meta($user_id, '_wpinv_vat_number', true); |
|
1358 | 1358 | |
1359 | 1359 | /* TODO |
1360 | 1360 | if ( $is_valid && $vat_number ) { |
@@ -1365,38 +1365,38 @@ discard block |
||
1365 | 1365 | } |
1366 | 1366 | */ |
1367 | 1367 | |
1368 | - return apply_filters('wpinv_get_user_vat_number', $vat_number, $user_id, $is_valid ); |
|
1368 | + return apply_filters('wpinv_get_user_vat_number', $vat_number, $user_id, $is_valid); |
|
1369 | 1369 | } |
1370 | 1370 | |
1371 | - public static function get_user_company( $company = '', $user_id = 0 ) { |
|
1371 | + public static function get_user_company($company = '', $user_id = 0) { |
|
1372 | 1372 | global $wpi_current_id, $wpi_userID; |
1373 | 1373 | |
1374 | - if ( empty( $user_id ) ) { |
|
1375 | - $user_id = !empty( $wpi_userID ) ? $wpi_userID : ( $wpi_current_id ? wpinv_get_user_id( $wpi_current_id ) : get_current_user_id() ); |
|
1374 | + if (empty($user_id)) { |
|
1375 | + $user_id = !empty($wpi_userID) ? $wpi_userID : ($wpi_current_id ? wpinv_get_user_id($wpi_current_id) : get_current_user_id()); |
|
1376 | 1376 | } |
1377 | 1377 | |
1378 | - $company = empty( $user_id ) ? "" : get_user_meta( $user_id, '_wpinv_company', true ); |
|
1378 | + $company = empty($user_id) ? "" : get_user_meta($user_id, '_wpinv_company', true); |
|
1379 | 1379 | |
1380 | - return apply_filters( 'wpinv_user_company', $company, $user_id ); |
|
1380 | + return apply_filters('wpinv_user_company', $company, $user_id); |
|
1381 | 1381 | } |
1382 | 1382 | |
1383 | - public static function save_user_vat_details( $company = '', $vat_number = '' ) { |
|
1384 | - $save = apply_filters( 'wpinv_allow_save_user_vat_details', true ); |
|
1383 | + public static function save_user_vat_details($company = '', $vat_number = '') { |
|
1384 | + $save = apply_filters('wpinv_allow_save_user_vat_details', true); |
|
1385 | 1385 | |
1386 | - if ( is_user_logged_in() && $save ) { |
|
1386 | + if (is_user_logged_in() && $save) { |
|
1387 | 1387 | $user_id = get_current_user_id(); |
1388 | 1388 | |
1389 | - if ( !empty( $vat_number ) ) { |
|
1390 | - update_user_meta( $user_id, '_wpinv_vat_number', $vat_number ); |
|
1389 | + if (!empty($vat_number)) { |
|
1390 | + update_user_meta($user_id, '_wpinv_vat_number', $vat_number); |
|
1391 | 1391 | } else { |
1392 | - delete_user_meta( $user_id, '_wpinv_vat_number'); |
|
1392 | + delete_user_meta($user_id, '_wpinv_vat_number'); |
|
1393 | 1393 | } |
1394 | 1394 | |
1395 | - if ( !empty( $company ) ) { |
|
1396 | - update_user_meta( $user_id, '_wpinv_company', $company ); |
|
1395 | + if (!empty($company)) { |
|
1396 | + update_user_meta($user_id, '_wpinv_company', $company); |
|
1397 | 1397 | } else { |
1398 | - delete_user_meta( $user_id, '_wpinv_company'); |
|
1399 | - delete_user_meta( $user_id, '_wpinv_vat_number'); |
|
1398 | + delete_user_meta($user_id, '_wpinv_company'); |
|
1399 | + delete_user_meta($user_id, '_wpinv_vat_number'); |
|
1400 | 1400 | } |
1401 | 1401 | } |
1402 | 1402 | |
@@ -1409,74 +1409,74 @@ discard block |
||
1409 | 1409 | $response = array(); |
1410 | 1410 | $response['success'] = false; |
1411 | 1411 | |
1412 | - if ( empty( $_REQUEST['_wpi_nonce'] ) || ( !empty( $_REQUEST['_wpi_nonce'] ) && !wp_verify_nonce( $_REQUEST['_wpi_nonce'], 'vat_validation' ) ) ) { |
|
1413 | - $response['error'] = __( 'Invalid security nonce', 'invoicing' ); |
|
1414 | - wp_send_json( $response ); |
|
1412 | + if (empty($_REQUEST['_wpi_nonce']) || (!empty($_REQUEST['_wpi_nonce']) && !wp_verify_nonce($_REQUEST['_wpi_nonce'], 'vat_validation'))) { |
|
1413 | + $response['error'] = __('Invalid security nonce', 'invoicing'); |
|
1414 | + wp_send_json($response); |
|
1415 | 1415 | } |
1416 | 1416 | |
1417 | 1417 | $vat_name = self::get_vat_name(); |
1418 | 1418 | |
1419 | - $company = !empty( $_POST['company'] ) ? sanitize_text_field( $_POST['company'] ) : ''; |
|
1420 | - $vat_number = !empty( $_POST['number'] ) ? sanitize_text_field( $_POST['number'] ) : ''; |
|
1419 | + $company = !empty($_POST['company']) ? sanitize_text_field($_POST['company']) : ''; |
|
1420 | + $vat_number = !empty($_POST['number']) ? sanitize_text_field($_POST['number']) : ''; |
|
1421 | 1421 | |
1422 | - $vat_info = getpaid_session()->get( 'user_vat_data' ); |
|
1423 | - if ( !is_array( $vat_info ) || empty( $vat_info ) ) { |
|
1424 | - $vat_info = array( 'company'=> $company, 'number' => '', 'valid' => true ); |
|
1422 | + $vat_info = getpaid_session()->get('user_vat_data'); |
|
1423 | + if (!is_array($vat_info) || empty($vat_info)) { |
|
1424 | + $vat_info = array('company'=> $company, 'number' => '', 'valid' => true); |
|
1425 | 1425 | } |
1426 | 1426 | |
1427 | - if ( empty( $vat_number ) ) { |
|
1428 | - $response['error'] = wp_sprintf( __( 'Please enter your %s number!', 'invoicing' ), $vat_name ); |
|
1427 | + if (empty($vat_number)) { |
|
1428 | + $response['error'] = wp_sprintf(__('Please enter your %s number!', 'invoicing'), $vat_name); |
|
1429 | 1429 | $vat_info['valid'] = false; |
1430 | - getpaid_session()->set( 'user_vat_data', $vat_info ); |
|
1431 | - wp_send_json( $response ); |
|
1430 | + getpaid_session()->set('user_vat_data', $vat_info); |
|
1431 | + wp_send_json($response); |
|
1432 | 1432 | } |
1433 | 1433 | |
1434 | - if ( empty( $company ) ) { |
|
1434 | + if (empty($company)) { |
|
1435 | 1435 | $vat_info['valid'] = false; |
1436 | - getpaid_session()->set( 'user_vat_data', $vat_info ); |
|
1436 | + getpaid_session()->set('user_vat_data', $vat_info); |
|
1437 | 1437 | |
1438 | - $response['error'] = __( 'Please enter your registered company name!', 'invoicing' ); |
|
1439 | - wp_send_json( $response ); |
|
1438 | + $response['error'] = __('Please enter your registered company name!', 'invoicing'); |
|
1439 | + wp_send_json($response); |
|
1440 | 1440 | } |
1441 | 1441 | |
1442 | - if ( !empty( $wpinv_options['vat_vies_check'] ) ) { |
|
1443 | - if ( empty( $wpinv_options['vat_offline_check'] ) && !self::offline_check( $vat_number ) ) { |
|
1442 | + if (!empty($wpinv_options['vat_vies_check'])) { |
|
1443 | + if (empty($wpinv_options['vat_offline_check']) && !self::offline_check($vat_number)) { |
|
1444 | 1444 | $vat_info['valid'] = false; |
1445 | - getpaid_session()->set( 'user_vat_data', $vat_info ); |
|
1445 | + getpaid_session()->set('user_vat_data', $vat_info); |
|
1446 | 1446 | |
1447 | - $response['error'] = wp_sprintf( __( '%s number not validated', 'invoicing' ), $vat_name ); |
|
1448 | - wp_send_json( $response ); |
|
1447 | + $response['error'] = wp_sprintf(__('%s number not validated', 'invoicing'), $vat_name); |
|
1448 | + wp_send_json($response); |
|
1449 | 1449 | } |
1450 | 1450 | |
1451 | 1451 | $response['success'] = true; |
1452 | - $response['message'] = wp_sprintf( __( '%s number validated', 'invoicing' ), $vat_name ); |
|
1452 | + $response['message'] = wp_sprintf(__('%s number validated', 'invoicing'), $vat_name); |
|
1453 | 1453 | } else { |
1454 | - $result = self::check_vat( $vat_number ); |
|
1454 | + $result = self::check_vat($vat_number); |
|
1455 | 1455 | |
1456 | - if ( empty( $result['valid'] ) ) { |
|
1456 | + if (empty($result['valid'])) { |
|
1457 | 1457 | $response['error'] = $result['message']; |
1458 | - wp_send_json( $response ); |
|
1458 | + wp_send_json($response); |
|
1459 | 1459 | } |
1460 | 1460 | |
1461 | - $vies_company = !empty( $result['company'] ) ? $result['company'] : ''; |
|
1462 | - $vies_company = apply_filters( 'wpinv_vies_company_name', $vies_company ); |
|
1461 | + $vies_company = !empty($result['company']) ? $result['company'] : ''; |
|
1462 | + $vies_company = apply_filters('wpinv_vies_company_name', $vies_company); |
|
1463 | 1463 | |
1464 | - $valid_company = $vies_company && $company && ( $vies_company == '---' || strcasecmp( trim( $vies_company ), trim( $company ) ) == 0 ) ? true : false; |
|
1464 | + $valid_company = $vies_company && $company && ($vies_company == '---' || strcasecmp(trim($vies_company), trim($company)) == 0) ? true : false; |
|
1465 | 1465 | |
1466 | - if ( !empty( $wpinv_options['vat_disable_company_name_check'] ) || $valid_company ) { |
|
1466 | + if (!empty($wpinv_options['vat_disable_company_name_check']) || $valid_company) { |
|
1467 | 1467 | $response['success'] = true; |
1468 | - $response['message'] = wp_sprintf( __( '%s number validated', 'invoicing' ), $vat_name ); |
|
1468 | + $response['message'] = wp_sprintf(__('%s number validated', 'invoicing'), $vat_name); |
|
1469 | 1469 | } else { |
1470 | 1470 | $vat_info['valid'] = false; |
1471 | - getpaid_session()->set( 'user_vat_data', $vat_info ); |
|
1471 | + getpaid_session()->set('user_vat_data', $vat_info); |
|
1472 | 1472 | |
1473 | 1473 | $response['success'] = false; |
1474 | - $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 ); |
|
1475 | - wp_send_json( $response ); |
|
1474 | + $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); |
|
1475 | + wp_send_json($response); |
|
1476 | 1476 | } |
1477 | 1477 | } |
1478 | 1478 | |
1479 | - wp_send_json( $response ); |
|
1479 | + wp_send_json($response); |
|
1480 | 1480 | } |
1481 | 1481 | |
1482 | 1482 | /** |
@@ -1484,16 +1484,16 @@ discard block |
||
1484 | 1484 | * |
1485 | 1485 | * @return string |
1486 | 1486 | */ |
1487 | - public static function validate_vat_number( $vat_number, $company, $country ) { |
|
1487 | + public static function validate_vat_number($vat_number, $company, $country) { |
|
1488 | 1488 | global $wpinv_options; |
1489 | 1489 | |
1490 | 1490 | // If we are not checking the vat number via view... |
1491 | - if ( ! empty( $wpinv_options['vat_vies_check'] ) ) { |
|
1491 | + if (!empty($wpinv_options['vat_vies_check'])) { |
|
1492 | 1492 | |
1493 | 1493 | // Try validating via regex. |
1494 | - if ( empty( $wpinv_options['vat_offline_check'] ) && ! self::offline_check( $vat_number, $country ) ) { |
|
1494 | + if (empty($wpinv_options['vat_offline_check']) && !self::offline_check($vat_number, $country)) { |
|
1495 | 1495 | return wp_sprintf( |
1496 | - __( 'Your %s number is invalid', 'invoicing' ), |
|
1496 | + __('Your %s number is invalid', 'invoicing'), |
|
1497 | 1497 | getpaid_vat_name() |
1498 | 1498 | ); |
1499 | 1499 | } |
@@ -1502,23 +1502,23 @@ discard block |
||
1502 | 1502 | } |
1503 | 1503 | |
1504 | 1504 | // Validate the vat number. |
1505 | - $result = self::check_vat( $vat_number, $country ); |
|
1505 | + $result = self::check_vat($vat_number, $country); |
|
1506 | 1506 | |
1507 | - if ( empty( $result['valid'] ) ) { |
|
1507 | + if (empty($result['valid'])) { |
|
1508 | 1508 | return wp_sprintf( |
1509 | - __( 'Failed to validate the %s number via EU Commission VAT server (VIES).', 'invoicing' ), |
|
1509 | + __('Failed to validate the %s number via EU Commission VAT server (VIES).', 'invoicing'), |
|
1510 | 1510 | getpaid_vat_name() |
1511 | 1511 | ); |
1512 | 1512 | } |
1513 | 1513 | |
1514 | 1514 | // Validate the company. |
1515 | - $vies_company = ! empty( $result['company'] ) ? $result['company'] : ''; |
|
1516 | - $vies_company = apply_filters( 'wpinv_vies_company_name', $vies_company ); |
|
1517 | - $valid_company = $vies_company && $company && ( $vies_company == '---' || strcasecmp( trim( $vies_company ), trim( $company ) ) == 0 ) ? true : false; |
|
1515 | + $vies_company = !empty($result['company']) ? $result['company'] : ''; |
|
1516 | + $vies_company = apply_filters('wpinv_vies_company_name', $vies_company); |
|
1517 | + $valid_company = $vies_company && $company && ($vies_company == '---' || strcasecmp(trim($vies_company), trim($company)) == 0) ? true : false; |
|
1518 | 1518 | |
1519 | - if ( ! $valid_company && ! empty( $wpinv_options['vat_disable_company_name_check'] ) ) { |
|
1519 | + if (!$valid_company && !empty($wpinv_options['vat_disable_company_name_check'])) { |
|
1520 | 1520 | return wp_sprintf( |
1521 | - __( 'The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing' ), |
|
1521 | + __('The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing'), |
|
1522 | 1522 | getpaid_vat_name() |
1523 | 1523 | ); |
1524 | 1524 | } |
@@ -1210,16 +1210,18 @@ |
||
1210 | 1210 | |
1211 | 1211 | if ( !empty( $tax_rates ) ) { |
1212 | 1212 | foreach ( $tax_rates as $key => $tax_rate ) { |
1213 | - if ( $country != $tax_rate['country'] ) |
|
1214 | - continue; |
|
1213 | + if ( $country != $tax_rate['country'] ) { |
|
1214 | + continue; |
|
1215 | + } |
|
1215 | 1216 | |
1216 | 1217 | if ( !empty( $tax_rate['global'] ) ) { |
1217 | 1218 | if ( 0 !== $tax_rate['rate'] || !empty( $tax_rate['rate'] ) ) { |
1218 | 1219 | $rate = number_format( $tax_rate['rate'], 4 ); |
1219 | 1220 | } |
1220 | 1221 | } else { |
1221 | - if ( empty( $tax_rate['state'] ) || strtolower( $state ) != strtolower( $tax_rate['state'] ) ) |
|
1222 | - continue; |
|
1222 | + if ( empty( $tax_rate['state'] ) || strtolower( $state ) != strtolower( $tax_rate['state'] ) ) { |
|
1223 | + continue; |
|
1224 | + } |
|
1223 | 1225 | |
1224 | 1226 | $state_rate = $tax_rate['rate']; |
1225 | 1227 | if ( 0 !== $state_rate || !empty( $state_rate ) ) { |
@@ -8,192 +8,192 @@ discard block |
||
8 | 8 | * @version 1.0.19 |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | -$pages = wpinv_get_pages( true ); |
|
13 | +$pages = wpinv_get_pages(true); |
|
14 | 14 | |
15 | 15 | $currencies = wpinv_get_currencies(); |
16 | 16 | |
17 | 17 | $currency_code_options = array(); |
18 | -foreach ( $currencies as $code => $name ) { |
|
19 | - $currency_code_options[ $code ] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol( $code ) . ')'; |
|
18 | +foreach ($currencies as $code => $name) { |
|
19 | + $currency_code_options[$code] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol($code) . ')'; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | $due_payment_options = array(); |
23 | -$due_payment_options[0] = __( 'Now', 'invoicing' ); |
|
24 | -for ( $i = 1; $i <= 30; $i++ ) { |
|
23 | +$due_payment_options[0] = __('Now', 'invoicing'); |
|
24 | +for ($i = 1; $i <= 30; $i++) { |
|
25 | 25 | $due_payment_options[$i] = $i; |
26 | 26 | } |
27 | 27 | |
28 | 28 | $invoice_number_padd_options = array(); |
29 | -for ( $i = 0; $i <= 20; $i++ ) { |
|
29 | +for ($i = 0; $i <= 20; $i++) { |
|
30 | 30 | $invoice_number_padd_options[$i] = $i; |
31 | 31 | } |
32 | 32 | |
33 | 33 | $currency_symbol = wpinv_currency_symbol(); |
34 | 34 | |
35 | 35 | $last_number = $reset_number = ''; |
36 | -if ( $last_invoice_number = get_option( 'wpinv_last_invoice_number' ) ) { |
|
37 | - $last_invoice_number = preg_replace( '/[^0-9]/', '', $last_invoice_number ); |
|
36 | +if ($last_invoice_number = get_option('wpinv_last_invoice_number')) { |
|
37 | + $last_invoice_number = preg_replace('/[^0-9]/', '', $last_invoice_number); |
|
38 | 38 | |
39 | - if ( !empty( $last_invoice_number ) ) { |
|
40 | - $last_number = ' ' . wp_sprintf( __( "( Last Invoice's sequential number: <b>%s</b> )", 'invoicing' ), $last_invoice_number ); |
|
39 | + if (!empty($last_invoice_number)) { |
|
40 | + $last_number = ' ' . wp_sprintf(__("( Last Invoice's sequential number: <b>%s</b> )", 'invoicing'), $last_invoice_number); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | $nonce = wp_create_nonce('reset_invoice_count'); |
44 | - $reset_number = '<a href="'.add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)).'" class="btn button">'.__('Force Reset Sequence', 'invoicing' ). '</a>'; |
|
44 | + $reset_number = '<a href="' . add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)) . '" class="btn button">' . __('Force Reset Sequence', 'invoicing') . '</a>'; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | $alert_wrapper_start = '<p style="color: #F00">'; |
48 | 48 | $alert_wrapper_close = '</p>'; |
49 | 49 | |
50 | 50 | return array( |
51 | - 'general' => apply_filters( 'wpinv_settings_general', |
|
51 | + 'general' => apply_filters('wpinv_settings_general', |
|
52 | 52 | array( |
53 | 53 | 'main' => array( |
54 | 54 | 'location_settings' => array( |
55 | 55 | 'id' => 'location_settings', |
56 | - 'name' => '<h3>' . __( 'Default Location', 'invoicing' ) . '</h3>', |
|
56 | + 'name' => '<h3>' . __('Default Location', 'invoicing') . '</h3>', |
|
57 | 57 | 'desc' => '', |
58 | 58 | 'type' => 'header', |
59 | 59 | ), |
60 | 60 | 'default_country' => array( |
61 | 61 | 'id' => 'default_country', |
62 | - 'name' => __( 'Default Country', 'invoicing' ), |
|
63 | - 'desc' => __( 'Where does your store operate from?', 'invoicing' ), |
|
62 | + 'name' => __('Default Country', 'invoicing'), |
|
63 | + 'desc' => __('Where does your store operate from?', 'invoicing'), |
|
64 | 64 | 'type' => 'select', |
65 | 65 | 'options' => wpinv_get_country_list(), |
66 | 66 | 'std' => 'GB', |
67 | 67 | 'class' => 'wpi_select2', |
68 | - 'placeholder' => __( 'Select a country', 'invoicing' ), |
|
68 | + 'placeholder' => __('Select a country', 'invoicing'), |
|
69 | 69 | ), |
70 | 70 | 'default_state' => array( |
71 | 71 | 'id' => 'default_state', |
72 | - 'name' => __( 'Default State / Province', 'invoicing' ), |
|
73 | - 'desc' => __( 'What state / province does your store operate from?', 'invoicing' ), |
|
72 | + 'name' => __('Default State / Province', 'invoicing'), |
|
73 | + 'desc' => __('What state / province does your store operate from?', 'invoicing'), |
|
74 | 74 | 'type' => 'country_states', |
75 | 75 | 'class' => 'wpi_select2', |
76 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
76 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
77 | 77 | ), |
78 | 78 | 'store_name' => array( |
79 | 79 | 'id' => 'store_name', |
80 | - 'name' => __( 'Store Name', 'invoicing' ), |
|
81 | - 'desc' => __( 'Store name to print on invoices.', 'invoicing' ), |
|
80 | + 'name' => __('Store Name', 'invoicing'), |
|
81 | + 'desc' => __('Store name to print on invoices.', 'invoicing'), |
|
82 | 82 | 'std' => get_option('blogname'), |
83 | 83 | 'type' => 'text', |
84 | 84 | ), |
85 | 85 | 'logo' => array( |
86 | 86 | 'id' => 'logo', |
87 | - 'name' => __( 'Logo URL', 'invoicing' ), |
|
88 | - 'desc' => __( 'Store logo to print on invoices.', 'invoicing' ), |
|
87 | + 'name' => __('Logo URL', 'invoicing'), |
|
88 | + 'desc' => __('Store logo to print on invoices.', 'invoicing'), |
|
89 | 89 | 'type' => 'text', |
90 | 90 | ), |
91 | 91 | 'store_address' => array( |
92 | 92 | 'id' => 'store_address', |
93 | - 'name' => __( 'Store Address', 'invoicing' ), |
|
94 | - 'desc' => __( 'Enter the store address to display on invoice', 'invoicing' ), |
|
93 | + 'name' => __('Store Address', 'invoicing'), |
|
94 | + 'desc' => __('Enter the store address to display on invoice', 'invoicing'), |
|
95 | 95 | 'type' => 'textarea', |
96 | 96 | ), |
97 | 97 | 'page_settings' => array( |
98 | 98 | 'id' => 'page_settings', |
99 | - 'name' => '<h3>' . __( 'Page Settings', 'invoicing' ) . '</h3>', |
|
99 | + 'name' => '<h3>' . __('Page Settings', 'invoicing') . '</h3>', |
|
100 | 100 | 'desc' => '', |
101 | 101 | 'type' => 'header', |
102 | 102 | ), |
103 | 103 | 'checkout_page' => array( |
104 | 104 | 'id' => 'checkout_page', |
105 | - 'name' => __( 'Checkout Page', 'invoicing' ), |
|
106 | - 'desc' => __( 'This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing' ), |
|
105 | + 'name' => __('Checkout Page', 'invoicing'), |
|
106 | + 'desc' => __('This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing'), |
|
107 | 107 | 'type' => 'select', |
108 | 108 | 'options' => $pages, |
109 | 109 | 'class' => 'wpi_select2', |
110 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
110 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
111 | 111 | ), |
112 | 112 | 'success_page' => array( |
113 | 113 | 'id' => 'success_page', |
114 | - 'name' => __( 'Success Page', 'invoicing' ), |
|
115 | - 'desc' => __( 'This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing' ), |
|
114 | + 'name' => __('Success Page', 'invoicing'), |
|
115 | + 'desc' => __('This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing'), |
|
116 | 116 | 'type' => 'select', |
117 | 117 | 'options' => $pages, |
118 | 118 | 'class' => 'wpi_select2', |
119 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
119 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
120 | 120 | ), |
121 | 121 | 'failure_page' => array( |
122 | 122 | 'id' => 'failure_page', |
123 | - 'name' => __( 'Failed Transaction Page', 'invoicing' ), |
|
124 | - 'desc' => __( 'This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing' ), |
|
123 | + 'name' => __('Failed Transaction Page', 'invoicing'), |
|
124 | + 'desc' => __('This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing'), |
|
125 | 125 | 'type' => 'select', |
126 | 126 | 'options' => $pages, |
127 | 127 | 'class' => 'wpi_select2', |
128 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
128 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
129 | 129 | ), |
130 | 130 | 'invoice_history_page' => array( |
131 | 131 | 'id' => 'invoice_history_page', |
132 | - 'name' => __( 'Invoice History Page', 'invoicing' ), |
|
133 | - 'desc' => __( 'This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing' ), |
|
132 | + 'name' => __('Invoice History Page', 'invoicing'), |
|
133 | + 'desc' => __('This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing'), |
|
134 | 134 | 'type' => 'select', |
135 | 135 | 'options' => $pages, |
136 | 136 | 'class' => 'wpi_select2', |
137 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
137 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
138 | 138 | ), |
139 | 139 | 'invoice_subscription_page' => array( |
140 | 140 | 'id' => 'invoice_subscription_page', |
141 | - 'name' => __( 'Invoice Subscriptions Page', 'invoicing' ), |
|
142 | - 'desc' => __( 'This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing' ), |
|
141 | + 'name' => __('Invoice Subscriptions Page', 'invoicing'), |
|
142 | + 'desc' => __('This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing'), |
|
143 | 143 | 'type' => 'select', |
144 | 144 | 'options' => $pages, |
145 | 145 | 'class' => 'wpi_select2', |
146 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
146 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
147 | 147 | ), |
148 | 148 | ), |
149 | 149 | 'currency_section' => array( |
150 | 150 | 'currency_settings' => array( |
151 | 151 | 'id' => 'currency_settings', |
152 | - 'name' => '<h3>' . __( 'Currency Settings', 'invoicing' ) . '</h3>', |
|
152 | + 'name' => '<h3>' . __('Currency Settings', 'invoicing') . '</h3>', |
|
153 | 153 | 'desc' => '', |
154 | 154 | 'type' => 'header', |
155 | 155 | ), |
156 | 156 | 'currency' => array( |
157 | 157 | 'id' => 'currency', |
158 | - 'name' => __( 'Currency', 'invoicing' ), |
|
159 | - 'desc' => __( 'Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing' ), |
|
158 | + 'name' => __('Currency', 'invoicing'), |
|
159 | + 'desc' => __('Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing'), |
|
160 | 160 | 'type' => 'select', |
161 | 161 | 'class' => 'wpi_select2', |
162 | 162 | 'options' => $currency_code_options, |
163 | 163 | ), |
164 | 164 | 'currency_position' => array( |
165 | 165 | 'id' => 'currency_position', |
166 | - 'name' => __( 'Currency Position', 'invoicing' ), |
|
167 | - 'desc' => __( 'Choose the location of the currency sign.', 'invoicing' ), |
|
166 | + 'name' => __('Currency Position', 'invoicing'), |
|
167 | + 'desc' => __('Choose the location of the currency sign.', 'invoicing'), |
|
168 | 168 | 'type' => 'select', |
169 | 169 | 'class' => 'wpi_select2', |
170 | 170 | 'options' => array( |
171 | - 'left' => __( 'Left', 'invoicing' ) . ' (' . $currency_symbol . wpinv_format_amount( '99.99' ) . ')', |
|
172 | - 'right' => __( 'Right', 'invoicing' ) . ' ('. wpinv_format_amount( '99.99' ) . $currency_symbol . ')', |
|
173 | - 'left_space' => __( 'Left with space', 'invoicing' ) . ' (' . $currency_symbol . ' ' . wpinv_format_amount( '99.99' ) . ')', |
|
174 | - 'right_space' => __( 'Right with space', 'invoicing' ) . ' (' . wpinv_format_amount( '99.99' ) . ' ' . $currency_symbol . ')' |
|
171 | + 'left' => __('Left', 'invoicing') . ' (' . $currency_symbol . wpinv_format_amount('99.99') . ')', |
|
172 | + 'right' => __('Right', 'invoicing') . ' (' . wpinv_format_amount('99.99') . $currency_symbol . ')', |
|
173 | + 'left_space' => __('Left with space', 'invoicing') . ' (' . $currency_symbol . ' ' . wpinv_format_amount('99.99') . ')', |
|
174 | + 'right_space' => __('Right with space', 'invoicing') . ' (' . wpinv_format_amount('99.99') . ' ' . $currency_symbol . ')' |
|
175 | 175 | ) |
176 | 176 | ), |
177 | 177 | 'thousands_separator' => array( |
178 | 178 | 'id' => 'thousands_separator', |
179 | - 'name' => __( 'Thousands Separator', 'invoicing' ), |
|
180 | - 'desc' => __( 'The symbol (usually , or .) to separate thousands', 'invoicing' ), |
|
179 | + 'name' => __('Thousands Separator', 'invoicing'), |
|
180 | + 'desc' => __('The symbol (usually , or .) to separate thousands', 'invoicing'), |
|
181 | 181 | 'type' => 'text', |
182 | 182 | 'size' => 'small', |
183 | 183 | 'std' => ',', |
184 | 184 | ), |
185 | 185 | 'decimal_separator' => array( |
186 | 186 | 'id' => 'decimal_separator', |
187 | - 'name' => __( 'Decimal Separator', 'invoicing' ), |
|
188 | - 'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'invoicing' ), |
|
187 | + 'name' => __('Decimal Separator', 'invoicing'), |
|
188 | + 'desc' => __('The symbol (usually , or .) to separate decimal points', 'invoicing'), |
|
189 | 189 | 'type' => 'text', |
190 | 190 | 'size' => 'small', |
191 | 191 | 'std' => '.', |
192 | 192 | ), |
193 | 193 | 'decimals' => array( |
194 | 194 | 'id' => 'decimals', |
195 | - 'name' => __( 'Number of Decimals', 'invoicing' ), |
|
196 | - 'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'invoicing' ), |
|
195 | + 'name' => __('Number of Decimals', 'invoicing'), |
|
196 | + 'desc' => __('This sets the number of decimal points shown in displayed prices.', 'invoicing'), |
|
197 | 197 | 'type' => 'number', |
198 | 198 | 'size' => 'small', |
199 | 199 | 'std' => '2', |
@@ -205,29 +205,29 @@ discard block |
||
205 | 205 | 'labels' => array( |
206 | 206 | 'labels' => array( |
207 | 207 | 'id' => 'labels_settings', |
208 | - 'name' => '<h3>' . __( 'Invoice Labels', 'invoicing' ) . '</h3>', |
|
208 | + 'name' => '<h3>' . __('Invoice Labels', 'invoicing') . '</h3>', |
|
209 | 209 | 'desc' => '', |
210 | 210 | 'type' => 'header', |
211 | 211 | ), |
212 | 212 | 'vat_name' => array( |
213 | 213 | 'id' => 'vat_name', |
214 | - 'name' => __( 'VAT Name', 'invoicing' ), |
|
215 | - 'desc' => __( 'Enter the VAT name', 'invoicing' ), |
|
214 | + 'name' => __('VAT Name', 'invoicing'), |
|
215 | + 'desc' => __('Enter the VAT name', 'invoicing'), |
|
216 | 216 | 'type' => 'text', |
217 | 217 | 'size' => 'regular', |
218 | - 'std' => __( 'VAT', 'invoicing' ), |
|
218 | + 'std' => __('VAT', 'invoicing'), |
|
219 | 219 | ), |
220 | 220 | 'vat_invoice_notice_label' => array( |
221 | 221 | 'id' => 'vat_invoice_notice_label', |
222 | - 'name' => __( 'Invoice Notice Label', 'invoicing' ), |
|
223 | - 'desc' => __( 'Use this to add an invoice notice section (label) to your invoices', 'invoicing' ), |
|
222 | + 'name' => __('Invoice Notice Label', 'invoicing'), |
|
223 | + 'desc' => __('Use this to add an invoice notice section (label) to your invoices', 'invoicing'), |
|
224 | 224 | 'type' => 'text', |
225 | 225 | 'size' => 'regular', |
226 | 226 | ), |
227 | 227 | 'vat_invoice_notice' => array( |
228 | 228 | 'id' => 'vat_invoice_notice', |
229 | - 'name' => __( 'Invoice notice', 'invoicing' ), |
|
230 | - 'desc' => __( 'Use this to add an invoice notice section (description) to your invoices', 'invoicing' ), |
|
229 | + 'name' => __('Invoice notice', 'invoicing'), |
|
230 | + 'desc' => __('Use this to add an invoice notice section (description) to your invoices', 'invoicing'), |
|
231 | 231 | 'type' => 'text', |
232 | 232 | 'size' => 'regular', |
233 | 233 | ), |
@@ -239,22 +239,22 @@ discard block |
||
239 | 239 | 'main' => array( |
240 | 240 | 'gateway_settings' => array( |
241 | 241 | 'id' => 'api_header', |
242 | - 'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>', |
|
242 | + 'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>', |
|
243 | 243 | 'desc' => '', |
244 | 244 | 'type' => 'header', |
245 | 245 | ), |
246 | 246 | 'gateways' => array( |
247 | 247 | 'id' => 'gateways', |
248 | - 'name' => __( 'Payment Gateways', 'invoicing' ), |
|
249 | - 'desc' => __( 'Choose the payment gateways you want to enable.', 'invoicing' ), |
|
248 | + 'name' => __('Payment Gateways', 'invoicing'), |
|
249 | + 'desc' => __('Choose the payment gateways you want to enable.', 'invoicing'), |
|
250 | 250 | 'type' => 'gateways', |
251 | 251 | 'std' => array('manual'=>1), |
252 | 252 | 'options' => wpinv_get_payment_gateways(), |
253 | 253 | ), |
254 | 254 | 'default_gateway' => array( |
255 | 255 | 'id' => 'default_gateway', |
256 | - 'name' => __( 'Default Gateway', 'invoicing' ), |
|
257 | - 'desc' => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ), |
|
256 | + 'name' => __('Default Gateway', 'invoicing'), |
|
257 | + 'desc' => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'), |
|
258 | 258 | 'type' => 'gateway_select', |
259 | 259 | 'std' => 'manual', |
260 | 260 | 'class' => 'wpi_select2', |
@@ -269,19 +269,19 @@ discard block |
||
269 | 269 | 'main' => array( |
270 | 270 | 'tax_settings' => array( |
271 | 271 | 'id' => 'tax_settings', |
272 | - 'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>', |
|
272 | + 'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>', |
|
273 | 273 | 'type' => 'header', |
274 | 274 | ), |
275 | 275 | 'enable_taxes' => array( |
276 | 276 | 'id' => 'enable_taxes', |
277 | - 'name' => __( 'Enable Taxes', 'invoicing' ), |
|
278 | - 'desc' => __( 'Check this to enable taxes on invoices.', 'invoicing' ), |
|
277 | + 'name' => __('Enable Taxes', 'invoicing'), |
|
278 | + 'desc' => __('Check this to enable taxes on invoices.', 'invoicing'), |
|
279 | 279 | 'type' => 'checkbox', |
280 | 280 | ), |
281 | 281 | 'tax_rate' => array( |
282 | 282 | 'id' => 'tax_rate', |
283 | - 'name' => __( 'Fallback Tax Rate', 'invoicing' ), |
|
284 | - 'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ), |
|
283 | + 'name' => __('Fallback Tax Rate', 'invoicing'), |
|
284 | + 'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'), |
|
285 | 285 | 'type' => 'number', |
286 | 286 | 'size' => 'small', |
287 | 287 | 'min' => '0', |
@@ -293,8 +293,8 @@ discard block |
||
293 | 293 | 'rates' => array( |
294 | 294 | 'tax_rates' => array( |
295 | 295 | 'id' => 'tax_rates', |
296 | - 'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>', |
|
297 | - 'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ), |
|
296 | + 'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>', |
|
297 | + 'desc' => __('Enter tax rates for specific regions.', 'invoicing'), |
|
298 | 298 | 'type' => 'tax_rates', |
299 | 299 | ), |
300 | 300 | ) |
@@ -306,68 +306,68 @@ discard block |
||
306 | 306 | 'main' => array( |
307 | 307 | 'email_settings_header' => array( |
308 | 308 | 'id' => 'email_settings_header', |
309 | - 'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>', |
|
309 | + 'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>', |
|
310 | 310 | 'type' => 'header', |
311 | 311 | ), |
312 | 312 | 'email_from_name' => array( |
313 | 313 | 'id' => 'email_from_name', |
314 | - 'name' => __( 'From Name', 'invoicing' ), |
|
315 | - 'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ), |
|
316 | - 'std' => esc_attr( get_bloginfo( 'name', 'display' ) ), |
|
314 | + 'name' => __('From Name', 'invoicing'), |
|
315 | + 'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'), |
|
316 | + 'std' => esc_attr(get_bloginfo('name', 'display')), |
|
317 | 317 | 'type' => 'text', |
318 | 318 | ), |
319 | 319 | 'email_from' => array( |
320 | 320 | 'id' => 'email_from', |
321 | - 'name' => __( 'From Email', 'invoicing' ), |
|
322 | - 'desc' => sprintf (__( 'Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing' ), $alert_wrapper_start, $alert_wrapper_close), |
|
323 | - 'std' => get_option( 'admin_email' ), |
|
321 | + 'name' => __('From Email', 'invoicing'), |
|
322 | + 'desc' => sprintf(__('Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing'), $alert_wrapper_start, $alert_wrapper_close), |
|
323 | + 'std' => get_option('admin_email'), |
|
324 | 324 | 'type' => 'text', |
325 | 325 | ), |
326 | 326 | 'admin_email' => array( |
327 | 327 | 'id' => 'admin_email', |
328 | - 'name' => __( 'Admin Email', 'invoicing' ), |
|
329 | - 'desc' => __( 'Where should we send admin notifications?', 'invoicing' ), |
|
330 | - 'std' => get_option( 'admin_email' ), |
|
328 | + 'name' => __('Admin Email', 'invoicing'), |
|
329 | + 'desc' => __('Where should we send admin notifications?', 'invoicing'), |
|
330 | + 'std' => get_option('admin_email'), |
|
331 | 331 | 'type' => 'text', |
332 | 332 | ), |
333 | 333 | 'overdue_settings_header' => array( |
334 | 334 | 'id' => 'overdue_settings_header', |
335 | - 'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>', |
|
335 | + 'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>', |
|
336 | 336 | 'type' => 'header', |
337 | 337 | ), |
338 | 338 | 'overdue_active' => array( |
339 | 339 | 'id' => 'overdue_active', |
340 | - 'name' => __( 'Enable Due Date', 'invoicing' ), |
|
341 | - 'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ), |
|
340 | + 'name' => __('Enable Due Date', 'invoicing'), |
|
341 | + 'desc' => __('Check this to enable due date option for invoices.', 'invoicing'), |
|
342 | 342 | 'type' => 'checkbox', |
343 | 343 | 'std' => false, |
344 | 344 | ), |
345 | 345 | 'overdue_days' => array( |
346 | 346 | 'id' => 'overdue_days', |
347 | - 'name' => __( 'Default Due Date', 'invoicing' ), |
|
348 | - 'desc' => __( 'Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing' ), |
|
347 | + 'name' => __('Default Due Date', 'invoicing'), |
|
348 | + 'desc' => __('Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing'), |
|
349 | 349 | 'type' => 'select', |
350 | 350 | 'options' => $due_payment_options, |
351 | 351 | 'std' => 0, |
352 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
352 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
353 | 353 | ), |
354 | 354 | 'email_template_header' => array( |
355 | 355 | 'id' => 'email_template_header', |
356 | - 'name' => '<h3>' . __( 'Email Template', 'invoicing' ) . '</h3>', |
|
356 | + 'name' => '<h3>' . __('Email Template', 'invoicing') . '</h3>', |
|
357 | 357 | 'type' => 'header', |
358 | 358 | ), |
359 | 359 | 'email_header_image' => array( |
360 | 360 | 'id' => 'email_header_image', |
361 | - 'name' => __( 'Header Image', 'invoicing' ), |
|
362 | - 'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing' ), |
|
361 | + 'name' => __('Header Image', 'invoicing'), |
|
362 | + 'desc' => __('URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing'), |
|
363 | 363 | 'std' => '', |
364 | 364 | 'type' => 'text', |
365 | 365 | ), |
366 | 366 | 'email_footer_text' => array( |
367 | 367 | 'id' => 'email_footer_text', |
368 | - 'name' => __( 'Footer Text', 'invoicing' ), |
|
369 | - 'desc' => __( 'The text to appear in the footer of all invoice emails.', 'invoicing' ), |
|
370 | - 'std' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GeoDirectory', 'invoicing' ), |
|
368 | + 'name' => __('Footer Text', 'invoicing'), |
|
369 | + 'desc' => __('The text to appear in the footer of all invoice emails.', 'invoicing'), |
|
370 | + 'std' => get_bloginfo('name', 'display') . ' - ' . __('Powered by GeoDirectory', 'invoicing'), |
|
371 | 371 | 'type' => 'textarea', |
372 | 372 | 'class' => 'regular-text', |
373 | 373 | 'rows' => 2, |
@@ -375,29 +375,29 @@ discard block |
||
375 | 375 | ), |
376 | 376 | 'email_base_color' => array( |
377 | 377 | 'id' => 'email_base_color', |
378 | - 'name' => __( 'Base Color', 'invoicing' ), |
|
379 | - 'desc' => __( 'The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing' ), |
|
378 | + 'name' => __('Base Color', 'invoicing'), |
|
379 | + 'desc' => __('The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing'), |
|
380 | 380 | 'std' => '#557da2', |
381 | 381 | 'type' => 'color', |
382 | 382 | ), |
383 | 383 | 'email_background_color' => array( |
384 | 384 | 'id' => 'email_background_color', |
385 | - 'name' => __( 'Background Color', 'invoicing' ), |
|
386 | - 'desc' => __( 'The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing' ), |
|
385 | + 'name' => __('Background Color', 'invoicing'), |
|
386 | + 'desc' => __('The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing'), |
|
387 | 387 | 'std' => '#f5f5f5', |
388 | 388 | 'type' => 'color', |
389 | 389 | ), |
390 | 390 | 'email_body_background_color' => array( |
391 | 391 | 'id' => 'email_body_background_color', |
392 | - 'name' => __( 'Body Background Color', 'invoicing' ), |
|
393 | - 'desc' => __( 'The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing' ), |
|
392 | + 'name' => __('Body Background Color', 'invoicing'), |
|
393 | + 'desc' => __('The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing'), |
|
394 | 394 | 'std' => '#fdfdfd', |
395 | 395 | 'type' => 'color', |
396 | 396 | ), |
397 | 397 | 'email_text_color' => array( |
398 | 398 | 'id' => 'email_text_color', |
399 | - 'name' => __( 'Body Text Color', 'invoicing' ), |
|
400 | - 'desc' => __( 'The main body text color. Default <code>#505050</code>.', 'invoicing' ), |
|
399 | + 'name' => __('Body Text Color', 'invoicing'), |
|
400 | + 'desc' => __('The main body text color. Default <code>#505050</code>.', 'invoicing'), |
|
401 | 401 | 'std' => '#505050', |
402 | 402 | 'type' => 'color', |
403 | 403 | ), |
@@ -416,17 +416,17 @@ discard block |
||
416 | 416 | 'main' => array( |
417 | 417 | 'invoicing_privacy_policy_settings' => array( |
418 | 418 | 'id' => 'invoicing_privacy_policy_settings', |
419 | - 'name' => '<h3>' . __( 'Privacy Policy', 'invoicing' ) . '</h3>', |
|
419 | + 'name' => '<h3>' . __('Privacy Policy', 'invoicing') . '</h3>', |
|
420 | 420 | 'type' => 'header', |
421 | 421 | ), |
422 | 422 | 'privacy_page' => array( |
423 | 423 | 'id' => 'privacy_page', |
424 | - 'name' => __( 'Privacy Page', 'invoicing' ), |
|
425 | - 'desc' => __( 'If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing' ), |
|
424 | + 'name' => __('Privacy Page', 'invoicing'), |
|
425 | + 'desc' => __('If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing'), |
|
426 | 426 | 'type' => 'select', |
427 | - 'options' => wpinv_get_pages( true, __( 'Select a page', 'invoicing' )), |
|
427 | + 'options' => wpinv_get_pages(true, __('Select a page', 'invoicing')), |
|
428 | 428 | 'class' => 'wpi_select2', |
429 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
429 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
430 | 430 | ), |
431 | 431 | ), |
432 | 432 | ) |
@@ -437,19 +437,19 @@ discard block |
||
437 | 437 | 'main' => array( |
438 | 438 | 'invoice_number_format_settings' => array( |
439 | 439 | 'id' => 'invoice_number_format_settings', |
440 | - 'name' => '<h3>' . __( 'Invoice Number', 'invoicing' ) . '</h3>', |
|
440 | + 'name' => '<h3>' . __('Invoice Number', 'invoicing') . '</h3>', |
|
441 | 441 | 'type' => 'header', |
442 | 442 | ), |
443 | 443 | 'sequential_invoice_number' => array( |
444 | 444 | 'id' => 'sequential_invoice_number', |
445 | - 'name' => __( 'Sequential Invoice Numbers', 'invoicing' ), |
|
446 | - 'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing' ) . $reset_number, |
|
445 | + 'name' => __('Sequential Invoice Numbers', 'invoicing'), |
|
446 | + 'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing') . $reset_number, |
|
447 | 447 | 'type' => 'checkbox', |
448 | 448 | ), |
449 | 449 | 'invoice_sequence_start' => array( |
450 | 450 | 'id' => 'invoice_sequence_start', |
451 | - 'name' => __( 'Sequential Starting Number', 'invoicing' ), |
|
452 | - 'desc' => __( 'The number at which the invoice number sequence should begin.', 'invoicing' ) . $last_number, |
|
451 | + 'name' => __('Sequential Starting Number', 'invoicing'), |
|
452 | + 'desc' => __('The number at which the invoice number sequence should begin.', 'invoicing') . $last_number, |
|
453 | 453 | 'type' => 'number', |
454 | 454 | 'size' => 'small', |
455 | 455 | 'std' => '1', |
@@ -457,8 +457,8 @@ discard block |
||
457 | 457 | ), |
458 | 458 | 'invoice_number_padd' => array( |
459 | 459 | 'id' => 'invoice_number_padd', |
460 | - 'name' => __( 'Minimum Digits', 'invoicing' ), |
|
461 | - 'desc' => __( 'If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing' ), |
|
460 | + 'name' => __('Minimum Digits', 'invoicing'), |
|
461 | + 'desc' => __('If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing'), |
|
462 | 462 | 'type' => 'select', |
463 | 463 | 'options' => $invoice_number_padd_options, |
464 | 464 | 'std' => 5, |
@@ -466,8 +466,8 @@ discard block |
||
466 | 466 | ), |
467 | 467 | 'invoice_number_prefix' => array( |
468 | 468 | 'id' => 'invoice_number_prefix', |
469 | - 'name' => __( 'Invoice Number Prefix', 'invoicing' ), |
|
470 | - 'desc' => __( 'Prefix for all invoice numbers. Ex: INV-', 'invoicing' ), |
|
469 | + 'name' => __('Invoice Number Prefix', 'invoicing'), |
|
470 | + 'desc' => __('Prefix for all invoice numbers. Ex: INV-', 'invoicing'), |
|
471 | 471 | 'type' => 'text', |
472 | 472 | 'size' => 'regular', |
473 | 473 | 'std' => 'INV-', |
@@ -475,41 +475,41 @@ discard block |
||
475 | 475 | ), |
476 | 476 | 'invoice_number_postfix' => array( |
477 | 477 | 'id' => 'invoice_number_postfix', |
478 | - 'name' => __( 'Invoice Number Postfix', 'invoicing' ), |
|
479 | - 'desc' => __( 'Postfix for all invoice numbers.', 'invoicing' ), |
|
478 | + 'name' => __('Invoice Number Postfix', 'invoicing'), |
|
479 | + 'desc' => __('Postfix for all invoice numbers.', 'invoicing'), |
|
480 | 480 | 'type' => 'text', |
481 | 481 | 'size' => 'regular', |
482 | 482 | 'std' => '' |
483 | 483 | ), |
484 | 484 | 'checkout_settings' => array( |
485 | 485 | 'id' => 'checkout_settings', |
486 | - 'name' => '<h3>' . __( 'Checkout Settings', 'invoicing' ) . '</h3>', |
|
486 | + 'name' => '<h3>' . __('Checkout Settings', 'invoicing') . '</h3>', |
|
487 | 487 | 'type' => 'header', |
488 | 488 | ), |
489 | 489 | 'login_to_checkout' => array( |
490 | 490 | 'id' => 'login_to_checkout', |
491 | - 'name' => __( 'Require Login To Checkout', 'invoicing' ), |
|
492 | - 'desc' => __( 'If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing' ), |
|
491 | + 'name' => __('Require Login To Checkout', 'invoicing'), |
|
492 | + 'desc' => __('If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing'), |
|
493 | 493 | 'type' => 'checkbox', |
494 | 494 | ), |
495 | 495 | |
496 | 496 | 'maxmind_license_key' => array( |
497 | 497 | 'id' => 'maxmind_license_key', |
498 | - 'name' => __( 'MaxMind License Key', 'invoicing' ), |
|
498 | + 'name' => __('MaxMind License Key', 'invoicing'), |
|
499 | 499 | 'type' => 'text', |
500 | 500 | 'size' => 'regular', |
501 | - 'desc' => __( "Enter you license key if you would like to use MaxMind to automatically detect a customer's country.", 'invoicing' ) . ' <a href="https://support.maxmind.com/account-faq/license-keys/how-do-i-generate-a-license-key/">' . __( 'How to generate a free license key.', 'invoicing' ) . '</a>', |
|
501 | + 'desc' => __("Enter you license key if you would like to use MaxMind to automatically detect a customer's country.", 'invoicing') . ' <a href="https://support.maxmind.com/account-faq/license-keys/how-do-i-generate-a-license-key/">' . __('How to generate a free license key.', 'invoicing') . '</a>', |
|
502 | 502 | ), |
503 | 503 | |
504 | 504 | 'uninstall_settings' => array( |
505 | 505 | 'id' => 'uninstall_settings', |
506 | - 'name' => '<h3>' . __( 'Uninstall Settings', 'invoicing' ) . '</h3>', |
|
506 | + 'name' => '<h3>' . __('Uninstall Settings', 'invoicing') . '</h3>', |
|
507 | 507 | 'type' => 'header', |
508 | 508 | ), |
509 | 509 | 'remove_data_on_unistall' => array( |
510 | 510 | 'id' => 'remove_data_on_unistall', |
511 | - 'name' => __( 'Remove Data on Uninstall?', 'invoicing' ), |
|
512 | - 'desc' => __( 'Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing' ), |
|
511 | + 'name' => __('Remove Data on Uninstall?', 'invoicing'), |
|
512 | + 'desc' => __('Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing'), |
|
513 | 513 | 'type' => 'checkbox', |
514 | 514 | 'std' => '' |
515 | 515 | ), |
@@ -518,13 +518,13 @@ discard block |
||
518 | 518 | 'custom-css' => array( |
519 | 519 | 'css_settings' => array( |
520 | 520 | 'id' => 'css_settings', |
521 | - 'name' => '<h3>' . __( 'Custom CSS', 'invoicing' ) . '</h3>', |
|
521 | + 'name' => '<h3>' . __('Custom CSS', 'invoicing') . '</h3>', |
|
522 | 522 | 'type' => 'header', |
523 | 523 | ), |
524 | 524 | 'template_custom_css' => array( |
525 | 525 | 'id' => 'template_custom_css', |
526 | - 'name' => __( 'Invoice Template CSS', 'invoicing' ), |
|
527 | - 'desc' => __( 'Add CSS to modify appearance of the print invoice page.', 'invoicing' ), |
|
526 | + 'name' => __('Invoice Template CSS', 'invoicing'), |
|
527 | + 'desc' => __('Add CSS to modify appearance of the print invoice page.', 'invoicing'), |
|
528 | 528 | 'type' => 'textarea', |
529 | 529 | 'class'=> 'regular-text', |
530 | 530 | 'rows' => 10, |
@@ -538,8 +538,8 @@ discard block |
||
538 | 538 | 'main' => array( |
539 | 539 | 'tool_settings' => array( |
540 | 540 | 'id' => 'tool_settings', |
541 | - 'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>', |
|
542 | - 'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ), |
|
541 | + 'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>', |
|
542 | + 'desc' => __('Invoicing diagnostic tools', 'invoicing'), |
|
543 | 543 | 'type' => 'tools', |
544 | 544 | ), |
545 | 545 | ), |
@@ -14,502 +14,502 @@ discard block |
||
14 | 14 | */ |
15 | 15 | class WPInv_Plugin { |
16 | 16 | |
17 | - /** |
|
18 | - * GetPaid version. |
|
19 | - * |
|
20 | - * @var string |
|
21 | - */ |
|
22 | - public $version; |
|
23 | - |
|
24 | - /** |
|
25 | - * Data container. |
|
26 | - * |
|
27 | - * @var array |
|
28 | - */ |
|
29 | - protected $data = array(); |
|
30 | - |
|
31 | - /** |
|
32 | - * Form elements instance. |
|
33 | - * |
|
34 | - * @var WPInv_Payment_Form_Elements |
|
35 | - */ |
|
36 | - public $form_elements; |
|
37 | - |
|
38 | - /** |
|
39 | - * Tax instance. |
|
40 | - * |
|
41 | - * @var WPInv_EUVat |
|
42 | - */ |
|
43 | - public $tax; |
|
44 | - |
|
45 | - /** |
|
46 | - * @param array An array of payment gateways. |
|
47 | - */ |
|
48 | - public $gateways; |
|
49 | - |
|
50 | - /** |
|
51 | - * Class constructor. |
|
52 | - */ |
|
53 | - public function __construct() { |
|
54 | - $this->define_constants(); |
|
55 | - $this->includes(); |
|
56 | - $this->init_hooks(); |
|
57 | - $this->set_properties(); |
|
58 | - } |
|
59 | - |
|
60 | - /** |
|
61 | - * Sets a custom data property. |
|
62 | - * |
|
63 | - * @param string $prop The prop to set. |
|
64 | - * @param mixed $value The value to retrieve. |
|
65 | - */ |
|
66 | - public function set( $prop, $value ) { |
|
67 | - $this->data[ $prop ] = $value; |
|
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * Gets a custom data property. |
|
72 | - * |
|
73 | - * @param string $prop The prop to set. |
|
74 | - * @return mixed The value. |
|
75 | - */ |
|
76 | - public function get( $prop ) { |
|
77 | - |
|
78 | - if ( isset( $this->data[ $prop ] ) ) { |
|
79 | - return $this->data[ $prop ]; |
|
80 | - } |
|
81 | - |
|
82 | - return null; |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * Define class properties. |
|
87 | - */ |
|
88 | - public function set_properties() { |
|
89 | - |
|
90 | - // Sessions. |
|
91 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
92 | - $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility. |
|
93 | - $this->tax = new WPInv_EUVat(); |
|
94 | - $this->tax->init(); |
|
95 | - $GLOBALS['wpinv_euvat'] = $this->tax; // Backwards compatibility. |
|
96 | - |
|
97 | - // Init other objects. |
|
98 | - $this->set( 'reports', new WPInv_Reports() ); // TODO: Refactor. |
|
99 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
100 | - $this->set( 'notes', new WPInv_Notes() ); |
|
101 | - $this->set( 'api', new WPInv_API() ); |
|
102 | - $this->set( 'post_types', new GetPaid_Post_Types() ); |
|
103 | - $this->set( 'template', new GetPaid_Template() ); |
|
104 | - $this->set( 'admin', new GetPaid_Admin() ); |
|
105 | - $this->set( 'subscriptions', new WPInv_Subscriptions() ); |
|
106 | - $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() ); |
|
107 | - $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() ); |
|
108 | - $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() ); |
|
109 | - $this->set( 'payment_forms', new GetPaid_Payment_Forms() ); |
|
110 | - $this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() ); |
|
111 | - |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * Define plugin constants. |
|
116 | - */ |
|
117 | - public function define_constants() { |
|
118 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
119 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
120 | - $this->version = WPINV_VERSION; |
|
121 | - } |
|
122 | - |
|
123 | - /** |
|
124 | - * Hook into actions and filters. |
|
125 | - * |
|
126 | - * @since 1.0.19 |
|
127 | - */ |
|
128 | - protected function init_hooks() { |
|
129 | - /* Internationalize the text strings used. */ |
|
130 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
131 | - |
|
132 | - // Init the plugin after WordPress inits. |
|
133 | - add_action( 'init', array( $this, 'init' ), 1 ); |
|
134 | - add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 ); |
|
135 | - add_action( 'init', array( $this, 'wpinv_actions' ) ); |
|
136 | - add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 ); |
|
137 | - |
|
138 | - if ( class_exists( 'BuddyPress' ) ) { |
|
139 | - add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) ); |
|
140 | - } |
|
141 | - |
|
142 | - add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); |
|
143 | - add_action( 'wp_footer', array( &$this, 'wp_footer' ) ); |
|
144 | - add_action( 'widgets_init', array( &$this, 'register_widgets' ) ); |
|
145 | - add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) ); |
|
146 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
147 | - |
|
148 | - // Fires after registering actions. |
|
149 | - do_action( 'wpinv_actions', $this ); |
|
150 | - do_action( 'getpaid_actions', $this ); |
|
151 | - |
|
152 | - } |
|
153 | - |
|
154 | - public function plugins_loaded() { |
|
155 | - /* Internationalize the text strings used. */ |
|
156 | - $this->load_textdomain(); |
|
157 | - |
|
158 | - do_action( 'wpinv_loaded' ); |
|
159 | - |
|
160 | - // Fix oxygen page builder conflict |
|
161 | - if ( function_exists( 'ct_css_output' ) ) { |
|
162 | - wpinv_oxygen_fix_conflict(); |
|
163 | - } |
|
164 | - } |
|
165 | - |
|
166 | - /** |
|
167 | - * Load the translation of the plugin. |
|
168 | - * |
|
169 | - * @since 1.0 |
|
170 | - */ |
|
171 | - public function load_textdomain( $locale = NULL ) { |
|
172 | - if ( empty( $locale ) ) { |
|
173 | - $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
174 | - } |
|
175 | - |
|
176 | - $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' ); |
|
177 | - |
|
178 | - unload_textdomain( 'invoicing' ); |
|
179 | - load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
|
180 | - load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
181 | - |
|
182 | - /** |
|
183 | - * Define language constants. |
|
184 | - */ |
|
185 | - require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
186 | - } |
|
187 | - |
|
188 | - /** |
|
189 | - * Include required core files used in admin and on the frontend. |
|
190 | - */ |
|
191 | - public function includes() { |
|
192 | - |
|
193 | - // Start with the settings. |
|
194 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
195 | - |
|
196 | - // Packages/libraries. |
|
197 | - require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
198 | - require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' ); |
|
199 | - |
|
200 | - // Load functions. |
|
201 | - require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' ); |
|
202 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
203 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
204 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
205 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
206 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
207 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
208 | - require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' ); |
|
209 | - require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' ); |
|
210 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
211 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
212 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
213 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
214 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' ); |
|
215 | - require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' ); |
|
216 | - |
|
217 | - // Register autoloader. |
|
218 | - try { |
|
219 | - spl_autoload_register( array( $this, 'autoload' ), true ); |
|
220 | - } catch ( Exception $e ) { |
|
221 | - wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
|
222 | - } |
|
223 | - |
|
224 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
225 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
226 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
227 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
228 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' ); |
|
229 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
230 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
231 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
232 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
233 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
234 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
235 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
236 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
237 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
238 | - require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
239 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
240 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
241 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
242 | - require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
243 | - require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
244 | - require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' ); |
|
245 | - |
|
246 | - /** |
|
247 | - * Load the tax class. |
|
248 | - */ |
|
249 | - if ( ! class_exists( 'WPInv_EUVat' ) ) { |
|
250 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' ); |
|
251 | - } |
|
252 | - |
|
253 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
254 | - GetPaid_Post_Types_Admin::init(); |
|
255 | - |
|
256 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' ); |
|
257 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
258 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' ); |
|
259 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
260 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
261 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
262 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
263 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' ); |
|
264 | - // load the user class only on the users.php page |
|
265 | - global $pagenow; |
|
266 | - if($pagenow=='users.php'){ |
|
267 | - new WPInv_Admin_Users(); |
|
268 | - } |
|
269 | - } |
|
270 | - |
|
271 | - // Register cli commands |
|
272 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
273 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
274 | - WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
275 | - } |
|
276 | - |
|
277 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' ); |
|
278 | - } |
|
279 | - |
|
280 | - /** |
|
281 | - * Class autoloader |
|
282 | - * |
|
283 | - * @param string $class_name The name of the class to load. |
|
284 | - * @access public |
|
285 | - * @since 1.0.19 |
|
286 | - * @return void |
|
287 | - */ |
|
288 | - public function autoload( $class_name ) { |
|
289 | - |
|
290 | - // Normalize the class name... |
|
291 | - $class_name = strtolower( $class_name ); |
|
292 | - |
|
293 | - // ... and make sure it is our class. |
|
294 | - if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
295 | - return; |
|
296 | - } |
|
297 | - |
|
298 | - // Next, prepare the file name from the class. |
|
299 | - $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
300 | - |
|
301 | - // Base path of the classes. |
|
302 | - $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
303 | - |
|
304 | - // And an array of possible locations in order of importance. |
|
305 | - $locations = array( |
|
306 | - "$plugin_path/includes", |
|
307 | - "$plugin_path/includes/data-stores", |
|
308 | - "$plugin_path/includes/gateways", |
|
309 | - "$plugin_path/includes/payments", |
|
310 | - "$plugin_path/includes/geolocation", |
|
311 | - "$plugin_path/includes/api", |
|
312 | - "$plugin_path/includes/admin", |
|
313 | - "$plugin_path/includes/admin/meta-boxes", |
|
314 | - ); |
|
315 | - |
|
316 | - foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) { |
|
317 | - |
|
318 | - if ( file_exists( trailingslashit( $location ) . $file_name ) ) { |
|
319 | - include trailingslashit( $location ) . $file_name; |
|
320 | - break; |
|
321 | - } |
|
322 | - |
|
323 | - } |
|
324 | - |
|
325 | - } |
|
326 | - |
|
327 | - /** |
|
328 | - * Inits hooks etc. |
|
329 | - */ |
|
330 | - public function init() { |
|
331 | - |
|
332 | - // Fires before getpaid inits. |
|
333 | - do_action( 'before_getpaid_init', $this ); |
|
334 | - |
|
335 | - // Load default gateways. |
|
336 | - $gateways = apply_filters( |
|
337 | - 'getpaid_default_gateways', |
|
338 | - array( |
|
339 | - 'manual' => 'GetPaid_Manual_Gateway', |
|
340 | - 'paypal' => 'GetPaid_Paypal_Gateway', |
|
341 | - 'worldpay' => 'GetPaid_Worldpay_Gateway', |
|
342 | - 'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway', |
|
343 | - 'authorizenet' => 'GetPaid_Authorize_Net_Gateway', |
|
344 | - ) |
|
345 | - ); |
|
346 | - |
|
347 | - foreach ( $gateways as $id => $class ) { |
|
348 | - $this->gateways[ $id ] = new $class(); |
|
349 | - } |
|
350 | - |
|
351 | - // Fires after getpaid inits. |
|
352 | - do_action( 'getpaid_init', $this ); |
|
353 | - |
|
354 | - } |
|
355 | - |
|
356 | - /** |
|
357 | - * Checks if this is an IPN request and processes it. |
|
358 | - */ |
|
359 | - public function maybe_process_ipn() { |
|
360 | - |
|
361 | - // Ensure that this is an IPN request. |
|
362 | - if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) { |
|
363 | - return; |
|
364 | - } |
|
365 | - |
|
366 | - $gateway = wpinv_clean( $_GET['wpi-gateway'] ); |
|
367 | - |
|
368 | - do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
369 | - do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
370 | - exit; |
|
371 | - |
|
372 | - } |
|
373 | - |
|
374 | - public function enqueue_scripts() { |
|
375 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
376 | - |
|
377 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' ); |
|
378 | - wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version ); |
|
379 | - wp_enqueue_style( 'wpinv_front_style' ); |
|
380 | - |
|
381 | - // Register scripts |
|
382 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
383 | - wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ), filemtime( WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js' ) ); |
|
384 | - |
|
385 | - $localize = array(); |
|
386 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
387 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
388 | - $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
389 | - $localize['UseTaxes'] = wpinv_use_taxes(); |
|
390 | - $localize['checkoutNonce'] = wp_create_nonce( 'wpinv_checkout_nonce' ); |
|
391 | - $localize['formNonce'] = wp_create_nonce( 'getpaid_form_nonce' ); |
|
392 | - $localize['connectionError'] = __( 'Could not establish a connection to the server.', 'invoicing' ); |
|
393 | - |
|
394 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
395 | - |
|
396 | - wp_enqueue_script( 'jquery-blockui' ); |
|
17 | + /** |
|
18 | + * GetPaid version. |
|
19 | + * |
|
20 | + * @var string |
|
21 | + */ |
|
22 | + public $version; |
|
23 | + |
|
24 | + /** |
|
25 | + * Data container. |
|
26 | + * |
|
27 | + * @var array |
|
28 | + */ |
|
29 | + protected $data = array(); |
|
30 | + |
|
31 | + /** |
|
32 | + * Form elements instance. |
|
33 | + * |
|
34 | + * @var WPInv_Payment_Form_Elements |
|
35 | + */ |
|
36 | + public $form_elements; |
|
37 | + |
|
38 | + /** |
|
39 | + * Tax instance. |
|
40 | + * |
|
41 | + * @var WPInv_EUVat |
|
42 | + */ |
|
43 | + public $tax; |
|
44 | + |
|
45 | + /** |
|
46 | + * @param array An array of payment gateways. |
|
47 | + */ |
|
48 | + public $gateways; |
|
49 | + |
|
50 | + /** |
|
51 | + * Class constructor. |
|
52 | + */ |
|
53 | + public function __construct() { |
|
54 | + $this->define_constants(); |
|
55 | + $this->includes(); |
|
56 | + $this->init_hooks(); |
|
57 | + $this->set_properties(); |
|
58 | + } |
|
59 | + |
|
60 | + /** |
|
61 | + * Sets a custom data property. |
|
62 | + * |
|
63 | + * @param string $prop The prop to set. |
|
64 | + * @param mixed $value The value to retrieve. |
|
65 | + */ |
|
66 | + public function set( $prop, $value ) { |
|
67 | + $this->data[ $prop ] = $value; |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * Gets a custom data property. |
|
72 | + * |
|
73 | + * @param string $prop The prop to set. |
|
74 | + * @return mixed The value. |
|
75 | + */ |
|
76 | + public function get( $prop ) { |
|
77 | + |
|
78 | + if ( isset( $this->data[ $prop ] ) ) { |
|
79 | + return $this->data[ $prop ]; |
|
80 | + } |
|
81 | + |
|
82 | + return null; |
|
83 | + } |
|
84 | + |
|
85 | + /** |
|
86 | + * Define class properties. |
|
87 | + */ |
|
88 | + public function set_properties() { |
|
89 | + |
|
90 | + // Sessions. |
|
91 | + $this->set( 'session', new WPInv_Session_Handler() ); |
|
92 | + $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility. |
|
93 | + $this->tax = new WPInv_EUVat(); |
|
94 | + $this->tax->init(); |
|
95 | + $GLOBALS['wpinv_euvat'] = $this->tax; // Backwards compatibility. |
|
96 | + |
|
97 | + // Init other objects. |
|
98 | + $this->set( 'reports', new WPInv_Reports() ); // TODO: Refactor. |
|
99 | + $this->set( 'session', new WPInv_Session_Handler() ); |
|
100 | + $this->set( 'notes', new WPInv_Notes() ); |
|
101 | + $this->set( 'api', new WPInv_API() ); |
|
102 | + $this->set( 'post_types', new GetPaid_Post_Types() ); |
|
103 | + $this->set( 'template', new GetPaid_Template() ); |
|
104 | + $this->set( 'admin', new GetPaid_Admin() ); |
|
105 | + $this->set( 'subscriptions', new WPInv_Subscriptions() ); |
|
106 | + $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() ); |
|
107 | + $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() ); |
|
108 | + $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() ); |
|
109 | + $this->set( 'payment_forms', new GetPaid_Payment_Forms() ); |
|
110 | + $this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() ); |
|
397 | 111 | |
398 | - wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), WPINV_VERSION, 'all' ); |
|
399 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * Define plugin constants. |
|
116 | + */ |
|
117 | + public function define_constants() { |
|
118 | + define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
119 | + define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
120 | + $this->version = WPINV_VERSION; |
|
121 | + } |
|
122 | + |
|
123 | + /** |
|
124 | + * Hook into actions and filters. |
|
125 | + * |
|
126 | + * @since 1.0.19 |
|
127 | + */ |
|
128 | + protected function init_hooks() { |
|
129 | + /* Internationalize the text strings used. */ |
|
130 | + add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
131 | + |
|
132 | + // Init the plugin after WordPress inits. |
|
133 | + add_action( 'init', array( $this, 'init' ), 1 ); |
|
134 | + add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 ); |
|
135 | + add_action( 'init', array( $this, 'wpinv_actions' ) ); |
|
136 | + add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 ); |
|
137 | + |
|
138 | + if ( class_exists( 'BuddyPress' ) ) { |
|
139 | + add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) ); |
|
140 | + } |
|
141 | + |
|
142 | + add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); |
|
143 | + add_action( 'wp_footer', array( &$this, 'wp_footer' ) ); |
|
144 | + add_action( 'widgets_init', array( &$this, 'register_widgets' ) ); |
|
145 | + add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) ); |
|
146 | + add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
147 | + |
|
148 | + // Fires after registering actions. |
|
149 | + do_action( 'wpinv_actions', $this ); |
|
150 | + do_action( 'getpaid_actions', $this ); |
|
151 | + |
|
152 | + } |
|
153 | + |
|
154 | + public function plugins_loaded() { |
|
155 | + /* Internationalize the text strings used. */ |
|
156 | + $this->load_textdomain(); |
|
157 | + |
|
158 | + do_action( 'wpinv_loaded' ); |
|
159 | + |
|
160 | + // Fix oxygen page builder conflict |
|
161 | + if ( function_exists( 'ct_css_output' ) ) { |
|
162 | + wpinv_oxygen_fix_conflict(); |
|
163 | + } |
|
164 | + } |
|
165 | + |
|
166 | + /** |
|
167 | + * Load the translation of the plugin. |
|
168 | + * |
|
169 | + * @since 1.0 |
|
170 | + */ |
|
171 | + public function load_textdomain( $locale = NULL ) { |
|
172 | + if ( empty( $locale ) ) { |
|
173 | + $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
174 | + } |
|
175 | + |
|
176 | + $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' ); |
|
177 | + |
|
178 | + unload_textdomain( 'invoicing' ); |
|
179 | + load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
|
180 | + load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
181 | + |
|
182 | + /** |
|
183 | + * Define language constants. |
|
184 | + */ |
|
185 | + require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
186 | + } |
|
187 | + |
|
188 | + /** |
|
189 | + * Include required core files used in admin and on the frontend. |
|
190 | + */ |
|
191 | + public function includes() { |
|
192 | + |
|
193 | + // Start with the settings. |
|
194 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
195 | + |
|
196 | + // Packages/libraries. |
|
197 | + require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
198 | + require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' ); |
|
199 | + |
|
200 | + // Load functions. |
|
201 | + require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' ); |
|
202 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
203 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
204 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
205 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
206 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
207 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
208 | + require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' ); |
|
209 | + require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' ); |
|
210 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
211 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
212 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
213 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
214 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' ); |
|
215 | + require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' ); |
|
216 | + |
|
217 | + // Register autoloader. |
|
218 | + try { |
|
219 | + spl_autoload_register( array( $this, 'autoload' ), true ); |
|
220 | + } catch ( Exception $e ) { |
|
221 | + wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
|
222 | + } |
|
223 | + |
|
224 | + require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
225 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
226 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
227 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
228 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' ); |
|
229 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
230 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
231 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
232 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
233 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
234 | + require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
235 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
236 | + require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
237 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
238 | + require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
239 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
240 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
241 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
242 | + require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
243 | + require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
244 | + require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' ); |
|
245 | + |
|
246 | + /** |
|
247 | + * Load the tax class. |
|
248 | + */ |
|
249 | + if ( ! class_exists( 'WPInv_EUVat' ) ) { |
|
250 | + require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' ); |
|
251 | + } |
|
252 | + |
|
253 | + if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
254 | + GetPaid_Post_Types_Admin::init(); |
|
255 | + |
|
256 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' ); |
|
257 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
258 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' ); |
|
259 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
260 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
261 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
262 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
263 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' ); |
|
264 | + // load the user class only on the users.php page |
|
265 | + global $pagenow; |
|
266 | + if($pagenow=='users.php'){ |
|
267 | + new WPInv_Admin_Users(); |
|
268 | + } |
|
269 | + } |
|
270 | + |
|
271 | + // Register cli commands |
|
272 | + if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
273 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
274 | + WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
275 | + } |
|
276 | + |
|
277 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' ); |
|
278 | + } |
|
279 | + |
|
280 | + /** |
|
281 | + * Class autoloader |
|
282 | + * |
|
283 | + * @param string $class_name The name of the class to load. |
|
284 | + * @access public |
|
285 | + * @since 1.0.19 |
|
286 | + * @return void |
|
287 | + */ |
|
288 | + public function autoload( $class_name ) { |
|
400 | 289 | |
401 | - wp_enqueue_script( 'wpinv-front-script' ); |
|
402 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
403 | - |
|
404 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
405 | - wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ), $version, true ); |
|
406 | - } |
|
407 | - |
|
408 | - public function wpinv_actions() { |
|
409 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
410 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
411 | - } |
|
412 | - } |
|
290 | + // Normalize the class name... |
|
291 | + $class_name = strtolower( $class_name ); |
|
413 | 292 | |
414 | - /** |
|
293 | + // ... and make sure it is our class. |
|
294 | + if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
295 | + return; |
|
296 | + } |
|
297 | + |
|
298 | + // Next, prepare the file name from the class. |
|
299 | + $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
300 | + |
|
301 | + // Base path of the classes. |
|
302 | + $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
303 | + |
|
304 | + // And an array of possible locations in order of importance. |
|
305 | + $locations = array( |
|
306 | + "$plugin_path/includes", |
|
307 | + "$plugin_path/includes/data-stores", |
|
308 | + "$plugin_path/includes/gateways", |
|
309 | + "$plugin_path/includes/payments", |
|
310 | + "$plugin_path/includes/geolocation", |
|
311 | + "$plugin_path/includes/api", |
|
312 | + "$plugin_path/includes/admin", |
|
313 | + "$plugin_path/includes/admin/meta-boxes", |
|
314 | + ); |
|
315 | + |
|
316 | + foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) { |
|
317 | + |
|
318 | + if ( file_exists( trailingslashit( $location ) . $file_name ) ) { |
|
319 | + include trailingslashit( $location ) . $file_name; |
|
320 | + break; |
|
321 | + } |
|
322 | + |
|
323 | + } |
|
324 | + |
|
325 | + } |
|
326 | + |
|
327 | + /** |
|
328 | + * Inits hooks etc. |
|
329 | + */ |
|
330 | + public function init() { |
|
331 | + |
|
332 | + // Fires before getpaid inits. |
|
333 | + do_action( 'before_getpaid_init', $this ); |
|
334 | + |
|
335 | + // Load default gateways. |
|
336 | + $gateways = apply_filters( |
|
337 | + 'getpaid_default_gateways', |
|
338 | + array( |
|
339 | + 'manual' => 'GetPaid_Manual_Gateway', |
|
340 | + 'paypal' => 'GetPaid_Paypal_Gateway', |
|
341 | + 'worldpay' => 'GetPaid_Worldpay_Gateway', |
|
342 | + 'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway', |
|
343 | + 'authorizenet' => 'GetPaid_Authorize_Net_Gateway', |
|
344 | + ) |
|
345 | + ); |
|
346 | + |
|
347 | + foreach ( $gateways as $id => $class ) { |
|
348 | + $this->gateways[ $id ] = new $class(); |
|
349 | + } |
|
350 | + |
|
351 | + // Fires after getpaid inits. |
|
352 | + do_action( 'getpaid_init', $this ); |
|
353 | + |
|
354 | + } |
|
355 | + |
|
356 | + /** |
|
357 | + * Checks if this is an IPN request and processes it. |
|
358 | + */ |
|
359 | + public function maybe_process_ipn() { |
|
360 | + |
|
361 | + // Ensure that this is an IPN request. |
|
362 | + if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) { |
|
363 | + return; |
|
364 | + } |
|
365 | + |
|
366 | + $gateway = wpinv_clean( $_GET['wpi-gateway'] ); |
|
367 | + |
|
368 | + do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
369 | + do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
370 | + exit; |
|
371 | + |
|
372 | + } |
|
373 | + |
|
374 | + public function enqueue_scripts() { |
|
375 | + $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
376 | + |
|
377 | + $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' ); |
|
378 | + wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version ); |
|
379 | + wp_enqueue_style( 'wpinv_front_style' ); |
|
380 | + |
|
381 | + // Register scripts |
|
382 | + wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
383 | + wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ), filemtime( WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js' ) ); |
|
384 | + |
|
385 | + $localize = array(); |
|
386 | + $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
387 | + $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
388 | + $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
389 | + $localize['UseTaxes'] = wpinv_use_taxes(); |
|
390 | + $localize['checkoutNonce'] = wp_create_nonce( 'wpinv_checkout_nonce' ); |
|
391 | + $localize['formNonce'] = wp_create_nonce( 'getpaid_form_nonce' ); |
|
392 | + $localize['connectionError'] = __( 'Could not establish a connection to the server.', 'invoicing' ); |
|
393 | + |
|
394 | + $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
395 | + |
|
396 | + wp_enqueue_script( 'jquery-blockui' ); |
|
397 | + |
|
398 | + wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), WPINV_VERSION, 'all' ); |
|
399 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
400 | + |
|
401 | + wp_enqueue_script( 'wpinv-front-script' ); |
|
402 | + wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
403 | + |
|
404 | + $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
405 | + wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ), $version, true ); |
|
406 | + } |
|
407 | + |
|
408 | + public function wpinv_actions() { |
|
409 | + if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
410 | + do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
411 | + } |
|
412 | + } |
|
413 | + |
|
414 | + /** |
|
415 | 415 | * Fires an action after verifying that a user can fire them. |
416 | - * |
|
417 | - * Note: If the action is on an invoice, subscription etc, esure that the |
|
418 | - * current user owns the invoice/subscription. |
|
416 | + * |
|
417 | + * Note: If the action is on an invoice, subscription etc, esure that the |
|
418 | + * current user owns the invoice/subscription. |
|
419 | 419 | */ |
420 | 420 | public function maybe_do_authenticated_action() { |
421 | 421 | |
422 | - if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
422 | + if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
423 | 423 | |
424 | - $key = sanitize_key( $_REQUEST['getpaid-action'] ); |
|
425 | - if ( is_user_logged_in() ) { |
|
426 | - do_action( "getpaid_authenticated_action_$key", $_REQUEST ); |
|
427 | - } |
|
424 | + $key = sanitize_key( $_REQUEST['getpaid-action'] ); |
|
425 | + if ( is_user_logged_in() ) { |
|
426 | + do_action( "getpaid_authenticated_action_$key", $_REQUEST ); |
|
427 | + } |
|
428 | 428 | |
429 | - do_action( "getpaid_unauthenticated_action_$key", $_REQUEST ); |
|
429 | + do_action( "getpaid_unauthenticated_action_$key", $_REQUEST ); |
|
430 | 430 | |
431 | - } |
|
431 | + } |
|
432 | 432 | |
433 | 433 | |
434 | 434 | } |
435 | 435 | |
436 | - public function pre_get_posts( $wp_query ) { |
|
437 | - |
|
438 | - if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) { |
|
439 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) ); |
|
440 | - } |
|
441 | - |
|
442 | - return $wp_query; |
|
443 | - } |
|
444 | - |
|
445 | - public function bp_invoicing_init() { |
|
446 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
447 | - } |
|
448 | - |
|
449 | - /** |
|
450 | - * Register widgets |
|
451 | - * |
|
452 | - */ |
|
453 | - public function register_widgets() { |
|
454 | - $widgets = apply_filters( |
|
455 | - 'getpaid_widget_classes', |
|
456 | - array( |
|
457 | - 'WPInv_Checkout_Widget', |
|
458 | - 'WPInv_History_Widget', |
|
459 | - 'WPInv_Receipt_Widget', |
|
460 | - 'WPInv_Subscriptions_Widget', |
|
461 | - 'WPInv_Buy_Item_Widget', |
|
462 | - 'WPInv_Messages_Widget', |
|
463 | - 'WPInv_GetPaid_Widget' |
|
464 | - ) |
|
465 | - ); |
|
466 | - |
|
467 | - foreach ( $widgets as $widget ) { |
|
468 | - register_widget( $widget ); |
|
469 | - } |
|
436 | + public function pre_get_posts( $wp_query ) { |
|
437 | + |
|
438 | + if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) { |
|
439 | + $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) ); |
|
440 | + } |
|
441 | + |
|
442 | + return $wp_query; |
|
443 | + } |
|
444 | + |
|
445 | + public function bp_invoicing_init() { |
|
446 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
447 | + } |
|
448 | + |
|
449 | + /** |
|
450 | + * Register widgets |
|
451 | + * |
|
452 | + */ |
|
453 | + public function register_widgets() { |
|
454 | + $widgets = apply_filters( |
|
455 | + 'getpaid_widget_classes', |
|
456 | + array( |
|
457 | + 'WPInv_Checkout_Widget', |
|
458 | + 'WPInv_History_Widget', |
|
459 | + 'WPInv_Receipt_Widget', |
|
460 | + 'WPInv_Subscriptions_Widget', |
|
461 | + 'WPInv_Buy_Item_Widget', |
|
462 | + 'WPInv_Messages_Widget', |
|
463 | + 'WPInv_GetPaid_Widget' |
|
464 | + ) |
|
465 | + ); |
|
466 | + |
|
467 | + foreach ( $widgets as $widget ) { |
|
468 | + register_widget( $widget ); |
|
469 | + } |
|
470 | 470 | |
471 | - } |
|
471 | + } |
|
472 | 472 | |
473 | - /** |
|
474 | - * Remove our pages from yoast sitemaps. |
|
475 | - * |
|
476 | - * @since 1.0.19 |
|
477 | - * @param int[] $excluded_posts_ids |
|
478 | - */ |
|
479 | - public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){ |
|
473 | + /** |
|
474 | + * Remove our pages from yoast sitemaps. |
|
475 | + * |
|
476 | + * @since 1.0.19 |
|
477 | + * @param int[] $excluded_posts_ids |
|
478 | + */ |
|
479 | + public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){ |
|
480 | 480 | |
481 | - // Ensure that we have an array. |
|
482 | - if ( ! is_array( $excluded_posts_ids ) ) { |
|
483 | - $excluded_posts_ids = array(); |
|
484 | - } |
|
481 | + // Ensure that we have an array. |
|
482 | + if ( ! is_array( $excluded_posts_ids ) ) { |
|
483 | + $excluded_posts_ids = array(); |
|
484 | + } |
|
485 | 485 | |
486 | - // Prepare our pages. |
|
487 | - $our_pages = array(); |
|
486 | + // Prepare our pages. |
|
487 | + $our_pages = array(); |
|
488 | 488 | |
489 | - // Checkout page. |
|
490 | - $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
489 | + // Checkout page. |
|
490 | + $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
491 | 491 | |
492 | - // Success page. |
|
493 | - $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
492 | + // Success page. |
|
493 | + $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
494 | 494 | |
495 | - // Failure page. |
|
496 | - $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
495 | + // Failure page. |
|
496 | + $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
497 | 497 | |
498 | - // History page. |
|
499 | - $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
498 | + // History page. |
|
499 | + $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
500 | 500 | |
501 | - // Subscriptions page. |
|
502 | - $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
501 | + // Subscriptions page. |
|
502 | + $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
503 | 503 | |
504 | - $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
504 | + $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
505 | 505 | |
506 | - $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
|
507 | - return array_unique( $excluded_posts_ids ); |
|
506 | + $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
|
507 | + return array_unique( $excluded_posts_ids ); |
|
508 | 508 | |
509 | - } |
|
509 | + } |
|
510 | 510 | |
511 | - public function wp_footer() { |
|
512 | - echo ' |
|
511 | + public function wp_footer() { |
|
512 | + echo ' |
|
513 | 513 | <div class="bsui"> |
514 | 514 | <div id="getpaid-payment-modal" class="modal" tabindex="-1" role="dialog"> |
515 | 515 | <div class="modal-dialog modal-dialog-centered modal-lg" role="checkout" style="max-width: 650px;"> |
@@ -520,6 +520,6 @@ discard block |
||
520 | 520 | </div> |
521 | 521 | </div> |
522 | 522 | '; |
523 | - } |
|
523 | + } |
|
524 | 524 | |
525 | 525 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @since 1.0.0 |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Main Invoicing class. |
@@ -63,8 +63,8 @@ discard block |
||
63 | 63 | * @param string $prop The prop to set. |
64 | 64 | * @param mixed $value The value to retrieve. |
65 | 65 | */ |
66 | - public function set( $prop, $value ) { |
|
67 | - $this->data[ $prop ] = $value; |
|
66 | + public function set($prop, $value) { |
|
67 | + $this->data[$prop] = $value; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -73,10 +73,10 @@ discard block |
||
73 | 73 | * @param string $prop The prop to set. |
74 | 74 | * @return mixed The value. |
75 | 75 | */ |
76 | - public function get( $prop ) { |
|
76 | + public function get($prop) { |
|
77 | 77 | |
78 | - if ( isset( $this->data[ $prop ] ) ) { |
|
79 | - return $this->data[ $prop ]; |
|
78 | + if (isset($this->data[$prop])) { |
|
79 | + return $this->data[$prop]; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | return null; |
@@ -88,26 +88,26 @@ discard block |
||
88 | 88 | public function set_properties() { |
89 | 89 | |
90 | 90 | // Sessions. |
91 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
92 | - $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility. |
|
91 | + $this->set('session', new WPInv_Session_Handler()); |
|
92 | + $GLOBALS['wpi_session'] = $this->get('session'); // Backwards compatibility. |
|
93 | 93 | $this->tax = new WPInv_EUVat(); |
94 | 94 | $this->tax->init(); |
95 | 95 | $GLOBALS['wpinv_euvat'] = $this->tax; // Backwards compatibility. |
96 | 96 | |
97 | 97 | // Init other objects. |
98 | - $this->set( 'reports', new WPInv_Reports() ); // TODO: Refactor. |
|
99 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
100 | - $this->set( 'notes', new WPInv_Notes() ); |
|
101 | - $this->set( 'api', new WPInv_API() ); |
|
102 | - $this->set( 'post_types', new GetPaid_Post_Types() ); |
|
103 | - $this->set( 'template', new GetPaid_Template() ); |
|
104 | - $this->set( 'admin', new GetPaid_Admin() ); |
|
105 | - $this->set( 'subscriptions', new WPInv_Subscriptions() ); |
|
106 | - $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() ); |
|
107 | - $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() ); |
|
108 | - $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() ); |
|
109 | - $this->set( 'payment_forms', new GetPaid_Payment_Forms() ); |
|
110 | - $this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() ); |
|
98 | + $this->set('reports', new WPInv_Reports()); // TODO: Refactor. |
|
99 | + $this->set('session', new WPInv_Session_Handler()); |
|
100 | + $this->set('notes', new WPInv_Notes()); |
|
101 | + $this->set('api', new WPInv_API()); |
|
102 | + $this->set('post_types', new GetPaid_Post_Types()); |
|
103 | + $this->set('template', new GetPaid_Template()); |
|
104 | + $this->set('admin', new GetPaid_Admin()); |
|
105 | + $this->set('subscriptions', new WPInv_Subscriptions()); |
|
106 | + $this->set('invoice_emails', new GetPaid_Invoice_Notification_Emails()); |
|
107 | + $this->set('subscription_emails', new GetPaid_Subscription_Notification_Emails()); |
|
108 | + $this->set('daily_maintenace', new GetPaid_Daily_Maintenance()); |
|
109 | + $this->set('payment_forms', new GetPaid_Payment_Forms()); |
|
110 | + $this->set('maxmind', new GetPaid_MaxMind_Geolocation()); |
|
111 | 111 | |
112 | 112 | } |
113 | 113 | |
@@ -115,8 +115,8 @@ discard block |
||
115 | 115 | * Define plugin constants. |
116 | 116 | */ |
117 | 117 | public function define_constants() { |
118 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
119 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
118 | + define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE)); |
|
119 | + define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE)); |
|
120 | 120 | $this->version = WPINV_VERSION; |
121 | 121 | } |
122 | 122 | |
@@ -127,27 +127,27 @@ discard block |
||
127 | 127 | */ |
128 | 128 | protected function init_hooks() { |
129 | 129 | /* Internationalize the text strings used. */ |
130 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
130 | + add_action('plugins_loaded', array(&$this, 'plugins_loaded')); |
|
131 | 131 | |
132 | 132 | // Init the plugin after WordPress inits. |
133 | - add_action( 'init', array( $this, 'init' ), 1 ); |
|
134 | - add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 ); |
|
135 | - add_action( 'init', array( $this, 'wpinv_actions' ) ); |
|
136 | - add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 ); |
|
133 | + add_action('init', array($this, 'init'), 1); |
|
134 | + add_action('init', array($this, 'maybe_process_ipn'), 10); |
|
135 | + add_action('init', array($this, 'wpinv_actions')); |
|
136 | + add_action('init', array($this, 'maybe_do_authenticated_action'), 100); |
|
137 | 137 | |
138 | - if ( class_exists( 'BuddyPress' ) ) { |
|
139 | - add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) ); |
|
138 | + if (class_exists('BuddyPress')) { |
|
139 | + add_action('bp_include', array(&$this, 'bp_invoicing_init')); |
|
140 | 140 | } |
141 | 141 | |
142 | - add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); |
|
143 | - add_action( 'wp_footer', array( &$this, 'wp_footer' ) ); |
|
144 | - add_action( 'widgets_init', array( &$this, 'register_widgets' ) ); |
|
145 | - add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) ); |
|
146 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
142 | + add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts')); |
|
143 | + add_action('wp_footer', array(&$this, 'wp_footer')); |
|
144 | + add_action('widgets_init', array(&$this, 'register_widgets')); |
|
145 | + add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids')); |
|
146 | + add_filter('pre_get_posts', array(&$this, 'pre_get_posts')); |
|
147 | 147 | |
148 | 148 | // Fires after registering actions. |
149 | - do_action( 'wpinv_actions', $this ); |
|
150 | - do_action( 'getpaid_actions', $this ); |
|
149 | + do_action('wpinv_actions', $this); |
|
150 | + do_action('getpaid_actions', $this); |
|
151 | 151 | |
152 | 152 | } |
153 | 153 | |
@@ -155,10 +155,10 @@ discard block |
||
155 | 155 | /* Internationalize the text strings used. */ |
156 | 156 | $this->load_textdomain(); |
157 | 157 | |
158 | - do_action( 'wpinv_loaded' ); |
|
158 | + do_action('wpinv_loaded'); |
|
159 | 159 | |
160 | 160 | // Fix oxygen page builder conflict |
161 | - if ( function_exists( 'ct_css_output' ) ) { |
|
161 | + if (function_exists('ct_css_output')) { |
|
162 | 162 | wpinv_oxygen_fix_conflict(); |
163 | 163 | } |
164 | 164 | } |
@@ -168,21 +168,21 @@ discard block |
||
168 | 168 | * |
169 | 169 | * @since 1.0 |
170 | 170 | */ |
171 | - public function load_textdomain( $locale = NULL ) { |
|
172 | - if ( empty( $locale ) ) { |
|
173 | - $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
171 | + public function load_textdomain($locale = NULL) { |
|
172 | + if (empty($locale)) { |
|
173 | + $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale(); |
|
174 | 174 | } |
175 | 175 | |
176 | - $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' ); |
|
176 | + $locale = apply_filters('plugin_locale', $locale, 'invoicing'); |
|
177 | 177 | |
178 | - unload_textdomain( 'invoicing' ); |
|
179 | - load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
|
180 | - load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
178 | + unload_textdomain('invoicing'); |
|
179 | + load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo'); |
|
180 | + load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages'); |
|
181 | 181 | |
182 | 182 | /** |
183 | 183 | * Define language constants. |
184 | 184 | */ |
185 | - require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
185 | + require_once(WPINV_PLUGIN_DIR . 'language.php'); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -191,90 +191,90 @@ discard block |
||
191 | 191 | public function includes() { |
192 | 192 | |
193 | 193 | // Start with the settings. |
194 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
194 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php'); |
|
195 | 195 | |
196 | 196 | // Packages/libraries. |
197 | - require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
198 | - require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' ); |
|
197 | + require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php'); |
|
198 | + require_once(WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php'); |
|
199 | 199 | |
200 | 200 | // Load functions. |
201 | - require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' ); |
|
202 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
203 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
204 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
205 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
206 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
207 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
208 | - require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' ); |
|
209 | - require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' ); |
|
210 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
211 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
212 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
213 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
214 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' ); |
|
215 | - require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' ); |
|
201 | + require_once(WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php'); |
|
202 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php'); |
|
203 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php'); |
|
204 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php'); |
|
205 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php'); |
|
206 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php'); |
|
207 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php'); |
|
208 | + require_once(WPINV_PLUGIN_DIR . 'includes/invoice-functions.php'); |
|
209 | + require_once(WPINV_PLUGIN_DIR . 'includes/subscription-functions.php'); |
|
210 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php'); |
|
211 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php'); |
|
212 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php'); |
|
213 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php'); |
|
214 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php'); |
|
215 | + require_once(WPINV_PLUGIN_DIR . 'includes/error-functions.php'); |
|
216 | 216 | |
217 | 217 | // Register autoloader. |
218 | 218 | try { |
219 | - spl_autoload_register( array( $this, 'autoload' ), true ); |
|
220 | - } catch ( Exception $e ) { |
|
221 | - wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
|
219 | + spl_autoload_register(array($this, 'autoload'), true); |
|
220 | + } catch (Exception $e) { |
|
221 | + wpinv_error_log($e->getMessage(), '', __FILE__, 149, true); |
|
222 | 222 | } |
223 | 223 | |
224 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
225 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
226 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
227 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
228 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' ); |
|
229 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
230 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
231 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
232 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
233 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
234 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
235 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
236 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
237 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
238 | - require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
239 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
240 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
241 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
242 | - require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
243 | - require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
244 | - require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' ); |
|
224 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php'); |
|
225 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php'); |
|
226 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php'); |
|
227 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php'); |
|
228 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php'); |
|
229 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php'); |
|
230 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php'); |
|
231 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php'); |
|
232 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php'); |
|
233 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php'); |
|
234 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php'); |
|
235 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php'); |
|
236 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php'); |
|
237 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php'); |
|
238 | + require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php'); |
|
239 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php'); |
|
240 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php'); |
|
241 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php'); |
|
242 | + require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php'); |
|
243 | + require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php'); |
|
244 | + require_once(WPINV_PLUGIN_DIR . 'widgets/getpaid.php'); |
|
245 | 245 | |
246 | 246 | /** |
247 | 247 | * Load the tax class. |
248 | 248 | */ |
249 | - if ( ! class_exists( 'WPInv_EUVat' ) ) { |
|
250 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' ); |
|
249 | + if (!class_exists('WPInv_EUVat')) { |
|
250 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php'); |
|
251 | 251 | } |
252 | 252 | |
253 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
253 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
254 | 254 | GetPaid_Post_Types_Admin::init(); |
255 | 255 | |
256 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' ); |
|
257 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
258 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' ); |
|
259 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
260 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
261 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
262 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
263 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' ); |
|
256 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php'); |
|
257 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php'); |
|
258 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php'); |
|
259 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php'); |
|
260 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'); |
|
261 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php'); |
|
262 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php'); |
|
263 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php'); |
|
264 | 264 | // load the user class only on the users.php page |
265 | 265 | global $pagenow; |
266 | - if($pagenow=='users.php'){ |
|
266 | + if ($pagenow == 'users.php') { |
|
267 | 267 | new WPInv_Admin_Users(); |
268 | 268 | } |
269 | 269 | } |
270 | 270 | |
271 | 271 | // Register cli commands |
272 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
273 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
274 | - WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
272 | + if (defined('WP_CLI') && WP_CLI) { |
|
273 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php'); |
|
274 | + WP_CLI::add_command('invoicing', 'WPInv_CLI'); |
|
275 | 275 | } |
276 | 276 | |
277 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' ); |
|
277 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php'); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | /** |
@@ -285,21 +285,21 @@ discard block |
||
285 | 285 | * @since 1.0.19 |
286 | 286 | * @return void |
287 | 287 | */ |
288 | - public function autoload( $class_name ) { |
|
288 | + public function autoload($class_name) { |
|
289 | 289 | |
290 | 290 | // Normalize the class name... |
291 | - $class_name = strtolower( $class_name ); |
|
291 | + $class_name = strtolower($class_name); |
|
292 | 292 | |
293 | 293 | // ... and make sure it is our class. |
294 | - if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
294 | + if (false === strpos($class_name, 'getpaid_') && false === strpos($class_name, 'wpinv_')) { |
|
295 | 295 | return; |
296 | 296 | } |
297 | 297 | |
298 | 298 | // Next, prepare the file name from the class. |
299 | - $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
299 | + $file_name = 'class-' . str_replace('_', '-', $class_name) . '.php'; |
|
300 | 300 | |
301 | 301 | // Base path of the classes. |
302 | - $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
302 | + $plugin_path = untrailingslashit(WPINV_PLUGIN_DIR); |
|
303 | 303 | |
304 | 304 | // And an array of possible locations in order of importance. |
305 | 305 | $locations = array( |
@@ -313,10 +313,10 @@ discard block |
||
313 | 313 | "$plugin_path/includes/admin/meta-boxes", |
314 | 314 | ); |
315 | 315 | |
316 | - foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) { |
|
316 | + foreach (apply_filters('getpaid_autoload_locations', $locations) as $location) { |
|
317 | 317 | |
318 | - if ( file_exists( trailingslashit( $location ) . $file_name ) ) { |
|
319 | - include trailingslashit( $location ) . $file_name; |
|
318 | + if (file_exists(trailingslashit($location) . $file_name)) { |
|
319 | + include trailingslashit($location) . $file_name; |
|
320 | 320 | break; |
321 | 321 | } |
322 | 322 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | public function init() { |
331 | 331 | |
332 | 332 | // Fires before getpaid inits. |
333 | - do_action( 'before_getpaid_init', $this ); |
|
333 | + do_action('before_getpaid_init', $this); |
|
334 | 334 | |
335 | 335 | // Load default gateways. |
336 | 336 | $gateways = apply_filters( |
@@ -344,12 +344,12 @@ discard block |
||
344 | 344 | ) |
345 | 345 | ); |
346 | 346 | |
347 | - foreach ( $gateways as $id => $class ) { |
|
348 | - $this->gateways[ $id ] = new $class(); |
|
347 | + foreach ($gateways as $id => $class) { |
|
348 | + $this->gateways[$id] = new $class(); |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | // Fires after getpaid inits. |
352 | - do_action( 'getpaid_init', $this ); |
|
352 | + do_action('getpaid_init', $this); |
|
353 | 353 | |
354 | 354 | } |
355 | 355 | |
@@ -359,55 +359,55 @@ discard block |
||
359 | 359 | public function maybe_process_ipn() { |
360 | 360 | |
361 | 361 | // Ensure that this is an IPN request. |
362 | - if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) { |
|
362 | + if (empty($_GET['wpi-listener']) || 'IPN' !== $_GET['wpi-listener'] || empty($_GET['wpi-gateway'])) { |
|
363 | 363 | return; |
364 | 364 | } |
365 | 365 | |
366 | - $gateway = wpinv_clean( $_GET['wpi-gateway'] ); |
|
366 | + $gateway = wpinv_clean($_GET['wpi-gateway']); |
|
367 | 367 | |
368 | - do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
369 | - do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
368 | + do_action('wpinv_verify_payment_ipn', $gateway); |
|
369 | + do_action("wpinv_verify_{$gateway}_ipn"); |
|
370 | 370 | exit; |
371 | 371 | |
372 | 372 | } |
373 | 373 | |
374 | 374 | public function enqueue_scripts() { |
375 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
375 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
376 | 376 | |
377 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' ); |
|
378 | - wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version ); |
|
379 | - wp_enqueue_style( 'wpinv_front_style' ); |
|
377 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css'); |
|
378 | + wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version); |
|
379 | + wp_enqueue_style('wpinv_front_style'); |
|
380 | 380 | |
381 | 381 | // Register scripts |
382 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
383 | - wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ), filemtime( WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js' ) ); |
|
382 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
383 | + wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array('jquery'), filemtime(WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js')); |
|
384 | 384 | |
385 | 385 | $localize = array(); |
386 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
387 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
388 | - $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
386 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
387 | + $localize['nonce'] = wp_create_nonce('wpinv-nonce'); |
|
388 | + $localize['txtComplete'] = __('Continue', 'invoicing'); |
|
389 | 389 | $localize['UseTaxes'] = wpinv_use_taxes(); |
390 | - $localize['checkoutNonce'] = wp_create_nonce( 'wpinv_checkout_nonce' ); |
|
391 | - $localize['formNonce'] = wp_create_nonce( 'getpaid_form_nonce' ); |
|
392 | - $localize['connectionError'] = __( 'Could not establish a connection to the server.', 'invoicing' ); |
|
390 | + $localize['checkoutNonce'] = wp_create_nonce('wpinv_checkout_nonce'); |
|
391 | + $localize['formNonce'] = wp_create_nonce('getpaid_form_nonce'); |
|
392 | + $localize['connectionError'] = __('Could not establish a connection to the server.', 'invoicing'); |
|
393 | 393 | |
394 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
394 | + $localize = apply_filters('wpinv_front_js_localize', $localize); |
|
395 | 395 | |
396 | - wp_enqueue_script( 'jquery-blockui' ); |
|
396 | + wp_enqueue_script('jquery-blockui'); |
|
397 | 397 | |
398 | - wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), WPINV_VERSION, 'all' ); |
|
399 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
398 | + wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), WPINV_VERSION, 'all'); |
|
399 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
400 | 400 | |
401 | - wp_enqueue_script( 'wpinv-front-script' ); |
|
402 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
401 | + wp_enqueue_script('wpinv-front-script'); |
|
402 | + wp_localize_script('wpinv-front-script', 'WPInv', $localize); |
|
403 | 403 | |
404 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
405 | - wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ), $version, true ); |
|
404 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js'); |
|
405 | + wp_enqueue_script('wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('wpinv-front-script', 'wp-hooks'), $version, true); |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | public function wpinv_actions() { |
409 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
410 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
409 | + if (isset($_REQUEST['wpi_action'])) { |
|
410 | + do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); |
|
411 | 411 | } |
412 | 412 | } |
413 | 413 | |
@@ -419,31 +419,31 @@ discard block |
||
419 | 419 | */ |
420 | 420 | public function maybe_do_authenticated_action() { |
421 | 421 | |
422 | - if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
422 | + if (isset($_REQUEST['getpaid-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) { |
|
423 | 423 | |
424 | - $key = sanitize_key( $_REQUEST['getpaid-action'] ); |
|
425 | - if ( is_user_logged_in() ) { |
|
426 | - do_action( "getpaid_authenticated_action_$key", $_REQUEST ); |
|
424 | + $key = sanitize_key($_REQUEST['getpaid-action']); |
|
425 | + if (is_user_logged_in()) { |
|
426 | + do_action("getpaid_authenticated_action_$key", $_REQUEST); |
|
427 | 427 | } |
428 | 428 | |
429 | - do_action( "getpaid_unauthenticated_action_$key", $_REQUEST ); |
|
429 | + do_action("getpaid_unauthenticated_action_$key", $_REQUEST); |
|
430 | 430 | |
431 | 431 | } |
432 | 432 | |
433 | 433 | |
434 | 434 | } |
435 | 435 | |
436 | - public function pre_get_posts( $wp_query ) { |
|
436 | + public function pre_get_posts($wp_query) { |
|
437 | 437 | |
438 | - if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) { |
|
439 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) ); |
|
438 | + if (!is_admin() && !empty($wp_query->query_vars['post_type']) && getpaid_is_invoice_post_type($wp_query->query_vars['post_type']) && is_user_logged_in() && is_single() && $wp_query->is_main_query()) { |
|
439 | + $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses(false, false, $wp_query->query_vars['post_type'])); |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | return $wp_query; |
443 | 443 | } |
444 | 444 | |
445 | 445 | public function bp_invoicing_init() { |
446 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
446 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php'); |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | /** |
@@ -464,8 +464,8 @@ discard block |
||
464 | 464 | ) |
465 | 465 | ); |
466 | 466 | |
467 | - foreach ( $widgets as $widget ) { |
|
468 | - register_widget( $widget ); |
|
467 | + foreach ($widgets as $widget) { |
|
468 | + register_widget($widget); |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | } |
@@ -476,10 +476,10 @@ discard block |
||
476 | 476 | * @since 1.0.19 |
477 | 477 | * @param int[] $excluded_posts_ids |
478 | 478 | */ |
479 | - public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){ |
|
479 | + public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) { |
|
480 | 480 | |
481 | 481 | // Ensure that we have an array. |
482 | - if ( ! is_array( $excluded_posts_ids ) ) { |
|
482 | + if (!is_array($excluded_posts_ids)) { |
|
483 | 483 | $excluded_posts_ids = array(); |
484 | 484 | } |
485 | 485 | |
@@ -487,24 +487,24 @@ discard block |
||
487 | 487 | $our_pages = array(); |
488 | 488 | |
489 | 489 | // Checkout page. |
490 | - $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
490 | + $our_pages[] = wpinv_get_option('checkout_page', false); |
|
491 | 491 | |
492 | 492 | // Success page. |
493 | - $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
493 | + $our_pages[] = wpinv_get_option('success_page', false); |
|
494 | 494 | |
495 | 495 | // Failure page. |
496 | - $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
496 | + $our_pages[] = wpinv_get_option('failure_page', false); |
|
497 | 497 | |
498 | 498 | // History page. |
499 | - $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
499 | + $our_pages[] = wpinv_get_option('invoice_history_page', false); |
|
500 | 500 | |
501 | 501 | // Subscriptions page. |
502 | - $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
502 | + $our_pages[] = wpinv_get_option('invoice_subscription_page', false); |
|
503 | 503 | |
504 | - $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
504 | + $our_pages = array_map('intval', array_filter($our_pages)); |
|
505 | 505 | |
506 | 506 | $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
507 | - return array_unique( $excluded_posts_ids ); |
|
507 | + return array_unique($excluded_posts_ids); |
|
508 | 508 | |
509 | 509 | } |
510 | 510 |
@@ -7,16 +7,16 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | -if ( empty( $text ) ) { |
|
13 | - $text = __( 'Your IP address is:', 'invoicing' ); |
|
12 | +if (empty($text)) { |
|
13 | + $text = __('Your IP address is:', 'invoicing'); |
|
14 | 14 | } |
15 | 15 | |
16 | -$ip_address = sanitize_text_field( wpinv_get_ip() ); |
|
16 | +$ip_address = sanitize_text_field(wpinv_get_ip()); |
|
17 | 17 | |
18 | 18 | ?> |
19 | 19 | <div class="form-group getpaid-ip-info"> |
20 | - <span><?php echo wp_kses_post( $text ); ?></span> |
|
20 | + <span><?php echo wp_kses_post($text); ?></span> |
|
21 | 21 | <strong><?php echo $ip_address; ?></strong> |
22 | 22 | </div> |
@@ -12,8 +12,8 @@ discard block |
||
12 | 12 | class InstalledVersions |
13 | 13 | { |
14 | 14 | private static $installed = array ( |
15 | - 'root' => |
|
16 | - array ( |
|
15 | + 'root' => |
|
16 | + array ( |
|
17 | 17 | 'pretty_version' => 'dev-master', |
18 | 18 | 'version' => 'dev-master', |
19 | 19 | 'aliases' => |
@@ -21,87 +21,87 @@ discard block |
||
21 | 21 | ), |
22 | 22 | 'reference' => '58e08ab4fbfabf9d48bdecf0dce878830040d4ea', |
23 | 23 | 'name' => 'ayecode/invoicing', |
24 | - ), |
|
25 | - 'versions' => |
|
26 | - array ( |
|
24 | + ), |
|
25 | + 'versions' => |
|
26 | + array ( |
|
27 | 27 | 'ayecode/ayecode-connect-helper' => |
28 | 28 | array ( |
29 | - 'pretty_version' => '1.0.3', |
|
30 | - 'version' => '1.0.3.0', |
|
31 | - 'aliases' => |
|
32 | - array ( |
|
33 | - ), |
|
34 | - 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
|
29 | + 'pretty_version' => '1.0.3', |
|
30 | + 'version' => '1.0.3.0', |
|
31 | + 'aliases' => |
|
32 | + array ( |
|
33 | + ), |
|
34 | + 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
|
35 | 35 | ), |
36 | 36 | 'ayecode/invoicing' => |
37 | 37 | array ( |
38 | - 'pretty_version' => 'dev-master', |
|
39 | - 'version' => 'dev-master', |
|
40 | - 'aliases' => |
|
41 | - array ( |
|
42 | - ), |
|
43 | - 'reference' => '58e08ab4fbfabf9d48bdecf0dce878830040d4ea', |
|
38 | + 'pretty_version' => 'dev-master', |
|
39 | + 'version' => 'dev-master', |
|
40 | + 'aliases' => |
|
41 | + array ( |
|
42 | + ), |
|
43 | + 'reference' => '58e08ab4fbfabf9d48bdecf0dce878830040d4ea', |
|
44 | 44 | ), |
45 | 45 | 'ayecode/wp-ayecode-ui' => |
46 | 46 | array ( |
47 | - 'pretty_version' => '0.1.35', |
|
48 | - 'version' => '0.1.35.0', |
|
49 | - 'aliases' => |
|
50 | - array ( |
|
51 | - ), |
|
52 | - 'reference' => 'e5d7955f648c6b350a8fe72e0110b8d78645c60f', |
|
47 | + 'pretty_version' => '0.1.35', |
|
48 | + 'version' => '0.1.35.0', |
|
49 | + 'aliases' => |
|
50 | + array ( |
|
51 | + ), |
|
52 | + 'reference' => 'e5d7955f648c6b350a8fe72e0110b8d78645c60f', |
|
53 | 53 | ), |
54 | 54 | 'ayecode/wp-font-awesome-settings' => |
55 | 55 | array ( |
56 | - 'pretty_version' => '1.0.12', |
|
57 | - 'version' => '1.0.12.0', |
|
58 | - 'aliases' => |
|
59 | - array ( |
|
60 | - ), |
|
61 | - 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
|
56 | + 'pretty_version' => '1.0.12', |
|
57 | + 'version' => '1.0.12.0', |
|
58 | + 'aliases' => |
|
59 | + array ( |
|
60 | + ), |
|
61 | + 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
|
62 | 62 | ), |
63 | 63 | 'ayecode/wp-super-duper' => |
64 | 64 | array ( |
65 | - 'pretty_version' => '1.0.22', |
|
66 | - 'version' => '1.0.22.0', |
|
67 | - 'aliases' => |
|
68 | - array ( |
|
69 | - ), |
|
70 | - 'reference' => '42b638502c9e4be0877f27903df7c7ed2080bdac', |
|
65 | + 'pretty_version' => '1.0.22', |
|
66 | + 'version' => '1.0.22.0', |
|
67 | + 'aliases' => |
|
68 | + array ( |
|
69 | + ), |
|
70 | + 'reference' => '42b638502c9e4be0877f27903df7c7ed2080bdac', |
|
71 | 71 | ), |
72 | 72 | 'composer/installers' => |
73 | 73 | array ( |
74 | - 'pretty_version' => 'v1.9.0', |
|
75 | - 'version' => '1.9.0.0', |
|
76 | - 'aliases' => |
|
77 | - array ( |
|
78 | - ), |
|
79 | - 'reference' => 'b93bcf0fa1fccb0b7d176b0967d969691cd74cca', |
|
74 | + 'pretty_version' => 'v1.9.0', |
|
75 | + 'version' => '1.9.0.0', |
|
76 | + 'aliases' => |
|
77 | + array ( |
|
78 | + ), |
|
79 | + 'reference' => 'b93bcf0fa1fccb0b7d176b0967d969691cd74cca', |
|
80 | 80 | ), |
81 | 81 | 'maxmind-db/reader' => |
82 | 82 | array ( |
83 | - 'pretty_version' => 'v1.6.0', |
|
84 | - 'version' => '1.6.0.0', |
|
85 | - 'aliases' => |
|
86 | - array ( |
|
87 | - ), |
|
88 | - 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
|
83 | + 'pretty_version' => 'v1.6.0', |
|
84 | + 'version' => '1.6.0.0', |
|
85 | + 'aliases' => |
|
86 | + array ( |
|
87 | + ), |
|
88 | + 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
|
89 | 89 | ), |
90 | 90 | 'roundcube/plugin-installer' => |
91 | 91 | array ( |
92 | - 'replaced' => |
|
93 | - array ( |
|
92 | + 'replaced' => |
|
93 | + array ( |
|
94 | 94 | 0 => '*', |
95 | - ), |
|
95 | + ), |
|
96 | 96 | ), |
97 | 97 | 'shama/baton' => |
98 | 98 | array ( |
99 | - 'replaced' => |
|
100 | - array ( |
|
99 | + 'replaced' => |
|
100 | + array ( |
|
101 | 101 | 0 => '*', |
102 | - ), |
|
102 | + ), |
|
103 | + ), |
|
103 | 104 | ), |
104 | - ), |
|
105 | 105 | ); |
106 | 106 | |
107 | 107 |
@@ -11,93 +11,93 @@ |
||
11 | 11 | |
12 | 12 | class InstalledVersions |
13 | 13 | { |
14 | -private static $installed = array ( |
|
14 | +private static $installed = array( |
|
15 | 15 | 'root' => |
16 | - array ( |
|
16 | + array( |
|
17 | 17 | 'pretty_version' => 'dev-master', |
18 | 18 | 'version' => 'dev-master', |
19 | 19 | 'aliases' => |
20 | - array ( |
|
20 | + array( |
|
21 | 21 | ), |
22 | 22 | 'reference' => '58e08ab4fbfabf9d48bdecf0dce878830040d4ea', |
23 | 23 | 'name' => 'ayecode/invoicing', |
24 | 24 | ), |
25 | 25 | 'versions' => |
26 | - array ( |
|
26 | + array( |
|
27 | 27 | 'ayecode/ayecode-connect-helper' => |
28 | - array ( |
|
28 | + array( |
|
29 | 29 | 'pretty_version' => '1.0.3', |
30 | 30 | 'version' => '1.0.3.0', |
31 | 31 | 'aliases' => |
32 | - array ( |
|
32 | + array( |
|
33 | 33 | ), |
34 | 34 | 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
35 | 35 | ), |
36 | 36 | 'ayecode/invoicing' => |
37 | - array ( |
|
37 | + array( |
|
38 | 38 | 'pretty_version' => 'dev-master', |
39 | 39 | 'version' => 'dev-master', |
40 | 40 | 'aliases' => |
41 | - array ( |
|
41 | + array( |
|
42 | 42 | ), |
43 | 43 | 'reference' => '58e08ab4fbfabf9d48bdecf0dce878830040d4ea', |
44 | 44 | ), |
45 | 45 | 'ayecode/wp-ayecode-ui' => |
46 | - array ( |
|
46 | + array( |
|
47 | 47 | 'pretty_version' => '0.1.35', |
48 | 48 | 'version' => '0.1.35.0', |
49 | 49 | 'aliases' => |
50 | - array ( |
|
50 | + array( |
|
51 | 51 | ), |
52 | 52 | 'reference' => 'e5d7955f648c6b350a8fe72e0110b8d78645c60f', |
53 | 53 | ), |
54 | 54 | 'ayecode/wp-font-awesome-settings' => |
55 | - array ( |
|
55 | + array( |
|
56 | 56 | 'pretty_version' => '1.0.12', |
57 | 57 | 'version' => '1.0.12.0', |
58 | 58 | 'aliases' => |
59 | - array ( |
|
59 | + array( |
|
60 | 60 | ), |
61 | 61 | 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
62 | 62 | ), |
63 | 63 | 'ayecode/wp-super-duper' => |
64 | - array ( |
|
64 | + array( |
|
65 | 65 | 'pretty_version' => '1.0.22', |
66 | 66 | 'version' => '1.0.22.0', |
67 | 67 | 'aliases' => |
68 | - array ( |
|
68 | + array( |
|
69 | 69 | ), |
70 | 70 | 'reference' => '42b638502c9e4be0877f27903df7c7ed2080bdac', |
71 | 71 | ), |
72 | 72 | 'composer/installers' => |
73 | - array ( |
|
73 | + array( |
|
74 | 74 | 'pretty_version' => 'v1.9.0', |
75 | 75 | 'version' => '1.9.0.0', |
76 | 76 | 'aliases' => |
77 | - array ( |
|
77 | + array( |
|
78 | 78 | ), |
79 | 79 | 'reference' => 'b93bcf0fa1fccb0b7d176b0967d969691cd74cca', |
80 | 80 | ), |
81 | 81 | 'maxmind-db/reader' => |
82 | - array ( |
|
82 | + array( |
|
83 | 83 | 'pretty_version' => 'v1.6.0', |
84 | 84 | 'version' => '1.6.0.0', |
85 | 85 | 'aliases' => |
86 | - array ( |
|
86 | + array( |
|
87 | 87 | ), |
88 | 88 | 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
89 | 89 | ), |
90 | 90 | 'roundcube/plugin-installer' => |
91 | - array ( |
|
91 | + array( |
|
92 | 92 | 'replaced' => |
93 | - array ( |
|
93 | + array( |
|
94 | 94 | 0 => '*', |
95 | 95 | ), |
96 | 96 | ), |
97 | 97 | 'shama/baton' => |
98 | - array ( |
|
98 | + array( |
|
99 | 99 | 'replaced' => |
100 | - array ( |
|
100 | + array( |
|
101 | 101 | 0 => '*', |
102 | 102 | ), |
103 | 103 | ), |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php return array ( |
2 | - 'root' => |
|
3 | - array ( |
|
2 | + 'root' => |
|
3 | + array ( |
|
4 | 4 | 'pretty_version' => 'dev-master', |
5 | 5 | 'version' => 'dev-master', |
6 | 6 | 'aliases' => |
@@ -8,85 +8,85 @@ discard block |
||
8 | 8 | ), |
9 | 9 | 'reference' => '58e08ab4fbfabf9d48bdecf0dce878830040d4ea', |
10 | 10 | 'name' => 'ayecode/invoicing', |
11 | - ), |
|
12 | - 'versions' => |
|
13 | - array ( |
|
11 | + ), |
|
12 | + 'versions' => |
|
13 | + array ( |
|
14 | 14 | 'ayecode/ayecode-connect-helper' => |
15 | 15 | array ( |
16 | - 'pretty_version' => '1.0.3', |
|
17 | - 'version' => '1.0.3.0', |
|
18 | - 'aliases' => |
|
19 | - array ( |
|
20 | - ), |
|
21 | - 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
|
16 | + 'pretty_version' => '1.0.3', |
|
17 | + 'version' => '1.0.3.0', |
|
18 | + 'aliases' => |
|
19 | + array ( |
|
20 | + ), |
|
21 | + 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
|
22 | 22 | ), |
23 | 23 | 'ayecode/invoicing' => |
24 | 24 | array ( |
25 | - 'pretty_version' => 'dev-master', |
|
26 | - 'version' => 'dev-master', |
|
27 | - 'aliases' => |
|
28 | - array ( |
|
29 | - ), |
|
30 | - 'reference' => '58e08ab4fbfabf9d48bdecf0dce878830040d4ea', |
|
25 | + 'pretty_version' => 'dev-master', |
|
26 | + 'version' => 'dev-master', |
|
27 | + 'aliases' => |
|
28 | + array ( |
|
29 | + ), |
|
30 | + 'reference' => '58e08ab4fbfabf9d48bdecf0dce878830040d4ea', |
|
31 | 31 | ), |
32 | 32 | 'ayecode/wp-ayecode-ui' => |
33 | 33 | array ( |
34 | - 'pretty_version' => '0.1.35', |
|
35 | - 'version' => '0.1.35.0', |
|
36 | - 'aliases' => |
|
37 | - array ( |
|
38 | - ), |
|
39 | - 'reference' => 'e5d7955f648c6b350a8fe72e0110b8d78645c60f', |
|
34 | + 'pretty_version' => '0.1.35', |
|
35 | + 'version' => '0.1.35.0', |
|
36 | + 'aliases' => |
|
37 | + array ( |
|
38 | + ), |
|
39 | + 'reference' => 'e5d7955f648c6b350a8fe72e0110b8d78645c60f', |
|
40 | 40 | ), |
41 | 41 | 'ayecode/wp-font-awesome-settings' => |
42 | 42 | array ( |
43 | - 'pretty_version' => '1.0.12', |
|
44 | - 'version' => '1.0.12.0', |
|
45 | - 'aliases' => |
|
46 | - array ( |
|
47 | - ), |
|
48 | - 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
|
43 | + 'pretty_version' => '1.0.12', |
|
44 | + 'version' => '1.0.12.0', |
|
45 | + 'aliases' => |
|
46 | + array ( |
|
47 | + ), |
|
48 | + 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
|
49 | 49 | ), |
50 | 50 | 'ayecode/wp-super-duper' => |
51 | 51 | array ( |
52 | - 'pretty_version' => '1.0.22', |
|
53 | - 'version' => '1.0.22.0', |
|
54 | - 'aliases' => |
|
55 | - array ( |
|
56 | - ), |
|
57 | - 'reference' => '42b638502c9e4be0877f27903df7c7ed2080bdac', |
|
52 | + 'pretty_version' => '1.0.22', |
|
53 | + 'version' => '1.0.22.0', |
|
54 | + 'aliases' => |
|
55 | + array ( |
|
56 | + ), |
|
57 | + 'reference' => '42b638502c9e4be0877f27903df7c7ed2080bdac', |
|
58 | 58 | ), |
59 | 59 | 'composer/installers' => |
60 | 60 | array ( |
61 | - 'pretty_version' => 'v1.9.0', |
|
62 | - 'version' => '1.9.0.0', |
|
63 | - 'aliases' => |
|
64 | - array ( |
|
65 | - ), |
|
66 | - 'reference' => 'b93bcf0fa1fccb0b7d176b0967d969691cd74cca', |
|
61 | + 'pretty_version' => 'v1.9.0', |
|
62 | + 'version' => '1.9.0.0', |
|
63 | + 'aliases' => |
|
64 | + array ( |
|
65 | + ), |
|
66 | + 'reference' => 'b93bcf0fa1fccb0b7d176b0967d969691cd74cca', |
|
67 | 67 | ), |
68 | 68 | 'maxmind-db/reader' => |
69 | 69 | array ( |
70 | - 'pretty_version' => 'v1.6.0', |
|
71 | - 'version' => '1.6.0.0', |
|
72 | - 'aliases' => |
|
73 | - array ( |
|
74 | - ), |
|
75 | - 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
|
70 | + 'pretty_version' => 'v1.6.0', |
|
71 | + 'version' => '1.6.0.0', |
|
72 | + 'aliases' => |
|
73 | + array ( |
|
74 | + ), |
|
75 | + 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
|
76 | 76 | ), |
77 | 77 | 'roundcube/plugin-installer' => |
78 | 78 | array ( |
79 | - 'replaced' => |
|
80 | - array ( |
|
79 | + 'replaced' => |
|
80 | + array ( |
|
81 | 81 | 0 => '*', |
82 | - ), |
|
82 | + ), |
|
83 | 83 | ), |
84 | 84 | 'shama/baton' => |
85 | 85 | array ( |
86 | - 'replaced' => |
|
87 | - array ( |
|
86 | + 'replaced' => |
|
87 | + array ( |
|
88 | 88 | 0 => '*', |
89 | - ), |
|
89 | + ), |
|
90 | + ), |
|
90 | 91 | ), |
91 | - ), |
|
92 | 92 | ); |
@@ -1,90 +1,90 @@ |
||
1 | -<?php return array ( |
|
1 | +<?php return array( |
|
2 | 2 | 'root' => |
3 | - array ( |
|
3 | + array( |
|
4 | 4 | 'pretty_version' => 'dev-master', |
5 | 5 | 'version' => 'dev-master', |
6 | 6 | 'aliases' => |
7 | - array ( |
|
7 | + array( |
|
8 | 8 | ), |
9 | 9 | 'reference' => '58e08ab4fbfabf9d48bdecf0dce878830040d4ea', |
10 | 10 | 'name' => 'ayecode/invoicing', |
11 | 11 | ), |
12 | 12 | 'versions' => |
13 | - array ( |
|
13 | + array( |
|
14 | 14 | 'ayecode/ayecode-connect-helper' => |
15 | - array ( |
|
15 | + array( |
|
16 | 16 | 'pretty_version' => '1.0.3', |
17 | 17 | 'version' => '1.0.3.0', |
18 | 18 | 'aliases' => |
19 | - array ( |
|
19 | + array( |
|
20 | 20 | ), |
21 | 21 | 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
22 | 22 | ), |
23 | 23 | 'ayecode/invoicing' => |
24 | - array ( |
|
24 | + array( |
|
25 | 25 | 'pretty_version' => 'dev-master', |
26 | 26 | 'version' => 'dev-master', |
27 | 27 | 'aliases' => |
28 | - array ( |
|
28 | + array( |
|
29 | 29 | ), |
30 | 30 | 'reference' => '58e08ab4fbfabf9d48bdecf0dce878830040d4ea', |
31 | 31 | ), |
32 | 32 | 'ayecode/wp-ayecode-ui' => |
33 | - array ( |
|
33 | + array( |
|
34 | 34 | 'pretty_version' => '0.1.35', |
35 | 35 | 'version' => '0.1.35.0', |
36 | 36 | 'aliases' => |
37 | - array ( |
|
37 | + array( |
|
38 | 38 | ), |
39 | 39 | 'reference' => 'e5d7955f648c6b350a8fe72e0110b8d78645c60f', |
40 | 40 | ), |
41 | 41 | 'ayecode/wp-font-awesome-settings' => |
42 | - array ( |
|
42 | + array( |
|
43 | 43 | 'pretty_version' => '1.0.12', |
44 | 44 | 'version' => '1.0.12.0', |
45 | 45 | 'aliases' => |
46 | - array ( |
|
46 | + array( |
|
47 | 47 | ), |
48 | 48 | 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
49 | 49 | ), |
50 | 50 | 'ayecode/wp-super-duper' => |
51 | - array ( |
|
51 | + array( |
|
52 | 52 | 'pretty_version' => '1.0.22', |
53 | 53 | 'version' => '1.0.22.0', |
54 | 54 | 'aliases' => |
55 | - array ( |
|
55 | + array( |
|
56 | 56 | ), |
57 | 57 | 'reference' => '42b638502c9e4be0877f27903df7c7ed2080bdac', |
58 | 58 | ), |
59 | 59 | 'composer/installers' => |
60 | - array ( |
|
60 | + array( |
|
61 | 61 | 'pretty_version' => 'v1.9.0', |
62 | 62 | 'version' => '1.9.0.0', |
63 | 63 | 'aliases' => |
64 | - array ( |
|
64 | + array( |
|
65 | 65 | ), |
66 | 66 | 'reference' => 'b93bcf0fa1fccb0b7d176b0967d969691cd74cca', |
67 | 67 | ), |
68 | 68 | 'maxmind-db/reader' => |
69 | - array ( |
|
69 | + array( |
|
70 | 70 | 'pretty_version' => 'v1.6.0', |
71 | 71 | 'version' => '1.6.0.0', |
72 | 72 | 'aliases' => |
73 | - array ( |
|
73 | + array( |
|
74 | 74 | ), |
75 | 75 | 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
76 | 76 | ), |
77 | 77 | 'roundcube/plugin-installer' => |
78 | - array ( |
|
78 | + array( |
|
79 | 79 | 'replaced' => |
80 | - array ( |
|
80 | + array( |
|
81 | 81 | 0 => '*', |
82 | 82 | ), |
83 | 83 | ), |
84 | 84 | 'shama/baton' => |
85 | - array ( |
|
85 | + array( |
|
86 | 86 | 'replaced' => |
87 | - array ( |
|
87 | + array( |
|
88 | 88 | 0 => '*', |
89 | 89 | ), |
90 | 90 | ), |
@@ -5,7 +5,7 @@ |
||
5 | 5 | $issues = array(); |
6 | 6 | |
7 | 7 | if (!(PHP_VERSION_ID >= 50600)) { |
8 | - $issues[] = 'Your Composer dependencies require a PHP version ">= 5.6.0". You are running ' . PHP_VERSION . '.'; |
|
8 | + $issues[] = 'Your Composer dependencies require a PHP version ">= 5.6.0". You are running ' . PHP_VERSION . '.'; |
|
9 | 9 | } |
10 | 10 | |
11 | 11 | if ($issues) { |
@@ -6,34 +6,34 @@ discard block |
||
6 | 6 | |
7 | 7 | class ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5 |
8 | 8 | { |
9 | - public static $files = array ( |
|
9 | + public static $files = array( |
|
10 | 10 | 'e8d544c98e79f913e13eae1306ab635e' => __DIR__ . '/..' . '/ayecode/wp-ayecode-ui/ayecode-ui-loader.php', |
11 | 11 | '24583d3588ebda5228dd453cfaa070da' => __DIR__ . '/..' . '/ayecode/wp-font-awesome-settings/wp-font-awesome-settings.php', |
12 | 12 | ); |
13 | 13 | |
14 | - public static $prefixLengthsPsr4 = array ( |
|
14 | + public static $prefixLengthsPsr4 = array( |
|
15 | 15 | 'M' => |
16 | - array ( |
|
16 | + array( |
|
17 | 17 | 'MaxMind\\Db\\' => 11, |
18 | 18 | ), |
19 | 19 | 'C' => |
20 | - array ( |
|
20 | + array( |
|
21 | 21 | 'Composer\\Installers\\' => 20, |
22 | 22 | ), |
23 | 23 | ); |
24 | 24 | |
25 | - public static $prefixDirsPsr4 = array ( |
|
25 | + public static $prefixDirsPsr4 = array( |
|
26 | 26 | 'MaxMind\\Db\\' => |
27 | - array ( |
|
27 | + array( |
|
28 | 28 | 0 => __DIR__ . '/..' . '/maxmind-db/reader/src/MaxMind/Db', |
29 | 29 | ), |
30 | 30 | 'Composer\\Installers\\' => |
31 | - array ( |
|
31 | + array( |
|
32 | 32 | 0 => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers', |
33 | 33 | ), |
34 | 34 | ); |
35 | 35 | |
36 | - public static $classMap = array ( |
|
36 | + public static $classMap = array( |
|
37 | 37 | 'AyeCode_Connect_Helper' => __DIR__ . '/..' . '/ayecode/ayecode-connect-helper/ayecode-connect-helper.php', |
38 | 38 | 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', |
39 | 39 | 'WP_Super_Duper' => __DIR__ . '/..' . '/ayecode/wp-super-duper/wp-super-duper.php', |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | public static function getInitializer(ClassLoader $loader) |
43 | 43 | { |
44 | - return \Closure::bind(function () use ($loader) { |
|
44 | + return \Closure::bind(function() use ($loader) { |
|
45 | 45 | $loader->prefixLengthsPsr4 = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$prefixLengthsPsr4; |
46 | 46 | $loader->prefixDirsPsr4 = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$prefixDirsPsr4; |
47 | 47 | $loader->classMap = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$classMap; |