Test Failed
Push — master ( 553162...c86db0 )
by Devin
03:45
created
includes/class-give-donor.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -918,7 +918,7 @@
 block discarded – undo
918 918
 	 * @access public
919 919
 	 *
920 920
 	 * @param  string $meta_key Metadata name. Default is empty.
921
-	 * @param  mixed $meta_value Optional. Metadata value. Default is empty.
921
+	 * @param  string $meta_value Optional. Metadata value. Default is empty.
922 922
 	 *
923 923
 	 * @return bool               False for failure. True for success.
924 924
 	 */
Please login to merge, or discard this patch.
Spacing   +170 added lines, -170 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
 
@@ -139,32 +139,32 @@  discard block
 block discarded – undo
139 139
 	 * @param bool $_id_or_email
140 140
 	 * @param bool $by_user_id
141 141
 	 */
142
-	public function __construct( $_id_or_email = false, $by_user_id = false ) {
142
+	public function __construct($_id_or_email = false, $by_user_id = false) {
143 143
 
144 144
 		$this->db = Give()->donors;
145 145
 
146 146
 		if (
147 147
 			false === $_id_or_email
148
-			|| ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) )
148
+			|| (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email))
149 149
 		) {
150 150
 			return false;
151 151
 		}
152 152
 
153
-		$by_user_id = is_bool( $by_user_id ) ? $by_user_id : false;
153
+		$by_user_id = is_bool($by_user_id) ? $by_user_id : false;
154 154
 
155
-		if ( is_numeric( $_id_or_email ) ) {
155
+		if (is_numeric($_id_or_email)) {
156 156
 			$field = $by_user_id ? 'user_id' : 'id';
157 157
 		} else {
158 158
 			$field = 'email';
159 159
 		}
160 160
 
161
-		$donor = $this->db->get_donor_by( $field, $_id_or_email );
161
+		$donor = $this->db->get_donor_by($field, $_id_or_email);
162 162
 
163
-		if ( empty( $donor ) || ! is_object( $donor ) ) {
163
+		if (empty($donor) || ! is_object($donor)) {
164 164
 			return false;
165 165
 		}
166 166
 
167
-		$this->setup_donor( $donor );
167
+		$this->setup_donor($donor);
168 168
 
169 169
 	}
170 170
 
@@ -180,15 +180,15 @@  discard block
 block discarded – undo
180 180
 	 *
181 181
 	 * @return bool             If the setup was successful or not.
182 182
 	 */
183
-	private function setup_donor( $donor ) {
183
+	private function setup_donor($donor) {
184 184
 
185
-		if ( ! is_object( $donor ) ) {
185
+		if ( ! is_object($donor)) {
186 186
 			return false;
187 187
 		}
188 188
 
189
-		foreach ( $donor as $key => $value ) {
189
+		foreach ($donor as $key => $value) {
190 190
 
191
-			switch ( $key ) {
191
+			switch ($key) {
192 192
 
193 193
 				case 'notes':
194 194
 					$this->$key = $this->get_notes();
@@ -202,11 +202,11 @@  discard block
 block discarded – undo
202 202
 		}
203 203
 
204 204
 		// Get donor's all email including primary email.
205
-		$this->emails = (array) $this->get_meta( 'additional_email', false );
206
-		$this->emails = array( 'primary' => $this->email ) + $this->emails;
205
+		$this->emails = (array) $this->get_meta('additional_email', false);
206
+		$this->emails = array('primary' => $this->email) + $this->emails;
207 207
 
208 208
 		// Donor ID and email are the only things that are necessary, make sure they exist.
209
-		if ( ! empty( $this->id ) && ! empty( $this->email ) ) {
209
+		if ( ! empty($this->id) && ! empty($this->email)) {
210 210
 			return true;
211 211
 		}
212 212
 
@@ -223,16 +223,16 @@  discard block
 block discarded – undo
223 223
 	 *
224 224
 	 * @return mixed|\WP_Error
225 225
 	 */
226
-	public function __get( $key ) {
226
+	public function __get($key) {
227 227
 
228
-		if ( method_exists( $this, 'get_' . $key ) ) {
228
+		if (method_exists($this, 'get_'.$key)) {
229 229
 
230
-			return call_user_func( array( $this, 'get_' . $key ) );
230
+			return call_user_func(array($this, 'get_'.$key));
231 231
 
232 232
 		} else {
233 233
 
234 234
 			/* translators: %s: property key */
235
-			return new WP_Error( 'give-donor-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) );
235
+			return new WP_Error('give-donor-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key));
236 236
 
237 237
 		}
238 238
 
@@ -248,9 +248,9 @@  discard block
 block discarded – undo
248 248
 	 *
249 249
 	 * @return bool|int    False if not a valid creation, donor ID if user is found or valid creation.
250 250
 	 */
251
-	public function create( $data = array() ) {
251
+	public function create($data = array()) {
252 252
 
253
-		if ( $this->id != 0 || empty( $data ) ) {
253
+		if ($this->id != 0 || empty($data)) {
254 254
 			return false;
255 255
 		}
256 256
 
@@ -258,15 +258,15 @@  discard block
 block discarded – undo
258 258
 			'payment_ids' => '',
259 259
 		);
260 260
 
261
-		$args = wp_parse_args( $data, $defaults );
262
-		$args = $this->sanitize_columns( $args );
261
+		$args = wp_parse_args($data, $defaults);
262
+		$args = $this->sanitize_columns($args);
263 263
 
264
-		if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) {
264
+		if (empty($args['email']) || ! is_email($args['email'])) {
265 265
 			return false;
266 266
 		}
267 267
 
268
-		if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) {
269
-			$args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) );
268
+		if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) {
269
+			$args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids'])));
270 270
 		}
271 271
 
272 272
 		/**
@@ -276,18 +276,18 @@  discard block
 block discarded – undo
276 276
 		 *
277 277
 		 * @param array $args Donor attributes.
278 278
 		 */
279
-		do_action( 'give_donor_pre_create', $args );
279
+		do_action('give_donor_pre_create', $args);
280 280
 
281 281
 		$created = false;
282 282
 
283 283
 		// The DB class 'add' implies an update if the donor being asked to be created already exists
284
-		if ( $this->db->add( $data ) ) {
284
+		if ($this->db->add($data)) {
285 285
 
286 286
 			// We've successfully added/updated the donor, reset the class vars with the new data
287
-			$donor = $this->db->get_donor_by( 'email', $args['email'] );
287
+			$donor = $this->db->get_donor_by('email', $args['email']);
288 288
 
289 289
 			// Setup the donor data with the values from DB
290
-			$this->setup_donor( $donor );
290
+			$this->setup_donor($donor);
291 291
 
292 292
 			$created = $this->id;
293 293
 		}
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 		 * @param bool|int $created False if not a valid creation, donor ID if user is found or valid creation.
301 301
 		 * @param array $args Customer attributes.
302 302
 		 */
303
-		do_action( 'give_donor_post_create', $created, $args );
303
+		do_action('give_donor_post_create', $created, $args);
304 304
 
305 305
 		return $created;
306 306
 
@@ -316,13 +316,13 @@  discard block
 block discarded – undo
316 316
 	 *
317 317
 	 * @return bool        If the update was successful or not.
318 318
 	 */
319
-	public function update( $data = array() ) {
319
+	public function update($data = array()) {
320 320
 
321
-		if ( empty( $data ) ) {
321
+		if (empty($data)) {
322 322
 			return false;
323 323
 		}
324 324
 
325
-		$data = $this->sanitize_columns( $data );
325
+		$data = $this->sanitize_columns($data);
326 326
 
327 327
 		/**
328 328
 		 * Fires before updating donors.
@@ -332,14 +332,14 @@  discard block
 block discarded – undo
332 332
 		 * @param int $donor_id Donor id.
333 333
 		 * @param array $data Donor attributes.
334 334
 		 */
335
-		do_action( 'give_donor_pre_update', $this->id, $data );
335
+		do_action('give_donor_pre_update', $this->id, $data);
336 336
 
337 337
 		$updated = false;
338 338
 
339
-		if ( $this->db->update( $this->id, $data ) ) {
339
+		if ($this->db->update($this->id, $data)) {
340 340
 
341
-			$donor = $this->db->get_donor_by( 'id', $this->id );
342
-			$this->setup_donor( $donor );
341
+			$donor = $this->db->get_donor_by('id', $this->id);
342
+			$this->setup_donor($donor);
343 343
 
344 344
 			$updated = true;
345 345
 		}
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 		 * @param int $donor_id Donor id.
354 354
 		 * @param array $data Donor attributes.
355 355
 		 */
356
-		do_action( 'give_donor_post_update', $updated, $this->id, $data );
356
+		do_action('give_donor_post_update', $updated, $this->id, $data);
357 357
 
358 358
 		return $updated;
359 359
 	}
@@ -371,27 +371,27 @@  discard block
 block discarded – undo
371 371
 	 *
372 372
 	 * @return bool            If the attachment was successfully.
373 373
 	 */
374
-	public function attach_payment( $payment_id = 0, $update_stats = true ) {
374
+	public function attach_payment($payment_id = 0, $update_stats = true) {
375 375
 
376
-		if ( empty( $payment_id ) ) {
376
+		if (empty($payment_id)) {
377 377
 			return false;
378 378
 		}
379 379
 
380
-		if ( empty( $this->payment_ids ) ) {
380
+		if (empty($this->payment_ids)) {
381 381
 
382 382
 			$new_payment_ids = $payment_id;
383 383
 
384 384
 		} else {
385 385
 
386
-			$payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) );
386
+			$payment_ids = array_map('absint', explode(',', $this->payment_ids));
387 387
 
388
-			if ( in_array( $payment_id, $payment_ids ) ) {
388
+			if (in_array($payment_id, $payment_ids)) {
389 389
 				$update_stats = false;
390 390
 			}
391 391
 
392 392
 			$payment_ids[] = $payment_id;
393 393
 
394
-			$new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
394
+			$new_payment_ids = implode(',', array_unique(array_values($payment_ids)));
395 395
 
396 396
 		}
397 397
 
@@ -403,20 +403,20 @@  discard block
 block discarded – undo
403 403
 		 * @param int $payment_id Payment id.
404 404
 		 * @param int $donor_id Customer id.
405 405
 		 */
406
-		do_action( 'give_donor_pre_attach_payment', $payment_id, $this->id );
406
+		do_action('give_donor_pre_attach_payment', $payment_id, $this->id);
407 407
 
408
-		$payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) );
408
+		$payment_added = $this->update(array('payment_ids' => $new_payment_ids));
409 409
 
410
-		if ( $payment_added ) {
410
+		if ($payment_added) {
411 411
 
412 412
 			$this->payment_ids = $new_payment_ids;
413 413
 
414 414
 			// We added this payment successfully, increment the stats
415
-			if ( $update_stats ) {
416
-				$payment_amount = give_get_payment_amount( $payment_id );
415
+			if ($update_stats) {
416
+				$payment_amount = give_get_payment_amount($payment_id);
417 417
 
418
-				if ( ! empty( $payment_amount ) ) {
419
-					$this->increase_value( $payment_amount );
418
+				if ( ! empty($payment_amount)) {
419
+					$this->increase_value($payment_amount);
420 420
 				}
421 421
 
422 422
 				$this->increase_purchase_count();
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 		 * @param int $payment_id Payment id.
433 433
 		 * @param int $donor_id Donor id.
434 434
 		 */
435
-		do_action( 'give_donor_post_attach_payment', $payment_added, $payment_id, $this->id );
435
+		do_action('give_donor_post_attach_payment', $payment_added, $payment_id, $this->id);
436 436
 
437 437
 		return $payment_added;
438 438
 	}
@@ -450,33 +450,33 @@  discard block
 block discarded – undo
450 450
 	 *
451 451
 	 * @return boolean               If the removal was successful.
452 452
 	 */
453
-	public function remove_payment( $payment_id = 0, $update_stats = true ) {
453
+	public function remove_payment($payment_id = 0, $update_stats = true) {
454 454
 
455
-		if ( empty( $payment_id ) ) {
455
+		if (empty($payment_id)) {
456 456
 			return false;
457 457
 		}
458 458
 
459
-		$payment = new Give_Payment( $payment_id );
459
+		$payment = new Give_Payment($payment_id);
460 460
 
461
-		if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) {
461
+		if ('publish' !== $payment->status && 'revoked' !== $payment->status) {
462 462
 			$update_stats = false;
463 463
 		}
464 464
 
465 465
 		$new_payment_ids = '';
466 466
 
467
-		if ( ! empty( $this->payment_ids ) ) {
467
+		if ( ! empty($this->payment_ids)) {
468 468
 
469
-			$payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) );
469
+			$payment_ids = array_map('absint', explode(',', $this->payment_ids));
470 470
 
471
-			$pos = array_search( $payment_id, $payment_ids );
472
-			if ( false === $pos ) {
471
+			$pos = array_search($payment_id, $payment_ids);
472
+			if (false === $pos) {
473 473
 				return false;
474 474
 			}
475 475
 
476
-			unset( $payment_ids[ $pos ] );
477
-			$payment_ids = array_filter( $payment_ids );
476
+			unset($payment_ids[$pos]);
477
+			$payment_ids = array_filter($payment_ids);
478 478
 
479
-			$new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
479
+			$new_payment_ids = implode(',', array_unique(array_values($payment_ids)));
480 480
 
481 481
 		}
482 482
 
@@ -488,20 +488,20 @@  discard block
 block discarded – undo
488 488
 		 * @param int $payment_id Payment id.
489 489
 		 * @param int $donor_id Customer id.
490 490
 		 */
491
-		do_action( 'give_donor_pre_remove_payment', $payment_id, $this->id );
491
+		do_action('give_donor_pre_remove_payment', $payment_id, $this->id);
492 492
 
493
-		$payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) );
493
+		$payment_removed = $this->update(array('payment_ids' => $new_payment_ids));
494 494
 
495
-		if ( $payment_removed ) {
495
+		if ($payment_removed) {
496 496
 
497 497
 			$this->payment_ids = $new_payment_ids;
498 498
 
499
-			if ( $update_stats ) {
499
+			if ($update_stats) {
500 500
 				// We removed this payment successfully, decrement the stats
501
-				$payment_amount = give_get_payment_amount( $payment_id );
501
+				$payment_amount = give_get_payment_amount($payment_id);
502 502
 
503
-				if ( ! empty( $payment_amount ) ) {
504
-					$this->decrease_value( $payment_amount );
503
+				if ( ! empty($payment_amount)) {
504
+					$this->decrease_value($payment_amount);
505 505
 				}
506 506
 
507 507
 				$this->decrease_donation_count();
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 		 * @param int $payment_id Payment id.
518 518
 		 * @param int $donor_id Donor id.
519 519
 		 */
520
-		do_action( 'give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id );
520
+		do_action('give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id);
521 521
 
522 522
 		return $payment_removed;
523 523
 
@@ -533,10 +533,10 @@  discard block
 block discarded – undo
533 533
 	 *
534 534
 	 * @return int        The donation count.
535 535
 	 */
536
-	public function increase_purchase_count( $count = 1 ) {
536
+	public function increase_purchase_count($count = 1) {
537 537
 
538 538
 		// Make sure it's numeric and not negative.
539
-		if ( ! is_numeric( $count ) || $count != absint( $count ) ) {
539
+		if ( ! is_numeric($count) || $count != absint($count)) {
540 540
 			return false;
541 541
 		}
542 542
 
@@ -550,9 +550,9 @@  discard block
 block discarded – undo
550 550
 		 * @param int $count The number to increase by.
551 551
 		 * @param int $donor_id Donor id.
552 552
 		 */
553
-		do_action( 'give_donor_pre_increase_donation_count', $count, $this->id );
553
+		do_action('give_donor_pre_increase_donation_count', $count, $this->id);
554 554
 
555
-		if ( $this->update( array( 'purchase_count' => $new_total ) ) ) {
555
+		if ($this->update(array('purchase_count' => $new_total))) {
556 556
 			$this->purchase_count = $new_total;
557 557
 		}
558 558
 
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
 		 * @param int $count The number increased by.
566 566
 		 * @param int $donor_id Donor id.
567 567
 		 */
568
-		do_action( 'give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id );
568
+		do_action('give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id);
569 569
 
570 570
 		return $this->purchase_count;
571 571
 	}
@@ -580,16 +580,16 @@  discard block
 block discarded – undo
580 580
 	 *
581 581
 	 * @return mixed      If successful, the new count, otherwise false.
582 582
 	 */
583
-	public function decrease_donation_count( $count = 1 ) {
583
+	public function decrease_donation_count($count = 1) {
584 584
 
585 585
 		// Make sure it's numeric and not negative
586
-		if ( ! is_numeric( $count ) || $count != absint( $count ) ) {
586
+		if ( ! is_numeric($count) || $count != absint($count)) {
587 587
 			return false;
588 588
 		}
589 589
 
590 590
 		$new_total = (int) $this->purchase_count - (int) $count;
591 591
 
592
-		if ( $new_total < 0 ) {
592
+		if ($new_total < 0) {
593 593
 			$new_total = 0;
594 594
 		}
595 595
 
@@ -601,9 +601,9 @@  discard block
 block discarded – undo
601 601
 		 * @param int $count The number to decrease by.
602 602
 		 * @param int $donor_id Customer id.
603 603
 		 */
604
-		do_action( 'give_donor_pre_decrease_donation_count', $count, $this->id );
604
+		do_action('give_donor_pre_decrease_donation_count', $count, $this->id);
605 605
 
606
-		if ( $this->update( array( 'purchase_count' => $new_total ) ) ) {
606
+		if ($this->update(array('purchase_count' => $new_total))) {
607 607
 			$this->purchase_count = $new_total;
608 608
 		}
609 609
 
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
 		 * @param int $count The number decreased by.
617 617
 		 * @param int $donor_id Donor id.
618 618
 		 */
619
-		do_action( 'give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id );
619
+		do_action('give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id);
620 620
 
621 621
 		return $this->purchase_count;
622 622
 	}
@@ -631,9 +631,9 @@  discard block
 block discarded – undo
631 631
 	 *
632 632
 	 * @return mixed        If successful, the new value, otherwise false.
633 633
 	 */
634
-	public function increase_value( $value = 0.00 ) {
634
+	public function increase_value($value = 0.00) {
635 635
 
636
-		$new_value = floatval( $this->purchase_value ) + $value;
636
+		$new_value = floatval($this->purchase_value) + $value;
637 637
 
638 638
 		/**
639 639
 		 * Fires before increasing donor lifetime value.
@@ -643,9 +643,9 @@  discard block
 block discarded – undo
643 643
 		 * @param float $value The value to increase by.
644 644
 		 * @param int $donor_id Customer id.
645 645
 		 */
646
-		do_action( 'give_donor_pre_increase_value', $value, $this->id );
646
+		do_action('give_donor_pre_increase_value', $value, $this->id);
647 647
 
648
-		if ( $this->update( array( 'purchase_value' => $new_value ) ) ) {
648
+		if ($this->update(array('purchase_value' => $new_value))) {
649 649
 			$this->purchase_value = $new_value;
650 650
 		}
651 651
 
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
 		 * @param float $value The value increased by.
659 659
 		 * @param int $donor_id Donor id.
660 660
 		 */
661
-		do_action( 'give_donor_post_increase_value', $this->purchase_value, $value, $this->id );
661
+		do_action('give_donor_post_increase_value', $this->purchase_value, $value, $this->id);
662 662
 
663 663
 		return $this->purchase_value;
664 664
 	}
@@ -673,11 +673,11 @@  discard block
 block discarded – undo
673 673
 	 *
674 674
 	 * @return mixed        If successful, the new value, otherwise false.
675 675
 	 */
676
-	public function decrease_value( $value = 0.00 ) {
676
+	public function decrease_value($value = 0.00) {
677 677
 
678
-		$new_value = floatval( $this->purchase_value ) - $value;
678
+		$new_value = floatval($this->purchase_value) - $value;
679 679
 
680
-		if ( $new_value < 0 ) {
680
+		if ($new_value < 0) {
681 681
 			$new_value = 0.00;
682 682
 		}
683 683
 
@@ -689,9 +689,9 @@  discard block
 block discarded – undo
689 689
 		 * @param float $value The value to decrease by.
690 690
 		 * @param int $donor_id Donor id.
691 691
 		 */
692
-		do_action( 'give_donor_pre_decrease_value', $value, $this->id );
692
+		do_action('give_donor_pre_decrease_value', $value, $this->id);
693 693
 
694
-		if ( $this->update( array( 'purchase_value' => $new_value ) ) ) {
694
+		if ($this->update(array('purchase_value' => $new_value))) {
695 695
 			$this->purchase_value = $new_value;
696 696
 		}
697 697
 
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 		 * @param float $value The value decreased by.
705 705
 		 * @param int $donor_id Donor id.
706 706
 		 */
707
-		do_action( 'give_donor_post_decrease_value', $this->purchase_value, $value, $this->id );
707
+		do_action('give_donor_post_decrease_value', $this->purchase_value, $value, $this->id);
708 708
 
709 709
 		return $this->purchase_value;
710 710
 	}
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 	 *
724 724
 	 * @return mixed              If successful, the new donation stat value, otherwise false.
725 725
 	 */
726
-	public function update_donation_value( $curr_amount, $new_amount ) {
726
+	public function update_donation_value($curr_amount, $new_amount) {
727 727
 		/**
728 728
 		 * Payment total difference value can be:
729 729
 		 *  zero   (in case amount not change)
@@ -733,15 +733,15 @@  discard block
 block discarded – undo
733 733
 		$payment_total_diff = $new_amount - $curr_amount;
734 734
 
735 735
 		// We do not need to update donation stat if donation did not change.
736
-		if ( ! $payment_total_diff ) {
736
+		if ( ! $payment_total_diff) {
737 737
 			return false;
738 738
 		}
739 739
 
740
-		if ( $payment_total_diff > 0 ) {
741
-			$this->increase_value( $payment_total_diff );
740
+		if ($payment_total_diff > 0) {
741
+			$this->increase_value($payment_total_diff);
742 742
 		} else {
743 743
 			// Pass payment total difference as +ve value to decrease amount from user lifetime stat.
744
-			$this->decrease_value( - $payment_total_diff );
744
+			$this->decrease_value( -$payment_total_diff );
745 745
 		}
746 746
 
747 747
 		return $this->purchase_value;
@@ -758,15 +758,15 @@  discard block
 block discarded – undo
758 758
 	 *
759 759
 	 * @return array       The notes requested.
760 760
 	 */
761
-	public function get_notes( $length = 20, $paged = 1 ) {
761
+	public function get_notes($length = 20, $paged = 1) {
762 762
 
763
-		$length = is_numeric( $length ) ? $length : 20;
764
-		$offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0;
763
+		$length = is_numeric($length) ? $length : 20;
764
+		$offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0;
765 765
 
766 766
 		$all_notes   = $this->get_raw_notes();
767
-		$notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) );
767
+		$notes_array = array_reverse(array_filter(explode("\n\n", $all_notes)));
768 768
 
769
-		$desired_notes = array_slice( $notes_array, $offset, $length );
769
+		$desired_notes = array_slice($notes_array, $offset, $length);
770 770
 
771 771
 		return $desired_notes;
772 772
 
@@ -783,9 +783,9 @@  discard block
 block discarded – undo
783 783
 	public function get_notes_count() {
784 784
 
785 785
 		$all_notes   = $this->get_raw_notes();
786
-		$notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) );
786
+		$notes_array = array_reverse(array_filter(explode("\n\n", $all_notes)));
787 787
 
788
-		return count( $notes_array );
788
+		return count($notes_array);
789 789
 
790 790
 	}
791 791
 
@@ -799,22 +799,22 @@  discard block
 block discarded – undo
799 799
 	 *
800 800
 	 * @return string|boolean The new note if added successfully, false otherwise.
801 801
 	 */
802
-	public function add_note( $note = '' ) {
802
+	public function add_note($note = '') {
803 803
 
804
-		$note = trim( $note );
805
-		if ( empty( $note ) ) {
804
+		$note = trim($note);
805
+		if (empty($note)) {
806 806
 			return false;
807 807
 		}
808 808
 
809 809
 		$notes = $this->get_raw_notes();
810 810
 
811
-		if ( empty( $notes ) ) {
811
+		if (empty($notes)) {
812 812
 			$notes = '';
813 813
 		}
814 814
 
815
-		$note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note;
816
-		$new_note    = apply_filters( 'give_customer_add_note_string', $note_string );
817
-		$notes       .= "\n\n" . $new_note;
815
+		$note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note;
816
+		$new_note    = apply_filters('give_customer_add_note_string', $note_string);
817
+		$notes .= "\n\n".$new_note;
818 818
 
819 819
 		/**
820 820
 		 * Fires before donor note is added.
@@ -824,11 +824,11 @@  discard block
 block discarded – undo
824 824
 		 * @param string $new_note New note to add.
825 825
 		 * @param int $donor_id Donor id.
826 826
 		 */
827
-		do_action( 'give_donor_pre_add_note', $new_note, $this->id );
827
+		do_action('give_donor_pre_add_note', $new_note, $this->id);
828 828
 
829
-		$updated = $this->update( array( 'notes' => $notes ) );
829
+		$updated = $this->update(array('notes' => $notes));
830 830
 
831
-		if ( $updated ) {
831
+		if ($updated) {
832 832
 			$this->notes = $this->get_notes();
833 833
 		}
834 834
 
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
 		 * @param string $new_note New note added.
842 842
 		 * @param int $donor_id Donor id.
843 843
 		 */
844
-		do_action( 'give_donor_post_add_note', $this->notes, $new_note, $this->id );
844
+		do_action('give_donor_post_add_note', $this->notes, $new_note, $this->id);
845 845
 
846 846
 		// Return the formatted note, so we can test, as well as update any displays
847 847
 		return $new_note;
@@ -858,7 +858,7 @@  discard block
 block discarded – undo
858 858
 	 */
859 859
 	private function get_raw_notes() {
860 860
 
861
-		$all_notes = $this->db->get_column( 'notes', $this->id );
861
+		$all_notes = $this->db->get_column('notes', $this->id);
862 862
 
863 863
 		return $all_notes;
864 864
 
@@ -875,8 +875,8 @@  discard block
 block discarded – undo
875 875
 	 *
876 876
 	 * @return mixed            Will be an array if $single is false. Will be value of meta data field if $single is true.
877 877
 	 */
878
-	public function get_meta( $meta_key = '', $single = true ) {
879
-		return Give()->donor_meta->get_meta( $this->id, $meta_key, $single );
878
+	public function get_meta($meta_key = '', $single = true) {
879
+		return Give()->donor_meta->get_meta($this->id, $meta_key, $single);
880 880
 	}
881 881
 
882 882
 	/**
@@ -891,8 +891,8 @@  discard block
 block discarded – undo
891 891
 	 *
892 892
 	 * @return bool               False for failure. True for success.
893 893
 	 */
894
-	public function add_meta( $meta_key = '', $meta_value, $unique = false ) {
895
-		return Give()->donor_meta->add_meta( $this->id, $meta_key, $meta_value, $unique );
894
+	public function add_meta($meta_key = '', $meta_value, $unique = false) {
895
+		return Give()->donor_meta->add_meta($this->id, $meta_key, $meta_value, $unique);
896 896
 	}
897 897
 
898 898
 	/**
@@ -907,8 +907,8 @@  discard block
 block discarded – undo
907 907
 	 *
908 908
 	 * @return bool               False on failure, true if success.
909 909
 	 */
910
-	public function update_meta( $meta_key = '', $meta_value, $prev_value = '' ) {
911
-		return Give()->donor_meta->update_meta( $this->id, $meta_key, $meta_value, $prev_value );
910
+	public function update_meta($meta_key = '', $meta_value, $prev_value = '') {
911
+		return Give()->donor_meta->update_meta($this->id, $meta_key, $meta_value, $prev_value);
912 912
 	}
913 913
 
914 914
 	/**
@@ -922,8 +922,8 @@  discard block
 block discarded – undo
922 922
 	 *
923 923
 	 * @return bool               False for failure. True for success.
924 924
 	 */
925
-	public function delete_meta( $meta_key = '', $meta_value = '' ) {
926
-		return Give()->donor_meta->delete_meta( $this->id, $meta_key, $meta_value );
925
+	public function delete_meta($meta_key = '', $meta_value = '') {
926
+		return Give()->donor_meta->delete_meta($this->id, $meta_key, $meta_value);
927 927
 	}
928 928
 
929 929
 	/**
@@ -936,51 +936,51 @@  discard block
 block discarded – undo
936 936
 	 *
937 937
 	 * @return array       The sanitized data, based off column defaults.
938 938
 	 */
939
-	private function sanitize_columns( $data ) {
939
+	private function sanitize_columns($data) {
940 940
 
941 941
 		$columns        = $this->db->get_columns();
942 942
 		$default_values = $this->db->get_column_defaults();
943 943
 
944
-		foreach ( $columns as $key => $type ) {
944
+		foreach ($columns as $key => $type) {
945 945
 
946 946
 			// Only sanitize data that we were provided
947
-			if ( ! array_key_exists( $key, $data ) ) {
947
+			if ( ! array_key_exists($key, $data)) {
948 948
 				continue;
949 949
 			}
950 950
 
951
-			switch ( $type ) {
951
+			switch ($type) {
952 952
 
953 953
 				case '%s':
954
-					if ( 'email' == $key ) {
955
-						$data[ $key ] = sanitize_email( $data[ $key ] );
956
-					} elseif ( 'notes' == $key ) {
957
-						$data[ $key ] = strip_tags( $data[ $key ] );
954
+					if ('email' == $key) {
955
+						$data[$key] = sanitize_email($data[$key]);
956
+					} elseif ('notes' == $key) {
957
+						$data[$key] = strip_tags($data[$key]);
958 958
 					} else {
959
-						$data[ $key ] = sanitize_text_field( $data[ $key ] );
959
+						$data[$key] = sanitize_text_field($data[$key]);
960 960
 					}
961 961
 					break;
962 962
 
963 963
 				case '%d':
964
-					if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) {
965
-						$data[ $key ] = $default_values[ $key ];
964
+					if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) {
965
+						$data[$key] = $default_values[$key];
966 966
 					} else {
967
-						$data[ $key ] = absint( $data[ $key ] );
967
+						$data[$key] = absint($data[$key]);
968 968
 					}
969 969
 					break;
970 970
 
971 971
 				case '%f':
972 972
 					// Convert what was given to a float
973
-					$value = floatval( $data[ $key ] );
973
+					$value = floatval($data[$key]);
974 974
 
975
-					if ( ! is_float( $value ) ) {
976
-						$data[ $key ] = $default_values[ $key ];
975
+					if ( ! is_float($value)) {
976
+						$data[$key] = $default_values[$key];
977 977
 					} else {
978
-						$data[ $key ] = $value;
978
+						$data[$key] = $value;
979 979
 					}
980 980
 					break;
981 981
 
982 982
 				default:
983
-					$data[ $key ] = sanitize_text_field( $data[ $key ] );
983
+					$data[$key] = sanitize_text_field($data[$key]);
984 984
 					break;
985 985
 
986 986
 			}
@@ -1000,33 +1000,33 @@  discard block
 block discarded – undo
1000 1000
 	 *
1001 1001
 	 * @return bool            If the email was added successfully
1002 1002
 	 */
1003
-	public function add_email( $email = '', $primary = false ) {
1004
-		if ( ! is_email( $email ) ) {
1003
+	public function add_email($email = '', $primary = false) {
1004
+		if ( ! is_email($email)) {
1005 1005
 			return false;
1006 1006
 		}
1007
-		$existing = new Give_Donor( $email );
1007
+		$existing = new Give_Donor($email);
1008 1008
 
1009
-		if ( $existing->id > 0 ) {
1009
+		if ($existing->id > 0) {
1010 1010
 			// Email address already belongs to another donor
1011 1011
 			return false;
1012 1012
 		}
1013 1013
 
1014
-		if ( email_exists( $email ) ) {
1015
-			$user = get_user_by( 'email', $email );
1016
-			if ( $user->ID != $this->user_id ) {
1014
+		if (email_exists($email)) {
1015
+			$user = get_user_by('email', $email);
1016
+			if ($user->ID != $this->user_id) {
1017 1017
 				return false;
1018 1018
 			}
1019 1019
 		}
1020 1020
 
1021
-		do_action( 'give_donor_pre_add_email', $email, $this->id, $this );
1021
+		do_action('give_donor_pre_add_email', $email, $this->id, $this);
1022 1022
 
1023 1023
 		// Add is used to ensure duplicate emails are not added
1024
-		$ret = (bool) $this->add_meta( 'additional_email', $email );
1024
+		$ret = (bool) $this->add_meta('additional_email', $email);
1025 1025
 
1026
-		do_action( 'give_donor_post_add_email', $email, $this->id, $this );
1026
+		do_action('give_donor_post_add_email', $email, $this->id, $this);
1027 1027
 
1028
-		if ( $ret && true === $primary ) {
1029
-			$this->set_primary_email( $email );
1028
+		if ($ret && true === $primary) {
1029
+			$this->set_primary_email($email);
1030 1030
 		}
1031 1031
 
1032 1032
 		return $ret;
@@ -1042,16 +1042,16 @@  discard block
 block discarded – undo
1042 1042
 	 *
1043 1043
 	 * @return bool          If the email was removed successfully.
1044 1044
 	 */
1045
-	public function remove_email( $email = '' ) {
1046
-		if ( ! is_email( $email ) ) {
1045
+	public function remove_email($email = '') {
1046
+		if ( ! is_email($email)) {
1047 1047
 			return false;
1048 1048
 		}
1049 1049
 
1050
-		do_action( 'give_donor_pre_remove_email', $email, $this->id, $this );
1050
+		do_action('give_donor_pre_remove_email', $email, $this->id, $this);
1051 1051
 
1052
-		$ret = (bool) $this->delete_meta( 'additional_email', $email );
1052
+		$ret = (bool) $this->delete_meta('additional_email', $email);
1053 1053
 
1054
-		do_action( 'give_donor_post_remove_email', $email, $this->id, $this );
1054
+		do_action('give_donor_post_remove_email', $email, $this->id, $this);
1055 1055
 
1056 1056
 		return $ret;
1057 1057
 	}
@@ -1068,16 +1068,16 @@  discard block
 block discarded – undo
1068 1068
 	 *
1069 1069
 	 * @return bool                      If the email was set as primary successfully.
1070 1070
 	 */
1071
-	public function set_primary_email( $new_primary_email = '' ) {
1072
-		if ( ! is_email( $new_primary_email ) ) {
1071
+	public function set_primary_email($new_primary_email = '') {
1072
+		if ( ! is_email($new_primary_email)) {
1073 1073
 			return false;
1074 1074
 		}
1075 1075
 
1076
-		do_action( 'give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this );
1076
+		do_action('give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this);
1077 1077
 
1078
-		$existing = new Give_Donor( $new_primary_email );
1078
+		$existing = new Give_Donor($new_primary_email);
1079 1079
 
1080
-		if ( $existing->id > 0 && (int) $existing->id !== (int) $this->id ) {
1080
+		if ($existing->id > 0 && (int) $existing->id !== (int) $this->id) {
1081 1081
 			// This email belongs to another donor.
1082 1082
 			return false;
1083 1083
 		}
@@ -1085,21 +1085,21 @@  discard block
 block discarded – undo
1085 1085
 		$old_email = $this->email;
1086 1086
 
1087 1087
 		// Update donor record with new email.
1088
-		$update = $this->update( array( 'email' => $new_primary_email ) );
1088
+		$update = $this->update(array('email' => $new_primary_email));
1089 1089
 
1090 1090
 		// Remove new primary from list of additional emails.
1091
-		$remove = $this->remove_email( $new_primary_email );
1091
+		$remove = $this->remove_email($new_primary_email);
1092 1092
 
1093 1093
 		// Add old email to additional emails list.
1094
-		$add = $this->add_email( $old_email );
1094
+		$add = $this->add_email($old_email);
1095 1095
 
1096 1096
 		$ret = $update && $remove && $add;
1097 1097
 
1098
-		if ( $ret ) {
1098
+		if ($ret) {
1099 1099
 			$this->email = $new_primary_email;
1100 1100
 		}
1101 1101
 
1102
-		do_action( 'give_donor_post_set_primary_email', $new_primary_email, $this->id, $this );
1102
+		do_action('give_donor_post_set_primary_email', $new_primary_email, $this->id, $this);
1103 1103
 
1104 1104
 		return $ret;
1105 1105
 	}
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
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
  * @param  int $year Year number. Default is null.
698 698
  * @param  int $hour Hour number. Default is null.
699 699
  *
700
- * @return int $earnings  Earnings
700
+ * @return double $earnings  Earnings
701 701
  */
702 702
 function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) {
703 703
 
@@ -986,7 +986,7 @@  discard block
 block discarded – undo
986 986
  *
987 987
  * @param int $payment_id Payment ID.
988 988
  *
989
- * @return array $user_info User Info Meta Values.
989
+ * @return string $user_info User Info Meta Values.
990 990
  */
991 991
 function give_get_payment_meta_user_info( $payment_id ) {
992 992
 	$payment = new Give_Payment( $payment_id );
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
  *
1004 1004
  * @param int $payment_id Payment ID.
1005 1005
  *
1006
- * @return int $form_id Form ID.
1006
+ * @return string $form_id Form ID.
1007 1007
  */
1008 1008
 function give_get_payment_form_id( $payment_id ) {
1009 1009
 	$payment = new Give_Payment( $payment_id );
Please login to merge, or discard this patch.
Spacing   +416 added lines, -416 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
 
@@ -43,15 +43,15 @@  discard block
 block discarded – undo
43 43
  *
44 44
  * @return array $payments Payments retrieved from the database
45 45
  */
46
-function give_get_payments( $args = array() ) {
46
+function give_get_payments($args = array()) {
47 47
 
48 48
 	// Fallback to post objects to ensure backwards compatibility.
49
-	if ( ! isset( $args['output'] ) ) {
49
+	if ( ! isset($args['output'])) {
50 50
 		$args['output'] = 'posts';
51 51
 	}
52 52
 
53
-	$args     = apply_filters( 'give_get_payments_args', $args );
54
-	$payments = new Give_Payments_Query( $args );
53
+	$args     = apply_filters('give_get_payments_args', $args);
54
+	$payments = new Give_Payments_Query($args);
55 55
 
56 56
 	return $payments->get_payments();
57 57
 }
@@ -66,48 +66,48 @@  discard block
 block discarded – undo
66 66
  *
67 67
  * @return mixed
68 68
  */
69
-function give_get_payment_by( $field = '', $value = '' ) {
69
+function give_get_payment_by($field = '', $value = '') {
70 70
 
71
-	if ( empty( $field ) || empty( $value ) ) {
71
+	if (empty($field) || empty($value)) {
72 72
 		return false;
73 73
 	}
74 74
 
75
-	switch ( strtolower( $field ) ) {
75
+	switch (strtolower($field)) {
76 76
 
77 77
 		case 'id':
78
-			$payment = new Give_Payment( $value );
78
+			$payment = new Give_Payment($value);
79 79
 			$id      = $payment->ID;
80 80
 
81
-			if ( empty( $id ) ) {
81
+			if (empty($id)) {
82 82
 				return false;
83 83
 			}
84 84
 
85 85
 			break;
86 86
 
87 87
 		case 'key':
88
-			$payment = give_get_payments( array(
88
+			$payment = give_get_payments(array(
89 89
 				'meta_key'       => '_give_payment_purchase_key',
90 90
 				'meta_value'     => $value,
91 91
 				'posts_per_page' => 1,
92 92
 				'fields'         => 'ids',
93
-			) );
93
+			));
94 94
 
95
-			if ( $payment ) {
96
-				$payment = new Give_Payment( $payment[0] );
95
+			if ($payment) {
96
+				$payment = new Give_Payment($payment[0]);
97 97
 			}
98 98
 
99 99
 			break;
100 100
 
101 101
 		case 'payment_number':
102
-			$payment = give_get_payments( array(
102
+			$payment = give_get_payments(array(
103 103
 				'meta_key'       => '_give_payment_number',
104 104
 				'meta_value'     => $value,
105 105
 				'posts_per_page' => 1,
106 106
 				'fields'         => 'ids',
107
-			) );
107
+			));
108 108
 
109
-			if ( $payment ) {
110
-				$payment = new Give_Payment( $payment[0] );
109
+			if ($payment) {
110
+				$payment = new Give_Payment($payment[0]);
111 111
 			}
112 112
 
113 113
 			break;
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 			return false;
117 117
 	}// End switch().
118 118
 
119
-	if ( $payment ) {
119
+	if ($payment) {
120 120
 		return $payment;
121 121
 	}
122 122
 
@@ -132,29 +132,29 @@  discard block
 block discarded – undo
132 132
  *
133 133
  * @return int|bool Payment ID if payment is inserted, false otherwise.
134 134
  */
135
-function give_insert_payment( $payment_data = array() ) {
135
+function give_insert_payment($payment_data = array()) {
136 136
 
137
-	if ( empty( $payment_data ) ) {
137
+	if (empty($payment_data)) {
138 138
 		return false;
139 139
 	}
140 140
 
141 141
 	$payment    = new Give_Payment();
142
-	$gateway    = ! empty( $payment_data['gateway'] ) ? $payment_data['gateway'] : '';
143
-	$gateway    = empty( $gateway ) && isset( $_POST['give-gateway'] ) ? $_POST['give-gateway'] : $gateway;
144
-	$form_id    = isset( $payment_data['give_form_id'] ) ? $payment_data['give_form_id'] : 0;
145
-	$price_id   = give_get_payment_meta_price_id( $payment_data );
146
-	$form_title = isset( $payment_data['give_form_title'] ) ? $payment_data['give_form_title'] : get_the_title( $form_id );
142
+	$gateway    = ! empty($payment_data['gateway']) ? $payment_data['gateway'] : '';
143
+	$gateway    = empty($gateway) && isset($_POST['give-gateway']) ? $_POST['give-gateway'] : $gateway;
144
+	$form_id    = isset($payment_data['give_form_id']) ? $payment_data['give_form_id'] : 0;
145
+	$price_id   = give_get_payment_meta_price_id($payment_data);
146
+	$form_title = isset($payment_data['give_form_title']) ? $payment_data['give_form_title'] : get_the_title($form_id);
147 147
 
148 148
 	// Set properties.
149 149
 	$payment->total          = $payment_data['price'];
150
-	$payment->status         = ! empty( $payment_data['status'] ) ? $payment_data['status'] : 'pending';
151
-	$payment->currency       = ! empty( $payment_data['currency'] ) ? $payment_data['currency'] : give_get_currency();
150
+	$payment->status         = ! empty($payment_data['status']) ? $payment_data['status'] : 'pending';
151
+	$payment->currency       = ! empty($payment_data['currency']) ? $payment_data['currency'] : give_get_currency();
152 152
 	$payment->user_info      = $payment_data['user_info'];
153 153
 	$payment->gateway        = $gateway;
154 154
 	$payment->form_title     = $form_title;
155 155
 	$payment->form_id        = $form_id;
156 156
 	$payment->price_id       = $price_id;
157
-	$payment->donor_id       = ( ! empty( $payment_data['donor_id'] ) ? $payment_data['donor_id'] : '' );
157
+	$payment->donor_id       = ( ! empty($payment_data['donor_id']) ? $payment_data['donor_id'] : '');
158 158
 	$payment->user_id        = $payment_data['user_info']['id'];
159 159
 	$payment->email          = $payment_data['user_email'];
160 160
 	$payment->first_name     = $payment_data['user_info']['first_name'];
@@ -162,8 +162,8 @@  discard block
 block discarded – undo
162 162
 	$payment->email          = $payment_data['user_info']['email'];
163 163
 	$payment->ip             = give_get_ip();
164 164
 	$payment->key            = $payment_data['purchase_key'];
165
-	$payment->mode           = ( ! empty( $payment_data['mode'] ) ? (string) $payment_data['mode'] : ( give_is_test_mode() ? 'test' : 'live' ) );
166
-	$payment->parent_payment = ! empty( $payment_data['parent'] ) ? absint( $payment_data['parent'] ) : '';
165
+	$payment->mode           = ( ! empty($payment_data['mode']) ? (string) $payment_data['mode'] : (give_is_test_mode() ? 'test' : 'live'));
166
+	$payment->parent_payment = ! empty($payment_data['parent']) ? absint($payment_data['parent']) : '';
167 167
 
168 168
 	// Add the donation.
169 169
 	$args = array(
@@ -171,19 +171,19 @@  discard block
 block discarded – undo
171 171
 		'price_id' => $payment->price_id,
172 172
 	);
173 173
 
174
-	$payment->add_donation( $payment->form_id, $args );
174
+	$payment->add_donation($payment->form_id, $args);
175 175
 
176 176
 
177 177
 	// Set date if present.
178
-	if ( isset( $payment_data['post_date'] ) ) {
178
+	if (isset($payment_data['post_date'])) {
179 179
 		$payment->date = $payment_data['post_date'];
180 180
 	}
181 181
 
182 182
 	// Handle sequential payments.
183
-	if ( give_get_option( 'enable_sequential' ) ) {
183
+	if (give_get_option('enable_sequential')) {
184 184
 		$number          = give_get_next_payment_number();
185
-		$payment->number = give_format_payment_number( $number );
186
-		update_option( 'give_last_payment_number', $number );
185
+		$payment->number = give_format_payment_number($number);
186
+		update_option('give_last_payment_number', $number);
187 187
 	}
188 188
 
189 189
 	// Save payment.
@@ -197,10 +197,10 @@  discard block
 block discarded – undo
197 197
 	 * @param int $payment_id The payment ID.
198 198
 	 * @param array $payment_data Arguments passed.
199 199
 	 */
200
-	do_action( 'give_insert_payment', $payment->ID, $payment_data );
200
+	do_action('give_insert_payment', $payment->ID, $payment_data);
201 201
 
202 202
 	// Return payment ID upon success.
203
-	if ( ! empty( $payment->ID ) ) {
203
+	if ( ! empty($payment->ID)) {
204 204
 		return $payment->ID;
205 205
 	}
206 206
 
@@ -216,10 +216,10 @@  discard block
 block discarded – undo
216 216
  *
217 217
  * @return bool|int
218 218
  */
219
-function give_create_payment( $payment_data ) {
219
+function give_create_payment($payment_data) {
220 220
 
221
-	$form_id  = intval( $payment_data['post_data']['give-form-id'] );
222
-	$price_id = isset( $payment_data['post_data']['give-price-id'] ) ? $payment_data['post_data']['give-price-id'] : '';
221
+	$form_id  = intval($payment_data['post_data']['give-form-id']);
222
+	$price_id = isset($payment_data['post_data']['give-price-id']) ? $payment_data['post_data']['give-price-id'] : '';
223 223
 
224 224
 	// Collect payment data.
225 225
 	$insert_payment_data = array(
@@ -243,10 +243,10 @@  discard block
 block discarded – undo
243 243
 	 *
244 244
 	 * @param array $insert_payment_data
245 245
 	 */
246
-	$insert_payment_data = apply_filters( 'give_create_payment', $insert_payment_data );
246
+	$insert_payment_data = apply_filters('give_create_payment', $insert_payment_data);
247 247
 
248 248
 	// Record the pending payment.
249
-	return give_insert_payment( $insert_payment_data );
249
+	return give_insert_payment($insert_payment_data);
250 250
 }
251 251
 
252 252
 /**
@@ -259,12 +259,12 @@  discard block
 block discarded – undo
259 259
  *
260 260
  * @return bool
261 261
  */
262
-function give_update_payment_status( $payment_id, $new_status = 'publish' ) {
262
+function give_update_payment_status($payment_id, $new_status = 'publish') {
263 263
 
264 264
 	$updated = false;
265
-	$payment = new Give_Payment( $payment_id );
265
+	$payment = new Give_Payment($payment_id);
266 266
 
267
-	if ( $payment && $payment->ID > 0 ) {
267
+	if ($payment && $payment->ID > 0) {
268 268
 
269 269
 		$payment->status = $new_status;
270 270
 		$updated         = $payment->save();
@@ -286,38 +286,38 @@  discard block
 block discarded – undo
286 286
  *
287 287
  * @return void
288 288
  */
289
-function give_delete_donation( $payment_id = 0, $update_donor = true ) {
289
+function give_delete_donation($payment_id = 0, $update_donor = true) {
290 290
 	global $give_logs;
291 291
 
292
-	$payment  = new Give_Payment( $payment_id );
293
-	$amount   = give_get_payment_amount( $payment_id );
292
+	$payment  = new Give_Payment($payment_id);
293
+	$amount   = give_get_payment_amount($payment_id);
294 294
 	$status   = $payment->post_status;
295
-	$donor_id = give_get_payment_donor_id( $payment_id );
296
-	$donor    = new Give_Donor( $donor_id );
295
+	$donor_id = give_get_payment_donor_id($payment_id);
296
+	$donor    = new Give_Donor($donor_id);
297 297
 
298 298
 	// Only undo donations that aren't these statuses.
299
-	$dont_undo_statuses = apply_filters( 'give_undo_donation_statuses', array(
299
+	$dont_undo_statuses = apply_filters('give_undo_donation_statuses', array(
300 300
 		'pending',
301 301
 		'cancelled',
302
-	) );
302
+	));
303 303
 
304
-	if ( ! in_array( $status, $dont_undo_statuses ) ) {
305
-		give_undo_donation( $payment_id );
304
+	if ( ! in_array($status, $dont_undo_statuses)) {
305
+		give_undo_donation($payment_id);
306 306
 	}
307 307
 
308
-	if ( $status == 'publish' ) {
308
+	if ($status == 'publish') {
309 309
 
310 310
 		// Only decrease earnings if they haven't already been decreased (or were never increased for this payment).
311
-		give_decrease_total_earnings( $amount );
311
+		give_decrease_total_earnings($amount);
312 312
 
313 313
 		// @todo: Refresh only range related stat cache
314 314
 		give_delete_donation_stats();
315 315
 
316
-		if ( $donor->id && $update_donor ) {
316
+		if ($donor->id && $update_donor) {
317 317
 
318 318
 			// Decrement the stats for the donor.
319 319
 			$donor->decrease_donation_count();
320
-			$donor->decrease_value( $amount );
320
+			$donor->decrease_value($amount);
321 321
 
322 322
 		}
323 323
 	}
@@ -329,25 +329,25 @@  discard block
 block discarded – undo
329 329
 	 *
330 330
 	 * @param int $payment_id Payment ID.
331 331
 	 */
332
-	do_action( 'give_payment_delete', $payment_id );
332
+	do_action('give_payment_delete', $payment_id);
333 333
 
334
-	if ( $donor->id && $update_donor ) {
334
+	if ($donor->id && $update_donor) {
335 335
 
336 336
 		// Remove the payment ID from the donor.
337
-		$donor->remove_payment( $payment_id );
337
+		$donor->remove_payment($payment_id);
338 338
 
339 339
 	}
340 340
 
341 341
 	// Remove the payment.
342
-	wp_delete_post( $payment_id, true );
342
+	wp_delete_post($payment_id, true);
343 343
 
344 344
 	// Remove related sale log entries.
345
-	$give_logs->delete_logs( null, 'sale', array(
345
+	$give_logs->delete_logs(null, 'sale', array(
346 346
 		array(
347 347
 			'key'   => '_give_log_payment_id',
348 348
 			'value' => $payment_id,
349 349
 		),
350
-	) );
350
+	));
351 351
 
352 352
 	/**
353 353
 	 * Fires after payment deleted.
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 	 *
357 357
 	 * @param int $payment_id Payment ID.
358 358
 	 */
359
-	do_action( 'give_payment_deleted', $payment_id );
359
+	do_action('give_payment_deleted', $payment_id);
360 360
 }
361 361
 
362 362
 /**
@@ -371,20 +371,20 @@  discard block
 block discarded – undo
371 371
  *
372 372
  * @return void
373 373
  */
374
-function give_undo_donation( $payment_id ) {
374
+function give_undo_donation($payment_id) {
375 375
 
376
-	$payment = new Give_Payment( $payment_id );
376
+	$payment = new Give_Payment($payment_id);
377 377
 
378
-	$maybe_decrease_earnings = apply_filters( 'give_decrease_earnings_on_undo', true, $payment, $payment->form_id );
379
-	if ( true === $maybe_decrease_earnings ) {
378
+	$maybe_decrease_earnings = apply_filters('give_decrease_earnings_on_undo', true, $payment, $payment->form_id);
379
+	if (true === $maybe_decrease_earnings) {
380 380
 		// Decrease earnings.
381
-		give_decrease_earnings( $payment->form_id, $payment->total );
381
+		give_decrease_earnings($payment->form_id, $payment->total);
382 382
 	}
383 383
 
384
-	$maybe_decrease_donations = apply_filters( 'give_decrease_donations_on_undo', true, $payment, $payment->form_id );
385
-	if ( true === $maybe_decrease_donations ) {
384
+	$maybe_decrease_donations = apply_filters('give_decrease_donations_on_undo', true, $payment, $payment->form_id);
385
+	if (true === $maybe_decrease_donations) {
386 386
 		// Decrease donation count.
387
-		give_decrease_donation_count( $payment->form_id );
387
+		give_decrease_donation_count($payment->form_id);
388 388
 	}
389 389
 
390 390
 }
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
  *
402 402
  * @return object $stats Contains the number of payments per payment status.
403 403
  */
404
-function give_count_payments( $args = array() ) {
404
+function give_count_payments($args = array()) {
405 405
 
406 406
 	global $wpdb;
407 407
 
@@ -413,18 +413,18 @@  discard block
 block discarded – undo
413 413
 		'form_id'    => null,
414 414
 	);
415 415
 
416
-	$args = wp_parse_args( $args, $defaults );
416
+	$args = wp_parse_args($args, $defaults);
417 417
 
418 418
 	$select = 'SELECT p.post_status,count( * ) AS num_posts';
419 419
 	$join   = '';
420
-	$where  = "WHERE p.post_type = 'give_payment' AND p.post_status IN ('" . implode( "','", give_get_payment_status_keys() ) . "')";
420
+	$where  = "WHERE p.post_type = 'give_payment' AND p.post_status IN ('".implode("','", give_get_payment_status_keys())."')";
421 421
 
422 422
 	// Count payments for a specific user.
423
-	if ( ! empty( $args['user'] ) ) {
423
+	if ( ! empty($args['user'])) {
424 424
 
425
-		if ( is_email( $args['user'] ) ) {
425
+		if (is_email($args['user'])) {
426 426
 			$field = 'email';
427
-		} elseif ( is_numeric( $args['user'] ) ) {
427
+		} elseif (is_numeric($args['user'])) {
428 428
 			$field = 'id';
429 429
 		} else {
430 430
 			$field = '';
@@ -432,107 +432,107 @@  discard block
 block discarded – undo
432 432
 
433 433
 		$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
434 434
 
435
-		if ( ! empty( $field ) ) {
435
+		if ( ! empty($field)) {
436 436
 			$where .= "
437 437
 				AND m.meta_key = '_give_payment_user_{$field}'
438 438
 				AND m.meta_value = '{$args['user']}'";
439 439
 		}
440
-	} elseif ( ! empty( $args['donor'] ) ) {
440
+	} elseif ( ! empty($args['donor'])) {
441 441
 
442
-		$join  = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
442
+		$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
443 443
 		$where .= "
444 444
 			AND m.meta_key = '_give_payment_customer_id'
445 445
 			AND m.meta_value = '{$args['donor']}'";
446 446
 
447 447
 		// Count payments for a search.
448
-	} elseif ( ! empty( $args['s'] ) ) {
448
+	} elseif ( ! empty($args['s'])) {
449 449
 
450
-		if ( is_email( $args['s'] ) || strlen( $args['s'] ) == 32 ) {
450
+		if (is_email($args['s']) || strlen($args['s']) == 32) {
451 451
 
452
-			if ( is_email( $args['s'] ) ) {
452
+			if (is_email($args['s'])) {
453 453
 				$field = '_give_payment_user_email';
454 454
 			} else {
455 455
 				$field = '_give_payment_purchase_key';
456 456
 			}
457 457
 
458
-			$join  = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
459
-			$where .= $wpdb->prepare( '
458
+			$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
459
+			$where .= $wpdb->prepare('
460 460
                 AND m.meta_key = %s
461
-                AND m.meta_value = %s', $field, $args['s'] );
461
+                AND m.meta_value = %s', $field, $args['s']);
462 462
 
463
-		} elseif ( '#' == substr( $args['s'], 0, 1 ) ) {
463
+		} elseif ('#' == substr($args['s'], 0, 1)) {
464 464
 
465
-			$search = str_replace( '#:', '', $args['s'] );
466
-			$search = str_replace( '#', '', $search );
465
+			$search = str_replace('#:', '', $args['s']);
466
+			$search = str_replace('#', '', $search);
467 467
 
468 468
 			$select = 'SELECT p.post_status,count( * ) AS num_posts ';
469 469
 			$join   = '';
470
-			$where  = $wpdb->prepare( 'WHERE p.post_type=%s  AND p.ID = %d ', 'give_payment', $search );
470
+			$where  = $wpdb->prepare('WHERE p.post_type=%s  AND p.ID = %d ', 'give_payment', $search);
471 471
 
472
-		} elseif ( is_numeric( $args['s'] ) ) {
472
+		} elseif (is_numeric($args['s'])) {
473 473
 
474
-			$join  = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
475
-			$where .= $wpdb->prepare( "
474
+			$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
475
+			$where .= $wpdb->prepare("
476 476
 				AND m.meta_key = '_give_payment_user_id'
477
-				AND m.meta_value = %d", $args['s'] );
477
+				AND m.meta_value = %d", $args['s']);
478 478
 
479 479
 		} else {
480
-			$search = $wpdb->esc_like( $args['s'] );
481
-			$search = '%' . $search . '%';
480
+			$search = $wpdb->esc_like($args['s']);
481
+			$search = '%'.$search.'%';
482 482
 
483
-			$where .= $wpdb->prepare( 'AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search );
483
+			$where .= $wpdb->prepare('AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search);
484 484
 		}// End if().
485 485
 	}// End if().
486 486
 
487
-	if ( ! empty( $args['form_id'] ) && is_numeric( $args['form_id'] ) ) {
487
+	if ( ! empty($args['form_id']) && is_numeric($args['form_id'])) {
488 488
 
489
-		$join  = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
490
-		$where .= $wpdb->prepare( '
489
+		$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
490
+		$where .= $wpdb->prepare('
491 491
                 AND m.meta_key = %s
492
-                AND m.meta_value = %s', '_give_payment_form_id', $args['form_id'] );
492
+                AND m.meta_value = %s', '_give_payment_form_id', $args['form_id']);
493 493
 	}
494 494
 
495 495
 	// Limit payments count by date.
496
-	if ( ! empty( $args['start-date'] ) && false !== strpos( $args['start-date'], '/' ) ) {
496
+	if ( ! empty($args['start-date']) && false !== strpos($args['start-date'], '/')) {
497 497
 
498
-		$date_parts = explode( '/', $args['start-date'] );
499
-		$month      = ! empty( $date_parts[0] ) && is_numeric( $date_parts[0] ) ? $date_parts[0] : 0;
500
-		$day        = ! empty( $date_parts[1] ) && is_numeric( $date_parts[1] ) ? $date_parts[1] : 0;
501
-		$year       = ! empty( $date_parts[2] ) && is_numeric( $date_parts[2] ) ? $date_parts[2] : 0;
498
+		$date_parts = explode('/', $args['start-date']);
499
+		$month      = ! empty($date_parts[0]) && is_numeric($date_parts[0]) ? $date_parts[0] : 0;
500
+		$day        = ! empty($date_parts[1]) && is_numeric($date_parts[1]) ? $date_parts[1] : 0;
501
+		$year       = ! empty($date_parts[2]) && is_numeric($date_parts[2]) ? $date_parts[2] : 0;
502 502
 
503
-		$is_date = checkdate( $month, $day, $year );
504
-		if ( false !== $is_date ) {
503
+		$is_date = checkdate($month, $day, $year);
504
+		if (false !== $is_date) {
505 505
 
506
-			$date  = new DateTime( $args['start-date'] );
507
-			$where .= $wpdb->prepare( " AND p.post_date >= '%s'", $date->format( 'Y-m-d' ) );
506
+			$date = new DateTime($args['start-date']);
507
+			$where .= $wpdb->prepare(" AND p.post_date >= '%s'", $date->format('Y-m-d'));
508 508
 
509 509
 		}
510 510
 
511 511
 		// Fixes an issue with the payments list table counts when no end date is specified (with stats class).
512
-		if ( empty( $args['end-date'] ) ) {
512
+		if (empty($args['end-date'])) {
513 513
 			$args['end-date'] = $args['start-date'];
514 514
 		}
515 515
 	}
516 516
 
517
-	if ( ! empty( $args['end-date'] ) && false !== strpos( $args['end-date'], '/' ) ) {
517
+	if ( ! empty($args['end-date']) && false !== strpos($args['end-date'], '/')) {
518 518
 
519
-		$date_parts = explode( '/', $args['end-date'] );
519
+		$date_parts = explode('/', $args['end-date']);
520 520
 
521
-		$month = ! empty( $date_parts[0] ) ? $date_parts[0] : 0;
522
-		$day   = ! empty( $date_parts[1] ) ? $date_parts[1] : 0;
523
-		$year  = ! empty( $date_parts[2] ) ? $date_parts[2] : 0;
521
+		$month = ! empty($date_parts[0]) ? $date_parts[0] : 0;
522
+		$day   = ! empty($date_parts[1]) ? $date_parts[1] : 0;
523
+		$year  = ! empty($date_parts[2]) ? $date_parts[2] : 0;
524 524
 
525
-		$is_date = checkdate( $month, $day, $year );
526
-		if ( false !== $is_date ) {
525
+		$is_date = checkdate($month, $day, $year);
526
+		if (false !== $is_date) {
527 527
 
528
-			$date  = new DateTime( $args['end-date'] );
529
-			$where .= $wpdb->prepare( " AND p.post_date <= '%s'", $date->format( 'Y-m-d' ) );
528
+			$date = new DateTime($args['end-date']);
529
+			$where .= $wpdb->prepare(" AND p.post_date <= '%s'", $date->format('Y-m-d'));
530 530
 
531 531
 		}
532 532
 	}
533 533
 
534
-	$where = apply_filters( 'give_count_payments_where', $where );
535
-	$join  = apply_filters( 'give_count_payments_join', $join );
534
+	$where = apply_filters('give_count_payments_where', $where);
535
+	$join  = apply_filters('give_count_payments_join', $join);
536 536
 
537 537
 	$query = "$select
538 538
 		FROM $wpdb->posts p
@@ -541,36 +541,36 @@  discard block
 block discarded – undo
541 541
 		GROUP BY p.post_status
542 542
 	";
543 543
 
544
-	$cache_key = md5( $query );
544
+	$cache_key = md5($query);
545 545
 
546
-	$count = wp_cache_get( $cache_key, 'counts' );
547
-	if ( false !== $count ) {
546
+	$count = wp_cache_get($cache_key, 'counts');
547
+	if (false !== $count) {
548 548
 		return $count;
549 549
 	}
550 550
 
551
-	$count = $wpdb->get_results( $query, ARRAY_A );
551
+	$count = $wpdb->get_results($query, ARRAY_A);
552 552
 
553 553
 	$stats    = array();
554 554
 	$statuses = get_post_stati();
555
-	if ( isset( $statuses['private'] ) && empty( $args['s'] ) ) {
556
-		unset( $statuses['private'] );
555
+	if (isset($statuses['private']) && empty($args['s'])) {
556
+		unset($statuses['private']);
557 557
 	}
558 558
 
559
-	foreach ( $statuses as $state ) {
560
-		$stats[ $state ] = 0;
559
+	foreach ($statuses as $state) {
560
+		$stats[$state] = 0;
561 561
 	}
562 562
 
563
-	foreach ( (array) $count as $row ) {
563
+	foreach ((array) $count as $row) {
564 564
 
565
-		if ( 'private' == $row['post_status'] && empty( $args['s'] ) ) {
565
+		if ('private' == $row['post_status'] && empty($args['s'])) {
566 566
 			continue;
567 567
 		}
568 568
 
569
-		$stats[ $row['post_status'] ] = $row['num_posts'];
569
+		$stats[$row['post_status']] = $row['num_posts'];
570 570
 	}
571 571
 
572 572
 	$stats = (object) $stats;
573
-	wp_cache_set( $cache_key, $stats, 'counts' );
573
+	wp_cache_set($cache_key, $stats, 'counts');
574 574
 
575 575
 	return $stats;
576 576
 }
@@ -585,11 +585,11 @@  discard block
 block discarded – undo
585 585
  *
586 586
  * @return bool $exists True if payment exists, false otherwise.
587 587
  */
588
-function give_check_for_existing_payment( $payment_id ) {
588
+function give_check_for_existing_payment($payment_id) {
589 589
 	$exists  = false;
590
-	$payment = new Give_Payment( $payment_id );
590
+	$payment = new Give_Payment($payment_id);
591 591
 
592
-	if ( $payment_id === $payment->ID && 'publish' === $payment->status ) {
592
+	if ($payment_id === $payment->ID && 'publish' === $payment->status) {
593 593
 		$exists = true;
594 594
 	}
595 595
 
@@ -607,41 +607,41 @@  discard block
 block discarded – undo
607 607
  *
608 608
  * @return bool|mixed True if payment status exists, false otherwise.
609 609
  */
610
-function give_get_payment_status( $payment, $return_label = false ) {
610
+function give_get_payment_status($payment, $return_label = false) {
611 611
 
612
-	if ( is_numeric( $payment ) ) {
612
+	if (is_numeric($payment)) {
613 613
 
614
-		$payment = new Give_Payment( $payment );
614
+		$payment = new Give_Payment($payment);
615 615
 
616
-		if ( ! $payment->ID > 0 ) {
616
+		if ( ! $payment->ID > 0) {
617 617
 			return false;
618 618
 		}
619 619
 
620 620
 	}
621 621
 
622
-	if ( ! is_object( $payment ) || ! isset( $payment->post_status ) ) {
622
+	if ( ! is_object($payment) || ! isset($payment->post_status)) {
623 623
 		return false;
624 624
 	}
625 625
 
626 626
 	$statuses = give_get_payment_statuses();
627 627
 
628
-	if ( ! is_array( $statuses ) || empty( $statuses ) ) {
628
+	if ( ! is_array($statuses) || empty($statuses)) {
629 629
 		return false;
630 630
 	}
631 631
 
632 632
 	// Get payment object if not already given.
633
-	$payment = $payment instanceof Give_Payment ? $payment : new Give_Payment( $payment->ID );
633
+	$payment = $payment instanceof Give_Payment ? $payment : new Give_Payment($payment->ID);
634 634
 
635
-	if ( array_key_exists( $payment->status, $statuses ) ) {
636
-		if ( true === $return_label ) {
635
+	if (array_key_exists($payment->status, $statuses)) {
636
+		if (true === $return_label) {
637 637
 			// Return translated status label.
638
-			return $statuses[ $payment->status ];
638
+			return $statuses[$payment->status];
639 639
 		} else {
640 640
 			// Account that our 'publish' status is labeled 'Complete'
641 641
 			$post_status = 'publish' == $payment->status ? 'Complete' : $payment->post_status;
642 642
 
643 643
 			// Make sure we're matching cases, since they matter
644
-			return array_search( strtolower( $post_status ), array_map( 'strtolower', $statuses ) );
644
+			return array_search(strtolower($post_status), array_map('strtolower', $statuses));
645 645
 		}
646 646
 	}
647 647
 
@@ -657,18 +657,18 @@  discard block
 block discarded – undo
657 657
  */
658 658
 function give_get_payment_statuses() {
659 659
 	$payment_statuses = array(
660
-		'pending'     => __( 'Pending', 'give' ),
661
-		'publish'     => __( 'Complete', 'give' ),
662
-		'refunded'    => __( 'Refunded', 'give' ),
663
-		'failed'      => __( 'Failed', 'give' ),
664
-		'cancelled'   => __( 'Cancelled', 'give' ),
665
-		'abandoned'   => __( 'Abandoned', 'give' ),
666
-		'preapproval' => __( 'Pre-Approved', 'give' ),
667
-		'processing'  => __( 'Processing', 'give' ),
668
-		'revoked'     => __( 'Revoked', 'give' ),
660
+		'pending'     => __('Pending', 'give'),
661
+		'publish'     => __('Complete', 'give'),
662
+		'refunded'    => __('Refunded', 'give'),
663
+		'failed'      => __('Failed', 'give'),
664
+		'cancelled'   => __('Cancelled', 'give'),
665
+		'abandoned'   => __('Abandoned', 'give'),
666
+		'preapproval' => __('Pre-Approved', 'give'),
667
+		'processing'  => __('Processing', 'give'),
668
+		'revoked'     => __('Revoked', 'give'),
669 669
 	);
670 670
 
671
-	return apply_filters( 'give_payment_statuses', $payment_statuses );
671
+	return apply_filters('give_payment_statuses', $payment_statuses);
672 672
 }
673 673
 
674 674
 /**
@@ -681,10 +681,10 @@  discard block
 block discarded – undo
681 681
  * @return array $payment_status All the available payment statuses.
682 682
  */
683 683
 function give_get_payment_status_keys() {
684
-	$statuses = array_keys( give_get_payment_statuses() );
685
-	asort( $statuses );
684
+	$statuses = array_keys(give_get_payment_statuses());
685
+	asort($statuses);
686 686
 
687
-	return array_values( $statuses );
687
+	return array_values($statuses);
688 688
 }
689 689
 
690 690
 /**
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
  *
700 700
  * @return int $earnings  Earnings
701 701
  */
702
-function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) {
702
+function give_get_earnings_by_date($day = null, $month_num, $year = null, $hour = null) {
703 703
 
704 704
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead.
705 705
 	global $wpdb;
@@ -709,41 +709,41 @@  discard block
 block discarded – undo
709 709
 		'nopaging'               => true,
710 710
 		'year'                   => $year,
711 711
 		'monthnum'               => $month_num,
712
-		'post_status'            => array( 'publish' ),
712
+		'post_status'            => array('publish'),
713 713
 		'fields'                 => 'ids',
714 714
 		'update_post_term_cache' => false,
715 715
 	);
716
-	if ( ! empty( $day ) ) {
716
+	if ( ! empty($day)) {
717 717
 		$args['day'] = $day;
718 718
 	}
719 719
 
720
-	if ( ! empty( $hour ) ) {
720
+	if ( ! empty($hour)) {
721 721
 		$args['hour'] = $hour;
722 722
 	}
723 723
 
724
-	$args = apply_filters( 'give_get_earnings_by_date_args', $args );
725
-	$key  = Give_Cache::get_key( 'give_stats', $args );
724
+	$args = apply_filters('give_get_earnings_by_date_args', $args);
725
+	$key  = Give_Cache::get_key('give_stats', $args);
726 726
 
727
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
727
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
728 728
 		$earnings = false;
729 729
 	} else {
730
-		$earnings = Give_Cache::get( $key );
730
+		$earnings = Give_Cache::get($key);
731 731
 	}
732 732
 
733
-	if ( false === $earnings ) {
734
-		$donations = get_posts( $args );
733
+	if (false === $earnings) {
734
+		$donations = get_posts($args);
735 735
 		$earnings  = 0;
736
-		if ( $donations ) {
737
-			$donations = implode( ',', $donations );
736
+		if ($donations) {
737
+			$donations = implode(',', $donations);
738 738
 
739
-			$earnings = $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$donations})" );
739
+			$earnings = $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$donations})");
740 740
 
741 741
 		}
742 742
 		// Cache the results for one hour.
743
-		Give_Cache::set( $key, $earnings, HOUR_IN_SECONDS );
743
+		Give_Cache::set($key, $earnings, HOUR_IN_SECONDS);
744 744
 	}
745 745
 
746
-	return round( $earnings, 2 );
746
+	return round($earnings, 2);
747 747
 }
748 748
 
749 749
 /**
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
  *
759 759
  * @return int $count     Sales
760 760
  */
761
-function give_get_sales_by_date( $day = null, $month_num = null, $year = null, $hour = null ) {
761
+function give_get_sales_by_date($day = null, $month_num = null, $year = null, $hour = null) {
762 762
 
763 763
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_sales() method instead.
764 764
 	$args = array(
@@ -766,14 +766,14 @@  discard block
 block discarded – undo
766 766
 		'nopaging'               => true,
767 767
 		'year'                   => $year,
768 768
 		'fields'                 => 'ids',
769
-		'post_status'            => array( 'publish' ),
769
+		'post_status'            => array('publish'),
770 770
 		'update_post_meta_cache' => false,
771 771
 		'update_post_term_cache' => false,
772 772
 	);
773 773
 
774
-	$show_free = apply_filters( 'give_sales_by_date_show_free', true, $args );
774
+	$show_free = apply_filters('give_sales_by_date_show_free', true, $args);
775 775
 
776
-	if ( false === $show_free ) {
776
+	if (false === $show_free) {
777 777
 		$args['meta_query'] = array(
778 778
 			array(
779 779
 				'key'     => '_give_payment_total',
@@ -784,33 +784,33 @@  discard block
 block discarded – undo
784 784
 		);
785 785
 	}
786 786
 
787
-	if ( ! empty( $month_num ) ) {
787
+	if ( ! empty($month_num)) {
788 788
 		$args['monthnum'] = $month_num;
789 789
 	}
790 790
 
791
-	if ( ! empty( $day ) ) {
791
+	if ( ! empty($day)) {
792 792
 		$args['day'] = $day;
793 793
 	}
794 794
 
795
-	if ( ! empty( $hour ) ) {
795
+	if ( ! empty($hour)) {
796 796
 		$args['hour'] = $hour;
797 797
 	}
798 798
 
799
-	$args = apply_filters( 'give_get_sales_by_date_args', $args );
799
+	$args = apply_filters('give_get_sales_by_date_args', $args);
800 800
 
801
-	$key = Give_Cache::get_key( 'give_stats', $args );
801
+	$key = Give_Cache::get_key('give_stats', $args);
802 802
 
803
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
803
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
804 804
 		$count = false;
805 805
 	} else {
806
-		$count = Give_Cache::get( $key );
806
+		$count = Give_Cache::get($key);
807 807
 	}
808 808
 
809
-	if ( false === $count ) {
810
-		$donations = new WP_Query( $args );
809
+	if (false === $count) {
810
+		$donations = new WP_Query($args);
811 811
 		$count     = (int) $donations->post_count;
812 812
 		// Cache the results for one hour.
813
-		Give_Cache::set( $key, $count, HOUR_IN_SECONDS );
813
+		Give_Cache::set($key, $count, HOUR_IN_SECONDS);
814 814
 	}
815 815
 
816 816
 	return $count;
@@ -825,19 +825,19 @@  discard block
 block discarded – undo
825 825
  *
826 826
  * @return bool $ret True if complete, false otherwise.
827 827
  */
828
-function give_is_payment_complete( $payment_id ) {
829
-	$payment = new Give_Payment( $payment_id );
828
+function give_is_payment_complete($payment_id) {
829
+	$payment = new Give_Payment($payment_id);
830 830
 
831 831
 	$ret = false;
832 832
 
833
-	if ( $payment->ID > 0 ) {
833
+	if ($payment->ID > 0) {
834 834
 
835
-		if ( (int) $payment_id === (int) $payment->ID && 'publish' == $payment->status ) {
835
+		if ((int) $payment_id === (int) $payment->ID && 'publish' == $payment->status) {
836 836
 			$ret = true;
837 837
 		}
838 838
 	}
839 839
 
840
-	return apply_filters( 'give_is_payment_complete', $ret, $payment_id, $payment->post_status );
840
+	return apply_filters('give_is_payment_complete', $ret, $payment_id, $payment->post_status);
841 841
 }
842 842
 
843 843
 /**
@@ -863,49 +863,49 @@  discard block
 block discarded – undo
863 863
  *
864 864
  * @return float $total Total earnings.
865 865
  */
866
-function give_get_total_earnings( $recalculate = false ) {
866
+function give_get_total_earnings($recalculate = false) {
867 867
 
868
-	$total = get_option( 'give_earnings_total', 0 );
868
+	$total = get_option('give_earnings_total', 0);
869 869
 
870 870
 	// Calculate total earnings.
871
-	if ( ! $total || $recalculate ) {
871
+	if ( ! $total || $recalculate) {
872 872
 		global $wpdb;
873 873
 
874 874
 		$total = (float) 0;
875 875
 
876
-		$args = apply_filters( 'give_get_total_earnings_args', array(
876
+		$args = apply_filters('give_get_total_earnings_args', array(
877 877
 			'offset' => 0,
878
-			'number' => - 1,
879
-			'status' => array( 'publish' ),
878
+			'number' => -1,
879
+			'status' => array('publish'),
880 880
 			'fields' => 'ids',
881
-		) );
881
+		));
882 882
 
883
-		$payments = give_get_payments( $args );
884
-		if ( $payments ) {
883
+		$payments = give_get_payments($args);
884
+		if ($payments) {
885 885
 
886 886
 			/**
887 887
 			 * If performing a donation, we need to skip the very last payment in the database,
888 888
 			 * since it calls give_increase_total_earnings() on completion,
889 889
 			 * which results in duplicated earnings for the very first donation.
890 890
 			 */
891
-			if ( did_action( 'give_update_payment_status' ) ) {
892
-				array_pop( $payments );
891
+			if (did_action('give_update_payment_status')) {
892
+				array_pop($payments);
893 893
 			}
894 894
 
895
-			if ( ! empty( $payments ) ) {
896
-				$payments = implode( ',', $payments );
897
-				$total    += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})" );
895
+			if ( ! empty($payments)) {
896
+				$payments = implode(',', $payments);
897
+				$total += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})");
898 898
 			}
899 899
 		}
900 900
 
901
-		update_option( 'give_earnings_total', $total, 'no' );
901
+		update_option('give_earnings_total', $total, 'no');
902 902
 	}
903 903
 
904
-	if ( $total < 0 ) {
904
+	if ($total < 0) {
905 905
 		$total = 0; // Don't ever show negative earnings.
906 906
 	}
907 907
 
908
-	return apply_filters( 'give_total_earnings', round( $total, give_currency_decimal_filter() ) );
908
+	return apply_filters('give_total_earnings', round($total, give_currency_decimal_filter()));
909 909
 }
910 910
 
911 911
 /**
@@ -918,10 +918,10 @@  discard block
 block discarded – undo
918 918
  *
919 919
  * @return float $total  Total earnings.
920 920
  */
921
-function give_increase_total_earnings( $amount = 0 ) {
921
+function give_increase_total_earnings($amount = 0) {
922 922
 	$total = give_get_total_earnings();
923 923
 	$total += $amount;
924
-	update_option( 'give_earnings_total', $total );
924
+	update_option('give_earnings_total', $total);
925 925
 
926 926
 	return $total;
927 927
 }
@@ -935,13 +935,13 @@  discard block
 block discarded – undo
935 935
  *
936 936
  * @return float $total Total earnings.
937 937
  */
938
-function give_decrease_total_earnings( $amount = 0 ) {
938
+function give_decrease_total_earnings($amount = 0) {
939 939
 	$total = give_get_total_earnings();
940 940
 	$total -= $amount;
941
-	if ( $total < 0 ) {
941
+	if ($total < 0) {
942 942
 		$total = 0;
943 943
 	}
944
-	update_option( 'give_earnings_total', $total );
944
+	update_option('give_earnings_total', $total);
945 945
 
946 946
 	return $total;
947 947
 }
@@ -957,10 +957,10 @@  discard block
 block discarded – undo
957 957
  *
958 958
  * @return mixed $meta Payment Meta.
959 959
  */
960
-function give_get_payment_meta( $payment_id = 0, $meta_key = '_give_payment_meta', $single = true ) {
961
-	$payment = new Give_Payment( $payment_id );
960
+function give_get_payment_meta($payment_id = 0, $meta_key = '_give_payment_meta', $single = true) {
961
+	$payment = new Give_Payment($payment_id);
962 962
 
963
-	return $payment->get_meta( $meta_key, $single );
963
+	return $payment->get_meta($meta_key, $single);
964 964
 }
965 965
 
966 966
 /**
@@ -973,10 +973,10 @@  discard block
 block discarded – undo
973 973
  *
974 974
  * @return mixed Meta ID if successful, false if unsuccessful.
975 975
  */
976
-function give_update_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) {
977
-	$payment = new Give_Payment( $payment_id );
976
+function give_update_payment_meta($payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') {
977
+	$payment = new Give_Payment($payment_id);
978 978
 
979
-	return $payment->update_meta( $meta_key, $meta_value, $prev_value );
979
+	return $payment->update_meta($meta_key, $meta_value, $prev_value);
980 980
 }
981 981
 
982 982
 /**
@@ -988,8 +988,8 @@  discard block
 block discarded – undo
988 988
  *
989 989
  * @return array $user_info User Info Meta Values.
990 990
  */
991
-function give_get_payment_meta_user_info( $payment_id ) {
992
-	$payment = new Give_Payment( $payment_id );
991
+function give_get_payment_meta_user_info($payment_id) {
992
+	$payment = new Give_Payment($payment_id);
993 993
 
994 994
 	return $payment->user_info;
995 995
 }
@@ -1005,8 +1005,8 @@  discard block
 block discarded – undo
1005 1005
  *
1006 1006
  * @return int $form_id Form ID.
1007 1007
  */
1008
-function give_get_payment_form_id( $payment_id ) {
1009
-	$payment = new Give_Payment( $payment_id );
1008
+function give_get_payment_form_id($payment_id) {
1009
+	$payment = new Give_Payment($payment_id);
1010 1010
 
1011 1011
 	return $payment->form_id;
1012 1012
 }
@@ -1020,8 +1020,8 @@  discard block
 block discarded – undo
1020 1020
  *
1021 1021
  * @return string $email User email.
1022 1022
  */
1023
-function give_get_payment_user_email( $payment_id ) {
1024
-	$payment = new Give_Payment( $payment_id );
1023
+function give_get_payment_user_email($payment_id) {
1024
+	$payment = new Give_Payment($payment_id);
1025 1025
 
1026 1026
 	return $payment->email;
1027 1027
 }
@@ -1035,11 +1035,11 @@  discard block
 block discarded – undo
1035 1035
  *
1036 1036
  * @return bool $is_guest_payment If the payment is associated with a user (false) or not (true)
1037 1037
  */
1038
-function give_is_guest_payment( $payment_id ) {
1039
-	$payment_user_id  = give_get_payment_user_id( $payment_id );
1040
-	$is_guest_payment = ! empty( $payment_user_id ) && $payment_user_id > 0 ? false : true;
1038
+function give_is_guest_payment($payment_id) {
1039
+	$payment_user_id  = give_get_payment_user_id($payment_id);
1040
+	$is_guest_payment = ! empty($payment_user_id) && $payment_user_id > 0 ? false : true;
1041 1041
 
1042
-	return (bool) apply_filters( 'give_is_guest_payment', $is_guest_payment, $payment_id );
1042
+	return (bool) apply_filters('give_is_guest_payment', $is_guest_payment, $payment_id);
1043 1043
 }
1044 1044
 
1045 1045
 /**
@@ -1051,8 +1051,8 @@  discard block
 block discarded – undo
1051 1051
  *
1052 1052
  * @return int $user_id User ID.
1053 1053
  */
1054
-function give_get_payment_user_id( $payment_id ) {
1055
-	$payment = new Give_Payment( $payment_id );
1054
+function give_get_payment_user_id($payment_id) {
1055
+	$payment = new Give_Payment($payment_id);
1056 1056
 
1057 1057
 	return $payment->user_id;
1058 1058
 }
@@ -1066,8 +1066,8 @@  discard block
 block discarded – undo
1066 1066
  *
1067 1067
  * @return int $payment->customer_id Donor ID.
1068 1068
  */
1069
-function give_get_payment_donor_id( $payment_id ) {
1070
-	$payment = new Give_Payment( $payment_id );
1069
+function give_get_payment_donor_id($payment_id) {
1070
+	$payment = new Give_Payment($payment_id);
1071 1071
 
1072 1072
 	return $payment->customer_id;
1073 1073
 }
@@ -1081,8 +1081,8 @@  discard block
 block discarded – undo
1081 1081
  *
1082 1082
  * @return string $ip User IP.
1083 1083
  */
1084
-function give_get_payment_user_ip( $payment_id ) {
1085
-	$payment = new Give_Payment( $payment_id );
1084
+function give_get_payment_user_ip($payment_id) {
1085
+	$payment = new Give_Payment($payment_id);
1086 1086
 
1087 1087
 	return $payment->ip;
1088 1088
 }
@@ -1096,8 +1096,8 @@  discard block
 block discarded – undo
1096 1096
  *
1097 1097
  * @return string $date The date the payment was completed.
1098 1098
  */
1099
-function give_get_payment_completed_date( $payment_id = 0 ) {
1100
-	$payment = new Give_Payment( $payment_id );
1099
+function give_get_payment_completed_date($payment_id = 0) {
1100
+	$payment = new Give_Payment($payment_id);
1101 1101
 
1102 1102
 	return $payment->completed_date;
1103 1103
 }
@@ -1111,8 +1111,8 @@  discard block
 block discarded – undo
1111 1111
  *
1112 1112
  * @return string $gateway Gateway.
1113 1113
  */
1114
-function give_get_payment_gateway( $payment_id ) {
1115
-	$payment = new Give_Payment( $payment_id );
1114
+function give_get_payment_gateway($payment_id) {
1115
+	$payment = new Give_Payment($payment_id);
1116 1116
 
1117 1117
 	return $payment->gateway;
1118 1118
 }
@@ -1126,8 +1126,8 @@  discard block
 block discarded – undo
1126 1126
  *
1127 1127
  * @return string $currency The currency code.
1128 1128
  */
1129
-function give_get_payment_currency_code( $payment_id = 0 ) {
1130
-	$payment = new Give_Payment( $payment_id );
1129
+function give_get_payment_currency_code($payment_id = 0) {
1130
+	$payment = new Give_Payment($payment_id);
1131 1131
 
1132 1132
 	return $payment->currency;
1133 1133
 }
@@ -1141,10 +1141,10 @@  discard block
 block discarded – undo
1141 1141
  *
1142 1142
  * @return string $currency The currency name.
1143 1143
  */
1144
-function give_get_payment_currency( $payment_id = 0 ) {
1145
-	$currency = give_get_payment_currency_code( $payment_id );
1144
+function give_get_payment_currency($payment_id = 0) {
1145
+	$currency = give_get_payment_currency_code($payment_id);
1146 1146
 
1147
-	return apply_filters( 'give_payment_currency', give_get_currency_name( $currency ), $payment_id );
1147
+	return apply_filters('give_payment_currency', give_get_currency_name($currency), $payment_id);
1148 1148
 }
1149 1149
 
1150 1150
 /**
@@ -1156,8 +1156,8 @@  discard block
 block discarded – undo
1156 1156
  *
1157 1157
  * @return string $key Donation key.
1158 1158
  */
1159
-function give_get_payment_key( $payment_id = 0 ) {
1160
-	$payment = new Give_Payment( $payment_id );
1159
+function give_get_payment_key($payment_id = 0) {
1160
+	$payment = new Give_Payment($payment_id);
1161 1161
 
1162 1162
 	return $payment->key;
1163 1163
 }
@@ -1173,8 +1173,8 @@  discard block
 block discarded – undo
1173 1173
  *
1174 1174
  * @return string $number Payment order number.
1175 1175
  */
1176
-function give_get_payment_number( $payment_id = 0 ) {
1177
-	$payment = new Give_Payment( $payment_id );
1176
+function give_get_payment_number($payment_id = 0) {
1177
+	$payment = new Give_Payment($payment_id);
1178 1178
 
1179 1179
 	return $payment->number;
1180 1180
 }
@@ -1188,23 +1188,23 @@  discard block
 block discarded – undo
1188 1188
  *
1189 1189
  * @return string      The formatted payment number.
1190 1190
  */
1191
-function give_format_payment_number( $number ) {
1191
+function give_format_payment_number($number) {
1192 1192
 
1193
-	if ( ! give_get_option( 'enable_sequential' ) ) {
1193
+	if ( ! give_get_option('enable_sequential')) {
1194 1194
 		return $number;
1195 1195
 	}
1196 1196
 
1197
-	if ( ! is_numeric( $number ) ) {
1197
+	if ( ! is_numeric($number)) {
1198 1198
 		return $number;
1199 1199
 	}
1200 1200
 
1201
-	$prefix  = give_get_option( 'sequential_prefix' );
1202
-	$number  = absint( $number );
1203
-	$postfix = give_get_option( 'sequential_postfix' );
1201
+	$prefix  = give_get_option('sequential_prefix');
1202
+	$number  = absint($number);
1203
+	$postfix = give_get_option('sequential_postfix');
1204 1204
 
1205
-	$formatted_number = $prefix . $number . $postfix;
1205
+	$formatted_number = $prefix.$number.$postfix;
1206 1206
 
1207
-	return apply_filters( 'give_format_payment_number', $formatted_number, $prefix, $number, $postfix );
1207
+	return apply_filters('give_format_payment_number', $formatted_number, $prefix, $number, $postfix);
1208 1208
 }
1209 1209
 
1210 1210
 /**
@@ -1217,17 +1217,17 @@  discard block
 block discarded – undo
1217 1217
  */
1218 1218
 function give_get_next_payment_number() {
1219 1219
 
1220
-	if ( ! give_get_option( 'enable_sequential' ) ) {
1220
+	if ( ! give_get_option('enable_sequential')) {
1221 1221
 		return false;
1222 1222
 	}
1223 1223
 
1224
-	$number           = get_option( 'give_last_payment_number' );
1225
-	$start            = give_get_option( 'sequential_start', 1 );
1224
+	$number           = get_option('give_last_payment_number');
1225
+	$start            = give_get_option('sequential_start', 1);
1226 1226
 	$increment_number = true;
1227 1227
 
1228
-	if ( false !== $number ) {
1228
+	if (false !== $number) {
1229 1229
 
1230
-		if ( empty( $number ) ) {
1230
+		if (empty($number)) {
1231 1231
 
1232 1232
 			$number           = $start;
1233 1233
 			$increment_number = false;
@@ -1236,24 +1236,24 @@  discard block
 block discarded – undo
1236 1236
 	} else {
1237 1237
 
1238 1238
 		// This case handles the first addition of the new option, as well as if it get's deleted for any reason.
1239
-		$payments     = new Give_Payments_Query( array(
1239
+		$payments = new Give_Payments_Query(array(
1240 1240
 			'number'  => 1,
1241 1241
 			'order'   => 'DESC',
1242 1242
 			'orderby' => 'ID',
1243 1243
 			'output'  => 'posts',
1244 1244
 			'fields'  => 'ids',
1245
-		) );
1245
+		));
1246 1246
 		$last_payment = $payments->get_payments();
1247 1247
 
1248
-		if ( ! empty( $last_payment ) ) {
1248
+		if ( ! empty($last_payment)) {
1249 1249
 
1250
-			$number = give_get_payment_number( $last_payment[0] );
1250
+			$number = give_get_payment_number($last_payment[0]);
1251 1251
 
1252 1252
 		}
1253 1253
 
1254
-		if ( ! empty( $number ) && $number !== (int) $last_payment[0] ) {
1254
+		if ( ! empty($number) && $number !== (int) $last_payment[0]) {
1255 1255
 
1256
-			$number = give_remove_payment_prefix_postfix( $number );
1256
+			$number = give_remove_payment_prefix_postfix($number);
1257 1257
 
1258 1258
 		} else {
1259 1259
 
@@ -1262,13 +1262,13 @@  discard block
 block discarded – undo
1262 1262
 		}
1263 1263
 	}// End if().
1264 1264
 
1265
-	$increment_number = apply_filters( 'give_increment_payment_number', $increment_number, $number );
1265
+	$increment_number = apply_filters('give_increment_payment_number', $increment_number, $number);
1266 1266
 
1267
-	if ( $increment_number ) {
1268
-		$number ++;
1267
+	if ($increment_number) {
1268
+		$number++;
1269 1269
 	}
1270 1270
 
1271
-	return apply_filters( 'give_get_next_payment_number', $number );
1271
+	return apply_filters('give_get_next_payment_number', $number);
1272 1272
 }
1273 1273
 
1274 1274
 /**
@@ -1280,25 +1280,25 @@  discard block
 block discarded – undo
1280 1280
  *
1281 1281
  * @return string The new Payment number without prefix and postfix.
1282 1282
  */
1283
-function give_remove_payment_prefix_postfix( $number ) {
1283
+function give_remove_payment_prefix_postfix($number) {
1284 1284
 
1285
-	$prefix  = give_get_option( 'sequential_prefix' );
1286
-	$postfix = give_get_option( 'sequential_postfix' );
1285
+	$prefix  = give_get_option('sequential_prefix');
1286
+	$postfix = give_get_option('sequential_postfix');
1287 1287
 
1288 1288
 	// Remove prefix.
1289
-	$number = preg_replace( '/' . $prefix . '/', '', $number, 1 );
1289
+	$number = preg_replace('/'.$prefix.'/', '', $number, 1);
1290 1290
 
1291 1291
 	// Remove the postfix.
1292
-	$length      = strlen( $number );
1293
-	$postfix_pos = strrpos( $number, $postfix );
1294
-	if ( false !== $postfix_pos ) {
1295
-		$number = substr_replace( $number, '', $postfix_pos, $length );
1292
+	$length      = strlen($number);
1293
+	$postfix_pos = strrpos($number, $postfix);
1294
+	if (false !== $postfix_pos) {
1295
+		$number = substr_replace($number, '', $postfix_pos, $length);
1296 1296
 	}
1297 1297
 
1298 1298
 	// Ensure it's a whole number.
1299
-	$number = intval( $number );
1299
+	$number = intval($number);
1300 1300
 
1301
-	return apply_filters( 'give_remove_payment_prefix_postfix', $number, $prefix, $postfix );
1301
+	return apply_filters('give_remove_payment_prefix_postfix', $number, $prefix, $postfix);
1302 1302
 
1303 1303
 }
1304 1304
 
@@ -1315,10 +1315,10 @@  discard block
 block discarded – undo
1315 1315
  *
1316 1316
  * @return string $amount Fully formatted payment amount.
1317 1317
  */
1318
-function give_payment_amount( $payment_id = 0 ) {
1319
-	$amount = give_get_payment_amount( $payment_id );
1318
+function give_payment_amount($payment_id = 0) {
1319
+	$amount = give_get_payment_amount($payment_id);
1320 1320
 
1321
-	return give_currency_filter( give_format_amount( $amount, array( 'sanitize' => false ) ), give_get_payment_currency_code( $payment_id ) );
1321
+	return give_currency_filter(give_format_amount($amount, array('sanitize' => false)), give_get_payment_currency_code($payment_id));
1322 1322
 }
1323 1323
 
1324 1324
 /**
@@ -1331,11 +1331,11 @@  discard block
 block discarded – undo
1331 1331
  *
1332 1332
  * @return mixed
1333 1333
  */
1334
-function give_get_payment_amount( $payment_id ) {
1334
+function give_get_payment_amount($payment_id) {
1335 1335
 
1336
-	$payment = new Give_Payment( $payment_id );
1336
+	$payment = new Give_Payment($payment_id);
1337 1337
 
1338
-	return apply_filters( 'give_payment_amount', floatval( $payment->total ), $payment_id );
1338
+	return apply_filters('give_payment_amount', floatval($payment->total), $payment_id);
1339 1339
 }
1340 1340
 
1341 1341
 /**
@@ -1352,10 +1352,10 @@  discard block
 block discarded – undo
1352 1352
  *
1353 1353
  * @return array Fully formatted payment subtotal.
1354 1354
  */
1355
-function give_payment_subtotal( $payment_id = 0 ) {
1356
-	$subtotal = give_get_payment_subtotal( $payment_id );
1355
+function give_payment_subtotal($payment_id = 0) {
1356
+	$subtotal = give_get_payment_subtotal($payment_id);
1357 1357
 
1358
-	return give_currency_filter( give_format_amount( $subtotal, array( 'sanitize' => false ) ), give_get_payment_currency_code( $payment_id ) );
1358
+	return give_currency_filter(give_format_amount($subtotal, array('sanitize' => false)), give_get_payment_currency_code($payment_id));
1359 1359
 }
1360 1360
 
1361 1361
 /**
@@ -1369,8 +1369,8 @@  discard block
 block discarded – undo
1369 1369
  *
1370 1370
  * @return float $subtotal Subtotal for payment (non formatted).
1371 1371
  */
1372
-function give_get_payment_subtotal( $payment_id = 0 ) {
1373
-	$payment = new Give_Payment( $payment_id );
1372
+function give_get_payment_subtotal($payment_id = 0) {
1373
+	$payment = new Give_Payment($payment_id);
1374 1374
 
1375 1375
 	return $payment->subtotal;
1376 1376
 }
@@ -1384,8 +1384,8 @@  discard block
 block discarded – undo
1384 1384
  *
1385 1385
  * @return string The donation ID.
1386 1386
  */
1387
-function give_get_payment_transaction_id( $payment_id = 0 ) {
1388
-	$payment = new Give_Payment( $payment_id );
1387
+function give_get_payment_transaction_id($payment_id = 0) {
1388
+	$payment = new Give_Payment($payment_id);
1389 1389
 
1390 1390
 	return $payment->transaction_id;
1391 1391
 }
@@ -1400,15 +1400,15 @@  discard block
 block discarded – undo
1400 1400
  *
1401 1401
  * @return bool|mixed
1402 1402
  */
1403
-function give_set_payment_transaction_id( $payment_id = 0, $transaction_id = '' ) {
1403
+function give_set_payment_transaction_id($payment_id = 0, $transaction_id = '') {
1404 1404
 
1405
-	if ( empty( $payment_id ) || empty( $transaction_id ) ) {
1405
+	if (empty($payment_id) || empty($transaction_id)) {
1406 1406
 		return false;
1407 1407
 	}
1408 1408
 
1409
-	$transaction_id = apply_filters( 'give_set_payment_transaction_id', $transaction_id, $payment_id );
1409
+	$transaction_id = apply_filters('give_set_payment_transaction_id', $transaction_id, $payment_id);
1410 1410
 
1411
-	return give_update_payment_meta( $payment_id, '_give_payment_transaction_id', $transaction_id );
1411
+	return give_update_payment_meta($payment_id, '_give_payment_transaction_id', $transaction_id);
1412 1412
 }
1413 1413
 
1414 1414
 /**
@@ -1421,12 +1421,12 @@  discard block
 block discarded – undo
1421 1421
  *
1422 1422
  * @return int $purchase Donation ID.
1423 1423
  */
1424
-function give_get_purchase_id_by_key( $key ) {
1424
+function give_get_purchase_id_by_key($key) {
1425 1425
 	global $wpdb;
1426 1426
 
1427
-	$purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key ) );
1427
+	$purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key));
1428 1428
 
1429
-	if ( $purchase != null ) {
1429
+	if ($purchase != null) {
1430 1430
 		return $purchase;
1431 1431
 	}
1432 1432
 
@@ -1444,12 +1444,12 @@  discard block
 block discarded – undo
1444 1444
  *
1445 1445
  * @return int $purchase Donation ID.
1446 1446
  */
1447
-function give_get_purchase_id_by_transaction_id( $key ) {
1447
+function give_get_purchase_id_by_transaction_id($key) {
1448 1448
 	global $wpdb;
1449 1449
 
1450
-	$purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key ) );
1450
+	$purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key));
1451 1451
 
1452
-	if ( $purchase != null ) {
1452
+	if ($purchase != null) {
1453 1453
 		return $purchase;
1454 1454
 	}
1455 1455
 
@@ -1466,23 +1466,23 @@  discard block
 block discarded – undo
1466 1466
  *
1467 1467
  * @return array $notes Donation Notes
1468 1468
  */
1469
-function give_get_payment_notes( $payment_id = 0, $search = '' ) {
1469
+function give_get_payment_notes($payment_id = 0, $search = '') {
1470 1470
 
1471
-	if ( empty( $payment_id ) && empty( $search ) ) {
1471
+	if (empty($payment_id) && empty($search)) {
1472 1472
 		return false;
1473 1473
 	}
1474 1474
 
1475
-	remove_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1476
-	remove_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10 );
1475
+	remove_action('pre_get_comments', 'give_hide_payment_notes', 10);
1476
+	remove_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10);
1477 1477
 
1478
-	$notes = get_comments( array(
1478
+	$notes = get_comments(array(
1479 1479
 		'post_id' => $payment_id,
1480 1480
 		'order'   => 'ASC',
1481 1481
 		'search'  => $search,
1482
-	) );
1482
+	));
1483 1483
 
1484
-	add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1485
-	add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 );
1484
+	add_action('pre_get_comments', 'give_hide_payment_notes', 10);
1485
+	add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2);
1486 1486
 
1487 1487
 	return $notes;
1488 1488
 }
@@ -1498,8 +1498,8 @@  discard block
 block discarded – undo
1498 1498
  *
1499 1499
  * @return int The new note ID
1500 1500
  */
1501
-function give_insert_payment_note( $payment_id = 0, $note = '' ) {
1502
-	if ( empty( $payment_id ) ) {
1501
+function give_insert_payment_note($payment_id = 0, $note = '') {
1502
+	if (empty($payment_id)) {
1503 1503
 		return false;
1504 1504
 	}
1505 1505
 
@@ -1511,14 +1511,14 @@  discard block
 block discarded – undo
1511 1511
 	 * @param int $payment_id Payment ID.
1512 1512
 	 * @param string $note The note.
1513 1513
 	 */
1514
-	do_action( 'give_pre_insert_payment_note', $payment_id, $note );
1514
+	do_action('give_pre_insert_payment_note', $payment_id, $note);
1515 1515
 
1516
-	$note_id = wp_insert_comment( wp_filter_comment( array(
1516
+	$note_id = wp_insert_comment(wp_filter_comment(array(
1517 1517
 		'comment_post_ID'      => $payment_id,
1518 1518
 		'comment_content'      => $note,
1519 1519
 		'user_id'              => is_admin() ? get_current_user_id() : 0,
1520
-		'comment_date'         => current_time( 'mysql' ),
1521
-		'comment_date_gmt'     => current_time( 'mysql', 1 ),
1520
+		'comment_date'         => current_time('mysql'),
1521
+		'comment_date_gmt'     => current_time('mysql', 1),
1522 1522
 		'comment_approved'     => 1,
1523 1523
 		'comment_parent'       => 0,
1524 1524
 		'comment_author'       => '',
@@ -1527,7 +1527,7 @@  discard block
 block discarded – undo
1527 1527
 		'comment_author_email' => '',
1528 1528
 		'comment_type'         => 'give_payment_note',
1529 1529
 
1530
-	) ) );
1530
+	)));
1531 1531
 
1532 1532
 	/**
1533 1533
 	 * Fires after payment note inserted.
@@ -1538,7 +1538,7 @@  discard block
 block discarded – undo
1538 1538
 	 * @param int $payment_id Payment ID.
1539 1539
 	 * @param string $note The note.
1540 1540
 	 */
1541
-	do_action( 'give_insert_payment_note', $note_id, $payment_id, $note );
1541
+	do_action('give_insert_payment_note', $note_id, $payment_id, $note);
1542 1542
 
1543 1543
 	return $note_id;
1544 1544
 }
@@ -1553,8 +1553,8 @@  discard block
 block discarded – undo
1553 1553
  *
1554 1554
  * @return bool True on success, false otherwise.
1555 1555
  */
1556
-function give_delete_payment_note( $comment_id = 0, $payment_id = 0 ) {
1557
-	if ( empty( $comment_id ) ) {
1556
+function give_delete_payment_note($comment_id = 0, $payment_id = 0) {
1557
+	if (empty($comment_id)) {
1558 1558
 		return false;
1559 1559
 	}
1560 1560
 
@@ -1566,9 +1566,9 @@  discard block
 block discarded – undo
1566 1566
 	 * @param int $comment_id Note ID.
1567 1567
 	 * @param int $payment_id Payment ID.
1568 1568
 	 */
1569
-	do_action( 'give_pre_delete_payment_note', $comment_id, $payment_id );
1569
+	do_action('give_pre_delete_payment_note', $comment_id, $payment_id);
1570 1570
 
1571
-	$ret = wp_delete_comment( $comment_id, true );
1571
+	$ret = wp_delete_comment($comment_id, true);
1572 1572
 
1573 1573
 	/**
1574 1574
 	 * Fires after donation note deleted.
@@ -1578,7 +1578,7 @@  discard block
 block discarded – undo
1578 1578
 	 * @param int $comment_id Note ID.
1579 1579
 	 * @param int $payment_id Payment ID.
1580 1580
 	 */
1581
-	do_action( 'give_post_delete_payment_note', $comment_id, $payment_id );
1581
+	do_action('give_post_delete_payment_note', $comment_id, $payment_id);
1582 1582
 
1583 1583
 	return $ret;
1584 1584
 }
@@ -1593,32 +1593,32 @@  discard block
 block discarded – undo
1593 1593
  *
1594 1594
  * @return string
1595 1595
  */
1596
-function give_get_payment_note_html( $note, $payment_id = 0 ) {
1596
+function give_get_payment_note_html($note, $payment_id = 0) {
1597 1597
 
1598
-	if ( is_numeric( $note ) ) {
1599
-		$note = get_comment( $note );
1598
+	if (is_numeric($note)) {
1599
+		$note = get_comment($note);
1600 1600
 	}
1601 1601
 
1602
-	if ( ! empty( $note->user_id ) ) {
1603
-		$user = get_userdata( $note->user_id );
1602
+	if ( ! empty($note->user_id)) {
1603
+		$user = get_userdata($note->user_id);
1604 1604
 		$user = $user->display_name;
1605 1605
 	} else {
1606
-		$user = esc_html__( 'System', 'give' );
1606
+		$user = esc_html__('System', 'give');
1607 1607
 	}
1608 1608
 
1609
-	$date_format = give_date_format() . ', ' . get_option( 'time_format' );
1609
+	$date_format = give_date_format().', '.get_option('time_format');
1610 1610
 
1611
-	$delete_note_url = wp_nonce_url( add_query_arg( array(
1611
+	$delete_note_url = wp_nonce_url(add_query_arg(array(
1612 1612
 		'give-action' => 'delete_payment_note',
1613 1613
 		'note_id'     => $note->comment_ID,
1614 1614
 		'payment_id'  => $payment_id,
1615
-	) ), 'give_delete_payment_note_' . $note->comment_ID );
1615
+	)), 'give_delete_payment_note_'.$note->comment_ID);
1616 1616
 
1617
-	$note_html = '<div class="give-payment-note" id="give-payment-note-' . $note->comment_ID . '">';
1617
+	$note_html = '<div class="give-payment-note" id="give-payment-note-'.$note->comment_ID.'">';
1618 1618
 	$note_html .= '<p>';
1619
-	$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/>';
1619
+	$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/>';
1620 1620
 	$note_html .= $note->comment_content;
1621
-	$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="' . esc_attr__( 'Delete this donation note.', 'give' ) . '">' . esc_html__( 'Delete', 'give' ) . '</a>';
1621
+	$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="'.esc_attr__('Delete this donation note.', 'give').'">'.esc_html__('Delete', 'give').'</a>';
1622 1622
 	$note_html .= '</p>';
1623 1623
 	$note_html .= '</div>';
1624 1624
 
@@ -1636,18 +1636,18 @@  discard block
 block discarded – undo
1636 1636
  *
1637 1637
  * @return void
1638 1638
  */
1639
-function give_hide_payment_notes( $query ) {
1640
-	if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '>=' ) ) {
1641
-		$types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array();
1642
-		if ( ! is_array( $types ) ) {
1643
-			$types = array( $types );
1639
+function give_hide_payment_notes($query) {
1640
+	if (version_compare(floatval(get_bloginfo('version')), '4.1', '>=')) {
1641
+		$types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array();
1642
+		if ( ! is_array($types)) {
1643
+			$types = array($types);
1644 1644
 		}
1645 1645
 		$types[]                           = 'give_payment_note';
1646 1646
 		$query->query_vars['type__not_in'] = $types;
1647 1647
 	}
1648 1648
 }
1649 1649
 
1650
-add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1650
+add_action('pre_get_comments', 'give_hide_payment_notes', 10);
1651 1651
 
1652 1652
 /**
1653 1653
  * Exclude notes (comments) on give_payment post type from showing in Recent Comments widgets
@@ -1659,15 +1659,15 @@  discard block
 block discarded – undo
1659 1659
  *
1660 1660
  * @return array $clauses Updated comment clauses.
1661 1661
  */
1662
-function give_hide_payment_notes_pre_41( $clauses, $wp_comment_query ) {
1663
-	if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '<' ) ) {
1662
+function give_hide_payment_notes_pre_41($clauses, $wp_comment_query) {
1663
+	if (version_compare(floatval(get_bloginfo('version')), '4.1', '<')) {
1664 1664
 		$clauses['where'] .= ' AND comment_type != "give_payment_note"';
1665 1665
 	}
1666 1666
 
1667 1667
 	return $clauses;
1668 1668
 }
1669 1669
 
1670
-add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 );
1670
+add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2);
1671 1671
 
1672 1672
 
1673 1673
 /**
@@ -1680,15 +1680,15 @@  discard block
 block discarded – undo
1680 1680
  *
1681 1681
  * @return string $where
1682 1682
  */
1683
-function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) {
1683
+function give_hide_payment_notes_from_feeds($where, $wp_comment_query) {
1684 1684
 	global $wpdb;
1685 1685
 
1686
-	$where .= $wpdb->prepare( ' AND comment_type != %s', 'give_payment_note' );
1686
+	$where .= $wpdb->prepare(' AND comment_type != %s', 'give_payment_note');
1687 1687
 
1688 1688
 	return $where;
1689 1689
 }
1690 1690
 
1691
-add_filter( 'comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2 );
1691
+add_filter('comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2);
1692 1692
 
1693 1693
 
1694 1694
 /**
@@ -1702,32 +1702,32 @@  discard block
 block discarded – undo
1702 1702
  *
1703 1703
  * @return array Array of comment counts.
1704 1704
  */
1705
-function give_remove_payment_notes_in_comment_counts( $stats, $post_id ) {
1705
+function give_remove_payment_notes_in_comment_counts($stats, $post_id) {
1706 1706
 	global $wpdb, $pagenow;
1707 1707
 
1708
-	if ( 'index.php' != $pagenow ) {
1708
+	if ('index.php' != $pagenow) {
1709 1709
 		return $stats;
1710 1710
 	}
1711 1711
 
1712 1712
 	$post_id = (int) $post_id;
1713 1713
 
1714
-	if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) {
1714
+	if (apply_filters('give_count_payment_notes_in_comments', false)) {
1715 1715
 		return $stats;
1716 1716
 	}
1717 1717
 
1718
-	$stats = wp_cache_get( "comments-{$post_id}", 'counts' );
1718
+	$stats = wp_cache_get("comments-{$post_id}", 'counts');
1719 1719
 
1720
-	if ( false !== $stats ) {
1720
+	if (false !== $stats) {
1721 1721
 		return $stats;
1722 1722
 	}
1723 1723
 
1724 1724
 	$where = 'WHERE comment_type != "give_payment_note"';
1725 1725
 
1726
-	if ( $post_id > 0 ) {
1727
-		$where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id );
1726
+	if ($post_id > 0) {
1727
+		$where .= $wpdb->prepare(' AND comment_post_ID = %d', $post_id);
1728 1728
 	}
1729 1729
 
1730
-	$count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A );
1730
+	$count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A);
1731 1731
 
1732 1732
 	$total    = 0;
1733 1733
 	$approved = array(
@@ -1737,30 +1737,30 @@  discard block
 block discarded – undo
1737 1737
 		'trash'        => 'trash',
1738 1738
 		'post-trashed' => 'post-trashed',
1739 1739
 	);
1740
-	foreach ( (array) $count as $row ) {
1740
+	foreach ((array) $count as $row) {
1741 1741
 		// Don't count post-trashed toward totals.
1742
-		if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) {
1742
+		if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) {
1743 1743
 			$total += $row['num_comments'];
1744 1744
 		}
1745
-		if ( isset( $approved[ $row['comment_approved'] ] ) ) {
1746
-			$stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments'];
1745
+		if (isset($approved[$row['comment_approved']])) {
1746
+			$stats[$approved[$row['comment_approved']]] = $row['num_comments'];
1747 1747
 		}
1748 1748
 	}
1749 1749
 
1750 1750
 	$stats['total_comments'] = $total;
1751
-	foreach ( $approved as $key ) {
1752
-		if ( empty( $stats[ $key ] ) ) {
1753
-			$stats[ $key ] = 0;
1751
+	foreach ($approved as $key) {
1752
+		if (empty($stats[$key])) {
1753
+			$stats[$key] = 0;
1754 1754
 		}
1755 1755
 	}
1756 1756
 
1757 1757
 	$stats = (object) $stats;
1758
-	wp_cache_set( "comments-{$post_id}", $stats, 'counts' );
1758
+	wp_cache_set("comments-{$post_id}", $stats, 'counts');
1759 1759
 
1760 1760
 	return $stats;
1761 1761
 }
1762 1762
 
1763
-add_filter( 'wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2 );
1763
+add_filter('wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2);
1764 1764
 
1765 1765
 
1766 1766
 /**
@@ -1773,9 +1773,9 @@  discard block
 block discarded – undo
1773 1773
  *
1774 1774
  * @return string $where Modified where clause.
1775 1775
  */
1776
-function give_filter_where_older_than_week( $where = '' ) {
1776
+function give_filter_where_older_than_week($where = '') {
1777 1777
 	// Payments older than one week.
1778
-	$start = date( 'Y-m-d', strtotime( '-7 days' ) );
1778
+	$start = date('Y-m-d', strtotime('-7 days'));
1779 1779
 	$where .= " AND post_date <= '{$start}'";
1780 1780
 
1781 1781
 	return $where;
@@ -1795,38 +1795,38 @@  discard block
 block discarded – undo
1795 1795
  *
1796 1796
  * @return string $form_title Returns the full title if $only_level is false, otherwise returns the levels title.
1797 1797
  */
1798
-function give_get_payment_form_title( $payment_meta, $only_level = false, $separator = '' ) {
1798
+function give_get_payment_form_title($payment_meta, $only_level = false, $separator = '') {
1799 1799
 
1800
-	$form_id    = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0;
1801
-	$price_id   = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null;
1802
-	$form_title = isset( $payment_meta['form_title'] ) ? $payment_meta['form_title'] : '';
1800
+	$form_id    = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0;
1801
+	$price_id   = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null;
1802
+	$form_title = isset($payment_meta['form_title']) ? $payment_meta['form_title'] : '';
1803 1803
 
1804
-	if ( $only_level == true ) {
1804
+	if ($only_level == true) {
1805 1805
 		$form_title = '';
1806 1806
 	}
1807 1807
 
1808 1808
 	// If multi-level, append to the form title.
1809
-	if ( give_has_variable_prices( $form_id ) ) {
1809
+	if (give_has_variable_prices($form_id)) {
1810 1810
 
1811 1811
 		// Only add separator if there is a form title.
1812
-		if ( ! empty( $form_title ) ) {
1813
-			$form_title .= ' ' . $separator . ' ';
1812
+		if ( ! empty($form_title)) {
1813
+			$form_title .= ' '.$separator.' ';
1814 1814
 		}
1815 1815
 
1816 1816
 		$form_title .= '<span class="donation-level-text-wrap">';
1817 1817
 
1818
-		if ( $price_id == 'custom' ) {
1819
-			$custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true );
1820
-			$form_title         .= ! empty( $custom_amount_text ) ? $custom_amount_text : __( 'Custom Amount', 'give' );
1818
+		if ($price_id == 'custom') {
1819
+			$custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true);
1820
+			$form_title .= ! empty($custom_amount_text) ? $custom_amount_text : __('Custom Amount', 'give');
1821 1821
 		} else {
1822
-			$form_title .= give_get_price_option_name( $form_id, $price_id );
1822
+			$form_title .= give_get_price_option_name($form_id, $price_id);
1823 1823
 		}
1824 1824
 
1825 1825
 		$form_title .= '</span>';
1826 1826
 
1827 1827
 	}
1828 1828
 
1829
-	return apply_filters( 'give_get_payment_form_title', $form_title, $payment_meta );
1829
+	return apply_filters('give_get_payment_form_title', $form_title, $payment_meta);
1830 1830
 
1831 1831
 }
1832 1832
 
@@ -1840,19 +1840,19 @@  discard block
 block discarded – undo
1840 1840
  *
1841 1841
  * @return string $price_id
1842 1842
  */
1843
-function give_get_price_id( $form_id, $price ) {
1843
+function give_get_price_id($form_id, $price) {
1844 1844
 	$price_id = null;
1845 1845
 
1846
-	if ( give_has_variable_prices( $form_id ) ) {
1846
+	if (give_has_variable_prices($form_id)) {
1847 1847
 
1848
-		$levels = give_get_meta( $form_id, '_give_donation_levels', true );
1848
+		$levels = give_get_meta($form_id, '_give_donation_levels', true);
1849 1849
 
1850
-		foreach ( $levels as $level ) {
1850
+		foreach ($levels as $level) {
1851 1851
 
1852
-			$level_amount = give_maybe_sanitize_amount( $level['_give_amount'] );
1852
+			$level_amount = give_maybe_sanitize_amount($level['_give_amount']);
1853 1853
 
1854 1854
 			// Check that this indeed the recurring price.
1855
-			if ( $level_amount == $price ) {
1855
+			if ($level_amount == $price) {
1856 1856
 
1857 1857
 				$price_id = $level['_give_id']['level_id'];
1858 1858
 				break;
@@ -1860,13 +1860,13 @@  discard block
 block discarded – undo
1860 1860
 			}
1861 1861
 		}
1862 1862
 
1863
-		if( is_null( $price_id ) && give_is_custom_price_mode( $form_id ) ) {
1863
+		if (is_null($price_id) && give_is_custom_price_mode($form_id)) {
1864 1864
 			$price_id = 'custom';
1865 1865
 		}
1866 1866
 	}
1867 1867
 
1868 1868
 	// Price ID must be numeric or string.
1869
-	$price_id = ! is_numeric( $price_id ) && ! is_string( $price_id ) ? 0 : $price_id;
1869
+	$price_id = ! is_numeric($price_id) && ! is_string($price_id) ? 0 : $price_id;
1870 1870
 
1871 1871
 	return $price_id;
1872 1872
 }
@@ -1884,10 +1884,10 @@  discard block
 block discarded – undo
1884 1884
  *
1885 1885
  * @return string
1886 1886
  */
1887
-function give_get_form_dropdown( $args = array(), $echo = false ) {
1888
-	$form_dropdown_html = Give()->html->forms_dropdown( $args );
1887
+function give_get_form_dropdown($args = array(), $echo = false) {
1888
+	$form_dropdown_html = Give()->html->forms_dropdown($args);
1889 1889
 
1890
-	if ( ! $echo ) {
1890
+	if ( ! $echo) {
1891 1891
 		return $form_dropdown_html;
1892 1892
 	}
1893 1893
 
@@ -1904,17 +1904,17 @@  discard block
 block discarded – undo
1904 1904
  *
1905 1905
  * @return string|bool
1906 1906
  */
1907
-function give_get_form_variable_price_dropdown( $args = array(), $echo = false ) {
1907
+function give_get_form_variable_price_dropdown($args = array(), $echo = false) {
1908 1908
 
1909 1909
 	// Check for give form id.
1910
-	if ( empty( $args['id'] ) ) {
1910
+	if (empty($args['id'])) {
1911 1911
 		return false;
1912 1912
 	}
1913 1913
 
1914
-	$form = new Give_Donate_Form( $args['id'] );
1914
+	$form = new Give_Donate_Form($args['id']);
1915 1915
 
1916 1916
 	// Check if form has variable prices or not.
1917
-	if ( ! $form->ID || ! $form->has_variable_prices() ) {
1917
+	if ( ! $form->ID || ! $form->has_variable_prices()) {
1918 1918
 		return false;
1919 1919
 	}
1920 1920
 
@@ -1922,24 +1922,24 @@  discard block
 block discarded – undo
1922 1922
 	$variable_price_options = array();
1923 1923
 
1924 1924
 	// Check if multi donation form support custom donation or not.
1925
-	if ( $form->is_custom_price_mode() ) {
1926
-		$variable_price_options['custom'] = _x( 'Custom', 'custom donation dropdown item', 'give' );
1925
+	if ($form->is_custom_price_mode()) {
1926
+		$variable_price_options['custom'] = _x('Custom', 'custom donation dropdown item', 'give');
1927 1927
 	}
1928 1928
 
1929 1929
 	// Get variable price and ID from variable price array.
1930
-	foreach ( $variable_prices as $variable_price ) {
1931
-		$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 ) ) );
1930
+	foreach ($variable_prices as $variable_price) {
1931
+		$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)));
1932 1932
 	}
1933 1933
 
1934 1934
 	// Update options.
1935
-	$args = array_merge( $args, array(
1935
+	$args = array_merge($args, array(
1936 1936
 		'options' => $variable_price_options,
1937
-	) );
1937
+	));
1938 1938
 
1939 1939
 	// Generate select html.
1940
-	$form_dropdown_html = Give()->html->select( $args );
1940
+	$form_dropdown_html = Give()->html->select($args);
1941 1941
 
1942
-	if ( ! $echo ) {
1942
+	if ( ! $echo) {
1943 1943
 		return $form_dropdown_html;
1944 1944
 	}
1945 1945
 
@@ -1958,16 +1958,16 @@  discard block
 block discarded – undo
1958 1958
  *
1959 1959
  * @return string
1960 1960
  */
1961
-function give_get_payment_meta_price_id( $payment_meta ) {
1961
+function give_get_payment_meta_price_id($payment_meta) {
1962 1962
 
1963
-	if ( isset( $payment_meta['give_price_id'] ) ) {
1963
+	if (isset($payment_meta['give_price_id'])) {
1964 1964
 		$price_id = $payment_meta['give_price_id'];
1965
-	} elseif ( isset( $payment_meta['price_id'] ) ) {
1965
+	} elseif (isset($payment_meta['price_id'])) {
1966 1966
 		$price_id = $payment_meta['price_id'];
1967 1967
 	} else {
1968
-		$price_id = give_get_price_id( $payment_meta['give_form_id'], $payment_meta['price'] );
1968
+		$price_id = give_get_price_id($payment_meta['give_form_id'], $payment_meta['price']);
1969 1969
 	}
1970 1970
 
1971
-	return apply_filters( 'give_get_payment_meta_price_id', $price_id );
1971
+	return apply_filters('give_get_payment_meta_price_id', $price_id);
1972 1972
 
1973 1973
 }
Please login to merge, or discard this patch.
includes/user-functions.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -671,7 +671,7 @@
 block discarded – undo
671 671
 /**
672 672
  * This function will check whether the donor email is primary or additional.
673 673
  *
674
- * @param $email Donor Email.
674
+ * @param string $email Donor Email.
675 675
  *
676 676
  * @since 1.8.13
677 677
  *
Please login to merge, or discard this patch.
Spacing   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly.
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -30,54 +30,54 @@  discard block
 block discarded – undo
30 30
  *
31 31
  * @return bool|array List of all user donations.
32 32
  */
33
-function give_get_users_donations( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) {
33
+function give_get_users_donations($user = 0, $number = 20, $pagination = false, $status = 'complete') {
34 34
 
35
-	if ( empty( $user ) ) {
35
+	if (empty($user)) {
36 36
 		$user = get_current_user_id();
37 37
 	}
38 38
 
39
-	if ( 0 === $user && ! Give()->email_access->token_exists ) {
39
+	if (0 === $user && ! Give()->email_access->token_exists) {
40 40
 		return false;
41 41
 	}
42 42
 
43 43
 	$status = $status === 'complete' ? 'publish' : $status;
44 44
 	$paged = 1;
45 45
 
46
-	if ( $pagination ) {
47
-		if ( get_query_var( 'paged' ) ) {
48
-			$paged = get_query_var( 'paged' );
49
-		} elseif ( get_query_var( 'page' ) ) {
50
-			$paged = get_query_var( 'page' );
46
+	if ($pagination) {
47
+		if (get_query_var('paged')) {
48
+			$paged = get_query_var('paged');
49
+		} elseif (get_query_var('page')) {
50
+			$paged = get_query_var('page');
51 51
 		}
52 52
 	}
53 53
 
54
-	$args = apply_filters( 'give_get_users_donations_args', array(
54
+	$args = apply_filters('give_get_users_donations_args', array(
55 55
 		'user'    => $user,
56 56
 		'number'  => $number,
57 57
 		'status'  => $status,
58 58
 		'orderby' => 'date',
59
-	) );
59
+	));
60 60
 
61
-	if ( $pagination ) {
61
+	if ($pagination) {
62 62
 		$args['page'] = $paged;
63 63
 	} else {
64 64
 		$args['nopaging'] = true;
65 65
 	}
66 66
 
67
-	$by_user_id = is_numeric( $user ) ? true : false;
68
-	$donor   = new Give_Donor( $user, $by_user_id );
67
+	$by_user_id = is_numeric($user) ? true : false;
68
+	$donor = new Give_Donor($user, $by_user_id);
69 69
 
70
-	if ( ! empty( $donor->payment_ids ) ) {
70
+	if ( ! empty($donor->payment_ids)) {
71 71
 
72
-		unset( $args['user'] );
73
-		$args['post__in'] = array_map( 'absint', explode( ',', $donor->payment_ids ) );
72
+		unset($args['user']);
73
+		$args['post__in'] = array_map('absint', explode(',', $donor->payment_ids));
74 74
 
75 75
 	}
76 76
 
77
-	$donations = give_get_payments( apply_filters( 'give_get_users_donations_args', $args ) );
77
+	$donations = give_get_payments(apply_filters('give_get_users_donations_args', $args));
78 78
 
79 79
 	// No donations
80
-	if ( ! $donations ) {
80
+	if ( ! $donations) {
81 81
 		return false;
82 82
 	}
83 83
 
@@ -96,65 +96,65 @@  discard block
 block discarded – undo
96 96
  *
97 97
  * @return bool|object List of unique forms donated by user
98 98
  */
99
-function give_get_users_completed_donations( $user = 0, $status = 'complete' ) {
100
-	if ( empty( $user ) ) {
99
+function give_get_users_completed_donations($user = 0, $status = 'complete') {
100
+	if (empty($user)) {
101 101
 		$user = get_current_user_id();
102 102
 	}
103 103
 
104
-	if ( empty( $user ) ) {
104
+	if (empty($user)) {
105 105
 		return false;
106 106
 	}
107 107
 
108
-	$by_user_id = is_numeric( $user ) ? true : false;
108
+	$by_user_id = is_numeric($user) ? true : false;
109 109
 
110
-	$donor = new Give_Donor( $user, $by_user_id );
110
+	$donor = new Give_Donor($user, $by_user_id);
111 111
 
112
-	if ( empty( $donor->payment_ids ) ) {
112
+	if (empty($donor->payment_ids)) {
113 113
 		return false;
114 114
 	}
115 115
 
116 116
 	// Get all the items donated.
117
-	$payment_ids    = array_reverse( explode( ',', $donor->payment_ids ) );
118
-	$limit_payments = apply_filters( 'give_users_completed_donations_payments', 50 );
119
-	if ( ! empty( $limit_payments ) ) {
120
-		$payment_ids = array_slice( $payment_ids, 0, $limit_payments );
117
+	$payment_ids    = array_reverse(explode(',', $donor->payment_ids));
118
+	$limit_payments = apply_filters('give_users_completed_donations_payments', 50);
119
+	if ( ! empty($limit_payments)) {
120
+		$payment_ids = array_slice($payment_ids, 0, $limit_payments);
121 121
 	}
122 122
 	$donation_data = array();
123
-	foreach ( $payment_ids as $payment_id ) {
124
-		$donation_data[] = give_get_payment_meta( $payment_id );
123
+	foreach ($payment_ids as $payment_id) {
124
+		$donation_data[] = give_get_payment_meta($payment_id);
125 125
 	}
126 126
 
127
-	if ( empty( $donation_data ) ) {
127
+	if (empty($donation_data)) {
128 128
 		return false;
129 129
 	}
130 130
 
131 131
 	// Grab only the post ids "form_id" of the forms donated on this order
132 132
 	$completed_donations_ids = array();
133
-	foreach ( $donation_data as $donation_meta ) {
134
-		$completed_donations_ids[] = isset( $donation_meta['form_id'] ) ? $donation_meta['form_id'] : '';
133
+	foreach ($donation_data as $donation_meta) {
134
+		$completed_donations_ids[] = isset($donation_meta['form_id']) ? $donation_meta['form_id'] : '';
135 135
 	}
136 136
 
137
-	if ( empty( $completed_donations_ids ) ) {
137
+	if (empty($completed_donations_ids)) {
138 138
 		return false;
139 139
 	}
140 140
 
141 141
 	// Only include each donation once
142
-	$form_ids = array_unique( $completed_donations_ids );
142
+	$form_ids = array_unique($completed_donations_ids);
143 143
 
144 144
 	// Make sure we still have some products and a first item
145
-	if ( empty( $form_ids ) || ! isset( $form_ids[0] ) ) {
145
+	if (empty($form_ids) || ! isset($form_ids[0])) {
146 146
 		return false;
147 147
 	}
148 148
 
149
-	$post_type = get_post_type( $form_ids[0] );
149
+	$post_type = get_post_type($form_ids[0]);
150 150
 
151
-	$args = apply_filters( 'give_get_users_completed_donations_args', array(
151
+	$args = apply_filters('give_get_users_completed_donations_args', array(
152 152
 		'include'        => $form_ids,
153 153
 		'post_type'      => $post_type,
154
-		'posts_per_page' => - 1,
155
-	) );
154
+		'posts_per_page' => -1,
155
+	));
156 156
 
157
-	return apply_filters( 'give_users_completed_donations_list', get_posts( $args ) );
157
+	return apply_filters('give_users_completed_donations_list', get_posts($args));
158 158
 }
159 159
 
160 160
 
@@ -170,12 +170,12 @@  discard block
 block discarded – undo
170 170
  *
171 171
  * @return      bool True if has donated, false other wise.
172 172
  */
173
-function give_has_donations( $user_id = null ) {
174
-	if ( empty( $user_id ) ) {
173
+function give_has_donations($user_id = null) {
174
+	if (empty($user_id)) {
175 175
 		$user_id = get_current_user_id();
176 176
 	}
177 177
 
178
-	if ( give_get_users_donations( $user_id, 1 ) ) {
178
+	if (give_get_users_donations($user_id, 1)) {
179 179
 		return true; // User has at least one donation.
180 180
 	}
181 181
 
@@ -196,23 +196,23 @@  discard block
 block discarded – undo
196 196
  *
197 197
  * @return      array
198 198
  */
199
-function give_get_donation_stats_by_user( $user = '' ) {
199
+function give_get_donation_stats_by_user($user = '') {
200 200
 
201 201
 	$field = '';
202 202
 
203
-	if ( is_email( $user ) ) {
203
+	if (is_email($user)) {
204 204
 		$field = 'email';
205
-	} elseif ( is_numeric( $user ) ) {
205
+	} elseif (is_numeric($user)) {
206 206
 		$field = 'user_id';
207 207
 	}
208 208
 
209
-	$stats    = array();
210
-	$donor = Give()->donors->get_donor_by( $field, $user );
209
+	$stats = array();
210
+	$donor = Give()->donors->get_donor_by($field, $user);
211 211
 
212
-	if ( $donor ) {
213
-		$donor = new Give_Donor( $donor->id );
214
-		$stats['purchases']   = absint( $donor->purchase_count );
215
-		$stats['total_spent'] = give_maybe_sanitize_amount( $donor->purchase_value );
212
+	if ($donor) {
213
+		$donor = new Give_Donor($donor->id);
214
+		$stats['purchases']   = absint($donor->purchase_count);
215
+		$stats['total_spent'] = give_maybe_sanitize_amount($donor->purchase_value);
216 216
 	}
217 217
 
218 218
 	/**
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	 *
221 221
 	 * @since 1.7
222 222
 	 */
223
-	$stats = (array) apply_filters( 'give_donation_stats_by_user', $stats, $user );
223
+	$stats = (array) apply_filters('give_donation_stats_by_user', $stats, $user);
224 224
 
225 225
 	return $stats;
226 226
 }
@@ -238,21 +238,21 @@  discard block
 block discarded – undo
238 238
  *
239 239
  * @return      int The total number of donations.
240 240
  */
241
-function give_count_donations_of_donor( $user = null ) {
241
+function give_count_donations_of_donor($user = null) {
242 242
 
243 243
 	// Logged in?
244
-	if ( empty( $user ) ) {
244
+	if (empty($user)) {
245 245
 		$user = get_current_user_id();
246 246
 	}
247 247
 
248 248
 	// Email access?
249
-	if ( empty( $user ) && Give()->email_access->token_email ) {
249
+	if (empty($user) && Give()->email_access->token_email) {
250 250
 		$user = Give()->email_access->token_email;
251 251
 	}
252 252
 
253
-	$stats = ! empty( $user ) ? give_get_donation_stats_by_user( $user ) : false;
253
+	$stats = ! empty($user) ? give_get_donation_stats_by_user($user) : false;
254 254
 
255
-	return isset( $stats['purchases'] ) ? $stats['purchases'] : 0;
255
+	return isset($stats['purchases']) ? $stats['purchases'] : 0;
256 256
 }
257 257
 
258 258
 /**
@@ -265,9 +265,9 @@  discard block
 block discarded – undo
265 265
  *
266 266
  * @return      float The total amount the user has spent
267 267
  */
268
-function give_donation_total_of_user( $user = null ) {
268
+function give_donation_total_of_user($user = null) {
269 269
 
270
-	$stats = give_get_donation_stats_by_user( $user );
270
+	$stats = give_get_donation_stats_by_user($user);
271 271
 
272 272
 	return $stats['total_spent'];
273 273
 }
@@ -283,40 +283,40 @@  discard block
 block discarded – undo
283 283
  *
284 284
  * @return bool
285 285
  */
286
-function give_validate_username( $username, $form_id = 0 ) {
286
+function give_validate_username($username, $form_id = 0) {
287 287
 	$valid = true;
288 288
 
289 289
 	// Validate username.
290
-	if ( ! empty( $username ) ) {
290
+	if ( ! empty($username)) {
291 291
 
292 292
 		// Sanitize username.
293
-		$sanitized_user_name = sanitize_user( $username, false );
293
+		$sanitized_user_name = sanitize_user($username, false);
294 294
 
295 295
 		// We have an user name, check if it already exists.
296
-		if ( username_exists( $username ) ) {
296
+		if (username_exists($username)) {
297 297
 			// Username already registered.
298
-			give_set_error( 'username_unavailable', __( 'Username already taken.', 'give' ) );
298
+			give_set_error('username_unavailable', __('Username already taken.', 'give'));
299 299
 			$valid = false;
300 300
 
301 301
 			// Check if it's valid.
302
-		} elseif ( $sanitized_user_name !== $username ) {
302
+		} elseif ($sanitized_user_name !== $username) {
303 303
 			// Invalid username.
304
-			if ( is_multisite() ) {
305
-				give_set_error( 'username_invalid', __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ) );
304
+			if (is_multisite()) {
305
+				give_set_error('username_invalid', __('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give'));
306 306
 				$valid = false;
307 307
 			} else {
308
-				give_set_error( 'username_invalid', __( 'Invalid username.', 'give' ) );
308
+				give_set_error('username_invalid', __('Invalid username.', 'give'));
309 309
 				$valid = false;
310 310
 			}
311 311
 		}
312 312
 	} else {
313 313
 		// Username is empty.
314
-		give_set_error( 'username_empty', __( 'Enter a username.', 'give' ) );
314
+		give_set_error('username_empty', __('Enter a username.', 'give'));
315 315
 		$valid = false;
316 316
 
317 317
 		// Check if guest checkout is disable for form.
318
-		if ( $form_id && give_logged_in_only( $form_id ) ) {
319
-			give_set_error( 'registration_required', __( 'You must register or login to complete your donation.', 'give' ) );
318
+		if ($form_id && give_logged_in_only($form_id)) {
319
+			give_set_error('registration_required', __('You must register or login to complete your donation.', 'give'));
320 320
 			$valid = false;
321 321
 		}
322 322
 	}
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 	 * @param string $username
331 331
 	 * @param bool   $form_id
332 332
 	 */
333
-	$valid = (bool) apply_filters( 'give_validate_username', $valid, $username, $form_id );
333
+	$valid = (bool) apply_filters('give_validate_username', $valid, $username, $form_id);
334 334
 
335 335
 	return $valid;
336 336
 }
@@ -346,25 +346,25 @@  discard block
 block discarded – undo
346 346
  *
347 347
  * @return bool
348 348
  */
349
-function give_validate_user_email( $email, $registering_new_user = false ) {
349
+function give_validate_user_email($email, $registering_new_user = false) {
350 350
 	$valid = true;
351 351
 
352
-	if ( empty( $email ) ) {
352
+	if (empty($email)) {
353 353
 		// No email.
354
-		give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) );
354
+		give_set_error('email_empty', __('Enter an email.', 'give'));
355 355
 		$valid = false;
356 356
 
357
-	} elseif ( ! is_email( $email ) ) {
357
+	} elseif ( ! is_email($email)) {
358 358
 		// Validate email.
359
-		give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) );
359
+		give_set_error('email_invalid', __('Invalid email.', 'give'));
360 360
 		$valid = false;
361 361
 
362
-	} elseif ( $registering_new_user ) {
362
+	} elseif ($registering_new_user) {
363 363
 
364 364
 		// If donor email is not primary
365
-		if ( ! email_exists( $email ) && give_donor_email_exists( $email ) && give_is_additional_email( $email ) ) {
365
+		if ( ! email_exists($email) && give_donor_email_exists($email) && give_is_additional_email($email)) {
366 366
 			// Check if email exists.
367
-			give_set_error( 'email_used', __( 'The email address provided is already active for another user.', 'give' ) );
367
+			give_set_error('email_used', __('The email address provided is already active for another user.', 'give'));
368 368
 			$valid = false;
369 369
 		}
370 370
 	}
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 	 * @param string $email
379 379
 	 * @param bool   $registering_new_user
380 380
 	 */
381
-	$valid = (bool) apply_filters( 'give_validate_user_email', $valid, $email, $registering_new_user );
381
+	$valid = (bool) apply_filters('give_validate_user_email', $valid, $email, $registering_new_user);
382 382
 
383 383
 	return $valid;
384 384
 }
@@ -394,34 +394,34 @@  discard block
 block discarded – undo
394 394
  *
395 395
  * @return bool
396 396
  */
397
-function give_validate_user_password( $password = '', $confirm_password = '', $registering_new_user = false ) {
397
+function give_validate_user_password($password = '', $confirm_password = '', $registering_new_user = false) {
398 398
 	$valid = true;
399 399
 
400 400
 	// Passwords Validation For New Donors Only
401
-	if ( $registering_new_user ) {
401
+	if ($registering_new_user) {
402 402
 		// Password or confirmation missing.
403
-		if ( ! $password ) {
403
+		if ( ! $password) {
404 404
 			// The password is invalid.
405
-			give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) );
405
+			give_set_error('password_empty', __('Enter a password.', 'give'));
406 406
 			$valid = false;
407
-		} elseif ( ! $confirm_password ) {
407
+		} elseif ( ! $confirm_password) {
408 408
 			// Confirmation password is invalid.
409
-			give_set_error( 'confirmation_empty', __( 'Enter the password confirmation.', 'give' ) );
409
+			give_set_error('confirmation_empty', __('Enter the password confirmation.', 'give'));
410 410
 			$valid = false;
411 411
 		}
412 412
 	}
413 413
 	// Passwords Validation For New Donors as well as Existing Donors
414
-	if ( $password || $confirm_password ) {
415
-		if ( strlen( $password ) < 6 || strlen( $confirm_password ) < 6 ) {
414
+	if ($password || $confirm_password) {
415
+		if (strlen($password) < 6 || strlen($confirm_password) < 6) {
416 416
 			// Seems Weak Password
417
-			give_set_error( 'password_weak', __( 'Passwords should have at least 6 characters.', 'give' ) );
417
+			give_set_error('password_weak', __('Passwords should have at least 6 characters.', 'give'));
418 418
 			$valid = false;
419 419
 		}
420
-		if ( $password && $confirm_password ) {
420
+		if ($password && $confirm_password) {
421 421
 			// Verify confirmation matches.
422
-			if ( $password != $confirm_password ) {
422
+			if ($password != $confirm_password) {
423 423
 				// Passwords do not match
424
-				give_set_error( 'password_mismatch', __( 'Passwords you entered do not match. Please try again.', 'give' ) );
424
+				give_set_error('password_mismatch', __('Passwords you entered do not match. Please try again.', 'give'));
425 425
 				$valid = false;
426 426
 			}
427 427
 		}
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 	 * @param string $confirm_password
438 438
 	 * @param bool   $registering_new_user
439 439
 	 */
440
-	$valid = (bool) apply_filters( 'give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user );
440
+	$valid = (bool) apply_filters('give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user);
441 441
 
442 442
 	return $valid;
443 443
 }
@@ -455,19 +455,19 @@  discard block
 block discarded – undo
455 455
  *
456 456
  * @return      void
457 457
  */
458
-function give_add_past_donations_to_new_user( $user_id ) {
458
+function give_add_past_donations_to_new_user($user_id) {
459 459
 
460
-	$email = get_the_author_meta( 'user_email', $user_id );
460
+	$email = get_the_author_meta('user_email', $user_id);
461 461
 
462
-	$payments = give_get_payments( array(
462
+	$payments = give_get_payments(array(
463 463
 		's' => $email,
464
-	) );
464
+	));
465 465
 
466
-	if ( $payments ) {
467
-		foreach ( $payments as $payment ) {
466
+	if ($payments) {
467
+		foreach ($payments as $payment) {
468 468
 			/* @var $payment \Give_Payment */
469 469
 
470
-			if ( intval( give_get_payment_user_id( $payment->ID ) ) > 0 ) {
470
+			if (intval(give_get_payment_user_id($payment->ID)) > 0) {
471 471
 				continue;
472 472
 			}
473 473
 
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
 
480 480
 }
481 481
 
482
-add_action( 'user_register', 'give_add_past_donations_to_new_user' );
482
+add_action('user_register', 'give_add_past_donations_to_new_user');
483 483
 
484 484
 
485 485
 /**
@@ -505,34 +505,34 @@  discard block
 block discarded – undo
505 505
  *
506 506
  * @return        array The donor's address, if any
507 507
  */
508
-function give_get_donor_address( $user_id = 0 ) {
509
-	if ( empty( $user_id ) ) {
508
+function give_get_donor_address($user_id = 0) {
509
+	if (empty($user_id)) {
510 510
 		$user_id = get_current_user_id();
511 511
 	}
512 512
 
513
-	$address = get_user_meta( $user_id, '_give_user_address', true );
513
+	$address = get_user_meta($user_id, '_give_user_address', true);
514 514
 
515
-	if ( ! isset( $address['line1'] ) ) {
515
+	if ( ! isset($address['line1'])) {
516 516
 		$address['line1'] = '';
517 517
 	}
518 518
 
519
-	if ( ! isset( $address['line2'] ) ) {
519
+	if ( ! isset($address['line2'])) {
520 520
 		$address['line2'] = '';
521 521
 	}
522 522
 
523
-	if ( ! isset( $address['city'] ) ) {
523
+	if ( ! isset($address['city'])) {
524 524
 		$address['city'] = '';
525 525
 	}
526 526
 
527
-	if ( ! isset( $address['zip'] ) ) {
527
+	if ( ! isset($address['zip'])) {
528 528
 		$address['zip'] = '';
529 529
 	}
530 530
 
531
-	if ( ! isset( $address['country'] ) ) {
531
+	if ( ! isset($address['country'])) {
532 532
 		$address['country'] = '';
533 533
 	}
534 534
 
535
-	if ( ! isset( $address['state'] ) ) {
535
+	if ( ! isset($address['state'])) {
536 536
 		$address['state'] = '';
537 537
 	}
538 538
 
@@ -552,53 +552,53 @@  discard block
 block discarded – undo
552 552
  *
553 553
  * @return        void
554 554
  */
555
-function give_new_user_notification( $user_id = 0, $user_data = array() ) {
555
+function give_new_user_notification($user_id = 0, $user_data = array()) {
556 556
 
557
-	if ( empty( $user_id ) || empty( $user_data ) ) {
557
+	if (empty($user_id) || empty($user_data)) {
558 558
 		return;
559 559
 	}
560
-	$blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
560
+	$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
561 561
 
562 562
 	// New User Registration: Email sends to the site admin.
563 563
 	$emails = Give()->emails;
564
-	$emails->__set( 'heading', esc_html__( 'New User Registration', 'give' ) );
564
+	$emails->__set('heading', esc_html__('New User Registration', 'give'));
565 565
 
566 566
 	/* translators: %s: site name */
567
-	$message = sprintf( esc_attr__( 'A new user has registered on %s:', 'give' ), $blogname ) . "\r\n\r\n";
567
+	$message = sprintf(esc_attr__('A new user has registered on %s:', 'give'), $blogname)."\r\n\r\n";
568 568
 	/* translators: %s: user login */
569
-	$message .= '<strong>' . esc_attr__( 'Username:', 'give' ) . '</strong> ' . $user_data['user_login'] . "\r\n";
569
+	$message .= '<strong>'.esc_attr__('Username:', 'give').'</strong> '.$user_data['user_login']."\r\n";
570 570
 	/* translators: %s: user email */
571
-	$message .= '<strong>' . esc_attr__( 'E-mail:', 'give' ) . '</strong> ' . $user_data['user_email'] . "\r\n\r\n";
571
+	$message .= '<strong>'.esc_attr__('E-mail:', 'give').'</strong> '.$user_data['user_email']."\r\n\r\n";
572 572
 
573
-	$message .= '<a href="' . admin_url( 'user-edit.php?user_id=' . $user_id ) . '" target="_blank"> ' . esc_attr__( 'Click here to view &raquo;', 'give' ) . '</a>' . "\r\n";
573
+	$message .= '<a href="'.admin_url('user-edit.php?user_id='.$user_id).'" target="_blank"> '.esc_attr__('Click here to view &raquo;', 'give').'</a>'."\r\n";
574 574
 
575 575
 	$emails->send(
576
-		get_option( 'admin_email' ),
576
+		get_option('admin_email'),
577 577
 		sprintf(
578 578
 			/* translators: %s: site name */
579
-			esc_attr__( '[%s] New User Registration', 'give' ),
579
+			esc_attr__('[%s] New User Registration', 'give'),
580 580
 			$blogname
581 581
 		),
582 582
 		$message
583 583
 	);
584 584
 
585 585
 	// Account Information: Email sends to donor who registered.
586
-	$emails->__set( 'heading', esc_html__( 'Account Information', 'give' ) );
586
+	$emails->__set('heading', esc_html__('Account Information', 'give'));
587 587
 
588
-	$message = sprintf( esc_attr__( 'The following email contains your account information for %s:', 'give' ), $blogname ) . "\r\n\r\n";
588
+	$message = sprintf(esc_attr__('The following email contains your account information for %s:', 'give'), $blogname)."\r\n\r\n";
589 589
 
590 590
 	/* translators: %s: user login */
591
-	$message .= '<strong>' . esc_attr__( 'Username:', 'give' ) . '</strong> ' . $user_data['user_login'] . "\r\n";
591
+	$message .= '<strong>'.esc_attr__('Username:', 'give').'</strong> '.$user_data['user_login']."\r\n";
592 592
 	/* translators: %s: password */
593
-	$message .= '<strong>' . esc_attr__( 'Password:', 'give' ) . '</strong> ' . esc_attr__( '[Password entered during donation]', 'give' ) . "\r\n\r\n";
593
+	$message .= '<strong>'.esc_attr__('Password:', 'give').'</strong> '.esc_attr__('[Password entered during donation]', 'give')."\r\n\r\n";
594 594
 
595
-	$message .= '<a href="' . wp_login_url() . '" target="_blank"> ' . esc_attr__( 'Click here to login &raquo;', 'give' ) . '</a>' . "\r\n";
595
+	$message .= '<a href="'.wp_login_url().'" target="_blank"> '.esc_attr__('Click here to login &raquo;', 'give').'</a>'."\r\n";
596 596
 
597 597
 	$emails->send(
598 598
 		$user_data['user_email'],
599 599
 		sprintf(
600 600
 			/* translators: %s: site name */
601
-			esc_attr__( '[%s] Your username and password', 'give' ),
601
+			esc_attr__('[%s] Your username and password', 'give'),
602 602
 			$blogname
603 603
 		),
604 604
 		$message
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
 
607 607
 }
608 608
 
609
-add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 );
609
+add_action('give_insert_user', 'give_new_user_notification', 10, 2);
610 610
 
611 611
 
612 612
 /**
@@ -622,34 +622,34 @@  discard block
 block discarded – undo
622 622
  *
623 623
  * @return      string
624 624
  */
625
-function give_get_donor_name_by( $id = 0, $from = 'donation' ) {
625
+function give_get_donor_name_by($id = 0, $from = 'donation') {
626 626
 
627 627
 	// ID shouldn't be empty
628
-	if ( empty( $id ) ) {
628
+	if (empty($id)) {
629 629
 		return;
630 630
 	}
631 631
 
632 632
 	$name = '';
633 633
 
634
-	switch ( $from ) {
634
+	switch ($from) {
635 635
 
636 636
 		case 'donation':
637 637
 
638
-			$user_info = give_get_payment_meta_user_info( $id );
639
-			$name = $user_info['first_name'] . ' ' . $user_info['last_name'];
638
+			$user_info = give_get_payment_meta_user_info($id);
639
+			$name = $user_info['first_name'].' '.$user_info['last_name'];
640 640
 
641 641
 		break;
642 642
 
643 643
 		case 'donor':
644 644
 
645
-			$donor = new Give_Donor( $id );
645
+			$donor = new Give_Donor($id);
646 646
 			$name = $donor->name;
647 647
 
648 648
 		break;
649 649
 
650 650
 	}
651 651
 
652
-	return trim( $name );
652
+	return trim($name);
653 653
 
654 654
 }
655 655
 
@@ -661,8 +661,8 @@  discard block
 block discarded – undo
661 661
  * @param  string $email Donor Email.
662 662
  * @return boolean  The user's ID on success, and false on failure.
663 663
  */
664
-function give_donor_email_exists( $email ) {
665
-	if ( Give()->donors->get_donor_by( 'email', $email ) ) {
664
+function give_donor_email_exists($email) {
665
+	if (Give()->donors->get_donor_by('email', $email)) {
666 666
 		return true;
667 667
 	}
668 668
 	return false;
@@ -677,12 +677,12 @@  discard block
 block discarded – undo
677 677
  *
678 678
  * @return bool
679 679
  */
680
-function give_is_additional_email( $email ) {
680
+function give_is_additional_email($email) {
681 681
 	global $wpdb;
682
-	$meta_table  = Give()->donor_meta->table_name;
683
-	$donor_id = $wpdb->get_var( $wpdb->prepare( "SELECT customer_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $email ) );
682
+	$meta_table = Give()->donor_meta->table_name;
683
+	$donor_id = $wpdb->get_var($wpdb->prepare("SELECT customer_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $email));
684 684
 
685
-	if ( empty( $donor_id ) ) {
685
+	if (empty($donor_id)) {
686 686
 		return false;
687 687
 	}
688 688
 	return true;
Please login to merge, or discard this patch.
includes/process-donation.php 1 patch
Spacing   +247 added lines, -248 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
 
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @since 1.0
32 32
 	 */
33
-	do_action( 'give_pre_process_donation' );
33
+	do_action('give_pre_process_donation');
34 34
 
35 35
 	// Validate the form $_POST data
36 36
 	$valid_data = give_donation_form_validate_fields();
@@ -45,26 +45,26 @@  discard block
 block discarded – undo
45 45
 	 * @param bool|array $valid_data Validate fields.
46 46
 	 * @param array $_POST Array of variables passed via the HTTP POST.
47 47
 	 */
48
-	do_action( 'give_checkout_error_checks', $valid_data, $_POST );
48
+	do_action('give_checkout_error_checks', $valid_data, $_POST);
49 49
 
50
-	$is_ajax = isset( $_POST['give_ajax'] );
50
+	$is_ajax = isset($_POST['give_ajax']);
51 51
 
52 52
 	// Process the login form
53
-	if ( isset( $_POST['give_login_submit'] ) ) {
53
+	if (isset($_POST['give_login_submit'])) {
54 54
 		give_process_form_login();
55 55
 	}
56 56
 
57 57
 	// Validate the user
58
-	$user = give_get_donation_form_user( $valid_data );
58
+	$user = give_get_donation_form_user($valid_data);
59 59
 
60
-	if ( false === $valid_data || give_get_errors() || ! $user ) {
61
-		if ( $is_ajax ) {
60
+	if (false === $valid_data || give_get_errors() || ! $user) {
61
+		if ($is_ajax) {
62 62
 			/**
63 63
 			 * Fires when AJAX sends back errors from the donation form.
64 64
 			 *
65 65
 			 * @since 1.0
66 66
 			 */
67
-			do_action( 'give_ajax_donation_errors' );
67
+			do_action('give_ajax_donation_errors');
68 68
 			give_die();
69 69
 		} else {
70 70
 			return false;
@@ -72,17 +72,17 @@  discard block
 block discarded – undo
72 72
 	}
73 73
 
74 74
 	// If AJAX send back success to proceed with form submission
75
-	if ( $is_ajax ) {
75
+	if ($is_ajax) {
76 76
 		echo 'success';
77 77
 		give_die();
78 78
 	}
79 79
 
80 80
 	// After AJAX: Setup session if not using php_sessions
81
-	if ( ! Give()->session->use_php_sessions() ) {
81
+	if ( ! Give()->session->use_php_sessions()) {
82 82
 		// Double-check that set_cookie is publicly accessible;
83 83
 		// we're using a slightly modified class-wp-sessions.php
84
-		$session_reflection = new ReflectionMethod( 'WP_Session', 'set_cookie' );
85
-		if ( $session_reflection->isPublic() ) {
84
+		$session_reflection = new ReflectionMethod('WP_Session', 'set_cookie');
85
+		if ($session_reflection->isPublic()) {
86 86
 			// Manually set the cookie.
87 87
 			Give()->session->init()->set_cookie();
88 88
 		}
@@ -97,20 +97,19 @@  discard block
 block discarded – undo
97 97
 		'address'    => $user['address'],
98 98
 	);
99 99
 
100
-	$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
100
+	$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
101 101
 
102
-	$price        = isset( $_POST['give-amount'] ) ?
103
-		(float) apply_filters( 'give_donation_total', give_maybe_sanitize_amount( $_POST['give-amount'] ) ) :
104
-		'0.00';
105
-	$purchase_key = strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) );
102
+	$price        = isset($_POST['give-amount']) ?
103
+		(float) apply_filters('give_donation_total', give_maybe_sanitize_amount($_POST['give-amount'])) : '0.00';
104
+	$purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true)));
106 105
 
107 106
 	// Setup donation information
108 107
 	$donation_data = array(
109 108
 		'price'        => $price,
110 109
 		'purchase_key' => $purchase_key,
111 110
 		'user_email'   => $user['user_email'],
112
-		'date'         => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ),
113
-		'user_info'    => stripslashes_deep( $user_info ),
111
+		'date'         => date('Y-m-d H:i:s', current_time('timestamp')),
112
+		'user_info'    => stripslashes_deep($user_info),
114 113
 		'post_data'    => $_POST,
115 114
 		'gateway'      => $valid_data['gateway'],
116 115
 		'card_info'    => $valid_data['cc_info'],
@@ -130,10 +129,10 @@  discard block
 block discarded – undo
130 129
 	 * @param array $user_info Array containing basic user information.
131 130
 	 * @param bool|array $valid_data Validate fields.
132 131
 	 */
133
-	do_action( 'give_checkout_before_gateway', $_POST, $user_info, $valid_data );
132
+	do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data);
134 133
 
135 134
 	// Sanity check for price
136
-	if ( ! $donation_data['price'] ) {
135
+	if ( ! $donation_data['price']) {
137 136
 		// Revert to manual
138 137
 		$donation_data['gateway'] = 'manual';
139 138
 		$_POST['give-gateway']    = 'manual';
@@ -144,27 +143,27 @@  discard block
 block discarded – undo
144 143
 	 *
145 144
 	 * @since 1.7
146 145
 	 */
147
-	$donation_data = apply_filters( 'give_donation_data_before_gateway', $donation_data, $valid_data );
146
+	$donation_data = apply_filters('give_donation_data_before_gateway', $donation_data, $valid_data);
148 147
 
149 148
 	// Setup the data we're storing in the donation session
150 149
 	$session_data = $donation_data;
151 150
 
152 151
 	// Make sure credit card numbers are never stored in sessions
153
-	unset( $session_data['card_info']['card_number'] );
154
-	unset( $session_data['post_data']['card_number'] );
152
+	unset($session_data['card_info']['card_number']);
153
+	unset($session_data['post_data']['card_number']);
155 154
 
156 155
 	// Used for showing data to non logged-in users after donation, and for other plugins needing donation data.
157
-	give_set_purchase_session( $session_data );
156
+	give_set_purchase_session($session_data);
158 157
 
159 158
 	// Send info to the gateway for payment processing
160
-	give_send_to_gateway( $donation_data['gateway'], $donation_data );
159
+	give_send_to_gateway($donation_data['gateway'], $donation_data);
161 160
 	give_die();
162 161
 
163 162
 }
164 163
 
165
-add_action( 'give_purchase', 'give_process_donation_form' );
166
-add_action( 'wp_ajax_give_process_donation', 'give_process_donation_form' );
167
-add_action( 'wp_ajax_nopriv_give_process_donation', 'give_process_donation_form' );
164
+add_action('give_purchase', 'give_process_donation_form');
165
+add_action('wp_ajax_give_process_donation', 'give_process_donation_form');
166
+add_action('wp_ajax_nopriv_give_process_donation', 'give_process_donation_form');
168 167
 
169 168
 
170 169
 /**
@@ -177,29 +176,29 @@  discard block
 block discarded – undo
177 176
  *
178 177
  * @return void
179 178
  */
180
-function give_check_logged_in_user_for_existing_email( $valid_data, $post ) {
179
+function give_check_logged_in_user_for_existing_email($valid_data, $post) {
181 180
 
182 181
 	// Verify that the email address belongs to this customer.
183
-	if ( is_user_logged_in() ) {
182
+	if (is_user_logged_in()) {
184 183
 
185 184
 		$submitted_email = $valid_data['logged_in_user']['user_email'];
186
-		$donor           = new Give_Donor( get_current_user_id(), true );
185
+		$donor           = new Give_Donor(get_current_user_id(), true);
187 186
 
188 187
 		// If this email address is not registered with this customer, see if it belongs to any other customer
189 188
 		if (
190 189
 			$submitted_email !== $donor->email
191
-			&& ( is_array( $donor->emails ) && ! in_array( $submitted_email, $donor->emails ) )
190
+			&& (is_array($donor->emails) && ! in_array($submitted_email, $donor->emails))
192 191
 		) {
193
-			$found_donor = new Give_Donor( $submitted_email );
192
+			$found_donor = new Give_Donor($submitted_email);
194 193
 
195
-			if ( $found_donor->id > 0 ) {
196
-				give_set_error( 'give-customer-email-exists', sprintf( __( 'You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.', 'give' ), $donor->email, $submitted_email ) );
194
+			if ($found_donor->id > 0) {
195
+				give_set_error('give-customer-email-exists', sprintf(__('You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.', 'give'), $donor->email, $submitted_email));
197 196
 			}
198 197
 		}
199 198
 	}
200 199
 }
201 200
 
202
-add_action( 'give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2 );
201
+add_action('give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2);
203 202
 
204 203
 /**
205 204
  * Process the checkout login form
@@ -209,49 +208,49 @@  discard block
 block discarded – undo
209 208
  * @return      void
210 209
  */
211 210
 function give_process_form_login() {
212
-	$is_ajax = isset( $_POST['give_ajax'] );
211
+	$is_ajax = isset($_POST['give_ajax']);
213 212
 
214 213
 	$user_data = give_donation_form_validate_user_login();
215 214
 
216
-	if ( give_get_errors() || $user_data['user_id'] < 1 ) {
217
-		if ( $is_ajax ) {
215
+	if (give_get_errors() || $user_data['user_id'] < 1) {
216
+		if ($is_ajax) {
218 217
 			/**
219 218
 			 * Fires when AJAX sends back errors from the donation form.
220 219
 			 *
221 220
 			 * @since 1.0
222 221
 			 */
223 222
 			ob_start();
224
-			do_action( 'give_ajax_donation_errors' );
223
+			do_action('give_ajax_donation_errors');
225 224
 			$message = ob_get_contents();
226 225
 			ob_end_clean();
227
-			wp_send_json_error( $message );
226
+			wp_send_json_error($message);
228 227
 		} else {
229
-			wp_redirect( $_SERVER['HTTP_REFERER'] );
228
+			wp_redirect($_SERVER['HTTP_REFERER']);
230 229
 			exit;
231 230
 		}
232 231
 	}
233 232
 
234
-	give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] );
233
+	give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']);
235 234
 
236
-	if ( $is_ajax ) {
235
+	if ($is_ajax) {
237 236
 		$message = Give()->notices->print_frontend_notice(
238 237
 			sprintf(
239 238
 			/* translators: %s: user first name */
240
-				esc_html__( 'Welcome %s! You have successfully logged into your account.', 'give' ),
241
-				( ! empty( $user_data['user_first'] ) ) ? $user_data['user_first'] : $user_data['user_login']
239
+				esc_html__('Welcome %s! You have successfully logged into your account.', 'give'),
240
+				( ! empty($user_data['user_first'])) ? $user_data['user_first'] : $user_data['user_login']
242 241
 			),
243 242
 			false,
244 243
 			'success'
245 244
 		);
246 245
 
247
-		wp_send_json_success( $message );
246
+		wp_send_json_success($message);
248 247
 	} else {
249
-		wp_redirect( $_SERVER['HTTP_REFERER'] );
248
+		wp_redirect($_SERVER['HTTP_REFERER']);
250 249
 	}
251 250
 }
252 251
 
253
-add_action( 'wp_ajax_give_process_donation_login', 'give_process_form_login' );
254
-add_action( 'wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login' );
252
+add_action('wp_ajax_give_process_donation_login', 'give_process_form_login');
253
+add_action('wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login');
255 254
 
256 255
 /**
257 256
  * Donation Form Validate Fields.
@@ -263,55 +262,55 @@  discard block
 block discarded – undo
263 262
 function give_donation_form_validate_fields() {
264 263
 
265 264
 	// Check if there is $_POST
266
-	if ( empty( $_POST ) ) {
265
+	if (empty($_POST)) {
267 266
 		return false;
268 267
 	}
269 268
 
270
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
269
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
271 270
 
272 271
 	// Start an array to collect valid data
273 272
 	$valid_data = array(
274 273
 		'gateway'          => give_donation_form_validate_gateway(), // Gateway fallback (amount is validated here)
275
-		'need_new_user'    => false,     // New user flag
276
-		'need_user_login'  => false,     // Login user flag
277
-		'logged_user_data' => array(),   // Logged user collected data
278
-		'new_user_data'    => array(),   // New user collected data
279
-		'login_user_data'  => array(),   // Login user collected data
280
-		'guest_user_data'  => array(),   // Guest user collected data
281
-		'cc_info'          => give_donation_form_validate_cc(),// Credit card info
274
+		'need_new_user'    => false, // New user flag
275
+		'need_user_login'  => false, // Login user flag
276
+		'logged_user_data' => array(), // Logged user collected data
277
+		'new_user_data'    => array(), // New user collected data
278
+		'login_user_data'  => array(), // Login user collected data
279
+		'guest_user_data'  => array(), // Guest user collected data
280
+		'cc_info'          => give_donation_form_validate_cc(), // Credit card info
282 281
 	);
283 282
 
284 283
 	// Validate Honeypot First
285
-	if ( ! empty( $_POST['give-honeypot'] ) ) {
286
-		give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) );
284
+	if ( ! empty($_POST['give-honeypot'])) {
285
+		give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give'));
287 286
 	}
288 287
 
289 288
 	// Validate agree to terms
290
-	if ( give_is_terms_enabled( $form_id ) ) {
289
+	if (give_is_terms_enabled($form_id)) {
291 290
 		give_donation_form_validate_agree_to_terms();
292 291
 	}
293 292
 
294 293
 	// Stop processing donor registration, if donor registration is optional and donor can do guest checkout.
295 294
 	// If registration form username field is empty that means donor do not want to registration instead want guest checkout.
296 295
 	if (
297
-		! give_logged_in_only( $form_id )
298
-		&& isset( $_POST['give-purchase-var'] )
296
+		! give_logged_in_only($form_id)
297
+		&& isset($_POST['give-purchase-var'])
299 298
 		&& $_POST['give-purchase-var'] == 'needs-to-register'
300
-		&& empty( $_POST['give_user_login'] )
299
+		&& empty($_POST['give_user_login'])
301 300
 	) {
302
-		unset( $_POST['give-purchase-var'] );
301
+		unset($_POST['give-purchase-var']);
303 302
 	}
304 303
 
305
-	if ( is_user_logged_in() ) {
304
+	if (is_user_logged_in()) {
306 305
 		// Collect logged in user data.
307 306
 		$valid_data['logged_in_user'] = give_donation_form_validate_logged_in_user();
308
-	} elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) {
307
+	} elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') {
309 308
 		// Set new user registration as required.
310 309
 		$valid_data['need_new_user'] = true;
311 310
 		// Validate new user data.
312 311
 		$valid_data['new_user_data'] = give_donation_form_validate_new_user();
313 312
 		// Check if login validation is needed.
314
-	} elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) {
313
+	} elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') {
315 314
 		// Set user login as required.
316 315
 		$valid_data['need_user_login'] = true;
317 316
 		// Validate users login info.
@@ -336,41 +335,41 @@  discard block
 block discarded – undo
336 335
  */
337 336
 function give_donation_form_validate_gateway() {
338 337
 
339
-	$form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
340
-	$amount  = isset( $_REQUEST['give-amount'] ) ? give_maybe_sanitize_amount( $_REQUEST['give-amount'] ) : 0;
341
-	$gateway = give_get_default_gateway( $form_id );
338
+	$form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
339
+	$amount  = isset($_REQUEST['give-amount']) ? give_maybe_sanitize_amount($_REQUEST['give-amount']) : 0;
340
+	$gateway = give_get_default_gateway($form_id);
342 341
 
343 342
 	// Check if a gateway value is present.
344
-	if ( ! empty( $_REQUEST['give-gateway'] ) ) {
343
+	if ( ! empty($_REQUEST['give-gateway'])) {
345 344
 
346
-		$gateway = sanitize_text_field( $_REQUEST['give-gateway'] );
345
+		$gateway = sanitize_text_field($_REQUEST['give-gateway']);
347 346
 
348 347
 		// Is amount being donated in LIVE mode 0.00? If so, error:
349
-		if ( $amount == 0 && ! give_is_test_mode() ) {
348
+		if ($amount == 0 && ! give_is_test_mode()) {
350 349
 
351
-			give_set_error( 'invalid_donation_amount', __( 'Please insert a valid donation amount.', 'give' ) );
350
+			give_set_error('invalid_donation_amount', __('Please insert a valid donation amount.', 'give'));
352 351
 
353 352
 		} // End if().
354
-		elseif ( ! give_verify_minimum_price() ) {
353
+		elseif ( ! give_verify_minimum_price()) {
355 354
 			// translators: %s: minimum donation amount.
356 355
 			give_set_error(
357 356
 				'invalid_donation_minimum',
358 357
 				sprintf(
359 358
 				/* translators: %s: minimum donation amount */
360
-					__( 'This form has a minimum donation amount of %s.', 'give' ),
361
-					give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ), array( 'sanitize' => false ) ) )
359
+					__('This form has a minimum donation amount of %s.', 'give'),
360
+					give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id), array('sanitize' => false)))
362 361
 				)
363 362
 			);
364 363
 
365 364
 		} //Is this test mode zero donation? Let it through but set to manual gateway.
366
-		elseif ( $amount == 0 && give_is_test_mode() ) {
365
+		elseif ($amount == 0 && give_is_test_mode()) {
367 366
 
368 367
 			$gateway = 'manual';
369 368
 
370 369
 		} //Check if this gateway is active.
371
-		elseif ( ! give_is_gateway_active( $gateway ) ) {
370
+		elseif ( ! give_is_gateway_active($gateway)) {
372 371
 
373
-			give_set_error( 'invalid_gateway', __( 'The selected payment gateway is not enabled.', 'give' ) );
372
+			give_set_error('invalid_gateway', __('The selected payment gateway is not enabled.', 'give'));
374 373
 
375 374
 		}
376 375
 	}
@@ -388,21 +387,21 @@  discard block
 block discarded – undo
388 387
  */
389 388
 function give_verify_minimum_price() {
390 389
 
391
-	$amount          = give_maybe_sanitize_amount( $_REQUEST['give-amount'] );
392
-	$form_id         = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
393
-	$price_id        = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : null;
394
-	$variable_prices = give_has_variable_prices( $form_id );
390
+	$amount          = give_maybe_sanitize_amount($_REQUEST['give-amount']);
391
+	$form_id         = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
392
+	$price_id        = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : null;
393
+	$variable_prices = give_has_variable_prices($form_id);
395 394
 
396
-	if ( $variable_prices && in_array( $price_id, give_get_variable_price_ids( $form_id ) ) ) {
395
+	if ($variable_prices && in_array($price_id, give_get_variable_price_ids($form_id))) {
397 396
 
398
-		$price_level_amount = give_get_price_option_amount( $form_id, $price_id );
397
+		$price_level_amount = give_get_price_option_amount($form_id, $price_id);
399 398
 
400
-		if ( $price_level_amount == $amount ) {
399
+		if ($price_level_amount == $amount) {
401 400
 			return true;
402 401
 		}
403 402
 	}
404 403
 
405
-	if ( give_get_form_minimum_price( $form_id ) > $amount ) {
404
+	if (give_get_form_minimum_price($form_id) > $amount) {
406 405
 		return false;
407 406
 	}
408 407
 
@@ -418,9 +417,9 @@  discard block
 block discarded – undo
418 417
  */
419 418
 function give_donation_form_validate_agree_to_terms() {
420 419
 	// Validate agree to terms.
421
-	if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) {
420
+	if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) {
422 421
 		// User did not agree.
423
-		give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', __( 'You must agree to the terms and conditions.', 'give' ) ) );
422
+		give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', __('You must agree to the terms and conditions.', 'give')));
424 423
 	}
425 424
 }
426 425
 
@@ -434,59 +433,59 @@  discard block
 block discarded – undo
434 433
  *
435 434
  * @return      array
436 435
  */
437
-function give_get_required_fields( $form_id ) {
436
+function give_get_required_fields($form_id) {
438 437
 
439
-	$payment_mode = give_get_chosen_gateway( $form_id );
438
+	$payment_mode = give_get_chosen_gateway($form_id);
440 439
 
441 440
 	$required_fields = array(
442 441
 		'give_email' => array(
443 442
 			'error_id'      => 'invalid_email',
444
-			'error_message' => __( 'Please enter a valid email address.', 'give' ),
443
+			'error_message' => __('Please enter a valid email address.', 'give'),
445 444
 		),
446 445
 		'give_first' => array(
447 446
 			'error_id'      => 'invalid_first_name',
448
-			'error_message' => __( 'Please enter your first name.', 'give' ),
447
+			'error_message' => __('Please enter your first name.', 'give'),
449 448
 		),
450 449
 	);
451 450
 
452
-	$require_address = give_require_billing_address( $payment_mode );
451
+	$require_address = give_require_billing_address($payment_mode);
453 452
 
454
-	if ( $require_address ) {
455
-		$required_fields['card_address']    = array(
453
+	if ($require_address) {
454
+		$required_fields['card_address'] = array(
456 455
 			'error_id'      => 'invalid_card_address',
457
-			'error_message' => __( 'Please enter your primary billing address.', 'give' ),
456
+			'error_message' => __('Please enter your primary billing address.', 'give'),
458 457
 		);
459
-		$required_fields['card_zip']        = array(
458
+		$required_fields['card_zip'] = array(
460 459
 			'error_id'      => 'invalid_zip_code',
461
-			'error_message' => __( 'Please enter your zip / postal code.', 'give' ),
460
+			'error_message' => __('Please enter your zip / postal code.', 'give'),
462 461
 		);
463
-		$required_fields['card_city']       = array(
462
+		$required_fields['card_city'] = array(
464 463
 			'error_id'      => 'invalid_city',
465
-			'error_message' => __( 'Please enter your billing city.', 'give' ),
464
+			'error_message' => __('Please enter your billing city.', 'give'),
466 465
 		);
467 466
 		$required_fields['billing_country'] = array(
468 467
 			'error_id'      => 'invalid_country',
469
-			'error_message' => __( 'Please select your billing country.', 'give' ),
468
+			'error_message' => __('Please select your billing country.', 'give'),
470 469
 		);
471 470
 
472 471
 
473 472
 		$required_fields['card_state'] = array(
474 473
 			'error_id'      => 'invalid_state',
475
-			'error_message' => __( 'Please enter billing state / province / County.', 'give' ),
474
+			'error_message' => __('Please enter billing state / province / County.', 'give'),
476 475
 		);
477 476
 
478 477
 		// Check if billing country alredy exists.
479
-		if ( ! empty( $_POST['billing_country'] ) ) {
478
+		if ( ! empty($_POST['billing_country'])) {
480 479
 			// Get the value from $_POST.
481
-			$country = sanitize_text_field( $_POST['billing_country'] );
480
+			$country = sanitize_text_field($_POST['billing_country']);
482 481
 
483 482
 			// Get the country list that does not required any states init.
484 483
 			$states_country = give_states_not_required_country_list();
485 484
 
486 485
 			// Check if states is empty or not.
487
-			if ( array_key_exists( $country, $states_country ) ) {
486
+			if (array_key_exists($country, $states_country)) {
488 487
 				// If states is empty remove the required feilds of state in billing cart.
489
-				unset( $required_fields['card_state'] );
488
+				unset($required_fields['card_state']);
490 489
 			}
491 490
 		}
492 491
 	}
@@ -496,7 +495,7 @@  discard block
 block discarded – undo
496 495
 	 *
497 496
 	 * @since 1.7
498 497
 	 */
499
-	$required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id );
498
+	$required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id);
500 499
 
501 500
 	return $required_fields;
502 501
 
@@ -511,16 +510,16 @@  discard block
 block discarded – undo
511 510
  *
512 511
  * @return bool
513 512
  */
514
-function give_require_billing_address( $payment_mode ) {
513
+function give_require_billing_address($payment_mode) {
515 514
 
516 515
 	$return = false;
517 516
 
518
-	if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) {
517
+	if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) {
519 518
 		$return = true;
520 519
 	}
521 520
 
522 521
 	// Let payment gateways and other extensions determine if address fields should be required.
523
-	return apply_filters( 'give_require_billing_address', $return );
522
+	return apply_filters('give_require_billing_address', $return);
524 523
 
525 524
 }
526 525
 
@@ -534,42 +533,42 @@  discard block
 block discarded – undo
534 533
 function give_donation_form_validate_logged_in_user() {
535 534
 	global $user_ID;
536 535
 
537
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
536
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
538 537
 
539 538
 	// Start empty array to collect valid user data.
540 539
 	$valid_user_data = array(
541 540
 		// Assume there will be errors.
542
-		'user_id' => - 1,
541
+		'user_id' => -1,
543 542
 	);
544 543
 
545 544
 	// Verify there is a user_ID.
546
-	if ( $user_ID > 0 ) {
545
+	if ($user_ID > 0) {
547 546
 		// Get the logged in user data.
548
-		$user_data = get_userdata( $user_ID );
547
+		$user_data = get_userdata($user_ID);
549 548
 
550 549
 		// Loop through required fields and show error messages.
551
-		foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
552
-			if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
553
-				give_set_error( $value['error_id'], $value['error_message'] );
550
+		foreach (give_get_required_fields($form_id) as $field_name => $value) {
551
+			if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
552
+				give_set_error($value['error_id'], $value['error_message']);
554 553
 			}
555 554
 		}
556 555
 
557 556
 		// Verify data.
558
-		if ( $user_data ) {
557
+		if ($user_data) {
559 558
 			// Collected logged in user data.
560 559
 			$valid_user_data = array(
561 560
 				'user_id'    => $user_ID,
562
-				'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email,
563
-				'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name,
564
-				'user_last'  => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name,
561
+				'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email,
562
+				'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name,
563
+				'user_last'  => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name,
565 564
 			);
566 565
 
567
-			if ( ! is_email( $valid_user_data['user_email'] ) ) {
568
-				give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
566
+			if ( ! is_email($valid_user_data['user_email'])) {
567
+				give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
569 568
 			}
570 569
 		} else {
571 570
 			// Set invalid user error.
572
-			give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) );
571
+			give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give'));
573 572
 		}
574 573
 	}
575 574
 
@@ -588,7 +587,7 @@  discard block
 block discarded – undo
588 587
 	// Default user data.
589 588
 	$default_user_data = array(
590 589
 		'give-form-id'           => '',
591
-		'user_id'                => - 1, // Assume there will be errors.
590
+		'user_id'                => -1, // Assume there will be errors.
592 591
 		'user_first'             => '',
593 592
 		'user_last'              => '',
594 593
 		'give_user_login'        => false,
@@ -598,14 +597,14 @@  discard block
 block discarded – undo
598 597
 	);
599 598
 
600 599
 	// Get user data.
601
-	$user_data            = wp_parse_args( array_map( 'trim', give_clean( $_POST ) ), $default_user_data );
600
+	$user_data            = wp_parse_args(array_map('trim', give_clean($_POST)), $default_user_data);
602 601
 	$registering_new_user = false;
603
-	$form_id              = absint( $user_data['give-form-id'] );
602
+	$form_id              = absint($user_data['give-form-id']);
604 603
 
605 604
 	// Start an empty array to collect valid user data.
606 605
 	$valid_user_data = array(
607 606
 		// Assume there will be errors.
608
-		'user_id'    => - 1,
607
+		'user_id'    => -1,
609 608
 
610 609
 		// Get first name.
611 610
 		'user_first' => $user_data['give_first'],
@@ -615,25 +614,25 @@  discard block
 block discarded – undo
615 614
 	);
616 615
 
617 616
 	// Loop through required fields and show error messages.
618
-	foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
619
-		if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
620
-			give_set_error( $value['error_id'], $value['error_message'] );
617
+	foreach (give_get_required_fields($form_id) as $field_name => $value) {
618
+		if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
619
+			give_set_error($value['error_id'], $value['error_message']);
621 620
 		}
622 621
 	}
623 622
 
624 623
 	// Check if we have an username to register.
625
-	if ( give_validate_username( $user_data['give_user_login'] ) ) {
624
+	if (give_validate_username($user_data['give_user_login'])) {
626 625
 		$registering_new_user          = true;
627 626
 		$valid_user_data['user_login'] = $user_data['give_user_login'];
628 627
 	}
629 628
 
630 629
 	// Check if we have an email to verify.
631
-	if ( give_validate_user_email( $user_data['give_email'], $registering_new_user ) ) {
630
+	if (give_validate_user_email($user_data['give_email'], $registering_new_user)) {
632 631
 		$valid_user_data['user_email'] = $user_data['give_email'];
633 632
 	}
634 633
 
635 634
 	// Check password.
636
-	if ( give_validate_user_password( $user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user ) ) {
635
+	if (give_validate_user_password($user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user)) {
637 636
 		// All is good to go.
638 637
 		$valid_user_data['user_pass'] = $user_data['give_user_pass'];
639 638
 	}
@@ -653,36 +652,36 @@  discard block
 block discarded – undo
653 652
 	// Start an array to collect valid user data.
654 653
 	$valid_user_data = array(
655 654
 		// Assume there will be errors.
656
-		'user_id' => - 1,
655
+		'user_id' => -1,
657 656
 	);
658 657
 
659 658
 	// Username.
660
-	if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) {
661
-		give_set_error( 'must_log_in', __( 'You must register or login to complete your donation.', 'give' ) );
659
+	if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') {
660
+		give_set_error('must_log_in', __('You must register or login to complete your donation.', 'give'));
662 661
 
663 662
 		return $valid_user_data;
664 663
 	}
665 664
 
666 665
 	// Get the user by login.
667
-	$user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) );
666
+	$user_data = get_user_by('login', strip_tags($_POST['give_user_login']));
668 667
 
669 668
 	// Check if user exists.
670
-	if ( $user_data ) {
669
+	if ($user_data) {
671 670
 		// Get password.
672
-		$user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false;
671
+		$user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false;
673 672
 
674 673
 		// Check user_pass.
675
-		if ( $user_pass ) {
674
+		if ($user_pass) {
676 675
 			// Check if password is valid.
677
-			if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) {
676
+			if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) {
678 677
 				// Incorrect password.
679 678
 				give_set_error(
680 679
 					'password_incorrect',
681 680
 					sprintf(
682 681
 						'%1$s <a href="%2$s">%3$s</a>',
683
-						__( 'The password you entered is incorrect.', 'give' ),
684
-						wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ),
685
-						__( 'Reset Password', 'give' )
682
+						__('The password you entered is incorrect.', 'give'),
683
+						wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"),
684
+						__('Reset Password', 'give')
686 685
 					)
687 686
 				);
688 687
 				// All is correct.
@@ -699,11 +698,11 @@  discard block
 block discarded – undo
699 698
 			}
700 699
 		} else {
701 700
 			// Empty password.
702
-			give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) );
701
+			give_set_error('password_empty', __('Enter a password.', 'give'));
703 702
 		}
704 703
 	} else {
705 704
 		// No username.
706
-		give_set_error( 'username_incorrect', __( 'The username you entered does not exist.', 'give' ) );
705
+		give_set_error('username_incorrect', __('The username you entered does not exist.', 'give'));
707 706
 	}// End if().
708 707
 
709 708
 	return $valid_user_data;
@@ -718,7 +717,7 @@  discard block
 block discarded – undo
718 717
  */
719 718
 function give_donation_form_validate_guest_user() {
720 719
 
721
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
720
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
722 721
 
723 722
 	// Start an array to collect valid user data.
724 723
 	$valid_user_data = array(
@@ -727,38 +726,38 @@  discard block
 block discarded – undo
727 726
 	);
728 727
 
729 728
 	// Show error message if user must be logged in.
730
-	if ( give_logged_in_only( $form_id ) ) {
731
-		give_set_error( 'logged_in_only', __( 'You must be logged in to donate.', 'give' ) );
729
+	if (give_logged_in_only($form_id)) {
730
+		give_set_error('logged_in_only', __('You must be logged in to donate.', 'give'));
732 731
 	}
733 732
 
734 733
 	// Get the guest email.
735
-	$guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false;
734
+	$guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false;
736 735
 
737 736
 	// Check email.
738
-	if ( $guest_email && strlen( $guest_email ) > 0 ) {
737
+	if ($guest_email && strlen($guest_email) > 0) {
739 738
 		// Validate email.
740
-		if ( ! is_email( $guest_email ) ) {
739
+		if ( ! is_email($guest_email)) {
741 740
 			// Invalid email.
742
-			give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) );
741
+			give_set_error('email_invalid', __('Invalid email.', 'give'));
743 742
 		} else {
744 743
 			// All is good to go.
745 744
 			$valid_user_data['user_email'] = $guest_email;
746 745
 
747 746
 			// Get user_id from donor if exist.
748
-			$donor = new Give_Donor( $guest_email );
749
-			if ( $donor->id && $donor->user_id ) {
747
+			$donor = new Give_Donor($guest_email);
748
+			if ($donor->id && $donor->user_id) {
750 749
 				$valid_user_data['user_id'] = $donor->user_id;
751 750
 			}
752 751
 		}
753 752
 	} else {
754 753
 		// No email.
755
-		give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) );
754
+		give_set_error('email_empty', __('Enter an email.', 'give'));
756 755
 	}
757 756
 
758 757
 	// Loop through required fields and show error messages.
759
-	foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
760
-		if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
761
-			give_set_error( $value['error_id'], $value['error_message'] );
758
+	foreach (give_get_required_fields($form_id) as $field_name => $value) {
759
+		if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
760
+			give_set_error($value['error_id'], $value['error_message']);
762 761
 		}
763 762
 	}
764 763
 
@@ -774,36 +773,36 @@  discard block
 block discarded – undo
774 773
  * @since   1.0
775 774
  * @return  integer
776 775
  */
777
-function give_register_and_login_new_user( $user_data = array() ) {
776
+function give_register_and_login_new_user($user_data = array()) {
778 777
 	// Verify the array.
779
-	if ( empty( $user_data ) ) {
780
-		return - 1;
778
+	if (empty($user_data)) {
779
+		return -1;
781 780
 	}
782 781
 
783
-	if ( give_get_errors() ) {
784
-		return - 1;
782
+	if (give_get_errors()) {
783
+		return -1;
785 784
 	}
786 785
 
787
-	$user_args = apply_filters( 'give_insert_user_args', array(
788
-		'user_login'      => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '',
789
-		'user_pass'       => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '',
790
-		'user_email'      => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '',
791
-		'first_name'      => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '',
792
-		'last_name'       => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '',
793
-		'user_registered' => date( 'Y-m-d H:i:s' ),
794
-		'role'            => give_get_option( 'donor_default_user_role', 'give_donor' ),
795
-	), $user_data );
786
+	$user_args = apply_filters('give_insert_user_args', array(
787
+		'user_login'      => isset($user_data['user_login']) ? $user_data['user_login'] : '',
788
+		'user_pass'       => isset($user_data['user_pass']) ? $user_data['user_pass'] : '',
789
+		'user_email'      => isset($user_data['user_email']) ? $user_data['user_email'] : '',
790
+		'first_name'      => isset($user_data['user_first']) ? $user_data['user_first'] : '',
791
+		'last_name'       => isset($user_data['user_last']) ? $user_data['user_last'] : '',
792
+		'user_registered' => date('Y-m-d H:i:s'),
793
+		'role'            => give_get_option('donor_default_user_role', 'give_donor'),
794
+	), $user_data);
796 795
 
797 796
 	// Insert new user.
798
-	$user_id = wp_insert_user( $user_args );
797
+	$user_id = wp_insert_user($user_args);
799 798
 
800 799
 	// Validate inserted user.
801
-	if ( is_wp_error( $user_id ) ) {
802
-		return - 1;
800
+	if (is_wp_error($user_id)) {
801
+		return -1;
803 802
 	}
804 803
 
805 804
 	// Allow themes and plugins to filter the user data.
806
-	$user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args );
805
+	$user_data = apply_filters('give_insert_user_data', $user_data, $user_args);
807 806
 
808 807
 	/**
809 808
 	 * Fires after inserting user.
@@ -813,7 +812,7 @@  discard block
 block discarded – undo
813 812
 	 * @param int $user_id User id.
814 813
 	 * @param array $user_data Array containing user data.
815 814
 	 */
816
-	do_action( 'give_insert_user', $user_id, $user_data );
815
+	do_action('give_insert_user', $user_id, $user_data);
817 816
 
818 817
 	/**
819 818
 	 * Filter allow user to alter if user when to login or not when user is register for the first time.
@@ -822,9 +821,9 @@  discard block
 block discarded – undo
822 821
 	 *
823 822
 	 * return bool True if login with registration and False if only want to register.
824 823
 	 */
825
-	if ( true === (bool) apply_filters( 'give_log_user_in_on_register', true ) ) {
824
+	if (true === (bool) apply_filters('give_log_user_in_on_register', true)) {
826 825
 		// Login new user.
827
-		give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] );
826
+		give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']);
828 827
 	}
829 828
 
830 829
 	// Return user id.
@@ -840,27 +839,27 @@  discard block
 block discarded – undo
840 839
  * @since   1.0
841 840
  * @return  array|bool
842 841
  */
843
-function give_get_donation_form_user( $valid_data = array() ) {
842
+function give_get_donation_form_user($valid_data = array()) {
844 843
 
845 844
 	// Initialize user.
846 845
 	$user    = false;
847
-	$is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
846
+	$is_ajax = defined('DOING_AJAX') && DOING_AJAX;
848 847
 
849
-	if ( $is_ajax ) {
848
+	if ($is_ajax) {
850 849
 		// Do not create or login the user during the ajax submission (check for errors only).
851 850
 		return true;
852
-	} elseif ( is_user_logged_in() ) {
851
+	} elseif (is_user_logged_in()) {
853 852
 		// Set the valid user as the logged in collected data.
854 853
 		$user = $valid_data['logged_in_user'];
855
-	} elseif ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) {
854
+	} elseif ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) {
856 855
 		// New user registration.
857
-		if ( $valid_data['need_new_user'] === true ) {
856
+		if ($valid_data['need_new_user'] === true) {
858 857
 			// Set user.
859 858
 			$user = $valid_data['new_user_data'];
860 859
 			// Register and login new user.
861
-			$user['user_id'] = give_register_and_login_new_user( $user );
860
+			$user['user_id'] = give_register_and_login_new_user($user);
862 861
 			// User login
863
-		} elseif ( $valid_data['need_user_login'] === true && ! $is_ajax ) {
862
+		} elseif ($valid_data['need_user_login'] === true && ! $is_ajax) {
864 863
 
865 864
 			/**
866 865
 			 * The login form is now processed in the give_process_donation_login() function.
@@ -872,48 +871,48 @@  discard block
 block discarded – undo
872 871
 			// Set user.
873 872
 			$user = $valid_data['login_user_data'];
874 873
 			// Login user.
875
-			give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] );
874
+			give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']);
876 875
 		}
877 876
 	}
878 877
 
879 878
 	// Check guest checkout.
880
-	if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) {
879
+	if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) {
881 880
 		// Set user
882 881
 		$user = $valid_data['guest_user_data'];
883 882
 	}
884 883
 
885 884
 	// Verify we have an user.
886
-	if ( false === $user || empty( $user ) ) {
885
+	if (false === $user || empty($user)) {
887 886
 		// Return false.
888 887
 		return false;
889 888
 	}
890 889
 
891 890
 	// Get user first name.
892
-	if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) {
893
-		$user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : '';
891
+	if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) {
892
+		$user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : '';
894 893
 	}
895 894
 
896 895
 	// Get user last name.
897
-	if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) {
898
-		$user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : '';
896
+	if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) {
897
+		$user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : '';
899 898
 	}
900 899
 
901 900
 	// Get the user's billing address details.
902 901
 	$user['address']            = array();
903
-	$user['address']['line1']   = ! empty( $_POST['card_address'] ) ? give_clean( $_POST['card_address'] ) : false;
904
-	$user['address']['line2']   = ! empty( $_POST['card_address_2'] ) ? give_clean( $_POST['card_address_2'] ) : false;
905
-	$user['address']['city']    = ! empty( $_POST['card_city'] ) ? give_clean( $_POST['card_city'] ) : false;
906
-	$user['address']['state']   = ! empty( $_POST['card_state'] ) ? give_clean( $_POST['card_state'] ) : false;
907
-	$user['address']['zip']     = ! empty( $_POST['card_zip'] ) ? give_clean( $_POST['card_zip'] ) : false;
908
-	$user['address']['country'] = ! empty( $_POST['billing_country'] ) ? give_clean( $_POST['billing_country'] ) : false;
909
-
910
-	if ( empty( $user['address']['country'] ) ) {
902
+	$user['address']['line1']   = ! empty($_POST['card_address']) ? give_clean($_POST['card_address']) : false;
903
+	$user['address']['line2']   = ! empty($_POST['card_address_2']) ? give_clean($_POST['card_address_2']) : false;
904
+	$user['address']['city']    = ! empty($_POST['card_city']) ? give_clean($_POST['card_city']) : false;
905
+	$user['address']['state']   = ! empty($_POST['card_state']) ? give_clean($_POST['card_state']) : false;
906
+	$user['address']['zip']     = ! empty($_POST['card_zip']) ? give_clean($_POST['card_zip']) : false;
907
+	$user['address']['country'] = ! empty($_POST['billing_country']) ? give_clean($_POST['billing_country']) : false;
908
+
909
+	if (empty($user['address']['country'])) {
911 910
 		$user['address'] = false;
912 911
 	} // End if().
913 912
 
914
-	if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) {
913
+	if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) {
915 914
 		// Store the address in the user's meta so the donation form can be pre-populated with it on return donation.
916
-		update_user_meta( $user['user_id'], '_give_user_address', $user['address'] );
915
+		update_user_meta($user['user_id'], '_give_user_address', $user['address']);
917 916
 	}
918 917
 
919 918
 	// Return valid user.
@@ -932,16 +931,16 @@  discard block
 block discarded – undo
932 931
 	$card_data = give_get_donation_cc_info();
933 932
 
934 933
 	// Validate the card zip.
935
-	if ( ! empty( $card_data['card_zip'] ) ) {
936
-		if ( ! give_donation_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) {
937
-			give_set_error( 'invalid_cc_zip', __( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) );
934
+	if ( ! empty($card_data['card_zip'])) {
935
+		if ( ! give_donation_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) {
936
+			give_set_error('invalid_cc_zip', __('The zip / postal code you entered for your billing address is invalid.', 'give'));
938 937
 		}
939 938
 	}
940 939
 
941 940
 	// Ensure no spaces.
942
-	if ( ! empty( $card_data['card_number'] ) ) {
943
-		$card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs
944
-		$card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces
941
+	if ( ! empty($card_data['card_number'])) {
942
+		$card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs
943
+		$card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces
945 944
 	}
946 945
 
947 946
 	// This should validate card numbers at some point too.
@@ -958,17 +957,17 @@  discard block
 block discarded – undo
958 957
 function give_get_donation_cc_info() {
959 958
 
960 959
 	$cc_info                   = array();
961
-	$cc_info['card_name']      = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : '';
962
-	$cc_info['card_number']    = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : '';
963
-	$cc_info['card_cvc']       = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : '';
964
-	$cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : '';
965
-	$cc_info['card_exp_year']  = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : '';
966
-	$cc_info['card_address']   = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : '';
967
-	$cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : '';
968
-	$cc_info['card_city']      = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : '';
969
-	$cc_info['card_state']     = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : '';
970
-	$cc_info['card_country']   = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : '';
971
-	$cc_info['card_zip']       = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : '';
960
+	$cc_info['card_name']      = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : '';
961
+	$cc_info['card_number']    = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : '';
962
+	$cc_info['card_cvc']       = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : '';
963
+	$cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : '';
964
+	$cc_info['card_exp_year']  = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : '';
965
+	$cc_info['card_address']   = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : '';
966
+	$cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : '';
967
+	$cc_info['card_city']      = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : '';
968
+	$cc_info['card_state']     = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : '';
969
+	$cc_info['card_country']   = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : '';
970
+	$cc_info['card_zip']       = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : '';
972 971
 
973 972
 	// Return cc info.
974 973
 	return $cc_info;
@@ -984,14 +983,14 @@  discard block
 block discarded – undo
984 983
  *
985 984
  * @return bool|mixed
986 985
  */
987
-function give_donation_form_validate_cc_zip( $zip = 0, $country_code = '' ) {
986
+function give_donation_form_validate_cc_zip($zip = 0, $country_code = '') {
988 987
 	$ret = false;
989 988
 
990
-	if ( empty( $zip ) || empty( $country_code ) ) {
989
+	if (empty($zip) || empty($country_code)) {
991 990
 		return $ret;
992 991
 	}
993 992
 
994
-	$country_code = strtoupper( $country_code );
993
+	$country_code = strtoupper($country_code);
995 994
 
996 995
 	$zip_regex = array(
997 996
 		'AD' => 'AD\d{3}',
@@ -1151,11 +1150,11 @@  discard block
 block discarded – undo
1151 1150
 		'ZM' => '\d{5}',
1152 1151
 	);
1153 1152
 
1154
-	if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) {
1153
+	if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) {
1155 1154
 		$ret = true;
1156 1155
 	}
1157 1156
 
1158
-	return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code );
1157
+	return apply_filters('give_is_zip_valid', $ret, $zip, $country_code);
1159 1158
 }
1160 1159
 
1161 1160
 
@@ -1169,33 +1168,33 @@  discard block
 block discarded – undo
1169 1168
  *
1170 1169
  * @return bool
1171 1170
  */
1172
-function give_validate_multi_donation_form_level( $valid_data, $data ) {
1171
+function give_validate_multi_donation_form_level($valid_data, $data) {
1173 1172
 	/* @var Give_Donate_Form $form */
1174
-	$form = new Give_Donate_Form( $data['give-form-id'] );
1173
+	$form = new Give_Donate_Form($data['give-form-id']);
1175 1174
 
1176 1175
 	$donation_level_matched = false;
1177 1176
 
1178
-	if ( $form->is_multi_type_donation_form() ) {
1177
+	if ($form->is_multi_type_donation_form()) {
1179 1178
 
1180 1179
 		// Bailout.
1181
-		if ( ! ( $variable_prices = $form->get_prices() ) ) {
1180
+		if ( ! ($variable_prices = $form->get_prices())) {
1182 1181
 			return false;
1183 1182
 		}
1184 1183
 
1185 1184
 		// Sanitize donation amount.
1186
-		$data['give-amount'] = give_maybe_sanitize_amount( $data['give-amount'] );
1185
+		$data['give-amount'] = give_maybe_sanitize_amount($data['give-amount']);
1187 1186
 
1188
-		if ( $data['give-amount'] === give_maybe_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ) ) ) {
1187
+		if ($data['give-amount'] === give_maybe_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']))) {
1189 1188
 			return true;
1190 1189
 		}
1191 1190
 
1192 1191
 		// Find correct donation level from all donation levels.
1193
-		foreach ( $variable_prices as $variable_price ) {
1192
+		foreach ($variable_prices as $variable_price) {
1194 1193
 			// Sanitize level amount.
1195
-			$variable_price['_give_amount'] = give_maybe_sanitize_amount( $variable_price['_give_amount'] );
1194
+			$variable_price['_give_amount'] = give_maybe_sanitize_amount($variable_price['_give_amount']);
1196 1195
 
1197 1196
 			// Set first match donation level ID.
1198
-			if ( $data['give-amount'] === $variable_price['_give_amount'] ) {
1197
+			if ($data['give-amount'] === $variable_price['_give_amount']) {
1199 1198
 				$_POST['give-price-id'] = $variable_price['_give_id']['level_id'];
1200 1199
 				$donation_level_matched = true;
1201 1200
 				break;
@@ -1206,19 +1205,19 @@  discard block
 block discarded – undo
1206 1205
 		// If yes then set price id to custom if amount is greater then custom minimum amount (if any).
1207 1206
 		if (
1208 1207
 			! $donation_level_matched
1209
-			&& ( give_is_setting_enabled( give_get_meta( $data['give-form-id'], '_give_custom_amount', true ) ) )
1208
+			&& (give_is_setting_enabled(give_get_meta($data['give-form-id'], '_give_custom_amount', true)))
1210 1209
 		) {
1211 1210
 			// Sanitize custom minimum amount.
1212
-			$custom_minimum_amount = give_maybe_sanitize_amount( give_get_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ) );
1211
+			$custom_minimum_amount = give_maybe_sanitize_amount(give_get_meta($data['give-form-id'], '_give_custom_amount_minimum', true));
1213 1212
 
1214
-			if ( $data['give-amount'] >= $custom_minimum_amount ) {
1213
+			if ($data['give-amount'] >= $custom_minimum_amount) {
1215 1214
 				$_POST['give-price-id'] = 'custom';
1216 1215
 				$donation_level_matched = true;
1217 1216
 			}
1218 1217
 		}
1219 1218
 	}// End if().
1220 1219
 
1221
-	return ( $donation_level_matched ? true : false );
1220
+	return ($donation_level_matched ? true : false);
1222 1221
 }
1223 1222
 
1224
-add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 );
1223
+add_action('give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2);
Please login to merge, or discard this patch.
includes/error-tracking.php 1 patch
Spacing   +19 added lines, -19 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
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  * @return mixed array if errors are present, false if none found
26 26
  */
27 27
 function give_get_errors() {
28
-	return Give()->session->get( 'give_errors' );
28
+	return Give()->session->get('give_errors');
29 29
 }
30 30
 
31 31
 /**
@@ -42,23 +42,23 @@  discard block
 block discarded – undo
42 42
  *
43 43
  * @return void
44 44
  */
45
-function give_set_error( $error_id, $error_message, $notice_args = array() ) {
45
+function give_set_error($error_id, $error_message, $notice_args = array()) {
46 46
 	$errors = give_get_errors();
47
-	if ( ! $errors ) {
47
+	if ( ! $errors) {
48 48
 		$errors = array();
49 49
 	}
50 50
 
51
-	if( is_array( $notice_args ) && ! empty( $notice_args ) ) {
52
-		$errors[ $error_id ] = array(
51
+	if (is_array($notice_args) && ! empty($notice_args)) {
52
+		$errors[$error_id] = array(
53 53
 			'message'     => $error_message,
54 54
 			'notice_args' => $notice_args,
55 55
 		);
56 56
 	} else {
57 57
 		// Backward compatibility v<1.8.11.
58
-		$errors[ $error_id ] = $error_message;
58
+		$errors[$error_id] = $error_message;
59 59
 	}
60 60
 
61
-	Give()->session->set( 'give_errors', $errors );
61
+	Give()->session->set('give_errors', $errors);
62 62
 }
63 63
 
64 64
 /**
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
  * @return void
70 70
  */
71 71
 function give_clear_errors() {
72
-	Give()->session->set( 'give_errors', null );
72
+	Give()->session->set('give_errors', null);
73 73
 }
74 74
 
75 75
 /**
@@ -82,19 +82,19 @@  discard block
 block discarded – undo
82 82
  *
83 83
  * @return void
84 84
  */
85
-function give_unset_error( $error_id ) {
85
+function give_unset_error($error_id) {
86 86
 	$errors = give_get_errors();
87
-	if ( $errors ) {
87
+	if ($errors) {
88 88
 		/**
89 89
 		 * Check If $error_id exists in the array.
90 90
 		 * If exists then unset it.
91 91
 		 *
92 92
 		 * @since 1.8.13
93 93
 		 */
94
-		if ( isset( $errors[ $error_id ] ) ) {
95
-			unset( $errors[ $error_id ] );
94
+		if (isset($errors[$error_id])) {
95
+			unset($errors[$error_id]);
96 96
 		}
97
-		Give()->session->set( 'give_errors', $errors );
97
+		Give()->session->set('give_errors', $errors);
98 98
 	}
99 99
 }
100 100
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
  * @return string
106 106
  */
107 107
 function _give_die_handler() {
108
-	if ( defined( 'GIVE_UNIT_TESTS' ) ) {
108
+	if (defined('GIVE_UNIT_TESTS')) {
109 109
 		return '_give_die_handler';
110 110
 	} else {
111 111
 		die();
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
  *
126 126
  * @return void
127 127
  */
128
-function give_die( $message = '', $title = '', $status = 400 ) {
129
-	add_filter( 'wp_die_ajax_handler', '_give_die_handler', 10, 3 );
130
-	add_filter( 'wp_die_handler', '_give_die_handler', 10, 3 );
131
-	wp_die( $message, $title, array( 'response' => $status ) );
128
+function give_die($message = '', $title = '', $status = 400) {
129
+	add_filter('wp_die_ajax_handler', '_give_die_handler', 10, 3);
130
+	add_filter('wp_die_handler', '_give_die_handler', 10, 3);
131
+	wp_die($message, $title, array('response' => $status));
132 132
 }
Please login to merge, or discard this patch.
includes/scripts.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -363,8 +363,8 @@
 block discarded – undo
363 363
 			'ajax_search_msg' => __( 'Searching results for match {search_term}', 'give' ),
364 364
 		),
365 365
 		'db_update_confirmation_msg' => __( 'The following process will make updates to your site\'s database. Please create a database backup before proceeding with updates.', 'give' ),
366
-        'error_message' => __( 'Something went wrong kindly try again!','give' ),
367
-        'give_donation_import' => 'give_donation_import',
366
+		'error_message' => __( 'Something went wrong kindly try again!','give' ),
367
+		'give_donation_import' => 'give_donation_import',
368 368
 	) );
369 369
 
370 370
 	if ( function_exists( 'wp_enqueue_media' ) && version_compare( get_bloginfo( 'version' ), '3.5', '>=' ) ) {
Please login to merge, or discard this patch.
Spacing   +167 added lines, -167 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
 
@@ -25,26 +25,26 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function give_load_scripts() {
27 27
 
28
-	$js_dir         = GIVE_PLUGIN_URL . 'assets/js/frontend/';
29
-	$js_plugins     = GIVE_PLUGIN_URL . 'assets/js/plugins/';
30
-	$scripts_footer = ( give_is_setting_enabled( give_get_option( 'scripts_footer' ) ) ) ? true : false;
28
+	$js_dir         = GIVE_PLUGIN_URL.'assets/js/frontend/';
29
+	$js_plugins     = GIVE_PLUGIN_URL.'assets/js/plugins/';
30
+	$scripts_footer = (give_is_setting_enabled(give_get_option('scripts_footer'))) ? true : false;
31 31
 
32 32
 	// Use minified libraries if SCRIPT_DEBUG is turned off.
33
-	$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
33
+	$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
34 34
 
35 35
 	// Localize / PHP to AJAX vars.
36
-	$localize_give_vars = apply_filters( 'give_global_script_vars', array(
36
+	$localize_give_vars = apply_filters('give_global_script_vars', array(
37 37
 		'ajaxurl'             => give_get_ajax_url(),
38
-		'checkout_nonce'      => wp_create_nonce( 'give_checkout_nonce' ),
38
+		'checkout_nonce'      => wp_create_nonce('give_checkout_nonce'),
39 39
 		'currency'            => give_get_currency(),
40
-		'currency_sign'       => give_currency_filter( '' ),
40
+		'currency_sign'       => give_currency_filter(''),
41 41
 		'currency_pos'        => give_get_currency_position(),
42 42
 		'thousands_separator' => give_get_price_thousand_separator(),
43 43
 		'decimal_separator'   => give_get_price_decimal_separator(),
44
-		'no_gateway'          => __( 'Please select a payment method.', 'give' ),
45
-		'bad_minimum'         => __( 'The minimum custom donation amount for this form is', 'give' ),
46
-		'general_loading'     => __( 'Loading...', 'give' ),
47
-		'purchase_loading'    => __( 'Please Wait...', 'give' ),
44
+		'no_gateway'          => __('Please select a payment method.', 'give'),
45
+		'bad_minimum'         => __('The minimum custom donation amount for this form is', 'give'),
46
+		'general_loading'     => __('Loading...', 'give'),
47
+		'purchase_loading'    => __('Please Wait...', 'give'),
48 48
 		'number_decimals'     => give_get_price_decimals(),
49 49
 		'give_version'        => GIVE_VERSION,
50 50
 		'magnific_options'    => apply_filters(
@@ -58,81 +58,81 @@  discard block
 block discarded – undo
58 58
 			'give_form_translation_js',
59 59
 			array(
60 60
 				// Field name               Validation message.
61
-				'payment-mode'           => __( 'Please select payment mode.', 'give' ),
62
-				'give_first'             => __( 'Please enter your first name.', 'give' ),
63
-				'give_email'             => __( 'Please enter a valid email address.', 'give' ),
64
-				'give_user_login'        => __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ),
65
-				'give_user_pass'         => __( 'Enter a password.', 'give' ),
66
-				'give_user_pass_confirm' => __( 'Enter the password confirmation.', 'give' ),
67
-				'give_agree_to_terms'    => __( 'You must agree to the terms and conditions.', 'give' ),
61
+				'payment-mode'           => __('Please select payment mode.', 'give'),
62
+				'give_first'             => __('Please enter your first name.', 'give'),
63
+				'give_email'             => __('Please enter a valid email address.', 'give'),
64
+				'give_user_login'        => __('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give'),
65
+				'give_user_pass'         => __('Enter a password.', 'give'),
66
+				'give_user_pass_confirm' => __('Enter the password confirmation.', 'give'),
67
+				'give_agree_to_terms'    => __('You must agree to the terms and conditions.', 'give'),
68 68
 			)
69 69
 		),
70
-	) );
70
+	));
71 71
 
72
-	$localize_give_ajax = apply_filters( 'give_global_ajax_vars', array(
72
+	$localize_give_ajax = apply_filters('give_global_ajax_vars', array(
73 73
 		'ajaxurl'         => give_get_ajax_url(),
74
-		'loading'         => __( 'Loading', 'give' ),
74
+		'loading'         => __('Loading', 'give'),
75 75
 		// General loading message.
76
-		'select_option'   => __( 'Please select an option', 'give' ),
76
+		'select_option'   => __('Please select an option', 'give'),
77 77
 		// Variable pricing error with multi-donation option enabled.
78
-		'default_gateway' => give_get_default_gateway( null ),
79
-		'permalinks'      => get_option( 'permalink_structure' ) ? '1' : '0',
78
+		'default_gateway' => give_get_default_gateway(null),
79
+		'permalinks'      => get_option('permalink_structure') ? '1' : '0',
80 80
 		'number_decimals' => give_get_price_decimals(),
81
-	) );
81
+	));
82 82
 
83 83
 	// DEBUG is On.
84
-	if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
84
+	if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) {
85 85
 
86
-		if ( give_is_cc_verify_enabled() ) {
87
-			wp_register_script( 'give-cc-validator', $js_plugins . 'jquery.payment' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
88
-			wp_enqueue_script( 'give-cc-validator' );
86
+		if (give_is_cc_verify_enabled()) {
87
+			wp_register_script('give-cc-validator', $js_plugins.'jquery.payment'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
88
+			wp_enqueue_script('give-cc-validator');
89 89
 		}
90 90
 
91
-		wp_register_script( 'give-float-labels', $js_plugins . 'float-labels' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
92
-		wp_enqueue_script( 'give-float-labels' );
91
+		wp_register_script('give-float-labels', $js_plugins.'float-labels'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
92
+		wp_enqueue_script('give-float-labels');
93 93
 
94
-		wp_register_script( 'give-blockui', $js_plugins . 'jquery.blockUI' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
95
-		wp_enqueue_script( 'give-blockui' );
94
+		wp_register_script('give-blockui', $js_plugins.'jquery.blockUI'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
95
+		wp_enqueue_script('give-blockui');
96 96
 
97
-		wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
98
-		wp_enqueue_script( 'give-qtip' );
97
+		wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
98
+		wp_enqueue_script('give-qtip');
99 99
 
100
-		wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
101
-		wp_enqueue_script( 'give-accounting' );
100
+		wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
101
+		wp_enqueue_script('give-accounting');
102 102
 
103
-		wp_register_script( 'give-magnific', $js_plugins . 'jquery.magnific-popup' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
104
-		wp_enqueue_script( 'give-magnific' );
103
+		wp_register_script('give-magnific', $js_plugins.'jquery.magnific-popup'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
104
+		wp_enqueue_script('give-magnific');
105 105
 
106
-		wp_register_script( 'give-checkout-global', $js_dir . 'give-checkout-global' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
107
-		wp_enqueue_script( 'give-checkout-global' );
106
+		wp_register_script('give-checkout-global', $js_dir.'give-checkout-global'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
107
+		wp_enqueue_script('give-checkout-global');
108 108
 
109 109
 		// General scripts.
110
-		wp_register_script( 'give-scripts', $js_dir . 'give' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
111
-		wp_enqueue_script( 'give-scripts' );
110
+		wp_register_script('give-scripts', $js_dir.'give'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
111
+		wp_enqueue_script('give-scripts');
112 112
 
113 113
 		// Load AJAX scripts, if enabled.
114
-		wp_register_script( 'give-ajax', $js_dir . 'give-ajax' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
115
-		wp_enqueue_script( 'give-ajax' );
114
+		wp_register_script('give-ajax', $js_dir.'give-ajax'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
115
+		wp_enqueue_script('give-ajax');
116 116
 
117 117
 		// Localize / Pass AJAX vars from PHP,
118
-		wp_localize_script( 'give-checkout-global', 'give_global_vars', $localize_give_vars );
119
-		wp_localize_script( 'give-ajax', 'give_scripts', $localize_give_ajax );
118
+		wp_localize_script('give-checkout-global', 'give_global_vars', $localize_give_vars);
119
+		wp_localize_script('give-ajax', 'give_scripts', $localize_give_ajax);
120 120
 
121 121
 	} else {
122 122
 
123 123
 		// DEBUG is OFF (one JS file to rule them all!).
124
-		wp_register_script( 'give', $js_dir . 'give.all.min.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
125
-		wp_enqueue_script( 'give' );
124
+		wp_register_script('give', $js_dir.'give.all.min.js', array('jquery'), GIVE_VERSION, $scripts_footer);
125
+		wp_enqueue_script('give');
126 126
 
127 127
 		// Localize / Pass AJAX vars from PHP.
128
-		wp_localize_script( 'give', 'give_global_vars', $localize_give_vars );
129
-		wp_localize_script( 'give', 'give_scripts', $localize_give_ajax );
128
+		wp_localize_script('give', 'give_global_vars', $localize_give_vars);
129
+		wp_localize_script('give', 'give_scripts', $localize_give_ajax);
130 130
 
131 131
 	}
132 132
 
133 133
 }
134 134
 
135
-add_action( 'wp_enqueue_scripts', 'give_load_scripts' );
135
+add_action('wp_enqueue_scripts', 'give_load_scripts');
136 136
 
137 137
 /**
138 138
  * Register styles.
@@ -145,16 +145,16 @@  discard block
 block discarded – undo
145 145
  */
146 146
 function give_register_styles() {
147 147
 
148
-	if ( ! give_is_setting_enabled( give_get_option( 'css' ) ) ) {
148
+	if ( ! give_is_setting_enabled(give_get_option('css'))) {
149 149
 		return;
150 150
 	}
151 151
 
152
-	wp_register_style( 'give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all' );
153
-	wp_enqueue_style( 'give-styles' );
152
+	wp_register_style('give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all');
153
+	wp_enqueue_style('give-styles');
154 154
 
155 155
 }
156 156
 
157
-add_action( 'wp_enqueue_scripts', 'give_register_styles' );
157
+add_action('wp_enqueue_scripts', 'give_register_styles');
158 158
 
159 159
 
160 160
 /**
@@ -167,19 +167,19 @@  discard block
 block discarded – undo
167 167
 function give_get_stylesheet_uri() {
168 168
 
169 169
 	// Use minified libraries if SCRIPT_DEBUG is turned off.
170
-	$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
170
+	$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
171 171
 
172 172
 	// LTR or RTL files.
173
-	$direction = ( is_rtl() ) ? '-rtl' : '';
173
+	$direction = (is_rtl()) ? '-rtl' : '';
174 174
 
175
-	$file          = 'give' . $direction . $suffix . '.css';
175
+	$file          = 'give'.$direction.$suffix.'.css';
176 176
 	$templates_dir = give_get_theme_template_dir_name();
177 177
 
178
-	$child_theme_style_sheet    = trailingslashit( get_stylesheet_directory() ) . $templates_dir . $file;
179
-	$child_theme_style_sheet_2  = trailingslashit( get_stylesheet_directory() ) . $templates_dir . 'give' . $direction . '.css';
180
-	$parent_theme_style_sheet   = trailingslashit( get_template_directory() ) . $templates_dir . $file;
181
-	$parent_theme_style_sheet_2 = trailingslashit( get_template_directory() ) . $templates_dir . 'give' . $direction . '.css';
182
-	$give_plugin_style_sheet    = trailingslashit( give_get_templates_dir() ) . $file;
178
+	$child_theme_style_sheet    = trailingslashit(get_stylesheet_directory()).$templates_dir.$file;
179
+	$child_theme_style_sheet_2  = trailingslashit(get_stylesheet_directory()).$templates_dir.'give'.$direction.'.css';
180
+	$parent_theme_style_sheet   = trailingslashit(get_template_directory()).$templates_dir.$file;
181
+	$parent_theme_style_sheet_2 = trailingslashit(get_template_directory()).$templates_dir.'give'.$direction.'.css';
182
+	$give_plugin_style_sheet    = trailingslashit(give_get_templates_dir()).$file;
183 183
 
184 184
 	$uri = false;
185 185
 
@@ -189,23 +189,23 @@  discard block
 block discarded – undo
189 189
 	 * followed by non minified version, even if SCRIPT_DEBUG is not enabled.
190 190
 	 * This allows users to copy just give.css to their theme.
191 191
 	 */
192
-	if ( file_exists( $child_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $child_theme_style_sheet_2 ) ) ) ) {
193
-		if ( ! empty( $nonmin ) ) {
194
-			$uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . 'give' . $direction . '.css';
192
+	if (file_exists($child_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($child_theme_style_sheet_2)))) {
193
+		if ( ! empty($nonmin)) {
194
+			$uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.'give'.$direction.'.css';
195 195
 		} else {
196
-			$uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . $file;
196
+			$uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.$file;
197 197
 		}
198
-	} elseif ( file_exists( $parent_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $parent_theme_style_sheet_2 ) ) ) ) {
199
-		if ( ! empty( $nonmin ) ) {
200
-			$uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . 'give' . $direction . '.css';
198
+	} elseif (file_exists($parent_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($parent_theme_style_sheet_2)))) {
199
+		if ( ! empty($nonmin)) {
200
+			$uri = trailingslashit(get_template_directory_uri()).$templates_dir.'give'.$direction.'.css';
201 201
 		} else {
202
-			$uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . $file;
202
+			$uri = trailingslashit(get_template_directory_uri()).$templates_dir.$file;
203 203
 		}
204
-	} elseif ( file_exists( $give_plugin_style_sheet ) || file_exists( $give_plugin_style_sheet ) ) {
205
-		$uri = trailingslashit( give_get_templates_url() ) . $file;
204
+	} elseif (file_exists($give_plugin_style_sheet) || file_exists($give_plugin_style_sheet)) {
205
+		$uri = trailingslashit(give_get_templates_url()).$file;
206 206
 	}
207 207
 
208
-	return apply_filters( 'give_get_stylesheet_uri', $uri );
208
+	return apply_filters('give_get_stylesheet_uri', $uri);
209 209
 
210 210
 }
211 211
 
@@ -222,79 +222,79 @@  discard block
 block discarded – undo
222 222
  *
223 223
  * @return void
224 224
  */
225
-function give_load_admin_scripts( $hook ) {
225
+function give_load_admin_scripts($hook) {
226 226
 
227 227
 	global $post, $post_type;
228 228
 
229 229
 	$give_options = give_get_settings();
230 230
 
231 231
 	// Directories of assets.
232
-	$js_dir     = GIVE_PLUGIN_URL . 'assets/js/admin/';
233
-	$js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/';
234
-	$css_dir    = GIVE_PLUGIN_URL . 'assets/css/';
232
+	$js_dir     = GIVE_PLUGIN_URL.'assets/js/admin/';
233
+	$js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/';
234
+	$css_dir    = GIVE_PLUGIN_URL.'assets/css/';
235 235
 
236 236
 	// Use minified libraries if SCRIPT_DEBUG is turned off.
237
-	$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
237
+	$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
238 238
 
239 239
 	// LTR or RTL files.
240
-	$direction = ( is_rtl() ) ? '-rtl' : '';
240
+	$direction = (is_rtl()) ? '-rtl' : '';
241 241
 
242 242
 	// Global Admin.
243
-	wp_register_style( 'give-admin-bar-notification', $css_dir . 'adminbar-style.css' );
244
-	wp_enqueue_style( 'give-admin-bar-notification' );
243
+	wp_register_style('give-admin-bar-notification', $css_dir.'adminbar-style.css');
244
+	wp_enqueue_style('give-admin-bar-notification');
245 245
 
246 246
 	// Give Admin Only.
247
-	if ( ! apply_filters( 'give_load_admin_scripts', give_is_admin_page(), $hook ) ) {
247
+	if ( ! apply_filters('give_load_admin_scripts', give_is_admin_page(), $hook)) {
248 248
 		return;
249 249
 	}
250 250
 
251 251
 	// CSS.
252
-	wp_register_style( 'jquery-ui-css', $css_dir . 'jquery-ui-fresh' . $suffix . '.css' );
253
-	wp_enqueue_style( 'jquery-ui-css' );
254
-	wp_register_style( 'give-admin', $css_dir . 'give-admin' . $direction . $suffix . '.css', array(), GIVE_VERSION );
255
-	wp_enqueue_style( 'give-admin' );
256
-	wp_register_style( 'jquery-chosen', $css_dir . 'chosen' . $suffix . '.css', array(), GIVE_VERSION );
257
-	wp_enqueue_style( 'jquery-chosen' );
258
-	wp_enqueue_style( 'thickbox' );
259
-	wp_enqueue_style( 'wp-color-picker' );
252
+	wp_register_style('jquery-ui-css', $css_dir.'jquery-ui-fresh'.$suffix.'.css');
253
+	wp_enqueue_style('jquery-ui-css');
254
+	wp_register_style('give-admin', $css_dir.'give-admin'.$direction.$suffix.'.css', array(), GIVE_VERSION);
255
+	wp_enqueue_style('give-admin');
256
+	wp_register_style('jquery-chosen', $css_dir.'chosen'.$suffix.'.css', array(), GIVE_VERSION);
257
+	wp_enqueue_style('jquery-chosen');
258
+	wp_enqueue_style('thickbox');
259
+	wp_enqueue_style('wp-color-picker');
260 260
 
261 261
 
262 262
 	// JS.
263
-	wp_register_script( 'give-selector-cache', $js_plugins . 'selector-cache' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
264
-	wp_enqueue_script( 'give-selector-cache' );
263
+	wp_register_script('give-selector-cache', $js_plugins.'selector-cache'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
264
+	wp_enqueue_script('give-selector-cache');
265 265
 
266
-	wp_register_script( 'jquery-chosen', $js_plugins . 'chosen.jquery' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION );
267
-	wp_enqueue_script( 'jquery-chosen' );
266
+	wp_register_script('jquery-chosen', $js_plugins.'chosen.jquery'.$suffix.'.js', array('jquery'), GIVE_VERSION);
267
+	wp_enqueue_script('jquery-chosen');
268 268
 
269
-	wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
270
-	wp_enqueue_script( 'give-accounting' );
269
+	wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
270
+	wp_enqueue_script('give-accounting');
271 271
 
272
-	wp_enqueue_script( 'wp-color-picker' );
273
-	wp_enqueue_script( 'jquery-ui-datepicker' );
274
-	wp_enqueue_script( 'thickbox' );
272
+	wp_enqueue_script('wp-color-picker');
273
+	wp_enqueue_script('jquery-ui-datepicker');
274
+	wp_enqueue_script('thickbox');
275 275
 
276
-	wp_register_script( 'give-admin-scripts', $js_dir . 'admin-scripts' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker', 'wp-color-picker', 'jquery-query' ), GIVE_VERSION, false );
277
-	wp_enqueue_script( 'give-admin-scripts' );
276
+	wp_register_script('give-admin-scripts', $js_dir.'admin-scripts'.$suffix.'.js', array('jquery', 'jquery-ui-datepicker', 'wp-color-picker', 'jquery-query'), GIVE_VERSION, false);
277
+	wp_enqueue_script('give-admin-scripts');
278 278
 
279
-	wp_register_script( 'jquery-flot', $js_plugins . 'jquery.flot' . $suffix . '.js' );
280
-	wp_enqueue_script( 'jquery-flot' );
279
+	wp_register_script('jquery-flot', $js_plugins.'jquery.flot'.$suffix.'.js');
280
+	wp_enqueue_script('jquery-flot');
281 281
 
282
-	wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
283
-	wp_enqueue_script( 'give-qtip' );
282
+	wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
283
+	wp_enqueue_script('give-qtip');
284 284
 
285
-	wp_register_script( 'give-repeatable-fields', $js_plugins . 'repeatable-fields' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
286
-	wp_enqueue_script( 'give-repeatable-fields' );
285
+	wp_register_script('give-repeatable-fields', $js_plugins.'repeatable-fields'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
286
+	wp_enqueue_script('give-repeatable-fields');
287 287
 
288 288
 	// Forms CPT Script.
289
-	if ( $post_type === 'give_forms' ) {
290
-		wp_register_script( 'give-admin-forms-scripts', $js_dir . 'admin-forms' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
291
-		wp_enqueue_script( 'give-admin-forms-scripts' );
289
+	if ($post_type === 'give_forms') {
290
+		wp_register_script('give-admin-forms-scripts', $js_dir.'admin-forms'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
291
+		wp_enqueue_script('give-admin-forms-scripts');
292 292
 	}
293 293
 
294 294
 	// Settings Scripts.
295
-	if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-settings' ) {
296
-		wp_register_script( 'give-admin-settings-scripts', $js_dir . 'admin-settings' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
297
-		wp_enqueue_script( 'give-admin-settings-scripts' );
295
+	if (isset($_GET['page']) && $_GET['page'] == 'give-settings') {
296
+		wp_register_script('give-admin-settings-scripts', $js_dir.'admin-settings'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
297
+		wp_enqueue_script('give-admin-settings-scripts');
298 298
 	}
299 299
 
300 300
 	// Price Separators.
@@ -302,79 +302,79 @@  discard block
 block discarded – undo
302 302
 	$decimal_separator  = give_get_price_decimal_separator();
303 303
 
304 304
 	// Localize strings & variables for JS.
305
-	wp_localize_script( 'give-admin-scripts', 'give_vars', array(
306
-		'post_id'                        => isset( $post->ID ) ? $post->ID : null,
305
+	wp_localize_script('give-admin-scripts', 'give_vars', array(
306
+		'post_id'                        => isset($post->ID) ? $post->ID : null,
307 307
 		'give_version'                   => GIVE_VERSION,
308 308
 		'thousands_separator'            => $thousand_separator,
309 309
 		'decimal_separator'              => $decimal_separator,
310
-		'quick_edit_warning'             => __( 'Not available for variable priced forms.', 'give' ),
311
-		'delete_payment'                 => __( 'Are you sure you want to delete this payment?', 'give' ),
312
-		'delete_payment_note'            => __( 'Are you sure you want to delete this note?', 'give' ),
313
-		'revoke_api_key'                 => __( 'Are you sure you want to revoke this API key?', 'give' ),
314
-		'regenerate_api_key'             => __( 'Are you sure you want to regenerate this API key?', 'give' ),
315
-		'resend_receipt'                 => __( 'Are you sure you want to resend the donation receipt?', 'give' ),
316
-		'disconnect_user'                => __( 'Are you sure you want to disconnect the user from this donor?', 'give' ),
317
-		'one_option'                     => __( 'Choose a form', 'give' ),
318
-		'one_or_more_option'             => __( 'Choose one or more forms', 'give' ),
319
-		'currency_sign'                  => give_currency_filter( '' ),
320
-		'currency_pos'                   => isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before',
321
-		'currency_decimals'              => give_currency_decimal_filter( give_get_price_decimals() ),
322
-		'batch_export_no_class'          => __( 'You must choose a method.', 'give' ),
323
-		'batch_export_no_reqs'           => __( 'Required fields not completed.', 'give' ),
324
-		'reset_stats_warn'               => __( 'Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give' ),
325
-		'delete_test_donor'               => __( 'Are you sure you want to delete all the test donors? This process will also delete test donations as well.', 'give' ),
326
-		'delete_import_donor'               => __( 'Are you sure you want to delete all the imported donors? This process will also delete imported donations as well.', 'give' ),
327
-		'price_format_guide'             => sprintf( __( 'Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give' ), $decimal_separator, $thousand_separator ),
310
+		'quick_edit_warning'             => __('Not available for variable priced forms.', 'give'),
311
+		'delete_payment'                 => __('Are you sure you want to delete this payment?', 'give'),
312
+		'delete_payment_note'            => __('Are you sure you want to delete this note?', 'give'),
313
+		'revoke_api_key'                 => __('Are you sure you want to revoke this API key?', 'give'),
314
+		'regenerate_api_key'             => __('Are you sure you want to regenerate this API key?', 'give'),
315
+		'resend_receipt'                 => __('Are you sure you want to resend the donation receipt?', 'give'),
316
+		'disconnect_user'                => __('Are you sure you want to disconnect the user from this donor?', 'give'),
317
+		'one_option'                     => __('Choose a form', 'give'),
318
+		'one_or_more_option'             => __('Choose one or more forms', 'give'),
319
+		'currency_sign'                  => give_currency_filter(''),
320
+		'currency_pos'                   => isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before',
321
+		'currency_decimals'              => give_currency_decimal_filter(give_get_price_decimals()),
322
+		'batch_export_no_class'          => __('You must choose a method.', 'give'),
323
+		'batch_export_no_reqs'           => __('Required fields not completed.', 'give'),
324
+		'reset_stats_warn'               => __('Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give'),
325
+		'delete_test_donor'               => __('Are you sure you want to delete all the test donors? This process will also delete test donations as well.', 'give'),
326
+		'delete_import_donor'               => __('Are you sure you want to delete all the imported donors? This process will also delete imported donations as well.', 'give'),
327
+		'price_format_guide'             => sprintf(__('Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give'), $decimal_separator, $thousand_separator),
328 328
 		/* translators : %s: Donation form options metabox */
329
-		'confirm_before_remove_row_text' => __( 'Do you want to delete this level?', 'give' ),
330
-		'matched_success_failure_page'   => __( 'You cannot set the success and failed pages to the same page', 'give' ),
331
-		'dismiss_notice_text'            => __( 'Dismiss this notice.', 'give' ),
332
-		'search_placeholder'             => __( 'Type to search all forms', 'give' ),
333
-		'search_placeholder_donor'       => __( 'Type to search all donors', 'give' ),
334
-		'search_placeholder_country'     => __( 'Type to search all countries', 'give' ),
335
-		'search_placeholder_state'       => __( 'Type to search all states/provinces', 'give' ),
329
+		'confirm_before_remove_row_text' => __('Do you want to delete this level?', 'give'),
330
+		'matched_success_failure_page'   => __('You cannot set the success and failed pages to the same page', 'give'),
331
+		'dismiss_notice_text'            => __('Dismiss this notice.', 'give'),
332
+		'search_placeholder'             => __('Type to search all forms', 'give'),
333
+		'search_placeholder_donor'       => __('Type to search all donors', 'give'),
334
+		'search_placeholder_country'     => __('Type to search all countries', 'give'),
335
+		'search_placeholder_state'       => __('Type to search all states/provinces', 'give'),
336 336
 		'bulk_action' => array(
337 337
 			'delete'    => array(
338
-				'zero'     => __( 'You must choose at least one or more payments to delete.', 'give' ),
339
-				'single'   => __( 'Are you sure you want to permanently delete this donation?', 'give' ),
340
-				'multiple' => __( 'Are you sure you want to permanently delete the selected {payment_count} donations?', 'give' ),
338
+				'zero'     => __('You must choose at least one or more payments to delete.', 'give'),
339
+				'single'   => __('Are you sure you want to permanently delete this donation?', 'give'),
340
+				'multiple' => __('Are you sure you want to permanently delete the selected {payment_count} donations?', 'give'),
341 341
 			),
342 342
 			'resend-receipt' => array(
343
-				'zero'     => __( 'You must choose at least one or more recipients to resend the email receipt.', 'give' ),
344
-				'single'   => __( 'Are you sure you want to resend the email receipt to this recipient?', 'give' ),
345
-				'multiple' => __( 'Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give' ),
343
+				'zero'     => __('You must choose at least one or more recipients to resend the email receipt.', 'give'),
344
+				'single'   => __('Are you sure you want to resend the email receipt to this recipient?', 'give'),
345
+				'multiple' => __('Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give'),
346 346
 			),
347 347
 			'set-to-status' => array(
348
-				'zero'      => __( 'You must choose at least one or more donations to set status to {status}.', 'give' ),
349
-				'single'    => __( 'Are you sure you want to set status of this donation to {status}?', 'give' ),
350
-				'multiple'  => __( 'Are you sure you want to set status of {payment_count} donations to {status}?', 'give' ),
348
+				'zero'      => __('You must choose at least one or more donations to set status to {status}.', 'give'),
349
+				'single'    => __('Are you sure you want to set status of this donation to {status}?', 'give'),
350
+				'multiple'  => __('Are you sure you want to set status of {payment_count} donations to {status}?', 'give'),
351 351
 			),
352 352
 		),
353 353
 		'metabox_fields' => array(
354 354
 			'media' => array(
355
-				'button_title' => __( 'Choose Image', 'give' ),
355
+				'button_title' => __('Choose Image', 'give'),
356 356
 			),
357 357
 			'file' => array(
358
-				'button_title' => __( 'Choose File', 'give' ),
358
+				'button_title' => __('Choose File', 'give'),
359 359
 			)
360 360
 		),
361 361
 		'chosen' => array(
362
-			'no_results_msg'  => __( 'No results match {search_term}', 'give' ),
363
-			'ajax_search_msg' => __( 'Searching results for match {search_term}', 'give' ),
362
+			'no_results_msg'  => __('No results match {search_term}', 'give'),
363
+			'ajax_search_msg' => __('Searching results for match {search_term}', 'give'),
364 364
 		),
365
-		'db_update_confirmation_msg' => __( 'The following process will make updates to your site\'s database. Please create a database backup before proceeding with updates.', 'give' ),
366
-        'error_message' => __( 'Something went wrong kindly try again!','give' ),
365
+		'db_update_confirmation_msg' => __('The following process will make updates to your site\'s database. Please create a database backup before proceeding with updates.', 'give'),
366
+        'error_message' => __('Something went wrong kindly try again!', 'give'),
367 367
         'give_donation_import' => 'give_donation_import',
368
-	) );
368
+	));
369 369
 
370
-	if ( function_exists( 'wp_enqueue_media' ) && version_compare( get_bloginfo( 'version' ), '3.5', '>=' ) ) {
370
+	if (function_exists('wp_enqueue_media') && version_compare(get_bloginfo('version'), '3.5', '>=')) {
371 371
 		// call for new media manager.
372 372
 		wp_enqueue_media();
373 373
 	}
374 374
 
375 375
 }
376 376
 
377
-add_action( 'admin_enqueue_scripts', 'give_load_admin_scripts', 100 );
377
+add_action('admin_enqueue_scripts', 'give_load_admin_scripts', 100);
378 378
 
379 379
 /**
380 380
  * Admin Give Icon
@@ -389,13 +389,13 @@  discard block
 block discarded – undo
389 389
 	?>
390 390
 	<style type="text/css" media="screen">
391 391
 
392
-		<?php if ( version_compare( get_bloginfo( 'version' ), '3.8-RC', '>=' ) || version_compare( get_bloginfo( 'version' ), '3.8', '>=' ) ) { ?>
392
+		<?php if (version_compare(get_bloginfo('version'), '3.8-RC', '>=') || version_compare(get_bloginfo('version'), '3.8', '>=')) { ?>
393 393
 		@font-face {
394 394
 			font-family: 'give-icomoon';
395
-			src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?ngjl88'; ?>');
396
-			src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?#iefixngjl88'?>') format('embedded-opentype'),
397
-			url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.woff?ngjl88'; ?>') format('woff'),
398
-			url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.svg?ngjl88#icomoon'; ?>') format('svg');
395
+			src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?ngjl88'; ?>');
396
+			src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?#iefixngjl88'?>') format('embedded-opentype'),
397
+			url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.woff?ngjl88'; ?>') format('woff'),
398
+			url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.svg?ngjl88#icomoon'; ?>') format('svg');
399 399
 			font-weight: normal;
400 400
 			font-style: normal;
401 401
 		}
@@ -414,4 +414,4 @@  discard block
 block discarded – undo
414 414
 	<?php
415 415
 }
416 416
 
417
-add_action( 'admin_head', 'give_admin_icon' );
417
+add_action('admin_head', 'give_admin_icon');
Please login to merge, or discard this patch.
includes/class-give-db.php 2 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -165,16 +165,16 @@  discard block
 block discarded – undo
165 165
 	 *
166 166
 	 * @since  1.0
167 167
 	 * @access public
168
-     *
169
-     * @param  int    $column       Column ID.
170
-     * @param  string $column_where Column name.
171
-     * @param  string $column_value Column value.
172
-     *
168
+	 *
169
+	 * @param  int    $column       Column ID.
170
+	 * @param  string $column_where Column name.
171
+	 * @param  string $column_value Column value.
172
+	 *
173 173
 	 * @return string
174 174
 	 */
175 175
 	public function get_column_by( $column, $column_where, $column_value ) {
176
-        /* @var WPDB $wpdb */
177
-        global $wpdb;
176
+		/* @var WPDB $wpdb */
177
+		global $wpdb;
178 178
 
179 179
 		// Bailout.
180 180
 		if ( empty( $column ) || empty( $column_where ) || empty( $column_value ) ) {
@@ -191,15 +191,15 @@  discard block
 block discarded – undo
191 191
 	 *
192 192
 	 * @since  1.0
193 193
 	 * @access public
194
-     *
195
-     * @param  array  $data
196
-     * @param  string $type
197
-     *
194
+	 *
195
+	 * @param  array  $data
196
+	 * @param  string $type
197
+	 *
198 198
 	 * @return int
199 199
 	 */
200 200
 	public function insert( $data, $type = '' ) {
201
-        /* @var WPDB $wpdb */
202
-        global $wpdb;
201
+		/* @var WPDB $wpdb */
202
+		global $wpdb;
203 203
 
204 204
 		// Set default values.
205 205
 		$data = wp_parse_args( $data, $this->get_column_defaults() );
@@ -246,16 +246,16 @@  discard block
 block discarded – undo
246 246
 	 *
247 247
 	 * @since  1.0
248 248
 	 * @access public
249
-     *
250
-     * @param  int    $row_id Column ID
251
-     * @param  array  $data
252
-     * @param  string $where  Column value
253
-     *
249
+	 *
250
+	 * @param  int    $row_id Column ID
251
+	 * @param  array  $data
252
+	 * @param  string $where  Column value
253
+	 *
254 254
 	 * @return bool
255 255
 	 */
256 256
 	public function update( $row_id, $data = array(), $where = '' ) {
257
-        /* @var WPDB $wpdb */
258
-        global $wpdb;
257
+		/* @var WPDB $wpdb */
258
+		global $wpdb;
259 259
 
260 260
 		// Row ID must be positive integer
261 261
 		$row_id = absint( $row_id );
@@ -293,14 +293,14 @@  discard block
 block discarded – undo
293 293
 	 *
294 294
 	 * @since  1.0
295 295
 	 * @access public
296
-     *
297
-     * @param  int $row_id Column ID.
298
-     *
296
+	 *
297
+	 * @param  int $row_id Column ID.
298
+	 *
299 299
 	 * @return bool
300 300
 	 */
301 301
 	public function delete( $row_id = 0 ) {
302
-        /* @var WPDB $wpdb */
303
-        global $wpdb;
302
+		/* @var WPDB $wpdb */
303
+		global $wpdb;
304 304
 
305 305
 		// Row ID must be positive integer
306 306
 		$row_id = absint( $row_id );
@@ -321,13 +321,13 @@  discard block
 block discarded – undo
321 321
 	 *
322 322
 	 * @since  1.3.2
323 323
 	 * @access public
324
-     *
324
+	 *
325 325
 	 * @param  string $table The table name.
326
-     *
326
+	 *
327 327
 	 * @return bool          If the table name exists.
328 328
 	 */
329 329
 	public function table_exists( $table ) {
330
-        /* @var WPDB $wpdb */
330
+		/* @var WPDB $wpdb */
331 331
 		global $wpdb;
332 332
 
333 333
 		$table = sanitize_text_field( $table );
Please login to merge, or discard this patch.
Spacing   +46 added lines, -46 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
 
@@ -98,16 +98,16 @@  discard block
 block discarded – undo
98 98
 	 *
99 99
 	 * @return object
100 100
 	 */
101
-	public function get( $row_id ) {
101
+	public function get($row_id) {
102 102
 		/* @var WPDB $wpdb */
103 103
 		global $wpdb;
104 104
 
105 105
 		// Bailout.
106
-		if ( empty( $row_id ) ) {
106
+		if (empty($row_id)) {
107 107
 			return null;
108 108
 		}
109 109
 
110
-		return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) );
110
+		return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id));
111 111
 	}
112 112
 
113 113
 	/**
@@ -121,18 +121,18 @@  discard block
 block discarded – undo
121 121
 	 *
122 122
 	 * @return object
123 123
 	 */
124
-	public function get_by( $column, $row_id ) {
124
+	public function get_by($column, $row_id) {
125 125
 		/* @var WPDB $wpdb */
126 126
 		global $wpdb;
127 127
 
128 128
 		// Bailout.
129
-		if ( empty( $column ) || empty( $row_id ) ) {
129
+		if (empty($column) || empty($row_id)) {
130 130
 			return null;
131 131
 		}
132 132
 
133
-		$column = esc_sql( $column );
133
+		$column = esc_sql($column);
134 134
 
135
-		return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) );
135
+		return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id));
136 136
 	}
137 137
 
138 138
 	/**
@@ -146,18 +146,18 @@  discard block
 block discarded – undo
146 146
 	 *
147 147
 	 * @return string      Column value.
148 148
 	 */
149
-	public function get_column( $column, $row_id ) {
149
+	public function get_column($column, $row_id) {
150 150
 		/* @var WPDB $wpdb */
151 151
 		global $wpdb;
152 152
 
153 153
 		// Bailout.
154
-		if ( empty( $column ) || empty( $row_id ) ) {
154
+		if (empty($column) || empty($row_id)) {
155 155
 			return null;
156 156
 		}
157 157
 
158
-		$column = esc_sql( $column );
158
+		$column = esc_sql($column);
159 159
 
160
-		return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) );
160
+		return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id));
161 161
 	}
162 162
 
163 163
 	/**
@@ -172,18 +172,18 @@  discard block
 block discarded – undo
172 172
      *
173 173
 	 * @return string
174 174
 	 */
175
-	public function get_column_by( $column, $column_where, $column_value ) {
175
+	public function get_column_by($column, $column_where, $column_value) {
176 176
         /* @var WPDB $wpdb */
177 177
         global $wpdb;
178 178
 
179 179
 		// Bailout.
180
-		if ( empty( $column ) || empty( $column_where ) || empty( $column_value ) ) {
180
+		if (empty($column) || empty($column_where) || empty($column_value)) {
181 181
 			return null;
182 182
 		}
183 183
 
184
-		$column_where = esc_sql( $column_where );
185
-		$column       = esc_sql( $column );
186
-		return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) );
184
+		$column_where = esc_sql($column_where);
185
+		$column       = esc_sql($column);
186
+		return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value));
187 187
 	}
188 188
 
189 189
 	/**
@@ -197,12 +197,12 @@  discard block
 block discarded – undo
197 197
      *
198 198
 	 * @return int
199 199
 	 */
200
-	public function insert( $data, $type = '' ) {
200
+	public function insert($data, $type = '') {
201 201
         /* @var WPDB $wpdb */
202 202
         global $wpdb;
203 203
 
204 204
 		// Set default values.
205
-		$data = wp_parse_args( $data, $this->get_column_defaults() );
205
+		$data = wp_parse_args($data, $this->get_column_defaults());
206 206
 
207 207
 		/**
208 208
 		 * Fires before inserting data to the database.
@@ -211,22 +211,22 @@  discard block
 block discarded – undo
211 211
 		 *
212 212
 		 * @param array $data
213 213
 		 */
214
-		do_action( "give_pre_insert_{$type}", $data );
214
+		do_action("give_pre_insert_{$type}", $data);
215 215
 
216 216
 		// Initialise column format array
217 217
 		$column_formats = $this->get_columns();
218 218
 
219 219
 		// Force fields to lower case
220
-		$data = array_change_key_case( $data );
220
+		$data = array_change_key_case($data);
221 221
 
222 222
 		// White list columns
223
-		$data = array_intersect_key( $data, $column_formats );
223
+		$data = array_intersect_key($data, $column_formats);
224 224
 
225 225
 		// Reorder $column_formats to match the order of columns given in $data
226
-		$data_keys      = array_keys( $data );
227
-		$column_formats = array_merge( array_flip( $data_keys ), $column_formats );
226
+		$data_keys      = array_keys($data);
227
+		$column_formats = array_merge(array_flip($data_keys), $column_formats);
228 228
 
229
-		$wpdb->insert( $this->table_name, $data, $column_formats );
229
+		$wpdb->insert($this->table_name, $data, $column_formats);
230 230
 
231 231
 		/**
232 232
 		 * Fires after inserting data to the database.
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 		 * @param int   $insert_id
237 237
 		 * @param array $data
238 238
 		 */
239
-		do_action( "give_post_insert_{$type}", $wpdb->insert_id, $data );
239
+		do_action("give_post_insert_{$type}", $wpdb->insert_id, $data);
240 240
 
241 241
 		return $wpdb->insert_id;
242 242
 	}
@@ -253,18 +253,18 @@  discard block
 block discarded – undo
253 253
      *
254 254
 	 * @return bool
255 255
 	 */
256
-	public function update( $row_id, $data = array(), $where = '' ) {
256
+	public function update($row_id, $data = array(), $where = '') {
257 257
         /* @var WPDB $wpdb */
258 258
         global $wpdb;
259 259
 
260 260
 		// Row ID must be positive integer
261
-		$row_id = absint( $row_id );
261
+		$row_id = absint($row_id);
262 262
 
263
-		if ( empty( $row_id ) ) {
263
+		if (empty($row_id)) {
264 264
 			return false;
265 265
 		}
266 266
 
267
-		if ( empty( $where ) ) {
267
+		if (empty($where)) {
268 268
 			$where = $this->primary_key;
269 269
 		}
270 270
 
@@ -272,16 +272,16 @@  discard block
 block discarded – undo
272 272
 		$column_formats = $this->get_columns();
273 273
 
274 274
 		// Force fields to lower case
275
-		$data = array_change_key_case( $data );
275
+		$data = array_change_key_case($data);
276 276
 
277 277
 		// White list columns
278
-		$data = array_intersect_key( $data, $column_formats );
278
+		$data = array_intersect_key($data, $column_formats);
279 279
 
280 280
 		// Reorder $column_formats to match the order of columns given in $data
281
-		$data_keys      = array_keys( $data );
282
-		$column_formats = array_merge( array_flip( $data_keys ), $column_formats );
281
+		$data_keys      = array_keys($data);
282
+		$column_formats = array_merge(array_flip($data_keys), $column_formats);
283 283
 
284
-		if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) {
284
+		if (false === $wpdb->update($this->table_name, $data, array($where => $row_id), $column_formats)) {
285 285
 			return false;
286 286
 		}
287 287
 
@@ -298,18 +298,18 @@  discard block
 block discarded – undo
298 298
      *
299 299
 	 * @return bool
300 300
 	 */
301
-	public function delete( $row_id = 0 ) {
301
+	public function delete($row_id = 0) {
302 302
         /* @var WPDB $wpdb */
303 303
         global $wpdb;
304 304
 
305 305
 		// Row ID must be positive integer
306
-		$row_id = absint( $row_id );
306
+		$row_id = absint($row_id);
307 307
 
308
-		if ( empty( $row_id ) ) {
308
+		if (empty($row_id)) {
309 309
 			return false;
310 310
 		}
311 311
 
312
-		if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) {
312
+		if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id))) {
313 313
 			return false;
314 314
 		}
315 315
 
@@ -326,13 +326,13 @@  discard block
 block discarded – undo
326 326
      *
327 327
 	 * @return bool          If the table name exists.
328 328
 	 */
329
-	public function table_exists( $table ) {
329
+	public function table_exists($table) {
330 330
         /* @var WPDB $wpdb */
331 331
 		global $wpdb;
332 332
 
333
-		$table = sanitize_text_field( $table );
333
+		$table = sanitize_text_field($table);
334 334
 
335
-		return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table;
335
+		return $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE '%s'", $table)) === $table;
336 336
 	}
337 337
 
338 338
 	/**
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 	 * @return bool Returns if the customers table was installed and upgrade routine run.
345 345
 	 */
346 346
 	public function installed() {
347
-		return $this->table_exists( $this->table_name );
347
+		return $this->table_exists($this->table_name);
348 348
 	}
349 349
 
350 350
 	/**
@@ -354,8 +354,8 @@  discard block
 block discarded – undo
354 354
 	 * @access public
355 355
 	 */
356 356
 	public function register_table() {
357
-		$current_version = get_option( $this->table_name . '_db_version' );
358
-		if ( ! $current_version || version_compare( $current_version, $this->version, '<' ) ) {
357
+		$current_version = get_option($this->table_name.'_db_version');
358
+		if ( ! $current_version || version_compare($current_version, $this->version, '<')) {
359 359
 			$this->create_table();
360 360
 		}
361 361
 	}
@@ -366,5 +366,5 @@  discard block
 block discarded – undo
366 366
 	 * @since  1.8.9
367 367
 	 * @access public
368 368
 	 */
369
-	public function create_table(){}
369
+	public function create_table() {}
370 370
 }
Please login to merge, or discard this patch.
includes/class-give-session.php 1 patch
Spacing   +76 added lines, -76 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
 
@@ -74,57 +74,57 @@  discard block
 block discarded – undo
74 74
 	public function __construct() {
75 75
 
76 76
 		$this->use_php_sessions = $this->use_php_sessions();
77
-		$this->exp_option       = give_get_option( 'session_lifetime' );
77
+		$this->exp_option       = give_get_option('session_lifetime');
78 78
 
79 79
 		// PHP Sessions.
80
-		if ( $this->use_php_sessions ) {
80
+		if ($this->use_php_sessions) {
81 81
 
82
-			if ( is_multisite() ) {
82
+			if (is_multisite()) {
83 83
 
84
-				$this->prefix = '_' . get_current_blog_id();
84
+				$this->prefix = '_'.get_current_blog_id();
85 85
 
86 86
 			}
87 87
 
88
-			add_action( 'init', array( $this, 'maybe_start_session' ), - 2 );
88
+			add_action('init', array($this, 'maybe_start_session'), - 2);
89 89
 
90 90
 		} else {
91 91
 
92
-			if ( ! $this->should_start_session() ) {
92
+			if ( ! $this->should_start_session()) {
93 93
 				return;
94 94
 			}
95 95
 
96 96
 			// Use WP_Session.
97
-			if ( ! defined( 'WP_SESSION_COOKIE' ) ) {
98
-				define( 'WP_SESSION_COOKIE', 'give_wp_session' );
97
+			if ( ! defined('WP_SESSION_COOKIE')) {
98
+				define('WP_SESSION_COOKIE', 'give_wp_session');
99 99
 			}
100 100
 
101
-			if ( ! class_exists( 'Recursive_ArrayAccess' ) ) {
102
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-recursive-arrayaccess.php';
101
+			if ( ! class_exists('Recursive_ArrayAccess')) {
102
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-recursive-arrayaccess.php';
103 103
 			}
104 104
 
105 105
 			// Include utilities class
106
-			if ( ! class_exists( 'WP_Session_Utils' ) ) {
107
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-wp-session-utils.php';
106
+			if ( ! class_exists('WP_Session_Utils')) {
107
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-wp-session-utils.php';
108 108
 			}
109
-			if ( ! class_exists( 'WP_Session' ) ) {
110
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-wp-session.php';
111
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/wp-session.php';
109
+			if ( ! class_exists('WP_Session')) {
110
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-wp-session.php';
111
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/wp-session.php';
112 112
 			}
113 113
 
114
-			add_filter( 'wp_session_expiration_variant', array( $this, 'set_expiration_variant_time' ), 99999 );
115
-			add_filter( 'wp_session_expiration', array( $this, 'set_expiration_time' ), 99999 );
114
+			add_filter('wp_session_expiration_variant', array($this, 'set_expiration_variant_time'), 99999);
115
+			add_filter('wp_session_expiration', array($this, 'set_expiration_time'), 99999);
116 116
 
117 117
 		}
118 118
 
119 119
 		// Init Session.
120
-		if ( empty( $this->session ) && ! $this->use_php_sessions ) {
121
-			add_action( 'plugins_loaded', array( $this, 'init' ), 9999 );
120
+		if (empty($this->session) && ! $this->use_php_sessions) {
121
+			add_action('plugins_loaded', array($this, 'init'), 9999);
122 122
 		} else {
123
-			add_action( 'init', array( $this, 'init' ), - 1 );
123
+			add_action('init', array($this, 'init'), - 1);
124 124
 		}
125 125
 
126 126
 		// Set cookie on Donation Completion page.
127
-		add_action( 'give_pre_process_donation', array( $this, 'set_session_cookies' ) );
127
+		add_action('give_pre_process_donation', array($this, 'set_session_cookies'));
128 128
 
129 129
 	}
130 130
 
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
 	 */
141 141
 	public function init() {
142 142
 
143
-		if ( $this->use_php_sessions ) {
144
-			$this->session = isset( $_SESSION[ 'give' . $this->prefix ] ) && is_array( $_SESSION[ 'give' . $this->prefix ] ) ? $_SESSION[ 'give' . $this->prefix ] : array();
143
+		if ($this->use_php_sessions) {
144
+			$this->session = isset($_SESSION['give'.$this->prefix]) && is_array($_SESSION['give'.$this->prefix]) ? $_SESSION['give'.$this->prefix] : array();
145 145
 		} else {
146 146
 			$this->session = WP_Session::get_instance();
147 147
 		}
@@ -176,37 +176,37 @@  discard block
 block discarded – undo
176 176
 	 *
177 177
 	 * @return string|array      Session variable.
178 178
 	 */
179
-	public function get( $key ) {
180
-		$key    = sanitize_key( $key );
179
+	public function get($key) {
180
+		$key    = sanitize_key($key);
181 181
 		$return = false;
182 182
 
183
-		if ( isset( $this->session[ $key ] ) && ! empty( $this->session[ $key ] ) ) {
183
+		if (isset($this->session[$key]) && ! empty($this->session[$key])) {
184 184
 
185
-			preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $this->session[ $key ], $matches );
186
-			if ( ! empty( $matches ) ) {
187
-				$this->set( $key, null );
185
+			preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $this->session[$key], $matches);
186
+			if ( ! empty($matches)) {
187
+				$this->set($key, null);
188 188
 
189 189
 				return false;
190 190
 			}
191 191
 
192
-			if ( is_numeric( $this->session[ $key ] ) ) {
193
-				$return = $this->session[ $key ];
192
+			if (is_numeric($this->session[$key])) {
193
+				$return = $this->session[$key];
194 194
 			} else {
195 195
 
196
-				$maybe_json = json_decode( $this->session[ $key ] );
196
+				$maybe_json = json_decode($this->session[$key]);
197 197
 
198 198
 				// Since json_last_error is PHP 5.3+, we have to rely on a `null` value for failing to parse JSON.
199
-				if ( is_null( $maybe_json ) ) {
200
-					$is_serialized = is_serialized( $this->session[ $key ] );
201
-					if ( $is_serialized ) {
202
-						$value = @unserialize( $this->session[ $key ] );
203
-						$this->set( $key, (array) $value );
199
+				if (is_null($maybe_json)) {
200
+					$is_serialized = is_serialized($this->session[$key]);
201
+					if ($is_serialized) {
202
+						$value = @unserialize($this->session[$key]);
203
+						$this->set($key, (array) $value);
204 204
 						$return = $value;
205 205
 					} else {
206
-						$return = $this->session[ $key ];
206
+						$return = $this->session[$key];
207 207
 					}
208 208
 				} else {
209
-					$return = json_decode( $this->session[ $key ], true );
209
+					$return = json_decode($this->session[$key], true);
210 210
 				}
211 211
 
212 212
 			}
@@ -229,21 +229,21 @@  discard block
 block discarded – undo
229 229
 	 *
230 230
 	 * @return string        Session variable.
231 231
 	 */
232
-	public function set( $key, $value ) {
232
+	public function set($key, $value) {
233 233
 
234
-		$key = sanitize_key( $key );
234
+		$key = sanitize_key($key);
235 235
 
236
-		if ( is_array( $value ) ) {
237
-			$this->session[ $key ] = wp_json_encode( $value );
236
+		if (is_array($value)) {
237
+			$this->session[$key] = wp_json_encode($value);
238 238
 		} else {
239
-			$this->session[ $key ] = esc_attr( $value );
239
+			$this->session[$key] = esc_attr($value);
240 240
 		}
241 241
 
242
-		if ( $this->use_php_sessions ) {
243
-			$_SESSION[ 'give' . $this->prefix ] = $this->session;
242
+		if ($this->use_php_sessions) {
243
+			$_SESSION['give'.$this->prefix] = $this->session;
244 244
 		}
245 245
 
246
-		return $this->session[ $key ];
246
+		return $this->session[$key];
247 247
 	}
248 248
 
249 249
 	/**
@@ -258,10 +258,10 @@  discard block
 block discarded – undo
258 258
 	 * @hook
259 259
 	 */
260 260
 	public function set_session_cookies() {
261
-		if ( ! headers_sent() ) {
262
-			$lifetime = current_time( 'timestamp' ) + $this->set_expiration_time();
263
-			@setcookie( session_name(), session_id(), $lifetime, COOKIEPATH, COOKIE_DOMAIN, false );
264
-			@setcookie( session_name() . '_expiration', $lifetime, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false );
261
+		if ( ! headers_sent()) {
262
+			$lifetime = current_time('timestamp') + $this->set_expiration_time();
263
+			@setcookie(session_name(), session_id(), $lifetime, COOKIEPATH, COOKIE_DOMAIN, false);
264
+			@setcookie(session_name().'_expiration', $lifetime, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false);
265 265
 		}
266 266
 	}
267 267
 
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 	 */
278 278
 	public function set_expiration_variant_time() {
279 279
 
280
-		return ( ! empty( $this->exp_option ) ? ( intval( $this->exp_option ) - 3600 ) : 30 * 60 * 23 );
280
+		return ( ! empty($this->exp_option) ? (intval($this->exp_option) - 3600) : 30 * 60 * 23);
281 281
 	}
282 282
 
283 283
 	/**
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 	 */
293 293
 	public function set_expiration_time() {
294 294
 
295
-		return ( ! empty( $this->exp_option ) ? intval( $this->exp_option ) : 30 * 60 * 24 );
295
+		return ( ! empty($this->exp_option) ? intval($this->exp_option) : 30 * 60 * 24);
296 296
 	}
297 297
 
298 298
 	/**
@@ -310,21 +310,21 @@  discard block
 block discarded – undo
310 310
 		$ret = false;
311 311
 
312 312
 		// If the database variable is already set, no need to run auto detection.
313
-		$give_use_php_sessions = (bool) get_option( 'give_use_php_sessions' );
313
+		$give_use_php_sessions = (bool) get_option('give_use_php_sessions');
314 314
 
315
-		if ( ! $give_use_php_sessions ) {
315
+		if ( ! $give_use_php_sessions) {
316 316
 
317 317
 			// Attempt to detect if the server supports PHP sessions.
318
-			if ( function_exists( 'session_start' ) && ! ini_get( 'safe_mode' ) ) {
318
+			if (function_exists('session_start') && ! ini_get('safe_mode')) {
319 319
 
320
-				$this->set( 'give_use_php_sessions', 1 );
320
+				$this->set('give_use_php_sessions', 1);
321 321
 
322
-				if ( $this->get( 'give_use_php_sessions' ) ) {
322
+				if ($this->get('give_use_php_sessions')) {
323 323
 
324 324
 					$ret = true;
325 325
 
326 326
 					// Set the database option.
327
-					update_option( 'give_use_php_sessions', true );
327
+					update_option('give_use_php_sessions', true);
328 328
 
329 329
 				}
330 330
 			}
@@ -334,13 +334,13 @@  discard block
 block discarded – undo
334 334
 		}
335 335
 
336 336
 		// Enable or disable PHP Sessions based on the GIVE_USE_PHP_SESSIONS constant.
337
-		if ( defined( 'GIVE_USE_PHP_SESSIONS' ) && GIVE_USE_PHP_SESSIONS ) {
337
+		if (defined('GIVE_USE_PHP_SESSIONS') && GIVE_USE_PHP_SESSIONS) {
338 338
 			$ret = true;
339
-		} elseif ( defined( 'GIVE_USE_PHP_SESSIONS' ) && ! GIVE_USE_PHP_SESSIONS ) {
339
+		} elseif (defined('GIVE_USE_PHP_SESSIONS') && ! GIVE_USE_PHP_SESSIONS) {
340 340
 			$ret = false;
341 341
 		}
342 342
 
343
-		return (bool) apply_filters( 'give_use_php_sessions', $ret );
343
+		return (bool) apply_filters('give_use_php_sessions', $ret);
344 344
 	}
345 345
 
346 346
 	/**
@@ -357,9 +357,9 @@  discard block
 block discarded – undo
357 357
 
358 358
 		$start_session = true;
359 359
 
360
-		if ( ! empty( $_SERVER['REQUEST_URI'] ) ) {
360
+		if ( ! empty($_SERVER['REQUEST_URI'])) {
361 361
 
362
-			$blacklist = apply_filters( 'give_session_start_uri_blacklist', array(
362
+			$blacklist = apply_filters('give_session_start_uri_blacklist', array(
363 363
 				'feed',
364 364
 				'feed',
365 365
 				'feed/rss',
@@ -367,21 +367,21 @@  discard block
 block discarded – undo
367 367
 				'feed/rdf',
368 368
 				'feed/atom',
369 369
 				'comments/feed/',
370
-			) );
371
-			$uri       = ltrim( $_SERVER['REQUEST_URI'], '/' );
372
-			$uri       = untrailingslashit( $uri );
373
-			if ( in_array( $uri, $blacklist ) ) {
370
+			));
371
+			$uri       = ltrim($_SERVER['REQUEST_URI'], '/');
372
+			$uri       = untrailingslashit($uri);
373
+			if (in_array($uri, $blacklist)) {
374 374
 				$start_session = false;
375 375
 			}
376
-			if ( false !== strpos( $uri, 'feed=' ) ) {
376
+			if (false !== strpos($uri, 'feed=')) {
377 377
 				$start_session = false;
378 378
 			}
379
-			if ( is_admin() ) {
379
+			if (is_admin()) {
380 380
 				$start_session = false;
381 381
 			}
382 382
 		}
383 383
 
384
-		return apply_filters( 'give_start_session', $start_session );
384
+		return apply_filters('give_start_session', $start_session);
385 385
 	}
386 386
 
387 387
 	/**
@@ -397,11 +397,11 @@  discard block
 block discarded – undo
397 397
 	 */
398 398
 	public function maybe_start_session() {
399 399
 
400
-		if ( ! $this->should_start_session() ) {
400
+		if ( ! $this->should_start_session()) {
401 401
 			return;
402 402
 		}
403 403
 
404
-		if ( ! session_id() && ! headers_sent() ) {
404
+		if ( ! session_id() && ! headers_sent()) {
405 405
 			session_start();
406 406
 		}
407 407
 
@@ -420,9 +420,9 @@  discard block
 block discarded – undo
420 420
 
421 421
 		$expiration = false;
422 422
 
423
-		if ( session_id() && isset( $_COOKIE[ session_name() . '_expiration' ] ) ) {
423
+		if (session_id() && isset($_COOKIE[session_name().'_expiration'])) {
424 424
 
425
-			$expiration = date( 'D, d M Y h:i:s', intval( $_COOKIE[ session_name() . '_expiration' ] ) );
425
+			$expiration = date('D, d M Y h:i:s', intval($_COOKIE[session_name().'_expiration']));
426 426
 
427 427
 		}
428 428
 
Please login to merge, or discard this patch.
includes/admin/upgrades/views/upgrades.php 1 patch
Spacing   +14 added lines, -14 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
 
@@ -18,30 +18,30 @@  discard block
 block discarded – undo
18 18
 ?>
19 19
 <div class="wrap" id="poststuff">
20 20
 	<div id="give-updates">
21
-		<h1 id="give-updates-h1"><?php esc_html_e( 'Give - Updates', 'give' ); ?></h1>
21
+		<h1 id="give-updates-h1"><?php esc_html_e('Give - Updates', 'give'); ?></h1>
22 22
 		<div class="give-update-panel-content">
23
-			<p><?php printf( __( 'Give regularly receives new features, bug fixes, and enhancements. It is important to always stay up-to-date with latest version of Give core and its add-ons.  Please create a backup of your site before updating. To update add-ons be sure your <a href="%1$s">license keys</a> are activated.', 'give' ), 'https://givewp.com/my-account/' ); ?></p>
23
+			<p><?php printf(__('Give regularly receives new features, bug fixes, and enhancements. It is important to always stay up-to-date with latest version of Give core and its add-ons.  Please create a backup of your site before updating. To update add-ons be sure your <a href="%1$s">license keys</a> are activated.', 'give'), 'https://givewp.com/my-account/'); ?></p>
24 24
 		</div>
25 25
 
26 26
 		<?php $update_counter = 1; ?>
27 27
 
28 28
 		<?php $db_updates = $give_updates->get_db_update_count(); ?>
29
-		<?php if ( ! empty( $db_updates ) ) : ?>
30
-			<?php $db_update_url = add_query_arg( array(
29
+		<?php if ( ! empty($db_updates)) : ?>
30
+			<?php $db_update_url = add_query_arg(array(
31 31
 				'type' => 'database',
32
-			) ); ?>
32
+			)); ?>
33 33
 			<div id="give-db-updates">
34 34
 				<div class="postbox-container">
35 35
 					<div class="postbox">
36
-						<h2 class="hndle"><?php _e( 'Database Updates', 'give' ); ?></h2>
36
+						<h2 class="hndle"><?php _e('Database Updates', 'give'); ?></h2>
37 37
 						<div class="inside">
38 38
 							<div class="panel-content">
39
-								<p><?php echo sprintf( __( 'Give needs to update the database. <a href="%s">Update now ></a>', 'give' ), $db_update_url ); ?></p>
39
+								<p><?php echo sprintf(__('Give needs to update the database. <a href="%s">Update now ></a>', 'give'), $db_update_url); ?></p>
40 40
 							</div>
41 41
 							<div class="progress-container give-hidden">
42 42
 								<p class="update-message" data-update-count="<?php echo $db_updates; ?>"
43 43
 								   data-resume-update="<?php echo $give_updates->resume_updates(); ?>">
44
-									<strong><?php echo sprintf( __( 'Update 1 of %s', 'give' ), $db_updates ); ?></strong></p>
44
+									<strong><?php echo sprintf(__('Update 1 of %s', 'give'), $db_updates); ?></strong></p>
45 45
 								<div class="progress-content"></div>
46 46
 							</div>
47 47
 						</div>
@@ -52,17 +52,17 @@  discard block
 block discarded – undo
52 52
 		<?php endif; ?>
53 53
 
54 54
 		<?php $plugin_updates = $give_updates->get_plugin_update_count(); ?>
55
-		<?php if ( ! empty( $plugin_updates ) ) : ?>
56
-			<?php $plugin_update_url = add_query_arg( array(
55
+		<?php if ( ! empty($plugin_updates)) : ?>
56
+			<?php $plugin_update_url = add_query_arg(array(
57 57
 				's' => 'Give',
58
-			), admin_url( '/plugins.php' ) ); ?>
58
+			), admin_url('/plugins.php')); ?>
59 59
 			<div id="give-plugin-updates">
60 60
 				<div class="postbox-container">
61 61
 					<div class="postbox">
62
-						<h2 class="hndle"><?php _e( 'Add-on Updates', 'give' ); ?></h2>
62
+						<h2 class="hndle"><?php _e('Add-on Updates', 'give'); ?></h2>
63 63
 						<div class="inside">
64 64
 							<div class="panel-content">
65
-								<p><?php echo sprintf( __( 'There %1$s %2$s Give %3$s that %4$s to be updated. <a href="%5$s">Update now ></a>', 'give' ), _n( 'is', 'are', $plugin_updates, 'give' ), $plugin_updates, _n( 'add-on', 'add-ons', $plugin_updates, 'give' ), _n( 'needs', 'need', $plugin_updates, 'give' ), $plugin_update_url  ); ?></p>
65
+								<p><?php echo sprintf(__('There %1$s %2$s Give %3$s that %4$s to be updated. <a href="%5$s">Update now ></a>', 'give'), _n('is', 'are', $plugin_updates, 'give'), $plugin_updates, _n('add-on', 'add-ons', $plugin_updates, 'give'), _n('needs', 'need', $plugin_updates, 'give'), $plugin_update_url); ?></p>
66 66
 								<?php include_once 'plugins-update-section.php'; ?>
67 67
 							</div>
68 68
 						</div>
Please login to merge, or discard this patch.