@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | class WPInv_EUVat { |
10 | 10 | |
@@ -28,35 +28,35 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public static function section_vat_settings() {} |
30 | 30 | |
31 | - public static function get_eu_states( $sort = true ) { |
|
32 | - $eu_states = array( 'AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GB', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE' ); |
|
33 | - if ( $sort ) { |
|
34 | - $sort = sort( $eu_states ); |
|
31 | + public static function get_eu_states($sort = true) { |
|
32 | + $eu_states = array('AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GB', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE'); |
|
33 | + if ($sort) { |
|
34 | + $sort = sort($eu_states); |
|
35 | 35 | } |
36 | 36 | |
37 | - return apply_filters( 'wpinv_get_eu_states', $eu_states, $sort ); |
|
37 | + return apply_filters('wpinv_get_eu_states', $eu_states, $sort); |
|
38 | 38 | } |
39 | 39 | |
40 | - public static function get_gst_countries( $sort = true ) { |
|
41 | - $gst_countries = array( 'AU', 'NZ', 'CA', 'CN' ); |
|
40 | + public static function get_gst_countries($sort = true) { |
|
41 | + $gst_countries = array('AU', 'NZ', 'CA', 'CN'); |
|
42 | 42 | |
43 | - if ( $sort ) { |
|
44 | - $sort = sort( $gst_countries ); |
|
43 | + if ($sort) { |
|
44 | + $sort = sort($gst_countries); |
|
45 | 45 | } |
46 | 46 | |
47 | - return apply_filters( 'wpinv_get_gst_countries', $gst_countries, $sort ); |
|
47 | + return apply_filters('wpinv_get_gst_countries', $gst_countries, $sort); |
|
48 | 48 | } |
49 | 49 | |
50 | - public static function is_eu_state( $country_code ) { |
|
51 | - $return = !empty( $country_code ) && in_array( strtoupper( $country_code ), self::get_eu_states() ) ? true : false; |
|
50 | + public static function is_eu_state($country_code) { |
|
51 | + $return = !empty($country_code) && in_array(strtoupper($country_code), self::get_eu_states()) ? true : false; |
|
52 | 52 | |
53 | - return apply_filters( 'wpinv_is_eu_state', $return, $country_code ); |
|
53 | + return apply_filters('wpinv_is_eu_state', $return, $country_code); |
|
54 | 54 | } |
55 | 55 | |
56 | - public static function is_gst_country( $country_code ) { |
|
57 | - $return = !empty( $country_code ) && in_array( strtoupper( $country_code ), self::get_gst_countries() ) ? true : false; |
|
56 | + public static function is_gst_country($country_code) { |
|
57 | + $return = !empty($country_code) && in_array(strtoupper($country_code), self::get_gst_countries()) ? true : false; |
|
58 | 58 | |
59 | - return apply_filters( 'wpinv_is_gst_country', $return, $country_code ); |
|
59 | + return apply_filters('wpinv_is_gst_country', $return, $country_code); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | /** |
68 | 68 | * @deprecated |
69 | 69 | */ |
70 | - public function load_vat_scripts(){} |
|
70 | + public function load_vat_scripts() {} |
|
71 | 71 | |
72 | 72 | /** |
73 | 73 | * @deprecated |
@@ -207,26 +207,26 @@ discard block |
||
207 | 207 | * Retrieves the vat name. |
208 | 208 | */ |
209 | 209 | public function get_vat_name() { |
210 | - $vat_name = wpinv_get_option( 'vat_name' ); |
|
211 | - return empty( $vat_name ) ? __( 'VAT', 'invoicing' ) : sanitize_text_field( $vat_name ); |
|
210 | + $vat_name = wpinv_get_option('vat_name'); |
|
211 | + return empty($vat_name) ? __('VAT', 'invoicing') : sanitize_text_field($vat_name); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | public static function get_company_name() { |
215 | - $company_name = wpinv_get_option( 'vat_company_name' ); |
|
215 | + $company_name = wpinv_get_option('vat_company_name'); |
|
216 | 216 | |
217 | - return apply_filters( 'wpinv_get_owner_company_name', $company_name ); |
|
217 | + return apply_filters('wpinv_get_owner_company_name', $company_name); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | public static function get_vat_number() { |
221 | - $vat_number = wpinv_get_option( 'vat_number' ); |
|
221 | + $vat_number = wpinv_get_option('vat_number'); |
|
222 | 222 | |
223 | - return apply_filters( 'wpinv_get_owner_vat_number', $vat_number ); |
|
223 | + return apply_filters('wpinv_get_owner_vat_number', $vat_number); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | public static function is_vat_validated() { |
227 | - $validated = self::get_vat_number() && wpinv_get_option( 'vat_valid' ); |
|
227 | + $validated = self::get_vat_number() && wpinv_get_option('vat_valid'); |
|
228 | 228 | |
229 | - return apply_filters( 'wpinv_is_owner_vat_validated', $validated ); |
|
229 | + return apply_filters('wpinv_is_owner_vat_validated', $validated); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -237,8 +237,8 @@ discard block |
||
237 | 237 | /** |
238 | 238 | * @deprecated |
239 | 239 | */ |
240 | - public static function offline_check( $vat_number ) { |
|
241 | - return wpinv_regex_validate_vat_number( $vat_number ); |
|
240 | + public static function offline_check($vat_number) { |
|
241 | + return wpinv_regex_validate_vat_number($vat_number); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
@@ -269,32 +269,32 @@ discard block |
||
269 | 269 | public static function tax_label() {} |
270 | 270 | |
271 | 271 | public static function standard_rates_label() { |
272 | - return __( 'Standard Rates', 'invoicing' ); |
|
272 | + return __('Standard Rates', 'invoicing'); |
|
273 | 273 | } |
274 | 274 | |
275 | - public static function get_rate_classes( $with_desc = false ) { |
|
276 | - $rate_classes_option = get_option( '_wpinv_vat_rate_classes', true ); |
|
277 | - $classes = maybe_unserialize( $rate_classes_option ); |
|
275 | + public static function get_rate_classes($with_desc = false) { |
|
276 | + $rate_classes_option = get_option('_wpinv_vat_rate_classes', true); |
|
277 | + $classes = maybe_unserialize($rate_classes_option); |
|
278 | 278 | |
279 | - if ( empty( $classes ) || !is_array( $classes ) ) { |
|
279 | + if (empty($classes) || !is_array($classes)) { |
|
280 | 280 | $classes = array(); |
281 | 281 | } |
282 | 282 | |
283 | 283 | $rate_classes = array(); |
284 | - if ( !array_key_exists( '_standard', $classes ) ) { |
|
285 | - if ( $with_desc ) { |
|
286 | - $rate_classes['_standard'] = array( 'name' => self::standard_rates_label(), 'desc' => __( 'EU member states standard VAT rates', 'invoicing' ) ); |
|
284 | + if (!array_key_exists('_standard', $classes)) { |
|
285 | + if ($with_desc) { |
|
286 | + $rate_classes['_standard'] = array('name' => self::standard_rates_label(), 'desc' => __('EU member states standard VAT rates', 'invoicing')); |
|
287 | 287 | } else { |
288 | 288 | $rate_classes['_standard'] = self::standard_rates_label(); |
289 | 289 | } |
290 | 290 | } |
291 | 291 | |
292 | - foreach ( $classes as $key => $class ) { |
|
293 | - $name = !empty( $class['name'] ) ? __( $class['name'], 'invoicing' ) : $key; |
|
294 | - $desc = !empty( $class['desc'] ) ? __( $class['desc'], 'invoicing' ) : ''; |
|
292 | + foreach ($classes as $key => $class) { |
|
293 | + $name = !empty($class['name']) ? __($class['name'], 'invoicing') : $key; |
|
294 | + $desc = !empty($class['desc']) ? __($class['desc'], 'invoicing') : ''; |
|
295 | 295 | |
296 | - if ( $with_desc ) { |
|
297 | - $rate_classes[$key] = array( 'name' => $name, 'desc' => $desc ); |
|
296 | + if ($with_desc) { |
|
297 | + $rate_classes[$key] = array('name' => $name, 'desc' => $desc); |
|
298 | 298 | } else { |
299 | 299 | $rate_classes[$key] = $name; |
300 | 300 | } |
@@ -305,15 +305,15 @@ discard block |
||
305 | 305 | |
306 | 306 | public static function get_all_classes() { |
307 | 307 | $classes = self::get_rate_classes(); |
308 | - $classes['_exempt'] = __( 'Exempt (0%)', 'invoicing' ); |
|
308 | + $classes['_exempt'] = __('Exempt (0%)', 'invoicing'); |
|
309 | 309 | |
310 | - return apply_filters( 'wpinv_vat_get_all_classes', $classes ); |
|
310 | + return apply_filters('wpinv_vat_get_all_classes', $classes); |
|
311 | 311 | } |
312 | 312 | |
313 | - public static function get_class_desc( $rate_class ) { |
|
314 | - $rate_classes = self::get_rate_classes( true ); |
|
313 | + public static function get_class_desc($rate_class) { |
|
314 | + $rate_classes = self::get_rate_classes(true); |
|
315 | 315 | |
316 | - if ( !empty( $rate_classes ) && isset( $rate_classes[$rate_class] ) && isset( $rate_classes[$rate_class]['desc'] ) ) { |
|
316 | + if (!empty($rate_classes) && isset($rate_classes[$rate_class]) && isset($rate_classes[$rate_class]['desc'])) { |
|
317 | 317 | return $rate_classes[$rate_class]['desc']; |
318 | 318 | } |
319 | 319 | |
@@ -327,26 +327,26 @@ discard block |
||
327 | 327 | |
328 | 328 | public static function get_rules() { |
329 | 329 | $vat_rules = array( |
330 | - 'digital' => __( 'Digital Product', 'invoicing' ), |
|
331 | - 'physical' => __( 'Physical Product', 'invoicing' ), |
|
332 | - '_exempt' => __( 'Tax-Free Product', 'invoicing' ), |
|
330 | + 'digital' => __('Digital Product', 'invoicing'), |
|
331 | + 'physical' => __('Physical Product', 'invoicing'), |
|
332 | + '_exempt' => __('Tax-Free Product', 'invoicing'), |
|
333 | 333 | ); |
334 | - return apply_filters( 'wpinv_get_vat_rules', $vat_rules ); |
|
334 | + return apply_filters('wpinv_get_vat_rules', $vat_rules); |
|
335 | 335 | } |
336 | 336 | |
337 | - public static function get_vat_rates( $class ) { |
|
338 | - if ( $class === '_standard' ) { |
|
337 | + public static function get_vat_rates($class) { |
|
338 | + if ($class === '_standard') { |
|
339 | 339 | return GetPaid_Tax::get_all_tax_rates(); |
340 | 340 | } |
341 | 341 | |
342 | 342 | $rates = self::get_non_standard_rates(); |
343 | 343 | |
344 | - return array_key_exists( $class, $rates ) ? $rates[$class] : array(); |
|
344 | + return array_key_exists($class, $rates) ? $rates[$class] : array(); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | public static function get_non_standard_rates() { |
348 | - $option = get_option( 'wpinv_vat_rates', array()); |
|
349 | - return is_array( $option ) ? $option : array(); |
|
348 | + $option = get_option('wpinv_vat_rates', array()); |
|
349 | + return is_array($option) ? $option : array(); |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | /** |
@@ -363,41 +363,41 @@ discard block |
||
363 | 363 | return wpinv_use_taxes(); |
364 | 364 | } |
365 | 365 | |
366 | - public static function get_item_class( $postID ) { |
|
367 | - $class = get_post_meta( $postID, '_wpinv_vat_class', true ); |
|
366 | + public static function get_item_class($postID) { |
|
367 | + $class = get_post_meta($postID, '_wpinv_vat_class', true); |
|
368 | 368 | |
369 | - if ( empty( $class ) ) { |
|
369 | + if (empty($class)) { |
|
370 | 370 | $class = '_standard'; |
371 | 371 | } |
372 | 372 | |
373 | - return apply_filters( 'wpinv_get_item_vat_class', $class, $postID ); |
|
373 | + return apply_filters('wpinv_get_item_vat_class', $class, $postID); |
|
374 | 374 | } |
375 | 375 | |
376 | - public static function item_class_label( $postID ) { |
|
376 | + public static function item_class_label($postID) { |
|
377 | 377 | $vat_classes = self::get_all_classes(); |
378 | 378 | |
379 | - $class = self::get_item_class( $postID ); |
|
380 | - $class = isset( $vat_classes[$class] ) ? $vat_classes[$class] : __( $class, 'invoicing' ); |
|
379 | + $class = self::get_item_class($postID); |
|
380 | + $class = isset($vat_classes[$class]) ? $vat_classes[$class] : __($class, 'invoicing'); |
|
381 | 381 | |
382 | - return apply_filters( 'wpinv_item_class_label', $class, $postID ); |
|
382 | + return apply_filters('wpinv_item_class_label', $class, $postID); |
|
383 | 383 | } |
384 | 384 | |
385 | - public static function get_item_rule( $postID ) { |
|
386 | - $rule_type = get_post_meta( $postID, '_wpinv_vat_rule', true ); |
|
385 | + public static function get_item_rule($postID) { |
|
386 | + $rule_type = get_post_meta($postID, '_wpinv_vat_rule', true); |
|
387 | 387 | |
388 | - if ( empty( $rule_type ) ) { |
|
388 | + if (empty($rule_type)) { |
|
389 | 389 | $rule_type = 'digital'; |
390 | 390 | } |
391 | 391 | |
392 | - return apply_filters( 'wpinv_item_get_vat_rule', $rule_type, $postID ); |
|
392 | + return apply_filters('wpinv_item_get_vat_rule', $rule_type, $postID); |
|
393 | 393 | } |
394 | 394 | |
395 | - public static function item_rule_label( $postID ) { |
|
395 | + public static function item_rule_label($postID) { |
|
396 | 396 | $vat_rules = self::get_rules(); |
397 | - $vat_rule = self::get_item_rule( $postID ); |
|
398 | - $vat_rule = isset( $vat_rules[$vat_rule] ) ? $vat_rules[$vat_rule] : $vat_rule; |
|
397 | + $vat_rule = self::get_item_rule($postID); |
|
398 | + $vat_rule = isset($vat_rules[$vat_rule]) ? $vat_rules[$vat_rule] : $vat_rule; |
|
399 | 399 | |
400 | - return apply_filters( 'wpinv_item_rule_label', $vat_rule, $postID ); |
|
400 | + return apply_filters('wpinv_item_rule_label', $vat_rule, $postID); |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | /** |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @since 1.0.0 |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Retrieves all default settings. |
@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | function wpinv_get_settings() { |
17 | 17 | $defaults = array(); |
18 | 18 | |
19 | - foreach ( array_values( wpinv_get_registered_settings() ) as $tab_settings ) { |
|
19 | + foreach (array_values(wpinv_get_registered_settings()) as $tab_settings) { |
|
20 | 20 | |
21 | - foreach ( array_values( $tab_settings ) as $section_settings ) { |
|
21 | + foreach (array_values($tab_settings) as $section_settings) { |
|
22 | 22 | |
23 | - foreach ( $section_settings as $key => $setting ) { |
|
24 | - if ( isset( $setting['std'] ) ) { |
|
25 | - $defaults[ $key ] = $setting['std']; |
|
23 | + foreach ($section_settings as $key => $setting) { |
|
24 | + if (isset($setting['std'])) { |
|
25 | + $defaults[$key] = $setting['std']; |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | global $wpinv_options; |
44 | 44 | |
45 | 45 | // Try fetching the saved options. |
46 | - if ( ! is_array( $wpinv_options ) ) { |
|
47 | - $wpinv_options = get_option( 'wpinv_settings' ); |
|
46 | + if (!is_array($wpinv_options)) { |
|
47 | + $wpinv_options = get_option('wpinv_settings'); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | // If that fails, don't fetch the default settings to prevent a loop. |
51 | - if ( ! is_array( $wpinv_options ) ) { |
|
51 | + if (!is_array($wpinv_options)) { |
|
52 | 52 | $wpinv_options = array(); |
53 | 53 | } |
54 | 54 | |
@@ -62,13 +62,13 @@ discard block |
||
62 | 62 | * @param mixed $default The default value to use if the setting has not been set. |
63 | 63 | * @return mixed |
64 | 64 | */ |
65 | -function wpinv_get_option( $key = '', $default = false ) { |
|
65 | +function wpinv_get_option($key = '', $default = false) { |
|
66 | 66 | |
67 | 67 | $options = wpinv_get_options(); |
68 | - $value = isset( $options[ $key ] ) ? $options[ $key ] : $default; |
|
69 | - $value = apply_filters( 'wpinv_get_option', $value, $key, $default ); |
|
68 | + $value = isset($options[$key]) ? $options[$key] : $default; |
|
69 | + $value = apply_filters('wpinv_get_option', $value, $key, $default); |
|
70 | 70 | |
71 | - return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default ); |
|
71 | + return apply_filters('wpinv_get_option_' . $key, $value, $key, $default); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | * @param array $options the new options. |
78 | 78 | * @return bool |
79 | 79 | */ |
80 | -function wpinv_update_options( $options ) { |
|
80 | +function wpinv_update_options($options) { |
|
81 | 81 | global $wpinv_options; |
82 | 82 | |
83 | 83 | // update the option. |
84 | - if ( is_array( $options ) && update_option( 'wpinv_settings', $options ) ) { |
|
84 | + if (is_array($options) && update_option('wpinv_settings', $options)) { |
|
85 | 85 | $wpinv_options = $options; |
86 | 86 | return true; |
87 | 87 | } |
@@ -96,24 +96,24 @@ discard block |
||
96 | 96 | * @param mixed $value The setting value. |
97 | 97 | * @return bool |
98 | 98 | */ |
99 | -function wpinv_update_option( $key = '', $value = false ) { |
|
99 | +function wpinv_update_option($key = '', $value = false) { |
|
100 | 100 | |
101 | 101 | // If no key, exit. |
102 | - if ( empty( $key ) ) { |
|
102 | + if (empty($key)) { |
|
103 | 103 | return false; |
104 | 104 | } |
105 | 105 | |
106 | 106 | // Maybe delete the option instead. |
107 | - if ( is_null( $value ) ) { |
|
108 | - return wpinv_delete_option( $key ); |
|
107 | + if (is_null($value)) { |
|
108 | + return wpinv_delete_option($key); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | // Prepare the new options. |
112 | 112 | $options = wpinv_get_options(); |
113 | - $options[ $key ] = apply_filters( 'wpinv_update_option', $value, $key ); |
|
113 | + $options[$key] = apply_filters('wpinv_update_option', $value, $key); |
|
114 | 114 | |
115 | 115 | // Save the new options. |
116 | - return wpinv_update_options( $options ); |
|
116 | + return wpinv_update_options($options); |
|
117 | 117 | |
118 | 118 | } |
119 | 119 | |
@@ -123,18 +123,18 @@ discard block |
||
123 | 123 | * @param string $key the setting key. |
124 | 124 | * @return bool |
125 | 125 | */ |
126 | -function wpinv_delete_option( $key = '' ) { |
|
126 | +function wpinv_delete_option($key = '') { |
|
127 | 127 | |
128 | 128 | // If no key, exit |
129 | - if ( empty( $key ) ) { |
|
129 | + if (empty($key)) { |
|
130 | 130 | return false; |
131 | 131 | } |
132 | 132 | |
133 | 133 | $options = wpinv_get_options(); |
134 | 134 | |
135 | - if ( isset( $options[ $key ] ) ) { |
|
136 | - unset( $options[ $key ] ); |
|
137 | - return wpinv_update_options( $options ); |
|
135 | + if (isset($options[$key])) { |
|
136 | + unset($options[$key]); |
|
137 | + return wpinv_update_options($options); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | return true; |
@@ -148,14 +148,14 @@ discard block |
||
148 | 148 | function wpinv_register_settings() { |
149 | 149 | |
150 | 150 | // Loop through all tabs. |
151 | - foreach ( wpinv_get_registered_settings() as $tab => $sections ) { |
|
151 | + foreach (wpinv_get_registered_settings() as $tab => $sections) { |
|
152 | 152 | |
153 | 153 | // In each tab, loop through sections. |
154 | - foreach ( $sections as $section => $settings ) { |
|
154 | + foreach ($sections as $section => $settings) { |
|
155 | 155 | |
156 | 156 | // Check for backwards compatibility |
157 | - $section_tabs = wpinv_get_settings_tab_sections( $tab ); |
|
158 | - if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) { |
|
157 | + $section_tabs = wpinv_get_settings_tab_sections($tab); |
|
158 | + if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) { |
|
159 | 159 | $section = 'main'; |
160 | 160 | $settings = $sections; |
161 | 161 | } |
@@ -168,9 +168,9 @@ discard block |
||
168 | 168 | 'wpinv_settings_' . $tab . '_' . $section |
169 | 169 | ); |
170 | 170 | |
171 | - foreach ( $settings as $option ) { |
|
172 | - if ( ! empty( $option['id'] ) ) { |
|
173 | - wpinv_register_settings_option( $tab, $section, $option ); |
|
171 | + foreach ($settings as $option) { |
|
172 | + if (!empty($option['id'])) { |
|
173 | + wpinv_register_settings_option($tab, $section, $option); |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
@@ -178,9 +178,9 @@ discard block |
||
178 | 178 | } |
179 | 179 | |
180 | 180 | // Creates our settings in the options table. |
181 | - register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' ); |
|
181 | + register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize'); |
|
182 | 182 | } |
183 | -add_action( 'admin_init', 'wpinv_register_settings' ); |
|
183 | +add_action('admin_init', 'wpinv_register_settings'); |
|
184 | 184 | |
185 | 185 | /** |
186 | 186 | * Register a single settings option. |
@@ -190,46 +190,46 @@ discard block |
||
190 | 190 | * @param string $option |
191 | 191 | * |
192 | 192 | */ |
193 | -function wpinv_register_settings_option( $tab, $section, $option ) { |
|
193 | +function wpinv_register_settings_option($tab, $section, $option) { |
|
194 | 194 | |
195 | - $name = isset( $option['name'] ) ? $option['name'] : ''; |
|
195 | + $name = isset($option['name']) ? $option['name'] : ''; |
|
196 | 196 | $cb = "wpinv_{$option['type']}_callback"; |
197 | 197 | $section = "wpinv_settings_{$tab}_$section"; |
198 | 198 | |
199 | - if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) { |
|
200 | - $tip = esc_attr( $option['desc'] ); |
|
199 | + if (isset($option['desc']) && !empty($option['help-tip'])) { |
|
200 | + $tip = esc_attr($option['desc']); |
|
201 | 201 | $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
202 | - unset( $option['desc'] ); |
|
202 | + unset($option['desc']); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | // Loop through all tabs. |
206 | 206 | add_settings_field( |
207 | 207 | 'wpinv_settings[' . $option['id'] . ']', |
208 | 208 | $name, |
209 | - function_exists( $cb ) ? $cb : 'wpinv_missing_callback', |
|
209 | + function_exists($cb) ? $cb : 'wpinv_missing_callback', |
|
210 | 210 | $section, |
211 | 211 | $section, |
212 | 212 | array( |
213 | 213 | 'section' => $section, |
214 | - 'id' => isset( $option['id'] ) ? $option['id'] : null, |
|
215 | - 'desc' => isset( $option['desc'] ) ? $option['desc'] : '', |
|
214 | + 'id' => isset($option['id']) ? $option['id'] : null, |
|
215 | + 'desc' => isset($option['desc']) ? $option['desc'] : '', |
|
216 | 216 | 'name' => $name, |
217 | - 'size' => isset( $option['size'] ) ? $option['size'] : null, |
|
218 | - 'options' => isset( $option['options'] ) ? $option['options'] : '', |
|
219 | - 'selected' => isset( $option['selected'] ) ? $option['selected'] : null, |
|
220 | - 'std' => isset( $option['std'] ) ? $option['std'] : '', |
|
221 | - 'min' => isset( $option['min'] ) ? $option['min'] : null, |
|
222 | - 'max' => isset( $option['max'] ) ? $option['max'] : null, |
|
223 | - 'step' => isset( $option['step'] ) ? $option['step'] : null, |
|
224 | - 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null, |
|
225 | - 'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true, |
|
226 | - 'readonly' => isset( $option['readonly'] ) ? $option['readonly'] : false, |
|
227 | - 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
|
228 | - 'onchange' => isset( $option['onchange'] ) ? $option['onchange'] : '', |
|
229 | - 'custom' => isset( $option['custom'] ) ? $option['custom'] : '', |
|
230 | - 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
231 | - 'cols' => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
232 | - 'rows' => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
217 | + 'size' => isset($option['size']) ? $option['size'] : null, |
|
218 | + 'options' => isset($option['options']) ? $option['options'] : '', |
|
219 | + 'selected' => isset($option['selected']) ? $option['selected'] : null, |
|
220 | + 'std' => isset($option['std']) ? $option['std'] : '', |
|
221 | + 'min' => isset($option['min']) ? $option['min'] : null, |
|
222 | + 'max' => isset($option['max']) ? $option['max'] : null, |
|
223 | + 'step' => isset($option['step']) ? $option['step'] : null, |
|
224 | + 'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null, |
|
225 | + 'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true, |
|
226 | + 'readonly' => isset($option['readonly']) ? $option['readonly'] : false, |
|
227 | + 'faux' => isset($option['faux']) ? $option['faux'] : false, |
|
228 | + 'onchange' => isset($option['onchange']) ? $option['onchange'] : '', |
|
229 | + 'custom' => isset($option['custom']) ? $option['custom'] : '', |
|
230 | + 'class' => isset($option['class']) ? $option['class'] : '', |
|
231 | + 'cols' => isset($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
232 | + 'rows' => isset($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
233 | 233 | ) |
234 | 234 | ); |
235 | 235 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * @return array |
242 | 242 | */ |
243 | 243 | function wpinv_get_registered_settings() { |
244 | - return apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ); |
|
244 | + return apply_filters('wpinv_registered_settings', wpinv_get_data('admin-settings')); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -249,135 +249,135 @@ discard block |
||
249 | 249 | * |
250 | 250 | * @return array |
251 | 251 | */ |
252 | -function wpinv_settings_sanitize( $input = array() ) { |
|
252 | +function wpinv_settings_sanitize($input = array()) { |
|
253 | 253 | |
254 | 254 | $wpinv_options = wpinv_get_options(); |
255 | 255 | |
256 | - if ( empty( wp_get_raw_referer() ) ) { |
|
256 | + if (empty(wp_get_raw_referer())) { |
|
257 | 257 | return $input; |
258 | 258 | } |
259 | 259 | |
260 | - wp_parse_str( wp_get_raw_referer(), $referrer ); |
|
260 | + wp_parse_str(wp_get_raw_referer(), $referrer); |
|
261 | 261 | |
262 | 262 | $settings = wpinv_get_registered_settings(); |
263 | - $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
|
264 | - $section = isset( $referrer['section'] ) ? $referrer['section'] : 'main'; |
|
263 | + $tab = isset($referrer['tab']) ? $referrer['tab'] : 'general'; |
|
264 | + $section = isset($referrer['section']) ? $referrer['section'] : 'main'; |
|
265 | 265 | |
266 | 266 | $input = $input ? $input : array(); |
267 | - $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input ); |
|
268 | - $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input ); |
|
267 | + $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input); |
|
268 | + $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input); |
|
269 | 269 | |
270 | 270 | // Loop through each setting being saved and pass it through a sanitization filter |
271 | - foreach ( $input as $key => $value ) { |
|
271 | + foreach ($input as $key => $value) { |
|
272 | 272 | |
273 | 273 | // Get the setting type (checkbox, select, etc) |
274 | - $type = isset( $settings[ $tab ][$section][ $key ]['type'] ) ? $settings[ $tab ][$section][ $key ]['type'] : false; |
|
274 | + $type = isset($settings[$tab][$section][$key]['type']) ? $settings[$tab][$section][$key]['type'] : false; |
|
275 | 275 | |
276 | - if ( $type ) { |
|
276 | + if ($type) { |
|
277 | 277 | // Field type specific filter |
278 | - $input[$key] = apply_filters( 'wpinv_settings_sanitize_' . $type, $value, $key ); |
|
278 | + $input[$key] = apply_filters('wpinv_settings_sanitize_' . $type, $value, $key); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | // General filter |
282 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
282 | + $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key); |
|
283 | 283 | |
284 | 284 | // Key specific filter. |
285 | - $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
285 | + $input[$key] = apply_filters("wpinv_settings_sanitize_$key", $input[$key]); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | // Loop through the whitelist and unset any that are empty for the tab being saved |
289 | - $main_settings = $section == 'main' ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections |
|
290 | - $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array(); |
|
289 | + $main_settings = $section == 'main' ? $settings[$tab] : array(); // Check for extensions that aren't using new sections |
|
290 | + $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array(); |
|
291 | 291 | |
292 | - $found_settings = array_merge( $main_settings, $section_settings ); |
|
292 | + $found_settings = array_merge($main_settings, $section_settings); |
|
293 | 293 | |
294 | - if ( ! empty( $found_settings ) ) { |
|
295 | - foreach ( $found_settings as $key => $value ) { |
|
294 | + if (!empty($found_settings)) { |
|
295 | + foreach ($found_settings as $key => $value) { |
|
296 | 296 | |
297 | 297 | // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work |
298 | - if ( is_numeric( $key ) ) { |
|
298 | + if (is_numeric($key)) { |
|
299 | 299 | $key = $value['id']; |
300 | 300 | } |
301 | 301 | |
302 | - if ( ! isset( $input[ $key ] ) && isset( $wpinv_options[ $key ] ) ) { |
|
303 | - unset( $wpinv_options[ $key ] ); |
|
302 | + if (!isset($input[$key]) && isset($wpinv_options[$key])) { |
|
303 | + unset($wpinv_options[$key]); |
|
304 | 304 | } |
305 | 305 | } |
306 | 306 | } |
307 | 307 | |
308 | 308 | // Merge our new settings with the existing |
309 | - $output = array_merge( $wpinv_options, $input ); |
|
309 | + $output = array_merge($wpinv_options, $input); |
|
310 | 310 | |
311 | - add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' ); |
|
311 | + add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated'); |
|
312 | 312 | |
313 | 313 | return $output; |
314 | 314 | } |
315 | 315 | |
316 | -function wpinv_settings_sanitize_misc_accounting( $input ) { |
|
316 | +function wpinv_settings_sanitize_misc_accounting($input) { |
|
317 | 317 | |
318 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
318 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
319 | 319 | return $input; |
320 | 320 | } |
321 | 321 | |
322 | - if( ! empty( $input['enable_sequential'] ) && !wpinv_get_option( 'enable_sequential' ) ) { |
|
322 | + if (!empty($input['enable_sequential']) && !wpinv_get_option('enable_sequential')) { |
|
323 | 323 | // Shows an admin notice about upgrading previous order numbers |
324 | - getpaid_session()->set( 'upgrade_sequential', '1' ); |
|
324 | + getpaid_session()->set('upgrade_sequential', '1'); |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | return $input; |
328 | 328 | } |
329 | -add_filter( 'wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting' ); |
|
329 | +add_filter('wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting'); |
|
330 | 330 | |
331 | -function wpinv_settings_sanitize_tax_rates( $input ) { |
|
332 | - if( ! wpinv_current_user_can_manage_invoicing() ) { |
|
331 | +function wpinv_settings_sanitize_tax_rates($input) { |
|
332 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
333 | 333 | return $input; |
334 | 334 | } |
335 | 335 | |
336 | - $new_rates = ! empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array(); |
|
336 | + $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array(); |
|
337 | 337 | $tax_rates = array(); |
338 | 338 | |
339 | - foreach ( $new_rates as $rate ) { |
|
339 | + foreach ($new_rates as $rate) { |
|
340 | 340 | |
341 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
342 | - $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
343 | - $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
344 | - $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
345 | - $rate['global'] = empty( $rate['state'] ); |
|
341 | + $rate['rate'] = wpinv_sanitize_amount($rate['rate']); |
|
342 | + $rate['name'] = sanitize_text_field($rate['name']); |
|
343 | + $rate['state'] = sanitize_text_field($rate['state']); |
|
344 | + $rate['country'] = sanitize_text_field($rate['country']); |
|
345 | + $rate['global'] = empty($rate['state']); |
|
346 | 346 | $tax_rates[] = $rate; |
347 | 347 | |
348 | 348 | } |
349 | 349 | |
350 | - update_option( 'wpinv_tax_rates', $tax_rates ); |
|
350 | + update_option('wpinv_tax_rates', $tax_rates); |
|
351 | 351 | |
352 | 352 | return $input; |
353 | 353 | } |
354 | -add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' ); |
|
354 | +add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates'); |
|
355 | 355 | |
356 | -function wpinv_sanitize_text_field( $input ) { |
|
357 | - return trim( $input ); |
|
356 | +function wpinv_sanitize_text_field($input) { |
|
357 | + return trim($input); |
|
358 | 358 | } |
359 | -add_filter( 'wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field' ); |
|
359 | +add_filter('wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field'); |
|
360 | 360 | |
361 | 361 | function wpinv_get_settings_tabs() { |
362 | 362 | $tabs = array(); |
363 | - $tabs['general'] = __( 'General', 'invoicing' ); |
|
364 | - $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
|
365 | - $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
|
366 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
367 | - $tabs['privacy'] = __( 'Privacy', 'invoicing' ); |
|
368 | - $tabs['misc'] = __( 'Misc', 'invoicing' ); |
|
369 | - $tabs['tools'] = __( 'Tools', 'invoicing' ); |
|
370 | - |
|
371 | - return apply_filters( 'wpinv_settings_tabs', $tabs ); |
|
363 | + $tabs['general'] = __('General', 'invoicing'); |
|
364 | + $tabs['gateways'] = __('Payment Gateways', 'invoicing'); |
|
365 | + $tabs['taxes'] = __('Taxes', 'invoicing'); |
|
366 | + $tabs['emails'] = __('Emails', 'invoicing'); |
|
367 | + $tabs['privacy'] = __('Privacy', 'invoicing'); |
|
368 | + $tabs['misc'] = __('Misc', 'invoicing'); |
|
369 | + $tabs['tools'] = __('Tools', 'invoicing'); |
|
370 | + |
|
371 | + return apply_filters('wpinv_settings_tabs', $tabs); |
|
372 | 372 | } |
373 | 373 | |
374 | -function wpinv_get_settings_tab_sections( $tab = false ) { |
|
374 | +function wpinv_get_settings_tab_sections($tab = false) { |
|
375 | 375 | $tabs = false; |
376 | 376 | $sections = wpinv_get_registered_settings_sections(); |
377 | 377 | |
378 | - if( $tab && ! empty( $sections[ $tab ] ) ) { |
|
379 | - $tabs = $sections[ $tab ]; |
|
380 | - } else if ( $tab ) { |
|
378 | + if ($tab && !empty($sections[$tab])) { |
|
379 | + $tabs = $sections[$tab]; |
|
380 | + } else if ($tab) { |
|
381 | 381 | $tabs = false; |
382 | 382 | } |
383 | 383 | |
@@ -387,88 +387,88 @@ discard block |
||
387 | 387 | function wpinv_get_registered_settings_sections() { |
388 | 388 | static $sections = false; |
389 | 389 | |
390 | - if ( false !== $sections ) { |
|
390 | + if (false !== $sections) { |
|
391 | 391 | return $sections; |
392 | 392 | } |
393 | 393 | |
394 | 394 | $sections = array( |
395 | - 'general' => apply_filters( 'wpinv_settings_sections_general', array( |
|
396 | - 'main' => __( 'General Settings', 'invoicing' ), |
|
397 | - 'currency_section' => __( 'Currency Settings', 'invoicing' ), |
|
398 | - 'labels' => __( 'Label Texts', 'invoicing' ), |
|
399 | - ) ), |
|
400 | - 'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array( |
|
401 | - 'main' => __( 'Gateway Settings', 'invoicing' ), |
|
402 | - ) ), |
|
403 | - 'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array( |
|
404 | - 'main' => __( 'Tax Settings', 'invoicing' ), |
|
405 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
406 | - 'vat' => __( 'EU VAT Settings', 'invoicing' ) |
|
407 | - ) ), |
|
408 | - 'emails' => apply_filters( 'wpinv_settings_sections_emails', array( |
|
409 | - 'main' => __( 'Email Settings', 'invoicing' ), |
|
410 | - ) ), |
|
411 | - 'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array( |
|
412 | - 'main' => __( 'Privacy policy', 'invoicing' ), |
|
413 | - ) ), |
|
414 | - 'misc' => apply_filters( 'wpinv_settings_sections_misc', array( |
|
415 | - 'main' => __( 'Miscellaneous', 'invoicing' ), |
|
416 | - 'custom-css' => __( 'Custom CSS', 'invoicing' ), |
|
417 | - ) ), |
|
418 | - 'tools' => apply_filters( 'wpinv_settings_sections_tools', array( |
|
419 | - 'main' => __( 'Diagnostic Tools', 'invoicing' ), |
|
420 | - ) ), |
|
395 | + 'general' => apply_filters('wpinv_settings_sections_general', array( |
|
396 | + 'main' => __('General Settings', 'invoicing'), |
|
397 | + 'currency_section' => __('Currency Settings', 'invoicing'), |
|
398 | + 'labels' => __('Label Texts', 'invoicing'), |
|
399 | + )), |
|
400 | + 'gateways' => apply_filters('wpinv_settings_sections_gateways', array( |
|
401 | + 'main' => __('Gateway Settings', 'invoicing'), |
|
402 | + )), |
|
403 | + 'taxes' => apply_filters('wpinv_settings_sections_taxes', array( |
|
404 | + 'main' => __('Tax Settings', 'invoicing'), |
|
405 | + 'rates' => __('Tax Rates', 'invoicing'), |
|
406 | + 'vat' => __('EU VAT Settings', 'invoicing') |
|
407 | + )), |
|
408 | + 'emails' => apply_filters('wpinv_settings_sections_emails', array( |
|
409 | + 'main' => __('Email Settings', 'invoicing'), |
|
410 | + )), |
|
411 | + 'privacy' => apply_filters('wpinv_settings_sections_privacy', array( |
|
412 | + 'main' => __('Privacy policy', 'invoicing'), |
|
413 | + )), |
|
414 | + 'misc' => apply_filters('wpinv_settings_sections_misc', array( |
|
415 | + 'main' => __('Miscellaneous', 'invoicing'), |
|
416 | + 'custom-css' => __('Custom CSS', 'invoicing'), |
|
417 | + )), |
|
418 | + 'tools' => apply_filters('wpinv_settings_sections_tools', array( |
|
419 | + 'main' => __('Diagnostic Tools', 'invoicing'), |
|
420 | + )), |
|
421 | 421 | ); |
422 | 422 | |
423 | - $sections = apply_filters( 'wpinv_settings_sections', $sections ); |
|
423 | + $sections = apply_filters('wpinv_settings_sections', $sections); |
|
424 | 424 | |
425 | 425 | return $sections; |
426 | 426 | } |
427 | 427 | |
428 | -function wpinv_get_pages( $with_slug = false, $default_label = NULL ) { |
|
428 | +function wpinv_get_pages($with_slug = false, $default_label = NULL) { |
|
429 | 429 | $pages_options = array(); |
430 | 430 | |
431 | - if( $default_label !== NULL && $default_label !== false ) { |
|
432 | - $pages_options = array( '' => $default_label ); // Blank option |
|
431 | + if ($default_label !== NULL && $default_label !== false) { |
|
432 | + $pages_options = array('' => $default_label); // Blank option |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | $pages = get_pages(); |
436 | - if ( $pages ) { |
|
437 | - foreach ( $pages as $page ) { |
|
436 | + if ($pages) { |
|
437 | + foreach ($pages as $page) { |
|
438 | 438 | $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
439 | - $pages_options[ $page->ID ] = $title; |
|
439 | + $pages_options[$page->ID] = $title; |
|
440 | 440 | } |
441 | 441 | } |
442 | 442 | |
443 | 443 | return $pages_options; |
444 | 444 | } |
445 | 445 | |
446 | -function wpinv_header_callback( $args ) { |
|
447 | - if ( !empty( $args['desc'] ) ) { |
|
446 | +function wpinv_header_callback($args) { |
|
447 | + if (!empty($args['desc'])) { |
|
448 | 448 | echo $args['desc']; |
449 | 449 | } |
450 | 450 | } |
451 | 451 | |
452 | -function wpinv_hidden_callback( $args ) { |
|
452 | +function wpinv_hidden_callback($args) { |
|
453 | 453 | global $wpinv_options; |
454 | 454 | |
455 | - if ( isset( $args['set_value'] ) ) { |
|
455 | + if (isset($args['set_value'])) { |
|
456 | 456 | $value = $args['set_value']; |
457 | - } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
458 | - $value = $wpinv_options[ $args['id'] ]; |
|
457 | + } elseif (isset($wpinv_options[$args['id']])) { |
|
458 | + $value = $wpinv_options[$args['id']]; |
|
459 | 459 | } else { |
460 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
460 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
461 | 461 | } |
462 | 462 | |
463 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
463 | + if (isset($args['faux']) && true === $args['faux']) { |
|
464 | 464 | $args['readonly'] = true; |
465 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
465 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
466 | 466 | $name = ''; |
467 | 467 | } else { |
468 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
468 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
469 | 469 | } |
470 | 470 | |
471 | - $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
471 | + $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />'; |
|
472 | 472 | |
473 | 473 | echo $html; |
474 | 474 | } |
@@ -476,61 +476,61 @@ discard block |
||
476 | 476 | /** |
477 | 477 | * Displays a checkbox settings callback. |
478 | 478 | */ |
479 | -function wpinv_checkbox_callback( $args ) { |
|
479 | +function wpinv_checkbox_callback($args) { |
|
480 | 480 | |
481 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
482 | - $std = wpinv_get_option( $args['id'], $std ); |
|
483 | - $id = esc_attr( $args['id'] ); |
|
481 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
482 | + $std = wpinv_get_option($args['id'], $std); |
|
483 | + $id = esc_attr($args['id']); |
|
484 | 484 | |
485 | - getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
485 | + getpaid_hidden_field("wpinv_settings[$id]", '0'); |
|
486 | 486 | ?> |
487 | 487 | <fieldset> |
488 | 488 | <label> |
489 | - <input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox"> |
|
490 | - <?php echo wp_kses_post( $args['desc'] ); ?> |
|
489 | + <input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked(empty($std), false); ?> value="1" type="checkbox"> |
|
490 | + <?php echo wp_kses_post($args['desc']); ?> |
|
491 | 491 | </label> |
492 | 492 | </fieldset> |
493 | 493 | <?php |
494 | 494 | } |
495 | 495 | |
496 | -function wpinv_multicheck_callback( $args ) { |
|
496 | +function wpinv_multicheck_callback($args) { |
|
497 | 497 | |
498 | 498 | global $wpinv_options; |
499 | 499 | |
500 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
501 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
500 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
501 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
502 | 502 | |
503 | - if ( ! empty( $args['options'] ) ) { |
|
503 | + if (!empty($args['options'])) { |
|
504 | 504 | |
505 | - $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
506 | - $value = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std; |
|
505 | + $std = isset($args['std']) ? $args['std'] : array(); |
|
506 | + $value = isset($wpinv_options[$args['id']]) ? $wpinv_options[$args['id']] : $std; |
|
507 | 507 | |
508 | 508 | echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">'; |
509 | - foreach( $args['options'] as $key => $option ): |
|
510 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
511 | - if ( in_array( $sanitize_key, $value ) ) { |
|
509 | + foreach ($args['options'] as $key => $option): |
|
510 | + $sanitize_key = wpinv_sanitize_key($key); |
|
511 | + if (in_array($sanitize_key, $value)) { |
|
512 | 512 | $enabled = $sanitize_key; |
513 | 513 | } else { |
514 | 514 | $enabled = NULL; |
515 | 515 | } |
516 | - echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
517 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
516 | + echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/> '; |
|
517 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label></div>'; |
|
518 | 518 | endforeach; |
519 | 519 | echo '</div>'; |
520 | 520 | echo '<p class="description">' . $args['desc'] . '</p>'; |
521 | 521 | } |
522 | 522 | } |
523 | 523 | |
524 | -function wpinv_payment_icons_callback( $args ) { |
|
524 | +function wpinv_payment_icons_callback($args) { |
|
525 | 525 | global $wpinv_options; |
526 | 526 | |
527 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
527 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
528 | 528 | |
529 | - if ( ! empty( $args['options'] ) ) { |
|
530 | - foreach( $args['options'] as $key => $option ) { |
|
531 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
529 | + if (!empty($args['options'])) { |
|
530 | + foreach ($args['options'] as $key => $option) { |
|
531 | + $sanitize_key = wpinv_sanitize_key($key); |
|
532 | 532 | |
533 | - if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
533 | + if (isset($wpinv_options[$args['id']][$key])) { |
|
534 | 534 | $enabled = $option; |
535 | 535 | } else { |
536 | 536 | $enabled = NULL; |
@@ -538,211 +538,211 @@ discard block |
||
538 | 538 | |
539 | 539 | echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
540 | 540 | |
541 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
541 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/> '; |
|
542 | 542 | |
543 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
544 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
543 | + if (wpinv_string_is_image_url($key)) { |
|
544 | + echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
545 | 545 | } else { |
546 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
546 | + $card = strtolower(str_replace(' ', '', $option)); |
|
547 | 547 | |
548 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
549 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
548 | + if (has_filter('wpinv_accepted_payment_' . $card . '_image')) { |
|
549 | + $image = apply_filters('wpinv_accepted_payment_' . $card . '_image', ''); |
|
550 | 550 | } else { |
551 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
551 | + $image = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false); |
|
552 | 552 | $content_dir = WP_CONTENT_DIR; |
553 | 553 | |
554 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
554 | + if (function_exists('wp_normalize_path')) { |
|
555 | 555 | // Replaces backslashes with forward slashes for Windows systems |
556 | - $image = wp_normalize_path( $image ); |
|
557 | - $content_dir = wp_normalize_path( $content_dir ); |
|
556 | + $image = wp_normalize_path($image); |
|
557 | + $content_dir = wp_normalize_path($content_dir); |
|
558 | 558 | } |
559 | 559 | |
560 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
560 | + $image = str_replace($content_dir, content_url(), $image); |
|
561 | 561 | } |
562 | 562 | |
563 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
563 | + echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
564 | 564 | } |
565 | 565 | echo $option . '</label>'; |
566 | 566 | } |
567 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
567 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>'; |
|
568 | 568 | } |
569 | 569 | } |
570 | 570 | |
571 | 571 | /** |
572 | 572 | * Displays a radio settings field. |
573 | 573 | */ |
574 | -function wpinv_radio_callback( $args ) { |
|
574 | +function wpinv_radio_callback($args) { |
|
575 | 575 | |
576 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
577 | - $std = wpinv_get_option( $args['id'], $std ); |
|
576 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
577 | + $std = wpinv_get_option($args['id'], $std); |
|
578 | 578 | ?> |
579 | 579 | <fieldset> |
580 | - <ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;"> |
|
581 | - <?php foreach( $args['options'] as $key => $option ) : ?> |
|
580 | + <ul id="wpinv-settings-<?php echo esc_attr($args['id']); ?>" style="margin-top: 0;"> |
|
581 | + <?php foreach ($args['options'] as $key => $option) : ?> |
|
582 | 582 | <li> |
583 | 583 | <label> |
584 | - <input name="wpinv_settings[<?php echo esc_attr( $args['id'] ); ?>]" <?php checked( $std, $key ); ?> value="<?php echo esc_attr( $key ); ?>" type="radio"> |
|
585 | - <?php echo wp_kses_post( $option ); ?> |
|
584 | + <input name="wpinv_settings[<?php echo esc_attr($args['id']); ?>]" <?php checked($std, $key); ?> value="<?php echo esc_attr($key); ?>" type="radio"> |
|
585 | + <?php echo wp_kses_post($option); ?> |
|
586 | 586 | </label> |
587 | 587 | </li> |
588 | 588 | <?php endforeach; ?> |
589 | 589 | </ul> |
590 | 590 | </fieldset> |
591 | 591 | <?php |
592 | - getpaid_settings_description_callback( $args ); |
|
592 | + getpaid_settings_description_callback($args); |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | /** |
596 | 596 | * Displays a description if available. |
597 | 597 | */ |
598 | -function getpaid_settings_description_callback( $args ) { |
|
598 | +function getpaid_settings_description_callback($args) { |
|
599 | 599 | |
600 | - if ( ! empty( $args['desc'] ) ) { |
|
601 | - $description = wp_kses_post( $args['desc'] ); |
|
600 | + if (!empty($args['desc'])) { |
|
601 | + $description = wp_kses_post($args['desc']); |
|
602 | 602 | echo "<p class='description'>$description</p>"; |
603 | 603 | } |
604 | 604 | |
605 | 605 | } |
606 | 606 | |
607 | -function wpinv_gateways_callback( $args ) { |
|
607 | +function wpinv_gateways_callback($args) { |
|
608 | 608 | global $wpinv_options; |
609 | 609 | |
610 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
610 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
611 | 611 | |
612 | - foreach ( $args['options'] as $key => $option ) : |
|
613 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
612 | + foreach ($args['options'] as $key => $option) : |
|
613 | + $sanitize_key = wpinv_sanitize_key($key); |
|
614 | 614 | |
615 | - if ( isset( $wpinv_options['gateways'][ $key ] ) ) |
|
615 | + if (isset($wpinv_options['gateways'][$key])) |
|
616 | 616 | $enabled = '1'; |
617 | 617 | else |
618 | 618 | $enabled = null; |
619 | 619 | |
620 | - echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
621 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
620 | + echo '<input name="wpinv_settings[' . esc_attr($args['id']) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
621 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option['admin_label']) . '</label><br/>'; |
|
622 | 622 | endforeach; |
623 | 623 | } |
624 | 624 | |
625 | 625 | function wpinv_gateway_select_callback($args) { |
626 | 626 | global $wpinv_options; |
627 | 627 | |
628 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
629 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
628 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
629 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
630 | 630 | |
631 | - echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >'; |
|
631 | + echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '" >'; |
|
632 | 632 | |
633 | - foreach ( $args['options'] as $key => $option ) : |
|
634 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
635 | - $selected = selected( $key, $args['selected'], false ); |
|
633 | + foreach ($args['options'] as $key => $option) : |
|
634 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
635 | + $selected = selected($key, $args['selected'], false); |
|
636 | 636 | } else { |
637 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : ''; |
|
637 | + $selected = isset($wpinv_options[$args['id']]) ? selected($key, $wpinv_options[$args['id']], false) : ''; |
|
638 | 638 | } |
639 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
639 | + echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>'; |
|
640 | 640 | endforeach; |
641 | 641 | |
642 | 642 | echo '</select>'; |
643 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
643 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
644 | 644 | } |
645 | 645 | |
646 | -function wpinv_text_callback( $args ) { |
|
646 | +function wpinv_text_callback($args) { |
|
647 | 647 | global $wpinv_options; |
648 | 648 | |
649 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
649 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
650 | 650 | |
651 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
652 | - $value = $wpinv_options[ $args['id'] ]; |
|
651 | + if (isset($wpinv_options[$args['id']])) { |
|
652 | + $value = $wpinv_options[$args['id']]; |
|
653 | 653 | } else { |
654 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
654 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
655 | 655 | } |
656 | 656 | |
657 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
657 | + if (isset($args['faux']) && true === $args['faux']) { |
|
658 | 658 | $args['readonly'] = true; |
659 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
659 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
660 | 660 | $name = ''; |
661 | 661 | } else { |
662 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
662 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
663 | 663 | } |
664 | - $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
664 | + $class = !empty($args['class']) ? sanitize_html_class($args['class']) : ''; |
|
665 | 665 | |
666 | 666 | $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; |
667 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
668 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>'; |
|
669 | - $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
667 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
668 | + $html = '<input type="text" class="' . sanitize_html_class($size) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"' . $readonly . '/>'; |
|
669 | + $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
670 | 670 | |
671 | 671 | echo $html; |
672 | 672 | } |
673 | 673 | |
674 | -function wpinv_number_callback( $args ) { |
|
674 | +function wpinv_number_callback($args) { |
|
675 | 675 | global $wpinv_options; |
676 | 676 | |
677 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
677 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
678 | 678 | |
679 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
680 | - $value = $wpinv_options[ $args['id'] ]; |
|
679 | + if (isset($wpinv_options[$args['id']])) { |
|
680 | + $value = $wpinv_options[$args['id']]; |
|
681 | 681 | } else { |
682 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
682 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
683 | 683 | } |
684 | 684 | |
685 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
685 | + if (isset($args['faux']) && true === $args['faux']) { |
|
686 | 686 | $args['readonly'] = true; |
687 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
687 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
688 | 688 | $name = ''; |
689 | 689 | } else { |
690 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
690 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
691 | 691 | } |
692 | 692 | |
693 | - $max = isset( $args['max'] ) ? $args['max'] : 999999; |
|
694 | - $min = isset( $args['min'] ) ? $args['min'] : 0; |
|
695 | - $step = isset( $args['step'] ) ? $args['step'] : 1; |
|
696 | - $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
693 | + $max = isset($args['max']) ? $args['max'] : 999999; |
|
694 | + $min = isset($args['min']) ? $args['min'] : 0; |
|
695 | + $step = isset($args['step']) ? $args['step'] : 1; |
|
696 | + $class = !empty($args['class']) ? sanitize_html_class($args['class']) : ''; |
|
697 | 697 | |
698 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
699 | - $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
700 | - $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
698 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
699 | + $html = '<input type="number" step="' . esc_attr($step) . '" max="' . esc_attr($max) . '" min="' . esc_attr($min) . '" class="' . sanitize_html_class($size) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
700 | + $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
701 | 701 | |
702 | 702 | echo $html; |
703 | 703 | } |
704 | 704 | |
705 | -function wpinv_textarea_callback( $args ) { |
|
705 | +function wpinv_textarea_callback($args) { |
|
706 | 706 | global $wpinv_options; |
707 | 707 | |
708 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
708 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
709 | 709 | |
710 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
711 | - $value = $wpinv_options[ $args['id'] ]; |
|
710 | + if (isset($wpinv_options[$args['id']])) { |
|
711 | + $value = $wpinv_options[$args['id']]; |
|
712 | 712 | } else { |
713 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
713 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
714 | 714 | } |
715 | 715 | |
716 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
717 | - $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
|
716 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
717 | + $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text'; |
|
718 | 718 | |
719 | - $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
720 | - $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
719 | + $html = '<textarea class="' . sanitize_html_class($class) . ' txtarea-' . sanitize_html_class($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
720 | + $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
721 | 721 | |
722 | 722 | echo $html; |
723 | 723 | } |
724 | 724 | |
725 | -function wpinv_password_callback( $args ) { |
|
725 | +function wpinv_password_callback($args) { |
|
726 | 726 | global $wpinv_options; |
727 | 727 | |
728 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
728 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
729 | 729 | |
730 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
731 | - $value = $wpinv_options[ $args['id'] ]; |
|
730 | + if (isset($wpinv_options[$args['id']])) { |
|
731 | + $value = $wpinv_options[$args['id']]; |
|
732 | 732 | } else { |
733 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
733 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
734 | 734 | } |
735 | 735 | |
736 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
737 | - $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
738 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
736 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
737 | + $html = '<input type="password" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>'; |
|
738 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
739 | 739 | |
740 | 740 | echo $html; |
741 | 741 | } |
742 | 742 | |
743 | 743 | function wpinv_missing_callback($args) { |
744 | 744 | printf( |
745 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
745 | + __('The callback function used for the %s setting is missing.', 'invoicing'), |
|
746 | 746 | '<strong>' . $args['id'] . '</strong>' |
747 | 747 | ); |
748 | 748 | } |
@@ -750,134 +750,134 @@ discard block |
||
750 | 750 | function wpinv_select_callback($args) { |
751 | 751 | global $wpinv_options; |
752 | 752 | |
753 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
753 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
754 | 754 | |
755 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
756 | - $value = $wpinv_options[ $args['id'] ]; |
|
755 | + if (isset($wpinv_options[$args['id']])) { |
|
756 | + $value = $wpinv_options[$args['id']]; |
|
757 | 757 | } else { |
758 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
758 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
759 | 759 | } |
760 | 760 | |
761 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
761 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
762 | 762 | $value = $args['selected']; |
763 | 763 | } |
764 | 764 | |
765 | - if ( isset( $args['placeholder'] ) ) { |
|
765 | + if (isset($args['placeholder'])) { |
|
766 | 766 | $placeholder = $args['placeholder']; |
767 | 767 | } else { |
768 | 768 | $placeholder = ''; |
769 | 769 | } |
770 | 770 | |
771 | - if( !empty( $args['onchange'] ) ) { |
|
772 | - $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
771 | + if (!empty($args['onchange'])) { |
|
772 | + $onchange = ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
773 | 773 | } else { |
774 | 774 | $onchange = ''; |
775 | 775 | } |
776 | 776 | |
777 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
777 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
778 | 778 | |
779 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />'; |
|
779 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '" name="wpinv_settings[' . esc_attr($args['id']) . ']" data-placeholder="' . esc_html($placeholder) . '"' . $onchange . ' />'; |
|
780 | 780 | |
781 | - foreach ( $args['options'] as $option => $name ) { |
|
782 | - $selected = selected( $option, $value, false ); |
|
783 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
781 | + foreach ($args['options'] as $option => $name) { |
|
782 | + $selected = selected($option, $value, false); |
|
783 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>'; |
|
784 | 784 | } |
785 | 785 | |
786 | 786 | $html .= '</select>'; |
787 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
787 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
788 | 788 | |
789 | 789 | echo $html; |
790 | 790 | } |
791 | 791 | |
792 | -function wpinv_color_select_callback( $args ) { |
|
792 | +function wpinv_color_select_callback($args) { |
|
793 | 793 | global $wpinv_options; |
794 | 794 | |
795 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
795 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
796 | 796 | |
797 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
798 | - $value = $wpinv_options[ $args['id'] ]; |
|
797 | + if (isset($wpinv_options[$args['id']])) { |
|
798 | + $value = $wpinv_options[$args['id']]; |
|
799 | 799 | } else { |
800 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
800 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
801 | 801 | } |
802 | 802 | |
803 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
803 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>'; |
|
804 | 804 | |
805 | - foreach ( $args['options'] as $option => $color ) { |
|
806 | - $selected = selected( $option, $value, false ); |
|
807 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
805 | + foreach ($args['options'] as $option => $color) { |
|
806 | + $selected = selected($option, $value, false); |
|
807 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>'; |
|
808 | 808 | } |
809 | 809 | |
810 | 810 | $html .= '</select>'; |
811 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
811 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
812 | 812 | |
813 | 813 | echo $html; |
814 | 814 | } |
815 | 815 | |
816 | -function wpinv_rich_editor_callback( $args ) { |
|
816 | +function wpinv_rich_editor_callback($args) { |
|
817 | 817 | global $wpinv_options, $wp_version; |
818 | 818 | |
819 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
819 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
820 | 820 | |
821 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
822 | - $value = $wpinv_options[ $args['id'] ]; |
|
821 | + if (isset($wpinv_options[$args['id']])) { |
|
822 | + $value = $wpinv_options[$args['id']]; |
|
823 | 823 | |
824 | - if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
825 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
824 | + if (empty($args['allow_blank']) && empty($value)) { |
|
825 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
826 | 826 | } |
827 | 827 | } else { |
828 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
828 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
829 | 829 | } |
830 | 830 | |
831 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
831 | + $rows = isset($args['size']) ? $args['size'] : 20; |
|
832 | 832 | |
833 | 833 | $html = '<div class="getpaid-settings-editor-input">'; |
834 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
834 | + if ($wp_version >= 3.3 && function_exists('wp_editor')) { |
|
835 | 835 | ob_start(); |
836 | - wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) ); |
|
836 | + wp_editor(stripslashes($value), 'wpinv_settings_' . esc_attr($args['id']), array('textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', 'textarea_rows' => absint($rows), 'media_buttons' => false)); |
|
837 | 837 | $html .= ob_get_clean(); |
838 | 838 | } else { |
839 | - $html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
839 | + $html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
840 | 840 | } |
841 | 841 | |
842 | - $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
842 | + $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
843 | 843 | |
844 | 844 | echo $html; |
845 | 845 | } |
846 | 846 | |
847 | -function wpinv_upload_callback( $args ) { |
|
847 | +function wpinv_upload_callback($args) { |
|
848 | 848 | global $wpinv_options; |
849 | 849 | |
850 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
850 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
851 | 851 | |
852 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
852 | + if (isset($wpinv_options[$args['id']])) { |
|
853 | 853 | $value = $wpinv_options[$args['id']]; |
854 | 854 | } else { |
855 | 855 | $value = isset($args['std']) ? $args['std'] : ''; |
856 | 856 | } |
857 | 857 | |
858 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
859 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
860 | - $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
861 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
858 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
859 | + $html = '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
860 | + $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>'; |
|
861 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
862 | 862 | |
863 | 863 | echo $html; |
864 | 864 | } |
865 | 865 | |
866 | -function wpinv_color_callback( $args ) { |
|
866 | +function wpinv_color_callback($args) { |
|
867 | 867 | global $wpinv_options; |
868 | 868 | |
869 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
869 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
870 | 870 | |
871 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
872 | - $value = $wpinv_options[ $args['id'] ]; |
|
871 | + if (isset($wpinv_options[$args['id']])) { |
|
872 | + $value = $wpinv_options[$args['id']]; |
|
873 | 873 | } else { |
874 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
874 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
875 | 875 | } |
876 | 876 | |
877 | - $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
877 | + $default = isset($args['std']) ? $args['std'] : ''; |
|
878 | 878 | |
879 | - $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />'; |
|
880 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
879 | + $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($default) . '" />'; |
|
880 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
881 | 881 | |
882 | 882 | echo $html; |
883 | 883 | } |
@@ -885,9 +885,9 @@ discard block |
||
885 | 885 | function wpinv_country_states_callback($args) { |
886 | 886 | global $wpinv_options; |
887 | 887 | |
888 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
888 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
889 | 889 | |
890 | - if ( isset( $args['placeholder'] ) ) { |
|
890 | + if (isset($args['placeholder'])) { |
|
891 | 891 | $placeholder = $args['placeholder']; |
892 | 892 | } else { |
893 | 893 | $placeholder = ''; |
@@ -895,16 +895,16 @@ discard block |
||
895 | 895 | |
896 | 896 | $states = wpinv_get_country_states(); |
897 | 897 | |
898 | - $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
899 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
898 | + $class = empty($states) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
899 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>'; |
|
900 | 900 | |
901 | - foreach ( $states as $option => $name ) { |
|
902 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
903 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
901 | + foreach ($states as $option => $name) { |
|
902 | + $selected = isset($wpinv_options[$args['id']]) ? selected($option, $wpinv_options[$args['id']], false) : ''; |
|
903 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>'; |
|
904 | 904 | } |
905 | 905 | |
906 | 906 | $html .= '</select>'; |
907 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
907 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
908 | 908 | |
909 | 909 | echo $html; |
910 | 910 | } |
@@ -919,7 +919,7 @@ discard block |
||
919 | 919 | </tr> |
920 | 920 | <tr class="bsui"> |
921 | 921 | <td colspan="2" class="p-0"> |
922 | - <?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rates-edit.php'; ?> |
|
922 | + <?php include plugin_dir_path(__FILE__) . 'views/html-tax-rates-edit.php'; ?> |
|
923 | 923 | |
924 | 924 | <?php |
925 | 925 | |
@@ -928,17 +928,17 @@ discard block |
||
928 | 928 | /** |
929 | 929 | * Displays a tax rate' edit row. |
930 | 930 | */ |
931 | -function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) { |
|
931 | +function wpinv_tax_rate_callback($tax_rate, $key, $echo = true) { |
|
932 | 932 | ob_start(); |
933 | 933 | |
934 | - $key = sanitize_key( $key ); |
|
935 | - $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
936 | - include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
934 | + $key = sanitize_key($key); |
|
935 | + $tax_rate['reduced_rate'] = empty($tax_rate['reduced_rate']) ? 0 : $tax_rate['reduced_rate']; |
|
936 | + include plugin_dir_path(__FILE__) . 'views/html-tax-rate-edit.php'; |
|
937 | 937 | |
938 | - if ( $echo ) { |
|
939 | - echo ob_get_clean( $echo ); |
|
938 | + if ($echo) { |
|
939 | + echo ob_get_clean($echo); |
|
940 | 940 | } else { |
941 | - return ob_get_clean( $echo ); |
|
941 | + return ob_get_clean($echo); |
|
942 | 942 | } |
943 | 943 | |
944 | 944 | } |
@@ -947,77 +947,77 @@ discard block |
||
947 | 947 | ob_start(); ?> |
948 | 948 | </td><tr> |
949 | 949 | <td colspan="2" class="wpinv_tools_tdbox"> |
950 | - <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
951 | - <?php do_action( 'wpinv_tools_before' ); ?> |
|
950 | + <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
951 | + <?php do_action('wpinv_tools_before'); ?> |
|
952 | 952 | <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts"> |
953 | 953 | <thead> |
954 | 954 | <tr> |
955 | - <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th> |
|
956 | - <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th> |
|
957 | - <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th> |
|
955 | + <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th> |
|
956 | + <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th> |
|
957 | + <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th> |
|
958 | 958 | </tr> |
959 | 959 | </thead> |
960 | - <?php do_action( 'wpinv_tools_row' ); ?> |
|
960 | + <?php do_action('wpinv_tools_row'); ?> |
|
961 | 961 | <tbody> |
962 | 962 | </tbody> |
963 | 963 | </table> |
964 | - <?php do_action( 'wpinv_tools_after' ); ?> |
|
964 | + <?php do_action('wpinv_tools_after'); ?> |
|
965 | 965 | <?php |
966 | 966 | echo ob_get_clean(); |
967 | 967 | } |
968 | 968 | |
969 | -function wpinv_descriptive_text_callback( $args ) { |
|
970 | - echo wp_kses_post( $args['desc'] ); |
|
969 | +function wpinv_descriptive_text_callback($args) { |
|
970 | + echo wp_kses_post($args['desc']); |
|
971 | 971 | } |
972 | 972 | |
973 | -function wpinv_hook_callback( $args ) { |
|
974 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
973 | +function wpinv_hook_callback($args) { |
|
974 | + do_action('wpinv_' . $args['id'], $args); |
|
975 | 975 | } |
976 | 976 | |
977 | 977 | function wpinv_set_settings_cap() { |
978 | 978 | return wpinv_get_capability(); |
979 | 979 | } |
980 | -add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
|
980 | +add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap'); |
|
981 | 981 | |
982 | -function wpinv_settings_sanitize_input( $value, $key ) { |
|
982 | +function wpinv_settings_sanitize_input($value, $key) { |
|
983 | 983 | |
984 | - if ( $key == 'tax_rate' ) { |
|
985 | - $value = wpinv_sanitize_amount( $value ); |
|
984 | + if ($key == 'tax_rate') { |
|
985 | + $value = wpinv_sanitize_amount($value); |
|
986 | 986 | $value = $value >= 100 ? 99 : $value; |
987 | 987 | } |
988 | 988 | |
989 | 989 | return $value; |
990 | 990 | } |
991 | -add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 ); |
|
991 | +add_filter('wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2); |
|
992 | 992 | |
993 | -function wpinv_on_update_settings( $old_value, $value, $option ) { |
|
994 | - $old = !empty( $old_value['remove_data_on_unistall'] ) ? 1 : ''; |
|
995 | - $new = !empty( $value['remove_data_on_unistall'] ) ? 1 : ''; |
|
993 | +function wpinv_on_update_settings($old_value, $value, $option) { |
|
994 | + $old = !empty($old_value['remove_data_on_unistall']) ? 1 : ''; |
|
995 | + $new = !empty($value['remove_data_on_unistall']) ? 1 : ''; |
|
996 | 996 | |
997 | - if ( $old != $new ) { |
|
998 | - update_option( 'wpinv_remove_data_on_invoice_unistall', $new ); |
|
997 | + if ($old != $new) { |
|
998 | + update_option('wpinv_remove_data_on_invoice_unistall', $new); |
|
999 | 999 | } |
1000 | 1000 | } |
1001 | -add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 ); |
|
1002 | -add_action( 'wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1003 | -add_action( 'wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1004 | -add_action( 'wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1005 | -add_action( 'wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1006 | -add_action( 'wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1007 | -add_action( 'wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1008 | -add_action( 'wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1009 | -add_action( 'wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1010 | -add_action( 'wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1011 | -add_action( 'wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1012 | - |
|
1013 | -function wpinv_settings_tab_bottom_emails( $active_tab, $section ) { |
|
1001 | +add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3); |
|
1002 | +add_action('wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1003 | +add_action('wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1004 | +add_action('wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1005 | +add_action('wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1006 | +add_action('wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1007 | +add_action('wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1008 | +add_action('wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1009 | +add_action('wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1010 | +add_action('wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1011 | +add_action('wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1012 | + |
|
1013 | +function wpinv_settings_tab_bottom_emails($active_tab, $section) { |
|
1014 | 1014 | ?> |
1015 | 1015 | <div class="wpinv-email-wc-row "> |
1016 | 1016 | <div class="wpinv-email-wc-td"> |
1017 | - <h3 class="wpinv-email-wc-title"><?php echo apply_filters( 'wpinv_settings_email_wildcards_title', __( 'Wildcards For Emails', 'invoicing' ) ); ?></h3> |
|
1017 | + <h3 class="wpinv-email-wc-title"><?php echo apply_filters('wpinv_settings_email_wildcards_title', __('Wildcards For Emails', 'invoicing')); ?></h3> |
|
1018 | 1018 | <p class="wpinv-email-wc-description"> |
1019 | 1019 | <?php |
1020 | - $description = __( 'The following wildcards can be used in email subjects, heading and content:<br> |
|
1020 | + $description = __('The following wildcards can be used in email subjects, heading and content:<br> |
|
1021 | 1021 | <strong>{site_title} :</strong> Site Title<br> |
1022 | 1022 | <strong>{name} :</strong> Customer\'s full name<br> |
1023 | 1023 | <strong>{first_name} :</strong> Customer\'s first name<br> |
@@ -1031,7 +1031,7 @@ discard block |
||
1031 | 1031 | <strong>{invoice_due_date} :</strong> The date the invoice is due<br> |
1032 | 1032 | <strong>{date} :</strong> Today\'s date.<br> |
1033 | 1033 | <strong>{is_was} :</strong> If due date of invoice is past, displays "was" otherwise displays "is"<br> |
1034 | - <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing' ); |
|
1034 | + <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing'); |
|
1035 | 1035 | echo apply_filters('wpinv_settings_email_wildcards_description', $description, $active_tab, $section); |
1036 | 1036 | ?> |
1037 | 1037 | </p> |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Returns the tax class objet. |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @return bool |
22 | 22 | */ |
23 | -function getpaid_is_eu_state( $country ) { |
|
24 | - return WPInv_EUVat::is_eu_state( $country ); |
|
23 | +function getpaid_is_eu_state($country) { |
|
24 | + return WPInv_EUVat::is_eu_state($country); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @return bool |
31 | 31 | */ |
32 | -function getpaid_is_gst_country( $country ) { |
|
33 | - return WPInv_EUVat::is_gst_country( $country ); |
|
32 | +function getpaid_is_gst_country($country) { |
|
33 | + return WPInv_EUVat::is_gst_country($country); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | */ |
50 | 50 | function wpinv_use_taxes() { |
51 | 51 | |
52 | - $ret = wpinv_get_option( 'enable_taxes', false ); |
|
53 | - return (bool) apply_filters( 'wpinv_use_taxes', ! empty( $ret ) ); |
|
52 | + $ret = wpinv_get_option('enable_taxes', false); |
|
53 | + return (bool) apply_filters('wpinv_use_taxes', !empty($ret)); |
|
54 | 54 | |
55 | 55 | } |
56 | 56 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @param WPInv_Invoice $invoice |
61 | 61 | * @return bool |
62 | 62 | */ |
63 | -function wpinv_is_invoice_taxable( $invoice ) { |
|
63 | +function wpinv_is_invoice_taxable($invoice) { |
|
64 | 64 | return $invoice->is_taxable(); |
65 | 65 | } |
66 | 66 | |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | * @param string $country |
71 | 71 | * @return bool |
72 | 72 | */ |
73 | -function wpinv_is_country_taxable( $country ) { |
|
74 | - $is_eu = getpaid_is_eu_state( $country ); |
|
75 | - $is_exempt = $is_eu && $country == wpinv_is_base_country( $country ) && wpinv_same_country_exempt_vat(); |
|
73 | +function wpinv_is_country_taxable($country) { |
|
74 | + $is_eu = getpaid_is_eu_state($country); |
|
75 | + $is_exempt = $is_eu && $country == wpinv_is_base_country($country) && wpinv_same_country_exempt_vat(); |
|
76 | 76 | |
77 | - return (bool) apply_filters( 'wpinv_is_country_taxable', ! $is_exempt, $country ); |
|
77 | + return (bool) apply_filters('wpinv_is_country_taxable', !$is_exempt, $country); |
|
78 | 78 | |
79 | 79 | } |
80 | 80 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @param WPInv_Item|GetPaid_Form_Item $item |
85 | 85 | * @return bool |
86 | 86 | */ |
87 | -function wpinv_is_item_taxable( $item ) { |
|
87 | +function wpinv_is_item_taxable($item) { |
|
88 | 88 | return '_exempt' != $item->get_vat_rule(); |
89 | 89 | } |
90 | 90 | |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | * @return bool |
95 | 95 | */ |
96 | 96 | function wpinv_use_store_address_as_tax_base() { |
97 | - $use_base = wpinv_get_option( 'tax_base', 'billing' ) == 'base'; |
|
98 | - return (bool) apply_filters( 'wpinv_use_store_address_as_tax_base', $use_base ); |
|
97 | + $use_base = wpinv_get_option('tax_base', 'billing') == 'base'; |
|
98 | + return (bool) apply_filters('wpinv_use_store_address_as_tax_base', $use_base); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | * @return bool |
105 | 105 | */ |
106 | 106 | function wpinv_prices_include_tax() { |
107 | - $is_inclusive = wpinv_get_option( 'prices_include_tax', 'no' ) == 'yes'; |
|
108 | - return (bool) apply_filters( 'wpinv_prices_include_tax', $is_inclusive ); |
|
107 | + $is_inclusive = wpinv_get_option('prices_include_tax', 'no') == 'yes'; |
|
108 | + return (bool) apply_filters('wpinv_prices_include_tax', $is_inclusive); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | * @return bool |
115 | 115 | */ |
116 | 116 | function wpinv_round_tax_per_tax_rate() { |
117 | - $subtotal_rounding = wpinv_get_option( 'tax_subtotal_rounding', 1 ); |
|
118 | - return (bool) apply_filters( 'wpinv_round_tax_per_tax_rate', empty( $subtotal_rounding ) ); |
|
117 | + $subtotal_rounding = wpinv_get_option('tax_subtotal_rounding', 1); |
|
118 | + return (bool) apply_filters('wpinv_round_tax_per_tax_rate', empty($subtotal_rounding)); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | * @return bool |
125 | 125 | */ |
126 | 126 | function wpinv_display_individual_tax_rates() { |
127 | - $individual = wpinv_get_option( 'tax_display_totals', 'single' ) == 'individual'; |
|
128 | - return (bool) apply_filters( 'wpinv_display_individual_tax_rates', $individual ); |
|
127 | + $individual = wpinv_get_option('tax_display_totals', 'single') == 'individual'; |
|
128 | + return (bool) apply_filters('wpinv_display_individual_tax_rates', $individual); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | * @return float |
135 | 135 | */ |
136 | 136 | function wpinv_get_default_tax_rate() { |
137 | - $rate = wpinv_get_option( 'tax_rate', false ); |
|
138 | - return (float) apply_filters( 'wpinv_get_default_tax_rate', floatval( $rate ) ); |
|
137 | + $rate = wpinv_get_option('tax_rate', false); |
|
138 | + return (float) apply_filters('wpinv_get_default_tax_rate', floatval($rate)); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * @return bool |
145 | 145 | */ |
146 | 146 | function wpinv_same_country_exempt_vat() { |
147 | - return 'no' == wpinv_get_option( 'vat_same_country_rule' ); |
|
147 | + return 'no' == wpinv_get_option('vat_same_country_rule'); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -164,28 +164,28 @@ discard block |
||
164 | 164 | * @param string $state |
165 | 165 | * @return array |
166 | 166 | */ |
167 | -function getpaid_get_item_tax_rates( $item, $country = '', $state = '' ) { |
|
167 | +function getpaid_get_item_tax_rates($item, $country = '', $state = '') { |
|
168 | 168 | |
169 | 169 | // Abort if the item is not taxable. |
170 | - if ( ! wpinv_is_item_taxable( $item ) ) { |
|
170 | + if (!wpinv_is_item_taxable($item)) { |
|
171 | 171 | return array(); |
172 | 172 | } |
173 | 173 | |
174 | 174 | // Maybe use the store address. |
175 | - if ( wpinv_use_store_address_as_tax_base() ) { |
|
175 | + if (wpinv_use_store_address_as_tax_base()) { |
|
176 | 176 | $country = wpinv_get_default_country(); |
177 | 177 | $state = wpinv_get_default_state(); |
178 | 178 | } |
179 | 179 | |
180 | 180 | // Retrieve tax rates. |
181 | - $tax_rates = GetPaid_Tax::get_address_tax_rates( $country, $state ); |
|
181 | + $tax_rates = GetPaid_Tax::get_address_tax_rates($country, $state); |
|
182 | 182 | |
183 | 183 | // Fallback to the default tax rates if non were found. |
184 | - if ( empty( $tax_rates ) ) { |
|
184 | + if (empty($tax_rates)) { |
|
185 | 185 | $tax_rates = GetPaid_Tax::get_default_tax_rates(); |
186 | 186 | } |
187 | 187 | |
188 | - return apply_filters( 'getpaid_get_item_tax_rates', $tax_rates, $item, $country, $state ); |
|
188 | + return apply_filters('getpaid_get_item_tax_rates', $tax_rates, $item, $country, $state); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -195,12 +195,12 @@ discard block |
||
195 | 195 | * @param array $rates |
196 | 196 | * @return array |
197 | 197 | */ |
198 | -function getpaid_calculate_item_taxes( $amount, $rates ) { |
|
198 | +function getpaid_calculate_item_taxes($amount, $rates) { |
|
199 | 199 | |
200 | 200 | $is_inclusive = wpinv_prices_include_tax(); |
201 | - $taxes = GetPaid_Tax::calc_tax( $amount, $rates, $is_inclusive ); |
|
201 | + $taxes = GetPaid_Tax::calc_tax($amount, $rates, $is_inclusive); |
|
202 | 202 | |
203 | - return apply_filters( 'getpaid_calculate_taxes', $taxes, $amount, $rates ); |
|
203 | + return apply_filters('getpaid_calculate_taxes', $taxes, $amount, $rates); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -212,17 +212,17 @@ discard block |
||
212 | 212 | * @param float $recurring_tax_amount |
213 | 213 | * @return array |
214 | 214 | */ |
215 | -function getpaid_prepare_item_tax( $item, $tax_name, $tax_amount, $recurring_tax_amount ) { |
|
215 | +function getpaid_prepare_item_tax($item, $tax_name, $tax_amount, $recurring_tax_amount) { |
|
216 | 216 | |
217 | - $initial_tax = $tax_amount; |
|
217 | + $initial_tax = $tax_amount; |
|
218 | 218 | $recurring_tax = 0; |
219 | 219 | |
220 | - if ( $item->is_recurring() ) { |
|
220 | + if ($item->is_recurring()) { |
|
221 | 221 | $recurring_tax = $recurring_tax_amount; |
222 | 222 | } |
223 | 223 | |
224 | 224 | return array( |
225 | - 'name' => sanitize_text_field( $tax_name ), |
|
225 | + 'name' => sanitize_text_field($tax_name), |
|
226 | 226 | 'initial_tax' => $initial_tax, |
227 | 227 | 'recurring_tax' => $recurring_tax, |
228 | 228 | ); |
@@ -235,8 +235,8 @@ discard block |
||
235 | 235 | * @param string $vat_number |
236 | 236 | * @return string |
237 | 237 | */ |
238 | -function wpinv_sanitize_vat_number( $vat_number ) { |
|
239 | - return str_replace( array(' ', '.', '-', '_', ',' ), '', strtoupper( trim( $vat_number ) ) ); |
|
238 | +function wpinv_sanitize_vat_number($vat_number) { |
|
239 | + return str_replace(array(' ', '.', '-', '_', ','), '', strtoupper(trim($vat_number))); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | /** |
@@ -245,22 +245,22 @@ discard block |
||
245 | 245 | * @param string $vat_number |
246 | 246 | * @return bool |
247 | 247 | */ |
248 | -function wpinv_regex_validate_vat_number( $vat_number ) { |
|
248 | +function wpinv_regex_validate_vat_number($vat_number) { |
|
249 | 249 | |
250 | - $country = substr( $vat_number, 0, 2 ); |
|
251 | - $vatin = substr( $vat_number, 2 ); |
|
252 | - $regexes = wpinv_get_data( 'vat-number-regexes' ); |
|
250 | + $country = substr($vat_number, 0, 2); |
|
251 | + $vatin = substr($vat_number, 2); |
|
252 | + $regexes = wpinv_get_data('vat-number-regexes'); |
|
253 | 253 | |
254 | - if ( isset( $regexes[ $country ] ) ) { |
|
254 | + if (isset($regexes[$country])) { |
|
255 | 255 | |
256 | - $regex = $regexes[ $country ]; |
|
256 | + $regex = $regexes[$country]; |
|
257 | 257 | $regex = '/^(?:' . $regex . ')$/'; |
258 | - return 1 === preg_match( $regex, $vatin ); |
|
258 | + return 1 === preg_match($regex, $vatin); |
|
259 | 259 | |
260 | 260 | } |
261 | 261 | |
262 | 262 | // Not an EU state, use filters to validate the number. |
263 | - return apply_filters( 'wpinv_regex_validate_vat_number', true, $vat_number ); |
|
263 | + return apply_filters('wpinv_regex_validate_vat_number', true, $vat_number); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | /** |
@@ -269,29 +269,29 @@ discard block |
||
269 | 269 | * @param string $vat_number |
270 | 270 | * @return bool |
271 | 271 | */ |
272 | -function wpinv_vies_validate_vat_number( $vat_number ) { |
|
272 | +function wpinv_vies_validate_vat_number($vat_number) { |
|
273 | 273 | |
274 | - $country = substr( $vat_number, 0, 2 ); |
|
275 | - $vatin = substr( $vat_number, 2 ); |
|
274 | + $country = substr($vat_number, 0, 2); |
|
275 | + $vatin = substr($vat_number, 2); |
|
276 | 276 | |
277 | 277 | $url = add_query_arg( |
278 | 278 | array( |
279 | - 'ms' => urlencode( $country ), |
|
280 | - 'iso' => urlencode( $country ), |
|
281 | - 'vat' => urlencode( $vatin ), |
|
279 | + 'ms' => urlencode($country), |
|
280 | + 'iso' => urlencode($country), |
|
281 | + 'vat' => urlencode($vatin), |
|
282 | 282 | ), |
283 | 283 | 'http://ec.europa.eu/taxation_customs/vies/viesquer.do' |
284 | 284 | ); |
285 | 285 | |
286 | - $response = wp_remote_get( $url ); |
|
287 | - $response = wp_remote_retrieve_body( $response ); |
|
286 | + $response = wp_remote_get($url); |
|
287 | + $response = wp_remote_retrieve_body($response); |
|
288 | 288 | |
289 | 289 | // Fallback gracefully if the VIES website is down. |
290 | - if ( empty( $response ) ) { |
|
290 | + if (empty($response)) { |
|
291 | 291 | return true; |
292 | 292 | } |
293 | 293 | |
294 | - return 1 !== preg_match( '/invalid VAT number/i', $response ); |
|
294 | + return 1 !== preg_match('/invalid VAT number/i', $response); |
|
295 | 295 | |
296 | 296 | } |
297 | 297 | |
@@ -302,23 +302,23 @@ discard block |
||
302 | 302 | * @param string $country |
303 | 303 | * @return bool |
304 | 304 | */ |
305 | -function wpinv_validate_vat_number( $vat_number, $country ) { |
|
305 | +function wpinv_validate_vat_number($vat_number, $country) { |
|
306 | 306 | |
307 | 307 | // Abort if we are not validating this. |
308 | - if ( ! wpinv_should_validate_vat_number() || empty( $vat_number ) ) { |
|
308 | + if (!wpinv_should_validate_vat_number() || empty($vat_number)) { |
|
309 | 309 | return true; |
310 | 310 | } |
311 | 311 | |
312 | 312 | // In case the vat number does not have a country code... |
313 | - $vat_number = wpinv_sanitize_vat_number( $vat_number ); |
|
314 | - $_country = substr( $vat_number, 0, 2 ); |
|
315 | - $_country = $_country == wpinv_country_name( $_country ); |
|
313 | + $vat_number = wpinv_sanitize_vat_number($vat_number); |
|
314 | + $_country = substr($vat_number, 0, 2); |
|
315 | + $_country = $_country == wpinv_country_name($_country); |
|
316 | 316 | |
317 | - if ( $_country ) { |
|
318 | - $vat_number = strtoupper( $country ) . $vat_number; |
|
317 | + if ($_country) { |
|
318 | + $vat_number = strtoupper($country) . $vat_number; |
|
319 | 319 | } |
320 | 320 | |
321 | - return wpinv_regex_validate_vat_number( $vat_number ) && wpinv_vies_validate_vat_number( $vat_number ); |
|
321 | + return wpinv_regex_validate_vat_number($vat_number) && wpinv_vies_validate_vat_number($vat_number); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | /** |
@@ -327,40 +327,40 @@ discard block |
||
327 | 327 | * @return bool |
328 | 328 | */ |
329 | 329 | function wpinv_should_validate_vat_number() { |
330 | - $validate = wpinv_get_option( 'validate_vat_number' ); |
|
331 | - return ! empty( $validate ); |
|
330 | + $validate = wpinv_get_option('validate_vat_number'); |
|
331 | + return !empty($validate); |
|
332 | 332 | } |
333 | 333 | |
334 | -function wpinv_sales_tax_for_year( $year = null ) { |
|
335 | - return wpinv_price( wpinv_format_amount( wpinv_get_sales_tax_for_year( $year ) ) ); |
|
334 | +function wpinv_sales_tax_for_year($year = null) { |
|
335 | + return wpinv_price(wpinv_format_amount(wpinv_get_sales_tax_for_year($year))); |
|
336 | 336 | } |
337 | 337 | |
338 | -function wpinv_get_sales_tax_for_year( $year = null ) { |
|
338 | +function wpinv_get_sales_tax_for_year($year = null) { |
|
339 | 339 | global $wpdb; |
340 | 340 | |
341 | 341 | // Start at zero |
342 | 342 | $tax = 0; |
343 | 343 | |
344 | - if ( ! empty( $year ) ) { |
|
344 | + if (!empty($year)) { |
|
345 | 345 | $args = array( |
346 | 346 | 'post_type' => 'wpi_invoice', |
347 | - 'post_status' => array( 'publish' ), |
|
347 | + 'post_status' => array('publish'), |
|
348 | 348 | 'posts_per_page' => -1, |
349 | 349 | 'year' => $year, |
350 | 350 | 'fields' => 'ids' |
351 | 351 | ); |
352 | 352 | |
353 | - $payments = get_posts( $args ); |
|
354 | - $payment_ids = implode( ',', $payments ); |
|
353 | + $payments = get_posts($args); |
|
354 | + $payment_ids = implode(',', $payments); |
|
355 | 355 | |
356 | - if ( count( $payments ) > 0 ) { |
|
356 | + if (count($payments) > 0) { |
|
357 | 357 | $sql = "SELECT SUM( meta_value ) FROM $wpdb->postmeta WHERE meta_key = '_wpinv_tax' AND post_id IN( $payment_ids )"; |
358 | - $tax = $wpdb->get_var( $sql ); |
|
358 | + $tax = $wpdb->get_var($sql); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | } |
362 | 362 | |
363 | - return apply_filters( 'wpinv_get_sales_tax_for_year', $tax, $year ); |
|
363 | + return apply_filters('wpinv_get_sales_tax_for_year', $tax, $year); |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | function wpinv_is_cart_taxed() { |
@@ -369,33 +369,33 @@ discard block |
||
369 | 369 | |
370 | 370 | function wpinv_prices_show_tax_on_checkout() { |
371 | 371 | return false; // TODO |
372 | - $ret = ( wpinv_get_option( 'checkout_include_tax', false ) == 'yes' && wpinv_use_taxes() ); |
|
372 | + $ret = (wpinv_get_option('checkout_include_tax', false) == 'yes' && wpinv_use_taxes()); |
|
373 | 373 | |
374 | - return apply_filters( 'wpinv_taxes_on_prices_on_checkout', $ret ); |
|
374 | + return apply_filters('wpinv_taxes_on_prices_on_checkout', $ret); |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | function wpinv_display_tax_rate() { |
378 | - $ret = wpinv_use_taxes() && wpinv_get_option( 'display_tax_rate', false ); |
|
378 | + $ret = wpinv_use_taxes() && wpinv_get_option('display_tax_rate', false); |
|
379 | 379 | |
380 | - return apply_filters( 'wpinv_display_tax_rate', $ret ); |
|
380 | + return apply_filters('wpinv_display_tax_rate', $ret); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | function wpinv_cart_needs_tax_address_fields() { |
384 | - if( !wpinv_is_cart_taxed() ) |
|
384 | + if (!wpinv_is_cart_taxed()) |
|
385 | 385 | return false; |
386 | 386 | |
387 | - return ! did_action( 'wpinv_after_cc_fields', 'wpinv_default_cc_address_fields' ); |
|
387 | + return !did_action('wpinv_after_cc_fields', 'wpinv_default_cc_address_fields'); |
|
388 | 388 | } |
389 | 389 | |
390 | -function wpinv_item_is_tax_exclusive( $item_id = 0 ) { |
|
391 | - $ret = (bool)get_post_meta( $item_id, '_wpinv_tax_exclusive', false ); |
|
392 | - return apply_filters( 'wpinv_is_tax_exclusive', $ret, $item_id ); |
|
390 | +function wpinv_item_is_tax_exclusive($item_id = 0) { |
|
391 | + $ret = (bool) get_post_meta($item_id, '_wpinv_tax_exclusive', false); |
|
392 | + return apply_filters('wpinv_is_tax_exclusive', $ret, $item_id); |
|
393 | 393 | } |
394 | 394 | |
395 | -function wpinv_currency_decimal_filter( $decimals = 2 ) { |
|
395 | +function wpinv_currency_decimal_filter($decimals = 2) { |
|
396 | 396 | $currency = wpinv_get_currency(); |
397 | 397 | |
398 | - switch ( $currency ) { |
|
398 | + switch ($currency) { |
|
399 | 399 | case 'RIAL' : |
400 | 400 | case 'JPY' : |
401 | 401 | case 'TWD' : |
@@ -404,50 +404,50 @@ discard block |
||
404 | 404 | break; |
405 | 405 | } |
406 | 406 | |
407 | - return apply_filters( 'wpinv_currency_decimal_count', $decimals, $currency ); |
|
407 | + return apply_filters('wpinv_currency_decimal_count', $decimals, $currency); |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | function wpinv_tax_amount() { |
411 | 411 | $output = 0.00; |
412 | 412 | |
413 | - return apply_filters( 'wpinv_tax_amount', $output ); |
|
413 | + return apply_filters('wpinv_tax_amount', $output); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | // VAT Settings |
417 | -function wpinv_vat_rate_add_callback( $args ) { |
|
417 | +function wpinv_vat_rate_add_callback($args) { |
|
418 | 418 | ?> |
419 | - <p class="wpi-vat-rate-actions"><input id="wpi_vat_rate_add" type="button" value="<?php esc_attr_e( 'Add', 'invoicing' );?>" class="button button-primary" /> <i style="display:none;" class="fa fa-refresh fa-spin"></i></p> |
|
419 | + <p class="wpi-vat-rate-actions"><input id="wpi_vat_rate_add" type="button" value="<?php esc_attr_e('Add', 'invoicing'); ?>" class="button button-primary" /> <i style="display:none;" class="fa fa-refresh fa-spin"></i></p> |
|
420 | 420 | <?php |
421 | 421 | } |
422 | 422 | |
423 | -function wpinv_vat_rate_delete_callback( $args ) { |
|
423 | +function wpinv_vat_rate_delete_callback($args) { |
|
424 | 424 | global $wpinv_euvat; |
425 | 425 | |
426 | 426 | $vat_classes = $wpinv_euvat->get_rate_classes(); |
427 | - $vat_class = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' && isset( $vat_classes[$_REQUEST['wpi_sub']] )? sanitize_text_field( $_REQUEST['wpi_sub'] ) : ''; |
|
428 | - if ( isset( $vat_classes[$vat_class] ) ) { |
|
427 | + $vat_class = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' && isset($vat_classes[$_REQUEST['wpi_sub']]) ? sanitize_text_field($_REQUEST['wpi_sub']) : ''; |
|
428 | + if (isset($vat_classes[$vat_class])) { |
|
429 | 429 | ?> |
430 | - <p class="wpi-vat-rate-actions"><input id="wpi_vat_rate_delete" type="button" value="<?php echo wp_sprintf( esc_attr__( 'Delete class "%s"', 'invoicing' ), $vat_classes[$vat_class] );?>" class="button button-primary" /> <i style="display:none;" class="fa fa-refresh fa-spin"></i></p> |
|
430 | + <p class="wpi-vat-rate-actions"><input id="wpi_vat_rate_delete" type="button" value="<?php echo wp_sprintf(esc_attr__('Delete class "%s"', 'invoicing'), $vat_classes[$vat_class]); ?>" class="button button-primary" /> <i style="display:none;" class="fa fa-refresh fa-spin"></i></p> |
|
431 | 431 | <?php |
432 | 432 | } |
433 | 433 | } |
434 | 434 | |
435 | -function wpinv_vat_rates_callback( $args ) { |
|
435 | +function wpinv_vat_rates_callback($args) { |
|
436 | 436 | global $wpinv_euvat; |
437 | 437 | |
438 | 438 | $vat_classes = $wpinv_euvat->get_rate_classes(); |
439 | - $vat_class = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' && isset( $vat_classes[$_REQUEST['wpi_sub']] )? sanitize_text_field( $_REQUEST['wpi_sub'] ) : '_standard'; |
|
439 | + $vat_class = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' && isset($vat_classes[$_REQUEST['wpi_sub']]) ? sanitize_text_field($_REQUEST['wpi_sub']) : '_standard'; |
|
440 | 440 | |
441 | 441 | $eu_states = $wpinv_euvat->get_eu_states(); |
442 | 442 | $countries = wpinv_get_country_list(); |
443 | 443 | $vat_groups = $wpinv_euvat->get_vat_groups(); |
444 | - $rates = $wpinv_euvat->get_vat_rates( $vat_class ); |
|
444 | + $rates = $wpinv_euvat->get_vat_rates($vat_class); |
|
445 | 445 | ob_start(); |
446 | 446 | ?> |
447 | 447 | </td><tr> |
448 | 448 | <td colspan="2" class="wpinv_vat_tdbox"> |
449 | - <input type="hidden" name="wpi_vat_class" value="<?php echo $vat_class;?>" /> |
|
450 | - <p><?php echo ( isset( $args['desc'] ) ? $args['desc'] : '' ); ?></p> |
|
449 | + <input type="hidden" name="wpi_vat_class" value="<?php echo $vat_class; ?>" /> |
|
450 | + <p><?php echo (isset($args['desc']) ? $args['desc'] : ''); ?></p> |
|
451 | 451 | <table id="wpinv_vat_rates" class="wp-list-table widefat fixed posts"> |
452 | 452 | <colgroup> |
453 | 453 | <col width="50px" /> |
@@ -459,43 +459,43 @@ discard block |
||
459 | 459 | </colgroup> |
460 | 460 | <thead> |
461 | 461 | <tr> |
462 | - <th scope="col" colspan="2" class="wpinv_vat_country_name"><?php _e( 'Country', 'invoicing' ); ?></th> |
|
463 | - <th scope="col" class="wpinv_vat_global" title="<?php esc_attr_e( 'Apply rate to whole country', 'invoicing' ); ?>"><?php _e( 'Country Wide', 'invoicing' ); ?></th> |
|
464 | - <th scope="col" class="wpinv_vat_rate"><?php _e( 'Rate %', 'invoicing' ); ?></th> |
|
465 | - <th scope="col" class="wpinv_vat_name"><?php _e( 'VAT Name', 'invoicing' ); ?></th> |
|
466 | - <th scope="col" class="wpinv_vat_group"><?php _e( 'Tax Group', 'invoicing' ); ?></th> |
|
462 | + <th scope="col" colspan="2" class="wpinv_vat_country_name"><?php _e('Country', 'invoicing'); ?></th> |
|
463 | + <th scope="col" class="wpinv_vat_global" title="<?php esc_attr_e('Apply rate to whole country', 'invoicing'); ?>"><?php _e('Country Wide', 'invoicing'); ?></th> |
|
464 | + <th scope="col" class="wpinv_vat_rate"><?php _e('Rate %', 'invoicing'); ?></th> |
|
465 | + <th scope="col" class="wpinv_vat_name"><?php _e('VAT Name', 'invoicing'); ?></th> |
|
466 | + <th scope="col" class="wpinv_vat_group"><?php _e('Tax Group', 'invoicing'); ?></th> |
|
467 | 467 | </tr> |
468 | 468 | </thead> |
469 | 469 | <tbody> |
470 | - <?php if( !empty( $eu_states ) ) { ?> |
|
470 | + <?php if (!empty($eu_states)) { ?> |
|
471 | 471 | <?php |
472 | - foreach ( $eu_states as $state ) { |
|
473 | - $country_name = isset( $countries[$state] ) ? $countries[$state] : ''; |
|
472 | + foreach ($eu_states as $state) { |
|
473 | + $country_name = isset($countries[$state]) ? $countries[$state] : ''; |
|
474 | 474 | |
475 | 475 | // Filter the rate for each country |
476 | - $country_rate = array_filter( $rates, function( $rate ) use( $state ) { return $rate['country'] === $state; } ); |
|
476 | + $country_rate = array_filter($rates, function($rate) use($state) { return $rate['country'] === $state; } ); |
|
477 | 477 | |
478 | 478 | // If one does not exist create a default |
479 | - $country_rate = is_array( $country_rate ) && count( $country_rate ) > 0 ? reset( $country_rate ) : array(); |
|
479 | + $country_rate = is_array($country_rate) && count($country_rate) > 0 ? reset($country_rate) : array(); |
|
480 | 480 | |
481 | - $vat_global = isset( $country_rate['global'] ) ? !empty( $country_rate['global'] ) : true; |
|
482 | - $vat_rate = isset( $country_rate['rate'] ) ? $country_rate['rate'] : ''; |
|
483 | - $vat_name = !empty( $country_rate['name'] ) ? esc_attr( stripslashes( $country_rate['name'] ) ) : ''; |
|
484 | - $vat_group = !empty( $country_rate['group'] ) ? $country_rate['group'] : ( $vat_class === '_standard' ? 'standard' : 'reduced' ); |
|
481 | + $vat_global = isset($country_rate['global']) ? !empty($country_rate['global']) : true; |
|
482 | + $vat_rate = isset($country_rate['rate']) ? $country_rate['rate'] : ''; |
|
483 | + $vat_name = !empty($country_rate['name']) ? esc_attr(stripslashes($country_rate['name'])) : ''; |
|
484 | + $vat_group = !empty($country_rate['group']) ? $country_rate['group'] : ($vat_class === '_standard' ? 'standard' : 'reduced'); |
|
485 | 485 | ?> |
486 | 486 | <tr> |
487 | 487 | <td class="wpinv_vat_country"><?php echo $state; ?><input type="hidden" name="vat_rates[<?php echo $state; ?>][country]" value="<?php echo $state; ?>" /><input type="hidden" name="vat_rates[<?php echo $state; ?>][state]" value="" /></td> |
488 | 488 | <td class="wpinv_vat_country_name"><?php echo $country_name; ?></td> |
489 | 489 | <td class="wpinv_vat_global"> |
490 | - <input type="checkbox" name="vat_rates[<?php echo $state;?>][global]" id="vat_rates[<?php echo $state;?>][global]" value="1" <?php checked( true, $vat_global );?> disabled="disabled" /> |
|
491 | - <label for="tax_rates[<?php echo $state;?>][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label> |
|
492 | - <input type="hidden" name="vat_rates[<?php echo $state;?>][global]" value="1" checked="checked" /> |
|
490 | + <input type="checkbox" name="vat_rates[<?php echo $state; ?>][global]" id="vat_rates[<?php echo $state; ?>][global]" value="1" <?php checked(true, $vat_global); ?> disabled="disabled" /> |
|
491 | + <label for="tax_rates[<?php echo $state; ?>][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label> |
|
492 | + <input type="hidden" name="vat_rates[<?php echo $state; ?>][global]" value="1" checked="checked" /> |
|
493 | 493 | </td> |
494 | - <td class="wpinv_vat_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="vat_rates[<?php echo $state;?>][rate]" value="<?php echo $vat_rate; ?>" /></td> |
|
495 | - <td class="wpinv_vat_name"><input type="text" class="regular-text" name="vat_rates[<?php echo $state;?>][name]" value="<?php echo $vat_name; ?>" /></td> |
|
494 | + <td class="wpinv_vat_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="vat_rates[<?php echo $state; ?>][rate]" value="<?php echo $vat_rate; ?>" /></td> |
|
495 | + <td class="wpinv_vat_name"><input type="text" class="regular-text" name="vat_rates[<?php echo $state; ?>][name]" value="<?php echo $vat_name; ?>" /></td> |
|
496 | 496 | <td class="wpinv_vat_group"> |
497 | 497 | <?php |
498 | - echo wpinv_html_select( array( |
|
498 | + echo wpinv_html_select(array( |
|
499 | 499 | 'name' => 'vat_rates[' . $state . '][group]', |
500 | 500 | 'selected' => $vat_group, |
501 | 501 | 'id' => 'vat_rates[' . $state . '][group]', |
@@ -504,14 +504,14 @@ discard block |
||
504 | 504 | 'multiple' => false, |
505 | 505 | 'show_option_all' => false, |
506 | 506 | 'show_option_none' => false |
507 | - ) ); |
|
507 | + )); |
|
508 | 508 | ?> |
509 | 509 | </td> |
510 | 510 | </tr> |
511 | 511 | <?php } ?> |
512 | 512 | <tr> |
513 | 513 | <td colspan="6" style="background-color:#fafafa;"> |
514 | - <span><input id="wpi_vat_get_rates_group" type="button" class="button-secondary" value="<?php esc_attr_e( 'Update EU VAT Rates', 'invoicing' ); ?>" /> <i style="display:none" class="fa fa-refresh fa-spin"></i></span><span id="wpinv-rates-error-wrap" class="wpinv_errors" style="display:none;"></span> |
|
514 | + <span><input id="wpi_vat_get_rates_group" type="button" class="button-secondary" value="<?php esc_attr_e('Update EU VAT Rates', 'invoicing'); ?>" /> <i style="display:none" class="fa fa-refresh fa-spin"></i></span><span id="wpinv-rates-error-wrap" class="wpinv_errors" style="display:none;"></span> |
|
515 | 515 | </td> |
516 | 516 | </tr> |
517 | 517 | <?php } ?> |
@@ -528,22 +528,22 @@ discard block |
||
528 | 528 | * |
529 | 529 | * @param string|bool|null $vat_rule |
530 | 530 | */ |
531 | -function getpaid_filter_vat_rule( $vat_rule ) { |
|
531 | +function getpaid_filter_vat_rule($vat_rule) { |
|
532 | 532 | |
533 | - if ( empty( $vat_rule ) ) { |
|
533 | + if (empty($vat_rule)) { |
|
534 | 534 | return 'digital'; |
535 | 535 | } |
536 | 536 | |
537 | 537 | return $vat_rule; |
538 | 538 | } |
539 | -add_filter( 'wpinv_get_item_vat_rule', 'getpaid_filter_vat_rule' ); |
|
539 | +add_filter('wpinv_get_item_vat_rule', 'getpaid_filter_vat_rule'); |
|
540 | 540 | |
541 | 541 | /** |
542 | 542 | * Filters the VAT class to ensure that each item has a VAT class. |
543 | 543 | * |
544 | 544 | * @param string|bool|null $vat_rule |
545 | 545 | */ |
546 | -function getpaid_filter_vat_class( $vat_class ) { |
|
547 | - return empty( $vat_class ) ? '_standard' : $vat_class; |
|
546 | +function getpaid_filter_vat_class($vat_class) { |
|
547 | + return empty($vat_class) ? '_standard' : $vat_class; |
|
548 | 548 | } |
549 | -add_filter( 'wpinv_get_item_vat_class', 'getpaid_filter_vat_class' ); |
|
549 | +add_filter('wpinv_get_item_vat_class', 'getpaid_filter_vat_class'); |
@@ -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 | * Retrieves the current invoice. |
@@ -14,15 +14,15 @@ discard block |
||
14 | 14 | function getpaid_get_current_invoice_id() { |
15 | 15 | |
16 | 16 | // Ensure that we have an invoice key. |
17 | - if ( empty( $_GET['invoice_key'] ) ) { |
|
17 | + if (empty($_GET['invoice_key'])) { |
|
18 | 18 | return 0; |
19 | 19 | } |
20 | 20 | |
21 | 21 | // Retrieve an invoice using the key. |
22 | - $invoice = new WPInv_Invoice( $_GET['invoice_key'] ); |
|
22 | + $invoice = new WPInv_Invoice($_GET['invoice_key']); |
|
23 | 23 | |
24 | 24 | // Compare the invoice key and the parsed key. |
25 | - if ( $invoice->get_id() != 0 && $invoice->get_key() == $_GET['invoice_key'] ) { |
|
25 | + if ($invoice->get_id() != 0 && $invoice->get_key() == $_GET['invoice_key']) { |
|
26 | 26 | return $invoice->get_id(); |
27 | 27 | } |
28 | 28 | |
@@ -32,42 +32,42 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * Checks if the current user cna view an invoice. |
34 | 34 | */ |
35 | -function wpinv_user_can_view_invoice( $invoice ) { |
|
36 | - $invoice = new WPInv_Invoice( $invoice ); |
|
35 | +function wpinv_user_can_view_invoice($invoice) { |
|
36 | + $invoice = new WPInv_Invoice($invoice); |
|
37 | 37 | |
38 | 38 | // Abort if the invoice does not exist. |
39 | - if ( 0 == $invoice->get_id() ) { |
|
39 | + if (0 == $invoice->get_id()) { |
|
40 | 40 | return false; |
41 | 41 | } |
42 | 42 | |
43 | 43 | // Don't allow trash, draft status |
44 | - if ( $invoice->is_draft() ) { |
|
44 | + if ($invoice->is_draft()) { |
|
45 | 45 | return false; |
46 | 46 | } |
47 | 47 | |
48 | 48 | // If users are not required to login to check out, compare the invoice keys. |
49 | - if ( ! wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && trim( $_GET['invoice_key'] ) == $invoice->get_key() ) { |
|
49 | + if (!wpinv_require_login_to_checkout() && isset($_GET['invoice_key']) && trim($_GET['invoice_key']) == $invoice->get_key()) { |
|
50 | 50 | return true; |
51 | 51 | } |
52 | 52 | |
53 | 53 | // Always enable for admins.. |
54 | - if ( wpinv_current_user_can_manage_invoicing() || current_user_can( 'view_invoices', $invoice->get_id() ) ) { // Admin user |
|
54 | + if (wpinv_current_user_can_manage_invoicing() || current_user_can('view_invoices', $invoice->get_id())) { // Admin user |
|
55 | 55 | return true; |
56 | 56 | } |
57 | 57 | |
58 | 58 | // Else, ensure that this is their invoice. |
59 | - if ( is_user_logged_in() && $invoice->get_user_id() == get_current_user_id() ) { |
|
59 | + if (is_user_logged_in() && $invoice->get_user_id() == get_current_user_id()) { |
|
60 | 60 | return true; |
61 | 61 | } |
62 | 62 | |
63 | - return apply_filters( 'wpinv_current_user_can_view_invoice', false, $invoice ); |
|
63 | + return apply_filters('wpinv_current_user_can_view_invoice', false, $invoice); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
67 | 67 | * Checks if the current user cna view an invoice receipt. |
68 | 68 | */ |
69 | -function wpinv_can_view_receipt( $invoice ) { |
|
70 | - return (bool) apply_filters( 'wpinv_can_view_receipt', wpinv_user_can_view_invoice( $invoice ), $invoice ); |
|
69 | +function wpinv_can_view_receipt($invoice) { |
|
70 | + return (bool) apply_filters('wpinv_can_view_receipt', wpinv_user_can_view_invoice($invoice), $invoice); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | */ |
78 | 78 | function getpaid_get_invoice_post_types() { |
79 | 79 | $post_types = array( |
80 | - 'wpi_quote' => __( 'Quote', 'invoicing' ), |
|
81 | - 'wpi_invoice' => __( 'Invoice', 'invoicing' ), |
|
80 | + 'wpi_quote' => __('Quote', 'invoicing'), |
|
81 | + 'wpi_invoice' => __('Invoice', 'invoicing'), |
|
82 | 82 | ); |
83 | 83 | |
84 | - return apply_filters( 'getpaid_invoice_post_types', $post_types ); |
|
84 | + return apply_filters('getpaid_invoice_post_types', $post_types); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @param string $post_type The post type to check for. |
92 | 92 | */ |
93 | -function getpaid_is_invoice_post_type( $post_type ) { |
|
94 | - return ! empty( $post_type ) && array_key_exists( $post_type, getpaid_get_invoice_post_types() ); |
|
93 | +function getpaid_is_invoice_post_type($post_type) { |
|
94 | + return !empty($post_type) && array_key_exists($post_type, getpaid_get_invoice_post_types()); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | * @param bool $wp_error Whether to return false or WP_Error on failure. |
102 | 102 | * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success. |
103 | 103 | */ |
104 | -function wpinv_create_invoice( $data = array(), $deprecated = null, $wp_error = false ) { |
|
105 | - $data[ 'invoice_id' ] = 0; |
|
106 | - return wpinv_insert_invoice( $data, $wp_error ); |
|
104 | +function wpinv_create_invoice($data = array(), $deprecated = null, $wp_error = false) { |
|
105 | + $data['invoice_id'] = 0; |
|
106 | + return wpinv_insert_invoice($data, $wp_error); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -113,36 +113,36 @@ discard block |
||
113 | 113 | * @param bool $wp_error Whether to return false or WP_Error on failure. |
114 | 114 | * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success. |
115 | 115 | */ |
116 | -function wpinv_update_invoice( $data = array(), $wp_error = false ) { |
|
116 | +function wpinv_update_invoice($data = array(), $wp_error = false) { |
|
117 | 117 | |
118 | 118 | // Backwards compatibility. |
119 | - if ( ! empty( $data['ID'] ) ) { |
|
119 | + if (!empty($data['ID'])) { |
|
120 | 120 | $data['invoice_id'] = $data['ID']; |
121 | 121 | } |
122 | 122 | |
123 | 123 | // Do we have an invoice id? |
124 | - if ( empty( $data['invoice_id'] ) ) { |
|
125 | - return $wp_error ? new WP_Error( 'invalid_invoice_id', __( 'Invalid invoice ID.', 'invoicing' ) ) : 0; |
|
124 | + if (empty($data['invoice_id'])) { |
|
125 | + return $wp_error ? new WP_Error('invalid_invoice_id', __('Invalid invoice ID.', 'invoicing')) : 0; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | // Retrieve the invoice. |
129 | - $invoice = wpinv_get_invoice( $data['invoice_id'] ); |
|
129 | + $invoice = wpinv_get_invoice($data['invoice_id']); |
|
130 | 130 | |
131 | 131 | // And abort if it does not exist. |
132 | - if ( empty( $invoice ) ) { |
|
133 | - return $wp_error ? new WP_Error( 'missing_invoice', __( 'Invoice not found.', 'invoicing' ) ) : 0; |
|
132 | + if (empty($invoice)) { |
|
133 | + return $wp_error ? new WP_Error('missing_invoice', __('Invoice not found.', 'invoicing')) : 0; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | // Do not update totals for paid / refunded invoices. |
137 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
137 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
138 | 138 | |
139 | - if ( ! empty( $data['items'] ) || ! empty( $data['cart_details'] ) ) { |
|
140 | - return $wp_error ? new WP_Error( 'paid_invoice', __( 'You can not update cart items for invoices that have already been paid for.', 'invoicing' ) ) : 0; |
|
139 | + if (!empty($data['items']) || !empty($data['cart_details'])) { |
|
140 | + return $wp_error ? new WP_Error('paid_invoice', __('You can not update cart items for invoices that have already been paid for.', 'invoicing')) : 0; |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | } |
144 | 144 | |
145 | - return wpinv_insert_invoice( $data, $wp_error ); |
|
145 | + return wpinv_insert_invoice($data, $wp_error); |
|
146 | 146 | |
147 | 147 | } |
148 | 148 | |
@@ -153,34 +153,34 @@ discard block |
||
153 | 153 | * @param bool $wp_error Whether to return false or WP_Error on failure. |
154 | 154 | * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success. |
155 | 155 | */ |
156 | -function wpinv_insert_invoice( $data = array(), $wp_error = false ) { |
|
156 | +function wpinv_insert_invoice($data = array(), $wp_error = false) { |
|
157 | 157 | |
158 | 158 | // Ensure that we have invoice data. |
159 | - if ( empty( $data ) ) { |
|
159 | + if (empty($data)) { |
|
160 | 160 | return false; |
161 | 161 | } |
162 | 162 | |
163 | 163 | // The invoice id will be provided when updating an invoice. |
164 | - $data['invoice_id'] = ! empty( $data['invoice_id'] ) ? (int) $data['invoice_id'] : false; |
|
164 | + $data['invoice_id'] = !empty($data['invoice_id']) ? (int) $data['invoice_id'] : false; |
|
165 | 165 | |
166 | 166 | // Retrieve the invoice. |
167 | - $invoice = new WPInv_Invoice( $data['invoice_id'] ); |
|
167 | + $invoice = new WPInv_Invoice($data['invoice_id']); |
|
168 | 168 | |
169 | 169 | // Do we have an error? |
170 | - if ( ! empty( $invoice->last_error ) ) { |
|
171 | - return $wp_error ? new WP_Error( 'invalid_invoice_id', $invoice->last_error ) : 0; |
|
170 | + if (!empty($invoice->last_error)) { |
|
171 | + return $wp_error ? new WP_Error('invalid_invoice_id', $invoice->last_error) : 0; |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | // Backwards compatibility (billing address). |
175 | - if ( ! empty( $data['user_info'] ) ) { |
|
175 | + if (!empty($data['user_info'])) { |
|
176 | 176 | |
177 | - foreach ( $data['user_info'] as $key => $value ) { |
|
177 | + foreach ($data['user_info'] as $key => $value) { |
|
178 | 178 | |
179 | - if ( $key == 'discounts' ) { |
|
179 | + if ($key == 'discounts') { |
|
180 | 180 | $value = (array) $value; |
181 | - $data[ 'discount_code' ] = empty( $value ) ? null : $value[0]; |
|
181 | + $data['discount_code'] = empty($value) ? null : $value[0]; |
|
182 | 182 | } else { |
183 | - $data[ $key ] = $value; |
|
183 | + $data[$key] = $value; |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | } |
@@ -188,30 +188,30 @@ discard block |
||
188 | 188 | } |
189 | 189 | |
190 | 190 | // Backwards compatibility. |
191 | - if ( ! empty( $data['payment_details'] ) ) { |
|
191 | + if (!empty($data['payment_details'])) { |
|
192 | 192 | |
193 | - foreach ( $data['payment_details'] as $key => $value ) { |
|
194 | - $data[ $key ] = $value; |
|
193 | + foreach ($data['payment_details'] as $key => $value) { |
|
194 | + $data[$key] = $value; |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | } |
198 | 198 | |
199 | 199 | // Set up the owner of the invoice. |
200 | - $user_id = ! empty( $data['user_id'] ) ? wpinv_clean( $data['user_id'] ) : get_current_user_id(); |
|
200 | + $user_id = !empty($data['user_id']) ? wpinv_clean($data['user_id']) : get_current_user_id(); |
|
201 | 201 | |
202 | 202 | // Make sure the user exists. |
203 | - if ( ! get_userdata( $user_id ) ) { |
|
204 | - return $wp_error ? new WP_Error( 'wpinv_invalid_user', __( 'There is no user with that ID.', 'invoicing' ) ) : 0; |
|
203 | + if (!get_userdata($user_id)) { |
|
204 | + return $wp_error ? new WP_Error('wpinv_invalid_user', __('There is no user with that ID.', 'invoicing')) : 0; |
|
205 | 205 | } |
206 | 206 | |
207 | - $address = wpinv_get_user_address( $user_id ); |
|
207 | + $address = wpinv_get_user_address($user_id); |
|
208 | 208 | |
209 | - foreach ( $address as $key => $value ) { |
|
209 | + foreach ($address as $key => $value) { |
|
210 | 210 | |
211 | - if ( $value == '' ) { |
|
212 | - $address[ $key ] = null; |
|
211 | + if ($value == '') { |
|
212 | + $address[$key] = null; |
|
213 | 213 | } else { |
214 | - $address[ $key ] = wpinv_clean( $value ); |
|
214 | + $address[$key] = wpinv_clean($value); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | } |
@@ -222,103 +222,103 @@ discard block |
||
222 | 222 | array( |
223 | 223 | |
224 | 224 | // Basic info. |
225 | - 'template' => isset( $data['template'] ) ? wpinv_clean( $data['template'] ) : null, |
|
226 | - 'email_cc' => isset( $data['email_cc'] ) ? wpinv_clean( $data['email_cc'] ) : null, |
|
227 | - 'date_created' => isset( $data['created_date'] ) ? wpinv_clean( $data['created_date'] ) : null, |
|
228 | - 'due_date' => isset( $data['due_date'] ) ? wpinv_clean( $data['due_date'] ) : null, |
|
229 | - 'date_completed' => isset( $data['date_completed'] ) ? wpinv_clean( $data['date_completed'] ) : null, |
|
230 | - 'number' => isset( $data['number'] ) ? wpinv_clean( $data['number'] ) : null, |
|
231 | - 'key' => isset( $data['key'] ) ? wpinv_clean( $data['key'] ) : null, |
|
232 | - 'status' => isset( $data['status'] ) ? wpinv_clean( $data['status'] ) : null, |
|
233 | - 'post_type' => isset( $data['post_type'] ) ? wpinv_clean( $data['post_type'] ) : null, |
|
234 | - 'user_ip' => isset( $data['ip'] ) ? wpinv_clean( $data['ip'] ) : wpinv_get_ip(), |
|
235 | - 'parent_id' => isset( $data['parent'] ) ? intval( $data['parent'] ) : null, |
|
236 | - 'mode' => isset( $data['mode'] ) ? wpinv_clean( $data['mode'] ) : null, |
|
237 | - 'description' => isset( $data['description'] ) ? wp_kses_post( $data['description'] ) : null, |
|
225 | + 'template' => isset($data['template']) ? wpinv_clean($data['template']) : null, |
|
226 | + 'email_cc' => isset($data['email_cc']) ? wpinv_clean($data['email_cc']) : null, |
|
227 | + 'date_created' => isset($data['created_date']) ? wpinv_clean($data['created_date']) : null, |
|
228 | + 'due_date' => isset($data['due_date']) ? wpinv_clean($data['due_date']) : null, |
|
229 | + 'date_completed' => isset($data['date_completed']) ? wpinv_clean($data['date_completed']) : null, |
|
230 | + 'number' => isset($data['number']) ? wpinv_clean($data['number']) : null, |
|
231 | + 'key' => isset($data['key']) ? wpinv_clean($data['key']) : null, |
|
232 | + 'status' => isset($data['status']) ? wpinv_clean($data['status']) : null, |
|
233 | + 'post_type' => isset($data['post_type']) ? wpinv_clean($data['post_type']) : null, |
|
234 | + 'user_ip' => isset($data['ip']) ? wpinv_clean($data['ip']) : wpinv_get_ip(), |
|
235 | + 'parent_id' => isset($data['parent']) ? intval($data['parent']) : null, |
|
236 | + 'mode' => isset($data['mode']) ? wpinv_clean($data['mode']) : null, |
|
237 | + 'description' => isset($data['description']) ? wp_kses_post($data['description']) : null, |
|
238 | 238 | |
239 | 239 | // Payment info. |
240 | - 'disable_taxes' => ! empty( $data['disable_taxes'] ), |
|
241 | - 'currency' => isset( $data['currency'] ) ? wpinv_clean( $data['currency'] ) : wpinv_get_currency(), |
|
242 | - 'gateway' => isset( $data['gateway'] ) ? wpinv_clean( $data['gateway'] ) : null, |
|
243 | - 'transaction_id' => isset( $data['transaction_id'] ) ? wpinv_clean( $data['transaction_id'] ) : null, |
|
244 | - 'discount_code' => isset( $data['discount_code'] ) ? wpinv_clean( $data['discount_code'] ) : null, |
|
245 | - 'payment_form' => isset( $data['payment_form'] ) ? intval( $data['payment_form'] ) : null, |
|
246 | - 'submission_id' => isset( $data['submission_id'] ) ? wpinv_clean( $data['submission_id'] ) : null, |
|
247 | - 'subscription_id' => isset( $data['subscription_id'] ) ? wpinv_clean( $data['subscription_id'] ) : null, |
|
248 | - 'is_viewed' => isset( $data['is_viewed'] ) ? wpinv_clean( $data['is_viewed'] ) : null, |
|
249 | - 'fees' => isset( $data['fees'] ) ? wpinv_clean( $data['fees'] ) : null, |
|
250 | - 'discounts' => isset( $data['discounts'] ) ? wpinv_clean( $data['discounts'] ) : null, |
|
251 | - 'taxes' => isset( $data['taxes'] ) ? wpinv_clean( $data['taxes'] ) : null, |
|
240 | + 'disable_taxes' => !empty($data['disable_taxes']), |
|
241 | + 'currency' => isset($data['currency']) ? wpinv_clean($data['currency']) : wpinv_get_currency(), |
|
242 | + 'gateway' => isset($data['gateway']) ? wpinv_clean($data['gateway']) : null, |
|
243 | + 'transaction_id' => isset($data['transaction_id']) ? wpinv_clean($data['transaction_id']) : null, |
|
244 | + 'discount_code' => isset($data['discount_code']) ? wpinv_clean($data['discount_code']) : null, |
|
245 | + 'payment_form' => isset($data['payment_form']) ? intval($data['payment_form']) : null, |
|
246 | + 'submission_id' => isset($data['submission_id']) ? wpinv_clean($data['submission_id']) : null, |
|
247 | + 'subscription_id' => isset($data['subscription_id']) ? wpinv_clean($data['subscription_id']) : null, |
|
248 | + 'is_viewed' => isset($data['is_viewed']) ? wpinv_clean($data['is_viewed']) : null, |
|
249 | + 'fees' => isset($data['fees']) ? wpinv_clean($data['fees']) : null, |
|
250 | + 'discounts' => isset($data['discounts']) ? wpinv_clean($data['discounts']) : null, |
|
251 | + 'taxes' => isset($data['taxes']) ? wpinv_clean($data['taxes']) : null, |
|
252 | 252 | |
253 | 253 | |
254 | 254 | // Billing details. |
255 | 255 | 'user_id' => $data['user_id'], |
256 | - 'first_name' => isset( $data['first_name'] ) ? wpinv_clean( $data['first_name'] ) : $address['first_name'], |
|
257 | - 'last_name' => isset( $data['last_name'] ) ? wpinv_clean( $data['last_name'] ) : $address['last_name'], |
|
258 | - 'address' => isset( $data['address'] ) ? wpinv_clean( $data['address'] ) : $address['address'] , |
|
259 | - 'vat_number' => isset( $data['vat_number'] ) ? wpinv_clean( $data['vat_number'] ) : $address['vat_number'], |
|
260 | - 'company' => isset( $data['company'] ) ? wpinv_clean( $data['company'] ) : $address['company'], |
|
261 | - 'zip' => isset( $data['zip'] ) ? wpinv_clean( $data['zip'] ) : $address['zip'], |
|
262 | - 'state' => isset( $data['state'] ) ? wpinv_clean( $data['state'] ) : $address['state'], |
|
263 | - 'city' => isset( $data['city'] ) ? wpinv_clean( $data['city'] ) : $address['city'], |
|
264 | - 'country' => isset( $data['country'] ) ? wpinv_clean( $data['country'] ) : $address['country'], |
|
265 | - 'phone' => isset( $data['phone'] ) ? wpinv_clean( $data['phone'] ) : $address['phone'], |
|
266 | - 'address_confirmed' => ! empty( $data['address_confirmed'] ), |
|
256 | + 'first_name' => isset($data['first_name']) ? wpinv_clean($data['first_name']) : $address['first_name'], |
|
257 | + 'last_name' => isset($data['last_name']) ? wpinv_clean($data['last_name']) : $address['last_name'], |
|
258 | + 'address' => isset($data['address']) ? wpinv_clean($data['address']) : $address['address'], |
|
259 | + 'vat_number' => isset($data['vat_number']) ? wpinv_clean($data['vat_number']) : $address['vat_number'], |
|
260 | + 'company' => isset($data['company']) ? wpinv_clean($data['company']) : $address['company'], |
|
261 | + 'zip' => isset($data['zip']) ? wpinv_clean($data['zip']) : $address['zip'], |
|
262 | + 'state' => isset($data['state']) ? wpinv_clean($data['state']) : $address['state'], |
|
263 | + 'city' => isset($data['city']) ? wpinv_clean($data['city']) : $address['city'], |
|
264 | + 'country' => isset($data['country']) ? wpinv_clean($data['country']) : $address['country'], |
|
265 | + 'phone' => isset($data['phone']) ? wpinv_clean($data['phone']) : $address['phone'], |
|
266 | + 'address_confirmed' => !empty($data['address_confirmed']), |
|
267 | 267 | |
268 | 268 | ) |
269 | 269 | |
270 | 270 | ); |
271 | 271 | |
272 | 272 | // Backwards compatibililty. |
273 | - if ( ! empty( $data['cart_details'] ) && is_array( $data['cart_details'] ) ) { |
|
273 | + if (!empty($data['cart_details']) && is_array($data['cart_details'])) { |
|
274 | 274 | $data['items'] = array(); |
275 | 275 | |
276 | - foreach( $data['cart_details'] as $_item ) { |
|
276 | + foreach ($data['cart_details'] as $_item) { |
|
277 | 277 | |
278 | 278 | // Ensure that we have an item id. |
279 | - if ( empty( $_item['id'] ) ) { |
|
279 | + if (empty($_item['id'])) { |
|
280 | 280 | continue; |
281 | 281 | } |
282 | 282 | |
283 | 283 | // Retrieve the item. |
284 | - $item = new GetPaid_Form_Item( $_item['id'] ); |
|
284 | + $item = new GetPaid_Form_Item($_item['id']); |
|
285 | 285 | |
286 | 286 | // Ensure that it is purchasable. |
287 | - if ( ! $item->can_purchase() ) { |
|
287 | + if (!$item->can_purchase()) { |
|
288 | 288 | continue; |
289 | 289 | } |
290 | 290 | |
291 | 291 | // Set quantity. |
292 | - if ( ! empty( $_item['quantity'] ) && is_numeric( $_item['quantity'] ) ) { |
|
293 | - $item->set_quantity( $_item['quantity'] ); |
|
292 | + if (!empty($_item['quantity']) && is_numeric($_item['quantity'])) { |
|
293 | + $item->set_quantity($_item['quantity']); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | // Set price. |
297 | - if ( isset( $_item['item_price'] ) ) { |
|
298 | - $item->set_price( $_item['item_price'] ); |
|
297 | + if (isset($_item['item_price'])) { |
|
298 | + $item->set_price($_item['item_price']); |
|
299 | 299 | } |
300 | 300 | |
301 | - if ( isset( $_item['custom_price'] ) ) { |
|
302 | - $item->set_price( $_item['custom_price'] ); |
|
301 | + if (isset($_item['custom_price'])) { |
|
302 | + $item->set_price($_item['custom_price']); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | // Set name. |
306 | - if ( ! empty( $_item['name'] ) ) { |
|
307 | - $item->set_name( $_item['name'] ); |
|
306 | + if (!empty($_item['name'])) { |
|
307 | + $item->set_name($_item['name']); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | // Set description. |
311 | - if ( isset( $_item['description'] ) ) { |
|
312 | - $item->set_custom_description( $_item['description'] ); |
|
311 | + if (isset($_item['description'])) { |
|
312 | + $item->set_custom_description($_item['description']); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | // Set meta. |
316 | - if ( isset( $_item['meta'] ) && is_array( $_item['meta'] ) ) { |
|
316 | + if (isset($_item['meta']) && is_array($_item['meta'])) { |
|
317 | 317 | |
318 | - $item->set_item_meta( $_item['meta'] ); |
|
318 | + $item->set_item_meta($_item['meta']); |
|
319 | 319 | |
320 | - if ( isset( $_item['meta']['description'] ) ) { |
|
321 | - $item->set_custom_description( $_item['meta']['description'] ); |
|
320 | + if (isset($_item['meta']['description'])) { |
|
321 | + $item->set_custom_description($_item['meta']['description']); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | } |
@@ -329,14 +329,14 @@ discard block |
||
329 | 329 | } |
330 | 330 | |
331 | 331 | // Add invoice items. |
332 | - if ( ! empty( $data['items'] ) && is_array( $data['items'] ) ) { |
|
332 | + if (!empty($data['items']) && is_array($data['items'])) { |
|
333 | 333 | |
334 | - $invoice->set_items( array() ); |
|
334 | + $invoice->set_items(array()); |
|
335 | 335 | |
336 | - foreach ( $data['items'] as $item ) { |
|
336 | + foreach ($data['items'] as $item) { |
|
337 | 337 | |
338 | - if ( is_object( $item ) && is_a( $item, 'GetPaid_Form_Item' ) && $item->can_purchase() ) { |
|
339 | - $invoice->add_item( $item ); |
|
338 | + if (is_object($item) && is_a($item, 'GetPaid_Form_Item') && $item->can_purchase()) { |
|
339 | + $invoice->add_item($item); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | } |
@@ -347,30 +347,30 @@ discard block |
||
347 | 347 | $invoice->recalculate_total(); |
348 | 348 | $invoice->save(); |
349 | 349 | |
350 | - if ( ! $invoice->get_id() ) { |
|
351 | - return $wp_error ? new WP_Error( 'wpinv_insert_invoice_error', __( 'An error occured when saving your invoice.', 'invoicing' ) ) : 0; |
|
350 | + if (!$invoice->get_id()) { |
|
351 | + return $wp_error ? new WP_Error('wpinv_insert_invoice_error', __('An error occured when saving your invoice.', 'invoicing')) : 0; |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | // Add private note. |
355 | - if ( ! empty( $data['private_note'] ) ) { |
|
356 | - $invoice->add_note( $data['private_note'] ); |
|
355 | + if (!empty($data['private_note'])) { |
|
356 | + $invoice->add_note($data['private_note']); |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | // User notes. |
360 | - if ( !empty( $data['user_note'] ) ) { |
|
361 | - $invoice->add_note( $data['user_note'], true ); |
|
360 | + if (!empty($data['user_note'])) { |
|
361 | + $invoice->add_note($data['user_note'], true); |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | // Created via. |
365 | - if ( isset( $data['created_via'] ) ) { |
|
366 | - update_post_meta( $invoice->get_id(), 'wpinv_created_via', $data['created_via'] ); |
|
365 | + if (isset($data['created_via'])) { |
|
366 | + update_post_meta($invoice->get_id(), 'wpinv_created_via', $data['created_via']); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | // Backwards compatiblity. |
370 | - if ( $invoice->is_quote() ) { |
|
370 | + if ($invoice->is_quote()) { |
|
371 | 371 | |
372 | - if ( isset( $data['valid_until'] ) ) { |
|
373 | - update_post_meta( $invoice->get_id(), 'wpinv_quote_valid_until', $data['valid_until'] ); |
|
372 | + if (isset($data['valid_until'])) { |
|
373 | + update_post_meta($invoice->get_id(), 'wpinv_quote_valid_until', $data['valid_until']); |
|
374 | 374 | } |
375 | 375 | return $invoice; |
376 | 376 | |
@@ -385,18 +385,18 @@ discard block |
||
385 | 385 | * @param $bool $deprecated |
386 | 386 | * @return WPInv_Invoice|null |
387 | 387 | */ |
388 | -function wpinv_get_invoice( $invoice = 0, $deprecated = false ) { |
|
388 | +function wpinv_get_invoice($invoice = 0, $deprecated = false) { |
|
389 | 389 | |
390 | 390 | // If we are retrieving the invoice from the cart... |
391 | - if ( $deprecated && empty( $invoice ) ) { |
|
391 | + if ($deprecated && empty($invoice)) { |
|
392 | 392 | $invoice = (int) getpaid_get_current_invoice_id(); |
393 | 393 | } |
394 | 394 | |
395 | 395 | // Retrieve the invoice. |
396 | - $invoice = new WPInv_Invoice( $invoice ); |
|
396 | + $invoice = new WPInv_Invoice($invoice); |
|
397 | 397 | |
398 | 398 | // Check if it exists. |
399 | - if ( $invoice->get_id() != 0 ) { |
|
399 | + if ($invoice->get_id() != 0) { |
|
400 | 400 | return $invoice; |
401 | 401 | } |
402 | 402 | |
@@ -409,15 +409,15 @@ discard block |
||
409 | 409 | * @param array $args Args to search for. |
410 | 410 | * @return WPInv_Invoice[]|int[]|object |
411 | 411 | */ |
412 | -function wpinv_get_invoices( $args ) { |
|
412 | +function wpinv_get_invoices($args) { |
|
413 | 413 | |
414 | 414 | // Prepare args. |
415 | 415 | $args = wp_parse_args( |
416 | 416 | $args, |
417 | 417 | array( |
418 | - 'status' => array_keys( wpinv_get_invoice_statuses() ), |
|
418 | + 'status' => array_keys(wpinv_get_invoice_statuses()), |
|
419 | 419 | 'type' => 'wpi_invoice', |
420 | - 'limit' => get_option( 'posts_per_page' ), |
|
420 | + 'limit' => get_option('posts_per_page'), |
|
421 | 421 | 'return' => 'objects', |
422 | 422 | ) |
423 | 423 | ); |
@@ -435,24 +435,24 @@ discard block |
||
435 | 435 | 'post__in' => 'include', |
436 | 436 | ); |
437 | 437 | |
438 | - foreach ( $map_legacy as $to => $from ) { |
|
439 | - if ( isset( $args[ $from ] ) ) { |
|
440 | - $args[ $to ] = $args[ $from ]; |
|
441 | - unset( $args[ $from ] ); |
|
438 | + foreach ($map_legacy as $to => $from) { |
|
439 | + if (isset($args[$from])) { |
|
440 | + $args[$to] = $args[$from]; |
|
441 | + unset($args[$from]); |
|
442 | 442 | } |
443 | 443 | } |
444 | 444 | |
445 | 445 | // Backwards compatibility. |
446 | - if ( ! empty( $args['email'] ) && empty( $args['user'] ) ) { |
|
446 | + if (!empty($args['email']) && empty($args['user'])) { |
|
447 | 447 | $args['user'] = $args['email']; |
448 | - unset( $args['email'] ); |
|
448 | + unset($args['email']); |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | // Handle cases where the user is set as an email. |
452 | - if ( ! empty( $args['author'] ) && is_email( $args['author'] ) ) { |
|
453 | - $user = get_user_by( 'email', $args['user'] ); |
|
452 | + if (!empty($args['author']) && is_email($args['author'])) { |
|
453 | + $user = get_user_by('email', $args['user']); |
|
454 | 454 | |
455 | - if ( $user ) { |
|
455 | + if ($user) { |
|
456 | 456 | $args['author'] = $user->user_email; |
457 | 457 | } |
458 | 458 | |
@@ -463,31 +463,31 @@ discard block |
||
463 | 463 | |
464 | 464 | // Show all posts. |
465 | 465 | $paginate = true; |
466 | - if ( isset( $args['paginate'] ) ) { |
|
466 | + if (isset($args['paginate'])) { |
|
467 | 467 | |
468 | 468 | $paginate = $args['paginate']; |
469 | - $args['no_found_rows'] = empty( $args['paginate'] ); |
|
470 | - unset( $args['paginate'] ); |
|
469 | + $args['no_found_rows'] = empty($args['paginate']); |
|
470 | + unset($args['paginate']); |
|
471 | 471 | |
472 | 472 | } |
473 | 473 | |
474 | 474 | // Whether to return objects or fields. |
475 | 475 | $return = $args['return']; |
476 | - unset( $args['return'] ); |
|
476 | + unset($args['return']); |
|
477 | 477 | |
478 | 478 | // Get invoices. |
479 | - $invoices = new WP_Query( apply_filters( 'wpinv_get_invoices_args', $args ) ); |
|
479 | + $invoices = new WP_Query(apply_filters('wpinv_get_invoices_args', $args)); |
|
480 | 480 | |
481 | 481 | // Prepare the results. |
482 | - if ( 'objects' === $return ) { |
|
483 | - $results = array_map( 'wpinv_get_invoice', $invoices->posts ); |
|
484 | - } elseif ( 'self' === $return ) { |
|
482 | + if ('objects' === $return) { |
|
483 | + $results = array_map('wpinv_get_invoice', $invoices->posts); |
|
484 | + } elseif ('self' === $return) { |
|
485 | 485 | return $invoices; |
486 | 486 | } else { |
487 | 487 | $results = $invoices->posts; |
488 | 488 | } |
489 | 489 | |
490 | - if ( $paginate ) { |
|
490 | + if ($paginate) { |
|
491 | 491 | return (object) array( |
492 | 492 | 'invoices' => $results, |
493 | 493 | 'total' => $invoices->found_posts, |
@@ -505,8 +505,8 @@ discard block |
||
505 | 505 | * @param string $transaction_id The transaction id to check. |
506 | 506 | * @return int Invoice id on success or 0 on failure |
507 | 507 | */ |
508 | -function wpinv_get_id_by_transaction_id( $transaction_id ) { |
|
509 | - return WPInv_Invoice::get_invoice_id_by_field( $transaction_id, 'transaction_id' ); |
|
508 | +function wpinv_get_id_by_transaction_id($transaction_id) { |
|
509 | + return WPInv_Invoice::get_invoice_id_by_field($transaction_id, 'transaction_id'); |
|
510 | 510 | } |
511 | 511 | |
512 | 512 | /** |
@@ -515,8 +515,8 @@ discard block |
||
515 | 515 | * @param string $invoice_number The invoice number to check. |
516 | 516 | * @return int Invoice id on success or 0 on failure |
517 | 517 | */ |
518 | -function wpinv_get_id_by_invoice_number( $invoice_number ) { |
|
519 | - return WPInv_Invoice::get_invoice_id_by_field( $invoice_number, 'number' ); |
|
518 | +function wpinv_get_id_by_invoice_number($invoice_number) { |
|
519 | + return WPInv_Invoice::get_invoice_id_by_field($invoice_number, 'number'); |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | /** |
@@ -525,8 +525,8 @@ discard block |
||
525 | 525 | * @param string $invoice_key The invoice key to check. |
526 | 526 | * @return int Invoice id on success or 0 on failure |
527 | 527 | */ |
528 | -function wpinv_get_invoice_id_by_key( $invoice_key ) { |
|
529 | - return WPInv_Invoice::get_invoice_id_by_field( $invoice_key, 'key' ); |
|
528 | +function wpinv_get_invoice_id_by_key($invoice_key) { |
|
529 | + return WPInv_Invoice::get_invoice_id_by_field($invoice_key, 'key'); |
|
530 | 530 | } |
531 | 531 | |
532 | 532 | /** |
@@ -536,19 +536,19 @@ discard block |
||
536 | 536 | * @param string $type Optionally filter by type i.e customer|system |
537 | 537 | * @return array|null |
538 | 538 | */ |
539 | -function wpinv_get_invoice_notes( $invoice = 0, $type = '' ) { |
|
539 | +function wpinv_get_invoice_notes($invoice = 0, $type = '') { |
|
540 | 540 | |
541 | 541 | // Prepare the invoice. |
542 | - $invoice = wpinv_get_invoice( $invoice ); |
|
543 | - if ( empty( $invoice ) ) { |
|
542 | + $invoice = wpinv_get_invoice($invoice); |
|
543 | + if (empty($invoice)) { |
|
544 | 544 | return NULL; |
545 | 545 | } |
546 | 546 | |
547 | 547 | // Fetch notes. |
548 | - $notes = getpaid_notes()->get_invoice_notes( $invoice->get_id(), $type ); |
|
548 | + $notes = getpaid_notes()->get_invoice_notes($invoice->get_id(), $type); |
|
549 | 549 | |
550 | 550 | // Filter the notes. |
551 | - return apply_filters( 'wpinv_invoice_notes', $notes, $invoice->get_id(), $type ); |
|
551 | + return apply_filters('wpinv_invoice_notes', $notes, $invoice->get_id(), $type); |
|
552 | 552 | } |
553 | 553 | |
554 | 554 | /** |
@@ -556,10 +556,10 @@ discard block |
||
556 | 556 | * |
557 | 557 | * @param string $post_type |
558 | 558 | */ |
559 | -function wpinv_get_user_invoices_columns( $post_type = 'wpi_invoice' ) { |
|
559 | +function wpinv_get_user_invoices_columns($post_type = 'wpi_invoice') { |
|
560 | 560 | |
561 | - $label = getpaid_get_post_type_label( $post_type, false ); |
|
562 | - $label = empty( $label ) ? __( 'Invoice', 'invoicing' ) : sanitize_text_field( $label ); |
|
561 | + $label = getpaid_get_post_type_label($post_type, false); |
|
562 | + $label = empty($label) ? __('Invoice', 'invoicing') : sanitize_text_field($label); |
|
563 | 563 | $columns = array( |
564 | 564 | |
565 | 565 | 'invoice-number' => array( |
@@ -568,22 +568,22 @@ discard block |
||
568 | 568 | ), |
569 | 569 | |
570 | 570 | 'created-date' => array( |
571 | - 'title' => __( 'Created Date', 'invoicing' ), |
|
571 | + 'title' => __('Created Date', 'invoicing'), |
|
572 | 572 | 'class' => 'text-left' |
573 | 573 | ), |
574 | 574 | |
575 | 575 | 'payment-date' => array( |
576 | - 'title' => __( 'Payment Date', 'invoicing' ), |
|
576 | + 'title' => __('Payment Date', 'invoicing'), |
|
577 | 577 | 'class' => 'text-left' |
578 | 578 | ), |
579 | 579 | |
580 | 580 | 'invoice-status' => array( |
581 | - 'title' => __( 'Status', 'invoicing' ), |
|
581 | + 'title' => __('Status', 'invoicing'), |
|
582 | 582 | 'class' => 'text-center' |
583 | 583 | ), |
584 | 584 | |
585 | 585 | 'invoice-total' => array( |
586 | - 'title' => __( 'Total', 'invoicing' ), |
|
586 | + 'title' => __('Total', 'invoicing'), |
|
587 | 587 | 'class' => 'text-right' |
588 | 588 | ), |
589 | 589 | |
@@ -594,7 +594,7 @@ discard block |
||
594 | 594 | |
595 | 595 | ); |
596 | 596 | |
597 | - return apply_filters( 'wpinv_user_invoices_columns', $columns, $post_type ); |
|
597 | + return apply_filters('wpinv_user_invoices_columns', $columns, $post_type); |
|
598 | 598 | } |
599 | 599 | |
600 | 600 | /** |
@@ -604,59 +604,59 @@ discard block |
||
604 | 604 | |
605 | 605 | // Find the invoice. |
606 | 606 | $invoice_id = getpaid_get_current_invoice_id(); |
607 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
607 | + $invoice = new WPInv_Invoice($invoice_id); |
|
608 | 608 | |
609 | 609 | // Abort if non was found. |
610 | - if ( empty( $invoice_id ) || $invoice->is_draft() ) { |
|
610 | + if (empty($invoice_id) || $invoice->is_draft()) { |
|
611 | 611 | |
612 | 612 | return aui()->alert( |
613 | 613 | array( |
614 | 614 | 'type' => 'warning', |
615 | - 'content' => __( 'We could not find your invoice', 'invoicing' ), |
|
615 | + 'content' => __('We could not find your invoice', 'invoicing'), |
|
616 | 616 | ) |
617 | 617 | ); |
618 | 618 | |
619 | 619 | } |
620 | 620 | |
621 | 621 | // Can the user view this invoice? |
622 | - if ( ! wpinv_can_view_receipt( $invoice_id ) ) { |
|
622 | + if (!wpinv_can_view_receipt($invoice_id)) { |
|
623 | 623 | |
624 | 624 | return aui()->alert( |
625 | 625 | array( |
626 | 626 | 'type' => 'warning', |
627 | - 'content' => __( 'You are not allowed to view this receipt', 'invoicing' ), |
|
627 | + 'content' => __('You are not allowed to view this receipt', 'invoicing'), |
|
628 | 628 | ) |
629 | 629 | ); |
630 | 630 | |
631 | 631 | } |
632 | 632 | |
633 | 633 | // Load the template. |
634 | - return wpinv_get_template_html( 'invoice-receipt.php', compact( 'invoice' ) ); |
|
634 | + return wpinv_get_template_html('invoice-receipt.php', compact('invoice')); |
|
635 | 635 | |
636 | 636 | } |
637 | 637 | |
638 | 638 | /** |
639 | 639 | * Displays the invoice history. |
640 | 640 | */ |
641 | -function getpaid_invoice_history( $user_id = 0, $post_type = 'wpi_invoice' ) { |
|
641 | +function getpaid_invoice_history($user_id = 0, $post_type = 'wpi_invoice') { |
|
642 | 642 | |
643 | 643 | // Ensure that we have a user id. |
644 | - if ( empty( $user_id ) || ! is_numeric( $user_id ) ) { |
|
644 | + if (empty($user_id) || !is_numeric($user_id)) { |
|
645 | 645 | $user_id = get_current_user_id(); |
646 | 646 | } |
647 | 647 | |
648 | - $label = getpaid_get_post_type_label( $post_type ); |
|
649 | - $label = empty( $label ) ? __( 'Invoices', 'invoicing' ) : sanitize_text_field( $label ); |
|
648 | + $label = getpaid_get_post_type_label($post_type); |
|
649 | + $label = empty($label) ? __('Invoices', 'invoicing') : sanitize_text_field($label); |
|
650 | 650 | |
651 | 651 | // View user id. |
652 | - if ( empty( $user_id ) ) { |
|
652 | + if (empty($user_id)) { |
|
653 | 653 | |
654 | 654 | return aui()->alert( |
655 | 655 | array( |
656 | 656 | 'type' => 'warning', |
657 | 657 | 'content' => sprintf( |
658 | - __( 'You must be logged in to view your %s.', 'invoicing' ), |
|
659 | - strtolower( $label ) |
|
658 | + __('You must be logged in to view your %s.', 'invoicing'), |
|
659 | + strtolower($label) |
|
660 | 660 | ) |
661 | 661 | ) |
662 | 662 | ); |
@@ -667,23 +667,23 @@ discard block |
||
667 | 667 | $invoices = wpinv_get_invoices( |
668 | 668 | |
669 | 669 | array( |
670 | - 'page' => ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1, |
|
670 | + 'page' => (get_query_var('paged')) ? absint(get_query_var('paged')) : 1, |
|
671 | 671 | 'user' => $user_id, |
672 | 672 | 'paginate' => true, |
673 | 673 | 'type' => $post_type, |
674 | - 'status' => array_keys( wpinv_get_invoice_statuses( false, false, $post_type ) ), |
|
674 | + 'status' => array_keys(wpinv_get_invoice_statuses(false, false, $post_type)), |
|
675 | 675 | ) |
676 | 676 | |
677 | 677 | ); |
678 | 678 | |
679 | - if ( empty( $invoices->total ) ) { |
|
679 | + if (empty($invoices->total)) { |
|
680 | 680 | |
681 | 681 | return aui()->alert( |
682 | 682 | array( |
683 | 683 | 'type' => 'info', |
684 | 684 | 'content' => sprintf( |
685 | - __( 'No %s found.', 'invoicing' ), |
|
686 | - strtolower( $label ) |
|
685 | + __('No %s found.', 'invoicing'), |
|
686 | + strtolower($label) |
|
687 | 687 | ) |
688 | 688 | ) |
689 | 689 | ); |
@@ -691,38 +691,38 @@ discard block |
||
691 | 691 | } |
692 | 692 | |
693 | 693 | // Load the template. |
694 | - return wpinv_get_template_html( 'invoice-history.php', compact( 'invoices', 'post_type' ) ); |
|
694 | + return wpinv_get_template_html('invoice-history.php', compact('invoices', 'post_type')); |
|
695 | 695 | |
696 | 696 | } |
697 | 697 | |
698 | 698 | /** |
699 | 699 | * Formats an invoice number given an invoice type. |
700 | 700 | */ |
701 | -function wpinv_format_invoice_number( $number, $type = '' ) { |
|
701 | +function wpinv_format_invoice_number($number, $type = '') { |
|
702 | 702 | |
703 | 703 | // Allow other plugins to overide this. |
704 | - $check = apply_filters( 'wpinv_pre_format_invoice_number', null, $number, $type ); |
|
705 | - if ( null !== $check ) { |
|
704 | + $check = apply_filters('wpinv_pre_format_invoice_number', null, $number, $type); |
|
705 | + if (null !== $check) { |
|
706 | 706 | return $check; |
707 | 707 | } |
708 | 708 | |
709 | 709 | // Ensure that we have a numeric number. |
710 | - if ( ! is_numeric( $number ) ) { |
|
710 | + if (!is_numeric($number)) { |
|
711 | 711 | return $number; |
712 | 712 | } |
713 | 713 | |
714 | 714 | // Format the number. |
715 | - $padd = absint( (int) wpinv_get_option( 'invoice_number_padd' ) ); |
|
716 | - $prefix = sanitize_text_field( (string) wpinv_get_option( 'invoice_number_prefix', 'INV-' ) ); |
|
717 | - $prefix = sanitize_text_field( apply_filters( 'getpaid_invoice_type_prefix', $prefix, $type ) ); |
|
718 | - $postfix = sanitize_text_field( (string) wpinv_get_option( 'invoice_number_postfix' ) ); |
|
719 | - $postfix = sanitize_text_field( apply_filters( 'getpaid_invoice_type_postfix', $postfix, $type ) ); |
|
720 | - $formatted_number = zeroise( absint( $number ), $padd ); |
|
715 | + $padd = absint((int) wpinv_get_option('invoice_number_padd')); |
|
716 | + $prefix = sanitize_text_field((string) wpinv_get_option('invoice_number_prefix', 'INV-')); |
|
717 | + $prefix = sanitize_text_field(apply_filters('getpaid_invoice_type_prefix', $prefix, $type)); |
|
718 | + $postfix = sanitize_text_field((string) wpinv_get_option('invoice_number_postfix')); |
|
719 | + $postfix = sanitize_text_field(apply_filters('getpaid_invoice_type_postfix', $postfix, $type)); |
|
720 | + $formatted_number = zeroise(absint($number), $padd); |
|
721 | 721 | |
722 | 722 | // Add the prefix and post fix. |
723 | 723 | $formatted_number = $prefix . $formatted_number . $postfix; |
724 | 724 | |
725 | - return apply_filters( 'wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd ); |
|
725 | + return apply_filters('wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd); |
|
726 | 726 | } |
727 | 727 | |
728 | 728 | /** |
@@ -731,58 +731,58 @@ discard block |
||
731 | 731 | * @param string $type. |
732 | 732 | * @return int|null|bool |
733 | 733 | */ |
734 | -function wpinv_get_next_invoice_number( $type = '' ) { |
|
734 | +function wpinv_get_next_invoice_number($type = '') { |
|
735 | 735 | |
736 | 736 | // Allow plugins to overide this. |
737 | - $check = apply_filters( 'wpinv_get_pre_next_invoice_number', null, $type ); |
|
738 | - if ( null !== $check ) { |
|
737 | + $check = apply_filters('wpinv_get_pre_next_invoice_number', null, $type); |
|
738 | + if (null !== $check) { |
|
739 | 739 | return $check; |
740 | 740 | } |
741 | 741 | |
742 | 742 | // Ensure sequential invoice numbers is active. |
743 | - if ( ! wpinv_sequential_number_active() ) { |
|
743 | + if (!wpinv_sequential_number_active()) { |
|
744 | 744 | return false; |
745 | 745 | } |
746 | 746 | |
747 | 747 | // Retrieve the current number and the start number. |
748 | - $number = (int) get_option( 'wpinv_last_invoice_number', 0 ); |
|
749 | - $start = absint( (int) wpinv_get_option( 'invoice_sequence_start', 1 ) ); |
|
748 | + $number = (int) get_option('wpinv_last_invoice_number', 0); |
|
749 | + $start = absint((int) wpinv_get_option('invoice_sequence_start', 1)); |
|
750 | 750 | |
751 | 751 | // Ensure that we are starting at a positive integer. |
752 | - $start = max( $start, 1 ); |
|
752 | + $start = max($start, 1); |
|
753 | 753 | |
754 | 754 | // If this is the first invoice, use the start number. |
755 | - $number = max( $start, $number ); |
|
755 | + $number = max($start, $number); |
|
756 | 756 | |
757 | 757 | // Format the invoice number. |
758 | - $formatted_number = wpinv_format_invoice_number( $number, $type ); |
|
758 | + $formatted_number = wpinv_format_invoice_number($number, $type); |
|
759 | 759 | |
760 | 760 | // Ensure that this number is unique. |
761 | - $invoice_id = WPInv_Invoice::get_invoice_id_by_field( $formatted_number, 'number' ); |
|
761 | + $invoice_id = WPInv_Invoice::get_invoice_id_by_field($formatted_number, 'number'); |
|
762 | 762 | |
763 | 763 | // We found a match. Nice. |
764 | - if ( empty( $invoice_id ) ) { |
|
765 | - update_option( 'wpinv_last_invoice_number', $number ); |
|
766 | - return apply_filters( 'wpinv_get_next_invoice_number', $number ); |
|
764 | + if (empty($invoice_id)) { |
|
765 | + update_option('wpinv_last_invoice_number', $number); |
|
766 | + return apply_filters('wpinv_get_next_invoice_number', $number); |
|
767 | 767 | } |
768 | 768 | |
769 | - update_option( 'wpinv_last_invoice_number', $number + 1 ); |
|
770 | - return wpinv_get_next_invoice_number( $type ); |
|
769 | + update_option('wpinv_last_invoice_number', $number + 1); |
|
770 | + return wpinv_get_next_invoice_number($type); |
|
771 | 771 | |
772 | 772 | } |
773 | 773 | |
774 | 774 | /** |
775 | 775 | * The prefix used for invoice paths. |
776 | 776 | */ |
777 | -function wpinv_post_name_prefix( $post_type = 'wpi_invoice' ) { |
|
778 | - return apply_filters( 'wpinv_post_name_prefix', 'inv-', $post_type ); |
|
777 | +function wpinv_post_name_prefix($post_type = 'wpi_invoice') { |
|
778 | + return apply_filters('wpinv_post_name_prefix', 'inv-', $post_type); |
|
779 | 779 | } |
780 | 780 | |
781 | -function wpinv_generate_post_name( $post_ID ) { |
|
782 | - $prefix = wpinv_post_name_prefix( get_post_type( $post_ID ) ); |
|
783 | - $post_name = sanitize_title( $prefix . $post_ID ); |
|
781 | +function wpinv_generate_post_name($post_ID) { |
|
782 | + $prefix = wpinv_post_name_prefix(get_post_type($post_ID)); |
|
783 | + $post_name = sanitize_title($prefix . $post_ID); |
|
784 | 784 | |
785 | - return apply_filters( 'wpinv_generate_post_name', $post_name, $post_ID, $prefix ); |
|
785 | + return apply_filters('wpinv_generate_post_name', $post_name, $post_ID, $prefix); |
|
786 | 786 | } |
787 | 787 | |
788 | 788 | /** |
@@ -790,8 +790,8 @@ discard block |
||
790 | 790 | * |
791 | 791 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object. |
792 | 792 | */ |
793 | -function wpinv_is_invoice_viewed( $invoice ) { |
|
794 | - $invoice = new WPInv_Invoice( $invoice ); |
|
793 | +function wpinv_is_invoice_viewed($invoice) { |
|
794 | + $invoice = new WPInv_Invoice($invoice); |
|
795 | 795 | return (bool) $invoice->get_is_viewed(); |
796 | 796 | } |
797 | 797 | |
@@ -800,17 +800,17 @@ discard block |
||
800 | 800 | * |
801 | 801 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object. |
802 | 802 | */ |
803 | -function getpaid_maybe_mark_invoice_as_viewed( $invoice ) { |
|
804 | - $invoice = new WPInv_Invoice( $invoice ); |
|
803 | +function getpaid_maybe_mark_invoice_as_viewed($invoice) { |
|
804 | + $invoice = new WPInv_Invoice($invoice); |
|
805 | 805 | |
806 | - if ( get_current_user_id() == $invoice->get_user_id() && ! $invoice->get_is_viewed() ) { |
|
807 | - $invoice->set_is_viewed( true ); |
|
806 | + if (get_current_user_id() == $invoice->get_user_id() && !$invoice->get_is_viewed()) { |
|
807 | + $invoice->set_is_viewed(true); |
|
808 | 808 | $invoice->save(); |
809 | 809 | } |
810 | 810 | |
811 | 811 | } |
812 | -add_action( 'wpinv_invoice_print_before_display', 'getpaid_maybe_mark_invoice_as_viewed' ); |
|
813 | -add_action( 'wpinv_before_receipt', 'getpaid_maybe_mark_invoice_as_viewed' ); |
|
812 | +add_action('wpinv_invoice_print_before_display', 'getpaid_maybe_mark_invoice_as_viewed'); |
|
813 | +add_action('wpinv_before_receipt', 'getpaid_maybe_mark_invoice_as_viewed'); |
|
814 | 814 | |
815 | 815 | /** |
816 | 816 | * Processes an invoice refund. |
@@ -819,27 +819,27 @@ discard block |
||
819 | 819 | * @param array $status_transition |
820 | 820 | * @todo: descrease customer/store earnings |
821 | 821 | */ |
822 | -function getpaid_maybe_process_refund( $invoice, $status_transition ) { |
|
822 | +function getpaid_maybe_process_refund($invoice, $status_transition) { |
|
823 | 823 | |
824 | - if ( empty( $status_transition['from'] ) || ! in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ) ) ) { |
|
824 | + if (empty($status_transition['from']) || !in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'))) { |
|
825 | 825 | return; |
826 | 826 | } |
827 | 827 | |
828 | 828 | $discount_code = $invoice->get_discount_code(); |
829 | - if ( ! empty( $discount_code ) ) { |
|
830 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
829 | + if (!empty($discount_code)) { |
|
830 | + $discount = wpinv_get_discount_obj($discount_code); |
|
831 | 831 | |
832 | - if ( $discount->exists() ) { |
|
832 | + if ($discount->exists()) { |
|
833 | 833 | $discount->increase_usage( -1 ); |
834 | 834 | } |
835 | 835 | |
836 | 836 | } |
837 | 837 | |
838 | - do_action( 'wpinv_pre_refund_invoice', $invoice, $invoice->get_id() ); |
|
839 | - do_action( 'wpinv_refund_invoice', $invoice, $invoice->get_id() ); |
|
840 | - do_action( 'wpinv_post_refund_invoice', $invoice, $invoice->get_id() ); |
|
838 | + do_action('wpinv_pre_refund_invoice', $invoice, $invoice->get_id()); |
|
839 | + do_action('wpinv_refund_invoice', $invoice, $invoice->get_id()); |
|
840 | + do_action('wpinv_post_refund_invoice', $invoice, $invoice->get_id()); |
|
841 | 841 | } |
842 | -add_action( 'getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 2 ); |
|
842 | +add_action('getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 2); |
|
843 | 843 | |
844 | 844 | |
845 | 845 | /** |
@@ -847,48 +847,48 @@ discard block |
||
847 | 847 | * |
848 | 848 | * @param int $invoice_id |
849 | 849 | */ |
850 | -function getpaid_process_invoice_payment( $invoice_id ) { |
|
850 | +function getpaid_process_invoice_payment($invoice_id) { |
|
851 | 851 | |
852 | 852 | // Fetch the invoice. |
853 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
853 | + $invoice = new WPInv_Invoice($invoice_id); |
|
854 | 854 | |
855 | 855 | // We only want to do this once. |
856 | - if ( 1 == get_post_meta( $invoice->get_id(), 'wpinv_processed_payment', true ) ) { |
|
856 | + if (1 == get_post_meta($invoice->get_id(), 'wpinv_processed_payment', true)) { |
|
857 | 857 | return; |
858 | 858 | } |
859 | 859 | |
860 | - update_post_meta( $invoice->get_id(), 'wpinv_processed_payment', 1 ); |
|
860 | + update_post_meta($invoice->get_id(), 'wpinv_processed_payment', 1); |
|
861 | 861 | |
862 | 862 | // Fires when processing a payment. |
863 | - do_action( 'getpaid_process_payment', $invoice ); |
|
863 | + do_action('getpaid_process_payment', $invoice); |
|
864 | 864 | |
865 | 865 | // Fire an action for each invoice item. |
866 | - foreach( $invoice->get_items() as $item ) { |
|
867 | - do_action( 'getpaid_process_item_payment', $item, $invoice ); |
|
866 | + foreach ($invoice->get_items() as $item) { |
|
867 | + do_action('getpaid_process_item_payment', $item, $invoice); |
|
868 | 868 | } |
869 | 869 | |
870 | 870 | // Increase discount usage. |
871 | 871 | $discount_code = $invoice->get_discount_code(); |
872 | - if ( ! empty( $discount_code ) && ! $invoice->is_renewal() ) { |
|
873 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
872 | + if (!empty($discount_code) && !$invoice->is_renewal()) { |
|
873 | + $discount = wpinv_get_discount_obj($discount_code); |
|
874 | 874 | |
875 | - if ( $discount->exists() ) { |
|
875 | + if ($discount->exists()) { |
|
876 | 876 | $discount->increase_usage(); |
877 | 877 | } |
878 | 878 | |
879 | 879 | } |
880 | 880 | |
881 | 881 | // Record reverse vat. |
882 | - if ( 'invoice' == $invoice->get_type() && wpinv_use_taxes() && ! $invoice->get_disable_taxes() ) { |
|
882 | + if ('invoice' == $invoice->get_type() && wpinv_use_taxes() && !$invoice->get_disable_taxes()) { |
|
883 | 883 | |
884 | - if ( wpinv_same_country_exempt_vat() && wpinv_is_base_country( $invoice->get_country() ) ) { |
|
885 | - $invoice->add_note( __( 'VAT was reverse charged', 'invoicing' ), false, false, true ); |
|
884 | + if (wpinv_same_country_exempt_vat() && wpinv_is_base_country($invoice->get_country())) { |
|
885 | + $invoice->add_note(__('VAT was reverse charged', 'invoicing'), false, false, true); |
|
886 | 886 | } |
887 | 887 | |
888 | 888 | } |
889 | 889 | |
890 | 890 | } |
891 | -add_action( 'getpaid_invoice_payment_status_changed', 'getpaid_process_invoice_payment' ); |
|
891 | +add_action('getpaid_invoice_payment_status_changed', 'getpaid_process_invoice_payment'); |
|
892 | 892 | |
893 | 893 | /** |
894 | 894 | * Returns an array of invoice item columns |
@@ -896,13 +896,13 @@ discard block |
||
896 | 896 | * @param int|WPInv_Invoice $invoice |
897 | 897 | * @return array |
898 | 898 | */ |
899 | -function getpaid_invoice_item_columns( $invoice ) { |
|
899 | +function getpaid_invoice_item_columns($invoice) { |
|
900 | 900 | |
901 | 901 | // Prepare the invoice. |
902 | - $invoice = new WPInv_Invoice( $invoice ); |
|
902 | + $invoice = new WPInv_Invoice($invoice); |
|
903 | 903 | |
904 | 904 | // Abort if there is no invoice. |
905 | - if ( 0 == $invoice->get_id() ) { |
|
905 | + if (0 == $invoice->get_id()) { |
|
906 | 906 | return array(); |
907 | 907 | } |
908 | 908 | |
@@ -910,47 +910,47 @@ discard block |
||
910 | 910 | $columns = apply_filters( |
911 | 911 | 'getpaid_invoice_item_columns', |
912 | 912 | array( |
913 | - 'name' => __( 'Item', 'invoicing' ), |
|
914 | - 'price' => __( 'Price', 'invoicing' ), |
|
915 | - 'quantity' => __( 'Quantity', 'invoicing' ), |
|
916 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
913 | + 'name' => __('Item', 'invoicing'), |
|
914 | + 'price' => __('Price', 'invoicing'), |
|
915 | + 'quantity' => __('Quantity', 'invoicing'), |
|
916 | + 'subtotal' => __('Subtotal', 'invoicing'), |
|
917 | 917 | ), |
918 | 918 | $invoice |
919 | 919 | ); |
920 | 920 | |
921 | 921 | // Quantities. |
922 | - if ( isset( $columns[ 'quantity' ] ) ) { |
|
922 | + if (isset($columns['quantity'])) { |
|
923 | 923 | |
924 | - if ( 'hours' == $invoice->get_template() ) { |
|
925 | - $columns[ 'quantity' ] = __( 'Hours', 'invoicing' ); |
|
924 | + if ('hours' == $invoice->get_template()) { |
|
925 | + $columns['quantity'] = __('Hours', 'invoicing'); |
|
926 | 926 | } |
927 | 927 | |
928 | - if ( ! wpinv_item_quantities_enabled() || 'amount' == $invoice->get_template() ) { |
|
929 | - unset( $columns[ 'quantity' ] ); |
|
928 | + if (!wpinv_item_quantities_enabled() || 'amount' == $invoice->get_template()) { |
|
929 | + unset($columns['quantity']); |
|
930 | 930 | } |
931 | 931 | |
932 | 932 | } |
933 | 933 | |
934 | 934 | |
935 | 935 | // Price. |
936 | - if ( isset( $columns[ 'price' ] ) ) { |
|
936 | + if (isset($columns['price'])) { |
|
937 | 937 | |
938 | - if ( 'amount' == $invoice->get_template() ) { |
|
939 | - $columns[ 'price' ] = __( 'Amount', 'invoicing' ); |
|
938 | + if ('amount' == $invoice->get_template()) { |
|
939 | + $columns['price'] = __('Amount', 'invoicing'); |
|
940 | 940 | } |
941 | 941 | |
942 | - if ( 'hours' == $invoice->get_template() ) { |
|
943 | - $columns[ 'price' ] = __( 'Rate', 'invoicing' ); |
|
942 | + if ('hours' == $invoice->get_template()) { |
|
943 | + $columns['price'] = __('Rate', 'invoicing'); |
|
944 | 944 | } |
945 | 945 | |
946 | 946 | } |
947 | 947 | |
948 | 948 | |
949 | 949 | // Sub total. |
950 | - if ( isset( $columns[ 'subtotal' ] ) ) { |
|
950 | + if (isset($columns['subtotal'])) { |
|
951 | 951 | |
952 | - if ( 'amount' == $invoice->get_template() ) { |
|
953 | - unset( $columns[ 'subtotal' ] ); |
|
952 | + if ('amount' == $invoice->get_template()) { |
|
953 | + unset($columns['subtotal']); |
|
954 | 954 | } |
955 | 955 | |
956 | 956 | } |
@@ -964,30 +964,30 @@ discard block |
||
964 | 964 | * @param int|WPInv_Invoice $invoice |
965 | 965 | * @return array |
966 | 966 | */ |
967 | -function getpaid_invoice_totals_rows( $invoice ) { |
|
967 | +function getpaid_invoice_totals_rows($invoice) { |
|
968 | 968 | |
969 | 969 | // Prepare the invoice. |
970 | - $invoice = new WPInv_Invoice( $invoice ); |
|
970 | + $invoice = new WPInv_Invoice($invoice); |
|
971 | 971 | |
972 | 972 | // Abort if there is no invoice. |
973 | - if ( 0 == $invoice->get_id() ) { |
|
973 | + if (0 == $invoice->get_id()) { |
|
974 | 974 | return array(); |
975 | 975 | } |
976 | 976 | |
977 | 977 | $totals = apply_filters( |
978 | 978 | 'getpaid_invoice_totals_rows', |
979 | 979 | array( |
980 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
981 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
982 | - 'fee' => __( 'Fee', 'invoicing' ), |
|
983 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
984 | - 'total' => __( 'Total', 'invoicing' ), |
|
980 | + 'subtotal' => __('Subtotal', 'invoicing'), |
|
981 | + 'tax' => __('Tax', 'invoicing'), |
|
982 | + 'fee' => __('Fee', 'invoicing'), |
|
983 | + 'discount' => __('Discount', 'invoicing'), |
|
984 | + 'total' => __('Total', 'invoicing'), |
|
985 | 985 | ), |
986 | 986 | $invoice |
987 | 987 | ); |
988 | 988 | |
989 | - if ( ( $invoice->get_disable_taxes() || ! wpinv_use_taxes() ) && isset( $totals['tax'] ) ) { |
|
990 | - unset( $totals['tax'] ); |
|
989 | + if (($invoice->get_disable_taxes() || !wpinv_use_taxes()) && isset($totals['tax'])) { |
|
990 | + unset($totals['tax']); |
|
991 | 991 | } |
992 | 992 | |
993 | 993 | return $totals; |
@@ -998,47 +998,47 @@ discard block |
||
998 | 998 | * |
999 | 999 | * @param WPInv_Invoice $invoice |
1000 | 1000 | */ |
1001 | -function getpaid_new_invoice( $invoice ) { |
|
1001 | +function getpaid_new_invoice($invoice) { |
|
1002 | 1002 | |
1003 | - if ( ! $invoice->get_status() ) { |
|
1003 | + if (!$invoice->get_status()) { |
|
1004 | 1004 | return; |
1005 | 1005 | } |
1006 | 1006 | |
1007 | 1007 | // Add an invoice created note. |
1008 | 1008 | $invoice->add_note( |
1009 | 1009 | sprintf( |
1010 | - __( '%s created with the status "%s".', 'invoicing' ), |
|
1011 | - ucfirst( $invoice->get_type() ), |
|
1012 | - wpinv_status_nicename( $invoice->get_status(), $invoice ) |
|
1010 | + __('%s created with the status "%s".', 'invoicing'), |
|
1011 | + ucfirst($invoice->get_type()), |
|
1012 | + wpinv_status_nicename($invoice->get_status(), $invoice) |
|
1013 | 1013 | ) |
1014 | 1014 | ); |
1015 | 1015 | |
1016 | 1016 | } |
1017 | -add_action( 'getpaid_new_invoice', 'getpaid_new_invoice' ); |
|
1017 | +add_action('getpaid_new_invoice', 'getpaid_new_invoice'); |
|
1018 | 1018 | |
1019 | 1019 | /** |
1020 | 1020 | * This function updates invoice caches. |
1021 | 1021 | * |
1022 | 1022 | * @param WPInv_Invoice $invoice |
1023 | 1023 | */ |
1024 | -function getpaid_update_invoice_caches( $invoice ) { |
|
1024 | +function getpaid_update_invoice_caches($invoice) { |
|
1025 | 1025 | |
1026 | 1026 | // Cache invoice number. |
1027 | - wp_cache_set( $invoice->get_number(), $invoice->get_id(), "getpaid_invoice_numbers_to_invoice_ids" ); |
|
1027 | + wp_cache_set($invoice->get_number(), $invoice->get_id(), "getpaid_invoice_numbers_to_invoice_ids"); |
|
1028 | 1028 | |
1029 | 1029 | // Cache invoice key. |
1030 | - wp_cache_set( $invoice->get_key(), $invoice->get_id(), "getpaid_invoice_keys_to_invoice_ids" ); |
|
1030 | + wp_cache_set($invoice->get_key(), $invoice->get_id(), "getpaid_invoice_keys_to_invoice_ids"); |
|
1031 | 1031 | |
1032 | 1032 | // (Maybe) cache transaction id. |
1033 | 1033 | $transaction_id = $invoice->get_transaction_id(); |
1034 | 1034 | |
1035 | - if ( ! empty( $transaction_id ) ) { |
|
1036 | - wp_cache_set( $transaction_id, $invoice->get_id(), "getpaid_invoice_transaction_ids_to_invoice_ids" ); |
|
1035 | + if (!empty($transaction_id)) { |
|
1036 | + wp_cache_set($transaction_id, $invoice->get_id(), "getpaid_invoice_transaction_ids_to_invoice_ids"); |
|
1037 | 1037 | } |
1038 | 1038 | |
1039 | 1039 | } |
1040 | -add_action( 'getpaid_new_invoice', 'getpaid_update_invoice_caches', 5 ); |
|
1041 | -add_action( 'getpaid_update_invoice', 'getpaid_update_invoice_caches', 5 ); |
|
1040 | +add_action('getpaid_new_invoice', 'getpaid_update_invoice_caches', 5); |
|
1041 | +add_action('getpaid_update_invoice', 'getpaid_update_invoice_caches', 5); |
|
1042 | 1042 | |
1043 | 1043 | /** |
1044 | 1044 | * Duplicates an invoice. |
@@ -1048,7 +1048,7 @@ discard block |
||
1048 | 1048 | * @param WPInv_Invoice $old_invoice The invoice to duplicate |
1049 | 1049 | * @return WPInv_Invoice The new invoice. |
1050 | 1050 | */ |
1051 | -function getpaid_duplicate_invoice( $old_invoice ) { |
|
1051 | +function getpaid_duplicate_invoice($old_invoice) { |
|
1052 | 1052 | |
1053 | 1053 | // Create the new invoice. |
1054 | 1054 | $invoice = new WPInv_Invoice(); |
@@ -1109,126 +1109,126 @@ discard block |
||
1109 | 1109 | * @param WPInv_Invoice $invoice |
1110 | 1110 | * @return array |
1111 | 1111 | */ |
1112 | -function getpaid_get_invoice_meta( $invoice ) { |
|
1112 | +function getpaid_get_invoice_meta($invoice) { |
|
1113 | 1113 | |
1114 | 1114 | // Load the invoice meta. |
1115 | 1115 | $meta = array( |
1116 | 1116 | |
1117 | 1117 | 'number' => array( |
1118 | 1118 | 'label' => sprintf( |
1119 | - __( '%s Number', 'invoicing' ), |
|
1120 | - ucfirst( $invoice->get_type() ) |
|
1119 | + __('%s Number', 'invoicing'), |
|
1120 | + ucfirst($invoice->get_type()) |
|
1121 | 1121 | ), |
1122 | - 'value' => sanitize_text_field( $invoice->get_number() ), |
|
1122 | + 'value' => sanitize_text_field($invoice->get_number()), |
|
1123 | 1123 | ), |
1124 | 1124 | |
1125 | 1125 | 'status' => array( |
1126 | 1126 | 'label' => sprintf( |
1127 | - __( '%s Status', 'invoicing' ), |
|
1128 | - ucfirst( $invoice->get_type() ) |
|
1127 | + __('%s Status', 'invoicing'), |
|
1128 | + ucfirst($invoice->get_type()) |
|
1129 | 1129 | ), |
1130 | 1130 | 'value' => $invoice->get_status_label_html(), |
1131 | 1131 | ), |
1132 | 1132 | |
1133 | 1133 | 'date' => array( |
1134 | 1134 | 'label' => sprintf( |
1135 | - __( '%s Date', 'invoicing' ), |
|
1136 | - ucfirst( $invoice->get_type() ) |
|
1135 | + __('%s Date', 'invoicing'), |
|
1136 | + ucfirst($invoice->get_type()) |
|
1137 | 1137 | ), |
1138 | - 'value' => getpaid_format_date( $invoice->get_created_date() ), |
|
1138 | + 'value' => getpaid_format_date($invoice->get_created_date()), |
|
1139 | 1139 | ), |
1140 | 1140 | |
1141 | 1141 | 'date_paid' => array( |
1142 | - 'label' => __( 'Paid On', 'invoicing' ), |
|
1143 | - 'value' => getpaid_format_date( $invoice->get_completed_date() ), |
|
1142 | + 'label' => __('Paid On', 'invoicing'), |
|
1143 | + 'value' => getpaid_format_date($invoice->get_completed_date()), |
|
1144 | 1144 | ), |
1145 | 1145 | |
1146 | 1146 | 'gateway' => array( |
1147 | - 'label' => __( 'Payment Method', 'invoicing' ), |
|
1148 | - 'value' => sanitize_text_field( $invoice->get_gateway_title() ), |
|
1147 | + 'label' => __('Payment Method', 'invoicing'), |
|
1148 | + 'value' => sanitize_text_field($invoice->get_gateway_title()), |
|
1149 | 1149 | ), |
1150 | 1150 | |
1151 | 1151 | 'transaction_id' => array( |
1152 | - 'label' => __( 'Transaction ID', 'invoicing' ), |
|
1153 | - 'value' => sanitize_text_field( $invoice->get_transaction_id() ), |
|
1152 | + 'label' => __('Transaction ID', 'invoicing'), |
|
1153 | + 'value' => sanitize_text_field($invoice->get_transaction_id()), |
|
1154 | 1154 | ), |
1155 | 1155 | |
1156 | 1156 | 'due_date' => array( |
1157 | - 'label' => __( 'Due Date', 'invoicing' ), |
|
1158 | - 'value' => getpaid_format_date( $invoice->get_due_date() ), |
|
1157 | + 'label' => __('Due Date', 'invoicing'), |
|
1158 | + 'value' => getpaid_format_date($invoice->get_due_date()), |
|
1159 | 1159 | ), |
1160 | 1160 | |
1161 | 1161 | 'vat_number' => array( |
1162 | 1162 | 'label' => sprintf( |
1163 | - __( '%s Number', 'invoicing' ), |
|
1163 | + __('%s Number', 'invoicing'), |
|
1164 | 1164 | getpaid_tax()->get_vat_name() |
1165 | 1165 | ), |
1166 | - 'value' => sanitize_text_field( $invoice->get_vat_number() ), |
|
1166 | + 'value' => sanitize_text_field($invoice->get_vat_number()), |
|
1167 | 1167 | ), |
1168 | 1168 | |
1169 | 1169 | ); |
1170 | 1170 | |
1171 | 1171 | // If it is not paid, remove the date of payment. |
1172 | - if ( ! $invoice->is_paid() ) { |
|
1173 | - unset( $meta[ 'date_paid' ] ); |
|
1174 | - unset( $meta[ 'transaction_id' ] ); |
|
1172 | + if (!$invoice->is_paid()) { |
|
1173 | + unset($meta['date_paid']); |
|
1174 | + unset($meta['transaction_id']); |
|
1175 | 1175 | } |
1176 | 1176 | |
1177 | - if ( ! $invoice->is_paid() || 'none' == $invoice->get_gateway() ) { |
|
1178 | - unset( $meta[ 'gateway' ] ); |
|
1177 | + if (!$invoice->is_paid() || 'none' == $invoice->get_gateway()) { |
|
1178 | + unset($meta['gateway']); |
|
1179 | 1179 | } |
1180 | 1180 | |
1181 | 1181 | // Only display the due date if due dates are enabled. |
1182 | - if ( ! $invoice->needs_payment() || ! wpinv_get_option( 'overdue_active' ) ) { |
|
1183 | - unset( $meta[ 'due_date' ] ); |
|
1182 | + if (!$invoice->needs_payment() || !wpinv_get_option('overdue_active')) { |
|
1183 | + unset($meta['due_date']); |
|
1184 | 1184 | } |
1185 | 1185 | |
1186 | 1186 | // Only display the vat number if taxes are enabled. |
1187 | - if ( ! wpinv_use_taxes() ) { |
|
1188 | - unset( $meta[ 'vat_number' ] ); |
|
1187 | + if (!wpinv_use_taxes()) { |
|
1188 | + unset($meta['vat_number']); |
|
1189 | 1189 | } |
1190 | 1190 | |
1191 | - if ( $invoice->is_recurring() ) { |
|
1191 | + if ($invoice->is_recurring()) { |
|
1192 | 1192 | |
1193 | 1193 | // Link to the parent invoice. |
1194 | - if ( $invoice->is_renewal() ) { |
|
1194 | + if ($invoice->is_renewal()) { |
|
1195 | 1195 | |
1196 | - $meta[ 'parent' ] = array( |
|
1196 | + $meta['parent'] = array( |
|
1197 | 1197 | |
1198 | 1198 | 'label' => sprintf( |
1199 | - __( 'Parent %s', 'invoicing' ), |
|
1200 | - ucfirst( $invoice->get_type() ) |
|
1199 | + __('Parent %s', 'invoicing'), |
|
1200 | + ucfirst($invoice->get_type()) |
|
1201 | 1201 | ), |
1202 | 1202 | |
1203 | - 'value' => wpinv_invoice_link( $invoice->get_parent_id() ), |
|
1203 | + 'value' => wpinv_invoice_link($invoice->get_parent_id()), |
|
1204 | 1204 | |
1205 | 1205 | ); |
1206 | 1206 | |
1207 | 1207 | } |
1208 | 1208 | |
1209 | - $subscription = wpinv_get_subscription( $invoice ); |
|
1209 | + $subscription = wpinv_get_subscription($invoice); |
|
1210 | 1210 | |
1211 | - if ( ! empty ( $subscription ) ) { |
|
1211 | + if (!empty ($subscription)) { |
|
1212 | 1212 | |
1213 | 1213 | // Display the renewal date. |
1214 | - if ( $subscription->is_active() && 'cancelled' != $subscription->get_status() ) { |
|
1214 | + if ($subscription->is_active() && 'cancelled' != $subscription->get_status()) { |
|
1215 | 1215 | |
1216 | - $meta[ 'renewal_date' ] = array( |
|
1216 | + $meta['renewal_date'] = array( |
|
1217 | 1217 | |
1218 | - 'label' => __( 'Renews On', 'invoicing' ), |
|
1219 | - 'value' => getpaid_format_date( $subscription->get_expiration() ), |
|
1218 | + 'label' => __('Renews On', 'invoicing'), |
|
1219 | + 'value' => getpaid_format_date($subscription->get_expiration()), |
|
1220 | 1220 | |
1221 | 1221 | ); |
1222 | 1222 | |
1223 | 1223 | } |
1224 | 1224 | |
1225 | - if ( $invoice->is_parent() ) { |
|
1225 | + if ($invoice->is_parent()) { |
|
1226 | 1226 | |
1227 | 1227 | // Display the recurring amount. |
1228 | - $meta[ 'recurring_total' ] = array( |
|
1228 | + $meta['recurring_total'] = array( |
|
1229 | 1229 | |
1230 | - 'label' => __( 'Recurring Amount', 'invoicing' ), |
|
1231 | - 'value' => wpinv_price( wpinv_format_amount( $subscription->get_recurring_amount() ), $invoice->get_currency() ), |
|
1230 | + 'label' => __('Recurring Amount', 'invoicing'), |
|
1231 | + 'value' => wpinv_price(wpinv_format_amount($subscription->get_recurring_amount()), $invoice->get_currency()), |
|
1232 | 1232 | |
1233 | 1233 | ); |
1234 | 1234 | |
@@ -1238,15 +1238,15 @@ discard block |
||
1238 | 1238 | } |
1239 | 1239 | |
1240 | 1240 | // Add the invoice total to the meta. |
1241 | - $meta[ 'invoice_total' ] = array( |
|
1241 | + $meta['invoice_total'] = array( |
|
1242 | 1242 | |
1243 | - 'label' => __( 'Total Amount', 'invoicing' ), |
|
1244 | - 'value' => wpinv_price( wpinv_format_amount( $invoice->get_total() ), $invoice->get_currency() ), |
|
1243 | + 'label' => __('Total Amount', 'invoicing'), |
|
1244 | + 'value' => wpinv_price(wpinv_format_amount($invoice->get_total()), $invoice->get_currency()), |
|
1245 | 1245 | |
1246 | 1246 | ); |
1247 | 1247 | |
1248 | 1248 | // Provide a way for third party plugins to filter the meta. |
1249 | - $meta = apply_filters( 'getpaid_invoice_meta_data', $meta, $invoice ); |
|
1249 | + $meta = apply_filters('getpaid_invoice_meta_data', $meta, $invoice); |
|
1250 | 1250 | |
1251 | 1251 | return $meta; |
1252 | 1252 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | $this->state = wpinv_get_default_state(); |
135 | 135 | |
136 | 136 | // Do we have an actual submission? |
137 | - if ( isset( $_POST['getpaid_payment_form_submission'] ) ) { |
|
138 | - $this->load_data( $_POST ); |
|
137 | + if (isset($_POST['getpaid_payment_form_submission'])) { |
|
138 | + $this->load_data($_POST); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | } |
@@ -145,19 +145,19 @@ discard block |
||
145 | 145 | * |
146 | 146 | * @param array $data |
147 | 147 | */ |
148 | - public function load_data( $data ) { |
|
148 | + public function load_data($data) { |
|
149 | 149 | |
150 | 150 | // Remove slashes from the submitted data... |
151 | - $data = wp_unslash( $data ); |
|
151 | + $data = wp_unslash($data); |
|
152 | 152 | |
153 | 153 | // Allow plugins to filter the data. |
154 | - $data = apply_filters( 'getpaid_submission_data', $data, $this ); |
|
154 | + $data = apply_filters('getpaid_submission_data', $data, $this); |
|
155 | 155 | |
156 | 156 | // Cache it... |
157 | 157 | $this->data = $data; |
158 | 158 | |
159 | 159 | // Then generate a unique id from the data. |
160 | - $this->id = md5( wp_json_encode( $data ) ); |
|
160 | + $this->id = md5(wp_json_encode($data)); |
|
161 | 161 | |
162 | 162 | // Finally, process the submission. |
163 | 163 | try { |
@@ -167,26 +167,26 @@ discard block |
||
167 | 167 | $processors = apply_filters( |
168 | 168 | 'getpaid_payment_form_submission_processors', |
169 | 169 | array( |
170 | - array( $this, 'process_payment_form' ), |
|
171 | - array( $this, 'process_invoice' ), |
|
172 | - array( $this, 'process_fees' ), |
|
173 | - array( $this, 'process_items' ), |
|
174 | - array( $this, 'process_taxes' ), |
|
175 | - array( $this, 'process_discount' ), |
|
170 | + array($this, 'process_payment_form'), |
|
171 | + array($this, 'process_invoice'), |
|
172 | + array($this, 'process_fees'), |
|
173 | + array($this, 'process_items'), |
|
174 | + array($this, 'process_taxes'), |
|
175 | + array($this, 'process_discount'), |
|
176 | 176 | ), |
177 | 177 | $this |
178 | 178 | ); |
179 | 179 | |
180 | - foreach ( $processors as $processor ) { |
|
181 | - call_user_func_array( $processor, array( &$this ) ); |
|
180 | + foreach ($processors as $processor) { |
|
181 | + call_user_func_array($processor, array(&$this)); |
|
182 | 182 | } |
183 | 183 | |
184 | - } catch ( Exception $e ) { |
|
184 | + } catch (Exception $e) { |
|
185 | 185 | $this->last_error = $e->getMessage(); |
186 | 186 | } |
187 | 187 | |
188 | 188 | // Fired when we are done processing a submission. |
189 | - do_action_ref_array( 'getpaid_process_submission', array( &$this ) ); |
|
189 | + do_action_ref_array('getpaid_process_submission', array(&$this)); |
|
190 | 190 | |
191 | 191 | } |
192 | 192 | |
@@ -207,18 +207,18 @@ discard block |
||
207 | 207 | public function process_payment_form() { |
208 | 208 | |
209 | 209 | // Every submission needs an active payment form. |
210 | - if ( empty( $this->data['form_id'] ) ) { |
|
211 | - throw new Exception( __( 'Missing payment form', 'invoicing' ) ); |
|
210 | + if (empty($this->data['form_id'])) { |
|
211 | + throw new Exception(__('Missing payment form', 'invoicing')); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | // Fetch the payment form. |
215 | - $this->payment_form = new GetPaid_Payment_Form( $this->data['form_id'] ); |
|
215 | + $this->payment_form = new GetPaid_Payment_Form($this->data['form_id']); |
|
216 | 216 | |
217 | - if ( ! $this->payment_form->is_active() ) { |
|
218 | - throw new Exception( __( 'Payment form not active', 'invoicing' ) ); |
|
217 | + if (!$this->payment_form->is_active()) { |
|
218 | + throw new Exception(__('Payment form not active', 'invoicing')); |
|
219 | 219 | } |
220 | 220 | |
221 | - do_action_ref_array( 'getpaid_submissions_process_payment_form', array( &$this ) ); |
|
221 | + do_action_ref_array('getpaid_submissions_process_payment_form', array(&$this)); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | /** |
@@ -248,30 +248,30 @@ discard block |
||
248 | 248 | public function process_invoice() { |
249 | 249 | |
250 | 250 | // Abort if there is no invoice. |
251 | - if ( empty( $this->data['invoice_id'] ) ) { |
|
251 | + if (empty($this->data['invoice_id'])) { |
|
252 | 252 | return; |
253 | 253 | } |
254 | 254 | |
255 | 255 | // If the submission is for an existing invoice, ensure that it exists |
256 | 256 | // and that it is not paid for. |
257 | - $invoice = wpinv_get_invoice( $this->data['invoice_id'] ); |
|
257 | + $invoice = wpinv_get_invoice($this->data['invoice_id']); |
|
258 | 258 | |
259 | - if ( empty( $invoice ) ) { |
|
260 | - throw new Exception( __( 'Invalid invoice', 'invoicing' ) ); |
|
259 | + if (empty($invoice)) { |
|
260 | + throw new Exception(__('Invalid invoice', 'invoicing')); |
|
261 | 261 | } |
262 | 262 | |
263 | - if ( $invoice->is_paid() ) { |
|
264 | - throw new Exception( __( 'This invoice is already paid for.', 'invoicing' ) ); |
|
263 | + if ($invoice->is_paid()) { |
|
264 | + throw new Exception(__('This invoice is already paid for.', 'invoicing')); |
|
265 | 265 | } |
266 | 266 | |
267 | - $this->payment_form->set_items( $invoice->get_items() ); |
|
267 | + $this->payment_form->set_items($invoice->get_items()); |
|
268 | 268 | $this->payment_form->invoice = $invoice; |
269 | 269 | |
270 | 270 | $this->country = $invoice->get_country(); |
271 | 271 | $this->state = $invoice->get_state(); |
272 | 272 | $this->invoice = $invoice; |
273 | 273 | |
274 | - do_action_ref_array( 'getpaid_submissions_process_invoice', array( &$this ) ); |
|
274 | + do_action_ref_array('getpaid_submissions_process_invoice', array(&$this)); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | /** |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | * @return bool |
292 | 292 | */ |
293 | 293 | public function has_invoice() { |
294 | - return ! empty( $this->invoice ); |
|
294 | + return !empty($this->invoice); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | /* |
@@ -310,13 +310,13 @@ discard block |
||
310 | 310 | */ |
311 | 311 | public function process_items() { |
312 | 312 | |
313 | - $processor = new GetPaid_Payment_Form_Submission_Items( $this ); |
|
313 | + $processor = new GetPaid_Payment_Form_Submission_Items($this); |
|
314 | 314 | |
315 | - foreach ( $processor->items as $item ) { |
|
316 | - $this->add_item( $item ); |
|
315 | + foreach ($processor->items as $item) { |
|
316 | + $this->add_item($item); |
|
317 | 317 | } |
318 | 318 | |
319 | - do_action_ref_array( 'getpaid_submissions_process_items', array( &$this ) ); |
|
319 | + do_action_ref_array('getpaid_submissions_process_items', array(&$this)); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | /** |
@@ -325,18 +325,18 @@ discard block |
||
325 | 325 | * @since 1.0.19 |
326 | 326 | * @param GetPaid_Form_Item $item |
327 | 327 | */ |
328 | - public function add_item( $item ) { |
|
328 | + public function add_item($item) { |
|
329 | 329 | |
330 | 330 | // Make sure that it is available for purchase. |
331 | - if ( ! $item->can_purchase() || isset( $this->items[ $item->get_id() ] ) ) { |
|
331 | + if (!$item->can_purchase() || isset($this->items[$item->get_id()])) { |
|
332 | 332 | return; |
333 | 333 | } |
334 | 334 | |
335 | 335 | // Each submission can only contain one recurring item. |
336 | - if ( $item->is_recurring() ) { |
|
336 | + if ($item->is_recurring()) { |
|
337 | 337 | |
338 | - if ( $this->has_recurring != 0 ) { |
|
339 | - throw new Exception( __( 'You can only buy one recurring item at a time.', 'invoicing' ) ); |
|
338 | + if ($this->has_recurring != 0) { |
|
339 | + throw new Exception(__('You can only buy one recurring item at a time.', 'invoicing')); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | $this->has_recurring = $item->get_id(); |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | } |
345 | 345 | |
346 | 346 | // Update the items and totals. |
347 | - $this->items[ $item->get_id() ] = $item; |
|
347 | + $this->items[$item->get_id()] = $item; |
|
348 | 348 | $this->totals['subtotal']['initial'] += $item->get_sub_total(); |
349 | 349 | $this->totals['subtotal']['recurring'] += $item->get_recurring_sub_total(); |
350 | 350 | |
@@ -358,17 +358,17 @@ discard block |
||
358 | 358 | * |
359 | 359 | * @since 1.0.19 |
360 | 360 | */ |
361 | - public function remove_item( $item_id ) { |
|
361 | + public function remove_item($item_id) { |
|
362 | 362 | |
363 | - if ( isset( $this->items[ $item_id ] ) ) { |
|
364 | - $this->totals['subtotal']['initial'] -= $this->items[ $item_id ]->get_sub_total(); |
|
365 | - $this->totals['subtotal']['recurring'] -= $this->items[ $item_id ]->get_recurring_sub_total(); |
|
363 | + if (isset($this->items[$item_id])) { |
|
364 | + $this->totals['subtotal']['initial'] -= $this->items[$item_id]->get_sub_total(); |
|
365 | + $this->totals['subtotal']['recurring'] -= $this->items[$item_id]->get_recurring_sub_total(); |
|
366 | 366 | |
367 | - if ( $this->items[ $item_id ]->is_recurring() ) { |
|
367 | + if ($this->items[$item_id]->is_recurring()) { |
|
368 | 368 | $this->has_recurring = 0; |
369 | 369 | } |
370 | 370 | |
371 | - unset( $this->items[ $item_id ] ); |
|
371 | + unset($this->items[$item_id]); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | } |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | */ |
381 | 381 | public function get_subtotal() { |
382 | 382 | |
383 | - if ( wpinv_prices_include_tax() ) { |
|
383 | + if (wpinv_prices_include_tax()) { |
|
384 | 384 | return $this->totals['subtotal']['initial'] - $this->totals['taxes']['initial']; |
385 | 385 | } |
386 | 386 | |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | */ |
395 | 395 | public function get_recurring_subtotal() { |
396 | 396 | |
397 | - if ( wpinv_prices_include_tax() ) { |
|
397 | + if (wpinv_prices_include_tax()) { |
|
398 | 398 | return $this->totals['subtotal']['recurring'] - $this->totals['taxes']['recurring']; |
399 | 399 | } |
400 | 400 | |
@@ -428,33 +428,33 @@ discard block |
||
428 | 428 | public function process_taxes() { |
429 | 429 | |
430 | 430 | // Abort if we're not using taxes. |
431 | - if ( ! $this->use_taxes() ) { |
|
431 | + if (!$this->use_taxes()) { |
|
432 | 432 | return; |
433 | 433 | } |
434 | 434 | |
435 | 435 | // If a custom country && state has been passed in, use it to calculate taxes. |
436 | - $country = $this->get_field( 'wpinv_country', 'billing' ); |
|
437 | - if ( ! empty( $country ) ) { |
|
436 | + $country = $this->get_field('wpinv_country', 'billing'); |
|
437 | + if (!empty($country)) { |
|
438 | 438 | $this->country = $country; |
439 | 439 | } |
440 | 440 | |
441 | - $state = $this->get_field( 'wpinv_state', 'billing' ); |
|
442 | - if ( ! empty( $state ) ) { |
|
441 | + $state = $this->get_field('wpinv_state', 'billing'); |
|
442 | + if (!empty($state)) { |
|
443 | 443 | $this->state = $state; |
444 | 444 | } |
445 | 445 | |
446 | 446 | // Abort if the country is not taxable. |
447 | - if ( wpinv_is_country_taxable( $this->country ) ) { |
|
447 | + if (wpinv_is_country_taxable($this->country)) { |
|
448 | 448 | return; |
449 | 449 | } |
450 | 450 | |
451 | - $processor = new GetPaid_Payment_Form_Submission_Taxes( $this ); |
|
451 | + $processor = new GetPaid_Payment_Form_Submission_Taxes($this); |
|
452 | 452 | |
453 | - foreach ( $processor->taxes as $tax ) { |
|
454 | - $this->add_tax( $tax ); |
|
453 | + foreach ($processor->taxes as $tax) { |
|
454 | + $this->add_tax($tax); |
|
455 | 455 | } |
456 | 456 | |
457 | - do_action_ref_array( 'getpaid_submissions_process_taxes', array( &$this ) ); |
|
457 | + do_action_ref_array('getpaid_submissions_process_taxes', array(&$this)); |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | /** |
@@ -463,16 +463,16 @@ discard block |
||
463 | 463 | * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required. |
464 | 464 | * @since 1.0.19 |
465 | 465 | */ |
466 | - public function add_tax( $tax ) { |
|
466 | + public function add_tax($tax) { |
|
467 | 467 | |
468 | - if ( wpinv_round_tax_per_tax_rate() ) { |
|
469 | - $tax['initial_tax'] = wpinv_round_amount( $tax['initial_tax'] ); |
|
470 | - $tax['recurring_tax'] = wpinv_round_amount( $tax['recurring_tax'] ); |
|
468 | + if (wpinv_round_tax_per_tax_rate()) { |
|
469 | + $tax['initial_tax'] = wpinv_round_amount($tax['initial_tax']); |
|
470 | + $tax['recurring_tax'] = wpinv_round_amount($tax['recurring_tax']); |
|
471 | 471 | } |
472 | 472 | |
473 | - $this->taxes[ $tax['name'] ] = $tax; |
|
474 | - $this->totals['taxes']['initial'] += wpinv_sanitize_amount( $tax['initial_tax'] ); |
|
475 | - $this->totals['taxes']['recurring'] += wpinv_sanitize_amount( $tax['recurring_tax'] ); |
|
473 | + $this->taxes[$tax['name']] = $tax; |
|
474 | + $this->totals['taxes']['initial'] += wpinv_sanitize_amount($tax['initial_tax']); |
|
475 | + $this->totals['taxes']['recurring'] += wpinv_sanitize_amount($tax['recurring_tax']); |
|
476 | 476 | |
477 | 477 | } |
478 | 478 | |
@@ -481,12 +481,12 @@ discard block |
||
481 | 481 | * |
482 | 482 | * @since 1.0.19 |
483 | 483 | */ |
484 | - public function remove_tax( $tax_name ) { |
|
484 | + public function remove_tax($tax_name) { |
|
485 | 485 | |
486 | - if ( isset( $this->taxes[ $tax_name ] ) ) { |
|
487 | - $this->totals['taxes']['initial'] -= $this->taxes[ $tax_name ]['initial_tax']; |
|
488 | - $this->totals['taxes']['recurring'] -= $this->taxes[ $tax_name ]['recurring_tax']; |
|
489 | - unset( $this->taxes[ $tax_name ] ); |
|
486 | + if (isset($this->taxes[$tax_name])) { |
|
487 | + $this->totals['taxes']['initial'] -= $this->taxes[$tax_name]['initial_tax']; |
|
488 | + $this->totals['taxes']['recurring'] -= $this->taxes[$tax_name]['recurring_tax']; |
|
489 | + unset($this->taxes[$tax_name]); |
|
490 | 490 | } |
491 | 491 | |
492 | 492 | } |
@@ -500,11 +500,11 @@ discard block |
||
500 | 500 | |
501 | 501 | $use_taxes = wpinv_use_taxes(); |
502 | 502 | |
503 | - if ( $this->has_invoice() && ! $this->invoice->is_taxable() ) { |
|
503 | + if ($this->has_invoice() && !$this->invoice->is_taxable()) { |
|
504 | 504 | $use_taxes = false; |
505 | 505 | } |
506 | 506 | |
507 | - return apply_filters( 'getpaid_submission_use_taxes', $use_taxes, $this ); |
|
507 | + return apply_filters('getpaid_submission_use_taxes', $use_taxes, $this); |
|
508 | 508 | |
509 | 509 | } |
510 | 510 | |
@@ -553,13 +553,13 @@ discard block |
||
553 | 553 | |
554 | 554 | $initial_total = $this->get_subtotal() + $this->get_fee() + $this->get_tax(); |
555 | 555 | $recurring_total = $this->get_recurring_subtotal() + $this->get_recurring_fee() + $this->get_recurring_tax(); |
556 | - $processor = new GetPaid_Payment_Form_Submission_Discount( $this, $initial_total, $recurring_total ); |
|
556 | + $processor = new GetPaid_Payment_Form_Submission_Discount($this, $initial_total, $recurring_total); |
|
557 | 557 | |
558 | - foreach ( $processor->discounts as $discount ) { |
|
559 | - $this->add_discount( $discount ); |
|
558 | + foreach ($processor->discounts as $discount) { |
|
559 | + $this->add_discount($discount); |
|
560 | 560 | } |
561 | 561 | |
562 | - do_action_ref_array( 'getpaid_submissions_process_discounts', array( &$this ) ); |
|
562 | + do_action_ref_array('getpaid_submissions_process_discounts', array(&$this)); |
|
563 | 563 | } |
564 | 564 | |
565 | 565 | /** |
@@ -568,10 +568,10 @@ discard block |
||
568 | 568 | * @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. |
569 | 569 | * @since 1.0.19 |
570 | 570 | */ |
571 | - public function add_discount( $discount ) { |
|
572 | - $this->discounts[ $discount['name'] ] = $discount; |
|
573 | - $this->totals['discount']['initial'] += wpinv_sanitize_amount( $discount['initial_discount'] ); |
|
574 | - $this->totals['discount']['recurring'] += wpinv_sanitize_amount( $discount['recurring_discount'] ); |
|
571 | + public function add_discount($discount) { |
|
572 | + $this->discounts[$discount['name']] = $discount; |
|
573 | + $this->totals['discount']['initial'] += wpinv_sanitize_amount($discount['initial_discount']); |
|
574 | + $this->totals['discount']['recurring'] += wpinv_sanitize_amount($discount['recurring_discount']); |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | /** |
@@ -579,12 +579,12 @@ discard block |
||
579 | 579 | * |
580 | 580 | * @since 1.0.19 |
581 | 581 | */ |
582 | - public function remove_discount( $name ) { |
|
582 | + public function remove_discount($name) { |
|
583 | 583 | |
584 | - if ( isset( $this->discounts[ $name ] ) ) { |
|
585 | - $this->totals['discount']['initial'] -= $this->discounts[ $name ]['initial_discount']; |
|
586 | - $this->totals['discount']['recurring'] -= $this->discounts[ $name ]['recurring_discount']; |
|
587 | - unset( $this->discounts[ $name ] ); |
|
584 | + if (isset($this->discounts[$name])) { |
|
585 | + $this->totals['discount']['initial'] -= $this->discounts[$name]['initial_discount']; |
|
586 | + $this->totals['discount']['recurring'] -= $this->discounts[$name]['recurring_discount']; |
|
587 | + unset($this->discounts[$name]); |
|
588 | 588 | } |
589 | 589 | |
590 | 590 | } |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | * @return bool |
597 | 597 | */ |
598 | 598 | public function has_discount_code() { |
599 | - return ! empty( $this->discounts['discount_code'] ); |
|
599 | + return !empty($this->discounts['discount_code']); |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | /** |
@@ -653,13 +653,13 @@ discard block |
||
653 | 653 | */ |
654 | 654 | public function process_fees() { |
655 | 655 | |
656 | - $fees_processor = new GetPaid_Payment_Form_Submission_Fees( $this ); |
|
656 | + $fees_processor = new GetPaid_Payment_Form_Submission_Fees($this); |
|
657 | 657 | |
658 | - foreach ( $fees_processor->fees as $fee ) { |
|
659 | - $this->add_fee( $fee ); |
|
658 | + foreach ($fees_processor->fees as $fee) { |
|
659 | + $this->add_fee($fee); |
|
660 | 660 | } |
661 | 661 | |
662 | - do_action_ref_array( 'getpaid_submissions_process_fees', array( &$this ) ); |
|
662 | + do_action_ref_array('getpaid_submissions_process_fees', array(&$this)); |
|
663 | 663 | } |
664 | 664 | |
665 | 665 | /** |
@@ -668,11 +668,11 @@ discard block |
||
668 | 668 | * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required. |
669 | 669 | * @since 1.0.19 |
670 | 670 | */ |
671 | - public function add_fee( $fee ) { |
|
671 | + public function add_fee($fee) { |
|
672 | 672 | |
673 | - $this->fees[ $fee['name'] ] = $fee; |
|
674 | - $this->totals['fees']['initial'] += wpinv_sanitize_amount( $fee['initial_fee'] ); |
|
675 | - $this->totals['fees']['recurring'] += wpinv_sanitize_amount( $fee['recurring_fee'] ); |
|
673 | + $this->fees[$fee['name']] = $fee; |
|
674 | + $this->totals['fees']['initial'] += wpinv_sanitize_amount($fee['initial_fee']); |
|
675 | + $this->totals['fees']['recurring'] += wpinv_sanitize_amount($fee['recurring_fee']); |
|
676 | 676 | |
677 | 677 | } |
678 | 678 | |
@@ -681,12 +681,12 @@ discard block |
||
681 | 681 | * |
682 | 682 | * @since 1.0.19 |
683 | 683 | */ |
684 | - public function remove_fee( $name ) { |
|
684 | + public function remove_fee($name) { |
|
685 | 685 | |
686 | - if ( isset( $this->fees[ $name ] ) ) { |
|
687 | - $this->totals['fees']['initial'] -= $this->fees[ $name ]['initial_fee']; |
|
688 | - $this->totals['fees']['recurring'] -= $this->fees[ $name ]['recurring_fee']; |
|
689 | - unset( $this->fees[ $name ] ); |
|
686 | + if (isset($this->fees[$name])) { |
|
687 | + $this->totals['fees']['initial'] -= $this->fees[$name]['initial_fee']; |
|
688 | + $this->totals['fees']['recurring'] -= $this->fees[$name]['recurring_fee']; |
|
689 | + unset($this->fees[$name]); |
|
690 | 690 | } |
691 | 691 | |
692 | 692 | } |
@@ -725,7 +725,7 @@ discard block |
||
725 | 725 | * @since 1.0.19 |
726 | 726 | */ |
727 | 727 | public function has_fees() { |
728 | - return count( $this->fees ) !== 0; |
|
728 | + return count($this->fees) !== 0; |
|
729 | 729 | } |
730 | 730 | |
731 | 731 | /* |
@@ -743,7 +743,7 @@ discard block |
||
743 | 743 | */ |
744 | 744 | public function get_total() { |
745 | 745 | $total = $this->get_subtotal() + $this->get_fee() + $this->get_tax() - $this->get_discount(); |
746 | - return max( $total, 0 ); |
|
746 | + return max($total, 0); |
|
747 | 747 | } |
748 | 748 | |
749 | 749 | /** |
@@ -753,7 +753,7 @@ discard block |
||
753 | 753 | */ |
754 | 754 | public function get_recurring_total() { |
755 | 755 | $total = $this->get_recurring_subtotal() + $this->get_recurring_fee() + $this->get_recurring_tax() - $this->get_recurring_discount(); |
756 | - return max( $total, 0 ); |
|
756 | + return max($total, 0); |
|
757 | 757 | } |
758 | 758 | |
759 | 759 | /** |
@@ -765,12 +765,12 @@ discard block |
||
765 | 765 | $initial = $this->get_total(); |
766 | 766 | $recurring = $this->get_recurring_total(); |
767 | 767 | |
768 | - if ( $this->has_recurring == 0 ) { |
|
768 | + if ($this->has_recurring == 0) { |
|
769 | 769 | $recurring = 0; |
770 | 770 | } |
771 | 771 | |
772 | 772 | $collect = $initial > 0 || $recurring > 0; |
773 | - return apply_filters( 'getpaid_submission_should_collect_payment_details', $collect, $this ); |
|
773 | + return apply_filters('getpaid_submission_should_collect_payment_details', $collect, $this); |
|
774 | 774 | } |
775 | 775 | |
776 | 776 | /** |
@@ -779,7 +779,7 @@ discard block |
||
779 | 779 | * @since 1.0.19 |
780 | 780 | */ |
781 | 781 | public function get_billing_email() { |
782 | - return apply_filters( 'getpaid_get_submission_billing_email', $this->get_field( 'billing_email' ), $this ); |
|
782 | + return apply_filters('getpaid_get_submission_billing_email', $this->get_field('billing_email'), $this); |
|
783 | 783 | } |
784 | 784 | |
785 | 785 | /** |
@@ -789,7 +789,7 @@ discard block |
||
789 | 789 | */ |
790 | 790 | public function has_billing_email() { |
791 | 791 | $billing_email = $this->get_billing_email(); |
792 | - return ! empty( $billing_email ) && is_email( $billing_email ); |
|
792 | + return !empty($billing_email) && is_email($billing_email); |
|
793 | 793 | } |
794 | 794 | |
795 | 795 | /** |
@@ -819,8 +819,8 @@ discard block |
||
819 | 819 | * @since 1.0.19 |
820 | 820 | * @return mixed|null |
821 | 821 | */ |
822 | - public function get_field( $field, $sub_array_key = null ) { |
|
823 | - return getpaid_get_array_field( $this->data, $field, $sub_array_key ); |
|
822 | + public function get_field($field, $sub_array_key = null) { |
|
823 | + return getpaid_get_array_field($this->data, $field, $sub_array_key); |
|
824 | 824 | } |
825 | 825 | |
826 | 826 | /** |
@@ -828,8 +828,8 @@ discard block |
||
828 | 828 | * |
829 | 829 | * @since 1.0.19 |
830 | 830 | */ |
831 | - public function is_required_field_set( $field ) { |
|
832 | - return empty( $field['required'] ) || ! empty( $this->data[ $field['id'] ] ); |
|
831 | + public function is_required_field_set($field) { |
|
832 | + return empty($field['required']) || !empty($this->data[$field['id']]); |
|
833 | 833 | } |
834 | 834 | |
835 | 835 | /** |
@@ -837,8 +837,8 @@ discard block |
||
837 | 837 | * |
838 | 838 | * @since 1.0.19 |
839 | 839 | */ |
840 | - public function format_amount( $amount ) { |
|
841 | - return wpinv_price( $amount, $this->get_currency() ); |
|
840 | + public function format_amount($amount) { |
|
841 | + return wpinv_price($amount, $this->get_currency()); |
|
842 | 842 | } |
843 | 843 | |
844 | 844 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Payment form submission taxes class |
@@ -23,18 +23,18 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @param GetPaid_Payment_Form_Submission $submission |
25 | 25 | */ |
26 | - public function __construct( $submission ) { |
|
26 | + public function __construct($submission) { |
|
27 | 27 | |
28 | 28 | // Validate VAT number. |
29 | - $this->validate_vat( $submission ); |
|
29 | + $this->validate_vat($submission); |
|
30 | 30 | |
31 | - foreach ( $submission->get_items() as $item ) { |
|
32 | - $this->process_item_tax( $item, $submission ); |
|
31 | + foreach ($submission->get_items() as $item) { |
|
32 | + $this->process_item_tax($item, $submission); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | // Process any existing invoice taxes. |
36 | - if ( $submission->has_invoice() ) { |
|
37 | - $this->taxes = array_replace( $submission->get_invoice()->get_taxes(), $this->taxes ); |
|
36 | + if ($submission->has_invoice()) { |
|
37 | + $this->taxes = array_replace($submission->get_invoice()->get_taxes(), $this->taxes); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | } |
@@ -46,23 +46,23 @@ discard block |
||
46 | 46 | * @param GetPaid_Form_Item $item |
47 | 47 | * @param GetPaid_Payment_Form_Submission $submission |
48 | 48 | */ |
49 | - public function process_item_tax( $item, $submission ) { |
|
49 | + public function process_item_tax($item, $submission) { |
|
50 | 50 | |
51 | - $rates = getpaid_get_item_tax_rates( $item, $submission->country, $submission->state ); |
|
52 | - $taxes = getpaid_calculate_item_taxes( $item->get_sub_total(), $rates ); |
|
53 | - $r_taxes = getpaid_calculate_item_taxes( $item->get_recurring_sub_total(), $rates ); |
|
51 | + $rates = getpaid_get_item_tax_rates($item, $submission->country, $submission->state); |
|
52 | + $taxes = getpaid_calculate_item_taxes($item->get_sub_total(), $rates); |
|
53 | + $r_taxes = getpaid_calculate_item_taxes($item->get_recurring_sub_total(), $rates); |
|
54 | 54 | |
55 | - foreach ( $taxes as $name => $amount ) { |
|
56 | - $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0; |
|
57 | - $tax = getpaid_prepare_item_tax( $item, $name, $amount, $recurring ); |
|
55 | + foreach ($taxes as $name => $amount) { |
|
56 | + $recurring = isset($r_taxes[$name]) ? $r_taxes[$name] : 0; |
|
57 | + $tax = getpaid_prepare_item_tax($item, $name, $amount, $recurring); |
|
58 | 58 | |
59 | - if ( ! isset( $this->taxes[ $name ] ) ) { |
|
60 | - $this->taxes[ $name ] = $tax; |
|
59 | + if (!isset($this->taxes[$name])) { |
|
60 | + $this->taxes[$name] = $tax; |
|
61 | 61 | continue; |
62 | 62 | } |
63 | 63 | |
64 | - $this->taxes[ $name ]['initial_tax'] += $tax['initial_tax']; |
|
65 | - $this->taxes[ $name ]['recurring_tax'] += $tax['recurring_tax']; |
|
64 | + $this->taxes[$name]['initial_tax'] += $tax['initial_tax']; |
|
65 | + $this->taxes[$name]['recurring_tax'] += $tax['recurring_tax']; |
|
66 | 66 | |
67 | 67 | } |
68 | 68 | |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | * @since 1.0.19 |
76 | 76 | * @return bool |
77 | 77 | */ |
78 | - public function has_digital_item( $submission ) { |
|
78 | + public function has_digital_item($submission) { |
|
79 | 79 | |
80 | - foreach ( $submission->get_items() as $item ) { |
|
80 | + foreach ($submission->get_items() as $item) { |
|
81 | 81 | |
82 | - if ( 'digital' == $item->get_vat_rule() ) { |
|
82 | + if ('digital' == $item->get_vat_rule()) { |
|
83 | 83 | return true; |
84 | 84 | } |
85 | 85 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @return bool |
96 | 96 | */ |
97 | 97 | public function is_eu_store() { |
98 | - return $this->is_eu_country( wpinv_get_default_country() ); |
|
98 | + return $this->is_eu_country(wpinv_get_default_country()); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | * @since 1.0.19 |
106 | 106 | * @return bool |
107 | 107 | */ |
108 | - public function is_eu_country( $country ) { |
|
109 | - return getpaid_is_eu_state( $country ) || getpaid_is_gst_country( $country ); |
|
108 | + public function is_eu_country($country) { |
|
109 | + return getpaid_is_eu_state($country) || getpaid_is_gst_country($country); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | * @since 1.0.19 |
117 | 117 | * @return bool |
118 | 118 | */ |
119 | - public function is_eu_transaction( $customer_country ) { |
|
120 | - return $this->is_eu_country( $customer_country ) && $this->is_eu_store(); |
|
119 | + public function is_eu_transaction($customer_country) { |
|
120 | + return $this->is_eu_country($customer_country) && $this->is_eu_store(); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -127,12 +127,12 @@ discard block |
||
127 | 127 | * @since 1.0.19 |
128 | 128 | * @return string |
129 | 129 | */ |
130 | - public function get_vat_number( $submission ) { |
|
130 | + public function get_vat_number($submission) { |
|
131 | 131 | |
132 | 132 | // Retrieve from the posted number. |
133 | - $vat_number = $submission->get_field( 'wpinv_vat_number', 'billing' ); |
|
134 | - if ( ! empty( $vat_number ) ) { |
|
135 | - return wpinv_clean( $vat_number ); |
|
133 | + $vat_number = $submission->get_field('wpinv_vat_number', 'billing'); |
|
134 | + if (!empty($vat_number)) { |
|
135 | + return wpinv_clean($vat_number); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | // Retrieve from the invoice. |
@@ -146,12 +146,12 @@ discard block |
||
146 | 146 | * @since 1.0.19 |
147 | 147 | * @return string |
148 | 148 | */ |
149 | - public function get_company( $submission ) { |
|
149 | + public function get_company($submission) { |
|
150 | 150 | |
151 | 151 | // Retrieve from the posted data. |
152 | - $company = $submission->get_field( 'wpinv_company', 'billing' ); |
|
153 | - if ( ! empty( $company ) ) { |
|
154 | - return wpinv_clean( $company ); |
|
152 | + $company = $submission->get_field('wpinv_company', 'billing'); |
|
153 | + if (!empty($company)) { |
|
154 | + return wpinv_clean($company); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | // Retrieve from the invoice. |
@@ -166,10 +166,10 @@ discard block |
||
166 | 166 | * @since 1.0.19 |
167 | 167 | * @return string |
168 | 168 | */ |
169 | - public function requires_vat( $ip_in_eu, $country_in_eu ) { |
|
169 | + public function requires_vat($ip_in_eu, $country_in_eu) { |
|
170 | 170 | |
171 | - $prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' ); |
|
172 | - $prevent_b2c = ! empty( $prevent_b2c ); |
|
171 | + $prevent_b2c = wpinv_get_option('vat_prevent_b2c_purchase'); |
|
172 | + $prevent_b2c = !empty($prevent_b2c); |
|
173 | 173 | $is_eu = $ip_in_eu || $country_in_eu; |
174 | 174 | |
175 | 175 | return $prevent_b2c && $is_eu; |
@@ -181,29 +181,29 @@ discard block |
||
181 | 181 | * @param GetPaid_Payment_Form_Submission $submission |
182 | 182 | * @since 1.0.19 |
183 | 183 | */ |
184 | - public function validate_vat( $submission ) { |
|
184 | + public function validate_vat($submission) { |
|
185 | 185 | |
186 | - $has_digital = $this->has_digital_item( $submission ); |
|
187 | - $in_eu = $this->is_eu_transaction( $submission->country ); |
|
186 | + $has_digital = $this->has_digital_item($submission); |
|
187 | + $in_eu = $this->is_eu_transaction($submission->country); |
|
188 | 188 | |
189 | 189 | // Abort if we are not validating vat numbers. |
190 | - if ( ! $has_digital && ! $in_eu ) { |
|
190 | + if (!$has_digital && !$in_eu) { |
|
191 | 191 | return; |
192 | 192 | } |
193 | 193 | |
194 | 194 | // Prepare variables. |
195 | - $vat_number = $this->get_vat_number( $submission ); |
|
195 | + $vat_number = $this->get_vat_number($submission); |
|
196 | 196 | $ip_country = getpaid_get_ip_country(); |
197 | - $is_eu = $this->is_eu_country( $submission->country ); |
|
198 | - $is_ip_eu = $this->is_eu_country( $ip_country ); |
|
197 | + $is_eu = $this->is_eu_country($submission->country); |
|
198 | + $is_ip_eu = $this->is_eu_country($ip_country); |
|
199 | 199 | |
200 | 200 | // If we're preventing business to consumer purchases, ensure |
201 | - if ( $this->requires_vat( $is_ip_eu, $is_eu ) && empty( $vat_number ) ) { |
|
201 | + if ($this->requires_vat($is_ip_eu, $is_eu) && empty($vat_number)) { |
|
202 | 202 | |
203 | 203 | // Ensure that a vat number has been specified. |
204 | 204 | throw new Exception( |
205 | 205 | wp_sprintf( |
206 | - __( 'Please enter your %s number to verify your purchase is by an EU business.', 'invoicing' ), |
|
206 | + __('Please enter your %s number to verify your purchase is by an EU business.', 'invoicing'), |
|
207 | 207 | getpaid_vat_name() |
208 | 208 | ) |
209 | 209 | ); |
@@ -211,12 +211,12 @@ discard block |
||
211 | 211 | } |
212 | 212 | |
213 | 213 | // Abort if we are not validating vat (vat number should exist, user should be in eu and business too). |
214 | - if ( ! $is_eu || ! $in_eu || empty( $vat_number ) ) { |
|
214 | + if (!$is_eu || !$in_eu || empty($vat_number)) { |
|
215 | 215 | return; |
216 | 216 | } |
217 | 217 | |
218 | - if ( ! wpinv_validate_vat_number( $vat_number, $submission->country ) ) { |
|
219 | - throw new Exception( __( 'Your VAT number is invalid', 'invoicing' ) ); |
|
218 | + if (!wpinv_validate_vat_number($vat_number, $submission->country)) { |
|
219 | + throw new Exception(__('Your VAT number is invalid', 'invoicing')); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | } |
@@ -8,192 +8,192 @@ discard block |
||
8 | 8 | * @version 1.0.19 |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | -$pages = wpinv_get_pages( true ); |
|
13 | +$pages = wpinv_get_pages(true); |
|
14 | 14 | |
15 | 15 | $currencies = wpinv_get_currencies(); |
16 | 16 | |
17 | 17 | $currency_code_options = array(); |
18 | -foreach ( $currencies as $code => $name ) { |
|
19 | - $currency_code_options[ $code ] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol( $code ) . ')'; |
|
18 | +foreach ($currencies as $code => $name) { |
|
19 | + $currency_code_options[$code] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol($code) . ')'; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | $due_payment_options = array(); |
23 | -$due_payment_options[0] = __( 'Now', 'invoicing' ); |
|
24 | -for ( $i = 1; $i <= 30; $i++ ) { |
|
23 | +$due_payment_options[0] = __('Now', 'invoicing'); |
|
24 | +for ($i = 1; $i <= 30; $i++) { |
|
25 | 25 | $due_payment_options[$i] = $i; |
26 | 26 | } |
27 | 27 | |
28 | 28 | $invoice_number_padd_options = array(); |
29 | -for ( $i = 0; $i <= 20; $i++ ) { |
|
29 | +for ($i = 0; $i <= 20; $i++) { |
|
30 | 30 | $invoice_number_padd_options[$i] = $i; |
31 | 31 | } |
32 | 32 | |
33 | 33 | $currency_symbol = wpinv_currency_symbol(); |
34 | 34 | |
35 | 35 | $last_number = $reset_number = ''; |
36 | -if ( $last_invoice_number = get_option( 'wpinv_last_invoice_number' ) ) { |
|
37 | - $last_invoice_number = preg_replace( '/[^0-9]/', '', $last_invoice_number ); |
|
36 | +if ($last_invoice_number = get_option('wpinv_last_invoice_number')) { |
|
37 | + $last_invoice_number = preg_replace('/[^0-9]/', '', $last_invoice_number); |
|
38 | 38 | |
39 | - if ( !empty( $last_invoice_number ) ) { |
|
40 | - $last_number = ' ' . wp_sprintf( __( "( Last Invoice's sequential number: <b>%s</b> )", 'invoicing' ), $last_invoice_number ); |
|
39 | + if (!empty($last_invoice_number)) { |
|
40 | + $last_number = ' ' . wp_sprintf(__("( Last Invoice's sequential number: <b>%s</b> )", 'invoicing'), $last_invoice_number); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | $nonce = wp_create_nonce('reset_invoice_count'); |
44 | - $reset_number = '<a href="'.add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)).'" class="btn button">'.__('Force Reset Sequence', 'invoicing' ). '</a>'; |
|
44 | + $reset_number = '<a href="' . add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)) . '" class="btn button">' . __('Force Reset Sequence', 'invoicing') . '</a>'; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | $alert_wrapper_start = '<p style="color: #F00">'; |
48 | 48 | $alert_wrapper_close = '</p>'; |
49 | 49 | |
50 | 50 | return array( |
51 | - 'general' => apply_filters( 'wpinv_settings_general', |
|
51 | + 'general' => apply_filters('wpinv_settings_general', |
|
52 | 52 | array( |
53 | 53 | 'main' => array( |
54 | 54 | 'location_settings' => array( |
55 | 55 | 'id' => 'location_settings', |
56 | - 'name' => '<h3>' . __( 'Default Location', 'invoicing' ) . '</h3>', |
|
56 | + 'name' => '<h3>' . __('Default Location', 'invoicing') . '</h3>', |
|
57 | 57 | 'desc' => '', |
58 | 58 | 'type' => 'header', |
59 | 59 | ), |
60 | 60 | 'default_country' => array( |
61 | 61 | 'id' => 'default_country', |
62 | - 'name' => __( 'Default Country', 'invoicing' ), |
|
63 | - 'desc' => __( 'Where does your store operate from?', 'invoicing' ), |
|
62 | + 'name' => __('Default Country', 'invoicing'), |
|
63 | + 'desc' => __('Where does your store operate from?', 'invoicing'), |
|
64 | 64 | 'type' => 'select', |
65 | 65 | 'options' => wpinv_get_country_list(), |
66 | 66 | 'std' => 'GB', |
67 | 67 | 'class' => 'wpi_select2', |
68 | - 'placeholder' => __( 'Select a country', 'invoicing' ), |
|
68 | + 'placeholder' => __('Select a country', 'invoicing'), |
|
69 | 69 | ), |
70 | 70 | 'default_state' => array( |
71 | 71 | 'id' => 'default_state', |
72 | - 'name' => __( 'Default State / Province', 'invoicing' ), |
|
73 | - 'desc' => __( 'What state / province does your store operate from?', 'invoicing' ), |
|
72 | + 'name' => __('Default State / Province', 'invoicing'), |
|
73 | + 'desc' => __('What state / province does your store operate from?', 'invoicing'), |
|
74 | 74 | 'type' => 'country_states', |
75 | 75 | 'class' => 'wpi_select2', |
76 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
76 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
77 | 77 | ), |
78 | 78 | 'store_name' => array( |
79 | 79 | 'id' => 'store_name', |
80 | - 'name' => __( 'Store Name', 'invoicing' ), |
|
81 | - 'desc' => __( 'Store name to print on invoices.', 'invoicing' ), |
|
80 | + 'name' => __('Store Name', 'invoicing'), |
|
81 | + 'desc' => __('Store name to print on invoices.', 'invoicing'), |
|
82 | 82 | 'std' => get_option('blogname'), |
83 | 83 | 'type' => 'text', |
84 | 84 | ), |
85 | 85 | 'logo' => array( |
86 | 86 | 'id' => 'logo', |
87 | - 'name' => __( 'Logo URL', 'invoicing' ), |
|
88 | - 'desc' => __( 'Store logo to print on invoices.', 'invoicing' ), |
|
87 | + 'name' => __('Logo URL', 'invoicing'), |
|
88 | + 'desc' => __('Store logo to print on invoices.', 'invoicing'), |
|
89 | 89 | 'type' => 'text', |
90 | 90 | ), |
91 | 91 | 'store_address' => array( |
92 | 92 | 'id' => 'store_address', |
93 | - 'name' => __( 'Store Address', 'invoicing' ), |
|
94 | - 'desc' => __( 'Enter the store address to display on invoice', 'invoicing' ), |
|
93 | + 'name' => __('Store Address', 'invoicing'), |
|
94 | + 'desc' => __('Enter the store address to display on invoice', 'invoicing'), |
|
95 | 95 | 'type' => 'textarea', |
96 | 96 | ), |
97 | 97 | 'page_settings' => array( |
98 | 98 | 'id' => 'page_settings', |
99 | - 'name' => '<h3>' . __( 'Page Settings', 'invoicing' ) . '</h3>', |
|
99 | + 'name' => '<h3>' . __('Page Settings', 'invoicing') . '</h3>', |
|
100 | 100 | 'desc' => '', |
101 | 101 | 'type' => 'header', |
102 | 102 | ), |
103 | 103 | 'checkout_page' => array( |
104 | 104 | 'id' => 'checkout_page', |
105 | - 'name' => __( 'Checkout Page', 'invoicing' ), |
|
106 | - 'desc' => __( 'This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing' ), |
|
105 | + 'name' => __('Checkout Page', 'invoicing'), |
|
106 | + 'desc' => __('This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing'), |
|
107 | 107 | 'type' => 'select', |
108 | 108 | 'options' => $pages, |
109 | 109 | 'class' => 'wpi_select2', |
110 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
110 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
111 | 111 | ), |
112 | 112 | 'success_page' => array( |
113 | 113 | 'id' => 'success_page', |
114 | - 'name' => __( 'Success Page', 'invoicing' ), |
|
115 | - 'desc' => __( 'This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing' ), |
|
114 | + 'name' => __('Success Page', 'invoicing'), |
|
115 | + 'desc' => __('This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing'), |
|
116 | 116 | 'type' => 'select', |
117 | 117 | 'options' => $pages, |
118 | 118 | 'class' => 'wpi_select2', |
119 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
119 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
120 | 120 | ), |
121 | 121 | 'failure_page' => array( |
122 | 122 | 'id' => 'failure_page', |
123 | - 'name' => __( 'Failed Transaction Page', 'invoicing' ), |
|
124 | - 'desc' => __( 'This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing' ), |
|
123 | + 'name' => __('Failed Transaction Page', 'invoicing'), |
|
124 | + 'desc' => __('This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing'), |
|
125 | 125 | 'type' => 'select', |
126 | 126 | 'options' => $pages, |
127 | 127 | 'class' => 'wpi_select2', |
128 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
128 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
129 | 129 | ), |
130 | 130 | 'invoice_history_page' => array( |
131 | 131 | 'id' => 'invoice_history_page', |
132 | - 'name' => __( 'Invoice History Page', 'invoicing' ), |
|
133 | - 'desc' => __( 'This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing' ), |
|
132 | + 'name' => __('Invoice History Page', 'invoicing'), |
|
133 | + 'desc' => __('This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing'), |
|
134 | 134 | 'type' => 'select', |
135 | 135 | 'options' => $pages, |
136 | 136 | 'class' => 'wpi_select2', |
137 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
137 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
138 | 138 | ), |
139 | 139 | 'invoice_subscription_page' => array( |
140 | 140 | 'id' => 'invoice_subscription_page', |
141 | - 'name' => __( 'Invoice Subscriptions Page', 'invoicing' ), |
|
142 | - 'desc' => __( 'This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing' ), |
|
141 | + 'name' => __('Invoice Subscriptions Page', 'invoicing'), |
|
142 | + 'desc' => __('This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing'), |
|
143 | 143 | 'type' => 'select', |
144 | 144 | 'options' => $pages, |
145 | 145 | 'class' => 'wpi_select2', |
146 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
146 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
147 | 147 | ), |
148 | 148 | ), |
149 | 149 | 'currency_section' => array( |
150 | 150 | 'currency_settings' => array( |
151 | 151 | 'id' => 'currency_settings', |
152 | - 'name' => '<h3>' . __( 'Currency Settings', 'invoicing' ) . '</h3>', |
|
152 | + 'name' => '<h3>' . __('Currency Settings', 'invoicing') . '</h3>', |
|
153 | 153 | 'desc' => '', |
154 | 154 | 'type' => 'header', |
155 | 155 | ), |
156 | 156 | 'currency' => array( |
157 | 157 | 'id' => 'currency', |
158 | - 'name' => __( 'Currency', 'invoicing' ), |
|
159 | - 'desc' => __( 'Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing' ), |
|
158 | + 'name' => __('Currency', 'invoicing'), |
|
159 | + 'desc' => __('Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing'), |
|
160 | 160 | 'type' => 'select', |
161 | 161 | 'class' => 'wpi_select2', |
162 | 162 | 'options' => $currency_code_options, |
163 | 163 | ), |
164 | 164 | 'currency_position' => array( |
165 | 165 | 'id' => 'currency_position', |
166 | - 'name' => __( 'Currency Position', 'invoicing' ), |
|
167 | - 'desc' => __( 'Choose the location of the currency sign.', 'invoicing' ), |
|
166 | + 'name' => __('Currency Position', 'invoicing'), |
|
167 | + 'desc' => __('Choose the location of the currency sign.', 'invoicing'), |
|
168 | 168 | 'type' => 'select', |
169 | 169 | 'class' => 'wpi_select2', |
170 | 170 | 'options' => array( |
171 | - 'left' => __( 'Left', 'invoicing' ) . ' (' . $currency_symbol . wpinv_format_amount( '99.99' ) . ')', |
|
172 | - 'right' => __( 'Right', 'invoicing' ) . ' ('. wpinv_format_amount( '99.99' ) . $currency_symbol . ')', |
|
173 | - 'left_space' => __( 'Left with space', 'invoicing' ) . ' (' . $currency_symbol . ' ' . wpinv_format_amount( '99.99' ) . ')', |
|
174 | - 'right_space' => __( 'Right with space', 'invoicing' ) . ' (' . wpinv_format_amount( '99.99' ) . ' ' . $currency_symbol . ')' |
|
171 | + 'left' => __('Left', 'invoicing') . ' (' . $currency_symbol . wpinv_format_amount('99.99') . ')', |
|
172 | + 'right' => __('Right', 'invoicing') . ' (' . wpinv_format_amount('99.99') . $currency_symbol . ')', |
|
173 | + 'left_space' => __('Left with space', 'invoicing') . ' (' . $currency_symbol . ' ' . wpinv_format_amount('99.99') . ')', |
|
174 | + 'right_space' => __('Right with space', 'invoicing') . ' (' . wpinv_format_amount('99.99') . ' ' . $currency_symbol . ')' |
|
175 | 175 | ) |
176 | 176 | ), |
177 | 177 | 'thousands_separator' => array( |
178 | 178 | 'id' => 'thousands_separator', |
179 | - 'name' => __( 'Thousands Separator', 'invoicing' ), |
|
180 | - 'desc' => __( 'The symbol (usually , or .) to separate thousands', 'invoicing' ), |
|
179 | + 'name' => __('Thousands Separator', 'invoicing'), |
|
180 | + 'desc' => __('The symbol (usually , or .) to separate thousands', 'invoicing'), |
|
181 | 181 | 'type' => 'text', |
182 | 182 | 'size' => 'small', |
183 | 183 | 'std' => ',', |
184 | 184 | ), |
185 | 185 | 'decimal_separator' => array( |
186 | 186 | 'id' => 'decimal_separator', |
187 | - 'name' => __( 'Decimal Separator', 'invoicing' ), |
|
188 | - 'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'invoicing' ), |
|
187 | + 'name' => __('Decimal Separator', 'invoicing'), |
|
188 | + 'desc' => __('The symbol (usually , or .) to separate decimal points', 'invoicing'), |
|
189 | 189 | 'type' => 'text', |
190 | 190 | 'size' => 'small', |
191 | 191 | 'std' => '.', |
192 | 192 | ), |
193 | 193 | 'decimals' => array( |
194 | 194 | 'id' => 'decimals', |
195 | - 'name' => __( 'Number of Decimals', 'invoicing' ), |
|
196 | - 'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'invoicing' ), |
|
195 | + 'name' => __('Number of Decimals', 'invoicing'), |
|
196 | + 'desc' => __('This sets the number of decimal points shown in displayed prices.', 'invoicing'), |
|
197 | 197 | 'type' => 'number', |
198 | 198 | 'size' => 'small', |
199 | 199 | 'std' => '2', |
@@ -205,29 +205,29 @@ discard block |
||
205 | 205 | 'labels' => array( |
206 | 206 | 'labels' => array( |
207 | 207 | 'id' => 'labels_settings', |
208 | - 'name' => '<h3>' . __( 'Invoice Labels', 'invoicing' ) . '</h3>', |
|
208 | + 'name' => '<h3>' . __('Invoice Labels', 'invoicing') . '</h3>', |
|
209 | 209 | 'desc' => '', |
210 | 210 | 'type' => 'header', |
211 | 211 | ), |
212 | 212 | 'vat_name' => array( |
213 | 213 | 'id' => 'vat_name', |
214 | - 'name' => __( 'VAT Name', 'invoicing' ), |
|
215 | - 'desc' => __( 'Enter the VAT name', 'invoicing' ), |
|
214 | + 'name' => __('VAT Name', 'invoicing'), |
|
215 | + 'desc' => __('Enter the VAT name', 'invoicing'), |
|
216 | 216 | 'type' => 'text', |
217 | 217 | 'size' => 'regular', |
218 | - 'std' => __( 'VAT', 'invoicing' ), |
|
218 | + 'std' => __('VAT', 'invoicing'), |
|
219 | 219 | ), |
220 | 220 | 'vat_invoice_notice_label' => array( |
221 | 221 | 'id' => 'vat_invoice_notice_label', |
222 | - 'name' => __( 'Invoice Notice Label', 'invoicing' ), |
|
223 | - 'desc' => __( 'Use this to add an invoice notice section (label) to your invoices', 'invoicing' ), |
|
222 | + 'name' => __('Invoice Notice Label', 'invoicing'), |
|
223 | + 'desc' => __('Use this to add an invoice notice section (label) to your invoices', 'invoicing'), |
|
224 | 224 | 'type' => 'text', |
225 | 225 | 'size' => 'regular', |
226 | 226 | ), |
227 | 227 | 'vat_invoice_notice' => array( |
228 | 228 | 'id' => 'vat_invoice_notice', |
229 | - 'name' => __( 'Invoice notice', 'invoicing' ), |
|
230 | - 'desc' => __( 'Use this to add an invoice notice section (description) to your invoices', 'invoicing' ), |
|
229 | + 'name' => __('Invoice notice', 'invoicing'), |
|
230 | + 'desc' => __('Use this to add an invoice notice section (description) to your invoices', 'invoicing'), |
|
231 | 231 | 'type' => 'text', |
232 | 232 | 'size' => 'regular', |
233 | 233 | ), |
@@ -239,22 +239,22 @@ discard block |
||
239 | 239 | 'main' => array( |
240 | 240 | 'gateway_settings' => array( |
241 | 241 | 'id' => 'api_header', |
242 | - 'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>', |
|
242 | + 'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>', |
|
243 | 243 | 'desc' => '', |
244 | 244 | 'type' => 'header', |
245 | 245 | ), |
246 | 246 | 'gateways' => array( |
247 | 247 | 'id' => 'gateways', |
248 | - 'name' => __( 'Payment Gateways', 'invoicing' ), |
|
249 | - 'desc' => __( 'Choose the payment gateways you want to enable.', 'invoicing' ), |
|
248 | + 'name' => __('Payment Gateways', 'invoicing'), |
|
249 | + 'desc' => __('Choose the payment gateways you want to enable.', 'invoicing'), |
|
250 | 250 | 'type' => 'gateways', |
251 | 251 | 'std' => array('manual'=>1), |
252 | 252 | 'options' => wpinv_get_payment_gateways(), |
253 | 253 | ), |
254 | 254 | 'default_gateway' => array( |
255 | 255 | 'id' => 'default_gateway', |
256 | - 'name' => __( 'Default Gateway', 'invoicing' ), |
|
257 | - 'desc' => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ), |
|
256 | + 'name' => __('Default Gateway', 'invoicing'), |
|
257 | + 'desc' => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'), |
|
258 | 258 | 'type' => 'gateway_select', |
259 | 259 | 'std' => 'manual', |
260 | 260 | 'class' => 'wpi_select2', |
@@ -269,32 +269,32 @@ discard block |
||
269 | 269 | 'main' => array( |
270 | 270 | 'tax_settings' => array( |
271 | 271 | 'id' => 'tax_settings', |
272 | - 'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>', |
|
272 | + 'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>', |
|
273 | 273 | 'type' => 'header', |
274 | 274 | ), |
275 | 275 | |
276 | 276 | 'enable_taxes' => array( |
277 | 277 | 'id' => 'enable_taxes', |
278 | - 'name' => __( 'Enable Taxes', 'invoicing' ), |
|
279 | - 'desc' => __( 'Enable tax rates and calculations.', 'invoicing' ), |
|
278 | + 'name' => __('Enable Taxes', 'invoicing'), |
|
279 | + 'desc' => __('Enable tax rates and calculations.', 'invoicing'), |
|
280 | 280 | 'type' => 'checkbox', |
281 | 281 | 'std' => 0, |
282 | 282 | ), |
283 | 283 | |
284 | 284 | 'tax_subtotal_rounding' => array( |
285 | 285 | 'id' => 'tax_subtotal_rounding', |
286 | - 'name' => __( 'Rounding', 'invoicing' ), |
|
287 | - 'desc' => __( 'Round tax at subtotal level, instead of rounding per tax rate', 'invoicing' ), |
|
286 | + 'name' => __('Rounding', 'invoicing'), |
|
287 | + 'desc' => __('Round tax at subtotal level, instead of rounding per tax rate', 'invoicing'), |
|
288 | 288 | 'type' => 'checkbox', |
289 | 289 | 'std' => 1, |
290 | 290 | ), |
291 | 291 | |
292 | 292 | 'prices_include_tax' => array( |
293 | 293 | 'id' => 'prices_include_tax', |
294 | - 'name' => __( 'Prices entered with tax', 'invoicing' ), |
|
294 | + 'name' => __('Prices entered with tax', 'invoicing'), |
|
295 | 295 | 'options' => array( |
296 | - 'yes' => __( 'Yes, I will enter prices inclusive of tax', 'invoicing' ), |
|
297 | - 'no' => __( 'No, I will enter prices exclusive of tax', 'invoicing' ), |
|
296 | + 'yes' => __('Yes, I will enter prices inclusive of tax', 'invoicing'), |
|
297 | + 'no' => __('No, I will enter prices exclusive of tax', 'invoicing'), |
|
298 | 298 | ), |
299 | 299 | 'type' => 'select', |
300 | 300 | 'std' => 'no', |
@@ -302,10 +302,10 @@ discard block |
||
302 | 302 | |
303 | 303 | 'tax_base' => array( |
304 | 304 | 'id' => 'tax_base', |
305 | - 'name' => __( 'Calculate tax based on', 'invoicing' ), |
|
305 | + 'name' => __('Calculate tax based on', 'invoicing'), |
|
306 | 306 | 'options' => array( |
307 | - 'billing' => __( 'Customer billing address', 'invoicing' ), |
|
308 | - 'base' => __( 'Shop base address', 'invoicing' ), |
|
307 | + 'billing' => __('Customer billing address', 'invoicing'), |
|
308 | + 'base' => __('Shop base address', 'invoicing'), |
|
309 | 309 | ), |
310 | 310 | 'type' => 'select', |
311 | 311 | 'std' => 'billing', |
@@ -313,10 +313,10 @@ discard block |
||
313 | 313 | |
314 | 314 | 'tax_display_totals' => array( |
315 | 315 | 'id' => 'tax_display_totals', |
316 | - 'name' => __( 'Display tax totals', 'invoicing' ), |
|
316 | + 'name' => __('Display tax totals', 'invoicing'), |
|
317 | 317 | 'options' => array( |
318 | - 'single' => __( 'As a single total', 'invoicing' ), |
|
319 | - 'individual' => __( 'As individual tax rates', 'invoicing' ), |
|
318 | + 'single' => __('As a single total', 'invoicing'), |
|
319 | + 'individual' => __('As individual tax rates', 'invoicing'), |
|
320 | 320 | ), |
321 | 321 | 'type' => 'select', |
322 | 322 | 'std' => 'individual', |
@@ -324,8 +324,8 @@ discard block |
||
324 | 324 | |
325 | 325 | 'tax_rate' => array( |
326 | 326 | 'id' => 'tax_rate', |
327 | - 'name' => __( 'Fallback Tax Rate', 'invoicing' ), |
|
328 | - 'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ), |
|
327 | + 'name' => __('Fallback Tax Rate', 'invoicing'), |
|
328 | + 'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'), |
|
329 | 329 | 'type' => 'number', |
330 | 330 | 'size' => 'small', |
331 | 331 | 'min' => '0', |
@@ -337,8 +337,8 @@ discard block |
||
337 | 337 | 'rates' => array( |
338 | 338 | 'tax_rates' => array( |
339 | 339 | 'id' => 'tax_rates', |
340 | - 'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>', |
|
341 | - 'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ), |
|
340 | + 'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>', |
|
341 | + 'desc' => __('Enter tax rates for specific regions.', 'invoicing'), |
|
342 | 342 | 'type' => 'tax_rates', |
343 | 343 | ), |
344 | 344 | ), |
@@ -347,44 +347,44 @@ discard block |
||
347 | 347 | |
348 | 348 | 'vat_company_name' => array( |
349 | 349 | 'id' => 'vat_company_name', |
350 | - 'name' => __( 'Company Name', 'invoicing' ), |
|
351 | - 'desc' => wp_sprintf(__( 'Verify your company name and VAT number on the %sEU VIES System.%s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ), |
|
350 | + 'name' => __('Company Name', 'invoicing'), |
|
351 | + 'desc' => wp_sprintf(__('Verify your company name and VAT number on the %sEU VIES System.%s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'), |
|
352 | 352 | 'type' => 'text', |
353 | 353 | 'size' => 'regular', |
354 | 354 | ), |
355 | 355 | |
356 | 356 | 'vat_number' => array( |
357 | 357 | 'id' => 'vat_number', |
358 | - 'name' => __( 'VAT Number', 'invoicing' ), |
|
359 | - 'desc' => __( 'Enter your VAT number including the country identifier, eg: GB123456789', 'invoicing' ), |
|
358 | + 'name' => __('VAT Number', 'invoicing'), |
|
359 | + 'desc' => __('Enter your VAT number including the country identifier, eg: GB123456789', 'invoicing'), |
|
360 | 360 | 'type' => 'text', |
361 | 361 | 'size' => 'regular', |
362 | 362 | ), |
363 | 363 | |
364 | 364 | 'vat_prevent_b2c_purchase' => array( |
365 | 365 | 'id' => 'vat_prevent_b2c_purchase', |
366 | - 'name' => __( 'Prevent B2C Sales', 'invoicing' ), |
|
367 | - 'desc' => __( 'Require everyone in the EU to provide a VAT number.', 'invoicing' ), |
|
366 | + 'name' => __('Prevent B2C Sales', 'invoicing'), |
|
367 | + 'desc' => __('Require everyone in the EU to provide a VAT number.', 'invoicing'), |
|
368 | 368 | 'type' => 'checkbox' |
369 | 369 | ), |
370 | 370 | |
371 | 371 | 'validate_vat_number' => array( |
372 | 372 | 'id' => 'validate_vat_number', |
373 | - 'name' => __( 'Validate VAT Number', 'invoicing' ), |
|
374 | - 'desc' => __( 'Validate VAT numbers with VIES.', 'invoicing' ), |
|
373 | + 'name' => __('Validate VAT Number', 'invoicing'), |
|
374 | + 'desc' => __('Validate VAT numbers with VIES.', 'invoicing'), |
|
375 | 375 | 'type' => 'checkbox' |
376 | 376 | ), |
377 | 377 | |
378 | 378 | 'vat_same_country_rule' => array( |
379 | 379 | 'id' => 'vat_same_country_rule', |
380 | - 'name' => __( 'Same Country Rule', 'invoicing' ), |
|
381 | - 'desc' => __( 'What should happen if a customer is from the same country as your business?', 'invoicing' ), |
|
380 | + 'name' => __('Same Country Rule', 'invoicing'), |
|
381 | + 'desc' => __('What should happen if a customer is from the same country as your business?', 'invoicing'), |
|
382 | 382 | 'type' => 'select', |
383 | 383 | 'options' => array( |
384 | - 'no' => __( 'Do not charge Tax', 'invoicing' ), |
|
385 | - 'always' => __( 'Charge Tax', 'invoicing' ), |
|
384 | + 'no' => __('Do not charge Tax', 'invoicing'), |
|
385 | + 'always' => __('Charge Tax', 'invoicing'), |
|
386 | 386 | ), |
387 | - 'placeholder' => __( 'Select an option', 'invoicing' ), |
|
387 | + 'placeholder' => __('Select an option', 'invoicing'), |
|
388 | 388 | 'std' => 'always', |
389 | 389 | ), |
390 | 390 | |
@@ -398,68 +398,68 @@ discard block |
||
398 | 398 | 'main' => array( |
399 | 399 | 'email_settings_header' => array( |
400 | 400 | 'id' => 'email_settings_header', |
401 | - 'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>', |
|
401 | + 'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>', |
|
402 | 402 | 'type' => 'header', |
403 | 403 | ), |
404 | 404 | 'email_from_name' => array( |
405 | 405 | 'id' => 'email_from_name', |
406 | - 'name' => __( 'From Name', 'invoicing' ), |
|
407 | - 'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ), |
|
408 | - 'std' => esc_attr( get_bloginfo( 'name', 'display' ) ), |
|
406 | + 'name' => __('From Name', 'invoicing'), |
|
407 | + 'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'), |
|
408 | + 'std' => esc_attr(get_bloginfo('name', 'display')), |
|
409 | 409 | 'type' => 'text', |
410 | 410 | ), |
411 | 411 | 'email_from' => array( |
412 | 412 | 'id' => 'email_from', |
413 | - 'name' => __( 'From Email', 'invoicing' ), |
|
414 | - 'desc' => sprintf (__( 'Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing' ), $alert_wrapper_start, $alert_wrapper_close), |
|
415 | - 'std' => get_option( 'admin_email' ), |
|
413 | + 'name' => __('From Email', 'invoicing'), |
|
414 | + 'desc' => sprintf(__('Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing'), $alert_wrapper_start, $alert_wrapper_close), |
|
415 | + 'std' => get_option('admin_email'), |
|
416 | 416 | 'type' => 'text', |
417 | 417 | ), |
418 | 418 | 'admin_email' => array( |
419 | 419 | 'id' => 'admin_email', |
420 | - 'name' => __( 'Admin Email', 'invoicing' ), |
|
421 | - 'desc' => __( 'Where should we send admin notifications?', 'invoicing' ), |
|
422 | - 'std' => get_option( 'admin_email' ), |
|
420 | + 'name' => __('Admin Email', 'invoicing'), |
|
421 | + 'desc' => __('Where should we send admin notifications?', 'invoicing'), |
|
422 | + 'std' => get_option('admin_email'), |
|
423 | 423 | 'type' => 'text', |
424 | 424 | ), |
425 | 425 | 'overdue_settings_header' => array( |
426 | 426 | 'id' => 'overdue_settings_header', |
427 | - 'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>', |
|
427 | + 'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>', |
|
428 | 428 | 'type' => 'header', |
429 | 429 | ), |
430 | 430 | 'overdue_active' => array( |
431 | 431 | 'id' => 'overdue_active', |
432 | - 'name' => __( 'Enable Due Date', 'invoicing' ), |
|
433 | - 'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ), |
|
432 | + 'name' => __('Enable Due Date', 'invoicing'), |
|
433 | + 'desc' => __('Check this to enable due date option for invoices.', 'invoicing'), |
|
434 | 434 | 'type' => 'checkbox', |
435 | 435 | 'std' => false, |
436 | 436 | ), |
437 | 437 | 'overdue_days' => array( |
438 | 438 | 'id' => 'overdue_days', |
439 | - 'name' => __( 'Default Due Date', 'invoicing' ), |
|
440 | - 'desc' => __( 'Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing' ), |
|
439 | + 'name' => __('Default Due Date', 'invoicing'), |
|
440 | + 'desc' => __('Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing'), |
|
441 | 441 | 'type' => 'select', |
442 | 442 | 'options' => $due_payment_options, |
443 | 443 | 'std' => 0, |
444 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
444 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
445 | 445 | ), |
446 | 446 | 'email_template_header' => array( |
447 | 447 | 'id' => 'email_template_header', |
448 | - 'name' => '<h3>' . __( 'Email Template', 'invoicing' ) . '</h3>', |
|
448 | + 'name' => '<h3>' . __('Email Template', 'invoicing') . '</h3>', |
|
449 | 449 | 'type' => 'header', |
450 | 450 | ), |
451 | 451 | 'email_header_image' => array( |
452 | 452 | 'id' => 'email_header_image', |
453 | - 'name' => __( 'Header Image', 'invoicing' ), |
|
454 | - 'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing' ), |
|
453 | + 'name' => __('Header Image', 'invoicing'), |
|
454 | + 'desc' => __('URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing'), |
|
455 | 455 | 'std' => '', |
456 | 456 | 'type' => 'text', |
457 | 457 | ), |
458 | 458 | 'email_footer_text' => array( |
459 | 459 | 'id' => 'email_footer_text', |
460 | - 'name' => __( 'Footer Text', 'invoicing' ), |
|
461 | - 'desc' => __( 'The text to appear in the footer of all invoice emails.', 'invoicing' ), |
|
462 | - 'std' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GeoDirectory', 'invoicing' ), |
|
460 | + 'name' => __('Footer Text', 'invoicing'), |
|
461 | + 'desc' => __('The text to appear in the footer of all invoice emails.', 'invoicing'), |
|
462 | + 'std' => get_bloginfo('name', 'display') . ' - ' . __('Powered by GeoDirectory', 'invoicing'), |
|
463 | 463 | 'type' => 'textarea', |
464 | 464 | 'class' => 'regular-text', |
465 | 465 | 'rows' => 2, |
@@ -467,29 +467,29 @@ discard block |
||
467 | 467 | ), |
468 | 468 | 'email_base_color' => array( |
469 | 469 | 'id' => 'email_base_color', |
470 | - 'name' => __( 'Base Color', 'invoicing' ), |
|
471 | - 'desc' => __( 'The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing' ), |
|
470 | + 'name' => __('Base Color', 'invoicing'), |
|
471 | + 'desc' => __('The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing'), |
|
472 | 472 | 'std' => '#557da2', |
473 | 473 | 'type' => 'color', |
474 | 474 | ), |
475 | 475 | 'email_background_color' => array( |
476 | 476 | 'id' => 'email_background_color', |
477 | - 'name' => __( 'Background Color', 'invoicing' ), |
|
478 | - 'desc' => __( 'The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing' ), |
|
477 | + 'name' => __('Background Color', 'invoicing'), |
|
478 | + 'desc' => __('The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing'), |
|
479 | 479 | 'std' => '#f5f5f5', |
480 | 480 | 'type' => 'color', |
481 | 481 | ), |
482 | 482 | 'email_body_background_color' => array( |
483 | 483 | 'id' => 'email_body_background_color', |
484 | - 'name' => __( 'Body Background Color', 'invoicing' ), |
|
485 | - 'desc' => __( 'The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing' ), |
|
484 | + 'name' => __('Body Background Color', 'invoicing'), |
|
485 | + 'desc' => __('The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing'), |
|
486 | 486 | 'std' => '#fdfdfd', |
487 | 487 | 'type' => 'color', |
488 | 488 | ), |
489 | 489 | 'email_text_color' => array( |
490 | 490 | 'id' => 'email_text_color', |
491 | - 'name' => __( 'Body Text Color', 'invoicing' ), |
|
492 | - 'desc' => __( 'The main body text color. Default <code>#505050</code>.', 'invoicing' ), |
|
491 | + 'name' => __('Body Text Color', 'invoicing'), |
|
492 | + 'desc' => __('The main body text color. Default <code>#505050</code>.', 'invoicing'), |
|
493 | 493 | 'std' => '#505050', |
494 | 494 | 'type' => 'color', |
495 | 495 | ), |
@@ -508,17 +508,17 @@ discard block |
||
508 | 508 | 'main' => array( |
509 | 509 | 'invoicing_privacy_policy_settings' => array( |
510 | 510 | 'id' => 'invoicing_privacy_policy_settings', |
511 | - 'name' => '<h3>' . __( 'Privacy Policy', 'invoicing' ) . '</h3>', |
|
511 | + 'name' => '<h3>' . __('Privacy Policy', 'invoicing') . '</h3>', |
|
512 | 512 | 'type' => 'header', |
513 | 513 | ), |
514 | 514 | 'privacy_page' => array( |
515 | 515 | 'id' => 'privacy_page', |
516 | - 'name' => __( 'Privacy Page', 'invoicing' ), |
|
517 | - 'desc' => __( 'If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing' ), |
|
516 | + 'name' => __('Privacy Page', 'invoicing'), |
|
517 | + 'desc' => __('If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing'), |
|
518 | 518 | 'type' => 'select', |
519 | - 'options' => wpinv_get_pages( true, __( 'Select a page', 'invoicing' )), |
|
519 | + 'options' => wpinv_get_pages(true, __('Select a page', 'invoicing')), |
|
520 | 520 | 'class' => 'wpi_select2', |
521 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
521 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
522 | 522 | ), |
523 | 523 | ), |
524 | 524 | ) |
@@ -529,19 +529,19 @@ discard block |
||
529 | 529 | 'main' => array( |
530 | 530 | 'invoice_number_format_settings' => array( |
531 | 531 | 'id' => 'invoice_number_format_settings', |
532 | - 'name' => '<h3>' . __( 'Invoice Number', 'invoicing' ) . '</h3>', |
|
532 | + 'name' => '<h3>' . __('Invoice Number', 'invoicing') . '</h3>', |
|
533 | 533 | 'type' => 'header', |
534 | 534 | ), |
535 | 535 | 'sequential_invoice_number' => array( |
536 | 536 | 'id' => 'sequential_invoice_number', |
537 | - 'name' => __( 'Sequential Invoice Numbers', 'invoicing' ), |
|
538 | - 'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing' ) . $reset_number, |
|
537 | + 'name' => __('Sequential Invoice Numbers', 'invoicing'), |
|
538 | + 'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing') . $reset_number, |
|
539 | 539 | 'type' => 'checkbox', |
540 | 540 | ), |
541 | 541 | 'invoice_sequence_start' => array( |
542 | 542 | 'id' => 'invoice_sequence_start', |
543 | - 'name' => __( 'Sequential Starting Number', 'invoicing' ), |
|
544 | - 'desc' => __( 'The number at which the invoice number sequence should begin.', 'invoicing' ) . $last_number, |
|
543 | + 'name' => __('Sequential Starting Number', 'invoicing'), |
|
544 | + 'desc' => __('The number at which the invoice number sequence should begin.', 'invoicing') . $last_number, |
|
545 | 545 | 'type' => 'number', |
546 | 546 | 'size' => 'small', |
547 | 547 | 'std' => '1', |
@@ -549,8 +549,8 @@ discard block |
||
549 | 549 | ), |
550 | 550 | 'invoice_number_padd' => array( |
551 | 551 | 'id' => 'invoice_number_padd', |
552 | - 'name' => __( 'Minimum Digits', 'invoicing' ), |
|
553 | - 'desc' => __( 'If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing' ), |
|
552 | + 'name' => __('Minimum Digits', 'invoicing'), |
|
553 | + 'desc' => __('If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing'), |
|
554 | 554 | 'type' => 'select', |
555 | 555 | 'options' => $invoice_number_padd_options, |
556 | 556 | 'std' => 5, |
@@ -558,8 +558,8 @@ discard block |
||
558 | 558 | ), |
559 | 559 | 'invoice_number_prefix' => array( |
560 | 560 | 'id' => 'invoice_number_prefix', |
561 | - 'name' => __( 'Invoice Number Prefix', 'invoicing' ), |
|
562 | - 'desc' => __( 'Prefix for all invoice numbers. Ex: INV-', 'invoicing' ), |
|
561 | + 'name' => __('Invoice Number Prefix', 'invoicing'), |
|
562 | + 'desc' => __('Prefix for all invoice numbers. Ex: INV-', 'invoicing'), |
|
563 | 563 | 'type' => 'text', |
564 | 564 | 'size' => 'regular', |
565 | 565 | 'std' => 'INV-', |
@@ -567,41 +567,41 @@ discard block |
||
567 | 567 | ), |
568 | 568 | 'invoice_number_postfix' => array( |
569 | 569 | 'id' => 'invoice_number_postfix', |
570 | - 'name' => __( 'Invoice Number Postfix', 'invoicing' ), |
|
571 | - 'desc' => __( 'Postfix for all invoice numbers.', 'invoicing' ), |
|
570 | + 'name' => __('Invoice Number Postfix', 'invoicing'), |
|
571 | + 'desc' => __('Postfix for all invoice numbers.', 'invoicing'), |
|
572 | 572 | 'type' => 'text', |
573 | 573 | 'size' => 'regular', |
574 | 574 | 'std' => '' |
575 | 575 | ), |
576 | 576 | 'checkout_settings' => array( |
577 | 577 | 'id' => 'checkout_settings', |
578 | - 'name' => '<h3>' . __( 'Checkout Settings', 'invoicing' ) . '</h3>', |
|
578 | + 'name' => '<h3>' . __('Checkout Settings', 'invoicing') . '</h3>', |
|
579 | 579 | 'type' => 'header', |
580 | 580 | ), |
581 | 581 | 'login_to_checkout' => array( |
582 | 582 | 'id' => 'login_to_checkout', |
583 | - 'name' => __( 'Require Login To Checkout', 'invoicing' ), |
|
584 | - 'desc' => __( 'If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing' ), |
|
583 | + 'name' => __('Require Login To Checkout', 'invoicing'), |
|
584 | + 'desc' => __('If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing'), |
|
585 | 585 | 'type' => 'checkbox', |
586 | 586 | ), |
587 | 587 | |
588 | 588 | 'maxmind_license_key' => array( |
589 | 589 | 'id' => 'maxmind_license_key', |
590 | - 'name' => __( 'MaxMind License Key', 'invoicing' ), |
|
590 | + 'name' => __('MaxMind License Key', 'invoicing'), |
|
591 | 591 | 'type' => 'text', |
592 | 592 | 'size' => 'regular', |
593 | - 'desc' => __( "Enter you license key if you would like to use MaxMind to automatically detect a customer's country.", 'invoicing' ) . ' <a href="https://support.maxmind.com/account-faq/license-keys/how-do-i-generate-a-license-key/">' . __( 'How to generate a free license key.', 'invoicing' ) . '</a>', |
|
593 | + 'desc' => __("Enter you license key if you would like to use MaxMind to automatically detect a customer's country.", 'invoicing') . ' <a href="https://support.maxmind.com/account-faq/license-keys/how-do-i-generate-a-license-key/">' . __('How to generate a free license key.', 'invoicing') . '</a>', |
|
594 | 594 | ), |
595 | 595 | |
596 | 596 | 'uninstall_settings' => array( |
597 | 597 | 'id' => 'uninstall_settings', |
598 | - 'name' => '<h3>' . __( 'Uninstall Settings', 'invoicing' ) . '</h3>', |
|
598 | + 'name' => '<h3>' . __('Uninstall Settings', 'invoicing') . '</h3>', |
|
599 | 599 | 'type' => 'header', |
600 | 600 | ), |
601 | 601 | 'remove_data_on_unistall' => array( |
602 | 602 | 'id' => 'remove_data_on_unistall', |
603 | - 'name' => __( 'Remove Data on Uninstall?', 'invoicing' ), |
|
604 | - 'desc' => __( 'Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing' ), |
|
603 | + 'name' => __('Remove Data on Uninstall?', 'invoicing'), |
|
604 | + 'desc' => __('Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing'), |
|
605 | 605 | 'type' => 'checkbox', |
606 | 606 | 'std' => '' |
607 | 607 | ), |
@@ -610,13 +610,13 @@ discard block |
||
610 | 610 | 'custom-css' => array( |
611 | 611 | 'css_settings' => array( |
612 | 612 | 'id' => 'css_settings', |
613 | - 'name' => '<h3>' . __( 'Custom CSS', 'invoicing' ) . '</h3>', |
|
613 | + 'name' => '<h3>' . __('Custom CSS', 'invoicing') . '</h3>', |
|
614 | 614 | 'type' => 'header', |
615 | 615 | ), |
616 | 616 | 'template_custom_css' => array( |
617 | 617 | 'id' => 'template_custom_css', |
618 | - 'name' => __( 'Invoice Template CSS', 'invoicing' ), |
|
619 | - 'desc' => __( 'Add CSS to modify appearance of the print invoice page.', 'invoicing' ), |
|
618 | + 'name' => __('Invoice Template CSS', 'invoicing'), |
|
619 | + 'desc' => __('Add CSS to modify appearance of the print invoice page.', 'invoicing'), |
|
620 | 620 | 'type' => 'textarea', |
621 | 621 | 'class'=> 'regular-text', |
622 | 622 | 'rows' => 10, |
@@ -630,8 +630,8 @@ discard block |
||
630 | 630 | 'main' => array( |
631 | 631 | 'tool_settings' => array( |
632 | 632 | 'id' => 'tool_settings', |
633 | - 'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>', |
|
634 | - 'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ), |
|
633 | + 'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>', |
|
634 | + 'desc' => __('Invoicing diagnostic tools', 'invoicing'), |
|
635 | 635 | 'type' => 'tools', |
636 | 636 | ), |
637 | 637 | ), |
@@ -6,7 +6,7 @@ |
||
6 | 6 | * @package Invoicing/data |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | array( |
12 | 12 |
@@ -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,8 +587,8 @@ 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 | /** |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | * @return string |
599 | 599 | */ |
600 | 600 | public function get_invoice_quote_type() { |
601 | - return getpaid_get_post_type_label( $this->get_post_type(), false ); |
|
601 | + return getpaid_get_post_type_label($this->get_post_type(), false); |
|
602 | 602 | } |
603 | 603 | |
604 | 604 | /** |
@@ -608,8 +608,8 @@ discard block |
||
608 | 608 | * @param string $context View or edit context. |
609 | 609 | * @return string |
610 | 610 | */ |
611 | - public function get_post_type( $context = 'view' ) { |
|
612 | - return $this->get_prop( 'post_type', $context ); |
|
611 | + public function get_post_type($context = 'view') { |
|
612 | + return $this->get_prop('post_type', $context); |
|
613 | 613 | } |
614 | 614 | |
615 | 615 | /** |
@@ -619,8 +619,8 @@ discard block |
||
619 | 619 | * @param string $context View or edit context. |
620 | 620 | * @return string |
621 | 621 | */ |
622 | - public function get_mode( $context = 'view' ) { |
|
623 | - return $this->get_prop( 'mode', $context ); |
|
622 | + public function get_mode($context = 'view') { |
|
623 | + return $this->get_prop('mode', $context); |
|
624 | 624 | } |
625 | 625 | |
626 | 626 | /** |
@@ -630,13 +630,13 @@ discard block |
||
630 | 630 | * @param string $context View or edit context. |
631 | 631 | * @return string |
632 | 632 | */ |
633 | - public function get_path( $context = 'view' ) { |
|
634 | - $path = $this->get_prop( 'path', $context ); |
|
633 | + public function get_path($context = 'view') { |
|
634 | + $path = $this->get_prop('path', $context); |
|
635 | 635 | $prefix = $this->get_type(); |
636 | 636 | |
637 | - if ( 0 !== strpos( $path, $prefix ) ) { |
|
638 | - $path = sanitize_title( $prefix . '-' . $this->get_id() ); |
|
639 | - $this->set_path( $path ); |
|
637 | + if (0 !== strpos($path, $prefix)) { |
|
638 | + $path = sanitize_title($prefix . '-' . $this->get_id()); |
|
639 | + $this->set_path($path); |
|
640 | 640 | } |
641 | 641 | |
642 | 642 | return $path; |
@@ -649,8 +649,8 @@ discard block |
||
649 | 649 | * @param string $context View or edit context. |
650 | 650 | * @return string |
651 | 651 | */ |
652 | - public function get_name( $context = 'view' ) { |
|
653 | - return $this->get_prop( 'title', $context ); |
|
652 | + public function get_name($context = 'view') { |
|
653 | + return $this->get_prop('title', $context); |
|
654 | 654 | } |
655 | 655 | |
656 | 656 | /** |
@@ -660,8 +660,8 @@ discard block |
||
660 | 660 | * @param string $context View or edit context. |
661 | 661 | * @return string |
662 | 662 | */ |
663 | - public function get_title( $context = 'view' ) { |
|
664 | - return $this->get_name( $context ); |
|
663 | + public function get_title($context = 'view') { |
|
664 | + return $this->get_name($context); |
|
665 | 665 | } |
666 | 666 | |
667 | 667 | /** |
@@ -671,8 +671,8 @@ discard block |
||
671 | 671 | * @param string $context View or edit context. |
672 | 672 | * @return string |
673 | 673 | */ |
674 | - public function get_description( $context = 'view' ) { |
|
675 | - return $this->get_prop( 'description', $context ); |
|
674 | + public function get_description($context = 'view') { |
|
675 | + return $this->get_prop('description', $context); |
|
676 | 676 | } |
677 | 677 | |
678 | 678 | /** |
@@ -682,8 +682,8 @@ discard block |
||
682 | 682 | * @param string $context View or edit context. |
683 | 683 | * @return string |
684 | 684 | */ |
685 | - public function get_excerpt( $context = 'view' ) { |
|
686 | - return $this->get_description( $context ); |
|
685 | + public function get_excerpt($context = 'view') { |
|
686 | + return $this->get_description($context); |
|
687 | 687 | } |
688 | 688 | |
689 | 689 | /** |
@@ -693,8 +693,8 @@ discard block |
||
693 | 693 | * @param string $context View or edit context. |
694 | 694 | * @return string |
695 | 695 | */ |
696 | - public function get_summary( $context = 'view' ) { |
|
697 | - return $this->get_description( $context ); |
|
696 | + public function get_summary($context = 'view') { |
|
697 | + return $this->get_description($context); |
|
698 | 698 | } |
699 | 699 | |
700 | 700 | /** |
@@ -704,25 +704,25 @@ discard block |
||
704 | 704 | * @param string $context View or edit context. |
705 | 705 | * @return array |
706 | 706 | */ |
707 | - public function get_user_info( $context = 'view' ) { |
|
707 | + public function get_user_info($context = 'view') { |
|
708 | 708 | |
709 | 709 | $user_info = array( |
710 | - 'user_id' => $this->get_user_id( $context ), |
|
711 | - 'email' => $this->get_email( $context ), |
|
712 | - 'first_name' => $this->get_first_name( $context ), |
|
713 | - 'last_name' => $this->get_last_name( $context ), |
|
714 | - 'address' => $this->get_address( $context ), |
|
715 | - 'phone' => $this->get_phone( $context ), |
|
716 | - 'city' => $this->get_city( $context ), |
|
717 | - 'country' => $this->get_country( $context ), |
|
718 | - 'state' => $this->get_state( $context ), |
|
719 | - 'zip' => $this->get_zip( $context ), |
|
720 | - 'company' => $this->get_company( $context ), |
|
721 | - 'vat_number' => $this->get_vat_number( $context ), |
|
722 | - 'discount' => $this->get_discount_code( $context ), |
|
710 | + 'user_id' => $this->get_user_id($context), |
|
711 | + 'email' => $this->get_email($context), |
|
712 | + 'first_name' => $this->get_first_name($context), |
|
713 | + 'last_name' => $this->get_last_name($context), |
|
714 | + 'address' => $this->get_address($context), |
|
715 | + 'phone' => $this->get_phone($context), |
|
716 | + 'city' => $this->get_city($context), |
|
717 | + 'country' => $this->get_country($context), |
|
718 | + 'state' => $this->get_state($context), |
|
719 | + 'zip' => $this->get_zip($context), |
|
720 | + 'company' => $this->get_company($context), |
|
721 | + 'vat_number' => $this->get_vat_number($context), |
|
722 | + 'discount' => $this->get_discount_code($context), |
|
723 | 723 | ); |
724 | 724 | |
725 | - return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this ); |
|
725 | + return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this); |
|
726 | 726 | |
727 | 727 | } |
728 | 728 | |
@@ -733,8 +733,8 @@ discard block |
||
733 | 733 | * @param string $context View or edit context. |
734 | 734 | * @return int |
735 | 735 | */ |
736 | - public function get_author( $context = 'view' ) { |
|
737 | - return (int) $this->get_prop( 'author', $context ); |
|
736 | + public function get_author($context = 'view') { |
|
737 | + return (int) $this->get_prop('author', $context); |
|
738 | 738 | } |
739 | 739 | |
740 | 740 | /** |
@@ -744,8 +744,8 @@ discard block |
||
744 | 744 | * @param string $context View or edit context. |
745 | 745 | * @return int |
746 | 746 | */ |
747 | - public function get_user_id( $context = 'view' ) { |
|
748 | - return $this->get_author( $context ); |
|
747 | + public function get_user_id($context = 'view') { |
|
748 | + return $this->get_author($context); |
|
749 | 749 | } |
750 | 750 | |
751 | 751 | /** |
@@ -755,8 +755,8 @@ discard block |
||
755 | 755 | * @param string $context View or edit context. |
756 | 756 | * @return int |
757 | 757 | */ |
758 | - public function get_customer_id( $context = 'view' ) { |
|
759 | - return $this->get_author( $context ); |
|
758 | + public function get_customer_id($context = 'view') { |
|
759 | + return $this->get_author($context); |
|
760 | 760 | } |
761 | 761 | |
762 | 762 | /** |
@@ -766,8 +766,8 @@ discard block |
||
766 | 766 | * @param string $context View or edit context. |
767 | 767 | * @return string |
768 | 768 | */ |
769 | - public function get_ip( $context = 'view' ) { |
|
770 | - return $this->get_prop( 'user_ip', $context ); |
|
769 | + public function get_ip($context = 'view') { |
|
770 | + return $this->get_prop('user_ip', $context); |
|
771 | 771 | } |
772 | 772 | |
773 | 773 | /** |
@@ -777,8 +777,8 @@ discard block |
||
777 | 777 | * @param string $context View or edit context. |
778 | 778 | * @return string |
779 | 779 | */ |
780 | - public function get_user_ip( $context = 'view' ) { |
|
781 | - return $this->get_ip( $context ); |
|
780 | + public function get_user_ip($context = 'view') { |
|
781 | + return $this->get_ip($context); |
|
782 | 782 | } |
783 | 783 | |
784 | 784 | /** |
@@ -788,8 +788,8 @@ discard block |
||
788 | 788 | * @param string $context View or edit context. |
789 | 789 | * @return string |
790 | 790 | */ |
791 | - public function get_customer_ip( $context = 'view' ) { |
|
792 | - return $this->get_ip( $context ); |
|
791 | + public function get_customer_ip($context = 'view') { |
|
792 | + return $this->get_ip($context); |
|
793 | 793 | } |
794 | 794 | |
795 | 795 | /** |
@@ -799,8 +799,8 @@ discard block |
||
799 | 799 | * @param string $context View or edit context. |
800 | 800 | * @return string |
801 | 801 | */ |
802 | - public function get_first_name( $context = 'view' ) { |
|
803 | - return $this->get_prop( 'first_name', $context ); |
|
802 | + public function get_first_name($context = 'view') { |
|
803 | + return $this->get_prop('first_name', $context); |
|
804 | 804 | } |
805 | 805 | |
806 | 806 | /** |
@@ -810,8 +810,8 @@ discard block |
||
810 | 810 | * @param string $context View or edit context. |
811 | 811 | * @return string |
812 | 812 | */ |
813 | - public function get_user_first_name( $context = 'view' ) { |
|
814 | - return $this->get_first_name( $context ); |
|
813 | + public function get_user_first_name($context = 'view') { |
|
814 | + return $this->get_first_name($context); |
|
815 | 815 | } |
816 | 816 | |
817 | 817 | /** |
@@ -821,8 +821,8 @@ discard block |
||
821 | 821 | * @param string $context View or edit context. |
822 | 822 | * @return string |
823 | 823 | */ |
824 | - public function get_customer_first_name( $context = 'view' ) { |
|
825 | - return $this->get_first_name( $context ); |
|
824 | + public function get_customer_first_name($context = 'view') { |
|
825 | + return $this->get_first_name($context); |
|
826 | 826 | } |
827 | 827 | |
828 | 828 | /** |
@@ -832,8 +832,8 @@ discard block |
||
832 | 832 | * @param string $context View or edit context. |
833 | 833 | * @return string |
834 | 834 | */ |
835 | - public function get_last_name( $context = 'view' ) { |
|
836 | - return $this->get_prop( 'last_name', $context ); |
|
835 | + public function get_last_name($context = 'view') { |
|
836 | + return $this->get_prop('last_name', $context); |
|
837 | 837 | } |
838 | 838 | |
839 | 839 | /** |
@@ -843,8 +843,8 @@ discard block |
||
843 | 843 | * @param string $context View or edit context. |
844 | 844 | * @return string |
845 | 845 | */ |
846 | - public function get_user_last_name( $context = 'view' ) { |
|
847 | - return $this->get_last_name( $context ); |
|
846 | + public function get_user_last_name($context = 'view') { |
|
847 | + return $this->get_last_name($context); |
|
848 | 848 | } |
849 | 849 | |
850 | 850 | /** |
@@ -854,8 +854,8 @@ discard block |
||
854 | 854 | * @param string $context View or edit context. |
855 | 855 | * @return string |
856 | 856 | */ |
857 | - public function get_customer_last_name( $context = 'view' ) { |
|
858 | - return $this->get_last_name( $context ); |
|
857 | + public function get_customer_last_name($context = 'view') { |
|
858 | + return $this->get_last_name($context); |
|
859 | 859 | } |
860 | 860 | |
861 | 861 | /** |
@@ -865,8 +865,8 @@ discard block |
||
865 | 865 | * @param string $context View or edit context. |
866 | 866 | * @return string |
867 | 867 | */ |
868 | - public function get_full_name( $context = 'view' ) { |
|
869 | - return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) ); |
|
868 | + public function get_full_name($context = 'view') { |
|
869 | + return trim($this->get_first_name($context) . ' ' . $this->get_last_name($context)); |
|
870 | 870 | } |
871 | 871 | |
872 | 872 | /** |
@@ -876,8 +876,8 @@ discard block |
||
876 | 876 | * @param string $context View or edit context. |
877 | 877 | * @return string |
878 | 878 | */ |
879 | - public function get_user_full_name( $context = 'view' ) { |
|
880 | - return $this->get_full_name( $context ); |
|
879 | + public function get_user_full_name($context = 'view') { |
|
880 | + return $this->get_full_name($context); |
|
881 | 881 | } |
882 | 882 | |
883 | 883 | /** |
@@ -887,8 +887,8 @@ discard block |
||
887 | 887 | * @param string $context View or edit context. |
888 | 888 | * @return string |
889 | 889 | */ |
890 | - public function get_customer_full_name( $context = 'view' ) { |
|
891 | - return $this->get_full_name( $context ); |
|
890 | + public function get_customer_full_name($context = 'view') { |
|
891 | + return $this->get_full_name($context); |
|
892 | 892 | } |
893 | 893 | |
894 | 894 | /** |
@@ -898,8 +898,8 @@ discard block |
||
898 | 898 | * @param string $context View or edit context. |
899 | 899 | * @return string |
900 | 900 | */ |
901 | - public function get_phone( $context = 'view' ) { |
|
902 | - return $this->get_prop( 'phone', $context ); |
|
901 | + public function get_phone($context = 'view') { |
|
902 | + return $this->get_prop('phone', $context); |
|
903 | 903 | } |
904 | 904 | |
905 | 905 | /** |
@@ -909,8 +909,8 @@ discard block |
||
909 | 909 | * @param string $context View or edit context. |
910 | 910 | * @return string |
911 | 911 | */ |
912 | - public function get_phone_number( $context = 'view' ) { |
|
913 | - return $this->get_phone( $context ); |
|
912 | + public function get_phone_number($context = 'view') { |
|
913 | + return $this->get_phone($context); |
|
914 | 914 | } |
915 | 915 | |
916 | 916 | /** |
@@ -920,8 +920,8 @@ discard block |
||
920 | 920 | * @param string $context View or edit context. |
921 | 921 | * @return string |
922 | 922 | */ |
923 | - public function get_user_phone( $context = 'view' ) { |
|
924 | - return $this->get_phone( $context ); |
|
923 | + public function get_user_phone($context = 'view') { |
|
924 | + return $this->get_phone($context); |
|
925 | 925 | } |
926 | 926 | |
927 | 927 | /** |
@@ -931,8 +931,8 @@ discard block |
||
931 | 931 | * @param string $context View or edit context. |
932 | 932 | * @return string |
933 | 933 | */ |
934 | - public function get_customer_phone( $context = 'view' ) { |
|
935 | - return $this->get_phone( $context ); |
|
934 | + public function get_customer_phone($context = 'view') { |
|
935 | + return $this->get_phone($context); |
|
936 | 936 | } |
937 | 937 | |
938 | 938 | /** |
@@ -942,8 +942,8 @@ discard block |
||
942 | 942 | * @param string $context View or edit context. |
943 | 943 | * @return string |
944 | 944 | */ |
945 | - public function get_email( $context = 'view' ) { |
|
946 | - return $this->get_prop( 'email', $context ); |
|
945 | + public function get_email($context = 'view') { |
|
946 | + return $this->get_prop('email', $context); |
|
947 | 947 | } |
948 | 948 | |
949 | 949 | /** |
@@ -953,8 +953,8 @@ discard block |
||
953 | 953 | * @param string $context View or edit context. |
954 | 954 | * @return string |
955 | 955 | */ |
956 | - public function get_email_address( $context = 'view' ) { |
|
957 | - return $this->get_email( $context ); |
|
956 | + public function get_email_address($context = 'view') { |
|
957 | + return $this->get_email($context); |
|
958 | 958 | } |
959 | 959 | |
960 | 960 | /** |
@@ -964,8 +964,8 @@ discard block |
||
964 | 964 | * @param string $context View or edit context. |
965 | 965 | * @return string |
966 | 966 | */ |
967 | - public function get_user_email( $context = 'view' ) { |
|
968 | - return $this->get_email( $context ); |
|
967 | + public function get_user_email($context = 'view') { |
|
968 | + return $this->get_email($context); |
|
969 | 969 | } |
970 | 970 | |
971 | 971 | /** |
@@ -975,8 +975,8 @@ discard block |
||
975 | 975 | * @param string $context View or edit context. |
976 | 976 | * @return string |
977 | 977 | */ |
978 | - public function get_customer_email( $context = 'view' ) { |
|
979 | - return $this->get_email( $context ); |
|
978 | + public function get_customer_email($context = 'view') { |
|
979 | + return $this->get_email($context); |
|
980 | 980 | } |
981 | 981 | |
982 | 982 | /** |
@@ -986,9 +986,9 @@ discard block |
||
986 | 986 | * @param string $context View or edit context. |
987 | 987 | * @return string |
988 | 988 | */ |
989 | - public function get_country( $context = 'view' ) { |
|
990 | - $country = $this->get_prop( 'country', $context ); |
|
991 | - return empty( $country ) ? wpinv_get_default_country() : $country; |
|
989 | + public function get_country($context = 'view') { |
|
990 | + $country = $this->get_prop('country', $context); |
|
991 | + return empty($country) ? wpinv_get_default_country() : $country; |
|
992 | 992 | } |
993 | 993 | |
994 | 994 | /** |
@@ -998,8 +998,8 @@ discard block |
||
998 | 998 | * @param string $context View or edit context. |
999 | 999 | * @return string |
1000 | 1000 | */ |
1001 | - public function get_user_country( $context = 'view' ) { |
|
1002 | - return $this->get_country( $context ); |
|
1001 | + public function get_user_country($context = 'view') { |
|
1002 | + return $this->get_country($context); |
|
1003 | 1003 | } |
1004 | 1004 | |
1005 | 1005 | /** |
@@ -1009,8 +1009,8 @@ discard block |
||
1009 | 1009 | * @param string $context View or edit context. |
1010 | 1010 | * @return string |
1011 | 1011 | */ |
1012 | - public function get_customer_country( $context = 'view' ) { |
|
1013 | - return $this->get_country( $context ); |
|
1012 | + public function get_customer_country($context = 'view') { |
|
1013 | + return $this->get_country($context); |
|
1014 | 1014 | } |
1015 | 1015 | |
1016 | 1016 | /** |
@@ -1020,9 +1020,9 @@ discard block |
||
1020 | 1020 | * @param string $context View or edit context. |
1021 | 1021 | * @return string |
1022 | 1022 | */ |
1023 | - public function get_state( $context = 'view' ) { |
|
1024 | - $state = $this->get_prop( 'state', $context ); |
|
1025 | - return empty( $state ) ? wpinv_get_default_state() : $state; |
|
1023 | + public function get_state($context = 'view') { |
|
1024 | + $state = $this->get_prop('state', $context); |
|
1025 | + return empty($state) ? wpinv_get_default_state() : $state; |
|
1026 | 1026 | } |
1027 | 1027 | |
1028 | 1028 | /** |
@@ -1032,8 +1032,8 @@ discard block |
||
1032 | 1032 | * @param string $context View or edit context. |
1033 | 1033 | * @return string |
1034 | 1034 | */ |
1035 | - public function get_user_state( $context = 'view' ) { |
|
1036 | - return $this->get_state( $context ); |
|
1035 | + public function get_user_state($context = 'view') { |
|
1036 | + return $this->get_state($context); |
|
1037 | 1037 | } |
1038 | 1038 | |
1039 | 1039 | /** |
@@ -1043,8 +1043,8 @@ discard block |
||
1043 | 1043 | * @param string $context View or edit context. |
1044 | 1044 | * @return string |
1045 | 1045 | */ |
1046 | - public function get_customer_state( $context = 'view' ) { |
|
1047 | - return $this->get_state( $context ); |
|
1046 | + public function get_customer_state($context = 'view') { |
|
1047 | + return $this->get_state($context); |
|
1048 | 1048 | } |
1049 | 1049 | |
1050 | 1050 | /** |
@@ -1054,8 +1054,8 @@ discard block |
||
1054 | 1054 | * @param string $context View or edit context. |
1055 | 1055 | * @return string |
1056 | 1056 | */ |
1057 | - public function get_city( $context = 'view' ) { |
|
1058 | - return $this->get_prop( 'city', $context ); |
|
1057 | + public function get_city($context = 'view') { |
|
1058 | + return $this->get_prop('city', $context); |
|
1059 | 1059 | } |
1060 | 1060 | |
1061 | 1061 | /** |
@@ -1065,8 +1065,8 @@ discard block |
||
1065 | 1065 | * @param string $context View or edit context. |
1066 | 1066 | * @return string |
1067 | 1067 | */ |
1068 | - public function get_user_city( $context = 'view' ) { |
|
1069 | - return $this->get_city( $context ); |
|
1068 | + public function get_user_city($context = 'view') { |
|
1069 | + return $this->get_city($context); |
|
1070 | 1070 | } |
1071 | 1071 | |
1072 | 1072 | /** |
@@ -1076,8 +1076,8 @@ discard block |
||
1076 | 1076 | * @param string $context View or edit context. |
1077 | 1077 | * @return string |
1078 | 1078 | */ |
1079 | - public function get_customer_city( $context = 'view' ) { |
|
1080 | - return $this->get_city( $context ); |
|
1079 | + public function get_customer_city($context = 'view') { |
|
1080 | + return $this->get_city($context); |
|
1081 | 1081 | } |
1082 | 1082 | |
1083 | 1083 | /** |
@@ -1087,8 +1087,8 @@ discard block |
||
1087 | 1087 | * @param string $context View or edit context. |
1088 | 1088 | * @return string |
1089 | 1089 | */ |
1090 | - public function get_zip( $context = 'view' ) { |
|
1091 | - return $this->get_prop( 'zip', $context ); |
|
1090 | + public function get_zip($context = 'view') { |
|
1091 | + return $this->get_prop('zip', $context); |
|
1092 | 1092 | } |
1093 | 1093 | |
1094 | 1094 | /** |
@@ -1098,8 +1098,8 @@ discard block |
||
1098 | 1098 | * @param string $context View or edit context. |
1099 | 1099 | * @return string |
1100 | 1100 | */ |
1101 | - public function get_user_zip( $context = 'view' ) { |
|
1102 | - return $this->get_zip( $context ); |
|
1101 | + public function get_user_zip($context = 'view') { |
|
1102 | + return $this->get_zip($context); |
|
1103 | 1103 | } |
1104 | 1104 | |
1105 | 1105 | /** |
@@ -1109,8 +1109,8 @@ discard block |
||
1109 | 1109 | * @param string $context View or edit context. |
1110 | 1110 | * @return string |
1111 | 1111 | */ |
1112 | - public function get_customer_zip( $context = 'view' ) { |
|
1113 | - return $this->get_zip( $context ); |
|
1112 | + public function get_customer_zip($context = 'view') { |
|
1113 | + return $this->get_zip($context); |
|
1114 | 1114 | } |
1115 | 1115 | |
1116 | 1116 | /** |
@@ -1120,8 +1120,8 @@ discard block |
||
1120 | 1120 | * @param string $context View or edit context. |
1121 | 1121 | * @return string |
1122 | 1122 | */ |
1123 | - public function get_company( $context = 'view' ) { |
|
1124 | - return $this->get_prop( 'company', $context ); |
|
1123 | + public function get_company($context = 'view') { |
|
1124 | + return $this->get_prop('company', $context); |
|
1125 | 1125 | } |
1126 | 1126 | |
1127 | 1127 | /** |
@@ -1131,8 +1131,8 @@ discard block |
||
1131 | 1131 | * @param string $context View or edit context. |
1132 | 1132 | * @return string |
1133 | 1133 | */ |
1134 | - public function get_user_company( $context = 'view' ) { |
|
1135 | - return $this->get_company( $context ); |
|
1134 | + public function get_user_company($context = 'view') { |
|
1135 | + return $this->get_company($context); |
|
1136 | 1136 | } |
1137 | 1137 | |
1138 | 1138 | /** |
@@ -1142,8 +1142,8 @@ discard block |
||
1142 | 1142 | * @param string $context View or edit context. |
1143 | 1143 | * @return string |
1144 | 1144 | */ |
1145 | - public function get_customer_company( $context = 'view' ) { |
|
1146 | - return $this->get_company( $context ); |
|
1145 | + public function get_customer_company($context = 'view') { |
|
1146 | + return $this->get_company($context); |
|
1147 | 1147 | } |
1148 | 1148 | |
1149 | 1149 | /** |
@@ -1153,8 +1153,8 @@ discard block |
||
1153 | 1153 | * @param string $context View or edit context. |
1154 | 1154 | * @return string |
1155 | 1155 | */ |
1156 | - public function get_vat_number( $context = 'view' ) { |
|
1157 | - return $this->get_prop( 'vat_number', $context ); |
|
1156 | + public function get_vat_number($context = 'view') { |
|
1157 | + return $this->get_prop('vat_number', $context); |
|
1158 | 1158 | } |
1159 | 1159 | |
1160 | 1160 | /** |
@@ -1164,8 +1164,8 @@ discard block |
||
1164 | 1164 | * @param string $context View or edit context. |
1165 | 1165 | * @return string |
1166 | 1166 | */ |
1167 | - public function get_user_vat_number( $context = 'view' ) { |
|
1168 | - return $this->get_vat_number( $context ); |
|
1167 | + public function get_user_vat_number($context = 'view') { |
|
1168 | + return $this->get_vat_number($context); |
|
1169 | 1169 | } |
1170 | 1170 | |
1171 | 1171 | /** |
@@ -1175,8 +1175,8 @@ discard block |
||
1175 | 1175 | * @param string $context View or edit context. |
1176 | 1176 | * @return string |
1177 | 1177 | */ |
1178 | - public function get_customer_vat_number( $context = 'view' ) { |
|
1179 | - return $this->get_vat_number( $context ); |
|
1178 | + public function get_customer_vat_number($context = 'view') { |
|
1179 | + return $this->get_vat_number($context); |
|
1180 | 1180 | } |
1181 | 1181 | |
1182 | 1182 | /** |
@@ -1186,8 +1186,8 @@ discard block |
||
1186 | 1186 | * @param string $context View or edit context. |
1187 | 1187 | * @return string |
1188 | 1188 | */ |
1189 | - public function get_vat_rate( $context = 'view' ) { |
|
1190 | - return $this->get_prop( 'vat_rate', $context ); |
|
1189 | + public function get_vat_rate($context = 'view') { |
|
1190 | + return $this->get_prop('vat_rate', $context); |
|
1191 | 1191 | } |
1192 | 1192 | |
1193 | 1193 | /** |
@@ -1197,8 +1197,8 @@ discard block |
||
1197 | 1197 | * @param string $context View or edit context. |
1198 | 1198 | * @return string |
1199 | 1199 | */ |
1200 | - public function get_user_vat_rate( $context = 'view' ) { |
|
1201 | - return $this->get_vat_rate( $context ); |
|
1200 | + public function get_user_vat_rate($context = 'view') { |
|
1201 | + return $this->get_vat_rate($context); |
|
1202 | 1202 | } |
1203 | 1203 | |
1204 | 1204 | /** |
@@ -1208,8 +1208,8 @@ discard block |
||
1208 | 1208 | * @param string $context View or edit context. |
1209 | 1209 | * @return string |
1210 | 1210 | */ |
1211 | - public function get_customer_vat_rate( $context = 'view' ) { |
|
1212 | - return $this->get_vat_rate( $context ); |
|
1211 | + public function get_customer_vat_rate($context = 'view') { |
|
1212 | + return $this->get_vat_rate($context); |
|
1213 | 1213 | } |
1214 | 1214 | |
1215 | 1215 | /** |
@@ -1219,8 +1219,8 @@ discard block |
||
1219 | 1219 | * @param string $context View or edit context. |
1220 | 1220 | * @return string |
1221 | 1221 | */ |
1222 | - public function get_address( $context = 'view' ) { |
|
1223 | - return $this->get_prop( 'address', $context ); |
|
1222 | + public function get_address($context = 'view') { |
|
1223 | + return $this->get_prop('address', $context); |
|
1224 | 1224 | } |
1225 | 1225 | |
1226 | 1226 | /** |
@@ -1230,8 +1230,8 @@ discard block |
||
1230 | 1230 | * @param string $context View or edit context. |
1231 | 1231 | * @return string |
1232 | 1232 | */ |
1233 | - public function get_user_address( $context = 'view' ) { |
|
1234 | - return $this->get_address( $context ); |
|
1233 | + public function get_user_address($context = 'view') { |
|
1234 | + return $this->get_address($context); |
|
1235 | 1235 | } |
1236 | 1236 | |
1237 | 1237 | /** |
@@ -1241,8 +1241,8 @@ discard block |
||
1241 | 1241 | * @param string $context View or edit context. |
1242 | 1242 | * @return string |
1243 | 1243 | */ |
1244 | - public function get_customer_address( $context = 'view' ) { |
|
1245 | - return $this->get_address( $context ); |
|
1244 | + public function get_customer_address($context = 'view') { |
|
1245 | + return $this->get_address($context); |
|
1246 | 1246 | } |
1247 | 1247 | |
1248 | 1248 | /** |
@@ -1252,8 +1252,8 @@ discard block |
||
1252 | 1252 | * @param string $context View or edit context. |
1253 | 1253 | * @return bool |
1254 | 1254 | */ |
1255 | - public function get_is_viewed( $context = 'view' ) { |
|
1256 | - return (bool) $this->get_prop( 'is_viewed', $context ); |
|
1255 | + public function get_is_viewed($context = 'view') { |
|
1256 | + return (bool) $this->get_prop('is_viewed', $context); |
|
1257 | 1257 | } |
1258 | 1258 | |
1259 | 1259 | /** |
@@ -1263,8 +1263,8 @@ discard block |
||
1263 | 1263 | * @param string $context View or edit context. |
1264 | 1264 | * @return bool |
1265 | 1265 | */ |
1266 | - public function get_email_cc( $context = 'view' ) { |
|
1267 | - return $this->get_prop( 'email_cc', $context ); |
|
1266 | + public function get_email_cc($context = 'view') { |
|
1267 | + return $this->get_prop('email_cc', $context); |
|
1268 | 1268 | } |
1269 | 1269 | |
1270 | 1270 | /** |
@@ -1274,8 +1274,8 @@ discard block |
||
1274 | 1274 | * @param string $context View or edit context. |
1275 | 1275 | * @return bool |
1276 | 1276 | */ |
1277 | - public function get_template( $context = 'view' ) { |
|
1278 | - return $this->get_prop( 'template', $context ); |
|
1277 | + public function get_template($context = 'view') { |
|
1278 | + return $this->get_prop('template', $context); |
|
1279 | 1279 | } |
1280 | 1280 | |
1281 | 1281 | /** |
@@ -1285,8 +1285,8 @@ discard block |
||
1285 | 1285 | * @param string $context View or edit context. |
1286 | 1286 | * @return bool |
1287 | 1287 | */ |
1288 | - public function get_created_via( $context = 'view' ) { |
|
1289 | - return $this->get_prop( 'created_via', $context ); |
|
1288 | + public function get_created_via($context = 'view') { |
|
1289 | + return $this->get_prop('created_via', $context); |
|
1290 | 1290 | } |
1291 | 1291 | |
1292 | 1292 | /** |
@@ -1296,8 +1296,8 @@ discard block |
||
1296 | 1296 | * @param string $context View or edit context. |
1297 | 1297 | * @return bool |
1298 | 1298 | */ |
1299 | - public function get_address_confirmed( $context = 'view' ) { |
|
1300 | - return (bool) $this->get_prop( 'address_confirmed', $context ); |
|
1299 | + public function get_address_confirmed($context = 'view') { |
|
1300 | + return (bool) $this->get_prop('address_confirmed', $context); |
|
1301 | 1301 | } |
1302 | 1302 | |
1303 | 1303 | /** |
@@ -1307,8 +1307,8 @@ discard block |
||
1307 | 1307 | * @param string $context View or edit context. |
1308 | 1308 | * @return bool |
1309 | 1309 | */ |
1310 | - public function get_user_address_confirmed( $context = 'view' ) { |
|
1311 | - return $this->get_address_confirmed( $context ); |
|
1310 | + public function get_user_address_confirmed($context = 'view') { |
|
1311 | + return $this->get_address_confirmed($context); |
|
1312 | 1312 | } |
1313 | 1313 | |
1314 | 1314 | /** |
@@ -1318,8 +1318,8 @@ discard block |
||
1318 | 1318 | * @param string $context View or edit context. |
1319 | 1319 | * @return bool |
1320 | 1320 | */ |
1321 | - public function get_customer_address_confirmed( $context = 'view' ) { |
|
1322 | - return $this->get_address_confirmed( $context ); |
|
1321 | + public function get_customer_address_confirmed($context = 'view') { |
|
1322 | + return $this->get_address_confirmed($context); |
|
1323 | 1323 | } |
1324 | 1324 | |
1325 | 1325 | /** |
@@ -1329,12 +1329,12 @@ discard block |
||
1329 | 1329 | * @param string $context View or edit context. |
1330 | 1330 | * @return float |
1331 | 1331 | */ |
1332 | - public function get_subtotal( $context = 'view' ) { |
|
1333 | - $subtotal = (float) $this->get_prop( 'subtotal', $context ); |
|
1332 | + public function get_subtotal($context = 'view') { |
|
1333 | + $subtotal = (float) $this->get_prop('subtotal', $context); |
|
1334 | 1334 | |
1335 | 1335 | // Backwards compatibility. |
1336 | - if ( is_bool( $context ) && $context ) { |
|
1337 | - return wpinv_price( wpinv_format_amount( $subtotal ), $this->get_currency() ); |
|
1336 | + if (is_bool($context) && $context) { |
|
1337 | + return wpinv_price(wpinv_format_amount($subtotal), $this->get_currency()); |
|
1338 | 1338 | } |
1339 | 1339 | |
1340 | 1340 | return $subtotal; |
@@ -1347,8 +1347,8 @@ discard block |
||
1347 | 1347 | * @param string $context View or edit context. |
1348 | 1348 | * @return float |
1349 | 1349 | */ |
1350 | - public function get_total_discount( $context = 'view' ) { |
|
1351 | - return (float) $this->get_prop( 'total_discount', $context ); |
|
1350 | + public function get_total_discount($context = 'view') { |
|
1351 | + return (float) $this->get_prop('total_discount', $context); |
|
1352 | 1352 | } |
1353 | 1353 | |
1354 | 1354 | /** |
@@ -1358,18 +1358,18 @@ discard block |
||
1358 | 1358 | * @param string $context View or edit context. |
1359 | 1359 | * @return float |
1360 | 1360 | */ |
1361 | - public function get_total_tax( $context = 'view' ) { |
|
1362 | - return (float) $this->get_prop( 'total_tax', $context ); |
|
1361 | + public function get_total_tax($context = 'view') { |
|
1362 | + return (float) $this->get_prop('total_tax', $context); |
|
1363 | 1363 | } |
1364 | 1364 | |
1365 | 1365 | /** |
1366 | 1366 | * @deprecated |
1367 | 1367 | */ |
1368 | - public function get_final_tax( $currency = false ) { |
|
1368 | + public function get_final_tax($currency = false) { |
|
1369 | 1369 | $tax = $this->get_total_tax(); |
1370 | 1370 | |
1371 | - if ( $currency ) { |
|
1372 | - return wpinv_price( $tax, $this->get_currency() ); |
|
1371 | + if ($currency) { |
|
1372 | + return wpinv_price($tax, $this->get_currency()); |
|
1373 | 1373 | } |
1374 | 1374 | |
1375 | 1375 | return $tax; |
@@ -1382,8 +1382,8 @@ discard block |
||
1382 | 1382 | * @param string $context View or edit context. |
1383 | 1383 | * @return float |
1384 | 1384 | */ |
1385 | - public function get_total_fees( $context = 'view' ) { |
|
1386 | - return (float) $this->get_prop( 'total_fees', $context ); |
|
1385 | + public function get_total_fees($context = 'view') { |
|
1386 | + return (float) $this->get_prop('total_fees', $context); |
|
1387 | 1387 | } |
1388 | 1388 | |
1389 | 1389 | /** |
@@ -1393,8 +1393,8 @@ discard block |
||
1393 | 1393 | * @param string $context View or edit context. |
1394 | 1394 | * @return float |
1395 | 1395 | */ |
1396 | - public function get_fees_total( $context = 'view' ) { |
|
1397 | - return $this->get_total_fees( $context ); |
|
1396 | + public function get_fees_total($context = 'view') { |
|
1397 | + return $this->get_total_fees($context); |
|
1398 | 1398 | } |
1399 | 1399 | |
1400 | 1400 | /** |
@@ -1405,7 +1405,7 @@ discard block |
||
1405 | 1405 | */ |
1406 | 1406 | public function get_total() { |
1407 | 1407 | $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total(); |
1408 | - return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this ); |
|
1408 | + return apply_filters('getpaid_get_invoice_total_amount', $total, $this); |
|
1409 | 1409 | } |
1410 | 1410 | |
1411 | 1411 | /** |
@@ -1427,7 +1427,7 @@ discard block |
||
1427 | 1427 | */ |
1428 | 1428 | public function get_initial_total() { |
1429 | 1429 | |
1430 | - if ( empty( $this->totals ) ) { |
|
1430 | + if (empty($this->totals)) { |
|
1431 | 1431 | $this->recalculate_total(); |
1432 | 1432 | } |
1433 | 1433 | |
@@ -1437,11 +1437,11 @@ discard block |
||
1437 | 1437 | $subtotal = $this->totals['subtotal']['initial']; |
1438 | 1438 | $total = $tax + $fee - $discount + $subtotal; |
1439 | 1439 | |
1440 | - if ( 0 > $total ) { |
|
1440 | + if (0 > $total) { |
|
1441 | 1441 | $total = 0; |
1442 | 1442 | } |
1443 | 1443 | |
1444 | - return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this ); |
|
1444 | + return apply_filters('wpinv_get_initial_invoice_total', $total, $this); |
|
1445 | 1445 | } |
1446 | 1446 | |
1447 | 1447 | /** |
@@ -1453,7 +1453,7 @@ discard block |
||
1453 | 1453 | */ |
1454 | 1454 | public function get_recurring_total() { |
1455 | 1455 | |
1456 | - if ( empty( $this->totals ) ) { |
|
1456 | + if (empty($this->totals)) { |
|
1457 | 1457 | $this->recalculate_total(); |
1458 | 1458 | } |
1459 | 1459 | |
@@ -1463,11 +1463,11 @@ discard block |
||
1463 | 1463 | $subtotal = $this->totals['subtotal']['recurring']; |
1464 | 1464 | $total = $tax + $fee - $discount + $subtotal; |
1465 | 1465 | |
1466 | - if ( 0 > $total ) { |
|
1466 | + if (0 > $total) { |
|
1467 | 1467 | $total = 0; |
1468 | 1468 | } |
1469 | 1469 | |
1470 | - return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this ); |
|
1470 | + return apply_filters('wpinv_get_recurring_invoice_total', $total, $this); |
|
1471 | 1471 | } |
1472 | 1472 | |
1473 | 1473 | /** |
@@ -1478,10 +1478,10 @@ discard block |
||
1478 | 1478 | * @param string $currency Whether to include the currency. |
1479 | 1479 | * @return float|string |
1480 | 1480 | */ |
1481 | - public function get_recurring_details( $field = '', $currency = false ) { |
|
1481 | + public function get_recurring_details($field = '', $currency = false) { |
|
1482 | 1482 | |
1483 | 1483 | // Maybe recalculate totals. |
1484 | - if ( empty( $this->totals ) ) { |
|
1484 | + if (empty($this->totals)) { |
|
1485 | 1485 | $this->recalculate_total(); |
1486 | 1486 | } |
1487 | 1487 | |
@@ -1501,8 +1501,8 @@ discard block |
||
1501 | 1501 | $currency |
1502 | 1502 | ); |
1503 | 1503 | |
1504 | - if ( isset( $data[$field] ) ) { |
|
1505 | - return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] ); |
|
1504 | + if (isset($data[$field])) { |
|
1505 | + return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]); |
|
1506 | 1506 | } |
1507 | 1507 | |
1508 | 1508 | return $data; |
@@ -1515,8 +1515,8 @@ discard block |
||
1515 | 1515 | * @param string $context View or edit context. |
1516 | 1516 | * @return array |
1517 | 1517 | */ |
1518 | - public function get_fees( $context = 'view' ) { |
|
1519 | - return wpinv_parse_list( $this->get_prop( 'fees', $context ) ); |
|
1518 | + public function get_fees($context = 'view') { |
|
1519 | + return wpinv_parse_list($this->get_prop('fees', $context)); |
|
1520 | 1520 | } |
1521 | 1521 | |
1522 | 1522 | /** |
@@ -1526,8 +1526,8 @@ discard block |
||
1526 | 1526 | * @param string $context View or edit context. |
1527 | 1527 | * @return array |
1528 | 1528 | */ |
1529 | - public function get_discounts( $context = 'view' ) { |
|
1530 | - return wpinv_parse_list( $this->get_prop( 'discounts', $context ) ); |
|
1529 | + public function get_discounts($context = 'view') { |
|
1530 | + return wpinv_parse_list($this->get_prop('discounts', $context)); |
|
1531 | 1531 | } |
1532 | 1532 | |
1533 | 1533 | /** |
@@ -1537,8 +1537,8 @@ discard block |
||
1537 | 1537 | * @param string $context View or edit context. |
1538 | 1538 | * @return array |
1539 | 1539 | */ |
1540 | - public function get_taxes( $context = 'view' ) { |
|
1541 | - return wpinv_parse_list( $this->get_prop( 'taxes', $context ) ); |
|
1540 | + public function get_taxes($context = 'view') { |
|
1541 | + return wpinv_parse_list($this->get_prop('taxes', $context)); |
|
1542 | 1542 | } |
1543 | 1543 | |
1544 | 1544 | /** |
@@ -1548,8 +1548,8 @@ discard block |
||
1548 | 1548 | * @param string $context View or edit context. |
1549 | 1549 | * @return GetPaid_Form_Item[] |
1550 | 1550 | */ |
1551 | - public function get_items( $context = 'view' ) { |
|
1552 | - return $this->get_prop( 'items', $context ); |
|
1551 | + public function get_items($context = 'view') { |
|
1552 | + return $this->get_prop('items', $context); |
|
1553 | 1553 | } |
1554 | 1554 | |
1555 | 1555 | /** |
@@ -1559,7 +1559,7 @@ discard block |
||
1559 | 1559 | * @return string |
1560 | 1560 | */ |
1561 | 1561 | public function get_item_ids() { |
1562 | - return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) ); |
|
1562 | + return implode(', ', wp_list_pluck($this->get_cart_details(), 'item_id')); |
|
1563 | 1563 | } |
1564 | 1564 | |
1565 | 1565 | /** |
@@ -1569,8 +1569,8 @@ discard block |
||
1569 | 1569 | * @param string $context View or edit context. |
1570 | 1570 | * @return int |
1571 | 1571 | */ |
1572 | - public function get_payment_form( $context = 'view' ) { |
|
1573 | - return intval( $this->get_prop( 'payment_form', $context ) ); |
|
1572 | + public function get_payment_form($context = 'view') { |
|
1573 | + return intval($this->get_prop('payment_form', $context)); |
|
1574 | 1574 | } |
1575 | 1575 | |
1576 | 1576 | /** |
@@ -1580,8 +1580,8 @@ discard block |
||
1580 | 1580 | * @param string $context View or edit context. |
1581 | 1581 | * @return string |
1582 | 1582 | */ |
1583 | - public function get_submission_id( $context = 'view' ) { |
|
1584 | - return $this->get_prop( 'submission_id', $context ); |
|
1583 | + public function get_submission_id($context = 'view') { |
|
1584 | + return $this->get_prop('submission_id', $context); |
|
1585 | 1585 | } |
1586 | 1586 | |
1587 | 1587 | /** |
@@ -1591,8 +1591,8 @@ discard block |
||
1591 | 1591 | * @param string $context View or edit context. |
1592 | 1592 | * @return string |
1593 | 1593 | */ |
1594 | - public function get_discount_code( $context = 'view' ) { |
|
1595 | - return $this->get_prop( 'discount_code', $context ); |
|
1594 | + public function get_discount_code($context = 'view') { |
|
1595 | + return $this->get_prop('discount_code', $context); |
|
1596 | 1596 | } |
1597 | 1597 | |
1598 | 1598 | /** |
@@ -1602,8 +1602,8 @@ discard block |
||
1602 | 1602 | * @param string $context View or edit context. |
1603 | 1603 | * @return string |
1604 | 1604 | */ |
1605 | - public function get_gateway( $context = 'view' ) { |
|
1606 | - return $this->get_prop( 'gateway', $context ); |
|
1605 | + public function get_gateway($context = 'view') { |
|
1606 | + return $this->get_prop('gateway', $context); |
|
1607 | 1607 | } |
1608 | 1608 | |
1609 | 1609 | /** |
@@ -1613,8 +1613,8 @@ discard block |
||
1613 | 1613 | * @return string |
1614 | 1614 | */ |
1615 | 1615 | public function get_gateway_title() { |
1616 | - $title = wpinv_get_gateway_checkout_label( $this->get_gateway() ); |
|
1617 | - return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this ); |
|
1616 | + $title = wpinv_get_gateway_checkout_label($this->get_gateway()); |
|
1617 | + return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this); |
|
1618 | 1618 | } |
1619 | 1619 | |
1620 | 1620 | /** |
@@ -1624,8 +1624,8 @@ discard block |
||
1624 | 1624 | * @param string $context View or edit context. |
1625 | 1625 | * @return string |
1626 | 1626 | */ |
1627 | - public function get_transaction_id( $context = 'view' ) { |
|
1628 | - return $this->get_prop( 'transaction_id', $context ); |
|
1627 | + public function get_transaction_id($context = 'view') { |
|
1628 | + return $this->get_prop('transaction_id', $context); |
|
1629 | 1629 | } |
1630 | 1630 | |
1631 | 1631 | /** |
@@ -1635,9 +1635,9 @@ discard block |
||
1635 | 1635 | * @param string $context View or edit context. |
1636 | 1636 | * @return string |
1637 | 1637 | */ |
1638 | - public function get_currency( $context = 'view' ) { |
|
1639 | - $currency = $this->get_prop( 'currency', $context ); |
|
1640 | - return empty( $currency ) ? wpinv_get_currency() : $currency; |
|
1638 | + public function get_currency($context = 'view') { |
|
1639 | + $currency = $this->get_prop('currency', $context); |
|
1640 | + return empty($currency) ? wpinv_get_currency() : $currency; |
|
1641 | 1641 | } |
1642 | 1642 | |
1643 | 1643 | /** |
@@ -1647,8 +1647,8 @@ discard block |
||
1647 | 1647 | * @param string $context View or edit context. |
1648 | 1648 | * @return bool |
1649 | 1649 | */ |
1650 | - public function get_disable_taxes( $context = 'view' ) { |
|
1651 | - return (bool) $this->get_prop( 'disable_taxes', $context ); |
|
1650 | + public function get_disable_taxes($context = 'view') { |
|
1651 | + return (bool) $this->get_prop('disable_taxes', $context); |
|
1652 | 1652 | } |
1653 | 1653 | |
1654 | 1654 | /** |
@@ -1658,8 +1658,8 @@ discard block |
||
1658 | 1658 | * @param string $context View or edit context. |
1659 | 1659 | * @return int |
1660 | 1660 | */ |
1661 | - public function get_subscription_id( $context = 'view' ) { |
|
1662 | - return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context ); |
|
1661 | + public function get_subscription_id($context = 'view') { |
|
1662 | + return $this->is_renewal() ? $this->get_parent()->get_subscription_id($context) : $this->get_prop('subscription_id', $context); |
|
1663 | 1663 | } |
1664 | 1664 | |
1665 | 1665 | /** |
@@ -1669,12 +1669,12 @@ discard block |
||
1669 | 1669 | * @param string $context View or edit context. |
1670 | 1670 | * @return int |
1671 | 1671 | */ |
1672 | - public function get_remote_subscription_id( $context = 'view' ) { |
|
1673 | - $subscription_id = $this->get_prop( 'remote_subscription_id', $context ); |
|
1672 | + public function get_remote_subscription_id($context = 'view') { |
|
1673 | + $subscription_id = $this->get_prop('remote_subscription_id', $context); |
|
1674 | 1674 | |
1675 | - if ( empty( $subscription_id ) && $this->is_renewal() ) { |
|
1675 | + if (empty($subscription_id) && $this->is_renewal()) { |
|
1676 | 1676 | $parent = $this->get_parent(); |
1677 | - return $parent->get_subscription_id( $context ); |
|
1677 | + return $parent->get_subscription_id($context); |
|
1678 | 1678 | } |
1679 | 1679 | |
1680 | 1680 | return $subscription_id; |
@@ -1687,20 +1687,20 @@ discard block |
||
1687 | 1687 | * @param string $context View or edit context. |
1688 | 1688 | * @return array |
1689 | 1689 | */ |
1690 | - public function get_payment_meta( $context = 'view' ) { |
|
1690 | + public function get_payment_meta($context = 'view') { |
|
1691 | 1691 | |
1692 | 1692 | return array( |
1693 | - 'price' => $this->get_total( $context ), |
|
1694 | - 'date' => $this->get_date_created( $context ), |
|
1695 | - 'user_email' => $this->get_email( $context ), |
|
1696 | - 'invoice_key' => $this->get_key( $context ), |
|
1697 | - 'currency' => $this->get_currency( $context ), |
|
1698 | - 'items' => $this->get_items( $context ), |
|
1699 | - 'user_info' => $this->get_user_info( $context ), |
|
1693 | + 'price' => $this->get_total($context), |
|
1694 | + 'date' => $this->get_date_created($context), |
|
1695 | + 'user_email' => $this->get_email($context), |
|
1696 | + 'invoice_key' => $this->get_key($context), |
|
1697 | + 'currency' => $this->get_currency($context), |
|
1698 | + 'items' => $this->get_items($context), |
|
1699 | + 'user_info' => $this->get_user_info($context), |
|
1700 | 1700 | 'cart_details' => $this->get_cart_details(), |
1701 | - 'status' => $this->get_status( $context ), |
|
1702 | - 'fees' => $this->get_fees( $context ), |
|
1703 | - 'taxes' => $this->get_taxes( $context ), |
|
1701 | + 'status' => $this->get_status($context), |
|
1702 | + 'fees' => $this->get_fees($context), |
|
1703 | + 'taxes' => $this->get_taxes($context), |
|
1704 | 1704 | ); |
1705 | 1705 | |
1706 | 1706 | } |
@@ -1715,9 +1715,9 @@ discard block |
||
1715 | 1715 | $items = $this->get_items(); |
1716 | 1716 | $cart_details = array(); |
1717 | 1717 | |
1718 | - foreach ( $items as $item ) { |
|
1718 | + foreach ($items as $item) { |
|
1719 | 1719 | $item->invoice_id = $this->get_id(); |
1720 | - $cart_details[] = $item->prepare_data_for_saving(); |
|
1720 | + $cart_details[] = $item->prepare_data_for_saving(); |
|
1721 | 1721 | } |
1722 | 1722 | |
1723 | 1723 | return $cart_details; |
@@ -1728,11 +1728,11 @@ discard block |
||
1728 | 1728 | * |
1729 | 1729 | * @return null|GetPaid_Form_Item|int |
1730 | 1730 | */ |
1731 | - public function get_recurring( $object = false ) { |
|
1731 | + public function get_recurring($object = false) { |
|
1732 | 1732 | |
1733 | 1733 | // Are we returning an object? |
1734 | - if ( $object ) { |
|
1735 | - return $this->get_item( $this->recurring_item ); |
|
1734 | + if ($object) { |
|
1735 | + return $this->get_item($this->recurring_item); |
|
1736 | 1736 | } |
1737 | 1737 | |
1738 | 1738 | return $this->recurring_item; |
@@ -1747,15 +1747,15 @@ discard block |
||
1747 | 1747 | public function get_subscription_name() { |
1748 | 1748 | |
1749 | 1749 | // Retrieve the recurring name |
1750 | - $item = $this->get_recurring( true ); |
|
1750 | + $item = $this->get_recurring(true); |
|
1751 | 1751 | |
1752 | 1752 | // Abort if it does not exist. |
1753 | - if ( empty( $item ) ) { |
|
1753 | + if (empty($item)) { |
|
1754 | 1754 | return ''; |
1755 | 1755 | } |
1756 | 1756 | |
1757 | 1757 | // Return the item name. |
1758 | - return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this ); |
|
1758 | + return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this); |
|
1759 | 1759 | } |
1760 | 1760 | |
1761 | 1761 | /** |
@@ -1765,9 +1765,9 @@ discard block |
||
1765 | 1765 | * @return string |
1766 | 1766 | */ |
1767 | 1767 | public function get_view_url() { |
1768 | - $invoice_url = get_permalink( $this->get_id() ); |
|
1769 | - $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
1770 | - return apply_filters( 'wpinv_get_view_url', $invoice_url, $this ); |
|
1768 | + $invoice_url = get_permalink($this->get_id()); |
|
1769 | + $invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url); |
|
1770 | + return apply_filters('wpinv_get_view_url', $invoice_url, $this); |
|
1771 | 1771 | } |
1772 | 1772 | |
1773 | 1773 | /** |
@@ -1776,25 +1776,25 @@ discard block |
||
1776 | 1776 | * @since 1.0.19 |
1777 | 1777 | * @return string |
1778 | 1778 | */ |
1779 | - public function get_checkout_payment_url( $deprecated = false, $secret = false ) { |
|
1779 | + public function get_checkout_payment_url($deprecated = false, $secret = false) { |
|
1780 | 1780 | |
1781 | 1781 | // Retrieve the checkout url. |
1782 | 1782 | $pay_url = wpinv_get_checkout_uri(); |
1783 | 1783 | |
1784 | 1784 | // Maybe force ssl. |
1785 | - if ( is_ssl() ) { |
|
1786 | - $pay_url = str_replace( 'http:', 'https:', $pay_url ); |
|
1785 | + if (is_ssl()) { |
|
1786 | + $pay_url = str_replace('http:', 'https:', $pay_url); |
|
1787 | 1787 | } |
1788 | 1788 | |
1789 | 1789 | // Add the invoice key. |
1790 | - $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url ); |
|
1790 | + $pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url); |
|
1791 | 1791 | |
1792 | 1792 | // (Maybe?) add a secret |
1793 | - if ( $secret ) { |
|
1794 | - $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url ); |
|
1793 | + if ($secret) { |
|
1794 | + $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url); |
|
1795 | 1795 | } |
1796 | 1796 | |
1797 | - return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret ); |
|
1797 | + return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret); |
|
1798 | 1798 | } |
1799 | 1799 | |
1800 | 1800 | /** |
@@ -1809,14 +1809,14 @@ discard block |
||
1809 | 1809 | $receipt_url = wpinv_get_success_page_uri(); |
1810 | 1810 | |
1811 | 1811 | // Maybe force ssl. |
1812 | - if ( is_ssl() ) { |
|
1813 | - $receipt_url = str_replace( 'http:', 'https:', $receipt_url ); |
|
1812 | + if (is_ssl()) { |
|
1813 | + $receipt_url = str_replace('http:', 'https:', $receipt_url); |
|
1814 | 1814 | } |
1815 | 1815 | |
1816 | 1816 | // Add the invoice key. |
1817 | - $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url ); |
|
1817 | + $receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url); |
|
1818 | 1818 | |
1819 | - return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this ); |
|
1819 | + return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this); |
|
1820 | 1820 | } |
1821 | 1821 | |
1822 | 1822 | /** |
@@ -1829,7 +1829,7 @@ discard block |
||
1829 | 1829 | |
1830 | 1830 | $type = $this->get_type(); |
1831 | 1831 | $status = "wpi-$type-pending"; |
1832 | - return str_replace( '-invoice', '', $status ); |
|
1832 | + return str_replace('-invoice', '', $status); |
|
1833 | 1833 | |
1834 | 1834 | } |
1835 | 1835 | |
@@ -1843,8 +1843,8 @@ discard block |
||
1843 | 1843 | * @param string $context View or edit context. |
1844 | 1844 | * @return mixed Value of the given invoice property (if set). |
1845 | 1845 | */ |
1846 | - public function get( $key, $context = 'view' ) { |
|
1847 | - return $this->get_prop( $key, $context ); |
|
1846 | + public function get($key, $context = 'view') { |
|
1847 | + return $this->get_prop($key, $context); |
|
1848 | 1848 | } |
1849 | 1849 | |
1850 | 1850 | /* |
@@ -1867,11 +1867,11 @@ discard block |
||
1867 | 1867 | * @param mixed $value new value. |
1868 | 1868 | * @return mixed Value of the given invoice property (if set). |
1869 | 1869 | */ |
1870 | - public function set( $key, $value ) { |
|
1870 | + public function set($key, $value) { |
|
1871 | 1871 | |
1872 | 1872 | $setter = "set_$key"; |
1873 | - if ( is_callable( array( $this, $setter ) ) ) { |
|
1874 | - $this->{$setter}( $value ); |
|
1873 | + if (is_callable(array($this, $setter))) { |
|
1874 | + $this->{$setter}($value); |
|
1875 | 1875 | } |
1876 | 1876 | |
1877 | 1877 | } |
@@ -1885,47 +1885,47 @@ discard block |
||
1885 | 1885 | * @param bool $manual_update Is this a manual status change?. |
1886 | 1886 | * @return array details of change. |
1887 | 1887 | */ |
1888 | - public function set_status( $new_status, $note = '', $manual_update = false ) { |
|
1888 | + public function set_status($new_status, $note = '', $manual_update = false) { |
|
1889 | 1889 | $old_status = $this->get_status(); |
1890 | 1890 | |
1891 | 1891 | $statuses = $this->get_all_statuses(); |
1892 | 1892 | |
1893 | - if ( isset( $statuses[ 'draft' ] ) ) { |
|
1894 | - unset( $statuses[ 'draft' ] ); |
|
1893 | + if (isset($statuses['draft'])) { |
|
1894 | + unset($statuses['draft']); |
|
1895 | 1895 | } |
1896 | 1896 | |
1897 | - $this->set_prop( 'status', $new_status ); |
|
1897 | + $this->set_prop('status', $new_status); |
|
1898 | 1898 | |
1899 | 1899 | // If setting the status, ensure it's set to a valid status. |
1900 | - if ( true === $this->object_read ) { |
|
1900 | + if (true === $this->object_read) { |
|
1901 | 1901 | |
1902 | 1902 | // Only allow valid new status. |
1903 | - if ( ! array_key_exists( $new_status, $statuses ) ) { |
|
1903 | + if (!array_key_exists($new_status, $statuses)) { |
|
1904 | 1904 | $new_status = $this->get_default_status(); |
1905 | 1905 | } |
1906 | 1906 | |
1907 | 1907 | // If the old status is set but unknown (e.g. draft) assume its pending for action usage. |
1908 | - if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) { |
|
1908 | + if ($old_status && !array_key_exists($new_status, $statuses)) { |
|
1909 | 1909 | $old_status = $this->get_default_status(); |
1910 | 1910 | } |
1911 | 1911 | |
1912 | 1912 | // Paid - Renewal (i.e when duplicating a parent invoice ) |
1913 | - if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) { |
|
1913 | + if ($new_status == 'wpi-pending' && $old_status == 'publish' && !$this->get_id()) { |
|
1914 | 1914 | $old_status = 'wpi-pending'; |
1915 | 1915 | } |
1916 | 1916 | |
1917 | 1917 | } |
1918 | 1918 | |
1919 | - if ( true === $this->object_read && $old_status !== $new_status ) { |
|
1919 | + if (true === $this->object_read && $old_status !== $new_status) { |
|
1920 | 1920 | $this->status_transition = array( |
1921 | - 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
1921 | + 'from' => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status, |
|
1922 | 1922 | 'to' => $new_status, |
1923 | 1923 | 'note' => $note, |
1924 | 1924 | 'manual' => (bool) $manual_update, |
1925 | 1925 | ); |
1926 | 1926 | |
1927 | - if ( $manual_update ) { |
|
1928 | - do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status ); |
|
1927 | + if ($manual_update) { |
|
1928 | + do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status); |
|
1929 | 1929 | } |
1930 | 1930 | |
1931 | 1931 | $this->maybe_set_date_paid(); |
@@ -1948,8 +1948,8 @@ discard block |
||
1948 | 1948 | */ |
1949 | 1949 | public function maybe_set_date_paid() { |
1950 | 1950 | |
1951 | - if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) { |
|
1952 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
1951 | + if (!$this->get_date_completed('edit') && $this->is_paid()) { |
|
1952 | + $this->set_date_completed(current_time('mysql')); |
|
1953 | 1953 | } |
1954 | 1954 | } |
1955 | 1955 | |
@@ -1958,11 +1958,11 @@ discard block |
||
1958 | 1958 | * |
1959 | 1959 | * @since 1.0.19 |
1960 | 1960 | */ |
1961 | - public function set_parent_id( $value ) { |
|
1962 | - if ( $value && ( $value === $this->get_id() ) ) { |
|
1961 | + public function set_parent_id($value) { |
|
1962 | + if ($value && ($value === $this->get_id())) { |
|
1963 | 1963 | return; |
1964 | 1964 | } |
1965 | - $this->set_prop( 'parent_id', absint( $value ) ); |
|
1965 | + $this->set_prop('parent_id', absint($value)); |
|
1966 | 1966 | } |
1967 | 1967 | |
1968 | 1968 | /** |
@@ -1970,8 +1970,8 @@ discard block |
||
1970 | 1970 | * |
1971 | 1971 | * @since 1.0.19 |
1972 | 1972 | */ |
1973 | - public function set_version( $value ) { |
|
1974 | - $this->set_prop( 'version', $value ); |
|
1973 | + public function set_version($value) { |
|
1974 | + $this->set_prop('version', $value); |
|
1975 | 1975 | } |
1976 | 1976 | |
1977 | 1977 | /** |
@@ -1981,15 +1981,15 @@ discard block |
||
1981 | 1981 | * @param string $value Value to set. |
1982 | 1982 | * @return bool Whether or not the date was set. |
1983 | 1983 | */ |
1984 | - public function set_date_created( $value ) { |
|
1985 | - $date = strtotime( $value ); |
|
1984 | + public function set_date_created($value) { |
|
1985 | + $date = strtotime($value); |
|
1986 | 1986 | |
1987 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
1988 | - $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) ); |
|
1987 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
1988 | + $this->set_prop('date_created', date('Y-m-d H:i:s', $date)); |
|
1989 | 1989 | return true; |
1990 | 1990 | } |
1991 | 1991 | |
1992 | - $this->set_prop( 'date_created', '' ); |
|
1992 | + $this->set_prop('date_created', ''); |
|
1993 | 1993 | return false; |
1994 | 1994 | |
1995 | 1995 | } |
@@ -2001,15 +2001,15 @@ discard block |
||
2001 | 2001 | * @param string $value Value to set. |
2002 | 2002 | * @return bool Whether or not the date was set. |
2003 | 2003 | */ |
2004 | - public function set_due_date( $value ) { |
|
2005 | - $date = strtotime( $value ); |
|
2004 | + public function set_due_date($value) { |
|
2005 | + $date = strtotime($value); |
|
2006 | 2006 | |
2007 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
2008 | - $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) ); |
|
2007 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
2008 | + $this->set_prop('due_date', date('Y-m-d H:i:s', $date)); |
|
2009 | 2009 | return true; |
2010 | 2010 | } |
2011 | 2011 | |
2012 | - $this->set_prop( 'due_date', '' ); |
|
2012 | + $this->set_prop('due_date', ''); |
|
2013 | 2013 | return false; |
2014 | 2014 | |
2015 | 2015 | } |
@@ -2020,8 +2020,8 @@ discard block |
||
2020 | 2020 | * @since 1.0.19 |
2021 | 2021 | * @param string $value New name. |
2022 | 2022 | */ |
2023 | - public function set_date_due( $value ) { |
|
2024 | - $this->set_due_date( $value ); |
|
2023 | + public function set_date_due($value) { |
|
2024 | + $this->set_due_date($value); |
|
2025 | 2025 | } |
2026 | 2026 | |
2027 | 2027 | /** |
@@ -2031,15 +2031,15 @@ discard block |
||
2031 | 2031 | * @param string $value Value to set. |
2032 | 2032 | * @return bool Whether or not the date was set. |
2033 | 2033 | */ |
2034 | - public function set_completed_date( $value ) { |
|
2035 | - $date = strtotime( $value ); |
|
2034 | + public function set_completed_date($value) { |
|
2035 | + $date = strtotime($value); |
|
2036 | 2036 | |
2037 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
2038 | - $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) ); |
|
2037 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
2038 | + $this->set_prop('completed_date', date('Y-m-d H:i:s', $date)); |
|
2039 | 2039 | return true; |
2040 | 2040 | } |
2041 | 2041 | |
2042 | - $this->set_prop( 'completed_date', '' ); |
|
2042 | + $this->set_prop('completed_date', ''); |
|
2043 | 2043 | return false; |
2044 | 2044 | |
2045 | 2045 | } |
@@ -2050,8 +2050,8 @@ discard block |
||
2050 | 2050 | * @since 1.0.19 |
2051 | 2051 | * @param string $value New name. |
2052 | 2052 | */ |
2053 | - public function set_date_completed( $value ) { |
|
2054 | - $this->set_completed_date( $value ); |
|
2053 | + public function set_date_completed($value) { |
|
2054 | + $this->set_completed_date($value); |
|
2055 | 2055 | } |
2056 | 2056 | |
2057 | 2057 | /** |
@@ -2061,15 +2061,15 @@ discard block |
||
2061 | 2061 | * @param string $value Value to set. |
2062 | 2062 | * @return bool Whether or not the date was set. |
2063 | 2063 | */ |
2064 | - public function set_date_modified( $value ) { |
|
2065 | - $date = strtotime( $value ); |
|
2064 | + public function set_date_modified($value) { |
|
2065 | + $date = strtotime($value); |
|
2066 | 2066 | |
2067 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
2068 | - $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) ); |
|
2067 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
2068 | + $this->set_prop('date_modified', date('Y-m-d H:i:s', $date)); |
|
2069 | 2069 | return true; |
2070 | 2070 | } |
2071 | 2071 | |
2072 | - $this->set_prop( 'date_modified', '' ); |
|
2072 | + $this->set_prop('date_modified', ''); |
|
2073 | 2073 | return false; |
2074 | 2074 | |
2075 | 2075 | } |
@@ -2080,9 +2080,9 @@ discard block |
||
2080 | 2080 | * @since 1.0.19 |
2081 | 2081 | * @param string $value New number. |
2082 | 2082 | */ |
2083 | - public function set_number( $value ) { |
|
2084 | - $number = sanitize_text_field( $value ); |
|
2085 | - $this->set_prop( 'number', $number ); |
|
2083 | + public function set_number($value) { |
|
2084 | + $number = sanitize_text_field($value); |
|
2085 | + $this->set_prop('number', $number); |
|
2086 | 2086 | } |
2087 | 2087 | |
2088 | 2088 | /** |
@@ -2091,9 +2091,9 @@ discard block |
||
2091 | 2091 | * @since 1.0.19 |
2092 | 2092 | * @param string $value Type. |
2093 | 2093 | */ |
2094 | - public function set_type( $value ) { |
|
2095 | - $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) ); |
|
2096 | - $this->set_prop( 'type', $type ); |
|
2094 | + public function set_type($value) { |
|
2095 | + $type = sanitize_text_field(str_replace('wpi_', '', $value)); |
|
2096 | + $this->set_prop('type', $type); |
|
2097 | 2097 | } |
2098 | 2098 | |
2099 | 2099 | /** |
@@ -2102,10 +2102,10 @@ discard block |
||
2102 | 2102 | * @since 1.0.19 |
2103 | 2103 | * @param string $value Post type. |
2104 | 2104 | */ |
2105 | - public function set_post_type( $value ) { |
|
2106 | - if ( getpaid_is_invoice_post_type( $value ) ) { |
|
2107 | - $this->set_type( $value ); |
|
2108 | - $this->set_prop( 'post_type', $value ); |
|
2105 | + public function set_post_type($value) { |
|
2106 | + if (getpaid_is_invoice_post_type($value)) { |
|
2107 | + $this->set_type($value); |
|
2108 | + $this->set_prop('post_type', $value); |
|
2109 | 2109 | } |
2110 | 2110 | } |
2111 | 2111 | |
@@ -2115,9 +2115,9 @@ discard block |
||
2115 | 2115 | * @since 1.0.19 |
2116 | 2116 | * @param string $value New key. |
2117 | 2117 | */ |
2118 | - public function set_key( $value ) { |
|
2119 | - $key = sanitize_text_field( $value ); |
|
2120 | - $this->set_prop( 'key', $key ); |
|
2118 | + public function set_key($value) { |
|
2119 | + $key = sanitize_text_field($value); |
|
2120 | + $this->set_prop('key', $key); |
|
2121 | 2121 | } |
2122 | 2122 | |
2123 | 2123 | /** |
@@ -2126,9 +2126,9 @@ discard block |
||
2126 | 2126 | * @since 1.0.19 |
2127 | 2127 | * @param string $value mode. |
2128 | 2128 | */ |
2129 | - public function set_mode( $value ) { |
|
2130 | - if ( ! in_array( $value, array( 'live', 'test' ) ) ) { |
|
2131 | - $this->set_prop( 'value', $value ); |
|
2129 | + public function set_mode($value) { |
|
2130 | + if (!in_array($value, array('live', 'test'))) { |
|
2131 | + $this->set_prop('value', $value); |
|
2132 | 2132 | } |
2133 | 2133 | } |
2134 | 2134 | |
@@ -2138,8 +2138,8 @@ discard block |
||
2138 | 2138 | * @since 1.0.19 |
2139 | 2139 | * @param string $value path. |
2140 | 2140 | */ |
2141 | - public function set_path( $value ) { |
|
2142 | - $this->set_prop( 'path', $value ); |
|
2141 | + public function set_path($value) { |
|
2142 | + $this->set_prop('path', $value); |
|
2143 | 2143 | } |
2144 | 2144 | |
2145 | 2145 | /** |
@@ -2148,9 +2148,9 @@ discard block |
||
2148 | 2148 | * @since 1.0.19 |
2149 | 2149 | * @param string $value New name. |
2150 | 2150 | */ |
2151 | - public function set_name( $value ) { |
|
2152 | - $name = sanitize_text_field( $value ); |
|
2153 | - $this->set_prop( 'name', $name ); |
|
2151 | + public function set_name($value) { |
|
2152 | + $name = sanitize_text_field($value); |
|
2153 | + $this->set_prop('name', $name); |
|
2154 | 2154 | } |
2155 | 2155 | |
2156 | 2156 | /** |
@@ -2159,8 +2159,8 @@ discard block |
||
2159 | 2159 | * @since 1.0.19 |
2160 | 2160 | * @param string $value New name. |
2161 | 2161 | */ |
2162 | - public function set_title( $value ) { |
|
2163 | - $this->set_name( $value ); |
|
2162 | + public function set_title($value) { |
|
2163 | + $this->set_name($value); |
|
2164 | 2164 | } |
2165 | 2165 | |
2166 | 2166 | /** |
@@ -2169,9 +2169,9 @@ discard block |
||
2169 | 2169 | * @since 1.0.19 |
2170 | 2170 | * @param string $value New description. |
2171 | 2171 | */ |
2172 | - public function set_description( $value ) { |
|
2173 | - $description = wp_kses_post( $value ); |
|
2174 | - $this->set_prop( 'description', $description ); |
|
2172 | + public function set_description($value) { |
|
2173 | + $description = wp_kses_post($value); |
|
2174 | + $this->set_prop('description', $description); |
|
2175 | 2175 | } |
2176 | 2176 | |
2177 | 2177 | /** |
@@ -2180,8 +2180,8 @@ discard block |
||
2180 | 2180 | * @since 1.0.19 |
2181 | 2181 | * @param string $value New description. |
2182 | 2182 | */ |
2183 | - public function set_excerpt( $value ) { |
|
2184 | - $this->set_description( $value ); |
|
2183 | + public function set_excerpt($value) { |
|
2184 | + $this->set_description($value); |
|
2185 | 2185 | } |
2186 | 2186 | |
2187 | 2187 | /** |
@@ -2190,8 +2190,8 @@ discard block |
||
2190 | 2190 | * @since 1.0.19 |
2191 | 2191 | * @param string $value New description. |
2192 | 2192 | */ |
2193 | - public function set_summary( $value ) { |
|
2194 | - $this->set_description( $value ); |
|
2193 | + public function set_summary($value) { |
|
2194 | + $this->set_description($value); |
|
2195 | 2195 | } |
2196 | 2196 | |
2197 | 2197 | /** |
@@ -2200,12 +2200,12 @@ discard block |
||
2200 | 2200 | * @since 1.0.19 |
2201 | 2201 | * @param int $value New author. |
2202 | 2202 | */ |
2203 | - public function set_author( $value ) { |
|
2204 | - $user = get_user_by( 'id', (int) $value ); |
|
2203 | + public function set_author($value) { |
|
2204 | + $user = get_user_by('id', (int) $value); |
|
2205 | 2205 | |
2206 | - if ( $user && $user->ID ) { |
|
2207 | - $this->set_prop( 'author', $user->ID ); |
|
2208 | - $this->set_prop( 'email', $user->user_email ); |
|
2206 | + if ($user && $user->ID) { |
|
2207 | + $this->set_prop('author', $user->ID); |
|
2208 | + $this->set_prop('email', $user->user_email); |
|
2209 | 2209 | } |
2210 | 2210 | |
2211 | 2211 | } |
@@ -2216,8 +2216,8 @@ discard block |
||
2216 | 2216 | * @since 1.0.19 |
2217 | 2217 | * @param int $value New user id. |
2218 | 2218 | */ |
2219 | - public function set_user_id( $value ) { |
|
2220 | - $this->set_author( $value ); |
|
2219 | + public function set_user_id($value) { |
|
2220 | + $this->set_author($value); |
|
2221 | 2221 | } |
2222 | 2222 | |
2223 | 2223 | /** |
@@ -2226,8 +2226,8 @@ discard block |
||
2226 | 2226 | * @since 1.0.19 |
2227 | 2227 | * @param int $value New user id. |
2228 | 2228 | */ |
2229 | - public function set_customer_id( $value ) { |
|
2230 | - $this->set_author( $value ); |
|
2229 | + public function set_customer_id($value) { |
|
2230 | + $this->set_author($value); |
|
2231 | 2231 | } |
2232 | 2232 | |
2233 | 2233 | /** |
@@ -2236,8 +2236,8 @@ discard block |
||
2236 | 2236 | * @since 1.0.19 |
2237 | 2237 | * @param string $value ip address. |
2238 | 2238 | */ |
2239 | - public function set_ip( $value ) { |
|
2240 | - $this->set_prop( 'ip', $value ); |
|
2239 | + public function set_ip($value) { |
|
2240 | + $this->set_prop('ip', $value); |
|
2241 | 2241 | } |
2242 | 2242 | |
2243 | 2243 | /** |
@@ -2246,8 +2246,8 @@ discard block |
||
2246 | 2246 | * @since 1.0.19 |
2247 | 2247 | * @param string $value ip address. |
2248 | 2248 | */ |
2249 | - public function set_user_ip( $value ) { |
|
2250 | - $this->set_ip( $value ); |
|
2249 | + public function set_user_ip($value) { |
|
2250 | + $this->set_ip($value); |
|
2251 | 2251 | } |
2252 | 2252 | |
2253 | 2253 | /** |
@@ -2256,8 +2256,8 @@ discard block |
||
2256 | 2256 | * @since 1.0.19 |
2257 | 2257 | * @param string $value first name. |
2258 | 2258 | */ |
2259 | - public function set_first_name( $value ) { |
|
2260 | - $this->set_prop( 'first_name', $value ); |
|
2259 | + public function set_first_name($value) { |
|
2260 | + $this->set_prop('first_name', $value); |
|
2261 | 2261 | } |
2262 | 2262 | |
2263 | 2263 | /** |
@@ -2266,8 +2266,8 @@ discard block |
||
2266 | 2266 | * @since 1.0.19 |
2267 | 2267 | * @param string $value first name. |
2268 | 2268 | */ |
2269 | - public function set_user_first_name( $value ) { |
|
2270 | - $this->set_first_name( $value ); |
|
2269 | + public function set_user_first_name($value) { |
|
2270 | + $this->set_first_name($value); |
|
2271 | 2271 | } |
2272 | 2272 | |
2273 | 2273 | /** |
@@ -2276,8 +2276,8 @@ discard block |
||
2276 | 2276 | * @since 1.0.19 |
2277 | 2277 | * @param string $value first name. |
2278 | 2278 | */ |
2279 | - public function set_customer_first_name( $value ) { |
|
2280 | - $this->set_first_name( $value ); |
|
2279 | + public function set_customer_first_name($value) { |
|
2280 | + $this->set_first_name($value); |
|
2281 | 2281 | } |
2282 | 2282 | |
2283 | 2283 | /** |
@@ -2286,8 +2286,8 @@ discard block |
||
2286 | 2286 | * @since 1.0.19 |
2287 | 2287 | * @param string $value last name. |
2288 | 2288 | */ |
2289 | - public function set_last_name( $value ) { |
|
2290 | - $this->set_prop( 'last_name', $value ); |
|
2289 | + public function set_last_name($value) { |
|
2290 | + $this->set_prop('last_name', $value); |
|
2291 | 2291 | } |
2292 | 2292 | |
2293 | 2293 | /** |
@@ -2296,8 +2296,8 @@ discard block |
||
2296 | 2296 | * @since 1.0.19 |
2297 | 2297 | * @param string $value last name. |
2298 | 2298 | */ |
2299 | - public function set_user_last_name( $value ) { |
|
2300 | - $this->set_last_name( $value ); |
|
2299 | + public function set_user_last_name($value) { |
|
2300 | + $this->set_last_name($value); |
|
2301 | 2301 | } |
2302 | 2302 | |
2303 | 2303 | /** |
@@ -2306,8 +2306,8 @@ discard block |
||
2306 | 2306 | * @since 1.0.19 |
2307 | 2307 | * @param string $value last name. |
2308 | 2308 | */ |
2309 | - public function set_customer_last_name( $value ) { |
|
2310 | - $this->set_last_name( $value ); |
|
2309 | + public function set_customer_last_name($value) { |
|
2310 | + $this->set_last_name($value); |
|
2311 | 2311 | } |
2312 | 2312 | |
2313 | 2313 | /** |
@@ -2316,8 +2316,8 @@ discard block |
||
2316 | 2316 | * @since 1.0.19 |
2317 | 2317 | * @param string $value phone. |
2318 | 2318 | */ |
2319 | - public function set_phone( $value ) { |
|
2320 | - $this->set_prop( 'phone', $value ); |
|
2319 | + public function set_phone($value) { |
|
2320 | + $this->set_prop('phone', $value); |
|
2321 | 2321 | } |
2322 | 2322 | |
2323 | 2323 | /** |
@@ -2326,8 +2326,8 @@ discard block |
||
2326 | 2326 | * @since 1.0.19 |
2327 | 2327 | * @param string $value phone. |
2328 | 2328 | */ |
2329 | - public function set_user_phone( $value ) { |
|
2330 | - $this->set_phone( $value ); |
|
2329 | + public function set_user_phone($value) { |
|
2330 | + $this->set_phone($value); |
|
2331 | 2331 | } |
2332 | 2332 | |
2333 | 2333 | /** |
@@ -2336,8 +2336,8 @@ discard block |
||
2336 | 2336 | * @since 1.0.19 |
2337 | 2337 | * @param string $value phone. |
2338 | 2338 | */ |
2339 | - public function set_customer_phone( $value ) { |
|
2340 | - $this->set_phone( $value ); |
|
2339 | + public function set_customer_phone($value) { |
|
2340 | + $this->set_phone($value); |
|
2341 | 2341 | } |
2342 | 2342 | |
2343 | 2343 | /** |
@@ -2346,8 +2346,8 @@ discard block |
||
2346 | 2346 | * @since 1.0.19 |
2347 | 2347 | * @param string $value phone. |
2348 | 2348 | */ |
2349 | - public function set_phone_number( $value ) { |
|
2350 | - $this->set_phone( $value ); |
|
2349 | + public function set_phone_number($value) { |
|
2350 | + $this->set_phone($value); |
|
2351 | 2351 | } |
2352 | 2352 | |
2353 | 2353 | /** |
@@ -2356,8 +2356,8 @@ discard block |
||
2356 | 2356 | * @since 1.0.19 |
2357 | 2357 | * @param string $value email address. |
2358 | 2358 | */ |
2359 | - public function set_email( $value ) { |
|
2360 | - $this->set_prop( 'email', $value ); |
|
2359 | + public function set_email($value) { |
|
2360 | + $this->set_prop('email', $value); |
|
2361 | 2361 | } |
2362 | 2362 | |
2363 | 2363 | /** |
@@ -2366,8 +2366,8 @@ discard block |
||
2366 | 2366 | * @since 1.0.19 |
2367 | 2367 | * @param string $value email address. |
2368 | 2368 | */ |
2369 | - public function set_user_email( $value ) { |
|
2370 | - $this->set_email( $value ); |
|
2369 | + public function set_user_email($value) { |
|
2370 | + $this->set_email($value); |
|
2371 | 2371 | } |
2372 | 2372 | |
2373 | 2373 | /** |
@@ -2376,8 +2376,8 @@ discard block |
||
2376 | 2376 | * @since 1.0.19 |
2377 | 2377 | * @param string $value email address. |
2378 | 2378 | */ |
2379 | - public function set_email_address( $value ) { |
|
2380 | - $this->set_email( $value ); |
|
2379 | + public function set_email_address($value) { |
|
2380 | + $this->set_email($value); |
|
2381 | 2381 | } |
2382 | 2382 | |
2383 | 2383 | /** |
@@ -2386,8 +2386,8 @@ discard block |
||
2386 | 2386 | * @since 1.0.19 |
2387 | 2387 | * @param string $value email address. |
2388 | 2388 | */ |
2389 | - public function set_customer_email( $value ) { |
|
2390 | - $this->set_email( $value ); |
|
2389 | + public function set_customer_email($value) { |
|
2390 | + $this->set_email($value); |
|
2391 | 2391 | } |
2392 | 2392 | |
2393 | 2393 | /** |
@@ -2396,8 +2396,8 @@ discard block |
||
2396 | 2396 | * @since 1.0.19 |
2397 | 2397 | * @param string $value country. |
2398 | 2398 | */ |
2399 | - public function set_country( $value ) { |
|
2400 | - $this->set_prop( 'country', $value ); |
|
2399 | + public function set_country($value) { |
|
2400 | + $this->set_prop('country', $value); |
|
2401 | 2401 | } |
2402 | 2402 | |
2403 | 2403 | /** |
@@ -2406,8 +2406,8 @@ discard block |
||
2406 | 2406 | * @since 1.0.19 |
2407 | 2407 | * @param string $value country. |
2408 | 2408 | */ |
2409 | - public function set_user_country( $value ) { |
|
2410 | - $this->set_country( $value ); |
|
2409 | + public function set_user_country($value) { |
|
2410 | + $this->set_country($value); |
|
2411 | 2411 | } |
2412 | 2412 | |
2413 | 2413 | /** |
@@ -2416,8 +2416,8 @@ discard block |
||
2416 | 2416 | * @since 1.0.19 |
2417 | 2417 | * @param string $value country. |
2418 | 2418 | */ |
2419 | - public function set_customer_country( $value ) { |
|
2420 | - $this->set_country( $value ); |
|
2419 | + public function set_customer_country($value) { |
|
2420 | + $this->set_country($value); |
|
2421 | 2421 | } |
2422 | 2422 | |
2423 | 2423 | /** |
@@ -2426,8 +2426,8 @@ discard block |
||
2426 | 2426 | * @since 1.0.19 |
2427 | 2427 | * @param string $value state. |
2428 | 2428 | */ |
2429 | - public function set_state( $value ) { |
|
2430 | - $this->set_prop( 'state', $value ); |
|
2429 | + public function set_state($value) { |
|
2430 | + $this->set_prop('state', $value); |
|
2431 | 2431 | } |
2432 | 2432 | |
2433 | 2433 | /** |
@@ -2436,8 +2436,8 @@ discard block |
||
2436 | 2436 | * @since 1.0.19 |
2437 | 2437 | * @param string $value state. |
2438 | 2438 | */ |
2439 | - public function set_user_state( $value ) { |
|
2440 | - $this->set_state( $value ); |
|
2439 | + public function set_user_state($value) { |
|
2440 | + $this->set_state($value); |
|
2441 | 2441 | } |
2442 | 2442 | |
2443 | 2443 | /** |
@@ -2446,8 +2446,8 @@ discard block |
||
2446 | 2446 | * @since 1.0.19 |
2447 | 2447 | * @param string $value state. |
2448 | 2448 | */ |
2449 | - public function set_customer_state( $value ) { |
|
2450 | - $this->set_state( $value ); |
|
2449 | + public function set_customer_state($value) { |
|
2450 | + $this->set_state($value); |
|
2451 | 2451 | } |
2452 | 2452 | |
2453 | 2453 | /** |
@@ -2456,8 +2456,8 @@ discard block |
||
2456 | 2456 | * @since 1.0.19 |
2457 | 2457 | * @param string $value city. |
2458 | 2458 | */ |
2459 | - public function set_city( $value ) { |
|
2460 | - $this->set_prop( 'city', $value ); |
|
2459 | + public function set_city($value) { |
|
2460 | + $this->set_prop('city', $value); |
|
2461 | 2461 | } |
2462 | 2462 | |
2463 | 2463 | /** |
@@ -2466,8 +2466,8 @@ discard block |
||
2466 | 2466 | * @since 1.0.19 |
2467 | 2467 | * @param string $value city. |
2468 | 2468 | */ |
2469 | - public function set_user_city( $value ) { |
|
2470 | - $this->set_city( $value ); |
|
2469 | + public function set_user_city($value) { |
|
2470 | + $this->set_city($value); |
|
2471 | 2471 | } |
2472 | 2472 | |
2473 | 2473 | /** |
@@ -2476,8 +2476,8 @@ discard block |
||
2476 | 2476 | * @since 1.0.19 |
2477 | 2477 | * @param string $value city. |
2478 | 2478 | */ |
2479 | - public function set_customer_city( $value ) { |
|
2480 | - $this->set_city( $value ); |
|
2479 | + public function set_customer_city($value) { |
|
2480 | + $this->set_city($value); |
|
2481 | 2481 | } |
2482 | 2482 | |
2483 | 2483 | /** |
@@ -2486,8 +2486,8 @@ discard block |
||
2486 | 2486 | * @since 1.0.19 |
2487 | 2487 | * @param string $value zip. |
2488 | 2488 | */ |
2489 | - public function set_zip( $value ) { |
|
2490 | - $this->set_prop( 'zip', $value ); |
|
2489 | + public function set_zip($value) { |
|
2490 | + $this->set_prop('zip', $value); |
|
2491 | 2491 | } |
2492 | 2492 | |
2493 | 2493 | /** |
@@ -2496,8 +2496,8 @@ discard block |
||
2496 | 2496 | * @since 1.0.19 |
2497 | 2497 | * @param string $value zip. |
2498 | 2498 | */ |
2499 | - public function set_user_zip( $value ) { |
|
2500 | - $this->set_zip( $value ); |
|
2499 | + public function set_user_zip($value) { |
|
2500 | + $this->set_zip($value); |
|
2501 | 2501 | } |
2502 | 2502 | |
2503 | 2503 | /** |
@@ -2506,8 +2506,8 @@ discard block |
||
2506 | 2506 | * @since 1.0.19 |
2507 | 2507 | * @param string $value zip. |
2508 | 2508 | */ |
2509 | - public function set_customer_zip( $value ) { |
|
2510 | - $this->set_zip( $value ); |
|
2509 | + public function set_customer_zip($value) { |
|
2510 | + $this->set_zip($value); |
|
2511 | 2511 | } |
2512 | 2512 | |
2513 | 2513 | /** |
@@ -2516,8 +2516,8 @@ discard block |
||
2516 | 2516 | * @since 1.0.19 |
2517 | 2517 | * @param string $value company. |
2518 | 2518 | */ |
2519 | - public function set_company( $value ) { |
|
2520 | - $this->set_prop( 'company', $value ); |
|
2519 | + public function set_company($value) { |
|
2520 | + $this->set_prop('company', $value); |
|
2521 | 2521 | } |
2522 | 2522 | |
2523 | 2523 | /** |
@@ -2526,8 +2526,8 @@ discard block |
||
2526 | 2526 | * @since 1.0.19 |
2527 | 2527 | * @param string $value company. |
2528 | 2528 | */ |
2529 | - public function set_user_company( $value ) { |
|
2530 | - $this->set_company( $value ); |
|
2529 | + public function set_user_company($value) { |
|
2530 | + $this->set_company($value); |
|
2531 | 2531 | } |
2532 | 2532 | |
2533 | 2533 | /** |
@@ -2536,8 +2536,8 @@ discard block |
||
2536 | 2536 | * @since 1.0.19 |
2537 | 2537 | * @param string $value company. |
2538 | 2538 | */ |
2539 | - public function set_customer_company( $value ) { |
|
2540 | - $this->set_company( $value ); |
|
2539 | + public function set_customer_company($value) { |
|
2540 | + $this->set_company($value); |
|
2541 | 2541 | } |
2542 | 2542 | |
2543 | 2543 | /** |
@@ -2546,8 +2546,8 @@ discard block |
||
2546 | 2546 | * @since 1.0.19 |
2547 | 2547 | * @param string $value var number. |
2548 | 2548 | */ |
2549 | - public function set_vat_number( $value ) { |
|
2550 | - $this->set_prop( 'vat_number', $value ); |
|
2549 | + public function set_vat_number($value) { |
|
2550 | + $this->set_prop('vat_number', $value); |
|
2551 | 2551 | } |
2552 | 2552 | |
2553 | 2553 | /** |
@@ -2556,8 +2556,8 @@ discard block |
||
2556 | 2556 | * @since 1.0.19 |
2557 | 2557 | * @param string $value var number. |
2558 | 2558 | */ |
2559 | - public function set_user_vat_number( $value ) { |
|
2560 | - $this->set_vat_number( $value ); |
|
2559 | + public function set_user_vat_number($value) { |
|
2560 | + $this->set_vat_number($value); |
|
2561 | 2561 | } |
2562 | 2562 | |
2563 | 2563 | /** |
@@ -2566,8 +2566,8 @@ discard block |
||
2566 | 2566 | * @since 1.0.19 |
2567 | 2567 | * @param string $value var number. |
2568 | 2568 | */ |
2569 | - public function set_customer_vat_number( $value ) { |
|
2570 | - $this->set_vat_number( $value ); |
|
2569 | + public function set_customer_vat_number($value) { |
|
2570 | + $this->set_vat_number($value); |
|
2571 | 2571 | } |
2572 | 2572 | |
2573 | 2573 | /** |
@@ -2576,8 +2576,8 @@ discard block |
||
2576 | 2576 | * @since 1.0.19 |
2577 | 2577 | * @param string $value var rate. |
2578 | 2578 | */ |
2579 | - public function set_vat_rate( $value ) { |
|
2580 | - $this->set_prop( 'vat_rate', $value ); |
|
2579 | + public function set_vat_rate($value) { |
|
2580 | + $this->set_prop('vat_rate', $value); |
|
2581 | 2581 | } |
2582 | 2582 | |
2583 | 2583 | /** |
@@ -2586,8 +2586,8 @@ discard block |
||
2586 | 2586 | * @since 1.0.19 |
2587 | 2587 | * @param string $value var number. |
2588 | 2588 | */ |
2589 | - public function set_user_vat_rate( $value ) { |
|
2590 | - $this->set_vat_rate( $value ); |
|
2589 | + public function set_user_vat_rate($value) { |
|
2590 | + $this->set_vat_rate($value); |
|
2591 | 2591 | } |
2592 | 2592 | |
2593 | 2593 | /** |
@@ -2596,8 +2596,8 @@ discard block |
||
2596 | 2596 | * @since 1.0.19 |
2597 | 2597 | * @param string $value var number. |
2598 | 2598 | */ |
2599 | - public function set_customer_vat_rate( $value ) { |
|
2600 | - $this->set_vat_rate( $value ); |
|
2599 | + public function set_customer_vat_rate($value) { |
|
2600 | + $this->set_vat_rate($value); |
|
2601 | 2601 | } |
2602 | 2602 | |
2603 | 2603 | /** |
@@ -2606,8 +2606,8 @@ discard block |
||
2606 | 2606 | * @since 1.0.19 |
2607 | 2607 | * @param string $value address. |
2608 | 2608 | */ |
2609 | - public function set_address( $value ) { |
|
2610 | - $this->set_prop( 'address', $value ); |
|
2609 | + public function set_address($value) { |
|
2610 | + $this->set_prop('address', $value); |
|
2611 | 2611 | } |
2612 | 2612 | |
2613 | 2613 | /** |
@@ -2616,8 +2616,8 @@ discard block |
||
2616 | 2616 | * @since 1.0.19 |
2617 | 2617 | * @param string $value address. |
2618 | 2618 | */ |
2619 | - public function set_user_address( $value ) { |
|
2620 | - $this->set_address( $value ); |
|
2619 | + public function set_user_address($value) { |
|
2620 | + $this->set_address($value); |
|
2621 | 2621 | } |
2622 | 2622 | |
2623 | 2623 | /** |
@@ -2626,8 +2626,8 @@ discard block |
||
2626 | 2626 | * @since 1.0.19 |
2627 | 2627 | * @param string $value address. |
2628 | 2628 | */ |
2629 | - public function set_customer_address( $value ) { |
|
2630 | - $this->set_address( $value ); |
|
2629 | + public function set_customer_address($value) { |
|
2630 | + $this->set_address($value); |
|
2631 | 2631 | } |
2632 | 2632 | |
2633 | 2633 | /** |
@@ -2636,8 +2636,8 @@ discard block |
||
2636 | 2636 | * @since 1.0.19 |
2637 | 2637 | * @param int|bool $value confirmed. |
2638 | 2638 | */ |
2639 | - public function set_is_viewed( $value ) { |
|
2640 | - $this->set_prop( 'is_viewed', $value ); |
|
2639 | + public function set_is_viewed($value) { |
|
2640 | + $this->set_prop('is_viewed', $value); |
|
2641 | 2641 | } |
2642 | 2642 | |
2643 | 2643 | /** |
@@ -2646,8 +2646,8 @@ discard block |
||
2646 | 2646 | * @since 1.0.19 |
2647 | 2647 | * @param string $value email recipients. |
2648 | 2648 | */ |
2649 | - public function set_email_cc( $value ) { |
|
2650 | - $this->set_prop( 'email_cc', $value ); |
|
2649 | + public function set_email_cc($value) { |
|
2650 | + $this->set_prop('email_cc', $value); |
|
2651 | 2651 | } |
2652 | 2652 | |
2653 | 2653 | /** |
@@ -2656,9 +2656,9 @@ discard block |
||
2656 | 2656 | * @since 1.0.19 |
2657 | 2657 | * @param string $value template. |
2658 | 2658 | */ |
2659 | - public function set_template( $value ) { |
|
2660 | - if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) { |
|
2661 | - $this->set_prop( 'template', $value ); |
|
2659 | + public function set_template($value) { |
|
2660 | + if (in_array($value, array('quantity', 'hours', 'amount'))) { |
|
2661 | + $this->set_prop('template', $value); |
|
2662 | 2662 | } |
2663 | 2663 | } |
2664 | 2664 | |
@@ -2668,8 +2668,8 @@ discard block |
||
2668 | 2668 | * @since 1.0.19 |
2669 | 2669 | * @param string $value email recipients. |
2670 | 2670 | */ |
2671 | - public function created_via( $value ) { |
|
2672 | - $this->set_prop( 'created_via', sanitize_text_field( $value ) ); |
|
2671 | + public function created_via($value) { |
|
2672 | + $this->set_prop('created_via', sanitize_text_field($value)); |
|
2673 | 2673 | } |
2674 | 2674 | |
2675 | 2675 | /** |
@@ -2678,8 +2678,8 @@ discard block |
||
2678 | 2678 | * @since 1.0.19 |
2679 | 2679 | * @param int|bool $value confirmed. |
2680 | 2680 | */ |
2681 | - public function set_address_confirmed( $value ) { |
|
2682 | - $this->set_prop( 'address_confirmed', $value ); |
|
2681 | + public function set_address_confirmed($value) { |
|
2682 | + $this->set_prop('address_confirmed', $value); |
|
2683 | 2683 | } |
2684 | 2684 | |
2685 | 2685 | /** |
@@ -2688,8 +2688,8 @@ discard block |
||
2688 | 2688 | * @since 1.0.19 |
2689 | 2689 | * @param int|bool $value confirmed. |
2690 | 2690 | */ |
2691 | - public function set_user_address_confirmed( $value ) { |
|
2692 | - $this->set_address_confirmed( $value ); |
|
2691 | + public function set_user_address_confirmed($value) { |
|
2692 | + $this->set_address_confirmed($value); |
|
2693 | 2693 | } |
2694 | 2694 | |
2695 | 2695 | /** |
@@ -2698,8 +2698,8 @@ discard block |
||
2698 | 2698 | * @since 1.0.19 |
2699 | 2699 | * @param int|bool $value confirmed. |
2700 | 2700 | */ |
2701 | - public function set_customer_address_confirmed( $value ) { |
|
2702 | - $this->set_address_confirmed( $value ); |
|
2701 | + public function set_customer_address_confirmed($value) { |
|
2702 | + $this->set_address_confirmed($value); |
|
2703 | 2703 | } |
2704 | 2704 | |
2705 | 2705 | /** |
@@ -2708,8 +2708,8 @@ discard block |
||
2708 | 2708 | * @since 1.0.19 |
2709 | 2709 | * @param float $value sub total. |
2710 | 2710 | */ |
2711 | - public function set_subtotal( $value ) { |
|
2712 | - $this->set_prop( 'subtotal', $value ); |
|
2711 | + public function set_subtotal($value) { |
|
2712 | + $this->set_prop('subtotal', $value); |
|
2713 | 2713 | } |
2714 | 2714 | |
2715 | 2715 | /** |
@@ -2718,8 +2718,8 @@ discard block |
||
2718 | 2718 | * @since 1.0.19 |
2719 | 2719 | * @param float $value discount total. |
2720 | 2720 | */ |
2721 | - public function set_total_discount( $value ) { |
|
2722 | - $this->set_prop( 'total_discount', $value ); |
|
2721 | + public function set_total_discount($value) { |
|
2722 | + $this->set_prop('total_discount', $value); |
|
2723 | 2723 | } |
2724 | 2724 | |
2725 | 2725 | /** |
@@ -2728,8 +2728,8 @@ discard block |
||
2728 | 2728 | * @since 1.0.19 |
2729 | 2729 | * @param float $value discount total. |
2730 | 2730 | */ |
2731 | - public function set_discount( $value ) { |
|
2732 | - $this->set_total_discount( $value ); |
|
2731 | + public function set_discount($value) { |
|
2732 | + $this->set_total_discount($value); |
|
2733 | 2733 | } |
2734 | 2734 | |
2735 | 2735 | /** |
@@ -2738,8 +2738,8 @@ discard block |
||
2738 | 2738 | * @since 1.0.19 |
2739 | 2739 | * @param float $value tax total. |
2740 | 2740 | */ |
2741 | - public function set_total_tax( $value ) { |
|
2742 | - $this->set_prop( 'total_tax', $value ); |
|
2741 | + public function set_total_tax($value) { |
|
2742 | + $this->set_prop('total_tax', $value); |
|
2743 | 2743 | } |
2744 | 2744 | |
2745 | 2745 | /** |
@@ -2748,8 +2748,8 @@ discard block |
||
2748 | 2748 | * @since 1.0.19 |
2749 | 2749 | * @param float $value tax total. |
2750 | 2750 | */ |
2751 | - public function set_tax_total( $value ) { |
|
2752 | - $this->set_total_tax( $value ); |
|
2751 | + public function set_tax_total($value) { |
|
2752 | + $this->set_total_tax($value); |
|
2753 | 2753 | } |
2754 | 2754 | |
2755 | 2755 | /** |
@@ -2758,8 +2758,8 @@ discard block |
||
2758 | 2758 | * @since 1.0.19 |
2759 | 2759 | * @param float $value fees total. |
2760 | 2760 | */ |
2761 | - public function set_total_fees( $value ) { |
|
2762 | - $this->set_prop( 'total_fees', $value ); |
|
2761 | + public function set_total_fees($value) { |
|
2762 | + $this->set_prop('total_fees', $value); |
|
2763 | 2763 | } |
2764 | 2764 | |
2765 | 2765 | /** |
@@ -2768,8 +2768,8 @@ discard block |
||
2768 | 2768 | * @since 1.0.19 |
2769 | 2769 | * @param float $value fees total. |
2770 | 2770 | */ |
2771 | - public function set_fees_total( $value ) { |
|
2772 | - $this->set_total_fees( $value ); |
|
2771 | + public function set_fees_total($value) { |
|
2772 | + $this->set_total_fees($value); |
|
2773 | 2773 | } |
2774 | 2774 | |
2775 | 2775 | /** |
@@ -2778,13 +2778,13 @@ discard block |
||
2778 | 2778 | * @since 1.0.19 |
2779 | 2779 | * @param array $value fees. |
2780 | 2780 | */ |
2781 | - public function set_fees( $value ) { |
|
2781 | + public function set_fees($value) { |
|
2782 | 2782 | |
2783 | - if ( ! is_array( $value ) ) { |
|
2783 | + if (!is_array($value)) { |
|
2784 | 2784 | $value = array(); |
2785 | 2785 | } |
2786 | 2786 | |
2787 | - $this->set_prop( 'fees', $value ); |
|
2787 | + $this->set_prop('fees', $value); |
|
2788 | 2788 | |
2789 | 2789 | } |
2790 | 2790 | |
@@ -2794,13 +2794,13 @@ discard block |
||
2794 | 2794 | * @since 1.0.19 |
2795 | 2795 | * @param array $value taxes. |
2796 | 2796 | */ |
2797 | - public function set_taxes( $value ) { |
|
2797 | + public function set_taxes($value) { |
|
2798 | 2798 | |
2799 | - if ( ! is_array( $value ) ) { |
|
2799 | + if (!is_array($value)) { |
|
2800 | 2800 | $value = array(); |
2801 | 2801 | } |
2802 | 2802 | |
2803 | - $this->set_prop( 'taxes', $value ); |
|
2803 | + $this->set_prop('taxes', $value); |
|
2804 | 2804 | |
2805 | 2805 | } |
2806 | 2806 | |
@@ -2810,13 +2810,13 @@ discard block |
||
2810 | 2810 | * @since 1.0.19 |
2811 | 2811 | * @param array $value discounts. |
2812 | 2812 | */ |
2813 | - public function set_discounts( $value ) { |
|
2813 | + public function set_discounts($value) { |
|
2814 | 2814 | |
2815 | - if ( ! is_array( $value ) ) { |
|
2815 | + if (!is_array($value)) { |
|
2816 | 2816 | $value = array(); |
2817 | 2817 | } |
2818 | 2818 | |
2819 | - $this->set_prop( 'discounts', $value ); |
|
2819 | + $this->set_prop('discounts', $value); |
|
2820 | 2820 | } |
2821 | 2821 | |
2822 | 2822 | /** |
@@ -2825,18 +2825,18 @@ discard block |
||
2825 | 2825 | * @since 1.0.19 |
2826 | 2826 | * @param GetPaid_Form_Item[] $value items. |
2827 | 2827 | */ |
2828 | - public function set_items( $value ) { |
|
2828 | + public function set_items($value) { |
|
2829 | 2829 | |
2830 | 2830 | // Remove existing items. |
2831 | - $this->set_prop( 'items', array() ); |
|
2831 | + $this->set_prop('items', array()); |
|
2832 | 2832 | |
2833 | 2833 | // Ensure that we have an array. |
2834 | - if ( ! is_array( $value ) ) { |
|
2834 | + if (!is_array($value)) { |
|
2835 | 2835 | return; |
2836 | 2836 | } |
2837 | 2837 | |
2838 | - foreach ( $value as $item ) { |
|
2839 | - $this->add_item( $item ); |
|
2838 | + foreach ($value as $item) { |
|
2839 | + $this->add_item($item); |
|
2840 | 2840 | } |
2841 | 2841 | |
2842 | 2842 | } |
@@ -2847,8 +2847,8 @@ discard block |
||
2847 | 2847 | * @since 1.0.19 |
2848 | 2848 | * @param int $value payment form. |
2849 | 2849 | */ |
2850 | - public function set_payment_form( $value ) { |
|
2851 | - $this->set_prop( 'payment_form', $value ); |
|
2850 | + public function set_payment_form($value) { |
|
2851 | + $this->set_prop('payment_form', $value); |
|
2852 | 2852 | } |
2853 | 2853 | |
2854 | 2854 | /** |
@@ -2857,8 +2857,8 @@ discard block |
||
2857 | 2857 | * @since 1.0.19 |
2858 | 2858 | * @param string $value submission id. |
2859 | 2859 | */ |
2860 | - public function set_submission_id( $value ) { |
|
2861 | - $this->set_prop( 'submission_id', $value ); |
|
2860 | + public function set_submission_id($value) { |
|
2861 | + $this->set_prop('submission_id', $value); |
|
2862 | 2862 | } |
2863 | 2863 | |
2864 | 2864 | /** |
@@ -2867,8 +2867,8 @@ discard block |
||
2867 | 2867 | * @since 1.0.19 |
2868 | 2868 | * @param string $value discount code. |
2869 | 2869 | */ |
2870 | - public function set_discount_code( $value ) { |
|
2871 | - $this->set_prop( 'discount_code', $value ); |
|
2870 | + public function set_discount_code($value) { |
|
2871 | + $this->set_prop('discount_code', $value); |
|
2872 | 2872 | } |
2873 | 2873 | |
2874 | 2874 | /** |
@@ -2877,8 +2877,8 @@ discard block |
||
2877 | 2877 | * @since 1.0.19 |
2878 | 2878 | * @param string $value gateway. |
2879 | 2879 | */ |
2880 | - public function set_gateway( $value ) { |
|
2881 | - $this->set_prop( 'gateway', $value ); |
|
2880 | + public function set_gateway($value) { |
|
2881 | + $this->set_prop('gateway', $value); |
|
2882 | 2882 | } |
2883 | 2883 | |
2884 | 2884 | /** |
@@ -2887,9 +2887,9 @@ discard block |
||
2887 | 2887 | * @since 1.0.19 |
2888 | 2888 | * @param string $value transaction id. |
2889 | 2889 | */ |
2890 | - public function set_transaction_id( $value ) { |
|
2891 | - if ( ! empty( $value ) ) { |
|
2892 | - $this->set_prop( 'transaction_id', $value ); |
|
2890 | + public function set_transaction_id($value) { |
|
2891 | + if (!empty($value)) { |
|
2892 | + $this->set_prop('transaction_id', $value); |
|
2893 | 2893 | } |
2894 | 2894 | } |
2895 | 2895 | |
@@ -2899,8 +2899,8 @@ discard block |
||
2899 | 2899 | * @since 1.0.19 |
2900 | 2900 | * @param string $value currency id. |
2901 | 2901 | */ |
2902 | - public function set_currency( $value ) { |
|
2903 | - $this->set_prop( 'currency', $value ); |
|
2902 | + public function set_currency($value) { |
|
2903 | + $this->set_prop('currency', $value); |
|
2904 | 2904 | } |
2905 | 2905 | |
2906 | 2906 | /** |
@@ -2909,8 +2909,8 @@ discard block |
||
2909 | 2909 | * @since 1.0.19 |
2910 | 2910 | * @param bool $value value. |
2911 | 2911 | */ |
2912 | - public function set_disable_taxes( $value ) { |
|
2913 | - $this->set_prop( 'disable_taxes', (bool) $value ); |
|
2912 | + public function set_disable_taxes($value) { |
|
2913 | + $this->set_prop('disable_taxes', (bool) $value); |
|
2914 | 2914 | } |
2915 | 2915 | |
2916 | 2916 | /** |
@@ -2919,8 +2919,8 @@ discard block |
||
2919 | 2919 | * @since 1.0.19 |
2920 | 2920 | * @param string $value subscription id. |
2921 | 2921 | */ |
2922 | - public function set_subscription_id( $value ) { |
|
2923 | - $this->set_prop( 'subscription_id', $value ); |
|
2922 | + public function set_subscription_id($value) { |
|
2923 | + $this->set_prop('subscription_id', $value); |
|
2924 | 2924 | } |
2925 | 2925 | |
2926 | 2926 | /** |
@@ -2929,8 +2929,8 @@ discard block |
||
2929 | 2929 | * @since 1.0.19 |
2930 | 2930 | * @param string $value subscription id. |
2931 | 2931 | */ |
2932 | - public function set_remote_subscription_id( $value ) { |
|
2933 | - $this->set_prop( 'remote_subscription_id', $value ); |
|
2932 | + public function set_remote_subscription_id($value) { |
|
2933 | + $this->set_prop('remote_subscription_id', $value); |
|
2934 | 2934 | } |
2935 | 2935 | |
2936 | 2936 | /* |
@@ -2947,28 +2947,28 @@ discard block |
||
2947 | 2947 | */ |
2948 | 2948 | public function is_parent() { |
2949 | 2949 | $parent = $this->get_parent_id(); |
2950 | - return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this ); |
|
2950 | + return apply_filters('wpinv_invoice_is_parent', empty($parent), $this); |
|
2951 | 2951 | } |
2952 | 2952 | |
2953 | 2953 | /** |
2954 | 2954 | * Checks if this is a renewal invoice. |
2955 | 2955 | */ |
2956 | 2956 | public function is_renewal() { |
2957 | - return ! $this->is_parent(); |
|
2957 | + return !$this->is_parent(); |
|
2958 | 2958 | } |
2959 | 2959 | |
2960 | 2960 | /** |
2961 | 2961 | * Checks if this is a recurring invoice. |
2962 | 2962 | */ |
2963 | 2963 | public function is_recurring() { |
2964 | - return $this->is_renewal() || ! empty( $this->recurring_item ); |
|
2964 | + return $this->is_renewal() || !empty($this->recurring_item); |
|
2965 | 2965 | } |
2966 | 2966 | |
2967 | 2967 | /** |
2968 | 2968 | * Checks if this is a taxable invoice. |
2969 | 2969 | */ |
2970 | 2970 | public function is_taxable() { |
2971 | - return ! $this->get_disable_taxes(); |
|
2971 | + return !$this->get_disable_taxes(); |
|
2972 | 2972 | } |
2973 | 2973 | |
2974 | 2974 | /** |
@@ -2982,45 +2982,45 @@ discard block |
||
2982 | 2982 | * Checks to see if the invoice requires payment. |
2983 | 2983 | */ |
2984 | 2984 | public function is_free() { |
2985 | - $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 ); |
|
2985 | + $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0); |
|
2986 | 2986 | |
2987 | - if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) { |
|
2987 | + if ($this->is_recurring() && $this->get_recurring_total() > 0) { |
|
2988 | 2988 | $is_free = false; |
2989 | 2989 | } |
2990 | 2990 | |
2991 | - return apply_filters( 'wpinv_invoice_is_free', $is_free, $this ); |
|
2991 | + return apply_filters('wpinv_invoice_is_free', $is_free, $this); |
|
2992 | 2992 | } |
2993 | 2993 | |
2994 | 2994 | /** |
2995 | 2995 | * Checks if the invoice is paid. |
2996 | 2996 | */ |
2997 | 2997 | public function is_paid() { |
2998 | - $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) ); |
|
2999 | - return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this ); |
|
2998 | + $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal')); |
|
2999 | + return apply_filters('wpinv_invoice_is_paid', $is_paid, $this); |
|
3000 | 3000 | } |
3001 | 3001 | |
3002 | 3002 | /** |
3003 | 3003 | * Checks if the invoice needs payment. |
3004 | 3004 | */ |
3005 | 3005 | public function needs_payment() { |
3006 | - $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free(); |
|
3007 | - return apply_filters( 'wpinv_needs_payment', $needs_payment, $this ); |
|
3006 | + $needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free(); |
|
3007 | + return apply_filters('wpinv_needs_payment', $needs_payment, $this); |
|
3008 | 3008 | } |
3009 | 3009 | |
3010 | 3010 | /** |
3011 | 3011 | * Checks if the invoice is refunded. |
3012 | 3012 | */ |
3013 | 3013 | public function is_refunded() { |
3014 | - $is_refunded = $this->has_status( 'wpi-refunded' ); |
|
3015 | - return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this ); |
|
3014 | + $is_refunded = $this->has_status('wpi-refunded'); |
|
3015 | + return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this); |
|
3016 | 3016 | } |
3017 | 3017 | |
3018 | 3018 | /** |
3019 | 3019 | * Checks if the invoice is held. |
3020 | 3020 | */ |
3021 | 3021 | public function is_held() { |
3022 | - $is_held = $this->has_status( 'wpi-onhold' ); |
|
3023 | - return apply_filters( 'wpinv_invoice_is_held', $is_held, $this ); |
|
3022 | + $is_held = $this->has_status('wpi-onhold'); |
|
3023 | + return apply_filters('wpinv_invoice_is_held', $is_held, $this); |
|
3024 | 3024 | } |
3025 | 3025 | |
3026 | 3026 | /** |
@@ -3028,30 +3028,30 @@ discard block |
||
3028 | 3028 | */ |
3029 | 3029 | public function is_due() { |
3030 | 3030 | $due_date = $this->get_due_date(); |
3031 | - return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date ); |
|
3031 | + return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date); |
|
3032 | 3032 | } |
3033 | 3033 | |
3034 | 3034 | /** |
3035 | 3035 | * Checks if the invoice is draft. |
3036 | 3036 | */ |
3037 | 3037 | public function is_draft() { |
3038 | - return $this->has_status( 'draft, auto-draft' ); |
|
3038 | + return $this->has_status('draft, auto-draft'); |
|
3039 | 3039 | } |
3040 | 3040 | |
3041 | 3041 | /** |
3042 | 3042 | * Checks if the invoice has a given status. |
3043 | 3043 | */ |
3044 | - public function has_status( $status ) { |
|
3045 | - $status = wpinv_parse_list( $status ); |
|
3046 | - return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status ); |
|
3044 | + public function has_status($status) { |
|
3045 | + $status = wpinv_parse_list($status); |
|
3046 | + return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status); |
|
3047 | 3047 | } |
3048 | 3048 | |
3049 | 3049 | /** |
3050 | 3050 | * Checks if the invoice is of a given type. |
3051 | 3051 | */ |
3052 | - public function is_type( $type ) { |
|
3053 | - $type = wpinv_parse_list( $type ); |
|
3054 | - return in_array( $this->get_type(), $type ); |
|
3052 | + public function is_type($type) { |
|
3053 | + $type = wpinv_parse_list($type); |
|
3054 | + return in_array($this->get_type(), $type); |
|
3055 | 3055 | } |
3056 | 3056 | |
3057 | 3057 | /** |
@@ -3083,8 +3083,8 @@ discard block |
||
3083 | 3083 | * |
3084 | 3084 | */ |
3085 | 3085 | public function is_initial_free() { |
3086 | - $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 ); |
|
3087 | - return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this ); |
|
3086 | + $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0); |
|
3087 | + return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this); |
|
3088 | 3088 | } |
3089 | 3089 | |
3090 | 3090 | /** |
@@ -3094,11 +3094,11 @@ discard block |
||
3094 | 3094 | public function item_has_free_trial() { |
3095 | 3095 | |
3096 | 3096 | // Ensure we have a recurring item. |
3097 | - if ( ! $this->is_recurring() ) { |
|
3097 | + if (!$this->is_recurring()) { |
|
3098 | 3098 | return false; |
3099 | 3099 | } |
3100 | 3100 | |
3101 | - $item = $this->get_recurring( true ); |
|
3101 | + $item = $this->get_recurring(true); |
|
3102 | 3102 | return $item->has_free_trial(); |
3103 | 3103 | } |
3104 | 3104 | |
@@ -3106,7 +3106,7 @@ discard block |
||
3106 | 3106 | * Check if the free trial is a result of a discount. |
3107 | 3107 | */ |
3108 | 3108 | public function is_free_trial_from_discount() { |
3109 | - return $this->has_free_trial() && ! $this->item_has_free_trial(); |
|
3109 | + return $this->has_free_trial() && !$this->item_has_free_trial(); |
|
3110 | 3110 | } |
3111 | 3111 | |
3112 | 3112 | /** |
@@ -3114,12 +3114,12 @@ discard block |
||
3114 | 3114 | */ |
3115 | 3115 | public function discount_first_payment_only() { |
3116 | 3116 | |
3117 | - $discount = wpinv_get_discount_obj( $this->get_discount_code() ); |
|
3118 | - if ( ! $discount->exists() || ! $this->is_recurring() ) { |
|
3117 | + $discount = wpinv_get_discount_obj($this->get_discount_code()); |
|
3118 | + if (!$discount->exists() || !$this->is_recurring()) { |
|
3119 | 3119 | return true; |
3120 | 3120 | } |
3121 | 3121 | |
3122 | - return ! $discount->get_is_recurring(); |
|
3122 | + return !$discount->get_is_recurring(); |
|
3123 | 3123 | } |
3124 | 3124 | |
3125 | 3125 | /* |
@@ -3137,27 +3137,27 @@ discard block |
||
3137 | 3137 | * @param GetPaid_Form_Item|array $item |
3138 | 3138 | * @return WP_Error|Bool |
3139 | 3139 | */ |
3140 | - public function add_item( $item ) { |
|
3140 | + public function add_item($item) { |
|
3141 | 3141 | |
3142 | - if ( is_array( $item ) ) { |
|
3143 | - $item = $this->process_array_item( $item ); |
|
3142 | + if (is_array($item)) { |
|
3143 | + $item = $this->process_array_item($item); |
|
3144 | 3144 | } |
3145 | 3145 | |
3146 | - if ( is_numeric( $item ) ) { |
|
3147 | - $item = new GetPaid_Form_Item( $item ); |
|
3146 | + if (is_numeric($item)) { |
|
3147 | + $item = new GetPaid_Form_Item($item); |
|
3148 | 3148 | } |
3149 | 3149 | |
3150 | 3150 | // Make sure that it is available for purchase. |
3151 | - if ( $item->get_id() > 0 && ! $item->can_purchase() ) { |
|
3152 | - return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) ); |
|
3151 | + if ($item->get_id() > 0 && !$item->can_purchase()) { |
|
3152 | + return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing')); |
|
3153 | 3153 | } |
3154 | 3154 | |
3155 | 3155 | // Do we have a recurring item? |
3156 | - if ( $item->is_recurring() ) { |
|
3156 | + if ($item->is_recurring()) { |
|
3157 | 3157 | |
3158 | 3158 | // An invoice can only contain one recurring item. |
3159 | - if ( ! empty( $this->recurring_item && $this->recurring_item != (int) $item->get_id() ) ) { |
|
3160 | - return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) ); |
|
3159 | + if (!empty($this->recurring_item && $this->recurring_item != (int) $item->get_id())) { |
|
3160 | + return new WP_Error('recurring_item', __('An invoice can only contain one recurring item', 'invoicing')); |
|
3161 | 3161 | } |
3162 | 3162 | |
3163 | 3163 | $this->recurring_item = $item->get_id(); |
@@ -3168,9 +3168,9 @@ discard block |
||
3168 | 3168 | |
3169 | 3169 | // Retrieve all items. |
3170 | 3170 | $items = $this->get_items(); |
3171 | - $items[ (int) $item->get_id() ] = $item; |
|
3171 | + $items[(int) $item->get_id()] = $item; |
|
3172 | 3172 | |
3173 | - $this->set_prop( 'items', $items ); |
|
3173 | + $this->set_prop('items', $items); |
|
3174 | 3174 | return true; |
3175 | 3175 | } |
3176 | 3176 | |
@@ -3180,26 +3180,26 @@ discard block |
||
3180 | 3180 | * @since 1.0.19 |
3181 | 3181 | * @return GetPaid_Form_Item |
3182 | 3182 | */ |
3183 | - protected function process_array_item( $array ) { |
|
3183 | + protected function process_array_item($array) { |
|
3184 | 3184 | |
3185 | - $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0; |
|
3186 | - $item = new GetPaid_Form_Item( $item_id ); |
|
3185 | + $item_id = isset($array['item_id']) ? $array['item_id'] : 0; |
|
3186 | + $item = new GetPaid_Form_Item($item_id); |
|
3187 | 3187 | |
3188 | 3188 | // Set item data. |
3189 | - foreach ( array( 'name', 'price', 'description' ) as $key ) { |
|
3190 | - if ( isset( $array[ "item_$key" ] ) ) { |
|
3189 | + foreach (array('name', 'price', 'description') as $key) { |
|
3190 | + if (isset($array["item_$key"])) { |
|
3191 | 3191 | $method = "set_$key"; |
3192 | - $item->$method( $array[ "item_$key" ] ); |
|
3192 | + $item->$method($array["item_$key"]); |
|
3193 | 3193 | } |
3194 | 3194 | } |
3195 | 3195 | |
3196 | - if ( isset( $array['quantity'] ) ) { |
|
3197 | - $item->set_quantity( $array['quantity'] ); |
|
3196 | + if (isset($array['quantity'])) { |
|
3197 | + $item->set_quantity($array['quantity']); |
|
3198 | 3198 | } |
3199 | 3199 | |
3200 | 3200 | // Set item meta. |
3201 | - if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) { |
|
3202 | - $item->set_item_meta( $array['meta'] ); |
|
3201 | + if (isset($array['meta']) && is_array($array['meta'])) { |
|
3202 | + $item->set_item_meta($array['meta']); |
|
3203 | 3203 | } |
3204 | 3204 | |
3205 | 3205 | return $item; |
@@ -3211,10 +3211,10 @@ discard block |
||
3211 | 3211 | * |
3212 | 3212 | * @since 1.0.19 |
3213 | 3213 | */ |
3214 | - public function get_item( $item_id ) { |
|
3214 | + public function get_item($item_id) { |
|
3215 | 3215 | $items = $this->get_items(); |
3216 | 3216 | $item_id = (int) $item_id; |
3217 | - return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null; |
|
3217 | + return (!empty($item_id) && isset($items[$item_id])) ? $items[$item_id] : null; |
|
3218 | 3218 | } |
3219 | 3219 | |
3220 | 3220 | /** |
@@ -3222,17 +3222,17 @@ discard block |
||
3222 | 3222 | * |
3223 | 3223 | * @since 1.0.19 |
3224 | 3224 | */ |
3225 | - public function remove_item( $item_id ) { |
|
3225 | + public function remove_item($item_id) { |
|
3226 | 3226 | $items = $this->get_items(); |
3227 | 3227 | $item_id = (int) $item_id; |
3228 | 3228 | |
3229 | - if ( $item_id == $this->recurring_item ) { |
|
3229 | + if ($item_id == $this->recurring_item) { |
|
3230 | 3230 | $this->recurring_item = null; |
3231 | 3231 | } |
3232 | 3232 | |
3233 | - if ( isset( $items[ $item_id ] ) ) { |
|
3234 | - unset( $items[ $item_id ] ); |
|
3235 | - $this->set_prop( 'items', $items ); |
|
3233 | + if (isset($items[$item_id])) { |
|
3234 | + unset($items[$item_id]); |
|
3235 | + $this->set_prop('items', $items); |
|
3236 | 3236 | } |
3237 | 3237 | } |
3238 | 3238 | |
@@ -3242,11 +3242,11 @@ discard block |
||
3242 | 3242 | * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required. |
3243 | 3243 | * @since 1.0.19 |
3244 | 3244 | */ |
3245 | - public function add_fee( $fee ) { |
|
3245 | + public function add_fee($fee) { |
|
3246 | 3246 | |
3247 | 3247 | $fees = $this->get_fees(); |
3248 | - $fees[ $fee['name'] ] = $fee; |
|
3249 | - $this->set_prop( 'fees', $fees ); |
|
3248 | + $fees[$fee['name']] = $fee; |
|
3249 | + $this->set_prop('fees', $fees); |
|
3250 | 3250 | |
3251 | 3251 | } |
3252 | 3252 | |
@@ -3255,9 +3255,9 @@ discard block |
||
3255 | 3255 | * |
3256 | 3256 | * @since 1.0.19 |
3257 | 3257 | */ |
3258 | - public function get_fee( $fee ) { |
|
3258 | + public function get_fee($fee) { |
|
3259 | 3259 | $fees = $this->get_fees(); |
3260 | - return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null; |
|
3260 | + return isset($fees[$fee]) ? $fees[$fee] : null; |
|
3261 | 3261 | } |
3262 | 3262 | |
3263 | 3263 | /** |
@@ -3265,11 +3265,11 @@ discard block |
||
3265 | 3265 | * |
3266 | 3266 | * @since 1.0.19 |
3267 | 3267 | */ |
3268 | - public function remove_fee( $fee ) { |
|
3268 | + public function remove_fee($fee) { |
|
3269 | 3269 | $fees = $this->get_fees(); |
3270 | - if ( isset( $fees[ $fee ] ) ) { |
|
3271 | - unset( $fees[ $fee ] ); |
|
3272 | - $this->set_prop( 'fees', $fees ); |
|
3270 | + if (isset($fees[$fee])) { |
|
3271 | + unset($fees[$fee]); |
|
3272 | + $this->set_prop('fees', $fees); |
|
3273 | 3273 | } |
3274 | 3274 | } |
3275 | 3275 | |
@@ -3279,11 +3279,11 @@ discard block |
||
3279 | 3279 | * @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. |
3280 | 3280 | * @since 1.0.19 |
3281 | 3281 | */ |
3282 | - public function add_discount( $discount ) { |
|
3282 | + public function add_discount($discount) { |
|
3283 | 3283 | |
3284 | 3284 | $discounts = $this->get_discounts(); |
3285 | - $discounts[ $discount['name'] ] = $discount; |
|
3286 | - $this->set_prop( 'discounts', $discounts ); |
|
3285 | + $discounts[$discount['name']] = $discount; |
|
3286 | + $this->set_prop('discounts', $discounts); |
|
3287 | 3287 | |
3288 | 3288 | } |
3289 | 3289 | |
@@ -3293,15 +3293,15 @@ discard block |
||
3293 | 3293 | * @since 1.0.19 |
3294 | 3294 | * @return float |
3295 | 3295 | */ |
3296 | - public function get_discount( $discount = false ) { |
|
3296 | + public function get_discount($discount = false) { |
|
3297 | 3297 | |
3298 | 3298 | // Backwards compatibilty. |
3299 | - if ( empty( $discount ) ) { |
|
3299 | + if (empty($discount)) { |
|
3300 | 3300 | return $this->get_total_discount(); |
3301 | 3301 | } |
3302 | 3302 | |
3303 | 3303 | $discounts = $this->get_discounts(); |
3304 | - return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null; |
|
3304 | + return isset($discounts[$discount]) ? $discounts[$discount] : null; |
|
3305 | 3305 | } |
3306 | 3306 | |
3307 | 3307 | /** |
@@ -3309,11 +3309,11 @@ discard block |
||
3309 | 3309 | * |
3310 | 3310 | * @since 1.0.19 |
3311 | 3311 | */ |
3312 | - public function remove_discount( $discount ) { |
|
3312 | + public function remove_discount($discount) { |
|
3313 | 3313 | $discounts = $this->get_discounts(); |
3314 | - if ( isset( $discounts[ $discount ] ) ) { |
|
3315 | - unset( $discounts[ $discount ] ); |
|
3316 | - $this->set_prop( 'discounts', $discounts ); |
|
3314 | + if (isset($discounts[$discount])) { |
|
3315 | + unset($discounts[$discount]); |
|
3316 | + $this->set_prop('discounts', $discounts); |
|
3317 | 3317 | } |
3318 | 3318 | } |
3319 | 3319 | |
@@ -3322,12 +3322,12 @@ discard block |
||
3322 | 3322 | * |
3323 | 3323 | * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required. |
3324 | 3324 | */ |
3325 | - public function add_tax( $tax ) { |
|
3326 | - if ( $this->is_taxable() ) { |
|
3325 | + public function add_tax($tax) { |
|
3326 | + if ($this->is_taxable()) { |
|
3327 | 3327 | |
3328 | - $taxes = $this->get_taxes(); |
|
3329 | - $taxes[ $tax['name'] ] = $tax; |
|
3330 | - $this->set_prop( 'taxes', $tax ); |
|
3328 | + $taxes = $this->get_taxes(); |
|
3329 | + $taxes[$tax['name']] = $tax; |
|
3330 | + $this->set_prop('taxes', $tax); |
|
3331 | 3331 | |
3332 | 3332 | } |
3333 | 3333 | } |
@@ -3337,15 +3337,15 @@ discard block |
||
3337 | 3337 | * |
3338 | 3338 | * @since 1.0.19 |
3339 | 3339 | */ |
3340 | - public function get_tax( $tax = null ) { |
|
3340 | + public function get_tax($tax = null) { |
|
3341 | 3341 | |
3342 | 3342 | // Backwards compatility. |
3343 | - if ( empty( $tax ) ) { |
|
3343 | + if (empty($tax)) { |
|
3344 | 3344 | return $this->get_total_tax(); |
3345 | 3345 | } |
3346 | 3346 | |
3347 | 3347 | $taxes = $this->get_taxes(); |
3348 | - return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null; |
|
3348 | + return isset($taxes[$tax]) ? $taxes[$tax] : null; |
|
3349 | 3349 | } |
3350 | 3350 | |
3351 | 3351 | /** |
@@ -3353,11 +3353,11 @@ discard block |
||
3353 | 3353 | * |
3354 | 3354 | * @since 1.0.19 |
3355 | 3355 | */ |
3356 | - public function remove_tax( $tax ) { |
|
3356 | + public function remove_tax($tax) { |
|
3357 | 3357 | $taxes = $this->get_taxes(); |
3358 | - if ( isset( $taxes[ $tax ] ) ) { |
|
3359 | - unset( $taxes[ $tax ] ); |
|
3360 | - $this->set_prop( 'taxes', $taxes ); |
|
3358 | + if (isset($taxes[$tax])) { |
|
3359 | + unset($taxes[$tax]); |
|
3360 | + $this->set_prop('taxes', $taxes); |
|
3361 | 3361 | } |
3362 | 3362 | } |
3363 | 3363 | |
@@ -3368,17 +3368,17 @@ discard block |
||
3368 | 3368 | * @return float The recalculated subtotal |
3369 | 3369 | */ |
3370 | 3370 | public function recalculate_subtotal() { |
3371 | - $items = $this->get_items(); |
|
3371 | + $items = $this->get_items(); |
|
3372 | 3372 | $subtotal = 0; |
3373 | 3373 | $recurring = 0; |
3374 | 3374 | |
3375 | - foreach ( $items as $item ) { |
|
3375 | + foreach ($items as $item) { |
|
3376 | 3376 | $subtotal += $item->get_sub_total(); |
3377 | 3377 | $recurring += $item->get_recurring_sub_total(); |
3378 | 3378 | } |
3379 | 3379 | |
3380 | 3380 | $current = $this->is_renewal() ? $recurring : $subtotal; |
3381 | - $this->set_subtotal( $current ); |
|
3381 | + $this->set_subtotal($current); |
|
3382 | 3382 | |
3383 | 3383 | $this->totals['subtotal'] = array( |
3384 | 3384 | 'initial' => $subtotal, |
@@ -3399,14 +3399,14 @@ discard block |
||
3399 | 3399 | $discount = 0; |
3400 | 3400 | $recurring = 0; |
3401 | 3401 | |
3402 | - foreach ( $discounts as $data ) { |
|
3403 | - $discount += wpinv_sanitize_amount( $data['initial_discount'] ); |
|
3404 | - $recurring += wpinv_sanitize_amount( $data['recurring_discount'] ); |
|
3402 | + foreach ($discounts as $data) { |
|
3403 | + $discount += wpinv_sanitize_amount($data['initial_discount']); |
|
3404 | + $recurring += wpinv_sanitize_amount($data['recurring_discount']); |
|
3405 | 3405 | } |
3406 | 3406 | |
3407 | 3407 | $current = $this->is_renewal() ? $recurring : $discount; |
3408 | 3408 | |
3409 | - $this->set_total_discount( $current ); |
|
3409 | + $this->set_total_discount($current); |
|
3410 | 3410 | |
3411 | 3411 | $this->totals['discount'] = array( |
3412 | 3412 | 'initial' => $discount, |
@@ -3424,17 +3424,17 @@ discard block |
||
3424 | 3424 | * @return float The recalculated tax |
3425 | 3425 | */ |
3426 | 3426 | public function recalculate_total_tax() { |
3427 | - $taxes = $this->get_taxes(); |
|
3427 | + $taxes = $this->get_taxes(); |
|
3428 | 3428 | $tax = 0; |
3429 | 3429 | $recurring = 0; |
3430 | 3430 | |
3431 | - foreach ( $taxes as $data ) { |
|
3432 | - $tax += wpinv_sanitize_amount( $data['initial_tax'] ); |
|
3433 | - $recurring += wpinv_sanitize_amount( $data['recurring_tax'] ); |
|
3431 | + foreach ($taxes as $data) { |
|
3432 | + $tax += wpinv_sanitize_amount($data['initial_tax']); |
|
3433 | + $recurring += wpinv_sanitize_amount($data['recurring_tax']); |
|
3434 | 3434 | } |
3435 | 3435 | |
3436 | 3436 | $current = $this->is_renewal() ? $recurring : $tax; |
3437 | - $this->set_total_tax( $current ); |
|
3437 | + $this->set_total_tax($current); |
|
3438 | 3438 | |
3439 | 3439 | $this->totals['tax'] = array( |
3440 | 3440 | 'initial' => $tax, |
@@ -3456,20 +3456,20 @@ discard block |
||
3456 | 3456 | $fee = 0; |
3457 | 3457 | $recurring = 0; |
3458 | 3458 | |
3459 | - foreach ( $fees as $data ) { |
|
3460 | - $fee += wpinv_sanitize_amount( $data['initial_fee'] ); |
|
3461 | - $recurring += wpinv_sanitize_amount( $data['recurring_fee'] ); |
|
3459 | + foreach ($fees as $data) { |
|
3460 | + $fee += wpinv_sanitize_amount($data['initial_fee']); |
|
3461 | + $recurring += wpinv_sanitize_amount($data['recurring_fee']); |
|
3462 | 3462 | } |
3463 | 3463 | |
3464 | 3464 | $current = $this->is_renewal() ? $recurring : $fee; |
3465 | - $this->set_total_fees( $current ); |
|
3465 | + $this->set_total_fees($current); |
|
3466 | 3466 | |
3467 | 3467 | $this->totals['fee'] = array( |
3468 | 3468 | 'initial' => $fee, |
3469 | 3469 | 'recurring' => $recurring, |
3470 | 3470 | ); |
3471 | 3471 | |
3472 | - $this->set_total_fees( $fee ); |
|
3472 | + $this->set_total_fees($fee); |
|
3473 | 3473 | return $current; |
3474 | 3474 | } |
3475 | 3475 | |
@@ -3492,7 +3492,7 @@ discard block |
||
3492 | 3492 | */ |
3493 | 3493 | public function recalculate_totals() { |
3494 | 3494 | $this->recalculate_total(); |
3495 | - $this->save( true ); |
|
3495 | + $this->save(true); |
|
3496 | 3496 | return $this; |
3497 | 3497 | } |
3498 | 3498 | |
@@ -3510,10 +3510,10 @@ discard block |
||
3510 | 3510 | * @return int|false The new note's ID on success, false on failure. |
3511 | 3511 | * |
3512 | 3512 | */ |
3513 | - public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) { |
|
3513 | + public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) { |
|
3514 | 3514 | |
3515 | 3515 | // Bail if no note specified or this invoice is not yet saved. |
3516 | - if ( ! $note || $this->get_id() == 0 || ( ! is_user_logged_in() && ! $system ) ) { |
|
3516 | + if (!$note || $this->get_id() == 0 || (!is_user_logged_in() && !$system)) { |
|
3517 | 3517 | return false; |
3518 | 3518 | } |
3519 | 3519 | |
@@ -3521,23 +3521,23 @@ discard block |
||
3521 | 3521 | $author_email = '[email protected]'; |
3522 | 3522 | |
3523 | 3523 | // If this is an admin comment or it has been added by the user. |
3524 | - if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) { |
|
3525 | - $user = get_user_by( 'id', get_current_user_id() ); |
|
3524 | + if (is_user_logged_in() && (!$system || $added_by_user)) { |
|
3525 | + $user = get_user_by('id', get_current_user_id()); |
|
3526 | 3526 | $author = $user->display_name; |
3527 | 3527 | $author_email = $user->user_email; |
3528 | 3528 | } |
3529 | 3529 | |
3530 | - return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type ); |
|
3530 | + return getpaid_notes()->add_invoice_note($this, $note, $author, $author_email, $customer_type); |
|
3531 | 3531 | |
3532 | 3532 | } |
3533 | 3533 | |
3534 | 3534 | /** |
3535 | 3535 | * Generates a unique key for the invoice. |
3536 | 3536 | */ |
3537 | - public function generate_key( $string = '' ) { |
|
3538 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
3537 | + public function generate_key($string = '') { |
|
3538 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
3539 | 3539 | return strtolower( |
3540 | - $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) ) |
|
3540 | + $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true)) |
|
3541 | 3541 | ); |
3542 | 3542 | } |
3543 | 3543 | |
@@ -3547,11 +3547,11 @@ discard block |
||
3547 | 3547 | public function generate_number() { |
3548 | 3548 | $number = $this->get_id(); |
3549 | 3549 | |
3550 | - if ( wpinv_sequential_number_active( $this->get_post_type() ) ) { |
|
3551 | - $number = wpinv_get_next_invoice_number( $this->get_post_type() ); |
|
3550 | + if (wpinv_sequential_number_active($this->get_post_type())) { |
|
3551 | + $number = wpinv_get_next_invoice_number($this->get_post_type()); |
|
3552 | 3552 | } |
3553 | 3553 | |
3554 | - return wpinv_format_invoice_number( $number, $this->get_post_type() ); |
|
3554 | + return wpinv_format_invoice_number($number, $this->get_post_type()); |
|
3555 | 3555 | |
3556 | 3556 | } |
3557 | 3557 | |
@@ -3564,55 +3564,55 @@ discard block |
||
3564 | 3564 | // Reset status transition variable. |
3565 | 3565 | $this->status_transition = false; |
3566 | 3566 | |
3567 | - if ( $status_transition ) { |
|
3567 | + if ($status_transition) { |
|
3568 | 3568 | try { |
3569 | 3569 | |
3570 | 3570 | // Fire a hook for the status change. |
3571 | - do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition ); |
|
3571 | + do_action('getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition); |
|
3572 | 3572 | |
3573 | 3573 | // @deprecated this is deprecated and will be removed in the future. |
3574 | - do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
3574 | + do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
3575 | 3575 | |
3576 | - if ( ! empty( $status_transition['from'] ) ) { |
|
3576 | + if (!empty($status_transition['from'])) { |
|
3577 | 3577 | |
3578 | 3578 | /* translators: 1: old invoice status 2: new invoice status */ |
3579 | - $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 ) ); |
|
3579 | + $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)); |
|
3580 | 3580 | |
3581 | 3581 | // Fire another hook. |
3582 | - do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this ); |
|
3583 | - do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] ); |
|
3582 | + do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this); |
|
3583 | + do_action('getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to']); |
|
3584 | 3584 | |
3585 | 3585 | // @deprecated this is deprecated and will be removed in the future. |
3586 | - do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
3586 | + do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
3587 | 3587 | |
3588 | 3588 | // Note the transition occurred. |
3589 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] ); |
|
3589 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), false, $status_transition['manual']); |
|
3590 | 3590 | |
3591 | 3591 | // Work out if this was for a payment, and trigger a payment_status hook instead. |
3592 | 3592 | if ( |
3593 | - in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
3594 | - && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
3593 | + in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true) |
|
3594 | + && in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true) |
|
3595 | 3595 | ) { |
3596 | - do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition ); |
|
3596 | + do_action('getpaid_invoice_payment_status_changed', $this, $status_transition); |
|
3597 | 3597 | } |
3598 | 3598 | |
3599 | 3599 | // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead. |
3600 | 3600 | if ( |
3601 | - in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
3602 | - && in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
3601 | + in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'), true) |
|
3602 | + && in_array($status_transition['to'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true) |
|
3603 | 3603 | ) { |
3604 | - do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition ); |
|
3604 | + do_action('getpaid_invoice_payment_status_reversed', $this, $status_transition); |
|
3605 | 3605 | } |
3606 | 3606 | } else { |
3607 | 3607 | /* translators: %s: new invoice status */ |
3608 | - $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this ) ); |
|
3608 | + $transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to'], $this)); |
|
3609 | 3609 | |
3610 | 3610 | // Note the transition occurred. |
3611 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
3611 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']); |
|
3612 | 3612 | |
3613 | 3613 | } |
3614 | - } catch ( Exception $e ) { |
|
3615 | - $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
3614 | + } catch (Exception $e) { |
|
3615 | + $this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage()); |
|
3616 | 3616 | } |
3617 | 3617 | } |
3618 | 3618 | } |
@@ -3620,13 +3620,13 @@ discard block |
||
3620 | 3620 | /** |
3621 | 3621 | * Updates an invoice status. |
3622 | 3622 | */ |
3623 | - public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
3623 | + public function update_status($new_status = false, $note = '', $manual = false) { |
|
3624 | 3624 | |
3625 | 3625 | // Fires before updating a status. |
3626 | - do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) ); |
|
3626 | + do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit')); |
|
3627 | 3627 | |
3628 | 3628 | // Update the status. |
3629 | - $this->set_status( $new_status, $note, $manual ); |
|
3629 | + $this->set_status($new_status, $note, $manual); |
|
3630 | 3630 | |
3631 | 3631 | // Save the order. |
3632 | 3632 | return $this->save(); |
@@ -3637,18 +3637,18 @@ discard block |
||
3637 | 3637 | * @deprecated |
3638 | 3638 | */ |
3639 | 3639 | public function refresh_item_ids() { |
3640 | - $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) ); |
|
3641 | - update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids ); |
|
3640 | + $item_ids = implode(',', array_unique(array_keys($this->get_items()))); |
|
3641 | + update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids); |
|
3642 | 3642 | } |
3643 | 3643 | |
3644 | 3644 | /** |
3645 | 3645 | * @deprecated |
3646 | 3646 | */ |
3647 | - public function update_items( $temp = false ) { |
|
3647 | + public function update_items($temp = false) { |
|
3648 | 3648 | |
3649 | - $this->set_items( $this->get_items() ); |
|
3649 | + $this->set_items($this->get_items()); |
|
3650 | 3650 | |
3651 | - if ( ! $temp ) { |
|
3651 | + if (!$temp) { |
|
3652 | 3652 | $this->save(); |
3653 | 3653 | } |
3654 | 3654 | |
@@ -3662,11 +3662,11 @@ discard block |
||
3662 | 3662 | |
3663 | 3663 | $discount_code = $this->get_discount_code(); |
3664 | 3664 | |
3665 | - if ( empty( $discount_code ) ) { |
|
3665 | + if (empty($discount_code)) { |
|
3666 | 3666 | return false; |
3667 | 3667 | } |
3668 | 3668 | |
3669 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
3669 | + $discount = wpinv_get_discount_obj($discount_code); |
|
3670 | 3670 | |
3671 | 3671 | // Ensure it is active. |
3672 | 3672 | return $discount->exists(); |
@@ -3677,7 +3677,7 @@ discard block |
||
3677 | 3677 | * Refunds an invoice. |
3678 | 3678 | */ |
3679 | 3679 | public function refund() { |
3680 | - $this->set_status( 'wpi-refunded' ); |
|
3680 | + $this->set_status('wpi-refunded'); |
|
3681 | 3681 | $this->save(); |
3682 | 3682 | } |
3683 | 3683 | |
@@ -3686,56 +3686,56 @@ discard block |
||
3686 | 3686 | * |
3687 | 3687 | * @param string $transaction_id |
3688 | 3688 | */ |
3689 | - public function mark_paid( $transaction_id = null, $note = '' ) { |
|
3689 | + public function mark_paid($transaction_id = null, $note = '') { |
|
3690 | 3690 | |
3691 | 3691 | // Set the transaction id. |
3692 | - if ( empty( $transaction_id ) ) { |
|
3692 | + if (empty($transaction_id)) { |
|
3693 | 3693 | $transaction_id = $this->generate_key('trans_'); |
3694 | 3694 | } |
3695 | 3695 | |
3696 | - if ( ! $this->get_transaction_id() ) { |
|
3697 | - $this->set_transaction_id( $transaction_id ); |
|
3696 | + if (!$this->get_transaction_id()) { |
|
3697 | + $this->set_transaction_id($transaction_id); |
|
3698 | 3698 | } |
3699 | 3699 | |
3700 | - if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) { |
|
3700 | + if ($this->is_paid() && 'wpi-processing' != $this->get_status()) { |
|
3701 | 3701 | return $this->save(); |
3702 | 3702 | } |
3703 | 3703 | |
3704 | 3704 | // Set the completed date. |
3705 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
3705 | + $this->set_date_completed(current_time('mysql')); |
|
3706 | 3706 | |
3707 | 3707 | // Set the new status. |
3708 | - if ( $this->is_renewal() ) { |
|
3708 | + if ($this->is_renewal()) { |
|
3709 | 3709 | |
3710 | 3710 | $_note = sprintf( |
3711 | - __( 'Renewed via %s', 'invoicing' ), |
|
3712 | - $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
3711 | + __('Renewed 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( 'wpi-renewal', $_note ); |
|
3719 | + $this->set_status('wpi-renewal', $_note); |
|
3720 | 3720 | |
3721 | 3721 | } else { |
3722 | 3722 | |
3723 | 3723 | $_note = sprintf( |
3724 | - __( 'Paid via %s', 'invoicing' ), |
|
3725 | - $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
3724 | + __('Paid via %s', 'invoicing'), |
|
3725 | + $this->get_gateway_title() . empty($note) ? '' : " ($note)" |
|
3726 | 3726 | ); |
3727 | 3727 | |
3728 | - if ( 'none' == $this->get_gateway() ) { |
|
3728 | + if ('none' == $this->get_gateway()) { |
|
3729 | 3729 | $_note = $note; |
3730 | 3730 | } |
3731 | 3731 | |
3732 | - $this->set_status( 'publish',$_note ); |
|
3732 | + $this->set_status('publish', $_note); |
|
3733 | 3733 | |
3734 | 3734 | } |
3735 | 3735 | |
3736 | 3736 | // Set checkout mode. |
3737 | - $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live'; |
|
3738 | - $this->set_mode( $mode ); |
|
3737 | + $mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live'; |
|
3738 | + $this->set_mode($mode); |
|
3739 | 3739 | |
3740 | 3740 | // Save the invoice. |
3741 | 3741 | $this->save(); |
@@ -3761,9 +3761,9 @@ discard block |
||
3761 | 3761 | * Clears the subscription's cache. |
3762 | 3762 | */ |
3763 | 3763 | public function clear_cache() { |
3764 | - wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' ); |
|
3765 | - wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' ); |
|
3766 | - wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' ); |
|
3764 | + wp_cache_delete($this->get_key(), 'getpaid_invoice_keys_to_invoice_ids'); |
|
3765 | + wp_cache_delete($this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids'); |
|
3766 | + wp_cache_delete($this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids'); |
|
3767 | 3767 | } |
3768 | 3768 | |
3769 | 3769 | } |