@@ -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 | /** |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return string |
25 | 25 | */ |
26 | -function getpaid_get_ip_country( $ip_address = '' ) { |
|
27 | - $country = GetPaid_Geolocation::geolocate_ip( $ip_address, true ); |
|
26 | +function getpaid_get_ip_country($ip_address = '') { |
|
27 | + $country = GetPaid_Geolocation::geolocate_ip($ip_address, true); |
|
28 | 28 | return $country['country']; |
29 | 29 | } |
30 | 30 | |
@@ -34,59 +34,59 @@ discard block |
||
34 | 34 | * @param string $country The country code to sanitize |
35 | 35 | * @return array |
36 | 36 | */ |
37 | -function wpinv_sanitize_country( $country ) { |
|
37 | +function wpinv_sanitize_country($country) { |
|
38 | 38 | |
39 | 39 | // Enure the country is specified |
40 | - if ( empty( $country ) ) { |
|
40 | + if (empty($country)) { |
|
41 | 41 | $country = wpinv_get_default_country(); |
42 | 42 | } |
43 | - return trim( wpinv_utf8_strtoupper( $country ) ); |
|
43 | + return trim(wpinv_utf8_strtoupper($country)); |
|
44 | 44 | |
45 | 45 | } |
46 | 46 | |
47 | -function wpinv_is_base_country( $country ) { |
|
47 | +function wpinv_is_base_country($country) { |
|
48 | 48 | $base_country = wpinv_get_default_country(); |
49 | 49 | |
50 | - if ( $base_country === 'UK' ) { |
|
50 | + if ($base_country === 'UK') { |
|
51 | 51 | $base_country = 'GB'; |
52 | 52 | } |
53 | - if ( $country == 'UK' ) { |
|
53 | + if ($country == 'UK') { |
|
54 | 54 | $country = 'GB'; |
55 | 55 | } |
56 | 56 | |
57 | - return ( $country && $country === $base_country ) ? true : false; |
|
57 | + return ($country && $country === $base_country) ? true : false; |
|
58 | 58 | } |
59 | 59 | |
60 | -function wpinv_country_name( $country_code = '' ) { |
|
60 | +function wpinv_country_name($country_code = '') { |
|
61 | 61 | $countries = wpinv_get_country_list(); |
62 | 62 | $country_code = $country_code == 'UK' ? 'GB' : $country_code; |
63 | - $country = isset( $countries[$country_code] ) ? $countries[$country_code] : $country_code; |
|
63 | + $country = isset($countries[$country_code]) ? $countries[$country_code] : $country_code; |
|
64 | 64 | |
65 | - return apply_filters( 'wpinv_country_name', $country, $country_code ); |
|
65 | + return apply_filters('wpinv_country_name', $country, $country_code); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | function wpinv_get_default_state() { |
69 | - $state = wpinv_get_option( 'default_state', '' ); |
|
69 | + $state = wpinv_get_option('default_state', ''); |
|
70 | 70 | |
71 | - return apply_filters( 'wpinv_default_state', $state ); |
|
71 | + return apply_filters('wpinv_default_state', $state); |
|
72 | 72 | } |
73 | 73 | |
74 | -function wpinv_state_name( $state_code = '', $country_code = '' ) { |
|
74 | +function wpinv_state_name($state_code = '', $country_code = '') { |
|
75 | 75 | $state = $state_code; |
76 | 76 | |
77 | - if ( !empty( $country_code ) ) { |
|
78 | - $states = wpinv_get_country_states( $country_code ); |
|
77 | + if (!empty($country_code)) { |
|
78 | + $states = wpinv_get_country_states($country_code); |
|
79 | 79 | |
80 | - $state = !empty( $states ) && isset( $states[$state_code] ) ? $states[$state_code] : $state; |
|
80 | + $state = !empty($states) && isset($states[$state_code]) ? $states[$state_code] : $state; |
|
81 | 81 | } |
82 | 82 | |
83 | - return apply_filters( 'wpinv_state_name', $state, $state_code, $country_code ); |
|
83 | + return apply_filters('wpinv_state_name', $state, $state_code, $country_code); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | function wpinv_store_address() { |
87 | - $address = wpinv_get_option( 'store_address', '' ); |
|
87 | + $address = wpinv_get_option('store_address', ''); |
|
88 | 88 | |
89 | - return apply_filters( 'wpinv_store_address', $address ); |
|
89 | + return apply_filters('wpinv_store_address', $address); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -94,24 +94,24 @@ discard block |
||
94 | 94 | * |
95 | 95 | * @param WPInv_Invoice $invoice |
96 | 96 | */ |
97 | -function getpaid_maybe_add_default_address( &$invoice ) { |
|
97 | +function getpaid_maybe_add_default_address(&$invoice) { |
|
98 | 98 | |
99 | 99 | $user_id = $invoice->get_user_id(); |
100 | 100 | |
101 | 101 | // Abort if the invoice belongs to no one. |
102 | - if ( empty( $user_id ) ) { |
|
102 | + if (empty($user_id)) { |
|
103 | 103 | return; |
104 | 104 | } |
105 | 105 | |
106 | 106 | // Fill in defaults whenever necessary. |
107 | - foreach ( wpinv_get_user_address( $user_id ) as $key => $value ) { |
|
107 | + foreach (wpinv_get_user_address($user_id) as $key => $value) { |
|
108 | 108 | |
109 | - if ( is_callable( $invoice, "get_$key" ) ) { |
|
110 | - $current = call_user_func( array( $invoice, "get_$key" ) ); |
|
109 | + if (is_callable($invoice, "get_$key")) { |
|
110 | + $current = call_user_func(array($invoice, "get_$key")); |
|
111 | 111 | |
112 | - if ( empty( $current ) ) { |
|
112 | + if (empty($current)) { |
|
113 | 113 | $method = "set_$key"; |
114 | - $invoice->$method( $value ); |
|
114 | + $invoice->$method($value); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | } |
@@ -130,16 +130,16 @@ discard block |
||
130 | 130 | return apply_filters( |
131 | 131 | 'getpaid_user_address_fields', |
132 | 132 | array( |
133 | - 'first_name' => __( 'First Name', 'invoicing' ), |
|
134 | - 'last_name' => __( 'Last Name', 'invoicing' ), |
|
135 | - 'country' => __( 'Country', 'invoicing' ), |
|
136 | - 'state' => __( 'State', 'invoicing' ), |
|
137 | - 'city' => __( 'City', 'invoicing' ), |
|
138 | - 'zip' => __( 'Zip/Postal Code', 'invoicing' ), |
|
139 | - 'address' => __( 'Address', 'invoicing' ), |
|
140 | - 'phone' => __( 'Phone Number', 'invoicing' ), |
|
141 | - 'company' => __( 'Company', 'invoicing' ), |
|
142 | - 'vat_number' => __( 'VAT Number', 'invoicing' ), |
|
133 | + 'first_name' => __('First Name', 'invoicing'), |
|
134 | + 'last_name' => __('Last Name', 'invoicing'), |
|
135 | + 'country' => __('Country', 'invoicing'), |
|
136 | + 'state' => __('State', 'invoicing'), |
|
137 | + 'city' => __('City', 'invoicing'), |
|
138 | + 'zip' => __('Zip/Postal Code', 'invoicing'), |
|
139 | + 'address' => __('Address', 'invoicing'), |
|
140 | + 'phone' => __('Phone Number', 'invoicing'), |
|
141 | + 'company' => __('Company', 'invoicing'), |
|
142 | + 'vat_number' => __('VAT Number', 'invoicing'), |
|
143 | 143 | ) |
144 | 144 | ); |
145 | 145 | |
@@ -150,8 +150,8 @@ discard block |
||
150 | 150 | * |
151 | 151 | * @return bool |
152 | 152 | */ |
153 | -function getpaid_is_address_field_whitelisted( $key ) { |
|
154 | - return array_key_exists( $key, getpaid_user_address_fields() ); |
|
153 | +function getpaid_is_address_field_whitelisted($key) { |
|
154 | + return array_key_exists($key, getpaid_user_address_fields()); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -161,24 +161,24 @@ discard block |
||
161 | 161 | * |
162 | 162 | * @param WPInv_Invoice $invoice |
163 | 163 | */ |
164 | -function getpaid_save_invoice_user_address( $invoice ) { |
|
164 | +function getpaid_save_invoice_user_address($invoice) { |
|
165 | 165 | |
166 | 166 | // Retrieve the invoice. |
167 | - $invoice = wpinv_get_invoice( $invoice ); |
|
167 | + $invoice = wpinv_get_invoice($invoice); |
|
168 | 168 | |
169 | 169 | // Abort if it does not exist. |
170 | - if ( empty( $invoice ) ) { |
|
170 | + if (empty($invoice)) { |
|
171 | 171 | return; |
172 | 172 | } |
173 | 173 | |
174 | - foreach ( array_keys( getpaid_user_address_fields() ) as $field ) { |
|
174 | + foreach (array_keys(getpaid_user_address_fields()) as $field) { |
|
175 | 175 | |
176 | - if ( is_callable( array( $invoice, "get_$field" ) ) ) { |
|
177 | - $value = call_user_func( array( $invoice, "get_$field" ) ); |
|
176 | + if (is_callable(array($invoice, "get_$field"))) { |
|
177 | + $value = call_user_func(array($invoice, "get_$field")); |
|
178 | 178 | |
179 | 179 | // Only save if it is not empty. |
180 | - if ( ! empty( $value ) ) { |
|
181 | - update_user_meta( $invoice->get_user_id(), '_wpinv_' . $field, $value ); |
|
180 | + if (!empty($value)) { |
|
181 | + update_user_meta($invoice->get_user_id(), '_wpinv_' . $field, $value); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | } |
@@ -189,24 +189,24 @@ discard block |
||
189 | 189 | $last_name = $invoice->get_last_name(); |
190 | 190 | $update = array(); |
191 | 191 | |
192 | - if ( ! empty( $first_name ) ) { |
|
192 | + if (!empty($first_name)) { |
|
193 | 193 | $update['first_name'] = $first_name; |
194 | 194 | } |
195 | 195 | |
196 | - if ( ! empty( $last_name ) ) { |
|
196 | + if (!empty($last_name)) { |
|
197 | 197 | $update['last_name'] = $last_name; |
198 | 198 | } |
199 | 199 | |
200 | - if ( 2 == count( $update ) ) { |
|
201 | - $update['display_name'] = $first_name . ' ' .$last_name; |
|
200 | + if (2 == count($update)) { |
|
201 | + $update['display_name'] = $first_name . ' ' . $last_name; |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | $update['ID'] = $invoice->get_user_id(); |
205 | - wp_update_user( $update ); |
|
205 | + wp_update_user($update); |
|
206 | 206 | |
207 | 207 | } |
208 | -add_action( 'getpaid_new_invoice', 'getpaid_save_invoice_user_address' ); |
|
209 | -add_action( 'getpaid_update_invoice', 'getpaid_save_invoice_user_address' ); |
|
208 | +add_action('getpaid_new_invoice', 'getpaid_save_invoice_user_address'); |
|
209 | +add_action('getpaid_update_invoice', 'getpaid_save_invoice_user_address'); |
|
210 | 210 | |
211 | 211 | /** |
212 | 212 | * Retrieves a saved user address. |
@@ -215,14 +215,14 @@ discard block |
||
215 | 215 | * @param bool $with_default Whether or not we should use the default country and state. |
216 | 216 | * @return array |
217 | 217 | */ |
218 | -function wpinv_get_user_address( $user_id = 0, $with_default = true ) { |
|
218 | +function wpinv_get_user_address($user_id = 0, $with_default = true) { |
|
219 | 219 | |
220 | 220 | // Prepare the user id. |
221 | - $user_id = empty( $user_id ) ? get_current_user_id() : $user_id; |
|
222 | - $user_info = get_userdata( $user_id ); |
|
221 | + $user_id = empty($user_id) ? get_current_user_id() : $user_id; |
|
222 | + $user_info = get_userdata($user_id); |
|
223 | 223 | |
224 | 224 | // Abort if non exists. |
225 | - if ( empty( $user_info ) ) { |
|
225 | + if (empty($user_info)) { |
|
226 | 226 | return array(); |
227 | 227 | } |
228 | 228 | |
@@ -232,11 +232,11 @@ discard block |
||
232 | 232 | 'email' => $user_info->user_email, |
233 | 233 | ); |
234 | 234 | |
235 | - foreach ( array_keys( getpaid_user_address_fields() ) as $field ) { |
|
236 | - $address[$field] = getpaid_get_user_address_field( $user_id, $field ); |
|
235 | + foreach (array_keys(getpaid_user_address_fields()) as $field) { |
|
236 | + $address[$field] = getpaid_get_user_address_field($user_id, $field); |
|
237 | 237 | } |
238 | 238 | |
239 | - if ( ! $with_default ) { |
|
239 | + if (!$with_default) { |
|
240 | 240 | return $address; |
241 | 241 | } |
242 | 242 | |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | 'country' => wpinv_get_default_country(), |
248 | 248 | ); |
249 | 249 | |
250 | - return getpaid_array_merge_if_empty( $address, $defaults ); |
|
250 | + return getpaid_array_merge_if_empty($address, $defaults); |
|
251 | 251 | |
252 | 252 | } |
253 | 253 | |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * @param string $field The field to use. |
259 | 259 | * @return string|null |
260 | 260 | */ |
261 | -function getpaid_get_user_address_field( $user_id, $field ) { |
|
261 | +function getpaid_get_user_address_field($user_id, $field) { |
|
262 | 262 | |
263 | 263 | $prefixes = array( |
264 | 264 | '_wpinv_', |
@@ -266,15 +266,15 @@ discard block |
||
266 | 266 | '' |
267 | 267 | ); |
268 | 268 | |
269 | - foreach ( $prefixes as $prefix ) { |
|
269 | + foreach ($prefixes as $prefix) { |
|
270 | 270 | |
271 | 271 | // Meta table. |
272 | - $value = get_user_meta( $user_id, $prefix . $field, true ); |
|
272 | + $value = get_user_meta($user_id, $prefix . $field, true); |
|
273 | 273 | |
274 | 274 | // UWP table. |
275 | - $value = ( empty( $value ) && function_exists( 'uwp_get_usermeta' ) ) ? uwp_get_usermeta( $user_id, $prefix . $field ) : $value; |
|
275 | + $value = (empty($value) && function_exists('uwp_get_usermeta')) ? uwp_get_usermeta($user_id, $prefix . $field) : $value; |
|
276 | 276 | |
277 | - if ( ! empty( $value ) ) { |
|
277 | + if (!empty($value)) { |
|
278 | 278 | return $value; |
279 | 279 | } |
280 | 280 | |
@@ -291,16 +291,16 @@ discard block |
||
291 | 291 | * @param string $return What to return. |
292 | 292 | * @return array |
293 | 293 | */ |
294 | -function wpinv_get_continents( $return = 'all' ) { |
|
294 | +function wpinv_get_continents($return = 'all') { |
|
295 | 295 | |
296 | - $continents = wpinv_get_data( 'continents' ); |
|
296 | + $continents = wpinv_get_data('continents'); |
|
297 | 297 | |
298 | - switch( $return ) { |
|
298 | + switch ($return) { |
|
299 | 299 | case 'name' : |
300 | - return wp_list_pluck( $continents, 'name' ); |
|
300 | + return wp_list_pluck($continents, 'name'); |
|
301 | 301 | break; |
302 | 302 | case 'countries' : |
303 | - return wp_list_pluck( $continents, 'countries' ); |
|
303 | + return wp_list_pluck($continents, 'countries'); |
|
304 | 304 | break; |
305 | 305 | default : |
306 | 306 | return $continents; |
@@ -316,12 +316,12 @@ discard block |
||
316 | 316 | * @param string $country Country code. If no code is specified, defaults to the default country. |
317 | 317 | * @return string |
318 | 318 | */ |
319 | -function wpinv_get_continent_code_for_country( $country = false ) { |
|
319 | +function wpinv_get_continent_code_for_country($country = false) { |
|
320 | 320 | |
321 | - $country = wpinv_sanitize_country( $country ); |
|
321 | + $country = wpinv_sanitize_country($country); |
|
322 | 322 | |
323 | - foreach ( wpinv_get_continents( 'countries' ) as $continent_code => $countries ) { |
|
324 | - if ( false !== array_search( $country, $countries, true ) ) { |
|
323 | + foreach (wpinv_get_continents('countries') as $continent_code => $countries) { |
|
324 | + if (false !== array_search($country, $countries, true)) { |
|
325 | 325 | return $continent_code; |
326 | 326 | } |
327 | 327 | } |
@@ -337,13 +337,13 @@ discard block |
||
337 | 337 | * @param string $country Country code. If no code is specified, defaults to the default country. |
338 | 338 | * @return array |
339 | 339 | */ |
340 | -function wpinv_get_country_calling_code( $country = null) { |
|
340 | +function wpinv_get_country_calling_code($country = null) { |
|
341 | 341 | |
342 | - $country = wpinv_sanitize_country( $country ); |
|
343 | - $codes = wpinv_get_data( 'phone-codes' ); |
|
344 | - $code = isset( $codes[ $country ] ) ? $codes[ $country ] : ''; |
|
342 | + $country = wpinv_sanitize_country($country); |
|
343 | + $codes = wpinv_get_data('phone-codes'); |
|
344 | + $code = isset($codes[$country]) ? $codes[$country] : ''; |
|
345 | 345 | |
346 | - if ( is_array( $code ) ) { |
|
346 | + if (is_array($code)) { |
|
347 | 347 | return $code[0]; |
348 | 348 | } |
349 | 349 | return $code; |
@@ -356,8 +356,8 @@ discard block |
||
356 | 356 | * @param bool $first_empty Whether or not the first item in the list should be empty |
357 | 357 | * @return array |
358 | 358 | */ |
359 | -function wpinv_get_country_list( $first_empty = false ) { |
|
360 | - return wpinv_maybe_add_empty_option( apply_filters( 'wpinv_countries', wpinv_get_data( 'countries' ) ), $first_empty ); |
|
359 | +function wpinv_get_country_list($first_empty = false) { |
|
360 | + return wpinv_maybe_add_empty_option(apply_filters('wpinv_countries', wpinv_get_data('countries')), $first_empty); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | /** |
@@ -367,22 +367,22 @@ discard block |
||
367 | 367 | * @param bool $first_empty Whether or not the first item in the list should be empty |
368 | 368 | * @return array |
369 | 369 | */ |
370 | -function wpinv_get_country_states( $country = null, $first_empty = false ) { |
|
370 | +function wpinv_get_country_states($country = null, $first_empty = false) { |
|
371 | 371 | |
372 | 372 | // Prepare the country. |
373 | - $country = wpinv_sanitize_country( $country ); |
|
373 | + $country = wpinv_sanitize_country($country); |
|
374 | 374 | |
375 | 375 | // Fetch all states. |
376 | - $all_states = wpinv_get_data( 'states' ); |
|
376 | + $all_states = wpinv_get_data('states'); |
|
377 | 377 | |
378 | 378 | // Fetch the specified country's states. |
379 | - $states = isset( $all_states[ $country ] ) ? $all_states[ $country ] : array() ; |
|
380 | - $states = apply_filters( "wpinv_{$country}_states", $states ); |
|
381 | - $states = apply_filters( 'wpinv_country_states', $states, $country ); |
|
379 | + $states = isset($all_states[$country]) ? $all_states[$country] : array(); |
|
380 | + $states = apply_filters("wpinv_{$country}_states", $states); |
|
381 | + $states = apply_filters('wpinv_country_states', $states, $country); |
|
382 | 382 | |
383 | - asort( $states ); |
|
383 | + asort($states); |
|
384 | 384 | |
385 | - return wpinv_maybe_add_empty_option( $states, $first_empty ); |
|
385 | + return wpinv_maybe_add_empty_option($states, $first_empty); |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | /** |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | * @return array |
393 | 393 | */ |
394 | 394 | function wpinv_get_us_states_list() { |
395 | - return apply_filters( 'wpinv_usa_states', wpinv_get_country_states( 'US' ) ); |
|
395 | + return apply_filters('wpinv_usa_states', wpinv_get_country_states('US')); |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | /** |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | * @return array |
403 | 403 | */ |
404 | 404 | function wpinv_get_canada_states_list() { |
405 | - return apply_filters( 'wpinv_canada_provinces', wpinv_get_country_states( 'CA' ) ); |
|
405 | + return apply_filters('wpinv_canada_provinces', wpinv_get_country_states('CA')); |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | /** |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | * @return array |
413 | 413 | */ |
414 | 414 | function wpinv_get_australia_states_list() { |
415 | - return apply_filters( 'wpinv_australia_states', wpinv_get_country_states( 'AU' ) ); |
|
415 | + return apply_filters('wpinv_australia_states', wpinv_get_country_states('AU')); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | /** |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | * @return array |
423 | 423 | */ |
424 | 424 | function wpinv_get_bangladesh_states_list() { |
425 | - return apply_filters( 'wpinv_bangladesh_states', wpinv_get_country_states( 'BD' ) ); |
|
425 | + return apply_filters('wpinv_bangladesh_states', wpinv_get_country_states('BD')); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | /** |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | * @return array |
433 | 433 | */ |
434 | 434 | function wpinv_get_brazil_states_list() { |
435 | - return apply_filters( 'wpinv_brazil_states', wpinv_get_country_states( 'BR' ) ); |
|
435 | + return apply_filters('wpinv_brazil_states', wpinv_get_country_states('BR')); |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | /** |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | * @return array |
443 | 443 | */ |
444 | 444 | function wpinv_get_bulgaria_states_list() { |
445 | - return apply_filters( 'wpinv_bulgaria_states', wpinv_get_country_states( 'BG' ) ); |
|
445 | + return apply_filters('wpinv_bulgaria_states', wpinv_get_country_states('BG')); |
|
446 | 446 | } |
447 | 447 | |
448 | 448 | /** |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | * @return array |
453 | 453 | */ |
454 | 454 | function wpinv_get_hong_kong_states_list() { |
455 | - return apply_filters( 'wpinv_hong_kong_states', wpinv_get_country_states( 'HK' ) ); |
|
455 | + return apply_filters('wpinv_hong_kong_states', wpinv_get_country_states('HK')); |
|
456 | 456 | } |
457 | 457 | |
458 | 458 | /** |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | * @return array |
463 | 463 | */ |
464 | 464 | function wpinv_get_hungary_states_list() { |
465 | - return apply_filters( 'wpinv_hungary_states', wpinv_get_country_states( 'HU' ) ); |
|
465 | + return apply_filters('wpinv_hungary_states', wpinv_get_country_states('HU')); |
|
466 | 466 | } |
467 | 467 | |
468 | 468 | /** |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | * @return array |
473 | 473 | */ |
474 | 474 | function wpinv_get_japan_states_list() { |
475 | - return apply_filters( 'wpinv_japan_states', wpinv_get_country_states( 'JP' ) ); |
|
475 | + return apply_filters('wpinv_japan_states', wpinv_get_country_states('JP')); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | /** |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | * @return array |
483 | 483 | */ |
484 | 484 | function wpinv_get_china_states_list() { |
485 | - return apply_filters( 'wpinv_china_states', wpinv_get_country_states( 'CN' ) ); |
|
485 | + return apply_filters('wpinv_china_states', wpinv_get_country_states('CN')); |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | /** |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | * @return array |
493 | 493 | */ |
494 | 494 | function wpinv_get_new_zealand_states_list() { |
495 | - return apply_filters( 'wpinv_new_zealand_states', wpinv_get_country_states( 'NZ' ) ); |
|
495 | + return apply_filters('wpinv_new_zealand_states', wpinv_get_country_states('NZ')); |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | /** |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | * @return array |
503 | 503 | */ |
504 | 504 | function wpinv_get_peru_states_list() { |
505 | - return apply_filters( 'wpinv_peru_states', wpinv_get_country_states( 'PE' ) ); |
|
505 | + return apply_filters('wpinv_peru_states', wpinv_get_country_states('PE')); |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | /** |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | * @return array |
513 | 513 | */ |
514 | 514 | function wpinv_get_indonesia_states_list() { |
515 | - return apply_filters( 'wpinv_indonesia_states', wpinv_get_country_states( 'ID' ) ); |
|
515 | + return apply_filters('wpinv_indonesia_states', wpinv_get_country_states('ID')); |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | /** |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | * @return array |
523 | 523 | */ |
524 | 524 | function wpinv_get_india_states_list() { |
525 | - return apply_filters( 'wpinv_india_states', wpinv_get_country_states( 'IN' ) ); |
|
525 | + return apply_filters('wpinv_india_states', wpinv_get_country_states('IN')); |
|
526 | 526 | } |
527 | 527 | |
528 | 528 | /** |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | * @return array |
533 | 533 | */ |
534 | 534 | function wpinv_get_iran_states_list() { |
535 | - return apply_filters( 'wpinv_iran_states', wpinv_get_country_states( 'IR' ) ); |
|
535 | + return apply_filters('wpinv_iran_states', wpinv_get_country_states('IR')); |
|
536 | 536 | } |
537 | 537 | |
538 | 538 | /** |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | * @return array |
543 | 543 | */ |
544 | 544 | function wpinv_get_italy_states_list() { |
545 | - return apply_filters( 'wpinv_italy_states', wpinv_get_country_states( 'IT' ) ); |
|
545 | + return apply_filters('wpinv_italy_states', wpinv_get_country_states('IT')); |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | /** |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | * @return array |
553 | 553 | */ |
554 | 554 | function wpinv_get_malaysia_states_list() { |
555 | - return apply_filters( 'wpinv_malaysia_states', wpinv_get_country_states( 'MY' ) ); |
|
555 | + return apply_filters('wpinv_malaysia_states', wpinv_get_country_states('MY')); |
|
556 | 556 | } |
557 | 557 | |
558 | 558 | /** |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | * @return array |
563 | 563 | */ |
564 | 564 | function wpinv_get_mexico_states_list() { |
565 | - return apply_filters( 'wpinv_mexico_states', wpinv_get_country_states( 'MX' ) ); |
|
565 | + return apply_filters('wpinv_mexico_states', wpinv_get_country_states('MX')); |
|
566 | 566 | } |
567 | 567 | |
568 | 568 | /** |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | * @return array |
573 | 573 | */ |
574 | 574 | function wpinv_get_nepal_states_list() { |
575 | - return apply_filters( 'wpinv_nepal_states', wpinv_get_country_states( 'NP' ) ); |
|
575 | + return apply_filters('wpinv_nepal_states', wpinv_get_country_states('NP')); |
|
576 | 576 | } |
577 | 577 | |
578 | 578 | /** |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | * @return array |
583 | 583 | */ |
584 | 584 | function wpinv_get_south_africa_states_list() { |
585 | - return apply_filters( 'wpinv_south_africa_states', wpinv_get_country_states( 'ZA' ) ); |
|
585 | + return apply_filters('wpinv_south_africa_states', wpinv_get_country_states('ZA')); |
|
586 | 586 | } |
587 | 587 | |
588 | 588 | /** |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | * @return array |
593 | 593 | */ |
594 | 594 | function wpinv_get_thailand_states_list() { |
595 | - return apply_filters( 'wpinv_thailand_states', wpinv_get_country_states( 'TH' ) ); |
|
595 | + return apply_filters('wpinv_thailand_states', wpinv_get_country_states('TH')); |
|
596 | 596 | } |
597 | 597 | |
598 | 598 | /** |
@@ -602,7 +602,7 @@ discard block |
||
602 | 602 | * @return array |
603 | 603 | */ |
604 | 604 | function wpinv_get_turkey_states_list() { |
605 | - return apply_filters( 'wpinv_turkey_states', wpinv_get_country_states( 'TR' ) ); |
|
605 | + return apply_filters('wpinv_turkey_states', wpinv_get_country_states('TR')); |
|
606 | 606 | } |
607 | 607 | |
608 | 608 | /** |
@@ -612,28 +612,28 @@ discard block |
||
612 | 612 | * @return array |
613 | 613 | */ |
614 | 614 | function wpinv_get_spain_states_list() { |
615 | - return apply_filters( 'wpinv_spain_states', wpinv_get_country_states( 'ES' ) ); |
|
615 | + return apply_filters('wpinv_spain_states', wpinv_get_country_states('ES')); |
|
616 | 616 | } |
617 | 617 | |
618 | 618 | function wpinv_get_states_field() { |
619 | - if( empty( $_POST['country'] ) ) { |
|
619 | + if (empty($_POST['country'])) { |
|
620 | 620 | $_POST['country'] = wpinv_get_default_country(); |
621 | 621 | } |
622 | - $states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) ); |
|
622 | + $states = wpinv_get_country_states(sanitize_text_field($_POST['country'])); |
|
623 | 623 | |
624 | - if( !empty( $states ) ) { |
|
625 | - $sanitized_field_name = sanitize_text_field( $_POST['field_name'] ); |
|
624 | + if (!empty($states)) { |
|
625 | + $sanitized_field_name = sanitize_text_field($_POST['field_name']); |
|
626 | 626 | |
627 | 627 | $args = array( |
628 | 628 | 'name' => $sanitized_field_name, |
629 | 629 | 'id' => $sanitized_field_name, |
630 | 630 | 'class' => $sanitized_field_name . 'custom-select wpinv-select wpi_select2', |
631 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
631 | + 'options' => array_merge(array('' => ''), $states), |
|
632 | 632 | 'show_option_all' => false, |
633 | 633 | 'show_option_none' => false |
634 | 634 | ); |
635 | 635 | |
636 | - $response = wpinv_html_select( $args ); |
|
636 | + $response = wpinv_html_select($args); |
|
637 | 637 | |
638 | 638 | } else { |
639 | 639 | $response = 'nostates'; |
@@ -642,10 +642,10 @@ discard block |
||
642 | 642 | return $response; |
643 | 643 | } |
644 | 644 | |
645 | -function wpinv_default_billing_country( $country = '', $user_id = 0 ) { |
|
646 | - $country = !empty( $country ) ? $country : wpinv_get_default_country(); |
|
645 | +function wpinv_default_billing_country($country = '', $user_id = 0) { |
|
646 | + $country = !empty($country) ? $country : wpinv_get_default_country(); |
|
647 | 647 | |
648 | - return apply_filters( 'wpinv_default_billing_country', $country, $user_id ); |
|
648 | + return apply_filters('wpinv_default_billing_country', $country, $user_id); |
|
649 | 649 | } |
650 | 650 | |
651 | 651 | /** |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | */ |
658 | 658 | function wpinv_get_address_formats() { |
659 | 659 | |
660 | - return apply_filters( 'wpinv_localisation_address_formats', |
|
660 | + return apply_filters('wpinv_localisation_address_formats', |
|
661 | 661 | array( |
662 | 662 | 'default' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}\n{{zip}}\n{{country}}", |
663 | 663 | 'AU' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}} {{zip}}\n{{country}}", |
@@ -706,9 +706,9 @@ discard block |
||
706 | 706 | * @see `wpinv_get_invoice_address_replacements` |
707 | 707 | * @return string |
708 | 708 | */ |
709 | -function wpinv_get_full_address_format( $country = false) { |
|
709 | +function wpinv_get_full_address_format($country = false) { |
|
710 | 710 | |
711 | - if( empty( $country ) ) { |
|
711 | + if (empty($country)) { |
|
712 | 712 | $country = wpinv_get_default_country(); |
713 | 713 | } |
714 | 714 | |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | $formats = wpinv_get_address_formats(); |
717 | 717 | |
718 | 718 | // Get format for the specified country. |
719 | - $format = ( $country && isset( $formats[ $country ] ) ) ? $formats[ $country ] : $formats['default']; |
|
719 | + $format = ($country && isset($formats[$country])) ? $formats[$country] : $formats['default']; |
|
720 | 720 | |
721 | 721 | /** |
722 | 722 | * Filters the address format to use on Invoices. |
@@ -728,7 +728,7 @@ discard block |
||
728 | 728 | * @param string $format The address format to use. |
729 | 729 | * @param string $country The country who's address format is being retrieved. |
730 | 730 | */ |
731 | - return apply_filters( 'wpinv_get_full_address_format', $format, $country ); |
|
731 | + return apply_filters('wpinv_get_full_address_format', $format, $country); |
|
732 | 732 | } |
733 | 733 | |
734 | 734 | /** |
@@ -739,7 +739,7 @@ discard block |
||
739 | 739 | * @param array $billing_details customer's billing details |
740 | 740 | * @return array |
741 | 741 | */ |
742 | -function wpinv_get_invoice_address_replacements( $billing_details ) { |
|
742 | +function wpinv_get_invoice_address_replacements($billing_details) { |
|
743 | 743 | |
744 | 744 | $default_args = array( |
745 | 745 | 'address' => '', |
@@ -752,22 +752,22 @@ discard block |
||
752 | 752 | 'company' => '', |
753 | 753 | ); |
754 | 754 | |
755 | - $args = map_deep( wp_parse_args( $billing_details, $default_args ), 'trim' ); |
|
755 | + $args = map_deep(wp_parse_args($billing_details, $default_args), 'trim'); |
|
756 | 756 | $state = $args['state']; |
757 | 757 | $country = $args['country']; |
758 | 758 | |
759 | 759 | // Handle full country name. |
760 | - $full_country = empty( $country ) ? $country : wpinv_country_name( $country ); |
|
760 | + $full_country = empty($country) ? $country : wpinv_country_name($country); |
|
761 | 761 | |
762 | 762 | // Handle full state name. |
763 | - $full_state = ( $country && $state ) ? wpinv_state_name( $state, $country ) : $state; |
|
763 | + $full_state = ($country && $state) ? wpinv_state_name($state, $country) : $state; |
|
764 | 764 | |
765 | 765 | $args['postcode'] = $args['zip']; |
766 | 766 | $args['name'] = $args['first_name'] . ' ' . $args['last_name']; |
767 | 767 | $args['state'] = $full_state; |
768 | 768 | $args['state_code'] = $state; |
769 | 769 | $args['country'] = $full_country; |
770 | - $args['country_code']= $country; |
|
770 | + $args['country_code'] = $country; |
|
771 | 771 | |
772 | 772 | /** |
773 | 773 | * Filters the address format replacements to use on Invoices. |
@@ -778,14 +778,14 @@ discard block |
||
778 | 778 | * @param array $replacements The address replacements to use. |
779 | 779 | * @param array $billing_details The billing details to use. |
780 | 780 | */ |
781 | - $replacements = apply_filters( 'wpinv_get_invoice_address_replacements', $args, $billing_details ); |
|
781 | + $replacements = apply_filters('wpinv_get_invoice_address_replacements', $args, $billing_details); |
|
782 | 782 | |
783 | 783 | $return = array(); |
784 | 784 | |
785 | - foreach( $replacements as $key => $value ) { |
|
786 | - $value = is_scalar( $value ) ? trim( sanitize_text_field( $value ) ) : ''; |
|
785 | + foreach ($replacements as $key => $value) { |
|
786 | + $value = is_scalar($value) ? trim(sanitize_text_field($value)) : ''; |
|
787 | 787 | $return['{{' . $key . '}}'] = $value; |
788 | - $return['{{' . $key . '_upper}}'] = wpinv_utf8_strtoupper( $value ); |
|
788 | + $return['{{' . $key . '_upper}}'] = wpinv_utf8_strtoupper($value); |
|
789 | 789 | } |
790 | 790 | |
791 | 791 | return $return; |
@@ -799,6 +799,6 @@ discard block |
||
799 | 799 | * @since 1.0.14 |
800 | 800 | * @return string |
801 | 801 | */ |
802 | -function wpinv_trim_formatted_address_line( $line ) { |
|
803 | - return trim( $line, ', ' ); |
|
802 | +function wpinv_trim_formatted_address_line($line) { |
|
803 | + return trim($line, ', '); |
|
804 | 804 | } |
805 | 805 | \ No newline at end of file |