@@ -46,7 +46,7 @@ |
||
46 | 46 | * |
47 | 47 | * @since 2.2.0 |
48 | 48 | * |
49 | - * @param string|int $id_or_email |
|
49 | + * @param string $id_or_email |
|
50 | 50 | * |
51 | 51 | * @return bool |
52 | 52 | */ |
@@ -21,15 +21,15 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @return string HTML output. |
23 | 23 | */ |
24 | -function give_get_donor_avatar( $donor, $size = 60 ) { |
|
24 | +function give_get_donor_avatar($donor, $size = 60) { |
|
25 | 25 | ob_start(); |
26 | 26 | ?> |
27 | 27 | <div class="give-donor__image"> |
28 | 28 | <?php |
29 | 29 | // Check if gravatar exists. |
30 | - if ( give_validate_gravatar( $donor->email ) ) { |
|
30 | + if (give_validate_gravatar($donor->email)) { |
|
31 | 31 | // Return avatar. |
32 | - echo get_avatar( $donor->email, $size ); |
|
32 | + echo get_avatar($donor->email, $size); |
|
33 | 33 | } else { |
34 | 34 | // No gravatar = output initials. |
35 | 35 | echo $donor->get_donor_initals(); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | </div> |
38 | 38 | <?php |
39 | 39 | |
40 | - return apply_filters( 'give_get_donor_avatar', ob_get_clean() ); |
|
40 | + return apply_filters('give_get_donor_avatar', ob_get_clean()); |
|
41 | 41 | |
42 | 42 | } |
43 | 43 | |
@@ -50,51 +50,51 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @return bool |
52 | 52 | */ |
53 | -function give_validate_gravatar( $id_or_email ) { |
|
53 | +function give_validate_gravatar($id_or_email) { |
|
54 | 54 | |
55 | 55 | //id or email code borrowed from wp-includes/pluggable.php |
56 | 56 | $email = ''; |
57 | - if ( is_numeric( $id_or_email ) ) { |
|
57 | + if (is_numeric($id_or_email)) { |
|
58 | 58 | $id = (int) $id_or_email; |
59 | - $user = get_userdata( $id ); |
|
60 | - if ( $user ) { |
|
59 | + $user = get_userdata($id); |
|
60 | + if ($user) { |
|
61 | 61 | $email = $user->user_email; |
62 | 62 | } |
63 | - } elseif ( is_object( $id_or_email ) ) { |
|
63 | + } elseif (is_object($id_or_email)) { |
|
64 | 64 | // No avatar for pingbacks or trackbacks |
65 | - $allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) ); |
|
66 | - if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) ) { |
|
65 | + $allowed_comment_types = apply_filters('get_avatar_comment_types', array('comment')); |
|
66 | + if ( ! empty($id_or_email->comment_type) && ! in_array($id_or_email->comment_type, (array) $allowed_comment_types)) { |
|
67 | 67 | return false; |
68 | 68 | } |
69 | 69 | |
70 | - if ( ! empty( $id_or_email->user_id ) ) { |
|
70 | + if ( ! empty($id_or_email->user_id)) { |
|
71 | 71 | $id = (int) $id_or_email->user_id; |
72 | - $user = get_userdata( $id ); |
|
73 | - if ( $user ) { |
|
72 | + $user = get_userdata($id); |
|
73 | + if ($user) { |
|
74 | 74 | $email = $user->user_email; |
75 | 75 | } |
76 | - } elseif ( ! empty( $id_or_email->comment_author_email ) ) { |
|
76 | + } elseif ( ! empty($id_or_email->comment_author_email)) { |
|
77 | 77 | $email = $id_or_email->comment_author_email; |
78 | 78 | } |
79 | 79 | } else { |
80 | 80 | $email = $id_or_email; |
81 | 81 | } |
82 | 82 | |
83 | - $hashkey = md5( strtolower( trim( $email ) ) ); |
|
84 | - $uri = 'http://www.gravatar.com/avatar/' . $hashkey . '?d=404'; |
|
83 | + $hashkey = md5(strtolower(trim($email))); |
|
84 | + $uri = 'http://www.gravatar.com/avatar/'.$hashkey.'?d=404'; |
|
85 | 85 | |
86 | - $data = wp_cache_get( $hashkey ); |
|
87 | - if ( false === $data ) { |
|
88 | - $response = wp_remote_head( $uri ); |
|
89 | - if ( is_wp_error( $response ) ) { |
|
86 | + $data = wp_cache_get($hashkey); |
|
87 | + if (false === $data) { |
|
88 | + $response = wp_remote_head($uri); |
|
89 | + if (is_wp_error($response)) { |
|
90 | 90 | $data = 'not200'; |
91 | 91 | } else { |
92 | 92 | $data = $response['response']['code']; |
93 | 93 | } |
94 | - wp_cache_set( $hashkey, $data, $group = '', $expire = 60 * 5 ); |
|
94 | + wp_cache_set($hashkey, $data, $group = '', $expire = 60 * 5); |
|
95 | 95 | |
96 | 96 | } |
97 | - if ( $data == '200' ) { |
|
97 | + if ($data == '200') { |
|
98 | 98 | return true; |
99 | 99 | } else { |
100 | 100 | return false; |
@@ -114,18 +114,18 @@ discard block |
||
114 | 114 | * |
115 | 115 | * @return int The new note ID |
116 | 116 | */ |
117 | -function give_insert_donor_donation_comment( $donation_id, $donor, $note, $comment_args = array() ) { |
|
117 | +function give_insert_donor_donation_comment($donation_id, $donor, $note, $comment_args = array()) { |
|
118 | 118 | $comment_args = wp_parse_args( |
119 | 119 | $comment_args, |
120 | 120 | array( |
121 | 121 | 'comment_approved' => 0, |
122 | - 'comment_parent' => give_get_payment_form_id( $donation_id ) |
|
122 | + 'comment_parent' => give_get_payment_form_id($donation_id) |
|
123 | 123 | ) |
124 | 124 | ); |
125 | 125 | |
126 | - $comment_id = Give_Comment::add( $donation_id, $note, 'payment', $comment_args ); |
|
126 | + $comment_id = Give_Comment::add($donation_id, $note, 'payment', $comment_args); |
|
127 | 127 | |
128 | - update_comment_meta( $comment_id, '_give_donor_id', $donor ); |
|
128 | + update_comment_meta($comment_id, '_give_donor_id', $donor); |
|
129 | 129 | |
130 | 130 | return $comment_id; |
131 | 131 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * |
145 | 145 | * @return WP_Comment|array |
146 | 146 | */ |
147 | -function give_get_donor_donation_comment( $donation_id, $donor_id, $search = '' ) { |
|
147 | +function give_get_donor_donation_comment($donation_id, $donor_id, $search = '') { |
|
148 | 148 | $comments = Give_Comment::get( |
149 | 149 | $donation_id, |
150 | 150 | 'payment', |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | $search |
161 | 161 | ); |
162 | 162 | |
163 | - return ( ! empty( $comments ) ? current( $comments ) : array() ); |
|
163 | + return ( ! empty($comments) ? current($comments) : array()); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
@@ -176,9 +176,9 @@ discard block |
||
176 | 176 | * |
177 | 177 | * @return int |
178 | 178 | */ |
179 | -function give_get_donor_donation_comment_id( $donation_id, $donor_id, $search = '' ) { |
|
179 | +function give_get_donor_donation_comment_id($donation_id, $donor_id, $search = '') { |
|
180 | 180 | /* @var WP_Comment|array $comment */ |
181 | - $comment = give_get_donor_donation_comment( $donation_id, $donor_id, $search ); |
|
181 | + $comment = give_get_donor_donation_comment($donation_id, $donor_id, $search); |
|
182 | 182 | $comment_id = $comment instanceof WP_Comment ? $comment->comment_ID : 0; |
183 | 183 | |
184 | 184 | return $comment_id; |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * |
198 | 198 | * @return array |
199 | 199 | */ |
200 | -function give_get_donor_donation_comments( $donor_id, $comment_args = array(), $search = '' ) { |
|
200 | +function give_get_donor_donation_comments($donor_id, $comment_args = array(), $search = '') { |
|
201 | 201 | $comments = Give_Comment::get( |
202 | 202 | $donor_id, |
203 | 203 | 'payment', |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | $search |
206 | 206 | ); |
207 | 207 | |
208 | - return ( ! empty( $comments ) ? $comments : array() ); |
|
208 | + return ( ! empty($comments) ? $comments : array()); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | |
@@ -219,19 +219,19 @@ discard block |
||
219 | 219 | * |
220 | 220 | * @return string |
221 | 221 | */ |
222 | -function give_get_donor_donation_comment_html( $comment, $payment_id = 0 ) { |
|
222 | +function give_get_donor_donation_comment_html($comment, $payment_id = 0) { |
|
223 | 223 | |
224 | - if ( is_numeric( $comment ) ) { |
|
225 | - $comment = get_comment( $comment ); |
|
224 | + if (is_numeric($comment)) { |
|
225 | + $comment = get_comment($comment); |
|
226 | 226 | } |
227 | 227 | |
228 | - $date_format = give_date_format() . ', ' . get_option( 'time_format' ); |
|
228 | + $date_format = give_date_format().', '.get_option('time_format'); |
|
229 | 229 | |
230 | 230 | $comment_html = sprintf( |
231 | 231 | '<div class="give-payment-note" id="give-payment-note-%s"><p><strong>%s</strong> – <span style="color:#aaa;font-style:italic;">%s</span><br/>%s</p></div>', |
232 | 232 | $comment->comment_ID, |
233 | - get_comment_author( $comment->comment_ID ), |
|
234 | - date_i18n( $date_format, strtotime( $comment->comment_date ) ), |
|
233 | + get_comment_author($comment->comment_ID), |
|
234 | + date_i18n($date_format, strtotime($comment->comment_date)), |
|
235 | 235 | $comment->comment_content |
236 | 236 | ); |
237 | 237 | |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * |
251 | 251 | * @return WP_Comment/array |
252 | 252 | */ |
253 | -function give_get_donor_latest_comment( $donor_id, $form_id = 0 ) { |
|
253 | +function give_get_donor_latest_comment($donor_id, $form_id = 0) { |
|
254 | 254 | $comment_args = array( |
255 | 255 | 'post_id' => 0, |
256 | 256 | 'orderby' => 'comment_ID', |
@@ -270,11 +270,11 @@ discard block |
||
270 | 270 | ); |
271 | 271 | |
272 | 272 | // Get donor donation comment for specific form. |
273 | - if ( $form_id ) { |
|
273 | + if ($form_id) { |
|
274 | 274 | $comment_args['parent'] = $form_id; |
275 | 275 | } |
276 | 276 | |
277 | - $comment = current( give_get_donor_donation_comments( $donor_id, $comment_args ) ); |
|
277 | + $comment = current(give_get_donor_donation_comments($donor_id, $comment_args)); |
|
278 | 278 | |
279 | 279 | return $comment; |
280 | 280 | } |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | * |
406 | 406 | * @param int|bool $payment_id A given payment. |
407 | 407 | * |
408 | - * @return mixed void|false |
|
408 | + * @return false|null void|false |
|
409 | 409 | */ |
410 | 410 | public function __construct( $payment_id = false ) { |
411 | 411 | |
@@ -1174,7 +1174,7 @@ discard block |
||
1174 | 1174 | * |
1175 | 1175 | * @param string|bool $note The note to add. |
1176 | 1176 | * |
1177 | - * @return bool If the note was specified or not |
|
1177 | + * @return false|null If the note was specified or not |
|
1178 | 1178 | */ |
1179 | 1179 | public function add_note( $note = false ) { |
1180 | 1180 | // Bail if no note specified. |
@@ -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 | |
@@ -407,13 +407,13 @@ discard block |
||
407 | 407 | * |
408 | 408 | * @return mixed void|false |
409 | 409 | */ |
410 | - public function __construct( $payment_id = false ) { |
|
410 | + public function __construct($payment_id = false) { |
|
411 | 411 | |
412 | - if ( empty( $payment_id ) ) { |
|
412 | + if (empty($payment_id)) { |
|
413 | 413 | return false; |
414 | 414 | } |
415 | 415 | |
416 | - $this->setup_payment( $payment_id ); |
|
416 | + $this->setup_payment($payment_id); |
|
417 | 417 | } |
418 | 418 | |
419 | 419 | /** |
@@ -426,11 +426,11 @@ discard block |
||
426 | 426 | * |
427 | 427 | * @return mixed The value. |
428 | 428 | */ |
429 | - public function __get( $key ) { |
|
429 | + public function __get($key) { |
|
430 | 430 | |
431 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
431 | + if (method_exists($this, 'get_'.$key)) { |
|
432 | 432 | |
433 | - $value = call_user_func( array( $this, 'get_' . $key ) ); |
|
433 | + $value = call_user_func(array($this, 'get_'.$key)); |
|
434 | 434 | |
435 | 435 | } else { |
436 | 436 | |
@@ -452,18 +452,18 @@ discard block |
||
452 | 452 | * @param string $key The property name. |
453 | 453 | * @param mixed $value The value of the property. |
454 | 454 | */ |
455 | - public function __set( $key, $value ) { |
|
456 | - $ignore = array( '_ID' ); |
|
455 | + public function __set($key, $value) { |
|
456 | + $ignore = array('_ID'); |
|
457 | 457 | |
458 | - if ( 'status' === $key ) { |
|
458 | + if ('status' === $key) { |
|
459 | 459 | $this->old_status = $this->status; |
460 | 460 | } |
461 | 461 | |
462 | - if ( ! in_array( $key, $ignore ) ) { |
|
463 | - $this->pending[ $key ] = $value; |
|
462 | + if ( ! in_array($key, $ignore)) { |
|
463 | + $this->pending[$key] = $value; |
|
464 | 464 | } |
465 | 465 | |
466 | - if ( '_ID' !== $key ) { |
|
466 | + if ('_ID' !== $key) { |
|
467 | 467 | $this->$key = $value; |
468 | 468 | } |
469 | 469 | } |
@@ -478,9 +478,9 @@ discard block |
||
478 | 478 | * |
479 | 479 | * @return boolean|null If the item is set or not |
480 | 480 | */ |
481 | - public function __isset( $name ) { |
|
482 | - if ( property_exists( $this, $name ) ) { |
|
483 | - return false === empty( $this->$name ); |
|
481 | + public function __isset($name) { |
|
482 | + if (property_exists($this, $name)) { |
|
483 | + return false === empty($this->$name); |
|
484 | 484 | } else { |
485 | 485 | return null; |
486 | 486 | } |
@@ -496,20 +496,20 @@ discard block |
||
496 | 496 | * |
497 | 497 | * @return bool If the setup was successful or not |
498 | 498 | */ |
499 | - private function setup_payment( $payment_id ) { |
|
499 | + private function setup_payment($payment_id) { |
|
500 | 500 | $this->pending = array(); |
501 | 501 | |
502 | - if ( empty( $payment_id ) ) { |
|
502 | + if (empty($payment_id)) { |
|
503 | 503 | return false; |
504 | 504 | } |
505 | 505 | |
506 | - $payment = get_post( absint( $payment_id ) ); |
|
506 | + $payment = get_post(absint($payment_id)); |
|
507 | 507 | |
508 | - if ( ! $payment || is_wp_error( $payment ) ) { |
|
508 | + if ( ! $payment || is_wp_error($payment)) { |
|
509 | 509 | return false; |
510 | 510 | } |
511 | 511 | |
512 | - if ( 'give_payment' !== $payment->post_type ) { |
|
512 | + if ('give_payment' !== $payment->post_type) { |
|
513 | 513 | return false; |
514 | 514 | } |
515 | 515 | |
@@ -523,17 +523,17 @@ discard block |
||
523 | 523 | * @param Give_Payment $this Payment object. |
524 | 524 | * @param int $payment_id The ID of the payment. |
525 | 525 | */ |
526 | - do_action( 'give_pre_setup_payment', $this, $payment_id ); |
|
526 | + do_action('give_pre_setup_payment', $this, $payment_id); |
|
527 | 527 | |
528 | 528 | // Get payment from cache. |
529 | - $donation_vars = Give_Cache::get_group( $payment_id, 'give-donations' ); |
|
529 | + $donation_vars = Give_Cache::get_group($payment_id, 'give-donations'); |
|
530 | 530 | |
531 | - if ( is_null( $donation_vars ) ) { |
|
531 | + if (is_null($donation_vars)) { |
|
532 | 532 | // Primary Identifier. |
533 | - $this->ID = absint( $payment_id ); |
|
533 | + $this->ID = absint($payment_id); |
|
534 | 534 | |
535 | 535 | // Protected ID that can never be changed. |
536 | - $this->_ID = absint( $payment_id ); |
|
536 | + $this->_ID = absint($payment_id); |
|
537 | 537 | |
538 | 538 | // We have a payment, get the generic payment_meta item to reduce calls to it. |
539 | 539 | $this->payment_meta = $this->get_meta(); |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | $this->parent_payment = $payment->post_parent; |
550 | 550 | |
551 | 551 | $all_payment_statuses = give_get_payment_statuses(); |
552 | - $this->status_nicename = array_key_exists( $this->status, $all_payment_statuses ) ? $all_payment_statuses[ $this->status ] : ucfirst( $this->status ); |
|
552 | + $this->status_nicename = array_key_exists($this->status, $all_payment_statuses) ? $all_payment_statuses[$this->status] : ucfirst($this->status); |
|
553 | 553 | |
554 | 554 | // Currency Based. |
555 | 555 | $this->total = $this->setup_total(); |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | $this->address = $this->setup_address(); |
571 | 571 | $this->first_name = $this->user_info['first_name']; |
572 | 572 | $this->last_name = $this->user_info['last_name']; |
573 | - $this->title_prefix = isset( $this->user_info['title'] ) ? $this->user_info['title'] : ''; |
|
573 | + $this->title_prefix = isset($this->user_info['title']) ? $this->user_info['title'] : ''; |
|
574 | 574 | |
575 | 575 | // Other Identifiers. |
576 | 576 | $this->form_title = $this->setup_form_title(); |
@@ -579,10 +579,10 @@ discard block |
||
579 | 579 | $this->key = $this->setup_payment_key(); |
580 | 580 | $this->number = $this->setup_payment_number(); |
581 | 581 | |
582 | - Give_Cache::set_group( $this->ID, get_object_vars( $this ), 'give-donations' ); |
|
582 | + Give_Cache::set_group($this->ID, get_object_vars($this), 'give-donations'); |
|
583 | 583 | } else { |
584 | 584 | |
585 | - foreach ( $donation_vars as $donation_var => $value ) { |
|
585 | + foreach ($donation_vars as $donation_var => $value) { |
|
586 | 586 | $this->$donation_var = $value; |
587 | 587 | } |
588 | 588 | } // End if(). |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | * @param Give_Payment $this Payment object. |
598 | 598 | * @param int $payment_id The ID of the payment. |
599 | 599 | */ |
600 | - do_action( 'give_setup_payment', $this, $payment_id ); |
|
600 | + do_action('give_setup_payment', $this, $payment_id); |
|
601 | 601 | |
602 | 602 | return true; |
603 | 603 | } |
@@ -616,11 +616,11 @@ discard block |
||
616 | 616 | * |
617 | 617 | * @return void |
618 | 618 | */ |
619 | - public function update_payment_setup( $payment_id ) { |
|
619 | + public function update_payment_setup($payment_id) { |
|
620 | 620 | // Delete cache. |
621 | - Give_Cache::delete_group( $this->ID,'give-donations' ); |
|
621 | + Give_Cache::delete_group($this->ID, 'give-donations'); |
|
622 | 622 | |
623 | - $this->setup_payment( $payment_id ); |
|
623 | + $this->setup_payment($payment_id); |
|
624 | 624 | } |
625 | 625 | |
626 | 626 | /** |
@@ -635,24 +635,24 @@ discard block |
||
635 | 635 | |
636 | 636 | // Construct the payment title. |
637 | 637 | $payment_title = ''; |
638 | - if ( ! empty( $this->first_name ) && ! empty( $this->last_name ) ) { |
|
639 | - $payment_title = $this->first_name . ' ' . $this->last_name; |
|
640 | - } elseif ( ! empty( $this->first_name ) && empty( $this->last_name ) ) { |
|
638 | + if ( ! empty($this->first_name) && ! empty($this->last_name)) { |
|
639 | + $payment_title = $this->first_name.' '.$this->last_name; |
|
640 | + } elseif ( ! empty($this->first_name) && empty($this->last_name)) { |
|
641 | 641 | $payment_title = $this->first_name; |
642 | - } elseif ( ! empty( $this->email ) && is_email( $this->email ) ) { |
|
642 | + } elseif ( ! empty($this->email) && is_email($this->email)) { |
|
643 | 643 | $payment_title = $this->email; |
644 | 644 | } |
645 | 645 | |
646 | 646 | // Set Key. |
647 | - if ( empty( $this->key ) ) { |
|
647 | + if (empty($this->key)) { |
|
648 | 648 | |
649 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
650 | - $this->key = strtolower( md5( $this->email . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) ); // Unique key. |
|
649 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
650 | + $this->key = strtolower(md5($this->email.date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); // Unique key. |
|
651 | 651 | $this->pending['key'] = $this->key; |
652 | 652 | } |
653 | 653 | |
654 | 654 | // Set IP. |
655 | - if ( empty( $this->ip ) ) { |
|
655 | + if (empty($this->ip)) { |
|
656 | 656 | |
657 | 657 | $this->ip = give_get_ip(); |
658 | 658 | $this->pending['ip'] = $this->ip; |
@@ -682,19 +682,19 @@ discard block |
||
682 | 682 | 'status' => $this->status, |
683 | 683 | ); |
684 | 684 | |
685 | - $args = apply_filters( 'give_insert_payment_args', array( |
|
685 | + $args = apply_filters('give_insert_payment_args', array( |
|
686 | 686 | 'post_title' => $payment_title, |
687 | 687 | 'post_status' => $this->status, |
688 | 688 | 'post_type' => 'give_payment', |
689 | - 'post_date' => ! empty( $this->date ) ? $this->date : null, |
|
690 | - 'post_date_gmt' => ! empty( $this->date ) ? get_gmt_from_date( $this->date ) : null, |
|
689 | + 'post_date' => ! empty($this->date) ? $this->date : null, |
|
690 | + 'post_date_gmt' => ! empty($this->date) ? get_gmt_from_date($this->date) : null, |
|
691 | 691 | 'post_parent' => $this->parent_payment, |
692 | - ), $payment_data ); |
|
692 | + ), $payment_data); |
|
693 | 693 | |
694 | 694 | // Create a blank payment. |
695 | - $payment_id = wp_insert_post( $args ); |
|
695 | + $payment_id = wp_insert_post($args); |
|
696 | 696 | |
697 | - if ( ! empty( $payment_id ) ) { |
|
697 | + if ( ! empty($payment_id)) { |
|
698 | 698 | |
699 | 699 | $this->ID = $payment_id; |
700 | 700 | $this->_ID = $payment_id; |
@@ -706,43 +706,43 @@ discard block |
||
706 | 706 | * |
707 | 707 | * @since 1.8.13 |
708 | 708 | */ |
709 | - $donor = apply_filters( 'give_update_donor_information', $donor, $payment_id, $payment_data, $args ); |
|
709 | + $donor = apply_filters('give_update_donor_information', $donor, $payment_id, $payment_data, $args); |
|
710 | 710 | |
711 | - if ( did_action( 'give_pre_process_donation' ) && is_user_logged_in() ) { |
|
712 | - $donor = new Give_Donor( get_current_user_id(), true ); |
|
711 | + if (did_action('give_pre_process_donation') && is_user_logged_in()) { |
|
712 | + $donor = new Give_Donor(get_current_user_id(), true); |
|
713 | 713 | |
714 | 714 | // Donor is logged in but used a different email to purchase with so assign to their donor record. |
715 | - if ( ! empty( $donor->id ) && $this->email !== $donor->email ) { |
|
716 | - $donor->add_email( $this->email ); |
|
715 | + if ( ! empty($donor->id) && $this->email !== $donor->email) { |
|
716 | + $donor->add_email($this->email); |
|
717 | 717 | } |
718 | 718 | } |
719 | 719 | |
720 | - if ( empty( $donor->id ) ) { |
|
721 | - $donor = new Give_Donor( $this->email ); |
|
720 | + if (empty($donor->id)) { |
|
721 | + $donor = new Give_Donor($this->email); |
|
722 | 722 | } |
723 | 723 | |
724 | - if ( empty( $donor->id ) ) { |
|
724 | + if (empty($donor->id)) { |
|
725 | 725 | |
726 | 726 | $donor_data = array( |
727 | - 'name' => ! is_email( $payment_title ) ? $this->first_name . ' ' . $this->last_name : '', |
|
727 | + 'name' => ! is_email($payment_title) ? $this->first_name.' '.$this->last_name : '', |
|
728 | 728 | 'email' => $this->email, |
729 | 729 | 'user_id' => $this->user_id, |
730 | 730 | ); |
731 | 731 | |
732 | - $donor->create( $donor_data ); |
|
732 | + $donor->create($donor_data); |
|
733 | 733 | |
734 | 734 | } |
735 | 735 | |
736 | 736 | // Update Donor Meta once donor is created. |
737 | - $donor->update_meta( '_give_donor_first_name', $this->first_name ); |
|
738 | - $donor->update_meta( '_give_donor_last_name', $this->last_name ); |
|
739 | - $donor->update_meta( '_give_donor_title_prefix', $this->title_prefix ); |
|
737 | + $donor->update_meta('_give_donor_first_name', $this->first_name); |
|
738 | + $donor->update_meta('_give_donor_last_name', $this->last_name); |
|
739 | + $donor->update_meta('_give_donor_title_prefix', $this->title_prefix); |
|
740 | 740 | |
741 | 741 | $this->customer_id = $donor->id; |
742 | 742 | $this->pending['customer_id'] = $this->customer_id; |
743 | - $donor->attach_payment( $this->ID, false ); |
|
743 | + $donor->attach_payment($this->ID, false); |
|
744 | 744 | |
745 | - $this->payment_meta = apply_filters( 'give_payment_meta', $this->payment_meta, $payment_data ); |
|
745 | + $this->payment_meta = apply_filters('give_payment_meta', $this->payment_meta, $payment_data); |
|
746 | 746 | |
747 | 747 | /* |
748 | 748 | * _give_payment_meta backward compatibility. |
@@ -750,25 +750,25 @@ discard block |
||
750 | 750 | * @since 2.0.1 |
751 | 751 | */ |
752 | 752 | $custom_payment_meta = array_diff( |
753 | - array_map( 'maybe_serialize', $this->payment_meta ), |
|
754 | - array_map( 'maybe_serialize', $payment_data ) |
|
753 | + array_map('maybe_serialize', $this->payment_meta), |
|
754 | + array_map('maybe_serialize', $payment_data) |
|
755 | 755 | ); |
756 | 756 | |
757 | - if ( ! empty( $custom_payment_meta ) ) { |
|
758 | - give_doing_it_wrong( '_give_payment_meta', __( 'This custom meta key deprecated. We are not using this meta key for storing payment meta but your custom meta data will be store because we added backward compatibility. Please change your logic because in future we can remove it.', 'give' ), '2.0.0' ); |
|
757 | + if ( ! empty($custom_payment_meta)) { |
|
758 | + give_doing_it_wrong('_give_payment_meta', __('This custom meta key deprecated. We are not using this meta key for storing payment meta but your custom meta data will be store because we added backward compatibility. Please change your logic because in future we can remove it.', 'give'), '2.0.0'); |
|
759 | 759 | |
760 | - $this->update_meta( '_give_payment_meta', array_map( 'maybe_unserialize', $custom_payment_meta ) ); |
|
760 | + $this->update_meta('_give_payment_meta', array_map('maybe_unserialize', $custom_payment_meta)); |
|
761 | 761 | } |
762 | 762 | |
763 | - $give_company = ( ! empty( $_REQUEST['give_company_name'] ) ? give_clean( $_REQUEST['give_company_name'] ) : '' ); |
|
763 | + $give_company = ( ! empty($_REQUEST['give_company_name']) ? give_clean($_REQUEST['give_company_name']) : ''); |
|
764 | 764 | |
765 | 765 | // Check $page_url is not empty. |
766 | - if ( $give_company ) { |
|
767 | - give_update_meta( $payment_id, '_give_donation_company', $give_company ); |
|
766 | + if ($give_company) { |
|
767 | + give_update_meta($payment_id, '_give_donation_company', $give_company); |
|
768 | 768 | |
769 | - $donor_id = absint( $donor->id ); |
|
770 | - if ( ! empty( $donor_id ) ) { |
|
771 | - Give()->donor_meta->update_meta( $donor_id, '_give_donor_company', $give_company ); |
|
769 | + $donor_id = absint($donor->id); |
|
770 | + if ( ! empty($donor_id)) { |
|
771 | + Give()->donor_meta->update_meta($donor_id, '_give_donor_company', $give_company); |
|
772 | 772 | } |
773 | 773 | } |
774 | 774 | |
@@ -792,11 +792,11 @@ discard block |
||
792 | 792 | $saved = false; |
793 | 793 | |
794 | 794 | // Must have an ID. |
795 | - if ( empty( $this->ID ) ) { |
|
795 | + if (empty($this->ID)) { |
|
796 | 796 | |
797 | 797 | $payment_id = $this->insert_payment(); |
798 | 798 | |
799 | - if ( false === $payment_id ) { |
|
799 | + if (false === $payment_id) { |
|
800 | 800 | $saved = false; |
801 | 801 | } else { |
802 | 802 | $this->ID = $payment_id; |
@@ -804,42 +804,42 @@ discard block |
||
804 | 804 | } |
805 | 805 | |
806 | 806 | // Set ID if not matching. |
807 | - if ( $this->ID !== $this->_ID ) { |
|
807 | + if ($this->ID !== $this->_ID) { |
|
808 | 808 | $this->ID = $this->_ID; |
809 | 809 | } |
810 | 810 | |
811 | 811 | // If we have something pending, let's save it. |
812 | - if ( ! empty( $this->pending ) ) { |
|
812 | + if ( ! empty($this->pending)) { |
|
813 | 813 | |
814 | 814 | $total_increase = 0; |
815 | 815 | $total_decrease = 0; |
816 | 816 | |
817 | - foreach ( $this->pending as $key => $value ) { |
|
817 | + foreach ($this->pending as $key => $value) { |
|
818 | 818 | |
819 | - switch ( $key ) { |
|
819 | + switch ($key) { |
|
820 | 820 | |
821 | 821 | case 'donations': |
822 | 822 | // Update totals for pending donations. |
823 | - foreach ( $this->pending[ $key ] as $item ) { |
|
823 | + foreach ($this->pending[$key] as $item) { |
|
824 | 824 | |
825 | - $quantity = isset( $item['quantity'] ) ? $item['quantity'] : 1; |
|
826 | - $price_id = isset( $item['price_id'] ) ? $item['price_id'] : 0; |
|
825 | + $quantity = isset($item['quantity']) ? $item['quantity'] : 1; |
|
826 | + $price_id = isset($item['price_id']) ? $item['price_id'] : 0; |
|
827 | 827 | |
828 | - switch ( $item['action'] ) { |
|
828 | + switch ($item['action']) { |
|
829 | 829 | |
830 | 830 | case 'add': |
831 | 831 | |
832 | 832 | $price = $item['price']; |
833 | 833 | |
834 | - if ( 'publish' === $this->status || 'complete' === $this->status ) { |
|
834 | + if ('publish' === $this->status || 'complete' === $this->status) { |
|
835 | 835 | |
836 | 836 | // Add donation to logs. |
837 | - $log_date = date_i18n( 'Y-m-d G:i:s', current_time( 'timestamp' ) ); |
|
838 | - give_record_donation_in_log( $item['id'], $this->ID, $price_id, $log_date ); |
|
837 | + $log_date = date_i18n('Y-m-d G:i:s', current_time('timestamp')); |
|
838 | + give_record_donation_in_log($item['id'], $this->ID, $price_id, $log_date); |
|
839 | 839 | |
840 | - $form = new Give_Donate_Form( $item['id'] ); |
|
841 | - $form->increase_sales( $quantity ); |
|
842 | - $form->increase_earnings( $price, $this->ID ); |
|
840 | + $form = new Give_Donate_Form($item['id']); |
|
841 | + $form->increase_sales($quantity); |
|
842 | + $form->increase_earnings($price, $this->ID); |
|
843 | 843 | |
844 | 844 | $total_increase += $price; |
845 | 845 | } |
@@ -847,10 +847,10 @@ discard block |
||
847 | 847 | |
848 | 848 | case 'remove': |
849 | 849 | $this->delete_sales_logs(); |
850 | - if ( 'publish' === $this->status || 'complete' === $this->status ) { |
|
851 | - $form = new Give_Donate_Form( $item['id'] ); |
|
852 | - $form->decrease_sales( $quantity ); |
|
853 | - $form->decrease_earnings( $item['amount'], $this->ID ); |
|
850 | + if ('publish' === $this->status || 'complete' === $this->status) { |
|
851 | + $form = new Give_Donate_Form($item['id']); |
|
852 | + $form->decrease_sales($quantity); |
|
853 | + $form->decrease_earnings($item['amount'], $this->ID); |
|
854 | 854 | |
855 | 855 | $total_decrease += $item['amount']; |
856 | 856 | } |
@@ -861,89 +861,89 @@ discard block |
||
861 | 861 | break; |
862 | 862 | |
863 | 863 | case 'status': |
864 | - $this->update_status( $this->status ); |
|
864 | + $this->update_status($this->status); |
|
865 | 865 | break; |
866 | 866 | |
867 | 867 | case 'gateway': |
868 | - $this->update_meta( '_give_payment_gateway', $this->gateway ); |
|
868 | + $this->update_meta('_give_payment_gateway', $this->gateway); |
|
869 | 869 | break; |
870 | 870 | |
871 | 871 | case 'mode': |
872 | - $this->update_meta( '_give_payment_mode', $this->mode ); |
|
872 | + $this->update_meta('_give_payment_mode', $this->mode); |
|
873 | 873 | break; |
874 | 874 | |
875 | 875 | case 'transaction_id': |
876 | - $this->update_meta( '_give_payment_transaction_id', $this->transaction_id ); |
|
876 | + $this->update_meta('_give_payment_transaction_id', $this->transaction_id); |
|
877 | 877 | break; |
878 | 878 | |
879 | 879 | case 'ip': |
880 | - $this->update_meta( '_give_payment_donor_ip', $this->ip ); |
|
880 | + $this->update_meta('_give_payment_donor_ip', $this->ip); |
|
881 | 881 | break; |
882 | 882 | |
883 | 883 | case 'customer_id': |
884 | - $this->update_meta( '_give_payment_donor_id', $this->customer_id ); |
|
884 | + $this->update_meta('_give_payment_donor_id', $this->customer_id); |
|
885 | 885 | break; |
886 | 886 | |
887 | 887 | case 'form_title': |
888 | - $this->update_meta( '_give_payment_form_title', $this->form_title ); |
|
888 | + $this->update_meta('_give_payment_form_title', $this->form_title); |
|
889 | 889 | break; |
890 | 890 | |
891 | 891 | case 'form_id': |
892 | - $this->update_meta( '_give_payment_form_id', $this->form_id ); |
|
892 | + $this->update_meta('_give_payment_form_id', $this->form_id); |
|
893 | 893 | break; |
894 | 894 | |
895 | 895 | case 'price_id': |
896 | - $this->update_meta( '_give_payment_price_id', $this->price_id ); |
|
896 | + $this->update_meta('_give_payment_price_id', $this->price_id); |
|
897 | 897 | break; |
898 | 898 | |
899 | 899 | case 'first_name': |
900 | - $this->update_meta( '_give_donor_billing_first_name', $this->first_name ); |
|
900 | + $this->update_meta('_give_donor_billing_first_name', $this->first_name); |
|
901 | 901 | break; |
902 | 902 | |
903 | 903 | case 'last_name': |
904 | - $this->update_meta( '_give_donor_billing_last_name', $this->last_name ); |
|
904 | + $this->update_meta('_give_donor_billing_last_name', $this->last_name); |
|
905 | 905 | break; |
906 | 906 | |
907 | 907 | case 'currency': |
908 | - $this->update_meta( '_give_payment_currency', $this->currency ); |
|
908 | + $this->update_meta('_give_payment_currency', $this->currency); |
|
909 | 909 | break; |
910 | 910 | |
911 | 911 | case 'address': |
912 | - if ( ! empty( $this->address ) ) { |
|
913 | - foreach ( $this->address as $address_name => $address ) { |
|
914 | - switch ( $address_name ) { |
|
912 | + if ( ! empty($this->address)) { |
|
913 | + foreach ($this->address as $address_name => $address) { |
|
914 | + switch ($address_name) { |
|
915 | 915 | case 'line1': |
916 | - $this->update_meta( '_give_donor_billing_address1', $address ); |
|
916 | + $this->update_meta('_give_donor_billing_address1', $address); |
|
917 | 917 | break; |
918 | 918 | |
919 | 919 | case 'line2': |
920 | - $this->update_meta( '_give_donor_billing_address2', $address ); |
|
920 | + $this->update_meta('_give_donor_billing_address2', $address); |
|
921 | 921 | break; |
922 | 922 | |
923 | 923 | default: |
924 | - $this->update_meta( "_give_donor_billing_{$address_name}", $address ); |
|
924 | + $this->update_meta("_give_donor_billing_{$address_name}", $address); |
|
925 | 925 | } |
926 | 926 | } |
927 | 927 | } |
928 | 928 | break; |
929 | 929 | |
930 | 930 | case 'email': |
931 | - $this->update_meta( '_give_payment_donor_email', $this->email ); |
|
931 | + $this->update_meta('_give_payment_donor_email', $this->email); |
|
932 | 932 | break; |
933 | 933 | |
934 | 934 | case 'title_prefix': |
935 | - $this->update_meta( '_give_payment_donor_title_prefix', $this->title_prefix ); |
|
935 | + $this->update_meta('_give_payment_donor_title_prefix', $this->title_prefix); |
|
936 | 936 | break; |
937 | 937 | |
938 | 938 | case 'key': |
939 | - $this->update_meta( '_give_payment_purchase_key', $this->key ); |
|
939 | + $this->update_meta('_give_payment_purchase_key', $this->key); |
|
940 | 940 | break; |
941 | 941 | |
942 | 942 | case 'number': |
943 | 943 | // @todo: remove unused meta data. |
944 | 944 | // Core is using post_title to store donation serial code ( fi enabled ) instead this meta key. |
945 | 945 | // Do not use this meta key in your logic, can be remove in future |
946 | - $this->update_meta( '_give_payment_number', $this->number ); |
|
946 | + $this->update_meta('_give_payment_number', $this->number); |
|
947 | 947 | break; |
948 | 948 | |
949 | 949 | case 'date': |
@@ -953,11 +953,11 @@ discard block |
||
953 | 953 | 'edit_date' => true, |
954 | 954 | ); |
955 | 955 | |
956 | - wp_update_post( $args ); |
|
956 | + wp_update_post($args); |
|
957 | 957 | break; |
958 | 958 | |
959 | 959 | case 'completed_date': |
960 | - $this->update_meta( '_give_completed_date', $this->completed_date ); |
|
960 | + $this->update_meta('_give_completed_date', $this->completed_date); |
|
961 | 961 | break; |
962 | 962 | |
963 | 963 | case 'parent_payment': |
@@ -966,11 +966,11 @@ discard block |
||
966 | 966 | 'post_parent' => $this->parent_payment, |
967 | 967 | ); |
968 | 968 | |
969 | - wp_update_post( $args ); |
|
969 | + wp_update_post($args); |
|
970 | 970 | break; |
971 | 971 | |
972 | 972 | case 'total': |
973 | - $this->update_meta( '_give_payment_total', give_sanitize_amount_for_db( $this->total ) ); |
|
973 | + $this->update_meta('_give_payment_total', give_sanitize_amount_for_db($this->total)); |
|
974 | 974 | break; |
975 | 975 | |
976 | 976 | default: |
@@ -981,46 +981,46 @@ discard block |
||
981 | 981 | * |
982 | 982 | * @param Give_Payment $this Payment object. |
983 | 983 | */ |
984 | - do_action( 'give_payment_save', $this, $key ); |
|
984 | + do_action('give_payment_save', $this, $key); |
|
985 | 985 | break; |
986 | 986 | } // End switch(). |
987 | 987 | } // End foreach(). |
988 | 988 | |
989 | - if ( 'pending' !== $this->status ) { |
|
989 | + if ('pending' !== $this->status) { |
|
990 | 990 | |
991 | - $donor = new Give_Donor( $this->customer_id ); |
|
991 | + $donor = new Give_Donor($this->customer_id); |
|
992 | 992 | |
993 | 993 | $total_change = $total_increase - $total_decrease; |
994 | - if ( $total_change < 0 ) { |
|
994 | + if ($total_change < 0) { |
|
995 | 995 | |
996 | - $total_change = - ( $total_change ); |
|
996 | + $total_change = - ($total_change); |
|
997 | 997 | |
998 | 998 | // Decrease the donor's donation stats. |
999 | - $donor->decrease_value( $total_change ); |
|
1000 | - give_decrease_total_earnings( $total_change ); |
|
999 | + $donor->decrease_value($total_change); |
|
1000 | + give_decrease_total_earnings($total_change); |
|
1001 | 1001 | |
1002 | 1002 | $donor->decrease_donation_count(); |
1003 | 1003 | |
1004 | - } elseif ( $total_change > 0 ) { |
|
1004 | + } elseif ($total_change > 0) { |
|
1005 | 1005 | |
1006 | 1006 | // Increase the donor's donation stats. |
1007 | - $donor->increase_value( $total_change ); |
|
1008 | - give_increase_total_earnings( $total_change ); |
|
1007 | + $donor->increase_value($total_change); |
|
1008 | + give_increase_total_earnings($total_change); |
|
1009 | 1009 | |
1010 | 1010 | $donor->increase_purchase_count(); |
1011 | 1011 | |
1012 | 1012 | } |
1013 | 1013 | |
1014 | 1014 | // Verify and update form meta based on the form status. |
1015 | - give_set_form_closed_status( $this->form_id ); |
|
1015 | + give_set_form_closed_status($this->form_id); |
|
1016 | 1016 | } |
1017 | 1017 | |
1018 | 1018 | $this->pending = array(); |
1019 | 1019 | $saved = true; |
1020 | 1020 | } // End if(). |
1021 | 1021 | |
1022 | - if ( true === $saved ) { |
|
1023 | - $this->setup_payment( $this->ID ); |
|
1022 | + if (true === $saved) { |
|
1023 | + $this->setup_payment($this->ID); |
|
1024 | 1024 | } |
1025 | 1025 | |
1026 | 1026 | return $saved; |
@@ -1038,12 +1038,12 @@ discard block |
||
1038 | 1038 | * |
1039 | 1039 | * @return bool True when successful, false otherwise |
1040 | 1040 | */ |
1041 | - public function add_donation( $form_id = 0, $args = array(), $options = array() ) { |
|
1041 | + public function add_donation($form_id = 0, $args = array(), $options = array()) { |
|
1042 | 1042 | |
1043 | - $donation = new Give_Donate_Form( $form_id ); |
|
1043 | + $donation = new Give_Donate_Form($form_id); |
|
1044 | 1044 | |
1045 | 1045 | // Bail if this post isn't a give donation form. |
1046 | - if ( ! $donation || 'give_forms' !== $donation->post_type ) { |
|
1046 | + if ( ! $donation || 'give_forms' !== $donation->post_type) { |
|
1047 | 1047 | return false; |
1048 | 1048 | } |
1049 | 1049 | |
@@ -1053,25 +1053,25 @@ discard block |
||
1053 | 1053 | 'price_id' => false, |
1054 | 1054 | ); |
1055 | 1055 | |
1056 | - $args = wp_parse_args( apply_filters( 'give_payment_add_donation_args', $args, $donation->ID ), $defaults ); |
|
1056 | + $args = wp_parse_args(apply_filters('give_payment_add_donation_args', $args, $donation->ID), $defaults); |
|
1057 | 1057 | |
1058 | 1058 | // Allow overriding the price. |
1059 | - if ( false !== $args['price'] ) { |
|
1059 | + if (false !== $args['price']) { |
|
1060 | 1060 | $donation_amount = $args['price']; |
1061 | 1061 | } else { |
1062 | 1062 | |
1063 | 1063 | // Deal with variable pricing. |
1064 | - if ( give_has_variable_prices( $donation->ID ) ) { |
|
1065 | - $prices = give_get_meta( $form_id, '_give_donation_levels', true ); |
|
1064 | + if (give_has_variable_prices($donation->ID)) { |
|
1065 | + $prices = give_get_meta($form_id, '_give_donation_levels', true); |
|
1066 | 1066 | $donation_amount = ''; |
1067 | 1067 | |
1068 | 1068 | // Loop through prices. |
1069 | - foreach ( $prices as $price ) { |
|
1069 | + foreach ($prices as $price) { |
|
1070 | 1070 | // Find a match between price_id and level_id. |
1071 | 1071 | // First verify array keys exists THEN make the match. |
1072 | 1072 | if ( |
1073 | - isset( $args['price_id'] ) && |
|
1074 | - isset( $price['_give_id']['level_id'] ) && |
|
1073 | + isset($args['price_id']) && |
|
1074 | + isset($price['_give_id']['level_id']) && |
|
1075 | 1075 | $args['price_id'] === (int) $price['_give_id']['level_id'] |
1076 | 1076 | ) { |
1077 | 1077 | $donation_amount = $price['_give_amount']; |
@@ -1079,37 +1079,37 @@ discard block |
||
1079 | 1079 | } |
1080 | 1080 | |
1081 | 1081 | // Fallback to the lowest price point. |
1082 | - if ( '' === $donation_amount ) { |
|
1083 | - $donation_amount = give_get_lowest_price_option( $donation->ID ); |
|
1084 | - $args['price_id'] = give_get_lowest_price_id( $donation->ID ); |
|
1082 | + if ('' === $donation_amount) { |
|
1083 | + $donation_amount = give_get_lowest_price_option($donation->ID); |
|
1084 | + $args['price_id'] = give_get_lowest_price_id($donation->ID); |
|
1085 | 1085 | } |
1086 | 1086 | } else { |
1087 | 1087 | // Simple form price. |
1088 | - $donation_amount = give_get_form_price( $donation->ID ); |
|
1088 | + $donation_amount = give_get_form_price($donation->ID); |
|
1089 | 1089 | } |
1090 | 1090 | } |
1091 | 1091 | |
1092 | 1092 | // Sanitizing the price here so we don't have a dozen calls later. |
1093 | - $donation_amount = give_maybe_sanitize_amount( $donation_amount ); |
|
1094 | - $total = round( $donation_amount, give_get_price_decimals( $this->ID ) ); |
|
1093 | + $donation_amount = give_maybe_sanitize_amount($donation_amount); |
|
1094 | + $total = round($donation_amount, give_get_price_decimals($this->ID)); |
|
1095 | 1095 | |
1096 | 1096 | // Add Options. |
1097 | 1097 | $default_options = array(); |
1098 | - if ( false !== $args['price_id'] ) { |
|
1098 | + if (false !== $args['price_id']) { |
|
1099 | 1099 | $default_options['price_id'] = (int) $args['price_id']; |
1100 | 1100 | } |
1101 | - $options = wp_parse_args( $options, $default_options ); |
|
1101 | + $options = wp_parse_args($options, $default_options); |
|
1102 | 1102 | |
1103 | 1103 | // Do not allow totals to go negative. |
1104 | - if ( $total < 0 ) { |
|
1104 | + if ($total < 0) { |
|
1105 | 1105 | $total = 0; |
1106 | 1106 | } |
1107 | 1107 | |
1108 | 1108 | $donation = array( |
1109 | 1109 | 'name' => $donation->post_title, |
1110 | 1110 | 'id' => $donation->ID, |
1111 | - 'price' => round( $total, give_get_price_decimals( $this->ID ) ), |
|
1112 | - 'subtotal' => round( $total, give_get_price_decimals( $this->ID ) ), |
|
1111 | + 'price' => round($total, give_get_price_decimals($this->ID)), |
|
1112 | + 'subtotal' => round($total, give_get_price_decimals($this->ID)), |
|
1113 | 1113 | 'price_id' => $args['price_id'], |
1114 | 1114 | 'action' => 'add', |
1115 | 1115 | 'options' => $options, |
@@ -1117,7 +1117,7 @@ discard block |
||
1117 | 1117 | |
1118 | 1118 | $this->pending['donations'][] = $donation; |
1119 | 1119 | |
1120 | - $this->increase_subtotal( $total ); |
|
1120 | + $this->increase_subtotal($total); |
|
1121 | 1121 | |
1122 | 1122 | return true; |
1123 | 1123 | |
@@ -1134,7 +1134,7 @@ discard block |
||
1134 | 1134 | * |
1135 | 1135 | * @return bool If the item was removed or not |
1136 | 1136 | */ |
1137 | - public function remove_donation( $form_id, $args = array() ) { |
|
1137 | + public function remove_donation($form_id, $args = array()) { |
|
1138 | 1138 | |
1139 | 1139 | // Set some defaults. |
1140 | 1140 | $defaults = array( |
@@ -1142,12 +1142,12 @@ discard block |
||
1142 | 1142 | 'price' => false, |
1143 | 1143 | 'price_id' => false, |
1144 | 1144 | ); |
1145 | - $args = wp_parse_args( $args, $defaults ); |
|
1145 | + $args = wp_parse_args($args, $defaults); |
|
1146 | 1146 | |
1147 | - $form = new Give_Donate_Form( $form_id ); |
|
1147 | + $form = new Give_Donate_Form($form_id); |
|
1148 | 1148 | |
1149 | 1149 | // Bail if this post isn't a valid give donation form. |
1150 | - if ( ! $form || 'give_forms' !== $form->post_type ) { |
|
1150 | + if ( ! $form || 'give_forms' !== $form->post_type) { |
|
1151 | 1151 | return false; |
1152 | 1152 | } |
1153 | 1153 | |
@@ -1160,7 +1160,7 @@ discard block |
||
1160 | 1160 | |
1161 | 1161 | $this->pending['donations'][] = $pending_args; |
1162 | 1162 | |
1163 | - $this->decrease_subtotal( $this->total ); |
|
1163 | + $this->decrease_subtotal($this->total); |
|
1164 | 1164 | |
1165 | 1165 | return true; |
1166 | 1166 | } |
@@ -1176,13 +1176,13 @@ discard block |
||
1176 | 1176 | * |
1177 | 1177 | * @return bool If the note was specified or not |
1178 | 1178 | */ |
1179 | - public function add_note( $note = false ) { |
|
1179 | + public function add_note($note = false) { |
|
1180 | 1180 | // Bail if no note specified. |
1181 | - if ( ! $note ) { |
|
1181 | + if ( ! $note) { |
|
1182 | 1182 | return false; |
1183 | 1183 | } |
1184 | 1184 | |
1185 | - give_insert_payment_note( $this->ID, $note ); |
|
1185 | + give_insert_payment_note($this->ID, $note); |
|
1186 | 1186 | } |
1187 | 1187 | |
1188 | 1188 | /** |
@@ -1195,8 +1195,8 @@ discard block |
||
1195 | 1195 | * |
1196 | 1196 | * @return void |
1197 | 1197 | */ |
1198 | - private function increase_subtotal( $amount = 0.00 ) { |
|
1199 | - $amount = (float) $amount; |
|
1198 | + private function increase_subtotal($amount = 0.00) { |
|
1199 | + $amount = (float) $amount; |
|
1200 | 1200 | $this->subtotal += $amount; |
1201 | 1201 | |
1202 | 1202 | $this->recalculate_total(); |
@@ -1212,11 +1212,11 @@ discard block |
||
1212 | 1212 | * |
1213 | 1213 | * @return void |
1214 | 1214 | */ |
1215 | - private function decrease_subtotal( $amount = 0.00 ) { |
|
1216 | - $amount = (float) $amount; |
|
1215 | + private function decrease_subtotal($amount = 0.00) { |
|
1216 | + $amount = (float) $amount; |
|
1217 | 1217 | $this->subtotal -= $amount; |
1218 | 1218 | |
1219 | - if ( $this->subtotal < 0 ) { |
|
1219 | + if ($this->subtotal < 0) { |
|
1220 | 1220 | $this->subtotal = 0; |
1221 | 1221 | } |
1222 | 1222 | |
@@ -1246,24 +1246,24 @@ discard block |
||
1246 | 1246 | * |
1247 | 1247 | * @return bool $updated Returns if the status was successfully updated. |
1248 | 1248 | */ |
1249 | - public function update_status( $status = false ) { |
|
1249 | + public function update_status($status = false) { |
|
1250 | 1250 | |
1251 | 1251 | // standardize the 'complete(d)' status. |
1252 | - if ( 'completed' === $status || 'complete' === $status ) { |
|
1252 | + if ('completed' === $status || 'complete' === $status) { |
|
1253 | 1253 | $status = 'publish'; |
1254 | 1254 | } |
1255 | 1255 | |
1256 | - $old_status = ! empty( $this->old_status ) ? $this->old_status : false; |
|
1256 | + $old_status = ! empty($this->old_status) ? $this->old_status : false; |
|
1257 | 1257 | |
1258 | - if ( $old_status === $status ) { |
|
1258 | + if ($old_status === $status) { |
|
1259 | 1259 | return false; // Don't permit status changes that aren't changes. |
1260 | 1260 | } |
1261 | 1261 | |
1262 | - $do_change = apply_filters( 'give_should_update_payment_status', true, $this->ID, $status, $old_status ); |
|
1262 | + $do_change = apply_filters('give_should_update_payment_status', true, $this->ID, $status, $old_status); |
|
1263 | 1263 | |
1264 | 1264 | $updated = false; |
1265 | 1265 | |
1266 | - if ( $do_change ) { |
|
1266 | + if ($do_change) { |
|
1267 | 1267 | |
1268 | 1268 | /** |
1269 | 1269 | * Fires before changing payment status. |
@@ -1274,21 +1274,21 @@ discard block |
||
1274 | 1274 | * @param string $status The new status. |
1275 | 1275 | * @param string $old_status The old status. |
1276 | 1276 | */ |
1277 | - do_action( 'give_before_payment_status_change', $this->ID, $status, $old_status ); |
|
1277 | + do_action('give_before_payment_status_change', $this->ID, $status, $old_status); |
|
1278 | 1278 | |
1279 | 1279 | $update_fields = array( |
1280 | 1280 | 'ID' => $this->ID, |
1281 | 1281 | 'post_status' => $status, |
1282 | - 'edit_date' => current_time( 'mysql' ), |
|
1282 | + 'edit_date' => current_time('mysql'), |
|
1283 | 1283 | ); |
1284 | 1284 | |
1285 | - $updated = wp_update_post( apply_filters( 'give_update_payment_status_fields', $update_fields ) ); |
|
1285 | + $updated = wp_update_post(apply_filters('give_update_payment_status_fields', $update_fields)); |
|
1286 | 1286 | |
1287 | 1287 | $all_payment_statuses = give_get_payment_statuses(); |
1288 | - $this->status_nicename = array_key_exists( $status, $all_payment_statuses ) ? $all_payment_statuses[ $status ] : ucfirst( $status ); |
|
1288 | + $this->status_nicename = array_key_exists($status, $all_payment_statuses) ? $all_payment_statuses[$status] : ucfirst($status); |
|
1289 | 1289 | |
1290 | 1290 | // Process any specific status functions. |
1291 | - $this->process_status( $status ); |
|
1291 | + $this->process_status($status); |
|
1292 | 1292 | |
1293 | 1293 | /** |
1294 | 1294 | * Fires after changing payment status. |
@@ -1299,7 +1299,7 @@ discard block |
||
1299 | 1299 | * @param string $status The new status. |
1300 | 1300 | * @param string $old_status The old status. |
1301 | 1301 | */ |
1302 | - do_action( 'give_update_payment_status', $this->ID, $status, $old_status ); |
|
1302 | + do_action('give_update_payment_status', $this->ID, $status, $old_status); |
|
1303 | 1303 | |
1304 | 1304 | } // End if(). |
1305 | 1305 | |
@@ -1334,27 +1334,27 @@ discard block |
||
1334 | 1334 | * |
1335 | 1335 | * @return mixed The value from the post meta |
1336 | 1336 | */ |
1337 | - public function get_meta( $meta_key = '_give_payment_meta', $single = true ) { |
|
1337 | + public function get_meta($meta_key = '_give_payment_meta', $single = true) { |
|
1338 | 1338 | if ( |
1339 | - ! has_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta' ) && |
|
1340 | - ! doing_filter( 'get_post_metadata' ) |
|
1339 | + ! has_filter('get_post_metadata', 'give_bc_v20_get_payment_meta') && |
|
1340 | + ! doing_filter('get_post_metadata') |
|
1341 | 1341 | ) { |
1342 | - add_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4 ); |
|
1342 | + add_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4); |
|
1343 | 1343 | } |
1344 | 1344 | |
1345 | - $meta = give_get_meta( $this->ID, $meta_key, $single ); |
|
1345 | + $meta = give_get_meta($this->ID, $meta_key, $single); |
|
1346 | 1346 | |
1347 | 1347 | /** |
1348 | 1348 | * Filter the specific meta key value. |
1349 | 1349 | * |
1350 | 1350 | * @since 1.5 |
1351 | 1351 | */ |
1352 | - $meta = apply_filters( "give_get_payment_meta_{$meta_key}", $meta, $this->ID ); |
|
1352 | + $meta = apply_filters("give_get_payment_meta_{$meta_key}", $meta, $this->ID); |
|
1353 | 1353 | |
1354 | 1354 | // Security check. |
1355 | - if ( is_serialized( $meta ) ) { |
|
1356 | - preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $meta, $matches ); |
|
1357 | - if ( ! empty( $matches ) ) { |
|
1355 | + if (is_serialized($meta)) { |
|
1356 | + preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $meta, $matches); |
|
1357 | + if ( ! empty($matches)) { |
|
1358 | 1358 | $meta = array(); |
1359 | 1359 | } |
1360 | 1360 | } |
@@ -1364,7 +1364,7 @@ discard block |
||
1364 | 1364 | * |
1365 | 1365 | * @since 1.5 |
1366 | 1366 | */ |
1367 | - return apply_filters( 'give_get_payment_meta', $meta, $this->ID, $meta_key ); |
|
1367 | + return apply_filters('give_get_payment_meta', $meta, $this->ID, $meta_key); |
|
1368 | 1368 | } |
1369 | 1369 | |
1370 | 1370 | /** |
@@ -1379,8 +1379,8 @@ discard block |
||
1379 | 1379 | * |
1380 | 1380 | * @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure |
1381 | 1381 | */ |
1382 | - public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
1383 | - if ( empty( $meta_key ) ) { |
|
1382 | + public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') { |
|
1383 | + if (empty($meta_key)) { |
|
1384 | 1384 | return false; |
1385 | 1385 | } |
1386 | 1386 | |
@@ -1390,9 +1390,9 @@ discard block |
||
1390 | 1390 | * |
1391 | 1391 | * @since 1.5 |
1392 | 1392 | */ |
1393 | - $meta_value = apply_filters( "give_update_payment_meta_{$meta_key}", $meta_value, $this->ID ); |
|
1393 | + $meta_value = apply_filters("give_update_payment_meta_{$meta_key}", $meta_value, $this->ID); |
|
1394 | 1394 | |
1395 | - return give_update_meta( $this->ID, $meta_key, $meta_value, $prev_value ); |
|
1395 | + return give_update_meta($this->ID, $meta_key, $meta_value, $prev_value); |
|
1396 | 1396 | } |
1397 | 1397 | |
1398 | 1398 | /** |
@@ -1405,7 +1405,7 @@ discard block |
||
1405 | 1405 | * |
1406 | 1406 | * @return void |
1407 | 1407 | */ |
1408 | - private function process_status( $status ) { |
|
1408 | + private function process_status($status) { |
|
1409 | 1409 | $process = true; |
1410 | 1410 | |
1411 | 1411 | // Bailout, if changed from completed to preapproval/processing. |
@@ -1420,9 +1420,9 @@ discard block |
||
1420 | 1420 | } |
1421 | 1421 | |
1422 | 1422 | // Allow extensions to filter for their own payment types, Example: Recurring Payments. |
1423 | - $process = apply_filters( "give_should_process_{$status}", $process, $this ); |
|
1423 | + $process = apply_filters("give_should_process_{$status}", $process, $this); |
|
1424 | 1424 | |
1425 | - if ( false === $process ) { |
|
1425 | + if (false === $process) { |
|
1426 | 1426 | return; |
1427 | 1427 | } |
1428 | 1428 | |
@@ -1433,13 +1433,13 @@ discard block |
||
1433 | 1433 | * |
1434 | 1434 | * @since 1.5 |
1435 | 1435 | */ |
1436 | - do_action( "give_pre_{$status}_payment", $this ); |
|
1436 | + do_action("give_pre_{$status}_payment", $this); |
|
1437 | 1437 | |
1438 | - $decrease_earnings = apply_filters( "give_decrease_earnings_on_{$status}", true, $this ); |
|
1439 | - $decrease_donor_value = apply_filters( "give_decrease_donor_value_on_{$status}", true, $this ); |
|
1440 | - $decrease_donation_count = apply_filters( "give_decrease_donors_donation_count_on_{$status}", true, $this ); |
|
1438 | + $decrease_earnings = apply_filters("give_decrease_earnings_on_{$status}", true, $this); |
|
1439 | + $decrease_donor_value = apply_filters("give_decrease_donor_value_on_{$status}", true, $this); |
|
1440 | + $decrease_donation_count = apply_filters("give_decrease_donors_donation_count_on_{$status}", true, $this); |
|
1441 | 1441 | |
1442 | - $this->maybe_alter_stats( $decrease_earnings, $decrease_donor_value, $decrease_donation_count ); |
|
1442 | + $this->maybe_alter_stats($decrease_earnings, $decrease_donor_value, $decrease_donation_count); |
|
1443 | 1443 | $this->delete_sales_logs(); |
1444 | 1444 | |
1445 | 1445 | // @todo: Refresh only range related stat cache |
@@ -1452,7 +1452,7 @@ discard block |
||
1452 | 1452 | * |
1453 | 1453 | * @since 1.5 |
1454 | 1454 | */ |
1455 | - do_action( "give_post_{$status}_payment", $this ); |
|
1455 | + do_action("give_post_{$status}_payment", $this); |
|
1456 | 1456 | } |
1457 | 1457 | |
1458 | 1458 | /** |
@@ -1467,25 +1467,25 @@ discard block |
||
1467 | 1467 | * |
1468 | 1468 | * @return void |
1469 | 1469 | */ |
1470 | - private function maybe_alter_stats( $alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count ) { |
|
1470 | + private function maybe_alter_stats($alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count) { |
|
1471 | 1471 | |
1472 | - give_undo_donation( $this->ID ); |
|
1472 | + give_undo_donation($this->ID); |
|
1473 | 1473 | |
1474 | 1474 | // Decrease store earnings. |
1475 | - if ( true === $alter_store_earnings ) { |
|
1476 | - give_decrease_total_earnings( $this->total ); |
|
1475 | + if (true === $alter_store_earnings) { |
|
1476 | + give_decrease_total_earnings($this->total); |
|
1477 | 1477 | } |
1478 | 1478 | |
1479 | 1479 | // Decrement the stats for the donor. |
1480 | - if ( ! empty( $this->customer_id ) ) { |
|
1480 | + if ( ! empty($this->customer_id)) { |
|
1481 | 1481 | |
1482 | - $donor = new Give_Donor( $this->customer_id ); |
|
1482 | + $donor = new Give_Donor($this->customer_id); |
|
1483 | 1483 | |
1484 | - if ( true === $alter_customer_value ) { |
|
1485 | - $donor->decrease_value( $this->total ); |
|
1484 | + if (true === $alter_customer_value) { |
|
1485 | + $donor->decrease_value($this->total); |
|
1486 | 1486 | } |
1487 | 1487 | |
1488 | - if ( true === $alter_customer_purchase_count ) { |
|
1488 | + if (true === $alter_customer_purchase_count) { |
|
1489 | 1489 | $donor->decrease_donation_count(); |
1490 | 1490 | } |
1491 | 1491 | } |
@@ -1502,7 +1502,7 @@ discard block |
||
1502 | 1502 | */ |
1503 | 1503 | private function delete_sales_logs() { |
1504 | 1504 | // Remove related sale log entries. |
1505 | - Give()->logs->delete_logs( $this->ID ); |
|
1505 | + Give()->logs->delete_logs($this->ID); |
|
1506 | 1506 | } |
1507 | 1507 | |
1508 | 1508 | /** |
@@ -1523,13 +1523,13 @@ discard block |
||
1523 | 1523 | * @return string The date the payment was completed |
1524 | 1524 | */ |
1525 | 1525 | private function setup_completed_date() { |
1526 | - $payment = get_post( $this->ID ); |
|
1526 | + $payment = get_post($this->ID); |
|
1527 | 1527 | |
1528 | - if ( 'pending' === $payment->post_status || 'preapproved' === $payment->post_status ) { |
|
1528 | + if ('pending' === $payment->post_status || 'preapproved' === $payment->post_status) { |
|
1529 | 1529 | return false; // This payment was never completed. |
1530 | 1530 | } |
1531 | 1531 | |
1532 | - $date = ( $date = $this->get_meta( '_give_completed_date', true ) ) ? $date : $payment->modified_date; |
|
1532 | + $date = ($date = $this->get_meta('_give_completed_date', true)) ? $date : $payment->modified_date; |
|
1533 | 1533 | |
1534 | 1534 | return $date; |
1535 | 1535 | } |
@@ -1543,7 +1543,7 @@ discard block |
||
1543 | 1543 | * @return string The payment mode |
1544 | 1544 | */ |
1545 | 1545 | private function setup_mode() { |
1546 | - return $this->get_meta( '_give_payment_mode' ); |
|
1546 | + return $this->get_meta('_give_payment_mode'); |
|
1547 | 1547 | } |
1548 | 1548 | |
1549 | 1549 | /** |
@@ -1555,7 +1555,7 @@ discard block |
||
1555 | 1555 | * @return bool The payment import |
1556 | 1556 | */ |
1557 | 1557 | private function setup_import() { |
1558 | - return (bool) $this->get_meta( '_give_payment_import' ); |
|
1558 | + return (bool) $this->get_meta('_give_payment_import'); |
|
1559 | 1559 | } |
1560 | 1560 | |
1561 | 1561 | /** |
@@ -1567,9 +1567,9 @@ discard block |
||
1567 | 1567 | * @return float The payment total |
1568 | 1568 | */ |
1569 | 1569 | private function setup_total() { |
1570 | - $amount = $this->get_meta( '_give_payment_total', true ); |
|
1570 | + $amount = $this->get_meta('_give_payment_total', true); |
|
1571 | 1571 | |
1572 | - return round( floatval( $amount ), give_get_price_decimals( $this->ID ) ); |
|
1572 | + return round(floatval($amount), give_get_price_decimals($this->ID)); |
|
1573 | 1573 | } |
1574 | 1574 | |
1575 | 1575 | /** |
@@ -1596,17 +1596,16 @@ discard block |
||
1596 | 1596 | * @return string The currency for the payment |
1597 | 1597 | */ |
1598 | 1598 | private function setup_currency() { |
1599 | - $currency = $this->get_meta( '_give_payment_currency', true ); |
|
1600 | - $currency = ! empty( $currency ) ? |
|
1601 | - $currency : |
|
1602 | - /** |
|
1599 | + $currency = $this->get_meta('_give_payment_currency', true); |
|
1600 | + $currency = ! empty($currency) ? |
|
1601 | + $currency : /** |
|
1603 | 1602 | * Filter the default donation currency |
1604 | 1603 | * |
1605 | 1604 | * @since 1.5 |
1606 | 1605 | */ |
1607 | 1606 | apply_filters( |
1608 | 1607 | 'give_payment_currency_default', |
1609 | - give_get_currency( $this->form_id, $this ), |
|
1608 | + give_get_currency($this->form_id, $this), |
|
1610 | 1609 | $this |
1611 | 1610 | ); |
1612 | 1611 | |
@@ -1622,7 +1621,7 @@ discard block |
||
1622 | 1621 | * @return string The gateway |
1623 | 1622 | */ |
1624 | 1623 | private function setup_gateway() { |
1625 | - $gateway = $this->get_meta( '_give_payment_gateway', true ); |
|
1624 | + $gateway = $this->get_meta('_give_payment_gateway', true); |
|
1626 | 1625 | |
1627 | 1626 | return $gateway; |
1628 | 1627 | } |
@@ -1636,11 +1635,11 @@ discard block |
||
1636 | 1635 | * @return string The donation ID |
1637 | 1636 | */ |
1638 | 1637 | private function setup_transaction_id() { |
1639 | - $transaction_id = $this->get_meta( '_give_payment_transaction_id', true ); |
|
1638 | + $transaction_id = $this->get_meta('_give_payment_transaction_id', true); |
|
1640 | 1639 | |
1641 | - if ( empty( $transaction_id ) ) { |
|
1640 | + if (empty($transaction_id)) { |
|
1642 | 1641 | $gateway = $this->gateway; |
1643 | - $transaction_id = apply_filters( "give_get_payment_transaction_id-{$gateway}", $this->ID ); |
|
1642 | + $transaction_id = apply_filters("give_get_payment_transaction_id-{$gateway}", $this->ID); |
|
1644 | 1643 | } |
1645 | 1644 | |
1646 | 1645 | return $transaction_id; |
@@ -1656,7 +1655,7 @@ discard block |
||
1656 | 1655 | * @return string The IP address for the payment |
1657 | 1656 | */ |
1658 | 1657 | private function setup_ip() { |
1659 | - $ip = $this->get_meta( '_give_payment_donor_ip', true ); |
|
1658 | + $ip = $this->get_meta('_give_payment_donor_ip', true); |
|
1660 | 1659 | |
1661 | 1660 | return $ip; |
1662 | 1661 | } |
@@ -1671,7 +1670,7 @@ discard block |
||
1671 | 1670 | * @return int The Donor ID. |
1672 | 1671 | */ |
1673 | 1672 | private function setup_donor_id() { |
1674 | - $donor_id = $this->get_meta( '_give_payment_donor_id', true ); |
|
1673 | + $donor_id = $this->get_meta('_give_payment_donor_id', true); |
|
1675 | 1674 | |
1676 | 1675 | return $donor_id; |
1677 | 1676 | } |
@@ -1688,8 +1687,8 @@ discard block |
||
1688 | 1687 | */ |
1689 | 1688 | private function setup_user_id() { |
1690 | 1689 | |
1691 | - $donor = Give()->customers->get_customer_by( 'id', $this->customer_id ); |
|
1692 | - $user_id = $donor ? absint( $donor->user_id ) : 0; |
|
1690 | + $donor = Give()->customers->get_customer_by('id', $this->customer_id); |
|
1691 | + $user_id = $donor ? absint($donor->user_id) : 0; |
|
1693 | 1692 | |
1694 | 1693 | |
1695 | 1694 | return $user_id; |
@@ -1706,10 +1705,10 @@ discard block |
||
1706 | 1705 | * @return string The email address for the payment. |
1707 | 1706 | */ |
1708 | 1707 | private function setup_email() { |
1709 | - $email = $this->get_meta( '_give_payment_donor_email', true ); |
|
1708 | + $email = $this->get_meta('_give_payment_donor_email', true); |
|
1710 | 1709 | |
1711 | - if ( empty( $email ) && $this->customer_id ) { |
|
1712 | - $email = Give()->donors->get_column( 'email', $this->customer_id ); |
|
1710 | + if (empty($email) && $this->customer_id) { |
|
1711 | + $email = Give()->donors->get_column('email', $this->customer_id); |
|
1713 | 1712 | } |
1714 | 1713 | |
1715 | 1714 | return $email; |
@@ -1730,22 +1729,22 @@ discard block |
||
1730 | 1729 | 'last_name' => $this->last_name, |
1731 | 1730 | ); |
1732 | 1731 | |
1733 | - $user_info = isset( $this->payment_meta['user_info'] ) ? $this->payment_meta['user_info'] : array(); |
|
1732 | + $user_info = isset($this->payment_meta['user_info']) ? $this->payment_meta['user_info'] : array(); |
|
1734 | 1733 | |
1735 | - if ( is_serialized( $user_info ) ) { |
|
1736 | - preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches ); |
|
1737 | - if ( ! empty( $matches ) ) { |
|
1734 | + if (is_serialized($user_info)) { |
|
1735 | + preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches); |
|
1736 | + if ( ! empty($matches)) { |
|
1738 | 1737 | $user_info = array(); |
1739 | 1738 | } |
1740 | 1739 | } |
1741 | 1740 | |
1742 | - $user_info = wp_parse_args( $user_info, $defaults ); |
|
1741 | + $user_info = wp_parse_args($user_info, $defaults); |
|
1743 | 1742 | |
1744 | - if ( empty( $user_info ) ) { |
|
1743 | + if (empty($user_info)) { |
|
1745 | 1744 | // Get the donor, but only if it's been created. |
1746 | - $donor = new Give_Donor( $this->customer_id ); |
|
1745 | + $donor = new Give_Donor($this->customer_id); |
|
1747 | 1746 | |
1748 | - if ( $donor->id > 0 ) { |
|
1747 | + if ($donor->id > 0) { |
|
1749 | 1748 | $user_info = array( |
1750 | 1749 | 'first_name' => $donor->get_first_name(), |
1751 | 1750 | 'last_name' => $donor->get_last_name(), |
@@ -1755,29 +1754,29 @@ discard block |
||
1755 | 1754 | } |
1756 | 1755 | } else { |
1757 | 1756 | // Get the donor, but only if it's been created. |
1758 | - $donor = new Give_Donor( $this->customer_id ); |
|
1757 | + $donor = new Give_Donor($this->customer_id); |
|
1759 | 1758 | |
1760 | - if ( $donor->id > 0 ) { |
|
1761 | - foreach ( $user_info as $key => $value ) { |
|
1762 | - if ( ! empty( $value ) ) { |
|
1759 | + if ($donor->id > 0) { |
|
1760 | + foreach ($user_info as $key => $value) { |
|
1761 | + if ( ! empty($value)) { |
|
1763 | 1762 | continue; |
1764 | 1763 | } |
1765 | 1764 | |
1766 | - switch ( $key ) { |
|
1765 | + switch ($key) { |
|
1767 | 1766 | case 'title': |
1768 | - $user_info[ $key ] = Give()->donor_meta->get_meta( $donor->id, '_give_donor_title_prefix', true ); |
|
1767 | + $user_info[$key] = Give()->donor_meta->get_meta($donor->id, '_give_donor_title_prefix', true); |
|
1769 | 1768 | break; |
1770 | 1769 | |
1771 | 1770 | case 'first_name': |
1772 | - $user_info[ $key ] = $donor->get_first_name(); |
|
1771 | + $user_info[$key] = $donor->get_first_name(); |
|
1773 | 1772 | break; |
1774 | 1773 | |
1775 | 1774 | case 'last_name': |
1776 | - $user_info[ $key ] = $donor->get_last_name(); |
|
1775 | + $user_info[$key] = $donor->get_last_name(); |
|
1777 | 1776 | break; |
1778 | 1777 | |
1779 | 1778 | case 'email': |
1780 | - $user_info[ $key ] = $donor->email; |
|
1779 | + $user_info[$key] = $donor->email; |
|
1781 | 1780 | break; |
1782 | 1781 | } |
1783 | 1782 | } |
@@ -1797,12 +1796,12 @@ discard block |
||
1797 | 1796 | * @return array The Address information for the payment. |
1798 | 1797 | */ |
1799 | 1798 | private function setup_address() { |
1800 | - $address['line1'] = give_get_meta( $this->ID, '_give_donor_billing_address1', true, '' ); |
|
1801 | - $address['line2'] = give_get_meta( $this->ID, '_give_donor_billing_address2', true, '' ); |
|
1802 | - $address['city'] = give_get_meta( $this->ID, '_give_donor_billing_city', true, '' ); |
|
1803 | - $address['state'] = give_get_meta( $this->ID, '_give_donor_billing_state', true, '' ); |
|
1804 | - $address['zip'] = give_get_meta( $this->ID, '_give_donor_billing_zip', true, '' ); |
|
1805 | - $address['country'] = give_get_meta( $this->ID, '_give_donor_billing_country', true, '' ); |
|
1799 | + $address['line1'] = give_get_meta($this->ID, '_give_donor_billing_address1', true, ''); |
|
1800 | + $address['line2'] = give_get_meta($this->ID, '_give_donor_billing_address2', true, ''); |
|
1801 | + $address['city'] = give_get_meta($this->ID, '_give_donor_billing_city', true, ''); |
|
1802 | + $address['state'] = give_get_meta($this->ID, '_give_donor_billing_state', true, ''); |
|
1803 | + $address['zip'] = give_get_meta($this->ID, '_give_donor_billing_zip', true, ''); |
|
1804 | + $address['country'] = give_get_meta($this->ID, '_give_donor_billing_country', true, ''); |
|
1806 | 1805 | |
1807 | 1806 | return $address; |
1808 | 1807 | } |
@@ -1817,7 +1816,7 @@ discard block |
||
1817 | 1816 | */ |
1818 | 1817 | private function setup_form_title() { |
1819 | 1818 | |
1820 | - $form_id = $this->get_meta( '_give_payment_form_title', true ); |
|
1819 | + $form_id = $this->get_meta('_give_payment_form_title', true); |
|
1821 | 1820 | |
1822 | 1821 | return $form_id; |
1823 | 1822 | } |
@@ -1832,7 +1831,7 @@ discard block |
||
1832 | 1831 | */ |
1833 | 1832 | private function setup_form_id() { |
1834 | 1833 | |
1835 | - $form_id = $this->get_meta( '_give_payment_form_id', true ); |
|
1834 | + $form_id = $this->get_meta('_give_payment_form_id', true); |
|
1836 | 1835 | |
1837 | 1836 | return $form_id; |
1838 | 1837 | } |
@@ -1846,7 +1845,7 @@ discard block |
||
1846 | 1845 | * @return int The Form Price ID. |
1847 | 1846 | */ |
1848 | 1847 | private function setup_price_id() { |
1849 | - $price_id = $this->get_meta( '_give_payment_price_id', true ); |
|
1848 | + $price_id = $this->get_meta('_give_payment_price_id', true); |
|
1850 | 1849 | |
1851 | 1850 | return $price_id; |
1852 | 1851 | } |
@@ -1860,7 +1859,7 @@ discard block |
||
1860 | 1859 | * @return string The Payment Key. |
1861 | 1860 | */ |
1862 | 1861 | private function setup_payment_key() { |
1863 | - $key = $this->get_meta( '_give_payment_purchase_key', true ); |
|
1862 | + $key = $this->get_meta('_give_payment_purchase_key', true); |
|
1864 | 1863 | |
1865 | 1864 | return $key; |
1866 | 1865 | } |
@@ -1885,7 +1884,7 @@ discard block |
||
1885 | 1884 | * @return array The payment object as an array. |
1886 | 1885 | */ |
1887 | 1886 | public function array_convert() { |
1888 | - return get_object_vars( $this ); |
|
1887 | + return get_object_vars($this); |
|
1889 | 1888 | } |
1890 | 1889 | |
1891 | 1890 | |
@@ -1898,7 +1897,7 @@ discard block |
||
1898 | 1897 | * @return bool |
1899 | 1898 | */ |
1900 | 1899 | public function is_completed() { |
1901 | - return ( 'publish' === $this->status && $this->completed_date ); |
|
1900 | + return ('publish' === $this->status && $this->completed_date); |
|
1902 | 1901 | } |
1903 | 1902 | |
1904 | 1903 | /** |
@@ -1910,7 +1909,7 @@ discard block |
||
1910 | 1909 | * @return string Date payment was completed. |
1911 | 1910 | */ |
1912 | 1911 | private function get_completed_date() { |
1913 | - return apply_filters( 'give_payment_completed_date', $this->completed_date, $this->ID, $this ); |
|
1912 | + return apply_filters('give_payment_completed_date', $this->completed_date, $this->ID, $this); |
|
1914 | 1913 | } |
1915 | 1914 | |
1916 | 1915 | /** |
@@ -1922,7 +1921,7 @@ discard block |
||
1922 | 1921 | * @return float Payment subtotal. |
1923 | 1922 | */ |
1924 | 1923 | private function get_subtotal() { |
1925 | - return apply_filters( 'give_get_payment_subtotal', $this->subtotal, $this->ID, $this ); |
|
1924 | + return apply_filters('give_get_payment_subtotal', $this->subtotal, $this->ID, $this); |
|
1926 | 1925 | } |
1927 | 1926 | |
1928 | 1927 | /** |
@@ -1934,7 +1933,7 @@ discard block |
||
1934 | 1933 | * @return string Payment currency code. |
1935 | 1934 | */ |
1936 | 1935 | private function get_currency() { |
1937 | - return apply_filters( 'give_payment_currency_code', $this->currency, $this->ID, $this ); |
|
1936 | + return apply_filters('give_payment_currency_code', $this->currency, $this->ID, $this); |
|
1938 | 1937 | } |
1939 | 1938 | |
1940 | 1939 | /** |
@@ -1946,7 +1945,7 @@ discard block |
||
1946 | 1945 | * @return string Gateway used. |
1947 | 1946 | */ |
1948 | 1947 | private function get_gateway() { |
1949 | - return apply_filters( 'give_payment_gateway', $this->gateway, $this->ID, $this ); |
|
1948 | + return apply_filters('give_payment_gateway', $this->gateway, $this->ID, $this); |
|
1950 | 1949 | } |
1951 | 1950 | |
1952 | 1951 | /** |
@@ -1958,7 +1957,7 @@ discard block |
||
1958 | 1957 | * @return string Donation ID from merchant processor. |
1959 | 1958 | */ |
1960 | 1959 | private function get_transaction_id() { |
1961 | - return apply_filters( 'give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this ); |
|
1960 | + return apply_filters('give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this); |
|
1962 | 1961 | } |
1963 | 1962 | |
1964 | 1963 | /** |
@@ -1970,7 +1969,7 @@ discard block |
||
1970 | 1969 | * @return string Payment IP address |
1971 | 1970 | */ |
1972 | 1971 | private function get_ip() { |
1973 | - return apply_filters( 'give_payment_user_ip', $this->ip, $this->ID, $this ); |
|
1972 | + return apply_filters('give_payment_user_ip', $this->ip, $this->ID, $this); |
|
1974 | 1973 | } |
1975 | 1974 | |
1976 | 1975 | /** |
@@ -1982,7 +1981,7 @@ discard block |
||
1982 | 1981 | * @return int Payment donor ID. |
1983 | 1982 | */ |
1984 | 1983 | private function get_donor_id() { |
1985 | - return apply_filters( 'give_payment_customer_id', $this->customer_id, $this->ID, $this ); |
|
1984 | + return apply_filters('give_payment_customer_id', $this->customer_id, $this->ID, $this); |
|
1986 | 1985 | } |
1987 | 1986 | |
1988 | 1987 | /** |
@@ -1994,7 +1993,7 @@ discard block |
||
1994 | 1993 | * @return int Payment user ID. |
1995 | 1994 | */ |
1996 | 1995 | private function get_user_id() { |
1997 | - return apply_filters( 'give_payment_user_id', $this->user_id, $this->ID, $this ); |
|
1996 | + return apply_filters('give_payment_user_id', $this->user_id, $this->ID, $this); |
|
1998 | 1997 | } |
1999 | 1998 | |
2000 | 1999 | /** |
@@ -2006,7 +2005,7 @@ discard block |
||
2006 | 2005 | * @return string Payment donor email. |
2007 | 2006 | */ |
2008 | 2007 | private function get_email() { |
2009 | - return apply_filters( 'give_payment_user_email', $this->email, $this->ID, $this ); |
|
2008 | + return apply_filters('give_payment_user_email', $this->email, $this->ID, $this); |
|
2010 | 2009 | } |
2011 | 2010 | |
2012 | 2011 | /** |
@@ -2018,7 +2017,7 @@ discard block |
||
2018 | 2017 | * @return array Payment user info. |
2019 | 2018 | */ |
2020 | 2019 | private function get_user_info() { |
2021 | - return apply_filters( 'give_payment_meta_user_info', $this->user_info, $this->ID, $this ); |
|
2020 | + return apply_filters('give_payment_meta_user_info', $this->user_info, $this->ID, $this); |
|
2022 | 2021 | } |
2023 | 2022 | |
2024 | 2023 | /** |
@@ -2030,7 +2029,7 @@ discard block |
||
2030 | 2029 | * @return array Payment billing address. |
2031 | 2030 | */ |
2032 | 2031 | private function get_address() { |
2033 | - return apply_filters( 'give_payment_address', $this->address, $this->ID, $this ); |
|
2032 | + return apply_filters('give_payment_address', $this->address, $this->ID, $this); |
|
2034 | 2033 | } |
2035 | 2034 | |
2036 | 2035 | /** |
@@ -2042,7 +2041,7 @@ discard block |
||
2042 | 2041 | * @return string Payment key. |
2043 | 2042 | */ |
2044 | 2043 | private function get_key() { |
2045 | - return apply_filters( 'give_payment_key', $this->key, $this->ID, $this ); |
|
2044 | + return apply_filters('give_payment_key', $this->key, $this->ID, $this); |
|
2046 | 2045 | } |
2047 | 2046 | |
2048 | 2047 | /** |
@@ -2054,7 +2053,7 @@ discard block |
||
2054 | 2053 | * @return string Payment form id |
2055 | 2054 | */ |
2056 | 2055 | private function get_form_id() { |
2057 | - return apply_filters( 'give_payment_form_id', $this->form_id, $this->ID, $this ); |
|
2056 | + return apply_filters('give_payment_form_id', $this->form_id, $this->ID, $this); |
|
2058 | 2057 | } |
2059 | 2058 | |
2060 | 2059 | /** |
@@ -2066,7 +2065,7 @@ discard block |
||
2066 | 2065 | * @return int|string Payment number |
2067 | 2066 | */ |
2068 | 2067 | private function get_number() { |
2069 | - return apply_filters( 'give_payment_number', $this->number, $this->ID, $this ); |
|
2068 | + return apply_filters('give_payment_number', $this->number, $this->ID, $this); |
|
2070 | 2069 | } |
2071 | 2070 | |
2072 | 2071 | /** |
@@ -2078,7 +2077,7 @@ discard block |
||
2078 | 2077 | * |
2079 | 2078 | * @return string |
2080 | 2079 | */ |
2081 | - public function get_serial_code( $args = array() ) { |
|
2082 | - return Give()->seq_donation_number->get_serial_code( $this, $args ); |
|
2080 | + public function get_serial_code($args = array()) { |
|
2081 | + return Give()->seq_donation_number->get_serial_code($this, $args); |
|
2083 | 2082 | } |
2084 | 2083 | } |
@@ -789,7 +789,7 @@ |
||
789 | 789 | * @type string $display_style How the form is displayed, either in new page or modal popup. |
790 | 790 | * Default 'redirect'. Accepts 'redirect', 'modal'. |
791 | 791 | * } |
792 | - * @return string|bool The markup of the form grid or false. |
|
792 | + * @return string|null The markup of the form grid or false. |
|
793 | 793 | */ |
794 | 794 | function give_form_grid_shortcode( $atts ) { |
795 | 795 |
@@ -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 | |
@@ -26,42 +26,42 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return string|bool |
28 | 28 | */ |
29 | -function give_donation_history( $atts, $content = false ) { |
|
29 | +function give_donation_history($atts, $content = false) { |
|
30 | 30 | |
31 | - $donation_history_args = shortcode_atts( array( |
|
31 | + $donation_history_args = shortcode_atts(array( |
|
32 | 32 | 'id' => true, |
33 | 33 | 'date' => true, |
34 | 34 | 'donor' => false, |
35 | 35 | 'amount' => true, |
36 | 36 | 'status' => false, |
37 | 37 | 'payment_method' => false, |
38 | - ), $atts, 'donation_history' ); |
|
38 | + ), $atts, 'donation_history'); |
|
39 | 39 | |
40 | 40 | // Always show receipt link. |
41 | 41 | $donation_history_args['details'] = true; |
42 | 42 | |
43 | 43 | // Set Donation History Shortcode Arguments in session variable. |
44 | - Give()->session->set( 'give_donation_history_args', $donation_history_args ); |
|
44 | + Give()->session->set('give_donation_history_args', $donation_history_args); |
|
45 | 45 | |
46 | 46 | // If payment_key query arg exists, return receipt instead of donation history. |
47 | - if ( isset( $_GET['payment_key'] ) ) { |
|
47 | + if (isset($_GET['payment_key'])) { |
|
48 | 48 | ob_start(); |
49 | 49 | |
50 | - echo give_receipt_shortcode( array() ); |
|
50 | + echo give_receipt_shortcode(array()); |
|
51 | 51 | |
52 | 52 | // Display donation history link only if Receipt Access Session is available. |
53 | - if ( give_get_receipt_session() ) { |
|
53 | + if (give_get_receipt_session()) { |
|
54 | 54 | echo sprintf( |
55 | 55 | '<a href="%s">%s</a>', |
56 | - esc_url( give_get_history_page_uri() ), |
|
57 | - __( '« Return to All Donations', 'give' ) |
|
56 | + esc_url(give_get_history_page_uri()), |
|
57 | + __('« Return to All Donations', 'give') |
|
58 | 58 | ); |
59 | 59 | } |
60 | 60 | |
61 | 61 | return ob_get_clean(); |
62 | 62 | } |
63 | 63 | |
64 | - $email_access = give_get_option( 'email_access' ); |
|
64 | + $email_access = give_get_option('email_access'); |
|
65 | 65 | |
66 | 66 | ob_start(); |
67 | 67 | |
@@ -74,23 +74,23 @@ discard block |
||
74 | 74 | if ( |
75 | 75 | is_user_logged_in() |
76 | 76 | || false !== Give()->session->get_session_expiration() |
77 | - || ( give_is_setting_enabled( $email_access ) && Give()->email_access->token_exists ) |
|
77 | + || (give_is_setting_enabled($email_access) && Give()->email_access->token_exists) |
|
78 | 78 | || true === give_get_history_session() |
79 | 79 | ) { |
80 | - give_get_template_part( 'history', 'donations' ); |
|
80 | + give_get_template_part('history', 'donations'); |
|
81 | 81 | |
82 | - if ( ! empty( $content ) ) { |
|
83 | - echo do_shortcode( $content ); |
|
82 | + if ( ! empty($content)) { |
|
83 | + echo do_shortcode($content); |
|
84 | 84 | } |
85 | 85 | |
86 | - } elseif ( give_is_setting_enabled( $email_access ) ) { |
|
86 | + } elseif (give_is_setting_enabled($email_access)) { |
|
87 | 87 | // Is Email-based access enabled? |
88 | - give_get_template_part( 'email', 'login-form' ); |
|
88 | + give_get_template_part('email', 'login-form'); |
|
89 | 89 | |
90 | 90 | } else { |
91 | 91 | |
92 | - echo apply_filters( 'give_donation_history_nonuser_message', Give()->notices->print_frontend_notice( __( 'You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give' ), false ) ); |
|
93 | - echo do_shortcode( '[give_login]' ); |
|
92 | + echo apply_filters('give_donation_history_nonuser_message', Give()->notices->print_frontend_notice(__('You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give'), false)); |
|
93 | + echo do_shortcode('[give_login]'); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -104,10 +104,10 @@ discard block |
||
104 | 104 | * |
105 | 105 | * @return string HTML content |
106 | 106 | */ |
107 | - return apply_filters( 'give_donation_history_shortcode_html', ob_get_clean(), $atts, $content ); |
|
107 | + return apply_filters('give_donation_history_shortcode_html', ob_get_clean(), $atts, $content); |
|
108 | 108 | } |
109 | 109 | |
110 | -add_shortcode( 'donation_history', 'give_donation_history' ); |
|
110 | +add_shortcode('donation_history', 'give_donation_history'); |
|
111 | 111 | |
112 | 112 | /** |
113 | 113 | * Donation Form Shortcode |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @return string |
122 | 122 | */ |
123 | -function give_form_shortcode( $atts ) { |
|
124 | - $atts = shortcode_atts( array( |
|
123 | +function give_form_shortcode($atts) { |
|
124 | + $atts = shortcode_atts(array( |
|
125 | 125 | 'id' => '', |
126 | 126 | 'show_title' => true, |
127 | 127 | 'show_goal' => true, |
@@ -129,21 +129,21 @@ discard block |
||
129 | 129 | 'float_labels' => '', |
130 | 130 | 'display_style' => '', |
131 | 131 | 'continue_button_title' => '', |
132 | - ), $atts, 'give_form' ); |
|
132 | + ), $atts, 'give_form'); |
|
133 | 133 | |
134 | 134 | // Convert string to bool. |
135 | - $atts['show_title'] = filter_var( $atts['show_title'], FILTER_VALIDATE_BOOLEAN ); |
|
136 | - $atts['show_goal'] = filter_var( $atts['show_goal'], FILTER_VALIDATE_BOOLEAN ); |
|
135 | + $atts['show_title'] = filter_var($atts['show_title'], FILTER_VALIDATE_BOOLEAN); |
|
136 | + $atts['show_goal'] = filter_var($atts['show_goal'], FILTER_VALIDATE_BOOLEAN); |
|
137 | 137 | |
138 | 138 | // get the Give Form |
139 | 139 | ob_start(); |
140 | - give_get_donation_form( $atts ); |
|
140 | + give_get_donation_form($atts); |
|
141 | 141 | $final_output = ob_get_clean(); |
142 | 142 | |
143 | - return apply_filters( 'give_donate_form', $final_output, $atts ); |
|
143 | + return apply_filters('give_donate_form', $final_output, $atts); |
|
144 | 144 | } |
145 | 145 | |
146 | -add_shortcode( 'give_form', 'give_form_shortcode' ); |
|
146 | +add_shortcode('give_form', 'give_form_shortcode'); |
|
147 | 147 | |
148 | 148 | /** |
149 | 149 | * Donation Form Goal Shortcode. |
@@ -156,36 +156,36 @@ discard block |
||
156 | 156 | * |
157 | 157 | * @return string |
158 | 158 | */ |
159 | -function give_goal_shortcode( $atts ) { |
|
160 | - $atts = shortcode_atts( array( |
|
159 | +function give_goal_shortcode($atts) { |
|
160 | + $atts = shortcode_atts(array( |
|
161 | 161 | 'id' => '', |
162 | 162 | 'show_text' => true, |
163 | 163 | 'show_bar' => true, |
164 | - ), $atts, 'give_goal' ); |
|
164 | + ), $atts, 'give_goal'); |
|
165 | 165 | |
166 | 166 | // get the Give Form. |
167 | 167 | ob_start(); |
168 | 168 | |
169 | 169 | // Sanity check 1: ensure there is an ID Provided. |
170 | - if ( empty( $atts['id'] ) ) { |
|
171 | - Give()->notices->print_frontend_notice( __( 'The shortcode is missing Donation Form ID attribute.', 'give' ), true ); |
|
170 | + if (empty($atts['id'])) { |
|
171 | + Give()->notices->print_frontend_notice(__('The shortcode is missing Donation Form ID attribute.', 'give'), true); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | // Sanity check 2: Check the form even has Goals enabled. |
175 | - if ( ! give_is_setting_enabled( give_get_meta( $atts['id'], '_give_goal_option', true ) ) ) { |
|
175 | + if ( ! give_is_setting_enabled(give_get_meta($atts['id'], '_give_goal_option', true))) { |
|
176 | 176 | |
177 | - Give()->notices->print_frontend_notice( __( 'The form does not have Goals enabled.', 'give' ), true ); |
|
177 | + Give()->notices->print_frontend_notice(__('The form does not have Goals enabled.', 'give'), true); |
|
178 | 178 | } else { |
179 | 179 | // Passed all sanity checks: output Goal. |
180 | - give_show_goal_progress( $atts['id'], $atts ); |
|
180 | + give_show_goal_progress($atts['id'], $atts); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | $final_output = ob_get_clean(); |
184 | 184 | |
185 | - return apply_filters( 'give_goal_shortcode_output', $final_output, $atts ); |
|
185 | + return apply_filters('give_goal_shortcode_output', $final_output, $atts); |
|
186 | 186 | } |
187 | 187 | |
188 | -add_shortcode( 'give_goal', 'give_goal_shortcode' ); |
|
188 | +add_shortcode('give_goal', 'give_goal_shortcode'); |
|
189 | 189 | |
190 | 190 | |
191 | 191 | /** |
@@ -202,22 +202,22 @@ discard block |
||
202 | 202 | * |
203 | 203 | * @return string |
204 | 204 | */ |
205 | -function give_login_form_shortcode( $atts ) { |
|
205 | +function give_login_form_shortcode($atts) { |
|
206 | 206 | |
207 | - $atts = shortcode_atts( array( |
|
207 | + $atts = shortcode_atts(array( |
|
208 | 208 | // Add backward compatibility for redirect attribute. |
209 | 209 | 'redirect' => '', |
210 | 210 | 'login-redirect' => '', |
211 | 211 | 'logout-redirect' => '', |
212 | - ), $atts, 'give_login' ); |
|
212 | + ), $atts, 'give_login'); |
|
213 | 213 | |
214 | 214 | // Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute. |
215 | - $atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect'] ) ? $atts['redirect'] : '' ); |
|
215 | + $atts['login-redirect'] = ! empty($atts['login-redirect']) ? $atts['login-redirect'] : ( ! empty($atts['redirect']) ? $atts['redirect'] : ''); |
|
216 | 216 | |
217 | - return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] ); |
|
217 | + return give_login_form($atts['login-redirect'], $atts['logout-redirect']); |
|
218 | 218 | } |
219 | 219 | |
220 | -add_shortcode( 'give_login', 'give_login_form_shortcode' ); |
|
220 | +add_shortcode('give_login', 'give_login_form_shortcode'); |
|
221 | 221 | |
222 | 222 | /** |
223 | 223 | * Register Shortcode. |
@@ -232,15 +232,15 @@ discard block |
||
232 | 232 | * |
233 | 233 | * @return string |
234 | 234 | */ |
235 | -function give_register_form_shortcode( $atts ) { |
|
236 | - $atts = shortcode_atts( array( |
|
235 | +function give_register_form_shortcode($atts) { |
|
236 | + $atts = shortcode_atts(array( |
|
237 | 237 | 'redirect' => '', |
238 | - ), $atts, 'give_register' ); |
|
238 | + ), $atts, 'give_register'); |
|
239 | 239 | |
240 | - return give_register_form( $atts['redirect'] ); |
|
240 | + return give_register_form($atts['redirect']); |
|
241 | 241 | } |
242 | 242 | |
243 | -add_shortcode( 'give_register', 'give_register_form_shortcode' ); |
|
243 | +add_shortcode('give_register', 'give_register_form_shortcode'); |
|
244 | 244 | |
245 | 245 | /** |
246 | 246 | * Receipt Shortcode. |
@@ -253,12 +253,12 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @return string |
255 | 255 | */ |
256 | -function give_receipt_shortcode( $atts ) { |
|
256 | +function give_receipt_shortcode($atts) { |
|
257 | 257 | |
258 | 258 | global $give_receipt_args; |
259 | 259 | |
260 | - $give_receipt_args = shortcode_atts( array( |
|
261 | - 'error' => __( 'You are missing the payment key to view this donation receipt.', 'give' ), |
|
260 | + $give_receipt_args = shortcode_atts(array( |
|
261 | + 'error' => __('You are missing the payment key to view this donation receipt.', 'give'), |
|
262 | 262 | 'price' => true, |
263 | 263 | 'donor' => true, |
264 | 264 | 'date' => true, |
@@ -268,16 +268,16 @@ discard block |
||
268 | 268 | 'payment_status' => false, |
269 | 269 | 'company_name' => false, |
270 | 270 | 'status_notice' => true, |
271 | - ), $atts, 'give_receipt' ); |
|
271 | + ), $atts, 'give_receipt'); |
|
272 | 272 | |
273 | - if( ! wp_doing_ajax() ) { |
|
273 | + if ( ! wp_doing_ajax()) { |
|
274 | 274 | ob_start(); |
275 | - give_get_template_part( 'receipt/placeholder' ); |
|
275 | + give_get_template_part('receipt/placeholder'); |
|
276 | 276 | $placeholder = ob_get_clean(); |
277 | 277 | |
278 | 278 | return sprintf( |
279 | 279 | '<div id="give-receipt" data-shortcode="%s">%s</div>', |
280 | - urlencode_deep( wp_json_encode( $atts ) ), |
|
280 | + urlencode_deep(wp_json_encode($atts)), |
|
281 | 281 | $placeholder |
282 | 282 | ); |
283 | 283 | } |
@@ -286,43 +286,43 @@ discard block |
||
286 | 286 | $session = give_get_purchase_session(); |
287 | 287 | |
288 | 288 | // set payment key var |
289 | - if ( isset( $_GET['payment_key'] ) ) { |
|
290 | - $payment_key = urldecode( $_GET['payment_key'] ); |
|
291 | - } elseif ( $session ) { |
|
289 | + if (isset($_GET['payment_key'])) { |
|
290 | + $payment_key = urldecode($_GET['payment_key']); |
|
291 | + } elseif ($session) { |
|
292 | 292 | $payment_key = $session['purchase_key']; |
293 | - } elseif ( $give_receipt_args['payment_key'] ) { |
|
293 | + } elseif ($give_receipt_args['payment_key']) { |
|
294 | 294 | $payment_key = $give_receipt_args['payment_key']; |
295 | 295 | } |
296 | 296 | |
297 | - $email_access = give_get_option( 'email_access' ); |
|
297 | + $email_access = give_get_option('email_access'); |
|
298 | 298 | |
299 | 299 | // No payment_key found & Email Access is Turned on. |
300 | - if ( ! isset( $payment_key ) && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) { |
|
300 | + if ( ! isset($payment_key) && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) { |
|
301 | 301 | |
302 | 302 | ob_start(); |
303 | 303 | |
304 | - give_get_template_part( 'email-login-form' ); |
|
304 | + give_get_template_part('email-login-form'); |
|
305 | 305 | |
306 | 306 | return ob_get_clean(); |
307 | 307 | |
308 | - } elseif ( ! isset( $payment_key ) ) { |
|
308 | + } elseif ( ! isset($payment_key)) { |
|
309 | 309 | |
310 | - return Give()->notices->print_frontend_notice( $give_receipt_args['error'], false, 'error' ); |
|
310 | + return Give()->notices->print_frontend_notice($give_receipt_args['error'], false, 'error'); |
|
311 | 311 | |
312 | 312 | } |
313 | 313 | |
314 | - $user_can_view = give_can_view_receipt( $payment_key ); |
|
314 | + $user_can_view = give_can_view_receipt($payment_key); |
|
315 | 315 | |
316 | 316 | // Key was provided, but user is logged out. Offer them the ability to login and view the receipt. |
317 | - if ( ! $user_can_view && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) { |
|
317 | + if ( ! $user_can_view && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) { |
|
318 | 318 | |
319 | 319 | ob_start(); |
320 | 320 | |
321 | - give_get_template_part( 'email-login-form' ); |
|
321 | + give_get_template_part('email-login-form'); |
|
322 | 322 | |
323 | 323 | return ob_get_clean(); |
324 | 324 | |
325 | - } elseif ( ! $user_can_view ) { |
|
325 | + } elseif ( ! $user_can_view) { |
|
326 | 326 | |
327 | 327 | global $give_login_redirect; |
328 | 328 | |
@@ -330,9 +330,9 @@ discard block |
||
330 | 330 | |
331 | 331 | ob_start(); |
332 | 332 | |
333 | - Give()->notices->print_frontend_notice( apply_filters( 'give_must_be_logged_in_error_message', __( 'You must be logged in to view this donation receipt.', 'give' ) ) ); |
|
333 | + Give()->notices->print_frontend_notice(apply_filters('give_must_be_logged_in_error_message', __('You must be logged in to view this donation receipt.', 'give'))); |
|
334 | 334 | |
335 | - give_get_template_part( 'shortcode', 'login' ); |
|
335 | + give_get_template_part('shortcode', 'login'); |
|
336 | 336 | |
337 | 337 | $login_form = ob_get_clean(); |
338 | 338 | |
@@ -346,20 +346,20 @@ discard block |
||
346 | 346 | * or if user is logged out and donation was made as a guest, the donation session is checked for |
347 | 347 | * or if user is logged in and the user can view sensitive shop data. |
348 | 348 | */ |
349 | - if ( ! apply_filters( 'give_user_can_view_receipt', $user_can_view, $give_receipt_args ) ) { |
|
350 | - return Give()->notices->print_frontend_notice( $give_receipt_args['error'], false, 'error' ); |
|
349 | + if ( ! apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) { |
|
350 | + return Give()->notices->print_frontend_notice($give_receipt_args['error'], false, 'error'); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | ob_start(); |
354 | 354 | |
355 | - give_get_template_part( 'shortcode', 'receipt' ); |
|
355 | + give_get_template_part('shortcode', 'receipt'); |
|
356 | 356 | |
357 | 357 | $display = ob_get_clean(); |
358 | 358 | |
359 | 359 | return $display; |
360 | 360 | } |
361 | 361 | |
362 | -add_shortcode( 'give_receipt', 'give_receipt_shortcode' ); |
|
362 | +add_shortcode('give_receipt', 'give_receipt_shortcode'); |
|
363 | 363 | |
364 | 364 | /** |
365 | 365 | * Profile Editor Shortcode. |
@@ -378,26 +378,26 @@ discard block |
||
378 | 378 | * |
379 | 379 | * @return string Output generated from the profile editor |
380 | 380 | */ |
381 | -function give_profile_editor_shortcode( $atts ) { |
|
381 | +function give_profile_editor_shortcode($atts) { |
|
382 | 382 | |
383 | 383 | ob_start(); |
384 | 384 | |
385 | 385 | // Restrict access to donor profile, if donor and user are disconnected. |
386 | - $is_donor_disconnected = get_user_meta( get_current_user_id(), '_give_is_donor_disconnected', true ); |
|
387 | - if ( is_user_logged_in() && $is_donor_disconnected ) { |
|
388 | - Give()->notices->print_frontend_notice( __( 'Your Donor and User profile are no longer connected. Please contact the site administrator.', 'give' ), true, 'error' ); |
|
386 | + $is_donor_disconnected = get_user_meta(get_current_user_id(), '_give_is_donor_disconnected', true); |
|
387 | + if (is_user_logged_in() && $is_donor_disconnected) { |
|
388 | + Give()->notices->print_frontend_notice(__('Your Donor and User profile are no longer connected. Please contact the site administrator.', 'give'), true, 'error'); |
|
389 | 389 | |
390 | 390 | return false; |
391 | 391 | } |
392 | 392 | |
393 | - give_get_template_part( 'shortcode', 'profile-editor' ); |
|
393 | + give_get_template_part('shortcode', 'profile-editor'); |
|
394 | 394 | |
395 | 395 | $display = ob_get_clean(); |
396 | 396 | |
397 | 397 | return $display; |
398 | 398 | } |
399 | 399 | |
400 | -add_shortcode( 'give_profile_editor', 'give_profile_editor_shortcode' ); |
|
400 | +add_shortcode('give_profile_editor', 'give_profile_editor_shortcode'); |
|
401 | 401 | |
402 | 402 | /** |
403 | 403 | * Process Profile Updater Form. |
@@ -410,31 +410,31 @@ discard block |
||
410 | 410 | * |
411 | 411 | * @return bool |
412 | 412 | */ |
413 | -function give_process_profile_editor_updates( $data ) { |
|
413 | +function give_process_profile_editor_updates($data) { |
|
414 | 414 | // Profile field change request. |
415 | - if ( empty( $_POST['give_profile_editor_submit'] ) && ! is_user_logged_in() ) { |
|
415 | + if (empty($_POST['give_profile_editor_submit']) && ! is_user_logged_in()) { |
|
416 | 416 | return false; |
417 | 417 | } |
418 | 418 | |
419 | 419 | // Nonce security. |
420 | - if ( ! wp_verify_nonce( $data['give_profile_editor_nonce'], 'give-profile-editor-nonce' ) ) { |
|
420 | + if ( ! wp_verify_nonce($data['give_profile_editor_nonce'], 'give-profile-editor-nonce')) { |
|
421 | 421 | return false; |
422 | 422 | } |
423 | 423 | |
424 | 424 | $user_id = get_current_user_id(); |
425 | - $old_user_data = get_userdata( $user_id ); |
|
425 | + $old_user_data = get_userdata($user_id); |
|
426 | 426 | |
427 | 427 | /* @var Give_Donor $donor */ |
428 | - $donor = new Give_Donor( $user_id, true ); |
|
428 | + $donor = new Give_Donor($user_id, true); |
|
429 | 429 | $old_company_name = $donor->get_company_name(); |
430 | 430 | |
431 | - $display_name = isset( $data['give_display_name'] ) ? sanitize_text_field( $data['give_display_name'] ) : $old_user_data->display_name; |
|
432 | - $first_name = isset( $data['give_first_name'] ) ? sanitize_text_field( $data['give_first_name'] ) : $old_user_data->first_name; |
|
433 | - $last_name = isset( $data['give_last_name'] ) ? sanitize_text_field( $data['give_last_name'] ) : $old_user_data->last_name; |
|
434 | - $company_name = ! empty( $data['give_company_name'] ) ? sanitize_text_field( $data['give_company_name'] ) : $old_company_name; |
|
435 | - $email = isset( $data['give_email'] ) ? sanitize_email( $data['give_email'] ) : $old_user_data->user_email; |
|
436 | - $password = ! empty( $data['give_new_user_pass1'] ) ? $data['give_new_user_pass1'] : ''; |
|
437 | - $confirm_password = ! empty( $data['give_new_user_pass2'] ) ? $data['give_new_user_pass2'] : ''; |
|
431 | + $display_name = isset($data['give_display_name']) ? sanitize_text_field($data['give_display_name']) : $old_user_data->display_name; |
|
432 | + $first_name = isset($data['give_first_name']) ? sanitize_text_field($data['give_first_name']) : $old_user_data->first_name; |
|
433 | + $last_name = isset($data['give_last_name']) ? sanitize_text_field($data['give_last_name']) : $old_user_data->last_name; |
|
434 | + $company_name = ! empty($data['give_company_name']) ? sanitize_text_field($data['give_company_name']) : $old_company_name; |
|
435 | + $email = isset($data['give_email']) ? sanitize_email($data['give_email']) : $old_user_data->user_email; |
|
436 | + $password = ! empty($data['give_new_user_pass1']) ? $data['give_new_user_pass1'] : ''; |
|
437 | + $confirm_password = ! empty($data['give_new_user_pass2']) ? $data['give_new_user_pass2'] : ''; |
|
438 | 438 | |
439 | 439 | $userdata = array( |
440 | 440 | 'ID' => $user_id, |
@@ -454,60 +454,60 @@ discard block |
||
454 | 454 | * @param int $user_id The ID of the user. |
455 | 455 | * @param array $userdata User info, including ID, first name, last name, display name and email. |
456 | 456 | */ |
457 | - do_action( 'give_pre_update_user_profile', $user_id, $userdata ); |
|
457 | + do_action('give_pre_update_user_profile', $user_id, $userdata); |
|
458 | 458 | |
459 | 459 | // Make sure to validate first name of existing donors. |
460 | - if ( empty( $first_name ) ) { |
|
460 | + if (empty($first_name)) { |
|
461 | 461 | // Empty First Name. |
462 | - give_set_error( 'empty_first_name', __( 'Please enter your first name.', 'give' ) ); |
|
462 | + give_set_error('empty_first_name', __('Please enter your first name.', 'give')); |
|
463 | 463 | } |
464 | 464 | |
465 | 465 | // Make sure to validate passwords for existing Donors. |
466 | - give_validate_user_password( $password, $confirm_password ); |
|
466 | + give_validate_user_password($password, $confirm_password); |
|
467 | 467 | |
468 | - if ( empty( $email ) ) { |
|
468 | + if (empty($email)) { |
|
469 | 469 | // Make sure email should not be empty. |
470 | - give_set_error( 'email_empty', __( 'The email you entered is empty.', 'give' ) ); |
|
470 | + give_set_error('email_empty', __('The email you entered is empty.', 'give')); |
|
471 | 471 | |
472 | - } elseif ( ! is_email( $email ) ) { |
|
472 | + } elseif ( ! is_email($email)) { |
|
473 | 473 | // Make sure email should be valid. |
474 | - give_set_error( 'email_not_valid', __( 'The email you entered is not valid. Please use another', 'give' ) ); |
|
474 | + give_set_error('email_not_valid', __('The email you entered is not valid. Please use another', 'give')); |
|
475 | 475 | |
476 | - } elseif ( $email != $old_user_data->user_email ) { |
|
476 | + } elseif ($email != $old_user_data->user_email) { |
|
477 | 477 | // Make sure the new email doesn't belong to another user. |
478 | - if ( email_exists( $email ) ) { |
|
479 | - give_set_error( 'user_email_exists', __( 'The email you entered belongs to another user. Please use another.', 'give' ) ); |
|
480 | - } elseif ( Give()->donors->get_donor_by( 'email', $email ) ) { |
|
478 | + if (email_exists($email)) { |
|
479 | + give_set_error('user_email_exists', __('The email you entered belongs to another user. Please use another.', 'give')); |
|
480 | + } elseif (Give()->donors->get_donor_by('email', $email)) { |
|
481 | 481 | // Make sure the new email doesn't belong to another user. |
482 | - give_set_error( 'donor_email_exists', __( 'The email you entered belongs to another donor. Please use another.', 'give' ) ); |
|
482 | + give_set_error('donor_email_exists', __('The email you entered belongs to another donor. Please use another.', 'give')); |
|
483 | 483 | } |
484 | 484 | } |
485 | 485 | |
486 | 486 | // Check for errors. |
487 | 487 | $errors = give_get_errors(); |
488 | 488 | |
489 | - if ( $errors ) { |
|
489 | + if ($errors) { |
|
490 | 490 | // Send back to the profile editor if there are errors. |
491 | - wp_redirect( $data['give_redirect'] ); |
|
491 | + wp_redirect($data['give_redirect']); |
|
492 | 492 | give_die(); |
493 | 493 | } |
494 | 494 | |
495 | 495 | // Update Donor First Name and Last Name. |
496 | - Give()->donors->update( $donor->id, array( |
|
497 | - 'name' => trim( "{$first_name} {$last_name}" ), |
|
498 | - ) ); |
|
499 | - Give()->donor_meta->update_meta( $donor->id, '_give_donor_first_name', $first_name ); |
|
500 | - Give()->donor_meta->update_meta( $donor->id, '_give_donor_last_name', $last_name ); |
|
501 | - Give()->donor_meta->update_meta( $donor->id, '_give_donor_company', $company_name ); |
|
496 | + Give()->donors->update($donor->id, array( |
|
497 | + 'name' => trim("{$first_name} {$last_name}"), |
|
498 | + )); |
|
499 | + Give()->donor_meta->update_meta($donor->id, '_give_donor_first_name', $first_name); |
|
500 | + Give()->donor_meta->update_meta($donor->id, '_give_donor_last_name', $last_name); |
|
501 | + Give()->donor_meta->update_meta($donor->id, '_give_donor_company', $company_name); |
|
502 | 502 | |
503 | 503 | $current_user = wp_get_current_user(); |
504 | 504 | |
505 | 505 | // Compares new values with old values to detect change in values. |
506 | - $email_update = ( $email !== $current_user->user_email ) ? true : false; |
|
507 | - $display_name_update = ( $display_name !== $current_user->display_name ) ? true : false; |
|
508 | - $first_name_update = ( $first_name !== $current_user->first_name ) ? true : false; |
|
509 | - $last_name_update = ( $last_name !== $current_user->last_name ) ? true : false; |
|
510 | - $company_name_update = ( $company_name !== $old_company_name ) ? true : false; |
|
506 | + $email_update = ($email !== $current_user->user_email) ? true : false; |
|
507 | + $display_name_update = ($display_name !== $current_user->display_name) ? true : false; |
|
508 | + $first_name_update = ($first_name !== $current_user->first_name) ? true : false; |
|
509 | + $last_name_update = ($last_name !== $current_user->last_name) ? true : false; |
|
510 | + $company_name_update = ($company_name !== $old_company_name) ? true : false; |
|
511 | 511 | $update_code = 0; |
512 | 512 | |
513 | 513 | /** |
@@ -515,35 +515,35 @@ discard block |
||
515 | 515 | * |
516 | 516 | * @var boolean |
517 | 517 | */ |
518 | - $profile_update = ( $email_update || $display_name_update || $first_name_update || $last_name_update || $company_name_update ); |
|
518 | + $profile_update = ($email_update || $display_name_update || $first_name_update || $last_name_update || $company_name_update); |
|
519 | 519 | |
520 | 520 | /** |
521 | 521 | * True if password fields are filled. |
522 | 522 | * |
523 | 523 | * @var boolean |
524 | 524 | */ |
525 | - $password_update = ( ! empty( $password ) && ! empty( $confirm_password ) ); |
|
525 | + $password_update = ( ! empty($password) && ! empty($confirm_password)); |
|
526 | 526 | |
527 | - if ( $profile_update ) { |
|
527 | + if ($profile_update) { |
|
528 | 528 | |
529 | 529 | // If only profile fields are updated. |
530 | 530 | $update_code = '1'; |
531 | 531 | |
532 | - if ( $password_update ) { |
|
532 | + if ($password_update) { |
|
533 | 533 | |
534 | 534 | // If profile fields AND password both are updated. |
535 | 535 | $update_code = '2'; |
536 | 536 | } |
537 | - } elseif ( $password_update ) { |
|
537 | + } elseif ($password_update) { |
|
538 | 538 | |
539 | 539 | // If only password is updated. |
540 | 540 | $update_code = '3'; |
541 | 541 | } |
542 | 542 | |
543 | 543 | // Update the user. |
544 | - $updated = wp_update_user( $userdata ); |
|
544 | + $updated = wp_update_user($userdata); |
|
545 | 545 | |
546 | - if ( $updated ) { |
|
546 | + if ($updated) { |
|
547 | 547 | |
548 | 548 | /** |
549 | 549 | * Fires after updating user profile. |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | * @param int $user_id The ID of the user. |
554 | 554 | * @param array $userdata User info, including ID, first name, last name, display name and email. |
555 | 555 | */ |
556 | - do_action( 'give_user_profile_updated', $user_id, $userdata ); |
|
556 | + do_action('give_user_profile_updated', $user_id, $userdata); |
|
557 | 557 | |
558 | 558 | $profile_edit_redirect_args = array( |
559 | 559 | 'updated' => 'true', |
@@ -564,10 +564,10 @@ discard block |
||
564 | 564 | * Update codes '2' and '3' indicate a password change. |
565 | 565 | * If the password is changed, then logout and redirect to the same page. |
566 | 566 | */ |
567 | - if ( '2' === $update_code || '3' === $update_code ) { |
|
568 | - wp_logout( wp_redirect( add_query_arg( $profile_edit_redirect_args, $data['give_redirect'] ) ) ); |
|
567 | + if ('2' === $update_code || '3' === $update_code) { |
|
568 | + wp_logout(wp_redirect(add_query_arg($profile_edit_redirect_args, $data['give_redirect']))); |
|
569 | 569 | } else { |
570 | - wp_redirect( add_query_arg( $profile_edit_redirect_args, $data['give_redirect'] ) ); |
|
570 | + wp_redirect(add_query_arg($profile_edit_redirect_args, $data['give_redirect'])); |
|
571 | 571 | } |
572 | 572 | |
573 | 573 | give_die(); |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | return false; |
577 | 577 | } |
578 | 578 | |
579 | -add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' ); |
|
579 | +add_action('give_edit_user_profile', 'give_process_profile_editor_updates'); |
|
580 | 580 | |
581 | 581 | /** |
582 | 582 | * Give totals Shortcode. |
@@ -589,24 +589,24 @@ discard block |
||
589 | 589 | * |
590 | 590 | * @return string |
591 | 591 | */ |
592 | -function give_totals_shortcode( $atts ) { |
|
593 | - $total = get_option( 'give_earnings_total', false ); |
|
592 | +function give_totals_shortcode($atts) { |
|
593 | + $total = get_option('give_earnings_total', false); |
|
594 | 594 | |
595 | - $message = apply_filters( 'give_totals_message', __( 'Hey! We\'ve raised {total} of the {total_goal} we are trying to raise for this campaign!', 'give' ) ); |
|
595 | + $message = apply_filters('give_totals_message', __('Hey! We\'ve raised {total} of the {total_goal} we are trying to raise for this campaign!', 'give')); |
|
596 | 596 | |
597 | - $atts = shortcode_atts( array( |
|
597 | + $atts = shortcode_atts(array( |
|
598 | 598 | 'total_goal' => 0, // integer |
599 | 599 | 'ids' => 0, // integer|array |
600 | 600 | 'cats' => 0, // integer|array |
601 | 601 | 'tags' => 0, // integer|array |
602 | 602 | 'message' => $message, |
603 | 603 | 'link' => '', // URL |
604 | - 'link_text' => __( 'Donate Now', 'give' ), // string, |
|
604 | + 'link_text' => __('Donate Now', 'give'), // string, |
|
605 | 605 | 'progress_bar' => true, // boolean |
606 | - ), $atts, 'give_totals' ); |
|
606 | + ), $atts, 'give_totals'); |
|
607 | 607 | |
608 | 608 | // Total Goal. |
609 | - $total_goal = give_maybe_sanitize_amount( $atts['total_goal'] ); |
|
609 | + $total_goal = give_maybe_sanitize_amount($atts['total_goal']); |
|
610 | 610 | |
611 | 611 | /** |
612 | 612 | * Give Action fire before the shortcode is rendering is started. |
@@ -615,14 +615,14 @@ discard block |
||
615 | 615 | * |
616 | 616 | * @param array $atts shortcode attribute. |
617 | 617 | */ |
618 | - do_action( 'give_totals_goal_shortcode_before_render', $atts ); |
|
618 | + do_action('give_totals_goal_shortcode_before_render', $atts); |
|
619 | 619 | |
620 | 620 | // Build query based on cat, tag and Form ids. |
621 | - if ( ! empty( $atts['cats'] ) || ! empty( $atts['tags'] ) || ! empty( $atts['ids'] ) ) { |
|
621 | + if ( ! empty($atts['cats']) || ! empty($atts['tags']) || ! empty($atts['ids'])) { |
|
622 | 622 | |
623 | 623 | $form_ids = array(); |
624 | - if ( ! empty( $atts['ids'] ) ) { |
|
625 | - $form_ids = array_filter( array_map( 'trim', explode( ',', $atts['ids'] ) ) ); |
|
624 | + if ( ! empty($atts['ids'])) { |
|
625 | + $form_ids = array_filter(array_map('trim', explode(',', $atts['ids']))); |
|
626 | 626 | } |
627 | 627 | |
628 | 628 | /** |
@@ -636,23 +636,23 @@ discard block |
||
636 | 636 | 'post_type' => 'give_forms', |
637 | 637 | 'post_status' => 'publish', |
638 | 638 | 'post__in' => $form_ids, |
639 | - 'posts_per_page' => - 1, |
|
639 | + 'posts_per_page' => -1, |
|
640 | 640 | 'fields' => 'ids', |
641 | 641 | 'tax_query' => array( |
642 | 642 | 'relation' => 'AND', |
643 | 643 | ), |
644 | 644 | ); |
645 | 645 | |
646 | - if ( ! empty( $atts['cats'] ) ) { |
|
647 | - $cats = array_filter( array_map( 'trim', explode( ',', $atts['cats'] ) ) ); |
|
646 | + if ( ! empty($atts['cats'])) { |
|
647 | + $cats = array_filter(array_map('trim', explode(',', $atts['cats']))); |
|
648 | 648 | $form_args['tax_query'][] = array( |
649 | 649 | 'taxonomy' => 'give_forms_category', |
650 | 650 | 'terms' => $cats, |
651 | 651 | ); |
652 | 652 | } |
653 | 653 | |
654 | - if ( ! empty( $atts['tags'] ) ) { |
|
655 | - $tags = array_filter( array_map( 'trim', explode( ',', $atts['tags'] ) ) ); |
|
654 | + if ( ! empty($atts['tags'])) { |
|
655 | + $tags = array_filter(array_map('trim', explode(',', $atts['tags']))); |
|
656 | 656 | $form_args['tax_query'][] = array( |
657 | 657 | 'taxonomy' => 'give_forms_tag', |
658 | 658 | 'terms' => $tags, |
@@ -668,15 +668,15 @@ discard block |
||
668 | 668 | * |
669 | 669 | * @return array $form_args WP query argument for Total Goal. |
670 | 670 | */ |
671 | - $form_args = (array) apply_filters( 'give_totals_goal_shortcode_query_args', $form_args ); |
|
671 | + $form_args = (array) apply_filters('give_totals_goal_shortcode_query_args', $form_args); |
|
672 | 672 | |
673 | - $forms = new WP_Query( $form_args ); |
|
673 | + $forms = new WP_Query($form_args); |
|
674 | 674 | |
675 | - if ( isset( $forms->posts ) ) { |
|
675 | + if (isset($forms->posts)) { |
|
676 | 676 | $total = 0; |
677 | - foreach ( $forms->posts as $post ) { |
|
678 | - $form_earning = give_get_meta( $post, '_give_form_earnings', true ); |
|
679 | - $form_earning = ! empty( $form_earning ) ? $form_earning : 0; |
|
677 | + foreach ($forms->posts as $post) { |
|
678 | + $form_earning = give_get_meta($post, '_give_form_earnings', true); |
|
679 | + $form_earning = ! empty($form_earning) ? $form_earning : 0; |
|
680 | 680 | |
681 | 681 | /** |
682 | 682 | * Update Form earnings. |
@@ -686,7 +686,7 @@ discard block |
||
686 | 686 | * @param int $post Form ID. |
687 | 687 | * @param string $form_earning Total earning of Form. |
688 | 688 | */ |
689 | - $total += apply_filters( 'give_totals_form_earning', $form_earning, $post ); |
|
689 | + $total += apply_filters('give_totals_form_earning', $form_earning, $post); |
|
690 | 690 | } |
691 | 691 | } |
692 | 692 | |
@@ -694,23 +694,23 @@ discard block |
||
694 | 694 | |
695 | 695 | // Append link with text. |
696 | 696 | $donate_link = ''; |
697 | - if ( ! empty( $atts['link'] ) ) { |
|
698 | - $donate_link = sprintf( ' <a class="give-totals-text-link" href="%1$s">%2$s</a>', esc_url( $atts['link'] ), esc_html( $atts['link_text'] ) ); |
|
697 | + if ( ! empty($atts['link'])) { |
|
698 | + $donate_link = sprintf(' <a class="give-totals-text-link" href="%1$s">%2$s</a>', esc_url($atts['link']), esc_html($atts['link_text'])); |
|
699 | 699 | } |
700 | 700 | |
701 | 701 | // Replace {total} in message. |
702 | - $message = str_replace( '{total}', give_currency_filter( |
|
703 | - give_format_amount( $total, |
|
704 | - array( 'sanitize' => false ) |
|
702 | + $message = str_replace('{total}', give_currency_filter( |
|
703 | + give_format_amount($total, |
|
704 | + array('sanitize' => false) |
|
705 | 705 | ) |
706 | - ), esc_html( $atts['message'] ) ); |
|
706 | + ), esc_html($atts['message'])); |
|
707 | 707 | |
708 | 708 | // Replace {total_goal} in message. |
709 | - $message = str_replace( '{total_goal}', give_currency_filter( |
|
710 | - give_format_amount( $total_goal, |
|
711 | - array( 'sanitize' => true ) |
|
709 | + $message = str_replace('{total_goal}', give_currency_filter( |
|
710 | + give_format_amount($total_goal, |
|
711 | + array('sanitize' => true) |
|
712 | 712 | ) |
713 | - ), $message ); |
|
713 | + ), $message); |
|
714 | 714 | |
715 | 715 | /** |
716 | 716 | * Update Give totals shortcode output. |
@@ -720,19 +720,19 @@ discard block |
||
720 | 720 | * @param string $message Shortcode Message. |
721 | 721 | * @param array $atts ShortCode attributes. |
722 | 722 | */ |
723 | - $message = apply_filters( 'give_totals_shortcode_message', $message, $atts ); |
|
723 | + $message = apply_filters('give_totals_shortcode_message', $message, $atts); |
|
724 | 724 | |
725 | 725 | ob_start(); |
726 | 726 | ?> |
727 | 727 | <div class="give-totals-shortcode-wrap"> |
728 | 728 | <?php |
729 | 729 | // Show Progress Bar if progress_bar set true. |
730 | - $show_progress_bar = isset( $atts['progress_bar'] ) ? filter_var( $atts['progress_bar'], FILTER_VALIDATE_BOOLEAN ) : true; |
|
731 | - if ( $show_progress_bar ) { |
|
732 | - give_show_goal_totals_progress( $total, $total_goal ); |
|
730 | + $show_progress_bar = isset($atts['progress_bar']) ? filter_var($atts['progress_bar'], FILTER_VALIDATE_BOOLEAN) : true; |
|
731 | + if ($show_progress_bar) { |
|
732 | + give_show_goal_totals_progress($total, $total_goal); |
|
733 | 733 | } |
734 | 734 | |
735 | - echo sprintf( $message ) . $donate_link; |
|
735 | + echo sprintf($message).$donate_link; |
|
736 | 736 | ?> |
737 | 737 | </div> |
738 | 738 | <?php |
@@ -747,7 +747,7 @@ discard block |
||
747 | 747 | * @param array $atts shortcode attribute. |
748 | 748 | * @param string $give_totals_output shortcode output. |
749 | 749 | */ |
750 | - do_action( 'give_totals_goal_shortcode_after_render', $atts, $give_totals_output ); |
|
750 | + do_action('give_totals_goal_shortcode_after_render', $atts, $give_totals_output); |
|
751 | 751 | |
752 | 752 | /** |
753 | 753 | * Give Totals Shortcode output. |
@@ -756,11 +756,11 @@ discard block |
||
756 | 756 | * |
757 | 757 | * @param string $give_totals_output |
758 | 758 | */ |
759 | - return apply_filters( 'give_totals_shortcode_output', $give_totals_output ); |
|
759 | + return apply_filters('give_totals_shortcode_output', $give_totals_output); |
|
760 | 760 | |
761 | 761 | } |
762 | 762 | |
763 | -add_shortcode( 'give_totals', 'give_totals_shortcode' ); |
|
763 | +add_shortcode('give_totals', 'give_totals_shortcode'); |
|
764 | 764 | |
765 | 765 | |
766 | 766 | /** |
@@ -791,11 +791,11 @@ discard block |
||
791 | 791 | * } |
792 | 792 | * @return string|bool The markup of the form grid or false. |
793 | 793 | */ |
794 | -function give_form_grid_shortcode( $atts ) { |
|
794 | +function give_form_grid_shortcode($atts) { |
|
795 | 795 | |
796 | 796 | $give_settings = give_get_settings(); |
797 | 797 | |
798 | - $atts = shortcode_atts( array( |
|
798 | + $atts = shortcode_atts(array( |
|
799 | 799 | 'forms_per_page' => 12, |
800 | 800 | 'paged' => true, |
801 | 801 | 'ids' => '', |
@@ -812,11 +812,11 @@ discard block |
||
812 | 812 | 'excerpt_length' => 16, |
813 | 813 | 'display_style' => 'modal_reveal', |
814 | 814 | 'status' => '', // open or closed |
815 | - ), $atts ); |
|
815 | + ), $atts); |
|
816 | 816 | |
817 | 817 | // Validate integer attributes. |
818 | - $atts['forms_per_page'] = intval( $atts['forms_per_page'] ); |
|
819 | - $atts['excerpt_length'] = intval( $atts['excerpt_length'] ); |
|
818 | + $atts['forms_per_page'] = intval($atts['forms_per_page']); |
|
819 | + $atts['excerpt_length'] = intval($atts['excerpt_length']); |
|
820 | 820 | |
821 | 821 | // Validate boolean attributes. |
822 | 822 | $boolean_attributes = array( |
@@ -827,8 +827,8 @@ discard block |
||
827 | 827 | 'show_featured_image', |
828 | 828 | ); |
829 | 829 | |
830 | - foreach ( $boolean_attributes as $att ) { |
|
831 | - $atts[ $att ] = filter_var( $atts[ $att ], FILTER_VALIDATE_BOOLEAN ); |
|
830 | + foreach ($boolean_attributes as $att) { |
|
831 | + $atts[$att] = filter_var($atts[$att], FILTER_VALIDATE_BOOLEAN); |
|
832 | 832 | } |
833 | 833 | |
834 | 834 | // Set default form query args. |
@@ -842,9 +842,9 @@ discard block |
||
842 | 842 | ); |
843 | 843 | |
844 | 844 | // Filter results of form grid based on form status. |
845 | - $form_closed_status = trim( $atts['status'] ); |
|
845 | + $form_closed_status = trim($atts['status']); |
|
846 | 846 | |
847 | - if ( ! empty( $form_closed_status ) ) { |
|
847 | + if ( ! empty($form_closed_status)) { |
|
848 | 848 | $form_args['meta_query'] = array( |
849 | 849 | array( |
850 | 850 | 'key' => '_give_form_status', |
@@ -854,25 +854,25 @@ discard block |
||
854 | 854 | } |
855 | 855 | |
856 | 856 | // Maybe add pagination. |
857 | - if ( true === $atts['paged'] ) { |
|
858 | - $form_args['paged'] = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1; |
|
857 | + if (true === $atts['paged']) { |
|
858 | + $form_args['paged'] = get_query_var('paged') ? get_query_var('paged') : 1; |
|
859 | 859 | } |
860 | 860 | |
861 | 861 | // Maybe filter forms by IDs. |
862 | - if ( ! empty( $atts['ids'] ) ) { |
|
863 | - $form_args['post__in'] = array_filter( array_map( 'trim', explode( ',', $atts['ids'] ) ) ); |
|
862 | + if ( ! empty($atts['ids'])) { |
|
863 | + $form_args['post__in'] = array_filter(array_map('trim', explode(',', $atts['ids']))); |
|
864 | 864 | } |
865 | 865 | |
866 | 866 | // Convert comma-separated form IDs into array. |
867 | - if ( ! empty( $atts['exclude'] ) ) { |
|
868 | - $form_args['post__not_in'] = array_filter( array_map( function( $item ) { |
|
869 | - return intval( trim( $item ) ); |
|
870 | - }, explode( ',', $atts['exclude'] ) ) ); |
|
867 | + if ( ! empty($atts['exclude'])) { |
|
868 | + $form_args['post__not_in'] = array_filter(array_map(function($item) { |
|
869 | + return intval(trim($item)); |
|
870 | + }, explode(',', $atts['exclude']))); |
|
871 | 871 | } |
872 | 872 | |
873 | 873 | // Maybe filter by form category. |
874 | - if ( ! empty( $atts['cats'] ) ) { |
|
875 | - $cats = array_filter( array_map( 'trim', explode( ',', $atts['cats'] ) ) ); |
|
874 | + if ( ! empty($atts['cats'])) { |
|
875 | + $cats = array_filter(array_map('trim', explode(',', $atts['cats']))); |
|
876 | 876 | $tax_query = array( |
877 | 877 | 'taxonomy' => 'give_forms_category', |
878 | 878 | 'terms' => $cats, |
@@ -881,8 +881,8 @@ discard block |
||
881 | 881 | } |
882 | 882 | |
883 | 883 | // Maybe filter by form tag. |
884 | - if ( ! empty( $atts['tags'] ) ) { |
|
885 | - $tags = array_filter( array_map( 'trim', explode( ',', $atts['tags'] ) ) ); |
|
884 | + if ( ! empty($atts['tags'])) { |
|
885 | + $tags = array_filter(array_map('trim', explode(',', $atts['tags']))); |
|
886 | 886 | $tax_query = array( |
887 | 887 | 'taxonomy' => 'give_forms_tag', |
888 | 888 | 'terms' => $tags, |
@@ -891,24 +891,24 @@ discard block |
||
891 | 891 | } |
892 | 892 | |
893 | 893 | // Query to output donation forms. |
894 | - $form_query = new WP_Query( $form_args ); |
|
894 | + $form_query = new WP_Query($form_args); |
|
895 | 895 | |
896 | - if ( $form_query->have_posts() ) { |
|
896 | + if ($form_query->have_posts()) { |
|
897 | 897 | ob_start(); |
898 | 898 | |
899 | - add_filter( 'add_give_goal_progress_class', 'add_give_goal_progress_class', 10, 1 ); |
|
900 | - add_filter( 'add_give_goal_progress_bar_class', 'add_give_goal_progress_bar_class', 10, 1 ); |
|
901 | - add_filter( 'give_form_wrap_classes', 'add_class_for_form_grid', 10, 3 ); |
|
902 | - add_action( 'give_donation_form_top', 'give_is_form_grid_page_hidden_field', 10, 3 ); |
|
899 | + add_filter('add_give_goal_progress_class', 'add_give_goal_progress_class', 10, 1); |
|
900 | + add_filter('add_give_goal_progress_bar_class', 'add_give_goal_progress_bar_class', 10, 1); |
|
901 | + add_filter('give_form_wrap_classes', 'add_class_for_form_grid', 10, 3); |
|
902 | + add_action('give_donation_form_top', 'give_is_form_grid_page_hidden_field', 10, 3); |
|
903 | 903 | |
904 | 904 | echo '<div class="give-wrap">'; |
905 | - echo '<div class="give-grid give-grid--' . esc_attr( $atts['columns'] ) . '">'; |
|
905 | + echo '<div class="give-grid give-grid--'.esc_attr($atts['columns']).'">'; |
|
906 | 906 | |
907 | - while ( $form_query->have_posts() ) { |
|
907 | + while ($form_query->have_posts()) { |
|
908 | 908 | $form_query->the_post(); |
909 | 909 | |
910 | 910 | // Give/templates/shortcode-form-grid.php. |
911 | - give_get_template( 'shortcode-form-grid', array( $give_settings, $atts ) ); |
|
911 | + give_get_template('shortcode-form-grid', array($give_settings, $atts)); |
|
912 | 912 | |
913 | 913 | } |
914 | 914 | |
@@ -916,28 +916,28 @@ discard block |
||
916 | 916 | |
917 | 917 | echo '</div><!-- .give-grid -->'; |
918 | 918 | |
919 | - remove_filter( 'add_give_goal_progress_class', 'add_give_goal_progress_class' ); |
|
920 | - remove_filter( 'add_give_goal_progress_bar_class', 'add_give_goal_progress_bar_class' ); |
|
921 | - remove_filter( 'give_form_wrap_classes', 'add_class_for_form_grid', 10 ); |
|
922 | - remove_action( 'give_donation_form_top', 'give_is_form_grid_page_hidden_field', 10 ); |
|
919 | + remove_filter('add_give_goal_progress_class', 'add_give_goal_progress_class'); |
|
920 | + remove_filter('add_give_goal_progress_bar_class', 'add_give_goal_progress_bar_class'); |
|
921 | + remove_filter('give_form_wrap_classes', 'add_class_for_form_grid', 10); |
|
922 | + remove_action('give_donation_form_top', 'give_is_form_grid_page_hidden_field', 10); |
|
923 | 923 | |
924 | - if ( false !== $atts['paged'] ) { |
|
924 | + if (false !== $atts['paged']) { |
|
925 | 925 | $paginate_args = array( |
926 | - 'current' => max( 1, get_query_var( 'paged' ) ), |
|
926 | + 'current' => max(1, get_query_var('paged')), |
|
927 | 927 | 'total' => $form_query->max_num_pages, |
928 | 928 | 'show_all' => false, |
929 | 929 | 'end_size' => 1, |
930 | 930 | 'mid_size' => 2, |
931 | 931 | 'prev_next' => true, |
932 | - 'prev_text' => __( '« Previous', 'give' ), |
|
933 | - 'next_text' => __( 'Next »', 'give' ), |
|
932 | + 'prev_text' => __('« Previous', 'give'), |
|
933 | + 'next_text' => __('Next »', 'give'), |
|
934 | 934 | 'type' => 'plain', |
935 | 935 | 'add_args' => false, |
936 | 936 | ); |
937 | 937 | |
938 | 938 | printf( |
939 | 939 | '<div class="give-page-numbers">%s</div>', |
940 | - paginate_links( $paginate_args ) |
|
940 | + paginate_links($paginate_args) |
|
941 | 941 | ); |
942 | 942 | } |
943 | 943 | echo '</div><!-- .give-wrap -->'; |
@@ -946,4 +946,4 @@ discard block |
||
946 | 946 | } |
947 | 947 | } |
948 | 948 | |
949 | -add_shortcode( 'give_form_grid', 'give_form_grid_shortcode' ); |
|
949 | +add_shortcode('give_form_grid', 'give_form_grid_shortcode'); |
@@ -6,29 +6,29 @@ discard block |
||
6 | 6 | global $give_receipt_args, $payment; |
7 | 7 | |
8 | 8 | // Validation: Ensure $payment var is set. |
9 | -if ( empty( $payment ) ) { |
|
10 | - $payment = ! empty( $give_receipt_args['id'] ) ? get_post( $give_receipt_args['id'] ) : 0; |
|
9 | +if (empty($payment)) { |
|
10 | + $payment = ! empty($give_receipt_args['id']) ? get_post($give_receipt_args['id']) : 0; |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | // Double-Validation: Check for $payment global. |
14 | -if ( empty( $payment ) ) { |
|
15 | - Give()->notices->print_frontend_notice( __( 'The specified receipt ID appears to be invalid.', 'give' ) ); |
|
14 | +if (empty($payment)) { |
|
15 | + Give()->notices->print_frontend_notice(__('The specified receipt ID appears to be invalid.', 'give')); |
|
16 | 16 | |
17 | 17 | return; |
18 | 18 | } |
19 | 19 | |
20 | 20 | $donation_id = $payment->ID; |
21 | -$donation_number = Give()->seq_donation_number->get_serial_code( $payment->ID ); |
|
22 | -$form_id = give_get_payment_meta( $donation_id, '_give_payment_form_id', true ); |
|
23 | -$donation = give_get_donation_form_title( $donation_id ); |
|
24 | -$user = give_get_payment_meta_user_info( $donation_id ); |
|
25 | -$email = give_get_payment_user_email( $donation_id ); |
|
21 | +$donation_number = Give()->seq_donation_number->get_serial_code($payment->ID); |
|
22 | +$form_id = give_get_payment_meta($donation_id, '_give_payment_form_id', true); |
|
23 | +$donation = give_get_donation_form_title($donation_id); |
|
24 | +$user = give_get_payment_meta_user_info($donation_id); |
|
25 | +$email = give_get_payment_user_email($donation_id); |
|
26 | 26 | $status = $payment->post_status; |
27 | -$status_label = give_get_payment_status( $payment, true ); |
|
28 | -$company_name = give_get_payment_meta( $donation_id, '_give_donation_company', true ); |
|
27 | +$status_label = give_get_payment_status($payment, true); |
|
28 | +$company_name = give_get_payment_meta($donation_id, '_give_donation_company', true); |
|
29 | 29 | |
30 | 30 | // Update donor name, if title prefix is set. |
31 | -$full_name = give_get_donor_name_with_title_prefixes( $user['title'], "{$user['first_name']} {$user['last_name']}" ); |
|
31 | +$full_name = give_get_donor_name_with_title_prefixes($user['title'], "{$user['first_name']} {$user['last_name']}"); |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Generate Donation Receipt Arguments. |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @since 1.8.8 |
40 | 40 | */ |
41 | 41 | $give_receipt_args['donation_receipt']['donor'] = array( |
42 | - 'name' => __( 'Donor', 'give' ), |
|
42 | + 'name' => __('Donor', 'give'), |
|
43 | 43 | 'value' => $full_name, |
44 | 44 | 'display' => $give_receipt_args['donor'], |
45 | 45 | ); |
@@ -54,51 +54,51 @@ discard block |
||
54 | 54 | * @return bool show/hide company name in donation receipt page. |
55 | 55 | */ |
56 | 56 | $give_receipt_args['donation_receipt']['company_name'] = array( |
57 | - 'name' => __( 'Company Name', 'give' ), |
|
58 | - 'value' => esc_attr( $company_name ), |
|
57 | + 'name' => __('Company Name', 'give'), |
|
58 | + 'value' => esc_attr($company_name), |
|
59 | 59 | // Do not show company field if empty |
60 | - 'display' => empty( $company_name ) ? false : $give_receipt_args['company_name'], |
|
60 | + 'display' => empty($company_name) ? false : $give_receipt_args['company_name'], |
|
61 | 61 | ); |
62 | 62 | |
63 | 63 | $give_receipt_args['donation_receipt']['date'] = array( |
64 | - 'name' => __( 'Date', 'give' ), |
|
65 | - 'value' => date_i18n( give_date_format(), strtotime( give_get_payment_completed_date( $donation_id ) ) ), |
|
64 | + 'name' => __('Date', 'give'), |
|
65 | + 'value' => date_i18n(give_date_format(), strtotime(give_get_payment_completed_date($donation_id))), |
|
66 | 66 | 'display' => $give_receipt_args['date'], |
67 | 67 | ); |
68 | 68 | |
69 | 69 | $give_receipt_args['donation_receipt']['total_donation'] = array( |
70 | - 'name' => __( 'Total Donation', 'give' ), |
|
71 | - 'value' => give_donation_amount( $donation_id, array( 'currency' => true, 'amount' => true, 'type' => 'receipt' ) ), |
|
70 | + 'name' => __('Total Donation', 'give'), |
|
71 | + 'value' => give_donation_amount($donation_id, array('currency' => true, 'amount' => true, 'type' => 'receipt')), |
|
72 | 72 | 'display' => $give_receipt_args['price'], |
73 | 73 | ); |
74 | 74 | |
75 | 75 | $give_receipt_args['donation_receipt']['donation'] = array( |
76 | - 'name' => __( 'Donation', 'give' ), |
|
76 | + 'name' => __('Donation', 'give'), |
|
77 | 77 | 'value' => $donation, |
78 | 78 | 'display' => true, |
79 | 79 | ); |
80 | 80 | |
81 | 81 | $give_receipt_args['donation_receipt']['donation_status'] = array( |
82 | - 'name' => __( 'Donation Status', 'give' ), |
|
83 | - 'value' => esc_attr( $status_label ), |
|
82 | + 'name' => __('Donation Status', 'give'), |
|
83 | + 'value' => esc_attr($status_label), |
|
84 | 84 | 'display' => $give_receipt_args['payment_status'], |
85 | 85 | ); |
86 | 86 | |
87 | 87 | $give_receipt_args['donation_receipt']['donation_id'] = array( |
88 | - 'name' => __( 'Donation ID', 'give' ), |
|
88 | + 'name' => __('Donation ID', 'give'), |
|
89 | 89 | 'value' => $donation_number, |
90 | 90 | 'display' => $give_receipt_args['payment_id'], |
91 | 91 | ); |
92 | 92 | |
93 | 93 | $give_receipt_args['donation_receipt']['payment_key'] = array( |
94 | - 'name' => __( 'Payment Key', 'give' ), |
|
95 | - 'value' => get_post_meta( $donation_id, '_give_payment_purchase_key', true ), |
|
94 | + 'name' => __('Payment Key', 'give'), |
|
95 | + 'value' => get_post_meta($donation_id, '_give_payment_purchase_key', true), |
|
96 | 96 | 'display' => $give_receipt_args['payment_key'], |
97 | 97 | ); |
98 | 98 | |
99 | 99 | $give_receipt_args['donation_receipt']['payment_method'] = array( |
100 | - 'name' => __( 'Payment Method', 'give' ), |
|
101 | - 'value' => give_get_gateway_checkout_label( give_get_payment_gateway( $donation_id ) ), |
|
100 | + 'name' => __('Payment Method', 'give'), |
|
101 | + 'value' => give_get_gateway_checkout_label(give_get_payment_gateway($donation_id)), |
|
102 | 102 | 'display' => $give_receipt_args['payment_method'], |
103 | 103 | ); |
104 | 104 | |
@@ -113,10 +113,10 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @since 1.8.8 |
115 | 115 | */ |
116 | -$give_receipt_args['donation_receipt'] = apply_filters( 'give_donation_receipt_args', $give_receipt_args['donation_receipt'], $donation_id, $form_id ); |
|
116 | +$give_receipt_args['donation_receipt'] = apply_filters('give_donation_receipt_args', $give_receipt_args['donation_receipt'], $donation_id, $form_id); |
|
117 | 117 | |
118 | 118 | // When the donation were made through offline donation, We won't show receipt and payment status though. |
119 | -if ( 'offline' === give_get_payment_gateway( $payment->ID ) && 'pending' === $status ) { |
|
119 | +if ('offline' === give_get_payment_gateway($payment->ID) && 'pending' === $status) { |
|
120 | 120 | |
121 | 121 | /** |
122 | 122 | * Before the offline donation receipt content starts. |
@@ -126,13 +126,13 @@ discard block |
||
126 | 126 | * @param Give_Payment $payment Donation payment object. |
127 | 127 | * @param array $give_receipt_args Receipt Arguments. |
128 | 128 | */ |
129 | - do_action( 'give_receipt_before_offline_payment', $payment, $give_receipt_args ); |
|
129 | + do_action('give_receipt_before_offline_payment', $payment, $give_receipt_args); |
|
130 | 130 | ?> |
131 | - <h2><?php echo apply_filters( 'give_receipt_offline_payment_heading', __( 'Your Donation is Almost Complete!', 'give' ) ); ?></h2> |
|
132 | - <div id="give_donation_receipt" class="<?php echo esc_attr( apply_filters( 'give_receipt_offline_payment_classes', 'give_receipt_offline_payment' ) ); ?>"> |
|
131 | + <h2><?php echo apply_filters('give_receipt_offline_payment_heading', __('Your Donation is Almost Complete!', 'give')); ?></h2> |
|
132 | + <div id="give_donation_receipt" class="<?php echo esc_attr(apply_filters('give_receipt_offline_payment_classes', 'give_receipt_offline_payment')); ?>"> |
|
133 | 133 | <?php |
134 | 134 | // Instruction for offline donation. |
135 | - $offline_instruction = give_get_offline_payment_instruction( $form_id, true ); |
|
135 | + $offline_instruction = give_get_offline_payment_instruction($form_id, true); |
|
136 | 136 | |
137 | 137 | /** |
138 | 138 | * Instruction for the offline donation. |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @param Give_Payment $payment Payment object. |
144 | 144 | * @param integer $form_id Donation form id. |
145 | 145 | */ |
146 | - echo apply_filters( 'give_receipt_offline_payment_instruction', $offline_instruction, $payment, $form_id ); |
|
146 | + echo apply_filters('give_receipt_offline_payment_instruction', $offline_instruction, $payment, $form_id); |
|
147 | 147 | ?> |
148 | 148 | </div> |
149 | 149 | <?php |
@@ -155,52 +155,52 @@ discard block |
||
155 | 155 | * @param Give_Payment $payment Donation payment object. |
156 | 156 | * @param array $give_receipt_args Receipt Arguments. |
157 | 157 | */ |
158 | - do_action( 'give_receipt_after_offline_payment', $payment, $give_receipt_args ); |
|
158 | + do_action('give_receipt_after_offline_payment', $payment, $give_receipt_args); |
|
159 | 159 | |
160 | 160 | return; |
161 | 161 | } |
162 | 162 | |
163 | 163 | // Show payment status notice based on shortcode attribute. |
164 | -if ( filter_var( $give_receipt_args['status_notice'], FILTER_VALIDATE_BOOLEAN ) ) { |
|
164 | +if (filter_var($give_receipt_args['status_notice'], FILTER_VALIDATE_BOOLEAN)) { |
|
165 | 165 | $notice_message = ''; |
166 | 166 | $notice_type = 'warning'; |
167 | 167 | |
168 | - switch ( $status ) { |
|
168 | + switch ($status) { |
|
169 | 169 | case 'publish': |
170 | - $notice_message = __( 'Payment Complete: Thank you for your donation.', 'give' ); |
|
170 | + $notice_message = __('Payment Complete: Thank you for your donation.', 'give'); |
|
171 | 171 | $notice_type = 'success'; |
172 | 172 | break; |
173 | 173 | case 'pending': |
174 | - $notice_message = __( 'Payment Pending: Your donation is currently processing.', 'give' ); |
|
174 | + $notice_message = __('Payment Pending: Your donation is currently processing.', 'give'); |
|
175 | 175 | $notice_type = 'warning'; |
176 | 176 | break; |
177 | 177 | case 'refunded': |
178 | - $notice_message = __( 'Payment Refunded: Your donation has been refunded.', 'give' ); |
|
178 | + $notice_message = __('Payment Refunded: Your donation has been refunded.', 'give'); |
|
179 | 179 | $notice_type = 'warning'; |
180 | 180 | break; |
181 | 181 | case 'preapproval': |
182 | - $notice_message = __( 'Payment Preapproved: Thank you for your donation.', 'give' ); |
|
182 | + $notice_message = __('Payment Preapproved: Thank you for your donation.', 'give'); |
|
183 | 183 | $notice_type = 'warning'; |
184 | 184 | break; |
185 | 185 | case 'failed': |
186 | - $notice_message = __( 'Payment Failed: Please contact the site owner for assistance.', 'give' ); |
|
186 | + $notice_message = __('Payment Failed: Please contact the site owner for assistance.', 'give'); |
|
187 | 187 | $notice_type = 'error'; |
188 | 188 | break; |
189 | 189 | case 'cancelled': |
190 | - $notice_message = __( 'Payment Cancelled: Your donation has been cancelled.', 'give' ); |
|
190 | + $notice_message = __('Payment Cancelled: Your donation has been cancelled.', 'give'); |
|
191 | 191 | $notice_type = 'error'; |
192 | 192 | break; |
193 | 193 | case 'abandoned': |
194 | - $notice_message = __( 'Payment Abandoned: This donation has not been completed.', 'give' ); |
|
194 | + $notice_message = __('Payment Abandoned: This donation has not been completed.', 'give'); |
|
195 | 195 | $notice_type = 'error'; |
196 | 196 | break; |
197 | 197 | case 'revoked': |
198 | - $notice_message = __( 'Payment Revoked: Please contact the site owner for assistance.', 'give' ); |
|
198 | + $notice_message = __('Payment Revoked: Please contact the site owner for assistance.', 'give'); |
|
199 | 199 | $notice_type = 'error'; |
200 | 200 | break; |
201 | 201 | } |
202 | 202 | |
203 | - if ( ! empty( $notice_message ) ) { |
|
203 | + if ( ! empty($notice_message)) { |
|
204 | 204 | /** |
205 | 205 | * Filters payment status notice for receipts. |
206 | 206 | * |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * @param string $status Payment status. |
216 | 216 | * @param int $donation_id Donation ID. |
217 | 217 | */ |
218 | - echo apply_filters( 'give_receipt_status_notice', Give()->notices->print_frontend_notice( $notice_message, false, $notice_type ), $id, $status, $donation_id ); |
|
218 | + echo apply_filters('give_receipt_status_notice', Give()->notices->print_frontend_notice($notice_message, false, $notice_type), $id, $status, $donation_id); |
|
219 | 219 | } |
220 | 220 | }// End if(). |
221 | 221 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * @param object $payment The payment object. |
230 | 230 | * @param array $give_receipt_args Receipt_argument. |
231 | 231 | */ |
232 | -do_action( 'give_payment_receipt_before_table', $payment, $give_receipt_args ); |
|
232 | +do_action('give_payment_receipt_before_table', $payment, $give_receipt_args); |
|
233 | 233 | ?> |
234 | 234 | |
235 | 235 | <table id="give_donation_receipt" class="give-table"> |
@@ -245,11 +245,11 @@ discard block |
||
245 | 245 | * @param object $payment The payment object. |
246 | 246 | * @param array $give_receipt_args Receipt_argument. |
247 | 247 | */ |
248 | - do_action( 'give_payment_receipt_header_before', $payment, $give_receipt_args ); |
|
248 | + do_action('give_payment_receipt_header_before', $payment, $give_receipt_args); |
|
249 | 249 | ?> |
250 | 250 | <tr> |
251 | 251 | <th scope="colgroup" colspan="2"> |
252 | - <span class="give-receipt-thead-text"><?php esc_html_e( 'Donation Receipt', 'give' ) ?></span> |
|
252 | + <span class="give-receipt-thead-text"><?php esc_html_e('Donation Receipt', 'give') ?></span> |
|
253 | 253 | </th> |
254 | 254 | </tr> |
255 | 255 | <?php |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | * @param object $payment The payment object. |
264 | 264 | * @param array $give_receipt_args Receipt_argument. |
265 | 265 | */ |
266 | - do_action( 'give_payment_receipt_header_after', $payment, $give_receipt_args ); |
|
266 | + do_action('give_payment_receipt_header_after', $payment, $give_receipt_args); |
|
267 | 267 | ?> |
268 | 268 | </thead> |
269 | 269 | |
@@ -279,11 +279,11 @@ discard block |
||
279 | 279 | * @param object $payment The payment object. |
280 | 280 | * @param array $give_receipt_args Receipt_argument. |
281 | 281 | */ |
282 | - do_action( 'give_payment_receipt_before', $payment, $give_receipt_args ); |
|
282 | + do_action('give_payment_receipt_before', $payment, $give_receipt_args); |
|
283 | 283 | ?> |
284 | 284 | |
285 | - <?php foreach ( $give_receipt_args['donation_receipt'] as $receipt_item ) { ?> |
|
286 | - <?php if ( filter_var( $receipt_item['display'], FILTER_VALIDATE_BOOLEAN ) ) : ?> |
|
285 | + <?php foreach ($give_receipt_args['donation_receipt'] as $receipt_item) { ?> |
|
286 | + <?php if (filter_var($receipt_item['display'], FILTER_VALIDATE_BOOLEAN)) : ?> |
|
287 | 287 | <tr> |
288 | 288 | <td scope="row"><strong><?php echo $receipt_item['name']; ?></strong></td> |
289 | 289 | <td><?php echo $receipt_item['value']; ?></td> |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | * @param object $payment The payment object. |
303 | 303 | * @param array $give_receipt_args Receipt_argument. |
304 | 304 | */ |
305 | - do_action( 'give_payment_receipt_after', $payment, $give_receipt_args ); |
|
305 | + do_action('give_payment_receipt_after', $payment, $give_receipt_args); |
|
306 | 306 | ?> |
307 | 307 | </tbody> |
308 | 308 | </table> |
@@ -318,5 +318,5 @@ discard block |
||
318 | 318 | * @param object $payment The payment object. |
319 | 319 | * @param array $give_receipt_args Receipt_argument. |
320 | 320 | */ |
321 | -do_action( 'give_payment_receipt_after_table', $payment, $give_receipt_args ); |
|
321 | +do_action('give_payment_receipt_after_table', $payment, $give_receipt_args); |
|
322 | 322 | ?> |
@@ -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 | |
@@ -26,14 +26,14 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return void |
28 | 28 | */ |
29 | -function give_email_donation_receipt( $payment_id, $admin_notice = true ) { |
|
29 | +function give_email_donation_receipt($payment_id, $admin_notice = true) { |
|
30 | 30 | /** |
31 | 31 | * Fire the action |
32 | 32 | */ |
33 | - do_action( 'give_donation-receipt_email_notification', $payment_id ); |
|
33 | + do_action('give_donation-receipt_email_notification', $payment_id); |
|
34 | 34 | |
35 | 35 | // If admin notifications are on, send the admin notice. |
36 | - if ( $admin_notice && give_is_setting_enabled( Give_Email_Notification::get_instance('new-donation' )->get_notification_status() ) ) { |
|
36 | + if ($admin_notice && give_is_setting_enabled(Give_Email_Notification::get_instance('new-donation')->get_notification_status())) { |
|
37 | 37 | /** |
38 | 38 | * Fires in the donation email receipt. |
39 | 39 | * |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @param int $payment_id Payment id. |
45 | 45 | * @param mixed $payment_data Payment meta data. |
46 | 46 | */ |
47 | - do_action( 'give_new-donation_email_notification', $payment_id, give_get_payment_meta( $payment_id ) ); |
|
47 | + do_action('give_new-donation_email_notification', $payment_id, give_get_payment_meta($payment_id)); |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @return void |
59 | 59 | */ |
60 | -function give_admin_email_notice( $payment_id ) { |
|
60 | +function give_admin_email_notice($payment_id) { |
|
61 | 61 | /** |
62 | 62 | * Fires in the donation email receipt. |
63 | 63 | * |
@@ -68,10 +68,10 @@ discard block |
||
68 | 68 | * @param int $payment_id Payment id. |
69 | 69 | * @param mixed $payment_data Payment meta data. |
70 | 70 | */ |
71 | - do_action( 'give_new-donation_email_notification', $payment_id ); |
|
71 | + do_action('give_new-donation_email_notification', $payment_id); |
|
72 | 72 | } |
73 | 73 | |
74 | -add_action( 'give_admin_donation_email', 'give_admin_email_notice' ); |
|
74 | +add_action('give_admin_donation_email', 'give_admin_email_notice'); |
|
75 | 75 | |
76 | 76 | |
77 | 77 | /** |
@@ -84,16 +84,16 @@ discard block |
||
84 | 84 | */ |
85 | 85 | function give_get_default_donation_notification_email() { |
86 | 86 | |
87 | - $default_email_body = __( 'Hi there,', 'give' ) . "\n\n"; |
|
88 | - $default_email_body .= __( 'This email is to inform you that a new donation has been made on your website:', 'give' ) . ' {site_url}' . ".\n\n"; |
|
89 | - $default_email_body .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {name}' . "\n"; |
|
90 | - $default_email_body .= '<strong>' . __( 'Donation:', 'give' ) . '</strong> {donation}' . "\n"; |
|
91 | - $default_email_body .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n"; |
|
92 | - $default_email_body .= '<strong>' . __( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n\n"; |
|
93 | - $default_email_body .= __( 'Thank you,', 'give' ) . "\n\n"; |
|
94 | - $default_email_body .= '{sitename}' . "\n"; |
|
87 | + $default_email_body = __('Hi there,', 'give')."\n\n"; |
|
88 | + $default_email_body .= __('This email is to inform you that a new donation has been made on your website:', 'give').' {site_url}'.".\n\n"; |
|
89 | + $default_email_body .= '<strong>'.__('Donor:', 'give').'</strong> {name}'."\n"; |
|
90 | + $default_email_body .= '<strong>'.__('Donation:', 'give').'</strong> {donation}'."\n"; |
|
91 | + $default_email_body .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n"; |
|
92 | + $default_email_body .= '<strong>'.__('Payment Method:', 'give').'</strong> {payment_method}'."\n\n"; |
|
93 | + $default_email_body .= __('Thank you,', 'give')."\n\n"; |
|
94 | + $default_email_body .= '{sitename}'."\n"; |
|
95 | 95 | |
96 | - return apply_filters( 'give_default_donation_notification_email', $default_email_body ); |
|
96 | + return apply_filters('give_default_donation_notification_email', $default_email_body); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | |
@@ -107,21 +107,21 @@ discard block |
||
107 | 107 | */ |
108 | 108 | function give_get_default_donation_receipt_email() { |
109 | 109 | |
110 | - $default_email_body = __( 'Dear', 'give' ) . " {name},\n\n"; |
|
111 | - $default_email_body .= __( 'Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give' ) . "\n\n"; |
|
112 | - $default_email_body .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n"; |
|
113 | - $default_email_body .= '<strong>' . __( 'Donation:', 'give' ) . '</strong> {donation}' . "\n"; |
|
114 | - $default_email_body .= '<strong>' . __( 'Donation Date:', 'give' ) . '</strong> {date}' . "\n"; |
|
115 | - $default_email_body .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n"; |
|
116 | - $default_email_body .= '<strong>' . __( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n"; |
|
117 | - $default_email_body .= '<strong>' . __( 'Payment ID:', 'give' ) . '</strong> {payment_id}' . "\n"; |
|
118 | - $default_email_body .= '<strong>' . __( 'Receipt ID:', 'give' ) . '</strong> {receipt_id}' . "\n\n"; |
|
119 | - $default_email_body .= '{receipt_link}' . "\n\n"; |
|
110 | + $default_email_body = __('Dear', 'give')." {name},\n\n"; |
|
111 | + $default_email_body .= __('Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give')."\n\n"; |
|
112 | + $default_email_body .= '<strong>'.__('Donor:', 'give').'</strong> {fullname}'."\n"; |
|
113 | + $default_email_body .= '<strong>'.__('Donation:', 'give').'</strong> {donation}'."\n"; |
|
114 | + $default_email_body .= '<strong>'.__('Donation Date:', 'give').'</strong> {date}'."\n"; |
|
115 | + $default_email_body .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n"; |
|
116 | + $default_email_body .= '<strong>'.__('Payment Method:', 'give').'</strong> {payment_method}'."\n"; |
|
117 | + $default_email_body .= '<strong>'.__('Payment ID:', 'give').'</strong> {payment_id}'."\n"; |
|
118 | + $default_email_body .= '<strong>'.__('Receipt ID:', 'give').'</strong> {receipt_id}'."\n\n"; |
|
119 | + $default_email_body .= '{receipt_link}'."\n\n"; |
|
120 | 120 | $default_email_body .= "\n\n"; |
121 | - $default_email_body .= __( 'Sincerely,', 'give' ) . "\n"; |
|
122 | - $default_email_body .= '{sitename}' . "\n"; |
|
121 | + $default_email_body .= __('Sincerely,', 'give')."\n"; |
|
122 | + $default_email_body .= '{sitename}'."\n"; |
|
123 | 123 | |
124 | - return apply_filters( 'give_default_donation_receipt_email', $default_email_body ); |
|
124 | + return apply_filters('give_default_donation_receipt_email', $default_email_body); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -134,22 +134,22 @@ discard block |
||
134 | 134 | * |
135 | 135 | * @return array $email_names |
136 | 136 | */ |
137 | -function give_get_email_names( $user_info, $payment = false ) { |
|
137 | +function give_get_email_names($user_info, $payment = false) { |
|
138 | 138 | $email_names = array(); |
139 | 139 | |
140 | - if ( is_a( $payment, 'Give_Payment' ) ) { |
|
140 | + if (is_a($payment, 'Give_Payment')) { |
|
141 | 141 | |
142 | - if ( $payment->user_id > 0 ) { |
|
142 | + if ($payment->user_id > 0) { |
|
143 | 143 | |
144 | - $user_data = get_userdata( $payment->user_id ); |
|
144 | + $user_data = get_userdata($payment->user_id); |
|
145 | 145 | $email_names['name'] = $payment->first_name; |
146 | - $email_names['fullname'] = trim( $payment->first_name . ' ' . $payment->last_name ); |
|
146 | + $email_names['fullname'] = trim($payment->first_name.' '.$payment->last_name); |
|
147 | 147 | $email_names['username'] = $user_data->user_login; |
148 | 148 | |
149 | - } elseif ( ! empty( $payment->first_name ) ) { |
|
149 | + } elseif ( ! empty($payment->first_name)) { |
|
150 | 150 | |
151 | 151 | $email_names['name'] = $payment->first_name; |
152 | - $email_names['fullname'] = trim( $payment->first_name . ' ' . $payment->last_name ); |
|
152 | + $email_names['fullname'] = trim($payment->first_name.' '.$payment->last_name); |
|
153 | 153 | $email_names['username'] = $payment->first_name; |
154 | 154 | |
155 | 155 | } else { |
@@ -161,29 +161,29 @@ discard block |
||
161 | 161 | } else { |
162 | 162 | |
163 | 163 | // Support for old serialized data. |
164 | - if ( is_serialized( $user_info ) ) { |
|
164 | + if (is_serialized($user_info)) { |
|
165 | 165 | |
166 | 166 | // Security check. |
167 | - preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches ); |
|
168 | - if ( ! empty( $matches ) ) { |
|
167 | + preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches); |
|
168 | + if ( ! empty($matches)) { |
|
169 | 169 | return array( |
170 | 170 | 'name' => '', |
171 | 171 | 'fullname' => '', |
172 | 172 | 'username' => '', |
173 | 173 | ); |
174 | 174 | } else { |
175 | - $user_info = maybe_unserialize( $user_info ); |
|
175 | + $user_info = maybe_unserialize($user_info); |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 | |
179 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 && isset( $user_info['first_name'] ) ) { |
|
180 | - $user_data = get_userdata( $user_info['id'] ); |
|
179 | + if (isset($user_info['id']) && $user_info['id'] > 0 && isset($user_info['first_name'])) { |
|
180 | + $user_data = get_userdata($user_info['id']); |
|
181 | 181 | $email_names['name'] = $user_info['first_name']; |
182 | - $email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
182 | + $email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name']; |
|
183 | 183 | $email_names['username'] = $user_data->user_login; |
184 | - } elseif ( isset( $user_info['first_name'] ) ) { |
|
184 | + } elseif (isset($user_info['first_name'])) { |
|
185 | 185 | $email_names['name'] = $user_info['first_name']; |
186 | - $email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
186 | + $email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name']; |
|
187 | 187 | $email_names['username'] = $user_info['first_name']; |
188 | 188 | } else { |
189 | 189 | $email_names['name'] = $user_info['email']; |
@@ -192,13 +192,13 @@ discard block |
||
192 | 192 | } // End if(). |
193 | 193 | |
194 | 194 | // Set title prefix to name, if non empty. |
195 | - if ( ! empty( $user_info['title'] ) && ! empty( $user_info['last_name'] ) ) { |
|
196 | - $email_names['name'] = give_get_donor_name_with_title_prefixes( $user_info['title'], $user_info['last_name'] ); |
|
195 | + if ( ! empty($user_info['title']) && ! empty($user_info['last_name'])) { |
|
196 | + $email_names['name'] = give_get_donor_name_with_title_prefixes($user_info['title'], $user_info['last_name']); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | // Set title prefix to fullname, if non empty. |
200 | - if ( ! empty( $user_info['title'] ) && ! empty( $email_names['fullname'] ) ) { |
|
201 | - $email_names['fullname'] = give_get_donor_name_with_title_prefixes( $user_info['title'], $email_names['fullname'] ); |
|
200 | + if ( ! empty($user_info['title']) && ! empty($email_names['fullname'])) { |
|
201 | + $email_names['fullname'] = give_get_donor_name_with_title_prefixes($user_info['title'], $email_names['fullname']); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | return $email_names; |
@@ -212,37 +212,37 @@ discard block |
||
212 | 212 | * |
213 | 213 | * @since 1.8.14 |
214 | 214 | */ |
215 | -function give_admin_email_user_donor_disconnection( $user_id, $donor_id ) { |
|
215 | +function give_admin_email_user_donor_disconnection($user_id, $donor_id) { |
|
216 | 216 | |
217 | - $user_id = absint( $user_id ); |
|
218 | - $donor_id = absint( $donor_id ); |
|
217 | + $user_id = absint($user_id); |
|
218 | + $donor_id = absint($donor_id); |
|
219 | 219 | |
220 | 220 | // Bail Out, if user id doesn't exists. |
221 | - if ( empty( $user_id ) ) { |
|
221 | + if (empty($user_id)) { |
|
222 | 222 | return; |
223 | 223 | } |
224 | 224 | |
225 | 225 | // Bail Out, if donor id doesn't exists. |
226 | - if ( empty( $donor_id ) ) { |
|
226 | + if (empty($donor_id)) { |
|
227 | 227 | return; |
228 | 228 | } |
229 | 229 | |
230 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
230 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
231 | 231 | |
232 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
232 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
233 | 233 | |
234 | 234 | /* translators: %s: payment id */ |
235 | - $subject = __( 'Attention: User tries to login whose Donor profile is disconnected!', 'give' ); |
|
235 | + $subject = __('Attention: User tries to login whose Donor profile is disconnected!', 'give'); |
|
236 | 236 | |
237 | 237 | /** |
238 | 238 | * Filters the Donor-User Disconnection notification subject. |
239 | 239 | * |
240 | 240 | * @since 1.8.14 |
241 | 241 | */ |
242 | - $subject = apply_filters( 'give_admin_donor_user_disconnection_notification_subject', wp_strip_all_tags( $subject ) ); |
|
242 | + $subject = apply_filters('give_admin_donor_user_disconnection_notification_subject', wp_strip_all_tags($subject)); |
|
243 | 243 | |
244 | - $headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n"; |
|
245 | - $headers .= "Reply-To: " . $from_email . "\r\n"; |
|
244 | + $headers = "From: ".stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8'))." <$from_email>\r\n"; |
|
245 | + $headers .= "Reply-To: ".$from_email."\r\n"; |
|
246 | 246 | $headers .= "Content-Type: text/html; charset=utf-8\r\n"; |
247 | 247 | |
248 | 248 | /** |
@@ -250,25 +250,25 @@ discard block |
||
250 | 250 | * |
251 | 251 | * @since 1.8.14 |
252 | 252 | */ |
253 | - $headers = apply_filters( 'give_admin_donor_user_disconnection_notification_headers', $headers ); |
|
253 | + $headers = apply_filters('give_admin_donor_user_disconnection_notification_headers', $headers); |
|
254 | 254 | |
255 | - $message = __( 'Hi Admin,', 'give' ) . "\n\n"; |
|
256 | - $message .= __( 'This email is to inform you that a user has tried logging in. But, User was unable to login due to User-Donor profile disconnection.', 'give' ) . "\n\n"; |
|
257 | - $message .= __( 'Do you want to reconnect User and Donor profile again?', 'give' ) . "\n\n"; |
|
255 | + $message = __('Hi Admin,', 'give')."\n\n"; |
|
256 | + $message .= __('This email is to inform you that a user has tried logging in. But, User was unable to login due to User-Donor profile disconnection.', 'give')."\n\n"; |
|
257 | + $message .= __('Do you want to reconnect User and Donor profile again?', 'give')."\n\n"; |
|
258 | 258 | $message .= sprintf( |
259 | 259 | '<a href="%1$s">%2$s</a>', |
260 | - esc_url( admin_url() . 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor_id . '&user_id=' . $user_id . '&give-messages[]=reconnect-user' ), |
|
261 | - __( 'Reconnect User', 'give' ) . "\n\n" |
|
260 | + esc_url(admin_url().'edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor_id.'&user_id='.$user_id.'&give-messages[]=reconnect-user'), |
|
261 | + __('Reconnect User', 'give')."\n\n" |
|
262 | 262 | ); |
263 | - $message .= __( 'Thank you,', 'give' ) . "\n\n"; |
|
264 | - $message .= '{sitename}' . "\n"; |
|
263 | + $message .= __('Thank you,', 'give')."\n\n"; |
|
264 | + $message .= '{sitename}'."\n"; |
|
265 | 265 | |
266 | 266 | $emails = Give()->emails; |
267 | - $emails->__set( 'from_name', $from_name ); |
|
268 | - $emails->__set( 'from_email', $from_email ); |
|
269 | - $emails->__set( 'headers', $headers ); |
|
270 | - $emails->__set( 'heading', __( 'User - Donor Profile Disconnection', 'give' ) ); |
|
267 | + $emails->__set('from_name', $from_name); |
|
268 | + $emails->__set('from_email', $from_email); |
|
269 | + $emails->__set('headers', $headers); |
|
270 | + $emails->__set('heading', __('User - Donor Profile Disconnection', 'give')); |
|
271 | 271 | |
272 | - $emails->send( give_get_admin_notice_emails(), $subject, give_do_email_tags( $message ) ); |
|
272 | + $emails->send(give_get_admin_notice_emails(), $subject, give_do_email_tags($message)); |
|
273 | 273 | |
274 | 274 | } |
@@ -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 | |
@@ -26,34 +26,34 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return void |
28 | 28 | */ |
29 | -function give_set_settings_with_disable_prefix( $old_settings, $settings ) { |
|
29 | +function give_set_settings_with_disable_prefix($old_settings, $settings) { |
|
30 | 30 | // Bailout. |
31 | - if ( ! function_exists( 'give_v18_renamed_core_settings' ) ) { |
|
31 | + if ( ! function_exists('give_v18_renamed_core_settings')) { |
|
32 | 32 | return; |
33 | 33 | } |
34 | 34 | |
35 | 35 | // Get old setting names. |
36 | - $old_settings = array_flip( give_v18_renamed_core_settings() ); |
|
36 | + $old_settings = array_flip(give_v18_renamed_core_settings()); |
|
37 | 37 | $update_setting = false; |
38 | 38 | |
39 | - foreach ( $settings as $key => $value ) { |
|
39 | + foreach ($settings as $key => $value) { |
|
40 | 40 | |
41 | 41 | // Check 1. Check if new option is really updated or not. |
42 | 42 | // Check 2. Continue if key is not renamed. |
43 | - if ( ! isset( $old_settings[ $key ] ) ) { |
|
43 | + if ( ! isset($old_settings[$key])) { |
|
44 | 44 | continue; |
45 | 45 | } |
46 | 46 | |
47 | 47 | // Set old setting. |
48 | - $settings[ $old_settings[ $key ] ] = 'on'; |
|
48 | + $settings[$old_settings[$key]] = 'on'; |
|
49 | 49 | |
50 | 50 | // Do not need to set old setting if new setting is not set. |
51 | 51 | if ( |
52 | - ( give_is_setting_enabled( $value ) && ( false !== strpos( $old_settings[ $key ], 'disable_' ) ) ) |
|
53 | - || ( ! give_is_setting_enabled( $value ) && ( false !== strpos( $old_settings[ $key ], 'enable_' ) ) ) |
|
52 | + (give_is_setting_enabled($value) && (false !== strpos($old_settings[$key], 'disable_'))) |
|
53 | + || ( ! give_is_setting_enabled($value) && (false !== strpos($old_settings[$key], 'enable_'))) |
|
54 | 54 | |
55 | 55 | ) { |
56 | - unset( $settings[ $old_settings[ $key ] ] ); |
|
56 | + unset($settings[$old_settings[$key]]); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | // Tell bot to update setting. |
@@ -61,12 +61,12 @@ discard block |
||
61 | 61 | } |
62 | 62 | |
63 | 63 | // Update setting if any old setting set. |
64 | - if ( $update_setting ) { |
|
65 | - update_option( 'give_settings', $settings, false ); |
|
64 | + if ($update_setting) { |
|
65 | + update_option('give_settings', $settings, false); |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
69 | -add_action( 'update_option_give_settings', 'give_set_settings_with_disable_prefix', 10, 2 ); |
|
69 | +add_action('update_option_give_settings', 'give_set_settings_with_disable_prefix', 10, 2); |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * Check spam through Akismet. |
@@ -80,45 +80,45 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return bool|mixed |
82 | 82 | */ |
83 | -function give_akismet( $spam ) { |
|
83 | +function give_akismet($spam) { |
|
84 | 84 | |
85 | 85 | // Bail out, If spam. |
86 | - if ( $spam ) { |
|
86 | + if ($spam) { |
|
87 | 87 | return $spam; |
88 | 88 | } |
89 | 89 | |
90 | 90 | // Bail out, if Akismet key not exist. |
91 | - if ( ! give_check_akismet_key() ) { |
|
91 | + if ( ! give_check_akismet_key()) { |
|
92 | 92 | return false; |
93 | 93 | } |
94 | 94 | |
95 | 95 | // Build args array. |
96 | 96 | $args = array(); |
97 | 97 | |
98 | - $args['comment_author'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : ''; |
|
99 | - $args['comment_author_email'] = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false; |
|
100 | - $args['blog'] = get_option( 'home' ); |
|
98 | + $args['comment_author'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : ''; |
|
99 | + $args['comment_author_email'] = isset($_POST['give_email']) ? $_POST['give_email'] : false; |
|
100 | + $args['blog'] = get_option('home'); |
|
101 | 101 | $args['blog_lang'] = get_locale(); |
102 | - $args['blog_charset'] = get_option( 'blog_charset' ); |
|
102 | + $args['blog_charset'] = get_option('blog_charset'); |
|
103 | 103 | $args['user_ip'] = $_SERVER['REMOTE_ADDR']; |
104 | 104 | $args['user_agent'] = $_SERVER['HTTP_USER_AGENT']; |
105 | 105 | $args['referrer'] = $_SERVER['HTTP_REFERER']; |
106 | 106 | $args['comment_type'] = 'contact-form'; |
107 | 107 | |
108 | - $ignore = array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ); |
|
108 | + $ignore = array('HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW'); |
|
109 | 109 | |
110 | - foreach ( $_SERVER as $key => $value ) { |
|
111 | - if ( ! in_array( $key, (array) $ignore ) ) { |
|
110 | + foreach ($_SERVER as $key => $value) { |
|
111 | + if ( ! in_array($key, (array) $ignore)) { |
|
112 | 112 | $args["$key"] = $value; |
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
116 | 116 | // It will return Akismet spam detect API response. |
117 | - return give_akismet_spam_check( $args ); |
|
117 | + return give_akismet_spam_check($args); |
|
118 | 118 | |
119 | 119 | } |
120 | 120 | |
121 | -add_filter( 'give_spam', 'give_akismet' ); |
|
121 | +add_filter('give_spam', 'give_akismet'); |
|
122 | 122 | |
123 | 123 | /** |
124 | 124 | * Check Akismet API Key. |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | * @return bool |
129 | 129 | */ |
130 | 130 | function give_check_akismet_key() { |
131 | - if ( is_callable( array( 'Akismet', 'get_api_key' ) ) ) { // Akismet v3.0+ |
|
131 | + if (is_callable(array('Akismet', 'get_api_key'))) { // Akismet v3.0+ |
|
132 | 132 | return (bool) Akismet::get_api_key(); |
133 | 133 | } |
134 | 134 | |
135 | - if ( function_exists( 'akismet_get_key' ) ) { |
|
135 | + if (function_exists('akismet_get_key')) { |
|
136 | 136 | return (bool) akismet_get_key(); |
137 | 137 | } |
138 | 138 | |
@@ -148,26 +148,26 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @return bool|mixed |
150 | 150 | */ |
151 | -function give_akismet_spam_check( $args ) { |
|
151 | +function give_akismet_spam_check($args) { |
|
152 | 152 | global $akismet_api_host, $akismet_api_port; |
153 | 153 | |
154 | 154 | $spam = false; |
155 | - $query_string = http_build_query( $args ); |
|
155 | + $query_string = http_build_query($args); |
|
156 | 156 | |
157 | - if ( is_callable( array( 'Akismet', 'http_post' ) ) ) { // Akismet v3.0+ |
|
158 | - $response = Akismet::http_post( $query_string, 'comment-check' ); |
|
157 | + if (is_callable(array('Akismet', 'http_post'))) { // Akismet v3.0+ |
|
158 | + $response = Akismet::http_post($query_string, 'comment-check'); |
|
159 | 159 | } else { |
160 | - $response = akismet_http_post( $query_string, $akismet_api_host, |
|
161 | - '/1.1/comment-check', $akismet_api_port ); |
|
160 | + $response = akismet_http_post($query_string, $akismet_api_host, |
|
161 | + '/1.1/comment-check', $akismet_api_port); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | // It's spam if response status is true. |
165 | - if ( 'true' === $response[1] ) { |
|
165 | + if ('true' === $response[1]) { |
|
166 | 166 | $spam = true; |
167 | 167 | } |
168 | 168 | |
169 | 169 | // Allow developer to modified Akismet spam detection response. |
170 | - return apply_filters( 'give_akismet_spam_check', $spam, $args ); |
|
170 | + return apply_filters('give_akismet_spam_check', $spam, $args); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
@@ -180,15 +180,15 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @return array |
182 | 182 | */ |
183 | -function give_bc_v1817_iranian_currency_code( $currencies ) { |
|
184 | - if ( ! give_has_upgrade_completed( 'v1817_update_donation_iranian_currency_code' ) ) { |
|
183 | +function give_bc_v1817_iranian_currency_code($currencies) { |
|
184 | + if ( ! give_has_upgrade_completed('v1817_update_donation_iranian_currency_code')) { |
|
185 | 185 | $currencies['RIAL'] = $currencies['IRR']; |
186 | 186 | } |
187 | 187 | |
188 | 188 | return $currencies; |
189 | 189 | } |
190 | 190 | |
191 | -add_filter( 'give_currencies', 'give_bc_v1817_iranian_currency_code', 0 ); |
|
191 | +add_filter('give_currencies', 'give_bc_v1817_iranian_currency_code', 0); |
|
192 | 192 | |
193 | 193 | |
194 | 194 | /** |
@@ -202,25 +202,23 @@ discard block |
||
202 | 202 | * |
203 | 203 | * @return string |
204 | 204 | */ |
205 | -function give_format_price_for_right_to_left_supported_currency( $formatted_amount, $currency_args, $price ) { |
|
206 | - if ( ! give_is_right_to_left_supported_currency( $currency_args['currency_code'] ) ) { |
|
205 | +function give_format_price_for_right_to_left_supported_currency($formatted_amount, $currency_args, $price) { |
|
206 | + if ( ! give_is_right_to_left_supported_currency($currency_args['currency_code'])) { |
|
207 | 207 | return $formatted_amount; |
208 | 208 | } |
209 | 209 | |
210 | 210 | $formatted_amount = ( |
211 | 211 | 'before' === (string) $currency_args['position'] ? |
212 | - '‫' . $price . $currency_args['symbol'] . '‬' : |
|
213 | - '‪' . $price . $currency_args['symbol'] . '‬' |
|
212 | + '‫'.$price.$currency_args['symbol'].'‬' : '‪'.$price.$currency_args['symbol'].'‬' |
|
214 | 213 | ); |
215 | 214 | |
216 | 215 | $formatted_amount = $currency_args['decode_currency'] ? |
217 | - html_entity_decode( $formatted_amount, ENT_COMPAT, 'UTF-8' ) : |
|
218 | - $formatted_amount; |
|
216 | + html_entity_decode($formatted_amount, ENT_COMPAT, 'UTF-8') : $formatted_amount; |
|
219 | 217 | |
220 | 218 | return $formatted_amount; |
221 | 219 | } |
222 | 220 | |
223 | -add_filter( 'give_currency_filter', 'give_format_price_for_right_to_left_supported_currency', 10, 3 ); |
|
221 | +add_filter('give_currency_filter', 'give_format_price_for_right_to_left_supported_currency', 10, 3); |
|
224 | 222 | |
225 | 223 | /** |
226 | 224 | * Validate active gateway value before returning result. |
@@ -231,31 +229,31 @@ discard block |
||
231 | 229 | * |
232 | 230 | * @return array |
233 | 231 | */ |
234 | -function __give_validate_active_gateways( $value ) { |
|
235 | - $gateways = array_keys( give_get_payment_gateways() ); |
|
236 | - $active_gateways = is_array( $value ) ? array_keys( $value ) : array(); |
|
232 | +function __give_validate_active_gateways($value) { |
|
233 | + $gateways = array_keys(give_get_payment_gateways()); |
|
234 | + $active_gateways = is_array($value) ? array_keys($value) : array(); |
|
237 | 235 | |
238 | 236 | // Remove deactivated payment gateways. |
239 | - if( ! empty( $active_gateways ) ) { |
|
240 | - foreach ( $active_gateways as $index => $gateway_id ) { |
|
241 | - if( ! in_array( $gateway_id, $gateways ) ) { |
|
242 | - unset( $value[$gateway_id] ); |
|
237 | + if ( ! empty($active_gateways)) { |
|
238 | + foreach ($active_gateways as $index => $gateway_id) { |
|
239 | + if ( ! in_array($gateway_id, $gateways)) { |
|
240 | + unset($value[$gateway_id]); |
|
243 | 241 | } |
244 | 242 | } |
245 | 243 | } |
246 | 244 | |
247 | - if ( empty( $value ) ) { |
|
245 | + if (empty($value)) { |
|
248 | 246 | /** |
249 | 247 | * Filter the default active gateway |
250 | 248 | * |
251 | 249 | * @since 2.1.0 |
252 | 250 | */ |
253 | - $value = apply_filters( 'give_default_active_gateways', array( |
|
251 | + $value = apply_filters('give_default_active_gateways', array( |
|
254 | 252 | 'manual' => 1, |
255 | - ) ); |
|
253 | + )); |
|
256 | 254 | } |
257 | 255 | |
258 | 256 | return $value; |
259 | 257 | } |
260 | 258 | |
261 | -add_filter( 'give_get_option_gateways', '__give_validate_active_gateways', 10, 1 ); |
|
259 | +add_filter('give_get_option_gateways', '__give_validate_active_gateways', 10, 1); |
@@ -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,14 +21,14 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param $data |
23 | 23 | */ |
24 | -function give_process_gateway_select( $data ) { |
|
25 | - if ( isset( $_POST['gateway_submit'] ) ) { |
|
26 | - wp_redirect( esc_url( add_query_arg( 'payment-mode', $_POST['payment-mode'] ) ) ); |
|
24 | +function give_process_gateway_select($data) { |
|
25 | + if (isset($_POST['gateway_submit'])) { |
|
26 | + wp_redirect(esc_url(add_query_arg('payment-mode', $_POST['payment-mode']))); |
|
27 | 27 | exit; |
28 | 28 | } |
29 | 29 | } |
30 | 30 | |
31 | -add_action( 'give_gateway_select', 'give_process_gateway_select' ); |
|
31 | +add_action('give_gateway_select', 'give_process_gateway_select'); |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Loads a payment gateway via AJAX. |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | */ |
40 | 40 | function give_load_ajax_gateway() { |
41 | 41 | |
42 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, CSRF ok. |
|
42 | + $post_data = give_clean($_POST); // WPCS: input var ok, CSRF ok. |
|
43 | 43 | |
44 | - if ( isset( $post_data['give_payment_mode'] ) ) { |
|
44 | + if (isset($post_data['give_payment_mode'])) { |
|
45 | 45 | |
46 | - $form_id_prefix = ! empty( $post_data['give_form_id_prefix'] ) ? $post_data['give_form_id_prefix'] : ''; |
|
46 | + $form_id_prefix = ! empty($post_data['give_form_id_prefix']) ? $post_data['give_form_id_prefix'] : ''; |
|
47 | 47 | |
48 | 48 | $args = array( |
49 | 49 | 'id_prefix' => $form_id_prefix, |
@@ -54,14 +54,14 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @since 1.7 |
56 | 56 | */ |
57 | - do_action( 'give_donation_form', $post_data['give_form_id'], $args ); |
|
57 | + do_action('give_donation_form', $post_data['give_form_id'], $args); |
|
58 | 58 | |
59 | 59 | exit(); |
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
63 | -add_action( 'wp_ajax_give_load_gateway', 'give_load_ajax_gateway' ); |
|
64 | -add_action( 'wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway' ); |
|
63 | +add_action('wp_ajax_give_load_gateway', 'give_load_ajax_gateway'); |
|
64 | +add_action('wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway'); |
|
65 | 65 | |
66 | 66 | /** |
67 | 67 | * Create wp nonce using Ajax call. |
@@ -73,18 +73,18 @@ discard block |
||
73 | 73 | * @return void |
74 | 74 | */ |
75 | 75 | function give_donation_form_nonce() { |
76 | - if ( isset( $_POST['give_form_id'] ) ) { |
|
76 | + if (isset($_POST['give_form_id'])) { |
|
77 | 77 | |
78 | 78 | // Get donation form id. |
79 | - $form_id = is_numeric( $_POST['give_form_id'] ) ? absint( $_POST['give_form_id'] ) : 0; |
|
79 | + $form_id = is_numeric($_POST['give_form_id']) ? absint($_POST['give_form_id']) : 0; |
|
80 | 80 | |
81 | 81 | // Send nonce json data. |
82 | - wp_send_json_success( wp_create_nonce( "give_donation_form_nonce_{$form_id}" ) ); |
|
82 | + wp_send_json_success(wp_create_nonce("give_donation_form_nonce_{$form_id}")); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
86 | -add_action( 'wp_ajax_give_donation_form_nonce', 'give_donation_form_nonce' ); |
|
87 | -add_action( 'wp_ajax_nopriv_give_donation_form_nonce', 'give_donation_form_nonce' ); |
|
86 | +add_action('wp_ajax_give_donation_form_nonce', 'give_donation_form_nonce'); |
|
87 | +add_action('wp_ajax_nopriv_give_donation_form_nonce', 'give_donation_form_nonce'); |
|
88 | 88 | |
89 | 89 | |
90 | 90 | /** |
@@ -96,14 +96,14 @@ discard block |
||
96 | 96 | * @return void |
97 | 97 | */ |
98 | 98 | function __give_donation_form_reset_all_nonce() { |
99 | - if ( isset( $_POST['give_form_id'] ) ) { |
|
99 | + if (isset($_POST['give_form_id'])) { |
|
100 | 100 | |
101 | 101 | // Get donation form id. |
102 | - $form_id = is_numeric( $_POST['give_form_id'] ) ? absint( $_POST['give_form_id'] ) : 0; |
|
102 | + $form_id = is_numeric($_POST['give_form_id']) ? absint($_POST['give_form_id']) : 0; |
|
103 | 103 | |
104 | 104 | $data = array( |
105 | - 'give_form_hash' => wp_create_nonce( "give_donation_form_nonce_{$form_id}" ), |
|
106 | - 'give_form_user_register_hash' => wp_create_nonce( "give_form_create_user_nonce_{$form_id}" ) |
|
105 | + 'give_form_hash' => wp_create_nonce("give_donation_form_nonce_{$form_id}"), |
|
106 | + 'give_form_user_register_hash' => wp_create_nonce("give_form_create_user_nonce_{$form_id}") |
|
107 | 107 | ); |
108 | 108 | |
109 | 109 | /** |
@@ -112,15 +112,15 @@ discard block |
||
112 | 112 | * @since 2.2.0 |
113 | 113 | * |
114 | 114 | */ |
115 | - $data = apply_filters( 'give_donation_form_reset_all_nonce_data', $data ); |
|
115 | + $data = apply_filters('give_donation_form_reset_all_nonce_data', $data); |
|
116 | 116 | |
117 | 117 | // Send nonce json data. |
118 | - wp_send_json_success( $data ); |
|
118 | + wp_send_json_success($data); |
|
119 | 119 | } |
120 | 120 | } |
121 | 121 | |
122 | -add_action( 'wp_ajax_give_donation_form_reset_all_nonce', '__give_donation_form_reset_all_nonce' ); |
|
123 | -add_action( 'wp_ajax_nopriv_give_donation_form_reset_all_nonce', '__give_donation_form_reset_all_nonce' ); |
|
122 | +add_action('wp_ajax_give_donation_form_reset_all_nonce', '__give_donation_form_reset_all_nonce'); |
|
123 | +add_action('wp_ajax_nopriv_give_donation_form_reset_all_nonce', '__give_donation_form_reset_all_nonce'); |
|
124 | 124 | |
125 | 125 | /** |
126 | 126 | * Sets an error within the donation form if no gateways are enabled. |
@@ -133,11 +133,11 @@ discard block |
||
133 | 133 | function give_no_gateway_error() { |
134 | 134 | $gateways = give_get_enabled_payment_gateways(); |
135 | 135 | |
136 | - if ( empty( $gateways ) ) { |
|
137 | - give_set_error( 'no_gateways', esc_html__( 'You must enable a payment gateway to use Give.', 'give' ) ); |
|
136 | + if (empty($gateways)) { |
|
137 | + give_set_error('no_gateways', esc_html__('You must enable a payment gateway to use Give.', 'give')); |
|
138 | 138 | } else { |
139 | - give_unset_error( 'no_gateways' ); |
|
139 | + give_unset_error('no_gateways'); |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
143 | -add_action( 'init', 'give_no_gateway_error' ); |
|
143 | +add_action('init', 'give_no_gateway_error'); |
@@ -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 | |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | // Set cache group id. |
55 | 55 | $current_blog_id = get_current_blog_id(); |
56 | 56 | $this->incrementer_name = "give-cache-incrementer-sessions-{$current_blog_id}"; |
57 | - $incrementer_value = wp_cache_get( $this->incrementer_name ); |
|
58 | - $incrementer_value = ! empty( $incrementer_value ) ? $incrementer_value : microtime( true ); |
|
57 | + $incrementer_value = wp_cache_get($this->incrementer_name); |
|
58 | + $incrementer_value = ! empty($incrementer_value) ? $incrementer_value : microtime(true); |
|
59 | 59 | $this->cache_group = "{$this->cache_group}_{$current_blog_id}_{$incrementer_value}"; |
60 | 60 | |
61 | 61 | $this->register_table(); |
@@ -101,10 +101,10 @@ discard block |
||
101 | 101 | UNIQUE KEY session_id (session_id) |
102 | 102 | ) {$charset_collate};"; |
103 | 103 | |
104 | - require_once ABSPATH . 'wp-admin/includes/upgrade.php'; |
|
105 | - dbDelta( $sql ); |
|
104 | + require_once ABSPATH.'wp-admin/includes/upgrade.php'; |
|
105 | + dbDelta($sql); |
|
106 | 106 | |
107 | - update_option( $this->table_name . '_db_version', $this->version, false ); |
|
107 | + update_option($this->table_name.'_db_version', $this->version, false); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | |
@@ -118,14 +118,14 @@ discard block |
||
118 | 118 | * |
119 | 119 | * @return mixed |
120 | 120 | */ |
121 | - public function get_session( $donor_id, $default = false ) { |
|
121 | + public function get_session($donor_id, $default = false) { |
|
122 | 122 | global $wpdb; |
123 | 123 | |
124 | - if ( defined( 'WP_SETUP_CONFIG' ) ) { |
|
124 | + if (defined('WP_SETUP_CONFIG')) { |
|
125 | 125 | return false; |
126 | 126 | } |
127 | 127 | |
128 | - if ( ! ( $value = wp_cache_get( $donor_id, $this->cache_group ) ) ) { // @codingStandardsIgnoreLine |
|
128 | + if ( ! ($value = wp_cache_get($donor_id, $this->cache_group))) { // @codingStandardsIgnoreLine |
|
129 | 129 | |
130 | 130 | // @codingStandardsIgnoreStart |
131 | 131 | $value = $wpdb->get_var( |
@@ -140,14 +140,14 @@ discard block |
||
140 | 140 | ); |
141 | 141 | // @codingStandardsIgnoreEnd |
142 | 142 | |
143 | - if ( is_null( $value ) ) { |
|
143 | + if (is_null($value)) { |
|
144 | 144 | $value = $default; |
145 | 145 | } |
146 | 146 | |
147 | - wp_cache_add( $donor_id, $value, $this->cache_group ); |
|
147 | + wp_cache_add($donor_id, $value, $this->cache_group); |
|
148 | 148 | } |
149 | 149 | |
150 | - return maybe_unserialize( $value ); |
|
150 | + return maybe_unserialize($value); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | * @param string $donor_id Donor ID. |
157 | 157 | * @param int $timestamp Timestamp to expire the cookie. |
158 | 158 | */ |
159 | - public function update_session_timestamp( $donor_id, $timestamp ) { |
|
159 | + public function update_session_timestamp($donor_id, $timestamp) { |
|
160 | 160 | global $wpdb; |
161 | 161 | |
162 | 162 | // @codingStandardsIgnoreStart. |
@@ -183,10 +183,10 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @param int $donor_id Customer ID. |
185 | 185 | */ |
186 | - public function delete_session( $donor_id ) { |
|
186 | + public function delete_session($donor_id) { |
|
187 | 187 | global $wpdb; |
188 | 188 | |
189 | - wp_cache_delete( $donor_id, $this->cache_group ); |
|
189 | + wp_cache_delete($donor_id, $this->cache_group); |
|
190 | 190 | |
191 | 191 | // @codingStandardsIgnoreStart |
192 | 192 | $wpdb->delete( |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | public function delete_expired_sessions() { |
210 | 210 | global $wpdb; |
211 | 211 | |
212 | - wp_cache_set( $this->incrementer_name, microtime( true ) ); |
|
212 | + wp_cache_set($this->incrementer_name, microtime(true)); |
|
213 | 213 | |
214 | 214 | // @codingStandardsIgnoreStart |
215 | 215 | $wpdb->query( |
@@ -232,10 +232,10 @@ discard block |
||
232 | 232 | * @param array $data Data. |
233 | 233 | * @param array $format Array for data format of each key:value in data. |
234 | 234 | */ |
235 | - public function __replace( $table_name, $data, $format = null ) { |
|
235 | + public function __replace($table_name, $data, $format = null) { |
|
236 | 236 | global $wpdb; |
237 | 237 | |
238 | - wp_cache_set( $data['session_key'], $data['session_value'], $this->cache_group, $data['session_expiry'] - time() ); |
|
238 | + wp_cache_set($data['session_key'], $data['session_value'], $this->cache_group, $data['session_expiry'] - time()); |
|
239 | 239 | |
240 | 240 | |
241 | 241 | // @codingStandardsIgnoreStart |
@@ -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 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * @return Give_Session |
136 | 136 | */ |
137 | 137 | public static function get_instance() { |
138 | - if ( null === static::$instance ) { |
|
138 | + if (null === static::$instance) { |
|
139 | 139 | self::$instance = new static(); |
140 | 140 | self::$instance->__setup(); |
141 | 141 | } |
@@ -150,25 +150,25 @@ discard block |
||
150 | 150 | * @access public |
151 | 151 | */ |
152 | 152 | private function __setup() { // @codingStandardsIgnoreLine |
153 | - $this->exp_option = give_get_option( 'session_lifetime' ); |
|
154 | - $this->exp_option = ! empty( $this->exp_option ) |
|
153 | + $this->exp_option = give_get_option('session_lifetime'); |
|
154 | + $this->exp_option = ! empty($this->exp_option) |
|
155 | 155 | ? $this->exp_option |
156 | 156 | : 30 * 60 * 24; // Default expiration time is 12 hours |
157 | 157 | |
158 | 158 | $this->set_cookie_name(); |
159 | - $this->cookie_name = $this->get_cookie_name( 'session' ); |
|
159 | + $this->cookie_name = $this->get_cookie_name('session'); |
|
160 | 160 | $cookie = $this->get_session_cookie(); |
161 | 161 | |
162 | - if ( ! empty( $cookie ) ) { |
|
162 | + if ( ! empty($cookie)) { |
|
163 | 163 | $this->donor_id = $cookie[0]; |
164 | 164 | $this->session_expiration = $cookie[1]; |
165 | 165 | $this->session_expiring = $cookie[2]; |
166 | 166 | $this->has_cookie = true; |
167 | 167 | |
168 | 168 | // Update session if its close to expiring. |
169 | - if ( time() > $this->session_expiring ) { |
|
169 | + if (time() > $this->session_expiring) { |
|
170 | 170 | $this->set_expiration_time(); |
171 | - Give()->session_db->update_session_timestamp( $this->donor_id, $this->session_expiration ); |
|
171 | + Give()->session_db->update_session_timestamp($this->donor_id, $this->session_expiration); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | // Load session. |
@@ -178,17 +178,17 @@ discard block |
||
178 | 178 | $this->generate_donor_id(); |
179 | 179 | } |
180 | 180 | |
181 | - add_action( 'give_process_donation_after_validation', array( $this, 'maybe_start_session' ) ); |
|
181 | + add_action('give_process_donation_after_validation', array($this, 'maybe_start_session')); |
|
182 | 182 | |
183 | - add_action( 'shutdown', array( $this, 'save_data' ), 20 ); |
|
184 | - add_action( 'wp_logout', array( $this, 'destroy_session' ) ); |
|
183 | + add_action('shutdown', array($this, 'save_data'), 20); |
|
184 | + add_action('wp_logout', array($this, 'destroy_session')); |
|
185 | 185 | |
186 | - if ( ! is_user_logged_in() ) { |
|
187 | - add_filter( 'nonce_user_logged_out', array( $this, '__nonce_user_logged_out' ) ); |
|
186 | + if ( ! is_user_logged_in()) { |
|
187 | + add_filter('nonce_user_logged_out', array($this, '__nonce_user_logged_out')); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | // Remove old sessions. |
191 | - Give_Cron::add_daily_event( array( $this, '__cleanup_sessions' ) ); |
|
191 | + Give_Cron::add_daily_event(array($this, '__cleanup_sessions')); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | /** |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | * @return array |
201 | 201 | */ |
202 | 202 | public function get_session_data() { |
203 | - return $this->has_session() ? (array) Give()->session_db->get_session( $this->donor_id, array() ) : array(); |
|
203 | + return $this->has_session() ? (array) Give()->session_db->get_session($this->donor_id, array()) : array(); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | |
@@ -214,27 +214,27 @@ discard block |
||
214 | 214 | */ |
215 | 215 | public function get_session_cookie() { |
216 | 216 | $session = array(); |
217 | - $cookie_value = isset( $_COOKIE[ $this->cookie_name ] ) ? give_clean( $_COOKIE[ $this->cookie_name ] ) : false; // @codingStandardsIgnoreLine. |
|
217 | + $cookie_value = isset($_COOKIE[$this->cookie_name]) ? give_clean($_COOKIE[$this->cookie_name]) : false; // @codingStandardsIgnoreLine. |
|
218 | 218 | |
219 | - if ( empty( $cookie_value ) || ! is_string( $cookie_value ) ) { |
|
219 | + if (empty($cookie_value) || ! is_string($cookie_value)) { |
|
220 | 220 | return $session; |
221 | 221 | } |
222 | 222 | |
223 | - list( $donor_id, $session_expiration, $session_expiring, $cookie_hash ) = explode( '||', $cookie_value ); |
|
223 | + list($donor_id, $session_expiration, $session_expiring, $cookie_hash) = explode('||', $cookie_value); |
|
224 | 224 | |
225 | - if ( empty( $donor_id ) ) { |
|
225 | + if (empty($donor_id)) { |
|
226 | 226 | return $session; |
227 | 227 | } |
228 | 228 | |
229 | 229 | // Validate hash. |
230 | - $to_hash = $donor_id . '|' . $session_expiration; |
|
231 | - $hash = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) ); |
|
230 | + $to_hash = $donor_id.'|'.$session_expiration; |
|
231 | + $hash = hash_hmac('md5', $to_hash, wp_hash($to_hash)); |
|
232 | 232 | |
233 | - if ( empty( $cookie_hash ) || ! hash_equals( $hash, $cookie_hash ) ) { |
|
233 | + if (empty($cookie_hash) || ! hash_equals($hash, $cookie_hash)) { |
|
234 | 234 | return $session; |
235 | 235 | } |
236 | 236 | |
237 | - return array( $donor_id, $session_expiration, $session_expiring, $cookie_hash ); |
|
237 | + return array($donor_id, $session_expiration, $session_expiring, $cookie_hash); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | |
@@ -259,8 +259,8 @@ discard block |
||
259 | 259 | * @return string Cookie name. |
260 | 260 | */ |
261 | 261 | private function set_cookie_name() { |
262 | - $this->cookie_name = apply_filters( 'give_session_cookie', 'wp_give_session_' . COOKIEHASH ); |
|
263 | - $this->nonce_cookie_name = 'wp_give_session_reset_nonce_' . COOKIEHASH; |
|
262 | + $this->cookie_name = apply_filters('give_session_cookie', 'wp_give_session_'.COOKIEHASH); |
|
263 | + $this->nonce_cookie_name = 'wp_give_session_reset_nonce_'.COOKIEHASH; |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | /** |
@@ -276,10 +276,10 @@ discard block |
||
276 | 276 | * |
277 | 277 | * @return string|array Session variable. |
278 | 278 | */ |
279 | - public function get( $key, $default = false ) { |
|
280 | - $key = sanitize_key( $key ); |
|
279 | + public function get($key, $default = false) { |
|
280 | + $key = sanitize_key($key); |
|
281 | 281 | |
282 | - return isset( $this->session[ $key ] ) ? maybe_unserialize( $this->session[ $key ] ) : $default; |
|
282 | + return isset($this->session[$key]) ? maybe_unserialize($this->session[$key]) : $default; |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | /** |
@@ -293,13 +293,13 @@ discard block |
||
293 | 293 | * |
294 | 294 | * @return string Session variable. |
295 | 295 | */ |
296 | - public function set( $key, $value ) { |
|
297 | - if ( $value !== $this->get( $key ) ) { |
|
298 | - $this->session[ sanitize_key( $key ) ] = maybe_serialize( $value ); |
|
296 | + public function set($key, $value) { |
|
297 | + if ($value !== $this->get($key)) { |
|
298 | + $this->session[sanitize_key($key)] = maybe_serialize($value); |
|
299 | 299 | $this->session_data_changed = true; |
300 | 300 | } |
301 | 301 | |
302 | - return $this->session[ $key ]; |
|
302 | + return $this->session[$key]; |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | /** |
@@ -313,17 +313,17 @@ discard block |
||
313 | 313 | * |
314 | 314 | * @param bool $set Flag to check if set cookie or not. |
315 | 315 | */ |
316 | - public function set_session_cookies( $set ) { |
|
317 | - if ( $set ) { |
|
316 | + public function set_session_cookies($set) { |
|
317 | + if ($set) { |
|
318 | 318 | $this->set_expiration_time(); |
319 | 319 | |
320 | - $to_hash = $this->donor_id . '|' . $this->session_expiration; |
|
321 | - $cookie_hash = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) ); |
|
322 | - $cookie_value = $this->donor_id . '||' . $this->session_expiration . '||' . $this->session_expiring . '||' . $cookie_hash; |
|
320 | + $to_hash = $this->donor_id.'|'.$this->session_expiration; |
|
321 | + $cookie_hash = hash_hmac('md5', $to_hash, wp_hash($to_hash)); |
|
322 | + $cookie_value = $this->donor_id.'||'.$this->session_expiration.'||'.$this->session_expiring.'||'.$cookie_hash; |
|
323 | 323 | $this->has_cookie = true; |
324 | 324 | |
325 | - give_setcookie( $this->cookie_name, $cookie_value, $this->session_expiration, apply_filters( 'give_session_use_secure_cookie', false ) ); |
|
326 | - give_setcookie( $this->nonce_cookie_name, '1', $this->session_expiration, apply_filters( 'give_session_use_secure_cookie', false ) ); |
|
325 | + give_setcookie($this->cookie_name, $cookie_value, $this->session_expiration, apply_filters('give_session_use_secure_cookie', false)); |
|
326 | + give_setcookie($this->nonce_cookie_name, '1', $this->session_expiration, apply_filters('give_session_use_secure_cookie', false)); |
|
327 | 327 | } |
328 | 328 | } |
329 | 329 | |
@@ -338,8 +338,8 @@ discard block |
||
338 | 338 | * @return int |
339 | 339 | */ |
340 | 340 | public function set_expiration_time() { |
341 | - $this->session_expiring = time() + intval( apply_filters( 'give_session_expiring', ( $this->exp_option - 3600 ) ) ); // Default 11 Hours. |
|
342 | - $this->session_expiration = time() + intval( apply_filters( 'give_session_expiration', $this->exp_option ) ); // Default 12 Hours. |
|
341 | + $this->session_expiring = time() + intval(apply_filters('give_session_expiring', ($this->exp_option - 3600))); // Default 11 Hours. |
|
342 | + $this->session_expiration = time() + intval(apply_filters('give_session_expiration', $this->exp_option)); // Default 12 Hours. |
|
343 | 343 | |
344 | 344 | return $this->session_expiration; |
345 | 345 | } |
@@ -371,10 +371,10 @@ discard block |
||
371 | 371 | public function maybe_start_session() { |
372 | 372 | if ( |
373 | 373 | ! headers_sent() |
374 | - && empty( $this->session ) |
|
374 | + && empty($this->session) |
|
375 | 375 | && ! $this->has_cookie |
376 | 376 | ) { |
377 | - $this->set_session_cookies( true ); |
|
377 | + $this->set_session_cookies(true); |
|
378 | 378 | } |
379 | 379 | } |
380 | 380 | |
@@ -387,10 +387,10 @@ discard block |
||
387 | 387 | * @access public |
388 | 388 | */ |
389 | 389 | public function generate_donor_id() { |
390 | - require_once ABSPATH . 'wp-includes/class-phpass.php'; |
|
390 | + require_once ABSPATH.'wp-includes/class-phpass.php'; |
|
391 | 391 | |
392 | - $hasher = new PasswordHash( 8, false ); |
|
393 | - $this->donor_id = md5( $hasher->get_random_bytes( 32 ) ); |
|
392 | + $hasher = new PasswordHash(8, false); |
|
393 | + $this->donor_id = md5($hasher->get_random_bytes(32)); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | /** |
@@ -401,14 +401,14 @@ discard block |
||
401 | 401 | */ |
402 | 402 | public function save_data() { |
403 | 403 | // Dirty if something changed - prevents saving nothing new. |
404 | - if ( $this->session_data_changed && $this->has_session() ) { |
|
404 | + if ($this->session_data_changed && $this->has_session()) { |
|
405 | 405 | global $wpdb; |
406 | 406 | |
407 | 407 | Give()->session_db->__replace( |
408 | 408 | Give()->session_db->table_name, |
409 | 409 | array( |
410 | 410 | 'session_key' => $this->donor_id, |
411 | - 'session_value' => maybe_serialize( $this->session ), |
|
411 | + 'session_value' => maybe_serialize($this->session), |
|
412 | 412 | 'session_expiry' => $this->session_expiration, |
413 | 413 | ), |
414 | 414 | array( |
@@ -429,10 +429,10 @@ discard block |
||
429 | 429 | * @access public |
430 | 430 | */ |
431 | 431 | public function destroy_session() { |
432 | - give_setcookie( $this->cookie_name, '', time() - YEAR_IN_SECONDS, apply_filters( 'give_session_use_secure_cookie', false ) ); |
|
433 | - give_setcookie( $this->nonce_cookie_name, '', time() - YEAR_IN_SECONDS, apply_filters( 'give_session_use_secure_cookie', false ) ); |
|
432 | + give_setcookie($this->cookie_name, '', time() - YEAR_IN_SECONDS, apply_filters('give_session_use_secure_cookie', false)); |
|
433 | + give_setcookie($this->nonce_cookie_name, '', time() - YEAR_IN_SECONDS, apply_filters('give_session_use_secure_cookie', false)); |
|
434 | 434 | |
435 | - Give()->session_db->delete_session( $this->donor_id ); |
|
435 | + Give()->session_db->delete_session($this->donor_id); |
|
436 | 436 | |
437 | 437 | $this->session = array(); |
438 | 438 | $this->session_data_changed = false; |
@@ -448,10 +448,10 @@ discard block |
||
448 | 448 | * |
449 | 449 | * @return bool |
450 | 450 | */ |
451 | - public function is_delete_nonce_cookie(){ |
|
451 | + public function is_delete_nonce_cookie() { |
|
452 | 452 | $value = false; |
453 | 453 | |
454 | - if ( Give()->session->has_session() ) { |
|
454 | + if (Give()->session->has_session()) { |
|
455 | 455 | $value = true; |
456 | 456 | } |
457 | 457 | |
@@ -468,10 +468,10 @@ discard block |
||
468 | 468 | * |
469 | 469 | * @return string Cookie name |
470 | 470 | */ |
471 | - public function get_cookie_name( $type = '' ) { |
|
471 | + public function get_cookie_name($type = '') { |
|
472 | 472 | $name = ''; |
473 | 473 | |
474 | - switch ( $type ) { |
|
474 | + switch ($type) { |
|
475 | 475 | case 'nonce': |
476 | 476 | $name = $this->nonce_cookie_name; |
477 | 477 | break; |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | * |
496 | 496 | * @return string |
497 | 497 | */ |
498 | - public function __nonce_user_logged_out( $uid ) { |
|
498 | + public function __nonce_user_logged_out($uid) { |
|
499 | 499 | return $this->has_session() && $this->donor_id ? $this->donor_id : $uid; |
500 | 500 | } |
501 | 501 | |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | */ |
542 | 542 | public function set_expiration_variant_time() { |
543 | 543 | |
544 | - return ( ! empty( $this->exp_option ) ? ( intval( $this->exp_option ) - 3600 ) : 30 * 60 * 23 ); |
|
544 | + return ( ! empty($this->exp_option) ? (intval($this->exp_option) - 3600) : 30 * 60 * 23); |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | /** |
@@ -558,9 +558,9 @@ discard block |
||
558 | 558 | public function use_php_sessions() { |
559 | 559 | $ret = false; |
560 | 560 | |
561 | - give_doing_it_wrong( __FUNCTION__, __( 'We are using database session logic instead of PHP session', 'give' ), '2.2.0' ); |
|
561 | + give_doing_it_wrong(__FUNCTION__, __('We are using database session logic instead of PHP session', 'give'), '2.2.0'); |
|
562 | 562 | |
563 | - return (bool) apply_filters( 'give_use_php_sessions', $ret ); |
|
563 | + return (bool) apply_filters('give_use_php_sessions', $ret); |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | /** |
@@ -578,10 +578,10 @@ discard block |
||
578 | 578 | |
579 | 579 | $start_session = true; |
580 | 580 | |
581 | - give_doing_it_wrong( __FUNCTION__, __( 'We are using database session logic instead of PHP session', 'give' ), '2.2.0' ); |
|
581 | + give_doing_it_wrong(__FUNCTION__, __('We are using database session logic instead of PHP session', 'give'), '2.2.0'); |
|
582 | 582 | |
583 | 583 | |
584 | - if ( ! empty( $_SERVER['REQUEST_URI'] ) ) { // @codingStandardsIgnoreLine |
|
584 | + if ( ! empty($_SERVER['REQUEST_URI'])) { // @codingStandardsIgnoreLine |
|
585 | 585 | |
586 | 586 | $blacklist = apply_filters( |
587 | 587 | 'give_session_start_uri_blacklist', array( |
@@ -594,19 +594,19 @@ discard block |
||
594 | 594 | 'comments/feed/', |
595 | 595 | ) |
596 | 596 | ); |
597 | - $uri = ltrim( $_SERVER['REQUEST_URI'], '/' ); // // @codingStandardsIgnoreLine |
|
598 | - $uri = untrailingslashit( $uri ); |
|
599 | - if ( in_array( $uri, $blacklist, true ) ) { |
|
597 | + $uri = ltrim($_SERVER['REQUEST_URI'], '/'); // // @codingStandardsIgnoreLine |
|
598 | + $uri = untrailingslashit($uri); |
|
599 | + if (in_array($uri, $blacklist, true)) { |
|
600 | 600 | $start_session = false; |
601 | 601 | } |
602 | - if ( false !== strpos( $uri, 'feed=' ) ) { |
|
602 | + if (false !== strpos($uri, 'feed=')) { |
|
603 | 603 | $start_session = false; |
604 | 604 | } |
605 | - if ( is_admin() ) { |
|
605 | + if (is_admin()) { |
|
606 | 606 | $start_session = false; |
607 | 607 | } |
608 | 608 | } |
609 | 609 | |
610 | - return apply_filters( 'give_start_session', $start_session ); |
|
610 | + return apply_filters('give_start_session', $start_session); |
|
611 | 611 | } |
612 | 612 | } |