@@ -11,93 +11,93 @@ |
||
11 | 11 | |
12 | 12 | class InstalledVersions |
13 | 13 | { |
14 | -private static $installed = array ( |
|
14 | +private static $installed = array( |
|
15 | 15 | 'root' => |
16 | - array ( |
|
16 | + array( |
|
17 | 17 | 'pretty_version' => 'dev-master', |
18 | 18 | 'version' => 'dev-master', |
19 | 19 | 'aliases' => |
20 | - array ( |
|
20 | + array( |
|
21 | 21 | ), |
22 | 22 | 'reference' => 'fb4f29a148b1524852836f00b2884f287f708067', |
23 | 23 | 'name' => 'ayecode/invoicing', |
24 | 24 | ), |
25 | 25 | 'versions' => |
26 | - array ( |
|
26 | + array( |
|
27 | 27 | 'ayecode/ayecode-connect-helper' => |
28 | - array ( |
|
28 | + array( |
|
29 | 29 | 'pretty_version' => '1.0.3', |
30 | 30 | 'version' => '1.0.3.0', |
31 | 31 | 'aliases' => |
32 | - array ( |
|
32 | + array( |
|
33 | 33 | ), |
34 | 34 | 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
35 | 35 | ), |
36 | 36 | 'ayecode/invoicing' => |
37 | - array ( |
|
37 | + array( |
|
38 | 38 | 'pretty_version' => 'dev-master', |
39 | 39 | 'version' => 'dev-master', |
40 | 40 | 'aliases' => |
41 | - array ( |
|
41 | + array( |
|
42 | 42 | ), |
43 | 43 | 'reference' => 'fb4f29a148b1524852836f00b2884f287f708067', |
44 | 44 | ), |
45 | 45 | 'ayecode/wp-ayecode-ui' => |
46 | - array ( |
|
46 | + array( |
|
47 | 47 | 'pretty_version' => '0.1.46', |
48 | 48 | 'version' => '0.1.46.0', |
49 | 49 | 'aliases' => |
50 | - array ( |
|
50 | + array( |
|
51 | 51 | ), |
52 | 52 | 'reference' => '8b9825d9fe52f6da57302358df1a920eec3bace3', |
53 | 53 | ), |
54 | 54 | 'ayecode/wp-font-awesome-settings' => |
55 | - array ( |
|
55 | + array( |
|
56 | 56 | 'pretty_version' => '1.0.12', |
57 | 57 | 'version' => '1.0.12.0', |
58 | 58 | 'aliases' => |
59 | - array ( |
|
59 | + array( |
|
60 | 60 | ), |
61 | 61 | 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
62 | 62 | ), |
63 | 63 | 'ayecode/wp-super-duper' => |
64 | - array ( |
|
64 | + array( |
|
65 | 65 | 'pretty_version' => '1.0.24', |
66 | 66 | 'version' => '1.0.24.0', |
67 | 67 | 'aliases' => |
68 | - array ( |
|
68 | + array( |
|
69 | 69 | ), |
70 | 70 | 'reference' => '4eaa2f6f6e1a29ff71f7fdbd694892d7479ef754', |
71 | 71 | ), |
72 | 72 | 'composer/installers' => |
73 | - array ( |
|
73 | + array( |
|
74 | 74 | 'pretty_version' => 'v1.10.0', |
75 | 75 | 'version' => '1.10.0.0', |
76 | 76 | 'aliases' => |
77 | - array ( |
|
77 | + array( |
|
78 | 78 | ), |
79 | 79 | 'reference' => '1a0357fccad9d1cc1ea0c9a05b8847fbccccb78d', |
80 | 80 | ), |
81 | 81 | 'maxmind-db/reader' => |
82 | - array ( |
|
82 | + array( |
|
83 | 83 | 'pretty_version' => 'v1.6.0', |
84 | 84 | 'version' => '1.6.0.0', |
85 | 85 | 'aliases' => |
86 | - array ( |
|
86 | + array( |
|
87 | 87 | ), |
88 | 88 | 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
89 | 89 | ), |
90 | 90 | 'roundcube/plugin-installer' => |
91 | - array ( |
|
91 | + array( |
|
92 | 92 | 'replaced' => |
93 | - array ( |
|
93 | + array( |
|
94 | 94 | 0 => '*', |
95 | 95 | ), |
96 | 96 | ), |
97 | 97 | 'shama/baton' => |
98 | - array ( |
|
98 | + array( |
|
99 | 99 | 'replaced' => |
100 | - array ( |
|
100 | + array( |
|
101 | 101 | 0 => '*', |
102 | 102 | ), |
103 | 103 | ), |
@@ -1,90 +1,90 @@ |
||
1 | -<?php return array ( |
|
1 | +<?php return array( |
|
2 | 2 | 'root' => |
3 | - array ( |
|
3 | + array( |
|
4 | 4 | 'pretty_version' => 'dev-master', |
5 | 5 | 'version' => 'dev-master', |
6 | 6 | 'aliases' => |
7 | - array ( |
|
7 | + array( |
|
8 | 8 | ), |
9 | 9 | 'reference' => 'fb4f29a148b1524852836f00b2884f287f708067', |
10 | 10 | 'name' => 'ayecode/invoicing', |
11 | 11 | ), |
12 | 12 | 'versions' => |
13 | - array ( |
|
13 | + array( |
|
14 | 14 | 'ayecode/ayecode-connect-helper' => |
15 | - array ( |
|
15 | + array( |
|
16 | 16 | 'pretty_version' => '1.0.3', |
17 | 17 | 'version' => '1.0.3.0', |
18 | 18 | 'aliases' => |
19 | - array ( |
|
19 | + array( |
|
20 | 20 | ), |
21 | 21 | 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
22 | 22 | ), |
23 | 23 | 'ayecode/invoicing' => |
24 | - array ( |
|
24 | + array( |
|
25 | 25 | 'pretty_version' => 'dev-master', |
26 | 26 | 'version' => 'dev-master', |
27 | 27 | 'aliases' => |
28 | - array ( |
|
28 | + array( |
|
29 | 29 | ), |
30 | 30 | 'reference' => 'fb4f29a148b1524852836f00b2884f287f708067', |
31 | 31 | ), |
32 | 32 | 'ayecode/wp-ayecode-ui' => |
33 | - array ( |
|
33 | + array( |
|
34 | 34 | 'pretty_version' => '0.1.46', |
35 | 35 | 'version' => '0.1.46.0', |
36 | 36 | 'aliases' => |
37 | - array ( |
|
37 | + array( |
|
38 | 38 | ), |
39 | 39 | 'reference' => '8b9825d9fe52f6da57302358df1a920eec3bace3', |
40 | 40 | ), |
41 | 41 | 'ayecode/wp-font-awesome-settings' => |
42 | - array ( |
|
42 | + array( |
|
43 | 43 | 'pretty_version' => '1.0.12', |
44 | 44 | 'version' => '1.0.12.0', |
45 | 45 | 'aliases' => |
46 | - array ( |
|
46 | + array( |
|
47 | 47 | ), |
48 | 48 | 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
49 | 49 | ), |
50 | 50 | 'ayecode/wp-super-duper' => |
51 | - array ( |
|
51 | + array( |
|
52 | 52 | 'pretty_version' => '1.0.24', |
53 | 53 | 'version' => '1.0.24.0', |
54 | 54 | 'aliases' => |
55 | - array ( |
|
55 | + array( |
|
56 | 56 | ), |
57 | 57 | 'reference' => '4eaa2f6f6e1a29ff71f7fdbd694892d7479ef754', |
58 | 58 | ), |
59 | 59 | 'composer/installers' => |
60 | - array ( |
|
60 | + array( |
|
61 | 61 | 'pretty_version' => 'v1.10.0', |
62 | 62 | 'version' => '1.10.0.0', |
63 | 63 | 'aliases' => |
64 | - array ( |
|
64 | + array( |
|
65 | 65 | ), |
66 | 66 | 'reference' => '1a0357fccad9d1cc1ea0c9a05b8847fbccccb78d', |
67 | 67 | ), |
68 | 68 | 'maxmind-db/reader' => |
69 | - array ( |
|
69 | + array( |
|
70 | 70 | 'pretty_version' => 'v1.6.0', |
71 | 71 | 'version' => '1.6.0.0', |
72 | 72 | 'aliases' => |
73 | - array ( |
|
73 | + array( |
|
74 | 74 | ), |
75 | 75 | 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
76 | 76 | ), |
77 | 77 | 'roundcube/plugin-installer' => |
78 | - array ( |
|
78 | + array( |
|
79 | 79 | 'replaced' => |
80 | - array ( |
|
80 | + array( |
|
81 | 81 | 0 => '*', |
82 | 82 | ), |
83 | 83 | ), |
84 | 84 | 'shama/baton' => |
85 | - array ( |
|
85 | + array( |
|
86 | 86 | 'replaced' => |
87 | - array ( |
|
87 | + array( |
|
88 | 88 | 0 => '*', |
89 | 89 | ), |
90 | 90 | ), |
@@ -6,39 +6,39 @@ |
||
6 | 6 | /** |
7 | 7 | * Bail if we are not in WP. |
8 | 8 | */ |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
9 | +if (!defined('ABSPATH')) { |
|
10 | 10 | exit; |
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
14 | 14 | * Set the version only if its the current newest while loading. |
15 | 15 | */ |
16 | -add_action('after_setup_theme', function () { |
|
17 | - global $ayecode_ui_version,$ayecode_ui_file_key; |
|
16 | +add_action('after_setup_theme', function() { |
|
17 | + global $ayecode_ui_version, $ayecode_ui_file_key; |
|
18 | 18 | $this_version = "0.1.46"; |
19 | - if(version_compare($this_version , $ayecode_ui_version, '>')){ |
|
20 | - $ayecode_ui_version = $this_version ; |
|
21 | - $ayecode_ui_file_key = wp_hash( __FILE__ ); |
|
19 | + if (version_compare($this_version, $ayecode_ui_version, '>')) { |
|
20 | + $ayecode_ui_version = $this_version; |
|
21 | + $ayecode_ui_file_key = wp_hash(__FILE__); |
|
22 | 22 | } |
23 | 23 | },0); |
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Load this version of WP Bootstrap Settings only if the file hash is the current one. |
27 | 27 | */ |
28 | -add_action('after_setup_theme', function () { |
|
28 | +add_action('after_setup_theme', function() { |
|
29 | 29 | global $ayecode_ui_file_key; |
30 | - if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){ |
|
31 | - include_once( dirname( __FILE__ ) . '/includes/class-aui.php' ); |
|
32 | - include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' ); |
|
30 | + if ($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash(__FILE__)) { |
|
31 | + include_once(dirname(__FILE__) . '/includes/class-aui.php'); |
|
32 | + include_once(dirname(__FILE__) . '/includes/ayecode-ui-settings.php'); |
|
33 | 33 | } |
34 | 34 | },1); |
35 | 35 | |
36 | 36 | /** |
37 | 37 | * Add the function that calls the class. |
38 | 38 | */ |
39 | -if(!function_exists('aui')){ |
|
40 | - function aui(){ |
|
41 | - if(!class_exists("AUI",false)){ |
|
39 | +if (!function_exists('aui')) { |
|
40 | + function aui() { |
|
41 | + if (!class_exists("AUI", false)) { |
|
42 | 42 | return false; |
43 | 43 | } |
44 | 44 | return AUI::instance(); |
@@ -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 | * Returns the errors as html |
@@ -15,36 +15,36 @@ discard block |
||
15 | 15 | * @param bool $wrap whether or not to wrap the errors. |
16 | 16 | * @since 1.0.19 |
17 | 17 | */ |
18 | -function getpaid_get_errors_html( $clear = true, $wrap = true ) { |
|
18 | +function getpaid_get_errors_html($clear = true, $wrap = true) { |
|
19 | 19 | |
20 | 20 | $errors = ''; |
21 | - foreach ( wpinv_get_errors() as $id => $error ) { |
|
22 | - $type = 'error'; |
|
21 | + foreach (wpinv_get_errors() as $id => $error) { |
|
22 | + $type = 'error'; |
|
23 | 23 | |
24 | - if ( is_array( $error ) ) { |
|
24 | + if (is_array($error)) { |
|
25 | 25 | $type = $error['type']; |
26 | 26 | $error = $error['text']; |
27 | 27 | } |
28 | 28 | |
29 | - if ( $wrap ) { |
|
29 | + if ($wrap) { |
|
30 | 30 | |
31 | 31 | $errors .= aui()->alert( |
32 | 32 | array( |
33 | - 'content' => wp_kses_post( $error ), |
|
33 | + 'content' => wp_kses_post($error), |
|
34 | 34 | 'type' => $type, |
35 | 35 | ) |
36 | 36 | ); |
37 | 37 | |
38 | 38 | } else { |
39 | 39 | |
40 | - $id = esc_attr( $id ); |
|
41 | - $error = wp_kses_post( $error ); |
|
40 | + $id = esc_attr($id); |
|
41 | + $error = wp_kses_post($error); |
|
42 | 42 | $errors .= "<div data-code='$id'>$error</div>"; |
43 | 43 | } |
44 | 44 | |
45 | 45 | } |
46 | 46 | |
47 | - if ( $clear ){ |
|
47 | + if ($clear) { |
|
48 | 48 | wpinv_clear_errors(); |
49 | 49 | } |
50 | 50 | |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | * @return array |
66 | 66 | */ |
67 | 67 | function wpinv_get_errors() { |
68 | - $errors = getpaid_session()->get( 'wpinv_errors' ); |
|
69 | - return is_array( $errors ) ? $errors : array(); |
|
68 | + $errors = getpaid_session()->get('wpinv_errors'); |
|
69 | + return is_array($errors) ? $errors : array(); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -76,15 +76,15 @@ discard block |
||
76 | 76 | * @param string $error_message The error message. |
77 | 77 | * @param string $type Either error, info, warning, primary, dark, light or success. |
78 | 78 | */ |
79 | -function wpinv_set_error( $error_id, $error_message, $type = 'error' ) { |
|
79 | +function wpinv_set_error($error_id, $error_message, $type = 'error') { |
|
80 | 80 | |
81 | 81 | $errors = wpinv_get_errors(); |
82 | - $errors[ $error_id ] = array( |
|
82 | + $errors[$error_id] = array( |
|
83 | 83 | 'type' => $type, |
84 | 84 | 'text' => $error_message, |
85 | 85 | ); |
86 | 86 | |
87 | - getpaid_session()->set( 'wpinv_errors', $errors ); |
|
87 | + getpaid_session()->set('wpinv_errors', $errors); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * |
93 | 93 | */ |
94 | 94 | function wpinv_has_errors() { |
95 | - return count( wpinv_get_errors() ) > 0; |
|
95 | + return count(wpinv_get_errors()) > 0; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -100,21 +100,21 @@ discard block |
||
100 | 100 | * |
101 | 101 | */ |
102 | 102 | function wpinv_clear_errors() { |
103 | - getpaid_session()->set( 'wpinv_errors', null ); |
|
103 | + getpaid_session()->set('wpinv_errors', null); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
107 | 107 | * Clears a single error. |
108 | 108 | * |
109 | 109 | */ |
110 | -function wpinv_unset_error( $error_id ) { |
|
110 | +function wpinv_unset_error($error_id) { |
|
111 | 111 | $errors = wpinv_get_errors(); |
112 | 112 | |
113 | - if ( isset( $errors[ $error_id ] ) ) { |
|
114 | - unset( $errors[ $error_id ] ); |
|
113 | + if (isset($errors[$error_id])) { |
|
114 | + unset($errors[$error_id]); |
|
115 | 115 | } |
116 | 116 | |
117 | - getpaid_session()->set( 'wpinv_errors', $errors ); |
|
117 | + getpaid_session()->set('wpinv_errors', $errors); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -125,15 +125,15 @@ discard block |
||
125 | 125 | * @param string $message Message to log. |
126 | 126 | * @param string $version Version the message was added in. |
127 | 127 | */ |
128 | -function getpaid_doing_it_wrong( $function, $message, $version ) { |
|
128 | +function getpaid_doing_it_wrong($function, $message, $version) { |
|
129 | 129 | |
130 | 130 | $message .= ' Backtrace: ' . wp_debug_backtrace_summary(); |
131 | 131 | |
132 | - if ( wp_doing_ajax() || defined( 'REST_REQUEST' ) ) { |
|
133 | - do_action( 'doing_it_wrong_run', $function, $message, $version ); |
|
134 | - error_log( "{$function} was called incorrectly. {$message}. This message was added in version {$version}." ); |
|
132 | + if (wp_doing_ajax() || defined('REST_REQUEST')) { |
|
133 | + do_action('doing_it_wrong_run', $function, $message, $version); |
|
134 | + error_log("{$function} was called incorrectly. {$message}. This message was added in version {$version}."); |
|
135 | 135 | } else { |
136 | - _doing_it_wrong( $function, $message, $version ); |
|
136 | + _doing_it_wrong($function, $message, $version); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | } |
@@ -147,42 +147,42 @@ discard block |
||
147 | 147 | * @param string $line The line that contains the error. |
148 | 148 | * @param bool $exit Whether or not to exit function execution. |
149 | 149 | */ |
150 | -function wpinv_error_log( $log, $title = '', $file = '', $line = '', $exit = false ) { |
|
150 | +function wpinv_error_log($log, $title = '', $file = '', $line = '', $exit = false) { |
|
151 | 151 | |
152 | - if ( true === apply_filters( 'wpinv_log_errors', true ) ) { |
|
152 | + if (true === apply_filters('wpinv_log_errors', true)) { |
|
153 | 153 | |
154 | 154 | // Ensure the log is a scalar. |
155 | - if ( ! is_scalar( $log ) ) { |
|
156 | - $log = print_r( $log, true ); |
|
155 | + if (!is_scalar($log)) { |
|
156 | + $log = print_r($log, true); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | // Add title. |
160 | - if ( ! empty( $title ) ) { |
|
161 | - $log = $title . ' ' . trim( $log ); |
|
160 | + if (!empty($title)) { |
|
161 | + $log = $title . ' ' . trim($log); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | // Add the file to the label. |
165 | - if ( ! empty( $file ) ) { |
|
165 | + if (!empty($file)) { |
|
166 | 166 | $log .= ' in ' . $file; |
167 | 167 | } |
168 | 168 | |
169 | 169 | // Add the line number to the label. |
170 | - if ( ! empty( $line ) ) { |
|
170 | + if (!empty($line)) { |
|
171 | 171 | $log .= ' on line ' . $line; |
172 | 172 | } |
173 | 173 | |
174 | 174 | // Log the message. |
175 | - error_log( trim ( $log ) ); |
|
175 | + error_log(trim($log)); |
|
176 | 176 | |
177 | 177 | // ... and a backtrace. |
178 | - if ( false !== $title && false !== $file ) { |
|
179 | - error_log( 'Backtrace ' . wp_debug_backtrace_summary() ); |
|
178 | + if (false !== $title && false !== $file) { |
|
179 | + error_log('Backtrace ' . wp_debug_backtrace_summary()); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | } |
183 | 183 | |
184 | 184 | // Maybe exit. |
185 | - if ( $exit ) { |
|
185 | + if ($exit) { |
|
186 | 186 | exit; |
187 | 187 | } |
188 | 188 |
@@ -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 | * Paypal Payment Gateway IPN handler class. |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * |
32 | 32 | * @param GetPaid_Paypal_Gateway $gateway |
33 | 33 | */ |
34 | - public function __construct( $gateway ) { |
|
34 | + public function __construct($gateway) { |
|
35 | 35 | $this->gateway = $gateway; |
36 | 36 | $this->verify_ipn(); |
37 | 37 | } |
@@ -43,37 +43,37 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function verify_ipn() { |
45 | 45 | |
46 | - wpinv_error_log( 'GetPaid PayPal IPN Handler', false ); |
|
46 | + wpinv_error_log('GetPaid PayPal IPN Handler', false); |
|
47 | 47 | |
48 | 48 | // Validate the IPN. |
49 | - if ( empty( $_POST ) || ! $this->validate_ipn() ) { |
|
50 | - wp_die( 'PayPal IPN Request Failure', 500 ); |
|
49 | + if (empty($_POST) || !$this->validate_ipn()) { |
|
50 | + wp_die('PayPal IPN Request Failure', 500); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | // Process the IPN. |
54 | - $posted = wp_unslash( $_POST ); |
|
55 | - $invoice = $this->get_ipn_invoice( $posted ); |
|
54 | + $posted = wp_unslash($_POST); |
|
55 | + $invoice = $this->get_ipn_invoice($posted); |
|
56 | 56 | |
57 | 57 | // Abort if it was not paid by our gateway. |
58 | - if ( $this->id != $invoice->get_gateway() ) { |
|
59 | - wpinv_error_log( 'Aborting, Invoice was not paid via PayPal', false ); |
|
60 | - wp_die( 'Invoice not paid via PayPal', 200 ); |
|
58 | + if ($this->id != $invoice->get_gateway()) { |
|
59 | + wpinv_error_log('Aborting, Invoice was not paid via PayPal', false); |
|
60 | + wp_die('Invoice not paid via PayPal', 200); |
|
61 | 61 | } |
62 | 62 | |
63 | - $posted['payment_status'] = isset( $posted['payment_status'] ) ? sanitize_key( strtolower( $posted['payment_status'] ) ) : ''; |
|
64 | - $posted['txn_type'] = sanitize_key( strtolower( $posted['txn_type'] ) ); |
|
63 | + $posted['payment_status'] = isset($posted['payment_status']) ? sanitize_key(strtolower($posted['payment_status'])) : ''; |
|
64 | + $posted['txn_type'] = sanitize_key(strtolower($posted['txn_type'])); |
|
65 | 65 | |
66 | - wpinv_error_log( 'Payment status:' . $posted['payment_status'], false ); |
|
67 | - wpinv_error_log( 'IPN Type:' . $posted['txn_type'], false ); |
|
66 | + wpinv_error_log('Payment status:' . $posted['payment_status'], false); |
|
67 | + wpinv_error_log('IPN Type:' . $posted['txn_type'], false); |
|
68 | 68 | |
69 | - if ( method_exists( $this, 'ipn_txn_' . $posted['txn_type'] ) ) { |
|
70 | - call_user_func( array( $this, 'ipn_txn_' . $posted['txn_type'] ), $invoice, $posted ); |
|
71 | - wpinv_error_log( 'Done processing IPN', false ); |
|
72 | - wp_die( 'Processed', 200 ); |
|
69 | + if (method_exists($this, 'ipn_txn_' . $posted['txn_type'])) { |
|
70 | + call_user_func(array($this, 'ipn_txn_' . $posted['txn_type']), $invoice, $posted); |
|
71 | + wpinv_error_log('Done processing IPN', false); |
|
72 | + wp_die('Processed', 200); |
|
73 | 73 | } |
74 | 74 | |
75 | - wpinv_error_log( 'Aborting, Unsupported IPN type:' . $posted['txn_type'], false ); |
|
76 | - wp_die( 'Unsupported IPN type', 200 ); |
|
75 | + wpinv_error_log('Aborting, Unsupported IPN type:' . $posted['txn_type'], false); |
|
76 | + wp_die('Unsupported IPN type', 200); |
|
77 | 77 | |
78 | 78 | } |
79 | 79 | |
@@ -83,22 +83,22 @@ discard block |
||
83 | 83 | * @param array $posted |
84 | 84 | * @return WPInv_Invoice |
85 | 85 | */ |
86 | - protected function get_ipn_invoice( $posted ) { |
|
86 | + protected function get_ipn_invoice($posted) { |
|
87 | 87 | |
88 | - wpinv_error_log( 'Retrieving PayPal IPN Response Invoice', false ); |
|
88 | + wpinv_error_log('Retrieving PayPal IPN Response Invoice', false); |
|
89 | 89 | |
90 | - if ( ! empty( $posted['custom'] ) ) { |
|
91 | - $invoice = new WPInv_Invoice( $posted['custom'] ); |
|
90 | + if (!empty($posted['custom'])) { |
|
91 | + $invoice = new WPInv_Invoice($posted['custom']); |
|
92 | 92 | |
93 | - if ( $invoice->exists() ) { |
|
94 | - wpinv_error_log( 'Found invoice #' . $invoice->get_number(), false ); |
|
93 | + if ($invoice->exists()) { |
|
94 | + wpinv_error_log('Found invoice #' . $invoice->get_number(), false); |
|
95 | 95 | return $invoice; |
96 | 96 | } |
97 | 97 | |
98 | 98 | } |
99 | 99 | |
100 | - wpinv_error_log( 'Could not retrieve the associated invoice.', false ); |
|
101 | - wp_die( 'Could not retrieve the associated invoice.', 200 ); |
|
100 | + wpinv_error_log('Could not retrieve the associated invoice.', false); |
|
101 | + wp_die('Could not retrieve the associated invoice.', 200); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -106,14 +106,14 @@ discard block |
||
106 | 106 | */ |
107 | 107 | protected function validate_ipn() { |
108 | 108 | |
109 | - wpinv_error_log( 'Validating PayPal IPN response', false ); |
|
109 | + wpinv_error_log('Validating PayPal IPN response', false); |
|
110 | 110 | |
111 | 111 | // Retrieve the associated invoice. |
112 | - $posted = wp_unslash( $_POST ); |
|
113 | - $invoice = $this->get_ipn_invoice( $posted ); |
|
112 | + $posted = wp_unslash($_POST); |
|
113 | + $invoice = $this->get_ipn_invoice($posted); |
|
114 | 114 | |
115 | - if ( $this->gateway->is_sandbox( $invoice ) ) { |
|
116 | - wpinv_error_log( $posted, 'Invoice was processed in sandbox hence logging the posted data', false ); |
|
115 | + if ($this->gateway->is_sandbox($invoice)) { |
|
116 | + wpinv_error_log($posted, 'Invoice was processed in sandbox hence logging the posted data', false); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | // Validate the IPN. |
@@ -130,20 +130,20 @@ discard block |
||
130 | 130 | ); |
131 | 131 | |
132 | 132 | // Post back to get a response. |
133 | - $response = wp_safe_remote_post( $this->gateway->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params ); |
|
133 | + $response = wp_safe_remote_post($this->gateway->is_sandbox($invoice) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params); |
|
134 | 134 | |
135 | 135 | // Check to see if the request was valid. |
136 | - if ( ! is_wp_error( $response ) && $response['response']['code'] < 300 && strstr( $response['body'], 'VERIFIED' ) ) { |
|
137 | - wpinv_error_log( 'Received valid response from PayPal IPN: ' . $response['body'], false ); |
|
136 | + if (!is_wp_error($response) && $response['response']['code'] < 300 && strstr($response['body'], 'VERIFIED')) { |
|
137 | + wpinv_error_log('Received valid response from PayPal IPN: ' . $response['body'], false); |
|
138 | 138 | return true; |
139 | 139 | } |
140 | 140 | |
141 | - if ( is_wp_error( $response ) ) { |
|
142 | - wpinv_error_log( $response->get_error_message(), 'Received invalid response from PayPal IPN' ); |
|
141 | + if (is_wp_error($response)) { |
|
142 | + wpinv_error_log($response->get_error_message(), 'Received invalid response from PayPal IPN'); |
|
143 | 143 | return false; |
144 | 144 | } |
145 | 145 | |
146 | - wpinv_error_log( $response['body'], 'Received invalid response from PayPal IPN' ); |
|
146 | + wpinv_error_log($response['body'], 'Received invalid response from PayPal IPN'); |
|
147 | 147 | return false; |
148 | 148 | |
149 | 149 | } |
@@ -154,17 +154,17 @@ discard block |
||
154 | 154 | * @param WPInv_Invoice $invoice Invoice object. |
155 | 155 | * @param string $currency currency to validate. |
156 | 156 | */ |
157 | - protected function validate_ipn_currency( $invoice, $currency ) { |
|
157 | + protected function validate_ipn_currency($invoice, $currency) { |
|
158 | 158 | |
159 | - if ( strtolower( $invoice->get_currency() ) !== strtolower( $currency ) ) { |
|
159 | + if (strtolower($invoice->get_currency()) !== strtolower($currency)) { |
|
160 | 160 | |
161 | 161 | /* translators: %s: currency code. */ |
162 | - $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal currencies do not match (code %s).', 'invoicing' ), $currency ) ); |
|
162 | + $invoice->update_status('wpi-processing', sprintf(__('Validation error: PayPal currencies do not match (code %s).', 'invoicing'), $currency)); |
|
163 | 163 | |
164 | - wpinv_error_log( "Currencies do not match: {$currency} instead of {$invoice->get_currency()}", 'IPN Error', __FILE__, __LINE__, true ); |
|
164 | + wpinv_error_log("Currencies do not match: {$currency} instead of {$invoice->get_currency()}", 'IPN Error', __FILE__, __LINE__, true); |
|
165 | 165 | } |
166 | 166 | |
167 | - wpinv_error_log( $currency, 'Validated IPN Currency', false ); |
|
167 | + wpinv_error_log($currency, 'Validated IPN Currency', false); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
@@ -173,16 +173,16 @@ discard block |
||
173 | 173 | * @param WPInv_Invoice $invoice Invoice object. |
174 | 174 | * @param float $amount amount to validate. |
175 | 175 | */ |
176 | - protected function validate_ipn_amount( $invoice, $amount ) { |
|
177 | - if ( number_format( $invoice->get_total(), 2, '.', '' ) !== number_format( $amount, 2, '.', '' ) ) { |
|
176 | + protected function validate_ipn_amount($invoice, $amount) { |
|
177 | + if (number_format($invoice->get_total(), 2, '.', '') !== number_format($amount, 2, '.', '')) { |
|
178 | 178 | |
179 | 179 | /* translators: %s: Amount. */ |
180 | - $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal amounts do not match (gross %s).', 'invoicing' ), $amount ) ); |
|
180 | + $invoice->update_status('wpi-processing', sprintf(__('Validation error: PayPal amounts do not match (gross %s).', 'invoicing'), $amount)); |
|
181 | 181 | |
182 | - wpinv_error_log( "Amounts do not match: {$amount} instead of {$invoice->get_total()}", 'IPN Error', __FILE__, __LINE__, true ); |
|
182 | + wpinv_error_log("Amounts do not match: {$amount} instead of {$invoice->get_total()}", 'IPN Error', __FILE__, __LINE__, true); |
|
183 | 183 | } |
184 | 184 | |
185 | - wpinv_error_log( $amount, 'Validated IPN Amount', false ); |
|
185 | + wpinv_error_log($amount, 'Validated IPN Amount', false); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -191,19 +191,19 @@ discard block |
||
191 | 191 | * @param WPInv_Invoice $invoice Invoice object. |
192 | 192 | * @param string $receiver_email Email to validate. |
193 | 193 | */ |
194 | - protected function validate_ipn_receiver_email( $invoice, $receiver_email ) { |
|
195 | - $paypal_email = wpinv_get_option( 'paypal_email' ); |
|
194 | + protected function validate_ipn_receiver_email($invoice, $receiver_email) { |
|
195 | + $paypal_email = wpinv_get_option('paypal_email'); |
|
196 | 196 | |
197 | - if ( strcasecmp( trim( $receiver_email ), trim( $paypal_email ) ) !== 0 ) { |
|
198 | - wpinv_record_gateway_error( 'IPN Error', "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}" ); |
|
197 | + if (strcasecmp(trim($receiver_email), trim($paypal_email)) !== 0) { |
|
198 | + wpinv_record_gateway_error('IPN Error', "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}"); |
|
199 | 199 | |
200 | 200 | /* translators: %s: email address . */ |
201 | - $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal IPN response from a different email address (%s).', 'invoicing' ), $receiver_email ) ); |
|
201 | + $invoice->update_status('wpi-processing', sprintf(__('Validation error: PayPal IPN response from a different email address (%s).', 'invoicing'), $receiver_email)); |
|
202 | 202 | |
203 | - return wpinv_error_log( "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}", 'IPN Error', __FILE__, __LINE__, true ); |
|
203 | + return wpinv_error_log("IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}", 'IPN Error', __FILE__, __LINE__, true); |
|
204 | 204 | } |
205 | 205 | |
206 | - wpinv_error_log( 'Validated PayPal Email', false ); |
|
206 | + wpinv_error_log('Validated PayPal Email', false); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
@@ -212,68 +212,68 @@ discard block |
||
212 | 212 | * @param WPInv_Invoice $invoice Invoice object. |
213 | 213 | * @param array $posted Posted data. |
214 | 214 | */ |
215 | - protected function ipn_txn_web_accept( $invoice, $posted ) { |
|
215 | + protected function ipn_txn_web_accept($invoice, $posted) { |
|
216 | 216 | |
217 | 217 | // Collect payment details |
218 | - $payment_status = strtolower( $posted['payment_status'] ); |
|
219 | - $business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] ); |
|
218 | + $payment_status = strtolower($posted['payment_status']); |
|
219 | + $business_email = isset($posted['business']) && is_email($posted['business']) ? trim($posted['business']) : trim($posted['receiver_email']); |
|
220 | 220 | |
221 | - $this->validate_ipn_receiver_email( $invoice, $business_email ); |
|
222 | - $this->validate_ipn_currency( $invoice, $posted['mc_currency'] ); |
|
221 | + $this->validate_ipn_receiver_email($invoice, $business_email); |
|
222 | + $this->validate_ipn_currency($invoice, $posted['mc_currency']); |
|
223 | 223 | |
224 | 224 | // Update the transaction id. |
225 | - if ( ! empty( $posted['txn_id'] ) ) { |
|
226 | - $invoice->set_transaction_id( wpinv_clean( $posted['txn_id'] ) ); |
|
225 | + if (!empty($posted['txn_id'])) { |
|
226 | + $invoice->set_transaction_id(wpinv_clean($posted['txn_id'])); |
|
227 | 227 | $invoice->save(); |
228 | 228 | } |
229 | 229 | |
230 | 230 | // Process a refund. |
231 | - if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) { |
|
231 | + if ($payment_status == 'refunded' || $payment_status == 'reversed') { |
|
232 | 232 | |
233 | - update_post_meta( $invoice->get_id(), 'refunded_remotely', 1 ); |
|
233 | + update_post_meta($invoice->get_id(), 'refunded_remotely', 1); |
|
234 | 234 | |
235 | - if ( ! $invoice->is_refunded() ) { |
|
236 | - $invoice->update_status( 'wpi-refunded', $posted['reason_code'] ); |
|
235 | + if (!$invoice->is_refunded()) { |
|
236 | + $invoice->update_status('wpi-refunded', $posted['reason_code']); |
|
237 | 237 | } |
238 | 238 | |
239 | - return wpinv_error_log( $posted['reason_code'], false ); |
|
239 | + return wpinv_error_log($posted['reason_code'], false); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | // Process payments. |
243 | - if ( $payment_status == 'completed' ) { |
|
243 | + if ($payment_status == 'completed') { |
|
244 | 244 | |
245 | - if ( $invoice->is_paid() && 'wpi_processing' != $invoice->get_status() ) { |
|
246 | - return wpinv_error_log( 'Aborting, Invoice #' . $invoice->get_number() . ' is already paid.', false ); |
|
245 | + if ($invoice->is_paid() && 'wpi_processing' != $invoice->get_status()) { |
|
246 | + return wpinv_error_log('Aborting, Invoice #' . $invoice->get_number() . ' is already paid.', false); |
|
247 | 247 | } |
248 | 248 | |
249 | - $this->validate_ipn_amount( $invoice, $posted['mc_gross'] ); |
|
249 | + $this->validate_ipn_amount($invoice, $posted['mc_gross']); |
|
250 | 250 | |
251 | 251 | $note = ''; |
252 | 252 | |
253 | - if ( ! empty( $posted['mc_fee'] ) ) { |
|
254 | - $note = sprintf( __( 'PayPal Transaction Fee %.', 'invoicing' ), sanitize_text_field( $posted['mc_fee'] ) ); |
|
253 | + if (!empty($posted['mc_fee'])) { |
|
254 | + $note = sprintf(__('PayPal Transaction Fee %.', 'invoicing'), sanitize_text_field($posted['mc_fee'])); |
|
255 | 255 | } |
256 | 256 | |
257 | - if ( ! empty( $posted['payer_status'] ) ) { |
|
258 | - $note = ' ' . sprintf( __( 'Buyer status %.', 'invoicing' ), sanitize_text_field( $posted['payer_status'] ) ); |
|
257 | + if (!empty($posted['payer_status'])) { |
|
258 | + $note = ' ' . sprintf(__('Buyer status %.', 'invoicing'), sanitize_text_field($posted['payer_status'])); |
|
259 | 259 | } |
260 | 260 | |
261 | - $invoice->mark_paid( ( ! empty( $posted['txn_id'] ) ? sanitize_text_field( $posted['txn_id'] ) : '' ), trim( $note ) ); |
|
262 | - return wpinv_error_log( 'Invoice marked as paid.', false ); |
|
261 | + $invoice->mark_paid((!empty($posted['txn_id']) ? sanitize_text_field($posted['txn_id']) : ''), trim($note)); |
|
262 | + return wpinv_error_log('Invoice marked as paid.', false); |
|
263 | 263 | |
264 | 264 | } |
265 | 265 | |
266 | 266 | // Pending payments. |
267 | - if ( $payment_status == 'pending' ) { |
|
267 | + if ($payment_status == 'pending') { |
|
268 | 268 | |
269 | 269 | /* translators: %s: pending reason. */ |
270 | - $invoice->update_status( 'wpi-onhold', sprintf( __( 'Payment pending (%s).', 'invoicing' ), $posted['pending_reason'] ) ); |
|
270 | + $invoice->update_status('wpi-onhold', sprintf(__('Payment pending (%s).', 'invoicing'), $posted['pending_reason'])); |
|
271 | 271 | |
272 | - return wpinv_error_log( 'Invoice marked as "payment held".', false ); |
|
272 | + return wpinv_error_log('Invoice marked as "payment held".', false); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | /* translators: %s: payment status. */ |
276 | - $invoice->update_status( 'wpi-failed', sprintf( __( 'Payment %s via IPN.', 'invoicing' ), sanitize_text_field( $posted['payment_status'] ) ) ); |
|
276 | + $invoice->update_status('wpi-failed', sprintf(__('Payment %s via IPN.', 'invoicing'), sanitize_text_field($posted['payment_status']))); |
|
277 | 277 | |
278 | 278 | } |
279 | 279 | |
@@ -283,8 +283,8 @@ discard block |
||
283 | 283 | * @param WPInv_Invoice $invoice Invoice object. |
284 | 284 | * @param array $posted Posted data. |
285 | 285 | */ |
286 | - protected function ipn_txn_cart( $invoice, $posted ) { |
|
287 | - $this->ipn_txn_web_accept( $invoice, $posted ); |
|
286 | + protected function ipn_txn_cart($invoice, $posted) { |
|
287 | + $this->ipn_txn_web_accept($invoice, $posted); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
@@ -293,42 +293,42 @@ discard block |
||
293 | 293 | * @param WPInv_Invoice $invoice Invoice object. |
294 | 294 | * @param array $posted Posted data. |
295 | 295 | */ |
296 | - protected function ipn_txn_subscr_signup( $invoice, $posted ) { |
|
296 | + protected function ipn_txn_subscr_signup($invoice, $posted) { |
|
297 | 297 | |
298 | - wpinv_error_log( 'Processing subscription signup', false ); |
|
298 | + wpinv_error_log('Processing subscription signup', false); |
|
299 | 299 | |
300 | 300 | // Make sure the invoice has a subscription. |
301 | - $subscription = getpaid_get_invoice_subscription( $invoice ); |
|
301 | + $subscription = getpaid_get_invoice_subscription($invoice); |
|
302 | 302 | |
303 | - if ( empty( $subscription ) ) { |
|
304 | - return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false ); |
|
303 | + if (empty($subscription)) { |
|
304 | + return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false); |
|
305 | 305 | } |
306 | 306 | |
307 | - wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false ); |
|
307 | + wpinv_error_log('Found subscription #' . $subscription->get_id(), false); |
|
308 | 308 | |
309 | 309 | // Validate the IPN. |
310 | - $business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] ); |
|
311 | - $this->validate_ipn_receiver_email( $invoice, $business_email ); |
|
312 | - $this->validate_ipn_currency( $invoice, $posted['mc_currency'] ); |
|
310 | + $business_email = isset($posted['business']) && is_email($posted['business']) ? trim($posted['business']) : trim($posted['receiver_email']); |
|
311 | + $this->validate_ipn_receiver_email($invoice, $business_email); |
|
312 | + $this->validate_ipn_currency($invoice, $posted['mc_currency']); |
|
313 | 313 | |
314 | 314 | // Activate the subscription. |
315 | - $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() ); |
|
316 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
317 | - $subscription->set_expiration( date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ) ); |
|
318 | - $subscription->set_profile_id( sanitize_text_field( $posted['subscr_id'] ) ); |
|
315 | + $duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created()); |
|
316 | + $subscription->set_date_created(current_time('mysql')); |
|
317 | + $subscription->set_expiration(date('Y-m-d H:i:s', (current_time('timestamp') + $duration))); |
|
318 | + $subscription->set_profile_id(sanitize_text_field($posted['subscr_id'])); |
|
319 | 319 | $subscription->activate(); |
320 | 320 | |
321 | 321 | // Set the transaction id. |
322 | - if ( ! empty( $posted['txn_id'] ) ) { |
|
323 | - $invoice->set_transaction_id( $posted['txn_id'] ); |
|
322 | + if (!empty($posted['txn_id'])) { |
|
323 | + $invoice->set_transaction_id($posted['txn_id']); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | // Update the payment status. |
327 | 327 | $invoice->mark_paid(); |
328 | 328 | |
329 | - $invoice->add_note( sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $posted['subscr_id'] ), false, false, true ); |
|
329 | + $invoice->add_note(sprintf(__('PayPal Subscription ID: %s', 'invoicing'), $posted['subscr_id']), false, false, true); |
|
330 | 330 | |
331 | - wpinv_error_log( 'Subscription started.', false ); |
|
331 | + wpinv_error_log('Subscription started.', false); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | /** |
@@ -337,35 +337,35 @@ discard block |
||
337 | 337 | * @param WPInv_Invoice $invoice Invoice object. |
338 | 338 | * @param array $posted Posted data. |
339 | 339 | */ |
340 | - protected function ipn_txn_subscr_payment( $invoice, $posted ) { |
|
340 | + protected function ipn_txn_subscr_payment($invoice, $posted) { |
|
341 | 341 | |
342 | 342 | // Make sure the invoice has a subscription. |
343 | - $subscription = wpinv_get_subscription( $invoice ); |
|
343 | + $subscription = wpinv_get_subscription($invoice); |
|
344 | 344 | |
345 | - if ( empty( $subscription ) ) { |
|
346 | - return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false ); |
|
345 | + if (empty($subscription)) { |
|
346 | + return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false); |
|
347 | 347 | } |
348 | 348 | |
349 | - wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false ); |
|
349 | + wpinv_error_log('Found subscription #' . $subscription->get_id(), false); |
|
350 | 350 | |
351 | 351 | // Abort if this is the first payment. |
352 | - $invoice_completed = date( 'Ynd', strtotime( $invoice->get_date_completed() ) ); |
|
353 | - $payment_date = date( 'Ynd', strtotime( $posted['payment_date'] ) ); |
|
354 | - $subscription_date = date( 'Ynd', $subscription->get_time_created() ); |
|
355 | - if ( $invoice_completed == $payment_date || $subscription_date == $payment_date ) { |
|
352 | + $invoice_completed = date('Ynd', strtotime($invoice->get_date_completed())); |
|
353 | + $payment_date = date('Ynd', strtotime($posted['payment_date'])); |
|
354 | + $subscription_date = date('Ynd', $subscription->get_time_created()); |
|
355 | + if ($invoice_completed == $payment_date || $subscription_date == $payment_date) { |
|
356 | 356 | |
357 | - if ( ! empty( $posted['txn_id'] ) ) { |
|
358 | - $invoice->set_transaction_id( sanitize_text_field( $posted['txn_id'] ) ); |
|
357 | + if (!empty($posted['txn_id'])) { |
|
358 | + $invoice->set_transaction_id(sanitize_text_field($posted['txn_id'])); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | return $invoice->mark_paid(); |
362 | 362 | } |
363 | 363 | |
364 | - wpinv_error_log( 'Processing subscription renewal payment for the invoice ' . $invoice->get_id(), false ); |
|
364 | + wpinv_error_log('Processing subscription renewal payment for the invoice ' . $invoice->get_id(), false); |
|
365 | 365 | |
366 | 366 | // Abort if the payment is already recorded. |
367 | - if ( wpinv_get_id_by_transaction_id( $posted['txn_id'] ) ) { |
|
368 | - return wpinv_error_log( 'Aborting, Transaction ' . $posted['txn_id'] .' has already been processed', false ); |
|
367 | + if (wpinv_get_id_by_transaction_id($posted['txn_id'])) { |
|
368 | + return wpinv_error_log('Aborting, Transaction ' . $posted['txn_id'] . ' has already been processed', false); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | $args = array( |
@@ -373,17 +373,17 @@ discard block |
||
373 | 373 | 'gateway' => $this->id, |
374 | 374 | ); |
375 | 375 | |
376 | - $invoice = wpinv_get_invoice( $subscription->add_payment( $args ) ); |
|
376 | + $invoice = wpinv_get_invoice($subscription->add_payment($args)); |
|
377 | 377 | |
378 | - if ( empty( $invoice ) ) { |
|
378 | + if (empty($invoice)) { |
|
379 | 379 | return; |
380 | 380 | } |
381 | 381 | |
382 | - $invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $posted['txn_id'] ), false, false, true ); |
|
383 | - $invoice->add_note( wp_sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $posted['subscr_id'] ), false, false, true ); |
|
382 | + $invoice->add_note(wp_sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $posted['txn_id']), false, false, true); |
|
383 | + $invoice->add_note(wp_sprintf(__('PayPal Subscription ID: %s', 'invoicing'), $posted['subscr_id']), false, false, true); |
|
384 | 384 | |
385 | 385 | $subscription->renew(); |
386 | - wpinv_error_log( 'Subscription renewed.', false ); |
|
386 | + wpinv_error_log('Subscription renewed.', false); |
|
387 | 387 | |
388 | 388 | } |
389 | 389 | |
@@ -392,18 +392,18 @@ discard block |
||
392 | 392 | * |
393 | 393 | * @param WPInv_Invoice $invoice Invoice object. |
394 | 394 | */ |
395 | - protected function ipn_txn_subscr_cancel( $invoice ) { |
|
395 | + protected function ipn_txn_subscr_cancel($invoice) { |
|
396 | 396 | |
397 | 397 | // Make sure the invoice has a subscription. |
398 | - $subscription = wpinv_get_subscription( $invoice ); |
|
398 | + $subscription = wpinv_get_subscription($invoice); |
|
399 | 399 | |
400 | - if ( empty( $subscription ) ) { |
|
401 | - return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false); |
|
400 | + if (empty($subscription)) { |
|
401 | + return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false); |
|
402 | 402 | } |
403 | 403 | |
404 | - wpinv_error_log( 'Processing subscription cancellation for the invoice ' . $invoice->get_id(), false ); |
|
404 | + wpinv_error_log('Processing subscription cancellation for the invoice ' . $invoice->get_id(), false); |
|
405 | 405 | $subscription->cancel(); |
406 | - wpinv_error_log( 'Subscription cancelled.', false ); |
|
406 | + wpinv_error_log('Subscription cancelled.', false); |
|
407 | 407 | |
408 | 408 | } |
409 | 409 | |
@@ -413,18 +413,18 @@ discard block |
||
413 | 413 | * @param WPInv_Invoice $invoice Invoice object. |
414 | 414 | * @param array $posted Posted data. |
415 | 415 | */ |
416 | - protected function ipn_txn_subscr_eot( $invoice ) { |
|
416 | + protected function ipn_txn_subscr_eot($invoice) { |
|
417 | 417 | |
418 | 418 | // Make sure the invoice has a subscription. |
419 | - $subscription = wpinv_get_subscription( $invoice ); |
|
419 | + $subscription = wpinv_get_subscription($invoice); |
|
420 | 420 | |
421 | - if ( empty( $subscription ) ) { |
|
422 | - return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false ); |
|
421 | + if (empty($subscription)) { |
|
422 | + return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false); |
|
423 | 423 | } |
424 | 424 | |
425 | - wpinv_error_log( 'Processing subscription end of life for the invoice ' . $invoice->get_id(), false ); |
|
425 | + wpinv_error_log('Processing subscription end of life for the invoice ' . $invoice->get_id(), false); |
|
426 | 426 | $subscription->complete(); |
427 | - wpinv_error_log( 'Subscription completed.', false ); |
|
427 | + wpinv_error_log('Subscription completed.', false); |
|
428 | 428 | |
429 | 429 | } |
430 | 430 | |
@@ -434,18 +434,18 @@ discard block |
||
434 | 434 | * @param WPInv_Invoice $invoice Invoice object. |
435 | 435 | * @param array $posted Posted data. |
436 | 436 | */ |
437 | - protected function ipn_txn_subscr_failed( $invoice ) { |
|
437 | + protected function ipn_txn_subscr_failed($invoice) { |
|
438 | 438 | |
439 | 439 | // Make sure the invoice has a subscription. |
440 | - $subscription = wpinv_get_subscription( $invoice ); |
|
440 | + $subscription = wpinv_get_subscription($invoice); |
|
441 | 441 | |
442 | - if ( empty( $subscription ) ) { |
|
443 | - return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false ); |
|
442 | + if (empty($subscription)) { |
|
443 | + return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false); |
|
444 | 444 | } |
445 | 445 | |
446 | - wpinv_error_log( 'Processing subscription payment failure for the invoice ' . $invoice->get_id(), false ); |
|
446 | + wpinv_error_log('Processing subscription payment failure for the invoice ' . $invoice->get_id(), false); |
|
447 | 447 | $subscription->failing(); |
448 | - wpinv_error_log( 'Subscription marked as failing.', false ); |
|
448 | + wpinv_error_log('Subscription marked as failing.', false); |
|
449 | 449 | |
450 | 450 | } |
451 | 451 | |
@@ -455,18 +455,18 @@ discard block |
||
455 | 455 | * @param WPInv_Invoice $invoice Invoice object. |
456 | 456 | * @param array $posted Posted data. |
457 | 457 | */ |
458 | - protected function ipn_txn_recurring_payment_suspended_due_to_max_failed_payment( $invoice ) { |
|
458 | + protected function ipn_txn_recurring_payment_suspended_due_to_max_failed_payment($invoice) { |
|
459 | 459 | |
460 | 460 | // Make sure the invoice has a subscription. |
461 | - $subscription = wpinv_get_subscription( $invoice ); |
|
461 | + $subscription = wpinv_get_subscription($invoice); |
|
462 | 462 | |
463 | - if ( empty( $subscription ) ) { |
|
464 | - return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false ); |
|
463 | + if (empty($subscription)) { |
|
464 | + return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false); |
|
465 | 465 | } |
466 | 466 | |
467 | - wpinv_error_log( 'Processing subscription cancellation due to max failed payment for the invoice ' . $invoice->get_id(), false ); |
|
467 | + wpinv_error_log('Processing subscription cancellation due to max failed payment for the invoice ' . $invoice->get_id(), false); |
|
468 | 468 | $subscription->cancel(); |
469 | - wpinv_error_log( 'Subscription cancelled.', false ); |
|
469 | + wpinv_error_log('Subscription cancelled.', false); |
|
470 | 470 | } |
471 | 471 | |
472 | 472 | } |
@@ -4,8 +4,8 @@ |
||
4 | 4 | <?php |
5 | 5 | echo |
6 | 6 | wp_sprintf( |
7 | - __( 'Your payment is processing. This page will reload automatically in 10 seconds. If it does not, click <a href="%s">here</a>.', 'invoicing' ), |
|
8 | - esc_url( $_SERVER['REQUEST_URI'] ) |
|
7 | + __('Your payment is processing. This page will reload automatically in 10 seconds. If it does not, click <a href="%s">here</a>.', 'invoicing'), |
|
8 | + esc_url($_SERVER['REQUEST_URI']) |
|
9 | 9 | ); |
10 | 10 | ?> |
11 | 11 | <i class="fa fa-spin fa-refresh"></i> |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -21,10 +21,10 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param WP_Post $post |
23 | 23 | */ |
24 | - public static function output( $post ) { |
|
24 | + public static function output($post) { |
|
25 | 25 | |
26 | 26 | // Prepare the invoice. |
27 | - $invoice = new WPInv_Invoice( $post ); |
|
27 | + $invoice = new WPInv_Invoice($post); |
|
28 | 28 | |
29 | 29 | ?> |
30 | 30 | |
@@ -47,12 +47,12 @@ discard block |
||
47 | 47 | 'id' => 'wpinv_key', |
48 | 48 | 'name' => 'wpinv_key', |
49 | 49 | 'label' => sprintf( |
50 | - __( '%s Key:', 'invoicing' ), |
|
51 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
50 | + __('%s Key:', 'invoicing'), |
|
51 | + ucfirst($invoice->get_invoice_quote_type()) |
|
52 | 52 | ), |
53 | 53 | 'label_type' => 'vertical', |
54 | 54 | 'class' => 'form-control-sm', |
55 | - 'value' => $invoice->get_key( 'edit' ), |
|
55 | + 'value' => $invoice->get_key('edit'), |
|
56 | 56 | 'extra_attributes' => array( |
57 | 57 | 'onclick' => 'this.select();', |
58 | 58 | 'readonly' => 'true', |
@@ -67,8 +67,8 @@ discard block |
||
67 | 67 | 'id' => 'wpinv_view_url', |
68 | 68 | 'name' => 'wpinv_view_url', |
69 | 69 | 'label' => sprintf( |
70 | - __( '%s URL:', 'invoicing' ), |
|
71 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
70 | + __('%s URL:', 'invoicing'), |
|
71 | + ucfirst($invoice->get_invoice_quote_type()) |
|
72 | 72 | ), |
73 | 73 | 'label_type' => 'vertical', |
74 | 74 | 'class' => 'form-control-sm', |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | ); |
82 | 82 | |
83 | 83 | // If the invoice is paid... |
84 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
84 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
85 | 85 | |
86 | 86 | // Gateway. |
87 | 87 | echo aui()->input( |
@@ -89,10 +89,10 @@ discard block |
||
89 | 89 | 'type' => 'text', |
90 | 90 | 'id' => 'wpinv_gateway', |
91 | 91 | 'name' => '', |
92 | - 'label' => __( 'Gateway:', 'invoicing' ), |
|
92 | + 'label' => __('Gateway:', 'invoicing'), |
|
93 | 93 | 'label_type' => 'vertical', |
94 | 94 | 'class' => 'form-control-sm', |
95 | - 'value' => wpinv_get_gateway_admin_label( $invoice->get_gateway( 'edit' ) ), |
|
95 | + 'value' => wpinv_get_gateway_admin_label($invoice->get_gateway('edit')), |
|
96 | 96 | 'extra_attributes' => array( |
97 | 97 | 'onclick' => 'this.select();', |
98 | 98 | 'readonly' => 'true', |
@@ -106,11 +106,11 @@ discard block |
||
106 | 106 | 'type' => 'text', |
107 | 107 | 'id' => 'wpinv_transaction_id', |
108 | 108 | 'name' => 'wpinv_transaction_id', |
109 | - 'label' => __( 'Transaction ID:', 'invoicing' ), |
|
109 | + 'label' => __('Transaction ID:', 'invoicing'), |
|
110 | 110 | 'label_type' => 'vertical', |
111 | 111 | 'class' => 'form-control-sm', |
112 | - 'value' => $invoice->get_transaction_id( 'edit' ), |
|
113 | - 'help_text' => apply_filters( 'wpinv_invoice_transaction_link_' . $invoice->get_gateway( 'edit' ), '', $invoice->get_transaction_id(), $invoice ), |
|
112 | + 'value' => $invoice->get_transaction_id('edit'), |
|
113 | + 'help_text' => apply_filters('wpinv_invoice_transaction_link_' . $invoice->get_gateway('edit'), '', $invoice->get_transaction_id(), $invoice), |
|
114 | 114 | 'extra_attributes' => array( |
115 | 115 | 'onclick' => 'this.select();', |
116 | 116 | 'readonly' => 'true', |
@@ -124,10 +124,10 @@ discard block |
||
124 | 124 | 'type' => 'text', |
125 | 125 | 'id' => 'wpinv_currency', |
126 | 126 | 'name' => 'wpinv_currency', |
127 | - 'label' => __( 'Currency:', 'invoicing' ), |
|
127 | + 'label' => __('Currency:', 'invoicing'), |
|
128 | 128 | 'label_type' => 'vertical', |
129 | 129 | 'class' => 'form-control-sm', |
130 | - 'value' => $invoice->get_currency( 'edit' ), |
|
130 | + 'value' => $invoice->get_currency('edit'), |
|
131 | 131 | 'extra_attributes' => array( |
132 | 132 | 'onclick' => 'this.select();', |
133 | 133 | 'readonly' => 'true', |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | |
138 | 138 | } else { |
139 | 139 | |
140 | - if ( 'wpi_invoice' == $invoice->get_post_type() ) { |
|
140 | + if ('wpi_invoice' == $invoice->get_post_type()) { |
|
141 | 141 | |
142 | 142 | // Payment URL. |
143 | 143 | echo aui()->input( |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | 'type' => 'text', |
146 | 146 | 'id' => 'wpinv_payment_url', |
147 | 147 | 'name' => 'wpinv_payment_url', |
148 | - 'label' => __( 'Payment URL:', 'invoicing' ), |
|
148 | + 'label' => __('Payment URL:', 'invoicing'), |
|
149 | 149 | 'label_type' => 'vertical', |
150 | 150 | 'class' => 'form-control-sm', |
151 | 151 | 'value' => $invoice->get_checkout_payment_url(), |
@@ -161,13 +161,13 @@ discard block |
||
161 | 161 | array( |
162 | 162 | 'id' => 'wpinv_gateway', |
163 | 163 | 'name' => 'wpinv_gateway', |
164 | - 'label' => __( 'Gateway:', 'invoicing' ), |
|
164 | + 'label' => __('Gateway:', 'invoicing'), |
|
165 | 165 | 'label_type' => 'vertical', |
166 | - 'placeholder' => __( 'Select Gateway', 'invoicing' ), |
|
167 | - 'value' => $invoice->get_gateway( 'edit' ), |
|
166 | + 'placeholder' => __('Select Gateway', 'invoicing'), |
|
167 | + 'value' => $invoice->get_gateway('edit'), |
|
168 | 168 | 'select2' => true, |
169 | 169 | 'data-allow-clear' => 'false', |
170 | - 'options' => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ), |
|
170 | + 'options' => wp_list_pluck(wpinv_get_enabled_payment_gateways(true), 'admin_label'), |
|
171 | 171 | ) |
172 | 172 | ); |
173 | 173 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -21,14 +21,14 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param WP_Post $post |
23 | 23 | */ |
24 | - public static function output( $post ) { |
|
24 | + public static function output($post) { |
|
25 | 25 | |
26 | 26 | // Prepare the invoice. |
27 | - $invoice = new WPInv_Invoice( $post ); |
|
28 | - $customer = $invoice->exists() ? $invoice->get_user_id( 'edit' ) : get_current_user_id(); |
|
29 | - $customer = new WP_User( $customer ); |
|
30 | - $display = sprintf( _x( '%1$s (%2$s)', 'user dropdown', 'invoicing' ), $customer->display_name, $customer->user_email ); |
|
31 | - wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' ); |
|
27 | + $invoice = new WPInv_Invoice($post); |
|
28 | + $customer = $invoice->exists() ? $invoice->get_user_id('edit') : get_current_user_id(); |
|
29 | + $customer = new WP_User($customer); |
|
30 | + $display = sprintf(_x('%1$s (%2$s)', 'user dropdown', 'invoicing'), $customer->display_name, $customer->user_email); |
|
31 | + wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce'); |
|
32 | 32 | |
33 | 33 | ?> |
34 | 34 | |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | <div class="col-12 col-sm-6"> |
44 | 44 | <div id="getpaid-invoice-user-id-wrapper" class="form-group"> |
45 | 45 | <div> |
46 | - <label for="post_author_override"><?php _e( 'Customer', 'invoicing' );?></label> |
|
46 | + <label for="post_author_override"><?php _e('Customer', 'invoicing'); ?></label> |
|
47 | 47 | </div> |
48 | 48 | <div> |
49 | - <select name="post_author_override" id="wpinv_post_author_override" class="getpaid-customer-search form-control regular-text" data-placeholder="<?php esc_attr_e( 'Search for a customer by email or name', 'invoicing' ); ?>"> |
|
50 | - <option selected="selected" value="<?php echo (int) $customer->ID; ?>"><?php echo sanitize_text_field( $display ); ?> </option>) |
|
49 | + <select name="post_author_override" id="wpinv_post_author_override" class="getpaid-customer-search form-control regular-text" data-placeholder="<?php esc_attr_e('Search for a customer by email or name', 'invoicing'); ?>"> |
|
50 | + <option selected="selected" value="<?php echo (int) $customer->ID; ?>"><?php echo sanitize_text_field($display); ?> </option>) |
|
51 | 51 | </select> |
52 | 52 | </div> |
53 | 53 | </div> |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | 'type' => 'text', |
61 | 61 | 'id' => 'getpaid-invoice-new-user-email', |
62 | 62 | 'name' => 'wpinv_email', |
63 | - 'label' => __( 'Email', 'invoicing' ) . '<span class="required">*</span>', |
|
63 | + 'label' => __('Email', 'invoicing') . '<span class="required">*</span>', |
|
64 | 64 | 'label_type' => 'vertical', |
65 | 65 | 'placeholder' => '[email protected]', |
66 | 66 | 'class' => 'form-control-sm', |
@@ -70,18 +70,18 @@ discard block |
||
70 | 70 | </div> |
71 | 71 | </div> |
72 | 72 | <div class="col-12 col-sm-6 form-group mt-sm-4"> |
73 | - <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?> |
|
73 | + <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?> |
|
74 | 74 | <a id="getpaid-invoice-fill-user-details" class="button button-small button-secondary" href="javascript:void(0)"> |
75 | 75 | <i aria-hidden="true" class="fa fa-refresh"></i> |
76 | - <?php _e( 'Fill User Details', 'invoicing' );?> |
|
76 | + <?php _e('Fill User Details', 'invoicing'); ?> |
|
77 | 77 | </a> |
78 | 78 | <a id="getpaid-invoice-create-new-user-button" class="button button-small button-secondary" href="javascript:void(0)"> |
79 | 79 | <i aria-hidden="true" class="fa fa-plus"></i> |
80 | - <?php _e( 'Add New User', 'invoicing' );?> |
|
80 | + <?php _e('Add New User', 'invoicing'); ?> |
|
81 | 81 | </a> |
82 | 82 | <a id="getpaid-invoice-cancel-create-new-user" class="button button-small button-secondary d-none" href="javascript:void(0)"> |
83 | 83 | <i aria-hidden="true" class="fa fa-close"></i> |
84 | - <?php _e( 'Cancel', 'invoicing' );?> |
|
84 | + <?php _e('Cancel', 'invoicing'); ?> |
|
85 | 85 | </a> |
86 | 86 | <?php endif; ?> |
87 | 87 | </div> |
@@ -94,11 +94,11 @@ discard block |
||
94 | 94 | 'type' => 'text', |
95 | 95 | 'id' => 'wpinv_first_name', |
96 | 96 | 'name' => 'wpinv_first_name', |
97 | - 'label' => __( 'First Name', 'invoicing' ), |
|
97 | + 'label' => __('First Name', 'invoicing'), |
|
98 | 98 | 'label_type' => 'vertical', |
99 | 99 | 'placeholder' => '', |
100 | 100 | 'class' => 'form-control-sm', |
101 | - 'value' => $invoice->get_first_name( 'edit' ), |
|
101 | + 'value' => $invoice->get_first_name('edit'), |
|
102 | 102 | ) |
103 | 103 | ); |
104 | 104 | ?> |
@@ -110,11 +110,11 @@ discard block |
||
110 | 110 | 'type' => 'text', |
111 | 111 | 'id' => 'wpinv_last_name', |
112 | 112 | 'name' => 'wpinv_last_name', |
113 | - 'label' => __( 'Last Name', 'invoicing' ), |
|
113 | + 'label' => __('Last Name', 'invoicing'), |
|
114 | 114 | 'label_type' => 'vertical', |
115 | 115 | 'placeholder' => '', |
116 | 116 | 'class' => 'form-control-sm', |
117 | - 'value' => $invoice->get_last_name( 'edit' ), |
|
117 | + 'value' => $invoice->get_last_name('edit'), |
|
118 | 118 | ) |
119 | 119 | ); |
120 | 120 | ?> |
@@ -129,11 +129,11 @@ discard block |
||
129 | 129 | 'type' => 'text', |
130 | 130 | 'id' => 'wpinv_company', |
131 | 131 | 'name' => 'wpinv_company', |
132 | - 'label' => __( 'Company', 'invoicing' ), |
|
132 | + 'label' => __('Company', 'invoicing'), |
|
133 | 133 | 'label_type' => 'vertical', |
134 | 134 | 'placeholder' => '', |
135 | 135 | 'class' => 'form-control-sm', |
136 | - 'value' => $invoice->get_company( 'edit' ), |
|
136 | + 'value' => $invoice->get_company('edit'), |
|
137 | 137 | ) |
138 | 138 | ); |
139 | 139 | ?> |
@@ -145,11 +145,11 @@ discard block |
||
145 | 145 | 'type' => 'text', |
146 | 146 | 'id' => 'wpinv_vat_number', |
147 | 147 | 'name' => 'wpinv_vat_number', |
148 | - 'label' => __( 'Vat Number', 'invoicing' ), |
|
148 | + 'label' => __('Vat Number', 'invoicing'), |
|
149 | 149 | 'label_type' => 'vertical', |
150 | 150 | 'placeholder' => '', |
151 | 151 | 'class' => 'form-control-sm', |
152 | - 'value' => $invoice->get_vat_number( 'edit' ), |
|
152 | + 'value' => $invoice->get_vat_number('edit'), |
|
153 | 153 | ) |
154 | 154 | ); |
155 | 155 | ?> |
@@ -164,11 +164,11 @@ discard block |
||
164 | 164 | 'type' => 'text', |
165 | 165 | 'id' => 'wpinv_address', |
166 | 166 | 'name' => 'wpinv_address', |
167 | - 'label' => __( 'Address', 'invoicing' ), |
|
167 | + 'label' => __('Address', 'invoicing'), |
|
168 | 168 | 'label_type' => 'vertical', |
169 | 169 | 'placeholder' => '', |
170 | 170 | 'class' => 'form-control-sm', |
171 | - 'value' => $invoice->get_address( 'edit' ), |
|
171 | + 'value' => $invoice->get_address('edit'), |
|
172 | 172 | ) |
173 | 173 | ); |
174 | 174 | ?> |
@@ -180,11 +180,11 @@ discard block |
||
180 | 180 | 'type' => 'text', |
181 | 181 | 'id' => 'wpinv_city', |
182 | 182 | 'name' => 'wpinv_city', |
183 | - 'label' => __( 'City', 'invoicing' ), |
|
183 | + 'label' => __('City', 'invoicing'), |
|
184 | 184 | 'label_type' => 'vertical', |
185 | 185 | 'placeholder' => '', |
186 | 186 | 'class' => 'form-control-sm', |
187 | - 'value' => $invoice->get_city( 'edit' ), |
|
187 | + 'value' => $invoice->get_city('edit'), |
|
188 | 188 | ) |
189 | 189 | ); |
190 | 190 | ?> |
@@ -198,11 +198,11 @@ discard block |
||
198 | 198 | array( |
199 | 199 | 'id' => 'wpinv_country', |
200 | 200 | 'name' => 'wpinv_country', |
201 | - 'label' => __( 'Country', 'invoicing' ), |
|
201 | + 'label' => __('Country', 'invoicing'), |
|
202 | 202 | 'label_type' => 'vertical', |
203 | - 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
203 | + 'placeholder' => __('Choose a country', 'invoicing'), |
|
204 | 204 | 'class' => 'form-control-sm', |
205 | - 'value' => $invoice->get_country( 'edit' ), |
|
205 | + 'value' => $invoice->get_country('edit'), |
|
206 | 206 | 'options' => wpinv_get_country_list(), |
207 | 207 | 'data-allow-clear' => 'false', |
208 | 208 | 'select2' => true, |
@@ -213,20 +213,20 @@ discard block |
||
213 | 213 | <div class="col-12 col-sm-6"> |
214 | 214 | <?php |
215 | 215 | |
216 | - $states = wpinv_get_country_states( $invoice->get_country( 'edit' ) ); |
|
216 | + $states = wpinv_get_country_states($invoice->get_country('edit')); |
|
217 | 217 | |
218 | - if ( empty( $states ) ) { |
|
218 | + if (empty($states)) { |
|
219 | 219 | |
220 | 220 | echo aui()->input( |
221 | 221 | array( |
222 | 222 | 'type' => 'text', |
223 | 223 | 'id' => 'wpinv_state', |
224 | 224 | 'name' => 'wpinv_state', |
225 | - 'label' => __( 'State', 'invoicing' ), |
|
225 | + 'label' => __('State', 'invoicing'), |
|
226 | 226 | 'label_type' => 'vertical', |
227 | 227 | 'placeholder' => '', |
228 | 228 | 'class' => 'form-control-sm', |
229 | - 'value' => $invoice->get_state( 'edit' ), |
|
229 | + 'value' => $invoice->get_state('edit'), |
|
230 | 230 | ) |
231 | 231 | ); |
232 | 232 | |
@@ -236,11 +236,11 @@ discard block |
||
236 | 236 | array( |
237 | 237 | 'id' => 'wpinv_state', |
238 | 238 | 'name' => 'wpinv_state', |
239 | - 'label' => __( 'State', 'invoicing' ), |
|
239 | + 'label' => __('State', 'invoicing'), |
|
240 | 240 | 'label_type' => 'vertical', |
241 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
241 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
242 | 242 | 'class' => 'form-control-sm', |
243 | - 'value' => $invoice->get_state( 'edit' ), |
|
243 | + 'value' => $invoice->get_state('edit'), |
|
244 | 244 | 'options' => $states, |
245 | 245 | 'data-allow-clear' => 'false', |
246 | 246 | 'select2' => true, |
@@ -261,11 +261,11 @@ discard block |
||
261 | 261 | 'type' => 'text', |
262 | 262 | 'id' => 'wpinv_zip', |
263 | 263 | 'name' => 'wpinv_zip', |
264 | - 'label' => __( 'Zip / Postal Code', 'invoicing' ), |
|
264 | + 'label' => __('Zip / Postal Code', 'invoicing'), |
|
265 | 265 | 'label_type' => 'vertical', |
266 | 266 | 'placeholder' => '', |
267 | 267 | 'class' => 'form-control-sm', |
268 | - 'value' => $invoice->get_zip( 'edit' ), |
|
268 | + 'value' => $invoice->get_zip('edit'), |
|
269 | 269 | ) |
270 | 270 | ); |
271 | 271 | ?> |
@@ -277,18 +277,18 @@ discard block |
||
277 | 277 | 'type' => 'text', |
278 | 278 | 'id' => 'wpinv_phone', |
279 | 279 | 'name' => 'wpinv_phone', |
280 | - 'label' => __( 'Phone', 'invoicing' ), |
|
280 | + 'label' => __('Phone', 'invoicing'), |
|
281 | 281 | 'label_type' => 'vertical', |
282 | 282 | 'placeholder' => '', |
283 | 283 | 'class' => 'form-control-sm', |
284 | - 'value' => $invoice->get_phone( 'edit' ), |
|
284 | + 'value' => $invoice->get_phone('edit'), |
|
285 | 285 | ) |
286 | 286 | ); |
287 | 287 | ?> |
288 | 288 | </div> |
289 | 289 | </div> |
290 | 290 | |
291 | - <?php do_action( 'getpaid_after_metabox_invoice_address', $invoice ); ?> |
|
291 | + <?php do_action('getpaid_after_metabox_invoice_address', $invoice); ?> |
|
292 | 292 | </div> |
293 | 293 | <?php |
294 | 294 | } |
@@ -298,50 +298,50 @@ discard block |
||
298 | 298 | * |
299 | 299 | * @param int $post_id |
300 | 300 | */ |
301 | - public static function save( $post_id ) { |
|
301 | + public static function save($post_id) { |
|
302 | 302 | |
303 | 303 | // Prepare the invoice. |
304 | - $invoice = new WPInv_Invoice( $post_id ); |
|
304 | + $invoice = new WPInv_Invoice($post_id); |
|
305 | 305 | |
306 | 306 | // Load new data. |
307 | 307 | $invoice->set_props( |
308 | 308 | array( |
309 | - 'template' => isset( $_POST['wpinv_template'] ) ? wpinv_clean( $_POST['wpinv_template'] ) : null, |
|
310 | - 'email_cc' => isset( $_POST['wpinv_cc'] ) ? wpinv_clean( $_POST['wpinv_cc'] ) : null, |
|
311 | - 'disable_taxes' => isset( $_POST['disable_taxes'] ), |
|
312 | - 'currency' => isset( $_POST['wpinv_currency'] ) ? wpinv_clean( $_POST['wpinv_currency'] ) : null, |
|
313 | - 'gateway' => ( $invoice->needs_payment() && isset( $_POST['wpinv_gateway'] ) ) ? wpinv_clean( $_POST['wpinv_gateway'] ) : null, |
|
314 | - 'address' => isset( $_POST['wpinv_address'] ) ? wpinv_clean( $_POST['wpinv_address'] ) : null, |
|
315 | - 'vat_number' => isset( $_POST['wpinv_vat_number'] ) ? wpinv_clean( $_POST['wpinv_vat_number'] ) : null, |
|
316 | - 'company' => isset( $_POST['wpinv_company'] ) ? wpinv_clean( $_POST['wpinv_company'] ) : null, |
|
317 | - 'zip' => isset( $_POST['wpinv_zip'] ) ? wpinv_clean( $_POST['wpinv_zip'] ) : null, |
|
318 | - 'state' => isset( $_POST['wpinv_state'] ) ? wpinv_clean( $_POST['wpinv_state'] ) : null, |
|
319 | - 'city' => isset( $_POST['wpinv_city'] ) ? wpinv_clean( $_POST['wpinv_city'] ) : null, |
|
320 | - 'country' => isset( $_POST['wpinv_country'] ) ? wpinv_clean( $_POST['wpinv_country'] ) : null, |
|
321 | - 'phone' => isset( $_POST['wpinv_phone'] ) ? wpinv_clean( $_POST['wpinv_phone'] ) : null, |
|
322 | - 'first_name' => isset( $_POST['wpinv_first_name'] ) ? wpinv_clean( $_POST['wpinv_first_name'] ) : null, |
|
323 | - 'last_name' => isset( $_POST['wpinv_last_name'] ) ? wpinv_clean( $_POST['wpinv_last_name'] ) : null, |
|
324 | - 'author' => isset( $_POST['post_author_override'] ) ? wpinv_clean( $_POST['post_author_override'] ) : null, |
|
325 | - 'date_created' => isset( $_POST['date_created'] ) ? wpinv_clean( $_POST['date_created'] ) : null, |
|
326 | - 'date_completed' => isset( $_POST['wpinv_date_completed'] ) ? wpinv_clean( $_POST['wpinv_date_completed'] ) : null, |
|
327 | - 'due_date' => isset( $_POST['wpinv_due_date'] ) ? wpinv_clean( $_POST['wpinv_due_date'] ) : null, |
|
328 | - 'number' => isset( $_POST['wpinv_number'] ) ? wpinv_clean( $_POST['wpinv_number'] ) : null, |
|
329 | - 'status' => isset( $_POST['wpinv_status'] ) ? wpinv_clean( $_POST['wpinv_status'] ) : null, |
|
309 | + 'template' => isset($_POST['wpinv_template']) ? wpinv_clean($_POST['wpinv_template']) : null, |
|
310 | + 'email_cc' => isset($_POST['wpinv_cc']) ? wpinv_clean($_POST['wpinv_cc']) : null, |
|
311 | + 'disable_taxes' => isset($_POST['disable_taxes']), |
|
312 | + 'currency' => isset($_POST['wpinv_currency']) ? wpinv_clean($_POST['wpinv_currency']) : null, |
|
313 | + 'gateway' => ($invoice->needs_payment() && isset($_POST['wpinv_gateway'])) ? wpinv_clean($_POST['wpinv_gateway']) : null, |
|
314 | + 'address' => isset($_POST['wpinv_address']) ? wpinv_clean($_POST['wpinv_address']) : null, |
|
315 | + 'vat_number' => isset($_POST['wpinv_vat_number']) ? wpinv_clean($_POST['wpinv_vat_number']) : null, |
|
316 | + 'company' => isset($_POST['wpinv_company']) ? wpinv_clean($_POST['wpinv_company']) : null, |
|
317 | + 'zip' => isset($_POST['wpinv_zip']) ? wpinv_clean($_POST['wpinv_zip']) : null, |
|
318 | + 'state' => isset($_POST['wpinv_state']) ? wpinv_clean($_POST['wpinv_state']) : null, |
|
319 | + 'city' => isset($_POST['wpinv_city']) ? wpinv_clean($_POST['wpinv_city']) : null, |
|
320 | + 'country' => isset($_POST['wpinv_country']) ? wpinv_clean($_POST['wpinv_country']) : null, |
|
321 | + 'phone' => isset($_POST['wpinv_phone']) ? wpinv_clean($_POST['wpinv_phone']) : null, |
|
322 | + 'first_name' => isset($_POST['wpinv_first_name']) ? wpinv_clean($_POST['wpinv_first_name']) : null, |
|
323 | + 'last_name' => isset($_POST['wpinv_last_name']) ? wpinv_clean($_POST['wpinv_last_name']) : null, |
|
324 | + 'author' => isset($_POST['post_author_override']) ? wpinv_clean($_POST['post_author_override']) : null, |
|
325 | + 'date_created' => isset($_POST['date_created']) ? wpinv_clean($_POST['date_created']) : null, |
|
326 | + 'date_completed' => isset($_POST['wpinv_date_completed']) ? wpinv_clean($_POST['wpinv_date_completed']) : null, |
|
327 | + 'due_date' => isset($_POST['wpinv_due_date']) ? wpinv_clean($_POST['wpinv_due_date']) : null, |
|
328 | + 'number' => isset($_POST['wpinv_number']) ? wpinv_clean($_POST['wpinv_number']) : null, |
|
329 | + 'status' => isset($_POST['wpinv_status']) ? wpinv_clean($_POST['wpinv_status']) : null, |
|
330 | 330 | ) |
331 | 331 | ); |
332 | 332 | |
333 | 333 | // Discount code. |
334 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
334 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
335 | 335 | |
336 | - if ( isset( $_POST['wpinv_discount_code'] ) ) { |
|
337 | - $invoice->set_discount_code( $_POST['wpinv_discount_code'] ); |
|
336 | + if (isset($_POST['wpinv_discount_code'])) { |
|
337 | + $invoice->set_discount_code($_POST['wpinv_discount_code']); |
|
338 | 338 | } |
339 | 339 | |
340 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
341 | - if ( $discount->exists() ) { |
|
342 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
340 | + $discount = new WPInv_Discount($invoice->get_discount_code()); |
|
341 | + if ($discount->exists()) { |
|
342 | + $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount)); |
|
343 | 343 | } else { |
344 | - $invoice->remove_discount( 'discount_code' ); |
|
344 | + $invoice->remove_discount('discount_code'); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | // Recalculate totals. |
@@ -350,17 +350,17 @@ discard block |
||
350 | 350 | } |
351 | 351 | |
352 | 352 | // If we're creating a new user... |
353 | - if ( ! empty( $_POST['wpinv_new_user'] ) && is_email( $_POST['wpinv_email'] ) ) { |
|
353 | + if (!empty($_POST['wpinv_new_user']) && is_email($_POST['wpinv_email'])) { |
|
354 | 354 | |
355 | 355 | // Attempt to create the user. |
356 | - $user = wpinv_create_user( sanitize_email( $_POST['wpinv_email'] ) ); |
|
356 | + $user = wpinv_create_user(sanitize_email($_POST['wpinv_email'])); |
|
357 | 357 | |
358 | 358 | |
359 | 359 | // If successful, update the invoice author. |
360 | - if ( is_numeric( $user ) ) { |
|
361 | - $invoice->set_author( $user ); |
|
360 | + if (is_numeric($user)) { |
|
361 | + $invoice->set_author($user); |
|
362 | 362 | } else { |
363 | - wpinv_error_log( $user->get_error_message(), __( 'Invoice add new user', 'invoicing' ), __FILE__, __LINE__ ); |
|
363 | + wpinv_error_log($user->get_error_message(), __('Invoice add new user', 'invoicing'), __FILE__, __LINE__); |
|
364 | 364 | } |
365 | 365 | } |
366 | 366 | |
@@ -374,23 +374,23 @@ discard block |
||
374 | 374 | $GLOBALS['wpinv_skip_invoice_notification'] = false; |
375 | 375 | |
376 | 376 | // (Maybe) send new user notification. |
377 | - if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', true ) ) { |
|
378 | - wp_send_new_user_notifications( $user, 'user' ); |
|
377 | + if (!empty($user) && is_numeric($user) && apply_filters('getpaid_send_new_user_notification', true)) { |
|
378 | + wp_send_new_user_notifications($user, 'user'); |
|
379 | 379 | } |
380 | 380 | |
381 | - if ( ! empty( $_POST['send_to_customer'] ) && ! $invoice->is_draft() ) { |
|
381 | + if (!empty($_POST['send_to_customer']) && !$invoice->is_draft()) { |
|
382 | 382 | |
383 | - $sent = getpaid()->get( 'invoice_emails' )->user_invoice( $invoice, true ); |
|
383 | + $sent = getpaid()->get('invoice_emails')->user_invoice($invoice, true); |
|
384 | 384 | |
385 | - if ( $sent ) { |
|
386 | - getpaid_admin()->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) ); |
|
385 | + if ($sent) { |
|
386 | + getpaid_admin()->show_success(__('Invoice was successfully sent to the customer', 'invoicing')); |
|
387 | 387 | } else { |
388 | - getpaid_admin()->show_error( __( 'Could not send the invoice to the customer', 'invoicing' ) ); |
|
388 | + getpaid_admin()->show_error(__('Could not send the invoice to the customer', 'invoicing')); |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | } |
392 | 392 | |
393 | 393 | // Fires after an invoice is saved. |
394 | - do_action( 'wpinv_invoice_metabox_saved', $invoice ); |
|
394 | + do_action('wpinv_invoice_metabox_saved', $invoice); |
|
395 | 395 | } |
396 | 396 | } |
@@ -7,15 +7,15 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
10 | +if (!defined('WPINC')) { |
|
11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | |
15 | 15 | function wpinv_get_default_country() { |
16 | - $country = wpinv_get_option( 'default_country', 'UK' ); |
|
16 | + $country = wpinv_get_option('default_country', 'UK'); |
|
17 | 17 | |
18 | - return apply_filters( 'wpinv_default_country', $country ); |
|
18 | + return apply_filters('wpinv_default_country', $country); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return string |
25 | 25 | */ |
26 | -function getpaid_get_ip_country( $ip_address = '' ) { |
|
27 | - $country = GetPaid_Geolocation::geolocate_ip( $ip_address, true ); |
|
26 | +function getpaid_get_ip_country($ip_address = '') { |
|
27 | + $country = GetPaid_Geolocation::geolocate_ip($ip_address, true); |
|
28 | 28 | return $country['country']; |
29 | 29 | } |
30 | 30 | |
@@ -34,59 +34,59 @@ discard block |
||
34 | 34 | * @param string $country The country code to sanitize |
35 | 35 | * @return array |
36 | 36 | */ |
37 | -function wpinv_sanitize_country( $country ) { |
|
37 | +function wpinv_sanitize_country($country) { |
|
38 | 38 | |
39 | 39 | // Enure the country is specified |
40 | - if ( empty( $country ) ) { |
|
40 | + if (empty($country)) { |
|
41 | 41 | $country = wpinv_get_default_country(); |
42 | 42 | } |
43 | - return trim( wpinv_utf8_strtoupper( $country ) ); |
|
43 | + return trim(wpinv_utf8_strtoupper($country)); |
|
44 | 44 | |
45 | 45 | } |
46 | 46 | |
47 | -function wpinv_is_base_country( $country ) { |
|
47 | +function wpinv_is_base_country($country) { |
|
48 | 48 | $base_country = wpinv_get_default_country(); |
49 | 49 | |
50 | - if ( $base_country === 'UK' ) { |
|
50 | + if ($base_country === 'UK') { |
|
51 | 51 | $base_country = 'GB'; |
52 | 52 | } |
53 | - if ( $country == 'UK' ) { |
|
53 | + if ($country == 'UK') { |
|
54 | 54 | $country = 'GB'; |
55 | 55 | } |
56 | 56 | |
57 | - return ( $country && $country === $base_country ) ? true : false; |
|
57 | + return ($country && $country === $base_country) ? true : false; |
|
58 | 58 | } |
59 | 59 | |
60 | -function wpinv_country_name( $country_code = '' ) { |
|
60 | +function wpinv_country_name($country_code = '') { |
|
61 | 61 | $countries = wpinv_get_country_list(); |
62 | 62 | $country_code = $country_code == 'UK' ? 'GB' : $country_code; |
63 | - $country = isset( $countries[$country_code] ) ? $countries[$country_code] : $country_code; |
|
63 | + $country = isset($countries[$country_code]) ? $countries[$country_code] : $country_code; |
|
64 | 64 | |
65 | - return apply_filters( 'wpinv_country_name', $country, $country_code ); |
|
65 | + return apply_filters('wpinv_country_name', $country, $country_code); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | function wpinv_get_default_state() { |
69 | - $state = wpinv_get_option( 'default_state', '' ); |
|
69 | + $state = wpinv_get_option('default_state', ''); |
|
70 | 70 | |
71 | - return apply_filters( 'wpinv_default_state', $state ); |
|
71 | + return apply_filters('wpinv_default_state', $state); |
|
72 | 72 | } |
73 | 73 | |
74 | -function wpinv_state_name( $state_code = '', $country_code = '' ) { |
|
74 | +function wpinv_state_name($state_code = '', $country_code = '') { |
|
75 | 75 | $state = $state_code; |
76 | 76 | |
77 | - if ( !empty( $country_code ) ) { |
|
78 | - $states = wpinv_get_country_states( $country_code ); |
|
77 | + if (!empty($country_code)) { |
|
78 | + $states = wpinv_get_country_states($country_code); |
|
79 | 79 | |
80 | - $state = !empty( $states ) && isset( $states[$state_code] ) ? $states[$state_code] : $state; |
|
80 | + $state = !empty($states) && isset($states[$state_code]) ? $states[$state_code] : $state; |
|
81 | 81 | } |
82 | 82 | |
83 | - return apply_filters( 'wpinv_state_name', $state, $state_code, $country_code ); |
|
83 | + return apply_filters('wpinv_state_name', $state, $state_code, $country_code); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | function wpinv_store_address() { |
87 | - $address = wpinv_get_option( 'store_address', '' ); |
|
87 | + $address = wpinv_get_option('store_address', ''); |
|
88 | 88 | |
89 | - return apply_filters( 'wpinv_store_address', $address ); |
|
89 | + return apply_filters('wpinv_store_address', $address); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -94,24 +94,24 @@ discard block |
||
94 | 94 | * |
95 | 95 | * @param WPInv_Invoice $invoice |
96 | 96 | */ |
97 | -function getpaid_maybe_add_default_address( &$invoice ) { |
|
97 | +function getpaid_maybe_add_default_address(&$invoice) { |
|
98 | 98 | |
99 | 99 | $user_id = $invoice->get_user_id(); |
100 | 100 | |
101 | 101 | // Abort if the invoice belongs to no one. |
102 | - if ( empty( $user_id ) ) { |
|
102 | + if (empty($user_id)) { |
|
103 | 103 | return; |
104 | 104 | } |
105 | 105 | |
106 | 106 | // Fill in defaults whenever necessary. |
107 | - foreach ( wpinv_get_user_address( $user_id ) as $key => $value ) { |
|
107 | + foreach (wpinv_get_user_address($user_id) as $key => $value) { |
|
108 | 108 | |
109 | - if ( is_callable( $invoice, "get_$key" ) ) { |
|
110 | - $current = call_user_func( array( $invoice, "get_$key" ) ); |
|
109 | + if (is_callable($invoice, "get_$key")) { |
|
110 | + $current = call_user_func(array($invoice, "get_$key")); |
|
111 | 111 | |
112 | - if ( empty( $current ) ) { |
|
112 | + if (empty($current)) { |
|
113 | 113 | $method = "set_$key"; |
114 | - $invoice->$method( $value ); |
|
114 | + $invoice->$method($value); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | } |
@@ -130,21 +130,21 @@ discard block |
||
130 | 130 | $address_fields = apply_filters( |
131 | 131 | 'getpaid_user_address_fields', |
132 | 132 | array( |
133 | - 'first_name' => __( 'First Name', 'invoicing' ), |
|
134 | - 'last_name' => __( 'Last Name', 'invoicing' ), |
|
135 | - 'country' => __( 'Country', 'invoicing' ), |
|
136 | - 'state' => __( 'State', 'invoicing' ), |
|
137 | - 'city' => __( 'City', 'invoicing' ), |
|
138 | - 'zip' => __( 'Zip/Postal Code', 'invoicing' ), |
|
139 | - 'address' => __( 'Address', 'invoicing' ), |
|
140 | - 'phone' => __( 'Phone Number', 'invoicing' ), |
|
141 | - 'company' => __( 'Company', 'invoicing' ), |
|
142 | - 'vat_number' => __( 'VAT Number', 'invoicing' ), |
|
133 | + 'first_name' => __('First Name', 'invoicing'), |
|
134 | + 'last_name' => __('Last Name', 'invoicing'), |
|
135 | + 'country' => __('Country', 'invoicing'), |
|
136 | + 'state' => __('State', 'invoicing'), |
|
137 | + 'city' => __('City', 'invoicing'), |
|
138 | + 'zip' => __('Zip/Postal Code', 'invoicing'), |
|
139 | + 'address' => __('Address', 'invoicing'), |
|
140 | + 'phone' => __('Phone Number', 'invoicing'), |
|
141 | + 'company' => __('Company', 'invoicing'), |
|
142 | + 'vat_number' => __('VAT Number', 'invoicing'), |
|
143 | 143 | ) |
144 | 144 | ); |
145 | 145 | |
146 | - if ( ! wpinv_use_taxes() && isset( $address_fields['vat_number'] ) ) { |
|
147 | - unset( $address_fields['vat_number'] ); |
|
146 | + if (!wpinv_use_taxes() && isset($address_fields['vat_number'])) { |
|
147 | + unset($address_fields['vat_number']); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | return $address_fields; |
@@ -155,8 +155,8 @@ discard block |
||
155 | 155 | * |
156 | 156 | * @return bool |
157 | 157 | */ |
158 | -function getpaid_is_address_field_whitelisted( $key ) { |
|
159 | - return array_key_exists( $key, getpaid_user_address_fields() ); |
|
158 | +function getpaid_is_address_field_whitelisted($key) { |
|
159 | + return array_key_exists($key, getpaid_user_address_fields()); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -166,24 +166,24 @@ discard block |
||
166 | 166 | * |
167 | 167 | * @param WPInv_Invoice $invoice |
168 | 168 | */ |
169 | -function getpaid_save_invoice_user_address( $invoice ) { |
|
169 | +function getpaid_save_invoice_user_address($invoice) { |
|
170 | 170 | |
171 | 171 | // Retrieve the invoice. |
172 | - $invoice = wpinv_get_invoice( $invoice ); |
|
172 | + $invoice = wpinv_get_invoice($invoice); |
|
173 | 173 | |
174 | 174 | // Abort if it does not exist. |
175 | - if ( empty( $invoice ) ) { |
|
175 | + if (empty($invoice)) { |
|
176 | 176 | return; |
177 | 177 | } |
178 | 178 | |
179 | - foreach ( array_keys( getpaid_user_address_fields() ) as $field ) { |
|
179 | + foreach (array_keys(getpaid_user_address_fields()) as $field) { |
|
180 | 180 | |
181 | - if ( is_callable( array( $invoice, "get_$field" ) ) ) { |
|
182 | - $value = call_user_func( array( $invoice, "get_$field" ) ); |
|
181 | + if (is_callable(array($invoice, "get_$field"))) { |
|
182 | + $value = call_user_func(array($invoice, "get_$field")); |
|
183 | 183 | |
184 | 184 | // Only save if it is not empty. |
185 | - if ( ! empty( $value ) ) { |
|
186 | - update_user_meta( $invoice->get_user_id(), '_wpinv_' . $field, $value ); |
|
185 | + if (!empty($value)) { |
|
186 | + update_user_meta($invoice->get_user_id(), '_wpinv_' . $field, $value); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | } |
@@ -191,8 +191,8 @@ discard block |
||
191 | 191 | } |
192 | 192 | |
193 | 193 | } |
194 | -add_action( 'getpaid_new_invoice', 'getpaid_save_invoice_user_address' ); |
|
195 | -add_action( 'getpaid_update_invoice', 'getpaid_save_invoice_user_address' ); |
|
194 | +add_action('getpaid_new_invoice', 'getpaid_save_invoice_user_address'); |
|
195 | +add_action('getpaid_update_invoice', 'getpaid_save_invoice_user_address'); |
|
196 | 196 | |
197 | 197 | /** |
198 | 198 | * Retrieves a saved user address. |
@@ -201,14 +201,14 @@ discard block |
||
201 | 201 | * @param bool $with_default Whether or not we should use the default country and state. |
202 | 202 | * @return array |
203 | 203 | */ |
204 | -function wpinv_get_user_address( $user_id = 0, $with_default = true ) { |
|
204 | +function wpinv_get_user_address($user_id = 0, $with_default = true) { |
|
205 | 205 | |
206 | 206 | // Prepare the user id. |
207 | - $user_id = empty( $user_id ) ? get_current_user_id() : $user_id; |
|
208 | - $user_info = get_userdata( $user_id ); |
|
207 | + $user_id = empty($user_id) ? get_current_user_id() : $user_id; |
|
208 | + $user_info = get_userdata($user_id); |
|
209 | 209 | |
210 | 210 | // Abort if non exists. |
211 | - if ( empty( $user_info ) ) { |
|
211 | + if (empty($user_info)) { |
|
212 | 212 | return array(); |
213 | 213 | } |
214 | 214 | |
@@ -218,11 +218,11 @@ discard block |
||
218 | 218 | 'email' => $user_info->user_email, |
219 | 219 | ); |
220 | 220 | |
221 | - foreach ( array_keys( getpaid_user_address_fields() ) as $field ) { |
|
222 | - $address[$field] = getpaid_get_user_address_field( $user_id, $field ); |
|
221 | + foreach (array_keys(getpaid_user_address_fields()) as $field) { |
|
222 | + $address[$field] = getpaid_get_user_address_field($user_id, $field); |
|
223 | 223 | } |
224 | 224 | |
225 | - if ( ! $with_default ) { |
|
225 | + if (!$with_default) { |
|
226 | 226 | return $address; |
227 | 227 | } |
228 | 228 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | 'country' => wpinv_get_default_country(), |
234 | 234 | ); |
235 | 235 | |
236 | - return getpaid_array_merge_if_empty( $address, $defaults ); |
|
236 | + return getpaid_array_merge_if_empty($address, $defaults); |
|
237 | 237 | |
238 | 238 | } |
239 | 239 | |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * @param string $field The field to use. |
245 | 245 | * @return string|null |
246 | 246 | */ |
247 | -function getpaid_get_user_address_field( $user_id, $field ) { |
|
247 | +function getpaid_get_user_address_field($user_id, $field) { |
|
248 | 248 | |
249 | 249 | $prefixes = array( |
250 | 250 | '_wpinv_', |
@@ -252,15 +252,15 @@ discard block |
||
252 | 252 | '' |
253 | 253 | ); |
254 | 254 | |
255 | - foreach ( $prefixes as $prefix ) { |
|
255 | + foreach ($prefixes as $prefix) { |
|
256 | 256 | |
257 | 257 | // Meta table. |
258 | - $value = get_user_meta( $user_id, $prefix . $field, true ); |
|
258 | + $value = get_user_meta($user_id, $prefix . $field, true); |
|
259 | 259 | |
260 | 260 | // UWP table. |
261 | - $value = ( empty( $value ) && function_exists( 'uwp_get_usermeta' ) ) ? uwp_get_usermeta( $user_id, $prefix . $field ) : $value; |
|
261 | + $value = (empty($value) && function_exists('uwp_get_usermeta')) ? uwp_get_usermeta($user_id, $prefix . $field) : $value; |
|
262 | 262 | |
263 | - if ( ! empty( $value ) ) { |
|
263 | + if (!empty($value)) { |
|
264 | 264 | return $value; |
265 | 265 | } |
266 | 266 | |
@@ -277,16 +277,16 @@ discard block |
||
277 | 277 | * @param string $return What to return. |
278 | 278 | * @return array |
279 | 279 | */ |
280 | -function wpinv_get_continents( $return = 'all' ) { |
|
280 | +function wpinv_get_continents($return = 'all') { |
|
281 | 281 | |
282 | - $continents = wpinv_get_data( 'continents' ); |
|
282 | + $continents = wpinv_get_data('continents'); |
|
283 | 283 | |
284 | - switch( $return ) { |
|
284 | + switch ($return) { |
|
285 | 285 | case 'name' : |
286 | - return wp_list_pluck( $continents, 'name' ); |
|
286 | + return wp_list_pluck($continents, 'name'); |
|
287 | 287 | break; |
288 | 288 | case 'countries' : |
289 | - return wp_list_pluck( $continents, 'countries' ); |
|
289 | + return wp_list_pluck($continents, 'countries'); |
|
290 | 290 | break; |
291 | 291 | default : |
292 | 292 | return $continents; |
@@ -302,12 +302,12 @@ discard block |
||
302 | 302 | * @param string $country Country code. If no code is specified, defaults to the default country. |
303 | 303 | * @return string |
304 | 304 | */ |
305 | -function wpinv_get_continent_code_for_country( $country = false ) { |
|
305 | +function wpinv_get_continent_code_for_country($country = false) { |
|
306 | 306 | |
307 | - $country = wpinv_sanitize_country( $country ); |
|
307 | + $country = wpinv_sanitize_country($country); |
|
308 | 308 | |
309 | - foreach ( wpinv_get_continents( 'countries' ) as $continent_code => $countries ) { |
|
310 | - if ( false !== array_search( $country, $countries, true ) ) { |
|
309 | + foreach (wpinv_get_continents('countries') as $continent_code => $countries) { |
|
310 | + if (false !== array_search($country, $countries, true)) { |
|
311 | 311 | return $continent_code; |
312 | 312 | } |
313 | 313 | } |
@@ -323,13 +323,13 @@ discard block |
||
323 | 323 | * @param string $country Country code. If no code is specified, defaults to the default country. |
324 | 324 | * @return array |
325 | 325 | */ |
326 | -function wpinv_get_country_calling_code( $country = null) { |
|
326 | +function wpinv_get_country_calling_code($country = null) { |
|
327 | 327 | |
328 | - $country = wpinv_sanitize_country( $country ); |
|
329 | - $codes = wpinv_get_data( 'phone-codes' ); |
|
330 | - $code = isset( $codes[ $country ] ) ? $codes[ $country ] : ''; |
|
328 | + $country = wpinv_sanitize_country($country); |
|
329 | + $codes = wpinv_get_data('phone-codes'); |
|
330 | + $code = isset($codes[$country]) ? $codes[$country] : ''; |
|
331 | 331 | |
332 | - if ( is_array( $code ) ) { |
|
332 | + if (is_array($code)) { |
|
333 | 333 | return $code[0]; |
334 | 334 | } |
335 | 335 | return $code; |
@@ -342,8 +342,8 @@ discard block |
||
342 | 342 | * @param bool $first_empty Whether or not the first item in the list should be empty |
343 | 343 | * @return array |
344 | 344 | */ |
345 | -function wpinv_get_country_list( $first_empty = false ) { |
|
346 | - return wpinv_maybe_add_empty_option( apply_filters( 'wpinv_countries', wpinv_get_data( 'countries' ) ), $first_empty ); |
|
345 | +function wpinv_get_country_list($first_empty = false) { |
|
346 | + return wpinv_maybe_add_empty_option(apply_filters('wpinv_countries', wpinv_get_data('countries')), $first_empty); |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | /** |
@@ -353,22 +353,22 @@ discard block |
||
353 | 353 | * @param bool $first_empty Whether or not the first item in the list should be empty |
354 | 354 | * @return array |
355 | 355 | */ |
356 | -function wpinv_get_country_states( $country = null, $first_empty = false ) { |
|
356 | +function wpinv_get_country_states($country = null, $first_empty = false) { |
|
357 | 357 | |
358 | 358 | // Prepare the country. |
359 | - $country = wpinv_sanitize_country( $country ); |
|
359 | + $country = wpinv_sanitize_country($country); |
|
360 | 360 | |
361 | 361 | // Fetch all states. |
362 | - $all_states = wpinv_get_data( 'states' ); |
|
362 | + $all_states = wpinv_get_data('states'); |
|
363 | 363 | |
364 | 364 | // Fetch the specified country's states. |
365 | - $states = isset( $all_states[ $country ] ) ? $all_states[ $country ] : array() ; |
|
366 | - $states = apply_filters( "wpinv_{$country}_states", $states ); |
|
367 | - $states = apply_filters( 'wpinv_country_states', $states, $country ); |
|
365 | + $states = isset($all_states[$country]) ? $all_states[$country] : array(); |
|
366 | + $states = apply_filters("wpinv_{$country}_states", $states); |
|
367 | + $states = apply_filters('wpinv_country_states', $states, $country); |
|
368 | 368 | |
369 | - asort( $states ); |
|
369 | + asort($states); |
|
370 | 370 | |
371 | - return wpinv_maybe_add_empty_option( $states, $first_empty ); |
|
371 | + return wpinv_maybe_add_empty_option($states, $first_empty); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | /** |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | * @return array |
379 | 379 | */ |
380 | 380 | function wpinv_get_us_states_list() { |
381 | - return apply_filters( 'wpinv_usa_states', wpinv_get_country_states( 'US' ) ); |
|
381 | + return apply_filters('wpinv_usa_states', wpinv_get_country_states('US')); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | /** |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | * @return array |
389 | 389 | */ |
390 | 390 | function wpinv_get_canada_states_list() { |
391 | - return apply_filters( 'wpinv_canada_provinces', wpinv_get_country_states( 'CA' ) ); |
|
391 | + return apply_filters('wpinv_canada_provinces', wpinv_get_country_states('CA')); |
|
392 | 392 | } |
393 | 393 | |
394 | 394 | /** |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | * @return array |
399 | 399 | */ |
400 | 400 | function wpinv_get_australia_states_list() { |
401 | - return apply_filters( 'wpinv_australia_states', wpinv_get_country_states( 'AU' ) ); |
|
401 | + return apply_filters('wpinv_australia_states', wpinv_get_country_states('AU')); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | /** |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | * @return array |
409 | 409 | */ |
410 | 410 | function wpinv_get_bangladesh_states_list() { |
411 | - return apply_filters( 'wpinv_bangladesh_states', wpinv_get_country_states( 'BD' ) ); |
|
411 | + return apply_filters('wpinv_bangladesh_states', wpinv_get_country_states('BD')); |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | /** |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | * @return array |
419 | 419 | */ |
420 | 420 | function wpinv_get_brazil_states_list() { |
421 | - return apply_filters( 'wpinv_brazil_states', wpinv_get_country_states( 'BR' ) ); |
|
421 | + return apply_filters('wpinv_brazil_states', wpinv_get_country_states('BR')); |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | /** |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | * @return array |
429 | 429 | */ |
430 | 430 | function wpinv_get_bulgaria_states_list() { |
431 | - return apply_filters( 'wpinv_bulgaria_states', wpinv_get_country_states( 'BG' ) ); |
|
431 | + return apply_filters('wpinv_bulgaria_states', wpinv_get_country_states('BG')); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | /** |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | * @return array |
439 | 439 | */ |
440 | 440 | function wpinv_get_hong_kong_states_list() { |
441 | - return apply_filters( 'wpinv_hong_kong_states', wpinv_get_country_states( 'HK' ) ); |
|
441 | + return apply_filters('wpinv_hong_kong_states', wpinv_get_country_states('HK')); |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | /** |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | * @return array |
449 | 449 | */ |
450 | 450 | function wpinv_get_hungary_states_list() { |
451 | - return apply_filters( 'wpinv_hungary_states', wpinv_get_country_states( 'HU' ) ); |
|
451 | + return apply_filters('wpinv_hungary_states', wpinv_get_country_states('HU')); |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | /** |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | * @return array |
459 | 459 | */ |
460 | 460 | function wpinv_get_japan_states_list() { |
461 | - return apply_filters( 'wpinv_japan_states', wpinv_get_country_states( 'JP' ) ); |
|
461 | + return apply_filters('wpinv_japan_states', wpinv_get_country_states('JP')); |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | /** |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | * @return array |
469 | 469 | */ |
470 | 470 | function wpinv_get_china_states_list() { |
471 | - return apply_filters( 'wpinv_china_states', wpinv_get_country_states( 'CN' ) ); |
|
471 | + return apply_filters('wpinv_china_states', wpinv_get_country_states('CN')); |
|
472 | 472 | } |
473 | 473 | |
474 | 474 | /** |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | * @return array |
479 | 479 | */ |
480 | 480 | function wpinv_get_new_zealand_states_list() { |
481 | - return apply_filters( 'wpinv_new_zealand_states', wpinv_get_country_states( 'NZ' ) ); |
|
481 | + return apply_filters('wpinv_new_zealand_states', wpinv_get_country_states('NZ')); |
|
482 | 482 | } |
483 | 483 | |
484 | 484 | /** |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | * @return array |
489 | 489 | */ |
490 | 490 | function wpinv_get_peru_states_list() { |
491 | - return apply_filters( 'wpinv_peru_states', wpinv_get_country_states( 'PE' ) ); |
|
491 | + return apply_filters('wpinv_peru_states', wpinv_get_country_states('PE')); |
|
492 | 492 | } |
493 | 493 | |
494 | 494 | /** |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | * @return array |
499 | 499 | */ |
500 | 500 | function wpinv_get_indonesia_states_list() { |
501 | - return apply_filters( 'wpinv_indonesia_states', wpinv_get_country_states( 'ID' ) ); |
|
501 | + return apply_filters('wpinv_indonesia_states', wpinv_get_country_states('ID')); |
|
502 | 502 | } |
503 | 503 | |
504 | 504 | /** |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | * @return array |
509 | 509 | */ |
510 | 510 | function wpinv_get_india_states_list() { |
511 | - return apply_filters( 'wpinv_india_states', wpinv_get_country_states( 'IN' ) ); |
|
511 | + return apply_filters('wpinv_india_states', wpinv_get_country_states('IN')); |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | /** |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | * @return array |
519 | 519 | */ |
520 | 520 | function wpinv_get_iran_states_list() { |
521 | - return apply_filters( 'wpinv_iran_states', wpinv_get_country_states( 'IR' ) ); |
|
521 | + return apply_filters('wpinv_iran_states', wpinv_get_country_states('IR')); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | /** |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | * @return array |
529 | 529 | */ |
530 | 530 | function wpinv_get_italy_states_list() { |
531 | - return apply_filters( 'wpinv_italy_states', wpinv_get_country_states( 'IT' ) ); |
|
531 | + return apply_filters('wpinv_italy_states', wpinv_get_country_states('IT')); |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | /** |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | * @return array |
539 | 539 | */ |
540 | 540 | function wpinv_get_malaysia_states_list() { |
541 | - return apply_filters( 'wpinv_malaysia_states', wpinv_get_country_states( 'MY' ) ); |
|
541 | + return apply_filters('wpinv_malaysia_states', wpinv_get_country_states('MY')); |
|
542 | 542 | } |
543 | 543 | |
544 | 544 | /** |
@@ -548,7 +548,7 @@ discard block |
||
548 | 548 | * @return array |
549 | 549 | */ |
550 | 550 | function wpinv_get_mexico_states_list() { |
551 | - return apply_filters( 'wpinv_mexico_states', wpinv_get_country_states( 'MX' ) ); |
|
551 | + return apply_filters('wpinv_mexico_states', wpinv_get_country_states('MX')); |
|
552 | 552 | } |
553 | 553 | |
554 | 554 | /** |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | * @return array |
559 | 559 | */ |
560 | 560 | function wpinv_get_nepal_states_list() { |
561 | - return apply_filters( 'wpinv_nepal_states', wpinv_get_country_states( 'NP' ) ); |
|
561 | + return apply_filters('wpinv_nepal_states', wpinv_get_country_states('NP')); |
|
562 | 562 | } |
563 | 563 | |
564 | 564 | /** |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | * @return array |
569 | 569 | */ |
570 | 570 | function wpinv_get_south_africa_states_list() { |
571 | - return apply_filters( 'wpinv_south_africa_states', wpinv_get_country_states( 'ZA' ) ); |
|
571 | + return apply_filters('wpinv_south_africa_states', wpinv_get_country_states('ZA')); |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | /** |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | * @return array |
579 | 579 | */ |
580 | 580 | function wpinv_get_thailand_states_list() { |
581 | - return apply_filters( 'wpinv_thailand_states', wpinv_get_country_states( 'TH' ) ); |
|
581 | + return apply_filters('wpinv_thailand_states', wpinv_get_country_states('TH')); |
|
582 | 582 | } |
583 | 583 | |
584 | 584 | /** |
@@ -588,7 +588,7 @@ discard block |
||
588 | 588 | * @return array |
589 | 589 | */ |
590 | 590 | function wpinv_get_turkey_states_list() { |
591 | - return apply_filters( 'wpinv_turkey_states', wpinv_get_country_states( 'TR' ) ); |
|
591 | + return apply_filters('wpinv_turkey_states', wpinv_get_country_states('TR')); |
|
592 | 592 | } |
593 | 593 | |
594 | 594 | /** |
@@ -598,28 +598,28 @@ discard block |
||
598 | 598 | * @return array |
599 | 599 | */ |
600 | 600 | function wpinv_get_spain_states_list() { |
601 | - return apply_filters( 'wpinv_spain_states', wpinv_get_country_states( 'ES' ) ); |
|
601 | + return apply_filters('wpinv_spain_states', wpinv_get_country_states('ES')); |
|
602 | 602 | } |
603 | 603 | |
604 | 604 | function wpinv_get_states_field() { |
605 | - if( empty( $_POST['country'] ) ) { |
|
605 | + if (empty($_POST['country'])) { |
|
606 | 606 | $_POST['country'] = wpinv_get_default_country(); |
607 | 607 | } |
608 | - $states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) ); |
|
608 | + $states = wpinv_get_country_states(sanitize_text_field($_POST['country'])); |
|
609 | 609 | |
610 | - if( !empty( $states ) ) { |
|
611 | - $sanitized_field_name = sanitize_text_field( $_POST['field_name'] ); |
|
610 | + if (!empty($states)) { |
|
611 | + $sanitized_field_name = sanitize_text_field($_POST['field_name']); |
|
612 | 612 | |
613 | 613 | $args = array( |
614 | 614 | 'name' => $sanitized_field_name, |
615 | 615 | 'id' => $sanitized_field_name, |
616 | 616 | 'class' => $sanitized_field_name . 'custom-select wpinv-select wpi_select2', |
617 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
617 | + 'options' => array_merge(array('' => ''), $states), |
|
618 | 618 | 'show_option_all' => false, |
619 | 619 | 'show_option_none' => false |
620 | 620 | ); |
621 | 621 | |
622 | - $response = wpinv_html_select( $args ); |
|
622 | + $response = wpinv_html_select($args); |
|
623 | 623 | |
624 | 624 | } else { |
625 | 625 | $response = 'nostates'; |
@@ -628,10 +628,10 @@ discard block |
||
628 | 628 | return $response; |
629 | 629 | } |
630 | 630 | |
631 | -function wpinv_default_billing_country( $country = '', $user_id = 0 ) { |
|
632 | - $country = !empty( $country ) ? $country : wpinv_get_default_country(); |
|
631 | +function wpinv_default_billing_country($country = '', $user_id = 0) { |
|
632 | + $country = !empty($country) ? $country : wpinv_get_default_country(); |
|
633 | 633 | |
634 | - return apply_filters( 'wpinv_default_billing_country', $country, $user_id ); |
|
634 | + return apply_filters('wpinv_default_billing_country', $country, $user_id); |
|
635 | 635 | } |
636 | 636 | |
637 | 637 | /** |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | */ |
644 | 644 | function wpinv_get_address_formats() { |
645 | 645 | |
646 | - return apply_filters( 'wpinv_localisation_address_formats', |
|
646 | + return apply_filters('wpinv_localisation_address_formats', |
|
647 | 647 | array( |
648 | 648 | 'default' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}\n{{zip}}\n{{country}}", |
649 | 649 | 'AU' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}} {{zip}}\n{{country}}", |
@@ -692,9 +692,9 @@ discard block |
||
692 | 692 | * @see `wpinv_get_invoice_address_replacements` |
693 | 693 | * @return string |
694 | 694 | */ |
695 | -function wpinv_get_full_address_format( $country = false) { |
|
695 | +function wpinv_get_full_address_format($country = false) { |
|
696 | 696 | |
697 | - if( empty( $country ) ) { |
|
697 | + if (empty($country)) { |
|
698 | 698 | $country = wpinv_get_default_country(); |
699 | 699 | } |
700 | 700 | |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | $formats = wpinv_get_address_formats(); |
703 | 703 | |
704 | 704 | // Get format for the specified country. |
705 | - $format = ( $country && isset( $formats[ $country ] ) ) ? $formats[ $country ] : $formats['default']; |
|
705 | + $format = ($country && isset($formats[$country])) ? $formats[$country] : $formats['default']; |
|
706 | 706 | |
707 | 707 | /** |
708 | 708 | * Filters the address format to use on Invoices. |
@@ -714,7 +714,7 @@ discard block |
||
714 | 714 | * @param string $format The address format to use. |
715 | 715 | * @param string $country The country who's address format is being retrieved. |
716 | 716 | */ |
717 | - return apply_filters( 'wpinv_get_full_address_format', $format, $country ); |
|
717 | + return apply_filters('wpinv_get_full_address_format', $format, $country); |
|
718 | 718 | } |
719 | 719 | |
720 | 720 | /** |
@@ -725,7 +725,7 @@ discard block |
||
725 | 725 | * @param array $billing_details customer's billing details |
726 | 726 | * @return array |
727 | 727 | */ |
728 | -function wpinv_get_invoice_address_replacements( $billing_details ) { |
|
728 | +function wpinv_get_invoice_address_replacements($billing_details) { |
|
729 | 729 | |
730 | 730 | $default_args = array( |
731 | 731 | 'address' => '', |
@@ -738,22 +738,22 @@ discard block |
||
738 | 738 | 'company' => '', |
739 | 739 | ); |
740 | 740 | |
741 | - $args = map_deep( wp_parse_args( $billing_details, $default_args ), 'trim' ); |
|
741 | + $args = map_deep(wp_parse_args($billing_details, $default_args), 'trim'); |
|
742 | 742 | $state = $args['state']; |
743 | 743 | $country = $args['country']; |
744 | 744 | |
745 | 745 | // Handle full country name. |
746 | - $full_country = empty( $country ) ? $country : wpinv_country_name( $country ); |
|
746 | + $full_country = empty($country) ? $country : wpinv_country_name($country); |
|
747 | 747 | |
748 | 748 | // Handle full state name. |
749 | - $full_state = ( $country && $state ) ? wpinv_state_name( $state, $country ) : $state; |
|
749 | + $full_state = ($country && $state) ? wpinv_state_name($state, $country) : $state; |
|
750 | 750 | |
751 | 751 | $args['postcode'] = $args['zip']; |
752 | 752 | $args['name'] = $args['first_name'] . ' ' . $args['last_name']; |
753 | 753 | $args['state'] = $full_state; |
754 | 754 | $args['state_code'] = $state; |
755 | 755 | $args['country'] = $full_country; |
756 | - $args['country_code']= $country; |
|
756 | + $args['country_code'] = $country; |
|
757 | 757 | |
758 | 758 | /** |
759 | 759 | * Filters the address format replacements to use on Invoices. |
@@ -764,14 +764,14 @@ discard block |
||
764 | 764 | * @param array $replacements The address replacements to use. |
765 | 765 | * @param array $billing_details The billing details to use. |
766 | 766 | */ |
767 | - $replacements = apply_filters( 'wpinv_get_invoice_address_replacements', $args, $billing_details ); |
|
767 | + $replacements = apply_filters('wpinv_get_invoice_address_replacements', $args, $billing_details); |
|
768 | 768 | |
769 | 769 | $return = array(); |
770 | 770 | |
771 | - foreach( $replacements as $key => $value ) { |
|
772 | - $value = is_scalar( $value ) ? trim( sanitize_text_field( $value ) ) : ''; |
|
771 | + foreach ($replacements as $key => $value) { |
|
772 | + $value = is_scalar($value) ? trim(sanitize_text_field($value)) : ''; |
|
773 | 773 | $return['{{' . $key . '}}'] = $value; |
774 | - $return['{{' . $key . '_upper}}'] = wpinv_utf8_strtoupper( $value ); |
|
774 | + $return['{{' . $key . '_upper}}'] = wpinv_utf8_strtoupper($value); |
|
775 | 775 | } |
776 | 776 | |
777 | 777 | return $return; |
@@ -785,6 +785,6 @@ discard block |
||
785 | 785 | * @since 1.0.14 |
786 | 786 | * @return string |
787 | 787 | */ |
788 | -function wpinv_trim_formatted_address_line( $line ) { |
|
789 | - return trim( $line, ', ' ); |
|
788 | +function wpinv_trim_formatted_address_line($line) { |
|
789 | + return trim($line, ', '); |
|
790 | 790 | } |
791 | 791 | \ No newline at end of file |