Test Failed
Push — master ( b64360...78a339 )
by Ravinder
07:30
created
includes/payments/class-give-payment.php 1 patch
Spacing   +292 added lines, -293 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,14 +735,14 @@  discard block
 block discarded – undo
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 748
 			$this->new = true;
@@ -765,11 +765,11 @@  discard block
 block discarded – undo
765 765
 		$saved = false;
766 766
 
767 767
 		// Must have an ID.
768
-		if ( empty( $this->ID ) ) {
768
+		if (empty($this->ID)) {
769 769
 
770 770
 			$payment_id = $this->insert_payment();
771 771
 
772
-			if ( false === $payment_id ) {
772
+			if (false === $payment_id) {
773 773
 				$saved = false;
774 774
 			} else {
775 775
 				$this->ID = $payment_id;
@@ -777,42 +777,42 @@  discard block
 block discarded – undo
777 777
 		}
778 778
 
779 779
 		// Set ID if not matching.
780
-		if ( $this->ID !== $this->_ID ) {
780
+		if ($this->ID !== $this->_ID) {
781 781
 			$this->ID = $this->_ID;
782 782
 		}
783 783
 
784 784
 		// If we have something pending, let's save it.
785
-		if ( ! empty( $this->pending ) ) {
785
+		if ( ! empty($this->pending)) {
786 786
 
787 787
 			$total_increase = 0;
788 788
 			$total_decrease = 0;
789 789
 
790
-			foreach ( $this->pending as $key => $value ) {
790
+			foreach ($this->pending as $key => $value) {
791 791
 
792
-				switch ( $key ) {
792
+				switch ($key) {
793 793
 
794 794
 					case 'donations':
795 795
 						// Update totals for pending donations.
796
-						foreach ( $this->pending[ $key ] as $item ) {
796
+						foreach ($this->pending[$key] as $item) {
797 797
 
798
-							$quantity = isset( $item['quantity'] ) ? $item['quantity'] : 1;
799
-							$price_id = isset( $item['price_id'] ) ? $item['price_id'] : 0;
798
+							$quantity = isset($item['quantity']) ? $item['quantity'] : 1;
799
+							$price_id = isset($item['price_id']) ? $item['price_id'] : 0;
800 800
 
801
-							switch ( $item['action'] ) {
801
+							switch ($item['action']) {
802 802
 
803 803
 								case 'add':
804 804
 
805 805
 									$price = $item['price'];
806 806
 
807
-									if ( 'publish' === $this->status || 'complete' === $this->status ) {
807
+									if ('publish' === $this->status || 'complete' === $this->status) {
808 808
 
809 809
 										// Add donation to logs.
810
-										$log_date = date_i18n( 'Y-m-d G:i:s', current_time( 'timestamp' ) );
811
-										give_record_donation_in_log( $item['id'], $this->ID, $price_id, $log_date );
810
+										$log_date = date_i18n('Y-m-d G:i:s', current_time('timestamp'));
811
+										give_record_donation_in_log($item['id'], $this->ID, $price_id, $log_date);
812 812
 
813
-										$form = new Give_Donate_Form( $item['id'] );
814
-										$form->increase_sales( $quantity );
815
-										$form->increase_earnings( $price );
813
+										$form = new Give_Donate_Form($item['id']);
814
+										$form->increase_sales($quantity);
815
+										$form->increase_earnings($price);
816 816
 
817 817
 										$total_increase += $price;
818 818
 									}
@@ -820,10 +820,10 @@  discard block
 block discarded – undo
820 820
 
821 821
 								case 'remove':
822 822
 									$this->delete_sales_logs();
823
-									if ( 'publish' === $this->status || 'complete' === $this->status ) {
824
-										$form = new Give_Donate_Form( $item['id'] );
825
-										$form->decrease_sales( $quantity );
826
-										$form->decrease_earnings( $item['amount'] );
823
+									if ('publish' === $this->status || 'complete' === $this->status) {
824
+										$form = new Give_Donate_Form($item['id']);
825
+										$form->decrease_sales($quantity);
826
+										$form->decrease_earnings($item['amount']);
827 827
 
828 828
 										$total_decrease += $item['amount'];
829 829
 									}
@@ -834,27 +834,27 @@  discard block
 block discarded – undo
834 834
 						break;
835 835
 
836 836
 					case 'status':
837
-						$this->update_status( $this->status );
837
+						$this->update_status($this->status);
838 838
 						break;
839 839
 
840 840
 					case 'gateway':
841
-						$this->update_meta( '_give_payment_gateway', $this->gateway );
841
+						$this->update_meta('_give_payment_gateway', $this->gateway);
842 842
 						break;
843 843
 
844 844
 					case 'mode':
845
-						$this->update_meta( '_give_payment_mode', $this->mode );
845
+						$this->update_meta('_give_payment_mode', $this->mode);
846 846
 						break;
847 847
 
848 848
 					case 'transaction_id':
849
-						$this->update_meta( '_give_payment_transaction_id', $this->transaction_id );
849
+						$this->update_meta('_give_payment_transaction_id', $this->transaction_id);
850 850
 						break;
851 851
 
852 852
 					case 'ip':
853
-						$this->update_meta( '_give_payment_donor_ip', $this->ip );
853
+						$this->update_meta('_give_payment_donor_ip', $this->ip);
854 854
 						break;
855 855
 
856 856
 					case 'customer_id':
857
-						$this->update_meta( '_give_payment_donor_id', $this->customer_id );
857
+						$this->update_meta('_give_payment_donor_id', $this->customer_id);
858 858
 						break;
859 859
 
860 860
 					// case 'user_id':
@@ -862,58 +862,58 @@  discard block
 block discarded – undo
862 862
 					// 	break;
863 863
 
864 864
 					case 'form_title':
865
-						$this->update_meta( '_give_payment_form_title', $this->form_title );
865
+						$this->update_meta('_give_payment_form_title', $this->form_title);
866 866
 						break;
867 867
 
868 868
 					case 'form_id':
869
-						$this->update_meta( '_give_payment_form_id', $this->form_id );
869
+						$this->update_meta('_give_payment_form_id', $this->form_id);
870 870
 						break;
871 871
 
872 872
 					case 'price_id':
873
-						$this->update_meta( '_give_payment_price_id', $this->price_id );
873
+						$this->update_meta('_give_payment_price_id', $this->price_id);
874 874
 						break;
875 875
 
876 876
 					case 'first_name':
877
-						$this->update_meta( '_give_donor_billing_first_name', $this->first_name );
877
+						$this->update_meta('_give_donor_billing_first_name', $this->first_name);
878 878
 						break;
879 879
 
880 880
 					case 'last_name':
881
-						$this->update_meta( '_give_donor_billing_last_name', $this->last_name );
881
+						$this->update_meta('_give_donor_billing_last_name', $this->last_name);
882 882
 						break;
883 883
 
884 884
 					case 'currency':
885
-						$this->update_meta( '_give_payment_currency', $this->currency );
885
+						$this->update_meta('_give_payment_currency', $this->currency);
886 886
 						break;
887 887
 
888 888
 					case 'address':
889
-						if ( ! empty( $this->address ) ) {
890
-							foreach ( $this->address as $address_name => $address ) {
891
-								switch ( $address_name ) {
889
+						if ( ! empty($this->address)) {
890
+							foreach ($this->address as $address_name => $address) {
891
+								switch ($address_name) {
892 892
 									case 'line1':
893
-										$this->update_meta( '_give_donor_billing_address1', $address );
893
+										$this->update_meta('_give_donor_billing_address1', $address);
894 894
 										break;
895 895
 
896 896
 									case 'line2':
897
-										$this->update_meta( '_give_donor_billing_address2', $address );
897
+										$this->update_meta('_give_donor_billing_address2', $address);
898 898
 										break;
899 899
 
900 900
 									default:
901
-										$this->update_meta( "_give_donor_billing_{$address_name}", $address );
901
+										$this->update_meta("_give_donor_billing_{$address_name}", $address);
902 902
 								}
903 903
 							}
904 904
 						}
905 905
 						break;
906 906
 
907 907
 					case 'email':
908
-						$this->update_meta( '_give_payment_donor_email', $this->email );
908
+						$this->update_meta('_give_payment_donor_email', $this->email);
909 909
 						break;
910 910
 
911 911
 					case 'key':
912
-						$this->update_meta( '_give_payment_purchase_key', $this->key );
912
+						$this->update_meta('_give_payment_purchase_key', $this->key);
913 913
 						break;
914 914
 
915 915
 					case 'number':
916
-						$this->update_meta( '_give_payment_number', $this->number );
916
+						$this->update_meta('_give_payment_number', $this->number);
917 917
 						break;
918 918
 
919 919
 					case 'date':
@@ -923,11 +923,11 @@  discard block
 block discarded – undo
923 923
 							'edit_date' => true,
924 924
 						);
925 925
 
926
-						wp_update_post( $args );
926
+						wp_update_post($args);
927 927
 						break;
928 928
 
929 929
 					case 'completed_date':
930
-						$this->update_meta( '_give_completed_date', $this->completed_date );
930
+						$this->update_meta('_give_completed_date', $this->completed_date);
931 931
 						break;
932 932
 
933 933
 					case 'parent_payment':
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
 							'post_parent' => $this->parent_payment,
937 937
 						);
938 938
 
939
-						wp_update_post( $args );
939
+						wp_update_post($args);
940 940
 						break;
941 941
 
942 942
 					default:
@@ -947,40 +947,40 @@  discard block
 block discarded – undo
947 947
 						 *
948 948
 						 * @param Give_Payment $this Payment object.
949 949
 						 */
950
-						do_action( 'give_payment_save', $this, $key );
950
+						do_action('give_payment_save', $this, $key);
951 951
 						break;
952 952
 				}// End switch().
953 953
 			}// End foreach().
954 954
 
955
-			if ( 'pending' !== $this->status ) {
955
+			if ('pending' !== $this->status) {
956 956
 
957
-				$donor = new Give_Donor( $this->customer_id );
957
+				$donor = new Give_Donor($this->customer_id);
958 958
 
959 959
 				$total_change = $total_increase - $total_decrease;
960
-				if ( $total_change < 0 ) {
960
+				if ($total_change < 0) {
961 961
 
962
-					$total_change = - ( $total_change );
962
+					$total_change = - ($total_change);
963 963
 					// Decrease the donor's donation stats.
964
-					$donor->decrease_value( $total_change );
965
-					give_decrease_total_earnings( $total_change );
964
+					$donor->decrease_value($total_change);
965
+					give_decrease_total_earnings($total_change);
966 966
 
967
-				} elseif ( $total_change > 0 ) {
967
+				} elseif ($total_change > 0) {
968 968
 
969 969
 					// Increase the donor's donation stats.
970
-					$donor->increase_value( $total_change );
971
-					give_increase_total_earnings( $total_change );
970
+					$donor->increase_value($total_change);
971
+					give_increase_total_earnings($total_change);
972 972
 
973 973
 				}
974 974
 			}
975 975
 
976
-			$this->update_meta( '_give_payment_total', give_sanitize_amount_for_db( $this->total ) );
976
+			$this->update_meta('_give_payment_total', give_sanitize_amount_for_db($this->total));
977 977
 
978 978
 			$this->pending = array();
979 979
 			$saved         = true;
980 980
 		}// End if().
981 981
 
982
-		if ( true === $saved ) {
983
-			$this->setup_payment( $this->ID );
982
+		if (true === $saved) {
983
+			$this->setup_payment($this->ID);
984 984
 		}
985 985
 
986 986
 		return $saved;
@@ -998,12 +998,12 @@  discard block
 block discarded – undo
998 998
 	 *
999 999
 	 * @return bool           True when successful, false otherwise
1000 1000
 	 */
1001
-	public function add_donation( $form_id = 0, $args = array(), $options = array() ) {
1001
+	public function add_donation($form_id = 0, $args = array(), $options = array()) {
1002 1002
 
1003
-		$donation = new Give_Donate_Form( $form_id );
1003
+		$donation = new Give_Donate_Form($form_id);
1004 1004
 
1005 1005
 		// Bail if this post isn't a give donation form.
1006
-		if ( ! $donation || $donation->post_type !== 'give_forms' ) {
1006
+		if ( ! $donation || $donation->post_type !== 'give_forms') {
1007 1007
 			return false;
1008 1008
 		}
1009 1009
 
@@ -1013,59 +1013,59 @@  discard block
 block discarded – undo
1013 1013
 			'price_id' => false,
1014 1014
 		);
1015 1015
 
1016
-		$args = wp_parse_args( apply_filters( 'give_payment_add_donation_args', $args, $donation->ID ), $defaults );
1016
+		$args = wp_parse_args(apply_filters('give_payment_add_donation_args', $args, $donation->ID), $defaults);
1017 1017
 
1018 1018
 		// Allow overriding the price.
1019
-		if ( false !== $args['price'] ) {
1019
+		if (false !== $args['price']) {
1020 1020
 			$donation_amount = $args['price'];
1021 1021
 		} else {
1022 1022
 
1023 1023
 			// Deal with variable pricing.
1024
-			if ( give_has_variable_prices( $donation->ID ) ) {
1025
-				$prices          = give_get_meta( $form_id, '_give_donation_levels', true );
1024
+			if (give_has_variable_prices($donation->ID)) {
1025
+				$prices          = give_get_meta($form_id, '_give_donation_levels', true);
1026 1026
 				$donation_amount = '';
1027 1027
 				// Loop through prices.
1028
-				foreach ( $prices as $price ) {
1028
+				foreach ($prices as $price) {
1029 1029
 					// Find a match between price_id and level_id.
1030 1030
 					// First verify array keys exists THEN make the match.
1031
-					if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) )
1031
+					if ((isset($args['price_id']) && isset($price['_give_id']['level_id']))
1032 1032
 					     && $args['price_id'] == $price['_give_id']['level_id']
1033 1033
 					) {
1034 1034
 						$donation_amount = $price['_give_amount'];
1035 1035
 					}
1036 1036
 				}
1037 1037
 				// Fallback to the lowest price point.
1038
-				if ( $donation_amount == '' ) {
1039
-					$donation_amount  = give_get_lowest_price_option( $donation->ID );
1040
-					$args['price_id'] = give_get_lowest_price_id( $donation->ID );
1038
+				if ($donation_amount == '') {
1039
+					$donation_amount  = give_get_lowest_price_option($donation->ID);
1040
+					$args['price_id'] = give_get_lowest_price_id($donation->ID);
1041 1041
 				}
1042 1042
 			} else {
1043 1043
 				// Simple form price.
1044
-				$donation_amount = give_get_form_price( $donation->ID );
1044
+				$donation_amount = give_get_form_price($donation->ID);
1045 1045
 			}
1046 1046
 		}
1047 1047
 
1048 1048
 		// Sanitizing the price here so we don't have a dozen calls later.
1049
-		$donation_amount = give_maybe_sanitize_amount( $donation_amount );
1050
-		$total           = round( $donation_amount, give_get_price_decimals( $this->ID ) );
1049
+		$donation_amount = give_maybe_sanitize_amount($donation_amount);
1050
+		$total           = round($donation_amount, give_get_price_decimals($this->ID));
1051 1051
 
1052 1052
 		// Add Options.
1053 1053
 		$default_options = array();
1054
-		if ( false !== $args['price_id'] ) {
1054
+		if (false !== $args['price_id']) {
1055 1055
 			$default_options['price_id'] = (int) $args['price_id'];
1056 1056
 		}
1057
-		$options = wp_parse_args( $options, $default_options );
1057
+		$options = wp_parse_args($options, $default_options);
1058 1058
 
1059 1059
 		// Do not allow totals to go negative.
1060
-		if ( $total < 0 ) {
1060
+		if ($total < 0) {
1061 1061
 			$total = 0;
1062 1062
 		}
1063 1063
 
1064 1064
 		$donation = array(
1065 1065
 			'name'     => $donation->post_title,
1066 1066
 			'id'       => $donation->ID,
1067
-			'price'    => round( $total, give_get_price_decimals( $this->ID ) ),
1068
-			'subtotal' => round( $total, give_get_price_decimals( $this->ID ) ),
1067
+			'price'    => round($total, give_get_price_decimals($this->ID)),
1068
+			'subtotal' => round($total, give_get_price_decimals($this->ID)),
1069 1069
 			'price_id' => $args['price_id'],
1070 1070
 			'action'   => 'add',
1071 1071
 			'options'  => $options,
@@ -1073,7 +1073,7 @@  discard block
 block discarded – undo
1073 1073
 
1074 1074
 		$this->pending['donations'][] = $donation;
1075 1075
 
1076
-		$this->increase_subtotal( $total );
1076
+		$this->increase_subtotal($total);
1077 1077
 
1078 1078
 		return true;
1079 1079
 
@@ -1090,7 +1090,7 @@  discard block
 block discarded – undo
1090 1090
 	 *
1091 1091
 	 * @return bool           If the item was removed or not
1092 1092
 	 */
1093
-	public function remove_donation( $form_id, $args = array() ) {
1093
+	public function remove_donation($form_id, $args = array()) {
1094 1094
 
1095 1095
 		// Set some defaults.
1096 1096
 		$defaults = array(
@@ -1098,12 +1098,12 @@  discard block
 block discarded – undo
1098 1098
 			'price'    => false,
1099 1099
 			'price_id' => false,
1100 1100
 		);
1101
-		$args     = wp_parse_args( $args, $defaults );
1101
+		$args = wp_parse_args($args, $defaults);
1102 1102
 
1103
-		$form = new Give_Donate_Form( $form_id );
1103
+		$form = new Give_Donate_Form($form_id);
1104 1104
 
1105 1105
 		// Bail if this post isn't a valid give donation form.
1106
-		if ( ! $form || $form->post_type !== 'give_forms' ) {
1106
+		if ( ! $form || $form->post_type !== 'give_forms') {
1107 1107
 			return false;
1108 1108
 		}
1109 1109
 
@@ -1116,7 +1116,7 @@  discard block
 block discarded – undo
1116 1116
 
1117 1117
 		$this->pending['donations'][] = $pending_args;
1118 1118
 
1119
-		$this->decrease_subtotal( $this->total );
1119
+		$this->decrease_subtotal($this->total);
1120 1120
 
1121 1121
 		return true;
1122 1122
 	}
@@ -1132,13 +1132,13 @@  discard block
 block discarded – undo
1132 1132
 	 *
1133 1133
 	 * @return bool           If the note was specified or not
1134 1134
 	 */
1135
-	public function add_note( $note = false ) {
1135
+	public function add_note($note = false) {
1136 1136
 		// Bail if no note specified.
1137
-		if ( ! $note ) {
1137
+		if ( ! $note) {
1138 1138
 			return false;
1139 1139
 		}
1140 1140
 
1141
-		give_insert_payment_note( $this->ID, $note );
1141
+		give_insert_payment_note($this->ID, $note);
1142 1142
 	}
1143 1143
 
1144 1144
 	/**
@@ -1151,8 +1151,8 @@  discard block
 block discarded – undo
1151 1151
 	 *
1152 1152
 	 * @return void
1153 1153
 	 */
1154
-	private function increase_subtotal( $amount = 0.00 ) {
1155
-		$amount         = (float) $amount;
1154
+	private function increase_subtotal($amount = 0.00) {
1155
+		$amount = (float) $amount;
1156 1156
 		$this->subtotal += $amount;
1157 1157
 
1158 1158
 		$this->recalculate_total();
@@ -1168,11 +1168,11 @@  discard block
 block discarded – undo
1168 1168
 	 *
1169 1169
 	 * @return void
1170 1170
 	 */
1171
-	private function decrease_subtotal( $amount = 0.00 ) {
1172
-		$amount         = (float) $amount;
1171
+	private function decrease_subtotal($amount = 0.00) {
1172
+		$amount = (float) $amount;
1173 1173
 		$this->subtotal -= $amount;
1174 1174
 
1175
-		if ( $this->subtotal < 0 ) {
1175
+		if ($this->subtotal < 0) {
1176 1176
 			$this->subtotal = 0;
1177 1177
 		}
1178 1178
 
@@ -1201,24 +1201,24 @@  discard block
 block discarded – undo
1201 1201
 	 *
1202 1202
 	 * @return bool   $updated Returns if the status was successfully updated.
1203 1203
 	 */
1204
-	public function update_status( $status = false ) {
1204
+	public function update_status($status = false) {
1205 1205
 
1206 1206
 		// standardize the 'complete(d)' status.
1207
-		if ( $status == 'completed' || $status == 'complete' ) {
1207
+		if ($status == 'completed' || $status == 'complete') {
1208 1208
 			$status = 'publish';
1209 1209
 		}
1210 1210
 
1211
-		$old_status = ! empty( $this->old_status ) ? $this->old_status : false;
1211
+		$old_status = ! empty($this->old_status) ? $this->old_status : false;
1212 1212
 
1213
-		if ( $old_status === $status ) {
1213
+		if ($old_status === $status) {
1214 1214
 			return false; // Don't permit status changes that aren't changes.
1215 1215
 		}
1216 1216
 
1217
-		$do_change = apply_filters( 'give_should_update_payment_status', true, $this->ID, $status, $old_status );
1217
+		$do_change = apply_filters('give_should_update_payment_status', true, $this->ID, $status, $old_status);
1218 1218
 
1219 1219
 		$updated = false;
1220 1220
 
1221
-		if ( $do_change ) {
1221
+		if ($do_change) {
1222 1222
 
1223 1223
 			/**
1224 1224
 			 * Fires before changing payment status.
@@ -1229,21 +1229,21 @@  discard block
 block discarded – undo
1229 1229
 			 * @param string $status     The new status.
1230 1230
 			 * @param string $old_status The old status.
1231 1231
 			 */
1232
-			do_action( 'give_before_payment_status_change', $this->ID, $status, $old_status );
1232
+			do_action('give_before_payment_status_change', $this->ID, $status, $old_status);
1233 1233
 
1234 1234
 			$update_fields = array(
1235 1235
 				'ID'          => $this->ID,
1236 1236
 				'post_status' => $status,
1237
-				'edit_date'   => current_time( 'mysql' ),
1237
+				'edit_date'   => current_time('mysql'),
1238 1238
 			);
1239 1239
 
1240
-			$updated = wp_update_post( apply_filters( 'give_update_payment_status_fields', $update_fields ) );
1240
+			$updated = wp_update_post(apply_filters('give_update_payment_status_fields', $update_fields));
1241 1241
 
1242 1242
 			$all_payment_statuses  = give_get_payment_statuses();
1243
-			$this->status_nicename = array_key_exists( $status, $all_payment_statuses ) ? $all_payment_statuses[ $status ] : ucfirst( $status );
1243
+			$this->status_nicename = array_key_exists($status, $all_payment_statuses) ? $all_payment_statuses[$status] : ucfirst($status);
1244 1244
 
1245 1245
 			// Process any specific status functions.
1246
-			switch ( $status ) {
1246
+			switch ($status) {
1247 1247
 				case 'refunded':
1248 1248
 					$this->process_refund();
1249 1249
 					break;
@@ -1270,7 +1270,7 @@  discard block
 block discarded – undo
1270 1270
 			 * @param string $status     The new status.
1271 1271
 			 * @param string $old_status The old status.
1272 1272
 			 */
1273
-			do_action( 'give_update_payment_status', $this->ID, $status, $old_status );
1273
+			do_action('give_update_payment_status', $this->ID, $status, $old_status);
1274 1274
 
1275 1275
 		}// End if().
1276 1276
 
@@ -1305,24 +1305,24 @@  discard block
 block discarded – undo
1305 1305
 	 *
1306 1306
 	 * @return mixed             The value from the post meta
1307 1307
 	 */
1308
-	public function get_meta( $meta_key = '_give_payment_meta', $single = true ) {
1309
-		if( ! has_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta' ) && ! doing_filter( 'get_post_metadata' ) ) {
1310
-			add_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4 );
1308
+	public function get_meta($meta_key = '_give_payment_meta', $single = true) {
1309
+		if ( ! has_filter('get_post_metadata', 'give_bc_v20_get_payment_meta') && ! doing_filter('get_post_metadata')) {
1310
+			add_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4);
1311 1311
 		}
1312 1312
 
1313
-		$meta = give_get_meta( $this->ID, $meta_key, $single );
1313
+		$meta = give_get_meta($this->ID, $meta_key, $single);
1314 1314
 
1315 1315
 		/**
1316 1316
 		 * Filter the specific meta key value.
1317 1317
 		 *
1318 1318
 		 * @since 1.5
1319 1319
 		 */
1320
-		$meta = apply_filters( "give_get_payment_meta_{$meta_key}", $meta, $this->ID );
1320
+		$meta = apply_filters("give_get_payment_meta_{$meta_key}", $meta, $this->ID);
1321 1321
 
1322 1322
 		// Security check.
1323
-		if ( is_serialized( $meta ) ) {
1324
-			preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $meta, $matches );
1325
-			if ( ! empty( $matches ) ) {
1323
+		if (is_serialized($meta)) {
1324
+			preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $meta, $matches);
1325
+			if ( ! empty($matches)) {
1326 1326
 				$meta = array();
1327 1327
 			}
1328 1328
 		}
@@ -1332,7 +1332,7 @@  discard block
 block discarded – undo
1332 1332
 		 *
1333 1333
 		 * @since 1.5
1334 1334
 		 */
1335
-		return apply_filters( 'give_get_payment_meta', $meta, $this->ID, $meta_key );
1335
+		return apply_filters('give_get_payment_meta', $meta, $this->ID, $meta_key);
1336 1336
 	}
1337 1337
 
1338 1338
 	/**
@@ -1347,8 +1347,8 @@  discard block
 block discarded – undo
1347 1347
 	 *
1348 1348
 	 * @return int|bool           Meta ID if the key didn't exist, true on successful update, false on failure
1349 1349
 	 */
1350
-	public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) {
1351
-		if ( empty( $meta_key ) ) {
1350
+	public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') {
1351
+		if (empty($meta_key)) {
1352 1352
 			return false;
1353 1353
 		}
1354 1354
 
@@ -1358,9 +1358,9 @@  discard block
 block discarded – undo
1358 1358
 		 *
1359 1359
 		 * @since 1.5
1360 1360
 		 */
1361
-		$meta_value = apply_filters( "give_update_payment_meta_{$meta_key}", $meta_value, $this->ID );
1361
+		$meta_value = apply_filters("give_update_payment_meta_{$meta_key}", $meta_value, $this->ID);
1362 1362
 
1363
-		return give_update_meta( $this->ID, $meta_key, $meta_value, $prev_value );
1363
+		return give_update_meta($this->ID, $meta_key, $meta_value, $prev_value);
1364 1364
 	}
1365 1365
 
1366 1366
 	/**
@@ -1375,14 +1375,14 @@  discard block
 block discarded – undo
1375 1375
 		$process_refund = true;
1376 1376
 
1377 1377
 		// If the payment was not in publish or revoked status, don't decrement stats as they were never incremented.
1378
-		if ( 'publish' != $this->old_status || 'refunded' != $this->status ) {
1378
+		if ('publish' != $this->old_status || 'refunded' != $this->status) {
1379 1379
 			$process_refund = false;
1380 1380
 		}
1381 1381
 
1382 1382
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments.
1383
-		$process_refund = apply_filters( 'give_should_process_refund', $process_refund, $this );
1383
+		$process_refund = apply_filters('give_should_process_refund', $process_refund, $this);
1384 1384
 
1385
-		if ( false === $process_refund ) {
1385
+		if (false === $process_refund) {
1386 1386
 			return;
1387 1387
 		}
1388 1388
 
@@ -1393,13 +1393,13 @@  discard block
 block discarded – undo
1393 1393
 		 *
1394 1394
 		 * @param Give_Payment $this Payment object.
1395 1395
 		 */
1396
-		do_action( 'give_pre_refund_payment', $this );
1396
+		do_action('give_pre_refund_payment', $this);
1397 1397
 
1398
-		$decrease_earnings       = apply_filters( 'give_decrease_store_earnings_on_refund', true, $this );
1399
-		$decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_refund', true, $this );
1400
-		$decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_refund', true, $this );
1398
+		$decrease_earnings       = apply_filters('give_decrease_store_earnings_on_refund', true, $this);
1399
+		$decrease_customer_value = apply_filters('give_decrease_customer_value_on_refund', true, $this);
1400
+		$decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_refund', true, $this);
1401 1401
 
1402
-		$this->maybe_alter_stats( $decrease_earnings, $decrease_customer_value, $decrease_purchase_count );
1402
+		$this->maybe_alter_stats($decrease_earnings, $decrease_customer_value, $decrease_purchase_count);
1403 1403
 		$this->delete_sales_logs();
1404 1404
 
1405 1405
 		// @todo: Refresh only range related stat cache
@@ -1412,7 +1412,7 @@  discard block
 block discarded – undo
1412 1412
 		 *
1413 1413
 		 * @param Give_Payment $this Payment object.
1414 1414
 		 */
1415
-		do_action( 'give_post_refund_payment', $this );
1415
+		do_action('give_post_refund_payment', $this);
1416 1416
 	}
1417 1417
 
1418 1418
 	/**
@@ -1439,26 +1439,26 @@  discard block
 block discarded – undo
1439 1439
 		$process_pending = true;
1440 1440
 
1441 1441
 		// If the payment was not in publish or revoked status, don't decrement stats as they were never incremented.
1442
-		if ( 'publish' != $this->old_status || 'pending' != $this->status ) {
1442
+		if ('publish' != $this->old_status || 'pending' != $this->status) {
1443 1443
 			$process_pending = false;
1444 1444
 		}
1445 1445
 
1446 1446
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments.
1447
-		$process_pending = apply_filters( 'give_should_process_pending', $process_pending, $this );
1447
+		$process_pending = apply_filters('give_should_process_pending', $process_pending, $this);
1448 1448
 
1449
-		if ( false === $process_pending ) {
1449
+		if (false === $process_pending) {
1450 1450
 			return;
1451 1451
 		}
1452 1452
 
1453
-		$decrease_earnings       = apply_filters( 'give_decrease_earnings_on_pending', true, $this );
1454
-		$decrease_donor_value    = apply_filters( 'give_decrease_donor_value_on_pending', true, $this );
1455
-		$decrease_donation_count = apply_filters( 'give_decrease_donors_donation_count_on_pending', true, $this );
1453
+		$decrease_earnings       = apply_filters('give_decrease_earnings_on_pending', true, $this);
1454
+		$decrease_donor_value    = apply_filters('give_decrease_donor_value_on_pending', true, $this);
1455
+		$decrease_donation_count = apply_filters('give_decrease_donors_donation_count_on_pending', true, $this);
1456 1456
 
1457
-		$this->maybe_alter_stats( $decrease_earnings, $decrease_donor_value, $decrease_donation_count );
1457
+		$this->maybe_alter_stats($decrease_earnings, $decrease_donor_value, $decrease_donation_count);
1458 1458
 		$this->delete_sales_logs();
1459 1459
 
1460 1460
 		$this->completed_date = false;
1461
-		$this->update_meta( '_give_completed_date', '' );
1461
+		$this->update_meta('_give_completed_date', '');
1462 1462
 
1463 1463
 		// @todo: Refresh only range related stat cache
1464 1464
 		give_delete_donation_stats();
@@ -1476,26 +1476,26 @@  discard block
 block discarded – undo
1476 1476
 		$process_cancelled = true;
1477 1477
 
1478 1478
 		// If the payment was not in publish or revoked status, don't decrement stats as they were never incremented.
1479
-		if ( 'publish' != $this->old_status || 'cancelled' != $this->status ) {
1479
+		if ('publish' != $this->old_status || 'cancelled' != $this->status) {
1480 1480
 			$process_cancelled = false;
1481 1481
 		}
1482 1482
 
1483 1483
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments.
1484
-		$process_cancelled = apply_filters( 'give_should_process_cancelled', $process_cancelled, $this );
1484
+		$process_cancelled = apply_filters('give_should_process_cancelled', $process_cancelled, $this);
1485 1485
 
1486
-		if ( false === $process_cancelled ) {
1486
+		if (false === $process_cancelled) {
1487 1487
 			return;
1488 1488
 		}
1489 1489
 
1490
-		$decrease_earnings       = apply_filters( 'give_decrease_earnings_on_cancelled', true, $this );
1491
-		$decrease_donor_value    = apply_filters( 'give_decrease_donor_value_on_cancelled', true, $this );
1492
-		$decrease_donation_count = apply_filters( 'give_decrease_donors_donation_count_on_cancelled', true, $this );
1490
+		$decrease_earnings       = apply_filters('give_decrease_earnings_on_cancelled', true, $this);
1491
+		$decrease_donor_value    = apply_filters('give_decrease_donor_value_on_cancelled', true, $this);
1492
+		$decrease_donation_count = apply_filters('give_decrease_donors_donation_count_on_cancelled', true, $this);
1493 1493
 
1494
-		$this->maybe_alter_stats( $decrease_earnings, $decrease_donor_value, $decrease_donation_count );
1494
+		$this->maybe_alter_stats($decrease_earnings, $decrease_donor_value, $decrease_donation_count);
1495 1495
 		$this->delete_sales_logs();
1496 1496
 
1497 1497
 		$this->completed_date = false;
1498
-		$this->update_meta( '_give_completed_date', '' );
1498
+		$this->update_meta('_give_completed_date', '');
1499 1499
 
1500 1500
 		// @todo: Refresh only range related stat cache
1501 1501
 		give_delete_donation_stats();
@@ -1511,26 +1511,26 @@  discard block
 block discarded – undo
1511 1511
 		$process_revoked = true;
1512 1512
 
1513 1513
 		// If the payment was not in publish, don't decrement stats as they were never incremented.
1514
-		if ( 'publish' != $this->old_status || 'revoked' != $this->status ) {
1514
+		if ('publish' != $this->old_status || 'revoked' != $this->status) {
1515 1515
 			$process_revoked = false;
1516 1516
 		}
1517 1517
 
1518 1518
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments.
1519
-		$process_revoked = apply_filters( 'give_should_process_revoked', $process_revoked, $this );
1519
+		$process_revoked = apply_filters('give_should_process_revoked', $process_revoked, $this);
1520 1520
 
1521
-		if ( false === $process_revoked ) {
1521
+		if (false === $process_revoked) {
1522 1522
 			return;
1523 1523
 		}
1524 1524
 
1525
-		$decrease_earnings       = apply_filters( 'give_decrease_earnings_on_revoked', true, $this );
1526
-		$decrease_donor_value    = apply_filters( 'give_decrease_donor_value_on_revoked', true, $this );
1527
-		$decrease_donation_count = apply_filters( 'give_decrease_donors_donation_count_on_revoked', true, $this );
1525
+		$decrease_earnings       = apply_filters('give_decrease_earnings_on_revoked', true, $this);
1526
+		$decrease_donor_value    = apply_filters('give_decrease_donor_value_on_revoked', true, $this);
1527
+		$decrease_donation_count = apply_filters('give_decrease_donors_donation_count_on_revoked', true, $this);
1528 1528
 
1529
-		$this->maybe_alter_stats( $decrease_earnings, $decrease_donor_value, $decrease_donation_count );
1529
+		$this->maybe_alter_stats($decrease_earnings, $decrease_donor_value, $decrease_donation_count);
1530 1530
 		$this->delete_sales_logs();
1531 1531
 
1532 1532
 		$this->completed_date = false;
1533
-		$this->update_meta( '_give_completed_date', '' );
1533
+		$this->update_meta('_give_completed_date', '');
1534 1534
 
1535 1535
 		// @todo: Refresh only range related stat cache
1536 1536
 		give_delete_donation_stats();
@@ -1548,25 +1548,25 @@  discard block
 block discarded – undo
1548 1548
 	 *
1549 1549
 	 * @return void
1550 1550
 	 */
1551
-	private function maybe_alter_stats( $alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count ) {
1551
+	private function maybe_alter_stats($alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count) {
1552 1552
 
1553
-		give_undo_donation( $this->ID );
1553
+		give_undo_donation($this->ID);
1554 1554
 
1555 1555
 		// Decrease store earnings.
1556
-		if ( true === $alter_store_earnings ) {
1557
-			give_decrease_total_earnings( $this->total );
1556
+		if (true === $alter_store_earnings) {
1557
+			give_decrease_total_earnings($this->total);
1558 1558
 		}
1559 1559
 
1560 1560
 		// Decrement the stats for the donor.
1561
-		if ( ! empty( $this->customer_id ) ) {
1561
+		if ( ! empty($this->customer_id)) {
1562 1562
 
1563
-			$donor = new Give_Donor( $this->customer_id );
1563
+			$donor = new Give_Donor($this->customer_id);
1564 1564
 
1565
-			if ( true === $alter_customer_value ) {
1566
-				$donor->decrease_value( $this->total );
1565
+			if (true === $alter_customer_value) {
1566
+				$donor->decrease_value($this->total);
1567 1567
 			}
1568 1568
 
1569
-			if ( true === $alter_customer_purchase_count ) {
1569
+			if (true === $alter_customer_purchase_count) {
1570 1570
 				$donor->decrease_donation_count();
1571 1571
 			}
1572 1572
 		}
@@ -1583,7 +1583,7 @@  discard block
 block discarded – undo
1583 1583
 	 */
1584 1584
 	private function delete_sales_logs() {
1585 1585
 		// Remove related sale log entries.
1586
-		Give()->logs->delete_logs( $this->ID );
1586
+		Give()->logs->delete_logs($this->ID);
1587 1587
 	}
1588 1588
 
1589 1589
 	/**
@@ -1604,13 +1604,13 @@  discard block
 block discarded – undo
1604 1604
 	 * @return string The date the payment was completed
1605 1605
 	 */
1606 1606
 	private function setup_completed_date() {
1607
-		$payment = get_post( $this->ID );
1607
+		$payment = get_post($this->ID);
1608 1608
 
1609
-		if ( 'pending' == $payment->post_status || 'preapproved' == $payment->post_status ) {
1609
+		if ('pending' == $payment->post_status || 'preapproved' == $payment->post_status) {
1610 1610
 			return false; // This payment was never completed.
1611 1611
 		}
1612 1612
 
1613
-		$date = ( $date = $this->get_meta( '_give_completed_date', true ) ) ? $date : $payment->modified_date;
1613
+		$date = ($date = $this->get_meta('_give_completed_date', true)) ? $date : $payment->modified_date;
1614 1614
 
1615 1615
 		return $date;
1616 1616
 	}
@@ -1624,7 +1624,7 @@  discard block
 block discarded – undo
1624 1624
 	 * @return string The payment mode
1625 1625
 	 */
1626 1626
 	private function setup_mode() {
1627
-		return $this->get_meta( '_give_payment_mode' );
1627
+		return $this->get_meta('_give_payment_mode');
1628 1628
 	}
1629 1629
 
1630 1630
 	/**
@@ -1636,7 +1636,7 @@  discard block
 block discarded – undo
1636 1636
 	 * @return bool The payment import
1637 1637
 	 */
1638 1638
 	private function setup_import() {
1639
-		return (bool) $this->get_meta( '_give_payment_import' );
1639
+		return (bool) $this->get_meta('_give_payment_import');
1640 1640
 	}
1641 1641
 
1642 1642
 	/**
@@ -1648,9 +1648,9 @@  discard block
 block discarded – undo
1648 1648
 	 * @return float The payment total
1649 1649
 	 */
1650 1650
 	private function setup_total() {
1651
-		$amount = $this->get_meta( '_give_payment_total', true );
1651
+		$amount = $this->get_meta('_give_payment_total', true);
1652 1652
 
1653
-		return round( floatval( $amount ), give_get_price_decimals( $this->ID ) );
1653
+		return round(floatval($amount), give_get_price_decimals($this->ID));
1654 1654
 	}
1655 1655
 
1656 1656
 	/**
@@ -1677,17 +1677,16 @@  discard block
 block discarded – undo
1677 1677
 	 * @return string The currency for the payment
1678 1678
 	 */
1679 1679
 	private function setup_currency() {
1680
-		$currency = $this->get_meta( '_give_payment_currency', true );
1681
-		$currency = ! empty( $currency ) ?
1682
-			$currency :
1683
-			/**
1680
+		$currency = $this->get_meta('_give_payment_currency', true);
1681
+		$currency = ! empty($currency) ?
1682
+			$currency : /**
1684 1683
 			 * Filter the default donation currency
1685 1684
 			 *
1686 1685
 			 * @since 1.5
1687 1686
 			 */
1688 1687
 			apply_filters(
1689 1688
 				'give_payment_currency_default',
1690
-				give_get_currency( $this->form_id, $this ),
1689
+				give_get_currency($this->form_id, $this),
1691 1690
 				$this
1692 1691
 			);
1693 1692
 
@@ -1703,7 +1702,7 @@  discard block
 block discarded – undo
1703 1702
 	 * @return string The gateway
1704 1703
 	 */
1705 1704
 	private function setup_gateway() {
1706
-		$gateway = $this->get_meta( '_give_payment_gateway', true );
1705
+		$gateway = $this->get_meta('_give_payment_gateway', true);
1707 1706
 
1708 1707
 		return $gateway;
1709 1708
 	}
@@ -1717,11 +1716,11 @@  discard block
 block discarded – undo
1717 1716
 	 * @return string The donation ID
1718 1717
 	 */
1719 1718
 	private function setup_transaction_id() {
1720
-		$transaction_id = $this->get_meta( '_give_payment_transaction_id', true );
1719
+		$transaction_id = $this->get_meta('_give_payment_transaction_id', true);
1721 1720
 
1722
-		if ( empty( $transaction_id ) ) {
1721
+		if (empty($transaction_id)) {
1723 1722
 			$gateway        = $this->gateway;
1724
-			$transaction_id = apply_filters( "give_get_payment_transaction_id-{$gateway}", $this->ID );
1723
+			$transaction_id = apply_filters("give_get_payment_transaction_id-{$gateway}", $this->ID);
1725 1724
 		}
1726 1725
 
1727 1726
 		return $transaction_id;
@@ -1737,7 +1736,7 @@  discard block
 block discarded – undo
1737 1736
 	 * @return string The IP address for the payment
1738 1737
 	 */
1739 1738
 	private function setup_ip() {
1740
-		$ip = $this->get_meta( '_give_payment_donor_ip', true );
1739
+		$ip = $this->get_meta('_give_payment_donor_ip', true);
1741 1740
 
1742 1741
 		return $ip;
1743 1742
 	}
@@ -1752,7 +1751,7 @@  discard block
 block discarded – undo
1752 1751
 	 * @return int The Donor ID.
1753 1752
 	 */
1754 1753
 	private function setup_donor_id() {
1755
-		$donor_id = $this->get_meta( '_give_payment_donor_id', true );
1754
+		$donor_id = $this->get_meta('_give_payment_donor_id', true);
1756 1755
 
1757 1756
 		return $donor_id;
1758 1757
 	}
@@ -1769,8 +1768,8 @@  discard block
 block discarded – undo
1769 1768
 	 */
1770 1769
 	private function setup_user_id() {
1771 1770
 
1772
-		$donor   = Give()->customers->get_customer_by( 'id', $this->customer_id );
1773
-		$user_id = $donor ? absint( $donor->user_id ) : 0;
1771
+		$donor   = Give()->customers->get_customer_by('id', $this->customer_id);
1772
+		$user_id = $donor ? absint($donor->user_id) : 0;
1774 1773
 
1775 1774
 
1776 1775
 		return $user_id;
@@ -1787,10 +1786,10 @@  discard block
 block discarded – undo
1787 1786
 	 * @return string The email address for the payment.
1788 1787
 	 */
1789 1788
 	private function setup_email() {
1790
-		$email = $this->get_meta( '_give_payment_donor_email', true );
1789
+		$email = $this->get_meta('_give_payment_donor_email', true);
1791 1790
 
1792
-		if ( empty( $email ) && $this->customer_id ) {
1793
-			$email = Give()->donors->get_column( 'email', $this->customer_id );
1791
+		if (empty($email) && $this->customer_id) {
1792
+			$email = Give()->donors->get_column('email', $this->customer_id);
1794 1793
 		}
1795 1794
 
1796 1795
 		return $email;
@@ -1810,22 +1809,22 @@  discard block
 block discarded – undo
1810 1809
 			'last_name'  => $this->last_name,
1811 1810
 		);
1812 1811
 
1813
-		$user_info = isset( $this->payment_meta['user_info'] ) ? $this->payment_meta['user_info'] : array();
1812
+		$user_info = isset($this->payment_meta['user_info']) ? $this->payment_meta['user_info'] : array();
1814 1813
 
1815
-		if ( is_serialized( $user_info ) ) {
1816
-			preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches );
1817
-			if ( ! empty( $matches ) ) {
1814
+		if (is_serialized($user_info)) {
1815
+			preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches);
1816
+			if ( ! empty($matches)) {
1818 1817
 				$user_info = array();
1819 1818
 			}
1820 1819
 		}
1821 1820
 
1822
-		$user_info = wp_parse_args( $user_info, $defaults );
1821
+		$user_info = wp_parse_args($user_info, $defaults);
1823 1822
 
1824
-		if ( empty( $user_info ) ) {
1823
+		if (empty($user_info)) {
1825 1824
 			// Get the donor, but only if it's been created.
1826
-			$donor = new Give_Donor( $this->customer_id );
1825
+			$donor = new Give_Donor($this->customer_id);
1827 1826
 
1828
-			if ( $donor->id > 0 ) {
1827
+			if ($donor->id > 0) {
1829 1828
 				$user_info = array(
1830 1829
 					'first_name' => $donor->get_first_name(),
1831 1830
 					'last_name'  => $donor->get_last_name(),
@@ -1835,25 +1834,25 @@  discard block
 block discarded – undo
1835 1834
 			}
1836 1835
 		} else {
1837 1836
 			// Get the donor, but only if it's been created.
1838
-			$donor = new Give_Donor( $this->customer_id );
1837
+			$donor = new Give_Donor($this->customer_id);
1839 1838
 
1840
-			if ( $donor->id > 0 ) {
1841
-				foreach ( $user_info as $key => $value ) {
1842
-					if ( ! empty( $value ) ) {
1839
+			if ($donor->id > 0) {
1840
+				foreach ($user_info as $key => $value) {
1841
+					if ( ! empty($value)) {
1843 1842
 						continue;
1844 1843
 					}
1845 1844
 
1846
-					switch ( $key ) {
1845
+					switch ($key) {
1847 1846
 						case 'first_name':
1848
-							$user_info[ $key ] = $donor->get_first_name();
1847
+							$user_info[$key] = $donor->get_first_name();
1849 1848
 							break;
1850 1849
 
1851 1850
 						case 'last_name':
1852
-							$user_info[ $key ] = $donor->get_last_name();
1851
+							$user_info[$key] = $donor->get_last_name();
1853 1852
 							break;
1854 1853
 
1855 1854
 						case 'email':
1856
-							$user_info[ $key ] = $donor->email;
1855
+							$user_info[$key] = $donor->email;
1857 1856
 							break;
1858 1857
 					}
1859 1858
 				}
@@ -1873,12 +1872,12 @@  discard block
 block discarded – undo
1873 1872
 	 * @return array The Address information for the payment.
1874 1873
 	 */
1875 1874
 	private function setup_address() {
1876
-		$address['line1']   = give_get_meta( $this->ID, '_give_donor_billing_address1', true, '' );
1877
-		$address['line2']   = give_get_meta( $this->ID, '_give_donor_billing_address2', true, '' );
1878
-		$address['city']    = give_get_meta( $this->ID, '_give_donor_billing_city', true, '' );
1879
-		$address['state']   = give_get_meta( $this->ID, '_give_donor_billing_state', true, '' );
1880
-		$address['zip']     = give_get_meta( $this->ID, '_give_donor_billing_zip', true, '' );
1881
-		$address['country'] = give_get_meta( $this->ID, '_give_donor_billing_country', true, '' );
1875
+		$address['line1']   = give_get_meta($this->ID, '_give_donor_billing_address1', true, '');
1876
+		$address['line2']   = give_get_meta($this->ID, '_give_donor_billing_address2', true, '');
1877
+		$address['city']    = give_get_meta($this->ID, '_give_donor_billing_city', true, '');
1878
+		$address['state']   = give_get_meta($this->ID, '_give_donor_billing_state', true, '');
1879
+		$address['zip']     = give_get_meta($this->ID, '_give_donor_billing_zip', true, '');
1880
+		$address['country'] = give_get_meta($this->ID, '_give_donor_billing_country', true, '');
1882 1881
 
1883 1882
 		return $address;
1884 1883
 	}
@@ -1893,7 +1892,7 @@  discard block
 block discarded – undo
1893 1892
 	 */
1894 1893
 	private function setup_form_title() {
1895 1894
 
1896
-		$form_id = $this->get_meta( '_give_payment_form_title', true );
1895
+		$form_id = $this->get_meta('_give_payment_form_title', true);
1897 1896
 
1898 1897
 		return $form_id;
1899 1898
 	}
@@ -1908,7 +1907,7 @@  discard block
 block discarded – undo
1908 1907
 	 */
1909 1908
 	private function setup_form_id() {
1910 1909
 
1911
-		$form_id = $this->get_meta( '_give_payment_form_id', true );
1910
+		$form_id = $this->get_meta('_give_payment_form_id', true);
1912 1911
 
1913 1912
 		return $form_id;
1914 1913
 	}
@@ -1922,7 +1921,7 @@  discard block
 block discarded – undo
1922 1921
 	 * @return int The Form Price ID.
1923 1922
 	 */
1924 1923
 	private function setup_price_id() {
1925
-		$price_id = $this->get_meta( '_give_payment_price_id', true );
1924
+		$price_id = $this->get_meta('_give_payment_price_id', true);
1926 1925
 
1927 1926
 		return $price_id;
1928 1927
 	}
@@ -1936,7 +1935,7 @@  discard block
 block discarded – undo
1936 1935
 	 * @return string The Payment Key.
1937 1936
 	 */
1938 1937
 	private function setup_payment_key() {
1939
-		$key = $this->get_meta( '_give_payment_purchase_key', true );
1938
+		$key = $this->get_meta('_give_payment_purchase_key', true);
1940 1939
 
1941 1940
 		return $key;
1942 1941
 	}
@@ -1952,11 +1951,11 @@  discard block
 block discarded – undo
1952 1951
 	private function setup_payment_number() {
1953 1952
 		$number = $this->ID;
1954 1953
 
1955
-		if ( give_get_option( 'enable_sequential' ) ) {
1954
+		if (give_get_option('enable_sequential')) {
1956 1955
 
1957
-			$number = $this->get_meta( '_give_payment_number', true );
1956
+			$number = $this->get_meta('_give_payment_number', true);
1958 1957
 
1959
-			if ( ! $number ) {
1958
+			if ( ! $number) {
1960 1959
 
1961 1960
 				$number = $this->ID;
1962 1961
 
@@ -1974,7 +1973,7 @@  discard block
 block discarded – undo
1974 1973
 	 * @return array The payment object as an array.
1975 1974
 	 */
1976 1975
 	public function array_convert() {
1977
-		return get_object_vars( $this );
1976
+		return get_object_vars($this);
1978 1977
 	}
1979 1978
 
1980 1979
 
@@ -1987,7 +1986,7 @@  discard block
 block discarded – undo
1987 1986
 	 * @return bool
1988 1987
 	 */
1989 1988
 	public function is_completed() {
1990
-		return ( 'publish' === $this->status && $this->completed_date );
1989
+		return ('publish' === $this->status && $this->completed_date);
1991 1990
 	}
1992 1991
 
1993 1992
 	/**
@@ -1999,7 +1998,7 @@  discard block
 block discarded – undo
1999 1998
 	 * @return string Date payment was completed.
2000 1999
 	 */
2001 2000
 	private function get_completed_date() {
2002
-		return apply_filters( 'give_payment_completed_date', $this->completed_date, $this->ID, $this );
2001
+		return apply_filters('give_payment_completed_date', $this->completed_date, $this->ID, $this);
2003 2002
 	}
2004 2003
 
2005 2004
 	/**
@@ -2011,7 +2010,7 @@  discard block
 block discarded – undo
2011 2010
 	 * @return float Payment subtotal.
2012 2011
 	 */
2013 2012
 	private function get_subtotal() {
2014
-		return apply_filters( 'give_get_payment_subtotal', $this->subtotal, $this->ID, $this );
2013
+		return apply_filters('give_get_payment_subtotal', $this->subtotal, $this->ID, $this);
2015 2014
 	}
2016 2015
 
2017 2016
 	/**
@@ -2023,7 +2022,7 @@  discard block
 block discarded – undo
2023 2022
 	 * @return string Payment currency code.
2024 2023
 	 */
2025 2024
 	private function get_currency() {
2026
-		return apply_filters( 'give_payment_currency_code', $this->currency, $this->ID, $this );
2025
+		return apply_filters('give_payment_currency_code', $this->currency, $this->ID, $this);
2027 2026
 	}
2028 2027
 
2029 2028
 	/**
@@ -2035,7 +2034,7 @@  discard block
 block discarded – undo
2035 2034
 	 * @return string Gateway used.
2036 2035
 	 */
2037 2036
 	private function get_gateway() {
2038
-		return apply_filters( 'give_payment_gateway', $this->gateway, $this->ID, $this );
2037
+		return apply_filters('give_payment_gateway', $this->gateway, $this->ID, $this);
2039 2038
 	}
2040 2039
 
2041 2040
 	/**
@@ -2047,7 +2046,7 @@  discard block
 block discarded – undo
2047 2046
 	 * @return string Donation ID from merchant processor.
2048 2047
 	 */
2049 2048
 	private function get_transaction_id() {
2050
-		return apply_filters( 'give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this );
2049
+		return apply_filters('give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this);
2051 2050
 	}
2052 2051
 
2053 2052
 	/**
@@ -2059,7 +2058,7 @@  discard block
 block discarded – undo
2059 2058
 	 * @return string Payment IP address
2060 2059
 	 */
2061 2060
 	private function get_ip() {
2062
-		return apply_filters( 'give_payment_user_ip', $this->ip, $this->ID, $this );
2061
+		return apply_filters('give_payment_user_ip', $this->ip, $this->ID, $this);
2063 2062
 	}
2064 2063
 
2065 2064
 	/**
@@ -2071,7 +2070,7 @@  discard block
 block discarded – undo
2071 2070
 	 * @return int Payment donor ID.
2072 2071
 	 */
2073 2072
 	private function get_donor_id() {
2074
-		return apply_filters( 'give_payment_customer_id', $this->customer_id, $this->ID, $this );
2073
+		return apply_filters('give_payment_customer_id', $this->customer_id, $this->ID, $this);
2075 2074
 	}
2076 2075
 
2077 2076
 	/**
@@ -2083,7 +2082,7 @@  discard block
 block discarded – undo
2083 2082
 	 * @return int Payment user ID.
2084 2083
 	 */
2085 2084
 	private function get_user_id() {
2086
-		return apply_filters( 'give_payment_user_id', $this->user_id, $this->ID, $this );
2085
+		return apply_filters('give_payment_user_id', $this->user_id, $this->ID, $this);
2087 2086
 	}
2088 2087
 
2089 2088
 	/**
@@ -2095,7 +2094,7 @@  discard block
 block discarded – undo
2095 2094
 	 * @return string Payment donor email.
2096 2095
 	 */
2097 2096
 	private function get_email() {
2098
-		return apply_filters( 'give_payment_user_email', $this->email, $this->ID, $this );
2097
+		return apply_filters('give_payment_user_email', $this->email, $this->ID, $this);
2099 2098
 	}
2100 2099
 
2101 2100
 	/**
@@ -2107,7 +2106,7 @@  discard block
 block discarded – undo
2107 2106
 	 * @return array Payment user info.
2108 2107
 	 */
2109 2108
 	private function get_user_info() {
2110
-		return apply_filters( 'give_payment_meta_user_info', $this->user_info, $this->ID, $this );
2109
+		return apply_filters('give_payment_meta_user_info', $this->user_info, $this->ID, $this);
2111 2110
 	}
2112 2111
 
2113 2112
 	/**
@@ -2119,7 +2118,7 @@  discard block
 block discarded – undo
2119 2118
 	 * @return array Payment billing address.
2120 2119
 	 */
2121 2120
 	private function get_address() {
2122
-		return apply_filters( 'give_payment_address', $this->address, $this->ID, $this );
2121
+		return apply_filters('give_payment_address', $this->address, $this->ID, $this);
2123 2122
 	}
2124 2123
 
2125 2124
 	/**
@@ -2131,7 +2130,7 @@  discard block
 block discarded – undo
2131 2130
 	 * @return string Payment key.
2132 2131
 	 */
2133 2132
 	private function get_key() {
2134
-		return apply_filters( 'give_payment_key', $this->key, $this->ID, $this );
2133
+		return apply_filters('give_payment_key', $this->key, $this->ID, $this);
2135 2134
 	}
2136 2135
 
2137 2136
 	/**
@@ -2143,7 +2142,7 @@  discard block
 block discarded – undo
2143 2142
 	 * @return string Payment form id
2144 2143
 	 */
2145 2144
 	private function get_form_id() {
2146
-		return apply_filters( 'give_payment_form_id', $this->form_id, $this->ID, $this );
2145
+		return apply_filters('give_payment_form_id', $this->form_id, $this->ID, $this);
2147 2146
 	}
2148 2147
 
2149 2148
 	/**
@@ -2155,6 +2154,6 @@  discard block
 block discarded – undo
2155 2154
 	 * @return int|string Payment number
2156 2155
 	 */
2157 2156
 	private function get_number() {
2158
-		return apply_filters( 'give_payment_number', $this->number, $this->ID, $this );
2157
+		return apply_filters('give_payment_number', $this->number, $this->ID, $this);
2159 2158
 	}
2160 2159
 }
Please login to merge, or discard this patch.