@@ -1012,7 +1012,7 @@ |
||
1012 | 1012 | // Find a match between price_id and level_id. |
1013 | 1013 | // First verify array keys exists THEN make the match. |
1014 | 1014 | if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) ) |
1015 | - && $args['price_id'] == $price['_give_id']['level_id'] |
|
1015 | + && $args['price_id'] == $price['_give_id']['level_id'] |
|
1016 | 1016 | ) { |
1017 | 1017 | $donation_amount = $price['_give_amount']; |
1018 | 1018 | } |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | * |
392 | 392 | * @param int|bool $payment_id A given payment |
393 | 393 | * |
394 | - * @return mixed void|false |
|
394 | + * @return false|null void|false |
|
395 | 395 | */ |
396 | 396 | public function __construct( $payment_id = false ) { |
397 | 397 | |
@@ -1115,7 +1115,7 @@ discard block |
||
1115 | 1115 | * |
1116 | 1116 | * @param string|bool $note The note to add |
1117 | 1117 | * |
1118 | - * @return bool If the note was specified or not |
|
1118 | + * @return false|null If the note was specified or not |
|
1119 | 1119 | */ |
1120 | 1120 | public function add_note( $note = false ) { |
1121 | 1121 | // 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 | |
@@ -395,13 +395,13 @@ discard block |
||
395 | 395 | * |
396 | 396 | * @return mixed void|false |
397 | 397 | */ |
398 | - public function __construct( $payment_id = false ) { |
|
398 | + public function __construct($payment_id = false) { |
|
399 | 399 | |
400 | - if ( empty( $payment_id ) ) { |
|
400 | + if (empty($payment_id)) { |
|
401 | 401 | return false; |
402 | 402 | } |
403 | 403 | |
404 | - $this->setup_payment( $payment_id ); |
|
404 | + $this->setup_payment($payment_id); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | /** |
@@ -414,11 +414,11 @@ discard block |
||
414 | 414 | * |
415 | 415 | * @return mixed The value. |
416 | 416 | */ |
417 | - public function __get( $key ) { |
|
417 | + public function __get($key) { |
|
418 | 418 | |
419 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
419 | + if (method_exists($this, 'get_'.$key)) { |
|
420 | 420 | |
421 | - $value = call_user_func( array( $this, 'get_' . $key ) ); |
|
421 | + $value = call_user_func(array($this, 'get_'.$key)); |
|
422 | 422 | |
423 | 423 | } else { |
424 | 424 | |
@@ -440,18 +440,18 @@ discard block |
||
440 | 440 | * @param string $key The property name |
441 | 441 | * @param mixed $value The value of the property |
442 | 442 | */ |
443 | - public function __set( $key, $value ) { |
|
444 | - $ignore = array( '_ID' ); |
|
443 | + public function __set($key, $value) { |
|
444 | + $ignore = array('_ID'); |
|
445 | 445 | |
446 | - if ( 'status' === $key ) { |
|
446 | + if ('status' === $key) { |
|
447 | 447 | $this->old_status = $this->status; |
448 | 448 | } |
449 | 449 | |
450 | - if ( ! in_array( $key, $ignore ) ) { |
|
451 | - $this->pending[ $key ] = $value; |
|
450 | + if ( ! in_array($key, $ignore)) { |
|
451 | + $this->pending[$key] = $value; |
|
452 | 452 | } |
453 | 453 | |
454 | - if ( '_ID' !== $key ) { |
|
454 | + if ('_ID' !== $key) { |
|
455 | 455 | $this->$key = $value; |
456 | 456 | } |
457 | 457 | } |
@@ -466,9 +466,9 @@ discard block |
||
466 | 466 | * |
467 | 467 | * @return boolean|null If the item is set or not |
468 | 468 | */ |
469 | - public function __isset( $name ) { |
|
470 | - if ( property_exists( $this, $name ) ) { |
|
471 | - return false === empty( $this->$name ); |
|
469 | + public function __isset($name) { |
|
470 | + if (property_exists($this, $name)) { |
|
471 | + return false === empty($this->$name); |
|
472 | 472 | } else { |
473 | 473 | return null; |
474 | 474 | } |
@@ -484,20 +484,20 @@ discard block |
||
484 | 484 | * |
485 | 485 | * @return bool If the setup was successful or not |
486 | 486 | */ |
487 | - private function setup_payment( $payment_id ) { |
|
487 | + private function setup_payment($payment_id) { |
|
488 | 488 | $this->pending = array(); |
489 | 489 | |
490 | - if ( empty( $payment_id ) ) { |
|
490 | + if (empty($payment_id)) { |
|
491 | 491 | return false; |
492 | 492 | } |
493 | 493 | |
494 | - $payment = get_post( absint( $payment_id ) ); |
|
494 | + $payment = get_post(absint($payment_id)); |
|
495 | 495 | |
496 | - if ( ! $payment || is_wp_error( $payment ) ) { |
|
496 | + if ( ! $payment || is_wp_error($payment)) { |
|
497 | 497 | return false; |
498 | 498 | } |
499 | 499 | |
500 | - if ( 'give_payment' !== $payment->post_type ) { |
|
500 | + if ('give_payment' !== $payment->post_type) { |
|
501 | 501 | return false; |
502 | 502 | } |
503 | 503 | |
@@ -511,17 +511,17 @@ discard block |
||
511 | 511 | * @param Give_Payment $this Payment object. |
512 | 512 | * @param int $payment_id The ID of the payment. |
513 | 513 | */ |
514 | - do_action( 'give_pre_setup_payment', $this, $payment_id ); |
|
514 | + do_action('give_pre_setup_payment', $this, $payment_id); |
|
515 | 515 | |
516 | 516 | // Get payment from cache. |
517 | - $donation_vars = Give_Cache::get_group( $payment_id, 'give-donations' ); |
|
517 | + $donation_vars = Give_Cache::get_group($payment_id, 'give-donations'); |
|
518 | 518 | |
519 | - if ( is_null( $donation_vars ) ) { |
|
519 | + if (is_null($donation_vars)) { |
|
520 | 520 | // Primary Identifier. |
521 | - $this->ID = absint( $payment_id ); |
|
521 | + $this->ID = absint($payment_id); |
|
522 | 522 | |
523 | 523 | // Protected ID that can never be changed. |
524 | - $this->_ID = absint( $payment_id ); |
|
524 | + $this->_ID = absint($payment_id); |
|
525 | 525 | |
526 | 526 | // We have a payment, get the generic payment_meta item to reduce calls to it. |
527 | 527 | $this->payment_meta = $this->get_meta(); |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | $this->parent_payment = $payment->post_parent; |
538 | 538 | |
539 | 539 | $all_payment_statuses = give_get_payment_statuses(); |
540 | - $this->status_nicename = array_key_exists( $this->status, $all_payment_statuses ) ? $all_payment_statuses[ $this->status ] : ucfirst( $this->status ); |
|
540 | + $this->status_nicename = array_key_exists($this->status, $all_payment_statuses) ? $all_payment_statuses[$this->status] : ucfirst($this->status); |
|
541 | 541 | |
542 | 542 | // Currency Based. |
543 | 543 | $this->total = $this->setup_total(); |
@@ -566,10 +566,10 @@ discard block |
||
566 | 566 | $this->key = $this->setup_payment_key(); |
567 | 567 | $this->number = $this->setup_payment_number(); |
568 | 568 | |
569 | - Give_Cache::set_group( $this->ID, get_object_vars( $this ), 'give-donations' ); |
|
569 | + Give_Cache::set_group($this->ID, get_object_vars($this), 'give-donations'); |
|
570 | 570 | } else { |
571 | 571 | |
572 | - foreach ( $donation_vars as $donation_var => $value ) { |
|
572 | + foreach ($donation_vars as $donation_var => $value) { |
|
573 | 573 | $this->$donation_var = $value; |
574 | 574 | } |
575 | 575 | } |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | * @param Give_Payment $this Payment object. |
585 | 585 | * @param int $payment_id The ID of the payment. |
586 | 586 | */ |
587 | - do_action( 'give_setup_payment', $this, $payment_id ); |
|
587 | + do_action('give_setup_payment', $this, $payment_id); |
|
588 | 588 | |
589 | 589 | return true; |
590 | 590 | } |
@@ -603,11 +603,11 @@ discard block |
||
603 | 603 | * |
604 | 604 | * @return void |
605 | 605 | */ |
606 | - public function update_payment_setup( $payment_id ) { |
|
606 | + public function update_payment_setup($payment_id) { |
|
607 | 607 | // Delete cache. |
608 | - Give_Cache::delete_group( $this->ID,'give-donations' ); |
|
608 | + Give_Cache::delete_group($this->ID, 'give-donations'); |
|
609 | 609 | |
610 | - $this->setup_payment( $payment_id ); |
|
610 | + $this->setup_payment($payment_id); |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | /** |
@@ -622,24 +622,24 @@ discard block |
||
622 | 622 | |
623 | 623 | // Construct the payment title. |
624 | 624 | $payment_title = ''; |
625 | - if ( ! empty( $this->first_name ) && ! empty( $this->last_name ) ) { |
|
626 | - $payment_title = $this->first_name . ' ' . $this->last_name; |
|
627 | - } elseif ( ! empty( $this->first_name ) && empty( $this->last_name ) ) { |
|
625 | + if ( ! empty($this->first_name) && ! empty($this->last_name)) { |
|
626 | + $payment_title = $this->first_name.' '.$this->last_name; |
|
627 | + } elseif ( ! empty($this->first_name) && empty($this->last_name)) { |
|
628 | 628 | $payment_title = $this->first_name; |
629 | - } elseif ( ! empty( $this->email ) && is_email( $this->email ) ) { |
|
629 | + } elseif ( ! empty($this->email) && is_email($this->email)) { |
|
630 | 630 | $payment_title = $this->email; |
631 | 631 | } |
632 | 632 | |
633 | 633 | // Set Key. |
634 | - if ( empty( $this->key ) ) { |
|
634 | + if (empty($this->key)) { |
|
635 | 635 | |
636 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
637 | - $this->key = strtolower( md5( $this->email . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) ); // Unique key |
|
636 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
637 | + $this->key = strtolower(md5($this->email.date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); // Unique key |
|
638 | 638 | $this->pending['key'] = $this->key; |
639 | 639 | } |
640 | 640 | |
641 | 641 | // Set IP. |
642 | - if ( empty( $this->ip ) ) { |
|
642 | + if (empty($this->ip)) { |
|
643 | 643 | |
644 | 644 | $this->ip = give_get_ip(); |
645 | 645 | $this->pending['ip'] = $this->ip; |
@@ -668,19 +668,19 @@ discard block |
||
668 | 668 | 'status' => $this->status, |
669 | 669 | ); |
670 | 670 | |
671 | - $args = apply_filters( 'give_insert_payment_args', array( |
|
671 | + $args = apply_filters('give_insert_payment_args', array( |
|
672 | 672 | 'post_title' => $payment_title, |
673 | 673 | 'post_status' => $this->status, |
674 | 674 | 'post_type' => 'give_payment', |
675 | - 'post_date' => ! empty( $this->date ) ? $this->date : null, |
|
676 | - 'post_date_gmt' => ! empty( $this->date ) ? get_gmt_from_date( $this->date ) : null, |
|
675 | + 'post_date' => ! empty($this->date) ? $this->date : null, |
|
676 | + 'post_date_gmt' => ! empty($this->date) ? get_gmt_from_date($this->date) : null, |
|
677 | 677 | 'post_parent' => $this->parent_payment, |
678 | - ), $payment_data ); |
|
678 | + ), $payment_data); |
|
679 | 679 | |
680 | 680 | // Create a blank payment |
681 | - $payment_id = wp_insert_post( $args ); |
|
681 | + $payment_id = wp_insert_post($args); |
|
682 | 682 | |
683 | - if ( ! empty( $payment_id ) ) { |
|
683 | + if ( ! empty($payment_id)) { |
|
684 | 684 | |
685 | 685 | $this->ID = $payment_id; |
686 | 686 | $this->_ID = $payment_id; |
@@ -692,42 +692,42 @@ discard block |
||
692 | 692 | * |
693 | 693 | * @since 1.8.13 |
694 | 694 | */ |
695 | - $donor = apply_filters( 'give_update_donor_information', $donor, $payment_id, $payment_data, $args ); |
|
695 | + $donor = apply_filters('give_update_donor_information', $donor, $payment_id, $payment_data, $args); |
|
696 | 696 | |
697 | - if ( did_action( 'give_pre_process_donation' ) && is_user_logged_in() ) { |
|
698 | - $donor = new Give_Donor( get_current_user_id(), true ); |
|
697 | + if (did_action('give_pre_process_donation') && is_user_logged_in()) { |
|
698 | + $donor = new Give_Donor(get_current_user_id(), true); |
|
699 | 699 | |
700 | 700 | // Donor is logged in but used a different email to purchase with so assign to their donor record. |
701 | - if ( ! empty( $donor->id ) && $this->email !== $donor->email ) { |
|
702 | - $donor->add_email( $this->email ); |
|
701 | + if ( ! empty($donor->id) && $this->email !== $donor->email) { |
|
702 | + $donor->add_email($this->email); |
|
703 | 703 | } |
704 | 704 | } |
705 | 705 | |
706 | - if ( empty( $donor->id ) ) { |
|
707 | - $donor = new Give_Donor( $this->email ); |
|
706 | + if (empty($donor->id)) { |
|
707 | + $donor = new Give_Donor($this->email); |
|
708 | 708 | } |
709 | 709 | |
710 | - if ( empty( $donor->id ) ) { |
|
710 | + if (empty($donor->id)) { |
|
711 | 711 | |
712 | 712 | $donor_data = array( |
713 | - 'name' => ! is_email( $payment_title ) ? $this->first_name . ' ' . $this->last_name : '', |
|
713 | + 'name' => ! is_email($payment_title) ? $this->first_name.' '.$this->last_name : '', |
|
714 | 714 | 'email' => $this->email, |
715 | 715 | 'user_id' => $this->user_id, |
716 | 716 | ); |
717 | 717 | |
718 | - $donor->create( $donor_data ); |
|
718 | + $donor->create($donor_data); |
|
719 | 719 | |
720 | 720 | } |
721 | 721 | |
722 | 722 | // Update Donor Meta once donor is created. |
723 | - $donor->update_meta( '_give_donor_first_name', $this->first_name ); |
|
724 | - $donor->update_meta( '_give_donor_last_name', $this->last_name ); |
|
723 | + $donor->update_meta('_give_donor_first_name', $this->first_name); |
|
724 | + $donor->update_meta('_give_donor_last_name', $this->last_name); |
|
725 | 725 | |
726 | 726 | $this->customer_id = $donor->id; |
727 | 727 | $this->pending['customer_id'] = $this->customer_id; |
728 | - $donor->attach_payment( $this->ID, false ); |
|
728 | + $donor->attach_payment($this->ID, false); |
|
729 | 729 | |
730 | - $this->payment_meta = apply_filters( 'give_payment_meta', $this->payment_meta, $payment_data ); |
|
730 | + $this->payment_meta = apply_filters('give_payment_meta', $this->payment_meta, $payment_data); |
|
731 | 731 | |
732 | 732 | /* |
733 | 733 | * _give_payment_meta backward compatibility. |
@@ -735,25 +735,25 @@ discard block |
||
735 | 735 | * @since 2.0.1 |
736 | 736 | */ |
737 | 737 | $custom_payment_meta = array_diff( |
738 | - array_map( 'maybe_serialize', $this->payment_meta ), |
|
739 | - array_map( 'maybe_serialize', $payment_data ) |
|
738 | + array_map('maybe_serialize', $this->payment_meta), |
|
739 | + array_map('maybe_serialize', $payment_data) |
|
740 | 740 | ); |
741 | 741 | |
742 | - if( ! empty( $custom_payment_meta ) ) { |
|
743 | - 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' ); |
|
742 | + if ( ! empty($custom_payment_meta)) { |
|
743 | + 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'); |
|
744 | 744 | |
745 | - $this->update_meta( '_give_payment_meta', array_map( 'maybe_unserialize', $custom_payment_meta ) ); |
|
745 | + $this->update_meta('_give_payment_meta', array_map('maybe_unserialize', $custom_payment_meta)); |
|
746 | 746 | } |
747 | 747 | |
748 | - $give_company = ( ! empty( $_REQUEST['give_company_name'] ) ? give_clean( $_REQUEST['give_company_name'] ) : '' ); |
|
748 | + $give_company = ( ! empty($_REQUEST['give_company_name']) ? give_clean($_REQUEST['give_company_name']) : ''); |
|
749 | 749 | |
750 | 750 | // Check $page_url is not empty. |
751 | - if ( $give_company ) { |
|
752 | - give_update_meta( $payment_id, '_give_donation_company', $give_company ); |
|
751 | + if ($give_company) { |
|
752 | + give_update_meta($payment_id, '_give_donation_company', $give_company); |
|
753 | 753 | |
754 | - $donor_id = absint( $donor->id ); |
|
755 | - if ( ! empty( $donor_id ) ) { |
|
756 | - Give()->donor_meta->update_meta( $donor_id, '_give_donor_company', $give_company ); |
|
754 | + $donor_id = absint($donor->id); |
|
755 | + if ( ! empty($donor_id)) { |
|
756 | + Give()->donor_meta->update_meta($donor_id, '_give_donor_company', $give_company); |
|
757 | 757 | } |
758 | 758 | } |
759 | 759 | |
@@ -777,11 +777,11 @@ discard block |
||
777 | 777 | $saved = false; |
778 | 778 | |
779 | 779 | // Must have an ID. |
780 | - if ( empty( $this->ID ) ) { |
|
780 | + if (empty($this->ID)) { |
|
781 | 781 | |
782 | 782 | $payment_id = $this->insert_payment(); |
783 | 783 | |
784 | - if ( false === $payment_id ) { |
|
784 | + if (false === $payment_id) { |
|
785 | 785 | $saved = false; |
786 | 786 | } else { |
787 | 787 | $this->ID = $payment_id; |
@@ -789,42 +789,42 @@ discard block |
||
789 | 789 | } |
790 | 790 | |
791 | 791 | // Set ID if not matching. |
792 | - if ( $this->ID !== $this->_ID ) { |
|
792 | + if ($this->ID !== $this->_ID) { |
|
793 | 793 | $this->ID = $this->_ID; |
794 | 794 | } |
795 | 795 | |
796 | 796 | // If we have something pending, let's save it. |
797 | - if ( ! empty( $this->pending ) ) { |
|
797 | + if ( ! empty($this->pending)) { |
|
798 | 798 | |
799 | 799 | $total_increase = 0; |
800 | 800 | $total_decrease = 0; |
801 | 801 | |
802 | - foreach ( $this->pending as $key => $value ) { |
|
802 | + foreach ($this->pending as $key => $value) { |
|
803 | 803 | |
804 | - switch ( $key ) { |
|
804 | + switch ($key) { |
|
805 | 805 | |
806 | 806 | case 'donations': |
807 | 807 | // Update totals for pending donations. |
808 | - foreach ( $this->pending[ $key ] as $item ) { |
|
808 | + foreach ($this->pending[$key] as $item) { |
|
809 | 809 | |
810 | - $quantity = isset( $item['quantity'] ) ? $item['quantity'] : 1; |
|
811 | - $price_id = isset( $item['price_id'] ) ? $item['price_id'] : 0; |
|
810 | + $quantity = isset($item['quantity']) ? $item['quantity'] : 1; |
|
811 | + $price_id = isset($item['price_id']) ? $item['price_id'] : 0; |
|
812 | 812 | |
813 | - switch ( $item['action'] ) { |
|
813 | + switch ($item['action']) { |
|
814 | 814 | |
815 | 815 | case 'add': |
816 | 816 | |
817 | 817 | $price = $item['price']; |
818 | 818 | |
819 | - if ( 'publish' === $this->status || 'complete' === $this->status ) { |
|
819 | + if ('publish' === $this->status || 'complete' === $this->status) { |
|
820 | 820 | |
821 | 821 | // Add donation to logs. |
822 | - $log_date = date_i18n( 'Y-m-d G:i:s', current_time( 'timestamp' ) ); |
|
823 | - give_record_donation_in_log( $item['id'], $this->ID, $price_id, $log_date ); |
|
822 | + $log_date = date_i18n('Y-m-d G:i:s', current_time('timestamp')); |
|
823 | + give_record_donation_in_log($item['id'], $this->ID, $price_id, $log_date); |
|
824 | 824 | |
825 | - $form = new Give_Donate_Form( $item['id'] ); |
|
826 | - $form->increase_sales( $quantity ); |
|
827 | - $form->increase_earnings( $price, $this->ID ); |
|
825 | + $form = new Give_Donate_Form($item['id']); |
|
826 | + $form->increase_sales($quantity); |
|
827 | + $form->increase_earnings($price, $this->ID); |
|
828 | 828 | |
829 | 829 | $total_increase += $price; |
830 | 830 | } |
@@ -832,10 +832,10 @@ discard block |
||
832 | 832 | |
833 | 833 | case 'remove': |
834 | 834 | $this->delete_sales_logs(); |
835 | - if ( 'publish' === $this->status || 'complete' === $this->status ) { |
|
836 | - $form = new Give_Donate_Form( $item['id'] ); |
|
837 | - $form->decrease_sales( $quantity ); |
|
838 | - $form->decrease_earnings( $item['amount'], $this->ID ); |
|
835 | + if ('publish' === $this->status || 'complete' === $this->status) { |
|
836 | + $form = new Give_Donate_Form($item['id']); |
|
837 | + $form->decrease_sales($quantity); |
|
838 | + $form->decrease_earnings($item['amount'], $this->ID); |
|
839 | 839 | |
840 | 840 | $total_decrease += $item['amount']; |
841 | 841 | } |
@@ -846,27 +846,27 @@ discard block |
||
846 | 846 | break; |
847 | 847 | |
848 | 848 | case 'status': |
849 | - $this->update_status( $this->status ); |
|
849 | + $this->update_status($this->status); |
|
850 | 850 | break; |
851 | 851 | |
852 | 852 | case 'gateway': |
853 | - $this->update_meta( '_give_payment_gateway', $this->gateway ); |
|
853 | + $this->update_meta('_give_payment_gateway', $this->gateway); |
|
854 | 854 | break; |
855 | 855 | |
856 | 856 | case 'mode': |
857 | - $this->update_meta( '_give_payment_mode', $this->mode ); |
|
857 | + $this->update_meta('_give_payment_mode', $this->mode); |
|
858 | 858 | break; |
859 | 859 | |
860 | 860 | case 'transaction_id': |
861 | - $this->update_meta( '_give_payment_transaction_id', $this->transaction_id ); |
|
861 | + $this->update_meta('_give_payment_transaction_id', $this->transaction_id); |
|
862 | 862 | break; |
863 | 863 | |
864 | 864 | case 'ip': |
865 | - $this->update_meta( '_give_payment_donor_ip', $this->ip ); |
|
865 | + $this->update_meta('_give_payment_donor_ip', $this->ip); |
|
866 | 866 | break; |
867 | 867 | |
868 | 868 | case 'customer_id': |
869 | - $this->update_meta( '_give_payment_donor_id', $this->customer_id ); |
|
869 | + $this->update_meta('_give_payment_donor_id', $this->customer_id); |
|
870 | 870 | break; |
871 | 871 | |
872 | 872 | // case 'user_id': |
@@ -874,61 +874,61 @@ discard block |
||
874 | 874 | // break; |
875 | 875 | |
876 | 876 | case 'form_title': |
877 | - $this->update_meta( '_give_payment_form_title', $this->form_title ); |
|
877 | + $this->update_meta('_give_payment_form_title', $this->form_title); |
|
878 | 878 | break; |
879 | 879 | |
880 | 880 | case 'form_id': |
881 | - $this->update_meta( '_give_payment_form_id', $this->form_id ); |
|
881 | + $this->update_meta('_give_payment_form_id', $this->form_id); |
|
882 | 882 | break; |
883 | 883 | |
884 | 884 | case 'price_id': |
885 | - $this->update_meta( '_give_payment_price_id', $this->price_id ); |
|
885 | + $this->update_meta('_give_payment_price_id', $this->price_id); |
|
886 | 886 | break; |
887 | 887 | |
888 | 888 | case 'first_name': |
889 | - $this->update_meta( '_give_donor_billing_first_name', $this->first_name ); |
|
889 | + $this->update_meta('_give_donor_billing_first_name', $this->first_name); |
|
890 | 890 | break; |
891 | 891 | |
892 | 892 | case 'last_name': |
893 | - $this->update_meta( '_give_donor_billing_last_name', $this->last_name ); |
|
893 | + $this->update_meta('_give_donor_billing_last_name', $this->last_name); |
|
894 | 894 | break; |
895 | 895 | |
896 | 896 | case 'currency': |
897 | - $this->update_meta( '_give_payment_currency', $this->currency ); |
|
897 | + $this->update_meta('_give_payment_currency', $this->currency); |
|
898 | 898 | break; |
899 | 899 | |
900 | 900 | case 'address': |
901 | - if ( ! empty( $this->address ) ) { |
|
902 | - foreach ( $this->address as $address_name => $address ) { |
|
903 | - switch ( $address_name ) { |
|
901 | + if ( ! empty($this->address)) { |
|
902 | + foreach ($this->address as $address_name => $address) { |
|
903 | + switch ($address_name) { |
|
904 | 904 | case 'line1': |
905 | - $this->update_meta( '_give_donor_billing_address1', $address ); |
|
905 | + $this->update_meta('_give_donor_billing_address1', $address); |
|
906 | 906 | break; |
907 | 907 | |
908 | 908 | case 'line2': |
909 | - $this->update_meta( '_give_donor_billing_address2', $address ); |
|
909 | + $this->update_meta('_give_donor_billing_address2', $address); |
|
910 | 910 | break; |
911 | 911 | |
912 | 912 | default: |
913 | - $this->update_meta( "_give_donor_billing_{$address_name}", $address ); |
|
913 | + $this->update_meta("_give_donor_billing_{$address_name}", $address); |
|
914 | 914 | } |
915 | 915 | } |
916 | 916 | } |
917 | 917 | break; |
918 | 918 | |
919 | 919 | case 'email': |
920 | - $this->update_meta( '_give_payment_donor_email', $this->email ); |
|
920 | + $this->update_meta('_give_payment_donor_email', $this->email); |
|
921 | 921 | break; |
922 | 922 | |
923 | 923 | case 'key': |
924 | - $this->update_meta( '_give_payment_purchase_key', $this->key ); |
|
924 | + $this->update_meta('_give_payment_purchase_key', $this->key); |
|
925 | 925 | break; |
926 | 926 | |
927 | 927 | case 'number': |
928 | 928 | // @todo: remove unused meta data. |
929 | 929 | // Core is using post_title to store donation serial code ( fi enabled ) instead this meta key. |
930 | 930 | // Do not use this meta key in your logic, can be remove in future |
931 | - $this->update_meta( '_give_payment_number', $this->number ); |
|
931 | + $this->update_meta('_give_payment_number', $this->number); |
|
932 | 932 | break; |
933 | 933 | |
934 | 934 | case 'date': |
@@ -938,11 +938,11 @@ discard block |
||
938 | 938 | 'edit_date' => true, |
939 | 939 | ); |
940 | 940 | |
941 | - wp_update_post( $args ); |
|
941 | + wp_update_post($args); |
|
942 | 942 | break; |
943 | 943 | |
944 | 944 | case 'completed_date': |
945 | - $this->update_meta( '_give_completed_date', $this->completed_date ); |
|
945 | + $this->update_meta('_give_completed_date', $this->completed_date); |
|
946 | 946 | break; |
947 | 947 | |
948 | 948 | case 'parent_payment': |
@@ -951,11 +951,11 @@ discard block |
||
951 | 951 | 'post_parent' => $this->parent_payment, |
952 | 952 | ); |
953 | 953 | |
954 | - wp_update_post( $args ); |
|
954 | + wp_update_post($args); |
|
955 | 955 | break; |
956 | 956 | |
957 | 957 | case 'total': |
958 | - $this->update_meta( '_give_payment_total', give_sanitize_amount_for_db( $this->total ) ); |
|
958 | + $this->update_meta('_give_payment_total', give_sanitize_amount_for_db($this->total)); |
|
959 | 959 | break; |
960 | 960 | |
961 | 961 | default: |
@@ -966,46 +966,46 @@ discard block |
||
966 | 966 | * |
967 | 967 | * @param Give_Payment $this Payment object. |
968 | 968 | */ |
969 | - do_action( 'give_payment_save', $this, $key ); |
|
969 | + do_action('give_payment_save', $this, $key); |
|
970 | 970 | break; |
971 | 971 | }// End switch(). |
972 | 972 | }// End foreach(). |
973 | 973 | |
974 | - if ( 'pending' !== $this->status ) { |
|
974 | + if ('pending' !== $this->status) { |
|
975 | 975 | |
976 | - $donor = new Give_Donor( $this->customer_id ); |
|
976 | + $donor = new Give_Donor($this->customer_id); |
|
977 | 977 | |
978 | 978 | $total_change = $total_increase - $total_decrease; |
979 | - if ( $total_change < 0 ) { |
|
979 | + if ($total_change < 0) { |
|
980 | 980 | |
981 | - $total_change = - ( $total_change ); |
|
981 | + $total_change = - ($total_change); |
|
982 | 982 | |
983 | 983 | // Decrease the donor's donation stats. |
984 | - $donor->decrease_value( $total_change ); |
|
985 | - give_decrease_total_earnings( $total_change ); |
|
984 | + $donor->decrease_value($total_change); |
|
985 | + give_decrease_total_earnings($total_change); |
|
986 | 986 | |
987 | 987 | $donor->decrease_donation_count(); |
988 | 988 | |
989 | - } elseif ( $total_change > 0 ) { |
|
989 | + } elseif ($total_change > 0) { |
|
990 | 990 | |
991 | 991 | // Increase the donor's donation stats. |
992 | - $donor->increase_value( $total_change ); |
|
993 | - give_increase_total_earnings( $total_change ); |
|
992 | + $donor->increase_value($total_change); |
|
993 | + give_increase_total_earnings($total_change); |
|
994 | 994 | |
995 | 995 | $donor->increase_purchase_count(); |
996 | 996 | |
997 | 997 | } |
998 | 998 | |
999 | 999 | // Verify and update form meta based on the form status. |
1000 | - give_set_form_closed_status( $this->form_id ); |
|
1000 | + give_set_form_closed_status($this->form_id); |
|
1001 | 1001 | } |
1002 | 1002 | |
1003 | 1003 | $this->pending = array(); |
1004 | 1004 | $saved = true; |
1005 | 1005 | }// End if(). |
1006 | 1006 | |
1007 | - if ( true === $saved ) { |
|
1008 | - $this->setup_payment( $this->ID ); |
|
1007 | + if (true === $saved) { |
|
1008 | + $this->setup_payment($this->ID); |
|
1009 | 1009 | } |
1010 | 1010 | |
1011 | 1011 | return $saved; |
@@ -1023,12 +1023,12 @@ discard block |
||
1023 | 1023 | * |
1024 | 1024 | * @return bool True when successful, false otherwise |
1025 | 1025 | */ |
1026 | - public function add_donation( $form_id = 0, $args = array(), $options = array() ) { |
|
1026 | + public function add_donation($form_id = 0, $args = array(), $options = array()) { |
|
1027 | 1027 | |
1028 | - $donation = new Give_Donate_Form( $form_id ); |
|
1028 | + $donation = new Give_Donate_Form($form_id); |
|
1029 | 1029 | |
1030 | 1030 | // Bail if this post isn't a give donation form. |
1031 | - if ( ! $donation || $donation->post_type !== 'give_forms' ) { |
|
1031 | + if ( ! $donation || $donation->post_type !== 'give_forms') { |
|
1032 | 1032 | return false; |
1033 | 1033 | } |
1034 | 1034 | |
@@ -1038,59 +1038,59 @@ discard block |
||
1038 | 1038 | 'price_id' => false, |
1039 | 1039 | ); |
1040 | 1040 | |
1041 | - $args = wp_parse_args( apply_filters( 'give_payment_add_donation_args', $args, $donation->ID ), $defaults ); |
|
1041 | + $args = wp_parse_args(apply_filters('give_payment_add_donation_args', $args, $donation->ID), $defaults); |
|
1042 | 1042 | |
1043 | 1043 | // Allow overriding the price. |
1044 | - if ( false !== $args['price'] ) { |
|
1044 | + if (false !== $args['price']) { |
|
1045 | 1045 | $donation_amount = $args['price']; |
1046 | 1046 | } else { |
1047 | 1047 | |
1048 | 1048 | // Deal with variable pricing. |
1049 | - if ( give_has_variable_prices( $donation->ID ) ) { |
|
1050 | - $prices = give_get_meta( $form_id, '_give_donation_levels', true ); |
|
1049 | + if (give_has_variable_prices($donation->ID)) { |
|
1050 | + $prices = give_get_meta($form_id, '_give_donation_levels', true); |
|
1051 | 1051 | $donation_amount = ''; |
1052 | 1052 | // Loop through prices. |
1053 | - foreach ( $prices as $price ) { |
|
1053 | + foreach ($prices as $price) { |
|
1054 | 1054 | // Find a match between price_id and level_id. |
1055 | 1055 | // First verify array keys exists THEN make the match. |
1056 | - if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) ) |
|
1056 | + if ((isset($args['price_id']) && isset($price['_give_id']['level_id'])) |
|
1057 | 1057 | && $args['price_id'] == $price['_give_id']['level_id'] |
1058 | 1058 | ) { |
1059 | 1059 | $donation_amount = $price['_give_amount']; |
1060 | 1060 | } |
1061 | 1061 | } |
1062 | 1062 | // Fallback to the lowest price point. |
1063 | - if ( $donation_amount == '' ) { |
|
1064 | - $donation_amount = give_get_lowest_price_option( $donation->ID ); |
|
1065 | - $args['price_id'] = give_get_lowest_price_id( $donation->ID ); |
|
1063 | + if ($donation_amount == '') { |
|
1064 | + $donation_amount = give_get_lowest_price_option($donation->ID); |
|
1065 | + $args['price_id'] = give_get_lowest_price_id($donation->ID); |
|
1066 | 1066 | } |
1067 | 1067 | } else { |
1068 | 1068 | // Simple form price. |
1069 | - $donation_amount = give_get_form_price( $donation->ID ); |
|
1069 | + $donation_amount = give_get_form_price($donation->ID); |
|
1070 | 1070 | } |
1071 | 1071 | } |
1072 | 1072 | |
1073 | 1073 | // Sanitizing the price here so we don't have a dozen calls later. |
1074 | - $donation_amount = give_maybe_sanitize_amount( $donation_amount ); |
|
1075 | - $total = round( $donation_amount, give_get_price_decimals( $this->ID ) ); |
|
1074 | + $donation_amount = give_maybe_sanitize_amount($donation_amount); |
|
1075 | + $total = round($donation_amount, give_get_price_decimals($this->ID)); |
|
1076 | 1076 | |
1077 | 1077 | // Add Options. |
1078 | 1078 | $default_options = array(); |
1079 | - if ( false !== $args['price_id'] ) { |
|
1079 | + if (false !== $args['price_id']) { |
|
1080 | 1080 | $default_options['price_id'] = (int) $args['price_id']; |
1081 | 1081 | } |
1082 | - $options = wp_parse_args( $options, $default_options ); |
|
1082 | + $options = wp_parse_args($options, $default_options); |
|
1083 | 1083 | |
1084 | 1084 | // Do not allow totals to go negative. |
1085 | - if ( $total < 0 ) { |
|
1085 | + if ($total < 0) { |
|
1086 | 1086 | $total = 0; |
1087 | 1087 | } |
1088 | 1088 | |
1089 | 1089 | $donation = array( |
1090 | 1090 | 'name' => $donation->post_title, |
1091 | 1091 | 'id' => $donation->ID, |
1092 | - 'price' => round( $total, give_get_price_decimals( $this->ID ) ), |
|
1093 | - 'subtotal' => round( $total, give_get_price_decimals( $this->ID ) ), |
|
1092 | + 'price' => round($total, give_get_price_decimals($this->ID)), |
|
1093 | + 'subtotal' => round($total, give_get_price_decimals($this->ID)), |
|
1094 | 1094 | 'price_id' => $args['price_id'], |
1095 | 1095 | 'action' => 'add', |
1096 | 1096 | 'options' => $options, |
@@ -1098,7 +1098,7 @@ discard block |
||
1098 | 1098 | |
1099 | 1099 | $this->pending['donations'][] = $donation; |
1100 | 1100 | |
1101 | - $this->increase_subtotal( $total ); |
|
1101 | + $this->increase_subtotal($total); |
|
1102 | 1102 | |
1103 | 1103 | return true; |
1104 | 1104 | |
@@ -1115,7 +1115,7 @@ discard block |
||
1115 | 1115 | * |
1116 | 1116 | * @return bool If the item was removed or not |
1117 | 1117 | */ |
1118 | - public function remove_donation( $form_id, $args = array() ) { |
|
1118 | + public function remove_donation($form_id, $args = array()) { |
|
1119 | 1119 | |
1120 | 1120 | // Set some defaults. |
1121 | 1121 | $defaults = array( |
@@ -1123,12 +1123,12 @@ discard block |
||
1123 | 1123 | 'price' => false, |
1124 | 1124 | 'price_id' => false, |
1125 | 1125 | ); |
1126 | - $args = wp_parse_args( $args, $defaults ); |
|
1126 | + $args = wp_parse_args($args, $defaults); |
|
1127 | 1127 | |
1128 | - $form = new Give_Donate_Form( $form_id ); |
|
1128 | + $form = new Give_Donate_Form($form_id); |
|
1129 | 1129 | |
1130 | 1130 | // Bail if this post isn't a valid give donation form. |
1131 | - if ( ! $form || $form->post_type !== 'give_forms' ) { |
|
1131 | + if ( ! $form || $form->post_type !== 'give_forms') { |
|
1132 | 1132 | return false; |
1133 | 1133 | } |
1134 | 1134 | |
@@ -1141,7 +1141,7 @@ discard block |
||
1141 | 1141 | |
1142 | 1142 | $this->pending['donations'][] = $pending_args; |
1143 | 1143 | |
1144 | - $this->decrease_subtotal( $this->total ); |
|
1144 | + $this->decrease_subtotal($this->total); |
|
1145 | 1145 | |
1146 | 1146 | return true; |
1147 | 1147 | } |
@@ -1157,13 +1157,13 @@ discard block |
||
1157 | 1157 | * |
1158 | 1158 | * @return bool If the note was specified or not |
1159 | 1159 | */ |
1160 | - public function add_note( $note = false ) { |
|
1160 | + public function add_note($note = false) { |
|
1161 | 1161 | // Bail if no note specified. |
1162 | - if ( ! $note ) { |
|
1162 | + if ( ! $note) { |
|
1163 | 1163 | return false; |
1164 | 1164 | } |
1165 | 1165 | |
1166 | - give_insert_payment_note( $this->ID, $note ); |
|
1166 | + give_insert_payment_note($this->ID, $note); |
|
1167 | 1167 | } |
1168 | 1168 | |
1169 | 1169 | /** |
@@ -1176,8 +1176,8 @@ discard block |
||
1176 | 1176 | * |
1177 | 1177 | * @return void |
1178 | 1178 | */ |
1179 | - private function increase_subtotal( $amount = 0.00 ) { |
|
1180 | - $amount = (float) $amount; |
|
1179 | + private function increase_subtotal($amount = 0.00) { |
|
1180 | + $amount = (float) $amount; |
|
1181 | 1181 | $this->subtotal += $amount; |
1182 | 1182 | |
1183 | 1183 | $this->recalculate_total(); |
@@ -1193,11 +1193,11 @@ discard block |
||
1193 | 1193 | * |
1194 | 1194 | * @return void |
1195 | 1195 | */ |
1196 | - private function decrease_subtotal( $amount = 0.00 ) { |
|
1197 | - $amount = (float) $amount; |
|
1196 | + private function decrease_subtotal($amount = 0.00) { |
|
1197 | + $amount = (float) $amount; |
|
1198 | 1198 | $this->subtotal -= $amount; |
1199 | 1199 | |
1200 | - if ( $this->subtotal < 0 ) { |
|
1200 | + if ($this->subtotal < 0) { |
|
1201 | 1201 | $this->subtotal = 0; |
1202 | 1202 | } |
1203 | 1203 | |
@@ -1227,24 +1227,24 @@ discard block |
||
1227 | 1227 | * |
1228 | 1228 | * @return bool $updated Returns if the status was successfully updated. |
1229 | 1229 | */ |
1230 | - public function update_status( $status = false ) { |
|
1230 | + public function update_status($status = false) { |
|
1231 | 1231 | |
1232 | 1232 | // standardize the 'complete(d)' status. |
1233 | - if ( $status == 'completed' || $status == 'complete' ) { |
|
1233 | + if ($status == 'completed' || $status == 'complete') { |
|
1234 | 1234 | $status = 'publish'; |
1235 | 1235 | } |
1236 | 1236 | |
1237 | - $old_status = ! empty( $this->old_status ) ? $this->old_status : false; |
|
1237 | + $old_status = ! empty($this->old_status) ? $this->old_status : false; |
|
1238 | 1238 | |
1239 | - if ( $old_status === $status ) { |
|
1239 | + if ($old_status === $status) { |
|
1240 | 1240 | return false; // Don't permit status changes that aren't changes. |
1241 | 1241 | } |
1242 | 1242 | |
1243 | - $do_change = apply_filters( 'give_should_update_payment_status', true, $this->ID, $status, $old_status ); |
|
1243 | + $do_change = apply_filters('give_should_update_payment_status', true, $this->ID, $status, $old_status); |
|
1244 | 1244 | |
1245 | 1245 | $updated = false; |
1246 | 1246 | |
1247 | - if ( $do_change ) { |
|
1247 | + if ($do_change) { |
|
1248 | 1248 | |
1249 | 1249 | /** |
1250 | 1250 | * Fires before changing payment status. |
@@ -1255,21 +1255,21 @@ discard block |
||
1255 | 1255 | * @param string $status The new status. |
1256 | 1256 | * @param string $old_status The old status. |
1257 | 1257 | */ |
1258 | - do_action( 'give_before_payment_status_change', $this->ID, $status, $old_status ); |
|
1258 | + do_action('give_before_payment_status_change', $this->ID, $status, $old_status); |
|
1259 | 1259 | |
1260 | 1260 | $update_fields = array( |
1261 | 1261 | 'ID' => $this->ID, |
1262 | 1262 | 'post_status' => $status, |
1263 | - 'edit_date' => current_time( 'mysql' ), |
|
1263 | + 'edit_date' => current_time('mysql'), |
|
1264 | 1264 | ); |
1265 | 1265 | |
1266 | - $updated = wp_update_post( apply_filters( 'give_update_payment_status_fields', $update_fields ) ); |
|
1266 | + $updated = wp_update_post(apply_filters('give_update_payment_status_fields', $update_fields)); |
|
1267 | 1267 | |
1268 | 1268 | $all_payment_statuses = give_get_payment_statuses(); |
1269 | - $this->status_nicename = array_key_exists( $status, $all_payment_statuses ) ? $all_payment_statuses[ $status ] : ucfirst( $status ); |
|
1269 | + $this->status_nicename = array_key_exists($status, $all_payment_statuses) ? $all_payment_statuses[$status] : ucfirst($status); |
|
1270 | 1270 | |
1271 | 1271 | // Process any specific status functions. |
1272 | - $this->process_status( $status ); |
|
1272 | + $this->process_status($status); |
|
1273 | 1273 | |
1274 | 1274 | /** |
1275 | 1275 | * Fires after changing payment status. |
@@ -1280,7 +1280,7 @@ discard block |
||
1280 | 1280 | * @param string $status The new status. |
1281 | 1281 | * @param string $old_status The old status. |
1282 | 1282 | */ |
1283 | - do_action( 'give_update_payment_status', $this->ID, $status, $old_status ); |
|
1283 | + do_action('give_update_payment_status', $this->ID, $status, $old_status); |
|
1284 | 1284 | |
1285 | 1285 | }// End if(). |
1286 | 1286 | |
@@ -1315,24 +1315,24 @@ discard block |
||
1315 | 1315 | * |
1316 | 1316 | * @return mixed The value from the post meta |
1317 | 1317 | */ |
1318 | - public function get_meta( $meta_key = '_give_payment_meta', $single = true ) { |
|
1319 | - if( ! has_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta' ) && ! doing_filter( 'get_post_metadata' ) ) { |
|
1320 | - add_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4 ); |
|
1318 | + public function get_meta($meta_key = '_give_payment_meta', $single = true) { |
|
1319 | + if ( ! has_filter('get_post_metadata', 'give_bc_v20_get_payment_meta') && ! doing_filter('get_post_metadata')) { |
|
1320 | + add_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4); |
|
1321 | 1321 | } |
1322 | 1322 | |
1323 | - $meta = give_get_meta( $this->ID, $meta_key, $single ); |
|
1323 | + $meta = give_get_meta($this->ID, $meta_key, $single); |
|
1324 | 1324 | |
1325 | 1325 | /** |
1326 | 1326 | * Filter the specific meta key value. |
1327 | 1327 | * |
1328 | 1328 | * @since 1.5 |
1329 | 1329 | */ |
1330 | - $meta = apply_filters( "give_get_payment_meta_{$meta_key}", $meta, $this->ID ); |
|
1330 | + $meta = apply_filters("give_get_payment_meta_{$meta_key}", $meta, $this->ID); |
|
1331 | 1331 | |
1332 | 1332 | // Security check. |
1333 | - if ( is_serialized( $meta ) ) { |
|
1334 | - preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $meta, $matches ); |
|
1335 | - if ( ! empty( $matches ) ) { |
|
1333 | + if (is_serialized($meta)) { |
|
1334 | + preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $meta, $matches); |
|
1335 | + if ( ! empty($matches)) { |
|
1336 | 1336 | $meta = array(); |
1337 | 1337 | } |
1338 | 1338 | } |
@@ -1342,7 +1342,7 @@ discard block |
||
1342 | 1342 | * |
1343 | 1343 | * @since 1.5 |
1344 | 1344 | */ |
1345 | - return apply_filters( 'give_get_payment_meta', $meta, $this->ID, $meta_key ); |
|
1345 | + return apply_filters('give_get_payment_meta', $meta, $this->ID, $meta_key); |
|
1346 | 1346 | } |
1347 | 1347 | |
1348 | 1348 | /** |
@@ -1357,8 +1357,8 @@ discard block |
||
1357 | 1357 | * |
1358 | 1358 | * @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure |
1359 | 1359 | */ |
1360 | - public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
1361 | - if ( empty( $meta_key ) ) { |
|
1360 | + public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') { |
|
1361 | + if (empty($meta_key)) { |
|
1362 | 1362 | return false; |
1363 | 1363 | } |
1364 | 1364 | |
@@ -1368,9 +1368,9 @@ discard block |
||
1368 | 1368 | * |
1369 | 1369 | * @since 1.5 |
1370 | 1370 | */ |
1371 | - $meta_value = apply_filters( "give_update_payment_meta_{$meta_key}", $meta_value, $this->ID ); |
|
1371 | + $meta_value = apply_filters("give_update_payment_meta_{$meta_key}", $meta_value, $this->ID); |
|
1372 | 1372 | |
1373 | - return give_update_meta( $this->ID, $meta_key, $meta_value, $prev_value ); |
|
1373 | + return give_update_meta($this->ID, $meta_key, $meta_value, $prev_value); |
|
1374 | 1374 | } |
1375 | 1375 | |
1376 | 1376 | /** |
@@ -1383,7 +1383,7 @@ discard block |
||
1383 | 1383 | * |
1384 | 1384 | * @return void |
1385 | 1385 | */ |
1386 | - private function process_status( $status ) { |
|
1386 | + private function process_status($status) { |
|
1387 | 1387 | $process = true; |
1388 | 1388 | |
1389 | 1389 | // Bailout, if changed from completed to preapproval/processing. |
@@ -1398,9 +1398,9 @@ discard block |
||
1398 | 1398 | } |
1399 | 1399 | |
1400 | 1400 | // Allow extensions to filter for their own payment types, Example: Recurring Payments. |
1401 | - $process = apply_filters( "give_should_process_{$status}", $process, $this ); |
|
1401 | + $process = apply_filters("give_should_process_{$status}", $process, $this); |
|
1402 | 1402 | |
1403 | - if ( false === $process ) { |
|
1403 | + if (false === $process) { |
|
1404 | 1404 | return; |
1405 | 1405 | } |
1406 | 1406 | |
@@ -1411,13 +1411,13 @@ discard block |
||
1411 | 1411 | * |
1412 | 1412 | * @since 1.5 |
1413 | 1413 | */ |
1414 | - do_action( "give_pre_{$status}_payment", $this ); |
|
1414 | + do_action("give_pre_{$status}_payment", $this); |
|
1415 | 1415 | |
1416 | - $decrease_earnings = apply_filters( "give_decrease_earnings_on_{$status}", true, $this ); |
|
1417 | - $decrease_donor_value = apply_filters( "give_decrease_donor_value_on_{$status}", true, $this ); |
|
1418 | - $decrease_donation_count = apply_filters( "give_decrease_donors_donation_count_on_{$status}", true, $this ); |
|
1416 | + $decrease_earnings = apply_filters("give_decrease_earnings_on_{$status}", true, $this); |
|
1417 | + $decrease_donor_value = apply_filters("give_decrease_donor_value_on_{$status}", true, $this); |
|
1418 | + $decrease_donation_count = apply_filters("give_decrease_donors_donation_count_on_{$status}", true, $this); |
|
1419 | 1419 | |
1420 | - $this->maybe_alter_stats( $decrease_earnings, $decrease_donor_value, $decrease_donation_count ); |
|
1420 | + $this->maybe_alter_stats($decrease_earnings, $decrease_donor_value, $decrease_donation_count); |
|
1421 | 1421 | $this->delete_sales_logs(); |
1422 | 1422 | |
1423 | 1423 | // @todo: Refresh only range related stat cache |
@@ -1430,7 +1430,7 @@ discard block |
||
1430 | 1430 | * |
1431 | 1431 | * @since 1.5 |
1432 | 1432 | */ |
1433 | - do_action( "give_post_{$status}_payment", $this ); |
|
1433 | + do_action("give_post_{$status}_payment", $this); |
|
1434 | 1434 | } |
1435 | 1435 | |
1436 | 1436 | /** |
@@ -1445,25 +1445,25 @@ discard block |
||
1445 | 1445 | * |
1446 | 1446 | * @return void |
1447 | 1447 | */ |
1448 | - private function maybe_alter_stats( $alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count ) { |
|
1448 | + private function maybe_alter_stats($alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count) { |
|
1449 | 1449 | |
1450 | - give_undo_donation( $this->ID ); |
|
1450 | + give_undo_donation($this->ID); |
|
1451 | 1451 | |
1452 | 1452 | // Decrease store earnings. |
1453 | - if ( true === $alter_store_earnings ) { |
|
1454 | - give_decrease_total_earnings( $this->total ); |
|
1453 | + if (true === $alter_store_earnings) { |
|
1454 | + give_decrease_total_earnings($this->total); |
|
1455 | 1455 | } |
1456 | 1456 | |
1457 | 1457 | // Decrement the stats for the donor. |
1458 | - if ( ! empty( $this->customer_id ) ) { |
|
1458 | + if ( ! empty($this->customer_id)) { |
|
1459 | 1459 | |
1460 | - $donor = new Give_Donor( $this->customer_id ); |
|
1460 | + $donor = new Give_Donor($this->customer_id); |
|
1461 | 1461 | |
1462 | - if ( true === $alter_customer_value ) { |
|
1463 | - $donor->decrease_value( $this->total ); |
|
1462 | + if (true === $alter_customer_value) { |
|
1463 | + $donor->decrease_value($this->total); |
|
1464 | 1464 | } |
1465 | 1465 | |
1466 | - if ( true === $alter_customer_purchase_count ) { |
|
1466 | + if (true === $alter_customer_purchase_count) { |
|
1467 | 1467 | $donor->decrease_donation_count(); |
1468 | 1468 | } |
1469 | 1469 | } |
@@ -1480,7 +1480,7 @@ discard block |
||
1480 | 1480 | */ |
1481 | 1481 | private function delete_sales_logs() { |
1482 | 1482 | // Remove related sale log entries. |
1483 | - Give()->logs->delete_logs( $this->ID ); |
|
1483 | + Give()->logs->delete_logs($this->ID); |
|
1484 | 1484 | } |
1485 | 1485 | |
1486 | 1486 | /** |
@@ -1501,13 +1501,13 @@ discard block |
||
1501 | 1501 | * @return string The date the payment was completed |
1502 | 1502 | */ |
1503 | 1503 | private function setup_completed_date() { |
1504 | - $payment = get_post( $this->ID ); |
|
1504 | + $payment = get_post($this->ID); |
|
1505 | 1505 | |
1506 | - if ( 'pending' == $payment->post_status || 'preapproved' == $payment->post_status ) { |
|
1506 | + if ('pending' == $payment->post_status || 'preapproved' == $payment->post_status) { |
|
1507 | 1507 | return false; // This payment was never completed. |
1508 | 1508 | } |
1509 | 1509 | |
1510 | - $date = ( $date = $this->get_meta( '_give_completed_date', true ) ) ? $date : $payment->modified_date; |
|
1510 | + $date = ($date = $this->get_meta('_give_completed_date', true)) ? $date : $payment->modified_date; |
|
1511 | 1511 | |
1512 | 1512 | return $date; |
1513 | 1513 | } |
@@ -1521,7 +1521,7 @@ discard block |
||
1521 | 1521 | * @return string The payment mode |
1522 | 1522 | */ |
1523 | 1523 | private function setup_mode() { |
1524 | - return $this->get_meta( '_give_payment_mode' ); |
|
1524 | + return $this->get_meta('_give_payment_mode'); |
|
1525 | 1525 | } |
1526 | 1526 | |
1527 | 1527 | /** |
@@ -1533,7 +1533,7 @@ discard block |
||
1533 | 1533 | * @return bool The payment import |
1534 | 1534 | */ |
1535 | 1535 | private function setup_import() { |
1536 | - return (bool) $this->get_meta( '_give_payment_import' ); |
|
1536 | + return (bool) $this->get_meta('_give_payment_import'); |
|
1537 | 1537 | } |
1538 | 1538 | |
1539 | 1539 | /** |
@@ -1545,9 +1545,9 @@ discard block |
||
1545 | 1545 | * @return float The payment total |
1546 | 1546 | */ |
1547 | 1547 | private function setup_total() { |
1548 | - $amount = $this->get_meta( '_give_payment_total', true ); |
|
1548 | + $amount = $this->get_meta('_give_payment_total', true); |
|
1549 | 1549 | |
1550 | - return round( floatval( $amount ), give_get_price_decimals( $this->ID ) ); |
|
1550 | + return round(floatval($amount), give_get_price_decimals($this->ID)); |
|
1551 | 1551 | } |
1552 | 1552 | |
1553 | 1553 | /** |
@@ -1574,17 +1574,16 @@ discard block |
||
1574 | 1574 | * @return string The currency for the payment |
1575 | 1575 | */ |
1576 | 1576 | private function setup_currency() { |
1577 | - $currency = $this->get_meta( '_give_payment_currency', true ); |
|
1578 | - $currency = ! empty( $currency ) ? |
|
1579 | - $currency : |
|
1580 | - /** |
|
1577 | + $currency = $this->get_meta('_give_payment_currency', true); |
|
1578 | + $currency = ! empty($currency) ? |
|
1579 | + $currency : /** |
|
1581 | 1580 | * Filter the default donation currency |
1582 | 1581 | * |
1583 | 1582 | * @since 1.5 |
1584 | 1583 | */ |
1585 | 1584 | apply_filters( |
1586 | 1585 | 'give_payment_currency_default', |
1587 | - give_get_currency( $this->form_id, $this ), |
|
1586 | + give_get_currency($this->form_id, $this), |
|
1588 | 1587 | $this |
1589 | 1588 | ); |
1590 | 1589 | |
@@ -1600,7 +1599,7 @@ discard block |
||
1600 | 1599 | * @return string The gateway |
1601 | 1600 | */ |
1602 | 1601 | private function setup_gateway() { |
1603 | - $gateway = $this->get_meta( '_give_payment_gateway', true ); |
|
1602 | + $gateway = $this->get_meta('_give_payment_gateway', true); |
|
1604 | 1603 | |
1605 | 1604 | return $gateway; |
1606 | 1605 | } |
@@ -1614,11 +1613,11 @@ discard block |
||
1614 | 1613 | * @return string The donation ID |
1615 | 1614 | */ |
1616 | 1615 | private function setup_transaction_id() { |
1617 | - $transaction_id = $this->get_meta( '_give_payment_transaction_id', true ); |
|
1616 | + $transaction_id = $this->get_meta('_give_payment_transaction_id', true); |
|
1618 | 1617 | |
1619 | - if ( empty( $transaction_id ) ) { |
|
1618 | + if (empty($transaction_id)) { |
|
1620 | 1619 | $gateway = $this->gateway; |
1621 | - $transaction_id = apply_filters( "give_get_payment_transaction_id-{$gateway}", $this->ID ); |
|
1620 | + $transaction_id = apply_filters("give_get_payment_transaction_id-{$gateway}", $this->ID); |
|
1622 | 1621 | } |
1623 | 1622 | |
1624 | 1623 | return $transaction_id; |
@@ -1634,7 +1633,7 @@ discard block |
||
1634 | 1633 | * @return string The IP address for the payment |
1635 | 1634 | */ |
1636 | 1635 | private function setup_ip() { |
1637 | - $ip = $this->get_meta( '_give_payment_donor_ip', true ); |
|
1636 | + $ip = $this->get_meta('_give_payment_donor_ip', true); |
|
1638 | 1637 | |
1639 | 1638 | return $ip; |
1640 | 1639 | } |
@@ -1649,7 +1648,7 @@ discard block |
||
1649 | 1648 | * @return int The Donor ID. |
1650 | 1649 | */ |
1651 | 1650 | private function setup_donor_id() { |
1652 | - $donor_id = $this->get_meta( '_give_payment_donor_id', true ); |
|
1651 | + $donor_id = $this->get_meta('_give_payment_donor_id', true); |
|
1653 | 1652 | |
1654 | 1653 | return $donor_id; |
1655 | 1654 | } |
@@ -1666,8 +1665,8 @@ discard block |
||
1666 | 1665 | */ |
1667 | 1666 | private function setup_user_id() { |
1668 | 1667 | |
1669 | - $donor = Give()->customers->get_customer_by( 'id', $this->customer_id ); |
|
1670 | - $user_id = $donor ? absint( $donor->user_id ) : 0; |
|
1668 | + $donor = Give()->customers->get_customer_by('id', $this->customer_id); |
|
1669 | + $user_id = $donor ? absint($donor->user_id) : 0; |
|
1671 | 1670 | |
1672 | 1671 | |
1673 | 1672 | return $user_id; |
@@ -1684,10 +1683,10 @@ discard block |
||
1684 | 1683 | * @return string The email address for the payment. |
1685 | 1684 | */ |
1686 | 1685 | private function setup_email() { |
1687 | - $email = $this->get_meta( '_give_payment_donor_email', true ); |
|
1686 | + $email = $this->get_meta('_give_payment_donor_email', true); |
|
1688 | 1687 | |
1689 | - if ( empty( $email ) && $this->customer_id ) { |
|
1690 | - $email = Give()->donors->get_column( 'email', $this->customer_id ); |
|
1688 | + if (empty($email) && $this->customer_id) { |
|
1689 | + $email = Give()->donors->get_column('email', $this->customer_id); |
|
1691 | 1690 | } |
1692 | 1691 | |
1693 | 1692 | return $email; |
@@ -1707,22 +1706,22 @@ discard block |
||
1707 | 1706 | 'last_name' => $this->last_name, |
1708 | 1707 | ); |
1709 | 1708 | |
1710 | - $user_info = isset( $this->payment_meta['user_info'] ) ? $this->payment_meta['user_info'] : array(); |
|
1709 | + $user_info = isset($this->payment_meta['user_info']) ? $this->payment_meta['user_info'] : array(); |
|
1711 | 1710 | |
1712 | - if ( is_serialized( $user_info ) ) { |
|
1713 | - preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches ); |
|
1714 | - if ( ! empty( $matches ) ) { |
|
1711 | + if (is_serialized($user_info)) { |
|
1712 | + preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches); |
|
1713 | + if ( ! empty($matches)) { |
|
1715 | 1714 | $user_info = array(); |
1716 | 1715 | } |
1717 | 1716 | } |
1718 | 1717 | |
1719 | - $user_info = wp_parse_args( $user_info, $defaults ); |
|
1718 | + $user_info = wp_parse_args($user_info, $defaults); |
|
1720 | 1719 | |
1721 | - if ( empty( $user_info ) ) { |
|
1720 | + if (empty($user_info)) { |
|
1722 | 1721 | // Get the donor, but only if it's been created. |
1723 | - $donor = new Give_Donor( $this->customer_id ); |
|
1722 | + $donor = new Give_Donor($this->customer_id); |
|
1724 | 1723 | |
1725 | - if ( $donor->id > 0 ) { |
|
1724 | + if ($donor->id > 0) { |
|
1726 | 1725 | $user_info = array( |
1727 | 1726 | 'first_name' => $donor->get_first_name(), |
1728 | 1727 | 'last_name' => $donor->get_last_name(), |
@@ -1732,25 +1731,25 @@ discard block |
||
1732 | 1731 | } |
1733 | 1732 | } else { |
1734 | 1733 | // Get the donor, but only if it's been created. |
1735 | - $donor = new Give_Donor( $this->customer_id ); |
|
1734 | + $donor = new Give_Donor($this->customer_id); |
|
1736 | 1735 | |
1737 | - if ( $donor->id > 0 ) { |
|
1738 | - foreach ( $user_info as $key => $value ) { |
|
1739 | - if ( ! empty( $value ) ) { |
|
1736 | + if ($donor->id > 0) { |
|
1737 | + foreach ($user_info as $key => $value) { |
|
1738 | + if ( ! empty($value)) { |
|
1740 | 1739 | continue; |
1741 | 1740 | } |
1742 | 1741 | |
1743 | - switch ( $key ) { |
|
1742 | + switch ($key) { |
|
1744 | 1743 | case 'first_name': |
1745 | - $user_info[ $key ] = $donor->get_first_name(); |
|
1744 | + $user_info[$key] = $donor->get_first_name(); |
|
1746 | 1745 | break; |
1747 | 1746 | |
1748 | 1747 | case 'last_name': |
1749 | - $user_info[ $key ] = $donor->get_last_name(); |
|
1748 | + $user_info[$key] = $donor->get_last_name(); |
|
1750 | 1749 | break; |
1751 | 1750 | |
1752 | 1751 | case 'email': |
1753 | - $user_info[ $key ] = $donor->email; |
|
1752 | + $user_info[$key] = $donor->email; |
|
1754 | 1753 | break; |
1755 | 1754 | } |
1756 | 1755 | } |
@@ -1770,12 +1769,12 @@ discard block |
||
1770 | 1769 | * @return array The Address information for the payment. |
1771 | 1770 | */ |
1772 | 1771 | private function setup_address() { |
1773 | - $address['line1'] = give_get_meta( $this->ID, '_give_donor_billing_address1', true, '' ); |
|
1774 | - $address['line2'] = give_get_meta( $this->ID, '_give_donor_billing_address2', true, '' ); |
|
1775 | - $address['city'] = give_get_meta( $this->ID, '_give_donor_billing_city', true, '' ); |
|
1776 | - $address['state'] = give_get_meta( $this->ID, '_give_donor_billing_state', true, '' ); |
|
1777 | - $address['zip'] = give_get_meta( $this->ID, '_give_donor_billing_zip', true, '' ); |
|
1778 | - $address['country'] = give_get_meta( $this->ID, '_give_donor_billing_country', true, '' ); |
|
1772 | + $address['line1'] = give_get_meta($this->ID, '_give_donor_billing_address1', true, ''); |
|
1773 | + $address['line2'] = give_get_meta($this->ID, '_give_donor_billing_address2', true, ''); |
|
1774 | + $address['city'] = give_get_meta($this->ID, '_give_donor_billing_city', true, ''); |
|
1775 | + $address['state'] = give_get_meta($this->ID, '_give_donor_billing_state', true, ''); |
|
1776 | + $address['zip'] = give_get_meta($this->ID, '_give_donor_billing_zip', true, ''); |
|
1777 | + $address['country'] = give_get_meta($this->ID, '_give_donor_billing_country', true, ''); |
|
1779 | 1778 | |
1780 | 1779 | return $address; |
1781 | 1780 | } |
@@ -1790,7 +1789,7 @@ discard block |
||
1790 | 1789 | */ |
1791 | 1790 | private function setup_form_title() { |
1792 | 1791 | |
1793 | - $form_id = $this->get_meta( '_give_payment_form_title', true ); |
|
1792 | + $form_id = $this->get_meta('_give_payment_form_title', true); |
|
1794 | 1793 | |
1795 | 1794 | return $form_id; |
1796 | 1795 | } |
@@ -1805,7 +1804,7 @@ discard block |
||
1805 | 1804 | */ |
1806 | 1805 | private function setup_form_id() { |
1807 | 1806 | |
1808 | - $form_id = $this->get_meta( '_give_payment_form_id', true ); |
|
1807 | + $form_id = $this->get_meta('_give_payment_form_id', true); |
|
1809 | 1808 | |
1810 | 1809 | return $form_id; |
1811 | 1810 | } |
@@ -1819,7 +1818,7 @@ discard block |
||
1819 | 1818 | * @return int The Form Price ID. |
1820 | 1819 | */ |
1821 | 1820 | private function setup_price_id() { |
1822 | - $price_id = $this->get_meta( '_give_payment_price_id', true ); |
|
1821 | + $price_id = $this->get_meta('_give_payment_price_id', true); |
|
1823 | 1822 | |
1824 | 1823 | return $price_id; |
1825 | 1824 | } |
@@ -1833,7 +1832,7 @@ discard block |
||
1833 | 1832 | * @return string The Payment Key. |
1834 | 1833 | */ |
1835 | 1834 | private function setup_payment_key() { |
1836 | - $key = $this->get_meta( '_give_payment_purchase_key', true ); |
|
1835 | + $key = $this->get_meta('_give_payment_purchase_key', true); |
|
1837 | 1836 | |
1838 | 1837 | return $key; |
1839 | 1838 | } |
@@ -1858,7 +1857,7 @@ discard block |
||
1858 | 1857 | * @return array The payment object as an array. |
1859 | 1858 | */ |
1860 | 1859 | public function array_convert() { |
1861 | - return get_object_vars( $this ); |
|
1860 | + return get_object_vars($this); |
|
1862 | 1861 | } |
1863 | 1862 | |
1864 | 1863 | |
@@ -1871,7 +1870,7 @@ discard block |
||
1871 | 1870 | * @return bool |
1872 | 1871 | */ |
1873 | 1872 | public function is_completed() { |
1874 | - return ( 'publish' === $this->status && $this->completed_date ); |
|
1873 | + return ('publish' === $this->status && $this->completed_date); |
|
1875 | 1874 | } |
1876 | 1875 | |
1877 | 1876 | /** |
@@ -1883,7 +1882,7 @@ discard block |
||
1883 | 1882 | * @return string Date payment was completed. |
1884 | 1883 | */ |
1885 | 1884 | private function get_completed_date() { |
1886 | - return apply_filters( 'give_payment_completed_date', $this->completed_date, $this->ID, $this ); |
|
1885 | + return apply_filters('give_payment_completed_date', $this->completed_date, $this->ID, $this); |
|
1887 | 1886 | } |
1888 | 1887 | |
1889 | 1888 | /** |
@@ -1895,7 +1894,7 @@ discard block |
||
1895 | 1894 | * @return float Payment subtotal. |
1896 | 1895 | */ |
1897 | 1896 | private function get_subtotal() { |
1898 | - return apply_filters( 'give_get_payment_subtotal', $this->subtotal, $this->ID, $this ); |
|
1897 | + return apply_filters('give_get_payment_subtotal', $this->subtotal, $this->ID, $this); |
|
1899 | 1898 | } |
1900 | 1899 | |
1901 | 1900 | /** |
@@ -1907,7 +1906,7 @@ discard block |
||
1907 | 1906 | * @return string Payment currency code. |
1908 | 1907 | */ |
1909 | 1908 | private function get_currency() { |
1910 | - return apply_filters( 'give_payment_currency_code', $this->currency, $this->ID, $this ); |
|
1909 | + return apply_filters('give_payment_currency_code', $this->currency, $this->ID, $this); |
|
1911 | 1910 | } |
1912 | 1911 | |
1913 | 1912 | /** |
@@ -1919,7 +1918,7 @@ discard block |
||
1919 | 1918 | * @return string Gateway used. |
1920 | 1919 | */ |
1921 | 1920 | private function get_gateway() { |
1922 | - return apply_filters( 'give_payment_gateway', $this->gateway, $this->ID, $this ); |
|
1921 | + return apply_filters('give_payment_gateway', $this->gateway, $this->ID, $this); |
|
1923 | 1922 | } |
1924 | 1923 | |
1925 | 1924 | /** |
@@ -1931,7 +1930,7 @@ discard block |
||
1931 | 1930 | * @return string Donation ID from merchant processor. |
1932 | 1931 | */ |
1933 | 1932 | private function get_transaction_id() { |
1934 | - return apply_filters( 'give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this ); |
|
1933 | + return apply_filters('give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this); |
|
1935 | 1934 | } |
1936 | 1935 | |
1937 | 1936 | /** |
@@ -1943,7 +1942,7 @@ discard block |
||
1943 | 1942 | * @return string Payment IP address |
1944 | 1943 | */ |
1945 | 1944 | private function get_ip() { |
1946 | - return apply_filters( 'give_payment_user_ip', $this->ip, $this->ID, $this ); |
|
1945 | + return apply_filters('give_payment_user_ip', $this->ip, $this->ID, $this); |
|
1947 | 1946 | } |
1948 | 1947 | |
1949 | 1948 | /** |
@@ -1955,7 +1954,7 @@ discard block |
||
1955 | 1954 | * @return int Payment donor ID. |
1956 | 1955 | */ |
1957 | 1956 | private function get_donor_id() { |
1958 | - return apply_filters( 'give_payment_customer_id', $this->customer_id, $this->ID, $this ); |
|
1957 | + return apply_filters('give_payment_customer_id', $this->customer_id, $this->ID, $this); |
|
1959 | 1958 | } |
1960 | 1959 | |
1961 | 1960 | /** |
@@ -1967,7 +1966,7 @@ discard block |
||
1967 | 1966 | * @return int Payment user ID. |
1968 | 1967 | */ |
1969 | 1968 | private function get_user_id() { |
1970 | - return apply_filters( 'give_payment_user_id', $this->user_id, $this->ID, $this ); |
|
1969 | + return apply_filters('give_payment_user_id', $this->user_id, $this->ID, $this); |
|
1971 | 1970 | } |
1972 | 1971 | |
1973 | 1972 | /** |
@@ -1979,7 +1978,7 @@ discard block |
||
1979 | 1978 | * @return string Payment donor email. |
1980 | 1979 | */ |
1981 | 1980 | private function get_email() { |
1982 | - return apply_filters( 'give_payment_user_email', $this->email, $this->ID, $this ); |
|
1981 | + return apply_filters('give_payment_user_email', $this->email, $this->ID, $this); |
|
1983 | 1982 | } |
1984 | 1983 | |
1985 | 1984 | /** |
@@ -1991,7 +1990,7 @@ discard block |
||
1991 | 1990 | * @return array Payment user info. |
1992 | 1991 | */ |
1993 | 1992 | private function get_user_info() { |
1994 | - return apply_filters( 'give_payment_meta_user_info', $this->user_info, $this->ID, $this ); |
|
1993 | + return apply_filters('give_payment_meta_user_info', $this->user_info, $this->ID, $this); |
|
1995 | 1994 | } |
1996 | 1995 | |
1997 | 1996 | /** |
@@ -2003,7 +2002,7 @@ discard block |
||
2003 | 2002 | * @return array Payment billing address. |
2004 | 2003 | */ |
2005 | 2004 | private function get_address() { |
2006 | - return apply_filters( 'give_payment_address', $this->address, $this->ID, $this ); |
|
2005 | + return apply_filters('give_payment_address', $this->address, $this->ID, $this); |
|
2007 | 2006 | } |
2008 | 2007 | |
2009 | 2008 | /** |
@@ -2015,7 +2014,7 @@ discard block |
||
2015 | 2014 | * @return string Payment key. |
2016 | 2015 | */ |
2017 | 2016 | private function get_key() { |
2018 | - return apply_filters( 'give_payment_key', $this->key, $this->ID, $this ); |
|
2017 | + return apply_filters('give_payment_key', $this->key, $this->ID, $this); |
|
2019 | 2018 | } |
2020 | 2019 | |
2021 | 2020 | /** |
@@ -2027,7 +2026,7 @@ discard block |
||
2027 | 2026 | * @return string Payment form id |
2028 | 2027 | */ |
2029 | 2028 | private function get_form_id() { |
2030 | - return apply_filters( 'give_payment_form_id', $this->form_id, $this->ID, $this ); |
|
2029 | + return apply_filters('give_payment_form_id', $this->form_id, $this->ID, $this); |
|
2031 | 2030 | } |
2032 | 2031 | |
2033 | 2032 | /** |
@@ -2039,7 +2038,7 @@ discard block |
||
2039 | 2038 | * @return int|string Payment number |
2040 | 2039 | */ |
2041 | 2040 | private function get_number() { |
2042 | - return apply_filters( 'give_payment_number', $this->number, $this->ID, $this ); |
|
2041 | + return apply_filters('give_payment_number', $this->number, $this->ID, $this); |
|
2043 | 2042 | } |
2044 | 2043 | |
2045 | 2044 | /** |
@@ -2051,7 +2050,7 @@ discard block |
||
2051 | 2050 | * |
2052 | 2051 | * @return string |
2053 | 2052 | */ |
2054 | - public function get_serial_code( $args = array() ) { |
|
2055 | - return Give()->seq_donation_number->get_serial_code( $this, $args ); |
|
2053 | + public function get_serial_code($args = array()) { |
|
2054 | + return Give()->seq_donation_number->get_serial_code($this, $args); |
|
2056 | 2055 | } |
2057 | 2056 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -81,15 +81,15 @@ discard block |
||
81 | 81 | * @param array $_data |
82 | 82 | * @param array $options |
83 | 83 | */ |
84 | - public function __construct( $_data, $options = array() ) { |
|
84 | + public function __construct($_data, $options = array()) { |
|
85 | 85 | |
86 | - $this->data = $_data; |
|
86 | + $this->data = $_data; |
|
87 | 87 | |
88 | 88 | // Generate unique ID |
89 | - $this->id = md5( rand() ); |
|
89 | + $this->id = md5(rand()); |
|
90 | 90 | |
91 | 91 | // Setup default options; |
92 | - $this->options = apply_filters( 'give_graph_args', array( |
|
92 | + $this->options = apply_filters('give_graph_args', array( |
|
93 | 93 | 'y_mode' => null, |
94 | 94 | 'x_mode' => null, |
95 | 95 | 'y_decimals' => 0, |
@@ -107,9 +107,9 @@ discard block |
||
107 | 107 | 'lines' => false, |
108 | 108 | 'points' => true, |
109 | 109 | 'dataType' => array() |
110 | - ) ); |
|
110 | + )); |
|
111 | 111 | |
112 | - $this->options = wp_parse_args( $options, $this->options ); |
|
112 | + $this->options = wp_parse_args($options, $this->options); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @since 1.0 |
122 | 122 | */ |
123 | - public function set( $key, $value ) { |
|
124 | - $this->options[ $key ] = $value; |
|
123 | + public function set($key, $value) { |
|
124 | + $this->options[$key] = $value; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @since 1.0 |
133 | 133 | */ |
134 | - public function get( $key ) { |
|
135 | - return isset( $this->options[ $key ] ) ? $this->options[ $key ] : false; |
|
134 | + public function get($key) { |
|
135 | + return isset($this->options[$key]) ? $this->options[$key] : false; |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * @since 1.0 |
142 | 142 | */ |
143 | 143 | public function get_data() { |
144 | - return apply_filters( 'give_get_graph_data', $this->data, $this ); |
|
144 | + return apply_filters('give_get_graph_data', $this->data, $this); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
@@ -151,19 +151,19 @@ discard block |
||
151 | 151 | */ |
152 | 152 | public function load_scripts() { |
153 | 153 | // Use minified libraries if SCRIPT_DEBUG is turned off |
154 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
154 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
155 | 155 | |
156 | - wp_register_script( 'jquery-flot-orderbars', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.orderBars' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION ); |
|
157 | - wp_enqueue_script( 'jquery-flot-orderbars' ); |
|
156 | + wp_register_script('jquery-flot-orderbars', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot.orderBars'.$suffix.'.js', array('jquery-flot'), GIVE_VERSION); |
|
157 | + wp_enqueue_script('jquery-flot-orderbars'); |
|
158 | 158 | |
159 | - wp_register_script( 'jquery-flot-time', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.time' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION ); |
|
160 | - wp_enqueue_script( 'jquery-flot-time' ); |
|
159 | + wp_register_script('jquery-flot-time', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot.time'.$suffix.'.js', array('jquery-flot'), GIVE_VERSION); |
|
160 | + wp_enqueue_script('jquery-flot-time'); |
|
161 | 161 | |
162 | - wp_register_script( 'jquery-flot-resize', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.resize' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION ); |
|
163 | - wp_enqueue_script( 'jquery-flot-resize' ); |
|
162 | + wp_register_script('jquery-flot-resize', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot.resize'.$suffix.'.js', array('jquery-flot'), GIVE_VERSION); |
|
163 | + wp_enqueue_script('jquery-flot-resize'); |
|
164 | 164 | |
165 | - wp_register_script( 'jquery-flot', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot' . $suffix . '.js', false, GIVE_VERSION ); |
|
166 | - wp_enqueue_script( 'jquery-flot' ); |
|
165 | + wp_register_script('jquery-flot', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot'.$suffix.'.js', false, GIVE_VERSION); |
|
166 | + wp_enqueue_script('jquery-flot'); |
|
167 | 167 | |
168 | 168 | } |
169 | 169 | |
@@ -190,14 +190,14 @@ discard block |
||
190 | 190 | [ |
191 | 191 | <?php |
192 | 192 | $order = 0; |
193 | - foreach( $this->get_data() as $label => $data ) : |
|
193 | + foreach ($this->get_data() as $label => $data) : |
|
194 | 194 | ?> |
195 | 195 | { |
196 | - label : "<?php echo esc_attr( $label ); ?>", |
|
197 | - id : "<?php echo sanitize_key( $label ); ?>", |
|
198 | - dataType : '<?php echo ( ! empty( $this->options['dataType'][$order] ) ? $this->options['dataType'][$order] : 'count' ); ?>', |
|
196 | + label : "<?php echo esc_attr($label); ?>", |
|
197 | + id : "<?php echo sanitize_key($label); ?>", |
|
198 | + dataType : '<?php echo ( ! empty($this->options['dataType'][$order]) ? $this->options['dataType'][$order] : 'count'); ?>', |
|
199 | 199 | // data format is: [ point on x, value on y ] |
200 | - data : [<?php foreach( $data as $point ) { echo '[' . implode( ',', $point ) . '],'; } ?>], |
|
200 | + data : [<?php foreach ($data as $point) { echo '['.implode(',', $point).'],'; } ?>], |
|
201 | 201 | points: { |
202 | 202 | show: <?php echo $this->options['points'] ? 'true' : 'false'; ?>, |
203 | 203 | }, |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | fill : true, |
213 | 213 | fillColor: {colors: [{opacity: 0.4}, {opacity: 0.1}]} |
214 | 214 | }, |
215 | - <?php if( $this->options[ 'multiple_y_axes' ] ) : ?> |
|
215 | + <?php if ($this->options['multiple_y_axes']) : ?> |
|
216 | 216 | yaxis : <?php echo $yaxis_count; ?> |
217 | 217 | <?php endif; ?> |
218 | 218 | |
@@ -226,10 +226,10 @@ discard block |
||
226 | 226 | grid: { |
227 | 227 | show : true, |
228 | 228 | aboveData : false, |
229 | - color : "<?php echo $this->options[ 'color' ]; ?>", |
|
230 | - backgroundColor: "<?php echo $this->options[ 'bgcolor' ]; ?>", |
|
231 | - borderColor : "<?php echo $this->options[ 'bordercolor' ]; ?>", |
|
232 | - borderWidth : <?php echo absint( $this->options[ 'borderwidth' ] ); ?>, |
|
229 | + color : "<?php echo $this->options['color']; ?>", |
|
230 | + backgroundColor: "<?php echo $this->options['bgcolor']; ?>", |
|
231 | + borderColor : "<?php echo $this->options['bordercolor']; ?>", |
|
232 | + borderWidth : <?php echo absint($this->options['borderwidth']); ?>, |
|
233 | 233 | clickable : false, |
234 | 234 | hoverable : true |
235 | 235 | }, |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | mode : "<?php echo $this->options['x_mode']; ?>", |
241 | 241 | timeFormat : "<?php echo $this->options['x_mode'] == 'time' ? $this->options['time_format'] : ''; ?>", |
242 | 242 | tickSize : "<?php echo $this->options['x_mode'] == 'time' ? '' : 1; ?>", |
243 | - <?php if( $this->options['x_mode'] != 'time' ) : ?> |
|
243 | + <?php if ($this->options['x_mode'] != 'time') : ?> |
|
244 | 244 | tickDecimals: <?php echo $this->options['x_decimals']; ?> |
245 | 245 | <?php endif; ?> |
246 | 246 | }, |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | min : 0, |
250 | 250 | mode : "<?php echo $this->options['y_mode']; ?>", |
251 | 251 | timeFormat : "<?php echo $this->options['y_mode'] == 'time' ? $this->options['time_format'] : ''; ?>", |
252 | - <?php if( $this->options['y_mode'] != 'time' ) : ?> |
|
252 | + <?php if ($this->options['y_mode'] != 'time') : ?> |
|
253 | 253 | tickDecimals: <?php echo $this->options['y_decimals']; ?>, |
254 | 254 | <?php endif; ?> |
255 | 255 | tickFormatter: function(val) { |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | * |
324 | 324 | * @param Give_Graph $this Graph object. |
325 | 325 | */ |
326 | - do_action( 'give_before_graph', $this ); |
|
326 | + do_action('give_before_graph', $this); |
|
327 | 327 | |
328 | 328 | // Build the graph. |
329 | 329 | echo $this->build_graph(); |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | * |
336 | 336 | * @param Give_Graph $this Graph object. |
337 | 337 | */ |
338 | - do_action( 'give_after_graph', $this ); |
|
338 | + do_action('give_after_graph', $this); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | } |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | |
455 | 455 | /** |
456 | 456 | * @param $option_value |
457 | - * @param $value |
|
457 | + * @param boolean $value |
|
458 | 458 | * |
459 | 459 | * @return string |
460 | 460 | */ |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | * |
545 | 545 | * @since 1.8.14 |
546 | 546 | * |
547 | - * @param $file_id |
|
547 | + * @param integer $file_id |
|
548 | 548 | * |
549 | 549 | * @return bool|int |
550 | 550 | */ |
@@ -201,13 +201,13 @@ discard block |
||
201 | 201 | id="recount-stats-submit" |
202 | 202 | value=" |
203 | 203 | <?php |
204 | - /** |
|
205 | - * Filter to modify donation importer submit button text. |
|
206 | - * |
|
207 | - * @since 2.1 |
|
208 | - */ |
|
209 | - echo apply_filters( 'give_import_donation_submit_button_text', __( 'Submit', 'give' ) ); |
|
210 | - ?> |
|
204 | + /** |
|
205 | + * Filter to modify donation importer submit button text. |
|
206 | + * |
|
207 | + * @since 2.1 |
|
208 | + */ |
|
209 | + echo apply_filters( 'give_import_donation_submit_button_text', __( 'Submit', 'give' ) ); |
|
210 | + ?> |
|
211 | 211 | "/> |
212 | 212 | </th> |
213 | 213 | <th> |
@@ -1079,8 +1079,8 @@ discard block |
||
1079 | 1079 | */ |
1080 | 1080 | private function is_donations_import_page() { |
1081 | 1081 | return 'import' === give_get_current_setting_tab() && |
1082 | - isset( $_GET['importer-type'] ) && |
|
1083 | - $this->importer_type === give_clean( $_GET['importer-type'] ); |
|
1082 | + isset( $_GET['importer-type'] ) && |
|
1083 | + $this->importer_type === give_clean( $_GET['importer-type'] ); |
|
1084 | 1084 | } |
1085 | 1085 | } |
1086 | 1086 |
@@ -11,11 +11,11 @@ discard block |
||
11 | 11 | * @since 1.8.14 |
12 | 12 | */ |
13 | 13 | |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; // Exit if accessed directly |
16 | 16 | } |
17 | 17 | |
18 | -if ( ! class_exists( 'Give_Import_Donations' ) ) { |
|
18 | +if ( ! class_exists('Give_Import_Donations')) { |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * Give_Import_Donations. |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @access private |
67 | 67 | */ |
68 | 68 | private function __construct() { |
69 | - self::$per_page = ! empty( $_GET['per_page'] ) ? absint( $_GET['per_page'] ) : self::$per_page; |
|
69 | + self::$per_page = ! empty($_GET['per_page']) ? absint($_GET['per_page']) : self::$per_page; |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @return static |
79 | 79 | */ |
80 | 80 | public static function get_instance() { |
81 | - if ( null === static::$instance ) { |
|
81 | + if (null === static::$instance) { |
|
82 | 82 | self::$instance = new static(); |
83 | 83 | } |
84 | 84 | |
@@ -105,27 +105,27 @@ discard block |
||
105 | 105 | * @return void |
106 | 106 | */ |
107 | 107 | private function setup_hooks() { |
108 | - if ( ! $this->is_donations_import_page() ) { |
|
108 | + if ( ! $this->is_donations_import_page()) { |
|
109 | 109 | return; |
110 | 110 | } |
111 | 111 | |
112 | 112 | // Do not render main import tools page. |
113 | - remove_action( 'give_admin_field_tools_import', array( 'Give_Settings_Import', 'render_import_field', ) ); |
|
113 | + remove_action('give_admin_field_tools_import', array('Give_Settings_Import', 'render_import_field',)); |
|
114 | 114 | |
115 | 115 | |
116 | 116 | // Render donation import page |
117 | - add_action( 'give_admin_field_tools_import', array( $this, 'render_page' ) ); |
|
117 | + add_action('give_admin_field_tools_import', array($this, 'render_page')); |
|
118 | 118 | |
119 | 119 | // Print the HTML. |
120 | - add_action( 'give_tools_import_donations_form_start', array( $this, 'html' ), 10 ); |
|
120 | + add_action('give_tools_import_donations_form_start', array($this, 'html'), 10); |
|
121 | 121 | |
122 | 122 | // Run when form submit. |
123 | - add_action( 'give-tools_save_import', array( $this, 'save' ) ); |
|
123 | + add_action('give-tools_save_import', array($this, 'save')); |
|
124 | 124 | |
125 | - add_action( 'give-tools_update_notices', array( $this, 'update_notices' ), 11, 1 ); |
|
125 | + add_action('give-tools_update_notices', array($this, 'update_notices'), 11, 1); |
|
126 | 126 | |
127 | 127 | // Used to add submit button. |
128 | - add_action( 'give_tools_import_donations_form_end', array( $this, 'submit' ), 10 ); |
|
128 | + add_action('give_tools_import_donations_form_end', array($this, 'submit'), 10); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | * |
138 | 138 | * @return mixed |
139 | 139 | */ |
140 | - public function update_notices( $messages ) { |
|
141 | - if ( ! empty( $_GET['tab'] ) && 'import' === give_clean( $_GET['tab'] ) ) { |
|
142 | - unset( $messages['give-setting-updated'] ); |
|
140 | + public function update_notices($messages) { |
|
141 | + if ( ! empty($_GET['tab']) && 'import' === give_clean($_GET['tab'])) { |
|
142 | + unset($messages['give-setting-updated']); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | return $messages; |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * @since 1.8.14 |
152 | 152 | */ |
153 | 153 | public function submit() { |
154 | - wp_nonce_field( 'give-save-settings', '_give-save-settings' ); |
|
154 | + wp_nonce_field('give-save-settings', '_give-save-settings'); |
|
155 | 155 | ?> |
156 | 156 | <input type="hidden" class="import-step" id="import-step" name="step" |
157 | 157 | value="<?php echo $this->get_step(); ?>"/> |
@@ -172,11 +172,11 @@ discard block |
||
172 | 172 | ?> |
173 | 173 | <section> |
174 | 174 | <table |
175 | - class="widefat export-options-table give-table <?php echo "step-{$step}"; ?> <?php echo( 1 === $step && ! empty( $this->is_csv_valid ) ? 'give-hidden' : '' ); ?> " |
|
175 | + class="widefat export-options-table give-table <?php echo "step-{$step}"; ?> <?php echo(1 === $step && ! empty($this->is_csv_valid) ? 'give-hidden' : ''); ?> " |
|
176 | 176 | id="<?php echo "step-{$step}"; ?>"> |
177 | 177 | <tbody> |
178 | 178 | <?php |
179 | - switch ( $step ) { |
|
179 | + switch ($step) { |
|
180 | 180 | case 1: |
181 | 181 | $this->render_media_csv(); |
182 | 182 | break; |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | case 4: |
193 | 193 | $this->import_success(); |
194 | 194 | } |
195 | - if ( false === $this->check_for_dropdown_or_import() ) { |
|
195 | + if (false === $this->check_for_dropdown_or_import()) { |
|
196 | 196 | ?> |
197 | 197 | <tr valign="top"> |
198 | 198 | <th> |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | * |
207 | 207 | * @since 2.1 |
208 | 208 | */ |
209 | - echo apply_filters( 'give_import_donation_submit_button_text', __( 'Submit', 'give' ) ); |
|
209 | + echo apply_filters('give_import_donation_submit_button_text', __('Submit', 'give')); |
|
210 | 210 | ?> |
211 | 211 | "/> |
212 | 212 | </th> |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | * |
218 | 218 | * @since 2.1 |
219 | 219 | */ |
220 | - do_action( 'give_import_donation_submit_button' ); |
|
220 | + do_action('give_import_donation_submit_button'); |
|
221 | 221 | ?> |
222 | 222 | </th> |
223 | 223 | </tr> |
@@ -237,70 +237,70 @@ discard block |
||
237 | 237 | */ |
238 | 238 | public function import_success() { |
239 | 239 | |
240 | - $delete_csv = ( ! empty( $_GET['delete_csv'] ) ? absint( $_GET['delete_csv'] ) : false ); |
|
241 | - $csv = ( ! empty( $_GET['csv'] ) ? absint( $_GET['csv'] ) : false ); |
|
242 | - if ( ! empty( $delete_csv ) && ! empty( $csv ) ) { |
|
243 | - wp_delete_attachment( $csv, true ); |
|
240 | + $delete_csv = ( ! empty($_GET['delete_csv']) ? absint($_GET['delete_csv']) : false); |
|
241 | + $csv = ( ! empty($_GET['csv']) ? absint($_GET['csv']) : false); |
|
242 | + if ( ! empty($delete_csv) && ! empty($csv)) { |
|
243 | + wp_delete_attachment($csv, true); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | $report = give_import_donation_report(); |
247 | 247 | |
248 | 248 | $report_html = array( |
249 | 249 | 'duplicate_donor' => array( |
250 | - __( '%s duplicate %s detected', 'give' ), |
|
251 | - __( '%s duplicate %s will be detected', 'give' ), |
|
252 | - __( 'donor', 'give' ), |
|
253 | - __( 'donors', 'give' ), |
|
250 | + __('%s duplicate %s detected', 'give'), |
|
251 | + __('%s duplicate %s will be detected', 'give'), |
|
252 | + __('donor', 'give'), |
|
253 | + __('donors', 'give'), |
|
254 | 254 | ), |
255 | 255 | 'create_donor' => array( |
256 | - __( '%s %s created', 'give' ), |
|
257 | - __( '%s %s will be going to get created', 'give' ), |
|
258 | - __( 'donor', 'give' ), |
|
259 | - __( 'donors', 'give' ), |
|
256 | + __('%s %s created', 'give'), |
|
257 | + __('%s %s will be going to get created', 'give'), |
|
258 | + __('donor', 'give'), |
|
259 | + __('donors', 'give'), |
|
260 | 260 | ), |
261 | 261 | 'create_form' => array( |
262 | - __( '%s donation %s created', 'give' ), |
|
263 | - __( '%s donation %s will be going to get created', 'give' ), |
|
264 | - __( 'form', 'give' ), |
|
265 | - __( 'forms', 'give' ), |
|
262 | + __('%s donation %s created', 'give'), |
|
263 | + __('%s donation %s will be going to get created', 'give'), |
|
264 | + __('form', 'give'), |
|
265 | + __('forms', 'give'), |
|
266 | 266 | ), |
267 | 267 | 'duplicate_donation' => array( |
268 | - __( '%s duplicate %s detected', 'give' ), |
|
269 | - __( '%s duplicate %s will be detected', 'give' ), |
|
270 | - __( 'donation', 'give' ), |
|
271 | - __( 'donations', 'give' ), |
|
268 | + __('%s duplicate %s detected', 'give'), |
|
269 | + __('%s duplicate %s will be detected', 'give'), |
|
270 | + __('donation', 'give'), |
|
271 | + __('donations', 'give'), |
|
272 | 272 | ), |
273 | 273 | 'create_donation' => array( |
274 | - __( '%s %s imported', 'give' ), |
|
275 | - __( '%s %s will going to get imported', 'give' ), |
|
276 | - __( 'donation', 'give' ), |
|
277 | - __( 'donations', 'give' ), |
|
274 | + __('%s %s imported', 'give'), |
|
275 | + __('%s %s will going to get imported', 'give'), |
|
276 | + __('donation', 'give'), |
|
277 | + __('donations', 'give'), |
|
278 | 278 | ), |
279 | 279 | ); |
280 | - $total = (int) $_GET['total']; |
|
281 | - -- $total; |
|
280 | + $total = (int) $_GET['total']; |
|
281 | + --$total; |
|
282 | 282 | $success = (bool) $_GET['success']; |
283 | - $dry_run = empty( $_GET['dry_run'] ) ? 0 : absint( $_GET['dry_run'] ); |
|
283 | + $dry_run = empty($_GET['dry_run']) ? 0 : absint($_GET['dry_run']); |
|
284 | 284 | ?> |
285 | 285 | <tr valign="top" class="give-import-dropdown"> |
286 | 286 | <th colspan="2"> |
287 | 287 | <h2> |
288 | 288 | <?php |
289 | - if ( $success ) { |
|
290 | - if ( $dry_run ) { |
|
289 | + if ($success) { |
|
290 | + if ($dry_run) { |
|
291 | 291 | printf( |
292 | - _n( 'Dry run import complete! %s donation processed', 'Dry run import complete! %s donations processed', $total, 'give' ), |
|
292 | + _n('Dry run import complete! %s donation processed', 'Dry run import complete! %s donations processed', $total, 'give'), |
|
293 | 293 | "<strong>{$total}</strong>" |
294 | 294 | ); |
295 | 295 | } else { |
296 | 296 | printf( |
297 | - _n( 'Import complete! %s donation processed', 'Import complete! %s donations processed', $total, 'give' ), |
|
297 | + _n('Import complete! %s donation processed', 'Import complete! %s donations processed', $total, 'give'), |
|
298 | 298 | "<strong>{$total}</strong>" |
299 | 299 | ); |
300 | 300 | } |
301 | 301 | } else { |
302 | 302 | printf( |
303 | - _n( 'Failed to import %s donation', 'Failed to import %s donations', $total, 'give' ), |
|
303 | + _n('Failed to import %s donation', 'Failed to import %s donations', $total, 'give'), |
|
304 | 304 | "<strong>{$total}</strong>" |
305 | 305 | ); |
306 | 306 | } |
@@ -308,16 +308,16 @@ discard block |
||
308 | 308 | </h2> |
309 | 309 | |
310 | 310 | <?php |
311 | - $text = __( 'Import Donation', 'give' ); |
|
311 | + $text = __('Import Donation', 'give'); |
|
312 | 312 | $query_arg = array( |
313 | 313 | 'post_type' => 'give_forms', |
314 | 314 | 'page' => 'give-tools', |
315 | 315 | 'tab' => 'import', |
316 | 316 | ); |
317 | - if ( $success ) { |
|
317 | + if ($success) { |
|
318 | 318 | |
319 | 319 | |
320 | - if ( $dry_run ) { |
|
320 | + if ($dry_run) { |
|
321 | 321 | $query_arg = array( |
322 | 322 | 'post_type' => 'give_forms', |
323 | 323 | 'page' => 'give-tools', |
@@ -325,25 +325,25 @@ discard block |
||
325 | 325 | 'importer-type' => 'import_donations', |
326 | 326 | ); |
327 | 327 | |
328 | - $text = __( 'Start Import', 'give' ); |
|
328 | + $text = __('Start Import', 'give'); |
|
329 | 329 | } else { |
330 | 330 | $query_arg = array( |
331 | 331 | 'post_type' => 'give_forms', |
332 | 332 | 'page' => 'give-payment-history', |
333 | 333 | ); |
334 | - $text = __( 'View Donations', 'give' ); |
|
334 | + $text = __('View Donations', 'give'); |
|
335 | 335 | } |
336 | 336 | } |
337 | 337 | |
338 | - foreach ( $report as $key => $value ) { |
|
339 | - if ( array_key_exists( $key, $report_html ) && ! empty( $value ) ) { |
|
340 | - $key_name = $report_html[ $key ][2]; |
|
341 | - if ( $value > 1 ) { |
|
342 | - $key_name = $report_html[ $key ][3]; |
|
338 | + foreach ($report as $key => $value) { |
|
339 | + if (array_key_exists($key, $report_html) && ! empty($value)) { |
|
340 | + $key_name = $report_html[$key][2]; |
|
341 | + if ($value > 1) { |
|
342 | + $key_name = $report_html[$key][3]; |
|
343 | 343 | } |
344 | 344 | ?> |
345 | 345 | <p> |
346 | - <?php printf( $report_html[ $key ][ $dry_run ], $value, $key_name ); ?> |
|
346 | + <?php printf($report_html[$key][$dry_run], $value, $key_name); ?> |
|
347 | 347 | </p> |
348 | 348 | <?php |
349 | 349 | } |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | |
353 | 353 | <p> |
354 | 354 | <a class="button button-large button-secondary" |
355 | - href="<?php echo add_query_arg( $query_arg, admin_url( 'edit.php' ) ); ?>"><?php echo $text; ?></a> |
|
355 | + href="<?php echo add_query_arg($query_arg, admin_url('edit.php')); ?>"><?php echo $text; ?></a> |
|
356 | 356 | </p> |
357 | 357 | </th> |
358 | 358 | </tr> |
@@ -369,26 +369,26 @@ discard block |
||
369 | 369 | give_import_donation_report_reset(); |
370 | 370 | |
371 | 371 | $csv = (int) $_REQUEST['csv']; |
372 | - $delimiter = ( ! empty( $_REQUEST['delimiter'] ) ? give_clean( $_REQUEST['delimiter'] ) : 'csv' ); |
|
372 | + $delimiter = ( ! empty($_REQUEST['delimiter']) ? give_clean($_REQUEST['delimiter']) : 'csv'); |
|
373 | 373 | $index_start = 1; |
374 | 374 | $index_end = 1; |
375 | 375 | $next = true; |
376 | - $total = self::get_csv_total( $csv ); |
|
377 | - if ( self::$per_page < $total ) { |
|
378 | - $total_ajax = ceil( $total / self::$per_page ); |
|
376 | + $total = self::get_csv_total($csv); |
|
377 | + if (self::$per_page < $total) { |
|
378 | + $total_ajax = ceil($total / self::$per_page); |
|
379 | 379 | $index_end = self::$per_page; |
380 | 380 | } else { |
381 | 381 | $total_ajax = 1; |
382 | 382 | $index_end = $total; |
383 | 383 | $next = false; |
384 | 384 | } |
385 | - $current_percentage = 100 / ( $total_ajax + 1 ); |
|
385 | + $current_percentage = 100 / ($total_ajax + 1); |
|
386 | 386 | |
387 | 387 | ?> |
388 | 388 | <tr valign="top" class="give-import-dropdown"> |
389 | 389 | <th colspan="2"> |
390 | - <h2 id="give-import-title"><?php _e( 'Importing', 'give' ) ?></h2> |
|
391 | - <p class="give-field-description"><?php _e( 'Your donations are now being imported...', 'give' ) ?></p> |
|
390 | + <h2 id="give-import-title"><?php _e('Importing', 'give') ?></h2> |
|
391 | + <p class="give-field-description"><?php _e('Your donations are now being imported...', 'give') ?></p> |
|
392 | 392 | </th> |
393 | 393 | </tr> |
394 | 394 | |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | <div style="width: <?php echo $current_percentage; ?>%"></div> |
408 | 408 | </div> |
409 | 409 | <input type="hidden" value="3" name="step"> |
410 | - <input type="hidden" value='<?php echo maybe_serialize( $_REQUEST['mapto'] ); ?>' name="mapto" |
|
410 | + <input type="hidden" value='<?php echo maybe_serialize($_REQUEST['mapto']); ?>' name="mapto" |
|
411 | 411 | class="mapto"> |
412 | 412 | <input type="hidden" value="<?php echo $_REQUEST['csv']; ?>" name="csv" class="csv"> |
413 | 413 | <input type="hidden" value="<?php echo $_REQUEST['mode']; ?>" name="mode" class="mode"> |
@@ -416,9 +416,9 @@ discard block |
||
416 | 416 | <input type="hidden" value="<?php echo $_REQUEST['delete_csv']; ?>" name="delete_csv" |
417 | 417 | class="delete_csv"> |
418 | 418 | <input type="hidden" value="<?php echo $delimiter; ?>" name="delimiter"> |
419 | - <input type="hidden" value="<?php echo absint( $_REQUEST['dry_run'] ); ?>" name="dry_run"> |
|
419 | + <input type="hidden" value="<?php echo absint($_REQUEST['dry_run']); ?>" name="dry_run"> |
|
420 | 420 | <input type="hidden" |
421 | - value='<?php echo maybe_serialize( self::get_importer( $csv, 0, $delimiter ) ); ?>' |
|
421 | + value='<?php echo maybe_serialize(self::get_importer($csv, 0, $delimiter)); ?>' |
|
422 | 422 | name="main_key" |
423 | 423 | class="main_key"> |
424 | 424 | </th> |
@@ -433,20 +433,20 @@ discard block |
||
433 | 433 | */ |
434 | 434 | public function check_for_dropdown_or_import() { |
435 | 435 | $return = true; |
436 | - if ( isset( $_REQUEST['mapto'] ) ) { |
|
436 | + if (isset($_REQUEST['mapto'])) { |
|
437 | 437 | $mapto = (array) $_REQUEST['mapto']; |
438 | - if ( false === in_array( 'form_title', $mapto ) && false === in_array( 'form_id', $mapto ) ) { |
|
439 | - Give_Admin_Settings::add_error( 'give-import-csv-form', __( 'In order to import donations, a column must be mapped to either the "Donation Form Title" or "Donation Form ID" field. Please map a column to one of those fields.', 'give' ) ); |
|
438 | + if (false === in_array('form_title', $mapto) && false === in_array('form_id', $mapto)) { |
|
439 | + Give_Admin_Settings::add_error('give-import-csv-form', __('In order to import donations, a column must be mapped to either the "Donation Form Title" or "Donation Form ID" field. Please map a column to one of those fields.', 'give')); |
|
440 | 440 | $return = false; |
441 | 441 | } |
442 | 442 | |
443 | - if ( false === in_array( 'amount', $mapto ) ) { |
|
444 | - Give_Admin_Settings::add_error( 'give-import-csv-amount', __( 'In order to import donations, a column must be mapped to the "Amount" field. Please map a column to that field.', 'give' ) ); |
|
443 | + if (false === in_array('amount', $mapto)) { |
|
444 | + Give_Admin_Settings::add_error('give-import-csv-amount', __('In order to import donations, a column must be mapped to the "Amount" field. Please map a column to that field.', 'give')); |
|
445 | 445 | $return = false; |
446 | 446 | } |
447 | 447 | |
448 | - if ( false === in_array( 'email', $mapto ) && false === in_array( 'donor_id', $mapto ) ) { |
|
449 | - Give_Admin_Settings::add_error( 'give-import-csv-donor', __( 'In order to import donations, a column must be mapped to either the "Donor Email" or "Donor ID" field. Please map a column to that field.', 'give' ) ); |
|
448 | + if (false === in_array('email', $mapto) && false === in_array('donor_id', $mapto)) { |
|
449 | + Give_Admin_Settings::add_error('give-import-csv-donor', __('In order to import donations, a column must be mapped to either the "Donor Email" or "Donor ID" field. Please map a column to that field.', 'give')); |
|
450 | 450 | $return = false; |
451 | 451 | } |
452 | 452 | } else { |
@@ -463,10 +463,10 @@ discard block |
||
463 | 463 | */ |
464 | 464 | public function render_dropdown() { |
465 | 465 | $csv = (int) $_GET['csv']; |
466 | - $delimiter = ( ! empty( $_GET['delimiter'] ) ? give_clean( $_GET['delimiter'] ) : 'csv' ); |
|
466 | + $delimiter = ( ! empty($_GET['delimiter']) ? give_clean($_GET['delimiter']) : 'csv'); |
|
467 | 467 | |
468 | 468 | // TO check if the CSV files that is being add is valid or not if not then redirect to first step again |
469 | - if ( ! $this->is_valid_csv( $csv ) ) { |
|
469 | + if ( ! $this->is_valid_csv($csv)) { |
|
470 | 470 | $url = give_import_page_url(); |
471 | 471 | ?> |
472 | 472 | <input type="hidden" name="csv_not_valid" class="csv_not_valid" value="<?php echo $url; ?>"/> |
@@ -475,11 +475,11 @@ discard block |
||
475 | 475 | ?> |
476 | 476 | <tr valign="top" class="give-import-dropdown"> |
477 | 477 | <th colspan="2"> |
478 | - <h2 id="give-import-title"><?php _e( 'Map CSV fields to donations', 'give' ) ?></h2> |
|
478 | + <h2 id="give-import-title"><?php _e('Map CSV fields to donations', 'give') ?></h2> |
|
479 | 479 | |
480 | - <p class="give-import-donation-required-fields-title"><?php _e( 'Required Fields' ); ?></p> |
|
480 | + <p class="give-import-donation-required-fields-title"><?php _e('Required Fields'); ?></p> |
|
481 | 481 | |
482 | - <p class="give-field-description"><?php _e( 'These fields are required for the import to submitted' ); ?></p> |
|
482 | + <p class="give-field-description"><?php _e('These fields are required for the import to submitted'); ?></p> |
|
483 | 483 | |
484 | 484 | <ul class="give-import-donation-required-fields"> |
485 | 485 | <li class="give-import-donation-required-email" |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | <span class="give-import-donation-required-symbol dashicons dashicons-no-alt"></span> |
488 | 488 | <span class="give-import-donation-required-text"> |
489 | 489 | <?php |
490 | - _e( 'Email Address', 'give' ); |
|
490 | + _e('Email Address', 'give'); |
|
491 | 491 | ?> |
492 | 492 | </span> |
493 | 493 | </li> |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | <span class="give-import-donation-required-symbol dashicons dashicons-no-alt"></span> |
498 | 498 | <span class="give-import-donation-required-text"> |
499 | 499 | <?php |
500 | - _e( 'First Name', 'give' ); |
|
500 | + _e('First Name', 'give'); |
|
501 | 501 | ?> |
502 | 502 | </span> |
503 | 503 | </li> |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | <span class="give-import-donation-required-symbol dashicons dashicons-no-alt"></span> |
508 | 508 | <span class="give-import-donation-required-text"> |
509 | 509 | <?php |
510 | - _e( 'Donation Amount', 'give' ); |
|
510 | + _e('Donation Amount', 'give'); |
|
511 | 511 | ?> |
512 | 512 | </span> |
513 | 513 | </li> |
@@ -517,32 +517,32 @@ discard block |
||
517 | 517 | <span class="give-import-donation-required-symbol dashicons dashicons-no-alt"></span> |
518 | 518 | <span class="give-import-donation-required-text"> |
519 | 519 | <?php |
520 | - _e( 'Form Title or ID', 'give' ); |
|
520 | + _e('Form Title or ID', 'give'); |
|
521 | 521 | ?> |
522 | 522 | </span> |
523 | 523 | </li> |
524 | 524 | </ul> |
525 | 525 | |
526 | - <p class="give-field-description"><?php _e( 'Select fields from your CSV file to map against donations fields or to ignore during import.', 'give' ) ?></p> |
|
526 | + <p class="give-field-description"><?php _e('Select fields from your CSV file to map against donations fields or to ignore during import.', 'give') ?></p> |
|
527 | 527 | </th> |
528 | 528 | </tr> |
529 | 529 | |
530 | 530 | <tr valign="top" class="give-import-dropdown"> |
531 | - <th><b><?php _e( 'Column name', 'give' ); ?></b></th> |
|
532 | - <th><b><?php _e( 'Map to field', 'give' ); ?></b></th> |
|
531 | + <th><b><?php _e('Column name', 'give'); ?></b></th> |
|
532 | + <th><b><?php _e('Map to field', 'give'); ?></b></th> |
|
533 | 533 | </tr> |
534 | 534 | |
535 | 535 | <?php |
536 | - $raw_key = $this->get_importer( $csv, 0, $delimiter ); |
|
537 | - $mapto = (array) ( isset( $_REQUEST['mapto'] ) ? $_REQUEST['mapto'] : array() ); |
|
536 | + $raw_key = $this->get_importer($csv, 0, $delimiter); |
|
537 | + $mapto = (array) (isset($_REQUEST['mapto']) ? $_REQUEST['mapto'] : array()); |
|
538 | 538 | |
539 | - foreach ( $raw_key as $index => $value ) { |
|
539 | + foreach ($raw_key as $index => $value) { |
|
540 | 540 | ?> |
541 | 541 | <tr valign="top" class="give-import-option"> |
542 | 542 | <th><?php echo $value; ?></th> |
543 | 543 | <th> |
544 | 544 | <?php |
545 | - $this->get_columns( $index, $value, $mapto ); |
|
545 | + $this->get_columns($index, $value, $mapto); |
|
546 | 546 | ?> |
547 | 547 | </th> |
548 | 548 | </tr> |
@@ -557,14 +557,14 @@ discard block |
||
557 | 557 | * |
558 | 558 | * @return string |
559 | 559 | */ |
560 | - public function selected( $option_value, $value ) { |
|
561 | - $option_value = strtolower( $option_value ); |
|
562 | - $value = strtolower( $value ); |
|
560 | + public function selected($option_value, $value) { |
|
561 | + $option_value = strtolower($option_value); |
|
562 | + $value = strtolower($value); |
|
563 | 563 | |
564 | 564 | $selected = ''; |
565 | - if ( stristr( $value, $option_value ) ) { |
|
565 | + if (stristr($value, $option_value)) { |
|
566 | 566 | $selected = 'selected'; |
567 | - } elseif ( strrpos( $value, 'give_' ) && stristr( $option_value, __( 'Import as Meta', 'give' ) ) ) { |
|
567 | + } elseif (strrpos($value, 'give_') && stristr($option_value, __('Import as Meta', 'give'))) { |
|
568 | 568 | $selected = 'selected'; |
569 | 569 | } |
570 | 570 | |
@@ -583,28 +583,28 @@ discard block |
||
583 | 583 | * |
584 | 584 | * @return void |
585 | 585 | */ |
586 | - private function get_columns( $index, $value = false, $mapto = array() ) { |
|
586 | + private function get_columns($index, $value = false, $mapto = array()) { |
|
587 | 587 | $default = give_import_default_options(); |
588 | - $current_mapto = (string) ( ! empty( $mapto[ $index ] ) ? $mapto[ $index ] : '' ); |
|
588 | + $current_mapto = (string) ( ! empty($mapto[$index]) ? $mapto[$index] : ''); |
|
589 | 589 | ?> |
590 | 590 | <select name="mapto[<?php echo $index; ?>]"> |
591 | - <?php $this->get_dropdown_option_html( $default, $current_mapto, $value ); ?> |
|
591 | + <?php $this->get_dropdown_option_html($default, $current_mapto, $value); ?> |
|
592 | 592 | |
593 | - <optgroup label="<?php _e( 'Donations', 'give' ); ?>"> |
|
593 | + <optgroup label="<?php _e('Donations', 'give'); ?>"> |
|
594 | 594 | <?php |
595 | - $this->get_dropdown_option_html( give_import_donations_options(), $current_mapto, $value ); |
|
595 | + $this->get_dropdown_option_html(give_import_donations_options(), $current_mapto, $value); |
|
596 | 596 | ?> |
597 | 597 | </optgroup> |
598 | 598 | |
599 | - <optgroup label="<?php _e( 'Donors', 'give' ); ?>"> |
|
599 | + <optgroup label="<?php _e('Donors', 'give'); ?>"> |
|
600 | 600 | <?php |
601 | - $this->get_dropdown_option_html( give_import_donor_options(), $current_mapto, $value ); |
|
601 | + $this->get_dropdown_option_html(give_import_donor_options(), $current_mapto, $value); |
|
602 | 602 | ?> |
603 | 603 | </optgroup> |
604 | 604 | |
605 | - <optgroup label="<?php _e( 'Forms', 'give' ); ?>"> |
|
605 | + <optgroup label="<?php _e('Forms', 'give'); ?>"> |
|
606 | 606 | <?php |
607 | - $this->get_dropdown_option_html( give_import_donation_form_options(), $current_mapto, $value ); |
|
607 | + $this->get_dropdown_option_html(give_import_donation_form_options(), $current_mapto, $value); |
|
608 | 608 | ?> |
609 | 609 | </optgroup> |
610 | 610 | |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | * |
616 | 616 | * @since 1.8.15 |
617 | 617 | */ |
618 | - do_action( 'give_import_dropdown_option', $index, $value, $mapto, $current_mapto ); |
|
618 | + do_action('give_import_dropdown_option', $index, $value, $mapto, $current_mapto); |
|
619 | 619 | ?> |
620 | 620 | </select> |
621 | 621 | <?php |
@@ -633,16 +633,16 @@ discard block |
||
633 | 633 | * |
634 | 634 | * @return void |
635 | 635 | */ |
636 | - public function get_dropdown_option_html( $options, $current_mapto, $value = false ) { |
|
637 | - foreach ( $options as $option => $option_value ) { |
|
636 | + public function get_dropdown_option_html($options, $current_mapto, $value = false) { |
|
637 | + foreach ($options as $option => $option_value) { |
|
638 | 638 | $option_value_texts = (array) $option_value; |
639 | 639 | $option_text = $option_value_texts[0]; |
640 | 640 | |
641 | - $checked = ( ( $current_mapto === $option ) ? 'selected' : false ); |
|
642 | - if ( empty( $checked ) ) { |
|
643 | - foreach ( $option_value_texts as $option_value_text ) { |
|
644 | - $checked = $this->selected( $option_value_text, $value ); |
|
645 | - if ( $checked ) { |
|
641 | + $checked = (($current_mapto === $option) ? 'selected' : false); |
|
642 | + if (empty($checked)) { |
|
643 | + foreach ($option_value_texts as $option_value_text) { |
|
644 | + $checked = $this->selected($option_value_text, $value); |
|
645 | + if ($checked) { |
|
646 | 646 | break; |
647 | 647 | } |
648 | 648 | } |
@@ -666,12 +666,12 @@ discard block |
||
666 | 666 | * |
667 | 667 | * @return bool|int |
668 | 668 | */ |
669 | - public function get_csv_total( $file_id ) { |
|
669 | + public function get_csv_total($file_id) { |
|
670 | 670 | $total = false; |
671 | - if ( $file_id ) { |
|
672 | - $file_dir = get_attached_file( $file_id ); |
|
673 | - if ( $file_dir ) { |
|
674 | - $total = $this->get_csv_data_from_file_dir( $file_dir ); |
|
671 | + if ($file_id) { |
|
672 | + $file_dir = get_attached_file($file_id); |
|
673 | + if ($file_dir) { |
|
674 | + $total = $this->get_csv_data_from_file_dir($file_dir); |
|
675 | 675 | } |
676 | 676 | } |
677 | 677 | |
@@ -687,11 +687,11 @@ discard block |
||
687 | 687 | * |
688 | 688 | * @return bool|int |
689 | 689 | */ |
690 | - public function get_csv_data_from_file_dir( $file_dir ) { |
|
690 | + public function get_csv_data_from_file_dir($file_dir) { |
|
691 | 691 | $total = false; |
692 | - if ( $file_dir ) { |
|
693 | - $file = new SplFileObject( $file_dir, 'r' ); |
|
694 | - $file->seek( PHP_INT_MAX ); |
|
692 | + if ($file_dir) { |
|
693 | + $file = new SplFileObject($file_dir, 'r'); |
|
694 | + $file->seek(PHP_INT_MAX); |
|
695 | 695 | $total = $file->key() + 1; |
696 | 696 | } |
697 | 697 | |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | * |
710 | 710 | * @return array|bool $raw_data title of the CSV file fields |
711 | 711 | */ |
712 | - public function get_importer( $file_id, $index = 0, $delimiter = 'csv' ) { |
|
712 | + public function get_importer($file_id, $index = 0, $delimiter = 'csv') { |
|
713 | 713 | /** |
714 | 714 | * Filter to modify delimiter of Import. |
715 | 715 | * |
@@ -717,16 +717,16 @@ discard block |
||
717 | 717 | * |
718 | 718 | * Return string $delimiter. |
719 | 719 | */ |
720 | - $delimiter = (string) apply_filters( 'give_import_delimiter_set', $delimiter ); |
|
720 | + $delimiter = (string) apply_filters('give_import_delimiter_set', $delimiter); |
|
721 | 721 | |
722 | 722 | $raw_data = false; |
723 | - $file_dir = get_attached_file( $file_id ); |
|
724 | - if ( $file_dir ) { |
|
725 | - if ( false !== ( $handle = fopen( $file_dir, 'r' ) ) ) { |
|
726 | - $raw_data = fgetcsv( $handle, $index, $delimiter ); |
|
723 | + $file_dir = get_attached_file($file_id); |
|
724 | + if ($file_dir) { |
|
725 | + if (false !== ($handle = fopen($file_dir, 'r'))) { |
|
726 | + $raw_data = fgetcsv($handle, $index, $delimiter); |
|
727 | 727 | // Remove BOM signature from the first item. |
728 | - if ( isset( $raw_data[0] ) ) { |
|
729 | - $raw_data[0] = $this->remove_utf8_bom( $raw_data[0] ); |
|
728 | + if (isset($raw_data[0])) { |
|
729 | + $raw_data[0] = $this->remove_utf8_bom($raw_data[0]); |
|
730 | 730 | } |
731 | 731 | } |
732 | 732 | } |
@@ -743,9 +743,9 @@ discard block |
||
743 | 743 | * |
744 | 744 | * @return string |
745 | 745 | */ |
746 | - public function remove_utf8_bom( $string ) { |
|
747 | - if ( 'efbbbf' === substr( bin2hex( $string ), 0, 6 ) ) { |
|
748 | - $string = substr( $string, 3 ); |
|
746 | + public function remove_utf8_bom($string) { |
|
747 | + if ('efbbbf' === substr(bin2hex($string), 0, 6)) { |
|
748 | + $string = substr($string, 3); |
|
749 | 749 | } |
750 | 750 | |
751 | 751 | return $string; |
@@ -760,17 +760,17 @@ discard block |
||
760 | 760 | $step = $this->get_step(); |
761 | 761 | ?> |
762 | 762 | <ol class="give-progress-steps"> |
763 | - <li class="<?php echo( 1 === $step ? 'active' : '' ); ?>"> |
|
764 | - <?php _e( 'Upload CSV file', 'give' ); ?> |
|
763 | + <li class="<?php echo(1 === $step ? 'active' : ''); ?>"> |
|
764 | + <?php _e('Upload CSV file', 'give'); ?> |
|
765 | 765 | </li> |
766 | - <li class="<?php echo( 2 === $step ? 'active' : '' ); ?>"> |
|
767 | - <?php _e( 'Column mapping', 'give' ); ?> |
|
766 | + <li class="<?php echo(2 === $step ? 'active' : ''); ?>"> |
|
767 | + <?php _e('Column mapping', 'give'); ?> |
|
768 | 768 | </li> |
769 | - <li class="<?php echo( 3 === $step ? 'active' : '' ); ?>"> |
|
770 | - <?php _e( 'Import', 'give' ); ?> |
|
769 | + <li class="<?php echo(3 === $step ? 'active' : ''); ?>"> |
|
770 | + <?php _e('Import', 'give'); ?> |
|
771 | 771 | </li> |
772 | - <li class="<?php echo( 4 === $step ? 'active' : '' ); ?>"> |
|
773 | - <?php _e( 'Done!', 'give' ); ?> |
|
772 | + <li class="<?php echo(4 === $step ? 'active' : ''); ?>"> |
|
773 | + <?php _e('Done!', 'give'); ?> |
|
774 | 774 | </li> |
775 | 775 | </ol> |
776 | 776 | <?php |
@@ -784,16 +784,16 @@ discard block |
||
784 | 784 | * @return int $step on which step doest the import is on. |
785 | 785 | */ |
786 | 786 | public function get_step() { |
787 | - $step = (int) ( isset( $_REQUEST['step'] ) ? give_clean( $_REQUEST['step'] ) : 0 ); |
|
787 | + $step = (int) (isset($_REQUEST['step']) ? give_clean($_REQUEST['step']) : 0); |
|
788 | 788 | $on_step = 1; |
789 | 789 | |
790 | - if ( empty( $step ) || 1 === $step ) { |
|
790 | + if (empty($step) || 1 === $step) { |
|
791 | 791 | $on_step = 1; |
792 | - } elseif ( $this->check_for_dropdown_or_import() ) { |
|
792 | + } elseif ($this->check_for_dropdown_or_import()) { |
|
793 | 793 | $on_step = 3; |
794 | - } elseif ( 2 === $step ) { |
|
794 | + } elseif (2 === $step) { |
|
795 | 795 | $on_step = 2; |
796 | - } elseif ( 4 === $step ) { |
|
796 | + } elseif (4 === $step) { |
|
797 | 797 | $on_step = 4; |
798 | 798 | } |
799 | 799 | |
@@ -806,7 +806,7 @@ discard block |
||
806 | 806 | * @since 1.8.14 |
807 | 807 | */ |
808 | 808 | public function render_page() { |
809 | - include_once GIVE_PLUGIN_DIR . 'includes/admin/tools/views/html-admin-page-import-donations.php'; |
|
809 | + include_once GIVE_PLUGIN_DIR.'includes/admin/tools/views/html-admin-page-import-donations.php'; |
|
810 | 810 | } |
811 | 811 | |
812 | 812 | /** |
@@ -815,18 +815,18 @@ discard block |
||
815 | 815 | * @since 2.1 |
816 | 816 | */ |
817 | 817 | public function give_import_donation_submit_button_render_media_csv() { |
818 | - $dry_run = isset( $_POST['dry_run'] ) ? absint( $_POST['dry_run'] ) : 1; |
|
818 | + $dry_run = isset($_POST['dry_run']) ? absint($_POST['dry_run']) : 1; |
|
819 | 819 | ?> |
820 | 820 | <div> |
821 | 821 | <label for="dry_run"> |
822 | 822 | <input type="hidden" name="dry_run" value="0"/> |
823 | 823 | <input type="checkbox" name="dry_run" id="dry_run" class="dry_run" |
824 | - value="1" <?php checked( 1, $dry_run ); ?> > |
|
825 | - <strong><?php _e( 'Dry Run', 'give' ); ?></strong> |
|
824 | + value="1" <?php checked(1, $dry_run); ?> > |
|
825 | + <strong><?php _e('Dry Run', 'give'); ?></strong> |
|
826 | 826 | </label> |
827 | 827 | <p class="give-field-description"> |
828 | 828 | <?php |
829 | - _e( 'Preview what the import would look like without making any default changes to your site or your database.', 'give' ); |
|
829 | + _e('Preview what the import would look like without making any default changes to your site or your database.', 'give'); |
|
830 | 830 | ?> |
831 | 831 | </p> |
832 | 832 | </div> |
@@ -842,8 +842,8 @@ discard block |
||
842 | 842 | * |
843 | 843 | * @return string |
844 | 844 | */ |
845 | - function give_import_donation_submit_text_render_media_csv( $text ) { |
|
846 | - return __( 'Begin Import', 'give' ); |
|
845 | + function give_import_donation_submit_text_render_media_csv($text) { |
|
846 | + return __('Begin Import', 'give'); |
|
847 | 847 | } |
848 | 848 | |
849 | 849 | /** |
@@ -855,60 +855,57 @@ discard block |
||
855 | 855 | * @return void |
856 | 856 | */ |
857 | 857 | public function render_media_csv() { |
858 | - add_filter( 'give_import_donation_submit_button_text', array( |
|
858 | + add_filter('give_import_donation_submit_button_text', array( |
|
859 | 859 | $this, |
860 | 860 | 'give_import_donation_submit_text_render_media_csv' |
861 | - ) ); |
|
862 | - add_action( 'give_import_donation_submit_button', array( |
|
861 | + )); |
|
862 | + add_action('give_import_donation_submit_button', array( |
|
863 | 863 | $this, |
864 | 864 | 'give_import_donation_submit_button_render_media_csv' |
865 | - ) ); |
|
865 | + )); |
|
866 | 866 | ?> |
867 | 867 | <tr valign="top"> |
868 | 868 | <th colspan="2"> |
869 | - <h2 id="give-import-title"><?php _e( 'Import donations from a CSV file', 'give' ) ?></h2> |
|
870 | - <p class="give-field-description"><?php _e( 'This tool allows you to import or add donation data to your give form(s) via a CSV file.', 'give' ) ?></p> |
|
869 | + <h2 id="give-import-title"><?php _e('Import donations from a CSV file', 'give') ?></h2> |
|
870 | + <p class="give-field-description"><?php _e('This tool allows you to import or add donation data to your give form(s) via a CSV file.', 'give') ?></p> |
|
871 | 871 | </th> |
872 | 872 | </tr> |
873 | 873 | <?php |
874 | - $csv = ( isset( $_POST['csv'] ) ? give_clean( $_POST['csv'] ) : '' ); |
|
875 | - $csv_id = ( isset( $_POST['csv_id'] ) ? give_clean( $_POST['csv_id'] ) : '' ); |
|
876 | - $delimiter = ( isset( $_POST['delimiter'] ) ? give_clean( $_POST['delimiter'] ) : 'csv' ); |
|
877 | - $mode = empty( $_POST['mode'] ) ? |
|
878 | - 'disabled' : |
|
879 | - ( give_is_setting_enabled( give_clean( $_POST['mode'] ) ) ? 'enabled' : 'disabled' ); |
|
880 | - $create_user = empty( $_POST['create_user'] ) ? |
|
881 | - 'disabled' : |
|
882 | - ( give_is_setting_enabled( give_clean( $_POST['create_user'] ) ) ? 'enabled' : 'disabled' ); |
|
883 | - $delete_csv = empty( $_POST['delete_csv'] ) ? |
|
884 | - 'enabled' : |
|
885 | - ( give_is_setting_enabled( give_clean( $_POST['delete_csv'] ) ) ? 'enabled' : 'disabled' ); |
|
874 | + $csv = (isset($_POST['csv']) ? give_clean($_POST['csv']) : ''); |
|
875 | + $csv_id = (isset($_POST['csv_id']) ? give_clean($_POST['csv_id']) : ''); |
|
876 | + $delimiter = (isset($_POST['delimiter']) ? give_clean($_POST['delimiter']) : 'csv'); |
|
877 | + $mode = empty($_POST['mode']) ? |
|
878 | + 'disabled' : (give_is_setting_enabled(give_clean($_POST['mode'])) ? 'enabled' : 'disabled'); |
|
879 | + $create_user = empty($_POST['create_user']) ? |
|
880 | + 'disabled' : (give_is_setting_enabled(give_clean($_POST['create_user'])) ? 'enabled' : 'disabled'); |
|
881 | + $delete_csv = empty($_POST['delete_csv']) ? |
|
882 | + 'enabled' : (give_is_setting_enabled(give_clean($_POST['delete_csv'])) ? 'enabled' : 'disabled'); |
|
886 | 883 | |
887 | 884 | // Reset csv and csv_id if csv |
888 | - if ( empty( $csv_id ) || ! $this->is_valid_csv( $csv_id, $csv ) ) { |
|
885 | + if (empty($csv_id) || ! $this->is_valid_csv($csv_id, $csv)) { |
|
889 | 886 | $csv_id = $csv = ''; |
890 | 887 | } |
891 | - $per_page = isset( $_POST['per_page'] ) ? absint( $_POST['per_page'] ) : self::$per_page; |
|
888 | + $per_page = isset($_POST['per_page']) ? absint($_POST['per_page']) : self::$per_page; |
|
892 | 889 | |
893 | 890 | $sample_file_text = sprintf( |
894 | 891 | '%s <a href="%s">%s</a>.', |
895 | - __( 'Download the sample file', 'give' ), |
|
896 | - esc_url( GIVE_PLUGIN_URL . 'sample-data/sample-data.csv' ), |
|
897 | - __( 'here', 'give' ) |
|
892 | + __('Download the sample file', 'give'), |
|
893 | + esc_url(GIVE_PLUGIN_URL.'sample-data/sample-data.csv'), |
|
894 | + __('here', 'give') |
|
898 | 895 | ); |
899 | 896 | |
900 | 897 | $csv_description = sprintf( |
901 | 898 | '%1$s %2$s', |
902 | - __( 'The file must be a Comma Seperated Version (CSV) file type only.', 'give' ), |
|
899 | + __('The file must be a Comma Seperated Version (CSV) file type only.', 'give'), |
|
903 | 900 | $sample_file_text |
904 | 901 | ); |
905 | 902 | |
906 | 903 | $settings = array( |
907 | 904 | array( |
908 | 905 | 'id' => 'csv', |
909 | - 'name' => __( 'Choose a CSV file:', 'give' ), |
|
906 | + 'name' => __('Choose a CSV file:', 'give'), |
|
910 | 907 | 'type' => 'file', |
911 | - 'attributes' => array( 'editing' => 'false', 'library' => 'text' ), |
|
908 | + 'attributes' => array('editing' => 'false', 'library' => 'text'), |
|
912 | 909 | 'description' => $csv_description, |
913 | 910 | 'fvalue' => 'url', |
914 | 911 | 'default' => $csv, |
@@ -920,62 +917,62 @@ discard block |
||
920 | 917 | ), |
921 | 918 | array( |
922 | 919 | 'id' => 'delimiter', |
923 | - 'name' => __( 'CSV Delimiter:', 'give' ), |
|
924 | - 'description' => __( 'In case your CSV file supports a different type of separator (or delimiter) -- like a tab or space -- you can set that here.', 'give' ), |
|
920 | + 'name' => __('CSV Delimiter:', 'give'), |
|
921 | + 'description' => __('In case your CSV file supports a different type of separator (or delimiter) -- like a tab or space -- you can set that here.', 'give'), |
|
925 | 922 | 'default' => $delimiter, |
926 | 923 | 'type' => 'select', |
927 | 924 | 'options' => array( |
928 | - 'csv' => __( 'Comma', 'give' ), |
|
929 | - 'tab-separated-values' => __( 'Tab', 'give' ), |
|
925 | + 'csv' => __('Comma', 'give'), |
|
926 | + 'tab-separated-values' => __('Tab', 'give'), |
|
930 | 927 | ), |
931 | 928 | ), |
932 | 929 | array( |
933 | 930 | 'id' => 'mode', |
934 | - 'name' => __( 'Test Mode:', 'give' ), |
|
935 | - 'description' => __( 'Select whether you would like these donations to be marked as "test" donations within the database. By default, they will be marked as live donations.', 'give' ), |
|
931 | + 'name' => __('Test Mode:', 'give'), |
|
932 | + 'description' => __('Select whether you would like these donations to be marked as "test" donations within the database. By default, they will be marked as live donations.', 'give'), |
|
936 | 933 | 'default' => $mode, |
937 | 934 | 'type' => 'radio_inline', |
938 | 935 | 'options' => array( |
939 | - 'enabled' => __( 'Enabled', 'give' ), |
|
940 | - 'disabled' => __( 'Disabled', 'give' ), |
|
936 | + 'enabled' => __('Enabled', 'give'), |
|
937 | + 'disabled' => __('Disabled', 'give'), |
|
941 | 938 | ), |
942 | 939 | ), |
943 | 940 | array( |
944 | 941 | 'id' => 'create_user', |
945 | - 'name' => __( 'Create WP users for new donors:', 'give' ), |
|
946 | - 'description' => __( 'The importer can create WordPress user accounts based on the names and email addresses of the donations in your CSV file. Enable this option if you\'d like the importer to do that.', 'give' ), |
|
942 | + 'name' => __('Create WP users for new donors:', 'give'), |
|
943 | + 'description' => __('The importer can create WordPress user accounts based on the names and email addresses of the donations in your CSV file. Enable this option if you\'d like the importer to do that.', 'give'), |
|
947 | 944 | 'default' => $create_user, |
948 | 945 | 'type' => 'radio_inline', |
949 | 946 | 'options' => array( |
950 | - 'enabled' => __( 'Enabled', 'give' ), |
|
951 | - 'disabled' => __( 'Disabled', 'give' ), |
|
947 | + 'enabled' => __('Enabled', 'give'), |
|
948 | + 'disabled' => __('Disabled', 'give'), |
|
952 | 949 | ), |
953 | 950 | ), |
954 | 951 | array( |
955 | 952 | 'id' => 'delete_csv', |
956 | - 'name' => __( 'Delete CSV after import:', 'give' ), |
|
957 | - 'description' => __( 'Your CSV file will be uploaded via the WordPress Media Library. It\'s a good idea to delete it after the import is finished so that your sensitive data is not accessible on the web. Disable this only if you plan to delete the file manually later.', 'give' ), |
|
953 | + 'name' => __('Delete CSV after import:', 'give'), |
|
954 | + 'description' => __('Your CSV file will be uploaded via the WordPress Media Library. It\'s a good idea to delete it after the import is finished so that your sensitive data is not accessible on the web. Disable this only if you plan to delete the file manually later.', 'give'), |
|
958 | 955 | 'default' => $delete_csv, |
959 | 956 | 'type' => 'radio_inline', |
960 | 957 | 'options' => array( |
961 | - 'enabled' => __( 'Enabled', 'give' ), |
|
962 | - 'disabled' => __( 'Disabled', 'give' ), |
|
958 | + 'enabled' => __('Enabled', 'give'), |
|
959 | + 'disabled' => __('Disabled', 'give'), |
|
963 | 960 | ), |
964 | 961 | ), |
965 | 962 | array( |
966 | 963 | 'id' => 'per_page', |
967 | - 'name' => __( 'Process Rows Per Batch:', 'give' ), |
|
964 | + 'name' => __('Process Rows Per Batch:', 'give'), |
|
968 | 965 | 'type' => 'number', |
969 | - 'description' => __( 'Determine how many rows you would like to import per cycle.', 'give' ), |
|
966 | + 'description' => __('Determine how many rows you would like to import per cycle.', 'give'), |
|
970 | 967 | 'default' => $per_page, |
971 | 968 | 'class' => 'give-text-small', |
972 | 969 | ), |
973 | 970 | ); |
974 | 971 | |
975 | - $settings = apply_filters( 'give_import_file_upload_html', $settings ); |
|
972 | + $settings = apply_filters('give_import_file_upload_html', $settings); |
|
976 | 973 | |
977 | - if ( empty( $this->is_csv_valid ) ) { |
|
978 | - Give_Admin_Settings::output_fields( $settings, 'give_settings' ); |
|
974 | + if (empty($this->is_csv_valid)) { |
|
975 | + Give_Admin_Settings::output_fields($settings, 'give_settings'); |
|
979 | 976 | } else { |
980 | 977 | ?> |
981 | 978 | <input type="hidden" name="is_csv_valid" class="is_csv_valid" |
@@ -994,28 +991,25 @@ discard block |
||
994 | 991 | $step = $this->get_step(); |
995 | 992 | |
996 | 993 | // Validation for first step. |
997 | - if ( 1 === $step ) { |
|
998 | - $csv_id = absint( $_POST['csv_id'] ); |
|
994 | + if (1 === $step) { |
|
995 | + $csv_id = absint($_POST['csv_id']); |
|
999 | 996 | |
1000 | - if ( $this->is_valid_csv( $csv_id, esc_url( $_POST['csv'] ) ) ) { |
|
997 | + if ($this->is_valid_csv($csv_id, esc_url($_POST['csv']))) { |
|
1001 | 998 | |
1002 | - $url = give_import_page_url( (array) apply_filters( 'give_import_step_two_url', array( |
|
999 | + $url = give_import_page_url((array) apply_filters('give_import_step_two_url', array( |
|
1003 | 1000 | 'step' => '2', |
1004 | 1001 | 'importer-type' => $this->importer_type, |
1005 | 1002 | 'csv' => $csv_id, |
1006 | - 'delimiter' => isset( $_REQUEST['delimiter'] ) ? give_clean( $_REQUEST['delimiter'] ) : 'csv', |
|
1007 | - 'mode' => empty( $_POST['mode'] ) ? |
|
1008 | - '0' : |
|
1009 | - ( give_is_setting_enabled( give_clean( $_POST['mode'] ) ) ? '1' : '0' ), |
|
1010 | - 'create_user' => empty( $_POST['create_user'] ) ? |
|
1011 | - '0' : |
|
1012 | - ( give_is_setting_enabled( give_clean( $_POST['create_user'] ) ) ? '1' : '0' ), |
|
1013 | - 'delete_csv' => empty( $_POST['delete_csv'] ) ? |
|
1014 | - '1' : |
|
1015 | - ( give_is_setting_enabled( give_clean( $_POST['delete_csv'] ) ) ? '1' : '0' ), |
|
1016 | - 'per_page' => isset( $_POST['per_page'] ) ? absint( $_POST['per_page'] ) : self::$per_page, |
|
1017 | - 'dry_run' => isset( $_POST['dry_run'] ) ? absint( $_POST['dry_run'] ) : 0, |
|
1018 | - ) ) ); |
|
1003 | + 'delimiter' => isset($_REQUEST['delimiter']) ? give_clean($_REQUEST['delimiter']) : 'csv', |
|
1004 | + 'mode' => empty($_POST['mode']) ? |
|
1005 | + '0' : (give_is_setting_enabled(give_clean($_POST['mode'])) ? '1' : '0'), |
|
1006 | + 'create_user' => empty($_POST['create_user']) ? |
|
1007 | + '0' : (give_is_setting_enabled(give_clean($_POST['create_user'])) ? '1' : '0'), |
|
1008 | + 'delete_csv' => empty($_POST['delete_csv']) ? |
|
1009 | + '1' : (give_is_setting_enabled(give_clean($_POST['delete_csv'])) ? '1' : '0'), |
|
1010 | + 'per_page' => isset($_POST['per_page']) ? absint($_POST['per_page']) : self::$per_page, |
|
1011 | + 'dry_run' => isset($_POST['dry_run']) ? absint($_POST['dry_run']) : 0, |
|
1012 | + ))); |
|
1019 | 1013 | |
1020 | 1014 | $this->is_csv_valid = $url; |
1021 | 1015 | } |
@@ -1033,25 +1027,25 @@ discard block |
||
1033 | 1027 | * |
1034 | 1028 | * @return bool $has_error CSV is valid or not. |
1035 | 1029 | */ |
1036 | - private function is_valid_csv( $csv = false, $match_url = '' ) { |
|
1030 | + private function is_valid_csv($csv = false, $match_url = '') { |
|
1037 | 1031 | $is_valid_csv = true; |
1038 | 1032 | |
1039 | - if ( $csv ) { |
|
1040 | - $csv_url = wp_get_attachment_url( $csv ); |
|
1033 | + if ($csv) { |
|
1034 | + $csv_url = wp_get_attachment_url($csv); |
|
1041 | 1035 | |
1042 | - $delimiter = ( ! empty( $_REQUEST['delimiter'] ) ? give_clean( $_REQUEST['delimiter'] ) : 'csv' ); |
|
1036 | + $delimiter = ( ! empty($_REQUEST['delimiter']) ? give_clean($_REQUEST['delimiter']) : 'csv'); |
|
1043 | 1037 | |
1044 | 1038 | if ( |
1045 | 1039 | ! $csv_url || |
1046 | - ( ! empty( $match_url ) && ( $csv_url !== $match_url ) ) || |
|
1047 | - ( ( $mime_type = get_post_mime_type( $csv ) ) && ! strpos( $mime_type, $delimiter ) ) |
|
1040 | + ( ! empty($match_url) && ($csv_url !== $match_url)) || |
|
1041 | + (($mime_type = get_post_mime_type($csv)) && ! strpos($mime_type, $delimiter)) |
|
1048 | 1042 | ) { |
1049 | 1043 | $is_valid_csv = false; |
1050 | - Give_Admin_Settings::add_error( 'give-import-csv', __( 'Please upload or provide a valid CSV file.', 'give' ) ); |
|
1044 | + Give_Admin_Settings::add_error('give-import-csv', __('Please upload or provide a valid CSV file.', 'give')); |
|
1051 | 1045 | } |
1052 | 1046 | } else { |
1053 | 1047 | $is_valid_csv = false; |
1054 | - Give_Admin_Settings::add_error( 'give-import-csv', __( 'Please upload or provide a valid CSV file.', 'give' ) ); |
|
1048 | + Give_Admin_Settings::add_error('give-import-csv', __('Please upload or provide a valid CSV file.', 'give')); |
|
1055 | 1049 | } |
1056 | 1050 | |
1057 | 1051 | return $is_valid_csv; |
@@ -1067,8 +1061,8 @@ discard block |
||
1067 | 1061 | * @param $field |
1068 | 1062 | * @param $option_value |
1069 | 1063 | */ |
1070 | - public function render_import_field( $field, $option_value ) { |
|
1071 | - include_once GIVE_PLUGIN_DIR . 'includes/admin/tools/views/html-admin-page-imports.php'; |
|
1064 | + public function render_import_field($field, $option_value) { |
|
1065 | + include_once GIVE_PLUGIN_DIR.'includes/admin/tools/views/html-admin-page-imports.php'; |
|
1072 | 1066 | } |
1073 | 1067 | |
1074 | 1068 | /** |
@@ -1079,8 +1073,8 @@ discard block |
||
1079 | 1073 | */ |
1080 | 1074 | private function is_donations_import_page() { |
1081 | 1075 | return 'import' === give_get_current_setting_tab() && |
1082 | - isset( $_GET['importer-type'] ) && |
|
1083 | - $this->importer_type === give_clean( $_GET['importer-type'] ); |
|
1076 | + isset($_GET['importer-type']) && |
|
1077 | + $this->importer_type === give_clean($_GET['importer-type']); |
|
1084 | 1078 | } |
1085 | 1079 | } |
1086 | 1080 |
@@ -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 | |
@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return bool true if has variable prices, false otherwise |
25 | 25 | */ |
26 | -function give_has_variable_prices( $form_id = 0 ) { |
|
26 | +function give_has_variable_prices($form_id = 0) { |
|
27 | 27 | |
28 | - if ( empty( $form_id ) ) { |
|
28 | + if (empty($form_id)) { |
|
29 | 29 | return false; |
30 | 30 | } |
31 | 31 | |
32 | - $form = new Give_Donate_Form( $form_id ); |
|
32 | + $form = new Give_Donate_Form($form_id); |
|
33 | 33 | |
34 | 34 | return $form->has_variable_prices(); |
35 | 35 | } |
@@ -44,13 +44,13 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return array|bool Variable prices |
46 | 46 | */ |
47 | -function give_get_variable_prices( $form_id = 0 ) { |
|
47 | +function give_get_variable_prices($form_id = 0) { |
|
48 | 48 | |
49 | - if ( empty( $form_id ) ) { |
|
49 | + if (empty($form_id)) { |
|
50 | 50 | return false; |
51 | 51 | } |
52 | 52 | |
53 | - $form = new Give_Donate_Form( $form_id ); |
|
53 | + $form = new Give_Donate_Form($form_id); |
|
54 | 54 | |
55 | 55 | return $form->prices; |
56 | 56 | |
@@ -65,13 +65,13 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @return array Variable prices |
67 | 67 | */ |
68 | -function give_get_variable_price_ids( $form_id = 0 ) { |
|
69 | - if( ! ( $prices = give_get_variable_prices( $form_id ) ) ) { |
|
68 | +function give_get_variable_price_ids($form_id = 0) { |
|
69 | + if ( ! ($prices = give_get_variable_prices($form_id))) { |
|
70 | 70 | return array(); |
71 | 71 | } |
72 | 72 | |
73 | 73 | $price_ids = array(); |
74 | - foreach ( $prices as $price ){ |
|
74 | + foreach ($prices as $price) { |
|
75 | 75 | $price_ids[] = $price['_give_id']['level_id']; |
76 | 76 | } |
77 | 77 | |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @return string $default_price |
91 | 91 | */ |
92 | -function give_get_default_multilevel_amount( $form_id ) { |
|
92 | +function give_get_default_multilevel_amount($form_id) { |
|
93 | 93 | $default_price = '1.00'; |
94 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
94 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
95 | 95 | |
96 | - foreach ( $prices as $price ) { |
|
96 | + foreach ($prices as $price) { |
|
97 | 97 | |
98 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
98 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
99 | 99 | $default_price = $price['_give_amount']; |
100 | 100 | } |
101 | 101 | |
@@ -116,19 +116,19 @@ discard block |
||
116 | 116 | * @return string $default_price |
117 | 117 | * @since 1.0 |
118 | 118 | */ |
119 | -function give_get_default_form_amount( $form_id ) { |
|
119 | +function give_get_default_form_amount($form_id) { |
|
120 | 120 | |
121 | - if ( give_has_variable_prices( $form_id ) ) { |
|
121 | + if (give_has_variable_prices($form_id)) { |
|
122 | 122 | |
123 | - $default_amount = give_get_default_multilevel_amount( $form_id ); |
|
123 | + $default_amount = give_get_default_multilevel_amount($form_id); |
|
124 | 124 | |
125 | 125 | } else { |
126 | 126 | |
127 | - $default_amount = give_get_meta( $form_id, '_give_set_price', true ); |
|
127 | + $default_amount = give_get_meta($form_id, '_give_set_price', true); |
|
128 | 128 | |
129 | 129 | } |
130 | 130 | |
131 | - return apply_filters( 'give_default_form_amount', $default_amount, $form_id ); |
|
131 | + return apply_filters('give_default_form_amount', $default_amount, $form_id); |
|
132 | 132 | |
133 | 133 | } |
134 | 134 | |
@@ -146,13 +146,13 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @return bool |
148 | 148 | */ |
149 | -function give_is_custom_price_mode( $form_id = 0 ) { |
|
149 | +function give_is_custom_price_mode($form_id = 0) { |
|
150 | 150 | |
151 | - if ( empty( $form_id ) ) { |
|
151 | + if (empty($form_id)) { |
|
152 | 152 | return false; |
153 | 153 | } |
154 | 154 | |
155 | - $form = new Give_Donate_Form( $form_id ); |
|
155 | + $form = new Give_Donate_Form($form_id); |
|
156 | 156 | |
157 | 157 | return $form->is_custom_price_mode(); |
158 | 158 | } |
159 | 159 | \ No newline at end of file |
@@ -1020,9 +1020,12 @@ |
||
1020 | 1020 | } |
1021 | 1021 | ?> |
1022 | 1022 | </select> |
1023 | - <?php else : ?> |
|
1023 | + <?php else { |
|
1024 | + : ?> |
|
1024 | 1025 | <input type="text" size="6" name="card_state" id="card_state" class="card_state give-input" |
1025 | - placeholder="<?php echo $label; ?>" value="<?php echo $selected_state; ?>"/> |
|
1026 | + placeholder="<?php echo $label; |
|
1027 | +} |
|
1028 | +?>" value="<?php echo $selected_state; ?>"/> |
|
1026 | 1029 | <?php endif; ?> |
1027 | 1030 | </p> |
1028 | 1031 |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @since 1.0 |
23 | 23 | * |
24 | - * @return string Donation form. |
|
24 | + * @return false|null Donation form. |
|
25 | 25 | */ |
26 | 26 | function give_get_donation_form( $args = array() ) { |
27 | 27 | |
@@ -1482,7 +1482,7 @@ discard block |
||
1482 | 1482 | * |
1483 | 1483 | * @param int $form_id The form ID. |
1484 | 1484 | * |
1485 | - * @return bool |
|
1485 | + * @return false|null |
|
1486 | 1486 | */ |
1487 | 1487 | function give_terms_agreement( $form_id ) { |
1488 | 1488 | $form_option = give_get_meta( $form_id, '_give_terms_option', true ); |
@@ -1676,7 +1676,7 @@ discard block |
||
1676 | 1676 | * @param int $form_id The form ID. |
1677 | 1677 | * @param array $args An array of form arguments. |
1678 | 1678 | * |
1679 | - * @return mixed |
|
1679 | + * @return boolean |
|
1680 | 1680 | */ |
1681 | 1681 | function give_show_goal_progress( $form_id, $args = array() ) { |
1682 | 1682 | |
@@ -1703,7 +1703,7 @@ discard block |
||
1703 | 1703 | * @param int $total Total amount based on shortcode parameter. |
1704 | 1704 | * @param int $total_goal Total Goal amount passed by Admin. |
1705 | 1705 | * |
1706 | - * @return mixed |
|
1706 | + * @return boolean |
|
1707 | 1707 | */ |
1708 | 1708 | function give_show_goal_totals_progress( $total, $total_goal ) { |
1709 | 1709 | |
@@ -1727,7 +1727,7 @@ discard block |
||
1727 | 1727 | * |
1728 | 1728 | * @since 1.8 |
1729 | 1729 | * |
1730 | - * @param $form_id |
|
1730 | + * @param integer $form_id |
|
1731 | 1731 | * @param $args |
1732 | 1732 | * |
1733 | 1733 | * @return mixed|string |
@@ -1768,7 +1768,7 @@ discard block |
||
1768 | 1768 | * @param int $form_id The form ID. |
1769 | 1769 | * @param array $args An array of form arguments. |
1770 | 1770 | * |
1771 | - * @return void|bool |
|
1771 | + * @return false|null |
|
1772 | 1772 | */ |
1773 | 1773 | function give_form_content( $form_id, $args ) { |
1774 | 1774 | |
@@ -2058,7 +2058,7 @@ discard block |
||
2058 | 2058 | * |
2059 | 2059 | * @since 2.1 |
2060 | 2060 | * |
2061 | - * @return array |
|
2061 | + * @return string[] |
|
2062 | 2062 | */ |
2063 | 2063 | function add_class_for_form_grid( $class, $id, $args ) { |
2064 | 2064 | $class[] = 'give-form-grid-wrap'; |
@@ -2069,7 +2069,6 @@ discard block |
||
2069 | 2069 | /** |
2070 | 2070 | * Add hidden field to Form Grid page |
2071 | 2071 | * |
2072 | - * @param int $form_id The form ID. |
|
2073 | 2072 | * @param array $args An array of form arguments. |
2074 | 2073 | * @param Give_Donate_Form $form Form object. |
2075 | 2074 | * |
@@ -996,10 +996,10 @@ discard block |
||
996 | 996 | <?php echo( give_field_is_required( 'billing_country', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
997 | 997 | > |
998 | 998 | <?php |
999 | - foreach ( $countries as $country_code => $country ) { |
|
1000 | - echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
1001 | - } |
|
1002 | - ?> |
|
999 | + foreach ( $countries as $country_code => $country ) { |
|
1000 | + echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
1001 | + } |
|
1002 | + ?> |
|
1003 | 1003 | </select> |
1004 | 1004 | </p> |
1005 | 1005 | |
@@ -1071,7 +1071,7 @@ discard block |
||
1071 | 1071 | <label for="card_state" class="give-label"> |
1072 | 1072 | <span class="state-label-text"><?php echo $label; ?></span> |
1073 | 1073 | <?php if ( give_field_is_required( 'card_state', $form_id ) ) : |
1074 | - ?> |
|
1074 | + ?> |
|
1075 | 1075 | <span class="give-required-indicator <?php echo( array_key_exists( $selected_country, $states_not_required_country_list ) ? 'give-hidden' : '' ) ?> ">*</span> |
1076 | 1076 | <?php endif; ?> |
1077 | 1077 | <span class="give-tooltip give-icon give-icon-question" |
@@ -1079,7 +1079,7 @@ discard block |
||
1079 | 1079 | </label> |
1080 | 1080 | <?php |
1081 | 1081 | |
1082 | - if ( ! empty( $states ) ) : ?> |
|
1082 | + if ( ! empty( $states ) ) : ?> |
|
1083 | 1083 | <select |
1084 | 1084 | name="card_state" |
1085 | 1085 | autocomplete="address-level4" |
@@ -1087,10 +1087,10 @@ discard block |
||
1087 | 1087 | class="card_state give-select<?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required' : '' ); ?>" |
1088 | 1088 | <?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required aria-required="true" ' : '' ); ?>> |
1089 | 1089 | <?php |
1090 | - foreach ( $states as $state_code => $state ) { |
|
1091 | - echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
1092 | - } |
|
1093 | - ?> |
|
1090 | + foreach ( $states as $state_code => $state ) { |
|
1091 | + echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
1092 | + } |
|
1093 | + ?> |
|
1094 | 1094 | </select> |
1095 | 1095 | <?php else : ?> |
1096 | 1096 | <input type="text" size="6" name="card_state" id="card_state" class="card_state give-input" |
@@ -1292,8 +1292,8 @@ discard block |
||
1292 | 1292 | <a href="<?php echo remove_query_arg( 'login' ); ?>" class="give-checkout-register-cancel" |
1293 | 1293 | data-action="give_checkout_register"> |
1294 | 1294 | <?php if ( give_logged_in_only( $form_id ) ) { |
1295 | - _e( 'Register as a part of your donation »', 'give' ); |
|
1296 | - } else { |
|
1295 | + _e( 'Register as a part of your donation »', 'give' ); |
|
1296 | + } else { |
|
1297 | 1297 | _e( 'Register or donate as a guest »', 'give' ); |
1298 | 1298 | } ?> |
1299 | 1299 | </a> |
@@ -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 | |
@@ -23,35 +23,35 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return string Donation form. |
25 | 25 | */ |
26 | -function give_get_donation_form( $args = array() ) { |
|
26 | +function give_get_donation_form($args = array()) { |
|
27 | 27 | |
28 | 28 | global $post; |
29 | 29 | static $count = 1; |
30 | 30 | |
31 | - $form_id = is_object( $post ) ? $post->ID : 0; |
|
31 | + $form_id = is_object($post) ? $post->ID : 0; |
|
32 | 32 | |
33 | - if ( isset( $args['id'] ) ) { |
|
33 | + if (isset($args['id'])) { |
|
34 | 34 | $form_id = $args['id']; |
35 | 35 | } |
36 | 36 | |
37 | - $defaults = apply_filters( 'give_form_args_defaults', array( |
|
37 | + $defaults = apply_filters('give_form_args_defaults', array( |
|
38 | 38 | 'form_id' => $form_id, |
39 | - ) ); |
|
39 | + )); |
|
40 | 40 | |
41 | - $args = wp_parse_args( $args, $defaults ); |
|
41 | + $args = wp_parse_args($args, $defaults); |
|
42 | 42 | |
43 | - $form = new Give_Donate_Form( $args['form_id'] ); |
|
43 | + $form = new Give_Donate_Form($args['form_id']); |
|
44 | 44 | |
45 | 45 | // Bail out, if no form ID. |
46 | - if ( empty( $form->ID ) ) { |
|
46 | + if (empty($form->ID)) { |
|
47 | 47 | return false; |
48 | 48 | } |
49 | 49 | |
50 | 50 | $args['id_prefix'] = "{$form_id}-{$count}"; |
51 | - $payment_mode = give_get_chosen_gateway( $form->ID ); |
|
51 | + $payment_mode = give_get_chosen_gateway($form->ID); |
|
52 | 52 | |
53 | 53 | $form_action = add_query_arg( |
54 | - apply_filters( 'give_form_action_args', array( |
|
54 | + apply_filters('give_form_action_args', array( |
|
55 | 55 | 'payment-mode' => $payment_mode, |
56 | 56 | ) |
57 | 57 | ), |
@@ -60,17 +60,17 @@ discard block |
||
60 | 60 | |
61 | 61 | // Sanity Check: Donation form not published or user doesn't have permission to view drafts. |
62 | 62 | if ( |
63 | - ( 'publish' !== $form->post_status && ! current_user_can( 'edit_give_forms', $form->ID ) ) |
|
64 | - || ( 'trash' === $form->post_status ) |
|
63 | + ('publish' !== $form->post_status && ! current_user_can('edit_give_forms', $form->ID)) |
|
64 | + || ('trash' === $form->post_status) |
|
65 | 65 | ) { |
66 | 66 | return false; |
67 | 67 | } |
68 | 68 | |
69 | 69 | // Get the form wrap CSS classes. |
70 | - $form_wrap_classes = $form->get_form_wrap_classes( $args ); |
|
70 | + $form_wrap_classes = $form->get_form_wrap_classes($args); |
|
71 | 71 | |
72 | 72 | // Get the <form> tag wrap CSS classes. |
73 | - $form_classes = $form->get_form_classes( $args ); |
|
73 | + $form_classes = $form->get_form_classes($args); |
|
74 | 74 | |
75 | 75 | ob_start(); |
76 | 76 | |
@@ -82,21 +82,21 @@ discard block |
||
82 | 82 | * @param int $form_id The form ID. |
83 | 83 | * @param array $args An array of form arguments. |
84 | 84 | */ |
85 | - do_action( 'give_pre_form_output', $form->ID, $args, $form ); |
|
85 | + do_action('give_pre_form_output', $form->ID, $args, $form); |
|
86 | 86 | |
87 | 87 | ?> |
88 | 88 | <div id="give-form-<?php echo $form->ID; ?>-wrap" class="<?php echo $form_wrap_classes; ?>"> |
89 | 89 | <?php |
90 | - if ( $form->is_close_donation_form() ) { |
|
90 | + if ($form->is_close_donation_form()) { |
|
91 | 91 | |
92 | - $form_title = ! is_singular( 'give_forms' ) ? apply_filters( 'give_form_title', '<h2 class="give-form-title">' . get_the_title( $form_id ) . '</h2>' ) : ''; |
|
92 | + $form_title = ! is_singular('give_forms') ? apply_filters('give_form_title', '<h2 class="give-form-title">'.get_the_title($form_id).'</h2>') : ''; |
|
93 | 93 | |
94 | 94 | // Get Goal thank you message. |
95 | - $goal_achieved_message = get_post_meta( $form->ID, '_give_form_goal_achieved_message', true ); |
|
96 | - $goal_achieved_message = ! empty( $goal_achieved_message ) ? $form_title . apply_filters( 'the_content', $goal_achieved_message ) : ''; |
|
95 | + $goal_achieved_message = get_post_meta($form->ID, '_give_form_goal_achieved_message', true); |
|
96 | + $goal_achieved_message = ! empty($goal_achieved_message) ? $form_title.apply_filters('the_content', $goal_achieved_message) : ''; |
|
97 | 97 | |
98 | 98 | // Print thank you message. |
99 | - echo apply_filters( 'give_goal_closed_output', $goal_achieved_message, $form->ID, $form ); |
|
99 | + echo apply_filters('give_goal_closed_output', $goal_achieved_message, $form->ID, $form); |
|
100 | 100 | |
101 | 101 | } else { |
102 | 102 | /** |
@@ -104,13 +104,13 @@ discard block |
||
104 | 104 | * 1. if show_title params set to true |
105 | 105 | * 2. if admin set form display_style to button |
106 | 106 | */ |
107 | - $form_title = apply_filters( 'give_form_title', '<h2 class="give-form-title">' . get_the_title( $form_id ) . '</h2>' ); |
|
107 | + $form_title = apply_filters('give_form_title', '<h2 class="give-form-title">'.get_the_title($form_id).'</h2>'); |
|
108 | 108 | if ( |
109 | 109 | ( |
110 | - ( isset( $args['show_title'] ) && $args['show_title'] == true ) |
|
111 | - || ( 'button' === get_post_meta( $form_id, '_give_payment_display', true ) ) |
|
110 | + (isset($args['show_title']) && $args['show_title'] == true) |
|
111 | + || ('button' === get_post_meta($form_id, '_give_payment_display', true)) |
|
112 | 112 | ) |
113 | - && ! doing_action( 'give_single_form_summary' ) |
|
113 | + && ! doing_action('give_single_form_summary') |
|
114 | 114 | ) { |
115 | 115 | echo $form_title; |
116 | 116 | } |
@@ -124,13 +124,13 @@ discard block |
||
124 | 124 | * @param array $args An array of form arguments. |
125 | 125 | * @param Give_Donate_Form $form Form object. |
126 | 126 | */ |
127 | - do_action( 'give_pre_form', $form->ID, $args, $form ); |
|
127 | + do_action('give_pre_form', $form->ID, $args, $form); |
|
128 | 128 | |
129 | 129 | // Set form html tags. |
130 | 130 | $form_html_tags = array( |
131 | 131 | 'id' => "give-form-{$args['id_prefix']}", |
132 | 132 | 'class' => $form_classes, |
133 | - 'action' => esc_url_raw( $form_action ), |
|
133 | + 'action' => esc_url_raw($form_action), |
|
134 | 134 | 'data-id' => $args['id_prefix'], |
135 | 135 | ); |
136 | 136 | |
@@ -142,9 +142,9 @@ discard block |
||
142 | 142 | * @param array $form_html_tags Array of form html tags. |
143 | 143 | * @param Give_Donate_Form $form Form object. |
144 | 144 | */ |
145 | - $form_html_tags = apply_filters( 'give_form_html_tags', (array) $form_html_tags, $form ); |
|
145 | + $form_html_tags = apply_filters('give_form_html_tags', (array) $form_html_tags, $form); |
|
146 | 146 | ?> |
147 | - <form <?php echo give_get_attribute_str( $form_html_tags ); ?> method="post"> |
|
147 | + <form <?php echo give_get_attribute_str($form_html_tags); ?> method="post"> |
|
148 | 148 | <!-- The following field is for robots only, invisible to humans: --> |
149 | 149 | <span class="give-hidden" style="display: none !important;"> |
150 | 150 | <label for="give-form-honeypot-<?php echo $form_id; ?>"></label> |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | * @param array $args An array of form arguments. |
163 | 163 | * @param Give_Donate_Form $form Form object. |
164 | 164 | */ |
165 | - do_action( 'give_donation_form_top', $form->ID, $args, $form ); |
|
165 | + do_action('give_donation_form_top', $form->ID, $args, $form); |
|
166 | 166 | |
167 | 167 | /** |
168 | 168 | * Fires while outputting donation form, for payment gateway fields. |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * @param array $args An array of form arguments. |
174 | 174 | * @param Give_Donate_Form $form Form object. |
175 | 175 | */ |
176 | - do_action( 'give_payment_mode_select', $form->ID, $args, $form ); |
|
176 | + do_action('give_payment_mode_select', $form->ID, $args, $form); |
|
177 | 177 | |
178 | 178 | /** |
179 | 179 | * Fires while outputting donation form, after all other fields. |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | * @param array $args An array of form arguments. |
185 | 185 | * @param Give_Donate_Form $form Form object. |
186 | 186 | */ |
187 | - do_action( 'give_donation_form_bottom', $form->ID, $args, $form ); |
|
187 | + do_action('give_donation_form_bottom', $form->ID, $args, $form); |
|
188 | 188 | |
189 | 189 | ?> |
190 | 190 | </form> |
@@ -199,12 +199,12 @@ discard block |
||
199 | 199 | * @param array $args An array of form arguments. |
200 | 200 | * @param Give_Donate_Form $form Form object. |
201 | 201 | */ |
202 | - do_action( 'give_post_form', $form->ID, $args, $form ); |
|
202 | + do_action('give_post_form', $form->ID, $args, $form); |
|
203 | 203 | |
204 | 204 | } |
205 | 205 | ?> |
206 | 206 | |
207 | - </div><!--end #give-form-<?php echo absint( $form->ID ); ?>--> |
|
207 | + </div><!--end #give-form-<?php echo absint($form->ID); ?>--> |
|
208 | 208 | <?php |
209 | 209 | |
210 | 210 | /** |
@@ -215,12 +215,12 @@ discard block |
||
215 | 215 | * @param int $form_id The form ID. |
216 | 216 | * @param array $args An array of form arguments. |
217 | 217 | */ |
218 | - do_action( 'give_post_form_output', $form->ID, $args ); |
|
218 | + do_action('give_post_form_output', $form->ID, $args); |
|
219 | 219 | |
220 | 220 | $final_output = ob_get_clean(); |
221 | - $count ++; |
|
221 | + $count++; |
|
222 | 222 | |
223 | - echo apply_filters( 'give_donate_form', $final_output, $args ); |
|
223 | + echo apply_filters('give_donate_form', $final_output, $args); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | /** |
@@ -237,11 +237,11 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return string |
239 | 239 | */ |
240 | -function give_show_purchase_form( $form_id, $args ) { |
|
240 | +function give_show_purchase_form($form_id, $args) { |
|
241 | 241 | |
242 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
242 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
243 | 243 | |
244 | - if ( ! isset( $form_id ) && isset( $_POST['give_form_id'] ) ) { |
|
244 | + if ( ! isset($form_id) && isset($_POST['give_form_id'])) { |
|
245 | 245 | $form_id = $_POST['give_form_id']; |
246 | 246 | } |
247 | 247 | |
@@ -250,33 +250,33 @@ discard block |
||
250 | 250 | * |
251 | 251 | * @since 1.7 |
252 | 252 | */ |
253 | - do_action( 'give_payment_fields_top', $form_id ); |
|
253 | + do_action('give_payment_fields_top', $form_id); |
|
254 | 254 | |
255 | - if ( give_can_checkout() && isset( $form_id ) ) { |
|
255 | + if (give_can_checkout() && isset($form_id)) { |
|
256 | 256 | |
257 | 257 | /** |
258 | 258 | * Fires while displaying donation form, before registration login. |
259 | 259 | * |
260 | 260 | * @since 1.7 |
261 | 261 | */ |
262 | - do_action( 'give_donation_form_before_register_login', $form_id, $args ); |
|
262 | + do_action('give_donation_form_before_register_login', $form_id, $args); |
|
263 | 263 | |
264 | 264 | /** |
265 | 265 | * Fire when register/login form fields render. |
266 | 266 | * |
267 | 267 | * @since 1.7 |
268 | 268 | */ |
269 | - do_action( 'give_donation_form_register_login_fields', $form_id, $args ); |
|
269 | + do_action('give_donation_form_register_login_fields', $form_id, $args); |
|
270 | 270 | |
271 | 271 | /** |
272 | 272 | * Fire when credit card form fields render. |
273 | 273 | * |
274 | 274 | * @since 1.7 |
275 | 275 | */ |
276 | - do_action( 'give_donation_form_before_cc_form', $form_id, $args ); |
|
276 | + do_action('give_donation_form_before_cc_form', $form_id, $args); |
|
277 | 277 | |
278 | 278 | // Load the credit card form and allow gateways to load their own if they wish. |
279 | - if ( has_action( 'give_' . $payment_mode . '_cc_form' ) ) { |
|
279 | + if (has_action('give_'.$payment_mode.'_cc_form')) { |
|
280 | 280 | /** |
281 | 281 | * Fires while displaying donation form, credit card form fields for a given gateway. |
282 | 282 | * |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | * |
285 | 285 | * @param int $form_id The form ID. |
286 | 286 | */ |
287 | - do_action( "give_{$payment_mode}_cc_form", $form_id, $args ); |
|
287 | + do_action("give_{$payment_mode}_cc_form", $form_id, $args); |
|
288 | 288 | } else { |
289 | 289 | /** |
290 | 290 | * Fires while displaying donation form, credit card form fields. |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | * |
294 | 294 | * @param int $form_id The form ID. |
295 | 295 | */ |
296 | - do_action( 'give_cc_form', $form_id, $args ); |
|
296 | + do_action('give_cc_form', $form_id, $args); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | /** |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * |
302 | 302 | * @since 1.7 |
303 | 303 | */ |
304 | - do_action( 'give_donation_form_after_cc_form', $form_id, $args ); |
|
304 | + do_action('give_donation_form_after_cc_form', $form_id, $args); |
|
305 | 305 | |
306 | 306 | } else { |
307 | 307 | /** |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * |
310 | 310 | * @since 1.7 |
311 | 311 | */ |
312 | - do_action( 'give_donation_form_no_access', $form_id ); |
|
312 | + do_action('give_donation_form_no_access', $form_id); |
|
313 | 313 | |
314 | 314 | } |
315 | 315 | |
@@ -318,10 +318,10 @@ discard block |
||
318 | 318 | * |
319 | 319 | * @since 1.7 |
320 | 320 | */ |
321 | - do_action( 'give_payment_fields_bottom', $form_id, $args ); |
|
321 | + do_action('give_payment_fields_bottom', $form_id, $args); |
|
322 | 322 | } |
323 | 323 | |
324 | -add_action( 'give_donation_form', 'give_show_purchase_form', 10, 2 ); |
|
324 | +add_action('give_donation_form', 'give_show_purchase_form', 10, 2); |
|
325 | 325 | |
326 | 326 | /** |
327 | 327 | * Give Show Login/Register Form Fields. |
@@ -332,11 +332,11 @@ discard block |
||
332 | 332 | * |
333 | 333 | * @return void |
334 | 334 | */ |
335 | -function give_show_register_login_fields( $form_id ) { |
|
335 | +function give_show_register_login_fields($form_id) { |
|
336 | 336 | |
337 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
337 | + $show_register_form = give_show_login_register_option($form_id); |
|
338 | 338 | |
339 | - if ( ( $show_register_form === 'registration' || ( $show_register_form === 'both' && ! isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : |
|
339 | + if (($show_register_form === 'registration' || ($show_register_form === 'both' && ! isset($_GET['login']))) && ! is_user_logged_in()) : |
|
340 | 340 | ?> |
341 | 341 | <div id="give-checkout-login-register-<?php echo $form_id; ?>"> |
342 | 342 | <?php |
@@ -345,11 +345,11 @@ discard block |
||
345 | 345 | * |
346 | 346 | * @since 1.7 |
347 | 347 | */ |
348 | - do_action( 'give_donation_form_register_fields', $form_id ); |
|
348 | + do_action('give_donation_form_register_fields', $form_id); |
|
349 | 349 | ?> |
350 | 350 | </div> |
351 | 351 | <?php |
352 | - elseif ( ( $show_register_form === 'login' || ( $show_register_form === 'both' && isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : |
|
352 | + elseif (($show_register_form === 'login' || ($show_register_form === 'both' && isset($_GET['login']))) && ! is_user_logged_in()) : |
|
353 | 353 | ?> |
354 | 354 | <div id="give-checkout-login-register-<?php echo $form_id; ?>"> |
355 | 355 | <?php |
@@ -358,23 +358,23 @@ discard block |
||
358 | 358 | * |
359 | 359 | * @since 1.7 |
360 | 360 | */ |
361 | - do_action( 'give_donation_form_login_fields', $form_id ); |
|
361 | + do_action('give_donation_form_login_fields', $form_id); |
|
362 | 362 | ?> |
363 | 363 | </div> |
364 | 364 | <?php |
365 | 365 | endif; |
366 | 366 | |
367 | - if ( ( ! isset( $_GET['login'] ) && is_user_logged_in() ) || ! isset( $show_register_form ) || 'none' === $show_register_form || 'login' === $show_register_form ) { |
|
367 | + if (( ! isset($_GET['login']) && is_user_logged_in()) || ! isset($show_register_form) || 'none' === $show_register_form || 'login' === $show_register_form) { |
|
368 | 368 | /** |
369 | 369 | * Fire when user info render. |
370 | 370 | * |
371 | 371 | * @since 1.7 |
372 | 372 | */ |
373 | - do_action( 'give_donation_form_after_user_info', $form_id ); |
|
373 | + do_action('give_donation_form_after_user_info', $form_id); |
|
374 | 374 | } |
375 | 375 | } |
376 | 376 | |
377 | -add_action( 'give_donation_form_register_login_fields', 'give_show_register_login_fields' ); |
|
377 | +add_action('give_donation_form_register_login_fields', 'give_show_register_login_fields'); |
|
378 | 378 | |
379 | 379 | /** |
380 | 380 | * Donation Amount Field. |
@@ -389,16 +389,16 @@ discard block |
||
389 | 389 | * |
390 | 390 | * @return void |
391 | 391 | */ |
392 | -function give_output_donation_amount_top( $form_id = 0, $args = array() ) { |
|
392 | +function give_output_donation_amount_top($form_id = 0, $args = array()) { |
|
393 | 393 | |
394 | 394 | $give_options = give_get_settings(); |
395 | - $variable_pricing = give_has_variable_prices( $form_id ); |
|
396 | - $allow_custom_amount = give_get_meta( $form_id, '_give_custom_amount', true ); |
|
397 | - $currency_position = isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before'; |
|
398 | - $symbol = give_currency_symbol( give_get_currency( $form_id, $args ) ); |
|
399 | - $currency_output = '<span class="give-currency-symbol give-currency-position-' . $currency_position . '">' . $symbol . '</span>'; |
|
400 | - $default_amount = give_format_amount( give_get_default_form_amount( $form_id ), array( 'sanitize' => false, 'currency' => give_get_currency( $form_id ) ) ); |
|
401 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
395 | + $variable_pricing = give_has_variable_prices($form_id); |
|
396 | + $allow_custom_amount = give_get_meta($form_id, '_give_custom_amount', true); |
|
397 | + $currency_position = isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before'; |
|
398 | + $symbol = give_currency_symbol(give_get_currency($form_id, $args)); |
|
399 | + $currency_output = '<span class="give-currency-symbol give-currency-position-'.$currency_position.'">'.$symbol.'</span>'; |
|
400 | + $default_amount = give_format_amount(give_get_default_form_amount($form_id), array('sanitize' => false, 'currency' => give_get_currency($form_id))); |
|
401 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
402 | 402 | |
403 | 403 | /** |
404 | 404 | * Fires while displaying donation form, before donation level fields. |
@@ -408,20 +408,20 @@ discard block |
||
408 | 408 | * @param int $form_id The form ID. |
409 | 409 | * @param array $args An array of form arguments. |
410 | 410 | */ |
411 | - do_action( 'give_before_donation_levels', $form_id, $args ); |
|
411 | + do_action('give_before_donation_levels', $form_id, $args); |
|
412 | 412 | |
413 | 413 | //Set Price, No Custom Amount Allowed means hidden price field |
414 | - if ( ! give_is_setting_enabled( $allow_custom_amount ) ) { |
|
414 | + if ( ! give_is_setting_enabled($allow_custom_amount)) { |
|
415 | 415 | ?> |
416 | - <label class="give-hidden" for="give-amount-hidden"><?php esc_html_e( 'Donation Amount:', 'give' ); ?></label> |
|
416 | + <label class="give-hidden" for="give-amount-hidden"><?php esc_html_e('Donation Amount:', 'give'); ?></label> |
|
417 | 417 | <input id="give-amount" class="give-amount-hidden" type="hidden" name="give-amount" |
418 | 418 | value="<?php echo $default_amount; ?>" required aria-required="true"/> |
419 | 419 | <div class="set-price give-donation-amount form-row-wide"> |
420 | - <?php if ( $currency_position == 'before' ) { |
|
420 | + <?php if ($currency_position == 'before') { |
|
421 | 421 | echo $currency_output; |
422 | 422 | } ?> |
423 | 423 | <span id="give-amount-text" class="give-text-input give-amount-top"><?php echo $default_amount; ?></span> |
424 | - <?php if ( $currency_position == 'after' ) { |
|
424 | + <?php if ($currency_position == 'after') { |
|
425 | 425 | echo $currency_output; |
426 | 426 | } ?> |
427 | 427 | </div> |
@@ -431,13 +431,13 @@ discard block |
||
431 | 431 | ?> |
432 | 432 | <div class="give-total-wrap"> |
433 | 433 | <div class="give-donation-amount form-row-wide"> |
434 | - <?php if ( $currency_position == 'before' ) { |
|
434 | + <?php if ($currency_position == 'before') { |
|
435 | 435 | echo $currency_output; |
436 | 436 | } ?> |
437 | - <label class="give-hidden" for="give-amount"><?php esc_html_e( 'Donation Amount:', 'give' ); ?></label> |
|
437 | + <label class="give-hidden" for="give-amount"><?php esc_html_e('Donation Amount:', 'give'); ?></label> |
|
438 | 438 | <input class="give-text-input give-amount-top" id="give-amount" name="give-amount" type="tel" |
439 | 439 | placeholder="" value="<?php echo $default_amount; ?>" autocomplete="off"> |
440 | - <?php if ( $currency_position == 'after' ) { |
|
440 | + <?php if ($currency_position == 'after') { |
|
441 | 441 | echo $currency_output; |
442 | 442 | } ?> |
443 | 443 | </div> |
@@ -452,16 +452,16 @@ discard block |
||
452 | 452 | * @param int $form_id The form ID. |
453 | 453 | * @param array $args An array of form arguments. |
454 | 454 | */ |
455 | - do_action( 'give_after_donation_amount', $form_id, $args ); |
|
455 | + do_action('give_after_donation_amount', $form_id, $args); |
|
456 | 456 | |
457 | 457 | //Custom Amount Text |
458 | - if ( ! $variable_pricing && give_is_setting_enabled( $allow_custom_amount ) && ! empty( $custom_amount_text ) ) { ?> |
|
458 | + if ( ! $variable_pricing && give_is_setting_enabled($allow_custom_amount) && ! empty($custom_amount_text)) { ?> |
|
459 | 459 | <p class="give-custom-amount-text"><?php echo $custom_amount_text; ?></p> |
460 | 460 | <?php } |
461 | 461 | |
462 | 462 | //Output Variable Pricing Levels. |
463 | - if ( $variable_pricing ) { |
|
464 | - give_output_levels( $form_id ); |
|
463 | + if ($variable_pricing) { |
|
464 | + give_output_levels($form_id); |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | /** |
@@ -472,10 +472,10 @@ discard block |
||
472 | 472 | * @param int $form_id The form ID. |
473 | 473 | * @param array $args An array of form arguments. |
474 | 474 | */ |
475 | - do_action( 'give_after_donation_levels', $form_id, $args ); |
|
475 | + do_action('give_after_donation_levels', $form_id, $args); |
|
476 | 476 | } |
477 | 477 | |
478 | -add_action( 'give_donation_form_top', 'give_output_donation_amount_top', 10, 2 ); |
|
478 | +add_action('give_donation_form_top', 'give_output_donation_amount_top', 10, 2); |
|
479 | 479 | |
480 | 480 | /** |
481 | 481 | * Outputs the Donation Levels in various formats such as dropdown, radios, and buttons. |
@@ -486,33 +486,33 @@ discard block |
||
486 | 486 | * |
487 | 487 | * @return string Donation levels. |
488 | 488 | */ |
489 | -function give_output_levels( $form_id ) { |
|
489 | +function give_output_levels($form_id) { |
|
490 | 490 | |
491 | 491 | //Get variable pricing. |
492 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
493 | - $display_style = give_get_meta( $form_id, '_give_display_style', true ); |
|
494 | - $custom_amount = give_get_meta( $form_id, '_give_custom_amount', true ); |
|
495 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
492 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
493 | + $display_style = give_get_meta($form_id, '_give_display_style', true); |
|
494 | + $custom_amount = give_get_meta($form_id, '_give_custom_amount', true); |
|
495 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
496 | 496 | |
497 | - if ( empty( $custom_amount_text ) ) { |
|
498 | - $custom_amount_text = esc_html__( 'Give a Custom Amount', 'give' ); |
|
497 | + if (empty($custom_amount_text)) { |
|
498 | + $custom_amount_text = esc_html__('Give a Custom Amount', 'give'); |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | $output = ''; |
502 | 502 | |
503 | - switch ( $display_style ) { |
|
503 | + switch ($display_style) { |
|
504 | 504 | case 'buttons': |
505 | 505 | |
506 | 506 | $output .= '<ul id="give-donation-level-button-wrap" class="give-donation-levels-wrap give-list-inline">'; |
507 | 507 | |
508 | - foreach ( $prices as $price ) { |
|
509 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) ), $form_id, $price ); |
|
510 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-donation-level-btn give-btn give-btn-level-' . $price['_give_id']['level_id'] . ' ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'give-default-level' : '' ), $form_id, $price ); |
|
508 | + foreach ($prices as $price) { |
|
509 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false))), $form_id, $price); |
|
510 | + $level_classes = apply_filters('give_form_level_classes', 'give-donation-level-btn give-btn give-btn-level-'.$price['_give_id']['level_id'].' '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'give-default-level' : ''), $form_id, $price); |
|
511 | 511 | |
512 | - $formatted_amount = give_format_amount( $price['_give_amount'], array( |
|
512 | + $formatted_amount = give_format_amount($price['_give_amount'], array( |
|
513 | 513 | 'sanitize' => false, |
514 | - 'currency' => give_get_currency( $form_id ), |
|
515 | - ) ); |
|
514 | + 'currency' => give_get_currency($form_id), |
|
515 | + )); |
|
516 | 516 | |
517 | 517 | $output .= sprintf( |
518 | 518 | '<li><button type="button" data-price-id="%1$s" class="%2$s" value="%3$s">%4$s</button></li>', |
@@ -525,8 +525,8 @@ discard block |
||
525 | 525 | |
526 | 526 | //Custom Amount. |
527 | 527 | if ( |
528 | - give_is_setting_enabled( $custom_amount ) |
|
529 | - && ! empty( $custom_amount_text ) |
|
528 | + give_is_setting_enabled($custom_amount) |
|
529 | + && ! empty($custom_amount_text) |
|
530 | 530 | ) { |
531 | 531 | |
532 | 532 | $output .= sprintf( |
@@ -543,29 +543,29 @@ discard block |
||
543 | 543 | |
544 | 544 | $output .= '<ul id="give-donation-level-radio-list" class="give-donation-levels-wrap">'; |
545 | 545 | |
546 | - foreach ( $prices as $price ) { |
|
547 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) ), $form_id, $price ); |
|
548 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-radio-input give-radio-input-level give-radio-level-' . $price['_give_id']['level_id'] . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? ' give-default-level' : '' ), $form_id, $price ); |
|
546 | + foreach ($prices as $price) { |
|
547 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false))), $form_id, $price); |
|
548 | + $level_classes = apply_filters('give_form_level_classes', 'give-radio-input give-radio-input-level give-radio-level-'.$price['_give_id']['level_id'].((isset($price['_give_default']) && $price['_give_default'] === 'default') ? ' give-default-level' : ''), $form_id, $price); |
|
549 | 549 | |
550 | - $formatted_amount = give_format_amount( $price['_give_amount'], array( |
|
550 | + $formatted_amount = give_format_amount($price['_give_amount'], array( |
|
551 | 551 | 'sanitize' => false, |
552 | - 'currency' => give_get_currency( $form_id ), |
|
553 | - ) ); |
|
552 | + 'currency' => give_get_currency($form_id), |
|
553 | + )); |
|
554 | 554 | |
555 | 555 | $output .= sprintf( |
556 | 556 | '<li><input type="radio" data-price-id="%1$s" class="%2$s" value="%3$s" name="give-radio-donation-level" id="give-radio-level-%1$s" %4$s ><label for="give-radio-level-%1$s">%5$s</label></li>', |
557 | 557 | $price['_give_id']['level_id'], |
558 | 558 | $level_classes, |
559 | 559 | $formatted_amount, |
560 | - ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'checked="checked"' : '' ), |
|
560 | + ((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'checked="checked"' : ''), |
|
561 | 561 | $level_text |
562 | 562 | ); |
563 | 563 | } |
564 | 564 | |
565 | 565 | //Custom Amount. |
566 | 566 | if ( |
567 | - give_is_setting_enabled( $custom_amount ) |
|
568 | - && ! empty( $custom_amount_text ) |
|
567 | + give_is_setting_enabled($custom_amount) |
|
568 | + && ! empty($custom_amount_text) |
|
569 | 569 | ) { |
570 | 570 | $output .= sprintf( |
571 | 571 | '<li><input type="radio" data-price-id="custom" class="give-radio-input give-radio-input-level give-radio-level-custom" name="give-radio-donation-level" id="give-radio-level-custom" value="custom"><label for="give-radio-level-custom">%1$s</label></li>', |
@@ -579,31 +579,31 @@ discard block |
||
579 | 579 | |
580 | 580 | case 'dropdown': |
581 | 581 | |
582 | - $output .= '<label for="give-donation-level-select-' . $form_id . '" class="give-hidden">' . esc_html__( 'Choose Your Donation Amount', 'give' ) . ':</label>'; |
|
583 | - $output .= '<select id="give-donation-level-select-' . $form_id . '" class="give-select give-select-level give-donation-levels-wrap">'; |
|
582 | + $output .= '<label for="give-donation-level-select-'.$form_id.'" class="give-hidden">'.esc_html__('Choose Your Donation Amount', 'give').':</label>'; |
|
583 | + $output .= '<select id="give-donation-level-select-'.$form_id.'" class="give-select give-select-level give-donation-levels-wrap">'; |
|
584 | 584 | |
585 | 585 | //first loop through prices. |
586 | - foreach ( $prices as $price ) { |
|
587 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) ), $form_id, $price ); |
|
588 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-donation-level-' . $price['_give_id']['level_id'] . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? ' give-default-level' : '' ), $form_id, $price ); |
|
586 | + foreach ($prices as $price) { |
|
587 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false))), $form_id, $price); |
|
588 | + $level_classes = apply_filters('give_form_level_classes', 'give-donation-level-'.$price['_give_id']['level_id'].((isset($price['_give_default']) && $price['_give_default'] === 'default') ? ' give-default-level' : ''), $form_id, $price); |
|
589 | 589 | |
590 | - $formatted_amount = give_format_amount( $price['_give_amount'], array( |
|
590 | + $formatted_amount = give_format_amount($price['_give_amount'], array( |
|
591 | 591 | 'sanitize' => false, |
592 | - 'currency' => give_get_currency( $form_id ), |
|
593 | - ) ); |
|
592 | + 'currency' => give_get_currency($form_id), |
|
593 | + )); |
|
594 | 594 | |
595 | 595 | $output .= sprintf( |
596 | 596 | '<option data-price-id="%1$s" class="%2$s" value="%3$s" %4$s >%5$s</option>', |
597 | 597 | $price['_give_id']['level_id'], |
598 | 598 | $level_classes, |
599 | 599 | $formatted_amount, |
600 | - ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'selected="selected"' : '' ), |
|
600 | + ((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'selected="selected"' : ''), |
|
601 | 601 | $level_text |
602 | 602 | ); |
603 | 603 | } |
604 | 604 | |
605 | 605 | //Custom Amount. |
606 | - if ( give_is_setting_enabled( $custom_amount ) && ! empty( $custom_amount_text ) ) { |
|
606 | + if (give_is_setting_enabled($custom_amount) && ! empty($custom_amount_text)) { |
|
607 | 607 | $output .= sprintf( |
608 | 608 | '<option data-price-id="custom" class="give-donation-level-custom" value="custom">%1$s</option>', |
609 | 609 | $custom_amount_text |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | break; |
616 | 616 | } |
617 | 617 | |
618 | - echo apply_filters( 'give_form_level_output', $output, $form_id ); |
|
618 | + echo apply_filters('give_form_level_output', $output, $form_id); |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | /** |
@@ -630,27 +630,27 @@ discard block |
||
630 | 630 | * |
631 | 631 | * @return string Checkout button. |
632 | 632 | */ |
633 | -function give_display_checkout_button( $form_id, $args ) { |
|
633 | +function give_display_checkout_button($form_id, $args) { |
|
634 | 634 | |
635 | - $display_option = ( isset( $args['display_style'] ) && ! empty( $args['display_style'] ) ) |
|
635 | + $display_option = (isset($args['display_style']) && ! empty($args['display_style'])) |
|
636 | 636 | ? $args['display_style'] |
637 | - : give_get_meta( $form_id, '_give_payment_display', true ); |
|
637 | + : give_get_meta($form_id, '_give_payment_display', true); |
|
638 | 638 | |
639 | - if ( 'button' === $display_option ) { |
|
639 | + if ('button' === $display_option) { |
|
640 | 640 | $display_option = 'modal'; |
641 | - } elseif ( $display_option === 'onpage' ) { |
|
641 | + } elseif ($display_option === 'onpage') { |
|
642 | 642 | return ''; |
643 | 643 | } |
644 | 644 | |
645 | - $display_label_field = give_get_meta( $form_id, '_give_reveal_label', true ); |
|
646 | - $display_label = ! empty( $args['continue_button_title'] ) ? $args['continue_button_title'] : ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) ); |
|
645 | + $display_label_field = give_get_meta($form_id, '_give_reveal_label', true); |
|
646 | + $display_label = ! empty($args['continue_button_title']) ? $args['continue_button_title'] : ( ! empty($display_label_field) ? $display_label_field : esc_html__('Donate Now', 'give')); |
|
647 | 647 | |
648 | - $output = '<button type="button" class="give-btn give-btn-' . $display_option . '">' . $display_label . '</button>'; |
|
648 | + $output = '<button type="button" class="give-btn give-btn-'.$display_option.'">'.$display_label.'</button>'; |
|
649 | 649 | |
650 | - echo apply_filters( 'give_display_checkout_button', $output ); |
|
650 | + echo apply_filters('give_display_checkout_button', $output); |
|
651 | 651 | } |
652 | 652 | |
653 | -add_action( 'give_after_donation_levels', 'give_display_checkout_button', 10, 2 ); |
|
653 | +add_action('give_after_donation_levels', 'give_display_checkout_button', 10, 2); |
|
654 | 654 | |
655 | 655 | /** |
656 | 656 | * Shows the User Info fields in the Personal Info box, more fields can be added via the hooks provided. |
@@ -663,79 +663,79 @@ discard block |
||
663 | 663 | * |
664 | 664 | * @return void |
665 | 665 | */ |
666 | -function give_user_info_fields( $form_id ) { |
|
666 | +function give_user_info_fields($form_id) { |
|
667 | 667 | // Get user info. |
668 | - $give_user_info = _give_get_prefill_form_field_values( $form_id ); |
|
668 | + $give_user_info = _give_get_prefill_form_field_values($form_id); |
|
669 | 669 | |
670 | 670 | /** |
671 | 671 | * Fire before user personal information fields |
672 | 672 | * |
673 | 673 | * @since 1.7 |
674 | 674 | */ |
675 | - do_action( 'give_donation_form_before_personal_info', $form_id ); |
|
675 | + do_action('give_donation_form_before_personal_info', $form_id); |
|
676 | 676 | ?> |
677 | 677 | <fieldset id="give_checkout_user_info"> |
678 | - <legend><?php echo apply_filters( 'give_checkout_personal_info_text', __( 'Personal Info', 'give' ) ); ?></legend> |
|
678 | + <legend><?php echo apply_filters('give_checkout_personal_info_text', __('Personal Info', 'give')); ?></legend> |
|
679 | 679 | <p id="give-first-name-wrap" class="form-row form-row-first form-row-responsive"> |
680 | 680 | <label class="give-label" for="give-first"> |
681 | - <?php _e( 'First Name', 'give' ); ?> |
|
682 | - <?php if ( give_field_is_required( 'give_first', $form_id ) ) : ?> |
|
681 | + <?php _e('First Name', 'give'); ?> |
|
682 | + <?php if (give_field_is_required('give_first', $form_id)) : ?> |
|
683 | 683 | <span class="give-required-indicator">*</span> |
684 | 684 | <?php endif ?> |
685 | - <?php echo Give()->tooltips->render_help( __( 'We will use this to personalize your account experience.', 'give' ) ); ?> |
|
685 | + <?php echo Give()->tooltips->render_help(__('We will use this to personalize your account experience.', 'give')); ?> |
|
686 | 686 | </label> |
687 | 687 | <input |
688 | 688 | class="give-input required" |
689 | 689 | type="text" |
690 | 690 | name="give_first" |
691 | 691 | autocomplete="given-name" |
692 | - placeholder="<?php _e( 'First Name', 'give' ); ?>" |
|
692 | + placeholder="<?php _e('First Name', 'give'); ?>" |
|
693 | 693 | id="give-first" |
694 | - value="<?php echo isset( $give_user_info['give_first'] ) ? $give_user_info['give_first'] : ''; ?>" |
|
695 | - <?php echo( give_field_is_required( 'give_first', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
694 | + value="<?php echo isset($give_user_info['give_first']) ? $give_user_info['give_first'] : ''; ?>" |
|
695 | + <?php echo(give_field_is_required('give_first', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
696 | 696 | /> |
697 | 697 | </p> |
698 | 698 | |
699 | 699 | <p id="give-last-name-wrap" class="form-row form-row-last form-row-responsive"> |
700 | 700 | <label class="give-label" for="give-last"> |
701 | - <?php _e( 'Last Name', 'give' ); ?> |
|
702 | - <?php if ( give_field_is_required( 'give_last', $form_id ) ) : ?> |
|
701 | + <?php _e('Last Name', 'give'); ?> |
|
702 | + <?php if (give_field_is_required('give_last', $form_id)) : ?> |
|
703 | 703 | <span class="give-required-indicator">*</span> |
704 | 704 | <?php endif ?> |
705 | - <?php echo Give()->tooltips->render_help( __( 'We will use this as well to personalize your account experience.', 'give' ) ); ?> |
|
705 | + <?php echo Give()->tooltips->render_help(__('We will use this as well to personalize your account experience.', 'give')); ?> |
|
706 | 706 | </label> |
707 | 707 | |
708 | 708 | <input |
709 | - class="give-input<?php echo( give_field_is_required( 'give_last', $form_id ) ? ' required' : '' ); ?>" |
|
709 | + class="give-input<?php echo(give_field_is_required('give_last', $form_id) ? ' required' : ''); ?>" |
|
710 | 710 | type="text" |
711 | 711 | name="give_last" |
712 | 712 | autocomplete="family-name" |
713 | 713 | id="give-last" |
714 | - placeholder="<?php _e( 'Last Name', 'give' ); ?>" |
|
715 | - value="<?php echo isset( $give_user_info['give_last'] ) ? $give_user_info['give_last'] : ''; ?>" |
|
716 | - <?php echo( give_field_is_required( 'give_last', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
714 | + placeholder="<?php _e('Last Name', 'give'); ?>" |
|
715 | + value="<?php echo isset($give_user_info['give_last']) ? $give_user_info['give_last'] : ''; ?>" |
|
716 | + <?php echo(give_field_is_required('give_last', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
717 | 717 | /> |
718 | 718 | </p> |
719 | 719 | |
720 | - <?php if ( give_is_company_field_enabled( $form_id ) ) : ?> |
|
721 | - <?php $give_company = give_field_is_required( 'give_company_name', $form_id ); ?> |
|
720 | + <?php if (give_is_company_field_enabled($form_id)) : ?> |
|
721 | + <?php $give_company = give_field_is_required('give_company_name', $form_id); ?> |
|
722 | 722 | <p id="give-company-wrap" class="form-row form-row-wide"> |
723 | 723 | <label class="give-label" for="give-company"> |
724 | - <?php _e( 'Company Name', 'give' ); ?> |
|
725 | - <?php if ( $give_company ) : ?> |
|
724 | + <?php _e('Company Name', 'give'); ?> |
|
725 | + <?php if ($give_company) : ?> |
|
726 | 726 | <span class="give-required-indicator">*</span> |
727 | 727 | <?php endif; ?> |
728 | - <?php echo Give()->tooltips->render_help( __( 'Donate on behalf of Company', 'give' ) ); ?> |
|
728 | + <?php echo Give()->tooltips->render_help(__('Donate on behalf of Company', 'give')); ?> |
|
729 | 729 | </label> |
730 | 730 | |
731 | 731 | <input |
732 | - class="give-input<?php echo( $give_company ? ' required' : '' ); ?>" |
|
732 | + class="give-input<?php echo($give_company ? ' required' : ''); ?>" |
|
733 | 733 | type="text" |
734 | 734 | name="give_company_name" |
735 | - placeholder="<?php _e( 'Company Name', 'give' ); ?>" |
|
735 | + placeholder="<?php _e('Company Name', 'give'); ?>" |
|
736 | 736 | id="give-company" |
737 | - value="<?php echo isset( $give_user_info['company_name'] ) ? $give_user_info['company_name'] : ''; ?>" |
|
738 | - <?php echo( $give_company ? ' required aria-required="true" ' : '' ); ?> |
|
737 | + value="<?php echo isset($give_user_info['company_name']) ? $give_user_info['company_name'] : ''; ?>" |
|
738 | + <?php echo($give_company ? ' required aria-required="true" ' : ''); ?> |
|
739 | 739 | /> |
740 | 740 | |
741 | 741 | </p> |
@@ -747,15 +747,15 @@ discard block |
||
747 | 747 | * |
748 | 748 | * @since 1.7 |
749 | 749 | */ |
750 | - do_action( 'give_donation_form_before_email', $form_id ); |
|
750 | + do_action('give_donation_form_before_email', $form_id); |
|
751 | 751 | ?> |
752 | 752 | <p id="give-email-wrap" class="form-row form-row-wide"> |
753 | 753 | <label class="give-label" for="give-email"> |
754 | - <?php _e( 'Email Address', 'give' ); ?> |
|
755 | - <?php if ( give_field_is_required( 'give_email', $form_id ) ) { ?> |
|
754 | + <?php _e('Email Address', 'give'); ?> |
|
755 | + <?php if (give_field_is_required('give_email', $form_id)) { ?> |
|
756 | 756 | <span class="give-required-indicator">*</span> |
757 | 757 | <?php } ?> |
758 | - <?php echo Give()->tooltips->render_help( __( 'We will send the donation receipt to this address.', 'give' ) ); ?> |
|
758 | + <?php echo Give()->tooltips->render_help(__('We will send the donation receipt to this address.', 'give')); ?> |
|
759 | 759 | </label> |
760 | 760 | |
761 | 761 | <input |
@@ -763,10 +763,10 @@ discard block |
||
763 | 763 | type="email" |
764 | 764 | name="give_email" |
765 | 765 | autocomplete="email" |
766 | - placeholder="<?php _e( 'Email Address', 'give' ); ?>" |
|
766 | + placeholder="<?php _e('Email Address', 'give'); ?>" |
|
767 | 767 | id="give-email" |
768 | - value="<?php echo isset( $give_user_info['give_email'] ) ? $give_user_info['give_email'] : ''; ?>" |
|
769 | - <?php echo( give_field_is_required( 'give_email', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
768 | + value="<?php echo isset($give_user_info['give_email']) ? $give_user_info['give_email'] : ''; ?>" |
|
769 | + <?php echo(give_field_is_required('give_email', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
770 | 770 | /> |
771 | 771 | |
772 | 772 | </p> |
@@ -776,14 +776,14 @@ discard block |
||
776 | 776 | * |
777 | 777 | * @since 1.7 |
778 | 778 | */ |
779 | - do_action( 'give_donation_form_after_email', $form_id ); |
|
779 | + do_action('give_donation_form_after_email', $form_id); |
|
780 | 780 | |
781 | 781 | /** |
782 | 782 | * Fire after personal email field |
783 | 783 | * |
784 | 784 | * @since 1.7 |
785 | 785 | */ |
786 | - do_action( 'give_donation_form_user_info', $form_id ); |
|
786 | + do_action('give_donation_form_user_info', $form_id); |
|
787 | 787 | ?> |
788 | 788 | </fieldset> |
789 | 789 | <?php |
@@ -792,11 +792,11 @@ discard block |
||
792 | 792 | * |
793 | 793 | * @since 1.7 |
794 | 794 | */ |
795 | - do_action( 'give_donation_form_after_personal_info', $form_id ); |
|
795 | + do_action('give_donation_form_after_personal_info', $form_id); |
|
796 | 796 | } |
797 | 797 | |
798 | -add_action( 'give_donation_form_after_user_info', 'give_user_info_fields' ); |
|
799 | -add_action( 'give_register_fields_before', 'give_user_info_fields' ); |
|
798 | +add_action('give_donation_form_after_user_info', 'give_user_info_fields'); |
|
799 | +add_action('give_register_fields_before', 'give_user_info_fields'); |
|
800 | 800 | |
801 | 801 | /** |
802 | 802 | * Renders the credit card info form. |
@@ -807,7 +807,7 @@ discard block |
||
807 | 807 | * |
808 | 808 | * @return void |
809 | 809 | */ |
810 | -function give_get_cc_form( $form_id ) { |
|
810 | +function give_get_cc_form($form_id) { |
|
811 | 811 | |
812 | 812 | ob_start(); |
813 | 813 | |
@@ -818,50 +818,50 @@ discard block |
||
818 | 818 | * |
819 | 819 | * @param int $form_id The form ID. |
820 | 820 | */ |
821 | - do_action( 'give_before_cc_fields', $form_id ); |
|
821 | + do_action('give_before_cc_fields', $form_id); |
|
822 | 822 | ?> |
823 | 823 | <fieldset id="give_cc_fields-<?php echo $form_id ?>" class="give-do-validate"> |
824 | - <legend><?php echo apply_filters( 'give_credit_card_fieldset_heading', esc_html__( 'Credit Card Info', 'give' ) ); ?></legend> |
|
825 | - <?php if ( is_ssl() ) : ?> |
|
824 | + <legend><?php echo apply_filters('give_credit_card_fieldset_heading', esc_html__('Credit Card Info', 'give')); ?></legend> |
|
825 | + <?php if (is_ssl()) : ?> |
|
826 | 826 | <div id="give_secure_site_wrapper-<?php echo $form_id ?>"> |
827 | 827 | <span class="give-icon padlock"></span> |
828 | - <span><?php _e( 'This is a secure SSL encrypted payment.', 'give' ); ?></span> |
|
828 | + <span><?php _e('This is a secure SSL encrypted payment.', 'give'); ?></span> |
|
829 | 829 | </div> |
830 | 830 | <?php endif; ?> |
831 | 831 | <p id="give-card-number-wrap-<?php echo $form_id ?>" class="form-row form-row-two-thirds form-row-responsive"> |
832 | 832 | <label for="card_number-<?php echo $form_id ?>" class="give-label"> |
833 | - <?php _e( 'Card Number', 'give' ); ?> |
|
833 | + <?php _e('Card Number', 'give'); ?> |
|
834 | 834 | <span class="give-required-indicator">*</span> |
835 | - <?php echo Give()->tooltips->render_help( __( 'The (typically) 16 digits on the front of your credit card.', 'give' ) ); ?> |
|
835 | + <?php echo Give()->tooltips->render_help(__('The (typically) 16 digits on the front of your credit card.', 'give')); ?> |
|
836 | 836 | <span class="card-type"></span> |
837 | 837 | </label> |
838 | 838 | |
839 | 839 | <input type="tel" autocomplete="off" name="card_number" id="card_number-<?php echo $form_id ?>" |
840 | - class="card-number give-input required" placeholder="<?php _e( 'Card number', 'give' ); ?>" |
|
840 | + class="card-number give-input required" placeholder="<?php _e('Card number', 'give'); ?>" |
|
841 | 841 | required aria-required="true"/> |
842 | 842 | </p> |
843 | 843 | |
844 | 844 | <p id="give-card-cvc-wrap-<?php echo $form_id ?>" class="form-row form-row-one-third form-row-responsive"> |
845 | 845 | <label for="card_cvc-<?php echo $form_id ?>" class="give-label"> |
846 | - <?php _e( 'CVC', 'give' ); ?> |
|
846 | + <?php _e('CVC', 'give'); ?> |
|
847 | 847 | <span class="give-required-indicator">*</span> |
848 | - <?php echo Give()->tooltips->render_help( __( 'The 3 digit (back) or 4 digit (front) value on your card.', 'give' ) ); ?> |
|
848 | + <?php echo Give()->tooltips->render_help(__('The 3 digit (back) or 4 digit (front) value on your card.', 'give')); ?> |
|
849 | 849 | </label> |
850 | 850 | |
851 | 851 | <input type="tel" size="4" autocomplete="off" name="card_cvc" id="card_cvc-<?php echo $form_id ?>" |
852 | - class="card-cvc give-input required" placeholder="<?php _e( 'Security code', 'give' ); ?>" |
|
852 | + class="card-cvc give-input required" placeholder="<?php _e('Security code', 'give'); ?>" |
|
853 | 853 | required aria-required="true"/> |
854 | 854 | </p> |
855 | 855 | |
856 | 856 | <p id="give-card-name-wrap-<?php echo $form_id ?>" class="form-row form-row-two-thirds form-row-responsive"> |
857 | 857 | <label for="card_name-<?php echo $form_id ?>" class="give-label"> |
858 | - <?php _e( 'Name on the Card', 'give' ); ?> |
|
858 | + <?php _e('Name on the Card', 'give'); ?> |
|
859 | 859 | <span class="give-required-indicator">*</span> |
860 | - <?php echo Give()->tooltips->render_help( __( 'The name printed on the front of your credit card.', 'give' ) ); ?> |
|
860 | + <?php echo Give()->tooltips->render_help(__('The name printed on the front of your credit card.', 'give')); ?> |
|
861 | 861 | </label> |
862 | 862 | |
863 | 863 | <input type="text" autocomplete="off" name="card_name" id="card_name-<?php echo $form_id ?>" |
864 | - class="card-name give-input required" placeholder="<?php esc_attr_e( 'Card name', 'give' ); ?>" |
|
864 | + class="card-name give-input required" placeholder="<?php esc_attr_e('Card name', 'give'); ?>" |
|
865 | 865 | required aria-required="true"/> |
866 | 866 | </p> |
867 | 867 | <?php |
@@ -872,19 +872,19 @@ discard block |
||
872 | 872 | * |
873 | 873 | * @param int $form_id The form ID. |
874 | 874 | */ |
875 | - do_action( 'give_before_cc_expiration' ); |
|
875 | + do_action('give_before_cc_expiration'); |
|
876 | 876 | ?> |
877 | 877 | <p class="card-expiration form-row form-row-one-third form-row-responsive"> |
878 | 878 | <label for="card_expiry-<?php echo $form_id ?>" class="give-label"> |
879 | - <?php _e( 'Expiration', 'give' ); ?> |
|
879 | + <?php _e('Expiration', 'give'); ?> |
|
880 | 880 | <span class="give-required-indicator">*</span> |
881 | - <?php echo Give()->tooltips->render_help( __( 'The date your credit card expires, typically on the front of the card.', 'give' ) ); ?> |
|
881 | + <?php echo Give()->tooltips->render_help(__('The date your credit card expires, typically on the front of the card.', 'give')); ?> |
|
882 | 882 | </label> |
883 | 883 | |
884 | 884 | <input type="hidden" id="card_exp_month-<?php echo $form_id ?>" name="card_exp_month" class="card-expiry-month"/> |
885 | 885 | <input type="hidden" id="card_exp_year-<?php echo $form_id ?>" name="card_exp_year" class="card-expiry-year"/> |
886 | 886 | |
887 | - <input type="tel" autocomplete="off" name="card_expiry" id="card_expiry-<?php echo $form_id ?>" class="card-expiry give-input required" placeholder="<?php esc_attr_e( 'MM / YY', 'give' ); ?>" required aria-required="true"/> |
|
887 | + <input type="tel" autocomplete="off" name="card_expiry" id="card_expiry-<?php echo $form_id ?>" class="card-expiry give-input required" placeholder="<?php esc_attr_e('MM / YY', 'give'); ?>" required aria-required="true"/> |
|
888 | 888 | </p> |
889 | 889 | <?php |
890 | 890 | /** |
@@ -894,7 +894,7 @@ discard block |
||
894 | 894 | * |
895 | 895 | * @param int $form_id The form ID. |
896 | 896 | */ |
897 | - do_action( 'give_after_cc_expiration', $form_id ); |
|
897 | + do_action('give_after_cc_expiration', $form_id); |
|
898 | 898 | ?> |
899 | 899 | </fieldset> |
900 | 900 | <?php |
@@ -905,12 +905,12 @@ discard block |
||
905 | 905 | * |
906 | 906 | * @param int $form_id The form ID. |
907 | 907 | */ |
908 | - do_action( 'give_after_cc_fields', $form_id ); |
|
908 | + do_action('give_after_cc_fields', $form_id); |
|
909 | 909 | |
910 | 910 | echo ob_get_clean(); |
911 | 911 | } |
912 | 912 | |
913 | -add_action( 'give_cc_form', 'give_get_cc_form' ); |
|
913 | +add_action('give_cc_form', 'give_get_cc_form'); |
|
914 | 914 | |
915 | 915 | /** |
916 | 916 | * Outputs the default credit card address fields. |
@@ -921,20 +921,20 @@ discard block |
||
921 | 921 | * |
922 | 922 | * @return void |
923 | 923 | */ |
924 | -function give_default_cc_address_fields( $form_id ) { |
|
924 | +function give_default_cc_address_fields($form_id) { |
|
925 | 925 | // Get user info. |
926 | - $give_user_info = _give_get_prefill_form_field_values( $form_id ); |
|
926 | + $give_user_info = _give_get_prefill_form_field_values($form_id); |
|
927 | 927 | |
928 | 928 | $logged_in = is_user_logged_in(); |
929 | 929 | |
930 | - if ( $logged_in ) { |
|
931 | - $user_address = give_get_donor_address( get_current_user_id() ); |
|
930 | + if ($logged_in) { |
|
931 | + $user_address = give_get_donor_address(get_current_user_id()); |
|
932 | 932 | } |
933 | 933 | |
934 | 934 | ob_start(); |
935 | 935 | ?> |
936 | 936 | <fieldset id="give_cc_address" class="cc-address"> |
937 | - <legend><?php echo apply_filters( 'give_billing_details_fieldset_heading', esc_html__( 'Billing Details', 'give' ) ); ?></legend> |
|
937 | + <legend><?php echo apply_filters('give_billing_details_fieldset_heading', esc_html__('Billing Details', 'give')); ?></legend> |
|
938 | 938 | <?php |
939 | 939 | /** |
940 | 940 | * Fires while rendering credit card billing form, before address fields. |
@@ -943,36 +943,36 @@ discard block |
||
943 | 943 | * |
944 | 944 | * @param int $form_id The form ID. |
945 | 945 | */ |
946 | - do_action( 'give_cc_billing_top' ); |
|
946 | + do_action('give_cc_billing_top'); |
|
947 | 947 | |
948 | 948 | // For Country. |
949 | 949 | $selected_country = give_get_country(); |
950 | - if ( ! empty( $give_user_info['billing_country'] ) && '*' !== $give_user_info['billing_country'] ) { |
|
950 | + if ( ! empty($give_user_info['billing_country']) && '*' !== $give_user_info['billing_country']) { |
|
951 | 951 | $selected_country = $give_user_info['billing_country']; |
952 | 952 | } |
953 | 953 | $countries = give_get_country_list(); |
954 | 954 | |
955 | 955 | // For state |
956 | 956 | $selected_state = ''; |
957 | - if ( $selected_country === give_get_country() ) { |
|
957 | + if ($selected_country === give_get_country()) { |
|
958 | 958 | // Get defalut selected state by admin. |
959 | 959 | $selected_state = give_get_state(); |
960 | 960 | } |
961 | 961 | // Get the last payment made by user states. |
962 | - if ( ! empty( $give_user_info['card_state'] ) && '*' !== $give_user_info['card_state'] ) { |
|
962 | + if ( ! empty($give_user_info['card_state']) && '*' !== $give_user_info['card_state']) { |
|
963 | 963 | $selected_state = $give_user_info['card_state']; |
964 | 964 | } |
965 | 965 | // Get the country code |
966 | - if ( ! empty( $give_user_info['billing_country'] ) && '*' !== $give_user_info['billing_country'] ) { |
|
966 | + if ( ! empty($give_user_info['billing_country']) && '*' !== $give_user_info['billing_country']) { |
|
967 | 967 | $selected_country = $give_user_info['billing_country']; |
968 | 968 | } |
969 | - $label = __( 'State', 'give' ); |
|
969 | + $label = __('State', 'give'); |
|
970 | 970 | $states_label = give_get_states_label(); |
971 | 971 | // Check if $country code exists in the array key for states label. |
972 | - if ( array_key_exists( $selected_country, $states_label ) ) { |
|
973 | - $label = $states_label[ $selected_country ]; |
|
972 | + if (array_key_exists($selected_country, $states_label)) { |
|
973 | + $label = $states_label[$selected_country]; |
|
974 | 974 | } |
975 | - $states = give_get_states( $selected_country ); |
|
975 | + $states = give_get_states($selected_country); |
|
976 | 976 | // Get the country list that do not have any states init. |
977 | 977 | $no_states_country = give_no_states_country_list(); |
978 | 978 | // Get the country list that does not require states. |
@@ -980,24 +980,24 @@ discard block |
||
980 | 980 | ?> |
981 | 981 | <p id="give-card-country-wrap" class="form-row form-row-wide"> |
982 | 982 | <label for="billing_country" class="give-label"> |
983 | - <?php esc_html_e( 'Country', 'give' ); ?> |
|
984 | - <?php if ( give_field_is_required( 'billing_country', $form_id ) ) : ?> |
|
983 | + <?php esc_html_e('Country', 'give'); ?> |
|
984 | + <?php if (give_field_is_required('billing_country', $form_id)) : ?> |
|
985 | 985 | <span class="give-required-indicator">*</span> |
986 | 986 | <?php endif; ?> |
987 | 987 | <span class="give-tooltip give-icon give-icon-question" |
988 | - data-tooltip="<?php esc_attr_e( 'The country for your billing address.', 'give' ); ?>"></span> |
|
988 | + data-tooltip="<?php esc_attr_e('The country for your billing address.', 'give'); ?>"></span> |
|
989 | 989 | </label> |
990 | 990 | |
991 | 991 | <select |
992 | 992 | name="billing_country" |
993 | 993 | autocomplete="country-name" |
994 | 994 | id="billing_country" |
995 | - class="billing-country billing_country give-select<?php echo( give_field_is_required( 'billing_country', $form_id ) ? ' required' : '' ); ?>" |
|
996 | - <?php echo( give_field_is_required( 'billing_country', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
995 | + class="billing-country billing_country give-select<?php echo(give_field_is_required('billing_country', $form_id) ? ' required' : ''); ?>" |
|
996 | + <?php echo(give_field_is_required('billing_country', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
997 | 997 | > |
998 | 998 | <?php |
999 | - foreach ( $countries as $country_code => $country ) { |
|
1000 | - echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
999 | + foreach ($countries as $country_code => $country) { |
|
1000 | + echo '<option value="'.esc_attr($country_code).'"'.selected($country_code, $selected_country, false).'>'.$country.'</option>'; |
|
1001 | 1001 | } |
1002 | 1002 | ?> |
1003 | 1003 | </select> |
@@ -1005,12 +1005,12 @@ discard block |
||
1005 | 1005 | |
1006 | 1006 | <p id="give-card-address-wrap" class="form-row form-row-wide"> |
1007 | 1007 | <label for="card_address" class="give-label"> |
1008 | - <?php _e( 'Address 1', 'give' ); ?> |
|
1008 | + <?php _e('Address 1', 'give'); ?> |
|
1009 | 1009 | <?php |
1010 | - if ( give_field_is_required( 'card_address', $form_id ) ) : ?> |
|
1010 | + if (give_field_is_required('card_address', $form_id)) : ?> |
|
1011 | 1011 | <span class="give-required-indicator">*</span> |
1012 | 1012 | <?php endif; ?> |
1013 | - <?php echo Give()->tooltips->render_help( __( 'The primary billing address for your credit card.', 'give' ) ); ?> |
|
1013 | + <?php echo Give()->tooltips->render_help(__('The primary billing address for your credit card.', 'give')); ?> |
|
1014 | 1014 | </label> |
1015 | 1015 | |
1016 | 1016 | <input |
@@ -1018,20 +1018,20 @@ discard block |
||
1018 | 1018 | id="card_address" |
1019 | 1019 | name="card_address" |
1020 | 1020 | autocomplete="address-line1" |
1021 | - class="card-address give-input<?php echo( give_field_is_required( 'card_address', $form_id ) ? ' required' : '' ); ?>" |
|
1022 | - placeholder="<?php _e( 'Address line 1', 'give' ); ?>" |
|
1023 | - value="<?php echo isset( $give_user_info['card_address'] ) ? $give_user_info['card_address'] : ''; ?>" |
|
1024 | - <?php echo( give_field_is_required( 'card_address', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
1021 | + class="card-address give-input<?php echo(give_field_is_required('card_address', $form_id) ? ' required' : ''); ?>" |
|
1022 | + placeholder="<?php _e('Address line 1', 'give'); ?>" |
|
1023 | + value="<?php echo isset($give_user_info['card_address']) ? $give_user_info['card_address'] : ''; ?>" |
|
1024 | + <?php echo(give_field_is_required('card_address', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
1025 | 1025 | /> |
1026 | 1026 | </p> |
1027 | 1027 | |
1028 | 1028 | <p id="give-card-address-2-wrap" class="form-row form-row-wide"> |
1029 | 1029 | <label for="card_address_2" class="give-label"> |
1030 | - <?php _e( 'Address 2', 'give' ); ?> |
|
1031 | - <?php if ( give_field_is_required( 'card_address_2', $form_id ) ) : ?> |
|
1030 | + <?php _e('Address 2', 'give'); ?> |
|
1031 | + <?php if (give_field_is_required('card_address_2', $form_id)) : ?> |
|
1032 | 1032 | <span class="give-required-indicator">*</span> |
1033 | 1033 | <?php endif; ?> |
1034 | - <?php echo Give()->tooltips->render_help( __( '(optional) The suite, apartment number, post office box (etc) associated with your billing address.', 'give' ) ); ?> |
|
1034 | + <?php echo Give()->tooltips->render_help(__('(optional) The suite, apartment number, post office box (etc) associated with your billing address.', 'give')); ?> |
|
1035 | 1035 | </label> |
1036 | 1036 | |
1037 | 1037 | <input |
@@ -1039,56 +1039,56 @@ discard block |
||
1039 | 1039 | id="card_address_2" |
1040 | 1040 | name="card_address_2" |
1041 | 1041 | autocomplete="address-line2" |
1042 | - class="card-address-2 give-input<?php echo( give_field_is_required( 'card_address_2', $form_id ) ? ' required' : '' ); ?>" |
|
1043 | - placeholder="<?php _e( 'Address line 2', 'give' ); ?>" |
|
1044 | - value="<?php echo isset( $give_user_info['card_address_2'] ) ? $give_user_info['card_address_2'] : ''; ?>" |
|
1045 | - <?php echo( give_field_is_required( 'card_address_2', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
1042 | + class="card-address-2 give-input<?php echo(give_field_is_required('card_address_2', $form_id) ? ' required' : ''); ?>" |
|
1043 | + placeholder="<?php _e('Address line 2', 'give'); ?>" |
|
1044 | + value="<?php echo isset($give_user_info['card_address_2']) ? $give_user_info['card_address_2'] : ''; ?>" |
|
1045 | + <?php echo(give_field_is_required('card_address_2', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
1046 | 1046 | /> |
1047 | 1047 | </p> |
1048 | 1048 | |
1049 | 1049 | <p id="give-card-city-wrap" class="form-row form-row-wide"> |
1050 | 1050 | <label for="card_city" class="give-label"> |
1051 | - <?php _e( 'City', 'give' ); ?> |
|
1052 | - <?php if ( give_field_is_required( 'card_city', $form_id ) ) : ?> |
|
1051 | + <?php _e('City', 'give'); ?> |
|
1052 | + <?php if (give_field_is_required('card_city', $form_id)) : ?> |
|
1053 | 1053 | <span class="give-required-indicator">*</span> |
1054 | 1054 | <?php endif; ?> |
1055 | - <?php echo Give()->tooltips->render_help( __( 'The city for your billing address.', 'give' ) ); ?> |
|
1055 | + <?php echo Give()->tooltips->render_help(__('The city for your billing address.', 'give')); ?> |
|
1056 | 1056 | </label> |
1057 | 1057 | <input |
1058 | 1058 | type="text" |
1059 | 1059 | id="card_city" |
1060 | 1060 | name="card_city" |
1061 | 1061 | autocomplete="address-level3" |
1062 | - class="card-city give-input<?php echo( give_field_is_required( 'card_city', $form_id ) ? ' required' : '' ); ?>" |
|
1063 | - placeholder="<?php _e( 'City', 'give' ); ?>" |
|
1064 | - value="<?php echo isset( $give_user_info['card_city'] ) ? $give_user_info['card_city'] : ''; ?>" |
|
1065 | - <?php echo( give_field_is_required( 'card_city', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
1062 | + class="card-city give-input<?php echo(give_field_is_required('card_city', $form_id) ? ' required' : ''); ?>" |
|
1063 | + placeholder="<?php _e('City', 'give'); ?>" |
|
1064 | + value="<?php echo isset($give_user_info['card_city']) ? $give_user_info['card_city'] : ''; ?>" |
|
1065 | + <?php echo(give_field_is_required('card_city', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
1066 | 1066 | /> |
1067 | 1067 | </p> |
1068 | 1068 | |
1069 | 1069 | <p id="give-card-state-wrap" |
1070 | - class="form-row form-row-first form-row-responsive <?php echo ( ! empty( $selected_country ) && array_key_exists( $selected_country, $no_states_country ) ) ? 'give-hidden' : ''; ?> "> |
|
1070 | + class="form-row form-row-first form-row-responsive <?php echo ( ! empty($selected_country) && array_key_exists($selected_country, $no_states_country)) ? 'give-hidden' : ''; ?> "> |
|
1071 | 1071 | <label for="card_state" class="give-label"> |
1072 | 1072 | <span class="state-label-text"><?php echo $label; ?></span> |
1073 | - <?php if ( give_field_is_required( 'card_state', $form_id ) ) : |
|
1073 | + <?php if (give_field_is_required('card_state', $form_id)) : |
|
1074 | 1074 | ?> |
1075 | - <span class="give-required-indicator <?php echo( array_key_exists( $selected_country, $states_not_required_country_list ) ? 'give-hidden' : '' ) ?> ">*</span> |
|
1075 | + <span class="give-required-indicator <?php echo(array_key_exists($selected_country, $states_not_required_country_list) ? 'give-hidden' : '') ?> ">*</span> |
|
1076 | 1076 | <?php endif; ?> |
1077 | 1077 | <span class="give-tooltip give-icon give-icon-question" |
1078 | - data-tooltip="<?php esc_attr_e( 'The state, province, or county for your billing address.', 'give' ); ?>"></span> |
|
1078 | + data-tooltip="<?php esc_attr_e('The state, province, or county for your billing address.', 'give'); ?>"></span> |
|
1079 | 1079 | </label> |
1080 | 1080 | <?php |
1081 | 1081 | |
1082 | - if ( ! empty( $states ) ) : ?> |
|
1082 | + if ( ! empty($states)) : ?> |
|
1083 | 1083 | <select |
1084 | 1084 | name="card_state" |
1085 | 1085 | autocomplete="address-level4" |
1086 | 1086 | id="card_state" |
1087 | - class="card_state give-select<?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required' : '' ); ?>" |
|
1088 | - <?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required aria-required="true" ' : '' ); ?>> |
|
1087 | + class="card_state give-select<?php echo(give_field_is_required('card_state', $form_id) ? ' required' : ''); ?>" |
|
1088 | + <?php echo(give_field_is_required('card_state', $form_id) ? ' required aria-required="true" ' : ''); ?>> |
|
1089 | 1089 | <?php |
1090 | - foreach ( $states as $state_code => $state ) { |
|
1091 | - echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
1090 | + foreach ($states as $state_code => $state) { |
|
1091 | + echo '<option value="'.$state_code.'"'.selected($state_code, $selected_state, false).'>'.$state.'</option>'; |
|
1092 | 1092 | } |
1093 | 1093 | ?> |
1094 | 1094 | </select> |
@@ -1100,11 +1100,11 @@ discard block |
||
1100 | 1100 | |
1101 | 1101 | <p id="give-card-zip-wrap" class="form-row form-row-last form-row-responsive"> |
1102 | 1102 | <label for="card_zip" class="give-label"> |
1103 | - <?php _e( 'Zip / Postal Code', 'give' ); ?> |
|
1104 | - <?php if ( give_field_is_required( 'card_zip', $form_id ) ) : ?> |
|
1103 | + <?php _e('Zip / Postal Code', 'give'); ?> |
|
1104 | + <?php if (give_field_is_required('card_zip', $form_id)) : ?> |
|
1105 | 1105 | <span class="give-required-indicator">*</span> |
1106 | 1106 | <?php endif; ?> |
1107 | - <?php echo Give()->tooltips->render_help( __( 'The ZIP Code or postal code for your billing address.', 'give' ) ); ?> |
|
1107 | + <?php echo Give()->tooltips->render_help(__('The ZIP Code or postal code for your billing address.', 'give')); ?> |
|
1108 | 1108 | </label> |
1109 | 1109 | |
1110 | 1110 | <input |
@@ -1113,10 +1113,10 @@ discard block |
||
1113 | 1113 | id="card_zip" |
1114 | 1114 | name="card_zip" |
1115 | 1115 | autocomplete="postal-code" |
1116 | - class="card-zip give-input<?php echo( give_field_is_required( 'card_zip', $form_id ) ? ' required' : '' ); ?>" |
|
1117 | - placeholder="<?php _e( 'Zip / Postal Code', 'give' ); ?>" |
|
1118 | - value="<?php echo isset( $give_user_info['card_zip'] ) ? $give_user_info['card_zip'] : ''; ?>" |
|
1119 | - <?php echo( give_field_is_required( 'card_zip', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
1116 | + class="card-zip give-input<?php echo(give_field_is_required('card_zip', $form_id) ? ' required' : ''); ?>" |
|
1117 | + placeholder="<?php _e('Zip / Postal Code', 'give'); ?>" |
|
1118 | + value="<?php echo isset($give_user_info['card_zip']) ? $give_user_info['card_zip'] : ''; ?>" |
|
1119 | + <?php echo(give_field_is_required('card_zip', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
1120 | 1120 | /> |
1121 | 1121 | </p> |
1122 | 1122 | <?php |
@@ -1127,14 +1127,14 @@ discard block |
||
1127 | 1127 | * |
1128 | 1128 | * @param int $form_id The form ID. |
1129 | 1129 | */ |
1130 | - do_action( 'give_cc_billing_bottom' ); |
|
1130 | + do_action('give_cc_billing_bottom'); |
|
1131 | 1131 | ?> |
1132 | 1132 | </fieldset> |
1133 | 1133 | <?php |
1134 | 1134 | echo ob_get_clean(); |
1135 | 1135 | } |
1136 | 1136 | |
1137 | -add_action( 'give_after_cc_fields', 'give_default_cc_address_fields' ); |
|
1137 | +add_action('give_after_cc_fields', 'give_default_cc_address_fields'); |
|
1138 | 1138 | |
1139 | 1139 | |
1140 | 1140 | /** |
@@ -1147,15 +1147,15 @@ discard block |
||
1147 | 1147 | * |
1148 | 1148 | * @return string |
1149 | 1149 | */ |
1150 | -function give_get_register_fields( $form_id ) { |
|
1150 | +function give_get_register_fields($form_id) { |
|
1151 | 1151 | |
1152 | 1152 | global $user_ID; |
1153 | 1153 | |
1154 | - if ( is_user_logged_in() ) { |
|
1155 | - $user_data = get_userdata( $user_ID ); |
|
1154 | + if (is_user_logged_in()) { |
|
1155 | + $user_data = get_userdata($user_ID); |
|
1156 | 1156 | } |
1157 | 1157 | |
1158 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
1158 | + $show_register_form = give_show_login_register_option($form_id); |
|
1159 | 1159 | |
1160 | 1160 | ob_start(); ?> |
1161 | 1161 | <fieldset id="give-register-fields-<?php echo $form_id; ?>"> |
@@ -1168,7 +1168,7 @@ discard block |
||
1168 | 1168 | * |
1169 | 1169 | * @param int $form_id The form ID. |
1170 | 1170 | */ |
1171 | - do_action( 'give_register_fields_before', $form_id ); |
|
1171 | + do_action('give_register_fields_before', $form_id); |
|
1172 | 1172 | ?> |
1173 | 1173 | |
1174 | 1174 | <fieldset id="give-register-account-fields-<?php echo $form_id; ?>"> |
@@ -1180,22 +1180,22 @@ discard block |
||
1180 | 1180 | * |
1181 | 1181 | * @param int $form_id The form ID. |
1182 | 1182 | */ |
1183 | - do_action( 'give_register_account_fields_before', $form_id ); |
|
1183 | + do_action('give_register_account_fields_before', $form_id); |
|
1184 | 1184 | ?> |
1185 | 1185 | <div id="give-create-account-wrap-<?php echo $form_id; ?>" class="form-row form-row-first form-row-responsive"> |
1186 | 1186 | <label for="give-create-account-<?php echo $form_id; ?>"> |
1187 | 1187 | <?php |
1188 | 1188 | // Add attributes to checkbox, if Guest Checkout is disabled. |
1189 | - $is_guest_checkout = give_get_meta( $form_id, '_give_logged_in_only', true ); |
|
1190 | - $id = 'give-create-account-' . $form_id; |
|
1191 | - if ( ! give_is_setting_enabled( $is_guest_checkout ) ) { |
|
1189 | + $is_guest_checkout = give_get_meta($form_id, '_give_logged_in_only', true); |
|
1190 | + $id = 'give-create-account-'.$form_id; |
|
1191 | + if ( ! give_is_setting_enabled($is_guest_checkout)) { |
|
1192 | 1192 | echo Give()->tooltips->render( |
1193 | 1193 | array( |
1194 | 1194 | 'tag_content' => sprintf( |
1195 | 1195 | '<input type="checkbox" name="give_create_account" value="on" id="%s" class="give-input give-disabled" checked />', |
1196 | 1196 | $id |
1197 | 1197 | ), |
1198 | - 'label' => __( 'Registration is required to donate.', 'give' ), |
|
1198 | + 'label' => __('Registration is required to donate.', 'give'), |
|
1199 | 1199 | ) ); |
1200 | 1200 | } else { |
1201 | 1201 | ?> |
@@ -1203,17 +1203,17 @@ discard block |
||
1203 | 1203 | <?php |
1204 | 1204 | } |
1205 | 1205 | ?> |
1206 | - <?php _e( 'Create an account', 'give' ); ?> |
|
1207 | - <?php echo Give()->tooltips->render_help( __( 'Create an account on the site to see and manage donation history.', 'give' ) ); ?> |
|
1208 | - <?php wp_nonce_field( 'give_form_create_user_nonce', 'give-form-user-register-hash', false, true );?> |
|
1206 | + <?php _e('Create an account', 'give'); ?> |
|
1207 | + <?php echo Give()->tooltips->render_help(__('Create an account on the site to see and manage donation history.', 'give')); ?> |
|
1208 | + <?php wp_nonce_field('give_form_create_user_nonce', 'give-form-user-register-hash', false, true); ?> |
|
1209 | 1209 | </label> |
1210 | 1210 | </div> |
1211 | 1211 | |
1212 | - <?php if ( 'both' === $show_register_form ) { ?> |
|
1212 | + <?php if ('both' === $show_register_form) { ?> |
|
1213 | 1213 | <div class="give-login-account-wrap form-row form-row-last form-row-responsive"> |
1214 | - <p class="give-login-message"><?php esc_html_e( 'Already have an account?', 'give' ); ?> |
|
1215 | - <a href="<?php echo esc_url( add_query_arg( 'login', 1 ) ); ?>" class="give-checkout-login" |
|
1216 | - data-action="give_checkout_login"><?php esc_html_e( 'Login', 'give' ); ?></a> |
|
1214 | + <p class="give-login-message"><?php esc_html_e('Already have an account?', 'give'); ?> |
|
1215 | + <a href="<?php echo esc_url(add_query_arg('login', 1)); ?>" class="give-checkout-login" |
|
1216 | + data-action="give_checkout_login"><?php esc_html_e('Login', 'give'); ?></a> |
|
1217 | 1217 | </p> |
1218 | 1218 | <p class="give-loading-text"> |
1219 | 1219 | <span class="give-loading-animation"></span> |
@@ -1229,7 +1229,7 @@ discard block |
||
1229 | 1229 | * |
1230 | 1230 | * @param int $form_id The form ID. |
1231 | 1231 | */ |
1232 | - do_action( 'give_register_account_fields_after', $form_id ); |
|
1232 | + do_action('give_register_account_fields_after', $form_id); |
|
1233 | 1233 | ?> |
1234 | 1234 | </fieldset> |
1235 | 1235 | |
@@ -1241,7 +1241,7 @@ discard block |
||
1241 | 1241 | * |
1242 | 1242 | * @param int $form_id The form ID. |
1243 | 1243 | */ |
1244 | - do_action( 'give_register_fields_after', $form_id ); |
|
1244 | + do_action('give_register_fields_after', $form_id); |
|
1245 | 1245 | ?> |
1246 | 1246 | |
1247 | 1247 | <input type="hidden" name="give-purchase-var" value="needs-to-register"/> |
@@ -1252,7 +1252,7 @@ discard block |
||
1252 | 1252 | * |
1253 | 1253 | * @since 1.7 |
1254 | 1254 | */ |
1255 | - do_action( 'give_donation_form_user_info', $form_id ); |
|
1255 | + do_action('give_donation_form_user_info', $form_id); |
|
1256 | 1256 | ?> |
1257 | 1257 | |
1258 | 1258 | </fieldset> |
@@ -1260,7 +1260,7 @@ discard block |
||
1260 | 1260 | echo ob_get_clean(); |
1261 | 1261 | } |
1262 | 1262 | |
1263 | -add_action( 'give_donation_form_register_fields', 'give_get_register_fields' ); |
|
1263 | +add_action('give_donation_form_register_fields', 'give_get_register_fields'); |
|
1264 | 1264 | |
1265 | 1265 | /** |
1266 | 1266 | * Gets the login fields for the login form on the checkout. This function hooks |
@@ -1273,28 +1273,28 @@ discard block |
||
1273 | 1273 | * |
1274 | 1274 | * @return string |
1275 | 1275 | */ |
1276 | -function give_get_login_fields( $form_id ) { |
|
1276 | +function give_get_login_fields($form_id) { |
|
1277 | 1277 | |
1278 | - $form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : $form_id; |
|
1279 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
1278 | + $form_id = isset($_POST['form_id']) ? $_POST['form_id'] : $form_id; |
|
1279 | + $show_register_form = give_show_login_register_option($form_id); |
|
1280 | 1280 | |
1281 | 1281 | ob_start(); |
1282 | 1282 | ?> |
1283 | 1283 | <fieldset id="give-login-fields-<?php echo $form_id; ?>"> |
1284 | - <legend><?php echo apply_filters( 'give_account_login_fieldset_heading', __( 'Login to Your Account', 'give' ) ); |
|
1285 | - if ( ! give_logged_in_only( $form_id ) ) { |
|
1286 | - echo ' <span class="sub-text">' . __( '(optional)', 'give' ) . '</span>'; |
|
1284 | + <legend><?php echo apply_filters('give_account_login_fieldset_heading', __('Login to Your Account', 'give')); |
|
1285 | + if ( ! give_logged_in_only($form_id)) { |
|
1286 | + echo ' <span class="sub-text">'.__('(optional)', 'give').'</span>'; |
|
1287 | 1287 | } ?> |
1288 | 1288 | </legend> |
1289 | - <?php if ( $show_register_form == 'both' ) { ?> |
|
1289 | + <?php if ($show_register_form == 'both') { ?> |
|
1290 | 1290 | <p class="give-new-account-link"> |
1291 | - <?php _e( 'Don\'t have an account?', 'give' ); ?> |
|
1292 | - <a href="<?php echo remove_query_arg( 'login' ); ?>" class="give-checkout-register-cancel" |
|
1291 | + <?php _e('Don\'t have an account?', 'give'); ?> |
|
1292 | + <a href="<?php echo remove_query_arg('login'); ?>" class="give-checkout-register-cancel" |
|
1293 | 1293 | data-action="give_checkout_register"> |
1294 | - <?php if ( give_logged_in_only( $form_id ) ) { |
|
1295 | - _e( 'Register as a part of your donation »', 'give' ); |
|
1294 | + <?php if (give_logged_in_only($form_id)) { |
|
1295 | + _e('Register as a part of your donation »', 'give'); |
|
1296 | 1296 | } else { |
1297 | - _e( 'Register or donate as a guest »', 'give' ); |
|
1297 | + _e('Register or donate as a guest »', 'give'); |
|
1298 | 1298 | } ?> |
1299 | 1299 | </a> |
1300 | 1300 | </p> |
@@ -1310,49 +1310,49 @@ discard block |
||
1310 | 1310 | * |
1311 | 1311 | * @param int $form_id The form ID. |
1312 | 1312 | */ |
1313 | - do_action( 'give_checkout_login_fields_before', $form_id ); |
|
1313 | + do_action('give_checkout_login_fields_before', $form_id); |
|
1314 | 1314 | ?> |
1315 | 1315 | <div id="give-user-login-wrap-<?php echo $form_id; ?>" class="form-row form-row-first form-row-responsive"> |
1316 | 1316 | <label class="give-label" for="give-user-login-<?php echo $form_id; ?>"> |
1317 | - <?php _e( 'Username', 'give' ); ?> |
|
1318 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
1317 | + <?php _e('Username', 'give'); ?> |
|
1318 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
1319 | 1319 | <span class="give-required-indicator">*</span> |
1320 | 1320 | <?php } ?> |
1321 | 1321 | </label> |
1322 | 1322 | |
1323 | - <input class="give-input<?php echo ( give_logged_in_only( $form_id ) ) ? ' required' : ''; ?>" type="text" |
|
1323 | + <input class="give-input<?php echo (give_logged_in_only($form_id)) ? ' required' : ''; ?>" type="text" |
|
1324 | 1324 | name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" value="" |
1325 | - placeholder="<?php _e( 'Your username', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
1325 | + placeholder="<?php _e('Your username', 'give'); ?>"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
1326 | 1326 | </div> |
1327 | 1327 | |
1328 | 1328 | <div id="give-user-pass-wrap-<?php echo $form_id; ?>" |
1329 | 1329 | class="give_login_password form-row form-row-last form-row-responsive"> |
1330 | 1330 | <label class="give-label" for="give-user-pass-<?php echo $form_id; ?>"> |
1331 | - <?php _e( 'Password', 'give' ); ?> |
|
1332 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
1331 | + <?php _e('Password', 'give'); ?> |
|
1332 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
1333 | 1333 | <span class="give-required-indicator">*</span> |
1334 | 1334 | <?php } ?> |
1335 | 1335 | </label> |
1336 | - <input class="give-input<?php echo ( give_logged_in_only( $form_id ) ) ? ' required' : ''; ?>" |
|
1336 | + <input class="give-input<?php echo (give_logged_in_only($form_id)) ? ' required' : ''; ?>" |
|
1337 | 1337 | type="password" name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" |
1338 | - placeholder="<?php _e( 'Your password', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
1338 | + placeholder="<?php _e('Your password', 'give'); ?>"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
1339 | 1339 | <input type="hidden" name="give-purchase-var" value="needs-to-login"/> |
1340 | 1340 | </div> |
1341 | 1341 | |
1342 | 1342 | <div id="give-forgot-password-wrap-<?php echo $form_id; ?>" class="give_login_forgot_password"> |
1343 | 1343 | <span class="give-forgot-password "> |
1344 | 1344 | <a href="<?php echo wp_lostpassword_url() ?>" |
1345 | - target="_blank"><?php _e( 'Reset Password', 'give' ) ?></a> |
|
1345 | + target="_blank"><?php _e('Reset Password', 'give') ?></a> |
|
1346 | 1346 | </span> |
1347 | 1347 | </div> |
1348 | 1348 | |
1349 | 1349 | <div id="give-user-login-submit-<?php echo $form_id; ?>" class="give-clearfix"> |
1350 | 1350 | <input type="submit" class="give-submit give-btn button" name="give_login_submit" |
1351 | - value="<?php _e( 'Login', 'give' ); ?>"/> |
|
1352 | - <?php if ( $show_register_form !== 'login' ) { ?> |
|
1351 | + value="<?php _e('Login', 'give'); ?>"/> |
|
1352 | + <?php if ($show_register_form !== 'login') { ?> |
|
1353 | 1353 | <input type="button" data-action="give_cancel_login" |
1354 | 1354 | class="give-cancel-login give-checkout-register-cancel give-btn button" name="give_login_cancel" |
1355 | - value="<?php _e( 'Cancel', 'give' ); ?>"/> |
|
1355 | + value="<?php _e('Cancel', 'give'); ?>"/> |
|
1356 | 1356 | <?php } ?> |
1357 | 1357 | <span class="give-loading-animation"></span> |
1358 | 1358 | </div> |
@@ -1364,14 +1364,14 @@ discard block |
||
1364 | 1364 | * |
1365 | 1365 | * @param int $form_id The form ID. |
1366 | 1366 | */ |
1367 | - do_action( 'give_checkout_login_fields_after', $form_id ); |
|
1367 | + do_action('give_checkout_login_fields_after', $form_id); |
|
1368 | 1368 | ?> |
1369 | 1369 | </fieldset><!--end #give-login-fields--> |
1370 | 1370 | <?php |
1371 | 1371 | echo ob_get_clean(); |
1372 | 1372 | } |
1373 | 1373 | |
1374 | -add_action( 'give_donation_form_login_fields', 'give_get_login_fields', 10, 1 ); |
|
1374 | +add_action('give_donation_form_login_fields', 'give_get_login_fields', 10, 1); |
|
1375 | 1375 | |
1376 | 1376 | /** |
1377 | 1377 | * Payment Mode Select. |
@@ -1387,10 +1387,10 @@ discard block |
||
1387 | 1387 | * |
1388 | 1388 | * @return void |
1389 | 1389 | */ |
1390 | -function give_payment_mode_select( $form_id, $args ) { |
|
1390 | +function give_payment_mode_select($form_id, $args) { |
|
1391 | 1391 | |
1392 | - $gateways = give_get_enabled_payment_gateways( $form_id ); |
|
1393 | - $id_prefix = ! empty( $args['id_prefix'] ) ? $args['id_prefix'] : ''; |
|
1392 | + $gateways = give_get_enabled_payment_gateways($form_id); |
|
1393 | + $id_prefix = ! empty($args['id_prefix']) ? $args['id_prefix'] : ''; |
|
1394 | 1394 | |
1395 | 1395 | /** |
1396 | 1396 | * Fires while selecting payment gateways, before the fields. |
@@ -1399,10 +1399,10 @@ discard block |
||
1399 | 1399 | * |
1400 | 1400 | * @param int $form_id The form ID. |
1401 | 1401 | */ |
1402 | - do_action( 'give_payment_mode_top', $form_id ); |
|
1402 | + do_action('give_payment_mode_top', $form_id); |
|
1403 | 1403 | ?> |
1404 | 1404 | |
1405 | - <fieldset id="give-payment-mode-select" <?php if ( count( $gateways ) <= 1 ) { |
|
1405 | + <fieldset id="give-payment-mode-select" <?php if (count($gateways) <= 1) { |
|
1406 | 1406 | echo 'style="display: none;"'; |
1407 | 1407 | } ?>> |
1408 | 1408 | <?php |
@@ -1413,10 +1413,10 @@ discard block |
||
1413 | 1413 | * |
1414 | 1414 | * @param int $form_id The form ID. |
1415 | 1415 | */ |
1416 | - do_action( 'give_payment_mode_before_gateways_wrap' ); |
|
1416 | + do_action('give_payment_mode_before_gateways_wrap'); |
|
1417 | 1417 | ?> |
1418 | 1418 | <legend |
1419 | - class="give-payment-mode-label"><?php echo apply_filters( 'give_checkout_payment_method_text', esc_html__( 'Select Payment Method', 'give' ) ); ?> |
|
1419 | + class="give-payment-mode-label"><?php echo apply_filters('give_checkout_payment_method_text', esc_html__('Select Payment Method', 'give')); ?> |
|
1420 | 1420 | <span class="give-loading-text"><span |
1421 | 1421 | class="give-loading-animation"></span> |
1422 | 1422 | </span> |
@@ -1429,37 +1429,36 @@ discard block |
||
1429 | 1429 | * |
1430 | 1430 | * @since 1.7 |
1431 | 1431 | */ |
1432 | - do_action( 'give_payment_mode_before_gateways' ) |
|
1432 | + do_action('give_payment_mode_before_gateways') |
|
1433 | 1433 | ?> |
1434 | 1434 | <ul id="give-gateway-radio-list"> |
1435 | 1435 | <?php |
1436 | 1436 | /** |
1437 | 1437 | * Loop through the active payment gateways. |
1438 | 1438 | */ |
1439 | - $selected_gateway = give_get_chosen_gateway( $form_id ); |
|
1439 | + $selected_gateway = give_get_chosen_gateway($form_id); |
|
1440 | 1440 | $give_settings = give_get_settings(); |
1441 | - $gateways_label = array_key_exists( 'gateways_label', $give_settings ) ? |
|
1442 | - $give_settings['gateways_label'] : |
|
1443 | - array(); |
|
1441 | + $gateways_label = array_key_exists('gateways_label', $give_settings) ? |
|
1442 | + $give_settings['gateways_label'] : array(); |
|
1444 | 1443 | |
1445 | - foreach ( $gateways as $gateway_id => $gateway ) : |
|
1444 | + foreach ($gateways as $gateway_id => $gateway) : |
|
1446 | 1445 | //Determine the default gateway. |
1447 | - $checked = checked( $gateway_id, $selected_gateway, false ); |
|
1446 | + $checked = checked($gateway_id, $selected_gateway, false); |
|
1448 | 1447 | $checked_class = $checked ? ' class="give-gateway-option-selected"' : ''; ?> |
1449 | 1448 | <li<?php echo $checked_class ?>> |
1450 | 1449 | <input type="radio" name="payment-mode" class="give-gateway" |
1451 | - id="give-gateway-<?php echo esc_attr( $gateway_id . '-' . $id_prefix ); ?>" |
|
1452 | - value="<?php echo esc_attr( $gateway_id ); ?>"<?php echo $checked; ?>> |
|
1450 | + id="give-gateway-<?php echo esc_attr($gateway_id.'-'.$id_prefix); ?>" |
|
1451 | + value="<?php echo esc_attr($gateway_id); ?>"<?php echo $checked; ?>> |
|
1453 | 1452 | |
1454 | 1453 | <?php |
1455 | 1454 | $label = $gateway['checkout_label']; |
1456 | - if ( ! empty( $gateways_label[ $gateway_id ] ) ) { |
|
1457 | - $label = $gateways_label[ $gateway_id ]; |
|
1455 | + if ( ! empty($gateways_label[$gateway_id])) { |
|
1456 | + $label = $gateways_label[$gateway_id]; |
|
1458 | 1457 | } |
1459 | 1458 | ?> |
1460 | - <label for="give-gateway-<?php echo esc_attr( $gateway_id . '-' . $id_prefix ); ?>" |
|
1459 | + <label for="give-gateway-<?php echo esc_attr($gateway_id.'-'.$id_prefix); ?>" |
|
1461 | 1460 | class="give-gateway-option" |
1462 | - id="give-gateway-option-<?php echo esc_attr( $gateway_id ); ?>"> <?php echo esc_html( $label ); ?></label> |
|
1461 | + id="give-gateway-option-<?php echo esc_attr($gateway_id); ?>"> <?php echo esc_html($label); ?></label> |
|
1463 | 1462 | </li> |
1464 | 1463 | <?php |
1465 | 1464 | endforeach; |
@@ -1471,7 +1470,7 @@ discard block |
||
1471 | 1470 | * |
1472 | 1471 | * @since 1.7 |
1473 | 1472 | */ |
1474 | - do_action( 'give_payment_mode_after_gateways' ); |
|
1473 | + do_action('give_payment_mode_after_gateways'); |
|
1475 | 1474 | ?> |
1476 | 1475 | </div> |
1477 | 1476 | <?php |
@@ -1482,7 +1481,7 @@ discard block |
||
1482 | 1481 | * |
1483 | 1482 | * @param int $form_id The form ID. |
1484 | 1483 | */ |
1485 | - do_action( 'give_payment_mode_after_gateways_wrap' ); |
|
1484 | + do_action('give_payment_mode_after_gateways_wrap'); |
|
1486 | 1485 | ?> |
1487 | 1486 | </fieldset> |
1488 | 1487 | |
@@ -1494,7 +1493,7 @@ discard block |
||
1494 | 1493 | * |
1495 | 1494 | * @param int $form_id The form ID. |
1496 | 1495 | */ |
1497 | - do_action( 'give_payment_mode_bottom', $form_id ); |
|
1496 | + do_action('give_payment_mode_bottom', $form_id); |
|
1498 | 1497 | ?> |
1499 | 1498 | |
1500 | 1499 | <div id="give_purchase_form_wrap"> |
@@ -1505,7 +1504,7 @@ discard block |
||
1505 | 1504 | * |
1506 | 1505 | * @since 1.7 |
1507 | 1506 | */ |
1508 | - do_action( 'give_donation_form', $form_id, $args ); |
|
1507 | + do_action('give_donation_form', $form_id, $args); |
|
1509 | 1508 | ?> |
1510 | 1509 | |
1511 | 1510 | </div> |
@@ -1516,10 +1515,10 @@ discard block |
||
1516 | 1515 | * |
1517 | 1516 | * @since 1.7 |
1518 | 1517 | */ |
1519 | - do_action( 'give_donation_form_wrap_bottom', $form_id ); |
|
1518 | + do_action('give_donation_form_wrap_bottom', $form_id); |
|
1520 | 1519 | } |
1521 | 1520 | |
1522 | -add_action( 'give_payment_mode_select', 'give_payment_mode_select', 10, 2 ); |
|
1521 | +add_action('give_payment_mode_select', 'give_payment_mode_select', 10, 2); |
|
1523 | 1522 | |
1524 | 1523 | /** |
1525 | 1524 | * Renders the Checkout Agree to Terms, this displays a checkbox for users to |
@@ -1532,31 +1531,31 @@ discard block |
||
1532 | 1531 | * |
1533 | 1532 | * @return bool |
1534 | 1533 | */ |
1535 | -function give_terms_agreement( $form_id ) { |
|
1536 | - $form_option = give_get_meta( $form_id, '_give_terms_option', true ); |
|
1534 | +function give_terms_agreement($form_id) { |
|
1535 | + $form_option = give_get_meta($form_id, '_give_terms_option', true); |
|
1537 | 1536 | |
1538 | 1537 | // Bailout if per form and global term and conditions is not setup. |
1539 | 1538 | if ( |
1540 | - give_is_setting_enabled( $form_option, 'global' ) |
|
1541 | - && give_is_setting_enabled( give_get_option( 'terms' ) ) |
|
1539 | + give_is_setting_enabled($form_option, 'global') |
|
1540 | + && give_is_setting_enabled(give_get_option('terms')) |
|
1542 | 1541 | ) { |
1543 | - $label = give_get_option( 'agree_to_terms_label', esc_html__( 'Agree to Terms?', 'give' ) ); |
|
1544 | - $terms = $terms = give_get_option( 'agreement_text', '' ); |
|
1545 | - $edit_term_url = admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=display§ion=term-and-conditions' ); |
|
1542 | + $label = give_get_option('agree_to_terms_label', esc_html__('Agree to Terms?', 'give')); |
|
1543 | + $terms = $terms = give_get_option('agreement_text', ''); |
|
1544 | + $edit_term_url = admin_url('edit.php?post_type=give_forms&page=give-settings&tab=display§ion=term-and-conditions'); |
|
1546 | 1545 | |
1547 | - } elseif ( give_is_setting_enabled( $form_option ) ) { |
|
1548 | - $label = ( $label = give_get_meta( $form_id, '_give_agree_label', true ) ) ? stripslashes( $label ) : esc_html__( 'Agree to Terms?', 'give' ); |
|
1549 | - $terms = give_get_meta( $form_id, '_give_agree_text', true ); |
|
1550 | - $edit_term_url = admin_url( 'post.php?post=' . $form_id . '&action=edit#form_terms_options' ); |
|
1546 | + } elseif (give_is_setting_enabled($form_option)) { |
|
1547 | + $label = ($label = give_get_meta($form_id, '_give_agree_label', true)) ? stripslashes($label) : esc_html__('Agree to Terms?', 'give'); |
|
1548 | + $terms = give_get_meta($form_id, '_give_agree_text', true); |
|
1549 | + $edit_term_url = admin_url('post.php?post='.$form_id.'&action=edit#form_terms_options'); |
|
1551 | 1550 | |
1552 | 1551 | } else { |
1553 | 1552 | return false; |
1554 | 1553 | } |
1555 | 1554 | |
1556 | 1555 | // Bailout: Check if term and conditions text is empty or not. |
1557 | - if ( empty( $terms ) ) { |
|
1558 | - if ( is_user_logged_in() && current_user_can( 'edit_give_forms' ) ) { |
|
1559 | - echo sprintf( __( 'Please enter valid terms and conditions in <a href="%s">this form\'s settings</a>.', 'give' ), $edit_term_url ); |
|
1556 | + if (empty($terms)) { |
|
1557 | + if (is_user_logged_in() && current_user_can('edit_give_forms')) { |
|
1558 | + echo sprintf(__('Please enter valid terms and conditions in <a href="%s">this form\'s settings</a>.', 'give'), $edit_term_url); |
|
1560 | 1559 | } |
1561 | 1560 | |
1562 | 1561 | return false; |
@@ -1564,7 +1563,7 @@ discard block |
||
1564 | 1563 | |
1565 | 1564 | ?> |
1566 | 1565 | <fieldset id="give_terms_agreement"> |
1567 | - <legend><?php echo apply_filters( 'give_terms_agreement_text', esc_html__( 'Terms', 'give' ) ); ?></legend> |
|
1566 | + <legend><?php echo apply_filters('give_terms_agreement_text', esc_html__('Terms', 'give')); ?></legend> |
|
1568 | 1567 | <div id="give_terms" class="give_terms-<?php echo $form_id; ?>" style="display:none;"> |
1569 | 1568 | <?php |
1570 | 1569 | /** |
@@ -1572,22 +1571,22 @@ discard block |
||
1572 | 1571 | * |
1573 | 1572 | * @since 1.0 |
1574 | 1573 | */ |
1575 | - do_action( 'give_before_terms' ); |
|
1574 | + do_action('give_before_terms'); |
|
1576 | 1575 | |
1577 | - echo wpautop( stripslashes( $terms ) ); |
|
1576 | + echo wpautop(stripslashes($terms)); |
|
1578 | 1577 | /** |
1579 | 1578 | * Fires while rendering terms of agreement, after the fields. |
1580 | 1579 | * |
1581 | 1580 | * @since 1.0 |
1582 | 1581 | */ |
1583 | - do_action( 'give_after_terms' ); |
|
1582 | + do_action('give_after_terms'); |
|
1584 | 1583 | ?> |
1585 | 1584 | </div> |
1586 | 1585 | <div id="give_show_terms"> |
1587 | 1586 | <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>" role="button" |
1588 | - aria-controls="give_terms"><?php esc_html_e( 'Show Terms', 'give' ); ?></a> |
|
1587 | + aria-controls="give_terms"><?php esc_html_e('Show Terms', 'give'); ?></a> |
|
1589 | 1588 | <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>" role="button" |
1590 | - aria-controls="give_terms" style="display:none;"><?php esc_html_e( 'Hide Terms', 'give' ); ?></a> |
|
1589 | + aria-controls="give_terms" style="display:none;"><?php esc_html_e('Hide Terms', 'give'); ?></a> |
|
1591 | 1590 | </div> |
1592 | 1591 | |
1593 | 1592 | <input name="give_agree_to_terms" class="required" type="checkbox" |
@@ -1598,7 +1597,7 @@ discard block |
||
1598 | 1597 | <?php |
1599 | 1598 | } |
1600 | 1599 | |
1601 | -add_action( 'give_donation_form_after_cc_form', 'give_terms_agreement', 8888, 1 ); |
|
1600 | +add_action('give_donation_form_after_cc_form', 'give_terms_agreement', 8888, 1); |
|
1602 | 1601 | |
1603 | 1602 | /** |
1604 | 1603 | * Checkout Final Total. |
@@ -1611,15 +1610,14 @@ discard block |
||
1611 | 1610 | * |
1612 | 1611 | * @return void |
1613 | 1612 | */ |
1614 | -function give_checkout_final_total( $form_id ) { |
|
1613 | +function give_checkout_final_total($form_id) { |
|
1615 | 1614 | |
1616 | - $total = isset( $_POST['give_total'] ) ? |
|
1617 | - apply_filters( 'give_donation_total', give_maybe_sanitize_amount( $_POST['give_total'] ) ) : |
|
1618 | - give_get_default_form_amount( $form_id ); |
|
1615 | + $total = isset($_POST['give_total']) ? |
|
1616 | + apply_filters('give_donation_total', give_maybe_sanitize_amount($_POST['give_total'])) : give_get_default_form_amount($form_id); |
|
1619 | 1617 | |
1620 | 1618 | |
1621 | 1619 | // Only proceed if give_total available. |
1622 | - if ( empty( $total ) ) { |
|
1620 | + if (empty($total)) { |
|
1623 | 1621 | return; |
1624 | 1622 | } |
1625 | 1623 | ?> |
@@ -1630,19 +1628,19 @@ discard block |
||
1630 | 1628 | * |
1631 | 1629 | * @since 2.0.5 |
1632 | 1630 | */ |
1633 | - do_action( 'give_donation_final_total_label_before', $form_id ); |
|
1631 | + do_action('give_donation_final_total_label_before', $form_id); |
|
1634 | 1632 | ?> |
1635 | 1633 | <span class="give-donation-total-label"> |
1636 | - <?php echo apply_filters( 'give_donation_total_label', esc_html__( 'Donation Total:', 'give' ) ); ?> |
|
1634 | + <?php echo apply_filters('give_donation_total_label', esc_html__('Donation Total:', 'give')); ?> |
|
1637 | 1635 | </span> |
1638 | 1636 | <span class="give-final-total-amount" |
1639 | - data-total="<?php echo give_format_amount( $total, array( 'sanitize' => false ) ); ?>"> |
|
1637 | + data-total="<?php echo give_format_amount($total, array('sanitize' => false)); ?>"> |
|
1640 | 1638 | <?php |
1641 | 1639 | |
1642 | - echo give_currency_filter( give_format_amount( $total, array( |
|
1640 | + echo give_currency_filter(give_format_amount($total, array( |
|
1643 | 1641 | 'sanitize' => false, |
1644 | - 'currency' => give_get_currency( $form_id ), |
|
1645 | - ) ), array( 'currency_code' => give_get_currency( $form_id ) ) ); ?> |
|
1642 | + 'currency' => give_get_currency($form_id), |
|
1643 | + )), array('currency_code' => give_get_currency($form_id))); ?> |
|
1646 | 1644 | </span> |
1647 | 1645 | <?php |
1648 | 1646 | /** |
@@ -1650,13 +1648,13 @@ discard block |
||
1650 | 1648 | * |
1651 | 1649 | * @since 2.0.5 |
1652 | 1650 | */ |
1653 | - do_action( 'give_donation_final_total_label_after', $form_id ); |
|
1651 | + do_action('give_donation_final_total_label_after', $form_id); |
|
1654 | 1652 | ?> |
1655 | 1653 | </p> |
1656 | 1654 | <?php |
1657 | 1655 | } |
1658 | 1656 | |
1659 | -add_action( 'give_donation_form_before_submit', 'give_checkout_final_total', 999 ); |
|
1657 | +add_action('give_donation_form_before_submit', 'give_checkout_final_total', 999); |
|
1660 | 1658 | |
1661 | 1659 | /** |
1662 | 1660 | * Renders the Checkout Submit section. |
@@ -1668,7 +1666,7 @@ discard block |
||
1668 | 1666 | * |
1669 | 1667 | * @return void |
1670 | 1668 | */ |
1671 | -function give_checkout_submit( $form_id, $args ) { |
|
1669 | +function give_checkout_submit($form_id, $args) { |
|
1672 | 1670 | ?> |
1673 | 1671 | <fieldset id="give_purchase_submit" class="give-donation-submit"> |
1674 | 1672 | <?php |
@@ -1677,24 +1675,24 @@ discard block |
||
1677 | 1675 | * |
1678 | 1676 | * @since 1.7 |
1679 | 1677 | */ |
1680 | - do_action( 'give_donation_form_before_submit', $form_id, $args ); |
|
1678 | + do_action('give_donation_form_before_submit', $form_id, $args); |
|
1681 | 1679 | |
1682 | - give_checkout_hidden_fields( $form_id ); |
|
1680 | + give_checkout_hidden_fields($form_id); |
|
1683 | 1681 | |
1684 | - echo give_get_donation_form_submit_button( $form_id ); |
|
1682 | + echo give_get_donation_form_submit_button($form_id); |
|
1685 | 1683 | |
1686 | 1684 | /** |
1687 | 1685 | * Fire after donation form submit. |
1688 | 1686 | * |
1689 | 1687 | * @since 1.7 |
1690 | 1688 | */ |
1691 | - do_action( 'give_donation_form_after_submit', $form_id, $args ); |
|
1689 | + do_action('give_donation_form_after_submit', $form_id, $args); |
|
1692 | 1690 | ?> |
1693 | 1691 | </fieldset> |
1694 | 1692 | <?php |
1695 | 1693 | } |
1696 | 1694 | |
1697 | -add_action( 'give_donation_form_after_cc_form', 'give_checkout_submit', 9999, 2 ); |
|
1695 | +add_action('give_donation_form_after_cc_form', 'give_checkout_submit', 9999, 2); |
|
1698 | 1696 | |
1699 | 1697 | /** |
1700 | 1698 | * Give Donation form submit button. |
@@ -1705,10 +1703,10 @@ discard block |
||
1705 | 1703 | * |
1706 | 1704 | * @return string |
1707 | 1705 | */ |
1708 | -function give_get_donation_form_submit_button( $form_id ) { |
|
1706 | +function give_get_donation_form_submit_button($form_id) { |
|
1709 | 1707 | |
1710 | - $display_label_field = give_get_meta( $form_id, '_give_checkout_label', true ); |
|
1711 | - $display_label = ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) ); |
|
1708 | + $display_label_field = give_get_meta($form_id, '_give_checkout_label', true); |
|
1709 | + $display_label = ( ! empty($display_label_field) ? $display_label_field : esc_html__('Donate Now', 'give')); |
|
1712 | 1710 | ob_start(); |
1713 | 1711 | ?> |
1714 | 1712 | <div class="give-submit-button-wrap give-clearfix"> |
@@ -1717,7 +1715,7 @@ discard block |
||
1717 | 1715 | <span class="give-loading-animation"></span> |
1718 | 1716 | </div> |
1719 | 1717 | <?php |
1720 | - return apply_filters( 'give_donation_form_submit_button', ob_get_clean(), $form_id ); |
|
1718 | + return apply_filters('give_donation_form_submit_button', ob_get_clean(), $form_id); |
|
1721 | 1719 | } |
1722 | 1720 | |
1723 | 1721 | /** |
@@ -1732,22 +1730,22 @@ discard block |
||
1732 | 1730 | * |
1733 | 1731 | * @return mixed |
1734 | 1732 | */ |
1735 | -function give_show_goal_progress( $form_id, $args = array() ) { |
|
1733 | +function give_show_goal_progress($form_id, $args = array()) { |
|
1736 | 1734 | |
1737 | 1735 | ob_start(); |
1738 | - give_get_template( 'shortcode-goal', array( 'form_id' => $form_id, 'args' => $args ) ); |
|
1736 | + give_get_template('shortcode-goal', array('form_id' => $form_id, 'args' => $args)); |
|
1739 | 1737 | |
1740 | 1738 | /** |
1741 | 1739 | * Filter progress bar output |
1742 | 1740 | * |
1743 | 1741 | * @since 2.0 |
1744 | 1742 | */ |
1745 | - echo apply_filters( 'give_goal_output', ob_get_clean(), $form_id, $args ); |
|
1743 | + echo apply_filters('give_goal_output', ob_get_clean(), $form_id, $args); |
|
1746 | 1744 | |
1747 | 1745 | return true; |
1748 | 1746 | } |
1749 | 1747 | |
1750 | -add_action( 'give_pre_form', 'give_show_goal_progress', 10, 2 ); |
|
1748 | +add_action('give_pre_form', 'give_show_goal_progress', 10, 2); |
|
1751 | 1749 | |
1752 | 1750 | /** |
1753 | 1751 | * Show Give Totals Progress. |
@@ -1759,22 +1757,22 @@ discard block |
||
1759 | 1757 | * |
1760 | 1758 | * @return mixed |
1761 | 1759 | */ |
1762 | -function give_show_goal_totals_progress( $total, $total_goal ) { |
|
1760 | +function give_show_goal_totals_progress($total, $total_goal) { |
|
1763 | 1761 | |
1764 | 1762 | // Bail out if total goal is set as an array. |
1765 | - if ( isset( $total_goal ) && is_array( $total_goal ) ) { |
|
1763 | + if (isset($total_goal) && is_array($total_goal)) { |
|
1766 | 1764 | return false; |
1767 | 1765 | } |
1768 | 1766 | |
1769 | 1767 | ob_start(); |
1770 | - give_get_template( 'shortcode-totals-progress', array( 'total' => $total, 'total_goal' => $total_goal ) ); |
|
1768 | + give_get_template('shortcode-totals-progress', array('total' => $total, 'total_goal' => $total_goal)); |
|
1771 | 1769 | |
1772 | - echo apply_filters( 'give_total_progress_output', ob_get_clean() ); |
|
1770 | + echo apply_filters('give_total_progress_output', ob_get_clean()); |
|
1773 | 1771 | |
1774 | 1772 | return true; |
1775 | 1773 | } |
1776 | 1774 | |
1777 | -add_action( 'give_pre_form', 'give_show_goal_totals_progress', 10, 2 ); |
|
1775 | +add_action('give_pre_form', 'give_show_goal_totals_progress', 10, 2); |
|
1778 | 1776 | |
1779 | 1777 | /** |
1780 | 1778 | * Get form content position. |
@@ -1786,10 +1784,10 @@ discard block |
||
1786 | 1784 | * |
1787 | 1785 | * @return mixed|string |
1788 | 1786 | */ |
1789 | -function give_get_form_content_placement( $form_id, $args ) { |
|
1787 | +function give_get_form_content_placement($form_id, $args) { |
|
1790 | 1788 | $show_content = ''; |
1791 | 1789 | |
1792 | - if ( isset( $args['show_content'] ) && ! empty( $args['show_content'] ) ) { |
|
1790 | + if (isset($args['show_content']) && ! empty($args['show_content'])) { |
|
1793 | 1791 | // Content positions. |
1794 | 1792 | $content_placement = array( |
1795 | 1793 | 'above' => 'give_pre_form', |
@@ -1797,18 +1795,18 @@ discard block |
||
1797 | 1795 | ); |
1798 | 1796 | |
1799 | 1797 | // Check if content position already decoded. |
1800 | - if ( in_array( $args['show_content'], $content_placement ) ) { |
|
1798 | + if (in_array($args['show_content'], $content_placement)) { |
|
1801 | 1799 | return $args['show_content']; |
1802 | 1800 | } |
1803 | 1801 | |
1804 | - $show_content = ( 'none' !== $args['show_content'] ? $content_placement[ $args['show_content'] ] : '' ); |
|
1802 | + $show_content = ('none' !== $args['show_content'] ? $content_placement[$args['show_content']] : ''); |
|
1805 | 1803 | |
1806 | - } elseif ( give_is_setting_enabled( give_get_meta( $form_id, '_give_display_content', true ) ) ) { |
|
1807 | - $show_content = give_get_meta( $form_id, '_give_content_placement', true ); |
|
1804 | + } elseif (give_is_setting_enabled(give_get_meta($form_id, '_give_display_content', true))) { |
|
1805 | + $show_content = give_get_meta($form_id, '_give_content_placement', true); |
|
1808 | 1806 | |
1809 | - } elseif ( 'none' !== give_get_meta( $form_id, '_give_content_option', true ) ) { |
|
1807 | + } elseif ('none' !== give_get_meta($form_id, '_give_content_option', true)) { |
|
1810 | 1808 | // Backward compatibility for _give_content_option for v18. |
1811 | - $show_content = give_get_meta( $form_id, '_give_content_option', true ); |
|
1809 | + $show_content = give_get_meta($form_id, '_give_content_option', true); |
|
1812 | 1810 | } |
1813 | 1811 | |
1814 | 1812 | return $show_content; |
@@ -1824,20 +1822,20 @@ discard block |
||
1824 | 1822 | * |
1825 | 1823 | * @return void|bool |
1826 | 1824 | */ |
1827 | -function give_form_content( $form_id, $args ) { |
|
1825 | +function give_form_content($form_id, $args) { |
|
1828 | 1826 | |
1829 | - $show_content = give_get_form_content_placement( $form_id, $args ); |
|
1827 | + $show_content = give_get_form_content_placement($form_id, $args); |
|
1830 | 1828 | |
1831 | 1829 | // Bailout. |
1832 | - if ( empty( $show_content ) ) { |
|
1830 | + if (empty($show_content)) { |
|
1833 | 1831 | return false; |
1834 | 1832 | } |
1835 | 1833 | |
1836 | 1834 | // Add action according to value. |
1837 | - add_action( $show_content, 'give_form_display_content', 10, 2 ); |
|
1835 | + add_action($show_content, 'give_form_display_content', 10, 2); |
|
1838 | 1836 | } |
1839 | 1837 | |
1840 | -add_action( 'give_pre_form_output', 'give_form_content', 10, 2 ); |
|
1838 | +add_action('give_pre_form_output', 'give_form_content', 10, 2); |
|
1841 | 1839 | |
1842 | 1840 | /** |
1843 | 1841 | * Renders Post Form Content. |
@@ -1851,22 +1849,22 @@ discard block |
||
1851 | 1849 | * |
1852 | 1850 | * @return void |
1853 | 1851 | */ |
1854 | -function give_form_display_content( $form_id, $args ) { |
|
1852 | +function give_form_display_content($form_id, $args) { |
|
1855 | 1853 | |
1856 | - $content = wpautop( give_get_meta( $form_id, '_give_form_content', true ) ); |
|
1857 | - $show_content = give_get_form_content_placement( $form_id, $args ); |
|
1854 | + $content = wpautop(give_get_meta($form_id, '_give_form_content', true)); |
|
1855 | + $show_content = give_get_form_content_placement($form_id, $args); |
|
1858 | 1856 | |
1859 | - if ( give_is_setting_enabled( give_get_option( 'the_content_filter' ) ) ) { |
|
1860 | - $content = apply_filters( 'the_content', $content ); |
|
1857 | + if (give_is_setting_enabled(give_get_option('the_content_filter'))) { |
|
1858 | + $content = apply_filters('the_content', $content); |
|
1861 | 1859 | } |
1862 | 1860 | |
1863 | - $output = '<div id="give-form-content-' . $form_id . '" class="give-form-content-wrap ' . $show_content . '-content">' . $content . '</div>'; |
|
1861 | + $output = '<div id="give-form-content-'.$form_id.'" class="give-form-content-wrap '.$show_content.'-content">'.$content.'</div>'; |
|
1864 | 1862 | |
1865 | - echo apply_filters( 'give_form_content_output', $output ); |
|
1863 | + echo apply_filters('give_form_content_output', $output); |
|
1866 | 1864 | |
1867 | 1865 | // remove action to prevent content output on addition forms on page. |
1868 | 1866 | // @see: https://github.com/WordImpress/Give/issues/634. |
1869 | - remove_action( $show_content, 'give_form_display_content' ); |
|
1867 | + remove_action($show_content, 'give_form_display_content'); |
|
1870 | 1868 | } |
1871 | 1869 | |
1872 | 1870 | /** |
@@ -1878,7 +1876,7 @@ discard block |
||
1878 | 1876 | * |
1879 | 1877 | * @return void |
1880 | 1878 | */ |
1881 | -function give_checkout_hidden_fields( $form_id ) { |
|
1879 | +function give_checkout_hidden_fields($form_id) { |
|
1882 | 1880 | |
1883 | 1881 | /** |
1884 | 1882 | * Fires while rendering hidden checkout fields, before the fields. |
@@ -1887,13 +1885,13 @@ discard block |
||
1887 | 1885 | * |
1888 | 1886 | * @param int $form_id The form ID. |
1889 | 1887 | */ |
1890 | - do_action( 'give_hidden_fields_before', $form_id ); |
|
1888 | + do_action('give_hidden_fields_before', $form_id); |
|
1891 | 1889 | |
1892 | - if ( is_user_logged_in() ) { ?> |
|
1890 | + if (is_user_logged_in()) { ?> |
|
1893 | 1891 | <input type="hidden" name="give-user-id" value="<?php echo get_current_user_id(); ?>"/> |
1894 | 1892 | <?php } ?> |
1895 | 1893 | <input type="hidden" name="give_action" value="purchase"/> |
1896 | - <input type="hidden" name="give-gateway" value="<?php echo give_get_chosen_gateway( $form_id ); ?>"/> |
|
1894 | + <input type="hidden" name="give-gateway" value="<?php echo give_get_chosen_gateway($form_id); ?>"/> |
|
1897 | 1895 | <?php |
1898 | 1896 | /** |
1899 | 1897 | * Fires while rendering hidden checkout fields, after the fields. |
@@ -1902,7 +1900,7 @@ discard block |
||
1902 | 1900 | * |
1903 | 1901 | * @param int $form_id The form ID. |
1904 | 1902 | */ |
1905 | - do_action( 'give_hidden_fields_after', $form_id ); |
|
1903 | + do_action('give_hidden_fields_after', $form_id); |
|
1906 | 1904 | |
1907 | 1905 | } |
1908 | 1906 | |
@@ -1917,20 +1915,20 @@ discard block |
||
1917 | 1915 | * |
1918 | 1916 | * @return string $content Filtered content. |
1919 | 1917 | */ |
1920 | -function give_filter_success_page_content( $content ) { |
|
1918 | +function give_filter_success_page_content($content) { |
|
1921 | 1919 | |
1922 | 1920 | $give_options = give_get_settings(); |
1923 | 1921 | |
1924 | - if ( isset( $give_options['success_page'] ) && isset( $_GET['payment-confirmation'] ) && is_page( $give_options['success_page'] ) ) { |
|
1925 | - if ( has_filter( 'give_payment_confirm_' . $_GET['payment-confirmation'] ) ) { |
|
1926 | - $content = apply_filters( 'give_payment_confirm_' . $_GET['payment-confirmation'], $content ); |
|
1922 | + if (isset($give_options['success_page']) && isset($_GET['payment-confirmation']) && is_page($give_options['success_page'])) { |
|
1923 | + if (has_filter('give_payment_confirm_'.$_GET['payment-confirmation'])) { |
|
1924 | + $content = apply_filters('give_payment_confirm_'.$_GET['payment-confirmation'], $content); |
|
1927 | 1925 | } |
1928 | 1926 | } |
1929 | 1927 | |
1930 | 1928 | return $content; |
1931 | 1929 | } |
1932 | 1930 | |
1933 | -add_filter( 'the_content', 'give_filter_success_page_content' ); |
|
1931 | +add_filter('the_content', 'give_filter_success_page_content'); |
|
1934 | 1932 | |
1935 | 1933 | /** |
1936 | 1934 | * Test Mode Frontend Warning. |
@@ -1941,12 +1939,12 @@ discard block |
||
1941 | 1939 | */ |
1942 | 1940 | function give_test_mode_frontend_warning() { |
1943 | 1941 | |
1944 | - if ( give_is_test_mode() ) { |
|
1945 | - echo '<div class="give_error give_warning" id="give_error_test_mode"><p><strong>' . esc_html__( 'Notice:', 'give' ) . '</strong> ' . esc_html__( 'Test mode is enabled. While in test mode no live donations are processed.', 'give' ) . '</p></div>'; |
|
1942 | + if (give_is_test_mode()) { |
|
1943 | + echo '<div class="give_error give_warning" id="give_error_test_mode"><p><strong>'.esc_html__('Notice:', 'give').'</strong> '.esc_html__('Test mode is enabled. While in test mode no live donations are processed.', 'give').'</p></div>'; |
|
1946 | 1944 | } |
1947 | 1945 | } |
1948 | 1946 | |
1949 | -add_action( 'give_pre_form', 'give_test_mode_frontend_warning', 10 ); |
|
1947 | +add_action('give_pre_form', 'give_test_mode_frontend_warning', 10); |
|
1950 | 1948 | |
1951 | 1949 | /** |
1952 | 1950 | * Members-only Form. |
@@ -1960,21 +1958,21 @@ discard block |
||
1960 | 1958 | * |
1961 | 1959 | * @return string |
1962 | 1960 | */ |
1963 | -function give_members_only_form( $final_output, $args ) { |
|
1961 | +function give_members_only_form($final_output, $args) { |
|
1964 | 1962 | |
1965 | - $form_id = isset( $args['form_id'] ) ? $args['form_id'] : 0; |
|
1963 | + $form_id = isset($args['form_id']) ? $args['form_id'] : 0; |
|
1966 | 1964 | |
1967 | 1965 | //Sanity Check: Must have form_id & not be logged in. |
1968 | - if ( empty( $form_id ) || is_user_logged_in() ) { |
|
1966 | + if (empty($form_id) || is_user_logged_in()) { |
|
1969 | 1967 | return $final_output; |
1970 | 1968 | } |
1971 | 1969 | |
1972 | 1970 | //Logged in only and Register / Login set to none. |
1973 | - if ( give_logged_in_only( $form_id ) && give_show_login_register_option( $form_id ) == 'none' ) { |
|
1971 | + if (give_logged_in_only($form_id) && give_show_login_register_option($form_id) == 'none') { |
|
1974 | 1972 | |
1975 | - $final_output = Give()->notices->print_frontend_notice( esc_html__( 'Please log in in order to complete your donation.', 'give' ), false ); |
|
1973 | + $final_output = Give()->notices->print_frontend_notice(esc_html__('Please log in in order to complete your donation.', 'give'), false); |
|
1976 | 1974 | |
1977 | - return apply_filters( 'give_members_only_output', $final_output, $form_id ); |
|
1975 | + return apply_filters('give_members_only_output', $final_output, $form_id); |
|
1978 | 1976 | |
1979 | 1977 | } |
1980 | 1978 | |
@@ -1982,7 +1980,7 @@ discard block |
||
1982 | 1980 | |
1983 | 1981 | } |
1984 | 1982 | |
1985 | -add_filter( 'give_donate_form', 'give_members_only_form', 10, 2 ); |
|
1983 | +add_filter('give_donate_form', 'give_members_only_form', 10, 2); |
|
1986 | 1984 | |
1987 | 1985 | |
1988 | 1986 | /** |
@@ -1994,45 +1992,45 @@ discard block |
||
1994 | 1992 | * @param array $args |
1995 | 1993 | * @param Give_Donate_Form $form |
1996 | 1994 | */ |
1997 | -function __give_form_add_donation_hidden_field( $form_id, $args, $form ) { |
|
1998 | - $id_prefix = ! empty( $args['id_prefix'] ) ? $args['id_prefix'] : ''; |
|
1995 | +function __give_form_add_donation_hidden_field($form_id, $args, $form) { |
|
1996 | + $id_prefix = ! empty($args['id_prefix']) ? $args['id_prefix'] : ''; |
|
1999 | 1997 | ?> |
2000 | 1998 | <input type="hidden" name="give-form-id-prefix" value="<?php echo $id_prefix; ?>"/> |
2001 | - <input type="hidden" name="give-form-id" value="<?php echo intval( $form_id ); ?>"/> |
|
2002 | - <input type="hidden" name="give-form-title" value="<?php echo esc_html( $form->post_title ); ?>"/> |
|
2003 | - <input type="hidden" name="give-current-url" value="<?php echo esc_url( give_get_current_page_url() ); ?>"/> |
|
2004 | - <input type="hidden" name="give-form-url" value="<?php echo esc_url( give_get_current_page_url() ); ?>"/> |
|
1999 | + <input type="hidden" name="give-form-id" value="<?php echo intval($form_id); ?>"/> |
|
2000 | + <input type="hidden" name="give-form-title" value="<?php echo esc_html($form->post_title); ?>"/> |
|
2001 | + <input type="hidden" name="give-current-url" value="<?php echo esc_url(give_get_current_page_url()); ?>"/> |
|
2002 | + <input type="hidden" name="give-form-url" value="<?php echo esc_url(give_get_current_page_url()); ?>"/> |
|
2005 | 2003 | <?php |
2006 | 2004 | // Get the custom option amount. |
2007 | - $custom_amount = give_get_meta( $form_id, '_give_custom_amount', true ); |
|
2005 | + $custom_amount = give_get_meta($form_id, '_give_custom_amount', true); |
|
2008 | 2006 | |
2009 | 2007 | // If custom amount enabled. |
2010 | - if ( give_is_setting_enabled( $custom_amount ) ) { |
|
2008 | + if (give_is_setting_enabled($custom_amount)) { |
|
2011 | 2009 | ?> |
2012 | 2010 | <input type="hidden" name="give-form-minimum" |
2013 | - value="<?php echo give_maybe_sanitize_amount( give_get_form_minimum_price( $form_id ) ); ?>"/> |
|
2011 | + value="<?php echo give_maybe_sanitize_amount(give_get_form_minimum_price($form_id)); ?>"/> |
|
2014 | 2012 | <input type="hidden" name="give-form-maximum" |
2015 | - value="<?php echo give_maybe_sanitize_amount( give_get_form_maximum_price( $form_id ) ); ?>"/> |
|
2013 | + value="<?php echo give_maybe_sanitize_amount(give_get_form_maximum_price($form_id)); ?>"/> |
|
2016 | 2014 | <?php |
2017 | 2015 | } |
2018 | 2016 | |
2019 | 2017 | // WP nonce field. |
2020 | 2018 | echo str_replace( |
2021 | 2019 | '/>', |
2022 | - 'data-time="' . time() . '" data-nonce-life="' . give_get_nonce_life() . '"/>', |
|
2023 | - give_get_nonce_field( "give_donation_form_nonce_{$form_id}", 'give-form-hash', false ) |
|
2020 | + 'data-time="'.time().'" data-nonce-life="'.give_get_nonce_life().'"/>', |
|
2021 | + give_get_nonce_field("give_donation_form_nonce_{$form_id}", 'give-form-hash', false) |
|
2024 | 2022 | ); |
2025 | 2023 | |
2026 | 2024 | // Price ID hidden field for variable (multi-level) donation forms. |
2027 | - if ( give_has_variable_prices( $form_id ) ) { |
|
2025 | + if (give_has_variable_prices($form_id)) { |
|
2028 | 2026 | |
2029 | 2027 | // Get default selected price ID. |
2030 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
2028 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
2031 | 2029 | $price_id = 0; |
2032 | 2030 | |
2033 | 2031 | // Loop through prices. |
2034 | - foreach ( $prices as $price ) { |
|
2035 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
2032 | + foreach ($prices as $price) { |
|
2033 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
2036 | 2034 | $price_id = $price['_give_id']['level_id']; |
2037 | 2035 | }; |
2038 | 2036 | } |
@@ -2045,7 +2043,7 @@ discard block |
||
2045 | 2043 | } |
2046 | 2044 | } |
2047 | 2045 | |
2048 | -add_action( 'give_donation_form_top', '__give_form_add_donation_hidden_field', 0, 3 ); |
|
2046 | +add_action('give_donation_form_top', '__give_form_add_donation_hidden_field', 0, 3); |
|
2049 | 2047 | |
2050 | 2048 | /** |
2051 | 2049 | * Add currency settings on donation form. |
@@ -2057,20 +2055,20 @@ discard block |
||
2057 | 2055 | * |
2058 | 2056 | * @return array |
2059 | 2057 | */ |
2060 | -function __give_form_add_currency_settings( $form_html_tags, $form ) { |
|
2061 | - $form_currency = give_get_currency( $form->ID ); |
|
2062 | - $currency_settings = give_get_currency_formatting_settings( $form_currency ); |
|
2058 | +function __give_form_add_currency_settings($form_html_tags, $form) { |
|
2059 | + $form_currency = give_get_currency($form->ID); |
|
2060 | + $currency_settings = give_get_currency_formatting_settings($form_currency); |
|
2063 | 2061 | |
2064 | 2062 | // Check if currency exist. |
2065 | - if ( empty( $currency_settings ) ) { |
|
2063 | + if (empty($currency_settings)) { |
|
2066 | 2064 | return $form_html_tags; |
2067 | 2065 | } |
2068 | 2066 | |
2069 | - $form_html_tags['data-currency_symbol'] = give_currency_symbol( $form_currency ); |
|
2067 | + $form_html_tags['data-currency_symbol'] = give_currency_symbol($form_currency); |
|
2070 | 2068 | $form_html_tags['data-currency_code'] = $form_currency; |
2071 | 2069 | |
2072 | - if ( ! empty( $currency_settings ) ) { |
|
2073 | - foreach ( $currency_settings as $key => $value ) { |
|
2070 | + if ( ! empty($currency_settings)) { |
|
2071 | + foreach ($currency_settings as $key => $value) { |
|
2074 | 2072 | $form_html_tags["data-{$key}"] = $value; |
2075 | 2073 | } |
2076 | 2074 | } |
@@ -2078,7 +2076,7 @@ discard block |
||
2078 | 2076 | return $form_html_tags; |
2079 | 2077 | } |
2080 | 2078 | |
2081 | -add_filter( 'give_form_html_tags', '__give_form_add_currency_settings', 0, 2 ); |
|
2079 | +add_filter('give_form_html_tags', '__give_form_add_currency_settings', 0, 2); |
|
2082 | 2080 | |
2083 | 2081 | /** |
2084 | 2082 | * Adds classes to progress bar container. |
@@ -2089,7 +2087,7 @@ discard block |
||
2089 | 2087 | * |
2090 | 2088 | * @return string |
2091 | 2089 | */ |
2092 | -function add_give_goal_progress_class( $class_goal ) { |
|
2090 | +function add_give_goal_progress_class($class_goal) { |
|
2093 | 2091 | $class_goal = 'progress progress-striped active'; |
2094 | 2092 | |
2095 | 2093 | return $class_goal; |
@@ -2104,7 +2102,7 @@ discard block |
||
2104 | 2102 | * |
2105 | 2103 | * @return string |
2106 | 2104 | */ |
2107 | -function add_give_goal_progress_bar_class( $class_bar ) { |
|
2105 | +function add_give_goal_progress_bar_class($class_bar) { |
|
2108 | 2106 | $class_bar = 'bar'; |
2109 | 2107 | |
2110 | 2108 | return $class_bar; |
@@ -2121,12 +2119,12 @@ discard block |
||
2121 | 2119 | * |
2122 | 2120 | * @return array |
2123 | 2121 | */ |
2124 | -function add_class_for_form_grid( $class, $id, $args ) { |
|
2122 | +function add_class_for_form_grid($class, $id, $args) { |
|
2125 | 2123 | $class[] = 'give-form-grid-wrap'; |
2126 | 2124 | |
2127 | - foreach ( $class as $index => $item ) { |
|
2128 | - if( false !== strpos( $item, 'give-display-' ) ) { |
|
2129 | - unset( $class[$index] ); |
|
2125 | + foreach ($class as $index => $item) { |
|
2126 | + if (false !== strpos($item, 'give-display-')) { |
|
2127 | + unset($class[$index]); |
|
2130 | 2128 | } |
2131 | 2129 | } |
2132 | 2130 | |
@@ -2142,7 +2140,7 @@ discard block |
||
2142 | 2140 | * |
2143 | 2141 | * @since 2.1 |
2144 | 2142 | */ |
2145 | -function give_is_form_grid_page_hidden_field( $id, $args, $form ) { |
|
2143 | +function give_is_form_grid_page_hidden_field($id, $args, $form) { |
|
2146 | 2144 | echo '<input type="hidden" name="is-form-grid" value="true" />'; |
2147 | 2145 | } |
2148 | 2146 | |
@@ -2157,28 +2155,28 @@ discard block |
||
2157 | 2155 | * @since 2.1 |
2158 | 2156 | * @return string |
2159 | 2157 | */ |
2160 | -function give_redirect_and_popup_form( $redirect, $args ) { |
|
2158 | +function give_redirect_and_popup_form($redirect, $args) { |
|
2161 | 2159 | |
2162 | 2160 | // Check the page has Form Grid. |
2163 | - $is_form_grid = isset( $_POST['is-form-grid'] ) ? give_clean( $_POST['is-form-grid'] ) : ''; |
|
2161 | + $is_form_grid = isset($_POST['is-form-grid']) ? give_clean($_POST['is-form-grid']) : ''; |
|
2164 | 2162 | |
2165 | - if ( 'true' === $is_form_grid ) { |
|
2163 | + if ('true' === $is_form_grid) { |
|
2166 | 2164 | |
2167 | - $payment_mode = give_clean( $_POST['payment-mode'] ); |
|
2165 | + $payment_mode = give_clean($_POST['payment-mode']); |
|
2168 | 2166 | $form_id = $args['form-id']; |
2169 | 2167 | |
2170 | 2168 | // Get the URL without Query parameters. |
2171 | - $redirect = strtok( $redirect, '?' ); |
|
2169 | + $redirect = strtok($redirect, '?'); |
|
2172 | 2170 | |
2173 | 2171 | // Add query parameters 'form-id' and 'payment-mode'. |
2174 | - $redirect = add_query_arg( array( |
|
2172 | + $redirect = add_query_arg(array( |
|
2175 | 2173 | 'form-id' => $form_id, |
2176 | 2174 | 'payment-mode' => $payment_mode, |
2177 | - ), $redirect ); |
|
2175 | + ), $redirect); |
|
2178 | 2176 | } |
2179 | 2177 | |
2180 | 2178 | // Return the modified URL. |
2181 | 2179 | return $redirect; |
2182 | 2180 | } |
2183 | 2181 | |
2184 | -add_filter( 'give_send_back_to_checkout', 'give_redirect_and_popup_form', 10, 2 ); |
|
2182 | +add_filter('give_send_back_to_checkout', 'give_redirect_and_popup_form', 10, 2); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @since 1.0 |
21 | 21 | * @return void |
22 | 22 | */ |
23 | -add_action( 'give_manual_cc_form', '__return_false' ); |
|
23 | +add_action('give_manual_cc_form', '__return_false'); |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Processes the donation data and uses the Manual Payment gateway to record |
@@ -32,44 +32,44 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @return void |
34 | 34 | */ |
35 | -function give_manual_payment( $purchase_data ) { |
|
35 | +function give_manual_payment($purchase_data) { |
|
36 | 36 | |
37 | - if ( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'give-gateway' ) ) { |
|
38 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
37 | + if ( ! wp_verify_nonce($purchase_data['gateway_nonce'], 'give-gateway')) { |
|
38 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | //Create payment_data array |
42 | 42 | $payment_data = array( |
43 | 43 | 'price' => $purchase_data['price'], |
44 | 44 | 'give_form_title' => $purchase_data['post_data']['give-form-title'], |
45 | - 'give_form_id' => intval( $purchase_data['post_data']['give-form-id'] ), |
|
45 | + 'give_form_id' => intval($purchase_data['post_data']['give-form-id']), |
|
46 | 46 | 'give_price_id' => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '', |
47 | 47 | 'date' => $purchase_data['date'], |
48 | 48 | 'user_email' => $purchase_data['user_email'], |
49 | 49 | 'purchase_key' => $purchase_data['purchase_key'], |
50 | - 'currency' => give_get_currency( $purchase_data['post_data']['give-form-id'], $purchase_data ), |
|
50 | + 'currency' => give_get_currency($purchase_data['post_data']['give-form-id'], $purchase_data), |
|
51 | 51 | 'user_info' => $purchase_data['user_info'], |
52 | 52 | 'status' => 'pending' |
53 | 53 | ); |
54 | 54 | // Record the pending payment |
55 | - $payment = give_insert_payment( $payment_data ); |
|
55 | + $payment = give_insert_payment($payment_data); |
|
56 | 56 | |
57 | - if ( $payment ) { |
|
58 | - give_update_payment_status( $payment, 'publish' ); |
|
57 | + if ($payment) { |
|
58 | + give_update_payment_status($payment, 'publish'); |
|
59 | 59 | give_send_to_success_page(); |
60 | 60 | } else { |
61 | 61 | give_record_gateway_error( |
62 | - esc_html__( 'Payment Error', 'give' ), |
|
62 | + esc_html__('Payment Error', 'give'), |
|
63 | 63 | sprintf( |
64 | 64 | /* translators: %s: payment data */ |
65 | - esc_html__( 'The payment creation failed while processing a manual (free or test) donation. Payment data: %s', 'give' ), |
|
66 | - json_encode( $payment_data ) |
|
65 | + esc_html__('The payment creation failed while processing a manual (free or test) donation. Payment data: %s', 'give'), |
|
66 | + json_encode($payment_data) |
|
67 | 67 | ), |
68 | 68 | $payment |
69 | 69 | ); |
70 | 70 | // If errors are present, send the user back to the donation page so they can be corrected |
71 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
71 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
75 | -add_action( 'give_gateway_manual', 'give_manual_payment' ); |
|
75 | +add_action('give_gateway_manual', 'give_manual_payment'); |
@@ -258,7 +258,7 @@ |
||
258 | 258 | * @access public |
259 | 259 | * @since 1.0 |
260 | 260 | * |
261 | - * @return mixed string If search is present, false otherwise. |
|
261 | + * @return string|false string If search is present, false otherwise. |
|
262 | 262 | */ |
263 | 263 | public function get_search() { |
264 | 264 | return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
@@ -12,13 +12,13 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
19 | 19 | // Load WP_List_Table if not loaded. |
20 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
21 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
20 | +if ( ! class_exists('WP_List_Table')) { |
|
21 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | public function __construct() { |
62 | 62 | |
63 | 63 | // Set parent defaults. |
64 | - parent::__construct( array( |
|
65 | - 'singular' => __( 'Donor', 'give' ), // Singular name of the listed records. |
|
66 | - 'plural' => __( 'Donors', 'give' ), // Plural name of the listed records. |
|
64 | + parent::__construct(array( |
|
65 | + 'singular' => __('Donor', 'give'), // Singular name of the listed records. |
|
66 | + 'plural' => __('Donors', 'give'), // Plural name of the listed records. |
|
67 | 67 | 'ajax' => false, // Does this table support ajax?. |
68 | - ) ); |
|
68 | + )); |
|
69 | 69 | |
70 | 70 | } |
71 | 71 | |
@@ -80,23 +80,23 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return void |
82 | 82 | */ |
83 | - public function search_box( $text, $input_id ) { |
|
84 | - $input_id = $input_id . '-search-input'; |
|
83 | + public function search_box($text, $input_id) { |
|
84 | + $input_id = $input_id.'-search-input'; |
|
85 | 85 | |
86 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
87 | - echo sprintf( '<input type="hidden" name="orderby" value="%1$s" />', esc_attr( $_REQUEST['orderby'] ) ); |
|
86 | + if ( ! empty($_REQUEST['orderby'])) { |
|
87 | + echo sprintf('<input type="hidden" name="orderby" value="%1$s" />', esc_attr($_REQUEST['orderby'])); |
|
88 | 88 | } |
89 | 89 | |
90 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
91 | - echo sprintf( '<input type="hidden" name="order" value="%1$s" />', esc_attr( $_REQUEST['order'] ) ); |
|
90 | + if ( ! empty($_REQUEST['order'])) { |
|
91 | + echo sprintf('<input type="hidden" name="order" value="%1$s" />', esc_attr($_REQUEST['order'])); |
|
92 | 92 | } |
93 | 93 | ?> |
94 | 94 | <p class="search-box" role="search"> |
95 | 95 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
96 | 96 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>"/> |
97 | - <?php submit_button( $text, 'button', false, false, array( |
|
97 | + <?php submit_button($text, 'button', false, false, array( |
|
98 | 98 | 'ID' => 'search-submit', |
99 | - ) ); ?> |
|
99 | + )); ?> |
|
100 | 100 | </p> |
101 | 101 | <?php |
102 | 102 | } |
@@ -112,32 +112,32 @@ discard block |
||
112 | 112 | * |
113 | 113 | * @return string Column Name. |
114 | 114 | */ |
115 | - public function column_default( $donor, $column_name ) { |
|
115 | + public function column_default($donor, $column_name) { |
|
116 | 116 | |
117 | - switch ( $column_name ) { |
|
117 | + switch ($column_name) { |
|
118 | 118 | |
119 | 119 | case 'num_donations' : |
120 | 120 | $value = sprintf( |
121 | 121 | '<a href="%s">%s</a>', |
122 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( $donor['id'] ) ), |
|
123 | - esc_html( $donor['num_donations'] ) |
|
122 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&donor='.absint($donor['id'])), |
|
123 | + esc_html($donor['num_donations']) |
|
124 | 124 | ); |
125 | 125 | break; |
126 | 126 | |
127 | 127 | case 'amount_spent' : |
128 | - $value = give_currency_filter( give_format_amount( $donor[ $column_name ], array( 'sanitize' => false ) ) ); |
|
128 | + $value = give_currency_filter(give_format_amount($donor[$column_name], array('sanitize' => false))); |
|
129 | 129 | break; |
130 | 130 | |
131 | 131 | case 'date_created' : |
132 | - $value = date_i18n( give_date_format(), strtotime( $donor['date_created'] ) ); |
|
132 | + $value = date_i18n(give_date_format(), strtotime($donor['date_created'])); |
|
133 | 133 | break; |
134 | 134 | |
135 | 135 | default: |
136 | - $value = isset( $donor[ $column_name ] ) ? $donor[ $column_name ] : null; |
|
136 | + $value = isset($donor[$column_name]) ? $donor[$column_name] : null; |
|
137 | 137 | break; |
138 | 138 | } |
139 | 139 | |
140 | - return apply_filters( "give_donors_column_{$column_name}", $value, $donor['id'] ); |
|
140 | + return apply_filters("give_donors_column_{$column_name}", $value, $donor['id']); |
|
141 | 141 | |
142 | 142 | } |
143 | 143 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * |
152 | 152 | * @return string |
153 | 153 | */ |
154 | - public function column_cb( $donor ){ |
|
154 | + public function column_cb($donor) { |
|
155 | 155 | return sprintf( |
156 | 156 | '<input class="donor-selector" type="checkbox" name="%1$s[]" value="%2$d" data-name="%3$s" />', |
157 | 157 | $this->_args['singular'], |
@@ -170,12 +170,12 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @return string |
172 | 172 | */ |
173 | - public function column_name( $donor ) { |
|
174 | - $name = ! empty( $donor['name'] ) ? $donor['name'] : '<em>' . __( 'Unnamed Donor', 'give' ) . '</em>'; |
|
175 | - $view_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor['id'] ); |
|
176 | - $actions = $this->get_row_actions( $donor ); |
|
173 | + public function column_name($donor) { |
|
174 | + $name = ! empty($donor['name']) ? $donor['name'] : '<em>'.__('Unnamed Donor', 'give').'</em>'; |
|
175 | + $view_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor['id']); |
|
176 | + $actions = $this->get_row_actions($donor); |
|
177 | 177 | |
178 | - return '<a href="' . esc_url( $view_url ) . '">' . $name . '</a>' . $this->row_actions( $actions ); |
|
178 | + return '<a href="'.esc_url($view_url).'">'.$name.'</a>'.$this->row_actions($actions); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -189,14 +189,14 @@ discard block |
||
189 | 189 | public function get_columns() { |
190 | 190 | $columns = array( |
191 | 191 | 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text. |
192 | - 'name' => __( 'Name', 'give' ), |
|
193 | - 'email' => __( 'Email', 'give' ), |
|
194 | - 'num_donations' => __( 'Donations', 'give' ), |
|
195 | - 'amount_spent' => __( 'Total Donated', 'give' ), |
|
196 | - 'date_created' => __( 'Date Created', 'give' ), |
|
192 | + 'name' => __('Name', 'give'), |
|
193 | + 'email' => __('Email', 'give'), |
|
194 | + 'num_donations' => __('Donations', 'give'), |
|
195 | + 'amount_spent' => __('Total Donated', 'give'), |
|
196 | + 'date_created' => __('Date Created', 'give'), |
|
197 | 197 | ); |
198 | 198 | |
199 | - return apply_filters( 'give_list_donors_columns', $columns ); |
|
199 | + return apply_filters('give_list_donors_columns', $columns); |
|
200 | 200 | |
201 | 201 | } |
202 | 202 | |
@@ -210,13 +210,13 @@ discard block |
||
210 | 210 | public function get_sortable_columns() { |
211 | 211 | |
212 | 212 | $columns = array( |
213 | - 'date_created' => array( 'date_created', true ), |
|
214 | - 'name' => array( 'name', true ), |
|
215 | - 'num_donations' => array( 'purchase_count', false ), |
|
216 | - 'amount_spent' => array( 'purchase_value', false ), |
|
213 | + 'date_created' => array('date_created', true), |
|
214 | + 'name' => array('name', true), |
|
215 | + 'num_donations' => array('purchase_count', false), |
|
216 | + 'amount_spent' => array('purchase_value', false), |
|
217 | 217 | ); |
218 | 218 | |
219 | - return apply_filters( 'give_list_donors_sortable_columns', $columns ); |
|
219 | + return apply_filters('give_list_donors_sortable_columns', $columns); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
@@ -229,15 +229,15 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @return array An array of action links. |
231 | 231 | */ |
232 | - public function get_row_actions( $donor ) { |
|
232 | + public function get_row_actions($donor) { |
|
233 | 233 | |
234 | 234 | $actions = array( |
235 | - 'view' => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor['id'] ), sprintf( esc_attr__( 'View "%s"', 'give' ), $donor['name'] ), __( 'View Donor', 'give' ) ), |
|
236 | - 'notes' => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $donor['id'] ), sprintf( esc_attr__( 'Notes for "%s"', 'give' ), $donor['name'] ), __( 'Notes', 'give' ) ), |
|
237 | - 'delete' => sprintf( '<a class="%1$s" data-id="%2$s" href="#" aria-label="%3$s">%4$s</a>', 'give-single-donor-delete', $donor['id'],sprintf( esc_attr__( 'Delete "%s"', 'give' ), $donor['name'] ), __( 'Delete', 'give' ) ), |
|
235 | + 'view' => sprintf('<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor['id']), sprintf(esc_attr__('View "%s"', 'give'), $donor['name']), __('View Donor', 'give')), |
|
236 | + 'notes' => sprintf('<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url('edit.php?post_type=give_forms&page=give-donors&view=notes&id='.$donor['id']), sprintf(esc_attr__('Notes for "%s"', 'give'), $donor['name']), __('Notes', 'give')), |
|
237 | + 'delete' => sprintf('<a class="%1$s" data-id="%2$s" href="#" aria-label="%3$s">%4$s</a>', 'give-single-donor-delete', $donor['id'], sprintf(esc_attr__('Delete "%s"', 'give'), $donor['name']), __('Delete', 'give')), |
|
238 | 238 | ); |
239 | 239 | |
240 | - return apply_filters( 'give_donor_row_actions', $actions, $donor ); |
|
240 | + return apply_filters('give_donor_row_actions', $actions, $donor); |
|
241 | 241 | |
242 | 242 | } |
243 | 243 | |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * @return int Current page number. |
251 | 251 | */ |
252 | 252 | public function get_paged() { |
253 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
253 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | /** |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | * @return mixed string If search is present, false otherwise. |
263 | 263 | */ |
264 | 264 | public function get_search() { |
265 | - return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
|
265 | + return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false; |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | */ |
276 | 276 | public function get_bulk_actions() { |
277 | 277 | $actions = array( |
278 | - 'delete' => __( 'Delete', 'give' ), |
|
278 | + 'delete' => __('Delete', 'give'), |
|
279 | 279 | ); |
280 | 280 | return $actions; |
281 | 281 | } |
@@ -288,19 +288,19 @@ discard block |
||
288 | 288 | * @access protected |
289 | 289 | * @since 1.8.16 |
290 | 290 | */ |
291 | - protected function display_tablenav( $which ) { |
|
292 | - if ( 'top' === $which ) { |
|
293 | - wp_nonce_field( 'bulk-' . $this->_args['plural'], '_wpnonce', false ); |
|
291 | + protected function display_tablenav($which) { |
|
292 | + if ('top' === $which) { |
|
293 | + wp_nonce_field('bulk-'.$this->_args['plural'], '_wpnonce', false); |
|
294 | 294 | } |
295 | 295 | ?> |
296 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
297 | - <?php if ( $this->has_items() ): ?> |
|
296 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
297 | + <?php if ($this->has_items()): ?> |
|
298 | 298 | <div class="alignleft actions bulkactions"> |
299 | - <?php $this->bulk_actions( $which ); ?> |
|
299 | + <?php $this->bulk_actions($which); ?> |
|
300 | 300 | </div> |
301 | 301 | <?php endif; |
302 | - $this->extra_tablenav( $which ); |
|
303 | - $this->pagination( $which ); |
|
302 | + $this->extra_tablenav($which); |
|
303 | + $this->pagination($which); |
|
304 | 304 | ?> |
305 | 305 | <br class="clear" /> |
306 | 306 | </div> |
@@ -321,13 +321,13 @@ discard block |
||
321 | 321 | |
322 | 322 | // Get donor query. |
323 | 323 | $args = $this->get_donor_query(); |
324 | - $donors = Give()->donors->get_donors( $args ); |
|
324 | + $donors = Give()->donors->get_donors($args); |
|
325 | 325 | |
326 | - if ( $donors ) { |
|
326 | + if ($donors) { |
|
327 | 327 | |
328 | - foreach ( $donors as $donor ) { |
|
328 | + foreach ($donors as $donor) { |
|
329 | 329 | |
330 | - $user_id = ! empty( $donor->user_id ) ? intval( $donor->user_id ) : 0; |
|
330 | + $user_id = ! empty($donor->user_id) ? intval($donor->user_id) : 0; |
|
331 | 331 | |
332 | 332 | $data[] = array( |
333 | 333 | 'id' => $donor->id, |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | } |
342 | 342 | } |
343 | 343 | |
344 | - return apply_filters( 'give_donors_column_query_data', $data ); |
|
344 | + return apply_filters('give_donors_column_query_data', $data); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | /** |
@@ -356,9 +356,9 @@ discard block |
||
356 | 356 | |
357 | 357 | $_donor_query['number'] = - 1; |
358 | 358 | $_donor_query['offset'] = 0; |
359 | - $donors = Give()->donors->get_donors( $_donor_query ); |
|
359 | + $donors = Give()->donors->get_donors($_donor_query); |
|
360 | 360 | |
361 | - return count( $donors ); |
|
361 | + return count($donors); |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | /** |
@@ -371,10 +371,10 @@ discard block |
||
371 | 371 | */ |
372 | 372 | public function get_donor_query() { |
373 | 373 | $paged = $this->get_paged(); |
374 | - $offset = $this->per_page * ( $paged - 1 ); |
|
374 | + $offset = $this->per_page * ($paged - 1); |
|
375 | 375 | $search = $this->get_search(); |
376 | - $order = isset( $_GET['order'] ) ? sanitize_text_field( $_GET['order'] ) : 'DESC'; |
|
377 | - $orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( $_GET['orderby'] ) : 'id'; |
|
376 | + $order = isset($_GET['order']) ? sanitize_text_field($_GET['order']) : 'DESC'; |
|
377 | + $orderby = isset($_GET['orderby']) ? sanitize_text_field($_GET['orderby']) : 'id'; |
|
378 | 378 | |
379 | 379 | $args = array( |
380 | 380 | 'number' => $this->per_page, |
@@ -383,10 +383,10 @@ discard block |
||
383 | 383 | 'orderby' => $orderby, |
384 | 384 | ); |
385 | 385 | |
386 | - if ( $search ) { |
|
387 | - if ( is_email( $search ) ) { |
|
386 | + if ($search) { |
|
387 | + if (is_email($search)) { |
|
388 | 388 | $args['email'] = $search; |
389 | - } elseif ( is_numeric( $search ) ) { |
|
389 | + } elseif (is_numeric($search)) { |
|
390 | 390 | $args['id'] = $search; |
391 | 391 | } else { |
392 | 392 | $args['name'] = $search; |
@@ -404,9 +404,9 @@ discard block |
||
404 | 404 | * @since 1.8.17 |
405 | 405 | * @access public |
406 | 406 | */ |
407 | - public function single_row( $item ) { |
|
408 | - echo sprintf( '<tr id="donor-%1$d" data-id="%2$d" data-name="%3$s">', $item['id'], $item['id'], $item['name'] ); |
|
409 | - $this->single_row_columns( $item ); |
|
407 | + public function single_row($item) { |
|
408 | + echo sprintf('<tr id="donor-%1$d" data-id="%2$d" data-name="%3$s">', $item['id'], $item['id'], $item['name']); |
|
409 | + $this->single_row_columns($item); |
|
410 | 410 | echo '</tr>'; |
411 | 411 | } |
412 | 412 | |
@@ -419,11 +419,11 @@ discard block |
||
419 | 419 | public function display() { |
420 | 420 | $singular = $this->_args['singular']; |
421 | 421 | |
422 | - $this->display_tablenav( 'top' ); |
|
422 | + $this->display_tablenav('top'); |
|
423 | 423 | |
424 | - $this->screen->render_screen_reader_content( 'heading_list' ); |
|
424 | + $this->screen->render_screen_reader_content('heading_list'); |
|
425 | 425 | ?> |
426 | - <table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>"> |
|
426 | + <table class="wp-list-table <?php echo implode(' ', $this->get_table_classes()); ?>"> |
|
427 | 427 | <thead> |
428 | 428 | <tr> |
429 | 429 | <?php $this->print_column_headers(); ?> |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | </thead> |
432 | 432 | |
433 | 433 | <tbody id="the-list"<?php |
434 | - if ( $singular ) { |
|
434 | + if ($singular) { |
|
435 | 435 | echo " data-wp-lists='list:$singular'"; |
436 | 436 | } ?>> |
437 | 437 | <tr class="hidden"></tr> |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | <td colspan="6" class="colspanchange"> |
440 | 440 | |
441 | 441 | <fieldset class="inline-edit-col-left"> |
442 | - <legend class="inline-edit-legend"><?php _e( 'BULK DELETE', 'give' ); ?></legend> |
|
442 | + <legend class="inline-edit-legend"><?php _e('BULK DELETE', 'give'); ?></legend> |
|
443 | 443 | <div class="inline-edit-col"> |
444 | 444 | <div id="bulk-titles"> |
445 | 445 | <div id="give-bulk-donors" class="give-bulk-donors"> |
@@ -452,22 +452,22 @@ discard block |
||
452 | 452 | <div class="inline-edit-col"> |
453 | 453 | <label> |
454 | 454 | <input id="give-delete-donor-confirm" type="checkbox" name="give-delete-donor-confirm"/> |
455 | - <?php _e( 'Are you sure you want to delete the selected donor(s)?', 'give' ); ?> |
|
455 | + <?php _e('Are you sure you want to delete the selected donor(s)?', 'give'); ?> |
|
456 | 456 | </label> |
457 | 457 | <label> |
458 | 458 | <input id="give-delete-donor-records" type="checkbox" name="give-delete-donor-records"/> |
459 | - <?php _e( 'Delete all associated donations and records?', 'give' ); ?> |
|
459 | + <?php _e('Delete all associated donations and records?', 'give'); ?> |
|
460 | 460 | </label> |
461 | 461 | </div> |
462 | 462 | </fieldset> |
463 | 463 | |
464 | 464 | <p class="submit inline-edit-save"> |
465 | 465 | <input type="hidden" name="give_action" value="delete_donor"/> |
466 | - <input type="hidden" name="s" value="<?php echo ( ! empty( $_GET['s'] ) ) ? $_GET['s'] : ''; ?>"/> |
|
467 | - <input type="hidden" name="orderby" value="<?php echo ( ! empty( $_GET['orderby'] ) ) ? $_GET['orderby'] : 'id'; ?>"/> |
|
468 | - <input type="hidden" name="order" value="<?php echo ( ! empty( $_GET['order'] ) ) ? $_GET['order'] : 'desc'; ?>"/> |
|
469 | - <button type="button" id="give-bulk-delete-cancel" class="button cancel alignleft"><?php _e( 'Cancel', 'give' ); ?></button> |
|
470 | - <input type="submit" id="give-bulk-delete-button" disabled class="button button-primary alignright" value="<?php _e( 'Delete', 'give' ); ?>"> |
|
466 | + <input type="hidden" name="s" value="<?php echo ( ! empty($_GET['s'])) ? $_GET['s'] : ''; ?>"/> |
|
467 | + <input type="hidden" name="orderby" value="<?php echo ( ! empty($_GET['orderby'])) ? $_GET['orderby'] : 'id'; ?>"/> |
|
468 | + <input type="hidden" name="order" value="<?php echo ( ! empty($_GET['order'])) ? $_GET['order'] : 'desc'; ?>"/> |
|
469 | + <button type="button" id="give-bulk-delete-cancel" class="button cancel alignleft"><?php _e('Cancel', 'give'); ?></button> |
|
470 | + <input type="submit" id="give-bulk-delete-button" disabled class="button button-primary alignright" value="<?php _e('Delete', 'give'); ?>"> |
|
471 | 471 | <br class="clear"> |
472 | 472 | </p> |
473 | 473 | </td> |
@@ -477,13 +477,13 @@ discard block |
||
477 | 477 | |
478 | 478 | <tfoot> |
479 | 479 | <tr> |
480 | - <?php $this->print_column_headers( false ); ?> |
|
480 | + <?php $this->print_column_headers(false); ?> |
|
481 | 481 | </tr> |
482 | 482 | </tfoot> |
483 | 483 | |
484 | 484 | </table> |
485 | 485 | <?php |
486 | - $this->display_tablenav( 'bottom' ); |
|
486 | + $this->display_tablenav('bottom'); |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | /** |
@@ -500,16 +500,16 @@ discard block |
||
500 | 500 | $hidden = array(); // No hidden columns. |
501 | 501 | $sortable = $this->get_sortable_columns(); |
502 | 502 | |
503 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
503 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
504 | 504 | |
505 | 505 | $this->items = $this->donor_data(); |
506 | 506 | |
507 | 507 | $this->total = $this->get_donor_count(); |
508 | 508 | |
509 | - $this->set_pagination_args( array( |
|
509 | + $this->set_pagination_args(array( |
|
510 | 510 | 'total_items' => $this->total, |
511 | 511 | 'per_page' => $this->per_page, |
512 | - 'total_pages' => ceil( $this->total / $this->per_page ), |
|
513 | - ) ); |
|
512 | + 'total_pages' => ceil($this->total / $this->per_page), |
|
513 | + )); |
|
514 | 514 | } |
515 | 515 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @since 1.0 |
23 | 23 | * |
24 | - * @return array|bool $output Response messages |
|
24 | + * @return false|null $output Response messages |
|
25 | 25 | */ |
26 | 26 | function give_edit_donor( $args ) { |
27 | 27 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * |
228 | 228 | * @since 1.0 |
229 | 229 | * |
230 | - * @return int Whether it was a successful deletion. |
|
230 | + * @return false|null Whether it was a successful deletion. |
|
231 | 231 | */ |
232 | 232 | function give_donor_delete( $args ) { |
233 | 233 | |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | * |
522 | 522 | * @since 1.7 |
523 | 523 | * |
524 | - * @return bool|null |
|
524 | + * @return false|null |
|
525 | 525 | */ |
526 | 526 | function give_remove_donor_email() { |
527 | 527 | if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | * |
566 | 566 | * @since 1.7 |
567 | 567 | * |
568 | - * @return bool|null |
|
568 | + * @return false|null |
|
569 | 569 | */ |
570 | 570 | function give_set_donor_primary_email() { |
571 | 571 | if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
@@ -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 | |
@@ -23,33 +23,33 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return array|bool $output Response messages |
25 | 25 | */ |
26 | -function give_edit_donor( $args ) { |
|
26 | +function give_edit_donor($args) { |
|
27 | 27 | |
28 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
28 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
29 | 29 | |
30 | - if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) { |
|
31 | - wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array( |
|
30 | + if ( ! is_admin() || ! current_user_can($donor_edit_role)) { |
|
31 | + wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array( |
|
32 | 32 | 'response' => 403, |
33 | - ) ); |
|
33 | + )); |
|
34 | 34 | } |
35 | 35 | |
36 | - if ( empty( $args ) ) { |
|
36 | + if (empty($args)) { |
|
37 | 37 | return false; |
38 | 38 | } |
39 | 39 | |
40 | - $donor_info = give_clean( $args['customerinfo'] ); |
|
40 | + $donor_info = give_clean($args['customerinfo']); |
|
41 | 41 | $donor_id = (int) $args['customerinfo']['id']; |
42 | 42 | $nonce = $args['_wpnonce']; |
43 | 43 | |
44 | - if ( ! wp_verify_nonce( $nonce, 'edit-donor' ) ) { |
|
45 | - wp_die( __( 'Cheatin’ uh?', 'give' ), __( 'Error', 'give' ), array( |
|
44 | + if ( ! wp_verify_nonce($nonce, 'edit-donor')) { |
|
45 | + wp_die(__('Cheatin’ uh?', 'give'), __('Error', 'give'), array( |
|
46 | 46 | 'response' => 400, |
47 | - ) ); |
|
47 | + )); |
|
48 | 48 | } |
49 | 49 | |
50 | - $donor = new Give_Donor( $donor_id ); |
|
50 | + $donor = new Give_Donor($donor_id); |
|
51 | 51 | |
52 | - if ( empty( $donor->id ) ) { |
|
52 | + if (empty($donor->id)) { |
|
53 | 53 | return false; |
54 | 54 | } |
55 | 55 | |
@@ -64,39 +64,39 @@ discard block |
||
64 | 64 | 'country' => '', |
65 | 65 | ); |
66 | 66 | |
67 | - $donor_info = wp_parse_args( $donor_info, $defaults ); |
|
67 | + $donor_info = wp_parse_args($donor_info, $defaults); |
|
68 | 68 | |
69 | - if ( (int) $donor_info['user_id'] !== (int) $donor->user_id ) { |
|
69 | + if ((int) $donor_info['user_id'] !== (int) $donor->user_id) { |
|
70 | 70 | |
71 | 71 | // Make sure we don't already have this user attached to a donor. |
72 | - if ( ! empty( $donor_info['user_id'] ) && false !== Give()->donors->get_donor_by( 'user_id', $donor_info['user_id'] ) ) { |
|
73 | - give_set_error( 'give-invalid-donor-user_id', sprintf( __( 'The User ID #%d is already associated with a different donor.', 'give' ), $donor_info['user_id'] ) ); |
|
72 | + if ( ! empty($donor_info['user_id']) && false !== Give()->donors->get_donor_by('user_id', $donor_info['user_id'])) { |
|
73 | + give_set_error('give-invalid-donor-user_id', sprintf(__('The User ID #%d is already associated with a different donor.', 'give'), $donor_info['user_id'])); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | // Make sure it's actually a user. |
77 | - $user = get_user_by( 'id', $donor_info['user_id'] ); |
|
78 | - if ( ! empty( $donor_info['user_id'] ) && false === $user ) { |
|
79 | - give_set_error( 'give-invalid-user_id', sprintf( __( 'The User ID #%d does not exist. Please assign an existing user.', 'give' ), $donor_info['user_id'] ) ); |
|
77 | + $user = get_user_by('id', $donor_info['user_id']); |
|
78 | + if ( ! empty($donor_info['user_id']) && false === $user) { |
|
79 | + give_set_error('give-invalid-user_id', sprintf(__('The User ID #%d does not exist. Please assign an existing user.', 'give'), $donor_info['user_id'])); |
|
80 | 80 | } |
81 | 81 | } |
82 | 82 | |
83 | - if ( give_get_errors() ) { |
|
83 | + if (give_get_errors()) { |
|
84 | 84 | return false; |
85 | 85 | } |
86 | 86 | |
87 | 87 | // If First name of donor is empty, then fetch the current first name of donor. |
88 | - if ( empty( $donor_info['first_name'] ) ) { |
|
88 | + if (empty($donor_info['first_name'])) { |
|
89 | 89 | $donor_info['first_name'] = $donor->get_first_name(); |
90 | 90 | } |
91 | 91 | |
92 | 92 | // Sanitize the inputs. |
93 | 93 | $donor_data = array(); |
94 | - $donor_data['name'] = trim( "{$donor_info['first_name']} {$donor_info['last_name']}" ); |
|
94 | + $donor_data['name'] = trim("{$donor_info['first_name']} {$donor_info['last_name']}"); |
|
95 | 95 | $donor_data['first_name'] = $donor_info['first_name']; |
96 | 96 | $donor_data['last_name'] = $donor_info['last_name']; |
97 | 97 | $donor_data['user_id'] = $donor_info['user_id']; |
98 | 98 | |
99 | - $donor_data = apply_filters( 'give_edit_donor_info', $donor_data, $donor_id ); |
|
99 | + $donor_data = apply_filters('give_edit_donor_info', $donor_data, $donor_id); |
|
100 | 100 | |
101 | 101 | /** |
102 | 102 | * Filter the address |
@@ -104,28 +104,28 @@ discard block |
||
104 | 104 | * |
105 | 105 | * @since 1.0 |
106 | 106 | */ |
107 | - $address = apply_filters( 'give_edit_donor_address', array(), $donor_id ); |
|
107 | + $address = apply_filters('give_edit_donor_address', array(), $donor_id); |
|
108 | 108 | |
109 | - $donor_data = give_clean( $donor_data ); |
|
110 | - $address = give_clean( $address ); |
|
109 | + $donor_data = give_clean($donor_data); |
|
110 | + $address = give_clean($address); |
|
111 | 111 | |
112 | - $output = give_connect_user_donor_profile( $donor, $donor_data, $address ); |
|
112 | + $output = give_connect_user_donor_profile($donor, $donor_data, $address); |
|
113 | 113 | |
114 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
115 | - header( 'Content-Type: application/json' ); |
|
116 | - echo json_encode( $output ); |
|
114 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
115 | + header('Content-Type: application/json'); |
|
116 | + echo json_encode($output); |
|
117 | 117 | wp_die(); |
118 | 118 | } |
119 | 119 | |
120 | - if ( $output['success'] ) { |
|
121 | - wp_redirect( admin_url( "edit.php?post_type=give_forms&page=give-donors&view=overview&id={$donor_id}&give-messages[]=profile-updated" ) ); |
|
120 | + if ($output['success']) { |
|
121 | + wp_redirect(admin_url("edit.php?post_type=give_forms&page=give-donors&view=overview&id={$donor_id}&give-messages[]=profile-updated")); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | exit; |
125 | 125 | |
126 | 126 | } |
127 | 127 | |
128 | -add_action( 'give_edit-donor', 'give_edit_donor', 10, 1 ); |
|
128 | +add_action('give_edit-donor', 'give_edit_donor', 10, 1); |
|
129 | 129 | |
130 | 130 | /** |
131 | 131 | * Save a donor note. |
@@ -136,40 +136,40 @@ discard block |
||
136 | 136 | * |
137 | 137 | * @return int The Note ID that was saved, or 0 if nothing was saved. |
138 | 138 | */ |
139 | -function give_donor_save_note( $args ) { |
|
139 | +function give_donor_save_note($args) { |
|
140 | 140 | |
141 | - $donor_view_role = apply_filters( 'give_view_donors_role', 'view_give_reports' ); |
|
141 | + $donor_view_role = apply_filters('give_view_donors_role', 'view_give_reports'); |
|
142 | 142 | |
143 | - if ( ! is_admin() || ! current_user_can( $donor_view_role ) ) { |
|
144 | - wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array( |
|
143 | + if ( ! is_admin() || ! current_user_can($donor_view_role)) { |
|
144 | + wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array( |
|
145 | 145 | 'response' => 403, |
146 | - ) ); |
|
146 | + )); |
|
147 | 147 | } |
148 | 148 | |
149 | - if ( empty( $args ) ) { |
|
149 | + if (empty($args)) { |
|
150 | 150 | return false; |
151 | 151 | } |
152 | 152 | |
153 | - $donor_note = trim( give_clean( $args['donor_note'] ) ); |
|
153 | + $donor_note = trim(give_clean($args['donor_note'])); |
|
154 | 154 | $donor_id = (int) $args['customer_id']; |
155 | 155 | $nonce = $args['add_donor_note_nonce']; |
156 | 156 | |
157 | - if ( ! wp_verify_nonce( $nonce, 'add-donor-note' ) ) { |
|
158 | - wp_die( __( 'Cheatin’ uh?', 'give' ), __( 'Error', 'give' ), array( |
|
157 | + if ( ! wp_verify_nonce($nonce, 'add-donor-note')) { |
|
158 | + wp_die(__('Cheatin’ uh?', 'give'), __('Error', 'give'), array( |
|
159 | 159 | 'response' => 400, |
160 | - ) ); |
|
160 | + )); |
|
161 | 161 | } |
162 | 162 | |
163 | - if ( empty( $donor_note ) ) { |
|
164 | - give_set_error( 'empty-donor-note', __( 'A note is required.', 'give' ) ); |
|
163 | + if (empty($donor_note)) { |
|
164 | + give_set_error('empty-donor-note', __('A note is required.', 'give')); |
|
165 | 165 | } |
166 | 166 | |
167 | - if ( give_get_errors() ) { |
|
167 | + if (give_get_errors()) { |
|
168 | 168 | return false; |
169 | 169 | } |
170 | 170 | |
171 | - $donor = new Give_Donor( $donor_id ); |
|
172 | - $new_note = $donor->add_note( $donor_note ); |
|
171 | + $donor = new Give_Donor($donor_id); |
|
172 | + $new_note = $donor->add_note($donor_note); |
|
173 | 173 | |
174 | 174 | /** |
175 | 175 | * Fires before inserting donor note. |
@@ -179,22 +179,22 @@ discard block |
||
179 | 179 | * |
180 | 180 | * @since 1.0 |
181 | 181 | */ |
182 | - do_action( 'give_pre_insert_donor_note', $donor_id, $new_note ); |
|
182 | + do_action('give_pre_insert_donor_note', $donor_id, $new_note); |
|
183 | 183 | |
184 | - if ( ! empty( $new_note ) && ! empty( $donor->id ) ) { |
|
184 | + if ( ! empty($new_note) && ! empty($donor->id)) { |
|
185 | 185 | |
186 | 186 | ob_start(); |
187 | 187 | ?> |
188 | 188 | <div class="donor-note-wrapper dashboard-comment-wrap comment-item"> |
189 | 189 | <span class="note-content-wrap"> |
190 | - <?php echo stripslashes( $new_note ); ?> |
|
190 | + <?php echo stripslashes($new_note); ?> |
|
191 | 191 | </span> |
192 | 192 | </div> |
193 | 193 | <?php |
194 | 194 | $output = ob_get_contents(); |
195 | 195 | ob_end_clean(); |
196 | 196 | |
197 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
197 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
198 | 198 | echo $output; |
199 | 199 | exit; |
200 | 200 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | |
208 | 208 | } |
209 | 209 | |
210 | -add_action( 'give_add-donor-note', 'give_donor_save_note', 10, 1 ); |
|
210 | +add_action('give_add-donor-note', 'give_donor_save_note', 10, 1); |
|
211 | 211 | |
212 | 212 | /** |
213 | 213 | * Delete a donor. |
@@ -218,41 +218,41 @@ discard block |
||
218 | 218 | * |
219 | 219 | * @return int Whether it was a successful deletion. |
220 | 220 | */ |
221 | -function give_donor_delete( $args ) { |
|
221 | +function give_donor_delete($args) { |
|
222 | 222 | |
223 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
223 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
224 | 224 | |
225 | - if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) { |
|
226 | - wp_die( __( 'You do not have permission to delete donors.', 'give' ), __( 'Error', 'give' ), array( |
|
225 | + if ( ! is_admin() || ! current_user_can($donor_edit_role)) { |
|
226 | + wp_die(__('You do not have permission to delete donors.', 'give'), __('Error', 'give'), array( |
|
227 | 227 | 'response' => 403, |
228 | - ) ); |
|
228 | + )); |
|
229 | 229 | } |
230 | 230 | |
231 | - if ( empty( $args ) ) { |
|
231 | + if (empty($args)) { |
|
232 | 232 | return false; |
233 | 233 | } |
234 | 234 | |
235 | 235 | $donor_id = (int) $args['customer_id']; |
236 | - $confirm = ! empty( $args['give-donor-delete-confirm'] ) ? true : false; |
|
237 | - $remove_data = ! empty( $args['give-donor-delete-records'] ) ? true : false; |
|
236 | + $confirm = ! empty($args['give-donor-delete-confirm']) ? true : false; |
|
237 | + $remove_data = ! empty($args['give-donor-delete-records']) ? true : false; |
|
238 | 238 | $nonce = $args['_wpnonce']; |
239 | 239 | |
240 | - if ( ! wp_verify_nonce( $nonce, 'delete-donor' ) ) { |
|
241 | - wp_die( __( 'Cheatin’ uh?', 'give' ), __( 'Error', 'give' ), array( |
|
240 | + if ( ! wp_verify_nonce($nonce, 'delete-donor')) { |
|
241 | + wp_die(__('Cheatin’ uh?', 'give'), __('Error', 'give'), array( |
|
242 | 242 | 'response' => 400, |
243 | - ) ); |
|
243 | + )); |
|
244 | 244 | } |
245 | 245 | |
246 | - if ( ! $confirm ) { |
|
247 | - give_set_error( 'donor-delete-no-confirm', __( 'Please confirm you want to delete this donor.', 'give' ) ); |
|
246 | + if ( ! $confirm) { |
|
247 | + give_set_error('donor-delete-no-confirm', __('Please confirm you want to delete this donor.', 'give')); |
|
248 | 248 | } |
249 | 249 | |
250 | - if ( give_get_errors() ) { |
|
251 | - wp_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor_id ) ); |
|
250 | + if (give_get_errors()) { |
|
251 | + wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor_id)); |
|
252 | 252 | exit; |
253 | 253 | } |
254 | 254 | |
255 | - $donor = new Give_Donor( $donor_id ); |
|
255 | + $donor = new Give_Donor($donor_id); |
|
256 | 256 | |
257 | 257 | /** |
258 | 258 | * Fires before deleting donor. |
@@ -263,50 +263,50 @@ discard block |
||
263 | 263 | * |
264 | 264 | * @since 1.0 |
265 | 265 | */ |
266 | - do_action( 'give_pre_delete_donor', $donor_id, $confirm, $remove_data ); |
|
266 | + do_action('give_pre_delete_donor', $donor_id, $confirm, $remove_data); |
|
267 | 267 | |
268 | - if ( $donor->id > 0 ) { |
|
268 | + if ($donor->id > 0) { |
|
269 | 269 | |
270 | - $payments_array = explode( ',', $donor->payment_ids ); |
|
271 | - $success = Give()->donors->delete( $donor->id ); |
|
270 | + $payments_array = explode(',', $donor->payment_ids); |
|
271 | + $success = Give()->donors->delete($donor->id); |
|
272 | 272 | |
273 | - if ( $success ) { |
|
273 | + if ($success) { |
|
274 | 274 | |
275 | - if ( $remove_data ) { |
|
275 | + if ($remove_data) { |
|
276 | 276 | |
277 | 277 | // Remove all donations, logs, etc. |
278 | - foreach ( $payments_array as $payment_id ) { |
|
279 | - give_delete_donation( $payment_id ); |
|
278 | + foreach ($payments_array as $payment_id) { |
|
279 | + give_delete_donation($payment_id); |
|
280 | 280 | } |
281 | 281 | } else { |
282 | 282 | |
283 | 283 | // Just set the donations to customer_id of 0. |
284 | - foreach ( $payments_array as $payment_id ) { |
|
285 | - give_update_payment_meta( $payment_id, '_give_payment_donor_id', 0 ); |
|
284 | + foreach ($payments_array as $payment_id) { |
|
285 | + give_update_payment_meta($payment_id, '_give_payment_donor_id', 0); |
|
286 | 286 | } |
287 | 287 | } |
288 | 288 | |
289 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&give-messages[]=donor-deleted' ); |
|
289 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&give-messages[]=donor-deleted'); |
|
290 | 290 | |
291 | 291 | } else { |
292 | 292 | |
293 | - give_set_error( 'give-donor-delete-failed', __( 'Error deleting donor.', 'give' ) ); |
|
294 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $donor_id ); |
|
293 | + give_set_error('give-donor-delete-failed', __('Error deleting donor.', 'give')); |
|
294 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$donor_id); |
|
295 | 295 | |
296 | 296 | } |
297 | 297 | } else { |
298 | 298 | |
299 | - give_set_error( 'give-donor-delete-invalid-id', __( 'Invalid Donor ID.', 'give' ) ); |
|
300 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors' ); |
|
299 | + give_set_error('give-donor-delete-invalid-id', __('Invalid Donor ID.', 'give')); |
|
300 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors'); |
|
301 | 301 | |
302 | 302 | } |
303 | 303 | |
304 | - wp_redirect( $redirect ); |
|
304 | + wp_redirect($redirect); |
|
305 | 305 | exit; |
306 | 306 | |
307 | 307 | } |
308 | 308 | |
309 | -add_action( 'give_delete-donor', 'give_donor_delete', 10, 1 ); |
|
309 | +add_action('give_delete-donor', 'give_donor_delete', 10, 1); |
|
310 | 310 | |
311 | 311 | /** |
312 | 312 | * Disconnect a user ID from a donor |
@@ -317,17 +317,17 @@ discard block |
||
317 | 317 | * |
318 | 318 | * @return bool|array If the disconnect was successful. |
319 | 319 | */ |
320 | -function give_disconnect_donor_user_id( $args ) { |
|
320 | +function give_disconnect_donor_user_id($args) { |
|
321 | 321 | |
322 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
322 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
323 | 323 | |
324 | - if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) { |
|
325 | - wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array( |
|
324 | + if ( ! is_admin() || ! current_user_can($donor_edit_role)) { |
|
325 | + wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array( |
|
326 | 326 | 'response' => 403, |
327 | - ) ); |
|
327 | + )); |
|
328 | 328 | } |
329 | 329 | |
330 | - if ( empty( $args ) ) { |
|
330 | + if (empty($args)) { |
|
331 | 331 | return false; |
332 | 332 | } |
333 | 333 | |
@@ -335,14 +335,14 @@ discard block |
||
335 | 335 | |
336 | 336 | $nonce = $args['_wpnonce']; |
337 | 337 | |
338 | - if ( ! wp_verify_nonce( $nonce, 'edit-donor' ) ) { |
|
339 | - wp_die( __( 'Cheatin’ uh?', 'give' ), __( 'Error', 'give' ), array( |
|
338 | + if ( ! wp_verify_nonce($nonce, 'edit-donor')) { |
|
339 | + wp_die(__('Cheatin’ uh?', 'give'), __('Error', 'give'), array( |
|
340 | 340 | 'response' => 400, |
341 | - ) ); |
|
341 | + )); |
|
342 | 342 | } |
343 | 343 | |
344 | - $donor = new Give_Donor( $donor_id ); |
|
345 | - if ( empty( $donor->id ) ) { |
|
344 | + $donor = new Give_Donor($donor_id); |
|
345 | + if (empty($donor->id)) { |
|
346 | 346 | return false; |
347 | 347 | } |
348 | 348 | |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | * |
357 | 357 | * @since 1.0 |
358 | 358 | */ |
359 | - do_action( 'give_pre_donor_disconnect_user_id', $donor_id, $user_id ); |
|
359 | + do_action('give_pre_donor_disconnect_user_id', $donor_id, $user_id); |
|
360 | 360 | |
361 | 361 | $output = array(); |
362 | 362 | $donor_args = array( |
@@ -365,19 +365,19 @@ discard block |
||
365 | 365 | |
366 | 366 | |
367 | 367 | $output['success'] = true; |
368 | - if ( ! $donor->update( $donor_args ) ) { |
|
369 | - update_user_meta( $user_id, '_give_is_donor_disconnected', true ); |
|
370 | - update_user_meta( $user_id, '_give_disconnected_donor_id', $donor->id ); |
|
371 | - $donor->update_meta( '_give_disconnected_user_id', $user_id ); |
|
368 | + if ( ! $donor->update($donor_args)) { |
|
369 | + update_user_meta($user_id, '_give_is_donor_disconnected', true); |
|
370 | + update_user_meta($user_id, '_give_disconnected_donor_id', $donor->id); |
|
371 | + $donor->update_meta('_give_disconnected_user_id', $user_id); |
|
372 | 372 | |
373 | 373 | $output['success'] = true; |
374 | 374 | |
375 | 375 | } else { |
376 | 376 | $output['success'] = false; |
377 | - give_set_error( 'give-disconnect-user-fail', __( 'Failed to disconnect user from donor.', 'give' ) ); |
|
377 | + give_set_error('give-disconnect-user-fail', __('Failed to disconnect user from donor.', 'give')); |
|
378 | 378 | } |
379 | 379 | |
380 | - $output['redirect'] = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' ) . $donor_id; |
|
380 | + $output['redirect'] = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id=').$donor_id; |
|
381 | 381 | |
382 | 382 | /** |
383 | 383 | * Fires after disconnecting user ID from a donor. |
@@ -386,11 +386,11 @@ discard block |
||
386 | 386 | * |
387 | 387 | * @since 1.0 |
388 | 388 | */ |
389 | - do_action( 'give_post_donor_disconnect_user_id', $donor_id ); |
|
389 | + do_action('give_post_donor_disconnect_user_id', $donor_id); |
|
390 | 390 | |
391 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
392 | - header( 'Content-Type: application/json' ); |
|
393 | - echo json_encode( $output ); |
|
391 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
392 | + header('Content-Type: application/json'); |
|
393 | + echo json_encode($output); |
|
394 | 394 | wp_die(); |
395 | 395 | } |
396 | 396 | |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | |
399 | 399 | } |
400 | 400 | |
401 | -add_action( 'give_disconnect-userid', 'give_disconnect_donor_user_id', 10, 1 ); |
|
401 | +add_action('give_disconnect-userid', 'give_disconnect_donor_user_id', 10, 1); |
|
402 | 402 | |
403 | 403 | /** |
404 | 404 | * Add an email address to the donor from within the admin and log a donor note. |
@@ -409,86 +409,86 @@ discard block |
||
409 | 409 | * |
410 | 410 | * @return mixed If DOING_AJAX echos out JSON, otherwise returns array of success (bool) and message (string). |
411 | 411 | */ |
412 | -function give_add_donor_email( $args ) { |
|
412 | +function give_add_donor_email($args) { |
|
413 | 413 | |
414 | 414 | $donor_id = ''; |
415 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
415 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
416 | 416 | |
417 | - if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) { |
|
418 | - wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array( |
|
417 | + if ( ! is_admin() || ! current_user_can($donor_edit_role)) { |
|
418 | + wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array( |
|
419 | 419 | 'response' => 403, |
420 | - ) ); |
|
420 | + )); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | $output = array(); |
424 | - if ( empty( $args ) || empty( $args['email'] ) || empty( $args['customer_id'] ) ) { |
|
424 | + if (empty($args) || empty($args['email']) || empty($args['customer_id'])) { |
|
425 | 425 | $output['success'] = false; |
426 | - if ( empty( $args['email'] ) ) { |
|
427 | - $output['message'] = __( 'Email address is required.', 'give' ); |
|
428 | - } elseif ( empty( $args['customer_id'] ) ) { |
|
429 | - $output['message'] = __( 'Donor ID is required.', 'give' ); |
|
426 | + if (empty($args['email'])) { |
|
427 | + $output['message'] = __('Email address is required.', 'give'); |
|
428 | + } elseif (empty($args['customer_id'])) { |
|
429 | + $output['message'] = __('Donor ID is required.', 'give'); |
|
430 | 430 | } else { |
431 | - $output['message'] = __( 'An error has occurred. Please try again.', 'give' ); |
|
431 | + $output['message'] = __('An error has occurred. Please try again.', 'give'); |
|
432 | 432 | } |
433 | - } elseif ( ! wp_verify_nonce( $args['_wpnonce'], 'give_add_donor_email' ) ) { |
|
433 | + } elseif ( ! wp_verify_nonce($args['_wpnonce'], 'give_add_donor_email')) { |
|
434 | 434 | $output = array( |
435 | 435 | 'success' => false, |
436 | - 'message' => __( 'Nonce verification failed.', 'give' ), |
|
436 | + 'message' => __('Nonce verification failed.', 'give'), |
|
437 | 437 | ); |
438 | - } elseif ( ! is_email( $args['email'] ) ) { |
|
438 | + } elseif ( ! is_email($args['email'])) { |
|
439 | 439 | $output = array( |
440 | 440 | 'success' => false, |
441 | - 'message' => __( 'Invalid email.', 'give' ), |
|
441 | + 'message' => __('Invalid email.', 'give'), |
|
442 | 442 | ); |
443 | 443 | } else { |
444 | - $email = sanitize_email( $args['email'] ); |
|
444 | + $email = sanitize_email($args['email']); |
|
445 | 445 | $donor_id = (int) $args['customer_id']; |
446 | 446 | $primary = 'true' === $args['primary'] ? true : false; |
447 | - $donor = new Give_Donor( $donor_id ); |
|
448 | - if ( false === $donor->add_email( $email, $primary ) ) { |
|
449 | - if ( in_array( $email, $donor->emails ) ) { |
|
447 | + $donor = new Give_Donor($donor_id); |
|
448 | + if (false === $donor->add_email($email, $primary)) { |
|
449 | + if (in_array($email, $donor->emails)) { |
|
450 | 450 | $output = array( |
451 | 451 | 'success' => false, |
452 | - 'message' => __( 'Email already associated with this donor.', 'give' ), |
|
452 | + 'message' => __('Email already associated with this donor.', 'give'), |
|
453 | 453 | ); |
454 | 454 | } else { |
455 | 455 | $output = array( |
456 | 456 | 'success' => false, |
457 | - 'message' => __( 'Email address is already associated with another donor.', 'give' ), |
|
457 | + 'message' => __('Email address is already associated with another donor.', 'give'), |
|
458 | 458 | ); |
459 | 459 | } |
460 | 460 | } else { |
461 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor_id . '&give-messages[]=email-added' ); |
|
461 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor_id.'&give-messages[]=email-added'); |
|
462 | 462 | $output = array( |
463 | 463 | 'success' => true, |
464 | - 'message' => __( 'Email successfully added to donor.', 'give' ), |
|
464 | + 'message' => __('Email successfully added to donor.', 'give'), |
|
465 | 465 | 'redirect' => $redirect, |
466 | 466 | ); |
467 | 467 | |
468 | 468 | $user = wp_get_current_user(); |
469 | - $user_login = ! empty( $user->user_login ) ? $user->user_login : __( 'System', 'give' ); |
|
470 | - $donor_note = sprintf( __( 'Email address %1$s added by %2$s', 'give' ), $email, $user_login ); |
|
471 | - $donor->add_note( $donor_note ); |
|
469 | + $user_login = ! empty($user->user_login) ? $user->user_login : __('System', 'give'); |
|
470 | + $donor_note = sprintf(__('Email address %1$s added by %2$s', 'give'), $email, $user_login); |
|
471 | + $donor->add_note($donor_note); |
|
472 | 472 | |
473 | - if ( $primary ) { |
|
474 | - $donor_note = sprintf( __( 'Email address %1$s set as primary by %2$s', 'give' ), $email, $user_login ); |
|
475 | - $donor->add_note( $donor_note ); |
|
473 | + if ($primary) { |
|
474 | + $donor_note = sprintf(__('Email address %1$s set as primary by %2$s', 'give'), $email, $user_login); |
|
475 | + $donor->add_note($donor_note); |
|
476 | 476 | } |
477 | 477 | } |
478 | 478 | } // End if(). |
479 | 479 | |
480 | - do_action( 'give_post_add_donor_email', $donor_id, $args ); |
|
480 | + do_action('give_post_add_donor_email', $donor_id, $args); |
|
481 | 481 | |
482 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
483 | - header( 'Content-Type: application/json' ); |
|
484 | - echo json_encode( $output ); |
|
482 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
483 | + header('Content-Type: application/json'); |
|
484 | + echo json_encode($output); |
|
485 | 485 | wp_die(); |
486 | 486 | } |
487 | 487 | |
488 | 488 | return $output; |
489 | 489 | } |
490 | 490 | |
491 | -add_action( 'give_add_donor_email', 'give_add_donor_email', 10, 1 ); |
|
491 | +add_action('give_add_donor_email', 'give_add_donor_email', 10, 1); |
|
492 | 492 | |
493 | 493 | |
494 | 494 | /** |
@@ -499,39 +499,39 @@ discard block |
||
499 | 499 | * @return bool|null |
500 | 500 | */ |
501 | 501 | function give_remove_donor_email() { |
502 | - if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
502 | + if (empty($_GET['id']) || ! is_numeric($_GET['id'])) { |
|
503 | 503 | return false; |
504 | 504 | } |
505 | - if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) { |
|
505 | + if (empty($_GET['email']) || ! is_email($_GET['email'])) { |
|
506 | 506 | return false; |
507 | 507 | } |
508 | - if ( empty( $_GET['_wpnonce'] ) ) { |
|
508 | + if (empty($_GET['_wpnonce'])) { |
|
509 | 509 | return false; |
510 | 510 | } |
511 | 511 | |
512 | 512 | $nonce = $_GET['_wpnonce']; |
513 | - if ( ! wp_verify_nonce( $nonce, 'give-remove-donor-email' ) ) { |
|
514 | - wp_die( __( 'Nonce verification failed', 'give' ), __( 'Error', 'give' ), array( |
|
513 | + if ( ! wp_verify_nonce($nonce, 'give-remove-donor-email')) { |
|
514 | + wp_die(__('Nonce verification failed', 'give'), __('Error', 'give'), array( |
|
515 | 515 | 'response' => 403, |
516 | - ) ); |
|
516 | + )); |
|
517 | 517 | } |
518 | 518 | |
519 | - $donor = new Give_Donor( $_GET['id'] ); |
|
520 | - if ( $donor->remove_email( $_GET['email'] ) ) { |
|
521 | - $url = add_query_arg( 'give-messages[]', 'email-removed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) ); |
|
519 | + $donor = new Give_Donor($_GET['id']); |
|
520 | + if ($donor->remove_email($_GET['email'])) { |
|
521 | + $url = add_query_arg('give-messages[]', 'email-removed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id)); |
|
522 | 522 | $user = wp_get_current_user(); |
523 | - $user_login = ! empty( $user->user_login ) ? $user->user_login : __( 'System', 'give' ); |
|
524 | - $donor_note = sprintf( __( 'Email address %1$s removed by %2$s', 'give' ), $_GET['email'], $user_login ); |
|
525 | - $donor->add_note( $donor_note ); |
|
523 | + $user_login = ! empty($user->user_login) ? $user->user_login : __('System', 'give'); |
|
524 | + $donor_note = sprintf(__('Email address %1$s removed by %2$s', 'give'), $_GET['email'], $user_login); |
|
525 | + $donor->add_note($donor_note); |
|
526 | 526 | } else { |
527 | - $url = add_query_arg( 'give-messages[]', 'email-remove-failed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) ); |
|
527 | + $url = add_query_arg('give-messages[]', 'email-remove-failed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id)); |
|
528 | 528 | } |
529 | 529 | |
530 | - wp_safe_redirect( $url ); |
|
530 | + wp_safe_redirect($url); |
|
531 | 531 | exit; |
532 | 532 | } |
533 | 533 | |
534 | -add_action( 'give_remove_donor_email', 'give_remove_donor_email', 10 ); |
|
534 | +add_action('give_remove_donor_email', 'give_remove_donor_email', 10); |
|
535 | 535 | |
536 | 536 | |
537 | 537 | /** |
@@ -543,44 +543,44 @@ discard block |
||
543 | 543 | * @return bool|null |
544 | 544 | */ |
545 | 545 | function give_set_donor_primary_email() { |
546 | - if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
546 | + if (empty($_GET['id']) || ! is_numeric($_GET['id'])) { |
|
547 | 547 | return false; |
548 | 548 | } |
549 | 549 | |
550 | - if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) { |
|
550 | + if (empty($_GET['email']) || ! is_email($_GET['email'])) { |
|
551 | 551 | return false; |
552 | 552 | } |
553 | 553 | |
554 | - if ( empty( $_GET['_wpnonce'] ) ) { |
|
554 | + if (empty($_GET['_wpnonce'])) { |
|
555 | 555 | return false; |
556 | 556 | } |
557 | 557 | |
558 | 558 | $nonce = $_GET['_wpnonce']; |
559 | 559 | |
560 | - if ( ! wp_verify_nonce( $nonce, 'give-set-donor-primary-email' ) ) { |
|
561 | - wp_die( __( 'Nonce verification failed', 'give' ), __( 'Error', 'give' ), array( |
|
560 | + if ( ! wp_verify_nonce($nonce, 'give-set-donor-primary-email')) { |
|
561 | + wp_die(__('Nonce verification failed', 'give'), __('Error', 'give'), array( |
|
562 | 562 | 'response' => 403, |
563 | - ) ); |
|
563 | + )); |
|
564 | 564 | } |
565 | 565 | |
566 | - $donor = new Give_Donor( $_GET['id'] ); |
|
566 | + $donor = new Give_Donor($_GET['id']); |
|
567 | 567 | |
568 | - if ( $donor->set_primary_email( $_GET['email'] ) ) { |
|
569 | - $url = add_query_arg( 'give-messages[]', 'primary-email-updated', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) ); |
|
568 | + if ($donor->set_primary_email($_GET['email'])) { |
|
569 | + $url = add_query_arg('give-messages[]', 'primary-email-updated', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id)); |
|
570 | 570 | $user = wp_get_current_user(); |
571 | - $user_login = ! empty( $user->user_login ) ? $user->user_login : __( 'System', 'give' ); |
|
572 | - $donor_note = sprintf( __( 'Email address %1$s set as primary by %2$s', 'give' ), $_GET['email'], $user_login ); |
|
571 | + $user_login = ! empty($user->user_login) ? $user->user_login : __('System', 'give'); |
|
572 | + $donor_note = sprintf(__('Email address %1$s set as primary by %2$s', 'give'), $_GET['email'], $user_login); |
|
573 | 573 | |
574 | - $donor->add_note( $donor_note ); |
|
574 | + $donor->add_note($donor_note); |
|
575 | 575 | } else { |
576 | - $url = add_query_arg( 'give-messages[]', 'primary-email-failed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) ); |
|
576 | + $url = add_query_arg('give-messages[]', 'primary-email-failed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id)); |
|
577 | 577 | } |
578 | 578 | |
579 | - wp_safe_redirect( $url ); |
|
579 | + wp_safe_redirect($url); |
|
580 | 580 | exit; |
581 | 581 | } |
582 | 582 | |
583 | -add_action( 'give_set_donor_primary_email', 'give_set_donor_primary_email', 10 ); |
|
583 | +add_action('give_set_donor_primary_email', 'give_set_donor_primary_email', 10); |
|
584 | 584 | |
585 | 585 | /** |
586 | 586 | * Delete Donor using Bulk Actions. |
@@ -591,57 +591,57 @@ discard block |
||
591 | 591 | * |
592 | 592 | * @return void |
593 | 593 | */ |
594 | -function give_delete_donor( $args ) { |
|
594 | +function give_delete_donor($args) { |
|
595 | 595 | |
596 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
596 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
597 | 597 | |
598 | - if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) { |
|
599 | - wp_die( __( 'You do not have permission to delete donors.', 'give' ), __( 'Error', 'give' ), array( |
|
598 | + if ( ! is_admin() || ! current_user_can($donor_edit_role)) { |
|
599 | + wp_die(__('You do not have permission to delete donors.', 'give'), __('Error', 'give'), array( |
|
600 | 600 | 'response' => 403, |
601 | - ) ); |
|
601 | + )); |
|
602 | 602 | } |
603 | 603 | |
604 | 604 | $give_args = array(); |
605 | - $donor_ids = ( ! empty( $_GET['donor'] ) && is_array( $_GET['donor'] ) && count( $_GET['donor'] ) > 0 ) ? $_GET['donor'] : array(); |
|
606 | - $delete_donor = ! empty( $_GET['give-delete-donor-confirm'] ) ? $_GET['give-delete-donor-confirm'] : ''; |
|
607 | - $delete_donations = ! empty( $_GET['give-delete-donor-records'] ) ? $_GET['give-delete-donor-records'] : ''; |
|
608 | - $search_keyword = ! empty( $_GET['s'] ) ? $_GET['s'] : ''; |
|
609 | - $give_args['orderby'] = ! empty( $_GET['orderby'] ) ? $_GET['orderby'] : 'id'; |
|
610 | - $give_args['order'] = ! empty( $_GET['order'] ) ? $_GET['order'] : 'desc'; |
|
605 | + $donor_ids = ( ! empty($_GET['donor']) && is_array($_GET['donor']) && count($_GET['donor']) > 0) ? $_GET['donor'] : array(); |
|
606 | + $delete_donor = ! empty($_GET['give-delete-donor-confirm']) ? $_GET['give-delete-donor-confirm'] : ''; |
|
607 | + $delete_donations = ! empty($_GET['give-delete-donor-records']) ? $_GET['give-delete-donor-records'] : ''; |
|
608 | + $search_keyword = ! empty($_GET['s']) ? $_GET['s'] : ''; |
|
609 | + $give_args['orderby'] = ! empty($_GET['orderby']) ? $_GET['orderby'] : 'id'; |
|
610 | + $give_args['order'] = ! empty($_GET['order']) ? $_GET['order'] : 'desc'; |
|
611 | 611 | $nonce = $args['_wpnonce']; |
612 | 612 | |
613 | 613 | // Verify Nonce for deleting bulk donors. |
614 | - if ( ! wp_verify_nonce( $nonce, 'bulk-donors' ) ) { |
|
615 | - wp_die( __( 'Cheatin’ uh?', 'give' ), __( 'Error', 'give' ), array( |
|
614 | + if ( ! wp_verify_nonce($nonce, 'bulk-donors')) { |
|
615 | + wp_die(__('Cheatin’ uh?', 'give'), __('Error', 'give'), array( |
|
616 | 616 | 'response' => 400, |
617 | - ) ); |
|
617 | + )); |
|
618 | 618 | } |
619 | 619 | |
620 | - if( count( $donor_ids ) > 0 ) { |
|
621 | - foreach ( $donor_ids as $donor_id ) { |
|
622 | - $donor = new Give_Donor( $donor_id ); |
|
620 | + if (count($donor_ids) > 0) { |
|
621 | + foreach ($donor_ids as $donor_id) { |
|
622 | + $donor = new Give_Donor($donor_id); |
|
623 | 623 | |
624 | - if ( $donor->id > 0 ) { |
|
624 | + if ($donor->id > 0) { |
|
625 | 625 | |
626 | - if( $delete_donor ) { |
|
627 | - $donor_deleted = Give()->donors->delete( $donor->id ); |
|
626 | + if ($delete_donor) { |
|
627 | + $donor_deleted = Give()->donors->delete($donor->id); |
|
628 | 628 | |
629 | - if ( $donor_deleted ) { |
|
630 | - $donation_ids = explode( ',', $donor->payment_ids ); |
|
629 | + if ($donor_deleted) { |
|
630 | + $donation_ids = explode(',', $donor->payment_ids); |
|
631 | 631 | |
632 | - if( $delete_donations ) { |
|
632 | + if ($delete_donations) { |
|
633 | 633 | |
634 | 634 | // Remove all donations, logs, etc. |
635 | - foreach ( $donation_ids as $donation_id ) { |
|
636 | - give_delete_donation( $donation_id ); |
|
635 | + foreach ($donation_ids as $donation_id) { |
|
636 | + give_delete_donation($donation_id); |
|
637 | 637 | } |
638 | 638 | |
639 | 639 | $give_args['give-messages[]'] = 'donor-donations-deleted'; |
640 | 640 | } else { |
641 | 641 | |
642 | 642 | // Just set the donations to customer_id of 0. |
643 | - foreach ( $donation_ids as $donation_id ) { |
|
644 | - give_update_payment_meta( $donation_id, '_give_payment_customer_id', 0 ); |
|
643 | + foreach ($donation_ids as $donation_id) { |
|
644 | + give_update_payment_meta($donation_id, '_give_payment_customer_id', 0); |
|
645 | 645 | } |
646 | 646 | |
647 | 647 | $give_args['give-messages[]'] = 'donor-deleted'; |
@@ -658,13 +658,13 @@ discard block |
||
658 | 658 | } |
659 | 659 | |
660 | 660 | // Add Search Keyword on redirection, if it exists. |
661 | - if ( ! empty( $search_keyword ) ) { |
|
661 | + if ( ! empty($search_keyword)) { |
|
662 | 662 | $give_args['s'] = $search_keyword; |
663 | 663 | } |
664 | 664 | |
665 | - wp_redirect( add_query_arg( $give_args, admin_url( 'edit.php?post_type=give_forms&page=give-donors' ) ) ); |
|
665 | + wp_redirect(add_query_arg($give_args, admin_url('edit.php?post_type=give_forms&page=give-donors'))); |
|
666 | 666 | give_die(); |
667 | 667 | } |
668 | 668 | } |
669 | 669 | |
670 | -add_action( 'give_delete_donor', 'give_delete_donor' ); |
|
671 | 670 | \ No newline at end of file |
671 | +add_action('give_delete_donor', 'give_delete_donor'); |
|
672 | 672 | \ No newline at end of file |
@@ -65,18 +65,18 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @param $args |
67 | 67 | */ |
68 | - public function __construct( $args ) { |
|
68 | + public function __construct($args) { |
|
69 | 69 | |
70 | 70 | // Only for admins. |
71 | - if ( ! is_admin() ) { |
|
71 | + if ( ! is_admin()) { |
|
72 | 72 | return; |
73 | 73 | } |
74 | 74 | |
75 | - foreach ( $args as $key => $arg ) { |
|
75 | + foreach ($args as $key => $arg) { |
|
76 | 76 | $this->$key = $arg; |
77 | 77 | } |
78 | 78 | |
79 | - add_action( 'admin_init', array( $this, 'init' ) ); |
|
79 | + add_action('admin_init', array($this, 'init')); |
|
80 | 80 | |
81 | 81 | |
82 | 82 | } |
@@ -87,19 +87,19 @@ discard block |
||
87 | 87 | function init() { |
88 | 88 | |
89 | 89 | // First get user's locale (4.7+). |
90 | - $this->locale = function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
90 | + $this->locale = function_exists('get_user_locale') ? get_user_locale() : get_locale(); |
|
91 | 91 | |
92 | 92 | // This plugin is en_US native. |
93 | - if ( 'en_US' === $this->locale ) { |
|
93 | + if ('en_US' === $this->locale) { |
|
94 | 94 | return; |
95 | 95 | } |
96 | 96 | |
97 | 97 | if ( |
98 | 98 | ! $this->hide_promo() |
99 | - && ( ! empty( $_GET['post_type'] ) && 'give_forms' === $_GET['post_type'] ) |
|
100 | - && ( ! empty( $_GET['page'] ) && 'give-settings' === $_GET['page'] ) |
|
99 | + && ( ! empty($_GET['post_type']) && 'give_forms' === $_GET['post_type']) |
|
100 | + && ( ! empty($_GET['page']) && 'give-settings' === $_GET['page']) |
|
101 | 101 | ) { |
102 | - add_action( $this->hook, array( $this, 'promo' ) ); |
|
102 | + add_action($this->hook, array($this, 'promo')); |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
@@ -112,11 +112,11 @@ discard block |
||
112 | 112 | * @return bool |
113 | 113 | */ |
114 | 114 | private function hide_promo() { |
115 | - $hide_promo = Give_Cache::get( 'give_i18n_give_promo_hide', true ); |
|
116 | - if ( ! $hide_promo ) { |
|
117 | - if ( filter_input( INPUT_GET, 'remove_i18n_promo', FILTER_VALIDATE_INT ) === 1 ) { |
|
115 | + $hide_promo = Give_Cache::get('give_i18n_give_promo_hide', true); |
|
116 | + if ( ! $hide_promo) { |
|
117 | + if (filter_input(INPUT_GET, 'remove_i18n_promo', FILTER_VALIDATE_INT) === 1) { |
|
118 | 118 | // No expiration time, so this would normally not expire, but it wouldn't be copied to other sites etc. |
119 | - Give_Cache::set( 'give_i18n_give_promo_hide', true, null, true ); |
|
119 | + Give_Cache::set('give_i18n_give_promo_hide', true, null, true); |
|
120 | 120 | $hide_promo = true; |
121 | 121 | } |
122 | 122 | } |
@@ -135,20 +135,20 @@ discard block |
||
135 | 135 | $message = false; |
136 | 136 | |
137 | 137 | // Using a translation less than 90% complete. |
138 | - if ( $this->translation_exists && $this->translation_loaded && $this->percent_translated < 90 ) { |
|
139 | - $message = __( 'As you can see, there is a translation of this plugin in %1$s. This translation is currently %3$d%% complete. We need your help to make it complete and to fix any errors. Please register at %4$s to help %5$s to %1$s!', 'give' ); |
|
140 | - } elseif ( ! $this->translation_loaded && $this->translation_exists ) { |
|
141 | - $message = __( 'You\'re using WordPress in %1$s. While %2$s has been %3$d%% translated to %1$s, it has not been shipped with the plugin yet. You can help! Register at %4$s to help complete the translation to %1$s!', 'give' ); |
|
142 | - } elseif ( ! $this->translation_exists ) { |
|
143 | - $message = __( 'You\'re using WordPress in a language we don\'t support yet. We\'d love for %2$s to be translated in that language too, but unfortunately, it isn\'t right now. You can change that! Register at %4$s to help translate it!', 'give' ); |
|
138 | + if ($this->translation_exists && $this->translation_loaded && $this->percent_translated < 90) { |
|
139 | + $message = __('As you can see, there is a translation of this plugin in %1$s. This translation is currently %3$d%% complete. We need your help to make it complete and to fix any errors. Please register at %4$s to help %5$s to %1$s!', 'give'); |
|
140 | + } elseif ( ! $this->translation_loaded && $this->translation_exists) { |
|
141 | + $message = __('You\'re using WordPress in %1$s. While %2$s has been %3$d%% translated to %1$s, it has not been shipped with the plugin yet. You can help! Register at %4$s to help complete the translation to %1$s!', 'give'); |
|
142 | + } elseif ( ! $this->translation_exists) { |
|
143 | + $message = __('You\'re using WordPress in a language we don\'t support yet. We\'d love for %2$s to be translated in that language too, but unfortunately, it isn\'t right now. You can change that! Register at %4$s to help translate it!', 'give'); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | // Links. |
147 | - $registration_link = sprintf( '<a href="%1$s" target="_blank">%2$s</a>', 'https://wordpress.org/support/register.php', esc_html__( 'WordPress.org', 'give' ) ); |
|
148 | - $translations_link = sprintf( '<a href="%1$s" target="_blank">%2$s</a>', 'https://translate.wordpress.org/projects/wp-plugins/give', esc_html__( 'complete the translation', 'give' ) ); |
|
147 | + $registration_link = sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://wordpress.org/support/register.php', esc_html__('WordPress.org', 'give')); |
|
148 | + $translations_link = sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://translate.wordpress.org/projects/wp-plugins/give', esc_html__('complete the translation', 'give')); |
|
149 | 149 | |
150 | 150 | // Message. |
151 | - $message = sprintf( $message, $this->locale_name, 'Give', $this->percent_translated, $registration_link, $translations_link ); |
|
151 | + $message = sprintf($message, $this->locale_name, 'Give', $this->percent_translated, $registration_link, $translations_link); |
|
152 | 152 | |
153 | 153 | return $message; |
154 | 154 | |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | $this->translation_details(); |
163 | 163 | $message = $this->promo_message(); |
164 | 164 | |
165 | - if ( $message ) { |
|
165 | + if ($message) { |
|
166 | 166 | $this->print_css(); |
167 | 167 | |
168 | 168 | ob_start(); |
@@ -173,12 +173,12 @@ discard block |
||
173 | 173 | style="font-size: 110px; text-decoration: none;"></span></a> |
174 | 174 | |
175 | 175 | <div class="give-i18n-notice-content"> |
176 | - <a href="<?php echo esc_url( add_query_arg( array( 'remove_i18n_promo' => '1' ) ) ); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a> |
|
176 | + <a href="<?php echo esc_url(add_query_arg(array('remove_i18n_promo' => '1'))); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a> |
|
177 | 177 | |
178 | - <h2 style="margin: 10px 0;"><?php printf( esc_html__( 'Help Translate Give to %s', 'give' ), $this->locale_name ); ?></h2> |
|
178 | + <h2 style="margin: 10px 0;"><?php printf(esc_html__('Help Translate Give to %s', 'give'), $this->locale_name); ?></h2> |
|
179 | 179 | <p><?php echo $message; ?></p> |
180 | 180 | <p> |
181 | - <a href="https://wordpress.org/support/register.php" target="_blank"><?php _e( 'Register now »', 'give' ); ?></a> |
|
181 | + <a href="https://wordpress.org/support/register.php" target="_blank"><?php _e('Register now »', 'give'); ?></a> |
|
182 | 182 | </p> |
183 | 183 | </div> |
184 | 184 | </div> |
@@ -187,12 +187,12 @@ discard block |
||
187 | 187 | $notice_html = ob_get_clean(); |
188 | 188 | |
189 | 189 | // Register notice. |
190 | - Give()->notices->register_notice( array( |
|
190 | + Give()->notices->register_notice(array( |
|
191 | 191 | 'id' => 'give-i18n-notice', |
192 | 192 | 'type' => 'updated', |
193 | 193 | 'description_html' => $notice_html, |
194 | 194 | 'show' => true, |
195 | - ) ); |
|
195 | + )); |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
@@ -274,11 +274,11 @@ discard block |
||
274 | 274 | */ |
275 | 275 | private function find_or_initialize_translation_details() { |
276 | 276 | |
277 | - $set = Give_Cache::get( "give_i18n_give_{$this->locale}", true ); |
|
277 | + $set = Give_Cache::get("give_i18n_give_{$this->locale}", true); |
|
278 | 278 | |
279 | - if ( ! $set ) { |
|
279 | + if ( ! $set) { |
|
280 | 280 | $set = $this->retrieve_translation_details(); |
281 | - Give_Cache::set( "give_i18n_give_{$this->locale}", $set, DAY_IN_SECONDS, true ); |
|
281 | + Give_Cache::set("give_i18n_give_{$this->locale}", $set, DAY_IN_SECONDS, true); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | return $set; |
@@ -292,10 +292,10 @@ discard block |
||
292 | 292 | private function translation_details() { |
293 | 293 | $set = $this->find_or_initialize_translation_details(); |
294 | 294 | |
295 | - $this->translation_exists = ! is_null( $set ); |
|
296 | - $this->translation_loaded = is_textdomain_loaded( 'give' ); |
|
295 | + $this->translation_exists = ! is_null($set); |
|
296 | + $this->translation_loaded = is_textdomain_loaded('give'); |
|
297 | 297 | |
298 | - $this->parse_translation_set( $set ); |
|
298 | + $this->parse_translation_set($set); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | /** |
@@ -307,26 +307,26 @@ discard block |
||
307 | 307 | */ |
308 | 308 | private function retrieve_translation_details() { |
309 | 309 | |
310 | - $api_url = trailingslashit( $this->glotpress_url ); |
|
310 | + $api_url = trailingslashit($this->glotpress_url); |
|
311 | 311 | |
312 | - $resp = wp_remote_get( $api_url ); |
|
312 | + $resp = wp_remote_get($api_url); |
|
313 | 313 | |
314 | - if ( is_wp_error( $resp ) || wp_remote_retrieve_response_code( $resp ) === '404' ) { |
|
314 | + if (is_wp_error($resp) || wp_remote_retrieve_response_code($resp) === '404') { |
|
315 | 315 | return null; |
316 | 316 | } |
317 | 317 | |
318 | - $body = wp_remote_retrieve_body( $resp ); |
|
319 | - unset( $resp ); |
|
318 | + $body = wp_remote_retrieve_body($resp); |
|
319 | + unset($resp); |
|
320 | 320 | |
321 | - if ( $body ) { |
|
322 | - $body = json_decode( $body ); |
|
321 | + if ($body) { |
|
322 | + $body = json_decode($body); |
|
323 | 323 | |
324 | - foreach ( $body->translation_sets as $set ) { |
|
325 | - if ( ! property_exists( $set, 'wp_locale' ) ) { |
|
324 | + foreach ($body->translation_sets as $set) { |
|
325 | + if ( ! property_exists($set, 'wp_locale')) { |
|
326 | 326 | continue; |
327 | 327 | } |
328 | 328 | |
329 | - if ( $this->locale == $set->wp_locale ) { |
|
329 | + if ($this->locale == $set->wp_locale) { |
|
330 | 330 | return $set; |
331 | 331 | } |
332 | 332 | } |
@@ -342,8 +342,8 @@ discard block |
||
342 | 342 | * |
343 | 343 | * @access private |
344 | 344 | */ |
345 | - private function parse_translation_set( $set ) { |
|
346 | - if ( $this->translation_exists && is_object( $set ) ) { |
|
345 | + private function parse_translation_set($set) { |
|
346 | + if ($this->translation_exists && is_object($set)) { |
|
347 | 347 | $this->locale_name = $set->name; |
348 | 348 | $this->percent_translated = $set->percent_translated; |
349 | 349 | } else { |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | } |
354 | 354 | } |
355 | 355 | |
356 | -$give_i18n = new Give_i18n_Banner( array( |
|
356 | +$give_i18n = new Give_i18n_Banner(array( |
|
357 | 357 | 'hook' => 'admin_notices', |
358 | 358 | 'glotpress_url' => 'https://translate.wordpress.org/api/projects/wp-plugins/give/stable/', |
359 | - ) ); |
|
359 | + )); |