Test Failed
Push — master ( 26906f...b49498 )
by Devin
05:35
created
includes/class-give-db-payment-meta.php 1 patch
Spacing   +3 added lines, -3 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
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 		/* @var WPDB $wpdb */
51 51
 		global $wpdb;
52 52
 
53
-		$wpdb->paymentmeta = $this->table_name = $wpdb->prefix . 'give_paymentmeta';
53
+		$wpdb->paymentmeta = $this->table_name = $wpdb->prefix.'give_paymentmeta';
54 54
 		$this->primary_key = 'meta_id';
55 55
 		$this->version     = '1.0';
56 56
 
@@ -84,6 +84,6 @@  discard block
 block discarded – undo
84 84
 	 * @return bool
85 85
 	 */
86 86
 	protected function is_custom_meta_table_active() {
87
-		return give_has_upgrade_completed( 'v20_move_metadata_into_new_table' );
87
+		return give_has_upgrade_completed('v20_move_metadata_into_new_table');
88 88
 	}
89 89
 }
Please login to merge, or discard this patch.
includes/class-give-db-logs-meta.php 1 patch
Spacing   +7 added lines, -7 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
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 		/* @var WPDB $wpdb */
51 51
 		global $wpdb;
52 52
 
53
-		$wpdb->logmeta     = $this->table_name = $wpdb->prefix . 'give_logmeta';
53
+		$wpdb->logmeta     = $this->table_name = $wpdb->prefix.'give_logmeta';
54 54
 		$this->primary_key = 'meta_id';
55 55
 		$this->version     = '1.0';
56 56
 
@@ -86,18 +86,18 @@  discard block
 block discarded – undo
86 86
 	 *
87 87
 	 * @return bool
88 88
 	 */
89
-	public function delete_row( $log_id = 0 ) {
89
+	public function delete_row($log_id = 0) {
90 90
 		/* @var WPDB $wpdb */
91 91
 		global $wpdb;
92 92
 
93 93
 		// Row ID must be positive integer
94
-		$log_id = absint( $log_id );
94
+		$log_id = absint($log_id);
95 95
 
96
-		if ( empty( $log_id ) ) {
96
+		if (empty($log_id)) {
97 97
 			return false;
98 98
 		}
99 99
 
100
-		if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE log_id = %d", $log_id ) ) ) {
100
+		if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE log_id = %d", $log_id))) {
101 101
 			return false;
102 102
 		}
103 103
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 *
115 115
 	 * @return bool
116 116
 	 */
117
-	protected function is_valid_post_type( $ID ) {
117
+	protected function is_valid_post_type($ID) {
118 118
 		return $ID && true;
119 119
 	}
120 120
 }
Please login to merge, or discard this patch.
includes/class-give-db-donor-meta.php 1 patch
Spacing   +9 added lines, -9 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
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 		/* @var WPDB $wpdb */
54 54
 		global $wpdb;
55 55
 
56
-		$wpdb->donormeta   = $this->table_name = $wpdb->prefix . 'give_donormeta';
56
+		$wpdb->donormeta   = $this->table_name = $wpdb->prefix.'give_donormeta';
57 57
 		$this->primary_key = 'meta_id';
58 58
 		$this->version     = '1.0';
59 59
 
@@ -90,12 +90,12 @@  discard block
 block discarded – undo
90 90
 	 *
91 91
 	 * @return  bool  False for failure. True for success.
92 92
 	 */
93
-	public function delete_all_meta( $donor_id = 0 ) {
93
+	public function delete_all_meta($donor_id = 0) {
94 94
 		global $wpdb;
95
-		$status = $wpdb->delete( $this->table_name, array( 'donor_id' => $donor_id ), array( '%d' ) );
95
+		$status = $wpdb->delete($this->table_name, array('donor_id' => $donor_id), array('%d'));
96 96
 
97
-		if( $status ) {
98
-			Give_Cache::delete_group( $donor_id, 'give-donors' );
97
+		if ($status) {
98
+			Give_Cache::delete_group($donor_id, 'give-donors');
99 99
 		}
100 100
 	}
101 101
 
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
 		global $wpdb;
112 112
 
113 113
 		if (
114
-			! give_has_upgrade_completed( 'v20_rename_donor_tables' ) &&
115
-			$wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s","{$wpdb->prefix}give_customermeta" ) )
114
+			! give_has_upgrade_completed('v20_rename_donor_tables') &&
115
+			$wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customermeta"))
116 116
 		) {
117 117
 			$wpdb->donormeta = $this->table_name = "{$wpdb->prefix}give_customermeta";
118 118
 			$this->meta_type = 'customer';
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	 *
132 132
 	 * @return bool
133 133
 	 */
134
-	protected function is_valid_post_type( $ID ) {
134
+	protected function is_valid_post_type($ID) {
135 135
 		return $ID && true;
136 136
 	}
137 137
 
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-donor-stats.php 1 patch
Spacing   +37 added lines, -37 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
 
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
 	/**
49 49
 	 * Constructor.
50 50
 	 */
51
-	public function __construct( $_step = 1 ) {
52
-		parent::__construct( $_step );
51
+	public function __construct($_step = 1) {
52
+		parent::__construct($_step);
53 53
 
54 54
 		$this->is_writable = true;
55 55
 	}
@@ -66,32 +66,32 @@  discard block
 block discarded – undo
66 66
 
67 67
 		$args = array(
68 68
 			'number'  => $this->per_step,
69
-			'offset'  => $this->per_step * ( $this->step - 1 ),
69
+			'offset'  => $this->per_step * ($this->step - 1),
70 70
 			'orderby' => 'id',
71 71
 			'order'   => 'DESC',
72 72
 		);
73 73
 
74
-		$donors = Give()->donors->get_donors( $args );
74
+		$donors = Give()->donors->get_donors($args);
75 75
 
76
-		if ( $donors ) {
76
+		if ($donors) {
77 77
 
78
-			$allowed_payment_status = apply_filters( 'give_recount_donors_donation_statuses', give_get_payment_status_keys() );
78
+			$allowed_payment_status = apply_filters('give_recount_donors_donation_statuses', give_get_payment_status_keys());
79 79
 
80
-			foreach ( $donors as $donor ) {
80
+			foreach ($donors as $donor) {
81 81
 
82
-				$attached_payment_ids = explode( ',', $donor->payment_ids );
82
+				$attached_payment_ids = explode(',', $donor->payment_ids);
83 83
 
84 84
 				$attached_args = array(
85 85
 					'post__in' => $attached_payment_ids,
86
-					'number'   => - 1,
86
+					'number'   => -1,
87 87
 					'status'   => $allowed_payment_status,
88 88
 				);
89 89
 
90
-				$attached_payments = (array) give_get_payments( $attached_args );
90
+				$attached_payments = (array) give_get_payments($attached_args);
91 91
 
92 92
 				$unattached_args = array(
93 93
 					'post__not_in' => $attached_payment_ids,
94
-					'number'       => - 1,
94
+					'number'       => -1,
95 95
 					'status'       => $allowed_payment_status,
96 96
 					'meta_query'   => array(
97 97
 						array(
@@ -102,29 +102,29 @@  discard block
 block discarded – undo
102 102
 					),
103 103
 				);
104 104
 
105
-				$unattached_payments = give_get_payments( $unattached_args );
105
+				$unattached_payments = give_get_payments($unattached_args);
106 106
 
107
-				$payments = array_merge( $attached_payments, $unattached_payments );
107
+				$payments = array_merge($attached_payments, $unattached_payments);
108 108
 
109 109
 				$purchase_value = 0.00;
110 110
 				$purchase_count = 0;
111 111
 				$payment_ids    = array();
112 112
 
113
-				if ( $payments ) {
113
+				if ($payments) {
114 114
 
115
-					foreach ( $payments as $payment ) {
115
+					foreach ($payments as $payment) {
116 116
 
117 117
 						$should_process_payment = 'publish' == $payment->post_status ? true : false;
118
-						$should_process_payment = apply_filters( 'give_donor_recount_should_process_donation', $should_process_payment, $payment );
118
+						$should_process_payment = apply_filters('give_donor_recount_should_process_donation', $should_process_payment, $payment);
119 119
 
120
-						if ( true === $should_process_payment ) {
120
+						if (true === $should_process_payment) {
121 121
 
122
-							if ( apply_filters( 'give_donor_recount_should_increase_value', true, $payment ) ) {
123
-								$purchase_value += (float) give_donation_amount( $payment->ID, array( 'type' => 'stats' ) );
122
+							if (apply_filters('give_donor_recount_should_increase_value', true, $payment)) {
123
+								$purchase_value += (float) give_donation_amount($payment->ID, array('type' => 'stats'));
124 124
 							}
125 125
 
126
-							if ( apply_filters( 'give_donor_recount_should_increase_count', true, $payment ) ) {
127
-								$purchase_count ++;
126
+							if (apply_filters('give_donor_recount_should_increase_count', true, $payment)) {
127
+								$purchase_count++;
128 128
 							}
129 129
 						}
130 130
 
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 					}
133 133
 				}
134 134
 
135
-				$payment_ids = implode( ',', $payment_ids );
135
+				$payment_ids = implode(',', $payment_ids);
136 136
 
137 137
 				$donor_update_data = array(
138 138
 					'purchase_count' => $purchase_count,
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
 					'payment_ids'    => $payment_ids,
141 141
 				);
142 142
 
143
-				$donor_instance = new Give_Donor( $donor->id );
144
-				$donor_instance->update( $donor_update_data );
143
+				$donor_instance = new Give_Donor($donor->id);
144
+				$donor_instance->update($donor_update_data);
145 145
 
146 146
 			}// End foreach().
147 147
 
@@ -161,21 +161,21 @@  discard block
 block discarded – undo
161 161
 	public function get_percentage_complete() {
162 162
 
163 163
 		$args = array(
164
-			'number'  => - 1,
164
+			'number'  => -1,
165 165
 			'orderby' => 'id',
166 166
 			'order'   => 'DESC',
167 167
 		);
168 168
 
169
-		$donors = Give()->donors->get_donors( $args );
170
-		$total     = count( $donors );
169
+		$donors = Give()->donors->get_donors($args);
170
+		$total = count($donors);
171 171
 
172 172
 		$percentage = 100;
173 173
 
174
-		if ( $total > 0 ) {
175
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
174
+		if ($total > 0) {
175
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
176 176
 		}
177 177
 
178
-		if ( $percentage > 100 ) {
178
+		if ($percentage > 100) {
179 179
 			$percentage = 100;
180 180
 		}
181 181
 
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	 *
190 190
 	 * @param array $request The Form Data passed into the batch processing
191 191
 	 */
192
-	public function set_properties( $request ) {
192
+	public function set_properties($request) {
193 193
 	}
194 194
 
195 195
 	/**
@@ -200,21 +200,21 @@  discard block
 block discarded – undo
200 200
 	 */
201 201
 	public function process_step() {
202 202
 
203
-		if ( ! $this->can_export() ) {
204
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array(
203
+		if ( ! $this->can_export()) {
204
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array(
205 205
 				'response' => 403,
206
-			) );
206
+			));
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 216
 			$this->done    = true;
217
-			$this->message = esc_html__( 'Donor stats have been successfully recounted.', 'give' );
217
+			$this->message = esc_html__('Donor stats have been successfully recounted.', 'give');
218 218
 
219 219
 			return false;
220 220
 		}
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-form-stats.php 1 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
 
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
 	/**
54 54
 	 * Constructor.
55 55
 	 */
56
-	public function __construct( $_step = 1 ) {
57
-		parent::__construct( $_step );
56
+	public function __construct($_step = 1) {
57
+		parent::__construct($_step);
58 58
 
59 59
 		$this->is_writable = true;
60 60
 	}
@@ -69,59 +69,59 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	public function get_data() {
71 71
 
72
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
72
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
73 73
 
74
-		if ( $this->step == 1 ) {
75
-			$this->delete_data( 'give_temp_recount_form_stats' );
74
+		if ($this->step == 1) {
75
+			$this->delete_data('give_temp_recount_form_stats');
76 76
 		}
77 77
 
78
-		$totals = $this->get_stored_data( 'give_temp_recount_form_stats' );
78
+		$totals = $this->get_stored_data('give_temp_recount_form_stats');
79 79
 
80
-		if ( false === $totals ) {
80
+		if (false === $totals) {
81 81
 			$totals = array(
82 82
 				'earnings' => (float) 0,
83 83
 				'sales'    => 0,
84 84
 			);
85
-			$this->store_data( 'give_temp_recount_form_stats', $totals );
85
+			$this->store_data('give_temp_recount_form_stats', $totals);
86 86
 		}
87 87
 
88
-		$args = apply_filters( 'give_recount_form_stats_args', array(
88
+		$args = apply_filters('give_recount_form_stats_args', array(
89 89
 			'give_forms' => $this->form_id,
90 90
 			'number'     => $this->per_step,
91 91
 			'status'     => $accepted_statuses,
92 92
 			'paged'      => $this->step,
93 93
 			'fields'     => 'ids',
94
-		) );
94
+		));
95 95
 
96
-		$payments = new Give_Payments_Query( $args );
96
+		$payments = new Give_Payments_Query($args);
97 97
 		$payments = $payments->get_payments();
98 98
 
99
-		if ( $payments ) {
100
-			foreach ( $payments as $payment ) {
99
+		if ($payments) {
100
+			foreach ($payments as $payment) {
101 101
 
102 102
 				// Ensure acceptable status only.
103
-				if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
103
+				if ( ! in_array($payment->post_status, $accepted_statuses)) {
104 104
 					continue;
105 105
 				}
106 106
 
107 107
 				// Ensure only payments for this form are counted.
108
-				if ( $payment->form_id != $this->form_id ) {
108
+				if ($payment->form_id != $this->form_id) {
109 109
 					continue;
110 110
 				}
111 111
 
112
-				$totals['sales'] ++;
112
+				$totals['sales']++;
113 113
 				$totals['earnings'] += $payment->total;
114 114
 
115 115
 			}
116 116
 
117
-			$this->store_data( 'give_temp_recount_form_stats', $totals );
117
+			$this->store_data('give_temp_recount_form_stats', $totals);
118 118
 
119 119
 			return true;
120 120
 		}
121 121
 
122 122
 
123
-		give_update_meta( $this->form_id, '_give_form_sales', $totals['sales'] );
124
-		give_update_meta( $this->form_id, '_give_form_earnings', give_sanitize_amount_for_db( $totals['earnings'] ) );
123
+		give_update_meta($this->form_id, '_give_form_sales', $totals['sales']);
124
+		give_update_meta($this->form_id, '_give_form_earnings', give_sanitize_amount_for_db($totals['earnings']));
125 125
 
126 126
 		return false;
127 127
 	}
@@ -133,35 +133,35 @@  discard block
 block discarded – undo
133 133
 	 * @return int
134 134
 	 */
135 135
 	public function get_percentage_complete() {
136
-		if ( $this->step == 1 ) {
137
-			$this->delete_data( 'give_recount_total_' . $this->form_id );
136
+		if ($this->step == 1) {
137
+			$this->delete_data('give_recount_total_'.$this->form_id);
138 138
 		}
139 139
 
140
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
141
-		$total             = $this->get_stored_data( 'give_recount_total_' . $this->form_id );
140
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
141
+		$total             = $this->get_stored_data('give_recount_total_'.$this->form_id);
142 142
 
143
-		if ( false === $total ) {
143
+		if (false === $total) {
144 144
 			$total = 0;
145
-			$args  = apply_filters( 'give_recount_form_stats_total_args', array(
145
+			$args  = apply_filters('give_recount_form_stats_total_args', array(
146 146
 				'give_forms' => $this->form_id,
147
-				'number'     => - 1,
147
+				'number'     => -1,
148 148
 				'status'     => $accepted_statuses,
149 149
 				'fields'     => 'ids',
150
-			) );
150
+			));
151 151
 
152
-			$payments = new Give_Payments_Query( $args );
153
-			$total    = count( $payments->get_payments() );
154
-			$this->store_data( 'give_recount_total_' . $this->form_id, $total );
152
+			$payments = new Give_Payments_Query($args);
153
+			$total    = count($payments->get_payments());
154
+			$this->store_data('give_recount_total_'.$this->form_id, $total);
155 155
 
156 156
 		}
157 157
 
158 158
 		$percentage = 100;
159 159
 
160
-		if ( $total > 0 ) {
161
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
160
+		if ($total > 0) {
161
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
162 162
 		}
163 163
 
164
-		if ( $percentage > 100 ) {
164
+		if ($percentage > 100) {
165 165
 			$percentage = 100;
166 166
 		}
167 167
 
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
 	 *
176 176
 	 * @param array $request The Form Data passed into the batch processing
177 177
 	 */
178
-	public function set_properties( $request ) {
179
-		$this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false;
178
+	public function set_properties($request) {
179
+		$this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false;
180 180
 	}
181 181
 
182 182
 	/**
@@ -187,21 +187,21 @@  discard block
 block discarded – undo
187 187
 	 */
188 188
 	public function process_step() {
189 189
 
190
-		if ( ! $this->can_export() ) {
191
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
190
+		if ( ! $this->can_export()) {
191
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
192 192
 		}
193 193
 
194 194
 		$had_data = $this->get_data();
195 195
 
196
-		if ( $had_data ) {
196
+		if ($had_data) {
197 197
 			$this->done = false;
198 198
 
199 199
 			return true;
200 200
 		} else {
201
-			$this->delete_data( 'give_recount_total_' . $this->form_id );
202
-			$this->delete_data( 'give_temp_recount_form_stats' );
201
+			$this->delete_data('give_recount_total_'.$this->form_id);
202
+			$this->delete_data('give_temp_recount_form_stats');
203 203
 			$this->done    = true;
204
-			$this->message = sprintf( esc_html__( 'Donation counts and income amount statistics successfully recounted for "%s".', 'give' ), get_the_title( $this->form_id ) );
204
+			$this->message = sprintf(esc_html__('Donation counts and income amount statistics successfully recounted for "%s".', 'give'), get_the_title($this->form_id));
205 205
 
206 206
 			return false;
207 207
 		}
@@ -235,17 +235,17 @@  discard block
 block discarded – undo
235 235
 	 *
236 236
 	 * @return mixed       Returns the data from the database
237 237
 	 */
238
-	private function get_stored_data( $key ) {
238
+	private function get_stored_data($key) {
239 239
 		global $wpdb;
240
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
240
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
241 241
 
242
-		if ( empty( $value ) ) {
242
+		if (empty($value)) {
243 243
 			return false;
244 244
 		}
245 245
 
246
-		$maybe_json = json_decode( $value );
247
-		if ( ! is_null( $maybe_json ) ) {
248
-			$value = json_decode( $value, true );
246
+		$maybe_json = json_decode($value);
247
+		if ( ! is_null($maybe_json)) {
248
+			$value = json_decode($value, true);
249 249
 		}
250 250
 
251 251
 		return $value;
@@ -261,10 +261,10 @@  discard block
 block discarded – undo
261 261
 	 *
262 262
 	 * @return void
263 263
 	 */
264
-	private function store_data( $key, $value ) {
264
+	private function store_data($key, $value) {
265 265
 		global $wpdb;
266 266
 
267
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
267
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
268 268
 
269 269
 		$data = array(
270 270
 			'option_name'  => $key,
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 			'%s',
279 279
 		);
280 280
 
281
-		$wpdb->replace( $wpdb->options, $data, $formats );
281
+		$wpdb->replace($wpdb->options, $data, $formats);
282 282
 	}
283 283
 
284 284
 	/**
@@ -290,9 +290,9 @@  discard block
 block discarded – undo
290 290
 	 *
291 291
 	 * @return void
292 292
 	 */
293
-	private function delete_data( $key ) {
293
+	private function delete_data($key) {
294 294
 		global $wpdb;
295
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
295
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
296 296
 	}
297 297
 
298 298
 }
299 299
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-income.php 1 patch
Spacing   +47 added lines, -47 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
 
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 	/**
47 47
 	 * Constructor.
48 48
 	 */
49
-	public function __construct( $_step = 1 ) {
50
-		parent::__construct( $_step );
49
+	public function __construct($_step = 1) {
50
+		parent::__construct($_step);
51 51
 
52 52
 		$this->is_writable = true;
53 53
 	}
@@ -61,49 +61,49 @@  discard block
 block discarded – undo
61 61
 	 */
62 62
 	public function get_data() {
63 63
 
64
-		if ( $this->step == 1 ) {
65
-			$this->delete_data( 'give_temp_recount_earnings' );
64
+		if ($this->step == 1) {
65
+			$this->delete_data('give_temp_recount_earnings');
66 66
 		}
67 67
 
68
-		$total = get_option( 'give_temp_recount_earnings', false );
68
+		$total = get_option('give_temp_recount_earnings', false);
69 69
 
70
-		if ( false === $total ) {
70
+		if (false === $total) {
71 71
 			$total = (float) 0;
72
-			$this->store_data( 'give_temp_recount_earnings', $total );
72
+			$this->store_data('give_temp_recount_earnings', $total);
73 73
 		}
74 74
 
75
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
75
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
76 76
 
77
-		$args = apply_filters( 'give_recount_earnings_args', array(
77
+		$args = apply_filters('give_recount_earnings_args', array(
78 78
 			'number' => $this->per_step,
79 79
 			'page'   => $this->step,
80 80
 			'status' => $accepted_statuses,
81 81
 			'fields' => 'ids'
82
-		) );
82
+		));
83 83
 
84
-		$payments = give_get_payments( $args );
84
+		$payments = give_get_payments($args);
85 85
 
86
-		if ( ! empty( $payments ) ) {
86
+		if ( ! empty($payments)) {
87 87
 
88
-			foreach ( $payments as $payment ) {
88
+			foreach ($payments as $payment) {
89 89
 
90
-				$total += (float) give_donation_amount( $payment, array( 'type' => 'stats' ) );
90
+				$total += (float) give_donation_amount($payment, array('type' => 'stats'));
91 91
 
92 92
 			}
93 93
 
94
-			if ( $total < 0 ) {
94
+			if ($total < 0) {
95 95
 				$totals = 0;
96 96
 			}
97 97
 
98
-			$total = round( $total, give_get_price_decimals() );
98
+			$total = round($total, give_get_price_decimals());
99 99
 
100
-			$this->store_data( 'give_temp_recount_earnings', $total );
100
+			$this->store_data('give_temp_recount_earnings', $total);
101 101
 
102 102
 			return true;
103 103
 
104 104
 		}
105 105
 
106
-		update_option( 'give_earnings_total', $total );
106
+		update_option('give_earnings_total', $total);
107 107
 
108 108
 		return false;
109 109
 
@@ -117,25 +117,25 @@  discard block
 block discarded – undo
117 117
 	 */
118 118
 	public function get_percentage_complete() {
119 119
 
120
-		$total = $this->get_stored_data( 'give_recount_earnings_total' );
120
+		$total = $this->get_stored_data('give_recount_earnings_total');
121 121
 
122
-		if ( false === $total ) {
123
-			$args = apply_filters( 'give_recount_earnings_total_args', array() );
122
+		if (false === $total) {
123
+			$args = apply_filters('give_recount_earnings_total_args', array());
124 124
 
125
-			$counts = give_count_payments( $args );
126
-			$total  = absint( $counts->publish );
127
-			$total  = apply_filters( 'give_recount_store_earnings_total', $total );
125
+			$counts = give_count_payments($args);
126
+			$total  = absint($counts->publish);
127
+			$total  = apply_filters('give_recount_store_earnings_total', $total);
128 128
 
129
-			$this->store_data( 'give_recount_earnings_total', $total );
129
+			$this->store_data('give_recount_earnings_total', $total);
130 130
 		}
131 131
 
132 132
 		$percentage = 100;
133 133
 
134
-		if ( $total > 0 ) {
135
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
134
+		if ($total > 0) {
135
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
136 136
 		}
137 137
 
138
-		if ( $percentage > 100 ) {
138
+		if ($percentage > 100) {
139 139
 			$percentage = 100;
140 140
 		}
141 141
 
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 	 *
150 150
 	 * @param array $request The Form Data passed into the batch processing
151 151
 	 */
152
-	public function set_properties( $request ) {
152
+	public function set_properties($request) {
153 153
 	}
154 154
 
155 155
 	/**
@@ -160,21 +160,21 @@  discard block
 block discarded – undo
160 160
 	 */
161 161
 	public function process_step() {
162 162
 
163
-		if ( ! $this->can_export() ) {
164
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
163
+		if ( ! $this->can_export()) {
164
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
165 165
 		}
166 166
 
167 167
 		$had_data = $this->get_data();
168 168
 
169
-		if ( $had_data ) {
169
+		if ($had_data) {
170 170
 			$this->done = false;
171 171
 
172 172
 			return true;
173 173
 		} else {
174
-			$this->delete_data( 'give_recount_earnings_total' );
175
-			$this->delete_data( 'give_temp_recount_earnings' );
174
+			$this->delete_data('give_recount_earnings_total');
175
+			$this->delete_data('give_temp_recount_earnings');
176 176
 			$this->done    = true;
177
-			$this->message = esc_html__( 'Income stats have been successfully recounted.', 'give' );
177
+			$this->message = esc_html__('Income stats have been successfully recounted.', 'give');
178 178
 
179 179
 			return false;
180 180
 		}
@@ -211,17 +211,17 @@  discard block
 block discarded – undo
211 211
 	 *
212 212
 	 * @return mixed       Returns the data from the database
213 213
 	 */
214
-	private function get_stored_data( $key ) {
214
+	private function get_stored_data($key) {
215 215
 		global $wpdb;
216
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
216
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
217 217
 
218
-		if ( empty( $value ) ) {
218
+		if (empty($value)) {
219 219
 			return false;
220 220
 		}
221 221
 
222
-		$maybe_json = json_decode( $value );
223
-		if ( ! is_null( $maybe_json ) ) {
224
-			$value = json_decode( $value, true );
222
+		$maybe_json = json_decode($value);
223
+		if ( ! is_null($maybe_json)) {
224
+			$value = json_decode($value, true);
225 225
 		}
226 226
 
227 227
 		return $value;
@@ -237,10 +237,10 @@  discard block
 block discarded – undo
237 237
 	 *
238 238
 	 * @return void
239 239
 	 */
240
-	private function store_data( $key, $value ) {
240
+	private function store_data($key, $value) {
241 241
 		global $wpdb;
242 242
 
243
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
243
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
244 244
 
245 245
 		$data = array(
246 246
 			'option_name'  => $key,
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 			'%s',
255 255
 		);
256 256
 
257
-		$wpdb->replace( $wpdb->options, $data, $formats );
257
+		$wpdb->replace($wpdb->options, $data, $formats);
258 258
 	}
259 259
 
260 260
 	/**
@@ -266,9 +266,9 @@  discard block
 block discarded – undo
266 266
 	 *
267 267
 	 * @return void
268 268
 	 */
269
-	private function delete_data( $key ) {
269
+	private function delete_data($key) {
270 270
 		global $wpdb;
271
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
271
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
272 272
 	}
273 273
 
274 274
 }
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-delete-test-transactions.php 1 patch
Spacing   +48 added lines, -48 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
 
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 	/**
47 47
 	 * Constructor.
48 48
 	 */
49
-	public function __construct( $_step = 1 ) {
50
-		parent::__construct( $_step );
49
+	public function __construct($_step = 1) {
50
+		parent::__construct($_step);
51 51
 
52 52
 		$this->is_writable = true;
53 53
 	}
@@ -62,20 +62,20 @@  discard block
 block discarded – undo
62 62
 	 * @return array|bool $data The data for the CSV file
63 63
 	 */
64 64
 	public function get_data() {
65
-		$items = $this->get_stored_data( 'give_temp_delete_test_ids' );
65
+		$items = $this->get_stored_data('give_temp_delete_test_ids');
66 66
 
67
-		if ( ! is_array( $items ) ) {
67
+		if ( ! is_array($items)) {
68 68
 			return false;
69 69
 		}
70 70
 
71
-		$offset     = ( $this->step - 1 ) * $this->per_step;
72
-		$step_items = array_slice( $items, $offset, $this->per_step );
73
-		$meta_table = __give_v20_bc_table_details( 'payment' );
71
+		$offset     = ($this->step - 1) * $this->per_step;
72
+		$step_items = array_slice($items, $offset, $this->per_step);
73
+		$meta_table = __give_v20_bc_table_details('payment');
74 74
 
75
-		if ( $step_items ) {
76
-			foreach ( $step_items as $item ) {
75
+		if ($step_items) {
76
+			foreach ($step_items as $item) {
77 77
 				// Delete the main payment.
78
-				give_delete_donation( absint( $item['id'] ) );
78
+				give_delete_donation(absint($item['id']));
79 79
 			}
80 80
 			return true;
81 81
 		}
@@ -91,16 +91,16 @@  discard block
 block discarded – undo
91 91
 	 */
92 92
 	public function get_percentage_complete() {
93 93
 
94
-		$items = $this->get_stored_data( 'give_temp_delete_test_ids', false );
95
-		$total = count( $items );
94
+		$items = $this->get_stored_data('give_temp_delete_test_ids', false);
95
+		$total = count($items);
96 96
 
97 97
 		$percentage = 100;
98 98
 
99
-		if ( $total > 0 ) {
100
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
99
+		if ($total > 0) {
100
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
101 101
 		}
102 102
 
103
-		if ( $percentage > 100 ) {
103
+		if ($percentage > 100) {
104 104
 			$percentage = 100;
105 105
 		}
106 106
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 *
115 115
 	 * @param array $request The Form Data passed into the batch processing
116 116
 	 */
117
-	public function set_properties( $request ) {
117
+	public function set_properties($request) {
118 118
 	}
119 119
 
120 120
 	/**
@@ -125,29 +125,29 @@  discard block
 block discarded – undo
125 125
 	 */
126 126
 	public function process_step() {
127 127
 
128
-		if ( ! $this->can_export() ) {
129
-			wp_die( __( 'You do not have permission to delete test transactions.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
128
+		if ( ! $this->can_export()) {
129
+			wp_die(__('You do not have permission to delete test transactions.', 'give'), __('Error', 'give'), array('response' => 403));
130 130
 		}
131 131
 
132 132
 		$had_data = $this->get_data();
133 133
 
134
-		if ( $had_data ) {
134
+		if ($had_data) {
135 135
 			$this->done = false;
136 136
 
137 137
 			return true;
138 138
 		} else {
139
-			update_option( 'give_earnings_total', give_get_total_earnings( true ) );
140
-			Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) );
139
+			update_option('give_earnings_total', give_get_total_earnings(true));
140
+			Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
141 141
 
142
-			$this->delete_data( 'give_temp_delete_test_ids' );
142
+			$this->delete_data('give_temp_delete_test_ids');
143 143
 
144 144
 			// Reset the sequential order numbers
145
-			if ( give_get_option( 'enable_sequential' ) ) {
146
-				delete_option( 'give_last_payment_number' );
145
+			if (give_get_option('enable_sequential')) {
146
+				delete_option('give_last_payment_number');
147 147
 			}
148 148
 
149 149
 			$this->done    = true;
150
-			$this->message = __( 'Test transactions successfully deleted.', 'give' );
150
+			$this->message = __('Test transactions successfully deleted.', 'give');
151 151
 
152 152
 			return false;
153 153
 		}
@@ -180,27 +180,27 @@  discard block
 block discarded – undo
180 180
 	 */
181 181
 	public function pre_fetch() {
182 182
 
183
-		if ( $this->step == 1 ) {
184
-			$this->delete_data( 'give_temp_delete_test_ids' );
183
+		if ($this->step == 1) {
184
+			$this->delete_data('give_temp_delete_test_ids');
185 185
 		}
186 186
 
187
-		$items = get_option( 'give_temp_delete_test_ids', false );
187
+		$items = get_option('give_temp_delete_test_ids', false);
188 188
 
189
-		if ( false === $items ) {
189
+		if (false === $items) {
190 190
 			$items = array();
191 191
 
192
-			$args = apply_filters( 'give_tools_reset_stats_total_args', array(
192
+			$args = apply_filters('give_tools_reset_stats_total_args', array(
193 193
 				'post_status' => 'any',
194
-				'number'      => - 1,
194
+				'number'      => -1,
195 195
 				'meta_key'    => '_give_payment_mode',
196 196
 				'meta_value'  => 'test'
197
-			) );
197
+			));
198 198
 
199
-			$posts    = new Give_Payments_Query( $args );
199
+			$posts    = new Give_Payments_Query($args);
200 200
 			$payments = $posts->get_payments();
201 201
 
202 202
 			/* @var Give_Payment $payment */
203
-			foreach ( $payments as $payment ) {
203
+			foreach ($payments as $payment) {
204 204
 				$items[] = array(
205 205
 					'id'   => (int) $payment->ID,
206 206
 					'type' => 'give_payment',
@@ -209,9 +209,9 @@  discard block
 block discarded – undo
209 209
 			
210 210
 			// Allow filtering of items to remove with an unassociative array for each item.
211 211
 			// The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method.
212
-			$items = apply_filters( 'give_delete_test_items', $items );
212
+			$items = apply_filters('give_delete_test_items', $items);
213 213
 
214
-			$this->store_data( 'give_temp_delete_test_ids', $items );
214
+			$this->store_data('give_temp_delete_test_ids', $items);
215 215
 		}
216 216
 
217 217
 	}
@@ -225,17 +225,17 @@  discard block
 block discarded – undo
225 225
 	 *
226 226
 	 * @return mixed       Returns the data from the database
227 227
 	 */
228
-	private function get_stored_data( $key ) {
228
+	private function get_stored_data($key) {
229 229
 		global $wpdb;
230
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
230
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
231 231
 
232
-		if ( empty( $value ) ) {
232
+		if (empty($value)) {
233 233
 			return false;
234 234
 		}
235 235
 
236
-		$maybe_json = json_decode( $value );
237
-		if ( ! is_null( $maybe_json ) ) {
238
-			$value = json_decode( $value, true );
236
+		$maybe_json = json_decode($value);
237
+		if ( ! is_null($maybe_json)) {
238
+			$value = json_decode($value, true);
239 239
 		}
240 240
 
241 241
 		return $value;
@@ -251,10 +251,10 @@  discard block
 block discarded – undo
251 251
 	 *
252 252
 	 * @return void
253 253
 	 */
254
-	private function store_data( $key, $value ) {
254
+	private function store_data($key, $value) {
255 255
 		global $wpdb;
256 256
 
257
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
257
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
258 258
 
259 259
 		$data = array(
260 260
 			'option_name'  => $key,
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 			'%s',
269 269
 		);
270 270
 
271
-		$wpdb->replace( $wpdb->options, $data, $formats );
271
+		$wpdb->replace($wpdb->options, $data, $formats);
272 272
 	}
273 273
 
274 274
 	/**
@@ -280,9 +280,9 @@  discard block
 block discarded – undo
280 280
 	 *
281 281
 	 * @return void
282 282
 	 */
283
-	private function delete_data( $key ) {
283
+	private function delete_data($key) {
284 284
 		global $wpdb;
285
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
285
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
286 286
 	}
287 287
 
288 288
 }
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-all-stats.php 1 patch
Spacing   +97 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
 
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
 	/**
74 74
 	 * Constructor.
75 75
 	 */
76
-	public function __construct( $_step = 1 ) {
77
-		parent::__construct( $_step );
76
+	public function __construct($_step = 1) {
77
+		parent::__construct($_step);
78 78
 
79 79
 		$this->is_writable = true;
80 80
 	}
@@ -89,108 +89,106 @@  discard block
 block discarded – undo
89 89
 	 */
90 90
 	public function get_data() {
91 91
 
92
-		$totals             = $this->get_stored_data( 'give_temp_recount_all_stats' );
93
-		$payment_items      = $this->get_stored_data( 'give_temp_payment_items' );
94
-		$processed_payments = $this->get_stored_data( 'give_temp_processed_payments' );
95
-		$accepted_statuses  = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
92
+		$totals             = $this->get_stored_data('give_temp_recount_all_stats');
93
+		$payment_items      = $this->get_stored_data('give_temp_payment_items');
94
+		$processed_payments = $this->get_stored_data('give_temp_processed_payments');
95
+		$accepted_statuses  = apply_filters('give_recount_accepted_statuses', array('publish'));
96 96
 
97
-		if ( false === $totals ) {
97
+		if (false === $totals) {
98 98
 			$totals = array();
99 99
 		}
100 100
 
101
-		if ( false === $payment_items ) {
101
+		if (false === $payment_items) {
102 102
 			$payment_items = array();
103 103
 		}
104 104
 
105
-		if ( false === $processed_payments ) {
105
+		if (false === $processed_payments) {
106 106
 			$processed_payments = array();
107 107
 		}
108 108
 
109
-		$all_forms = $this->get_stored_data( 'give_temp_form_ids' );
109
+		$all_forms = $this->get_stored_data('give_temp_form_ids');
110 110
 
111
-		$payments = $this->get_stored_data( 'give_temp_all_payments_data' );
111
+		$payments = $this->get_stored_data('give_temp_all_payments_data');
112 112
 
113
-		if ( empty( $payments ) ) {
114
-			$args = apply_filters( 'give_recount_form_stats_args', array(
113
+		if (empty($payments)) {
114
+			$args = apply_filters('give_recount_form_stats_args', array(
115 115
 				'give_forms' => $all_forms,
116 116
 				'number'     => $this->per_step,
117 117
 				'status'     => $accepted_statuses,
118 118
 				'paged'      => $this->step,
119 119
 				'output'     => 'give_payments',
120
-			) );
120
+			));
121 121
 
122
-			$payments_query = new Give_Payments_Query( $args );
122
+			$payments_query = new Give_Payments_Query($args);
123 123
 			$payments       = $payments_query->get_payments();
124 124
 		}
125 125
 
126
-		if ( ! empty( $payments ) ) {
126
+		if ( ! empty($payments)) {
127 127
 
128 128
 			//Loop through payments
129
-			foreach ( $payments as $payment ) {
129
+			foreach ($payments as $payment) {
130 130
 
131
-				$payment_id = ( ! empty( $payment['ID'] ) ? absint( $payment['ID'] ) : ( ! empty( $payment->ID ) ? absint( $payment->ID ) : false ) );
132
-				$payment = new Give_Payment( $payment_id );
131
+				$payment_id = ( ! empty($payment['ID']) ? absint($payment['ID']) : ( ! empty($payment->ID) ? absint($payment->ID) : false));
132
+				$payment = new Give_Payment($payment_id);
133 133
 
134 134
 				// Prevent payments that have all ready been retrieved from a previous sales log from counting again.
135
-				if ( in_array( $payment->ID, $processed_payments ) ) {
135
+				if (in_array($payment->ID, $processed_payments)) {
136 136
 					continue;
137 137
 				}
138 138
 
139 139
 				// Verify accepted status.
140
-				if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
140
+				if ( ! in_array($payment->post_status, $accepted_statuses)) {
141 141
 					$processed_payments[] = $payment->ID;
142 142
 					continue;
143 143
 				}
144 144
 
145
-				$payment_item = $payment_items[ $payment->ID ];
145
+				$payment_item = $payment_items[$payment->ID];
146 146
 
147
-				$form_id = isset( $payment_item['id'] ) ? $payment_item['id'] : '';
147
+				$form_id = isset($payment_item['id']) ? $payment_item['id'] : '';
148 148
 
149 149
 				// Must have a form ID.
150
-				if ( empty( $form_id ) ) {
150
+				if (empty($form_id)) {
151 151
 					continue;
152 152
 				}
153 153
 
154 154
 				// Form ID must be within $all_forms array to be validated.
155
-				if ( ! in_array( $form_id, $all_forms ) ) {
155
+				if ( ! in_array($form_id, $all_forms)) {
156 156
 					continue;
157 157
 				}
158 158
 
159 159
 				// Set Sales count
160
-				$totals[ $form_id ]['sales'] = isset( $totals[ $form_id ]['sales'] ) ?
161
-					++ $totals[ $form_id ]['sales'] :
162
-					1;
160
+				$totals[$form_id]['sales'] = isset($totals[$form_id]['sales']) ?
161
+					++$totals[$form_id]['sales'] : 1;
163 162
 
164 163
 				// Set Total Earnings
165
-				$totals[ $form_id ]['earnings'] = isset( $totals[ $form_id ]['earnings'] ) ?
166
-					( $totals[ $form_id ]['earnings'] + $payment_item['price'] ) :
167
-					$payment_item['price'];
164
+				$totals[$form_id]['earnings'] = isset($totals[$form_id]['earnings']) ?
165
+					($totals[$form_id]['earnings'] + $payment_item['price']) : $payment_item['price'];
168 166
 
169 167
 				$processed_payments[] = $payment->ID;
170 168
 			}
171 169
 
172 170
 			// Get the list of form ids which does not contain any payment record.
173
-			$remaining_form_ids = array_diff( $all_forms, array_keys( $totals ) );
174
-			foreach ( $remaining_form_ids as $form_id ) {
171
+			$remaining_form_ids = array_diff($all_forms, array_keys($totals));
172
+			foreach ($remaining_form_ids as $form_id) {
175 173
 				//If array key doesn't exist, create it
176
-				if ( ! array_key_exists( $form_id, $totals ) ) {
177
-					$totals[ $form_id ] = array(
174
+				if ( ! array_key_exists($form_id, $totals)) {
175
+					$totals[$form_id] = array(
178 176
 						'sales'    => (int) 0,
179 177
 						'earnings' => (float) 0,
180 178
 					);
181 179
 				}
182 180
 			}
183 181
 
184
-			$this->store_data( 'give_temp_processed_payments', $processed_payments );
185
-			$this->store_data( 'give_temp_recount_all_stats', $totals );
182
+			$this->store_data('give_temp_processed_payments', $processed_payments);
183
+			$this->store_data('give_temp_recount_all_stats', $totals);
186 184
 
187 185
 			return true;
188 186
 		}
189 187
 
190 188
 
191
-		foreach ( $totals as $key => $stats ) {
192
-			give_update_meta( $key, '_give_form_sales', $stats['sales'] );
193
-			give_update_meta( $key, '_give_form_earnings', give_sanitize_amount_for_db( $stats['earnings'] ) );
189
+		foreach ($totals as $key => $stats) {
190
+			give_update_meta($key, '_give_form_sales', $stats['sales']);
191
+			give_update_meta($key, '_give_form_earnings', give_sanitize_amount_for_db($stats['earnings']));
194 192
 		}
195 193
 
196 194
 		return false;
@@ -205,20 +203,20 @@  discard block
 block discarded – undo
205 203
 	 */
206 204
 	public function get_percentage_complete() {
207 205
 
208
-		$total = $this->get_stored_data( 'give_recount_all_total' );
206
+		$total = $this->get_stored_data('give_recount_all_total');
209 207
 
210
-		if ( false === $total ) {
208
+		if (false === $total) {
211 209
 			$this->pre_fetch();
212
-			$total = $this->get_stored_data( 'give_recount_all_total' );
210
+			$total = $this->get_stored_data('give_recount_all_total');
213 211
 		}
214 212
 
215 213
 		$percentage = 100;
216 214
 
217
-		if ( $total > 0 ) {
218
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
215
+		if ($total > 0) {
216
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
219 217
 		}
220 218
 
221
-		if ( $percentage > 100 ) {
219
+		if ($percentage > 100) {
222 220
 			$percentage = 100;
223 221
 		}
224 222
 
@@ -232,8 +230,8 @@  discard block
 block discarded – undo
232 230
 	 *
233 231
 	 * @param array $request The Form Data passed into the batch processing
234 232
 	 */
235
-	public function set_properties( $request ) {
236
-		$this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false;
233
+	public function set_properties($request) {
234
+		$this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false;
237 235
 	}
238 236
 
239 237
 	/**
@@ -244,25 +242,25 @@  discard block
 block discarded – undo
244 242
 	 */
245 243
 	public function process_step() {
246 244
 
247
-		if ( ! $this->can_export() ) {
248
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
245
+		if ( ! $this->can_export()) {
246
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
249 247
 		}
250 248
 
251 249
 		$had_data = $this->get_data();
252 250
 
253
-		if ( $had_data ) {
251
+		if ($had_data) {
254 252
 			$this->done = false;
255 253
 
256 254
 			return true;
257 255
 		} else {
258
-			$this->delete_data( 'give_recount_total_' . $this->form_id );
259
-			$this->delete_data( 'give_recount_all_total' );
260
-			$this->delete_data( 'give_temp_recount_all_stats' );
261
-			$this->delete_data( 'give_temp_payment_items' );
262
-			$this->delete_data( 'give_temp_form_ids' );
263
-			$this->delete_data( 'give_temp_processed_payments' );
256
+			$this->delete_data('give_recount_total_'.$this->form_id);
257
+			$this->delete_data('give_recount_all_total');
258
+			$this->delete_data('give_temp_recount_all_stats');
259
+			$this->delete_data('give_temp_payment_items');
260
+			$this->delete_data('give_temp_form_ids');
261
+			$this->delete_data('give_temp_processed_payments');
264 262
 			$this->done    = true;
265
-			$this->message = esc_html__( 'Donation form income amounts and donation counts stats successfully recounted.', 'give' );
263
+			$this->message = esc_html__('Donation form income amounts and donation counts stats successfully recounted.', 'give');
266 264
 
267 265
 			return false;
268 266
 		}
@@ -298,70 +296,70 @@  discard block
 block discarded – undo
298 296
 	 */
299 297
 	public function pre_fetch() {
300 298
 
301
-		if ( 1 == $this->step ) {
302
-			$this->delete_data( 'give_temp_recount_all_total' );
303
-			$this->delete_data( 'give_temp_recount_all_stats' );
304
-			$this->delete_data( 'give_temp_payment_items' );
305
-			$this->delete_data( 'give_temp_processed_payments' );
306
-			$this->delete_data( 'give_temp_all_payments_data' );
299
+		if (1 == $this->step) {
300
+			$this->delete_data('give_temp_recount_all_total');
301
+			$this->delete_data('give_temp_recount_all_stats');
302
+			$this->delete_data('give_temp_payment_items');
303
+			$this->delete_data('give_temp_processed_payments');
304
+			$this->delete_data('give_temp_all_payments_data');
307 305
 		}
308 306
 
309
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
310
-		$total             = $this->get_stored_data( 'give_temp_recount_all_total' );
307
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
308
+		$total             = $this->get_stored_data('give_temp_recount_all_total');
311 309
 
312
-		if ( false === $total ) {
310
+		if (false === $total) {
313 311
 
314
-			$payment_items = $this->get_stored_data( 'give_temp_payment_items' );
312
+			$payment_items = $this->get_stored_data('give_temp_payment_items');
315 313
 
316
-			if ( false === $payment_items ) {
314
+			if (false === $payment_items) {
317 315
 				$payment_items = array();
318
-				$this->store_data( 'give_temp_payment_items', $payment_items );
316
+				$this->store_data('give_temp_payment_items', $payment_items);
319 317
 			}
320 318
 
321 319
 			$args = array(
322 320
 				'post_status'    => 'publish',
323 321
 				'post_type'      => 'give_forms',
324
-				'posts_per_page' => - 1,
322
+				'posts_per_page' => -1,
325 323
 				'fields'         => 'ids',
326 324
 			);
327 325
 
328
-			$all_forms = get_posts( $args );
326
+			$all_forms = get_posts($args);
329 327
 
330
-			$this->store_data( 'give_temp_form_ids', $all_forms );
328
+			$this->store_data('give_temp_form_ids', $all_forms);
331 329
 
332
-			$args = apply_filters( 'give_recount_form_stats_total_args', array(
330
+			$args = apply_filters('give_recount_form_stats_total_args', array(
333 331
 				'give_forms' => $all_forms,
334 332
 				'number'     => $this->per_step,
335 333
 				'status'     => $accepted_statuses,
336 334
 				'page'       => $this->step,
337 335
 				'output'     => 'payments',
338
-			) );
336
+			));
339 337
 
340
-			$payments_query = new Give_Payments_Query( $args );
338
+			$payments_query = new Give_Payments_Query($args);
341 339
 			$payments       = $payments_query->get_payments();
342 340
 
343
-			$total = wp_count_posts( 'give_payment' )->publish;
341
+			$total = wp_count_posts('give_payment')->publish;
344 342
 
345
-			$this->store_data( 'give_temp_all_payments_data', $payments );
343
+			$this->store_data('give_temp_all_payments_data', $payments);
346 344
 
347
-			if ( $payments ) {
345
+			if ($payments) {
348 346
 
349
-				foreach ( $payments as $payment ) {
347
+				foreach ($payments as $payment) {
350 348
 
351 349
 					$form_id = $payment->form_id;
352 350
 
353 351
 					//If for some reason somehow the form_ID isn't set check payment meta
354
-					if ( empty( $payment->form_id ) ) {
352
+					if (empty($payment->form_id)) {
355 353
 						$payment_meta = $payment->get_meta();
356
-						$form_id      = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0;
354
+						$form_id      = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0;
357 355
 					}
358 356
 
359
-					if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
357
+					if ( ! in_array($payment->post_status, $accepted_statuses)) {
360 358
 						continue;
361 359
 					}
362 360
 
363
-					if ( ! array_key_exists( $payment->ID, $payment_items ) ) {
364
-						$payment_items[ $payment->ID ] = array(
361
+					if ( ! array_key_exists($payment->ID, $payment_items)) {
362
+						$payment_items[$payment->ID] = array(
365 363
 							'id'         => $form_id,
366 364
 							'payment_id' => $payment->ID,
367 365
 							'price'      => $payment->total,
@@ -369,8 +367,8 @@  discard block
 block discarded – undo
369 367
 					}
370 368
 				}
371 369
 			}
372
-			$this->store_data( 'give_temp_payment_items', $payment_items );
373
-			$this->store_data( 'give_recount_all_total', $total );
370
+			$this->store_data('give_temp_payment_items', $payment_items);
371
+			$this->store_data('give_recount_all_total', $total);
374 372
 		}
375 373
 
376 374
 	}
@@ -384,17 +382,17 @@  discard block
 block discarded – undo
384 382
 	 *
385 383
 	 * @return mixed       Returns the data from the database
386 384
 	 */
387
-	private function get_stored_data( $key ) {
385
+	private function get_stored_data($key) {
388 386
 		global $wpdb;
389
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
390
-		if ( empty( $value ) ) {
387
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
388
+		if (empty($value)) {
391 389
 			return false;
392 390
 		}
393 391
 
394
-		$maybe_json = json_decode( $value );
392
+		$maybe_json = json_decode($value);
395 393
 
396
-		if ( ! is_null( $maybe_json ) ) {
397
-			$value = json_decode( $value, true );
394
+		if ( ! is_null($maybe_json)) {
395
+			$value = json_decode($value, true);
398 396
 		}
399 397
 
400 398
 		return $value;
@@ -410,10 +408,10 @@  discard block
 block discarded – undo
410 408
 	 *
411 409
 	 * @return void
412 410
 	 */
413
-	private function store_data( $key, $value ) {
411
+	private function store_data($key, $value) {
414 412
 		global $wpdb;
415 413
 
416
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
414
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
417 415
 
418 416
 		$data = array(
419 417
 			'option_name'  => $key,
@@ -427,7 +425,7 @@  discard block
 block discarded – undo
427 425
 			'%s',
428 426
 		);
429 427
 
430
-		$wpdb->replace( $wpdb->options, $data, $formats );
428
+		$wpdb->replace($wpdb->options, $data, $formats);
431 429
 	}
432 430
 
433 431
 	/**
@@ -439,9 +437,9 @@  discard block
 block discarded – undo
439 437
 	 *
440 438
 	 * @return void
441 439
 	 */
442
-	private function delete_data( $key ) {
440
+	private function delete_data($key) {
443 441
 		global $wpdb;
444
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
442
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
445 443
 	}
446 444
 
447 445
 }
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-single-donor-stats.php 1 patch
Spacing   +73 added lines, -73 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
 
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 	/**
47 47
 	 * Constructor.
48 48
 	 */
49
-	public function __construct( $_step = 1 ) {
50
-		parent::__construct( $_step );
49
+	public function __construct($_step = 1) {
50
+		parent::__construct($_step);
51 51
 
52 52
 		$this->is_writable = true;
53 53
 	}
@@ -62,40 +62,40 @@  discard block
 block discarded – undo
62 62
 	 */
63 63
 	public function get_data() {
64 64
 
65
-		$donor    = new Give_Donor( $this->customer_id );
66
-		$payments = $this->get_stored_data( 'give_recount_donor_payments_' . $donor->id );
65
+		$donor    = new Give_Donor($this->customer_id);
66
+		$payments = $this->get_stored_data('give_recount_donor_payments_'.$donor->id);
67 67
 
68
-		$offset     = ( $this->step - 1 ) * $this->per_step;
69
-		$step_items = array_slice( $payments, $offset, $this->per_step );
68
+		$offset     = ($this->step - 1) * $this->per_step;
69
+		$step_items = array_slice($payments, $offset, $this->per_step);
70 70
 
71
-		if ( count( $step_items ) > 0 ) {
72
-			$pending_total = (float) $this->get_stored_data( 'give_stats_donor_pending_total' . $donor->id );
71
+		if (count($step_items) > 0) {
72
+			$pending_total = (float) $this->get_stored_data('give_stats_donor_pending_total'.$donor->id);
73 73
 			$step_total    = 0;
74 74
 
75
-			$found_payment_ids = $this->get_stored_data( 'give_stats_found_payments_' . $donor->id );
75
+			$found_payment_ids = $this->get_stored_data('give_stats_found_payments_'.$donor->id);
76 76
 
77
-			foreach ( $step_items as $payment ) {
78
-				$payment = get_post( $payment->ID );
77
+			foreach ($step_items as $payment) {
78
+				$payment = get_post($payment->ID);
79 79
 
80
-				if ( is_null( $payment ) || is_wp_error( $payment ) || 'give_payment' !== $payment->post_type ) {
80
+				if (is_null($payment) || is_wp_error($payment) || 'give_payment' !== $payment->post_type) {
81 81
 
82
-					$missing_payments   = $this->get_stored_data( 'give_stats_missing_payments' . $donor->id );
82
+					$missing_payments   = $this->get_stored_data('give_stats_missing_payments'.$donor->id);
83 83
 					$missing_payments[] = $payment->ID;
84
-					$this->store_data( 'give_stats_missing_payments' . $donor->id, $missing_payments );
84
+					$this->store_data('give_stats_missing_payments'.$donor->id, $missing_payments);
85 85
 
86 86
 					continue;
87 87
 				}
88 88
 
89 89
 				$should_process_payment = 'publish' == $payment->post_status ? true : false;
90
-				$should_process_payment = apply_filters( 'give_donor_recount_should_process_donation', $should_process_payment, $payment );
90
+				$should_process_payment = apply_filters('give_donor_recount_should_process_donation', $should_process_payment, $payment);
91 91
 
92
-				if ( true === $should_process_payment ) {
92
+				if (true === $should_process_payment) {
93 93
 
94 94
 					$found_payment_ids[] = $payment->ID;
95 95
 
96
-					if ( apply_filters( 'give_donor_recount_should_increase_value', true, $payment ) ) {
97
-						$payment_amount = (float) give_donation_amount( $payment->ID, array( 'type' => 'stats' ) );
98
-						$step_total     += $payment_amount;
96
+					if (apply_filters('give_donor_recount_should_increase_value', true, $payment)) {
97
+						$payment_amount = (float) give_donation_amount($payment->ID, array('type' => 'stats'));
98
+						$step_total += $payment_amount;
99 99
 					}
100 100
 
101 101
 				}
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 			}
104 104
 
105 105
 			$updated_total = $pending_total + $step_total;
106
-			$this->store_data( 'give_stats_donor_pending_total' . $donor->id, $updated_total );
107
-			$this->store_data( 'give_stats_found_payments_' . $donor->id, $found_payment_ids );
106
+			$this->store_data('give_stats_donor_pending_total'.$donor->id, $updated_total);
107
+			$this->store_data('give_stats_found_payments_'.$donor->id, $found_payment_ids);
108 108
 
109 109
 			return true;
110 110
 		}
@@ -121,16 +121,16 @@  discard block
 block discarded – undo
121 121
 	 */
122 122
 	public function get_percentage_complete() {
123 123
 
124
-		$payments = $this->get_stored_data( 'give_recount_donor_payments_' . $this->customer_id );
125
-		$total    = count( $payments );
124
+		$payments = $this->get_stored_data('give_recount_donor_payments_'.$this->customer_id);
125
+		$total    = count($payments);
126 126
 
127 127
 		$percentage = 100;
128 128
 
129
-		if ( $total > 0 ) {
130
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
129
+		if ($total > 0) {
130
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
131 131
 		}
132 132
 
133
-		if ( $percentage > 100 ) {
133
+		if ($percentage > 100) {
134 134
 			$percentage = 100;
135 135
 		}
136 136
 
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
 	 *
145 145
 	 * @param array $request The Form Data passed into the batch processing
146 146
 	 */
147
-	public function set_properties( $request ) {
148
-		$this->customer_id = isset( $request['customer_id'] ) ? sanitize_text_field( $request['customer_id'] ) : false;
147
+	public function set_properties($request) {
148
+		$this->customer_id = isset($request['customer_id']) ? sanitize_text_field($request['customer_id']) : false;
149 149
 	}
150 150
 
151 151
 	/**
@@ -156,53 +156,53 @@  discard block
 block discarded – undo
156 156
 	 */
157 157
 	public function process_step() {
158 158
 
159
-		if ( ! $this->can_export() ) {
160
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
159
+		if ( ! $this->can_export()) {
160
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
161 161
 		}
162 162
 
163 163
 		$had_data = $this->get_data();
164 164
 
165
-		if ( $had_data ) {
165
+		if ($had_data) {
166 166
 			$this->done = false;
167 167
 
168 168
 			return true;
169 169
 		} else {
170
-			$donor       = new Give_Donor( $this->customer_id );
171
-			$payment_ids = get_option( 'give_stats_found_payments_' . $donor->id, array() );
172
-			$this->delete_data( 'give_stats_found_payments_' . $donor->id );
170
+			$donor       = new Give_Donor($this->customer_id);
171
+			$payment_ids = get_option('give_stats_found_payments_'.$donor->id, array());
172
+			$this->delete_data('give_stats_found_payments_'.$donor->id);
173 173
 
174
-			$removed_payments = array_unique( get_option( 'give_stats_missing_payments' . $donor->id, array() ) );
174
+			$removed_payments = array_unique(get_option('give_stats_missing_payments'.$donor->id, array()));
175 175
 
176 176
 			// Find non-existing payments (deleted) and total up the donation count
177 177
 			$purchase_count = 0;
178
-			foreach ( $payment_ids as $key => $payment_id ) {
179
-				if ( in_array( $payment_id, $removed_payments ) ) {
180
-					unset( $payment_ids[ $key ] );
178
+			foreach ($payment_ids as $key => $payment_id) {
179
+				if (in_array($payment_id, $removed_payments)) {
180
+					unset($payment_ids[$key]);
181 181
 					continue;
182 182
 				}
183 183
 
184
-				$payment = get_post( $payment_id );
185
-				if ( apply_filters( 'give_donor_recount_should_increase_count', true, $payment ) ) {
186
-					$purchase_count ++;
184
+				$payment = get_post($payment_id);
185
+				if (apply_filters('give_donor_recount_should_increase_count', true, $payment)) {
186
+					$purchase_count++;
187 187
 				}
188 188
 			}
189 189
 
190
-			$this->delete_data( 'give_stats_missing_payments' . $donor->id );
190
+			$this->delete_data('give_stats_missing_payments'.$donor->id);
191 191
 
192
-			$pending_total = $this->get_stored_data( 'give_stats_donor_pending_total' . $donor->id );
193
-			$this->delete_data( 'give_stats_donor_pending_total' . $donor->id );
194
-			$this->delete_data( 'give_recount_donor_stats_' . $donor->id );
195
-			$this->delete_data( 'give_recount_donor_payments_' . $this->customer_id );
192
+			$pending_total = $this->get_stored_data('give_stats_donor_pending_total'.$donor->id);
193
+			$this->delete_data('give_stats_donor_pending_total'.$donor->id);
194
+			$this->delete_data('give_recount_donor_stats_'.$donor->id);
195
+			$this->delete_data('give_recount_donor_payments_'.$this->customer_id);
196 196
 
197
-			$payment_ids = implode( ',', $payment_ids );
198
-			$donor->update( array(
197
+			$payment_ids = implode(',', $payment_ids);
198
+			$donor->update(array(
199 199
 				'payment_ids'    => $payment_ids,
200 200
 				'purchase_count' => $purchase_count,
201 201
 				'purchase_value' => $pending_total,
202
-			) );
202
+			));
203 203
 
204 204
 			$this->done    = true;
205
-			$this->message = esc_html__( 'Donor stats have been successfully recounted.', 'give' );
205
+			$this->message = esc_html__('Donor stats have been successfully recounted.', 'give');
206 206
 
207 207
 			return false;
208 208
 		}
@@ -235,26 +235,26 @@  discard block
 block discarded – undo
235 235
 	 * @return void
236 236
 	 */
237 237
 	public function pre_fetch() {
238
-		if ( $this->step === 1 ) {
239
-			$allowed_payment_status = apply_filters( 'give_recount_donors_donation_statuses', give_get_payment_status_keys() );
238
+		if ($this->step === 1) {
239
+			$allowed_payment_status = apply_filters('give_recount_donors_donation_statuses', give_get_payment_status_keys());
240 240
 
241 241
 			// Before we start, let's zero out the customer's data
242
-			$donor = new Give_Donor( $this->customer_id );
243
-			$donor->update( array( 'purchase_value' => give_format_amount( 0, array( 'sanitize' => false ) ), 'purchase_count' => 0 ) );
242
+			$donor = new Give_Donor($this->customer_id);
243
+			$donor->update(array('purchase_value' => give_format_amount(0, array('sanitize' => false)), 'purchase_count' => 0));
244 244
 
245
-			$attached_payment_ids = explode( ',', $donor->payment_ids );
245
+			$attached_payment_ids = explode(',', $donor->payment_ids);
246 246
 
247 247
 			$attached_args = array(
248 248
 				'post__in' => $attached_payment_ids,
249
-				'number'   => - 1,
249
+				'number'   => -1,
250 250
 				'status'   => $allowed_payment_status,
251 251
 			);
252 252
 
253
-			$attached_payments = give_get_payments( $attached_args );
253
+			$attached_payments = give_get_payments($attached_args);
254 254
 
255 255
 			$unattached_args = array(
256 256
 				'post__not_in' => $attached_payment_ids,
257
-				'number'       => - 1,
257
+				'number'       => -1,
258 258
 				'status'       => $allowed_payment_status,
259 259
 				'meta_query'   => array(
260 260
 					array(
@@ -264,11 +264,11 @@  discard block
 block discarded – undo
264 264
 				),
265 265
 			);
266 266
 
267
-			$unattached_payments = give_get_payments( $unattached_args );
267
+			$unattached_payments = give_get_payments($unattached_args);
268 268
 
269
-			$payments = array_merge( $attached_payments, $unattached_payments );
269
+			$payments = array_merge($attached_payments, $unattached_payments);
270 270
 
271
-			$this->store_data( 'give_recount_donor_payments_' . $donor->id, $payments );
271
+			$this->store_data('give_recount_donor_payments_'.$donor->id, $payments);
272 272
 		}
273 273
 	}
274 274
 
@@ -281,17 +281,17 @@  discard block
 block discarded – undo
281 281
 	 *
282 282
 	 * @return mixed       Returns the data from the database
283 283
 	 */
284
-	private function get_stored_data( $key ) {
284
+	private function get_stored_data($key) {
285 285
 		global $wpdb;
286
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
286
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
287 287
 
288
-		if ( empty( $value ) ) {
288
+		if (empty($value)) {
289 289
 			return false;
290 290
 		}
291 291
 
292
-		$maybe_json = json_decode( $value );
293
-		if ( ! is_null( $maybe_json ) ) {
294
-			$value = json_decode( $value, true );
292
+		$maybe_json = json_decode($value);
293
+		if ( ! is_null($maybe_json)) {
294
+			$value = json_decode($value, true);
295 295
 		}
296 296
 
297 297
 		return $value;
@@ -307,10 +307,10 @@  discard block
 block discarded – undo
307 307
 	 *
308 308
 	 * @return void
309 309
 	 */
310
-	private function store_data( $key, $value ) {
310
+	private function store_data($key, $value) {
311 311
 		global $wpdb;
312 312
 
313
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
313
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
314 314
 
315 315
 		$data = array(
316 316
 			'option_name'  => $key,
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 			'%s',
325 325
 		);
326 326
 
327
-		$wpdb->replace( $wpdb->options, $data, $formats );
327
+		$wpdb->replace($wpdb->options, $data, $formats);
328 328
 	}
329 329
 
330 330
 	/**
@@ -336,9 +336,9 @@  discard block
 block discarded – undo
336 336
 	 *
337 337
 	 * @return void
338 338
 	 */
339
-	private function delete_data( $key ) {
339
+	private function delete_data($key) {
340 340
 		global $wpdb;
341
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
341
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
342 342
 	}
343 343
 
344 344
 }
Please login to merge, or discard this patch.