@@ -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_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_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 atleast 6 characters.', 'give' ) ); |
|
413 | + give_set_error('password_weak', __('Passwords should have atleast 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; |
@@ -45,22 +45,22 @@ discard block |
||
45 | 45 | * @param string $default_path Default path. Default is empty. |
46 | 46 | */ |
47 | 47 | function give_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
48 | - if ( ! empty( $args ) && is_array( $args ) ) { |
|
49 | - extract( $args ); |
|
50 | - } |
|
48 | + if ( ! empty( $args ) && is_array( $args ) ) { |
|
49 | + extract( $args ); |
|
50 | + } |
|
51 | 51 | |
52 | - $template_names = array( $template_name . '.php' ); |
|
52 | + $template_names = array( $template_name . '.php' ); |
|
53 | 53 | |
54 | - $located = give_locate_template( $template_names, $template_path, $default_path ); |
|
54 | + $located = give_locate_template( $template_names, $template_path, $default_path ); |
|
55 | 55 | |
56 | - if ( ! file_exists( $located ) ) { |
|
56 | + if ( ! file_exists( $located ) ) { |
|
57 | 57 | /* translators: %s: the template */ |
58 | - Give()->notices->print_frontend_notice( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true ); |
|
59 | - return; |
|
60 | - } |
|
58 | + Give()->notices->print_frontend_notice( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true ); |
|
59 | + return; |
|
60 | + } |
|
61 | 61 | |
62 | - // Allow 3rd party plugin filter template file from their plugin. |
|
63 | - $located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
62 | + // Allow 3rd party plugin filter template file from their plugin. |
|
63 | + $located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * Fires in give template, before the file is included. |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | * @param string $located Template file filter by 3rd party plugin. |
75 | 75 | * @param array $args Passed arguments. |
76 | 76 | */ |
77 | - do_action( 'give_before_template_part', $template_name, $template_path, $located, $args ); |
|
77 | + do_action( 'give_before_template_part', $template_name, $template_path, $located, $args ); |
|
78 | 78 | |
79 | - include( $located ); |
|
79 | + include( $located ); |
|
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Fires in give template, after the file is included. |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param string $located Template file filter by 3rd party plugin. |
91 | 91 | * @param array $args Passed arguments. |
92 | 92 | */ |
93 | - do_action( 'give_after_template_part', $template_name, $template_path, $located, $args ); |
|
93 | + do_action( 'give_after_template_part', $template_name, $template_path, $located, $args ); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -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 | |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @return string |
22 | 22 | */ |
23 | 23 | function give_get_templates_dir() { |
24 | - return GIVE_PLUGIN_DIR . 'templates'; |
|
24 | + return GIVE_PLUGIN_DIR.'templates'; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @return string |
32 | 32 | */ |
33 | 33 | function give_get_templates_url() { |
34 | - return GIVE_PLUGIN_URL . 'templates'; |
|
34 | + return GIVE_PLUGIN_URL.'templates'; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -44,23 +44,23 @@ discard block |
||
44 | 44 | * @param string $template_path Template file path. Default is empty. |
45 | 45 | * @param string $default_path Default path. Default is empty. |
46 | 46 | */ |
47 | -function give_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
48 | - if ( ! empty( $args ) && is_array( $args ) ) { |
|
49 | - extract( $args ); |
|
47 | +function give_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
48 | + if ( ! empty($args) && is_array($args)) { |
|
49 | + extract($args); |
|
50 | 50 | } |
51 | 51 | |
52 | - $template_names = array( $template_name . '.php' ); |
|
52 | + $template_names = array($template_name.'.php'); |
|
53 | 53 | |
54 | - $located = give_locate_template( $template_names, $template_path, $default_path ); |
|
54 | + $located = give_locate_template($template_names, $template_path, $default_path); |
|
55 | 55 | |
56 | - if ( ! file_exists( $located ) ) { |
|
56 | + if ( ! file_exists($located)) { |
|
57 | 57 | /* translators: %s: the template */ |
58 | - Give()->notices->print_frontend_notice( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true ); |
|
58 | + Give()->notices->print_frontend_notice(sprintf(__('The %s template was not found.', 'give'), $located), true); |
|
59 | 59 | return; |
60 | 60 | } |
61 | 61 | |
62 | 62 | // Allow 3rd party plugin filter template file from their plugin. |
63 | - $located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
63 | + $located = apply_filters('give_get_template', $located, $template_name, $args, $template_path, $default_path); |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * Fires in give template, before the file is included. |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | * @param string $located Template file filter by 3rd party plugin. |
75 | 75 | * @param array $args Passed arguments. |
76 | 76 | */ |
77 | - do_action( 'give_before_template_part', $template_name, $template_path, $located, $args ); |
|
77 | + do_action('give_before_template_part', $template_name, $template_path, $located, $args); |
|
78 | 78 | |
79 | - include( $located ); |
|
79 | + include($located); |
|
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Fires in give template, after the file is included. |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param string $located Template file filter by 3rd party plugin. |
91 | 91 | * @param array $args Passed arguments. |
92 | 92 | */ |
93 | - do_action( 'give_after_template_part', $template_name, $template_path, $located, $args ); |
|
93 | + do_action('give_after_template_part', $template_name, $template_path, $located, $args); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @return string |
108 | 108 | */ |
109 | -function give_get_template_part( $slug, $name = null, $load = true ) { |
|
109 | +function give_get_template_part($slug, $name = null, $load = true) { |
|
110 | 110 | |
111 | 111 | /** |
112 | 112 | * Fires in give template part, before the template part is retrieved. |
@@ -118,20 +118,20 @@ discard block |
||
118 | 118 | * @param string $slug Template part file slug {slug}.php. |
119 | 119 | * @param string $name Template part file name {slug}-{name}.php. |
120 | 120 | */ |
121 | - do_action( "get_template_part_{$slug}", $slug, $name ); |
|
121 | + do_action("get_template_part_{$slug}", $slug, $name); |
|
122 | 122 | |
123 | 123 | // Setup possible parts |
124 | 124 | $templates = array(); |
125 | - if ( isset( $name ) ) { |
|
126 | - $templates[] = $slug . '-' . $name . '.php'; |
|
125 | + if (isset($name)) { |
|
126 | + $templates[] = $slug.'-'.$name.'.php'; |
|
127 | 127 | } |
128 | - $templates[] = $slug . '.php'; |
|
128 | + $templates[] = $slug.'.php'; |
|
129 | 129 | |
130 | 130 | // Allow template parts to be filtered |
131 | - $templates = apply_filters( 'give_get_template_part', $templates, $slug, $name ); |
|
131 | + $templates = apply_filters('give_get_template_part', $templates, $slug, $name); |
|
132 | 132 | |
133 | 133 | // Return the part that is found |
134 | - return give_locate_template( $templates, $load, false ); |
|
134 | + return give_locate_template($templates, $load, false); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -152,37 +152,37 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @return string The template filename if one is located. |
154 | 154 | */ |
155 | -function give_locate_template( $template_names, $load = false, $require_once = true ) { |
|
155 | +function give_locate_template($template_names, $load = false, $require_once = true) { |
|
156 | 156 | // No file found yet |
157 | 157 | $located = false; |
158 | 158 | |
159 | 159 | // Try to find a template file |
160 | - foreach ( (array) $template_names as $template_name ) { |
|
160 | + foreach ((array) $template_names as $template_name) { |
|
161 | 161 | |
162 | 162 | // Continue if template is empty |
163 | - if ( empty( $template_name ) ) { |
|
163 | + if (empty($template_name)) { |
|
164 | 164 | continue; |
165 | 165 | } |
166 | 166 | |
167 | 167 | // Trim off any slashes from the template name |
168 | - $template_name = ltrim( $template_name, '/' ); |
|
168 | + $template_name = ltrim($template_name, '/'); |
|
169 | 169 | |
170 | 170 | // try locating this template file by looping through the template paths |
171 | - foreach ( give_get_theme_template_paths() as $template_path ) { |
|
171 | + foreach (give_get_theme_template_paths() as $template_path) { |
|
172 | 172 | |
173 | - if ( file_exists( $template_path . $template_name ) ) { |
|
174 | - $located = $template_path . $template_name; |
|
173 | + if (file_exists($template_path.$template_name)) { |
|
174 | + $located = $template_path.$template_name; |
|
175 | 175 | break; |
176 | 176 | } |
177 | 177 | } |
178 | 178 | |
179 | - if ( $located ) { |
|
179 | + if ($located) { |
|
180 | 180 | break; |
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
184 | - if ( ( true == $load ) && ! empty( $located ) ) { |
|
185 | - load_template( $located, $require_once ); |
|
184 | + if ((true == $load) && ! empty($located)) { |
|
185 | + load_template($located, $require_once); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | return $located; |
@@ -199,17 +199,17 @@ discard block |
||
199 | 199 | $template_dir = give_get_theme_template_dir_name(); |
200 | 200 | |
201 | 201 | $file_paths = array( |
202 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
203 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
202 | + 1 => trailingslashit(get_stylesheet_directory()).$template_dir, |
|
203 | + 10 => trailingslashit(get_template_directory()).$template_dir, |
|
204 | 204 | 100 => give_get_templates_dir() |
205 | 205 | ); |
206 | 206 | |
207 | - $file_paths = apply_filters( 'give_template_paths', $file_paths ); |
|
207 | + $file_paths = apply_filters('give_template_paths', $file_paths); |
|
208 | 208 | |
209 | 209 | // sort the file paths based on priority |
210 | - ksort( $file_paths, SORT_NUMERIC ); |
|
210 | + ksort($file_paths, SORT_NUMERIC); |
|
211 | 211 | |
212 | - return array_map( 'trailingslashit', $file_paths ); |
|
212 | + return array_map('trailingslashit', $file_paths); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * @return string |
222 | 222 | */ |
223 | 223 | function give_get_theme_template_dir_name() { |
224 | - return trailingslashit( apply_filters( 'give_templates_dir', 'give' ) ); |
|
224 | + return trailingslashit(apply_filters('give_templates_dir', 'give')); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | /** |
@@ -231,10 +231,10 @@ discard block |
||
231 | 231 | * @return void |
232 | 232 | */ |
233 | 233 | function give_version_in_header() { |
234 | - echo '<meta name="generator" content="Give v' . GIVE_VERSION . '" />' . "\n"; |
|
234 | + echo '<meta name="generator" content="Give v'.GIVE_VERSION.'" />'."\n"; |
|
235 | 235 | } |
236 | 236 | |
237 | -add_action( 'wp_head', 'give_version_in_header' ); |
|
237 | +add_action('wp_head', 'give_version_in_header'); |
|
238 | 238 | |
239 | 239 | /** |
240 | 240 | * Determines if we're currently on the Donations History page. |
@@ -244,9 +244,9 @@ discard block |
||
244 | 244 | */ |
245 | 245 | function give_is_donation_history_page() { |
246 | 246 | |
247 | - $ret = is_page( give_get_option( 'history_page' ) ); |
|
247 | + $ret = is_page(give_get_option('history_page')); |
|
248 | 248 | |
249 | - return apply_filters( 'give_is_donation_history_page', $ret ); |
|
249 | + return apply_filters('give_is_donation_history_page', $ret); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
@@ -258,25 +258,25 @@ discard block |
||
258 | 258 | * |
259 | 259 | * @return array Modified array of classes |
260 | 260 | */ |
261 | -function give_add_body_classes( $class ) { |
|
261 | +function give_add_body_classes($class) { |
|
262 | 262 | $classes = (array) $class; |
263 | 263 | |
264 | - if ( give_is_success_page() ) { |
|
264 | + if (give_is_success_page()) { |
|
265 | 265 | $classes[] = 'give-success'; |
266 | 266 | $classes[] = 'give-page'; |
267 | 267 | } |
268 | 268 | |
269 | - if ( give_is_failed_transaction_page() ) { |
|
269 | + if (give_is_failed_transaction_page()) { |
|
270 | 270 | $classes[] = 'give-failed-transaction'; |
271 | 271 | $classes[] = 'give-page'; |
272 | 272 | } |
273 | 273 | |
274 | - if ( give_is_donation_history_page() ) { |
|
274 | + if (give_is_donation_history_page()) { |
|
275 | 275 | $classes[] = 'give-donation-history'; |
276 | 276 | $classes[] = 'give-page'; |
277 | 277 | } |
278 | 278 | |
279 | - if ( give_is_test_mode() ) { |
|
279 | + if (give_is_test_mode()) { |
|
280 | 280 | $classes[] = 'give-test-mode'; |
281 | 281 | $classes[] = 'give-page'; |
282 | 282 | } |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | //Theme-specific Classes used to prevent conflicts via CSS |
285 | 285 | $current_theme = wp_get_theme(); |
286 | 286 | |
287 | - switch ( $current_theme->template ) { |
|
287 | + switch ($current_theme->template) { |
|
288 | 288 | |
289 | 289 | case 'Divi': |
290 | 290 | $classes[] = 'give-divi'; |
@@ -298,10 +298,10 @@ discard block |
||
298 | 298 | |
299 | 299 | } |
300 | 300 | |
301 | - return array_unique( $classes ); |
|
301 | + return array_unique($classes); |
|
302 | 302 | } |
303 | 303 | |
304 | -add_filter( 'body_class', 'give_add_body_classes' ); |
|
304 | +add_filter('body_class', 'give_add_body_classes'); |
|
305 | 305 | |
306 | 306 | |
307 | 307 | /** |
@@ -317,22 +317,22 @@ discard block |
||
317 | 317 | * |
318 | 318 | * @return array |
319 | 319 | */ |
320 | -function give_add_post_class( $classes, $class = '', $post_id = '' ) { |
|
321 | - if ( ! $post_id || 'give_forms' !== get_post_type( $post_id ) ) { |
|
320 | +function give_add_post_class($classes, $class = '', $post_id = '') { |
|
321 | + if ( ! $post_id || 'give_forms' !== get_post_type($post_id)) { |
|
322 | 322 | return $classes; |
323 | 323 | } |
324 | 324 | |
325 | 325 | //@TODO: Add classes for custom taxonomy and form configurations (multi vs single donations, etc). |
326 | 326 | |
327 | - if ( false !== ( $key = array_search( 'hentry', $classes ) ) ) { |
|
328 | - unset( $classes[ $key ] ); |
|
327 | + if (false !== ($key = array_search('hentry', $classes))) { |
|
328 | + unset($classes[$key]); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | return $classes; |
332 | 332 | } |
333 | 333 | |
334 | 334 | |
335 | -add_filter( 'post_class', 'give_add_post_class', 20, 3 ); |
|
335 | +add_filter('post_class', 'give_add_post_class', 20, 3); |
|
336 | 336 | |
337 | 337 | /** |
338 | 338 | * Get the placeholder image URL for forms etc |
@@ -342,74 +342,74 @@ discard block |
||
342 | 342 | */ |
343 | 343 | function give_get_placeholder_img_src() { |
344 | 344 | |
345 | - $placeholder_url = '//placehold.it/600x600&text=' . urlencode( esc_attr__( 'Give Placeholder Image', 'give' ) ); |
|
345 | + $placeholder_url = '//placehold.it/600x600&text='.urlencode(esc_attr__('Give Placeholder Image', 'give')); |
|
346 | 346 | |
347 | - return apply_filters( 'give_placeholder_img_src', $placeholder_url ); |
|
347 | + return apply_filters('give_placeholder_img_src', $placeholder_url); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | |
351 | 351 | /** |
352 | 352 | * Global |
353 | 353 | */ |
354 | -if ( ! function_exists( 'give_output_content_wrapper' ) ) { |
|
354 | +if ( ! function_exists('give_output_content_wrapper')) { |
|
355 | 355 | |
356 | 356 | /** |
357 | 357 | * Output the start of the page wrapper. |
358 | 358 | */ |
359 | 359 | function give_output_content_wrapper() { |
360 | - give_get_template_part( 'global/wrapper-start' ); |
|
360 | + give_get_template_part('global/wrapper-start'); |
|
361 | 361 | } |
362 | 362 | } |
363 | -if ( ! function_exists( 'give_output_content_wrapper_end' ) ) { |
|
363 | +if ( ! function_exists('give_output_content_wrapper_end')) { |
|
364 | 364 | |
365 | 365 | /** |
366 | 366 | * Output the end of the page wrapper. |
367 | 367 | */ |
368 | 368 | function give_output_content_wrapper_end() { |
369 | - give_get_template_part( 'global/wrapper-end' ); |
|
369 | + give_get_template_part('global/wrapper-end'); |
|
370 | 370 | } |
371 | 371 | } |
372 | 372 | |
373 | 373 | /** |
374 | 374 | * Single Give Form |
375 | 375 | */ |
376 | -if ( ! function_exists( 'give_left_sidebar_pre_wrap' ) ) { |
|
376 | +if ( ! function_exists('give_left_sidebar_pre_wrap')) { |
|
377 | 377 | function give_left_sidebar_pre_wrap() { |
378 | - echo apply_filters( 'give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">' ); |
|
378 | + echo apply_filters('give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">'); |
|
379 | 379 | } |
380 | 380 | } |
381 | 381 | |
382 | -if ( ! function_exists( 'give_left_sidebar_post_wrap' ) ) { |
|
382 | +if ( ! function_exists('give_left_sidebar_post_wrap')) { |
|
383 | 383 | function give_left_sidebar_post_wrap() { |
384 | - echo apply_filters( 'give_left_sidebar_post_wrap', '</div>' ); |
|
384 | + echo apply_filters('give_left_sidebar_post_wrap', '</div>'); |
|
385 | 385 | } |
386 | 386 | } |
387 | 387 | |
388 | -if ( ! function_exists( 'give_get_forms_sidebar' ) ) { |
|
388 | +if ( ! function_exists('give_get_forms_sidebar')) { |
|
389 | 389 | function give_get_forms_sidebar() { |
390 | - give_get_template_part( 'single-give-form/sidebar' ); |
|
390 | + give_get_template_part('single-give-form/sidebar'); |
|
391 | 391 | } |
392 | 392 | } |
393 | 393 | |
394 | -if ( ! function_exists( 'give_show_form_images' ) ) { |
|
394 | +if ( ! function_exists('give_show_form_images')) { |
|
395 | 395 | |
396 | 396 | /** |
397 | 397 | * Output the donation form featured image. |
398 | 398 | */ |
399 | 399 | function give_show_form_images() { |
400 | - if ( give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) { |
|
401 | - give_get_template_part( 'single-give-form/featured-image' ); |
|
400 | + if (give_is_setting_enabled(give_get_option('form_featured_img'))) { |
|
401 | + give_get_template_part('single-give-form/featured-image'); |
|
402 | 402 | } |
403 | 403 | } |
404 | 404 | } |
405 | 405 | |
406 | -if ( ! function_exists( 'give_template_single_title' ) ) { |
|
406 | +if ( ! function_exists('give_template_single_title')) { |
|
407 | 407 | |
408 | 408 | /** |
409 | 409 | * Output the form title. |
410 | 410 | */ |
411 | 411 | function give_template_single_title() { |
412 | - give_get_template_part( 'single-give-form/title' ); |
|
412 | + give_get_template_part('single-give-form/title'); |
|
413 | 413 | } |
414 | 414 | } |
415 | 415 | |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | * Conditional Functions |
418 | 418 | */ |
419 | 419 | |
420 | -if ( ! function_exists( 'is_give_form' ) ) { |
|
420 | +if ( ! function_exists('is_give_form')) { |
|
421 | 421 | |
422 | 422 | /** |
423 | 423 | * is_give_form |
@@ -429,11 +429,11 @@ discard block |
||
429 | 429 | * @return bool |
430 | 430 | */ |
431 | 431 | function is_give_form() { |
432 | - return is_singular( array( 'give_form' ) ); |
|
432 | + return is_singular(array('give_form')); |
|
433 | 433 | } |
434 | 434 | } |
435 | 435 | |
436 | -if ( ! function_exists( 'is_give_category' ) ) { |
|
436 | +if ( ! function_exists('is_give_category')) { |
|
437 | 437 | |
438 | 438 | /** |
439 | 439 | * is_give_category |
@@ -448,12 +448,12 @@ discard block |
||
448 | 448 | * |
449 | 449 | * @return bool |
450 | 450 | */ |
451 | - function is_give_category( $term = '' ) { |
|
452 | - return is_tax( 'give_forms_category', $term ); |
|
451 | + function is_give_category($term = '') { |
|
452 | + return is_tax('give_forms_category', $term); |
|
453 | 453 | } |
454 | 454 | } |
455 | 455 | |
456 | -if ( ! function_exists( 'is_give_tag' ) ) { |
|
456 | +if ( ! function_exists('is_give_tag')) { |
|
457 | 457 | |
458 | 458 | /** |
459 | 459 | * is_give_tag |
@@ -468,12 +468,12 @@ discard block |
||
468 | 468 | * |
469 | 469 | * @return bool |
470 | 470 | */ |
471 | - function is_give_tag( $term = '' ) { |
|
472 | - return is_tax( 'give_forms_tag', $term ); |
|
471 | + function is_give_tag($term = '') { |
|
472 | + return is_tax('give_forms_tag', $term); |
|
473 | 473 | } |
474 | 474 | } |
475 | 475 | |
476 | -if ( ! function_exists( 'is_give_taxonomy' ) ) { |
|
476 | +if ( ! function_exists('is_give_taxonomy')) { |
|
477 | 477 | |
478 | 478 | /** |
479 | 479 | * is_give_taxonomy |
@@ -485,6 +485,6 @@ discard block |
||
485 | 485 | * @return bool |
486 | 486 | */ |
487 | 487 | function is_give_taxonomy() { |
488 | - return is_tax( get_object_taxonomies( 'give_form' ) ); |
|
488 | + return is_tax(get_object_taxonomies('give_form')); |
|
489 | 489 | } |
490 | 490 | } |
@@ -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 | |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @return string $message Fully formatted message |
43 | 43 | */ |
44 | -function give_email_template_tags( $message, $payment_data, $payment_id, $admin_notice = false ) { |
|
45 | - return give_do_email_tags( $message, $payment_id ); |
|
44 | +function give_email_template_tags($message, $payment_data, $payment_id, $admin_notice = false) { |
|
45 | + return give_do_email_tags($message, $payment_id); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -56,42 +56,42 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @return string $message Fully formatted message |
58 | 58 | */ |
59 | -function give_email_preview_template_tags( $message ) { |
|
59 | +function give_email_preview_template_tags($message) { |
|
60 | 60 | |
61 | - $price = give_currency_filter( give_format_amount( 10.50 ) ); |
|
61 | + $price = give_currency_filter(give_format_amount(10.50)); |
|
62 | 62 | |
63 | 63 | $gateway = 'PayPal'; |
64 | 64 | |
65 | - $receipt_id = strtolower( md5( uniqid() ) ); |
|
65 | + $receipt_id = strtolower(md5(uniqid())); |
|
66 | 66 | |
67 | - $payment_id = rand( 1, 100 ); |
|
67 | + $payment_id = rand(1, 100); |
|
68 | 68 | |
69 | - $receipt_link_url = esc_url( add_query_arg( array( 'payment_key' => $receipt_id, 'give_action' => 'view_receipt' ), home_url() ) ); |
|
69 | + $receipt_link_url = esc_url(add_query_arg(array('payment_key' => $receipt_id, 'give_action' => 'view_receipt'), home_url())); |
|
70 | 70 | $receipt_link = sprintf( |
71 | 71 | '<a href="%1$s">%2$s</a>', |
72 | 72 | $receipt_link_url, |
73 | - esc_html__( 'View the receipt in your browser »', 'give' ) |
|
73 | + esc_html__('View the receipt in your browser »', 'give') |
|
74 | 74 | ); |
75 | 75 | |
76 | 76 | $user = wp_get_current_user(); |
77 | 77 | |
78 | - $message = str_replace( '{name}', $user->display_name, $message ); |
|
79 | - $message = str_replace( '{fullname}', $user->display_name, $message ); |
|
80 | - $message = str_replace( '{username}', $user->user_login, $message ); |
|
81 | - $message = str_replace( '{date}', date( give_date_format(), current_time( 'timestamp' ) ), $message ); |
|
82 | - $message = str_replace( '{amount}', $price, $message ); |
|
83 | - $message = str_replace( '{price}', $price, $message ); |
|
84 | - $message = str_replace( '{donation}', esc_html__( 'Sample Donation Form Title', 'give' ), $message ); |
|
85 | - $message = str_replace( '{form_title}', esc_html__( 'Sample Donation Form Title - Sample Donation Level', 'give' ), $message ); |
|
86 | - $message = str_replace( '{receipt_id}', $receipt_id, $message ); |
|
87 | - $message = str_replace( '{payment_method}', $gateway, $message ); |
|
88 | - $message = str_replace( '{sitename}', get_bloginfo( 'name' ), $message ); |
|
89 | - $message = str_replace( '{payment_id}', $payment_id, $message ); |
|
90 | - $message = str_replace( '{receipt_link}', $receipt_link, $message ); |
|
91 | - $message = str_replace( '{receipt_link_url}', $receipt_link_url, $message ); |
|
92 | - $message = str_replace( '{pdf_receipt}', '<a href="#">Download Receipt</a>', $message ); |
|
93 | - |
|
94 | - return wpautop( apply_filters( 'give_email_preview_template_tags', $message ) ); |
|
78 | + $message = str_replace('{name}', $user->display_name, $message); |
|
79 | + $message = str_replace('{fullname}', $user->display_name, $message); |
|
80 | + $message = str_replace('{username}', $user->user_login, $message); |
|
81 | + $message = str_replace('{date}', date(give_date_format(), current_time('timestamp')), $message); |
|
82 | + $message = str_replace('{amount}', $price, $message); |
|
83 | + $message = str_replace('{price}', $price, $message); |
|
84 | + $message = str_replace('{donation}', esc_html__('Sample Donation Form Title', 'give'), $message); |
|
85 | + $message = str_replace('{form_title}', esc_html__('Sample Donation Form Title - Sample Donation Level', 'give'), $message); |
|
86 | + $message = str_replace('{receipt_id}', $receipt_id, $message); |
|
87 | + $message = str_replace('{payment_method}', $gateway, $message); |
|
88 | + $message = str_replace('{sitename}', get_bloginfo('name'), $message); |
|
89 | + $message = str_replace('{payment_id}', $payment_id, $message); |
|
90 | + $message = str_replace('{receipt_link}', $receipt_link, $message); |
|
91 | + $message = str_replace('{receipt_link_url}', $receipt_link_url, $message); |
|
92 | + $message = str_replace('{pdf_receipt}', '<a href="#">Download Receipt</a>', $message); |
|
93 | + |
|
94 | + return wpautop(apply_filters('give_email_preview_template_tags', $message)); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -103,23 +103,23 @@ discard block |
||
103 | 103 | * @since 1.0 |
104 | 104 | * @return array|bool |
105 | 105 | */ |
106 | -function give_email_template_preview( $array ) { |
|
106 | +function give_email_template_preview($array) { |
|
107 | 107 | |
108 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
108 | + if ( ! current_user_can('manage_give_settings')) { |
|
109 | 109 | return false; |
110 | 110 | } |
111 | 111 | $custom_field = array( |
112 | - 'name' => esc_html__( 'Preview Email', 'give' ), |
|
113 | - 'desc' => esc_html__( 'Click the buttons to preview or send test emails.', 'give' ), |
|
112 | + 'name' => esc_html__('Preview Email', 'give'), |
|
113 | + 'desc' => esc_html__('Click the buttons to preview or send test emails.', 'give'), |
|
114 | 114 | 'id' => 'give_email_preview_buttons', |
115 | 115 | 'type' => 'email_preview_buttons' |
116 | 116 | ); |
117 | 117 | |
118 | - return give_settings_array_insert( $array, 'donation_subject', array( $custom_field ) ); |
|
118 | + return give_settings_array_insert($array, 'donation_subject', array($custom_field)); |
|
119 | 119 | |
120 | 120 | } |
121 | 121 | |
122 | -add_filter( 'give_settings_emails', 'give_email_template_preview' ); |
|
122 | +add_filter('give_settings_emails', 'give_email_template_preview'); |
|
123 | 123 | |
124 | 124 | /** |
125 | 125 | * Output Email Template Preview Buttons. |
@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | function give_email_preview_buttons_callback() { |
132 | 132 | ob_start(); |
133 | 133 | ?> |
134 | - <a href="<?php echo esc_url( add_query_arg( array( 'give_action' => 'preview_email' ), home_url() ) ); ?>" class="button-secondary" target="_blank"><?php esc_html_e( 'Preview Donation Receipt', 'give' ); ?></a> |
|
135 | - <a href="<?php echo wp_nonce_url( add_query_arg( array( |
|
134 | + <a href="<?php echo esc_url(add_query_arg(array('give_action' => 'preview_email'), home_url())); ?>" class="button-secondary" target="_blank"><?php esc_html_e('Preview Donation Receipt', 'give'); ?></a> |
|
135 | + <a href="<?php echo wp_nonce_url(add_query_arg(array( |
|
136 | 136 | 'give_action' => 'send_test_email', |
137 | 137 | 'give-message' => 'sent-test-email', |
138 | 138 | 'tag' => 'emails' |
139 | - ) ), 'give-test-email' ); ?>" aria-label="<?php esc_attr_e( 'Send demo donation receipt to the emails listed below.', 'give' ); ?>" class="button-secondary"><?php esc_html_e( 'Send Test Email', 'give' ); ?></a> |
|
139 | + )), 'give-test-email'); ?>" aria-label="<?php esc_attr_e('Send demo donation receipt to the emails listed below.', 'give'); ?>" class="button-secondary"><?php esc_html_e('Send Test Email', 'give'); ?></a> |
|
140 | 140 | <?php |
141 | 141 | echo ob_get_clean(); |
142 | 142 | } |
@@ -149,46 +149,46 @@ discard block |
||
149 | 149 | */ |
150 | 150 | function give_display_email_template_preview() { |
151 | 151 | |
152 | - if ( empty( $_GET['give_action'] ) ) { |
|
152 | + if (empty($_GET['give_action'])) { |
|
153 | 153 | return; |
154 | 154 | } |
155 | 155 | |
156 | - if ( 'preview_email' !== $_GET['give_action'] ) { |
|
156 | + if ('preview_email' !== $_GET['give_action']) { |
|
157 | 157 | return; |
158 | 158 | } |
159 | 159 | |
160 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
160 | + if ( ! current_user_can('manage_give_settings')) { |
|
161 | 161 | return; |
162 | 162 | } |
163 | 163 | |
164 | 164 | |
165 | - Give()->emails->heading = esc_html__( 'Donation Receipt', 'give' ); |
|
165 | + Give()->emails->heading = esc_html__('Donation Receipt', 'give'); |
|
166 | 166 | |
167 | - $payment_id = (int) isset( $_GET['preview_id'] ) ? $_GET['preview_id'] : ''; |
|
167 | + $payment_id = (int) isset($_GET['preview_id']) ? $_GET['preview_id'] : ''; |
|
168 | 168 | |
169 | 169 | echo give_get_preview_email_header(); |
170 | 170 | |
171 | 171 | //Are we previewing an actual payment? |
172 | - if ( ! empty( $payment_id ) ) { |
|
172 | + if ( ! empty($payment_id)) { |
|
173 | 173 | |
174 | - $content = give_get_email_body_content( $payment_id ); |
|
174 | + $content = give_get_email_body_content($payment_id); |
|
175 | 175 | |
176 | - $preview_content = give_do_email_tags( $content, $payment_id ); |
|
176 | + $preview_content = give_do_email_tags($content, $payment_id); |
|
177 | 177 | |
178 | 178 | } else { |
179 | 179 | |
180 | 180 | //No payment ID, use sample preview content |
181 | - $preview_content = give_email_preview_template_tags( give_get_email_body_content( 0, array() ) ); |
|
181 | + $preview_content = give_email_preview_template_tags(give_get_email_body_content(0, array())); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | |
185 | - echo Give()->emails->build_email( $preview_content ); |
|
185 | + echo Give()->emails->build_email($preview_content); |
|
186 | 186 | |
187 | 187 | exit; |
188 | 188 | |
189 | 189 | } |
190 | 190 | |
191 | -add_action( 'init', 'give_display_email_template_preview' ); |
|
191 | +add_action('init', 'give_display_email_template_preview'); |
|
192 | 192 | |
193 | 193 | /** |
194 | 194 | * Email Template Body. |
@@ -200,18 +200,18 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @return string $email_body Body of the email |
202 | 202 | */ |
203 | -function give_get_email_body_content( $payment_id = 0, $payment_data = array() ) { |
|
203 | +function give_get_email_body_content($payment_id = 0, $payment_data = array()) { |
|
204 | 204 | |
205 | 205 | $default_email_body = give_get_default_donation_receipt_email(); |
206 | 206 | |
207 | - $email_content = give_get_option( 'donation_receipt' ); |
|
208 | - $email_content = ( $email_content ) ? stripslashes( $email_content ) : $default_email_body; |
|
207 | + $email_content = give_get_option('donation_receipt'); |
|
208 | + $email_content = ($email_content) ? stripslashes($email_content) : $default_email_body; |
|
209 | 209 | |
210 | - $email_body = wpautop( $email_content ); |
|
210 | + $email_body = wpautop($email_content); |
|
211 | 211 | |
212 | - $email_body = apply_filters( 'give_donation_receipt_' . Give()->emails->get_template(), $email_body, $payment_id, $payment_data ); |
|
212 | + $email_body = apply_filters('give_donation_receipt_'.Give()->emails->get_template(), $email_body, $payment_id, $payment_data); |
|
213 | 213 | |
214 | - return apply_filters( 'give_donation_receipt', $email_body, $payment_id, $payment_data ); |
|
214 | + return apply_filters('give_donation_receipt', $email_body, $payment_id, $payment_data); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
@@ -224,36 +224,36 @@ discard block |
||
224 | 224 | * |
225 | 225 | * @return string $email_body Body of the email |
226 | 226 | */ |
227 | -function give_get_donation_notification_body_content( $payment_id = 0, $payment_data = array() ) { |
|
227 | +function give_get_donation_notification_body_content($payment_id = 0, $payment_data = array()) { |
|
228 | 228 | |
229 | - $user_info = maybe_unserialize( $payment_data['user_info'] ); |
|
230 | - $email = give_get_payment_user_email( $payment_id ); |
|
229 | + $user_info = maybe_unserialize($payment_data['user_info']); |
|
230 | + $email = give_get_payment_user_email($payment_id); |
|
231 | 231 | |
232 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) { |
|
233 | - $user_data = get_userdata( $user_info['id'] ); |
|
232 | + if (isset($user_info['id']) && $user_info['id'] > 0) { |
|
233 | + $user_data = get_userdata($user_info['id']); |
|
234 | 234 | $name = $user_data->display_name; |
235 | - } elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) { |
|
236 | - $name = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
235 | + } elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) { |
|
236 | + $name = $user_info['first_name'].' '.$user_info['last_name']; |
|
237 | 237 | } else { |
238 | 238 | $name = $email; |
239 | 239 | } |
240 | 240 | |
241 | - $gateway = give_get_gateway_admin_label( give_get_meta( $payment_id, '_give_payment_gateway', true ) ); |
|
241 | + $gateway = give_get_gateway_admin_label(give_get_meta($payment_id, '_give_payment_gateway', true)); |
|
242 | 242 | |
243 | - $default_email_body = esc_html__( 'Hello', 'give' ) . "\n\n"; |
|
244 | - $default_email_body .= esc_html__( 'A donation has been made.', 'give' ) . "\n\n"; |
|
245 | - $default_email_body .= esc_html__( 'Donation:', 'give' ) . "\n\n"; |
|
246 | - $default_email_body .= esc_html__( 'Donor:', 'give' ) . ' ' . html_entity_decode( $name, ENT_COMPAT, 'UTF-8' ) . "\n"; |
|
247 | - $default_email_body .= esc_html__( 'Amount:', 'give' ) . ' ' . html_entity_decode( give_currency_filter( give_format_amount( give_get_payment_amount( $payment_id ) ) ), ENT_COMPAT, 'UTF-8' ) . "\n"; |
|
248 | - $default_email_body .= esc_html__( 'Payment Method:', 'give' ) . ' ' . $gateway . "\n\n"; |
|
249 | - $default_email_body .= esc_html__( 'Thank you', 'give' ); |
|
243 | + $default_email_body = esc_html__('Hello', 'give')."\n\n"; |
|
244 | + $default_email_body .= esc_html__('A donation has been made.', 'give')."\n\n"; |
|
245 | + $default_email_body .= esc_html__('Donation:', 'give')."\n\n"; |
|
246 | + $default_email_body .= esc_html__('Donor:', 'give').' '.html_entity_decode($name, ENT_COMPAT, 'UTF-8')."\n"; |
|
247 | + $default_email_body .= esc_html__('Amount:', 'give').' '.html_entity_decode(give_currency_filter(give_format_amount(give_get_payment_amount($payment_id))), ENT_COMPAT, 'UTF-8')."\n"; |
|
248 | + $default_email_body .= esc_html__('Payment Method:', 'give').' '.$gateway."\n\n"; |
|
249 | + $default_email_body .= esc_html__('Thank you', 'give'); |
|
250 | 250 | |
251 | - $email = give_get_option( 'donation_notification' ); |
|
252 | - $email = isset( $email ) ? stripslashes( $email ) : $default_email_body; |
|
251 | + $email = give_get_option('donation_notification'); |
|
252 | + $email = isset($email) ? stripslashes($email) : $default_email_body; |
|
253 | 253 | |
254 | - $email_body = give_do_email_tags( $email, $payment_id ); |
|
254 | + $email_body = give_do_email_tags($email, $payment_id); |
|
255 | 255 | |
256 | - return apply_filters( 'give_donation_notification', wpautop( $email_body ), $payment_id, $payment_data ); |
|
256 | + return apply_filters('give_donation_notification', wpautop($email_body), $payment_id, $payment_data); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -266,19 +266,19 @@ discard block |
||
266 | 266 | * @since 1.0 |
267 | 267 | */ |
268 | 268 | function give_render_receipt_in_browser() { |
269 | - if ( ! isset( $_GET['payment_key'] ) ) { |
|
270 | - wp_die( esc_html__( 'Missing donation payment key.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
269 | + if ( ! isset($_GET['payment_key'])) { |
|
270 | + wp_die(esc_html__('Missing donation payment key.', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
271 | 271 | } |
272 | 272 | |
273 | - $key = urlencode( $_GET['payment_key'] ); |
|
273 | + $key = urlencode($_GET['payment_key']); |
|
274 | 274 | |
275 | 275 | ob_start(); |
276 | 276 | //Disallows caching of the page |
277 | - header( "Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . " GMT" ); |
|
278 | - header( "Cache-Control: no-store, no-cache, must-revalidate" ); // HTTP/1.1 |
|
279 | - header( "Cache-Control: post-check=0, pre-check=0", false ); |
|
280 | - header( "Pragma: no-cache" ); // HTTP/1.0 |
|
281 | - header( "Expires: Sat, 23 Oct 1977 05:00:00 PST" ); // Date in the past |
|
277 | + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); |
|
278 | + header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1 |
|
279 | + header("Cache-Control: post-check=0, pre-check=0", false); |
|
280 | + header("Pragma: no-cache"); // HTTP/1.0 |
|
281 | + header("Expires: Sat, 23 Oct 1977 05:00:00 PST"); // Date in the past |
|
282 | 282 | ?> |
283 | 283 | <!DOCTYPE html> |
284 | 284 | <html lang="en"> |
@@ -289,10 +289,10 @@ discard block |
||
289 | 289 | * |
290 | 290 | * @since 1.0 |
291 | 291 | */ |
292 | - do_action( 'give_receipt_head' ); |
|
292 | + do_action('give_receipt_head'); |
|
293 | 293 | ?> |
294 | 294 | </head> |
295 | - <body class="<?php echo apply_filters( 'give_receipt_page_body_class', 'give_receipt_page' ); ?>"> |
|
295 | + <body class="<?php echo apply_filters('give_receipt_page_body_class', 'give_receipt_page'); ?>"> |
|
296 | 296 | |
297 | 297 | <div id="give_receipt_wrapper"> |
298 | 298 | <?php |
@@ -301,16 +301,16 @@ discard block |
||
301 | 301 | * |
302 | 302 | * @since 1.0 |
303 | 303 | */ |
304 | - do_action( 'give_render_receipt_in_browser_before' ); |
|
304 | + do_action('give_render_receipt_in_browser_before'); |
|
305 | 305 | |
306 | - echo do_shortcode( '[give_receipt payment_key=' . $key . ']' ); |
|
306 | + echo do_shortcode('[give_receipt payment_key='.$key.']'); |
|
307 | 307 | |
308 | 308 | /** |
309 | 309 | * Fires in the receipt template after the content. |
310 | 310 | * |
311 | 311 | * @since 1.0 |
312 | 312 | */ |
313 | - do_action( 'give_render_receipt_in_browser_after' ); |
|
313 | + do_action('give_render_receipt_in_browser_after'); |
|
314 | 314 | ?> |
315 | 315 | </div> |
316 | 316 | |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | * |
321 | 321 | * @since 1.0 |
322 | 322 | */ |
323 | - do_action( 'give_receipt_footer' ); |
|
323 | + do_action('give_receipt_footer'); |
|
324 | 324 | ?> |
325 | 325 | </body> |
326 | 326 | </html> |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | die(); |
330 | 330 | } |
331 | 331 | |
332 | -add_action( 'give_view_receipt', 'give_render_receipt_in_browser' ); |
|
332 | +add_action('give_view_receipt', 'give_render_receipt_in_browser'); |
|
333 | 333 | |
334 | 334 | |
335 | 335 | /** |
@@ -344,29 +344,29 @@ discard block |
||
344 | 344 | |
345 | 345 | //Payment receipt switcher |
346 | 346 | $payment_count = give_count_payments()->publish; |
347 | - $payment_id = (int) isset( $_GET['preview_id'] ) ? $_GET['preview_id'] : ''; |
|
347 | + $payment_id = (int) isset($_GET['preview_id']) ? $_GET['preview_id'] : ''; |
|
348 | 348 | |
349 | - if ( $payment_count <= 0 ) { |
|
349 | + if ($payment_count <= 0) { |
|
350 | 350 | return false; |
351 | 351 | } |
352 | 352 | |
353 | 353 | //Get payments. |
354 | - $payments = new Give_Payments_Query( array( |
|
354 | + $payments = new Give_Payments_Query(array( |
|
355 | 355 | 'number' => 100 |
356 | - ) ); |
|
356 | + )); |
|
357 | 357 | $payments = $payments->get_payments(); |
358 | 358 | $options = array(); |
359 | 359 | |
360 | 360 | //Provide nice human readable options. |
361 | - if ( $payments ) { |
|
362 | - $options[0] = esc_html__( '- Select a donation -', 'give' ); |
|
363 | - foreach ( $payments as $payment ) { |
|
361 | + if ($payments) { |
|
362 | + $options[0] = esc_html__('- Select a donation -', 'give'); |
|
363 | + foreach ($payments as $payment) { |
|
364 | 364 | |
365 | - $options[ $payment->ID ] = esc_html( '#' . $payment->ID . ' - ' . $payment->email . ' - ' . $payment->form_title ); |
|
365 | + $options[$payment->ID] = esc_html('#'.$payment->ID.' - '.$payment->email.' - '.$payment->form_title); |
|
366 | 366 | |
367 | 367 | } |
368 | 368 | } else { |
369 | - $options[0] = esc_html__( 'No donations found.', 'give' ); |
|
369 | + $options[0] = esc_html__('No donations found.', 'give'); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | //Start constructing HTML output. |
@@ -379,16 +379,16 @@ discard block |
||
379 | 379 | var selected_trans = transactions.options[transactions.selectedIndex]; |
380 | 380 | console.log(selected_trans); |
381 | 381 | if (selected_trans){ |
382 | - var url_string = "' . get_bloginfo( 'url' ) . '?give_action=preview_email&preview_id=" + selected_trans.value; |
|
382 | + var url_string = "' . get_bloginfo('url').'?give_action=preview_email&preview_id=" + selected_trans.value; |
|
383 | 383 | window.location = url_string; |
384 | 384 | } |
385 | 385 | } |
386 | 386 | </script>'; |
387 | 387 | |
388 | - $transaction_header .= '<label for="give_preview_email_payment_id" style="font-size:12px;color:#333;margin:0 4px 0 0;">' . esc_html__( 'Preview email with a donation:', 'give' ) . '</label>'; |
|
388 | + $transaction_header .= '<label for="give_preview_email_payment_id" style="font-size:12px;color:#333;margin:0 4px 0 0;">'.esc_html__('Preview email with a donation:', 'give').'</label>'; |
|
389 | 389 | |
390 | 390 | //The select field with 100 latest transactions |
391 | - $transaction_header .= Give()->html->select( array( |
|
391 | + $transaction_header .= Give()->html->select(array( |
|
392 | 392 | 'name' => 'preview_email_payment_id', |
393 | 393 | 'selected' => $payment_id, |
394 | 394 | 'id' => 'give_preview_email_payment_id', |
@@ -398,12 +398,12 @@ discard block |
||
398 | 398 | 'select_atts' => 'onchange="change_preview()">', |
399 | 399 | 'show_option_all' => false, |
400 | 400 | 'show_option_none' => false |
401 | - ) ); |
|
401 | + )); |
|
402 | 402 | |
403 | 403 | //Closing tag |
404 | 404 | $transaction_header .= '</div>'; |
405 | 405 | |
406 | - return apply_filters( 'give_preview_email_receipt_header', $transaction_header ); |
|
406 | + return apply_filters('give_preview_email_receipt_header', $transaction_header); |
|
407 | 407 | |
408 | 408 | } |
409 | 409 | |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | function give_receipt_head_content() { |
418 | 418 | |
419 | 419 | //Title. |
420 | - $output = '<title>' . esc_html__( 'Donation Receipt', 'give' ) . '</title>'; |
|
420 | + $output = '<title>'.esc_html__('Donation Receipt', 'give').'</title>'; |
|
421 | 421 | |
422 | 422 | //Meta. |
423 | 423 | $output .= '<meta charset="utf-8"/> |
@@ -431,10 +431,10 @@ discard block |
||
431 | 431 | <meta name="robots" content="noindex, nofollow"/>'; |
432 | 432 | |
433 | 433 | //CSS |
434 | - $output .= '<link rel="stylesheet" href="' . give_get_stylesheet_uri() . '?ver=' . GIVE_VERSION . '">'; |
|
434 | + $output .= '<link rel="stylesheet" href="'.give_get_stylesheet_uri().'?ver='.GIVE_VERSION.'">'; |
|
435 | 435 | |
436 | - echo apply_filters( 'give_receipt_head_content', $output ); |
|
436 | + echo apply_filters('give_receipt_head_content', $output); |
|
437 | 437 | |
438 | 438 | } |
439 | 439 | |
440 | -add_action( 'give_receipt_head', 'give_receipt_head_content' ); |
|
441 | 440 | \ No newline at end of file |
441 | +add_action('give_receipt_head', 'give_receipt_head_content'); |
|
442 | 442 | \ No newline at end of file |
@@ -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 | |
@@ -28,21 +28,21 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return void |
30 | 30 | */ |
31 | -function give_complete_purchase( $payment_id, $new_status, $old_status ) { |
|
31 | +function give_complete_purchase($payment_id, $new_status, $old_status) { |
|
32 | 32 | |
33 | 33 | // Make sure that payments are only completed once. |
34 | - if ( $old_status == 'publish' || $old_status == 'complete' ) { |
|
34 | + if ($old_status == 'publish' || $old_status == 'complete') { |
|
35 | 35 | return; |
36 | 36 | } |
37 | 37 | |
38 | 38 | // Make sure the payment completion is only processed when new status is complete. |
39 | - if ( $new_status != 'publish' && $new_status != 'complete' ) { |
|
39 | + if ($new_status != 'publish' && $new_status != 'complete') { |
|
40 | 40 | return; |
41 | 41 | } |
42 | 42 | |
43 | - $payment = new Give_Payment( $payment_id ); |
|
43 | + $payment = new Give_Payment($payment_id); |
|
44 | 44 | |
45 | - $creation_date = get_post_field( 'post_date', $payment_id, 'raw' ); |
|
45 | + $creation_date = get_post_field('post_date', $payment_id, 'raw'); |
|
46 | 46 | $payment_meta = $payment->payment_meta; |
47 | 47 | $completed_date = $payment->completed_date; |
48 | 48 | $user_info = $payment->user_info; |
@@ -58,12 +58,12 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @param int $payment_id The ID of the payment. |
60 | 60 | */ |
61 | - do_action( 'give_pre_complete_donation', $payment_id ); |
|
61 | + do_action('give_pre_complete_donation', $payment_id); |
|
62 | 62 | |
63 | 63 | // Ensure these actions only run once, ever. |
64 | - if ( empty( $completed_date ) ) { |
|
64 | + if (empty($completed_date)) { |
|
65 | 65 | |
66 | - give_record_donation_in_log( $form_id, $payment_id, $price_id, $creation_date ); |
|
66 | + give_record_donation_in_log($form_id, $payment_id, $price_id, $creation_date); |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * Fires after logging donation record. |
@@ -74,29 +74,29 @@ discard block |
||
74 | 74 | * @param int $payment_id The ID number of the payment. |
75 | 75 | * @param array $payment_meta The payment meta. |
76 | 76 | */ |
77 | - do_action( 'give_complete_form_donation', $form_id, $payment_id, $payment_meta ); |
|
77 | + do_action('give_complete_form_donation', $form_id, $payment_id, $payment_meta); |
|
78 | 78 | |
79 | 79 | } |
80 | 80 | |
81 | 81 | // Increase the earnings for this form ID. |
82 | - give_increase_earnings( $form_id, $amount ); |
|
83 | - give_increase_donation_count( $form_id ); |
|
82 | + give_increase_earnings($form_id, $amount); |
|
83 | + give_increase_donation_count($form_id); |
|
84 | 84 | |
85 | 85 | // @todo: Refresh only range related stat cache |
86 | 86 | give_delete_donation_stats(); |
87 | 87 | |
88 | 88 | // Increase the donor's donation stats. |
89 | - $donor = new Give_Donor( $donor_id ); |
|
89 | + $donor = new Give_Donor($donor_id); |
|
90 | 90 | $donor->increase_purchase_count(); |
91 | - $donor->increase_value( $amount ); |
|
91 | + $donor->increase_value($amount); |
|
92 | 92 | |
93 | - give_increase_total_earnings( $amount ); |
|
93 | + give_increase_total_earnings($amount); |
|
94 | 94 | |
95 | 95 | // Ensure this action only runs once ever. |
96 | - if ( empty( $completed_date ) ) { |
|
96 | + if (empty($completed_date)) { |
|
97 | 97 | |
98 | 98 | // Save the completed date. |
99 | - $payment->completed_date = current_time( 'mysql' ); |
|
99 | + $payment->completed_date = current_time('mysql'); |
|
100 | 100 | $payment->save(); |
101 | 101 | |
102 | 102 | /** |
@@ -106,12 +106,12 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @param int $payment_id The ID of the payment. |
108 | 108 | */ |
109 | - do_action( 'give_complete_donation', $payment_id ); |
|
109 | + do_action('give_complete_donation', $payment_id); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | } |
113 | 113 | |
114 | -add_action( 'give_update_payment_status', 'give_complete_purchase', 100, 3 ); |
|
114 | +add_action('give_update_payment_status', 'give_complete_purchase', 100, 3); |
|
115 | 115 | |
116 | 116 | |
117 | 117 | /** |
@@ -125,20 +125,20 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @return void |
127 | 127 | */ |
128 | -function give_record_status_change( $payment_id, $new_status, $old_status ) { |
|
128 | +function give_record_status_change($payment_id, $new_status, $old_status) { |
|
129 | 129 | |
130 | 130 | // Get the list of statuses so that status in the payment note can be translated. |
131 | 131 | $stati = give_get_payment_statuses(); |
132 | - $old_status = isset( $stati[ $old_status ] ) ? $stati[ $old_status ] : $old_status; |
|
133 | - $new_status = isset( $stati[ $new_status ] ) ? $stati[ $new_status ] : $new_status; |
|
132 | + $old_status = isset($stati[$old_status]) ? $stati[$old_status] : $old_status; |
|
133 | + $new_status = isset($stati[$new_status]) ? $stati[$new_status] : $new_status; |
|
134 | 134 | |
135 | 135 | // translators: 1: old status 2: new status. |
136 | - $status_change = sprintf( esc_html__( 'Status changed from %1$s to %2$s.', 'give' ), $old_status, $new_status ); |
|
136 | + $status_change = sprintf(esc_html__('Status changed from %1$s to %2$s.', 'give'), $old_status, $new_status); |
|
137 | 137 | |
138 | - give_insert_payment_note( $payment_id, $status_change ); |
|
138 | + give_insert_payment_note($payment_id, $status_change); |
|
139 | 139 | } |
140 | 140 | |
141 | -add_action( 'give_update_payment_status', 'give_record_status_change', 100, 3 ); |
|
141 | +add_action('give_update_payment_status', 'give_record_status_change', 100, 3); |
|
142 | 142 | |
143 | 143 | |
144 | 144 | /** |
@@ -154,25 +154,25 @@ discard block |
||
154 | 154 | * |
155 | 155 | * @return void |
156 | 156 | */ |
157 | -function give_update_old_payments_with_totals( $data ) { |
|
158 | - if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_upgrade_payments_nonce' ) ) { |
|
157 | +function give_update_old_payments_with_totals($data) { |
|
158 | + if ( ! wp_verify_nonce($data['_wpnonce'], 'give_upgrade_payments_nonce')) { |
|
159 | 159 | return; |
160 | 160 | } |
161 | 161 | |
162 | - if ( get_option( 'give_payment_totals_upgraded' ) ) { |
|
162 | + if (get_option('give_payment_totals_upgraded')) { |
|
163 | 163 | return; |
164 | 164 | } |
165 | 165 | |
166 | - $payments = give_get_payments( array( |
|
166 | + $payments = give_get_payments(array( |
|
167 | 167 | 'offset' => 0, |
168 | - 'number' => - 1, |
|
168 | + 'number' => -1, |
|
169 | 169 | 'mode' => 'all', |
170 | - ) ); |
|
170 | + )); |
|
171 | 171 | |
172 | - if ( $payments ) { |
|
173 | - foreach ( $payments as $payment ) { |
|
172 | + if ($payments) { |
|
173 | + foreach ($payments as $payment) { |
|
174 | 174 | |
175 | - $payment = new Give_Payment( $payment->ID ); |
|
175 | + $payment = new Give_Payment($payment->ID); |
|
176 | 176 | $meta = $payment->get_meta(); |
177 | 177 | |
178 | 178 | $payment->total = $meta['amount']; |
@@ -181,10 +181,10 @@ discard block |
||
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
184 | - add_option( 'give_payment_totals_upgraded', 1 ); |
|
184 | + add_option('give_payment_totals_upgraded', 1); |
|
185 | 185 | } |
186 | 186 | |
187 | -add_action( 'give_upgrade_payments', 'give_update_old_payments_with_totals' ); |
|
187 | +add_action('give_upgrade_payments', 'give_update_old_payments_with_totals'); |
|
188 | 188 | |
189 | 189 | /** |
190 | 190 | * Mark Abandoned Donations |
@@ -198,17 +198,17 @@ discard block |
||
198 | 198 | function give_mark_abandoned_donations() { |
199 | 199 | $args = array( |
200 | 200 | 'status' => 'pending', |
201 | - 'number' => - 1, |
|
201 | + 'number' => -1, |
|
202 | 202 | 'output' => 'give_payments', |
203 | 203 | ); |
204 | 204 | |
205 | - add_filter( 'posts_where', 'give_filter_where_older_than_week' ); |
|
205 | + add_filter('posts_where', 'give_filter_where_older_than_week'); |
|
206 | 206 | |
207 | - $payments = give_get_payments( $args ); |
|
207 | + $payments = give_get_payments($args); |
|
208 | 208 | |
209 | - remove_filter( 'posts_where', 'give_filter_where_older_than_week' ); |
|
209 | + remove_filter('posts_where', 'give_filter_where_older_than_week'); |
|
210 | 210 | |
211 | - if ( $payments ) { |
|
211 | + if ($payments) { |
|
212 | 212 | /** |
213 | 213 | * Filter payment gateways: Used to set payment gateways which can be skip while transferring pending payment to abandon. |
214 | 214 | * |
@@ -216,13 +216,13 @@ discard block |
||
216 | 216 | * |
217 | 217 | * @param array $skip_payment_gateways Array of payment gateways |
218 | 218 | */ |
219 | - $skip_payment_gateways = apply_filters( 'give_mark_abandoned_donation_gateways', array( 'offline' ) ); |
|
219 | + $skip_payment_gateways = apply_filters('give_mark_abandoned_donation_gateways', array('offline')); |
|
220 | 220 | |
221 | - foreach ( $payments as $payment ) { |
|
222 | - $gateway = give_get_payment_gateway( $payment ); |
|
221 | + foreach ($payments as $payment) { |
|
222 | + $gateway = give_get_payment_gateway($payment); |
|
223 | 223 | |
224 | 224 | // Skip payment gateways. |
225 | - if ( in_array( $gateway, $skip_payment_gateways ) ) { |
|
225 | + if (in_array($gateway, $skip_payment_gateways)) { |
|
226 | 226 | continue; |
227 | 227 | } |
228 | 228 | |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | } |
233 | 233 | } |
234 | 234 | |
235 | -add_action( 'give_weekly_scheduled_events', 'give_mark_abandoned_donations' ); |
|
235 | +add_action('give_weekly_scheduled_events', 'give_mark_abandoned_donations'); |
|
236 | 236 | |
237 | 237 | |
238 | 238 | /** |
@@ -244,12 +244,12 @@ discard block |
||
244 | 244 | * |
245 | 245 | * @return void |
246 | 246 | */ |
247 | -function give_refresh_thismonth_stat_transients( $payment_ID ) { |
|
247 | +function give_refresh_thismonth_stat_transients($payment_ID) { |
|
248 | 248 | // Monthly stats. |
249 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
249 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
250 | 250 | |
251 | 251 | // @todo: Refresh only range related stat cache |
252 | 252 | give_delete_donation_stats(); |
253 | 253 | } |
254 | 254 | |
255 | -add_action( 'save_post_give_payment', 'give_refresh_thismonth_stat_transients' ); |
|
255 | +add_action('save_post_give_payment', 'give_refresh_thismonth_stat_transients'); |
@@ -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 | |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @param $args array The array of arguments that can be passed in and used for setting up this payment query. |
57 | 57 | */ |
58 | - public function __construct( $args = array() ) { |
|
58 | + public function __construct($args = array()) { |
|
59 | 59 | $defaults = array( |
60 | 60 | 'output' => 'payments', |
61 | - 'post_type' => array( 'give_payment' ), |
|
61 | + 'post_type' => array('give_payment'), |
|
62 | 62 | 'start_date' => false, |
63 | 63 | 'end_date' => false, |
64 | 64 | 'number' => 20, |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | 'give_forms' => null, |
80 | 80 | ); |
81 | 81 | |
82 | - $this->args = wp_parse_args( $args, $defaults ); |
|
82 | + $this->args = wp_parse_args($args, $defaults); |
|
83 | 83 | |
84 | 84 | $this->init(); |
85 | 85 | } |
@@ -93,11 +93,11 @@ discard block |
||
93 | 93 | * @param $query_var |
94 | 94 | * @param $value |
95 | 95 | */ |
96 | - public function __set( $query_var, $value ) { |
|
97 | - if ( in_array( $query_var, array( 'meta_query', 'tax_query' ) ) ) { |
|
98 | - $this->args[ $query_var ][] = $value; |
|
96 | + public function __set($query_var, $value) { |
|
97 | + if (in_array($query_var, array('meta_query', 'tax_query'))) { |
|
98 | + $this->args[$query_var][] = $value; |
|
99 | 99 | } else { |
100 | - $this->args[ $query_var ] = $value; |
|
100 | + $this->args[$query_var] = $value; |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | * |
110 | 110 | * @param $query_var |
111 | 111 | */ |
112 | - public function __unset( $query_var ) { |
|
113 | - unset( $this->args[ $query_var ] ); |
|
112 | + public function __unset($query_var) { |
|
113 | + unset($this->args[$query_var]); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | $this->children(); |
146 | 146 | $this->give_forms(); |
147 | 147 | |
148 | - add_filter( 'posts_orderby', array( $this, 'custom_orderby' ), 10, 2 ); |
|
148 | + add_filter('posts_orderby', array($this, 'custom_orderby'), 10, 2); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | */ |
157 | 157 | private function unset_filters() { |
158 | 158 | $this->date_filter_post(); |
159 | - remove_filter( 'posts_orderby', array( $this, 'custom_orderby' ) ); |
|
159 | + remove_filter('posts_orderby', array($this, 'custom_orderby')); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | |
@@ -181,30 +181,30 @@ discard block |
||
181 | 181 | * |
182 | 182 | * @param Give_Payments_Query $this Payments query object. |
183 | 183 | */ |
184 | - do_action( 'give_pre_get_payments', $this ); |
|
184 | + do_action('give_pre_get_payments', $this); |
|
185 | 185 | |
186 | 186 | // Modify the query/query arguments before we retrieve payments. |
187 | 187 | $this->set_filters(); |
188 | 188 | |
189 | - $query = new WP_Query( $this->args ); |
|
189 | + $query = new WP_Query($this->args); |
|
190 | 190 | |
191 | 191 | $custom_output = array( |
192 | 192 | 'payments', |
193 | 193 | 'give_payments', |
194 | 194 | ); |
195 | 195 | |
196 | - if ( ! in_array( $this->args['output'], $custom_output ) ) { |
|
196 | + if ( ! in_array($this->args['output'], $custom_output)) { |
|
197 | 197 | return $query->posts; |
198 | 198 | } |
199 | 199 | |
200 | - if ( $query->have_posts() ) { |
|
201 | - while ( $query->have_posts() ) { |
|
200 | + if ($query->have_posts()) { |
|
201 | + while ($query->have_posts()) { |
|
202 | 202 | $query->the_post(); |
203 | 203 | |
204 | 204 | $payment_id = get_post()->ID; |
205 | - $payment = new Give_Payment( $payment_id ); |
|
205 | + $payment = new Give_Payment($payment_id); |
|
206 | 206 | |
207 | - $this->payments[] = apply_filters( 'give_payment', $payment, $payment_id, $this ); |
|
207 | + $this->payments[] = apply_filters('give_payment', $payment, $payment_id, $this); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | wp_reset_postdata(); |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @param Give_Payments_Query $this Payments query object. |
223 | 223 | */ |
224 | - do_action( 'give_post_get_payments', $this ); |
|
224 | + do_action('give_post_get_payments', $this); |
|
225 | 225 | |
226 | 226 | return $this->payments; |
227 | 227 | } |
@@ -235,13 +235,13 @@ discard block |
||
235 | 235 | * @return void |
236 | 236 | */ |
237 | 237 | public function date_filter_pre() { |
238 | - if ( ! ( $this->args['start_date'] || $this->args['end_date'] ) ) { |
|
238 | + if ( ! ($this->args['start_date'] || $this->args['end_date'])) { |
|
239 | 239 | return; |
240 | 240 | } |
241 | 241 | |
242 | - $this->setup_dates( $this->args['start_date'], $this->args['end_date'] ); |
|
242 | + $this->setup_dates($this->args['start_date'], $this->args['end_date']); |
|
243 | 243 | |
244 | - add_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
244 | + add_filter('posts_where', array($this, 'payments_where')); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -254,11 +254,11 @@ discard block |
||
254 | 254 | * @return void |
255 | 255 | */ |
256 | 256 | public function date_filter_post() { |
257 | - if ( ! ( $this->args['start_date'] || $this->args['end_date'] ) ) { |
|
257 | + if ( ! ($this->args['start_date'] || $this->args['end_date'])) { |
|
258 | 258 | return; |
259 | 259 | } |
260 | 260 | |
261 | - remove_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
261 | + remove_filter('posts_where', array($this, 'payments_where')); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
@@ -270,12 +270,12 @@ discard block |
||
270 | 270 | * @return void |
271 | 271 | */ |
272 | 272 | public function status() { |
273 | - if ( ! isset ( $this->args['status'] ) ) { |
|
273 | + if ( ! isset ($this->args['status'])) { |
|
274 | 274 | return; |
275 | 275 | } |
276 | 276 | |
277 | - $this->__set( 'post_status', $this->args['status'] ); |
|
278 | - $this->__unset( 'status' ); |
|
277 | + $this->__set('post_status', $this->args['status']); |
|
278 | + $this->__unset('status'); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |
@@ -287,12 +287,12 @@ discard block |
||
287 | 287 | * @return void |
288 | 288 | */ |
289 | 289 | public function page() { |
290 | - if ( ! isset ( $this->args['page'] ) ) { |
|
290 | + if ( ! isset ($this->args['page'])) { |
|
291 | 291 | return; |
292 | 292 | } |
293 | 293 | |
294 | - $this->__set( 'paged', $this->args['page'] ); |
|
295 | - $this->__unset( 'page' ); |
|
294 | + $this->__set('paged', $this->args['page']); |
|
295 | + $this->__unset('page'); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | /** |
@@ -305,17 +305,17 @@ discard block |
||
305 | 305 | */ |
306 | 306 | public function per_page() { |
307 | 307 | |
308 | - if ( ! isset( $this->args['number'] ) ) { |
|
308 | + if ( ! isset($this->args['number'])) { |
|
309 | 309 | return; |
310 | 310 | } |
311 | 311 | |
312 | - if ( $this->args['number'] == - 1 ) { |
|
313 | - $this->__set( 'nopaging', true ); |
|
312 | + if ($this->args['number'] == - 1) { |
|
313 | + $this->__set('nopaging', true); |
|
314 | 314 | } else { |
315 | - $this->__set( 'posts_per_page', $this->args['number'] ); |
|
315 | + $this->__set('posts_per_page', $this->args['number']); |
|
316 | 316 | } |
317 | 317 | |
318 | - $this->__unset( 'number' ); |
|
318 | + $this->__unset('number'); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | /** |
@@ -327,12 +327,12 @@ discard block |
||
327 | 327 | * @return void |
328 | 328 | */ |
329 | 329 | public function month() { |
330 | - if ( ! isset ( $this->args['month'] ) ) { |
|
330 | + if ( ! isset ($this->args['month'])) { |
|
331 | 331 | return; |
332 | 332 | } |
333 | 333 | |
334 | - $this->__set( 'monthnum', $this->args['month'] ); |
|
335 | - $this->__unset( 'month' ); |
|
334 | + $this->__set('monthnum', $this->args['month']); |
|
335 | + $this->__unset('month'); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | /** |
@@ -344,23 +344,23 @@ discard block |
||
344 | 344 | * @return void |
345 | 345 | */ |
346 | 346 | public function orderby() { |
347 | - switch ( $this->args['orderby'] ) { |
|
347 | + switch ($this->args['orderby']) { |
|
348 | 348 | case 'amount' : |
349 | - $this->__set( 'orderby', 'meta_value_num' ); |
|
350 | - $this->__set( 'meta_key', '_give_payment_total' ); |
|
349 | + $this->__set('orderby', 'meta_value_num'); |
|
350 | + $this->__set('meta_key', '_give_payment_total'); |
|
351 | 351 | break; |
352 | 352 | |
353 | 353 | case 'status' : |
354 | - $this->__set( 'orderby', 'post_status' ); |
|
354 | + $this->__set('orderby', 'post_status'); |
|
355 | 355 | break; |
356 | 356 | |
357 | 357 | case 'donation_form' : |
358 | - $this->__set( 'orderby', 'meta_value' ); |
|
359 | - $this->__set( 'meta_key', '_give_payment_form_title' ); |
|
358 | + $this->__set('orderby', 'meta_value'); |
|
359 | + $this->__set('meta_key', '_give_payment_form_title'); |
|
360 | 360 | break; |
361 | 361 | |
362 | 362 | default : |
363 | - $this->__set( 'orderby', $this->args['orderby'] ); |
|
363 | + $this->__set('orderby', $this->args['orderby']); |
|
364 | 364 | break; |
365 | 365 | } |
366 | 366 | } |
@@ -377,15 +377,15 @@ discard block |
||
377 | 377 | * |
378 | 378 | * @return mixed |
379 | 379 | */ |
380 | - public function custom_orderby( $order, $query ) { |
|
381 | - $post_types = is_array( $query->query['post_type'] ) ? $query->query['post_type'] : array( $query->query['post_type'] ); |
|
382 | - if ( ! in_array( 'give_payment', $post_types ) || is_array( $query->query['orderby'] ) ) { |
|
380 | + public function custom_orderby($order, $query) { |
|
381 | + $post_types = is_array($query->query['post_type']) ? $query->query['post_type'] : array($query->query['post_type']); |
|
382 | + if ( ! in_array('give_payment', $post_types) || is_array($query->query['orderby'])) { |
|
383 | 383 | return $order; |
384 | 384 | } |
385 | 385 | |
386 | - switch ( $query->query['orderby'] ) { |
|
386 | + switch ($query->query['orderby']) { |
|
387 | 387 | case 'post_status': |
388 | - $order = 'wp_posts.post_status ' . strtoupper( $query->query['order'] ); |
|
388 | + $order = 'wp_posts.post_status '.strtoupper($query->query['order']); |
|
389 | 389 | break; |
390 | 390 | } |
391 | 391 | |
@@ -401,20 +401,20 @@ discard block |
||
401 | 401 | * @return void |
402 | 402 | */ |
403 | 403 | public function user() { |
404 | - if ( is_null( $this->args['user'] ) ) { |
|
404 | + if (is_null($this->args['user'])) { |
|
405 | 405 | return; |
406 | 406 | } |
407 | 407 | |
408 | - if ( is_numeric( $this->args['user'] ) ) { |
|
408 | + if (is_numeric($this->args['user'])) { |
|
409 | 409 | $user_key = '_give_payment_user_id'; |
410 | 410 | } else { |
411 | 411 | $user_key = '_give_payment_user_email'; |
412 | 412 | } |
413 | 413 | |
414 | - $this->__set( 'meta_query', array( |
|
414 | + $this->__set('meta_query', array( |
|
415 | 415 | 'key' => $user_key, |
416 | 416 | 'value' => $this->args['user'], |
417 | - ) ); |
|
417 | + )); |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | /** |
@@ -425,14 +425,14 @@ discard block |
||
425 | 425 | * @return void |
426 | 426 | */ |
427 | 427 | public function donor() { |
428 | - if ( is_null( $this->args['donor'] ) || ! is_numeric( $this->args['donor'] ) ) { |
|
428 | + if (is_null($this->args['donor']) || ! is_numeric($this->args['donor'])) { |
|
429 | 429 | return; |
430 | 430 | } |
431 | 431 | |
432 | - $this->__set( 'meta_query', array( |
|
432 | + $this->__set('meta_query', array( |
|
433 | 433 | 'key' => '_give_payment_customer_id', |
434 | 434 | 'value' => (int) $this->args['donor'], |
435 | - ) ); |
|
435 | + )); |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | /** |
@@ -445,33 +445,33 @@ discard block |
||
445 | 445 | */ |
446 | 446 | public function search() { |
447 | 447 | |
448 | - if ( ! isset( $this->args['s'] ) ) { |
|
448 | + if ( ! isset($this->args['s'])) { |
|
449 | 449 | return; |
450 | 450 | } |
451 | 451 | |
452 | - $search = trim( $this->args['s'] ); |
|
452 | + $search = trim($this->args['s']); |
|
453 | 453 | |
454 | - if ( empty( $search ) ) { |
|
454 | + if (empty($search)) { |
|
455 | 455 | return; |
456 | 456 | } |
457 | 457 | |
458 | - $is_email = is_email( $search ) || strpos( $search, '@' ) !== false; |
|
459 | - $is_user = strpos( $search, strtolower( 'user:' ) ) !== false; |
|
458 | + $is_email = is_email($search) || strpos($search, '@') !== false; |
|
459 | + $is_user = strpos($search, strtolower('user:')) !== false; |
|
460 | 460 | |
461 | - if ( ! empty( $this->args['search_in_notes'] ) ) { |
|
461 | + if ( ! empty($this->args['search_in_notes'])) { |
|
462 | 462 | |
463 | - $notes = give_get_payment_notes( 0, $search ); |
|
463 | + $notes = give_get_payment_notes(0, $search); |
|
464 | 464 | |
465 | - if ( ! empty( $notes ) ) { |
|
465 | + if ( ! empty($notes)) { |
|
466 | 466 | |
467 | - $payment_ids = wp_list_pluck( (array) $notes, 'comment_post_ID' ); |
|
467 | + $payment_ids = wp_list_pluck((array) $notes, 'comment_post_ID'); |
|
468 | 468 | |
469 | - $this->__set( 'post__in', $payment_ids ); |
|
469 | + $this->__set('post__in', $payment_ids); |
|
470 | 470 | } |
471 | 471 | |
472 | - $this->__unset( 's' ); |
|
472 | + $this->__unset('s'); |
|
473 | 473 | |
474 | - } elseif ( $is_email || strlen( $search ) == 32 ) { |
|
474 | + } elseif ($is_email || strlen($search) == 32) { |
|
475 | 475 | |
476 | 476 | $key = $is_email ? '_give_payment_user_email' : '_give_payment_purchase_key'; |
477 | 477 | $search_meta = array( |
@@ -480,19 +480,19 @@ discard block |
||
480 | 480 | 'compare' => 'LIKE', |
481 | 481 | ); |
482 | 482 | |
483 | - $this->__set( 'meta_query', $search_meta ); |
|
484 | - $this->__unset( 's' ); |
|
483 | + $this->__set('meta_query', $search_meta); |
|
484 | + $this->__unset('s'); |
|
485 | 485 | |
486 | - } elseif ( $is_user ) { |
|
486 | + } elseif ($is_user) { |
|
487 | 487 | |
488 | 488 | $search_meta = array( |
489 | 489 | 'key' => '_give_payment_user_id', |
490 | - 'value' => trim( str_replace( 'user:', '', strtolower( $search ) ) ), |
|
490 | + 'value' => trim(str_replace('user:', '', strtolower($search))), |
|
491 | 491 | ); |
492 | 492 | |
493 | - $this->__set( 'meta_query', $search_meta ); |
|
493 | + $this->__set('meta_query', $search_meta); |
|
494 | 494 | |
495 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
495 | + if (give_get_option('enable_sequential')) { |
|
496 | 496 | |
497 | 497 | $search_meta = array( |
498 | 498 | 'key' => '_give_payment_number', |
@@ -500,19 +500,19 @@ discard block |
||
500 | 500 | 'compare' => 'LIKE', |
501 | 501 | ); |
502 | 502 | |
503 | - $this->__set( 'meta_query', $search_meta ); |
|
503 | + $this->__set('meta_query', $search_meta); |
|
504 | 504 | |
505 | 505 | $this->args['meta_query']['relation'] = 'OR'; |
506 | 506 | |
507 | 507 | } |
508 | 508 | |
509 | - $this->__unset( 's' ); |
|
509 | + $this->__unset('s'); |
|
510 | 510 | |
511 | 511 | } elseif ( |
512 | - give_get_option( 'enable_sequential' ) && |
|
512 | + give_get_option('enable_sequential') && |
|
513 | 513 | ( |
514 | - false !== strpos( $search, give_get_option( 'sequential_prefix' ) ) || |
|
515 | - false !== strpos( $search, give_get_option( 'sequential_postfix' ) ) |
|
514 | + false !== strpos($search, give_get_option('sequential_prefix')) || |
|
515 | + false !== strpos($search, give_get_option('sequential_postfix')) |
|
516 | 516 | ) |
517 | 517 | ) { |
518 | 518 | |
@@ -522,29 +522,29 @@ discard block |
||
522 | 522 | 'compare' => 'LIKE', |
523 | 523 | ); |
524 | 524 | |
525 | - $this->__set( 'meta_query', $search_meta ); |
|
526 | - $this->__unset( 's' ); |
|
525 | + $this->__set('meta_query', $search_meta); |
|
526 | + $this->__unset('s'); |
|
527 | 527 | |
528 | - } elseif ( is_numeric( $search ) ) { |
|
528 | + } elseif (is_numeric($search)) { |
|
529 | 529 | |
530 | - $post = get_post( $search ); |
|
530 | + $post = get_post($search); |
|
531 | 531 | |
532 | - if ( is_object( $post ) && $post->post_type == 'give_payment' ) { |
|
532 | + if (is_object($post) && $post->post_type == 'give_payment') { |
|
533 | 533 | |
534 | 534 | $arr = array(); |
535 | 535 | $arr[] = $search; |
536 | - $this->__set( 'post__in', $arr ); |
|
537 | - $this->__unset( 's' ); |
|
536 | + $this->__set('post__in', $arr); |
|
537 | + $this->__unset('s'); |
|
538 | 538 | } |
539 | - } elseif ( '#' == substr( $search, 0, 1 ) ) { |
|
539 | + } elseif ('#' == substr($search, 0, 1)) { |
|
540 | 540 | |
541 | - $search = str_replace( '#:', '', $search ); |
|
542 | - $search = str_replace( '#', '', $search ); |
|
543 | - $this->__set( 'give_forms', $search ); |
|
544 | - $this->__unset( 's' ); |
|
541 | + $search = str_replace('#:', '', $search); |
|
542 | + $search = str_replace('#', '', $search); |
|
543 | + $this->__set('give_forms', $search); |
|
544 | + $this->__unset('s'); |
|
545 | 545 | |
546 | 546 | } else { |
547 | - $this->__set( 's', $search ); |
|
547 | + $this->__set('s', $search); |
|
548 | 548 | |
549 | 549 | } |
550 | 550 | |
@@ -559,16 +559,16 @@ discard block |
||
559 | 559 | * @return void |
560 | 560 | */ |
561 | 561 | public function mode() { |
562 | - if ( empty( $this->args['mode'] ) || $this->args['mode'] == 'all' ) { |
|
563 | - $this->__unset( 'mode' ); |
|
562 | + if (empty($this->args['mode']) || $this->args['mode'] == 'all') { |
|
563 | + $this->__unset('mode'); |
|
564 | 564 | |
565 | 565 | return; |
566 | 566 | } |
567 | 567 | |
568 | - $this->__set( 'meta_query', array( |
|
568 | + $this->__set('meta_query', array( |
|
569 | 569 | 'key' => '_give_payment_mode', |
570 | 570 | 'value' => $this->args['mode'], |
571 | - ) ); |
|
571 | + )); |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | /** |
@@ -580,10 +580,10 @@ discard block |
||
580 | 580 | * @return void |
581 | 581 | */ |
582 | 582 | public function children() { |
583 | - if ( empty( $this->args['children'] ) ) { |
|
584 | - $this->__set( 'post_parent', 0 ); |
|
583 | + if (empty($this->args['children'])) { |
|
584 | + $this->__set('post_parent', 0); |
|
585 | 585 | } |
586 | - $this->__unset( 'children' ); |
|
586 | + $this->__unset('children'); |
|
587 | 587 | } |
588 | 588 | |
589 | 589 | /** |
@@ -596,25 +596,25 @@ discard block |
||
596 | 596 | */ |
597 | 597 | public function give_forms() { |
598 | 598 | |
599 | - if ( empty( $this->args['give_forms'] ) ) { |
|
599 | + if (empty($this->args['give_forms'])) { |
|
600 | 600 | return; |
601 | 601 | } |
602 | 602 | |
603 | 603 | $compare = '='; |
604 | 604 | |
605 | - if ( is_array( $this->args['give_forms'] ) ) { |
|
605 | + if (is_array($this->args['give_forms'])) { |
|
606 | 606 | $compare = 'IN'; |
607 | 607 | } |
608 | 608 | |
609 | - $this->__set( 'meta_query', array( |
|
609 | + $this->__set('meta_query', array( |
|
610 | 610 | array( |
611 | 611 | 'key' => '_give_payment_form_id', |
612 | 612 | 'value' => $this->args['give_forms'], |
613 | 613 | 'compare' => $compare, |
614 | 614 | ), |
615 | - ) ); |
|
615 | + )); |
|
616 | 616 | |
617 | - $this->__unset( 'give_forms' ); |
|
617 | + $this->__unset('give_forms'); |
|
618 | 618 | |
619 | 619 | } |
620 | 620 |
@@ -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 | |
@@ -93,19 +93,19 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function get_predefined_dates() { |
95 | 95 | $predefined = array( |
96 | - 'today' => esc_html__( 'Today', 'give' ), |
|
97 | - 'yesterday' => esc_html__( 'Yesterday', 'give' ), |
|
98 | - 'this_week' => esc_html__( 'This Week', 'give' ), |
|
99 | - 'last_week' => esc_html__( 'Last Week', 'give' ), |
|
100 | - 'this_month' => esc_html__( 'This Month', 'give' ), |
|
101 | - 'last_month' => esc_html__( 'Last Month', 'give' ), |
|
102 | - 'this_quarter' => esc_html__( 'This Quarter', 'give' ), |
|
103 | - 'last_quarter' => esc_html__( 'Last Quarter', 'give' ), |
|
104 | - 'this_year' => esc_html__( 'This Year', 'give' ), |
|
105 | - 'last_year' => esc_html__( 'Last Year', 'give' ) |
|
96 | + 'today' => esc_html__('Today', 'give'), |
|
97 | + 'yesterday' => esc_html__('Yesterday', 'give'), |
|
98 | + 'this_week' => esc_html__('This Week', 'give'), |
|
99 | + 'last_week' => esc_html__('Last Week', 'give'), |
|
100 | + 'this_month' => esc_html__('This Month', 'give'), |
|
101 | + 'last_month' => esc_html__('Last Month', 'give'), |
|
102 | + 'this_quarter' => esc_html__('This Quarter', 'give'), |
|
103 | + 'last_quarter' => esc_html__('Last Quarter', 'give'), |
|
104 | + 'this_year' => esc_html__('This Year', 'give'), |
|
105 | + 'last_year' => esc_html__('Last Year', 'give') |
|
106 | 106 | ); |
107 | 107 | |
108 | - return apply_filters( 'give_stats_predefined_dates', $predefined ); |
|
108 | + return apply_filters('give_stats_predefined_dates', $predefined); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -121,18 +121,18 @@ discard block |
||
121 | 121 | * |
122 | 122 | * @return void |
123 | 123 | */ |
124 | - public function setup_dates( $_start_date = 'this_month', $_end_date = false ) { |
|
124 | + public function setup_dates($_start_date = 'this_month', $_end_date = false) { |
|
125 | 125 | |
126 | - if ( empty( $_start_date ) ) { |
|
126 | + if (empty($_start_date)) { |
|
127 | 127 | $_start_date = 'this_month'; |
128 | 128 | } |
129 | 129 | |
130 | - if ( empty( $_end_date ) ) { |
|
130 | + if (empty($_end_date)) { |
|
131 | 131 | $_end_date = $_start_date; |
132 | 132 | } |
133 | 133 | |
134 | - $this->start_date = $this->convert_date( $_start_date ); |
|
135 | - $this->end_date = $this->convert_date( $_end_date, true ); |
|
134 | + $this->start_date = $this->convert_date($_start_date); |
|
135 | + $this->end_date = $this->convert_date($_end_date, true); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -148,26 +148,26 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @return array|WP_Error If the date is invalid, a WP_Error object will be returned. |
150 | 150 | */ |
151 | - public function convert_date( $date, $end_date = false ) { |
|
151 | + public function convert_date($date, $end_date = false) { |
|
152 | 152 | |
153 | 153 | $this->timestamp = false; |
154 | 154 | $second = $end_date ? 59 : 0; |
155 | 155 | $minute = $end_date ? 59 : 0; |
156 | 156 | $hour = $end_date ? 23 : 0; |
157 | 157 | $day = 1; |
158 | - $month = date( 'n', current_time( 'timestamp' ) ); |
|
159 | - $year = date( 'Y', current_time( 'timestamp' ) ); |
|
158 | + $month = date('n', current_time('timestamp')); |
|
159 | + $year = date('Y', current_time('timestamp')); |
|
160 | 160 | |
161 | - if ( array_key_exists( $date, $this->get_predefined_dates() ) ) { |
|
161 | + if (array_key_exists($date, $this->get_predefined_dates())) { |
|
162 | 162 | |
163 | 163 | // This is a predefined date rate, such as last_week |
164 | - switch ( $date ) { |
|
164 | + switch ($date) { |
|
165 | 165 | |
166 | 166 | case 'this_month' : |
167 | 167 | |
168 | - if ( $end_date ) { |
|
168 | + if ($end_date) { |
|
169 | 169 | |
170 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
170 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
171 | 171 | $hour = 23; |
172 | 172 | $minute = 59; |
173 | 173 | $second = 59; |
@@ -177,28 +177,28 @@ discard block |
||
177 | 177 | |
178 | 178 | case 'last_month' : |
179 | 179 | |
180 | - if ( $month == 1 ) { |
|
180 | + if ($month == 1) { |
|
181 | 181 | |
182 | 182 | $month = 12; |
183 | - $year --; |
|
183 | + $year--; |
|
184 | 184 | |
185 | 185 | } else { |
186 | 186 | |
187 | - $month --; |
|
187 | + $month--; |
|
188 | 188 | |
189 | 189 | } |
190 | 190 | |
191 | - if ( $end_date ) { |
|
192 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
191 | + if ($end_date) { |
|
192 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | break; |
196 | 196 | |
197 | 197 | case 'today' : |
198 | 198 | |
199 | - $day = date( 'd', current_time( 'timestamp' ) ); |
|
199 | + $day = date('d', current_time('timestamp')); |
|
200 | 200 | |
201 | - if ( $end_date ) { |
|
201 | + if ($end_date) { |
|
202 | 202 | $hour = 23; |
203 | 203 | $minute = 59; |
204 | 204 | $second = 59; |
@@ -208,23 +208,23 @@ discard block |
||
208 | 208 | |
209 | 209 | case 'yesterday' : |
210 | 210 | |
211 | - $day = date( 'd', current_time( 'timestamp' ) ) - 1; |
|
211 | + $day = date('d', current_time('timestamp')) - 1; |
|
212 | 212 | |
213 | 213 | // Check if Today is the first day of the month (meaning subtracting one will get us 0) |
214 | - if ( $day < 1 ) { |
|
214 | + if ($day < 1) { |
|
215 | 215 | |
216 | 216 | // If current month is 1 |
217 | - if ( 1 == $month ) { |
|
217 | + if (1 == $month) { |
|
218 | 218 | |
219 | 219 | $year -= 1; // Today is January 1, so skip back to last day of December |
220 | 220 | $month = 12; |
221 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
221 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
222 | 222 | |
223 | 223 | } else { |
224 | 224 | |
225 | 225 | // Go back one month and get the last day of the month |
226 | 226 | $month -= 1; |
227 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
227 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
228 | 228 | |
229 | 229 | } |
230 | 230 | } |
@@ -233,12 +233,12 @@ discard block |
||
233 | 233 | |
234 | 234 | case 'this_week' : |
235 | 235 | |
236 | - $days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24; |
|
237 | - $today = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24; |
|
236 | + $days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24; |
|
237 | + $today = date('d', current_time('timestamp')) * 60 * 60 * 24; |
|
238 | 238 | |
239 | - if ( $today < $days_to_week_start ) { |
|
239 | + if ($today < $days_to_week_start) { |
|
240 | 240 | |
241 | - if ( $month > 1 ) { |
|
241 | + if ($month > 1) { |
|
242 | 242 | $month -= 1; |
243 | 243 | } else { |
244 | 244 | $month = 12; |
@@ -246,19 +246,19 @@ discard block |
||
246 | 246 | |
247 | 247 | } |
248 | 248 | |
249 | - if ( ! $end_date ) { |
|
249 | + if ( ! $end_date) { |
|
250 | 250 | |
251 | 251 | // Getting the start day |
252 | 252 | |
253 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1; |
|
254 | - $day += get_option( 'start_of_week' ); |
|
253 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 1; |
|
254 | + $day += get_option('start_of_week'); |
|
255 | 255 | |
256 | 256 | } else { |
257 | 257 | |
258 | 258 | // Getting the end day |
259 | 259 | |
260 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1; |
|
261 | - $day += get_option( 'start_of_week' ) + 6; |
|
260 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 1; |
|
261 | + $day += get_option('start_of_week') + 6; |
|
262 | 262 | |
263 | 263 | } |
264 | 264 | |
@@ -266,12 +266,12 @@ discard block |
||
266 | 266 | |
267 | 267 | case 'last_week' : |
268 | 268 | |
269 | - $days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24; |
|
270 | - $today = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24; |
|
269 | + $days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24; |
|
270 | + $today = date('d', current_time('timestamp')) * 60 * 60 * 24; |
|
271 | 271 | |
272 | - if ( $today < $days_to_week_start ) { |
|
272 | + if ($today < $days_to_week_start) { |
|
273 | 273 | |
274 | - if ( $month > 1 ) { |
|
274 | + if ($month > 1) { |
|
275 | 275 | $month -= 1; |
276 | 276 | } else { |
277 | 277 | $month = 12; |
@@ -279,19 +279,19 @@ discard block |
||
279 | 279 | |
280 | 280 | } |
281 | 281 | |
282 | - if ( ! $end_date ) { |
|
282 | + if ( ! $end_date) { |
|
283 | 283 | |
284 | 284 | // Getting the start day |
285 | 285 | |
286 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8; |
|
287 | - $day += get_option( 'start_of_week' ); |
|
286 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 8; |
|
287 | + $day += get_option('start_of_week'); |
|
288 | 288 | |
289 | 289 | } else { |
290 | 290 | |
291 | 291 | // Getting the end day |
292 | 292 | |
293 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8; |
|
294 | - $day += get_option( 'start_of_week' ) + 6; |
|
293 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 8; |
|
294 | + $day += get_option('start_of_week') + 6; |
|
295 | 295 | |
296 | 296 | } |
297 | 297 | |
@@ -299,39 +299,39 @@ discard block |
||
299 | 299 | |
300 | 300 | case 'this_quarter' : |
301 | 301 | |
302 | - $month_now = date( 'n', current_time( 'timestamp' ) ); |
|
302 | + $month_now = date('n', current_time('timestamp')); |
|
303 | 303 | |
304 | - if ( $month_now <= 3 ) { |
|
304 | + if ($month_now <= 3) { |
|
305 | 305 | |
306 | - if ( ! $end_date ) { |
|
306 | + if ( ! $end_date) { |
|
307 | 307 | $month = 1; |
308 | 308 | } else { |
309 | 309 | $month = 3; |
310 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
310 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
311 | 311 | $hour = 23; |
312 | 312 | $minute = 59; |
313 | 313 | $second = 59; |
314 | 314 | } |
315 | 315 | |
316 | - } else if ( $month_now <= 6 ) { |
|
316 | + } else if ($month_now <= 6) { |
|
317 | 317 | |
318 | - if ( ! $end_date ) { |
|
318 | + if ( ! $end_date) { |
|
319 | 319 | $month = 4; |
320 | 320 | } else { |
321 | 321 | $month = 6; |
322 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
322 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
323 | 323 | $hour = 23; |
324 | 324 | $minute = 59; |
325 | 325 | $second = 59; |
326 | 326 | } |
327 | 327 | |
328 | - } else if ( $month_now <= 9 ) { |
|
328 | + } else if ($month_now <= 9) { |
|
329 | 329 | |
330 | - if ( ! $end_date ) { |
|
330 | + if ( ! $end_date) { |
|
331 | 331 | $month = 7; |
332 | 332 | } else { |
333 | 333 | $month = 9; |
334 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
334 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
335 | 335 | $hour = 23; |
336 | 336 | $minute = 59; |
337 | 337 | $second = 59; |
@@ -339,11 +339,11 @@ discard block |
||
339 | 339 | |
340 | 340 | } else { |
341 | 341 | |
342 | - if ( ! $end_date ) { |
|
342 | + if ( ! $end_date) { |
|
343 | 343 | $month = 10; |
344 | 344 | } else { |
345 | 345 | $month = 12; |
346 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
346 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
347 | 347 | $hour = 23; |
348 | 348 | $minute = 59; |
349 | 349 | $second = 59; |
@@ -355,40 +355,40 @@ discard block |
||
355 | 355 | |
356 | 356 | case 'last_quarter' : |
357 | 357 | |
358 | - $month_now = date( 'n', current_time( 'timestamp' ) ); |
|
358 | + $month_now = date('n', current_time('timestamp')); |
|
359 | 359 | |
360 | - if ( $month_now <= 3 ) { |
|
360 | + if ($month_now <= 3) { |
|
361 | 361 | |
362 | - if ( ! $end_date ) { |
|
362 | + if ( ! $end_date) { |
|
363 | 363 | $month = 10; |
364 | 364 | } else { |
365 | 365 | $year -= 1; |
366 | 366 | $month = 12; |
367 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
367 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
368 | 368 | $hour = 23; |
369 | 369 | $minute = 59; |
370 | 370 | $second = 59; |
371 | 371 | } |
372 | 372 | |
373 | - } else if ( $month_now <= 6 ) { |
|
373 | + } else if ($month_now <= 6) { |
|
374 | 374 | |
375 | - if ( ! $end_date ) { |
|
375 | + if ( ! $end_date) { |
|
376 | 376 | $month = 1; |
377 | 377 | } else { |
378 | 378 | $month = 3; |
379 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
379 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
380 | 380 | $hour = 23; |
381 | 381 | $minute = 59; |
382 | 382 | $second = 59; |
383 | 383 | } |
384 | 384 | |
385 | - } else if ( $month_now <= 9 ) { |
|
385 | + } else if ($month_now <= 9) { |
|
386 | 386 | |
387 | - if ( ! $end_date ) { |
|
387 | + if ( ! $end_date) { |
|
388 | 388 | $month = 4; |
389 | 389 | } else { |
390 | 390 | $month = 6; |
391 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
391 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
392 | 392 | $hour = 23; |
393 | 393 | $minute = 59; |
394 | 394 | $second = 59; |
@@ -396,11 +396,11 @@ discard block |
||
396 | 396 | |
397 | 397 | } else { |
398 | 398 | |
399 | - if ( ! $end_date ) { |
|
399 | + if ( ! $end_date) { |
|
400 | 400 | $month = 7; |
401 | 401 | } else { |
402 | 402 | $month = 9; |
403 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
403 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
404 | 404 | $hour = 23; |
405 | 405 | $minute = 59; |
406 | 406 | $second = 59; |
@@ -412,11 +412,11 @@ discard block |
||
412 | 412 | |
413 | 413 | case 'this_year' : |
414 | 414 | |
415 | - if ( ! $end_date ) { |
|
415 | + if ( ! $end_date) { |
|
416 | 416 | $month = 1; |
417 | 417 | } else { |
418 | 418 | $month = 12; |
419 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
419 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
420 | 420 | $hour = 23; |
421 | 421 | $minute = 59; |
422 | 422 | $second = 59; |
@@ -427,11 +427,11 @@ discard block |
||
427 | 427 | case 'last_year' : |
428 | 428 | |
429 | 429 | $year -= 1; |
430 | - if ( ! $end_date ) { |
|
430 | + if ( ! $end_date) { |
|
431 | 431 | $month = 1; |
432 | 432 | } else { |
433 | 433 | $month = 12; |
434 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
434 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
435 | 435 | $hour = 23; |
436 | 436 | $minute = 59; |
437 | 437 | $second = 59; |
@@ -442,30 +442,30 @@ discard block |
||
442 | 442 | } |
443 | 443 | |
444 | 444 | |
445 | - } else if ( is_numeric( $date ) ) { |
|
445 | + } else if (is_numeric($date)) { |
|
446 | 446 | |
447 | 447 | // return $date unchanged since it is a timestamp |
448 | 448 | $this->timestamp = true; |
449 | 449 | |
450 | - } else if ( false !== strtotime( $date ) ) { |
|
450 | + } else if (false !== strtotime($date)) { |
|
451 | 451 | |
452 | - $date = strtotime( $date, current_time( 'timestamp' ) ); |
|
453 | - $year = date( 'Y', $date ); |
|
454 | - $month = date( 'm', $date ); |
|
455 | - $day = date( 'd', $date ); |
|
452 | + $date = strtotime($date, current_time('timestamp')); |
|
453 | + $year = date('Y', $date); |
|
454 | + $month = date('m', $date); |
|
455 | + $day = date('d', $date); |
|
456 | 456 | |
457 | 457 | } else { |
458 | 458 | |
459 | - return new WP_Error( 'invalid_date', esc_html__( 'Improper date provided.', 'give' ) ); |
|
459 | + return new WP_Error('invalid_date', esc_html__('Improper date provided.', 'give')); |
|
460 | 460 | |
461 | 461 | } |
462 | 462 | |
463 | - if ( false === $this->timestamp ) { |
|
463 | + if (false === $this->timestamp) { |
|
464 | 464 | // Create an exact timestamp |
465 | - $date = mktime( $hour, $minute, $second, $month, $day, $year ); |
|
465 | + $date = mktime($hour, $minute, $second, $month, $day, $year); |
|
466 | 466 | } |
467 | 467 | |
468 | - return apply_filters( 'give_stats_date', $date, $end_date, $this ); |
|
468 | + return apply_filters('give_stats_date', $date, $end_date, $this); |
|
469 | 469 | |
470 | 470 | } |
471 | 471 | |
@@ -481,33 +481,33 @@ discard block |
||
481 | 481 | * |
482 | 482 | * @return string |
483 | 483 | */ |
484 | - public function count_where( $where = '' ) { |
|
484 | + public function count_where($where = '') { |
|
485 | 485 | // Only get payments in our date range |
486 | 486 | |
487 | 487 | $start_where = ''; |
488 | 488 | $end_where = ''; |
489 | 489 | |
490 | - if ( $this->start_date ) { |
|
490 | + if ($this->start_date) { |
|
491 | 491 | |
492 | - if ( $this->timestamp ) { |
|
492 | + if ($this->timestamp) { |
|
493 | 493 | $format = 'Y-m-d H:i:s'; |
494 | 494 | } else { |
495 | 495 | $format = 'Y-m-d 00:00:00'; |
496 | 496 | } |
497 | 497 | |
498 | - $start_date = date( $format, $this->start_date ); |
|
498 | + $start_date = date($format, $this->start_date); |
|
499 | 499 | $start_where = " AND p.post_date >= '{$start_date}'"; |
500 | 500 | } |
501 | 501 | |
502 | - if ( $this->end_date ) { |
|
502 | + if ($this->end_date) { |
|
503 | 503 | |
504 | - if ( $this->timestamp ) { |
|
504 | + if ($this->timestamp) { |
|
505 | 505 | $format = 'Y-m-d H:i:s'; |
506 | 506 | } else { |
507 | 507 | $format = 'Y-m-d 23:59:59'; |
508 | 508 | } |
509 | 509 | |
510 | - $end_date = date( $format, $this->end_date ); |
|
510 | + $end_date = date($format, $this->end_date); |
|
511 | 511 | |
512 | 512 | $end_where = " AND p.post_date <= '{$end_date}'"; |
513 | 513 | } |
@@ -529,34 +529,34 @@ discard block |
||
529 | 529 | * |
530 | 530 | * @return string |
531 | 531 | */ |
532 | - public function payments_where( $where = '' ) { |
|
532 | + public function payments_where($where = '') { |
|
533 | 533 | |
534 | 534 | global $wpdb; |
535 | 535 | |
536 | 536 | $start_where = ''; |
537 | 537 | $end_where = ''; |
538 | 538 | |
539 | - if ( ! is_wp_error( $this->start_date ) ) { |
|
539 | + if ( ! is_wp_error($this->start_date)) { |
|
540 | 540 | |
541 | - if ( $this->timestamp ) { |
|
541 | + if ($this->timestamp) { |
|
542 | 542 | $format = 'Y-m-d H:i:s'; |
543 | 543 | } else { |
544 | 544 | $format = 'Y-m-d 00:00:00'; |
545 | 545 | } |
546 | 546 | |
547 | - $start_date = date( $format, $this->start_date ); |
|
547 | + $start_date = date($format, $this->start_date); |
|
548 | 548 | $start_where = " AND $wpdb->posts.post_date >= '{$start_date}'"; |
549 | 549 | } |
550 | 550 | |
551 | - if ( ! is_wp_error( $this->end_date ) ) { |
|
551 | + if ( ! is_wp_error($this->end_date)) { |
|
552 | 552 | |
553 | - if ( $this->timestamp ) { |
|
553 | + if ($this->timestamp) { |
|
554 | 554 | $format = 'Y-m-d H:i:s'; |
555 | 555 | } else { |
556 | 556 | $format = 'Y-m-d 23:59:59'; |
557 | 557 | } |
558 | 558 | |
559 | - $end_date = date( $format, $this->end_date ); |
|
559 | + $end_date = date($format, $this->end_date); |
|
560 | 560 | |
561 | 561 | $end_where = " AND $wpdb->posts.post_date <= '{$end_date}'"; |
562 | 562 | } |
@@ -44,7 +44,7 @@ |
||
44 | 44 | ) { |
45 | 45 | // If Yoast SEO or Yoast SEO Premium plugin exists, then update seo sitemap cache. |
46 | 46 | if ( (is_plugin_active( 'wordpress-seo/wp-seo.php' ) |
47 | - || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' )) |
|
47 | + || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' )) |
|
48 | 48 | && class_exists( 'WPSEO_Sitemaps_Cache' ) |
49 | 49 | ) { |
50 | 50 | $yoast_sitemaps_cache = new WPSEO_Sitemaps_Cache(); |
@@ -19,9 +19,9 @@ discard block |
||
19 | 19 | * @return void |
20 | 20 | */ |
21 | 21 | function give_disable_mandrill_nl2br() { |
22 | - add_filter( 'mandrill_nl2br', '__return_false' ); |
|
22 | + add_filter('mandrill_nl2br', '__return_false'); |
|
23 | 23 | } |
24 | -add_action( 'give_email_send_before', 'give_disable_mandrill_nl2br' ); |
|
24 | +add_action('give_email_send_before', 'give_disable_mandrill_nl2br'); |
|
25 | 25 | |
26 | 26 | |
27 | 27 | /** |
@@ -33,26 +33,26 @@ discard block |
||
33 | 33 | */ |
34 | 34 | function give_clear_seo_sitemap_cache_on_settings_change() { |
35 | 35 | // Load required file if the fn 'is_plugin_active' doesn't exists. |
36 | - if ( ! function_exists( 'is_plugin_active' ) ) { |
|
37 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
36 | + if ( ! function_exists('is_plugin_active')) { |
|
37 | + require_once ABSPATH.'wp-admin/includes/plugin.php'; |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | // If there is change detected for Single Form View and Form Archives options then proceed. |
41 | 41 | if ( |
42 | - ( $_POST['forms_singular'] != give_get_option( 'forms_singular' ) ) || |
|
43 | - ( $_POST['forms_archives'] != give_get_option( 'forms_archives' ) ) |
|
42 | + ($_POST['forms_singular'] != give_get_option('forms_singular')) || |
|
43 | + ($_POST['forms_archives'] != give_get_option('forms_archives')) |
|
44 | 44 | ) { |
45 | 45 | // If Yoast SEO or Yoast SEO Premium plugin exists, then update seo sitemap cache. |
46 | - if ( (is_plugin_active( 'wordpress-seo/wp-seo.php' ) |
|
47 | - || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' )) |
|
48 | - && class_exists( 'WPSEO_Sitemaps_Cache' ) |
|
46 | + if ((is_plugin_active('wordpress-seo/wp-seo.php') |
|
47 | + || is_plugin_active('wordpress-seo-premium/wp-seo-premium.php')) |
|
48 | + && class_exists('WPSEO_Sitemaps_Cache') |
|
49 | 49 | ) { |
50 | 50 | $yoast_sitemaps_cache = new WPSEO_Sitemaps_Cache(); |
51 | - if ( method_exists( $yoast_sitemaps_cache, 'clear' ) ) { |
|
51 | + if (method_exists($yoast_sitemaps_cache, 'clear')) { |
|
52 | 52 | WPSEO_Sitemaps_Cache::clear(); |
53 | 53 | } |
54 | 54 | } |
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
58 | -add_action( 'give-settings_save_display', 'give_clear_seo_sitemap_cache_on_settings_change' ); |
|
58 | +add_action('give-settings_save_display', 'give_clear_seo_sitemap_cache_on_settings_change'); |
@@ -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 | |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | /* @var WPDB $wpdb */ |
34 | 34 | global $wpdb; |
35 | 35 | |
36 | - $wpdb->customermeta = $this->table_name = $wpdb->prefix . 'give_customermeta'; |
|
36 | + $wpdb->customermeta = $this->table_name = $wpdb->prefix.'give_customermeta'; |
|
37 | 37 | $this->primary_key = 'meta_id'; |
38 | 38 | $this->version = '1.0'; |
39 | 39 | |
@@ -71,13 +71,13 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single is true. |
73 | 73 | */ |
74 | - public function get_meta( $donor_id = 0, $meta_key = '', $single = false ) { |
|
75 | - $donor_id = $this->sanitize_donor_id( $donor_id ); |
|
76 | - if ( false === $donor_id ) { |
|
74 | + public function get_meta($donor_id = 0, $meta_key = '', $single = false) { |
|
75 | + $donor_id = $this->sanitize_donor_id($donor_id); |
|
76 | + if (false === $donor_id) { |
|
77 | 77 | return false; |
78 | 78 | } |
79 | 79 | |
80 | - return get_metadata( 'customer', $donor_id, $meta_key, $single ); |
|
80 | + return get_metadata('customer', $donor_id, $meta_key, $single); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -95,13 +95,13 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @return bool False for failure. True for success. |
97 | 97 | */ |
98 | - public function add_meta( $donor_id = 0, $meta_key = '', $meta_value, $unique = false ) { |
|
99 | - $donor_id = $this->sanitize_donor_id( $donor_id ); |
|
100 | - if ( false === $donor_id ) { |
|
98 | + public function add_meta($donor_id = 0, $meta_key = '', $meta_value, $unique = false) { |
|
99 | + $donor_id = $this->sanitize_donor_id($donor_id); |
|
100 | + if (false === $donor_id) { |
|
101 | 101 | return false; |
102 | 102 | } |
103 | 103 | |
104 | - return add_metadata( 'customer', $donor_id, $meta_key, $meta_value, $unique ); |
|
104 | + return add_metadata('customer', $donor_id, $meta_key, $meta_value, $unique); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -124,13 +124,13 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @return bool False on failure, true if success. |
126 | 126 | */ |
127 | - public function update_meta( $donor_id = 0, $meta_key = '', $meta_value, $prev_value = '' ) { |
|
128 | - $donor_id = $this->sanitize_donor_id( $donor_id ); |
|
129 | - if ( false === $donor_id ) { |
|
127 | + public function update_meta($donor_id = 0, $meta_key = '', $meta_value, $prev_value = '') { |
|
128 | + $donor_id = $this->sanitize_donor_id($donor_id); |
|
129 | + if (false === $donor_id) { |
|
130 | 130 | return false; |
131 | 131 | } |
132 | 132 | |
133 | - return update_metadata( 'customer', $donor_id, $meta_key, $meta_value, $prev_value ); |
|
133 | + return update_metadata('customer', $donor_id, $meta_key, $meta_value, $prev_value); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -151,8 +151,8 @@ discard block |
||
151 | 151 | * |
152 | 152 | * @return bool False for failure. True for success. |
153 | 153 | */ |
154 | - public function delete_meta( $donor_id = 0, $meta_key = '', $meta_value = '' ) { |
|
155 | - return delete_metadata( 'customer', $donor_id, $meta_key, $meta_value ); |
|
154 | + public function delete_meta($donor_id = 0, $meta_key = '', $meta_value = '') { |
|
155 | + return delete_metadata('customer', $donor_id, $meta_key, $meta_value); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | */ |
166 | 166 | public function create_table() { |
167 | 167 | |
168 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
168 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
169 | 169 | |
170 | 170 | $sql = "CREATE TABLE {$this->table_name} ( |
171 | 171 | meta_id bigint(20) NOT NULL AUTO_INCREMENT, |
@@ -177,9 +177,9 @@ discard block |
||
177 | 177 | KEY meta_key (meta_key) |
178 | 178 | ) CHARACTER SET utf8 COLLATE utf8_general_ci;"; |
179 | 179 | |
180 | - dbDelta( $sql ); |
|
180 | + dbDelta($sql); |
|
181 | 181 | |
182 | - update_option( $this->table_name . '_db_version', $this->version ); |
|
182 | + update_option($this->table_name.'_db_version', $this->version); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
@@ -192,23 +192,23 @@ discard block |
||
192 | 192 | * |
193 | 193 | * @return int|bool The normalized donor ID or false if it's found to not be valid. |
194 | 194 | */ |
195 | - private function sanitize_donor_id( $donor_id ) { |
|
196 | - if ( ! is_numeric( $donor_id ) ) { |
|
195 | + private function sanitize_donor_id($donor_id) { |
|
196 | + if ( ! is_numeric($donor_id)) { |
|
197 | 197 | return false; |
198 | 198 | } |
199 | 199 | |
200 | 200 | $donor_id = (int) $donor_id; |
201 | 201 | |
202 | 202 | // We were given a non positive number. |
203 | - if ( absint( $donor_id ) !== $donor_id ) { |
|
203 | + if (absint($donor_id) !== $donor_id) { |
|
204 | 204 | return false; |
205 | 205 | } |
206 | 206 | |
207 | - if ( empty( $donor_id ) ) { |
|
207 | + if (empty($donor_id)) { |
|
208 | 208 | return false; |
209 | 209 | } |
210 | 210 | |
211 | - return absint( $donor_id ); |
|
211 | + return absint($donor_id); |
|
212 | 212 | |
213 | 213 | } |
214 | 214 |
@@ -7,12 +7,12 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // Exit if accessed directly. |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if ( ! defined('ABSPATH')) { |
|
11 | 11 | exit; |
12 | 12 | } |
13 | 13 | |
14 | 14 | // Add give command. |
15 | -WP_CLI::add_command( 'give', 'GIVE_CLI_COMMAND' ); |
|
15 | +WP_CLI::add_command('give', 'GIVE_CLI_COMMAND'); |
|
16 | 16 | |
17 | 17 | |
18 | 18 | /** |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | * |
69 | 69 | * @subcommand logo |
70 | 70 | */ |
71 | - public function ascii( $args, $assoc_args ) { |
|
72 | - WP_CLI::log( file_get_contents( GIVE_PLUGIN_DIR . 'assets/images/give-ascii-logo.txt' ) ); |
|
71 | + public function ascii($args, $assoc_args) { |
|
72 | + WP_CLI::log(file_get_contents(GIVE_PLUGIN_DIR.'assets/images/give-ascii-logo.txt')); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | |
@@ -94,54 +94,54 @@ discard block |
||
94 | 94 | * |
95 | 95 | * @subcommand details |
96 | 96 | */ |
97 | - public function details( $args, $assoc_args ) { |
|
97 | + public function details($args, $assoc_args) { |
|
98 | 98 | |
99 | 99 | /** |
100 | 100 | * Plugin Information |
101 | 101 | */ |
102 | - WP_CLI::log( $this->color_message( __( 'Give Version: ', 'give' ) ) . GIVE_VERSION ); |
|
102 | + WP_CLI::log($this->color_message(__('Give Version: ', 'give')).GIVE_VERSION); |
|
103 | 103 | |
104 | 104 | /** |
105 | 105 | * General Information. |
106 | 106 | */ |
107 | - WP_CLI::log( "\n#### " . $this->color_message( __( 'General information', 'give' ) ) . ' ####' ); |
|
107 | + WP_CLI::log("\n#### ".$this->color_message(__('General information', 'give')).' ####'); |
|
108 | 108 | |
109 | - $success_page = give_get_option( 'success_page' ); |
|
110 | - $failure_page = give_get_option( 'failure_page' ); |
|
111 | - $history_page = give_get_option( 'history_page' ); |
|
109 | + $success_page = give_get_option('success_page'); |
|
110 | + $failure_page = give_get_option('failure_page'); |
|
111 | + $history_page = give_get_option('history_page'); |
|
112 | 112 | |
113 | - WP_CLI::log( $this->color_message( sprintf( __( 'Success Page: ', 'give' ) ) ) . ( $success_page ? "[{$success_page}] " . get_permalink( $success_page ) : __( 'Not Set', 'give' ) ) ); |
|
114 | - WP_CLI::log( $this->color_message( __( 'Failed Donation Page: ', 'give' ) ) . ( $failure_page ? "[{$failure_page}] " . get_permalink( $failure_page ) : __( 'Not Set', 'give' ) ) ); |
|
115 | - WP_CLI::log( $this->color_message( __( 'Donation History Page: ', 'give' ) ) . ( $history_page ? "[{$history_page}] " . get_permalink( $history_page ) : __( 'Not Set', 'give' ) ) ); |
|
116 | - WP_CLI::log( $this->color_message( __( 'Country: ', 'give' ) ) . give_get_country() ); |
|
113 | + WP_CLI::log($this->color_message(sprintf(__('Success Page: ', 'give'))).($success_page ? "[{$success_page}] ".get_permalink($success_page) : __('Not Set', 'give'))); |
|
114 | + WP_CLI::log($this->color_message(__('Failed Donation Page: ', 'give')).($failure_page ? "[{$failure_page}] ".get_permalink($failure_page) : __('Not Set', 'give'))); |
|
115 | + WP_CLI::log($this->color_message(__('Donation History Page: ', 'give')).($history_page ? "[{$history_page}] ".get_permalink($history_page) : __('Not Set', 'give'))); |
|
116 | + WP_CLI::log($this->color_message(__('Country: ', 'give')).give_get_country()); |
|
117 | 117 | |
118 | 118 | /** |
119 | 119 | * Currency Information. |
120 | 120 | */ |
121 | - $default_gateway = give_get_option( 'default_gateway' ); |
|
121 | + $default_gateway = give_get_option('default_gateway'); |
|
122 | 122 | |
123 | - WP_CLI::log( "\n#### " . $this->color_message( __( 'Currency Information', 'give' ) ) . ' ####' ); |
|
123 | + WP_CLI::log("\n#### ".$this->color_message(__('Currency Information', 'give')).' ####'); |
|
124 | 124 | |
125 | - WP_CLI::log( $this->color_message( __( 'Currency: ', 'give' ), give_get_currency() ) ); |
|
126 | - WP_CLI::log( $this->color_message( __( 'Currency Position: ', 'give' ), give_get_currency_position() ) ); |
|
127 | - WP_CLI::log( $this->color_message( __( 'Thousand Separator: ', 'give' ), give_get_price_thousand_separator() ) ); |
|
128 | - WP_CLI::log( $this->color_message( __( 'Decimal Separator: ', 'give' ), give_get_price_decimal_separator() ) ); |
|
129 | - WP_CLI::log( $this->color_message( __( 'Number of Decimals: ', 'give' ), give_get_price_decimals() ) ); |
|
130 | - WP_CLI::log( $this->color_message( __( 'Test Mode: ', 'give' ), ( give_get_option( 'test_mode' ) ? __( 'Yes', 'give' ) : __( 'No', 'give' ) ) ) ); |
|
131 | - WP_CLI::log( $this->color_message( __( 'Default Gateway: ', 'give' ), ( $default_gateway ? $default_gateway : __( 'Not Set', 'give' ) ) ) ); |
|
125 | + WP_CLI::log($this->color_message(__('Currency: ', 'give'), give_get_currency())); |
|
126 | + WP_CLI::log($this->color_message(__('Currency Position: ', 'give'), give_get_currency_position())); |
|
127 | + WP_CLI::log($this->color_message(__('Thousand Separator: ', 'give'), give_get_price_thousand_separator())); |
|
128 | + WP_CLI::log($this->color_message(__('Decimal Separator: ', 'give'), give_get_price_decimal_separator())); |
|
129 | + WP_CLI::log($this->color_message(__('Number of Decimals: ', 'give'), give_get_price_decimals())); |
|
130 | + WP_CLI::log($this->color_message(__('Test Mode: ', 'give'), (give_get_option('test_mode') ? __('Yes', 'give') : __('No', 'give')))); |
|
131 | + WP_CLI::log($this->color_message(__('Default Gateway: ', 'give'), ($default_gateway ? $default_gateway : __('Not Set', 'give')))); |
|
132 | 132 | |
133 | 133 | // Payment gateways Information. |
134 | - $gateways = give_get_ordered_payment_gateways( give_get_payment_gateways() ); |
|
135 | - WP_CLI::log( $this->color_message( __( 'Enabled Gateways: ', 'give' ) ) ); |
|
134 | + $gateways = give_get_ordered_payment_gateways(give_get_payment_gateways()); |
|
135 | + WP_CLI::log($this->color_message(__('Enabled Gateways: ', 'give'))); |
|
136 | 136 | |
137 | - if ( ! empty( $gateways ) ) { |
|
137 | + if ( ! empty($gateways)) { |
|
138 | 138 | self::$counter = 1; |
139 | - foreach ( $gateways as $gateway ) { |
|
140 | - WP_CLI::log( ' ' . $this->color_message( self::$counter, $gateway['admin_label'] ) ); |
|
141 | - self::$counter ++; |
|
139 | + foreach ($gateways as $gateway) { |
|
140 | + WP_CLI::log(' '.$this->color_message(self::$counter, $gateway['admin_label'])); |
|
141 | + self::$counter++; |
|
142 | 142 | } |
143 | 143 | } else { |
144 | - WP_CLI::log( __( 'Not any payment gateways found', 'give' ) ); |
|
144 | + WP_CLI::log(__('Not any payment gateways found', 'give')); |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | |
@@ -173,15 +173,15 @@ discard block |
||
173 | 173 | * |
174 | 174 | * @subcommand forms |
175 | 175 | */ |
176 | - public function forms( $args, $assoc_args ) { |
|
176 | + public function forms($args, $assoc_args) { |
|
177 | 177 | global $wp_query; |
178 | - $form_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false; |
|
179 | - $number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? absint( $assoc_args['number'] ) : 10; |
|
178 | + $form_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : false; |
|
179 | + $number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? absint($assoc_args['number']) : 10; |
|
180 | 180 | $start = time(); |
181 | 181 | |
182 | 182 | // Cache previous number query var. |
183 | 183 | $is_set_number = $cache_per_page = false; |
184 | - if ( isset( $wp_query->query_vars['number'] ) ) { |
|
184 | + if (isset($wp_query->query_vars['number'])) { |
|
185 | 185 | $cache_per_page = $wp_query->query_vars['number']; |
186 | 186 | $is_set_number = true; |
187 | 187 | } |
@@ -190,22 +190,22 @@ discard block |
||
190 | 190 | $wp_query->query_vars['number'] = $number; |
191 | 191 | |
192 | 192 | // Get forms. |
193 | - $forms = $form_id ? $this->api->get_forms( $form_id ) : $this->api->get_forms(); |
|
193 | + $forms = $form_id ? $this->api->get_forms($form_id) : $this->api->get_forms(); |
|
194 | 194 | |
195 | 195 | // Reset number query var. |
196 | - if ( $is_set_number ) { |
|
196 | + if ($is_set_number) { |
|
197 | 197 | $wp_query->query_vars['number'] = $cache_per_page; |
198 | 198 | } |
199 | 199 | |
200 | 200 | // Bailout. |
201 | - if ( array_key_exists( 'error', $forms ) ) { |
|
201 | + if (array_key_exists('error', $forms)) { |
|
202 | 202 | |
203 | - WP_CLI::warning( $forms['error'] ); |
|
203 | + WP_CLI::warning($forms['error']); |
|
204 | 204 | |
205 | 205 | return; |
206 | - } elseif ( empty( $forms['forms'] ) ) { |
|
206 | + } elseif (empty($forms['forms'])) { |
|
207 | 207 | |
208 | - WP_CLI::error( __( 'No forms found.', 'give' ) ); |
|
208 | + WP_CLI::error(__('No forms found.', 'give')); |
|
209 | 209 | |
210 | 210 | return; |
211 | 211 | } |
@@ -213,25 +213,25 @@ discard block |
||
213 | 213 | // Param to check if form typeis already showed or not. |
214 | 214 | $is_show_form_type = false; |
215 | 215 | |
216 | - if ( 1 === count( $forms ) && $form_id ) { |
|
216 | + if (1 === count($forms) && $form_id) { |
|
217 | 217 | // Show single form. |
218 | - foreach ( $forms['forms'][0] as $key => $info ) { |
|
219 | - switch ( $key ) { |
|
218 | + foreach ($forms['forms'][0] as $key => $info) { |
|
219 | + switch ($key) { |
|
220 | 220 | case 'stats': |
221 | - $this->color_main_heading( ucfirst( $key ) ); |
|
221 | + $this->color_main_heading(ucfirst($key)); |
|
222 | 222 | |
223 | - foreach ( $info as $heading => $data ) { |
|
224 | - $this->color_sub_heading( ucfirst( $heading ) ); |
|
225 | - switch ( $heading ) { |
|
223 | + foreach ($info as $heading => $data) { |
|
224 | + $this->color_sub_heading(ucfirst($heading)); |
|
225 | + switch ($heading) { |
|
226 | 226 | default: |
227 | - foreach ( $data as $subheading => $subdata ) { |
|
227 | + foreach ($data as $subheading => $subdata) { |
|
228 | 228 | |
229 | - switch ( $subheading ) { |
|
229 | + switch ($subheading) { |
|
230 | 230 | case 'earnings': |
231 | - WP_CLI::log( $this->color_message( $subheading . ': ', give_currency_filter( $subdata ) ) ); |
|
231 | + WP_CLI::log($this->color_message($subheading.': ', give_currency_filter($subdata))); |
|
232 | 232 | break; |
233 | 233 | default: |
234 | - WP_CLI::log( $this->color_message( $subheading . ': ', $subdata ) ); |
|
234 | + WP_CLI::log($this->color_message($subheading.': ', $subdata)); |
|
235 | 235 | } |
236 | 236 | } |
237 | 237 | } |
@@ -241,26 +241,26 @@ discard block |
||
241 | 241 | case 'pricing': |
242 | 242 | case 'info': |
243 | 243 | default: |
244 | - $this->color_main_heading( ucfirst( $key ) ); |
|
244 | + $this->color_main_heading(ucfirst($key)); |
|
245 | 245 | |
246 | 246 | // Show form type. |
247 | - if ( ! $is_show_form_type ) { |
|
248 | - $form = new Give_Donate_Form( $form_id ); |
|
247 | + if ( ! $is_show_form_type) { |
|
248 | + $form = new Give_Donate_Form($form_id); |
|
249 | 249 | $is_show_form_type = true; |
250 | 250 | |
251 | - WP_CLI::log( $this->color_message( __( 'form type', 'give' ), $form->get_type() ) ); |
|
251 | + WP_CLI::log($this->color_message(__('form type', 'give'), $form->get_type())); |
|
252 | 252 | } |
253 | 253 | |
254 | - foreach ( $info as $heading => $data ) { |
|
254 | + foreach ($info as $heading => $data) { |
|
255 | 255 | |
256 | - switch ( $heading ) { |
|
256 | + switch ($heading) { |
|
257 | 257 | case 'id': |
258 | - WP_CLI::log( $this->color_message( $heading, $data ) ); |
|
258 | + WP_CLI::log($this->color_message($heading, $data)); |
|
259 | 259 | break; |
260 | 260 | |
261 | 261 | default: |
262 | - $data = empty( $data ) ? __( 'Not set', 'give' ) : $data; |
|
263 | - WP_CLI::log( $this->color_message( $heading, $data ) ); |
|
262 | + $data = empty($data) ? __('Not set', 'give') : $data; |
|
263 | + WP_CLI::log($this->color_message($heading, $data)); |
|
264 | 264 | } |
265 | 265 | } |
266 | 266 | }// End switch(). |
@@ -271,37 +271,37 @@ discard block |
||
271 | 271 | $is_table_first_row_set = false; |
272 | 272 | $table_column_count = 0; |
273 | 273 | |
274 | - WP_CLI::line( $this->color_message( sprintf( __( '%d donation forms found', 'give' ), count( $forms['forms'] ) ), '', false ) ); |
|
274 | + WP_CLI::line($this->color_message(sprintf(__('%d donation forms found', 'give'), count($forms['forms'])), '', false)); |
|
275 | 275 | |
276 | - foreach ( $forms['forms'] as $index => $form_data ) { |
|
276 | + foreach ($forms['forms'] as $index => $form_data) { |
|
277 | 277 | |
278 | 278 | // Default table data. |
279 | 279 | $table_first_row = array(); |
280 | 280 | $table_row = array(); |
281 | 281 | |
282 | - foreach ( $form_data['info'] as $key => $form ) { |
|
282 | + foreach ($form_data['info'] as $key => $form) { |
|
283 | 283 | |
284 | 284 | // Do not show thumbnail, content and link in table. |
285 | - if ( in_array( $key, array( 'content', 'thumbnail', 'link' ), true ) ) { |
|
285 | + if (in_array($key, array('content', 'thumbnail', 'link'), true)) { |
|
286 | 286 | continue; |
287 | 287 | } |
288 | 288 | |
289 | - if ( ! $is_table_first_row_set ) { |
|
289 | + if ( ! $is_table_first_row_set) { |
|
290 | 290 | $table_first_row[] = $key; |
291 | 291 | } |
292 | 292 | |
293 | 293 | $table_row[] = $form; |
294 | 294 | |
295 | - if ( 'status' === $key ) { |
|
295 | + if ('status' === $key) { |
|
296 | 296 | // First array item will be an form id in our case. |
297 | - $form = new Give_Donate_Form( absint( $table_row[0] ) ); |
|
297 | + $form = new Give_Donate_Form(absint($table_row[0])); |
|
298 | 298 | |
299 | 299 | $table_row[] = $form->get_type(); |
300 | 300 | } |
301 | 301 | } |
302 | 302 | |
303 | 303 | // Set table first row. |
304 | - if ( ! $is_table_first_row_set ) { |
|
304 | + if ( ! $is_table_first_row_set) { |
|
305 | 305 | |
306 | 306 | // Add extra column to table. |
307 | 307 | $table_first_row[] = 'type'; |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | $table_data[] = $table_row; |
315 | 315 | }// End foreach(). |
316 | 316 | |
317 | - $this->display_table( $table_data ); |
|
317 | + $this->display_table($table_data); |
|
318 | 318 | }// End if(). |
319 | 319 | } |
320 | 320 | |
@@ -366,37 +366,37 @@ discard block |
||
366 | 366 | * |
367 | 367 | * @subcommand donors |
368 | 368 | */ |
369 | - public function donors( $args, $assoc_args ) { |
|
369 | + public function donors($args, $assoc_args) { |
|
370 | 370 | global $wp_query; |
371 | - $donor_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false; |
|
372 | - $email = isset( $assoc_args ) && array_key_exists( 'email', $assoc_args ) ? $assoc_args['email'] : false; |
|
373 | - $name = isset( $assoc_args ) && array_key_exists( 'name', $assoc_args ) ? $assoc_args['name'] : ''; |
|
374 | - $create = isset( $assoc_args ) && array_key_exists( 'create', $assoc_args ) ? $assoc_args['create'] : false; |
|
375 | - $number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10; |
|
376 | - $form_id = isset( $assoc_args ) && array_key_exists( 'form-id', $assoc_args ) ? $assoc_args['form-id'] : 0; |
|
377 | - $format = isset( $assoc_args ) && array_key_exists( 'format', $assoc_args ) ? $assoc_args['format'] : 'table'; |
|
371 | + $donor_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : false; |
|
372 | + $email = isset($assoc_args) && array_key_exists('email', $assoc_args) ? $assoc_args['email'] : false; |
|
373 | + $name = isset($assoc_args) && array_key_exists('name', $assoc_args) ? $assoc_args['name'] : ''; |
|
374 | + $create = isset($assoc_args) && array_key_exists('create', $assoc_args) ? $assoc_args['create'] : false; |
|
375 | + $number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? $assoc_args['number'] : 10; |
|
376 | + $form_id = isset($assoc_args) && array_key_exists('form-id', $assoc_args) ? $assoc_args['form-id'] : 0; |
|
377 | + $format = isset($assoc_args) && array_key_exists('format', $assoc_args) ? $assoc_args['format'] : 'table'; |
|
378 | 378 | $start = time(); |
379 | 379 | |
380 | - if ( $create ) { |
|
380 | + if ($create) { |
|
381 | 381 | $number = 1; |
382 | 382 | |
383 | - if ( isset( $assoc_args['email'] ) && ! is_email( $email ) ) { |
|
384 | - WP_CLI::warning( 'Wrong email address provided.', 'give' ); |
|
383 | + if (isset($assoc_args['email']) && ! is_email($email)) { |
|
384 | + WP_CLI::warning('Wrong email address provided.', 'give'); |
|
385 | 385 | |
386 | 386 | return; |
387 | 387 | } |
388 | 388 | |
389 | 389 | // Create one or more donors. |
390 | - if ( ! $email ) { |
|
390 | + if ( ! $email) { |
|
391 | 391 | // If no email is specified, look to see if we are generating arbitrary donor accounts. |
392 | - $number = is_numeric( $create ) ? absint( $create ) : 1; |
|
392 | + $number = is_numeric($create) ? absint($create) : 1; |
|
393 | 393 | } |
394 | 394 | |
395 | - for ( $i = 0; $i < $number; $i ++ ) { |
|
396 | - if ( ! $email ) { |
|
395 | + for ($i = 0; $i < $number; $i++) { |
|
396 | + if ( ! $email) { |
|
397 | 397 | |
398 | 398 | // Generate fake email. |
399 | - $email = 'customer-' . uniqid() . '@test.com'; |
|
399 | + $email = 'customer-'.uniqid().'@test.com'; |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | $args = array( |
@@ -404,19 +404,19 @@ discard block |
||
404 | 404 | 'name' => $name, |
405 | 405 | ); |
406 | 406 | |
407 | - $donor_id = Give()->donors->add( $args ); |
|
407 | + $donor_id = Give()->donors->add($args); |
|
408 | 408 | |
409 | - if ( $donor_id ) { |
|
410 | - WP_CLI::line( $this->color_message( sprintf( __( 'Donor #%d created successfully', 'give' ), $donor_id ) ) ); |
|
409 | + if ($donor_id) { |
|
410 | + WP_CLI::line($this->color_message(sprintf(__('Donor #%d created successfully', 'give'), $donor_id))); |
|
411 | 411 | } else { |
412 | - WP_CLI::error( __( 'Failed to create donor', 'give' ) ); |
|
412 | + WP_CLI::error(__('Failed to create donor', 'give')); |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | // Reset email to false so it is generated on the next loop (if creating donors). |
416 | 416 | $email = false; |
417 | 417 | } |
418 | 418 | |
419 | - WP_CLI::line( $this->color_message( sprintf( __( '%1$d donors created in %2$d seconds', 'give' ), $number, time() - $start ) ) ); |
|
419 | + WP_CLI::line($this->color_message(sprintf(__('%1$d donors created in %2$d seconds', 'give'), $number, time() - $start))); |
|
420 | 420 | |
421 | 421 | } else { |
422 | 422 | // Counter. |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | */ |
431 | 431 | // Cache previous number query var. |
432 | 432 | $is_set_number = $cache_per_page = false; |
433 | - if ( isset( $wp_query->query_vars['number'] ) ) { |
|
433 | + if (isset($wp_query->query_vars['number'])) { |
|
434 | 434 | $cache_per_page = $wp_query->query_vars['number']; |
435 | 435 | $is_set_number = true; |
436 | 436 | } |
@@ -439,24 +439,24 @@ discard block |
||
439 | 439 | $wp_query->query_vars['number'] = $number; |
440 | 440 | |
441 | 441 | // Get donors. |
442 | - if ( $form_id ) { |
|
442 | + if ($form_id) { |
|
443 | 443 | // @TODO: Allow user to get a list of donors by donation status. |
444 | - $donors = $this->get_donors_by_form_id( $form_id ); |
|
444 | + $donors = $this->get_donors_by_form_id($form_id); |
|
445 | 445 | } else { |
446 | - $donors = $this->api->get_donors( $search ); |
|
446 | + $donors = $this->api->get_donors($search); |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | // Reset number query var. |
450 | - if ( $is_set_number ) { |
|
450 | + if ($is_set_number) { |
|
451 | 451 | $wp_query->query_vars['number'] = $cache_per_page; |
452 | 452 | } |
453 | 453 | |
454 | - if ( isset( $donors['error'] ) ) { |
|
455 | - WP_CLI::error( $donors['error'] ); |
|
454 | + if (isset($donors['error'])) { |
|
455 | + WP_CLI::error($donors['error']); |
|
456 | 456 | } |
457 | 457 | |
458 | - if ( empty( $donors ) ) { |
|
459 | - WP_CLI::error( __( 'No donors found.', 'give' ) ); |
|
458 | + if (empty($donors)) { |
|
459 | + WP_CLI::error(__('No donors found.', 'give')); |
|
460 | 460 | |
461 | 461 | return; |
462 | 462 | } |
@@ -464,24 +464,24 @@ discard block |
||
464 | 464 | $table_data = array(); |
465 | 465 | $is_table_first_row_set = false; |
466 | 466 | |
467 | - foreach ( $donors['donors'] as $donor_data ) { |
|
467 | + foreach ($donors['donors'] as $donor_data) { |
|
468 | 468 | // Set default table row data. |
469 | - $table_first_row = array( __( 's_no', 'give' ) ); |
|
470 | - $table_row = array( self::$counter ); |
|
469 | + $table_first_row = array(__('s_no', 'give')); |
|
470 | + $table_row = array(self::$counter); |
|
471 | 471 | |
472 | - foreach ( $donor_data as $key => $donor ) { |
|
473 | - switch ( $key ) { |
|
472 | + foreach ($donor_data as $key => $donor) { |
|
473 | + switch ($key) { |
|
474 | 474 | case 'stats': |
475 | - foreach ( $donor as $heading => $data ) { |
|
475 | + foreach ($donor as $heading => $data) { |
|
476 | 476 | |
477 | 477 | // Get first row. |
478 | - if ( ! $is_table_first_row_set ) { |
|
478 | + if ( ! $is_table_first_row_set) { |
|
479 | 479 | $table_first_row[] = $heading; |
480 | 480 | } |
481 | 481 | |
482 | - switch ( $heading ) { |
|
482 | + switch ($heading) { |
|
483 | 483 | case 'total_spent': |
484 | - $table_row[] = give_currency_filter( $data ); |
|
484 | + $table_row[] = give_currency_filter($data); |
|
485 | 485 | break; |
486 | 486 | |
487 | 487 | default: |
@@ -492,10 +492,10 @@ discard block |
||
492 | 492 | |
493 | 493 | case 'info': |
494 | 494 | default: |
495 | - foreach ( $donor as $heading => $data ) { |
|
495 | + foreach ($donor as $heading => $data) { |
|
496 | 496 | |
497 | 497 | // Get first row. |
498 | - if ( ! $is_table_first_row_set ) { |
|
498 | + if ( ! $is_table_first_row_set) { |
|
499 | 499 | $table_first_row[] = $heading; |
500 | 500 | } |
501 | 501 | |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | } |
506 | 506 | |
507 | 507 | // Add first row data to table data. |
508 | - if ( ! $is_table_first_row_set ) { |
|
508 | + if ( ! $is_table_first_row_set) { |
|
509 | 509 | $table_data[] = $table_first_row; |
510 | 510 | $is_table_first_row_set = true; |
511 | 511 | } |
@@ -514,44 +514,44 @@ discard block |
||
514 | 514 | $table_data[] = $table_row; |
515 | 515 | |
516 | 516 | // Increase counter. |
517 | - self::$counter ++; |
|
517 | + self::$counter++; |
|
518 | 518 | }// End foreach(). |
519 | 519 | |
520 | - switch ( $format ) { |
|
520 | + switch ($format) { |
|
521 | 521 | case 'json': |
522 | 522 | $table_column_name = $table_data[0]; |
523 | - unset( $table_data[0] ); |
|
523 | + unset($table_data[0]); |
|
524 | 524 | |
525 | 525 | $new_table_data = array(); |
526 | - foreach ( $table_data as $index => $data ) { |
|
527 | - foreach ( $data as $key => $value ) { |
|
528 | - $new_table_data[ $index ][ $table_column_name[ $key ] ] = $value; |
|
526 | + foreach ($table_data as $index => $data) { |
|
527 | + foreach ($data as $key => $value) { |
|
528 | + $new_table_data[$index][$table_column_name[$key]] = $value; |
|
529 | 529 | } |
530 | 530 | } |
531 | 531 | |
532 | - WP_CLI::log( json_encode( $new_table_data ) ); |
|
532 | + WP_CLI::log(json_encode($new_table_data)); |
|
533 | 533 | break; |
534 | 534 | |
535 | 535 | case 'csv': |
536 | - $file_path = trailingslashit( WP_CONTENT_DIR ) . 'uploads/give_donors_' . date( 'Y_m_d_s', current_time( 'timestamp' ) ) . '.csv'; |
|
537 | - $fp = fopen( $file_path, 'w' ); |
|
536 | + $file_path = trailingslashit(WP_CONTENT_DIR).'uploads/give_donors_'.date('Y_m_d_s', current_time('timestamp')).'.csv'; |
|
537 | + $fp = fopen($file_path, 'w'); |
|
538 | 538 | |
539 | - if ( is_writable( $file_path ) ) { |
|
540 | - foreach ( $table_data as $fields ) { |
|
541 | - fputcsv( $fp, $fields ); |
|
539 | + if (is_writable($file_path)) { |
|
540 | + foreach ($table_data as $fields) { |
|
541 | + fputcsv($fp, $fields); |
|
542 | 542 | } |
543 | 543 | |
544 | - fclose( $fp ); |
|
544 | + fclose($fp); |
|
545 | 545 | |
546 | - WP_CLI::success( "Donors list csv created successfully: {$file_path}" ); |
|
546 | + WP_CLI::success("Donors list csv created successfully: {$file_path}"); |
|
547 | 547 | } else { |
548 | - WP_CLI::warning( "Unable to create donors list csv file: {$file_path} (May folder do not have write permission)" ); |
|
548 | + WP_CLI::warning("Unable to create donors list csv file: {$file_path} (May folder do not have write permission)"); |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | break; |
552 | 552 | |
553 | 553 | default: |
554 | - $this->display_table( $table_data ); |
|
554 | + $this->display_table($table_data); |
|
555 | 555 | }// End switch(). |
556 | 556 | }// End if(). |
557 | 557 | } |
@@ -581,13 +581,13 @@ discard block |
||
581 | 581 | * |
582 | 582 | * @subcommand donations |
583 | 583 | */ |
584 | - public function donations( $args, $assoc_args ) { |
|
584 | + public function donations($args, $assoc_args) { |
|
585 | 585 | global $wp_query; |
586 | - $number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10; |
|
586 | + $number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? $assoc_args['number'] : 10; |
|
587 | 587 | |
588 | 588 | // Cache previous number query var. |
589 | 589 | $is_set_number = $cache_per_page = false; |
590 | - if ( isset( $wp_query->query_vars['number'] ) ) { |
|
590 | + if (isset($wp_query->query_vars['number'])) { |
|
591 | 591 | $cache_per_page = $wp_query->query_vars['number']; |
592 | 592 | $is_set_number = true; |
593 | 593 | } |
@@ -599,46 +599,46 @@ discard block |
||
599 | 599 | $donations = $this->api->get_recent_donations(); |
600 | 600 | |
601 | 601 | // Reset number query var. |
602 | - if ( $is_set_number ) { |
|
602 | + if ($is_set_number) { |
|
603 | 603 | $wp_query->query_vars['number'] = $cache_per_page; |
604 | 604 | } |
605 | 605 | |
606 | - if ( empty( $donations ) ) { |
|
607 | - WP_CLI::error( __( 'No donations found.', 'give' ) ); |
|
606 | + if (empty($donations)) { |
|
607 | + WP_CLI::error(__('No donations found.', 'give')); |
|
608 | 608 | |
609 | 609 | return; |
610 | 610 | } |
611 | 611 | |
612 | 612 | self::$counter = 1; |
613 | 613 | |
614 | - foreach ( $donations['donations'] as $key => $donation ) { |
|
615 | - $this->color_main_heading( sprintf( __( '%1$s. Donation #%2$s', 'give' ), self::$counter, $donation['ID'] ), 'Y' ); |
|
616 | - self::$counter ++; |
|
614 | + foreach ($donations['donations'] as $key => $donation) { |
|
615 | + $this->color_main_heading(sprintf(__('%1$s. Donation #%2$s', 'give'), self::$counter, $donation['ID']), 'Y'); |
|
616 | + self::$counter++; |
|
617 | 617 | |
618 | - foreach ( $donation as $column => $data ) { |
|
618 | + foreach ($donation as $column => $data) { |
|
619 | 619 | |
620 | - if ( is_array( $data ) ) { |
|
621 | - $this->color_sub_heading( $column ); |
|
622 | - foreach ( $data as $subcolumn => $subdata ) { |
|
620 | + if (is_array($data)) { |
|
621 | + $this->color_sub_heading($column); |
|
622 | + foreach ($data as $subcolumn => $subdata) { |
|
623 | 623 | |
624 | 624 | // Decode html codes. |
625 | - switch ( $subcolumn ) { |
|
625 | + switch ($subcolumn) { |
|
626 | 626 | case 'name': |
627 | - $subdata = html_entity_decode( $subdata ); |
|
627 | + $subdata = html_entity_decode($subdata); |
|
628 | 628 | break; |
629 | 629 | } |
630 | 630 | |
631 | 631 | // @TODO Check if multi dimension array information is importent to show or not. For example inside donation array we have array for fees data inside payment meta. |
632 | - if ( is_array( $subdata ) ) { |
|
632 | + if (is_array($subdata)) { |
|
633 | 633 | continue; |
634 | 634 | } |
635 | 635 | |
636 | - WP_CLI::log( $this->color_message( $subcolumn, $subdata ) ); |
|
636 | + WP_CLI::log($this->color_message($subcolumn, $subdata)); |
|
637 | 637 | } |
638 | 638 | continue; |
639 | 639 | } |
640 | 640 | |
641 | - WP_CLI::log( $this->color_message( $column, $data ) ); |
|
641 | + WP_CLI::log($this->color_message($column, $data)); |
|
642 | 642 | } |
643 | 643 | } |
644 | 644 | } |
@@ -677,27 +677,27 @@ discard block |
||
677 | 677 | * |
678 | 678 | * @return void |
679 | 679 | */ |
680 | - public function report( $args, $assoc_args ) { |
|
680 | + public function report($args, $assoc_args) { |
|
681 | 681 | $stats = new Give_Payment_Stats(); |
682 | - $date = isset( $assoc_args ) && array_key_exists( 'date', $assoc_args ) ? $assoc_args['date'] : false; |
|
683 | - $start_date = isset( $assoc_args ) && array_key_exists( 'start-date', $assoc_args ) ? $assoc_args['start-date'] : false; |
|
684 | - $end_date = isset( $assoc_args ) && array_key_exists( 'end-date', $assoc_args ) ? $assoc_args['end-date'] : false; |
|
685 | - $form_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? $assoc_args['id'] : 0; |
|
682 | + $date = isset($assoc_args) && array_key_exists('date', $assoc_args) ? $assoc_args['date'] : false; |
|
683 | + $start_date = isset($assoc_args) && array_key_exists('start-date', $assoc_args) ? $assoc_args['start-date'] : false; |
|
684 | + $end_date = isset($assoc_args) && array_key_exists('end-date', $assoc_args) ? $assoc_args['end-date'] : false; |
|
685 | + $form_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? $assoc_args['id'] : 0; |
|
686 | 686 | |
687 | - if ( ! empty( $date ) ) { |
|
687 | + if ( ! empty($date)) { |
|
688 | 688 | $start_date = $date; |
689 | 689 | $end_date = false; |
690 | - } elseif ( empty( $date ) && empty( $start_date ) ) { |
|
690 | + } elseif (empty($date) && empty($start_date)) { |
|
691 | 691 | $start_date = 'this_month'; |
692 | 692 | $end_date = false; |
693 | 693 | } |
694 | 694 | |
695 | 695 | // Get stats. |
696 | - $earnings = $stats->get_earnings( $form_id, $start_date, $end_date ); |
|
697 | - $sales = $stats->get_sales( $form_id, $start_date, $end_date ); |
|
696 | + $earnings = $stats->get_earnings($form_id, $start_date, $end_date); |
|
697 | + $sales = $stats->get_sales($form_id, $start_date, $end_date); |
|
698 | 698 | |
699 | - WP_CLI::line( $this->color_message( __( 'Earnings', 'give' ), give_currency_filter( $earnings ) ) ); |
|
700 | - WP_CLI::line( $this->color_message( __( 'Sales', 'give' ), $sales ) ); |
|
699 | + WP_CLI::line($this->color_message(__('Earnings', 'give'), give_currency_filter($earnings))); |
|
700 | + WP_CLI::line($this->color_message(__('Sales', 'give'), $sales)); |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | |
@@ -724,27 +724,27 @@ discard block |
||
724 | 724 | * |
725 | 725 | * @subcommand cache |
726 | 726 | */ |
727 | - public function cache( $args, $assoc_args ) { |
|
728 | - $action = isset( $assoc_args ) && array_key_exists( 'action', $assoc_args ) ? $assoc_args['action'] : false; |
|
727 | + public function cache($args, $assoc_args) { |
|
728 | + $action = isset($assoc_args) && array_key_exists('action', $assoc_args) ? $assoc_args['action'] : false; |
|
729 | 729 | |
730 | 730 | // Bailout. |
731 | - if ( ! $action || ! in_array( $action, array( 'delete' ), true ) ) { |
|
732 | - WP_CLI::warning( __( 'Type wp give cache --action=delete to delete all stat transients', 'give' ) ); |
|
731 | + if ( ! $action || ! in_array($action, array('delete'), true)) { |
|
732 | + WP_CLI::warning(__('Type wp give cache --action=delete to delete all stat transients', 'give')); |
|
733 | 733 | |
734 | 734 | return; |
735 | 735 | } |
736 | 736 | |
737 | - switch ( $action ) { |
|
737 | + switch ($action) { |
|
738 | 738 | case 'delete' : |
739 | 739 | // Reset counter. |
740 | 740 | self::$counter = 1; |
741 | 741 | |
742 | - if ( $this->delete_stats_transients() ) { |
|
742 | + if ($this->delete_stats_transients()) { |
|
743 | 743 | // Report .eading. |
744 | - WP_CLI::success( 'Give cache deleted.' ); |
|
744 | + WP_CLI::success('Give cache deleted.'); |
|
745 | 745 | } else { |
746 | 746 | // Report .eading. |
747 | - WP_CLI::warning( 'We did not find any Give plugin cache to delete :)' ); |
|
747 | + WP_CLI::warning('We did not find any Give plugin cache to delete :)'); |
|
748 | 748 | } |
749 | 749 | break; |
750 | 750 | } |
@@ -773,27 +773,27 @@ discard block |
||
773 | 773 | ARRAY_A |
774 | 774 | ); |
775 | 775 | |
776 | - if ( ! empty( $stat_option_names ) ) { |
|
776 | + if ( ! empty($stat_option_names)) { |
|
777 | 777 | |
778 | - foreach ( $stat_option_names as $option_name ) { |
|
778 | + foreach ($stat_option_names as $option_name) { |
|
779 | 779 | $error = false; |
780 | 780 | $option_name = $option_name['option_name']; |
781 | 781 | |
782 | - switch ( true ) { |
|
783 | - case ( false !== strpos( $option_name, 'transient' ) ): |
|
784 | - $option_name = str_replace( '_transient_', '', $option_name ); |
|
785 | - $error = delete_transient( $option_name ); |
|
782 | + switch (true) { |
|
783 | + case (false !== strpos($option_name, 'transient')): |
|
784 | + $option_name = str_replace('_transient_', '', $option_name); |
|
785 | + $error = delete_transient($option_name); |
|
786 | 786 | break; |
787 | 787 | |
788 | 788 | default: |
789 | - $error = delete_option( $option_name ); |
|
789 | + $error = delete_option($option_name); |
|
790 | 790 | } |
791 | 791 | |
792 | - if ( $error ) { |
|
793 | - WP_CLI::log( $this->color_message( self::$counter, $option_name ) ); |
|
794 | - self::$counter ++; |
|
792 | + if ($error) { |
|
793 | + WP_CLI::log($this->color_message(self::$counter, $option_name)); |
|
794 | + self::$counter++; |
|
795 | 795 | } else { |
796 | - WP_CLI::log( $this->color_message( __( 'Error while deleting this transient', 'give' ), $option_name ) ); |
|
796 | + WP_CLI::log($this->color_message(__('Error while deleting this transient', 'give'), $option_name)); |
|
797 | 797 | } |
798 | 798 | } |
799 | 799 | |
@@ -814,13 +814,13 @@ discard block |
||
814 | 814 | * |
815 | 815 | * @return string |
816 | 816 | */ |
817 | - private function color_message( $heading, $message = '', $colon = true, $color = 'g' ) { |
|
817 | + private function color_message($heading, $message = '', $colon = true, $color = 'g') { |
|
818 | 818 | // Add colon. |
819 | - if ( $colon ) { |
|
820 | - $heading = $heading . ': '; |
|
819 | + if ($colon) { |
|
820 | + $heading = $heading.': '; |
|
821 | 821 | } |
822 | 822 | |
823 | - return WP_CLI::colorize( "%{$color}" . $heading . '%n' ) . $message; |
|
823 | + return WP_CLI::colorize("%{$color}".$heading.'%n').$message; |
|
824 | 824 | } |
825 | 825 | |
826 | 826 | |
@@ -835,8 +835,8 @@ discard block |
||
835 | 835 | * |
836 | 836 | * @return void |
837 | 837 | */ |
838 | - private function color_main_heading( $heading, $color = 'g' ) { |
|
839 | - WP_CLI::log( "\n###### " . $this->color_message( $heading, '', false, $color ) . ' ######' ); |
|
838 | + private function color_main_heading($heading, $color = 'g') { |
|
839 | + WP_CLI::log("\n###### ".$this->color_message($heading, '', false, $color).' ######'); |
|
840 | 840 | } |
841 | 841 | |
842 | 842 | /** |
@@ -849,8 +849,8 @@ discard block |
||
849 | 849 | * |
850 | 850 | * @return void |
851 | 851 | */ |
852 | - private function color_sub_heading( $subheading ) { |
|
853 | - WP_CLI::log( "\n--->" . $subheading . '', '', false ); |
|
852 | + private function color_sub_heading($subheading) { |
|
853 | + WP_CLI::log("\n--->".$subheading.'', '', false); |
|
854 | 854 | } |
855 | 855 | |
856 | 856 | |
@@ -864,17 +864,17 @@ discard block |
||
864 | 864 | * |
865 | 865 | * @return void |
866 | 866 | */ |
867 | - private function display_table( $data ) { |
|
867 | + private function display_table($data) { |
|
868 | 868 | $table = new \cli\Table(); |
869 | 869 | |
870 | 870 | // Set table header. |
871 | - $table->setHeaders( $data[0] ); |
|
871 | + $table->setHeaders($data[0]); |
|
872 | 872 | |
873 | 873 | // Remove table header. |
874 | - unset( $data[0] ); |
|
874 | + unset($data[0]); |
|
875 | 875 | |
876 | 876 | // Set table data. |
877 | - $table->setRows( $data ); |
|
877 | + $table->setRows($data); |
|
878 | 878 | |
879 | 879 | // Display table. |
880 | 880 | $table->display(); |
@@ -891,14 +891,14 @@ discard block |
||
891 | 891 | * @return array |
892 | 892 | */ |
893 | 893 | |
894 | - private function get_donors_by_form_id( $form_id ) { |
|
894 | + private function get_donors_by_form_id($form_id) { |
|
895 | 895 | $donors = array(); |
896 | 896 | |
897 | 897 | $donations = new Give_Payments_Query( |
898 | 898 | array( |
899 | - 'give_forms' => array( $form_id ), |
|
900 | - 'number' => - 1, |
|
901 | - 'status' => array( 'publish' ), |
|
899 | + 'give_forms' => array($form_id), |
|
900 | + 'number' => -1, |
|
901 | + 'status' => array('publish'), |
|
902 | 902 | ) |
903 | 903 | ); |
904 | 904 | |
@@ -906,16 +906,16 @@ discard block |
||
906 | 906 | $skip_donors = array(); |
907 | 907 | |
908 | 908 | /* @var Give_Payment|object $donation Payment object. */ |
909 | - foreach ( $donations as $donation ) { |
|
909 | + foreach ($donations as $donation) { |
|
910 | 910 | |
911 | - if ( in_array( $donation->customer_id, $skip_donors ) ) { |
|
911 | + if (in_array($donation->customer_id, $skip_donors)) { |
|
912 | 912 | continue; |
913 | 913 | } |
914 | 914 | |
915 | - if ( ! empty( $donors ) ) { |
|
916 | - $donors['donors'][] = current( current( $this->api->get_donors( (int) $donation->customer_id ) ) ); |
|
915 | + if ( ! empty($donors)) { |
|
916 | + $donors['donors'][] = current(current($this->api->get_donors((int) $donation->customer_id))); |
|
917 | 917 | } else { |
918 | - $donors = array_merge( $donors, $this->api->get_donors( (int) $donation->customer_id ) ); |
|
918 | + $donors = array_merge($donors, $this->api->get_donors((int) $donation->customer_id)); |
|
919 | 919 | } |
920 | 920 | |
921 | 921 | $skip_donors[] = $donation->customer_id; |