@@ -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,30 +11,30 @@ 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 | |
19 | 19 | $options = wpinv_get_options(); |
20 | 20 | $gateways = array(); |
21 | - foreach ( $all_gateways as $key => $gateway ) { |
|
22 | - if ( !empty( $options[$key . '_title'] ) ) { |
|
23 | - $all_gateways[$key]['checkout_label'] = __( $options[$key . '_title'], 'invoicing' ); |
|
21 | + foreach ($all_gateways as $key => $gateway) { |
|
22 | + if (!empty($options[$key . '_title'])) { |
|
23 | + $all_gateways[$key]['checkout_label'] = __($options[$key . '_title'], 'invoicing'); |
|
24 | 24 | } |
25 | 25 | |
26 | - $gateways[$key] = isset( $options[$key . '_ordering'] ) ? $options[$key . '_ordering'] : ( isset( $gateway['ordering'] ) ? $gateway['ordering'] : '' ); |
|
26 | + $gateways[$key] = isset($options[$key . '_ordering']) ? $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 | 39 | /** |
40 | 40 | * Returns an array of enabled gateways. |
@@ -42,38 +42,38 @@ discard block |
||
42 | 42 | * @param bool $sort |
43 | 43 | * @return array |
44 | 44 | */ |
45 | -function wpinv_get_enabled_payment_gateways( $sort = false ) { |
|
45 | +function wpinv_get_enabled_payment_gateways($sort = false) { |
|
46 | 46 | |
47 | 47 | $enabled = array(); |
48 | 48 | |
49 | - foreach ( wpinv_get_payment_gateways() as $gateway => $data ) { |
|
49 | + foreach (wpinv_get_payment_gateways() as $gateway => $data) { |
|
50 | 50 | |
51 | - if ( (int) wpinv_get_option( "{$gateway}_active", $gateway === 'manual' ) === 1 ) { |
|
52 | - $enabled[ $gateway ] = $data; |
|
51 | + if ((int) wpinv_get_option("{$gateway}_active", $gateway === 'manual') === 1) { |
|
52 | + $enabled[$gateway] = $data; |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | } |
56 | 56 | |
57 | - if ( true === $sort ) { |
|
58 | - uasort( $enabled, 'wpinv_sort_gateway_order' ); |
|
57 | + if (true === $sort) { |
|
58 | + uasort($enabled, 'wpinv_sort_gateway_order'); |
|
59 | 59 | |
60 | 60 | // Reorder our gateways so the default is first |
61 | 61 | $default_gateway_id = wpinv_get_default_gateway(); |
62 | - if ( isset( $enabled[ $default_gateway_id ] ) ) { |
|
62 | + if (isset($enabled[$default_gateway_id])) { |
|
63 | 63 | $default_gateway = array( |
64 | - $default_gateway_id => $enabled[ $default_gateway_id ] |
|
64 | + $default_gateway_id => $enabled[$default_gateway_id] |
|
65 | 65 | ); |
66 | 66 | |
67 | - unset( $enabled[ $default_gateway_id ] ); |
|
68 | - $enabled = array_merge( $default_gateway, $enabled ); |
|
67 | + unset($enabled[$default_gateway_id]); |
|
68 | + $enabled = array_merge($default_gateway, $enabled); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | } |
72 | 72 | |
73 | - return apply_filters( 'wpinv_enabled_payment_gateways', $enabled ); |
|
73 | + return apply_filters('wpinv_enabled_payment_gateways', $enabled); |
|
74 | 74 | } |
75 | 75 | |
76 | -function wpinv_sort_gateway_order( $a, $b ) { |
|
76 | +function wpinv_sort_gateway_order($a, $b) { |
|
77 | 77 | return $a['ordering'] - $b['ordering']; |
78 | 78 | } |
79 | 79 | |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | * @param string $gateway |
84 | 84 | * @return bool |
85 | 85 | */ |
86 | -function wpinv_is_gateway_active( $gateway ) { |
|
87 | - $is_active = (int) wpinv_get_option( "{$gateway}_active", $gateway === 'manual' ) === 1 ; |
|
88 | - return apply_filters( 'wpinv_is_gateway_active', $is_active, $gateway ); |
|
86 | +function wpinv_is_gateway_active($gateway) { |
|
87 | + $is_active = (int) wpinv_get_option("{$gateway}_active", $gateway === 'manual') === 1; |
|
88 | + return apply_filters('wpinv_is_gateway_active', $is_active, $gateway); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -94,11 +94,11 @@ discard block |
||
94 | 94 | * @return string|false |
95 | 95 | */ |
96 | 96 | function wpinv_get_default_gateway() { |
97 | - $default = wpinv_get_option( 'default_gateway' ); |
|
97 | + $default = wpinv_get_option('default_gateway'); |
|
98 | 98 | $gateways = wpinv_get_enabled_payment_gateways(); |
99 | - $default = ! empty( $default ) && isset( $gateways[ $default ] ) ? $default : false; |
|
99 | + $default = !empty($default) && isset($gateways[$default]) ? $default : false; |
|
100 | 100 | |
101 | - return apply_filters( 'wpinv_default_gateway', $default ); |
|
101 | + return apply_filters('wpinv_default_gateway', $default); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -107,17 +107,17 @@ discard block |
||
107 | 107 | * @param string $gateway The gateway to key. |
108 | 108 | * @return string |
109 | 109 | */ |
110 | -function wpinv_get_gateway_admin_label( $gateway ) { |
|
110 | +function wpinv_get_gateway_admin_label($gateway) { |
|
111 | 111 | |
112 | - if ( empty( $gateway ) || 'none' == $gateway ) { |
|
113 | - return esc_html__( 'No Gateway', 'invoicing' ); |
|
112 | + if (empty($gateway) || 'none' == $gateway) { |
|
113 | + return esc_html__('No Gateway', 'invoicing'); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | $gateways = wpinv_get_payment_gateways(); |
117 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway; |
|
118 | - $gateway = apply_filters( 'wpinv_gateway_admin_label', $label, $gateway ); |
|
117 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway; |
|
118 | + $gateway = apply_filters('wpinv_gateway_admin_label', $label, $gateway); |
|
119 | 119 | |
120 | - return wpinv_clean( $gateway ); |
|
120 | + return wpinv_clean($gateway); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -125,48 +125,48 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @param string $gateway |
127 | 127 | */ |
128 | -function wpinv_get_gateway_description( $gateway ) { |
|
128 | +function wpinv_get_gateway_description($gateway) { |
|
129 | 129 | |
130 | 130 | $options = wpinv_get_options(); |
131 | - $description = ! empty( $options[$gateway . '_desc'] ) ? $options[$gateway . '_desc'] : ''; |
|
131 | + $description = !empty($options[$gateway . '_desc']) ? $options[$gateway . '_desc'] : ''; |
|
132 | 132 | |
133 | - return apply_filters( 'wpinv_gateway_description', $description, $gateway ); |
|
133 | + return apply_filters('wpinv_gateway_description', $description, $gateway); |
|
134 | 134 | } |
135 | 135 | |
136 | -function wpinv_get_gateway_button_label( $gateway ) { |
|
137 | - return apply_filters( 'wpinv_gateway_' . $gateway . '_button_label', '' ); |
|
136 | +function wpinv_get_gateway_button_label($gateway) { |
|
137 | + return apply_filters('wpinv_gateway_' . $gateway . '_button_label', ''); |
|
138 | 138 | } |
139 | 139 | |
140 | -function wpinv_get_gateway_checkout_label( $gateway ) { |
|
140 | +function wpinv_get_gateway_checkout_label($gateway) { |
|
141 | 141 | $gateways = wpinv_get_payment_gateways(); |
142 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway; |
|
142 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway; |
|
143 | 143 | |
144 | - if ( $gateway == 'none' ) { |
|
145 | - $label = __( 'None', 'invoicing' ); |
|
144 | + if ($gateway == 'none') { |
|
145 | + $label = __('None', 'invoicing'); |
|
146 | 146 | } |
147 | 147 | |
148 | - return apply_filters( 'wpinv_gateway_checkout_label', ucfirst( $label ), $gateway ); |
|
148 | + return apply_filters('wpinv_gateway_checkout_label', ucfirst($label), $gateway); |
|
149 | 149 | } |
150 | 150 | |
151 | -function wpinv_settings_sections_gateways( $settings ) { |
|
151 | +function wpinv_settings_sections_gateways($settings) { |
|
152 | 152 | $gateways = wpinv_get_payment_gateways(); |
153 | - ksort( $gateways ); |
|
153 | + ksort($gateways); |
|
154 | 154 | |
155 | - foreach ( $gateways as $key => $gateway ) { |
|
156 | - $settings[ $key ] = $gateway['admin_label']; |
|
155 | + foreach ($gateways as $key => $gateway) { |
|
156 | + $settings[$key] = $gateway['admin_label']; |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | return $settings; |
160 | 160 | } |
161 | -add_filter( 'wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1 ); |
|
161 | +add_filter('wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1); |
|
162 | 162 | |
163 | 163 | /** |
164 | 164 | * Adds GateWay settings. |
165 | 165 | */ |
166 | -function wpinv_settings_gateways( $settings ) { |
|
166 | +function wpinv_settings_gateways($settings) { |
|
167 | 167 | |
168 | 168 | // Loop through each gateway. |
169 | - foreach ( wpinv_get_payment_gateways() as $key => $gateway ) { |
|
169 | + foreach (wpinv_get_payment_gateways() as $key => $gateway) { |
|
170 | 170 | |
171 | 171 | $gateway_settings = array( |
172 | 172 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | "{$key}_header" => array( |
175 | 175 | |
176 | 176 | 'id' => "{$key}_gateway_header", |
177 | - 'name' => '<h3>' . wp_sprintf( __( '%s Settings', 'invoicing' ), $gateway['admin_label'] ) . '</h3>', |
|
177 | + 'name' => '<h3>' . wp_sprintf(__('%s Settings', 'invoicing'), $gateway['admin_label']) . '</h3>', |
|
178 | 178 | 'custom' => $key, |
179 | 179 | 'type' => 'gateway_header', |
180 | 180 | |
@@ -183,8 +183,8 @@ discard block |
||
183 | 183 | // Activate/Deactivate a gateway. |
184 | 184 | "{$key}_active" => array( |
185 | 185 | 'id' => $key . '_active', |
186 | - 'name' => __( 'Activate', 'invoicing' ), |
|
187 | - 'desc' => wp_sprintf( __( 'Enable %s', 'invoicing' ), $gateway['admin_label'] ), |
|
186 | + 'name' => __('Activate', 'invoicing'), |
|
187 | + 'desc' => wp_sprintf(__('Enable %s', 'invoicing'), $gateway['admin_label']), |
|
188 | 188 | 'type' => 'checkbox', |
189 | 189 | 'std' => $key === 'manual' ? '1' : '0', |
190 | 190 | ), |
@@ -192,8 +192,8 @@ discard block |
||
192 | 192 | // Activate/Deactivate sandbox. |
193 | 193 | "{$key}_sandbox" => array( |
194 | 194 | 'id' => $key . '_sandbox', |
195 | - 'name' => __( 'Sandbox', 'invoicing' ), |
|
196 | - 'desc' => __( 'Enable sandbox to test payments', 'invoicing' ), |
|
195 | + 'name' => __('Sandbox', 'invoicing'), |
|
196 | + 'desc' => __('Enable sandbox to test payments', 'invoicing'), |
|
197 | 197 | 'type' => 'checkbox', |
198 | 198 | 'std' => '1', |
199 | 199 | ), |
@@ -201,40 +201,40 @@ discard block |
||
201 | 201 | // Checkout title. |
202 | 202 | "{$key}_title" => array( |
203 | 203 | 'id' => $key . '_title', |
204 | - 'name' => __( 'Checkout Title', 'invoicing' ), |
|
205 | - 'std' => isset( $gateway['checkout_label'] ) ? $gateway['checkout_label'] : '', |
|
204 | + 'name' => __('Checkout Title', 'invoicing'), |
|
205 | + 'std' => isset($gateway['checkout_label']) ? $gateway['checkout_label'] : '', |
|
206 | 206 | 'type' => 'text', |
207 | 207 | ), |
208 | 208 | |
209 | 209 | // Checkout description. |
210 | 210 | "{$key}_desc" => array( |
211 | 211 | 'id' => $key . '_desc', |
212 | - 'name' => __( 'Checkout Description', 'invoicing' ), |
|
213 | - 'std' => apply_filters( "getpaid_default_{$key}_checkout_description", '' ), |
|
212 | + 'name' => __('Checkout Description', 'invoicing'), |
|
213 | + 'std' => apply_filters("getpaid_default_{$key}_checkout_description", ''), |
|
214 | 214 | 'type' => 'text', |
215 | 215 | ), |
216 | 216 | |
217 | 217 | // Checkout order. |
218 | 218 | "{$key}_ordering" => array( |
219 | 219 | 'id' => $key . '_ordering', |
220 | - 'name' => __( 'Priority', 'invoicing' ), |
|
221 | - 'std' => apply_filters( "getpaid_default_{$key}_checkout_description", '' ), |
|
220 | + 'name' => __('Priority', 'invoicing'), |
|
221 | + 'std' => apply_filters("getpaid_default_{$key}_checkout_description", ''), |
|
222 | 222 | 'type' => 'number', |
223 | 223 | 'step' => '1', |
224 | 224 | 'min' => '0', |
225 | 225 | 'max' => '100000', |
226 | - 'std' => isset( $gateway['ordering'] ) ? $gateway['ordering'] : '10', |
|
226 | + 'std' => isset($gateway['ordering']) ? $gateway['ordering'] : '10', |
|
227 | 227 | ), |
228 | 228 | |
229 | 229 | ); |
230 | 230 | |
231 | 231 | // Maybe remove the sandbox. |
232 | - if ( ! getpaid_payment_gateway_supports( $key, 'sandbox' ) ) { |
|
233 | - unset( $gateway_settings["{$key}_sandbox"] ); |
|
232 | + if (!getpaid_payment_gateway_supports($key, 'sandbox')) { |
|
233 | + unset($gateway_settings["{$key}_sandbox"]); |
|
234 | 234 | } |
235 | 235 | |
236 | - $gateway_settings = apply_filters( 'wpinv_gateway_settings', $gateway_settings, $key, $gateway ); |
|
237 | - $gateway_settings = apply_filters( 'wpinv_gateway_settings_' . $key, $gateway_settings, $gateway ); |
|
236 | + $gateway_settings = apply_filters('wpinv_gateway_settings', $gateway_settings, $key, $gateway); |
|
237 | + $gateway_settings = apply_filters('wpinv_gateway_settings_' . $key, $gateway_settings, $gateway); |
|
238 | 238 | |
239 | 239 | $settings[$key] = $gateway_settings; |
240 | 240 | } |
@@ -242,10 +242,10 @@ discard block |
||
242 | 242 | return $settings; |
243 | 243 | |
244 | 244 | } |
245 | -add_filter( 'wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1 ); |
|
245 | +add_filter('wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1); |
|
246 | 246 | |
247 | -function wpinv_gateway_header_callback( $args ) { |
|
248 | - echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr( $args['custom'] ) . '" />'; |
|
247 | +function wpinv_gateway_header_callback($args) { |
|
248 | + echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr($args['custom']) . '" />'; |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | /** |
@@ -256,61 +256,61 @@ discard block |
||
256 | 256 | * @return bool |
257 | 257 | * @since 2.3.0 |
258 | 258 | */ |
259 | -function getpaid_payment_gateway_supports( $gateway, $feature ) { |
|
259 | +function getpaid_payment_gateway_supports($gateway, $feature) { |
|
260 | 260 | |
261 | 261 | $supports = false; |
262 | 262 | |
263 | - $supports = apply_filters( "getpaid_{$gateway}_supports_{$feature}", false ); |
|
263 | + $supports = apply_filters("getpaid_{$gateway}_supports_{$feature}", false); |
|
264 | 264 | |
265 | 265 | // Backwards compatibility. |
266 | - $supports = apply_filters( "wpinv_{$gateway}_supports_{$feature}", $supports ); |
|
267 | - $supports = apply_filters( "wpinv_{$gateway}_support_{$feature}", $supports ); |
|
266 | + $supports = apply_filters("wpinv_{$gateway}_supports_{$feature}", $supports); |
|
267 | + $supports = apply_filters("wpinv_{$gateway}_support_{$feature}", $supports); |
|
268 | 268 | |
269 | - $supports = apply_filters( "getpaid_gateway_supports_{$feature}", $supports, $gateway ); |
|
270 | - $supports = apply_filters( 'getpaid_payment_gateway_supports', $supports, $feature, $gateway ); |
|
269 | + $supports = apply_filters("getpaid_gateway_supports_{$feature}", $supports, $gateway); |
|
270 | + $supports = apply_filters('getpaid_payment_gateway_supports', $supports, $feature, $gateway); |
|
271 | 271 | |
272 | 272 | return $supports; |
273 | 273 | } |
274 | 274 | |
275 | -function wpinv_get_chosen_gateway( $invoice_id = 0 ) { |
|
276 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
275 | +function wpinv_get_chosen_gateway($invoice_id = 0) { |
|
276 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
277 | 277 | |
278 | 278 | $chosen = false; |
279 | - if ( $invoice_id > 0 && $invoice = wpinv_get_invoice( $invoice_id ) ) { |
|
279 | + if ($invoice_id > 0 && $invoice = wpinv_get_invoice($invoice_id)) { |
|
280 | 280 | $chosen = $invoice->get_gateway(); |
281 | 281 | } |
282 | 282 | |
283 | - $chosen = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen; |
|
283 | + $chosen = isset($_REQUEST['payment-mode']) ? sanitize_text_field($_REQUEST['payment-mode']) : $chosen; |
|
284 | 284 | |
285 | - if ( false !== $chosen ) { |
|
286 | - $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen ); |
|
285 | + if (false !== $chosen) { |
|
286 | + $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen); |
|
287 | 287 | } |
288 | 288 | |
289 | - if ( ! empty ( $chosen ) ) { |
|
290 | - $enabled_gateway = urldecode( $chosen ); |
|
291 | - } else if ( !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) { |
|
289 | + if (!empty ($chosen)) { |
|
290 | + $enabled_gateway = urldecode($chosen); |
|
291 | + } else if (!empty($invoice) && (float) $invoice->get_subtotal() <= 0) { |
|
292 | 292 | $enabled_gateway = 'manual'; |
293 | 293 | } else { |
294 | 294 | $enabled_gateway = wpinv_get_default_gateway(); |
295 | 295 | } |
296 | 296 | |
297 | - if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) { |
|
298 | - if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){ |
|
297 | + if (!wpinv_is_gateway_active($enabled_gateway) && !empty($gateways)) { |
|
298 | + if (wpinv_is_gateway_active(wpinv_get_default_gateway())) { |
|
299 | 299 | $enabled_gateway = wpinv_get_default_gateway(); |
300 | - }else{ |
|
300 | + } else { |
|
301 | 301 | $enabled_gateway = $gateways[0]; |
302 | 302 | } |
303 | 303 | |
304 | 304 | } |
305 | 305 | |
306 | - return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway ); |
|
306 | + return apply_filters('wpinv_chosen_gateway', $enabled_gateway); |
|
307 | 307 | } |
308 | 308 | |
309 | -function wpinv_record_gateway_error( $title = '', $message = '' ) { |
|
310 | - return wpinv_error_log( $message, $title ); |
|
309 | +function wpinv_record_gateway_error($title = '', $message = '') { |
|
310 | + return wpinv_error_log($message, $title); |
|
311 | 311 | } |
312 | 312 | |
313 | -function wpinv_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) { |
|
313 | +function wpinv_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') { |
|
314 | 314 | $ret = 0; |
315 | 315 | $args = array( |
316 | 316 | 'meta_key' => '_wpinv_gateway', |
@@ -321,9 +321,9 @@ discard block |
||
321 | 321 | 'fields' => 'ids' |
322 | 322 | ); |
323 | 323 | |
324 | - $payments = new WP_Query( $args ); |
|
324 | + $payments = new WP_Query($args); |
|
325 | 325 | |
326 | - if( $payments ) |
|
326 | + if ($payments) |
|
327 | 327 | $ret = $payments->post_count; |
328 | 328 | return $ret; |
329 | 329 | } |
@@ -331,13 +331,13 @@ discard block |
||
331 | 331 | /** |
332 | 332 | * Displays the ipn url field. |
333 | 333 | */ |
334 | -function wpinv_ipn_url_callback( $args ) { |
|
335 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
334 | +function wpinv_ipn_url_callback($args) { |
|
335 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
336 | 336 | |
337 | 337 | $attrs = $args['readonly'] ? ' readonly' : ''; |
338 | 338 | |
339 | - $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()">'; |
|
340 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>'; |
|
339 | + $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()">'; |
|
340 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>'; |
|
341 | 341 | |
342 | 342 | echo $html; |
343 | 343 | } |
@@ -349,10 +349,10 @@ discard block |
||
349 | 349 | * |
350 | 350 | * @return bool |
351 | 351 | */ |
352 | -function wpinv_is_test_mode( $gateway = '' ) { |
|
353 | - $sandbox = empty( $gateway ) ? false : wpinv_get_option( "{$gateway}_sandbox", true ); |
|
354 | - $supports = getpaid_payment_gateway_supports( $gateway, 'sandbox' ); |
|
355 | - return apply_filters( 'wpinv_is_test_mode', $sandbox && $supports, $gateway ); |
|
352 | +function wpinv_is_test_mode($gateway = '') { |
|
353 | + $sandbox = empty($gateway) ? false : wpinv_get_option("{$gateway}_sandbox", true); |
|
354 | + $supports = getpaid_payment_gateway_supports($gateway, 'sandbox'); |
|
355 | + return apply_filters('wpinv_is_test_mode', $sandbox && $supports, $gateway); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | /** |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | * |
364 | 364 | * @return string |
365 | 365 | */ |
366 | -function wpinv_get_ipn_url( $gateway = false, $args = array() ) { |
|
366 | +function wpinv_get_ipn_url($gateway = false, $args = array()) { |
|
367 | 367 | $args = wp_parse_args( |
368 | 368 | array( |
369 | 369 | 'wpi-listener' => 'IPN', |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | $args |
373 | 373 | ); |
374 | 374 | |
375 | - return apply_filters( 'wpinv_ipn_url', add_query_arg( $args, home_url( 'index.php' ) ), $gateway, $args ); |
|
375 | + return apply_filters('wpinv_ipn_url', add_query_arg($args, home_url('index.php')), $gateway, $args); |
|
376 | 376 | |
377 | 377 | } |
378 | 378 | |
@@ -383,34 +383,34 @@ discard block |
||
383 | 383 | * |
384 | 384 | * @return string |
385 | 385 | */ |
386 | -function getpaid_get_non_query_string_ipn_url( $gateway ) { |
|
387 | - $gateway = wpinv_sanitize_key( $gateway ); |
|
388 | - return home_url( "getpaid-ipn/$gateway" ); |
|
386 | +function getpaid_get_non_query_string_ipn_url($gateway) { |
|
387 | + $gateway = wpinv_sanitize_key($gateway); |
|
388 | + return home_url("getpaid-ipn/$gateway"); |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | |
392 | 392 | /** |
393 | 393 | * Retrieves request data with slashes removed slashes. |
394 | 394 | */ |
395 | -function wpinv_get_post_data( $method = 'request' ) { |
|
395 | +function wpinv_get_post_data($method = 'request') { |
|
396 | 396 | |
397 | - if ( $method == 'post' ) { |
|
398 | - return wp_unslash( $_POST ); |
|
397 | + if ($method == 'post') { |
|
398 | + return wp_unslash($_POST); |
|
399 | 399 | } |
400 | 400 | |
401 | - if ( $method == 'get' ) { |
|
402 | - return wp_unslash( $_GET ); |
|
401 | + if ($method == 'get') { |
|
402 | + return wp_unslash($_GET); |
|
403 | 403 | } |
404 | 404 | |
405 | - return wp_unslash( $_REQUEST ); |
|
405 | + return wp_unslash($_REQUEST); |
|
406 | 406 | |
407 | 407 | } |
408 | 408 | |
409 | 409 | /** |
410 | 410 | * Checks if a given gateway supports subscription payments. |
411 | 411 | */ |
412 | -function wpinv_gateway_support_subscription( $gateway ) { |
|
413 | - return getpaid_payment_gateway_supports( $gateway, 'subscription' ); |
|
412 | +function wpinv_gateway_support_subscription($gateway) { |
|
413 | + return getpaid_payment_gateway_supports($gateway, 'subscription'); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | /** |
@@ -419,14 +419,14 @@ discard block |
||
419 | 419 | * @param array $gateways an array of gateways. |
420 | 420 | * @param GetPaid_Payment_Form $form payment form. |
421 | 421 | */ |
422 | -function wpinv_payment_gateways_on_cart( $gateways, $form ) { |
|
422 | +function wpinv_payment_gateways_on_cart($gateways, $form) { |
|
423 | 423 | |
424 | - if ( $form->is_recurring() ) { |
|
424 | + if ($form->is_recurring()) { |
|
425 | 425 | |
426 | - foreach ( array_keys( $gateways ) as $gateway ) { |
|
426 | + foreach (array_keys($gateways) as $gateway) { |
|
427 | 427 | |
428 | - if ( ! wpinv_gateway_support_subscription( $gateway ) ) { |
|
429 | - unset( $gateways[$gateway] ); |
|
428 | + if (!wpinv_gateway_support_subscription($gateway)) { |
|
429 | + unset($gateways[$gateway]); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | } |
@@ -435,4 +435,4 @@ discard block |
||
435 | 435 | |
436 | 436 | return $gateways; |
437 | 437 | } |
438 | -add_filter( 'getpaid_payment_form_gateways', 'wpinv_payment_gateways_on_cart', 10, 2 ); |
|
438 | +add_filter('getpaid_payment_form_gateways', 'wpinv_payment_gateways_on_cart', 10, 2); |