@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -30,54 +30,54 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @return bool|array List of all user donations. |
32 | 32 | */ |
33 | -function give_get_users_donations( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) { |
|
33 | +function give_get_users_donations($user = 0, $number = 20, $pagination = false, $status = 'complete') { |
|
34 | 34 | |
35 | - if ( empty( $user ) ) { |
|
35 | + if (empty($user)) { |
|
36 | 36 | $user = get_current_user_id(); |
37 | 37 | } |
38 | 38 | |
39 | - if ( 0 === $user && ! Give()->email_access->token_exists ) { |
|
39 | + if (0 === $user && ! Give()->email_access->token_exists) { |
|
40 | 40 | return false; |
41 | 41 | } |
42 | 42 | |
43 | 43 | $status = $status === 'complete' ? 'publish' : $status; |
44 | 44 | $paged = 1; |
45 | 45 | |
46 | - if ( $pagination ) { |
|
47 | - if ( get_query_var( 'paged' ) ) { |
|
48 | - $paged = get_query_var( 'paged' ); |
|
49 | - } elseif ( get_query_var( 'page' ) ) { |
|
50 | - $paged = get_query_var( 'page' ); |
|
46 | + if ($pagination) { |
|
47 | + if (get_query_var('paged')) { |
|
48 | + $paged = get_query_var('paged'); |
|
49 | + } elseif (get_query_var('page')) { |
|
50 | + $paged = get_query_var('page'); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
54 | - $args = apply_filters( 'give_get_users_donations_args', array( |
|
54 | + $args = apply_filters('give_get_users_donations_args', array( |
|
55 | 55 | 'user' => $user, |
56 | 56 | 'number' => $number, |
57 | 57 | 'status' => $status, |
58 | 58 | 'orderby' => 'date', |
59 | - ) ); |
|
59 | + )); |
|
60 | 60 | |
61 | - if ( $pagination ) { |
|
61 | + if ($pagination) { |
|
62 | 62 | $args['page'] = $paged; |
63 | 63 | } else { |
64 | 64 | $args['nopaging'] = true; |
65 | 65 | } |
66 | 66 | |
67 | - $by_user_id = is_numeric( $user ) ? true : false; |
|
68 | - $donor = new Give_Donor( $user, $by_user_id ); |
|
67 | + $by_user_id = is_numeric($user) ? true : false; |
|
68 | + $donor = new Give_Donor($user, $by_user_id); |
|
69 | 69 | |
70 | - if ( ! empty( $donor->payment_ids ) ) { |
|
70 | + if ( ! empty($donor->payment_ids)) { |
|
71 | 71 | |
72 | - unset( $args['user'] ); |
|
73 | - $args['post__in'] = array_map( 'absint', explode( ',', $donor->payment_ids ) ); |
|
72 | + unset($args['user']); |
|
73 | + $args['post__in'] = array_map('absint', explode(',', $donor->payment_ids)); |
|
74 | 74 | |
75 | 75 | } |
76 | 76 | |
77 | - $donations = give_get_payments( apply_filters( 'give_get_users_donations_args', $args ) ); |
|
77 | + $donations = give_get_payments(apply_filters('give_get_users_donations_args', $args)); |
|
78 | 78 | |
79 | 79 | // No donations |
80 | - if ( ! $donations ) { |
|
80 | + if ( ! $donations) { |
|
81 | 81 | return false; |
82 | 82 | } |
83 | 83 | |
@@ -96,65 +96,65 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @return bool|object List of unique forms donated by user |
98 | 98 | */ |
99 | -function give_get_users_completed_donations( $user = 0, $status = 'complete' ) { |
|
100 | - if ( empty( $user ) ) { |
|
99 | +function give_get_users_completed_donations($user = 0, $status = 'complete') { |
|
100 | + if (empty($user)) { |
|
101 | 101 | $user = get_current_user_id(); |
102 | 102 | } |
103 | 103 | |
104 | - if ( empty( $user ) ) { |
|
104 | + if (empty($user)) { |
|
105 | 105 | return false; |
106 | 106 | } |
107 | 107 | |
108 | - $by_user_id = is_numeric( $user ) ? true : false; |
|
108 | + $by_user_id = is_numeric($user) ? true : false; |
|
109 | 109 | |
110 | - $donor = new Give_Donor( $user, $by_user_id ); |
|
110 | + $donor = new Give_Donor($user, $by_user_id); |
|
111 | 111 | |
112 | - if ( empty( $donor->payment_ids ) ) { |
|
112 | + if (empty($donor->payment_ids)) { |
|
113 | 113 | return false; |
114 | 114 | } |
115 | 115 | |
116 | 116 | // Get all the items donated. |
117 | - $payment_ids = array_reverse( explode( ',', $donor->payment_ids ) ); |
|
118 | - $limit_payments = apply_filters( 'give_users_completed_donations_payments', 50 ); |
|
119 | - if ( ! empty( $limit_payments ) ) { |
|
120 | - $payment_ids = array_slice( $payment_ids, 0, $limit_payments ); |
|
117 | + $payment_ids = array_reverse(explode(',', $donor->payment_ids)); |
|
118 | + $limit_payments = apply_filters('give_users_completed_donations_payments', 50); |
|
119 | + if ( ! empty($limit_payments)) { |
|
120 | + $payment_ids = array_slice($payment_ids, 0, $limit_payments); |
|
121 | 121 | } |
122 | 122 | $donation_data = array(); |
123 | - foreach ( $payment_ids as $payment_id ) { |
|
124 | - $donation_data[] = give_get_payment_meta( $payment_id ); |
|
123 | + foreach ($payment_ids as $payment_id) { |
|
124 | + $donation_data[] = give_get_payment_meta($payment_id); |
|
125 | 125 | } |
126 | 126 | |
127 | - if ( empty( $donation_data ) ) { |
|
127 | + if (empty($donation_data)) { |
|
128 | 128 | return false; |
129 | 129 | } |
130 | 130 | |
131 | 131 | // Grab only the post ids "form_id" of the forms donated on this order |
132 | 132 | $completed_donations_ids = array(); |
133 | - foreach ( $donation_data as $donation_meta ) { |
|
134 | - $completed_donations_ids[] = isset( $donation_meta['form_id'] ) ? $donation_meta['form_id'] : ''; |
|
133 | + foreach ($donation_data as $donation_meta) { |
|
134 | + $completed_donations_ids[] = isset($donation_meta['form_id']) ? $donation_meta['form_id'] : ''; |
|
135 | 135 | } |
136 | 136 | |
137 | - if ( empty( $completed_donations_ids ) ) { |
|
137 | + if (empty($completed_donations_ids)) { |
|
138 | 138 | return false; |
139 | 139 | } |
140 | 140 | |
141 | 141 | // Only include each donation once |
142 | - $form_ids = array_unique( $completed_donations_ids ); |
|
142 | + $form_ids = array_unique($completed_donations_ids); |
|
143 | 143 | |
144 | 144 | // Make sure we still have some products and a first item |
145 | - if ( empty( $form_ids ) || ! isset( $form_ids[0] ) ) { |
|
145 | + if (empty($form_ids) || ! isset($form_ids[0])) { |
|
146 | 146 | return false; |
147 | 147 | } |
148 | 148 | |
149 | - $post_type = get_post_type( $form_ids[0] ); |
|
149 | + $post_type = get_post_type($form_ids[0]); |
|
150 | 150 | |
151 | - $args = apply_filters( 'give_get_users_completed_donations_args', array( |
|
151 | + $args = apply_filters('give_get_users_completed_donations_args', array( |
|
152 | 152 | 'include' => $form_ids, |
153 | 153 | 'post_type' => $post_type, |
154 | - 'posts_per_page' => - 1, |
|
155 | - ) ); |
|
154 | + 'posts_per_page' => -1, |
|
155 | + )); |
|
156 | 156 | |
157 | - return apply_filters( 'give_users_completed_donations_list', get_posts( $args ) ); |
|
157 | + return apply_filters('give_users_completed_donations_list', get_posts($args)); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | |
@@ -170,12 +170,12 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @return bool True if has donated, false other wise. |
172 | 172 | */ |
173 | -function give_has_donations( $user_id = null ) { |
|
174 | - if ( empty( $user_id ) ) { |
|
173 | +function give_has_donations($user_id = null) { |
|
174 | + if (empty($user_id)) { |
|
175 | 175 | $user_id = get_current_user_id(); |
176 | 176 | } |
177 | 177 | |
178 | - if ( give_get_users_donations( $user_id, 1 ) ) { |
|
178 | + if (give_get_users_donations($user_id, 1)) { |
|
179 | 179 | return true; // User has at least one donation. |
180 | 180 | } |
181 | 181 | |
@@ -196,23 +196,23 @@ discard block |
||
196 | 196 | * |
197 | 197 | * @return array |
198 | 198 | */ |
199 | -function give_get_donation_stats_by_user( $user = '' ) { |
|
199 | +function give_get_donation_stats_by_user($user = '') { |
|
200 | 200 | |
201 | 201 | $field = ''; |
202 | 202 | |
203 | - if ( is_email( $user ) ) { |
|
203 | + if (is_email($user)) { |
|
204 | 204 | $field = 'email'; |
205 | - } elseif ( is_numeric( $user ) ) { |
|
205 | + } elseif (is_numeric($user)) { |
|
206 | 206 | $field = 'user_id'; |
207 | 207 | } |
208 | 208 | |
209 | - $stats = array(); |
|
210 | - $donor = Give()->donors->get_donor_by( $field, $user ); |
|
209 | + $stats = array(); |
|
210 | + $donor = Give()->donors->get_donor_by($field, $user); |
|
211 | 211 | |
212 | - if ( $donor ) { |
|
213 | - $donor = new Give_Donor( $donor->id ); |
|
214 | - $stats['purchases'] = absint( $donor->purchase_count ); |
|
215 | - $stats['total_spent'] = give_maybe_sanitize_amount( $donor->purchase_value ); |
|
212 | + if ($donor) { |
|
213 | + $donor = new Give_Donor($donor->id); |
|
214 | + $stats['purchases'] = absint($donor->purchase_count); |
|
215 | + $stats['total_spent'] = give_maybe_sanitize_amount($donor->purchase_value); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @since 1.7 |
222 | 222 | */ |
223 | - $stats = (array) apply_filters( 'give_donation_stats_by_user', $stats, $user ); |
|
223 | + $stats = (array) apply_filters('give_donation_stats_by_user', $stats, $user); |
|
224 | 224 | |
225 | 225 | return $stats; |
226 | 226 | } |
@@ -238,21 +238,21 @@ discard block |
||
238 | 238 | * |
239 | 239 | * @return int The total number of donations. |
240 | 240 | */ |
241 | -function give_count_donations_of_donor( $user = null ) { |
|
241 | +function give_count_donations_of_donor($user = null) { |
|
242 | 242 | |
243 | 243 | // Logged in? |
244 | - if ( empty( $user ) ) { |
|
244 | + if (empty($user)) { |
|
245 | 245 | $user = get_current_user_id(); |
246 | 246 | } |
247 | 247 | |
248 | 248 | // Email access? |
249 | - if ( empty( $user ) && Give()->email_access->token_email ) { |
|
249 | + if (empty($user) && Give()->email_access->token_email) { |
|
250 | 250 | $user = Give()->email_access->token_email; |
251 | 251 | } |
252 | 252 | |
253 | - $stats = ! empty( $user ) ? give_get_donation_stats_by_user( $user ) : false; |
|
253 | + $stats = ! empty($user) ? give_get_donation_stats_by_user($user) : false; |
|
254 | 254 | |
255 | - return isset( $stats['purchases'] ) ? $stats['purchases'] : 0; |
|
255 | + return isset($stats['purchases']) ? $stats['purchases'] : 0; |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
@@ -265,9 +265,9 @@ discard block |
||
265 | 265 | * |
266 | 266 | * @return float The total amount the user has spent |
267 | 267 | */ |
268 | -function give_donation_total_of_user( $user = null ) { |
|
268 | +function give_donation_total_of_user($user = null) { |
|
269 | 269 | |
270 | - $stats = give_get_donation_stats_by_user( $user ); |
|
270 | + $stats = give_get_donation_stats_by_user($user); |
|
271 | 271 | |
272 | 272 | return $stats['total_spent']; |
273 | 273 | } |
@@ -283,40 +283,40 @@ discard block |
||
283 | 283 | * |
284 | 284 | * @return bool |
285 | 285 | */ |
286 | -function give_validate_username( $username, $form_id = 0 ) { |
|
286 | +function give_validate_username($username, $form_id = 0) { |
|
287 | 287 | $valid = true; |
288 | 288 | |
289 | 289 | // Validate username. |
290 | - if ( ! empty( $username ) ) { |
|
290 | + if ( ! empty($username)) { |
|
291 | 291 | |
292 | 292 | // Sanitize username. |
293 | - $sanitized_user_name = sanitize_user( $username, false ); |
|
293 | + $sanitized_user_name = sanitize_user($username, false); |
|
294 | 294 | |
295 | 295 | // We have an user name, check if it already exists. |
296 | - if ( username_exists( $username ) ) { |
|
296 | + if (username_exists($username)) { |
|
297 | 297 | // Username already registered. |
298 | - give_set_error( 'username_unavailable', __( 'Username already taken.', 'give' ) ); |
|
298 | + give_set_error('username_unavailable', __('Username already taken.', 'give')); |
|
299 | 299 | $valid = false; |
300 | 300 | |
301 | 301 | // Check if it's valid. |
302 | - } elseif ( $sanitized_user_name !== $username ) { |
|
302 | + } elseif ($sanitized_user_name !== $username) { |
|
303 | 303 | // Invalid username. |
304 | - if ( is_multisite() ) { |
|
305 | - give_set_error( 'username_invalid', __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ) ); |
|
304 | + if (is_multisite()) { |
|
305 | + give_set_error('username_invalid', __('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give')); |
|
306 | 306 | $valid = false; |
307 | 307 | } else { |
308 | - give_set_error( 'username_invalid', __( 'Invalid username.', 'give' ) ); |
|
308 | + give_set_error('username_invalid', __('Invalid username.', 'give')); |
|
309 | 309 | $valid = false; |
310 | 310 | } |
311 | 311 | } |
312 | 312 | } else { |
313 | 313 | // Username is empty. |
314 | - give_set_error( 'username_empty', __( 'Enter a username.', 'give' ) ); |
|
314 | + give_set_error('username_empty', __('Enter a username.', 'give')); |
|
315 | 315 | $valid = false; |
316 | 316 | |
317 | 317 | // Check if guest checkout is disable for form. |
318 | - if ( $form_id && give_logged_in_only( $form_id ) ) { |
|
319 | - give_set_error( 'registration_required', __( 'You must register or login to complete your donation.', 'give' ) ); |
|
318 | + if ($form_id && give_logged_in_only($form_id)) { |
|
319 | + give_set_error('registration_required', __('You must register or login to complete your donation.', 'give')); |
|
320 | 320 | $valid = false; |
321 | 321 | } |
322 | 322 | } |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | * @param string $username |
331 | 331 | * @param bool $form_id |
332 | 332 | */ |
333 | - $valid = (bool) apply_filters( 'give_validate_username', $valid, $username, $form_id ); |
|
333 | + $valid = (bool) apply_filters('give_validate_username', $valid, $username, $form_id); |
|
334 | 334 | |
335 | 335 | return $valid; |
336 | 336 | } |
@@ -346,22 +346,22 @@ discard block |
||
346 | 346 | * |
347 | 347 | * @return bool |
348 | 348 | */ |
349 | -function give_validate_user_email( $email, $registering_new_user = false ) { |
|
349 | +function give_validate_user_email($email, $registering_new_user = false) { |
|
350 | 350 | $valid = true; |
351 | 351 | |
352 | - if ( empty( $email ) ) { |
|
352 | + if (empty($email)) { |
|
353 | 353 | // No email. |
354 | - give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) ); |
|
354 | + give_set_error('email_empty', __('Enter an email.', 'give')); |
|
355 | 355 | $valid = false; |
356 | 356 | |
357 | - } elseif ( ! is_email( $email ) ) { |
|
357 | + } elseif ( ! is_email($email)) { |
|
358 | 358 | // Validate email. |
359 | - give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) ); |
|
359 | + give_set_error('email_invalid', __('Invalid email.', 'give')); |
|
360 | 360 | $valid = false; |
361 | 361 | |
362 | - } elseif ( $registering_new_user && ( give_donor_email_exists( $email ) || email_exists( $email ) ) ) { |
|
362 | + } elseif ($registering_new_user && (give_donor_email_exists($email) || email_exists($email))) { |
|
363 | 363 | // Check if email exists. |
364 | - give_set_error( 'email_used', __( 'The email address provided is already active for another user.', 'give' ) ); |
|
364 | + give_set_error('email_used', __('The email address provided is already active for another user.', 'give')); |
|
365 | 365 | $valid = false; |
366 | 366 | } |
367 | 367 | |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | * @param string $email |
375 | 375 | * @param bool $registering_new_user |
376 | 376 | */ |
377 | - $valid = (bool) apply_filters( 'give_validate_user_email', $valid, $email, $registering_new_user ); |
|
377 | + $valid = (bool) apply_filters('give_validate_user_email', $valid, $email, $registering_new_user); |
|
378 | 378 | |
379 | 379 | return $valid; |
380 | 380 | } |
@@ -390,34 +390,34 @@ discard block |
||
390 | 390 | * |
391 | 391 | * @return bool |
392 | 392 | */ |
393 | -function give_validate_user_password( $password = '', $confirm_password = '', $registering_new_user = false ) { |
|
393 | +function give_validate_user_password($password = '', $confirm_password = '', $registering_new_user = false) { |
|
394 | 394 | $valid = true; |
395 | 395 | |
396 | 396 | // Passwords Validation For New Donors Only |
397 | - if ( $registering_new_user ) { |
|
397 | + if ($registering_new_user) { |
|
398 | 398 | // Password or confirmation missing. |
399 | - if ( ! $password ) { |
|
399 | + if ( ! $password) { |
|
400 | 400 | // The password is invalid. |
401 | - give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) ); |
|
401 | + give_set_error('password_empty', __('Enter a password.', 'give')); |
|
402 | 402 | $valid = false; |
403 | - } elseif ( ! $confirm_password ) { |
|
403 | + } elseif ( ! $confirm_password) { |
|
404 | 404 | // Confirmation password is invalid. |
405 | - give_set_error( 'confirmation_empty', __( 'Enter the password confirmation.', 'give' ) ); |
|
405 | + give_set_error('confirmation_empty', __('Enter the password confirmation.', 'give')); |
|
406 | 406 | $valid = false; |
407 | 407 | } |
408 | 408 | } |
409 | 409 | // Passwords Validation For New Donors as well as Existing Donors |
410 | - if( $password || $confirm_password ) { |
|
411 | - if ( strlen( $password ) < 6 || strlen( $confirm_password ) < 6 ) { |
|
410 | + if ($password || $confirm_password) { |
|
411 | + if (strlen($password) < 6 || strlen($confirm_password) < 6) { |
|
412 | 412 | // Seems Weak Password |
413 | - give_set_error( 'password_weak', __( 'Passwords should have at least 6 characters.', 'give' ) ); |
|
413 | + give_set_error('password_weak', __('Passwords should have at least 6 characters.', 'give')); |
|
414 | 414 | $valid = false; |
415 | 415 | } |
416 | - if ( $password && $confirm_password ) { |
|
416 | + if ($password && $confirm_password) { |
|
417 | 417 | // Verify confirmation matches. |
418 | - if ( $password != $confirm_password ) { |
|
418 | + if ($password != $confirm_password) { |
|
419 | 419 | // Passwords do not match |
420 | - give_set_error( 'password_mismatch', __( 'Passwords you entered do not match. Please try again.', 'give' ) ); |
|
420 | + give_set_error('password_mismatch', __('Passwords you entered do not match. Please try again.', 'give')); |
|
421 | 421 | $valid = false; |
422 | 422 | } |
423 | 423 | } |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | * @param string $confirm_password |
434 | 434 | * @param bool $registering_new_user |
435 | 435 | */ |
436 | - $valid = (bool) apply_filters( 'give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user ); |
|
436 | + $valid = (bool) apply_filters('give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user); |
|
437 | 437 | |
438 | 438 | return $valid; |
439 | 439 | } |
@@ -451,33 +451,33 @@ discard block |
||
451 | 451 | * |
452 | 452 | * @return void |
453 | 453 | */ |
454 | -function give_add_past_donations_to_new_user( $user_id ) { |
|
454 | +function give_add_past_donations_to_new_user($user_id) { |
|
455 | 455 | |
456 | - $email = get_the_author_meta( 'user_email', $user_id ); |
|
456 | + $email = get_the_author_meta('user_email', $user_id); |
|
457 | 457 | |
458 | - $payments = give_get_payments( array( |
|
458 | + $payments = give_get_payments(array( |
|
459 | 459 | 's' => $email, |
460 | - ) ); |
|
460 | + )); |
|
461 | 461 | |
462 | - if ( $payments ) { |
|
463 | - foreach ( $payments as $payment ) { |
|
464 | - if ( intval( give_get_payment_user_id( $payment->ID ) ) > 0 ) { |
|
462 | + if ($payments) { |
|
463 | + foreach ($payments as $payment) { |
|
464 | + if (intval(give_get_payment_user_id($payment->ID)) > 0) { |
|
465 | 465 | continue; |
466 | 466 | } // End if(). |
467 | 467 | |
468 | - $meta = give_get_payment_meta( $payment->ID ); |
|
469 | - $meta['user_info'] = maybe_unserialize( $meta['user_info'] ); |
|
468 | + $meta = give_get_payment_meta($payment->ID); |
|
469 | + $meta['user_info'] = maybe_unserialize($meta['user_info']); |
|
470 | 470 | $meta['user_info']['id'] = $user_id; |
471 | 471 | |
472 | 472 | // Store the updated user ID in the payment meta. |
473 | - give_update_payment_meta( $payment->ID, '_give_payment_meta', $meta ); |
|
474 | - give_update_payment_meta( $payment->ID, '_give_payment_user_id', $user_id ); |
|
473 | + give_update_payment_meta($payment->ID, '_give_payment_meta', $meta); |
|
474 | + give_update_payment_meta($payment->ID, '_give_payment_user_id', $user_id); |
|
475 | 475 | } |
476 | 476 | } |
477 | 477 | |
478 | 478 | } |
479 | 479 | |
480 | -add_action( 'user_register', 'give_add_past_donations_to_new_user' ); |
|
480 | +add_action('user_register', 'give_add_past_donations_to_new_user'); |
|
481 | 481 | |
482 | 482 | |
483 | 483 | /** |
@@ -503,34 +503,34 @@ discard block |
||
503 | 503 | * |
504 | 504 | * @return array The donor's address, if any |
505 | 505 | */ |
506 | -function give_get_donor_address( $user_id = 0 ) { |
|
507 | - if ( empty( $user_id ) ) { |
|
506 | +function give_get_donor_address($user_id = 0) { |
|
507 | + if (empty($user_id)) { |
|
508 | 508 | $user_id = get_current_user_id(); |
509 | 509 | } |
510 | 510 | |
511 | - $address = get_user_meta( $user_id, '_give_user_address', true ); |
|
511 | + $address = get_user_meta($user_id, '_give_user_address', true); |
|
512 | 512 | |
513 | - if ( ! isset( $address['line1'] ) ) { |
|
513 | + if ( ! isset($address['line1'])) { |
|
514 | 514 | $address['line1'] = ''; |
515 | 515 | } |
516 | 516 | |
517 | - if ( ! isset( $address['line2'] ) ) { |
|
517 | + if ( ! isset($address['line2'])) { |
|
518 | 518 | $address['line2'] = ''; |
519 | 519 | } |
520 | 520 | |
521 | - if ( ! isset( $address['city'] ) ) { |
|
521 | + if ( ! isset($address['city'])) { |
|
522 | 522 | $address['city'] = ''; |
523 | 523 | } |
524 | 524 | |
525 | - if ( ! isset( $address['zip'] ) ) { |
|
525 | + if ( ! isset($address['zip'])) { |
|
526 | 526 | $address['zip'] = ''; |
527 | 527 | } |
528 | 528 | |
529 | - if ( ! isset( $address['country'] ) ) { |
|
529 | + if ( ! isset($address['country'])) { |
|
530 | 530 | $address['country'] = ''; |
531 | 531 | } |
532 | 532 | |
533 | - if ( ! isset( $address['state'] ) ) { |
|
533 | + if ( ! isset($address['state'])) { |
|
534 | 534 | $address['state'] = ''; |
535 | 535 | } |
536 | 536 | |
@@ -550,32 +550,32 @@ discard block |
||
550 | 550 | * |
551 | 551 | * @return void |
552 | 552 | */ |
553 | -function give_new_user_notification( $user_id = 0, $user_data = array() ) { |
|
553 | +function give_new_user_notification($user_id = 0, $user_data = array()) { |
|
554 | 554 | |
555 | - if ( empty( $user_id ) || empty( $user_data ) ) { |
|
555 | + if (empty($user_id) || empty($user_data)) { |
|
556 | 556 | return; |
557 | 557 | } |
558 | - $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
|
558 | + $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
|
559 | 559 | |
560 | 560 | |
561 | 561 | // New User Registration: Email sends to the site admin. |
562 | 562 | $emails = Give()->emails; |
563 | - $emails->__set( 'heading', esc_html__( 'New User Registration', 'give' ) ); |
|
563 | + $emails->__set('heading', esc_html__('New User Registration', 'give')); |
|
564 | 564 | |
565 | 565 | /* translators: %s: site name */ |
566 | - $message = sprintf( esc_attr__( 'A new user has registered on %s:', 'give' ), $blogname ) . "\r\n\r\n"; |
|
566 | + $message = sprintf(esc_attr__('A new user has registered on %s:', 'give'), $blogname)."\r\n\r\n"; |
|
567 | 567 | /* translators: %s: user login */ |
568 | - $message .= '<strong>' . esc_attr__( 'Username:', 'give' ) . '</strong> ' . $user_data['user_login'] . "\r\n"; |
|
568 | + $message .= '<strong>'.esc_attr__('Username:', 'give').'</strong> '.$user_data['user_login']."\r\n"; |
|
569 | 569 | /* translators: %s: user email */ |
570 | - $message .= '<strong>' . esc_attr__( 'E-mail:', 'give' ) . '</strong> ' . $user_data['user_email'] . "\r\n\r\n"; |
|
570 | + $message .= '<strong>'.esc_attr__('E-mail:', 'give').'</strong> '.$user_data['user_email']."\r\n\r\n"; |
|
571 | 571 | |
572 | - $message .= '<a href="' . admin_url('user-edit.php?user_id=' . $user_id) . '" target="_blank"> ' . esc_attr__( 'Click here to view »', 'give' ) . '</a>' . "\r\n"; |
|
572 | + $message .= '<a href="'.admin_url('user-edit.php?user_id='.$user_id).'" target="_blank"> '.esc_attr__('Click here to view »', 'give').'</a>'."\r\n"; |
|
573 | 573 | |
574 | 574 | $emails->send( |
575 | - get_option( 'admin_email' ), |
|
575 | + get_option('admin_email'), |
|
576 | 576 | sprintf( |
577 | 577 | /* translators: %s: site name */ |
578 | - esc_attr__( '[%s] New User Registration', 'give' ), |
|
578 | + esc_attr__('[%s] New User Registration', 'give'), |
|
579 | 579 | $blogname |
580 | 580 | ), |
581 | 581 | $message |
@@ -583,22 +583,22 @@ discard block |
||
583 | 583 | |
584 | 584 | |
585 | 585 | // Account Information: Email sends to donor who registered. |
586 | - $emails->__set( 'heading', esc_html__( 'Account Information', 'give' ) ); |
|
586 | + $emails->__set('heading', esc_html__('Account Information', 'give')); |
|
587 | 587 | |
588 | - $message = sprintf( esc_attr__( 'The following email contains your account information for %s:', 'give' ), $blogname ) . "\r\n\r\n"; |
|
588 | + $message = sprintf(esc_attr__('The following email contains your account information for %s:', 'give'), $blogname)."\r\n\r\n"; |
|
589 | 589 | |
590 | 590 | /* translators: %s: user login */ |
591 | - $message .= '<strong>' . esc_attr__( 'Username:', 'give' ) . '</strong> ' . $user_data['user_login'] . "\r\n"; |
|
591 | + $message .= '<strong>'.esc_attr__('Username:', 'give').'</strong> '.$user_data['user_login']."\r\n"; |
|
592 | 592 | /* translators: %s: password */ |
593 | - $message .= '<strong>' . esc_attr__( 'Password:', 'give' ) . '</strong> ' . esc_attr__( '[Password entered during donation]', 'give' ) . "\r\n\r\n"; |
|
593 | + $message .= '<strong>'.esc_attr__('Password:', 'give').'</strong> '.esc_attr__('[Password entered during donation]', 'give')."\r\n\r\n"; |
|
594 | 594 | |
595 | - $message .= '<a href="' . wp_login_url() . '" target="_blank"> ' . esc_attr__( 'Click here to login »', 'give' ) . '</a>' . "\r\n"; |
|
595 | + $message .= '<a href="'.wp_login_url().'" target="_blank"> '.esc_attr__('Click here to login »', 'give').'</a>'."\r\n"; |
|
596 | 596 | |
597 | 597 | $emails->send( |
598 | 598 | $user_data['user_email'], |
599 | 599 | sprintf( |
600 | 600 | /* translators: %s: site name */ |
601 | - esc_attr__( '[%s] Your username and password', 'give' ), |
|
601 | + esc_attr__('[%s] Your username and password', 'give'), |
|
602 | 602 | $blogname |
603 | 603 | ), |
604 | 604 | $message |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | |
607 | 607 | } |
608 | 608 | |
609 | -add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 ); |
|
609 | +add_action('give_insert_user', 'give_new_user_notification', 10, 2); |
|
610 | 610 | |
611 | 611 | |
612 | 612 | /** |
@@ -622,34 +622,34 @@ discard block |
||
622 | 622 | * |
623 | 623 | * @return string |
624 | 624 | */ |
625 | -function give_get_donor_name_by( $id = 0, $from = 'donation' ) { |
|
625 | +function give_get_donor_name_by($id = 0, $from = 'donation') { |
|
626 | 626 | |
627 | 627 | // ID shouldn't be empty |
628 | - if ( empty( $id ) ) { |
|
628 | + if (empty($id)) { |
|
629 | 629 | return; |
630 | 630 | } |
631 | 631 | |
632 | 632 | $name = ''; |
633 | 633 | |
634 | - switch ( $from ) { |
|
634 | + switch ($from) { |
|
635 | 635 | |
636 | 636 | case 'donation': |
637 | 637 | |
638 | - $user_info = give_get_payment_meta_user_info( $id ); |
|
639 | - $name = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
638 | + $user_info = give_get_payment_meta_user_info($id); |
|
639 | + $name = $user_info['first_name'].' '.$user_info['last_name']; |
|
640 | 640 | |
641 | 641 | break; |
642 | 642 | |
643 | 643 | case 'donor': |
644 | 644 | |
645 | - $donor = new Give_Donor( $id ); |
|
645 | + $donor = new Give_Donor($id); |
|
646 | 646 | $name = $donor->name; |
647 | 647 | |
648 | 648 | break; |
649 | 649 | |
650 | 650 | } |
651 | 651 | |
652 | - return trim( $name ); |
|
652 | + return trim($name); |
|
653 | 653 | |
654 | 654 | } |
655 | 655 | |
@@ -661,8 +661,8 @@ discard block |
||
661 | 661 | * @param string $email Donor Email. |
662 | 662 | * @return boolean The user's ID on success, and false on failure. |
663 | 663 | */ |
664 | -function give_donor_email_exists( $email ) { |
|
665 | - if ( Give()->donors->get_donor_by( 'email', $email ) ) { |
|
664 | +function give_donor_email_exists($email) { |
|
665 | + if (Give()->donors->get_donor_by('email', $email)) { |
|
666 | 666 | return true; |
667 | 667 | } |
668 | 668 | return false; |
@@ -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 | |
@@ -20,19 +20,19 @@ discard block |
||
20 | 20 | * @since 1.8 |
21 | 21 | */ |
22 | 22 | function give_load_wp_editor() { |
23 | - if ( ! isset( $_POST['wp_editor'] ) ) { |
|
23 | + if ( ! isset($_POST['wp_editor'])) { |
|
24 | 24 | die(); |
25 | 25 | } |
26 | 26 | |
27 | - $wp_editor = json_decode( base64_decode( $_POST['wp_editor'] ), true ); |
|
27 | + $wp_editor = json_decode(base64_decode($_POST['wp_editor']), true); |
|
28 | 28 | $wp_editor[2]['textarea_name'] = $_POST['textarea_name']; |
29 | 29 | |
30 | - wp_editor( $wp_editor[0], $_POST['wp_editor_id'], $wp_editor[2] ); |
|
30 | + wp_editor($wp_editor[0], $_POST['wp_editor_id'], $wp_editor[2]); |
|
31 | 31 | |
32 | 32 | die(); |
33 | 33 | } |
34 | 34 | |
35 | -add_action( 'wp_ajax_give_load_wp_editor', 'give_load_wp_editor' ); |
|
35 | +add_action('wp_ajax_give_load_wp_editor', 'give_load_wp_editor'); |
|
36 | 36 | |
37 | 37 | |
38 | 38 | /** |
@@ -52,13 +52,13 @@ discard block |
||
52 | 52 | ); |
53 | 53 | |
54 | 54 | // Get current page. |
55 | - $current_page = isset( $_GET['page'] ) ? esc_attr( $_GET['page'] ) : ''; |
|
55 | + $current_page = isset($_GET['page']) ? esc_attr($_GET['page']) : ''; |
|
56 | 56 | |
57 | 57 | // Bailout. |
58 | 58 | if ( |
59 | - empty( $current_page ) |
|
60 | - || empty( $_GET['_wp_http_referer'] ) |
|
61 | - || ! in_array( $current_page, $give_pages ) |
|
59 | + empty($current_page) |
|
60 | + || empty($_GET['_wp_http_referer']) |
|
61 | + || ! in_array($current_page, $give_pages) |
|
62 | 62 | ) { |
63 | 63 | return false; |
64 | 64 | } |
@@ -68,21 +68,21 @@ discard block |
||
68 | 68 | * |
69 | 69 | * @since 1.8 |
70 | 70 | */ |
71 | - $redirect = apply_filters( "give_validate_{$current_page}", true ); |
|
71 | + $redirect = apply_filters("give_validate_{$current_page}", true); |
|
72 | 72 | |
73 | - if ( $redirect ) { |
|
73 | + if ($redirect) { |
|
74 | 74 | // Redirect. |
75 | 75 | wp_redirect( |
76 | 76 | remove_query_arg( |
77 | - array( '_wp_http_referer', '_wpnonce' ), |
|
78 | - wp_unslash( $_SERVER['REQUEST_URI'] ) |
|
77 | + array('_wp_http_referer', '_wpnonce'), |
|
78 | + wp_unslash($_SERVER['REQUEST_URI']) |
|
79 | 79 | ) |
80 | 80 | ); |
81 | 81 | exit; |
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
85 | -add_action( 'admin_init', 'give_redirect_to_clean_url_admin_pages' ); |
|
85 | +add_action('admin_init', 'give_redirect_to_clean_url_admin_pages'); |
|
86 | 86 | |
87 | 87 | |
88 | 88 | /** |
@@ -96,25 +96,25 @@ discard block |
||
96 | 96 | */ |
97 | 97 | function give_hide_outdated_php_notice() { |
98 | 98 | |
99 | - if ( ! isset( $_POST['_give_hide_outdated_php_notices_shortly'] ) ) { |
|
99 | + if ( ! isset($_POST['_give_hide_outdated_php_notices_shortly'])) { |
|
100 | 100 | give_die(); |
101 | 101 | } |
102 | 102 | |
103 | 103 | // Transient key name. |
104 | 104 | $transient_key = "_give_hide_outdated_php_notices_shortly"; |
105 | 105 | |
106 | - if ( Give_Cache::get( $transient_key, true ) ) { |
|
106 | + if (Give_Cache::get($transient_key, true)) { |
|
107 | 107 | return; |
108 | 108 | } |
109 | 109 | |
110 | 110 | // Hide notice for 24 hours. |
111 | - Give_Cache::set( $transient_key, true, DAY_IN_SECONDS, true ); |
|
111 | + Give_Cache::set($transient_key, true, DAY_IN_SECONDS, true); |
|
112 | 112 | |
113 | 113 | give_die(); |
114 | 114 | |
115 | 115 | } |
116 | 116 | |
117 | -add_action( 'wp_ajax_give_hide_outdated_php_notice', 'give_hide_outdated_php_notice' ); |
|
117 | +add_action('wp_ajax_give_hide_outdated_php_notice', 'give_hide_outdated_php_notice'); |
|
118 | 118 | |
119 | 119 | /** |
120 | 120 | * Register admin notices. |
@@ -123,23 +123,23 @@ discard block |
||
123 | 123 | */ |
124 | 124 | function _give_register_admin_notices() { |
125 | 125 | // Bailout. |
126 | - if( ! is_admin() ) { |
|
126 | + if ( ! is_admin()) { |
|
127 | 127 | return; |
128 | 128 | } |
129 | 129 | |
130 | 130 | // Add payment bulk notice. |
131 | 131 | if ( |
132 | - current_user_can( 'edit_give_payments' ) |
|
133 | - && isset( $_GET['action'] ) |
|
134 | - && ! empty( $_GET['action'] ) |
|
135 | - && isset( $_GET['payment'] ) |
|
136 | - && ! empty( $_GET['payment'] ) |
|
132 | + current_user_can('edit_give_payments') |
|
133 | + && isset($_GET['action']) |
|
134 | + && ! empty($_GET['action']) |
|
135 | + && isset($_GET['payment']) |
|
136 | + && ! empty($_GET['payment']) |
|
137 | 137 | ) { |
138 | - $payment_count = isset( $_GET['payment'] ) ? count( $_GET['payment'] ) : 0; |
|
138 | + $payment_count = isset($_GET['payment']) ? count($_GET['payment']) : 0; |
|
139 | 139 | |
140 | - switch ( $_GET['action'] ) { |
|
140 | + switch ($_GET['action']) { |
|
141 | 141 | case 'delete': |
142 | - Give()->notices->register_notice( array( |
|
142 | + Give()->notices->register_notice(array( |
|
143 | 143 | 'id' => 'bulk_action_delete', |
144 | 144 | 'type' => 'updated', |
145 | 145 | 'description' => sprintf( |
@@ -151,12 +151,12 @@ discard block |
||
151 | 151 | ), |
152 | 152 | $payment_count ), |
153 | 153 | 'show' => true, |
154 | - ) ); |
|
154 | + )); |
|
155 | 155 | |
156 | 156 | break; |
157 | 157 | |
158 | 158 | case 'resend-receipt': |
159 | - Give()->notices->register_notice( array( |
|
159 | + Give()->notices->register_notice(array( |
|
160 | 160 | 'id' => 'bulk_action_resend_receipt', |
161 | 161 | 'type' => 'updated', |
162 | 162 | 'description' => sprintf( |
@@ -169,196 +169,196 @@ discard block |
||
169 | 169 | $payment_count |
170 | 170 | ), |
171 | 171 | 'show' => true, |
172 | - ) ); |
|
172 | + )); |
|
173 | 173 | break; |
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
177 | 177 | // Add give message notices. |
178 | - if ( ! empty( $_GET['give-message'] ) ) { |
|
178 | + if ( ! empty($_GET['give-message'])) { |
|
179 | 179 | // Donation reports errors. |
180 | - if ( current_user_can( 'view_give_reports' ) ) { |
|
181 | - switch ( $_GET['give-message'] ) { |
|
180 | + if (current_user_can('view_give_reports')) { |
|
181 | + switch ($_GET['give-message']) { |
|
182 | 182 | case 'donation_deleted' : |
183 | - Give()->notices->register_notice( array( |
|
183 | + Give()->notices->register_notice(array( |
|
184 | 184 | 'id' => 'give-donation-deleted', |
185 | 185 | 'type' => 'updated', |
186 | - 'description' => __( 'The donation has been deleted.', 'give' ), |
|
186 | + 'description' => __('The donation has been deleted.', 'give'), |
|
187 | 187 | 'show' => true, |
188 | - ) ); |
|
188 | + )); |
|
189 | 189 | break; |
190 | 190 | case 'email_sent' : |
191 | - Give()->notices->register_notice( array( |
|
191 | + Give()->notices->register_notice(array( |
|
192 | 192 | 'id' => 'give-payment-sent', |
193 | 193 | 'type' => 'updated', |
194 | - 'description' => __( 'The donation receipt has been resent.', 'give' ), |
|
194 | + 'description' => __('The donation receipt has been resent.', 'give'), |
|
195 | 195 | 'show' => true, |
196 | - ) ); |
|
196 | + )); |
|
197 | 197 | break; |
198 | 198 | case 'refreshed-reports' : |
199 | - Give()->notices->register_notice( array( |
|
199 | + Give()->notices->register_notice(array( |
|
200 | 200 | 'id' => 'give-refreshed-reports', |
201 | 201 | 'type' => 'updated', |
202 | - 'description' => __( 'The reports cache has been cleared.', 'give' ), |
|
202 | + 'description' => __('The reports cache has been cleared.', 'give'), |
|
203 | 203 | 'show' => true, |
204 | - ) ); |
|
204 | + )); |
|
205 | 205 | break; |
206 | 206 | case 'donation-note-deleted' : |
207 | - Give()->notices->register_notice( array( |
|
207 | + Give()->notices->register_notice(array( |
|
208 | 208 | 'id' => 'give-donation-note-deleted', |
209 | 209 | 'type' => 'updated', |
210 | - 'description' => __( 'The donation note has been deleted.', 'give' ), |
|
210 | + 'description' => __('The donation note has been deleted.', 'give'), |
|
211 | 211 | 'show' => true, |
212 | - ) ); |
|
212 | + )); |
|
213 | 213 | break; |
214 | 214 | } |
215 | 215 | } |
216 | 216 | |
217 | 217 | // Give settings notices and errors. |
218 | - if ( current_user_can( 'manage_give_settings' ) ) { |
|
219 | - switch ( $_GET['give-message'] ) { |
|
218 | + if (current_user_can('manage_give_settings')) { |
|
219 | + switch ($_GET['give-message']) { |
|
220 | 220 | case 'settings-imported' : |
221 | - Give()->notices->register_notice( array( |
|
221 | + Give()->notices->register_notice(array( |
|
222 | 222 | 'id' => 'give-settings-imported', |
223 | 223 | 'type' => 'updated', |
224 | - 'description' => __( 'The settings have been imported.', 'give' ), |
|
224 | + 'description' => __('The settings have been imported.', 'give'), |
|
225 | 225 | 'show' => true, |
226 | - ) ); |
|
226 | + )); |
|
227 | 227 | break; |
228 | 228 | case 'api-key-generated' : |
229 | - Give()->notices->register_notice( array( |
|
229 | + Give()->notices->register_notice(array( |
|
230 | 230 | 'id' => 'give-api-key-generated', |
231 | 231 | 'type' => 'updated', |
232 | - 'description' => __( 'API keys have been generated.', 'give' ), |
|
232 | + 'description' => __('API keys have been generated.', 'give'), |
|
233 | 233 | 'show' => true, |
234 | - ) ); |
|
234 | + )); |
|
235 | 235 | break; |
236 | 236 | case 'api-key-exists' : |
237 | - Give()->notices->register_notice( array( |
|
237 | + Give()->notices->register_notice(array( |
|
238 | 238 | 'id' => 'give-api-key-exists', |
239 | 239 | 'type' => 'updated', |
240 | - 'description' => __( 'The specified user already has API keys.', 'give' ), |
|
240 | + 'description' => __('The specified user already has API keys.', 'give'), |
|
241 | 241 | 'show' => true, |
242 | - ) ); |
|
242 | + )); |
|
243 | 243 | break; |
244 | 244 | case 'api-key-regenerated' : |
245 | - Give()->notices->register_notice( array( |
|
245 | + Give()->notices->register_notice(array( |
|
246 | 246 | 'id' => 'give-api-key-regenerated', |
247 | 247 | 'type' => 'updated', |
248 | - 'description' => __( 'API keys have been regenerated.', 'give' ), |
|
248 | + 'description' => __('API keys have been regenerated.', 'give'), |
|
249 | 249 | 'show' => true, |
250 | - ) ); |
|
250 | + )); |
|
251 | 251 | break; |
252 | 252 | case 'api-key-revoked' : |
253 | - Give()->notices->register_notice( array( |
|
253 | + Give()->notices->register_notice(array( |
|
254 | 254 | 'id' => 'give-api-key-revoked', |
255 | 255 | 'type' => 'updated', |
256 | - 'description' => __( 'API keys have been revoked.', 'give' ), |
|
256 | + 'description' => __('API keys have been revoked.', 'give'), |
|
257 | 257 | 'show' => true, |
258 | - ) ); |
|
258 | + )); |
|
259 | 259 | break; |
260 | 260 | case 'sent-test-email' : |
261 | - Give()->notices->register_notice( array( |
|
261 | + Give()->notices->register_notice(array( |
|
262 | 262 | 'id' => 'give-sent-test-email', |
263 | 263 | 'type' => 'updated', |
264 | - 'description' => __( 'The test email has been sent.', 'give' ), |
|
264 | + 'description' => __('The test email has been sent.', 'give'), |
|
265 | 265 | 'show' => true, |
266 | - ) ); |
|
266 | + )); |
|
267 | 267 | break; |
268 | 268 | case 'matched-success-failure-page': |
269 | - Give()->notices->register_notice( array( |
|
269 | + Give()->notices->register_notice(array( |
|
270 | 270 | 'id' => 'give-matched-success-failure-page', |
271 | 271 | 'type' => 'updated', |
272 | - 'description' => __( 'You cannot set the success and failed pages to the same page', 'give' ), |
|
272 | + 'description' => __('You cannot set the success and failed pages to the same page', 'give'), |
|
273 | 273 | 'show' => true, |
274 | - ) ); |
|
274 | + )); |
|
275 | 275 | break; |
276 | 276 | } |
277 | 277 | } |
278 | 278 | // Payments errors. |
279 | - if ( current_user_can( 'edit_give_payments' ) ) { |
|
280 | - switch ( $_GET['give-message'] ) { |
|
279 | + if (current_user_can('edit_give_payments')) { |
|
280 | + switch ($_GET['give-message']) { |
|
281 | 281 | case 'note-added' : |
282 | - Give()->notices->register_notice( array( |
|
282 | + Give()->notices->register_notice(array( |
|
283 | 283 | 'id' => 'give-note-added', |
284 | 284 | 'type' => 'updated', |
285 | - 'description' => __( 'The donation note has been added.', 'give' ), |
|
285 | + 'description' => __('The donation note has been added.', 'give'), |
|
286 | 286 | 'show' => true, |
287 | - ) ); |
|
287 | + )); |
|
288 | 288 | break; |
289 | 289 | case 'payment-updated' : |
290 | - Give()->notices->register_notice( array( |
|
290 | + Give()->notices->register_notice(array( |
|
291 | 291 | 'id' => 'give-payment-updated', |
292 | 292 | 'type' => 'updated', |
293 | - 'description' => __( 'The donation has been updated.', 'give' ), |
|
293 | + 'description' => __('The donation has been updated.', 'give'), |
|
294 | 294 | 'show' => true, |
295 | - ) ); |
|
295 | + )); |
|
296 | 296 | break; |
297 | 297 | } |
298 | 298 | } |
299 | 299 | |
300 | 300 | // Donor Notices. |
301 | - if ( current_user_can( 'edit_give_payments' ) ) { |
|
302 | - switch ( $_GET['give-message'] ) { |
|
301 | + if (current_user_can('edit_give_payments')) { |
|
302 | + switch ($_GET['give-message']) { |
|
303 | 303 | case 'donor-deleted' : |
304 | - Give()->notices->register_notice( array( |
|
304 | + Give()->notices->register_notice(array( |
|
305 | 305 | 'id' => 'give-donor-deleted', |
306 | 306 | 'type' => 'updated', |
307 | - 'description' => __( 'The donor has been deleted.', 'give' ), |
|
307 | + 'description' => __('The donor has been deleted.', 'give'), |
|
308 | 308 | 'show' => true, |
309 | - ) ); |
|
309 | + )); |
|
310 | 310 | break; |
311 | 311 | |
312 | 312 | case 'email-added' : |
313 | - Give()->notices->register_notice( array( |
|
313 | + Give()->notices->register_notice(array( |
|
314 | 314 | 'id' => 'give-donor-email-added', |
315 | 315 | 'type' => 'updated', |
316 | - 'description' => __( 'Donor email added.', 'give' ), |
|
316 | + 'description' => __('Donor email added.', 'give'), |
|
317 | 317 | 'show' => true, |
318 | - ) ); |
|
318 | + )); |
|
319 | 319 | break; |
320 | 320 | |
321 | 321 | case 'email-removed' : |
322 | - Give()->notices->register_notice( array( |
|
322 | + Give()->notices->register_notice(array( |
|
323 | 323 | 'id' => 'give-donor-email-removed', |
324 | 324 | 'type' => 'updated', |
325 | - 'description' => __( 'Donor email removed.', 'give' ), |
|
325 | + 'description' => __('Donor email removed.', 'give'), |
|
326 | 326 | 'show' => true, |
327 | - ) ); |
|
327 | + )); |
|
328 | 328 | break; |
329 | 329 | |
330 | 330 | case 'email-remove-failed' : |
331 | - Give()->notices->register_notice( array( |
|
331 | + Give()->notices->register_notice(array( |
|
332 | 332 | 'id' => 'give-donor-email-remove-failed', |
333 | 333 | 'type' => 'updated', |
334 | - 'description' => __( 'Failed to remove donor email.', 'give' ), |
|
334 | + 'description' => __('Failed to remove donor email.', 'give'), |
|
335 | 335 | 'show' => true, |
336 | - ) ); |
|
336 | + )); |
|
337 | 337 | break; |
338 | 338 | |
339 | 339 | case 'primary-email-updated' : |
340 | - Give()->notices->register_notice( array( |
|
340 | + Give()->notices->register_notice(array( |
|
341 | 341 | 'id' => 'give-donor-primary-email-updated', |
342 | 342 | 'type' => 'updated', |
343 | - 'description' => __( 'Primary email updated for donor.', 'give' ), |
|
343 | + 'description' => __('Primary email updated for donor.', 'give'), |
|
344 | 344 | 'show' => true, |
345 | - ) ); |
|
345 | + )); |
|
346 | 346 | break; |
347 | 347 | |
348 | 348 | case 'primary-email-failed' : |
349 | - Give()->notices->register_notice( array( |
|
349 | + Give()->notices->register_notice(array( |
|
350 | 350 | 'id' => 'give-donor-primary-email-failed', |
351 | 351 | 'type' => 'updated', |
352 | - 'description' => __( 'Failed to set primary email.', 'give' ), |
|
352 | + 'description' => __('Failed to set primary email.', 'give'), |
|
353 | 353 | 'show' => true, |
354 | - ) ); |
|
354 | + )); |
|
355 | 355 | break; |
356 | 356 | } |
357 | 357 | } |
358 | 358 | } |
359 | 359 | } |
360 | 360 | |
361 | -add_action( 'admin_notices', '_give_register_admin_notices', - 1 ); |
|
361 | +add_action('admin_notices', '_give_register_admin_notices', - 1); |
|
362 | 362 | |
363 | 363 | |
364 | 364 | /** |
@@ -368,27 +368,26 @@ discard block |
||
368 | 368 | * |
369 | 369 | * @return bool |
370 | 370 | */ |
371 | -function _give_show_test_mode_notice_in_admin_bar( $wp_admin_bar ) { |
|
372 | - $is_test_mode = ! empty( $_POST['test_mode'] ) ? |
|
373 | - give_is_setting_enabled( $_POST['test_mode'] ) : |
|
374 | - give_is_test_mode(); |
|
371 | +function _give_show_test_mode_notice_in_admin_bar($wp_admin_bar) { |
|
372 | + $is_test_mode = ! empty($_POST['test_mode']) ? |
|
373 | + give_is_setting_enabled($_POST['test_mode']) : give_is_test_mode(); |
|
375 | 374 | |
376 | 375 | if ( |
377 | - ! current_user_can( 'view_give_reports' ) || |
|
376 | + ! current_user_can('view_give_reports') || |
|
378 | 377 | ! $is_test_mode |
379 | 378 | ) { |
380 | 379 | return false; |
381 | 380 | } |
382 | 381 | |
383 | 382 | // Add the main siteadmin menu item. |
384 | - $wp_admin_bar->add_menu( array( |
|
383 | + $wp_admin_bar->add_menu(array( |
|
385 | 384 | 'id' => 'give-test-notice', |
386 | - 'href' => admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=gateways' ), |
|
385 | + 'href' => admin_url('edit.php?post_type=give_forms&page=give-settings&tab=gateways'), |
|
387 | 386 | 'parent' => 'top-secondary', |
388 | - 'title' => esc_html__( 'Give Test Mode Active', 'give' ), |
|
389 | - 'meta' => array( 'class' => 'give-test-mode-active' ), |
|
390 | - ) ); |
|
387 | + 'title' => esc_html__('Give Test Mode Active', 'give'), |
|
388 | + 'meta' => array('class' => 'give-test-mode-active'), |
|
389 | + )); |
|
391 | 390 | |
392 | 391 | return true; |
393 | 392 | } |
394 | -add_action( 'admin_bar_menu', '_give_show_test_mode_notice_in_admin_bar', 1000, 1 ); |
|
395 | 393 | \ No newline at end of file |
394 | +add_action('admin_bar_menu', '_give_show_test_mode_notice_in_admin_bar', 1000, 1); |
|
396 | 395 | \ No newline at end of file |