@@ -4,29 +4,29 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | $gateways = wpinv_get_payment_gateways(); |
10 | -ksort( $gateways ); |
|
10 | +ksort($gateways); |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 | <div class="table-responsive"> |
14 | 14 | <table id="wpinv_gateways_select" class="table border bg-white form-table"> |
15 | - <caption><?php echo esc_html_e( 'This table displays installed payment methods.', 'invoicing' ); ?></caption> |
|
15 | + <caption><?php echo esc_html_e('This table displays installed payment methods.', 'invoicing'); ?></caption> |
|
16 | 16 | |
17 | 17 | <thead> |
18 | 18 | <tr class="table-light"> |
19 | 19 | |
20 | 20 | <th scope="col" class="border-bottom border-top text-left"> |
21 | - <?php _e( 'Payment Method', 'invoicing' ); ?> |
|
21 | + <?php _e('Payment Method', 'invoicing'); ?> |
|
22 | 22 | </th> |
23 | 23 | |
24 | 24 | <th scope="col" class="border-bottom border-top text-center"> |
25 | - <?php _e( 'Enabled', 'invoicing' ); ?> |
|
25 | + <?php _e('Enabled', 'invoicing'); ?> |
|
26 | 26 | </th> |
27 | 27 | |
28 | 28 | <th scope="col" class="border-bottom border-top text-center"> |
29 | - <?php _e( 'Supports Subscriptions', 'invoicing' ); ?> |
|
29 | + <?php _e('Supports Subscriptions', 'invoicing'); ?> |
|
30 | 30 | </th> |
31 | 31 | |
32 | 32 | <th scope="col" class="border-bottom border-top text-right" style="width:32px"> </th> |
@@ -35,15 +35,15 @@ discard block |
||
35 | 35 | </thead> |
36 | 36 | |
37 | 37 | <tbody> |
38 | - <?php foreach ( $gateways as $id => $gateway ) : ?> |
|
38 | + <?php foreach ($gateways as $id => $gateway) : ?> |
|
39 | 39 | <tr> |
40 | 40 | <td class="getpaid-payment-method text-left"> |
41 | - <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> |
|
41 | + <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> |
|
42 | 42 | </td> |
43 | 43 | <td class="getpaid-payment-method-enabled text-center"> |
44 | 44 | <?php |
45 | 45 | |
46 | - if ( wpinv_is_gateway_active( $id ) ) { |
|
46 | + if (wpinv_is_gateway_active($id)) { |
|
47 | 47 | echo "<i class='text-success fa fa-check'></i>"; |
48 | 48 | } else { |
49 | 49 | echo "<i class='text-dark fa fa-times'></i>"; |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | <td class="getpaid-payment-method-subscription text-center"> |
55 | 55 | <?php |
56 | 56 | |
57 | - $supports = apply_filters( "wpinv_{$id}_support_subscription", false ); |
|
58 | - $supports = apply_filters( 'getapid_gateway_supports_subscription', $supports, $id ); |
|
57 | + $supports = apply_filters("wpinv_{$id}_support_subscription", false); |
|
58 | + $supports = apply_filters('getapid_gateway_supports_subscription', $supports, $id); |
|
59 | 59 | |
60 | - if ( $supports ) { |
|
60 | + if ($supports) { |
|
61 | 61 | echo "<i class='text-success fa fa-check'></i>"; |
62 | 62 | } else { |
63 | 63 | echo "<i class='text-dark fa fa-times'></i>"; |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | </td> |
68 | 68 | |
69 | 69 | <td class="getpaid-payment-method-action text-right"> |
70 | - <a class="button button-secondary" href="<?php echo esc_url( add_query_arg( 'section', $id ) ); ?>"><?php _e( 'Manage', 'invoicing' ); ?></a> |
|
70 | + <a class="button button-secondary" href="<?php echo esc_url(add_query_arg('section', $id)); ?>"><?php _e('Manage', 'invoicing'); ?></a> |
|
71 | 71 | </td> |
72 | 72 | |
73 | 73 | </tr> |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | <tfoot> |
78 | 78 | <tr class="table-light"> |
79 | 79 | <td colspan="4" class="border-top"> |
80 | - <a class="button button-secondary getpaid-install-gateways" href="<?php echo esc_url( admin_url( 'admin.php?page=wpi-addons&tab=gateways' ) ); ?>"> |
|
81 | - <span><?php _e( 'Add Payment Methods', 'invoicing' ); ?></span> |
|
80 | + <a class="button button-secondary getpaid-install-gateways" href="<?php echo esc_url(admin_url('admin.php?page=wpi-addons&tab=gateways')); ?>"> |
|
81 | + <span><?php _e('Add Payment Methods', 'invoicing'); ?></span> |
|
82 | 82 | </a> |
83 | 83 | </td> |
84 | 84 | </tr> |
@@ -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,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 | 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 | - 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,64 +256,64 @@ 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 | - if ( wpinv_is_gateway_active( $gateway ) ) { |
|
263 | + if (wpinv_is_gateway_active($gateway)) { |
|
264 | 264 | |
265 | - $supports = apply_filters( "getpaid_{$gateway}_supports_{$feature}", false ); |
|
265 | + $supports = apply_filters("getpaid_{$gateway}_supports_{$feature}", false); |
|
266 | 266 | |
267 | 267 | // Backwards compatibility. |
268 | - $supports = apply_filters( "wpinv_{$gateway}_supports_{$feature}", $supports ); |
|
269 | - $supports = apply_filters( "wpinv_{$gateway}_support_{$feature}", $supports ); |
|
268 | + $supports = apply_filters("wpinv_{$gateway}_supports_{$feature}", $supports); |
|
269 | + $supports = apply_filters("wpinv_{$gateway}_support_{$feature}", $supports); |
|
270 | 270 | |
271 | - $supports = apply_filters( "getpaid_gateway_supports_{$feature}", $supports, $gateway ); |
|
272 | - $supports = apply_filters( 'getpaid_payment_gateway_supports', $supports, $feature, $gateway ); |
|
271 | + $supports = apply_filters("getpaid_gateway_supports_{$feature}", $supports, $gateway); |
|
272 | + $supports = apply_filters('getpaid_payment_gateway_supports', $supports, $feature, $gateway); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | return $supports; |
276 | 276 | } |
277 | 277 | |
278 | -function wpinv_get_chosen_gateway( $invoice_id = 0 ) { |
|
279 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
278 | +function wpinv_get_chosen_gateway($invoice_id = 0) { |
|
279 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
280 | 280 | |
281 | 281 | $chosen = false; |
282 | - if ( $invoice_id > 0 && $invoice = wpinv_get_invoice( $invoice_id ) ) { |
|
282 | + if ($invoice_id > 0 && $invoice = wpinv_get_invoice($invoice_id)) { |
|
283 | 283 | $chosen = $invoice->get_gateway(); |
284 | 284 | } |
285 | 285 | |
286 | - $chosen = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen; |
|
286 | + $chosen = isset($_REQUEST['payment-mode']) ? sanitize_text_field($_REQUEST['payment-mode']) : $chosen; |
|
287 | 287 | |
288 | - if ( false !== $chosen ) { |
|
289 | - $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen ); |
|
288 | + if (false !== $chosen) { |
|
289 | + $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen); |
|
290 | 290 | } |
291 | 291 | |
292 | - if ( ! empty ( $chosen ) ) { |
|
293 | - $enabled_gateway = urldecode( $chosen ); |
|
294 | - } else if ( !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) { |
|
292 | + if (!empty ($chosen)) { |
|
293 | + $enabled_gateway = urldecode($chosen); |
|
294 | + } else if (!empty($invoice) && (float) $invoice->get_subtotal() <= 0) { |
|
295 | 295 | $enabled_gateway = 'manual'; |
296 | 296 | } else { |
297 | 297 | $enabled_gateway = wpinv_get_default_gateway(); |
298 | 298 | } |
299 | 299 | |
300 | - if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) { |
|
301 | - if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){ |
|
300 | + if (!wpinv_is_gateway_active($enabled_gateway) && !empty($gateways)) { |
|
301 | + if (wpinv_is_gateway_active(wpinv_get_default_gateway())) { |
|
302 | 302 | $enabled_gateway = wpinv_get_default_gateway(); |
303 | - }else{ |
|
303 | + } else { |
|
304 | 304 | $enabled_gateway = $gateways[0]; |
305 | 305 | } |
306 | 306 | |
307 | 307 | } |
308 | 308 | |
309 | - return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway ); |
|
309 | + return apply_filters('wpinv_chosen_gateway', $enabled_gateway); |
|
310 | 310 | } |
311 | 311 | |
312 | -function wpinv_record_gateway_error( $title = '', $message = '' ) { |
|
313 | - return wpinv_error_log( $message, $title ); |
|
312 | +function wpinv_record_gateway_error($title = '', $message = '') { |
|
313 | + return wpinv_error_log($message, $title); |
|
314 | 314 | } |
315 | 315 | |
316 | -function wpinv_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) { |
|
316 | +function wpinv_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') { |
|
317 | 317 | $ret = 0; |
318 | 318 | $args = array( |
319 | 319 | 'meta_key' => '_wpinv_gateway', |
@@ -324,32 +324,32 @@ discard block |
||
324 | 324 | 'fields' => 'ids' |
325 | 325 | ); |
326 | 326 | |
327 | - $payments = new WP_Query( $args ); |
|
327 | + $payments = new WP_Query($args); |
|
328 | 328 | |
329 | - if( $payments ) |
|
329 | + if ($payments) |
|
330 | 330 | $ret = $payments->post_count; |
331 | 331 | return $ret; |
332 | 332 | } |
333 | 333 | |
334 | 334 | // PayPal Standard settings |
335 | -function wpinv_gateway_settings_paypal( $setting ) { |
|
336 | - $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' ); |
|
337 | - $setting['paypal_desc']['std'] = __( 'Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing' ); |
|
335 | +function wpinv_gateway_settings_paypal($setting) { |
|
336 | + $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'); |
|
337 | + $setting['paypal_desc']['std'] = __('Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing'); |
|
338 | 338 | |
339 | 339 | $setting['paypal_sandbox'] = array( |
340 | 340 | 'type' => 'checkbox', |
341 | 341 | 'id' => 'paypal_sandbox', |
342 | - 'name' => __( 'PayPal Sandbox', 'invoicing' ), |
|
343 | - 'desc' => __( 'PayPal sandbox can be used to test payments.', 'invoicing' ), |
|
342 | + 'name' => __('PayPal Sandbox', 'invoicing'), |
|
343 | + 'desc' => __('PayPal sandbox can be used to test payments.', 'invoicing'), |
|
344 | 344 | 'std' => 1 |
345 | 345 | ); |
346 | 346 | |
347 | 347 | $setting['paypal_email'] = array( |
348 | 348 | 'type' => 'text', |
349 | 349 | 'id' => 'paypal_email', |
350 | - 'name' => __( 'PayPal Email', 'invoicing' ), |
|
351 | - 'desc' => __( 'Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing' ), |
|
352 | - 'std' => __( '[email protected]', 'invoicing' ), |
|
350 | + 'name' => __('PayPal Email', 'invoicing'), |
|
351 | + 'desc' => __('Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing'), |
|
352 | + 'std' => __('[email protected]', 'invoicing'), |
|
353 | 353 | ); |
354 | 354 | /* |
355 | 355 | $setting['paypal_ipn_url'] = array( |
@@ -363,18 +363,18 @@ discard block |
||
363 | 363 | |
364 | 364 | return $setting; |
365 | 365 | } |
366 | -add_filter( 'wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1 ); |
|
366 | +add_filter('wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1); |
|
367 | 367 | |
368 | 368 | /** |
369 | 369 | * Displays the ipn url field. |
370 | 370 | */ |
371 | -function wpinv_ipn_url_callback( $args ) { |
|
372 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
371 | +function wpinv_ipn_url_callback($args) { |
|
372 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
373 | 373 | |
374 | 374 | $attrs = $args['readonly'] ? ' readonly' : ''; |
375 | 375 | |
376 | - $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()">'; |
|
377 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>'; |
|
376 | + $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()">'; |
|
377 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>'; |
|
378 | 378 | |
379 | 379 | echo $html; |
380 | 380 | } |
@@ -386,10 +386,10 @@ discard block |
||
386 | 386 | * |
387 | 387 | * @return bool |
388 | 388 | */ |
389 | -function wpinv_is_test_mode( $gateway = '' ) { |
|
390 | - $sandbox = empty( $gateway ) ? false : wpinv_get_option( "{$gateway}_sandbox", true ); |
|
391 | - $supports = getpaid_payment_gateway_supports( $gateway, 'sandbox' ); |
|
392 | - return apply_filters( 'wpinv_is_test_mode', $sandbox && $supports, $gateway ); |
|
389 | +function wpinv_is_test_mode($gateway = '') { |
|
390 | + $sandbox = empty($gateway) ? false : wpinv_get_option("{$gateway}_sandbox", true); |
|
391 | + $supports = getpaid_payment_gateway_supports($gateway, 'sandbox'); |
|
392 | + return apply_filters('wpinv_is_test_mode', $sandbox && $supports, $gateway); |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | /** |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | * |
401 | 401 | * @return string |
402 | 402 | */ |
403 | -function wpinv_get_ipn_url( $gateway = false, $args = array() ) { |
|
403 | +function wpinv_get_ipn_url($gateway = false, $args = array()) { |
|
404 | 404 | $args = wp_parse_args( |
405 | 405 | array( |
406 | 406 | 'wpi-listener' => 'IPN', |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | $args |
410 | 410 | ); |
411 | 411 | |
412 | - return apply_filters( 'wpinv_ipn_url', add_query_arg( $args, home_url( 'index.php' ) ), $gateway, $args ); |
|
412 | + return apply_filters('wpinv_ipn_url', add_query_arg($args, home_url('index.php')), $gateway, $args); |
|
413 | 413 | |
414 | 414 | } |
415 | 415 | |
@@ -420,34 +420,34 @@ discard block |
||
420 | 420 | * |
421 | 421 | * @return string |
422 | 422 | */ |
423 | -function getpaid_get_non_query_string_ipn_url( $gateway ) { |
|
424 | - $gateway = wpinv_sanitize_key( $gateway ); |
|
425 | - return home_url( "getpaid-ipn/$gateway" ); |
|
423 | +function getpaid_get_non_query_string_ipn_url($gateway) { |
|
424 | + $gateway = wpinv_sanitize_key($gateway); |
|
425 | + return home_url("getpaid-ipn/$gateway"); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | |
429 | 429 | /** |
430 | 430 | * Retrieves request data with slashes removed slashes. |
431 | 431 | */ |
432 | -function wpinv_get_post_data( $method = 'request' ) { |
|
432 | +function wpinv_get_post_data($method = 'request') { |
|
433 | 433 | |
434 | - if ( $method == 'post' ) { |
|
435 | - return wp_unslash( $_POST ); |
|
434 | + if ($method == 'post') { |
|
435 | + return wp_unslash($_POST); |
|
436 | 436 | } |
437 | 437 | |
438 | - if ( $method == 'get' ) { |
|
439 | - return wp_unslash( $_GET ); |
|
438 | + if ($method == 'get') { |
|
439 | + return wp_unslash($_GET); |
|
440 | 440 | } |
441 | 441 | |
442 | - return wp_unslash( $_REQUEST ); |
|
442 | + return wp_unslash($_REQUEST); |
|
443 | 443 | |
444 | 444 | } |
445 | 445 | |
446 | 446 | /** |
447 | 447 | * Checks if a given gateway supports subscription payments. |
448 | 448 | */ |
449 | -function wpinv_gateway_support_subscription( $gateway ) { |
|
450 | - return getpaid_payment_gateway_supports( $gateway, 'subscription' ); |
|
449 | +function wpinv_gateway_support_subscription($gateway) { |
|
450 | + return getpaid_payment_gateway_supports($gateway, 'subscription'); |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | /** |
@@ -456,14 +456,14 @@ discard block |
||
456 | 456 | * @param array $gateways an array of gateways. |
457 | 457 | * @param GetPaid_Payment_Form $form payment form. |
458 | 458 | */ |
459 | -function wpinv_payment_gateways_on_cart( $gateways, $form ) { |
|
459 | +function wpinv_payment_gateways_on_cart($gateways, $form) { |
|
460 | 460 | |
461 | - if ( $form->is_recurring() ) { |
|
461 | + if ($form->is_recurring()) { |
|
462 | 462 | |
463 | - foreach ( array_keys( $gateways ) as $gateway ) { |
|
463 | + foreach (array_keys($gateways) as $gateway) { |
|
464 | 464 | |
465 | - if ( ! wpinv_gateway_support_subscription( $gateway ) ) { |
|
466 | - unset( $gateways[$gateway] ); |
|
465 | + if (!wpinv_gateway_support_subscription($gateway)) { |
|
466 | + unset($gateways[$gateway]); |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | } |
@@ -472,4 +472,4 @@ discard block |
||
472 | 472 | |
473 | 473 | return $gateways; |
474 | 474 | } |
475 | -add_filter( 'getpaid_payment_form_gateways', 'wpinv_payment_gateways_on_cart', 10, 2 ); |
|
475 | +add_filter('getpaid_payment_form_gateways', 'wpinv_payment_gateways_on_cart', 10, 2); |