@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Contains gateway functions. |
4 | 4 | * |
5 | 5 | */ |
6 | -defined( 'ABSPATH' ) || exit; |
|
6 | +defined('ABSPATH') || exit; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * Returns an array of payment gateways. |
@@ -11,96 +11,96 @@ discard block |
||
11 | 11 | * @return array |
12 | 12 | */ |
13 | 13 | function wpinv_get_payment_gateways() { |
14 | - return apply_filters( 'wpinv_payment_gateways', array() ); |
|
14 | + return apply_filters('wpinv_payment_gateways', array()); |
|
15 | 15 | } |
16 | 16 | |
17 | -function wpinv_payment_gateway_titles( $all_gateways ) { |
|
17 | +function wpinv_payment_gateway_titles($all_gateways) { |
|
18 | 18 | global $wpinv_options; |
19 | 19 | |
20 | 20 | $gateways = array(); |
21 | - foreach ( $all_gateways as $key => $gateway ) { |
|
22 | - if ( !empty( $wpinv_options[$key . '_title'] ) ) { |
|
23 | - $all_gateways[$key]['checkout_label'] = __( $wpinv_options[$key . '_title'], 'invoicing' ); |
|
21 | + foreach ($all_gateways as $key => $gateway) { |
|
22 | + if (!empty($wpinv_options[$key . '_title'])) { |
|
23 | + $all_gateways[$key]['checkout_label'] = __($wpinv_options[$key . '_title'], 'invoicing'); |
|
24 | 24 | } |
25 | 25 | |
26 | - $gateways[$key] = isset( $wpinv_options[$key . '_ordering'] ) ? $wpinv_options[$key . '_ordering'] : ( isset( $gateway['ordering'] ) ? $gateway['ordering'] : '' ); |
|
26 | + $gateways[$key] = isset($wpinv_options[$key . '_ordering']) ? $wpinv_options[$key . '_ordering'] : (isset($gateway['ordering']) ? $gateway['ordering'] : ''); |
|
27 | 27 | } |
28 | 28 | |
29 | - asort( $gateways ); |
|
29 | + asort($gateways); |
|
30 | 30 | |
31 | - foreach ( $gateways as $gateway => $key ) { |
|
31 | + foreach ($gateways as $gateway => $key) { |
|
32 | 32 | $gateways[$gateway] = $all_gateways[$gateway]; |
33 | 33 | } |
34 | 34 | |
35 | 35 | return $gateways; |
36 | 36 | } |
37 | -add_filter( 'wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1 ); |
|
37 | +add_filter('wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1); |
|
38 | 38 | |
39 | -function wpinv_get_enabled_payment_gateways( $sort = false ) { |
|
39 | +function wpinv_get_enabled_payment_gateways($sort = false) { |
|
40 | 40 | $gateways = wpinv_get_payment_gateways(); |
41 | - $enabled = wpinv_get_option( 'gateways', false ); |
|
41 | + $enabled = wpinv_get_option('gateways', false); |
|
42 | 42 | |
43 | 43 | $gateway_list = array(); |
44 | 44 | |
45 | - foreach ( $gateways as $key => $gateway ) { |
|
46 | - if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) { |
|
47 | - $gateway_list[ $key ] = $gateway; |
|
45 | + foreach ($gateways as $key => $gateway) { |
|
46 | + if (isset($enabled[$key]) && $enabled[$key] == 1) { |
|
47 | + $gateway_list[$key] = $gateway; |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 | |
51 | - if ( true === $sort ) { |
|
52 | - uasort( $gateway_list, 'wpinv_sort_gateway_order' ); |
|
51 | + if (true === $sort) { |
|
52 | + uasort($gateway_list, 'wpinv_sort_gateway_order'); |
|
53 | 53 | |
54 | 54 | // Reorder our gateways so the default is first |
55 | 55 | $default_gateway_id = wpinv_get_default_gateway(); |
56 | 56 | |
57 | - if ( wpinv_is_gateway_active( $default_gateway_id ) ) { |
|
58 | - $default_gateway = array( $default_gateway_id => $gateway_list[ $default_gateway_id ] ); |
|
59 | - unset( $gateway_list[ $default_gateway_id ] ); |
|
57 | + if (wpinv_is_gateway_active($default_gateway_id)) { |
|
58 | + $default_gateway = array($default_gateway_id => $gateway_list[$default_gateway_id]); |
|
59 | + unset($gateway_list[$default_gateway_id]); |
|
60 | 60 | |
61 | - $gateway_list = array_merge( $default_gateway, $gateway_list ); |
|
61 | + $gateway_list = array_merge($default_gateway, $gateway_list); |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
65 | - return apply_filters( 'wpinv_enabled_payment_gateways', $gateway_list ); |
|
65 | + return apply_filters('wpinv_enabled_payment_gateways', $gateway_list); |
|
66 | 66 | } |
67 | 67 | |
68 | -function wpinv_sort_gateway_order( $a, $b ) { |
|
68 | +function wpinv_sort_gateway_order($a, $b) { |
|
69 | 69 | return $a['ordering'] - $b['ordering']; |
70 | 70 | } |
71 | 71 | |
72 | -function wpinv_is_gateway_active( $gateway ) { |
|
72 | +function wpinv_is_gateway_active($gateway) { |
|
73 | 73 | $gateways = wpinv_get_enabled_payment_gateways(); |
74 | 74 | |
75 | - $ret = is_array($gateways) && $gateway ? array_key_exists( $gateway, $gateways ) : false; |
|
75 | + $ret = is_array($gateways) && $gateway ? array_key_exists($gateway, $gateways) : false; |
|
76 | 76 | |
77 | - return apply_filters( 'wpinv_is_gateway_active', $ret, $gateway, $gateways ); |
|
77 | + return apply_filters('wpinv_is_gateway_active', $ret, $gateway, $gateways); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | function wpinv_get_default_gateway() { |
81 | - $default = wpinv_get_option( 'default_gateway', 'paypal' ); |
|
81 | + $default = wpinv_get_option('default_gateway', 'paypal'); |
|
82 | 82 | |
83 | - if ( !wpinv_is_gateway_active( $default ) ) { |
|
83 | + if (!wpinv_is_gateway_active($default)) { |
|
84 | 84 | $gateways = wpinv_get_enabled_payment_gateways(); |
85 | - $gateways = array_keys( $gateways ); |
|
86 | - $default = reset( $gateways ); |
|
85 | + $gateways = array_keys($gateways); |
|
86 | + $default = reset($gateways); |
|
87 | 87 | } |
88 | 88 | |
89 | - return apply_filters( 'wpinv_default_gateway', $default ); |
|
89 | + return apply_filters('wpinv_default_gateway', $default); |
|
90 | 90 | } |
91 | 91 | |
92 | -function wpinv_get_gateway_admin_label( $gateway ) { |
|
92 | +function wpinv_get_gateway_admin_label($gateway) { |
|
93 | 93 | $gateways = wpinv_get_payment_gateways(); |
94 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway; |
|
95 | - $payment = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : false; |
|
94 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway; |
|
95 | + $payment = isset($_GET['id']) ? absint($_GET['id']) : false; |
|
96 | 96 | |
97 | - if( $gateway == 'manual' && $payment ) { |
|
98 | - if( !( (float)wpinv_payment_total( $payment ) > 0 ) ) { |
|
99 | - $label = __( 'Free Purchase', 'invoicing' ); |
|
97 | + if ($gateway == 'manual' && $payment) { |
|
98 | + if (!((float) wpinv_payment_total($payment) > 0)) { |
|
99 | + $label = __('Free Purchase', 'invoicing'); |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
103 | - return apply_filters( 'wpinv_gateway_admin_label', $label, $gateway ); |
|
103 | + return apply_filters('wpinv_gateway_admin_label', $label, $gateway); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -108,49 +108,49 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @param string $gateway |
110 | 110 | */ |
111 | -function wpinv_get_gateway_description( $gateway ) { |
|
111 | +function wpinv_get_gateway_description($gateway) { |
|
112 | 112 | global $wpinv_options; |
113 | 113 | |
114 | - $description = ! empty( $wpinv_options[$gateway . '_desc'] ) ? $wpinv_options[$gateway . '_desc'] : ''; |
|
114 | + $description = !empty($wpinv_options[$gateway . '_desc']) ? $wpinv_options[$gateway . '_desc'] : ''; |
|
115 | 115 | |
116 | - return apply_filters( 'wpinv_gateway_description', $description, $gateway ); |
|
116 | + return apply_filters('wpinv_gateway_description', $description, $gateway); |
|
117 | 117 | } |
118 | 118 | |
119 | -function wpinv_get_gateway_button_label( $gateway ) { |
|
120 | - return apply_filters( 'wpinv_gateway_' . $gateway . '_button_label', '' ); |
|
119 | +function wpinv_get_gateway_button_label($gateway) { |
|
120 | + return apply_filters('wpinv_gateway_' . $gateway . '_button_label', ''); |
|
121 | 121 | } |
122 | 122 | |
123 | -function wpinv_get_gateway_checkout_label( $gateway ) { |
|
123 | +function wpinv_get_gateway_checkout_label($gateway) { |
|
124 | 124 | $gateways = wpinv_get_payment_gateways(); |
125 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway; |
|
125 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway; |
|
126 | 126 | |
127 | - if ( $gateway == 'none' ) { |
|
128 | - $label = __( 'None', 'invoicing' ); |
|
127 | + if ($gateway == 'none') { |
|
128 | + $label = __('None', 'invoicing'); |
|
129 | 129 | } |
130 | 130 | |
131 | - return apply_filters( 'wpinv_gateway_checkout_label', ucfirst( $label ), $gateway ); |
|
131 | + return apply_filters('wpinv_gateway_checkout_label', ucfirst($label), $gateway); |
|
132 | 132 | } |
133 | 133 | |
134 | -function wpinv_settings_sections_gateways( $settings ) { |
|
134 | +function wpinv_settings_sections_gateways($settings) { |
|
135 | 135 | $gateways = wpinv_get_payment_gateways(); |
136 | 136 | |
137 | 137 | if (!empty($gateways)) { |
138 | - foreach ($gateways as $key => $gateway) { |
|
138 | + foreach ($gateways as $key => $gateway) { |
|
139 | 139 | $settings[$key] = $gateway['admin_label']; |
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
143 | 143 | return $settings; |
144 | 144 | } |
145 | -add_filter( 'wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1 ); |
|
145 | +add_filter('wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1); |
|
146 | 146 | |
147 | 147 | /** |
148 | 148 | * Adds GateWay settings. |
149 | 149 | */ |
150 | -function wpinv_settings_gateways( $settings ) { |
|
150 | +function wpinv_settings_gateways($settings) { |
|
151 | 151 | |
152 | 152 | // Loop through each gateway. |
153 | - foreach ( wpinv_get_payment_gateways() as $key => $gateway ) { |
|
153 | + foreach (wpinv_get_payment_gateways() as $key => $gateway) { |
|
154 | 154 | |
155 | 155 | $gateway_settings = array( |
156 | 156 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | "{$key}_header" => array( |
159 | 159 | |
160 | 160 | 'id' => "{$key}_gateway_header", |
161 | - 'name' => '<h3>' . wp_sprintf( __( '%s Settings', 'invoicing' ), $gateway['admin_label'] ) . '</h3>', |
|
161 | + 'name' => '<h3>' . wp_sprintf(__('%s Settings', 'invoicing'), $gateway['admin_label']) . '</h3>', |
|
162 | 162 | 'custom' => $key, |
163 | 163 | 'type' => 'gateway_header', |
164 | 164 | |
@@ -167,56 +167,56 @@ discard block |
||
167 | 167 | // Activate/Deactivate a gateway. |
168 | 168 | "{$key}_active" => array( |
169 | 169 | 'id' => $key . '_active', |
170 | - 'name' => __( 'Activate', 'invoicing' ), |
|
171 | - 'desc' => wp_sprintf( __( 'Enable %s', 'invoicing' ), $gateway['admin_label'] ), |
|
170 | + 'name' => __('Activate', 'invoicing'), |
|
171 | + 'desc' => wp_sprintf(__('Enable %s', 'invoicing'), $gateway['admin_label']), |
|
172 | 172 | 'type' => 'checkbox', |
173 | 173 | ), |
174 | 174 | |
175 | 175 | // Activate/Deactivate sandbox. |
176 | 176 | "{$key}_sandbox" => array( |
177 | 177 | 'id' => $key . '_sandbox', |
178 | - 'name' => __( 'Sandbox', 'invoicing' ), |
|
179 | - 'desc' => __( 'Enable sandbox to test payments', 'invoicing' ), |
|
178 | + 'name' => __('Sandbox', 'invoicing'), |
|
179 | + 'desc' => __('Enable sandbox to test payments', 'invoicing'), |
|
180 | 180 | 'type' => 'checkbox', |
181 | 181 | ), |
182 | 182 | |
183 | 183 | // Checkout title. |
184 | 184 | "{$key}_title" => array( |
185 | 185 | 'id' => $key . '_title', |
186 | - 'name' => __( 'Checkout Title', 'invoicing' ), |
|
187 | - 'std' => isset( $gateway['checkout_label'] ) ? $gateway['checkout_label'] : '', |
|
186 | + 'name' => __('Checkout Title', 'invoicing'), |
|
187 | + 'std' => isset($gateway['checkout_label']) ? $gateway['checkout_label'] : '', |
|
188 | 188 | 'type' => 'text', |
189 | 189 | ), |
190 | 190 | |
191 | 191 | // Checkout description. |
192 | 192 | "{$key}_desc" => array( |
193 | 193 | 'id' => $key . '_desc', |
194 | - 'name' => __( 'Checkout Description', 'invoicing' ), |
|
195 | - 'std' => apply_filters( "getpaid_default_{$key}_checkout_description", '' ), |
|
194 | + 'name' => __('Checkout Description', 'invoicing'), |
|
195 | + 'std' => apply_filters("getpaid_default_{$key}_checkout_description", ''), |
|
196 | 196 | 'type' => 'text', |
197 | 197 | ), |
198 | 198 | |
199 | 199 | // Checkout order. |
200 | 200 | "{$key}_ordering" => array( |
201 | 201 | 'id' => $key . '_ordering', |
202 | - 'name' => __( 'Priority', 'invoicing' ), |
|
203 | - 'std' => apply_filters( "getpaid_default_{$key}_checkout_description", '' ), |
|
202 | + 'name' => __('Priority', 'invoicing'), |
|
203 | + 'std' => apply_filters("getpaid_default_{$key}_checkout_description", ''), |
|
204 | 204 | 'type' => 'number', |
205 | 205 | 'step' => '1', |
206 | 206 | 'min' => '-100000', |
207 | 207 | 'max' => '100000', |
208 | - 'std' => isset( $gateway['ordering'] ) ? $gateway['ordering'] : '10', |
|
208 | + 'std' => isset($gateway['ordering']) ? $gateway['ordering'] : '10', |
|
209 | 209 | ), |
210 | 210 | |
211 | 211 | ); |
212 | 212 | |
213 | 213 | // Maybe remove the sandbox. |
214 | - if ( ! apply_filters( "wpinv_{$key}_supports_sandbox", false ) ) { |
|
215 | - unset( $gateway_settings["{$key}_sandbox"] ); |
|
214 | + if (!apply_filters("wpinv_{$key}_supports_sandbox", false)) { |
|
215 | + unset($gateway_settings["{$key}_sandbox"]); |
|
216 | 216 | } |
217 | 217 | |
218 | - $gateway_settings = apply_filters( 'wpinv_gateway_settings', $gateway_settings, $key, $gateway ); |
|
219 | - $gateway_settings = apply_filters( 'wpinv_gateway_settings_' . $key, $gateway_settings, $gateway ); |
|
218 | + $gateway_settings = apply_filters('wpinv_gateway_settings', $gateway_settings, $key, $gateway); |
|
219 | + $gateway_settings = apply_filters('wpinv_gateway_settings_' . $key, $gateway_settings, $gateway); |
|
220 | 220 | |
221 | 221 | $settings[$key] = $gateway_settings; |
222 | 222 | } |
@@ -224,57 +224,57 @@ discard block |
||
224 | 224 | return $settings; |
225 | 225 | |
226 | 226 | } |
227 | -add_filter( 'wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1 ); |
|
227 | +add_filter('wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1); |
|
228 | 228 | |
229 | -function wpinv_gateway_header_callback( $args ) { |
|
230 | - echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr( $args['custom'] ) . '" />'; |
|
229 | +function wpinv_gateway_header_callback($args) { |
|
230 | + echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr($args['custom']) . '" />'; |
|
231 | 231 | } |
232 | 232 | |
233 | -function wpinv_get_gateway_supports( $gateway ) { |
|
233 | +function wpinv_get_gateway_supports($gateway) { |
|
234 | 234 | $gateways = wpinv_get_enabled_payment_gateways(); |
235 | - $supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array(); |
|
236 | - return apply_filters( 'wpinv_gateway_supports', $supports, $gateway ); |
|
235 | + $supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array(); |
|
236 | + return apply_filters('wpinv_gateway_supports', $supports, $gateway); |
|
237 | 237 | } |
238 | 238 | |
239 | -function wpinv_get_chosen_gateway( $invoice_id = 0 ) { |
|
240 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
239 | +function wpinv_get_chosen_gateway($invoice_id = 0) { |
|
240 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
241 | 241 | |
242 | 242 | $chosen = false; |
243 | - if ( $invoice_id > 0 && $invoice = wpinv_get_invoice( $invoice_id ) ) { |
|
243 | + if ($invoice_id > 0 && $invoice = wpinv_get_invoice($invoice_id)) { |
|
244 | 244 | $chosen = $invoice->get_gateway(); |
245 | 245 | } |
246 | 246 | |
247 | - $chosen = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen; |
|
247 | + $chosen = isset($_REQUEST['payment-mode']) ? sanitize_text_field($_REQUEST['payment-mode']) : $chosen; |
|
248 | 248 | |
249 | - if ( false !== $chosen ) { |
|
250 | - $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen ); |
|
249 | + if (false !== $chosen) { |
|
250 | + $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen); |
|
251 | 251 | } |
252 | 252 | |
253 | - if ( ! empty ( $chosen ) ) { |
|
254 | - $enabled_gateway = urldecode( $chosen ); |
|
255 | - } else if ( !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) { |
|
253 | + if (!empty ($chosen)) { |
|
254 | + $enabled_gateway = urldecode($chosen); |
|
255 | + } else if (!empty($invoice) && (float) $invoice->get_subtotal() <= 0) { |
|
256 | 256 | $enabled_gateway = 'manual'; |
257 | 257 | } else { |
258 | 258 | $enabled_gateway = wpinv_get_default_gateway(); |
259 | 259 | } |
260 | 260 | |
261 | - if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) { |
|
262 | - if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){ |
|
261 | + if (!wpinv_is_gateway_active($enabled_gateway) && !empty($gateways)) { |
|
262 | + if (wpinv_is_gateway_active(wpinv_get_default_gateway())) { |
|
263 | 263 | $enabled_gateway = wpinv_get_default_gateway(); |
264 | - }else{ |
|
264 | + } else { |
|
265 | 265 | $enabled_gateway = $gateways[0]; |
266 | 266 | } |
267 | 267 | |
268 | 268 | } |
269 | 269 | |
270 | - return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway ); |
|
270 | + return apply_filters('wpinv_chosen_gateway', $enabled_gateway); |
|
271 | 271 | } |
272 | 272 | |
273 | -function wpinv_record_gateway_error( $title = '', $message = '' ) { |
|
274 | - return wpinv_error_log( $message, $title ); |
|
273 | +function wpinv_record_gateway_error($title = '', $message = '') { |
|
274 | + return wpinv_error_log($message, $title); |
|
275 | 275 | } |
276 | 276 | |
277 | -function wpinv_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) { |
|
277 | +function wpinv_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') { |
|
278 | 278 | $ret = 0; |
279 | 279 | $args = array( |
280 | 280 | 'meta_key' => '_wpinv_gateway', |
@@ -285,48 +285,48 @@ discard block |
||
285 | 285 | 'fields' => 'ids' |
286 | 286 | ); |
287 | 287 | |
288 | - $payments = new WP_Query( $args ); |
|
288 | + $payments = new WP_Query($args); |
|
289 | 289 | |
290 | - if( $payments ) |
|
290 | + if ($payments) |
|
291 | 291 | $ret = $payments->post_count; |
292 | 292 | return $ret; |
293 | 293 | } |
294 | 294 | |
295 | -function wpinv_settings_update_gateways( $input ) { |
|
295 | +function wpinv_settings_update_gateways($input) { |
|
296 | 296 | global $wpinv_options; |
297 | 297 | |
298 | - if ( !empty( $input['save_gateway'] ) ) { |
|
299 | - $gateways = wpinv_get_option( 'gateways', false ); |
|
298 | + if (!empty($input['save_gateway'])) { |
|
299 | + $gateways = wpinv_get_option('gateways', false); |
|
300 | 300 | $gateways = !empty($gateways) ? $gateways : array(); |
301 | 301 | $gateway = $input['save_gateway']; |
302 | 302 | |
303 | - if ( !empty( $input[$gateway . '_active'] ) ) { |
|
303 | + if (!empty($input[$gateway . '_active'])) { |
|
304 | 304 | $gateways[$gateway] = 1; |
305 | 305 | } else { |
306 | - if ( isset( $gateways[$gateway] ) ) { |
|
307 | - unset( $gateways[$gateway] ); |
|
306 | + if (isset($gateways[$gateway])) { |
|
307 | + unset($gateways[$gateway]); |
|
308 | 308 | } |
309 | 309 | } |
310 | 310 | |
311 | 311 | $input['gateways'] = $gateways; |
312 | 312 | } |
313 | 313 | |
314 | - if ( !empty( $input['default_gateway'] ) ) { |
|
314 | + if (!empty($input['default_gateway'])) { |
|
315 | 315 | $gateways = wpinv_get_payment_gateways(); |
316 | 316 | |
317 | - foreach ( $gateways as $key => $gateway ) { |
|
318 | - $active = 0; |
|
319 | - if ( !empty( $input['gateways'] ) && !empty( $input['gateways'][$key] ) ) { |
|
317 | + foreach ($gateways as $key => $gateway) { |
|
318 | + $active = 0; |
|
319 | + if (!empty($input['gateways']) && !empty($input['gateways'][$key])) { |
|
320 | 320 | $active = 1; |
321 | 321 | } |
322 | 322 | |
323 | 323 | $input[$key . '_active'] = $active; |
324 | 324 | |
325 | - if ( empty( $wpinv_options[$key . '_title'] ) ) { |
|
325 | + if (empty($wpinv_options[$key . '_title'])) { |
|
326 | 326 | $input[$key . '_title'] = $gateway['checkout_label']; |
327 | 327 | } |
328 | 328 | |
329 | - if ( !isset( $wpinv_options[$key . '_ordering'] ) && isset( $gateway['ordering'] ) ) { |
|
329 | + if (!isset($wpinv_options[$key . '_ordering']) && isset($gateway['ordering'])) { |
|
330 | 330 | $input[$key . '_ordering'] = $gateway['ordering']; |
331 | 331 | } |
332 | 332 | } |
@@ -334,27 +334,27 @@ discard block |
||
334 | 334 | |
335 | 335 | return $input; |
336 | 336 | } |
337 | -add_filter( 'wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1 ); |
|
337 | +add_filter('wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1); |
|
338 | 338 | |
339 | 339 | // PayPal Standard settings |
340 | -function wpinv_gateway_settings_paypal( $setting ) { |
|
341 | - $setting['paypal_active']['desc'] = $setting['paypal_active']['desc'] . ' ' . __( '( Supported Currencies: AUD, BRL, CAD, CZK, DKK, EUR, HKD, HUF, ILS, JPY, MYR, MXN, NOK, NZD, PHP, PLN, GBP, SGD, SEK, CHF, TWD, THB, USD )', 'invoicing' ); |
|
342 | - $setting['paypal_desc']['std'] = __( 'Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing' ); |
|
340 | +function wpinv_gateway_settings_paypal($setting) { |
|
341 | + $setting['paypal_active']['desc'] = $setting['paypal_active']['desc'] . ' ' . __('( Supported Currencies: AUD, BRL, CAD, CZK, DKK, EUR, HKD, HUF, ILS, JPY, MYR, MXN, NOK, NZD, PHP, PLN, GBP, SGD, SEK, CHF, TWD, THB, USD )', 'invoicing'); |
|
342 | + $setting['paypal_desc']['std'] = __('Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing'); |
|
343 | 343 | |
344 | 344 | $setting['paypal_sandbox'] = array( |
345 | 345 | 'type' => 'checkbox', |
346 | 346 | 'id' => 'paypal_sandbox', |
347 | - 'name' => __( 'PayPal Sandbox', 'invoicing' ), |
|
348 | - 'desc' => __( 'PayPal sandbox can be used to test payments.', 'invoicing' ), |
|
347 | + 'name' => __('PayPal Sandbox', 'invoicing'), |
|
348 | + 'desc' => __('PayPal sandbox can be used to test payments.', 'invoicing'), |
|
349 | 349 | 'std' => 1 |
350 | 350 | ); |
351 | 351 | |
352 | 352 | $setting['paypal_email'] = array( |
353 | 353 | 'type' => 'text', |
354 | 354 | 'id' => 'paypal_email', |
355 | - 'name' => __( 'PayPal Email', 'invoicing' ), |
|
356 | - 'desc' => __( 'Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing' ), |
|
357 | - 'std' => __( '[email protected]', 'invoicing' ), |
|
355 | + 'name' => __('PayPal Email', 'invoicing'), |
|
356 | + 'desc' => __('Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing'), |
|
357 | + 'std' => __('[email protected]', 'invoicing'), |
|
358 | 358 | ); |
359 | 359 | /* |
360 | 360 | $setting['paypal_ipn_url'] = array( |
@@ -368,18 +368,18 @@ discard block |
||
368 | 368 | |
369 | 369 | return $setting; |
370 | 370 | } |
371 | -add_filter( 'wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1 ); |
|
371 | +add_filter('wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1); |
|
372 | 372 | |
373 | 373 | /** |
374 | 374 | * Displays the ipn url field. |
375 | 375 | */ |
376 | -function wpinv_ipn_url_callback( $args ) { |
|
377 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
376 | +function wpinv_ipn_url_callback($args) { |
|
377 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
378 | 378 | |
379 | 379 | $attrs = $args['readonly'] ? ' readonly' : ''; |
380 | 380 | |
381 | - $html = '<input class="regular-text" type="text" ' . $attrs . ' value="' . esc_attr( $args['std'] ) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" onClick="this.select()">'; |
|
382 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>'; |
|
381 | + $html = '<input class="regular-text" type="text" ' . $attrs . ' value="' . esc_attr($args['std']) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" onClick="this.select()">'; |
|
382 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>'; |
|
383 | 383 | |
384 | 384 | echo $html; |
385 | 385 | } |
@@ -391,9 +391,9 @@ discard block |
||
391 | 391 | * |
392 | 392 | * @return bool |
393 | 393 | */ |
394 | -function wpinv_is_test_mode( $gateway = '' ) { |
|
395 | - $sandbox = empty( $gateway ) ? false : wpinv_get_option( "{$gateway}_sandbox", false ); |
|
396 | - return apply_filters( 'wpinv_is_test_mode', $sandbox, $gateway ); |
|
394 | +function wpinv_is_test_mode($gateway = '') { |
|
395 | + $sandbox = empty($gateway) ? false : wpinv_get_option("{$gateway}_sandbox", false); |
|
396 | + return apply_filters('wpinv_is_test_mode', $sandbox, $gateway); |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | /** |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | * |
405 | 405 | * @return string |
406 | 406 | */ |
407 | -function wpinv_get_ipn_url( $gateway = false, $args = array() ) { |
|
407 | +function wpinv_get_ipn_url($gateway = false, $args = array()) { |
|
408 | 408 | $args = wp_parse_args( |
409 | 409 | array( |
410 | 410 | 'wpi-listener' => 'IPN', |
@@ -413,37 +413,37 @@ discard block |
||
413 | 413 | $args |
414 | 414 | ); |
415 | 415 | |
416 | - return apply_filters( 'wpinv_ipn_url', add_query_arg( $args, home_url( 'index.php' ) ), $gateway, $args ); |
|
416 | + return apply_filters('wpinv_ipn_url', add_query_arg($args, home_url('index.php')), $gateway, $args); |
|
417 | 417 | |
418 | 418 | } |
419 | 419 | |
420 | 420 | /** |
421 | 421 | * Retrieves request data with slashes removed slashes. |
422 | 422 | */ |
423 | -function wpinv_get_post_data( $method = 'request' ) { |
|
423 | +function wpinv_get_post_data($method = 'request') { |
|
424 | 424 | |
425 | - if ( $method == 'post' ) { |
|
426 | - return wp_unslash( $_POST ); |
|
425 | + if ($method == 'post') { |
|
426 | + return wp_unslash($_POST); |
|
427 | 427 | } |
428 | 428 | |
429 | - if ( $method == 'get' ) { |
|
430 | - return wp_unslash( $_GET ); |
|
429 | + if ($method == 'get') { |
|
430 | + return wp_unslash($_GET); |
|
431 | 431 | } |
432 | 432 | |
433 | - return wp_unslash( $_REQUEST ); |
|
433 | + return wp_unslash($_REQUEST); |
|
434 | 434 | |
435 | 435 | } |
436 | 436 | |
437 | 437 | /** |
438 | 438 | * Checks if a given gateway supports subscription payments. |
439 | 439 | */ |
440 | -function wpinv_gateway_support_subscription( $gateway ) { |
|
440 | +function wpinv_gateway_support_subscription($gateway) { |
|
441 | 441 | $supports = false; |
442 | 442 | |
443 | - if ( wpinv_is_gateway_active( $gateway ) ) { |
|
444 | - $supports = apply_filters( 'wpinv_' . $gateway . '_support_subscription', $supports ); |
|
443 | + if (wpinv_is_gateway_active($gateway)) { |
|
444 | + $supports = apply_filters('wpinv_' . $gateway . '_support_subscription', $supports); |
|
445 | 445 | |
446 | - $supports = apply_filters( 'getapid_gateway_supports_subscription', $supports, $gateway ); |
|
446 | + $supports = apply_filters('getapid_gateway_supports_subscription', $supports, $gateway); |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | return $supports; |
@@ -455,14 +455,14 @@ discard block |
||
455 | 455 | * @param array $gateways an array of gateways. |
456 | 456 | * @param GetPaid_Payment_Form $form payment form. |
457 | 457 | */ |
458 | -function wpinv_payment_gateways_on_cart( $gateways, $form ) { |
|
458 | +function wpinv_payment_gateways_on_cart($gateways, $form) { |
|
459 | 459 | |
460 | - if ( $form->is_recurring() ) { |
|
460 | + if ($form->is_recurring()) { |
|
461 | 461 | |
462 | - foreach ( array_keys( $gateways ) as $gateway ) { |
|
462 | + foreach (array_keys($gateways) as $gateway) { |
|
463 | 463 | |
464 | - if ( ! wpinv_gateway_support_subscription( $gateway ) ) { |
|
465 | - unset( $gateways[$gateway] ); |
|
464 | + if (!wpinv_gateway_support_subscription($gateway)) { |
|
465 | + unset($gateways[$gateway]); |
|
466 | 466 | } |
467 | 467 | |
468 | 468 | } |
@@ -471,4 +471,4 @@ discard block |
||
471 | 471 | |
472 | 472 | return $gateways; |
473 | 473 | } |
474 | -add_filter( 'getpaid_payment_form_gateways', 'wpinv_payment_gateways_on_cart', 10, 2 ); |
|
474 | +add_filter('getpaid_payment_form_gateways', 'wpinv_payment_gateways_on_cart', 10, 2); |
@@ -7,21 +7,21 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | // The payment methods select title. |
13 | -if ( empty( $text ) ) { |
|
14 | - $text = __( 'Select Payment Method', 'invoicing' ); |
|
13 | +if (empty($text)) { |
|
14 | + $text = __('Select Payment Method', 'invoicing'); |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | // An array of active payment methods. |
18 | -$gateways = wpinv_get_enabled_payment_gateways( true ); |
|
18 | +$gateways = wpinv_get_enabled_payment_gateways(true); |
|
19 | 19 | |
20 | 20 | // The current invoice id. |
21 | 21 | $invoice_id = 0; |
22 | 22 | $chosen_gateway = wpinv_get_default_gateway(); |
23 | 23 | |
24 | -if ( ! empty( $form->invoice ) ) { |
|
24 | +if (!empty($form->invoice)) { |
|
25 | 25 | $invoice_id = $form->invoice->get_id(); |
26 | 26 | $chosen_gateway = $form->invoice->get_gateway(); |
27 | 27 | } |
@@ -30,21 +30,21 @@ discard block |
||
30 | 30 | |
31 | 31 | <div class="mt-4 mb-4 getpaid-gateways"> |
32 | 32 | |
33 | - <?php do_action( 'wpinv_payment_mode_top', $invoice_id, $chosen_gateway, $gateways, $form ); ?> |
|
33 | + <?php do_action('wpinv_payment_mode_top', $invoice_id, $chosen_gateway, $gateways, $form); ?> |
|
34 | 34 | |
35 | 35 | <div class="getpaid-select-gateway-title-div"> |
36 | - <h6><?php echo sanitize_text_field( $text ); ?></h6> |
|
36 | + <h6><?php echo sanitize_text_field($text); ?></h6> |
|
37 | 37 | </div> |
38 | 38 | |
39 | 39 | <div class="getpaid-available-gateways-div"> |
40 | 40 | |
41 | - <?php foreach ( array_keys( $gateways ) as $gateway ) : ?> |
|
41 | + <?php foreach (array_keys($gateways) as $gateway) : ?> |
|
42 | 42 | |
43 | - <div class="pt-1 pb-1 getpaid-gateway getpaid-gateway-<?php echo sanitize_html_class( $gateway ) ;?>" data-checkout-label='<?php echo esc_attr( apply_filters( "getpaid_gateway_{$gateway}_checkout_button_label", '' ) ); ?>'> |
|
43 | + <div class="pt-1 pb-1 getpaid-gateway getpaid-gateway-<?php echo sanitize_html_class($gateway); ?>" data-checkout-label='<?php echo esc_attr(apply_filters("getpaid_gateway_{$gateway}_checkout_button_label", '')); ?>'> |
|
44 | 44 | |
45 | 45 | <label class="d-block w-100 getpaid-gateway-radio"> |
46 | - <input type="radio" value="<?php echo esc_attr( $gateway ) ;?>" <?php checked( $gateway, $chosen_gateway ) ;?> name="wpi-gateway"> |
|
47 | - <span><?php echo sanitize_text_field( wpinv_get_gateway_checkout_label( $gateway ) ); ?></span> |
|
46 | + <input type="radio" value="<?php echo esc_attr($gateway); ?>" <?php checked($gateway, $chosen_gateway); ?> name="wpi-gateway"> |
|
47 | + <span><?php echo sanitize_text_field(wpinv_get_gateway_checkout_label($gateway)); ?></span> |
|
48 | 48 | </label> |
49 | 49 | |
50 | 50 | </div> |
@@ -55,22 +55,22 @@ discard block |
||
55 | 55 | |
56 | 56 | <div class="getpaid-gateway-descriptions-div"> |
57 | 57 | |
58 | - <?php foreach ( array_keys( $gateways ) as $gateway ) : ?> |
|
58 | + <?php foreach (array_keys($gateways) as $gateway) : ?> |
|
59 | 59 | |
60 | - <div class="mb-2 mt-2 bg-light border getpaid-gateway-description getpaid-description-<?php echo sanitize_html_class( $gateway ) ;?>" style="display: none;"> |
|
60 | + <div class="mb-2 mt-2 bg-light border getpaid-gateway-description getpaid-description-<?php echo sanitize_html_class($gateway); ?>" style="display: none;"> |
|
61 | 61 | <?php |
62 | 62 | |
63 | - $description = wpinv_get_gateway_description( $gateway ); |
|
63 | + $description = wpinv_get_gateway_description($gateway); |
|
64 | 64 | |
65 | - if ( wpinv_is_test_mode( $gateway ) ) { |
|
66 | - $sandbox_notice = apply_filters( "getpaid_{$gateway}_sandbox_notice", __( 'SANDBOX ENABLED: No real payments will occur.', 'invoicing' ) ); |
|
65 | + if (wpinv_is_test_mode($gateway)) { |
|
66 | + $sandbox_notice = apply_filters("getpaid_{$gateway}_sandbox_notice", __('SANDBOX ENABLED: No real payments will occur.', 'invoicing')); |
|
67 | 67 | $description = "$description $sandbox_notice"; |
68 | 68 | } |
69 | 69 | |
70 | - echo wpautop( wp_kses_post( $description ) ); |
|
70 | + echo wpautop(wp_kses_post($description)); |
|
71 | 71 | |
72 | - do_action( 'wpinv_' . $gateway . '_checkout_fields', $invoice_id ) ; |
|
73 | - do_action( 'wpinv_' . $gateway . '_cc_form', $invoice_id, $form ) ; |
|
72 | + do_action('wpinv_' . $gateway . '_checkout_fields', $invoice_id); |
|
73 | + do_action('wpinv_' . $gateway . '_cc_form', $invoice_id, $form); |
|
74 | 74 | |
75 | 75 | ?> |
76 | 76 | </div> |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | <?php |
84 | 84 | echo aui()->alert( |
85 | 85 | array( |
86 | - 'content' => __( 'None of the available payment gateways support subscriptions.', 'invoicing' ), |
|
86 | + 'content' => __('None of the available payment gateways support subscriptions.', 'invoicing'), |
|
87 | 87 | 'type' => 'danger', |
88 | 88 | ) |
89 | 89 | ); |
@@ -94,14 +94,14 @@ discard block |
||
94 | 94 | <?php |
95 | 95 | echo aui()->alert( |
96 | 96 | array( |
97 | - 'content' => __( 'There is no active payment gateway available to process your request.', 'invoicing' ), |
|
97 | + 'content' => __('There is no active payment gateway available to process your request.', 'invoicing'), |
|
98 | 98 | 'type' => 'danger', |
99 | 99 | ) |
100 | 100 | ); |
101 | 101 | ?> |
102 | 102 | </div> |
103 | 103 | |
104 | - <?php do_action( 'wpinv_payment_mode_bottom', $invoice_id, $chosen_gateway, $gateways, $form ); ?> |
|
104 | + <?php do_action('wpinv_payment_mode_bottom', $invoice_id, $chosen_gateway, $gateways, $form); ?> |
|
105 | 105 | |
106 | 106 | </div> |
107 | 107 |
@@ -7,18 +7,18 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | -$class = empty( $class ) ? 'btn-primary' : sanitize_html_class( $class ); |
|
13 | -$label = empty( $label ) ? esc_attr__( 'Proceed to Pay »', 'invoicing' ) : esc_attr( $label ); |
|
14 | -$free = empty( $free ) ? esc_attr__( 'Continue »', 'invoicing' ) : esc_attr( $free ); |
|
12 | +$class = empty($class) ? 'btn-primary' : sanitize_html_class($class); |
|
13 | +$label = empty($label) ? esc_attr__('Proceed to Pay »', 'invoicing') : esc_attr($label); |
|
14 | +$free = empty($free) ? esc_attr__('Continue »', 'invoicing') : esc_attr($free); |
|
15 | 15 | |
16 | 16 | echo aui()->input( |
17 | 17 | array( |
18 | - 'name' => esc_attr( $id ), |
|
19 | - 'id' => esc_attr( $id ) . uniqid( '_' ), |
|
20 | - 'value' => empty( $label ) ? __( 'Proceed to Pay »', 'invoicing' ) : esc_attr( $label ), |
|
21 | - 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
18 | + 'name' => esc_attr($id), |
|
19 | + 'id' => esc_attr($id) . uniqid('_'), |
|
20 | + 'value' => empty($label) ? __('Proceed to Pay »', 'invoicing') : esc_attr($label), |
|
21 | + 'help_text' => empty($description) ? '' : wp_kses_post($description), |
|
22 | 22 | 'type' => 'submit', |
23 | 23 | 'class' => 'getpaid-payment-form-submit btn btn-block submit-button ' . $class, |
24 | 24 | 'extra_attributes' => array( |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * WPInv_Ajax class. |
@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | * Hook in ajax handlers. |
18 | 18 | */ |
19 | 19 | public static function init() { |
20 | - add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 ); |
|
21 | - add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 ); |
|
20 | + add_action('init', array(__CLASS__, 'define_ajax'), 0); |
|
21 | + add_action('template_redirect', array(__CLASS__, 'do_wpinv_ajax'), 0); |
|
22 | 22 | self::add_ajax_events(); |
23 | 23 | } |
24 | 24 | |
@@ -27,11 +27,11 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public static function define_ajax() { |
29 | 29 | |
30 | - if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
31 | - getpaid_maybe_define_constant( 'DOING_AJAX', true ); |
|
32 | - getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true ); |
|
33 | - if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) { |
|
34 | - /** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 ); |
|
30 | + if (!empty($_GET['wpinv-ajax'])) { |
|
31 | + getpaid_maybe_define_constant('DOING_AJAX', true); |
|
32 | + getpaid_maybe_define_constant('WPInv_DOING_AJAX', true); |
|
33 | + if (!WP_DEBUG || (WP_DEBUG && !WP_DEBUG_DISPLAY)) { |
|
34 | + /** @scrutinizer ignore-unhandled */ @ini_set('display_errors', 0); |
|
35 | 35 | } |
36 | 36 | $GLOBALS['wpdb']->hide_errors(); |
37 | 37 | } |
@@ -44,13 +44,13 @@ discard block |
||
44 | 44 | * @since 1.0.18 |
45 | 45 | */ |
46 | 46 | private static function wpinv_ajax_headers() { |
47 | - if ( ! headers_sent() ) { |
|
47 | + if (!headers_sent()) { |
|
48 | 48 | send_origin_headers(); |
49 | 49 | send_nosniff_header(); |
50 | 50 | nocache_headers(); |
51 | - header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
52 | - header( 'X-Robots-Tag: noindex' ); |
|
53 | - status_header( 200 ); |
|
51 | + header('Content-Type: text/html; charset=' . get_option('blog_charset')); |
|
52 | + header('X-Robots-Tag: noindex'); |
|
53 | + status_header(200); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
@@ -60,16 +60,16 @@ discard block |
||
60 | 60 | public static function do_wpinv_ajax() { |
61 | 61 | global $wp_query; |
62 | 62 | |
63 | - if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
64 | - $wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) ); |
|
63 | + if (!empty($_GET['wpinv-ajax'])) { |
|
64 | + $wp_query->set('wpinv-ajax', sanitize_text_field(wp_unslash($_GET['wpinv-ajax']))); |
|
65 | 65 | } |
66 | 66 | |
67 | - $action = $wp_query->get( 'wpinv-ajax' ); |
|
67 | + $action = $wp_query->get('wpinv-ajax'); |
|
68 | 68 | |
69 | - if ( $action ) { |
|
69 | + if ($action) { |
|
70 | 70 | self::wpinv_ajax_headers(); |
71 | - $action = sanitize_text_field( $action ); |
|
72 | - do_action( 'wpinv_ajax_' . $action ); |
|
71 | + $action = sanitize_text_field($action); |
|
72 | + do_action('wpinv_ajax_' . $action); |
|
73 | 73 | wp_die(); |
74 | 74 | } |
75 | 75 | |
@@ -102,36 +102,36 @@ discard block |
||
102 | 102 | 'ip_geolocation' => true, |
103 | 103 | ); |
104 | 104 | |
105 | - foreach ( $ajax_events as $ajax_event => $nopriv ) { |
|
106 | - add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
107 | - add_action( 'wp_ajax_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
105 | + foreach ($ajax_events as $ajax_event => $nopriv) { |
|
106 | + add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
107 | + add_action('wp_ajax_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
108 | 108 | |
109 | - if ( $nopriv ) { |
|
110 | - add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
111 | - add_action( 'wp_ajax_nopriv_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
112 | - add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
109 | + if ($nopriv) { |
|
110 | + add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
111 | + add_action('wp_ajax_nopriv_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
112 | + add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
117 | 117 | public static function add_note() { |
118 | - check_ajax_referer( 'add-invoice-note', '_nonce' ); |
|
118 | + check_ajax_referer('add-invoice-note', '_nonce'); |
|
119 | 119 | |
120 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
120 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
121 | 121 | die(-1); |
122 | 122 | } |
123 | 123 | |
124 | - $post_id = absint( $_POST['post_id'] ); |
|
125 | - $note = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) ); |
|
126 | - $note_type = sanitize_text_field( $_POST['note_type'] ); |
|
124 | + $post_id = absint($_POST['post_id']); |
|
125 | + $note = wp_kses_post(trim(stripslashes($_POST['note']))); |
|
126 | + $note_type = sanitize_text_field($_POST['note_type']); |
|
127 | 127 | |
128 | 128 | $is_customer_note = $note_type == 'customer' ? 1 : 0; |
129 | 129 | |
130 | - if ( $post_id > 0 ) { |
|
131 | - $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note ); |
|
130 | + if ($post_id > 0) { |
|
131 | + $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note); |
|
132 | 132 | |
133 | - if ( $note_id > 0 && !is_wp_error( $note_id ) ) { |
|
134 | - wpinv_get_invoice_note_line_item( $note_id ); |
|
133 | + if ($note_id > 0 && !is_wp_error($note_id)) { |
|
134 | + wpinv_get_invoice_note_line_item($note_id); |
|
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
@@ -139,16 +139,16 @@ discard block |
||
139 | 139 | } |
140 | 140 | |
141 | 141 | public static function delete_note() { |
142 | - check_ajax_referer( 'delete-invoice-note', '_nonce' ); |
|
142 | + check_ajax_referer('delete-invoice-note', '_nonce'); |
|
143 | 143 | |
144 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
144 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
145 | 145 | die(-1); |
146 | 146 | } |
147 | 147 | |
148 | - $note_id = (int)$_POST['note_id']; |
|
148 | + $note_id = (int) $_POST['note_id']; |
|
149 | 149 | |
150 | - if ( $note_id > 0 ) { |
|
151 | - wp_delete_comment( $note_id, true ); |
|
150 | + if ($note_id > 0) { |
|
151 | + wp_delete_comment($note_id, true); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | die(); |
@@ -166,34 +166,34 @@ discard block |
||
166 | 166 | public static function get_billing_details() { |
167 | 167 | |
168 | 168 | // Verify nonce. |
169 | - check_ajax_referer( 'wpinv-nonce' ); |
|
169 | + check_ajax_referer('wpinv-nonce'); |
|
170 | 170 | |
171 | 171 | // Can the user manage the plugin? |
172 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
172 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
173 | 173 | die(-1); |
174 | 174 | } |
175 | 175 | |
176 | 176 | // Do we have a user id? |
177 | 177 | $user_id = $_GET['user_id']; |
178 | 178 | |
179 | - if ( empty( $user_id ) || ! is_numeric( $user_id ) ) { |
|
179 | + if (empty($user_id) || !is_numeric($user_id)) { |
|
180 | 180 | die(-1); |
181 | 181 | } |
182 | 182 | |
183 | 183 | // Fetch the billing details. |
184 | - $billing_details = wpinv_get_user_address( $user_id ); |
|
185 | - $billing_details = apply_filters( 'wpinv_ajax_billing_details', $billing_details, $user_id ); |
|
184 | + $billing_details = wpinv_get_user_address($user_id); |
|
185 | + $billing_details = apply_filters('wpinv_ajax_billing_details', $billing_details, $user_id); |
|
186 | 186 | |
187 | 187 | // unset the user id and email. |
188 | - $to_ignore = array( 'user_id', 'email' ); |
|
188 | + $to_ignore = array('user_id', 'email'); |
|
189 | 189 | |
190 | - foreach ( $to_ignore as $key ) { |
|
191 | - if ( isset( $billing_details[ $key ] ) ) { |
|
192 | - unset( $billing_details[ $key ] ); |
|
190 | + foreach ($to_ignore as $key) { |
|
191 | + if (isset($billing_details[$key])) { |
|
192 | + unset($billing_details[$key]); |
|
193 | 193 | } |
194 | 194 | } |
195 | 195 | |
196 | - wp_send_json_success( $billing_details ); |
|
196 | + wp_send_json_success($billing_details); |
|
197 | 197 | |
198 | 198 | } |
199 | 199 | |
@@ -203,47 +203,47 @@ discard block |
||
203 | 203 | public static function check_new_user_email() { |
204 | 204 | |
205 | 205 | // Verify nonce. |
206 | - check_ajax_referer( 'wpinv-nonce' ); |
|
206 | + check_ajax_referer('wpinv-nonce'); |
|
207 | 207 | |
208 | 208 | // Can the user manage the plugin? |
209 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
209 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
210 | 210 | die(-1); |
211 | 211 | } |
212 | 212 | |
213 | 213 | // We need an email address. |
214 | - if ( empty( $_GET['email'] ) ) { |
|
215 | - _e( "Provide the new user's email address", 'invoicing' ); |
|
214 | + if (empty($_GET['email'])) { |
|
215 | + _e("Provide the new user's email address", 'invoicing'); |
|
216 | 216 | exit; |
217 | 217 | } |
218 | 218 | |
219 | 219 | // Ensure the email is valid. |
220 | - $email = sanitize_text_field( $_GET['email'] ); |
|
221 | - if ( ! is_email( $email ) ) { |
|
222 | - _e( 'Invalid email address', 'invoicing' ); |
|
220 | + $email = sanitize_text_field($_GET['email']); |
|
221 | + if (!is_email($email)) { |
|
222 | + _e('Invalid email address', 'invoicing'); |
|
223 | 223 | exit; |
224 | 224 | } |
225 | 225 | |
226 | 226 | // And it does not exist. |
227 | - if ( email_exists( $email ) ) { |
|
228 | - _e( 'A user with this email address already exists', 'invoicing' ); |
|
227 | + if (email_exists($email)) { |
|
228 | + _e('A user with this email address already exists', 'invoicing'); |
|
229 | 229 | exit; |
230 | 230 | } |
231 | 231 | |
232 | - wp_send_json_success( true ); |
|
232 | + wp_send_json_success(true); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | public static function run_tool() { |
236 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
237 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
236 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
237 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
238 | 238 | die(-1); |
239 | 239 | } |
240 | 240 | |
241 | - $tool = sanitize_text_field( $_POST['tool'] ); |
|
241 | + $tool = sanitize_text_field($_POST['tool']); |
|
242 | 242 | |
243 | - do_action( 'wpinv_run_tool' ); |
|
243 | + do_action('wpinv_run_tool'); |
|
244 | 244 | |
245 | - if ( !empty( $tool ) ) { |
|
246 | - do_action( 'wpinv_tool_' . $tool ); |
|
245 | + if (!empty($tool)) { |
|
246 | + do_action('wpinv_tool_' . $tool); |
|
247 | 247 | } |
248 | 248 | } |
249 | 249 | |
@@ -253,30 +253,30 @@ discard block |
||
253 | 253 | public static function get_payment_form() { |
254 | 254 | |
255 | 255 | // Check nonce. |
256 | - if ( ! isset( $_GET['nonce'] ) || ! wp_verify_nonce( $_GET['nonce'], 'getpaid_ajax_form' ) ) { |
|
257 | - _e( 'Error: Reload the page and try again.', 'invoicing' ); |
|
256 | + if (!isset($_GET['nonce']) || !wp_verify_nonce($_GET['nonce'], 'getpaid_ajax_form')) { |
|
257 | + _e('Error: Reload the page and try again.', 'invoicing'); |
|
258 | 258 | exit; |
259 | 259 | } |
260 | 260 | |
261 | 261 | // Is the request set up correctly? |
262 | - if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) { |
|
262 | + if (empty($_GET['form']) && empty($_GET['item'])) { |
|
263 | 263 | echo aui()->alert( |
264 | 264 | array( |
265 | 265 | 'type' => 'warning', |
266 | - 'content' => __( 'No payment form or item provided', 'invoicing' ), |
|
266 | + 'content' => __('No payment form or item provided', 'invoicing'), |
|
267 | 267 | ) |
268 | 268 | ); |
269 | 269 | exit; |
270 | 270 | } |
271 | 271 | |
272 | 272 | // Payment form or button? |
273 | - if ( ! empty( $_GET['form'] ) ) { |
|
274 | - getpaid_display_payment_form( $_GET['form'] ); |
|
275 | - } else if( ! empty( $_GET['invoice'] ) ) { |
|
276 | - getpaid_display_invoice_payment_form( $_GET['invoice'] ); |
|
273 | + if (!empty($_GET['form'])) { |
|
274 | + getpaid_display_payment_form($_GET['form']); |
|
275 | + } else if (!empty($_GET['invoice'])) { |
|
276 | + getpaid_display_invoice_payment_form($_GET['invoice']); |
|
277 | 277 | } else { |
278 | - $items = getpaid_convert_items_to_array( $_GET['item'] ); |
|
279 | - getpaid_display_item_payment_form( $items ); |
|
278 | + $items = getpaid_convert_items_to_array($_GET['item']); |
|
279 | + getpaid_display_item_payment_form($items); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | exit; |
@@ -291,17 +291,17 @@ discard block |
||
291 | 291 | public static function payment_form() { |
292 | 292 | |
293 | 293 | // Check nonce. |
294 | - check_ajax_referer( 'getpaid_form_nonce' ); |
|
294 | + check_ajax_referer('getpaid_form_nonce'); |
|
295 | 295 | |
296 | 296 | // ... form fields... |
297 | - if ( empty( $_POST['getpaid_payment_form_submission'] ) ) { |
|
298 | - _e( 'Error: Reload the page and try again.', 'invoicing' ); |
|
297 | + if (empty($_POST['getpaid_payment_form_submission'])) { |
|
298 | + _e('Error: Reload the page and try again.', 'invoicing'); |
|
299 | 299 | exit; |
300 | 300 | } |
301 | 301 | |
302 | 302 | // Process the payment form. |
303 | - $checkout_class = apply_filters( 'getpaid_checkout_class', 'GetPaid_Checkout' ); |
|
304 | - $checkout = new $checkout_class( new GetPaid_Payment_Form_Submission() ); |
|
303 | + $checkout_class = apply_filters('getpaid_checkout_class', 'GetPaid_Checkout'); |
|
304 | + $checkout = new $checkout_class(new GetPaid_Payment_Form_Submission()); |
|
305 | 305 | $checkout->process_checkout(); |
306 | 306 | |
307 | 307 | exit; |
@@ -314,53 +314,53 @@ discard block |
||
314 | 314 | */ |
315 | 315 | public static function get_payment_form_states_field() { |
316 | 316 | |
317 | - if ( empty( $_GET['country'] ) || empty( $_GET['form'] ) ) { |
|
317 | + if (empty($_GET['country']) || empty($_GET['form'])) { |
|
318 | 318 | exit; |
319 | 319 | } |
320 | 320 | |
321 | - $elements = getpaid_get_payment_form_elements( $_GET['form'] ); |
|
321 | + $elements = getpaid_get_payment_form_elements($_GET['form']); |
|
322 | 322 | |
323 | - if ( empty( $elements ) ) { |
|
323 | + if (empty($elements)) { |
|
324 | 324 | exit; |
325 | 325 | } |
326 | 326 | |
327 | 327 | $address_fields = array(); |
328 | - foreach ( $elements as $element ) { |
|
329 | - if ( 'address' === $element['type'] ) { |
|
328 | + foreach ($elements as $element) { |
|
329 | + if ('address' === $element['type']) { |
|
330 | 330 | $address_fields = $element; |
331 | 331 | break; |
332 | 332 | } |
333 | 333 | } |
334 | 334 | |
335 | - if ( empty( $address_fields ) ) { |
|
335 | + if (empty($address_fields)) { |
|
336 | 336 | exit; |
337 | 337 | } |
338 | 338 | |
339 | - foreach ( $address_fields['fields'] as $address_field ) { |
|
339 | + foreach ($address_fields['fields'] as $address_field) { |
|
340 | 340 | |
341 | - if ( 'wpinv_state' == $address_field['name'] ) { |
|
341 | + if ('wpinv_state' == $address_field['name']) { |
|
342 | 342 | |
343 | - $placeholder = empty( $address_field['placeholder'] ) ? '' : esc_attr( $address_field['placeholder'] ); |
|
344 | - $description = empty( $address_field['description'] ) ? '' : wp_kses_post( $address_field['description'] ); |
|
345 | - $value = is_user_logged_in() ? get_user_meta( get_current_user_id(), '_wpinv_state', true ) : ''; |
|
346 | - $label = empty( $address_field['label'] ) ? '' : wp_kses_post( $address_field['label'] ); |
|
343 | + $placeholder = empty($address_field['placeholder']) ? '' : esc_attr($address_field['placeholder']); |
|
344 | + $description = empty($address_field['description']) ? '' : wp_kses_post($address_field['description']); |
|
345 | + $value = is_user_logged_in() ? get_user_meta(get_current_user_id(), '_wpinv_state', true) : ''; |
|
346 | + $label = empty($address_field['label']) ? '' : wp_kses_post($address_field['label']); |
|
347 | 347 | |
348 | - if ( ! empty( $address_field['required'] ) ) { |
|
348 | + if (!empty($address_field['required'])) { |
|
349 | 349 | $label .= "<span class='text-danger'> *</span>"; |
350 | 350 | } |
351 | 351 | |
352 | - $states = wpinv_get_country_states( $_GET['country'] ); |
|
352 | + $states = wpinv_get_country_states($_GET['country']); |
|
353 | 353 | |
354 | - if ( ! empty( $states ) ) { |
|
354 | + if (!empty($states)) { |
|
355 | 355 | |
356 | - $html = aui()->select( array( |
|
356 | + $html = aui()->select(array( |
|
357 | 357 | 'options' => $states, |
358 | 358 | 'name' => 'wpinv_state', |
359 | 359 | 'id' => 'wpinv_state' . uniqid(), |
360 | - 'value' => sanitize_text_field( $value ), |
|
360 | + 'value' => sanitize_text_field($value), |
|
361 | 361 | 'placeholder' => $placeholder, |
362 | - 'required' => ! empty( $address_field['required'] ), |
|
363 | - 'label' => wp_kses_post( $label ), |
|
362 | + 'required' => !empty($address_field['required']), |
|
363 | + 'label' => wp_kses_post($label), |
|
364 | 364 | 'label_type' => 'vertical', |
365 | 365 | 'help_text' => $description, |
366 | 366 | 'class' => 'wpinv_state', |
@@ -373,8 +373,8 @@ discard block |
||
373 | 373 | 'name' => 'wpinv_state', |
374 | 374 | 'id' => 'wpinv_state' . uniqid(), |
375 | 375 | 'placeholder'=> $placeholder, |
376 | - 'required' => ! empty( $address_field['required'] ), |
|
377 | - 'label' => wp_kses_post( $label ), |
|
376 | + 'required' => !empty($address_field['required']), |
|
377 | + 'label' => wp_kses_post($label), |
|
378 | 378 | 'label_type' => 'vertical', |
379 | 379 | 'help_text' => $description, |
380 | 380 | 'value' => $value, |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | |
385 | 385 | } |
386 | 386 | |
387 | - wp_send_json_success( $html ); |
|
387 | + wp_send_json_success($html); |
|
388 | 388 | exit; |
389 | 389 | |
390 | 390 | } |
@@ -400,56 +400,56 @@ discard block |
||
400 | 400 | public static function recalculate_invoice_totals() { |
401 | 401 | |
402 | 402 | // Verify nonce. |
403 | - check_ajax_referer( 'wpinv-nonce' ); |
|
403 | + check_ajax_referer('wpinv-nonce'); |
|
404 | 404 | |
405 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
405 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
406 | 406 | exit; |
407 | 407 | } |
408 | 408 | |
409 | 409 | // We need an invoice. |
410 | - if ( empty( $_POST['post_id'] ) ) { |
|
410 | + if (empty($_POST['post_id'])) { |
|
411 | 411 | exit; |
412 | 412 | } |
413 | 413 | |
414 | 414 | // Fetch the invoice. |
415 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
415 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
416 | 416 | |
417 | 417 | // Ensure it exists. |
418 | - if ( ! $invoice->get_id() ) { |
|
418 | + if (!$invoice->get_id()) { |
|
419 | 419 | exit; |
420 | 420 | } |
421 | 421 | |
422 | 422 | // Maybe set the country, state, currency. |
423 | - foreach ( array( 'country', 'state', 'currency' ) as $key ) { |
|
424 | - if ( isset( $_POST[ $key ] ) ) { |
|
423 | + foreach (array('country', 'state', 'currency') as $key) { |
|
424 | + if (isset($_POST[$key])) { |
|
425 | 425 | $method = "set_$key"; |
426 | - $invoice->$method( $_POST[ $key ] ); |
|
426 | + $invoice->$method($_POST[$key]); |
|
427 | 427 | } |
428 | 428 | } |
429 | 429 | |
430 | 430 | // Maybe disable taxes. |
431 | - $invoice->set_disable_taxes( ! empty( $_POST['taxes'] ) ); |
|
431 | + $invoice->set_disable_taxes(!empty($_POST['taxes'])); |
|
432 | 432 | |
433 | 433 | // Recalculate totals. |
434 | 434 | $invoice->recalculate_total(); |
435 | 435 | |
436 | - $total = wpinv_price( wpinv_format_amount( $invoice->get_total() ), $invoice->get_currency() ); |
|
436 | + $total = wpinv_price(wpinv_format_amount($invoice->get_total()), $invoice->get_currency()); |
|
437 | 437 | |
438 | - if ( $invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total() ) { |
|
439 | - $recurring_total = wpinv_price( wpinv_format_amount( $invoice->get_recurring_total() ), $invoice->get_currency() ); |
|
440 | - $total .= '<small class="form-text text-muted">' . sprintf( __( 'Recurring Price: %s', 'invoicing' ), $recurring_total ) . '</small>'; |
|
438 | + if ($invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total()) { |
|
439 | + $recurring_total = wpinv_price(wpinv_format_amount($invoice->get_recurring_total()), $invoice->get_currency()); |
|
440 | + $total .= '<small class="form-text text-muted">' . sprintf(__('Recurring Price: %s', 'invoicing'), $recurring_total) . '</small>'; |
|
441 | 441 | } |
442 | 442 | |
443 | 443 | $totals = array( |
444 | - 'subtotal' => wpinv_price( wpinv_format_amount( $invoice->get_subtotal() ), $invoice->get_currency() ), |
|
445 | - 'discount' => wpinv_price( wpinv_format_amount( $invoice->get_total_discount() ), $invoice->get_currency() ), |
|
446 | - 'tax' => wpinv_price( wpinv_format_amount( $invoice->get_total_tax() ), $invoice->get_currency() ), |
|
444 | + 'subtotal' => wpinv_price(wpinv_format_amount($invoice->get_subtotal()), $invoice->get_currency()), |
|
445 | + 'discount' => wpinv_price(wpinv_format_amount($invoice->get_total_discount()), $invoice->get_currency()), |
|
446 | + 'tax' => wpinv_price(wpinv_format_amount($invoice->get_total_tax()), $invoice->get_currency()), |
|
447 | 447 | 'total' => $total, |
448 | 448 | ); |
449 | 449 | |
450 | - $totals = apply_filters( 'getpaid_invoice_totals', $totals, $invoice ); |
|
450 | + $totals = apply_filters('getpaid_invoice_totals', $totals, $invoice); |
|
451 | 451 | |
452 | - wp_send_json_success( compact( 'totals' ) ); |
|
452 | + wp_send_json_success(compact('totals')); |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | /** |
@@ -458,33 +458,33 @@ discard block |
||
458 | 458 | public static function get_invoice_items() { |
459 | 459 | |
460 | 460 | // Verify nonce. |
461 | - check_ajax_referer( 'wpinv-nonce' ); |
|
461 | + check_ajax_referer('wpinv-nonce'); |
|
462 | 462 | |
463 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
463 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
464 | 464 | exit; |
465 | 465 | } |
466 | 466 | |
467 | 467 | // We need an invoice and items. |
468 | - if ( empty( $_POST['post_id'] ) ) { |
|
468 | + if (empty($_POST['post_id'])) { |
|
469 | 469 | exit; |
470 | 470 | } |
471 | 471 | |
472 | 472 | // Fetch the invoice. |
473 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
473 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
474 | 474 | |
475 | 475 | // Ensure it exists. |
476 | - if ( ! $invoice->get_id() ) { |
|
476 | + if (!$invoice->get_id()) { |
|
477 | 477 | exit; |
478 | 478 | } |
479 | 479 | |
480 | 480 | // Return an array of invoice items. |
481 | 481 | $items = array(); |
482 | 482 | |
483 | - foreach ( $invoice->get_items() as $item_id => $item ) { |
|
484 | - $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
483 | + foreach ($invoice->get_items() as $item_id => $item) { |
|
484 | + $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
485 | 485 | } |
486 | 486 | |
487 | - wp_send_json_success( compact( 'items' ) ); |
|
487 | + wp_send_json_success(compact('items')); |
|
488 | 488 | } |
489 | 489 | |
490 | 490 | /** |
@@ -493,50 +493,50 @@ discard block |
||
493 | 493 | public static function edit_invoice_item() { |
494 | 494 | |
495 | 495 | // Verify nonce. |
496 | - check_ajax_referer( 'wpinv-nonce' ); |
|
496 | + check_ajax_referer('wpinv-nonce'); |
|
497 | 497 | |
498 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
498 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
499 | 499 | exit; |
500 | 500 | } |
501 | 501 | |
502 | 502 | // We need an invoice and item details. |
503 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['data'] ) ) { |
|
503 | + if (empty($_POST['post_id']) || empty($_POST['data'])) { |
|
504 | 504 | exit; |
505 | 505 | } |
506 | 506 | |
507 | 507 | // Fetch the invoice. |
508 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
508 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
509 | 509 | |
510 | 510 | // Ensure it exists and its not been paid for. |
511 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
511 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
512 | 512 | exit; |
513 | 513 | } |
514 | 514 | |
515 | 515 | // Format the data. |
516 | - $data = wp_list_pluck( $_POST['data'], 'value', 'field' ); |
|
516 | + $data = wp_list_pluck($_POST['data'], 'value', 'field'); |
|
517 | 517 | |
518 | 518 | // Ensure that we have an item id. |
519 | - if ( empty( $data['id'] ) ) { |
|
519 | + if (empty($data['id'])) { |
|
520 | 520 | exit; |
521 | 521 | } |
522 | 522 | |
523 | 523 | // Abort if the invoice does not have the specified item. |
524 | - $item = $invoice->get_item( (int) $data['id'] ); |
|
524 | + $item = $invoice->get_item((int) $data['id']); |
|
525 | 525 | |
526 | - if ( empty( $item ) ) { |
|
526 | + if (empty($item)) { |
|
527 | 527 | exit; |
528 | 528 | } |
529 | 529 | |
530 | 530 | // Update the item. |
531 | - $item->set_price( $data['price'] ); |
|
532 | - $item->set_name( $data['name'] ); |
|
533 | - $item->set_description( $data['description'] ); |
|
534 | - $item->set_quantity( $data['quantity'] ); |
|
531 | + $item->set_price($data['price']); |
|
532 | + $item->set_name($data['name']); |
|
533 | + $item->set_description($data['description']); |
|
534 | + $item->set_quantity($data['quantity']); |
|
535 | 535 | |
536 | 536 | // Add it to the invoice. |
537 | - $error = $invoice->add_item( $item ); |
|
537 | + $error = $invoice->add_item($item); |
|
538 | 538 | $alert = false; |
539 | - if ( is_wp_error( $error ) ) { |
|
539 | + if (is_wp_error($error)) { |
|
540 | 540 | $alert = $error->get_error_message(); |
541 | 541 | } |
542 | 542 | |
@@ -549,11 +549,11 @@ discard block |
||
549 | 549 | // Return an array of invoice items. |
550 | 550 | $items = array(); |
551 | 551 | |
552 | - foreach ( $invoice->get_items() as $item_id => $item ) { |
|
553 | - $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
552 | + foreach ($invoice->get_items() as $item_id => $item) { |
|
553 | + $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
554 | 554 | } |
555 | 555 | |
556 | - wp_send_json_success( compact( 'items', 'alert' ) ); |
|
556 | + wp_send_json_success(compact('items', 'alert')); |
|
557 | 557 | } |
558 | 558 | |
559 | 559 | /** |
@@ -562,33 +562,33 @@ discard block |
||
562 | 562 | public static function remove_invoice_item() { |
563 | 563 | |
564 | 564 | // Verify nonce. |
565 | - check_ajax_referer( 'wpinv-nonce' ); |
|
565 | + check_ajax_referer('wpinv-nonce'); |
|
566 | 566 | |
567 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
567 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
568 | 568 | exit; |
569 | 569 | } |
570 | 570 | |
571 | 571 | // We need an invoice and an item. |
572 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['item_id'] ) ) { |
|
572 | + if (empty($_POST['post_id']) || empty($_POST['item_id'])) { |
|
573 | 573 | exit; |
574 | 574 | } |
575 | 575 | |
576 | 576 | // Fetch the invoice. |
577 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
577 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
578 | 578 | |
579 | 579 | // Ensure it exists and its not been paid for. |
580 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
580 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
581 | 581 | exit; |
582 | 582 | } |
583 | 583 | |
584 | 584 | // Abort if the invoice does not have the specified item. |
585 | - $item = $invoice->get_item( (int) $_POST['item_id'] ); |
|
585 | + $item = $invoice->get_item((int) $_POST['item_id']); |
|
586 | 586 | |
587 | - if ( empty( $item ) ) { |
|
587 | + if (empty($item)) { |
|
588 | 588 | exit; |
589 | 589 | } |
590 | 590 | |
591 | - $invoice->remove_item( (int) $_POST['item_id'] ); |
|
591 | + $invoice->remove_item((int) $_POST['item_id']); |
|
592 | 592 | |
593 | 593 | // Update totals. |
594 | 594 | $invoice->recalculate_total(); |
@@ -599,11 +599,11 @@ discard block |
||
599 | 599 | // Return an array of invoice items. |
600 | 600 | $items = array(); |
601 | 601 | |
602 | - foreach ( $invoice->get_items() as $item_id => $item ) { |
|
603 | - $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
602 | + foreach ($invoice->get_items() as $item_id => $item) { |
|
603 | + $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
604 | 604 | } |
605 | 605 | |
606 | - wp_send_json_success( compact( 'items' ) ); |
|
606 | + wp_send_json_success(compact('items')); |
|
607 | 607 | } |
608 | 608 | |
609 | 609 | /** |
@@ -612,39 +612,39 @@ discard block |
||
612 | 612 | public static function add_invoice_items() { |
613 | 613 | |
614 | 614 | // Verify nonce. |
615 | - check_ajax_referer( 'wpinv-nonce' ); |
|
615 | + check_ajax_referer('wpinv-nonce'); |
|
616 | 616 | |
617 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
617 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
618 | 618 | exit; |
619 | 619 | } |
620 | 620 | |
621 | 621 | // We need an invoice and items. |
622 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['items'] ) ) { |
|
622 | + if (empty($_POST['post_id']) || empty($_POST['items'])) { |
|
623 | 623 | exit; |
624 | 624 | } |
625 | 625 | |
626 | 626 | // Fetch the invoice. |
627 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
627 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
628 | 628 | $alert = false; |
629 | 629 | |
630 | 630 | // Ensure it exists and its not been paid for. |
631 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
631 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
632 | 632 | exit; |
633 | 633 | } |
634 | 634 | |
635 | 635 | // Add the items. |
636 | - foreach ( $_POST['items'] as $data ) { |
|
636 | + foreach ($_POST['items'] as $data) { |
|
637 | 637 | |
638 | - $item = new GetPaid_Form_Item( $data[ 'id' ] ); |
|
638 | + $item = new GetPaid_Form_Item($data['id']); |
|
639 | 639 | |
640 | - if ( is_numeric( $data[ 'qty' ] ) && (int) $data[ 'qty' ] > 0 ) { |
|
641 | - $item->set_quantity( $data[ 'qty' ] ); |
|
640 | + if (is_numeric($data['qty']) && (int) $data['qty'] > 0) { |
|
641 | + $item->set_quantity($data['qty']); |
|
642 | 642 | } |
643 | 643 | |
644 | - if ( $item->get_id() > 0 ) { |
|
645 | - $error = $invoice->add_item( $item ); |
|
644 | + if ($item->get_id() > 0) { |
|
645 | + $error = $invoice->add_item($item); |
|
646 | 646 | |
647 | - if ( is_wp_error( $error ) ) { |
|
647 | + if (is_wp_error($error)) { |
|
648 | 648 | $alert = $error->get_error_message(); |
649 | 649 | } |
650 | 650 | |
@@ -659,11 +659,11 @@ discard block |
||
659 | 659 | // Return an array of invoice items. |
660 | 660 | $items = array(); |
661 | 661 | |
662 | - foreach ( $invoice->get_items() as $item_id => $item ) { |
|
663 | - $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
662 | + foreach ($invoice->get_items() as $item_id => $item) { |
|
663 | + $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
664 | 664 | } |
665 | 665 | |
666 | - wp_send_json_success( compact( 'items', 'alert' ) ); |
|
666 | + wp_send_json_success(compact('items', 'alert')); |
|
667 | 667 | } |
668 | 668 | |
669 | 669 | /** |
@@ -672,15 +672,15 @@ discard block |
||
672 | 672 | public static function get_invoicing_items() { |
673 | 673 | |
674 | 674 | // Verify nonce. |
675 | - check_ajax_referer( 'wpinv-nonce' ); |
|
675 | + check_ajax_referer('wpinv-nonce'); |
|
676 | 676 | |
677 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
677 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
678 | 678 | exit; |
679 | 679 | } |
680 | 680 | |
681 | 681 | // We need a search term. |
682 | - if ( empty( $_GET['search'] ) ) { |
|
683 | - wp_send_json_success( array() ); |
|
682 | + if (empty($_GET['search'])) { |
|
683 | + wp_send_json_success(array()); |
|
684 | 684 | } |
685 | 685 | |
686 | 686 | // Retrieve items. |
@@ -689,8 +689,8 @@ discard block |
||
689 | 689 | 'orderby' => 'title', |
690 | 690 | 'order' => 'ASC', |
691 | 691 | 'posts_per_page' => -1, |
692 | - 'post_status' => array( 'publish' ), |
|
693 | - 's' => trim( $_GET['search'] ), |
|
692 | + 'post_status' => array('publish'), |
|
693 | + 's' => trim($_GET['search']), |
|
694 | 694 | 'meta_query' => array( |
695 | 695 | array( |
696 | 696 | 'key' => '_wpinv_type', |
@@ -700,22 +700,22 @@ discard block |
||
700 | 700 | ) |
701 | 701 | ); |
702 | 702 | |
703 | - $items = get_posts( apply_filters( 'getpaid_ajax_invoice_items_query_args', $item_args ) ); |
|
703 | + $items = get_posts(apply_filters('getpaid_ajax_invoice_items_query_args', $item_args)); |
|
704 | 704 | $data = array(); |
705 | 705 | |
706 | 706 | |
707 | - $is_payment_form = ( ! empty( $_GET['post_id'] ) && 'wpi_payment_form' == get_post_type( $_GET['post_id'] ) ); |
|
707 | + $is_payment_form = (!empty($_GET['post_id']) && 'wpi_payment_form' == get_post_type($_GET['post_id'])); |
|
708 | 708 | |
709 | - foreach ( $items as $item ) { |
|
710 | - $item = new GetPaid_Form_Item( $item ); |
|
709 | + foreach ($items as $item) { |
|
710 | + $item = new GetPaid_Form_Item($item); |
|
711 | 711 | $data[] = array( |
712 | 712 | 'id' => (int) $item->get_id(), |
713 | - 'text' => strip_tags( $item->get_name() ), |
|
714 | - 'form_data' => $is_payment_form ? $item->prepare_data_for_use( false ) : '', |
|
713 | + 'text' => strip_tags($item->get_name()), |
|
714 | + 'form_data' => $is_payment_form ? $item->prepare_data_for_use(false) : '', |
|
715 | 715 | ); |
716 | 716 | } |
717 | 717 | |
718 | - wp_send_json_success( $data ); |
|
718 | + wp_send_json_success($data); |
|
719 | 719 | |
720 | 720 | } |
721 | 721 | |
@@ -725,24 +725,24 @@ discard block |
||
725 | 725 | public static function get_aui_states_field() { |
726 | 726 | |
727 | 727 | // Verify nonce. |
728 | - check_ajax_referer( 'wpinv-nonce' ); |
|
728 | + check_ajax_referer('wpinv-nonce'); |
|
729 | 729 | |
730 | 730 | // We need a country. |
731 | - if ( empty( $_GET['country'] ) ) { |
|
731 | + if (empty($_GET['country'])) { |
|
732 | 732 | exit; |
733 | 733 | } |
734 | 734 | |
735 | - $states = wpinv_get_country_states( trim( $_GET['country'] ) ); |
|
736 | - $state = isset( $_GET['state'] ) ? trim( $_GET['state'] ) : wpinv_get_default_state(); |
|
735 | + $states = wpinv_get_country_states(trim($_GET['country'])); |
|
736 | + $state = isset($_GET['state']) ? trim($_GET['state']) : wpinv_get_default_state(); |
|
737 | 737 | |
738 | - if ( empty( $states ) ) { |
|
738 | + if (empty($states)) { |
|
739 | 739 | |
740 | 740 | $html = aui()->input( |
741 | 741 | array( |
742 | 742 | 'type' => 'text', |
743 | 743 | 'id' => 'wpinv_state', |
744 | 744 | 'name' => 'wpinv_state', |
745 | - 'label' => __( 'State', 'invoicing' ), |
|
745 | + 'label' => __('State', 'invoicing'), |
|
746 | 746 | 'label_type' => 'vertical', |
747 | 747 | 'placeholder' => 'Liège', |
748 | 748 | 'class' => 'form-control-sm', |
@@ -756,9 +756,9 @@ discard block |
||
756 | 756 | array( |
757 | 757 | 'id' => 'wpinv_state', |
758 | 758 | 'name' => 'wpinv_state', |
759 | - 'label' => __( 'State', 'invoicing' ), |
|
759 | + 'label' => __('State', 'invoicing'), |
|
760 | 760 | 'label_type' => 'vertical', |
761 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
761 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
762 | 762 | 'class' => 'form-control-sm', |
763 | 763 | 'value' => $state, |
764 | 764 | 'options' => $states, |
@@ -772,7 +772,7 @@ discard block |
||
772 | 772 | wp_send_json_success( |
773 | 773 | array( |
774 | 774 | 'html' => $html, |
775 | - 'select' => ! empty ( $states ) |
|
775 | + 'select' => !empty ($states) |
|
776 | 776 | ) |
777 | 777 | ); |
778 | 778 | |
@@ -786,46 +786,46 @@ discard block |
||
786 | 786 | public static function ip_geolocation() { |
787 | 787 | |
788 | 788 | // Check nonce. |
789 | - check_ajax_referer( 'getpaid-ip-location' ); |
|
789 | + check_ajax_referer('getpaid-ip-location'); |
|
790 | 790 | |
791 | 791 | // IP address. |
792 | - if ( empty( $_GET['ip'] ) || ! rest_is_ip_address( $_GET['ip'] ) ) { |
|
793 | - _e( 'Invalid IP Address.', 'invoicing' ); |
|
792 | + if (empty($_GET['ip']) || !rest_is_ip_address($_GET['ip'])) { |
|
793 | + _e('Invalid IP Address.', 'invoicing'); |
|
794 | 794 | exit; |
795 | 795 | } |
796 | 796 | |
797 | 797 | // Retrieve location info. |
798 | - $location = getpaid_geolocate_ip_address( $_GET['ip'] ); |
|
798 | + $location = getpaid_geolocate_ip_address($_GET['ip']); |
|
799 | 799 | |
800 | - if ( empty( $location ) ) { |
|
801 | - _e( 'Unable to find geolocation for the IP Address.', 'invoicing' ); |
|
800 | + if (empty($location)) { |
|
801 | + _e('Unable to find geolocation for the IP Address.', 'invoicing'); |
|
802 | 802 | exit; |
803 | 803 | } |
804 | 804 | |
805 | 805 | // Sorry. |
806 | - extract( $location ); |
|
806 | + extract($location); |
|
807 | 807 | |
808 | 808 | // Prepare the address. |
809 | 809 | $content = ''; |
810 | 810 | |
811 | - if ( ! empty( $location['city'] ) ) { |
|
812 | - $content .= $location['city'] . ', '; |
|
811 | + if (!empty($location['city'])) { |
|
812 | + $content .= $location['city'] . ', '; |
|
813 | 813 | } |
814 | 814 | |
815 | - if ( ! empty( $location['region'] ) ) { |
|
816 | - $content .= $location['region'] . ', '; |
|
815 | + if (!empty($location['region'])) { |
|
816 | + $content .= $location['region'] . ', '; |
|
817 | 817 | } |
818 | 818 | |
819 | - $content .= $location['country'] . ' (' . $location['iso'] . ')'; |
|
819 | + $content .= $location['country'] . ' (' . $location['iso'] . ')'; |
|
820 | 820 | |
821 | 821 | $location['address'] = $content; |
822 | 822 | |
823 | - $content = '<p>'. sprintf( __( '<b>Address:</b> %s', 'invoicing' ), $content ) . '</p>'; |
|
824 | - $content .= '<p>'. $location['credit'] . '</p>'; |
|
823 | + $content = '<p>' . sprintf(__('<b>Address:</b> %s', 'invoicing'), $content) . '</p>'; |
|
824 | + $content .= '<p>' . $location['credit'] . '</p>'; |
|
825 | 825 | |
826 | 826 | $location['content'] = $content; |
827 | 827 | |
828 | - wpinv_get_template( 'geolocation.php', $location ); |
|
828 | + wpinv_get_template('geolocation.php', $location); |
|
829 | 829 | |
830 | 830 | exit; |
831 | 831 | } |
@@ -838,11 +838,11 @@ discard block |
||
838 | 838 | public static function payment_form_refresh_prices() { |
839 | 839 | |
840 | 840 | // Check nonce. |
841 | - check_ajax_referer( 'getpaid_form_nonce' ); |
|
841 | + check_ajax_referer('getpaid_form_nonce'); |
|
842 | 842 | |
843 | 843 | // ... form fields... |
844 | - if ( empty( $_POST['getpaid_payment_form_submission'] ) ) { |
|
845 | - _e( 'Error: Reload the page and try again.', 'invoicing' ); |
|
844 | + if (empty($_POST['getpaid_payment_form_submission'])) { |
|
845 | + _e('Error: Reload the page and try again.', 'invoicing'); |
|
846 | 846 | exit; |
847 | 847 | } |
848 | 848 | |
@@ -850,18 +850,18 @@ discard block |
||
850 | 850 | $submission = new GetPaid_Payment_Form_Submission(); |
851 | 851 | |
852 | 852 | // Do we have an error? |
853 | - if ( ! empty( $submission->last_error ) ) { |
|
853 | + if (!empty($submission->last_error)) { |
|
854 | 854 | echo $submission->last_error; |
855 | 855 | exit; |
856 | 856 | } |
857 | 857 | |
858 | 858 | // Prepare the response. |
859 | - $response = new GetPaid_Payment_Form_Submission_Refresh_Prices( $submission ); |
|
859 | + $response = new GetPaid_Payment_Form_Submission_Refresh_Prices($submission); |
|
860 | 860 | |
861 | 861 | // Filter the response. |
862 | - $response = apply_filters( 'getpaid_payment_form_ajax_refresh_prices', $response->response, $submission ); |
|
862 | + $response = apply_filters('getpaid_payment_form_ajax_refresh_prices', $response->response, $submission); |
|
863 | 863 | |
864 | - wp_send_json_success( $response ); |
|
864 | + wp_send_json_success($response); |
|
865 | 865 | } |
866 | 866 | |
867 | 867 | } |
@@ -10,67 +10,67 @@ discard block |
||
10 | 10 | * @var array $columns |
11 | 11 | */ |
12 | 12 | |
13 | -defined( 'ABSPATH' ) || exit; |
|
13 | +defined('ABSPATH') || exit; |
|
14 | 14 | |
15 | 15 | ?> |
16 | 16 | |
17 | -<?php do_action( 'getpaid_before_email_line_item', $invoice, $item ); ?> |
|
17 | +<?php do_action('getpaid_before_email_line_item', $invoice, $item); ?> |
|
18 | 18 | |
19 | -<tr class="wpinv_cart_item item-type-<?php echo sanitize_html_class( $item->get_type() ); ?>"> |
|
19 | +<tr class="wpinv_cart_item item-type-<?php echo sanitize_html_class($item->get_type()); ?>"> |
|
20 | 20 | |
21 | - <?php foreach ( array_keys( $columns ) as $column ): ?> |
|
21 | + <?php foreach (array_keys($columns) as $column): ?> |
|
22 | 22 | |
23 | - <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right' ?> wpinv_cart_item_<?php echo sanitize_html_class( $column ); ?>"> |
|
23 | + <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right' ?> wpinv_cart_item_<?php echo sanitize_html_class($column); ?>"> |
|
24 | 24 | |
25 | 25 | <?php |
26 | 26 | |
27 | 27 | // Fires before printing a line item column. |
28 | - do_action( "getpaid_email_line_item_before_$column", $item, $invoice ); |
|
28 | + do_action("getpaid_email_line_item_before_$column", $item, $invoice); |
|
29 | 29 | |
30 | 30 | // Item name. |
31 | - if ( 'name' == $column ) { |
|
31 | + if ('name' == $column) { |
|
32 | 32 | |
33 | 33 | // Display the name. |
34 | - echo '<div class="wpinv_email_cart_item_title">' . sanitize_text_field( $item->get_name() ) . '</div>'; |
|
34 | + echo '<div class="wpinv_email_cart_item_title">' . sanitize_text_field($item->get_name()) . '</div>'; |
|
35 | 35 | |
36 | 36 | // And an optional description. |
37 | 37 | $description = $item->get_description(); |
38 | 38 | |
39 | - if ( ! empty( $description ) ) { |
|
40 | - $description = wp_kses_post( $description ); |
|
39 | + if (!empty($description)) { |
|
40 | + $description = wp_kses_post($description); |
|
41 | 41 | echo "<p class='small'>$description</p>"; |
42 | 42 | } |
43 | 43 | |
44 | 44 | // Price help text |
45 | - $description = getpaid_item_recurring_price_help_text( $item, $invoice->get_currency() ); |
|
46 | - if ( $description ) { |
|
45 | + $description = getpaid_item_recurring_price_help_text($item, $invoice->get_currency()); |
|
46 | + if ($description) { |
|
47 | 47 | echo "<p class='small'>$description</p>"; |
48 | 48 | } |
49 | 49 | |
50 | 50 | } |
51 | 51 | |
52 | 52 | // Item price. |
53 | - if ( 'price' == $column ) { |
|
53 | + if ('price' == $column) { |
|
54 | 54 | |
55 | 55 | // Display the item price (or recurring price if this is a renewal invoice) |
56 | 56 | $price = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price(); |
57 | - echo wpinv_price( $price ); |
|
57 | + echo wpinv_price($price); |
|
58 | 58 | |
59 | 59 | } |
60 | 60 | |
61 | 61 | // Item quantity. |
62 | - if ( 'quantity' == $column ) { |
|
62 | + if ('quantity' == $column) { |
|
63 | 63 | echo (int) $item->get_quantity(); |
64 | 64 | } |
65 | 65 | |
66 | 66 | // Item sub total. |
67 | - if ( 'subtotal' == $column ) { |
|
67 | + if ('subtotal' == $column) { |
|
68 | 68 | $subtotal = $invoice->is_renewal() ? $item->get_recurring_sub_total() : $item->get_sub_total(); |
69 | - echo wpinv_price( $subtotal ); |
|
69 | + echo wpinv_price($subtotal); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | // Fires when printing a line item column. |
73 | - do_action( "getpaid_email_line_item_$column", $item, $invoice ); |
|
73 | + do_action("getpaid_email_line_item_$column", $item, $invoice); |
|
74 | 74 | |
75 | 75 | ?> |
76 | 76 | |
@@ -80,4 +80,4 @@ discard block |
||
80 | 80 | |
81 | 81 | </tr> |
82 | 82 | |
83 | -<?php do_action( 'getpaid_after_email_line_item', $invoice, $item ); ?> |
|
83 | +<?php do_action('getpaid_after_email_line_item', $invoice, $item); ?> |
@@ -10,63 +10,63 @@ discard block |
||
10 | 10 | * @var array $columns |
11 | 11 | */ |
12 | 12 | |
13 | -defined( 'ABSPATH' ) || exit; |
|
13 | +defined('ABSPATH') || exit; |
|
14 | 14 | |
15 | 15 | ?> |
16 | 16 | |
17 | -<?php do_action( 'getpaid_before_email_fee_item', $invoice, $fee ); ?> |
|
17 | +<?php do_action('getpaid_before_email_fee_item', $invoice, $fee); ?> |
|
18 | 18 | |
19 | 19 | <tr class="wpinv_cart_item item-fee"> |
20 | 20 | |
21 | - <?php foreach ( array_keys( $columns ) as $column ): ?> |
|
21 | + <?php foreach (array_keys($columns) as $column): ?> |
|
22 | 22 | |
23 | - <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right' ?> wpinv_cart_item_<?php echo sanitize_html_class( $column ); ?>"> |
|
23 | + <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right' ?> wpinv_cart_item_<?php echo sanitize_html_class($column); ?>"> |
|
24 | 24 | |
25 | 25 | <?php |
26 | 26 | |
27 | 27 | // Fires before printing a fee item column. |
28 | - do_action( "getpaid_email_fee_item_before_$column", $fee, $invoice ); |
|
28 | + do_action("getpaid_email_fee_item_before_$column", $fee, $invoice); |
|
29 | 29 | |
30 | 30 | // Item name. |
31 | - if ( 'name' == $column ) { |
|
31 | + if ('name' == $column) { |
|
32 | 32 | |
33 | 33 | // Display the name. |
34 | - echo '<div class="wpinv_email_cart_item_title">' . sanitize_text_field( $fee['name'] ) . '</div>'; |
|
34 | + echo '<div class="wpinv_email_cart_item_title">' . sanitize_text_field($fee['name']) . '</div>'; |
|
35 | 35 | |
36 | 36 | // And an optional description. |
37 | - $description = esc_html__( 'Fee', 'invoicing' ); |
|
37 | + $description = esc_html__('Fee', 'invoicing'); |
|
38 | 38 | echo "<p class='small'>$description</p>"; |
39 | 39 | |
40 | 40 | } |
41 | 41 | |
42 | 42 | // Item price. |
43 | - if ( 'price' == $column ) { |
|
43 | + if ('price' == $column) { |
|
44 | 44 | |
45 | 45 | // Display the item price (or recurring price if this is a renewal invoice) |
46 | - if ( $invoice->is_recurring() && $invoice->is_renewal() ) { |
|
47 | - echo wpinv_price( $fee['recurring_fee'], $invoice->get_currency() ); |
|
46 | + if ($invoice->is_recurring() && $invoice->is_renewal()) { |
|
47 | + echo wpinv_price($fee['recurring_fee'], $invoice->get_currency()); |
|
48 | 48 | } else { |
49 | - echo wpinv_price( $fee['initial_fee'], $invoice->get_currency() ); |
|
49 | + echo wpinv_price($fee['initial_fee'], $invoice->get_currency()); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | } |
53 | 53 | |
54 | 54 | // Item quantity. |
55 | - if ( 'quantity' == $column ) { |
|
55 | + if ('quantity' == $column) { |
|
56 | 56 | echo "—"; |
57 | 57 | } |
58 | 58 | |
59 | 59 | // Item sub total. |
60 | - if ( 'subtotal' == $column ) { |
|
61 | - if ( $invoice->is_recurring() && $invoice->is_renewal() ) { |
|
62 | - echo wpinv_price( $fee['recurring_fee'], $invoice->get_currency() ); |
|
60 | + if ('subtotal' == $column) { |
|
61 | + if ($invoice->is_recurring() && $invoice->is_renewal()) { |
|
62 | + echo wpinv_price($fee['recurring_fee'], $invoice->get_currency()); |
|
63 | 63 | } else { |
64 | - echo wpinv_price( $fee['initial_fee'], $invoice->get_currency() ); |
|
64 | + echo wpinv_price($fee['initial_fee'], $invoice->get_currency()); |
|
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
68 | 68 | // Fires when printing a line item column. |
69 | - do_action( "getpaid_email_fee_item_$column", $fee, $invoice ); |
|
69 | + do_action("getpaid_email_fee_item_$column", $fee, $invoice); |
|
70 | 70 | |
71 | 71 | ?> |
72 | 72 | |
@@ -76,4 +76,4 @@ discard block |
||
76 | 76 | |
77 | 77 | </tr> |
78 | 78 | |
79 | -<?php do_action( 'getpaid_after_email_fee_item', $invoice, $fee ); ?> |
|
79 | +<?php do_action('getpaid_after_email_fee_item', $invoice, $fee); ?> |
@@ -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 | * Abstaract Payment Gateway class. |
@@ -139,49 +139,49 @@ discard block |
||
139 | 139 | public function __construct() { |
140 | 140 | |
141 | 141 | // Register gateway. |
142 | - add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) ); |
|
142 | + add_filter('wpinv_payment_gateways', array($this, 'register_gateway')); |
|
143 | 143 | |
144 | - $this->enabled = wpinv_is_gateway_active( $this->id ); |
|
144 | + $this->enabled = wpinv_is_gateway_active($this->id); |
|
145 | 145 | |
146 | 146 | // Enable Subscriptions. |
147 | - if ( $this->supports( 'subscription' ) ) { |
|
148 | - add_filter( "wpinv_{$this->id}_support_subscription", '__return_true' ); |
|
147 | + if ($this->supports('subscription')) { |
|
148 | + add_filter("wpinv_{$this->id}_support_subscription", '__return_true'); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | // Enable sandbox. |
152 | - if ( $this->supports( 'sandbox' ) ) { |
|
153 | - add_filter( "wpinv_{$this->id}_supports_sandbox", '__return_true' ); |
|
152 | + if ($this->supports('sandbox')) { |
|
153 | + add_filter("wpinv_{$this->id}_supports_sandbox", '__return_true'); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | // Gateway settings. |
157 | - add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) ); |
|
157 | + add_filter("wpinv_gateway_settings_{$this->id}", array($this, 'admin_settings')); |
|
158 | 158 | |
159 | 159 | |
160 | 160 | // Gateway checkout fiellds. |
161 | - add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 ); |
|
161 | + add_action("wpinv_{$this->id}_cc_form", array($this, 'payment_fields'), 10, 2); |
|
162 | 162 | |
163 | 163 | // Process payment. |
164 | - add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 ); |
|
164 | + add_action("getpaid_gateway_{$this->id}", array($this, 'process_payment'), 10, 3); |
|
165 | 165 | |
166 | 166 | // Change the checkout button text. |
167 | - if ( ! empty( $this->checkout_button_text ) ) { |
|
168 | - add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) ); |
|
167 | + if (!empty($this->checkout_button_text)) { |
|
168 | + add_filter("getpaid_gateway_{$this->id}_checkout_button_label", array($this, 'rename_checkout_button')); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | // Check if a gateway is valid for a given currency. |
172 | - add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 ); |
|
172 | + add_filter("getpaid_gateway_{$this->id}_is_valid_for_currency", array($this, 'validate_currency'), 10, 2); |
|
173 | 173 | |
174 | 174 | // Generate the transaction url. |
175 | - add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 ); |
|
175 | + add_filter("getpaid_gateway_{$this->id}_transaction_url", array($this, 'filter_transaction_url'), 10, 2); |
|
176 | 176 | |
177 | 177 | // Generate the subscription url. |
178 | - add_filter( "getpaid_gateway_{$this->id}_subscription_url", array( $this, 'filter_subscription_url' ), 10, 2 ); |
|
178 | + add_filter("getpaid_gateway_{$this->id}_subscription_url", array($this, 'filter_subscription_url'), 10, 2); |
|
179 | 179 | |
180 | 180 | // Confirm payments. |
181 | - add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 ); |
|
181 | + add_filter("wpinv_payment_confirm_{$this->id}", array($this, 'confirm_payment'), 10, 2); |
|
182 | 182 | |
183 | 183 | // Verify IPNs. |
184 | - add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) ); |
|
184 | + add_action("wpinv_verify_{$this->id}_ipn", array($this, 'verify_ipn')); |
|
185 | 185 | |
186 | 186 | } |
187 | 187 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * @since 1.0.19 |
192 | 192 | * @return bool |
193 | 193 | */ |
194 | - public function is( $gateway ) { |
|
194 | + public function is($gateway) { |
|
195 | 195 | return $gateway == $this->id; |
196 | 196 | } |
197 | 197 | |
@@ -201,23 +201,23 @@ discard block |
||
201 | 201 | * @since 1.0.19 |
202 | 202 | * @return array |
203 | 203 | */ |
204 | - public function get_tokens( $sandbox = null ) { |
|
204 | + public function get_tokens($sandbox = null) { |
|
205 | 205 | |
206 | - if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) { |
|
207 | - $tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true ); |
|
206 | + if (is_user_logged_in() && $this->supports('tokens') && 0 == count($this->tokens)) { |
|
207 | + $tokens = get_user_meta(get_current_user_id(), "getpaid_{$this->id}_tokens", true); |
|
208 | 208 | |
209 | - if ( is_array( $tokens ) ) { |
|
209 | + if (is_array($tokens)) { |
|
210 | 210 | $this->tokens = $tokens; |
211 | 211 | } |
212 | 212 | |
213 | 213 | } |
214 | 214 | |
215 | - if ( ! is_bool( $sandbox ) ) { |
|
215 | + if (!is_bool($sandbox)) { |
|
216 | 216 | return $this->tokens; |
217 | 217 | } |
218 | 218 | |
219 | - $args = array( 'type' => $sandbox ? 'sandbox' : 'live' ); |
|
220 | - return wp_list_filter( $this->tokens, $args ); |
|
219 | + $args = array('type' => $sandbox ? 'sandbox' : 'live'); |
|
220 | + return wp_list_filter($this->tokens, $args); |
|
221 | 221 | |
222 | 222 | } |
223 | 223 | |
@@ -226,12 +226,12 @@ discard block |
||
226 | 226 | * |
227 | 227 | * @since 1.0.19 |
228 | 228 | */ |
229 | - public function save_token( $token ) { |
|
229 | + public function save_token($token) { |
|
230 | 230 | |
231 | 231 | $tokens = $this->get_tokens(); |
232 | 232 | $tokens[] = $token; |
233 | 233 | |
234 | - update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens ); |
|
234 | + update_user_meta(get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens); |
|
235 | 235 | |
236 | 236 | $this->tokens = $tokens; |
237 | 237 | |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | * @return string |
244 | 244 | */ |
245 | 245 | public function get_method_title() { |
246 | - return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this ); |
|
246 | + return apply_filters('getpaid_gateway_method_title', $this->method_title, $this); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * @return string |
253 | 253 | */ |
254 | 254 | public function get_method_description() { |
255 | - return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this ); |
|
255 | + return apply_filters('getpaid_gateway_method_description', $this->method_description, $this); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | * @param WPInv_Invoice $invoice Invoice object. |
262 | 262 | * @return string |
263 | 263 | */ |
264 | - public function get_return_url( $invoice ) { |
|
264 | + public function get_return_url($invoice) { |
|
265 | 265 | |
266 | 266 | // Payment success url |
267 | 267 | $return_url = add_query_arg( |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | wpinv_get_success_page_uri() |
274 | 274 | ); |
275 | 275 | |
276 | - return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this ); |
|
276 | + return apply_filters('getpaid_gateway_success_url', $return_url, $invoice, $this); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | /** |
@@ -282,24 +282,24 @@ discard block |
||
282 | 282 | * @param string $content Success page content. |
283 | 283 | * @return string |
284 | 284 | */ |
285 | - public function confirm_payment( $content ) { |
|
285 | + public function confirm_payment($content) { |
|
286 | 286 | |
287 | 287 | // Retrieve the invoice. |
288 | 288 | $invoice_id = getpaid_get_current_invoice_id(); |
289 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
289 | + $invoice = wpinv_get_invoice($invoice_id); |
|
290 | 290 | |
291 | 291 | // Ensure that it exists and that it is pending payment. |
292 | - if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) { |
|
292 | + if (empty($invoice_id) || !$invoice->needs_payment()) { |
|
293 | 293 | return $content; |
294 | 294 | } |
295 | 295 | |
296 | 296 | // Can the user view this invoice?? |
297 | - if ( ! wpinv_user_can_view_invoice( $invoice ) ) { |
|
297 | + if (!wpinv_user_can_view_invoice($invoice)) { |
|
298 | 298 | return $content; |
299 | 299 | } |
300 | 300 | |
301 | 301 | // Show payment processing indicator. |
302 | - return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) ); |
|
302 | + return wpinv_get_template_html('wpinv-payment-processing.php', compact('invoice')); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | /** |
@@ -316,14 +316,14 @@ discard block |
||
316 | 316 | * @param WPInv_Invoice $invoice Invoice object. |
317 | 317 | * @return string transaction URL, or empty string. |
318 | 318 | */ |
319 | - public function filter_transaction_url( $transaction_url, $invoice ) { |
|
319 | + public function filter_transaction_url($transaction_url, $invoice) { |
|
320 | 320 | |
321 | - $transaction_id = $invoice->get_transaction_id(); |
|
321 | + $transaction_id = $invoice->get_transaction_id(); |
|
322 | 322 | |
323 | - if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) { |
|
324 | - $transaction_url = sprintf( $this->view_transaction_url, $transaction_id ); |
|
325 | - $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
326 | - $transaction_url = str_replace( '{sandbox}', $replace, $transaction_url ); |
|
323 | + if (!empty($this->view_transaction_url) && !empty($transaction_id)) { |
|
324 | + $transaction_url = sprintf($this->view_transaction_url, $transaction_id); |
|
325 | + $replace = $this->is_sandbox($invoice) ? 'sandbox' : ''; |
|
326 | + $transaction_url = str_replace('{sandbox}', $replace, $transaction_url); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | return $transaction_url; |
@@ -336,15 +336,15 @@ discard block |
||
336 | 336 | * @param WPInv_Invoice $invoice Invoice object. |
337 | 337 | * @return string subscription URL, or empty string. |
338 | 338 | */ |
339 | - public function filter_subscription_url( $subscription_url, $invoice ) { |
|
339 | + public function filter_subscription_url($subscription_url, $invoice) { |
|
340 | 340 | |
341 | - $profile_id = $invoice->get_subscription_id(); |
|
341 | + $profile_id = $invoice->get_subscription_id(); |
|
342 | 342 | |
343 | - if ( ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) { |
|
343 | + if (!empty($this->view_subscription_url) && !empty($profile_id)) { |
|
344 | 344 | |
345 | - $subscription_url = sprintf( $this->view_subscription_url, $profile_id ); |
|
346 | - $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
347 | - $subscription_url = str_replace( '{sandbox}', $replace, $subscription_url ); |
|
345 | + $subscription_url = sprintf($this->view_subscription_url, $profile_id); |
|
346 | + $replace = $this->is_sandbox($invoice) ? 'sandbox' : ''; |
|
347 | + $subscription_url = str_replace('{sandbox}', $replace, $subscription_url); |
|
348 | 348 | |
349 | 349 | } |
350 | 350 | |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | * @return bool |
358 | 358 | */ |
359 | 359 | public function is_available() { |
360 | - return ! empty( $this->enabled ); |
|
360 | + return !empty($this->enabled); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | /** |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | * @return string |
367 | 367 | */ |
368 | 368 | public function get_title() { |
369 | - return apply_filters( 'getpaid_gateway_title', $this->title, $this ); |
|
369 | + return apply_filters('getpaid_gateway_title', $this->title, $this); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | /** |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | * @return string |
376 | 376 | */ |
377 | 377 | public function get_description() { |
378 | - return apply_filters( 'getpaid_gateway_description', $this->description, $this ); |
|
378 | + return apply_filters('getpaid_gateway_description', $this->description, $this); |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | /** |
@@ -387,9 +387,9 @@ discard block |
||
387 | 387 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
388 | 388 | * @return void |
389 | 389 | */ |
390 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
390 | + public function process_payment($invoice, $submission_data, $submission) { |
|
391 | 391 | // Process the payment then either redirect to the success page or the gateway. |
392 | - do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission ); |
|
392 | + do_action('getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission); |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | /** |
@@ -403,8 +403,8 @@ discard block |
||
403 | 403 | * @param string $reason Refund reason. |
404 | 404 | * @return WP_Error|bool True or false based on success, or a WP_Error object. |
405 | 405 | */ |
406 | - public function process_refund( $invoice, $amount = null, $reason = '' ) { |
|
407 | - return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason ); |
|
406 | + public function process_refund($invoice, $amount = null, $reason = '') { |
|
407 | + return apply_filters('getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason); |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | /** |
@@ -413,8 +413,8 @@ discard block |
||
413 | 413 | * @param int $invoice_id 0 or invoice id. |
414 | 414 | * @param GetPaid_Payment_Form $form Current payment form. |
415 | 415 | */ |
416 | - public function payment_fields( $invoice_id, $form ) { |
|
417 | - do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form ); |
|
416 | + public function payment_fields($invoice_id, $form) { |
|
417 | + do_action('getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form); |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | /** |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | * |
423 | 423 | * @param array $admin_settings |
424 | 424 | */ |
425 | - public function admin_settings( $admin_settings ) { |
|
425 | + public function admin_settings($admin_settings) { |
|
426 | 426 | return $admin_settings; |
427 | 427 | } |
428 | 428 | |
@@ -431,8 +431,8 @@ discard block |
||
431 | 431 | * |
432 | 432 | * @param string $option |
433 | 433 | */ |
434 | - public function get_option( $option, $default = false ) { |
|
435 | - return wpinv_get_option( $this->id . '_' . $option, $default ); |
|
434 | + public function get_option($option, $default = false) { |
|
435 | + return wpinv_get_option($this->id . '_' . $option, $default); |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | /** |
@@ -445,8 +445,8 @@ discard block |
||
445 | 445 | * @return bool True if the gateway supports the feature, false otherwise. |
446 | 446 | * @since 1.0.19 |
447 | 447 | */ |
448 | - public function supports( $feature ) { |
|
449 | - return apply_filters( 'getpaid_payment_gateway_supports', in_array( $feature, $this->supports ), $feature, $this ); |
|
448 | + public function supports($feature) { |
|
449 | + return apply_filters('getpaid_payment_gateway_supports', in_array($feature, $this->supports), $feature, $this); |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | /** |
@@ -454,36 +454,36 @@ discard block |
||
454 | 454 | * |
455 | 455 | * @param bool $save whether or not to display the save button. |
456 | 456 | */ |
457 | - public function get_cc_form( $save = false ) { |
|
457 | + public function get_cc_form($save = false) { |
|
458 | 458 | |
459 | 459 | ob_start(); |
460 | 460 | |
461 | - $id_prefix = esc_attr( uniqid( $this->id ) ); |
|
461 | + $id_prefix = esc_attr(uniqid($this->id)); |
|
462 | 462 | |
463 | 463 | $months = array( |
464 | - '01' => __( 'January', 'invoicing' ), |
|
465 | - '02' => __( 'February', 'invoicing' ), |
|
466 | - '03' => __( 'March', 'invoicing' ), |
|
467 | - '04' => __( 'April', 'invoicing' ), |
|
468 | - '05' => __( 'May', 'invoicing' ), |
|
469 | - '06' => __( 'June', 'invoicing' ), |
|
470 | - '07' => __( 'July', 'invoicing' ), |
|
471 | - '08' => __( 'August', 'invoicing' ), |
|
472 | - '09' => __( 'September', 'invoicing' ), |
|
473 | - '10' => __( 'October', 'invoicing' ), |
|
474 | - '11' => __( 'November', 'invoicing' ), |
|
475 | - '12' => __( 'December', 'invoicing' ), |
|
464 | + '01' => __('January', 'invoicing'), |
|
465 | + '02' => __('February', 'invoicing'), |
|
466 | + '03' => __('March', 'invoicing'), |
|
467 | + '04' => __('April', 'invoicing'), |
|
468 | + '05' => __('May', 'invoicing'), |
|
469 | + '06' => __('June', 'invoicing'), |
|
470 | + '07' => __('July', 'invoicing'), |
|
471 | + '08' => __('August', 'invoicing'), |
|
472 | + '09' => __('September', 'invoicing'), |
|
473 | + '10' => __('October', 'invoicing'), |
|
474 | + '11' => __('November', 'invoicing'), |
|
475 | + '12' => __('December', 'invoicing'), |
|
476 | 476 | ); |
477 | 477 | |
478 | - $year = (int) date( 'Y', current_time( 'timestamp' ) ); |
|
478 | + $year = (int) date('Y', current_time('timestamp')); |
|
479 | 479 | $years = array(); |
480 | 480 | |
481 | - for ( $i = 0; $i <= 10; $i++ ) { |
|
482 | - $years[ $year + $i ] = $year + $i; |
|
481 | + for ($i = 0; $i <= 10; $i++) { |
|
482 | + $years[$year + $i] = $year + $i; |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | ?> |
486 | - <div class="<?php echo esc_attr( $this->id );?>-cc-form getpaid-cc-form mt-1"> |
|
486 | + <div class="<?php echo esc_attr($this->id); ?>-cc-form getpaid-cc-form mt-1"> |
|
487 | 487 | |
488 | 488 | |
489 | 489 | <div class="getpaid-cc-card-inner"> |
@@ -492,14 +492,14 @@ discard block |
||
492 | 492 | <div class="col-12"> |
493 | 493 | |
494 | 494 | <div class="form-group"> |
495 | - <label for="<?php echo esc_attr( "$id_prefix-cc-number" ) ?>"><?php _e( 'Card number', 'invoicing' ); ?></label> |
|
495 | + <label for="<?php echo esc_attr("$id_prefix-cc-number") ?>"><?php _e('Card number', 'invoicing'); ?></label> |
|
496 | 496 | <div class="input-group input-group-sm"> |
497 | 497 | <div class="input-group-prepend "> |
498 | 498 | <span class="input-group-text"> |
499 | 499 | <i class="fa fa-credit-card"></i> |
500 | 500 | </span> |
501 | 501 | </div> |
502 | - <input type="text" name="<?php echo esc_attr( $this->id . '[cc_number]' ) ?>authorizenet[cc_number]" id="<?php echo esc_attr( "$id_prefix-cc-number" ) ?>" class="form-control form-control-sm"> |
|
502 | + <input type="text" name="<?php echo esc_attr($this->id . '[cc_number]') ?>authorizenet[cc_number]" id="<?php echo esc_attr("$id_prefix-cc-number") ?>" class="form-control form-control-sm"> |
|
503 | 503 | </div> |
504 | 504 | </div> |
505 | 505 | |
@@ -507,17 +507,17 @@ discard block |
||
507 | 507 | |
508 | 508 | <div class="col-12"> |
509 | 509 | <div class="form-group"> |
510 | - <label><?php _e( 'Expiration', 'invoicing' ); ?></label> |
|
510 | + <label><?php _e('Expiration', 'invoicing'); ?></label> |
|
511 | 511 | <div class="form-row"> |
512 | 512 | |
513 | 513 | <div class="col"> |
514 | - <select class="form-control form-control-sm" name="<?php echo esc_attr( $this->id );?>[cc_expire_month]"> |
|
515 | - <option disabled selected="selected"><?php _e( 'MM', 'invoicing' ); ?></option> |
|
514 | + <select class="form-control form-control-sm" name="<?php echo esc_attr($this->id); ?>[cc_expire_month]"> |
|
515 | + <option disabled selected="selected"><?php _e('MM', 'invoicing'); ?></option> |
|
516 | 516 | |
517 | 517 | <?php |
518 | - foreach ( $months as $key => $month ) { |
|
519 | - $key = esc_attr( $key ); |
|
520 | - $month = wpinv_clean( $month ); |
|
518 | + foreach ($months as $key => $month) { |
|
519 | + $key = esc_attr($key); |
|
520 | + $month = wpinv_clean($month); |
|
521 | 521 | echo "<option value='$key'>$month</option>" . PHP_EOL; |
522 | 522 | } |
523 | 523 | ?> |
@@ -526,13 +526,13 @@ discard block |
||
526 | 526 | </div> |
527 | 527 | |
528 | 528 | <div class="col"> |
529 | - <select class="form-control form-control-sm" name="<?php echo esc_attr( $this->id );?>[cc_expire_year]"> |
|
530 | - <option disabled selected="selected"><?php _e( 'YY', 'invoicing' ); ?></option> |
|
529 | + <select class="form-control form-control-sm" name="<?php echo esc_attr($this->id); ?>[cc_expire_year]"> |
|
530 | + <option disabled selected="selected"><?php _e('YY', 'invoicing'); ?></option> |
|
531 | 531 | |
532 | 532 | <?php |
533 | - foreach ( $years as $key => $year ) { |
|
534 | - $key = esc_attr( $key ); |
|
535 | - $year = wpinv_clean( $year ); |
|
533 | + foreach ($years as $key => $year) { |
|
534 | + $key = esc_attr($key); |
|
535 | + $year = wpinv_clean($year); |
|
536 | 536 | echo "<option value='$key'>$year</option>" . PHP_EOL; |
537 | 537 | } |
538 | 538 | ?> |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | array( |
551 | 551 | 'name' => $this->id . '[cc_cvv2]', |
552 | 552 | 'id' => "$id_prefix-cc-cvv2", |
553 | - 'label' => __( 'CCV', 'invoicing' ), |
|
553 | + 'label' => __('CCV', 'invoicing'), |
|
554 | 554 | 'label_type' => 'vertical', |
555 | 555 | 'class' => 'form-control-sm', |
556 | 556 | ) |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | |
563 | 563 | <?php |
564 | 564 | |
565 | - if ( $save ) { |
|
565 | + if ($save) { |
|
566 | 566 | echo $this->save_payment_method_checkbox(); |
567 | 567 | } |
568 | 568 | |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | * |
582 | 582 | * @since 1.0.19 |
583 | 583 | */ |
584 | - public function new_payment_method_entry( $form ) { |
|
584 | + public function new_payment_method_entry($form) { |
|
585 | 585 | echo "<div class='getpaid-new-payment-method-form' style='display:none;'>$form</div>"; |
586 | 586 | } |
587 | 587 | |
@@ -591,16 +591,16 @@ discard block |
||
591 | 591 | * @since 1.0.19 |
592 | 592 | */ |
593 | 593 | public function saved_payment_methods() { |
594 | - $html = '<ul class="getpaid-saved-payment-methods m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">'; |
|
594 | + $html = '<ul class="getpaid-saved-payment-methods m-0 mt-2" data-count="' . esc_attr(count($this->get_tokens($this->is_sandbox()))) . '">'; |
|
595 | 595 | |
596 | - foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) { |
|
597 | - $html .= $this->get_saved_payment_method_option_html( $token ); |
|
596 | + foreach ($this->get_tokens($this->is_sandbox()) as $token) { |
|
597 | + $html .= $this->get_saved_payment_method_option_html($token); |
|
598 | 598 | } |
599 | 599 | |
600 | 600 | $html .= $this->get_new_payment_method_option_html(); |
601 | 601 | $html .= '</ul>'; |
602 | 602 | |
603 | - echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this ); |
|
603 | + echo apply_filters('getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this); |
|
604 | 604 | } |
605 | 605 | |
606 | 606 | /** |
@@ -610,7 +610,7 @@ discard block |
||
610 | 610 | * @param array $token Payment Token. |
611 | 611 | * @return string Generated payment method HTML |
612 | 612 | */ |
613 | - public function get_saved_payment_method_option_html( $token ) { |
|
613 | + public function get_saved_payment_method_option_html($token) { |
|
614 | 614 | |
615 | 615 | return sprintf( |
616 | 616 | '<li class="getpaid-payment-method form-group"> |
@@ -619,10 +619,10 @@ discard block |
||
619 | 619 | <span>%3$s</span> |
620 | 620 | </label> |
621 | 621 | </li>', |
622 | - esc_attr( $this->id ), |
|
623 | - esc_attr( $token['id'] ), |
|
624 | - esc_html( $token['name'] ), |
|
625 | - checked( empty( $token['default'] ), false, false ) |
|
622 | + esc_attr($this->id), |
|
623 | + esc_attr($token['id']), |
|
624 | + esc_html($token['name']), |
|
625 | + checked(empty($token['default']), false, false) |
|
626 | 626 | ); |
627 | 627 | |
628 | 628 | } |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | */ |
635 | 635 | public function get_new_payment_method_option_html() { |
636 | 636 | |
637 | - $label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this ); |
|
637 | + $label = apply_filters('getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __('Use a new payment method', 'invoicing'), $this); |
|
638 | 638 | |
639 | 639 | return sprintf( |
640 | 640 | '<li class="getpaid-new-payment-method"> |
@@ -643,8 +643,8 @@ discard block |
||
643 | 643 | <span>%2$s</span> |
644 | 644 | </label> |
645 | 645 | </li>', |
646 | - esc_attr( $this->id ), |
|
647 | - esc_html( $label ) |
|
646 | + esc_attr($this->id), |
|
647 | + esc_html($label) |
|
648 | 648 | ); |
649 | 649 | |
650 | 650 | } |
@@ -663,8 +663,8 @@ discard block |
||
663 | 663 | <span>%2$s</span> |
664 | 664 | </label> |
665 | 665 | </p>', |
666 | - esc_attr( $this->id ), |
|
667 | - esc_html__( 'Save payment method', 'invoicing' ) |
|
666 | + esc_attr($this->id), |
|
667 | + esc_html__('Save payment method', 'invoicing') |
|
668 | 668 | ); |
669 | 669 | |
670 | 670 | } |
@@ -674,9 +674,9 @@ discard block |
||
674 | 674 | * |
675 | 675 | * @return array |
676 | 676 | */ |
677 | - public function register_gateway( $gateways ) { |
|
677 | + public function register_gateway($gateways) { |
|
678 | 678 | |
679 | - $gateways[ $this->id ] = array( |
|
679 | + $gateways[$this->id] = array( |
|
680 | 680 | |
681 | 681 | 'admin_label' => $this->method_title, |
682 | 682 | 'checkout_label' => $this->title, |
@@ -694,13 +694,13 @@ discard block |
||
694 | 694 | * @param WPInv_Invoice|null $invoice Invoice object or null. |
695 | 695 | * @return bool |
696 | 696 | */ |
697 | - public function is_sandbox( $invoice = null ) { |
|
697 | + public function is_sandbox($invoice = null) { |
|
698 | 698 | |
699 | - if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) { |
|
699 | + if (!empty($invoice) && !$invoice->needs_payment()) { |
|
700 | 700 | return $invoice->get_mode() == 'test'; |
701 | 701 | } |
702 | 702 | |
703 | - return wpinv_is_test_mode( $this->id ); |
|
703 | + return wpinv_is_test_mode($this->id); |
|
704 | 704 | |
705 | 705 | } |
706 | 706 | |
@@ -718,15 +718,15 @@ discard block |
||
718 | 718 | * |
719 | 719 | * @return bool |
720 | 720 | */ |
721 | - public function validate_currency( $validation, $currency ) { |
|
721 | + public function validate_currency($validation, $currency) { |
|
722 | 722 | |
723 | 723 | // Required currencies. |
724 | - if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) { |
|
724 | + if (!empty($this->currencies) && !in_array($currency, $this->currencies)) { |
|
725 | 725 | return false; |
726 | 726 | } |
727 | 727 | |
728 | 728 | // Excluded currencies. |
729 | - if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) { |
|
729 | + if (!empty($this->exclude_currencies) && in_array($currency, $this->exclude_currencies)) { |
|
730 | 730 | return false; |
731 | 731 | } |
732 | 732 |
@@ -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 | * @deprecated |
@@ -19,48 +19,48 @@ discard block |
||
19 | 19 | * @deprecated |
20 | 20 | */ |
21 | 21 | function wpinv_get_invoice_cart() { |
22 | - return wpinv_get_invoice( getpaid_get_current_invoice_id() ); |
|
22 | + return wpinv_get_invoice(getpaid_get_current_invoice_id()); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
26 | 26 | * @deprecated |
27 | 27 | */ |
28 | -function wpinv_get_invoice_description( $invoice ) { |
|
29 | - $invoice = new WPInv_Invoice( $invoice ); |
|
28 | +function wpinv_get_invoice_description($invoice) { |
|
29 | + $invoice = new WPInv_Invoice($invoice); |
|
30 | 30 | return $invoice->get_description(); |
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
34 | 34 | * @deprecated |
35 | 35 | */ |
36 | -function wpinv_get_invoice_currency_code( $invoice ) { |
|
37 | - $invoice = new WPInv_Invoice( $invoice ); |
|
36 | +function wpinv_get_invoice_currency_code($invoice) { |
|
37 | + $invoice = new WPInv_Invoice($invoice); |
|
38 | 38 | return $invoice->get_currency(); |
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
42 | 42 | * @deprecated |
43 | 43 | */ |
44 | -function wpinv_get_payment_user_email( $invoice ) { |
|
45 | - $invoice = new WPInv_Invoice( $invoice ); |
|
44 | +function wpinv_get_payment_user_email($invoice) { |
|
45 | + $invoice = new WPInv_Invoice($invoice); |
|
46 | 46 | return $invoice->get_email(); |
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
50 | 50 | * @deprecated |
51 | 51 | */ |
52 | -function wpinv_get_user_id( $invoice ) { |
|
53 | - $invoice = new WPInv_Invoice( $invoice ); |
|
52 | +function wpinv_get_user_id($invoice) { |
|
53 | + $invoice = new WPInv_Invoice($invoice); |
|
54 | 54 | return $invoice->get_user_id(); |
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
58 | 58 | * @deprecated |
59 | 59 | */ |
60 | -function wpinv_get_invoice_status( $invoice, $return_label = false ) { |
|
61 | - $invoice = new WPInv_Invoice( $invoice ); |
|
60 | +function wpinv_get_invoice_status($invoice, $return_label = false) { |
|
61 | + $invoice = new WPInv_Invoice($invoice); |
|
62 | 62 | |
63 | - if ( $return_label ) { |
|
63 | + if ($return_label) { |
|
64 | 64 | return $invoice->get_status_nicename(); |
65 | 65 | } |
66 | 66 | |
@@ -70,10 +70,10 @@ discard block |
||
70 | 70 | /** |
71 | 71 | * @deprecated |
72 | 72 | */ |
73 | -function wpinv_get_payment_gateway( $invoice, $return_label = false ) { |
|
74 | - $invoice = new WPInv_Invoice( $invoice ); |
|
73 | +function wpinv_get_payment_gateway($invoice, $return_label = false) { |
|
74 | + $invoice = new WPInv_Invoice($invoice); |
|
75 | 75 | |
76 | - if ( $return_label ) { |
|
76 | + if ($return_label) { |
|
77 | 77 | return $invoice->get_gateway_title(); |
78 | 78 | } |
79 | 79 | |
@@ -83,75 +83,75 @@ discard block |
||
83 | 83 | /** |
84 | 84 | * @deprecated |
85 | 85 | */ |
86 | -function wpinv_get_payment_gateway_name( $invoice ) { |
|
87 | - return wpinv_get_payment_gateway( $invoice, true ); |
|
86 | +function wpinv_get_payment_gateway_name($invoice) { |
|
87 | + return wpinv_get_payment_gateway($invoice, true); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
91 | 91 | * @deprecated |
92 | 92 | */ |
93 | -function wpinv_get_payment_transaction_id( $invoice ) { |
|
94 | - $invoice = new WPInv_Invoice( $invoice ); |
|
93 | +function wpinv_get_payment_transaction_id($invoice) { |
|
94 | + $invoice = new WPInv_Invoice($invoice); |
|
95 | 95 | return $invoice->get_transaction_id(); |
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
99 | 99 | * @deprecated |
100 | 100 | */ |
101 | -function wpinv_get_invoice_meta( $invoice_id = 0, $meta_key = '_wpinv_payment_meta', $single = true ) { |
|
102 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
103 | - return $invoice->get_meta( $meta_key, $single ); |
|
101 | +function wpinv_get_invoice_meta($invoice_id = 0, $meta_key = '_wpinv_payment_meta', $single = true) { |
|
102 | + $invoice = new WPInv_Invoice($invoice_id); |
|
103 | + return $invoice->get_meta($meta_key, $single); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
107 | 107 | * @deprecated |
108 | 108 | */ |
109 | -function wpinv_update_invoice_meta( $invoice_id = 0, $meta_key = '', $meta_value = '' ) { |
|
110 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
111 | - return $invoice->update_meta_data( $meta_key, $meta_value ); |
|
109 | +function wpinv_update_invoice_meta($invoice_id = 0, $meta_key = '', $meta_value = '') { |
|
110 | + $invoice = new WPInv_Invoice($invoice_id); |
|
111 | + return $invoice->update_meta_data($meta_key, $meta_value); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
115 | 115 | * @deprecated |
116 | 116 | */ |
117 | -function wpinv_get_items( $invoice = 0 ) { |
|
118 | - $invoice = new WPInv_Invoice( $invoice ); |
|
117 | +function wpinv_get_items($invoice = 0) { |
|
118 | + $invoice = new WPInv_Invoice($invoice); |
|
119 | 119 | return $invoice->get_items(); |
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
123 | 123 | * @deprecated |
124 | 124 | */ |
125 | -function wpinv_get_fees( $invoice = 0 ) { |
|
126 | - $invoice = new WPInv_Invoice( $invoice ); |
|
125 | +function wpinv_get_fees($invoice = 0) { |
|
126 | + $invoice = new WPInv_Invoice($invoice); |
|
127 | 127 | return $invoice->get_fees(); |
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
131 | 131 | * @deprecated |
132 | 132 | */ |
133 | -function wpinv_get_invoice_ip( $invoice ) { |
|
134 | - $invoice = new WPInv_Invoice( $invoice ); |
|
133 | +function wpinv_get_invoice_ip($invoice) { |
|
134 | + $invoice = new WPInv_Invoice($invoice); |
|
135 | 135 | return $invoice->get_ip(); |
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
139 | 139 | * @deprecated |
140 | 140 | */ |
141 | -function wpinv_get_invoice_user_info( $invoice ) { |
|
142 | - $invoice = new WPInv_Invoice( $invoice ); |
|
141 | +function wpinv_get_invoice_user_info($invoice) { |
|
142 | + $invoice = new WPInv_Invoice($invoice); |
|
143 | 143 | return $invoice->get_user_info(); |
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
147 | 147 | * @deprecated |
148 | 148 | */ |
149 | -function wpinv_subtotal( $invoice = 0, $currency = false ) { |
|
150 | - $invoice = new WPInv_Invoice( $invoice ); |
|
149 | +function wpinv_subtotal($invoice = 0, $currency = false) { |
|
150 | + $invoice = new WPInv_Invoice($invoice); |
|
151 | 151 | $subtotal = $invoice->get_subtotal(); |
152 | 152 | |
153 | - if ( $currency ) { |
|
154 | - return wpinv_price( wpinv_format_amount( $subtotal ), $invoice->get_currency() ); |
|
153 | + if ($currency) { |
|
154 | + return wpinv_price(wpinv_format_amount($subtotal), $invoice->get_currency()); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | return $subtotal; |
@@ -160,12 +160,12 @@ discard block |
||
160 | 160 | /** |
161 | 161 | * @deprecated |
162 | 162 | */ |
163 | -function wpinv_tax( $invoice = 0, $currency = false ) { |
|
164 | - $invoice = new WPInv_Invoice( $invoice ); |
|
163 | +function wpinv_tax($invoice = 0, $currency = false) { |
|
164 | + $invoice = new WPInv_Invoice($invoice); |
|
165 | 165 | $tax = $invoice->get_total_tax(); |
166 | 166 | |
167 | - if ( $currency ) { |
|
168 | - return wpinv_price( wpinv_format_amount( $tax ), $invoice->get_currency() ); |
|
167 | + if ($currency) { |
|
168 | + return wpinv_price(wpinv_format_amount($tax), $invoice->get_currency()); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | return $tax; |
@@ -174,12 +174,12 @@ discard block |
||
174 | 174 | /** |
175 | 175 | * @deprecated |
176 | 176 | */ |
177 | -function wpinv_discount( $invoice = 0, $currency = false, $deprecated ) { |
|
178 | - $invoice = new WPInv_Invoice( $invoice ); |
|
177 | +function wpinv_discount($invoice = 0, $currency = false, $deprecated) { |
|
178 | + $invoice = new WPInv_Invoice($invoice); |
|
179 | 179 | $discount = $invoice->get_total_discount(); |
180 | 180 | |
181 | - if ( $currency ) { |
|
182 | - return wpinv_price( wpinv_format_amount( $discount ), $invoice->get_currency() ); |
|
181 | + if ($currency) { |
|
182 | + return wpinv_price(wpinv_format_amount($discount), $invoice->get_currency()); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | return $discount; |
@@ -188,20 +188,20 @@ discard block |
||
188 | 188 | /** |
189 | 189 | * @deprecated |
190 | 190 | */ |
191 | -function wpinv_discount_code( $invoice = 0 ) { |
|
192 | - $invoice = new WPInv_Invoice( $invoice ); |
|
191 | +function wpinv_discount_code($invoice = 0) { |
|
192 | + $invoice = new WPInv_Invoice($invoice); |
|
193 | 193 | return $invoice->get_discount_code(); |
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
197 | 197 | * @deprecated |
198 | 198 | */ |
199 | -function wpinv_payment_total( $invoice = 0, $currency = false ) { |
|
200 | - $invoice = new WPInv_Invoice( $invoice ); |
|
199 | +function wpinv_payment_total($invoice = 0, $currency = false) { |
|
200 | + $invoice = new WPInv_Invoice($invoice); |
|
201 | 201 | $total = $invoice->get_total(); |
202 | 202 | |
203 | - if ( $currency ) { |
|
204 | - return wpinv_price( wpinv_format_amount( $total ), $invoice->get_currency() ); |
|
203 | + if ($currency) { |
|
204 | + return wpinv_price(wpinv_format_amount($total), $invoice->get_currency()); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | return $total; |
@@ -210,51 +210,51 @@ discard block |
||
210 | 210 | /** |
211 | 211 | * @deprecated |
212 | 212 | */ |
213 | -function wpinv_get_date_created( $invoice = 0, $format = '' ) { |
|
214 | - $invoice = new WPInv_Invoice( $invoice ); |
|
213 | +function wpinv_get_date_created($invoice = 0, $format = '') { |
|
214 | + $invoice = new WPInv_Invoice($invoice); |
|
215 | 215 | |
216 | - $format = ! empty( $format ) ? $format : get_option( 'date_format' ); |
|
216 | + $format = !empty($format) ? $format : get_option('date_format'); |
|
217 | 217 | $date_created = $invoice->get_created_date(); |
218 | 218 | |
219 | - return empty( $date_created ) ? date_i18n( $format, strtotime( $date_created ) ) : ''; |
|
219 | + return empty($date_created) ? date_i18n($format, strtotime($date_created)) : ''; |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
223 | 223 | * @deprecated |
224 | 224 | */ |
225 | -function wpinv_get_invoice_date( $invoice = 0, $format = '' ) { |
|
226 | - wpinv_get_date_created( $invoice, $format ); |
|
225 | +function wpinv_get_invoice_date($invoice = 0, $format = '') { |
|
226 | + wpinv_get_date_created($invoice, $format); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
230 | 230 | * @deprecated |
231 | 231 | */ |
232 | -function wpinv_get_invoice_vat_number( $invoice = 0 ) { |
|
233 | - $invoice = new WPInv_Invoice( $invoice ); |
|
232 | +function wpinv_get_invoice_vat_number($invoice = 0) { |
|
233 | + $invoice = new WPInv_Invoice($invoice); |
|
234 | 234 | return $invoice->get_vat_number(); |
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
238 | 238 | * @deprecated |
239 | 239 | */ |
240 | -function wpinv_insert_payment_note( $invoice = 0, $note = '', $user_type = false, $added_by_user = false, $system = false ) { |
|
241 | - $invoice = new WPInv_Invoice( $invoice ); |
|
242 | - return $invoice->add_note( $note, $user_type, $added_by_user, $system ); |
|
240 | +function wpinv_insert_payment_note($invoice = 0, $note = '', $user_type = false, $added_by_user = false, $system = false) { |
|
241 | + $invoice = new WPInv_Invoice($invoice); |
|
242 | + return $invoice->add_note($note, $user_type, $added_by_user, $system); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | /** |
246 | 246 | * @deprecated |
247 | 247 | */ |
248 | -function wpinv_get_payment_key( $invoice = 0 ) { |
|
249 | - $invoice = new WPInv_Invoice( $invoice ); |
|
248 | +function wpinv_get_payment_key($invoice = 0) { |
|
249 | + $invoice = new WPInv_Invoice($invoice); |
|
250 | 250 | return $invoice->get_key(); |
251 | 251 | } |
252 | 252 | |
253 | 253 | /** |
254 | 254 | * @deprecated |
255 | 255 | */ |
256 | -function wpinv_get_invoice_number( $invoice = 0 ) { |
|
257 | - $invoice = new WPInv_Invoice( $invoice ); |
|
256 | +function wpinv_get_invoice_number($invoice = 0) { |
|
257 | + $invoice = new WPInv_Invoice($invoice); |
|
258 | 258 | return $invoice->get_number(); |
259 | 259 | } |
260 | 260 | |
@@ -401,9 +401,9 @@ discard block |
||
401 | 401 | /** |
402 | 402 | * @deprecated |
403 | 403 | */ |
404 | -function wpinv_update_payment_status( $invoice, $new_status = 'publish' ) { |
|
405 | - $invoice = new WPInv_Invoice( $invoice ); |
|
406 | - return $invoice->update_status( $new_status ); |
|
404 | +function wpinv_update_payment_status($invoice, $new_status = 'publish') { |
|
405 | + $invoice = new WPInv_Invoice($invoice); |
|
406 | + return $invoice->update_status($new_status); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | /** |
@@ -456,22 +456,22 @@ discard block |
||
456 | 456 | /** |
457 | 457 | * @deprecated |
458 | 458 | */ |
459 | -function wpinv_set_payment_transaction_id( $invoice_id = 0, $transaction_id = '' ) { |
|
459 | +function wpinv_set_payment_transaction_id($invoice_id = 0, $transaction_id = '') { |
|
460 | 460 | |
461 | 461 | // Fetch the invoice. |
462 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
462 | + $invoice = new WPInv_Invoice($invoice_id); |
|
463 | 463 | |
464 | - if ( 0 == $invoice->get_id() ) { |
|
464 | + if (0 == $invoice->get_id()) { |
|
465 | 465 | return false; |
466 | 466 | } |
467 | 467 | |
468 | 468 | // Prepare the transaction id. |
469 | - if ( empty( $transaction_id ) ) { |
|
469 | + if (empty($transaction_id)) { |
|
470 | 470 | $transaction_id = $invoice_id; |
471 | 471 | } |
472 | 472 | |
473 | 473 | // Set the transaction id; |
474 | - $invoice->set_transaction_id( apply_filters( 'wpinv_set_payment_transaction_id', $transaction_id, $invoice ) ); |
|
474 | + $invoice->set_transaction_id(apply_filters('wpinv_set_payment_transaction_id', $transaction_id, $invoice)); |
|
475 | 475 | |
476 | 476 | // Save the invoice. |
477 | 477 | return $invoice->save(); |
@@ -484,12 +484,12 @@ discard block |
||
484 | 484 | * @param WPInv_Invoice $invoice |
485 | 485 | * @param string $gateway |
486 | 486 | */ |
487 | -function wpinv_send_to_gateway( $gateway, $invoice ) { |
|
487 | +function wpinv_send_to_gateway($gateway, $invoice) { |
|
488 | 488 | |
489 | 489 | $payment_data = array( |
490 | 490 | 'invoice_id' => $invoice->get_id(), |
491 | 491 | 'items' => $invoice->get_cart_details(), |
492 | - 'cart_discounts' => array( $invoice->get_discount_code() ), |
|
492 | + 'cart_discounts' => array($invoice->get_discount_code()), |
|
493 | 493 | 'fees' => $invoice->get_total_fees(), |
494 | 494 | 'subtotal' => $invoice->get_subtotal(), |
495 | 495 | 'discount' => $invoice->get_total_discount(), |
@@ -497,16 +497,16 @@ discard block |
||
497 | 497 | 'price' => $invoice->get_total(), |
498 | 498 | 'invoice_key' => $invoice->get_key(), |
499 | 499 | 'user_email' => $invoice->get_email(), |
500 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), |
|
500 | + 'date' => date('Y-m-d H:i:s', current_time('timestamp')), |
|
501 | 501 | 'user_info' => $invoice->get_user_info(), |
502 | - 'post_data' => stripslashes_deep( $_POST ), |
|
502 | + 'post_data' => stripslashes_deep($_POST), |
|
503 | 503 | 'cart_details' => $invoice->get_cart_details(), |
504 | 504 | 'gateway' => $gateway, |
505 | 505 | 'card_info' => array(), |
506 | 506 | 'gateway_nonce' => wp_create_nonce('wpi-gateway'), |
507 | 507 | ); |
508 | 508 | |
509 | - do_action( 'wpinv_gateway_' . $gateway, $payment_data ); |
|
509 | + do_action('wpinv_gateway_' . $gateway, $payment_data); |
|
510 | 510 | } |
511 | 511 | |
512 | 512 | /** |
@@ -519,10 +519,10 @@ discard block |
||
519 | 519 | /** |
520 | 520 | * @deprecated |
521 | 521 | */ |
522 | -function wpinv_die( $message = '', $title = '', $status = 400 ) { |
|
523 | - add_filter( 'wp_die_ajax_handler', 'wpinv_die_handler', 10, 3 ); |
|
524 | - add_filter( 'wp_die_handler', 'wpinv_die_handler', 10, 3 ); |
|
525 | - wp_die( $message, $title, array( 'response' => $status )); |
|
522 | +function wpinv_die($message = '', $title = '', $status = 400) { |
|
523 | + add_filter('wp_die_ajax_handler', 'wpinv_die_handler', 10, 3); |
|
524 | + add_filter('wp_die_handler', 'wpinv_die_handler', 10, 3); |
|
525 | + wp_die($message, $title, array('response' => $status)); |
|
526 | 526 | } |
527 | 527 | |
528 | 528 | /** |
@@ -640,14 +640,14 @@ discard block |
||
640 | 640 | /** |
641 | 641 | * @deprecated |
642 | 642 | */ |
643 | -function wpinv_invoice_status_label( $status, $status_display = '' ) { |
|
644 | - return empty( $status_display ) ? sanitize_text_field( $status ) : sanitize_text_field( $status_display ); |
|
643 | +function wpinv_invoice_status_label($status, $status_display = '') { |
|
644 | + return empty($status_display) ? sanitize_text_field($status) : sanitize_text_field($status_display); |
|
645 | 645 | } |
646 | 646 | |
647 | 647 | /** |
648 | 648 | * @deprecated |
649 | 649 | */ |
650 | -function wpinv_clean_invoice_number( $number ) { |
|
650 | +function wpinv_clean_invoice_number($number) { |
|
651 | 651 | return $number; |
652 | 652 | } |
653 | 653 | |
@@ -852,12 +852,12 @@ discard block |
||
852 | 852 | /** |
853 | 853 | * @deprecated |
854 | 854 | */ |
855 | -function wpinv_item_show_price( $item_id = 0, $echo = true ) { |
|
855 | +function wpinv_item_show_price($item_id = 0, $echo = true) { |
|
856 | 856 | |
857 | - if ( $echo ) { |
|
858 | - echo wpinv_item_price( $item_id ); |
|
857 | + if ($echo) { |
|
858 | + echo wpinv_item_price($item_id); |
|
859 | 859 | } else { |
860 | - return wpinv_item_price( $item_id ); |
|
860 | + return wpinv_item_price($item_id); |
|
861 | 861 | } |
862 | 862 | |
863 | 863 | } |
@@ -8,18 +8,18 @@ |
||
8 | 8 | * @var WPInv_Subscription $object |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | 13 | $invoice = $object->get_parent_payment(); |
14 | 14 | |
15 | 15 | // Print the email header. |
16 | -do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
|
16 | +do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin); |
|
17 | 17 | |
18 | 18 | // Generate the custom message body. |
19 | 19 | echo $message_body; |
20 | 20 | |
21 | 21 | // Print the billing details. |
22 | -do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin ); |
|
22 | +do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin); |
|
23 | 23 | |
24 | 24 | // Print the email footer. |
25 | -do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin ); |
|
25 | +do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin); |