@@ -4,26 +4,26 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | ?> |
10 | 10 | <div class="table-responsive"> |
11 | 11 | <table id="wpinv_gateways_select" class="table border bg-white form-table"> |
12 | - <caption><?php echo esc_html_e( 'This table displays installed payment methods.', 'invoicing' ); ?></caption> |
|
12 | + <caption><?php echo esc_html_e('This table displays installed payment methods.', 'invoicing'); ?></caption> |
|
13 | 13 | |
14 | 14 | <thead> |
15 | 15 | <tr class="table-light"> |
16 | 16 | |
17 | 17 | <th scope="col" class="border-bottom border-top text-left"> |
18 | - <?php _e( 'Payment Method', 'invoicing' ); ?> |
|
18 | + <?php _e('Payment Method', 'invoicing'); ?> |
|
19 | 19 | </th> |
20 | 20 | |
21 | 21 | <th scope="col" class="border-bottom border-top text-center"> |
22 | - <?php _e( 'Enabled', 'invoicing' ); ?> |
|
22 | + <?php _e('Enabled', 'invoicing'); ?> |
|
23 | 23 | </th> |
24 | 24 | |
25 | 25 | <th scope="col" class="border-bottom border-top text-center"> |
26 | - <?php _e( 'Supports Subscriptions', 'invoicing' ); ?> |
|
26 | + <?php _e('Supports Subscriptions', 'invoicing'); ?> |
|
27 | 27 | </th> |
28 | 28 | |
29 | 29 | <th scope="col" class="border-bottom border-top text-right" style="width:32px"> </th> |
@@ -32,15 +32,15 @@ discard block |
||
32 | 32 | </thead> |
33 | 33 | |
34 | 34 | <tbody> |
35 | - <?php foreach ( wpinv_get_payment_gateways() as $id => $gateway ) : ?> |
|
35 | + <?php foreach (wpinv_get_payment_gateways() as $id => $gateway) : ?> |
|
36 | 36 | <tr> |
37 | 37 | <td class="getpaid-payment-method text-left"> |
38 | - <a style="color: #0073aa;" href="<?php echo esc_url( add_query_arg( 'section', $id ) ); ?>" class="font-weight-bold"><?php echo sanitize_text_field( $gateway['admin_label'] ); ?></a> |
|
38 | + <a style="color: #0073aa;" href="<?php echo esc_url(add_query_arg('section', $id)); ?>" class="font-weight-bold"><?php echo sanitize_text_field($gateway['admin_label']); ?></a> |
|
39 | 39 | </td> |
40 | 40 | <td class="getpaid-payment-method-enabled text-center"> |
41 | 41 | <?php |
42 | 42 | |
43 | - if ( wpinv_is_gateway_active( $id ) ) { |
|
43 | + if (wpinv_is_gateway_active($id)) { |
|
44 | 44 | echo "<i class='text-success fa fa-check'></i>"; |
45 | 45 | } else { |
46 | 46 | echo "<i class='text-dark fa fa-times'></i>"; |
@@ -51,10 +51,10 @@ discard block |
||
51 | 51 | <td class="getpaid-payment-method-subscription text-center"> |
52 | 52 | <?php |
53 | 53 | |
54 | - $supports = apply_filters( "wpinv_{$id}_support_subscription", false ); |
|
55 | - $supports = apply_filters( 'getapid_gateway_supports_subscription', $supports, $id ); |
|
54 | + $supports = apply_filters("wpinv_{$id}_support_subscription", false); |
|
55 | + $supports = apply_filters('getapid_gateway_supports_subscription', $supports, $id); |
|
56 | 56 | |
57 | - if ( $supports ) { |
|
57 | + if ($supports) { |
|
58 | 58 | echo "<i class='text-success fa fa-check'></i>"; |
59 | 59 | } else { |
60 | 60 | echo "<i class='text-dark fa fa-times'></i>"; |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | </td> |
65 | 65 | |
66 | 66 | <td class="getpaid-payment-method-action text-right"> |
67 | - <a class="button button-secondary" href="<?php echo esc_url( add_query_arg( 'section', $id ) ); ?>"><?php _e( 'Manage', 'invoicing' ); ?></a> |
|
67 | + <a class="button button-secondary" href="<?php echo esc_url(add_query_arg('section', $id)); ?>"><?php _e('Manage', 'invoicing'); ?></a> |
|
68 | 68 | </td> |
69 | 69 | |
70 | 70 | </tr> |
@@ -74,8 +74,8 @@ discard block |
||
74 | 74 | <tfoot> |
75 | 75 | <tr class="table-light"> |
76 | 76 | <td colspan="4" class="border-top"> |
77 | - <a class="button button-secondary getpaid-install-gateways" href="<?php echo esc_url( admin_url( 'admin.php?page=wpi-addons&tab=gateways' ) ); ?>"> |
|
78 | - <span><?php _e( 'Add Payment Methods', 'invoicing' ); ?></span> |
|
77 | + <a class="button button-secondary getpaid-install-gateways" href="<?php echo esc_url(admin_url('admin.php?page=wpi-addons&tab=gateways')); ?>"> |
|
78 | + <span><?php _e('Add Payment Methods', 'invoicing'); ?></span> |
|
79 | 79 | </a> |
80 | 80 | </td> |
81 | 81 | </tr> |
@@ -277,26 +277,26 @@ discard block |
||
277 | 277 | } |
278 | 278 | |
279 | 279 | function wpinv_get_chosen_gateway( $invoice_id = 0 ) { |
280 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
280 | + $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
281 | 281 | |
282 | 282 | $chosen = false; |
283 | 283 | if ( $invoice_id > 0 && $invoice = wpinv_get_invoice( $invoice_id ) ) { |
284 | 284 | $chosen = $invoice->get_gateway(); |
285 | 285 | } |
286 | 286 | |
287 | - $chosen = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen; |
|
287 | + $chosen = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen; |
|
288 | 288 | |
289 | - if ( false !== $chosen ) { |
|
290 | - $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen ); |
|
291 | - } |
|
289 | + if ( false !== $chosen ) { |
|
290 | + $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen ); |
|
291 | + } |
|
292 | 292 | |
293 | - if ( ! empty ( $chosen ) ) { |
|
294 | - $enabled_gateway = urldecode( $chosen ); |
|
295 | - } else if ( !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) { |
|
296 | - $enabled_gateway = 'manual'; |
|
297 | - } else { |
|
298 | - $enabled_gateway = wpinv_get_default_gateway(); |
|
299 | - } |
|
293 | + if ( ! empty ( $chosen ) ) { |
|
294 | + $enabled_gateway = urldecode( $chosen ); |
|
295 | + } else if ( !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) { |
|
296 | + $enabled_gateway = 'manual'; |
|
297 | + } else { |
|
298 | + $enabled_gateway = wpinv_get_default_gateway(); |
|
299 | + } |
|
300 | 300 | |
301 | 301 | if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) { |
302 | 302 | if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){ |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | |
308 | 308 | } |
309 | 309 | |
310 | - return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway ); |
|
310 | + return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway ); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | function wpinv_record_gateway_error( $title = '', $message = '' ) { |
@@ -315,21 +315,21 @@ discard block |
||
315 | 315 | } |
316 | 316 | |
317 | 317 | function wpinv_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) { |
318 | - $ret = 0; |
|
319 | - $args = array( |
|
320 | - 'meta_key' => '_wpinv_gateway', |
|
321 | - 'meta_value' => $gateway_id, |
|
322 | - 'nopaging' => true, |
|
323 | - 'post_type' => 'wpi_invoice', |
|
324 | - 'post_status' => $status, |
|
325 | - 'fields' => 'ids' |
|
326 | - ); |
|
327 | - |
|
328 | - $payments = new WP_Query( $args ); |
|
329 | - |
|
330 | - if( $payments ) |
|
331 | - $ret = $payments->post_count; |
|
332 | - return $ret; |
|
318 | + $ret = 0; |
|
319 | + $args = array( |
|
320 | + 'meta_key' => '_wpinv_gateway', |
|
321 | + 'meta_value' => $gateway_id, |
|
322 | + 'nopaging' => true, |
|
323 | + 'post_type' => 'wpi_invoice', |
|
324 | + 'post_status' => $status, |
|
325 | + 'fields' => 'ids' |
|
326 | + ); |
|
327 | + |
|
328 | + $payments = new WP_Query( $args ); |
|
329 | + |
|
330 | + if( $payments ) |
|
331 | + $ret = $payments->post_count; |
|
332 | + return $ret; |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | // PayPal Standard settings |
@@ -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 | 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 | 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,49 +125,49 @@ 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 | global $wpinv_options; |
130 | 130 | |
131 | - $description = ! empty( $wpinv_options[$gateway . '_desc'] ) ? $wpinv_options[$gateway . '_desc'] : ''; |
|
131 | + $description = !empty($wpinv_options[$gateway . '_desc']) ? $wpinv_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 | 153 | |
154 | 154 | if (!empty($gateways)) { |
155 | - foreach ($gateways as $key => $gateway) { |
|
155 | + foreach ($gateways as $key => $gateway) { |
|
156 | 156 | $settings[$key] = $gateway['admin_label']; |
157 | 157 | } |
158 | 158 | } |
159 | 159 | |
160 | 160 | return $settings; |
161 | 161 | } |
162 | -add_filter( 'wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1 ); |
|
162 | +add_filter('wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1); |
|
163 | 163 | |
164 | 164 | /** |
165 | 165 | * Adds GateWay settings. |
166 | 166 | */ |
167 | -function wpinv_settings_gateways( $settings ) { |
|
167 | +function wpinv_settings_gateways($settings) { |
|
168 | 168 | |
169 | 169 | // Loop through each gateway. |
170 | - foreach ( wpinv_get_payment_gateways() as $key => $gateway ) { |
|
170 | + foreach (wpinv_get_payment_gateways() as $key => $gateway) { |
|
171 | 171 | |
172 | 172 | $gateway_settings = array( |
173 | 173 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | "{$key}_header" => array( |
176 | 176 | |
177 | 177 | 'id' => "{$key}_gateway_header", |
178 | - 'name' => '<h3>' . wp_sprintf( __( '%s Settings', 'invoicing' ), $gateway['admin_label'] ) . '</h3>', |
|
178 | + 'name' => '<h3>' . wp_sprintf(__('%s Settings', 'invoicing'), $gateway['admin_label']) . '</h3>', |
|
179 | 179 | 'custom' => $key, |
180 | 180 | 'type' => 'gateway_header', |
181 | 181 | |
@@ -184,8 +184,8 @@ discard block |
||
184 | 184 | // Activate/Deactivate a gateway. |
185 | 185 | "{$key}_active" => array( |
186 | 186 | 'id' => $key . '_active', |
187 | - 'name' => __( 'Activate', 'invoicing' ), |
|
188 | - 'desc' => wp_sprintf( __( 'Enable %s', 'invoicing' ), $gateway['admin_label'] ), |
|
187 | + 'name' => __('Activate', 'invoicing'), |
|
188 | + 'desc' => wp_sprintf(__('Enable %s', 'invoicing'), $gateway['admin_label']), |
|
189 | 189 | 'type' => 'checkbox', |
190 | 190 | 'std' => $key === 'manual' ? '1' : '0', |
191 | 191 | ), |
@@ -193,8 +193,8 @@ discard block |
||
193 | 193 | // Activate/Deactivate sandbox. |
194 | 194 | "{$key}_sandbox" => array( |
195 | 195 | 'id' => $key . '_sandbox', |
196 | - 'name' => __( 'Sandbox', 'invoicing' ), |
|
197 | - 'desc' => __( 'Enable sandbox to test payments', 'invoicing' ), |
|
196 | + 'name' => __('Sandbox', 'invoicing'), |
|
197 | + 'desc' => __('Enable sandbox to test payments', 'invoicing'), |
|
198 | 198 | 'type' => 'checkbox', |
199 | 199 | 'std' => '1', |
200 | 200 | ), |
@@ -202,40 +202,40 @@ discard block |
||
202 | 202 | // Checkout title. |
203 | 203 | "{$key}_title" => array( |
204 | 204 | 'id' => $key . '_title', |
205 | - 'name' => __( 'Checkout Title', 'invoicing' ), |
|
206 | - 'std' => isset( $gateway['checkout_label'] ) ? $gateway['checkout_label'] : '', |
|
205 | + 'name' => __('Checkout Title', 'invoicing'), |
|
206 | + 'std' => isset($gateway['checkout_label']) ? $gateway['checkout_label'] : '', |
|
207 | 207 | 'type' => 'text', |
208 | 208 | ), |
209 | 209 | |
210 | 210 | // Checkout description. |
211 | 211 | "{$key}_desc" => array( |
212 | 212 | 'id' => $key . '_desc', |
213 | - 'name' => __( 'Checkout Description', 'invoicing' ), |
|
214 | - 'std' => apply_filters( "getpaid_default_{$key}_checkout_description", '' ), |
|
213 | + 'name' => __('Checkout Description', 'invoicing'), |
|
214 | + 'std' => apply_filters("getpaid_default_{$key}_checkout_description", ''), |
|
215 | 215 | 'type' => 'text', |
216 | 216 | ), |
217 | 217 | |
218 | 218 | // Checkout order. |
219 | 219 | "{$key}_ordering" => array( |
220 | 220 | 'id' => $key . '_ordering', |
221 | - 'name' => __( 'Priority', 'invoicing' ), |
|
222 | - 'std' => apply_filters( "getpaid_default_{$key}_checkout_description", '' ), |
|
221 | + 'name' => __('Priority', 'invoicing'), |
|
222 | + 'std' => apply_filters("getpaid_default_{$key}_checkout_description", ''), |
|
223 | 223 | 'type' => 'number', |
224 | 224 | 'step' => '1', |
225 | 225 | 'min' => '0', |
226 | 226 | 'max' => '100000', |
227 | - 'std' => isset( $gateway['ordering'] ) ? $gateway['ordering'] : '10', |
|
227 | + 'std' => isset($gateway['ordering']) ? $gateway['ordering'] : '10', |
|
228 | 228 | ), |
229 | 229 | |
230 | 230 | ); |
231 | 231 | |
232 | 232 | // Maybe remove the sandbox. |
233 | - if ( ! getpaid_payment_gateway_supports( $key, 'sandbox' ) ) { |
|
234 | - unset( $gateway_settings["{$key}_sandbox"] ); |
|
233 | + if (!getpaid_payment_gateway_supports($key, 'sandbox')) { |
|
234 | + unset($gateway_settings["{$key}_sandbox"]); |
|
235 | 235 | } |
236 | 236 | |
237 | - $gateway_settings = apply_filters( 'wpinv_gateway_settings', $gateway_settings, $key, $gateway ); |
|
238 | - $gateway_settings = apply_filters( 'wpinv_gateway_settings_' . $key, $gateway_settings, $gateway ); |
|
237 | + $gateway_settings = apply_filters('wpinv_gateway_settings', $gateway_settings, $key, $gateway); |
|
238 | + $gateway_settings = apply_filters('wpinv_gateway_settings_' . $key, $gateway_settings, $gateway); |
|
239 | 239 | |
240 | 240 | $settings[$key] = $gateway_settings; |
241 | 241 | } |
@@ -243,10 +243,10 @@ discard block |
||
243 | 243 | return $settings; |
244 | 244 | |
245 | 245 | } |
246 | -add_filter( 'wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1 ); |
|
246 | +add_filter('wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1); |
|
247 | 247 | |
248 | -function wpinv_gateway_header_callback( $args ) { |
|
249 | - echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr( $args['custom'] ) . '" />'; |
|
248 | +function wpinv_gateway_header_callback($args) { |
|
249 | + echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr($args['custom']) . '" />'; |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
@@ -257,64 +257,64 @@ discard block |
||
257 | 257 | * @return bool |
258 | 258 | * @since 2.3.0 |
259 | 259 | */ |
260 | -function getpaid_payment_gateway_supports( $gateway, $feature ) { |
|
260 | +function getpaid_payment_gateway_supports($gateway, $feature) { |
|
261 | 261 | |
262 | 262 | $supports = false; |
263 | 263 | |
264 | - if ( wpinv_is_gateway_active( $gateway ) ) { |
|
264 | + if (wpinv_is_gateway_active($gateway)) { |
|
265 | 265 | |
266 | - $supports = apply_filters( "getpaid_{$gateway}_supports_{$feature}", false ); |
|
266 | + $supports = apply_filters("getpaid_{$gateway}_supports_{$feature}", false); |
|
267 | 267 | |
268 | 268 | // Backwards compatibility. |
269 | - $supports = apply_filters( "wpinv_{$gateway}_supports_{$feature}", $supports ); |
|
270 | - $supports = apply_filters( "wpinv_{$gateway}_support_{$feature}", $supports ); |
|
269 | + $supports = apply_filters("wpinv_{$gateway}_supports_{$feature}", $supports); |
|
270 | + $supports = apply_filters("wpinv_{$gateway}_support_{$feature}", $supports); |
|
271 | 271 | |
272 | - $supports = apply_filters( "getpaid_gateway_supports_{$feature}", $supports, $gateway ); |
|
273 | - $supports = apply_filters( 'getpaid_payment_gateway_supports', $supports, $feature, $gateway ); |
|
272 | + $supports = apply_filters("getpaid_gateway_supports_{$feature}", $supports, $gateway); |
|
273 | + $supports = apply_filters('getpaid_payment_gateway_supports', $supports, $feature, $gateway); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | return $supports; |
277 | 277 | } |
278 | 278 | |
279 | -function wpinv_get_chosen_gateway( $invoice_id = 0 ) { |
|
280 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
279 | +function wpinv_get_chosen_gateway($invoice_id = 0) { |
|
280 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
281 | 281 | |
282 | 282 | $chosen = false; |
283 | - if ( $invoice_id > 0 && $invoice = wpinv_get_invoice( $invoice_id ) ) { |
|
283 | + if ($invoice_id > 0 && $invoice = wpinv_get_invoice($invoice_id)) { |
|
284 | 284 | $chosen = $invoice->get_gateway(); |
285 | 285 | } |
286 | 286 | |
287 | - $chosen = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen; |
|
287 | + $chosen = isset($_REQUEST['payment-mode']) ? sanitize_text_field($_REQUEST['payment-mode']) : $chosen; |
|
288 | 288 | |
289 | - if ( false !== $chosen ) { |
|
290 | - $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen ); |
|
289 | + if (false !== $chosen) { |
|
290 | + $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen); |
|
291 | 291 | } |
292 | 292 | |
293 | - if ( ! empty ( $chosen ) ) { |
|
294 | - $enabled_gateway = urldecode( $chosen ); |
|
295 | - } else if ( !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) { |
|
293 | + if (!empty ($chosen)) { |
|
294 | + $enabled_gateway = urldecode($chosen); |
|
295 | + } else if (!empty($invoice) && (float) $invoice->get_subtotal() <= 0) { |
|
296 | 296 | $enabled_gateway = 'manual'; |
297 | 297 | } else { |
298 | 298 | $enabled_gateway = wpinv_get_default_gateway(); |
299 | 299 | } |
300 | 300 | |
301 | - if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) { |
|
302 | - if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){ |
|
301 | + if (!wpinv_is_gateway_active($enabled_gateway) && !empty($gateways)) { |
|
302 | + if (wpinv_is_gateway_active(wpinv_get_default_gateway())) { |
|
303 | 303 | $enabled_gateway = wpinv_get_default_gateway(); |
304 | - }else{ |
|
304 | + } else { |
|
305 | 305 | $enabled_gateway = $gateways[0]; |
306 | 306 | } |
307 | 307 | |
308 | 308 | } |
309 | 309 | |
310 | - return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway ); |
|
310 | + return apply_filters('wpinv_chosen_gateway', $enabled_gateway); |
|
311 | 311 | } |
312 | 312 | |
313 | -function wpinv_record_gateway_error( $title = '', $message = '' ) { |
|
314 | - return wpinv_error_log( $message, $title ); |
|
313 | +function wpinv_record_gateway_error($title = '', $message = '') { |
|
314 | + return wpinv_error_log($message, $title); |
|
315 | 315 | } |
316 | 316 | |
317 | -function wpinv_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) { |
|
317 | +function wpinv_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') { |
|
318 | 318 | $ret = 0; |
319 | 319 | $args = array( |
320 | 320 | 'meta_key' => '_wpinv_gateway', |
@@ -325,32 +325,32 @@ discard block |
||
325 | 325 | 'fields' => 'ids' |
326 | 326 | ); |
327 | 327 | |
328 | - $payments = new WP_Query( $args ); |
|
328 | + $payments = new WP_Query($args); |
|
329 | 329 | |
330 | - if( $payments ) |
|
330 | + if ($payments) |
|
331 | 331 | $ret = $payments->post_count; |
332 | 332 | return $ret; |
333 | 333 | } |
334 | 334 | |
335 | 335 | // PayPal Standard settings |
336 | -function wpinv_gateway_settings_paypal( $setting ) { |
|
337 | - $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' ); |
|
338 | - $setting['paypal_desc']['std'] = __( 'Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing' ); |
|
336 | +function wpinv_gateway_settings_paypal($setting) { |
|
337 | + $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'); |
|
338 | + $setting['paypal_desc']['std'] = __('Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing'); |
|
339 | 339 | |
340 | 340 | $setting['paypal_sandbox'] = array( |
341 | 341 | 'type' => 'checkbox', |
342 | 342 | 'id' => 'paypal_sandbox', |
343 | - 'name' => __( 'PayPal Sandbox', 'invoicing' ), |
|
344 | - 'desc' => __( 'PayPal sandbox can be used to test payments.', 'invoicing' ), |
|
343 | + 'name' => __('PayPal Sandbox', 'invoicing'), |
|
344 | + 'desc' => __('PayPal sandbox can be used to test payments.', 'invoicing'), |
|
345 | 345 | 'std' => 1 |
346 | 346 | ); |
347 | 347 | |
348 | 348 | $setting['paypal_email'] = array( |
349 | 349 | 'type' => 'text', |
350 | 350 | 'id' => 'paypal_email', |
351 | - 'name' => __( 'PayPal Email', 'invoicing' ), |
|
352 | - 'desc' => __( 'Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing' ), |
|
353 | - 'std' => __( '[email protected]', 'invoicing' ), |
|
351 | + 'name' => __('PayPal Email', 'invoicing'), |
|
352 | + 'desc' => __('Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing'), |
|
353 | + 'std' => __('[email protected]', 'invoicing'), |
|
354 | 354 | ); |
355 | 355 | /* |
356 | 356 | $setting['paypal_ipn_url'] = array( |
@@ -364,18 +364,18 @@ discard block |
||
364 | 364 | |
365 | 365 | return $setting; |
366 | 366 | } |
367 | -add_filter( 'wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1 ); |
|
367 | +add_filter('wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1); |
|
368 | 368 | |
369 | 369 | /** |
370 | 370 | * Displays the ipn url field. |
371 | 371 | */ |
372 | -function wpinv_ipn_url_callback( $args ) { |
|
373 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
372 | +function wpinv_ipn_url_callback($args) { |
|
373 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
374 | 374 | |
375 | 375 | $attrs = $args['readonly'] ? ' readonly' : ''; |
376 | 376 | |
377 | - $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()">'; |
|
378 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>'; |
|
377 | + $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()">'; |
|
378 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>'; |
|
379 | 379 | |
380 | 380 | echo $html; |
381 | 381 | } |
@@ -387,10 +387,10 @@ discard block |
||
387 | 387 | * |
388 | 388 | * @return bool |
389 | 389 | */ |
390 | -function wpinv_is_test_mode( $gateway = '' ) { |
|
391 | - $sandbox = empty( $gateway ) ? false : wpinv_get_option( "{$gateway}_sandbox", true ); |
|
392 | - $supports = getpaid_payment_gateway_supports( $gateway, 'sandbox' ); |
|
393 | - return apply_filters( 'wpinv_is_test_mode', $sandbox && $supports, $gateway ); |
|
390 | +function wpinv_is_test_mode($gateway = '') { |
|
391 | + $sandbox = empty($gateway) ? false : wpinv_get_option("{$gateway}_sandbox", true); |
|
392 | + $supports = getpaid_payment_gateway_supports($gateway, 'sandbox'); |
|
393 | + return apply_filters('wpinv_is_test_mode', $sandbox && $supports, $gateway); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | /** |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | * |
402 | 402 | * @return string |
403 | 403 | */ |
404 | -function wpinv_get_ipn_url( $gateway = false, $args = array() ) { |
|
404 | +function wpinv_get_ipn_url($gateway = false, $args = array()) { |
|
405 | 405 | $args = wp_parse_args( |
406 | 406 | array( |
407 | 407 | 'wpi-listener' => 'IPN', |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | $args |
411 | 411 | ); |
412 | 412 | |
413 | - return apply_filters( 'wpinv_ipn_url', add_query_arg( $args, home_url( 'index.php' ) ), $gateway, $args ); |
|
413 | + return apply_filters('wpinv_ipn_url', add_query_arg($args, home_url('index.php')), $gateway, $args); |
|
414 | 414 | |
415 | 415 | } |
416 | 416 | |
@@ -421,34 +421,34 @@ discard block |
||
421 | 421 | * |
422 | 422 | * @return string |
423 | 423 | */ |
424 | -function getpaid_get_non_query_string_ipn_url( $gateway ) { |
|
425 | - $gateway = wpinv_sanitize_key( $gateway ); |
|
426 | - return home_url( "getpaid-ipn/$gateway" ); |
|
424 | +function getpaid_get_non_query_string_ipn_url($gateway) { |
|
425 | + $gateway = wpinv_sanitize_key($gateway); |
|
426 | + return home_url("getpaid-ipn/$gateway"); |
|
427 | 427 | } |
428 | 428 | |
429 | 429 | |
430 | 430 | /** |
431 | 431 | * Retrieves request data with slashes removed slashes. |
432 | 432 | */ |
433 | -function wpinv_get_post_data( $method = 'request' ) { |
|
433 | +function wpinv_get_post_data($method = 'request') { |
|
434 | 434 | |
435 | - if ( $method == 'post' ) { |
|
436 | - return wp_unslash( $_POST ); |
|
435 | + if ($method == 'post') { |
|
436 | + return wp_unslash($_POST); |
|
437 | 437 | } |
438 | 438 | |
439 | - if ( $method == 'get' ) { |
|
440 | - return wp_unslash( $_GET ); |
|
439 | + if ($method == 'get') { |
|
440 | + return wp_unslash($_GET); |
|
441 | 441 | } |
442 | 442 | |
443 | - return wp_unslash( $_REQUEST ); |
|
443 | + return wp_unslash($_REQUEST); |
|
444 | 444 | |
445 | 445 | } |
446 | 446 | |
447 | 447 | /** |
448 | 448 | * Checks if a given gateway supports subscription payments. |
449 | 449 | */ |
450 | -function wpinv_gateway_support_subscription( $gateway ) { |
|
451 | - return getpaid_payment_gateway_supports( $gateway, 'subscription' ); |
|
450 | +function wpinv_gateway_support_subscription($gateway) { |
|
451 | + return getpaid_payment_gateway_supports($gateway, 'subscription'); |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | /** |
@@ -457,14 +457,14 @@ discard block |
||
457 | 457 | * @param array $gateways an array of gateways. |
458 | 458 | * @param GetPaid_Payment_Form $form payment form. |
459 | 459 | */ |
460 | -function wpinv_payment_gateways_on_cart( $gateways, $form ) { |
|
460 | +function wpinv_payment_gateways_on_cart($gateways, $form) { |
|
461 | 461 | |
462 | - if ( $form->is_recurring() ) { |
|
462 | + if ($form->is_recurring()) { |
|
463 | 463 | |
464 | - foreach ( array_keys( $gateways ) as $gateway ) { |
|
464 | + foreach (array_keys($gateways) as $gateway) { |
|
465 | 465 | |
466 | - if ( ! wpinv_gateway_support_subscription( $gateway ) ) { |
|
467 | - unset( $gateways[$gateway] ); |
|
466 | + if (!wpinv_gateway_support_subscription($gateway)) { |
|
467 | + unset($gateways[$gateway]); |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | } |
@@ -473,4 +473,4 @@ discard block |
||
473 | 473 | |
474 | 474 | return $gateways; |
475 | 475 | } |
476 | -add_filter( 'getpaid_payment_form_gateways', 'wpinv_payment_gateways_on_cart', 10, 2 ); |
|
476 | +add_filter('getpaid_payment_form_gateways', 'wpinv_payment_gateways_on_cart', 10, 2); |