Test Failed
Push — master ( 9e7bbe...8d52b4 )
by Ravinder
06:08
created
includes/payments/class-give-payment.php 1 patch
Spacing   +291 added lines, -292 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,52 +692,52 @@  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.
734 734
 			 *
735 735
 			 * @since 2.0.1
736 736
 			 */
737
-			$custom_payment_meta = array_diff( $this->payment_meta, $payment_data );
738
-			if( ! empty( $custom_payment_meta ) ) {
739
-				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' );
740
-				$this->update_meta( '_give_payment_meta', $custom_payment_meta );
737
+			$custom_payment_meta = array_diff($this->payment_meta, $payment_data);
738
+			if ( ! empty($custom_payment_meta)) {
739
+				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');
740
+				$this->update_meta('_give_payment_meta', $custom_payment_meta);
741 741
 			}
742 742
 
743 743
 			$this->new = true;
@@ -760,11 +760,11 @@  discard block
 block discarded – undo
760 760
 		$saved = false;
761 761
 
762 762
 		// Must have an ID.
763
-		if ( empty( $this->ID ) ) {
763
+		if (empty($this->ID)) {
764 764
 
765 765
 			$payment_id = $this->insert_payment();
766 766
 
767
-			if ( false === $payment_id ) {
767
+			if (false === $payment_id) {
768 768
 				$saved = false;
769 769
 			} else {
770 770
 				$this->ID = $payment_id;
@@ -772,42 +772,42 @@  discard block
 block discarded – undo
772 772
 		}
773 773
 
774 774
 		// Set ID if not matching.
775
-		if ( $this->ID !== $this->_ID ) {
775
+		if ($this->ID !== $this->_ID) {
776 776
 			$this->ID = $this->_ID;
777 777
 		}
778 778
 
779 779
 		// If we have something pending, let's save it.
780
-		if ( ! empty( $this->pending ) ) {
780
+		if ( ! empty($this->pending)) {
781 781
 
782 782
 			$total_increase = 0;
783 783
 			$total_decrease = 0;
784 784
 
785
-			foreach ( $this->pending as $key => $value ) {
785
+			foreach ($this->pending as $key => $value) {
786 786
 
787
-				switch ( $key ) {
787
+				switch ($key) {
788 788
 
789 789
 					case 'donations':
790 790
 						// Update totals for pending donations.
791
-						foreach ( $this->pending[ $key ] as $item ) {
791
+						foreach ($this->pending[$key] as $item) {
792 792
 
793
-							$quantity = isset( $item['quantity'] ) ? $item['quantity'] : 1;
794
-							$price_id = isset( $item['price_id'] ) ? $item['price_id'] : 0;
793
+							$quantity = isset($item['quantity']) ? $item['quantity'] : 1;
794
+							$price_id = isset($item['price_id']) ? $item['price_id'] : 0;
795 795
 
796
-							switch ( $item['action'] ) {
796
+							switch ($item['action']) {
797 797
 
798 798
 								case 'add':
799 799
 
800 800
 									$price = $item['price'];
801 801
 
802
-									if ( 'publish' === $this->status || 'complete' === $this->status ) {
802
+									if ('publish' === $this->status || 'complete' === $this->status) {
803 803
 
804 804
 										// Add donation to logs.
805
-										$log_date = date_i18n( 'Y-m-d G:i:s', current_time( 'timestamp' ) );
806
-										give_record_donation_in_log( $item['id'], $this->ID, $price_id, $log_date );
805
+										$log_date = date_i18n('Y-m-d G:i:s', current_time('timestamp'));
806
+										give_record_donation_in_log($item['id'], $this->ID, $price_id, $log_date);
807 807
 
808
-										$form = new Give_Donate_Form( $item['id'] );
809
-										$form->increase_sales( $quantity );
810
-										$form->increase_earnings( $price );
808
+										$form = new Give_Donate_Form($item['id']);
809
+										$form->increase_sales($quantity);
810
+										$form->increase_earnings($price);
811 811
 
812 812
 										$total_increase += $price;
813 813
 									}
@@ -815,10 +815,10 @@  discard block
 block discarded – undo
815 815
 
816 816
 								case 'remove':
817 817
 									$this->delete_sales_logs();
818
-									if ( 'publish' === $this->status || 'complete' === $this->status ) {
819
-										$form = new Give_Donate_Form( $item['id'] );
820
-										$form->decrease_sales( $quantity );
821
-										$form->decrease_earnings( $item['amount'] );
818
+									if ('publish' === $this->status || 'complete' === $this->status) {
819
+										$form = new Give_Donate_Form($item['id']);
820
+										$form->decrease_sales($quantity);
821
+										$form->decrease_earnings($item['amount']);
822 822
 
823 823
 										$total_decrease += $item['amount'];
824 824
 									}
@@ -829,27 +829,27 @@  discard block
 block discarded – undo
829 829
 						break;
830 830
 
831 831
 					case 'status':
832
-						$this->update_status( $this->status );
832
+						$this->update_status($this->status);
833 833
 						break;
834 834
 
835 835
 					case 'gateway':
836
-						$this->update_meta( '_give_payment_gateway', $this->gateway );
836
+						$this->update_meta('_give_payment_gateway', $this->gateway);
837 837
 						break;
838 838
 
839 839
 					case 'mode':
840
-						$this->update_meta( '_give_payment_mode', $this->mode );
840
+						$this->update_meta('_give_payment_mode', $this->mode);
841 841
 						break;
842 842
 
843 843
 					case 'transaction_id':
844
-						$this->update_meta( '_give_payment_transaction_id', $this->transaction_id );
844
+						$this->update_meta('_give_payment_transaction_id', $this->transaction_id);
845 845
 						break;
846 846
 
847 847
 					case 'ip':
848
-						$this->update_meta( '_give_payment_donor_ip', $this->ip );
848
+						$this->update_meta('_give_payment_donor_ip', $this->ip);
849 849
 						break;
850 850
 
851 851
 					case 'customer_id':
852
-						$this->update_meta( '_give_payment_donor_id', $this->customer_id );
852
+						$this->update_meta('_give_payment_donor_id', $this->customer_id);
853 853
 						break;
854 854
 
855 855
 					// case 'user_id':
@@ -857,58 +857,58 @@  discard block
 block discarded – undo
857 857
 					// 	break;
858 858
 
859 859
 					case 'form_title':
860
-						$this->update_meta( '_give_payment_form_title', $this->form_title );
860
+						$this->update_meta('_give_payment_form_title', $this->form_title);
861 861
 						break;
862 862
 
863 863
 					case 'form_id':
864
-						$this->update_meta( '_give_payment_form_id', $this->form_id );
864
+						$this->update_meta('_give_payment_form_id', $this->form_id);
865 865
 						break;
866 866
 
867 867
 					case 'price_id':
868
-						$this->update_meta( '_give_payment_price_id', $this->price_id );
868
+						$this->update_meta('_give_payment_price_id', $this->price_id);
869 869
 						break;
870 870
 
871 871
 					case 'first_name':
872
-						$this->update_meta( '_give_donor_billing_first_name', $this->first_name );
872
+						$this->update_meta('_give_donor_billing_first_name', $this->first_name);
873 873
 						break;
874 874
 
875 875
 					case 'last_name':
876
-						$this->update_meta( '_give_donor_billing_last_name', $this->last_name );
876
+						$this->update_meta('_give_donor_billing_last_name', $this->last_name);
877 877
 						break;
878 878
 
879 879
 					case 'currency':
880
-						$this->update_meta( '_give_payment_currency', $this->currency );
880
+						$this->update_meta('_give_payment_currency', $this->currency);
881 881
 						break;
882 882
 
883 883
 					case 'address':
884
-						if ( ! empty( $this->address ) ) {
885
-							foreach ( $this->address as $address_name => $address ) {
886
-								switch ( $address_name ) {
884
+						if ( ! empty($this->address)) {
885
+							foreach ($this->address as $address_name => $address) {
886
+								switch ($address_name) {
887 887
 									case 'line1':
888
-										$this->update_meta( '_give_donor_billing_address1', $address );
888
+										$this->update_meta('_give_donor_billing_address1', $address);
889 889
 										break;
890 890
 
891 891
 									case 'line2':
892
-										$this->update_meta( '_give_donor_billing_address2', $address );
892
+										$this->update_meta('_give_donor_billing_address2', $address);
893 893
 										break;
894 894
 
895 895
 									default:
896
-										$this->update_meta( "_give_donor_billing_{$address_name}", $address );
896
+										$this->update_meta("_give_donor_billing_{$address_name}", $address);
897 897
 								}
898 898
 							}
899 899
 						}
900 900
 						break;
901 901
 
902 902
 					case 'email':
903
-						$this->update_meta( '_give_payment_donor_email', $this->email );
903
+						$this->update_meta('_give_payment_donor_email', $this->email);
904 904
 						break;
905 905
 
906 906
 					case 'key':
907
-						$this->update_meta( '_give_payment_purchase_key', $this->key );
907
+						$this->update_meta('_give_payment_purchase_key', $this->key);
908 908
 						break;
909 909
 
910 910
 					case 'number':
911
-						$this->update_meta( '_give_payment_number', $this->number );
911
+						$this->update_meta('_give_payment_number', $this->number);
912 912
 						break;
913 913
 
914 914
 					case 'date':
@@ -918,11 +918,11 @@  discard block
 block discarded – undo
918 918
 							'edit_date' => true,
919 919
 						);
920 920
 
921
-						wp_update_post( $args );
921
+						wp_update_post($args);
922 922
 						break;
923 923
 
924 924
 					case 'completed_date':
925
-						$this->update_meta( '_give_completed_date', $this->completed_date );
925
+						$this->update_meta('_give_completed_date', $this->completed_date);
926 926
 						break;
927 927
 
928 928
 					case 'parent_payment':
@@ -931,7 +931,7 @@  discard block
 block discarded – undo
931 931
 							'post_parent' => $this->parent_payment,
932 932
 						);
933 933
 
934
-						wp_update_post( $args );
934
+						wp_update_post($args);
935 935
 						break;
936 936
 
937 937
 					default:
@@ -942,40 +942,40 @@  discard block
 block discarded – undo
942 942
 						 *
943 943
 						 * @param Give_Payment $this Payment object.
944 944
 						 */
945
-						do_action( 'give_payment_save', $this, $key );
945
+						do_action('give_payment_save', $this, $key);
946 946
 						break;
947 947
 				}// End switch().
948 948
 			}// End foreach().
949 949
 
950
-			if ( 'pending' !== $this->status ) {
950
+			if ('pending' !== $this->status) {
951 951
 
952
-				$donor = new Give_Donor( $this->customer_id );
952
+				$donor = new Give_Donor($this->customer_id);
953 953
 
954 954
 				$total_change = $total_increase - $total_decrease;
955
-				if ( $total_change < 0 ) {
955
+				if ($total_change < 0) {
956 956
 
957
-					$total_change = - ( $total_change );
957
+					$total_change = - ($total_change);
958 958
 					// Decrease the donor's donation stats.
959
-					$donor->decrease_value( $total_change );
960
-					give_decrease_total_earnings( $total_change );
959
+					$donor->decrease_value($total_change);
960
+					give_decrease_total_earnings($total_change);
961 961
 
962
-				} elseif ( $total_change > 0 ) {
962
+				} elseif ($total_change > 0) {
963 963
 
964 964
 					// Increase the donor's donation stats.
965
-					$donor->increase_value( $total_change );
966
-					give_increase_total_earnings( $total_change );
965
+					$donor->increase_value($total_change);
966
+					give_increase_total_earnings($total_change);
967 967
 
968 968
 				}
969 969
 			}
970 970
 
971
-			$this->update_meta( '_give_payment_total', give_sanitize_amount_for_db( $this->total ) );
971
+			$this->update_meta('_give_payment_total', give_sanitize_amount_for_db($this->total));
972 972
 
973 973
 			$this->pending = array();
974 974
 			$saved         = true;
975 975
 		}// End if().
976 976
 
977
-		if ( true === $saved ) {
978
-			$this->setup_payment( $this->ID );
977
+		if (true === $saved) {
978
+			$this->setup_payment($this->ID);
979 979
 		}
980 980
 
981 981
 		return $saved;
@@ -993,12 +993,12 @@  discard block
 block discarded – undo
993 993
 	 *
994 994
 	 * @return bool           True when successful, false otherwise
995 995
 	 */
996
-	public function add_donation( $form_id = 0, $args = array(), $options = array() ) {
996
+	public function add_donation($form_id = 0, $args = array(), $options = array()) {
997 997
 
998
-		$donation = new Give_Donate_Form( $form_id );
998
+		$donation = new Give_Donate_Form($form_id);
999 999
 
1000 1000
 		// Bail if this post isn't a give donation form.
1001
-		if ( ! $donation || $donation->post_type !== 'give_forms' ) {
1001
+		if ( ! $donation || $donation->post_type !== 'give_forms') {
1002 1002
 			return false;
1003 1003
 		}
1004 1004
 
@@ -1008,59 +1008,59 @@  discard block
 block discarded – undo
1008 1008
 			'price_id' => false,
1009 1009
 		);
1010 1010
 
1011
-		$args = wp_parse_args( apply_filters( 'give_payment_add_donation_args', $args, $donation->ID ), $defaults );
1011
+		$args = wp_parse_args(apply_filters('give_payment_add_donation_args', $args, $donation->ID), $defaults);
1012 1012
 
1013 1013
 		// Allow overriding the price.
1014
-		if ( false !== $args['price'] ) {
1014
+		if (false !== $args['price']) {
1015 1015
 			$donation_amount = $args['price'];
1016 1016
 		} else {
1017 1017
 
1018 1018
 			// Deal with variable pricing.
1019
-			if ( give_has_variable_prices( $donation->ID ) ) {
1020
-				$prices          = give_get_meta( $form_id, '_give_donation_levels', true );
1019
+			if (give_has_variable_prices($donation->ID)) {
1020
+				$prices          = give_get_meta($form_id, '_give_donation_levels', true);
1021 1021
 				$donation_amount = '';
1022 1022
 				// Loop through prices.
1023
-				foreach ( $prices as $price ) {
1023
+				foreach ($prices as $price) {
1024 1024
 					// Find a match between price_id and level_id.
1025 1025
 					// First verify array keys exists THEN make the match.
1026
-					if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) )
1026
+					if ((isset($args['price_id']) && isset($price['_give_id']['level_id']))
1027 1027
 					     && $args['price_id'] == $price['_give_id']['level_id']
1028 1028
 					) {
1029 1029
 						$donation_amount = $price['_give_amount'];
1030 1030
 					}
1031 1031
 				}
1032 1032
 				// Fallback to the lowest price point.
1033
-				if ( $donation_amount == '' ) {
1034
-					$donation_amount  = give_get_lowest_price_option( $donation->ID );
1035
-					$args['price_id'] = give_get_lowest_price_id( $donation->ID );
1033
+				if ($donation_amount == '') {
1034
+					$donation_amount  = give_get_lowest_price_option($donation->ID);
1035
+					$args['price_id'] = give_get_lowest_price_id($donation->ID);
1036 1036
 				}
1037 1037
 			} else {
1038 1038
 				// Simple form price.
1039
-				$donation_amount = give_get_form_price( $donation->ID );
1039
+				$donation_amount = give_get_form_price($donation->ID);
1040 1040
 			}
1041 1041
 		}
1042 1042
 
1043 1043
 		// Sanitizing the price here so we don't have a dozen calls later.
1044
-		$donation_amount = give_maybe_sanitize_amount( $donation_amount );
1045
-		$total           = round( $donation_amount, give_get_price_decimals( $this->ID ) );
1044
+		$donation_amount = give_maybe_sanitize_amount($donation_amount);
1045
+		$total           = round($donation_amount, give_get_price_decimals($this->ID));
1046 1046
 
1047 1047
 		// Add Options.
1048 1048
 		$default_options = array();
1049
-		if ( false !== $args['price_id'] ) {
1049
+		if (false !== $args['price_id']) {
1050 1050
 			$default_options['price_id'] = (int) $args['price_id'];
1051 1051
 		}
1052
-		$options = wp_parse_args( $options, $default_options );
1052
+		$options = wp_parse_args($options, $default_options);
1053 1053
 
1054 1054
 		// Do not allow totals to go negative.
1055
-		if ( $total < 0 ) {
1055
+		if ($total < 0) {
1056 1056
 			$total = 0;
1057 1057
 		}
1058 1058
 
1059 1059
 		$donation = array(
1060 1060
 			'name'     => $donation->post_title,
1061 1061
 			'id'       => $donation->ID,
1062
-			'price'    => round( $total, give_get_price_decimals( $this->ID ) ),
1063
-			'subtotal' => round( $total, give_get_price_decimals( $this->ID ) ),
1062
+			'price'    => round($total, give_get_price_decimals($this->ID)),
1063
+			'subtotal' => round($total, give_get_price_decimals($this->ID)),
1064 1064
 			'price_id' => $args['price_id'],
1065 1065
 			'action'   => 'add',
1066 1066
 			'options'  => $options,
@@ -1068,7 +1068,7 @@  discard block
 block discarded – undo
1068 1068
 
1069 1069
 		$this->pending['donations'][] = $donation;
1070 1070
 
1071
-		$this->increase_subtotal( $total );
1071
+		$this->increase_subtotal($total);
1072 1072
 
1073 1073
 		return true;
1074 1074
 
@@ -1085,7 +1085,7 @@  discard block
 block discarded – undo
1085 1085
 	 *
1086 1086
 	 * @return bool           If the item was removed or not
1087 1087
 	 */
1088
-	public function remove_donation( $form_id, $args = array() ) {
1088
+	public function remove_donation($form_id, $args = array()) {
1089 1089
 
1090 1090
 		// Set some defaults.
1091 1091
 		$defaults = array(
@@ -1093,12 +1093,12 @@  discard block
 block discarded – undo
1093 1093
 			'price'    => false,
1094 1094
 			'price_id' => false,
1095 1095
 		);
1096
-		$args     = wp_parse_args( $args, $defaults );
1096
+		$args = wp_parse_args($args, $defaults);
1097 1097
 
1098
-		$form = new Give_Donate_Form( $form_id );
1098
+		$form = new Give_Donate_Form($form_id);
1099 1099
 
1100 1100
 		// Bail if this post isn't a valid give donation form.
1101
-		if ( ! $form || $form->post_type !== 'give_forms' ) {
1101
+		if ( ! $form || $form->post_type !== 'give_forms') {
1102 1102
 			return false;
1103 1103
 		}
1104 1104
 
@@ -1111,7 +1111,7 @@  discard block
 block discarded – undo
1111 1111
 
1112 1112
 		$this->pending['donations'][] = $pending_args;
1113 1113
 
1114
-		$this->decrease_subtotal( $this->total );
1114
+		$this->decrease_subtotal($this->total);
1115 1115
 
1116 1116
 		return true;
1117 1117
 	}
@@ -1127,13 +1127,13 @@  discard block
 block discarded – undo
1127 1127
 	 *
1128 1128
 	 * @return bool           If the note was specified or not
1129 1129
 	 */
1130
-	public function add_note( $note = false ) {
1130
+	public function add_note($note = false) {
1131 1131
 		// Bail if no note specified.
1132
-		if ( ! $note ) {
1132
+		if ( ! $note) {
1133 1133
 			return false;
1134 1134
 		}
1135 1135
 
1136
-		give_insert_payment_note( $this->ID, $note );
1136
+		give_insert_payment_note($this->ID, $note);
1137 1137
 	}
1138 1138
 
1139 1139
 	/**
@@ -1146,8 +1146,8 @@  discard block
 block discarded – undo
1146 1146
 	 *
1147 1147
 	 * @return void
1148 1148
 	 */
1149
-	private function increase_subtotal( $amount = 0.00 ) {
1150
-		$amount         = (float) $amount;
1149
+	private function increase_subtotal($amount = 0.00) {
1150
+		$amount = (float) $amount;
1151 1151
 		$this->subtotal += $amount;
1152 1152
 
1153 1153
 		$this->recalculate_total();
@@ -1163,11 +1163,11 @@  discard block
 block discarded – undo
1163 1163
 	 *
1164 1164
 	 * @return void
1165 1165
 	 */
1166
-	private function decrease_subtotal( $amount = 0.00 ) {
1167
-		$amount         = (float) $amount;
1166
+	private function decrease_subtotal($amount = 0.00) {
1167
+		$amount = (float) $amount;
1168 1168
 		$this->subtotal -= $amount;
1169 1169
 
1170
-		if ( $this->subtotal < 0 ) {
1170
+		if ($this->subtotal < 0) {
1171 1171
 			$this->subtotal = 0;
1172 1172
 		}
1173 1173
 
@@ -1196,24 +1196,24 @@  discard block
 block discarded – undo
1196 1196
 	 *
1197 1197
 	 * @return bool   $updated Returns if the status was successfully updated.
1198 1198
 	 */
1199
-	public function update_status( $status = false ) {
1199
+	public function update_status($status = false) {
1200 1200
 
1201 1201
 		// standardize the 'complete(d)' status.
1202
-		if ( $status == 'completed' || $status == 'complete' ) {
1202
+		if ($status == 'completed' || $status == 'complete') {
1203 1203
 			$status = 'publish';
1204 1204
 		}
1205 1205
 
1206
-		$old_status = ! empty( $this->old_status ) ? $this->old_status : false;
1206
+		$old_status = ! empty($this->old_status) ? $this->old_status : false;
1207 1207
 
1208
-		if ( $old_status === $status ) {
1208
+		if ($old_status === $status) {
1209 1209
 			return false; // Don't permit status changes that aren't changes.
1210 1210
 		}
1211 1211
 
1212
-		$do_change = apply_filters( 'give_should_update_payment_status', true, $this->ID, $status, $old_status );
1212
+		$do_change = apply_filters('give_should_update_payment_status', true, $this->ID, $status, $old_status);
1213 1213
 
1214 1214
 		$updated = false;
1215 1215
 
1216
-		if ( $do_change ) {
1216
+		if ($do_change) {
1217 1217
 
1218 1218
 			/**
1219 1219
 			 * Fires before changing payment status.
@@ -1224,21 +1224,21 @@  discard block
 block discarded – undo
1224 1224
 			 * @param string $status     The new status.
1225 1225
 			 * @param string $old_status The old status.
1226 1226
 			 */
1227
-			do_action( 'give_before_payment_status_change', $this->ID, $status, $old_status );
1227
+			do_action('give_before_payment_status_change', $this->ID, $status, $old_status);
1228 1228
 
1229 1229
 			$update_fields = array(
1230 1230
 				'ID'          => $this->ID,
1231 1231
 				'post_status' => $status,
1232
-				'edit_date'   => current_time( 'mysql' ),
1232
+				'edit_date'   => current_time('mysql'),
1233 1233
 			);
1234 1234
 
1235
-			$updated = wp_update_post( apply_filters( 'give_update_payment_status_fields', $update_fields ) );
1235
+			$updated = wp_update_post(apply_filters('give_update_payment_status_fields', $update_fields));
1236 1236
 
1237 1237
 			$all_payment_statuses  = give_get_payment_statuses();
1238
-			$this->status_nicename = array_key_exists( $status, $all_payment_statuses ) ? $all_payment_statuses[ $status ] : ucfirst( $status );
1238
+			$this->status_nicename = array_key_exists($status, $all_payment_statuses) ? $all_payment_statuses[$status] : ucfirst($status);
1239 1239
 
1240 1240
 			// Process any specific status functions.
1241
-			switch ( $status ) {
1241
+			switch ($status) {
1242 1242
 				case 'refunded':
1243 1243
 					$this->process_refund();
1244 1244
 					break;
@@ -1265,7 +1265,7 @@  discard block
 block discarded – undo
1265 1265
 			 * @param string $status     The new status.
1266 1266
 			 * @param string $old_status The old status.
1267 1267
 			 */
1268
-			do_action( 'give_update_payment_status', $this->ID, $status, $old_status );
1268
+			do_action('give_update_payment_status', $this->ID, $status, $old_status);
1269 1269
 
1270 1270
 		}// End if().
1271 1271
 
@@ -1300,24 +1300,24 @@  discard block
 block discarded – undo
1300 1300
 	 *
1301 1301
 	 * @return mixed             The value from the post meta
1302 1302
 	 */
1303
-	public function get_meta( $meta_key = '_give_payment_meta', $single = true ) {
1304
-		if( ! has_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta' ) && ! doing_filter( 'get_post_metadata' ) ) {
1305
-			add_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4 );
1303
+	public function get_meta($meta_key = '_give_payment_meta', $single = true) {
1304
+		if ( ! has_filter('get_post_metadata', 'give_bc_v20_get_payment_meta') && ! doing_filter('get_post_metadata')) {
1305
+			add_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4);
1306 1306
 		}
1307 1307
 
1308
-		$meta = give_get_meta( $this->ID, $meta_key, $single );
1308
+		$meta = give_get_meta($this->ID, $meta_key, $single);
1309 1309
 
1310 1310
 		/**
1311 1311
 		 * Filter the specific meta key value.
1312 1312
 		 *
1313 1313
 		 * @since 1.5
1314 1314
 		 */
1315
-		$meta = apply_filters( "give_get_payment_meta_{$meta_key}", $meta, $this->ID );
1315
+		$meta = apply_filters("give_get_payment_meta_{$meta_key}", $meta, $this->ID);
1316 1316
 
1317 1317
 		// Security check.
1318
-		if ( is_serialized( $meta ) ) {
1319
-			preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $meta, $matches );
1320
-			if ( ! empty( $matches ) ) {
1318
+		if (is_serialized($meta)) {
1319
+			preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $meta, $matches);
1320
+			if ( ! empty($matches)) {
1321 1321
 				$meta = array();
1322 1322
 			}
1323 1323
 		}
@@ -1327,7 +1327,7 @@  discard block
 block discarded – undo
1327 1327
 		 *
1328 1328
 		 * @since 1.5
1329 1329
 		 */
1330
-		return apply_filters( 'give_get_payment_meta', $meta, $this->ID, $meta_key );
1330
+		return apply_filters('give_get_payment_meta', $meta, $this->ID, $meta_key);
1331 1331
 	}
1332 1332
 
1333 1333
 	/**
@@ -1342,8 +1342,8 @@  discard block
 block discarded – undo
1342 1342
 	 *
1343 1343
 	 * @return int|bool           Meta ID if the key didn't exist, true on successful update, false on failure
1344 1344
 	 */
1345
-	public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) {
1346
-		if ( empty( $meta_key ) ) {
1345
+	public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') {
1346
+		if (empty($meta_key)) {
1347 1347
 			return false;
1348 1348
 		}
1349 1349
 
@@ -1353,9 +1353,9 @@  discard block
 block discarded – undo
1353 1353
 		 *
1354 1354
 		 * @since 1.5
1355 1355
 		 */
1356
-		$meta_value = apply_filters( "give_update_payment_meta_{$meta_key}", $meta_value, $this->ID );
1356
+		$meta_value = apply_filters("give_update_payment_meta_{$meta_key}", $meta_value, $this->ID);
1357 1357
 
1358
-		return give_update_meta( $this->ID, $meta_key, $meta_value, $prev_value );
1358
+		return give_update_meta($this->ID, $meta_key, $meta_value, $prev_value);
1359 1359
 	}
1360 1360
 
1361 1361
 	/**
@@ -1370,14 +1370,14 @@  discard block
 block discarded – undo
1370 1370
 		$process_refund = true;
1371 1371
 
1372 1372
 		// If the payment was not in publish or revoked status, don't decrement stats as they were never incremented.
1373
-		if ( 'publish' != $this->old_status || 'refunded' != $this->status ) {
1373
+		if ('publish' != $this->old_status || 'refunded' != $this->status) {
1374 1374
 			$process_refund = false;
1375 1375
 		}
1376 1376
 
1377 1377
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments.
1378
-		$process_refund = apply_filters( 'give_should_process_refund', $process_refund, $this );
1378
+		$process_refund = apply_filters('give_should_process_refund', $process_refund, $this);
1379 1379
 
1380
-		if ( false === $process_refund ) {
1380
+		if (false === $process_refund) {
1381 1381
 			return;
1382 1382
 		}
1383 1383
 
@@ -1388,13 +1388,13 @@  discard block
 block discarded – undo
1388 1388
 		 *
1389 1389
 		 * @param Give_Payment $this Payment object.
1390 1390
 		 */
1391
-		do_action( 'give_pre_refund_payment', $this );
1391
+		do_action('give_pre_refund_payment', $this);
1392 1392
 
1393
-		$decrease_earnings       = apply_filters( 'give_decrease_store_earnings_on_refund', true, $this );
1394
-		$decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_refund', true, $this );
1395
-		$decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_refund', true, $this );
1393
+		$decrease_earnings       = apply_filters('give_decrease_store_earnings_on_refund', true, $this);
1394
+		$decrease_customer_value = apply_filters('give_decrease_customer_value_on_refund', true, $this);
1395
+		$decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_refund', true, $this);
1396 1396
 
1397
-		$this->maybe_alter_stats( $decrease_earnings, $decrease_customer_value, $decrease_purchase_count );
1397
+		$this->maybe_alter_stats($decrease_earnings, $decrease_customer_value, $decrease_purchase_count);
1398 1398
 		$this->delete_sales_logs();
1399 1399
 
1400 1400
 		// @todo: Refresh only range related stat cache
@@ -1407,7 +1407,7 @@  discard block
 block discarded – undo
1407 1407
 		 *
1408 1408
 		 * @param Give_Payment $this Payment object.
1409 1409
 		 */
1410
-		do_action( 'give_post_refund_payment', $this );
1410
+		do_action('give_post_refund_payment', $this);
1411 1411
 	}
1412 1412
 
1413 1413
 	/**
@@ -1434,26 +1434,26 @@  discard block
 block discarded – undo
1434 1434
 		$process_pending = true;
1435 1435
 
1436 1436
 		// If the payment was not in publish or revoked status, don't decrement stats as they were never incremented.
1437
-		if ( 'publish' != $this->old_status || 'pending' != $this->status ) {
1437
+		if ('publish' != $this->old_status || 'pending' != $this->status) {
1438 1438
 			$process_pending = false;
1439 1439
 		}
1440 1440
 
1441 1441
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments.
1442
-		$process_pending = apply_filters( 'give_should_process_pending', $process_pending, $this );
1442
+		$process_pending = apply_filters('give_should_process_pending', $process_pending, $this);
1443 1443
 
1444
-		if ( false === $process_pending ) {
1444
+		if (false === $process_pending) {
1445 1445
 			return;
1446 1446
 		}
1447 1447
 
1448
-		$decrease_earnings       = apply_filters( 'give_decrease_earnings_on_pending', true, $this );
1449
-		$decrease_donor_value    = apply_filters( 'give_decrease_donor_value_on_pending', true, $this );
1450
-		$decrease_donation_count = apply_filters( 'give_decrease_donors_donation_count_on_pending', true, $this );
1448
+		$decrease_earnings       = apply_filters('give_decrease_earnings_on_pending', true, $this);
1449
+		$decrease_donor_value    = apply_filters('give_decrease_donor_value_on_pending', true, $this);
1450
+		$decrease_donation_count = apply_filters('give_decrease_donors_donation_count_on_pending', true, $this);
1451 1451
 
1452
-		$this->maybe_alter_stats( $decrease_earnings, $decrease_donor_value, $decrease_donation_count );
1452
+		$this->maybe_alter_stats($decrease_earnings, $decrease_donor_value, $decrease_donation_count);
1453 1453
 		$this->delete_sales_logs();
1454 1454
 
1455 1455
 		$this->completed_date = false;
1456
-		$this->update_meta( '_give_completed_date', '' );
1456
+		$this->update_meta('_give_completed_date', '');
1457 1457
 
1458 1458
 		// @todo: Refresh only range related stat cache
1459 1459
 		give_delete_donation_stats();
@@ -1471,26 +1471,26 @@  discard block
 block discarded – undo
1471 1471
 		$process_cancelled = true;
1472 1472
 
1473 1473
 		// If the payment was not in publish or revoked status, don't decrement stats as they were never incremented.
1474
-		if ( 'publish' != $this->old_status || 'cancelled' != $this->status ) {
1474
+		if ('publish' != $this->old_status || 'cancelled' != $this->status) {
1475 1475
 			$process_cancelled = false;
1476 1476
 		}
1477 1477
 
1478 1478
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments.
1479
-		$process_cancelled = apply_filters( 'give_should_process_cancelled', $process_cancelled, $this );
1479
+		$process_cancelled = apply_filters('give_should_process_cancelled', $process_cancelled, $this);
1480 1480
 
1481
-		if ( false === $process_cancelled ) {
1481
+		if (false === $process_cancelled) {
1482 1482
 			return;
1483 1483
 		}
1484 1484
 
1485
-		$decrease_earnings       = apply_filters( 'give_decrease_earnings_on_cancelled', true, $this );
1486
-		$decrease_donor_value    = apply_filters( 'give_decrease_donor_value_on_cancelled', true, $this );
1487
-		$decrease_donation_count = apply_filters( 'give_decrease_donors_donation_count_on_cancelled', true, $this );
1485
+		$decrease_earnings       = apply_filters('give_decrease_earnings_on_cancelled', true, $this);
1486
+		$decrease_donor_value    = apply_filters('give_decrease_donor_value_on_cancelled', true, $this);
1487
+		$decrease_donation_count = apply_filters('give_decrease_donors_donation_count_on_cancelled', true, $this);
1488 1488
 
1489
-		$this->maybe_alter_stats( $decrease_earnings, $decrease_donor_value, $decrease_donation_count );
1489
+		$this->maybe_alter_stats($decrease_earnings, $decrease_donor_value, $decrease_donation_count);
1490 1490
 		$this->delete_sales_logs();
1491 1491
 
1492 1492
 		$this->completed_date = false;
1493
-		$this->update_meta( '_give_completed_date', '' );
1493
+		$this->update_meta('_give_completed_date', '');
1494 1494
 
1495 1495
 		// @todo: Refresh only range related stat cache
1496 1496
 		give_delete_donation_stats();
@@ -1506,26 +1506,26 @@  discard block
 block discarded – undo
1506 1506
 		$process_revoked = true;
1507 1507
 
1508 1508
 		// If the payment was not in publish, don't decrement stats as they were never incremented.
1509
-		if ( 'publish' != $this->old_status || 'revoked' != $this->status ) {
1509
+		if ('publish' != $this->old_status || 'revoked' != $this->status) {
1510 1510
 			$process_revoked = false;
1511 1511
 		}
1512 1512
 
1513 1513
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments.
1514
-		$process_revoked = apply_filters( 'give_should_process_revoked', $process_revoked, $this );
1514
+		$process_revoked = apply_filters('give_should_process_revoked', $process_revoked, $this);
1515 1515
 
1516
-		if ( false === $process_revoked ) {
1516
+		if (false === $process_revoked) {
1517 1517
 			return;
1518 1518
 		}
1519 1519
 
1520
-		$decrease_earnings       = apply_filters( 'give_decrease_earnings_on_revoked', true, $this );
1521
-		$decrease_donor_value    = apply_filters( 'give_decrease_donor_value_on_revoked', true, $this );
1522
-		$decrease_donation_count = apply_filters( 'give_decrease_donors_donation_count_on_revoked', true, $this );
1520
+		$decrease_earnings       = apply_filters('give_decrease_earnings_on_revoked', true, $this);
1521
+		$decrease_donor_value    = apply_filters('give_decrease_donor_value_on_revoked', true, $this);
1522
+		$decrease_donation_count = apply_filters('give_decrease_donors_donation_count_on_revoked', true, $this);
1523 1523
 
1524
-		$this->maybe_alter_stats( $decrease_earnings, $decrease_donor_value, $decrease_donation_count );
1524
+		$this->maybe_alter_stats($decrease_earnings, $decrease_donor_value, $decrease_donation_count);
1525 1525
 		$this->delete_sales_logs();
1526 1526
 
1527 1527
 		$this->completed_date = false;
1528
-		$this->update_meta( '_give_completed_date', '' );
1528
+		$this->update_meta('_give_completed_date', '');
1529 1529
 
1530 1530
 		// @todo: Refresh only range related stat cache
1531 1531
 		give_delete_donation_stats();
@@ -1543,25 +1543,25 @@  discard block
 block discarded – undo
1543 1543
 	 *
1544 1544
 	 * @return void
1545 1545
 	 */
1546
-	private function maybe_alter_stats( $alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count ) {
1546
+	private function maybe_alter_stats($alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count) {
1547 1547
 
1548
-		give_undo_donation( $this->ID );
1548
+		give_undo_donation($this->ID);
1549 1549
 
1550 1550
 		// Decrease store earnings.
1551
-		if ( true === $alter_store_earnings ) {
1552
-			give_decrease_total_earnings( $this->total );
1551
+		if (true === $alter_store_earnings) {
1552
+			give_decrease_total_earnings($this->total);
1553 1553
 		}
1554 1554
 
1555 1555
 		// Decrement the stats for the donor.
1556
-		if ( ! empty( $this->customer_id ) ) {
1556
+		if ( ! empty($this->customer_id)) {
1557 1557
 
1558
-			$donor = new Give_Donor( $this->customer_id );
1558
+			$donor = new Give_Donor($this->customer_id);
1559 1559
 
1560
-			if ( true === $alter_customer_value ) {
1561
-				$donor->decrease_value( $this->total );
1560
+			if (true === $alter_customer_value) {
1561
+				$donor->decrease_value($this->total);
1562 1562
 			}
1563 1563
 
1564
-			if ( true === $alter_customer_purchase_count ) {
1564
+			if (true === $alter_customer_purchase_count) {
1565 1565
 				$donor->decrease_donation_count();
1566 1566
 			}
1567 1567
 		}
@@ -1578,7 +1578,7 @@  discard block
 block discarded – undo
1578 1578
 	 */
1579 1579
 	private function delete_sales_logs() {
1580 1580
 		// Remove related sale log entries.
1581
-		Give()->logs->delete_logs( $this->ID );
1581
+		Give()->logs->delete_logs($this->ID);
1582 1582
 	}
1583 1583
 
1584 1584
 	/**
@@ -1599,13 +1599,13 @@  discard block
 block discarded – undo
1599 1599
 	 * @return string The date the payment was completed
1600 1600
 	 */
1601 1601
 	private function setup_completed_date() {
1602
-		$payment = get_post( $this->ID );
1602
+		$payment = get_post($this->ID);
1603 1603
 
1604
-		if ( 'pending' == $payment->post_status || 'preapproved' == $payment->post_status ) {
1604
+		if ('pending' == $payment->post_status || 'preapproved' == $payment->post_status) {
1605 1605
 			return false; // This payment was never completed.
1606 1606
 		}
1607 1607
 
1608
-		$date = ( $date = $this->get_meta( '_give_completed_date', true ) ) ? $date : $payment->modified_date;
1608
+		$date = ($date = $this->get_meta('_give_completed_date', true)) ? $date : $payment->modified_date;
1609 1609
 
1610 1610
 		return $date;
1611 1611
 	}
@@ -1619,7 +1619,7 @@  discard block
 block discarded – undo
1619 1619
 	 * @return string The payment mode
1620 1620
 	 */
1621 1621
 	private function setup_mode() {
1622
-		return $this->get_meta( '_give_payment_mode' );
1622
+		return $this->get_meta('_give_payment_mode');
1623 1623
 	}
1624 1624
 
1625 1625
 	/**
@@ -1631,7 +1631,7 @@  discard block
 block discarded – undo
1631 1631
 	 * @return bool The payment import
1632 1632
 	 */
1633 1633
 	private function setup_import() {
1634
-		return (bool) $this->get_meta( '_give_payment_import' );
1634
+		return (bool) $this->get_meta('_give_payment_import');
1635 1635
 	}
1636 1636
 
1637 1637
 	/**
@@ -1643,9 +1643,9 @@  discard block
 block discarded – undo
1643 1643
 	 * @return float The payment total
1644 1644
 	 */
1645 1645
 	private function setup_total() {
1646
-		$amount = $this->get_meta( '_give_payment_total', true );
1646
+		$amount = $this->get_meta('_give_payment_total', true);
1647 1647
 
1648
-		return round( floatval( $amount ), give_get_price_decimals( $this->ID ) );
1648
+		return round(floatval($amount), give_get_price_decimals($this->ID));
1649 1649
 	}
1650 1650
 
1651 1651
 	/**
@@ -1672,17 +1672,16 @@  discard block
 block discarded – undo
1672 1672
 	 * @return string The currency for the payment
1673 1673
 	 */
1674 1674
 	private function setup_currency() {
1675
-		$currency = $this->get_meta( '_give_payment_currency', true );
1676
-		$currency = ! empty( $currency ) ?
1677
-			$currency :
1678
-			/**
1675
+		$currency = $this->get_meta('_give_payment_currency', true);
1676
+		$currency = ! empty($currency) ?
1677
+			$currency : /**
1679 1678
 			 * Filter the default donation currency
1680 1679
 			 *
1681 1680
 			 * @since 1.5
1682 1681
 			 */
1683 1682
 			apply_filters(
1684 1683
 				'give_payment_currency_default',
1685
-				give_get_currency( $this->form_id, $this ),
1684
+				give_get_currency($this->form_id, $this),
1686 1685
 				$this
1687 1686
 			);
1688 1687
 
@@ -1698,7 +1697,7 @@  discard block
 block discarded – undo
1698 1697
 	 * @return string The gateway
1699 1698
 	 */
1700 1699
 	private function setup_gateway() {
1701
-		$gateway = $this->get_meta( '_give_payment_gateway', true );
1700
+		$gateway = $this->get_meta('_give_payment_gateway', true);
1702 1701
 
1703 1702
 		return $gateway;
1704 1703
 	}
@@ -1712,11 +1711,11 @@  discard block
 block discarded – undo
1712 1711
 	 * @return string The donation ID
1713 1712
 	 */
1714 1713
 	private function setup_transaction_id() {
1715
-		$transaction_id = $this->get_meta( '_give_payment_transaction_id', true );
1714
+		$transaction_id = $this->get_meta('_give_payment_transaction_id', true);
1716 1715
 
1717
-		if ( empty( $transaction_id ) ) {
1716
+		if (empty($transaction_id)) {
1718 1717
 			$gateway        = $this->gateway;
1719
-			$transaction_id = apply_filters( "give_get_payment_transaction_id-{$gateway}", $this->ID );
1718
+			$transaction_id = apply_filters("give_get_payment_transaction_id-{$gateway}", $this->ID);
1720 1719
 		}
1721 1720
 
1722 1721
 		return $transaction_id;
@@ -1732,7 +1731,7 @@  discard block
 block discarded – undo
1732 1731
 	 * @return string The IP address for the payment
1733 1732
 	 */
1734 1733
 	private function setup_ip() {
1735
-		$ip = $this->get_meta( '_give_payment_donor_ip', true );
1734
+		$ip = $this->get_meta('_give_payment_donor_ip', true);
1736 1735
 
1737 1736
 		return $ip;
1738 1737
 	}
@@ -1747,7 +1746,7 @@  discard block
 block discarded – undo
1747 1746
 	 * @return int The Donor ID.
1748 1747
 	 */
1749 1748
 	private function setup_donor_id() {
1750
-		$donor_id = $this->get_meta( '_give_payment_donor_id', true );
1749
+		$donor_id = $this->get_meta('_give_payment_donor_id', true);
1751 1750
 
1752 1751
 		return $donor_id;
1753 1752
 	}
@@ -1764,8 +1763,8 @@  discard block
 block discarded – undo
1764 1763
 	 */
1765 1764
 	private function setup_user_id() {
1766 1765
 
1767
-		$donor   = Give()->customers->get_customer_by( 'id', $this->customer_id );
1768
-		$user_id = $donor ? absint( $donor->user_id ) : 0;
1766
+		$donor   = Give()->customers->get_customer_by('id', $this->customer_id);
1767
+		$user_id = $donor ? absint($donor->user_id) : 0;
1769 1768
 
1770 1769
 
1771 1770
 		return $user_id;
@@ -1782,10 +1781,10 @@  discard block
 block discarded – undo
1782 1781
 	 * @return string The email address for the payment.
1783 1782
 	 */
1784 1783
 	private function setup_email() {
1785
-		$email = $this->get_meta( '_give_payment_donor_email', true );
1784
+		$email = $this->get_meta('_give_payment_donor_email', true);
1786 1785
 
1787
-		if ( empty( $email ) && $this->customer_id ) {
1788
-			$email = Give()->donors->get_column( 'email', $this->customer_id );
1786
+		if (empty($email) && $this->customer_id) {
1787
+			$email = Give()->donors->get_column('email', $this->customer_id);
1789 1788
 		}
1790 1789
 
1791 1790
 		return $email;
@@ -1805,22 +1804,22 @@  discard block
 block discarded – undo
1805 1804
 			'last_name'  => $this->last_name,
1806 1805
 		);
1807 1806
 
1808
-		$user_info = isset( $this->payment_meta['user_info'] ) ? $this->payment_meta['user_info'] : array();
1807
+		$user_info = isset($this->payment_meta['user_info']) ? $this->payment_meta['user_info'] : array();
1809 1808
 
1810
-		if ( is_serialized( $user_info ) ) {
1811
-			preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches );
1812
-			if ( ! empty( $matches ) ) {
1809
+		if (is_serialized($user_info)) {
1810
+			preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches);
1811
+			if ( ! empty($matches)) {
1813 1812
 				$user_info = array();
1814 1813
 			}
1815 1814
 		}
1816 1815
 
1817
-		$user_info = wp_parse_args( $user_info, $defaults );
1816
+		$user_info = wp_parse_args($user_info, $defaults);
1818 1817
 
1819
-		if ( empty( $user_info ) ) {
1818
+		if (empty($user_info)) {
1820 1819
 			// Get the donor, but only if it's been created.
1821
-			$donor = new Give_Donor( $this->customer_id );
1820
+			$donor = new Give_Donor($this->customer_id);
1822 1821
 
1823
-			if ( $donor->id > 0 ) {
1822
+			if ($donor->id > 0) {
1824 1823
 				$user_info = array(
1825 1824
 					'first_name' => $donor->get_first_name(),
1826 1825
 					'last_name'  => $donor->get_last_name(),
@@ -1830,25 +1829,25 @@  discard block
 block discarded – undo
1830 1829
 			}
1831 1830
 		} else {
1832 1831
 			// Get the donor, but only if it's been created.
1833
-			$donor = new Give_Donor( $this->customer_id );
1832
+			$donor = new Give_Donor($this->customer_id);
1834 1833
 
1835
-			if ( $donor->id > 0 ) {
1836
-				foreach ( $user_info as $key => $value ) {
1837
-					if ( ! empty( $value ) ) {
1834
+			if ($donor->id > 0) {
1835
+				foreach ($user_info as $key => $value) {
1836
+					if ( ! empty($value)) {
1838 1837
 						continue;
1839 1838
 					}
1840 1839
 
1841
-					switch ( $key ) {
1840
+					switch ($key) {
1842 1841
 						case 'first_name':
1843
-							$user_info[ $key ] = $donor->get_first_name();
1842
+							$user_info[$key] = $donor->get_first_name();
1844 1843
 							break;
1845 1844
 
1846 1845
 						case 'last_name':
1847
-							$user_info[ $key ] = $donor->get_last_name();
1846
+							$user_info[$key] = $donor->get_last_name();
1848 1847
 							break;
1849 1848
 
1850 1849
 						case 'email':
1851
-							$user_info[ $key ] = $donor->email;
1850
+							$user_info[$key] = $donor->email;
1852 1851
 							break;
1853 1852
 					}
1854 1853
 				}
@@ -1868,12 +1867,12 @@  discard block
 block discarded – undo
1868 1867
 	 * @return array The Address information for the payment.
1869 1868
 	 */
1870 1869
 	private function setup_address() {
1871
-		$address['line1']   = give_get_meta( $this->ID, '_give_donor_billing_address1', true, '' );
1872
-		$address['line2']   = give_get_meta( $this->ID, '_give_donor_billing_address2', true, '' );
1873
-		$address['city']    = give_get_meta( $this->ID, '_give_donor_billing_city', true, '' );
1874
-		$address['state']   = give_get_meta( $this->ID, '_give_donor_billing_state', true, '' );
1875
-		$address['zip']     = give_get_meta( $this->ID, '_give_donor_billing_zip', true, '' );
1876
-		$address['country'] = give_get_meta( $this->ID, '_give_donor_billing_country', true, '' );
1870
+		$address['line1']   = give_get_meta($this->ID, '_give_donor_billing_address1', true, '');
1871
+		$address['line2']   = give_get_meta($this->ID, '_give_donor_billing_address2', true, '');
1872
+		$address['city']    = give_get_meta($this->ID, '_give_donor_billing_city', true, '');
1873
+		$address['state']   = give_get_meta($this->ID, '_give_donor_billing_state', true, '');
1874
+		$address['zip']     = give_get_meta($this->ID, '_give_donor_billing_zip', true, '');
1875
+		$address['country'] = give_get_meta($this->ID, '_give_donor_billing_country', true, '');
1877 1876
 
1878 1877
 		return $address;
1879 1878
 	}
@@ -1888,7 +1887,7 @@  discard block
 block discarded – undo
1888 1887
 	 */
1889 1888
 	private function setup_form_title() {
1890 1889
 
1891
-		$form_id = $this->get_meta( '_give_payment_form_title', true );
1890
+		$form_id = $this->get_meta('_give_payment_form_title', true);
1892 1891
 
1893 1892
 		return $form_id;
1894 1893
 	}
@@ -1903,7 +1902,7 @@  discard block
 block discarded – undo
1903 1902
 	 */
1904 1903
 	private function setup_form_id() {
1905 1904
 
1906
-		$form_id = $this->get_meta( '_give_payment_form_id', true );
1905
+		$form_id = $this->get_meta('_give_payment_form_id', true);
1907 1906
 
1908 1907
 		return $form_id;
1909 1908
 	}
@@ -1917,7 +1916,7 @@  discard block
 block discarded – undo
1917 1916
 	 * @return int The Form Price ID.
1918 1917
 	 */
1919 1918
 	private function setup_price_id() {
1920
-		$price_id = $this->get_meta( '_give_payment_price_id', true );
1919
+		$price_id = $this->get_meta('_give_payment_price_id', true);
1921 1920
 
1922 1921
 		return $price_id;
1923 1922
 	}
@@ -1931,7 +1930,7 @@  discard block
 block discarded – undo
1931 1930
 	 * @return string The Payment Key.
1932 1931
 	 */
1933 1932
 	private function setup_payment_key() {
1934
-		$key = $this->get_meta( '_give_payment_purchase_key', true );
1933
+		$key = $this->get_meta('_give_payment_purchase_key', true);
1935 1934
 
1936 1935
 		return $key;
1937 1936
 	}
@@ -1947,11 +1946,11 @@  discard block
 block discarded – undo
1947 1946
 	private function setup_payment_number() {
1948 1947
 		$number = $this->ID;
1949 1948
 
1950
-		if ( give_get_option( 'enable_sequential' ) ) {
1949
+		if (give_get_option('enable_sequential')) {
1951 1950
 
1952
-			$number = $this->get_meta( '_give_payment_number', true );
1951
+			$number = $this->get_meta('_give_payment_number', true);
1953 1952
 
1954
-			if ( ! $number ) {
1953
+			if ( ! $number) {
1955 1954
 
1956 1955
 				$number = $this->ID;
1957 1956
 
@@ -1969,7 +1968,7 @@  discard block
 block discarded – undo
1969 1968
 	 * @return array The payment object as an array.
1970 1969
 	 */
1971 1970
 	public function array_convert() {
1972
-		return get_object_vars( $this );
1971
+		return get_object_vars($this);
1973 1972
 	}
1974 1973
 
1975 1974
 
@@ -1982,7 +1981,7 @@  discard block
 block discarded – undo
1982 1981
 	 * @return bool
1983 1982
 	 */
1984 1983
 	public function is_completed() {
1985
-		return ( 'publish' === $this->status && $this->completed_date );
1984
+		return ('publish' === $this->status && $this->completed_date);
1986 1985
 	}
1987 1986
 
1988 1987
 	/**
@@ -1994,7 +1993,7 @@  discard block
 block discarded – undo
1994 1993
 	 * @return string Date payment was completed.
1995 1994
 	 */
1996 1995
 	private function get_completed_date() {
1997
-		return apply_filters( 'give_payment_completed_date', $this->completed_date, $this->ID, $this );
1996
+		return apply_filters('give_payment_completed_date', $this->completed_date, $this->ID, $this);
1998 1997
 	}
1999 1998
 
2000 1999
 	/**
@@ -2006,7 +2005,7 @@  discard block
 block discarded – undo
2006 2005
 	 * @return float Payment subtotal.
2007 2006
 	 */
2008 2007
 	private function get_subtotal() {
2009
-		return apply_filters( 'give_get_payment_subtotal', $this->subtotal, $this->ID, $this );
2008
+		return apply_filters('give_get_payment_subtotal', $this->subtotal, $this->ID, $this);
2010 2009
 	}
2011 2010
 
2012 2011
 	/**
@@ -2018,7 +2017,7 @@  discard block
 block discarded – undo
2018 2017
 	 * @return string Payment currency code.
2019 2018
 	 */
2020 2019
 	private function get_currency() {
2021
-		return apply_filters( 'give_payment_currency_code', $this->currency, $this->ID, $this );
2020
+		return apply_filters('give_payment_currency_code', $this->currency, $this->ID, $this);
2022 2021
 	}
2023 2022
 
2024 2023
 	/**
@@ -2030,7 +2029,7 @@  discard block
 block discarded – undo
2030 2029
 	 * @return string Gateway used.
2031 2030
 	 */
2032 2031
 	private function get_gateway() {
2033
-		return apply_filters( 'give_payment_gateway', $this->gateway, $this->ID, $this );
2032
+		return apply_filters('give_payment_gateway', $this->gateway, $this->ID, $this);
2034 2033
 	}
2035 2034
 
2036 2035
 	/**
@@ -2042,7 +2041,7 @@  discard block
 block discarded – undo
2042 2041
 	 * @return string Donation ID from merchant processor.
2043 2042
 	 */
2044 2043
 	private function get_transaction_id() {
2045
-		return apply_filters( 'give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this );
2044
+		return apply_filters('give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this);
2046 2045
 	}
2047 2046
 
2048 2047
 	/**
@@ -2054,7 +2053,7 @@  discard block
 block discarded – undo
2054 2053
 	 * @return string Payment IP address
2055 2054
 	 */
2056 2055
 	private function get_ip() {
2057
-		return apply_filters( 'give_payment_user_ip', $this->ip, $this->ID, $this );
2056
+		return apply_filters('give_payment_user_ip', $this->ip, $this->ID, $this);
2058 2057
 	}
2059 2058
 
2060 2059
 	/**
@@ -2066,7 +2065,7 @@  discard block
 block discarded – undo
2066 2065
 	 * @return int Payment donor ID.
2067 2066
 	 */
2068 2067
 	private function get_donor_id() {
2069
-		return apply_filters( 'give_payment_customer_id', $this->customer_id, $this->ID, $this );
2068
+		return apply_filters('give_payment_customer_id', $this->customer_id, $this->ID, $this);
2070 2069
 	}
2071 2070
 
2072 2071
 	/**
@@ -2078,7 +2077,7 @@  discard block
 block discarded – undo
2078 2077
 	 * @return int Payment user ID.
2079 2078
 	 */
2080 2079
 	private function get_user_id() {
2081
-		return apply_filters( 'give_payment_user_id', $this->user_id, $this->ID, $this );
2080
+		return apply_filters('give_payment_user_id', $this->user_id, $this->ID, $this);
2082 2081
 	}
2083 2082
 
2084 2083
 	/**
@@ -2090,7 +2089,7 @@  discard block
 block discarded – undo
2090 2089
 	 * @return string Payment donor email.
2091 2090
 	 */
2092 2091
 	private function get_email() {
2093
-		return apply_filters( 'give_payment_user_email', $this->email, $this->ID, $this );
2092
+		return apply_filters('give_payment_user_email', $this->email, $this->ID, $this);
2094 2093
 	}
2095 2094
 
2096 2095
 	/**
@@ -2102,7 +2101,7 @@  discard block
 block discarded – undo
2102 2101
 	 * @return array Payment user info.
2103 2102
 	 */
2104 2103
 	private function get_user_info() {
2105
-		return apply_filters( 'give_payment_meta_user_info', $this->user_info, $this->ID, $this );
2104
+		return apply_filters('give_payment_meta_user_info', $this->user_info, $this->ID, $this);
2106 2105
 	}
2107 2106
 
2108 2107
 	/**
@@ -2114,7 +2113,7 @@  discard block
 block discarded – undo
2114 2113
 	 * @return array Payment billing address.
2115 2114
 	 */
2116 2115
 	private function get_address() {
2117
-		return apply_filters( 'give_payment_address', $this->address, $this->ID, $this );
2116
+		return apply_filters('give_payment_address', $this->address, $this->ID, $this);
2118 2117
 	}
2119 2118
 
2120 2119
 	/**
@@ -2126,7 +2125,7 @@  discard block
 block discarded – undo
2126 2125
 	 * @return string Payment key.
2127 2126
 	 */
2128 2127
 	private function get_key() {
2129
-		return apply_filters( 'give_payment_key', $this->key, $this->ID, $this );
2128
+		return apply_filters('give_payment_key', $this->key, $this->ID, $this);
2130 2129
 	}
2131 2130
 
2132 2131
 	/**
@@ -2138,7 +2137,7 @@  discard block
 block discarded – undo
2138 2137
 	 * @return string Payment form id
2139 2138
 	 */
2140 2139
 	private function get_form_id() {
2141
-		return apply_filters( 'give_payment_form_id', $this->form_id, $this->ID, $this );
2140
+		return apply_filters('give_payment_form_id', $this->form_id, $this->ID, $this);
2142 2141
 	}
2143 2142
 
2144 2143
 	/**
@@ -2150,6 +2149,6 @@  discard block
 block discarded – undo
2150 2149
 	 * @return int|string Payment number
2151 2150
 	 */
2152 2151
 	private function get_number() {
2153
-		return apply_filters( 'give_payment_number', $this->number, $this->ID, $this );
2152
+		return apply_filters('give_payment_number', $this->number, $this->ID, $this);
2154 2153
 	}
2155 2154
 }
Please login to merge, or discard this patch.