@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -29,20 +29,20 @@ discard block |
||
29 | 29 | function give_process_donation_form() { |
30 | 30 | |
31 | 31 | // Sanitize Posted Data. |
32 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, CSRF ok. |
|
32 | + $post_data = give_clean($_POST); // WPCS: input var ok, CSRF ok. |
|
33 | 33 | |
34 | 34 | // Check whether the form submitted via AJAX or not. |
35 | - $is_ajax = isset( $post_data['give_ajax'] ); |
|
35 | + $is_ajax = isset($post_data['give_ajax']); |
|
36 | 36 | |
37 | 37 | // Verify donation form nonce. |
38 | - if ( ! give_verify_donation_form_nonce( $post_data['give-form-hash'], $post_data['give-form-id'] ) ) { |
|
39 | - if ( $is_ajax ) { |
|
38 | + if ( ! give_verify_donation_form_nonce($post_data['give-form-hash'], $post_data['give-form-id'])) { |
|
39 | + if ($is_ajax) { |
|
40 | 40 | /** |
41 | 41 | * Fires when AJAX sends back errors from the donation form. |
42 | 42 | * |
43 | 43 | * @since 1.0 |
44 | 44 | */ |
45 | - do_action( 'give_ajax_donation_errors' ); |
|
45 | + do_action('give_ajax_donation_errors'); |
|
46 | 46 | give_die(); |
47 | 47 | } else { |
48 | 48 | give_send_back_to_checkout(); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @since 1.0 |
56 | 56 | */ |
57 | - do_action( 'give_pre_process_donation' ); |
|
57 | + do_action('give_pre_process_donation'); |
|
58 | 58 | |
59 | 59 | // Validate the form $_POST data. |
60 | 60 | $valid_data = give_donation_form_validate_fields(); |
@@ -70,24 +70,24 @@ discard block |
||
70 | 70 | * @param array $deprecated Deprecated Since 2.0.2. Use $_POST instead. |
71 | 71 | */ |
72 | 72 | $deprecated = $post_data; |
73 | - do_action( 'give_checkout_error_checks', $valid_data, $deprecated ); |
|
73 | + do_action('give_checkout_error_checks', $valid_data, $deprecated); |
|
74 | 74 | |
75 | 75 | // Process the login form. |
76 | - if ( isset( $post_data['give_login_submit'] ) ) { |
|
76 | + if (isset($post_data['give_login_submit'])) { |
|
77 | 77 | give_process_form_login(); |
78 | 78 | } |
79 | 79 | |
80 | 80 | // Validate the user. |
81 | - $user = give_get_donation_form_user( $valid_data ); |
|
81 | + $user = give_get_donation_form_user($valid_data); |
|
82 | 82 | |
83 | - if ( false === $valid_data || give_get_errors() || ! $user ) { |
|
84 | - if ( $is_ajax ) { |
|
83 | + if (false === $valid_data || give_get_errors() || ! $user) { |
|
84 | + if ($is_ajax) { |
|
85 | 85 | /** |
86 | 86 | * Fires when AJAX sends back errors from the donation form. |
87 | 87 | * |
88 | 88 | * @since 1.0 |
89 | 89 | */ |
90 | - do_action( 'give_ajax_donation_errors' ); |
|
90 | + do_action('give_ajax_donation_errors'); |
|
91 | 91 | give_die(); |
92 | 92 | } else { |
93 | 93 | return false; |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | } |
96 | 96 | |
97 | 97 | // If AJAX send back success to proceed with form submission. |
98 | - if ( $is_ajax ) { |
|
98 | + if ($is_ajax) { |
|
99 | 99 | echo 'success'; |
100 | 100 | give_die(); |
101 | 101 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @since 2.2.0 |
107 | 107 | */ |
108 | - do_action( 'give_process_donation_after_validation' ); |
|
108 | + do_action('give_process_donation_after_validation'); |
|
109 | 109 | |
110 | 110 | // Setup user information. |
111 | 111 | $user_info = array( |
@@ -117,15 +117,14 @@ discard block |
||
117 | 117 | 'address' => $user['address'], |
118 | 118 | ); |
119 | 119 | |
120 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
120 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
121 | 121 | |
122 | 122 | // Donation form ID. |
123 | - $form_id = isset( $post_data['give-form-id'] ) ? absint( $post_data['give-form-id'] ) : 0; |
|
123 | + $form_id = isset($post_data['give-form-id']) ? absint($post_data['give-form-id']) : 0; |
|
124 | 124 | |
125 | - $price = isset( $post_data['give-amount'] ) ? |
|
126 | - (float) apply_filters( 'give_donation_total', give_maybe_sanitize_amount( $post_data['give-amount'], array( 'currency' => give_get_currency( $form_id ) ) ) ) : |
|
127 | - '0.00'; |
|
128 | - $purchase_key = strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) ); |
|
125 | + $price = isset($post_data['give-amount']) ? |
|
126 | + (float) apply_filters('give_donation_total', give_maybe_sanitize_amount($post_data['give-amount'], array('currency' => give_get_currency($form_id)))) : '0.00'; |
|
127 | + $purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); |
|
129 | 128 | |
130 | 129 | /** |
131 | 130 | * Update Purchase key. |
@@ -140,15 +139,15 @@ discard block |
||
140 | 139 | * |
141 | 140 | * @return string $purchase_key |
142 | 141 | */ |
143 | - $purchase_key = apply_filters( 'give_purchase_key', $purchase_key, $valid_data['gateway'] ); |
|
142 | + $purchase_key = apply_filters('give_purchase_key', $purchase_key, $valid_data['gateway']); |
|
144 | 143 | |
145 | 144 | // Setup donation information. |
146 | 145 | $donation_data = array( |
147 | 146 | 'price' => $price, |
148 | 147 | 'purchase_key' => $purchase_key, |
149 | 148 | 'user_email' => $user['user_email'], |
150 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), |
|
151 | - 'user_info' => stripslashes_deep( $user_info ), |
|
149 | + 'date' => date('Y-m-d H:i:s', current_time('timestamp')), |
|
150 | + 'user_info' => stripslashes_deep($user_info), |
|
152 | 151 | 'post_data' => $post_data, |
153 | 152 | 'gateway' => $valid_data['gateway'], |
154 | 153 | 'card_info' => $valid_data['cc_info'], |
@@ -168,10 +167,10 @@ discard block |
||
168 | 167 | * @param array $user_info Array containing basic user information. |
169 | 168 | * @param bool|array $valid_data Validate fields. |
170 | 169 | */ |
171 | - do_action( 'give_checkout_before_gateway', $post_data, $user_info, $valid_data ); |
|
170 | + do_action('give_checkout_before_gateway', $post_data, $user_info, $valid_data); |
|
172 | 171 | |
173 | 172 | // Sanity check for price. |
174 | - if ( ! $donation_data['price'] ) { |
|
173 | + if ( ! $donation_data['price']) { |
|
175 | 174 | // Revert to manual. |
176 | 175 | $donation_data['gateway'] = 'manual'; |
177 | 176 | $_POST['give-gateway'] = 'manual'; |
@@ -182,26 +181,26 @@ discard block |
||
182 | 181 | * |
183 | 182 | * @since 1.7 |
184 | 183 | */ |
185 | - $donation_data = apply_filters( 'give_donation_data_before_gateway', $donation_data, $valid_data ); |
|
184 | + $donation_data = apply_filters('give_donation_data_before_gateway', $donation_data, $valid_data); |
|
186 | 185 | |
187 | 186 | // Setup the data we're storing in the donation session. |
188 | 187 | $session_data = $donation_data; |
189 | 188 | |
190 | 189 | // Make sure credit card numbers are never stored in sessions. |
191 | - unset( $session_data['card_info']['card_number'] ); |
|
192 | - unset( $session_data['post_data']['card_number'] ); |
|
190 | + unset($session_data['card_info']['card_number']); |
|
191 | + unset($session_data['post_data']['card_number']); |
|
193 | 192 | |
194 | 193 | // Used for showing data to non logged-in users after donation, and for other plugins needing donation data. |
195 | - give_set_purchase_session( $session_data ); |
|
194 | + give_set_purchase_session($session_data); |
|
196 | 195 | |
197 | 196 | // Send info to the gateway for payment processing. |
198 | - give_send_to_gateway( $donation_data['gateway'], $donation_data ); |
|
197 | + give_send_to_gateway($donation_data['gateway'], $donation_data); |
|
199 | 198 | give_die(); |
200 | 199 | } |
201 | 200 | |
202 | -add_action( 'give_purchase', 'give_process_donation_form' ); |
|
203 | -add_action( 'wp_ajax_give_process_donation', 'give_process_donation_form' ); |
|
204 | -add_action( 'wp_ajax_nopriv_give_process_donation', 'give_process_donation_form' ); |
|
201 | +add_action('give_purchase', 'give_process_donation_form'); |
|
202 | +add_action('wp_ajax_give_process_donation', 'give_process_donation_form'); |
|
203 | +add_action('wp_ajax_nopriv_give_process_donation', 'give_process_donation_form'); |
|
205 | 204 | |
206 | 205 | /** |
207 | 206 | * Verify that when a logged in user makes a donation that the email address used doesn't belong to a different customer. |
@@ -212,27 +211,27 @@ discard block |
||
212 | 211 | * |
213 | 212 | * @return void |
214 | 213 | */ |
215 | -function give_check_logged_in_user_for_existing_email( $valid_data ) { |
|
214 | +function give_check_logged_in_user_for_existing_email($valid_data) { |
|
216 | 215 | |
217 | 216 | // Verify that the email address belongs to this customer. |
218 | - if ( is_user_logged_in() ) { |
|
217 | + if (is_user_logged_in()) { |
|
219 | 218 | |
220 | 219 | $submitted_email = $valid_data['logged_in_user']['user_email']; |
221 | - $donor = new Give_Donor( get_current_user_id(), true ); |
|
220 | + $donor = new Give_Donor(get_current_user_id(), true); |
|
222 | 221 | |
223 | 222 | // If this email address is not registered with this customer, see if it belongs to any other customer. |
224 | 223 | if ( |
225 | 224 | $submitted_email !== $donor->email |
226 | - && ( is_array( $donor->emails ) && ! in_array( $submitted_email, $donor->emails, true ) ) |
|
225 | + && (is_array($donor->emails) && ! in_array($submitted_email, $donor->emails, true)) |
|
227 | 226 | ) { |
228 | - $found_donor = new Give_Donor( $submitted_email ); |
|
227 | + $found_donor = new Give_Donor($submitted_email); |
|
229 | 228 | |
230 | - if ( $found_donor->id > 0 ) { |
|
229 | + if ($found_donor->id > 0) { |
|
231 | 230 | give_set_error( |
232 | 231 | 'give-customer-email-exists', |
233 | 232 | sprintf( |
234 | 233 | /* translators: 1. Donor Email, 2. Submitted Email */ |
235 | - __( 'You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.', 'give' ), |
|
234 | + __('You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.', 'give'), |
|
236 | 235 | $donor->email, |
237 | 236 | $submitted_email |
238 | 237 | ) |
@@ -242,7 +241,7 @@ discard block |
||
242 | 241 | } |
243 | 242 | } |
244 | 243 | |
245 | -add_action( 'give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 1 ); |
|
244 | +add_action('give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 1); |
|
246 | 245 | |
247 | 246 | /** |
248 | 247 | * Process the checkout login form |
@@ -254,49 +253,49 @@ discard block |
||
254 | 253 | */ |
255 | 254 | function give_process_form_login() { |
256 | 255 | |
257 | - $is_ajax = ! empty( $_POST['give_ajax'] ) ? give_clean( $_POST['give_ajax'] ) : 0; // WPCS: input var ok, sanitization ok, CSRF ok. |
|
256 | + $is_ajax = ! empty($_POST['give_ajax']) ? give_clean($_POST['give_ajax']) : 0; // WPCS: input var ok, sanitization ok, CSRF ok. |
|
258 | 257 | $referrer = wp_get_referer(); |
259 | 258 | $user_data = give_donation_form_validate_user_login(); |
260 | 259 | |
261 | - if ( give_get_errors() || $user_data['user_id'] < 1 ) { |
|
262 | - if ( $is_ajax ) { |
|
260 | + if (give_get_errors() || $user_data['user_id'] < 1) { |
|
261 | + if ($is_ajax) { |
|
263 | 262 | /** |
264 | 263 | * Fires when AJAX sends back errors from the donation form. |
265 | 264 | * |
266 | 265 | * @since 1.0 |
267 | 266 | */ |
268 | 267 | ob_start(); |
269 | - do_action( 'give_ajax_donation_errors' ); |
|
268 | + do_action('give_ajax_donation_errors'); |
|
270 | 269 | $message = ob_get_contents(); |
271 | 270 | ob_end_clean(); |
272 | - wp_send_json_error( $message ); |
|
271 | + wp_send_json_error($message); |
|
273 | 272 | } else { |
274 | - wp_safe_redirect( $referrer ); |
|
273 | + wp_safe_redirect($referrer); |
|
275 | 274 | exit; |
276 | 275 | } |
277 | 276 | } |
278 | 277 | |
279 | - give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] ); |
|
278 | + give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']); |
|
280 | 279 | |
281 | - if ( $is_ajax ) { |
|
280 | + if ($is_ajax) { |
|
282 | 281 | $message = Give()->notices->print_frontend_notice( |
283 | 282 | sprintf( |
284 | 283 | /* translators: %s: user first name */ |
285 | - esc_html__( 'Welcome %s! You have successfully logged into your account.', 'give' ), |
|
286 | - ( ! empty( $user_data['user_first'] ) ) ? $user_data['user_first'] : $user_data['user_login'] |
|
284 | + esc_html__('Welcome %s! You have successfully logged into your account.', 'give'), |
|
285 | + ( ! empty($user_data['user_first'])) ? $user_data['user_first'] : $user_data['user_login'] |
|
287 | 286 | ), |
288 | 287 | false, |
289 | 288 | 'success' |
290 | 289 | ); |
291 | 290 | |
292 | - wp_send_json_success( $message ); |
|
291 | + wp_send_json_success($message); |
|
293 | 292 | } else { |
294 | - wp_safe_redirect( $referrer ); |
|
293 | + wp_safe_redirect($referrer); |
|
295 | 294 | } |
296 | 295 | } |
297 | 296 | |
298 | -add_action( 'wp_ajax_give_process_donation_login', 'give_process_form_login' ); |
|
299 | -add_action( 'wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login' ); |
|
297 | +add_action('wp_ajax_give_process_donation_login', 'give_process_form_login'); |
|
298 | +add_action('wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login'); |
|
300 | 299 | |
301 | 300 | /** |
302 | 301 | * Donation Form Validate Fields. |
@@ -308,49 +307,49 @@ discard block |
||
308 | 307 | */ |
309 | 308 | function give_donation_form_validate_fields() { |
310 | 309 | |
311 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
310 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
312 | 311 | |
313 | 312 | // Validate Honeypot First. |
314 | - if ( ! empty( $post_data['give-honeypot'] ) ) { |
|
315 | - give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) ); |
|
313 | + if ( ! empty($post_data['give-honeypot'])) { |
|
314 | + give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give')); |
|
316 | 315 | } |
317 | 316 | |
318 | 317 | // Check spam detect. |
319 | 318 | if ( |
320 | - isset( $post_data['action'] ) && |
|
321 | - give_is_setting_enabled( give_get_option( 'akismet_spam_protection' ) ) && |
|
319 | + isset($post_data['action']) && |
|
320 | + give_is_setting_enabled(give_get_option('akismet_spam_protection')) && |
|
322 | 321 | give_is_spam_donation() |
323 | 322 | ) { |
324 | - give_set_error( 'spam_donation', __( 'This donation has been flagged as spam. Please try again.', 'give' ) ); |
|
323 | + give_set_error('spam_donation', __('This donation has been flagged as spam. Please try again.', 'give')); |
|
325 | 324 | } |
326 | 325 | |
327 | 326 | // Start an array to collect valid data. |
328 | 327 | $valid_data = array( |
329 | 328 | 'gateway' => give_donation_form_validate_gateway(), // Gateway fallback (amount is validated here). |
330 | - 'need_new_user' => false, // New user flag. |
|
331 | - 'need_user_login' => false, // Login user flag. |
|
332 | - 'logged_user_data' => array(), // Logged user collected data. |
|
333 | - 'new_user_data' => array(), // New user collected data. |
|
334 | - 'login_user_data' => array(), // Login user collected data. |
|
335 | - 'guest_user_data' => array(), // Guest user collected data. |
|
329 | + 'need_new_user' => false, // New user flag. |
|
330 | + 'need_user_login' => false, // Login user flag. |
|
331 | + 'logged_user_data' => array(), // Logged user collected data. |
|
332 | + 'new_user_data' => array(), // New user collected data. |
|
333 | + 'login_user_data' => array(), // Login user collected data. |
|
334 | + 'guest_user_data' => array(), // Guest user collected data. |
|
336 | 335 | 'cc_info' => give_donation_form_validate_cc(), // Credit card info. |
337 | 336 | ); |
338 | 337 | |
339 | - $form_id = intval( $post_data['give-form-id'] ); |
|
338 | + $form_id = intval($post_data['give-form-id']); |
|
340 | 339 | |
341 | 340 | // Validate agree to terms. |
342 | - if ( give_is_terms_enabled( $form_id ) ) { |
|
341 | + if (give_is_terms_enabled($form_id)) { |
|
343 | 342 | give_donation_form_validate_agree_to_terms(); |
344 | 343 | } |
345 | 344 | |
346 | - if ( is_user_logged_in() ) { |
|
345 | + if (is_user_logged_in()) { |
|
347 | 346 | |
348 | 347 | // Collect logged in user data. |
349 | 348 | $valid_data['logged_in_user'] = give_donation_form_validate_logged_in_user(); |
350 | 349 | } elseif ( |
351 | - isset( $post_data['give-purchase-var'] ) && |
|
350 | + isset($post_data['give-purchase-var']) && |
|
352 | 351 | 'needs-to-register' === $post_data['give-purchase-var'] && |
353 | - ! empty( $post_data['give_create_account'] ) |
|
352 | + ! empty($post_data['give_create_account']) |
|
354 | 353 | ) { |
355 | 354 | |
356 | 355 | // Set new user registration as required. |
@@ -359,7 +358,7 @@ discard block |
||
359 | 358 | // Validate new user data. |
360 | 359 | $valid_data['new_user_data'] = give_donation_form_validate_new_user(); |
361 | 360 | } elseif ( |
362 | - isset( $post_data['give-purchase-var'] ) && |
|
361 | + isset($post_data['give-purchase-var']) && |
|
363 | 362 | 'needs-to-login' === $post_data['give-purchase-var'] |
364 | 363 | ) { |
365 | 364 | |
@@ -388,14 +387,14 @@ discard block |
||
388 | 387 | function give_is_spam_donation() { |
389 | 388 | $spam = false; |
390 | 389 | |
391 | - $user_agent = (string) isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : ''; |
|
390 | + $user_agent = (string) isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; |
|
392 | 391 | |
393 | - if ( strlen( $user_agent ) < 2 ) { |
|
392 | + if (strlen($user_agent) < 2) { |
|
394 | 393 | $spam = true; |
395 | 394 | } |
396 | 395 | |
397 | 396 | // Allow developer to customized Akismet spam detect API call and it's response. |
398 | - return apply_filters( 'give_spam', $spam ); |
|
397 | + return apply_filters('give_spam', $spam); |
|
399 | 398 | } |
400 | 399 | |
401 | 400 | /** |
@@ -410,33 +409,33 @@ discard block |
||
410 | 409 | */ |
411 | 410 | function give_donation_form_validate_gateway() { |
412 | 411 | |
413 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
414 | - $form_id = ! empty( $post_data['give-form-id'] ) ? $post_data['give-form-id'] : 0; |
|
415 | - $amount = ! empty( $post_data['give-amount'] ) ? give_maybe_sanitize_amount( $post_data['give-amount'] ) : 0; |
|
416 | - $gateway = ! empty( $post_data['give-gateway'] ) ? $post_data['give-gateway'] : 0; |
|
412 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
413 | + $form_id = ! empty($post_data['give-form-id']) ? $post_data['give-form-id'] : 0; |
|
414 | + $amount = ! empty($post_data['give-amount']) ? give_maybe_sanitize_amount($post_data['give-amount']) : 0; |
|
415 | + $gateway = ! empty($post_data['give-gateway']) ? $post_data['give-gateway'] : 0; |
|
417 | 416 | |
418 | 417 | // Bailout, if payment gateway is not submitted with donation form data. |
419 | - if ( empty( $gateway ) ) { |
|
418 | + if (empty($gateway)) { |
|
420 | 419 | |
421 | - give_set_error( 'empty_gateway', __( 'The donation form will process with a valid payment gateway.', 'give' ) ); |
|
420 | + give_set_error('empty_gateway', __('The donation form will process with a valid payment gateway.', 'give')); |
|
422 | 421 | |
423 | - } elseif ( ! give_is_gateway_active( $gateway ) ) { |
|
422 | + } elseif ( ! give_is_gateway_active($gateway)) { |
|
424 | 423 | |
425 | - give_set_error( 'invalid_gateway', __( 'The selected payment gateway is not enabled.', 'give' ) ); |
|
424 | + give_set_error('invalid_gateway', __('The selected payment gateway is not enabled.', 'give')); |
|
426 | 425 | |
427 | - } elseif ( empty( $amount ) ) { |
|
426 | + } elseif (empty($amount)) { |
|
428 | 427 | |
429 | - give_set_error( 'invalid_donation_amount', __( 'Please insert a valid donation amount.', 'give' ) ); |
|
428 | + give_set_error('invalid_donation_amount', __('Please insert a valid donation amount.', 'give')); |
|
430 | 429 | |
431 | - } elseif ( ! give_verify_minimum_price( 'minimum' ) ) { |
|
430 | + } elseif ( ! give_verify_minimum_price('minimum')) { |
|
432 | 431 | |
433 | 432 | give_set_error( |
434 | 433 | 'invalid_donation_minimum', |
435 | 434 | sprintf( |
436 | 435 | /* translators: %s: minimum donation amount */ |
437 | - __( 'This form has a minimum donation amount of %s.', 'give' ), |
|
436 | + __('This form has a minimum donation amount of %s.', 'give'), |
|
438 | 437 | give_currency_filter( |
439 | - give_format_amount( give_get_form_minimum_price( $form_id ), |
|
438 | + give_format_amount(give_get_form_minimum_price($form_id), |
|
440 | 439 | array( |
441 | 440 | 'sanitize' => false, |
442 | 441 | ) |
@@ -444,15 +443,15 @@ discard block |
||
444 | 443 | ) |
445 | 444 | ) |
446 | 445 | ); |
447 | - } elseif ( ! give_verify_minimum_price( 'maximum' ) ) { |
|
446 | + } elseif ( ! give_verify_minimum_price('maximum')) { |
|
448 | 447 | |
449 | 448 | give_set_error( |
450 | 449 | 'invalid_donation_maximum', |
451 | 450 | sprintf( |
452 | 451 | /* translators: %s: Maximum donation amount */ |
453 | - __( 'This form has a maximum donation amount of %s.', 'give' ), |
|
452 | + __('This form has a maximum donation amount of %s.', 'give'), |
|
454 | 453 | give_currency_filter( |
455 | - give_format_amount( give_get_form_maximum_price( $form_id ), |
|
454 | + give_format_amount(give_get_form_maximum_price($form_id), |
|
456 | 455 | array( |
457 | 456 | 'sanitize' => false, |
458 | 457 | ) |
@@ -478,33 +477,33 @@ discard block |
||
478 | 477 | * |
479 | 478 | * @return bool |
480 | 479 | */ |
481 | -function give_verify_minimum_price( $amount_range = 'minimum' ) { |
|
480 | +function give_verify_minimum_price($amount_range = 'minimum') { |
|
482 | 481 | |
483 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
484 | - $form_id = ! empty( $post_data['give-form-id'] ) ? $post_data['give-form-id'] : 0; |
|
485 | - $amount = ! empty( $post_data['give-amount'] ) ? give_maybe_sanitize_amount( $post_data['give-amount'], array( 'currency' => give_get_currency( $form_id ) ) ) : 0; |
|
486 | - $price_id = isset( $post_data['give-price-id'] ) ? absint( $post_data['give-price-id'] ) : ''; |
|
482 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
483 | + $form_id = ! empty($post_data['give-form-id']) ? $post_data['give-form-id'] : 0; |
|
484 | + $amount = ! empty($post_data['give-amount']) ? give_maybe_sanitize_amount($post_data['give-amount'], array('currency' => give_get_currency($form_id))) : 0; |
|
485 | + $price_id = isset($post_data['give-price-id']) ? absint($post_data['give-price-id']) : ''; |
|
487 | 486 | |
488 | - $variable_prices = give_has_variable_prices( $form_id ); |
|
489 | - $price_ids = array_map( 'absint', give_get_variable_price_ids( $form_id ) ); |
|
487 | + $variable_prices = give_has_variable_prices($form_id); |
|
488 | + $price_ids = array_map('absint', give_get_variable_price_ids($form_id)); |
|
490 | 489 | $verified_stat = false; |
491 | 490 | |
492 | - if ( $variable_prices && in_array( $price_id, $price_ids, true ) ) { |
|
491 | + if ($variable_prices && in_array($price_id, $price_ids, true)) { |
|
493 | 492 | |
494 | - $price_level_amount = give_get_price_option_amount( $form_id, $price_id ); |
|
493 | + $price_level_amount = give_get_price_option_amount($form_id, $price_id); |
|
495 | 494 | |
496 | - if ( $price_level_amount == $amount ) { |
|
495 | + if ($price_level_amount == $amount) { |
|
497 | 496 | $verified_stat = true; |
498 | 497 | } |
499 | 498 | } |
500 | 499 | |
501 | - if ( ! $verified_stat ) { |
|
502 | - switch ( $amount_range ) { |
|
500 | + if ( ! $verified_stat) { |
|
501 | + switch ($amount_range) { |
|
503 | 502 | case 'minimum' : |
504 | - $verified_stat = ( give_get_form_minimum_price( $form_id ) > $amount ) ? false : true; |
|
503 | + $verified_stat = (give_get_form_minimum_price($form_id) > $amount) ? false : true; |
|
505 | 504 | break; |
506 | 505 | case 'maximum' : |
507 | - $verified_stat = ( give_get_form_maximum_price( $form_id ) < $amount ) ? false : true; |
|
506 | + $verified_stat = (give_get_form_maximum_price($form_id) < $amount) ? false : true; |
|
508 | 507 | break; |
509 | 508 | } |
510 | 509 | } |
@@ -518,7 +517,7 @@ discard block |
||
518 | 517 | * @param string $amount_range Type of the amount. |
519 | 518 | * @param integer $form_id Give Donation Form ID. |
520 | 519 | */ |
521 | - return apply_filters( 'give_verify_minimum_maximum_price', $verified_stat, $amount_range, $form_id ); |
|
520 | + return apply_filters('give_verify_minimum_maximum_price', $verified_stat, $amount_range, $form_id); |
|
522 | 521 | } |
523 | 522 | |
524 | 523 | /** |
@@ -531,13 +530,13 @@ discard block |
||
531 | 530 | */ |
532 | 531 | function give_donation_form_validate_agree_to_terms() { |
533 | 532 | |
534 | - $agree_to_terms = ! empty( $_POST['give_agree_to_terms'] ) ? give_clean( $_POST['give_agree_to_terms'] ) : 0; // WPCS: input var ok, sanitization ok, CSRF ok. |
|
533 | + $agree_to_terms = ! empty($_POST['give_agree_to_terms']) ? give_clean($_POST['give_agree_to_terms']) : 0; // WPCS: input var ok, sanitization ok, CSRF ok. |
|
535 | 534 | |
536 | 535 | // Proceed only, if donor agreed to terms. |
537 | - if ( ! $agree_to_terms ) { |
|
536 | + if ( ! $agree_to_terms) { |
|
538 | 537 | |
539 | 538 | // User did not agree. |
540 | - give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', __( 'You must agree to the terms and conditions.', 'give' ) ) ); |
|
539 | + give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', __('You must agree to the terms and conditions.', 'give'))); |
|
541 | 540 | } |
542 | 541 | } |
543 | 542 | |
@@ -551,92 +550,92 @@ discard block |
||
551 | 550 | * |
552 | 551 | * @return array |
553 | 552 | */ |
554 | -function give_get_required_fields( $form_id ) { |
|
553 | +function give_get_required_fields($form_id) { |
|
555 | 554 | |
556 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
555 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
557 | 556 | |
558 | 557 | $required_fields = array( |
559 | 558 | 'give_email' => array( |
560 | 559 | 'error_id' => 'invalid_email', |
561 | - 'error_message' => __( 'Please enter a valid email address.', 'give' ), |
|
560 | + 'error_message' => __('Please enter a valid email address.', 'give'), |
|
562 | 561 | ), |
563 | 562 | 'give_first' => array( |
564 | 563 | 'error_id' => 'invalid_first_name', |
565 | - 'error_message' => __( 'Please enter your first name.', 'give' ), |
|
564 | + 'error_message' => __('Please enter your first name.', 'give'), |
|
566 | 565 | ), |
567 | 566 | ); |
568 | 567 | |
569 | - $name_title_prefix = give_is_name_title_prefix_required( $form_id ); |
|
570 | - if ( $name_title_prefix ) { |
|
568 | + $name_title_prefix = give_is_name_title_prefix_required($form_id); |
|
569 | + if ($name_title_prefix) { |
|
571 | 570 | $required_fields['give_title'] = array( |
572 | 571 | 'error_id' => 'invalid_title', |
573 | - 'error_message' => __( 'Please enter your title.', 'give' ), |
|
572 | + 'error_message' => __('Please enter your title.', 'give'), |
|
574 | 573 | ); |
575 | 574 | } |
576 | 575 | |
577 | - $require_address = give_require_billing_address( $payment_mode ); |
|
576 | + $require_address = give_require_billing_address($payment_mode); |
|
578 | 577 | |
579 | - if ( $require_address ) { |
|
580 | - $required_fields['card_address'] = array( |
|
578 | + if ($require_address) { |
|
579 | + $required_fields['card_address'] = array( |
|
581 | 580 | 'error_id' => 'invalid_card_address', |
582 | - 'error_message' => __( 'Please enter your primary billing address.', 'give' ), |
|
581 | + 'error_message' => __('Please enter your primary billing address.', 'give'), |
|
583 | 582 | ); |
584 | - $required_fields['card_zip'] = array( |
|
583 | + $required_fields['card_zip'] = array( |
|
585 | 584 | 'error_id' => 'invalid_zip_code', |
586 | - 'error_message' => __( 'Please enter your zip / postal code.', 'give' ), |
|
585 | + 'error_message' => __('Please enter your zip / postal code.', 'give'), |
|
587 | 586 | ); |
588 | - $required_fields['card_city'] = array( |
|
587 | + $required_fields['card_city'] = array( |
|
589 | 588 | 'error_id' => 'invalid_city', |
590 | - 'error_message' => __( 'Please enter your billing city.', 'give' ), |
|
589 | + 'error_message' => __('Please enter your billing city.', 'give'), |
|
591 | 590 | ); |
592 | 591 | $required_fields['billing_country'] = array( |
593 | 592 | 'error_id' => 'invalid_country', |
594 | - 'error_message' => __( 'Please select your billing country.', 'give' ), |
|
593 | + 'error_message' => __('Please select your billing country.', 'give'), |
|
595 | 594 | ); |
596 | 595 | |
597 | 596 | |
598 | 597 | $required_fields['card_state'] = array( |
599 | 598 | 'error_id' => 'invalid_state', |
600 | - 'error_message' => __( 'Please enter billing state / province / County.', 'give' ), |
|
599 | + 'error_message' => __('Please enter billing state / province / County.', 'give'), |
|
601 | 600 | ); |
602 | 601 | |
603 | - $country = ! empty( $_POST['billing_country'] ) ? give_clean( $_POST['billing_country'] ) : 0; // WPCS: input var ok, sanitization ok, CSRF ok. |
|
602 | + $country = ! empty($_POST['billing_country']) ? give_clean($_POST['billing_country']) : 0; // WPCS: input var ok, sanitization ok, CSRF ok. |
|
604 | 603 | |
605 | 604 | // Check if billing country already exists. |
606 | - if ( $country ) { |
|
605 | + if ($country) { |
|
607 | 606 | |
608 | 607 | // Get the country list that does not required any states init. |
609 | 608 | $states_country = give_states_not_required_country_list(); |
610 | 609 | |
611 | 610 | // Check if states is empty or not. |
612 | - if ( array_key_exists( $country, $states_country ) ) { |
|
611 | + if (array_key_exists($country, $states_country)) { |
|
613 | 612 | // If states is empty remove the required fields of state in billing cart. |
614 | - unset( $required_fields['card_state'] ); |
|
613 | + unset($required_fields['card_state']); |
|
615 | 614 | } |
616 | 615 | } |
617 | 616 | } // End if(). |
618 | 617 | |
619 | - if ( give_is_company_field_enabled( $form_id ) ) { |
|
620 | - $form_option = give_get_meta( $form_id, '_give_company_field', true ); |
|
621 | - $global_setting = give_get_option( 'company_field' ); |
|
618 | + if (give_is_company_field_enabled($form_id)) { |
|
619 | + $form_option = give_get_meta($form_id, '_give_company_field', true); |
|
620 | + $global_setting = give_get_option('company_field'); |
|
622 | 621 | |
623 | 622 | $is_company_field_required = false; |
624 | 623 | |
625 | - if ( ! empty( $form_option ) && give_is_setting_enabled( $form_option, array( 'required' ) ) ) { |
|
624 | + if ( ! empty($form_option) && give_is_setting_enabled($form_option, array('required'))) { |
|
626 | 625 | $is_company_field_required = true; |
627 | 626 | |
628 | - } elseif ( 'global' === $form_option && give_is_setting_enabled( $global_setting, array( 'required' ) ) ) { |
|
627 | + } elseif ('global' === $form_option && give_is_setting_enabled($global_setting, array('required'))) { |
|
629 | 628 | $is_company_field_required = true; |
630 | 629 | |
631 | - } elseif ( empty( $form_option ) && give_is_setting_enabled( $global_setting, array( 'required' ) ) ) { |
|
630 | + } elseif (empty($form_option) && give_is_setting_enabled($global_setting, array('required'))) { |
|
632 | 631 | $is_company_field_required = true; |
633 | 632 | |
634 | 633 | } |
635 | 634 | |
636 | - if ( $is_company_field_required ) { |
|
635 | + if ($is_company_field_required) { |
|
637 | 636 | $required_fields['give_company_name'] = array( |
638 | 637 | 'error_id' => 'invalid_company', |
639 | - 'error_message' => __( 'Please enter Company Name.', 'give' ), |
|
638 | + 'error_message' => __('Please enter Company Name.', 'give'), |
|
640 | 639 | ); |
641 | 640 | } |
642 | 641 | } |
@@ -646,7 +645,7 @@ discard block |
||
646 | 645 | * |
647 | 646 | * @since 1.7 |
648 | 647 | */ |
649 | - $required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id ); |
|
648 | + $required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id); |
|
650 | 649 | |
651 | 650 | return $required_fields; |
652 | 651 | |
@@ -661,17 +660,17 @@ discard block |
||
661 | 660 | * |
662 | 661 | * @return bool |
663 | 662 | */ |
664 | -function give_require_billing_address( $payment_mode ) { |
|
663 | +function give_require_billing_address($payment_mode) { |
|
665 | 664 | |
666 | 665 | $return = false; |
667 | - $billing_country = ! empty( $_POST['billing_country'] ) ? give_clean( $_POST['billing_country'] ) : 0; // WPCS: input var ok, sanitization ok, CSRF ok. |
|
666 | + $billing_country = ! empty($_POST['billing_country']) ? give_clean($_POST['billing_country']) : 0; // WPCS: input var ok, sanitization ok, CSRF ok. |
|
668 | 667 | |
669 | - if ( $billing_country || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) { |
|
668 | + if ($billing_country || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) { |
|
670 | 669 | $return = true; |
671 | 670 | } |
672 | 671 | |
673 | 672 | // Let payment gateways and other extensions determine if address fields should be required. |
674 | - return apply_filters( 'give_require_billing_address', $return ); |
|
673 | + return apply_filters('give_require_billing_address', $return); |
|
675 | 674 | |
676 | 675 | } |
677 | 676 | |
@@ -685,47 +684,47 @@ discard block |
||
685 | 684 | */ |
686 | 685 | function give_donation_form_validate_logged_in_user() { |
687 | 686 | |
688 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
687 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
689 | 688 | $user_id = get_current_user_id(); |
690 | - $form_id = ! empty( $post_data['give-form-id'] ) ? $post_data['give-form-id'] : 0; |
|
689 | + $form_id = ! empty($post_data['give-form-id']) ? $post_data['give-form-id'] : 0; |
|
691 | 690 | |
692 | 691 | // Start empty array to collect valid user data. |
693 | 692 | $valid_user_data = array( |
694 | 693 | |
695 | 694 | // Assume there will be errors. |
696 | - 'user_id' => - 1, |
|
695 | + 'user_id' => -1, |
|
697 | 696 | ); |
698 | 697 | |
699 | 698 | // Proceed on;y, if valid $user_id found. |
700 | - if ( $user_id > 0 ) { |
|
699 | + if ($user_id > 0) { |
|
701 | 700 | |
702 | 701 | // Get the logged in user data. |
703 | - $user_data = get_userdata( $user_id ); |
|
702 | + $user_data = get_userdata($user_id); |
|
704 | 703 | |
705 | 704 | // Validate Required Form Fields. |
706 | - give_validate_required_form_fields( $form_id ); |
|
705 | + give_validate_required_form_fields($form_id); |
|
707 | 706 | |
708 | 707 | // Verify data. |
709 | - if ( is_object( $user_data ) && $user_data->ID > 0 ) { |
|
708 | + if (is_object($user_data) && $user_data->ID > 0) { |
|
710 | 709 | |
711 | 710 | // Collected logged in user data. |
712 | 711 | $valid_user_data = array( |
713 | 712 | 'user_id' => $user_id, |
714 | - 'user_email' => ! empty( $post_data['give_email'] ) ? sanitize_email( $post_data['give_email'] ) : $user_data->user_email, |
|
715 | - 'user_first' => ! empty( $post_data['give_first'] ) ? $post_data['give_first'] : $user_data->first_name, |
|
716 | - 'user_last' => ! empty( $post_data['give_last'] ) ? $post_data['give_last'] : $user_data->last_name, |
|
713 | + 'user_email' => ! empty($post_data['give_email']) ? sanitize_email($post_data['give_email']) : $user_data->user_email, |
|
714 | + 'user_first' => ! empty($post_data['give_first']) ? $post_data['give_first'] : $user_data->first_name, |
|
715 | + 'user_last' => ! empty($post_data['give_last']) ? $post_data['give_last'] : $user_data->last_name, |
|
717 | 716 | ); |
718 | 717 | |
719 | 718 | // Validate essential form fields. |
720 | - give_donation_form_validate_name_fields( $post_data ); |
|
719 | + give_donation_form_validate_name_fields($post_data); |
|
721 | 720 | |
722 | - if ( ! is_email( $valid_user_data['user_email'] ) ) { |
|
723 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
721 | + if ( ! is_email($valid_user_data['user_email'])) { |
|
722 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
724 | 723 | } |
725 | 724 | } else { |
726 | 725 | |
727 | 726 | // Set invalid user information error. |
728 | - give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) ); |
|
727 | + give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give')); |
|
729 | 728 | } |
730 | 729 | } |
731 | 730 | |
@@ -746,7 +745,7 @@ discard block |
||
746 | 745 | $auto_generated_password = wp_generate_password(); |
747 | 746 | $default_user_data = array( |
748 | 747 | 'give-form-id' => '', |
749 | - 'user_id' => - 1, // Assume there will be errors. |
|
748 | + 'user_id' => -1, // Assume there will be errors. |
|
750 | 749 | 'user_first' => '', |
751 | 750 | 'user_last' => '', |
752 | 751 | 'give_user_login' => false, |
@@ -756,26 +755,26 @@ discard block |
||
756 | 755 | ); |
757 | 756 | |
758 | 757 | // Get data. |
759 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
760 | - $user_data = wp_parse_args( $post_data, $default_user_data ); |
|
758 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
759 | + $user_data = wp_parse_args($post_data, $default_user_data); |
|
761 | 760 | |
762 | - $form_id = absint( $user_data['give-form-id'] ); |
|
763 | - $nonce = ! empty( $post_data['give-form-user-register-hash'] ) ? $post_data['give-form-user-register-hash'] : ''; |
|
761 | + $form_id = absint($user_data['give-form-id']); |
|
762 | + $nonce = ! empty($post_data['give-form-user-register-hash']) ? $post_data['give-form-user-register-hash'] : ''; |
|
764 | 763 | |
765 | 764 | // Validate user creation nonce. |
766 | - if ( ! wp_verify_nonce( $nonce, "give_form_create_user_nonce_{$form_id}" ) ) { |
|
767 | - give_set_error( 'invalid_nonce', __( 'Nonce verification has failed.', 'give' ) ); |
|
765 | + if ( ! wp_verify_nonce($nonce, "give_form_create_user_nonce_{$form_id}")) { |
|
766 | + give_set_error('invalid_nonce', __('Nonce verification has failed.', 'give')); |
|
768 | 767 | } |
769 | 768 | |
770 | 769 | $registering_new_user = false; |
771 | 770 | |
772 | - give_donation_form_validate_name_fields( $user_data ); |
|
771 | + give_donation_form_validate_name_fields($user_data); |
|
773 | 772 | |
774 | 773 | // Start an empty array to collect valid user data. |
775 | 774 | $valid_user_data = array( |
776 | 775 | |
777 | 776 | // Assume there will be errors. |
778 | - 'user_id' => - 1, |
|
777 | + 'user_id' => -1, |
|
779 | 778 | |
780 | 779 | // Get first name. |
781 | 780 | 'user_first' => $user_data['give_first'], |
@@ -788,13 +787,13 @@ discard block |
||
788 | 787 | ); |
789 | 788 | |
790 | 789 | // Validate Required Form Fields. |
791 | - give_validate_required_form_fields( $form_id ); |
|
790 | + give_validate_required_form_fields($form_id); |
|
792 | 791 | |
793 | 792 | // Set Email as Username. |
794 | 793 | $valid_user_data['user_login'] = $user_data['give_email']; |
795 | 794 | |
796 | 795 | // Check if we have an email to verify. |
797 | - if ( give_validate_user_email( $user_data['give_email'], $registering_new_user ) ) { |
|
796 | + if (give_validate_user_email($user_data['give_email'], $registering_new_user)) { |
|
798 | 797 | $valid_user_data['user_email'] = $user_data['give_email']; |
799 | 798 | } |
800 | 799 | |
@@ -811,47 +810,47 @@ discard block |
||
811 | 810 | */ |
812 | 811 | function give_donation_form_validate_user_login() { |
813 | 812 | |
814 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
813 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
815 | 814 | |
816 | 815 | // Start an array to collect valid user data. |
817 | 816 | $valid_user_data = array( |
818 | 817 | |
819 | 818 | // Assume there will be errors. |
820 | - 'user_id' => - 1, |
|
819 | + 'user_id' => -1, |
|
821 | 820 | ); |
822 | 821 | |
823 | 822 | // Bailout, if Username is empty. |
824 | - if ( empty( $post_data['give_user_login'] ) ) { |
|
825 | - give_set_error( 'must_log_in', __( 'You must register or login to complete your donation.', 'give' ) ); |
|
823 | + if (empty($post_data['give_user_login'])) { |
|
824 | + give_set_error('must_log_in', __('You must register or login to complete your donation.', 'give')); |
|
826 | 825 | |
827 | 826 | return $valid_user_data; |
828 | 827 | } |
829 | 828 | |
830 | 829 | // Get the user by login. |
831 | - $user_data = get_user_by( 'login', strip_tags( $post_data['give_user_login'] ) ); |
|
830 | + $user_data = get_user_by('login', strip_tags($post_data['give_user_login'])); |
|
832 | 831 | |
833 | 832 | // Check if user exists. |
834 | - if ( $user_data ) { |
|
833 | + if ($user_data) { |
|
835 | 834 | |
836 | 835 | // Get password. |
837 | - $user_pass = ! empty( $post_data['give_user_pass'] ) ? $post_data['give_user_pass'] : false; |
|
836 | + $user_pass = ! empty($post_data['give_user_pass']) ? $post_data['give_user_pass'] : false; |
|
838 | 837 | |
839 | 838 | // Check user_pass. |
840 | - if ( $user_pass ) { |
|
839 | + if ($user_pass) { |
|
841 | 840 | |
842 | 841 | // Check if password is valid. |
843 | - if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) { |
|
842 | + if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) { |
|
844 | 843 | |
845 | - $current_page_url = site_url() . '/' . get_page_uri(); |
|
844 | + $current_page_url = site_url().'/'.get_page_uri(); |
|
846 | 845 | |
847 | 846 | // Incorrect password. |
848 | 847 | give_set_error( |
849 | 848 | 'password_incorrect', |
850 | 849 | sprintf( |
851 | 850 | '%1$s <a href="%2$s">%3$s</a>', |
852 | - __( 'The password you entered is incorrect.', 'give' ), |
|
853 | - wp_lostpassword_url( $current_page_url ), |
|
854 | - __( 'Reset Password', 'give' ) |
|
851 | + __('The password you entered is incorrect.', 'give'), |
|
852 | + wp_lostpassword_url($current_page_url), |
|
853 | + __('Reset Password', 'give') |
|
855 | 854 | ) |
856 | 855 | ); |
857 | 856 | |
@@ -869,11 +868,11 @@ discard block |
||
869 | 868 | } |
870 | 869 | } else { |
871 | 870 | // Empty password. |
872 | - give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) ); |
|
871 | + give_set_error('password_empty', __('Enter a password.', 'give')); |
|
873 | 872 | } |
874 | 873 | } else { |
875 | 874 | // No username. |
876 | - give_set_error( 'username_incorrect', __( 'The username you entered does not exist.', 'give' ) ); |
|
875 | + give_set_error('username_incorrect', __('The username you entered does not exist.', 'give')); |
|
877 | 876 | } // End if(). |
878 | 877 | |
879 | 878 | return $valid_user_data; |
@@ -889,8 +888,8 @@ discard block |
||
889 | 888 | */ |
890 | 889 | function give_donation_form_validate_guest_user() { |
891 | 890 | |
892 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
893 | - $form_id = ! empty( $post_data['give-form-id'] ) ? $post_data['give-form-id'] : 0; |
|
891 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
892 | + $form_id = ! empty($post_data['give-form-id']) ? $post_data['give-form-id'] : 0; |
|
894 | 893 | |
895 | 894 | // Start an array to collect valid user data. |
896 | 895 | $valid_user_data = array( |
@@ -899,22 +898,22 @@ discard block |
||
899 | 898 | ); |
900 | 899 | |
901 | 900 | // Validate name fields. |
902 | - give_donation_form_validate_name_fields( $post_data ); |
|
901 | + give_donation_form_validate_name_fields($post_data); |
|
903 | 902 | |
904 | 903 | // Validate Required Form Fields. |
905 | - give_validate_required_form_fields( $form_id ); |
|
904 | + give_validate_required_form_fields($form_id); |
|
906 | 905 | |
907 | 906 | // Get the guest email. |
908 | - $guest_email = ! empty( $post_data['give_email'] ) ? $post_data['give_email'] : false; |
|
907 | + $guest_email = ! empty($post_data['give_email']) ? $post_data['give_email'] : false; |
|
909 | 908 | |
910 | 909 | // Check email. |
911 | - if ( $guest_email && strlen( $guest_email ) > 0 ) { |
|
910 | + if ($guest_email && strlen($guest_email) > 0) { |
|
912 | 911 | |
913 | 912 | // Validate email. |
914 | - if ( ! is_email( $guest_email ) ) { |
|
913 | + if ( ! is_email($guest_email)) { |
|
915 | 914 | |
916 | 915 | // Invalid email. |
917 | - give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) ); |
|
916 | + give_set_error('email_invalid', __('Invalid email.', 'give')); |
|
918 | 917 | |
919 | 918 | } else { |
920 | 919 | |
@@ -922,15 +921,15 @@ discard block |
||
922 | 921 | $valid_user_data['user_email'] = $guest_email; |
923 | 922 | |
924 | 923 | // Get user_id from donor if exist. |
925 | - $donor = new Give_Donor( $guest_email ); |
|
924 | + $donor = new Give_Donor($guest_email); |
|
926 | 925 | |
927 | - if ( $donor->id && $donor->user_id ) { |
|
926 | + if ($donor->id && $donor->user_id) { |
|
928 | 927 | $valid_user_data['user_id'] = $donor->user_id; |
929 | 928 | } |
930 | 929 | } |
931 | 930 | } else { |
932 | 931 | // No email. |
933 | - give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) ); |
|
932 | + give_set_error('email_empty', __('Enter an email.', 'give')); |
|
934 | 933 | } |
935 | 934 | |
936 | 935 | return $valid_user_data; |
@@ -946,36 +945,36 @@ discard block |
||
946 | 945 | * |
947 | 946 | * @return integer |
948 | 947 | */ |
949 | -function give_register_and_login_new_user( $user_data = array() ) { |
|
948 | +function give_register_and_login_new_user($user_data = array()) { |
|
950 | 949 | // Verify the array. |
951 | - if ( empty( $user_data ) ) { |
|
952 | - return - 1; |
|
950 | + if (empty($user_data)) { |
|
951 | + return -1; |
|
953 | 952 | } |
954 | 953 | |
955 | - if ( give_get_errors() ) { |
|
956 | - return - 1; |
|
954 | + if (give_get_errors()) { |
|
955 | + return -1; |
|
957 | 956 | } |
958 | 957 | |
959 | - $user_args = apply_filters( 'give_insert_user_args', array( |
|
960 | - 'user_login' => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '', |
|
961 | - 'user_pass' => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '', |
|
962 | - 'user_email' => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '', |
|
963 | - 'first_name' => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '', |
|
964 | - 'last_name' => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '', |
|
965 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
966 | - 'role' => give_get_option( 'donor_default_user_role', 'give_donor' ), |
|
967 | - ), $user_data ); |
|
958 | + $user_args = apply_filters('give_insert_user_args', array( |
|
959 | + 'user_login' => isset($user_data['user_login']) ? $user_data['user_login'] : '', |
|
960 | + 'user_pass' => isset($user_data['user_pass']) ? $user_data['user_pass'] : '', |
|
961 | + 'user_email' => isset($user_data['user_email']) ? $user_data['user_email'] : '', |
|
962 | + 'first_name' => isset($user_data['user_first']) ? $user_data['user_first'] : '', |
|
963 | + 'last_name' => isset($user_data['user_last']) ? $user_data['user_last'] : '', |
|
964 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
965 | + 'role' => give_get_option('donor_default_user_role', 'give_donor'), |
|
966 | + ), $user_data); |
|
968 | 967 | |
969 | 968 | // Insert new user. |
970 | - $user_id = wp_insert_user( $user_args ); |
|
969 | + $user_id = wp_insert_user($user_args); |
|
971 | 970 | |
972 | 971 | // Validate inserted user. |
973 | - if ( is_wp_error( $user_id ) ) { |
|
974 | - return - 1; |
|
972 | + if (is_wp_error($user_id)) { |
|
973 | + return -1; |
|
975 | 974 | } |
976 | 975 | |
977 | 976 | // Allow themes and plugins to filter the user data. |
978 | - $user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args ); |
|
977 | + $user_data = apply_filters('give_insert_user_data', $user_data, $user_args); |
|
979 | 978 | |
980 | 979 | /** |
981 | 980 | * Fires after inserting user. |
@@ -985,7 +984,7 @@ discard block |
||
985 | 984 | * @param int $user_id User id. |
986 | 985 | * @param array $user_data Array containing user data. |
987 | 986 | */ |
988 | - do_action( 'give_insert_user', $user_id, $user_data ); |
|
987 | + do_action('give_insert_user', $user_id, $user_data); |
|
989 | 988 | |
990 | 989 | /** |
991 | 990 | * Filter allow user to alter if user when to login or not when user is register for the first time. |
@@ -994,9 +993,9 @@ discard block |
||
994 | 993 | * |
995 | 994 | * return bool True if login with registration and False if only want to register. |
996 | 995 | */ |
997 | - if ( true === (bool) apply_filters( 'give_log_user_in_on_register', true ) ) { |
|
996 | + if (true === (bool) apply_filters('give_log_user_in_on_register', true)) { |
|
998 | 997 | // Login new user. |
999 | - give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] ); |
|
998 | + give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']); |
|
1000 | 999 | } |
1001 | 1000 | |
1002 | 1001 | // Return user id. |
@@ -1013,33 +1012,33 @@ discard block |
||
1013 | 1012 | * |
1014 | 1013 | * @return array|bool |
1015 | 1014 | */ |
1016 | -function give_get_donation_form_user( $valid_data = array() ) { |
|
1015 | +function give_get_donation_form_user($valid_data = array()) { |
|
1017 | 1016 | |
1018 | 1017 | // Initialize user. |
1019 | 1018 | $user = false; |
1020 | - $is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
|
1021 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
1019 | + $is_ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
1020 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
1022 | 1021 | |
1023 | - if ( $is_ajax ) { |
|
1022 | + if ($is_ajax) { |
|
1024 | 1023 | |
1025 | 1024 | // Do not create or login the user during the ajax submission (check for errors only). |
1026 | 1025 | return true; |
1027 | - } elseif ( is_user_logged_in() ) { |
|
1026 | + } elseif (is_user_logged_in()) { |
|
1028 | 1027 | |
1029 | 1028 | // Set the valid user as the logged in collected data. |
1030 | 1029 | $user = $valid_data['logged_in_user']; |
1031 | - } elseif ( true === $valid_data['need_new_user'] || true === $valid_data['need_user_login'] ) { |
|
1030 | + } elseif (true === $valid_data['need_new_user'] || true === $valid_data['need_user_login']) { |
|
1032 | 1031 | |
1033 | 1032 | // New user registration. |
1034 | - if ( true === $valid_data['need_new_user'] ) { |
|
1033 | + if (true === $valid_data['need_new_user']) { |
|
1035 | 1034 | |
1036 | 1035 | // Set user. |
1037 | 1036 | $user = $valid_data['new_user_data']; |
1038 | 1037 | |
1039 | 1038 | // Register and login new user. |
1040 | - $user['user_id'] = give_register_and_login_new_user( $user ); |
|
1039 | + $user['user_id'] = give_register_and_login_new_user($user); |
|
1041 | 1040 | |
1042 | - } elseif ( true === $valid_data['need_user_login'] && ! $is_ajax ) { |
|
1041 | + } elseif (true === $valid_data['need_user_login'] && ! $is_ajax) { |
|
1043 | 1042 | |
1044 | 1043 | /** |
1045 | 1044 | * The login form is now processed in the give_process_donation_login() function. |
@@ -1051,47 +1050,47 @@ discard block |
||
1051 | 1050 | $user = $valid_data['login_user_data']; |
1052 | 1051 | |
1053 | 1052 | // Login user. |
1054 | - give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] ); |
|
1053 | + give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']); |
|
1055 | 1054 | } |
1056 | 1055 | } // End if(). |
1057 | 1056 | |
1058 | 1057 | // Check guest checkout. |
1059 | - if ( false === $user && false === give_logged_in_only( $post_data['give-form-id'] ) ) { |
|
1058 | + if (false === $user && false === give_logged_in_only($post_data['give-form-id'])) { |
|
1060 | 1059 | |
1061 | 1060 | // Set user. |
1062 | 1061 | $user = $valid_data['guest_user_data']; |
1063 | 1062 | } |
1064 | 1063 | |
1065 | 1064 | // Verify we have an user. |
1066 | - if ( false === $user || empty( $user ) ) { |
|
1065 | + if (false === $user || empty($user)) { |
|
1067 | 1066 | return false; |
1068 | 1067 | } |
1069 | 1068 | |
1070 | 1069 | // Get user first name. |
1071 | - if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) { |
|
1072 | - $user['user_first'] = isset( $post_data['give_first'] ) ? strip_tags( trim( $post_data['give_first'] ) ) : ''; |
|
1070 | + if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) { |
|
1071 | + $user['user_first'] = isset($post_data['give_first']) ? strip_tags(trim($post_data['give_first'])) : ''; |
|
1073 | 1072 | } |
1074 | 1073 | |
1075 | 1074 | // Get user last name. |
1076 | - if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) { |
|
1077 | - $user['user_last'] = isset( $post_data['give_last'] ) ? strip_tags( trim( $post_data['give_last'] ) ) : ''; |
|
1075 | + if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) { |
|
1076 | + $user['user_last'] = isset($post_data['give_last']) ? strip_tags(trim($post_data['give_last'])) : ''; |
|
1078 | 1077 | } |
1079 | 1078 | |
1080 | 1079 | // Add Title Prefix to user information. |
1081 | - if ( empty( $user['user_title'] ) || strlen( trim( $user['user_title'] ) ) < 1 ) { |
|
1082 | - $user['user_title'] = ! empty( $post_data['give_title'] ) ? strip_tags( trim( $post_data['give_title'] ) ) : ''; |
|
1080 | + if (empty($user['user_title']) || strlen(trim($user['user_title'])) < 1) { |
|
1081 | + $user['user_title'] = ! empty($post_data['give_title']) ? strip_tags(trim($post_data['give_title'])) : ''; |
|
1083 | 1082 | } |
1084 | 1083 | |
1085 | 1084 | // Get the user's billing address details. |
1086 | 1085 | $user['address'] = array(); |
1087 | - $user['address']['line1'] = ! empty( $post_data['card_address'] ) ? $post_data['card_address'] : false; |
|
1088 | - $user['address']['line2'] = ! empty( $post_data['card_address_2'] ) ? $post_data['card_address_2'] : false; |
|
1089 | - $user['address']['city'] = ! empty( $post_data['card_city'] ) ? $post_data['card_city'] : false; |
|
1090 | - $user['address']['state'] = ! empty( $post_data['card_state'] ) ? $post_data['card_state'] : false; |
|
1091 | - $user['address']['zip'] = ! empty( $post_data['card_zip'] ) ? $post_data['card_zip'] : false; |
|
1092 | - $user['address']['country'] = ! empty( $post_data['billing_country'] ) ? $post_data['billing_country'] : false; |
|
1093 | - |
|
1094 | - if ( empty( $user['address']['country'] ) ) { |
|
1086 | + $user['address']['line1'] = ! empty($post_data['card_address']) ? $post_data['card_address'] : false; |
|
1087 | + $user['address']['line2'] = ! empty($post_data['card_address_2']) ? $post_data['card_address_2'] : false; |
|
1088 | + $user['address']['city'] = ! empty($post_data['card_city']) ? $post_data['card_city'] : false; |
|
1089 | + $user['address']['state'] = ! empty($post_data['card_state']) ? $post_data['card_state'] : false; |
|
1090 | + $user['address']['zip'] = ! empty($post_data['card_zip']) ? $post_data['card_zip'] : false; |
|
1091 | + $user['address']['country'] = ! empty($post_data['billing_country']) ? $post_data['billing_country'] : false; |
|
1092 | + |
|
1093 | + if (empty($user['address']['country'])) { |
|
1095 | 1094 | $user['address'] = false; |
1096 | 1095 | } // End if(). |
1097 | 1096 | |
@@ -1112,16 +1111,16 @@ discard block |
||
1112 | 1111 | $card_data = give_get_donation_cc_info(); |
1113 | 1112 | |
1114 | 1113 | // Validate the card zip. |
1115 | - if ( ! empty( $card_data['card_zip'] ) ) { |
|
1116 | - if ( ! give_donation_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) { |
|
1117 | - give_set_error( 'invalid_cc_zip', __( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) ); |
|
1114 | + if ( ! empty($card_data['card_zip'])) { |
|
1115 | + if ( ! give_donation_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) { |
|
1116 | + give_set_error('invalid_cc_zip', __('The zip / postal code you entered for your billing address is invalid.', 'give')); |
|
1118 | 1117 | } |
1119 | 1118 | } |
1120 | 1119 | |
1121 | 1120 | // Ensure no spaces. |
1122 | - if ( ! empty( $card_data['card_number'] ) ) { |
|
1123 | - $card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs. |
|
1124 | - $card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces. |
|
1121 | + if ( ! empty($card_data['card_number'])) { |
|
1122 | + $card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs. |
|
1123 | + $card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces. |
|
1125 | 1124 | } |
1126 | 1125 | |
1127 | 1126 | // This should validate card numbers at some point too. |
@@ -1139,20 +1138,20 @@ discard block |
||
1139 | 1138 | function give_get_donation_cc_info() { |
1140 | 1139 | |
1141 | 1140 | // Sanitize the values submitted with donation form. |
1142 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
1141 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
1143 | 1142 | |
1144 | 1143 | $cc_info = array(); |
1145 | - $cc_info['card_name'] = ! empty( $post_data['card_name'] ) ? $post_data['card_name'] : ''; |
|
1146 | - $cc_info['card_number'] = ! empty( $post_data['card_number'] ) ? $post_data['card_number'] : ''; |
|
1147 | - $cc_info['card_cvc'] = ! empty( $post_data['card_cvc'] ) ? $post_data['card_cvc'] : ''; |
|
1148 | - $cc_info['card_exp_month'] = ! empty( $post_data['card_exp_month'] ) ? $post_data['card_exp_month'] : ''; |
|
1149 | - $cc_info['card_exp_year'] = ! empty( $post_data['card_exp_year'] ) ? $post_data['card_exp_year'] : ''; |
|
1150 | - $cc_info['card_address'] = ! empty( $post_data['card_address'] ) ? $post_data['card_address'] : ''; |
|
1151 | - $cc_info['card_address_2'] = ! empty( $post_data['card_address_2'] ) ? $post_data['card_address_2'] : ''; |
|
1152 | - $cc_info['card_city'] = ! empty( $post_data['card_city'] ) ? $post_data['card_city'] : ''; |
|
1153 | - $cc_info['card_state'] = ! empty( $post_data['card_state'] ) ? $post_data['card_state'] : ''; |
|
1154 | - $cc_info['card_country'] = ! empty( $post_data['billing_country'] ) ? $post_data['billing_country'] : ''; |
|
1155 | - $cc_info['card_zip'] = ! empty( $post_data['card_zip'] ) ? $post_data['card_zip'] : ''; |
|
1144 | + $cc_info['card_name'] = ! empty($post_data['card_name']) ? $post_data['card_name'] : ''; |
|
1145 | + $cc_info['card_number'] = ! empty($post_data['card_number']) ? $post_data['card_number'] : ''; |
|
1146 | + $cc_info['card_cvc'] = ! empty($post_data['card_cvc']) ? $post_data['card_cvc'] : ''; |
|
1147 | + $cc_info['card_exp_month'] = ! empty($post_data['card_exp_month']) ? $post_data['card_exp_month'] : ''; |
|
1148 | + $cc_info['card_exp_year'] = ! empty($post_data['card_exp_year']) ? $post_data['card_exp_year'] : ''; |
|
1149 | + $cc_info['card_address'] = ! empty($post_data['card_address']) ? $post_data['card_address'] : ''; |
|
1150 | + $cc_info['card_address_2'] = ! empty($post_data['card_address_2']) ? $post_data['card_address_2'] : ''; |
|
1151 | + $cc_info['card_city'] = ! empty($post_data['card_city']) ? $post_data['card_city'] : ''; |
|
1152 | + $cc_info['card_state'] = ! empty($post_data['card_state']) ? $post_data['card_state'] : ''; |
|
1153 | + $cc_info['card_country'] = ! empty($post_data['billing_country']) ? $post_data['billing_country'] : ''; |
|
1154 | + $cc_info['card_zip'] = ! empty($post_data['card_zip']) ? $post_data['card_zip'] : ''; |
|
1156 | 1155 | |
1157 | 1156 | // Return cc info. |
1158 | 1157 | return $cc_info; |
@@ -1168,14 +1167,14 @@ discard block |
||
1168 | 1167 | * |
1169 | 1168 | * @return bool|mixed |
1170 | 1169 | */ |
1171 | -function give_donation_form_validate_cc_zip( $zip = 0, $country_code = '' ) { |
|
1170 | +function give_donation_form_validate_cc_zip($zip = 0, $country_code = '') { |
|
1172 | 1171 | $ret = false; |
1173 | 1172 | |
1174 | - if ( empty( $zip ) || empty( $country_code ) ) { |
|
1173 | + if (empty($zip) || empty($country_code)) { |
|
1175 | 1174 | return $ret; |
1176 | 1175 | } |
1177 | 1176 | |
1178 | - $country_code = strtoupper( $country_code ); |
|
1177 | + $country_code = strtoupper($country_code); |
|
1179 | 1178 | |
1180 | 1179 | $zip_regex = array( |
1181 | 1180 | 'AD' => 'AD\d{3}', |
@@ -1335,11 +1334,11 @@ discard block |
||
1335 | 1334 | 'ZM' => '\d{5}', |
1336 | 1335 | ); |
1337 | 1336 | |
1338 | - if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) { |
|
1337 | + if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) { |
|
1339 | 1338 | $ret = true; |
1340 | 1339 | } |
1341 | 1340 | |
1342 | - return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code ); |
|
1341 | + return apply_filters('give_is_zip_valid', $ret, $zip, $country_code); |
|
1343 | 1342 | } |
1344 | 1343 | |
1345 | 1344 | /** |
@@ -1351,60 +1350,60 @@ discard block |
||
1351 | 1350 | * |
1352 | 1351 | * @return bool |
1353 | 1352 | */ |
1354 | -function give_validate_donation_amount( $valid_data ) { |
|
1353 | +function give_validate_donation_amount($valid_data) { |
|
1355 | 1354 | |
1356 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
1355 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
1357 | 1356 | |
1358 | 1357 | /* @var Give_Donate_Form $form */ |
1359 | - $form = new Give_Donate_Form( $post_data['give-form-id'] ); |
|
1358 | + $form = new Give_Donate_Form($post_data['give-form-id']); |
|
1360 | 1359 | |
1361 | 1360 | // Get the form currency. |
1362 | - $form_currency = give_get_currency( $post_data['give-form-id'] ); |
|
1361 | + $form_currency = give_get_currency($post_data['give-form-id']); |
|
1363 | 1362 | |
1364 | 1363 | $donation_level_matched = false; |
1365 | 1364 | |
1366 | - if ( $form->is_set_type_donation_form() ) { |
|
1365 | + if ($form->is_set_type_donation_form()) { |
|
1367 | 1366 | |
1368 | 1367 | // Sanitize donation amount. |
1369 | - $post_data['give-amount'] = give_maybe_sanitize_amount( $post_data['give-amount'], array( 'currency' => $form_currency ) ); |
|
1368 | + $post_data['give-amount'] = give_maybe_sanitize_amount($post_data['give-amount'], array('currency' => $form_currency)); |
|
1370 | 1369 | |
1371 | 1370 | // Backward compatibility. |
1372 | - if ( $form->is_custom_price( $post_data['give-amount'] ) ) { |
|
1371 | + if ($form->is_custom_price($post_data['give-amount'])) { |
|
1373 | 1372 | $post_data['give-price-id'] = 'custom'; |
1374 | 1373 | } |
1375 | 1374 | |
1376 | 1375 | $donation_level_matched = true; |
1377 | 1376 | |
1378 | - } elseif ( $form->is_multi_type_donation_form() ) { |
|
1377 | + } elseif ($form->is_multi_type_donation_form()) { |
|
1379 | 1378 | |
1380 | 1379 | $variable_prices = $form->get_prices(); |
1381 | 1380 | |
1382 | 1381 | // Bailout. |
1383 | - if ( ! $variable_prices ) { |
|
1382 | + if ( ! $variable_prices) { |
|
1384 | 1383 | return false; |
1385 | 1384 | } |
1386 | 1385 | |
1387 | 1386 | // Sanitize donation amount. |
1388 | - $post_data['give-amount'] = give_maybe_sanitize_amount( $post_data['give-amount'], array( 'currency' => $form_currency ) ); |
|
1389 | - $variable_price_option_amount = give_maybe_sanitize_amount( give_get_price_option_amount( $post_data['give-form-id'], $post_data['give-price-id'] ), array( 'currency' => $form_currency ) ); |
|
1387 | + $post_data['give-amount'] = give_maybe_sanitize_amount($post_data['give-amount'], array('currency' => $form_currency)); |
|
1388 | + $variable_price_option_amount = give_maybe_sanitize_amount(give_get_price_option_amount($post_data['give-form-id'], $post_data['give-price-id']), array('currency' => $form_currency)); |
|
1390 | 1389 | $new_price_id = ''; |
1391 | 1390 | |
1392 | - if ( $post_data['give-amount'] === $variable_price_option_amount ) { |
|
1391 | + if ($post_data['give-amount'] === $variable_price_option_amount) { |
|
1393 | 1392 | return true; |
1394 | 1393 | } |
1395 | 1394 | |
1396 | - if ( $form->is_custom_price( $post_data['give-amount'] ) ) { |
|
1395 | + if ($form->is_custom_price($post_data['give-amount'])) { |
|
1397 | 1396 | $new_price_id = 'custom'; |
1398 | 1397 | } else { |
1399 | 1398 | |
1400 | 1399 | // Find correct donation level from all donation levels. |
1401 | - foreach ( $variable_prices as $variable_price ) { |
|
1400 | + foreach ($variable_prices as $variable_price) { |
|
1402 | 1401 | |
1403 | 1402 | // Sanitize level amount. |
1404 | - $variable_price['_give_amount'] = give_maybe_sanitize_amount( $variable_price['_give_amount'] ); |
|
1403 | + $variable_price['_give_amount'] = give_maybe_sanitize_amount($variable_price['_give_amount']); |
|
1405 | 1404 | |
1406 | 1405 | // Set first match donation level ID. |
1407 | - if ( $post_data['give-amount'] === $variable_price['_give_amount'] ) { |
|
1406 | + if ($post_data['give-amount'] === $variable_price['_give_amount']) { |
|
1408 | 1407 | $new_price_id = $variable_price['_give_id']['level_id']; |
1409 | 1408 | break; |
1410 | 1409 | } |
@@ -1413,26 +1412,26 @@ discard block |
||
1413 | 1412 | |
1414 | 1413 | // If donation amount is not find in donation levels then check if form has custom donation feature enable or not. |
1415 | 1414 | // If yes then set price id to custom if amount is greater then custom minimum amount (if any). |
1416 | - if ( $post_data['give-price-id'] === $new_price_id ) { |
|
1415 | + if ($post_data['give-price-id'] === $new_price_id) { |
|
1417 | 1416 | $donation_level_matched = true; |
1418 | 1417 | } |
1419 | 1418 | } // End if(). |
1420 | 1419 | |
1421 | - if ( ! $donation_level_matched ) { |
|
1420 | + if ( ! $donation_level_matched) { |
|
1422 | 1421 | give_set_error( |
1423 | 1422 | 'invalid_donation_amount', |
1424 | 1423 | sprintf( |
1425 | 1424 | /* translators: %s: invalid donation amount */ |
1426 | - __( 'Donation amount %s is invalid.', 'give' ), |
|
1425 | + __('Donation amount %s is invalid.', 'give'), |
|
1427 | 1426 | give_currency_filter( |
1428 | - give_format_amount( $post_data['give-amount'], array( 'sanitize' => false, ) ) |
|
1427 | + give_format_amount($post_data['give-amount'], array('sanitize' => false,)) |
|
1429 | 1428 | ) |
1430 | 1429 | ) |
1431 | 1430 | ); |
1432 | 1431 | } |
1433 | 1432 | } |
1434 | 1433 | |
1435 | -add_action( 'give_checkout_error_checks', 'give_validate_donation_amount', 10, 1 ); |
|
1434 | +add_action('give_checkout_error_checks', 'give_validate_donation_amount', 10, 1); |
|
1436 | 1435 | |
1437 | 1436 | /** |
1438 | 1437 | * Validate Required Form Fields. |
@@ -1441,20 +1440,20 @@ discard block |
||
1441 | 1440 | * |
1442 | 1441 | * @since 2.0 |
1443 | 1442 | */ |
1444 | -function give_validate_required_form_fields( $form_id ) { |
|
1443 | +function give_validate_required_form_fields($form_id) { |
|
1445 | 1444 | |
1446 | 1445 | // Sanitize values submitted with donation form. |
1447 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
1446 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
1448 | 1447 | |
1449 | 1448 | // Loop through required fields and show error messages. |
1450 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
1449 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
1451 | 1450 | |
1452 | 1451 | // Clean Up Data of the input fields. |
1453 | - $field_value = $post_data[ $field_name ]; |
|
1452 | + $field_value = $post_data[$field_name]; |
|
1454 | 1453 | |
1455 | 1454 | // Check whether the required field is empty, then show the error message. |
1456 | - if ( in_array( $value, give_get_required_fields( $form_id ), true ) && empty( $field_value ) ) { |
|
1457 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
1455 | + if (in_array($value, give_get_required_fields($form_id), true) && empty($field_value)) { |
|
1456 | + give_set_error($value['error_id'], $value['error_message']); |
|
1458 | 1457 | } |
1459 | 1458 | } |
1460 | 1459 | } |
@@ -1468,12 +1467,12 @@ discard block |
||
1468 | 1467 | * |
1469 | 1468 | * @return void |
1470 | 1469 | */ |
1471 | -function give_donation_form_validate_name_fields( $post_data ) { |
|
1470 | +function give_donation_form_validate_name_fields($post_data) { |
|
1472 | 1471 | |
1473 | - $is_alpha_first_name = ( ! is_email( $post_data['give_first'] ) && ! preg_match( '~[0-9]~', $post_data['give_first'] ) ); |
|
1474 | - $is_alpha_last_name = ( ! is_email( $post_data['give_last'] ) && ! preg_match( '~[0-9]~', $post_data['give_last'] ) ); |
|
1472 | + $is_alpha_first_name = ( ! is_email($post_data['give_first']) && ! preg_match('~[0-9]~', $post_data['give_first'])); |
|
1473 | + $is_alpha_last_name = ( ! is_email($post_data['give_last']) && ! preg_match('~[0-9]~', $post_data['give_last'])); |
|
1475 | 1474 | |
1476 | - if ( ! $is_alpha_first_name || ( ! empty( $post_data['give_last'] ) && ! $is_alpha_last_name ) ) { |
|
1477 | - give_set_error( 'invalid_name', esc_html__( 'The First Name and Last Name fields cannot contain an email address or numbers.', 'give' ) ); |
|
1475 | + if ( ! $is_alpha_first_name || ( ! empty($post_data['give_last']) && ! $is_alpha_last_name)) { |
|
1476 | + give_set_error('invalid_name', esc_html__('The First Name and Last Name fields cannot contain an email address or numbers.', 'give')); |
|
1478 | 1477 | } |
1479 | 1478 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @since 1.0 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
@@ -22,10 +22,10 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @return bool |
24 | 24 | */ |
25 | -function give_paypal_standard_billing_fields( $form_id ) { |
|
25 | +function give_paypal_standard_billing_fields($form_id) { |
|
26 | 26 | |
27 | - if ( give_is_setting_enabled( give_get_option( 'paypal_standard_billing_details' ) ) ) { |
|
28 | - give_default_cc_address_fields( $form_id ); |
|
27 | + if (give_is_setting_enabled(give_get_option('paypal_standard_billing_details'))) { |
|
28 | + give_default_cc_address_fields($form_id); |
|
29 | 29 | |
30 | 30 | return true; |
31 | 31 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | |
35 | 35 | } |
36 | 36 | |
37 | -add_action( 'give_paypal_cc_form', 'give_paypal_standard_billing_fields' ); |
|
37 | +add_action('give_paypal_cc_form', 'give_paypal_standard_billing_fields'); |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * Process PayPal Payment. |
@@ -45,28 +45,28 @@ discard block |
||
45 | 45 | * |
46 | 46 | * @return void |
47 | 47 | */ |
48 | -function give_process_paypal_payment( $payment_data ) { |
|
48 | +function give_process_paypal_payment($payment_data) { |
|
49 | 49 | |
50 | 50 | // Validate nonce. |
51 | - give_validate_nonce( $payment_data['gateway_nonce'], 'give-gateway' ); |
|
51 | + give_validate_nonce($payment_data['gateway_nonce'], 'give-gateway'); |
|
52 | 52 | |
53 | - $payment_id = give_create_payment( $payment_data ); |
|
53 | + $payment_id = give_create_payment($payment_data); |
|
54 | 54 | |
55 | 55 | // Check payment. |
56 | - if ( empty( $payment_id ) ) { |
|
56 | + if (empty($payment_id)) { |
|
57 | 57 | // Record the error. |
58 | - give_record_gateway_error( __( 'Payment Error', 'give' ), sprintf( /* translators: %s: payment data */ |
|
59 | - __( 'Payment creation failed before sending donor to PayPal. Payment data: %s', 'give' ), json_encode( $payment_data ) ), $payment_id ); |
|
58 | + give_record_gateway_error(__('Payment Error', 'give'), sprintf( /* translators: %s: payment data */ |
|
59 | + __('Payment creation failed before sending donor to PayPal. Payment data: %s', 'give'), json_encode($payment_data) ), $payment_id); |
|
60 | 60 | // Problems? Send back. |
61 | - give_send_back_to_checkout( '?payment-mode=' . $payment_data['post_data']['give-gateway'] ); |
|
61 | + give_send_back_to_checkout('?payment-mode='.$payment_data['post_data']['give-gateway']); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | // Redirect to PayPal. |
65 | - wp_redirect( give_build_paypal_url( $payment_id, $payment_data ) ); |
|
65 | + wp_redirect(give_build_paypal_url($payment_id, $payment_data)); |
|
66 | 66 | exit; |
67 | 67 | } |
68 | 68 | |
69 | -add_action( 'give_gateway_paypal', 'give_process_paypal_payment' ); |
|
69 | +add_action('give_gateway_paypal', 'give_process_paypal_payment'); |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * Listens for a PayPal IPN requests and then sends to the processing function. |
@@ -77,17 +77,17 @@ discard block |
||
77 | 77 | function give_listen_for_paypal_ipn() { |
78 | 78 | |
79 | 79 | // Regular PayPal IPN. |
80 | - if ( isset( $_GET['give-listener'] ) && 'IPN' === $_GET['give-listener'] ) { |
|
80 | + if (isset($_GET['give-listener']) && 'IPN' === $_GET['give-listener']) { |
|
81 | 81 | /** |
82 | 82 | * Fires while verifying PayPal IPN |
83 | 83 | * |
84 | 84 | * @since 1.0 |
85 | 85 | */ |
86 | - do_action( 'give_verify_paypal_ipn' ); |
|
86 | + do_action('give_verify_paypal_ipn'); |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
90 | -add_action( 'init', 'give_listen_for_paypal_ipn' ); |
|
90 | +add_action('init', 'give_listen_for_paypal_ipn'); |
|
91 | 91 | |
92 | 92 | /** |
93 | 93 | * Process PayPal IPN |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | function give_process_paypal_ipn() { |
99 | 99 | |
100 | 100 | // Check the request method is POST. |
101 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) && 'POST' !== $_SERVER['REQUEST_METHOD'] ) { |
|
101 | + if (isset($_SERVER['REQUEST_METHOD']) && 'POST' !== $_SERVER['REQUEST_METHOD']) { |
|
102 | 102 | return; |
103 | 103 | } |
104 | 104 | |
@@ -106,11 +106,11 @@ discard block |
||
106 | 106 | $post_data = ''; |
107 | 107 | |
108 | 108 | // Fallback just in case post_max_size is lower than needed. |
109 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
110 | - $post_data = file_get_contents( 'php://input' ); |
|
109 | + if (ini_get('allow_url_fopen')) { |
|
110 | + $post_data = file_get_contents('php://input'); |
|
111 | 111 | } else { |
112 | 112 | // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough. |
113 | - ini_set( 'post_max_size', '12M' ); |
|
113 | + ini_set('post_max_size', '12M'); |
|
114 | 114 | } |
115 | 115 | // Start the encoded data collection with notification command. |
116 | 116 | $encoded_data = 'cmd=_notify-validate'; |
@@ -119,41 +119,41 @@ discard block |
||
119 | 119 | $arg_separator = give_get_php_arg_separator_output(); |
120 | 120 | |
121 | 121 | // Verify there is a post_data. |
122 | - if ( $post_data || strlen( $post_data ) > 0 ) { |
|
122 | + if ($post_data || strlen($post_data) > 0) { |
|
123 | 123 | // Append the data. |
124 | - $encoded_data .= $arg_separator . $post_data; |
|
124 | + $encoded_data .= $arg_separator.$post_data; |
|
125 | 125 | } else { |
126 | 126 | // Check if POST is empty. |
127 | - if ( empty( $_POST ) ) { |
|
127 | + if (empty($_POST)) { |
|
128 | 128 | // Nothing to do. |
129 | 129 | return; |
130 | 130 | } else { |
131 | 131 | // Loop through each POST. |
132 | - foreach ( $_POST as $key => $value ) { |
|
132 | + foreach ($_POST as $key => $value) { |
|
133 | 133 | // Encode the value and append the data. |
134 | - $encoded_data .= $arg_separator . "$key=" . urlencode( $value ); |
|
134 | + $encoded_data .= $arg_separator."$key=".urlencode($value); |
|
135 | 135 | } |
136 | 136 | } |
137 | 137 | } |
138 | 138 | |
139 | 139 | // Convert collected post data to an array. |
140 | - parse_str( $encoded_data, $encoded_data_array ); |
|
140 | + parse_str($encoded_data, $encoded_data_array); |
|
141 | 141 | |
142 | - foreach ( $encoded_data_array as $key => $value ) { |
|
142 | + foreach ($encoded_data_array as $key => $value) { |
|
143 | 143 | |
144 | - if ( false !== strpos( $key, 'amp;' ) ) { |
|
145 | - $new_key = str_replace( '&', '&', $key ); |
|
146 | - $new_key = str_replace( 'amp;', '&', $new_key ); |
|
144 | + if (false !== strpos($key, 'amp;')) { |
|
145 | + $new_key = str_replace('&', '&', $key); |
|
146 | + $new_key = str_replace('amp;', '&', $new_key); |
|
147 | 147 | |
148 | - unset( $encoded_data_array[ $key ] ); |
|
149 | - $encoded_data_array[ $new_key ] = $value; |
|
148 | + unset($encoded_data_array[$key]); |
|
149 | + $encoded_data_array[$new_key] = $value; |
|
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
153 | 153 | $api_response = false; |
154 | 154 | |
155 | 155 | // Validate IPN request w/ PayPal if user hasn't disabled this security measure. |
156 | - if ( give_is_setting_enabled( give_get_option( 'paypal_verification' ) ) ) { |
|
156 | + if (give_is_setting_enabled(give_get_option('paypal_verification'))) { |
|
157 | 157 | |
158 | 158 | $remote_post_vars = array( |
159 | 159 | 'method' => 'POST', |
@@ -173,25 +173,25 @@ discard block |
||
173 | 173 | ); |
174 | 174 | |
175 | 175 | // Validate the IPN. |
176 | - $api_response = wp_remote_post( give_get_paypal_redirect(), $remote_post_vars ); |
|
176 | + $api_response = wp_remote_post(give_get_paypal_redirect(), $remote_post_vars); |
|
177 | 177 | |
178 | - if ( is_wp_error( $api_response ) ) { |
|
179 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
180 | - __( 'Invalid IPN verification response. IPN data: %s', 'give' ), json_encode( $api_response ) ) ); |
|
178 | + if (is_wp_error($api_response)) { |
|
179 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
180 | + __('Invalid IPN verification response. IPN data: %s', 'give'), json_encode($api_response) )); |
|
181 | 181 | |
182 | 182 | return; // Something went wrong. |
183 | 183 | } |
184 | 184 | |
185 | - if ( 'VERIFIED' !== $api_response['body'] ) { |
|
186 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
187 | - __( 'Invalid IPN verification response. IPN data: %s', 'give' ), json_encode( $api_response ) ) ); |
|
185 | + if ('VERIFIED' !== $api_response['body']) { |
|
186 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
187 | + __('Invalid IPN verification response. IPN data: %s', 'give'), json_encode($api_response) )); |
|
188 | 188 | |
189 | 189 | return; // Response not okay. |
190 | 190 | } |
191 | 191 | }// End if(). |
192 | 192 | |
193 | 193 | // Check if $post_data_array has been populated. |
194 | - if ( ! is_array( $encoded_data_array ) && ! empty( $encoded_data_array ) ) { |
|
194 | + if ( ! is_array($encoded_data_array) && ! empty($encoded_data_array)) { |
|
195 | 195 | return; |
196 | 196 | } |
197 | 197 | |
@@ -200,28 +200,28 @@ discard block |
||
200 | 200 | 'payment_status' => '', |
201 | 201 | ); |
202 | 202 | |
203 | - $encoded_data_array = wp_parse_args( $encoded_data_array, $defaults ); |
|
203 | + $encoded_data_array = wp_parse_args($encoded_data_array, $defaults); |
|
204 | 204 | |
205 | - $payment_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0; |
|
205 | + $payment_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0; |
|
206 | 206 | $txn_type = $encoded_data_array['txn_type']; |
207 | 207 | |
208 | 208 | // Check for PayPal IPN Notifications and update data based on it. |
209 | - $current_timestamp = current_time( 'timestamp' ); |
|
209 | + $current_timestamp = current_time('timestamp'); |
|
210 | 210 | $paypal_ipn_vars = array( |
211 | - 'auth_status' => isset( $api_response['body'] ) ? $api_response['body'] : 'N/A', |
|
212 | - 'transaction_id' => isset( $encoded_data_array['txn_id'] ) ? $encoded_data_array['txn_id'] : 'N/A', |
|
211 | + 'auth_status' => isset($api_response['body']) ? $api_response['body'] : 'N/A', |
|
212 | + 'transaction_id' => isset($encoded_data_array['txn_id']) ? $encoded_data_array['txn_id'] : 'N/A', |
|
213 | 213 | 'payment_id' => $payment_id, |
214 | 214 | ); |
215 | - update_option( 'give_last_paypal_ipn_received', $paypal_ipn_vars, false ); |
|
216 | - give_insert_payment_note( $payment_id, sprintf( |
|
217 | - __( 'IPN received on %s at %s', 'give' ), |
|
218 | - date_i18n( 'm/d/Y', $current_timestamp ), |
|
219 | - date_i18n( 'H:i', $current_timestamp ) |
|
215 | + update_option('give_last_paypal_ipn_received', $paypal_ipn_vars, false); |
|
216 | + give_insert_payment_note($payment_id, sprintf( |
|
217 | + __('IPN received on %s at %s', 'give'), |
|
218 | + date_i18n('m/d/Y', $current_timestamp), |
|
219 | + date_i18n('H:i', $current_timestamp) |
|
220 | 220 | ) |
221 | 221 | ); |
222 | - give_update_meta( $payment_id, 'give_last_paypal_ipn_received', $current_timestamp ); |
|
222 | + give_update_meta($payment_id, 'give_last_paypal_ipn_received', $current_timestamp); |
|
223 | 223 | |
224 | - if ( has_action( 'give_paypal_' . $txn_type ) ) { |
|
224 | + if (has_action('give_paypal_'.$txn_type)) { |
|
225 | 225 | /** |
226 | 226 | * Fires while processing PayPal IPN $txn_type. |
227 | 227 | * |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | * @param array $encoded_data_array Encoded data. |
233 | 233 | * @param int $payment_id Payment id. |
234 | 234 | */ |
235 | - do_action( "give_paypal_{$txn_type}", $encoded_data_array, $payment_id ); |
|
235 | + do_action("give_paypal_{$txn_type}", $encoded_data_array, $payment_id); |
|
236 | 236 | } else { |
237 | 237 | /** |
238 | 238 | * Fires while process PayPal IPN. |
@@ -244,12 +244,12 @@ discard block |
||
244 | 244 | * @param array $encoded_data_array Encoded data. |
245 | 245 | * @param int $payment_id Payment id. |
246 | 246 | */ |
247 | - do_action( 'give_paypal_web_accept', $encoded_data_array, $payment_id ); |
|
247 | + do_action('give_paypal_web_accept', $encoded_data_array, $payment_id); |
|
248 | 248 | } |
249 | 249 | exit; |
250 | 250 | } |
251 | 251 | |
252 | -add_action( 'give_verify_paypal_ipn', 'give_process_paypal_ipn' ); |
|
252 | +add_action('give_verify_paypal_ipn', 'give_process_paypal_ipn'); |
|
253 | 253 | |
254 | 254 | /** |
255 | 255 | * Process web accept (one time) payment IPNs. |
@@ -261,99 +261,99 @@ discard block |
||
261 | 261 | * |
262 | 262 | * @return void |
263 | 263 | */ |
264 | -function give_process_paypal_web_accept( $data, $payment_id ) { |
|
264 | +function give_process_paypal_web_accept($data, $payment_id) { |
|
265 | 265 | |
266 | 266 | // Only allow through these transaction types. |
267 | - if ( 'web_accept' !== $data['txn_type'] && 'cart' !== $data['txn_type'] && 'refunded' !== strtolower( $data['payment_status'] ) ) { |
|
267 | + if ('web_accept' !== $data['txn_type'] && 'cart' !== $data['txn_type'] && 'refunded' !== strtolower($data['payment_status'])) { |
|
268 | 268 | return; |
269 | 269 | } |
270 | 270 | |
271 | 271 | // Need $payment_id to continue. |
272 | - if ( empty( $payment_id ) ) { |
|
272 | + if (empty($payment_id)) { |
|
273 | 273 | return; |
274 | 274 | } |
275 | 275 | |
276 | 276 | // Collect donation payment details. |
277 | 277 | $paypal_amount = $data['mc_gross']; |
278 | - $payment_status = strtolower( $data['payment_status'] ); |
|
279 | - $currency_code = strtolower( $data['mc_currency'] ); |
|
280 | - $business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] ); |
|
281 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
278 | + $payment_status = strtolower($data['payment_status']); |
|
279 | + $currency_code = strtolower($data['mc_currency']); |
|
280 | + $business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']); |
|
281 | + $payment_meta = give_get_payment_meta($payment_id); |
|
282 | 282 | |
283 | 283 | // Must be a PayPal standard IPN. |
284 | - if ( 'paypal' !== give_get_payment_gateway( $payment_id ) ) { |
|
284 | + if ('paypal' !== give_get_payment_gateway($payment_id)) { |
|
285 | 285 | return; |
286 | 286 | } |
287 | 287 | |
288 | 288 | // Verify payment recipient. |
289 | - if ( strcasecmp( $business_email, trim( give_get_option( 'paypal_email' ) ) ) !== 0 ) { |
|
289 | + if (strcasecmp($business_email, trim(give_get_option('paypal_email'))) !== 0) { |
|
290 | 290 | |
291 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
292 | - __( 'Invalid business email in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
293 | - give_update_payment_status( $payment_id, 'failed' ); |
|
294 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid PayPal business email.', 'give' ) ); |
|
291 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
292 | + __('Invalid business email in IPN response. IPN data: %s', 'give'), json_encode($data) ), $payment_id); |
|
293 | + give_update_payment_status($payment_id, 'failed'); |
|
294 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid PayPal business email.', 'give')); |
|
295 | 295 | |
296 | 296 | return; |
297 | 297 | } |
298 | 298 | |
299 | 299 | // Verify payment currency. |
300 | - if ( $currency_code !== strtolower( $payment_meta['currency'] ) ) { |
|
300 | + if ($currency_code !== strtolower($payment_meta['currency'])) { |
|
301 | 301 | |
302 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
303 | - __( 'Invalid currency in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
304 | - give_update_payment_status( $payment_id, 'failed' ); |
|
305 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid currency in PayPal IPN.', 'give' ) ); |
|
302 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
303 | + __('Invalid currency in IPN response. IPN data: %s', 'give'), json_encode($data) ), $payment_id); |
|
304 | + give_update_payment_status($payment_id, 'failed'); |
|
305 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid currency in PayPal IPN.', 'give')); |
|
306 | 306 | |
307 | 307 | return; |
308 | 308 | } |
309 | 309 | |
310 | 310 | // Process refunds & reversed. |
311 | - if ( 'refunded' === $payment_status || 'reversed' === $payment_status ) { |
|
312 | - give_process_paypal_refund( $data, $payment_id ); |
|
311 | + if ('refunded' === $payment_status || 'reversed' === $payment_status) { |
|
312 | + give_process_paypal_refund($data, $payment_id); |
|
313 | 313 | |
314 | 314 | return; |
315 | 315 | } |
316 | 316 | |
317 | 317 | // Only complete payments once. |
318 | - if ( 'publish' === get_post_status( $payment_id ) ) { |
|
318 | + if ('publish' === get_post_status($payment_id)) { |
|
319 | 319 | return; |
320 | 320 | } |
321 | 321 | |
322 | 322 | // Retrieve the total donation amount (before PayPal). |
323 | - $payment_amount = give_donation_amount( $payment_id ); |
|
323 | + $payment_amount = give_donation_amount($payment_id); |
|
324 | 324 | |
325 | 325 | // Check that the donation PP and local db amounts match. |
326 | - if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
326 | + if (number_format((float) $paypal_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
327 | 327 | // The prices don't match |
328 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
329 | - __( 'Invalid payment amount in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
330 | - give_update_payment_status( $payment_id, 'failed' ); |
|
331 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid amount in PayPal IPN.', 'give' ) ); |
|
328 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
329 | + __('Invalid payment amount in IPN response. IPN data: %s', 'give'), json_encode($data) ), $payment_id); |
|
330 | + give_update_payment_status($payment_id, 'failed'); |
|
331 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid amount in PayPal IPN.', 'give')); |
|
332 | 332 | |
333 | 333 | return; |
334 | 334 | } |
335 | 335 | |
336 | 336 | // Process completed donations. |
337 | - if ( 'completed' === $payment_status || give_is_test_mode() ) { |
|
337 | + if ('completed' === $payment_status || give_is_test_mode()) { |
|
338 | 338 | |
339 | - give_insert_payment_note( $payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
340 | - __( 'PayPal Transaction ID: %s', 'give' ), $data['txn_id'] ) ); |
|
341 | - give_set_payment_transaction_id( $payment_id, $data['txn_id'] ); |
|
342 | - give_update_payment_status( $payment_id, 'publish' ); |
|
339 | + give_insert_payment_note($payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
340 | + __('PayPal Transaction ID: %s', 'give'), $data['txn_id'] )); |
|
341 | + give_set_payment_transaction_id($payment_id, $data['txn_id']); |
|
342 | + give_update_payment_status($payment_id, 'publish'); |
|
343 | 343 | |
344 | - } elseif ( 'pending' === $payment_status && isset( $data['pending_reason'] ) ) { |
|
344 | + } elseif ('pending' === $payment_status && isset($data['pending_reason'])) { |
|
345 | 345 | |
346 | 346 | // Look for possible pending reasons, such as an echeck. |
347 | - $note = give_paypal_get_pending_donation_note( strtolower( $data['pending_reason'] ) ); |
|
347 | + $note = give_paypal_get_pending_donation_note(strtolower($data['pending_reason'])); |
|
348 | 348 | |
349 | - if ( ! empty( $note ) ) { |
|
350 | - give_insert_payment_note( $payment_id, $note ); |
|
349 | + if ( ! empty($note)) { |
|
350 | + give_insert_payment_note($payment_id, $note); |
|
351 | 351 | } |
352 | 352 | } |
353 | 353 | |
354 | 354 | } |
355 | 355 | |
356 | -add_action( 'give_paypal_web_accept', 'give_process_paypal_web_accept', 10, 2 ); |
|
356 | +add_action('give_paypal_web_accept', 'give_process_paypal_web_accept', 10, 2); |
|
357 | 357 | |
358 | 358 | /** |
359 | 359 | * Process PayPal IPN Refunds |
@@ -365,35 +365,35 @@ discard block |
||
365 | 365 | * |
366 | 366 | * @return void |
367 | 367 | */ |
368 | -function give_process_paypal_refund( $data, $payment_id = 0 ) { |
|
368 | +function give_process_paypal_refund($data, $payment_id = 0) { |
|
369 | 369 | |
370 | 370 | // Collect payment details. |
371 | - if ( empty( $payment_id ) ) { |
|
371 | + if (empty($payment_id)) { |
|
372 | 372 | return; |
373 | 373 | } |
374 | 374 | |
375 | 375 | // Only refund payments once. |
376 | - if ( 'refunded' === get_post_status( $payment_id ) ) { |
|
376 | + if ('refunded' === get_post_status($payment_id)) { |
|
377 | 377 | return; |
378 | 378 | } |
379 | 379 | |
380 | - $payment_amount = give_donation_amount( $payment_id ); |
|
380 | + $payment_amount = give_donation_amount($payment_id); |
|
381 | 381 | $refund_amount = $data['payment_gross'] * - 1; |
382 | 382 | |
383 | - if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
383 | + if (number_format((float) $refund_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
384 | 384 | |
385 | - give_insert_payment_note( $payment_id, sprintf( /* translators: %s: Paypal parent transaction ID */ |
|
386 | - __( 'Partial PayPal refund processed: %s', 'give' ), $data['parent_txn_id'] ) ); |
|
385 | + give_insert_payment_note($payment_id, sprintf( /* translators: %s: Paypal parent transaction ID */ |
|
386 | + __('Partial PayPal refund processed: %s', 'give'), $data['parent_txn_id'] )); |
|
387 | 387 | |
388 | 388 | return; // This is a partial refund |
389 | 389 | |
390 | 390 | } |
391 | 391 | |
392 | - give_insert_payment_note( $payment_id, sprintf( /* translators: 1: Paypal parent transaction ID 2. Paypal reason code */ |
|
393 | - __( 'PayPal Payment #%1$s Refunded for reason: %2$s', 'give' ), $data['parent_txn_id'], $data['reason_code'] ) ); |
|
394 | - give_insert_payment_note( $payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
395 | - __( 'PayPal Refund Transaction ID: %s', 'give' ), $data['txn_id'] ) ); |
|
396 | - give_update_payment_status( $payment_id, 'refunded' ); |
|
392 | + give_insert_payment_note($payment_id, sprintf( /* translators: 1: Paypal parent transaction ID 2. Paypal reason code */ |
|
393 | + __('PayPal Payment #%1$s Refunded for reason: %2$s', 'give'), $data['parent_txn_id'], $data['reason_code'] )); |
|
394 | + give_insert_payment_note($payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
395 | + __('PayPal Refund Transaction ID: %s', 'give'), $data['txn_id'] )); |
|
396 | + give_update_payment_status($payment_id, 'refunded'); |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | /** |
@@ -405,24 +405,24 @@ discard block |
||
405 | 405 | * |
406 | 406 | * @return string |
407 | 407 | */ |
408 | -function give_get_paypal_redirect( $ssl_check = false ) { |
|
408 | +function give_get_paypal_redirect($ssl_check = false) { |
|
409 | 409 | |
410 | - if ( is_ssl() || ! $ssl_check ) { |
|
410 | + if (is_ssl() || ! $ssl_check) { |
|
411 | 411 | $protocol = 'https://'; |
412 | 412 | } else { |
413 | 413 | $protocol = 'http://'; |
414 | 414 | } |
415 | 415 | |
416 | 416 | // Check the current payment mode |
417 | - if ( give_is_test_mode() ) { |
|
417 | + if (give_is_test_mode()) { |
|
418 | 418 | // Test mode |
419 | - $paypal_uri = $protocol . 'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
419 | + $paypal_uri = $protocol.'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
420 | 420 | } else { |
421 | 421 | // Live mode |
422 | - $paypal_uri = $protocol . 'www.paypal.com/cgi-bin/webscr'; |
|
422 | + $paypal_uri = $protocol.'www.paypal.com/cgi-bin/webscr'; |
|
423 | 423 | } |
424 | 424 | |
425 | - return apply_filters( 'give_paypal_uri', $paypal_uri ); |
|
425 | + return apply_filters('give_paypal_uri', $paypal_uri); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | /** |
@@ -432,9 +432,9 @@ discard block |
||
432 | 432 | * @return string |
433 | 433 | */ |
434 | 434 | function give_get_paypal_page_style() { |
435 | - $page_style = trim( give_get_option( 'paypal_page_style', 'PayPal' ) ); |
|
435 | + $page_style = trim(give_get_option('paypal_page_style', 'PayPal')); |
|
436 | 436 | |
437 | - return apply_filters( 'give_paypal_page_style', $page_style ); |
|
437 | + return apply_filters('give_paypal_page_style', $page_style); |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | /** |
@@ -448,26 +448,26 @@ discard block |
||
448 | 448 | * |
449 | 449 | * @return string |
450 | 450 | */ |
451 | -function give_paypal_success_page_content( $content ) { |
|
451 | +function give_paypal_success_page_content($content) { |
|
452 | 452 | |
453 | - if ( ! isset( $_GET['payment-id'] ) && ! give_get_purchase_session() ) { |
|
453 | + if ( ! isset($_GET['payment-id']) && ! give_get_purchase_session()) { |
|
454 | 454 | return $content; |
455 | 455 | } |
456 | 456 | |
457 | - $payment_id = isset( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : false; |
|
457 | + $payment_id = isset($_GET['payment-id']) ? absint($_GET['payment-id']) : false; |
|
458 | 458 | |
459 | - if ( ! $payment_id ) { |
|
459 | + if ( ! $payment_id) { |
|
460 | 460 | $session = give_get_purchase_session(); |
461 | - $payment_id = give_get_donation_id_by_key( $session['purchase_key'] ); |
|
461 | + $payment_id = give_get_donation_id_by_key($session['purchase_key']); |
|
462 | 462 | } |
463 | 463 | |
464 | - $payment = get_post( $payment_id ); |
|
465 | - if ( $payment && 'pending' === $payment->post_status ) { |
|
464 | + $payment = get_post($payment_id); |
|
465 | + if ($payment && 'pending' === $payment->post_status) { |
|
466 | 466 | |
467 | 467 | // Payment is still pending so show processing indicator to fix the race condition. |
468 | 468 | ob_start(); |
469 | 469 | |
470 | - give_get_template_part( 'payment', 'processing' ); |
|
470 | + give_get_template_part('payment', 'processing'); |
|
471 | 471 | |
472 | 472 | $content = ob_get_clean(); |
473 | 473 | |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | |
478 | 478 | } |
479 | 479 | |
480 | -add_filter( 'give_payment_confirm_paypal', 'give_paypal_success_page_content' ); |
|
480 | +add_filter('give_payment_confirm_paypal', 'give_paypal_success_page_content'); |
|
481 | 481 | |
482 | 482 | /** |
483 | 483 | * Given a transaction ID, generate a link to the PayPal transaction ID details |
@@ -489,16 +489,16 @@ discard block |
||
489 | 489 | * |
490 | 490 | * @return string A link to the PayPal transaction details |
491 | 491 | */ |
492 | -function give_paypal_link_transaction_id( $transaction_id, $payment_id ) { |
|
492 | +function give_paypal_link_transaction_id($transaction_id, $payment_id) { |
|
493 | 493 | |
494 | 494 | $paypal_base_url = 'https://history.paypal.com/cgi-bin/webscr?cmd=_history-details-from-hub&id='; |
495 | - $transaction_url = '<a href="' . esc_url( $paypal_base_url . $transaction_id ) . '" target="_blank">' . $transaction_id . '</a>'; |
|
495 | + $transaction_url = '<a href="'.esc_url($paypal_base_url.$transaction_id).'" target="_blank">'.$transaction_id.'</a>'; |
|
496 | 496 | |
497 | - return apply_filters( 'give_paypal_link_payment_details_transaction_id', $transaction_url ); |
|
497 | + return apply_filters('give_paypal_link_payment_details_transaction_id', $transaction_url); |
|
498 | 498 | |
499 | 499 | } |
500 | 500 | |
501 | -add_filter( 'give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2 ); |
|
501 | +add_filter('give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2); |
|
502 | 502 | |
503 | 503 | |
504 | 504 | /** |
@@ -510,64 +510,64 @@ discard block |
||
510 | 510 | * |
511 | 511 | * @return string |
512 | 512 | */ |
513 | -function give_paypal_get_pending_donation_note( $pending_reason ) { |
|
513 | +function give_paypal_get_pending_donation_note($pending_reason) { |
|
514 | 514 | |
515 | 515 | $note = ''; |
516 | 516 | |
517 | - switch ( $pending_reason ) { |
|
517 | + switch ($pending_reason) { |
|
518 | 518 | |
519 | 519 | case 'echeck' : |
520 | 520 | |
521 | - $note = __( 'Payment made via eCheck and will clear automatically in 5-8 days.', 'give' ); |
|
521 | + $note = __('Payment made via eCheck and will clear automatically in 5-8 days.', 'give'); |
|
522 | 522 | |
523 | 523 | break; |
524 | 524 | |
525 | 525 | case 'address' : |
526 | 526 | |
527 | - $note = __( 'Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give' ); |
|
527 | + $note = __('Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give'); |
|
528 | 528 | |
529 | 529 | break; |
530 | 530 | |
531 | 531 | case 'intl' : |
532 | 532 | |
533 | - $note = __( 'Payment must be accepted manually through PayPal due to international account regulations.', 'give' ); |
|
533 | + $note = __('Payment must be accepted manually through PayPal due to international account regulations.', 'give'); |
|
534 | 534 | |
535 | 535 | break; |
536 | 536 | |
537 | 537 | case 'multi-currency' : |
538 | 538 | |
539 | - $note = __( 'Payment received in non-shop currency and must be accepted manually through PayPal.', 'give' ); |
|
539 | + $note = __('Payment received in non-shop currency and must be accepted manually through PayPal.', 'give'); |
|
540 | 540 | |
541 | 541 | break; |
542 | 542 | |
543 | 543 | case 'paymentreview' : |
544 | 544 | case 'regulatory_review' : |
545 | 545 | |
546 | - $note = __( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give' ); |
|
546 | + $note = __('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give'); |
|
547 | 547 | |
548 | 548 | break; |
549 | 549 | |
550 | 550 | case 'unilateral' : |
551 | 551 | |
552 | - $note = __( 'Payment was sent to non-confirmed or non-registered email address.', 'give' ); |
|
552 | + $note = __('Payment was sent to non-confirmed or non-registered email address.', 'give'); |
|
553 | 553 | |
554 | 554 | break; |
555 | 555 | |
556 | 556 | case 'upgrade' : |
557 | 557 | |
558 | - $note = __( 'PayPal account must be upgraded before this payment can be accepted.', 'give' ); |
|
558 | + $note = __('PayPal account must be upgraded before this payment can be accepted.', 'give'); |
|
559 | 559 | |
560 | 560 | break; |
561 | 561 | |
562 | 562 | case 'verify' : |
563 | 563 | |
564 | - $note = __( 'PayPal account is not verified. Verify account in order to accept this donation.', 'give' ); |
|
564 | + $note = __('PayPal account is not verified. Verify account in order to accept this donation.', 'give'); |
|
565 | 565 | |
566 | 566 | break; |
567 | 567 | |
568 | 568 | case 'other' : |
569 | 569 | |
570 | - $note = __( 'Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give' ); |
|
570 | + $note = __('Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give'); |
|
571 | 571 | |
572 | 572 | break; |
573 | 573 | |
@@ -585,49 +585,49 @@ discard block |
||
585 | 585 | * |
586 | 586 | * @return mixed|string |
587 | 587 | */ |
588 | -function give_build_paypal_url( $payment_id, $payment_data ) { |
|
588 | +function give_build_paypal_url($payment_id, $payment_data) { |
|
589 | 589 | // Only send to PayPal if the pending payment is created successfully. |
590 | - $listener_url = add_query_arg( 'give-listener', 'IPN', home_url( 'index.php' ) ); |
|
590 | + $listener_url = add_query_arg('give-listener', 'IPN', home_url('index.php')); |
|
591 | 591 | |
592 | 592 | // Get the success url. |
593 | - $return_url = add_query_arg( array( |
|
593 | + $return_url = add_query_arg(array( |
|
594 | 594 | 'payment-confirmation' => 'paypal', |
595 | 595 | 'payment-id' => $payment_id, |
596 | 596 | |
597 | - ), get_permalink( give_get_option( 'success_page' ) ) ); |
|
597 | + ), get_permalink(give_get_option('success_page'))); |
|
598 | 598 | |
599 | 599 | // Get the PayPal redirect uri. |
600 | - $paypal_redirect = trailingslashit( give_get_paypal_redirect() ) . '?'; |
|
600 | + $paypal_redirect = trailingslashit(give_get_paypal_redirect()).'?'; |
|
601 | 601 | |
602 | 602 | // Item name. |
603 | - $item_name = give_payment_gateway_item_title( $payment_data ); |
|
603 | + $item_name = give_payment_gateway_item_title($payment_data); |
|
604 | 604 | |
605 | 605 | // Setup PayPal API params. |
606 | 606 | $paypal_args = array( |
607 | - 'business' => give_get_option( 'paypal_email', false ), |
|
607 | + 'business' => give_get_option('paypal_email', false), |
|
608 | 608 | 'first_name' => $payment_data['user_info']['first_name'], |
609 | 609 | 'last_name' => $payment_data['user_info']['last_name'], |
610 | 610 | 'email' => $payment_data['user_email'], |
611 | 611 | 'invoice' => $payment_data['purchase_key'], |
612 | 612 | 'amount' => $payment_data['price'], |
613 | - 'item_name' => stripslashes( $item_name ), |
|
613 | + 'item_name' => stripslashes($item_name), |
|
614 | 614 | 'no_shipping' => '1', |
615 | 615 | 'shipping' => '0', |
616 | 616 | 'no_note' => '1', |
617 | - 'currency_code' => give_get_currency( $payment_id, $payment_data ), |
|
618 | - 'charset' => get_bloginfo( 'charset' ), |
|
617 | + 'currency_code' => give_get_currency($payment_id, $payment_data), |
|
618 | + 'charset' => get_bloginfo('charset'), |
|
619 | 619 | 'custom' => $payment_id, |
620 | 620 | 'rm' => '2', |
621 | 621 | 'return' => $return_url, |
622 | - 'cancel_return' => give_get_failed_transaction_uri( '?payment-id=' . $payment_id ), |
|
622 | + 'cancel_return' => give_get_failed_transaction_uri('?payment-id='.$payment_id), |
|
623 | 623 | 'notify_url' => $listener_url, |
624 | 624 | 'page_style' => give_get_paypal_page_style(), |
625 | - 'cbt' => get_bloginfo( 'name' ), |
|
625 | + 'cbt' => get_bloginfo('name'), |
|
626 | 626 | 'bn' => 'givewp_SP', |
627 | 627 | ); |
628 | 628 | |
629 | 629 | // Add user address if present. |
630 | - if ( ! empty( $payment_data['user_info']['address'] ) ) { |
|
630 | + if ( ! empty($payment_data['user_info']['address'])) { |
|
631 | 631 | $default_address = array( |
632 | 632 | 'line1' => '', |
633 | 633 | 'line2' => '', |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | 'country' => '', |
638 | 638 | ); |
639 | 639 | |
640 | - $address = wp_parse_args( $payment_data['user_info']['address'], $default_address ); |
|
640 | + $address = wp_parse_args($payment_data['user_info']['address'], $default_address); |
|
641 | 641 | |
642 | 642 | $paypal_args['address1'] = $address['line1']; |
643 | 643 | $paypal_args['address2'] = $address['line2']; |
@@ -658,13 +658,13 @@ discard block |
||
658 | 658 | * |
659 | 659 | * @since 1.8 |
660 | 660 | */ |
661 | - $paypal_args = apply_filters( 'give_paypal_redirect_args', $paypal_args, $payment_data ); |
|
661 | + $paypal_args = apply_filters('give_paypal_redirect_args', $paypal_args, $payment_data); |
|
662 | 662 | |
663 | 663 | // Build query. |
664 | - $paypal_redirect .= http_build_query( $paypal_args ); |
|
664 | + $paypal_redirect .= http_build_query($paypal_args); |
|
665 | 665 | |
666 | 666 | // Fix for some sites that encode the entities. |
667 | - $paypal_redirect = str_replace( '&', '&', $paypal_redirect ); |
|
667 | + $paypal_redirect = str_replace('&', '&', $paypal_redirect); |
|
668 | 668 | |
669 | 669 | return $paypal_redirect; |
670 | 670 | } |
@@ -679,7 +679,7 @@ discard block |
||
679 | 679 | function give_get_paypal_button_type() { |
680 | 680 | // paypal_button_type can be donation or standard. |
681 | 681 | $paypal_button_type = '_donations'; |
682 | - if ( 'standard' === give_get_option( 'paypal_button_type' ) ) { |
|
682 | + if ('standard' === give_get_option('paypal_button_type')) { |
|
683 | 683 | $paypal_button_type = '_xclick'; |
684 | 684 | } |
685 | 685 | |
@@ -696,15 +696,15 @@ discard block |
||
696 | 696 | * |
697 | 697 | * @return string |
698 | 698 | */ |
699 | -function give_paypal_purchase_key( $purchase_key, $gateway ) { |
|
699 | +function give_paypal_purchase_key($purchase_key, $gateway) { |
|
700 | 700 | |
701 | - $invoice_id_prefix = give_get_option( 'paypal_invoice_prefix', 'GIVEPAYPAL-' ); |
|
701 | + $invoice_id_prefix = give_get_option('paypal_invoice_prefix', 'GIVEPAYPAL-'); |
|
702 | 702 | |
703 | - if ( 'paypal' === $gateway ) { |
|
704 | - $purchase_key = $invoice_id_prefix . $purchase_key; |
|
703 | + if ('paypal' === $gateway) { |
|
704 | + $purchase_key = $invoice_id_prefix.$purchase_key; |
|
705 | 705 | } |
706 | 706 | |
707 | 707 | return $purchase_key; |
708 | 708 | } |
709 | 709 | |
710 | -add_filter( 'give_purchase_key', 'give_paypal_purchase_key', 10, 2 ); |
|
711 | 710 | \ No newline at end of file |
711 | +add_filter('give_purchase_key', 'give_paypal_purchase_key', 10, 2); |
|
712 | 712 | \ No newline at end of file |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; // Exit if accessed directly |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Settings_Gateways' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_Gateways')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_Gateways. |
@@ -27,15 +27,15 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function __construct() { |
29 | 29 | $this->id = 'gateways'; |
30 | - $this->label = esc_html__( 'Payment Gateways', 'give' ); |
|
30 | + $this->label = esc_html__('Payment Gateways', 'give'); |
|
31 | 31 | |
32 | 32 | $this->default_tab = 'gateways-settings'; |
33 | 33 | |
34 | 34 | parent::__construct(); |
35 | 35 | |
36 | 36 | // Do not use main form for this tab. |
37 | - if ( give_get_current_setting_tab() === $this->id ) { |
|
38 | - add_action( 'give_admin_field_enabled_gateways', array( $this, 'render_enabled_gateways' ), 10, 2 ); |
|
37 | + if (give_get_current_setting_tab() === $this->id) { |
|
38 | + add_action('give_admin_field_enabled_gateways', array($this, 'render_enabled_gateways'), 10, 2); |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $settings = array(); |
50 | 50 | $current_section = give_get_current_setting_section(); |
51 | 51 | |
52 | - switch ( $current_section ) { |
|
52 | + switch ($current_section) { |
|
53 | 53 | case 'paypal-standard': |
54 | 54 | $settings = array( |
55 | 55 | // Section 2: PayPal Standard. |
@@ -58,62 +58,62 @@ discard block |
||
58 | 58 | 'id' => 'give_title_gateway_settings_2', |
59 | 59 | ), |
60 | 60 | array( |
61 | - 'name' => __( 'PayPal Email', 'give' ), |
|
62 | - 'desc' => __( 'Enter your PayPal account\'s email.', 'give' ), |
|
61 | + 'name' => __('PayPal Email', 'give'), |
|
62 | + 'desc' => __('Enter your PayPal account\'s email.', 'give'), |
|
63 | 63 | 'id' => 'paypal_email', |
64 | 64 | 'type' => 'email', |
65 | 65 | ), |
66 | 66 | array( |
67 | - 'name' => __( 'PayPal Page Style', 'give' ), |
|
68 | - 'desc' => __( 'Enter the name of the PayPal page style to use, or leave blank to use the default.', 'give' ), |
|
67 | + 'name' => __('PayPal Page Style', 'give'), |
|
68 | + 'desc' => __('Enter the name of the PayPal page style to use, or leave blank to use the default.', 'give'), |
|
69 | 69 | 'id' => 'paypal_page_style', |
70 | 70 | 'type' => 'text', |
71 | 71 | ), |
72 | 72 | array( |
73 | - 'name' => __( 'PayPal Transaction Type', 'give' ), |
|
74 | - 'desc' => __( 'Nonprofits must verify their status to withdraw donations they receive via PayPal. PayPal users that are not verified nonprofits must demonstrate how their donations will be used, once they raise more than $10,000. By default, Give transactions are sent to PayPal as donations. You may change the transaction type using this option if you feel you may not meet PayPal\'s donation requirements.', 'give' ), |
|
73 | + 'name' => __('PayPal Transaction Type', 'give'), |
|
74 | + 'desc' => __('Nonprofits must verify their status to withdraw donations they receive via PayPal. PayPal users that are not verified nonprofits must demonstrate how their donations will be used, once they raise more than $10,000. By default, Give transactions are sent to PayPal as donations. You may change the transaction type using this option if you feel you may not meet PayPal\'s donation requirements.', 'give'), |
|
75 | 75 | 'id' => 'paypal_button_type', |
76 | 76 | 'type' => 'radio_inline', |
77 | 77 | 'options' => array( |
78 | - 'donation' => __( 'Donation', 'give' ), |
|
79 | - 'standard' => __( 'Standard Transaction', 'give' ) |
|
78 | + 'donation' => __('Donation', 'give'), |
|
79 | + 'standard' => __('Standard Transaction', 'give') |
|
80 | 80 | ), |
81 | 81 | 'default' => 'donation', |
82 | 82 | ), |
83 | 83 | array( |
84 | - 'name' => __( 'Billing Details', 'give' ), |
|
85 | - 'desc' => __( 'This option will enable the billing details section for PayPal Standard which requires the donor\'s address to complete the donation. These fields are not required by PayPal to process the transaction, but you may have a need to collect the data.', 'give' ), |
|
84 | + 'name' => __('Billing Details', 'give'), |
|
85 | + 'desc' => __('This option will enable the billing details section for PayPal Standard which requires the donor\'s address to complete the donation. These fields are not required by PayPal to process the transaction, but you may have a need to collect the data.', 'give'), |
|
86 | 86 | 'id' => 'paypal_standard_billing_details', |
87 | 87 | 'type' => 'radio_inline', |
88 | 88 | 'default' => 'disabled', |
89 | 89 | 'options' => array( |
90 | - 'enabled' => __( 'Enabled', 'give' ), |
|
91 | - 'disabled' => __( 'Disabled', 'give' ), |
|
90 | + 'enabled' => __('Enabled', 'give'), |
|
91 | + 'disabled' => __('Disabled', 'give'), |
|
92 | 92 | ) |
93 | 93 | ), |
94 | 94 | array( |
95 | - 'name' => __( 'PayPal IPN Verification', 'give' ), |
|
96 | - 'desc' => __( 'If donations are not getting marked as complete, use a slightly less secure method of verifying donations.', 'give' ), |
|
95 | + 'name' => __('PayPal IPN Verification', 'give'), |
|
96 | + 'desc' => __('If donations are not getting marked as complete, use a slightly less secure method of verifying donations.', 'give'), |
|
97 | 97 | 'id' => 'paypal_verification', |
98 | 98 | 'type' => 'radio_inline', |
99 | 99 | 'default' => 'enabled', |
100 | 100 | 'options' => array( |
101 | - 'enabled' => __( 'Enabled', 'give' ), |
|
102 | - 'disabled' => __( 'Disabled', 'give' ), |
|
101 | + 'enabled' => __('Enabled', 'give'), |
|
102 | + 'disabled' => __('Disabled', 'give'), |
|
103 | 103 | ) |
104 | 104 | ), |
105 | 105 | array( |
106 | 106 | 'id' => 'paypal_invoice_prefix', |
107 | - 'name' => esc_html__( 'Invoice ID Prefix', 'give' ), |
|
108 | - 'desc' => esc_html__( 'Please enter a prefix for your invoice numbers. If you use your PayPal account for multiple stores ensure this prefix is unique as PayPal will not allow orders with the same invoice number.', 'give' ), |
|
107 | + 'name' => esc_html__('Invoice ID Prefix', 'give'), |
|
108 | + 'desc' => esc_html__('Please enter a prefix for your invoice numbers. If you use your PayPal account for multiple stores ensure this prefix is unique as PayPal will not allow orders with the same invoice number.', 'give'), |
|
109 | 109 | 'type' => 'text', |
110 | 110 | 'default' => 'GIVEPAYPAL-', |
111 | 111 | ), |
112 | 112 | array( |
113 | - 'name' => __( 'PayPal Standard Gateway Settings Docs Link', 'give' ), |
|
113 | + 'name' => __('PayPal Standard Gateway Settings Docs Link', 'give'), |
|
114 | 114 | 'id' => 'paypal_standard_gateway_settings_docs_link', |
115 | - 'url' => esc_url( 'http://docs.givewp.com/settings-gateway-paypal-standard' ), |
|
116 | - 'title' => __( 'PayPal Standard Gateway Settings', 'give' ), |
|
115 | + 'url' => esc_url('http://docs.givewp.com/settings-gateway-paypal-standard'), |
|
116 | + 'title' => __('PayPal Standard Gateway Settings', 'give'), |
|
117 | 117 | 'type' => 'give_docs_link', |
118 | 118 | ), |
119 | 119 | array( |
@@ -131,19 +131,19 @@ discard block |
||
131 | 131 | 'id' => 'give_title_gateway_settings_3', |
132 | 132 | ), |
133 | 133 | array( |
134 | - 'name' => __( 'Collect Billing Details', 'give' ), |
|
135 | - 'desc' => __( 'Enable to request billing details for offline donations. Will appear above offline donation instructions. Can be enabled/disabled per form.', 'give' ), |
|
134 | + 'name' => __('Collect Billing Details', 'give'), |
|
135 | + 'desc' => __('Enable to request billing details for offline donations. Will appear above offline donation instructions. Can be enabled/disabled per form.', 'give'), |
|
136 | 136 | 'id' => 'give_offline_donation_enable_billing_fields', |
137 | 137 | 'type' => 'radio_inline', |
138 | 138 | 'default' => 'disabled', |
139 | 139 | 'options' => array( |
140 | - 'enabled' => __( 'Enabled', 'give' ), |
|
141 | - 'disabled' => __( 'Disabled', 'give' ) |
|
140 | + 'enabled' => __('Enabled', 'give'), |
|
141 | + 'disabled' => __('Disabled', 'give') |
|
142 | 142 | ) |
143 | 143 | ), |
144 | 144 | array( |
145 | - 'name' => __( 'Offline Donation Instructions', 'give' ), |
|
146 | - 'desc' => __( 'The following content will appear for all forms when the user selects the offline donation payment option. Note: You may customize the content per form as needed.', 'give' ), |
|
145 | + 'name' => __('Offline Donation Instructions', 'give'), |
|
146 | + 'desc' => __('The following content will appear for all forms when the user selects the offline donation payment option. Note: You may customize the content per form as needed.', 'give'), |
|
147 | 147 | 'id' => 'global_offline_donation_content', |
148 | 148 | 'default' => give_get_default_offline_donation_content(), |
149 | 149 | 'type' => 'wysiwyg', |
@@ -152,10 +152,10 @@ discard block |
||
152 | 152 | ) |
153 | 153 | ), |
154 | 154 | array( |
155 | - 'name' => esc_html__( 'Offline Donations Settings Docs Link', 'give' ), |
|
155 | + 'name' => esc_html__('Offline Donations Settings Docs Link', 'give'), |
|
156 | 156 | 'id' => 'offline_gateway_settings_docs_link', |
157 | - 'url' => esc_url( 'http://docs.givewp.com/offlinegateway' ), |
|
158 | - 'title' => __( 'Offline Gateway Settings', 'give' ), |
|
157 | + 'url' => esc_url('http://docs.givewp.com/offlinegateway'), |
|
158 | + 'title' => __('Offline Gateway Settings', 'give'), |
|
159 | 159 | 'type' => 'give_docs_link', |
160 | 160 | ), |
161 | 161 | array( |
@@ -173,19 +173,19 @@ discard block |
||
173 | 173 | 'type' => 'title' |
174 | 174 | ), |
175 | 175 | array( |
176 | - 'name' => __( 'Test Mode', 'give' ), |
|
177 | - 'desc' => __( 'While in test mode no live donations are processed. To fully use test mode, you must have a sandbox (test) account for the payment gateway you are testing.', 'give' ), |
|
176 | + 'name' => __('Test Mode', 'give'), |
|
177 | + 'desc' => __('While in test mode no live donations are processed. To fully use test mode, you must have a sandbox (test) account for the payment gateway you are testing.', 'give'), |
|
178 | 178 | 'id' => 'test_mode', |
179 | 179 | 'type' => 'radio_inline', |
180 | 180 | 'default' => 'disabled', |
181 | 181 | 'options' => array( |
182 | - 'enabled' => __( 'Enabled', 'give' ), |
|
183 | - 'disabled' => __( 'Disabled', 'give' ), |
|
182 | + 'enabled' => __('Enabled', 'give'), |
|
183 | + 'disabled' => __('Disabled', 'give'), |
|
184 | 184 | ) |
185 | 185 | ), |
186 | 186 | array( |
187 | - 'name' => __( 'Enabled Gateways', 'give' ), |
|
188 | - 'desc' => __( 'Enable your payment gateway. Can be ordered by dragging.', 'give' ), |
|
187 | + 'name' => __('Enabled Gateways', 'give'), |
|
188 | + 'desc' => __('Enable your payment gateway. Can be ordered by dragging.', 'give'), |
|
189 | 189 | 'id' => 'gateways', |
190 | 190 | 'type' => 'enabled_gateways' |
191 | 191 | ), |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * This setting will not render on admin setting screen but help internal code to recognize "gateways_label" setting and add them to give setting when save. |
198 | 198 | */ |
199 | 199 | array( |
200 | - 'name' => __( 'Gateways Label', 'give' ), |
|
200 | + 'name' => __('Gateways Label', 'give'), |
|
201 | 201 | 'desc' => '', |
202 | 202 | 'id' => 'gateways_label', |
203 | 203 | 'type' => 'gateways_label_hidden' |
@@ -210,17 +210,17 @@ discard block |
||
210 | 210 | * This setting will not render on admin setting screen but help internal code to recognize "default_gateway" setting and add them to give setting when save. |
211 | 211 | */ |
212 | 212 | array( |
213 | - 'name' => __( 'Default Gateway', 'give' ), |
|
214 | - 'desc' => __( 'The gateway that will be selected by default.', 'give' ), |
|
213 | + 'name' => __('Default Gateway', 'give'), |
|
214 | + 'desc' => __('The gateway that will be selected by default.', 'give'), |
|
215 | 215 | 'id' => 'default_gateway', |
216 | 216 | 'type' => 'default_gateway_hidden' |
217 | 217 | ), |
218 | 218 | |
219 | 219 | array( |
220 | - 'name' => __( 'Gateways Docs Link', 'give' ), |
|
220 | + 'name' => __('Gateways Docs Link', 'give'), |
|
221 | 221 | 'id' => 'gateway_settings_docs_link', |
222 | - 'url' => esc_url( 'http://docs.givewp.com/settings-gateways' ), |
|
223 | - 'title' => __( 'Gateway Settings', 'give' ), |
|
222 | + 'url' => esc_url('http://docs.givewp.com/settings-gateways'), |
|
223 | + 'title' => __('Gateway Settings', 'give'), |
|
224 | 224 | 'type' => 'give_docs_link', |
225 | 225 | ), |
226 | 226 | array( |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | * Filter the payment gateways settings. |
236 | 236 | * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8 |
237 | 237 | */ |
238 | - $settings = apply_filters( 'give_settings_gateways', $settings ); |
|
238 | + $settings = apply_filters('give_settings_gateways', $settings); |
|
239 | 239 | |
240 | 240 | /** |
241 | 241 | * Filter the settings. |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * |
245 | 245 | * @param array $settings |
246 | 246 | */ |
247 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
247 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
248 | 248 | |
249 | 249 | // Output. |
250 | 250 | return $settings; |
@@ -258,12 +258,12 @@ discard block |
||
258 | 258 | */ |
259 | 259 | public function get_sections() { |
260 | 260 | $sections = array( |
261 | - 'gateways-settings' => __( 'Gateways', 'give' ), |
|
262 | - 'paypal-standard' => __( 'PayPal Standard', 'give' ), |
|
263 | - 'offline-donations' => __( 'Offline Donations', 'give' ) |
|
261 | + 'gateways-settings' => __('Gateways', 'give'), |
|
262 | + 'paypal-standard' => __('PayPal Standard', 'give'), |
|
263 | + 'offline-donations' => __('Offline Donations', 'give') |
|
264 | 264 | ); |
265 | 265 | |
266 | - return apply_filters( 'give_get_sections_' . $this->id, $sections ); |
|
266 | + return apply_filters('give_get_sections_'.$this->id, $sections); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | |
@@ -276,11 +276,11 @@ discard block |
||
276 | 276 | * @param $field |
277 | 277 | * @param $settings |
278 | 278 | */ |
279 | - public function render_enabled_gateways( $field, $settings ) { |
|
279 | + public function render_enabled_gateways($field, $settings) { |
|
280 | 280 | $id = $field['id']; |
281 | - $gateways = give_get_ordered_payment_gateways( give_get_payment_gateways() ); |
|
282 | - $gateways_label = give_get_option( 'gateways_label', array() ); |
|
283 | - $default_gateway = give_get_option( 'default_gateway', current( array_keys( $gateways ) ) ); |
|
281 | + $gateways = give_get_ordered_payment_gateways(give_get_payment_gateways()); |
|
282 | + $gateways_label = give_get_option('gateways_label', array()); |
|
283 | + $default_gateway = give_get_option('default_gateway', current(array_keys($gateways))); |
|
284 | 284 | |
285 | 285 | ob_start(); |
286 | 286 | |
@@ -295,51 +295,51 @@ discard block |
||
295 | 295 | <span>%3$s</span> |
296 | 296 | <span>%4$s</span> |
297 | 297 | ', |
298 | - __( 'Gateway', 'give' ), |
|
299 | - __( 'Label', 'give' ), |
|
300 | - __( 'Default', 'give' ), |
|
301 | - __( 'Enabled', 'give' ) |
|
298 | + __('Gateway', 'give'), |
|
299 | + __('Label', 'give'), |
|
300 | + __('Default', 'give'), |
|
301 | + __('Enabled', 'give') |
|
302 | 302 | ); |
303 | 303 | echo '</div>'; |
304 | 304 | |
305 | 305 | echo '<ul class="give-checklist-fields give-payment-gatways-list">'; |
306 | - foreach ( $gateways as $key => $option ) : |
|
306 | + foreach ($gateways as $key => $option) : |
|
307 | 307 | $enabled = null; |
308 | - if ( is_array( $settings ) && array_key_exists( $key, $settings ) ) { |
|
308 | + if (is_array($settings) && array_key_exists($key, $settings)) { |
|
309 | 309 | $enabled = '1'; |
310 | 310 | } |
311 | 311 | |
312 | 312 | echo '<li>'; |
313 | - printf( '<span class="give-drag-handle"><span class="dashicons dashicons-menu"></span></span>' ); |
|
314 | - printf( '<span class="admin-label">%s</span>', esc_html( $option['admin_label'] ) ); |
|
313 | + printf('<span class="give-drag-handle"><span class="dashicons dashicons-menu"></span></span>'); |
|
314 | + printf('<span class="admin-label">%s</span>', esc_html($option['admin_label'])); |
|
315 | 315 | |
316 | 316 | $label = ''; |
317 | - if ( ! empty( $gateways_label[ $key ] ) ) { |
|
318 | - $label = $gateways_label[ $key ]; |
|
317 | + if ( ! empty($gateways_label[$key])) { |
|
318 | + $label = $gateways_label[$key]; |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | printf( |
322 | 322 | '<input class="checkout-label" type="text" id="%1$s[%2$s]" name="%1$s[%2$s]" value="%3$s" placeholder="%4$s"/>', |
323 | 323 | 'gateways_label', |
324 | - esc_attr( $key ), |
|
325 | - esc_html( $label ), |
|
326 | - esc_html( $option['checkout_label'] ) |
|
324 | + esc_attr($key), |
|
325 | + esc_html($label), |
|
326 | + esc_html($option['checkout_label']) |
|
327 | 327 | ); |
328 | 328 | |
329 | 329 | printf( |
330 | 330 | '<input class="gateways-radio" type="radio" name="%1$s" value="%2$s" %3$s %4$s>', |
331 | 331 | 'default_gateway', |
332 | 332 | $key, |
333 | - checked( $key, $default_gateway, false ), |
|
334 | - disabled( NULL, $enabled, false ) |
|
333 | + checked($key, $default_gateway, false), |
|
334 | + disabled(NULL, $enabled, false) |
|
335 | 335 | ); |
336 | 336 | |
337 | 337 | printf( |
338 | 338 | '<input class="gateways-checkbox" name="%1$s[%2$s]" id="%1$s[%2$s]" type="checkbox" value="1" %3$s data-payment-gateway="%4$s"/>', |
339 | - esc_attr( $id ), |
|
340 | - esc_attr( $key ), |
|
341 | - checked( '1', $enabled, false ), |
|
342 | - esc_html( $option['admin_label'] ) |
|
339 | + esc_attr($id), |
|
340 | + esc_attr($key), |
|
341 | + checked('1', $enabled, false), |
|
342 | + esc_html($option['admin_label']) |
|
343 | 343 | ); |
344 | 344 | echo '</li>'; |
345 | 345 | endforeach; |