Test Failed
Push — master ( 966cf3...fe1ced )
by Devin
13:57 queued 06:53
created
includes/class-give-cache.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 *
122 122
 	 * @param  string $cache_key
123 123
 	 * @param  bool   $custom_key
124
-	 * @param  mixed  $query_args
124
+	 * @param  string  $query_args
125 125
 	 *
126 126
 	 * @return mixed
127 127
 	 */
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 	 *
238 238
 	 * @param bool  $force If set to true then all cached values will be delete instead of only expired
239 239
 	 *
240
-	 * @return bool
240
+	 * @return false|null
241 241
 	 */
242 242
 	public static function delete_all_expired( $force = false ) {
243 243
 		global $wpdb;
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
 	 * @since  2.0
670 670
 	 * @access private
671 671
 	 *
672
-	 * @param $group
672
+	 * @param string $group
673 673
 	 *
674 674
 	 * @return mixed
675 675
 	 */
Please login to merge, or discard this patch.
Spacing   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	 * @return static
54 54
 	 */
55 55
 	public static function get_instance() {
56
-		if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Give_Cache ) ) {
56
+		if ( ! isset(self::$instance) && ! (self::$instance instanceof Give_Cache)) {
57 57
 			self::$instance = new Give_Cache();
58 58
 		}
59 59
 
@@ -68,17 +68,17 @@  discard block
 block discarded – undo
68 68
 	 */
69 69
 	public function setup() {
70 70
 		// Currently enable cache only for backend.
71
-		self::$instance->is_cache = give_is_setting_enabled( give_get_option( 'cache', 'enabled' ) ) && is_admin();
71
+		self::$instance->is_cache = give_is_setting_enabled(give_get_option('cache', 'enabled')) && is_admin();
72 72
 
73 73
 		// weekly delete all expired cache.
74
-		Give_Cron::add_weekly_event( array( $this, 'delete_all_expired' ) );
74
+		Give_Cron::add_weekly_event(array($this, 'delete_all_expired'));
75 75
 
76
-		add_action( 'save_post_give_forms', array( $this, 'delete_form_related_cache' ) );
77
-		add_action( 'save_post_give_payment', array( $this, 'delete_payment_related_cache' ) );
78
-		add_action( 'give_deleted_give-donors_cache', array( $this, 'delete_donor_related_cache' ), 10, 3 );
79
-		add_action( 'give_deleted_give-donations_cache', array( $this, 'delete_donations_related_cache' ), 10, 3 );
76
+		add_action('save_post_give_forms', array($this, 'delete_form_related_cache'));
77
+		add_action('save_post_give_payment', array($this, 'delete_payment_related_cache'));
78
+		add_action('give_deleted_give-donors_cache', array($this, 'delete_donor_related_cache'), 10, 3);
79
+		add_action('give_deleted_give-donations_cache', array($this, 'delete_donations_related_cache'), 10, 3);
80 80
 
81
-		add_action( 'give_save_settings_give_settings', array( $this, 'flush_cache' ) );
81
+		add_action('give_save_settings_give_settings', array($this, 'flush_cache'));
82 82
 	}
83 83
 
84 84
 	/**
@@ -92,18 +92,18 @@  discard block
 block discarded – undo
92 92
 	 *
93 93
 	 * @return string
94 94
 	 */
95
-	public static function get_key( $action, $query_args = null, $is_prefix = true ) {
95
+	public static function get_key($action, $query_args = null, $is_prefix = true) {
96 96
 		// Bailout.
97
-		if ( empty( $action ) ) {
98
-			return new WP_Error( 'give_invalid_cache_key_action', __( 'Do not pass empty action to generate cache key.', 'give' ) );
97
+		if (empty($action)) {
98
+			return new WP_Error('give_invalid_cache_key_action', __('Do not pass empty action to generate cache key.', 'give'));
99 99
 		}
100 100
 
101 101
 		// Set cache key.
102 102
 		$cache_key = $is_prefix ? "give_cache_{$action}" : $action;
103 103
 
104 104
 		// Bailout.
105
-		if ( ! empty( $query_args ) ) {
106
-			$cache_key = "{$cache_key}_" . substr( md5( serialize( $query_args ) ), 0, 15 );
105
+		if ( ! empty($query_args)) {
106
+			$cache_key = "{$cache_key}_".substr(md5(serialize($query_args)), 0, 15);
107 107
 		}
108 108
 
109 109
 		/**
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 		 *
112 112
 		 * @since 2.0
113 113
 		 */
114
-		return apply_filters( 'give_get_cache_key', $cache_key, $action, $query_args );
114
+		return apply_filters('give_get_cache_key', $cache_key, $action, $query_args);
115 115
 	}
116 116
 
117 117
 	/**
@@ -125,26 +125,26 @@  discard block
 block discarded – undo
125 125
 	 *
126 126
 	 * @return mixed
127 127
 	 */
128
-	public static function get( $cache_key, $custom_key = false, $query_args = array() ) {
129
-		if ( ! self::is_valid_cache_key( $cache_key ) ) {
130
-			if ( ! $custom_key ) {
131
-				return new WP_Error( 'give_invalid_cache_key', __( 'Cache key format should be give_cache_*', 'give' ) );
128
+	public static function get($cache_key, $custom_key = false, $query_args = array()) {
129
+		if ( ! self::is_valid_cache_key($cache_key)) {
130
+			if ( ! $custom_key) {
131
+				return new WP_Error('give_invalid_cache_key', __('Cache key format should be give_cache_*', 'give'));
132 132
 			}
133 133
 
134
-			$cache_key = self::get_key( $cache_key, $query_args );
134
+			$cache_key = self::get_key($cache_key, $query_args);
135 135
 		}
136 136
 
137
-		$option = get_option( $cache_key );
137
+		$option = get_option($cache_key);
138 138
 
139 139
 		// Backward compatibility (<1.8.7).
140
-		if ( ! is_array( $option ) || empty( $option ) || ! array_key_exists( 'expiration', $option ) ) {
140
+		if ( ! is_array($option) || empty($option) || ! array_key_exists('expiration', $option)) {
141 141
 			return $option;
142 142
 		}
143 143
 
144 144
 		// Get current time.
145
-		$current_time = current_time( 'timestamp', 1 );
145
+		$current_time = current_time('timestamp', 1);
146 146
 
147
-		if ( empty( $option['expiration'] ) || ( $current_time < $option['expiration'] ) ) {
147
+		if (empty($option['expiration']) || ($current_time < $option['expiration'])) {
148 148
 			$option = $option['data'];
149 149
 		} else {
150 150
 			$option = false;
@@ -166,23 +166,23 @@  discard block
 block discarded – undo
166 166
 	 *
167 167
 	 * @return mixed
168 168
 	 */
169
-	public static function set( $cache_key, $data, $expiration = null, $custom_key = false, $query_args = array() ) {
170
-		if ( ! self::is_valid_cache_key( $cache_key ) ) {
171
-			if ( ! $custom_key ) {
172
-				return new WP_Error( 'give_invalid_cache_key', __( 'Cache key format should be give_cache_*', 'give' ) );
169
+	public static function set($cache_key, $data, $expiration = null, $custom_key = false, $query_args = array()) {
170
+		if ( ! self::is_valid_cache_key($cache_key)) {
171
+			if ( ! $custom_key) {
172
+				return new WP_Error('give_invalid_cache_key', __('Cache key format should be give_cache_*', 'give'));
173 173
 			}
174 174
 
175
-			$cache_key = self::get_key( $cache_key, $query_args );
175
+			$cache_key = self::get_key($cache_key, $query_args);
176 176
 		}
177 177
 
178 178
 		$option_value = array(
179 179
 			'data'       => $data,
180
-			'expiration' => ! is_null( $expiration )
181
-				? ( $expiration + current_time( 'timestamp', 1 ) )
180
+			'expiration' => ! is_null($expiration)
181
+				? ($expiration + current_time('timestamp', 1))
182 182
 				: null,
183 183
 		);
184 184
 
185
-		$result = update_option( $cache_key, $option_value, 'no' );
185
+		$result = update_option($cache_key, $option_value, 'no');
186 186
 
187 187
 		return $result;
188 188
 	}
@@ -198,27 +198,27 @@  discard block
 block discarded – undo
198 198
 	 *
199 199
 	 * @return bool|WP_Error
200 200
 	 */
201
-	public static function delete( $cache_keys ) {
201
+	public static function delete($cache_keys) {
202 202
 		$result       = true;
203 203
 		$invalid_keys = array();
204 204
 
205
-		if ( ! empty( $cache_keys ) ) {
206
-			$cache_keys = is_array( $cache_keys ) ? $cache_keys : array( $cache_keys );
205
+		if ( ! empty($cache_keys)) {
206
+			$cache_keys = is_array($cache_keys) ? $cache_keys : array($cache_keys);
207 207
 
208
-			foreach ( $cache_keys as $cache_key ) {
209
-				if ( ! self::is_valid_cache_key( $cache_key ) ) {
208
+			foreach ($cache_keys as $cache_key) {
209
+				if ( ! self::is_valid_cache_key($cache_key)) {
210 210
 					$invalid_keys[] = $cache_key;
211 211
 					$result         = false;
212 212
 				}
213 213
 
214
-				delete_option( $cache_key );
214
+				delete_option($cache_key);
215 215
 			}
216 216
 		}
217 217
 
218
-		if ( ! $result ) {
218
+		if ( ! $result) {
219 219
 			$result = new WP_Error(
220 220
 				'give_invalid_cache_key',
221
-				__( 'Cache key format should be give_cache_*', 'give' ),
221
+				__('Cache key format should be give_cache_*', 'give'),
222 222
 				$invalid_keys
223 223
 			);
224 224
 		}
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 	 *
240 240
 	 * @return bool
241 241
 	 */
242
-	public static function delete_all_expired( $force = false ) {
242
+	public static function delete_all_expired($force = false) {
243 243
 		global $wpdb;
244 244
 		$options = $wpdb->get_results(
245 245
 			$wpdb->prepare(
@@ -253,30 +253,30 @@  discard block
 block discarded – undo
253 253
 		);
254 254
 
255 255
 		// Bailout.
256
-		if ( empty( $options ) ) {
256
+		if (empty($options)) {
257 257
 			return false;
258 258
 		}
259 259
 
260
-		$current_time = current_time( 'timestamp', 1 );
260
+		$current_time = current_time('timestamp', 1);
261 261
 
262 262
 		// Delete log cache.
263
-		foreach ( $options as $option ) {
264
-			$option['option_value'] = maybe_unserialize( $option['option_value'] );
263
+		foreach ($options as $option) {
264
+			$option['option_value'] = maybe_unserialize($option['option_value']);
265 265
 
266 266
 			if (
267 267
 				(
268
-					! self::is_valid_cache_key( $option['option_name'] )
269
-					|| ! is_array( $option['option_value'] ) // Backward compatibility (<1.8.7).
270
-					|| ! array_key_exists( 'expiration', $option['option_value'] ) // Backward compatibility (<1.8.7).
271
-					|| empty( $option['option_value']['expiration'] )
272
-					|| ( $current_time < $option['option_value']['expiration'] )
268
+					! self::is_valid_cache_key($option['option_name'])
269
+					|| ! is_array($option['option_value']) // Backward compatibility (<1.8.7).
270
+					|| ! array_key_exists('expiration', $option['option_value']) // Backward compatibility (<1.8.7).
271
+					|| empty($option['option_value']['expiration'])
272
+					|| ($current_time < $option['option_value']['expiration'])
273 273
 				)
274 274
 				&& ! $force
275 275
 			) {
276 276
 				continue;
277 277
 			}
278 278
 
279
-			self::delete( $option['option_name'] );
279
+			self::delete($option['option_name']);
280 280
 		}
281 281
 	}
282 282
 
@@ -294,16 +294,16 @@  discard block
 block discarded – undo
294 294
 	 *
295 295
 	 * @return array
296 296
 	 */
297
-	public static function get_options_like( $option_name, $fields = false ) {
297
+	public static function get_options_like($option_name, $fields = false) {
298 298
 		global $wpdb;
299 299
 
300
-		if ( empty( $option_name ) ) {
300
+		if (empty($option_name)) {
301 301
 			return array();
302 302
 		}
303 303
 
304 304
 		$field_names = $fields ? 'option_name, option_value' : 'option_name';
305 305
 
306
-		if ( $fields ) {
306
+		if ($fields) {
307 307
 			$options = $wpdb->get_results(
308 308
 				$wpdb->prepare(
309 309
 					"SELECT {$field_names }
@@ -327,10 +327,10 @@  discard block
 block discarded – undo
327 327
 			);
328 328
 		}
329 329
 
330
-		if ( ! empty( $options ) && $fields ) {
331
-			foreach ( $options as $index => $option ) {
332
-				$option['option_value'] = maybe_unserialize( $option['option_value'] );
333
-				$options[ $index ]      = $option;
330
+		if ( ! empty($options) && $fields) {
331
+			foreach ($options as $index => $option) {
332
+				$option['option_value'] = maybe_unserialize($option['option_value']);
333
+				$options[$index]      = $option;
334 334
 			}
335 335
 		}
336 336
 
@@ -347,8 +347,8 @@  discard block
 block discarded – undo
347 347
 	 *
348 348
 	 * @return bool
349 349
 	 */
350
-	public static function is_valid_cache_key( $cache_key ) {
351
-		$is_valid = ( false !== strpos( $cache_key, 'give_cache_' ) );
350
+	public static function is_valid_cache_key($cache_key) {
351
+		$is_valid = (false !== strpos($cache_key, 'give_cache_'));
352 352
 
353 353
 
354 354
 		/**
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 		 *
357 357
 		 * @since 2.0
358 358
 		 */
359
-		return apply_filters( 'give_is_valid_cache_key', $is_valid, $cache_key );
359
+		return apply_filters('give_is_valid_cache_key', $is_valid, $cache_key);
360 360
 	}
361 361
 
362 362
 
@@ -371,14 +371,14 @@  discard block
 block discarded – undo
371 371
 	 *
372 372
 	 * @return mixed
373 373
 	 */
374
-	public static function get_group( $id, $group = '' ) {
374
+	public static function get_group($id, $group = '') {
375 375
 		$cached_data = null;
376 376
 
377 377
 		// Bailout.
378
-		if ( self::$instance->is_cache && ! empty( $id ) ) {
379
-			$group = self::$instance->filter_group_name( $group );
378
+		if (self::$instance->is_cache && ! empty($id)) {
379
+			$group = self::$instance->filter_group_name($group);
380 380
 
381
-			$cached_data = wp_cache_get( $id, $group );
381
+			$cached_data = wp_cache_get($id, $group);
382 382
 			$cached_data = false !== $cached_data ? $cached_data : null;
383 383
 		}
384 384
 
@@ -398,17 +398,17 @@  discard block
 block discarded – undo
398 398
 	 *
399 399
 	 * @return bool
400 400
 	 */
401
-	public static function set_group( $id, $data, $group = '', $expire = 0 ) {
401
+	public static function set_group($id, $data, $group = '', $expire = 0) {
402 402
 		$status = false;
403 403
 
404 404
 		// Bailout.
405
-		if ( ! self::$instance->is_cache || empty( $id ) ) {
405
+		if ( ! self::$instance->is_cache || empty($id)) {
406 406
 			return $status;
407 407
 		}
408 408
 
409
-		$group = self::$instance->filter_group_name( $group );
409
+		$group = self::$instance->filter_group_name($group);
410 410
 
411
-		$status = wp_cache_set( $id, $data, $group, $expire );
411
+		$status = wp_cache_set($id, $data, $group, $expire);
412 412
 
413 413
 		return $status;
414 414
 	}
@@ -424,15 +424,15 @@  discard block
 block discarded – undo
424 424
 	 *
425 425
 	 * @return bool
426 426
 	 */
427
-	public static function set_db_query( $id, $data ) {
427
+	public static function set_db_query($id, $data) {
428 428
 		$status = false;
429 429
 
430 430
 		// Bailout.
431
-		if ( ! self::$instance->is_cache || empty( $id ) ) {
431
+		if ( ! self::$instance->is_cache || empty($id)) {
432 432
 			return $status;
433 433
 		}
434 434
 
435
-		return self::set_group( $id, $data, 'give-db-queries', 0 );
435
+		return self::set_group($id, $data, 'give-db-queries', 0);
436 436
 	}
437 437
 
438 438
 	/**
@@ -445,8 +445,8 @@  discard block
 block discarded – undo
445 445
 	 *
446 446
 	 * @return mixed
447 447
 	 */
448
-	public static function get_db_query( $id ) {
449
-		return self::get_group( $id, 'give-db-queries' );
448
+	public static function get_db_query($id) {
449
+		return self::get_group($id, 'give-db-queries');
450 450
 	}
451 451
 
452 452
 	/**
@@ -461,20 +461,20 @@  discard block
 block discarded – undo
461 461
 	 *
462 462
 	 * @return bool
463 463
 	 */
464
-	public static function delete_group( $ids, $group = '', $expire = 0 ) {
464
+	public static function delete_group($ids, $group = '', $expire = 0) {
465 465
 		$status = false;
466 466
 
467 467
 		// Bailout.
468
-		if ( ! self::$instance->is_cache || empty( $ids ) ) {
468
+		if ( ! self::$instance->is_cache || empty($ids)) {
469 469
 			return $status;
470 470
 		}
471 471
 
472
-		$group = self::$instance->filter_group_name( $group );
472
+		$group = self::$instance->filter_group_name($group);
473 473
 
474 474
 		// Delete single or multiple cache items from cache.
475
-		if ( ! is_array( $ids ) ) {
476
-			$status = wp_cache_delete( $ids, $group, $expire );
477
-			self::$instance->get_incrementer( true );
475
+		if ( ! is_array($ids)) {
476
+			$status = wp_cache_delete($ids, $group, $expire);
477
+			self::$instance->get_incrementer(true);
478 478
 
479 479
 			/**
480 480
 			 * Fire action when cache deleted for specific id.
@@ -485,12 +485,12 @@  discard block
 block discarded – undo
485 485
 			 * @param string $group
486 486
 			 * @param int    $expire
487 487
 			 */
488
-			do_action( "give_deleted_{$group}_cache", $ids, $group, $expire, $status );
488
+			do_action("give_deleted_{$group}_cache", $ids, $group, $expire, $status);
489 489
 
490 490
 		} else {
491
-			foreach ( $ids as $id ) {
492
-				$status = wp_cache_delete( $id, $group, $expire );
493
-				self::$instance->get_incrementer( true );
491
+			foreach ($ids as $id) {
492
+				$status = wp_cache_delete($id, $group, $expire);
493
+				self::$instance->get_incrementer(true);
494 494
 
495 495
 				/**
496 496
 				 * Fire action when cache deleted for specific id .
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 				 * @param string $group
502 502
 				 * @param int    $expire
503 503
 				 */
504
-				do_action( "give_deleted_{$group}_cache", $id, $group, $expire, $status );
504
+				do_action("give_deleted_{$group}_cache", $id, $group, $expire, $status);
505 505
 			}
506 506
 		}
507 507
 
@@ -518,30 +518,30 @@  discard block
 block discarded – undo
518 518
 	 *
519 519
 	 * @param int $form_id
520 520
 	 */
521
-	public function delete_form_related_cache( $form_id ) {
521
+	public function delete_form_related_cache($form_id) {
522 522
 		// If this is just a revision, don't send the email.
523
-		if ( wp_is_post_revision( $form_id ) ) {
523
+		if (wp_is_post_revision($form_id)) {
524 524
 			return;
525 525
 		}
526 526
 
527 527
 		$donation_query = new Give_Payments_Query(
528 528
 			array(
529
-				'number'     => - 1,
529
+				'number'     => -1,
530 530
 				'give_forms' => $form_id,
531 531
 			)
532 532
 		);
533 533
 
534 534
 		$donations = $donation_query->get_payments();
535 535
 
536
-		if ( ! empty( $donations ) ) {
536
+		if ( ! empty($donations)) {
537 537
 			/* @var Give_Payment $donation */
538
-			foreach ( $donations as $donation ) {
539
-				wp_cache_delete( $donation->ID, 'give-donations' );
540
-				wp_cache_delete( $donation->donor_id, 'give-donors' );
538
+			foreach ($donations as $donation) {
539
+				wp_cache_delete($donation->ID, 'give-donations');
540
+				wp_cache_delete($donation->donor_id, 'give-donors');
541 541
 			}
542 542
 		}
543 543
 
544
-		self::$instance->get_incrementer( true );
544
+		self::$instance->get_incrementer(true);
545 545
 	}
546 546
 
547 547
 	/**
@@ -553,22 +553,22 @@  discard block
 block discarded – undo
553 553
 	 *
554 554
 	 * @param int $donation_id
555 555
 	 */
556
-	public function delete_payment_related_cache( $donation_id ) {
556
+	public function delete_payment_related_cache($donation_id) {
557 557
 		// If this is just a revision, don't send the email.
558
-		if ( wp_is_post_revision( $donation_id ) ) {
558
+		if (wp_is_post_revision($donation_id)) {
559 559
 			return;
560 560
 		}
561 561
 
562 562
 		/* @var Give_Payment $donation */
563
-		$donation = new Give_Payment( $donation_id );
563
+		$donation = new Give_Payment($donation_id);
564 564
 
565
-		if ( $donation && $donation->donor_id ) {
566
-			wp_cache_delete( $donation->donor_id, 'give-donors' );
565
+		if ($donation && $donation->donor_id) {
566
+			wp_cache_delete($donation->donor_id, 'give-donors');
567 567
 		}
568 568
 
569
-		wp_cache_delete( $donation->ID, 'give-donations' );
569
+		wp_cache_delete($donation->ID, 'give-donations');
570 570
 
571
-		self::$instance->get_incrementer( true );
571
+		self::$instance->get_incrementer(true);
572 572
 	}
573 573
 
574 574
 	/**
@@ -582,17 +582,17 @@  discard block
 block discarded – undo
582 582
 	 * @param string $group
583 583
 	 * @param int    $expire
584 584
 	 */
585
-	public function delete_donor_related_cache( $id, $group, $expire ) {
586
-		$donor        = new Give_Donor( $id );
587
-		$donation_ids = array_map( 'trim', (array) explode( ',', trim( $donor->payment_ids ) ) );
585
+	public function delete_donor_related_cache($id, $group, $expire) {
586
+		$donor        = new Give_Donor($id);
587
+		$donation_ids = array_map('trim', (array) explode(',', trim($donor->payment_ids)));
588 588
 
589
-		if ( ! empty( $donation_ids ) ) {
590
-			foreach ( $donation_ids as $donation ) {
591
-				wp_cache_delete( $donation, 'give-donations' );
589
+		if ( ! empty($donation_ids)) {
590
+			foreach ($donation_ids as $donation) {
591
+				wp_cache_delete($donation, 'give-donations');
592 592
 			}
593 593
 		}
594 594
 
595
-		self::$instance->get_incrementer( true );
595
+		self::$instance->get_incrementer(true);
596 596
 	}
597 597
 
598 598
 	/**
@@ -606,15 +606,15 @@  discard block
 block discarded – undo
606 606
 	 * @param string $group
607 607
 	 * @param int    $expire
608 608
 	 */
609
-	public function delete_donations_related_cache( $id, $group, $expire ) {
609
+	public function delete_donations_related_cache($id, $group, $expire) {
610 610
 		/* @var Give_Payment $donation */
611
-		$donation = new Give_Payment( $id );
611
+		$donation = new Give_Payment($id);
612 612
 
613
-		if ( $donation && $donation->donor_id ) {
614
-			wp_cache_delete( $donation->donor_id, 'give-donors' );
613
+		if ($donation && $donation->donor_id) {
614
+			wp_cache_delete($donation->donor_id, 'give-donors');
615 615
 		}
616 616
 
617
-		self::$instance->get_incrementer( true );
617
+		self::$instance->get_incrementer(true);
618 618
 	}
619 619
 
620 620
 
@@ -632,12 +632,12 @@  discard block
 block discarded – undo
632 632
 	 *
633 633
 	 * @return string
634 634
 	 */
635
-	private function get_incrementer( $refresh = false, $incrementer_key = 'give-cahce-incrementer-db-queries' ) {
636
-		$incrementer_value = wp_cache_get( $incrementer_key );
635
+	private function get_incrementer($refresh = false, $incrementer_key = 'give-cahce-incrementer-db-queries') {
636
+		$incrementer_value = wp_cache_get($incrementer_key);
637 637
 
638
-		if ( false === $incrementer_value || true === $refresh ) {
639
-			$incrementer_value = microtime( true );
640
-			wp_cache_set( $incrementer_key, $incrementer_value );
638
+		if (false === $incrementer_value || true === $refresh) {
639
+			$incrementer_value = microtime(true);
640
+			wp_cache_set($incrementer_key, $incrementer_value);
641 641
 		}
642 642
 
643 643
 		return $incrementer_value;
@@ -654,11 +654,11 @@  discard block
 block discarded – undo
654 654
 	public function flush_cache() {
655 655
 		if (
656 656
 			Give_Admin_Settings::is_saving_settings() &&
657
-			isset( $_POST['cache'] ) &&
658
-			give_is_setting_enabled( give_clean( $_POST['cache'] ) )
657
+			isset($_POST['cache']) &&
658
+			give_is_setting_enabled(give_clean($_POST['cache']))
659 659
 		) {
660
-			$this->get_incrementer( true );
661
-			$this->get_incrementer( true, 'give-cahce-incrementer' );
660
+			$this->get_incrementer(true);
661
+			$this->get_incrementer(true, 'give-cahce-incrementer');
662 662
 		}
663 663
 	}
664 664
 
@@ -673,11 +673,11 @@  discard block
 block discarded – undo
673 673
 	 *
674 674
 	 * @return mixed
675 675
 	 */
676
-	private function filter_group_name( $group ) {
677
-		if ( ! empty( $group ) ) {
678
-			$incrementer = self::$instance->get_incrementer( false, 'give-cahce-incrementer' );
676
+	private function filter_group_name($group) {
677
+		if ( ! empty($group)) {
678
+			$incrementer = self::$instance->get_incrementer(false, 'give-cahce-incrementer');
679 679
 
680
-			if ( 'give-db-queries' === $group ) {
680
+			if ('give-db-queries' === $group) {
681 681
 				$incrementer = self::$instance->get_incrementer();
682 682
 			}
683 683
 
Please login to merge, or discard this patch.
includes/class-give-db-donors.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 	 * NOTE: This should not be called directly as it does not make necessary changes to
208 208
 	 * the payment meta and logs. Use give_donor_delete() instead.
209 209
 	 *
210
-	 * @param  bool|string|int $_id_or_email ID or Email of Donor.
210
+	 * @param  integer $_id_or_email ID or Email of Donor.
211 211
 	 *
212 212
 	 * @since  1.0
213 213
 	 * @access public
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 	 * @access public
408 408
 	 *
409 409
 	 * @param  string $field ID or email. Default is 'id'.
410
-	 * @param  mixed  $value The Customer ID or email to search. Default is 0.
410
+	 * @param  integer  $value The Customer ID or email to search. Default is 0.
411 411
 	 *
412 412
 	 * @return mixed         Upon success, an object of the donor. Upon failure, NULL
413 413
 	 */
Please login to merge, or discard this patch.
Spacing   +107 added lines, -107 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
 
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 		$this->bc_200_params();
43 43
 
44 44
 		// Set hooks and register table only if instance loading first time.
45
-		if ( ! ( Give()->donors instanceof Give_DB_Donors ) ) {
45
+		if ( ! (Give()->donors instanceof Give_DB_Donors)) {
46 46
 			// Install table.
47 47
 			$this->register_table();
48 48
 		}
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 			'purchase_value'  => 0.00,
92 92
 			'purchase_count'  => 0,
93 93
 			'notes'           => '',
94
-			'date_created'    => date( 'Y-m-d H:i:s' ),
94
+			'date_created'    => date('Y-m-d H:i:s'),
95 95
 			'token'           => '',
96 96
 			'verify_key'      => '',
97 97
 			'verify_throttle' => '',
@@ -108,40 +108,40 @@  discard block
 block discarded – undo
108 108
 	 *
109 109
 	 * @return int|bool
110 110
 	 */
111
-	public function add( $data = array() ) {
111
+	public function add($data = array()) {
112 112
 
113 113
 		$defaults = array(
114 114
 			'payment_ids' => '',
115 115
 		);
116 116
 
117
-		$args = wp_parse_args( $data, $defaults );
117
+		$args = wp_parse_args($data, $defaults);
118 118
 
119
-		if ( empty( $args['email'] ) ) {
119
+		if (empty($args['email'])) {
120 120
 			return false;
121 121
 		}
122 122
 
123
-		if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) {
124
-			$args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) );
123
+		if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) {
124
+			$args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids'])));
125 125
 		}
126 126
 
127
-		$donor = $this->get_donor_by( 'email', $args['email'] );
127
+		$donor = $this->get_donor_by('email', $args['email']);
128 128
 
129 129
 		// update an existing donor.
130
-		if ( $donor ) {
130
+		if ($donor) {
131 131
 
132 132
 			// Update the payment IDs attached to the donor
133
-			if ( ! empty( $args['payment_ids'] ) ) {
133
+			if ( ! empty($args['payment_ids'])) {
134 134
 
135
-				if ( empty( $donor->payment_ids ) ) {
135
+				if (empty($donor->payment_ids)) {
136 136
 
137 137
 					$donor->payment_ids = $args['payment_ids'];
138 138
 
139 139
 				} else {
140 140
 
141
-					$existing_ids       = array_map( 'absint', explode( ',', $donor->payment_ids ) );
142
-					$payment_ids        = array_map( 'absint', explode( ',', $args['payment_ids'] ) );
143
-					$payment_ids        = array_merge( $payment_ids, $existing_ids );
144
-					$donor->payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
141
+					$existing_ids       = array_map('absint', explode(',', $donor->payment_ids));
142
+					$payment_ids        = array_map('absint', explode(',', $args['payment_ids']));
143
+					$payment_ids        = array_merge($payment_ids, $existing_ids);
144
+					$donor->payment_ids = implode(',', array_unique(array_values($payment_ids)));
145 145
 
146 146
 				}
147 147
 
@@ -149,13 +149,13 @@  discard block
 block discarded – undo
149 149
 
150 150
 			}
151 151
 
152
-			$this->update( $donor->id, $args );
152
+			$this->update($donor->id, $args);
153 153
 
154 154
 			return $donor->id;
155 155
 
156 156
 		} else {
157 157
 
158
-			return $this->insert( $args, 'donor' );
158
+			return $this->insert($args, 'donor');
159 159
 
160 160
 		}
161 161
 
@@ -172,12 +172,12 @@  discard block
 block discarded – undo
172 172
 	 *
173 173
 	 * @return bool
174 174
 	 */
175
-	public function update( $row_id, $data = array(), $where = '' ) {
175
+	public function update($row_id, $data = array(), $where = '') {
176 176
 
177
-		$status = parent::update( $row_id, $data, $where );
177
+		$status = parent::update($row_id, $data, $where);
178 178
 
179
-		if ( $status ) {
180
-			Give_Cache::delete_group( $row_id, 'give-donors' );
179
+		if ($status) {
180
+			Give_Cache::delete_group($row_id, 'give-donors');
181 181
 		}
182 182
 
183 183
 		return $status;
@@ -191,11 +191,11 @@  discard block
 block discarded – undo
191 191
 	 *
192 192
 	 * @return int
193 193
 	 */
194
-	public function insert( $data, $type = '' ) {
195
-		$donor_id = parent::insert( $data, $type );
194
+	public function insert($data, $type = '') {
195
+		$donor_id = parent::insert($data, $type);
196 196
 
197
-		if ( $donor_id ) {
198
-			Give_Cache::delete_group( $donor_id, 'give-donors' );
197
+		if ($donor_id) {
198
+			Give_Cache::delete_group($donor_id, 'give-donors');
199 199
 		}
200 200
 
201 201
 		return $donor_id;
@@ -214,16 +214,16 @@  discard block
 block discarded – undo
214 214
 	 *
215 215
 	 * @return bool|int
216 216
 	 */
217
-	public function delete( $_id_or_email = false ) {
217
+	public function delete($_id_or_email = false) {
218 218
 
219
-		if ( empty( $_id_or_email ) ) {
219
+		if (empty($_id_or_email)) {
220 220
 			return false;
221 221
 		}
222 222
 
223
-		$column = is_email( $_id_or_email ) ? 'email' : 'id';
224
-		$donor  = $this->get_donor_by( $column, $_id_or_email );
223
+		$column = is_email($_id_or_email) ? 'email' : 'id';
224
+		$donor  = $this->get_donor_by($column, $_id_or_email);
225 225
 
226
-		if ( $donor->id > 0 ) {
226
+		if ($donor->id > 0) {
227 227
 
228 228
 			global $wpdb;
229 229
 
@@ -232,11 +232,11 @@  discard block
 block discarded – undo
232 232
 			 *
233 233
 			 * @since 1.8.14
234 234
 			 */
235
-			Give()->donor_meta->delete_all_meta( $donor->id );
235
+			Give()->donor_meta->delete_all_meta($donor->id);
236 236
 
237 237
 			// Cache already deleted in delete_all_meta fn.
238 238
 
239
-			return $wpdb->delete( $this->table_name, array( 'id' => $donor->id ), array( '%d' ) );
239
+			return $wpdb->delete($this->table_name, array('id' => $donor->id), array('%d'));
240 240
 
241 241
 		} else {
242 242
 			return false;
@@ -257,10 +257,10 @@  discard block
 block discarded – undo
257 257
 	 *
258 258
 	 * @return bool|int
259 259
 	 */
260
-	public function delete_by_user_id( $user_id = false ) {
260
+	public function delete_by_user_id($user_id = false) {
261 261
 		global $wpdb;
262 262
 
263
-		if ( empty( $user_id ) ) {
263
+		if (empty($user_id)) {
264 264
 			return false;
265 265
 		}
266 266
 
@@ -269,14 +269,14 @@  discard block
 block discarded – undo
269 269
 		 *
270 270
 		 * @since 1.8.14
271 271
 		 */
272
-		$donor = new Give_Donor( $user_id, true );
273
-		if ( ! empty( $donor->id ) ) {
274
-			Give()->donor_meta->delete_all_meta( $donor->id );
272
+		$donor = new Give_Donor($user_id, true);
273
+		if ( ! empty($donor->id)) {
274
+			Give()->donor_meta->delete_all_meta($donor->id);
275 275
 		}
276 276
 
277 277
 		// Cache is already deleted in delete_all_meta fn.
278 278
 
279
-		return $wpdb->delete( $this->table_name, array( 'user_id' => $user_id ), array( '%d' ) );
279
+		return $wpdb->delete($this->table_name, array('user_id' => $user_id), array('%d'));
280 280
 	}
281 281
 
282 282
 	/**
@@ -290,14 +290,14 @@  discard block
 block discarded – undo
290 290
 	 *
291 291
 	 * @return bool          True is exists, false otherwise.
292 292
 	 */
293
-	public function exists( $value = '', $field = 'email' ) {
293
+	public function exists($value = '', $field = 'email') {
294 294
 
295 295
 		$columns = $this->get_columns();
296
-		if ( ! array_key_exists( $field, $columns ) ) {
296
+		if ( ! array_key_exists($field, $columns)) {
297 297
 			return false;
298 298
 		}
299 299
 
300
-		return (bool) $this->get_column_by( 'id', $field, $value );
300
+		return (bool) $this->get_column_by('id', $field, $value);
301 301
 
302 302
 	}
303 303
 
@@ -312,16 +312,16 @@  discard block
 block discarded – undo
312 312
 	 *
313 313
 	 * @return bool
314 314
 	 */
315
-	public function attach_payment( $donor_id = 0, $payment_id = 0 ) {
315
+	public function attach_payment($donor_id = 0, $payment_id = 0) {
316 316
 
317
-		$donor = new Give_Donor( $donor_id );
317
+		$donor = new Give_Donor($donor_id);
318 318
 
319
-		if ( empty( $donor->id ) ) {
319
+		if (empty($donor->id)) {
320 320
 			return false;
321 321
 		}
322 322
 
323 323
 		// Attach the payment, but don't increment stats, as this function previously did not
324
-		return $donor->attach_payment( $payment_id, false );
324
+		return $donor->attach_payment($payment_id, false);
325 325
 
326 326
 	}
327 327
 
@@ -336,16 +336,16 @@  discard block
 block discarded – undo
336 336
 	 *
337 337
 	 * @return bool
338 338
 	 */
339
-	public function remove_payment( $donor_id = 0, $payment_id = 0 ) {
339
+	public function remove_payment($donor_id = 0, $payment_id = 0) {
340 340
 
341
-		$donor = new Give_Donor( $donor_id );
341
+		$donor = new Give_Donor($donor_id);
342 342
 
343
-		if ( ! $donor ) {
343
+		if ( ! $donor) {
344 344
 			return false;
345 345
 		}
346 346
 
347 347
 		// Remove the payment, but don't decrease stats, as this function previously did not
348
-		return $donor->remove_payment( $payment_id, false );
348
+		return $donor->remove_payment($payment_id, false);
349 349
 
350 350
 	}
351 351
 
@@ -359,18 +359,18 @@  discard block
 block discarded – undo
359 359
 	 *
360 360
 	 * @return bool
361 361
 	 */
362
-	public function increment_stats( $donor_id = 0, $amount = 0.00 ) {
362
+	public function increment_stats($donor_id = 0, $amount = 0.00) {
363 363
 
364
-		$donor = new Give_Donor( $donor_id );
364
+		$donor = new Give_Donor($donor_id);
365 365
 
366
-		if ( empty( $donor->id ) ) {
366
+		if (empty($donor->id)) {
367 367
 			return false;
368 368
 		}
369 369
 
370 370
 		$increased_count = $donor->increase_purchase_count();
371
-		$increased_value = $donor->increase_value( $amount );
371
+		$increased_value = $donor->increase_value($amount);
372 372
 
373
-		return ( $increased_count && $increased_value ) ? true : false;
373
+		return ($increased_count && $increased_value) ? true : false;
374 374
 
375 375
 	}
376 376
 
@@ -385,18 +385,18 @@  discard block
 block discarded – undo
385 385
 	 *
386 386
 	 * @return bool
387 387
 	 */
388
-	public function decrement_stats( $donor_id = 0, $amount = 0.00 ) {
388
+	public function decrement_stats($donor_id = 0, $amount = 0.00) {
389 389
 
390
-		$donor = new Give_Donor( $donor_id );
390
+		$donor = new Give_Donor($donor_id);
391 391
 
392
-		if ( ! $donor ) {
392
+		if ( ! $donor) {
393 393
 			return false;
394 394
 		}
395 395
 
396 396
 		$decreased_count = $donor->decrease_donation_count();
397
-		$decreased_value = $donor->decrease_value( $amount );
397
+		$decreased_value = $donor->decrease_value($amount);
398 398
 
399
-		return ( $decreased_count && $decreased_value ) ? true : false;
399
+		return ($decreased_count && $decreased_value) ? true : false;
400 400
 
401 401
 	}
402 402
 
@@ -411,44 +411,44 @@  discard block
 block discarded – undo
411 411
 	 *
412 412
 	 * @return mixed         Upon success, an object of the donor. Upon failure, NULL
413 413
 	 */
414
-	public function get_donor_by( $field = 'id', $value = 0 ) {
415
-		$value = sanitize_text_field( $value );
414
+	public function get_donor_by($field = 'id', $value = 0) {
415
+		$value = sanitize_text_field($value);
416 416
 
417 417
 		// Bailout.
418
-		if ( empty( $field ) || empty( $value ) ) {
418
+		if (empty($field) || empty($value)) {
419 419
 			return null;
420 420
 		}
421 421
 
422 422
 		// Verify values.
423
-		if ( 'id' === $field || 'user_id' === $field ) {
423
+		if ('id' === $field || 'user_id' === $field) {
424 424
 			// Make sure the value is numeric to avoid casting objects, for example,
425 425
 			// to int 1.
426
-			if ( ! is_numeric( $value ) ) {
426
+			if ( ! is_numeric($value)) {
427 427
 				return false;
428 428
 			}
429 429
 
430
-			$value = absint( $value );
430
+			$value = absint($value);
431 431
 
432
-			if ( $value < 1 ) {
432
+			if ($value < 1) {
433 433
 				return false;
434 434
 			}
435 435
 
436
-		} elseif ( 'email' === $field ) {
436
+		} elseif ('email' === $field) {
437 437
 
438
-			if ( ! is_email( $value ) ) {
438
+			if ( ! is_email($value)) {
439 439
 				return false;
440 440
 			}
441 441
 
442
-			$value = trim( $value );
442
+			$value = trim($value);
443 443
 		}
444 444
 
445 445
 		// Bailout
446
-		if ( ! $value ) {
446
+		if ( ! $value) {
447 447
 			return false;
448 448
 		}
449 449
 
450 450
 		// Set query params.
451
-		switch ( $field ) {
451
+		switch ($field) {
452 452
 			case 'id':
453 453
 				$args['donor'] = $value;
454 454
 				break;
@@ -463,9 +463,9 @@  discard block
 block discarded – undo
463 463
 		}
464 464
 
465 465
 		// Get donors.
466
-		$donor = new Give_Donors_Query( $args );
466
+		$donor = new Give_Donors_Query($args);
467 467
 
468
-		if ( ! $donor = $donor->get_donors() ) {
468
+		if ( ! $donor = $donor->get_donors()) {
469 469
 			// Look for donor from an additional email.
470 470
 			$args = array(
471 471
 				'meta_query' => array(
@@ -476,15 +476,15 @@  discard block
 block discarded – undo
476 476
 				),
477 477
 			);
478 478
 
479
-			$donor = new Give_Donors_Query( $args );
479
+			$donor = new Give_Donors_Query($args);
480 480
 			$donor = $donor->get_donors();
481 481
 
482
-			if ( empty( $donor ) ) {
482
+			if (empty($donor)) {
483 483
 				return false;
484 484
 			}
485 485
 		}
486 486
 
487
-		return current( $donor );
487
+		return current($donor);
488 488
 	}
489 489
 
490 490
 	/**
@@ -497,10 +497,10 @@  discard block
 block discarded – undo
497 497
 	 *
498 498
 	 * @return array|object|null Donors array or object. Null if not found.
499 499
 	 */
500
-	public function get_donors( $args = array() ) {
501
-		$this->bc_1814_params( $args );
500
+	public function get_donors($args = array()) {
501
+		$this->bc_1814_params($args);
502 502
 
503
-		$donors = new Give_Donors_Query( $args );
503
+		$donors = new Give_Donors_Query($args);
504 504
 
505 505
 		return $donors->get_donors();
506 506
 
@@ -517,21 +517,21 @@  discard block
 block discarded – undo
517 517
 	 *
518 518
 	 * @return int         Total number of donors.
519 519
 	 */
520
-	public function count( $args = array() ) {
521
-		$this->bc_1814_params( $args );
520
+	public function count($args = array()) {
521
+		$this->bc_1814_params($args);
522 522
 		$args['count'] = true;
523 523
 
524
-		$cache_key = md5( 'give_donors_count' . serialize( $args ) );
525
-		$count     = Give_Cache::get_group( $cache_key, 'donors' );
524
+		$cache_key = md5('give_donors_count'.serialize($args));
525
+		$count     = Give_Cache::get_group($cache_key, 'donors');
526 526
 
527
-		if ( is_null( $count ) ) {
528
-			$donors = new Give_Donors_Query( $args );
527
+		if (is_null($count)) {
528
+			$donors = new Give_Donors_Query($args);
529 529
 			$count  = $donors->get_donors();
530 530
 
531
-			Give_Cache::set_group( $cache_key, $count, 'donors', 3600 );
531
+			Give_Cache::set_group($cache_key, $count, 'donors', 3600);
532 532
 		}
533 533
 
534
-		return absint( $count );
534
+		return absint($count);
535 535
 
536 536
 	}
537 537
 
@@ -545,9 +545,9 @@  discard block
 block discarded – undo
545 545
 	 */
546 546
 	public function create_table() {
547 547
 
548
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
548
+		require_once(ABSPATH.'wp-admin/includes/upgrade.php');
549 549
 
550
-		$sql = "CREATE TABLE " . $this->table_name . " (
550
+		$sql = "CREATE TABLE ".$this->table_name." (
551 551
 		id bigint(20) NOT NULL AUTO_INCREMENT,
552 552
 		user_id bigint(20) NOT NULL,
553 553
 		email varchar(50) NOT NULL,
@@ -565,9 +565,9 @@  discard block
 block discarded – undo
565 565
 		KEY user (user_id)
566 566
 		) CHARACTER SET utf8 COLLATE utf8_general_ci;";
567 567
 
568
-		dbDelta( $sql );
568
+		dbDelta($sql);
569 569
 
570
-		update_option( $this->table_name . '_db_version', $this->version );
570
+		update_option($this->table_name.'_db_version', $this->version);
571 571
 	}
572 572
 
573 573
 	/**
@@ -582,8 +582,8 @@  discard block
 block discarded – undo
582 582
 		global $wpdb;
583 583
 
584 584
 		if (
585
-			! give_has_upgrade_completed( 'v20_rename_donor_tables' ) &&
586
-			$wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customers" ) )
585
+			! give_has_upgrade_completed('v20_rename_donor_tables') &&
586
+			$wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customers"))
587 587
 		) {
588 588
 			$wpdb->donors = $this->table_name = "{$wpdb->prefix}give_customers";
589 589
 		}
@@ -597,41 +597,41 @@  discard block
 block discarded – undo
597 597
 	 *
598 598
 	 * @param $args
599 599
 	 */
600
-	private function bc_1814_params( &$args ) {
600
+	private function bc_1814_params(&$args) {
601 601
 		// Backward compatibility: user_id
602
-		if ( ! empty( $args['user_id'] ) ) {
602
+		if ( ! empty($args['user_id'])) {
603 603
 			$args['user'] = $args['user_id'];
604 604
 		}
605 605
 
606 606
 		// Backward compatibility: id
607
-		if ( ! empty( $args['id'] ) ) {
607
+		if ( ! empty($args['id'])) {
608 608
 			$args['donor'] = $args['id'];
609 609
 		}
610 610
 
611 611
 		// Backward compatibility: name
612
-		if ( ! empty( $args['name'] ) ) {
612
+		if ( ! empty($args['name'])) {
613 613
 			$args['s'] = "name:{$args['name']}";
614 614
 		}
615 615
 
616 616
 		// Backward compatibility: date
617 617
 		// Donors created for a specific date or in a date range.
618
-		if ( ! empty( $args['date'] ) ) {
618
+		if ( ! empty($args['date'])) {
619 619
 
620
-			if ( is_array( $args['date'] ) ) {
620
+			if (is_array($args['date'])) {
621 621
 
622
-				if ( ! empty( $args['date']['start'] ) ) {
623
-					$args['date_query']['after'] = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) );
622
+				if ( ! empty($args['date']['start'])) {
623
+					$args['date_query']['after'] = date('Y-m-d H:i:s', strtotime($args['date']['start']));
624 624
 				}
625 625
 
626
-				if ( ! empty( $args['date']['end'] ) ) {
627
-					$args['date_query']['before'] = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) );
626
+				if ( ! empty($args['date']['end'])) {
627
+					$args['date_query']['before'] = date('Y-m-d H:i:s', strtotime($args['date']['end']));
628 628
 				}
629 629
 
630 630
 			} else {
631 631
 
632
-				$args['date_query']['year']  = date( 'Y', strtotime( $args['date'] ) );
633
-				$args['date_query']['month'] = date( 'm', strtotime( $args['date'] ) );
634
-				$args['date_query']['day']   = date( 'd', strtotime( $args['date'] ) );
632
+				$args['date_query']['year']  = date('Y', strtotime($args['date']));
633
+				$args['date_query']['month'] = date('m', strtotime($args['date']));
634
+				$args['date_query']['day']   = date('d', strtotime($args['date']));
635 635
 			}
636 636
 		}
637 637
 	}
Please login to merge, or discard this patch.
includes/class-give-logging.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -512,7 +512,7 @@
 block discarded – undo
512 512
 	 * @since  1.7
513 513
 	 * @access public
514 514
 	 *
515
-	 * @return bool
515
+	 * @return false|null
516 516
 	 */
517 517
 	public function delete_cache() {
518 518
 		// Add log related keys to delete.
Please login to merge, or discard this patch.
Spacing   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
 		 * Setup properties
54 54
 		 */
55 55
 
56
-		require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-logs.php';
57
-		require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-logs-meta.php';
56
+		require_once GIVE_PLUGIN_DIR.'includes/class-give-db-logs.php';
57
+		require_once GIVE_PLUGIN_DIR.'includes/class-give-db-logs-meta.php';
58 58
 		$this->log_db     = new Give_DB_Logs();
59 59
 		$this->logmeta_db = new Give_DB_Log_Meta();
60 60
 
@@ -62,22 +62,22 @@  discard block
 block discarded – undo
62 62
 		 * Setup hooks.
63 63
 		 */
64 64
 
65
-		add_action( 'save_post_give_payment', array( $this, 'background_process_delete_cache' ) );
66
-		add_action( 'save_post_give_forms', array( $this, 'background_process_delete_cache' ) );
67
-		add_action( 'save_post_give_log', array( $this, 'background_process_delete_cache' ) );
68
-		add_action( 'give_delete_log_cache', array( $this, 'delete_cache' ) );
69
-		add_action( 'update_log_metadata', array( $this, 'bc_200_set_payment_as_log_parent' ), 10, 4 );
65
+		add_action('save_post_give_payment', array($this, 'background_process_delete_cache'));
66
+		add_action('save_post_give_forms', array($this, 'background_process_delete_cache'));
67
+		add_action('save_post_give_log', array($this, 'background_process_delete_cache'));
68
+		add_action('give_delete_log_cache', array($this, 'delete_cache'));
69
+		add_action('update_log_metadata', array($this, 'bc_200_set_payment_as_log_parent'), 10, 4);
70 70
 
71 71
 		// Backward compatibility.
72
-		if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) {
72
+		if ( ! give_has_upgrade_completed('v20_logs_upgrades')) {
73 73
 			// Create the log post type
74
-			add_action( 'init', array( $this, 'register_post_type' ), -2 );
74
+			add_action('init', array($this, 'register_post_type'), -2);
75 75
 		}
76 76
 
77 77
 		// Create types taxonomy and default types
78 78
 		// @todo: remove this taxonomy, some addon use this taxonomy with there custom log post type for example: recurring
79 79
 		// Do not use this taxonomy with your log type because we will remove it in future releases.
80
-		add_action( 'init', array( $this, 'register_taxonomy' ), -2 );
80
+		add_action('init', array($this, 'register_taxonomy'), -2);
81 81
 	}
82 82
 
83 83
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 		/* Logs post type */
96 96
 		$log_args = array(
97 97
 			'labels'              => array(
98
-				'name' => esc_html__( 'Logs', 'give' ),
98
+				'name' => esc_html__('Logs', 'give'),
99 99
 			),
100 100
 			'public'              => false,
101 101
 			'exclude_from_search' => true,
@@ -104,11 +104,11 @@  discard block
 block discarded – undo
104 104
 			'query_var'           => false,
105 105
 			'rewrite'             => false,
106 106
 			'capability_type'     => 'post',
107
-			'supports'            => array( 'title', 'editor' ),
107
+			'supports'            => array('title', 'editor'),
108 108
 			'can_export'          => true,
109 109
 		);
110 110
 
111
-		register_post_type( 'give_log', $log_args );
111
+		register_post_type('give_log', $log_args);
112 112
 	}
113 113
 
114 114
 	/**
@@ -122,9 +122,9 @@  discard block
 block discarded – undo
122 122
 	 * @return void
123 123
 	 */
124 124
 	public function register_taxonomy() {
125
-		register_taxonomy( 'give_log_type', 'give_log', array(
125
+		register_taxonomy('give_log_type', 'give_log', array(
126 126
 			'public' => false,
127
-		) );
127
+		));
128 128
 	}
129 129
 
130 130
 	/**
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 			'api_request',
145 145
 		);
146 146
 
147
-		return apply_filters( 'give_log_types', $terms );
147
+		return apply_filters('give_log_types', $terms);
148 148
 	}
149 149
 
150 150
 	/**
@@ -159,8 +159,8 @@  discard block
 block discarded – undo
159 159
 	 *
160 160
 	 * @return bool         Whether log type is valid.
161 161
 	 */
162
-	public function valid_type( $type ) {
163
-		return in_array( $type, $this->log_types() );
162
+	public function valid_type($type) {
163
+		return in_array($type, $this->log_types());
164 164
 	}
165 165
 
166 166
 	/**
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	 *
180 180
 	 * @return int             Log ID.
181 181
 	 */
182
-	public function add( $title = '', $message = '', $parent = 0, $type = '' ) {
182
+	public function add($title = '', $message = '', $parent = 0, $type = '') {
183 183
 		$log_data = array(
184 184
 			'post_title'   => $title,
185 185
 			'post_content' => $message,
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 			'log_type'     => $type,
188 188
 		);
189 189
 
190
-		return $this->insert_log( $log_data );
190
+		return $this->insert_log($log_data);
191 191
 	}
192 192
 
193 193
 	/**
@@ -204,12 +204,12 @@  discard block
 block discarded – undo
204 204
 	 *
205 205
 	 * @return array             An array of the connected logs.
206 206
 	 */
207
-	public function get_logs( $object_id = 0, $type = '', $paged = null ) {
208
-		return $this->get_connected_logs( array(
207
+	public function get_logs($object_id = 0, $type = '', $paged = null) {
208
+		return $this->get_connected_logs(array(
209 209
 			'log_parent' => $object_id,
210 210
 			'paged'      => $paged,
211 211
 			'log_type'   => $type,
212
-		) );
212
+		));
213 213
 	}
214 214
 
215 215
 	/**
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 	 *
224 224
 	 * @return int             The ID of the newly created log item.
225 225
 	 */
226
-	public function insert_log( $log_data = array(), $log_meta = array() ) {
226
+	public function insert_log($log_data = array(), $log_meta = array()) {
227 227
 		$log_id = 0;
228 228
 
229 229
 		$defaults = array(
@@ -236,28 +236,28 @@  discard block
 block discarded – undo
236 236
 			'post_status' => 'publish',
237 237
 		);
238 238
 
239
-		$args = wp_parse_args( $log_data, $defaults );
240
-		$this->bc_200_validate_params( $args, $log_meta );
239
+		$args = wp_parse_args($log_data, $defaults);
240
+		$this->bc_200_validate_params($args, $log_meta);
241 241
 
242
-		if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) {
242
+		if ( ! give_has_upgrade_completed('v20_logs_upgrades')) {
243 243
 			global $wpdb;
244 244
 
245 245
 			// Backward Compatibility.
246
-			if ( ! $wpdb->get_var( "SELECT ID from {$this->log_db->table_name} ORDER BY id DESC LIMIT 1" ) ) {
247
-				$latest_log_id = $wpdb->get_var( "SELECT ID from $wpdb->posts ORDER BY id DESC LIMIT 1" );
248
-				$latest_log_id = empty( $latest_log_id ) ? 1 : ++ $latest_log_id;
246
+			if ( ! $wpdb->get_var("SELECT ID from {$this->log_db->table_name} ORDER BY id DESC LIMIT 1")) {
247
+				$latest_log_id = $wpdb->get_var("SELECT ID from $wpdb->posts ORDER BY id DESC LIMIT 1");
248
+				$latest_log_id = empty($latest_log_id) ? 1 : ++ $latest_log_id;
249 249
 
250 250
 				$args['ID'] = $latest_log_id;
251
-				$this->log_db->insert( $args );
251
+				$this->log_db->insert($args);
252 252
 			}
253 253
 		}
254 254
 
255
-		$log_id = $this->log_db->add( $args );
255
+		$log_id = $this->log_db->add($args);
256 256
 
257 257
 		// Set log meta, if any
258
-		if ( $log_id && ! empty( $log_meta ) ) {
259
-			foreach ( (array) $log_meta as $key => $meta ) {
260
-				$this->logmeta_db->update_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta );
258
+		if ($log_id && ! empty($log_meta)) {
259
+			foreach ((array) $log_meta as $key => $meta) {
260
+				$this->logmeta_db->update_meta($log_id, '_give_log_'.sanitize_key($key), $meta);
261 261
 			}
262 262
 		}
263 263
 
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	 *
280 280
 	 * @return bool|null       True if successful, false otherwise.
281 281
 	 */
282
-	public function update_log( $log_data = array(), $log_meta = array() ) {
282
+	public function update_log($log_data = array(), $log_meta = array()) {
283 283
 		$log_id = 0;
284 284
 
285 285
 		/**
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 		 * @param array $log_data Log entry data.
291 291
 		 * @param array $log_meta Log entry meta.
292 292
 		 */
293
-		do_action( 'give_pre_update_log', $log_data, $log_meta );
293
+		do_action('give_pre_update_log', $log_data, $log_meta);
294 294
 
295 295
 		$defaults = array(
296 296
 			'log_parent'  => 0,
@@ -300,28 +300,28 @@  discard block
 block discarded – undo
300 300
 			'post_status' => 'publish',
301 301
 		);
302 302
 
303
-		$args = wp_parse_args( $log_data, $defaults );
304
-		$this->bc_200_validate_params( $args, $log_meta );
303
+		$args = wp_parse_args($log_data, $defaults);
304
+		$this->bc_200_validate_params($args, $log_meta);
305 305
 
306 306
 		// Store the log entry
307
-		if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) {
307
+		if ( ! give_has_upgrade_completed('v20_logs_upgrades')) {
308 308
 			// Backward compatibility.
309
-			$log_id = wp_update_post( $args );
309
+			$log_id = wp_update_post($args);
310 310
 
311
-			if ( $log_id && ! empty( $log_meta ) ) {
312
-				foreach ( (array) $log_meta as $key => $meta ) {
313
-					if ( ! empty( $meta ) ) {
314
-						give_update_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta );
311
+			if ($log_id && ! empty($log_meta)) {
312
+				foreach ((array) $log_meta as $key => $meta) {
313
+					if ( ! empty($meta)) {
314
+						give_update_meta($log_id, '_give_log_'.sanitize_key($key), $meta);
315 315
 					}
316 316
 				}
317 317
 			}
318 318
 		} else {
319
-			$log_id = $this->log_db->add( $args );
319
+			$log_id = $this->log_db->add($args);
320 320
 
321
-			if ( $log_id && ! empty( $log_meta ) ) {
322
-				foreach ( (array) $log_meta as $key => $meta ) {
323
-					if ( ! empty( $meta ) ) {
324
-						$this->logmeta_db->update_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta );
321
+			if ($log_id && ! empty($log_meta)) {
322
+				foreach ((array) $log_meta as $key => $meta) {
323
+					if ( ! empty($meta)) {
324
+						$this->logmeta_db->update_meta($log_id, '_give_log_'.sanitize_key($key), $meta);
325 325
 					}
326 326
 				}
327 327
 			}
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 		 * @param array $log_data Log entry data.
337 337
 		 * @param array $log_meta Log entry meta.
338 338
 		 */
339
-		do_action( 'give_post_update_log', $log_id, $log_data, $log_meta );
339
+		do_action('give_post_update_log', $log_id, $log_data, $log_meta);
340 340
 	}
341 341
 
342 342
 	/**
@@ -353,30 +353,30 @@  discard block
 block discarded – undo
353 353
 	 *
354 354
 	 * @return array|false Array if logs were found, false otherwise.
355 355
 	 */
356
-	public function get_connected_logs( $args = array() ) {
356
+	public function get_connected_logs($args = array()) {
357 357
 		$logs = array();
358 358
 
359
-		$defaults   = array(
359
+		$defaults = array(
360 360
 			'number'      => 20,
361
-			'paged'       => get_query_var( 'paged' ),
361
+			'paged'       => get_query_var('paged'),
362 362
 			'log_type'    => false,
363 363
 
364 364
 			// Backward compatibility.
365 365
 			'post_type'   => 'give_log',
366 366
 			'post_status' => 'publish',
367 367
 		);
368
-		$query_args = wp_parse_args( $args, $defaults );
369
-		$this->bc_200_validate_params( $query_args );
368
+		$query_args = wp_parse_args($args, $defaults);
369
+		$this->bc_200_validate_params($query_args);
370 370
 
371
-		if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) {
371
+		if ( ! give_has_upgrade_completed('v20_logs_upgrades')) {
372 372
 			// Backward compatibility.
373
-			$logs = get_posts( $query_args );
374
-			$this->bc_200_add_new_properties( $logs );
373
+			$logs = get_posts($query_args);
374
+			$this->bc_200_add_new_properties($logs);
375 375
 		} else {
376
-			$logs = $this->log_db->get_logs( $query_args );
376
+			$logs = $this->log_db->get_logs($query_args);
377 377
 		}
378 378
 
379
-		return ( ! empty( $logs ) ? $logs : false );
379
+		return ( ! empty($logs) ? $logs : false);
380 380
 	}
381 381
 
382 382
 	/**
@@ -394,41 +394,41 @@  discard block
 block discarded – undo
394 394
 	 *
395 395
 	 * @return int                Log count.
396 396
 	 */
397
-	public function get_log_count( $object_id = 0, $type = '', $meta_query = null, $date_query = null ) {
397
+	public function get_log_count($object_id = 0, $type = '', $meta_query = null, $date_query = null) {
398 398
 		$logs_count = 0;
399 399
 
400 400
 		$query_args = array(
401
-			'number'      => - 1,
401
+			'number'      => -1,
402 402
 
403 403
 			// Backward comatibility.
404 404
 			'post_type'   => 'give_log',
405 405
 			'post_status' => 'publish',
406 406
 		);
407 407
 
408
-		if ( $object_id ) {
408
+		if ($object_id) {
409 409
 			$query_args['log_parent'] = $object_id;
410 410
 		}
411 411
 
412
-		if ( ! empty( $type ) && $this->valid_type( $type ) ) {
412
+		if ( ! empty($type) && $this->valid_type($type)) {
413 413
 			$query_args['log_type'] = $type;
414 414
 		}
415 415
 
416
-		if ( ! empty( $meta_query ) ) {
416
+		if ( ! empty($meta_query)) {
417 417
 			$query_args['meta_query'] = $meta_query;
418 418
 		}
419 419
 
420
-		if ( ! empty( $date_query ) ) {
420
+		if ( ! empty($date_query)) {
421 421
 			$query_args['date_query'] = $date_query;
422 422
 		}
423 423
 
424
-		$this->bc_200_validate_params( $query_args );
424
+		$this->bc_200_validate_params($query_args);
425 425
 
426
-		if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) {
426
+		if ( ! give_has_upgrade_completed('v20_logs_upgrades')) {
427 427
 			// Backward compatibility.
428
-			$logs       = new WP_Query( $query_args );
428
+			$logs       = new WP_Query($query_args);
429 429
 			$logs_count = (int) $logs->post_count;
430 430
 		} else {
431
-			$logs_count = $this->log_db->count( $query_args );
431
+			$logs_count = $this->log_db->count($query_args);
432 432
 		}
433 433
 
434 434
 		return $logs_count;
@@ -448,10 +448,10 @@  discard block
 block discarded – undo
448 448
 	 *
449 449
 	 * @return void
450 450
 	 */
451
-	public function delete_logs( $object_id = 0, $type = '', $meta_query = null ) {
451
+	public function delete_logs($object_id = 0, $type = '', $meta_query = null) {
452 452
 		$query_args = array(
453 453
 			'log_parent'  => $object_id,
454
-			'number'      => - 1,
454
+			'number'      => -1,
455 455
 			'fields'      => 'ID',
456 456
 
457 457
 			// Backward compatibility.
@@ -459,32 +459,32 @@  discard block
 block discarded – undo
459 459
 			'post_status' => 'publish',
460 460
 		);
461 461
 
462
-		if ( ! empty( $type ) && $this->valid_type( $type ) ) {
462
+		if ( ! empty($type) && $this->valid_type($type)) {
463 463
 			$query_args['log_type'] = $type;
464 464
 		}
465 465
 
466
-		if ( ! empty( $meta_query ) ) {
466
+		if ( ! empty($meta_query)) {
467 467
 			$query_args['meta_query'] = $meta_query;
468 468
 		}
469 469
 
470
-		$this->bc_200_validate_params( $query_args );
470
+		$this->bc_200_validate_params($query_args);
471 471
 
472
-		if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) {
472
+		if ( ! give_has_upgrade_completed('v20_logs_upgrades')) {
473 473
 			// Backward compatibility.
474
-			$logs = get_posts( $query_args );
474
+			$logs = get_posts($query_args);
475 475
 
476
-			if ( $logs ) {
477
-				foreach ( $logs as $log ) {
478
-					wp_delete_post( $log, true );
476
+			if ($logs) {
477
+				foreach ($logs as $log) {
478
+					wp_delete_post($log, true);
479 479
 				}
480 480
 			}
481 481
 		} else {
482
-			$logs = $this->log_db->get_logs( $query_args );
482
+			$logs = $this->log_db->get_logs($query_args);
483 483
 
484
-			if ( $logs ) {
485
-				foreach ( $logs as $log ) {
486
-					if ( $this->log_db->delete( $log->ID ) ) {
487
-						$this->logmeta_db->delete_row( $log->ID );
484
+			if ($logs) {
485
+				foreach ($logs as $log) {
486
+					if ($this->log_db->delete($log->ID)) {
487
+						$this->logmeta_db->delete_row($log->ID);
488 488
 					}
489 489
 				}
490 490
 			}
@@ -501,9 +501,9 @@  discard block
 block discarded – undo
501 501
 	 *
502 502
 	 * @param int $post_id
503 503
 	 */
504
-	public function background_process_delete_cache( $post_id ) {
504
+	public function background_process_delete_cache($post_id) {
505 505
 		// Delete log cache immediately
506
-		wp_schedule_single_event( time() - 5, 'give_delete_log_cache' );
506
+		wp_schedule_single_event(time() - 5, 'give_delete_log_cache');
507 507
 	}
508 508
 
509 509
 	/**
@@ -516,17 +516,17 @@  discard block
 block discarded – undo
516 516
 	 */
517 517
 	public function delete_cache() {
518 518
 		// Add log related keys to delete.
519
-		$cache_give_logs      = Give_Cache::get_options_like( 'give_logs' );
520
-		$cache_give_log_count = Give_Cache::get_options_like( 'log_count' );
519
+		$cache_give_logs      = Give_Cache::get_options_like('give_logs');
520
+		$cache_give_log_count = Give_Cache::get_options_like('log_count');
521 521
 
522
-		$cache_option_names = array_merge( $cache_give_logs, $cache_give_log_count );
522
+		$cache_option_names = array_merge($cache_give_logs, $cache_give_log_count);
523 523
 
524 524
 		// Bailout.
525
-		if ( empty( $cache_option_names ) ) {
525
+		if (empty($cache_option_names)) {
526 526
 			return false;
527 527
 		}
528 528
 
529
-		Give_Cache::delete( $cache_option_names );
529
+		Give_Cache::delete($cache_option_names);
530 530
 	}
531 531
 
532 532
 	/**
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 	 * @param array $log_query
539 539
 	 * @param array $log_meta
540 540
 	 */
541
-	private function bc_200_validate_params( &$log_query, &$log_meta = array() ) {
541
+	private function bc_200_validate_params(&$log_query, &$log_meta = array()) {
542 542
 		$query_params = array(
543 543
 			'log_title'    => 'post_title',
544 544
 			'log_parent'   => 'post_parent',
@@ -550,41 +550,41 @@  discard block
 block discarded – undo
550 550
 			'meta_query'   => 'meta_query',
551 551
 		);
552 552
 
553
-		if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) {
553
+		if ( ! give_has_upgrade_completed('v20_logs_upgrades')) {
554 554
 			// Set old params.
555
-			foreach ( $query_params as $new_query_param => $old_query_param ) {
555
+			foreach ($query_params as $new_query_param => $old_query_param) {
556 556
 
557
-				if ( isset( $log_query[ $old_query_param ] ) && empty( $log_query[ $new_query_param ] ) ) {
558
-					$log_query[ $new_query_param ] = $log_query[ $old_query_param ];
557
+				if (isset($log_query[$old_query_param]) && empty($log_query[$new_query_param])) {
558
+					$log_query[$new_query_param] = $log_query[$old_query_param];
559 559
 					continue;
560
-				} elseif ( ! isset( $log_query[ $new_query_param ] ) ) {
560
+				} elseif ( ! isset($log_query[$new_query_param])) {
561 561
 					continue;
562
-				} elseif( empty( $log_query[ $new_query_param ] ) ) {
562
+				} elseif (empty($log_query[$new_query_param])) {
563 563
 					continue;
564 564
 				}
565 565
 
566
-				switch ( $new_query_param ) {
566
+				switch ($new_query_param) {
567 567
 					case 'log_type':
568 568
 						$log_query['tax_query'] = array(
569 569
 							array(
570 570
 								'taxonomy' => 'give_log_type',
571 571
 								'field'    => 'slug',
572
-								'terms'    => $log_query[ $new_query_param ],
572
+								'terms'    => $log_query[$new_query_param],
573 573
 							),
574 574
 						);
575 575
 						break;
576 576
 
577 577
 					case 'meta_query':
578
-						if( ! empty( $log_query['meta_query'] ) && empty( $log_query['post_parent'] ) ) {
579
-							foreach ( $log_query['meta_query'] as $index => $meta_query ){
580
-								if( ! is_array( $meta_query ) || empty( $meta_query['key'] ) ) {
578
+						if ( ! empty($log_query['meta_query']) && empty($log_query['post_parent'])) {
579
+							foreach ($log_query['meta_query'] as $index => $meta_query) {
580
+								if ( ! is_array($meta_query) || empty($meta_query['key'])) {
581 581
 									continue;
582 582
 								}
583 583
 
584
-								switch ( $meta_query['key'] ) {
584
+								switch ($meta_query['key']) {
585 585
 									case '_give_log_form_id':
586 586
 										$log_query['post_parent'] = $meta_query['value'];
587
-										unset( $log_query['meta_query'][$index] );
587
+										unset($log_query['meta_query'][$index]);
588 588
 										break;
589 589
 								}
590 590
 							}
@@ -592,40 +592,40 @@  discard block
 block discarded – undo
592 592
 						break;
593 593
 
594 594
 					default:
595
-						switch( $new_query_param ){
595
+						switch ($new_query_param) {
596 596
 							case 'log_parent':
597 597
 								$log_query['meta_query'][] = array(
598 598
 									'key' => '_give_log_payment_id',
599
-									'value' => $log_query[ $new_query_param ]
599
+									'value' => $log_query[$new_query_param]
600 600
 								);
601 601
 
602 602
 								break;
603 603
 
604 604
 							default:
605
-								$log_query[ $old_query_param ] = $log_query[ $new_query_param ];
605
+								$log_query[$old_query_param] = $log_query[$new_query_param];
606 606
 						}
607 607
 				}
608 608
 			}
609 609
 		} else {
610 610
 			// Set only old params.
611
-			$query_params = array_flip( $query_params );
612
-			foreach ( $query_params as $old_query_param => $new_query_param ) {
613
-				if ( isset( $log_query[ $new_query_param ] ) && empty( $log_query[ $old_query_param ] ) ) {
614
-					$log_query[ $old_query_param ] = $log_query[ $new_query_param ];
611
+			$query_params = array_flip($query_params);
612
+			foreach ($query_params as $old_query_param => $new_query_param) {
613
+				if (isset($log_query[$new_query_param]) && empty($log_query[$old_query_param])) {
614
+					$log_query[$old_query_param] = $log_query[$new_query_param];
615 615
 					continue;
616
-				} elseif ( ! isset( $log_query[ $old_query_param ] ) ) {
616
+				} elseif ( ! isset($log_query[$old_query_param])) {
617 617
 					continue;
618 618
 				}
619 619
 
620
-				switch ( $old_query_param ) {
620
+				switch ($old_query_param) {
621 621
 					case 'tax_query':
622
-						if ( isset( $log_query[ $old_query_param ][0]['terms'] ) ) {
623
-							$log_query[ $new_query_param ] = $log_query[ $old_query_param ][0]['terms'];
622
+						if (isset($log_query[$old_query_param][0]['terms'])) {
623
+							$log_query[$new_query_param] = $log_query[$old_query_param][0]['terms'];
624 624
 						}
625 625
 						break;
626 626
 
627 627
 					default:
628
-						$log_query[ $new_query_param ] = $log_query[ $old_query_param ];
628
+						$log_query[$new_query_param] = $log_query[$old_query_param];
629 629
 				}
630 630
 			}
631 631
 		}
@@ -639,8 +639,8 @@  discard block
 block discarded – undo
639 639
 	 *
640 640
 	 * @param  array $logs
641 641
 	 */
642
-	private function bc_200_add_new_properties( &$logs ) {
643
-		if ( empty( $logs ) ) {
642
+	private function bc_200_add_new_properties(&$logs) {
643
+		if (empty($logs)) {
644 644
 			return;
645 645
 		}
646 646
 
@@ -653,30 +653,30 @@  discard block
 block discarded – undo
653 653
 			'log_type'     => 'give_log_type',
654 654
 		);
655 655
 
656
-		if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) {
657
-			foreach ( $logs as $index => $log ) {
658
-				foreach ( $query_params as $new_query_param => $old_query_param ) {
659
-					if ( ! property_exists( $log, $old_query_param ) ) {
656
+		if ( ! give_has_upgrade_completed('v20_logs_upgrades')) {
657
+			foreach ($logs as $index => $log) {
658
+				foreach ($query_params as $new_query_param => $old_query_param) {
659
+					if ( ! property_exists($log, $old_query_param)) {
660 660
 						/**
661 661
 						 *  Set unmatched properties.
662 662
 						 */
663 663
 
664 664
 						// 1. log_type
665
-						$term = get_the_terms( $log->ID, 'give_log_type' );
666
-						$term = ! is_wp_error( $term ) && ! empty( $term ) ? $term[0] : array();
665
+						$term = get_the_terms($log->ID, 'give_log_type');
666
+						$term = ! is_wp_error($term) && ! empty($term) ? $term[0] : array();
667 667
 
668
-						$logs[ $index ]->{$new_query_param} = ! empty( $term ) ? $term->slug : '';
668
+						$logs[$index]->{$new_query_param} = ! empty($term) ? $term->slug : '';
669 669
 
670 670
 						continue;
671 671
 					}
672 672
 
673
-					switch ( $old_query_param ) {
673
+					switch ($old_query_param) {
674 674
 						case 'post_parent':
675
-							$logs[ $index ]->{$new_query_param} = give_get_meta( $log->ID, '_give_log_payment_id', true );
675
+							$logs[$index]->{$new_query_param} = give_get_meta($log->ID, '_give_log_payment_id', true);
676 676
 							break;
677 677
 
678 678
 						default:
679
-							$logs[ $index ]->{$new_query_param} = $log->{$old_query_param};
679
+							$logs[$index]->{$new_query_param} = $log->{$old_query_param};
680 680
 					}
681 681
 				}
682 682
 			}
@@ -696,10 +696,10 @@  discard block
 block discarded – undo
696 696
 	 *
697 697
 	 * @return mixed
698 698
 	 */
699
-	public function bc_200_set_payment_as_log_parent( $check, $log_id, $meta_key, $meta_value ) {
699
+	public function bc_200_set_payment_as_log_parent($check, $log_id, $meta_key, $meta_value) {
700 700
 		global $wpdb;
701 701
 		$update_status = false;
702
-		$post_type     = get_post_type( $log_id );
702
+		$post_type     = get_post_type($log_id);
703 703
 
704 704
 		// Bailout.
705 705
 		if (
@@ -719,9 +719,9 @@  discard block
 block discarded – undo
719 719
 			)
720 720
 		);
721 721
 
722
-		if ( $form_id ) {
723
-			$this->logmeta_db->delete_meta( $log_id, '_give_log_payment_id' );
724
-			$this->logmeta_db->update_meta( $log_id, '_give_log_form_id', $form_id );
722
+		if ($form_id) {
723
+			$this->logmeta_db->delete_meta($log_id, '_give_log_payment_id');
724
+			$this->logmeta_db->update_meta($log_id, '_give_log_form_id', $form_id);
725 725
 
726 726
 			$update_status = $wpdb->update(
727 727
 				$this->log_db->table_name,
Please login to merge, or discard this patch.
includes/install.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -397,7 +397,7 @@
 block discarded – undo
397 397
  *
398 398
  * @since 1.8.11
399 399
  *
400
- * @return void
400
+ * @return false|null
401 401
  */
402 402
 function give_create_pages() {
403 403
 
Please login to merge, or discard this patch.
Spacing   +60 added lines, -60 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,15 +28,15 @@  discard block
 block discarded – undo
28 28
  * @global     $wpdb
29 29
  * @return void
30 30
  */
31
-function give_install( $network_wide = false ) {
31
+function give_install($network_wide = false) {
32 32
 
33 33
 	global $wpdb;
34 34
 
35
-	if ( is_multisite() && $network_wide ) {
35
+	if (is_multisite() && $network_wide) {
36 36
 
37
-		foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) {
37
+		foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) {
38 38
 
39
-			switch_to_blog( $blog_id );
39
+			switch_to_blog($blog_id);
40 40
 			give_run_install();
41 41
 			restore_current_blog();
42 42
 
@@ -63,31 +63,31 @@  discard block
 block discarded – undo
63 63
 	give_setup_post_types();
64 64
 
65 65
 	// Add Upgraded From Option.
66
-	$current_version = get_option( 'give_version' );
67
-	if ( $current_version ) {
68
-		update_option( 'give_version_upgraded_from', $current_version );
66
+	$current_version = get_option('give_version');
67
+	if ($current_version) {
68
+		update_option('give_version_upgraded_from', $current_version);
69 69
 	}
70 70
 
71 71
 	// Setup some default options.
72 72
 	$options = array();
73 73
 
74 74
 	//Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency.
75
-	if ( empty( $current_version ) ) {
76
-		$options = array_merge( $options, give_get_default_settings() );
75
+	if (empty($current_version)) {
76
+		$options = array_merge($options, give_get_default_settings());
77 77
 	}
78 78
 
79 79
 	// Populate the default values.
80
-	update_option( 'give_settings', array_merge( $give_options, $options ) );
80
+	update_option('give_settings', array_merge($give_options, $options));
81 81
 
82 82
 	/**
83 83
 	 * Run plugin upgrades.
84 84
 	 *
85 85
 	 * @since 1.8
86 86
 	 */
87
-	do_action( 'give_upgrades' );
87
+	do_action('give_upgrades');
88 88
 
89
-	if ( GIVE_VERSION !== get_option( 'give_version' ) ) {
90
-		update_option( 'give_version', GIVE_VERSION );
89
+	if (GIVE_VERSION !== get_option('give_version')) {
90
+		update_option('give_version', GIVE_VERSION);
91 91
 	}
92 92
 
93 93
 	// Create Give roles.
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	// Set api version, end point and refresh permalink.
99 99
 	$api = new Give_API();
100 100
 	$api->add_endpoint();
101
-	update_option( 'give_default_api_version', 'v' . $api->get_version() );
101
+	update_option('give_default_api_version', 'v'.$api->get_version());
102 102
 
103 103
 	flush_rewrite_rules();
104 104
 
@@ -113,11 +113,11 @@  discard block
 block discarded – undo
113 113
 	$give_sessions->use_php_sessions();
114 114
 
115 115
 	// Add a temporary option to note that Give pages have been created.
116
-	Give_Cache::set( '_give_installed', $options, 30, true );
116
+	Give_Cache::set('_give_installed', $options, 30, true);
117 117
 
118
-	if ( ! $current_version ) {
118
+	if ( ! $current_version) {
119 119
 
120
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php';
120
+		require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php';
121 121
 
122 122
 		// When new upgrade routines are added, mark them as complete on fresh install.
123 123
 		$upgrade_routines = array(
@@ -144,18 +144,18 @@  discard block
 block discarded – undo
144 144
 			'v20_upgrades_payment_metadata'
145 145
 		);
146 146
 
147
-		foreach ( $upgrade_routines as $upgrade ) {
148
-			give_set_upgrade_complete( $upgrade );
147
+		foreach ($upgrade_routines as $upgrade) {
148
+			give_set_upgrade_complete($upgrade);
149 149
 		}
150 150
 	}
151 151
 
152 152
 	// Bail if activating from network, or bulk.
153
-	if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
153
+	if (is_network_admin() || isset($_GET['activate-multi'])) {
154 154
 		return;
155 155
 	}
156 156
 
157 157
 	// Add the transient to redirect.
158
-	Give_Cache::set( '_give_activation_redirect', true, 30, true );
158
+	Give_Cache::set('_give_activation_redirect', true, 30, true);
159 159
 }
160 160
 
161 161
 /**
@@ -173,11 +173,11 @@  discard block
 block discarded – undo
173 173
  * @param  int    $site_id The Site ID.
174 174
  * @param  array  $meta    Blog Meta.
175 175
  */
176
-function give_on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
176
+function give_on_create_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) {
177 177
 
178
-	if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) {
178
+	if (is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)) {
179 179
 
180
-		switch_to_blog( $blog_id );
180
+		switch_to_blog($blog_id);
181 181
 		give_install();
182 182
 		restore_current_blog();
183 183
 
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 
186 186
 }
187 187
 
188
-add_action( 'wpmu_new_blog', 'give_on_create_blog', 10, 6 );
188
+add_action('wpmu_new_blog', 'give_on_create_blog', 10, 6);
189 189
 
190 190
 
191 191
 /**
@@ -198,13 +198,13 @@  discard block
 block discarded – undo
198 198
  *
199 199
  * @return array          The tables to drop.
200 200
  */
201
-function give_wpmu_drop_tables( $tables, $blog_id ) {
201
+function give_wpmu_drop_tables($tables, $blog_id) {
202 202
 
203
-	switch_to_blog( $blog_id );
203
+	switch_to_blog($blog_id);
204 204
 	$donors_db     = new Give_DB_Donors();
205 205
 	$donor_meta_db = new Give_DB_Donor_Meta();
206 206
 
207
-	if ( $donors_db->installed() ) {
207
+	if ($donors_db->installed()) {
208 208
 		$tables[] = $donors_db->table_name;
209 209
 		$tables[] = $donor_meta_db->table_name;
210 210
 	}
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 
215 215
 }
216 216
 
217
-add_filter( 'wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2 );
217
+add_filter('wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2);
218 218
 
219 219
 /**
220 220
  * Post-installation
@@ -226,16 +226,16 @@  discard block
 block discarded – undo
226 226
  */
227 227
 function give_after_install() {
228 228
 
229
-	if ( ! is_admin() ) {
229
+	if ( ! is_admin()) {
230 230
 		return;
231 231
 	}
232 232
 
233
-	$give_options     = Give_Cache::get( '_give_installed', true );
234
-	$give_table_check = get_option( '_give_table_check', false );
233
+	$give_options     = Give_Cache::get('_give_installed', true);
234
+	$give_table_check = get_option('_give_table_check', false);
235 235
 
236
-	if ( false === $give_table_check || current_time( 'timestamp' ) > $give_table_check ) {
236
+	if (false === $give_table_check || current_time('timestamp') > $give_table_check) {
237 237
 
238
-		if ( ! @Give()->donor_meta->installed() ) {
238
+		if ( ! @Give()->donor_meta->installed()) {
239 239
 
240 240
 			// Create the donor meta database.
241 241
 			// (this ensures it creates it on multisite instances where it is network activated).
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 
244 244
 		}
245 245
 
246
-		if ( ! @Give()->donors->installed() ) {
246
+		if ( ! @Give()->donors->installed()) {
247 247
 			// Create the donor database.
248 248
 			// (this ensures it creates it on multisite instances where it is network activated).
249 249
 			@Give()->donors->create_table();
@@ -255,22 +255,22 @@  discard block
 block discarded – undo
255 255
 			 *
256 256
 			 * @param array $give_options Give plugin options.
257 257
 			 */
258
-			do_action( 'give_after_install', $give_options );
258
+			do_action('give_after_install', $give_options);
259 259
 		}
260 260
 
261
-		update_option( '_give_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ) );
261
+		update_option('_give_table_check', (current_time('timestamp') + WEEK_IN_SECONDS));
262 262
 
263 263
 	}
264 264
 
265 265
 	// Delete the transient
266
-	if ( false !== $give_options ) {
267
-		Give_Cache::delete( Give_Cache::get_key( '_give_installed' ) );
266
+	if (false !== $give_options) {
267
+		Give_Cache::delete(Give_Cache::get_key('_give_installed'));
268 268
 	}
269 269
 
270 270
 
271 271
 }
272 272
 
273
-add_action( 'admin_init', 'give_after_install' );
273
+add_action('admin_init', 'give_after_install');
274 274
 
275 275
 
276 276
 /**
@@ -285,11 +285,11 @@  discard block
 block discarded – undo
285 285
 
286 286
 	global $wp_roles;
287 287
 
288
-	if ( ! is_object( $wp_roles ) ) {
288
+	if ( ! is_object($wp_roles)) {
289 289
 		return;
290 290
 	}
291 291
 
292
-	if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) {
292
+	if ( ! array_key_exists('give_manager', $wp_roles->roles)) {
293 293
 
294 294
 		// Create Give plugin roles
295 295
 		$roles = new Give_Roles();
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 
301 301
 }
302 302
 
303
-add_action( 'admin_init', 'give_install_roles_on_network' );
303
+add_action('admin_init', 'give_install_roles_on_network');
304 304
 
305 305
 /**
306 306
  * Default core setting values.
@@ -339,14 +339,14 @@  discard block
 block discarded – undo
339 339
 		'uninstall_on_delete'                         => 'disabled',
340 340
 		'the_content_filter'                          => 'enabled',
341 341
 		'scripts_footer'                              => 'disabled',
342
-		'agree_to_terms_label'                        => __( 'Agree to Terms?', 'give' ),
342
+		'agree_to_terms_label'                        => __('Agree to Terms?', 'give'),
343 343
 		'agreement_text'                              => give_get_default_agreement_text(),
344 344
 
345 345
 		// Paypal IPN verification.
346 346
 		'paypal_verification'                         => 'enabled',
347 347
 
348 348
 		// Default is manual gateway.
349
-		'gateways'                                    => array( 'manual' => 1, 'offline' => 1 ),
349
+		'gateways'                                    => array('manual' => 1, 'offline' => 1),
350 350
 		'default_gateway'                             => 'manual',
351 351
 
352 352
 		// Offline gateway setup.
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
  */
375 375
 function give_get_default_agreement_text() {
376 376
 
377
-	$org_name = get_bloginfo( 'name' );
377
+	$org_name = get_bloginfo('name');
378 378
 
379 379
 	$agreement = sprintf(
380 380
 		'<p>Acceptance of any contribution, gift or grant is at the discretion of the %1$s. The  %1$s will not accept any gift unless it can be used or expended consistently with the purpose and mission of the  %1$s.</p>
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 		$org_name
389 389
 	);
390 390
 
391
-	return apply_filters( 'give_get_default_agreement_text', $agreement, $org_name );
391
+	return apply_filters('give_get_default_agreement_text', $agreement, $org_name);
392 392
 }
393 393
 
394 394
 
@@ -402,19 +402,19 @@  discard block
 block discarded – undo
402 402
 function give_create_pages() {
403 403
 
404 404
 	// Bailout if pages already created.
405
-	if ( get_option( 'give_install_pages_created' ) ) {
405
+	if (get_option('give_install_pages_created')) {
406 406
 		return false;
407 407
 	}
408 408
 
409 409
 	$options = array();
410 410
 
411 411
 	// Checks if the Success Page option exists AND that the page exists.
412
-	if ( ! get_post( give_get_option( 'success_page' ) ) ) {
412
+	if ( ! get_post(give_get_option('success_page'))) {
413 413
 
414 414
 		// Donation Confirmation (Success) Page
415 415
 		$success = wp_insert_post(
416 416
 			array(
417
-				'post_title'     => esc_html__( 'Donation Confirmation', 'give' ),
417
+				'post_title'     => esc_html__('Donation Confirmation', 'give'),
418 418
 				'post_content'   => '[give_receipt]',
419 419
 				'post_status'    => 'publish',
420 420
 				'post_author'    => 1,
@@ -428,13 +428,13 @@  discard block
 block discarded – undo
428 428
 	}
429 429
 
430 430
 	// Checks if the Failure Page option exists AND that the page exists.
431
-	if ( ! get_post( give_get_option( 'failure_page' ) ) ) {
431
+	if ( ! get_post(give_get_option('failure_page'))) {
432 432
 
433 433
 		// Failed Donation Page
434 434
 		$failed = wp_insert_post(
435 435
 			array(
436
-				'post_title'     => esc_html__( 'Donation Failed', 'give' ),
437
-				'post_content'   => esc_html__( 'We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give' ),
436
+				'post_title'     => esc_html__('Donation Failed', 'give'),
437
+				'post_content'   => esc_html__('We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give'),
438 438
 				'post_status'    => 'publish',
439 439
 				'post_author'    => 1,
440 440
 				'post_type'      => 'page',
@@ -446,11 +446,11 @@  discard block
 block discarded – undo
446 446
 	}
447 447
 
448 448
 	// Checks if the History Page option exists AND that the page exists.
449
-	if ( ! get_post( give_get_option( 'history_page' ) ) ) {
449
+	if ( ! get_post(give_get_option('history_page'))) {
450 450
 		// Donation History Page
451 451
 		$history = wp_insert_post(
452 452
 			array(
453
-				'post_title'     => esc_html__( 'Donation History', 'give' ),
453
+				'post_title'     => esc_html__('Donation History', 'give'),
454 454
 				'post_content'   => '[donation_history]',
455 455
 				'post_status'    => 'publish',
456 456
 				'post_author'    => 1,
@@ -462,11 +462,11 @@  discard block
 block discarded – undo
462 462
 		$options['history_page'] = $history;
463 463
 	}
464 464
 
465
-	if ( ! empty( $options ) ) {
466
-		update_option( 'give_settings', array_merge( give_get_settings(), $options ) );
465
+	if ( ! empty($options)) {
466
+		update_option('give_settings', array_merge(give_get_settings(), $options));
467 467
 	}
468 468
 
469
-	add_option( 'give_install_pages_created', 1, '', 'no' );
469
+	add_option('give_install_pages_created', 1, '', 'no');
470 470
 }
471 471
 
472
-add_action( 'admin_init', 'give_create_pages', - 1 );
472
+add_action('admin_init', 'give_create_pages', - 1);
Please login to merge, or discard this patch.
includes/payments/backward-compatibility.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -207,7 +207,7 @@
 block discarded – undo
207 207
  *                              metadata entries with the specified value.
208 208
  *                              Otherwise, update all entries.
209 209
  *
210
- * @return mixed
210
+ * @return null|boolean
211 211
  */
212 212
 function _give_20_bc_saving_old_payment_meta( $check, $object_id, $meta_key, $meta_value, $prev_value ) {
213 213
 	// Bailout.
Please login to merge, or discard this patch.
Spacing   +166 added lines, -171 removed lines patch added patch discarded remove patch
@@ -9,74 +9,74 @@  discard block
 block discarded – undo
9 9
  *
10 10
  * @return void
11 11
  */
12
-function _give_20_bc_split_and_save_give_payment_meta( $object_id, $meta_value ) {
12
+function _give_20_bc_split_and_save_give_payment_meta($object_id, $meta_value) {
13 13
 	// Bailout
14
-	if ( empty( $meta_value ) ) {
14
+	if (empty($meta_value)) {
15 15
 		return;
16
-	} elseif ( ! is_array( $meta_value ) ) {
16
+	} elseif ( ! is_array($meta_value)) {
17 17
 		$meta_value = array();
18 18
 	}
19 19
 
20
-	remove_filter( 'get_post_metadata', '_give_20_bc_get_new_payment_meta', 10 );
20
+	remove_filter('get_post_metadata', '_give_20_bc_get_new_payment_meta', 10);
21 21
 
22 22
 	// Date payment meta.
23
-	if ( ! empty( $meta_value['date'] ) ) {
24
-		give_update_meta( $object_id, '_give_payment_date', $meta_value['date'] );
23
+	if ( ! empty($meta_value['date'])) {
24
+		give_update_meta($object_id, '_give_payment_date', $meta_value['date']);
25 25
 	}
26 26
 
27 27
 	// Currency payment meta.
28
-	if ( ! empty( $meta_value['currency'] ) ) {
29
-		give_update_meta( $object_id, '_give_payment_currency', $meta_value['currency'] );
28
+	if ( ! empty($meta_value['currency'])) {
29
+		give_update_meta($object_id, '_give_payment_currency', $meta_value['currency']);
30 30
 	}
31 31
 
32 32
 	// User information.
33
-	if ( ! empty( $meta_value['user_info'] ) ) {
33
+	if ( ! empty($meta_value['user_info'])) {
34 34
 		// Donor first name.
35
-		if ( ! empty( $meta_value['user_info']['first_name'] ) ) {
36
-			give_update_meta( $object_id, '_give_donor_billing_first_name', $meta_value['user_info']['first_name'] );
35
+		if ( ! empty($meta_value['user_info']['first_name'])) {
36
+			give_update_meta($object_id, '_give_donor_billing_first_name', $meta_value['user_info']['first_name']);
37 37
 		}
38 38
 
39 39
 		// Donor last name.
40
-		if ( ! empty( $meta_value['user_info']['last_name'] ) ) {
41
-			give_update_meta( $object_id, '_give_donor_billing_last_name', $meta_value['user_info']['last_name'] );
40
+		if ( ! empty($meta_value['user_info']['last_name'])) {
41
+			give_update_meta($object_id, '_give_donor_billing_last_name', $meta_value['user_info']['last_name']);
42 42
 		}
43 43
 
44 44
 		// Donor address payment meta.
45
-		if ( ! empty( $meta_value['user_info']['address'] ) ) {
45
+		if ( ! empty($meta_value['user_info']['address'])) {
46 46
 
47 47
 			// Address1.
48
-			if ( ! empty( $meta_value['user_info']['address']['line1'] ) ) {
49
-				give_update_meta( $object_id, '_give_donor_billing_address1', $meta_value['user_info']['address']['line1'] );
48
+			if ( ! empty($meta_value['user_info']['address']['line1'])) {
49
+				give_update_meta($object_id, '_give_donor_billing_address1', $meta_value['user_info']['address']['line1']);
50 50
 			}
51 51
 
52 52
 			// Address2.
53
-			if ( ! empty( $meta_value['user_info']['address']['line2'] ) ) {
54
-				give_update_meta( $object_id, '_give_donor_billing_address2', $meta_value['user_info']['address']['line2'] );
53
+			if ( ! empty($meta_value['user_info']['address']['line2'])) {
54
+				give_update_meta($object_id, '_give_donor_billing_address2', $meta_value['user_info']['address']['line2']);
55 55
 			}
56 56
 
57 57
 			// City.
58
-			if ( ! empty( $meta_value['user_info']['address']['city'] ) ) {
59
-				give_update_meta( $object_id, '_give_donor_billing_city', $meta_value['user_info']['address']['city'] );
58
+			if ( ! empty($meta_value['user_info']['address']['city'])) {
59
+				give_update_meta($object_id, '_give_donor_billing_city', $meta_value['user_info']['address']['city']);
60 60
 			}
61 61
 
62 62
 			// Zip.
63
-			if ( ! empty( $meta_value['user_info']['address']['zip'] ) ) {
64
-				give_update_meta( $object_id, '_give_donor_billing_zip', $meta_value['user_info']['address']['zip'] );
63
+			if ( ! empty($meta_value['user_info']['address']['zip'])) {
64
+				give_update_meta($object_id, '_give_donor_billing_zip', $meta_value['user_info']['address']['zip']);
65 65
 			}
66 66
 
67 67
 			// State.
68
-			if ( ! empty( $meta_value['user_info']['address']['state'] ) ) {
69
-				give_update_meta( $object_id, '_give_donor_billing_state', $meta_value['user_info']['address']['state'] );
68
+			if ( ! empty($meta_value['user_info']['address']['state'])) {
69
+				give_update_meta($object_id, '_give_donor_billing_state', $meta_value['user_info']['address']['state']);
70 70
 			}
71 71
 
72 72
 			// Country.
73
-			if ( ! empty( $meta_value['user_info']['address']['country'] ) ) {
74
-				give_update_meta( $object_id, '_give_donor_billing_country', $meta_value['user_info']['address']['country'] );
73
+			if ( ! empty($meta_value['user_info']['address']['country'])) {
74
+				give_update_meta($object_id, '_give_donor_billing_country', $meta_value['user_info']['address']['country']);
75 75
 			}
76 76
 		}
77 77
 	}// End if().
78 78
 
79
-	add_filter( 'get_post_metadata', '_give_20_bc_get_new_payment_meta', 10, 5 );
79
+	add_filter('get_post_metadata', '_give_20_bc_get_new_payment_meta', 10, 5);
80 80
 }
81 81
 
82 82
 /**
@@ -89,103 +89,99 @@  discard block
 block discarded – undo
89 89
  *
90 90
  * @return array
91 91
  */
92
-function _give_20_bc_give_payment_meta_value( $object_id, $meta_value ) {
92
+function _give_20_bc_give_payment_meta_value($object_id, $meta_value) {
93 93
 	$cache_key = "_give_payment_meta_{$object_id}";
94
-	$cache     = Give_Cache::get_db_query( $cache_key );
94
+	$cache     = Give_Cache::get_db_query($cache_key);
95 95
 
96
-	if ( ! is_null( $cache ) ) {
96
+	if ( ! is_null($cache)) {
97 97
 		return $cache;
98 98
 	}
99 99
 
100 100
 	// Set default value to array.
101
-	if ( ! is_array( $meta_value ) ) {
101
+	if ( ! is_array($meta_value)) {
102 102
 		$meta_value = array();
103 103
 	}
104 104
 
105 105
 	// Donation key.
106
-	$meta_value['key'] = give_get_meta( $object_id, '_give_payment_purchase_key', true );
106
+	$meta_value['key'] = give_get_meta($object_id, '_give_payment_purchase_key', true);
107 107
 
108 108
 	// Donation form.
109
-	$meta_value['form_title'] = give_get_meta( $object_id, '_give_payment_form_title', true );
109
+	$meta_value['form_title'] = give_get_meta($object_id, '_give_payment_form_title', true);
110 110
 
111 111
 	// Donor email.
112
-	$meta_value['email'] = give_get_meta( $object_id, '_give_payment_donor_email', true );
113
-	$meta_value['email'] = ! empty( $meta_value['email'] ) ?
114
-		$meta_value['email'] :
115
-		Give()->donors->get_column( 'email', give_get_payment_donor_id( $object_id ) );
112
+	$meta_value['email'] = give_get_meta($object_id, '_give_payment_donor_email', true);
113
+	$meta_value['email'] = ! empty($meta_value['email']) ?
114
+		$meta_value['email'] : Give()->donors->get_column('email', give_get_payment_donor_id($object_id));
116 115
 
117 116
 	// Form id.
118
-	$meta_value['form_id'] = give_get_meta( $object_id, '_give_payment_form_id', true );
117
+	$meta_value['form_id'] = give_get_meta($object_id, '_give_payment_form_id', true);
119 118
 
120 119
 	// Price id.
121
-	$meta_value['price_id'] = give_get_meta( $object_id, '_give_payment_price_id', true );
120
+	$meta_value['price_id'] = give_get_meta($object_id, '_give_payment_price_id', true);
122 121
 
123 122
 	// Date.
124
-	$meta_value['date'] = give_get_meta( $object_id, '_give_payment_date', true );
125
-	$meta_value['date'] = ! empty( $meta_value['date'] ) ?
126
-		$meta_value['date'] :
127
-		get_post_field( 'post_date', $object_id );
123
+	$meta_value['date'] = give_get_meta($object_id, '_give_payment_date', true);
124
+	$meta_value['date'] = ! empty($meta_value['date']) ?
125
+		$meta_value['date'] : get_post_field('post_date', $object_id);
128 126
 
129 127
 	// Currency.
130
-	$meta_value['currency'] = give_get_meta( $object_id, '_give_payment_currency', true );
128
+	$meta_value['currency'] = give_get_meta($object_id, '_give_payment_currency', true);
131 129
 
132 130
 	// Decode donor data.
133
-	$donor_names = give_get_donor_name_by( give_get_meta( $object_id, '_give_payment_donor_id', true ), 'donor' );
134
-	$donor_names = explode( ' ', $donor_names, 2 );
131
+	$donor_names = give_get_donor_name_by(give_get_meta($object_id, '_give_payment_donor_id', true), 'donor');
132
+	$donor_names = explode(' ', $donor_names, 2);
135 133
 
136 134
 	// Donor first name.
137
-	$donor_data['first_name'] = give_get_meta( $object_id, '_give_donor_billing_first_name', true );
138
-	$donor_data['first_name'] = ! empty( $donor_data['first_name'] ) ?
139
-		$donor_data['first_name'] :
140
-		$donor_names[0];
135
+	$donor_data['first_name'] = give_get_meta($object_id, '_give_donor_billing_first_name', true);
136
+	$donor_data['first_name'] = ! empty($donor_data['first_name']) ?
137
+		$donor_data['first_name'] : $donor_names[0];
141 138
 
142 139
 	// Donor last name.
143
-	$donor_data['last_name'] = give_get_meta( $object_id, '_give_donor_billing_last_name', true );
144
-	$donor_data['last_name'] = ! empty( $donor_data['last_name'] ) ?
145
-		$donor_data['last_name'] :
146
-		( isset( $donor_names[1] ) ? $donor_names[1] : '' );
140
+	$donor_data['last_name'] = give_get_meta($object_id, '_give_donor_billing_last_name', true);
141
+	$donor_data['last_name'] = ! empty($donor_data['last_name']) ?
142
+		$donor_data['last_name'] : (isset($donor_names[1]) ? $donor_names[1] : '');
147 143
 
148 144
 	// Donor email.
149 145
 	$donor_data['email'] = $meta_value['email'];
150 146
 
151 147
 	// User ID.
152
-	$donor_data['id'] = give_get_payment_user_id( $object_id );
148
+	$donor_data['id'] = give_get_payment_user_id($object_id);
153 149
 
154 150
 	$donor_data['address'] = false;
155 151
 
156 152
 	// Address1.
157
-	if ( $address1 = give_get_meta( $object_id, '_give_donor_billing_address1', true ) ) {
153
+	if ($address1 = give_get_meta($object_id, '_give_donor_billing_address1', true)) {
158 154
 		$donor_data['address']['line1'] = $address1;
159 155
 	}
160 156
 
161 157
 	// Address2.
162
-	if ( $address2 = give_get_meta( $object_id, '_give_donor_billing_address2', true ) ) {
158
+	if ($address2 = give_get_meta($object_id, '_give_donor_billing_address2', true)) {
163 159
 		$donor_data['address']['line2'] = $address2;
164 160
 	}
165 161
 
166 162
 	// City.
167
-	if ( $city = give_get_meta( $object_id, '_give_donor_billing_city', true ) ) {
163
+	if ($city = give_get_meta($object_id, '_give_donor_billing_city', true)) {
168 164
 		$donor_data['address']['city'] = $city;
169 165
 	}
170 166
 
171 167
 	// Zip.
172
-	if ( $zip = give_get_meta( $object_id, '_give_donor_billing_zip', true ) ) {
168
+	if ($zip = give_get_meta($object_id, '_give_donor_billing_zip', true)) {
173 169
 		$donor_data['address']['zip'] = $zip;
174 170
 	}
175 171
 
176 172
 	// State.
177
-	if ( $state = give_get_meta( $object_id, '_give_donor_billing_state', true ) ) {
173
+	if ($state = give_get_meta($object_id, '_give_donor_billing_state', true)) {
178 174
 		$donor_data['address']['state'] = $state;
179 175
 	}
180 176
 
181 177
 	// Country.
182
-	if ( $country = give_get_meta( $object_id, '_give_donor_billing_country', true ) ) {
178
+	if ($country = give_get_meta($object_id, '_give_donor_billing_country', true)) {
183 179
 		$donor_data['address']['country'] = $country;
184 180
 	}
185 181
 
186
-	$meta_value['user_info'] = maybe_unserialize( $donor_data );
182
+	$meta_value['user_info'] = maybe_unserialize($donor_data);
187 183
 
188
-	Give_Cache::set_db_query( $cache_key, $meta_value );
184
+	Give_Cache::set_db_query($cache_key, $meta_value);
189 185
 
190 186
 	return $meta_value;
191 187
 }
@@ -209,37 +205,37 @@  discard block
 block discarded – undo
209 205
  *
210 206
  * @return mixed
211 207
  */
212
-function _give_20_bc_saving_old_payment_meta( $check, $object_id, $meta_key, $meta_value, $prev_value ) {
208
+function _give_20_bc_saving_old_payment_meta($check, $object_id, $meta_key, $meta_value, $prev_value) {
213 209
 	// Bailout.
214 210
 	if (
215
-		'give_payment' !== get_post_type( $object_id ) ||
216
-		! in_array( $meta_key, array(
211
+		'give_payment' !== get_post_type($object_id) ||
212
+		! in_array($meta_key, array(
217 213
 			'_give_payment_meta',
218 214
 			'_give_payment_user_email',
219 215
 			'_give_payment_customer_id',
220 216
 			'give_payment_user_ip',
221
-		) )
217
+		))
222 218
 	) {
223 219
 		return $check;
224 220
 	}
225 221
 
226
-	if ( '_give_payment_meta' === $meta_key ) {
227
-		_give_20_bc_split_and_save_give_payment_meta( $object_id, $meta_value );
228
-	} elseif ( '_give_payment_user_email' === $meta_key ) {
229
-		give_update_meta( $object_id, '_give_payment_donor_email', $meta_value );
222
+	if ('_give_payment_meta' === $meta_key) {
223
+		_give_20_bc_split_and_save_give_payment_meta($object_id, $meta_value);
224
+	} elseif ('_give_payment_user_email' === $meta_key) {
225
+		give_update_meta($object_id, '_give_payment_donor_email', $meta_value);
230 226
 		$check = true;
231
-	} elseif ( '_give_payment_customer_id' === $meta_key ) {
232
-		give_update_meta( $object_id, '_give_payment_donor_id', $meta_value );
227
+	} elseif ('_give_payment_customer_id' === $meta_key) {
228
+		give_update_meta($object_id, '_give_payment_donor_id', $meta_value);
233 229
 		$check = true;
234
-	} elseif ( 'give_payment_user_ip' === $meta_key ) {
235
-		give_update_meta( $object_id, '_give_payment_donor_ip', $meta_value );
230
+	} elseif ('give_payment_user_ip' === $meta_key) {
231
+		give_update_meta($object_id, '_give_payment_donor_ip', $meta_value);
236 232
 		$check = true;
237 233
 	}
238 234
 
239 235
 	return $check;
240 236
 }
241 237
 
242
-add_filter( 'update_post_metadata', '_give_20_bc_saving_old_payment_meta', 10, 5 );
238
+add_filter('update_post_metadata', '_give_20_bc_saving_old_payment_meta', 10, 5);
243 239
 
244 240
 
245 241
 /**
@@ -254,7 +250,7 @@  discard block
 block discarded – undo
254 250
  *
255 251
  * @return mixed
256 252
  */
257
-function _give_20_bc_get_old_payment_meta( $check, $object_id, $meta_key, $single ) {
253
+function _give_20_bc_get_old_payment_meta($check, $object_id, $meta_key, $single) {
258 254
 	global $wpdb;
259 255
 
260 256
 	// Deprecated meta keys.
@@ -265,32 +261,31 @@  discard block
 block discarded – undo
265 261
 	);
266 262
 
267 263
 	// Add _give_payment_meta to backward compatibility
268
-	if ( ! give_has_upgrade_completed( 'v20_upgrades_payment_metadata' ) ) {
264
+	if ( ! give_has_upgrade_completed('v20_upgrades_payment_metadata')) {
269 265
 		$old_meta_keys[] = '_give_payment_meta';
270 266
 	}
271 267
 
272 268
 	// Bailout.
273 269
 	if (
274
-		'give_payment' !== get_post_type( $object_id ) ||
275
-		! in_array( $meta_key, $old_meta_keys )
270
+		'give_payment' !== get_post_type($object_id) ||
271
+		! in_array($meta_key, $old_meta_keys)
276 272
 	) {
277 273
 		return $check;
278 274
 	}
279 275
 
280 276
 	$cache_key = "{$meta_key}_{$object_id}";
281
-	$check     = Give_Cache::get_db_query( $cache_key );
277
+	$check     = Give_Cache::get_db_query($cache_key);
282 278
 
283
-	if ( is_null( $check ) ) {
284
-		switch ( $meta_key ) {
279
+	if (is_null($check)) {
280
+		switch ($meta_key) {
285 281
 
286 282
 			// Handle old meta keys.
287 283
 			case '_give_payment_meta':
288
-				remove_filter( 'get_post_metadata', '_give_20_bc_get_old_payment_meta' );
284
+				remove_filter('get_post_metadata', '_give_20_bc_get_old_payment_meta');
289 285
 
290 286
 				// if ( $meta_value = give_get_meta( $object_id, '_give_payment_meta' ) ) {
291
-				$meta_value = ! empty( $meta_value ) ?
292
-					current( $meta_value ) :
293
-					(array) maybe_unserialize(
287
+				$meta_value = ! empty($meta_value) ?
288
+					current($meta_value) : (array) maybe_unserialize(
294 289
 						$wpdb->get_var(
295 290
 							$wpdb->prepare(
296 291
 								"
@@ -304,44 +299,44 @@  discard block
 block discarded – undo
304 299
 							)
305 300
 						)
306 301
 					);
307
-				$check      = _give_20_bc_give_payment_meta_value( $object_id, $meta_value );
302
+				$check = _give_20_bc_give_payment_meta_value($object_id, $meta_value);
308 303
 				// }
309 304
 
310
-				add_filter( 'get_post_metadata', '_give_20_bc_get_old_payment_meta', 10, 5 );
305
+				add_filter('get_post_metadata', '_give_20_bc_get_old_payment_meta', 10, 5);
311 306
 
312 307
 				break;
313 308
 
314 309
 			case '_give_payment_customer_id':
315
-				if ( $donor_id = give_get_meta( $object_id, '_give_payment_donor_id', $single ) ) {
310
+				if ($donor_id = give_get_meta($object_id, '_give_payment_donor_id', $single)) {
316 311
 					$check = $donor_id;
317 312
 				}
318 313
 				break;
319 314
 
320 315
 			case '_give_payment_user_email':
321
-				if ( $donor_email = give_get_meta( $object_id, '_give_payment_donor_email', $single ) ) {
316
+				if ($donor_email = give_get_meta($object_id, '_give_payment_donor_email', $single)) {
322 317
 					$check = $donor_email;
323 318
 				}
324 319
 				break;
325 320
 
326 321
 			case '_give_payment_user_ip':
327
-				if ( $donor_ip = give_get_meta( $object_id, '_give_payment_donor_ip', $single ) ) {
322
+				if ($donor_ip = give_get_meta($object_id, '_give_payment_donor_ip', $single)) {
328 323
 					$check = $donor_ip;
329 324
 				}
330 325
 				break;
331 326
 		}// End switch().
332 327
 
333
-		Give_Cache::set_db_query( $cache_key, $check );
328
+		Give_Cache::set_db_query($cache_key, $check);
334 329
 	}
335 330
 
336 331
 	// Put result in an array on zero index.
337
-	if ( ! is_null( $check ) ) {
338
-		$check = array( $check );
332
+	if ( ! is_null($check)) {
333
+		$check = array($check);
339 334
 	}
340 335
 
341 336
 	return $check;
342 337
 }
343 338
 
344
-add_filter( 'get_post_metadata', '_give_20_bc_get_old_payment_meta', 10, 5 );
339
+add_filter('get_post_metadata', '_give_20_bc_get_old_payment_meta', 10, 5);
345 340
 
346 341
 
347 342
 /**
@@ -356,9 +351,9 @@  discard block
 block discarded – undo
356 351
  *
357 352
  * @return mixed
358 353
  */
359
-function _give_20_bc_get_new_payment_meta( $check, $object_id, $meta_key, $single ) {
354
+function _give_20_bc_get_new_payment_meta($check, $object_id, $meta_key, $single) {
360 355
 	// Bailout: do not apply backward compatibility if upgrade done.
361
-	if ( give_has_upgrade_completed( 'v20_upgrades_payment_metadata' ) ) {
356
+	if (give_has_upgrade_completed('v20_upgrades_payment_metadata')) {
362 357
 		return $check;
363 358
 	}
364 359
 
@@ -380,26 +375,26 @@  discard block
 block discarded – undo
380 375
 	);
381 376
 
382 377
 	// metadata_exists fx will cause of firing get_post_metadata filter again so remove it to prevent infinite loop.
383
-	remove_filter( 'get_post_metadata', '_give_20_bc_get_new_payment_meta' );
378
+	remove_filter('get_post_metadata', '_give_20_bc_get_new_payment_meta');
384 379
 
385 380
 	// Bailout.
386 381
 	if (
387
-		'give_payment' !== get_post_type( $object_id ) ||
388
-		! in_array( $meta_key, $new_meta_keys ) ||
389
-		metadata_exists( 'post', $object_id, $meta_key )
382
+		'give_payment' !== get_post_type($object_id) ||
383
+		! in_array($meta_key, $new_meta_keys) ||
384
+		metadata_exists('post', $object_id, $meta_key)
390 385
 	) {
391
-		add_filter( 'get_post_metadata', '_give_20_bc_get_new_payment_meta', 10, 5 );
386
+		add_filter('get_post_metadata', '_give_20_bc_get_new_payment_meta', 10, 5);
392 387
 
393 388
 		return $check;
394 389
 	}
395 390
 
396
-	add_filter( 'get_post_metadata', '_give_20_bc_get_new_payment_meta', 10, 5 );
391
+	add_filter('get_post_metadata', '_give_20_bc_get_new_payment_meta', 10, 5);
397 392
 
398 393
 	$cache_key = "{$meta_key}_{$object_id}";
399
-	$check    = Give_Cache::get_db_query( $cache_key );
394
+	$check = Give_Cache::get_db_query($cache_key);
400 395
 
401
-	if ( is_null( $check ) ) {
402
-		switch ( $meta_key ) {
396
+	if (is_null($check)) {
397
+		switch ($meta_key) {
403 398
 
404 399
 			// Handle new meta keys.
405 400
 			case '_give_payment_donor_id':
@@ -442,9 +437,9 @@  discard block
 block discarded – undo
442 437
 			case '_give_donor_billing_country':
443 438
 			case '_give_payment_date':
444 439
 			case '_give_payment_currency':
445
-				$donation_meta = Give_Cache::get_db_query( "_give_payment_meta_{$object_id}" );
440
+				$donation_meta = Give_Cache::get_db_query("_give_payment_meta_{$object_id}");
446 441
 
447
-				if ( is_null( $donation_meta ) ) {
442
+				if (is_null($donation_meta)) {
448 443
 					$donation_meta = $wpdb->get_var(
449 444
 						$wpdb->prepare(
450 445
 							"SELECT meta_value FROM {$wpdb->postmeta} WHERE post_id=%d AND meta_key=%s",
@@ -452,51 +447,51 @@  discard block
 block discarded – undo
452 447
 							'_give_payment_meta'
453 448
 						)
454 449
 					);
455
-					$donation_meta = maybe_unserialize( $donation_meta );
456
-					$donation_meta = ! is_array( $donation_meta ) ? array() : $donation_meta;
457
-					Give_Cache::set_db_query( "_give_payment_meta_{$object_id}", $donation_meta );
450
+					$donation_meta = maybe_unserialize($donation_meta);
451
+					$donation_meta = ! is_array($donation_meta) ? array() : $donation_meta;
452
+					Give_Cache::set_db_query("_give_payment_meta_{$object_id}", $donation_meta);
458 453
 				}
459 454
 
460 455
 				// Get results.
461
-				if ( empty( $donation_meta ) ) {
456
+				if (empty($donation_meta)) {
462 457
 					$check = '';
463
-				} elseif ( in_array( $meta_key, array( '_give_payment_date', '_give_payment_currency' ) ) ) {
464
-					$payment_meta_key = str_replace( '_give_payment_', '', $meta_key );
458
+				} elseif (in_array($meta_key, array('_give_payment_date', '_give_payment_currency'))) {
459
+					$payment_meta_key = str_replace('_give_payment_', '', $meta_key);
465 460
 
466
-					if ( isset( $donation_meta[ $payment_meta_key ] ) ) {
467
-						$check = $donation_meta[ $payment_meta_key ];
461
+					if (isset($donation_meta[$payment_meta_key])) {
462
+						$check = $donation_meta[$payment_meta_key];
468 463
 					}
469 464
 				} else {
470
-					$payment_meta_key = str_replace( '_give_donor_billing_', '', $meta_key );
465
+					$payment_meta_key = str_replace('_give_donor_billing_', '', $meta_key);
471 466
 
472
-					switch ( $payment_meta_key ) {
467
+					switch ($payment_meta_key) {
473 468
 						case 'address1':
474
-							if ( isset( $donation_meta['user_info']['address']['line1'] ) ) {
469
+							if (isset($donation_meta['user_info']['address']['line1'])) {
475 470
 								$check = $donation_meta['user_info']['address']['line1'];
476 471
 							}
477 472
 							break;
478 473
 
479 474
 						case 'address2':
480
-							if ( isset( $donation_meta['user_info']['address']['line2'] ) ) {
475
+							if (isset($donation_meta['user_info']['address']['line2'])) {
481 476
 								$check = $donation_meta['user_info']['address']['line2'];
482 477
 							}
483 478
 							break;
484 479
 
485 480
 						case 'first_name':
486
-							if ( isset( $donation_meta['user_info']['first_name'] ) ) {
481
+							if (isset($donation_meta['user_info']['first_name'])) {
487 482
 								$check = $donation_meta['user_info']['first_name'];
488 483
 							}
489 484
 							break;
490 485
 
491 486
 						case 'last_name':
492
-							if ( isset( $donation_meta['user_info']['last_name'] ) ) {
487
+							if (isset($donation_meta['user_info']['last_name'])) {
493 488
 								$check = $donation_meta['user_info']['last_name'];
494 489
 							}
495 490
 							break;
496 491
 
497 492
 						default:
498
-							if ( isset( $donation_meta['user_info']['address'][ $payment_meta_key ] ) ) {
499
-								$check = $donation_meta['user_info']['address'][ $payment_meta_key ];
493
+							if (isset($donation_meta['user_info']['address'][$payment_meta_key])) {
494
+								$check = $donation_meta['user_info']['address'][$payment_meta_key];
500 495
 							}
501 496
 					}
502 497
 				}
@@ -505,19 +500,19 @@  discard block
 block discarded – undo
505 500
 		}// End switch().
506 501
 
507 502
 		// Set cache.
508
-		Give_Cache::set_db_query( $cache_key, $check );
503
+		Give_Cache::set_db_query($cache_key, $check);
509 504
 	}
510 505
 
511 506
 	// Put result in an array on zero index.
512
-	if ( ! $single ) {
513
-		$check = array( $check );
507
+	if ( ! $single) {
508
+		$check = array($check);
514 509
 	}
515 510
 
516 511
 
517 512
 	return $check;
518 513
 }
519 514
 
520
-add_filter( 'get_post_metadata', '_give_20_bc_get_new_payment_meta', 10, 5 );
515
+add_filter('get_post_metadata', '_give_20_bc_get_new_payment_meta', 10, 5);
521 516
 
522 517
 
523 518
 /**
@@ -529,9 +524,9 @@  discard block
 block discarded – undo
529 524
  *
530 525
  * @return void
531 526
  */
532
-function _give_20_bc_support_deprecated_meta_key_query( $query ) {
527
+function _give_20_bc_support_deprecated_meta_key_query($query) {
533 528
 	// Bailout.
534
-	if ( give_has_upgrade_completed( 'v20_upgrades_payment_metadata' ) ) {
529
+	if (give_has_upgrade_completed('v20_upgrades_payment_metadata')) {
535 530
 		return;
536 531
 	}
537 532
 
@@ -541,21 +536,21 @@  discard block
 block discarded – undo
541 536
 		// '_give_payment_user_ip'     => '_give_payment_donor_ip',
542 537
 	);
543 538
 
544
-	$deprecated_meta_keys = array_flip( $new_meta_keys );
539
+	$deprecated_meta_keys = array_flip($new_meta_keys);
545 540
 
546 541
 	// Set meta keys.
547 542
 	$meta_keys = array();
548 543
 
549 544
 
550 545
 	// Bailout.
551
-	if ( ! empty( $query->query_vars['meta_key'] ) ) {
552
-		if ( in_array( $query->query_vars['meta_key'], $new_meta_keys ) ) {
546
+	if ( ! empty($query->query_vars['meta_key'])) {
547
+		if (in_array($query->query_vars['meta_key'], $new_meta_keys)) {
553 548
 			$meta_keys = $deprecated_meta_keys;
554
-		} elseif ( in_array( $query->query_vars['meta_key'], $deprecated_meta_keys ) ) {
549
+		} elseif (in_array($query->query_vars['meta_key'], $deprecated_meta_keys)) {
555 550
 			$meta_keys = $new_meta_keys;
556 551
 		}
557 552
 
558
-		if ( ! empty( $meta_keys ) ) {
553
+		if ( ! empty($meta_keys)) {
559 554
 			// Set meta_query
560 555
 			$query->set(
561 556
 				'meta_query',
@@ -566,35 +561,35 @@  discard block
 block discarded – undo
566 561
 						'value' => $query->query_vars['meta_value'],
567 562
 					),
568 563
 					array(
569
-						'key'   => $meta_keys[ $query->query_vars['meta_key'] ],
564
+						'key'   => $meta_keys[$query->query_vars['meta_key']],
570 565
 						'value' => $query->query_vars['meta_value'],
571 566
 					),
572 567
 				)
573 568
 			);
574 569
 
575 570
 			// Unset single meta query.
576
-			unset( $query->query_vars['meta_key'] );
577
-			unset( $query->query_vars['meta_value'] );
571
+			unset($query->query_vars['meta_key']);
572
+			unset($query->query_vars['meta_value']);
578 573
 		}
579 574
 	} elseif (
580
-		! empty( $query->query_vars['meta_query'] ) &&
581
-		( 1 === count( $query->query_vars['meta_query'] ) )
575
+		! empty($query->query_vars['meta_query']) &&
576
+		(1 === count($query->query_vars['meta_query']))
582 577
 	) {
583
-		$meta_query = current( $query->query_vars['meta_query'] );
578
+		$meta_query = current($query->query_vars['meta_query']);
584 579
 
585
-		if ( empty( $meta_query[0]['key'] ) ) {
580
+		if (empty($meta_query[0]['key'])) {
586 581
 			return;
587 582
 		}
588 583
 
589
-		if ( in_array( $meta_query[0]['key'], $new_meta_keys ) ) {
584
+		if (in_array($meta_query[0]['key'], $new_meta_keys)) {
590 585
 			$meta_keys = $deprecated_meta_keys;
591
-		} elseif ( in_array( $meta_query[0]['key'], $deprecated_meta_keys ) ) {
586
+		} elseif (in_array($meta_query[0]['key'], $deprecated_meta_keys)) {
592 587
 			$meta_keys = $new_meta_keys;
593 588
 		} else {
594 589
 			return;
595 590
 		}
596 591
 
597
-		if ( ! empty( $meta_keys ) ) {
592
+		if ( ! empty($meta_keys)) {
598 593
 			// Set meta_query
599 594
 			$query->set(
600 595
 				'meta_query',
@@ -605,7 +600,7 @@  discard block
 block discarded – undo
605 600
 						'value' => $query->query_vars['meta_query'][0]['value'],
606 601
 					),
607 602
 					array(
608
-						'key'   => $meta_keys[ $query->query_vars['meta_query'][0]['key'] ],
603
+						'key'   => $meta_keys[$query->query_vars['meta_query'][0]['key']],
609 604
 						'value' => $query->query_vars['meta_query'][0]['value'],
610 605
 					),
611 606
 				)
@@ -614,7 +609,7 @@  discard block
 block discarded – undo
614 609
 	}
615 610
 }
616 611
 
617
-add_action( 'pre_get_posts', '_give_20_bc_support_deprecated_meta_key_query' );
612
+add_action('pre_get_posts', '_give_20_bc_support_deprecated_meta_key_query');
618 613
 
619 614
 
620 615
 /**
@@ -627,49 +622,49 @@  discard block
 block discarded – undo
627 622
  * @param Give_Payment $payment
628 623
  * @param string       $key
629 624
  */
630
-function _give_20_bc_payment_save( $payment, $key ) {
625
+function _give_20_bc_payment_save($payment, $key) {
631 626
 	// Bailout.
632
-	if ( ! give_has_upgrade_completed( 'v20_upgrades_payment_metadata' ) ) {
627
+	if ( ! give_has_upgrade_completed('v20_upgrades_payment_metadata')) {
633 628
 		return;
634 629
 	}
635 630
 
636
-	switch ( $key ) {
631
+	switch ($key) {
637 632
 		case 'user_info':
638
-			if ( empty( $payment->user_info ) ) {
633
+			if (empty($payment->user_info)) {
639 634
 				// Bailout.
640 635
 				break;
641
-			} elseif ( is_string( $payment->user_info ) ) {
636
+			} elseif (is_string($payment->user_info)) {
642 637
 				// Check if value serialize.
643
-				$payment->user_info = maybe_unserialize( $payment->user_info );
638
+				$payment->user_info = maybe_unserialize($payment->user_info);
644 639
 			}
645 640
 
646 641
 
647 642
 			// Save first name.
648
-			if ( isset( $payment->user_info['first_name'] ) ) {
649
-				$payment->update_meta( '_give_donor_billing_first_name', $payment->user_info['first_name'] );
643
+			if (isset($payment->user_info['first_name'])) {
644
+				$payment->update_meta('_give_donor_billing_first_name', $payment->user_info['first_name']);
650 645
 			}
651 646
 
652 647
 
653 648
 			// Save last name.
654
-			if ( isset( $payment->user_info['last_name'] ) ) {
655
-				$payment->update_meta( '_give_donor_billing_last_name', $payment->user_info['last_name'] );
649
+			if (isset($payment->user_info['last_name'])) {
650
+				$payment->update_meta('_give_donor_billing_last_name', $payment->user_info['last_name']);
656 651
 			}
657 652
 
658 653
 
659 654
 			// Save address.
660
-			if ( ! empty( $payment->user_info['address'] ) ) {
661
-				foreach ( $payment->user_info['address'] as $address_name => $address ) {
662
-					switch ( $address_name ) {
655
+			if ( ! empty($payment->user_info['address'])) {
656
+				foreach ($payment->user_info['address'] as $address_name => $address) {
657
+					switch ($address_name) {
663 658
 						case 'line1':
664
-							$payment->update_meta( '_give_donor_billing_address1', $address );
659
+							$payment->update_meta('_give_donor_billing_address1', $address);
665 660
 							break;
666 661
 
667 662
 						case 'line2':
668
-							$payment->update_meta( '_give_donor_billing_address2', $address );
663
+							$payment->update_meta('_give_donor_billing_address2', $address);
669 664
 							break;
670 665
 
671 666
 						default:
672
-							$payment->update_meta( "_give_donor_billing_{$address_name}", $address );
667
+							$payment->update_meta("_give_donor_billing_{$address_name}", $address);
673 668
 					}
674 669
 				}
675 670
 			}
@@ -678,7 +673,7 @@  discard block
 block discarded – undo
678 673
 	}
679 674
 }
680 675
 
681
-add_action( 'give_payment_save', '_give_20_bc_payment_save', 10, 2 );
676
+add_action('give_payment_save', '_give_20_bc_payment_save', 10, 2);
682 677
 
683 678
 
684 679
 /**
@@ -691,16 +686,16 @@  discard block
 block discarded – undo
691 686
  *
692 687
  * @return mixed
693 688
  */
694
-function __give_20_bc_flush_cache( $check, $object_id ) {
689
+function __give_20_bc_flush_cache($check, $object_id) {
695 690
 	if (
696
-		! give_has_upgrade_completed( 'v20_move_metadata_into_new_table' ) &&
697
-		'give_payment' === get_post_type( $object_id )
691
+		! give_has_upgrade_completed('v20_move_metadata_into_new_table') &&
692
+		'give_payment' === get_post_type($object_id)
698 693
 	) {
699
-		Give_Cache::delete_group( $object_id, 'give-donations' );
694
+		Give_Cache::delete_group($object_id, 'give-donations');
700 695
 	}
701 696
 
702 697
 	return $check;
703 698
 }
704 699
 
705
-add_action( 'update_post_metadata', '__give_20_bc_flush_cache', 9999, 2 );
706
-add_action( 'add_post_metadata', '__give_20_bc_flush_cache', 9999, 2 );
700
+add_action('update_post_metadata', '__give_20_bc_flush_cache', 9999, 2);
701
+add_action('add_post_metadata', '__give_20_bc_flush_cache', 9999, 2);
Please login to merge, or discard this patch.
includes/payments/class-payments-query.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	 * @since  1.0
108 108
 	 * @access public
109 109
 	 *
110
-	 * @param $query_var
110
+	 * @param string $query_var
111 111
 	 * @param $value
112 112
 	 */
113 113
 	public function __set( $query_var, $value ) {
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	 * @since  1.0
125 125
 	 * @access public
126 126
 	 *
127
-	 * @param $query_var
127
+	 * @param string $query_var
128 128
 	 */
129 129
 	public function __unset( $query_var ) {
130 130
 		unset( $this->args[ $query_var ] );
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
 	 * @param string   $order
469 469
 	 * @param WP_Query $query
470 470
 	 *
471
-	 * @return mixed
471
+	 * @return string
472 472
 	 */
473 473
 	public function custom_orderby( $order, $query ) {
474 474
 
Please login to merge, or discard this patch.
Spacing   +148 added lines, -148 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
 
@@ -66,10 +66,10 @@  discard block
 block discarded – undo
66 66
 	 *
67 67
 	 * @param  $args array The array of arguments that can be passed in and used for setting up this payment query.
68 68
 	 */
69
-	public function __construct( $args = array() ) {
69
+	public function __construct($args = array()) {
70 70
 		$defaults = array(
71 71
 			'output'          => 'payments',
72
-			'post_type'       => array( 'give_payment' ),
72
+			'post_type'       => array('give_payment'),
73 73
 			'start_date'      => false,
74 74
 			'end_date'        => false,
75 75
 			'number'          => 20,
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 			'count'           => false,
97 97
 		);
98 98
 
99
-		$this->args = $this->_args = wp_parse_args( $args, $defaults );
99
+		$this->args = $this->_args = wp_parse_args($args, $defaults);
100 100
 
101 101
 		$this->init();
102 102
 	}
@@ -110,11 +110,11 @@  discard block
 block discarded – undo
110 110
 	 * @param $query_var
111 111
 	 * @param $value
112 112
 	 */
113
-	public function __set( $query_var, $value ) {
114
-		if ( in_array( $query_var, array( 'meta_query', 'tax_query' ) ) ) {
115
-			$this->args[ $query_var ][] = $value;
113
+	public function __set($query_var, $value) {
114
+		if (in_array($query_var, array('meta_query', 'tax_query'))) {
115
+			$this->args[$query_var][] = $value;
116 116
 		} else {
117
-			$this->args[ $query_var ] = $value;
117
+			$this->args[$query_var] = $value;
118 118
 		}
119 119
 	}
120 120
 
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
 	 *
127 127
 	 * @param $query_var
128 128
 	 */
129
-	public function __unset( $query_var ) {
130
-		unset( $this->args[ $query_var ] );
129
+	public function __unset($query_var) {
130
+		unset($this->args[$query_var]);
131 131
 	}
132 132
 
133 133
 	/**
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 		$this->give_forms();
168 168
 		$this->gateway_filter();
169 169
 
170
-		add_filter( 'posts_orderby', array( $this, 'custom_orderby' ), 10, 2 );
170
+		add_filter('posts_orderby', array($this, 'custom_orderby'), 10, 2);
171 171
 
172 172
 		/**
173 173
 		 * Fires after setup filters.
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 		 *
177 177
 		 * @param Give_Payments_Query $this Payments query object.
178 178
 		 */
179
-		do_action( 'give_pre_get_payments', $this );
179
+		do_action('give_pre_get_payments', $this);
180 180
 	}
181 181
 
182 182
 	/**
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 	 * @access private
187 187
 	 */
188 188
 	private function unset_filters() {
189
-		remove_filter( 'posts_orderby', array( $this, 'custom_orderby' ) );
189
+		remove_filter('posts_orderby', array($this, 'custom_orderby'));
190 190
 
191 191
 		/**
192 192
 		 * Fires after retrieving payments.
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 		 *
196 196
 		 * @param Give_Payments_Query $this Payments query object.
197 197
 		 */
198
-		do_action( 'give_post_get_payments', $this );
198
+		do_action('give_post_get_payments', $this);
199 199
 	}
200 200
 
201 201
 
@@ -212,11 +212,11 @@  discard block
 block discarded – undo
212 212
 	 * @return array
213 213
 	 */
214 214
 	public function get_payments() {
215
-		$cache_key      = Give_Cache::get_key( 'give_payment_query', $this->args, false );
216
-		$this->payments = Give_Cache::get_db_query( $cache_key );
215
+		$cache_key      = Give_Cache::get_key('give_payment_query', $this->args, false);
216
+		$this->payments = Give_Cache::get_db_query($cache_key);
217 217
 
218 218
 		// Return cached result.
219
-		if ( ! is_null( $this->payments ) ) {
219
+		if ( ! is_null($this->payments)) {
220 220
 			return $this->payments;
221 221
 		}
222 222
 
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 		// Modify the query/query arguments before we retrieve payments.
225 225
 		$this->set_filters();
226 226
 
227
-		$query          = new WP_Query( $this->args );
227
+		$query          = new WP_Query($this->args);
228 228
 		$this->payments = array();
229 229
 
230 230
 		$custom_output = array(
@@ -232,24 +232,24 @@  discard block
 block discarded – undo
232 232
 			'give_payments',
233 233
 		);
234 234
 
235
-		if ( ! in_array( $this->args['output'], $custom_output ) ) {
235
+		if ( ! in_array($this->args['output'], $custom_output)) {
236 236
 			return $query->posts;
237 237
 		}
238 238
 
239
-		if ( $query->have_posts() ) {
240
-			while ( $query->have_posts() ) {
239
+		if ($query->have_posts()) {
240
+			while ($query->have_posts()) {
241 241
 				$query->the_post();
242 242
 
243 243
 				$payment_id = get_post()->ID;
244
-				$payment    = new Give_Payment( $payment_id );
244
+				$payment    = new Give_Payment($payment_id);
245 245
 
246
-				$this->payments[] = apply_filters( 'give_payment', $payment, $payment_id, $this );
246
+				$this->payments[] = apply_filters('give_payment', $payment, $payment_id, $this);
247 247
 			}
248 248
 
249 249
 			wp_reset_postdata();
250 250
 		}
251 251
 
252
-		Give_Cache::set_db_query( $cache_key, $this->payments );
252
+		Give_Cache::set_db_query($cache_key, $this->payments);
253 253
 
254 254
 		// Remove query filters after we retrieve payments.
255 255
 		$this->unset_filters();
@@ -268,31 +268,31 @@  discard block
 block discarded – undo
268 268
 	public function get_payment_by_group() {
269 269
 		global $wpdb;
270 270
 
271
-		$allowed_groups = array( 'post_status' );
271
+		$allowed_groups = array('post_status');
272 272
 		$result         = array();
273 273
 
274 274
 
275
-		if ( in_array( $this->args['group_by'], $allowed_groups ) ) {
275
+		if (in_array($this->args['group_by'], $allowed_groups)) {
276 276
 			// Set only count in result.
277
-			if ( $this->args['count'] ) {
277
+			if ($this->args['count']) {
278 278
 
279 279
 				$this->set_filters();
280 280
 
281
-				$new_results = $wpdb->get_results( $this->get_sql(), ARRAY_N );
281
+				$new_results = $wpdb->get_results($this->get_sql(), ARRAY_N);
282 282
 
283 283
 				$this->unset_filters();
284 284
 
285
-				foreach ( $new_results as $results ) {
286
-					$result[ $results[0] ] = $results[1];
285
+				foreach ($new_results as $results) {
286
+					$result[$results[0]] = $results[1];
287 287
 				}
288 288
 
289
-				switch ( $this->args['group_by'] ) {
289
+				switch ($this->args['group_by']) {
290 290
 					case 'post_status':
291 291
 
292 292
 						/* @var Give_Payment $donation */
293
-						foreach ( give_get_payment_status_keys() as $status ) {
294
-							if ( ! isset( $result[ $status ] ) ) {
295
-								$result[ $status ] = 0;
293
+						foreach (give_get_payment_status_keys() as $status) {
294
+							if ( ! isset($result[$status])) {
295
+								$result[$status] = 0;
296 296
 							}
297 297
 						}
298 298
 
@@ -302,8 +302,8 @@  discard block
 block discarded – undo
302 302
 				$donations = $this->get_payments();
303 303
 
304 304
 				/* @var $donation Give_Payment */
305
-				foreach ( $donations as $donation ) {
306
-					$result[ $donation->{$this->args['group_by']} ][] = $donation;
305
+				foreach ($donations as $donation) {
306
+					$result[$donation->{$this->args['group_by']}][] = $donation;
307 307
 				}
308 308
 			}
309 309
 		}
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 		 *
315 315
 		 * @since 1.8.17
316 316
 		 */
317
-		return apply_filters( 'give_get_payment_by_group', $result, $this );
317
+		return apply_filters('give_get_payment_by_group', $result, $this);
318 318
 	}
319 319
 
320 320
 	/**
@@ -326,29 +326,29 @@  discard block
 block discarded – undo
326 326
 	 * @return void
327 327
 	 */
328 328
 	public function date_filter_pre() {
329
-		if ( ! ( $this->args['start_date'] || $this->args['end_date'] ) ) {
329
+		if ( ! ($this->args['start_date'] || $this->args['end_date'])) {
330 330
 			return;
331 331
 		}
332 332
 
333
-		$this->setup_dates( $this->args['start_date'], $this->args['end_date'] );
334
-		$is_start_date = property_exists( __CLASS__, 'start_date' );
335
-		$is_end_date   = property_exists( __CLASS__, 'end_date' );
333
+		$this->setup_dates($this->args['start_date'], $this->args['end_date']);
334
+		$is_start_date = property_exists(__CLASS__, 'start_date');
335
+		$is_end_date   = property_exists(__CLASS__, 'end_date');
336 336
 
337
-		if ( $is_start_date || $is_end_date ) {
337
+		if ($is_start_date || $is_end_date) {
338 338
 			$date_query = array();
339 339
 
340
-			if ( $is_start_date && ! is_wp_error( $this->start_date ) ) {
341
-				$date_query['after'] = date( 'Y-m-d H:i:s', $this->start_date );
340
+			if ($is_start_date && ! is_wp_error($this->start_date)) {
341
+				$date_query['after'] = date('Y-m-d H:i:s', $this->start_date);
342 342
 			}
343 343
 
344
-			if ( $is_end_date && ! is_wp_error( $this->end_date ) ) {
345
-				$date_query['before'] = date( 'Y-m-d H:i:s', $this->end_date );
344
+			if ($is_end_date && ! is_wp_error($this->end_date)) {
345
+				$date_query['before'] = date('Y-m-d H:i:s', $this->end_date);
346 346
 			}
347 347
 
348 348
 			// Include Start Date and End Date while querying.
349 349
 			$date_query['inclusive'] = true;
350 350
 
351
-			$this->__set( 'date_query', $date_query );
351
+			$this->__set('date_query', $date_query);
352 352
 
353 353
 		}
354 354
 
@@ -363,12 +363,12 @@  discard block
 block discarded – undo
363 363
 	 * @return void
364 364
 	 */
365 365
 	public function status() {
366
-		if ( ! isset( $this->args['status'] ) ) {
366
+		if ( ! isset($this->args['status'])) {
367 367
 			return;
368 368
 		}
369 369
 
370
-		$this->__set( 'post_status', $this->args['status'] );
371
-		$this->__unset( 'status' );
370
+		$this->__set('post_status', $this->args['status']);
371
+		$this->__unset('status');
372 372
 	}
373 373
 
374 374
 	/**
@@ -380,12 +380,12 @@  discard block
 block discarded – undo
380 380
 	 * @return void
381 381
 	 */
382 382
 	public function page() {
383
-		if ( ! isset( $this->args['page'] ) ) {
383
+		if ( ! isset($this->args['page'])) {
384 384
 			return;
385 385
 		}
386 386
 
387
-		$this->__set( 'paged', $this->args['page'] );
388
-		$this->__unset( 'page' );
387
+		$this->__set('paged', $this->args['page']);
388
+		$this->__unset('page');
389 389
 	}
390 390
 
391 391
 	/**
@@ -398,17 +398,17 @@  discard block
 block discarded – undo
398 398
 	 */
399 399
 	public function per_page() {
400 400
 
401
-		if ( ! isset( $this->args['number'] ) ) {
401
+		if ( ! isset($this->args['number'])) {
402 402
 			return;
403 403
 		}
404 404
 
405
-		if ( $this->args['number'] == - 1 ) {
406
-			$this->__set( 'nopaging', true );
405
+		if ($this->args['number'] == - 1) {
406
+			$this->__set('nopaging', true);
407 407
 		} else {
408
-			$this->__set( 'posts_per_page', $this->args['number'] );
408
+			$this->__set('posts_per_page', $this->args['number']);
409 409
 		}
410 410
 
411
-		$this->__unset( 'number' );
411
+		$this->__unset('number');
412 412
 	}
413 413
 
414 414
 	/**
@@ -420,12 +420,12 @@  discard block
 block discarded – undo
420 420
 	 * @return void
421 421
 	 */
422 422
 	public function month() {
423
-		if ( ! isset( $this->args['month'] ) ) {
423
+		if ( ! isset($this->args['month'])) {
424 424
 			return;
425 425
 		}
426 426
 
427
-		$this->__set( 'monthnum', $this->args['month'] );
428
-		$this->__unset( 'month' );
427
+		$this->__set('monthnum', $this->args['month']);
428
+		$this->__unset('month');
429 429
 	}
430 430
 
431 431
 	/**
@@ -437,23 +437,23 @@  discard block
 block discarded – undo
437 437
 	 * @return void
438 438
 	 */
439 439
 	public function orderby() {
440
-		switch ( $this->args['orderby'] ) {
440
+		switch ($this->args['orderby']) {
441 441
 			case 'amount':
442
-				$this->__set( 'orderby', 'meta_value_num' );
443
-				$this->__set( 'meta_key', '_give_payment_total' );
442
+				$this->__set('orderby', 'meta_value_num');
443
+				$this->__set('meta_key', '_give_payment_total');
444 444
 				break;
445 445
 
446 446
 			case 'status':
447
-				$this->__set( 'orderby', 'post_status' );
447
+				$this->__set('orderby', 'post_status');
448 448
 				break;
449 449
 
450 450
 			case 'donation_form':
451
-				$this->__set( 'orderby', 'meta_value' );
452
-				$this->__set( 'meta_key', '_give_payment_form_title' );
451
+				$this->__set('orderby', 'meta_value');
452
+				$this->__set('meta_key', '_give_payment_form_title');
453 453
 				break;
454 454
 
455 455
 			default:
456
-				$this->__set( 'orderby', $this->args['orderby'] );
456
+				$this->__set('orderby', $this->args['orderby']);
457 457
 				break;
458 458
 		}
459 459
 	}
@@ -470,19 +470,19 @@  discard block
 block discarded – undo
470 470
 	 *
471 471
 	 * @return mixed
472 472
 	 */
473
-	public function custom_orderby( $order, $query ) {
473
+	public function custom_orderby($order, $query) {
474 474
 
475
-		if ( ! empty( $query->query['post_type'] ) ) {
476
-			$post_types = is_array( $query->query['post_type'] ) ? $query->query['post_type'] : array( $query->query['post_type'] );
475
+		if ( ! empty($query->query['post_type'])) {
476
+			$post_types = is_array($query->query['post_type']) ? $query->query['post_type'] : array($query->query['post_type']);
477 477
 
478
-			if ( ! in_array( 'give_payment', $post_types ) || is_array( $query->query['orderby'] ) ) {
478
+			if ( ! in_array('give_payment', $post_types) || is_array($query->query['orderby'])) {
479 479
 				return $order;
480 480
 			}
481 481
 
482 482
 			global $wpdb;
483
-			switch ( $query->query['orderby'] ) {
483
+			switch ($query->query['orderby']) {
484 484
 				case 'post_status':
485
-					$order = $wpdb->posts . '.post_status ' . strtoupper( $query->query['order'] );
485
+					$order = $wpdb->posts.'.post_status '.strtoupper($query->query['order']);
486 486
 					break;
487 487
 			}
488 488
 		}
@@ -499,11 +499,11 @@  discard block
 block discarded – undo
499 499
 	 * @return void
500 500
 	 */
501 501
 	public function user() {
502
-		if ( is_null( $this->args['user'] ) ) {
502
+		if (is_null($this->args['user'])) {
503 503
 			return;
504 504
 		}
505 505
 
506
-		if ( is_numeric( $this->args['user'] ) ) {
506
+		if (is_numeric($this->args['user'])) {
507 507
 			$user_key = '_give_payment_donor_id';
508 508
 		} else {
509 509
 			$user_key = '_give_payment_donor_email';
@@ -525,16 +525,16 @@  discard block
 block discarded – undo
525 525
 	 * @return  void
526 526
 	 */
527 527
 	public function donor() {
528
-		if ( is_null( $this->args['donor'] ) || ! is_numeric( $this->args['donor'] ) ) {
528
+		if (is_null($this->args['donor']) || ! is_numeric($this->args['donor'])) {
529 529
 			return;
530 530
 		}
531 531
 
532 532
 		$donor_meta_type = Give()->donor_meta->meta_type;
533 533
 
534
-		$this->__set( 'meta_query', array(
534
+		$this->__set('meta_query', array(
535 535
 			'key'   => "_give_payment_{$donor_meta_type}_id",
536 536
 			'value' => (int) $this->args['donor'],
537
-		) );
537
+		));
538 538
 	}
539 539
 
540 540
 	/**
@@ -547,33 +547,33 @@  discard block
 block discarded – undo
547 547
 	 */
548 548
 	public function search() {
549 549
 
550
-		if ( ! isset( $this->args['s'] ) ) {
550
+		if ( ! isset($this->args['s'])) {
551 551
 			return;
552 552
 		}
553 553
 
554
-		$search = trim( $this->args['s'] );
554
+		$search = trim($this->args['s']);
555 555
 
556
-		if ( empty( $search ) ) {
556
+		if (empty($search)) {
557 557
 			return;
558 558
 		}
559 559
 
560
-		$is_email = is_email( $search ) || strpos( $search, '@' ) !== false;
561
-		$is_user  = strpos( $search, strtolower( 'user:' ) ) !== false;
560
+		$is_email = is_email($search) || strpos($search, '@') !== false;
561
+		$is_user  = strpos($search, strtolower('user:')) !== false;
562 562
 
563
-		if ( ! empty( $this->args['search_in_notes'] ) ) {
563
+		if ( ! empty($this->args['search_in_notes'])) {
564 564
 
565
-			$notes = give_get_payment_notes( 0, $search );
565
+			$notes = give_get_payment_notes(0, $search);
566 566
 
567
-			if ( ! empty( $notes ) ) {
567
+			if ( ! empty($notes)) {
568 568
 
569
-				$payment_ids = wp_list_pluck( (array) $notes, 'comment_post_ID' );
569
+				$payment_ids = wp_list_pluck((array) $notes, 'comment_post_ID');
570 570
 
571
-				$this->__set( 'post__in', $payment_ids );
571
+				$this->__set('post__in', $payment_ids);
572 572
 			}
573 573
 
574
-			$this->__unset( 's' );
574
+			$this->__unset('s');
575 575
 
576
-		} elseif ( $is_email || strlen( $search ) == 32 ) {
576
+		} elseif ($is_email || strlen($search) == 32) {
577 577
 
578 578
 			$key         = $is_email ? '_give_payment_donor_email' : '_give_payment_purchase_key';
579 579
 			$search_meta = array(
@@ -582,19 +582,19 @@  discard block
 block discarded – undo
582 582
 				'compare' => 'LIKE',
583 583
 			);
584 584
 
585
-			$this->__set( 'meta_query', $search_meta );
586
-			$this->__unset( 's' );
585
+			$this->__set('meta_query', $search_meta);
586
+			$this->__unset('s');
587 587
 
588
-		} elseif ( $is_user ) {
588
+		} elseif ($is_user) {
589 589
 
590 590
 			$search_meta = array(
591 591
 				'key'   => '_give_payment_donor_id',
592
-				'value' => trim( str_replace( 'user:', '', strtolower( $search ) ) ),
592
+				'value' => trim(str_replace('user:', '', strtolower($search))),
593 593
 			);
594 594
 
595
-			$this->__set( 'meta_query', $search_meta );
595
+			$this->__set('meta_query', $search_meta);
596 596
 
597
-			if ( give_get_option( 'enable_sequential' ) ) {
597
+			if (give_get_option('enable_sequential')) {
598 598
 
599 599
 				$search_meta = array(
600 600
 					'key'     => '_give_payment_number',
@@ -602,19 +602,19 @@  discard block
 block discarded – undo
602 602
 					'compare' => 'LIKE',
603 603
 				);
604 604
 
605
-				$this->__set( 'meta_query', $search_meta );
605
+				$this->__set('meta_query', $search_meta);
606 606
 
607 607
 				$this->args['meta_query']['relation'] = 'OR';
608 608
 
609 609
 			}
610 610
 
611
-			$this->__unset( 's' );
611
+			$this->__unset('s');
612 612
 
613 613
 		} elseif (
614
-			give_get_option( 'enable_sequential' ) &&
614
+			give_get_option('enable_sequential') &&
615 615
 			(
616
-				false !== strpos( $search, give_get_option( 'sequential_prefix' ) ) ||
617
-				false !== strpos( $search, give_get_option( 'sequential_postfix' ) )
616
+				false !== strpos($search, give_get_option('sequential_prefix')) ||
617
+				false !== strpos($search, give_get_option('sequential_postfix'))
618 618
 			)
619 619
 		) {
620 620
 
@@ -624,29 +624,29 @@  discard block
 block discarded – undo
624 624
 				'compare' => 'LIKE',
625 625
 			);
626 626
 
627
-			$this->__set( 'meta_query', $search_meta );
628
-			$this->__unset( 's' );
627
+			$this->__set('meta_query', $search_meta);
628
+			$this->__unset('s');
629 629
 
630
-		} elseif ( is_numeric( $search ) ) {
630
+		} elseif (is_numeric($search)) {
631 631
 
632
-			$post = get_post( $search );
632
+			$post = get_post($search);
633 633
 
634
-			if ( is_object( $post ) && $post->post_type == 'give_payment' ) {
634
+			if (is_object($post) && $post->post_type == 'give_payment') {
635 635
 
636 636
 				$arr   = array();
637 637
 				$arr[] = $search;
638
-				$this->__set( 'post__in', $arr );
639
-				$this->__unset( 's' );
638
+				$this->__set('post__in', $arr);
639
+				$this->__unset('s');
640 640
 			}
641
-		} elseif ( '#' == substr( $search, 0, 1 ) ) {
641
+		} elseif ('#' == substr($search, 0, 1)) {
642 642
 
643
-			$search = str_replace( '#:', '', $search );
644
-			$search = str_replace( '#', '', $search );
645
-			$this->__set( 'give_forms', $search );
646
-			$this->__unset( 's' );
643
+			$search = str_replace('#:', '', $search);
644
+			$search = str_replace('#', '', $search);
645
+			$this->__set('give_forms', $search);
646
+			$this->__unset('s');
647 647
 
648 648
 		} else {
649
-			$this->__set( 's', $search );
649
+			$this->__set('s', $search);
650 650
 
651 651
 		}
652 652
 
@@ -661,8 +661,8 @@  discard block
 block discarded – undo
661 661
 	 * @return void
662 662
 	 */
663 663
 	public function mode() {
664
-		if ( empty( $this->args['mode'] ) || $this->args['mode'] == 'all' ) {
665
-			$this->__unset( 'mode' );
664
+		if (empty($this->args['mode']) || $this->args['mode'] == 'all') {
665
+			$this->__unset('mode');
666 666
 
667 667
 			return;
668 668
 		}
@@ -684,10 +684,10 @@  discard block
 block discarded – undo
684 684
 	 * @return void
685 685
 	 */
686 686
 	public function children() {
687
-		if ( empty( $this->args['children'] ) ) {
688
-			$this->__set( 'post_parent', 0 );
687
+		if (empty($this->args['children'])) {
688
+			$this->__set('post_parent', 0);
689 689
 		}
690
-		$this->__unset( 'children' );
690
+		$this->__unset('children');
691 691
 	}
692 692
 
693 693
 	/**
@@ -700,13 +700,13 @@  discard block
 block discarded – undo
700 700
 	 */
701 701
 	public function give_forms() {
702 702
 
703
-		if ( empty( $this->args['give_forms'] ) ) {
703
+		if (empty($this->args['give_forms'])) {
704 704
 			return;
705 705
 		}
706 706
 
707 707
 		$compare = '=';
708 708
 
709
-		if ( is_array( $this->args['give_forms'] ) ) {
709
+		if (is_array($this->args['give_forms'])) {
710 710
 			$compare = 'IN';
711 711
 		}
712 712
 
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
 			)
720 720
 		);
721 721
 
722
-		$this->__unset( 'give_forms' );
722
+		$this->__unset('give_forms');
723 723
 
724 724
 	}
725 725
 
@@ -733,13 +733,13 @@  discard block
 block discarded – undo
733 733
 	 */
734 734
 	public function gateway_filter() {
735 735
 
736
-		if ( empty( $this->args['gateway'] ) ) {
736
+		if (empty($this->args['gateway'])) {
737 737
 			return;
738 738
 		}
739 739
 
740 740
 		$compare = '=';
741 741
 
742
-		if ( is_array( $this->args['gateway'] ) ) {
742
+		if (is_array($this->args['gateway'])) {
743 743
 			$compare = 'IN';
744 744
 		}
745 745
 
@@ -753,7 +753,7 @@  discard block
 block discarded – undo
753 753
 			)
754 754
 		);
755 755
 
756
-		$this->__unset( 'gateway' );
756
+		$this->__unset('gateway');
757 757
 
758 758
 	}
759 759
 
@@ -773,9 +773,9 @@  discard block
 block discarded – undo
773 773
 		global $wpdb;
774 774
 
775 775
 		$where = "WHERE {$wpdb->posts}.post_type = 'give_payment'";
776
-		$where .= " AND {$wpdb->posts}.post_status IN ('" . implode( "','", $this->args['post_status'] ) . "')";
776
+		$where .= " AND {$wpdb->posts}.post_status IN ('".implode("','", $this->args['post_status'])."')";
777 777
 
778
-		if( is_numeric( $this->args['post_parent'] ) ) {
778
+		if (is_numeric($this->args['post_parent'])) {
779 779
 			$where .= " AND {$wpdb->posts}.post_parent={$this->args['post_parent']}";
780 780
 		}
781 781
 
@@ -784,42 +784,42 @@  discard block
 block discarded – undo
784 784
 		$group_by = '';
785 785
 
786 786
 		// Set group by.
787
-		if ( ! empty( $this->args['group_by'] ) ) {
787
+		if ( ! empty($this->args['group_by'])) {
788 788
 			$group_by = "GROUP BY {$wpdb->posts}.{$this->args['group_by']}";
789 789
 		}
790 790
 
791 791
 		// Set offset.
792 792
 		if (
793
-			empty( $this->args['nopaging'] ) &&
794
-			empty( $this->args['offset'] ) &&
795
-			( ! empty( $this->args['page'] ) && 0 < $this->args['page'] )
793
+			empty($this->args['nopaging']) &&
794
+			empty($this->args['offset']) &&
795
+			( ! empty($this->args['page']) && 0 < $this->args['page'])
796 796
 		) {
797
-			$this->args['offset'] = $this->args['posts_per_page'] * ( $this->args['page'] - 1 );
797
+			$this->args['offset'] = $this->args['posts_per_page'] * ($this->args['page'] - 1);
798 798
 		}
799 799
 
800 800
 		// Set fields.
801 801
 		$fields = "{$wpdb->posts}.*";
802
-		if ( ! empty( $this->args['fields'] ) && 'all' !== $this->args['fields'] ) {
803
-			if ( is_string( $this->args['fields'] ) ) {
802
+		if ( ! empty($this->args['fields']) && 'all' !== $this->args['fields']) {
803
+			if (is_string($this->args['fields'])) {
804 804
 				$fields = "{$wpdb->posts}.{$this->args['fields']}";
805
-			} elseif ( is_array( $this->args['fields'] ) ) {
806
-				$fields = "{$wpdb->posts}." . implode( " , {$wpdb->posts}.", $this->args['fields'] );
805
+			} elseif (is_array($this->args['fields'])) {
806
+				$fields = "{$wpdb->posts}.".implode(" , {$wpdb->posts}.", $this->args['fields']);
807 807
 			}
808 808
 		}
809 809
 
810 810
 		// Set count.
811
-		if ( ! empty( $this->args['count'] ) ) {
811
+		if ( ! empty($this->args['count'])) {
812 812
 			$fields = "COUNT({$wpdb->posts}.ID)";
813 813
 
814
-			if ( ! empty( $this->args['group_by'] ) ) {
814
+			if ( ! empty($this->args['group_by'])) {
815 815
 				$fields = "{$wpdb->posts}.{$this->args['group_by']}, {$fields}";
816 816
 			}
817 817
 		}
818 818
 
819 819
 		// Date query.
820
-		if ( ! empty( $this->args['date_query'] ) ) {
821
-			$date_query_obj = new WP_Date_Query( $this->args['date_query'] );
822
-			$where          .= str_replace(
820
+		if ( ! empty($this->args['date_query'])) {
821
+			$date_query_obj = new WP_Date_Query($this->args['date_query']);
822
+			$where .= str_replace(
823 823
 				array(
824 824
 					"\n",
825 825
 					'(   (',
@@ -835,21 +835,21 @@  discard block
 block discarded – undo
835 835
 		}
836 836
 
837 837
 		// Meta query.
838
-		if ( ! empty( $this->args['meta_query'] ) ) {
839
-			$meta_query_obj = new WP_Meta_Query( $this->args['meta_query'] );
840
-			$where          = implode( ' ', $meta_query_obj->get_sql( 'post', $wpdb->posts, 'ID' ) ) . " {$where}";
838
+		if ( ! empty($this->args['meta_query'])) {
839
+			$meta_query_obj = new WP_Meta_Query($this->args['meta_query']);
840
+			$where          = implode(' ', $meta_query_obj->get_sql('post', $wpdb->posts, 'ID'))." {$where}";
841 841
 		}
842 842
 
843 843
 		// Set sql query.
844 844
 		$sql = $wpdb->prepare(
845 845
 			"SELECT {$fields} FROM {$wpdb->posts} LIMIT %d,%d;",
846
-			absint( $this->args['offset'] ),
847
-			( empty( $this->args['nopaging'] ) ? absint( $this->args['posts_per_page'] ) : 999999999999999 )
846
+			absint($this->args['offset']),
847
+			(empty($this->args['nopaging']) ? absint($this->args['posts_per_page']) : 999999999999999)
848 848
 		);
849 849
 
850 850
 		// $where, $orderby and order already prepared query they can generate notice if you re prepare them in above.
851 851
 		// WordPress consider LIKE condition as placeholder if start with s,f, or d.
852
-		$sql = str_replace( 'LIMIT', "{$where} {$group_by} {$orderby} {$this->args['order']} LIMIT", $sql );
852
+		$sql = str_replace('LIMIT', "{$where} {$group_by} {$orderby} {$this->args['order']} LIMIT", $sql);
853 853
 
854 854
 		return $sql;
855 855
 	}
Please login to merge, or discard this patch.
includes/payments/functions.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
  *
566 566
  * @since 1.0
567 567
  *
568
- * @return int $earnings Earnings
568
+ * @return double $earnings Earnings
569 569
  */
570 570
 function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) {
571 571
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead.
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
  *
882 882
  * @since 1.0
883 883
  *
884
- * @return int $form_id Form ID.
884
+ * @return string $form_id Form ID.
885 885
  */
886 886
 function give_get_payment_form_id( $payment_id ) {
887 887
 	$payment = new Give_Payment( $payment_id );
@@ -1729,7 +1729,7 @@  discard block
 block discarded – undo
1729 1729
  *
1730 1730
  * Retrieves the form title and appends the level name if present.
1731 1731
  *
1732
- * @param int|Give_Payment $donation Donation Data Object.
1732
+ * @param Give_Payment $donation Donation Data Object.
1733 1733
  * @param array            $args     a. only_level = If set to true will only return the level name if multi-level enabled.
1734 1734
  *                                   b. separator  = The separator between the Form Title and the Donation Level.
1735 1735
  *
Please login to merge, or discard this patch.
Spacing   +380 added lines, -382 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
 
@@ -44,15 +44,15 @@  discard block
 block discarded – undo
44 44
  *
45 45
  * @return array $payments Payments retrieved from the database
46 46
  */
47
-function give_get_payments( $args = array() ) {
47
+function give_get_payments($args = array()) {
48 48
 
49 49
 	// Fallback to post objects to ensure backwards compatibility.
50
-	if ( ! isset( $args['output'] ) ) {
50
+	if ( ! isset($args['output'])) {
51 51
 		$args['output'] = 'posts';
52 52
 	}
53 53
 
54
-	$args     = apply_filters( 'give_get_payments_args', $args );
55
-	$payments = new Give_Payments_Query( $args );
54
+	$args     = apply_filters('give_get_payments_args', $args);
55
+	$payments = new Give_Payments_Query($args);
56 56
 
57 57
 	return $payments->get_payments();
58 58
 }
@@ -67,48 +67,48 @@  discard block
 block discarded – undo
67 67
  *
68 68
  * @return mixed
69 69
  */
70
-function give_get_payment_by( $field = '', $value = '' ) {
70
+function give_get_payment_by($field = '', $value = '') {
71 71
 
72
-	if ( empty( $field ) || empty( $value ) ) {
72
+	if (empty($field) || empty($value)) {
73 73
 		return false;
74 74
 	}
75 75
 
76
-	switch ( strtolower( $field ) ) {
76
+	switch (strtolower($field)) {
77 77
 
78 78
 		case 'id':
79
-			$payment = new Give_Payment( $value );
79
+			$payment = new Give_Payment($value);
80 80
 			$id      = $payment->ID;
81 81
 
82
-			if ( empty( $id ) ) {
82
+			if (empty($id)) {
83 83
 				return false;
84 84
 			}
85 85
 
86 86
 			break;
87 87
 
88 88
 		case 'key':
89
-			$payment = give_get_payments( array(
89
+			$payment = give_get_payments(array(
90 90
 				'meta_key'       => '_give_payment_purchase_key',
91 91
 				'meta_value'     => $value,
92 92
 				'posts_per_page' => 1,
93 93
 				'fields'         => 'ids',
94
-			) );
94
+			));
95 95
 
96
-			if ( $payment ) {
97
-				$payment = new Give_Payment( $payment[0] );
96
+			if ($payment) {
97
+				$payment = new Give_Payment($payment[0]);
98 98
 			}
99 99
 
100 100
 			break;
101 101
 
102 102
 		case 'payment_number':
103
-			$payment = give_get_payments( array(
103
+			$payment = give_get_payments(array(
104 104
 				'meta_key'       => '_give_payment_number',
105 105
 				'meta_value'     => $value,
106 106
 				'posts_per_page' => 1,
107 107
 				'fields'         => 'ids',
108
-			) );
108
+			));
109 109
 
110
-			if ( $payment ) {
111
-				$payment = new Give_Payment( $payment[0] );
110
+			if ($payment) {
111
+				$payment = new Give_Payment($payment[0]);
112 112
 			}
113 113
 
114 114
 			break;
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 			return false;
118 118
 	}// End switch().
119 119
 
120
-	if ( $payment ) {
120
+	if ($payment) {
121 121
 		return $payment;
122 122
 	}
123 123
 
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
  *
134 134
  * @return int|bool Payment ID if payment is inserted, false otherwise.
135 135
  */
136
-function give_insert_payment( $payment_data = array() ) {
136
+function give_insert_payment($payment_data = array()) {
137 137
 
138
-	if ( empty( $payment_data ) ) {
138
+	if (empty($payment_data)) {
139 139
 		return false;
140 140
 	}
141 141
 
@@ -146,25 +146,25 @@  discard block
 block discarded – undo
146 146
 	 *
147 147
 	 * @param array $payment_data Arguments passed.
148 148
 	 */
149
-	$payment_data = apply_filters( 'give_pre_insert_payment', $payment_data );
149
+	$payment_data = apply_filters('give_pre_insert_payment', $payment_data);
150 150
 
151 151
 	$payment    = new Give_Payment();
152
-	$gateway    = ! empty( $payment_data['gateway'] ) ? $payment_data['gateway'] : '';
153
-	$gateway    = empty( $gateway ) && isset( $_POST['give-gateway'] ) ? $_POST['give-gateway'] : $gateway;
154
-	$form_id    = isset( $payment_data['give_form_id'] ) ? $payment_data['give_form_id'] : 0;
155
-	$price_id   = give_get_payment_meta_price_id( $payment_data );
156
-	$form_title = isset( $payment_data['give_form_title'] ) ? $payment_data['give_form_title'] : get_the_title( $form_id );
152
+	$gateway    = ! empty($payment_data['gateway']) ? $payment_data['gateway'] : '';
153
+	$gateway    = empty($gateway) && isset($_POST['give-gateway']) ? $_POST['give-gateway'] : $gateway;
154
+	$form_id    = isset($payment_data['give_form_id']) ? $payment_data['give_form_id'] : 0;
155
+	$price_id   = give_get_payment_meta_price_id($payment_data);
156
+	$form_title = isset($payment_data['give_form_title']) ? $payment_data['give_form_title'] : get_the_title($form_id);
157 157
 
158 158
 	// Set properties.
159 159
 	$payment->total          = $payment_data['price'];
160
-	$payment->status         = ! empty( $payment_data['status'] ) ? $payment_data['status'] : 'pending';
161
-	$payment->currency       = ! empty( $payment_data['currency'] ) ? $payment_data['currency'] : give_get_currency( $payment_data['give_form_id'], $payment_data );
160
+	$payment->status         = ! empty($payment_data['status']) ? $payment_data['status'] : 'pending';
161
+	$payment->currency       = ! empty($payment_data['currency']) ? $payment_data['currency'] : give_get_currency($payment_data['give_form_id'], $payment_data);
162 162
 	$payment->user_info      = $payment_data['user_info'];
163 163
 	$payment->gateway        = $gateway;
164 164
 	$payment->form_title     = $form_title;
165 165
 	$payment->form_id        = $form_id;
166 166
 	$payment->price_id       = $price_id;
167
-	$payment->donor_id       = ( ! empty( $payment_data['donor_id'] ) ? $payment_data['donor_id'] : '' );
167
+	$payment->donor_id       = ( ! empty($payment_data['donor_id']) ? $payment_data['donor_id'] : '');
168 168
 	$payment->user_id        = $payment_data['user_info']['id'];
169 169
 	$payment->email          = $payment_data['user_email'];
170 170
 	$payment->first_name     = $payment_data['user_info']['first_name'];
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
 	$payment->email          = $payment_data['user_info']['email'];
173 173
 	$payment->ip             = give_get_ip();
174 174
 	$payment->key            = $payment_data['purchase_key'];
175
-	$payment->mode           = ( ! empty( $payment_data['mode'] ) ? (string) $payment_data['mode'] : ( give_is_test_mode() ? 'test' : 'live' ) );
176
-	$payment->parent_payment = ! empty( $payment_data['parent'] ) ? absint( $payment_data['parent'] ) : '';
175
+	$payment->mode           = ( ! empty($payment_data['mode']) ? (string) $payment_data['mode'] : (give_is_test_mode() ? 'test' : 'live'));
176
+	$payment->parent_payment = ! empty($payment_data['parent']) ? absint($payment_data['parent']) : '';
177 177
 
178 178
 	// Add the donation.
179 179
 	$args = array(
@@ -181,19 +181,19 @@  discard block
 block discarded – undo
181 181
 		'price_id' => $payment->price_id,
182 182
 	);
183 183
 
184
-	$payment->add_donation( $payment->form_id, $args );
184
+	$payment->add_donation($payment->form_id, $args);
185 185
 
186 186
 
187 187
 	// Set date if present.
188
-	if ( isset( $payment_data['post_date'] ) ) {
188
+	if (isset($payment_data['post_date'])) {
189 189
 		$payment->date = $payment_data['post_date'];
190 190
 	}
191 191
 
192 192
 	// Handle sequential payments.
193
-	if ( give_get_option( 'enable_sequential' ) ) {
193
+	if (give_get_option('enable_sequential')) {
194 194
 		$number          = give_get_next_payment_number();
195
-		$payment->number = give_format_payment_number( $number );
196
-		update_option( 'give_last_payment_number', $number );
195
+		$payment->number = give_format_payment_number($number);
196
+		update_option('give_last_payment_number', $number);
197 197
 	}
198 198
 
199 199
 	// Save payment.
@@ -207,10 +207,10 @@  discard block
 block discarded – undo
207 207
 	 * @param int   $payment_id   The payment ID.
208 208
 	 * @param array $payment_data Arguments passed.
209 209
 	 */
210
-	do_action( 'give_insert_payment', $payment->ID, $payment_data );
210
+	do_action('give_insert_payment', $payment->ID, $payment_data);
211 211
 
212 212
 	// Return payment ID upon success.
213
-	if ( ! empty( $payment->ID ) ) {
213
+	if ( ! empty($payment->ID)) {
214 214
 		return $payment->ID;
215 215
 	}
216 216
 
@@ -226,10 +226,10 @@  discard block
 block discarded – undo
226 226
  *
227 227
  * @return bool|int
228 228
  */
229
-function give_create_payment( $payment_data ) {
229
+function give_create_payment($payment_data) {
230 230
 
231
-	$form_id  = intval( $payment_data['post_data']['give-form-id'] );
232
-	$price_id = isset( $payment_data['post_data']['give-price-id'] ) ? $payment_data['post_data']['give-price-id'] : '';
231
+	$form_id  = intval($payment_data['post_data']['give-form-id']);
232
+	$price_id = isset($payment_data['post_data']['give-price-id']) ? $payment_data['post_data']['give-price-id'] : '';
233 233
 
234 234
 	// Collect payment data.
235 235
 	$insert_payment_data = array(
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 		'date'            => $payment_data['date'],
241 241
 		'user_email'      => $payment_data['user_email'],
242 242
 		'purchase_key'    => $payment_data['purchase_key'],
243
-		'currency'        => give_get_currency( $form_id, $payment_data ),
243
+		'currency'        => give_get_currency($form_id, $payment_data),
244 244
 		'user_info'       => $payment_data['user_info'],
245 245
 		'status'          => 'pending',
246 246
 		'gateway'         => 'paypal',
@@ -253,10 +253,10 @@  discard block
 block discarded – undo
253 253
 	 *
254 254
 	 * @param array $insert_payment_data
255 255
 	 */
256
-	$insert_payment_data = apply_filters( 'give_create_payment', $insert_payment_data );
256
+	$insert_payment_data = apply_filters('give_create_payment', $insert_payment_data);
257 257
 
258 258
 	// Record the pending payment.
259
-	return give_insert_payment( $insert_payment_data );
259
+	return give_insert_payment($insert_payment_data);
260 260
 }
261 261
 
262 262
 /**
@@ -269,12 +269,12 @@  discard block
 block discarded – undo
269 269
  *
270 270
  * @return bool
271 271
  */
272
-function give_update_payment_status( $payment_id, $new_status = 'publish' ) {
272
+function give_update_payment_status($payment_id, $new_status = 'publish') {
273 273
 
274 274
 	$updated = false;
275
-	$payment = new Give_Payment( $payment_id );
275
+	$payment = new Give_Payment($payment_id);
276 276
 
277
-	if ( $payment && $payment->ID > 0 ) {
277
+	if ($payment && $payment->ID > 0) {
278 278
 
279 279
 		$payment->status = $new_status;
280 280
 		$updated         = $payment->save();
@@ -295,45 +295,45 @@  discard block
 block discarded – undo
295 295
  *
296 296
  * @return void
297 297
  */
298
-function give_delete_donation( $payment_id = 0, $update_donor = true ) {
299
-	$payment = new Give_Payment( $payment_id );
298
+function give_delete_donation($payment_id = 0, $update_donor = true) {
299
+	$payment = new Give_Payment($payment_id);
300 300
 
301 301
 	// Bailout.
302
-	if ( ! $payment->ID ) {
302
+	if ( ! $payment->ID) {
303 303
 		return;
304 304
 	}
305 305
 
306
-	$amount   = give_donation_amount( $payment_id );
306
+	$amount   = give_donation_amount($payment_id);
307 307
 	$status   = $payment->post_status;
308
-	$donor_id = give_get_payment_donor_id( $payment_id );
309
-	$donor    = new Give_Donor( $donor_id );
308
+	$donor_id = give_get_payment_donor_id($payment_id);
309
+	$donor    = new Give_Donor($donor_id);
310 310
 
311 311
 	// Only undo donations that aren't these statuses.
312
-	$dont_undo_statuses = apply_filters( 'give_undo_donation_statuses', array(
312
+	$dont_undo_statuses = apply_filters('give_undo_donation_statuses', array(
313 313
 		'pending',
314 314
 		'cancelled',
315
-	) );
315
+	));
316 316
 
317
-	if ( ! in_array( $status, $dont_undo_statuses ) ) {
318
-		give_undo_donation( $payment_id );
317
+	if ( ! in_array($status, $dont_undo_statuses)) {
318
+		give_undo_donation($payment_id);
319 319
 	}
320 320
 
321 321
 	// Only undo donations that aren't these statuses.
322
-	$status_to_decrease_stats = apply_filters( 'give_decrease_donor_statuses', array( 'publish' ) );
322
+	$status_to_decrease_stats = apply_filters('give_decrease_donor_statuses', array('publish'));
323 323
 
324
-	if ( in_array( $status, $status_to_decrease_stats ) ) {
324
+	if (in_array($status, $status_to_decrease_stats)) {
325 325
 
326 326
 		// Only decrease earnings if they haven't already been decreased (or were never increased for this payment).
327
-		give_decrease_total_earnings( $amount );
327
+		give_decrease_total_earnings($amount);
328 328
 
329 329
 		// @todo: Refresh only range related stat cache
330 330
 		give_delete_donation_stats();
331 331
 
332
-		if ( $donor->id && $update_donor ) {
332
+		if ($donor->id && $update_donor) {
333 333
 
334 334
 			// Decrement the stats for the donor.
335 335
 			$donor->decrease_donation_count();
336
-			$donor->decrease_value( $amount );
336
+			$donor->decrease_value($amount);
337 337
 
338 338
 		}
339 339
 	}
@@ -345,18 +345,18 @@  discard block
 block discarded – undo
345 345
 	 *
346 346
 	 * @since 1.0
347 347
 	 */
348
-	do_action( 'give_payment_delete', $payment_id );
348
+	do_action('give_payment_delete', $payment_id);
349 349
 
350
-	if ( $donor->id && $update_donor ) {
350
+	if ($donor->id && $update_donor) {
351 351
 		// Remove the payment ID from the donor.
352
-		$donor->remove_payment( $payment_id );
352
+		$donor->remove_payment($payment_id);
353 353
 	}
354 354
 
355 355
 	// Remove the payment.
356
-	wp_delete_post( $payment_id, true );
356
+	wp_delete_post($payment_id, true);
357 357
 
358 358
 	// Remove related sale log entries.
359
-	Give()->logs->delete_logs( $payment_id );
359
+	Give()->logs->delete_logs($payment_id);
360 360
 
361 361
 	/**
362 362
 	 * Fires after payment deleted.
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 	 *
366 366
 	 * @since 1.0
367 367
 	 */
368
-	do_action( 'give_payment_deleted', $payment_id );
368
+	do_action('give_payment_deleted', $payment_id);
369 369
 }
370 370
 
371 371
 /**
@@ -380,20 +380,20 @@  discard block
 block discarded – undo
380 380
  *
381 381
  * @return void
382 382
  */
383
-function give_undo_donation( $payment_id ) {
383
+function give_undo_donation($payment_id) {
384 384
 
385
-	$payment = new Give_Payment( $payment_id );
385
+	$payment = new Give_Payment($payment_id);
386 386
 
387
-	$maybe_decrease_earnings = apply_filters( 'give_decrease_earnings_on_undo', true, $payment, $payment->form_id );
388
-	if ( true === $maybe_decrease_earnings ) {
387
+	$maybe_decrease_earnings = apply_filters('give_decrease_earnings_on_undo', true, $payment, $payment->form_id);
388
+	if (true === $maybe_decrease_earnings) {
389 389
 		// Decrease earnings.
390
-		give_decrease_form_earnings( $payment->form_id, $payment->total );
390
+		give_decrease_form_earnings($payment->form_id, $payment->total);
391 391
 	}
392 392
 
393
-	$maybe_decrease_donations = apply_filters( 'give_decrease_donations_on_undo', true, $payment, $payment->form_id );
394
-	if ( true === $maybe_decrease_donations ) {
393
+	$maybe_decrease_donations = apply_filters('give_decrease_donations_on_undo', true, $payment, $payment->form_id);
394
+	if (true === $maybe_decrease_donations) {
395 395
 		// Decrease donation count.
396
-		give_decrease_donation_count( $payment->form_id );
396
+		give_decrease_donation_count($payment->form_id);
397 397
 	}
398 398
 
399 399
 }
@@ -410,21 +410,21 @@  discard block
 block discarded – undo
410 410
  *
411 411
  * @return object $stats Contains the number of payments per payment status.
412 412
  */
413
-function give_count_payments( $args = array() ) {
413
+function give_count_payments($args = array()) {
414 414
 	// Backward compatibility.
415
-	if ( ! empty( $args['start-date'] ) ) {
415
+	if ( ! empty($args['start-date'])) {
416 416
 		$args['start_date'] = $args['start-date'];
417
-		unset( $args['start-date'] );
417
+		unset($args['start-date']);
418 418
 	}
419 419
 
420
-	if ( ! empty( $args['end-date'] ) ) {
420
+	if ( ! empty($args['end-date'])) {
421 421
 		$args['end_date'] = $args['end-date'];
422
-		unset( $args['end-date'] );
422
+		unset($args['end-date']);
423 423
 	}
424 424
 
425
-	if ( ! empty( $args['form_id'] ) ) {
425
+	if ( ! empty($args['form_id'])) {
426 426
 		$args['give_forms'] = $args['form_id'];
427
-		unset( $args['form_id'] );
427
+		unset($args['form_id']);
428 428
 	}
429 429
 
430 430
 	// Extract all donations
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 	$args['group_by']    = 'post_status';
433 433
 	$args['count']       = 'true';
434 434
 
435
-	$donations_obj   = new Give_Payments_Query( $args );
435
+	$donations_obj   = new Give_Payments_Query($args);
436 436
 	$donations_count = $donations_obj->get_payment_by_group();
437 437
 
438 438
 	/**
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
 	 *
441 441
 	 * @since 1.0
442 442
 	 */
443
-	return (object) apply_filters( 'give_count_payments', $donations_count, $args, $donations_obj );
443
+	return (object) apply_filters('give_count_payments', $donations_count, $args, $donations_obj);
444 444
 }
445 445
 
446 446
 
@@ -453,11 +453,11 @@  discard block
 block discarded – undo
453 453
  *
454 454
  * @return bool $exists True if payment exists, false otherwise.
455 455
  */
456
-function give_check_for_existing_payment( $payment_id ) {
456
+function give_check_for_existing_payment($payment_id) {
457 457
 	$exists  = false;
458
-	$payment = new Give_Payment( $payment_id );
458
+	$payment = new Give_Payment($payment_id);
459 459
 
460
-	if ( $payment_id === $payment->ID && 'publish' === $payment->status ) {
460
+	if ($payment_id === $payment->ID && 'publish' === $payment->status) {
461 461
 		$exists = true;
462 462
 	}
463 463
 
@@ -475,41 +475,41 @@  discard block
 block discarded – undo
475 475
  *
476 476
  * @return bool|mixed True if payment status exists, false otherwise.
477 477
  */
478
-function give_get_payment_status( $payment, $return_label = false ) {
478
+function give_get_payment_status($payment, $return_label = false) {
479 479
 
480
-	if ( is_numeric( $payment ) ) {
480
+	if (is_numeric($payment)) {
481 481
 
482
-		$payment = new Give_Payment( $payment );
482
+		$payment = new Give_Payment($payment);
483 483
 
484
-		if ( ! $payment->ID > 0 ) {
484
+		if ( ! $payment->ID > 0) {
485 485
 			return false;
486 486
 		}
487 487
 
488 488
 	}
489 489
 
490
-	if ( ! is_object( $payment ) || ! isset( $payment->post_status ) ) {
490
+	if ( ! is_object($payment) || ! isset($payment->post_status)) {
491 491
 		return false;
492 492
 	}
493 493
 
494 494
 	$statuses = give_get_payment_statuses();
495 495
 
496
-	if ( ! is_array( $statuses ) || empty( $statuses ) ) {
496
+	if ( ! is_array($statuses) || empty($statuses)) {
497 497
 		return false;
498 498
 	}
499 499
 
500 500
 	// Get payment object if not already given.
501
-	$payment = $payment instanceof Give_Payment ? $payment : new Give_Payment( $payment->ID );
501
+	$payment = $payment instanceof Give_Payment ? $payment : new Give_Payment($payment->ID);
502 502
 
503
-	if ( array_key_exists( $payment->status, $statuses ) ) {
504
-		if ( true === $return_label ) {
503
+	if (array_key_exists($payment->status, $statuses)) {
504
+		if (true === $return_label) {
505 505
 			// Return translated status label.
506
-			return $statuses[ $payment->status ];
506
+			return $statuses[$payment->status];
507 507
 		} else {
508 508
 			// Account that our 'publish' status is labeled 'Complete'
509 509
 			$post_status = 'publish' === $payment->status ? 'Complete' : $payment->post_status;
510 510
 
511 511
 			// Make sure we're matching cases, since they matter
512
-			return array_search( strtolower( $post_status ), array_map( 'strtolower', $statuses ) );
512
+			return array_search(strtolower($post_status), array_map('strtolower', $statuses));
513 513
 		}
514 514
 	}
515 515
 
@@ -525,18 +525,18 @@  discard block
 block discarded – undo
525 525
  */
526 526
 function give_get_payment_statuses() {
527 527
 	$payment_statuses = array(
528
-		'pending'     => __( 'Pending', 'give' ),
529
-		'publish'     => __( 'Complete', 'give' ),
530
-		'refunded'    => __( 'Refunded', 'give' ),
531
-		'failed'      => __( 'Failed', 'give' ),
532
-		'cancelled'   => __( 'Cancelled', 'give' ),
533
-		'abandoned'   => __( 'Abandoned', 'give' ),
534
-		'preapproval' => __( 'Pre-Approved', 'give' ),
535
-		'processing'  => __( 'Processing', 'give' ),
536
-		'revoked'     => __( 'Revoked', 'give' ),
528
+		'pending'     => __('Pending', 'give'),
529
+		'publish'     => __('Complete', 'give'),
530
+		'refunded'    => __('Refunded', 'give'),
531
+		'failed'      => __('Failed', 'give'),
532
+		'cancelled'   => __('Cancelled', 'give'),
533
+		'abandoned'   => __('Abandoned', 'give'),
534
+		'preapproval' => __('Pre-Approved', 'give'),
535
+		'processing'  => __('Processing', 'give'),
536
+		'revoked'     => __('Revoked', 'give'),
537 537
 	);
538 538
 
539
-	return apply_filters( 'give_payment_statuses', $payment_statuses );
539
+	return apply_filters('give_payment_statuses', $payment_statuses);
540 540
 }
541 541
 
542 542
 /**
@@ -549,10 +549,10 @@  discard block
 block discarded – undo
549 549
  * @return array $payment_status All the available payment statuses.
550 550
  */
551 551
 function give_get_payment_status_keys() {
552
-	$statuses = array_keys( give_get_payment_statuses() );
553
-	asort( $statuses );
552
+	$statuses = array_keys(give_get_payment_statuses());
553
+	asort($statuses);
554 554
 
555
-	return array_values( $statuses );
555
+	return array_values($statuses);
556 556
 }
557 557
 
558 558
 /**
@@ -567,44 +567,44 @@  discard block
 block discarded – undo
567 567
  *
568 568
  * @return int $earnings Earnings
569 569
  */
570
-function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) {
570
+function give_get_earnings_by_date($day = null, $month_num, $year = null, $hour = null) {
571 571
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead.
572 572
 
573 573
 	global $wpdb;
574
-	$meta_table = __give_v20_bc_table_details( 'payment' );
574
+	$meta_table = __give_v20_bc_table_details('payment');
575 575
 
576 576
 	$args = array(
577 577
 		'post_type'              => 'give_payment',
578 578
 		'nopaging'               => true,
579 579
 		'year'                   => $year,
580 580
 		'monthnum'               => $month_num,
581
-		'post_status'            => array( 'publish' ),
581
+		'post_status'            => array('publish'),
582 582
 		'fields'                 => 'ids',
583 583
 		'update_post_term_cache' => false,
584 584
 	);
585
-	if ( ! empty( $day ) ) {
585
+	if ( ! empty($day)) {
586 586
 		$args['day'] = $day;
587 587
 	}
588 588
 
589
-	if ( isset( $hour ) ) {
589
+	if (isset($hour)) {
590 590
 		$args['hour'] = $hour;
591 591
 	}
592 592
 
593
-	$args = apply_filters( 'give_get_earnings_by_date_args', $args );
594
-	$key  = Give_Cache::get_key( 'give_stats', $args );
593
+	$args = apply_filters('give_get_earnings_by_date_args', $args);
594
+	$key  = Give_Cache::get_key('give_stats', $args);
595 595
 
596
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
596
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
597 597
 		$earnings = false;
598 598
 	} else {
599
-		$earnings = Give_Cache::get( $key );
599
+		$earnings = Give_Cache::get($key);
600 600
 	}
601 601
 
602
-	if ( false === $earnings ) {
603
-		$donations = get_posts( $args );
602
+	if (false === $earnings) {
603
+		$donations = get_posts($args);
604 604
 		$earnings  = 0;
605
-		if ( $donations ) {
606
-			$donations      = implode( ',', $donations );
607
-			$earning_totals = $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$donations})" );
605
+		if ($donations) {
606
+			$donations      = implode(',', $donations);
607
+			$earning_totals = $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$donations})");
608 608
 
609 609
 			/**
610 610
 			 * Filter The earnings by dates.
@@ -615,13 +615,13 @@  discard block
 block discarded – undo
615 615
 			 * @param array $donations      Donations lists.
616 616
 			 * @param array $args           Donation query args.
617 617
 			 */
618
-			$earnings = apply_filters( 'give_get_earnings_by_date', $earning_totals, $donations, $args );
618
+			$earnings = apply_filters('give_get_earnings_by_date', $earning_totals, $donations, $args);
619 619
 		}
620 620
 		// Cache the results for one hour.
621
-		Give_Cache::set( $key, $earnings, HOUR_IN_SECONDS );
621
+		Give_Cache::set($key, $earnings, HOUR_IN_SECONDS);
622 622
 	}
623 623
 
624
-	return round( $earnings, 2 );
624
+	return round($earnings, 2);
625 625
 }
626 626
 
627 627
 /**
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
  *
637 637
  * @return int $count Sales
638 638
  */
639
-function give_get_sales_by_date( $day = null, $month_num = null, $year = null, $hour = null ) {
639
+function give_get_sales_by_date($day = null, $month_num = null, $year = null, $hour = null) {
640 640
 
641 641
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_sales() method instead.
642 642
 	$args = array(
@@ -644,14 +644,14 @@  discard block
 block discarded – undo
644 644
 		'nopaging'               => true,
645 645
 		'year'                   => $year,
646 646
 		'fields'                 => 'ids',
647
-		'post_status'            => array( 'publish' ),
647
+		'post_status'            => array('publish'),
648 648
 		'update_post_meta_cache' => false,
649 649
 		'update_post_term_cache' => false,
650 650
 	);
651 651
 
652
-	$show_free = apply_filters( 'give_sales_by_date_show_free', true, $args );
652
+	$show_free = apply_filters('give_sales_by_date_show_free', true, $args);
653 653
 
654
-	if ( false === $show_free ) {
654
+	if (false === $show_free) {
655 655
 		$args['meta_query'] = array(
656 656
 			array(
657 657
 				'key'     => '_give_payment_total',
@@ -662,33 +662,33 @@  discard block
 block discarded – undo
662 662
 		);
663 663
 	}
664 664
 
665
-	if ( ! empty( $month_num ) ) {
665
+	if ( ! empty($month_num)) {
666 666
 		$args['monthnum'] = $month_num;
667 667
 	}
668 668
 
669
-	if ( ! empty( $day ) ) {
669
+	if ( ! empty($day)) {
670 670
 		$args['day'] = $day;
671 671
 	}
672 672
 
673
-	if ( isset( $hour ) ) {
673
+	if (isset($hour)) {
674 674
 		$args['hour'] = $hour;
675 675
 	}
676 676
 
677
-	$args = apply_filters( 'give_get_sales_by_date_args', $args );
677
+	$args = apply_filters('give_get_sales_by_date_args', $args);
678 678
 
679
-	$key = Give_Cache::get_key( 'give_stats', $args );
679
+	$key = Give_Cache::get_key('give_stats', $args);
680 680
 
681
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
681
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
682 682
 		$count = false;
683 683
 	} else {
684
-		$count = Give_Cache::get( $key );
684
+		$count = Give_Cache::get($key);
685 685
 	}
686 686
 
687
-	if ( false === $count ) {
688
-		$donations = new WP_Query( $args );
687
+	if (false === $count) {
688
+		$donations = new WP_Query($args);
689 689
 		$count     = (int) $donations->post_count;
690 690
 		// Cache the results for one hour.
691
-		Give_Cache::set( $key, $count, HOUR_IN_SECONDS );
691
+		Give_Cache::set($key, $count, HOUR_IN_SECONDS);
692 692
 	}
693 693
 
694 694
 	return $count;
@@ -703,19 +703,19 @@  discard block
 block discarded – undo
703 703
  *
704 704
  * @return bool $ret True if complete, false otherwise.
705 705
  */
706
-function give_is_payment_complete( $payment_id ) {
707
-	$payment = new Give_Payment( $payment_id );
706
+function give_is_payment_complete($payment_id) {
707
+	$payment = new Give_Payment($payment_id);
708 708
 
709 709
 	$ret = false;
710 710
 
711
-	if ( $payment->ID > 0 ) {
711
+	if ($payment->ID > 0) {
712 712
 
713
-		if ( (int) $payment_id === (int) $payment->ID && 'publish' == $payment->status ) {
713
+		if ((int) $payment_id === (int) $payment->ID && 'publish' == $payment->status) {
714 714
 			$ret = true;
715 715
 		}
716 716
 	}
717 717
 
718
-	return apply_filters( 'give_is_payment_complete', $ret, $payment_id, $payment->post_status );
718
+	return apply_filters('give_is_payment_complete', $ret, $payment_id, $payment->post_status);
719 719
 }
720 720
 
721 721
 /**
@@ -741,50 +741,50 @@  discard block
 block discarded – undo
741 741
  *
742 742
  * @return float $total Total earnings.
743 743
  */
744
-function give_get_total_earnings( $recalculate = false ) {
744
+function give_get_total_earnings($recalculate = false) {
745 745
 
746
-	$total      = get_option( 'give_earnings_total', 0 );
747
-	$meta_table = __give_v20_bc_table_details( 'payment' );
746
+	$total      = get_option('give_earnings_total', 0);
747
+	$meta_table = __give_v20_bc_table_details('payment');
748 748
 
749 749
 	// Calculate total earnings.
750
-	if ( ! $total || $recalculate ) {
750
+	if ( ! $total || $recalculate) {
751 751
 		global $wpdb;
752 752
 
753 753
 		$total = (float) 0;
754 754
 
755
-		$args = apply_filters( 'give_get_total_earnings_args', array(
755
+		$args = apply_filters('give_get_total_earnings_args', array(
756 756
 			'offset' => 0,
757
-			'number' => - 1,
758
-			'status' => array( 'publish' ),
757
+			'number' => -1,
758
+			'status' => array('publish'),
759 759
 			'fields' => 'ids',
760
-		) );
760
+		));
761 761
 
762
-		$payments = give_get_payments( $args );
763
-		if ( $payments ) {
762
+		$payments = give_get_payments($args);
763
+		if ($payments) {
764 764
 
765 765
 			/**
766 766
 			 * If performing a donation, we need to skip the very last payment in the database,
767 767
 			 * since it calls give_increase_total_earnings() on completion,
768 768
 			 * which results in duplicated earnings for the very first donation.
769 769
 			 */
770
-			if ( did_action( 'give_update_payment_status' ) ) {
771
-				array_pop( $payments );
770
+			if (did_action('give_update_payment_status')) {
771
+				array_pop($payments);
772 772
 			}
773 773
 
774
-			if ( ! empty( $payments ) ) {
775
-				$payments = implode( ',', $payments );
776
-				$total    += $wpdb->get_var( "SELECT SUM(meta_value) FROM {$meta_table['name']} WHERE meta_key = '_give_payment_total' AND {$meta_table['column']['id']} IN({$payments})" );
774
+			if ( ! empty($payments)) {
775
+				$payments = implode(',', $payments);
776
+				$total += $wpdb->get_var("SELECT SUM(meta_value) FROM {$meta_table['name']} WHERE meta_key = '_give_payment_total' AND {$meta_table['column']['id']} IN({$payments})");
777 777
 			}
778 778
 		}
779 779
 
780
-		update_option( 'give_earnings_total', $total, 'no' );
780
+		update_option('give_earnings_total', $total, 'no');
781 781
 	}
782 782
 
783
-	if ( $total < 0 ) {
783
+	if ($total < 0) {
784 784
 		$total = 0; // Don't ever show negative earnings.
785 785
 	}
786 786
 
787
-	return apply_filters( 'give_total_earnings', round( $total, give_get_price_decimals() ), $total );
787
+	return apply_filters('give_total_earnings', round($total, give_get_price_decimals()), $total);
788 788
 }
789 789
 
790 790
 /**
@@ -796,10 +796,10 @@  discard block
 block discarded – undo
796 796
  *
797 797
  * @return float $total Total earnings.
798 798
  */
799
-function give_increase_total_earnings( $amount = 0 ) {
799
+function give_increase_total_earnings($amount = 0) {
800 800
 	$total = give_get_total_earnings();
801 801
 	$total += $amount;
802
-	update_option( 'give_earnings_total', $total );
802
+	update_option('give_earnings_total', $total);
803 803
 
804 804
 	return $total;
805 805
 }
@@ -813,13 +813,13 @@  discard block
 block discarded – undo
813 813
  *
814 814
  * @return float $total Total earnings.
815 815
  */
816
-function give_decrease_total_earnings( $amount = 0 ) {
816
+function give_decrease_total_earnings($amount = 0) {
817 817
 	$total = give_get_total_earnings();
818 818
 	$total -= $amount;
819
-	if ( $total < 0 ) {
819
+	if ($total < 0) {
820 820
 		$total = 0;
821 821
 	}
822
-	update_option( 'give_earnings_total', $total );
822
+	update_option('give_earnings_total', $total);
823 823
 
824 824
 	return $total;
825 825
 }
@@ -835,10 +835,10 @@  discard block
 block discarded – undo
835 835
  *
836 836
  * @return mixed $meta Payment Meta.
837 837
  */
838
-function give_get_payment_meta( $payment_id = 0, $meta_key = '_give_payment_meta', $single = true ) {
839
-	$payment = new Give_Payment( $payment_id );
838
+function give_get_payment_meta($payment_id = 0, $meta_key = '_give_payment_meta', $single = true) {
839
+	$payment = new Give_Payment($payment_id);
840 840
 
841
-	return $payment->get_meta( $meta_key, $single );
841
+	return $payment->get_meta($meta_key, $single);
842 842
 }
843 843
 
844 844
 /**
@@ -851,10 +851,10 @@  discard block
 block discarded – undo
851 851
  *
852 852
  * @return mixed Meta ID if successful, false if unsuccessful.
853 853
  */
854
-function give_update_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) {
855
-	$payment = new Give_Payment( $payment_id );
854
+function give_update_payment_meta($payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') {
855
+	$payment = new Give_Payment($payment_id);
856 856
 
857
-	return $payment->update_meta( $meta_key, $meta_value, $prev_value );
857
+	return $payment->update_meta($meta_key, $meta_value, $prev_value);
858 858
 }
859 859
 
860 860
 /**
@@ -866,8 +866,8 @@  discard block
 block discarded – undo
866 866
  *
867 867
  * @return array $user_info User Info Meta Values.
868 868
  */
869
-function give_get_payment_meta_user_info( $payment_id ) {
870
-	$payment = new Give_Payment( $payment_id );
869
+function give_get_payment_meta_user_info($payment_id) {
870
+	$payment = new Give_Payment($payment_id);
871 871
 
872 872
 	return $payment->user_info;
873 873
 }
@@ -883,8 +883,8 @@  discard block
 block discarded – undo
883 883
  *
884 884
  * @return int $form_id Form ID.
885 885
  */
886
-function give_get_payment_form_id( $payment_id ) {
887
-	$payment = new Give_Payment( $payment_id );
886
+function give_get_payment_form_id($payment_id) {
887
+	$payment = new Give_Payment($payment_id);
888 888
 
889 889
 	return $payment->form_id;
890 890
 }
@@ -898,8 +898,8 @@  discard block
 block discarded – undo
898 898
  *
899 899
  * @return string $email User email.
900 900
  */
901
-function give_get_payment_user_email( $payment_id ) {
902
-	$payment = new Give_Payment( $payment_id );
901
+function give_get_payment_user_email($payment_id) {
902
+	$payment = new Give_Payment($payment_id);
903 903
 
904 904
 	return $payment->email;
905 905
 }
@@ -913,11 +913,11 @@  discard block
 block discarded – undo
913 913
  *
914 914
  * @return bool $is_guest_payment If the payment is associated with a user (false) or not (true)
915 915
  */
916
-function give_is_guest_payment( $payment_id ) {
917
-	$payment_user_id  = give_get_payment_user_id( $payment_id );
918
-	$is_guest_payment = ! empty( $payment_user_id ) && $payment_user_id > 0 ? false : true;
916
+function give_is_guest_payment($payment_id) {
917
+	$payment_user_id  = give_get_payment_user_id($payment_id);
918
+	$is_guest_payment = ! empty($payment_user_id) && $payment_user_id > 0 ? false : true;
919 919
 
920
-	return (bool) apply_filters( 'give_is_guest_payment', $is_guest_payment, $payment_id );
920
+	return (bool) apply_filters('give_is_guest_payment', $is_guest_payment, $payment_id);
921 921
 }
922 922
 
923 923
 /**
@@ -929,8 +929,8 @@  discard block
 block discarded – undo
929 929
  *
930 930
  * @return int $user_id User ID.
931 931
  */
932
-function give_get_payment_user_id( $payment_id ) {
933
-	$payment = new Give_Payment( $payment_id );
932
+function give_get_payment_user_id($payment_id) {
933
+	$payment = new Give_Payment($payment_id);
934 934
 
935 935
 	return $payment->user_id;
936 936
 }
@@ -944,8 +944,8 @@  discard block
 block discarded – undo
944 944
  *
945 945
  * @return int $payment->customer_id Donor ID.
946 946
  */
947
-function give_get_payment_donor_id( $payment_id ) {
948
-	$payment = new Give_Payment( $payment_id );
947
+function give_get_payment_donor_id($payment_id) {
948
+	$payment = new Give_Payment($payment_id);
949 949
 
950 950
 	return $payment->customer_id;
951 951
 }
@@ -959,8 +959,8 @@  discard block
 block discarded – undo
959 959
  *
960 960
  * @return string $ip User IP.
961 961
  */
962
-function give_get_payment_user_ip( $payment_id ) {
963
-	$payment = new Give_Payment( $payment_id );
962
+function give_get_payment_user_ip($payment_id) {
963
+	$payment = new Give_Payment($payment_id);
964 964
 
965 965
 	return $payment->ip;
966 966
 }
@@ -974,8 +974,8 @@  discard block
 block discarded – undo
974 974
  *
975 975
  * @return string $date The date the payment was completed.
976 976
  */
977
-function give_get_payment_completed_date( $payment_id = 0 ) {
978
-	$payment = new Give_Payment( $payment_id );
977
+function give_get_payment_completed_date($payment_id = 0) {
978
+	$payment = new Give_Payment($payment_id);
979 979
 
980 980
 	return $payment->completed_date;
981 981
 }
@@ -989,8 +989,8 @@  discard block
 block discarded – undo
989 989
  *
990 990
  * @return string $gateway Gateway.
991 991
  */
992
-function give_get_payment_gateway( $payment_id ) {
993
-	$payment = new Give_Payment( $payment_id );
992
+function give_get_payment_gateway($payment_id) {
993
+	$payment = new Give_Payment($payment_id);
994 994
 
995 995
 	return $payment->gateway;
996 996
 }
@@ -1004,8 +1004,8 @@  discard block
 block discarded – undo
1004 1004
  *
1005 1005
  * @return string $currency The currency code.
1006 1006
  */
1007
-function give_get_payment_currency_code( $payment_id = 0 ) {
1008
-	$payment = new Give_Payment( $payment_id );
1007
+function give_get_payment_currency_code($payment_id = 0) {
1008
+	$payment = new Give_Payment($payment_id);
1009 1009
 
1010 1010
 	return $payment->currency;
1011 1011
 }
@@ -1019,10 +1019,10 @@  discard block
 block discarded – undo
1019 1019
  *
1020 1020
  * @return string $currency The currency name.
1021 1021
  */
1022
-function give_get_payment_currency( $payment_id = 0 ) {
1023
-	$currency = give_get_payment_currency_code( $payment_id );
1022
+function give_get_payment_currency($payment_id = 0) {
1023
+	$currency = give_get_payment_currency_code($payment_id);
1024 1024
 
1025
-	return apply_filters( 'give_payment_currency', give_get_currency_name( $currency ), $payment_id );
1025
+	return apply_filters('give_payment_currency', give_get_currency_name($currency), $payment_id);
1026 1026
 }
1027 1027
 
1028 1028
 /**
@@ -1034,8 +1034,8 @@  discard block
 block discarded – undo
1034 1034
  *
1035 1035
  * @return string $key Donation key.
1036 1036
  */
1037
-function give_get_payment_key( $payment_id = 0 ) {
1038
-	$payment = new Give_Payment( $payment_id );
1037
+function give_get_payment_key($payment_id = 0) {
1038
+	$payment = new Give_Payment($payment_id);
1039 1039
 
1040 1040
 	return $payment->key;
1041 1041
 }
@@ -1051,8 +1051,8 @@  discard block
 block discarded – undo
1051 1051
  *
1052 1052
  * @return string $number Payment order number.
1053 1053
  */
1054
-function give_get_payment_number( $payment_id = 0 ) {
1055
-	$payment = new Give_Payment( $payment_id );
1054
+function give_get_payment_number($payment_id = 0) {
1055
+	$payment = new Give_Payment($payment_id);
1056 1056
 
1057 1057
 	return $payment->number;
1058 1058
 }
@@ -1066,23 +1066,23 @@  discard block
 block discarded – undo
1066 1066
  *
1067 1067
  * @return string      The formatted payment number.
1068 1068
  */
1069
-function give_format_payment_number( $number ) {
1069
+function give_format_payment_number($number) {
1070 1070
 
1071
-	if ( ! give_get_option( 'enable_sequential' ) ) {
1071
+	if ( ! give_get_option('enable_sequential')) {
1072 1072
 		return $number;
1073 1073
 	}
1074 1074
 
1075
-	if ( ! is_numeric( $number ) ) {
1075
+	if ( ! is_numeric($number)) {
1076 1076
 		return $number;
1077 1077
 	}
1078 1078
 
1079
-	$prefix  = give_get_option( 'sequential_prefix' );
1080
-	$number  = absint( $number );
1081
-	$postfix = give_get_option( 'sequential_postfix' );
1079
+	$prefix  = give_get_option('sequential_prefix');
1080
+	$number  = absint($number);
1081
+	$postfix = give_get_option('sequential_postfix');
1082 1082
 
1083
-	$formatted_number = $prefix . $number . $postfix;
1083
+	$formatted_number = $prefix.$number.$postfix;
1084 1084
 
1085
-	return apply_filters( 'give_format_payment_number', $formatted_number, $prefix, $number, $postfix );
1085
+	return apply_filters('give_format_payment_number', $formatted_number, $prefix, $number, $postfix);
1086 1086
 }
1087 1087
 
1088 1088
 /**
@@ -1096,17 +1096,17 @@  discard block
 block discarded – undo
1096 1096
  */
1097 1097
 function give_get_next_payment_number() {
1098 1098
 
1099
-	if ( ! give_get_option( 'enable_sequential' ) ) {
1099
+	if ( ! give_get_option('enable_sequential')) {
1100 1100
 		return false;
1101 1101
 	}
1102 1102
 
1103
-	$number           = get_option( 'give_last_payment_number' );
1104
-	$start            = give_get_option( 'sequential_start', 1 );
1103
+	$number           = get_option('give_last_payment_number');
1104
+	$start            = give_get_option('sequential_start', 1);
1105 1105
 	$increment_number = true;
1106 1106
 
1107
-	if ( false !== $number ) {
1107
+	if (false !== $number) {
1108 1108
 
1109
-		if ( empty( $number ) ) {
1109
+		if (empty($number)) {
1110 1110
 
1111 1111
 			$number           = $start;
1112 1112
 			$increment_number = false;
@@ -1115,24 +1115,24 @@  discard block
 block discarded – undo
1115 1115
 	} else {
1116 1116
 
1117 1117
 		// This case handles the first addition of the new option, as well as if it get's deleted for any reason.
1118
-		$payments     = new Give_Payments_Query( array(
1118
+		$payments = new Give_Payments_Query(array(
1119 1119
 			'number'  => 1,
1120 1120
 			'order'   => 'DESC',
1121 1121
 			'orderby' => 'ID',
1122 1122
 			'output'  => 'posts',
1123 1123
 			'fields'  => 'ids',
1124
-		) );
1124
+		));
1125 1125
 		$last_payment = $payments->get_payments();
1126 1126
 
1127
-		if ( ! empty( $last_payment ) ) {
1127
+		if ( ! empty($last_payment)) {
1128 1128
 
1129
-			$number = give_get_payment_number( $last_payment[0] );
1129
+			$number = give_get_payment_number($last_payment[0]);
1130 1130
 
1131 1131
 		}
1132 1132
 
1133
-		if ( ! empty( $number ) && $number !== (int) $last_payment[0] ) {
1133
+		if ( ! empty($number) && $number !== (int) $last_payment[0]) {
1134 1134
 
1135
-			$number = give_remove_payment_prefix_postfix( $number );
1135
+			$number = give_remove_payment_prefix_postfix($number);
1136 1136
 
1137 1137
 		} else {
1138 1138
 
@@ -1141,13 +1141,13 @@  discard block
 block discarded – undo
1141 1141
 		}
1142 1142
 	}// End if().
1143 1143
 
1144
-	$increment_number = apply_filters( 'give_increment_payment_number', $increment_number, $number );
1144
+	$increment_number = apply_filters('give_increment_payment_number', $increment_number, $number);
1145 1145
 
1146
-	if ( $increment_number ) {
1147
-		$number ++;
1146
+	if ($increment_number) {
1147
+		$number++;
1148 1148
 	}
1149 1149
 
1150
-	return apply_filters( 'give_get_next_payment_number', $number );
1150
+	return apply_filters('give_get_next_payment_number', $number);
1151 1151
 }
1152 1152
 
1153 1153
 /**
@@ -1159,25 +1159,25 @@  discard block
 block discarded – undo
1159 1159
  *
1160 1160
  * @return string The new Payment number without prefix and postfix.
1161 1161
  */
1162
-function give_remove_payment_prefix_postfix( $number ) {
1162
+function give_remove_payment_prefix_postfix($number) {
1163 1163
 
1164
-	$prefix  = give_get_option( 'sequential_prefix' );
1165
-	$postfix = give_get_option( 'sequential_postfix' );
1164
+	$prefix  = give_get_option('sequential_prefix');
1165
+	$postfix = give_get_option('sequential_postfix');
1166 1166
 
1167 1167
 	// Remove prefix.
1168
-	$number = preg_replace( '/' . $prefix . '/', '', $number, 1 );
1168
+	$number = preg_replace('/'.$prefix.'/', '', $number, 1);
1169 1169
 
1170 1170
 	// Remove the postfix.
1171
-	$length      = strlen( $number );
1172
-	$postfix_pos = strrpos( $number, $postfix );
1173
-	if ( false !== $postfix_pos ) {
1174
-		$number = substr_replace( $number, '', $postfix_pos, $length );
1171
+	$length      = strlen($number);
1172
+	$postfix_pos = strrpos($number, $postfix);
1173
+	if (false !== $postfix_pos) {
1174
+		$number = substr_replace($number, '', $postfix_pos, $length);
1175 1175
 	}
1176 1176
 
1177 1177
 	// Ensure it's a whole number.
1178
-	$number = intval( $number );
1178
+	$number = intval($number);
1179 1179
 
1180
-	return apply_filters( 'give_remove_payment_prefix_postfix', $number, $prefix, $postfix );
1180
+	return apply_filters('give_remove_payment_prefix_postfix', $number, $prefix, $postfix);
1181 1181
 
1182 1182
 }
1183 1183
 
@@ -1195,16 +1195,16 @@  discard block
 block discarded – undo
1195 1195
  *
1196 1196
  * @return string $amount Fully formatted donation amount.
1197 1197
  */
1198
-function give_donation_amount( $donation, $format_args = array() ) {
1198
+function give_donation_amount($donation, $format_args = array()) {
1199 1199
 	/* @var Give_Payment $donation */
1200
-	if ( ! ( $donation instanceof Give_Payment ) ) {
1201
-		$donation = new Give_Payment( absint( $donation ) );
1200
+	if ( ! ($donation instanceof Give_Payment)) {
1201
+		$donation = new Give_Payment(absint($donation));
1202 1202
 	}
1203 1203
 
1204 1204
 	$amount           = $donation->total;
1205 1205
 	$formatted_amount = $amount;
1206 1206
 
1207
-	if ( is_bool( $format_args ) ) {
1207
+	if (is_bool($format_args)) {
1208 1208
 		$format_args = array(
1209 1209
 			'currency' => (bool) $format_args,
1210 1210
 			'amount'   => (bool) $format_args,
@@ -1227,27 +1227,25 @@  discard block
 block discarded – undo
1227 1227
 		)
1228 1228
 	);
1229 1229
 
1230
-	if ( $format_args['amount'] || $format_args['currency'] ) {
1230
+	if ($format_args['amount'] || $format_args['currency']) {
1231 1231
 
1232
-		if ( $format_args['amount'] ) {
1232
+		if ($format_args['amount']) {
1233 1233
 
1234 1234
 			$formatted_amount = give_format_amount(
1235 1235
 				$amount,
1236
-				! is_array( $format_args['amount'] ) ?
1236
+				! is_array($format_args['amount']) ?
1237 1237
 					array(
1238 1238
 						'sanitize' => false,
1239 1239
 						'currency' => $donation->currency,
1240
-					) :
1241
-					$format_args['amount']
1240
+					) : $format_args['amount']
1242 1241
 			);
1243 1242
 		}
1244 1243
 
1245
-		if ( $format_args['currency'] ) {
1244
+		if ($format_args['currency']) {
1246 1245
 			$formatted_amount = give_currency_filter(
1247 1246
 				$formatted_amount,
1248
-				! is_array( $format_args['currency'] ) ?
1249
-					array( 'currency_code' => $donation->currency ) :
1250
-					$format_args['currency']
1247
+				! is_array($format_args['currency']) ?
1248
+					array('currency_code' => $donation->currency) : $format_args['currency']
1251 1249
 			);
1252 1250
 		}
1253 1251
 	}
@@ -1262,7 +1260,7 @@  discard block
 block discarded – undo
1262 1260
 	 * @param int    $donation_id      Donation ID.
1263 1261
 	 * @param string $type             Donation amount type.
1264 1262
 	 */
1265
-	return apply_filters( 'give_donation_amount', (string) $formatted_amount, $amount, $donation, $format_args );
1263
+	return apply_filters('give_donation_amount', (string) $formatted_amount, $amount, $donation, $format_args);
1266 1264
 }
1267 1265
 
1268 1266
 /**
@@ -1279,10 +1277,10 @@  discard block
 block discarded – undo
1279 1277
  *
1280 1278
  * @return array Fully formatted payment subtotal.
1281 1279
  */
1282
-function give_payment_subtotal( $payment_id = 0 ) {
1283
-	$subtotal = give_get_payment_subtotal( $payment_id );
1280
+function give_payment_subtotal($payment_id = 0) {
1281
+	$subtotal = give_get_payment_subtotal($payment_id);
1284 1282
 
1285
-	return give_currency_filter( give_format_amount( $subtotal, array( 'sanitize' => false ) ), array( 'currency_code' => give_get_payment_currency_code( $payment_id ) ) );
1283
+	return give_currency_filter(give_format_amount($subtotal, array('sanitize' => false)), array('currency_code' => give_get_payment_currency_code($payment_id)));
1286 1284
 }
1287 1285
 
1288 1286
 /**
@@ -1296,8 +1294,8 @@  discard block
 block discarded – undo
1296 1294
  *
1297 1295
  * @return float $subtotal Subtotal for payment (non formatted).
1298 1296
  */
1299
-function give_get_payment_subtotal( $payment_id = 0 ) {
1300
-	$payment = new Give_Payment( $payment_id );
1297
+function give_get_payment_subtotal($payment_id = 0) {
1298
+	$payment = new Give_Payment($payment_id);
1301 1299
 
1302 1300
 	return $payment->subtotal;
1303 1301
 }
@@ -1311,8 +1309,8 @@  discard block
 block discarded – undo
1311 1309
  *
1312 1310
  * @return string The donation ID.
1313 1311
  */
1314
-function give_get_payment_transaction_id( $payment_id = 0 ) {
1315
-	$payment = new Give_Payment( $payment_id );
1312
+function give_get_payment_transaction_id($payment_id = 0) {
1313
+	$payment = new Give_Payment($payment_id);
1316 1314
 
1317 1315
 	return $payment->transaction_id;
1318 1316
 }
@@ -1327,15 +1325,15 @@  discard block
 block discarded – undo
1327 1325
  *
1328 1326
  * @return bool|mixed
1329 1327
  */
1330
-function give_set_payment_transaction_id( $payment_id = 0, $transaction_id = '' ) {
1328
+function give_set_payment_transaction_id($payment_id = 0, $transaction_id = '') {
1331 1329
 
1332
-	if ( empty( $payment_id ) || empty( $transaction_id ) ) {
1330
+	if (empty($payment_id) || empty($transaction_id)) {
1333 1331
 		return false;
1334 1332
 	}
1335 1333
 
1336
-	$transaction_id = apply_filters( 'give_set_payment_transaction_id', $transaction_id, $payment_id );
1334
+	$transaction_id = apply_filters('give_set_payment_transaction_id', $transaction_id, $payment_id);
1337 1335
 
1338
-	return give_update_payment_meta( $payment_id, '_give_payment_transaction_id', $transaction_id );
1336
+	return give_update_payment_meta($payment_id, '_give_payment_transaction_id', $transaction_id);
1339 1337
 }
1340 1338
 
1341 1339
 /**
@@ -1348,10 +1346,10 @@  discard block
 block discarded – undo
1348 1346
  *
1349 1347
  * @return int $purchase Donation ID.
1350 1348
  */
1351
-function give_get_donation_id_by_key( $key ) {
1349
+function give_get_donation_id_by_key($key) {
1352 1350
 	global $wpdb;
1353 1351
 
1354
-	$meta_table = __give_v20_bc_table_details( 'payment' );
1352
+	$meta_table = __give_v20_bc_table_details('payment');
1355 1353
 
1356 1354
 	$purchase = $wpdb->get_var(
1357 1355
 		$wpdb->prepare(
@@ -1367,7 +1365,7 @@  discard block
 block discarded – undo
1367 1365
 		)
1368 1366
 	);
1369 1367
 
1370
-	if ( $purchase != null ) {
1368
+	if ($purchase != null) {
1371 1369
 		return $purchase;
1372 1370
 	}
1373 1371
 
@@ -1385,13 +1383,13 @@  discard block
 block discarded – undo
1385 1383
  *
1386 1384
  * @return int $purchase Donation ID.
1387 1385
  */
1388
-function give_get_purchase_id_by_transaction_id( $key ) {
1386
+function give_get_purchase_id_by_transaction_id($key) {
1389 1387
 	global $wpdb;
1390
-	$meta_table = __give_v20_bc_table_details( 'payment' );
1388
+	$meta_table = __give_v20_bc_table_details('payment');
1391 1389
 
1392
-	$purchase = $wpdb->get_var( $wpdb->prepare( "SELECT {$meta_table['column']['id']} FROM {$meta_table['name']} WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key ) );
1390
+	$purchase = $wpdb->get_var($wpdb->prepare("SELECT {$meta_table['column']['id']} FROM {$meta_table['name']} WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key));
1393 1391
 
1394
-	if ( $purchase != null ) {
1392
+	if ($purchase != null) {
1395 1393
 		return $purchase;
1396 1394
 	}
1397 1395
 
@@ -1408,23 +1406,23 @@  discard block
 block discarded – undo
1408 1406
  *
1409 1407
  * @return array $notes Donation Notes
1410 1408
  */
1411
-function give_get_payment_notes( $payment_id = 0, $search = '' ) {
1409
+function give_get_payment_notes($payment_id = 0, $search = '') {
1412 1410
 
1413
-	if ( empty( $payment_id ) && empty( $search ) ) {
1411
+	if (empty($payment_id) && empty($search)) {
1414 1412
 		return false;
1415 1413
 	}
1416 1414
 
1417
-	remove_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1418
-	remove_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10 );
1415
+	remove_action('pre_get_comments', 'give_hide_payment_notes', 10);
1416
+	remove_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10);
1419 1417
 
1420
-	$notes = get_comments( array(
1418
+	$notes = get_comments(array(
1421 1419
 		'post_id' => $payment_id,
1422 1420
 		'order'   => 'ASC',
1423 1421
 		'search'  => $search,
1424
-	) );
1422
+	));
1425 1423
 
1426
-	add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1427
-	add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 );
1424
+	add_action('pre_get_comments', 'give_hide_payment_notes', 10);
1425
+	add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2);
1428 1426
 
1429 1427
 	return $notes;
1430 1428
 }
@@ -1440,8 +1438,8 @@  discard block
 block discarded – undo
1440 1438
  *
1441 1439
  * @return int The new note ID
1442 1440
  */
1443
-function give_insert_payment_note( $payment_id = 0, $note = '' ) {
1444
-	if ( empty( $payment_id ) ) {
1441
+function give_insert_payment_note($payment_id = 0, $note = '') {
1442
+	if (empty($payment_id)) {
1445 1443
 		return false;
1446 1444
 	}
1447 1445
 
@@ -1453,14 +1451,14 @@  discard block
 block discarded – undo
1453 1451
 	 *
1454 1452
 	 * @since 1.0
1455 1453
 	 */
1456
-	do_action( 'give_pre_insert_payment_note', $payment_id, $note );
1454
+	do_action('give_pre_insert_payment_note', $payment_id, $note);
1457 1455
 
1458
-	$note_id = wp_insert_comment( wp_filter_comment( array(
1456
+	$note_id = wp_insert_comment(wp_filter_comment(array(
1459 1457
 		'comment_post_ID'      => $payment_id,
1460 1458
 		'comment_content'      => $note,
1461 1459
 		'user_id'              => is_admin() ? get_current_user_id() : 0,
1462
-		'comment_date'         => current_time( 'mysql' ),
1463
-		'comment_date_gmt'     => current_time( 'mysql', 1 ),
1460
+		'comment_date'         => current_time('mysql'),
1461
+		'comment_date_gmt'     => current_time('mysql', 1),
1464 1462
 		'comment_approved'     => 1,
1465 1463
 		'comment_parent'       => 0,
1466 1464
 		'comment_author'       => '',
@@ -1469,7 +1467,7 @@  discard block
 block discarded – undo
1469 1467
 		'comment_author_email' => '',
1470 1468
 		'comment_type'         => 'give_payment_note',
1471 1469
 
1472
-	) ) );
1470
+	)));
1473 1471
 
1474 1472
 	/**
1475 1473
 	 * Fires after payment note inserted.
@@ -1480,7 +1478,7 @@  discard block
 block discarded – undo
1480 1478
 	 *
1481 1479
 	 * @since 1.0
1482 1480
 	 */
1483
-	do_action( 'give_insert_payment_note', $note_id, $payment_id, $note );
1481
+	do_action('give_insert_payment_note', $note_id, $payment_id, $note);
1484 1482
 
1485 1483
 	return $note_id;
1486 1484
 }
@@ -1495,8 +1493,8 @@  discard block
 block discarded – undo
1495 1493
  *
1496 1494
  * @return bool True on success, false otherwise.
1497 1495
  */
1498
-function give_delete_payment_note( $comment_id = 0, $payment_id = 0 ) {
1499
-	if ( empty( $comment_id ) ) {
1496
+function give_delete_payment_note($comment_id = 0, $payment_id = 0) {
1497
+	if (empty($comment_id)) {
1500 1498
 		return false;
1501 1499
 	}
1502 1500
 
@@ -1508,9 +1506,9 @@  discard block
 block discarded – undo
1508 1506
 	 *
1509 1507
 	 * @since 1.0
1510 1508
 	 */
1511
-	do_action( 'give_pre_delete_payment_note', $comment_id, $payment_id );
1509
+	do_action('give_pre_delete_payment_note', $comment_id, $payment_id);
1512 1510
 
1513
-	$ret = wp_delete_comment( $comment_id, true );
1511
+	$ret = wp_delete_comment($comment_id, true);
1514 1512
 
1515 1513
 	/**
1516 1514
 	 * Fires after donation note deleted.
@@ -1520,7 +1518,7 @@  discard block
 block discarded – undo
1520 1518
 	 *
1521 1519
 	 * @since 1.0
1522 1520
 	 */
1523
-	do_action( 'give_post_delete_payment_note', $comment_id, $payment_id );
1521
+	do_action('give_post_delete_payment_note', $comment_id, $payment_id);
1524 1522
 
1525 1523
 	return $ret;
1526 1524
 }
@@ -1535,32 +1533,32 @@  discard block
 block discarded – undo
1535 1533
  *
1536 1534
  * @return string
1537 1535
  */
1538
-function give_get_payment_note_html( $note, $payment_id = 0 ) {
1536
+function give_get_payment_note_html($note, $payment_id = 0) {
1539 1537
 
1540
-	if ( is_numeric( $note ) ) {
1541
-		$note = get_comment( $note );
1538
+	if (is_numeric($note)) {
1539
+		$note = get_comment($note);
1542 1540
 	}
1543 1541
 
1544
-	if ( ! empty( $note->user_id ) ) {
1545
-		$user = get_userdata( $note->user_id );
1542
+	if ( ! empty($note->user_id)) {
1543
+		$user = get_userdata($note->user_id);
1546 1544
 		$user = $user->display_name;
1547 1545
 	} else {
1548
-		$user = __( 'System', 'give' );
1546
+		$user = __('System', 'give');
1549 1547
 	}
1550 1548
 
1551
-	$date_format = give_date_format() . ', ' . get_option( 'time_format' );
1549
+	$date_format = give_date_format().', '.get_option('time_format');
1552 1550
 
1553
-	$delete_note_url = wp_nonce_url( add_query_arg( array(
1551
+	$delete_note_url = wp_nonce_url(add_query_arg(array(
1554 1552
 		'give-action' => 'delete_payment_note',
1555 1553
 		'note_id'     => $note->comment_ID,
1556 1554
 		'payment_id'  => $payment_id,
1557
-	) ), 'give_delete_payment_note_' . $note->comment_ID );
1555
+	)), 'give_delete_payment_note_'.$note->comment_ID);
1558 1556
 
1559
-	$note_html = '<div class="give-payment-note" id="give-payment-note-' . $note->comment_ID . '">';
1557
+	$note_html = '<div class="give-payment-note" id="give-payment-note-'.$note->comment_ID.'">';
1560 1558
 	$note_html .= '<p>';
1561
-	$note_html .= '<strong>' . $user . '</strong>&nbsp;&ndash;&nbsp;<span style="color:#aaa;font-style:italic;">' . date_i18n( $date_format, strtotime( $note->comment_date ) ) . '</span><br/>';
1559
+	$note_html .= '<strong>'.$user.'</strong>&nbsp;&ndash;&nbsp;<span style="color:#aaa;font-style:italic;">'.date_i18n($date_format, strtotime($note->comment_date)).'</span><br/>';
1562 1560
 	$note_html .= $note->comment_content;
1563
-	$note_html .= '&nbsp;&ndash;&nbsp;<a href="' . esc_url( $delete_note_url ) . '" class="give-delete-payment-note" data-note-id="' . absint( $note->comment_ID ) . '" data-payment-id="' . absint( $payment_id ) . '" aria-label="' . __( 'Delete this donation note.', 'give' ) . '">' . __( 'Delete', 'give' ) . '</a>';
1561
+	$note_html .= '&nbsp;&ndash;&nbsp;<a href="'.esc_url($delete_note_url).'" class="give-delete-payment-note" data-note-id="'.absint($note->comment_ID).'" data-payment-id="'.absint($payment_id).'" aria-label="'.__('Delete this donation note.', 'give').'">'.__('Delete', 'give').'</a>';
1564 1562
 	$note_html .= '</p>';
1565 1563
 	$note_html .= '</div>';
1566 1564
 
@@ -1578,18 +1576,18 @@  discard block
 block discarded – undo
1578 1576
  *
1579 1577
  * @return void
1580 1578
  */
1581
-function give_hide_payment_notes( $query ) {
1582
-	if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '>=' ) ) {
1583
-		$types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array();
1584
-		if ( ! is_array( $types ) ) {
1585
-			$types = array( $types );
1579
+function give_hide_payment_notes($query) {
1580
+	if (version_compare(floatval(get_bloginfo('version')), '4.1', '>=')) {
1581
+		$types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array();
1582
+		if ( ! is_array($types)) {
1583
+			$types = array($types);
1586 1584
 		}
1587 1585
 		$types[]                           = 'give_payment_note';
1588 1586
 		$query->query_vars['type__not_in'] = $types;
1589 1587
 	}
1590 1588
 }
1591 1589
 
1592
-add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1590
+add_action('pre_get_comments', 'give_hide_payment_notes', 10);
1593 1591
 
1594 1592
 /**
1595 1593
  * Exclude notes (comments) on give_payment post type from showing in Recent Comments widgets
@@ -1601,15 +1599,15 @@  discard block
 block discarded – undo
1601 1599
  *
1602 1600
  * @return array $clauses Updated comment clauses.
1603 1601
  */
1604
-function give_hide_payment_notes_pre_41( $clauses, $wp_comment_query ) {
1605
-	if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '<' ) ) {
1602
+function give_hide_payment_notes_pre_41($clauses, $wp_comment_query) {
1603
+	if (version_compare(floatval(get_bloginfo('version')), '4.1', '<')) {
1606 1604
 		$clauses['where'] .= ' AND comment_type != "give_payment_note"';
1607 1605
 	}
1608 1606
 
1609 1607
 	return $clauses;
1610 1608
 }
1611 1609
 
1612
-add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 );
1610
+add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2);
1613 1611
 
1614 1612
 
1615 1613
 /**
@@ -1622,15 +1620,15 @@  discard block
 block discarded – undo
1622 1620
  *
1623 1621
  * @return string $where
1624 1622
  */
1625
-function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) {
1623
+function give_hide_payment_notes_from_feeds($where, $wp_comment_query) {
1626 1624
 	global $wpdb;
1627 1625
 
1628
-	$where .= $wpdb->prepare( ' AND comment_type != %s', 'give_payment_note' );
1626
+	$where .= $wpdb->prepare(' AND comment_type != %s', 'give_payment_note');
1629 1627
 
1630 1628
 	return $where;
1631 1629
 }
1632 1630
 
1633
-add_filter( 'comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2 );
1631
+add_filter('comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2);
1634 1632
 
1635 1633
 
1636 1634
 /**
@@ -1644,32 +1642,32 @@  discard block
 block discarded – undo
1644 1642
  *
1645 1643
  * @return array|object Array of comment counts.
1646 1644
  */
1647
-function give_remove_payment_notes_in_comment_counts( $stats, $post_id ) {
1645
+function give_remove_payment_notes_in_comment_counts($stats, $post_id) {
1648 1646
 	global $wpdb, $pagenow;
1649 1647
 
1650
-	if ( 'index.php' != $pagenow ) {
1648
+	if ('index.php' != $pagenow) {
1651 1649
 		return $stats;
1652 1650
 	}
1653 1651
 
1654 1652
 	$post_id = (int) $post_id;
1655 1653
 
1656
-	if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) {
1654
+	if (apply_filters('give_count_payment_notes_in_comments', false)) {
1657 1655
 		return $stats;
1658 1656
 	}
1659 1657
 
1660
-	$stats = Give_Cache::get_group( "comments-{$post_id}", 'counts' );
1658
+	$stats = Give_Cache::get_group("comments-{$post_id}", 'counts');
1661 1659
 
1662
-	if ( ! is_null( $stats ) ) {
1660
+	if ( ! is_null($stats)) {
1663 1661
 		return $stats;
1664 1662
 	}
1665 1663
 
1666 1664
 	$where = 'WHERE comment_type != "give_payment_note"';
1667 1665
 
1668
-	if ( $post_id > 0 ) {
1669
-		$where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id );
1666
+	if ($post_id > 0) {
1667
+		$where .= $wpdb->prepare(' AND comment_post_ID = %d', $post_id);
1670 1668
 	}
1671 1669
 
1672
-	$count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A );
1670
+	$count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A);
1673 1671
 
1674 1672
 	$total    = 0;
1675 1673
 	$approved = array(
@@ -1679,30 +1677,30 @@  discard block
 block discarded – undo
1679 1677
 		'trash'        => 'trash',
1680 1678
 		'post-trashed' => 'post-trashed',
1681 1679
 	);
1682
-	foreach ( (array) $count as $row ) {
1680
+	foreach ((array) $count as $row) {
1683 1681
 		// Don't count post-trashed toward totals.
1684
-		if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) {
1682
+		if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) {
1685 1683
 			$total += $row['num_comments'];
1686 1684
 		}
1687
-		if ( isset( $approved[ $row['comment_approved'] ] ) ) {
1688
-			$stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments'];
1685
+		if (isset($approved[$row['comment_approved']])) {
1686
+			$stats[$approved[$row['comment_approved']]] = $row['num_comments'];
1689 1687
 		}
1690 1688
 	}
1691 1689
 
1692 1690
 	$stats['total_comments'] = $total;
1693
-	foreach ( $approved as $key ) {
1694
-		if ( empty( $stats[ $key ] ) ) {
1695
-			$stats[ $key ] = 0;
1691
+	foreach ($approved as $key) {
1692
+		if (empty($stats[$key])) {
1693
+			$stats[$key] = 0;
1696 1694
 		}
1697 1695
 	}
1698 1696
 
1699 1697
 	$stats = (object) $stats;
1700
-	Give_Cache::set_group( "comments-{$post_id}", $stats, 'counts' );
1698
+	Give_Cache::set_group("comments-{$post_id}", $stats, 'counts');
1701 1699
 
1702 1700
 	return $stats;
1703 1701
 }
1704 1702
 
1705
-add_filter( 'wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2 );
1703
+add_filter('wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2);
1706 1704
 
1707 1705
 
1708 1706
 /**
@@ -1715,9 +1713,9 @@  discard block
 block discarded – undo
1715 1713
  *
1716 1714
  * @return string $where Modified where clause.
1717 1715
  */
1718
-function give_filter_where_older_than_week( $where = '' ) {
1716
+function give_filter_where_older_than_week($where = '') {
1719 1717
 	// Payments older than one week.
1720
-	$start = date( 'Y-m-d', strtotime( '-7 days' ) );
1718
+	$start = date('Y-m-d', strtotime('-7 days'));
1721 1719
 	$where .= " AND post_date <= '{$start}'";
1722 1720
 
1723 1721
 	return $where;
@@ -1737,13 +1735,13 @@  discard block
 block discarded – undo
1737 1735
  *
1738 1736
  * @return string $form_title Returns the full title if $only_level is false, otherwise returns the levels title.
1739 1737
  */
1740
-function give_get_donation_form_title( $donation, $args = array() ) {
1738
+function give_get_donation_form_title($donation, $args = array()) {
1741 1739
 
1742
-	if ( ! $donation instanceof Give_Payment ) {
1743
-		$donation = new Give_Payment( $donation );
1740
+	if ( ! $donation instanceof Give_Payment) {
1741
+		$donation = new Give_Payment($donation);
1744 1742
 	}
1745 1743
 
1746
-	if( ! $donation->ID ) {
1744
+	if ( ! $donation->ID) {
1747 1745
 		return '';
1748 1746
 	}
1749 1747
 
@@ -1752,7 +1750,7 @@  discard block
 block discarded – undo
1752 1750
 		'separator'  => '',
1753 1751
 	);
1754 1752
 
1755
-	$args = wp_parse_args( $args, $defaults );
1753
+	$args = wp_parse_args($args, $defaults);
1756 1754
 
1757 1755
 	$form_id     = $donation->form_id;
1758 1756
 	$price_id    = $donation->price_id;
@@ -1773,32 +1771,32 @@  discard block
 block discarded – undo
1773 1771
 		, false
1774 1772
 	);
1775 1773
 
1776
-	$form_title_html = Give_Cache::get_db_query( $cache_key );
1774
+	$form_title_html = Give_Cache::get_db_query($cache_key);
1777 1775
 
1778
-	if ( is_null( $form_title_html ) ) {
1779
-		if ( true === $only_level ) {
1776
+	if (is_null($form_title_html)) {
1777
+		if (true === $only_level) {
1780 1778
 			$form_title = '';
1781 1779
 		}
1782 1780
 
1783 1781
 		$form_title_html = $form_title;
1784 1782
 
1785
-		if ( 'custom' === $price_id ) {
1786
-			$custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true );
1787
-			$level_label        = ! empty( $custom_amount_text ) ? $custom_amount_text : __( 'Custom Amount', 'give' );
1788
-		} elseif ( give_has_variable_prices( $form_id ) ) {
1789
-			$level_label = give_get_price_option_name( $form_id, $price_id );
1783
+		if ('custom' === $price_id) {
1784
+			$custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true);
1785
+			$level_label        = ! empty($custom_amount_text) ? $custom_amount_text : __('Custom Amount', 'give');
1786
+		} elseif (give_has_variable_prices($form_id)) {
1787
+			$level_label = give_get_price_option_name($form_id, $price_id);
1790 1788
 		}
1791 1789
 
1792 1790
 		// Only add separator if there is a form title.
1793 1791
 		if (
1794
-			! empty( $form_title_html ) &&
1795
-			! empty( $level_label )
1792
+			! empty($form_title_html) &&
1793
+			! empty($level_label)
1796 1794
 		) {
1797 1795
 			$form_title_html .= " {$separator} ";
1798 1796
 		}
1799 1797
 
1800 1798
 		$form_title_html .= "<span class=\"donation-level-text-wrap\">{$level_label}</span>";
1801
-		Give_Cache::set_db_query( $cache_key, $form_title_html );
1799
+		Give_Cache::set_db_query($cache_key, $form_title_html);
1802 1800
 	}
1803 1801
 
1804 1802
 	/**
@@ -1806,7 +1804,7 @@  discard block
 block discarded – undo
1806 1804
 	 *
1807 1805
 	 * @since 1.0
1808 1806
 	 */
1809
-	return apply_filters( 'give_get_donation_form_title', $form_title_html, $donation->payment_meta, $donation );
1807
+	return apply_filters('give_get_donation_form_title', $form_title_html, $donation->payment_meta, $donation);
1810 1808
 }
1811 1809
 
1812 1810
 /**
@@ -1819,19 +1817,19 @@  discard block
 block discarded – undo
1819 1817
  *
1820 1818
  * @return string $price_id
1821 1819
  */
1822
-function give_get_price_id( $form_id, $price ) {
1820
+function give_get_price_id($form_id, $price) {
1823 1821
 	$price_id = null;
1824 1822
 
1825
-	if ( give_has_variable_prices( $form_id ) ) {
1823
+	if (give_has_variable_prices($form_id)) {
1826 1824
 
1827
-		$levels = give_get_meta( $form_id, '_give_donation_levels', true );
1825
+		$levels = give_get_meta($form_id, '_give_donation_levels', true);
1828 1826
 
1829
-		foreach ( $levels as $level ) {
1827
+		foreach ($levels as $level) {
1830 1828
 
1831
-			$level_amount = give_maybe_sanitize_amount( $level['_give_amount'] );
1829
+			$level_amount = give_maybe_sanitize_amount($level['_give_amount']);
1832 1830
 
1833 1831
 			// Check that this indeed the recurring price.
1834
-			if ( $level_amount == $price ) {
1832
+			if ($level_amount == $price) {
1835 1833
 
1836 1834
 				$price_id = $level['_give_id']['level_id'];
1837 1835
 				break;
@@ -1839,13 +1837,13 @@  discard block
 block discarded – undo
1839 1837
 			}
1840 1838
 		}
1841 1839
 
1842
-		if ( is_null( $price_id ) && give_is_custom_price_mode( $form_id ) ) {
1840
+		if (is_null($price_id) && give_is_custom_price_mode($form_id)) {
1843 1841
 			$price_id = 'custom';
1844 1842
 		}
1845 1843
 	}
1846 1844
 
1847 1845
 	// Price ID must be numeric or string.
1848
-	$price_id = ! is_numeric( $price_id ) && ! is_string( $price_id ) ? 0 : $price_id;
1846
+	$price_id = ! is_numeric($price_id) && ! is_string($price_id) ? 0 : $price_id;
1849 1847
 
1850 1848
 	/**
1851 1849
 	 * Filter the price id
@@ -1855,7 +1853,7 @@  discard block
 block discarded – undo
1855 1853
 	 * @param string $price_id
1856 1854
 	 * @param int    $form_id
1857 1855
 	 */
1858
-	return apply_filters( 'give_get_price_id', $price_id, $form_id );
1856
+	return apply_filters('give_get_price_id', $price_id, $form_id);
1859 1857
 }
1860 1858
 
1861 1859
 /**
@@ -1871,10 +1869,10 @@  discard block
 block discarded – undo
1871 1869
  *
1872 1870
  * @return string
1873 1871
  */
1874
-function give_get_form_dropdown( $args = array(), $echo = false ) {
1875
-	$form_dropdown_html = Give()->html->forms_dropdown( $args );
1872
+function give_get_form_dropdown($args = array(), $echo = false) {
1873
+	$form_dropdown_html = Give()->html->forms_dropdown($args);
1876 1874
 
1877
-	if ( ! $echo ) {
1875
+	if ( ! $echo) {
1878 1876
 		return $form_dropdown_html;
1879 1877
 	}
1880 1878
 
@@ -1891,17 +1889,17 @@  discard block
 block discarded – undo
1891 1889
  *
1892 1890
  * @return string|bool
1893 1891
  */
1894
-function give_get_form_variable_price_dropdown( $args = array(), $echo = false ) {
1892
+function give_get_form_variable_price_dropdown($args = array(), $echo = false) {
1895 1893
 
1896 1894
 	// Check for give form id.
1897
-	if ( empty( $args['id'] ) ) {
1895
+	if (empty($args['id'])) {
1898 1896
 		return false;
1899 1897
 	}
1900 1898
 
1901
-	$form = new Give_Donate_Form( $args['id'] );
1899
+	$form = new Give_Donate_Form($args['id']);
1902 1900
 
1903 1901
 	// Check if form has variable prices or not.
1904
-	if ( ! $form->ID || ! $form->has_variable_prices() ) {
1902
+	if ( ! $form->ID || ! $form->has_variable_prices()) {
1905 1903
 		return false;
1906 1904
 	}
1907 1905
 
@@ -1909,24 +1907,24 @@  discard block
 block discarded – undo
1909 1907
 	$variable_price_options = array();
1910 1908
 
1911 1909
 	// Check if multi donation form support custom donation or not.
1912
-	if ( $form->is_custom_price_mode() ) {
1913
-		$variable_price_options['custom'] = _x( 'Custom', 'custom donation dropdown item', 'give' );
1910
+	if ($form->is_custom_price_mode()) {
1911
+		$variable_price_options['custom'] = _x('Custom', 'custom donation dropdown item', 'give');
1914 1912
 	}
1915 1913
 
1916 1914
 	// Get variable price and ID from variable price array.
1917
-	foreach ( $variable_prices as $variable_price ) {
1918
-		$variable_price_options[ $variable_price['_give_id']['level_id'] ] = ! empty( $variable_price['_give_text'] ) ? $variable_price['_give_text'] : give_currency_filter( give_format_amount( $variable_price['_give_amount'], array( 'sanitize' => false ) ) );
1915
+	foreach ($variable_prices as $variable_price) {
1916
+		$variable_price_options[$variable_price['_give_id']['level_id']] = ! empty($variable_price['_give_text']) ? $variable_price['_give_text'] : give_currency_filter(give_format_amount($variable_price['_give_amount'], array('sanitize' => false)));
1919 1917
 	}
1920 1918
 
1921 1919
 	// Update options.
1922
-	$args = array_merge( $args, array(
1920
+	$args = array_merge($args, array(
1923 1921
 		'options' => $variable_price_options,
1924
-	) );
1922
+	));
1925 1923
 
1926 1924
 	// Generate select html.
1927
-	$form_dropdown_html = Give()->html->select( $args );
1925
+	$form_dropdown_html = Give()->html->select($args);
1928 1926
 
1929
-	if ( ! $echo ) {
1927
+	if ( ! $echo) {
1930 1928
 		return $form_dropdown_html;
1931 1929
 	}
1932 1930
 
@@ -1945,14 +1943,14 @@  discard block
 block discarded – undo
1945 1943
  *
1946 1944
  * @return string
1947 1945
  */
1948
-function give_get_payment_meta_price_id( $payment_meta ) {
1946
+function give_get_payment_meta_price_id($payment_meta) {
1949 1947
 
1950
-	if ( isset( $payment_meta['give_price_id'] ) ) {
1948
+	if (isset($payment_meta['give_price_id'])) {
1951 1949
 		$price_id = $payment_meta['give_price_id'];
1952
-	} elseif ( isset( $payment_meta['price_id'] ) ) {
1950
+	} elseif (isset($payment_meta['price_id'])) {
1953 1951
 		$price_id = $payment_meta['price_id'];
1954 1952
 	} else {
1955
-		$price_id = give_get_price_id( $payment_meta['give_form_id'], $payment_meta['price'] );
1953
+		$price_id = give_get_price_id($payment_meta['give_form_id'], $payment_meta['price']);
1956 1954
 	}
1957 1955
 
1958 1956
 	/**
@@ -1963,6 +1961,6 @@  discard block
 block discarded – undo
1963 1961
 	 * @param string $price_id
1964 1962
 	 * @param array  $payment_meta
1965 1963
 	 */
1966
-	return apply_filters( 'give_get_payment_meta_price_id', $price_id, $payment_meta );
1964
+	return apply_filters('give_get_payment_meta_price_id', $price_id, $payment_meta);
1967 1965
 
1968 1966
 }
Please login to merge, or discard this patch.
includes/class-give-db-payment-meta.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 		/* @var WPDB $wpdb */
51 51
 		global $wpdb;
52 52
 
53
-		$wpdb->paymentmeta = $this->table_name = $wpdb->prefix . 'give_paymentmeta';
53
+		$wpdb->paymentmeta = $this->table_name = $wpdb->prefix.'give_paymentmeta';
54 54
 		$this->primary_key = 'meta_id';
55 55
 		$this->version     = '1.0';
56 56
 
@@ -99,10 +99,10 @@  discard block
 block discarded – undo
99 99
 			KEY meta_key (meta_key)
100 100
 			) {$charset_collate};";
101 101
 
102
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
103
-		dbDelta( $sql );
102
+		require_once(ABSPATH.'wp-admin/includes/upgrade.php');
103
+		dbDelta($sql);
104 104
 
105
-		update_option( $this->table_name . '_db_version', $this->version );
105
+		update_option($this->table_name.'_db_version', $this->version);
106 106
 	}
107 107
 
108 108
 	/**
@@ -113,6 +113,6 @@  discard block
 block discarded – undo
113 113
 	 * @return bool
114 114
 	 */
115 115
 	protected function is_custom_meta_table_active() {
116
-		return give_has_upgrade_completed( 'v20_move_metadata_into_new_table' );
116
+		return give_has_upgrade_completed('v20_move_metadata_into_new_table');
117 117
 	}
118 118
 }
Please login to merge, or discard this patch.
includes/admin/abstract-admin-settings-page.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@  discard block
 block discarded – undo
9 9
  * @since       1.8
10 10
  */
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit; // Exit if accessed directly
14 14
 }
15 15
 
16
-if ( ! class_exists( 'Give_Settings_Page' ) ) :
16
+if ( ! class_exists('Give_Settings_Page')) :
17 17
 
18 18
 	/**
19 19
 	 * Give_Settings_Page.
@@ -70,25 +70,25 @@  discard block
 block discarded – undo
70 70
 			// Get current setting page.
71 71
 			$this->current_setting_page = give_get_current_setting_page();
72 72
 
73
-			add_filter( "give_default_setting_tab_section_{$this->id}", array( $this, 'set_default_setting_tab' ), 10 );
74
-			add_filter( "{$this->current_setting_page}_tabs_array", array( $this, 'add_settings_page' ), 20 );
75
-			add_action( "{$this->current_setting_page}_settings_{$this->id}_page", array( $this, 'output' ) );
73
+			add_filter("give_default_setting_tab_section_{$this->id}", array($this, 'set_default_setting_tab'), 10);
74
+			add_filter("{$this->current_setting_page}_tabs_array", array($this, 'add_settings_page'), 20);
75
+			add_action("{$this->current_setting_page}_settings_{$this->id}_page", array($this, 'output'));
76 76
 
77 77
 			// Output section only if exist.
78 78
 			$sections = $this->get_sections();
79
-			if ( ! empty( $sections ) ) {
80
-				add_action( "{$this->current_setting_page}_sections_{$this->id}_page", array(
79
+			if ( ! empty($sections)) {
80
+				add_action("{$this->current_setting_page}_sections_{$this->id}_page", array(
81 81
 					$this,
82 82
 					'output_sections',
83
-				) );
83
+				));
84 84
 			}
85 85
 
86 86
 			// Save hide button by default.
87 87
 			$GLOBALS['give_hide_save_button'] = true;
88 88
 
89 89
 			// Enable saving feature.
90
-			if ( $this->enable_save ) {
91
-				add_action( "{$this->current_setting_page}_save_{$this->id}", array( $this, 'save' ) );
90
+			if ($this->enable_save) {
91
+				add_action("{$this->current_setting_page}_save_{$this->id}", array($this, 'save'));
92 92
 			}
93 93
 		}
94 94
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 		 *
114 114
 		 * @return string
115 115
 		 */
116
-		function set_default_setting_tab( $setting_tab ) {
116
+		function set_default_setting_tab($setting_tab) {
117 117
 			return $this->default_tab;
118 118
 		}
119 119
 
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
 		 *
127 127
 		 * @return array
128 128
 		 */
129
-		public function add_settings_page( $pages ) {
130
-			$pages[ $this->id ] = $this->label;
129
+		public function add_settings_page($pages) {
130
+			$pages[$this->id] = $this->label;
131 131
 
132 132
 			return $pages;
133 133
 		}
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 			 *
147 147
 			 * @param  array $settings
148 148
 			 */
149
-			$settings = apply_filters( 'give_get_settings_' . $this->id, array() );
149
+			$settings = apply_filters('give_get_settings_'.$this->id, array());
150 150
 
151 151
 			// Output.
152 152
 			return $settings;
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 		 * @return array
160 160
 		 */
161 161
 		public function get_sections() {
162
-			return apply_filters( 'give_get_sections_' . $this->id, array() );
162
+			return apply_filters('give_get_sections_'.$this->id, array());
163 163
 		}
164 164
 
165 165
 		/**
@@ -176,39 +176,39 @@  discard block
 block discarded – undo
176 176
 			$sections = $this->get_sections();
177 177
 
178 178
 			// Bailout.
179
-			if ( empty( $sections ) ) {
179
+			if (empty($sections)) {
180 180
 				return;
181 181
 			}
182 182
 
183 183
 			// Show section settings only if setting section exist.
184
-			if ( $current_section && ! in_array( $current_section, array_keys( $sections ) ) ) {
185
-				echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>';
184
+			if ($current_section && ! in_array($current_section, array_keys($sections))) {
185
+				echo '<div class="error"><p>'.__('Oops, this settings page does not exist.', 'give').'</p></div>';
186 186
 				$GLOBALS['give_hide_save_button'] = true;
187 187
 
188 188
 				return;
189 189
 			}
190 190
 
191
-			if ( is_null( $this->current_setting_page ) ) {
191
+			if (is_null($this->current_setting_page)) {
192 192
 				$this->current_setting_page = give_get_current_setting_page();
193 193
 			}
194 194
 
195 195
 			$section_list = array();
196
-			foreach ( $sections as $id => $label ) {
196
+			foreach ($sections as $id => $label) {
197 197
 				/**
198 198
 				 * Fire the filter to hide particular section on tab.
199 199
 				 *
200 200
 				 * @since 2.0
201 201
 				 */
202
-				if ( apply_filters( "give_hide_section_{$id}_on_{$this->id}_page", false, $sections, $this->id ) ) {
202
+				if (apply_filters("give_hide_section_{$id}_on_{$this->id}_page", false, $sections, $this->id)) {
203 203
 					continue;
204 204
 				}
205 205
 
206
-				$section_list[] = '<li><a href="' . admin_url( 'edit.php?post_type=give_forms&page=' . $this->current_setting_page . '&tab=' . $this->id . '&section=' . sanitize_title( $id ) ) . '" class="' . ( $current_section == $id ? 'current' : '' ) . '">' . $label . '</a>';
206
+				$section_list[] = '<li><a href="'.admin_url('edit.php?post_type=give_forms&page='.$this->current_setting_page.'&tab='.$this->id.'&section='.sanitize_title($id)).'" class="'.($current_section == $id ? 'current' : '').'">'.$label.'</a>';
207 207
 			}
208 208
 
209 209
 			echo sprintf(
210 210
 				'<ul class="subsubsub">%s</ul><br class="clear" /><hr>',
211
-				implode( ' | </li>', $section_list )
211
+				implode(' | </li>', $section_list)
212 212
 			);
213 213
 		}
214 214
 
@@ -221,13 +221,13 @@  discard block
 block discarded – undo
221 221
 		 * @return void
222 222
 		 */
223 223
 		public function output() {
224
-			if ( $this->enable_save ) {
224
+			if ($this->enable_save) {
225 225
 				$GLOBALS['give_hide_save_button'] = false;
226 226
 			}
227 227
 
228 228
 			$settings = $this->get_settings();
229 229
 
230
-			Give_Admin_Settings::output_fields( $settings, 'give_settings' );
230
+			Give_Admin_Settings::output_fields($settings, 'give_settings');
231 231
 		}
232 232
 
233 233
 		/**
@@ -240,14 +240,14 @@  discard block
 block discarded – undo
240 240
 			$settings        = $this->get_settings();
241 241
 			$current_section = give_get_current_setting_section();
242 242
 
243
-			Give_Admin_Settings::save_fields( $settings, 'give_settings' );
243
+			Give_Admin_Settings::save_fields($settings, 'give_settings');
244 244
 
245 245
 			/**
246 246
 			 * Trigger Action
247 247
 			 *
248 248
 			 * @since 1.8
249 249
 			 */
250
-			do_action( 'give_update_options_' . $this->id . '_' . $current_section );
250
+			do_action('give_update_options_'.$this->id.'_'.$current_section);
251 251
 		}
252 252
 
253 253
 		/**
@@ -264,11 +264,11 @@  discard block
 block discarded – undo
264 264
 			$section         = $this->get_sections();
265 265
 			$current_section = give_get_current_setting_section();
266 266
 
267
-			if ( array_key_exists( $current_section, $section ) ) {
268
-				$heading[] = $section[ $current_section ];
267
+			if (array_key_exists($current_section, $section)) {
268
+				$heading[] = $section[$current_section];
269 269
 			}
270 270
 
271
-			return array_unique( $heading );
271
+			return array_unique($heading);
272 272
 		}
273 273
 
274 274
 		/**
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 		public function get_heading_html() {
283 283
 			return sprintf(
284 284
 				'<h1 class="wp-heading-inline">%s</h1><hr class="wp-header-end">',
285
-				implode( ' <span class="give-settings-heading-sep dashicons dashicons-arrow-right-alt2"></span> ', $this->get_heading() )
285
+				implode(' <span class="give-settings-heading-sep dashicons dashicons-arrow-right-alt2"></span> ', $this->get_heading())
286 286
 			);
287 287
 		}
288 288
 	}
Please login to merge, or discard this patch.