Completed
Pull Request — master (#1857)
by Mehul
18:30
created
includes/payments/actions.php 1 patch
Spacing   +49 added lines, -49 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
 
@@ -28,21 +28,21 @@  discard block
 block discarded – undo
28 28
  *
29 29
  * @return void
30 30
  */
31
-function give_complete_purchase( $payment_id, $new_status, $old_status ) {
31
+function give_complete_purchase($payment_id, $new_status, $old_status) {
32 32
 
33 33
 	// Make sure that payments are only completed once.
34
-	if ( $old_status == 'publish' || $old_status == 'complete' ) {
34
+	if ($old_status == 'publish' || $old_status == 'complete') {
35 35
 		return;
36 36
 	}
37 37
 
38 38
 	// Make sure the payment completion is only processed when new status is complete.
39
-	if ( $new_status != 'publish' && $new_status != 'complete' ) {
39
+	if ($new_status != 'publish' && $new_status != 'complete') {
40 40
 		return;
41 41
 	}
42 42
 
43
-	$payment = new Give_Payment( $payment_id );
43
+	$payment = new Give_Payment($payment_id);
44 44
 
45
-	$creation_date  = get_post_field( 'post_date', $payment_id, 'raw' );
45
+	$creation_date  = get_post_field('post_date', $payment_id, 'raw');
46 46
 	$payment_meta   = $payment->payment_meta;
47 47
 	$completed_date = $payment->completed_date;
48 48
 	$user_info      = $payment->user_info;
@@ -58,12 +58,12 @@  discard block
 block discarded – undo
58 58
 	 *
59 59
 	 * @param int $payment_id The ID of the payment.
60 60
 	 */
61
-	do_action( 'give_pre_complete_donation', $payment_id );
61
+	do_action('give_pre_complete_donation', $payment_id);
62 62
 
63 63
 	// Ensure these actions only run once, ever.
64
-	if ( empty( $completed_date ) ) {
64
+	if (empty($completed_date)) {
65 65
 
66
-		give_record_donation_in_log( $form_id, $payment_id, $price_id, $creation_date );
66
+		give_record_donation_in_log($form_id, $payment_id, $price_id, $creation_date);
67 67
 
68 68
 		/**
69 69
 		 * Fires after logging donation record.
@@ -74,29 +74,29 @@  discard block
 block discarded – undo
74 74
 		 * @param int   $payment_id   The ID number of the payment.
75 75
 		 * @param array $payment_meta The payment meta.
76 76
 		 */
77
-		do_action( 'give_complete_form_donation', $form_id, $payment_id, $payment_meta );
77
+		do_action('give_complete_form_donation', $form_id, $payment_id, $payment_meta);
78 78
 
79 79
 	}
80 80
 
81 81
 	// Increase the earnings for this form ID.
82
-	give_increase_earnings( $form_id, $amount );
83
-	give_increase_donation_count( $form_id );
82
+	give_increase_earnings($form_id, $amount);
83
+	give_increase_donation_count($form_id);
84 84
 
85 85
 	// @todo: Refresh only range related stat cache
86 86
 	give_delete_donation_stats();
87 87
 
88 88
 	// Increase the donor's donation stats.
89
-	$donor = new Give_Donor( $donor_id );
89
+	$donor = new Give_Donor($donor_id);
90 90
 	$donor->increase_purchase_count();
91
-	$donor->increase_value( $amount );
91
+	$donor->increase_value($amount);
92 92
 
93
-	give_increase_total_earnings( $amount );
93
+	give_increase_total_earnings($amount);
94 94
 
95 95
 	// Ensure this action only runs once ever.
96
-	if ( empty( $completed_date ) ) {
96
+	if (empty($completed_date)) {
97 97
 
98 98
 		// Save the completed date.
99
-		$payment->completed_date = current_time( 'mysql' );
99
+		$payment->completed_date = current_time('mysql');
100 100
 		$payment->save();
101 101
 
102 102
 		/**
@@ -106,12 +106,12 @@  discard block
 block discarded – undo
106 106
 		 *
107 107
 		 * @param int $payment_id The ID of the payment.
108 108
 		 */
109
-		do_action( 'give_complete_donation', $payment_id );
109
+		do_action('give_complete_donation', $payment_id);
110 110
 	}
111 111
 
112 112
 }
113 113
 
114
-add_action( 'give_update_payment_status', 'give_complete_purchase', 100, 3 );
114
+add_action('give_update_payment_status', 'give_complete_purchase', 100, 3);
115 115
 
116 116
 
117 117
 /**
@@ -125,20 +125,20 @@  discard block
 block discarded – undo
125 125
  *
126 126
  * @return void
127 127
  */
128
-function give_record_status_change( $payment_id, $new_status, $old_status ) {
128
+function give_record_status_change($payment_id, $new_status, $old_status) {
129 129
 
130 130
 	// Get the list of statuses so that status in the payment note can be translated.
131 131
 	$stati      = give_get_payment_statuses();
132
-	$old_status = isset( $stati[ $old_status ] ) ? $stati[ $old_status ] : $old_status;
133
-	$new_status = isset( $stati[ $new_status ] ) ? $stati[ $new_status ] : $new_status;
132
+	$old_status = isset($stati[$old_status]) ? $stati[$old_status] : $old_status;
133
+	$new_status = isset($stati[$new_status]) ? $stati[$new_status] : $new_status;
134 134
 
135 135
 	// translators: 1: old status 2: new status.
136
-	$status_change = sprintf( esc_html__( 'Status changed from %1$s to %2$s.', 'give' ), $old_status, $new_status );
136
+	$status_change = sprintf(esc_html__('Status changed from %1$s to %2$s.', 'give'), $old_status, $new_status);
137 137
 
138
-	give_insert_payment_note( $payment_id, $status_change );
138
+	give_insert_payment_note($payment_id, $status_change);
139 139
 }
140 140
 
141
-add_action( 'give_update_payment_status', 'give_record_status_change', 100, 3 );
141
+add_action('give_update_payment_status', 'give_record_status_change', 100, 3);
142 142
 
143 143
 
144 144
 /**
@@ -154,25 +154,25 @@  discard block
 block discarded – undo
154 154
  *
155 155
  * @return void
156 156
  */
157
-function give_update_old_payments_with_totals( $data ) {
158
-	if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_upgrade_payments_nonce' ) ) {
157
+function give_update_old_payments_with_totals($data) {
158
+	if ( ! wp_verify_nonce($data['_wpnonce'], 'give_upgrade_payments_nonce')) {
159 159
 		return;
160 160
 	}
161 161
 
162
-	if ( get_option( 'give_payment_totals_upgraded' ) ) {
162
+	if (get_option('give_payment_totals_upgraded')) {
163 163
 		return;
164 164
 	}
165 165
 
166
-	$payments = give_get_payments( array(
166
+	$payments = give_get_payments(array(
167 167
 		'offset' => 0,
168
-		'number' => - 1,
168
+		'number' => -1,
169 169
 		'mode'   => 'all',
170
-	) );
170
+	));
171 171
 
172
-	if ( $payments ) {
173
-		foreach ( $payments as $payment ) {
172
+	if ($payments) {
173
+		foreach ($payments as $payment) {
174 174
 
175
-			$payment = new Give_Payment( $payment->ID );
175
+			$payment = new Give_Payment($payment->ID);
176 176
 			$meta    = $payment->get_meta();
177 177
 
178 178
 			$payment->total = $meta['amount'];
@@ -181,10 +181,10 @@  discard block
 block discarded – undo
181 181
 		}
182 182
 	}
183 183
 
184
-	add_option( 'give_payment_totals_upgraded', 1 );
184
+	add_option('give_payment_totals_upgraded', 1);
185 185
 }
186 186
 
187
-add_action( 'give_upgrade_payments', 'give_update_old_payments_with_totals' );
187
+add_action('give_upgrade_payments', 'give_update_old_payments_with_totals');
188 188
 
189 189
 /**
190 190
  * Mark Abandoned Donations
@@ -198,17 +198,17 @@  discard block
 block discarded – undo
198 198
 function give_mark_abandoned_donations() {
199 199
 	$args = array(
200 200
 		'status' => 'pending',
201
-		'number' => - 1,
201
+		'number' => -1,
202 202
 		'output' => 'give_payments',
203 203
 	);
204 204
 
205
-	add_filter( 'posts_where', 'give_filter_where_older_than_week' );
205
+	add_filter('posts_where', 'give_filter_where_older_than_week');
206 206
 
207
-	$payments = give_get_payments( $args );
207
+	$payments = give_get_payments($args);
208 208
 
209
-	remove_filter( 'posts_where', 'give_filter_where_older_than_week' );
209
+	remove_filter('posts_where', 'give_filter_where_older_than_week');
210 210
 
211
-	if ( $payments ) {
211
+	if ($payments) {
212 212
 		/**
213 213
 		 * Filter payment gateways:  Used to set payment gateways which can be skip while transferring pending payment to abandon.
214 214
 		 *
@@ -216,13 +216,13 @@  discard block
 block discarded – undo
216 216
 		 *
217 217
 		 * @param array $skip_payment_gateways Array of payment gateways
218 218
 		 */
219
-		$skip_payment_gateways = apply_filters( 'give_mark_abandoned_donation_gateways', array( 'offline' ) );
219
+		$skip_payment_gateways = apply_filters('give_mark_abandoned_donation_gateways', array('offline'));
220 220
 
221
-		foreach ( $payments as $payment ) {
222
-			$gateway = give_get_payment_gateway( $payment );
221
+		foreach ($payments as $payment) {
222
+			$gateway = give_get_payment_gateway($payment);
223 223
 
224 224
 			// Skip payment gateways.
225
-			if ( in_array( $gateway, $skip_payment_gateways ) ) {
225
+			if (in_array($gateway, $skip_payment_gateways)) {
226 226
 				continue;
227 227
 			}
228 228
 
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 	}
233 233
 }
234 234
 
235
-add_action( 'give_weekly_scheduled_events', 'give_mark_abandoned_donations' );
235
+add_action('give_weekly_scheduled_events', 'give_mark_abandoned_donations');
236 236
 
237 237
 
238 238
 /**
@@ -244,12 +244,12 @@  discard block
 block discarded – undo
244 244
  *
245 245
  * @return void
246 246
  */
247
-function give_refresh_thismonth_stat_transients( $payment_ID ) {
247
+function give_refresh_thismonth_stat_transients($payment_ID) {
248 248
 	// Monthly stats.
249
-	Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) );
249
+	Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
250 250
 
251 251
 	// @todo: Refresh only range related stat cache
252 252
 	give_delete_donation_stats();
253 253
 }
254 254
 
255
-add_action( 'save_post_give_payment', 'give_refresh_thismonth_stat_transients' );
255
+add_action('save_post_give_payment', 'give_refresh_thismonth_stat_transients');
Please login to merge, or discard this patch.
includes/payments/class-payments-query.php 1 patch
Spacing   +106 added lines, -106 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
 
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 * @param  $args array The array of arguments that can be passed in and used for setting up this payment query.
57 57
 	 */
58
-	public function __construct( $args = array() ) {
58
+	public function __construct($args = array()) {
59 59
 		$defaults = array(
60 60
 			'output'          => 'payments',
61
-			'post_type'       => array( 'give_payment' ),
61
+			'post_type'       => array('give_payment'),
62 62
 			'start_date'      => false,
63 63
 			'end_date'        => false,
64 64
 			'number'          => 20,
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 			'give_forms'      => null,
80 80
 		);
81 81
 
82
-		$this->args = wp_parse_args( $args, $defaults );
82
+		$this->args = wp_parse_args($args, $defaults);
83 83
 
84 84
 		$this->init();
85 85
 	}
@@ -93,11 +93,11 @@  discard block
 block discarded – undo
93 93
 	 * @param $query_var
94 94
 	 * @param $value
95 95
 	 */
96
-	public function __set( $query_var, $value ) {
97
-		if ( in_array( $query_var, array( 'meta_query', 'tax_query' ) ) ) {
98
-			$this->args[ $query_var ][] = $value;
96
+	public function __set($query_var, $value) {
97
+		if (in_array($query_var, array('meta_query', 'tax_query'))) {
98
+			$this->args[$query_var][] = $value;
99 99
 		} else {
100
-			$this->args[ $query_var ] = $value;
100
+			$this->args[$query_var] = $value;
101 101
 		}
102 102
 	}
103 103
 
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
 	 *
110 110
 	 * @param $query_var
111 111
 	 */
112
-	public function __unset( $query_var ) {
113
-		unset( $this->args[ $query_var ] );
112
+	public function __unset($query_var) {
113
+		unset($this->args[$query_var]);
114 114
 	}
115 115
 
116 116
 	/**
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 		$this->children();
146 146
 		$this->give_forms();
147 147
 
148
-		add_filter( 'posts_orderby', array( $this, 'custom_orderby' ), 10, 2 );
148
+		add_filter('posts_orderby', array($this, 'custom_orderby'), 10, 2);
149 149
 	}
150 150
 
151 151
 	/**
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	 */
157 157
 	private function unset_filters() {
158 158
 		$this->date_filter_post();
159
-		remove_filter( 'posts_orderby', array( $this, 'custom_orderby' ) );
159
+		remove_filter('posts_orderby', array($this, 'custom_orderby'));
160 160
 	}
161 161
 
162 162
 
@@ -181,30 +181,30 @@  discard block
 block discarded – undo
181 181
 		 *
182 182
 		 * @param Give_Payments_Query $this Payments query object.
183 183
 		 */
184
-		do_action( 'give_pre_get_payments', $this );
184
+		do_action('give_pre_get_payments', $this);
185 185
 
186 186
 		// Modify the query/query arguments before we retrieve payments.
187 187
 		$this->set_filters();
188 188
 
189
-		$query = new WP_Query( $this->args );
189
+		$query = new WP_Query($this->args);
190 190
 
191 191
 		$custom_output = array(
192 192
 			'payments',
193 193
 			'give_payments',
194 194
 		);
195 195
 
196
-		if ( ! in_array( $this->args['output'], $custom_output ) ) {
196
+		if ( ! in_array($this->args['output'], $custom_output)) {
197 197
 			return $query->posts;
198 198
 		}
199 199
 
200
-		if ( $query->have_posts() ) {
201
-			while ( $query->have_posts() ) {
200
+		if ($query->have_posts()) {
201
+			while ($query->have_posts()) {
202 202
 				$query->the_post();
203 203
 
204 204
 				$payment_id = get_post()->ID;
205
-				$payment    = new Give_Payment( $payment_id );
205
+				$payment    = new Give_Payment($payment_id);
206 206
 
207
-				$this->payments[] = apply_filters( 'give_payment', $payment, $payment_id, $this );
207
+				$this->payments[] = apply_filters('give_payment', $payment, $payment_id, $this);
208 208
 			}
209 209
 
210 210
 			wp_reset_postdata();
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 		 *
222 222
 		 * @param Give_Payments_Query $this Payments query object.
223 223
 		 */
224
-		do_action( 'give_post_get_payments', $this );
224
+		do_action('give_post_get_payments', $this);
225 225
 
226 226
 		return $this->payments;
227 227
 	}
@@ -235,13 +235,13 @@  discard block
 block discarded – undo
235 235
 	 * @return void
236 236
 	 */
237 237
 	public function date_filter_pre() {
238
-		if ( ! ( $this->args['start_date'] || $this->args['end_date'] ) ) {
238
+		if ( ! ($this->args['start_date'] || $this->args['end_date'])) {
239 239
 			return;
240 240
 		}
241 241
 
242
-		$this->setup_dates( $this->args['start_date'], $this->args['end_date'] );
242
+		$this->setup_dates($this->args['start_date'], $this->args['end_date']);
243 243
 
244
-		add_filter( 'posts_where', array( $this, 'payments_where' ) );
244
+		add_filter('posts_where', array($this, 'payments_where'));
245 245
 	}
246 246
 
247 247
 	/**
@@ -254,11 +254,11 @@  discard block
 block discarded – undo
254 254
 	 * @return void
255 255
 	 */
256 256
 	public function date_filter_post() {
257
-		if ( ! ( $this->args['start_date'] || $this->args['end_date'] ) ) {
257
+		if ( ! ($this->args['start_date'] || $this->args['end_date'])) {
258 258
 			return;
259 259
 		}
260 260
 
261
-		remove_filter( 'posts_where', array( $this, 'payments_where' ) );
261
+		remove_filter('posts_where', array($this, 'payments_where'));
262 262
 	}
263 263
 
264 264
 	/**
@@ -270,12 +270,12 @@  discard block
 block discarded – undo
270 270
 	 * @return void
271 271
 	 */
272 272
 	public function status() {
273
-		if ( ! isset ( $this->args['status'] ) ) {
273
+		if ( ! isset ($this->args['status'])) {
274 274
 			return;
275 275
 		}
276 276
 
277
-		$this->__set( 'post_status', $this->args['status'] );
278
-		$this->__unset( 'status' );
277
+		$this->__set('post_status', $this->args['status']);
278
+		$this->__unset('status');
279 279
 	}
280 280
 
281 281
 	/**
@@ -287,12 +287,12 @@  discard block
 block discarded – undo
287 287
 	 * @return void
288 288
 	 */
289 289
 	public function page() {
290
-		if ( ! isset ( $this->args['page'] ) ) {
290
+		if ( ! isset ($this->args['page'])) {
291 291
 			return;
292 292
 		}
293 293
 
294
-		$this->__set( 'paged', $this->args['page'] );
295
-		$this->__unset( 'page' );
294
+		$this->__set('paged', $this->args['page']);
295
+		$this->__unset('page');
296 296
 	}
297 297
 
298 298
 	/**
@@ -305,17 +305,17 @@  discard block
 block discarded – undo
305 305
 	 */
306 306
 	public function per_page() {
307 307
 
308
-		if ( ! isset( $this->args['number'] ) ) {
308
+		if ( ! isset($this->args['number'])) {
309 309
 			return;
310 310
 		}
311 311
 
312
-		if ( $this->args['number'] == - 1 ) {
313
-			$this->__set( 'nopaging', true );
312
+		if ($this->args['number'] == - 1) {
313
+			$this->__set('nopaging', true);
314 314
 		} else {
315
-			$this->__set( 'posts_per_page', $this->args['number'] );
315
+			$this->__set('posts_per_page', $this->args['number']);
316 316
 		}
317 317
 
318
-		$this->__unset( 'number' );
318
+		$this->__unset('number');
319 319
 	}
320 320
 
321 321
 	/**
@@ -327,12 +327,12 @@  discard block
 block discarded – undo
327 327
 	 * @return void
328 328
 	 */
329 329
 	public function month() {
330
-		if ( ! isset ( $this->args['month'] ) ) {
330
+		if ( ! isset ($this->args['month'])) {
331 331
 			return;
332 332
 		}
333 333
 
334
-		$this->__set( 'monthnum', $this->args['month'] );
335
-		$this->__unset( 'month' );
334
+		$this->__set('monthnum', $this->args['month']);
335
+		$this->__unset('month');
336 336
 	}
337 337
 
338 338
 	/**
@@ -344,23 +344,23 @@  discard block
 block discarded – undo
344 344
 	 * @return void
345 345
 	 */
346 346
 	public function orderby() {
347
-		switch ( $this->args['orderby'] ) {
347
+		switch ($this->args['orderby']) {
348 348
 			case 'amount' :
349
-				$this->__set( 'orderby', 'meta_value_num' );
350
-				$this->__set( 'meta_key', '_give_payment_total' );
349
+				$this->__set('orderby', 'meta_value_num');
350
+				$this->__set('meta_key', '_give_payment_total');
351 351
 				break;
352 352
 
353 353
 			case 'status' :
354
-				$this->__set( 'orderby', 'post_status' );
354
+				$this->__set('orderby', 'post_status');
355 355
 				break;
356 356
 
357 357
 			case 'donation_form' :
358
-				$this->__set( 'orderby', 'meta_value' );
359
-				$this->__set( 'meta_key', '_give_payment_form_title' );
358
+				$this->__set('orderby', 'meta_value');
359
+				$this->__set('meta_key', '_give_payment_form_title');
360 360
 				break;
361 361
 
362 362
 			default :
363
-				$this->__set( 'orderby', $this->args['orderby'] );
363
+				$this->__set('orderby', $this->args['orderby']);
364 364
 				break;
365 365
 		}
366 366
 	}
@@ -377,15 +377,15 @@  discard block
 block discarded – undo
377 377
 	 *
378 378
 	 * @return mixed
379 379
 	 */
380
-	public function custom_orderby( $order, $query ) {
381
-		$post_types = is_array( $query->query['post_type'] ) ? $query->query['post_type'] : array( $query->query['post_type'] );
382
-		if ( ! in_array( 'give_payment', $post_types ) || is_array( $query->query['orderby'] ) ) {
380
+	public function custom_orderby($order, $query) {
381
+		$post_types = is_array($query->query['post_type']) ? $query->query['post_type'] : array($query->query['post_type']);
382
+		if ( ! in_array('give_payment', $post_types) || is_array($query->query['orderby'])) {
383 383
 			return $order;
384 384
 		}
385 385
 
386
-		switch ( $query->query['orderby'] ) {
386
+		switch ($query->query['orderby']) {
387 387
 			case 'post_status':
388
-				$order = 'wp_posts.post_status ' . strtoupper( $query->query['order'] );
388
+				$order = 'wp_posts.post_status '.strtoupper($query->query['order']);
389 389
 				break;
390 390
 		}
391 391
 
@@ -401,20 +401,20 @@  discard block
 block discarded – undo
401 401
 	 * @return void
402 402
 	 */
403 403
 	public function user() {
404
-		if ( is_null( $this->args['user'] ) ) {
404
+		if (is_null($this->args['user'])) {
405 405
 			return;
406 406
 		}
407 407
 
408
-		if ( is_numeric( $this->args['user'] ) ) {
408
+		if (is_numeric($this->args['user'])) {
409 409
 			$user_key = '_give_payment_user_id';
410 410
 		} else {
411 411
 			$user_key = '_give_payment_user_email';
412 412
 		}
413 413
 
414
-		$this->__set( 'meta_query', array(
414
+		$this->__set('meta_query', array(
415 415
 			'key'   => $user_key,
416 416
 			'value' => $this->args['user'],
417
-		) );
417
+		));
418 418
 	}
419 419
 
420 420
 	/**
@@ -425,14 +425,14 @@  discard block
 block discarded – undo
425 425
 	 * @return  void
426 426
 	 */
427 427
 	public function donor() {
428
-		if ( is_null( $this->args['donor'] ) || ! is_numeric( $this->args['donor'] ) ) {
428
+		if (is_null($this->args['donor']) || ! is_numeric($this->args['donor'])) {
429 429
 			return;
430 430
 		}
431 431
 
432
-		$this->__set( 'meta_query', array(
432
+		$this->__set('meta_query', array(
433 433
 			'key'   => '_give_payment_customer_id',
434 434
 			'value' => (int) $this->args['donor'],
435
-		) );
435
+		));
436 436
 	}
437 437
 
438 438
 	/**
@@ -445,33 +445,33 @@  discard block
 block discarded – undo
445 445
 	 */
446 446
 	public function search() {
447 447
 
448
-		if ( ! isset( $this->args['s'] ) ) {
448
+		if ( ! isset($this->args['s'])) {
449 449
 			return;
450 450
 		}
451 451
 
452
-		$search = trim( $this->args['s'] );
452
+		$search = trim($this->args['s']);
453 453
 
454
-		if ( empty( $search ) ) {
454
+		if (empty($search)) {
455 455
 			return;
456 456
 		}
457 457
 
458
-		$is_email = is_email( $search ) || strpos( $search, '@' ) !== false;
459
-		$is_user  = strpos( $search, strtolower( 'user:' ) ) !== false;
458
+		$is_email = is_email($search) || strpos($search, '@') !== false;
459
+		$is_user  = strpos($search, strtolower('user:')) !== false;
460 460
 
461
-		if ( ! empty( $this->args['search_in_notes'] ) ) {
461
+		if ( ! empty($this->args['search_in_notes'])) {
462 462
 
463
-			$notes = give_get_payment_notes( 0, $search );
463
+			$notes = give_get_payment_notes(0, $search);
464 464
 
465
-			if ( ! empty( $notes ) ) {
465
+			if ( ! empty($notes)) {
466 466
 
467
-				$payment_ids = wp_list_pluck( (array) $notes, 'comment_post_ID' );
467
+				$payment_ids = wp_list_pluck((array) $notes, 'comment_post_ID');
468 468
 
469
-				$this->__set( 'post__in', $payment_ids );
469
+				$this->__set('post__in', $payment_ids);
470 470
 			}
471 471
 
472
-			$this->__unset( 's' );
472
+			$this->__unset('s');
473 473
 
474
-		} elseif ( $is_email || strlen( $search ) == 32 ) {
474
+		} elseif ($is_email || strlen($search) == 32) {
475 475
 
476 476
 			$key         = $is_email ? '_give_payment_user_email' : '_give_payment_purchase_key';
477 477
 			$search_meta = array(
@@ -480,19 +480,19 @@  discard block
 block discarded – undo
480 480
 				'compare' => 'LIKE',
481 481
 			);
482 482
 
483
-			$this->__set( 'meta_query', $search_meta );
484
-			$this->__unset( 's' );
483
+			$this->__set('meta_query', $search_meta);
484
+			$this->__unset('s');
485 485
 
486
-		} elseif ( $is_user ) {
486
+		} elseif ($is_user) {
487 487
 
488 488
 			$search_meta = array(
489 489
 				'key'   => '_give_payment_user_id',
490
-				'value' => trim( str_replace( 'user:', '', strtolower( $search ) ) ),
490
+				'value' => trim(str_replace('user:', '', strtolower($search))),
491 491
 			);
492 492
 
493
-			$this->__set( 'meta_query', $search_meta );
493
+			$this->__set('meta_query', $search_meta);
494 494
 
495
-			if ( give_get_option( 'enable_sequential' ) ) {
495
+			if (give_get_option('enable_sequential')) {
496 496
 
497 497
 				$search_meta = array(
498 498
 					'key'     => '_give_payment_number',
@@ -500,19 +500,19 @@  discard block
 block discarded – undo
500 500
 					'compare' => 'LIKE',
501 501
 				);
502 502
 
503
-				$this->__set( 'meta_query', $search_meta );
503
+				$this->__set('meta_query', $search_meta);
504 504
 
505 505
 				$this->args['meta_query']['relation'] = 'OR';
506 506
 
507 507
 			}
508 508
 
509
-			$this->__unset( 's' );
509
+			$this->__unset('s');
510 510
 
511 511
 		} elseif (
512
-			give_get_option( 'enable_sequential' ) &&
512
+			give_get_option('enable_sequential') &&
513 513
 			(
514
-				false !== strpos( $search, give_get_option( 'sequential_prefix' ) ) ||
515
-				false !== strpos( $search, give_get_option( 'sequential_postfix' ) )
514
+				false !== strpos($search, give_get_option('sequential_prefix')) ||
515
+				false !== strpos($search, give_get_option('sequential_postfix'))
516 516
 			)
517 517
 		) {
518 518
 
@@ -522,29 +522,29 @@  discard block
 block discarded – undo
522 522
 				'compare' => 'LIKE',
523 523
 			);
524 524
 
525
-			$this->__set( 'meta_query', $search_meta );
526
-			$this->__unset( 's' );
525
+			$this->__set('meta_query', $search_meta);
526
+			$this->__unset('s');
527 527
 
528
-		} elseif ( is_numeric( $search ) ) {
528
+		} elseif (is_numeric($search)) {
529 529
 
530
-			$post = get_post( $search );
530
+			$post = get_post($search);
531 531
 
532
-			if ( is_object( $post ) && $post->post_type == 'give_payment' ) {
532
+			if (is_object($post) && $post->post_type == 'give_payment') {
533 533
 
534 534
 				$arr   = array();
535 535
 				$arr[] = $search;
536
-				$this->__set( 'post__in', $arr );
537
-				$this->__unset( 's' );
536
+				$this->__set('post__in', $arr);
537
+				$this->__unset('s');
538 538
 			}
539
-		} elseif ( '#' == substr( $search, 0, 1 ) ) {
539
+		} elseif ('#' == substr($search, 0, 1)) {
540 540
 
541
-			$search = str_replace( '#:', '', $search );
542
-			$search = str_replace( '#', '', $search );
543
-			$this->__set( 'give_forms', $search );
544
-			$this->__unset( 's' );
541
+			$search = str_replace('#:', '', $search);
542
+			$search = str_replace('#', '', $search);
543
+			$this->__set('give_forms', $search);
544
+			$this->__unset('s');
545 545
 
546 546
 		} else {
547
-			$this->__set( 's', $search );
547
+			$this->__set('s', $search);
548 548
 
549 549
 		}
550 550
 
@@ -559,16 +559,16 @@  discard block
 block discarded – undo
559 559
 	 * @return void
560 560
 	 */
561 561
 	public function mode() {
562
-		if ( empty( $this->args['mode'] ) || $this->args['mode'] == 'all' ) {
563
-			$this->__unset( 'mode' );
562
+		if (empty($this->args['mode']) || $this->args['mode'] == 'all') {
563
+			$this->__unset('mode');
564 564
 
565 565
 			return;
566 566
 		}
567 567
 
568
-		$this->__set( 'meta_query', array(
568
+		$this->__set('meta_query', array(
569 569
 			'key'   => '_give_payment_mode',
570 570
 			'value' => $this->args['mode'],
571
-		) );
571
+		));
572 572
 	}
573 573
 
574 574
 	/**
@@ -580,10 +580,10 @@  discard block
 block discarded – undo
580 580
 	 * @return void
581 581
 	 */
582 582
 	public function children() {
583
-		if ( empty( $this->args['children'] ) ) {
584
-			$this->__set( 'post_parent', 0 );
583
+		if (empty($this->args['children'])) {
584
+			$this->__set('post_parent', 0);
585 585
 		}
586
-		$this->__unset( 'children' );
586
+		$this->__unset('children');
587 587
 	}
588 588
 
589 589
 	/**
@@ -596,25 +596,25 @@  discard block
 block discarded – undo
596 596
 	 */
597 597
 	public function give_forms() {
598 598
 
599
-		if ( empty( $this->args['give_forms'] ) ) {
599
+		if (empty($this->args['give_forms'])) {
600 600
 			return;
601 601
 		}
602 602
 
603 603
 		$compare = '=';
604 604
 
605
-		if ( is_array( $this->args['give_forms'] ) ) {
605
+		if (is_array($this->args['give_forms'])) {
606 606
 			$compare = 'IN';
607 607
 		}
608 608
 
609
-		$this->__set( 'meta_query', array(
609
+		$this->__set('meta_query', array(
610 610
 			array(
611 611
 				'key'     => '_give_payment_form_id',
612 612
 				'value'   => $this->args['give_forms'],
613 613
 				'compare' => $compare,
614 614
 			),
615
-		) );
615
+		));
616 616
 
617
-		$this->__unset( 'give_forms' );
617
+		$this->__unset('give_forms');
618 618
 
619 619
 	}
620 620
 
Please login to merge, or discard this patch.
includes/class-give-stats.php 1 patch
Spacing   +106 added lines, -106 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
 
@@ -93,19 +93,19 @@  discard block
 block discarded – undo
93 93
 	 */
94 94
 	public function get_predefined_dates() {
95 95
 		$predefined = array(
96
-			'today'        => esc_html__( 'Today', 'give' ),
97
-			'yesterday'    => esc_html__( 'Yesterday', 'give' ),
98
-			'this_week'    => esc_html__( 'This Week', 'give' ),
99
-			'last_week'    => esc_html__( 'Last Week', 'give' ),
100
-			'this_month'   => esc_html__( 'This Month', 'give' ),
101
-			'last_month'   => esc_html__( 'Last Month', 'give' ),
102
-			'this_quarter' => esc_html__( 'This Quarter', 'give' ),
103
-			'last_quarter' => esc_html__( 'Last Quarter', 'give' ),
104
-			'this_year'    => esc_html__( 'This Year', 'give' ),
105
-			'last_year'    => esc_html__( 'Last Year', 'give' )
96
+			'today'        => esc_html__('Today', 'give'),
97
+			'yesterday'    => esc_html__('Yesterday', 'give'),
98
+			'this_week'    => esc_html__('This Week', 'give'),
99
+			'last_week'    => esc_html__('Last Week', 'give'),
100
+			'this_month'   => esc_html__('This Month', 'give'),
101
+			'last_month'   => esc_html__('Last Month', 'give'),
102
+			'this_quarter' => esc_html__('This Quarter', 'give'),
103
+			'last_quarter' => esc_html__('Last Quarter', 'give'),
104
+			'this_year'    => esc_html__('This Year', 'give'),
105
+			'last_year'    => esc_html__('Last Year', 'give')
106 106
 		);
107 107
 
108
-		return apply_filters( 'give_stats_predefined_dates', $predefined );
108
+		return apply_filters('give_stats_predefined_dates', $predefined);
109 109
 	}
110 110
 
111 111
 	/**
@@ -121,18 +121,18 @@  discard block
 block discarded – undo
121 121
 	 *
122 122
 	 * @return void
123 123
 	 */
124
-	public function setup_dates( $_start_date = 'this_month', $_end_date = false ) {
124
+	public function setup_dates($_start_date = 'this_month', $_end_date = false) {
125 125
 
126
-		if ( empty( $_start_date ) ) {
126
+		if (empty($_start_date)) {
127 127
 			$_start_date = 'this_month';
128 128
 		}
129 129
 
130
-		if ( empty( $_end_date ) ) {
130
+		if (empty($_end_date)) {
131 131
 			$_end_date = $_start_date;
132 132
 		}
133 133
 
134
-		$this->start_date = $this->convert_date( $_start_date );
135
-		$this->end_date   = $this->convert_date( $_end_date, true );
134
+		$this->start_date = $this->convert_date($_start_date);
135
+		$this->end_date   = $this->convert_date($_end_date, true);
136 136
 	}
137 137
 
138 138
 	/**
@@ -148,26 +148,26 @@  discard block
 block discarded – undo
148 148
 	 *
149 149
 	 * @return array|WP_Error   If the date is invalid, a WP_Error object will be returned.
150 150
 	 */
151
-	public function convert_date( $date, $end_date = false ) {
151
+	public function convert_date($date, $end_date = false) {
152 152
 
153 153
 		$this->timestamp = false;
154 154
 		$second          = $end_date ? 59 : 0;
155 155
 		$minute          = $end_date ? 59 : 0;
156 156
 		$hour            = $end_date ? 23 : 0;
157 157
 		$day             = 1;
158
-		$month           = date( 'n', current_time( 'timestamp' ) );
159
-		$year            = date( 'Y', current_time( 'timestamp' ) );
158
+		$month           = date('n', current_time('timestamp'));
159
+		$year            = date('Y', current_time('timestamp'));
160 160
 
161
-		if ( array_key_exists( $date, $this->get_predefined_dates() ) ) {
161
+		if (array_key_exists($date, $this->get_predefined_dates())) {
162 162
 
163 163
 			// This is a predefined date rate, such as last_week
164
-			switch ( $date ) {
164
+			switch ($date) {
165 165
 
166 166
 				case 'this_month' :
167 167
 
168
-					if ( $end_date ) {
168
+					if ($end_date) {
169 169
 
170
-						$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
170
+						$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
171 171
 						$hour   = 23;
172 172
 						$minute = 59;
173 173
 						$second = 59;
@@ -177,28 +177,28 @@  discard block
 block discarded – undo
177 177
 
178 178
 				case 'last_month' :
179 179
 
180
-					if ( $month == 1 ) {
180
+					if ($month == 1) {
181 181
 
182 182
 						$month = 12;
183
-						$year --;
183
+						$year--;
184 184
 
185 185
 					} else {
186 186
 
187
-						$month --;
187
+						$month--;
188 188
 
189 189
 					}
190 190
 
191
-					if ( $end_date ) {
192
-						$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
191
+					if ($end_date) {
192
+						$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
193 193
 					}
194 194
 
195 195
 					break;
196 196
 
197 197
 				case 'today' :
198 198
 
199
-					$day = date( 'd', current_time( 'timestamp' ) );
199
+					$day = date('d', current_time('timestamp'));
200 200
 
201
-					if ( $end_date ) {
201
+					if ($end_date) {
202 202
 						$hour   = 23;
203 203
 						$minute = 59;
204 204
 						$second = 59;
@@ -208,23 +208,23 @@  discard block
 block discarded – undo
208 208
 
209 209
 				case 'yesterday' :
210 210
 
211
-					$day = date( 'd', current_time( 'timestamp' ) ) - 1;
211
+					$day = date('d', current_time('timestamp')) - 1;
212 212
 
213 213
 					// Check if Today is the first day of the month (meaning subtracting one will get us 0)
214
-					if ( $day < 1 ) {
214
+					if ($day < 1) {
215 215
 
216 216
 						// If current month is 1
217
-						if ( 1 == $month ) {
217
+						if (1 == $month) {
218 218
 
219 219
 							$year -= 1; // Today is January 1, so skip back to last day of December
220 220
 							$month = 12;
221
-							$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
221
+							$day   = cal_days_in_month(CAL_GREGORIAN, $month, $year);
222 222
 
223 223
 						} else {
224 224
 
225 225
 							// Go back one month and get the last day of the month
226 226
 							$month -= 1;
227
-							$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
227
+							$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
228 228
 
229 229
 						}
230 230
 					}
@@ -233,12 +233,12 @@  discard block
 block discarded – undo
233 233
 
234 234
 				case 'this_week' :
235 235
 
236
-					$days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24;
237
-					$today              = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24;
236
+					$days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24;
237
+					$today              = date('d', current_time('timestamp')) * 60 * 60 * 24;
238 238
 
239
-					if ( $today < $days_to_week_start ) {
239
+					if ($today < $days_to_week_start) {
240 240
 
241
-						if ( $month > 1 ) {
241
+						if ($month > 1) {
242 242
 							$month -= 1;
243 243
 						} else {
244 244
 							$month = 12;
@@ -246,19 +246,19 @@  discard block
 block discarded – undo
246 246
 
247 247
 					}
248 248
 
249
-					if ( ! $end_date ) {
249
+					if ( ! $end_date) {
250 250
 
251 251
 						// Getting the start day
252 252
 
253
-						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1;
254
-						$day += get_option( 'start_of_week' );
253
+						$day = date('d', current_time('timestamp') - $days_to_week_start) - 1;
254
+						$day += get_option('start_of_week');
255 255
 
256 256
 					} else {
257 257
 
258 258
 						// Getting the end day
259 259
 
260
-						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1;
261
-						$day += get_option( 'start_of_week' ) + 6;
260
+						$day = date('d', current_time('timestamp') - $days_to_week_start) - 1;
261
+						$day += get_option('start_of_week') + 6;
262 262
 
263 263
 					}
264 264
 
@@ -266,12 +266,12 @@  discard block
 block discarded – undo
266 266
 
267 267
 				case 'last_week' :
268 268
 
269
-					$days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24;
270
-					$today              = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24;
269
+					$days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24;
270
+					$today              = date('d', current_time('timestamp')) * 60 * 60 * 24;
271 271
 
272
-					if ( $today < $days_to_week_start ) {
272
+					if ($today < $days_to_week_start) {
273 273
 
274
-						if ( $month > 1 ) {
274
+						if ($month > 1) {
275 275
 							$month -= 1;
276 276
 						} else {
277 277
 							$month = 12;
@@ -279,19 +279,19 @@  discard block
 block discarded – undo
279 279
 
280 280
 					}
281 281
 
282
-					if ( ! $end_date ) {
282
+					if ( ! $end_date) {
283 283
 
284 284
 						// Getting the start day
285 285
 
286
-						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8;
287
-						$day += get_option( 'start_of_week' );
286
+						$day = date('d', current_time('timestamp') - $days_to_week_start) - 8;
287
+						$day += get_option('start_of_week');
288 288
 
289 289
 					} else {
290 290
 
291 291
 						// Getting the end day
292 292
 
293
-						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8;
294
-						$day += get_option( 'start_of_week' ) + 6;
293
+						$day = date('d', current_time('timestamp') - $days_to_week_start) - 8;
294
+						$day += get_option('start_of_week') + 6;
295 295
 
296 296
 					}
297 297
 
@@ -299,39 +299,39 @@  discard block
 block discarded – undo
299 299
 
300 300
 				case 'this_quarter' :
301 301
 
302
-					$month_now = date( 'n', current_time( 'timestamp' ) );
302
+					$month_now = date('n', current_time('timestamp'));
303 303
 
304
-					if ( $month_now <= 3 ) {
304
+					if ($month_now <= 3) {
305 305
 
306
-						if ( ! $end_date ) {
306
+						if ( ! $end_date) {
307 307
 							$month = 1;
308 308
 						} else {
309 309
 							$month  = 3;
310
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
310
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
311 311
 							$hour   = 23;
312 312
 							$minute = 59;
313 313
 							$second = 59;
314 314
 						}
315 315
 
316
-					} else if ( $month_now <= 6 ) {
316
+					} else if ($month_now <= 6) {
317 317
 
318
-						if ( ! $end_date ) {
318
+						if ( ! $end_date) {
319 319
 							$month = 4;
320 320
 						} else {
321 321
 							$month  = 6;
322
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
322
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
323 323
 							$hour   = 23;
324 324
 							$minute = 59;
325 325
 							$second = 59;
326 326
 						}
327 327
 
328
-					} else if ( $month_now <= 9 ) {
328
+					} else if ($month_now <= 9) {
329 329
 
330
-						if ( ! $end_date ) {
330
+						if ( ! $end_date) {
331 331
 							$month = 7;
332 332
 						} else {
333 333
 							$month  = 9;
334
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
334
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
335 335
 							$hour   = 23;
336 336
 							$minute = 59;
337 337
 							$second = 59;
@@ -339,11 +339,11 @@  discard block
 block discarded – undo
339 339
 
340 340
 					} else {
341 341
 
342
-						if ( ! $end_date ) {
342
+						if ( ! $end_date) {
343 343
 							$month = 10;
344 344
 						} else {
345 345
 							$month  = 12;
346
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
346
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
347 347
 							$hour   = 23;
348 348
 							$minute = 59;
349 349
 							$second = 59;
@@ -355,40 +355,40 @@  discard block
 block discarded – undo
355 355
 
356 356
 				case 'last_quarter' :
357 357
 
358
-					$month_now = date( 'n', current_time( 'timestamp' ) );
358
+					$month_now = date('n', current_time('timestamp'));
359 359
 
360
-					if ( $month_now <= 3 ) {
360
+					if ($month_now <= 3) {
361 361
 
362
-						if ( ! $end_date ) {
362
+						if ( ! $end_date) {
363 363
 							$month = 10;
364 364
 						} else {
365 365
 							$year -= 1;
366 366
 							$month  = 12;
367
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
367
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
368 368
 							$hour   = 23;
369 369
 							$minute = 59;
370 370
 							$second = 59;
371 371
 						}
372 372
 
373
-					} else if ( $month_now <= 6 ) {
373
+					} else if ($month_now <= 6) {
374 374
 
375
-						if ( ! $end_date ) {
375
+						if ( ! $end_date) {
376 376
 							$month = 1;
377 377
 						} else {
378 378
 							$month  = 3;
379
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
379
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
380 380
 							$hour   = 23;
381 381
 							$minute = 59;
382 382
 							$second = 59;
383 383
 						}
384 384
 
385
-					} else if ( $month_now <= 9 ) {
385
+					} else if ($month_now <= 9) {
386 386
 
387
-						if ( ! $end_date ) {
387
+						if ( ! $end_date) {
388 388
 							$month = 4;
389 389
 						} else {
390 390
 							$month  = 6;
391
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
391
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
392 392
 							$hour   = 23;
393 393
 							$minute = 59;
394 394
 							$second = 59;
@@ -396,11 +396,11 @@  discard block
 block discarded – undo
396 396
 
397 397
 					} else {
398 398
 
399
-						if ( ! $end_date ) {
399
+						if ( ! $end_date) {
400 400
 							$month = 7;
401 401
 						} else {
402 402
 							$month  = 9;
403
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
403
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
404 404
 							$hour   = 23;
405 405
 							$minute = 59;
406 406
 							$second = 59;
@@ -412,11 +412,11 @@  discard block
 block discarded – undo
412 412
 
413 413
 				case 'this_year' :
414 414
 
415
-					if ( ! $end_date ) {
415
+					if ( ! $end_date) {
416 416
 						$month = 1;
417 417
 					} else {
418 418
 						$month  = 12;
419
-						$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
419
+						$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
420 420
 						$hour   = 23;
421 421
 						$minute = 59;
422 422
 						$second = 59;
@@ -427,11 +427,11 @@  discard block
 block discarded – undo
427 427
 				case 'last_year' :
428 428
 
429 429
 					$year -= 1;
430
-					if ( ! $end_date ) {
430
+					if ( ! $end_date) {
431 431
 						$month = 1;
432 432
 					} else {
433 433
 						$month  = 12;
434
-						$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
434
+						$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
435 435
 						$hour   = 23;
436 436
 						$minute = 59;
437 437
 						$second = 59;
@@ -442,30 +442,30 @@  discard block
 block discarded – undo
442 442
 			}
443 443
 
444 444
 
445
-		} else if ( is_numeric( $date ) ) {
445
+		} else if (is_numeric($date)) {
446 446
 
447 447
 			// return $date unchanged since it is a timestamp
448 448
 			$this->timestamp = true;
449 449
 
450
-		} else if ( false !== strtotime( $date ) ) {
450
+		} else if (false !== strtotime($date)) {
451 451
 
452
-			$date  = strtotime( $date, current_time( 'timestamp' ) );
453
-			$year  = date( 'Y', $date );
454
-			$month = date( 'm', $date );
455
-			$day   = date( 'd', $date );
452
+			$date  = strtotime($date, current_time('timestamp'));
453
+			$year  = date('Y', $date);
454
+			$month = date('m', $date);
455
+			$day   = date('d', $date);
456 456
 
457 457
 		} else {
458 458
 
459
-			return new WP_Error( 'invalid_date', esc_html__( 'Improper date provided.', 'give' ) );
459
+			return new WP_Error('invalid_date', esc_html__('Improper date provided.', 'give'));
460 460
 
461 461
 		}
462 462
 
463
-		if ( false === $this->timestamp ) {
463
+		if (false === $this->timestamp) {
464 464
 			// Create an exact timestamp
465
-			$date = mktime( $hour, $minute, $second, $month, $day, $year );
465
+			$date = mktime($hour, $minute, $second, $month, $day, $year);
466 466
 		}
467 467
 
468
-		return apply_filters( 'give_stats_date', $date, $end_date, $this );
468
+		return apply_filters('give_stats_date', $date, $end_date, $this);
469 469
 
470 470
 	}
471 471
 
@@ -481,33 +481,33 @@  discard block
 block discarded – undo
481 481
 	 * 
482 482
 	 * @return string
483 483
 	 */
484
-	public function count_where( $where = '' ) {
484
+	public function count_where($where = '') {
485 485
 		// Only get payments in our date range
486 486
 
487 487
 		$start_where = '';
488 488
 		$end_where   = '';
489 489
 
490
-		if ( $this->start_date ) {
490
+		if ($this->start_date) {
491 491
 
492
-			if ( $this->timestamp ) {
492
+			if ($this->timestamp) {
493 493
 				$format = 'Y-m-d H:i:s';
494 494
 			} else {
495 495
 				$format = 'Y-m-d 00:00:00';
496 496
 			}
497 497
 
498
-			$start_date  = date( $format, $this->start_date );
498
+			$start_date  = date($format, $this->start_date);
499 499
 			$start_where = " AND p.post_date >= '{$start_date}'";
500 500
 		}
501 501
 
502
-		if ( $this->end_date ) {
502
+		if ($this->end_date) {
503 503
 
504
-			if ( $this->timestamp ) {
504
+			if ($this->timestamp) {
505 505
 				$format = 'Y-m-d H:i:s';
506 506
 			} else {
507 507
 				$format = 'Y-m-d 23:59:59';
508 508
 			}
509 509
 
510
-			$end_date = date( $format, $this->end_date );
510
+			$end_date = date($format, $this->end_date);
511 511
 
512 512
 			$end_where = " AND p.post_date <= '{$end_date}'";
513 513
 		}
@@ -529,34 +529,34 @@  discard block
 block discarded – undo
529 529
 	 *
530 530
 	 * @return string
531 531
 	 */
532
-	public function payments_where( $where = '' ) {
532
+	public function payments_where($where = '') {
533 533
 
534 534
 		global $wpdb;
535 535
 
536 536
 		$start_where = '';
537 537
 		$end_where   = '';
538 538
 
539
-		if ( ! is_wp_error( $this->start_date ) ) {
539
+		if ( ! is_wp_error($this->start_date)) {
540 540
 
541
-			if ( $this->timestamp ) {
541
+			if ($this->timestamp) {
542 542
 				$format = 'Y-m-d H:i:s';
543 543
 			} else {
544 544
 				$format = 'Y-m-d 00:00:00';
545 545
 			}
546 546
 
547
-			$start_date  = date( $format, $this->start_date );
547
+			$start_date  = date($format, $this->start_date);
548 548
 			$start_where = " AND $wpdb->posts.post_date >= '{$start_date}'";
549 549
 		}
550 550
 
551
-		if ( ! is_wp_error( $this->end_date ) ) {
551
+		if ( ! is_wp_error($this->end_date)) {
552 552
 
553
-			if ( $this->timestamp ) {
553
+			if ($this->timestamp) {
554 554
 				$format = 'Y-m-d H:i:s';
555 555
 			} else {
556 556
 				$format = 'Y-m-d 23:59:59';
557 557
 			}
558 558
 
559
-			$end_date = date( $format, $this->end_date );
559
+			$end_date = date($format, $this->end_date);
560 560
 
561 561
 			$end_where = " AND $wpdb->posts.post_date <= '{$end_date}'";
562 562
 		}
Please login to merge, or discard this patch.
includes/plugin-compatibility.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@
 block discarded – undo
44 44
 	) {
45 45
 		// If Yoast SEO or Yoast SEO Premium plugin exists, then update seo sitemap cache.
46 46
 		if ( (is_plugin_active( 'wordpress-seo/wp-seo.php' )
47
-		     || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ))
47
+			 || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ))
48 48
 			&& class_exists( 'WPSEO_Sitemaps_Cache' )
49 49
 		) {
50 50
 			$yoast_sitemaps_cache = new WPSEO_Sitemaps_Cache();
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -19,9 +19,9 @@  discard block
 block discarded – undo
19 19
  * @return void
20 20
  */
21 21
 function give_disable_mandrill_nl2br() {
22
-	add_filter( 'mandrill_nl2br', '__return_false' );
22
+	add_filter('mandrill_nl2br', '__return_false');
23 23
 }
24
-add_action( 'give_email_send_before', 'give_disable_mandrill_nl2br' );
24
+add_action('give_email_send_before', 'give_disable_mandrill_nl2br');
25 25
 
26 26
 
27 27
 /**
@@ -33,26 +33,26 @@  discard block
 block discarded – undo
33 33
  */
34 34
 function give_clear_seo_sitemap_cache_on_settings_change() {
35 35
 	// Load required file if the fn 'is_plugin_active' doesn't exists.
36
-	if ( ! function_exists( 'is_plugin_active' ) ) {
37
-		require_once ABSPATH . 'wp-admin/includes/plugin.php';
36
+	if ( ! function_exists('is_plugin_active')) {
37
+		require_once ABSPATH.'wp-admin/includes/plugin.php';
38 38
 	}
39 39
 
40 40
 	// If there is change detected for Single Form View and Form Archives options then proceed.
41 41
 	if (
42
-		( $_POST['forms_singular'] != give_get_option( 'forms_singular' ) ) ||
43
-		( $_POST['forms_archives'] != give_get_option( 'forms_archives' ) )
42
+		($_POST['forms_singular'] != give_get_option('forms_singular')) ||
43
+		($_POST['forms_archives'] != give_get_option('forms_archives'))
44 44
 	) {
45 45
 		// If Yoast SEO or Yoast SEO Premium plugin exists, then update seo sitemap cache.
46
-		if ( (is_plugin_active( 'wordpress-seo/wp-seo.php' )
47
-		     || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ))
48
-			&& class_exists( 'WPSEO_Sitemaps_Cache' )
46
+		if ((is_plugin_active('wordpress-seo/wp-seo.php')
47
+		     || is_plugin_active('wordpress-seo-premium/wp-seo-premium.php'))
48
+			&& class_exists('WPSEO_Sitemaps_Cache')
49 49
 		) {
50 50
 			$yoast_sitemaps_cache = new WPSEO_Sitemaps_Cache();
51
-			if ( method_exists( $yoast_sitemaps_cache, 'clear' ) ) {
51
+			if (method_exists($yoast_sitemaps_cache, 'clear')) {
52 52
 				WPSEO_Sitemaps_Cache::clear();
53 53
 			}
54 54
 		}
55 55
 	}
56 56
 }
57 57
 
58
-add_action( 'give-settings_save_display', 'give_clear_seo_sitemap_cache_on_settings_change' );
58
+add_action('give-settings_save_display', 'give_clear_seo_sitemap_cache_on_settings_change');
Please login to merge, or discard this patch.
includes/class-give-db-donor-meta.php 1 patch
Spacing   +24 added lines, -24 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
 
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 		/* @var WPDB $wpdb */
34 34
 		global $wpdb;
35 35
 
36
-		$wpdb->customermeta = $this->table_name  = $wpdb->prefix . 'give_customermeta';
36
+		$wpdb->customermeta = $this->table_name = $wpdb->prefix.'give_customermeta';
37 37
 		$this->primary_key = 'meta_id';
38 38
 		$this->version     = '1.0';
39 39
 
@@ -71,13 +71,13 @@  discard block
 block discarded – undo
71 71
 	 *
72 72
 	 * @return  mixed                 Will be an array if $single is false. Will be value of meta data field if $single is true.
73 73
 	 */
74
-	public function get_meta( $donor_id = 0, $meta_key = '', $single = false ) {
75
-		$donor_id = $this->sanitize_donor_id( $donor_id );
76
-		if ( false === $donor_id ) {
74
+	public function get_meta($donor_id = 0, $meta_key = '', $single = false) {
75
+		$donor_id = $this->sanitize_donor_id($donor_id);
76
+		if (false === $donor_id) {
77 77
 			return false;
78 78
 		}
79 79
 
80
-		return get_metadata( 'customer', $donor_id, $meta_key, $single );
80
+		return get_metadata('customer', $donor_id, $meta_key, $single);
81 81
 	}
82 82
 
83 83
 	/**
@@ -95,13 +95,13 @@  discard block
 block discarded – undo
95 95
 	 *
96 96
 	 * @return  bool                  False for failure. True for success.
97 97
 	 */
98
-	public function add_meta( $donor_id = 0, $meta_key = '', $meta_value, $unique = false ) {
99
-		$donor_id = $this->sanitize_donor_id( $donor_id );
100
-		if ( false === $donor_id ) {
98
+	public function add_meta($donor_id = 0, $meta_key = '', $meta_value, $unique = false) {
99
+		$donor_id = $this->sanitize_donor_id($donor_id);
100
+		if (false === $donor_id) {
101 101
 			return false;
102 102
 		}
103 103
 
104
-		return add_metadata( 'customer', $donor_id, $meta_key, $meta_value, $unique );
104
+		return add_metadata('customer', $donor_id, $meta_key, $meta_value, $unique);
105 105
 	}
106 106
 
107 107
 	/**
@@ -124,13 +124,13 @@  discard block
 block discarded – undo
124 124
 	 *
125 125
 	 * @return  bool                  False on failure, true if success.
126 126
 	 */
127
-	public function update_meta( $donor_id = 0, $meta_key = '', $meta_value, $prev_value = '' ) {
128
-		$donor_id = $this->sanitize_donor_id( $donor_id );
129
-		if ( false === $donor_id ) {
127
+	public function update_meta($donor_id = 0, $meta_key = '', $meta_value, $prev_value = '') {
128
+		$donor_id = $this->sanitize_donor_id($donor_id);
129
+		if (false === $donor_id) {
130 130
 			return false;
131 131
 		}
132 132
 
133
-		return update_metadata( 'customer', $donor_id, $meta_key, $meta_value, $prev_value );
133
+		return update_metadata('customer', $donor_id, $meta_key, $meta_value, $prev_value);
134 134
 	}
135 135
 
136 136
 	/**
@@ -151,8 +151,8 @@  discard block
 block discarded – undo
151 151
 	 *
152 152
 	 * @return  bool                  False for failure. True for success.
153 153
 	 */
154
-	public function delete_meta( $donor_id = 0, $meta_key = '', $meta_value = '' ) {
155
-		return delete_metadata( 'customer', $donor_id, $meta_key, $meta_value );
154
+	public function delete_meta($donor_id = 0, $meta_key = '', $meta_value = '') {
155
+		return delete_metadata('customer', $donor_id, $meta_key, $meta_value);
156 156
 	}
157 157
 
158 158
 	/**
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	 */
166 166
 	public function create_table() {
167 167
 
168
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
168
+		require_once(ABSPATH.'wp-admin/includes/upgrade.php');
169 169
 
170 170
 		$sql = "CREATE TABLE {$this->table_name} (
171 171
 			meta_id bigint(20) NOT NULL AUTO_INCREMENT,
@@ -177,9 +177,9 @@  discard block
 block discarded – undo
177 177
 			KEY meta_key (meta_key)
178 178
 			) CHARACTER SET utf8 COLLATE utf8_general_ci;";
179 179
 
180
-		dbDelta( $sql );
180
+		dbDelta($sql);
181 181
 
182
-		update_option( $this->table_name . '_db_version', $this->version );
182
+		update_option($this->table_name.'_db_version', $this->version);
183 183
 	}
184 184
 
185 185
 	/**
@@ -192,23 +192,23 @@  discard block
 block discarded – undo
192 192
 	 *
193 193
 	 * @return int|bool                The normalized donor ID or false if it's found to not be valid.
194 194
 	 */
195
-	private function sanitize_donor_id( $donor_id ) {
196
-		if ( ! is_numeric( $donor_id ) ) {
195
+	private function sanitize_donor_id($donor_id) {
196
+		if ( ! is_numeric($donor_id)) {
197 197
 			return false;
198 198
 		}
199 199
 
200 200
 		$donor_id = (int) $donor_id;
201 201
 
202 202
 		// We were given a non positive number.
203
-		if ( absint( $donor_id ) !== $donor_id ) {
203
+		if (absint($donor_id) !== $donor_id) {
204 204
 			return false;
205 205
 		}
206 206
 
207
-		if ( empty( $donor_id ) ) {
207
+		if (empty($donor_id)) {
208 208
 			return false;
209 209
 		}
210 210
 
211
-		return absint( $donor_id );
211
+		return absint($donor_id);
212 212
 
213 213
 	}
214 214
 
Please login to merge, or discard this patch.
includes/class-give-cli-commands.php 1 patch
Spacing   +196 added lines, -196 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 // Exit if accessed directly.
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if ( ! defined('ABSPATH')) {
11 11
 	exit;
12 12
 }
13 13
 
14 14
 // Add give command.
15
-WP_CLI::add_command( 'give', 'GIVE_CLI_COMMAND' );
15
+WP_CLI::add_command('give', 'GIVE_CLI_COMMAND');
16 16
 
17 17
 
18 18
 /**
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
 	 *
69 69
 	 * @subcommand    logo
70 70
 	 */
71
-	public function ascii( $args, $assoc_args ) {
72
-		WP_CLI::log( file_get_contents( GIVE_PLUGIN_DIR . 'assets/images/give-ascii-logo.txt' ) );
71
+	public function ascii($args, $assoc_args) {
72
+		WP_CLI::log(file_get_contents(GIVE_PLUGIN_DIR.'assets/images/give-ascii-logo.txt'));
73 73
 	}
74 74
 
75 75
 
@@ -94,54 +94,54 @@  discard block
 block discarded – undo
94 94
 	 *
95 95
 	 * @subcommand    details
96 96
 	 */
97
-	public function details( $args, $assoc_args ) {
97
+	public function details($args, $assoc_args) {
98 98
 
99 99
 		/**
100 100
 		 * Plugin Information
101 101
 		 */
102
-		WP_CLI::log( $this->color_message( __( 'Give Version: ', 'give' ) ) . GIVE_VERSION );
102
+		WP_CLI::log($this->color_message(__('Give Version: ', 'give')).GIVE_VERSION);
103 103
 
104 104
 		/**
105 105
 		 * General Information.
106 106
 		 */
107
-		WP_CLI::log( "\n####   " . $this->color_message( __( 'General information', 'give' ) ) . '   ####' );
107
+		WP_CLI::log("\n####   ".$this->color_message(__('General information', 'give')).'   ####');
108 108
 
109
-		$success_page = give_get_option( 'success_page' );
110
-		$failure_page = give_get_option( 'failure_page' );
111
-		$history_page = give_get_option( 'history_page' );
109
+		$success_page = give_get_option('success_page');
110
+		$failure_page = give_get_option('failure_page');
111
+		$history_page = give_get_option('history_page');
112 112
 
113
-		WP_CLI::log( $this->color_message( sprintf( __( 'Success Page: ', 'give' ) ) ) . ( $success_page ? "[{$success_page}] " . get_permalink( $success_page ) : __( 'Not Set', 'give' ) ) );
114
-		WP_CLI::log( $this->color_message( __( 'Failed Donation Page: ', 'give' ) ) . ( $failure_page ? "[{$failure_page}] " . get_permalink( $failure_page ) : __( 'Not Set', 'give' ) ) );
115
-		WP_CLI::log( $this->color_message( __( 'Donation History Page: ', 'give' ) ) . ( $history_page ? "[{$history_page}] " . get_permalink( $history_page ) : __( 'Not Set', 'give' ) ) );
116
-		WP_CLI::log( $this->color_message( __( 'Country: ', 'give' ) ) . give_get_country() );
113
+		WP_CLI::log($this->color_message(sprintf(__('Success Page: ', 'give'))).($success_page ? "[{$success_page}] ".get_permalink($success_page) : __('Not Set', 'give')));
114
+		WP_CLI::log($this->color_message(__('Failed Donation Page: ', 'give')).($failure_page ? "[{$failure_page}] ".get_permalink($failure_page) : __('Not Set', 'give')));
115
+		WP_CLI::log($this->color_message(__('Donation History Page: ', 'give')).($history_page ? "[{$history_page}] ".get_permalink($history_page) : __('Not Set', 'give')));
116
+		WP_CLI::log($this->color_message(__('Country: ', 'give')).give_get_country());
117 117
 
118 118
 		/**
119 119
 		 * Currency Information.
120 120
 		 */
121
-		$default_gateway = give_get_option( 'default_gateway' );
121
+		$default_gateway = give_get_option('default_gateway');
122 122
 
123
-		WP_CLI::log( "\n####   " . $this->color_message( __( 'Currency Information', 'give' ) ) . '   ####' );
123
+		WP_CLI::log("\n####   ".$this->color_message(__('Currency Information', 'give')).'   ####');
124 124
 
125
-		WP_CLI::log( $this->color_message( __( 'Currency: ', 'give' ), give_get_currency() ) );
126
-		WP_CLI::log( $this->color_message( __( 'Currency Position: ', 'give' ), give_get_currency_position() ) );
127
-		WP_CLI::log( $this->color_message( __( 'Thousand Separator: ', 'give' ), give_get_price_thousand_separator() ) );
128
-		WP_CLI::log( $this->color_message( __( 'Decimal Separator: ', 'give' ), give_get_price_decimal_separator() ) );
129
-		WP_CLI::log( $this->color_message( __( 'Number of Decimals: ', 'give' ), give_get_price_decimals() ) );
130
-		WP_CLI::log( $this->color_message( __( 'Test Mode: ', 'give' ), ( give_get_option( 'test_mode' ) ? __( 'Yes', 'give' ) : __( 'No', 'give' ) ) ) );
131
-		WP_CLI::log( $this->color_message( __( 'Default Gateway: ', 'give' ), ( $default_gateway ? $default_gateway : __( 'Not Set', 'give' ) ) ) );
125
+		WP_CLI::log($this->color_message(__('Currency: ', 'give'), give_get_currency()));
126
+		WP_CLI::log($this->color_message(__('Currency Position: ', 'give'), give_get_currency_position()));
127
+		WP_CLI::log($this->color_message(__('Thousand Separator: ', 'give'), give_get_price_thousand_separator()));
128
+		WP_CLI::log($this->color_message(__('Decimal Separator: ', 'give'), give_get_price_decimal_separator()));
129
+		WP_CLI::log($this->color_message(__('Number of Decimals: ', 'give'), give_get_price_decimals()));
130
+		WP_CLI::log($this->color_message(__('Test Mode: ', 'give'), (give_get_option('test_mode') ? __('Yes', 'give') : __('No', 'give'))));
131
+		WP_CLI::log($this->color_message(__('Default Gateway: ', 'give'), ($default_gateway ? $default_gateway : __('Not Set', 'give'))));
132 132
 
133 133
 		// Payment gateways Information.
134
-		$gateways = give_get_ordered_payment_gateways( give_get_payment_gateways() );
135
-		WP_CLI::log( $this->color_message( __( 'Enabled Gateways: ', 'give' ) ) );
134
+		$gateways = give_get_ordered_payment_gateways(give_get_payment_gateways());
135
+		WP_CLI::log($this->color_message(__('Enabled Gateways: ', 'give')));
136 136
 
137
-		if ( ! empty( $gateways ) ) {
137
+		if ( ! empty($gateways)) {
138 138
 			self::$counter = 1;
139
-			foreach ( $gateways as $gateway ) {
140
-				WP_CLI::log( '  ' . $this->color_message( self::$counter, $gateway['admin_label'] ) );
141
-				self::$counter ++;
139
+			foreach ($gateways as $gateway) {
140
+				WP_CLI::log('  '.$this->color_message(self::$counter, $gateway['admin_label']));
141
+				self::$counter++;
142 142
 			}
143 143
 		} else {
144
-			WP_CLI::log( __( 'Not any payment gateways found', 'give' ) );
144
+			WP_CLI::log(__('Not any payment gateways found', 'give'));
145 145
 		}
146 146
 	}
147 147
 
@@ -173,15 +173,15 @@  discard block
 block discarded – undo
173 173
 	 *
174 174
 	 * @subcommand    forms
175 175
 	 */
176
-	public function forms( $args, $assoc_args ) {
176
+	public function forms($args, $assoc_args) {
177 177
 		global $wp_query;
178
-		$form_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false;
179
-		$number  = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? absint( $assoc_args['number'] ) : 10;
178
+		$form_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : false;
179
+		$number  = isset($assoc_args) && array_key_exists('number', $assoc_args) ? absint($assoc_args['number']) : 10;
180 180
 		$start   = time();
181 181
 
182 182
 		// Cache previous number query var.
183 183
 		$is_set_number = $cache_per_page = false;
184
-		if ( isset( $wp_query->query_vars['number'] ) ) {
184
+		if (isset($wp_query->query_vars['number'])) {
185 185
 			$cache_per_page = $wp_query->query_vars['number'];
186 186
 			$is_set_number  = true;
187 187
 		}
@@ -190,22 +190,22 @@  discard block
 block discarded – undo
190 190
 		$wp_query->query_vars['number'] = $number;
191 191
 
192 192
 		// Get forms.
193
-		$forms = $form_id ? $this->api->get_forms( $form_id ) : $this->api->get_forms();
193
+		$forms = $form_id ? $this->api->get_forms($form_id) : $this->api->get_forms();
194 194
 
195 195
 		// Reset number query var.
196
-		if ( $is_set_number ) {
196
+		if ($is_set_number) {
197 197
 			$wp_query->query_vars['number'] = $cache_per_page;
198 198
 		}
199 199
 
200 200
 		// Bailout.
201
-		if ( array_key_exists( 'error', $forms ) ) {
201
+		if (array_key_exists('error', $forms)) {
202 202
 
203
-			WP_CLI::warning( $forms['error'] );
203
+			WP_CLI::warning($forms['error']);
204 204
 
205 205
 			return;
206
-		} elseif ( empty( $forms['forms'] ) ) {
206
+		} elseif (empty($forms['forms'])) {
207 207
 
208
-			WP_CLI::error( __( 'No forms found.', 'give' ) );
208
+			WP_CLI::error(__('No forms found.', 'give'));
209 209
 
210 210
 			return;
211 211
 		}
@@ -213,25 +213,25 @@  discard block
 block discarded – undo
213 213
 		// Param to check if form typeis already showed or not.
214 214
 		$is_show_form_type = false;
215 215
 
216
-		if ( 1 === count( $forms ) && $form_id ) {
216
+		if (1 === count($forms) && $form_id) {
217 217
 			// Show single form.
218
-			foreach ( $forms['forms'][0] as $key => $info ) {
219
-				switch ( $key ) {
218
+			foreach ($forms['forms'][0] as $key => $info) {
219
+				switch ($key) {
220 220
 					case 'stats':
221
-						$this->color_main_heading( ucfirst( $key ) );
221
+						$this->color_main_heading(ucfirst($key));
222 222
 
223
-						foreach ( $info as $heading => $data ) {
224
-							$this->color_sub_heading( ucfirst( $heading ) );
225
-							switch ( $heading ) {
223
+						foreach ($info as $heading => $data) {
224
+							$this->color_sub_heading(ucfirst($heading));
225
+							switch ($heading) {
226 226
 								default:
227
-									foreach ( $data as $subheading => $subdata ) {
227
+									foreach ($data as $subheading => $subdata) {
228 228
 
229
-										switch ( $subheading ) {
229
+										switch ($subheading) {
230 230
 											case 'earnings':
231
-												WP_CLI::log( $this->color_message( $subheading . ': ', give_currency_filter( $subdata ) ) );
231
+												WP_CLI::log($this->color_message($subheading.': ', give_currency_filter($subdata)));
232 232
 												break;
233 233
 											default:
234
-												WP_CLI::log( $this->color_message( $subheading . ': ', $subdata ) );
234
+												WP_CLI::log($this->color_message($subheading.': ', $subdata));
235 235
 										}
236 236
 									}
237 237
 							}
@@ -241,26 +241,26 @@  discard block
 block discarded – undo
241 241
 					case 'pricing':
242 242
 					case 'info':
243 243
 					default:
244
-						$this->color_main_heading( ucfirst( $key ) );
244
+						$this->color_main_heading(ucfirst($key));
245 245
 
246 246
 						// Show form type.
247
-						if ( ! $is_show_form_type ) {
248
-							$form              = new Give_Donate_Form( $form_id );
247
+						if ( ! $is_show_form_type) {
248
+							$form              = new Give_Donate_Form($form_id);
249 249
 							$is_show_form_type = true;
250 250
 
251
-							WP_CLI::log( $this->color_message( __( 'form type', 'give' ), $form->get_type() ) );
251
+							WP_CLI::log($this->color_message(__('form type', 'give'), $form->get_type()));
252 252
 						}
253 253
 
254
-						foreach ( $info as $heading => $data ) {
254
+						foreach ($info as $heading => $data) {
255 255
 
256
-							switch ( $heading ) {
256
+							switch ($heading) {
257 257
 								case 'id':
258
-									WP_CLI::log( $this->color_message( $heading, $data ) );
258
+									WP_CLI::log($this->color_message($heading, $data));
259 259
 									break;
260 260
 
261 261
 								default:
262
-									$data = empty( $data ) ? __( 'Not set', 'give' ) : $data;
263
-									WP_CLI::log( $this->color_message( $heading, $data ) );
262
+									$data = empty($data) ? __('Not set', 'give') : $data;
263
+									WP_CLI::log($this->color_message($heading, $data));
264 264
 							}
265 265
 						}
266 266
 				}// End switch().
@@ -271,37 +271,37 @@  discard block
 block discarded – undo
271 271
 			$is_table_first_row_set = false;
272 272
 			$table_column_count     = 0;
273 273
 
274
-			WP_CLI::line( $this->color_message( sprintf( __( '%d donation forms found', 'give' ), count( $forms['forms'] ) ), '', false ) );
274
+			WP_CLI::line($this->color_message(sprintf(__('%d donation forms found', 'give'), count($forms['forms'])), '', false));
275 275
 
276
-			foreach ( $forms['forms'] as $index => $form_data ) {
276
+			foreach ($forms['forms'] as $index => $form_data) {
277 277
 
278 278
 				// Default table data.
279 279
 				$table_first_row = array();
280 280
 				$table_row       = array();
281 281
 
282
-				foreach ( $form_data['info'] as $key => $form ) {
282
+				foreach ($form_data['info'] as $key => $form) {
283 283
 
284 284
 					// Do not show thumbnail, content and link in table.
285
-					if ( in_array( $key, array( 'content', 'thumbnail', 'link' ), true ) ) {
285
+					if (in_array($key, array('content', 'thumbnail', 'link'), true)) {
286 286
 						continue;
287 287
 					}
288 288
 
289
-					if ( ! $is_table_first_row_set ) {
289
+					if ( ! $is_table_first_row_set) {
290 290
 						$table_first_row[] = $key;
291 291
 					}
292 292
 
293 293
 					$table_row[] = $form;
294 294
 
295
-					if ( 'status' === $key ) {
295
+					if ('status' === $key) {
296 296
 						// First array item will be an form id in our case.
297
-						$form = new Give_Donate_Form( absint( $table_row[0] ) );
297
+						$form = new Give_Donate_Form(absint($table_row[0]));
298 298
 
299 299
 						$table_row[] = $form->get_type();
300 300
 					}
301 301
 				}
302 302
 
303 303
 				// Set table first row.
304
-				if ( ! $is_table_first_row_set ) {
304
+				if ( ! $is_table_first_row_set) {
305 305
 
306 306
 					// Add extra column to table.
307 307
 					$table_first_row[] = 'type';
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 				$table_data[] = $table_row;
315 315
 			}// End foreach().
316 316
 
317
-			$this->display_table( $table_data );
317
+			$this->display_table($table_data);
318 318
 		}// End if().
319 319
 	}
320 320
 
@@ -366,37 +366,37 @@  discard block
 block discarded – undo
366 366
 	 *
367 367
 	 * @subcommand    donors
368 368
 	 */
369
-	public function donors( $args, $assoc_args ) {
369
+	public function donors($args, $assoc_args) {
370 370
 		global $wp_query;
371
-		$donor_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false;
372
-		$email    = isset( $assoc_args ) && array_key_exists( 'email', $assoc_args ) ? $assoc_args['email'] : false;
373
-		$name     = isset( $assoc_args ) && array_key_exists( 'name', $assoc_args ) ? $assoc_args['name'] : '';
374
-		$create   = isset( $assoc_args ) && array_key_exists( 'create', $assoc_args ) ? $assoc_args['create'] : false;
375
-		$number   = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10;
376
-		$form_id  = isset( $assoc_args ) && array_key_exists( 'form-id', $assoc_args ) ? $assoc_args['form-id'] : 0;
377
-		$format   = isset( $assoc_args ) && array_key_exists( 'format', $assoc_args ) ? $assoc_args['format'] : 'table';
371
+		$donor_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : false;
372
+		$email    = isset($assoc_args) && array_key_exists('email', $assoc_args) ? $assoc_args['email'] : false;
373
+		$name     = isset($assoc_args) && array_key_exists('name', $assoc_args) ? $assoc_args['name'] : '';
374
+		$create   = isset($assoc_args) && array_key_exists('create', $assoc_args) ? $assoc_args['create'] : false;
375
+		$number   = isset($assoc_args) && array_key_exists('number', $assoc_args) ? $assoc_args['number'] : 10;
376
+		$form_id  = isset($assoc_args) && array_key_exists('form-id', $assoc_args) ? $assoc_args['form-id'] : 0;
377
+		$format   = isset($assoc_args) && array_key_exists('format', $assoc_args) ? $assoc_args['format'] : 'table';
378 378
 		$start    = time();
379 379
 
380
-		if ( $create ) {
380
+		if ($create) {
381 381
 			$number = 1;
382 382
 
383
-			if ( isset( $assoc_args['email'] ) && ! is_email( $email ) ) {
384
-				WP_CLI::warning( 'Wrong email address provided.', 'give' );
383
+			if (isset($assoc_args['email']) && ! is_email($email)) {
384
+				WP_CLI::warning('Wrong email address provided.', 'give');
385 385
 
386 386
 				return;
387 387
 			}
388 388
 
389 389
 			// Create one or more donors.
390
-			if ( ! $email ) {
390
+			if ( ! $email) {
391 391
 				// If no email is specified, look to see if we are generating arbitrary donor accounts.
392
-				$number = is_numeric( $create ) ? absint( $create ) : 1;
392
+				$number = is_numeric($create) ? absint($create) : 1;
393 393
 			}
394 394
 
395
-			for ( $i = 0; $i < $number; $i ++ ) {
396
-				if ( ! $email ) {
395
+			for ($i = 0; $i < $number; $i++) {
396
+				if ( ! $email) {
397 397
 
398 398
 					// Generate fake email.
399
-					$email = 'customer-' . uniqid() . '@test.com';
399
+					$email = 'customer-'.uniqid().'@test.com';
400 400
 				}
401 401
 
402 402
 				$args = array(
@@ -404,19 +404,19 @@  discard block
 block discarded – undo
404 404
 					'name'  => $name,
405 405
 				);
406 406
 
407
-				$donor_id = Give()->donors->add( $args );
407
+				$donor_id = Give()->donors->add($args);
408 408
 
409
-				if ( $donor_id ) {
410
-					WP_CLI::line( $this->color_message( sprintf( __( 'Donor #%d created successfully', 'give' ), $donor_id ) ) );
409
+				if ($donor_id) {
410
+					WP_CLI::line($this->color_message(sprintf(__('Donor #%d created successfully', 'give'), $donor_id)));
411 411
 				} else {
412
-					WP_CLI::error( __( 'Failed to create donor', 'give' ) );
412
+					WP_CLI::error(__('Failed to create donor', 'give'));
413 413
 				}
414 414
 
415 415
 				// Reset email to false so it is generated on the next loop (if creating donors).
416 416
 				$email = false;
417 417
 			}
418 418
 
419
-			WP_CLI::line( $this->color_message( sprintf( __( '%1$d donors created in %2$d seconds', 'give' ), $number, time() - $start ) ) );
419
+			WP_CLI::line($this->color_message(sprintf(__('%1$d donors created in %2$d seconds', 'give'), $number, time() - $start)));
420 420
 
421 421
 		} else {
422 422
 			// Counter.
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
 			 */
431 431
 			// Cache previous number query var.
432 432
 			$is_set_number = $cache_per_page = false;
433
-			if ( isset( $wp_query->query_vars['number'] ) ) {
433
+			if (isset($wp_query->query_vars['number'])) {
434 434
 				$cache_per_page = $wp_query->query_vars['number'];
435 435
 				$is_set_number  = true;
436 436
 			}
@@ -439,24 +439,24 @@  discard block
 block discarded – undo
439 439
 			$wp_query->query_vars['number'] = $number;
440 440
 
441 441
 			// Get donors.
442
-			if ( $form_id ) {
442
+			if ($form_id) {
443 443
 				// @TODO: Allow user to get a list of donors by donation status.
444
-				$donors = $this->get_donors_by_form_id( $form_id );
444
+				$donors = $this->get_donors_by_form_id($form_id);
445 445
 			} else {
446
-				$donors = $this->api->get_donors( $search );
446
+				$donors = $this->api->get_donors($search);
447 447
 			}
448 448
 
449 449
 			// Reset number query var.
450
-			if ( $is_set_number ) {
450
+			if ($is_set_number) {
451 451
 				$wp_query->query_vars['number'] = $cache_per_page;
452 452
 			}
453 453
 
454
-			if ( isset( $donors['error'] ) ) {
455
-				WP_CLI::error( $donors['error'] );
454
+			if (isset($donors['error'])) {
455
+				WP_CLI::error($donors['error']);
456 456
 			}
457 457
 
458
-			if ( empty( $donors ) ) {
459
-				WP_CLI::error( __( 'No donors found.', 'give' ) );
458
+			if (empty($donors)) {
459
+				WP_CLI::error(__('No donors found.', 'give'));
460 460
 
461 461
 				return;
462 462
 			}
@@ -464,24 +464,24 @@  discard block
 block discarded – undo
464 464
 			$table_data             = array();
465 465
 			$is_table_first_row_set = false;
466 466
 
467
-			foreach ( $donors['donors'] as $donor_data ) {
467
+			foreach ($donors['donors'] as $donor_data) {
468 468
 				// Set default table row data.
469
-				$table_first_row = array( __( 's_no', 'give' ) );
470
-				$table_row       = array( self::$counter );
469
+				$table_first_row = array(__('s_no', 'give'));
470
+				$table_row       = array(self::$counter);
471 471
 
472
-				foreach ( $donor_data as $key => $donor ) {
473
-					switch ( $key ) {
472
+				foreach ($donor_data as $key => $donor) {
473
+					switch ($key) {
474 474
 						case 'stats':
475
-							foreach ( $donor as $heading => $data ) {
475
+							foreach ($donor as $heading => $data) {
476 476
 
477 477
 								// Get first row.
478
-								if ( ! $is_table_first_row_set ) {
478
+								if ( ! $is_table_first_row_set) {
479 479
 									$table_first_row[] = $heading;
480 480
 								}
481 481
 
482
-								switch ( $heading ) {
482
+								switch ($heading) {
483 483
 									case 'total_spent':
484
-										$table_row[] = give_currency_filter( $data );
484
+										$table_row[] = give_currency_filter($data);
485 485
 										break;
486 486
 
487 487
 									default:
@@ -492,10 +492,10 @@  discard block
 block discarded – undo
492 492
 
493 493
 						case 'info':
494 494
 						default:
495
-							foreach ( $donor as $heading => $data ) {
495
+							foreach ($donor as $heading => $data) {
496 496
 
497 497
 								// Get first row.
498
-								if ( ! $is_table_first_row_set ) {
498
+								if ( ! $is_table_first_row_set) {
499 499
 									$table_first_row[] = $heading;
500 500
 								}
501 501
 
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 				}
506 506
 
507 507
 				// Add first row data to table data.
508
-				if ( ! $is_table_first_row_set ) {
508
+				if ( ! $is_table_first_row_set) {
509 509
 					$table_data[]           = $table_first_row;
510 510
 					$is_table_first_row_set = true;
511 511
 				}
@@ -514,44 +514,44 @@  discard block
 block discarded – undo
514 514
 				$table_data[] = $table_row;
515 515
 
516 516
 				// Increase counter.
517
-				self::$counter ++;
517
+				self::$counter++;
518 518
 			}// End foreach().
519 519
 
520
-			switch ( $format ) {
520
+			switch ($format) {
521 521
 				case 'json':
522 522
 					$table_column_name = $table_data[0];
523
-					unset( $table_data[0] );
523
+					unset($table_data[0]);
524 524
 
525 525
 					$new_table_data = array();
526
-					foreach ( $table_data as $index => $data ) {
527
-						foreach ( $data as $key => $value ) {
528
-							$new_table_data[ $index ][ $table_column_name[ $key ] ] = $value;
526
+					foreach ($table_data as $index => $data) {
527
+						foreach ($data as $key => $value) {
528
+							$new_table_data[$index][$table_column_name[$key]] = $value;
529 529
 						}
530 530
 					}
531 531
 
532
-					WP_CLI::log( json_encode( $new_table_data ) );
532
+					WP_CLI::log(json_encode($new_table_data));
533 533
 					break;
534 534
 
535 535
 				case 'csv':
536
-					$file_path = trailingslashit( WP_CONTENT_DIR ) . 'uploads/give_donors_' . date( 'Y_m_d_s', current_time( 'timestamp' ) ) . '.csv';
537
-					$fp        = fopen( $file_path, 'w' );
536
+					$file_path = trailingslashit(WP_CONTENT_DIR).'uploads/give_donors_'.date('Y_m_d_s', current_time('timestamp')).'.csv';
537
+					$fp        = fopen($file_path, 'w');
538 538
 
539
-					if ( is_writable( $file_path ) ) {
540
-						foreach ( $table_data as $fields ) {
541
-							fputcsv( $fp, $fields );
539
+					if (is_writable($file_path)) {
540
+						foreach ($table_data as $fields) {
541
+							fputcsv($fp, $fields);
542 542
 						}
543 543
 
544
-						fclose( $fp );
544
+						fclose($fp);
545 545
 
546
-						WP_CLI::success( "Donors list csv created successfully: {$file_path}" );
546
+						WP_CLI::success("Donors list csv created successfully: {$file_path}");
547 547
 					} else {
548
-						WP_CLI::warning( "Unable to create donors list csv file: {$file_path} (May folder do not have write permission)" );
548
+						WP_CLI::warning("Unable to create donors list csv file: {$file_path} (May folder do not have write permission)");
549 549
 					}
550 550
 
551 551
 					break;
552 552
 
553 553
 				default:
554
-					$this->display_table( $table_data );
554
+					$this->display_table($table_data);
555 555
 			}// End switch().
556 556
 		}// End if().
557 557
 	}
@@ -581,13 +581,13 @@  discard block
 block discarded – undo
581 581
 	 *
582 582
 	 * @subcommand    donations
583 583
 	 */
584
-	public function donations( $args, $assoc_args ) {
584
+	public function donations($args, $assoc_args) {
585 585
 		global $wp_query;
586
-		$number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10;
586
+		$number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? $assoc_args['number'] : 10;
587 587
 
588 588
 		// Cache previous number query var.
589 589
 		$is_set_number = $cache_per_page = false;
590
-		if ( isset( $wp_query->query_vars['number'] ) ) {
590
+		if (isset($wp_query->query_vars['number'])) {
591 591
 			$cache_per_page = $wp_query->query_vars['number'];
592 592
 			$is_set_number  = true;
593 593
 		}
@@ -599,46 +599,46 @@  discard block
 block discarded – undo
599 599
 		$donations = $this->api->get_recent_donations();
600 600
 
601 601
 		// Reset number query var.
602
-		if ( $is_set_number ) {
602
+		if ($is_set_number) {
603 603
 			$wp_query->query_vars['number'] = $cache_per_page;
604 604
 		}
605 605
 
606
-		if ( empty( $donations ) ) {
607
-			WP_CLI::error( __( 'No donations found.', 'give' ) );
606
+		if (empty($donations)) {
607
+			WP_CLI::error(__('No donations found.', 'give'));
608 608
 
609 609
 			return;
610 610
 		}
611 611
 
612 612
 		self::$counter = 1;
613 613
 
614
-		foreach ( $donations['donations'] as $key => $donation ) {
615
-			$this->color_main_heading( sprintf( __( '%1$s. Donation #%2$s', 'give' ), self::$counter, $donation['ID'] ), 'Y' );
616
-			self::$counter ++;
614
+		foreach ($donations['donations'] as $key => $donation) {
615
+			$this->color_main_heading(sprintf(__('%1$s. Donation #%2$s', 'give'), self::$counter, $donation['ID']), 'Y');
616
+			self::$counter++;
617 617
 
618
-			foreach ( $donation as $column => $data ) {
618
+			foreach ($donation as $column => $data) {
619 619
 
620
-				if ( is_array( $data ) ) {
621
-					$this->color_sub_heading( $column );
622
-					foreach ( $data as $subcolumn => $subdata ) {
620
+				if (is_array($data)) {
621
+					$this->color_sub_heading($column);
622
+					foreach ($data as $subcolumn => $subdata) {
623 623
 
624 624
 						// Decode html codes.
625
-						switch ( $subcolumn ) {
625
+						switch ($subcolumn) {
626 626
 							case 'name':
627
-								$subdata = html_entity_decode( $subdata );
627
+								$subdata = html_entity_decode($subdata);
628 628
 								break;
629 629
 						}
630 630
 
631 631
 						// @TODO Check if multi dimension array information is importent to show or not. For example inside donation array we have array for fees data inside payment meta.
632
-						if ( is_array( $subdata ) ) {
632
+						if (is_array($subdata)) {
633 633
 							continue;
634 634
 						}
635 635
 
636
-						WP_CLI::log( $this->color_message( $subcolumn, $subdata ) );
636
+						WP_CLI::log($this->color_message($subcolumn, $subdata));
637 637
 					}
638 638
 					continue;
639 639
 				}
640 640
 
641
-				WP_CLI::log( $this->color_message( $column, $data ) );
641
+				WP_CLI::log($this->color_message($column, $data));
642 642
 			}
643 643
 		}
644 644
 	}
@@ -677,27 +677,27 @@  discard block
 block discarded – undo
677 677
 	 *
678 678
 	 * @return        void
679 679
 	 */
680
-	public function report( $args, $assoc_args ) {
680
+	public function report($args, $assoc_args) {
681 681
 		$stats      = new Give_Payment_Stats();
682
-		$date       = isset( $assoc_args ) && array_key_exists( 'date', $assoc_args ) ? $assoc_args['date'] : false;
683
-		$start_date = isset( $assoc_args ) && array_key_exists( 'start-date', $assoc_args ) ? $assoc_args['start-date'] : false;
684
-		$end_date   = isset( $assoc_args ) && array_key_exists( 'end-date', $assoc_args ) ? $assoc_args['end-date'] : false;
685
-		$form_id    = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? $assoc_args['id'] : 0;
682
+		$date       = isset($assoc_args) && array_key_exists('date', $assoc_args) ? $assoc_args['date'] : false;
683
+		$start_date = isset($assoc_args) && array_key_exists('start-date', $assoc_args) ? $assoc_args['start-date'] : false;
684
+		$end_date   = isset($assoc_args) && array_key_exists('end-date', $assoc_args) ? $assoc_args['end-date'] : false;
685
+		$form_id    = isset($assoc_args) && array_key_exists('id', $assoc_args) ? $assoc_args['id'] : 0;
686 686
 
687
-		if ( ! empty( $date ) ) {
687
+		if ( ! empty($date)) {
688 688
 			$start_date = $date;
689 689
 			$end_date   = false;
690
-		} elseif ( empty( $date ) && empty( $start_date ) ) {
690
+		} elseif (empty($date) && empty($start_date)) {
691 691
 			$start_date = 'this_month';
692 692
 			$end_date   = false;
693 693
 		}
694 694
 
695 695
 		// Get stats.
696
-		$earnings = $stats->get_earnings( $form_id, $start_date, $end_date );
697
-		$sales    = $stats->get_sales( $form_id, $start_date, $end_date );
696
+		$earnings = $stats->get_earnings($form_id, $start_date, $end_date);
697
+		$sales    = $stats->get_sales($form_id, $start_date, $end_date);
698 698
 
699
-		WP_CLI::line( $this->color_message( __( 'Earnings', 'give' ), give_currency_filter( $earnings ) ) );
700
-		WP_CLI::line( $this->color_message( __( 'Sales', 'give' ), $sales ) );
699
+		WP_CLI::line($this->color_message(__('Earnings', 'give'), give_currency_filter($earnings)));
700
+		WP_CLI::line($this->color_message(__('Sales', 'give'), $sales));
701 701
 	}
702 702
 
703 703
 
@@ -724,27 +724,27 @@  discard block
 block discarded – undo
724 724
 	 *
725 725
 	 * @subcommand    cache
726 726
 	 */
727
-	public function cache( $args, $assoc_args ) {
728
-		$action = isset( $assoc_args ) && array_key_exists( 'action', $assoc_args ) ? $assoc_args['action'] : false;
727
+	public function cache($args, $assoc_args) {
728
+		$action = isset($assoc_args) && array_key_exists('action', $assoc_args) ? $assoc_args['action'] : false;
729 729
 
730 730
 		// Bailout.
731
-		if ( ! $action || ! in_array( $action, array( 'delete' ), true ) ) {
732
-			WP_CLI::warning( __( 'Type wp give cache --action=delete to delete all stat transients', 'give' ) );
731
+		if ( ! $action || ! in_array($action, array('delete'), true)) {
732
+			WP_CLI::warning(__('Type wp give cache --action=delete to delete all stat transients', 'give'));
733 733
 
734 734
 			return;
735 735
 		}
736 736
 
737
-		switch ( $action ) {
737
+		switch ($action) {
738 738
 			case 'delete' :
739 739
 				// Reset counter.
740 740
 				self::$counter = 1;
741 741
 
742
-				if ( $this->delete_stats_transients() ) {
742
+				if ($this->delete_stats_transients()) {
743 743
 					// Report .eading.
744
-					WP_CLI::success( 'Give cache deleted.' );
744
+					WP_CLI::success('Give cache deleted.');
745 745
 				} else {
746 746
 					// Report .eading.
747
-					WP_CLI::warning( 'We did not find any Give plugin cache to delete :)' );
747
+					WP_CLI::warning('We did not find any Give plugin cache to delete :)');
748 748
 				}
749 749
 				break;
750 750
 		}
@@ -773,27 +773,27 @@  discard block
 block discarded – undo
773 773
 			ARRAY_A
774 774
 		);
775 775
 
776
-		if ( ! empty( $stat_option_names ) ) {
776
+		if ( ! empty($stat_option_names)) {
777 777
 
778
-			foreach ( $stat_option_names as $option_name ) {
778
+			foreach ($stat_option_names as $option_name) {
779 779
 				$error       = false;
780 780
 				$option_name = $option_name['option_name'];
781 781
 
782
-				switch ( true ) {
783
-					case ( false !== strpos( $option_name, 'transient' ) ):
784
-						$option_name = str_replace( '_transient_', '', $option_name );
785
-						$error       = delete_transient( $option_name );
782
+				switch (true) {
783
+					case (false !== strpos($option_name, 'transient')):
784
+						$option_name = str_replace('_transient_', '', $option_name);
785
+						$error       = delete_transient($option_name);
786 786
 						break;
787 787
 
788 788
 					default:
789
-						$error = delete_option( $option_name );
789
+						$error = delete_option($option_name);
790 790
 				}
791 791
 
792
-				if ( $error ) {
793
-					WP_CLI::log( $this->color_message( self::$counter, $option_name ) );
794
-					self::$counter ++;
792
+				if ($error) {
793
+					WP_CLI::log($this->color_message(self::$counter, $option_name));
794
+					self::$counter++;
795 795
 				} else {
796
-					WP_CLI::log( $this->color_message( __( 'Error while deleting this transient', 'give' ), $option_name ) );
796
+					WP_CLI::log($this->color_message(__('Error while deleting this transient', 'give'), $option_name));
797 797
 				}
798 798
 			}
799 799
 
@@ -814,13 +814,13 @@  discard block
 block discarded – undo
814 814
 	 *
815 815
 	 * @return   string
816 816
 	 */
817
-	private function color_message( $heading, $message = '', $colon = true, $color = 'g' ) {
817
+	private function color_message($heading, $message = '', $colon = true, $color = 'g') {
818 818
 		// Add colon.
819
-		if ( $colon ) {
820
-			$heading = $heading . ': ';
819
+		if ($colon) {
820
+			$heading = $heading.': ';
821 821
 		}
822 822
 
823
-		return WP_CLI::colorize( "%{$color}" . $heading . '%n' ) . $message;
823
+		return WP_CLI::colorize("%{$color}".$heading.'%n').$message;
824 824
 	}
825 825
 
826 826
 
@@ -835,8 +835,8 @@  discard block
 block discarded – undo
835 835
 	 *
836 836
 	 * @return    void
837 837
 	 */
838
-	private function color_main_heading( $heading, $color = 'g' ) {
839
-		WP_CLI::log( "\n######   " . $this->color_message( $heading, '', false, $color ) . '   ######' );
838
+	private function color_main_heading($heading, $color = 'g') {
839
+		WP_CLI::log("\n######   ".$this->color_message($heading, '', false, $color).'   ######');
840 840
 	}
841 841
 
842 842
 	/**
@@ -849,8 +849,8 @@  discard block
 block discarded – undo
849 849
 	 *
850 850
 	 * @return    void
851 851
 	 */
852
-	private function color_sub_heading( $subheading ) {
853
-		WP_CLI::log( "\n--->" . $subheading . '', '', false );
852
+	private function color_sub_heading($subheading) {
853
+		WP_CLI::log("\n--->".$subheading.'', '', false);
854 854
 	}
855 855
 
856 856
 
@@ -864,17 +864,17 @@  discard block
 block discarded – undo
864 864
 	 *
865 865
 	 * @return    void
866 866
 	 */
867
-	private function display_table( $data ) {
867
+	private function display_table($data) {
868 868
 		$table = new \cli\Table();
869 869
 
870 870
 		// Set table header.
871
-		$table->setHeaders( $data[0] );
871
+		$table->setHeaders($data[0]);
872 872
 
873 873
 		// Remove table header.
874
-		unset( $data[0] );
874
+		unset($data[0]);
875 875
 
876 876
 		// Set table data.
877
-		$table->setRows( $data );
877
+		$table->setRows($data);
878 878
 
879 879
 		// Display table.
880 880
 		$table->display();
@@ -891,14 +891,14 @@  discard block
 block discarded – undo
891 891
 	 * @return array
892 892
 	 */
893 893
 
894
-	private function get_donors_by_form_id( $form_id ) {
894
+	private function get_donors_by_form_id($form_id) {
895 895
 		$donors = array();
896 896
 
897 897
 		$donations = new Give_Payments_Query(
898 898
 			array(
899
-				'give_forms' => array( $form_id ),
900
-				'number'     => - 1,
901
-				'status'     => array( 'publish' ),
899
+				'give_forms' => array($form_id),
900
+				'number'     => -1,
901
+				'status'     => array('publish'),
902 902
 			)
903 903
 		);
904 904
 
@@ -906,16 +906,16 @@  discard block
 block discarded – undo
906 906
 		$skip_donors = array();
907 907
 
908 908
 		/* @var Give_Payment|object $donation Payment object. */
909
-		foreach ( $donations as $donation ) {
909
+		foreach ($donations as $donation) {
910 910
 
911
-			if ( in_array( $donation->customer_id, $skip_donors ) ) {
911
+			if (in_array($donation->customer_id, $skip_donors)) {
912 912
 				continue;
913 913
 			}
914 914
 
915
-			if ( ! empty( $donors ) ) {
916
-				$donors['donors'][] = current( current( $this->api->get_donors( (int) $donation->customer_id ) ) );
915
+			if ( ! empty($donors)) {
916
+				$donors['donors'][] = current(current($this->api->get_donors((int) $donation->customer_id)));
917 917
 			} else {
918
-				$donors = array_merge( $donors, $this->api->get_donors( (int) $donation->customer_id ) );
918
+				$donors = array_merge($donors, $this->api->get_donors((int) $donation->customer_id));
919 919
 			}
920 920
 
921 921
 			$skip_donors[] = $donation->customer_id;
Please login to merge, or discard this patch.
includes/ajax-functions.php 1 patch
Spacing   +104 added lines, -104 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
 
@@ -26,26 +26,26 @@  discard block
 block discarded – undo
26 26
 function give_test_ajax_works() {
27 27
 
28 28
 	// Check if the Airplane Mode plugin is installed.
29
-	if ( class_exists( 'Airplane_Mode_Core' ) ) {
29
+	if (class_exists('Airplane_Mode_Core')) {
30 30
 
31 31
 		$airplane = Airplane_Mode_Core::getInstance();
32 32
 
33
-		if ( method_exists( $airplane, 'enabled' ) ) {
33
+		if (method_exists($airplane, 'enabled')) {
34 34
 
35
-			if ( $airplane->enabled() ) {
35
+			if ($airplane->enabled()) {
36 36
 				return true;
37 37
 			}
38 38
 		} else {
39 39
 
40
-			if ( 'on' === $airplane->check_status()  ) {
40
+			if ('on' === $airplane->check_status()) {
41 41
 				return true;
42 42
 			}
43 43
 		}
44 44
 	}
45 45
 
46
-	add_filter( 'block_local_requests', '__return_false' );
46
+	add_filter('block_local_requests', '__return_false');
47 47
 
48
-	if ( Give_Cache::get( '_give_ajax_works', true ) ) {
48
+	if (Give_Cache::get('_give_ajax_works', true)) {
49 49
 		return true;
50 50
 	}
51 51
 
@@ -57,35 +57,35 @@  discard block
 block discarded – undo
57 57
 		),
58 58
 	);
59 59
 
60
-	$ajax = wp_remote_post( give_get_ajax_url(), $params );
60
+	$ajax = wp_remote_post(give_get_ajax_url(), $params);
61 61
 
62 62
 	$works = true;
63 63
 
64
-	if ( is_wp_error( $ajax ) ) {
64
+	if (is_wp_error($ajax)) {
65 65
 
66 66
 		$works = false;
67 67
 
68 68
 	} else {
69 69
 
70
-		if ( empty( $ajax['response'] ) ) {
70
+		if (empty($ajax['response'])) {
71 71
 			$works = false;
72 72
 		}
73 73
 
74
-		if ( empty( $ajax['response']['code'] ) || 200 !== (int) $ajax['response']['code'] ) {
74
+		if (empty($ajax['response']['code']) || 200 !== (int) $ajax['response']['code']) {
75 75
 			$works = false;
76 76
 		}
77 77
 
78
-		if ( empty( $ajax['response']['message'] ) || 'OK' !== $ajax['response']['message'] ) {
78
+		if (empty($ajax['response']['message']) || 'OK' !== $ajax['response']['message']) {
79 79
 			$works = false;
80 80
 		}
81 81
 
82
-		if ( ! isset( $ajax['body'] ) || 0 !== (int) $ajax['body'] ) {
82
+		if ( ! isset($ajax['body']) || 0 !== (int) $ajax['body']) {
83 83
 			$works = false;
84 84
 		}
85 85
 	}
86 86
 
87
-	if ( $works ) {
88
-		Give_Cache::set( '_give_ajax_works', '1', DAY_IN_SECONDS, true );
87
+	if ($works) {
88
+		Give_Cache::set('_give_ajax_works', '1', DAY_IN_SECONDS, true);
89 89
 	}
90 90
 
91 91
 	return $works;
@@ -100,16 +100,16 @@  discard block
 block discarded – undo
100 100
  * @return string
101 101
  */
102 102
 function give_get_ajax_url() {
103
-	$scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
103
+	$scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin';
104 104
 
105 105
 	$current_url = give_get_current_page_url();
106
-	$ajax_url    = admin_url( 'admin-ajax.php', $scheme );
106
+	$ajax_url    = admin_url('admin-ajax.php', $scheme);
107 107
 
108
-	if ( preg_match( '/^https/', $current_url ) && ! preg_match( '/^https/', $ajax_url ) ) {
109
-		$ajax_url = preg_replace( '/^http/', 'https', $ajax_url );
108
+	if (preg_match('/^https/', $current_url) && ! preg_match('/^https/', $ajax_url)) {
109
+		$ajax_url = preg_replace('/^http/', 'https', $ajax_url);
110 110
 	}
111 111
 
112
-	return apply_filters( 'give_ajax_url', $ajax_url );
112
+	return apply_filters('give_ajax_url', $ajax_url);
113 113
 }
114 114
 
115 115
 /**
@@ -125,12 +125,12 @@  discard block
 block discarded – undo
125 125
 	 *
126 126
 	 * @since 1.7
127 127
 	 */
128
-	do_action( 'give_donation_form_login_fields' );
128
+	do_action('give_donation_form_login_fields');
129 129
 
130 130
 	give_die();
131 131
 }
132 132
 
133
-add_action( 'wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields' );
133
+add_action('wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields');
134 134
 
135 135
 /**
136 136
  * Load Checkout Fields
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
  * @return void
141 141
  */
142 142
 function give_load_checkout_fields() {
143
-	$form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : '';
143
+	$form_id = isset($_POST['form_id']) ? $_POST['form_id'] : '';
144 144
 
145 145
 	ob_start();
146 146
 
@@ -149,18 +149,18 @@  discard block
 block discarded – undo
149 149
 	 *
150 150
 	 * @since 1.7
151 151
 	 */
152
-	do_action( 'give_donation_form_register_login_fields', $form_id );
152
+	do_action('give_donation_form_register_login_fields', $form_id);
153 153
 
154 154
 	$fields = ob_get_clean();
155 155
 
156
-	wp_send_json( array(
157
-		'fields' => wp_json_encode( $fields ),
158
-		'submit' => wp_json_encode( give_get_donation_form_submit_button( $form_id ) ),
159
-	) );
156
+	wp_send_json(array(
157
+		'fields' => wp_json_encode($fields),
158
+		'submit' => wp_json_encode(give_get_donation_form_submit_button($form_id)),
159
+	));
160 160
 }
161 161
 
162
-add_action( 'wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields' );
163
-add_action( 'wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields' );
162
+add_action('wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields');
163
+add_action('wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields');
164 164
 
165 165
 /**
166 166
  * Get Form Title via AJAX (used only in WordPress Admin)
@@ -170,9 +170,9 @@  discard block
 block discarded – undo
170 170
  * @return void
171 171
  */
172 172
 function give_ajax_get_form_title() {
173
-	if ( isset( $_POST['form_id'] ) ) {
174
-		$title = get_the_title( $_POST['form_id'] );
175
-		if ( $title ) {
173
+	if (isset($_POST['form_id'])) {
174
+		$title = get_the_title($_POST['form_id']);
175
+		if ($title) {
176 176
 			echo $title;
177 177
 		} else {
178 178
 			echo 'fail';
@@ -181,8 +181,8 @@  discard block
 block discarded – undo
181 181
 	give_die();
182 182
 }
183 183
 
184
-add_action( 'wp_ajax_give_get_form_title', 'give_ajax_get_form_title' );
185
-add_action( 'wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title' );
184
+add_action('wp_ajax_give_get_form_title', 'give_ajax_get_form_title');
185
+add_action('wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title');
186 186
 
187 187
 /**
188 188
  * Retrieve a states drop down
@@ -193,23 +193,23 @@  discard block
 block discarded – undo
193 193
  */
194 194
 function give_ajax_get_states_field() {
195 195
 
196
-	if ( empty( $_POST['country'] ) ) {
196
+	if (empty($_POST['country'])) {
197 197
 		$_POST['country'] = give_get_country();
198 198
 	}
199
-	$states = give_get_states( $_POST['country'] );
199
+	$states = give_get_states($_POST['country']);
200 200
 
201
-	if ( ! empty( $states ) ) {
201
+	if ( ! empty($states)) {
202 202
 
203 203
 		$args = array(
204 204
 			'name'             => $_POST['field_name'],
205 205
 			'id'               => $_POST['field_name'],
206
-			'class'            => $_POST['field_name'] . '  give-select',
207
-			'options'          => give_get_states( $_POST['country'] ),
206
+			'class'            => $_POST['field_name'].'  give-select',
207
+			'options'          => give_get_states($_POST['country']),
208 208
 			'show_option_all'  => false,
209 209
 			'show_option_none' => false,
210 210
 		);
211 211
 
212
-		$response = Give()->html->select( $args );
212
+		$response = Give()->html->select($args);
213 213
 
214 214
 	} else {
215 215
 
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 	give_die();
222 222
 }
223 223
 
224
-add_action( 'wp_ajax_give_get_states', 'give_ajax_get_states_field' );
225
-add_action( 'wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field' );
224
+add_action('wp_ajax_give_get_states', 'give_ajax_get_states_field');
225
+add_action('wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field');
226 226
 
227 227
 /**
228 228
  * Retrieve donation forms via AJAX for chosen dropdown search field.
@@ -234,19 +234,19 @@  discard block
 block discarded – undo
234 234
 function give_ajax_form_search() {
235 235
 	global $wpdb;
236 236
 
237
-	$search   = esc_sql( sanitize_text_field( $_GET['s'] ) );
238
-	$excludes = ( isset( $_GET['current_id'] ) ? (array) $_GET['current_id'] : array() );
237
+	$search   = esc_sql(sanitize_text_field($_GET['s']));
238
+	$excludes = (isset($_GET['current_id']) ? (array) $_GET['current_id'] : array());
239 239
 
240 240
 	$results = array();
241
-	if ( current_user_can( 'edit_give_forms' ) ) {
242
-		$items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50" );
241
+	if (current_user_can('edit_give_forms')) {
242
+		$items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50");
243 243
 	} else {
244
-		$items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50" );
244
+		$items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50");
245 245
 	}
246 246
 
247
-	if ( $items ) {
247
+	if ($items) {
248 248
 
249
-		foreach ( $items as $item ) {
249
+		foreach ($items as $item) {
250 250
 
251 251
 			$results[] = array(
252 252
 				'id'   => $item->ID,
@@ -257,18 +257,18 @@  discard block
 block discarded – undo
257 257
 
258 258
 		$items[] = array(
259 259
 			'id'   => 0,
260
-			'name' => __( 'No forms found.', 'give' ),
260
+			'name' => __('No forms found.', 'give'),
261 261
 		);
262 262
 
263 263
 	}
264 264
 
265
-	echo json_encode( $results );
265
+	echo json_encode($results);
266 266
 
267 267
 	give_die();
268 268
 }
269 269
 
270
-add_action( 'wp_ajax_give_form_search', 'give_ajax_form_search' );
271
-add_action( 'wp_ajax_nopriv_give_form_search', 'give_ajax_form_search' );
270
+add_action('wp_ajax_give_form_search', 'give_ajax_form_search');
271
+add_action('wp_ajax_nopriv_give_form_search', 'give_ajax_form_search');
272 272
 
273 273
 /**
274 274
  * Search the donors database via Ajax
@@ -280,38 +280,38 @@  discard block
 block discarded – undo
280 280
 function give_ajax_donor_search() {
281 281
 	global $wpdb;
282 282
 
283
-	$search  = esc_sql( sanitize_text_field( $_GET['s'] ) );
283
+	$search  = esc_sql(sanitize_text_field($_GET['s']));
284 284
 	$results = array();
285
-	if ( ! current_user_can( 'view_give_reports' ) ) {
285
+	if ( ! current_user_can('view_give_reports')) {
286 286
 		$donors = array();
287 287
 	} else {
288
-		$donors = $wpdb->get_results( "SELECT id,name,email FROM {$wpdb->prefix}give_customers WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50" );
288
+		$donors = $wpdb->get_results("SELECT id,name,email FROM {$wpdb->prefix}give_customers WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50");
289 289
 	}
290 290
 
291
-	if ( $donors ) {
291
+	if ($donors) {
292 292
 
293
-		foreach ( $donors as $donor ) {
293
+		foreach ($donors as $donor) {
294 294
 
295 295
 			$results[] = array(
296 296
 				'id'   => $donor->id,
297
-				'name' => $donor->name . ' (' . $donor->email . ')',
297
+				'name' => $donor->name.' ('.$donor->email.')',
298 298
 			);
299 299
 		}
300 300
 	} else {
301 301
 
302 302
 		$donors[] = array(
303 303
 			'id'   => 0,
304
-			'name' => __( 'No donors found.', 'give' ),
304
+			'name' => __('No donors found.', 'give'),
305 305
 		);
306 306
 
307 307
 	}
308 308
 
309
-	echo json_encode( $results );
309
+	echo json_encode($results);
310 310
 
311 311
 	give_die();
312 312
 }
313 313
 
314
-add_action( 'wp_ajax_give_donor_search', 'give_ajax_donor_search' );
314
+add_action('wp_ajax_give_donor_search', 'give_ajax_donor_search');
315 315
 
316 316
 
317 317
 /**
@@ -323,39 +323,39 @@  discard block
 block discarded – undo
323 323
  */
324 324
 function give_ajax_search_users() {
325 325
 
326
-	if ( current_user_can( 'manage_give_settings' ) ) {
326
+	if (current_user_can('manage_give_settings')) {
327 327
 
328
-		$search   = esc_sql( sanitize_text_field( $_GET['s'] ) );
328
+		$search = esc_sql(sanitize_text_field($_GET['s']));
329 329
 
330 330
 		$get_users_args = array(
331 331
 			'number' => 9999,
332
-			'search' => $search . '*',
332
+			'search' => $search.'*',
333 333
 		);
334 334
 
335
-		$get_users_args = apply_filters( 'give_search_users_args', $get_users_args );
335
+		$get_users_args = apply_filters('give_search_users_args', $get_users_args);
336 336
 
337
-		$found_users = apply_filters( 'give_ajax_found_users', get_users( $get_users_args ), $search );
337
+		$found_users = apply_filters('give_ajax_found_users', get_users($get_users_args), $search);
338 338
 		$results     = array();
339 339
 
340
-		if ( $found_users ) {
340
+		if ($found_users) {
341 341
 
342
-			foreach ( $found_users as $user ) {
342
+			foreach ($found_users as $user) {
343 343
 
344 344
 				$results[] = array(
345 345
 					'id'   => $user->ID,
346
-					'name' => esc_html( $user->user_login . ' (' . $user->user_email . ')' ),
346
+					'name' => esc_html($user->user_login.' ('.$user->user_email.')'),
347 347
 				);
348 348
 			}
349 349
 		} else {
350 350
 
351 351
 			$results[] = array(
352 352
 				'id'   => 0,
353
-				'name' => __( 'No users found.', 'give' ),
353
+				'name' => __('No users found.', 'give'),
354 354
 			);
355 355
 
356 356
 		}
357 357
 
358
-		echo json_encode( $results );
358
+		echo json_encode($results);
359 359
 
360 360
 	}// End if().
361 361
 
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 
364 364
 }
365 365
 
366
-add_action( 'wp_ajax_give_user_search', 'give_ajax_search_users' );
366
+add_action('wp_ajax_give_user_search', 'give_ajax_search_users');
367 367
 
368 368
 
369 369
 /**
@@ -375,32 +375,32 @@  discard block
 block discarded – undo
375 375
  */
376 376
 function give_check_for_form_price_variations() {
377 377
 
378
-	if ( ! current_user_can( 'edit_give_forms', get_current_user_id() ) ) {
379
-		die( '-1' );
378
+	if ( ! current_user_can('edit_give_forms', get_current_user_id())) {
379
+		die('-1');
380 380
 	}
381 381
 
382
-	$form_id = intval( $_POST['form_id'] );
383
-	$form    = get_post( $form_id );
382
+	$form_id = intval($_POST['form_id']);
383
+	$form    = get_post($form_id);
384 384
 
385
-	if ( 'give_forms' != $form->post_type ) {
386
-		die( '-2' );
385
+	if ('give_forms' != $form->post_type) {
386
+		die('-2');
387 387
 	}
388 388
 
389
-	if ( give_has_variable_prices( $form_id ) ) {
390
-		$variable_prices = give_get_variable_prices( $form_id );
389
+	if (give_has_variable_prices($form_id)) {
390
+		$variable_prices = give_get_variable_prices($form_id);
391 391
 
392
-		if ( $variable_prices ) {
392
+		if ($variable_prices) {
393 393
 			$ajax_response = '<select class="give_price_options_select give-select give-select" name="give_price_option">';
394 394
 
395
-			if ( isset( $_POST['all_prices'] ) ) {
396
-				$ajax_response .= '<option value="all">' . esc_html__( 'All Levels', 'give' ) . '</option>';
395
+			if (isset($_POST['all_prices'])) {
396
+				$ajax_response .= '<option value="all">'.esc_html__('All Levels', 'give').'</option>';
397 397
 			}
398 398
 
399
-			foreach ( $variable_prices as $key => $price ) {
399
+			foreach ($variable_prices as $key => $price) {
400 400
 
401
-				$level_text = ! empty( $price['_give_text'] ) ? esc_html( $price['_give_text'] ) : give_currency_filter( give_format_amount( $price['_give_amount'] ) );
401
+				$level_text = ! empty($price['_give_text']) ? esc_html($price['_give_text']) : give_currency_filter(give_format_amount($price['_give_amount']));
402 402
 
403
-				$ajax_response .= '<option value="' . esc_attr( $price['_give_id']['level_id'] ) . '">' . $level_text . '</option>';
403
+				$ajax_response .= '<option value="'.esc_attr($price['_give_id']['level_id']).'">'.$level_text.'</option>';
404 404
 			}
405 405
 			$ajax_response .= '</select>';
406 406
 			echo $ajax_response;
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 	give_die();
411 411
 }
412 412
 
413
-add_action( 'wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations' );
413
+add_action('wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations');
414 414
 
415 415
 
416 416
 /**
@@ -421,25 +421,25 @@  discard block
 block discarded – undo
421 421
  * @return void
422 422
  */
423 423
 function give_check_for_form_price_variations_html() {
424
-	if ( ! current_user_can( 'edit_give_payments', get_current_user_id() ) ) {
424
+	if ( ! current_user_can('edit_give_payments', get_current_user_id())) {
425 425
 		wp_die();
426 426
 	}
427 427
 
428
-	$form_id    = ! empty( $_POST['form_id'] ) ? intval( $_POST['form_id'] ) : 0;
429
-	$payment_id = ! empty( $_POST['payment_id'] ) ? intval( $_POST['payment_id'] ) : 0;
430
-	$form       = get_post( $form_id );
428
+	$form_id    = ! empty($_POST['form_id']) ? intval($_POST['form_id']) : 0;
429
+	$payment_id = ! empty($_POST['payment_id']) ? intval($_POST['payment_id']) : 0;
430
+	$form       = get_post($form_id);
431 431
 
432
-	if ( 'give_forms' != $form->post_type ) {
432
+	if ('give_forms' != $form->post_type) {
433 433
 		wp_die();
434 434
 	}
435 435
 
436
-	if ( ! give_has_variable_prices( $form_id ) || ! $form_id ) {
437
-		esc_html_e( 'n/a', 'give' );
436
+	if ( ! give_has_variable_prices($form_id) || ! $form_id) {
437
+		esc_html_e('n/a', 'give');
438 438
 	} else {
439 439
 		$prices_atts = '';
440
-		if ( $variable_prices = give_get_variable_prices( $form_id ) ) {
441
-			foreach ( $variable_prices as $variable_price ) {
442
-				$prices_atts[ $variable_price['_give_id']['level_id'] ] = give_format_amount( $variable_price['_give_amount'] );
440
+		if ($variable_prices = give_get_variable_prices($form_id)) {
441
+			foreach ($variable_prices as $variable_price) {
442
+				$prices_atts[$variable_price['_give_id']['level_id']] = give_format_amount($variable_price['_give_amount']);
443 443
 			}
444 444
 		}
445 445
 
@@ -450,12 +450,12 @@  discard block
 block discarded – undo
450 450
 			'chosen'           => true,
451 451
 			'show_option_all'  => '',
452 452
 			'show_option_none' => '',
453
-			'select_atts'      => 'data-prices=' . esc_attr( json_encode( $prices_atts ) ),
453
+			'select_atts'      => 'data-prices='.esc_attr(json_encode($prices_atts)),
454 454
 		);
455 455
 
456
-		if ( $payment_id ) {
456
+		if ($payment_id) {
457 457
 			// Payment object.
458
-			$payment = new Give_Payment( $payment_id );
458
+			$payment = new Give_Payment($payment_id);
459 459
 
460 460
 			// Payment meta.
461 461
 			$payment_meta                               = $payment->get_meta();
@@ -463,10 +463,10 @@  discard block
 block discarded – undo
463 463
 		}
464 464
 
465 465
 		// Render variable prices select tag html.
466
-		give_get_form_variable_price_dropdown( $variable_price_dropdown_option, true );
466
+		give_get_form_variable_price_dropdown($variable_price_dropdown_option, true);
467 467
 	}
468 468
 
469 469
 	give_die();
470 470
 }
471 471
 
472
-add_action( 'wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html' );
472
+add_action('wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html');
Please login to merge, or discard this patch.
includes/admin/class-i18n-module.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -65,18 +65,18 @@  discard block
 block discarded – undo
65 65
 	 *
66 66
 	 * @param $args
67 67
 	 */
68
-	public function __construct( $args ) {
68
+	public function __construct($args) {
69 69
 
70 70
 		// Only for admins.
71
-		if ( ! is_admin() ) {
71
+		if ( ! is_admin()) {
72 72
 			return;
73 73
 		}
74 74
 
75
-		foreach ( $args as $key => $arg ) {
75
+		foreach ($args as $key => $arg) {
76 76
 			$this->$key = $arg;
77 77
 		}
78 78
 
79
-		add_action( 'admin_init', array( $this, 'init' ) );
79
+		add_action('admin_init', array($this, 'init'));
80 80
 
81 81
 
82 82
 	}
@@ -87,15 +87,15 @@  discard block
 block discarded – undo
87 87
 	function init() {
88 88
 
89 89
 		// First get user's locale (4.7+).
90
-		$this->locale = function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
90
+		$this->locale = function_exists('get_user_locale') ? get_user_locale() : get_locale();
91 91
 
92 92
 		// This plugin is en_US native.
93
-		if ( 'en_US' === $this->locale ) {
93
+		if ('en_US' === $this->locale) {
94 94
 			return;
95 95
 		}
96 96
 
97
-		if ( ! $this->hide_promo() ) {
98
-			add_action( $this->hook, array( $this, 'promo' ) );
97
+		if ( ! $this->hide_promo()) {
98
+			add_action($this->hook, array($this, 'promo'));
99 99
 		}
100 100
 	}
101 101
 
@@ -108,11 +108,11 @@  discard block
 block discarded – undo
108 108
 	 * @return bool
109 109
 	 */
110 110
 	private function hide_promo() {
111
-		$hide_promo = Give_Cache::get( 'give_i18n_give_promo_hide', true );
112
-		if ( ! $hide_promo ) {
113
-			if ( filter_input( INPUT_GET, 'remove_i18n_promo', FILTER_VALIDATE_INT ) === 1 ) {
111
+		$hide_promo = Give_Cache::get('give_i18n_give_promo_hide', true);
112
+		if ( ! $hide_promo) {
113
+			if (filter_input(INPUT_GET, 'remove_i18n_promo', FILTER_VALIDATE_INT) === 1) {
114 114
 				// No expiration time, so this would normally not expire, but it wouldn't be copied to other sites etc.
115
-				Give_Cache::set( 'give_i18n_give_promo_hide', true, null, true );
115
+				Give_Cache::set('give_i18n_give_promo_hide', true, null, true);
116 116
 				$hide_promo = true;
117 117
 			}
118 118
 		}
@@ -131,20 +131,20 @@  discard block
 block discarded – undo
131 131
 		$message = false;
132 132
 
133 133
 		// Using a translation less than 90% complete.
134
-		if ( $this->translation_exists && $this->translation_loaded && $this->percent_translated < 90 ) {
135
-			$message = __( 'As you can see, there is a translation of this plugin in %1$s. This translation is currently %3$d%% complete. We need your help to make it complete and to fix any errors. Please register at %4$s to help %5$s to %1$s!', 'give' );
136
-		} elseif ( ! $this->translation_loaded && $this->translation_exists ) {
137
-			$message = __( 'You\'re using WordPress in %1$s. While %2$s has been %3$d%% translated to %1$s, it has not been shipped with the plugin yet. You can help! Register at %4$s to help complete the translation to %1$s!', 'give' );
138
-		} elseif ( ! $this->translation_exists ) {
139
-			$message = __( 'You\'re using WordPress in a language we don\'t support yet. We\'d love for %2$s to be translated in that language too, but unfortunately, it isn\'t right now. You can change that! Register at %4$s to help translate it!', 'give' );
134
+		if ($this->translation_exists && $this->translation_loaded && $this->percent_translated < 90) {
135
+			$message = __('As you can see, there is a translation of this plugin in %1$s. This translation is currently %3$d%% complete. We need your help to make it complete and to fix any errors. Please register at %4$s to help %5$s to %1$s!', 'give');
136
+		} elseif ( ! $this->translation_loaded && $this->translation_exists) {
137
+			$message = __('You\'re using WordPress in %1$s. While %2$s has been %3$d%% translated to %1$s, it has not been shipped with the plugin yet. You can help! Register at %4$s to help complete the translation to %1$s!', 'give');
138
+		} elseif ( ! $this->translation_exists) {
139
+			$message = __('You\'re using WordPress in a language we don\'t support yet. We\'d love for %2$s to be translated in that language too, but unfortunately, it isn\'t right now. You can change that! Register at %4$s to help translate it!', 'give');
140 140
 		}
141 141
 
142 142
 		// Links.
143
-		$registration_link = sprintf( '<a href="%1$s" target="_blank">%2$s</a>', 'https://wordpress.org/support/register.php', esc_html__( 'WordPress.org', 'give' ) );
144
-		$translations_link = sprintf( '<a href="%1$s" target="_blank">%2$s</a>', 'https://translate.wordpress.org/projects/wp-plugins/give', esc_html__( 'complete the translation', 'give' ) );
143
+		$registration_link = sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://wordpress.org/support/register.php', esc_html__('WordPress.org', 'give'));
144
+		$translations_link = sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://translate.wordpress.org/projects/wp-plugins/give', esc_html__('complete the translation', 'give'));
145 145
 
146 146
 		// Message.
147
-		$message = sprintf( $message, $this->locale_name, 'Give', $this->percent_translated, $registration_link, $translations_link );
147
+		$message = sprintf($message, $this->locale_name, 'Give', $this->percent_translated, $registration_link, $translations_link);
148 148
 
149 149
 		return $message;
150 150
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 		$this->translation_details();
159 159
 		$message = $this->promo_message();
160 160
 
161
-		if ( $message ) { ?>
161
+		if ($message) { ?>
162 162
 
163 163
 			<style>
164 164
 				/* Banner specific styles */
@@ -223,12 +223,12 @@  discard block
 block discarded – undo
223 223
 				                                                                                                                             style="font-size: 110px; text-decoration: none;"></span></a>
224 224
 
225 225
 				<div class="give-i18n-notice-content">
226
-					<a href="<?php echo esc_url( add_query_arg( array( 'remove_i18n_promo' => '1' ) ) ); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a>
226
+					<a href="<?php echo esc_url(add_query_arg(array('remove_i18n_promo' => '1'))); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a>
227 227
 
228
-					<h2 style="margin: 10px 0;"><?php printf( esc_html__( 'Help Translate Give to %s', 'give' ), $this->locale_name ); ?></h2>
228
+					<h2 style="margin: 10px 0;"><?php printf(esc_html__('Help Translate Give to %s', 'give'), $this->locale_name); ?></h2>
229 229
 					<p><?php echo $message; ?></p>
230 230
 					<p>
231
-						<a href="https://wordpress.org/support/register.php" target="_blank"><?php _e( 'Register now &raquo;', 'give' ); ?></a>
231
+						<a href="https://wordpress.org/support/register.php" target="_blank"><?php _e('Register now &raquo;', 'give'); ?></a>
232 232
 					</p>
233 233
 				</div>
234 234
 			</div>
@@ -245,11 +245,11 @@  discard block
 block discarded – undo
245 245
 	 */
246 246
 	private function find_or_initialize_translation_details() {
247 247
 
248
-		$set = Give_Cache::get( "give_i18n_give_{$this->locale}", true );
248
+		$set = Give_Cache::get("give_i18n_give_{$this->locale}", true);
249 249
 
250
-		if ( ! $set ) {
250
+		if ( ! $set) {
251 251
 			$set = $this->retrieve_translation_details();
252
-			Give_Cache::set( "give_i18n_give_{$this->locale}", $set, DAY_IN_SECONDS, true );
252
+			Give_Cache::set("give_i18n_give_{$this->locale}", $set, DAY_IN_SECONDS, true);
253 253
 		}
254 254
 
255 255
 		return $set;
@@ -263,10 +263,10 @@  discard block
 block discarded – undo
263 263
 	private function translation_details() {
264 264
 		$set = $this->find_or_initialize_translation_details();
265 265
 
266
-		$this->translation_exists = ! is_null( $set );
267
-		$this->translation_loaded = is_textdomain_loaded( 'give' );
266
+		$this->translation_exists = ! is_null($set);
267
+		$this->translation_loaded = is_textdomain_loaded('give');
268 268
 
269
-		$this->parse_translation_set( $set );
269
+		$this->parse_translation_set($set);
270 270
 	}
271 271
 
272 272
 	/**
@@ -278,26 +278,26 @@  discard block
 block discarded – undo
278 278
 	 */
279 279
 	private function retrieve_translation_details() {
280 280
 
281
-		$api_url = trailingslashit( $this->glotpress_url );
281
+		$api_url = trailingslashit($this->glotpress_url);
282 282
 
283
-		$resp = wp_remote_get( $api_url );
283
+		$resp = wp_remote_get($api_url);
284 284
 
285
-		if ( is_wp_error( $resp ) || wp_remote_retrieve_response_code( $resp ) === '404' ) {
285
+		if (is_wp_error($resp) || wp_remote_retrieve_response_code($resp) === '404') {
286 286
 			return null;
287 287
 		}
288 288
 
289
-		$body = wp_remote_retrieve_body( $resp );
290
-		unset( $resp );
289
+		$body = wp_remote_retrieve_body($resp);
290
+		unset($resp);
291 291
 
292
-		if ( $body ) {
293
-			$body = json_decode( $body );
292
+		if ($body) {
293
+			$body = json_decode($body);
294 294
 
295
-			foreach ( $body->translation_sets as $set ) {
296
-				if ( ! property_exists( $set, 'wp_locale' ) ) {
295
+			foreach ($body->translation_sets as $set) {
296
+				if ( ! property_exists($set, 'wp_locale')) {
297 297
 					continue;
298 298
 				}
299 299
 
300
-				if ( $this->locale == $set->wp_locale ) {
300
+				if ($this->locale == $set->wp_locale) {
301 301
 					return $set;
302 302
 				}
303 303
 			}
@@ -313,8 +313,8 @@  discard block
 block discarded – undo
313 313
 	 *
314 314
 	 * @access private
315 315
 	 */
316
-	private function parse_translation_set( $set ) {
317
-		if ( $this->translation_exists && is_object( $set ) ) {
316
+	private function parse_translation_set($set) {
317
+		if ($this->translation_exists && is_object($set)) {
318 318
 			$this->locale_name        = $set->name;
319 319
 			$this->percent_translated = $set->percent_translated;
320 320
 		} else {
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 	}
325 325
 }
326 326
 
327
-$give_i18n = new Give_i18n_Banner( array(
327
+$give_i18n = new Give_i18n_Banner(array(
328 328
 		'hook'          => 'give_forms_page_give-settings',
329 329
 		'glotpress_url' => 'https://translate.wordpress.org/api/projects/wp-plugins/give/stable/',
330
-	) );
330
+	));
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-form-stats.php 1 patch
Spacing   +51 added lines, -51 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
 
@@ -59,58 +59,58 @@  discard block
 block discarded – undo
59 59
 	 * @return bool
60 60
 	 */
61 61
 	public function get_data() {
62
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
62
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
63 63
 
64
-		if ( $this->step == 1 ) {
65
-			$this->delete_data( 'give_temp_recount_form_stats' );
64
+		if ($this->step == 1) {
65
+			$this->delete_data('give_temp_recount_form_stats');
66 66
 		}
67 67
 
68
-		$totals = $this->get_stored_data( 'give_temp_recount_form_stats' );
68
+		$totals = $this->get_stored_data('give_temp_recount_form_stats');
69 69
 
70
-		if ( false === $totals ) {
70
+		if (false === $totals) {
71 71
 			$totals = array(
72 72
 				'earnings' => (float) 0,
73 73
 				'sales'    => 0,
74 74
 			);
75
-			$this->store_data( 'give_temp_recount_form_stats', $totals );
75
+			$this->store_data('give_temp_recount_form_stats', $totals);
76 76
 		}
77 77
 
78
-		$args = apply_filters( 'give_recount_form_stats_args', array(
78
+		$args = apply_filters('give_recount_form_stats_args', array(
79 79
 			'give_forms' => $this->form_id,
80 80
 			'number'     => $this->per_step,
81 81
 			'status'     => $accepted_statuses,
82 82
 			'paged'      => $this->step,
83 83
 			'fields'     => 'ids',
84
-		) );
84
+		));
85 85
 
86
-		$payments = new Give_Payments_Query( $args );
86
+		$payments = new Give_Payments_Query($args);
87 87
 		$payments = $payments->get_payments();
88 88
 
89
-		if ( $payments ) {
90
-			foreach ( $payments as $payment ) {
89
+		if ($payments) {
90
+			foreach ($payments as $payment) {
91 91
 				//Ensure acceptible status only
92
-				if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
92
+				if ( ! in_array($payment->post_status, $accepted_statuses)) {
93 93
 					continue;
94 94
 				}
95 95
 
96 96
 				//Ensure only payments for this form are counted
97
-				if ( $payment->form_id != $this->form_id ) {
97
+				if ($payment->form_id != $this->form_id) {
98 98
 					continue;
99 99
 				}
100 100
 
101
-				$totals['sales'] ++;
101
+				$totals['sales']++;
102 102
 				$totals['earnings'] += $payment->total;
103 103
 
104 104
 			}
105 105
 
106
-			$this->store_data( 'give_temp_recount_form_stats', $totals );
106
+			$this->store_data('give_temp_recount_form_stats', $totals);
107 107
 
108 108
 			return true;
109 109
 		}
110 110
 
111 111
 
112
-		give_update_meta( $this->form_id, '_give_form_sales', $totals['sales'] );
113
-		give_update_meta( $this->form_id, '_give_form_earnings', $totals['earnings'] );
112
+		give_update_meta($this->form_id, '_give_form_sales', $totals['sales']);
113
+		give_update_meta($this->form_id, '_give_form_earnings', $totals['earnings']);
114 114
 
115 115
 		return false;
116 116
 	}
@@ -122,35 +122,35 @@  discard block
 block discarded – undo
122 122
 	 * @return int
123 123
 	 */
124 124
 	public function get_percentage_complete() {
125
-		if ( $this->step == 1 ) {
126
-			$this->delete_data( 'give_recount_total_' . $this->form_id );
125
+		if ($this->step == 1) {
126
+			$this->delete_data('give_recount_total_'.$this->form_id);
127 127
 		}
128 128
 
129
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
130
-		$total             = $this->get_stored_data( 'give_recount_total_' . $this->form_id );
129
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
130
+		$total             = $this->get_stored_data('give_recount_total_'.$this->form_id);
131 131
 
132
-		if ( false === $total ) {
132
+		if (false === $total) {
133 133
 			$total = 0;
134
-			$args  = apply_filters( 'give_recount_form_stats_total_args', array(
134
+			$args  = apply_filters('give_recount_form_stats_total_args', array(
135 135
 				'give_forms' => $this->form_id,
136
-				'number'     => - 1,
136
+				'number'     => -1,
137 137
 				'status'     => $accepted_statuses,
138 138
 				'fields'     => 'ids',
139
-			) );
139
+			));
140 140
 
141
-			$payments = new Give_Payments_Query( $args );
142
-			$total    = count( $payments->get_payments() );
143
-			$this->store_data( 'give_recount_total_' . $this->form_id, $total );
141
+			$payments = new Give_Payments_Query($args);
142
+			$total    = count($payments->get_payments());
143
+			$this->store_data('give_recount_total_'.$this->form_id, $total);
144 144
 
145 145
 		}
146 146
 
147 147
 		$percentage = 100;
148 148
 
149
-		if ( $total > 0 ) {
150
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
149
+		if ($total > 0) {
150
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
151 151
 		}
152 152
 
153
-		if ( $percentage > 100 ) {
153
+		if ($percentage > 100) {
154 154
 			$percentage = 100;
155 155
 		}
156 156
 
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
 	 *
165 165
 	 * @param array $request The Form Data passed into the batch processing
166 166
 	 */
167
-	public function set_properties( $request ) {
168
-		$this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false;
167
+	public function set_properties($request) {
168
+		$this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false;
169 169
 	}
170 170
 
171 171
 	/**
@@ -176,31 +176,31 @@  discard block
 block discarded – undo
176 176
 	 */
177 177
 	public function process_step() {
178 178
 
179
-		if ( ! $this->can_export() ) {
180
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
179
+		if ( ! $this->can_export()) {
180
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
181 181
 		}
182 182
 
183 183
 		$had_data = $this->get_data();
184 184
 
185
-		if ( $had_data ) {
185
+		if ($had_data) {
186 186
 			$this->done = false;
187 187
 
188 188
 			return true;
189 189
 		} else {
190
-			$this->delete_data( 'give_recount_total_' . $this->form_id );
191
-			$this->delete_data( 'give_temp_recount_form_stats' );
190
+			$this->delete_data('give_recount_total_'.$this->form_id);
191
+			$this->delete_data('give_temp_recount_form_stats');
192 192
 			$this->done    = true;
193
-			$this->message = sprintf( esc_html__( 'Donation counts and income amount statistics successfully recounted for "%s".', 'give' ), get_the_title( $this->form_id ) );
193
+			$this->message = sprintf(esc_html__('Donation counts and income amount statistics successfully recounted for "%s".', 'give'), get_the_title($this->form_id));
194 194
 
195 195
 			return false;
196 196
 		}
197 197
 	}
198 198
 
199 199
 	public function headers() {
200
-		ignore_user_abort( true );
200
+		ignore_user_abort(true);
201 201
 
202
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
203
-			set_time_limit( 0 );
202
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
203
+			set_time_limit(0);
204 204
 		}
205 205
 	}
206 206
 
@@ -228,11 +228,11 @@  discard block
 block discarded – undo
228 228
 	 *
229 229
 	 * @return mixed       Returns the data from the database
230 230
 	 */
231
-	private function get_stored_data( $key ) {
231
+	private function get_stored_data($key) {
232 232
 		global $wpdb;
233
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
233
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
234 234
 
235
-		return empty( $value ) ? false : maybe_unserialize( $value );
235
+		return empty($value) ? false : maybe_unserialize($value);
236 236
 	}
237 237
 
238 238
 	/**
@@ -245,10 +245,10 @@  discard block
 block discarded – undo
245 245
 	 *
246 246
 	 * @return void
247 247
 	 */
248
-	private function store_data( $key, $value ) {
248
+	private function store_data($key, $value) {
249 249
 		global $wpdb;
250 250
 
251
-		$value = maybe_serialize( $value );
251
+		$value = maybe_serialize($value);
252 252
 
253 253
 		$data = array(
254 254
 			'option_name'  => $key,
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 			'%s',
263 263
 		);
264 264
 
265
-		$wpdb->replace( $wpdb->options, $data, $formats );
265
+		$wpdb->replace($wpdb->options, $data, $formats);
266 266
 	}
267 267
 
268 268
 	/**
@@ -274,9 +274,9 @@  discard block
 block discarded – undo
274 274
 	 *
275 275
 	 * @return void
276 276
 	 */
277
-	private function delete_data( $key ) {
277
+	private function delete_data($key) {
278 278
 		global $wpdb;
279
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
279
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
280 280
 	}
281 281
 
282 282
 }
283 283
\ No newline at end of file
Please login to merge, or discard this patch.