@@ -7,15 +7,15 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
10 | +if (!defined('WPINC')) { |
|
11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | |
15 | 15 | function wpinv_get_default_country() { |
16 | - $country = wpinv_get_option( 'default_country', 'UK' ); |
|
16 | + $country = wpinv_get_option('default_country', 'UK'); |
|
17 | 17 | |
18 | - return apply_filters( 'wpinv_default_country', $country ); |
|
18 | + return apply_filters('wpinv_default_country', $country); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -24,59 +24,59 @@ discard block |
||
24 | 24 | * @param string $country The country code to sanitize |
25 | 25 | * @return array |
26 | 26 | */ |
27 | -function wpinv_sanitize_country( $country ) { |
|
27 | +function wpinv_sanitize_country($country) { |
|
28 | 28 | |
29 | 29 | // Enure the country is specified |
30 | - if ( empty( $country ) ) { |
|
30 | + if (empty($country)) { |
|
31 | 31 | $country = wpinv_get_default_country(); |
32 | 32 | } |
33 | - return trim( wpinv_utf8_strtoupper( $country ) ); |
|
33 | + return trim(wpinv_utf8_strtoupper($country)); |
|
34 | 34 | |
35 | 35 | } |
36 | 36 | |
37 | -function wpinv_is_base_country( $country ) { |
|
37 | +function wpinv_is_base_country($country) { |
|
38 | 38 | $base_country = wpinv_get_default_country(); |
39 | 39 | |
40 | - if ( $base_country === 'UK' ) { |
|
40 | + if ($base_country === 'UK') { |
|
41 | 41 | $base_country = 'GB'; |
42 | 42 | } |
43 | - if ( $country == 'UK' ) { |
|
43 | + if ($country == 'UK') { |
|
44 | 44 | $country = 'GB'; |
45 | 45 | } |
46 | 46 | |
47 | - return ( $country && $country === $base_country ) ? true : false; |
|
47 | + return ($country && $country === $base_country) ? true : false; |
|
48 | 48 | } |
49 | 49 | |
50 | -function wpinv_country_name( $country_code = '' ) { |
|
50 | +function wpinv_country_name($country_code = '') { |
|
51 | 51 | $countries = wpinv_get_country_list(); |
52 | 52 | $country_code = $country_code == 'UK' ? 'GB' : $country_code; |
53 | - $country = isset( $countries[$country_code] ) ? $countries[$country_code] : $country_code; |
|
53 | + $country = isset($countries[$country_code]) ? $countries[$country_code] : $country_code; |
|
54 | 54 | |
55 | - return apply_filters( 'wpinv_country_name', $country, $country_code ); |
|
55 | + return apply_filters('wpinv_country_name', $country, $country_code); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | function wpinv_get_default_state() { |
59 | - $state = wpinv_get_option( 'default_state', false ); |
|
59 | + $state = wpinv_get_option('default_state', false); |
|
60 | 60 | |
61 | - return apply_filters( 'wpinv_default_state', $state ); |
|
61 | + return apply_filters('wpinv_default_state', $state); |
|
62 | 62 | } |
63 | 63 | |
64 | -function wpinv_state_name( $state_code = '', $country_code = '' ) { |
|
64 | +function wpinv_state_name($state_code = '', $country_code = '') { |
|
65 | 65 | $state = $state_code; |
66 | 66 | |
67 | - if ( !empty( $country_code ) ) { |
|
68 | - $states = wpinv_get_country_states( $country_code ); |
|
67 | + if (!empty($country_code)) { |
|
68 | + $states = wpinv_get_country_states($country_code); |
|
69 | 69 | |
70 | - $state = !empty( $states ) && isset( $states[$state_code] ) ? $states[$state_code] : $state; |
|
70 | + $state = !empty($states) && isset($states[$state_code]) ? $states[$state_code] : $state; |
|
71 | 71 | } |
72 | 72 | |
73 | - return apply_filters( 'wpinv_state_name', $state, $state_code, $country_code ); |
|
73 | + return apply_filters('wpinv_state_name', $state, $state_code, $country_code); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | function wpinv_store_address() { |
77 | - $address = wpinv_get_option( 'store_address', '' ); |
|
77 | + $address = wpinv_get_option('store_address', ''); |
|
78 | 78 | |
79 | - return apply_filters( 'wpinv_store_address', $address ); |
|
79 | + return apply_filters('wpinv_store_address', $address); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -84,24 +84,24 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @param WPInv_Invoice $invoice |
86 | 86 | */ |
87 | -function getpaid_maybe_add_default_address( &$invoice ) { |
|
87 | +function getpaid_maybe_add_default_address(&$invoice) { |
|
88 | 88 | |
89 | 89 | $user_id = $invoice->get_user_id(); |
90 | 90 | |
91 | 91 | // Abort if the invoice belongs to no one. |
92 | - if ( empty( $user_id ) ) { |
|
92 | + if (empty($user_id)) { |
|
93 | 93 | return; |
94 | 94 | } |
95 | 95 | |
96 | 96 | // Fill in defaults whenever necessary. |
97 | - foreach ( wpinv_get_user_address( $user_id ) as $key => $value ) { |
|
97 | + foreach (wpinv_get_user_address($user_id) as $key => $value) { |
|
98 | 98 | |
99 | - if ( is_callable( $invoice, "get_$key" ) ) { |
|
100 | - $current = call_user_func( array( $invoice, "get_$key" ) ); |
|
99 | + if (is_callable($invoice, "get_$key")) { |
|
100 | + $current = call_user_func(array($invoice, "get_$key")); |
|
101 | 101 | |
102 | - if ( empty( $current ) ) { |
|
102 | + if (empty($current)) { |
|
103 | 103 | $method = "set_$key"; |
104 | - $invoice->$method( $value ); |
|
104 | + $invoice->$method($value); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | } |
@@ -140,24 +140,24 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @param WPInv_Invoice $invoice |
142 | 142 | */ |
143 | -function getpaid_save_invoice_user_address( $invoice ) { |
|
143 | +function getpaid_save_invoice_user_address($invoice) { |
|
144 | 144 | |
145 | 145 | // Retrieve the invoice. |
146 | - $invoice = wpinv_get_invoice( $invoice ); |
|
146 | + $invoice = wpinv_get_invoice($invoice); |
|
147 | 147 | |
148 | 148 | // Abort if it does not exist. |
149 | - if ( empty( $invoice ) ) { |
|
149 | + if (empty($invoice)) { |
|
150 | 150 | return; |
151 | 151 | } |
152 | 152 | |
153 | - foreach ( getpaid_user_address_fields() as $field ) { |
|
153 | + foreach (getpaid_user_address_fields() as $field) { |
|
154 | 154 | |
155 | - if ( is_callable( array( $invoice, "get_$field" ) ) ) { |
|
156 | - $value = call_user_func( array( $invoice, "get_$field" ) ); |
|
155 | + if (is_callable(array($invoice, "get_$field"))) { |
|
156 | + $value = call_user_func(array($invoice, "get_$field")); |
|
157 | 157 | |
158 | 158 | // Only save if it is not empty. |
159 | - if ( ! empty( $value ) ) { |
|
160 | - update_user_meta( $invoice->get_user_id(), '_wpinv_' . $field, $value ); |
|
159 | + if (!empty($value)) { |
|
160 | + update_user_meta($invoice->get_user_id(), '_wpinv_' . $field, $value); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | } |
@@ -165,8 +165,8 @@ discard block |
||
165 | 165 | } |
166 | 166 | |
167 | 167 | } |
168 | -add_action( 'getpaid_new_invoice', 'getpaid_save_invoice_user_address' ); |
|
169 | -add_action( 'getpaid_update_invoice', 'getpaid_save_invoice_user_address' ); |
|
168 | +add_action('getpaid_new_invoice', 'getpaid_save_invoice_user_address'); |
|
169 | +add_action('getpaid_update_invoice', 'getpaid_save_invoice_user_address'); |
|
170 | 170 | |
171 | 171 | /** |
172 | 172 | * Retrieves a saved user address. |
@@ -175,14 +175,14 @@ discard block |
||
175 | 175 | * @param bool $with_default Whether or not we should use the default country and state. |
176 | 176 | * @return array |
177 | 177 | */ |
178 | -function wpinv_get_user_address( $user_id = 0, $with_default = true ) { |
|
178 | +function wpinv_get_user_address($user_id = 0, $with_default = true) { |
|
179 | 179 | |
180 | 180 | // Prepare the user id. |
181 | - $user_id = empty( $user_id ) ? get_current_user_id() : $user_id; |
|
182 | - $user_info = get_userdata( $user_id ); |
|
181 | + $user_id = empty($user_id) ? get_current_user_id() : $user_id; |
|
182 | + $user_info = get_userdata($user_id); |
|
183 | 183 | |
184 | 184 | // Abort if non exists. |
185 | - if ( empty( $user_info ) ) { |
|
185 | + if (empty($user_info)) { |
|
186 | 186 | return array(); |
187 | 187 | } |
188 | 188 | |
@@ -192,27 +192,27 @@ discard block |
||
192 | 192 | 'email' => $user_info->user_email, |
193 | 193 | ); |
194 | 194 | |
195 | - foreach ( getpaid_user_address_fields() as $field ) { |
|
196 | - $address[$field] = getpaid_get_user_address_field( $user_id, $field ); |
|
195 | + foreach (getpaid_user_address_fields() as $field) { |
|
196 | + $address[$field] = getpaid_get_user_address_field($user_id, $field); |
|
197 | 197 | } |
198 | 198 | |
199 | - if ( ! $with_default ) { |
|
199 | + if (!$with_default) { |
|
200 | 200 | return $address; |
201 | 201 | } |
202 | 202 | |
203 | - if ( isset( $address['first_name'] ) && empty( $address['first_name'] ) ) { |
|
203 | + if (isset($address['first_name']) && empty($address['first_name'])) { |
|
204 | 204 | $address['first_name'] = $user_info->first_name; |
205 | 205 | } |
206 | 206 | |
207 | - if ( isset( $address['last_name'] ) && empty( $address['last_name'] ) ) { |
|
207 | + if (isset($address['last_name']) && empty($address['last_name'])) { |
|
208 | 208 | $address['last_name'] = $user_info->last_name; |
209 | 209 | } |
210 | 210 | |
211 | - if ( isset( $address['state'] ) && empty( $address['state'] ) ) { |
|
211 | + if (isset($address['state']) && empty($address['state'])) { |
|
212 | 212 | $address['state'] = wpinv_get_default_state(); |
213 | 213 | } |
214 | 214 | |
215 | - if ( isset( $address['country'] ) && empty( $address['country'] ) ) { |
|
215 | + if (isset($address['country']) && empty($address['country'])) { |
|
216 | 216 | $address['country'] = wpinv_get_default_country(); |
217 | 217 | } |
218 | 218 | |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | * @param string $field The field to use. |
227 | 227 | * @return string|null |
228 | 228 | */ |
229 | -function getpaid_get_user_address_field( $user_id, $field ) { |
|
229 | +function getpaid_get_user_address_field($user_id, $field) { |
|
230 | 230 | |
231 | 231 | $prefixes = array( |
232 | 232 | '_wpinv_', |
@@ -234,15 +234,15 @@ discard block |
||
234 | 234 | '' |
235 | 235 | ); |
236 | 236 | |
237 | - foreach ( $prefixes as $prefix ) { |
|
237 | + foreach ($prefixes as $prefix) { |
|
238 | 238 | |
239 | 239 | // Meta table. |
240 | - $value = get_user_meta( $user_id, $prefix . $field, true ); |
|
240 | + $value = get_user_meta($user_id, $prefix . $field, true); |
|
241 | 241 | |
242 | 242 | // UWP table. |
243 | - $value = ( empty( $value ) && function_exists( 'uwp_get_usermeta' ) ) ? uwp_get_usermeta( $user_id, $prefix . $field ) : $value; |
|
243 | + $value = (empty($value) && function_exists('uwp_get_usermeta')) ? uwp_get_usermeta($user_id, $prefix . $field) : $value; |
|
244 | 244 | |
245 | - if ( ! empty( $value ) ) { |
|
245 | + if (!empty($value)) { |
|
246 | 246 | return $value; |
247 | 247 | } |
248 | 248 | |
@@ -259,16 +259,16 @@ discard block |
||
259 | 259 | * @param string $return What to return. |
260 | 260 | * @return array |
261 | 261 | */ |
262 | -function wpinv_get_continents( $return = 'all' ) { |
|
262 | +function wpinv_get_continents($return = 'all') { |
|
263 | 263 | |
264 | - $continents = wpinv_get_data( 'continents' ); |
|
264 | + $continents = wpinv_get_data('continents'); |
|
265 | 265 | |
266 | - switch( $return ) { |
|
266 | + switch ($return) { |
|
267 | 267 | case 'name' : |
268 | - return wp_list_pluck( $continents, 'name' ); |
|
268 | + return wp_list_pluck($continents, 'name'); |
|
269 | 269 | break; |
270 | 270 | case 'countries' : |
271 | - return wp_list_pluck( $continents, 'countries' ); |
|
271 | + return wp_list_pluck($continents, 'countries'); |
|
272 | 272 | break; |
273 | 273 | default : |
274 | 274 | return $continents; |
@@ -284,12 +284,12 @@ discard block |
||
284 | 284 | * @param string $country Country code. If no code is specified, defaults to the default country. |
285 | 285 | * @return string |
286 | 286 | */ |
287 | -function wpinv_get_continent_code_for_country( $country = false ) { |
|
287 | +function wpinv_get_continent_code_for_country($country = false) { |
|
288 | 288 | |
289 | - $country = wpinv_sanitize_country( $country ); |
|
289 | + $country = wpinv_sanitize_country($country); |
|
290 | 290 | |
291 | - foreach ( wpinv_get_continents( 'countries' ) as $continent_code => $countries ) { |
|
292 | - if ( false !== array_search( $country, $countries, true ) ) { |
|
291 | + foreach (wpinv_get_continents('countries') as $continent_code => $countries) { |
|
292 | + if (false !== array_search($country, $countries, true)) { |
|
293 | 293 | return $continent_code; |
294 | 294 | } |
295 | 295 | } |
@@ -305,13 +305,13 @@ discard block |
||
305 | 305 | * @param string $country Country code. If no code is specified, defaults to the default country. |
306 | 306 | * @return array |
307 | 307 | */ |
308 | -function wpinv_get_country_calling_code( $country = null) { |
|
308 | +function wpinv_get_country_calling_code($country = null) { |
|
309 | 309 | |
310 | - $country = wpinv_sanitize_country( $country ); |
|
311 | - $codes = wpinv_get_data( 'phone-codes' ); |
|
312 | - $code = isset( $codes[ $country ] ) ? $codes[ $country ] : ''; |
|
310 | + $country = wpinv_sanitize_country($country); |
|
311 | + $codes = wpinv_get_data('phone-codes'); |
|
312 | + $code = isset($codes[$country]) ? $codes[$country] : ''; |
|
313 | 313 | |
314 | - if ( is_array( $code ) ) { |
|
314 | + if (is_array($code)) { |
|
315 | 315 | return $code[0]; |
316 | 316 | } |
317 | 317 | return $code; |
@@ -324,8 +324,8 @@ discard block |
||
324 | 324 | * @param bool $first_empty Whether or not the first item in the list should be empty |
325 | 325 | * @return array |
326 | 326 | */ |
327 | -function wpinv_get_country_list( $first_empty = false ) { |
|
328 | - return wpinv_maybe_add_empty_option( apply_filters( 'wpinv_countries', wpinv_get_data( 'countries' ) ), $first_empty ); |
|
327 | +function wpinv_get_country_list($first_empty = false) { |
|
328 | + return wpinv_maybe_add_empty_option(apply_filters('wpinv_countries', wpinv_get_data('countries')), $first_empty); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | /** |
@@ -335,22 +335,22 @@ discard block |
||
335 | 335 | * @param bool $first_empty Whether or not the first item in the list should be empty |
336 | 336 | * @return array |
337 | 337 | */ |
338 | -function wpinv_get_country_states( $country = null, $first_empty = false ) { |
|
338 | +function wpinv_get_country_states($country = null, $first_empty = false) { |
|
339 | 339 | |
340 | 340 | // Prepare the country. |
341 | - $country = wpinv_sanitize_country( $country ); |
|
341 | + $country = wpinv_sanitize_country($country); |
|
342 | 342 | |
343 | 343 | // Fetch all states. |
344 | - $all_states = wpinv_get_data( 'states' ); |
|
344 | + $all_states = wpinv_get_data('states'); |
|
345 | 345 | |
346 | 346 | // Fetch the specified country's states. |
347 | - $states = isset( $all_states[ $country ] ) ? $all_states[ $country ] : array() ; |
|
348 | - $states = apply_filters( "wpinv_{$country}_states", $states ); |
|
349 | - $states = apply_filters( 'wpinv_country_states', $states, $country ); |
|
347 | + $states = isset($all_states[$country]) ? $all_states[$country] : array(); |
|
348 | + $states = apply_filters("wpinv_{$country}_states", $states); |
|
349 | + $states = apply_filters('wpinv_country_states', $states, $country); |
|
350 | 350 | |
351 | - asort( $states ); |
|
351 | + asort($states); |
|
352 | 352 | |
353 | - return wpinv_maybe_add_empty_option( $states, $first_empty ); |
|
353 | + return wpinv_maybe_add_empty_option($states, $first_empty); |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | /** |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | * @return array |
361 | 361 | */ |
362 | 362 | function wpinv_get_us_states_list() { |
363 | - return apply_filters( 'wpinv_usa_states', wpinv_get_country_states( 'US' ) ); |
|
363 | + return apply_filters('wpinv_usa_states', wpinv_get_country_states('US')); |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | /** |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | * @return array |
371 | 371 | */ |
372 | 372 | function wpinv_get_canada_states_list() { |
373 | - return apply_filters( 'wpinv_canada_provinces', wpinv_get_country_states( 'CA' ) ); |
|
373 | + return apply_filters('wpinv_canada_provinces', wpinv_get_country_states('CA')); |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | /** |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | * @return array |
381 | 381 | */ |
382 | 382 | function wpinv_get_australia_states_list() { |
383 | - return apply_filters( 'wpinv_australia_states', wpinv_get_country_states( 'AU' ) ); |
|
383 | + return apply_filters('wpinv_australia_states', wpinv_get_country_states('AU')); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | /** |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | * @return array |
391 | 391 | */ |
392 | 392 | function wpinv_get_bangladesh_states_list() { |
393 | - return apply_filters( 'wpinv_bangladesh_states', wpinv_get_country_states( 'BD' ) ); |
|
393 | + return apply_filters('wpinv_bangladesh_states', wpinv_get_country_states('BD')); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | /** |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | * @return array |
401 | 401 | */ |
402 | 402 | function wpinv_get_brazil_states_list() { |
403 | - return apply_filters( 'wpinv_brazil_states', wpinv_get_country_states( 'BR' ) ); |
|
403 | + return apply_filters('wpinv_brazil_states', wpinv_get_country_states('BR')); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | /** |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | * @return array |
411 | 411 | */ |
412 | 412 | function wpinv_get_bulgaria_states_list() { |
413 | - return apply_filters( 'wpinv_bulgaria_states', wpinv_get_country_states( 'BG' ) ); |
|
413 | + return apply_filters('wpinv_bulgaria_states', wpinv_get_country_states('BG')); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | /** |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | * @return array |
421 | 421 | */ |
422 | 422 | function wpinv_get_hong_kong_states_list() { |
423 | - return apply_filters( 'wpinv_hong_kong_states', wpinv_get_country_states( 'HK' ) ); |
|
423 | + return apply_filters('wpinv_hong_kong_states', wpinv_get_country_states('HK')); |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | /** |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | * @return array |
431 | 431 | */ |
432 | 432 | function wpinv_get_hungary_states_list() { |
433 | - return apply_filters( 'wpinv_hungary_states', wpinv_get_country_states( 'HU' ) ); |
|
433 | + return apply_filters('wpinv_hungary_states', wpinv_get_country_states('HU')); |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | /** |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | * @return array |
441 | 441 | */ |
442 | 442 | function wpinv_get_japan_states_list() { |
443 | - return apply_filters( 'wpinv_japan_states', wpinv_get_country_states( 'JP' ) ); |
|
443 | + return apply_filters('wpinv_japan_states', wpinv_get_country_states('JP')); |
|
444 | 444 | } |
445 | 445 | |
446 | 446 | /** |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | * @return array |
451 | 451 | */ |
452 | 452 | function wpinv_get_china_states_list() { |
453 | - return apply_filters( 'wpinv_china_states', wpinv_get_country_states( 'CN' ) ); |
|
453 | + return apply_filters('wpinv_china_states', wpinv_get_country_states('CN')); |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | /** |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | * @return array |
461 | 461 | */ |
462 | 462 | function wpinv_get_new_zealand_states_list() { |
463 | - return apply_filters( 'wpinv_new_zealand_states', wpinv_get_country_states( 'NZ' ) ); |
|
463 | + return apply_filters('wpinv_new_zealand_states', wpinv_get_country_states('NZ')); |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | /** |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | * @return array |
471 | 471 | */ |
472 | 472 | function wpinv_get_peru_states_list() { |
473 | - return apply_filters( 'wpinv_peru_states', wpinv_get_country_states( 'PE' ) ); |
|
473 | + return apply_filters('wpinv_peru_states', wpinv_get_country_states('PE')); |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | /** |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | * @return array |
481 | 481 | */ |
482 | 482 | function wpinv_get_indonesia_states_list() { |
483 | - return apply_filters( 'wpinv_indonesia_states', wpinv_get_country_states( 'ID' ) ); |
|
483 | + return apply_filters('wpinv_indonesia_states', wpinv_get_country_states('ID')); |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | /** |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | * @return array |
491 | 491 | */ |
492 | 492 | function wpinv_get_india_states_list() { |
493 | - return apply_filters( 'wpinv_india_states', wpinv_get_country_states( 'IN' ) ); |
|
493 | + return apply_filters('wpinv_india_states', wpinv_get_country_states('IN')); |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | /** |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | * @return array |
501 | 501 | */ |
502 | 502 | function wpinv_get_iran_states_list() { |
503 | - return apply_filters( 'wpinv_iran_states', wpinv_get_country_states( 'IR' ) ); |
|
503 | + return apply_filters('wpinv_iran_states', wpinv_get_country_states('IR')); |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | /** |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | * @return array |
511 | 511 | */ |
512 | 512 | function wpinv_get_italy_states_list() { |
513 | - return apply_filters( 'wpinv_italy_states', wpinv_get_country_states( 'IT' ) ); |
|
513 | + return apply_filters('wpinv_italy_states', wpinv_get_country_states('IT')); |
|
514 | 514 | } |
515 | 515 | |
516 | 516 | /** |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | * @return array |
521 | 521 | */ |
522 | 522 | function wpinv_get_malaysia_states_list() { |
523 | - return apply_filters( 'wpinv_malaysia_states', wpinv_get_country_states( 'MY' ) ); |
|
523 | + return apply_filters('wpinv_malaysia_states', wpinv_get_country_states('MY')); |
|
524 | 524 | } |
525 | 525 | |
526 | 526 | /** |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | * @return array |
531 | 531 | */ |
532 | 532 | function wpinv_get_mexico_states_list() { |
533 | - return apply_filters( 'wpinv_mexico_states', wpinv_get_country_states( 'MX' ) ); |
|
533 | + return apply_filters('wpinv_mexico_states', wpinv_get_country_states('MX')); |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | /** |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | * @return array |
541 | 541 | */ |
542 | 542 | function wpinv_get_nepal_states_list() { |
543 | - return apply_filters( 'wpinv_nepal_states', wpinv_get_country_states( 'NP' ) ); |
|
543 | + return apply_filters('wpinv_nepal_states', wpinv_get_country_states('NP')); |
|
544 | 544 | } |
545 | 545 | |
546 | 546 | /** |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | * @return array |
551 | 551 | */ |
552 | 552 | function wpinv_get_south_africa_states_list() { |
553 | - return apply_filters( 'wpinv_south_africa_states', wpinv_get_country_states( 'ZA' ) ); |
|
553 | + return apply_filters('wpinv_south_africa_states', wpinv_get_country_states('ZA')); |
|
554 | 554 | } |
555 | 555 | |
556 | 556 | /** |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | * @return array |
561 | 561 | */ |
562 | 562 | function wpinv_get_thailand_states_list() { |
563 | - return apply_filters( 'wpinv_thailand_states', wpinv_get_country_states( 'TH' ) ); |
|
563 | + return apply_filters('wpinv_thailand_states', wpinv_get_country_states('TH')); |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | /** |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | * @return array |
571 | 571 | */ |
572 | 572 | function wpinv_get_turkey_states_list() { |
573 | - return apply_filters( 'wpinv_turkey_states', wpinv_get_country_states( 'TR' ) ); |
|
573 | + return apply_filters('wpinv_turkey_states', wpinv_get_country_states('TR')); |
|
574 | 574 | } |
575 | 575 | |
576 | 576 | /** |
@@ -580,28 +580,28 @@ discard block |
||
580 | 580 | * @return array |
581 | 581 | */ |
582 | 582 | function wpinv_get_spain_states_list() { |
583 | - return apply_filters( 'wpinv_spain_states', wpinv_get_country_states( 'ES' ) ); |
|
583 | + return apply_filters('wpinv_spain_states', wpinv_get_country_states('ES')); |
|
584 | 584 | } |
585 | 585 | |
586 | 586 | function wpinv_get_states_field() { |
587 | - if( empty( $_POST['country'] ) ) { |
|
587 | + if (empty($_POST['country'])) { |
|
588 | 588 | $_POST['country'] = wpinv_get_default_country(); |
589 | 589 | } |
590 | - $states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) ); |
|
590 | + $states = wpinv_get_country_states(sanitize_text_field($_POST['country'])); |
|
591 | 591 | |
592 | - if( !empty( $states ) ) { |
|
593 | - $sanitized_field_name = sanitize_text_field( $_POST['field_name'] ); |
|
592 | + if (!empty($states)) { |
|
593 | + $sanitized_field_name = sanitize_text_field($_POST['field_name']); |
|
594 | 594 | |
595 | 595 | $args = array( |
596 | 596 | 'name' => $sanitized_field_name, |
597 | 597 | 'id' => $sanitized_field_name, |
598 | 598 | 'class' => $sanitized_field_name . 'custom-select wpinv-select wpi_select2', |
599 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
599 | + 'options' => array_merge(array('' => ''), $states), |
|
600 | 600 | 'show_option_all' => false, |
601 | 601 | 'show_option_none' => false |
602 | 602 | ); |
603 | 603 | |
604 | - $response = wpinv_html_select( $args ); |
|
604 | + $response = wpinv_html_select($args); |
|
605 | 605 | |
606 | 606 | } else { |
607 | 607 | $response = 'nostates'; |
@@ -610,10 +610,10 @@ discard block |
||
610 | 610 | return $response; |
611 | 611 | } |
612 | 612 | |
613 | -function wpinv_default_billing_country( $country = '', $user_id = 0 ) { |
|
614 | - $country = !empty( $country ) ? $country : wpinv_get_default_country(); |
|
613 | +function wpinv_default_billing_country($country = '', $user_id = 0) { |
|
614 | + $country = !empty($country) ? $country : wpinv_get_default_country(); |
|
615 | 615 | |
616 | - return apply_filters( 'wpinv_default_billing_country', $country, $user_id ); |
|
616 | + return apply_filters('wpinv_default_billing_country', $country, $user_id); |
|
617 | 617 | } |
618 | 618 | |
619 | 619 | /** |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | */ |
626 | 626 | function wpinv_get_address_formats() { |
627 | 627 | |
628 | - return apply_filters( 'wpinv_localisation_address_formats', |
|
628 | + return apply_filters('wpinv_localisation_address_formats', |
|
629 | 629 | array( |
630 | 630 | 'default' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}\n{{zip}}\n{{country}}", |
631 | 631 | 'AU' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}} {{zip}}\n{{country}}", |
@@ -674,9 +674,9 @@ discard block |
||
674 | 674 | * @see `wpinv_get_invoice_address_replacements` |
675 | 675 | * @return string |
676 | 676 | */ |
677 | -function wpinv_get_full_address_format( $country = false) { |
|
677 | +function wpinv_get_full_address_format($country = false) { |
|
678 | 678 | |
679 | - if( empty( $country ) ) { |
|
679 | + if (empty($country)) { |
|
680 | 680 | $country = wpinv_get_default_country(); |
681 | 681 | } |
682 | 682 | |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | $formats = wpinv_get_address_formats(); |
685 | 685 | |
686 | 686 | // Get format for the specified country. |
687 | - $format = ( $country && isset( $formats[ $country ] ) ) ? $formats[ $country ] : $formats['default']; |
|
687 | + $format = ($country && isset($formats[$country])) ? $formats[$country] : $formats['default']; |
|
688 | 688 | |
689 | 689 | /** |
690 | 690 | * Filters the address format to use on Invoices. |
@@ -696,7 +696,7 @@ discard block |
||
696 | 696 | * @param string $format The address format to use. |
697 | 697 | * @param string $country The country who's address format is being retrieved. |
698 | 698 | */ |
699 | - return apply_filters( 'wpinv_get_full_address_format', $format, $country ); |
|
699 | + return apply_filters('wpinv_get_full_address_format', $format, $country); |
|
700 | 700 | } |
701 | 701 | |
702 | 702 | /** |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | * @param array $billing_details customer's billing details |
708 | 708 | * @return array |
709 | 709 | */ |
710 | -function wpinv_get_invoice_address_replacements( $billing_details ) { |
|
710 | +function wpinv_get_invoice_address_replacements($billing_details) { |
|
711 | 711 | |
712 | 712 | $default_args = array( |
713 | 713 | 'address' => '', |
@@ -720,22 +720,22 @@ discard block |
||
720 | 720 | 'company' => '', |
721 | 721 | ); |
722 | 722 | |
723 | - $args = map_deep( wp_parse_args( $billing_details, $default_args ), 'trim' ); |
|
723 | + $args = map_deep(wp_parse_args($billing_details, $default_args), 'trim'); |
|
724 | 724 | $state = $args['state']; |
725 | 725 | $country = $args['country']; |
726 | 726 | |
727 | 727 | // Handle full country name. |
728 | - $full_country = empty( $country ) ? $country : wpinv_country_name( $country ); |
|
728 | + $full_country = empty($country) ? $country : wpinv_country_name($country); |
|
729 | 729 | |
730 | 730 | // Handle full state name. |
731 | - $full_state = ( $country && $state ) ? wpinv_state_name( $state, $country ) : $state; |
|
731 | + $full_state = ($country && $state) ? wpinv_state_name($state, $country) : $state; |
|
732 | 732 | |
733 | 733 | $args['postcode'] = $args['zip']; |
734 | 734 | $args['name'] = $args['first_name'] . ' ' . $args['last_name']; |
735 | 735 | $args['state'] = $full_state; |
736 | 736 | $args['state_code'] = $state; |
737 | 737 | $args['country'] = $full_country; |
738 | - $args['country_code']= $country; |
|
738 | + $args['country_code'] = $country; |
|
739 | 739 | |
740 | 740 | /** |
741 | 741 | * Filters the address format replacements to use on Invoices. |
@@ -746,14 +746,14 @@ discard block |
||
746 | 746 | * @param array $replacements The address replacements to use. |
747 | 747 | * @param array $billing_details The billing details to use. |
748 | 748 | */ |
749 | - $replacements = apply_filters( 'wpinv_get_invoice_address_replacements', $args, $billing_details ); |
|
749 | + $replacements = apply_filters('wpinv_get_invoice_address_replacements', $args, $billing_details); |
|
750 | 750 | |
751 | 751 | $return = array(); |
752 | 752 | |
753 | - foreach( $replacements as $key => $value ) { |
|
754 | - $value = is_scalar( $value ) ? trim( sanitize_text_field( $value ) ) : ''; |
|
753 | + foreach ($replacements as $key => $value) { |
|
754 | + $value = is_scalar($value) ? trim(sanitize_text_field($value)) : ''; |
|
755 | 755 | $return['{{' . $key . '}}'] = $value; |
756 | - $return['{{' . $key . '_upper}}'] = wpinv_utf8_strtoupper( $value ); |
|
756 | + $return['{{' . $key . '_upper}}'] = wpinv_utf8_strtoupper($value); |
|
757 | 757 | } |
758 | 758 | |
759 | 759 | return $return; |
@@ -767,6 +767,6 @@ discard block |
||
767 | 767 | * @since 1.0.14 |
768 | 768 | * @return string |
769 | 769 | */ |
770 | -function wpinv_trim_formatted_address_line( $line ) { |
|
771 | - return trim( $line, ', ' ); |
|
770 | +function wpinv_trim_formatted_address_line($line) { |
|
771 | + return trim($line, ', '); |
|
772 | 772 | } |
773 | 773 | \ No newline at end of file |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * WPInv_Ajax class. |
@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | * Hook in ajax handlers. |
18 | 18 | */ |
19 | 19 | public static function init() { |
20 | - add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 ); |
|
21 | - add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 ); |
|
20 | + add_action('init', array(__CLASS__, 'define_ajax'), 0); |
|
21 | + add_action('template_redirect', array(__CLASS__, 'do_wpinv_ajax'), 0); |
|
22 | 22 | self::add_ajax_events(); |
23 | 23 | } |
24 | 24 | |
@@ -27,11 +27,11 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public static function define_ajax() { |
29 | 29 | |
30 | - if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
31 | - getpaid_maybe_define_constant( 'DOING_AJAX', true ); |
|
32 | - getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true ); |
|
33 | - if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) { |
|
34 | - /** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 ); |
|
30 | + if (!empty($_GET['wpinv-ajax'])) { |
|
31 | + getpaid_maybe_define_constant('DOING_AJAX', true); |
|
32 | + getpaid_maybe_define_constant('WPInv_DOING_AJAX', true); |
|
33 | + if (!WP_DEBUG || (WP_DEBUG && !WP_DEBUG_DISPLAY)) { |
|
34 | + /** @scrutinizer ignore-unhandled */ @ini_set('display_errors', 0); |
|
35 | 35 | } |
36 | 36 | $GLOBALS['wpdb']->hide_errors(); |
37 | 37 | } |
@@ -44,13 +44,13 @@ discard block |
||
44 | 44 | * @since 1.0.18 |
45 | 45 | */ |
46 | 46 | private static function wpinv_ajax_headers() { |
47 | - if ( ! headers_sent() ) { |
|
47 | + if (!headers_sent()) { |
|
48 | 48 | send_origin_headers(); |
49 | 49 | send_nosniff_header(); |
50 | 50 | nocache_headers(); |
51 | - header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
52 | - header( 'X-Robots-Tag: noindex' ); |
|
53 | - status_header( 200 ); |
|
51 | + header('Content-Type: text/html; charset=' . get_option('blog_charset')); |
|
52 | + header('X-Robots-Tag: noindex'); |
|
53 | + status_header(200); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
@@ -60,16 +60,16 @@ discard block |
||
60 | 60 | public static function do_wpinv_ajax() { |
61 | 61 | global $wp_query; |
62 | 62 | |
63 | - if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
64 | - $wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) ); |
|
63 | + if (!empty($_GET['wpinv-ajax'])) { |
|
64 | + $wp_query->set('wpinv-ajax', sanitize_text_field(wp_unslash($_GET['wpinv-ajax']))); |
|
65 | 65 | } |
66 | 66 | |
67 | - $action = $wp_query->get( 'wpinv-ajax' ); |
|
67 | + $action = $wp_query->get('wpinv-ajax'); |
|
68 | 68 | |
69 | - if ( $action ) { |
|
69 | + if ($action) { |
|
70 | 70 | self::wpinv_ajax_headers(); |
71 | - $action = sanitize_text_field( $action ); |
|
72 | - do_action( 'wpinv_ajax_' . $action ); |
|
71 | + $action = sanitize_text_field($action); |
|
72 | + do_action('wpinv_ajax_' . $action); |
|
73 | 73 | wp_die(); |
74 | 74 | } |
75 | 75 | |
@@ -103,36 +103,36 @@ discard block |
||
103 | 103 | 'ip_geolocation' => true, |
104 | 104 | ); |
105 | 105 | |
106 | - foreach ( $ajax_events as $ajax_event => $nopriv ) { |
|
107 | - add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
108 | - add_action( 'wp_ajax_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
106 | + foreach ($ajax_events as $ajax_event => $nopriv) { |
|
107 | + add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
108 | + add_action('wp_ajax_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
109 | 109 | |
110 | - if ( $nopriv ) { |
|
111 | - add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
112 | - add_action( 'wp_ajax_nopriv_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
113 | - add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
110 | + if ($nopriv) { |
|
111 | + add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
112 | + add_action('wp_ajax_nopriv_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
113 | + add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
114 | 114 | } |
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
118 | 118 | public static function add_note() { |
119 | - check_ajax_referer( 'add-invoice-note', '_nonce' ); |
|
119 | + check_ajax_referer('add-invoice-note', '_nonce'); |
|
120 | 120 | |
121 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
121 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
122 | 122 | die(-1); |
123 | 123 | } |
124 | 124 | |
125 | - $post_id = absint( $_POST['post_id'] ); |
|
126 | - $note = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) ); |
|
127 | - $note_type = sanitize_text_field( $_POST['note_type'] ); |
|
125 | + $post_id = absint($_POST['post_id']); |
|
126 | + $note = wp_kses_post(trim(stripslashes($_POST['note']))); |
|
127 | + $note_type = sanitize_text_field($_POST['note_type']); |
|
128 | 128 | |
129 | 129 | $is_customer_note = $note_type == 'customer' ? 1 : 0; |
130 | 130 | |
131 | - if ( $post_id > 0 ) { |
|
132 | - $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note ); |
|
131 | + if ($post_id > 0) { |
|
132 | + $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note); |
|
133 | 133 | |
134 | - if ( $note_id > 0 && !is_wp_error( $note_id ) ) { |
|
135 | - wpinv_get_invoice_note_line_item( $note_id ); |
|
134 | + if ($note_id > 0 && !is_wp_error($note_id)) { |
|
135 | + wpinv_get_invoice_note_line_item($note_id); |
|
136 | 136 | } |
137 | 137 | } |
138 | 138 | |
@@ -140,16 +140,16 @@ discard block |
||
140 | 140 | } |
141 | 141 | |
142 | 142 | public static function delete_note() { |
143 | - check_ajax_referer( 'delete-invoice-note', '_nonce' ); |
|
143 | + check_ajax_referer('delete-invoice-note', '_nonce'); |
|
144 | 144 | |
145 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
145 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
146 | 146 | die(-1); |
147 | 147 | } |
148 | 148 | |
149 | - $note_id = (int)$_POST['note_id']; |
|
149 | + $note_id = (int) $_POST['note_id']; |
|
150 | 150 | |
151 | - if ( $note_id > 0 ) { |
|
152 | - wp_delete_comment( $note_id, true ); |
|
151 | + if ($note_id > 0) { |
|
152 | + wp_delete_comment($note_id, true); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | die(); |
@@ -167,34 +167,34 @@ discard block |
||
167 | 167 | public static function get_billing_details() { |
168 | 168 | |
169 | 169 | // Verify nonce. |
170 | - check_ajax_referer( 'wpinv-nonce' ); |
|
170 | + check_ajax_referer('wpinv-nonce'); |
|
171 | 171 | |
172 | 172 | // Can the user manage the plugin? |
173 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
173 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
174 | 174 | die(-1); |
175 | 175 | } |
176 | 176 | |
177 | 177 | // Do we have a user id? |
178 | 178 | $user_id = $_GET['user_id']; |
179 | 179 | |
180 | - if ( empty( $user_id ) || ! is_numeric( $user_id ) ) { |
|
180 | + if (empty($user_id) || !is_numeric($user_id)) { |
|
181 | 181 | die(-1); |
182 | 182 | } |
183 | 183 | |
184 | 184 | // Fetch the billing details. |
185 | - $billing_details = wpinv_get_user_address( $user_id ); |
|
186 | - $billing_details = apply_filters( 'wpinv_ajax_billing_details', $billing_details, $user_id ); |
|
185 | + $billing_details = wpinv_get_user_address($user_id); |
|
186 | + $billing_details = apply_filters('wpinv_ajax_billing_details', $billing_details, $user_id); |
|
187 | 187 | |
188 | 188 | // unset the user id and email. |
189 | - $to_ignore = array( 'user_id', 'email' ); |
|
189 | + $to_ignore = array('user_id', 'email'); |
|
190 | 190 | |
191 | - foreach ( $to_ignore as $key ) { |
|
192 | - if ( isset( $billing_details[ $key ] ) ) { |
|
193 | - unset( $billing_details[ $key ] ); |
|
191 | + foreach ($to_ignore as $key) { |
|
192 | + if (isset($billing_details[$key])) { |
|
193 | + unset($billing_details[$key]); |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
197 | - wp_send_json_success( $billing_details ); |
|
197 | + wp_send_json_success($billing_details); |
|
198 | 198 | |
199 | 199 | } |
200 | 200 | |
@@ -204,47 +204,47 @@ discard block |
||
204 | 204 | public static function check_new_user_email() { |
205 | 205 | |
206 | 206 | // Verify nonce. |
207 | - check_ajax_referer( 'wpinv-nonce' ); |
|
207 | + check_ajax_referer('wpinv-nonce'); |
|
208 | 208 | |
209 | 209 | // Can the user manage the plugin? |
210 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
210 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
211 | 211 | die(-1); |
212 | 212 | } |
213 | 213 | |
214 | 214 | // We need an email address. |
215 | - if ( empty( $_GET['email'] ) ) { |
|
216 | - _e( "Provide the new user's email address", 'invoicing' ); |
|
215 | + if (empty($_GET['email'])) { |
|
216 | + _e("Provide the new user's email address", 'invoicing'); |
|
217 | 217 | exit; |
218 | 218 | } |
219 | 219 | |
220 | 220 | // Ensure the email is valid. |
221 | - $email = sanitize_text_field( $_GET['email'] ); |
|
222 | - if ( ! is_email( $email ) ) { |
|
223 | - _e( 'Invalid email address', 'invoicing' ); |
|
221 | + $email = sanitize_text_field($_GET['email']); |
|
222 | + if (!is_email($email)) { |
|
223 | + _e('Invalid email address', 'invoicing'); |
|
224 | 224 | exit; |
225 | 225 | } |
226 | 226 | |
227 | 227 | // And it does not exist. |
228 | - if ( email_exists( $email ) ) { |
|
229 | - _e( 'A user with this email address already exists', 'invoicing' ); |
|
228 | + if (email_exists($email)) { |
|
229 | + _e('A user with this email address already exists', 'invoicing'); |
|
230 | 230 | exit; |
231 | 231 | } |
232 | 232 | |
233 | - wp_send_json_success( true ); |
|
233 | + wp_send_json_success(true); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | public static function run_tool() { |
237 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
238 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
237 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
238 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
239 | 239 | die(-1); |
240 | 240 | } |
241 | 241 | |
242 | - $tool = sanitize_text_field( $_POST['tool'] ); |
|
242 | + $tool = sanitize_text_field($_POST['tool']); |
|
243 | 243 | |
244 | - do_action( 'wpinv_run_tool' ); |
|
244 | + do_action('wpinv_run_tool'); |
|
245 | 245 | |
246 | - if ( !empty( $tool ) ) { |
|
247 | - do_action( 'wpinv_tool_' . $tool ); |
|
246 | + if (!empty($tool)) { |
|
247 | + do_action('wpinv_tool_' . $tool); |
|
248 | 248 | } |
249 | 249 | } |
250 | 250 | |
@@ -254,30 +254,30 @@ discard block |
||
254 | 254 | public static function get_payment_form() { |
255 | 255 | |
256 | 256 | // Check nonce. |
257 | - if ( ! isset( $_GET['nonce'] ) || ! wp_verify_nonce( $_GET['nonce'], 'getpaid_ajax_form' ) ) { |
|
258 | - _e( 'Error: Reload the page and try again.', 'invoicing' ); |
|
257 | + if (!isset($_GET['nonce']) || !wp_verify_nonce($_GET['nonce'], 'getpaid_ajax_form')) { |
|
258 | + _e('Error: Reload the page and try again.', 'invoicing'); |
|
259 | 259 | exit; |
260 | 260 | } |
261 | 261 | |
262 | 262 | // Is the request set up correctly? |
263 | - if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) { |
|
263 | + if (empty($_GET['form']) && empty($_GET['item'])) { |
|
264 | 264 | echo aui()->alert( |
265 | 265 | array( |
266 | 266 | 'type' => 'warning', |
267 | - 'content' => __( 'No payment form or item provided', 'invoicing' ), |
|
267 | + 'content' => __('No payment form or item provided', 'invoicing'), |
|
268 | 268 | ) |
269 | 269 | ); |
270 | 270 | exit; |
271 | 271 | } |
272 | 272 | |
273 | 273 | // Payment form or button? |
274 | - if ( ! empty( $_GET['form'] ) ) { |
|
275 | - getpaid_display_payment_form( $_GET['form'] ); |
|
276 | - } else if( ! empty( $_GET['invoice'] ) ) { |
|
277 | - echo getpaid_display_invoice_payment_form( $_GET['invoice'] ); |
|
274 | + if (!empty($_GET['form'])) { |
|
275 | + getpaid_display_payment_form($_GET['form']); |
|
276 | + } else if (!empty($_GET['invoice'])) { |
|
277 | + echo getpaid_display_invoice_payment_form($_GET['invoice']); |
|
278 | 278 | } else { |
279 | - $items = getpaid_convert_items_to_array( $_GET['item'] ); |
|
280 | - getpaid_display_item_payment_form( $items ); |
|
279 | + $items = getpaid_convert_items_to_array($_GET['item']); |
|
280 | + getpaid_display_item_payment_form($items); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | exit; |
@@ -292,16 +292,16 @@ discard block |
||
292 | 292 | public static function payment_form() { |
293 | 293 | |
294 | 294 | // Check nonce. |
295 | - check_ajax_referer( 'getpaid_form_nonce' ); |
|
295 | + check_ajax_referer('getpaid_form_nonce'); |
|
296 | 296 | |
297 | 297 | // ... form fields... |
298 | - if ( empty( $_POST['getpaid_payment_form_submission'] ) ) { |
|
299 | - _e( 'Error: Reload the page and try again.', 'invoicing' ); |
|
298 | + if (empty($_POST['getpaid_payment_form_submission'])) { |
|
299 | + _e('Error: Reload the page and try again.', 'invoicing'); |
|
300 | 300 | exit; |
301 | 301 | } |
302 | 302 | |
303 | 303 | // Process the payment form. |
304 | - $checkout = new GetPaid_Checkout( new GetPaid_Payment_Form_Submission() ); |
|
304 | + $checkout = new GetPaid_Checkout(new GetPaid_Payment_Form_Submission()); |
|
305 | 305 | $checkout->process_checkout(); |
306 | 306 | |
307 | 307 | exit; |
@@ -315,51 +315,51 @@ discard block |
||
315 | 315 | public static function get_payment_form_states_field() { |
316 | 316 | global $invoicing; |
317 | 317 | |
318 | - if ( empty( $_GET['country'] ) || empty( $_GET['form'] ) ) { |
|
318 | + if (empty($_GET['country']) || empty($_GET['form'])) { |
|
319 | 319 | exit; |
320 | 320 | } |
321 | 321 | |
322 | - $elements = $invoicing->form_elements->get_form_elements( $_GET['form'] ); |
|
322 | + $elements = $invoicing->form_elements->get_form_elements($_GET['form']); |
|
323 | 323 | |
324 | - if ( empty( $elements ) ) { |
|
324 | + if (empty($elements)) { |
|
325 | 325 | exit; |
326 | 326 | } |
327 | 327 | |
328 | 328 | $address_fields = array(); |
329 | - foreach ( $elements as $element ) { |
|
330 | - if ( 'address' === $element['type'] ) { |
|
329 | + foreach ($elements as $element) { |
|
330 | + if ('address' === $element['type']) { |
|
331 | 331 | $address_fields = $element; |
332 | 332 | break; |
333 | 333 | } |
334 | 334 | } |
335 | 335 | |
336 | - if ( empty( $address_fields ) ) { |
|
336 | + if (empty($address_fields)) { |
|
337 | 337 | exit; |
338 | 338 | } |
339 | 339 | |
340 | - foreach( $address_fields['fields'] as $address_field ) { |
|
340 | + foreach ($address_fields['fields'] as $address_field) { |
|
341 | 341 | |
342 | - if ( 'wpinv_state' == $address_field['name'] ) { |
|
342 | + if ('wpinv_state' == $address_field['name']) { |
|
343 | 343 | |
344 | 344 | $label = $address_field['label']; |
345 | 345 | |
346 | - if ( ! empty( $address_field['required'] ) ) { |
|
346 | + if (!empty($address_field['required'])) { |
|
347 | 347 | $label .= "<span class='text-danger'> *</span>"; |
348 | 348 | } |
349 | 349 | |
350 | - $states = wpinv_get_country_states( $_GET['country'] ); |
|
350 | + $states = wpinv_get_country_states($_GET['country']); |
|
351 | 351 | |
352 | - if ( ! empty( $states ) ) { |
|
352 | + if (!empty($states)) { |
|
353 | 353 | |
354 | 354 | $html = aui()->select( |
355 | 355 | array( |
356 | 356 | 'options' => $states, |
357 | - 'name' => esc_attr( $address_field['name'] ), |
|
358 | - 'id' => esc_attr( $address_field['name'] ), |
|
359 | - 'placeholder' => esc_attr( $address_field['placeholder'] ), |
|
357 | + 'name' => esc_attr($address_field['name']), |
|
358 | + 'id' => esc_attr($address_field['name']), |
|
359 | + 'placeholder' => esc_attr($address_field['placeholder']), |
|
360 | 360 | 'required' => (bool) $address_field['required'], |
361 | 361 | 'no_wrap' => true, |
362 | - 'label' => wp_kses_post( $label ), |
|
362 | + 'label' => wp_kses_post($label), |
|
363 | 363 | 'select2' => false, |
364 | 364 | ) |
365 | 365 | ); |
@@ -368,10 +368,10 @@ discard block |
||
368 | 368 | |
369 | 369 | $html = aui()->input( |
370 | 370 | array( |
371 | - 'name' => esc_attr( $address_field['name'] ), |
|
372 | - 'id' => esc_attr( $address_field['name'] ), |
|
371 | + 'name' => esc_attr($address_field['name']), |
|
372 | + 'id' => esc_attr($address_field['name']), |
|
373 | 373 | 'required' => (bool) $address_field['required'], |
374 | - 'label' => wp_kses_post( $label ), |
|
374 | + 'label' => wp_kses_post($label), |
|
375 | 375 | 'no_wrap' => true, |
376 | 376 | 'type' => 'text', |
377 | 377 | ) |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | |
380 | 380 | } |
381 | 381 | |
382 | - wp_send_json_success( str_replace( 'sr-only', '', $html ) ); |
|
382 | + wp_send_json_success(str_replace('sr-only', '', $html)); |
|
383 | 383 | exit; |
384 | 384 | |
385 | 385 | } |
@@ -395,56 +395,56 @@ discard block |
||
395 | 395 | public static function recalculate_invoice_totals() { |
396 | 396 | |
397 | 397 | // Verify nonce. |
398 | - check_ajax_referer( 'wpinv-nonce' ); |
|
398 | + check_ajax_referer('wpinv-nonce'); |
|
399 | 399 | |
400 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
400 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
401 | 401 | exit; |
402 | 402 | } |
403 | 403 | |
404 | 404 | // We need an invoice. |
405 | - if ( empty( $_POST['post_id'] ) ) { |
|
405 | + if (empty($_POST['post_id'])) { |
|
406 | 406 | exit; |
407 | 407 | } |
408 | 408 | |
409 | 409 | // Fetch the invoice. |
410 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
410 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
411 | 411 | |
412 | 412 | // Ensure it exists. |
413 | - if ( ! $invoice->get_id() ) { |
|
413 | + if (!$invoice->get_id()) { |
|
414 | 414 | exit; |
415 | 415 | } |
416 | 416 | |
417 | 417 | // Maybe set the country, state, currency. |
418 | - foreach ( array( 'country', 'state', 'currency' ) as $key ) { |
|
419 | - if ( isset( $_POST[ $key ] ) ) { |
|
418 | + foreach (array('country', 'state', 'currency') as $key) { |
|
419 | + if (isset($_POST[$key])) { |
|
420 | 420 | $method = "set_$key"; |
421 | - $invoice->$method( $_POST[ $key ] ); |
|
421 | + $invoice->$method($_POST[$key]); |
|
422 | 422 | } |
423 | 423 | } |
424 | 424 | |
425 | 425 | // Maybe disable taxes. |
426 | - $invoice->set_disable_taxes( ! empty( $_POST['taxes'] ) ); |
|
426 | + $invoice->set_disable_taxes(!empty($_POST['taxes'])); |
|
427 | 427 | |
428 | 428 | // Recalculate totals. |
429 | 429 | $invoice->recalculate_total(); |
430 | 430 | |
431 | - $total = wpinv_price( wpinv_format_amount( $invoice->get_total() ), $invoice->get_currency() ); |
|
431 | + $total = wpinv_price(wpinv_format_amount($invoice->get_total()), $invoice->get_currency()); |
|
432 | 432 | |
433 | - if ( $invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total() ) { |
|
434 | - $recurring_total = wpinv_price( wpinv_format_amount( $invoice->get_recurring_total() ), $invoice->get_currency() ); |
|
435 | - $total .= '<small class="form-text text-muted">' . sprintf( __( 'Recurring Price: %s', 'invoicing' ), $recurring_total ) . '</small>'; |
|
433 | + if ($invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total()) { |
|
434 | + $recurring_total = wpinv_price(wpinv_format_amount($invoice->get_recurring_total()), $invoice->get_currency()); |
|
435 | + $total .= '<small class="form-text text-muted">' . sprintf(__('Recurring Price: %s', 'invoicing'), $recurring_total) . '</small>'; |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | $totals = array( |
439 | - 'subtotal' => wpinv_price( wpinv_format_amount( $invoice->get_subtotal() ), $invoice->get_currency() ), |
|
440 | - 'discount' => wpinv_price( wpinv_format_amount( $invoice->get_total_discount() ), $invoice->get_currency() ), |
|
441 | - 'tax' => wpinv_price( wpinv_format_amount( $invoice->get_total_tax() ), $invoice->get_currency() ), |
|
439 | + 'subtotal' => wpinv_price(wpinv_format_amount($invoice->get_subtotal()), $invoice->get_currency()), |
|
440 | + 'discount' => wpinv_price(wpinv_format_amount($invoice->get_total_discount()), $invoice->get_currency()), |
|
441 | + 'tax' => wpinv_price(wpinv_format_amount($invoice->get_total_tax()), $invoice->get_currency()), |
|
442 | 442 | 'total' => $total, |
443 | 443 | ); |
444 | 444 | |
445 | - $totals = apply_filters( 'getpaid_invoice_totals', $totals, $invoice ); |
|
445 | + $totals = apply_filters('getpaid_invoice_totals', $totals, $invoice); |
|
446 | 446 | |
447 | - wp_send_json_success( compact( 'totals' ) ); |
|
447 | + wp_send_json_success(compact('totals')); |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | /** |
@@ -453,33 +453,33 @@ discard block |
||
453 | 453 | public static function get_invoice_items() { |
454 | 454 | |
455 | 455 | // Verify nonce. |
456 | - check_ajax_referer( 'wpinv-nonce' ); |
|
456 | + check_ajax_referer('wpinv-nonce'); |
|
457 | 457 | |
458 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
458 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
459 | 459 | exit; |
460 | 460 | } |
461 | 461 | |
462 | 462 | // We need an invoice and items. |
463 | - if ( empty( $_POST['post_id'] ) ) { |
|
463 | + if (empty($_POST['post_id'])) { |
|
464 | 464 | exit; |
465 | 465 | } |
466 | 466 | |
467 | 467 | // Fetch the invoice. |
468 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
468 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
469 | 469 | |
470 | 470 | // Ensure it exists. |
471 | - if ( ! $invoice->get_id() ) { |
|
471 | + if (!$invoice->get_id()) { |
|
472 | 472 | exit; |
473 | 473 | } |
474 | 474 | |
475 | 475 | // Return an array of invoice items. |
476 | 476 | $items = array(); |
477 | 477 | |
478 | - foreach ( $invoice->get_items() as $item_id => $item ) { |
|
479 | - $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
478 | + foreach ($invoice->get_items() as $item_id => $item) { |
|
479 | + $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
480 | 480 | } |
481 | 481 | |
482 | - wp_send_json_success( compact( 'items' ) ); |
|
482 | + wp_send_json_success(compact('items')); |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | /** |
@@ -488,50 +488,50 @@ discard block |
||
488 | 488 | public static function edit_invoice_item() { |
489 | 489 | |
490 | 490 | // Verify nonce. |
491 | - check_ajax_referer( 'wpinv-nonce' ); |
|
491 | + check_ajax_referer('wpinv-nonce'); |
|
492 | 492 | |
493 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
493 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
494 | 494 | exit; |
495 | 495 | } |
496 | 496 | |
497 | 497 | // We need an invoice and item details. |
498 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['data'] ) ) { |
|
498 | + if (empty($_POST['post_id']) || empty($_POST['data'])) { |
|
499 | 499 | exit; |
500 | 500 | } |
501 | 501 | |
502 | 502 | // Fetch the invoice. |
503 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
503 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
504 | 504 | |
505 | 505 | // Ensure it exists and its not been paid for. |
506 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
506 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
507 | 507 | exit; |
508 | 508 | } |
509 | 509 | |
510 | 510 | // Format the data. |
511 | - $data = wp_list_pluck( $_POST['data'], 'value', 'field' ); |
|
511 | + $data = wp_list_pluck($_POST['data'], 'value', 'field'); |
|
512 | 512 | |
513 | 513 | // Ensure that we have an item id. |
514 | - if ( empty( $data['id'] ) ) { |
|
514 | + if (empty($data['id'])) { |
|
515 | 515 | exit; |
516 | 516 | } |
517 | 517 | |
518 | 518 | // Abort if the invoice does not have the specified item. |
519 | - $item = $invoice->get_item( (int) $data['id'] ); |
|
519 | + $item = $invoice->get_item((int) $data['id']); |
|
520 | 520 | |
521 | - if ( empty( $item ) ) { |
|
521 | + if (empty($item)) { |
|
522 | 522 | exit; |
523 | 523 | } |
524 | 524 | |
525 | 525 | // Update the item. |
526 | - $item->set_price( $data['price'] ); |
|
527 | - $item->set_name( $data['name'] ); |
|
528 | - $item->set_description( $data['description'] ); |
|
529 | - $item->set_quantity( $data['quantity'] ); |
|
526 | + $item->set_price($data['price']); |
|
527 | + $item->set_name($data['name']); |
|
528 | + $item->set_description($data['description']); |
|
529 | + $item->set_quantity($data['quantity']); |
|
530 | 530 | |
531 | 531 | // Add it to the invoice. |
532 | - $error = $invoice->add_item( $item ); |
|
532 | + $error = $invoice->add_item($item); |
|
533 | 533 | $alert = false; |
534 | - if ( is_wp_error( $error ) ) { |
|
534 | + if (is_wp_error($error)) { |
|
535 | 535 | $alert = $error->get_error_message(); |
536 | 536 | } |
537 | 537 | |
@@ -544,11 +544,11 @@ discard block |
||
544 | 544 | // Return an array of invoice items. |
545 | 545 | $items = array(); |
546 | 546 | |
547 | - foreach ( $invoice->get_items() as $item_id => $item ) { |
|
548 | - $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
547 | + foreach ($invoice->get_items() as $item_id => $item) { |
|
548 | + $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
549 | 549 | } |
550 | 550 | |
551 | - wp_send_json_success( compact( 'items', 'alert' ) ); |
|
551 | + wp_send_json_success(compact('items', 'alert')); |
|
552 | 552 | } |
553 | 553 | |
554 | 554 | /** |
@@ -557,33 +557,33 @@ discard block |
||
557 | 557 | public static function remove_invoice_item() { |
558 | 558 | |
559 | 559 | // Verify nonce. |
560 | - check_ajax_referer( 'wpinv-nonce' ); |
|
560 | + check_ajax_referer('wpinv-nonce'); |
|
561 | 561 | |
562 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
562 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
563 | 563 | exit; |
564 | 564 | } |
565 | 565 | |
566 | 566 | // We need an invoice and an item. |
567 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['item_id'] ) ) { |
|
567 | + if (empty($_POST['post_id']) || empty($_POST['item_id'])) { |
|
568 | 568 | exit; |
569 | 569 | } |
570 | 570 | |
571 | 571 | // Fetch the invoice. |
572 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
572 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
573 | 573 | |
574 | 574 | // Ensure it exists and its not been paid for. |
575 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
575 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
576 | 576 | exit; |
577 | 577 | } |
578 | 578 | |
579 | 579 | // Abort if the invoice does not have the specified item. |
580 | - $item = $invoice->get_item( (int) $_POST['item_id'] ); |
|
580 | + $item = $invoice->get_item((int) $_POST['item_id']); |
|
581 | 581 | |
582 | - if ( empty( $item ) ) { |
|
582 | + if (empty($item)) { |
|
583 | 583 | exit; |
584 | 584 | } |
585 | 585 | |
586 | - $invoice->remove_item( (int) $_POST['item_id'] ); |
|
586 | + $invoice->remove_item((int) $_POST['item_id']); |
|
587 | 587 | |
588 | 588 | // Update totals. |
589 | 589 | $invoice->recalculate_total(); |
@@ -594,11 +594,11 @@ discard block |
||
594 | 594 | // Return an array of invoice items. |
595 | 595 | $items = array(); |
596 | 596 | |
597 | - foreach ( $invoice->get_items() as $item_id => $item ) { |
|
598 | - $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
597 | + foreach ($invoice->get_items() as $item_id => $item) { |
|
598 | + $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
599 | 599 | } |
600 | 600 | |
601 | - wp_send_json_success( compact( 'items' ) ); |
|
601 | + wp_send_json_success(compact('items')); |
|
602 | 602 | } |
603 | 603 | |
604 | 604 | /** |
@@ -607,39 +607,39 @@ discard block |
||
607 | 607 | public static function add_invoice_items() { |
608 | 608 | |
609 | 609 | // Verify nonce. |
610 | - check_ajax_referer( 'wpinv-nonce' ); |
|
610 | + check_ajax_referer('wpinv-nonce'); |
|
611 | 611 | |
612 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
612 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
613 | 613 | exit; |
614 | 614 | } |
615 | 615 | |
616 | 616 | // We need an invoice and items. |
617 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['items'] ) ) { |
|
617 | + if (empty($_POST['post_id']) || empty($_POST['items'])) { |
|
618 | 618 | exit; |
619 | 619 | } |
620 | 620 | |
621 | 621 | // Fetch the invoice. |
622 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
622 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
623 | 623 | $alert = false; |
624 | 624 | |
625 | 625 | // Ensure it exists and its not been paid for. |
626 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
626 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
627 | 627 | exit; |
628 | 628 | } |
629 | 629 | |
630 | 630 | // Add the items. |
631 | - foreach ( $_POST['items'] as $data ) { |
|
631 | + foreach ($_POST['items'] as $data) { |
|
632 | 632 | |
633 | - $item = new GetPaid_Form_Item( $data[ 'id' ] ); |
|
633 | + $item = new GetPaid_Form_Item($data['id']); |
|
634 | 634 | |
635 | - if ( is_numeric( $data[ 'qty' ] ) && (int) $data[ 'qty' ] > 0 ) { |
|
636 | - $item->set_quantity( $data[ 'qty' ] ); |
|
635 | + if (is_numeric($data['qty']) && (int) $data['qty'] > 0) { |
|
636 | + $item->set_quantity($data['qty']); |
|
637 | 637 | } |
638 | 638 | |
639 | - if ( $item->get_id() > 0 ) { |
|
640 | - $error = $invoice->add_item( $item ); |
|
639 | + if ($item->get_id() > 0) { |
|
640 | + $error = $invoice->add_item($item); |
|
641 | 641 | |
642 | - if ( is_wp_error( $error ) ) { |
|
642 | + if (is_wp_error($error)) { |
|
643 | 643 | $alert = $error->get_error_message(); |
644 | 644 | } |
645 | 645 | |
@@ -654,11 +654,11 @@ discard block |
||
654 | 654 | // Return an array of invoice items. |
655 | 655 | $items = array(); |
656 | 656 | |
657 | - foreach ( $invoice->get_items() as $item_id => $item ) { |
|
658 | - $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
657 | + foreach ($invoice->get_items() as $item_id => $item) { |
|
658 | + $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
659 | 659 | } |
660 | 660 | |
661 | - wp_send_json_success( compact( 'items', 'alert' ) ); |
|
661 | + wp_send_json_success(compact('items', 'alert')); |
|
662 | 662 | } |
663 | 663 | |
664 | 664 | /** |
@@ -667,15 +667,15 @@ discard block |
||
667 | 667 | public static function get_invoicing_items() { |
668 | 668 | |
669 | 669 | // Verify nonce. |
670 | - check_ajax_referer( 'wpinv-nonce' ); |
|
670 | + check_ajax_referer('wpinv-nonce'); |
|
671 | 671 | |
672 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
672 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
673 | 673 | exit; |
674 | 674 | } |
675 | 675 | |
676 | 676 | // We need a search term. |
677 | - if ( empty( $_GET['search'] ) ) { |
|
678 | - wp_send_json_success( array() ); |
|
677 | + if (empty($_GET['search'])) { |
|
678 | + wp_send_json_success(array()); |
|
679 | 679 | } |
680 | 680 | |
681 | 681 | // Retrieve items. |
@@ -684,8 +684,8 @@ discard block |
||
684 | 684 | 'orderby' => 'title', |
685 | 685 | 'order' => 'ASC', |
686 | 686 | 'posts_per_page' => -1, |
687 | - 'post_status' => array( 'publish' ), |
|
688 | - 's' => trim( $_GET['search'] ), |
|
687 | + 'post_status' => array('publish'), |
|
688 | + 's' => trim($_GET['search']), |
|
689 | 689 | 'meta_query' => array( |
690 | 690 | array( |
691 | 691 | 'key' => '_wpinv_type', |
@@ -695,18 +695,18 @@ discard block |
||
695 | 695 | ) |
696 | 696 | ); |
697 | 697 | |
698 | - $items = get_posts( apply_filters( 'getpaid_ajax_invoice_items_query_args', $item_args ) ); |
|
698 | + $items = get_posts(apply_filters('getpaid_ajax_invoice_items_query_args', $item_args)); |
|
699 | 699 | $data = array(); |
700 | 700 | |
701 | - foreach ( $items as $item ) { |
|
702 | - $item = new GetPaid_Form_Item( $item ); |
|
701 | + foreach ($items as $item) { |
|
702 | + $item = new GetPaid_Form_Item($item); |
|
703 | 703 | $data[] = array( |
704 | 704 | 'id' => $item->get_id(), |
705 | 705 | 'text' => $item->get_name() |
706 | 706 | ); |
707 | 707 | } |
708 | 708 | |
709 | - wp_send_json_success( $data ); |
|
709 | + wp_send_json_success($data); |
|
710 | 710 | |
711 | 711 | } |
712 | 712 | |
@@ -716,24 +716,24 @@ discard block |
||
716 | 716 | public static function get_aui_states_field() { |
717 | 717 | |
718 | 718 | // Verify nonce. |
719 | - check_ajax_referer( 'wpinv-nonce' ); |
|
719 | + check_ajax_referer('wpinv-nonce'); |
|
720 | 720 | |
721 | 721 | // We need a country. |
722 | - if ( empty( $_GET['country'] ) ) { |
|
722 | + if (empty($_GET['country'])) { |
|
723 | 723 | exit; |
724 | 724 | } |
725 | 725 | |
726 | - $states = wpinv_get_country_states( trim( $_GET['country'] ) ); |
|
727 | - $state = isset( $_GET['state'] ) ? trim( $_GET['state'] ) : wpinv_get_default_state(); |
|
726 | + $states = wpinv_get_country_states(trim($_GET['country'])); |
|
727 | + $state = isset($_GET['state']) ? trim($_GET['state']) : wpinv_get_default_state(); |
|
728 | 728 | |
729 | - if ( empty( $states ) ) { |
|
729 | + if (empty($states)) { |
|
730 | 730 | |
731 | 731 | $html = aui()->input( |
732 | 732 | array( |
733 | 733 | 'type' => 'text', |
734 | 734 | 'id' => 'wpinv_state', |
735 | 735 | 'name' => 'wpinv_state', |
736 | - 'label' => __( 'State', 'invoicing' ), |
|
736 | + 'label' => __('State', 'invoicing'), |
|
737 | 737 | 'label_type' => 'vertical', |
738 | 738 | 'placeholder' => 'Liège', |
739 | 739 | 'class' => 'form-control-sm', |
@@ -747,9 +747,9 @@ discard block |
||
747 | 747 | array( |
748 | 748 | 'id' => 'wpinv_state', |
749 | 749 | 'name' => 'wpinv_state', |
750 | - 'label' => __( 'State', 'invoicing' ), |
|
750 | + 'label' => __('State', 'invoicing'), |
|
751 | 751 | 'label_type' => 'vertical', |
752 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
752 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
753 | 753 | 'class' => 'form-control-sm', |
754 | 754 | 'value' => $state, |
755 | 755 | 'options' => $states, |
@@ -763,7 +763,7 @@ discard block |
||
763 | 763 | wp_send_json_success( |
764 | 764 | array( |
765 | 765 | 'html' => $html, |
766 | - 'select' => ! empty ( $states ) |
|
766 | + 'select' => !empty ($states) |
|
767 | 767 | ) |
768 | 768 | ); |
769 | 769 | |
@@ -777,46 +777,46 @@ discard block |
||
777 | 777 | public static function ip_geolocation() { |
778 | 778 | |
779 | 779 | // Check nonce. |
780 | - check_ajax_referer( 'getpaid-ip-location' ); |
|
780 | + check_ajax_referer('getpaid-ip-location'); |
|
781 | 781 | |
782 | 782 | // IP address. |
783 | - if ( empty( $_GET['ip'] ) || ! rest_is_ip_address( $_GET['ip'] ) ) { |
|
784 | - _e( 'Invalid IP Address.', 'invoicing' ); |
|
783 | + if (empty($_GET['ip']) || !rest_is_ip_address($_GET['ip'])) { |
|
784 | + _e('Invalid IP Address.', 'invoicing'); |
|
785 | 785 | exit; |
786 | 786 | } |
787 | 787 | |
788 | 788 | // Retrieve location info. |
789 | - $location = getpaid_geolocate_ip_address( $_GET['ip'] ); |
|
789 | + $location = getpaid_geolocate_ip_address($_GET['ip']); |
|
790 | 790 | |
791 | - if ( empty( $location ) ) { |
|
792 | - _e( 'Unable to find geolocation for the IP Address.', 'invoicing' ); |
|
791 | + if (empty($location)) { |
|
792 | + _e('Unable to find geolocation for the IP Address.', 'invoicing'); |
|
793 | 793 | exit; |
794 | 794 | } |
795 | 795 | |
796 | 796 | // Sorry. |
797 | - extract( $location ); |
|
797 | + extract($location); |
|
798 | 798 | |
799 | 799 | // Prepare the address. |
800 | 800 | $content = ''; |
801 | 801 | |
802 | - if ( ! empty( $location['city'] ) ) { |
|
803 | - $content .= $location['city'] . ', '; |
|
802 | + if (!empty($location['city'])) { |
|
803 | + $content .= $location['city'] . ', '; |
|
804 | 804 | } |
805 | 805 | |
806 | - if ( ! empty( $location['region'] ) ) { |
|
807 | - $content .= $location['region'] . ', '; |
|
806 | + if (!empty($location['region'])) { |
|
807 | + $content .= $location['region'] . ', '; |
|
808 | 808 | } |
809 | 809 | |
810 | - $content .= $location['country'] . ' (' . $location['iso'] . ')'; |
|
810 | + $content .= $location['country'] . ' (' . $location['iso'] . ')'; |
|
811 | 811 | |
812 | 812 | $location['address'] = $content; |
813 | 813 | |
814 | - $content = '<p>'. sprintf( __( '<b>Address:</b> %s', 'invoicing' ), $content ) . '</p>'; |
|
815 | - $content .= '<p>'. $location['credit'] . '</p>'; |
|
814 | + $content = '<p>' . sprintf(__('<b>Address:</b> %s', 'invoicing'), $content) . '</p>'; |
|
815 | + $content .= '<p>' . $location['credit'] . '</p>'; |
|
816 | 816 | |
817 | 817 | $location['content'] = $content; |
818 | 818 | |
819 | - wpinv_get_template( 'geolocation.php', $location ); |
|
819 | + wpinv_get_template('geolocation.php', $location); |
|
820 | 820 | |
821 | 821 | exit; |
822 | 822 | } |
@@ -829,11 +829,11 @@ discard block |
||
829 | 829 | public static function payment_form_refresh_prices() { |
830 | 830 | |
831 | 831 | // Check nonce. |
832 | - check_ajax_referer( 'getpaid_form_nonce' ); |
|
832 | + check_ajax_referer('getpaid_form_nonce'); |
|
833 | 833 | |
834 | 834 | // ... form fields... |
835 | - if ( empty( $_POST['getpaid_payment_form_submission'] ) ) { |
|
836 | - _e( 'Error: Reload the page and try again.', 'invoicing' ); |
|
835 | + if (empty($_POST['getpaid_payment_form_submission'])) { |
|
836 | + _e('Error: Reload the page and try again.', 'invoicing'); |
|
837 | 837 | exit; |
838 | 838 | } |
839 | 839 | |
@@ -841,7 +841,7 @@ discard block |
||
841 | 841 | $submission = new GetPaid_Payment_Form_Submission(); |
842 | 842 | |
843 | 843 | // Do we have an error? |
844 | - if ( ! empty( $submission->last_error ) ) { |
|
844 | + if (!empty($submission->last_error)) { |
|
845 | 845 | echo $submission->last_error; |
846 | 846 | exit; |
847 | 847 | } |
@@ -854,43 +854,43 @@ discard block |
||
854 | 854 | 'is_free' => $submission->get_payment_details(), |
855 | 855 | |
856 | 856 | 'totals' => array( |
857 | - 'subtotal' => wpinv_price( wpinv_format_amount( $submission->subtotal_amount ), $submission->get_currency() ), |
|
858 | - 'discount' => wpinv_price( wpinv_format_amount( $submission->get_total_discount() ), $submission->get_currency() ), |
|
859 | - 'fees' => wpinv_price( wpinv_format_amount( $submission->get_total_fees() ), $submission->get_currency() ), |
|
860 | - 'tax' => wpinv_price( wpinv_format_amount( $submission->get_total_tax() ), $submission->get_currency() ), |
|
861 | - 'total' => wpinv_price( wpinv_format_amount( $submission->get_total() ), $submission->get_currency() ), |
|
857 | + 'subtotal' => wpinv_price(wpinv_format_amount($submission->subtotal_amount), $submission->get_currency()), |
|
858 | + 'discount' => wpinv_price(wpinv_format_amount($submission->get_total_discount()), $submission->get_currency()), |
|
859 | + 'fees' => wpinv_price(wpinv_format_amount($submission->get_total_fees()), $submission->get_currency()), |
|
860 | + 'tax' => wpinv_price(wpinv_format_amount($submission->get_total_tax()), $submission->get_currency()), |
|
861 | + 'total' => wpinv_price(wpinv_format_amount($submission->get_total()), $submission->get_currency()), |
|
862 | 862 | ), |
863 | 863 | |
864 | 864 | 'texts' => array( |
865 | - '.getpaid-checkout-total-payable' => wpinv_price( wpinv_format_amount( $submission->get_total() ), $submission->get_currency() ), |
|
865 | + '.getpaid-checkout-total-payable' => wpinv_price(wpinv_format_amount($submission->get_total()), $submission->get_currency()), |
|
866 | 866 | ) |
867 | 867 | |
868 | 868 | ); |
869 | 869 | |
870 | 870 | // Add items. |
871 | 871 | $items = $submission->get_items(); |
872 | - if ( ! empty( $items ) ) { |
|
872 | + if (!empty($items)) { |
|
873 | 873 | $result['items'] = array(); |
874 | 874 | |
875 | - foreach( $items as $item_id => $item ) { |
|
876 | - $result['items']["$item_id"] = wpinv_price( wpinv_format_amount( $item->get_price() * $item->get_quantity() ) ); |
|
875 | + foreach ($items as $item_id => $item) { |
|
876 | + $result['items']["$item_id"] = wpinv_price(wpinv_format_amount($item->get_price() * $item->get_quantity())); |
|
877 | 877 | } |
878 | 878 | } |
879 | 879 | |
880 | 880 | // Add invoice. |
881 | - if ( $submission->has_invoice() ) { |
|
881 | + if ($submission->has_invoice()) { |
|
882 | 882 | $result['invoice'] = $submission->get_invoice()->ID; |
883 | 883 | } |
884 | 884 | |
885 | 885 | // Add discount code. |
886 | - if ( $submission->has_discount_code() ) { |
|
886 | + if ($submission->has_discount_code()) { |
|
887 | 887 | $result['discount_code'] = $submission->get_discount_code(); |
888 | 888 | } |
889 | 889 | |
890 | 890 | // Filter the result. |
891 | - $result = apply_filters( 'getpaid_payment_form_ajax_refresh_prices', $result, $submission ); |
|
891 | + $result = apply_filters('getpaid_payment_form_ajax_refresh_prices', $result, $submission); |
|
892 | 892 | |
893 | - wp_send_json_success( $result ); |
|
893 | + wp_send_json_success($result); |
|
894 | 894 | } |
895 | 895 | |
896 | 896 | /** |
@@ -901,53 +901,53 @@ discard block |
||
901 | 901 | public static function buy_items() { |
902 | 902 | $user_id = get_current_user_id(); |
903 | 903 | |
904 | - if ( empty( $user_id ) ) { // If not logged in then lets redirect to the login page |
|
905 | - wp_send_json( array( |
|
906 | - 'success' => wp_login_url( wp_get_referer() ) |
|
907 | - ) ); |
|
904 | + if (empty($user_id)) { // If not logged in then lets redirect to the login page |
|
905 | + wp_send_json(array( |
|
906 | + 'success' => wp_login_url(wp_get_referer()) |
|
907 | + )); |
|
908 | 908 | } else { |
909 | 909 | // Only check nonce if logged in as it could be cached when logged out. |
910 | - if ( ! isset( $_POST['wpinv_buy_nonce'] ) || ! wp_verify_nonce( $_POST['wpinv_buy_nonce'], 'wpinv_buy_items' ) ) { |
|
911 | - wp_send_json( array( |
|
912 | - 'error' => __( 'Security checks failed.', 'invoicing' ) |
|
913 | - ) ); |
|
910 | + if (!isset($_POST['wpinv_buy_nonce']) || !wp_verify_nonce($_POST['wpinv_buy_nonce'], 'wpinv_buy_items')) { |
|
911 | + wp_send_json(array( |
|
912 | + 'error' => __('Security checks failed.', 'invoicing') |
|
913 | + )); |
|
914 | 914 | wp_die(); |
915 | 915 | } |
916 | 916 | |
917 | 917 | // allow to set a custom price through post_id |
918 | 918 | $items = $_POST['items']; |
919 | - $related_post_id = isset( $_POST['post_id'] ) ? (int)$_POST['post_id'] : 0; |
|
920 | - $custom_item_price = $related_post_id ? abs( get_post_meta( $related_post_id, '_wpi_custom_price', true ) ) : 0; |
|
919 | + $related_post_id = isset($_POST['post_id']) ? (int) $_POST['post_id'] : 0; |
|
920 | + $custom_item_price = $related_post_id ? abs(get_post_meta($related_post_id, '_wpi_custom_price', true)) : 0; |
|
921 | 921 | |
922 | 922 | $cart_items = array(); |
923 | - if ( $items ) { |
|
924 | - $items = explode( ',', $items ); |
|
923 | + if ($items) { |
|
924 | + $items = explode(',', $items); |
|
925 | 925 | |
926 | - foreach( $items as $item ) { |
|
926 | + foreach ($items as $item) { |
|
927 | 927 | $item_id = $item; |
928 | 928 | $quantity = 1; |
929 | 929 | |
930 | - if ( strpos( $item, '|' ) !== false ) { |
|
931 | - $item_parts = explode( '|', $item ); |
|
930 | + if (strpos($item, '|') !== false) { |
|
931 | + $item_parts = explode('|', $item); |
|
932 | 932 | $item_id = $item_parts[0]; |
933 | 933 | $quantity = $item_parts[1]; |
934 | 934 | } |
935 | 935 | |
936 | - if ( $item_id && $quantity ) { |
|
936 | + if ($item_id && $quantity) { |
|
937 | 937 | $cart_items_arr = array( |
938 | - 'id' => (int)$item_id, |
|
939 | - 'quantity' => (int)$quantity |
|
938 | + 'id' => (int) $item_id, |
|
939 | + 'quantity' => (int) $quantity |
|
940 | 940 | ); |
941 | 941 | |
942 | 942 | // If there is a related post id then add it to meta |
943 | - if ( $related_post_id ) { |
|
943 | + if ($related_post_id) { |
|
944 | 944 | $cart_items_arr['meta'] = array( |
945 | 945 | 'post_id' => $related_post_id |
946 | 946 | ); |
947 | 947 | } |
948 | 948 | |
949 | 949 | // If there is a custom price then set it. |
950 | - if ( $custom_item_price ) { |
|
950 | + if ($custom_item_price) { |
|
951 | 951 | $cart_items_arr['custom_price'] = $custom_item_price; |
952 | 952 | } |
953 | 953 | |
@@ -963,37 +963,37 @@ discard block |
||
963 | 963 | * @param int $related_post_id The related post id if any. |
964 | 964 | * @since 1.0.0 |
965 | 965 | */ |
966 | - $cart_items = apply_filters( 'wpinv_buy_cart_items', $cart_items, $related_post_id ); |
|
966 | + $cart_items = apply_filters('wpinv_buy_cart_items', $cart_items, $related_post_id); |
|
967 | 967 | |
968 | 968 | // Make sure its not in the cart already, if it is then redirect to checkout. |
969 | 969 | $cart_invoice = wpinv_get_invoice_cart(); |
970 | 970 | |
971 | - if ( isset( $cart_invoice->items ) && !empty( $cart_invoice->items ) && !empty( $cart_items ) && serialize( $cart_invoice->items ) == serialize( $cart_items ) ) { |
|
972 | - wp_send_json( array( |
|
971 | + if (isset($cart_invoice->items) && !empty($cart_invoice->items) && !empty($cart_items) && serialize($cart_invoice->items) == serialize($cart_items)) { |
|
972 | + wp_send_json(array( |
|
973 | 973 | 'success' => $cart_invoice->get_checkout_payment_url() |
974 | - ) ); |
|
974 | + )); |
|
975 | 975 | wp_die(); |
976 | 976 | } |
977 | 977 | |
978 | 978 | // Check if user has invoice with same items waiting to be paid. |
979 | - $user_invoices = wpinv_get_users_invoices( $user_id , 10 , false , 'wpi-pending' ); |
|
980 | - if ( !empty( $user_invoices ) ) { |
|
981 | - foreach( $user_invoices as $user_invoice ) { |
|
979 | + $user_invoices = wpinv_get_users_invoices($user_id, 10, false, 'wpi-pending'); |
|
980 | + if (!empty($user_invoices)) { |
|
981 | + foreach ($user_invoices as $user_invoice) { |
|
982 | 982 | $user_cart_details = array(); |
983 | - $invoice = wpinv_get_invoice( $user_invoice->ID ); |
|
983 | + $invoice = wpinv_get_invoice($user_invoice->ID); |
|
984 | 984 | $cart_details = $invoice->get_cart_details(); |
985 | 985 | |
986 | - if ( !empty( $cart_details ) ) { |
|
987 | - foreach ( $cart_details as $invoice_item ) { |
|
986 | + if (!empty($cart_details)) { |
|
987 | + foreach ($cart_details as $invoice_item) { |
|
988 | 988 | $ii_arr = array(); |
989 | - $ii_arr['id'] = (int)$invoice_item['id']; |
|
990 | - $ii_arr['quantity'] = (int)$invoice_item['quantity']; |
|
989 | + $ii_arr['id'] = (int) $invoice_item['id']; |
|
990 | + $ii_arr['quantity'] = (int) $invoice_item['quantity']; |
|
991 | 991 | |
992 | - if (isset( $invoice_item['meta'] ) && !empty( $invoice_item['meta'] ) ) { |
|
992 | + if (isset($invoice_item['meta']) && !empty($invoice_item['meta'])) { |
|
993 | 993 | $ii_arr['meta'] = $invoice_item['meta']; |
994 | 994 | } |
995 | 995 | |
996 | - if ( isset( $invoice_item['custom_price'] ) && !empty( $invoice_item['custom_price'] ) ) { |
|
996 | + if (isset($invoice_item['custom_price']) && !empty($invoice_item['custom_price'])) { |
|
997 | 997 | $ii_arr['custom_price'] = $invoice_item['custom_price']; |
998 | 998 | } |
999 | 999 | |
@@ -1001,17 +1001,17 @@ discard block |
||
1001 | 1001 | } |
1002 | 1002 | } |
1003 | 1003 | |
1004 | - if ( !empty( $user_cart_details ) && serialize( $cart_items ) == serialize( $user_cart_details ) ) { |
|
1005 | - wp_send_json( array( |
|
1004 | + if (!empty($user_cart_details) && serialize($cart_items) == serialize($user_cart_details)) { |
|
1005 | + wp_send_json(array( |
|
1006 | 1006 | 'success' => $invoice->get_checkout_payment_url() |
1007 | - ) ); |
|
1007 | + )); |
|
1008 | 1008 | wp_die(); |
1009 | 1009 | } |
1010 | 1010 | } |
1011 | 1011 | } |
1012 | 1012 | |
1013 | 1013 | // Create invoice and send user to checkout |
1014 | - if ( !empty( $cart_items ) ) { |
|
1014 | + if (!empty($cart_items)) { |
|
1015 | 1015 | $invoice_data = array( |
1016 | 1016 | 'status' => 'wpi-pending', |
1017 | 1017 | 'created_via' => 'wpi', |
@@ -1019,21 +1019,21 @@ discard block |
||
1019 | 1019 | 'cart_details' => $cart_items, |
1020 | 1020 | ); |
1021 | 1021 | |
1022 | - $invoice = wpinv_insert_invoice( $invoice_data, true ); |
|
1022 | + $invoice = wpinv_insert_invoice($invoice_data, true); |
|
1023 | 1023 | |
1024 | - if ( !empty( $invoice ) && isset( $invoice->ID ) ) { |
|
1025 | - wp_send_json( array( |
|
1024 | + if (!empty($invoice) && isset($invoice->ID)) { |
|
1025 | + wp_send_json(array( |
|
1026 | 1026 | 'success' => $invoice->get_checkout_payment_url() |
1027 | - ) ); |
|
1027 | + )); |
|
1028 | 1028 | } else { |
1029 | - wp_send_json( array( |
|
1030 | - 'error' => __( 'Invoice failed to create', 'invoicing' ) |
|
1031 | - ) ); |
|
1029 | + wp_send_json(array( |
|
1030 | + 'error' => __('Invoice failed to create', 'invoicing') |
|
1031 | + )); |
|
1032 | 1032 | } |
1033 | 1033 | } else { |
1034 | - wp_send_json( array( |
|
1035 | - 'error' => __( 'Items not valid.', 'invoicing' ) |
|
1036 | - ) ); |
|
1034 | + wp_send_json(array( |
|
1035 | + 'error' => __('Items not valid.', 'invoicing') |
|
1036 | + )); |
|
1037 | 1037 | } |
1038 | 1038 | } |
1039 | 1039 |
@@ -12,168 +12,168 @@ discard block |
||
12 | 12 | */ |
13 | 13 | class GetPaid_Checkout { |
14 | 14 | |
15 | - /** |
|
16 | - * @var GetPaid_Payment_Form_Submission |
|
17 | - */ |
|
18 | - protected $payment_form_submission; |
|
19 | - |
|
20 | - /** |
|
21 | - * Class constructor. |
|
22 | - * |
|
23 | - * @param GetPaid_Payment_Form_Submission $submission |
|
24 | - */ |
|
25 | - public function __construct( $submission ) { |
|
26 | - $this->payment_form_submission = $submission; |
|
27 | - } |
|
28 | - |
|
29 | - /** |
|
30 | - * Processes the checkout. |
|
31 | - * |
|
32 | - */ |
|
33 | - public function process_checkout() { |
|
34 | - |
|
35 | - // Validate the submission. |
|
36 | - $this->validate_submission(); |
|
37 | - |
|
38 | - // Get the items and invoice. |
|
39 | - $items = $this->get_submission_items(); |
|
40 | - $invoice = $this->get_submission_invoice(); |
|
41 | - $invoice = $this->process_submission_invoice( $invoice, $items ); |
|
42 | - $prepared = $this->prepare_submission_data_for_saving( $invoice ); |
|
43 | - |
|
44 | - // Save the invoice. |
|
45 | - $invoice->recalculate_total(); |
|
15 | + /** |
|
16 | + * @var GetPaid_Payment_Form_Submission |
|
17 | + */ |
|
18 | + protected $payment_form_submission; |
|
19 | + |
|
20 | + /** |
|
21 | + * Class constructor. |
|
22 | + * |
|
23 | + * @param GetPaid_Payment_Form_Submission $submission |
|
24 | + */ |
|
25 | + public function __construct( $submission ) { |
|
26 | + $this->payment_form_submission = $submission; |
|
27 | + } |
|
28 | + |
|
29 | + /** |
|
30 | + * Processes the checkout. |
|
31 | + * |
|
32 | + */ |
|
33 | + public function process_checkout() { |
|
34 | + |
|
35 | + // Validate the submission. |
|
36 | + $this->validate_submission(); |
|
37 | + |
|
38 | + // Get the items and invoice. |
|
39 | + $items = $this->get_submission_items(); |
|
40 | + $invoice = $this->get_submission_invoice(); |
|
41 | + $invoice = $this->process_submission_invoice( $invoice, $items ); |
|
42 | + $prepared = $this->prepare_submission_data_for_saving( $invoice ); |
|
43 | + |
|
44 | + // Save the invoice. |
|
45 | + $invoice->recalculate_total(); |
|
46 | 46 | $invoice->save(); |
47 | 47 | |
48 | - // Send to the gateway. |
|
49 | - $this->post_process_submission( $invoice, $prepared ); |
|
50 | - } |
|
48 | + // Send to the gateway. |
|
49 | + $this->post_process_submission( $invoice, $prepared ); |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Validates the submission. |
|
54 | - * |
|
55 | - */ |
|
56 | - protected function validate_submission() { |
|
52 | + /** |
|
53 | + * Validates the submission. |
|
54 | + * |
|
55 | + */ |
|
56 | + protected function validate_submission() { |
|
57 | 57 | |
58 | - $submission = $this->payment_form_submission; |
|
59 | - $data = $submission->get_data(); |
|
58 | + $submission = $this->payment_form_submission; |
|
59 | + $data = $submission->get_data(); |
|
60 | 60 | |
61 | - // Do we have an error? |
|
61 | + // Do we have an error? |
|
62 | 62 | if ( ! empty( $submission->last_error ) ) { |
63 | - wp_send_json_error( $submission->last_error ); |
|
63 | + wp_send_json_error( $submission->last_error ); |
|
64 | 64 | } |
65 | 65 | |
66 | - // We need a billing email. |
|
66 | + // We need a billing email. |
|
67 | 67 | if ( ! $submission->has_billing_email() || ! is_email( $submission->get_billing_email() ) ) { |
68 | 68 | wp_send_json_error( __( 'Provide a valid billing email.', 'invoicing' ) ); |
69 | - } |
|
69 | + } |
|
70 | 70 | |
71 | - // Non-recurring gateways should not be allowed to process recurring invoices. |
|
72 | - if ( $submission->has_recurring && ! wpinv_gateway_support_subscription( $data['wpi-gateway'] ) ) { |
|
73 | - wp_send_json_error( __( 'The selected payment gateway does not support subscription payment.', 'invoicing' ) ); |
|
74 | - } |
|
71 | + // Non-recurring gateways should not be allowed to process recurring invoices. |
|
72 | + if ( $submission->has_recurring && ! wpinv_gateway_support_subscription( $data['wpi-gateway'] ) ) { |
|
73 | + wp_send_json_error( __( 'The selected payment gateway does not support subscription payment.', 'invoicing' ) ); |
|
74 | + } |
|
75 | 75 | |
76 | - // Ensure the gateway is active. |
|
77 | - if ( ! wpinv_is_gateway_active( $data['wpi-gateway'] ) ) { |
|
78 | - wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway is not active', 'invoicing' ) ); |
|
79 | - } |
|
76 | + // Ensure the gateway is active. |
|
77 | + if ( ! wpinv_is_gateway_active( $data['wpi-gateway'] ) ) { |
|
78 | + wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway is not active', 'invoicing' ) ); |
|
79 | + } |
|
80 | 80 | |
81 | - // Clear any existing errors. |
|
82 | - wpinv_clear_errors(); |
|
81 | + // Clear any existing errors. |
|
82 | + wpinv_clear_errors(); |
|
83 | 83 | |
84 | - // Allow themes and plugins to hook to errors |
|
85 | - do_action( 'getpaid_checkout_error_checks', $submission ); |
|
84 | + // Allow themes and plugins to hook to errors |
|
85 | + do_action( 'getpaid_checkout_error_checks', $submission ); |
|
86 | 86 | |
87 | - // Do we have any errors? |
|
87 | + // Do we have any errors? |
|
88 | 88 | if ( wpinv_get_errors() ) { |
89 | 89 | wp_send_json_error( getpaid_get_errors_html() ); |
90 | - } |
|
90 | + } |
|
91 | 91 | |
92 | - } |
|
92 | + } |
|
93 | 93 | |
94 | - /** |
|
95 | - * Retrieves submission items. |
|
96 | - * |
|
97 | - * @return GetPaid_Form_Item[] |
|
98 | - */ |
|
99 | - protected function get_submission_items() { |
|
94 | + /** |
|
95 | + * Retrieves submission items. |
|
96 | + * |
|
97 | + * @return GetPaid_Form_Item[] |
|
98 | + */ |
|
99 | + protected function get_submission_items() { |
|
100 | 100 | |
101 | - $items = $this->payment_form_submission->get_items(); |
|
101 | + $items = $this->payment_form_submission->get_items(); |
|
102 | 102 | |
103 | 103 | // Ensure that we have items. |
104 | 104 | if ( empty( $items ) && 0 == count( $this->payment_form_submission->get_fees() ) ) { |
105 | 105 | wp_send_json_error( __( 'Please select at least one item.', 'invoicing' ) ); |
106 | - } |
|
106 | + } |
|
107 | 107 | |
108 | - return $items; |
|
109 | - } |
|
108 | + return $items; |
|
109 | + } |
|
110 | 110 | |
111 | - /** |
|
112 | - * Retrieves submission invoice. |
|
113 | - * |
|
114 | - * @return WPInv_Invoice |
|
115 | - */ |
|
116 | - protected function get_submission_invoice() { |
|
117 | - $submission = $this->payment_form_submission; |
|
111 | + /** |
|
112 | + * Retrieves submission invoice. |
|
113 | + * |
|
114 | + * @return WPInv_Invoice |
|
115 | + */ |
|
116 | + protected function get_submission_invoice() { |
|
117 | + $submission = $this->payment_form_submission; |
|
118 | 118 | |
119 | - if ( ! $submission->has_invoice() ) { |
|
120 | - return new WPInv_Invoice(); |
|
119 | + if ( ! $submission->has_invoice() ) { |
|
120 | + return new WPInv_Invoice(); |
|
121 | 121 | } |
122 | 122 | |
123 | - $invoice = $submission->get_invoice(); |
|
123 | + $invoice = $submission->get_invoice(); |
|
124 | 124 | |
125 | - // Make sure that it is neither paid or refunded. |
|
126 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
127 | - wp_send_json_error( __( 'This invoice has already been paid for.', 'invoicing' ) ); |
|
128 | - } |
|
125 | + // Make sure that it is neither paid or refunded. |
|
126 | + if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
127 | + wp_send_json_error( __( 'This invoice has already been paid for.', 'invoicing' ) ); |
|
128 | + } |
|
129 | 129 | |
130 | - return $invoice; |
|
131 | - } |
|
130 | + return $invoice; |
|
131 | + } |
|
132 | 132 | |
133 | - /** |
|
134 | - * Processes the submission invoice. |
|
135 | - * |
|
136 | - * @param WPInv_Invoice $invoice |
|
137 | - * @param GetPaid_Form_Item[] $items |
|
138 | - * @return WPInv_Invoice |
|
139 | - */ |
|
140 | - protected function process_submission_invoice( $invoice, $items ) { |
|
133 | + /** |
|
134 | + * Processes the submission invoice. |
|
135 | + * |
|
136 | + * @param WPInv_Invoice $invoice |
|
137 | + * @param GetPaid_Form_Item[] $items |
|
138 | + * @return WPInv_Invoice |
|
139 | + */ |
|
140 | + protected function process_submission_invoice( $invoice, $items ) { |
|
141 | 141 | |
142 | - $submission = $this->payment_form_submission; |
|
143 | - $data = $submission->get_data(); |
|
142 | + $submission = $this->payment_form_submission; |
|
143 | + $data = $submission->get_data(); |
|
144 | 144 | |
145 | - // Set-up the invoice details. |
|
146 | - $invoice->set_email( sanitize_email( $submission->get_billing_email() ) ); |
|
147 | - $invoice->set_user_id( $this->get_submission_customer() ); |
|
148 | - $invoice->set_payment_form( absint( $submission->get_payment_form()->get_id() ) ); |
|
145 | + // Set-up the invoice details. |
|
146 | + $invoice->set_email( sanitize_email( $submission->get_billing_email() ) ); |
|
147 | + $invoice->set_user_id( $this->get_submission_customer() ); |
|
148 | + $invoice->set_payment_form( absint( $submission->get_payment_form()->get_id() ) ); |
|
149 | 149 | $invoice->set_items( $items ); |
150 | 150 | $invoice->set_fees( $submission->get_fees() ); |
151 | 151 | $invoice->set_taxes( $submission->get_taxes() ); |
152 | - $invoice->set_discounts( $submission->get_discounts() ); |
|
153 | - $invoice->set_gateway( $data['wpi-gateway'] ); |
|
152 | + $invoice->set_discounts( $submission->get_discounts() ); |
|
153 | + $invoice->set_gateway( $data['wpi-gateway'] ); |
|
154 | 154 | |
155 | - if ( $submission->has_discount_code() ) { |
|
155 | + if ( $submission->has_discount_code() ) { |
|
156 | 156 | $invoice->set_discount_code( $submission->get_discount_code() ); |
157 | - } |
|
158 | - |
|
159 | - getpaid_maybe_add_default_address( $invoice ); |
|
160 | - return $invoice; |
|
161 | - } |
|
162 | - |
|
163 | - /** |
|
164 | - * Retrieves the submission's customer. |
|
165 | - * |
|
166 | - * @return int The customer id. |
|
167 | - */ |
|
168 | - protected function get_submission_customer() { |
|
169 | - $submission = $this->payment_form_submission; |
|
170 | - |
|
171 | - // If this is an existing invoice... |
|
172 | - if ( $submission->has_invoice() ) { |
|
173 | - return $submission->get_invoice()->get_user_id(); |
|
174 | - } |
|
175 | - |
|
176 | - // (Maybe) create the user. |
|
157 | + } |
|
158 | + |
|
159 | + getpaid_maybe_add_default_address( $invoice ); |
|
160 | + return $invoice; |
|
161 | + } |
|
162 | + |
|
163 | + /** |
|
164 | + * Retrieves the submission's customer. |
|
165 | + * |
|
166 | + * @return int The customer id. |
|
167 | + */ |
|
168 | + protected function get_submission_customer() { |
|
169 | + $submission = $this->payment_form_submission; |
|
170 | + |
|
171 | + // If this is an existing invoice... |
|
172 | + if ( $submission->has_invoice() ) { |
|
173 | + return $submission->get_invoice()->get_user_id(); |
|
174 | + } |
|
175 | + |
|
176 | + // (Maybe) create the user. |
|
177 | 177 | $user = get_current_user_id(); |
178 | 178 | |
179 | 179 | if ( empty( $user ) ) { |
@@ -190,31 +190,31 @@ discard block |
||
190 | 190 | |
191 | 191 | if ( is_numeric( $user ) ) { |
192 | 192 | return $user; |
193 | - } |
|
193 | + } |
|
194 | 194 | |
195 | - return $user->ID; |
|
195 | + return $user->ID; |
|
196 | 196 | |
197 | - } |
|
197 | + } |
|
198 | 198 | |
199 | - /** |
|
199 | + /** |
|
200 | 200 | * Prepares submission data for saving to the database. |
201 | 201 | * |
202 | - * @param WPInv_Invoice $invoice |
|
202 | + * @param WPInv_Invoice $invoice |
|
203 | 203 | */ |
204 | 204 | public function prepare_submission_data_for_saving( &$invoice ) { |
205 | 205 | |
206 | - $submission = $this->payment_form_submission; |
|
206 | + $submission = $this->payment_form_submission; |
|
207 | 207 | |
208 | - // Prepared submission details. |
|
208 | + // Prepared submission details. |
|
209 | 209 | $prepared = array(); |
210 | 210 | |
211 | 211 | // Raw submission details. |
212 | - $data = $submission->get_data(); |
|
212 | + $data = $submission->get_data(); |
|
213 | 213 | |
214 | - // Loop throught the submitted details. |
|
214 | + // Loop throught the submitted details. |
|
215 | 215 | foreach ( $submission->get_payment_form()->get_elements() as $field ) { |
216 | 216 | |
217 | - // Skip premade fields. |
|
217 | + // Skip premade fields. |
|
218 | 218 | if ( ! empty( $field['premade'] ) ) { |
219 | 219 | continue; |
220 | 220 | } |
@@ -257,26 +257,26 @@ discard block |
||
257 | 257 | $prepared[ wpinv_clean( $label ) ] = wpinv_clean( $data[ $field['id'] ] ); |
258 | 258 | } |
259 | 259 | |
260 | - } |
|
260 | + } |
|
261 | 261 | |
262 | - return $prepared; |
|
262 | + return $prepared; |
|
263 | 263 | |
264 | - } |
|
264 | + } |
|
265 | 265 | |
266 | - /** |
|
267 | - * Confirms the submission is valid and send users to the gateway. |
|
268 | - * |
|
269 | - * @param WPInv_Invoice $invoice |
|
270 | - * @param array $prepared_payment_form_data |
|
271 | - */ |
|
272 | - protected function post_process_submission( $invoice, $prepared_payment_form_data ) { |
|
266 | + /** |
|
267 | + * Confirms the submission is valid and send users to the gateway. |
|
268 | + * |
|
269 | + * @param WPInv_Invoice $invoice |
|
270 | + * @param array $prepared_payment_form_data |
|
271 | + */ |
|
272 | + protected function post_process_submission( $invoice, $prepared_payment_form_data ) { |
|
273 | 273 | |
274 | - // Ensure the invoice exists. |
|
274 | + // Ensure the invoice exists. |
|
275 | 275 | if ( $invoice->get_id() == 0 ) { |
276 | 276 | wp_send_json_error( __( 'An error occured while saving your invoice.', 'invoicing' ) ); |
277 | 277 | } |
278 | 278 | |
279 | - // Was this invoice created via the payment form? |
|
279 | + // Was this invoice created via the payment form? |
|
280 | 280 | if ( ! $this->payment_form_submission->has_invoice() ) { |
281 | 281 | update_post_meta( $invoice->get_id(), 'wpinv_created_via', 'payment_form' ); |
282 | 282 | } |
@@ -284,20 +284,20 @@ discard block |
||
284 | 284 | // Save payment form data. |
285 | 285 | if ( ! empty( $prepared_payment_form_data ) ) { |
286 | 286 | update_post_meta( $invoice->get_id(), 'payment_form_data', $prepared_payment_form_data ); |
287 | - } |
|
287 | + } |
|
288 | 288 | |
289 | - // Backwards compatibility. |
|
289 | + // Backwards compatibility. |
|
290 | 290 | add_filter( 'wp_redirect', array( $this, 'send_redirect_response' ) ); |
291 | - add_action( 'wpinv_pre_send_back_to_checkout', array( $this, 'checkout_error' ) ); |
|
291 | + add_action( 'wpinv_pre_send_back_to_checkout', array( $this, 'checkout_error' ) ); |
|
292 | 292 | |
293 | - wpinv_process_checkout( $invoice, $this->payment_form_submission ); |
|
293 | + wpinv_process_checkout( $invoice, $this->payment_form_submission ); |
|
294 | 294 | |
295 | 295 | // If we are here, there was an error. |
296 | - $this->checkout_error(); |
|
296 | + $this->checkout_error(); |
|
297 | 297 | |
298 | - } |
|
298 | + } |
|
299 | 299 | |
300 | - /** |
|
300 | + /** |
|
301 | 301 | * Sends a redrect response to payment details. |
302 | 302 | * |
303 | 303 | */ |
@@ -315,10 +315,10 @@ discard block |
||
315 | 315 | // Do we have any errors? |
316 | 316 | if ( wpinv_get_errors() ) { |
317 | 317 | wp_send_json_error( getpaid_get_errors_html() ); |
318 | - } |
|
318 | + } |
|
319 | 319 | |
320 | 320 | wp_send_json_error( __( 'An error occured while processing your payment. Please try again.', 'invoicing' ) ); |
321 | 321 | |
322 | - } |
|
322 | + } |
|
323 | 323 | |
324 | 324 | } |
@@ -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 | * Main Checkout Class. |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @param GetPaid_Payment_Form_Submission $submission |
24 | 24 | */ |
25 | - public function __construct( $submission ) { |
|
25 | + public function __construct($submission) { |
|
26 | 26 | $this->payment_form_submission = $submission; |
27 | 27 | } |
28 | 28 | |
@@ -38,15 +38,15 @@ discard block |
||
38 | 38 | // Get the items and invoice. |
39 | 39 | $items = $this->get_submission_items(); |
40 | 40 | $invoice = $this->get_submission_invoice(); |
41 | - $invoice = $this->process_submission_invoice( $invoice, $items ); |
|
42 | - $prepared = $this->prepare_submission_data_for_saving( $invoice ); |
|
41 | + $invoice = $this->process_submission_invoice($invoice, $items); |
|
42 | + $prepared = $this->prepare_submission_data_for_saving($invoice); |
|
43 | 43 | |
44 | 44 | // Save the invoice. |
45 | 45 | $invoice->recalculate_total(); |
46 | 46 | $invoice->save(); |
47 | 47 | |
48 | 48 | // Send to the gateway. |
49 | - $this->post_process_submission( $invoice, $prepared ); |
|
49 | + $this->post_process_submission($invoice, $prepared); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -59,34 +59,34 @@ discard block |
||
59 | 59 | $data = $submission->get_data(); |
60 | 60 | |
61 | 61 | // Do we have an error? |
62 | - if ( ! empty( $submission->last_error ) ) { |
|
63 | - wp_send_json_error( $submission->last_error ); |
|
62 | + if (!empty($submission->last_error)) { |
|
63 | + wp_send_json_error($submission->last_error); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | // We need a billing email. |
67 | - if ( ! $submission->has_billing_email() || ! is_email( $submission->get_billing_email() ) ) { |
|
68 | - wp_send_json_error( __( 'Provide a valid billing email.', 'invoicing' ) ); |
|
67 | + if (!$submission->has_billing_email() || !is_email($submission->get_billing_email())) { |
|
68 | + wp_send_json_error(__('Provide a valid billing email.', 'invoicing')); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | // Non-recurring gateways should not be allowed to process recurring invoices. |
72 | - if ( $submission->has_recurring && ! wpinv_gateway_support_subscription( $data['wpi-gateway'] ) ) { |
|
73 | - wp_send_json_error( __( 'The selected payment gateway does not support subscription payment.', 'invoicing' ) ); |
|
72 | + if ($submission->has_recurring && !wpinv_gateway_support_subscription($data['wpi-gateway'])) { |
|
73 | + wp_send_json_error(__('The selected payment gateway does not support subscription payment.', 'invoicing')); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | // Ensure the gateway is active. |
77 | - if ( ! wpinv_is_gateway_active( $data['wpi-gateway'] ) ) { |
|
78 | - wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway is not active', 'invoicing' ) ); |
|
77 | + if (!wpinv_is_gateway_active($data['wpi-gateway'])) { |
|
78 | + wpinv_set_error('invalid_gateway', __('The selected payment gateway is not active', 'invoicing')); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | // Clear any existing errors. |
82 | 82 | wpinv_clear_errors(); |
83 | 83 | |
84 | 84 | // Allow themes and plugins to hook to errors |
85 | - do_action( 'getpaid_checkout_error_checks', $submission ); |
|
85 | + do_action('getpaid_checkout_error_checks', $submission); |
|
86 | 86 | |
87 | 87 | // Do we have any errors? |
88 | - if ( wpinv_get_errors() ) { |
|
89 | - wp_send_json_error( getpaid_get_errors_html() ); |
|
88 | + if (wpinv_get_errors()) { |
|
89 | + wp_send_json_error(getpaid_get_errors_html()); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | } |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | $items = $this->payment_form_submission->get_items(); |
102 | 102 | |
103 | 103 | // Ensure that we have items. |
104 | - if ( empty( $items ) && 0 == count( $this->payment_form_submission->get_fees() ) ) { |
|
105 | - wp_send_json_error( __( 'Please select at least one item.', 'invoicing' ) ); |
|
104 | + if (empty($items) && 0 == count($this->payment_form_submission->get_fees())) { |
|
105 | + wp_send_json_error(__('Please select at least one item.', 'invoicing')); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | return $items; |
@@ -116,15 +116,15 @@ discard block |
||
116 | 116 | protected function get_submission_invoice() { |
117 | 117 | $submission = $this->payment_form_submission; |
118 | 118 | |
119 | - if ( ! $submission->has_invoice() ) { |
|
119 | + if (!$submission->has_invoice()) { |
|
120 | 120 | return new WPInv_Invoice(); |
121 | 121 | } |
122 | 122 | |
123 | 123 | $invoice = $submission->get_invoice(); |
124 | 124 | |
125 | 125 | // Make sure that it is neither paid or refunded. |
126 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
127 | - wp_send_json_error( __( 'This invoice has already been paid for.', 'invoicing' ) ); |
|
126 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
127 | + wp_send_json_error(__('This invoice has already been paid for.', 'invoicing')); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | return $invoice; |
@@ -137,26 +137,26 @@ discard block |
||
137 | 137 | * @param GetPaid_Form_Item[] $items |
138 | 138 | * @return WPInv_Invoice |
139 | 139 | */ |
140 | - protected function process_submission_invoice( $invoice, $items ) { |
|
140 | + protected function process_submission_invoice($invoice, $items) { |
|
141 | 141 | |
142 | 142 | $submission = $this->payment_form_submission; |
143 | 143 | $data = $submission->get_data(); |
144 | 144 | |
145 | 145 | // Set-up the invoice details. |
146 | - $invoice->set_email( sanitize_email( $submission->get_billing_email() ) ); |
|
147 | - $invoice->set_user_id( $this->get_submission_customer() ); |
|
148 | - $invoice->set_payment_form( absint( $submission->get_payment_form()->get_id() ) ); |
|
149 | - $invoice->set_items( $items ); |
|
150 | - $invoice->set_fees( $submission->get_fees() ); |
|
151 | - $invoice->set_taxes( $submission->get_taxes() ); |
|
152 | - $invoice->set_discounts( $submission->get_discounts() ); |
|
153 | - $invoice->set_gateway( $data['wpi-gateway'] ); |
|
154 | - |
|
155 | - if ( $submission->has_discount_code() ) { |
|
156 | - $invoice->set_discount_code( $submission->get_discount_code() ); |
|
146 | + $invoice->set_email(sanitize_email($submission->get_billing_email())); |
|
147 | + $invoice->set_user_id($this->get_submission_customer()); |
|
148 | + $invoice->set_payment_form(absint($submission->get_payment_form()->get_id())); |
|
149 | + $invoice->set_items($items); |
|
150 | + $invoice->set_fees($submission->get_fees()); |
|
151 | + $invoice->set_taxes($submission->get_taxes()); |
|
152 | + $invoice->set_discounts($submission->get_discounts()); |
|
153 | + $invoice->set_gateway($data['wpi-gateway']); |
|
154 | + |
|
155 | + if ($submission->has_discount_code()) { |
|
156 | + $invoice->set_discount_code($submission->get_discount_code()); |
|
157 | 157 | } |
158 | 158 | |
159 | - getpaid_maybe_add_default_address( $invoice ); |
|
159 | + getpaid_maybe_add_default_address($invoice); |
|
160 | 160 | return $invoice; |
161 | 161 | } |
162 | 162 | |
@@ -169,26 +169,26 @@ discard block |
||
169 | 169 | $submission = $this->payment_form_submission; |
170 | 170 | |
171 | 171 | // If this is an existing invoice... |
172 | - if ( $submission->has_invoice() ) { |
|
172 | + if ($submission->has_invoice()) { |
|
173 | 173 | return $submission->get_invoice()->get_user_id(); |
174 | 174 | } |
175 | 175 | |
176 | 176 | // (Maybe) create the user. |
177 | 177 | $user = get_current_user_id(); |
178 | 178 | |
179 | - if ( empty( $user ) ) { |
|
180 | - $user = get_user_by( 'email', $submission->get_billing_email() ); |
|
179 | + if (empty($user)) { |
|
180 | + $user = get_user_by('email', $submission->get_billing_email()); |
|
181 | 181 | } |
182 | 182 | |
183 | - if ( empty( $user ) ) { |
|
184 | - $user = wpinv_create_user( $submission->get_billing_email() ); |
|
183 | + if (empty($user)) { |
|
184 | + $user = wpinv_create_user($submission->get_billing_email()); |
|
185 | 185 | } |
186 | 186 | |
187 | - if ( is_wp_error( $user ) ) { |
|
188 | - wp_send_json_error( $user->get_error_message() ); |
|
187 | + if (is_wp_error($user)) { |
|
188 | + wp_send_json_error($user->get_error_message()); |
|
189 | 189 | } |
190 | 190 | |
191 | - if ( is_numeric( $user ) ) { |
|
191 | + if (is_numeric($user)) { |
|
192 | 192 | return $user; |
193 | 193 | } |
194 | 194 | |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | * |
202 | 202 | * @param WPInv_Invoice $invoice |
203 | 203 | */ |
204 | - public function prepare_submission_data_for_saving( &$invoice ) { |
|
204 | + public function prepare_submission_data_for_saving(&$invoice) { |
|
205 | 205 | |
206 | 206 | $submission = $this->payment_form_submission; |
207 | 207 | |
@@ -212,49 +212,49 @@ discard block |
||
212 | 212 | $data = $submission->get_data(); |
213 | 213 | |
214 | 214 | // Loop throught the submitted details. |
215 | - foreach ( $submission->get_payment_form()->get_elements() as $field ) { |
|
215 | + foreach ($submission->get_payment_form()->get_elements() as $field) { |
|
216 | 216 | |
217 | 217 | // Skip premade fields. |
218 | - if ( ! empty( $field['premade'] ) ) { |
|
218 | + if (!empty($field['premade'])) { |
|
219 | 219 | continue; |
220 | 220 | } |
221 | 221 | |
222 | 222 | // If it is required and not set, abort. |
223 | - if ( ! $submission->is_required_field_set( $field ) ) { |
|
224 | - wp_send_json_error( __( 'Some required fields are not set.', 'invoicing' ) ); |
|
223 | + if (!$submission->is_required_field_set($field)) { |
|
224 | + wp_send_json_error(__('Some required fields are not set.', 'invoicing')); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | // Handle address fields. |
228 | - if ( $field['type'] == 'address' ) { |
|
228 | + if ($field['type'] == 'address') { |
|
229 | 229 | |
230 | - foreach ( $field['fields'] as $address_field ) { |
|
230 | + foreach ($field['fields'] as $address_field) { |
|
231 | 231 | |
232 | 232 | // skip if it is not visible. |
233 | - if ( empty( $address_field['visible'] ) ) { |
|
233 | + if (empty($address_field['visible'])) { |
|
234 | 234 | continue; |
235 | 235 | } |
236 | 236 | |
237 | 237 | // If it is required and not set, abort |
238 | - if ( ! empty( $address_field['required'] ) && empty( $data[ $address_field['name'] ] ) ) { |
|
239 | - wp_send_json_error( __( 'Some required fields are not set.', 'invoicing' ) ); |
|
238 | + if (!empty($address_field['required']) && empty($data[$address_field['name']])) { |
|
239 | + wp_send_json_error(__('Some required fields are not set.', 'invoicing')); |
|
240 | 240 | } |
241 | 241 | |
242 | - if ( isset( $data[ $address_field['name'] ] ) ) { |
|
243 | - $name = str_replace( 'wpinv_', '', $address_field['name'] ); |
|
242 | + if (isset($data[$address_field['name']])) { |
|
243 | + $name = str_replace('wpinv_', '', $address_field['name']); |
|
244 | 244 | $method = "set_$name"; |
245 | - $invoice->$method( wpinv_clean( $data[ $address_field['name'] ] ) ); |
|
245 | + $invoice->$method(wpinv_clean($data[$address_field['name']])); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | } |
249 | 249 | |
250 | - } else if ( isset( $data[ $field['id'] ] ) ) { |
|
250 | + } else if (isset($data[$field['id']])) { |
|
251 | 251 | $label = $field['id']; |
252 | 252 | |
253 | - if ( isset( $field['label'] ) ) { |
|
253 | + if (isset($field['label'])) { |
|
254 | 254 | $label = $field['label']; |
255 | 255 | } |
256 | 256 | |
257 | - $prepared[ wpinv_clean( $label ) ] = wpinv_clean( $data[ $field['id'] ] ); |
|
257 | + $prepared[wpinv_clean($label)] = wpinv_clean($data[$field['id']]); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | } |
@@ -269,28 +269,28 @@ discard block |
||
269 | 269 | * @param WPInv_Invoice $invoice |
270 | 270 | * @param array $prepared_payment_form_data |
271 | 271 | */ |
272 | - protected function post_process_submission( $invoice, $prepared_payment_form_data ) { |
|
272 | + protected function post_process_submission($invoice, $prepared_payment_form_data) { |
|
273 | 273 | |
274 | 274 | // Ensure the invoice exists. |
275 | - if ( $invoice->get_id() == 0 ) { |
|
276 | - wp_send_json_error( __( 'An error occured while saving your invoice.', 'invoicing' ) ); |
|
275 | + if ($invoice->get_id() == 0) { |
|
276 | + wp_send_json_error(__('An error occured while saving your invoice.', 'invoicing')); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | // Was this invoice created via the payment form? |
280 | - if ( ! $this->payment_form_submission->has_invoice() ) { |
|
281 | - update_post_meta( $invoice->get_id(), 'wpinv_created_via', 'payment_form' ); |
|
280 | + if (!$this->payment_form_submission->has_invoice()) { |
|
281 | + update_post_meta($invoice->get_id(), 'wpinv_created_via', 'payment_form'); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | // Save payment form data. |
285 | - if ( ! empty( $prepared_payment_form_data ) ) { |
|
286 | - update_post_meta( $invoice->get_id(), 'payment_form_data', $prepared_payment_form_data ); |
|
285 | + if (!empty($prepared_payment_form_data)) { |
|
286 | + update_post_meta($invoice->get_id(), 'payment_form_data', $prepared_payment_form_data); |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | // Backwards compatibility. |
290 | - add_filter( 'wp_redirect', array( $this, 'send_redirect_response' ) ); |
|
291 | - add_action( 'wpinv_pre_send_back_to_checkout', array( $this, 'checkout_error' ) ); |
|
290 | + add_filter('wp_redirect', array($this, 'send_redirect_response')); |
|
291 | + add_action('wpinv_pre_send_back_to_checkout', array($this, 'checkout_error')); |
|
292 | 292 | |
293 | - wpinv_process_checkout( $invoice, $this->payment_form_submission ); |
|
293 | + wpinv_process_checkout($invoice, $this->payment_form_submission); |
|
294 | 294 | |
295 | 295 | // If we are here, there was an error. |
296 | 296 | $this->checkout_error(); |
@@ -301,9 +301,9 @@ discard block |
||
301 | 301 | * Sends a redrect response to payment details. |
302 | 302 | * |
303 | 303 | */ |
304 | - public function send_redirect_response( $url ) { |
|
305 | - $url = urlencode( $url ); |
|
306 | - wp_send_json_success( $url ); |
|
304 | + public function send_redirect_response($url) { |
|
305 | + $url = urlencode($url); |
|
306 | + wp_send_json_success($url); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | /** |
@@ -313,11 +313,11 @@ discard block |
||
313 | 313 | public function checkout_error() { |
314 | 314 | |
315 | 315 | // Do we have any errors? |
316 | - if ( wpinv_get_errors() ) { |
|
317 | - wp_send_json_error( getpaid_get_errors_html() ); |
|
316 | + if (wpinv_get_errors()) { |
|
317 | + wp_send_json_error(getpaid_get_errors_html()); |
|
318 | 318 | } |
319 | 319 | |
320 | - wp_send_json_error( __( 'An error occured while processing your payment. Please try again.', 'invoicing' ) ); |
|
320 | + wp_send_json_error(__('An error occured while processing your payment. Please try again.', 'invoicing')); |
|
321 | 321 | |
322 | 322 | } |
323 | 323 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
3 | +if (!defined('ABSPATH')) { |
|
4 | 4 | exit; // Exit if accessed directly |
5 | 5 | } |
6 | 6 | |
@@ -13,15 +13,15 @@ discard block |
||
13 | 13 | |
14 | 14 | public function __construct() { |
15 | 15 | |
16 | - foreach( $this->get_elements() as $element ) { |
|
16 | + foreach ($this->get_elements() as $element) { |
|
17 | 17 | $element = $element['type']; |
18 | 18 | |
19 | - if ( method_exists( $this, "render_{$element}_template" ) ) { |
|
20 | - add_action( 'wpinv_payment_form_render_element_template', array( $this, "render_{$element}_template" ), 10, 2 ); |
|
19 | + if (method_exists($this, "render_{$element}_template")) { |
|
20 | + add_action('wpinv_payment_form_render_element_template', array($this, "render_{$element}_template"), 10, 2); |
|
21 | 21 | } |
22 | 22 | |
23 | - if ( method_exists( $this, "edit_{$element}_template" ) ) { |
|
24 | - add_action( 'wpinv_payment_form_edit_element_template', array( $this, "edit_{$element}_template" ), 10, 2 ); |
|
23 | + if (method_exists($this, "edit_{$element}_template")) { |
|
24 | + add_action('wpinv_payment_form_edit_element_template', array($this, "edit_{$element}_template"), 10, 2); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | |
@@ -34,20 +34,20 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function get_elements() { |
36 | 36 | |
37 | - if ( ! empty( $this->elements ) ) { |
|
37 | + if (!empty($this->elements)) { |
|
38 | 38 | return $this->elements; |
39 | 39 | } |
40 | 40 | |
41 | - $this->elements = wpinv_get_data( 'payment-form-elements' ); |
|
41 | + $this->elements = wpinv_get_data('payment-form-elements'); |
|
42 | 42 | |
43 | - $this->elements = apply_filters( 'wpinv_filter_core_payment_form_elements', $this->elements ); |
|
43 | + $this->elements = apply_filters('wpinv_filter_core_payment_form_elements', $this->elements); |
|
44 | 44 | return $this->elements; |
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
48 | 48 | * Returns the restrict markup. |
49 | 49 | */ |
50 | - public function get_restrict_markup( $field, $field_type ) { |
|
50 | + public function get_restrict_markup($field, $field_type) { |
|
51 | 51 | $restrict = "$field.type=='$field_type'"; |
52 | 52 | return "v-if=\"$restrict\""; |
53 | 53 | } |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | /** |
56 | 56 | * Renders the gateway select element template. |
57 | 57 | */ |
58 | - public function render_gateway_select_template( $field ) { |
|
59 | - $restrict = $this->get_restrict_markup( $field, 'gateway_select' ); |
|
60 | - $text = __( 'The gateway select box will appear hear', 'invoicing' ); |
|
58 | + public function render_gateway_select_template($field) { |
|
59 | + $restrict = $this->get_restrict_markup($field, 'gateway_select'); |
|
60 | + $text = __('The gateway select box will appear hear', 'invoicing'); |
|
61 | 61 | echo " |
62 | 62 | <div $restrict class='alert alert-info' role='alert'> |
63 | 63 | <span>$text</span> |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | /** |
69 | 69 | * Renders the edit gateway select element template. |
70 | 70 | */ |
71 | - public function edit_gateway_select_template( $field ) { |
|
72 | - $restrict = $this->get_restrict_markup( $field, 'gateway_select' ); |
|
73 | - $label = __( 'The gateway select text', 'invoicing' ); |
|
71 | + public function edit_gateway_select_template($field) { |
|
72 | + $restrict = $this->get_restrict_markup($field, 'gateway_select'); |
|
73 | + $label = __('The gateway select text', 'invoicing'); |
|
74 | 74 | $id = $field . '.id + "_edit"'; |
75 | 75 | echo " |
76 | 76 | <div $restrict> |
@@ -86,10 +86,10 @@ discard block |
||
86 | 86 | /** |
87 | 87 | * Renders the ip address element template. |
88 | 88 | */ |
89 | - public function render_ip_address_template( $field ) { |
|
90 | - $restrict = $this->get_restrict_markup( $field, 'ip_address' ); |
|
91 | - $ip_address = sanitize_text_field( wpinv_get_ip() ); |
|
92 | - $url = esc_url( getpaid_ip_location_url( $ip_address ) ); |
|
89 | + public function render_ip_address_template($field) { |
|
90 | + $restrict = $this->get_restrict_markup($field, 'ip_address'); |
|
91 | + $ip_address = sanitize_text_field(wpinv_get_ip()); |
|
92 | + $url = esc_url(getpaid_ip_location_url($ip_address)); |
|
93 | 93 | |
94 | 94 | echo " |
95 | 95 | <div $restrict class='getpaid-ip-info'> |
@@ -102,9 +102,9 @@ discard block |
||
102 | 102 | /** |
103 | 103 | * Renders the edit ip address element template. |
104 | 104 | */ |
105 | - public function edit_ip_address_template( $field ) { |
|
106 | - $restrict = $this->get_restrict_markup( $field, 'ip_address' ); |
|
107 | - $label = __( 'The IP Address text', 'invoicing' ); |
|
105 | + public function edit_ip_address_template($field) { |
|
106 | + $restrict = $this->get_restrict_markup($field, 'ip_address'); |
|
107 | + $label = __('The IP Address text', 'invoicing'); |
|
108 | 108 | $id = $field . '.id + "_edit"'; |
109 | 109 | echo " |
110 | 110 | <div $restrict> |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | /** |
121 | 121 | * Renders the total payable element template. |
122 | 122 | */ |
123 | - public function render_total_payable_template( $field ) { |
|
124 | - $restrict = $this->get_restrict_markup( $field, 'total_payable' ); |
|
125 | - $text = __( 'The total payable amount will appear here', 'invoicing' ); |
|
123 | + public function render_total_payable_template($field) { |
|
124 | + $restrict = $this->get_restrict_markup($field, 'total_payable'); |
|
125 | + $text = __('The total payable amount will appear here', 'invoicing'); |
|
126 | 126 | echo " |
127 | 127 | <div $restrict class='alert alert-info' role='alert'> |
128 | 128 | <span>$text</span> |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | /** |
134 | 134 | * Renders the edit total payable element template. |
135 | 135 | */ |
136 | - public function edit_total_payable_template( $field ) { |
|
137 | - $restrict = $this->get_restrict_markup( $field, 'total_payable' ); |
|
138 | - $label = __( 'The total payable text', 'invoicing' ); |
|
136 | + public function edit_total_payable_template($field) { |
|
137 | + $restrict = $this->get_restrict_markup($field, 'total_payable'); |
|
138 | + $label = __('The total payable text', 'invoicing'); |
|
139 | 139 | $id = $field . '.id + "_edit"'; |
140 | 140 | echo " |
141 | 141 | <div $restrict> |
@@ -151,18 +151,18 @@ discard block |
||
151 | 151 | /** |
152 | 152 | * Renders the title element template. |
153 | 153 | */ |
154 | - public function render_heading_template( $field ) { |
|
155 | - $restrict = $this->get_restrict_markup( $field, 'heading' ); |
|
154 | + public function render_heading_template($field) { |
|
155 | + $restrict = $this->get_restrict_markup($field, 'heading'); |
|
156 | 156 | echo "<component :is='$field.level' $restrict v-html='$field.text'></component>"; |
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
160 | 160 | * Renders the edit title element template. |
161 | 161 | */ |
162 | - public function edit_heading_template( $field ) { |
|
163 | - $restrict = $this->get_restrict_markup( $field, 'heading' ); |
|
164 | - $label = __( 'Heading', 'invoicing' ); |
|
165 | - $label2 = __( 'Select Heading Level', 'invoicing' ); |
|
162 | + public function edit_heading_template($field) { |
|
163 | + $restrict = $this->get_restrict_markup($field, 'heading'); |
|
164 | + $label = __('Heading', 'invoicing'); |
|
165 | + $label2 = __('Select Heading Level', 'invoicing'); |
|
166 | 166 | $id = $field . '.id + "_edit"'; |
167 | 167 | $id2 = $field . '.id + "_edit2"'; |
168 | 168 | |
@@ -194,8 +194,8 @@ discard block |
||
194 | 194 | /** |
195 | 195 | * Renders a paragraph element template. |
196 | 196 | */ |
197 | - public function render_paragraph_template( $field ) { |
|
198 | - $restrict = $this->get_restrict_markup( $field, 'paragraph' ); |
|
197 | + public function render_paragraph_template($field) { |
|
198 | + $restrict = $this->get_restrict_markup($field, 'paragraph'); |
|
199 | 199 | $label = "$field.text"; |
200 | 200 | echo "<p $restrict v-html='$label' style='font-size: 16px;'></p>"; |
201 | 201 | } |
@@ -203,9 +203,9 @@ discard block |
||
203 | 203 | /** |
204 | 204 | * Renders the edit paragraph element template. |
205 | 205 | */ |
206 | - public function edit_paragraph_template( $field ) { |
|
207 | - $restrict = $this->get_restrict_markup( $field, 'paragraph' ); |
|
208 | - $label = __( 'Enter your text', 'invoicing' ); |
|
206 | + public function edit_paragraph_template($field) { |
|
207 | + $restrict = $this->get_restrict_markup($field, 'paragraph'); |
|
208 | + $label = __('Enter your text', 'invoicing'); |
|
209 | 209 | $id = $field . '.id + "_edit"'; |
210 | 210 | echo " |
211 | 211 | <div $restrict> |
@@ -221,8 +221,8 @@ discard block |
||
221 | 221 | /** |
222 | 222 | * Renders the text element template. |
223 | 223 | */ |
224 | - public function render_text_template( $field ) { |
|
225 | - $restrict = $this->get_restrict_markup( $field, 'text' ); |
|
224 | + public function render_text_template($field) { |
|
225 | + $restrict = $this->get_restrict_markup($field, 'text'); |
|
226 | 226 | $label = "$field.label"; |
227 | 227 | echo " |
228 | 228 | <div $restrict class='wpinv-payment-form-field-preview'> |
@@ -237,56 +237,56 @@ discard block |
||
237 | 237 | /** |
238 | 238 | * Renders the edit price select element template. |
239 | 239 | */ |
240 | - public function edit_price_select_template( $field ) { |
|
241 | - $restrict = $this->get_restrict_markup( $field, 'price_select' ); |
|
240 | + public function edit_price_select_template($field) { |
|
241 | + $restrict = $this->get_restrict_markup($field, 'price_select'); |
|
242 | 242 | |
243 | - $label3 = __( 'Help text', 'invoicing' ); |
|
244 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
243 | + $label3 = __('Help text', 'invoicing'); |
|
244 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
245 | 245 | $id3 = $field . '.id + "_edit3"'; |
246 | - $label6 = __( 'Options', 'invoicing' ); |
|
246 | + $label6 = __('Options', 'invoicing'); |
|
247 | 247 | $id6 = $field . '.id + "_edit5"'; |
248 | 248 | ?> |
249 | 249 | <div <?php echo $restrict; ?>> |
250 | - <small class='form-text text-muted mb-2'><?php _e( 'This amount will be added to the total amount for this form', 'invoicing' ); ?></small> |
|
250 | + <small class='form-text text-muted mb-2'><?php _e('This amount will be added to the total amount for this form', 'invoicing'); ?></small> |
|
251 | 251 | <div class='form-group'> |
252 | 252 | <label class="d-block"> |
253 | - <span><?php _e( 'Field Label', 'invoicing' ); ?></span> |
|
253 | + <span><?php _e('Field Label', 'invoicing'); ?></span> |
|
254 | 254 | <input v-model='<?php echo $field; ?>.label' class='form-control' /> |
255 | 255 | </label> |
256 | 256 | </div> |
257 | 257 | |
258 | 258 | <div class='form-group' v-if="<?php echo $field; ?>.select_type=='select'"> |
259 | 259 | <label class="d-block"> |
260 | - <span><?php _e( 'Placeholder text', 'invoicing' ); ?></span> |
|
260 | + <span><?php _e('Placeholder text', 'invoicing'); ?></span> |
|
261 | 261 | <input v-model='<?php echo $field; ?>.placeholder' class='form-control' /> |
262 | 262 | </label> |
263 | 263 | </div> |
264 | 264 | |
265 | 265 | <div class='form-group'> |
266 | 266 | <label class="d-block"> |
267 | - <span><?php _e( 'Select Type', 'invoicing' ); ?></span> |
|
267 | + <span><?php _e('Select Type', 'invoicing'); ?></span> |
|
268 | 268 | <select class='form-control custom-select' v-model='<?php echo $field; ?>.select_type'> |
269 | - <option value='select'><?php _e( 'Dropdown', 'invoicing' ) ?></option> |
|
270 | - <option value='checkboxes'><?php _e( 'Checkboxes', 'invoicing' ) ?></option> |
|
271 | - <option value='radios'><?php _e( 'Radio Buttons', 'invoicing' ) ?></option> |
|
272 | - <option value='buttons'><?php _e( 'Buttons', 'invoicing' ) ?></option> |
|
273 | - <option value='circles'><?php _e( 'Circles', 'invoicing' ) ?></option> |
|
269 | + <option value='select'><?php _e('Dropdown', 'invoicing') ?></option> |
|
270 | + <option value='checkboxes'><?php _e('Checkboxes', 'invoicing') ?></option> |
|
271 | + <option value='radios'><?php _e('Radio Buttons', 'invoicing') ?></option> |
|
272 | + <option value='buttons'><?php _e('Buttons', 'invoicing') ?></option> |
|
273 | + <option value='circles'><?php _e('Circles', 'invoicing') ?></option> |
|
274 | 274 | </select> |
275 | 275 | </label> |
276 | 276 | </div> |
277 | 277 | |
278 | 278 | <div class='form-group'> |
279 | 279 | <label class="d-block"> |
280 | - <span><?php _e( 'Options', 'invoicing' ); ?></span> |
|
280 | + <span><?php _e('Options', 'invoicing'); ?></span> |
|
281 | 281 | <textarea placeholder='Basic|10,Pro|99,Business|199' v-model='<?php echo $field; ?>.options' class='form-control' rows='3'></textarea> |
282 | - <small class='form-text text-muted mb-2'><?php _e( 'Use commas to separate options and pipes to separate a label and its price. Do not include a currency symbol in the price.', 'invoicing' ); ?></small> |
|
282 | + <small class='form-text text-muted mb-2'><?php _e('Use commas to separate options and pipes to separate a label and its price. Do not include a currency symbol in the price.', 'invoicing'); ?></small> |
|
283 | 283 | </label> |
284 | 284 | </div> |
285 | 285 | |
286 | 286 | <div class='form-group'> |
287 | 287 | <label class="d-block"> |
288 | - <span><?php _e( 'Help Text', 'invoicing' ); ?></span> |
|
289 | - <textarea placeholder='<?php esc_attr_e( 'Add some help text for this field', 'invoicing' ); ?>' v-model='<?php echo $field; ?>.description' class='form-control' rows='3'></textarea> |
|
288 | + <span><?php _e('Help Text', 'invoicing'); ?></span> |
|
289 | + <textarea placeholder='<?php esc_attr_e('Add some help text for this field', 'invoicing'); ?>' v-model='<?php echo $field; ?>.description' class='form-control' rows='3'></textarea> |
|
290 | 290 | </label> |
291 | 291 | </div> |
292 | 292 | </div> |
@@ -297,8 +297,8 @@ discard block |
||
297 | 297 | /** |
298 | 298 | * Renders the price select element template. |
299 | 299 | */ |
300 | - public function render_price_select_template( $field ) { |
|
301 | - $restrict = $this->get_restrict_markup( $field, 'price_select' ); |
|
300 | + public function render_price_select_template($field) { |
|
301 | + $restrict = $this->get_restrict_markup($field, 'price_select'); |
|
302 | 302 | ?> |
303 | 303 | <div <?php echo $restrict; ?> class='wpinv-payment-form-field-preview'> |
304 | 304 | <div class='wpinv-payment-form-field-preview-overlay'></div> |
@@ -306,24 +306,24 @@ discard block |
||
306 | 306 | <label>{{<?php echo $field; ?>.label}}</label> |
307 | 307 | |
308 | 308 | <!-- Buttons --> |
309 | - <div v-if='<?php echo esc_attr( $field ); ?>.select_type=="buttons"' class="getpaid-price-buttons"> |
|
310 | - <span v-for="(option, index) in <?php echo esc_attr( $field ); ?>.options.split(',')" :key="index"> |
|
311 | - <input type="radio" :id="<?php echo esc_attr( $field ); ?>.id + index" :checked="index==0" /> |
|
312 | - <label :for="<?php echo esc_attr( $field ); ?>.id + index" class="rounded">{{option | optionize}}</label> |
|
309 | + <div v-if='<?php echo esc_attr($field); ?>.select_type=="buttons"' class="getpaid-price-buttons"> |
|
310 | + <span v-for="(option, index) in <?php echo esc_attr($field); ?>.options.split(',')" :key="index"> |
|
311 | + <input type="radio" :id="<?php echo esc_attr($field); ?>.id + index" :checked="index==0" /> |
|
312 | + <label :for="<?php echo esc_attr($field); ?>.id + index" class="rounded">{{option | optionize}}</label> |
|
313 | 313 | </span> |
314 | 314 | </div> |
315 | 315 | |
316 | 316 | <!-- Circles --> |
317 | - <div v-if='<?php echo esc_attr( $field ); ?>.select_type=="circles"' class="getpaid-price-buttons getpaid-price-circles"> |
|
318 | - <span v-for="(option, index) in <?php echo esc_attr( $field ); ?>.options.split(',')" :key="index"> |
|
319 | - <input type="radio" :id="<?php echo esc_attr( $field ); ?>.id + index" :checked="index==0" /> |
|
320 | - <label :for="<?php echo esc_attr( $field ); ?>.id + index"><span>{{option | optionize}}</span></label> |
|
317 | + <div v-if='<?php echo esc_attr($field); ?>.select_type=="circles"' class="getpaid-price-buttons getpaid-price-circles"> |
|
318 | + <span v-for="(option, index) in <?php echo esc_attr($field); ?>.options.split(',')" :key="index"> |
|
319 | + <input type="radio" :id="<?php echo esc_attr($field); ?>.id + index" :checked="index==0" /> |
|
320 | + <label :for="<?php echo esc_attr($field); ?>.id + index"><span>{{option | optionize}}</span></label> |
|
321 | 321 | </span> |
322 | 322 | </div> |
323 | 323 | |
324 | 324 | <!-- Radios --> |
325 | - <div v-if='<?php echo esc_attr( $field ); ?>.select_type=="radios"'> |
|
326 | - <div v-for="(option, index) in <?php echo esc_attr( $field ); ?>.options.split(',')" :key="index"> |
|
325 | + <div v-if='<?php echo esc_attr($field); ?>.select_type=="radios"'> |
|
326 | + <div v-for="(option, index) in <?php echo esc_attr($field); ?>.options.split(',')" :key="index"> |
|
327 | 327 | <label> |
328 | 328 | <input type="radio" :checked="index==0" /> |
329 | 329 | <span>{{option | optionize}}</span> |
@@ -332,8 +332,8 @@ discard block |
||
332 | 332 | </div> |
333 | 333 | |
334 | 334 | <!-- Checkboxes --> |
335 | - <div v-if='<?php echo esc_attr( $field ); ?>.select_type=="checkboxes"'> |
|
336 | - <div v-for="(option, index) in <?php echo esc_attr( $field ); ?>.options.split(',')" :key="index"> |
|
335 | + <div v-if='<?php echo esc_attr($field); ?>.select_type=="checkboxes"'> |
|
336 | + <div v-for="(option, index) in <?php echo esc_attr($field); ?>.options.split(',')" :key="index"> |
|
337 | 337 | <label> |
338 | 338 | <input type="checkbox" :checked="index==0" /> |
339 | 339 | <span>{{option | optionize}}</span> |
@@ -342,15 +342,15 @@ discard block |
||
342 | 342 | </div> |
343 | 343 | |
344 | 344 | <!-- Select --> |
345 | - <select v-if='<?php echo esc_attr( $field ); ?>.select_type=="select"' class='form-control custom-select'> |
|
346 | - <option v-if="<?php echo esc_attr( $field ); ?>.placeholder" selected="selected"> |
|
347 | - {{<?php echo esc_attr( $field ); ?>.placeholder}} |
|
345 | + <select v-if='<?php echo esc_attr($field); ?>.select_type=="select"' class='form-control custom-select'> |
|
346 | + <option v-if="<?php echo esc_attr($field); ?>.placeholder" selected="selected"> |
|
347 | + {{<?php echo esc_attr($field); ?>.placeholder}} |
|
348 | 348 | </option> |
349 | - <option v-for="(option, index) in <?php echo esc_attr( $field ); ?>.options.split(',')" :key="index"> |
|
349 | + <option v-for="(option, index) in <?php echo esc_attr($field); ?>.options.split(',')" :key="index"> |
|
350 | 350 | {{option | optionize}} |
351 | 351 | </option> |
352 | 352 | </select> |
353 | - <small v-if='<?php echo esc_attr( $field ); ?>.description' class='form-text text-muted' v-html='<?php echo esc_attr( $field ); ?>.description'></small> |
|
353 | + <small v-if='<?php echo esc_attr($field); ?>.description' class='form-text text-muted' v-html='<?php echo esc_attr($field); ?>.description'></small> |
|
354 | 354 | </div> |
355 | 355 | |
356 | 356 | <?php |
@@ -359,17 +359,17 @@ discard block |
||
359 | 359 | /** |
360 | 360 | * Renders the edit price input element template. |
361 | 361 | */ |
362 | - public function edit_price_input_template( $field ) { |
|
363 | - $restrict = $this->get_restrict_markup( $field, 'price_input' ); |
|
364 | - $label = __( 'Field Label', 'invoicing' ); |
|
362 | + public function edit_price_input_template($field) { |
|
363 | + $restrict = $this->get_restrict_markup($field, 'price_input'); |
|
364 | + $label = __('Field Label', 'invoicing'); |
|
365 | 365 | $id = $field . '.id + "_edit"'; |
366 | - $label2 = __( 'Placeholder text', 'invoicing' ); |
|
366 | + $label2 = __('Placeholder text', 'invoicing'); |
|
367 | 367 | $id2 = $field . '.id + "_edit2"'; |
368 | - $label3 = __( 'Help text', 'invoicing' ); |
|
369 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
368 | + $label3 = __('Help text', 'invoicing'); |
|
369 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
370 | 370 | $id3 = $field . '.id + "_edit3"'; |
371 | - $label5 = __( 'The amount that users add to this field will be added to the total amount', 'invoicing' ); |
|
372 | - $label6 = __( 'Default Amount', 'invoicing' ); |
|
371 | + $label5 = __('The amount that users add to this field will be added to the total amount', 'invoicing'); |
|
372 | + $label6 = __('Default Amount', 'invoicing'); |
|
373 | 373 | $id6 = $field . '.id + "_edit5"'; |
374 | 374 | echo " |
375 | 375 | <div $restrict> |
@@ -397,16 +397,16 @@ discard block |
||
397 | 397 | /** |
398 | 398 | * Renders the edit text element template. |
399 | 399 | */ |
400 | - public function edit_text_template( $field ) { |
|
401 | - $restrict = $this->get_restrict_markup( $field, 'text' ); |
|
402 | - $label = __( 'Field Label', 'invoicing' ); |
|
400 | + public function edit_text_template($field) { |
|
401 | + $restrict = $this->get_restrict_markup($field, 'text'); |
|
402 | + $label = __('Field Label', 'invoicing'); |
|
403 | 403 | $id = $field . '.id + "_edit"'; |
404 | - $label2 = __( 'Placeholder text', 'invoicing' ); |
|
404 | + $label2 = __('Placeholder text', 'invoicing'); |
|
405 | 405 | $id2 = $field . '.id + "_edit2"'; |
406 | - $label3 = __( 'Help text', 'invoicing' ); |
|
407 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
406 | + $label3 = __('Help text', 'invoicing'); |
|
407 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
408 | 408 | $id3 = $field . '.id + "_edit3"'; |
409 | - $label5 = __( 'Is this field required?', 'invoicing' ); |
|
409 | + $label5 = __('Is this field required?', 'invoicing'); |
|
410 | 410 | $id4 = $field . '.id + "_edit4"'; |
411 | 411 | echo " |
412 | 412 | <div $restrict> |
@@ -434,8 +434,8 @@ discard block |
||
434 | 434 | /** |
435 | 435 | * Renders the textarea element template. |
436 | 436 | */ |
437 | - public function render_textarea_template( $field ) { |
|
438 | - $restrict = $this->get_restrict_markup( $field, 'textarea' ); |
|
437 | + public function render_textarea_template($field) { |
|
438 | + $restrict = $this->get_restrict_markup($field, 'textarea'); |
|
439 | 439 | $label = "$field.label"; |
440 | 440 | echo " |
441 | 441 | <div $restrict class='wpinv-payment-form-field-preview'> |
@@ -450,16 +450,16 @@ discard block |
||
450 | 450 | /** |
451 | 451 | * Renders the edit textarea element template. |
452 | 452 | */ |
453 | - public function edit_textarea_template( $field ) { |
|
454 | - $restrict = $this->get_restrict_markup( $field, 'textarea' ); |
|
455 | - $label = __( 'Field Label', 'invoicing' ); |
|
453 | + public function edit_textarea_template($field) { |
|
454 | + $restrict = $this->get_restrict_markup($field, 'textarea'); |
|
455 | + $label = __('Field Label', 'invoicing'); |
|
456 | 456 | $id = $field . '.id + "_edit"'; |
457 | - $label2 = __( 'Placeholder text', 'invoicing' ); |
|
457 | + $label2 = __('Placeholder text', 'invoicing'); |
|
458 | 458 | $id2 = $field . '.id + "_edit2"'; |
459 | - $label3 = __( 'Help text', 'invoicing' ); |
|
460 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
459 | + $label3 = __('Help text', 'invoicing'); |
|
460 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
461 | 461 | $id3 = $field . '.id + "_edit3"'; |
462 | - $label5 = __( 'Is this field required?', 'invoicing' ); |
|
462 | + $label5 = __('Is this field required?', 'invoicing'); |
|
463 | 463 | $id4 = $field . '.id + "_edit4"'; |
464 | 464 | echo " |
465 | 465 | <div $restrict> |
@@ -487,8 +487,8 @@ discard block |
||
487 | 487 | /** |
488 | 488 | * Renders the select element template. |
489 | 489 | */ |
490 | - public function render_select_template( $field ) { |
|
491 | - $restrict = $this->get_restrict_markup( $field, 'select' ); |
|
490 | + public function render_select_template($field) { |
|
491 | + $restrict = $this->get_restrict_markup($field, 'select'); |
|
492 | 492 | $label = "$field.label"; |
493 | 493 | $placeholder = "$field.placeholder"; |
494 | 494 | $id = $field . '.id'; |
@@ -508,18 +508,18 @@ discard block |
||
508 | 508 | /** |
509 | 509 | * Renders the edit select element template. |
510 | 510 | */ |
511 | - public function edit_select_template( $field ) { |
|
512 | - $restrict = $this->get_restrict_markup( $field, 'select' ); |
|
513 | - $label = __( 'Field Label', 'invoicing' ); |
|
511 | + public function edit_select_template($field) { |
|
512 | + $restrict = $this->get_restrict_markup($field, 'select'); |
|
513 | + $label = __('Field Label', 'invoicing'); |
|
514 | 514 | $id = $field . '.id + "_edit"'; |
515 | - $label2 = __( 'Placeholder text', 'invoicing' ); |
|
515 | + $label2 = __('Placeholder text', 'invoicing'); |
|
516 | 516 | $id2 = $field . '.id + "_edit2"'; |
517 | - $label3 = __( 'Help text', 'invoicing' ); |
|
518 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
517 | + $label3 = __('Help text', 'invoicing'); |
|
518 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
519 | 519 | $id3 = $field . '.id + "_edit3"'; |
520 | - $label5 = __( 'Is this field required?', 'invoicing' ); |
|
520 | + $label5 = __('Is this field required?', 'invoicing'); |
|
521 | 521 | $id4 = $field . '.id + "_edit4"'; |
522 | - $label6 = __( 'Available Options', 'invoicing' ); |
|
522 | + $label6 = __('Available Options', 'invoicing'); |
|
523 | 523 | echo " |
524 | 524 | <div $restrict> |
525 | 525 | <div class='form-group'> |
@@ -557,8 +557,8 @@ discard block |
||
557 | 557 | /** |
558 | 558 | * Renders the checkbox element template. |
559 | 559 | */ |
560 | - public function render_checkbox_template( $field ) { |
|
561 | - $restrict = $this->get_restrict_markup( $field, 'checkbox' ); |
|
560 | + public function render_checkbox_template($field) { |
|
561 | + $restrict = $this->get_restrict_markup($field, 'checkbox'); |
|
562 | 562 | echo " |
563 | 563 | <div class='form-check' $restrict> |
564 | 564 | <div class='wpinv-payment-form-field-preview-overlay'></div> |
@@ -572,14 +572,14 @@ discard block |
||
572 | 572 | /** |
573 | 573 | * Renders the edit checkbox element template. |
574 | 574 | */ |
575 | - public function edit_checkbox_template( $field ) { |
|
576 | - $restrict = $this->get_restrict_markup( $field, 'checkbox' ); |
|
577 | - $label = __( 'Field Label', 'invoicing' ); |
|
575 | + public function edit_checkbox_template($field) { |
|
576 | + $restrict = $this->get_restrict_markup($field, 'checkbox'); |
|
577 | + $label = __('Field Label', 'invoicing'); |
|
578 | 578 | $id = $field . '.id + "_edit"'; |
579 | - $label2 = __( 'Help text', 'invoicing' ); |
|
580 | - $label3 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
579 | + $label2 = __('Help text', 'invoicing'); |
|
580 | + $label3 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
581 | 581 | $id2 = $field . '.id + "_edit2"'; |
582 | - $label4 = __( 'Is this field required?', 'invoicing' ); |
|
582 | + $label4 = __('Is this field required?', 'invoicing'); |
|
583 | 583 | $id3 = $field . '.id + "_edit3"'; |
584 | 584 | echo " |
585 | 585 | <div $restrict> |
@@ -603,8 +603,8 @@ discard block |
||
603 | 603 | /** |
604 | 604 | * Renders the radio element template. |
605 | 605 | */ |
606 | - public function render_radio_template( $field ) { |
|
607 | - $restrict = $this->get_restrict_markup( $field, 'radio' ); |
|
606 | + public function render_radio_template($field) { |
|
607 | + $restrict = $this->get_restrict_markup($field, 'radio'); |
|
608 | 608 | $label = "$field.label"; |
609 | 609 | $id = $field . '.id'; |
610 | 610 | echo " |
@@ -623,16 +623,16 @@ discard block |
||
623 | 623 | /** |
624 | 624 | * Renders the edit radio element template. |
625 | 625 | */ |
626 | - public function edit_radio_template( $field ) { |
|
627 | - $restrict = $this->get_restrict_markup( $field, 'radio' ); |
|
628 | - $label = __( 'Field Label', 'invoicing' ); |
|
626 | + public function edit_radio_template($field) { |
|
627 | + $restrict = $this->get_restrict_markup($field, 'radio'); |
|
628 | + $label = __('Field Label', 'invoicing'); |
|
629 | 629 | $id = $field . '.id + "_edit"'; |
630 | - $label2 = __( 'Help text', 'invoicing' ); |
|
631 | - $label3 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
630 | + $label2 = __('Help text', 'invoicing'); |
|
631 | + $label3 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
632 | 632 | $id2 = $field . '.id + "_edit3"'; |
633 | - $label4 = __( 'Is this field required?', 'invoicing' ); |
|
633 | + $label4 = __('Is this field required?', 'invoicing'); |
|
634 | 634 | $id3 = $field . '.id + "_edit4"'; |
635 | - $label5 = __( 'Available Options', 'invoicing' ); |
|
635 | + $label5 = __('Available Options', 'invoicing'); |
|
636 | 636 | echo " |
637 | 637 | <div $restrict> |
638 | 638 | <div class='form-group'> |
@@ -666,8 +666,8 @@ discard block |
||
666 | 666 | /** |
667 | 667 | * Renders the address element template. |
668 | 668 | */ |
669 | - public function render_address_template( $field ) { |
|
670 | - $restrict = $this->get_restrict_markup( $field, 'address' ); |
|
669 | + public function render_address_template($field) { |
|
670 | + $restrict = $this->get_restrict_markup($field, 'address'); |
|
671 | 671 | |
672 | 672 | echo " |
673 | 673 | <div class='wpinv-address-wrapper' $restrict> |
@@ -689,13 +689,13 @@ discard block |
||
689 | 689 | /** |
690 | 690 | * Renders the edit address element template. |
691 | 691 | */ |
692 | - public function edit_address_template( $field ) { |
|
693 | - $restrict = $this->get_restrict_markup( $field, 'address' ); |
|
694 | - $label = __( 'Field Label', 'invoicing' ); |
|
695 | - $label2 = __( 'Placeholder', 'invoicing' ); |
|
696 | - $label3 = __( 'Description', 'invoicing' ); |
|
697 | - $label4 = __( 'Is required', 'invoicing' ); |
|
698 | - $label5 = __( 'Is visible', 'invoicing' ); |
|
692 | + public function edit_address_template($field) { |
|
693 | + $restrict = $this->get_restrict_markup($field, 'address'); |
|
694 | + $label = __('Field Label', 'invoicing'); |
|
695 | + $label2 = __('Placeholder', 'invoicing'); |
|
696 | + $label3 = __('Description', 'invoicing'); |
|
697 | + $label4 = __('Is required', 'invoicing'); |
|
698 | + $label5 = __('Is visible', 'invoicing'); |
|
699 | 699 | $id = $field . '.id + "_edit_label"'; |
700 | 700 | $id2 = $field . '.id + "_edit_placeholder"'; |
701 | 701 | $id3 = $field . '.id + "_edit_description"'; |
@@ -763,8 +763,8 @@ discard block |
||
763 | 763 | /** |
764 | 764 | * Renders the email element template. |
765 | 765 | */ |
766 | - public function render_email_template( $field ) { |
|
767 | - $restrict = $this->get_restrict_markup( $field, 'email' ); |
|
766 | + public function render_email_template($field) { |
|
767 | + $restrict = $this->get_restrict_markup($field, 'email'); |
|
768 | 768 | $label = "$field.label"; |
769 | 769 | echo " |
770 | 770 | <div $restrict class='wpinv-payment-form-field-preview'> |
@@ -779,8 +779,8 @@ discard block |
||
779 | 779 | /** |
780 | 780 | * Renders the billing_email element template. |
781 | 781 | */ |
782 | - public function render_billing_email_template( $field ) { |
|
783 | - $restrict = $this->get_restrict_markup( $field, 'billing_email' ); |
|
782 | + public function render_billing_email_template($field) { |
|
783 | + $restrict = $this->get_restrict_markup($field, 'billing_email'); |
|
784 | 784 | $label = "$field.label"; |
785 | 785 | echo " |
786 | 786 | <div $restrict> |
@@ -794,16 +794,16 @@ discard block |
||
794 | 794 | /** |
795 | 795 | * Renders the edit email element template. |
796 | 796 | */ |
797 | - public function edit_email_template( $field ) { |
|
798 | - $restrict = $this->get_restrict_markup( $field, 'email' ); |
|
799 | - $label = __( 'Field Label', 'invoicing' ); |
|
797 | + public function edit_email_template($field) { |
|
798 | + $restrict = $this->get_restrict_markup($field, 'email'); |
|
799 | + $label = __('Field Label', 'invoicing'); |
|
800 | 800 | $id = $field . '.id + "_edit"'; |
801 | - $label2 = __( 'Placeholder text', 'invoicing' ); |
|
801 | + $label2 = __('Placeholder text', 'invoicing'); |
|
802 | 802 | $id2 = $field . '.id + "_edit2"'; |
803 | - $label3 = __( 'Help text', 'invoicing' ); |
|
804 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
803 | + $label3 = __('Help text', 'invoicing'); |
|
804 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
805 | 805 | $id3 = $field . '.id + "_edit3"'; |
806 | - $label5 = __( 'Is this field required?', 'invoicing' ); |
|
806 | + $label5 = __('Is this field required?', 'invoicing'); |
|
807 | 807 | $id4 = $field . '.id + "_edit4"'; |
808 | 808 | echo " |
809 | 809 | <div $restrict> |
@@ -831,16 +831,16 @@ discard block |
||
831 | 831 | /** |
832 | 832 | * Renders the edit billing_email element template. |
833 | 833 | */ |
834 | - public function edit_billing_email_template( $field ) { |
|
835 | - $restrict = $this->get_restrict_markup( $field, 'billing_email' ); |
|
836 | - $label = __( 'Field Label', 'invoicing' ); |
|
834 | + public function edit_billing_email_template($field) { |
|
835 | + $restrict = $this->get_restrict_markup($field, 'billing_email'); |
|
836 | + $label = __('Field Label', 'invoicing'); |
|
837 | 837 | $id = $field . '.id + "_edit"'; |
838 | - $label2 = __( 'Placeholder text', 'invoicing' ); |
|
838 | + $label2 = __('Placeholder text', 'invoicing'); |
|
839 | 839 | $id2 = $field . '.id + "_edit2"'; |
840 | - $label3 = __( 'Help text', 'invoicing' ); |
|
841 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
840 | + $label3 = __('Help text', 'invoicing'); |
|
841 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
842 | 842 | $id3 = $field . '.id + "_edit3"'; |
843 | - $label5 = __( 'Is this field required?', 'invoicing' ); |
|
843 | + $label5 = __('Is this field required?', 'invoicing'); |
|
844 | 844 | $id4 = $field . '.id + "_edit4"'; |
845 | 845 | echo " |
846 | 846 | <div $restrict> |
@@ -864,8 +864,8 @@ discard block |
||
864 | 864 | /** |
865 | 865 | * Renders the website element template. |
866 | 866 | */ |
867 | - public function render_website_template( $field ) { |
|
868 | - $restrict = $this->get_restrict_markup( $field, 'website' ); |
|
867 | + public function render_website_template($field) { |
|
868 | + $restrict = $this->get_restrict_markup($field, 'website'); |
|
869 | 869 | $label = "$field.label"; |
870 | 870 | echo " |
871 | 871 | <div $restrict class='wpinv-payment-form-field-preview'> |
@@ -880,16 +880,16 @@ discard block |
||
880 | 880 | /** |
881 | 881 | * Renders the edit website element template. |
882 | 882 | */ |
883 | - public function edit_website_template( $field ) { |
|
884 | - $restrict = $this->get_restrict_markup( $field, 'website' ); |
|
885 | - $label = __( 'Field Label', 'invoicing' ); |
|
883 | + public function edit_website_template($field) { |
|
884 | + $restrict = $this->get_restrict_markup($field, 'website'); |
|
885 | + $label = __('Field Label', 'invoicing'); |
|
886 | 886 | $id = $field . '.id + "_edit"'; |
887 | - $label2 = __( 'Placeholder text', 'invoicing' ); |
|
887 | + $label2 = __('Placeholder text', 'invoicing'); |
|
888 | 888 | $id2 = $field . '.id + "_edit2"'; |
889 | - $label3 = __( 'Help text', 'invoicing' ); |
|
890 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
889 | + $label3 = __('Help text', 'invoicing'); |
|
890 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
891 | 891 | $id3 = $field . '.id + "_edit3"'; |
892 | - $label5 = __( 'Is this field required?', 'invoicing' ); |
|
892 | + $label5 = __('Is this field required?', 'invoicing'); |
|
893 | 893 | $id4 = $field . '.id + "_edit4"'; |
894 | 894 | echo " |
895 | 895 | <div $restrict> |
@@ -917,8 +917,8 @@ discard block |
||
917 | 917 | /** |
918 | 918 | * Renders the date element template. |
919 | 919 | */ |
920 | - public function render_date_template( $field ) { |
|
921 | - $restrict = $this->get_restrict_markup( $field, 'date' ); |
|
920 | + public function render_date_template($field) { |
|
921 | + $restrict = $this->get_restrict_markup($field, 'date'); |
|
922 | 922 | $label = "$field.label"; |
923 | 923 | echo " |
924 | 924 | <div $restrict class='wpinv-payment-form-field-preview'> |
@@ -933,14 +933,14 @@ discard block |
||
933 | 933 | /** |
934 | 934 | * Renders the edit date element template. |
935 | 935 | */ |
936 | - public function edit_date_template( $field ) { |
|
937 | - $restrict = $this->get_restrict_markup( $field, 'date' ); |
|
938 | - $label = __( 'Field Label', 'invoicing' ); |
|
936 | + public function edit_date_template($field) { |
|
937 | + $restrict = $this->get_restrict_markup($field, 'date'); |
|
938 | + $label = __('Field Label', 'invoicing'); |
|
939 | 939 | $id = $field . '.id + "_edit"'; |
940 | - $label3 = __( 'Help text', 'invoicing' ); |
|
941 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
940 | + $label3 = __('Help text', 'invoicing'); |
|
941 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
942 | 942 | $id3 = $field . '.id + "_edit3"'; |
943 | - $label5 = __( 'Is this field required?', 'invoicing' ); |
|
943 | + $label5 = __('Is this field required?', 'invoicing'); |
|
944 | 944 | $id4 = $field . '.id + "_edit4"'; |
945 | 945 | echo " |
946 | 946 | <div $restrict> |
@@ -964,8 +964,8 @@ discard block |
||
964 | 964 | /** |
965 | 965 | * Renders the time element template. |
966 | 966 | */ |
967 | - public function render_time_template( $field ) { |
|
968 | - $restrict = $this->get_restrict_markup( $field, 'time' ); |
|
967 | + public function render_time_template($field) { |
|
968 | + $restrict = $this->get_restrict_markup($field, 'time'); |
|
969 | 969 | $label = "$field.label"; |
970 | 970 | echo " |
971 | 971 | <div $restrict class='wpinv-payment-form-field-preview'> |
@@ -980,14 +980,14 @@ discard block |
||
980 | 980 | /** |
981 | 981 | * Renders the edit time element template. |
982 | 982 | */ |
983 | - public function edit_time_template( $field ) { |
|
984 | - $restrict = $this->get_restrict_markup( $field, 'time' ); |
|
985 | - $label = __( 'Field Label', 'invoicing' ); |
|
983 | + public function edit_time_template($field) { |
|
984 | + $restrict = $this->get_restrict_markup($field, 'time'); |
|
985 | + $label = __('Field Label', 'invoicing'); |
|
986 | 986 | $id = $field . '.id + "_edit"'; |
987 | - $label3 = __( 'Help text', 'invoicing' ); |
|
988 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
987 | + $label3 = __('Help text', 'invoicing'); |
|
988 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
989 | 989 | $id3 = $field . '.id + "_edit3"'; |
990 | - $label5 = __( 'Is this field required?', 'invoicing' ); |
|
990 | + $label5 = __('Is this field required?', 'invoicing'); |
|
991 | 991 | $id4 = $field . '.id + "_edit4"'; |
992 | 992 | echo " |
993 | 993 | <div $restrict> |
@@ -1011,8 +1011,8 @@ discard block |
||
1011 | 1011 | /** |
1012 | 1012 | * Renders the number element template. |
1013 | 1013 | */ |
1014 | - public function render_number_template( $field ) { |
|
1015 | - $restrict = $this->get_restrict_markup( $field, 'number' ); |
|
1014 | + public function render_number_template($field) { |
|
1015 | + $restrict = $this->get_restrict_markup($field, 'number'); |
|
1016 | 1016 | $label = "$field.label"; |
1017 | 1017 | echo " |
1018 | 1018 | <div $restrict class='wpinv-payment-form-field-preview'> |
@@ -1027,16 +1027,16 @@ discard block |
||
1027 | 1027 | /** |
1028 | 1028 | * Renders the edit number element template. |
1029 | 1029 | */ |
1030 | - public function edit_number_template( $field ) { |
|
1031 | - $restrict = $this->get_restrict_markup( $field, 'number' ); |
|
1032 | - $label = __( 'Field Label', 'invoicing' ); |
|
1030 | + public function edit_number_template($field) { |
|
1031 | + $restrict = $this->get_restrict_markup($field, 'number'); |
|
1032 | + $label = __('Field Label', 'invoicing'); |
|
1033 | 1033 | $id = $field . '.id + "_edit"'; |
1034 | - $label2 = __( 'Placeholder text', 'invoicing' ); |
|
1034 | + $label2 = __('Placeholder text', 'invoicing'); |
|
1035 | 1035 | $id2 = $field . '.id + "_edit2"'; |
1036 | - $label3 = __( 'Help text', 'invoicing' ); |
|
1037 | - $label4 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
1036 | + $label3 = __('Help text', 'invoicing'); |
|
1037 | + $label4 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
1038 | 1038 | $id3 = $field . '.id + "_edit3"'; |
1039 | - $label5 = __( 'Is this field required?', 'invoicing' ); |
|
1039 | + $label5 = __('Is this field required?', 'invoicing'); |
|
1040 | 1040 | $id4 = $field . '.id + "_edit4"'; |
1041 | 1041 | echo " |
1042 | 1042 | <div $restrict> |
@@ -1064,16 +1064,16 @@ discard block |
||
1064 | 1064 | /** |
1065 | 1065 | * Renders the separator element template. |
1066 | 1066 | */ |
1067 | - public function render_separator_template( $field ) { |
|
1068 | - $restrict = $this->get_restrict_markup( $field, 'separator' ); |
|
1067 | + public function render_separator_template($field) { |
|
1068 | + $restrict = $this->get_restrict_markup($field, 'separator'); |
|
1069 | 1069 | echo "<hr class='featurette-divider' $restrict>"; |
1070 | 1070 | } |
1071 | 1071 | |
1072 | 1072 | /** |
1073 | 1073 | * Renders the pay button element template. |
1074 | 1074 | */ |
1075 | - public function render_pay_button_template( $field ) { |
|
1076 | - $restrict = $this->get_restrict_markup( $field, 'pay_button' ); |
|
1075 | + public function render_pay_button_template($field) { |
|
1076 | + $restrict = $this->get_restrict_markup($field, 'pay_button'); |
|
1077 | 1077 | $label = "$field.label"; |
1078 | 1078 | echo " |
1079 | 1079 | <div $restrict> |
@@ -1086,14 +1086,14 @@ discard block |
||
1086 | 1086 | /** |
1087 | 1087 | * Renders the pay button element template. |
1088 | 1088 | */ |
1089 | - public function edit_pay_button_template( $field ) { |
|
1090 | - $restrict = $this->get_restrict_markup( $field, 'pay_button' ); |
|
1091 | - $label = __( 'Button Text', 'invoicing' ); |
|
1089 | + public function edit_pay_button_template($field) { |
|
1090 | + $restrict = $this->get_restrict_markup($field, 'pay_button'); |
|
1091 | + $label = __('Button Text', 'invoicing'); |
|
1092 | 1092 | $id = $field . '.id + "_edit"'; |
1093 | - $label2 = __( 'Help text', 'invoicing' ); |
|
1094 | - $label3 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
1093 | + $label2 = __('Help text', 'invoicing'); |
|
1094 | + $label3 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
1095 | 1095 | $id2 = $field . '.id + "_edit2"'; |
1096 | - $label4 = esc_attr__( 'Button Type', 'invoicing' ); |
|
1096 | + $label4 = esc_attr__('Button Type', 'invoicing'); |
|
1097 | 1097 | $id3 = $field . '.id + "_edit3"'; |
1098 | 1098 | |
1099 | 1099 | echo " |
@@ -1110,15 +1110,15 @@ discard block |
||
1110 | 1110 | <label :for='$id3'>$label4</label> |
1111 | 1111 | |
1112 | 1112 | <select class='form-control custom-select' :id='$id3' v-model='$field.class'> |
1113 | - <option value='btn-primary'>" . __( 'Primary', 'invoicing' ) ."</option> |
|
1114 | - <option value='btn-secondary'>" . __( 'Secondary', 'invoicing' ) ."</option> |
|
1115 | - <option value='btn-success'>" . __( 'Success', 'invoicing' ) ."</option> |
|
1116 | - <option value='btn-danger'>" . __( 'Danger', 'invoicing' ) ."</option> |
|
1117 | - <option value='btn-warning'>" . __( 'Warning', 'invoicing' ) ."</option> |
|
1118 | - <option value='btn-info'>" . __( 'Info', 'invoicing' ) ."</option> |
|
1119 | - <option value='btn-light'>" . __( 'Light', 'invoicing' ) ."</option> |
|
1120 | - <option value='btn-dark'>" . __( 'Dark', 'invoicing' ) ."</option> |
|
1121 | - <option value='btn-link'>" . __( 'Link', 'invoicing' ) ."</option> |
|
1113 | + <option value='btn-primary'>" . __('Primary', 'invoicing') . "</option> |
|
1114 | + <option value='btn-secondary'>" . __('Secondary', 'invoicing') . "</option> |
|
1115 | + <option value='btn-success'>" . __('Success', 'invoicing') . "</option> |
|
1116 | + <option value='btn-danger'>" . __('Danger', 'invoicing') . "</option> |
|
1117 | + <option value='btn-warning'>" . __('Warning', 'invoicing') . "</option> |
|
1118 | + <option value='btn-info'>" . __('Info', 'invoicing') . "</option> |
|
1119 | + <option value='btn-light'>" . __('Light', 'invoicing') . "</option> |
|
1120 | + <option value='btn-dark'>" . __('Dark', 'invoicing') . "</option> |
|
1121 | + <option value='btn-link'>" . __('Link', 'invoicing') . "</option> |
|
1122 | 1122 | </select> |
1123 | 1123 | </div> |
1124 | 1124 | </div> |
@@ -1129,8 +1129,8 @@ discard block |
||
1129 | 1129 | /** |
1130 | 1130 | * Renders the alert element template. |
1131 | 1131 | */ |
1132 | - public function render_alert_template( $field ) { |
|
1133 | - $restrict = $this->get_restrict_markup( $field, 'alert' ); |
|
1132 | + public function render_alert_template($field) { |
|
1133 | + $restrict = $this->get_restrict_markup($field, 'alert'); |
|
1134 | 1134 | $text = "$field.text"; |
1135 | 1135 | echo " |
1136 | 1136 | <div $restrict class='alert' :class='$field.class' role='alert'> |
@@ -1145,14 +1145,14 @@ discard block |
||
1145 | 1145 | /** |
1146 | 1146 | * Renders the alert element template. |
1147 | 1147 | */ |
1148 | - public function edit_alert_template( $field ) { |
|
1149 | - $restrict = $this->get_restrict_markup( $field, 'alert' ); |
|
1150 | - $label = __( 'Alert Text', 'invoicing' ); |
|
1151 | - $label2 = esc_attr__( 'Enter your alert text here', 'invoicing' ); |
|
1148 | + public function edit_alert_template($field) { |
|
1149 | + $restrict = $this->get_restrict_markup($field, 'alert'); |
|
1150 | + $label = __('Alert Text', 'invoicing'); |
|
1151 | + $label2 = esc_attr__('Enter your alert text here', 'invoicing'); |
|
1152 | 1152 | $id = $field . '.id + "_edit"'; |
1153 | - $label3 = __( 'Is Dismissible?', 'invoicing' ); |
|
1153 | + $label3 = __('Is Dismissible?', 'invoicing'); |
|
1154 | 1154 | $id2 = $field . '.id + "_edit2"'; |
1155 | - $label4 = esc_attr__( 'Alert Type', 'invoicing' ); |
|
1155 | + $label4 = esc_attr__('Alert Type', 'invoicing'); |
|
1156 | 1156 | $id3 = $field . '.id + "_edit3"'; |
1157 | 1157 | echo " |
1158 | 1158 | <div $restrict> |
@@ -1168,14 +1168,14 @@ discard block |
||
1168 | 1168 | <label :for='$id3'>$label4</label> |
1169 | 1169 | |
1170 | 1170 | <select class='form-control custom-select' :id='$id3' v-model='$field.class'> |
1171 | - <option value='alert-primary'>" . __( 'Primary', 'invoicing' ) ."</option> |
|
1172 | - <option value='alert-secondary'>" . __( 'Secondary', 'invoicing' ) ."</option> |
|
1173 | - <option value='alert-success'>" . __( 'Success', 'invoicing' ) ."</option> |
|
1174 | - <option value='alert-danger'>" . __( 'Danger', 'invoicing' ) ."</option> |
|
1175 | - <option value='alert-warning'>" . __( 'Warning', 'invoicing' ) ."</option> |
|
1176 | - <option value='alert-info'>" . __( 'Info', 'invoicing' ) ."</option> |
|
1177 | - <option value='alert-light'>" . __( 'Light', 'invoicing' ) ."</option> |
|
1178 | - <option value='alert-dark'>" . __( 'Dark', 'invoicing' ) ."</option> |
|
1171 | + <option value='alert-primary'>" . __('Primary', 'invoicing') . "</option> |
|
1172 | + <option value='alert-secondary'>" . __('Secondary', 'invoicing') . "</option> |
|
1173 | + <option value='alert-success'>" . __('Success', 'invoicing') . "</option> |
|
1174 | + <option value='alert-danger'>" . __('Danger', 'invoicing') . "</option> |
|
1175 | + <option value='alert-warning'>" . __('Warning', 'invoicing') . "</option> |
|
1176 | + <option value='alert-info'>" . __('Info', 'invoicing') . "</option> |
|
1177 | + <option value='alert-light'>" . __('Light', 'invoicing') . "</option> |
|
1178 | + <option value='alert-dark'>" . __('Dark', 'invoicing') . "</option> |
|
1179 | 1179 | </select> |
1180 | 1180 | </div> |
1181 | 1181 | </div> |
@@ -1186,8 +1186,8 @@ discard block |
||
1186 | 1186 | /** |
1187 | 1187 | * Renders the discount element template. |
1188 | 1188 | */ |
1189 | - public function render_discount_template( $field ) { |
|
1190 | - $restrict = $this->get_restrict_markup( $field, 'discount' ); |
|
1189 | + public function render_discount_template($field) { |
|
1190 | + $restrict = $this->get_restrict_markup($field, 'discount'); |
|
1191 | 1191 | ?> |
1192 | 1192 | |
1193 | 1193 | <div <?php echo $restrict; ?> class="discount_field border rounded p-3 wpinv-payment-form-field-preview"> |
@@ -1205,12 +1205,12 @@ discard block |
||
1205 | 1205 | /** |
1206 | 1206 | * Renders the discount element template. |
1207 | 1207 | */ |
1208 | - public function edit_discount_template( $field ) { |
|
1209 | - $restrict = $this->get_restrict_markup( $field, 'discount' ); |
|
1210 | - $label = __( 'Discount Input Placeholder', 'invoicing' ); |
|
1211 | - $label2 = __( 'Help Text', 'invoicing' ); |
|
1212 | - $label3 = esc_attr__( 'Add some help text for this field', 'invoicing' ); |
|
1213 | - $label4 = __( 'Button Text', 'invoicing' ); |
|
1208 | + public function edit_discount_template($field) { |
|
1209 | + $restrict = $this->get_restrict_markup($field, 'discount'); |
|
1210 | + $label = __('Discount Input Placeholder', 'invoicing'); |
|
1211 | + $label2 = __('Help Text', 'invoicing'); |
|
1212 | + $label3 = esc_attr__('Add some help text for this field', 'invoicing'); |
|
1213 | + $label4 = __('Button Text', 'invoicing'); |
|
1214 | 1214 | $id = $field . '.id + "_edit"'; |
1215 | 1215 | $id2 = $field . '.id + "_edit2"'; |
1216 | 1216 | $id3 = $field . '.id + "_edit3"'; |
@@ -1239,17 +1239,17 @@ discard block |
||
1239 | 1239 | /** |
1240 | 1240 | * Renders the items element template. |
1241 | 1241 | */ |
1242 | - public function render_items_template( $field ) { |
|
1243 | - $restrict = $this->get_restrict_markup( $field, 'items' ); |
|
1242 | + public function render_items_template($field) { |
|
1243 | + $restrict = $this->get_restrict_markup($field, 'items'); |
|
1244 | 1244 | ?> |
1245 | 1245 | |
1246 | 1246 | <div <?php echo $restrict; ?> class='item_totals'> |
1247 | 1247 | <div v-if='!is_default'> |
1248 | - <div v-if='! canCheckoutSeveralSubscriptions(<?php echo $field; ?>)' class='alert alert-info' role='alert'><?php _e( 'Item totals will appear here. Click to set items.', 'invoicing' ) ?></div> |
|
1249 | - <div v-if='canCheckoutSeveralSubscriptions(<?php echo $field; ?>)' class='alert alert-danger' role='alert'><?php _e( 'Your form allows customers to buy several recurring items. This is not supported and might lead to unexpected behaviour.', 'invoicing' ); ?></div> |
|
1248 | + <div v-if='! canCheckoutSeveralSubscriptions(<?php echo $field; ?>)' class='alert alert-info' role='alert'><?php _e('Item totals will appear here. Click to set items.', 'invoicing') ?></div> |
|
1249 | + <div v-if='canCheckoutSeveralSubscriptions(<?php echo $field; ?>)' class='alert alert-danger' role='alert'><?php _e('Your form allows customers to buy several recurring items. This is not supported and might lead to unexpected behaviour.', 'invoicing'); ?></div> |
|
1250 | 1250 | </div> |
1251 | 1251 | <div v-if='is_default'> |
1252 | - <div class='alert alert-info' role='alert'><?php _e( 'Item totals will appear here.', 'invoicing' ) ?></div> |
|
1252 | + <div class='alert alert-info' role='alert'><?php _e('Item totals will appear here.', 'invoicing') ?></div> |
|
1253 | 1253 | </div> |
1254 | 1254 | </div> |
1255 | 1255 | |
@@ -1259,25 +1259,25 @@ discard block |
||
1259 | 1259 | /** |
1260 | 1260 | * Renders the items element template. |
1261 | 1261 | */ |
1262 | - public function edit_items_template( $field ) { |
|
1262 | + public function edit_items_template($field) { |
|
1263 | 1263 | global $wpinv_euvat, $post; |
1264 | 1264 | |
1265 | - $restrict = $this->get_restrict_markup( $field, 'items' ); |
|
1265 | + $restrict = $this->get_restrict_markup($field, 'items'); |
|
1266 | 1266 | $id2 = $field . '.id + "_edit2"'; |
1267 | 1267 | $id3 = $field . '.id + "_edit3"'; |
1268 | 1268 | |
1269 | 1269 | // Item types. |
1270 | - $item_types = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post ); |
|
1270 | + $item_types = apply_filters('wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post); |
|
1271 | 1271 | |
1272 | 1272 | ?> |
1273 | 1273 | <div <?php echo $restrict; ?>> |
1274 | 1274 | <div v-if="!is_default"> |
1275 | 1275 | <label class='form-group'> |
1276 | 1276 | <input v-model='<?php echo $field; ?>.hide_cart' type='checkbox' /> |
1277 | - <span class='form-check-label'><?php _e( 'Hide cart details', 'invoicing' ); ?></span> |
|
1277 | + <span class='form-check-label'><?php _e('Hide cart details', 'invoicing'); ?></span> |
|
1278 | 1278 | </label> |
1279 | 1279 | |
1280 | - <div class="mb-1"><?php _e( 'Form Items', 'invoicing' ); ?></div> |
|
1280 | + <div class="mb-1"><?php _e('Form Items', 'invoicing'); ?></div> |
|
1281 | 1281 | <draggable v-model='form_items' group='selectable_form_items'> |
1282 | 1282 | <div class='wpinv-available-items-editor' v-for='(item, index) in form_items' :class="'item_' + item.id" :key="item.id"> |
1283 | 1283 | |
@@ -1295,35 +1295,35 @@ discard block |
||
1295 | 1295 | |
1296 | 1296 | <div class="form-group" v-if="! item.new"> |
1297 | 1297 | <span class='form-text'> |
1298 | - <a target="_blank" :href="'<?php echo esc_url( admin_url( '/post.php?action=edit&post' ) ) ?>=' + item.id"> |
|
1299 | - <?php _e( 'Edit the item name, price and other details', 'invoicing' ); ?> |
|
1298 | + <a target="_blank" :href="'<?php echo esc_url(admin_url('/post.php?action=edit&post')) ?>=' + item.id"> |
|
1299 | + <?php _e('Edit the item name, price and other details', 'invoicing'); ?> |
|
1300 | 1300 | </a> |
1301 | 1301 | </span> |
1302 | 1302 | </div> |
1303 | 1303 | |
1304 | 1304 | <div class='form-group' v-if="item.new"> |
1305 | 1305 | <label class='mb-0 w-100'> |
1306 | - <span><?php _e( 'Item Name', 'invoicing' ); ?></span> |
|
1306 | + <span><?php _e('Item Name', 'invoicing'); ?></span> |
|
1307 | 1307 | <input v-model='item.title' type='text' class='w-100'/> |
1308 | 1308 | </label> |
1309 | 1309 | </div> |
1310 | 1310 | |
1311 | 1311 | <div class='form-group' v-if="item.new"> |
1312 | 1312 | <label class='mb-0 w-100'> |
1313 | - <span v-if='!item.custom_price'><?php _e( 'Item Price', 'invoicing' ); ?></span> |
|
1314 | - <span v-if='item.custom_price'><?php _e( 'Recommended Price', 'invoicing' ); ?></span> |
|
1313 | + <span v-if='!item.custom_price'><?php _e('Item Price', 'invoicing'); ?></span> |
|
1314 | + <span v-if='item.custom_price'><?php _e('Recommended Price', 'invoicing'); ?></span> |
|
1315 | 1315 | <input v-model='item.price' type='text' class='w-100'/> |
1316 | 1316 | </label> |
1317 | 1317 | </div> |
1318 | 1318 | |
1319 | 1319 | <div class='form-group' v-if='item.new'> |
1320 | 1320 | <label :for="'edit_item_type' + item.id" class='mb-0 w-100'> |
1321 | - <span><?php _e( 'Item Type', 'invoicing' ); ?></span> |
|
1321 | + <span><?php _e('Item Type', 'invoicing'); ?></span> |
|
1322 | 1322 | <select class='w-100' v-model='item.type'> |
1323 | 1323 | <?php |
1324 | - foreach ( $item_types as $type => $_label ) { |
|
1325 | - $type = esc_attr( $type ); |
|
1326 | - $_label = esc_html( $_label ); |
|
1324 | + foreach ($item_types as $type => $_label) { |
|
1325 | + $type = esc_attr($type); |
|
1326 | + $_label = esc_html($_label); |
|
1327 | 1327 | echo "<option value='$type'>$_label</type>"; |
1328 | 1328 | } |
1329 | 1329 | ?> |
@@ -1332,71 +1332,71 @@ discard block |
||
1332 | 1332 | </div> |
1333 | 1333 | |
1334 | 1334 | <div v-if='item.new'> |
1335 | - <?php if ( $wpinv_euvat->allow_vat_rules() ) : ?> |
|
1335 | + <?php if ($wpinv_euvat->allow_vat_rules()) : ?> |
|
1336 | 1336 | <div class='form-group'> |
1337 | - <label class='w-100 mb-0'><?php _e( 'VAT Rule', 'invoicing' ) ; ?> |
|
1337 | + <label class='w-100 mb-0'><?php _e('VAT Rule', 'invoicing'); ?> |
|
1338 | 1338 | <select class='w-100' v-model='item.rule'> |
1339 | 1339 | <?php |
1340 | - foreach ( $wpinv_euvat->get_rules() as $type => $_label ) { |
|
1341 | - $type = esc_attr( $type ); |
|
1342 | - $_label = esc_html( $_label ); |
|
1340 | + foreach ($wpinv_euvat->get_rules() as $type => $_label) { |
|
1341 | + $type = esc_attr($type); |
|
1342 | + $_label = esc_html($_label); |
|
1343 | 1343 | echo "<option value='$type'>$_label</type>"; |
1344 | 1344 | } |
1345 | 1345 | ?> |
1346 | 1346 | </select> |
1347 | 1347 | </label> |
1348 | 1348 | </div> |
1349 | - <?php endif;?> |
|
1349 | + <?php endif; ?> |
|
1350 | 1350 | |
1351 | - <?php if ( $wpinv_euvat->allow_vat_classes() ) : ?> |
|
1351 | + <?php if ($wpinv_euvat->allow_vat_classes()) : ?> |
|
1352 | 1352 | <div class='form-group'> |
1353 | - <label class='w-100 mb-0'><?php _e( 'VAT class', 'invoicing' ) ; ?> |
|
1353 | + <label class='w-100 mb-0'><?php _e('VAT class', 'invoicing'); ?> |
|
1354 | 1354 | <select class='w-100' v-model='item.class'> |
1355 | 1355 | <?php |
1356 | - foreach ( $wpinv_euvat->get_all_classes() as $type => $_label ) { |
|
1357 | - $type = esc_attr( $type ); |
|
1358 | - $_label = esc_html( $_label ); |
|
1356 | + foreach ($wpinv_euvat->get_all_classes() as $type => $_label) { |
|
1357 | + $type = esc_attr($type); |
|
1358 | + $_label = esc_html($_label); |
|
1359 | 1359 | echo "<option value='$type'>$_label</type>"; |
1360 | 1360 | } |
1361 | 1361 | ?> |
1362 | 1362 | </select> |
1363 | 1363 | </label> |
1364 | 1364 | </div> |
1365 | - <?php endif;?> |
|
1365 | + <?php endif; ?> |
|
1366 | 1366 | |
1367 | 1367 | </div> |
1368 | 1368 | |
1369 | 1369 | <label v-if='item.new' class='form-group'> |
1370 | 1370 | <input v-model='item.custom_price' type='checkbox' /> |
1371 | - <span class='form-check-label'><?php _e( 'Allow users to pay what they want', 'invoicing' ); ?></span> |
|
1371 | + <span class='form-check-label'><?php _e('Allow users to pay what they want', 'invoicing'); ?></span> |
|
1372 | 1372 | </label> |
1373 | 1373 | |
1374 | 1374 | <div class='form-group' v-if='item.new && item.custom_price'> |
1375 | 1375 | <label class='mb-0 w-100'> |
1376 | - <span><?php _e( 'Minimum Price', 'invoicing' ); ?></span> |
|
1376 | + <span><?php _e('Minimum Price', 'invoicing'); ?></span> |
|
1377 | 1377 | <input placeholder='0.00' v-model='item.minimum_price' class='w-100' /> |
1378 | - <small class='form-text text-muted'><?php _e( 'Enter the minimum price that a user can pay', 'invoicing' ); ?></small> |
|
1378 | + <small class='form-text text-muted'><?php _e('Enter the minimum price that a user can pay', 'invoicing'); ?></small> |
|
1379 | 1379 | </label> |
1380 | 1380 | </div> |
1381 | 1381 | |
1382 | 1382 | <label class='form-group'> |
1383 | 1383 | <input v-model='item.allow_quantities' type='checkbox' /> |
1384 | - <span><?php _e( 'Allow users to buy several quantities', 'invoicing' ); ?></span> |
|
1384 | + <span><?php _e('Allow users to buy several quantities', 'invoicing'); ?></span> |
|
1385 | 1385 | </label> |
1386 | 1386 | |
1387 | 1387 | <label class='form-group'> |
1388 | 1388 | <input v-model='item.required' type='checkbox' /> |
1389 | - <span><?php _e( 'This item is required', 'invoicing' ); ?></span> |
|
1389 | + <span><?php _e('This item is required', 'invoicing'); ?></span> |
|
1390 | 1390 | </label> |
1391 | 1391 | |
1392 | 1392 | <div class='form-group'> |
1393 | 1393 | <label class="mb-0 w-100"> |
1394 | - <span><?php _e( 'Item Description', 'invoicing' ); ?></span> |
|
1394 | + <span><?php _e('Item Description', 'invoicing'); ?></span> |
|
1395 | 1395 | <textarea v-model='item.description' class='w-100'></textarea> |
1396 | 1396 | </label> |
1397 | 1397 | </div> |
1398 | 1398 | |
1399 | - <button type='button' class='button button-link button-link-delete' @click.prevent='removeItem(item)'><?php _e( 'Delete Item', 'invoicing' ); ?></button> |
|
1399 | + <button type='button' class='button button-link button-link-delete' @click.prevent='removeItem(item)'><?php _e('Delete Item', 'invoicing'); ?></button> |
|
1400 | 1400 | |
1401 | 1401 | </div> |
1402 | 1402 | </div> |
@@ -1404,36 +1404,36 @@ discard block |
||
1404 | 1404 | </div> |
1405 | 1405 | </draggable> |
1406 | 1406 | |
1407 | - <small v-if='! form_items.length' class='form-text text-danger'><?php _e( 'You have not set up any items. Please select an item below or create a new item.', 'invoicing' ); ?></small> |
|
1407 | + <small v-if='! form_items.length' class='form-text text-danger'><?php _e('You have not set up any items. Please select an item below or create a new item.', 'invoicing'); ?></small> |
|
1408 | 1408 | |
1409 | 1409 | <div class='form-group mt-2'> |
1410 | 1410 | |
1411 | 1411 | <select class='w-100' style="padding: 6px 24px 6px 8px; border-color: #e0e0e0;" v-model='selected_item' @change='addSelectedItem'> |
1412 | - <option value=''><?php _e( 'Select an item to add...', 'invoicing' ) ?></option> |
|
1412 | + <option value=''><?php _e('Select an item to add...', 'invoicing') ?></option> |
|
1413 | 1413 | <option v-for='(item, index) in all_items' :value='index'>{{item.title}}</option> |
1414 | 1414 | </select> |
1415 | 1415 | |
1416 | 1416 | </div> |
1417 | 1417 | |
1418 | 1418 | <div class='form-group'> |
1419 | - <button @click.prevent='addNewItem' class="button button-link"><?php _e( 'Or create a new item.', 'invoicing' ) ?></button> |
|
1419 | + <button @click.prevent='addNewItem' class="button button-link"><?php _e('Or create a new item.', 'invoicing') ?></button> |
|
1420 | 1420 | </div> |
1421 | 1421 | |
1422 | 1422 | <div class='form-group mt-5'> |
1423 | - <label :for='<?php echo $id2; ?>'><?php _e( 'Let customers...', 'invoicing' ) ?></label> |
|
1423 | + <label :for='<?php echo $id2; ?>'><?php _e('Let customers...', 'invoicing') ?></label> |
|
1424 | 1424 | |
1425 | 1425 | <select class='w-100' style="padding: 6px 24px 6px 8px; border-color: #e0e0e0;" :id='<?php echo $id2; ?>' v-model='<?php echo $field; ?>.items_type'> |
1426 | - <option value='total' :disabled='canCheckoutSeveralSubscriptions(<?php echo $field; ?>)'><?php _e( 'Buy all items on the list', 'invoicing' ); ?></option> |
|
1427 | - <option value='radio'><?php _e( 'Select a single item from the list', 'invoicing' ); ?></option> |
|
1428 | - <option value='checkbox' :disabled='canCheckoutSeveralSubscriptions(<?php echo $field; ?>)'><?php _e( 'Select one or more items on the list', 'invoicing' ) ;?></option> |
|
1429 | - <option value='select'><?php _e( 'Select a single item from a dropdown', 'invoicing' ); ?></option> |
|
1426 | + <option value='total' :disabled='canCheckoutSeveralSubscriptions(<?php echo $field; ?>)'><?php _e('Buy all items on the list', 'invoicing'); ?></option> |
|
1427 | + <option value='radio'><?php _e('Select a single item from the list', 'invoicing'); ?></option> |
|
1428 | + <option value='checkbox' :disabled='canCheckoutSeveralSubscriptions(<?php echo $field; ?>)'><?php _e('Select one or more items on the list', 'invoicing'); ?></option> |
|
1429 | + <option value='select'><?php _e('Select a single item from a dropdown', 'invoicing'); ?></option> |
|
1430 | 1430 | </select> |
1431 | 1431 | |
1432 | 1432 | </div> |
1433 | 1433 | </div> |
1434 | 1434 | <div class='form-group'> |
1435 | - <label :for='<?php echo $id3; ?>'><?php _e( 'Help Text', 'invoicing' ); ?></label> |
|
1436 | - <textarea placeholder='<?php esc_attr_e( 'Add some help text for this element', 'invoicing' ); ?>' :id='<?php echo $id3; ?>' v-model='<?php echo $field; ?>.description' class='form-control' rows='3'></textarea> |
|
1435 | + <label :for='<?php echo $id3; ?>'><?php _e('Help Text', 'invoicing'); ?></label> |
|
1436 | + <textarea placeholder='<?php esc_attr_e('Add some help text for this element', 'invoicing'); ?>' :id='<?php echo $id3; ?>' v-model='<?php echo $field; ?>.description' class='form-control' rows='3'></textarea> |
|
1437 | 1437 | </div> |
1438 | 1438 | |
1439 | 1439 | </div> |
@@ -1452,7 +1452,7 @@ discard block |
||
1452 | 1452 | 'orderby' => 'title', |
1453 | 1453 | 'order' => 'ASC', |
1454 | 1454 | 'posts_per_page' => -1, |
1455 | - 'post_status' => array( 'publish' ), |
|
1455 | + 'post_status' => array('publish'), |
|
1456 | 1456 | 'meta_query' => array( |
1457 | 1457 | array( |
1458 | 1458 | 'key' => '_wpinv_type', |
@@ -1462,15 +1462,15 @@ discard block |
||
1462 | 1462 | ) |
1463 | 1463 | ); |
1464 | 1464 | |
1465 | - $items = get_posts( apply_filters( 'getpaid_payment_form_item_dropdown_query_args', $item_args ) ); |
|
1465 | + $items = get_posts(apply_filters('getpaid_payment_form_item_dropdown_query_args', $item_args)); |
|
1466 | 1466 | |
1467 | - if ( empty( $items ) ) { |
|
1467 | + if (empty($items)) { |
|
1468 | 1468 | return array(); |
1469 | 1469 | } |
1470 | 1470 | |
1471 | - $options = array(); |
|
1472 | - foreach ( $items as $item ) { |
|
1473 | - $item = new GetPaid_Form_Item( $item ); |
|
1471 | + $options = array(); |
|
1472 | + foreach ($items as $item) { |
|
1473 | + $item = new GetPaid_Form_Item($item); |
|
1474 | 1474 | $options[] = $item->prepare_data_for_use(); |
1475 | 1475 | } |
1476 | 1476 | return $options; |
@@ -1480,39 +1480,39 @@ discard block |
||
1480 | 1480 | /** |
1481 | 1481 | * Returns an array of items for the currently being edited form. |
1482 | 1482 | */ |
1483 | - public function get_form_items( $id = false ) { |
|
1484 | - $form = new GetPaid_Payment_Form( $id ); |
|
1483 | + public function get_form_items($id = false) { |
|
1484 | + $form = new GetPaid_Payment_Form($id); |
|
1485 | 1485 | |
1486 | 1486 | // Is this a default form? |
1487 | - if ( $form->is_default() ) { |
|
1487 | + if ($form->is_default()) { |
|
1488 | 1488 | return array(); |
1489 | 1489 | } |
1490 | 1490 | |
1491 | - return $form->get_items( 'view', 'arrays' ); |
|
1491 | + return $form->get_items('view', 'arrays'); |
|
1492 | 1492 | } |
1493 | 1493 | |
1494 | 1494 | /** |
1495 | 1495 | * Converts form items for use. |
1496 | 1496 | */ |
1497 | - public function convert_checkout_items( $items, $invoice ) { |
|
1497 | + public function convert_checkout_items($items, $invoice) { |
|
1498 | 1498 | |
1499 | 1499 | $converted = array(); |
1500 | - foreach ( $items as $item ) { |
|
1500 | + foreach ($items as $item) { |
|
1501 | 1501 | |
1502 | 1502 | $item_id = $item['id']; |
1503 | - $_item = new WPInv_Item( $item_id ); |
|
1503 | + $_item = new WPInv_Item($item_id); |
|
1504 | 1504 | |
1505 | - if( ! $_item ) { |
|
1505 | + if (!$_item) { |
|
1506 | 1506 | continue; |
1507 | 1507 | } |
1508 | 1508 | |
1509 | 1509 | $converted[] = array( |
1510 | - 'title' => esc_html( wpinv_get_cart_item_name( $item ) ) . wpinv_get_item_suffix( $_item ), |
|
1510 | + 'title' => esc_html(wpinv_get_cart_item_name($item)) . wpinv_get_item_suffix($_item), |
|
1511 | 1511 | 'id' => $item['id'], |
1512 | 1512 | 'price' => $item['subtotal'], |
1513 | 1513 | 'custom_price' => $_item->get_is_dynamic_pricing(), |
1514 | 1514 | 'recurring' => $_item->is_recurring(), |
1515 | - 'description' => apply_filters( 'wpinv_checkout_cart_line_item_summary', '', $item, $_item, $invoice ), |
|
1515 | + 'description' => apply_filters('wpinv_checkout_cart_line_item_summary', '', $item, $_item, $invoice), |
|
1516 | 1516 | 'minimum_price' => $_item->get_minimum_price(), |
1517 | 1517 | 'allow_quantities' => false, |
1518 | 1518 | 'quantity' => $item['quantity'], |
@@ -1526,27 +1526,27 @@ discard block |
||
1526 | 1526 | /** |
1527 | 1527 | * Converts an array of id => quantity for use. |
1528 | 1528 | */ |
1529 | - public function convert_normal_items( $items ) { |
|
1529 | + public function convert_normal_items($items) { |
|
1530 | 1530 | |
1531 | 1531 | $converted = array(); |
1532 | - foreach ( $items as $item_id => $quantity ) { |
|
1532 | + foreach ($items as $item_id => $quantity) { |
|
1533 | 1533 | |
1534 | - $item = new WPInv_Item( $item_id ); |
|
1534 | + $item = new WPInv_Item($item_id); |
|
1535 | 1535 | |
1536 | - if( ! $item ) { |
|
1536 | + if (!$item) { |
|
1537 | 1537 | continue; |
1538 | 1538 | } |
1539 | 1539 | |
1540 | 1540 | $converted[] = array( |
1541 | - 'title' => esc_html( $item->get_name() ) . wpinv_get_item_suffix( $item ), |
|
1541 | + 'title' => esc_html($item->get_name()) . wpinv_get_item_suffix($item), |
|
1542 | 1542 | 'id' => $item_id, |
1543 | 1543 | 'price' => $item->get_price(), |
1544 | 1544 | 'custom_price' => $item->get_is_dynamic_pricing(), |
1545 | 1545 | 'recurring' => $item->is_recurring(), |
1546 | 1546 | 'description' => $item->get_summary(), |
1547 | 1547 | 'minimum_price' => $item->get_minimum_price(), |
1548 | - 'allow_quantities' => ! empty( $quantity ), |
|
1549 | - 'quantity' => empty( $quantity ) ? 1 : $quantity, |
|
1548 | + 'allow_quantities' => !empty($quantity), |
|
1549 | + 'quantity' => empty($quantity) ? 1 : $quantity, |
|
1550 | 1550 | 'required' => true, |
1551 | 1551 | ); |
1552 | 1552 | |
@@ -1559,19 +1559,19 @@ discard block |
||
1559 | 1559 | /** |
1560 | 1560 | * Returns an array of elements for the currently being edited form. |
1561 | 1561 | */ |
1562 | - public function get_form_elements( $id = false ) { |
|
1562 | + public function get_form_elements($id = false) { |
|
1563 | 1563 | |
1564 | - if ( empty( $id ) ) { |
|
1565 | - return wpinv_get_data( 'sample-payment-form' ); |
|
1564 | + if (empty($id)) { |
|
1565 | + return wpinv_get_data('sample-payment-form'); |
|
1566 | 1566 | } |
1567 | 1567 | |
1568 | - $form_elements = get_post_meta( $id, 'wpinv_form_elements', true ); |
|
1568 | + $form_elements = get_post_meta($id, 'wpinv_form_elements', true); |
|
1569 | 1569 | |
1570 | - if ( is_array( $form_elements ) ) { |
|
1570 | + if (is_array($form_elements)) { |
|
1571 | 1571 | return $form_elements; |
1572 | 1572 | } |
1573 | 1573 | |
1574 | - return wpinv_get_data( 'sample-payment-form' ); |
|
1574 | + return wpinv_get_data('sample-payment-form'); |
|
1575 | 1575 | } |
1576 | 1576 | |
1577 | 1577 | } |