@@ -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', '' ); |
|
59 | + $state = wpinv_get_option('default_state', ''); |
|
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 |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * |
9 | 9 | */ |
10 | 10 | |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if (!defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | * |
118 | 118 | * @param int|object|array|string $read ID to load from the DB (optional) or already queried data. |
119 | 119 | */ |
120 | - public function __construct( $read = 0 ) { |
|
121 | - $this->data = array_merge( $this->data, $this->extra_data ); |
|
120 | + public function __construct($read = 0) { |
|
121 | + $this->data = array_merge($this->data, $this->extra_data); |
|
122 | 122 | $this->default_data = $this->data; |
123 | 123 | } |
124 | 124 | |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @return array |
129 | 129 | */ |
130 | 130 | public function __sleep() { |
131 | - return array( 'id' ); |
|
131 | + return array('id'); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | * If the object no longer exists, remove the ID. |
138 | 138 | */ |
139 | 139 | public function __wakeup() { |
140 | - $this->__construct( absint( $this->id ) ); |
|
140 | + $this->__construct(absint($this->id)); |
|
141 | 141 | |
142 | - if ( ! empty( $this->last_error ) ) { |
|
143 | - $this->set_id( 0 ); |
|
142 | + if (!empty($this->last_error)) { |
|
143 | + $this->set_id(0); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | } |
@@ -152,11 +152,11 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function __clone() { |
154 | 154 | $this->maybe_read_meta_data(); |
155 | - if ( ! empty( $this->meta_data ) ) { |
|
156 | - foreach ( $this->meta_data as $array_key => $meta ) { |
|
157 | - $this->meta_data[ $array_key ] = clone $meta; |
|
158 | - if ( ! empty( $meta->id ) ) { |
|
159 | - $this->meta_data[ $array_key ]->id = null; |
|
155 | + if (!empty($this->meta_data)) { |
|
156 | + foreach ($this->meta_data as $array_key => $meta) { |
|
157 | + $this->meta_data[$array_key] = clone $meta; |
|
158 | + if (!empty($meta->id)) { |
|
159 | + $this->meta_data[$array_key]->id = null; |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | } |
@@ -199,8 +199,8 @@ discard block |
||
199 | 199 | * @param string $context View or edit context. |
200 | 200 | * @return string |
201 | 201 | */ |
202 | - public function get_status( $context = 'view' ) { |
|
203 | - return $this->get_prop( 'status', $context ); |
|
202 | + public function get_status($context = 'view') { |
|
203 | + return $this->get_prop('status', $context); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -210,10 +210,10 @@ discard block |
||
210 | 210 | * @param bool $force_delete Should the data be deleted permanently. |
211 | 211 | * @return bool result |
212 | 212 | */ |
213 | - public function delete( $force_delete = false ) { |
|
214 | - if ( $this->data_store && $this->get_id() ) { |
|
215 | - $this->data_store->delete( $this, array( 'force_delete' => $force_delete ) ); |
|
216 | - $this->set_id( 0 ); |
|
213 | + public function delete($force_delete = false) { |
|
214 | + if ($this->data_store && $this->get_id()) { |
|
215 | + $this->data_store->delete($this, array('force_delete' => $force_delete)); |
|
216 | + $this->set_id(0); |
|
217 | 217 | return true; |
218 | 218 | } |
219 | 219 | return false; |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | * @return int |
227 | 227 | */ |
228 | 228 | public function save() { |
229 | - if ( ! $this->data_store ) { |
|
229 | + if (!$this->data_store) { |
|
230 | 230 | return $this->get_id(); |
231 | 231 | } |
232 | 232 | |
@@ -236,12 +236,12 @@ discard block |
||
236 | 236 | * @param GetPaid_Data $this The object being saved. |
237 | 237 | * @param GetPaid_Data_Store_WP $data_store The data store persisting the data. |
238 | 238 | */ |
239 | - do_action( 'getpaid_before_' . $this->object_type . '_object_save', $this, $this->data_store ); |
|
239 | + do_action('getpaid_before_' . $this->object_type . '_object_save', $this, $this->data_store); |
|
240 | 240 | |
241 | - if ( $this->get_id() ) { |
|
242 | - $this->data_store->update( $this ); |
|
241 | + if ($this->get_id()) { |
|
242 | + $this->data_store->update($this); |
|
243 | 243 | } else { |
244 | - $this->data_store->create( $this ); |
|
244 | + $this->data_store->create($this); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * @param GetPaid_Data $this The object being saved. |
251 | 251 | * @param GetPaid_Data_Store_WP $data_store The data store persisting the data. |
252 | 252 | */ |
253 | - do_action( 'getpaid_after_' . $this->object_type . '_object_save', $this, $this->data_store ); |
|
253 | + do_action('getpaid_after_' . $this->object_type . '_object_save', $this, $this->data_store); |
|
254 | 254 | |
255 | 255 | return $this->get_id(); |
256 | 256 | } |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | * @return string Data in JSON format. |
263 | 263 | */ |
264 | 264 | public function __toString() { |
265 | - return wp_json_encode( $this->get_data() ); |
|
265 | + return wp_json_encode($this->get_data()); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | * @return array |
273 | 273 | */ |
274 | 274 | public function get_data() { |
275 | - return array_merge( array( 'id' => $this->get_id() ), $this->data, array( 'meta_data' => $this->get_meta_data() ) ); |
|
275 | + return array_merge(array('id' => $this->get_id()), $this->data, array('meta_data' => $this->get_meta_data())); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | /** |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * @return array |
283 | 283 | */ |
284 | 284 | public function get_data_keys() { |
285 | - return array_keys( $this->data ); |
|
285 | + return array_keys($this->data); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | /** |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | * @return array |
293 | 293 | */ |
294 | 294 | public function get_extra_data_keys() { |
295 | - return array_keys( $this->extra_data ); |
|
295 | + return array_keys($this->extra_data); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | /** |
@@ -302,8 +302,8 @@ discard block |
||
302 | 302 | * @param mixed $meta Meta value to check. |
303 | 303 | * @return bool |
304 | 304 | */ |
305 | - protected function filter_null_meta( $meta ) { |
|
306 | - return ! is_null( $meta->value ); |
|
305 | + protected function filter_null_meta($meta) { |
|
306 | + return !is_null($meta->value); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | /** |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | */ |
315 | 315 | public function get_meta_data() { |
316 | 316 | $this->maybe_read_meta_data(); |
317 | - return array_values( array_filter( $this->meta_data, array( $this, 'filter_null_meta' ) ) ); |
|
317 | + return array_values(array_filter($this->meta_data, array($this, 'filter_null_meta'))); |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | /** |
@@ -324,21 +324,21 @@ discard block |
||
324 | 324 | * @param string $key Key to check. |
325 | 325 | * @return bool true if it's an internal key, false otherwise |
326 | 326 | */ |
327 | - protected function is_internal_meta_key( $key ) { |
|
328 | - $internal_meta_key = ! empty( $key ) && $this->data_store && in_array( $key, $this->data_store->get_internal_meta_keys(), true ); |
|
327 | + protected function is_internal_meta_key($key) { |
|
328 | + $internal_meta_key = !empty($key) && $this->data_store && in_array($key, $this->data_store->get_internal_meta_keys(), true); |
|
329 | 329 | |
330 | - if ( ! $internal_meta_key ) { |
|
330 | + if (!$internal_meta_key) { |
|
331 | 331 | return false; |
332 | 332 | } |
333 | 333 | |
334 | - $has_setter_or_getter = is_callable( array( $this, 'set_' . $key ) ) || is_callable( array( $this, 'get_' . $key ) ); |
|
334 | + $has_setter_or_getter = is_callable(array($this, 'set_' . $key)) || is_callable(array($this, 'get_' . $key)); |
|
335 | 335 | |
336 | - if ( ! $has_setter_or_getter ) { |
|
336 | + if (!$has_setter_or_getter) { |
|
337 | 337 | return false; |
338 | 338 | } |
339 | 339 | |
340 | 340 | /* translators: %s: $key Key to check */ |
341 | - getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Generic add/update/get meta methods should not be used for internal meta data, including "%s". Use getters and setters.', 'getpaid' ), $key ), '1.0.19' ); |
|
341 | + getpaid_doing_it_wrong(__FUNCTION__, sprintf(__('Generic add/update/get meta methods should not be used for internal meta data, including "%s". Use getters and setters.', 'getpaid'), $key), '1.0.19'); |
|
342 | 342 | |
343 | 343 | return true; |
344 | 344 | } |
@@ -352,20 +352,20 @@ discard block |
||
352 | 352 | * @access public |
353 | 353 | * |
354 | 354 | */ |
355 | - public function __set( $key, $value ) { |
|
355 | + public function __set($key, $value) { |
|
356 | 356 | |
357 | - if ( 'id' == strtolower( $key ) ) { |
|
358 | - return $this->set_id( $value ); |
|
357 | + if ('id' == strtolower($key)) { |
|
358 | + return $this->set_id($value); |
|
359 | 359 | } |
360 | 360 | |
361 | - if ( method_exists( $this, "set_$key") ) { |
|
361 | + if (method_exists($this, "set_$key")) { |
|
362 | 362 | |
363 | 363 | /* translators: %s: $key Key to set */ |
364 | - getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Object data such as "%s" should not be accessed directly. Use getters and setters.', 'getpaid' ), $key ), '1.0.19' ); |
|
364 | + getpaid_doing_it_wrong(__FUNCTION__, sprintf(__('Object data such as "%s" should not be accessed directly. Use getters and setters.', 'getpaid'), $key), '1.0.19'); |
|
365 | 365 | |
366 | - call_user_func( array( $this, "set_$key" ), $value ); |
|
366 | + call_user_func(array($this, "set_$key"), $value); |
|
367 | 367 | } else { |
368 | - $this->set_prop( $key, $value ); |
|
368 | + $this->set_prop($key, $value); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | } |
@@ -373,25 +373,25 @@ discard block |
||
373 | 373 | /** |
374 | 374 | * Margic method for retrieving a property. |
375 | 375 | */ |
376 | - public function __get( $key ) { |
|
376 | + public function __get($key) { |
|
377 | 377 | |
378 | 378 | // Check if we have a helper method for that. |
379 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
379 | + if (method_exists($this, 'get_' . $key)) { |
|
380 | 380 | |
381 | - if ( 'post_type' != $key ) { |
|
381 | + if ('post_type' != $key) { |
|
382 | 382 | /* translators: %s: $key Key to set */ |
383 | - getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Object data such as "%s" should not be accessed directly. Use getters and setters.', 'getpaid' ), $key ), '1.0.19' ); |
|
383 | + getpaid_doing_it_wrong(__FUNCTION__, sprintf(__('Object data such as "%s" should not be accessed directly. Use getters and setters.', 'getpaid'), $key), '1.0.19'); |
|
384 | 384 | } |
385 | 385 | |
386 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
386 | + return call_user_func(array($this, 'get_' . $key)); |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | // Check if the key is in the associated $post object. |
390 | - if ( ! empty( $this->post ) && isset( $this->post->$key ) ) { |
|
390 | + if (!empty($this->post) && isset($this->post->$key)) { |
|
391 | 391 | return $this->post->$key; |
392 | 392 | } |
393 | 393 | |
394 | - return $this->get_prop( $key ); |
|
394 | + return $this->get_prop($key); |
|
395 | 395 | |
396 | 396 | } |
397 | 397 | |
@@ -404,15 +404,15 @@ discard block |
||
404 | 404 | * @param string $context What the value is for. Valid values are view and edit. |
405 | 405 | * @return mixed |
406 | 406 | */ |
407 | - public function get_meta( $key = '', $single = true, $context = 'view' ) { |
|
407 | + public function get_meta($key = '', $single = true, $context = 'view') { |
|
408 | 408 | |
409 | 409 | // Check if this is an internal meta key. |
410 | - $_key = str_replace( '_wpinv', '', $key ); |
|
411 | - $_key = str_replace( 'wpinv', '', $_key ); |
|
412 | - if ( $this->is_internal_meta_key( $_key ) ) { |
|
410 | + $_key = str_replace('_wpinv', '', $key); |
|
411 | + $_key = str_replace('wpinv', '', $_key); |
|
412 | + if ($this->is_internal_meta_key($_key)) { |
|
413 | 413 | $function = 'get_' . $_key; |
414 | 414 | |
415 | - if ( is_callable( array( $this, $function ) ) ) { |
|
415 | + if (is_callable(array($this, $function))) { |
|
416 | 416 | return $this->{$function}(); |
417 | 417 | } |
418 | 418 | } |
@@ -420,20 +420,20 @@ discard block |
||
420 | 420 | // Read the meta data if not yet read. |
421 | 421 | $this->maybe_read_meta_data(); |
422 | 422 | $meta_data = $this->get_meta_data(); |
423 | - $array_keys = array_keys( wp_list_pluck( $meta_data, 'key' ), $key, true ); |
|
423 | + $array_keys = array_keys(wp_list_pluck($meta_data, 'key'), $key, true); |
|
424 | 424 | $value = $single ? '' : array(); |
425 | 425 | |
426 | - if ( ! empty( $array_keys ) ) { |
|
426 | + if (!empty($array_keys)) { |
|
427 | 427 | // We don't use the $this->meta_data property directly here because we don't want meta with a null value (i.e. meta which has been deleted via $this->delete_meta_data()). |
428 | - if ( $single ) { |
|
429 | - $value = $meta_data[ current( $array_keys ) ]->value; |
|
428 | + if ($single) { |
|
429 | + $value = $meta_data[current($array_keys)]->value; |
|
430 | 430 | } else { |
431 | - $value = array_intersect_key( $meta_data, array_flip( $array_keys ) ); |
|
431 | + $value = array_intersect_key($meta_data, array_flip($array_keys)); |
|
432 | 432 | } |
433 | 433 | } |
434 | 434 | |
435 | - if ( 'view' === $context ) { |
|
436 | - $value = apply_filters( $this->get_hook_prefix() . $key, $value, $this ); |
|
435 | + if ('view' === $context) { |
|
436 | + $value = apply_filters($this->get_hook_prefix() . $key, $value, $this); |
|
437 | 437 | } |
438 | 438 | |
439 | 439 | return $value; |
@@ -446,10 +446,10 @@ discard block |
||
446 | 446 | * @param string $key Meta Key. |
447 | 447 | * @return boolean |
448 | 448 | */ |
449 | - public function meta_exists( $key = '' ) { |
|
449 | + public function meta_exists($key = '') { |
|
450 | 450 | $this->maybe_read_meta_data(); |
451 | - $array_keys = wp_list_pluck( $this->get_meta_data(), 'key' ); |
|
452 | - return in_array( $key, $array_keys, true ); |
|
451 | + $array_keys = wp_list_pluck($this->get_meta_data(), 'key'); |
|
452 | + return in_array($key, $array_keys, true); |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | /** |
@@ -458,12 +458,12 @@ discard block |
||
458 | 458 | * @since 1.0.19 |
459 | 459 | * @param array $data Key/Value pairs. |
460 | 460 | */ |
461 | - public function set_meta_data( $data ) { |
|
462 | - if ( ! empty( $data ) && is_array( $data ) ) { |
|
461 | + public function set_meta_data($data) { |
|
462 | + if (!empty($data) && is_array($data)) { |
|
463 | 463 | $this->maybe_read_meta_data(); |
464 | - foreach ( $data as $meta ) { |
|
464 | + foreach ($data as $meta) { |
|
465 | 465 | $meta = (array) $meta; |
466 | - if ( isset( $meta['key'], $meta['value'], $meta['id'] ) ) { |
|
466 | + if (isset($meta['key'], $meta['value'], $meta['id'])) { |
|
467 | 467 | $this->meta_data[] = new GetPaid_Meta_Data( |
468 | 468 | array( |
469 | 469 | 'id' => $meta['id'], |
@@ -485,18 +485,18 @@ discard block |
||
485 | 485 | * @param string|array $value Meta value. |
486 | 486 | * @param bool $unique Should this be a unique key?. |
487 | 487 | */ |
488 | - public function add_meta_data( $key, $value, $unique = false ) { |
|
489 | - if ( $this->is_internal_meta_key( $key ) ) { |
|
488 | + public function add_meta_data($key, $value, $unique = false) { |
|
489 | + if ($this->is_internal_meta_key($key)) { |
|
490 | 490 | $function = 'set_' . $key; |
491 | 491 | |
492 | - if ( is_callable( array( $this, $function ) ) ) { |
|
493 | - return $this->{$function}( $value ); |
|
492 | + if (is_callable(array($this, $function))) { |
|
493 | + return $this->{$function}($value); |
|
494 | 494 | } |
495 | 495 | } |
496 | 496 | |
497 | 497 | $this->maybe_read_meta_data(); |
498 | - if ( $unique ) { |
|
499 | - $this->delete_meta_data( $key ); |
|
498 | + if ($unique) { |
|
499 | + $this->delete_meta_data($key); |
|
500 | 500 | } |
501 | 501 | $this->meta_data[] = new GetPaid_Meta_Data( |
502 | 502 | array( |
@@ -515,12 +515,12 @@ discard block |
||
515 | 515 | * @param string|array $value Meta value. |
516 | 516 | * @param int $meta_id Meta ID. |
517 | 517 | */ |
518 | - public function update_meta_data( $key, $value, $meta_id = 0 ) { |
|
519 | - if ( $this->is_internal_meta_key( $key ) ) { |
|
518 | + public function update_meta_data($key, $value, $meta_id = 0) { |
|
519 | + if ($this->is_internal_meta_key($key)) { |
|
520 | 520 | $function = 'set_' . $key; |
521 | 521 | |
522 | - if ( is_callable( array( $this, $function ) ) ) { |
|
523 | - return $this->{$function}( $value ); |
|
522 | + if (is_callable(array($this, $function))) { |
|
523 | + return $this->{$function}($value); |
|
524 | 524 | } |
525 | 525 | } |
526 | 526 | |
@@ -528,33 +528,33 @@ discard block |
||
528 | 528 | |
529 | 529 | $array_key = false; |
530 | 530 | |
531 | - if ( $meta_id ) { |
|
532 | - $array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), $meta_id, true ); |
|
533 | - $array_key = $array_keys ? current( $array_keys ) : false; |
|
531 | + if ($meta_id) { |
|
532 | + $array_keys = array_keys(wp_list_pluck($this->meta_data, 'id'), $meta_id, true); |
|
533 | + $array_key = $array_keys ? current($array_keys) : false; |
|
534 | 534 | } else { |
535 | 535 | // Find matches by key. |
536 | 536 | $matches = array(); |
537 | - foreach ( $this->meta_data as $meta_data_array_key => $meta ) { |
|
538 | - if ( $meta->key === $key ) { |
|
537 | + foreach ($this->meta_data as $meta_data_array_key => $meta) { |
|
538 | + if ($meta->key === $key) { |
|
539 | 539 | $matches[] = $meta_data_array_key; |
540 | 540 | } |
541 | 541 | } |
542 | 542 | |
543 | - if ( ! empty( $matches ) ) { |
|
543 | + if (!empty($matches)) { |
|
544 | 544 | // Set matches to null so only one key gets the new value. |
545 | - foreach ( $matches as $meta_data_array_key ) { |
|
546 | - $this->meta_data[ $meta_data_array_key ]->value = null; |
|
545 | + foreach ($matches as $meta_data_array_key) { |
|
546 | + $this->meta_data[$meta_data_array_key]->value = null; |
|
547 | 547 | } |
548 | - $array_key = current( $matches ); |
|
548 | + $array_key = current($matches); |
|
549 | 549 | } |
550 | 550 | } |
551 | 551 | |
552 | - if ( false !== $array_key ) { |
|
553 | - $meta = $this->meta_data[ $array_key ]; |
|
552 | + if (false !== $array_key) { |
|
553 | + $meta = $this->meta_data[$array_key]; |
|
554 | 554 | $meta->key = $key; |
555 | 555 | $meta->value = $value; |
556 | 556 | } else { |
557 | - $this->add_meta_data( $key, $value, true ); |
|
557 | + $this->add_meta_data($key, $value, true); |
|
558 | 558 | } |
559 | 559 | } |
560 | 560 | |
@@ -564,13 +564,13 @@ discard block |
||
564 | 564 | * @since 1.0.19 |
565 | 565 | * @param string $key Meta key. |
566 | 566 | */ |
567 | - public function delete_meta_data( $key ) { |
|
567 | + public function delete_meta_data($key) { |
|
568 | 568 | $this->maybe_read_meta_data(); |
569 | - $array_keys = array_keys( wp_list_pluck( $this->meta_data, 'key' ), $key, true ); |
|
569 | + $array_keys = array_keys(wp_list_pluck($this->meta_data, 'key'), $key, true); |
|
570 | 570 | |
571 | - if ( $array_keys ) { |
|
572 | - foreach ( $array_keys as $array_key ) { |
|
573 | - $this->meta_data[ $array_key ]->value = null; |
|
571 | + if ($array_keys) { |
|
572 | + foreach ($array_keys as $array_key) { |
|
573 | + $this->meta_data[$array_key]->value = null; |
|
574 | 574 | } |
575 | 575 | } |
576 | 576 | } |
@@ -581,13 +581,13 @@ discard block |
||
581 | 581 | * @since 1.0.19 |
582 | 582 | * @param int $mid Meta ID. |
583 | 583 | */ |
584 | - public function delete_meta_data_by_mid( $mid ) { |
|
584 | + public function delete_meta_data_by_mid($mid) { |
|
585 | 585 | $this->maybe_read_meta_data(); |
586 | - $array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), (int) $mid, true ); |
|
586 | + $array_keys = array_keys(wp_list_pluck($this->meta_data, 'id'), (int) $mid, true); |
|
587 | 587 | |
588 | - if ( $array_keys ) { |
|
589 | - foreach ( $array_keys as $array_key ) { |
|
590 | - $this->meta_data[ $array_key ]->value = null; |
|
588 | + if ($array_keys) { |
|
589 | + foreach ($array_keys as $array_key) { |
|
590 | + $this->meta_data[$array_key]->value = null; |
|
591 | 591 | } |
592 | 592 | } |
593 | 593 | } |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | * @since 1.0.19 |
599 | 599 | */ |
600 | 600 | protected function maybe_read_meta_data() { |
601 | - if ( is_null( $this->meta_data ) ) { |
|
601 | + if (is_null($this->meta_data)) { |
|
602 | 602 | $this->read_meta_data(); |
603 | 603 | } |
604 | 604 | } |
@@ -610,42 +610,42 @@ discard block |
||
610 | 610 | * @since 1.0.19 |
611 | 611 | * @param bool $force_read True to force a new DB read (and update cache). |
612 | 612 | */ |
613 | - public function read_meta_data( $force_read = false ) { |
|
613 | + public function read_meta_data($force_read = false) { |
|
614 | 614 | |
615 | 615 | // Reset meta data. |
616 | 616 | $this->meta_data = array(); |
617 | 617 | |
618 | 618 | // Maybe abort early. |
619 | - if ( ! $this->get_id() || ! $this->data_store ) { |
|
619 | + if (!$this->get_id() || !$this->data_store) { |
|
620 | 620 | return; |
621 | 621 | } |
622 | 622 | |
623 | 623 | // Only read from cache if the cache key is set. |
624 | 624 | $cache_key = null; |
625 | - if ( ! $force_read && ! empty( $this->cache_group ) ) { |
|
626 | - $cache_key = GetPaid_Cache_Helper::get_cache_prefix( $this->cache_group ) . GetPaid_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id(); |
|
627 | - $raw_meta_data = wp_cache_get( $cache_key, $this->cache_group ); |
|
625 | + if (!$force_read && !empty($this->cache_group)) { |
|
626 | + $cache_key = GetPaid_Cache_Helper::get_cache_prefix($this->cache_group) . GetPaid_Cache_Helper::get_cache_prefix('object_' . $this->get_id()) . 'object_meta_' . $this->get_id(); |
|
627 | + $raw_meta_data = wp_cache_get($cache_key, $this->cache_group); |
|
628 | 628 | } |
629 | 629 | |
630 | 630 | // Should we force read? |
631 | - if ( empty( $raw_meta_data ) ) { |
|
632 | - $raw_meta_data = $this->data_store->read_meta( $this ); |
|
631 | + if (empty($raw_meta_data)) { |
|
632 | + $raw_meta_data = $this->data_store->read_meta($this); |
|
633 | 633 | |
634 | - if ( ! empty( $cache_key ) ) { |
|
635 | - wp_cache_set( $cache_key, $raw_meta_data, $this->cache_group ); |
|
634 | + if (!empty($cache_key)) { |
|
635 | + wp_cache_set($cache_key, $raw_meta_data, $this->cache_group); |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | } |
639 | 639 | |
640 | 640 | // Set meta data. |
641 | - if ( is_array( $raw_meta_data ) ) { |
|
641 | + if (is_array($raw_meta_data)) { |
|
642 | 642 | |
643 | - foreach ( $raw_meta_data as $meta ) { |
|
643 | + foreach ($raw_meta_data as $meta) { |
|
644 | 644 | $this->meta_data[] = new GetPaid_Meta_Data( |
645 | 645 | array( |
646 | 646 | 'id' => (int) $meta->meta_id, |
647 | 647 | 'key' => $meta->meta_key, |
648 | - 'value' => maybe_unserialize( $meta->meta_value ), |
|
648 | + 'value' => maybe_unserialize($meta->meta_value), |
|
649 | 649 | ) |
650 | 650 | ); |
651 | 651 | } |
@@ -660,28 +660,28 @@ discard block |
||
660 | 660 | * @since 1.0.19 |
661 | 661 | */ |
662 | 662 | public function save_meta_data() { |
663 | - if ( ! $this->data_store || is_null( $this->meta_data ) ) { |
|
663 | + if (!$this->data_store || is_null($this->meta_data)) { |
|
664 | 664 | return; |
665 | 665 | } |
666 | - foreach ( $this->meta_data as $array_key => $meta ) { |
|
667 | - if ( is_null( $meta->value ) ) { |
|
668 | - if ( ! empty( $meta->id ) ) { |
|
669 | - $this->data_store->delete_meta( $this, $meta ); |
|
670 | - unset( $this->meta_data[ $array_key ] ); |
|
666 | + foreach ($this->meta_data as $array_key => $meta) { |
|
667 | + if (is_null($meta->value)) { |
|
668 | + if (!empty($meta->id)) { |
|
669 | + $this->data_store->delete_meta($this, $meta); |
|
670 | + unset($this->meta_data[$array_key]); |
|
671 | 671 | } |
672 | - } elseif ( empty( $meta->id ) ) { |
|
673 | - $meta->id = $this->data_store->add_meta( $this, $meta ); |
|
672 | + } elseif (empty($meta->id)) { |
|
673 | + $meta->id = $this->data_store->add_meta($this, $meta); |
|
674 | 674 | $meta->apply_changes(); |
675 | 675 | } else { |
676 | - if ( $meta->get_changes() ) { |
|
677 | - $this->data_store->update_meta( $this, $meta ); |
|
676 | + if ($meta->get_changes()) { |
|
677 | + $this->data_store->update_meta($this, $meta); |
|
678 | 678 | $meta->apply_changes(); |
679 | 679 | } |
680 | 680 | } |
681 | 681 | } |
682 | - if ( ! empty( $this->cache_group ) ) { |
|
683 | - $cache_key = GetPaid_Cache_Helper::get_cache_prefix( $this->cache_group ) . GetPaid_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id(); |
|
684 | - wp_cache_delete( $cache_key, $this->cache_group ); |
|
682 | + if (!empty($this->cache_group)) { |
|
683 | + $cache_key = GetPaid_Cache_Helper::get_cache_prefix($this->cache_group) . GetPaid_Cache_Helper::get_cache_prefix('object_' . $this->get_id()) . 'object_meta_' . $this->get_id(); |
|
684 | + wp_cache_delete($cache_key, $this->cache_group); |
|
685 | 685 | } |
686 | 686 | } |
687 | 687 | |
@@ -691,8 +691,8 @@ discard block |
||
691 | 691 | * @since 1.0.19 |
692 | 692 | * @param int $id ID. |
693 | 693 | */ |
694 | - public function set_id( $id ) { |
|
695 | - $this->id = absint( $id ); |
|
694 | + public function set_id($id) { |
|
695 | + $this->id = absint($id); |
|
696 | 696 | } |
697 | 697 | |
698 | 698 | /** |
@@ -702,10 +702,10 @@ discard block |
||
702 | 702 | * @param string $status New status. |
703 | 703 | * @return array details of change. |
704 | 704 | */ |
705 | - public function set_status( $status ) { |
|
705 | + public function set_status($status) { |
|
706 | 706 | $old_status = $this->get_status(); |
707 | 707 | |
708 | - $this->set_prop( 'status', $status ); |
|
708 | + $this->set_prop('status', $status); |
|
709 | 709 | |
710 | 710 | return array( |
711 | 711 | 'from' => $old_status, |
@@ -721,7 +721,7 @@ discard block |
||
721 | 721 | public function set_defaults() { |
722 | 722 | $this->data = $this->default_data; |
723 | 723 | $this->changes = array(); |
724 | - $this->set_object_read( false ); |
|
724 | + $this->set_object_read(false); |
|
725 | 725 | } |
726 | 726 | |
727 | 727 | /** |
@@ -730,7 +730,7 @@ discard block |
||
730 | 730 | * @since 1.0.19 |
731 | 731 | * @param boolean $read Should read?. |
732 | 732 | */ |
733 | - public function set_object_read( $read = true ) { |
|
733 | + public function set_object_read($read = true) { |
|
734 | 734 | $this->object_read = (bool) $read; |
735 | 735 | } |
736 | 736 | |
@@ -755,32 +755,32 @@ discard block |
||
755 | 755 | * |
756 | 756 | * @return bool|WP_Error |
757 | 757 | */ |
758 | - public function set_props( $props, $context = 'set' ) { |
|
758 | + public function set_props($props, $context = 'set') { |
|
759 | 759 | $errors = false; |
760 | 760 | |
761 | - foreach ( $props as $prop => $value ) { |
|
761 | + foreach ($props as $prop => $value) { |
|
762 | 762 | try { |
763 | 763 | /** |
764 | 764 | * Checks if the prop being set is allowed, and the value is not null. |
765 | 765 | */ |
766 | - if ( is_null( $value ) || in_array( $prop, array( 'prop', 'date_prop', 'meta_data' ), true ) ) { |
|
766 | + if (is_null($value) || in_array($prop, array('prop', 'date_prop', 'meta_data'), true)) { |
|
767 | 767 | continue; |
768 | 768 | } |
769 | 769 | $setter = "set_$prop"; |
770 | 770 | |
771 | - if ( is_callable( array( $this, $setter ) ) ) { |
|
772 | - $this->{$setter}( $value ); |
|
771 | + if (is_callable(array($this, $setter))) { |
|
772 | + $this->{$setter}($value); |
|
773 | 773 | } |
774 | - } catch ( Exception $e ) { |
|
775 | - if ( ! $errors ) { |
|
774 | + } catch (Exception $e) { |
|
775 | + if (!$errors) { |
|
776 | 776 | $errors = new WP_Error(); |
777 | 777 | } |
778 | - $errors->add( $e->getCode(), $e->getMessage() ); |
|
778 | + $errors->add($e->getCode(), $e->getMessage()); |
|
779 | 779 | $this->last_error = $e->getMessage(); |
780 | 780 | } |
781 | 781 | } |
782 | 782 | |
783 | - return $errors && count( $errors->get_error_codes() ) ? $errors : true; |
|
783 | + return $errors && count($errors->get_error_codes()) ? $errors : true; |
|
784 | 784 | } |
785 | 785 | |
786 | 786 | /** |
@@ -793,14 +793,14 @@ discard block |
||
793 | 793 | * @param string $prop Name of prop to set. |
794 | 794 | * @param mixed $value Value of the prop. |
795 | 795 | */ |
796 | - protected function set_prop( $prop, $value ) { |
|
797 | - if ( array_key_exists( $prop, $this->data ) ) { |
|
798 | - if ( true === $this->object_read ) { |
|
799 | - if ( $value !== $this->data[ $prop ] || array_key_exists( $prop, $this->changes ) ) { |
|
800 | - $this->changes[ $prop ] = $value; |
|
796 | + protected function set_prop($prop, $value) { |
|
797 | + if (array_key_exists($prop, $this->data)) { |
|
798 | + if (true === $this->object_read) { |
|
799 | + if ($value !== $this->data[$prop] || array_key_exists($prop, $this->changes)) { |
|
800 | + $this->changes[$prop] = $value; |
|
801 | 801 | } |
802 | 802 | } else { |
803 | - $this->data[ $prop ] = $value; |
|
803 | + $this->data[$prop] = $value; |
|
804 | 804 | } |
805 | 805 | } |
806 | 806 | } |
@@ -821,7 +821,7 @@ discard block |
||
821 | 821 | * @since 1.0.19 |
822 | 822 | */ |
823 | 823 | public function apply_changes() { |
824 | - $this->data = array_replace_recursive( $this->data, $this->changes ); |
|
824 | + $this->data = array_replace_recursive($this->data, $this->changes); |
|
825 | 825 | $this->changes = array(); |
826 | 826 | } |
827 | 827 | |
@@ -846,14 +846,14 @@ discard block |
||
846 | 846 | * @param string $context What the value is for. Valid values are view and edit. |
847 | 847 | * @return mixed |
848 | 848 | */ |
849 | - protected function get_prop( $prop, $context = 'view' ) { |
|
849 | + protected function get_prop($prop, $context = 'view') { |
|
850 | 850 | $value = null; |
851 | 851 | |
852 | - if ( array_key_exists( $prop, $this->data ) ) { |
|
853 | - $value = array_key_exists( $prop, $this->changes ) ? $this->changes[ $prop ] : $this->data[ $prop ]; |
|
852 | + if (array_key_exists($prop, $this->data)) { |
|
853 | + $value = array_key_exists($prop, $this->changes) ? $this->changes[$prop] : $this->data[$prop]; |
|
854 | 854 | |
855 | - if ( 'view' === $context ) { |
|
856 | - $value = apply_filters( $this->get_hook_prefix() . $prop, $value, $this ); |
|
855 | + if ('view' === $context) { |
|
856 | + $value = apply_filters($this->get_hook_prefix() . $prop, $value, $this); |
|
857 | 857 | } |
858 | 858 | } |
859 | 859 | |
@@ -867,13 +867,13 @@ discard block |
||
867 | 867 | * @param string $prop Name of prop to set. |
868 | 868 | * @param string|integer $value Value of the prop. |
869 | 869 | */ |
870 | - protected function set_date_prop( $prop, $value ) { |
|
870 | + protected function set_date_prop($prop, $value) { |
|
871 | 871 | |
872 | - if ( empty( $value ) ) { |
|
873 | - $this->set_prop( $prop, null ); |
|
872 | + if (empty($value)) { |
|
873 | + $this->set_prop($prop, null); |
|
874 | 874 | return; |
875 | 875 | } |
876 | - $this->set_prop( $prop, $value ); |
|
876 | + $this->set_prop($prop, $value); |
|
877 | 877 | |
878 | 878 | } |
879 | 879 | |
@@ -884,7 +884,7 @@ discard block |
||
884 | 884 | * @param string $code Error code. |
885 | 885 | * @param string $message Error message. |
886 | 886 | */ |
887 | - protected function error( $code, $message ) { |
|
887 | + protected function error($code, $message) { |
|
888 | 888 | $this->last_error = $message; |
889 | 889 | } |
890 | 890 | |
@@ -896,7 +896,7 @@ discard block |
||
896 | 896 | */ |
897 | 897 | public function exists() { |
898 | 898 | $id = $this->get_id(); |
899 | - return ! empty( $id ); |
|
899 | + return !empty($id); |
|
900 | 900 | } |
901 | 901 | |
902 | 902 | } |
@@ -4,99 +4,99 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Displays an invoice. |
11 | 11 | * |
12 | 12 | * @param WPInv_Invoice $invoice. |
13 | 13 | */ |
14 | -function getpaid_invoice( $invoice ) { |
|
15 | - if ( ! empty( $invoice ) ) { |
|
16 | - wpinv_get_template( 'invoice/invoice.php', compact( 'invoice' ) ); |
|
14 | +function getpaid_invoice($invoice) { |
|
15 | + if (!empty($invoice)) { |
|
16 | + wpinv_get_template('invoice/invoice.php', compact('invoice')); |
|
17 | 17 | } |
18 | 18 | } |
19 | -add_action( 'getpaid_invoice', 'getpaid_invoice', 10 ); |
|
19 | +add_action('getpaid_invoice', 'getpaid_invoice', 10); |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Displays the invoice footer. |
23 | 23 | */ |
24 | -function getpaid_invoice_footer( $invoice ) { |
|
25 | - if ( ! empty( $invoice ) ) { |
|
26 | - wpinv_get_template( 'invoice/footer.php', compact( 'invoice' ) ); |
|
24 | +function getpaid_invoice_footer($invoice) { |
|
25 | + if (!empty($invoice)) { |
|
26 | + wpinv_get_template('invoice/footer.php', compact('invoice')); |
|
27 | 27 | } |
28 | 28 | } |
29 | -add_action( 'getpaid_invoice_footer', 'getpaid_invoice_footer', 10 ); |
|
29 | +add_action('getpaid_invoice_footer', 'getpaid_invoice_footer', 10); |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Displays the invoice top bar. |
33 | 33 | */ |
34 | -function getpaid_invoice_header( $invoice ) { |
|
35 | - if ( ! empty( $invoice ) ) { |
|
36 | - wpinv_get_template( 'invoice/header.php', compact( 'invoice' ) ); |
|
34 | +function getpaid_invoice_header($invoice) { |
|
35 | + if (!empty($invoice)) { |
|
36 | + wpinv_get_template('invoice/header.php', compact('invoice')); |
|
37 | 37 | } |
38 | 38 | } |
39 | -add_action( 'getpaid_invoice_header', 'getpaid_invoice_header', 10 ); |
|
39 | +add_action('getpaid_invoice_header', 'getpaid_invoice_header', 10); |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * Displays actions on the left side of the header. |
43 | 43 | */ |
44 | -function getpaid_invoice_header_left_actions( $invoice ) { |
|
45 | - if ( ! empty( $invoice ) ) { |
|
46 | - wpinv_get_template( 'invoice/header-left-actions.php', compact( 'invoice' ) ); |
|
44 | +function getpaid_invoice_header_left_actions($invoice) { |
|
45 | + if (!empty($invoice)) { |
|
46 | + wpinv_get_template('invoice/header-left-actions.php', compact('invoice')); |
|
47 | 47 | } |
48 | 48 | } |
49 | -add_action( 'getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10 ); |
|
49 | +add_action('getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10); |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * Displays actions on the right side of the invoice top bar. |
53 | 53 | */ |
54 | -function getpaid_invoice_header_right_actions( $invoice ) { |
|
55 | - if ( ! empty( $invoice ) ) { |
|
56 | - wpinv_get_template( 'invoice/header-right-actions.php', compact( 'invoice' ) ); |
|
54 | +function getpaid_invoice_header_right_actions($invoice) { |
|
55 | + if (!empty($invoice)) { |
|
56 | + wpinv_get_template('invoice/header-right-actions.php', compact('invoice')); |
|
57 | 57 | } |
58 | 58 | } |
59 | -add_action( 'getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10 ); |
|
59 | +add_action('getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10); |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * Displays the invoice title, watermark, logo etc. |
63 | 63 | */ |
64 | -function getpaid_invoice_details_top( $invoice ) { |
|
65 | - if ( ! empty( $invoice ) ) { |
|
66 | - wpinv_get_template( 'invoice/details-top.php', compact( 'invoice' ) ); |
|
64 | +function getpaid_invoice_details_top($invoice) { |
|
65 | + if (!empty($invoice)) { |
|
66 | + wpinv_get_template('invoice/details-top.php', compact('invoice')); |
|
67 | 67 | } |
68 | 68 | } |
69 | -add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_top', 10 ); |
|
69 | +add_action('getpaid_invoice_details', 'getpaid_invoice_details_top', 10); |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * Displays the company logo. |
73 | 73 | */ |
74 | -function getpaid_invoice_logo( $invoice ) { |
|
75 | - if ( ! empty( $invoice ) ) { |
|
76 | - wpinv_get_template( 'invoice/invoice-logo.php', compact( 'invoice' ) ); |
|
74 | +function getpaid_invoice_logo($invoice) { |
|
75 | + if (!empty($invoice)) { |
|
76 | + wpinv_get_template('invoice/invoice-logo.php', compact('invoice')); |
|
77 | 77 | } |
78 | 78 | } |
79 | -add_action( 'getpaid_invoice_details_top_left', 'getpaid_invoice_logo' ); |
|
79 | +add_action('getpaid_invoice_details_top_left', 'getpaid_invoice_logo'); |
|
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Displays the type of invoice. |
83 | 83 | */ |
84 | -function getpaid_invoice_type( $invoice ) { |
|
85 | - if ( ! empty( $invoice ) ) { |
|
86 | - wpinv_get_template( 'invoice/invoice-type.php', compact( 'invoice' ) ); |
|
84 | +function getpaid_invoice_type($invoice) { |
|
85 | + if (!empty($invoice)) { |
|
86 | + wpinv_get_template('invoice/invoice-type.php', compact('invoice')); |
|
87 | 87 | } |
88 | 88 | } |
89 | -add_action( 'getpaid_invoice_details_top_right', 'getpaid_invoice_type' ); |
|
89 | +add_action('getpaid_invoice_details_top_right', 'getpaid_invoice_type'); |
|
90 | 90 | |
91 | 91 | /** |
92 | 92 | * Displays the invoice details. |
93 | 93 | */ |
94 | -function getpaid_invoice_details_main( $invoice ) { |
|
95 | - if ( ! empty( $invoice ) ) { |
|
96 | - wpinv_get_template( 'invoice/details.php', compact( 'invoice' ) ); |
|
94 | +function getpaid_invoice_details_main($invoice) { |
|
95 | + if (!empty($invoice)) { |
|
96 | + wpinv_get_template('invoice/details.php', compact('invoice')); |
|
97 | 97 | } |
98 | 98 | } |
99 | -add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_main', 50 ); |
|
99 | +add_action('getpaid_invoice_details', 'getpaid_invoice_details_main', 50); |
|
100 | 100 | |
101 | 101 | /** |
102 | 102 | * Returns a path to the templates directory. |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
126 | 126 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
127 | 127 | */ |
128 | -function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
129 | - return getpaid_template()->display_template( $template_name, $args, $template_path, $default_path ); |
|
128 | +function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
129 | + return getpaid_template()->display_template($template_name, $args, $template_path, $default_path); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
140 | 140 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
141 | 141 | */ |
142 | -function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
143 | - return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path ); |
|
142 | +function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
143 | + return getpaid_template()->get_template($template_name, $args, $template_path, $default_path); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @return string |
150 | 150 | */ |
151 | 151 | function wpinv_template_path() { |
152 | - return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() ); |
|
152 | + return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name()); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @return string |
159 | 159 | */ |
160 | 160 | function wpinv_get_theme_template_dir_name() { |
161 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
161 | + return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing')); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -170,56 +170,56 @@ discard block |
||
170 | 170 | * @param string $template_path The template path relative to the theme's root dir. Defaults to 'invoicing'. |
171 | 171 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
172 | 172 | */ |
173 | -function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
174 | - return getpaid_template()->locate_template( $template_name, $template_path, $default_path ); |
|
173 | +function wpinv_locate_template($template_name, $template_path = '', $default_path = '') { |
|
174 | + return getpaid_template()->locate_template($template_name, $template_path, $default_path); |
|
175 | 175 | } |
176 | 176 | |
177 | -function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
|
178 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
177 | +function wpinv_get_template_part($slug, $name = null, $load = true) { |
|
178 | + do_action('get_template_part_' . $slug, $slug, $name); |
|
179 | 179 | |
180 | 180 | // Setup possible parts |
181 | 181 | $templates = array(); |
182 | - if ( isset( $name ) ) |
|
182 | + if (isset($name)) |
|
183 | 183 | $templates[] = $slug . '-' . $name . '.php'; |
184 | 184 | $templates[] = $slug . '.php'; |
185 | 185 | |
186 | 186 | // Allow template parts to be filtered |
187 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
187 | + $templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name); |
|
188 | 188 | |
189 | 189 | // Return the part that is found |
190 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
190 | + return wpinv_locate_tmpl($templates, $load, false); |
|
191 | 191 | } |
192 | 192 | |
193 | -function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
|
193 | +function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) { |
|
194 | 194 | // No file found yet |
195 | 195 | $located = false; |
196 | 196 | |
197 | 197 | // Try to find a template file |
198 | - foreach ( (array)$template_names as $template_name ) { |
|
198 | + foreach ((array) $template_names as $template_name) { |
|
199 | 199 | |
200 | 200 | // Continue if template is empty |
201 | - if ( empty( $template_name ) ) |
|
201 | + if (empty($template_name)) |
|
202 | 202 | continue; |
203 | 203 | |
204 | 204 | // Trim off any slashes from the template name |
205 | - $template_name = ltrim( $template_name, '/' ); |
|
205 | + $template_name = ltrim($template_name, '/'); |
|
206 | 206 | |
207 | 207 | // try locating this template file by looping through the template paths |
208 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
208 | + foreach (wpinv_get_theme_template_paths() as $template_path) { |
|
209 | 209 | |
210 | - if( file_exists( $template_path . $template_name ) ) { |
|
210 | + if (file_exists($template_path . $template_name)) { |
|
211 | 211 | $located = $template_path . $template_name; |
212 | 212 | break; |
213 | 213 | } |
214 | 214 | } |
215 | 215 | |
216 | - if( !empty( $located ) ) { |
|
216 | + if (!empty($located)) { |
|
217 | 217 | break; |
218 | 218 | } |
219 | 219 | } |
220 | 220 | |
221 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
222 | - load_template( $located, $require_once ); |
|
221 | + if ((true == $load) && !empty($located)) |
|
222 | + load_template($located, $require_once); |
|
223 | 223 | |
224 | 224 | return $located; |
225 | 225 | } |
@@ -228,155 +228,155 @@ discard block |
||
228 | 228 | $template_dir = wpinv_get_theme_template_dir_name(); |
229 | 229 | |
230 | 230 | $file_paths = array( |
231 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
232 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
231 | + 1 => trailingslashit(get_stylesheet_directory()) . $template_dir, |
|
232 | + 10 => trailingslashit(get_template_directory()) . $template_dir, |
|
233 | 233 | 100 => wpinv_get_templates_dir() |
234 | 234 | ); |
235 | 235 | |
236 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
236 | + $file_paths = apply_filters('wpinv_template_paths', $file_paths); |
|
237 | 237 | |
238 | 238 | // sort the file paths based on priority |
239 | - ksort( $file_paths, SORT_NUMERIC ); |
|
239 | + ksort($file_paths, SORT_NUMERIC); |
|
240 | 240 | |
241 | - return array_map( 'trailingslashit', $file_paths ); |
|
241 | + return array_map('trailingslashit', $file_paths); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | function wpinv_checkout_meta_tags() { |
245 | 245 | |
246 | 246 | $pages = array(); |
247 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
248 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
249 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
250 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
247 | + $pages[] = wpinv_get_option('success_page'); |
|
248 | + $pages[] = wpinv_get_option('failure_page'); |
|
249 | + $pages[] = wpinv_get_option('invoice_history_page'); |
|
250 | + $pages[] = wpinv_get_option('invoice_subscription_page'); |
|
251 | 251 | |
252 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
252 | + if (!wpinv_is_checkout() && !is_page($pages)) { |
|
253 | 253 | return; |
254 | 254 | } |
255 | 255 | |
256 | 256 | echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
257 | 257 | } |
258 | -add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
|
258 | +add_action('wp_head', 'wpinv_checkout_meta_tags'); |
|
259 | 259 | |
260 | -function wpinv_add_body_classes( $class ) { |
|
261 | - $classes = (array)$class; |
|
260 | +function wpinv_add_body_classes($class) { |
|
261 | + $classes = (array) $class; |
|
262 | 262 | |
263 | - if( wpinv_is_checkout() ) { |
|
263 | + if (wpinv_is_checkout()) { |
|
264 | 264 | $classes[] = 'wpinv-checkout'; |
265 | 265 | $classes[] = 'wpinv-page'; |
266 | 266 | } |
267 | 267 | |
268 | - if( wpinv_is_success_page() ) { |
|
268 | + if (wpinv_is_success_page()) { |
|
269 | 269 | $classes[] = 'wpinv-success'; |
270 | 270 | $classes[] = 'wpinv-page'; |
271 | 271 | } |
272 | 272 | |
273 | - if( wpinv_is_failed_transaction_page() ) { |
|
273 | + if (wpinv_is_failed_transaction_page()) { |
|
274 | 274 | $classes[] = 'wpinv-failed-transaction'; |
275 | 275 | $classes[] = 'wpinv-page'; |
276 | 276 | } |
277 | 277 | |
278 | - if( wpinv_is_invoice_history_page() ) { |
|
278 | + if (wpinv_is_invoice_history_page()) { |
|
279 | 279 | $classes[] = 'wpinv-history'; |
280 | 280 | $classes[] = 'wpinv-page'; |
281 | 281 | } |
282 | 282 | |
283 | - if( wpinv_is_subscriptions_history_page() ) { |
|
283 | + if (wpinv_is_subscriptions_history_page()) { |
|
284 | 284 | $classes[] = 'wpinv-subscription'; |
285 | 285 | $classes[] = 'wpinv-page'; |
286 | 286 | } |
287 | 287 | |
288 | - if( wpinv_is_test_mode() ) { |
|
288 | + if (wpinv_is_test_mode()) { |
|
289 | 289 | $classes[] = 'wpinv-test-mode'; |
290 | 290 | $classes[] = 'wpinv-page'; |
291 | 291 | } |
292 | 292 | |
293 | - return array_unique( $classes ); |
|
293 | + return array_unique($classes); |
|
294 | 294 | } |
295 | -add_filter( 'body_class', 'wpinv_add_body_classes' ); |
|
295 | +add_filter('body_class', 'wpinv_add_body_classes'); |
|
296 | 296 | |
297 | -function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) { |
|
298 | - $args = array( 'nopaging' => true ); |
|
297 | +function wpinv_html_dropdown($name = 'wpinv_discounts', $selected = 0, $status = '') { |
|
298 | + $args = array('nopaging' => true); |
|
299 | 299 | |
300 | - if ( ! empty( $status ) ) |
|
300 | + if (!empty($status)) |
|
301 | 301 | $args['post_status'] = $status; |
302 | 302 | |
303 | - $discounts = wpinv_get_discounts( $args ); |
|
303 | + $discounts = wpinv_get_discounts($args); |
|
304 | 304 | $options = array(); |
305 | 305 | |
306 | - if ( $discounts ) { |
|
307 | - foreach ( $discounts as $discount ) { |
|
308 | - $options[ absint( $discount->ID ) ] = esc_html( get_the_title( $discount->ID ) ); |
|
306 | + if ($discounts) { |
|
307 | + foreach ($discounts as $discount) { |
|
308 | + $options[absint($discount->ID)] = esc_html(get_the_title($discount->ID)); |
|
309 | 309 | } |
310 | 310 | } else { |
311 | - $options[0] = __( 'No discounts found', 'invoicing' ); |
|
311 | + $options[0] = __('No discounts found', 'invoicing'); |
|
312 | 312 | } |
313 | 313 | |
314 | - $output = wpinv_html_select( array( |
|
314 | + $output = wpinv_html_select(array( |
|
315 | 315 | 'name' => $name, |
316 | 316 | 'selected' => $selected, |
317 | 317 | 'options' => $options, |
318 | 318 | 'show_option_all' => false, |
319 | 319 | 'show_option_none' => false, |
320 | - ) ); |
|
320 | + )); |
|
321 | 321 | |
322 | 322 | return $output; |
323 | 323 | } |
324 | 324 | |
325 | -function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
326 | - $current = date( 'Y' ); |
|
327 | - $start_year = $current - absint( $years_before ); |
|
328 | - $end_year = $current + absint( $years_after ); |
|
329 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
325 | +function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
326 | + $current = date('Y'); |
|
327 | + $start_year = $current - absint($years_before); |
|
328 | + $end_year = $current + absint($years_after); |
|
329 | + $selected = empty($selected) ? date('Y') : $selected; |
|
330 | 330 | $options = array(); |
331 | 331 | |
332 | - while ( $start_year <= $end_year ) { |
|
333 | - $options[ absint( $start_year ) ] = $start_year; |
|
332 | + while ($start_year <= $end_year) { |
|
333 | + $options[absint($start_year)] = $start_year; |
|
334 | 334 | $start_year++; |
335 | 335 | } |
336 | 336 | |
337 | - $output = wpinv_html_select( array( |
|
337 | + $output = wpinv_html_select(array( |
|
338 | 338 | 'name' => $name, |
339 | 339 | 'selected' => $selected, |
340 | 340 | 'options' => $options, |
341 | 341 | 'show_option_all' => false, |
342 | 342 | 'show_option_none' => false |
343 | - ) ); |
|
343 | + )); |
|
344 | 344 | |
345 | 345 | return $output; |
346 | 346 | } |
347 | 347 | |
348 | -function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) { |
|
348 | +function wpinv_html_month_dropdown($name = 'month', $selected = 0) { |
|
349 | 349 | |
350 | 350 | $options = array( |
351 | - '1' => __( 'January', 'invoicing' ), |
|
352 | - '2' => __( 'February', 'invoicing' ), |
|
353 | - '3' => __( 'March', 'invoicing' ), |
|
354 | - '4' => __( 'April', 'invoicing' ), |
|
355 | - '5' => __( 'May', 'invoicing' ), |
|
356 | - '6' => __( 'June', 'invoicing' ), |
|
357 | - '7' => __( 'July', 'invoicing' ), |
|
358 | - '8' => __( 'August', 'invoicing' ), |
|
359 | - '9' => __( 'September', 'invoicing' ), |
|
360 | - '10' => __( 'October', 'invoicing' ), |
|
361 | - '11' => __( 'November', 'invoicing' ), |
|
362 | - '12' => __( 'December', 'invoicing' ), |
|
351 | + '1' => __('January', 'invoicing'), |
|
352 | + '2' => __('February', 'invoicing'), |
|
353 | + '3' => __('March', 'invoicing'), |
|
354 | + '4' => __('April', 'invoicing'), |
|
355 | + '5' => __('May', 'invoicing'), |
|
356 | + '6' => __('June', 'invoicing'), |
|
357 | + '7' => __('July', 'invoicing'), |
|
358 | + '8' => __('August', 'invoicing'), |
|
359 | + '9' => __('September', 'invoicing'), |
|
360 | + '10' => __('October', 'invoicing'), |
|
361 | + '11' => __('November', 'invoicing'), |
|
362 | + '12' => __('December', 'invoicing'), |
|
363 | 363 | ); |
364 | 364 | |
365 | 365 | // If no month is selected, default to the current month |
366 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
366 | + $selected = empty($selected) ? date('n') : $selected; |
|
367 | 367 | |
368 | - $output = wpinv_html_select( array( |
|
368 | + $output = wpinv_html_select(array( |
|
369 | 369 | 'name' => $name, |
370 | 370 | 'selected' => $selected, |
371 | 371 | 'options' => $options, |
372 | 372 | 'show_option_all' => false, |
373 | 373 | 'show_option_none' => false |
374 | - ) ); |
|
374 | + )); |
|
375 | 375 | |
376 | 376 | return $output; |
377 | 377 | } |
378 | 378 | |
379 | -function wpinv_html_select( $args = array() ) { |
|
379 | +function wpinv_html_select($args = array()) { |
|
380 | 380 | $defaults = array( |
381 | 381 | 'options' => array(), |
382 | 382 | 'name' => null, |
@@ -385,8 +385,8 @@ discard block |
||
385 | 385 | 'selected' => 0, |
386 | 386 | 'placeholder' => null, |
387 | 387 | 'multiple' => false, |
388 | - 'show_option_all' => _x( 'All', 'all dropdown items', 'invoicing' ), |
|
389 | - 'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ), |
|
388 | + 'show_option_all' => _x('All', 'all dropdown items', 'invoicing'), |
|
389 | + 'show_option_none' => _x('None', 'no dropdown items', 'invoicing'), |
|
390 | 390 | 'data' => array(), |
391 | 391 | 'onchange' => null, |
392 | 392 | 'required' => false, |
@@ -394,74 +394,74 @@ discard block |
||
394 | 394 | 'readonly' => false, |
395 | 395 | ); |
396 | 396 | |
397 | - $args = wp_parse_args( $args, $defaults ); |
|
397 | + $args = wp_parse_args($args, $defaults); |
|
398 | 398 | |
399 | 399 | $data_elements = ''; |
400 | - foreach ( $args['data'] as $key => $value ) { |
|
401 | - $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
400 | + foreach ($args['data'] as $key => $value) { |
|
401 | + $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"'; |
|
402 | 402 | } |
403 | 403 | |
404 | - if( $args['multiple'] ) { |
|
404 | + if ($args['multiple']) { |
|
405 | 405 | $multiple = ' MULTIPLE'; |
406 | 406 | } else { |
407 | 407 | $multiple = ''; |
408 | 408 | } |
409 | 409 | |
410 | - if( $args['placeholder'] ) { |
|
410 | + if ($args['placeholder']) { |
|
411 | 411 | $placeholder = $args['placeholder']; |
412 | 412 | } else { |
413 | 413 | $placeholder = ''; |
414 | 414 | } |
415 | 415 | |
416 | 416 | $options = ''; |
417 | - if( !empty( $args['onchange'] ) ) { |
|
418 | - $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
417 | + if (!empty($args['onchange'])) { |
|
418 | + $options .= ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
419 | 419 | } |
420 | 420 | |
421 | - if( !empty( $args['required'] ) ) { |
|
421 | + if (!empty($args['required'])) { |
|
422 | 422 | $options .= ' required="required"'; |
423 | 423 | } |
424 | 424 | |
425 | - if( !empty( $args['disabled'] ) ) { |
|
425 | + if (!empty($args['disabled'])) { |
|
426 | 426 | $options .= ' disabled'; |
427 | 427 | } |
428 | 428 | |
429 | - if( !empty( $args['readonly'] ) ) { |
|
429 | + if (!empty($args['readonly'])) { |
|
430 | 430 | $options .= ' readonly'; |
431 | 431 | } |
432 | 432 | |
433 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
434 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>'; |
|
433 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
434 | + $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>'; |
|
435 | 435 | |
436 | - if ( $args['show_option_all'] ) { |
|
437 | - if( $args['multiple'] ) { |
|
438 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
436 | + if ($args['show_option_all']) { |
|
437 | + if ($args['multiple']) { |
|
438 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
439 | 439 | } else { |
440 | - $selected = selected( $args['selected'], 0, false ); |
|
440 | + $selected = selected($args['selected'], 0, false); |
|
441 | 441 | } |
442 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
442 | + $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>'; |
|
443 | 443 | } |
444 | 444 | |
445 | - if ( !empty( $args['options'] ) ) { |
|
445 | + if (!empty($args['options'])) { |
|
446 | 446 | |
447 | - if ( $args['show_option_none'] ) { |
|
448 | - if( $args['multiple'] ) { |
|
449 | - $selected = selected( true, in_array( "", $args['selected'] ), false ); |
|
447 | + if ($args['show_option_none']) { |
|
448 | + if ($args['multiple']) { |
|
449 | + $selected = selected(true, in_array("", $args['selected']), false); |
|
450 | 450 | } else { |
451 | - $selected = selected( $args['selected'] === "", true, false ); |
|
451 | + $selected = selected($args['selected'] === "", true, false); |
|
452 | 452 | } |
453 | - $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
453 | + $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>'; |
|
454 | 454 | } |
455 | 455 | |
456 | - foreach( $args['options'] as $key => $option ) { |
|
456 | + foreach ($args['options'] as $key => $option) { |
|
457 | 457 | |
458 | - if( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
459 | - $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false ); |
|
458 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
459 | + $selected = selected(true, (bool) in_array($key, $args['selected']), false); |
|
460 | 460 | } else { |
461 | - $selected = selected( $args['selected'], $key, false ); |
|
461 | + $selected = selected($args['selected'], $key, false); |
|
462 | 462 | } |
463 | 463 | |
464 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
464 | + $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>'; |
|
465 | 465 | } |
466 | 466 | } |
467 | 467 | |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | return $output; |
471 | 471 | } |
472 | 472 | |
473 | -function wpinv_item_dropdown( $args = array() ) { |
|
473 | +function wpinv_item_dropdown($args = array()) { |
|
474 | 474 | $defaults = array( |
475 | 475 | 'name' => 'wpi_item', |
476 | 476 | 'id' => 'wpi_item', |
@@ -478,14 +478,14 @@ discard block |
||
478 | 478 | 'multiple' => false, |
479 | 479 | 'selected' => 0, |
480 | 480 | 'number' => 100, |
481 | - 'placeholder' => __( 'Choose a item', 'invoicing' ), |
|
482 | - 'data' => array( 'search-type' => 'item' ), |
|
481 | + 'placeholder' => __('Choose a item', 'invoicing'), |
|
482 | + 'data' => array('search-type' => 'item'), |
|
483 | 483 | 'show_option_all' => false, |
484 | 484 | 'show_option_none' => false, |
485 | 485 | 'show_recurring' => false, |
486 | 486 | ); |
487 | 487 | |
488 | - $args = wp_parse_args( $args, $defaults ); |
|
488 | + $args = wp_parse_args($args, $defaults); |
|
489 | 489 | |
490 | 490 | $item_args = array( |
491 | 491 | 'post_type' => 'wpi_item', |
@@ -494,44 +494,44 @@ discard block |
||
494 | 494 | 'posts_per_page' => $args['number'] |
495 | 495 | ); |
496 | 496 | |
497 | - $item_args = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults ); |
|
497 | + $item_args = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults); |
|
498 | 498 | |
499 | - $items = get_posts( $item_args ); |
|
499 | + $items = get_posts($item_args); |
|
500 | 500 | $options = array(); |
501 | - if ( $items ) { |
|
502 | - foreach ( $items as $item ) { |
|
503 | - $title = esc_html( $item->post_title ); |
|
501 | + if ($items) { |
|
502 | + foreach ($items as $item) { |
|
503 | + $title = esc_html($item->post_title); |
|
504 | 504 | |
505 | - if ( !empty( $args['show_recurring'] ) ) { |
|
506 | - $title .= wpinv_get_item_suffix( $item->ID, false ); |
|
505 | + if (!empty($args['show_recurring'])) { |
|
506 | + $title .= wpinv_get_item_suffix($item->ID, false); |
|
507 | 507 | } |
508 | 508 | |
509 | - $options[ absint( $item->ID ) ] = $title; |
|
509 | + $options[absint($item->ID)] = $title; |
|
510 | 510 | } |
511 | 511 | } |
512 | 512 | |
513 | 513 | // This ensures that any selected items are included in the drop down |
514 | - if( is_array( $args['selected'] ) ) { |
|
515 | - foreach( $args['selected'] as $item ) { |
|
516 | - if( ! in_array( $item, $options ) ) { |
|
517 | - $title = get_the_title( $item ); |
|
518 | - if ( !empty( $args['show_recurring'] ) ) { |
|
519 | - $title .= wpinv_get_item_suffix( $item, false ); |
|
514 | + if (is_array($args['selected'])) { |
|
515 | + foreach ($args['selected'] as $item) { |
|
516 | + if (!in_array($item, $options)) { |
|
517 | + $title = get_the_title($item); |
|
518 | + if (!empty($args['show_recurring'])) { |
|
519 | + $title .= wpinv_get_item_suffix($item, false); |
|
520 | 520 | } |
521 | 521 | $options[$item] = $title; |
522 | 522 | } |
523 | 523 | } |
524 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
525 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
526 | - $title = get_the_title( $args['selected'] ); |
|
527 | - if ( !empty( $args['show_recurring'] ) ) { |
|
528 | - $title .= wpinv_get_item_suffix( $args['selected'], false ); |
|
524 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
525 | + if (!in_array($args['selected'], $options)) { |
|
526 | + $title = get_the_title($args['selected']); |
|
527 | + if (!empty($args['show_recurring'])) { |
|
528 | + $title .= wpinv_get_item_suffix($args['selected'], false); |
|
529 | 529 | } |
530 | - $options[$args['selected']] = get_the_title( $args['selected'] ); |
|
530 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
531 | 531 | } |
532 | 532 | } |
533 | 533 | |
534 | - $output = wpinv_html_select( array( |
|
534 | + $output = wpinv_html_select(array( |
|
535 | 535 | 'name' => $args['name'], |
536 | 536 | 'selected' => $args['selected'], |
537 | 537 | 'id' => $args['id'], |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | 'show_option_all' => $args['show_option_all'], |
543 | 543 | 'show_option_none' => $args['show_option_none'], |
544 | 544 | 'data' => $args['data'], |
545 | - ) ); |
|
545 | + )); |
|
546 | 546 | |
547 | 547 | return $output; |
548 | 548 | } |
@@ -562,16 +562,16 @@ discard block |
||
562 | 562 | ); |
563 | 563 | |
564 | 564 | $options = array(); |
565 | - if ( $items ) { |
|
566 | - foreach ( $items as $item ) { |
|
567 | - $options[ $item->ID ] = esc_html( $item->post_title ) . wpinv_get_item_suffix( $item->ID, false ); |
|
565 | + if ($items) { |
|
566 | + foreach ($items as $item) { |
|
567 | + $options[$item->ID] = esc_html($item->post_title) . wpinv_get_item_suffix($item->ID, false); |
|
568 | 568 | } |
569 | 569 | } |
570 | 570 | |
571 | 571 | return $options; |
572 | 572 | } |
573 | 573 | |
574 | -function wpinv_html_checkbox( $args = array() ) { |
|
574 | +function wpinv_html_checkbox($args = array()) { |
|
575 | 575 | $defaults = array( |
576 | 576 | 'name' => null, |
577 | 577 | 'current' => null, |
@@ -582,17 +582,17 @@ discard block |
||
582 | 582 | ) |
583 | 583 | ); |
584 | 584 | |
585 | - $args = wp_parse_args( $args, $defaults ); |
|
585 | + $args = wp_parse_args($args, $defaults); |
|
586 | 586 | |
587 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
587 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
588 | 588 | $options = ''; |
589 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
589 | + if (!empty($args['options']['disabled'])) { |
|
590 | 590 | $options .= ' disabled="disabled"'; |
591 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
591 | + } elseif (!empty($args['options']['readonly'])) { |
|
592 | 592 | $options .= ' readonly'; |
593 | 593 | } |
594 | 594 | |
595 | - $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $class . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
595 | + $output = '<input type="checkbox"' . $options . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . $class . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />'; |
|
596 | 596 | |
597 | 597 | return $output; |
598 | 598 | } |
@@ -600,30 +600,30 @@ discard block |
||
600 | 600 | /** |
601 | 601 | * Displays a hidden field. |
602 | 602 | */ |
603 | -function getpaid_hidden_field( $name, $value ) { |
|
604 | - $name = sanitize_text_field( $name ); |
|
605 | - $value = esc_attr( $value ); |
|
603 | +function getpaid_hidden_field($name, $value) { |
|
604 | + $name = sanitize_text_field($name); |
|
605 | + $value = esc_attr($value); |
|
606 | 606 | |
607 | 607 | echo "<input type='hidden' name='$name' value='$value' />"; |
608 | 608 | } |
609 | 609 | |
610 | -function wpinv_html_text( $args = array() ) { |
|
610 | +function wpinv_html_text($args = array()) { |
|
611 | 611 | // Backwards compatibility |
612 | - if ( func_num_args() > 1 ) { |
|
612 | + if (func_num_args() > 1) { |
|
613 | 613 | $args = func_get_args(); |
614 | 614 | |
615 | 615 | $name = $args[0]; |
616 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
617 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
618 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
616 | + $value = isset($args[1]) ? $args[1] : ''; |
|
617 | + $label = isset($args[2]) ? $args[2] : ''; |
|
618 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | $defaults = array( |
622 | 622 | 'id' => '', |
623 | - 'name' => isset( $name ) ? $name : 'text', |
|
624 | - 'value' => isset( $value ) ? $value : null, |
|
625 | - 'label' => isset( $label ) ? $label : null, |
|
626 | - 'desc' => isset( $desc ) ? $desc : null, |
|
623 | + 'name' => isset($name) ? $name : 'text', |
|
624 | + 'value' => isset($value) ? $value : null, |
|
625 | + 'label' => isset($label) ? $label : null, |
|
626 | + 'desc' => isset($desc) ? $desc : null, |
|
627 | 627 | 'placeholder' => '', |
628 | 628 | 'class' => 'regular-text', |
629 | 629 | 'disabled' => false, |
@@ -633,51 +633,51 @@ discard block |
||
633 | 633 | 'data' => false |
634 | 634 | ); |
635 | 635 | |
636 | - $args = wp_parse_args( $args, $defaults ); |
|
636 | + $args = wp_parse_args($args, $defaults); |
|
637 | 637 | |
638 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
638 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
639 | 639 | $options = ''; |
640 | - if( $args['required'] ) { |
|
640 | + if ($args['required']) { |
|
641 | 641 | $options .= ' required="required"'; |
642 | 642 | } |
643 | - if( $args['readonly'] ) { |
|
643 | + if ($args['readonly']) { |
|
644 | 644 | $options .= ' readonly'; |
645 | 645 | } |
646 | - if( $args['readonly'] ) { |
|
646 | + if ($args['readonly']) { |
|
647 | 647 | $options .= ' readonly'; |
648 | 648 | } |
649 | 649 | |
650 | 650 | $data = ''; |
651 | - if ( !empty( $args['data'] ) ) { |
|
652 | - foreach ( $args['data'] as $key => $value ) { |
|
653 | - $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" '; |
|
651 | + if (!empty($args['data'])) { |
|
652 | + foreach ($args['data'] as $key => $value) { |
|
653 | + $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" '; |
|
654 | 654 | } |
655 | 655 | } |
656 | 656 | |
657 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
658 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
659 | - if ( ! empty( $args['desc'] ) ) { |
|
660 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
657 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
658 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>'; |
|
659 | + if (!empty($args['desc'])) { |
|
660 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
661 | 661 | } |
662 | 662 | |
663 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>'; |
|
663 | + $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>'; |
|
664 | 664 | |
665 | 665 | $output .= '</span>'; |
666 | 666 | |
667 | 667 | return $output; |
668 | 668 | } |
669 | 669 | |
670 | -function wpinv_html_date_field( $args = array() ) { |
|
671 | - if( empty( $args['class'] ) ) { |
|
670 | +function wpinv_html_date_field($args = array()) { |
|
671 | + if (empty($args['class'])) { |
|
672 | 672 | $args['class'] = 'wpiDatepicker'; |
673 | - } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) { |
|
673 | + } elseif (!strpos($args['class'], 'wpiDatepicker')) { |
|
674 | 674 | $args['class'] .= ' wpiDatepicker'; |
675 | 675 | } |
676 | 676 | |
677 | - return wpinv_html_text( $args ); |
|
677 | + return wpinv_html_text($args); |
|
678 | 678 | } |
679 | 679 | |
680 | -function wpinv_html_textarea( $args = array() ) { |
|
680 | +function wpinv_html_textarea($args = array()) { |
|
681 | 681 | $defaults = array( |
682 | 682 | 'name' => 'textarea', |
683 | 683 | 'value' => null, |
@@ -688,31 +688,31 @@ discard block |
||
688 | 688 | 'placeholder' => '', |
689 | 689 | ); |
690 | 690 | |
691 | - $args = wp_parse_args( $args, $defaults ); |
|
691 | + $args = wp_parse_args($args, $defaults); |
|
692 | 692 | |
693 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
693 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
694 | 694 | $disabled = ''; |
695 | - if( $args['disabled'] ) { |
|
695 | + if ($args['disabled']) { |
|
696 | 696 | $disabled = ' disabled="disabled"'; |
697 | 697 | } |
698 | 698 | |
699 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
700 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
701 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
699 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
700 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>'; |
|
701 | + $output .= '<textarea name="' . esc_attr($args['name']) . '" placeholder="' . esc_attr($args['placeholder']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>'; |
|
702 | 702 | |
703 | - if ( ! empty( $args['desc'] ) ) { |
|
704 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
703 | + if (!empty($args['desc'])) { |
|
704 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
705 | 705 | } |
706 | 706 | $output .= '</span>'; |
707 | 707 | |
708 | 708 | return $output; |
709 | 709 | } |
710 | 710 | |
711 | -function wpinv_html_ajax_user_search( $args = array() ) { |
|
711 | +function wpinv_html_ajax_user_search($args = array()) { |
|
712 | 712 | $defaults = array( |
713 | 713 | 'name' => 'user_id', |
714 | 714 | 'value' => null, |
715 | - 'placeholder' => __( 'Enter username', 'invoicing' ), |
|
715 | + 'placeholder' => __('Enter username', 'invoicing'), |
|
716 | 716 | 'label' => null, |
717 | 717 | 'desc' => null, |
718 | 718 | 'class' => '', |
@@ -721,13 +721,13 @@ discard block |
||
721 | 721 | 'data' => false |
722 | 722 | ); |
723 | 723 | |
724 | - $args = wp_parse_args( $args, $defaults ); |
|
724 | + $args = wp_parse_args($args, $defaults); |
|
725 | 725 | |
726 | 726 | $args['class'] = 'wpinv-ajax-user-search ' . $args['class']; |
727 | 727 | |
728 | 728 | $output = '<span class="wpinv_user_search_wrap">'; |
729 | - $output .= wpinv_html_text( $args ); |
|
730 | - $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>'; |
|
729 | + $output .= wpinv_html_text($args); |
|
730 | + $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>'; |
|
731 | 731 | $output .= '</span>'; |
732 | 732 | |
733 | 733 | return $output; |
@@ -743,20 +743,20 @@ discard block |
||
743 | 743 | * |
744 | 744 | * @param string $template the template that is currently being used. |
745 | 745 | */ |
746 | -function wpinv_template( $template ) { |
|
746 | +function wpinv_template($template) { |
|
747 | 747 | global $post; |
748 | 748 | |
749 | - if ( ! is_admin() && ( is_single() || is_404() ) && ! empty( $post->ID ) && getpaid_is_invoice_post_type( get_post_type( $post->ID ) ) ) { |
|
749 | + if (!is_admin() && (is_single() || is_404()) && !empty($post->ID) && getpaid_is_invoice_post_type(get_post_type($post->ID))) { |
|
750 | 750 | |
751 | 751 | // If the user can view this invoice, display it. |
752 | - if ( wpinv_user_can_view_invoice( $post->ID ) ) { |
|
752 | + if (wpinv_user_can_view_invoice($post->ID)) { |
|
753 | 753 | |
754 | - return wpinv_get_template_part( 'wpinv-invoice-print', false, false ); |
|
754 | + return wpinv_get_template_part('wpinv-invoice-print', false, false); |
|
755 | 755 | |
756 | 756 | // Else display an error message. |
757 | 757 | } else { |
758 | 758 | |
759 | - return wpinv_get_template_part( 'wpinv-invalid-access', false, false ); |
|
759 | + return wpinv_get_template_part('wpinv-invalid-access', false, false); |
|
760 | 760 | |
761 | 761 | } |
762 | 762 | |
@@ -764,46 +764,46 @@ discard block |
||
764 | 764 | |
765 | 765 | return $template; |
766 | 766 | } |
767 | -add_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
767 | +add_filter('template_include', 'wpinv_template', 10, 1); |
|
768 | 768 | |
769 | 769 | function wpinv_get_business_address() { |
770 | 770 | $business_address = wpinv_store_address(); |
771 | - $business_address = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : ''; |
|
771 | + $business_address = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : ''; |
|
772 | 772 | |
773 | 773 | $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : ''; |
774 | 774 | |
775 | - return apply_filters( 'wpinv_get_business_address', $business_address ); |
|
775 | + return apply_filters('wpinv_get_business_address', $business_address); |
|
776 | 776 | } |
777 | 777 | |
778 | 778 | /** |
779 | 779 | * Displays the company address. |
780 | 780 | */ |
781 | 781 | function wpinv_display_from_address() { |
782 | - wpinv_get_template( 'invoice/company-address.php' ); |
|
782 | + wpinv_get_template('invoice/company-address.php'); |
|
783 | 783 | } |
784 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_from_address', 10 ); |
|
784 | +add_action('getpaid_invoice_details_left', 'wpinv_display_from_address', 10); |
|
785 | 785 | |
786 | -function wpinv_watermark( $id = 0 ) { |
|
787 | - $output = wpinv_get_watermark( $id ); |
|
788 | - return apply_filters( 'wpinv_get_watermark', $output, $id ); |
|
786 | +function wpinv_watermark($id = 0) { |
|
787 | + $output = wpinv_get_watermark($id); |
|
788 | + return apply_filters('wpinv_get_watermark', $output, $id); |
|
789 | 789 | } |
790 | 790 | |
791 | -function wpinv_get_watermark( $id ) { |
|
792 | - if ( !$id > 0 ) { |
|
791 | +function wpinv_get_watermark($id) { |
|
792 | + if (!$id > 0) { |
|
793 | 793 | return NULL; |
794 | 794 | } |
795 | 795 | |
796 | - $invoice = wpinv_get_invoice( $id ); |
|
796 | + $invoice = wpinv_get_invoice($id); |
|
797 | 797 | |
798 | - if ( !empty( $invoice ) && "wpi_invoice" === $invoice->post_type ) { |
|
799 | - if ( $invoice->is_paid() ) { |
|
800 | - return __( 'Paid', 'invoicing' ); |
|
798 | + if (!empty($invoice) && "wpi_invoice" === $invoice->post_type) { |
|
799 | + if ($invoice->is_paid()) { |
|
800 | + return __('Paid', 'invoicing'); |
|
801 | 801 | } |
802 | - if ( $invoice->is_refunded() ) { |
|
803 | - return __( 'Refunded', 'invoicing' ); |
|
802 | + if ($invoice->is_refunded()) { |
|
803 | + return __('Refunded', 'invoicing'); |
|
804 | 804 | } |
805 | - if ( $invoice->has_status( array( 'wpi-cancelled' ) ) ) { |
|
806 | - return __( 'Cancelled', 'invoicing' ); |
|
805 | + if ($invoice->has_status(array('wpi-cancelled'))) { |
|
806 | + return __('Cancelled', 'invoicing'); |
|
807 | 807 | } |
808 | 808 | } |
809 | 809 | |
@@ -813,30 +813,30 @@ discard block |
||
813 | 813 | /** |
814 | 814 | * @deprecated |
815 | 815 | */ |
816 | -function wpinv_display_invoice_details( $invoice ) { |
|
817 | - return getpaid_invoice_meta( $invoice ); |
|
816 | +function wpinv_display_invoice_details($invoice) { |
|
817 | + return getpaid_invoice_meta($invoice); |
|
818 | 818 | } |
819 | 819 | |
820 | 820 | /** |
821 | 821 | * Displays invoice meta. |
822 | 822 | */ |
823 | -function getpaid_invoice_meta( $invoice ) { |
|
823 | +function getpaid_invoice_meta($invoice) { |
|
824 | 824 | |
825 | - $invoice = new WPInv_Invoice( $invoice ); |
|
825 | + $invoice = new WPInv_Invoice($invoice); |
|
826 | 826 | |
827 | 827 | // Ensure that we have an invoice. |
828 | - if ( 0 == $invoice->get_id() ) { |
|
828 | + if (0 == $invoice->get_id()) { |
|
829 | 829 | return; |
830 | 830 | } |
831 | 831 | |
832 | 832 | // Get the invoice meta. |
833 | - $meta = getpaid_get_invoice_meta( $invoice ); |
|
833 | + $meta = getpaid_get_invoice_meta($invoice); |
|
834 | 834 | |
835 | 835 | // Display the meta. |
836 | - wpinv_get_template( 'invoice/invoice-meta.php', compact( 'invoice', 'meta' ) ); |
|
836 | + wpinv_get_template('invoice/invoice-meta.php', compact('invoice', 'meta')); |
|
837 | 837 | |
838 | 838 | } |
839 | -add_action( 'getpaid_invoice_details_right', 'getpaid_invoice_meta', 10 ); |
|
839 | +add_action('getpaid_invoice_details_right', 'getpaid_invoice_meta', 10); |
|
840 | 840 | |
841 | 841 | /** |
842 | 842 | * Retrieves the address markup to use on Invoices. |
@@ -848,29 +848,29 @@ discard block |
||
848 | 848 | * @param string $separator How to separate address lines. |
849 | 849 | * @return string |
850 | 850 | */ |
851 | -function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) { |
|
851 | +function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') { |
|
852 | 852 | |
853 | 853 | // Retrieve the address markup... |
854 | - $country= empty( $billing_details['country'] ) ? '' : $billing_details['country']; |
|
855 | - $format = wpinv_get_full_address_format( $country ); |
|
854 | + $country = empty($billing_details['country']) ? '' : $billing_details['country']; |
|
855 | + $format = wpinv_get_full_address_format($country); |
|
856 | 856 | |
857 | 857 | // ... and the replacements. |
858 | - $replacements = wpinv_get_invoice_address_replacements( $billing_details ); |
|
858 | + $replacements = wpinv_get_invoice_address_replacements($billing_details); |
|
859 | 859 | |
860 | - $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format ); |
|
860 | + $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format); |
|
861 | 861 | |
862 | 862 | // Remove unavailable tags. |
863 | - $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address ); |
|
863 | + $formatted_address = preg_replace("/\{\{\w+\}\}/", '', $formatted_address); |
|
864 | 864 | |
865 | 865 | // Clean up white space. |
866 | - $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
867 | - $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address ); |
|
866 | + $formatted_address = preg_replace('/ +/', ' ', trim($formatted_address)); |
|
867 | + $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address); |
|
868 | 868 | |
869 | 869 | // Break newlines apart and remove empty lines/trim commas and white space. |
870 | - $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
870 | + $formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address))); |
|
871 | 871 | |
872 | 872 | // Add html breaks. |
873 | - $formatted_address = implode( $separator, $formatted_address ); |
|
873 | + $formatted_address = implode($separator, $formatted_address); |
|
874 | 874 | |
875 | 875 | // We're done! |
876 | 876 | return $formatted_address; |
@@ -882,88 +882,88 @@ discard block |
||
882 | 882 | * |
883 | 883 | * @param WPInv_Invoice $invoice |
884 | 884 | */ |
885 | -function wpinv_display_to_address( $invoice = 0 ) { |
|
886 | - if ( ! empty( $invoice ) ) { |
|
887 | - wpinv_get_template( 'invoice/billing-address.php', compact( 'invoice' ) ); |
|
885 | +function wpinv_display_to_address($invoice = 0) { |
|
886 | + if (!empty($invoice)) { |
|
887 | + wpinv_get_template('invoice/billing-address.php', compact('invoice')); |
|
888 | 888 | } |
889 | 889 | } |
890 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_to_address', 40 ); |
|
890 | +add_action('getpaid_invoice_details_left', 'wpinv_display_to_address', 40); |
|
891 | 891 | |
892 | 892 | |
893 | 893 | /** |
894 | 894 | * Displays invoice line items. |
895 | 895 | */ |
896 | -function wpinv_display_line_items( $invoice_id = 0 ) { |
|
896 | +function wpinv_display_line_items($invoice_id = 0) { |
|
897 | 897 | |
898 | 898 | // Prepare the invoice. |
899 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
899 | + $invoice = new WPInv_Invoice($invoice_id); |
|
900 | 900 | |
901 | 901 | // Abort if there is no invoice. |
902 | - if ( 0 == $invoice->get_id() ) { |
|
902 | + if (0 == $invoice->get_id()) { |
|
903 | 903 | return; |
904 | 904 | } |
905 | 905 | |
906 | 906 | // Line item columns. |
907 | - $columns = getpaid_invoice_item_columns( $invoice ); |
|
908 | - $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice ); |
|
907 | + $columns = getpaid_invoice_item_columns($invoice); |
|
908 | + $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice); |
|
909 | 909 | |
910 | - wpinv_get_template( 'invoice/line-items.php', compact( 'invoice', 'columns' ) ); |
|
910 | + wpinv_get_template('invoice/line-items.php', compact('invoice', 'columns')); |
|
911 | 911 | } |
912 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_line_items', 10 ); |
|
912 | +add_action('getpaid_invoice_line_items', 'wpinv_display_line_items', 10); |
|
913 | 913 | |
914 | 914 | /** |
915 | 915 | * Displays invoice notices on invoices. |
916 | 916 | */ |
917 | 917 | function wpinv_display_invoice_notice() { |
918 | 918 | |
919 | - $label = wpinv_get_option( 'vat_invoice_notice_label' ); |
|
920 | - $notice = wpinv_get_option( 'vat_invoice_notice' ); |
|
919 | + $label = wpinv_get_option('vat_invoice_notice_label'); |
|
920 | + $notice = wpinv_get_option('vat_invoice_notice'); |
|
921 | 921 | |
922 | - if ( empty( $label ) && empty( $notice ) ) { |
|
922 | + if (empty($label) && empty($notice)) { |
|
923 | 923 | return; |
924 | 924 | } |
925 | 925 | |
926 | 926 | echo '<div class="mt-4 mb-4 wpinv-vat-notice">'; |
927 | 927 | |
928 | - if ( ! empty( $label ) ) { |
|
929 | - $label = sanitize_text_field( $label ); |
|
928 | + if (!empty($label)) { |
|
929 | + $label = sanitize_text_field($label); |
|
930 | 930 | echo "<h5>$label</h5>"; |
931 | 931 | } |
932 | 932 | |
933 | - if ( ! empty( $notice ) ) { |
|
934 | - echo '<small class="form-text text-muted">' . wpautop( wptexturize( $notice ) ) . '</small>'; |
|
933 | + if (!empty($notice)) { |
|
934 | + echo '<small class="form-text text-muted">' . wpautop(wptexturize($notice)) . '</small>'; |
|
935 | 935 | } |
936 | 936 | |
937 | 937 | echo '</div>'; |
938 | 938 | } |
939 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100 ); |
|
939 | +add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100); |
|
940 | 940 | |
941 | 941 | /** |
942 | 942 | * @param WPInv_Invoice $invoice |
943 | 943 | */ |
944 | -function wpinv_display_invoice_notes( $invoice ) { |
|
944 | +function wpinv_display_invoice_notes($invoice) { |
|
945 | 945 | |
946 | 946 | // Retrieve the notes. |
947 | - $notes = wpinv_get_invoice_notes( $invoice->get_id(), 'customer' ); |
|
947 | + $notes = wpinv_get_invoice_notes($invoice->get_id(), 'customer'); |
|
948 | 948 | |
949 | 949 | // Abort if we have non. |
950 | - if ( empty( $notes ) ) { |
|
950 | + if (empty($notes)) { |
|
951 | 951 | return; |
952 | 952 | } |
953 | 953 | |
954 | 954 | // Echo the note. |
955 | 955 | echo '<div class="getpaid-invoice-notes-wrapper border position-relative w-100 mb-4 p-0">'; |
956 | - echo '<h3 class="getpaid-invoice-notes-title text-dark bg-light border-bottom m-0 d-block">' . __( 'Notes', 'invoicing' ) .'</h3>'; |
|
956 | + echo '<h3 class="getpaid-invoice-notes-title text-dark bg-light border-bottom m-0 d-block">' . __('Notes', 'invoicing') . '</h3>'; |
|
957 | 957 | echo '<ul class="getpaid-invoice-notes mt-4 p-0">'; |
958 | 958 | |
959 | - foreach( $notes as $note ) { |
|
960 | - wpinv_get_invoice_note_line_item( $note ); |
|
959 | + foreach ($notes as $note) { |
|
960 | + wpinv_get_invoice_note_line_item($note); |
|
961 | 961 | } |
962 | 962 | |
963 | 963 | echo '</ul>'; |
964 | 964 | echo '</div>'; |
965 | 965 | } |
966 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60 ); |
|
966 | +add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60); |
|
967 | 967 | |
968 | 968 | /** |
969 | 969 | * Loads scripts on our invoice templates. |
@@ -971,32 +971,32 @@ discard block |
||
971 | 971 | function wpinv_display_style() { |
972 | 972 | |
973 | 973 | // Make sure that all scripts have been loaded. |
974 | - if ( ! did_action( 'wp_enqueue_scripts' ) ) { |
|
975 | - do_action( 'wp_enqueue_scripts' ); |
|
974 | + if (!did_action('wp_enqueue_scripts')) { |
|
975 | + do_action('wp_enqueue_scripts'); |
|
976 | 976 | } |
977 | 977 | |
978 | 978 | // Register the invoices style. |
979 | - wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice.css' ) ); |
|
979 | + wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice.css')); |
|
980 | 980 | |
981 | 981 | // Load required styles |
982 | - wp_print_styles( 'open-sans' ); |
|
983 | - wp_print_styles( 'wpinv-single-style' ); |
|
984 | - wp_print_styles( 'ayecode-ui' ); |
|
982 | + wp_print_styles('open-sans'); |
|
983 | + wp_print_styles('wpinv-single-style'); |
|
984 | + wp_print_styles('ayecode-ui'); |
|
985 | 985 | |
986 | 986 | // Maybe load custom css. |
987 | - $custom_css = wpinv_get_option( 'template_custom_css' ); |
|
987 | + $custom_css = wpinv_get_option('template_custom_css'); |
|
988 | 988 | |
989 | - if ( isset( $custom_css ) && ! empty( $custom_css ) ) { |
|
990 | - $custom_css = wp_kses( $custom_css, array( '\'', '\"' ) ); |
|
991 | - $custom_css = str_replace( '>', '>', $custom_css ); |
|
989 | + if (isset($custom_css) && !empty($custom_css)) { |
|
990 | + $custom_css = wp_kses($custom_css, array('\'', '\"')); |
|
991 | + $custom_css = str_replace('>', '>', $custom_css); |
|
992 | 992 | echo '<style type="text/css">'; |
993 | 993 | echo $custom_css; |
994 | 994 | echo '</style>'; |
995 | 995 | } |
996 | 996 | |
997 | 997 | } |
998 | -add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' ); |
|
999 | -add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' ); |
|
998 | +add_action('wpinv_invoice_print_head', 'wpinv_display_style'); |
|
999 | +add_action('wpinv_invalid_invoice_head', 'wpinv_display_style'); |
|
1000 | 1000 | |
1001 | 1001 | |
1002 | 1002 | /** |
@@ -1008,41 +1008,41 @@ discard block |
||
1008 | 1008 | // Retrieve the current invoice. |
1009 | 1009 | $invoice_id = getpaid_get_current_invoice_id(); |
1010 | 1010 | |
1011 | - if ( empty( $invoice_id ) ) { |
|
1011 | + if (empty($invoice_id)) { |
|
1012 | 1012 | |
1013 | 1013 | return aui()->alert( |
1014 | 1014 | array( |
1015 | 1015 | 'type' => 'warning', |
1016 | - 'content' => __( 'Invalid invoice', 'invoicing' ), |
|
1016 | + 'content' => __('Invalid invoice', 'invoicing'), |
|
1017 | 1017 | ) |
1018 | 1018 | ); |
1019 | 1019 | |
1020 | 1020 | } |
1021 | 1021 | |
1022 | 1022 | // Can the user view this invoice? |
1023 | - if ( ! wpinv_user_can_view_invoice( $invoice_id ) ) { |
|
1023 | + if (!wpinv_user_can_view_invoice($invoice_id)) { |
|
1024 | 1024 | |
1025 | 1025 | return aui()->alert( |
1026 | 1026 | array( |
1027 | 1027 | 'type' => 'warning', |
1028 | - 'content' => __( 'You are not allowed to view this invoice', 'invoicing' ), |
|
1028 | + 'content' => __('You are not allowed to view this invoice', 'invoicing'), |
|
1029 | 1029 | ) |
1030 | 1030 | ); |
1031 | 1031 | |
1032 | 1032 | } |
1033 | 1033 | |
1034 | 1034 | // Ensure that it is not yet paid for. |
1035 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
1035 | + $invoice = new WPInv_Invoice($invoice_id); |
|
1036 | 1036 | |
1037 | 1037 | // Maybe mark it as viewed. |
1038 | - getpaid_maybe_mark_invoice_as_viewed( $invoice ); |
|
1038 | + getpaid_maybe_mark_invoice_as_viewed($invoice); |
|
1039 | 1039 | |
1040 | - if ( $invoice->is_paid() ) { |
|
1040 | + if ($invoice->is_paid()) { |
|
1041 | 1041 | |
1042 | 1042 | return aui()->alert( |
1043 | 1043 | array( |
1044 | 1044 | 'type' => 'success', |
1045 | - 'content' => __( 'This invoice has already been paid.', 'invoicing' ), |
|
1045 | + 'content' => __('This invoice has already been paid.', 'invoicing'), |
|
1046 | 1046 | ) |
1047 | 1047 | ); |
1048 | 1048 | |
@@ -1052,14 +1052,14 @@ discard block |
||
1052 | 1052 | $wpi_checkout_id = $invoice_id; |
1053 | 1053 | |
1054 | 1054 | // We'll display this invoice via the default form. |
1055 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
1055 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
1056 | 1056 | |
1057 | - if ( 0 == $form->get_id() ) { |
|
1057 | + if (0 == $form->get_id()) { |
|
1058 | 1058 | |
1059 | 1059 | return aui()->alert( |
1060 | 1060 | array( |
1061 | 1061 | 'type' => 'warning', |
1062 | - 'content' => __( 'Error loading the payment form', 'invoicing' ), |
|
1062 | + 'content' => __('Error loading the payment form', 'invoicing'), |
|
1063 | 1063 | ) |
1064 | 1064 | ); |
1065 | 1065 | |
@@ -1067,7 +1067,7 @@ discard block |
||
1067 | 1067 | |
1068 | 1068 | // Set the invoice. |
1069 | 1069 | $form->invoice = $invoice; |
1070 | - $form->set_items( $invoice->get_items() ); |
|
1070 | + $form->set_items($invoice->get_items()); |
|
1071 | 1071 | |
1072 | 1072 | // Generate the html. |
1073 | 1073 | return $form->get_html(); |
@@ -1075,7 +1075,7 @@ discard block |
||
1075 | 1075 | } |
1076 | 1076 | |
1077 | 1077 | function wpinv_empty_cart_message() { |
1078 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1078 | + return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>'); |
|
1079 | 1079 | } |
1080 | 1080 | |
1081 | 1081 | /** |
@@ -1092,38 +1092,38 @@ discard block |
||
1092 | 1092 | ) |
1093 | 1093 | ); |
1094 | 1094 | } |
1095 | -add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
|
1095 | +add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart'); |
|
1096 | 1096 | |
1097 | -function wpinv_receipt_billing_address( $invoice_id = 0 ) { |
|
1098 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1097 | +function wpinv_receipt_billing_address($invoice_id = 0) { |
|
1098 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1099 | 1099 | |
1100 | - if ( empty( $invoice ) ) { |
|
1100 | + if (empty($invoice)) { |
|
1101 | 1101 | return NULL; |
1102 | 1102 | } |
1103 | 1103 | |
1104 | 1104 | $billing_details = $invoice->get_user_info(); |
1105 | - $address_row = wpinv_get_invoice_address_markup( $billing_details ); |
|
1105 | + $address_row = wpinv_get_invoice_address_markup($billing_details); |
|
1106 | 1106 | |
1107 | 1107 | ob_start(); |
1108 | 1108 | ?> |
1109 | 1109 | <table class="table table-bordered table-sm wpi-billing-details"> |
1110 | 1110 | <tbody> |
1111 | 1111 | <tr class="wpi-receipt-name"> |
1112 | - <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th> |
|
1113 | - <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td> |
|
1112 | + <th class="text-left"><?php _e('Name', 'invoicing'); ?></th> |
|
1113 | + <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td> |
|
1114 | 1114 | </tr> |
1115 | 1115 | <tr class="wpi-receipt-email"> |
1116 | - <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th> |
|
1117 | - <td><?php echo $billing_details['email'] ;?></td> |
|
1116 | + <th class="text-left"><?php _e('Email', 'invoicing'); ?></th> |
|
1117 | + <td><?php echo $billing_details['email']; ?></td> |
|
1118 | 1118 | </tr> |
1119 | 1119 | <tr class="wpi-receipt-address"> |
1120 | - <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th> |
|
1121 | - <td><?php echo $address_row ;?></td> |
|
1120 | + <th class="text-left"><?php _e('Address', 'invoicing'); ?></th> |
|
1121 | + <td><?php echo $address_row; ?></td> |
|
1122 | 1122 | </tr> |
1123 | - <?php if ( $billing_details['phone'] ) { ?> |
|
1123 | + <?php if ($billing_details['phone']) { ?> |
|
1124 | 1124 | <tr class="wpi-receipt-phone"> |
1125 | - <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th> |
|
1126 | - <td><?php echo esc_html( $billing_details['phone'] ) ;?></td> |
|
1125 | + <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th> |
|
1126 | + <td><?php echo esc_html($billing_details['phone']); ?></td> |
|
1127 | 1127 | </tr> |
1128 | 1128 | <?php } ?> |
1129 | 1129 | </tbody> |
@@ -1131,7 +1131,7 @@ discard block |
||
1131 | 1131 | <?php |
1132 | 1132 | $output = ob_get_clean(); |
1133 | 1133 | |
1134 | - $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id ); |
|
1134 | + $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id); |
|
1135 | 1135 | |
1136 | 1136 | echo $output; |
1137 | 1137 | } |
@@ -1139,66 +1139,66 @@ discard block |
||
1139 | 1139 | /** |
1140 | 1140 | * Filters the receipt page. |
1141 | 1141 | */ |
1142 | -function wpinv_filter_success_page_content( $content ) { |
|
1142 | +function wpinv_filter_success_page_content($content) { |
|
1143 | 1143 | |
1144 | 1144 | // Ensure this is our page. |
1145 | - if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) { |
|
1145 | + if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) { |
|
1146 | 1146 | |
1147 | - $gateway = sanitize_text_field( $_GET['payment-confirm'] ); |
|
1148 | - return apply_filters( "wpinv_payment_confirm_$gateway", $content ); |
|
1147 | + $gateway = sanitize_text_field($_GET['payment-confirm']); |
|
1148 | + return apply_filters("wpinv_payment_confirm_$gateway", $content); |
|
1149 | 1149 | |
1150 | 1150 | } |
1151 | 1151 | |
1152 | 1152 | return $content; |
1153 | 1153 | } |
1154 | -add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 ); |
|
1154 | +add_filter('the_content', 'wpinv_filter_success_page_content', 99999); |
|
1155 | 1155 | |
1156 | -function wpinv_invoice_link( $invoice_id ) { |
|
1157 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1156 | +function wpinv_invoice_link($invoice_id) { |
|
1157 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1158 | 1158 | |
1159 | - if ( empty( $invoice ) ) { |
|
1159 | + if (empty($invoice)) { |
|
1160 | 1160 | return NULL; |
1161 | 1161 | } |
1162 | 1162 | |
1163 | - $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>'; |
|
1163 | + $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>'; |
|
1164 | 1164 | |
1165 | - return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice ); |
|
1165 | + return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice); |
|
1166 | 1166 | } |
1167 | 1167 | |
1168 | -function wpinv_get_invoice_note_line_item( $note, $echo = true ) { |
|
1169 | - if ( empty( $note ) ) { |
|
1168 | +function wpinv_get_invoice_note_line_item($note, $echo = true) { |
|
1169 | + if (empty($note)) { |
|
1170 | 1170 | return NULL; |
1171 | 1171 | } |
1172 | 1172 | |
1173 | - if ( is_int( $note ) ) { |
|
1174 | - $note = get_comment( $note ); |
|
1173 | + if (is_int($note)) { |
|
1174 | + $note = get_comment($note); |
|
1175 | 1175 | } |
1176 | 1176 | |
1177 | - if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) { |
|
1177 | + if (!(is_object($note) && is_a($note, 'WP_Comment'))) { |
|
1178 | 1178 | return NULL; |
1179 | 1179 | } |
1180 | 1180 | |
1181 | - $note_classes = array( 'note' ); |
|
1182 | - $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : ''; |
|
1181 | + $note_classes = array('note'); |
|
1182 | + $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : ''; |
|
1183 | 1183 | $note_classes[] = $note->comment_author === 'System' ? 'system-note' : ''; |
1184 | - $note_classes = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note ); |
|
1185 | - $note_classes = !empty( $note_classes ) ? implode( ' ', $note_classes ) : ''; |
|
1184 | + $note_classes = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note); |
|
1185 | + $note_classes = !empty($note_classes) ? implode(' ', $note_classes) : ''; |
|
1186 | 1186 | |
1187 | 1187 | ob_start(); |
1188 | 1188 | ?> |
1189 | - <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?> mt-4 pl-3 pr-3"> |
|
1189 | + <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?> mt-4 pl-3 pr-3"> |
|
1190 | 1190 | <div class="note_content bg-light border position-relative p-4"> |
1191 | 1191 | |
1192 | - <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?> |
|
1192 | + <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?> |
|
1193 | 1193 | |
1194 | - <?php if ( ! is_admin() ) : ?> |
|
1194 | + <?php if (!is_admin()) : ?> |
|
1195 | 1195 | <em class="meta position-absolute form-text"> |
1196 | 1196 | <?php |
1197 | 1197 | printf( |
1198 | - __( '%1$s - %2$s at %3$s', 'invoicing' ), |
|
1198 | + __('%1$s - %2$s at %3$s', 'invoicing'), |
|
1199 | 1199 | $note->comment_author, |
1200 | - getpaid_format_date_value( $note->comment_date ), |
|
1201 | - date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) |
|
1200 | + getpaid_format_date_value($note->comment_date), |
|
1201 | + date_i18n(get_option('time_format'), strtotime($note->comment_date)) |
|
1202 | 1202 | ); |
1203 | 1203 | ?> |
1204 | 1204 | </em> |
@@ -1206,21 +1206,21 @@ discard block |
||
1206 | 1206 | |
1207 | 1207 | </div> |
1208 | 1208 | |
1209 | - <?php if ( is_admin() ) : ?> |
|
1209 | + <?php if (is_admin()) : ?> |
|
1210 | 1210 | |
1211 | 1211 | <p class="meta px-4 py-2"> |
1212 | - <abbr class="exact-date" title="<?php echo esc_attr( $note->comment_date ); ?>"> |
|
1212 | + <abbr class="exact-date" title="<?php echo esc_attr($note->comment_date); ?>"> |
|
1213 | 1213 | <?php |
1214 | 1214 | printf( |
1215 | - __( '%1$s - %2$s at %3$s', 'invoicing' ), |
|
1215 | + __('%1$s - %2$s at %3$s', 'invoicing'), |
|
1216 | 1216 | $note->comment_author, |
1217 | - getpaid_format_date_value( $note->comment_date ), |
|
1218 | - date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) |
|
1217 | + getpaid_format_date_value($note->comment_date), |
|
1218 | + date_i18n(get_option('time_format'), strtotime($note->comment_date)) |
|
1219 | 1219 | ); |
1220 | 1220 | ?> |
1221 | 1221 | </abbr> |
1222 | - <?php if ( $note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing() ) { ?> |
|
1223 | - <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a> |
|
1222 | + <?php if ($note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing()) { ?> |
|
1223 | + <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a> |
|
1224 | 1224 | <?php } ?> |
1225 | 1225 | </p> |
1226 | 1226 | |
@@ -1229,9 +1229,9 @@ discard block |
||
1229 | 1229 | </li> |
1230 | 1230 | <?php |
1231 | 1231 | $note_content = ob_get_clean(); |
1232 | - $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo ); |
|
1232 | + $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo); |
|
1233 | 1233 | |
1234 | - if ( $echo ) { |
|
1234 | + if ($echo) { |
|
1235 | 1235 | echo $note_content; |
1236 | 1236 | } else { |
1237 | 1237 | return $note_content; |
@@ -1241,36 +1241,36 @@ discard block |
||
1241 | 1241 | function wpinv_invalid_invoice_content() { |
1242 | 1242 | global $post; |
1243 | 1243 | |
1244 | - $invoice = wpinv_get_invoice( $post->ID ); |
|
1244 | + $invoice = wpinv_get_invoice($post->ID); |
|
1245 | 1245 | |
1246 | - $error = __( 'This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing' ); |
|
1247 | - if ( !empty( $invoice->get_id() ) && $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) { |
|
1248 | - if ( is_user_logged_in() ) { |
|
1249 | - if ( wpinv_require_login_to_checkout() ) { |
|
1250 | - if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
1251 | - $error = __( 'You are not allowed to view this invoice.', 'invoicing' ); |
|
1246 | + $error = __('This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing'); |
|
1247 | + if (!empty($invoice->get_id()) && $invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) { |
|
1248 | + if (is_user_logged_in()) { |
|
1249 | + if (wpinv_require_login_to_checkout()) { |
|
1250 | + if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
1251 | + $error = __('You are not allowed to view this invoice.', 'invoicing'); |
|
1252 | 1252 | } |
1253 | 1253 | } |
1254 | 1254 | } else { |
1255 | - if ( wpinv_require_login_to_checkout() ) { |
|
1256 | - if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
1257 | - $error = __( 'You must be logged in to view this invoice.', 'invoicing' ); |
|
1255 | + if (wpinv_require_login_to_checkout()) { |
|
1256 | + if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
1257 | + $error = __('You must be logged in to view this invoice.', 'invoicing'); |
|
1258 | 1258 | } |
1259 | 1259 | } |
1260 | 1260 | } |
1261 | 1261 | } else { |
1262 | - $error = __( 'This invoice is deleted or does not exist.', 'invoicing' ); |
|
1262 | + $error = __('This invoice is deleted or does not exist.', 'invoicing'); |
|
1263 | 1263 | } |
1264 | 1264 | ?> |
1265 | 1265 | <div class="row wpinv-row-invalid"> |
1266 | 1266 | <div class="col-md-6 col-md-offset-3 wpinv-message error"> |
1267 | - <h3><?php _e( 'Access Denied', 'invoicing' ); ?></h3> |
|
1267 | + <h3><?php _e('Access Denied', 'invoicing'); ?></h3> |
|
1268 | 1268 | <p class="wpinv-msg-text"><?php echo $error; ?></p> |
1269 | 1269 | </div> |
1270 | 1270 | </div> |
1271 | 1271 | <?php |
1272 | 1272 | } |
1273 | -add_action( 'wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content' ); |
|
1273 | +add_action('wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content'); |
|
1274 | 1274 | |
1275 | 1275 | /** |
1276 | 1276 | * Function to get privacy policy text. |
@@ -1279,21 +1279,21 @@ discard block |
||
1279 | 1279 | * @return string |
1280 | 1280 | */ |
1281 | 1281 | function wpinv_get_policy_text() { |
1282 | - $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 ); |
|
1282 | + $privacy_page_id = get_option('wp_page_for_privacy_policy', 0); |
|
1283 | 1283 | |
1284 | - $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' )); |
|
1284 | + $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]')); |
|
1285 | 1285 | |
1286 | - if(!$privacy_page_id){ |
|
1287 | - $privacy_page_id = wpinv_get_option( 'privacy_page', 0 ); |
|
1286 | + if (!$privacy_page_id) { |
|
1287 | + $privacy_page_id = wpinv_get_option('privacy_page', 0); |
|
1288 | 1288 | } |
1289 | 1289 | |
1290 | - $privacy_link = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' ); |
|
1290 | + $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing'); |
|
1291 | 1291 | |
1292 | 1292 | $find_replace = array( |
1293 | 1293 | '[wpinv_privacy_policy]' => $privacy_link, |
1294 | 1294 | ); |
1295 | 1295 | |
1296 | - $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text ); |
|
1296 | + $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text); |
|
1297 | 1297 | |
1298 | 1298 | return wp_kses_post(wpautop($privacy_text)); |
1299 | 1299 | } |
@@ -1301,21 +1301,21 @@ discard block |
||
1301 | 1301 | function wpinv_oxygen_fix_conflict() { |
1302 | 1302 | global $ct_ignore_post_types; |
1303 | 1303 | |
1304 | - if ( ! is_array( $ct_ignore_post_types ) ) { |
|
1304 | + if (!is_array($ct_ignore_post_types)) { |
|
1305 | 1305 | $ct_ignore_post_types = array(); |
1306 | 1306 | } |
1307 | 1307 | |
1308 | - $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item' ); |
|
1308 | + $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item'); |
|
1309 | 1309 | |
1310 | - foreach ( $post_types as $post_type ) { |
|
1310 | + foreach ($post_types as $post_type) { |
|
1311 | 1311 | $ct_ignore_post_types[] = $post_type; |
1312 | 1312 | |
1313 | 1313 | // Ignore post type |
1314 | - add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 ); |
|
1314 | + add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999); |
|
1315 | 1315 | } |
1316 | 1316 | |
1317 | - remove_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
1318 | - add_filter( 'template_include', 'wpinv_template', 999, 1 ); |
|
1317 | + remove_filter('template_include', 'wpinv_template', 10, 1); |
|
1318 | + add_filter('template_include', 'wpinv_template', 999, 1); |
|
1319 | 1319 | } |
1320 | 1320 | |
1321 | 1321 | /** |
@@ -1323,10 +1323,10 @@ discard block |
||
1323 | 1323 | * |
1324 | 1324 | * @param GetPaid_Payment_Form $form |
1325 | 1325 | */ |
1326 | -function getpaid_display_payment_form( $form ) { |
|
1326 | +function getpaid_display_payment_form($form) { |
|
1327 | 1327 | |
1328 | - if ( is_numeric( $form ) ) { |
|
1329 | - $form = new GetPaid_Payment_Form( $form ); |
|
1328 | + if (is_numeric($form)) { |
|
1329 | + $form = new GetPaid_Payment_Form($form); |
|
1330 | 1330 | } |
1331 | 1331 | |
1332 | 1332 | $form->display(); |
@@ -1336,55 +1336,55 @@ discard block |
||
1336 | 1336 | /** |
1337 | 1337 | * Helper function to display a item payment form on the frontend. |
1338 | 1338 | */ |
1339 | -function getpaid_display_item_payment_form( $items ) { |
|
1339 | +function getpaid_display_item_payment_form($items) { |
|
1340 | 1340 | |
1341 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
1342 | - $form->set_items( $items ); |
|
1341 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
1342 | + $form->set_items($items); |
|
1343 | 1343 | |
1344 | - if ( 0 == count( $form->get_items() ) ) { |
|
1344 | + if (0 == count($form->get_items())) { |
|
1345 | 1345 | echo aui()->alert( |
1346 | 1346 | array( |
1347 | 1347 | 'type' => 'warning', |
1348 | - 'content' => __( 'No published items found', 'invoicing' ), |
|
1348 | + 'content' => __('No published items found', 'invoicing'), |
|
1349 | 1349 | ) |
1350 | 1350 | ); |
1351 | 1351 | return; |
1352 | 1352 | } |
1353 | 1353 | |
1354 | - $form_items = esc_attr( getpaid_convert_items_to_string( $items ) ); |
|
1354 | + $form_items = esc_attr(getpaid_convert_items_to_string($items)); |
|
1355 | 1355 | $form_items = "<input type='hidden' name='getpaid-form-items' value='$form_items' />"; |
1356 | - $form->display( $form_items ); |
|
1356 | + $form->display($form_items); |
|
1357 | 1357 | } |
1358 | 1358 | |
1359 | 1359 | /** |
1360 | 1360 | * Helper function to display an invoice payment form on the frontend. |
1361 | 1361 | */ |
1362 | -function getpaid_display_invoice_payment_form( $invoice_id ) { |
|
1362 | +function getpaid_display_invoice_payment_form($invoice_id) { |
|
1363 | 1363 | |
1364 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1364 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1365 | 1365 | |
1366 | - if ( empty( $invoice ) ) { |
|
1366 | + if (empty($invoice)) { |
|
1367 | 1367 | echo aui()->alert( |
1368 | 1368 | array( |
1369 | 1369 | 'type' => 'warning', |
1370 | - 'content' => __( 'Invoice not found', 'invoicing' ), |
|
1370 | + 'content' => __('Invoice not found', 'invoicing'), |
|
1371 | 1371 | ) |
1372 | 1372 | ); |
1373 | 1373 | return; |
1374 | 1374 | } |
1375 | 1375 | |
1376 | - if ( $invoice->is_paid() ) { |
|
1376 | + if ($invoice->is_paid()) { |
|
1377 | 1377 | echo aui()->alert( |
1378 | 1378 | array( |
1379 | 1379 | 'type' => 'warning', |
1380 | - 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
1380 | + 'content' => __('Invoice has already been paid', 'invoicing'), |
|
1381 | 1381 | ) |
1382 | 1382 | ); |
1383 | 1383 | return; |
1384 | 1384 | } |
1385 | 1385 | |
1386 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
1387 | - $form->set_items( $invoice->get_items() ); |
|
1386 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
1387 | + $form->set_items($invoice->get_items()); |
|
1388 | 1388 | |
1389 | 1389 | $form->display(); |
1390 | 1390 | } |
@@ -1392,23 +1392,23 @@ discard block |
||
1392 | 1392 | /** |
1393 | 1393 | * Helper function to convert item string to array. |
1394 | 1394 | */ |
1395 | -function getpaid_convert_items_to_array( $items ) { |
|
1396 | - $items = array_filter( array_map( 'trim', explode( ',', $items ) ) ); |
|
1395 | +function getpaid_convert_items_to_array($items) { |
|
1396 | + $items = array_filter(array_map('trim', explode(',', $items))); |
|
1397 | 1397 | $prepared = array(); |
1398 | 1398 | |
1399 | - foreach ( $items as $item ) { |
|
1400 | - $data = array_map( 'trim', explode( '|', $item ) ); |
|
1399 | + foreach ($items as $item) { |
|
1400 | + $data = array_map('trim', explode('|', $item)); |
|
1401 | 1401 | |
1402 | - if ( empty( $data[0] ) || ! is_numeric( $data[0] ) ) { |
|
1402 | + if (empty($data[0]) || !is_numeric($data[0])) { |
|
1403 | 1403 | continue; |
1404 | 1404 | } |
1405 | 1405 | |
1406 | 1406 | $quantity = 1; |
1407 | - if ( isset( $data[1] ) && is_numeric( $data[1] ) ) { |
|
1407 | + if (isset($data[1]) && is_numeric($data[1])) { |
|
1408 | 1408 | $quantity = (int) $data[1]; |
1409 | 1409 | } |
1410 | 1410 | |
1411 | - $prepared[ $data[0] ] = $quantity; |
|
1411 | + $prepared[$data[0]] = $quantity; |
|
1412 | 1412 | |
1413 | 1413 | } |
1414 | 1414 | |
@@ -1418,13 +1418,13 @@ discard block |
||
1418 | 1418 | /** |
1419 | 1419 | * Helper function to convert item array to string. |
1420 | 1420 | */ |
1421 | -function getpaid_convert_items_to_string( $items ) { |
|
1421 | +function getpaid_convert_items_to_string($items) { |
|
1422 | 1422 | $prepared = array(); |
1423 | 1423 | |
1424 | - foreach ( $items as $item => $quantity ) { |
|
1424 | + foreach ($items as $item => $quantity) { |
|
1425 | 1425 | $prepared[] = "$item|$quantity"; |
1426 | 1426 | } |
1427 | - return implode( ',', $prepared ); |
|
1427 | + return implode(',', $prepared); |
|
1428 | 1428 | } |
1429 | 1429 | |
1430 | 1430 | /** |
@@ -1432,21 +1432,21 @@ discard block |
||
1432 | 1432 | * |
1433 | 1433 | * Provide a label and one of $form, $items or $invoice. |
1434 | 1434 | */ |
1435 | -function getpaid_get_payment_button( $label, $form = null, $items = null, $invoice = null ) { |
|
1436 | - $label = sanitize_text_field( $label ); |
|
1435 | +function getpaid_get_payment_button($label, $form = null, $items = null, $invoice = null) { |
|
1436 | + $label = sanitize_text_field($label); |
|
1437 | 1437 | |
1438 | - if ( ! empty( $form ) ) { |
|
1439 | - $form = esc_attr( $form ); |
|
1438 | + if (!empty($form)) { |
|
1439 | + $form = esc_attr($form); |
|
1440 | 1440 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-form='$form'>$label</button>"; |
1441 | 1441 | } |
1442 | 1442 | |
1443 | - if ( ! empty( $items ) ) { |
|
1444 | - $items = esc_attr( $items ); |
|
1443 | + if (!empty($items)) { |
|
1444 | + $items = esc_attr($items); |
|
1445 | 1445 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-item='$items'>$label</button>"; |
1446 | 1446 | } |
1447 | 1447 | |
1448 | - if ( ! empty( $invoice ) ) { |
|
1449 | - $invoice = esc_attr( $invoice ); |
|
1448 | + if (!empty($invoice)) { |
|
1449 | + $invoice = esc_attr($invoice); |
|
1450 | 1450 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-invoice='$invoice'>$label</button>"; |
1451 | 1451 | } |
1452 | 1452 | |
@@ -1457,17 +1457,17 @@ discard block |
||
1457 | 1457 | * |
1458 | 1458 | * @param WPInv_Invoice $invoice |
1459 | 1459 | */ |
1460 | -function getpaid_the_invoice_description( $invoice ) { |
|
1460 | +function getpaid_the_invoice_description($invoice) { |
|
1461 | 1461 | $description = $invoice->get_description(); |
1462 | 1462 | |
1463 | - if ( empty( $description ) ) { |
|
1463 | + if (empty($description)) { |
|
1464 | 1464 | return; |
1465 | 1465 | } |
1466 | 1466 | |
1467 | - $description = wp_kses_post( $description ); |
|
1467 | + $description = wp_kses_post($description); |
|
1468 | 1468 | echo "<small class='getpaid-invoice-description text-dark p-2 form-text'><em>$description</em></small>"; |
1469 | 1469 | } |
1470 | -add_action( 'getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100 ); |
|
1470 | +add_action('getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100); |
|
1471 | 1471 | |
1472 | 1472 | /** |
1473 | 1473 | * Render element on a form. |
@@ -1475,60 +1475,60 @@ discard block |
||
1475 | 1475 | * @param array $element |
1476 | 1476 | * @param GetPaid_Payment_Form $form |
1477 | 1477 | */ |
1478 | -function getpaid_payment_form_element( $element, $form ) { |
|
1478 | +function getpaid_payment_form_element($element, $form) { |
|
1479 | 1479 | |
1480 | 1480 | // Set up the args. |
1481 | - $element_type = trim( $element['type'] ); |
|
1481 | + $element_type = trim($element['type']); |
|
1482 | 1482 | $element['form'] = $form; |
1483 | - extract( $element ); |
|
1483 | + extract($element); |
|
1484 | 1484 | |
1485 | 1485 | // Try to locate the appropriate template. |
1486 | - $located = wpinv_locate_template( "payment-forms/elements/$element_type.php" ); |
|
1486 | + $located = wpinv_locate_template("payment-forms/elements/$element_type.php"); |
|
1487 | 1487 | |
1488 | 1488 | // Abort if this is not our element. |
1489 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
1489 | + if (empty($located) || !file_exists($located)) { |
|
1490 | 1490 | return; |
1491 | 1491 | } |
1492 | 1492 | |
1493 | 1493 | // Generate the class and id of the element. |
1494 | - $wrapper_class = 'getpaid-payment-form-element-' . trim( esc_attr( $element_type ) ); |
|
1495 | - $id = isset( $id ) ? $id : uniqid( 'gp' ); |
|
1494 | + $wrapper_class = 'getpaid-payment-form-element-' . trim(esc_attr($element_type)); |
|
1495 | + $id = isset($id) ? $id : uniqid('gp'); |
|
1496 | 1496 | |
1497 | 1497 | // Echo the opening wrapper. |
1498 | 1498 | echo "<div class='getpaid-payment-form-element $wrapper_class'>"; |
1499 | 1499 | |
1500 | 1500 | // Fires before displaying a given element type's content. |
1501 | - do_action( "getpaid_before_payment_form_{$element_type}_element", $element, $form ); |
|
1501 | + do_action("getpaid_before_payment_form_{$element_type}_element", $element, $form); |
|
1502 | 1502 | |
1503 | 1503 | // Include the template for the element. |
1504 | 1504 | include $located; |
1505 | 1505 | |
1506 | 1506 | // Fires after displaying a given element type's content. |
1507 | - do_action( "getpaid_payment_form_{$element_type}_element", $element, $form ); |
|
1507 | + do_action("getpaid_payment_form_{$element_type}_element", $element, $form); |
|
1508 | 1508 | |
1509 | 1509 | // Echo the closing wrapper. |
1510 | 1510 | echo '</div>'; |
1511 | 1511 | } |
1512 | -add_action( 'getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2 ); |
|
1512 | +add_action('getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2); |
|
1513 | 1513 | |
1514 | 1514 | /** |
1515 | 1515 | * Render an element's edit page. |
1516 | 1516 | * |
1517 | 1517 | * @param WP_Post $post |
1518 | 1518 | */ |
1519 | -function getpaid_payment_form_edit_element_template( $post ) { |
|
1519 | +function getpaid_payment_form_edit_element_template($post) { |
|
1520 | 1520 | |
1521 | 1521 | // Retrieve all elements. |
1522 | - $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' ); |
|
1522 | + $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type'); |
|
1523 | 1523 | |
1524 | - foreach ( $all_elements as $element ) { |
|
1524 | + foreach ($all_elements as $element) { |
|
1525 | 1525 | |
1526 | 1526 | // Try to locate the appropriate template. |
1527 | - $element = sanitize_key( $element ); |
|
1528 | - $located = wpinv_locate_template( "payment-forms-admin/edit/$element.php" ); |
|
1527 | + $element = sanitize_key($element); |
|
1528 | + $located = wpinv_locate_template("payment-forms-admin/edit/$element.php"); |
|
1529 | 1529 | |
1530 | 1530 | // Continue if this is not our element. |
1531 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
1531 | + if (empty($located) || !file_exists($located)) { |
|
1532 | 1532 | continue; |
1533 | 1533 | } |
1534 | 1534 | |
@@ -1539,7 +1539,7 @@ discard block |
||
1539 | 1539 | } |
1540 | 1540 | |
1541 | 1541 | } |
1542 | -add_action( 'getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template' ); |
|
1542 | +add_action('getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template'); |
|
1543 | 1543 | |
1544 | 1544 | /** |
1545 | 1545 | * Render an element's preview. |
@@ -1548,16 +1548,16 @@ discard block |
||
1548 | 1548 | function getpaid_payment_form_render_element_preview_template() { |
1549 | 1549 | |
1550 | 1550 | // Retrieve all elements. |
1551 | - $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' ); |
|
1551 | + $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type'); |
|
1552 | 1552 | |
1553 | - foreach ( $all_elements as $element ) { |
|
1553 | + foreach ($all_elements as $element) { |
|
1554 | 1554 | |
1555 | 1555 | // Try to locate the appropriate template. |
1556 | - $element = sanitize_key( $element ); |
|
1557 | - $located = wpinv_locate_template( "payment-forms-admin/previews/$element.php" ); |
|
1556 | + $element = sanitize_key($element); |
|
1557 | + $located = wpinv_locate_template("payment-forms-admin/previews/$element.php"); |
|
1558 | 1558 | |
1559 | 1559 | // Continue if this is not our element. |
1560 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
1560 | + if (empty($located) || !file_exists($located)) { |
|
1561 | 1561 | continue; |
1562 | 1562 | } |
1563 | 1563 | |
@@ -1568,7 +1568,7 @@ discard block |
||
1568 | 1568 | } |
1569 | 1569 | |
1570 | 1570 | } |
1571 | -add_action( 'wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template' ); |
|
1571 | +add_action('wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template'); |
|
1572 | 1572 | |
1573 | 1573 | /** |
1574 | 1574 | * Shows a list of gateways that support recurring payments. |
@@ -1576,17 +1576,17 @@ discard block |
||
1576 | 1576 | function wpinv_get_recurring_gateways_text() { |
1577 | 1577 | $gateways = array(); |
1578 | 1578 | |
1579 | - foreach ( wpinv_get_payment_gateways() as $key => $gateway ) { |
|
1580 | - if ( wpinv_gateway_support_subscription( $key ) ) { |
|
1581 | - $gateways[] = sanitize_text_field( $gateway['admin_label'] ); |
|
1579 | + foreach (wpinv_get_payment_gateways() as $key => $gateway) { |
|
1580 | + if (wpinv_gateway_support_subscription($key)) { |
|
1581 | + $gateways[] = sanitize_text_field($gateway['admin_label']); |
|
1582 | 1582 | } |
1583 | 1583 | } |
1584 | 1584 | |
1585 | - if ( empty( $gateways ) ) { |
|
1586 | - return "<span class='form-text text-danger'>" . __( 'No active gateways support subscription payments.', 'invoicing' ) ."</span>"; |
|
1585 | + if (empty($gateways)) { |
|
1586 | + return "<span class='form-text text-danger'>" . __('No active gateways support subscription payments.', 'invoicing') . "</span>"; |
|
1587 | 1587 | } |
1588 | 1588 | |
1589 | - return "<span class='form-text text-muted'>" . wp_sprintf( __( 'Subscription payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ) ."</span>"; |
|
1589 | + return "<span class='form-text text-muted'>" . wp_sprintf(__('Subscription payments only supported by: %s', 'invoicing'), implode(', ', $gateways)) . "</span>"; |
|
1590 | 1590 | |
1591 | 1591 | } |
1592 | 1592 | |
@@ -1596,7 +1596,7 @@ discard block |
||
1596 | 1596 | * @return GetPaid_Template |
1597 | 1597 | */ |
1598 | 1598 | function getpaid_template() { |
1599 | - return getpaid()->get( 'template' ); |
|
1599 | + return getpaid()->get('template'); |
|
1600 | 1600 | } |
1601 | 1601 | |
1602 | 1602 | /** |
@@ -1605,23 +1605,23 @@ discard block |
||
1605 | 1605 | * @param array args |
1606 | 1606 | * @return string |
1607 | 1607 | */ |
1608 | -function getpaid_paginate_links( $args ) { |
|
1608 | +function getpaid_paginate_links($args) { |
|
1609 | 1609 | |
1610 | 1610 | $args['type'] = 'array'; |
1611 | 1611 | $args['mid_size'] = 1; |
1612 | - $pages = paginate_links( $args ); |
|
1612 | + $pages = paginate_links($args); |
|
1613 | 1613 | |
1614 | - if ( ! is_array( $pages ) ) { |
|
1614 | + if (!is_array($pages)) { |
|
1615 | 1615 | return ''; |
1616 | 1616 | } |
1617 | 1617 | |
1618 | 1618 | $_pages = array(); |
1619 | - foreach ( $pages as $page ) { |
|
1620 | - $_pages[] = str_replace( 'page-numbers', 'page-link text-decoration-none', $page ); |
|
1619 | + foreach ($pages as $page) { |
|
1620 | + $_pages[] = str_replace('page-numbers', 'page-link text-decoration-none', $page); |
|
1621 | 1621 | } |
1622 | 1622 | |
1623 | 1623 | $links = "<nav>\n\t<ul class='pagination justify-content-end m-0'>\n\t\t<li class='page-item'>"; |
1624 | - $links .= join( "</li>\n\t\t<li class='page-item'>", $_pages ); |
|
1624 | + $links .= join("</li>\n\t\t<li class='page-item'>", $_pages); |
|
1625 | 1625 | $links .= "</li>\n\t</ul>\n</nav>\n"; |
1626 | 1626 | |
1627 | 1627 | return $links; |
@@ -1634,21 +1634,21 @@ discard block |
||
1634 | 1634 | * @param string state |
1635 | 1635 | * @return string |
1636 | 1636 | */ |
1637 | -function getpaid_get_states_select_markup( $country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12' ) { |
|
1637 | +function getpaid_get_states_select_markup($country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12') { |
|
1638 | 1638 | |
1639 | - $states = wpinv_get_country_states( $country ); |
|
1640 | - $uniqid = uniqid( '_' ); |
|
1639 | + $states = wpinv_get_country_states($country); |
|
1640 | + $uniqid = uniqid('_'); |
|
1641 | 1641 | |
1642 | - if ( ! empty( $states ) ) { |
|
1642 | + if (!empty($states)) { |
|
1643 | 1643 | |
1644 | - return aui()->select( array( |
|
1644 | + return aui()->select(array( |
|
1645 | 1645 | 'options' => $states, |
1646 | 1646 | 'name' => 'wpinv_state', |
1647 | 1647 | 'id' => 'wpinv_state' . $uniqid, |
1648 | - 'value' => sanitize_text_field( $state ), |
|
1648 | + 'value' => sanitize_text_field($state), |
|
1649 | 1649 | 'placeholder' => $placeholder, |
1650 | 1650 | 'required' => $required, |
1651 | - 'label' => wp_kses_post( $label ), |
|
1651 | + 'label' => wp_kses_post($label), |
|
1652 | 1652 | 'label_type' => 'vertical', |
1653 | 1653 | 'help_text' => $help_text, |
1654 | 1654 | 'class' => 'getpaid-address-field wpinv_state', |
@@ -1664,10 +1664,10 @@ discard block |
||
1664 | 1664 | 'id' => 'wpinv_state' . $uniqid, |
1665 | 1665 | 'placeholder' => $placeholder, |
1666 | 1666 | 'required' => $required, |
1667 | - 'label' => wp_kses_post( $label ), |
|
1667 | + 'label' => wp_kses_post($label), |
|
1668 | 1668 | 'label_type' => 'vertical', |
1669 | 1669 | 'help_text' => $help_text, |
1670 | - 'value' => sanitize_text_field( $state ), |
|
1670 | + 'value' => sanitize_text_field($state), |
|
1671 | 1671 | 'class' => 'getpaid-address-field wpinv_state', |
1672 | 1672 | 'wrap_class' => "$wrapper_class getpaid-address-field-wrapper__state", |
1673 | 1673 | 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__state', |
@@ -1682,16 +1682,16 @@ discard block |
||
1682 | 1682 | * @param array $element |
1683 | 1683 | * @return string |
1684 | 1684 | */ |
1685 | -function getpaid_get_form_element_grid_class( $element ) { |
|
1685 | +function getpaid_get_form_element_grid_class($element) { |
|
1686 | 1686 | |
1687 | 1687 | $class = "col-12"; |
1688 | - $width = empty( $element['grid_width'] ) ? 'full' : $element['grid_width']; |
|
1688 | + $width = empty($element['grid_width']) ? 'full' : $element['grid_width']; |
|
1689 | 1689 | |
1690 | - if ( $width == 'half' ) { |
|
1690 | + if ($width == 'half') { |
|
1691 | 1691 | $class = "col-12 col-md-6"; |
1692 | 1692 | } |
1693 | 1693 | |
1694 | - if ( $width == 'third' ) { |
|
1694 | + if ($width == 'third') { |
|
1695 | 1695 | $class = "col-12 col-md-4"; |
1696 | 1696 | } |
1697 | 1697 |
@@ -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 | * Invoice class. |
@@ -135,40 +135,40 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read. |
137 | 137 | */ |
138 | - public function __construct( $invoice = 0 ) { |
|
138 | + public function __construct($invoice = 0) { |
|
139 | 139 | |
140 | - parent::__construct( $invoice ); |
|
140 | + parent::__construct($invoice); |
|
141 | 141 | |
142 | - if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) { |
|
143 | - $this->set_id( (int) $invoice ); |
|
144 | - } elseif ( $invoice instanceof self ) { |
|
145 | - $this->set_id( $invoice->get_id() ); |
|
146 | - } elseif ( ! empty( $invoice->ID ) ) { |
|
147 | - $this->set_id( $invoice->ID ); |
|
148 | - } elseif ( is_array( $invoice ) ) { |
|
149 | - $this->set_props( $invoice ); |
|
142 | + if (!empty($invoice) && is_numeric($invoice) && getpaid_is_invoice_post_type(get_post_type((int) $invoice))) { |
|
143 | + $this->set_id((int) $invoice); |
|
144 | + } elseif ($invoice instanceof self) { |
|
145 | + $this->set_id($invoice->get_id()); |
|
146 | + } elseif (!empty($invoice->ID)) { |
|
147 | + $this->set_id($invoice->ID); |
|
148 | + } elseif (is_array($invoice)) { |
|
149 | + $this->set_props($invoice); |
|
150 | 150 | |
151 | - if ( isset( $invoice['ID'] ) ) { |
|
152 | - $this->set_id( $invoice['ID'] ); |
|
151 | + if (isset($invoice['ID'])) { |
|
152 | + $this->set_id($invoice['ID']); |
|
153 | 153 | } |
154 | 154 | |
155 | - } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) { |
|
156 | - $this->set_id( $invoice_id ); |
|
157 | - } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) { |
|
158 | - $this->set_id( $invoice_id ); |
|
159 | - } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) { |
|
160 | - $this->set_id( $invoice_id ); |
|
161 | - }else { |
|
162 | - $this->set_object_read( true ); |
|
155 | + } elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'key')) { |
|
156 | + $this->set_id($invoice_id); |
|
157 | + } elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'number')) { |
|
158 | + $this->set_id($invoice_id); |
|
159 | + } elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'transaction_id')) { |
|
160 | + $this->set_id($invoice_id); |
|
161 | + } else { |
|
162 | + $this->set_object_read(true); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | // Load the datastore. |
166 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
166 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
167 | 167 | |
168 | - if ( $this->get_id() > 0 ) { |
|
169 | - $this->post = get_post( $this->get_id() ); |
|
168 | + if ($this->get_id() > 0) { |
|
169 | + $this->post = get_post($this->get_id()); |
|
170 | 170 | $this->ID = $this->get_id(); |
171 | - $this->data_store->read( $this ); |
|
171 | + $this->data_store->read($this); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | } |
@@ -183,38 +183,38 @@ discard block |
||
183 | 183 | * @since 1.0.15 |
184 | 184 | * @return int |
185 | 185 | */ |
186 | - public static function get_invoice_id_by_field( $value, $field = 'key' ) { |
|
186 | + public static function get_invoice_id_by_field($value, $field = 'key') { |
|
187 | 187 | global $wpdb; |
188 | 188 | |
189 | 189 | // Trim the value. |
190 | - $value = trim( $value ); |
|
190 | + $value = trim($value); |
|
191 | 191 | |
192 | - if ( empty( $value ) ) { |
|
192 | + if (empty($value)) { |
|
193 | 193 | return 0; |
194 | 194 | } |
195 | 195 | |
196 | 196 | // Valid fields. |
197 | - $fields = array( 'key', 'number', 'transaction_id' ); |
|
197 | + $fields = array('key', 'number', 'transaction_id'); |
|
198 | 198 | |
199 | 199 | // Ensure a field has been passed. |
200 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
200 | + if (empty($field) || !in_array($field, $fields)) { |
|
201 | 201 | return 0; |
202 | 202 | } |
203 | 203 | |
204 | 204 | // Maybe retrieve from the cache. |
205 | - $invoice_id = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
206 | - if ( false !== $invoice_id ) { |
|
205 | + $invoice_id = wp_cache_get($value, "getpaid_invoice_{$field}s_to_invoice_ids"); |
|
206 | + if (false !== $invoice_id) { |
|
207 | 207 | return $invoice_id; |
208 | 208 | } |
209 | 209 | |
210 | 210 | // Fetch from the db. |
211 | 211 | $table = $wpdb->prefix . 'getpaid_invoices'; |
212 | 212 | $invoice_id = (int) $wpdb->get_var( |
213 | - $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value ) |
|
213 | + $wpdb->prepare("SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value) |
|
214 | 214 | ); |
215 | 215 | |
216 | 216 | // Update the cache with our data |
217 | - wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
217 | + wp_cache_set($value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids"); |
|
218 | 218 | |
219 | 219 | return $invoice_id; |
220 | 220 | } |
@@ -222,8 +222,8 @@ discard block |
||
222 | 222 | /** |
223 | 223 | * Checks if an invoice key is set. |
224 | 224 | */ |
225 | - public function _isset( $key ) { |
|
226 | - return isset( $this->data[$key] ) || method_exists( $this, "get_$key" ); |
|
225 | + public function _isset($key) { |
|
226 | + return isset($this->data[$key]) || method_exists($this, "get_$key"); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /* |
@@ -248,8 +248,8 @@ discard block |
||
248 | 248 | * @param string $context View or edit context. |
249 | 249 | * @return int |
250 | 250 | */ |
251 | - public function get_parent_id( $context = 'view' ) { |
|
252 | - return (int) $this->get_prop( 'parent_id', $context ); |
|
251 | + public function get_parent_id($context = 'view') { |
|
252 | + return (int) $this->get_prop('parent_id', $context); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /** |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | * @return WPInv_Invoice |
260 | 260 | */ |
261 | 261 | public function get_parent_payment() { |
262 | - return new WPInv_Invoice( $this->get_parent_id() ); |
|
262 | + return new WPInv_Invoice($this->get_parent_id()); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | /** |
@@ -279,8 +279,8 @@ discard block |
||
279 | 279 | * @param string $context View or edit context. |
280 | 280 | * @return string |
281 | 281 | */ |
282 | - public function get_status( $context = 'view' ) { |
|
283 | - return $this->get_prop( 'status', $context ); |
|
282 | + public function get_status($context = 'view') { |
|
283 | + return $this->get_prop('status', $context); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | /** |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | * @return array |
291 | 291 | */ |
292 | 292 | public function get_all_statuses() { |
293 | - return wpinv_get_invoice_statuses( true, true, $this ); |
|
293 | + return wpinv_get_invoice_statuses(true, true, $this); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | /** |
@@ -302,9 +302,9 @@ discard block |
||
302 | 302 | public function get_status_nicename() { |
303 | 303 | $statuses = $this->get_all_statuses(); |
304 | 304 | |
305 | - $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status(); |
|
305 | + $status = isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : $this->get_status(); |
|
306 | 306 | |
307 | - return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this ); |
|
307 | + return apply_filters('wpinv_get_invoice_status_nicename', $status, $this); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | /** |
@@ -315,8 +315,8 @@ discard block |
||
315 | 315 | */ |
316 | 316 | public function get_status_label_html() { |
317 | 317 | |
318 | - $status_label = sanitize_text_field( $this->get_status_nicename() ); |
|
319 | - $status = sanitize_html_class( $this->get_status() ); |
|
318 | + $status_label = sanitize_text_field($this->get_status_nicename()); |
|
319 | + $status = sanitize_html_class($this->get_status()); |
|
320 | 320 | |
321 | 321 | return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>"; |
322 | 322 | } |
@@ -328,23 +328,23 @@ discard block |
||
328 | 328 | * @param string $context View or edit context. |
329 | 329 | * @return string |
330 | 330 | */ |
331 | - public function get_version( $context = 'view' ) { |
|
332 | - return $this->get_prop( 'version', $context ); |
|
331 | + public function get_version($context = 'view') { |
|
332 | + return $this->get_prop('version', $context); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | /** |
336 | 336 | * @deprecated |
337 | 337 | */ |
338 | - public function get_invoice_date( $format = true ) { |
|
339 | - $date = getpaid_format_date( $this->get_date_completed() ); |
|
340 | - $date = empty( $date ) ? $this->get_date_created() : $this->get_date_completed(); |
|
341 | - $formatted = getpaid_format_date( $date ); |
|
338 | + public function get_invoice_date($format = true) { |
|
339 | + $date = getpaid_format_date($this->get_date_completed()); |
|
340 | + $date = empty($date) ? $this->get_date_created() : $this->get_date_completed(); |
|
341 | + $formatted = getpaid_format_date($date); |
|
342 | 342 | |
343 | - if ( $format ) { |
|
343 | + if ($format) { |
|
344 | 344 | return $formatted; |
345 | 345 | } |
346 | 346 | |
347 | - return empty( $formatted ) ? '' : $date; |
|
347 | + return empty($formatted) ? '' : $date; |
|
348 | 348 | |
349 | 349 | } |
350 | 350 | |
@@ -355,8 +355,8 @@ discard block |
||
355 | 355 | * @param string $context View or edit context. |
356 | 356 | * @return string |
357 | 357 | */ |
358 | - public function get_date_created( $context = 'view' ) { |
|
359 | - return $this->get_prop( 'date_created', $context ); |
|
358 | + public function get_date_created($context = 'view') { |
|
359 | + return $this->get_prop('date_created', $context); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | /** |
@@ -366,8 +366,8 @@ discard block |
||
366 | 366 | * @param string $context View or edit context. |
367 | 367 | * @return string |
368 | 368 | */ |
369 | - public function get_created_date( $context = 'view' ) { |
|
370 | - return $this->get_date_created( $context ); |
|
369 | + public function get_created_date($context = 'view') { |
|
370 | + return $this->get_date_created($context); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | /** |
@@ -377,11 +377,11 @@ discard block |
||
377 | 377 | * @param string $context View or edit context. |
378 | 378 | * @return string |
379 | 379 | */ |
380 | - public function get_date_created_gmt( $context = 'view' ) { |
|
381 | - $date = $this->get_date_created( $context ); |
|
380 | + public function get_date_created_gmt($context = 'view') { |
|
381 | + $date = $this->get_date_created($context); |
|
382 | 382 | |
383 | - if ( $date ) { |
|
384 | - $date = get_gmt_from_date( $date ); |
|
383 | + if ($date) { |
|
384 | + $date = get_gmt_from_date($date); |
|
385 | 385 | } |
386 | 386 | return $date; |
387 | 387 | } |
@@ -393,8 +393,8 @@ discard block |
||
393 | 393 | * @param string $context View or edit context. |
394 | 394 | * @return string |
395 | 395 | */ |
396 | - public function get_date_modified( $context = 'view' ) { |
|
397 | - return $this->get_prop( 'date_modified', $context ); |
|
396 | + public function get_date_modified($context = 'view') { |
|
397 | + return $this->get_prop('date_modified', $context); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | /** |
@@ -404,8 +404,8 @@ discard block |
||
404 | 404 | * @param string $context View or edit context. |
405 | 405 | * @return string |
406 | 406 | */ |
407 | - public function get_modified_date( $context = 'view' ) { |
|
408 | - return $this->get_date_modified( $context ); |
|
407 | + public function get_modified_date($context = 'view') { |
|
408 | + return $this->get_date_modified($context); |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | /** |
@@ -415,11 +415,11 @@ discard block |
||
415 | 415 | * @param string $context View or edit context. |
416 | 416 | * @return string |
417 | 417 | */ |
418 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
419 | - $date = $this->get_date_modified( $context ); |
|
418 | + public function get_date_modified_gmt($context = 'view') { |
|
419 | + $date = $this->get_date_modified($context); |
|
420 | 420 | |
421 | - if ( $date ) { |
|
422 | - $date = get_gmt_from_date( $date ); |
|
421 | + if ($date) { |
|
422 | + $date = get_gmt_from_date($date); |
|
423 | 423 | } |
424 | 424 | return $date; |
425 | 425 | } |
@@ -431,8 +431,8 @@ discard block |
||
431 | 431 | * @param string $context View or edit context. |
432 | 432 | * @return string |
433 | 433 | */ |
434 | - public function get_due_date( $context = 'view' ) { |
|
435 | - return $this->get_prop( 'due_date', $context ); |
|
434 | + public function get_due_date($context = 'view') { |
|
435 | + return $this->get_prop('due_date', $context); |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | /** |
@@ -442,8 +442,8 @@ discard block |
||
442 | 442 | * @param string $context View or edit context. |
443 | 443 | * @return string |
444 | 444 | */ |
445 | - public function get_date_due( $context = 'view' ) { |
|
446 | - return $this->get_due_date( $context ); |
|
445 | + public function get_date_due($context = 'view') { |
|
446 | + return $this->get_due_date($context); |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | /** |
@@ -453,11 +453,11 @@ discard block |
||
453 | 453 | * @param string $context View or edit context. |
454 | 454 | * @return string |
455 | 455 | */ |
456 | - public function get_due_date_gmt( $context = 'view' ) { |
|
457 | - $date = $this->get_due_date( $context ); |
|
456 | + public function get_due_date_gmt($context = 'view') { |
|
457 | + $date = $this->get_due_date($context); |
|
458 | 458 | |
459 | - if ( $date ) { |
|
460 | - $date = get_gmt_from_date( $date ); |
|
459 | + if ($date) { |
|
460 | + $date = get_gmt_from_date($date); |
|
461 | 461 | } |
462 | 462 | return $date; |
463 | 463 | } |
@@ -469,8 +469,8 @@ discard block |
||
469 | 469 | * @param string $context View or edit context. |
470 | 470 | * @return string |
471 | 471 | */ |
472 | - public function get_gmt_date_due( $context = 'view' ) { |
|
473 | - return $this->get_due_date_gmt( $context ); |
|
472 | + public function get_gmt_date_due($context = 'view') { |
|
473 | + return $this->get_due_date_gmt($context); |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | /** |
@@ -480,8 +480,8 @@ discard block |
||
480 | 480 | * @param string $context View or edit context. |
481 | 481 | * @return string |
482 | 482 | */ |
483 | - public function get_completed_date( $context = 'view' ) { |
|
484 | - return $this->get_prop( 'completed_date', $context ); |
|
483 | + public function get_completed_date($context = 'view') { |
|
484 | + return $this->get_prop('completed_date', $context); |
|
485 | 485 | } |
486 | 486 | |
487 | 487 | /** |
@@ -491,8 +491,8 @@ discard block |
||
491 | 491 | * @param string $context View or edit context. |
492 | 492 | * @return string |
493 | 493 | */ |
494 | - public function get_date_completed( $context = 'view' ) { |
|
495 | - return $this->get_completed_date( $context ); |
|
494 | + public function get_date_completed($context = 'view') { |
|
495 | + return $this->get_completed_date($context); |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | /** |
@@ -502,11 +502,11 @@ discard block |
||
502 | 502 | * @param string $context View or edit context. |
503 | 503 | * @return string |
504 | 504 | */ |
505 | - public function get_completed_date_gmt( $context = 'view' ) { |
|
506 | - $date = $this->get_completed_date( $context ); |
|
505 | + public function get_completed_date_gmt($context = 'view') { |
|
506 | + $date = $this->get_completed_date($context); |
|
507 | 507 | |
508 | - if ( $date ) { |
|
509 | - $date = get_gmt_from_date( $date ); |
|
508 | + if ($date) { |
|
509 | + $date = get_gmt_from_date($date); |
|
510 | 510 | } |
511 | 511 | return $date; |
512 | 512 | } |
@@ -518,8 +518,8 @@ discard block |
||
518 | 518 | * @param string $context View or edit context. |
519 | 519 | * @return string |
520 | 520 | */ |
521 | - public function get_gmt_completed_date( $context = 'view' ) { |
|
522 | - return $this->get_completed_date_gmt( $context ); |
|
521 | + public function get_gmt_completed_date($context = 'view') { |
|
522 | + return $this->get_completed_date_gmt($context); |
|
523 | 523 | } |
524 | 524 | |
525 | 525 | /** |
@@ -529,12 +529,12 @@ discard block |
||
529 | 529 | * @param string $context View or edit context. |
530 | 530 | * @return string |
531 | 531 | */ |
532 | - public function get_number( $context = 'view' ) { |
|
533 | - $number = $this->get_prop( 'number', $context ); |
|
532 | + public function get_number($context = 'view') { |
|
533 | + $number = $this->get_prop('number', $context); |
|
534 | 534 | |
535 | - if ( empty( $number ) ) { |
|
535 | + if (empty($number)) { |
|
536 | 536 | $number = $this->generate_number(); |
537 | - $this->set_number( $this->generate_number() ); |
|
537 | + $this->set_number($this->generate_number()); |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | return $number; |
@@ -548,8 +548,8 @@ discard block |
||
548 | 548 | public function maybe_set_number() { |
549 | 549 | $number = $this->get_number(); |
550 | 550 | |
551 | - if ( empty( $number ) || $this->get_id() == $number ) { |
|
552 | - $this->set_number( $this->generate_number() ); |
|
551 | + if (empty($number) || $this->get_id() == $number) { |
|
552 | + $this->set_number($this->generate_number()); |
|
553 | 553 | } |
554 | 554 | |
555 | 555 | } |
@@ -561,8 +561,8 @@ discard block |
||
561 | 561 | * @param string $context View or edit context. |
562 | 562 | * @return string |
563 | 563 | */ |
564 | - public function get_key( $context = 'view' ) { |
|
565 | - return $this->get_prop( 'key', $context ); |
|
564 | + public function get_key($context = 'view') { |
|
565 | + return $this->get_prop('key', $context); |
|
566 | 566 | } |
567 | 567 | |
568 | 568 | /** |
@@ -573,9 +573,9 @@ discard block |
||
573 | 573 | public function maybe_set_key() { |
574 | 574 | $key = $this->get_key(); |
575 | 575 | |
576 | - if ( empty( $key ) ) { |
|
577 | - $key = $this->generate_key( $this->get_type() . '_' ); |
|
578 | - $this->set_key( $key ); |
|
576 | + if (empty($key)) { |
|
577 | + $key = $this->generate_key($this->get_type() . '_'); |
|
578 | + $this->set_key($key); |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | } |
@@ -587,15 +587,15 @@ discard block |
||
587 | 587 | * @param string $context View or edit context. |
588 | 588 | * @return string |
589 | 589 | */ |
590 | - public function get_type( $context = 'view' ) { |
|
591 | - return $this->get_prop( 'type', $context ); |
|
590 | + public function get_type($context = 'view') { |
|
591 | + return $this->get_prop('type', $context); |
|
592 | 592 | } |
593 | 593 | |
594 | 594 | /** |
595 | 595 | * @deprecated |
596 | 596 | */ |
597 | 597 | public function get_invoice_quote_type() { |
598 | - ucfirst( $this->get_type() ); |
|
598 | + ucfirst($this->get_type()); |
|
599 | 599 | } |
600 | 600 | |
601 | 601 | /** |
@@ -605,8 +605,8 @@ discard block |
||
605 | 605 | * @param string $context View or edit context. |
606 | 606 | * @return string |
607 | 607 | */ |
608 | - public function get_post_type( $context = 'view' ) { |
|
609 | - return $this->get_prop( 'post_type', $context ); |
|
608 | + public function get_post_type($context = 'view') { |
|
609 | + return $this->get_prop('post_type', $context); |
|
610 | 610 | } |
611 | 611 | |
612 | 612 | /** |
@@ -616,8 +616,8 @@ discard block |
||
616 | 616 | * @param string $context View or edit context. |
617 | 617 | * @return string |
618 | 618 | */ |
619 | - public function get_mode( $context = 'view' ) { |
|
620 | - return $this->get_prop( 'mode', $context ); |
|
619 | + public function get_mode($context = 'view') { |
|
620 | + return $this->get_prop('mode', $context); |
|
621 | 621 | } |
622 | 622 | |
623 | 623 | /** |
@@ -627,13 +627,13 @@ discard block |
||
627 | 627 | * @param string $context View or edit context. |
628 | 628 | * @return string |
629 | 629 | */ |
630 | - public function get_path( $context = 'view' ) { |
|
631 | - $path = $this->get_prop( 'path', $context ); |
|
630 | + public function get_path($context = 'view') { |
|
631 | + $path = $this->get_prop('path', $context); |
|
632 | 632 | $prefix = $this->get_type(); |
633 | 633 | |
634 | - if ( 0 !== strpos( $path, $prefix ) ) { |
|
635 | - $path = sanitize_title( $prefix . '-' . $this->get_id() ); |
|
636 | - $this->set_path( $path ); |
|
634 | + if (0 !== strpos($path, $prefix)) { |
|
635 | + $path = sanitize_title($prefix . '-' . $this->get_id()); |
|
636 | + $this->set_path($path); |
|
637 | 637 | } |
638 | 638 | |
639 | 639 | return $path; |
@@ -646,8 +646,8 @@ discard block |
||
646 | 646 | * @param string $context View or edit context. |
647 | 647 | * @return string |
648 | 648 | */ |
649 | - public function get_name( $context = 'view' ) { |
|
650 | - return $this->get_prop( 'title', $context ); |
|
649 | + public function get_name($context = 'view') { |
|
650 | + return $this->get_prop('title', $context); |
|
651 | 651 | } |
652 | 652 | |
653 | 653 | /** |
@@ -657,8 +657,8 @@ discard block |
||
657 | 657 | * @param string $context View or edit context. |
658 | 658 | * @return string |
659 | 659 | */ |
660 | - public function get_title( $context = 'view' ) { |
|
661 | - return $this->get_name( $context ); |
|
660 | + public function get_title($context = 'view') { |
|
661 | + return $this->get_name($context); |
|
662 | 662 | } |
663 | 663 | |
664 | 664 | /** |
@@ -668,8 +668,8 @@ discard block |
||
668 | 668 | * @param string $context View or edit context. |
669 | 669 | * @return string |
670 | 670 | */ |
671 | - public function get_description( $context = 'view' ) { |
|
672 | - return $this->get_prop( 'description', $context ); |
|
671 | + public function get_description($context = 'view') { |
|
672 | + return $this->get_prop('description', $context); |
|
673 | 673 | } |
674 | 674 | |
675 | 675 | /** |
@@ -679,8 +679,8 @@ discard block |
||
679 | 679 | * @param string $context View or edit context. |
680 | 680 | * @return string |
681 | 681 | */ |
682 | - public function get_excerpt( $context = 'view' ) { |
|
683 | - return $this->get_description( $context ); |
|
682 | + public function get_excerpt($context = 'view') { |
|
683 | + return $this->get_description($context); |
|
684 | 684 | } |
685 | 685 | |
686 | 686 | /** |
@@ -690,8 +690,8 @@ discard block |
||
690 | 690 | * @param string $context View or edit context. |
691 | 691 | * @return string |
692 | 692 | */ |
693 | - public function get_summary( $context = 'view' ) { |
|
694 | - return $this->get_description( $context ); |
|
693 | + public function get_summary($context = 'view') { |
|
694 | + return $this->get_description($context); |
|
695 | 695 | } |
696 | 696 | |
697 | 697 | /** |
@@ -701,25 +701,25 @@ discard block |
||
701 | 701 | * @param string $context View or edit context. |
702 | 702 | * @return array |
703 | 703 | */ |
704 | - public function get_user_info( $context = 'view' ) { |
|
704 | + public function get_user_info($context = 'view') { |
|
705 | 705 | |
706 | 706 | $user_info = array( |
707 | - 'user_id' => $this->get_user_id( $context ), |
|
708 | - 'email' => $this->get_email( $context ), |
|
709 | - 'first_name' => $this->get_first_name( $context ), |
|
710 | - 'last_name' => $this->get_last_name( $context ), |
|
711 | - 'address' => $this->get_address( $context ), |
|
712 | - 'phone' => $this->get_phone( $context ), |
|
713 | - 'city' => $this->get_city( $context ), |
|
714 | - 'country' => $this->get_country( $context ), |
|
715 | - 'state' => $this->get_state( $context ), |
|
716 | - 'zip' => $this->get_zip( $context ), |
|
717 | - 'company' => $this->get_company( $context ), |
|
718 | - 'vat_number' => $this->get_vat_number( $context ), |
|
719 | - 'discount' => $this->get_discount_code( $context ), |
|
707 | + 'user_id' => $this->get_user_id($context), |
|
708 | + 'email' => $this->get_email($context), |
|
709 | + 'first_name' => $this->get_first_name($context), |
|
710 | + 'last_name' => $this->get_last_name($context), |
|
711 | + 'address' => $this->get_address($context), |
|
712 | + 'phone' => $this->get_phone($context), |
|
713 | + 'city' => $this->get_city($context), |
|
714 | + 'country' => $this->get_country($context), |
|
715 | + 'state' => $this->get_state($context), |
|
716 | + 'zip' => $this->get_zip($context), |
|
717 | + 'company' => $this->get_company($context), |
|
718 | + 'vat_number' => $this->get_vat_number($context), |
|
719 | + 'discount' => $this->get_discount_code($context), |
|
720 | 720 | ); |
721 | 721 | |
722 | - return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this ); |
|
722 | + return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this); |
|
723 | 723 | |
724 | 724 | } |
725 | 725 | |
@@ -730,8 +730,8 @@ discard block |
||
730 | 730 | * @param string $context View or edit context. |
731 | 731 | * @return int |
732 | 732 | */ |
733 | - public function get_author( $context = 'view' ) { |
|
734 | - return (int) $this->get_prop( 'author', $context ); |
|
733 | + public function get_author($context = 'view') { |
|
734 | + return (int) $this->get_prop('author', $context); |
|
735 | 735 | } |
736 | 736 | |
737 | 737 | /** |
@@ -741,8 +741,8 @@ discard block |
||
741 | 741 | * @param string $context View or edit context. |
742 | 742 | * @return int |
743 | 743 | */ |
744 | - public function get_user_id( $context = 'view' ) { |
|
745 | - return $this->get_author( $context ); |
|
744 | + public function get_user_id($context = 'view') { |
|
745 | + return $this->get_author($context); |
|
746 | 746 | } |
747 | 747 | |
748 | 748 | /** |
@@ -752,8 +752,8 @@ discard block |
||
752 | 752 | * @param string $context View or edit context. |
753 | 753 | * @return int |
754 | 754 | */ |
755 | - public function get_customer_id( $context = 'view' ) { |
|
756 | - return $this->get_author( $context ); |
|
755 | + public function get_customer_id($context = 'view') { |
|
756 | + return $this->get_author($context); |
|
757 | 757 | } |
758 | 758 | |
759 | 759 | /** |
@@ -763,8 +763,8 @@ discard block |
||
763 | 763 | * @param string $context View or edit context. |
764 | 764 | * @return string |
765 | 765 | */ |
766 | - public function get_ip( $context = 'view' ) { |
|
767 | - return $this->get_prop( 'user_ip', $context ); |
|
766 | + public function get_ip($context = 'view') { |
|
767 | + return $this->get_prop('user_ip', $context); |
|
768 | 768 | } |
769 | 769 | |
770 | 770 | /** |
@@ -774,8 +774,8 @@ discard block |
||
774 | 774 | * @param string $context View or edit context. |
775 | 775 | * @return string |
776 | 776 | */ |
777 | - public function get_user_ip( $context = 'view' ) { |
|
778 | - return $this->get_ip( $context ); |
|
777 | + public function get_user_ip($context = 'view') { |
|
778 | + return $this->get_ip($context); |
|
779 | 779 | } |
780 | 780 | |
781 | 781 | /** |
@@ -785,8 +785,8 @@ discard block |
||
785 | 785 | * @param string $context View or edit context. |
786 | 786 | * @return string |
787 | 787 | */ |
788 | - public function get_customer_ip( $context = 'view' ) { |
|
789 | - return $this->get_ip( $context ); |
|
788 | + public function get_customer_ip($context = 'view') { |
|
789 | + return $this->get_ip($context); |
|
790 | 790 | } |
791 | 791 | |
792 | 792 | /** |
@@ -796,8 +796,8 @@ discard block |
||
796 | 796 | * @param string $context View or edit context. |
797 | 797 | * @return string |
798 | 798 | */ |
799 | - public function get_first_name( $context = 'view' ) { |
|
800 | - return $this->get_prop( 'first_name', $context ); |
|
799 | + public function get_first_name($context = 'view') { |
|
800 | + return $this->get_prop('first_name', $context); |
|
801 | 801 | } |
802 | 802 | |
803 | 803 | /** |
@@ -807,8 +807,8 @@ discard block |
||
807 | 807 | * @param string $context View or edit context. |
808 | 808 | * @return string |
809 | 809 | */ |
810 | - public function get_user_first_name( $context = 'view' ) { |
|
811 | - return $this->get_first_name( $context ); |
|
810 | + public function get_user_first_name($context = 'view') { |
|
811 | + return $this->get_first_name($context); |
|
812 | 812 | } |
813 | 813 | |
814 | 814 | /** |
@@ -818,8 +818,8 @@ discard block |
||
818 | 818 | * @param string $context View or edit context. |
819 | 819 | * @return string |
820 | 820 | */ |
821 | - public function get_customer_first_name( $context = 'view' ) { |
|
822 | - return $this->get_first_name( $context ); |
|
821 | + public function get_customer_first_name($context = 'view') { |
|
822 | + return $this->get_first_name($context); |
|
823 | 823 | } |
824 | 824 | |
825 | 825 | /** |
@@ -829,8 +829,8 @@ discard block |
||
829 | 829 | * @param string $context View or edit context. |
830 | 830 | * @return string |
831 | 831 | */ |
832 | - public function get_last_name( $context = 'view' ) { |
|
833 | - return $this->get_prop( 'last_name', $context ); |
|
832 | + public function get_last_name($context = 'view') { |
|
833 | + return $this->get_prop('last_name', $context); |
|
834 | 834 | } |
835 | 835 | |
836 | 836 | /** |
@@ -840,8 +840,8 @@ discard block |
||
840 | 840 | * @param string $context View or edit context. |
841 | 841 | * @return string |
842 | 842 | */ |
843 | - public function get_user_last_name( $context = 'view' ) { |
|
844 | - return $this->get_last_name( $context ); |
|
843 | + public function get_user_last_name($context = 'view') { |
|
844 | + return $this->get_last_name($context); |
|
845 | 845 | } |
846 | 846 | |
847 | 847 | /** |
@@ -851,8 +851,8 @@ discard block |
||
851 | 851 | * @param string $context View or edit context. |
852 | 852 | * @return string |
853 | 853 | */ |
854 | - public function get_customer_last_name( $context = 'view' ) { |
|
855 | - return $this->get_last_name( $context ); |
|
854 | + public function get_customer_last_name($context = 'view') { |
|
855 | + return $this->get_last_name($context); |
|
856 | 856 | } |
857 | 857 | |
858 | 858 | /** |
@@ -862,8 +862,8 @@ discard block |
||
862 | 862 | * @param string $context View or edit context. |
863 | 863 | * @return string |
864 | 864 | */ |
865 | - public function get_full_name( $context = 'view' ) { |
|
866 | - return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) ); |
|
865 | + public function get_full_name($context = 'view') { |
|
866 | + return trim($this->get_first_name($context) . ' ' . $this->get_last_name($context)); |
|
867 | 867 | } |
868 | 868 | |
869 | 869 | /** |
@@ -873,8 +873,8 @@ discard block |
||
873 | 873 | * @param string $context View or edit context. |
874 | 874 | * @return string |
875 | 875 | */ |
876 | - public function get_user_full_name( $context = 'view' ) { |
|
877 | - return $this->get_full_name( $context ); |
|
876 | + public function get_user_full_name($context = 'view') { |
|
877 | + return $this->get_full_name($context); |
|
878 | 878 | } |
879 | 879 | |
880 | 880 | /** |
@@ -884,8 +884,8 @@ discard block |
||
884 | 884 | * @param string $context View or edit context. |
885 | 885 | * @return string |
886 | 886 | */ |
887 | - public function get_customer_full_name( $context = 'view' ) { |
|
888 | - return $this->get_full_name( $context ); |
|
887 | + public function get_customer_full_name($context = 'view') { |
|
888 | + return $this->get_full_name($context); |
|
889 | 889 | } |
890 | 890 | |
891 | 891 | /** |
@@ -895,8 +895,8 @@ discard block |
||
895 | 895 | * @param string $context View or edit context. |
896 | 896 | * @return string |
897 | 897 | */ |
898 | - public function get_phone( $context = 'view' ) { |
|
899 | - return $this->get_prop( 'phone', $context ); |
|
898 | + public function get_phone($context = 'view') { |
|
899 | + return $this->get_prop('phone', $context); |
|
900 | 900 | } |
901 | 901 | |
902 | 902 | /** |
@@ -906,8 +906,8 @@ discard block |
||
906 | 906 | * @param string $context View or edit context. |
907 | 907 | * @return string |
908 | 908 | */ |
909 | - public function get_phone_number( $context = 'view' ) { |
|
910 | - return $this->get_phone( $context ); |
|
909 | + public function get_phone_number($context = 'view') { |
|
910 | + return $this->get_phone($context); |
|
911 | 911 | } |
912 | 912 | |
913 | 913 | /** |
@@ -917,8 +917,8 @@ discard block |
||
917 | 917 | * @param string $context View or edit context. |
918 | 918 | * @return string |
919 | 919 | */ |
920 | - public function get_user_phone( $context = 'view' ) { |
|
921 | - return $this->get_phone( $context ); |
|
920 | + public function get_user_phone($context = 'view') { |
|
921 | + return $this->get_phone($context); |
|
922 | 922 | } |
923 | 923 | |
924 | 924 | /** |
@@ -928,8 +928,8 @@ discard block |
||
928 | 928 | * @param string $context View or edit context. |
929 | 929 | * @return string |
930 | 930 | */ |
931 | - public function get_customer_phone( $context = 'view' ) { |
|
932 | - return $this->get_phone( $context ); |
|
931 | + public function get_customer_phone($context = 'view') { |
|
932 | + return $this->get_phone($context); |
|
933 | 933 | } |
934 | 934 | |
935 | 935 | /** |
@@ -939,8 +939,8 @@ discard block |
||
939 | 939 | * @param string $context View or edit context. |
940 | 940 | * @return string |
941 | 941 | */ |
942 | - public function get_email( $context = 'view' ) { |
|
943 | - return $this->get_prop( 'email', $context ); |
|
942 | + public function get_email($context = 'view') { |
|
943 | + return $this->get_prop('email', $context); |
|
944 | 944 | } |
945 | 945 | |
946 | 946 | /** |
@@ -950,8 +950,8 @@ discard block |
||
950 | 950 | * @param string $context View or edit context. |
951 | 951 | * @return string |
952 | 952 | */ |
953 | - public function get_email_address( $context = 'view' ) { |
|
954 | - return $this->get_email( $context ); |
|
953 | + public function get_email_address($context = 'view') { |
|
954 | + return $this->get_email($context); |
|
955 | 955 | } |
956 | 956 | |
957 | 957 | /** |
@@ -961,8 +961,8 @@ discard block |
||
961 | 961 | * @param string $context View or edit context. |
962 | 962 | * @return string |
963 | 963 | */ |
964 | - public function get_user_email( $context = 'view' ) { |
|
965 | - return $this->get_email( $context ); |
|
964 | + public function get_user_email($context = 'view') { |
|
965 | + return $this->get_email($context); |
|
966 | 966 | } |
967 | 967 | |
968 | 968 | /** |
@@ -972,8 +972,8 @@ discard block |
||
972 | 972 | * @param string $context View or edit context. |
973 | 973 | * @return string |
974 | 974 | */ |
975 | - public function get_customer_email( $context = 'view' ) { |
|
976 | - return $this->get_email( $context ); |
|
975 | + public function get_customer_email($context = 'view') { |
|
976 | + return $this->get_email($context); |
|
977 | 977 | } |
978 | 978 | |
979 | 979 | /** |
@@ -983,9 +983,9 @@ discard block |
||
983 | 983 | * @param string $context View or edit context. |
984 | 984 | * @return string |
985 | 985 | */ |
986 | - public function get_country( $context = 'view' ) { |
|
987 | - $country = $this->get_prop( 'country', $context ); |
|
988 | - return empty( $country ) ? wpinv_get_default_country() : $country; |
|
986 | + public function get_country($context = 'view') { |
|
987 | + $country = $this->get_prop('country', $context); |
|
988 | + return empty($country) ? wpinv_get_default_country() : $country; |
|
989 | 989 | } |
990 | 990 | |
991 | 991 | /** |
@@ -995,8 +995,8 @@ discard block |
||
995 | 995 | * @param string $context View or edit context. |
996 | 996 | * @return string |
997 | 997 | */ |
998 | - public function get_user_country( $context = 'view' ) { |
|
999 | - return $this->get_country( $context ); |
|
998 | + public function get_user_country($context = 'view') { |
|
999 | + return $this->get_country($context); |
|
1000 | 1000 | } |
1001 | 1001 | |
1002 | 1002 | /** |
@@ -1006,8 +1006,8 @@ discard block |
||
1006 | 1006 | * @param string $context View or edit context. |
1007 | 1007 | * @return string |
1008 | 1008 | */ |
1009 | - public function get_customer_country( $context = 'view' ) { |
|
1010 | - return $this->get_country( $context ); |
|
1009 | + public function get_customer_country($context = 'view') { |
|
1010 | + return $this->get_country($context); |
|
1011 | 1011 | } |
1012 | 1012 | |
1013 | 1013 | /** |
@@ -1017,9 +1017,9 @@ discard block |
||
1017 | 1017 | * @param string $context View or edit context. |
1018 | 1018 | * @return string |
1019 | 1019 | */ |
1020 | - public function get_state( $context = 'view' ) { |
|
1021 | - $state = $this->get_prop( 'state', $context ); |
|
1022 | - return empty( $state ) ? wpinv_get_default_state() : $state; |
|
1020 | + public function get_state($context = 'view') { |
|
1021 | + $state = $this->get_prop('state', $context); |
|
1022 | + return empty($state) ? wpinv_get_default_state() : $state; |
|
1023 | 1023 | } |
1024 | 1024 | |
1025 | 1025 | /** |
@@ -1029,8 +1029,8 @@ discard block |
||
1029 | 1029 | * @param string $context View or edit context. |
1030 | 1030 | * @return string |
1031 | 1031 | */ |
1032 | - public function get_user_state( $context = 'view' ) { |
|
1033 | - return $this->get_state( $context ); |
|
1032 | + public function get_user_state($context = 'view') { |
|
1033 | + return $this->get_state($context); |
|
1034 | 1034 | } |
1035 | 1035 | |
1036 | 1036 | /** |
@@ -1040,8 +1040,8 @@ discard block |
||
1040 | 1040 | * @param string $context View or edit context. |
1041 | 1041 | * @return string |
1042 | 1042 | */ |
1043 | - public function get_customer_state( $context = 'view' ) { |
|
1044 | - return $this->get_state( $context ); |
|
1043 | + public function get_customer_state($context = 'view') { |
|
1044 | + return $this->get_state($context); |
|
1045 | 1045 | } |
1046 | 1046 | |
1047 | 1047 | /** |
@@ -1051,8 +1051,8 @@ discard block |
||
1051 | 1051 | * @param string $context View or edit context. |
1052 | 1052 | * @return string |
1053 | 1053 | */ |
1054 | - public function get_city( $context = 'view' ) { |
|
1055 | - return $this->get_prop( 'city', $context ); |
|
1054 | + public function get_city($context = 'view') { |
|
1055 | + return $this->get_prop('city', $context); |
|
1056 | 1056 | } |
1057 | 1057 | |
1058 | 1058 | /** |
@@ -1062,8 +1062,8 @@ discard block |
||
1062 | 1062 | * @param string $context View or edit context. |
1063 | 1063 | * @return string |
1064 | 1064 | */ |
1065 | - public function get_user_city( $context = 'view' ) { |
|
1066 | - return $this->get_city( $context ); |
|
1065 | + public function get_user_city($context = 'view') { |
|
1066 | + return $this->get_city($context); |
|
1067 | 1067 | } |
1068 | 1068 | |
1069 | 1069 | /** |
@@ -1073,8 +1073,8 @@ discard block |
||
1073 | 1073 | * @param string $context View or edit context. |
1074 | 1074 | * @return string |
1075 | 1075 | */ |
1076 | - public function get_customer_city( $context = 'view' ) { |
|
1077 | - return $this->get_city( $context ); |
|
1076 | + public function get_customer_city($context = 'view') { |
|
1077 | + return $this->get_city($context); |
|
1078 | 1078 | } |
1079 | 1079 | |
1080 | 1080 | /** |
@@ -1084,8 +1084,8 @@ discard block |
||
1084 | 1084 | * @param string $context View or edit context. |
1085 | 1085 | * @return string |
1086 | 1086 | */ |
1087 | - public function get_zip( $context = 'view' ) { |
|
1088 | - return $this->get_prop( 'zip', $context ); |
|
1087 | + public function get_zip($context = 'view') { |
|
1088 | + return $this->get_prop('zip', $context); |
|
1089 | 1089 | } |
1090 | 1090 | |
1091 | 1091 | /** |
@@ -1095,8 +1095,8 @@ discard block |
||
1095 | 1095 | * @param string $context View or edit context. |
1096 | 1096 | * @return string |
1097 | 1097 | */ |
1098 | - public function get_user_zip( $context = 'view' ) { |
|
1099 | - return $this->get_zip( $context ); |
|
1098 | + public function get_user_zip($context = 'view') { |
|
1099 | + return $this->get_zip($context); |
|
1100 | 1100 | } |
1101 | 1101 | |
1102 | 1102 | /** |
@@ -1106,8 +1106,8 @@ discard block |
||
1106 | 1106 | * @param string $context View or edit context. |
1107 | 1107 | * @return string |
1108 | 1108 | */ |
1109 | - public function get_customer_zip( $context = 'view' ) { |
|
1110 | - return $this->get_zip( $context ); |
|
1109 | + public function get_customer_zip($context = 'view') { |
|
1110 | + return $this->get_zip($context); |
|
1111 | 1111 | } |
1112 | 1112 | |
1113 | 1113 | /** |
@@ -1117,8 +1117,8 @@ discard block |
||
1117 | 1117 | * @param string $context View or edit context. |
1118 | 1118 | * @return string |
1119 | 1119 | */ |
1120 | - public function get_company( $context = 'view' ) { |
|
1121 | - return $this->get_prop( 'company', $context ); |
|
1120 | + public function get_company($context = 'view') { |
|
1121 | + return $this->get_prop('company', $context); |
|
1122 | 1122 | } |
1123 | 1123 | |
1124 | 1124 | /** |
@@ -1128,8 +1128,8 @@ discard block |
||
1128 | 1128 | * @param string $context View or edit context. |
1129 | 1129 | * @return string |
1130 | 1130 | */ |
1131 | - public function get_user_company( $context = 'view' ) { |
|
1132 | - return $this->get_company( $context ); |
|
1131 | + public function get_user_company($context = 'view') { |
|
1132 | + return $this->get_company($context); |
|
1133 | 1133 | } |
1134 | 1134 | |
1135 | 1135 | /** |
@@ -1139,8 +1139,8 @@ discard block |
||
1139 | 1139 | * @param string $context View or edit context. |
1140 | 1140 | * @return string |
1141 | 1141 | */ |
1142 | - public function get_customer_company( $context = 'view' ) { |
|
1143 | - return $this->get_company( $context ); |
|
1142 | + public function get_customer_company($context = 'view') { |
|
1143 | + return $this->get_company($context); |
|
1144 | 1144 | } |
1145 | 1145 | |
1146 | 1146 | /** |
@@ -1150,8 +1150,8 @@ discard block |
||
1150 | 1150 | * @param string $context View or edit context. |
1151 | 1151 | * @return string |
1152 | 1152 | */ |
1153 | - public function get_vat_number( $context = 'view' ) { |
|
1154 | - return $this->get_prop( 'vat_number', $context ); |
|
1153 | + public function get_vat_number($context = 'view') { |
|
1154 | + return $this->get_prop('vat_number', $context); |
|
1155 | 1155 | } |
1156 | 1156 | |
1157 | 1157 | /** |
@@ -1161,8 +1161,8 @@ discard block |
||
1161 | 1161 | * @param string $context View or edit context. |
1162 | 1162 | * @return string |
1163 | 1163 | */ |
1164 | - public function get_user_vat_number( $context = 'view' ) { |
|
1165 | - return $this->get_vat_number( $context ); |
|
1164 | + public function get_user_vat_number($context = 'view') { |
|
1165 | + return $this->get_vat_number($context); |
|
1166 | 1166 | } |
1167 | 1167 | |
1168 | 1168 | /** |
@@ -1172,8 +1172,8 @@ discard block |
||
1172 | 1172 | * @param string $context View or edit context. |
1173 | 1173 | * @return string |
1174 | 1174 | */ |
1175 | - public function get_customer_vat_number( $context = 'view' ) { |
|
1176 | - return $this->get_vat_number( $context ); |
|
1175 | + public function get_customer_vat_number($context = 'view') { |
|
1176 | + return $this->get_vat_number($context); |
|
1177 | 1177 | } |
1178 | 1178 | |
1179 | 1179 | /** |
@@ -1183,8 +1183,8 @@ discard block |
||
1183 | 1183 | * @param string $context View or edit context. |
1184 | 1184 | * @return string |
1185 | 1185 | */ |
1186 | - public function get_vat_rate( $context = 'view' ) { |
|
1187 | - return $this->get_prop( 'vat_rate', $context ); |
|
1186 | + public function get_vat_rate($context = 'view') { |
|
1187 | + return $this->get_prop('vat_rate', $context); |
|
1188 | 1188 | } |
1189 | 1189 | |
1190 | 1190 | /** |
@@ -1194,8 +1194,8 @@ discard block |
||
1194 | 1194 | * @param string $context View or edit context. |
1195 | 1195 | * @return string |
1196 | 1196 | */ |
1197 | - public function get_user_vat_rate( $context = 'view' ) { |
|
1198 | - return $this->get_vat_rate( $context ); |
|
1197 | + public function get_user_vat_rate($context = 'view') { |
|
1198 | + return $this->get_vat_rate($context); |
|
1199 | 1199 | } |
1200 | 1200 | |
1201 | 1201 | /** |
@@ -1205,8 +1205,8 @@ discard block |
||
1205 | 1205 | * @param string $context View or edit context. |
1206 | 1206 | * @return string |
1207 | 1207 | */ |
1208 | - public function get_customer_vat_rate( $context = 'view' ) { |
|
1209 | - return $this->get_vat_rate( $context ); |
|
1208 | + public function get_customer_vat_rate($context = 'view') { |
|
1209 | + return $this->get_vat_rate($context); |
|
1210 | 1210 | } |
1211 | 1211 | |
1212 | 1212 | /** |
@@ -1216,8 +1216,8 @@ discard block |
||
1216 | 1216 | * @param string $context View or edit context. |
1217 | 1217 | * @return string |
1218 | 1218 | */ |
1219 | - public function get_address( $context = 'view' ) { |
|
1220 | - return $this->get_prop( 'address', $context ); |
|
1219 | + public function get_address($context = 'view') { |
|
1220 | + return $this->get_prop('address', $context); |
|
1221 | 1221 | } |
1222 | 1222 | |
1223 | 1223 | /** |
@@ -1227,8 +1227,8 @@ discard block |
||
1227 | 1227 | * @param string $context View or edit context. |
1228 | 1228 | * @return string |
1229 | 1229 | */ |
1230 | - public function get_user_address( $context = 'view' ) { |
|
1231 | - return $this->get_address( $context ); |
|
1230 | + public function get_user_address($context = 'view') { |
|
1231 | + return $this->get_address($context); |
|
1232 | 1232 | } |
1233 | 1233 | |
1234 | 1234 | /** |
@@ -1238,8 +1238,8 @@ discard block |
||
1238 | 1238 | * @param string $context View or edit context. |
1239 | 1239 | * @return string |
1240 | 1240 | */ |
1241 | - public function get_customer_address( $context = 'view' ) { |
|
1242 | - return $this->get_address( $context ); |
|
1241 | + public function get_customer_address($context = 'view') { |
|
1242 | + return $this->get_address($context); |
|
1243 | 1243 | } |
1244 | 1244 | |
1245 | 1245 | /** |
@@ -1249,8 +1249,8 @@ discard block |
||
1249 | 1249 | * @param string $context View or edit context. |
1250 | 1250 | * @return bool |
1251 | 1251 | */ |
1252 | - public function get_is_viewed( $context = 'view' ) { |
|
1253 | - return (bool) $this->get_prop( 'is_viewed', $context ); |
|
1252 | + public function get_is_viewed($context = 'view') { |
|
1253 | + return (bool) $this->get_prop('is_viewed', $context); |
|
1254 | 1254 | } |
1255 | 1255 | |
1256 | 1256 | /** |
@@ -1260,8 +1260,8 @@ discard block |
||
1260 | 1260 | * @param string $context View or edit context. |
1261 | 1261 | * @return bool |
1262 | 1262 | */ |
1263 | - public function get_email_cc( $context = 'view' ) { |
|
1264 | - return $this->get_prop( 'email_cc', $context ); |
|
1263 | + public function get_email_cc($context = 'view') { |
|
1264 | + return $this->get_prop('email_cc', $context); |
|
1265 | 1265 | } |
1266 | 1266 | |
1267 | 1267 | /** |
@@ -1271,8 +1271,8 @@ discard block |
||
1271 | 1271 | * @param string $context View or edit context. |
1272 | 1272 | * @return bool |
1273 | 1273 | */ |
1274 | - public function get_template( $context = 'view' ) { |
|
1275 | - return $this->get_prop( 'template', $context ); |
|
1274 | + public function get_template($context = 'view') { |
|
1275 | + return $this->get_prop('template', $context); |
|
1276 | 1276 | } |
1277 | 1277 | |
1278 | 1278 | /** |
@@ -1282,8 +1282,8 @@ discard block |
||
1282 | 1282 | * @param string $context View or edit context. |
1283 | 1283 | * @return bool |
1284 | 1284 | */ |
1285 | - public function get_created_via( $context = 'view' ) { |
|
1286 | - return $this->get_prop( 'created_via', $context ); |
|
1285 | + public function get_created_via($context = 'view') { |
|
1286 | + return $this->get_prop('created_via', $context); |
|
1287 | 1287 | } |
1288 | 1288 | |
1289 | 1289 | /** |
@@ -1293,8 +1293,8 @@ discard block |
||
1293 | 1293 | * @param string $context View or edit context. |
1294 | 1294 | * @return bool |
1295 | 1295 | */ |
1296 | - public function get_address_confirmed( $context = 'view' ) { |
|
1297 | - return (bool) $this->get_prop( 'address_confirmed', $context ); |
|
1296 | + public function get_address_confirmed($context = 'view') { |
|
1297 | + return (bool) $this->get_prop('address_confirmed', $context); |
|
1298 | 1298 | } |
1299 | 1299 | |
1300 | 1300 | /** |
@@ -1304,8 +1304,8 @@ discard block |
||
1304 | 1304 | * @param string $context View or edit context. |
1305 | 1305 | * @return bool |
1306 | 1306 | */ |
1307 | - public function get_user_address_confirmed( $context = 'view' ) { |
|
1308 | - return $this->get_address_confirmed( $context ); |
|
1307 | + public function get_user_address_confirmed($context = 'view') { |
|
1308 | + return $this->get_address_confirmed($context); |
|
1309 | 1309 | } |
1310 | 1310 | |
1311 | 1311 | /** |
@@ -1315,8 +1315,8 @@ discard block |
||
1315 | 1315 | * @param string $context View or edit context. |
1316 | 1316 | * @return bool |
1317 | 1317 | */ |
1318 | - public function get_customer_address_confirmed( $context = 'view' ) { |
|
1319 | - return $this->get_address_confirmed( $context ); |
|
1318 | + public function get_customer_address_confirmed($context = 'view') { |
|
1319 | + return $this->get_address_confirmed($context); |
|
1320 | 1320 | } |
1321 | 1321 | |
1322 | 1322 | /** |
@@ -1326,12 +1326,12 @@ discard block |
||
1326 | 1326 | * @param string $context View or edit context. |
1327 | 1327 | * @return float |
1328 | 1328 | */ |
1329 | - public function get_subtotal( $context = 'view' ) { |
|
1330 | - $subtotal = (float) $this->get_prop( 'subtotal', $context ); |
|
1329 | + public function get_subtotal($context = 'view') { |
|
1330 | + $subtotal = (float) $this->get_prop('subtotal', $context); |
|
1331 | 1331 | |
1332 | 1332 | // Backwards compatibility. |
1333 | - if ( is_bool( $context ) && $context ) { |
|
1334 | - return wpinv_price( wpinv_format_amount( $subtotal ), $this->get_currency() ); |
|
1333 | + if (is_bool($context) && $context) { |
|
1334 | + return wpinv_price(wpinv_format_amount($subtotal), $this->get_currency()); |
|
1335 | 1335 | } |
1336 | 1336 | |
1337 | 1337 | return $subtotal; |
@@ -1344,8 +1344,8 @@ discard block |
||
1344 | 1344 | * @param string $context View or edit context. |
1345 | 1345 | * @return float |
1346 | 1346 | */ |
1347 | - public function get_total_discount( $context = 'view' ) { |
|
1348 | - return (float) $this->get_prop( 'total_discount', $context ); |
|
1347 | + public function get_total_discount($context = 'view') { |
|
1348 | + return (float) $this->get_prop('total_discount', $context); |
|
1349 | 1349 | } |
1350 | 1350 | |
1351 | 1351 | /** |
@@ -1355,18 +1355,18 @@ discard block |
||
1355 | 1355 | * @param string $context View or edit context. |
1356 | 1356 | * @return float |
1357 | 1357 | */ |
1358 | - public function get_total_tax( $context = 'view' ) { |
|
1359 | - return (float) $this->get_prop( 'total_tax', $context ); |
|
1358 | + public function get_total_tax($context = 'view') { |
|
1359 | + return (float) $this->get_prop('total_tax', $context); |
|
1360 | 1360 | } |
1361 | 1361 | |
1362 | 1362 | /** |
1363 | 1363 | * @deprecated |
1364 | 1364 | */ |
1365 | - public function get_final_tax( $currency = false ) { |
|
1365 | + public function get_final_tax($currency = false) { |
|
1366 | 1366 | $tax = $this->get_total_tax(); |
1367 | 1367 | |
1368 | - if ( $currency ) { |
|
1369 | - return wpinv_price( $tax, $this->get_currency() ); |
|
1368 | + if ($currency) { |
|
1369 | + return wpinv_price($tax, $this->get_currency()); |
|
1370 | 1370 | } |
1371 | 1371 | |
1372 | 1372 | return $tax; |
@@ -1379,8 +1379,8 @@ discard block |
||
1379 | 1379 | * @param string $context View or edit context. |
1380 | 1380 | * @return float |
1381 | 1381 | */ |
1382 | - public function get_total_fees( $context = 'view' ) { |
|
1383 | - return (float) $this->get_prop( 'total_fees', $context ); |
|
1382 | + public function get_total_fees($context = 'view') { |
|
1383 | + return (float) $this->get_prop('total_fees', $context); |
|
1384 | 1384 | } |
1385 | 1385 | |
1386 | 1386 | /** |
@@ -1390,8 +1390,8 @@ discard block |
||
1390 | 1390 | * @param string $context View or edit context. |
1391 | 1391 | * @return float |
1392 | 1392 | */ |
1393 | - public function get_fees_total( $context = 'view' ) { |
|
1394 | - return $this->get_total_fees( $context ); |
|
1393 | + public function get_fees_total($context = 'view') { |
|
1394 | + return $this->get_total_fees($context); |
|
1395 | 1395 | } |
1396 | 1396 | |
1397 | 1397 | /** |
@@ -1402,7 +1402,7 @@ discard block |
||
1402 | 1402 | */ |
1403 | 1403 | public function get_total() { |
1404 | 1404 | $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total(); |
1405 | - return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this ); |
|
1405 | + return apply_filters('getpaid_get_invoice_total_amount', $total, $this); |
|
1406 | 1406 | } |
1407 | 1407 | |
1408 | 1408 | /** |
@@ -1424,7 +1424,7 @@ discard block |
||
1424 | 1424 | */ |
1425 | 1425 | public function get_initial_total() { |
1426 | 1426 | |
1427 | - if ( empty( $this->totals ) ) { |
|
1427 | + if (empty($this->totals)) { |
|
1428 | 1428 | $this->recalculate_total(); |
1429 | 1429 | } |
1430 | 1430 | |
@@ -1434,11 +1434,11 @@ discard block |
||
1434 | 1434 | $subtotal = $this->totals['subtotal']['initial']; |
1435 | 1435 | $total = $tax + $fee - $discount + $subtotal; |
1436 | 1436 | |
1437 | - if ( 0 > $total ) { |
|
1437 | + if (0 > $total) { |
|
1438 | 1438 | $total = 0; |
1439 | 1439 | } |
1440 | 1440 | |
1441 | - return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this ); |
|
1441 | + return apply_filters('wpinv_get_initial_invoice_total', $total, $this); |
|
1442 | 1442 | } |
1443 | 1443 | |
1444 | 1444 | /** |
@@ -1450,7 +1450,7 @@ discard block |
||
1450 | 1450 | */ |
1451 | 1451 | public function get_recurring_total() { |
1452 | 1452 | |
1453 | - if ( empty( $this->totals ) ) { |
|
1453 | + if (empty($this->totals)) { |
|
1454 | 1454 | $this->recalculate_total(); |
1455 | 1455 | } |
1456 | 1456 | |
@@ -1460,11 +1460,11 @@ discard block |
||
1460 | 1460 | $subtotal = $this->totals['subtotal']['recurring']; |
1461 | 1461 | $total = $tax + $fee - $discount + $subtotal; |
1462 | 1462 | |
1463 | - if ( 0 > $total ) { |
|
1463 | + if (0 > $total) { |
|
1464 | 1464 | $total = 0; |
1465 | 1465 | } |
1466 | 1466 | |
1467 | - return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this ); |
|
1467 | + return apply_filters('wpinv_get_recurring_invoice_total', $total, $this); |
|
1468 | 1468 | } |
1469 | 1469 | |
1470 | 1470 | /** |
@@ -1475,10 +1475,10 @@ discard block |
||
1475 | 1475 | * @param string $currency Whether to include the currency. |
1476 | 1476 | * @return float|string |
1477 | 1477 | */ |
1478 | - public function get_recurring_details( $field = '', $currency = false ) { |
|
1478 | + public function get_recurring_details($field = '', $currency = false) { |
|
1479 | 1479 | |
1480 | 1480 | // Maybe recalculate totals. |
1481 | - if ( empty( $this->totals ) ) { |
|
1481 | + if (empty($this->totals)) { |
|
1482 | 1482 | $this->recalculate_total(); |
1483 | 1483 | } |
1484 | 1484 | |
@@ -1498,8 +1498,8 @@ discard block |
||
1498 | 1498 | $currency |
1499 | 1499 | ); |
1500 | 1500 | |
1501 | - if ( isset( $data[$field] ) ) { |
|
1502 | - return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] ); |
|
1501 | + if (isset($data[$field])) { |
|
1502 | + return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]); |
|
1503 | 1503 | } |
1504 | 1504 | |
1505 | 1505 | return $data; |
@@ -1512,8 +1512,8 @@ discard block |
||
1512 | 1512 | * @param string $context View or edit context. |
1513 | 1513 | * @return array |
1514 | 1514 | */ |
1515 | - public function get_fees( $context = 'view' ) { |
|
1516 | - return wpinv_parse_list( $this->get_prop( 'fees', $context ) ); |
|
1515 | + public function get_fees($context = 'view') { |
|
1516 | + return wpinv_parse_list($this->get_prop('fees', $context)); |
|
1517 | 1517 | } |
1518 | 1518 | |
1519 | 1519 | /** |
@@ -1523,8 +1523,8 @@ discard block |
||
1523 | 1523 | * @param string $context View or edit context. |
1524 | 1524 | * @return array |
1525 | 1525 | */ |
1526 | - public function get_discounts( $context = 'view' ) { |
|
1527 | - return wpinv_parse_list( $this->get_prop( 'discounts', $context ) ); |
|
1526 | + public function get_discounts($context = 'view') { |
|
1527 | + return wpinv_parse_list($this->get_prop('discounts', $context)); |
|
1528 | 1528 | } |
1529 | 1529 | |
1530 | 1530 | /** |
@@ -1534,8 +1534,8 @@ discard block |
||
1534 | 1534 | * @param string $context View or edit context. |
1535 | 1535 | * @return array |
1536 | 1536 | */ |
1537 | - public function get_taxes( $context = 'view' ) { |
|
1538 | - return wpinv_parse_list( $this->get_prop( 'taxes', $context ) ); |
|
1537 | + public function get_taxes($context = 'view') { |
|
1538 | + return wpinv_parse_list($this->get_prop('taxes', $context)); |
|
1539 | 1539 | } |
1540 | 1540 | |
1541 | 1541 | /** |
@@ -1545,8 +1545,8 @@ discard block |
||
1545 | 1545 | * @param string $context View or edit context. |
1546 | 1546 | * @return GetPaid_Form_Item[] |
1547 | 1547 | */ |
1548 | - public function get_items( $context = 'view' ) { |
|
1549 | - return $this->get_prop( 'items', $context ); |
|
1548 | + public function get_items($context = 'view') { |
|
1549 | + return $this->get_prop('items', $context); |
|
1550 | 1550 | } |
1551 | 1551 | |
1552 | 1552 | /** |
@@ -1556,8 +1556,8 @@ discard block |
||
1556 | 1556 | * @param string $context View or edit context. |
1557 | 1557 | * @return int |
1558 | 1558 | */ |
1559 | - public function get_payment_form( $context = 'view' ) { |
|
1560 | - return intval( $this->get_prop( 'payment_form', $context ) ); |
|
1559 | + public function get_payment_form($context = 'view') { |
|
1560 | + return intval($this->get_prop('payment_form', $context)); |
|
1561 | 1561 | } |
1562 | 1562 | |
1563 | 1563 | /** |
@@ -1567,8 +1567,8 @@ discard block |
||
1567 | 1567 | * @param string $context View or edit context. |
1568 | 1568 | * @return string |
1569 | 1569 | */ |
1570 | - public function get_submission_id( $context = 'view' ) { |
|
1571 | - return $this->get_prop( 'submission_id', $context ); |
|
1570 | + public function get_submission_id($context = 'view') { |
|
1571 | + return $this->get_prop('submission_id', $context); |
|
1572 | 1572 | } |
1573 | 1573 | |
1574 | 1574 | /** |
@@ -1578,8 +1578,8 @@ discard block |
||
1578 | 1578 | * @param string $context View or edit context. |
1579 | 1579 | * @return string |
1580 | 1580 | */ |
1581 | - public function get_discount_code( $context = 'view' ) { |
|
1582 | - return $this->get_prop( 'discount_code', $context ); |
|
1581 | + public function get_discount_code($context = 'view') { |
|
1582 | + return $this->get_prop('discount_code', $context); |
|
1583 | 1583 | } |
1584 | 1584 | |
1585 | 1585 | /** |
@@ -1589,8 +1589,8 @@ discard block |
||
1589 | 1589 | * @param string $context View or edit context. |
1590 | 1590 | * @return string |
1591 | 1591 | */ |
1592 | - public function get_gateway( $context = 'view' ) { |
|
1593 | - return $this->get_prop( 'gateway', $context ); |
|
1592 | + public function get_gateway($context = 'view') { |
|
1593 | + return $this->get_prop('gateway', $context); |
|
1594 | 1594 | } |
1595 | 1595 | |
1596 | 1596 | /** |
@@ -1600,8 +1600,8 @@ discard block |
||
1600 | 1600 | * @return string |
1601 | 1601 | */ |
1602 | 1602 | public function get_gateway_title() { |
1603 | - $title = wpinv_get_gateway_checkout_label( $this->get_gateway() ); |
|
1604 | - return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this ); |
|
1603 | + $title = wpinv_get_gateway_checkout_label($this->get_gateway()); |
|
1604 | + return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this); |
|
1605 | 1605 | } |
1606 | 1606 | |
1607 | 1607 | /** |
@@ -1611,8 +1611,8 @@ discard block |
||
1611 | 1611 | * @param string $context View or edit context. |
1612 | 1612 | * @return string |
1613 | 1613 | */ |
1614 | - public function get_transaction_id( $context = 'view' ) { |
|
1615 | - return $this->get_prop( 'transaction_id', $context ); |
|
1614 | + public function get_transaction_id($context = 'view') { |
|
1615 | + return $this->get_prop('transaction_id', $context); |
|
1616 | 1616 | } |
1617 | 1617 | |
1618 | 1618 | /** |
@@ -1622,9 +1622,9 @@ discard block |
||
1622 | 1622 | * @param string $context View or edit context. |
1623 | 1623 | * @return string |
1624 | 1624 | */ |
1625 | - public function get_currency( $context = 'view' ) { |
|
1626 | - $currency = $this->get_prop( 'currency', $context ); |
|
1627 | - return empty( $currency ) ? wpinv_get_currency() : $currency; |
|
1625 | + public function get_currency($context = 'view') { |
|
1626 | + $currency = $this->get_prop('currency', $context); |
|
1627 | + return empty($currency) ? wpinv_get_currency() : $currency; |
|
1628 | 1628 | } |
1629 | 1629 | |
1630 | 1630 | /** |
@@ -1634,8 +1634,8 @@ discard block |
||
1634 | 1634 | * @param string $context View or edit context. |
1635 | 1635 | * @return bool |
1636 | 1636 | */ |
1637 | - public function get_disable_taxes( $context = 'view' ) { |
|
1638 | - return (bool) $this->get_prop( 'disable_taxes', $context ); |
|
1637 | + public function get_disable_taxes($context = 'view') { |
|
1638 | + return (bool) $this->get_prop('disable_taxes', $context); |
|
1639 | 1639 | } |
1640 | 1640 | |
1641 | 1641 | /** |
@@ -1645,8 +1645,8 @@ discard block |
||
1645 | 1645 | * @param string $context View or edit context. |
1646 | 1646 | * @return int |
1647 | 1647 | */ |
1648 | - public function get_subscription_id( $context = 'view' ) { |
|
1649 | - return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context ); |
|
1648 | + public function get_subscription_id($context = 'view') { |
|
1649 | + return $this->is_renewal() ? $this->get_parent()->get_subscription_id($context) : $this->get_prop('subscription_id', $context); |
|
1650 | 1650 | } |
1651 | 1651 | |
1652 | 1652 | /** |
@@ -1656,12 +1656,12 @@ discard block |
||
1656 | 1656 | * @param string $context View or edit context. |
1657 | 1657 | * @return int |
1658 | 1658 | */ |
1659 | - public function get_remote_subscription_id( $context = 'view' ) { |
|
1660 | - $subscription_id = $this->get_prop( 'remote_subscription_id', $context ); |
|
1659 | + public function get_remote_subscription_id($context = 'view') { |
|
1660 | + $subscription_id = $this->get_prop('remote_subscription_id', $context); |
|
1661 | 1661 | |
1662 | - if ( empty( $subscription_id ) && $this->is_renewal() ) { |
|
1662 | + if (empty($subscription_id) && $this->is_renewal()) { |
|
1663 | 1663 | $parent = $this->get_parent(); |
1664 | - return $parent->get_subscription_id( $context ); |
|
1664 | + return $parent->get_subscription_id($context); |
|
1665 | 1665 | } |
1666 | 1666 | |
1667 | 1667 | return $subscription_id; |
@@ -1674,20 +1674,20 @@ discard block |
||
1674 | 1674 | * @param string $context View or edit context. |
1675 | 1675 | * @return array |
1676 | 1676 | */ |
1677 | - public function get_payment_meta( $context = 'view' ) { |
|
1677 | + public function get_payment_meta($context = 'view') { |
|
1678 | 1678 | |
1679 | 1679 | return array( |
1680 | - 'price' => $this->get_total( $context ), |
|
1681 | - 'date' => $this->get_date_created( $context ), |
|
1682 | - 'user_email' => $this->get_email( $context ), |
|
1683 | - 'invoice_key' => $this->get_key( $context ), |
|
1684 | - 'currency' => $this->get_currency( $context ), |
|
1685 | - 'items' => $this->get_items( $context ), |
|
1686 | - 'user_info' => $this->get_user_info( $context ), |
|
1680 | + 'price' => $this->get_total($context), |
|
1681 | + 'date' => $this->get_date_created($context), |
|
1682 | + 'user_email' => $this->get_email($context), |
|
1683 | + 'invoice_key' => $this->get_key($context), |
|
1684 | + 'currency' => $this->get_currency($context), |
|
1685 | + 'items' => $this->get_items($context), |
|
1686 | + 'user_info' => $this->get_user_info($context), |
|
1687 | 1687 | 'cart_details' => $this->get_cart_details(), |
1688 | - 'status' => $this->get_status( $context ), |
|
1689 | - 'fees' => $this->get_fees( $context ), |
|
1690 | - 'taxes' => $this->get_taxes( $context ), |
|
1688 | + 'status' => $this->get_status($context), |
|
1689 | + 'fees' => $this->get_fees($context), |
|
1690 | + 'taxes' => $this->get_taxes($context), |
|
1691 | 1691 | ); |
1692 | 1692 | |
1693 | 1693 | } |
@@ -1702,9 +1702,9 @@ discard block |
||
1702 | 1702 | $items = $this->get_items(); |
1703 | 1703 | $cart_details = array(); |
1704 | 1704 | |
1705 | - foreach ( $items as $item_id => $item ) { |
|
1705 | + foreach ($items as $item_id => $item) { |
|
1706 | 1706 | $item->invoice_id = $this->get_id(); |
1707 | - $cart_details[] = $item->prepare_data_for_saving(); |
|
1707 | + $cart_details[] = $item->prepare_data_for_saving(); |
|
1708 | 1708 | } |
1709 | 1709 | |
1710 | 1710 | return $cart_details; |
@@ -1715,11 +1715,11 @@ discard block |
||
1715 | 1715 | * |
1716 | 1716 | * @return null|GetPaid_Form_Item|int |
1717 | 1717 | */ |
1718 | - public function get_recurring( $object = false ) { |
|
1718 | + public function get_recurring($object = false) { |
|
1719 | 1719 | |
1720 | 1720 | // Are we returning an object? |
1721 | - if ( $object ) { |
|
1722 | - return $this->get_item( $this->recurring_item ); |
|
1721 | + if ($object) { |
|
1722 | + return $this->get_item($this->recurring_item); |
|
1723 | 1723 | } |
1724 | 1724 | |
1725 | 1725 | return $this->recurring_item; |
@@ -1734,15 +1734,15 @@ discard block |
||
1734 | 1734 | public function get_subscription_name() { |
1735 | 1735 | |
1736 | 1736 | // Retrieve the recurring name |
1737 | - $item = $this->get_recurring( true ); |
|
1737 | + $item = $this->get_recurring(true); |
|
1738 | 1738 | |
1739 | 1739 | // Abort if it does not exist. |
1740 | - if ( empty( $item ) ) { |
|
1740 | + if (empty($item)) { |
|
1741 | 1741 | return ''; |
1742 | 1742 | } |
1743 | 1743 | |
1744 | 1744 | // Return the item name. |
1745 | - return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this ); |
|
1745 | + return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this); |
|
1746 | 1746 | } |
1747 | 1747 | |
1748 | 1748 | /** |
@@ -1752,9 +1752,9 @@ discard block |
||
1752 | 1752 | * @return string |
1753 | 1753 | */ |
1754 | 1754 | public function get_view_url() { |
1755 | - $invoice_url = get_permalink( $this->get_id() ); |
|
1756 | - $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
1757 | - return apply_filters( 'wpinv_get_view_url', $invoice_url, $this ); |
|
1755 | + $invoice_url = get_permalink($this->get_id()); |
|
1756 | + $invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url); |
|
1757 | + return apply_filters('wpinv_get_view_url', $invoice_url, $this); |
|
1758 | 1758 | } |
1759 | 1759 | |
1760 | 1760 | /** |
@@ -1763,25 +1763,25 @@ discard block |
||
1763 | 1763 | * @since 1.0.19 |
1764 | 1764 | * @return string |
1765 | 1765 | */ |
1766 | - public function get_checkout_payment_url( $deprecated = false, $secret = false ) { |
|
1766 | + public function get_checkout_payment_url($deprecated = false, $secret = false) { |
|
1767 | 1767 | |
1768 | 1768 | // Retrieve the checkout url. |
1769 | 1769 | $pay_url = wpinv_get_checkout_uri(); |
1770 | 1770 | |
1771 | 1771 | // Maybe force ssl. |
1772 | - if ( is_ssl() ) { |
|
1773 | - $pay_url = str_replace( 'http:', 'https:', $pay_url ); |
|
1772 | + if (is_ssl()) { |
|
1773 | + $pay_url = str_replace('http:', 'https:', $pay_url); |
|
1774 | 1774 | } |
1775 | 1775 | |
1776 | 1776 | // Add the invoice key. |
1777 | - $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url ); |
|
1777 | + $pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url); |
|
1778 | 1778 | |
1779 | 1779 | // (Maybe?) add a secret |
1780 | - if ( $secret ) { |
|
1781 | - $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url ); |
|
1780 | + if ($secret) { |
|
1781 | + $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url); |
|
1782 | 1782 | } |
1783 | 1783 | |
1784 | - return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret ); |
|
1784 | + return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret); |
|
1785 | 1785 | } |
1786 | 1786 | |
1787 | 1787 | /** |
@@ -1796,14 +1796,14 @@ discard block |
||
1796 | 1796 | $receipt_url = wpinv_get_success_page_uri(); |
1797 | 1797 | |
1798 | 1798 | // Maybe force ssl. |
1799 | - if ( is_ssl() ) { |
|
1800 | - $receipt_url = str_replace( 'http:', 'https:', $receipt_url ); |
|
1799 | + if (is_ssl()) { |
|
1800 | + $receipt_url = str_replace('http:', 'https:', $receipt_url); |
|
1801 | 1801 | } |
1802 | 1802 | |
1803 | 1803 | // Add the invoice key. |
1804 | - $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url ); |
|
1804 | + $receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url); |
|
1805 | 1805 | |
1806 | - return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this ); |
|
1806 | + return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this); |
|
1807 | 1807 | } |
1808 | 1808 | |
1809 | 1809 | /** |
@@ -1816,7 +1816,7 @@ discard block |
||
1816 | 1816 | |
1817 | 1817 | $type = $this->get_type(); |
1818 | 1818 | $status = "wpi-$type-pending"; |
1819 | - return str_replace( '-invoice', '', $status ); |
|
1819 | + return str_replace('-invoice', '', $status); |
|
1820 | 1820 | |
1821 | 1821 | } |
1822 | 1822 | |
@@ -1830,8 +1830,8 @@ discard block |
||
1830 | 1830 | * @param string $context View or edit context. |
1831 | 1831 | * @return mixed Value of the given invoice property (if set). |
1832 | 1832 | */ |
1833 | - public function get( $key, $context = 'view' ) { |
|
1834 | - return $this->get_prop( $key, $context ); |
|
1833 | + public function get($key, $context = 'view') { |
|
1834 | + return $this->get_prop($key, $context); |
|
1835 | 1835 | } |
1836 | 1836 | |
1837 | 1837 | /* |
@@ -1854,11 +1854,11 @@ discard block |
||
1854 | 1854 | * @param mixed $value new value. |
1855 | 1855 | * @return mixed Value of the given invoice property (if set). |
1856 | 1856 | */ |
1857 | - public function set( $key, $value ) { |
|
1857 | + public function set($key, $value) { |
|
1858 | 1858 | |
1859 | 1859 | $setter = "set_$key"; |
1860 | - if ( is_callable( array( $this, $setter ) ) ) { |
|
1861 | - $this->{$setter}( $value ); |
|
1860 | + if (is_callable(array($this, $setter))) { |
|
1861 | + $this->{$setter}($value); |
|
1862 | 1862 | } |
1863 | 1863 | |
1864 | 1864 | } |
@@ -1872,47 +1872,47 @@ discard block |
||
1872 | 1872 | * @param bool $manual_update Is this a manual status change?. |
1873 | 1873 | * @return array details of change. |
1874 | 1874 | */ |
1875 | - public function set_status( $new_status, $note = '', $manual_update = false ) { |
|
1875 | + public function set_status($new_status, $note = '', $manual_update = false) { |
|
1876 | 1876 | $old_status = $this->get_status(); |
1877 | 1877 | |
1878 | 1878 | $statuses = $this->get_all_statuses(); |
1879 | 1879 | |
1880 | - if ( isset( $statuses[ 'draft' ] ) ) { |
|
1881 | - unset( $statuses[ 'draft' ] ); |
|
1880 | + if (isset($statuses['draft'])) { |
|
1881 | + unset($statuses['draft']); |
|
1882 | 1882 | } |
1883 | 1883 | |
1884 | - $this->set_prop( 'status', $new_status ); |
|
1884 | + $this->set_prop('status', $new_status); |
|
1885 | 1885 | |
1886 | 1886 | // If setting the status, ensure it's set to a valid status. |
1887 | - if ( true === $this->object_read ) { |
|
1887 | + if (true === $this->object_read) { |
|
1888 | 1888 | |
1889 | 1889 | // Only allow valid new status. |
1890 | - if ( ! array_key_exists( $new_status, $statuses ) ) { |
|
1890 | + if (!array_key_exists($new_status, $statuses)) { |
|
1891 | 1891 | $new_status = $this->get_default_status(); |
1892 | 1892 | } |
1893 | 1893 | |
1894 | 1894 | // If the old status is set but unknown (e.g. draft) assume its pending for action usage. |
1895 | - if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) { |
|
1895 | + if ($old_status && !array_key_exists($new_status, $statuses)) { |
|
1896 | 1896 | $old_status = $this->get_default_status(); |
1897 | 1897 | } |
1898 | 1898 | |
1899 | 1899 | // Paid - Renewal (i.e when duplicating a parent invoice ) |
1900 | - if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) { |
|
1900 | + if ($new_status == 'wpi-pending' && $old_status == 'publish' && !$this->get_id()) { |
|
1901 | 1901 | $old_status = 'wpi-pending'; |
1902 | 1902 | } |
1903 | 1903 | |
1904 | 1904 | } |
1905 | 1905 | |
1906 | - if ( true === $this->object_read && $old_status !== $new_status ) { |
|
1906 | + if (true === $this->object_read && $old_status !== $new_status) { |
|
1907 | 1907 | $this->status_transition = array( |
1908 | - 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
1908 | + 'from' => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status, |
|
1909 | 1909 | 'to' => $new_status, |
1910 | 1910 | 'note' => $note, |
1911 | 1911 | 'manual' => (bool) $manual_update, |
1912 | 1912 | ); |
1913 | 1913 | |
1914 | - if ( $manual_update ) { |
|
1915 | - do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status ); |
|
1914 | + if ($manual_update) { |
|
1915 | + do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status); |
|
1916 | 1916 | } |
1917 | 1917 | |
1918 | 1918 | $this->maybe_set_date_paid(); |
@@ -1935,8 +1935,8 @@ discard block |
||
1935 | 1935 | */ |
1936 | 1936 | public function maybe_set_date_paid() { |
1937 | 1937 | |
1938 | - if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) { |
|
1939 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
1938 | + if (!$this->get_date_completed('edit') && $this->is_paid()) { |
|
1939 | + $this->set_date_completed(current_time('mysql')); |
|
1940 | 1940 | } |
1941 | 1941 | } |
1942 | 1942 | |
@@ -1945,11 +1945,11 @@ discard block |
||
1945 | 1945 | * |
1946 | 1946 | * @since 1.0.19 |
1947 | 1947 | */ |
1948 | - public function set_parent_id( $value ) { |
|
1949 | - if ( $value && ( $value === $this->get_id() ) ) { |
|
1948 | + public function set_parent_id($value) { |
|
1949 | + if ($value && ($value === $this->get_id())) { |
|
1950 | 1950 | return; |
1951 | 1951 | } |
1952 | - $this->set_prop( 'parent_id', absint( $value ) ); |
|
1952 | + $this->set_prop('parent_id', absint($value)); |
|
1953 | 1953 | } |
1954 | 1954 | |
1955 | 1955 | /** |
@@ -1957,8 +1957,8 @@ discard block |
||
1957 | 1957 | * |
1958 | 1958 | * @since 1.0.19 |
1959 | 1959 | */ |
1960 | - public function set_version( $value ) { |
|
1961 | - $this->set_prop( 'version', $value ); |
|
1960 | + public function set_version($value) { |
|
1961 | + $this->set_prop('version', $value); |
|
1962 | 1962 | } |
1963 | 1963 | |
1964 | 1964 | /** |
@@ -1968,15 +1968,15 @@ discard block |
||
1968 | 1968 | * @param string $value Value to set. |
1969 | 1969 | * @return bool Whether or not the date was set. |
1970 | 1970 | */ |
1971 | - public function set_date_created( $value ) { |
|
1972 | - $date = strtotime( $value ); |
|
1971 | + public function set_date_created($value) { |
|
1972 | + $date = strtotime($value); |
|
1973 | 1973 | |
1974 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
1975 | - $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) ); |
|
1974 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
1975 | + $this->set_prop('date_created', date('Y-m-d H:i:s', $date)); |
|
1976 | 1976 | return true; |
1977 | 1977 | } |
1978 | 1978 | |
1979 | - $this->set_prop( 'date_created', '' ); |
|
1979 | + $this->set_prop('date_created', ''); |
|
1980 | 1980 | return false; |
1981 | 1981 | |
1982 | 1982 | } |
@@ -1988,15 +1988,15 @@ discard block |
||
1988 | 1988 | * @param string $value Value to set. |
1989 | 1989 | * @return bool Whether or not the date was set. |
1990 | 1990 | */ |
1991 | - public function set_due_date( $value ) { |
|
1992 | - $date = strtotime( $value ); |
|
1991 | + public function set_due_date($value) { |
|
1992 | + $date = strtotime($value); |
|
1993 | 1993 | |
1994 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
1995 | - $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) ); |
|
1994 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
1995 | + $this->set_prop('due_date', date('Y-m-d H:i:s', $date)); |
|
1996 | 1996 | return true; |
1997 | 1997 | } |
1998 | 1998 | |
1999 | - $this->set_prop( 'due_date', '' ); |
|
1999 | + $this->set_prop('due_date', ''); |
|
2000 | 2000 | return false; |
2001 | 2001 | |
2002 | 2002 | } |
@@ -2007,8 +2007,8 @@ discard block |
||
2007 | 2007 | * @since 1.0.19 |
2008 | 2008 | * @param string $value New name. |
2009 | 2009 | */ |
2010 | - public function set_date_due( $value ) { |
|
2011 | - $this->set_due_date( $value ); |
|
2010 | + public function set_date_due($value) { |
|
2011 | + $this->set_due_date($value); |
|
2012 | 2012 | } |
2013 | 2013 | |
2014 | 2014 | /** |
@@ -2018,15 +2018,15 @@ discard block |
||
2018 | 2018 | * @param string $value Value to set. |
2019 | 2019 | * @return bool Whether or not the date was set. |
2020 | 2020 | */ |
2021 | - public function set_completed_date( $value ) { |
|
2022 | - $date = strtotime( $value ); |
|
2021 | + public function set_completed_date($value) { |
|
2022 | + $date = strtotime($value); |
|
2023 | 2023 | |
2024 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
2025 | - $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) ); |
|
2024 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
2025 | + $this->set_prop('completed_date', date('Y-m-d H:i:s', $date)); |
|
2026 | 2026 | return true; |
2027 | 2027 | } |
2028 | 2028 | |
2029 | - $this->set_prop( 'completed_date', '' ); |
|
2029 | + $this->set_prop('completed_date', ''); |
|
2030 | 2030 | return false; |
2031 | 2031 | |
2032 | 2032 | } |
@@ -2037,8 +2037,8 @@ discard block |
||
2037 | 2037 | * @since 1.0.19 |
2038 | 2038 | * @param string $value New name. |
2039 | 2039 | */ |
2040 | - public function set_date_completed( $value ) { |
|
2041 | - $this->set_completed_date( $value ); |
|
2040 | + public function set_date_completed($value) { |
|
2041 | + $this->set_completed_date($value); |
|
2042 | 2042 | } |
2043 | 2043 | |
2044 | 2044 | /** |
@@ -2048,15 +2048,15 @@ discard block |
||
2048 | 2048 | * @param string $value Value to set. |
2049 | 2049 | * @return bool Whether or not the date was set. |
2050 | 2050 | */ |
2051 | - public function set_date_modified( $value ) { |
|
2052 | - $date = strtotime( $value ); |
|
2051 | + public function set_date_modified($value) { |
|
2052 | + $date = strtotime($value); |
|
2053 | 2053 | |
2054 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
2055 | - $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) ); |
|
2054 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
2055 | + $this->set_prop('date_modified', date('Y-m-d H:i:s', $date)); |
|
2056 | 2056 | return true; |
2057 | 2057 | } |
2058 | 2058 | |
2059 | - $this->set_prop( 'date_modified', '' ); |
|
2059 | + $this->set_prop('date_modified', ''); |
|
2060 | 2060 | return false; |
2061 | 2061 | |
2062 | 2062 | } |
@@ -2067,9 +2067,9 @@ discard block |
||
2067 | 2067 | * @since 1.0.19 |
2068 | 2068 | * @param string $value New number. |
2069 | 2069 | */ |
2070 | - public function set_number( $value ) { |
|
2071 | - $number = sanitize_text_field( $value ); |
|
2072 | - $this->set_prop( 'number', $number ); |
|
2070 | + public function set_number($value) { |
|
2071 | + $number = sanitize_text_field($value); |
|
2072 | + $this->set_prop('number', $number); |
|
2073 | 2073 | } |
2074 | 2074 | |
2075 | 2075 | /** |
@@ -2078,9 +2078,9 @@ discard block |
||
2078 | 2078 | * @since 1.0.19 |
2079 | 2079 | * @param string $value Type. |
2080 | 2080 | */ |
2081 | - public function set_type( $value ) { |
|
2082 | - $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) ); |
|
2083 | - $this->set_prop( 'type', $type ); |
|
2081 | + public function set_type($value) { |
|
2082 | + $type = sanitize_text_field(str_replace('wpi_', '', $value)); |
|
2083 | + $this->set_prop('type', $type); |
|
2084 | 2084 | } |
2085 | 2085 | |
2086 | 2086 | /** |
@@ -2089,10 +2089,10 @@ discard block |
||
2089 | 2089 | * @since 1.0.19 |
2090 | 2090 | * @param string $value Post type. |
2091 | 2091 | */ |
2092 | - public function set_post_type( $value ) { |
|
2093 | - if ( getpaid_is_invoice_post_type( $value ) ) { |
|
2094 | - $this->set_type( $value ); |
|
2095 | - $this->set_prop( 'post_type', $value ); |
|
2092 | + public function set_post_type($value) { |
|
2093 | + if (getpaid_is_invoice_post_type($value)) { |
|
2094 | + $this->set_type($value); |
|
2095 | + $this->set_prop('post_type', $value); |
|
2096 | 2096 | } |
2097 | 2097 | } |
2098 | 2098 | |
@@ -2102,9 +2102,9 @@ discard block |
||
2102 | 2102 | * @since 1.0.19 |
2103 | 2103 | * @param string $value New key. |
2104 | 2104 | */ |
2105 | - public function set_key( $value ) { |
|
2106 | - $key = sanitize_text_field( $value ); |
|
2107 | - $this->set_prop( 'key', $key ); |
|
2105 | + public function set_key($value) { |
|
2106 | + $key = sanitize_text_field($value); |
|
2107 | + $this->set_prop('key', $key); |
|
2108 | 2108 | } |
2109 | 2109 | |
2110 | 2110 | /** |
@@ -2113,9 +2113,9 @@ discard block |
||
2113 | 2113 | * @since 1.0.19 |
2114 | 2114 | * @param string $value mode. |
2115 | 2115 | */ |
2116 | - public function set_mode( $value ) { |
|
2117 | - if ( ! in_array( $value, array( 'live', 'test' ) ) ) { |
|
2118 | - $this->set_prop( 'value', $value ); |
|
2116 | + public function set_mode($value) { |
|
2117 | + if (!in_array($value, array('live', 'test'))) { |
|
2118 | + $this->set_prop('value', $value); |
|
2119 | 2119 | } |
2120 | 2120 | } |
2121 | 2121 | |
@@ -2125,8 +2125,8 @@ discard block |
||
2125 | 2125 | * @since 1.0.19 |
2126 | 2126 | * @param string $value path. |
2127 | 2127 | */ |
2128 | - public function set_path( $value ) { |
|
2129 | - $this->set_prop( 'path', $value ); |
|
2128 | + public function set_path($value) { |
|
2129 | + $this->set_prop('path', $value); |
|
2130 | 2130 | } |
2131 | 2131 | |
2132 | 2132 | /** |
@@ -2135,9 +2135,9 @@ discard block |
||
2135 | 2135 | * @since 1.0.19 |
2136 | 2136 | * @param string $value New name. |
2137 | 2137 | */ |
2138 | - public function set_name( $value ) { |
|
2139 | - $name = sanitize_text_field( $value ); |
|
2140 | - $this->set_prop( 'name', $name ); |
|
2138 | + public function set_name($value) { |
|
2139 | + $name = sanitize_text_field($value); |
|
2140 | + $this->set_prop('name', $name); |
|
2141 | 2141 | } |
2142 | 2142 | |
2143 | 2143 | /** |
@@ -2146,8 +2146,8 @@ discard block |
||
2146 | 2146 | * @since 1.0.19 |
2147 | 2147 | * @param string $value New name. |
2148 | 2148 | */ |
2149 | - public function set_title( $value ) { |
|
2150 | - $this->set_name( $value ); |
|
2149 | + public function set_title($value) { |
|
2150 | + $this->set_name($value); |
|
2151 | 2151 | } |
2152 | 2152 | |
2153 | 2153 | /** |
@@ -2156,9 +2156,9 @@ discard block |
||
2156 | 2156 | * @since 1.0.19 |
2157 | 2157 | * @param string $value New description. |
2158 | 2158 | */ |
2159 | - public function set_description( $value ) { |
|
2160 | - $description = wp_kses_post( $value ); |
|
2161 | - $this->set_prop( 'description', $description ); |
|
2159 | + public function set_description($value) { |
|
2160 | + $description = wp_kses_post($value); |
|
2161 | + $this->set_prop('description', $description); |
|
2162 | 2162 | } |
2163 | 2163 | |
2164 | 2164 | /** |
@@ -2167,8 +2167,8 @@ discard block |
||
2167 | 2167 | * @since 1.0.19 |
2168 | 2168 | * @param string $value New description. |
2169 | 2169 | */ |
2170 | - public function set_excerpt( $value ) { |
|
2171 | - $this->set_description( $value ); |
|
2170 | + public function set_excerpt($value) { |
|
2171 | + $this->set_description($value); |
|
2172 | 2172 | } |
2173 | 2173 | |
2174 | 2174 | /** |
@@ -2177,8 +2177,8 @@ discard block |
||
2177 | 2177 | * @since 1.0.19 |
2178 | 2178 | * @param string $value New description. |
2179 | 2179 | */ |
2180 | - public function set_summary( $value ) { |
|
2181 | - $this->set_description( $value ); |
|
2180 | + public function set_summary($value) { |
|
2181 | + $this->set_description($value); |
|
2182 | 2182 | } |
2183 | 2183 | |
2184 | 2184 | /** |
@@ -2187,12 +2187,12 @@ discard block |
||
2187 | 2187 | * @since 1.0.19 |
2188 | 2188 | * @param int $value New author. |
2189 | 2189 | */ |
2190 | - public function set_author( $value ) { |
|
2191 | - $user = get_user_by( 'id', (int) $value ); |
|
2190 | + public function set_author($value) { |
|
2191 | + $user = get_user_by('id', (int) $value); |
|
2192 | 2192 | |
2193 | - if ( $user && $user->ID ) { |
|
2194 | - $this->set_prop( 'author', $user->ID ); |
|
2195 | - $this->set_prop( 'email', $user->user_email ); |
|
2193 | + if ($user && $user->ID) { |
|
2194 | + $this->set_prop('author', $user->ID); |
|
2195 | + $this->set_prop('email', $user->user_email); |
|
2196 | 2196 | } |
2197 | 2197 | |
2198 | 2198 | } |
@@ -2203,8 +2203,8 @@ discard block |
||
2203 | 2203 | * @since 1.0.19 |
2204 | 2204 | * @param int $value New user id. |
2205 | 2205 | */ |
2206 | - public function set_user_id( $value ) { |
|
2207 | - $this->set_author( $value ); |
|
2206 | + public function set_user_id($value) { |
|
2207 | + $this->set_author($value); |
|
2208 | 2208 | } |
2209 | 2209 | |
2210 | 2210 | /** |
@@ -2213,8 +2213,8 @@ discard block |
||
2213 | 2213 | * @since 1.0.19 |
2214 | 2214 | * @param int $value New user id. |
2215 | 2215 | */ |
2216 | - public function set_customer_id( $value ) { |
|
2217 | - $this->set_author( $value ); |
|
2216 | + public function set_customer_id($value) { |
|
2217 | + $this->set_author($value); |
|
2218 | 2218 | } |
2219 | 2219 | |
2220 | 2220 | /** |
@@ -2223,8 +2223,8 @@ discard block |
||
2223 | 2223 | * @since 1.0.19 |
2224 | 2224 | * @param string $value ip address. |
2225 | 2225 | */ |
2226 | - public function set_ip( $value ) { |
|
2227 | - $this->set_prop( 'ip', $value ); |
|
2226 | + public function set_ip($value) { |
|
2227 | + $this->set_prop('ip', $value); |
|
2228 | 2228 | } |
2229 | 2229 | |
2230 | 2230 | /** |
@@ -2233,8 +2233,8 @@ discard block |
||
2233 | 2233 | * @since 1.0.19 |
2234 | 2234 | * @param string $value ip address. |
2235 | 2235 | */ |
2236 | - public function set_user_ip( $value ) { |
|
2237 | - $this->set_ip( $value ); |
|
2236 | + public function set_user_ip($value) { |
|
2237 | + $this->set_ip($value); |
|
2238 | 2238 | } |
2239 | 2239 | |
2240 | 2240 | /** |
@@ -2243,8 +2243,8 @@ discard block |
||
2243 | 2243 | * @since 1.0.19 |
2244 | 2244 | * @param string $value first name. |
2245 | 2245 | */ |
2246 | - public function set_first_name( $value ) { |
|
2247 | - $this->set_prop( 'first_name', $value ); |
|
2246 | + public function set_first_name($value) { |
|
2247 | + $this->set_prop('first_name', $value); |
|
2248 | 2248 | } |
2249 | 2249 | |
2250 | 2250 | /** |
@@ -2253,8 +2253,8 @@ discard block |
||
2253 | 2253 | * @since 1.0.19 |
2254 | 2254 | * @param string $value first name. |
2255 | 2255 | */ |
2256 | - public function set_user_first_name( $value ) { |
|
2257 | - $this->set_first_name( $value ); |
|
2256 | + public function set_user_first_name($value) { |
|
2257 | + $this->set_first_name($value); |
|
2258 | 2258 | } |
2259 | 2259 | |
2260 | 2260 | /** |
@@ -2263,8 +2263,8 @@ discard block |
||
2263 | 2263 | * @since 1.0.19 |
2264 | 2264 | * @param string $value first name. |
2265 | 2265 | */ |
2266 | - public function set_customer_first_name( $value ) { |
|
2267 | - $this->set_first_name( $value ); |
|
2266 | + public function set_customer_first_name($value) { |
|
2267 | + $this->set_first_name($value); |
|
2268 | 2268 | } |
2269 | 2269 | |
2270 | 2270 | /** |
@@ -2273,8 +2273,8 @@ discard block |
||
2273 | 2273 | * @since 1.0.19 |
2274 | 2274 | * @param string $value last name. |
2275 | 2275 | */ |
2276 | - public function set_last_name( $value ) { |
|
2277 | - $this->set_prop( 'last_name', $value ); |
|
2276 | + public function set_last_name($value) { |
|
2277 | + $this->set_prop('last_name', $value); |
|
2278 | 2278 | } |
2279 | 2279 | |
2280 | 2280 | /** |
@@ -2283,8 +2283,8 @@ discard block |
||
2283 | 2283 | * @since 1.0.19 |
2284 | 2284 | * @param string $value last name. |
2285 | 2285 | */ |
2286 | - public function set_user_last_name( $value ) { |
|
2287 | - $this->set_last_name( $value ); |
|
2286 | + public function set_user_last_name($value) { |
|
2287 | + $this->set_last_name($value); |
|
2288 | 2288 | } |
2289 | 2289 | |
2290 | 2290 | /** |
@@ -2293,8 +2293,8 @@ discard block |
||
2293 | 2293 | * @since 1.0.19 |
2294 | 2294 | * @param string $value last name. |
2295 | 2295 | */ |
2296 | - public function set_customer_last_name( $value ) { |
|
2297 | - $this->set_last_name( $value ); |
|
2296 | + public function set_customer_last_name($value) { |
|
2297 | + $this->set_last_name($value); |
|
2298 | 2298 | } |
2299 | 2299 | |
2300 | 2300 | /** |
@@ -2303,8 +2303,8 @@ discard block |
||
2303 | 2303 | * @since 1.0.19 |
2304 | 2304 | * @param string $value phone. |
2305 | 2305 | */ |
2306 | - public function set_phone( $value ) { |
|
2307 | - $this->set_prop( 'phone', $value ); |
|
2306 | + public function set_phone($value) { |
|
2307 | + $this->set_prop('phone', $value); |
|
2308 | 2308 | } |
2309 | 2309 | |
2310 | 2310 | /** |
@@ -2313,8 +2313,8 @@ discard block |
||
2313 | 2313 | * @since 1.0.19 |
2314 | 2314 | * @param string $value phone. |
2315 | 2315 | */ |
2316 | - public function set_user_phone( $value ) { |
|
2317 | - $this->set_phone( $value ); |
|
2316 | + public function set_user_phone($value) { |
|
2317 | + $this->set_phone($value); |
|
2318 | 2318 | } |
2319 | 2319 | |
2320 | 2320 | /** |
@@ -2323,8 +2323,8 @@ discard block |
||
2323 | 2323 | * @since 1.0.19 |
2324 | 2324 | * @param string $value phone. |
2325 | 2325 | */ |
2326 | - public function set_customer_phone( $value ) { |
|
2327 | - $this->set_phone( $value ); |
|
2326 | + public function set_customer_phone($value) { |
|
2327 | + $this->set_phone($value); |
|
2328 | 2328 | } |
2329 | 2329 | |
2330 | 2330 | /** |
@@ -2333,8 +2333,8 @@ discard block |
||
2333 | 2333 | * @since 1.0.19 |
2334 | 2334 | * @param string $value phone. |
2335 | 2335 | */ |
2336 | - public function set_phone_number( $value ) { |
|
2337 | - $this->set_phone( $value ); |
|
2336 | + public function set_phone_number($value) { |
|
2337 | + $this->set_phone($value); |
|
2338 | 2338 | } |
2339 | 2339 | |
2340 | 2340 | /** |
@@ -2343,8 +2343,8 @@ discard block |
||
2343 | 2343 | * @since 1.0.19 |
2344 | 2344 | * @param string $value email address. |
2345 | 2345 | */ |
2346 | - public function set_email( $value ) { |
|
2347 | - $this->set_prop( 'email', $value ); |
|
2346 | + public function set_email($value) { |
|
2347 | + $this->set_prop('email', $value); |
|
2348 | 2348 | } |
2349 | 2349 | |
2350 | 2350 | /** |
@@ -2353,8 +2353,8 @@ discard block |
||
2353 | 2353 | * @since 1.0.19 |
2354 | 2354 | * @param string $value email address. |
2355 | 2355 | */ |
2356 | - public function set_user_email( $value ) { |
|
2357 | - $this->set_email( $value ); |
|
2356 | + public function set_user_email($value) { |
|
2357 | + $this->set_email($value); |
|
2358 | 2358 | } |
2359 | 2359 | |
2360 | 2360 | /** |
@@ -2363,8 +2363,8 @@ discard block |
||
2363 | 2363 | * @since 1.0.19 |
2364 | 2364 | * @param string $value email address. |
2365 | 2365 | */ |
2366 | - public function set_email_address( $value ) { |
|
2367 | - $this->set_email( $value ); |
|
2366 | + public function set_email_address($value) { |
|
2367 | + $this->set_email($value); |
|
2368 | 2368 | } |
2369 | 2369 | |
2370 | 2370 | /** |
@@ -2373,8 +2373,8 @@ discard block |
||
2373 | 2373 | * @since 1.0.19 |
2374 | 2374 | * @param string $value email address. |
2375 | 2375 | */ |
2376 | - public function set_customer_email( $value ) { |
|
2377 | - $this->set_email( $value ); |
|
2376 | + public function set_customer_email($value) { |
|
2377 | + $this->set_email($value); |
|
2378 | 2378 | } |
2379 | 2379 | |
2380 | 2380 | /** |
@@ -2383,8 +2383,8 @@ discard block |
||
2383 | 2383 | * @since 1.0.19 |
2384 | 2384 | * @param string $value country. |
2385 | 2385 | */ |
2386 | - public function set_country( $value ) { |
|
2387 | - $this->set_prop( 'country', $value ); |
|
2386 | + public function set_country($value) { |
|
2387 | + $this->set_prop('country', $value); |
|
2388 | 2388 | } |
2389 | 2389 | |
2390 | 2390 | /** |
@@ -2393,8 +2393,8 @@ discard block |
||
2393 | 2393 | * @since 1.0.19 |
2394 | 2394 | * @param string $value country. |
2395 | 2395 | */ |
2396 | - public function set_user_country( $value ) { |
|
2397 | - $this->set_country( $value ); |
|
2396 | + public function set_user_country($value) { |
|
2397 | + $this->set_country($value); |
|
2398 | 2398 | } |
2399 | 2399 | |
2400 | 2400 | /** |
@@ -2403,8 +2403,8 @@ discard block |
||
2403 | 2403 | * @since 1.0.19 |
2404 | 2404 | * @param string $value country. |
2405 | 2405 | */ |
2406 | - public function set_customer_country( $value ) { |
|
2407 | - $this->set_country( $value ); |
|
2406 | + public function set_customer_country($value) { |
|
2407 | + $this->set_country($value); |
|
2408 | 2408 | } |
2409 | 2409 | |
2410 | 2410 | /** |
@@ -2413,8 +2413,8 @@ discard block |
||
2413 | 2413 | * @since 1.0.19 |
2414 | 2414 | * @param string $value state. |
2415 | 2415 | */ |
2416 | - public function set_state( $value ) { |
|
2417 | - $this->set_prop( 'state', $value ); |
|
2416 | + public function set_state($value) { |
|
2417 | + $this->set_prop('state', $value); |
|
2418 | 2418 | } |
2419 | 2419 | |
2420 | 2420 | /** |
@@ -2423,8 +2423,8 @@ discard block |
||
2423 | 2423 | * @since 1.0.19 |
2424 | 2424 | * @param string $value state. |
2425 | 2425 | */ |
2426 | - public function set_user_state( $value ) { |
|
2427 | - $this->set_state( $value ); |
|
2426 | + public function set_user_state($value) { |
|
2427 | + $this->set_state($value); |
|
2428 | 2428 | } |
2429 | 2429 | |
2430 | 2430 | /** |
@@ -2433,8 +2433,8 @@ discard block |
||
2433 | 2433 | * @since 1.0.19 |
2434 | 2434 | * @param string $value state. |
2435 | 2435 | */ |
2436 | - public function set_customer_state( $value ) { |
|
2437 | - $this->set_state( $value ); |
|
2436 | + public function set_customer_state($value) { |
|
2437 | + $this->set_state($value); |
|
2438 | 2438 | } |
2439 | 2439 | |
2440 | 2440 | /** |
@@ -2443,8 +2443,8 @@ discard block |
||
2443 | 2443 | * @since 1.0.19 |
2444 | 2444 | * @param string $value city. |
2445 | 2445 | */ |
2446 | - public function set_city( $value ) { |
|
2447 | - $this->set_prop( 'city', $value ); |
|
2446 | + public function set_city($value) { |
|
2447 | + $this->set_prop('city', $value); |
|
2448 | 2448 | } |
2449 | 2449 | |
2450 | 2450 | /** |
@@ -2453,8 +2453,8 @@ discard block |
||
2453 | 2453 | * @since 1.0.19 |
2454 | 2454 | * @param string $value city. |
2455 | 2455 | */ |
2456 | - public function set_user_city( $value ) { |
|
2457 | - $this->set_city( $value ); |
|
2456 | + public function set_user_city($value) { |
|
2457 | + $this->set_city($value); |
|
2458 | 2458 | } |
2459 | 2459 | |
2460 | 2460 | /** |
@@ -2463,8 +2463,8 @@ discard block |
||
2463 | 2463 | * @since 1.0.19 |
2464 | 2464 | * @param string $value city. |
2465 | 2465 | */ |
2466 | - public function set_customer_city( $value ) { |
|
2467 | - $this->set_city( $value ); |
|
2466 | + public function set_customer_city($value) { |
|
2467 | + $this->set_city($value); |
|
2468 | 2468 | } |
2469 | 2469 | |
2470 | 2470 | /** |
@@ -2473,8 +2473,8 @@ discard block |
||
2473 | 2473 | * @since 1.0.19 |
2474 | 2474 | * @param string $value zip. |
2475 | 2475 | */ |
2476 | - public function set_zip( $value ) { |
|
2477 | - $this->set_prop( 'zip', $value ); |
|
2476 | + public function set_zip($value) { |
|
2477 | + $this->set_prop('zip', $value); |
|
2478 | 2478 | } |
2479 | 2479 | |
2480 | 2480 | /** |
@@ -2483,8 +2483,8 @@ discard block |
||
2483 | 2483 | * @since 1.0.19 |
2484 | 2484 | * @param string $value zip. |
2485 | 2485 | */ |
2486 | - public function set_user_zip( $value ) { |
|
2487 | - $this->set_zip( $value ); |
|
2486 | + public function set_user_zip($value) { |
|
2487 | + $this->set_zip($value); |
|
2488 | 2488 | } |
2489 | 2489 | |
2490 | 2490 | /** |
@@ -2493,8 +2493,8 @@ discard block |
||
2493 | 2493 | * @since 1.0.19 |
2494 | 2494 | * @param string $value zip. |
2495 | 2495 | */ |
2496 | - public function set_customer_zip( $value ) { |
|
2497 | - $this->set_zip( $value ); |
|
2496 | + public function set_customer_zip($value) { |
|
2497 | + $this->set_zip($value); |
|
2498 | 2498 | } |
2499 | 2499 | |
2500 | 2500 | /** |
@@ -2503,8 +2503,8 @@ discard block |
||
2503 | 2503 | * @since 1.0.19 |
2504 | 2504 | * @param string $value company. |
2505 | 2505 | */ |
2506 | - public function set_company( $value ) { |
|
2507 | - $this->set_prop( 'company', $value ); |
|
2506 | + public function set_company($value) { |
|
2507 | + $this->set_prop('company', $value); |
|
2508 | 2508 | } |
2509 | 2509 | |
2510 | 2510 | /** |
@@ -2513,8 +2513,8 @@ discard block |
||
2513 | 2513 | * @since 1.0.19 |
2514 | 2514 | * @param string $value company. |
2515 | 2515 | */ |
2516 | - public function set_user_company( $value ) { |
|
2517 | - $this->set_company( $value ); |
|
2516 | + public function set_user_company($value) { |
|
2517 | + $this->set_company($value); |
|
2518 | 2518 | } |
2519 | 2519 | |
2520 | 2520 | /** |
@@ -2523,8 +2523,8 @@ discard block |
||
2523 | 2523 | * @since 1.0.19 |
2524 | 2524 | * @param string $value company. |
2525 | 2525 | */ |
2526 | - public function set_customer_company( $value ) { |
|
2527 | - $this->set_company( $value ); |
|
2526 | + public function set_customer_company($value) { |
|
2527 | + $this->set_company($value); |
|
2528 | 2528 | } |
2529 | 2529 | |
2530 | 2530 | /** |
@@ -2533,8 +2533,8 @@ discard block |
||
2533 | 2533 | * @since 1.0.19 |
2534 | 2534 | * @param string $value var number. |
2535 | 2535 | */ |
2536 | - public function set_vat_number( $value ) { |
|
2537 | - $this->set_prop( 'vat_number', $value ); |
|
2536 | + public function set_vat_number($value) { |
|
2537 | + $this->set_prop('vat_number', $value); |
|
2538 | 2538 | } |
2539 | 2539 | |
2540 | 2540 | /** |
@@ -2543,8 +2543,8 @@ discard block |
||
2543 | 2543 | * @since 1.0.19 |
2544 | 2544 | * @param string $value var number. |
2545 | 2545 | */ |
2546 | - public function set_user_vat_number( $value ) { |
|
2547 | - $this->set_vat_number( $value ); |
|
2546 | + public function set_user_vat_number($value) { |
|
2547 | + $this->set_vat_number($value); |
|
2548 | 2548 | } |
2549 | 2549 | |
2550 | 2550 | /** |
@@ -2553,8 +2553,8 @@ discard block |
||
2553 | 2553 | * @since 1.0.19 |
2554 | 2554 | * @param string $value var number. |
2555 | 2555 | */ |
2556 | - public function set_customer_vat_number( $value ) { |
|
2557 | - $this->set_vat_number( $value ); |
|
2556 | + public function set_customer_vat_number($value) { |
|
2557 | + $this->set_vat_number($value); |
|
2558 | 2558 | } |
2559 | 2559 | |
2560 | 2560 | /** |
@@ -2563,8 +2563,8 @@ discard block |
||
2563 | 2563 | * @since 1.0.19 |
2564 | 2564 | * @param string $value var rate. |
2565 | 2565 | */ |
2566 | - public function set_vat_rate( $value ) { |
|
2567 | - $this->set_prop( 'vat_rate', $value ); |
|
2566 | + public function set_vat_rate($value) { |
|
2567 | + $this->set_prop('vat_rate', $value); |
|
2568 | 2568 | } |
2569 | 2569 | |
2570 | 2570 | /** |
@@ -2573,8 +2573,8 @@ discard block |
||
2573 | 2573 | * @since 1.0.19 |
2574 | 2574 | * @param string $value var number. |
2575 | 2575 | */ |
2576 | - public function set_user_vat_rate( $value ) { |
|
2577 | - $this->set_vat_rate( $value ); |
|
2576 | + public function set_user_vat_rate($value) { |
|
2577 | + $this->set_vat_rate($value); |
|
2578 | 2578 | } |
2579 | 2579 | |
2580 | 2580 | /** |
@@ -2583,8 +2583,8 @@ discard block |
||
2583 | 2583 | * @since 1.0.19 |
2584 | 2584 | * @param string $value var number. |
2585 | 2585 | */ |
2586 | - public function set_customer_vat_rate( $value ) { |
|
2587 | - $this->set_vat_rate( $value ); |
|
2586 | + public function set_customer_vat_rate($value) { |
|
2587 | + $this->set_vat_rate($value); |
|
2588 | 2588 | } |
2589 | 2589 | |
2590 | 2590 | /** |
@@ -2593,8 +2593,8 @@ discard block |
||
2593 | 2593 | * @since 1.0.19 |
2594 | 2594 | * @param string $value address. |
2595 | 2595 | */ |
2596 | - public function set_address( $value ) { |
|
2597 | - $this->set_prop( 'address', $value ); |
|
2596 | + public function set_address($value) { |
|
2597 | + $this->set_prop('address', $value); |
|
2598 | 2598 | } |
2599 | 2599 | |
2600 | 2600 | /** |
@@ -2603,8 +2603,8 @@ discard block |
||
2603 | 2603 | * @since 1.0.19 |
2604 | 2604 | * @param string $value address. |
2605 | 2605 | */ |
2606 | - public function set_user_address( $value ) { |
|
2607 | - $this->set_address( $value ); |
|
2606 | + public function set_user_address($value) { |
|
2607 | + $this->set_address($value); |
|
2608 | 2608 | } |
2609 | 2609 | |
2610 | 2610 | /** |
@@ -2613,8 +2613,8 @@ discard block |
||
2613 | 2613 | * @since 1.0.19 |
2614 | 2614 | * @param string $value address. |
2615 | 2615 | */ |
2616 | - public function set_customer_address( $value ) { |
|
2617 | - $this->set_address( $value ); |
|
2616 | + public function set_customer_address($value) { |
|
2617 | + $this->set_address($value); |
|
2618 | 2618 | } |
2619 | 2619 | |
2620 | 2620 | /** |
@@ -2623,8 +2623,8 @@ discard block |
||
2623 | 2623 | * @since 1.0.19 |
2624 | 2624 | * @param int|bool $value confirmed. |
2625 | 2625 | */ |
2626 | - public function set_is_viewed( $value ) { |
|
2627 | - $this->set_prop( 'is_viewed', $value ); |
|
2626 | + public function set_is_viewed($value) { |
|
2627 | + $this->set_prop('is_viewed', $value); |
|
2628 | 2628 | } |
2629 | 2629 | |
2630 | 2630 | /** |
@@ -2633,8 +2633,8 @@ discard block |
||
2633 | 2633 | * @since 1.0.19 |
2634 | 2634 | * @param string $value email recipients. |
2635 | 2635 | */ |
2636 | - public function set_email_cc( $value ) { |
|
2637 | - $this->set_prop( 'email_cc', $value ); |
|
2636 | + public function set_email_cc($value) { |
|
2637 | + $this->set_prop('email_cc', $value); |
|
2638 | 2638 | } |
2639 | 2639 | |
2640 | 2640 | /** |
@@ -2643,9 +2643,9 @@ discard block |
||
2643 | 2643 | * @since 1.0.19 |
2644 | 2644 | * @param string $value template. |
2645 | 2645 | */ |
2646 | - public function set_template( $value ) { |
|
2647 | - if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) { |
|
2648 | - $this->set_prop( 'template', $value ); |
|
2646 | + public function set_template($value) { |
|
2647 | + if (in_array($value, array('quantity', 'hours', 'amount'))) { |
|
2648 | + $this->set_prop('template', $value); |
|
2649 | 2649 | } |
2650 | 2650 | } |
2651 | 2651 | |
@@ -2655,8 +2655,8 @@ discard block |
||
2655 | 2655 | * @since 1.0.19 |
2656 | 2656 | * @param string $value email recipients. |
2657 | 2657 | */ |
2658 | - public function created_via( $value ) { |
|
2659 | - $this->set_prop( 'created_via', sanitize_text_field( $value ) ); |
|
2658 | + public function created_via($value) { |
|
2659 | + $this->set_prop('created_via', sanitize_text_field($value)); |
|
2660 | 2660 | } |
2661 | 2661 | |
2662 | 2662 | /** |
@@ -2665,8 +2665,8 @@ discard block |
||
2665 | 2665 | * @since 1.0.19 |
2666 | 2666 | * @param int|bool $value confirmed. |
2667 | 2667 | */ |
2668 | - public function set_address_confirmed( $value ) { |
|
2669 | - $this->set_prop( 'address_confirmed', $value ); |
|
2668 | + public function set_address_confirmed($value) { |
|
2669 | + $this->set_prop('address_confirmed', $value); |
|
2670 | 2670 | } |
2671 | 2671 | |
2672 | 2672 | /** |
@@ -2675,8 +2675,8 @@ discard block |
||
2675 | 2675 | * @since 1.0.19 |
2676 | 2676 | * @param int|bool $value confirmed. |
2677 | 2677 | */ |
2678 | - public function set_user_address_confirmed( $value ) { |
|
2679 | - $this->set_address_confirmed( $value ); |
|
2678 | + public function set_user_address_confirmed($value) { |
|
2679 | + $this->set_address_confirmed($value); |
|
2680 | 2680 | } |
2681 | 2681 | |
2682 | 2682 | /** |
@@ -2685,8 +2685,8 @@ discard block |
||
2685 | 2685 | * @since 1.0.19 |
2686 | 2686 | * @param int|bool $value confirmed. |
2687 | 2687 | */ |
2688 | - public function set_customer_address_confirmed( $value ) { |
|
2689 | - $this->set_address_confirmed( $value ); |
|
2688 | + public function set_customer_address_confirmed($value) { |
|
2689 | + $this->set_address_confirmed($value); |
|
2690 | 2690 | } |
2691 | 2691 | |
2692 | 2692 | /** |
@@ -2695,8 +2695,8 @@ discard block |
||
2695 | 2695 | * @since 1.0.19 |
2696 | 2696 | * @param float $value sub total. |
2697 | 2697 | */ |
2698 | - public function set_subtotal( $value ) { |
|
2699 | - $this->set_prop( 'subtotal', $value ); |
|
2698 | + public function set_subtotal($value) { |
|
2699 | + $this->set_prop('subtotal', $value); |
|
2700 | 2700 | } |
2701 | 2701 | |
2702 | 2702 | /** |
@@ -2705,8 +2705,8 @@ discard block |
||
2705 | 2705 | * @since 1.0.19 |
2706 | 2706 | * @param float $value discount total. |
2707 | 2707 | */ |
2708 | - public function set_total_discount( $value ) { |
|
2709 | - $this->set_prop( 'total_discount', $value ); |
|
2708 | + public function set_total_discount($value) { |
|
2709 | + $this->set_prop('total_discount', $value); |
|
2710 | 2710 | } |
2711 | 2711 | |
2712 | 2712 | /** |
@@ -2715,8 +2715,8 @@ discard block |
||
2715 | 2715 | * @since 1.0.19 |
2716 | 2716 | * @param float $value discount total. |
2717 | 2717 | */ |
2718 | - public function set_discount( $value ) { |
|
2719 | - $this->set_total_discount( $value ); |
|
2718 | + public function set_discount($value) { |
|
2719 | + $this->set_total_discount($value); |
|
2720 | 2720 | } |
2721 | 2721 | |
2722 | 2722 | /** |
@@ -2725,8 +2725,8 @@ discard block |
||
2725 | 2725 | * @since 1.0.19 |
2726 | 2726 | * @param float $value tax total. |
2727 | 2727 | */ |
2728 | - public function set_total_tax( $value ) { |
|
2729 | - $this->set_prop( 'total_tax', $value ); |
|
2728 | + public function set_total_tax($value) { |
|
2729 | + $this->set_prop('total_tax', $value); |
|
2730 | 2730 | } |
2731 | 2731 | |
2732 | 2732 | /** |
@@ -2735,8 +2735,8 @@ discard block |
||
2735 | 2735 | * @since 1.0.19 |
2736 | 2736 | * @param float $value tax total. |
2737 | 2737 | */ |
2738 | - public function set_tax_total( $value ) { |
|
2739 | - $this->set_total_tax( $value ); |
|
2738 | + public function set_tax_total($value) { |
|
2739 | + $this->set_total_tax($value); |
|
2740 | 2740 | } |
2741 | 2741 | |
2742 | 2742 | /** |
@@ -2745,8 +2745,8 @@ discard block |
||
2745 | 2745 | * @since 1.0.19 |
2746 | 2746 | * @param float $value fees total. |
2747 | 2747 | */ |
2748 | - public function set_total_fees( $value ) { |
|
2749 | - $this->set_prop( 'total_fees', $value ); |
|
2748 | + public function set_total_fees($value) { |
|
2749 | + $this->set_prop('total_fees', $value); |
|
2750 | 2750 | } |
2751 | 2751 | |
2752 | 2752 | /** |
@@ -2755,8 +2755,8 @@ discard block |
||
2755 | 2755 | * @since 1.0.19 |
2756 | 2756 | * @param float $value fees total. |
2757 | 2757 | */ |
2758 | - public function set_fees_total( $value ) { |
|
2759 | - $this->set_total_fees( $value ); |
|
2758 | + public function set_fees_total($value) { |
|
2759 | + $this->set_total_fees($value); |
|
2760 | 2760 | } |
2761 | 2761 | |
2762 | 2762 | /** |
@@ -2765,13 +2765,13 @@ discard block |
||
2765 | 2765 | * @since 1.0.19 |
2766 | 2766 | * @param array $value fees. |
2767 | 2767 | */ |
2768 | - public function set_fees( $value ) { |
|
2768 | + public function set_fees($value) { |
|
2769 | 2769 | |
2770 | - if ( ! is_array( $value ) ) { |
|
2770 | + if (!is_array($value)) { |
|
2771 | 2771 | $value = array(); |
2772 | 2772 | } |
2773 | 2773 | |
2774 | - $this->set_prop( 'fees', $value ); |
|
2774 | + $this->set_prop('fees', $value); |
|
2775 | 2775 | |
2776 | 2776 | } |
2777 | 2777 | |
@@ -2781,13 +2781,13 @@ discard block |
||
2781 | 2781 | * @since 1.0.19 |
2782 | 2782 | * @param array $value taxes. |
2783 | 2783 | */ |
2784 | - public function set_taxes( $value ) { |
|
2784 | + public function set_taxes($value) { |
|
2785 | 2785 | |
2786 | - if ( ! is_array( $value ) ) { |
|
2786 | + if (!is_array($value)) { |
|
2787 | 2787 | $value = array(); |
2788 | 2788 | } |
2789 | 2789 | |
2790 | - $this->set_prop( 'taxes', $value ); |
|
2790 | + $this->set_prop('taxes', $value); |
|
2791 | 2791 | |
2792 | 2792 | } |
2793 | 2793 | |
@@ -2797,13 +2797,13 @@ discard block |
||
2797 | 2797 | * @since 1.0.19 |
2798 | 2798 | * @param array $value discounts. |
2799 | 2799 | */ |
2800 | - public function set_discounts( $value ) { |
|
2800 | + public function set_discounts($value) { |
|
2801 | 2801 | |
2802 | - if ( ! is_array( $value ) ) { |
|
2802 | + if (!is_array($value)) { |
|
2803 | 2803 | $value = array(); |
2804 | 2804 | } |
2805 | 2805 | |
2806 | - $this->set_prop( 'discounts', $value ); |
|
2806 | + $this->set_prop('discounts', $value); |
|
2807 | 2807 | } |
2808 | 2808 | |
2809 | 2809 | /** |
@@ -2812,18 +2812,18 @@ discard block |
||
2812 | 2812 | * @since 1.0.19 |
2813 | 2813 | * @param GetPaid_Form_Item[] $value items. |
2814 | 2814 | */ |
2815 | - public function set_items( $value ) { |
|
2815 | + public function set_items($value) { |
|
2816 | 2816 | |
2817 | 2817 | // Remove existing items. |
2818 | - $this->set_prop( 'items', array() ); |
|
2818 | + $this->set_prop('items', array()); |
|
2819 | 2819 | |
2820 | 2820 | // Ensure that we have an array. |
2821 | - if ( ! is_array( $value ) ) { |
|
2821 | + if (!is_array($value)) { |
|
2822 | 2822 | return; |
2823 | 2823 | } |
2824 | 2824 | |
2825 | - foreach ( $value as $item ) { |
|
2826 | - $this->add_item( $item ); |
|
2825 | + foreach ($value as $item) { |
|
2826 | + $this->add_item($item); |
|
2827 | 2827 | } |
2828 | 2828 | |
2829 | 2829 | } |
@@ -2834,8 +2834,8 @@ discard block |
||
2834 | 2834 | * @since 1.0.19 |
2835 | 2835 | * @param int $value payment form. |
2836 | 2836 | */ |
2837 | - public function set_payment_form( $value ) { |
|
2838 | - $this->set_prop( 'payment_form', $value ); |
|
2837 | + public function set_payment_form($value) { |
|
2838 | + $this->set_prop('payment_form', $value); |
|
2839 | 2839 | } |
2840 | 2840 | |
2841 | 2841 | /** |
@@ -2844,8 +2844,8 @@ discard block |
||
2844 | 2844 | * @since 1.0.19 |
2845 | 2845 | * @param string $value submission id. |
2846 | 2846 | */ |
2847 | - public function set_submission_id( $value ) { |
|
2848 | - $this->set_prop( 'submission_id', $value ); |
|
2847 | + public function set_submission_id($value) { |
|
2848 | + $this->set_prop('submission_id', $value); |
|
2849 | 2849 | } |
2850 | 2850 | |
2851 | 2851 | /** |
@@ -2854,8 +2854,8 @@ discard block |
||
2854 | 2854 | * @since 1.0.19 |
2855 | 2855 | * @param string $value discount code. |
2856 | 2856 | */ |
2857 | - public function set_discount_code( $value ) { |
|
2858 | - $this->set_prop( 'discount_code', $value ); |
|
2857 | + public function set_discount_code($value) { |
|
2858 | + $this->set_prop('discount_code', $value); |
|
2859 | 2859 | } |
2860 | 2860 | |
2861 | 2861 | /** |
@@ -2864,8 +2864,8 @@ discard block |
||
2864 | 2864 | * @since 1.0.19 |
2865 | 2865 | * @param string $value gateway. |
2866 | 2866 | */ |
2867 | - public function set_gateway( $value ) { |
|
2868 | - $this->set_prop( 'gateway', $value ); |
|
2867 | + public function set_gateway($value) { |
|
2868 | + $this->set_prop('gateway', $value); |
|
2869 | 2869 | } |
2870 | 2870 | |
2871 | 2871 | /** |
@@ -2874,9 +2874,9 @@ discard block |
||
2874 | 2874 | * @since 1.0.19 |
2875 | 2875 | * @param string $value transaction id. |
2876 | 2876 | */ |
2877 | - public function set_transaction_id( $value ) { |
|
2878 | - if ( ! empty( $value ) ) { |
|
2879 | - $this->set_prop( 'transaction_id', $value ); |
|
2877 | + public function set_transaction_id($value) { |
|
2878 | + if (!empty($value)) { |
|
2879 | + $this->set_prop('transaction_id', $value); |
|
2880 | 2880 | } |
2881 | 2881 | } |
2882 | 2882 | |
@@ -2886,8 +2886,8 @@ discard block |
||
2886 | 2886 | * @since 1.0.19 |
2887 | 2887 | * @param string $value currency id. |
2888 | 2888 | */ |
2889 | - public function set_currency( $value ) { |
|
2890 | - $this->set_prop( 'currency', $value ); |
|
2889 | + public function set_currency($value) { |
|
2890 | + $this->set_prop('currency', $value); |
|
2891 | 2891 | } |
2892 | 2892 | |
2893 | 2893 | /** |
@@ -2896,8 +2896,8 @@ discard block |
||
2896 | 2896 | * @since 1.0.19 |
2897 | 2897 | * @param bool $value value. |
2898 | 2898 | */ |
2899 | - public function set_disable_taxes( $value ) { |
|
2900 | - $this->set_prop( 'disable_taxes', (bool) $value ); |
|
2899 | + public function set_disable_taxes($value) { |
|
2900 | + $this->set_prop('disable_taxes', (bool) $value); |
|
2901 | 2901 | } |
2902 | 2902 | |
2903 | 2903 | /** |
@@ -2906,8 +2906,8 @@ discard block |
||
2906 | 2906 | * @since 1.0.19 |
2907 | 2907 | * @param string $value subscription id. |
2908 | 2908 | */ |
2909 | - public function set_subscription_id( $value ) { |
|
2910 | - $this->set_prop( 'subscription_id', $value ); |
|
2909 | + public function set_subscription_id($value) { |
|
2910 | + $this->set_prop('subscription_id', $value); |
|
2911 | 2911 | } |
2912 | 2912 | |
2913 | 2913 | /** |
@@ -2916,8 +2916,8 @@ discard block |
||
2916 | 2916 | * @since 1.0.19 |
2917 | 2917 | * @param string $value subscription id. |
2918 | 2918 | */ |
2919 | - public function set_remote_subscription_id( $value ) { |
|
2920 | - $this->set_prop( 'remote_subscription_id', $value ); |
|
2919 | + public function set_remote_subscription_id($value) { |
|
2920 | + $this->set_prop('remote_subscription_id', $value); |
|
2921 | 2921 | } |
2922 | 2922 | |
2923 | 2923 | /* |
@@ -2934,28 +2934,28 @@ discard block |
||
2934 | 2934 | */ |
2935 | 2935 | public function is_parent() { |
2936 | 2936 | $parent = $this->get_parent_id(); |
2937 | - return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this ); |
|
2937 | + return apply_filters('wpinv_invoice_is_parent', empty($parent), $this); |
|
2938 | 2938 | } |
2939 | 2939 | |
2940 | 2940 | /** |
2941 | 2941 | * Checks if this is a renewal invoice. |
2942 | 2942 | */ |
2943 | 2943 | public function is_renewal() { |
2944 | - return ! $this->is_parent(); |
|
2944 | + return !$this->is_parent(); |
|
2945 | 2945 | } |
2946 | 2946 | |
2947 | 2947 | /** |
2948 | 2948 | * Checks if this is a recurring invoice. |
2949 | 2949 | */ |
2950 | 2950 | public function is_recurring() { |
2951 | - return $this->is_renewal() || ! empty( $this->recurring_item ); |
|
2951 | + return $this->is_renewal() || !empty($this->recurring_item); |
|
2952 | 2952 | } |
2953 | 2953 | |
2954 | 2954 | /** |
2955 | 2955 | * Checks if this is a taxable invoice. |
2956 | 2956 | */ |
2957 | 2957 | public function is_taxable() { |
2958 | - return ! $this->get_disable_taxes(); |
|
2958 | + return !$this->get_disable_taxes(); |
|
2959 | 2959 | } |
2960 | 2960 | |
2961 | 2961 | /** |
@@ -2969,45 +2969,45 @@ discard block |
||
2969 | 2969 | * Checks to see if the invoice requires payment. |
2970 | 2970 | */ |
2971 | 2971 | public function is_free() { |
2972 | - $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 ); |
|
2972 | + $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0); |
|
2973 | 2973 | |
2974 | - if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) { |
|
2974 | + if ($this->is_recurring() && $this->get_recurring_total() > 0) { |
|
2975 | 2975 | $is_free = false; |
2976 | 2976 | } |
2977 | 2977 | |
2978 | - return apply_filters( 'wpinv_invoice_is_free', $is_free, $this ); |
|
2978 | + return apply_filters('wpinv_invoice_is_free', $is_free, $this); |
|
2979 | 2979 | } |
2980 | 2980 | |
2981 | 2981 | /** |
2982 | 2982 | * Checks if the invoice is paid. |
2983 | 2983 | */ |
2984 | 2984 | public function is_paid() { |
2985 | - $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) ); |
|
2986 | - return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this ); |
|
2985 | + $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal')); |
|
2986 | + return apply_filters('wpinv_invoice_is_paid', $is_paid, $this); |
|
2987 | 2987 | } |
2988 | 2988 | |
2989 | 2989 | /** |
2990 | 2990 | * Checks if the invoice needs payment. |
2991 | 2991 | */ |
2992 | 2992 | public function needs_payment() { |
2993 | - $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free(); |
|
2994 | - return apply_filters( 'wpinv_needs_payment', $needs_payment, $this ); |
|
2993 | + $needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free(); |
|
2994 | + return apply_filters('wpinv_needs_payment', $needs_payment, $this); |
|
2995 | 2995 | } |
2996 | 2996 | |
2997 | 2997 | /** |
2998 | 2998 | * Checks if the invoice is refunded. |
2999 | 2999 | */ |
3000 | 3000 | public function is_refunded() { |
3001 | - $is_refunded = $this->has_status( 'wpi-refunded' ); |
|
3002 | - return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this ); |
|
3001 | + $is_refunded = $this->has_status('wpi-refunded'); |
|
3002 | + return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this); |
|
3003 | 3003 | } |
3004 | 3004 | |
3005 | 3005 | /** |
3006 | 3006 | * Checks if the invoice is held. |
3007 | 3007 | */ |
3008 | 3008 | public function is_held() { |
3009 | - $is_held = $this->has_status( 'wpi-onhold' ); |
|
3010 | - return apply_filters( 'wpinv_invoice_is_held', $is_held, $this ); |
|
3009 | + $is_held = $this->has_status('wpi-onhold'); |
|
3010 | + return apply_filters('wpinv_invoice_is_held', $is_held, $this); |
|
3011 | 3011 | } |
3012 | 3012 | |
3013 | 3013 | /** |
@@ -3015,30 +3015,30 @@ discard block |
||
3015 | 3015 | */ |
3016 | 3016 | public function is_due() { |
3017 | 3017 | $due_date = $this->get_due_date(); |
3018 | - return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date ); |
|
3018 | + return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date); |
|
3019 | 3019 | } |
3020 | 3020 | |
3021 | 3021 | /** |
3022 | 3022 | * Checks if the invoice is draft. |
3023 | 3023 | */ |
3024 | 3024 | public function is_draft() { |
3025 | - return $this->has_status( 'draft, auto-draft' ); |
|
3025 | + return $this->has_status('draft, auto-draft'); |
|
3026 | 3026 | } |
3027 | 3027 | |
3028 | 3028 | /** |
3029 | 3029 | * Checks if the invoice has a given status. |
3030 | 3030 | */ |
3031 | - public function has_status( $status ) { |
|
3032 | - $status = wpinv_parse_list( $status ); |
|
3033 | - return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status ); |
|
3031 | + public function has_status($status) { |
|
3032 | + $status = wpinv_parse_list($status); |
|
3033 | + return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status); |
|
3034 | 3034 | } |
3035 | 3035 | |
3036 | 3036 | /** |
3037 | 3037 | * Checks if the invoice is of a given type. |
3038 | 3038 | */ |
3039 | - public function is_type( $type ) { |
|
3040 | - $type = wpinv_parse_list( $type ); |
|
3041 | - return in_array( $this->get_type(), $type ); |
|
3039 | + public function is_type($type) { |
|
3040 | + $type = wpinv_parse_list($type); |
|
3041 | + return in_array($this->get_type(), $type); |
|
3042 | 3042 | } |
3043 | 3043 | |
3044 | 3044 | /** |
@@ -3070,8 +3070,8 @@ discard block |
||
3070 | 3070 | * |
3071 | 3071 | */ |
3072 | 3072 | public function is_initial_free() { |
3073 | - $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 ); |
|
3074 | - return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this ); |
|
3073 | + $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0); |
|
3074 | + return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this); |
|
3075 | 3075 | } |
3076 | 3076 | |
3077 | 3077 | /** |
@@ -3081,11 +3081,11 @@ discard block |
||
3081 | 3081 | public function item_has_free_trial() { |
3082 | 3082 | |
3083 | 3083 | // Ensure we have a recurring item. |
3084 | - if ( ! $this->is_recurring() ) { |
|
3084 | + if (!$this->is_recurring()) { |
|
3085 | 3085 | return false; |
3086 | 3086 | } |
3087 | 3087 | |
3088 | - $item = $this->get_recurring( true ); |
|
3088 | + $item = $this->get_recurring(true); |
|
3089 | 3089 | return $item->has_free_trial(); |
3090 | 3090 | } |
3091 | 3091 | |
@@ -3093,7 +3093,7 @@ discard block |
||
3093 | 3093 | * Check if the free trial is a result of a discount. |
3094 | 3094 | */ |
3095 | 3095 | public function is_free_trial_from_discount() { |
3096 | - return $this->has_free_trial() && ! $this->item_has_free_trial(); |
|
3096 | + return $this->has_free_trial() && !$this->item_has_free_trial(); |
|
3097 | 3097 | } |
3098 | 3098 | |
3099 | 3099 | /** |
@@ -3101,12 +3101,12 @@ discard block |
||
3101 | 3101 | */ |
3102 | 3102 | public function discount_first_payment_only() { |
3103 | 3103 | |
3104 | - $discount = wpinv_get_discount_obj( $this->get_discount_code() ); |
|
3105 | - if ( ! $discount->exists() || ! $this->is_recurring() ) { |
|
3104 | + $discount = wpinv_get_discount_obj($this->get_discount_code()); |
|
3105 | + if (!$discount->exists() || !$this->is_recurring()) { |
|
3106 | 3106 | return true; |
3107 | 3107 | } |
3108 | 3108 | |
3109 | - return ! $discount->get_is_recurring(); |
|
3109 | + return !$discount->get_is_recurring(); |
|
3110 | 3110 | } |
3111 | 3111 | |
3112 | 3112 | /* |
@@ -3124,27 +3124,27 @@ discard block |
||
3124 | 3124 | * @param GetPaid_Form_Item|array $item |
3125 | 3125 | * @return WP_Error|Bool |
3126 | 3126 | */ |
3127 | - public function add_item( $item ) { |
|
3127 | + public function add_item($item) { |
|
3128 | 3128 | |
3129 | - if ( is_array( $item ) ) { |
|
3130 | - $item = $this->process_array_item( $item ); |
|
3129 | + if (is_array($item)) { |
|
3130 | + $item = $this->process_array_item($item); |
|
3131 | 3131 | } |
3132 | 3132 | |
3133 | - if ( is_numeric( $item ) ) { |
|
3134 | - $item = new GetPaid_Form_Item( $item ); |
|
3133 | + if (is_numeric($item)) { |
|
3134 | + $item = new GetPaid_Form_Item($item); |
|
3135 | 3135 | } |
3136 | 3136 | |
3137 | 3137 | // Make sure that it is available for purchase. |
3138 | - if ( $item->get_id() > 0 && ! $item->can_purchase() ) { |
|
3139 | - return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) ); |
|
3138 | + if ($item->get_id() > 0 && !$item->can_purchase()) { |
|
3139 | + return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing')); |
|
3140 | 3140 | } |
3141 | 3141 | |
3142 | 3142 | // Do we have a recurring item? |
3143 | - if ( $item->is_recurring() ) { |
|
3143 | + if ($item->is_recurring()) { |
|
3144 | 3144 | |
3145 | 3145 | // An invoice can only contain one recurring item. |
3146 | - if ( ! empty( $this->recurring_item && $this->recurring_item != (int) $item->get_id() ) ) { |
|
3147 | - return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) ); |
|
3146 | + if (!empty($this->recurring_item && $this->recurring_item != (int) $item->get_id())) { |
|
3147 | + return new WP_Error('recurring_item', __('An invoice can only contain one recurring item', 'invoicing')); |
|
3148 | 3148 | } |
3149 | 3149 | |
3150 | 3150 | $this->recurring_item = $item->get_id(); |
@@ -3155,9 +3155,9 @@ discard block |
||
3155 | 3155 | |
3156 | 3156 | // Retrieve all items. |
3157 | 3157 | $items = $this->get_items(); |
3158 | - $items[ (int) $item->get_id() ] = $item; |
|
3158 | + $items[(int) $item->get_id()] = $item; |
|
3159 | 3159 | |
3160 | - $this->set_prop( 'items', $items ); |
|
3160 | + $this->set_prop('items', $items); |
|
3161 | 3161 | return true; |
3162 | 3162 | } |
3163 | 3163 | |
@@ -3167,26 +3167,26 @@ discard block |
||
3167 | 3167 | * @since 1.0.19 |
3168 | 3168 | * @return GetPaid_Form_Item |
3169 | 3169 | */ |
3170 | - protected function process_array_item( $array ) { |
|
3170 | + protected function process_array_item($array) { |
|
3171 | 3171 | |
3172 | - $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0; |
|
3173 | - $item = new GetPaid_Form_Item( $item_id ); |
|
3172 | + $item_id = isset($array['item_id']) ? $array['item_id'] : 0; |
|
3173 | + $item = new GetPaid_Form_Item($item_id); |
|
3174 | 3174 | |
3175 | 3175 | // Set item data. |
3176 | - foreach ( array( 'name', 'price', 'description' ) as $key ) { |
|
3177 | - if ( isset( $array[ "item_$key" ] ) ) { |
|
3176 | + foreach (array('name', 'price', 'description') as $key) { |
|
3177 | + if (isset($array["item_$key"])) { |
|
3178 | 3178 | $method = "set_$key"; |
3179 | - $item->$method( $array[ "item_$key" ] ); |
|
3179 | + $item->$method($array["item_$key"]); |
|
3180 | 3180 | } |
3181 | 3181 | } |
3182 | 3182 | |
3183 | - if ( isset( $array['quantity'] ) ) { |
|
3184 | - $item->set_quantity( $array['quantity'] ); |
|
3183 | + if (isset($array['quantity'])) { |
|
3184 | + $item->set_quantity($array['quantity']); |
|
3185 | 3185 | } |
3186 | 3186 | |
3187 | 3187 | // Set item meta. |
3188 | - if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) { |
|
3189 | - $item->set_item_meta( $array['meta'] ); |
|
3188 | + if (isset($array['meta']) && is_array($array['meta'])) { |
|
3189 | + $item->set_item_meta($array['meta']); |
|
3190 | 3190 | } |
3191 | 3191 | |
3192 | 3192 | return $item; |
@@ -3198,10 +3198,10 @@ discard block |
||
3198 | 3198 | * |
3199 | 3199 | * @since 1.0.19 |
3200 | 3200 | */ |
3201 | - public function get_item( $item_id ) { |
|
3201 | + public function get_item($item_id) { |
|
3202 | 3202 | $items = $this->get_items(); |
3203 | 3203 | $item_id = (int) $item_id; |
3204 | - return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null; |
|
3204 | + return (!empty($item_id) && isset($items[$item_id])) ? $items[$item_id] : null; |
|
3205 | 3205 | } |
3206 | 3206 | |
3207 | 3207 | /** |
@@ -3209,17 +3209,17 @@ discard block |
||
3209 | 3209 | * |
3210 | 3210 | * @since 1.0.19 |
3211 | 3211 | */ |
3212 | - public function remove_item( $item_id ) { |
|
3212 | + public function remove_item($item_id) { |
|
3213 | 3213 | $items = $this->get_items(); |
3214 | 3214 | $item_id = (int) $item_id; |
3215 | 3215 | |
3216 | - if ( $item_id == $this->recurring_item ) { |
|
3216 | + if ($item_id == $this->recurring_item) { |
|
3217 | 3217 | $this->recurring_item = null; |
3218 | 3218 | } |
3219 | 3219 | |
3220 | - if ( isset( $items[ $item_id ] ) ) { |
|
3221 | - unset( $items[ $item_id ] ); |
|
3222 | - $this->set_prop( 'items', $items ); |
|
3220 | + if (isset($items[$item_id])) { |
|
3221 | + unset($items[$item_id]); |
|
3222 | + $this->set_prop('items', $items); |
|
3223 | 3223 | } |
3224 | 3224 | } |
3225 | 3225 | |
@@ -3229,11 +3229,11 @@ discard block |
||
3229 | 3229 | * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required. |
3230 | 3230 | * @since 1.0.19 |
3231 | 3231 | */ |
3232 | - public function add_fee( $fee ) { |
|
3232 | + public function add_fee($fee) { |
|
3233 | 3233 | |
3234 | 3234 | $fees = $this->get_fees(); |
3235 | - $fees[ $fee['name'] ] = $fee; |
|
3236 | - $this->set_prop( 'fees', $fees ); |
|
3235 | + $fees[$fee['name']] = $fee; |
|
3236 | + $this->set_prop('fees', $fees); |
|
3237 | 3237 | |
3238 | 3238 | } |
3239 | 3239 | |
@@ -3242,9 +3242,9 @@ discard block |
||
3242 | 3242 | * |
3243 | 3243 | * @since 1.0.19 |
3244 | 3244 | */ |
3245 | - public function get_fee( $fee ) { |
|
3245 | + public function get_fee($fee) { |
|
3246 | 3246 | $fees = $this->get_fees(); |
3247 | - return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null; |
|
3247 | + return isset($fees[$fee]) ? $fees[$fee] : null; |
|
3248 | 3248 | } |
3249 | 3249 | |
3250 | 3250 | /** |
@@ -3252,11 +3252,11 @@ discard block |
||
3252 | 3252 | * |
3253 | 3253 | * @since 1.0.19 |
3254 | 3254 | */ |
3255 | - public function remove_fee( $fee ) { |
|
3255 | + public function remove_fee($fee) { |
|
3256 | 3256 | $fees = $this->get_fees(); |
3257 | - if ( isset( $fees[ $fee ] ) ) { |
|
3258 | - unset( $fees[ $fee ] ); |
|
3259 | - $this->set_prop( 'fees', $fees ); |
|
3257 | + if (isset($fees[$fee])) { |
|
3258 | + unset($fees[$fee]); |
|
3259 | + $this->set_prop('fees', $fees); |
|
3260 | 3260 | } |
3261 | 3261 | } |
3262 | 3262 | |
@@ -3266,11 +3266,11 @@ discard block |
||
3266 | 3266 | * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code. |
3267 | 3267 | * @since 1.0.19 |
3268 | 3268 | */ |
3269 | - public function add_discount( $discount ) { |
|
3269 | + public function add_discount($discount) { |
|
3270 | 3270 | |
3271 | 3271 | $discounts = $this->get_discounts(); |
3272 | - $discounts[ $discount['name'] ] = $discount; |
|
3273 | - $this->set_prop( 'discounts', $discounts ); |
|
3272 | + $discounts[$discount['name']] = $discount; |
|
3273 | + $this->set_prop('discounts', $discounts); |
|
3274 | 3274 | |
3275 | 3275 | } |
3276 | 3276 | |
@@ -3280,15 +3280,15 @@ discard block |
||
3280 | 3280 | * @since 1.0.19 |
3281 | 3281 | * @return float |
3282 | 3282 | */ |
3283 | - public function get_discount( $discount = false ) { |
|
3283 | + public function get_discount($discount = false) { |
|
3284 | 3284 | |
3285 | 3285 | // Backwards compatibilty. |
3286 | - if ( empty( $discount ) ) { |
|
3286 | + if (empty($discount)) { |
|
3287 | 3287 | return $this->get_total_discount(); |
3288 | 3288 | } |
3289 | 3289 | |
3290 | 3290 | $discounts = $this->get_discounts(); |
3291 | - return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null; |
|
3291 | + return isset($discounts[$discount]) ? $discounts[$discount] : null; |
|
3292 | 3292 | } |
3293 | 3293 | |
3294 | 3294 | /** |
@@ -3296,11 +3296,11 @@ discard block |
||
3296 | 3296 | * |
3297 | 3297 | * @since 1.0.19 |
3298 | 3298 | */ |
3299 | - public function remove_discount( $discount ) { |
|
3299 | + public function remove_discount($discount) { |
|
3300 | 3300 | $discounts = $this->get_discounts(); |
3301 | - if ( isset( $discounts[ $discount ] ) ) { |
|
3302 | - unset( $discounts[ $discount ] ); |
|
3303 | - $this->set_prop( 'discounts', $discounts ); |
|
3301 | + if (isset($discounts[$discount])) { |
|
3302 | + unset($discounts[$discount]); |
|
3303 | + $this->set_prop('discounts', $discounts); |
|
3304 | 3304 | } |
3305 | 3305 | } |
3306 | 3306 | |
@@ -3309,12 +3309,12 @@ discard block |
||
3309 | 3309 | * |
3310 | 3310 | * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required. |
3311 | 3311 | */ |
3312 | - public function add_tax( $tax ) { |
|
3313 | - if ( $this->is_taxable() ) { |
|
3312 | + public function add_tax($tax) { |
|
3313 | + if ($this->is_taxable()) { |
|
3314 | 3314 | |
3315 | - $taxes = $this->get_taxes(); |
|
3316 | - $taxes[ $tax['name'] ] = $tax; |
|
3317 | - $this->set_prop( 'taxes', $tax ); |
|
3315 | + $taxes = $this->get_taxes(); |
|
3316 | + $taxes[$tax['name']] = $tax; |
|
3317 | + $this->set_prop('taxes', $tax); |
|
3318 | 3318 | |
3319 | 3319 | } |
3320 | 3320 | } |
@@ -3324,15 +3324,15 @@ discard block |
||
3324 | 3324 | * |
3325 | 3325 | * @since 1.0.19 |
3326 | 3326 | */ |
3327 | - public function get_tax( $tax = null ) { |
|
3327 | + public function get_tax($tax = null) { |
|
3328 | 3328 | |
3329 | 3329 | // Backwards compatility. |
3330 | - if ( empty( $tax ) ) { |
|
3330 | + if (empty($tax)) { |
|
3331 | 3331 | return $this->get_total_tax(); |
3332 | 3332 | } |
3333 | 3333 | |
3334 | 3334 | $taxes = $this->get_taxes(); |
3335 | - return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null; |
|
3335 | + return isset($taxes[$tax]) ? $taxes[$tax] : null; |
|
3336 | 3336 | } |
3337 | 3337 | |
3338 | 3338 | /** |
@@ -3340,11 +3340,11 @@ discard block |
||
3340 | 3340 | * |
3341 | 3341 | * @since 1.0.19 |
3342 | 3342 | */ |
3343 | - public function remove_tax( $tax ) { |
|
3343 | + public function remove_tax($tax) { |
|
3344 | 3344 | $taxes = $this->get_taxes(); |
3345 | - if ( isset( $taxes[ $tax ] ) ) { |
|
3346 | - unset( $taxes[ $tax ] ); |
|
3347 | - $this->set_prop( 'taxes', $taxes ); |
|
3345 | + if (isset($taxes[$tax])) { |
|
3346 | + unset($taxes[$tax]); |
|
3347 | + $this->set_prop('taxes', $taxes); |
|
3348 | 3348 | } |
3349 | 3349 | } |
3350 | 3350 | |
@@ -3355,17 +3355,17 @@ discard block |
||
3355 | 3355 | * @return float The recalculated subtotal |
3356 | 3356 | */ |
3357 | 3357 | public function recalculate_subtotal() { |
3358 | - $items = $this->get_items(); |
|
3358 | + $items = $this->get_items(); |
|
3359 | 3359 | $subtotal = 0; |
3360 | 3360 | $recurring = 0; |
3361 | 3361 | |
3362 | - foreach ( $items as $item ) { |
|
3362 | + foreach ($items as $item) { |
|
3363 | 3363 | $subtotal += $item->get_sub_total(); |
3364 | 3364 | $recurring += $item->get_recurring_sub_total(); |
3365 | 3365 | } |
3366 | 3366 | |
3367 | 3367 | $current = $this->is_renewal() ? $recurring : $subtotal; |
3368 | - $this->set_subtotal( $current ); |
|
3368 | + $this->set_subtotal($current); |
|
3369 | 3369 | |
3370 | 3370 | $this->totals['subtotal'] = array( |
3371 | 3371 | 'initial' => $subtotal, |
@@ -3386,14 +3386,14 @@ discard block |
||
3386 | 3386 | $discount = 0; |
3387 | 3387 | $recurring = 0; |
3388 | 3388 | |
3389 | - foreach ( $discounts as $data ) { |
|
3390 | - $discount += wpinv_sanitize_amount( $data['initial_discount'] ); |
|
3391 | - $recurring += wpinv_sanitize_amount( $data['recurring_discount'] ); |
|
3389 | + foreach ($discounts as $data) { |
|
3390 | + $discount += wpinv_sanitize_amount($data['initial_discount']); |
|
3391 | + $recurring += wpinv_sanitize_amount($data['recurring_discount']); |
|
3392 | 3392 | } |
3393 | 3393 | |
3394 | 3394 | $current = $this->is_renewal() ? $recurring : $discount; |
3395 | 3395 | |
3396 | - $this->set_total_discount( $current ); |
|
3396 | + $this->set_total_discount($current); |
|
3397 | 3397 | |
3398 | 3398 | $this->totals['discount'] = array( |
3399 | 3399 | 'initial' => $discount, |
@@ -3411,17 +3411,17 @@ discard block |
||
3411 | 3411 | * @return float The recalculated tax |
3412 | 3412 | */ |
3413 | 3413 | public function recalculate_total_tax() { |
3414 | - $taxes = $this->get_taxes(); |
|
3414 | + $taxes = $this->get_taxes(); |
|
3415 | 3415 | $tax = 0; |
3416 | 3416 | $recurring = 0; |
3417 | 3417 | |
3418 | - foreach ( $taxes as $data ) { |
|
3419 | - $tax += wpinv_sanitize_amount( $data['initial_tax'] ); |
|
3420 | - $recurring += wpinv_sanitize_amount( $data['recurring_tax'] ); |
|
3418 | + foreach ($taxes as $data) { |
|
3419 | + $tax += wpinv_sanitize_amount($data['initial_tax']); |
|
3420 | + $recurring += wpinv_sanitize_amount($data['recurring_tax']); |
|
3421 | 3421 | } |
3422 | 3422 | |
3423 | 3423 | $current = $this->is_renewal() ? $recurring : $tax; |
3424 | - $this->set_total_tax( $current ); |
|
3424 | + $this->set_total_tax($current); |
|
3425 | 3425 | |
3426 | 3426 | $this->totals['tax'] = array( |
3427 | 3427 | 'initial' => $tax, |
@@ -3443,20 +3443,20 @@ discard block |
||
3443 | 3443 | $fee = 0; |
3444 | 3444 | $recurring = 0; |
3445 | 3445 | |
3446 | - foreach ( $fees as $data ) { |
|
3447 | - $fee += wpinv_sanitize_amount( $data['initial_fee'] ); |
|
3448 | - $recurring += wpinv_sanitize_amount( $data['recurring_fee'] ); |
|
3446 | + foreach ($fees as $data) { |
|
3447 | + $fee += wpinv_sanitize_amount($data['initial_fee']); |
|
3448 | + $recurring += wpinv_sanitize_amount($data['recurring_fee']); |
|
3449 | 3449 | } |
3450 | 3450 | |
3451 | 3451 | $current = $this->is_renewal() ? $recurring : $fee; |
3452 | - $this->set_total_fees( $current ); |
|
3452 | + $this->set_total_fees($current); |
|
3453 | 3453 | |
3454 | 3454 | $this->totals['fee'] = array( |
3455 | 3455 | 'initial' => $fee, |
3456 | 3456 | 'recurring' => $recurring, |
3457 | 3457 | ); |
3458 | 3458 | |
3459 | - $this->set_total_fees( $fee ); |
|
3459 | + $this->set_total_fees($fee); |
|
3460 | 3460 | return $current; |
3461 | 3461 | } |
3462 | 3462 | |
@@ -3477,9 +3477,9 @@ discard block |
||
3477 | 3477 | /** |
3478 | 3478 | * @deprecated |
3479 | 3479 | */ |
3480 | - public function recalculate_totals( $temp = false ) { |
|
3481 | - $this->update_items( $temp ); |
|
3482 | - $this->save( true ); |
|
3480 | + public function recalculate_totals($temp = false) { |
|
3481 | + $this->update_items($temp); |
|
3482 | + $this->save(true); |
|
3483 | 3483 | return $this; |
3484 | 3484 | } |
3485 | 3485 | |
@@ -3497,10 +3497,10 @@ discard block |
||
3497 | 3497 | * @return int|false The new note's ID on success, false on failure. |
3498 | 3498 | * |
3499 | 3499 | */ |
3500 | - public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) { |
|
3500 | + public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) { |
|
3501 | 3501 | |
3502 | 3502 | // Bail if no note specified or this invoice is not yet saved. |
3503 | - if ( ! $note || $this->get_id() == 0 || ( ! is_user_logged_in() && ! $system ) ) { |
|
3503 | + if (!$note || $this->get_id() == 0 || (!is_user_logged_in() && !$system)) { |
|
3504 | 3504 | return false; |
3505 | 3505 | } |
3506 | 3506 | |
@@ -3508,23 +3508,23 @@ discard block |
||
3508 | 3508 | $author_email = '[email protected]'; |
3509 | 3509 | |
3510 | 3510 | // If this is an admin comment or it has been added by the user. |
3511 | - if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) { |
|
3512 | - $user = get_user_by( 'id', get_current_user_id() ); |
|
3511 | + if (is_user_logged_in() && (!$system || $added_by_user)) { |
|
3512 | + $user = get_user_by('id', get_current_user_id()); |
|
3513 | 3513 | $author = $user->display_name; |
3514 | 3514 | $author_email = $user->user_email; |
3515 | 3515 | } |
3516 | 3516 | |
3517 | - return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type ); |
|
3517 | + return getpaid_notes()->add_invoice_note($this, $note, $author, $author_email, $customer_type); |
|
3518 | 3518 | |
3519 | 3519 | } |
3520 | 3520 | |
3521 | 3521 | /** |
3522 | 3522 | * Generates a unique key for the invoice. |
3523 | 3523 | */ |
3524 | - public function generate_key( $string = '' ) { |
|
3525 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
3524 | + public function generate_key($string = '') { |
|
3525 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
3526 | 3526 | return strtolower( |
3527 | - $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) ) |
|
3527 | + $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true)) |
|
3528 | 3528 | ); |
3529 | 3529 | } |
3530 | 3530 | |
@@ -3534,11 +3534,11 @@ discard block |
||
3534 | 3534 | public function generate_number() { |
3535 | 3535 | $number = $this->get_id(); |
3536 | 3536 | |
3537 | - if ( wpinv_sequential_number_active( $this->get_post_type() ) ) { |
|
3538 | - $number = wpinv_get_next_invoice_number( $this->get_post_type() ); |
|
3537 | + if (wpinv_sequential_number_active($this->get_post_type())) { |
|
3538 | + $number = wpinv_get_next_invoice_number($this->get_post_type()); |
|
3539 | 3539 | } |
3540 | 3540 | |
3541 | - return wpinv_format_invoice_number( $number, $this->get_post_type() ); |
|
3541 | + return wpinv_format_invoice_number($number, $this->get_post_type()); |
|
3542 | 3542 | |
3543 | 3543 | } |
3544 | 3544 | |
@@ -3551,55 +3551,55 @@ discard block |
||
3551 | 3551 | // Reset status transition variable. |
3552 | 3552 | $this->status_transition = false; |
3553 | 3553 | |
3554 | - if ( $status_transition ) { |
|
3554 | + if ($status_transition) { |
|
3555 | 3555 | try { |
3556 | 3556 | |
3557 | 3557 | // Fire a hook for the status change. |
3558 | - do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition ); |
|
3558 | + do_action('getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition); |
|
3559 | 3559 | |
3560 | 3560 | // @deprecated this is deprecated and will be removed in the future. |
3561 | - do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
3561 | + do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
3562 | 3562 | |
3563 | - if ( ! empty( $status_transition['from'] ) ) { |
|
3563 | + if (!empty($status_transition['from'])) { |
|
3564 | 3564 | |
3565 | 3565 | /* translators: 1: old invoice status 2: new invoice status */ |
3566 | - $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this ) ); |
|
3566 | + $transition_note = sprintf(__('Status changed from %1$s to %2$s.', 'invoicing'), wpinv_status_nicename($status_transition['from'], $this), wpinv_status_nicename($status_transition['to'], $this)); |
|
3567 | 3567 | |
3568 | 3568 | // Fire another hook. |
3569 | - do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this ); |
|
3570 | - do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] ); |
|
3569 | + do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this); |
|
3570 | + do_action('getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to']); |
|
3571 | 3571 | |
3572 | 3572 | // @deprecated this is deprecated and will be removed in the future. |
3573 | - do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
3573 | + do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
3574 | 3574 | |
3575 | 3575 | // Note the transition occurred. |
3576 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] ); |
|
3576 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), false, $status_transition['manual']); |
|
3577 | 3577 | |
3578 | 3578 | // Work out if this was for a payment, and trigger a payment_status hook instead. |
3579 | 3579 | if ( |
3580 | - in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
3581 | - && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
3580 | + in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true) |
|
3581 | + && in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true) |
|
3582 | 3582 | ) { |
3583 | - do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition ); |
|
3583 | + do_action('getpaid_invoice_payment_status_changed', $this, $status_transition); |
|
3584 | 3584 | } |
3585 | 3585 | |
3586 | 3586 | // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead. |
3587 | 3587 | if ( |
3588 | - in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
3589 | - && in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
3588 | + in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'), true) |
|
3589 | + && in_array($status_transition['to'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true) |
|
3590 | 3590 | ) { |
3591 | - do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition ); |
|
3591 | + do_action('getpaid_invoice_payment_status_reversed', $this, $status_transition); |
|
3592 | 3592 | } |
3593 | 3593 | } else { |
3594 | 3594 | /* translators: %s: new invoice status */ |
3595 | - $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this ) ); |
|
3595 | + $transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to'], $this)); |
|
3596 | 3596 | |
3597 | 3597 | // Note the transition occurred. |
3598 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
3598 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']); |
|
3599 | 3599 | |
3600 | 3600 | } |
3601 | - } catch ( Exception $e ) { |
|
3602 | - $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
3601 | + } catch (Exception $e) { |
|
3602 | + $this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage()); |
|
3603 | 3603 | } |
3604 | 3604 | } |
3605 | 3605 | } |
@@ -3607,13 +3607,13 @@ discard block |
||
3607 | 3607 | /** |
3608 | 3608 | * Updates an invoice status. |
3609 | 3609 | */ |
3610 | - public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
3610 | + public function update_status($new_status = false, $note = '', $manual = false) { |
|
3611 | 3611 | |
3612 | 3612 | // Fires before updating a status. |
3613 | - do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) ); |
|
3613 | + do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit')); |
|
3614 | 3614 | |
3615 | 3615 | // Update the status. |
3616 | - $this->set_status( $new_status, $note, $manual ); |
|
3616 | + $this->set_status($new_status, $note, $manual); |
|
3617 | 3617 | |
3618 | 3618 | // Save the order. |
3619 | 3619 | return $this->save(); |
@@ -3624,18 +3624,18 @@ discard block |
||
3624 | 3624 | * @deprecated |
3625 | 3625 | */ |
3626 | 3626 | public function refresh_item_ids() { |
3627 | - $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) ); |
|
3628 | - update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids ); |
|
3627 | + $item_ids = implode(',', array_unique(array_keys($this->get_items()))); |
|
3628 | + update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids); |
|
3629 | 3629 | } |
3630 | 3630 | |
3631 | 3631 | /** |
3632 | 3632 | * @deprecated |
3633 | 3633 | */ |
3634 | - public function update_items( $temp = false ) { |
|
3634 | + public function update_items($temp = false) { |
|
3635 | 3635 | |
3636 | - $this->set_items( $this->get_items() ); |
|
3636 | + $this->set_items($this->get_items()); |
|
3637 | 3637 | |
3638 | - if ( ! $temp ) { |
|
3638 | + if (!$temp) { |
|
3639 | 3639 | $this->save(); |
3640 | 3640 | } |
3641 | 3641 | |
@@ -3649,11 +3649,11 @@ discard block |
||
3649 | 3649 | |
3650 | 3650 | $discount_code = $this->get_discount_code(); |
3651 | 3651 | |
3652 | - if ( empty( $discount_code ) ) { |
|
3652 | + if (empty($discount_code)) { |
|
3653 | 3653 | return false; |
3654 | 3654 | } |
3655 | 3655 | |
3656 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
3656 | + $discount = wpinv_get_discount_obj($discount_code); |
|
3657 | 3657 | |
3658 | 3658 | // Ensure it is active. |
3659 | 3659 | return $discount->exists(); |
@@ -3664,7 +3664,7 @@ discard block |
||
3664 | 3664 | * Refunds an invoice. |
3665 | 3665 | */ |
3666 | 3666 | public function refund() { |
3667 | - $this->set_status( 'wpi-refunded' ); |
|
3667 | + $this->set_status('wpi-refunded'); |
|
3668 | 3668 | $this->save(); |
3669 | 3669 | } |
3670 | 3670 | |
@@ -3673,56 +3673,56 @@ discard block |
||
3673 | 3673 | * |
3674 | 3674 | * @param string $transaction_id |
3675 | 3675 | */ |
3676 | - public function mark_paid( $transaction_id = null, $note = '' ) { |
|
3676 | + public function mark_paid($transaction_id = null, $note = '') { |
|
3677 | 3677 | |
3678 | 3678 | // Set the transaction id. |
3679 | - if ( empty( $transaction_id ) ) { |
|
3679 | + if (empty($transaction_id)) { |
|
3680 | 3680 | $transaction_id = $this->generate_key('trans_'); |
3681 | 3681 | } |
3682 | 3682 | |
3683 | - if ( ! $this->get_transaction_id() ) { |
|
3684 | - $this->set_transaction_id( $transaction_id ); |
|
3683 | + if (!$this->get_transaction_id()) { |
|
3684 | + $this->set_transaction_id($transaction_id); |
|
3685 | 3685 | } |
3686 | 3686 | |
3687 | - if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) { |
|
3687 | + if ($this->is_paid() && 'wpi-processing' != $this->get_status()) { |
|
3688 | 3688 | return $this->save(); |
3689 | 3689 | } |
3690 | 3690 | |
3691 | 3691 | // Set the completed date. |
3692 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
3692 | + $this->set_date_completed(current_time('mysql')); |
|
3693 | 3693 | |
3694 | 3694 | // Set the new status. |
3695 | - if ( $this->is_renewal() ) { |
|
3695 | + if ($this->is_renewal()) { |
|
3696 | 3696 | |
3697 | 3697 | $_note = sprintf( |
3698 | - __( 'Renewed via %s', 'invoicing' ), |
|
3699 | - $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
3698 | + __('Renewed via %s', 'invoicing'), |
|
3699 | + $this->get_gateway_title() . empty($note) ? '' : " ($note)" |
|
3700 | 3700 | ); |
3701 | 3701 | |
3702 | - if ( 'none' == $this->get_gateway() ) { |
|
3702 | + if ('none' == $this->get_gateway()) { |
|
3703 | 3703 | $_note = $note; |
3704 | 3704 | } |
3705 | 3705 | |
3706 | - $this->set_status( 'wpi-renewal', $_note ); |
|
3706 | + $this->set_status('wpi-renewal', $_note); |
|
3707 | 3707 | |
3708 | 3708 | } else { |
3709 | 3709 | |
3710 | 3710 | $_note = sprintf( |
3711 | - __( 'Paid via %s', 'invoicing' ), |
|
3712 | - $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
3711 | + __('Paid via %s', 'invoicing'), |
|
3712 | + $this->get_gateway_title() . empty($note) ? '' : " ($note)" |
|
3713 | 3713 | ); |
3714 | 3714 | |
3715 | - if ( 'none' == $this->get_gateway() ) { |
|
3715 | + if ('none' == $this->get_gateway()) { |
|
3716 | 3716 | $_note = $note; |
3717 | 3717 | } |
3718 | 3718 | |
3719 | - $this->set_status( 'publish',$_note ); |
|
3719 | + $this->set_status('publish', $_note); |
|
3720 | 3720 | |
3721 | 3721 | } |
3722 | 3722 | |
3723 | 3723 | // Set checkout mode. |
3724 | - $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live'; |
|
3725 | - $this->set_mode( $mode ); |
|
3724 | + $mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live'; |
|
3725 | + $this->set_mode($mode); |
|
3726 | 3726 | |
3727 | 3727 | // Save the invoice. |
3728 | 3728 | $this->save(); |
@@ -3748,9 +3748,9 @@ discard block |
||
3748 | 3748 | * Clears the subscription's cache. |
3749 | 3749 | */ |
3750 | 3750 | public function clear_cache() { |
3751 | - wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' ); |
|
3752 | - wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' ); |
|
3753 | - wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' ); |
|
3751 | + wp_cache_delete($this->get_key(), 'getpaid_invoice_keys_to_invoice_ids'); |
|
3752 | + wp_cache_delete($this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids'); |
|
3753 | + wp_cache_delete($this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids'); |
|
3754 | 3754 | } |
3755 | 3755 | |
3756 | 3756 | } |