Completed
Pull Request — master (#1055)
by Rami
19:01
created
includes/payments/class-give-payment.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 	 *
294 294
 	 * @param int $payment_id A given payment
295 295
 	 *
296
-	 * @return mixed void|false
296
+	 * @return false|null void|false
297 297
 	 */
298 298
 	public function __construct( $payment_id = false ) {
299 299
 
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 	 *
362 362
 	 * @param  string $name The attribute to get
363 363
 	 *
364
-	 * @return boolean       If the item is set or not
364
+	 * @return boolean|null       If the item is set or not
365 365
 	 */
366 366
 	public function __isset( $name ) {
367 367
 		if ( property_exists( $this, $name ) ) {
@@ -1149,7 +1149,7 @@  discard block
 block discarded – undo
1149 1149
 	 *
1150 1150
 	 * @param string $note The note to add
1151 1151
 	 *
1152
-	 * @return void
1152
+	 * @return false|null
1153 1153
 	 */
1154 1154
 	public function add_note( $note = false ) {
1155 1155
 		// Bail if no note specified
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1050,7 +1050,7 @@  discard block
 block discarded – undo
1050 1050
 					//Find a match between price_id and level_id
1051 1051
 					//First verify array keys exists THEN make the match
1052 1052
 					if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) )
1053
-					     && $args['price_id'] == $price['_give_id']['level_id']
1053
+						 && $args['price_id'] == $price['_give_id']['level_id']
1054 1054
 					) {
1055 1055
 						$item_price = $price['_give_amount'];
1056 1056
 					}
@@ -1303,7 +1303,7 @@  discard block
 block discarded – undo
1303 1303
 	 * Add a note to a payment
1304 1304
 	 *
1305 1305
 	 * @since  1.5
1306
-     * @access public
1306
+	 * @access public
1307 1307
 	 *
1308 1308
 	 * @param  string $note The note to add
1309 1309
 	 *
@@ -1398,7 +1398,7 @@  discard block
 block discarded – undo
1398 1398
 	 * Set or update the total for a payment.
1399 1399
 	 *
1400 1400
 	 * @since  1.5
1401
-     * @access private
1401
+	 * @access private
1402 1402
 	 *
1403 1403
 	 * @return void
1404 1404
 	 */
@@ -1410,7 +1410,7 @@  discard block
 block discarded – undo
1410 1410
 	 * Set the payment status and run any status specific changes necessary.
1411 1411
 	 *
1412 1412
 	 * @since  1.5
1413
-     * @access public
1413
+	 * @access public
1414 1414
 	 *
1415 1415
 	 * @param  string $status The status to set the payment to.
1416 1416
 	 *
Please login to merge, or discard this patch.
Spacing   +324 added lines, -324 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
 
@@ -390,13 +390,13 @@  discard block
 block discarded – undo
390 390
 	 *
391 391
 	 * @return mixed void|false
392 392
 	 */
393
-	public function __construct( $payment_id = false ) {
393
+	public function __construct($payment_id = false) {
394 394
 
395
-		if ( empty( $payment_id ) ) {
395
+		if (empty($payment_id)) {
396 396
 			return false;
397 397
 		}
398 398
 
399
-		$this->setup_payment( $payment_id );
399
+		$this->setup_payment($payment_id);
400 400
 	}
401 401
 
402 402
 	/**
@@ -409,11 +409,11 @@  discard block
 block discarded – undo
409 409
 	 *
410 410
 	 * @return mixed        The value.
411 411
 	 */
412
-	public function __get( $key ) {
412
+	public function __get($key) {
413 413
 
414
-		if ( method_exists( $this, 'get_' . $key ) ) {
414
+		if (method_exists($this, 'get_'.$key)) {
415 415
 
416
-			$value = call_user_func( array( $this, 'get_' . $key ) );
416
+			$value = call_user_func(array($this, 'get_'.$key));
417 417
 
418 418
 		} else {
419 419
 
@@ -435,18 +435,18 @@  discard block
 block discarded – undo
435 435
 	 * @param  string $key The property name
436 436
 	 * @param  mixed  $value The value of the property
437 437
 	 */
438
-	public function __set( $key, $value ) {
439
-		$ignore = array( '_ID' );
438
+	public function __set($key, $value) {
439
+		$ignore = array('_ID');
440 440
 
441
-		if ( $key === 'status' ) {
441
+		if ($key === 'status') {
442 442
 			$this->old_status = $this->status;
443 443
 		}
444 444
 
445
-		if ( ! in_array( $key, $ignore ) ) {
446
-			$this->pending[ $key ] = $value;
445
+		if ( ! in_array($key, $ignore)) {
446
+			$this->pending[$key] = $value;
447 447
 		}
448 448
 
449
-		if ( '_ID' !== $key ) {
449
+		if ('_ID' !== $key) {
450 450
 			$this->$key = $value;
451 451
 		}
452 452
 	}
@@ -461,9 +461,9 @@  discard block
 block discarded – undo
461 461
 	 *
462 462
 	 * @return boolean       If the item is set or not
463 463
 	 */
464
-	public function __isset( $name ) {
465
-		if ( property_exists( $this, $name ) ) {
466
-			return false === empty( $this->$name );
464
+	public function __isset($name) {
465
+		if (property_exists($this, $name)) {
466
+			return false === empty($this->$name);
467 467
 		} else {
468 468
 			return null;
469 469
 		}
@@ -479,20 +479,20 @@  discard block
 block discarded – undo
479 479
 	 *
480 480
 	 * @return bool            If the setup was successful or not
481 481
 	 */
482
-	private function setup_payment( $payment_id ) {
482
+	private function setup_payment($payment_id) {
483 483
 		$this->pending = array();
484 484
 
485
-		if ( empty( $payment_id ) ) {
485
+		if (empty($payment_id)) {
486 486
 			return false;
487 487
 		}
488 488
 
489
-		$payment = get_post( $payment_id );
489
+		$payment = get_post($payment_id);
490 490
 
491
-		if ( ! $payment || is_wp_error( $payment ) ) {
491
+		if ( ! $payment || is_wp_error($payment)) {
492 492
 			return false;
493 493
 		}
494 494
 
495
-		if ( 'give_payment' !== $payment->post_type ) {
495
+		if ('give_payment' !== $payment->post_type) {
496 496
 			return false;
497 497
 		}
498 498
 
@@ -506,13 +506,13 @@  discard block
 block discarded – undo
506 506
 		 * @param Give_Payment $this       Payment object.
507 507
 		 * @param int          $payment_id The ID of the payment.
508 508
 		 */
509
-		do_action( 'give_pre_setup_payment', $this, $payment_id );
509
+		do_action('give_pre_setup_payment', $this, $payment_id);
510 510
 
511 511
 		// Primary Identifier
512
-		$this->ID = absint( $payment_id );
512
+		$this->ID = absint($payment_id);
513 513
 
514 514
 		// Protected ID that can never be changed
515
-		$this->_ID = absint( $payment_id );
515
+		$this->_ID = absint($payment_id);
516 516
 
517 517
 		// We have a payment, get the generic payment_meta item to reduce calls to it
518 518
 		$this->payment_meta = $this->get_meta();
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
 		$this->parent_payment = $payment->post_parent;
528 528
 
529 529
 		$all_payment_statuses  = give_get_payment_statuses();
530
-		$this->status_nicename = array_key_exists( $this->status, $all_payment_statuses ) ? $all_payment_statuses[ $this->status ] : ucfirst( $this->status );
530
+		$this->status_nicename = array_key_exists($this->status, $all_payment_statuses) ? $all_payment_statuses[$this->status] : ucfirst($this->status);
531 531
 
532 532
 		// Items
533 533
 		$this->fees = $this->setup_fees();
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
 		 * @param Give_Payment $this       Payment object.
570 570
 		 * @param int          $payment_id The ID of the payment.
571 571
 		 */
572
-		do_action( 'give_setup_payment', $this, $payment_id );
572
+		do_action('give_setup_payment', $this, $payment_id);
573 573
 
574 574
 		return true;
575 575
 	}
@@ -587,8 +587,8 @@  discard block
 block discarded – undo
587 587
 	 *
588 588
 	 * @return void
589 589
 	 */
590
-	public function update_payment_setup( $payment_id ) {
591
-		$this->setup_payment( $payment_id );
590
+	public function update_payment_setup($payment_id) {
591
+		$this->setup_payment($payment_id);
592 592
 	}
593 593
 
594 594
 	/**
@@ -603,24 +603,24 @@  discard block
 block discarded – undo
603 603
 
604 604
 		// Construct the payment title
605 605
 		$payment_title = '';
606
-		if ( ! empty( $this->first_name ) && ! empty( $this->last_name ) ) {
607
-			$payment_title = $this->first_name . ' ' . $this->last_name;
608
-		} else if ( ! empty( $this->first_name ) && empty( $this->last_name ) ) {
606
+		if ( ! empty($this->first_name) && ! empty($this->last_name)) {
607
+			$payment_title = $this->first_name.' '.$this->last_name;
608
+		} else if ( ! empty($this->first_name) && empty($this->last_name)) {
609 609
 			$payment_title = $this->first_name;
610
-		} else if ( ! empty( $this->email ) && is_email( $this->email ) ) {
610
+		} else if ( ! empty($this->email) && is_email($this->email)) {
611 611
 			$payment_title = $this->email;
612 612
 		}
613 613
 
614 614
 		//Set Key
615
-		if ( empty( $this->key ) ) {
615
+		if (empty($this->key)) {
616 616
 
617
-			$auth_key             = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
618
-			$this->key            = strtolower( md5( $this->email . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) );  // Unique key
617
+			$auth_key             = defined('AUTH_KEY') ? AUTH_KEY : '';
618
+			$this->key            = strtolower(md5($this->email.date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); // Unique key
619 619
 			$this->pending['key'] = $this->key;
620 620
 		}
621 621
 
622 622
 		//Set IP
623
-		if ( empty( $this->ip ) ) {
623
+		if (empty($this->ip)) {
624 624
 
625 625
 			$this->ip            = give_get_ip();
626 626
 			$this->pending['ip'] = $this->ip;
@@ -647,63 +647,63 @@  discard block
 block discarded – undo
647 647
 			'fees'         => $this->fees,
648 648
 		);
649 649
 
650
-		$args = apply_filters( 'give_insert_payment_args', array(
650
+		$args = apply_filters('give_insert_payment_args', array(
651 651
 			'post_title'    => $payment_title,
652 652
 			'post_status'   => $this->status,
653 653
 			'post_type'     => 'give_payment',
654
-			'post_date'     => ! empty( $this->date ) ? $this->date : null,
655
-			'post_date_gmt' => ! empty( $this->date ) ? get_gmt_from_date( $this->date ) : null,
654
+			'post_date'     => ! empty($this->date) ? $this->date : null,
655
+			'post_date_gmt' => ! empty($this->date) ? get_gmt_from_date($this->date) : null,
656 656
 			'post_parent'   => $this->parent_payment,
657
-		), $payment_data );
657
+		), $payment_data);
658 658
 
659 659
 		// Create a blank payment
660
-		$payment_id = wp_insert_post( $args );
660
+		$payment_id = wp_insert_post($args);
661 661
 
662
-		if ( ! empty( $payment_id ) ) {
662
+		if ( ! empty($payment_id)) {
663 663
 
664 664
 			$this->ID  = $payment_id;
665 665
 			$this->_ID = $payment_id;
666 666
 
667 667
 			$customer = new stdClass;
668 668
 
669
-			if ( did_action( 'give_pre_process_purchase' ) && is_user_logged_in() ) {
670
-				$customer = new Give_Customer( get_current_user_id(), true );
669
+			if (did_action('give_pre_process_purchase') && is_user_logged_in()) {
670
+				$customer = new Give_Customer(get_current_user_id(), true);
671 671
 
672 672
 				// Customer is logged in but used a different email to purchase with so assign to their customer record
673
-				if( ! empty( $customer->id ) && $this->email != $customer->email ) {
674
-					$customer->add_email( $this->email );
673
+				if ( ! empty($customer->id) && $this->email != $customer->email) {
674
+					$customer->add_email($this->email);
675 675
 				}
676 676
 			}
677 677
 
678
-			if ( empty( $customer->id ) ) {
679
-				$customer = new Give_Customer( $this->email );
678
+			if (empty($customer->id)) {
679
+				$customer = new Give_Customer($this->email);
680 680
 			}
681 681
 
682
-			if ( empty( $customer->id ) ) {
682
+			if (empty($customer->id)) {
683 683
 
684 684
 				$customer_data = array(
685
-					'name'    => ! is_email( $payment_title ) ? $this->first_name . ' ' . $this->last_name : '',
685
+					'name'    => ! is_email($payment_title) ? $this->first_name.' '.$this->last_name : '',
686 686
 					'email'   => $this->email,
687 687
 					'user_id' => $this->user_id,
688 688
 				);
689 689
 
690
-				$customer->create( $customer_data );
690
+				$customer->create($customer_data);
691 691
 
692 692
 			}
693 693
 
694 694
 			$this->customer_id            = $customer->id;
695 695
 			$this->pending['customer_id'] = $this->customer_id;
696
-			$customer->attach_payment( $this->ID, false );
696
+			$customer->attach_payment($this->ID, false);
697 697
 
698
-			$this->payment_meta = apply_filters( 'give_donation_meta', $this->payment_meta, $payment_data );
699
-			if ( ! empty( $this->payment_meta['fees'] ) ) {
700
-				$this->fees = array_merge( $this->fees, $this->payment_meta['fees'] );
701
-				foreach ( $this->fees as $fee ) {
702
-					$this->increase_fees( $fee['amount'] );
698
+			$this->payment_meta = apply_filters('give_donation_meta', $this->payment_meta, $payment_data);
699
+			if ( ! empty($this->payment_meta['fees'])) {
700
+				$this->fees = array_merge($this->fees, $this->payment_meta['fees']);
701
+				foreach ($this->fees as $fee) {
702
+					$this->increase_fees($fee['amount']);
703 703
 				}
704 704
 			}
705 705
 
706
-			$this->update_meta( '_give_payment_meta', $this->payment_meta );
706
+			$this->update_meta('_give_payment_meta', $this->payment_meta);
707 707
 			$this->new = true;
708 708
 		}
709 709
 
@@ -725,11 +725,11 @@  discard block
 block discarded – undo
725 725
 		$saved = false;
726 726
 
727 727
 		//Must have an ID 
728
-		if ( empty( $this->ID ) ) {
728
+		if (empty($this->ID)) {
729 729
 
730 730
 			$payment_id = $this->insert_payment();
731 731
 
732
-			if ( false === $payment_id ) {
732
+			if (false === $payment_id) {
733 733
 				$saved = false;
734 734
 			} else {
735 735
 				$this->ID = $payment_id;
@@ -738,48 +738,48 @@  discard block
 block discarded – undo
738 738
 		}
739 739
 
740 740
 		//Set ID if not matching
741
-		if ( $this->ID !== $this->_ID ) {
741
+		if ($this->ID !== $this->_ID) {
742 742
 			$this->ID = $this->_ID;
743 743
 		}
744 744
 
745 745
 		// If we have something pending, let's save it
746
-		if ( ! empty( $this->pending ) ) {
746
+		if ( ! empty($this->pending)) {
747 747
 
748 748
 			$total_increase = 0;
749 749
 			$total_decrease = 0;
750 750
 
751
-			foreach ( $this->pending as $key => $value ) {
751
+			foreach ($this->pending as $key => $value) {
752 752
 
753
-				switch ( $key ) {
753
+				switch ($key) {
754 754
 
755 755
 					case 'donations':
756 756
 						// Update totals for pending donations
757
-						foreach ( $this->pending[ $key ] as $item ) {
757
+						foreach ($this->pending[$key] as $item) {
758 758
 
759
-							$quantity = isset( $item['quantity'] ) ? $item['quantity'] : 1;
760
-							$price_id = isset( $item['price_id'] ) ? $item['price_id'] : 0;
759
+							$quantity = isset($item['quantity']) ? $item['quantity'] : 1;
760
+							$price_id = isset($item['price_id']) ? $item['price_id'] : 0;
761 761
 
762
-							switch ( $item['action'] ) {
762
+							switch ($item['action']) {
763 763
 
764 764
 								case 'add':
765 765
 
766 766
 									$price = $item['price'];
767 767
 
768
-									if ( 'publish' === $this->status || 'complete' === $this->status ) {
768
+									if ('publish' === $this->status || 'complete' === $this->status) {
769 769
 
770 770
 										// Add sales logs
771
-										$log_date = date_i18n( 'Y-m-d G:i:s', current_time( 'timestamp' ) );
771
+										$log_date = date_i18n('Y-m-d G:i:s', current_time('timestamp'));
772 772
 
773 773
 										$y = 0;
774
-										while ( $y < $quantity ) {
774
+										while ($y < $quantity) {
775 775
 
776
-											give_record_sale_in_log( $item['id'], $this->ID, $price_id, $log_date );
777
-											$y ++;
776
+											give_record_sale_in_log($item['id'], $this->ID, $price_id, $log_date);
777
+											$y++;
778 778
 										}
779 779
 
780
-										$form = new Give_Donate_Form( $item['id'] );
781
-										$form->increase_sales( $quantity );
782
-										$form->increase_earnings( $price );
780
+										$form = new Give_Donate_Form($item['id']);
781
+										$form->increase_sales($quantity);
782
+										$form->increase_earnings($price);
783 783
 
784 784
 										$total_increase += $price;
785 785
 									}
@@ -804,15 +804,15 @@  discard block
 block discarded – undo
804 804
 										)
805 805
 									);
806 806
 
807
-									$found_logs = get_posts( $log_args );
808
-									foreach ( $found_logs as $log ) {
809
-										wp_delete_post( $log->ID, true );
807
+									$found_logs = get_posts($log_args);
808
+									foreach ($found_logs as $log) {
809
+										wp_delete_post($log->ID, true);
810 810
 									}
811 811
 
812
-									if ( 'publish' === $this->status || 'complete' === $this->status ) {
813
-										$form = new Give_Donate_Form( $item['id'] );
814
-										$form->decrease_sales( $quantity );
815
-										$form->decrease_earnings( $item['amount'] );
812
+									if ('publish' === $this->status || 'complete' === $this->status) {
813
+										$form = new Give_Donate_Form($item['id']);
814
+										$form->decrease_sales($quantity);
815
+										$form->decrease_earnings($item['amount']);
816 816
 
817 817
 										$total_decrease += $item['amount'];
818 818
 									}
@@ -825,17 +825,17 @@  discard block
 block discarded – undo
825 825
 
826 826
 					case 'fees':
827 827
 
828
-						if ( 'publish' !== $this->status && 'complete' !== $this->status ) {
828
+						if ('publish' !== $this->status && 'complete' !== $this->status) {
829 829
 							break;
830 830
 						}
831 831
 
832
-						if ( empty( $this->pending[ $key ] ) ) {
832
+						if (empty($this->pending[$key])) {
833 833
 							break;
834 834
 						}
835 835
 
836
-						foreach ( $this->pending[ $key ] as $fee ) {
836
+						foreach ($this->pending[$key] as $fee) {
837 837
 
838
-							switch ( $fee['action'] ) {
838
+							switch ($fee['action']) {
839 839
 
840 840
 								case 'add':
841 841
 									$total_increase += $fee['amount'];
@@ -852,43 +852,43 @@  discard block
 block discarded – undo
852 852
 						break;
853 853
 
854 854
 					case 'status':
855
-						$this->update_status( $this->status );
855
+						$this->update_status($this->status);
856 856
 						break;
857 857
 
858 858
 					case 'gateway':
859
-						$this->update_meta( '_give_payment_gateway', $this->gateway );
859
+						$this->update_meta('_give_payment_gateway', $this->gateway);
860 860
 						break;
861 861
 
862 862
 					case 'mode':
863
-						$this->update_meta( '_give_payment_mode', $this->mode );
863
+						$this->update_meta('_give_payment_mode', $this->mode);
864 864
 						break;
865 865
 
866 866
 					case 'transaction_id':
867
-						$this->update_meta( '_give_payment_transaction_id', $this->transaction_id );
867
+						$this->update_meta('_give_payment_transaction_id', $this->transaction_id);
868 868
 						break;
869 869
 
870 870
 					case 'ip':
871
-						$this->update_meta( '_give_payment_user_ip', $this->ip );
871
+						$this->update_meta('_give_payment_user_ip', $this->ip);
872 872
 						break;
873 873
 
874 874
 					case 'customer_id':
875
-						$this->update_meta( '_give_payment_customer_id', $this->customer_id );
875
+						$this->update_meta('_give_payment_customer_id', $this->customer_id);
876 876
 						break;
877 877
 
878 878
 					case 'user_id':
879
-						$this->update_meta( '_give_payment_user_id', $this->user_id );
879
+						$this->update_meta('_give_payment_user_id', $this->user_id);
880 880
 						break;
881 881
 
882 882
 					case 'form_title':
883
-						$this->update_meta( '_give_payment_form_title', $this->form_title );
883
+						$this->update_meta('_give_payment_form_title', $this->form_title);
884 884
 						break;
885 885
 
886 886
 					case 'form_id':
887
-						$this->update_meta( '_give_payment_form_id', $this->form_id );
887
+						$this->update_meta('_give_payment_form_id', $this->form_id);
888 888
 						break;
889 889
 
890 890
 					case 'price_id':
891
-						$this->update_meta( '_give_payment_price_id', $this->price_id );
891
+						$this->update_meta('_give_payment_price_id', $this->price_id);
892 892
 						break;
893 893
 
894 894
 					case 'first_name':
@@ -904,15 +904,15 @@  discard block
 block discarded – undo
904 904
 						break;
905 905
 
906 906
 					case 'email':
907
-						$this->update_meta( '_give_payment_user_email', $this->email );
907
+						$this->update_meta('_give_payment_user_email', $this->email);
908 908
 						break;
909 909
 
910 910
 					case 'key':
911
-						$this->update_meta( '_give_payment_purchase_key', $this->key );
911
+						$this->update_meta('_give_payment_purchase_key', $this->key);
912 912
 						break;
913 913
 
914 914
 					case 'number':
915
-						$this->update_meta( '_give_payment_number', $this->number );
915
+						$this->update_meta('_give_payment_number', $this->number);
916 916
 						break;
917 917
 
918 918
 					case 'date':
@@ -922,11 +922,11 @@  discard block
 block discarded – undo
922 922
 							'edit_date' => true,
923 923
 						);
924 924
 
925
-						wp_update_post( $args );
925
+						wp_update_post($args);
926 926
 						break;
927 927
 
928 928
 					case 'completed_date':
929
-						$this->update_meta( '_give_completed_date', $this->completed_date );
929
+						$this->update_meta('_give_completed_date', $this->completed_date);
930 930
 						break;
931 931
 
932 932
 					case 'parent_payment':
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
 							'post_parent' => $this->parent_payment,
936 936
 						);
937 937
 
938
-						wp_update_post( $args );
938
+						wp_update_post($args);
939 939
 						break;
940 940
 
941 941
 					default:
@@ -946,34 +946,34 @@  discard block
 block discarded – undo
946 946
 						 *
947 947
 						 * @param Give_Payment $this Payment object.
948 948
 						 */
949
-						do_action( 'give_donation_save', $this, $key );
949
+						do_action('give_donation_save', $this, $key);
950 950
 						break;
951 951
 				}
952 952
 			}
953 953
 
954
-			if ( 'pending' !== $this->status ) {
954
+			if ('pending' !== $this->status) {
955 955
 
956
-				$customer = new Give_Customer( $this->customer_id );
956
+				$customer = new Give_Customer($this->customer_id);
957 957
 
958 958
 				$total_change = $total_increase - $total_decrease;
959
-				if ( $total_change < 0 ) {
959
+				if ($total_change < 0) {
960 960
 
961
-					$total_change = - ( $total_change );
961
+					$total_change = - ($total_change);
962 962
 					// Decrease the customer's donation stats
963
-					$customer->decrease_value( $total_change );
964
-					give_decrease_total_earnings( $total_change );
963
+					$customer->decrease_value($total_change);
964
+					give_decrease_total_earnings($total_change);
965 965
 
966
-				} else if ( $total_change > 0 ) {
966
+				} else if ($total_change > 0) {
967 967
 
968 968
 					// Increase the customer's donation stats
969
-					$customer->increase_value( $total_change );
970
-					give_increase_total_earnings( $total_change );
969
+					$customer->increase_value($total_change);
970
+					give_increase_total_earnings($total_change);
971 971
 
972 972
 				}
973 973
 
974 974
 			}
975 975
 
976
-			$this->update_meta( '_give_payment_total', $this->total );
976
+			$this->update_meta('_give_payment_total', $this->total);
977 977
 
978 978
 			$new_meta = array(
979 979
 				'form_title' => $this->form_title,
@@ -985,12 +985,12 @@  discard block
 block discarded – undo
985 985
 			);
986 986
 
987 987
 			$meta        = $this->get_meta();
988
-			$merged_meta = array_merge( $meta, $new_meta );
988
+			$merged_meta = array_merge($meta, $new_meta);
989 989
 
990 990
 			// Only save the payment meta if it's changed
991
-			if ( md5( serialize( $meta ) ) !== md5( serialize( $merged_meta ) ) ) {
992
-				$updated = $this->update_meta( '_give_payment_meta', $merged_meta );
993
-				if ( false !== $updated ) {
991
+			if (md5(serialize($meta)) !== md5(serialize($merged_meta))) {
992
+				$updated = $this->update_meta('_give_payment_meta', $merged_meta);
993
+				if (false !== $updated) {
994 994
 					$saved = true;
995 995
 				}
996 996
 			}
@@ -999,8 +999,8 @@  discard block
 block discarded – undo
999 999
 			$saved         = true;
1000 1000
 		}
1001 1001
 
1002
-		if ( true === $saved ) {
1003
-			$this->setup_payment( $this->ID );
1002
+		if (true === $saved) {
1003
+			$this->setup_payment($this->ID);
1004 1004
 		}
1005 1005
 
1006 1006
 		return $saved;
@@ -1018,12 +1018,12 @@  discard block
 block discarded – undo
1018 1018
 	 *
1019 1019
 	 * @return bool           True when successful, false otherwise
1020 1020
 	 */
1021
-	public function add_donation( $form_id = 0, $args = array(), $options = array() ) {
1021
+	public function add_donation($form_id = 0, $args = array(), $options = array()) {
1022 1022
 
1023
-		$donation = new Give_Donate_Form( $form_id );
1023
+		$donation = new Give_Donate_Form($form_id);
1024 1024
 
1025 1025
 		// Bail if this post isn't a give donation form
1026
-		if ( ! $donation || $donation->post_type !== 'give_forms' ) {
1026
+		if ( ! $donation || $donation->post_type !== 'give_forms') {
1027 1027
 			return false;
1028 1028
 		}
1029 1029
 
@@ -1034,60 +1034,60 @@  discard block
 block discarded – undo
1034 1034
 			'fees'     => array(),
1035 1035
 		);
1036 1036
 
1037
-		$args = wp_parse_args( apply_filters( 'give_donation_add_donation_args', $args, $donation->ID ), $defaults );
1037
+		$args = wp_parse_args(apply_filters('give_donation_add_donation_args', $args, $donation->ID), $defaults);
1038 1038
 
1039 1039
 		// Allow overriding the price
1040
-		if ( false !== $args['price'] ) {
1040
+		if (false !== $args['price']) {
1041 1041
 			$item_price = $args['price'];
1042 1042
 		} else {
1043 1043
 
1044 1044
 			// Deal with variable pricing
1045
-			if ( give_has_variable_prices( $donation->ID ) ) {
1046
-				$prices     = maybe_unserialize( get_post_meta( $form_id, '_give_donation_levels', true ) );
1045
+			if (give_has_variable_prices($donation->ID)) {
1046
+				$prices     = maybe_unserialize(get_post_meta($form_id, '_give_donation_levels', true));
1047 1047
 				$item_price = '';
1048 1048
 				//Loop through prices
1049
-				foreach ( $prices as $price ) {
1049
+				foreach ($prices as $price) {
1050 1050
 					//Find a match between price_id and level_id
1051 1051
 					//First verify array keys exists THEN make the match
1052
-					if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) )
1052
+					if ((isset($args['price_id']) && isset($price['_give_id']['level_id']))
1053 1053
 					     && $args['price_id'] == $price['_give_id']['level_id']
1054 1054
 					) {
1055 1055
 						$item_price = $price['_give_amount'];
1056 1056
 					}
1057 1057
 				}
1058 1058
 				//Fallback to the lowest price point
1059
-				if ( $item_price == '' ) {
1060
-					$item_price       = give_get_lowest_price_option( $donation->ID );
1061
-					$args['price_id'] = give_get_lowest_price_id( $donation->ID );
1059
+				if ($item_price == '') {
1060
+					$item_price       = give_get_lowest_price_option($donation->ID);
1061
+					$args['price_id'] = give_get_lowest_price_id($donation->ID);
1062 1062
 				}
1063 1063
 			} else {
1064 1064
 				//Simple form price
1065
-				$item_price = give_get_form_price( $donation->ID );
1065
+				$item_price = give_get_form_price($donation->ID);
1066 1066
 			}
1067 1067
 
1068 1068
 		}
1069 1069
 
1070 1070
 		// Sanitizing the price here so we don't have a dozen calls later
1071
-		$item_price = give_sanitize_amount( $item_price );
1072
-		$total      = round( $item_price, give_currency_decimal_filter() );
1071
+		$item_price = give_sanitize_amount($item_price);
1072
+		$total      = round($item_price, give_currency_decimal_filter());
1073 1073
 
1074 1074
 		//Add Options
1075 1075
 		$default_options = array();
1076
-		if ( false !== $args['price_id'] ) {
1076
+		if (false !== $args['price_id']) {
1077 1077
 			$default_options['price_id'] = (int) $args['price_id'];
1078 1078
 		}
1079
-		$options = wp_parse_args( $options, $default_options );
1079
+		$options = wp_parse_args($options, $default_options);
1080 1080
 
1081 1081
 		// Do not allow totals to go negative
1082
-		if ( $total < 0 ) {
1082
+		if ($total < 0) {
1083 1083
 			$total = 0;
1084 1084
 		}
1085 1085
 
1086 1086
 		$donation = array(
1087 1087
 			'name'     => $donation->post_title,
1088 1088
 			'id'       => $donation->ID,
1089
-			'price'    => round( $total, give_currency_decimal_filter() ),
1090
-			'subtotal' => round( $total, give_currency_decimal_filter() ),
1089
+			'price'    => round($total, give_currency_decimal_filter()),
1090
+			'subtotal' => round($total, give_currency_decimal_filter()),
1091 1091
 			'fees'     => $args['fees'],
1092 1092
 			'price_id' => $args['price_id'],
1093 1093
 			'action'   => 'add',
@@ -1096,7 +1096,7 @@  discard block
 block discarded – undo
1096 1096
 
1097 1097
 		$this->pending['donations'][] = $donation;
1098 1098
 
1099
-		$this->increase_subtotal( $total );
1099
+		$this->increase_subtotal($total);
1100 1100
 
1101 1101
 		return true;
1102 1102
 
@@ -1113,7 +1113,7 @@  discard block
 block discarded – undo
1113 1113
 	 *
1114 1114
 	 * @return bool           If the item was removed or not
1115 1115
 	 */
1116
-	public function remove_donation( $form_id, $args = array() ) {
1116
+	public function remove_donation($form_id, $args = array()) {
1117 1117
 
1118 1118
 		// Set some defaults
1119 1119
 		$defaults = array(
@@ -1121,12 +1121,12 @@  discard block
 block discarded – undo
1121 1121
 			'price'    => false,
1122 1122
 			'price_id' => false,
1123 1123
 		);
1124
-		$args     = wp_parse_args( $args, $defaults );
1124
+		$args = wp_parse_args($args, $defaults);
1125 1125
 
1126
-		$form = new Give_Donate_Form( $form_id );
1126
+		$form = new Give_Donate_Form($form_id);
1127 1127
 
1128 1128
 		// Bail if this post isn't a valid give donation form
1129
-		if ( ! $form || $form->post_type !== 'give_forms' ) {
1129
+		if ( ! $form || $form->post_type !== 'give_forms') {
1130 1130
 			return false;
1131 1131
 		}
1132 1132
 
@@ -1139,7 +1139,7 @@  discard block
 block discarded – undo
1139 1139
 
1140 1140
 		$this->pending['donations'][] = $pending_args;
1141 1141
 
1142
-		$this->decrease_subtotal( $this->total );
1142
+		$this->decrease_subtotal($this->total);
1143 1143
 
1144 1144
 		return true;
1145 1145
 	}
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
 	 *
1156 1156
 	 * @return bool          If the fee was added
1157 1157
 	 */
1158
-	public function add_fee( $args, $global = true ) {
1158
+	public function add_fee($args, $global = true) {
1159 1159
 
1160 1160
 		$default_args = array(
1161 1161
 			'label'    => '',
@@ -1165,16 +1165,16 @@  discard block
 block discarded – undo
1165 1165
 			'price_id' => 0,
1166 1166
 		);
1167 1167
 
1168
-		$fee          = wp_parse_args( $args, $default_args );
1168
+		$fee          = wp_parse_args($args, $default_args);
1169 1169
 		$this->fees[] = $fee;
1170 1170
 
1171 1171
 
1172 1172
 		$added_fee               = $fee;
1173 1173
 		$added_fee['action']     = 'add';
1174 1174
 		$this->pending['fees'][] = $added_fee;
1175
-		reset( $this->fees );
1175
+		reset($this->fees);
1176 1176
 
1177
-		$this->increase_fees( $fee['amount'] );
1177
+		$this->increase_fees($fee['amount']);
1178 1178
 
1179 1179
 		return true;
1180 1180
 	}
@@ -1189,11 +1189,11 @@  discard block
 block discarded – undo
1189 1189
 	 *
1190 1190
 	 * @return bool     If the fee was removed successfully
1191 1191
 	 */
1192
-	public function remove_fee( $key ) {
1192
+	public function remove_fee($key) {
1193 1193
 		$removed = false;
1194 1194
 
1195
-		if ( is_numeric( $key ) ) {
1196
-			$removed = $this->remove_fee_by( 'index', $key );
1195
+		if (is_numeric($key)) {
1196
+			$removed = $this->remove_fee_by('index', $key);
1197 1197
 		}
1198 1198
 
1199 1199
 		return $removed;
@@ -1212,47 +1212,47 @@  discard block
 block discarded – undo
1212 1212
 	 *
1213 1213
 	 * @return boolean            If the item is removed
1214 1214
 	 */
1215
-	public function remove_fee_by( $key, $value, $global = false ) {
1215
+	public function remove_fee_by($key, $value, $global = false) {
1216 1216
 
1217
-		$allowed_fee_keys = apply_filters( 'give_donation_fee_keys', array(
1217
+		$allowed_fee_keys = apply_filters('give_donation_fee_keys', array(
1218 1218
 			'index',
1219 1219
 			'label',
1220 1220
 			'amount',
1221 1221
 			'type',
1222
-		) );
1222
+		));
1223 1223
 
1224
-		if ( ! in_array( $key, $allowed_fee_keys ) ) {
1224
+		if ( ! in_array($key, $allowed_fee_keys)) {
1225 1225
 			return false;
1226 1226
 		}
1227 1227
 
1228 1228
 		$removed = false;
1229
-		if ( 'index' === $key && array_key_exists( $value, $this->fees ) ) {
1229
+		if ('index' === $key && array_key_exists($value, $this->fees)) {
1230 1230
 
1231
-			$removed_fee             = $this->fees[ $value ];
1231
+			$removed_fee             = $this->fees[$value];
1232 1232
 			$removed_fee['action']   = 'remove';
1233 1233
 			$this->pending['fees'][] = $removed_fee;
1234 1234
 
1235
-			$this->decrease_fees( $removed_fee['amount'] );
1235
+			$this->decrease_fees($removed_fee['amount']);
1236 1236
 
1237
-			unset( $this->fees[ $value ] );
1237
+			unset($this->fees[$value]);
1238 1238
 			$removed = true;
1239 1239
 
1240
-		} else if ( 'index' !== $key ) {
1240
+		} else if ('index' !== $key) {
1241 1241
 
1242
-			foreach ( $this->fees as $index => $fee ) {
1242
+			foreach ($this->fees as $index => $fee) {
1243 1243
 
1244
-				if ( isset( $fee[ $key ] ) && $fee[ $key ] == $value ) {
1244
+				if (isset($fee[$key]) && $fee[$key] == $value) {
1245 1245
 
1246 1246
 					$removed_fee             = $fee;
1247 1247
 					$removed_fee['action']   = 'remove';
1248 1248
 					$this->pending['fees'][] = $removed_fee;
1249 1249
 
1250
-					$this->decrease_fees( $removed_fee['amount'] );
1250
+					$this->decrease_fees($removed_fee['amount']);
1251 1251
 
1252
-					unset( $this->fees[ $index ] );
1252
+					unset($this->fees[$index]);
1253 1253
 					$removed = true;
1254 1254
 
1255
-					if ( false === $global ) {
1255
+					if (false === $global) {
1256 1256
 						break;
1257 1257
 					}
1258 1258
 
@@ -1262,8 +1262,8 @@  discard block
 block discarded – undo
1262 1262
 
1263 1263
 		}
1264 1264
 
1265
-		if ( true === $removed ) {
1266
-			$this->fees = array_values( $this->fees );
1265
+		if (true === $removed) {
1266
+			$this->fees = array_values($this->fees);
1267 1267
 		}
1268 1268
 
1269 1269
 		return $removed;
@@ -1279,14 +1279,14 @@  discard block
 block discarded – undo
1279 1279
 	 *
1280 1280
 	 * @return array        The Fees for the type specified
1281 1281
 	 */
1282
-	public function get_fees( $type = 'all' ) {
1282
+	public function get_fees($type = 'all') {
1283 1283
 		$fees = array();
1284 1284
 
1285
-		if ( ! empty( $this->fees ) && is_array( $this->fees ) ) {
1285
+		if ( ! empty($this->fees) && is_array($this->fees)) {
1286 1286
 
1287
-			foreach ( $this->fees as $fee_id => $fee ) {
1287
+			foreach ($this->fees as $fee_id => $fee) {
1288 1288
 
1289
-				if ( 'all' != $type && ! empty( $fee['type'] ) && $type != $fee['type'] ) {
1289
+				if ('all' != $type && ! empty($fee['type']) && $type != $fee['type']) {
1290 1290
 					continue;
1291 1291
 				}
1292 1292
 
@@ -1296,7 +1296,7 @@  discard block
 block discarded – undo
1296 1296
 			}
1297 1297
 		}
1298 1298
 
1299
-		return apply_filters( 'give_get_payment_fees', $fees, $this->ID, $this );
1299
+		return apply_filters('give_get_payment_fees', $fees, $this->ID, $this);
1300 1300
 	}
1301 1301
 
1302 1302
 	/**
@@ -1309,13 +1309,13 @@  discard block
 block discarded – undo
1309 1309
 	 *
1310 1310
 	 * @return void
1311 1311
 	 */
1312
-	public function add_note( $note = false ) {
1312
+	public function add_note($note = false) {
1313 1313
 		// Bail if no note specified
1314
-		if ( ! $note ) {
1314
+		if ( ! $note) {
1315 1315
 			return false;
1316 1316
 		}
1317 1317
 
1318
-		give_insert_payment_note( $this->ID, $note );
1318
+		give_insert_payment_note($this->ID, $note);
1319 1319
 	}
1320 1320
 
1321 1321
 	/**
@@ -1328,7 +1328,7 @@  discard block
 block discarded – undo
1328 1328
 	 *
1329 1329
 	 * @return void
1330 1330
 	 */
1331
-	private function increase_subtotal( $amount = 0.00 ) {
1331
+	private function increase_subtotal($amount = 0.00) {
1332 1332
 		$amount = (float) $amount;
1333 1333
 		$this->subtotal += $amount;
1334 1334
 
@@ -1345,11 +1345,11 @@  discard block
 block discarded – undo
1345 1345
 	 *
1346 1346
 	 * @return void
1347 1347
 	 */
1348
-	private function decrease_subtotal( $amount = 0.00 ) {
1348
+	private function decrease_subtotal($amount = 0.00) {
1349 1349
 		$amount = (float) $amount;
1350 1350
 		$this->subtotal -= $amount;
1351 1351
 
1352
-		if ( $this->subtotal < 0 ) {
1352
+		if ($this->subtotal < 0) {
1353 1353
 			$this->subtotal = 0;
1354 1354
 		}
1355 1355
 
@@ -1366,7 +1366,7 @@  discard block
 block discarded – undo
1366 1366
 	 *
1367 1367
 	 * @return void
1368 1368
 	 */
1369
-	private function increase_fees( $amount = 0.00 ) {
1369
+	private function increase_fees($amount = 0.00) {
1370 1370
 		$amount = (float) $amount;
1371 1371
 		$this->fees_total += $amount;
1372 1372
 
@@ -1383,11 +1383,11 @@  discard block
 block discarded – undo
1383 1383
 	 *
1384 1384
 	 * @return void
1385 1385
 	 */
1386
-	private function decrease_fees( $amount = 0.00 ) {
1386
+	private function decrease_fees($amount = 0.00) {
1387 1387
 		$amount = (float) $amount;
1388 1388
 		$this->fees_total -= $amount;
1389 1389
 
1390
-		if ( $this->fees_total < 0 ) {
1390
+		if ($this->fees_total < 0) {
1391 1391
 			$this->fees_total = 0;
1392 1392
 		}
1393 1393
 
@@ -1416,25 +1416,25 @@  discard block
 block discarded – undo
1416 1416
 	 *
1417 1417
 	 * @return bool   $updated Returns if the status was successfully updated.
1418 1418
 	 */
1419
-	public function update_status( $status = false ) {
1419
+	public function update_status($status = false) {
1420 1420
 
1421 1421
 		//standardize the 'complete(d)' status
1422
-		if ( $status == 'completed' || $status == 'complete' ) {
1422
+		if ($status == 'completed' || $status == 'complete') {
1423 1423
 			$status = 'publish';
1424 1424
 		}
1425 1425
 
1426
-		$old_status = ! empty( $this->old_status ) ? $this->old_status : false;
1426
+		$old_status = ! empty($this->old_status) ? $this->old_status : false;
1427 1427
 
1428
-		if ( $old_status === $status ) {
1428
+		if ($old_status === $status) {
1429 1429
 			return false; // Don't permit status changes that aren't changes
1430 1430
 		}
1431 1431
 
1432
-		$do_change = apply_filters( 'give_should_update_payment_status', true, $this->ID, $status, $old_status );
1432
+		$do_change = apply_filters('give_should_update_payment_status', true, $this->ID, $status, $old_status);
1433 1433
 
1434 1434
 		$updated = false;
1435 1435
 
1436 1436
 
1437
-		if ( $do_change ) {
1437
+		if ($do_change) {
1438 1438
 
1439 1439
 			/**
1440 1440
 			 * Fires before changing payment status.
@@ -1445,21 +1445,21 @@  discard block
 block discarded – undo
1445 1445
 			 * @param string $status     The new status.
1446 1446
 			 * @param string $old_status The old status.
1447 1447
 			 */
1448
-			do_action( 'give_before_payment_status_change', $this->ID, $status, $old_status );
1448
+			do_action('give_before_payment_status_change', $this->ID, $status, $old_status);
1449 1449
 
1450 1450
 			$update_fields = array(
1451 1451
 				'ID'          => $this->ID,
1452 1452
 				'post_status' => $status,
1453
-				'edit_date'   => current_time( 'mysql' )
1453
+				'edit_date'   => current_time('mysql')
1454 1454
 			);
1455 1455
 
1456
-			$updated = wp_update_post( apply_filters( 'give_update_payment_status_fields', $update_fields ) );
1456
+			$updated = wp_update_post(apply_filters('give_update_payment_status_fields', $update_fields));
1457 1457
 
1458 1458
 			$all_payment_statuses  = give_get_payment_statuses();
1459
-			$this->status_nicename = array_key_exists( $status, $all_payment_statuses ) ? $all_payment_statuses[ $status ] : ucfirst( $status );
1459
+			$this->status_nicename = array_key_exists($status, $all_payment_statuses) ? $all_payment_statuses[$status] : ucfirst($status);
1460 1460
 
1461 1461
 			// Process any specific status functions
1462
-			switch ( $status ) {
1462
+			switch ($status) {
1463 1463
 				case 'refunded':
1464 1464
 					$this->process_refund();
1465 1465
 					break;
@@ -1486,7 +1486,7 @@  discard block
 block discarded – undo
1486 1486
 			 * @param string $status     The new status.
1487 1487
 			 * @param string $old_status The old status.
1488 1488
 			 */
1489
-			do_action( 'give_update_payment_status', $this->ID, $status, $old_status );
1489
+			do_action('give_update_payment_status', $this->ID, $status, $old_status);
1490 1490
 
1491 1491
 		}
1492 1492
 
@@ -1521,32 +1521,32 @@  discard block
 block discarded – undo
1521 1521
 	 *
1522 1522
 	 * @return mixed             The value from the post meta
1523 1523
 	 */
1524
-	public function get_meta( $meta_key = '_give_payment_meta', $single = true ) {
1524
+	public function get_meta($meta_key = '_give_payment_meta', $single = true) {
1525 1525
 
1526
-		$meta = get_post_meta( $this->ID, $meta_key, $single );
1526
+		$meta = get_post_meta($this->ID, $meta_key, $single);
1527 1527
 
1528
-		if ( $meta_key === '_give_payment_meta' ) {
1528
+		if ($meta_key === '_give_payment_meta') {
1529 1529
 
1530
-			if ( empty( $meta['key'] ) ) {
1530
+			if (empty($meta['key'])) {
1531 1531
 				$meta['key'] = $this->setup_payment_key();
1532 1532
 			}
1533 1533
 
1534
-			if ( empty( $meta['form_title'] ) ) {
1534
+			if (empty($meta['form_title'])) {
1535 1535
 				$meta['form_title'] = $this->setup_form_title();
1536 1536
 			}
1537 1537
 
1538
-			if ( empty( $meta['email'] ) ) {
1538
+			if (empty($meta['email'])) {
1539 1539
 				$meta['email'] = $this->setup_email();
1540 1540
 			}
1541 1541
 
1542
-			if ( empty( $meta['date'] ) ) {
1543
-				$meta['date'] = get_post_field( 'post_date', $this->ID );
1542
+			if (empty($meta['date'])) {
1543
+				$meta['date'] = get_post_field('post_date', $this->ID);
1544 1544
 			}
1545 1545
 		}
1546 1546
 
1547
-		$meta = apply_filters( "give_get_payment_meta_{$meta_key}", $meta, $this->ID );
1547
+		$meta = apply_filters("give_get_payment_meta_{$meta_key}", $meta, $this->ID);
1548 1548
 
1549
-		return apply_filters( 'give_get_payment_meta', $meta, $this->ID, $meta_key );
1549
+		return apply_filters('give_get_payment_meta', $meta, $this->ID, $meta_key);
1550 1550
 	}
1551 1551
 
1552 1552
 	/**
@@ -1561,23 +1561,23 @@  discard block
 block discarded – undo
1561 1561
 	 *
1562 1562
 	 * @return int|bool           Meta ID if the key didn't exist, true on successful update, false on failure
1563 1563
 	 */
1564
-	public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) {
1565
-		if ( empty( $meta_key ) ) {
1564
+	public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') {
1565
+		if (empty($meta_key)) {
1566 1566
 			return false;
1567 1567
 		}
1568 1568
 
1569
-		if ( $meta_key == 'key' || $meta_key == 'date' ) {
1569
+		if ($meta_key == 'key' || $meta_key == 'date') {
1570 1570
 
1571 1571
 			$current_meta              = $this->get_meta();
1572
-			$current_meta[ $meta_key ] = $meta_value;
1572
+			$current_meta[$meta_key] = $meta_value;
1573 1573
 
1574 1574
 			$meta_key   = '_give_payment_meta';
1575 1575
 			$meta_value = $current_meta;
1576 1576
 
1577
-		} else if ( $meta_key == 'email' || $meta_key == '_give_payment_user_email' ) {
1577
+		} else if ($meta_key == 'email' || $meta_key == '_give_payment_user_email') {
1578 1578
 
1579
-			$meta_value = apply_filters( "give_give_update_payment_meta_{$meta_key}", $meta_value, $this->ID );
1580
-			update_post_meta( $this->ID, '_give_payment_user_email', $meta_value );
1579
+			$meta_value = apply_filters("give_give_update_payment_meta_{$meta_key}", $meta_value, $this->ID);
1580
+			update_post_meta($this->ID, '_give_payment_user_email', $meta_value);
1581 1581
 
1582 1582
 			$current_meta                       = $this->get_meta();
1583 1583
 			$current_meta['user_info']['email'] = $meta_value;
@@ -1587,9 +1587,9 @@  discard block
 block discarded – undo
1587 1587
 
1588 1588
 		}
1589 1589
 
1590
-		$meta_value = apply_filters( "give_update_payment_meta_{$meta_key}", $meta_value, $this->ID );
1590
+		$meta_value = apply_filters("give_update_payment_meta_{$meta_key}", $meta_value, $this->ID);
1591 1591
 
1592
-		return update_post_meta( $this->ID, $meta_key, $meta_value, $prev_value );
1592
+		return update_post_meta($this->ID, $meta_key, $meta_value, $prev_value);
1593 1593
 	}
1594 1594
 
1595 1595
 	/**
@@ -1604,14 +1604,14 @@  discard block
 block discarded – undo
1604 1604
 		$process_refund = true;
1605 1605
 
1606 1606
 		// If the payment was not in publish or revoked status, don't decrement stats as they were never incremented
1607
-		if ( 'publish' != $this->old_status || 'refunded' != $this->status ) {
1607
+		if ('publish' != $this->old_status || 'refunded' != $this->status) {
1608 1608
 			$process_refund = false;
1609 1609
 		}
1610 1610
 
1611 1611
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments
1612
-		$process_refund = apply_filters( 'give_should_process_refund', $process_refund, $this );
1612
+		$process_refund = apply_filters('give_should_process_refund', $process_refund, $this);
1613 1613
 
1614
-		if ( false === $process_refund ) {
1614
+		if (false === $process_refund) {
1615 1615
 			return;
1616 1616
 		}
1617 1617
 
@@ -1622,17 +1622,17 @@  discard block
 block discarded – undo
1622 1622
 		 *
1623 1623
 		 * @param Give_Payment $this Payment object.
1624 1624
 		 */
1625
-		do_action( 'give_pre_refund_payment', $this );
1625
+		do_action('give_pre_refund_payment', $this);
1626 1626
 
1627
-		$decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_refund', true, $this );
1628
-		$decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_refund', true, $this );
1629
-		$decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_refund', true, $this );
1627
+		$decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_refund', true, $this);
1628
+		$decrease_customer_value = apply_filters('give_decrease_customer_value_on_refund', true, $this);
1629
+		$decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_refund', true, $this);
1630 1630
 
1631
-		$this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count );
1631
+		$this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count);
1632 1632
 		$this->delete_sales_logs();
1633 1633
 
1634 1634
 		// Clear the This Month earnings (this_monththis_month is NOT a typo)
1635
-		delete_transient( md5( 'give_earnings_this_monththis_month' ) );
1635
+		delete_transient(md5('give_earnings_this_monththis_month'));
1636 1636
 
1637 1637
 		/**
1638 1638
 		 * Fires after refunding payment.
@@ -1641,7 +1641,7 @@  discard block
 block discarded – undo
1641 1641
 		 *
1642 1642
 		 * @param Give_Payment $this Payment object.
1643 1643
 		 */
1644
-		do_action( 'give_post_refund_payment', $this );
1644
+		do_action('give_post_refund_payment', $this);
1645 1645
 	}
1646 1646
 
1647 1647
 	/**
@@ -1668,29 +1668,29 @@  discard block
 block discarded – undo
1668 1668
 		$process_pending = true;
1669 1669
 
1670 1670
 		// If the payment was not in publish or revoked status, don't decrement stats as they were never incremented
1671
-		if ( 'publish' != $this->old_status || 'pending' != $this->status ) {
1671
+		if ('publish' != $this->old_status || 'pending' != $this->status) {
1672 1672
 			$process_pending = false;
1673 1673
 		}
1674 1674
 
1675 1675
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments
1676
-		$process_pending = apply_filters( 'give_should_process_pending', $process_pending, $this );
1676
+		$process_pending = apply_filters('give_should_process_pending', $process_pending, $this);
1677 1677
 
1678
-		if ( false === $process_pending ) {
1678
+		if (false === $process_pending) {
1679 1679
 			return;
1680 1680
 		}
1681 1681
 
1682
-		$decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_pending', true, $this );
1683
-		$decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_pending', true, $this );
1684
-		$decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_pending', true, $this );
1682
+		$decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_pending', true, $this);
1683
+		$decrease_customer_value = apply_filters('give_decrease_customer_value_on_pending', true, $this);
1684
+		$decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_pending', true, $this);
1685 1685
 
1686
-		$this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count );
1686
+		$this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count);
1687 1687
 		$this->delete_sales_logs();
1688 1688
 
1689 1689
 		$this->completed_date = false;
1690
-		$this->update_meta( '_give_completed_date', '' );
1690
+		$this->update_meta('_give_completed_date', '');
1691 1691
 
1692 1692
 		// Clear the This Month earnings (this_monththis_month is NOT a typo)
1693
-		delete_transient( md5( 'give_earnings_this_monththis_month' ) );
1693
+		delete_transient(md5('give_earnings_this_monththis_month'));
1694 1694
 	}
1695 1695
 
1696 1696
 	/**
@@ -1705,29 +1705,29 @@  discard block
 block discarded – undo
1705 1705
 		$process_cancelled = true;
1706 1706
 
1707 1707
 		// If the payment was not in publish or revoked status, don't decrement stats as they were never incremented
1708
-		if ( 'publish' != $this->old_status || 'cancelled' != $this->status ) {
1708
+		if ('publish' != $this->old_status || 'cancelled' != $this->status) {
1709 1709
 			$process_cancelled = false;
1710 1710
 		}
1711 1711
 
1712 1712
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments
1713
-		$process_cancelled = apply_filters( 'give_should_process_cancelled', $process_cancelled, $this );
1713
+		$process_cancelled = apply_filters('give_should_process_cancelled', $process_cancelled, $this);
1714 1714
 
1715
-		if ( false === $process_cancelled ) {
1715
+		if (false === $process_cancelled) {
1716 1716
 			return;
1717 1717
 		}
1718 1718
 
1719
-		$decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_cancelled', true, $this );
1720
-		$decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_cancelled', true, $this );
1721
-		$decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_cancelled', true, $this );
1719
+		$decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_cancelled', true, $this);
1720
+		$decrease_customer_value = apply_filters('give_decrease_customer_value_on_cancelled', true, $this);
1721
+		$decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_cancelled', true, $this);
1722 1722
 
1723
-		$this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count );
1723
+		$this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count);
1724 1724
 		$this->delete_sales_logs();
1725 1725
 
1726 1726
 		$this->completed_date = false;
1727
-		$this->update_meta( '_give_completed_date', '' );
1727
+		$this->update_meta('_give_completed_date', '');
1728 1728
 
1729 1729
 		// Clear the This Month earnings (this_monththis_month is NOT a typo)
1730
-		delete_transient( md5( 'give_earnings_this_monththis_month' ) );
1730
+		delete_transient(md5('give_earnings_this_monththis_month'));
1731 1731
 	}
1732 1732
 
1733 1733
 	/**
@@ -1740,29 +1740,29 @@  discard block
 block discarded – undo
1740 1740
 		$process_revoked = true;
1741 1741
 
1742 1742
 		// If the payment was not in publish, don't decrement stats as they were never incremented
1743
-		if ( 'publish' != $this->old_status || 'revoked' != $this->status ) {
1743
+		if ('publish' != $this->old_status || 'revoked' != $this->status) {
1744 1744
 			$process_revoked = false;
1745 1745
 		}
1746 1746
 
1747 1747
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments
1748
-		$process_revoked = apply_filters( 'give_should_process_revoked', $process_revoked, $this );
1748
+		$process_revoked = apply_filters('give_should_process_revoked', $process_revoked, $this);
1749 1749
 
1750
-		if ( false === $process_revoked ) {
1750
+		if (false === $process_revoked) {
1751 1751
 			return;
1752 1752
 		}
1753 1753
 
1754
-		$decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_revoked', true, $this );
1755
-		$decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_revoked', true, $this );
1756
-		$decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_revoked', true, $this );
1754
+		$decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_revoked', true, $this);
1755
+		$decrease_customer_value = apply_filters('give_decrease_customer_value_on_revoked', true, $this);
1756
+		$decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_revoked', true, $this);
1757 1757
 
1758
-		$this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count );
1758
+		$this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count);
1759 1759
 		$this->delete_sales_logs();
1760 1760
 
1761 1761
 		$this->completed_date = false;
1762
-		$this->update_meta( '_give_completed_date', '' );
1762
+		$this->update_meta('_give_completed_date', '');
1763 1763
 
1764 1764
 		// Clear the This Month earnings (this_monththis_month is NOT a typo)
1765
-		delete_transient( md5( 'give_earnings_this_monththis_month' ) );
1765
+		delete_transient(md5('give_earnings_this_monththis_month'));
1766 1766
 	}
1767 1767
 
1768 1768
 	/**
@@ -1777,25 +1777,25 @@  discard block
 block discarded – undo
1777 1777
 	 *
1778 1778
 	 * @return void
1779 1779
 	 */
1780
-	private function maybe_alter_stats( $alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count ) {
1780
+	private function maybe_alter_stats($alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count) {
1781 1781
 
1782
-		give_undo_purchase( false, $this->ID );
1782
+		give_undo_purchase(false, $this->ID);
1783 1783
 
1784 1784
 		// Decrease store earnings
1785
-		if ( true === $alter_store_earnings ) {
1786
-			give_decrease_total_earnings( $this->total );
1785
+		if (true === $alter_store_earnings) {
1786
+			give_decrease_total_earnings($this->total);
1787 1787
 		}
1788 1788
 
1789 1789
 		// Decrement the stats for the customer
1790
-		if ( ! empty( $this->customer_id ) ) {
1790
+		if ( ! empty($this->customer_id)) {
1791 1791
 
1792
-			$customer = new Give_Customer( $this->customer_id );
1792
+			$customer = new Give_Customer($this->customer_id);
1793 1793
 
1794
-			if ( true === $alter_customer_value ) {
1795
-				$customer->decrease_value( $this->total );
1794
+			if (true === $alter_customer_value) {
1795
+				$customer->decrease_value($this->total);
1796 1796
 			}
1797 1797
 
1798
-			if ( true === $alter_customer_purchase_count ) {
1798
+			if (true === $alter_customer_purchase_count) {
1799 1799
 				$customer->decrease_purchase_count();
1800 1800
 			}
1801 1801
 
@@ -1845,13 +1845,13 @@  discard block
 block discarded – undo
1845 1845
 	 * @return string The date the payment was completed
1846 1846
 	 */
1847 1847
 	private function setup_completed_date() {
1848
-		$payment = get_post( $this->ID );
1848
+		$payment = get_post($this->ID);
1849 1849
 
1850
-		if ( 'pending' == $payment->post_status || 'preapproved' == $payment->post_status ) {
1850
+		if ('pending' == $payment->post_status || 'preapproved' == $payment->post_status) {
1851 1851
 			return false; // This payment was never completed
1852 1852
 		}
1853 1853
 
1854
-		$date = ( $date = $this->get_meta( '_give_completed_date', true ) ) ? $date : $payment->modified_date;
1854
+		$date = ($date = $this->get_meta('_give_completed_date', true)) ? $date : $payment->modified_date;
1855 1855
 
1856 1856
 		return $date;
1857 1857
 	}
@@ -1865,7 +1865,7 @@  discard block
 block discarded – undo
1865 1865
 	 * @return string The payment mode
1866 1866
 	 */
1867 1867
 	private function setup_mode() {
1868
-		return $this->get_meta( '_give_payment_mode' );
1868
+		return $this->get_meta('_give_payment_mode');
1869 1869
 	}
1870 1870
 
1871 1871
 	/**
@@ -1877,13 +1877,13 @@  discard block
 block discarded – undo
1877 1877
 	 * @return float The payment total
1878 1878
 	 */
1879 1879
 	private function setup_total() {
1880
-		$amount = $this->get_meta( '_give_payment_total', true );
1880
+		$amount = $this->get_meta('_give_payment_total', true);
1881 1881
 
1882
-		if ( empty( $amount ) && '0.00' != $amount ) {
1883
-			$meta = $this->get_meta( '_give_payment_meta', true );
1884
-			$meta = maybe_unserialize( $meta );
1882
+		if (empty($amount) && '0.00' != $amount) {
1883
+			$meta = $this->get_meta('_give_payment_meta', true);
1884
+			$meta = maybe_unserialize($meta);
1885 1885
 
1886
-			if ( isset( $meta['amount'] ) ) {
1886
+			if (isset($meta['amount'])) {
1887 1887
 				$amount = $meta['amount'];
1888 1888
 			}
1889 1889
 		}
@@ -1916,9 +1916,9 @@  discard block
 block discarded – undo
1916 1916
 	private function setup_fees_total() {
1917 1917
 		$fees_total = (float) 0.00;
1918 1918
 
1919
-		$payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array();
1920
-		if ( ! empty( $payment_fees ) ) {
1921
-			foreach ( $payment_fees as $fee ) {
1919
+		$payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array();
1920
+		if ( ! empty($payment_fees)) {
1921
+			foreach ($payment_fees as $fee) {
1922 1922
 				$fees_total += (float) $fee['amount'];
1923 1923
 			}
1924 1924
 		}
@@ -1936,7 +1936,7 @@  discard block
 block discarded – undo
1936 1936
 	 * @return string The currency for the payment
1937 1937
 	 */
1938 1938
 	private function setup_currency() {
1939
-		$currency = isset( $this->payment_meta['currency'] ) ? $this->payment_meta['currency'] : apply_filters( 'give_donation_currency_default', give_get_currency(), $this );
1939
+		$currency = isset($this->payment_meta['currency']) ? $this->payment_meta['currency'] : apply_filters('give_donation_currency_default', give_get_currency(), $this);
1940 1940
 
1941 1941
 		return $currency;
1942 1942
 	}
@@ -1950,7 +1950,7 @@  discard block
 block discarded – undo
1950 1950
 	 * @return array The Fees
1951 1951
 	 */
1952 1952
 	private function setup_fees() {
1953
-		$payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array();
1953
+		$payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array();
1954 1954
 
1955 1955
 		return $payment_fees;
1956 1956
 	}
@@ -1964,7 +1964,7 @@  discard block
 block discarded – undo
1964 1964
 	 * @return string The gateway
1965 1965
 	 */
1966 1966
 	private function setup_gateway() {
1967
-		$gateway = $this->get_meta( '_give_payment_gateway', true );
1967
+		$gateway = $this->get_meta('_give_payment_gateway', true);
1968 1968
 
1969 1969
 		return $gateway;
1970 1970
 	}
@@ -1978,12 +1978,12 @@  discard block
 block discarded – undo
1978 1978
 	 * @return string The donation ID
1979 1979
 	 */
1980 1980
 	private function setup_transaction_id() {
1981
-		$transaction_id = $this->get_meta( '_give_payment_transaction_id', true );
1981
+		$transaction_id = $this->get_meta('_give_payment_transaction_id', true);
1982 1982
 
1983
-		if ( empty( $transaction_id ) || (int) $transaction_id === (int) $this->ID ) {
1983
+		if (empty($transaction_id) || (int) $transaction_id === (int) $this->ID) {
1984 1984
 
1985 1985
 			$gateway        = $this->gateway;
1986
-			$transaction_id = apply_filters( "give_get_payment_transaction_id-{$gateway}", $this->ID );
1986
+			$transaction_id = apply_filters("give_get_payment_transaction_id-{$gateway}", $this->ID);
1987 1987
 
1988 1988
 		}
1989 1989
 
@@ -1999,7 +1999,7 @@  discard block
 block discarded – undo
1999 1999
 	 * @return string The IP address for the payment
2000 2000
 	 */
2001 2001
 	private function setup_ip() {
2002
-		$ip = $this->get_meta( '_give_payment_user_ip', true );
2002
+		$ip = $this->get_meta('_give_payment_user_ip', true);
2003 2003
 
2004 2004
 		return $ip;
2005 2005
 	}
@@ -2013,7 +2013,7 @@  discard block
 block discarded – undo
2013 2013
 	 * @return int The Customer ID
2014 2014
 	 */
2015 2015
 	private function setup_customer_id() {
2016
-		$customer_id = $this->get_meta( '_give_payment_customer_id', true );
2016
+		$customer_id = $this->get_meta('_give_payment_customer_id', true);
2017 2017
 
2018 2018
 		return $customer_id;
2019 2019
 	}
@@ -2027,7 +2027,7 @@  discard block
 block discarded – undo
2027 2027
 	 * @return int The User ID
2028 2028
 	 */
2029 2029
 	private function setup_user_id() {
2030
-		$user_id = $this->get_meta( '_give_payment_user_id', true );
2030
+		$user_id = $this->get_meta('_give_payment_user_id', true);
2031 2031
 
2032 2032
 		return $user_id;
2033 2033
 	}
@@ -2041,10 +2041,10 @@  discard block
 block discarded – undo
2041 2041
 	 * @return string The email address for the payment
2042 2042
 	 */
2043 2043
 	private function setup_email() {
2044
-		$email = $this->get_meta( '_give_payment_user_email', true );
2044
+		$email = $this->get_meta('_give_payment_user_email', true);
2045 2045
 
2046
-		if ( empty( $email ) ) {
2047
-			$email = Give()->customers->get_column( 'email', $this->customer_id );
2046
+		if (empty($email)) {
2047
+			$email = Give()->customers->get_column('email', $this->customer_id);
2048 2048
 		}
2049 2049
 
2050 2050
 		return $email;
@@ -2064,15 +2064,15 @@  discard block
 block discarded – undo
2064 2064
 			'last_name'  => $this->last_name,
2065 2065
 		);
2066 2066
 
2067
-		$user_info = isset( $this->payment_meta['user_info'] ) ? maybe_unserialize( $this->payment_meta['user_info'] ) : array();
2068
-		$user_info = wp_parse_args( $user_info, $defaults );
2067
+		$user_info = isset($this->payment_meta['user_info']) ? maybe_unserialize($this->payment_meta['user_info']) : array();
2068
+		$user_info = wp_parse_args($user_info, $defaults);
2069 2069
 
2070
-		if ( empty( $user_info ) ) {
2070
+		if (empty($user_info)) {
2071 2071
 			// Get the customer, but only if it's been created
2072
-			$customer = new Give_Customer( $this->customer_id );
2072
+			$customer = new Give_Customer($this->customer_id);
2073 2073
 
2074
-			if ( $customer->id > 0 ) {
2075
-				$name      = explode( ' ', $customer->name, 2 );
2074
+			if ($customer->id > 0) {
2075
+				$name      = explode(' ', $customer->name, 2);
2076 2076
 				$user_info = array(
2077 2077
 					'first_name' => $name[0],
2078 2078
 					'last_name'  => $name[1],
@@ -2082,29 +2082,29 @@  discard block
 block discarded – undo
2082 2082
 			}
2083 2083
 		} else {
2084 2084
 			// Get the customer, but only if it's been created
2085
-			$customer = new Give_Customer( $this->customer_id );
2086
-			if ( $customer->id > 0 ) {
2087
-				foreach ( $user_info as $key => $value ) {
2088
-					if ( ! empty( $value ) ) {
2085
+			$customer = new Give_Customer($this->customer_id);
2086
+			if ($customer->id > 0) {
2087
+				foreach ($user_info as $key => $value) {
2088
+					if ( ! empty($value)) {
2089 2089
 						continue;
2090 2090
 					}
2091 2091
 
2092
-					switch ( $key ) {
2092
+					switch ($key) {
2093 2093
 						case 'first_name':
2094
-							$name = explode( ' ', $customer->name, 2 );
2094
+							$name = explode(' ', $customer->name, 2);
2095 2095
 
2096
-							$user_info[ $key ] = $name[0];
2096
+							$user_info[$key] = $name[0];
2097 2097
 							break;
2098 2098
 
2099 2099
 						case 'last_name':
2100
-							$name      = explode( ' ', $customer->name, 2 );
2101
-							$last_name = ! empty( $name[1] ) ? $name[1] : '';
2100
+							$name      = explode(' ', $customer->name, 2);
2101
+							$last_name = ! empty($name[1]) ? $name[1] : '';
2102 2102
 
2103
-							$user_info[ $key ] = $last_name;
2103
+							$user_info[$key] = $last_name;
2104 2104
 							break;
2105 2105
 
2106 2106
 						case 'email':
2107
-							$user_info[ $key ] = $customer->email;
2107
+							$user_info[$key] = $customer->email;
2108 2108
 							break;
2109 2109
 					}
2110 2110
 				}
@@ -2126,7 +2126,7 @@  discard block
 block discarded – undo
2126 2126
 	 */
2127 2127
 	private function setup_address() {
2128 2128
 
2129
-		$address = ! empty( $this->payment_meta['user_info']['address'] ) ? $this->payment_meta['user_info']['address'] : array(
2129
+		$address = ! empty($this->payment_meta['user_info']['address']) ? $this->payment_meta['user_info']['address'] : array(
2130 2130
 			'line1'   => '',
2131 2131
 			'line2'   => '',
2132 2132
 			'city'    => '',
@@ -2148,7 +2148,7 @@  discard block
 block discarded – undo
2148 2148
 	 */
2149 2149
 	private function setup_form_title() {
2150 2150
 
2151
-		$form_id = $this->get_meta( '_give_payment_form_title', true );
2151
+		$form_id = $this->get_meta('_give_payment_form_title', true);
2152 2152
 
2153 2153
 		return $form_id;
2154 2154
 	}
@@ -2163,7 +2163,7 @@  discard block
 block discarded – undo
2163 2163
 	 */
2164 2164
 	private function setup_form_id() {
2165 2165
 
2166
-		$form_id = $this->get_meta( '_give_payment_form_id', true );
2166
+		$form_id = $this->get_meta('_give_payment_form_id', true);
2167 2167
 
2168 2168
 		return $form_id;
2169 2169
 	}
@@ -2177,7 +2177,7 @@  discard block
 block discarded – undo
2177 2177
 	 * @return int The Form Price ID
2178 2178
 	 */
2179 2179
 	private function setup_price_id() {
2180
-		$price_id = $this->get_meta( '_give_payment_price_id', true );
2180
+		$price_id = $this->get_meta('_give_payment_price_id', true);
2181 2181
 
2182 2182
 		return $price_id;
2183 2183
 	}
@@ -2191,7 +2191,7 @@  discard block
 block discarded – undo
2191 2191
 	 * @return string The Payment Key
2192 2192
 	 */
2193 2193
 	private function setup_payment_key() {
2194
-		$key = $this->get_meta( '_give_payment_purchase_key', true );
2194
+		$key = $this->get_meta('_give_payment_purchase_key', true);
2195 2195
 
2196 2196
 		return $key;
2197 2197
 	}
@@ -2207,11 +2207,11 @@  discard block
 block discarded – undo
2207 2207
 	private function setup_payment_number() {
2208 2208
 		$number = $this->ID;
2209 2209
 
2210
-		if ( give_get_option( 'enable_sequential' ) ) {
2210
+		if (give_get_option('enable_sequential')) {
2211 2211
 
2212
-			$number = $this->get_meta( '_give_payment_number', true );
2212
+			$number = $this->get_meta('_give_payment_number', true);
2213 2213
 
2214
-			if ( ! $number ) {
2214
+			if ( ! $number) {
2215 2215
 
2216 2216
 				$number = $this->ID;
2217 2217
 
@@ -2230,7 +2230,7 @@  discard block
 block discarded – undo
2230 2230
 	 * @return array The payment object as an array
2231 2231
 	 */
2232 2232
 	public function array_convert() {
2233
-		return get_object_vars( $this );
2233
+		return get_object_vars($this);
2234 2234
 	}
2235 2235
 
2236 2236
 	/**
@@ -2242,7 +2242,7 @@  discard block
 block discarded – undo
2242 2242
 	 * @return string Date payment was completed
2243 2243
 	 */
2244 2244
 	private function get_completed_date() {
2245
-		return apply_filters( 'give_donation_completed_date', $this->completed_date, $this->ID, $this );
2245
+		return apply_filters('give_donation_completed_date', $this->completed_date, $this->ID, $this);
2246 2246
 	}
2247 2247
 
2248 2248
 	/**
@@ -2254,7 +2254,7 @@  discard block
 block discarded – undo
2254 2254
 	 * @return float Payment subtotal
2255 2255
 	 */
2256 2256
 	private function get_subtotal() {
2257
-		return apply_filters( 'give_get_payment_subtotal', $this->subtotal, $this->ID, $this );
2257
+		return apply_filters('give_get_payment_subtotal', $this->subtotal, $this->ID, $this);
2258 2258
 	}
2259 2259
 
2260 2260
 	/**
@@ -2266,7 +2266,7 @@  discard block
 block discarded – undo
2266 2266
 	 * @return string Payment currency code
2267 2267
 	 */
2268 2268
 	private function get_currency() {
2269
-		return apply_filters( 'give_donation_currency_code', $this->currency, $this->ID, $this );
2269
+		return apply_filters('give_donation_currency_code', $this->currency, $this->ID, $this);
2270 2270
 	}
2271 2271
 
2272 2272
 	/**
@@ -2278,7 +2278,7 @@  discard block
 block discarded – undo
2278 2278
 	 * @return string Gateway used
2279 2279
 	 */
2280 2280
 	private function get_gateway() {
2281
-		return apply_filters( 'give_donation_gateway', $this->gateway, $this->ID, $this );
2281
+		return apply_filters('give_donation_gateway', $this->gateway, $this->ID, $this);
2282 2282
 	}
2283 2283
 
2284 2284
 	/**
@@ -2290,7 +2290,7 @@  discard block
 block discarded – undo
2290 2290
 	 * @return string Donation ID from merchant processor
2291 2291
 	 */
2292 2292
 	private function get_transaction_id() {
2293
-		return apply_filters( 'give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this );
2293
+		return apply_filters('give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this);
2294 2294
 	}
2295 2295
 
2296 2296
 	/**
@@ -2302,7 +2302,7 @@  discard block
 block discarded – undo
2302 2302
 	 * @return string Payment IP address
2303 2303
 	 */
2304 2304
 	private function get_ip() {
2305
-		return apply_filters( 'give_donation_user_ip', $this->ip, $this->ID, $this );
2305
+		return apply_filters('give_donation_user_ip', $this->ip, $this->ID, $this);
2306 2306
 	}
2307 2307
 
2308 2308
 	/**
@@ -2314,7 +2314,7 @@  discard block
 block discarded – undo
2314 2314
 	 * @return int Payment customer ID
2315 2315
 	 */
2316 2316
 	private function get_customer_id() {
2317
-		return apply_filters( 'give_donation_customer_id', $this->customer_id, $this->ID, $this );
2317
+		return apply_filters('give_donation_customer_id', $this->customer_id, $this->ID, $this);
2318 2318
 	}
2319 2319
 
2320 2320
 	/**
@@ -2326,7 +2326,7 @@  discard block
 block discarded – undo
2326 2326
 	 * @return int Payment user ID
2327 2327
 	 */
2328 2328
 	private function get_user_id() {
2329
-		return apply_filters( 'give_donation_user_id', $this->user_id, $this->ID, $this );
2329
+		return apply_filters('give_donation_user_id', $this->user_id, $this->ID, $this);
2330 2330
 	}
2331 2331
 
2332 2332
 	/**
@@ -2338,7 +2338,7 @@  discard block
 block discarded – undo
2338 2338
 	 * @return string Payment customer email
2339 2339
 	 */
2340 2340
 	private function get_email() {
2341
-		return apply_filters( 'give_donation_user_email', $this->email, $this->ID, $this );
2341
+		return apply_filters('give_donation_user_email', $this->email, $this->ID, $this);
2342 2342
 	}
2343 2343
 
2344 2344
 	/**
@@ -2350,7 +2350,7 @@  discard block
 block discarded – undo
2350 2350
 	 * @return array Payment user info
2351 2351
 	 */
2352 2352
 	private function get_user_info() {
2353
-		return apply_filters( 'give_donation_meta_user_info', $this->user_info, $this->ID, $this );
2353
+		return apply_filters('give_donation_meta_user_info', $this->user_info, $this->ID, $this);
2354 2354
 	}
2355 2355
 
2356 2356
 	/**
@@ -2362,7 +2362,7 @@  discard block
 block discarded – undo
2362 2362
 	 * @return array Payment billing address
2363 2363
 	 */
2364 2364
 	private function get_address() {
2365
-		return apply_filters( 'give_donation_address', $this->address, $this->ID, $this );
2365
+		return apply_filters('give_donation_address', $this->address, $this->ID, $this);
2366 2366
 	}
2367 2367
 
2368 2368
 	/**
@@ -2374,7 +2374,7 @@  discard block
 block discarded – undo
2374 2374
 	 * @return string Payment key
2375 2375
 	 */
2376 2376
 	private function get_key() {
2377
-		return apply_filters( 'give_donation_key', $this->key, $this->ID, $this );
2377
+		return apply_filters('give_donation_key', $this->key, $this->ID, $this);
2378 2378
 	}
2379 2379
 
2380 2380
 	/**
@@ -2386,7 +2386,7 @@  discard block
 block discarded – undo
2386 2386
 	 * @return string Payment form id
2387 2387
 	 */
2388 2388
 	private function get_form_id() {
2389
-		return apply_filters( 'give_donation_form_id', $this->form_id, $this->ID, $this );
2389
+		return apply_filters('give_donation_form_id', $this->form_id, $this->ID, $this);
2390 2390
 	}
2391 2391
 
2392 2392
 	/**
@@ -2398,7 +2398,7 @@  discard block
 block discarded – undo
2398 2398
 	 * @return int|string Payment number
2399 2399
 	 */
2400 2400
 	private function get_number() {
2401
-		return apply_filters( 'give_donation_number', $this->number, $this->ID, $this );
2401
+		return apply_filters('give_donation_number', $this->number, $this->ID, $this);
2402 2402
 	}
2403 2403
 
2404 2404
 }
Please login to merge, or discard this patch.
admin/reporting/tools/class-give-tools-recount-single-customer-stats.php 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -188,8 +188,8 @@
 block discarded – undo
188 188
 
189 189
 			$payment_ids = implode( ',', $payment_ids );
190 190
 			$customer->update( array( 'payment_ids'    => $payment_ids,
191
-			                          'purchase_count' => $purchase_count,
192
-			                          'purchase_value' => $pending_total
191
+									  'purchase_count' => $purchase_count,
192
+									  'purchase_value' => $pending_total
193 193
 			) );
194 194
 
195 195
 			$this->done    = true;
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
 	 * @since 1.5
51 51
 	 * @global object $wpdb Used to query the database using the WordPress
52 52
 	 *   Database API
53
-	 * @return array $data The data for the CSV file
53
+	 * @return boolean $data The data for the CSV file
54 54
 	 */
55 55
 	public function get_data() {
56 56
 		global $wpdb;
Please login to merge, or discard this patch.
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -54,39 +54,39 @@  discard block
 block discarded – undo
54 54
 	 */
55 55
 	public function get_data() {
56 56
 
57
-		$customer = new Give_Customer( $this->customer_id );
58
-		$payments = $this->get_stored_data( 'give_recount_customer_payments_' . $customer->id, array() );
57
+		$customer = new Give_Customer($this->customer_id);
58
+		$payments = $this->get_stored_data('give_recount_customer_payments_'.$customer->id, array());
59 59
 
60
-		$offset     = ( $this->step - 1 ) * $this->per_step;
61
-		$step_items = array_slice( $payments, $offset, $this->per_step );
60
+		$offset     = ($this->step - 1) * $this->per_step;
61
+		$step_items = array_slice($payments, $offset, $this->per_step);
62 62
 
63
-		if ( count( $step_items ) > 0 ) {
64
-			$pending_total = (float) $this->get_stored_data( 'give_stats_customer_pending_total' . $customer->id, 0 );
63
+		if (count($step_items) > 0) {
64
+			$pending_total = (float) $this->get_stored_data('give_stats_customer_pending_total'.$customer->id, 0);
65 65
 			$step_total    = 0;
66 66
 
67
-			$found_payment_ids = $this->get_stored_data( 'give_stats_found_payments_' . $customer->id, array() );
67
+			$found_payment_ids = $this->get_stored_data('give_stats_found_payments_'.$customer->id, array());
68 68
 
69
-			foreach ( $step_items as $payment ) {
70
-				$payment = get_post( $payment->ID );
69
+			foreach ($step_items as $payment) {
70
+				$payment = get_post($payment->ID);
71 71
 
72
-				if ( is_null( $payment ) || is_wp_error( $payment ) || 'give_payment' !== $payment->post_type ) {
72
+				if (is_null($payment) || is_wp_error($payment) || 'give_payment' !== $payment->post_type) {
73 73
 
74
-					$missing_payments   = $this->get_stored_data( 'give_stats_missing_payments' . $customer->id, array() );
74
+					$missing_payments   = $this->get_stored_data('give_stats_missing_payments'.$customer->id, array());
75 75
 					$missing_payments[] = $payment->ID;
76
-					$this->store_data( 'give_stats_missing_payments' . $customer->id, $missing_payments );
76
+					$this->store_data('give_stats_missing_payments'.$customer->id, $missing_payments);
77 77
 
78 78
 					continue;
79 79
 				}
80 80
 
81 81
 				$should_process_payment = 'publish' == $payment->post_status ? true : false;
82
-				$should_process_payment = apply_filters( 'give_donor_recount_should_process_donation', $should_process_payment, $payment );
82
+				$should_process_payment = apply_filters('give_donor_recount_should_process_donation', $should_process_payment, $payment);
83 83
 
84
-				if ( true === $should_process_payment ) {
84
+				if (true === $should_process_payment) {
85 85
 
86 86
 					$found_payment_ids[] = $payment->ID;
87 87
 
88
-					if ( apply_filters( 'give_customer_recount_sholud_increase_value', true, $payment ) ) {
89
-						$payment_amount = give_get_payment_amount( $payment->ID );
88
+					if (apply_filters('give_customer_recount_sholud_increase_value', true, $payment)) {
89
+						$payment_amount = give_get_payment_amount($payment->ID);
90 90
 						$step_total += $payment_amount;
91 91
 					}
92 92
 
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
 			}
96 96
 
97 97
 			$updated_total = $pending_total + $step_total;
98
-			$this->store_data( 'give_stats_customer_pending_total' . $customer->id, $updated_total );
99
-			$this->store_data( 'give_stats_found_payments_' . $customer->id, $found_payment_ids );
98
+			$this->store_data('give_stats_customer_pending_total'.$customer->id, $updated_total);
99
+			$this->store_data('give_stats_found_payments_'.$customer->id, $found_payment_ids);
100 100
 
101 101
 			return true;
102 102
 		}
@@ -113,16 +113,16 @@  discard block
 block discarded – undo
113 113
 	 */
114 114
 	public function get_percentage_complete() {
115 115
 
116
-		$payments = $this->get_stored_data( 'give_recount_customer_payments_' . $this->customer_id );
117
-		$total    = count( $payments );
116
+		$payments = $this->get_stored_data('give_recount_customer_payments_'.$this->customer_id);
117
+		$total    = count($payments);
118 118
 
119 119
 		$percentage = 100;
120 120
 
121
-		if ( $total > 0 ) {
122
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
121
+		if ($total > 0) {
122
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
123 123
 		}
124 124
 
125
-		if ( $percentage > 100 ) {
125
+		if ($percentage > 100) {
126 126
 			$percentage = 100;
127 127
 		}
128 128
 
@@ -136,8 +136,8 @@  discard block
 block discarded – undo
136 136
 	 *
137 137
 	 * @param array $request The Form Data passed into the batch processing
138 138
 	 */
139
-	public function set_properties( $request ) {
140
-		$this->customer_id = isset( $request['customer_id'] ) ? sanitize_text_field( $request['customer_id'] ) : false;
139
+	public function set_properties($request) {
140
+		$this->customer_id = isset($request['customer_id']) ? sanitize_text_field($request['customer_id']) : false;
141 141
 	}
142 142
 
143 143
 	/**
@@ -148,62 +148,62 @@  discard block
 block discarded – undo
148 148
 	 */
149 149
 	public function process_step() {
150 150
 
151
-		if ( ! $this->can_export() ) {
152
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
151
+		if ( ! $this->can_export()) {
152
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
153 153
 		}
154 154
 
155 155
 		$had_data = $this->get_data();
156 156
 
157
-		if ( $had_data ) {
157
+		if ($had_data) {
158 158
 			$this->done = false;
159 159
 
160 160
 			return true;
161 161
 		} else {
162
-			$customer    = new Give_Customer( $this->customer_id );
163
-			$payment_ids = get_option( 'give_stats_found_payments_' . $customer->id, array() );
164
-			$this->delete_data( 'give_stats_found_payments_' . $customer->id );
162
+			$customer    = new Give_Customer($this->customer_id);
163
+			$payment_ids = get_option('give_stats_found_payments_'.$customer->id, array());
164
+			$this->delete_data('give_stats_found_payments_'.$customer->id);
165 165
 
166
-			$removed_payments = array_unique( get_option( 'give_stats_missing_payments' . $customer->id, array() ) );
166
+			$removed_payments = array_unique(get_option('give_stats_missing_payments'.$customer->id, array()));
167 167
 
168 168
 			// Find non-existing payments (deleted) and total up the donation count
169 169
 			$purchase_count = 0;
170
-			foreach ( $payment_ids as $key => $payment_id ) {
171
-				if ( in_array( $payment_id, $removed_payments ) ) {
172
-					unset( $payment_ids[ $key ] );
170
+			foreach ($payment_ids as $key => $payment_id) {
171
+				if (in_array($payment_id, $removed_payments)) {
172
+					unset($payment_ids[$key]);
173 173
 					continue;
174 174
 				}
175 175
 
176
-				$payment = get_post( $payment_id );
177
-				if ( apply_filters( 'give_customer_recount_should_increase_count', true, $payment ) ) {
178
-					$purchase_count ++;
176
+				$payment = get_post($payment_id);
177
+				if (apply_filters('give_customer_recount_should_increase_count', true, $payment)) {
178
+					$purchase_count++;
179 179
 				}
180 180
 			}
181 181
 
182
-			$this->delete_data( 'give_stats_missing_payments' . $customer->id );
182
+			$this->delete_data('give_stats_missing_payments'.$customer->id);
183 183
 
184
-			$pending_total = $this->get_stored_data( 'give_stats_customer_pending_total' . $customer->id, 0 );
185
-			$this->delete_data( 'give_stats_customer_pending_total' . $customer->id );
186
-			$this->delete_data( 'give_recount_customer_stats_' . $customer->id );
187
-			$this->delete_data( 'give_recount_customer_payments_' . $this->customer_id );
184
+			$pending_total = $this->get_stored_data('give_stats_customer_pending_total'.$customer->id, 0);
185
+			$this->delete_data('give_stats_customer_pending_total'.$customer->id);
186
+			$this->delete_data('give_recount_customer_stats_'.$customer->id);
187
+			$this->delete_data('give_recount_customer_payments_'.$this->customer_id);
188 188
 
189
-			$payment_ids = implode( ',', $payment_ids );
190
-			$customer->update( array( 'payment_ids'    => $payment_ids,
189
+			$payment_ids = implode(',', $payment_ids);
190
+			$customer->update(array('payment_ids'    => $payment_ids,
191 191
 			                          'purchase_count' => $purchase_count,
192 192
 			                          'purchase_value' => $pending_total
193
-			) );
193
+			));
194 194
 
195 195
 			$this->done    = true;
196
-			$this->message = esc_html__( 'Donor stats successfully recounted.', 'give' );
196
+			$this->message = esc_html__('Donor stats successfully recounted.', 'give');
197 197
 
198 198
 			return false;
199 199
 		}
200 200
 	}
201 201
 
202 202
 	public function headers() {
203
-		ignore_user_abort( true );
203
+		ignore_user_abort(true);
204 204
 
205
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
206
-			set_time_limit( 0 );
205
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
206
+			set_time_limit(0);
207 207
 		}
208 208
 	}
209 209
 
@@ -230,26 +230,26 @@  discard block
 block discarded – undo
230 230
 	 * @return void
231 231
 	 */
232 232
 	public function pre_fetch() {
233
-		if ( $this->step === 1 ) {
234
-			$allowed_payment_status = apply_filters( 'give_recount_donors_donation_statuses', give_get_payment_status_keys() );
233
+		if ($this->step === 1) {
234
+			$allowed_payment_status = apply_filters('give_recount_donors_donation_statuses', give_get_payment_status_keys());
235 235
 
236 236
 			// Before we start, let's zero out the customer's data
237
-			$customer = new Give_Customer( $this->customer_id );
238
-			$customer->update( array( 'purchase_value' => give_format_amount( 0 ), 'purchase_count' => 0 ) );
237
+			$customer = new Give_Customer($this->customer_id);
238
+			$customer->update(array('purchase_value' => give_format_amount(0), 'purchase_count' => 0));
239 239
 
240
-			$attached_payment_ids = explode( ',', $customer->payment_ids );
240
+			$attached_payment_ids = explode(',', $customer->payment_ids);
241 241
 
242 242
 			$attached_args = array(
243 243
 				'post__in' => $attached_payment_ids,
244
-				'number'   => - 1,
244
+				'number'   => -1,
245 245
 				'status'   => $allowed_payment_status,
246 246
 			);
247 247
 
248
-			$attached_payments = give_get_payments( $attached_args );
248
+			$attached_payments = give_get_payments($attached_args);
249 249
 
250 250
 			$unattached_args = array(
251 251
 				'post__not_in' => $attached_payment_ids,
252
-				'number'       => - 1,
252
+				'number'       => -1,
253 253
 				'status'       => $allowed_payment_status,
254 254
 				'meta_query'   => array(
255 255
 					array(
@@ -259,11 +259,11 @@  discard block
 block discarded – undo
259 259
 				),
260 260
 			);
261 261
 
262
-			$unattached_payments = give_get_payments( $unattached_args );
262
+			$unattached_payments = give_get_payments($unattached_args);
263 263
 
264
-			$payments = array_merge( $attached_payments, $unattached_payments );
264
+			$payments = array_merge($attached_payments, $unattached_payments);
265 265
 
266
-			$this->store_data( 'give_recount_customer_payments_' . $customer->id, $payments );
266
+			$this->store_data('give_recount_customer_payments_'.$customer->id, $payments);
267 267
 		}
268 268
 	}
269 269
 
@@ -276,11 +276,11 @@  discard block
 block discarded – undo
276 276
 	 *
277 277
 	 * @return mixed       Returns the data from the database
278 278
 	 */
279
-	private function get_stored_data( $key ) {
279
+	private function get_stored_data($key) {
280 280
 		global $wpdb;
281
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
281
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
282 282
 
283
-		return empty( $value ) ? false : maybe_unserialize( $value );
283
+		return empty($value) ? false : maybe_unserialize($value);
284 284
 	}
285 285
 
286 286
 	/**
@@ -293,10 +293,10 @@  discard block
 block discarded – undo
293 293
 	 *
294 294
 	 * @return void
295 295
 	 */
296
-	private function store_data( $key, $value ) {
296
+	private function store_data($key, $value) {
297 297
 		global $wpdb;
298 298
 
299
-		$value = maybe_serialize( $value );
299
+		$value = maybe_serialize($value);
300 300
 
301 301
 		$data = array(
302 302
 			'option_name'  => $key,
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 			'%s',
311 311
 		);
312 312
 
313
-		$wpdb->replace( $wpdb->options, $data, $formats );
313
+		$wpdb->replace($wpdb->options, $data, $formats);
314 314
 	}
315 315
 
316 316
 	/**
@@ -322,9 +322,9 @@  discard block
 block discarded – undo
322 322
 	 *
323 323
 	 * @return void
324 324
 	 */
325
-	private function delete_data( $key ) {
325
+	private function delete_data($key) {
326 326
 		global $wpdb;
327
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
327
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
328 328
 	}
329 329
 
330 330
 }
Please login to merge, or discard this patch.
includes/admin/reporting/tools/tools-actions.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -19,10 +19,10 @@  discard block
 block discarded – undo
19 19
  * @since  1.5
20 20
  */
21 21
 function give_register_batch_recount_store_earnings_tool() {
22
-	add_action( 'give_batch_export_class_include', 'give_include_recount_income_tool_batch_processor', 10, 1 );
22
+	add_action('give_batch_export_class_include', 'give_include_recount_income_tool_batch_processor', 10, 1);
23 23
 }
24 24
 
25
-add_action( 'give_register_batch_exporter', 'give_register_batch_recount_store_earnings_tool', 10 );
25
+add_action('give_register_batch_exporter', 'give_register_batch_recount_store_earnings_tool', 10);
26 26
 
27 27
 /**
28 28
  * Loads the tools batch processing class for recounting store earnings
@@ -33,11 +33,11 @@  discard block
 block discarded – undo
33 33
  *
34 34
  * @return void
35 35
  */
36
-function give_include_recount_income_tool_batch_processor( $class ) {
36
+function give_include_recount_income_tool_batch_processor($class) {
37 37
 
38
-	$file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-recount-income.php';
38
+	$file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-recount-income.php';
39 39
 
40
-	if ( 'Give_Tools_Recount_Income' === $class && file_exists( $file_path ) ) {
40
+	if ('Give_Tools_Recount_Income' === $class && file_exists($file_path)) {
41 41
 		require_once $file_path;
42 42
 	}
43 43
 
@@ -49,10 +49,10 @@  discard block
 block discarded – undo
49 49
  * @since  1.5
50 50
  */
51 51
 function give_register_batch_recount_form_tool() {
52
-	add_action( 'give_batch_export_class_include', 'give_include_recount_form_tool_batch_processor', 10, 1 );
52
+	add_action('give_batch_export_class_include', 'give_include_recount_form_tool_batch_processor', 10, 1);
53 53
 }
54 54
 
55
-add_action( 'give_register_batch_exporter', 'give_register_batch_recount_form_tool', 10 );
55
+add_action('give_register_batch_exporter', 'give_register_batch_recount_form_tool', 10);
56 56
 
57 57
 /**
58 58
  * Loads the tools batch processing class for recounting download stats
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
  *
64 64
  * @return void
65 65
  */
66
-function give_include_recount_form_tool_batch_processor( $class ) {
66
+function give_include_recount_form_tool_batch_processor($class) {
67 67
 
68
-	$file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-recount-form-stats.php';
68
+	$file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-recount-form-stats.php';
69 69
 
70
-	if ( 'Give_Tools_Recount_Form_Stats' === $class && file_exists( $file_path ) ) {
70
+	if ('Give_Tools_Recount_Form_Stats' === $class && file_exists($file_path)) {
71 71
 		require_once $file_path;
72 72
 	}
73 73
 
@@ -78,10 +78,10 @@  discard block
 block discarded – undo
78 78
  * @since  1.5
79 79
  */
80 80
 function give_register_batch_recount_all_tool() {
81
-	add_action( 'give_batch_export_class_include', 'give_include_recount_all_tool_batch_processor', 10, 1 );
81
+	add_action('give_batch_export_class_include', 'give_include_recount_all_tool_batch_processor', 10, 1);
82 82
 }
83 83
 
84
-add_action( 'give_register_batch_exporter', 'give_register_batch_recount_all_tool', 10 );
84
+add_action('give_register_batch_exporter', 'give_register_batch_recount_all_tool', 10);
85 85
 
86 86
 /**
87 87
  * Loads the tools batch processing class for recounting all stats
@@ -92,9 +92,9 @@  discard block
 block discarded – undo
92 92
  *
93 93
  * @return void
94 94
  */
95
-function give_include_recount_all_tool_batch_processor( $class ) {
96
-	$file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-recount-all-stats.php';
97
-	if ( 'Give_Tools_Recount_All_Stats' === $class && file_exists( $file_path ) ) {
95
+function give_include_recount_all_tool_batch_processor($class) {
96
+	$file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-recount-all-stats.php';
97
+	if ('Give_Tools_Recount_All_Stats' === $class && file_exists($file_path)) {
98 98
 		require_once $file_path;
99 99
 	}
100 100
 
@@ -106,10 +106,10 @@  discard block
 block discarded – undo
106 106
  * @since  1.5
107 107
  */
108 108
 function give_register_batch_reset_tool() {
109
-	add_action( 'give_batch_export_class_include', 'give_include_reset_tool_batch_processor', 10, 1 );
109
+	add_action('give_batch_export_class_include', 'give_include_reset_tool_batch_processor', 10, 1);
110 110
 }
111 111
 
112
-add_action( 'give_register_batch_exporter', 'give_register_batch_reset_tool', 10 );
112
+add_action('give_register_batch_exporter', 'give_register_batch_reset_tool', 10);
113 113
 
114 114
 /**
115 115
  * Loads the tools batch processing class for resetting store and product earnings
@@ -120,11 +120,11 @@  discard block
 block discarded – undo
120 120
  *
121 121
  * @return void
122 122
  */
123
-function give_include_reset_tool_batch_processor( $class ) {
123
+function give_include_reset_tool_batch_processor($class) {
124 124
 
125
-	$file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-reset-stats.php';
125
+	$file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-reset-stats.php';
126 126
 
127
-	if ( 'Give_Tools_Reset_Stats' === $class && file_exists( $file_path ) ) {
127
+	if ('Give_Tools_Reset_Stats' === $class && file_exists($file_path)) {
128 128
 		require_once $file_path;
129 129
 	}
130 130
 
@@ -135,10 +135,10 @@  discard block
 block discarded – undo
135 135
  * @since  1.5
136 136
  */
137 137
 function give_register_batch_customer_recount_tool() {
138
-	add_action( 'give_batch_export_class_include', 'give_include_customer_recount_tool_batch_processor', 10, 1 );
138
+	add_action('give_batch_export_class_include', 'give_include_customer_recount_tool_batch_processor', 10, 1);
139 139
 }
140 140
 
141
-add_action( 'give_register_batch_exporter', 'give_register_batch_customer_recount_tool', 10 );
141
+add_action('give_register_batch_exporter', 'give_register_batch_customer_recount_tool', 10);
142 142
 
143 143
 /**
144 144
  * Loads the tools batch processing class for resetting all customer stats
@@ -149,11 +149,11 @@  discard block
 block discarded – undo
149 149
  *
150 150
  * @return void
151 151
  */
152
-function give_include_customer_recount_tool_batch_processor( $class ) {
152
+function give_include_customer_recount_tool_batch_processor($class) {
153 153
 
154
-	$file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-recount-customer-stats.php';
154
+	$file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-recount-customer-stats.php';
155 155
 
156
-	if ( 'Give_Tools_Recount_Customer_Stats' === $class && file_exists( $file_path ) ) {
156
+	if ('Give_Tools_Recount_Customer_Stats' === $class && file_exists($file_path)) {
157 157
 		require_once $file_path;
158 158
 	}
159 159
 
@@ -164,10 +164,10 @@  discard block
 block discarded – undo
164 164
  * @since  1.5
165 165
  */
166 166
 function give_register_batch_delete_test_transactions_tool() {
167
-	add_action( 'give_batch_export_class_include', 'give_include_delete_test_transactions_batch_processor', 10, 1 );
167
+	add_action('give_batch_export_class_include', 'give_include_delete_test_transactions_batch_processor', 10, 1);
168 168
 }
169 169
 
170
-add_action( 'give_register_batch_exporter', 'give_register_batch_delete_test_transactions_tool', 10 );
170
+add_action('give_register_batch_exporter', 'give_register_batch_delete_test_transactions_tool', 10);
171 171
 
172 172
 /**
173 173
  * Loads the tools batch processing class for resetting all customer stats
@@ -178,11 +178,11 @@  discard block
 block discarded – undo
178 178
  *
179 179
  * @return void
180 180
  */
181
-function give_include_delete_test_transactions_batch_processor( $class ) {
181
+function give_include_delete_test_transactions_batch_processor($class) {
182 182
 
183
-	$file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-delete-test-transactions.php';
183
+	$file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-delete-test-transactions.php';
184 184
 
185
-	if ( 'Give_Tools_Delete_Test_Transactions' === $class && file_exists( $file_path ) ) {
185
+	if ('Give_Tools_Delete_Test_Transactions' === $class && file_exists($file_path)) {
186 186
 		require_once $file_path;
187 187
 	}
188 188
 
Please login to merge, or discard this patch.
admin/reporting/tools/class-give-tools-delete-test-transactions.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
 	 * @since 1.5
51 51
 	 * @global object $wpdb Used to query the database using the WordPress
52 52
 	 *   Database API
53
-	 * @return array $data The data for the CSV file
53
+	 * @return boolean $data The data for the CSV file
54 54
 	 */
55 55
 	public function get_data() {
56 56
 		global $wpdb;
Please login to merge, or discard this patch.
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -55,22 +55,22 @@  discard block
 block discarded – undo
55 55
 	public function get_data() {
56 56
 		global $wpdb;
57 57
 
58
-		$items = $this->get_stored_data( 'give_temp_reset_ids' );
58
+		$items = $this->get_stored_data('give_temp_reset_ids');
59 59
 
60
-		if ( ! is_array( $items ) ) {
60
+		if ( ! is_array($items)) {
61 61
 			return false;
62 62
 		}
63 63
 
64
-		$offset     = ( $this->step - 1 ) * $this->per_step;
65
-		$step_items = array_slice( $items, $offset, $this->per_step );
64
+		$offset     = ($this->step - 1) * $this->per_step;
65
+		$step_items = array_slice($items, $offset, $this->per_step);
66 66
 
67
-		if ( $step_items ) {
67
+		if ($step_items) {
68 68
 
69 69
 			$step_ids = array(
70 70
 				'other' => array(),
71 71
 			);
72 72
 
73
-			foreach ( $step_items as $item ) {
73
+			foreach ($step_items as $item) {
74 74
 
75 75
 				$step_ids['other'][] = $item['id'];
76 76
 
@@ -78,15 +78,15 @@  discard block
 block discarded – undo
78 78
 
79 79
 			$sql = array();
80 80
 
81
-			foreach ( $step_ids as $type => $ids ) {
81
+			foreach ($step_ids as $type => $ids) {
82 82
 
83
-				if ( empty( $ids ) ) {
83
+				if (empty($ids)) {
84 84
 					continue;
85 85
 				}
86 86
 
87
-				$ids = implode( ',', $ids );
87
+				$ids = implode(',', $ids);
88 88
 
89
-				switch ( $type ) {
89
+				switch ($type) {
90 90
 					case 'other':
91 91
 						$sql[] = "DELETE FROM $wpdb->posts WHERE id IN ($ids)";
92 92
 						$sql[] = "DELETE FROM $wpdb->postmeta WHERE post_id IN ($ids)";
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
 
98 98
 			}
99 99
 
100
-			if ( ! empty( $sql ) ) {
101
-				foreach ( $sql as $query ) {
102
-					$wpdb->query( $query );
100
+			if ( ! empty($sql)) {
101
+				foreach ($sql as $query) {
102
+					$wpdb->query($query);
103 103
 				}
104 104
 			}
105 105
 
@@ -119,16 +119,16 @@  discard block
 block discarded – undo
119 119
 	 */
120 120
 	public function get_percentage_complete() {
121 121
 
122
-		$items = $this->get_stored_data( 'give_temp_reset_ids', false );
123
-		$total = count( $items );
122
+		$items = $this->get_stored_data('give_temp_reset_ids', false);
123
+		$total = count($items);
124 124
 
125 125
 		$percentage = 100;
126 126
 
127
-		if ( $total > 0 ) {
128
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
127
+		if ($total > 0) {
128
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
129 129
 		}
130 130
 
131
-		if ( $percentage > 100 ) {
131
+		if ($percentage > 100) {
132 132
 			$percentage = 100;
133 133
 		}
134 134
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	 *
143 143
 	 * @param array $request The Form Data passed into the batch processing
144 144
 	 */
145
-	public function set_properties( $request ) {
145
+	public function set_properties($request) {
146 146
 	}
147 147
 
148 148
 	/**
@@ -153,30 +153,30 @@  discard block
 block discarded – undo
153 153
 	 */
154 154
 	public function process_step() {
155 155
 
156
-		if ( ! $this->can_export() ) {
157
-			wp_die( esc_html__( 'You do not have permission to delete test transactions.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
156
+		if ( ! $this->can_export()) {
157
+			wp_die(esc_html__('You do not have permission to delete test transactions.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
158 158
 		}
159 159
 
160 160
 		$had_data = $this->get_data();
161 161
 
162
-		if ( $had_data ) {
162
+		if ($had_data) {
163 163
 			$this->done = false;
164 164
 
165 165
 			return true;
166 166
 		} else {
167
-			update_option( 'give_earnings_total', 0 );
168
-			delete_transient( 'give_earnings_total' );
169
-			delete_transient( 'give_estimated_monthly_stats' . true );
170
-			delete_transient( 'give_estimated_monthly_stats' . false );
171
-			$this->delete_data( 'give_temp_reset_ids' );
167
+			update_option('give_earnings_total', 0);
168
+			delete_transient('give_earnings_total');
169
+			delete_transient('give_estimated_monthly_stats'.true);
170
+			delete_transient('give_estimated_monthly_stats'.false);
171
+			$this->delete_data('give_temp_reset_ids');
172 172
 
173 173
 			// Reset the sequential order numbers
174
-			if ( give_get_option( 'enable_sequential' ) ) {
175
-				delete_option( 'give_last_payment_number' );
174
+			if (give_get_option('enable_sequential')) {
175
+				delete_option('give_last_payment_number');
176 176
 			}
177 177
 
178 178
 			$this->done    = true;
179
-			$this->message = esc_html__( 'Test transactions successfully deleted.', 'give' );
179
+			$this->message = esc_html__('Test transactions successfully deleted.', 'give');
180 180
 
181 181
 			return false;
182 182
 		}
@@ -186,10 +186,10 @@  discard block
 block discarded – undo
186 186
 	 * Headers
187 187
 	 */
188 188
 	public function headers() {
189
-		ignore_user_abort( true );
189
+		ignore_user_abort(true);
190 190
 
191
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
192
-			set_time_limit( 0 );
191
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
192
+			set_time_limit(0);
193 193
 		}
194 194
 	}
195 195
 
@@ -213,26 +213,26 @@  discard block
 block discarded – undo
213 213
 	 */
214 214
 	public function pre_fetch() {
215 215
 
216
-		if ( $this->step == 1 ) {
217
-			$this->delete_data( 'give_temp_reset_ids' );
216
+		if ($this->step == 1) {
217
+			$this->delete_data('give_temp_reset_ids');
218 218
 		}
219 219
 
220
-		$items = get_option( 'give_temp_reset_ids', false );
220
+		$items = get_option('give_temp_reset_ids', false);
221 221
 
222
-		if ( false === $items ) {
222
+		if (false === $items) {
223 223
 			$items = array();
224 224
 
225
-			$args = apply_filters( 'give_tools_reset_stats_total_args', array(
225
+			$args = apply_filters('give_tools_reset_stats_total_args', array(
226 226
 				'post_type'      => 'give_payment',
227 227
 				'post_status'    => 'any',
228
-				'posts_per_page' => - 1,
228
+				'posts_per_page' => -1,
229 229
 				//ONLY TEST MODE TRANSACTIONS!!!
230 230
 				'meta_key'   => '_give_payment_mode',
231 231
 				'meta_value' => 'test'
232
-			) );
232
+			));
233 233
 
234
-			$posts = get_posts( $args );
235
-			foreach ( $posts as $post ) {
234
+			$posts = get_posts($args);
235
+			foreach ($posts as $post) {
236 236
 				$items[] = array(
237 237
 					'id'   => (int) $post->ID,
238 238
 					'type' => $post->post_type,
@@ -241,9 +241,9 @@  discard block
 block discarded – undo
241 241
 
242 242
 			// Allow filtering of items to remove with an unassociative array for each item
243 243
 			// The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method
244
-			$items = apply_filters( 'give_reset_store_items', $items );
244
+			$items = apply_filters('give_reset_store_items', $items);
245 245
 
246
-			$this->store_data( 'give_temp_reset_ids', $items );
246
+			$this->store_data('give_temp_reset_ids', $items);
247 247
 		}
248 248
 
249 249
 	}
@@ -257,11 +257,11 @@  discard block
 block discarded – undo
257 257
 	 *
258 258
 	 * @return mixed       Returns the data from the database
259 259
 	 */
260
-	private function get_stored_data( $key ) {
260
+	private function get_stored_data($key) {
261 261
 		global $wpdb;
262
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
262
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
263 263
 
264
-		return empty( $value ) ? false : maybe_unserialize( $value );
264
+		return empty($value) ? false : maybe_unserialize($value);
265 265
 	}
266 266
 
267 267
 	/**
@@ -274,10 +274,10 @@  discard block
 block discarded – undo
274 274
 	 *
275 275
 	 * @return void
276 276
 	 */
277
-	private function store_data( $key, $value ) {
277
+	private function store_data($key, $value) {
278 278
 		global $wpdb;
279 279
 
280
-		$value = maybe_serialize( $value );
280
+		$value = maybe_serialize($value);
281 281
 
282 282
 		$data = array(
283 283
 			'option_name'  => $key,
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 			'%s',
292 292
 		);
293 293
 
294
-		$wpdb->replace( $wpdb->options, $data, $formats );
294
+		$wpdb->replace($wpdb->options, $data, $formats);
295 295
 	}
296 296
 
297 297
 	/**
@@ -303,9 +303,9 @@  discard block
 block discarded – undo
303 303
 	 *
304 304
 	 * @return void
305 305
 	 */
306
-	private function delete_data( $key ) {
306
+	private function delete_data($key) {
307 307
 		global $wpdb;
308
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
308
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
309 309
 	}
310 310
 
311 311
 }
Please login to merge, or discard this patch.
includes/admin/reporting/tools/class-give-tools-recount-all-stats.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
 	 * @since 1.5
51 51
 	 * @global object $wpdb Used to query the database using the WordPress
52 52
 	 *   Database API
53
-	 * @return array $data The data for the CSV file
53
+	 * @return boolean $data The data for the CSV file
54 54
 	 */
55 55
 	public function get_data() {
56 56
 		global $wpdb;
Please login to merge, or discard this patch.
Spacing   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -55,26 +55,26 @@  discard block
 block discarded – undo
55 55
 	public function get_data() {
56 56
 		global $give_logs, $wpdb;
57 57
 
58
-		$totals             = $this->get_stored_data( 'give_temp_recount_all_stats' );
59
-		$payment_items      = $this->get_stored_data( 'give_temp_payment_items' );
60
-		$processed_payments = $this->get_stored_data( 'give_temp_processed_payments' );
61
-		$accepted_statuses  = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
58
+		$totals             = $this->get_stored_data('give_temp_recount_all_stats');
59
+		$payment_items      = $this->get_stored_data('give_temp_payment_items');
60
+		$processed_payments = $this->get_stored_data('give_temp_processed_payments');
61
+		$accepted_statuses  = apply_filters('give_recount_accepted_statuses', array('publish'));
62 62
 
63
-		if ( false === $totals ) {
63
+		if (false === $totals) {
64 64
 			$totals = array();
65 65
 		}
66 66
 
67
-		if ( false === $payment_items ) {
67
+		if (false === $payment_items) {
68 68
 			$payment_items = array();
69 69
 		}
70 70
 
71
-		if ( false === $processed_payments ) {
71
+		if (false === $processed_payments) {
72 72
 			$processed_payments = array();
73 73
 		}
74 74
 
75
-		$all_forms = $this->get_stored_data( 'give_temp_form_ids' );
75
+		$all_forms = $this->get_stored_data('give_temp_form_ids');
76 76
 
77
-		$args = apply_filters( 'give_recount_form_stats_args', array(
77
+		$args = apply_filters('give_recount_form_stats_args', array(
78 78
 			'post_parent__in' => $all_forms,
79 79
 			'post_type'       => 'give_log',
80 80
 			'posts_per_page'  => $this->per_step,
@@ -82,73 +82,73 @@  discard block
 block discarded – undo
82 82
 			'paged'           => $this->step,
83 83
 			'log_type'        => 'sale',
84 84
 			'fields'          => 'ids',
85
-		) );
85
+		));
86 86
 
87
-		$log_ids = $give_logs->get_connected_logs( $args, 'sale' );
87
+		$log_ids = $give_logs->get_connected_logs($args, 'sale');
88 88
 
89
-		if ( $log_ids ) {
90
-			$log_ids = implode( ',', $log_ids );
89
+		if ($log_ids) {
90
+			$log_ids = implode(',', $log_ids);
91 91
 
92
-			$payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)" );
93
-			unset( $log_ids );
92
+			$payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)");
93
+			unset($log_ids);
94 94
 
95
-			$payment_ids = implode( ',', $payment_ids );
96
-			$payments    = $wpdb->get_results( "SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (" . $payment_ids . ")" );
97
-			unset( $payment_ids );
95
+			$payment_ids = implode(',', $payment_ids);
96
+			$payments    = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (".$payment_ids.")");
97
+			unset($payment_ids);
98 98
 
99 99
 			//Loop through payments
100
-			foreach ( $payments as $payment ) {
100
+			foreach ($payments as $payment) {
101 101
 
102 102
 				// Prevent payments that have all ready been retrieved from a previous sales log from counting again.
103
-				if ( in_array( $payment->ID, $processed_payments ) ) {
103
+				if (in_array($payment->ID, $processed_payments)) {
104 104
 					continue;
105 105
 				}
106 106
 
107 107
 				//Verify accepted status'
108
-				if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
108
+				if ( ! in_array($payment->post_status, $accepted_statuses)) {
109 109
 					$processed_payments[] = $payment->ID;
110 110
 					continue;
111 111
 				}
112 112
 
113
-				$payment_item = $payment_items[ $payment->ID ];
113
+				$payment_item = $payment_items[$payment->ID];
114 114
 
115 115
 
116
-				$form_id = isset( $payment_item['id'] ) ? $payment_item['id'] : '';
116
+				$form_id = isset($payment_item['id']) ? $payment_item['id'] : '';
117 117
 
118 118
 				//Must have a form ID
119
-				if ( empty( $form_id ) ) {
119
+				if (empty($form_id)) {
120 120
 					continue;
121 121
 				}
122 122
 
123 123
 				//Form ID must be within $all_forms array to be validated
124
-				if ( ! in_array( $form_id, $all_forms ) ) {
124
+				if ( ! in_array($form_id, $all_forms)) {
125 125
 					continue;
126 126
 				}
127 127
 
128 128
 				//If array key doesn't exist, create it
129
-				if ( ! array_key_exists( $form_id, $totals ) ) {
130
-					$totals[ $form_id ] = array(
129
+				if ( ! array_key_exists($form_id, $totals)) {
130
+					$totals[$form_id] = array(
131 131
 						'sales'    => (int) 0,
132 132
 						'earnings' => (float) 0,
133 133
 					);
134 134
 				}
135 135
 
136
-				$totals[ $form_id ]['sales'] ++;
137
-				$totals[ $form_id ]['earnings'] += $payment_item['price'];
136
+				$totals[$form_id]['sales']++;
137
+				$totals[$form_id]['earnings'] += $payment_item['price'];
138 138
 
139 139
 				$processed_payments[] = $payment->ID;
140 140
 
141 141
 			}
142 142
 
143
-			$this->store_data( 'give_temp_processed_payments', $processed_payments );
144
-			$this->store_data( 'give_temp_recount_all_stats', $totals );
143
+			$this->store_data('give_temp_processed_payments', $processed_payments);
144
+			$this->store_data('give_temp_recount_all_stats', $totals);
145 145
 
146 146
 			return true;
147 147
 		}
148 148
 
149
-		foreach ( $totals as $key => $stats ) {
150
-			update_post_meta( $key, '_give_form_sales', $stats['sales'] );
151
-			update_post_meta( $key, '_give_form_earnings', $stats['earnings'] );
149
+		foreach ($totals as $key => $stats) {
150
+			update_post_meta($key, '_give_form_sales', $stats['sales']);
151
+			update_post_meta($key, '_give_form_earnings', $stats['earnings']);
152 152
 		}
153 153
 
154 154
 		return false;
@@ -163,20 +163,20 @@  discard block
 block discarded – undo
163 163
 	 */
164 164
 	public function get_percentage_complete() {
165 165
 
166
-		$total = $this->get_stored_data( 'give_recount_all_total', false );
166
+		$total = $this->get_stored_data('give_recount_all_total', false);
167 167
 
168
-		if ( false === $total ) {
168
+		if (false === $total) {
169 169
 			$this->pre_fetch();
170
-			$total = $this->get_stored_data( 'give_recount_all_total', 0 );
170
+			$total = $this->get_stored_data('give_recount_all_total', 0);
171 171
 		}
172 172
 
173 173
 		$percentage = 100;
174 174
 
175
-		if ( $total > 0 ) {
176
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
175
+		if ($total > 0) {
176
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
177 177
 		}
178 178
 
179
-		if ( $percentage > 100 ) {
179
+		if ($percentage > 100) {
180 180
 			$percentage = 100;
181 181
 		}
182 182
 
@@ -190,8 +190,8 @@  discard block
 block discarded – undo
190 190
 	 *
191 191
 	 * @param array $request The Form Data passed into the batch processing
192 192
 	 */
193
-	public function set_properties( $request ) {
194
-		$this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false;
193
+	public function set_properties($request) {
194
+		$this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false;
195 195
 	}
196 196
 
197 197
 	/**
@@ -202,34 +202,34 @@  discard block
 block discarded – undo
202 202
 	 */
203 203
 	public function process_step() {
204 204
 
205
-		if ( ! $this->can_export() ) {
206
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
205
+		if ( ! $this->can_export()) {
206
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
207 207
 		}
208 208
 
209 209
 		$had_data = $this->get_data();
210 210
 
211
-		if ( $had_data ) {
211
+		if ($had_data) {
212 212
 			$this->done = false;
213 213
 
214 214
 			return true;
215 215
 		} else {
216
-			$this->delete_data( 'give_recount_all_total' );
217
-			$this->delete_data( 'give_temp_recount_all_stats' );
218
-			$this->delete_data( 'give_temp_payment_items' );
219
-			$this->delete_data( 'give_temp_form_ids' );
220
-			$this->delete_data( 'give_temp_processed_payments' );
216
+			$this->delete_data('give_recount_all_total');
217
+			$this->delete_data('give_temp_recount_all_stats');
218
+			$this->delete_data('give_temp_payment_items');
219
+			$this->delete_data('give_temp_form_ids');
220
+			$this->delete_data('give_temp_processed_payments');
221 221
 			$this->done    = true;
222
-			$this->message = esc_html__( 'Donation form income amounts and donation counts stats successfully recounted.', 'give' );
222
+			$this->message = esc_html__('Donation form income amounts and donation counts stats successfully recounted.', 'give');
223 223
 
224 224
 			return false;
225 225
 		}
226 226
 	}
227 227
 
228 228
 	public function headers() {
229
-		ignore_user_abort( true );
229
+		ignore_user_abort(true);
230 230
 
231
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
232
-			set_time_limit( 0 );
231
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
232
+			set_time_limit(0);
233 233
 		}
234 234
 	}
235 235
 
@@ -258,76 +258,76 @@  discard block
 block discarded – undo
258 258
 
259 259
 		global $give_logs, $wpdb;
260 260
 
261
-		if ( $this->step == 1 ) {
262
-			$this->delete_data( 'give_temp_recount_all_total' );
263
-			$this->delete_data( 'give_temp_recount_all_stats' );
264
-			$this->delete_data( 'give_temp_payment_items' );
265
-			$this->delete_data( 'give_temp_processed_payments' );
261
+		if ($this->step == 1) {
262
+			$this->delete_data('give_temp_recount_all_total');
263
+			$this->delete_data('give_temp_recount_all_stats');
264
+			$this->delete_data('give_temp_payment_items');
265
+			$this->delete_data('give_temp_processed_payments');
266 266
 		}
267 267
 
268
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
269
-		$total             = $this->get_stored_data( 'give_temp_recount_all_total' );
268
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
269
+		$total             = $this->get_stored_data('give_temp_recount_all_total');
270 270
 
271
-		if ( false === $total ) {
271
+		if (false === $total) {
272 272
 			$total         = 0;
273
-			$payment_items = $this->get_stored_data( 'give_temp_payment_items' );
273
+			$payment_items = $this->get_stored_data('give_temp_payment_items');
274 274
 
275
-			if ( false === $payment_items ) {
275
+			if (false === $payment_items) {
276 276
 				$payment_items = array();
277
-				$this->store_data( 'give_temp_payment_items', $payment_items );
277
+				$this->store_data('give_temp_payment_items', $payment_items);
278 278
 			}
279 279
 
280
-			$all_forms = $this->get_stored_data( 'give_temp_form_ids' );
280
+			$all_forms = $this->get_stored_data('give_temp_form_ids');
281 281
 
282
-			if ( false === $all_forms ) {
282
+			if (false === $all_forms) {
283 283
 				$args = array(
284 284
 					'post_status'    => 'any',
285 285
 					'post_type'      => 'give_forms',
286
-					'posts_per_page' => - 1,
286
+					'posts_per_page' => -1,
287 287
 					'fields'         => 'ids',
288 288
 				);
289 289
 
290
-				$all_forms = get_posts( $args );
291
-				$this->store_data( 'give_temp_form_ids', $all_forms );
290
+				$all_forms = get_posts($args);
291
+				$this->store_data('give_temp_form_ids', $all_forms);
292 292
 			}
293 293
 
294
-			$args = apply_filters( 'give_recount_form_stats_total_args', array(
294
+			$args = apply_filters('give_recount_form_stats_total_args', array(
295 295
 				'post_parent__in' => $all_forms,
296 296
 				'post_type'       => 'give_log',
297 297
 				'post_status'     => 'publish',
298 298
 				'log_type'        => 'sale',
299 299
 				'fields'          => 'ids',
300 300
 				'nopaging'        => true,
301
-			) );
301
+			));
302 302
 
303
-			$all_logs = $give_logs->get_connected_logs( $args, 'sale' );
303
+			$all_logs = $give_logs->get_connected_logs($args, 'sale');
304 304
 
305
-			if ( $all_logs ) {
306
-				$log_ids     = implode( ',', $all_logs );
307
-				$payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)" );
308
-				unset( $log_ids );
305
+			if ($all_logs) {
306
+				$log_ids     = implode(',', $all_logs);
307
+				$payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)");
308
+				unset($log_ids);
309 309
 
310
-				$payment_ids = implode( ',', $payment_ids );
311
-				$payments    = $wpdb->get_results( "SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (" . $payment_ids . ")" );
312
-				unset( $payment_ids );
310
+				$payment_ids = implode(',', $payment_ids);
311
+				$payments    = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (".$payment_ids.")");
312
+				unset($payment_ids);
313 313
 
314
-				foreach ( $payments as $payment ) {
314
+				foreach ($payments as $payment) {
315 315
 
316
-					$payment = new Give_Payment( $payment->ID );
316
+					$payment = new Give_Payment($payment->ID);
317 317
 					$form_id = $payment->form_id;
318 318
 
319 319
 					//If for some reason somehow the form_ID isn't set check payment meta
320
-					if ( empty( $payment->form_id ) ) {
320
+					if (empty($payment->form_id)) {
321 321
 						$payment_meta = $payment->get_meta();
322
-						$form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0;
322
+						$form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0;
323 323
 					}
324 324
 
325
-					if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
325
+					if ( ! in_array($payment->post_status, $accepted_statuses)) {
326 326
 						continue;
327 327
 					}
328 328
 
329
-					if ( ! array_key_exists( $payment->ID, $payment_items ) ) {
330
-						$payment_items[ $payment->ID ] = array(
329
+					if ( ! array_key_exists($payment->ID, $payment_items)) {
330
+						$payment_items[$payment->ID] = array(
331 331
 							'id'         => $form_id,
332 332
 							'payment_id' => $payment->ID,
333 333
 							'price'      => $payment->total
@@ -336,11 +336,11 @@  discard block
 block discarded – undo
336 336
 
337 337
 				}
338 338
 
339
-				$total = count( $all_logs );
339
+				$total = count($all_logs);
340 340
 			}
341 341
 
342
-			$this->store_data( 'give_temp_payment_items', $payment_items );
343
-			$this->store_data( 'give_recount_all_total', $total );
342
+			$this->store_data('give_temp_payment_items', $payment_items);
343
+			$this->store_data('give_recount_all_total', $total);
344 344
 		}
345 345
 
346 346
 	}
@@ -354,11 +354,11 @@  discard block
 block discarded – undo
354 354
 	 *
355 355
 	 * @return mixed       Returns the data from the database
356 356
 	 */
357
-	private function get_stored_data( $key ) {
357
+	private function get_stored_data($key) {
358 358
 		global $wpdb;
359
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
359
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
360 360
 
361
-		return empty( $value ) ? false : maybe_unserialize( $value );
361
+		return empty($value) ? false : maybe_unserialize($value);
362 362
 	}
363 363
 
364 364
 	/**
@@ -371,10 +371,10 @@  discard block
 block discarded – undo
371 371
 	 *
372 372
 	 * @return void
373 373
 	 */
374
-	private function store_data( $key, $value ) {
374
+	private function store_data($key, $value) {
375 375
 		global $wpdb;
376 376
 
377
-		$value = maybe_serialize( $value );
377
+		$value = maybe_serialize($value);
378 378
 
379 379
 		$data = array(
380 380
 			'option_name'  => $key,
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 			'%s',
389 389
 		);
390 390
 
391
-		$wpdb->replace( $wpdb->options, $data, $formats );
391
+		$wpdb->replace($wpdb->options, $data, $formats);
392 392
 	}
393 393
 
394 394
 	/**
@@ -400,9 +400,9 @@  discard block
 block discarded – undo
400 400
 	 *
401 401
 	 * @return void
402 402
 	 */
403
-	private function delete_data( $key ) {
403
+	private function delete_data($key) {
404 404
 		global $wpdb;
405
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
405
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
406 406
 	}
407 407
 
408 408
 }
Please login to merge, or discard this patch.
includes/admin/reporting/tools/class-give-tools-recount-customer-stats.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
 	 * @since 1.5
51 51
 	 * @global object $wpdb Used to query the database using the WordPress
52 52
 	 *   Database API
53
-	 * @return array $data The data for the CSV file
53
+	 * @return boolean $data The data for the CSV file
54 54
 	 */
55 55
 	public function get_data() {
56 56
 		global $wpdb;
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -56,32 +56,32 @@  discard block
 block discarded – undo
56 56
 
57 57
 		$args = array(
58 58
 			'number'  => $this->per_step,
59
-			'offset'  => $this->per_step * ( $this->step - 1 ),
59
+			'offset'  => $this->per_step * ($this->step - 1),
60 60
 			'orderby' => 'id',
61 61
 			'order'   => 'DESC',
62 62
 		);
63 63
 
64
-		$customers = Give()->customers->get_customers( $args );
64
+		$customers = Give()->customers->get_customers($args);
65 65
 
66
-		if ( $customers ) {
66
+		if ($customers) {
67 67
 
68
-			$allowed_payment_status = apply_filters( 'give_recount_donors_donation_statuses', give_get_payment_status_keys() );
68
+			$allowed_payment_status = apply_filters('give_recount_donors_donation_statuses', give_get_payment_status_keys());
69 69
 
70
-			foreach ( $customers as $customer ) {
70
+			foreach ($customers as $customer) {
71 71
 
72
-				$attached_payment_ids = explode( ',', $customer->payment_ids );
72
+				$attached_payment_ids = explode(',', $customer->payment_ids);
73 73
 
74 74
 				$attached_args = array(
75 75
 					'post__in' => $attached_payment_ids,
76
-					'number'   => - 1,
76
+					'number'   => -1,
77 77
 					'status'   => $allowed_payment_status,
78 78
 				);
79 79
 
80
-				$attached_payments = (array) give_get_payments( $attached_args );
80
+				$attached_payments = (array) give_get_payments($attached_args);
81 81
 
82 82
 				$unattached_args = array(
83 83
 					'post__not_in' => $attached_payment_ids,
84
-					'number'       => - 1,
84
+					'number'       => -1,
85 85
 					'status'       => $allowed_payment_status,
86 86
 					'meta_query'   => array(
87 87
 						array(
@@ -92,29 +92,29 @@  discard block
 block discarded – undo
92 92
 					),
93 93
 				);
94 94
 
95
-				$unattached_payments = give_get_payments( $unattached_args );
95
+				$unattached_payments = give_get_payments($unattached_args);
96 96
 
97
-				$payments = array_merge( $attached_payments, $unattached_payments );
97
+				$payments = array_merge($attached_payments, $unattached_payments);
98 98
 
99 99
 				$purchase_value = 0.00;
100 100
 				$purchase_count = 0;
101 101
 				$payment_ids    = array();
102 102
 
103
-				if ( $payments ) {
103
+				if ($payments) {
104 104
 
105
-					foreach ( $payments as $payment ) {
105
+					foreach ($payments as $payment) {
106 106
 
107 107
 						$should_process_payment = 'publish' == $payment->post_status ? true : false;
108
-						$should_process_payment = apply_filters( 'give_donor_recount_should_process_donation', $should_process_payment, $payment );
108
+						$should_process_payment = apply_filters('give_donor_recount_should_process_donation', $should_process_payment, $payment);
109 109
 
110
-						if ( true === $should_process_payment ) {
110
+						if (true === $should_process_payment) {
111 111
 
112
-							if ( apply_filters( 'give_customer_recount_should_increase_value', true, $payment ) ) {
113
-								$purchase_value += give_get_payment_amount( $payment->ID );
112
+							if (apply_filters('give_customer_recount_should_increase_value', true, $payment)) {
113
+								$purchase_value += give_get_payment_amount($payment->ID);
114 114
 							}
115 115
 
116
-							if ( apply_filters( 'give_customer_recount_should_increase_count', true, $payment ) ) {
117
-								$purchase_count ++;
116
+							if (apply_filters('give_customer_recount_should_increase_count', true, $payment)) {
117
+								$purchase_count++;
118 118
 							}
119 119
 
120 120
 						}
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 
125 125
 				}
126 126
 
127
-				$payment_ids = implode( ',', $payment_ids );
127
+				$payment_ids = implode(',', $payment_ids);
128 128
 
129 129
 				$customer_update_data = array(
130 130
 					'purchase_count' => $purchase_count,
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
 					'payment_ids'    => $payment_ids,
133 133
 				);
134 134
 
135
-				$customer_instance = new Give_Customer( $customer->id );
136
-				$customer_instance->update( $customer_update_data );
135
+				$customer_instance = new Give_Customer($customer->id);
136
+				$customer_instance->update($customer_update_data);
137 137
 
138 138
 			}
139 139
 
@@ -153,21 +153,21 @@  discard block
 block discarded – undo
153 153
 	public function get_percentage_complete() {
154 154
 
155 155
 		$args = array(
156
-			'number'  => - 1,
156
+			'number'  => -1,
157 157
 			'orderby' => 'id',
158 158
 			'order'   => 'DESC',
159 159
 		);
160 160
 
161
-		$customers = Give()->customers->get_customers( $args );
162
-		$total     = count( $customers );
161
+		$customers = Give()->customers->get_customers($args);
162
+		$total     = count($customers);
163 163
 
164 164
 		$percentage = 100;
165 165
 
166
-		if ( $total > 0 ) {
167
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
166
+		if ($total > 0) {
167
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
168 168
 		}
169 169
 
170
-		if ( $percentage > 100 ) {
170
+		if ($percentage > 100) {
171 171
 			$percentage = 100;
172 172
 		}
173 173
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	 *
182 182
 	 * @param array $request The Form Data passed into the batch processing
183 183
 	 */
184
-	public function set_properties( $request ) {
184
+	public function set_properties($request) {
185 185
 	}
186 186
 
187 187
 	/**
@@ -192,19 +192,19 @@  discard block
 block discarded – undo
192 192
 	 */
193 193
 	public function process_step() {
194 194
 
195
-		if ( ! $this->can_export() ) {
196
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
195
+		if ( ! $this->can_export()) {
196
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
197 197
 		}
198 198
 
199 199
 		$had_data = $this->get_data();
200 200
 
201
-		if ( $had_data ) {
201
+		if ($had_data) {
202 202
 			$this->done = false;
203 203
 
204 204
 			return true;
205 205
 		} else {
206 206
 			$this->done    = true;
207
-			$this->message = esc_html__( 'Donor stats have been successfully recounted.', 'give' );
207
+			$this->message = esc_html__('Donor stats have been successfully recounted.', 'give');
208 208
 
209 209
 			return false;
210 210
 		}
@@ -214,10 +214,10 @@  discard block
 block discarded – undo
214 214
 	 * Headers
215 215
 	 */
216 216
 	public function headers() {
217
-		ignore_user_abort( true );
217
+		ignore_user_abort(true);
218 218
 
219
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
220
-			set_time_limit( 0 );
219
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
220
+			set_time_limit(0);
221 221
 		}
222 222
 	}
223 223
 
Please login to merge, or discard this patch.
includes/admin/reporting/tools/class-give-tools-recount-form-stats.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
 	 * @since 1.5
51 51
 	 * @global object $wpdb Used to query the database using the WordPress
52 52
 	 *   Database API
53
-	 * @return array $data The data for the CSV file
53
+	 * @return boolean $data The data for the CSV file
54 54
 	 */
55 55
 	public function get_data() {
56 56
 		global $wpdb;
Please login to merge, or discard this patch.
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -62,23 +62,23 @@  discard block
 block discarded – undo
62 62
 	public function get_data() {
63 63
 		global $give_logs, $wpdb;
64 64
 
65
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
65
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
66 66
 
67
-		if ( $this->step == 1 ) {
68
-			$this->delete_data( 'give_temp_recount_form_stats' );
67
+		if ($this->step == 1) {
68
+			$this->delete_data('give_temp_recount_form_stats');
69 69
 		}
70 70
 
71
-		$totals = $this->get_stored_data( 'give_temp_recount_form_stats' );
71
+		$totals = $this->get_stored_data('give_temp_recount_form_stats');
72 72
 
73
-		if ( false === $totals ) {
73
+		if (false === $totals) {
74 74
 			$totals = array(
75 75
 				'earnings' => (float) 0,
76 76
 				'sales'    => 0,
77 77
 			);
78
-			$this->store_data( 'give_temp_recount_form_stats', $totals );
78
+			$this->store_data('give_temp_recount_form_stats', $totals);
79 79
 		}
80 80
 
81
-		$args = apply_filters( 'give_recount_form_stats_args', array(
81
+		$args = apply_filters('give_recount_form_stats_args', array(
82 82
 			'post_parent'    => $this->form_id,
83 83
 			'post_type'      => 'give_log',
84 84
 			'posts_per_page' => $this->per_step,
@@ -86,49 +86,49 @@  discard block
 block discarded – undo
86 86
 			'paged'          => $this->step,
87 87
 			'log_type'       => 'sale',
88 88
 			'fields'         => 'ids',
89
-		) );
89
+		));
90 90
 
91
-		$log_ids              = $give_logs->get_connected_logs( $args, 'sale' );
91
+		$log_ids              = $give_logs->get_connected_logs($args, 'sale');
92 92
 		$this->_log_ids_debug = array();
93 93
 
94
-		if ( $log_ids ) {
95
-			$log_ids     = implode( ',', $log_ids );
96
-			$payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)" );
97
-			unset( $log_ids );
94
+		if ($log_ids) {
95
+			$log_ids     = implode(',', $log_ids);
96
+			$payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)");
97
+			unset($log_ids);
98 98
 
99
-			$payment_ids = implode( ',', $payment_ids );
100
-			$payments    = $wpdb->get_results( "SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (" . $payment_ids . ")" );
101
-			unset( $payment_ids );
99
+			$payment_ids = implode(',', $payment_ids);
100
+			$payments    = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (".$payment_ids.")");
101
+			unset($payment_ids);
102 102
 
103
-			foreach ( $payments as $payment ) {
103
+			foreach ($payments as $payment) {
104 104
 
105
-				$payment = new Give_Payment( $payment->ID );
105
+				$payment = new Give_Payment($payment->ID);
106 106
 
107 107
 				//Ensure acceptible status only
108
-				if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
108
+				if ( ! in_array($payment->post_status, $accepted_statuses)) {
109 109
 					continue;
110 110
 				}
111 111
 
112 112
 				//Ensure only payments for this form are counted
113
-				if ( $payment->form_id != $this->form_id ) {
113
+				if ($payment->form_id != $this->form_id) {
114 114
 					continue;
115 115
 				}
116 116
 
117 117
 				$this->_log_ids_debug[] = $payment->ID;
118 118
 
119
-				$totals['sales'] ++;
119
+				$totals['sales']++;
120 120
 				$totals['earnings'] += $payment->total;
121 121
 
122 122
 			}
123 123
 
124
-			$this->store_data( 'give_temp_recount_form_stats', $totals );
124
+			$this->store_data('give_temp_recount_form_stats', $totals);
125 125
 
126 126
 			return true;
127 127
 		}
128 128
 
129 129
 
130
-		update_post_meta( $this->form_id, '_give_form_sales', $totals['sales'] );
131
-		update_post_meta( $this->form_id, '_give_form_earnings', $totals['earnings'] );
130
+		update_post_meta($this->form_id, '_give_form_sales', $totals['sales']);
131
+		update_post_meta($this->form_id, '_give_form_earnings', $totals['earnings']);
132 132
 
133 133
 		return false;
134 134
 
@@ -143,54 +143,54 @@  discard block
 block discarded – undo
143 143
 	public function get_percentage_complete() {
144 144
 		global $give_logs, $wpdb;
145 145
 
146
-		if ( $this->step == 1 ) {
147
-			$this->delete_data( 'give_recount_total_' . $this->form_id );
146
+		if ($this->step == 1) {
147
+			$this->delete_data('give_recount_total_'.$this->form_id);
148 148
 		}
149 149
 
150
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
151
-		$total             = $this->get_stored_data( 'give_recount_total_' . $this->form_id );
150
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
151
+		$total             = $this->get_stored_data('give_recount_total_'.$this->form_id);
152 152
 
153
-		if ( false === $total ) {
153
+		if (false === $total) {
154 154
 			$total = 0;
155
-			$args  = apply_filters( 'give_recount_form_stats_total_args', array(
155
+			$args  = apply_filters('give_recount_form_stats_total_args', array(
156 156
 				'post_parent' => $this->form_id,
157 157
 				'post_type'   => 'give_log',
158 158
 				'post_status' => 'publish',
159 159
 				'log_type'    => 'sale',
160 160
 				'fields'      => 'ids',
161 161
 				'nopaging'    => true,
162
-			) );
162
+			));
163 163
 
164
-			$log_ids = $give_logs->get_connected_logs( $args, 'sale' );
164
+			$log_ids = $give_logs->get_connected_logs($args, 'sale');
165 165
 
166
-			if ( $log_ids ) {
167
-				$log_ids     = implode( ',', $log_ids );
168
-				$payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)" );
169
-				unset( $log_ids );
166
+			if ($log_ids) {
167
+				$log_ids     = implode(',', $log_ids);
168
+				$payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)");
169
+				unset($log_ids);
170 170
 
171
-				$payment_ids = implode( ',', $payment_ids );
172
-				$payments    = $wpdb->get_results( "SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (" . $payment_ids . ")" );
173
-				unset( $payment_ids );
171
+				$payment_ids = implode(',', $payment_ids);
172
+				$payments    = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (".$payment_ids.")");
173
+				unset($payment_ids);
174 174
 
175
-				foreach ( $payments as $payment ) {
176
-					if ( in_array( $payment->post_status, $accepted_statuses ) ) {
175
+				foreach ($payments as $payment) {
176
+					if (in_array($payment->post_status, $accepted_statuses)) {
177 177
 						continue;
178 178
 					}
179 179
 
180
-					$total ++;
180
+					$total++;
181 181
 				}
182 182
 			}
183 183
 
184
-			$this->store_data( 'give_recount_total_' . $this->form_id, $total );
184
+			$this->store_data('give_recount_total_'.$this->form_id, $total);
185 185
 		}
186 186
 
187 187
 		$percentage = 100;
188 188
 
189
-		if ( $total > 0 ) {
190
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
189
+		if ($total > 0) {
190
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
191 191
 		}
192 192
 
193
-		if ( $percentage > 100 ) {
193
+		if ($percentage > 100) {
194 194
 			$percentage = 100;
195 195
 		}
196 196
 
@@ -204,8 +204,8 @@  discard block
 block discarded – undo
204 204
 	 *
205 205
 	 * @param array $request The Form Data passed into the batch processing
206 206
 	 */
207
-	public function set_properties( $request ) {
208
-		$this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false;
207
+	public function set_properties($request) {
208
+		$this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false;
209 209
 	}
210 210
 
211 211
 	/**
@@ -216,31 +216,31 @@  discard block
 block discarded – undo
216 216
 	 */
217 217
 	public function process_step() {
218 218
 
219
-		if ( ! $this->can_export() ) {
220
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
219
+		if ( ! $this->can_export()) {
220
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
221 221
 		}
222 222
 
223 223
 		$had_data = $this->get_data();
224 224
 
225
-		if ( $had_data ) {
225
+		if ($had_data) {
226 226
 			$this->done = false;
227 227
 
228 228
 			return true;
229 229
 		} else {
230
-			$this->delete_data( 'give_recount_total_' . $this->form_id );
231
-			$this->delete_data( 'give_temp_recount_form_stats' );
230
+			$this->delete_data('give_recount_total_'.$this->form_id);
231
+			$this->delete_data('give_temp_recount_form_stats');
232 232
 			$this->done    = true;
233
-			$this->message = sprintf( esc_html__( 'Donation counts and income amount statistics successfully recounted for "%s".', 'give' ), get_the_title( $this->form_id ) );
233
+			$this->message = sprintf(esc_html__('Donation counts and income amount statistics successfully recounted for "%s".', 'give'), get_the_title($this->form_id));
234 234
 
235 235
 			return false;
236 236
 		}
237 237
 	}
238 238
 
239 239
 	public function headers() {
240
-		ignore_user_abort( true );
240
+		ignore_user_abort(true);
241 241
 
242
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
243
-			set_time_limit( 0 );
242
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
243
+			set_time_limit(0);
244 244
 		}
245 245
 	}
246 246
 
@@ -268,11 +268,11 @@  discard block
 block discarded – undo
268 268
 	 *
269 269
 	 * @return mixed       Returns the data from the database
270 270
 	 */
271
-	private function get_stored_data( $key ) {
271
+	private function get_stored_data($key) {
272 272
 		global $wpdb;
273
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
273
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
274 274
 
275
-		return empty( $value ) ? false : maybe_unserialize( $value );
275
+		return empty($value) ? false : maybe_unserialize($value);
276 276
 	}
277 277
 
278 278
 	/**
@@ -285,10 +285,10 @@  discard block
 block discarded – undo
285 285
 	 *
286 286
 	 * @return void
287 287
 	 */
288
-	private function store_data( $key, $value ) {
288
+	private function store_data($key, $value) {
289 289
 		global $wpdb;
290 290
 
291
-		$value = maybe_serialize( $value );
291
+		$value = maybe_serialize($value);
292 292
 
293 293
 		$data = array(
294 294
 			'option_name'  => $key,
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 			'%s',
303 303
 		);
304 304
 
305
-		$wpdb->replace( $wpdb->options, $data, $formats );
305
+		$wpdb->replace($wpdb->options, $data, $formats);
306 306
 	}
307 307
 
308 308
 	/**
@@ -314,9 +314,9 @@  discard block
 block discarded – undo
314 314
 	 *
315 315
 	 * @return void
316 316
 	 */
317
-	private function delete_data( $key ) {
317
+	private function delete_data($key) {
318 318
 		global $wpdb;
319
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
319
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
320 320
 	}
321 321
 
322 322
 }
Please login to merge, or discard this patch.
includes/admin/reporting/tools/class-give-tools-recount-income.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
 	 * @since 1.5
51 51
 	 * @global object $wpdb Used to query the database using the WordPress
52 52
 	 *   Database API
53
-	 * @return array $data The data for the CSV file
53
+	 * @return boolean $data The data for the CSV file
54 54
 	 */
55 55
 	public function get_data() {
56 56
 		global $wpdb;
Please login to merge, or discard this patch.
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -54,50 +54,50 @@  discard block
 block discarded – undo
54 54
 	 */
55 55
 	public function get_data() {
56 56
 
57
-		if ( $this->step == 1 ) {
58
-			$this->delete_data( 'give_temp_recount_income' );
57
+		if ($this->step == 1) {
58
+			$this->delete_data('give_temp_recount_income');
59 59
 		}
60 60
 
61
-		$total = get_option( 'give_temp_recount_income', false );
61
+		$total = get_option('give_temp_recount_income', false);
62 62
 
63
-		if ( false === $total ) {
63
+		if (false === $total) {
64 64
 			$total = (float) 0;
65
-			$this->store_data( 'give_temp_recount_income', $total );
65
+			$this->store_data('give_temp_recount_income', $total);
66 66
 		}
67 67
 
68
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
68
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
69 69
 
70
-		$args = apply_filters( 'give_recount_income_args', array(
70
+		$args = apply_filters('give_recount_income_args', array(
71 71
 			'number' => $this->per_step,
72 72
 			'page'   => $this->step,
73 73
 			'status' => $accepted_statuses,
74 74
 			'fields' => 'ids'
75
-		) );
75
+		));
76 76
 
77
-		$payments = give_get_payments( $args );
77
+		$payments = give_get_payments($args);
78 78
 
79
-		if ( ! empty( $payments ) ) {
79
+		if ( ! empty($payments)) {
80 80
 
81
-			foreach ( $payments as $payment ) {
81
+			foreach ($payments as $payment) {
82 82
 
83
-				$total += give_get_payment_amount( $payment );
83
+				$total += give_get_payment_amount($payment);
84 84
 
85 85
 			}
86 86
 
87
-			if ( $total < 0 ) {
87
+			if ($total < 0) {
88 88
 				$totals = 0;
89 89
 			}
90 90
 
91
-			$total = round( $total, give_currency_decimal_filter() );
91
+			$total = round($total, give_currency_decimal_filter());
92 92
 
93
-			$this->store_data( 'give_temp_recount_income', $total );
93
+			$this->store_data('give_temp_recount_income', $total);
94 94
 
95 95
 			return true;
96 96
 
97 97
 		}
98 98
 
99
-		update_option( 'give_income_total', $total );
100
-		set_transient( 'give_income_total', $total, 86400 );
99
+		update_option('give_income_total', $total);
100
+		set_transient('give_income_total', $total, 86400);
101 101
 
102 102
 		return false;
103 103
 
@@ -111,25 +111,25 @@  discard block
 block discarded – undo
111 111
 	 */
112 112
 	public function get_percentage_complete() {
113 113
 
114
-		$total = $this->get_stored_data( 'give_recount_income_total' );
114
+		$total = $this->get_stored_data('give_recount_income_total');
115 115
 
116
-		if ( false === $total ) {
117
-			$args = apply_filters( 'give_recount_income_total_args', array() );
116
+		if (false === $total) {
117
+			$args = apply_filters('give_recount_income_total_args', array());
118 118
 
119
-			$counts = give_count_payments( $args );
120
-			$total  = absint( $counts->publish );
121
-			$total  = apply_filters( 'give_recount_store_income_total', $total );
119
+			$counts = give_count_payments($args);
120
+			$total  = absint($counts->publish);
121
+			$total  = apply_filters('give_recount_store_income_total', $total);
122 122
 
123
-			$this->store_data( 'give_recount_income_total', $total );
123
+			$this->store_data('give_recount_income_total', $total);
124 124
 		}
125 125
 
126 126
 		$percentage = 100;
127 127
 
128
-		if ( $total > 0 ) {
129
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
128
+		if ($total > 0) {
129
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
130 130
 		}
131 131
 
132
-		if ( $percentage > 100 ) {
132
+		if ($percentage > 100) {
133 133
 			$percentage = 100;
134 134
 		}
135 135
 
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	 *
144 144
 	 * @param array $request The Form Data passed into the batch processing
145 145
 	 */
146
-	public function set_properties( $request ) {
146
+	public function set_properties($request) {
147 147
 	}
148 148
 
149 149
 	/**
@@ -154,31 +154,31 @@  discard block
 block discarded – undo
154 154
 	 */
155 155
 	public function process_step() {
156 156
 
157
-		if ( ! $this->can_export() ) {
158
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
157
+		if ( ! $this->can_export()) {
158
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
159 159
 		}
160 160
 
161 161
 		$had_data = $this->get_data();
162 162
 
163
-		if ( $had_data ) {
163
+		if ($had_data) {
164 164
 			$this->done = false;
165 165
 
166 166
 			return true;
167 167
 		} else {
168
-			$this->delete_data( 'give_recount_income_total' );
169
-			$this->delete_data( 'give_temp_recount_income' );
168
+			$this->delete_data('give_recount_income_total');
169
+			$this->delete_data('give_temp_recount_income');
170 170
 			$this->done    = true;
171
-			$this->message = esc_html__( 'Income stats have been successfully recounted.', 'give' );
171
+			$this->message = esc_html__('Income stats have been successfully recounted.', 'give');
172 172
 
173 173
 			return false;
174 174
 		}
175 175
 	}
176 176
 
177 177
 	public function headers() {
178
-		ignore_user_abort( true );
178
+		ignore_user_abort(true);
179 179
 
180
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
181
-			set_time_limit( 0 );
180
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
181
+			set_time_limit(0);
182 182
 		}
183 183
 	}
184 184
 
@@ -206,11 +206,11 @@  discard block
 block discarded – undo
206 206
 	 *
207 207
 	 * @return mixed       Returns the data from the database
208 208
 	 */
209
-	private function get_stored_data( $key ) {
209
+	private function get_stored_data($key) {
210 210
 		global $wpdb;
211
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
211
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
212 212
 
213
-		return empty( $value ) ? false : maybe_unserialize( $value );
213
+		return empty($value) ? false : maybe_unserialize($value);
214 214
 	}
215 215
 
216 216
 	/**
@@ -223,10 +223,10 @@  discard block
 block discarded – undo
223 223
 	 *
224 224
 	 * @return void
225 225
 	 */
226
-	private function store_data( $key, $value ) {
226
+	private function store_data($key, $value) {
227 227
 		global $wpdb;
228 228
 
229
-		$value = maybe_serialize( $value );
229
+		$value = maybe_serialize($value);
230 230
 
231 231
 		$data = array(
232 232
 			'option_name'  => $key,
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 			'%s',
241 241
 		);
242 242
 
243
-		$wpdb->replace( $wpdb->options, $data, $formats );
243
+		$wpdb->replace($wpdb->options, $data, $formats);
244 244
 	}
245 245
 
246 246
 	/**
@@ -252,9 +252,9 @@  discard block
 block discarded – undo
252 252
 	 *
253 253
 	 * @return void
254 254
 	 */
255
-	private function delete_data( $key ) {
255
+	private function delete_data($key) {
256 256
 		global $wpdb;
257
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
257
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
258 258
 	}
259 259
 
260 260
 }
Please login to merge, or discard this patch.
includes/admin/reporting/export/class-batch-export-customers.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -206,6 +206,7 @@
 block discarded – undo
206 206
 	 * Set Donor Data
207 207
 	 *
208 208
 	 * @param $donor
209
+	 * @param integer $i
209 210
 	 */
210 211
 	private function set_donor_data( $i, $data, $donor ) {
211 212
 
Please login to merge, or discard this patch.
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -46,16 +46,16 @@  discard block
 block discarded – undo
46 46
 	 *
47 47
 	 * @param array $request The Form Data passed into the batch processing
48 48
 	 */
49
-	public function set_properties( $request ) {
49
+	public function set_properties($request) {
50 50
 
51 51
 		//Set data from form submission
52
-		if ( isset( $_POST['form'] ) ) {
53
-			parse_str( $_POST['form'], $this->data );
52
+		if (isset($_POST['form'])) {
53
+			parse_str($_POST['form'], $this->data);
54 54
 		}
55 55
 
56 56
 		$this->form = $this->data['forms'];
57 57
 
58
-		$this->price_id = ! empty( $request['give_price_option'] ) && 0 !== $request['give_price_option'] ? absint( $request['give_price_option'] ) : null;
58
+		$this->price_id = ! empty($request['give_price_option']) && 0 !== $request['give_price_option'] ? absint($request['give_price_option']) : null;
59 59
 
60 60
 	}
61 61
 
@@ -70,14 +70,14 @@  discard block
 block discarded – undo
70 70
 
71 71
 		$cols = array();
72 72
 
73
-		$columns = isset( $this->data['give_export_option'] ) ? $this->data['give_export_option'] : array();
73
+		$columns = isset($this->data['give_export_option']) ? $this->data['give_export_option'] : array();
74 74
 
75 75
 		//We need columns.
76
-		if ( empty( $columns ) ) {
76
+		if (empty($columns)) {
77 77
 			return false;
78 78
 		}
79 79
 
80
-		$cols = $this->get_cols( $columns );
80
+		$cols = $this->get_cols($columns);
81 81
 
82 82
 		return $cols;
83 83
 	}
@@ -85,38 +85,38 @@  discard block
 block discarded – undo
85 85
 	/**
86 86
 	 * @param $column
87 87
 	 */
88
-	private function get_cols( $columns ) {
88
+	private function get_cols($columns) {
89 89
 
90 90
 		$cols = array();
91 91
 
92
-		foreach ( $columns as $key => $value ) {
92
+		foreach ($columns as $key => $value) {
93 93
 
94
-			switch ( $key ) {
94
+			switch ($key) {
95 95
 				case 'full_name' :
96
-					$cols['full_name'] = esc_html__( 'Full Name', 'give' );
96
+					$cols['full_name'] = esc_html__('Full Name', 'give');
97 97
 					break;
98 98
 				case 'email' :
99
-					$cols['email'] = esc_html__( 'Email Address', 'give' );
99
+					$cols['email'] = esc_html__('Email Address', 'give');
100 100
 					break;
101 101
 				case 'address' :
102
-					$cols['address_line1']   = esc_html__( 'Address', 'give' );
103
-					$cols['address_line2']   = esc_html__( 'Address 2', 'give' );
104
-					$cols['address_city']    = esc_html__( 'City', 'give' );
105
-					$cols['address_state']   = esc_html__( 'State', 'give' );
106
-					$cols['address_zip']     = esc_html__( 'Zip', 'give' );
107
-					$cols['address_country'] = esc_html__( 'Country', 'give' );
102
+					$cols['address_line1']   = esc_html__('Address', 'give');
103
+					$cols['address_line2']   = esc_html__('Address 2', 'give');
104
+					$cols['address_city']    = esc_html__('City', 'give');
105
+					$cols['address_state']   = esc_html__('State', 'give');
106
+					$cols['address_zip']     = esc_html__('Zip', 'give');
107
+					$cols['address_country'] = esc_html__('Country', 'give');
108 108
 					break;
109 109
 				case 'userid' :
110
-					$cols['userid'] = esc_html__( 'User ID', 'give' );
110
+					$cols['userid'] = esc_html__('User ID', 'give');
111 111
 					break;
112 112
 				case 'date_first_donated' :
113
-					$cols['date_first_donated'] = esc_html__( 'First Donation Date', 'give' );
113
+					$cols['date_first_donated'] = esc_html__('First Donation Date', 'give');
114 114
 					break;
115 115
 				case 'donations' :
116
-					$cols['donations'] = esc_html__( 'Number of Donations', 'give' );
116
+					$cols['donations'] = esc_html__('Number of Donations', 'give');
117 117
 					break;
118 118
 				case 'donation_sum' :
119
-					$cols['donation_sum'] = esc_html__( 'Sum of Donations', 'give' );
119
+					$cols['donation_sum'] = esc_html__('Sum of Donations', 'give');
120 120
 					break;
121 121
 			}
122 122
 		}
@@ -139,20 +139,20 @@  discard block
 block discarded – undo
139 139
 
140 140
 		$i = 0;
141 141
 
142
-		if ( ! empty( $this->form ) ) {
142
+		if ( ! empty($this->form)) {
143 143
 
144 144
 			// Export donors of a specific product
145 145
 			global $give_logs;
146 146
 
147 147
 			$args = array(
148
-				'post_parent'    => absint( $this->form ),
148
+				'post_parent'    => absint($this->form),
149 149
 				'log_type'       => 'sale',
150 150
 				'posts_per_page' => 30,
151 151
 				'paged'          => $this->step
152 152
 			);
153 153
 
154 154
 			//Check for price option
155
-			if ( null !== $this->price_id ) {
155
+			if (null !== $this->price_id) {
156 156
 				$args['meta_query'] = array(
157 157
 					array(
158 158
 						'key'   => '_give_log_price_id',
@@ -161,33 +161,33 @@  discard block
 block discarded – undo
161 161
 				);
162 162
 			}
163 163
 
164
-			$logs = $give_logs->get_connected_logs( $args );
164
+			$logs = $give_logs->get_connected_logs($args);
165 165
 
166
-			if ( $logs ) {
167
-				foreach ( $logs as $log ) {
168
-					$payment_id = get_post_meta( $log->ID, '_give_log_payment_id', true );
169
-					$payment    = new Give_Payment( $payment_id );
170
-					$donor      = Give()->customers->get_customer_by( 'id', $payment->customer_id );
171
-					$data[]     = $this->set_donor_data( $i, $data, $donor );
172
-					$i ++;
166
+			if ($logs) {
167
+				foreach ($logs as $log) {
168
+					$payment_id = get_post_meta($log->ID, '_give_log_payment_id', true);
169
+					$payment    = new Give_Payment($payment_id);
170
+					$donor      = Give()->customers->get_customer_by('id', $payment->customer_id);
171
+					$data[]     = $this->set_donor_data($i, $data, $donor);
172
+					$i++;
173 173
 				}
174 174
 			}
175 175
 
176 176
 		} else {
177 177
 
178 178
 			// Export all customers
179
-			$offset = 30 * ( $this->step - 1 );
180
-			$donors = Give()->customers->get_customers( array( 'number' => 30, 'offset' => $offset ) );
179
+			$offset = 30 * ($this->step - 1);
180
+			$donors = Give()->customers->get_customers(array('number' => 30, 'offset' => $offset));
181 181
 
182
-			foreach ( $donors as $donor ) {
182
+			foreach ($donors as $donor) {
183 183
 
184
-				$data[] = $this->set_donor_data( $i, $data, $donor );
185
-				$i ++;
184
+				$data[] = $this->set_donor_data($i, $data, $donor);
185
+				$i++;
186 186
 			}
187 187
 		}
188 188
 
189
-		$data = apply_filters( 'give_export_get_data', $data );
190
-		$data = apply_filters( "give_export_get_data_{$this->export_type}", $data );
189
+		$data = apply_filters('give_export_get_data', $data);
190
+		$data = apply_filters("give_export_get_data_{$this->export_type}", $data);
191 191
 
192 192
 		return $data;
193 193
 	}
@@ -203,19 +203,19 @@  discard block
 block discarded – undo
203 203
 		$percentage = 0;
204 204
 
205 205
 		// We can't count the number when getting them for a specific form
206
-		if ( empty( $this->form ) ) {
206
+		if (empty($this->form)) {
207 207
 
208 208
 			$total = Give()->customers->count();
209 209
 
210
-			if ( $total > 0 ) {
210
+			if ($total > 0) {
211 211
 
212
-				$percentage = ( ( 30 * $this->step ) / $total ) * 100;
212
+				$percentage = ((30 * $this->step) / $total) * 100;
213 213
 
214 214
 			}
215 215
 
216 216
 		}
217 217
 
218
-		if ( $percentage > 100 ) {
218
+		if ($percentage > 100) {
219 219
 			$percentage = 100;
220 220
 		}
221 221
 
@@ -227,46 +227,46 @@  discard block
 block discarded – undo
227 227
 	 *
228 228
 	 * @param $donor
229 229
 	 */
230
-	private function set_donor_data( $i, $data, $donor ) {
230
+	private function set_donor_data($i, $data, $donor) {
231 231
 
232 232
 		$columns = $this->csv_cols();
233 233
 
234 234
 		//Set address variable
235 235
 		$address = '';
236
-		if ( isset( $donor->user_id ) && $donor->user_id > 0 ) {
237
-			$address = give_get_donor_address( $donor->user_id );
236
+		if (isset($donor->user_id) && $donor->user_id > 0) {
237
+			$address = give_get_donor_address($donor->user_id);
238 238
 		}
239 239
 
240 240
 		//Set columns
241
-		if ( ! empty( $columns['full_name'] ) ) {
242
-			$data[ $i ]['full_name'] = $donor->name;
241
+		if ( ! empty($columns['full_name'])) {
242
+			$data[$i]['full_name'] = $donor->name;
243 243
 		}
244
-		if ( ! empty( $columns['email'] ) ) {
245
-			$data[ $i ]['email'] = $donor->email;
244
+		if ( ! empty($columns['email'])) {
245
+			$data[$i]['email'] = $donor->email;
246 246
 		}
247
-		if ( ! empty( $columns['address_line1'] ) ) {
248
-
249
-			$data[ $i ]['address_line1']   = isset( $address['line1'] ) ? $address['line1'] : '';
250
-			$data[ $i ]['address_line2']   = isset( $address['line2'] ) ? $address['line2'] : '';
251
-			$data[ $i ]['address_city']    = isset( $address['city'] ) ? $address['city'] : '';
252
-			$data[ $i ]['address_state']   = isset( $address['state'] ) ? $address['state'] : '';
253
-			$data[ $i ]['address_zip']     = isset( $address['zip'] ) ? $address['zip'] : '';
254
-			$data[ $i ]['address_country'] = isset( $address['country'] ) ? $address['country'] : '';
247
+		if ( ! empty($columns['address_line1'])) {
248
+
249
+			$data[$i]['address_line1']   = isset($address['line1']) ? $address['line1'] : '';
250
+			$data[$i]['address_line2']   = isset($address['line2']) ? $address['line2'] : '';
251
+			$data[$i]['address_city']    = isset($address['city']) ? $address['city'] : '';
252
+			$data[$i]['address_state']   = isset($address['state']) ? $address['state'] : '';
253
+			$data[$i]['address_zip']     = isset($address['zip']) ? $address['zip'] : '';
254
+			$data[$i]['address_country'] = isset($address['country']) ? $address['country'] : '';
255 255
 		}
256
-		if ( ! empty( $columns['userid'] ) ) {
257
-			$data[ $i ]['userid'] = ! empty( $donor->user_id ) ? $donor->user_id : '';
256
+		if ( ! empty($columns['userid'])) {
257
+			$data[$i]['userid'] = ! empty($donor->user_id) ? $donor->user_id : '';
258 258
 		}
259
-		if ( ! empty( $columns['date_first_donated'] ) ) {
260
-			$data[ $i ]['date_first_donated'] = date_i18n( give_date_format(), strtotime( $donor->date_created ) );
259
+		if ( ! empty($columns['date_first_donated'])) {
260
+			$data[$i]['date_first_donated'] = date_i18n(give_date_format(), strtotime($donor->date_created));
261 261
 		}
262
-		if ( ! empty( $columns['donations'] ) ) {
263
-			$data[ $i ]['donations'] = $donor->purchase_count;
262
+		if ( ! empty($columns['donations'])) {
263
+			$data[$i]['donations'] = $donor->purchase_count;
264 264
 		}
265
-		if ( ! empty( $columns['donation_sum'] ) ) {
266
-			$data[ $i ]['donation_sum'] = give_format_amount( $donor->purchase_value );
265
+		if ( ! empty($columns['donation_sum'])) {
266
+			$data[$i]['donation_sum'] = give_format_amount($donor->purchase_value);
267 267
 		}
268 268
 
269
-		return $data[ $i ];
269
+		return $data[$i];
270 270
 
271 271
 	}
272 272
 
Please login to merge, or discard this patch.