Test Failed
Pull Request — master (#2482)
by Devin
05:37
created
includes/class-give-donate-form.php 1 patch
Spacing   +115 added lines, -115 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
 
@@ -337,11 +337,11 @@  discard block
 block discarded – undo
337 337
 	 * @param  bool  $_id   Post id. Default is false.
338 338
 	 * @param  array $_args Arguments passed.
339 339
 	 */
340
-	public function __construct( $_id = false, $_args = array() ) {
340
+	public function __construct($_id = false, $_args = array()) {
341 341
 
342
-		$donation_form = WP_Post::get_instance( $_id );
342
+		$donation_form = WP_Post::get_instance($_id);
343 343
 
344
-		return $this->setup_donation_form( $donation_form );
344
+		return $this->setup_donation_form($donation_form);
345 345
 	}
346 346
 
347 347
 	/**
@@ -354,23 +354,23 @@  discard block
 block discarded – undo
354 354
 	 *
355 355
 	 * @return bool                   If the setup was successful or not.
356 356
 	 */
357
-	private function setup_donation_form( $donation_form ) {
357
+	private function setup_donation_form($donation_form) {
358 358
 
359
-		if ( ! is_object( $donation_form ) ) {
359
+		if ( ! is_object($donation_form)) {
360 360
 			return false;
361 361
 		}
362 362
 
363
-		if ( ! is_a( $donation_form, 'WP_Post' ) ) {
363
+		if ( ! is_a($donation_form, 'WP_Post')) {
364 364
 			return false;
365 365
 		}
366 366
 
367
-		if ( 'give_forms' !== $donation_form->post_type ) {
367
+		if ('give_forms' !== $donation_form->post_type) {
368 368
 			return false;
369 369
 		}
370 370
 
371
-		foreach ( $donation_form as $key => $value ) {
371
+		foreach ($donation_form as $key => $value) {
372 372
 
373
-			switch ( $key ) {
373
+			switch ($key) {
374 374
 
375 375
 				default:
376 376
 					$this->$key = $value;
@@ -394,16 +394,16 @@  discard block
 block discarded – undo
394 394
 	 *
395 395
 	 * @return mixed
396 396
 	 */
397
-	public function __get( $key ) {
397
+	public function __get($key) {
398 398
 
399
-		if ( method_exists( $this, 'get_' . $key ) ) {
399
+		if (method_exists($this, 'get_'.$key)) {
400 400
 
401
-			return call_user_func( array( $this, 'get_' . $key ) );
401
+			return call_user_func(array($this, 'get_'.$key));
402 402
 
403 403
 		} else {
404 404
 
405 405
 			/* translators: %s: property key */
406
-			return new WP_Error( 'give-form-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) );
406
+			return new WP_Error('give-form-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key));
407 407
 
408 408
 		}
409 409
 
@@ -419,30 +419,30 @@  discard block
 block discarded – undo
419 419
 	 *
420 420
 	 * @return bool|int    False if data isn't passed and class not instantiated for creation, or New Form ID.
421 421
 	 */
422
-	public function create( $data = array() ) {
422
+	public function create($data = array()) {
423 423
 
424
-		if ( $this->id != 0 ) {
424
+		if ($this->id != 0) {
425 425
 			return false;
426 426
 		}
427 427
 
428 428
 		$defaults = array(
429 429
 			'post_type'   => 'give_forms',
430 430
 			'post_status' => 'draft',
431
-			'post_title'  => __( 'New Donation Form', 'give' ),
431
+			'post_title'  => __('New Donation Form', 'give'),
432 432
 		);
433 433
 
434
-		$args = wp_parse_args( $data, $defaults );
434
+		$args = wp_parse_args($data, $defaults);
435 435
 
436 436
 		/**
437 437
 		 * Fired before a donation form is created
438 438
 		 *
439 439
 		 * @param array $args The post object arguments used for creation.
440 440
 		 */
441
-		do_action( 'give_form_pre_create', $args );
441
+		do_action('give_form_pre_create', $args);
442 442
 
443
-		$id = wp_insert_post( $args, true );
443
+		$id = wp_insert_post($args, true);
444 444
 
445
-		$donation_form = WP_Post::get_instance( $id );
445
+		$donation_form = WP_Post::get_instance($id);
446 446
 
447 447
 		/**
448 448
 		 * Fired after a donation form is created
@@ -450,9 +450,9 @@  discard block
 block discarded – undo
450 450
 		 * @param int   $id   The post ID of the created item.
451 451
 		 * @param array $args The post object arguments used for creation.
452 452
 		 */
453
-		do_action( 'give_form_post_create', $id, $args );
453
+		do_action('give_form_post_create', $id, $args);
454 454
 
455
-		return $this->setup_donation_form( $donation_form );
455
+		return $this->setup_donation_form($donation_form);
456 456
 
457 457
 	}
458 458
 
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 	 * @return string Donation form name.
478 478
 	 */
479 479
 	public function get_name() {
480
-		return get_the_title( $this->ID );
480
+		return get_the_title($this->ID);
481 481
 	}
482 482
 
483 483
 	/**
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
 	 */
491 491
 	public function get_price() {
492 492
 
493
-		if ( ! isset( $this->price ) ) {
493
+		if ( ! isset($this->price)) {
494 494
 
495 495
 			$this->price = give_maybe_sanitize_amount(
496 496
 				give_get_meta(
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
 				)
501 501
 			);
502 502
 
503
-			if ( ! $this->price ) {
503
+			if ( ! $this->price) {
504 504
 				$this->price = 0;
505 505
 			}
506 506
 
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
 		 * @param string     $price The donation form price.
515 515
 		 * @param string|int $id    The form ID.
516 516
 		 */
517
-		return apply_filters( 'give_get_set_price', $this->price, $this->ID );
517
+		return apply_filters('give_get_set_price', $this->price, $this->ID);
518 518
 	}
519 519
 
520 520
 	/**
@@ -527,18 +527,18 @@  discard block
 block discarded – undo
527 527
 	 */
528 528
 	public function get_minimum_price() {
529 529
 
530
-		if ( ! isset( $this->minimum_price ) ) {
530
+		if ( ! isset($this->minimum_price)) {
531 531
 
532
-			$allow_custom_amount = give_get_meta( $this->ID, '_give_custom_amount', true );
533
-			$this->minimum_price = give_get_meta( $this->ID, '_give_custom_amount_minimum', true );
532
+			$allow_custom_amount = give_get_meta($this->ID, '_give_custom_amount', true);
533
+			$this->minimum_price = give_get_meta($this->ID, '_give_custom_amount_minimum', true);
534 534
 
535
-			if ( ! give_is_setting_enabled( $allow_custom_amount ) ) {
535
+			if ( ! give_is_setting_enabled($allow_custom_amount)) {
536 536
 				$this->minimum_price = 0;
537 537
 			}
538 538
 
539 539
 		}
540 540
 
541
-		return apply_filters( 'give_get_set_minimum_price', $this->minimum_price, $this->ID );
541
+		return apply_filters('give_get_set_minimum_price', $this->minimum_price, $this->ID);
542 542
 	}
543 543
 
544 544
 	/**
@@ -551,9 +551,9 @@  discard block
 block discarded – undo
551 551
 	 */
552 552
 	public function get_prices() {
553 553
 
554
-		if ( ! isset( $this->prices ) ) {
554
+		if ( ! isset($this->prices)) {
555 555
 
556
-			$this->prices = give_get_meta( $this->ID, '_give_donation_levels', true );
556
+			$this->prices = give_get_meta($this->ID, '_give_donation_levels', true);
557 557
 
558 558
 		}
559 559
 
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
 		 * @param array      $prices The array of mulit-level prices.
566 566
 		 * @param int|string $ID     The ID of the form.
567 567
 		 */
568
-		return apply_filters( 'give_get_donation_levels', $this->prices, $this->ID );
568
+		return apply_filters('give_get_donation_levels', $this->prices, $this->ID);
569 569
 
570 570
 	}
571 571
 
@@ -579,17 +579,17 @@  discard block
 block discarded – undo
579 579
 	 */
580 580
 	public function get_goal() {
581 581
 
582
-		if ( ! isset( $this->goal ) ) {
582
+		if ( ! isset($this->goal)) {
583 583
 
584
-			$this->goal = give_get_meta( $this->ID, '_give_set_goal', true );
584
+			$this->goal = give_get_meta($this->ID, '_give_set_goal', true);
585 585
 
586
-			if ( ! $this->goal ) {
586
+			if ( ! $this->goal) {
587 587
 				$this->goal = 0;
588 588
 			}
589 589
 
590 590
 		}
591 591
 
592
-		return apply_filters( 'give_get_set_goal', $this->goal, $this->ID );
592
+		return apply_filters('give_get_set_goal', $this->goal, $this->ID);
593 593
 
594 594
 	}
595 595
 
@@ -603,10 +603,10 @@  discard block
 block discarded – undo
603 603
 	 */
604 604
 	public function is_single_price_mode() {
605 605
 
606
-		$option = give_get_meta( $this->ID, '_give_price_option', true );
606
+		$option = give_get_meta($this->ID, '_give_price_option', true);
607 607
 		$ret    = 0;
608 608
 
609
-		if ( empty( $option ) || $option === 'set' ) {
609
+		if (empty($option) || $option === 'set') {
610 610
 			$ret = 1;
611 611
 		}
612 612
 
@@ -618,7 +618,7 @@  discard block
 block discarded – undo
618 618
 		 * @param bool       $ret Is donation form in single price mode?
619 619
 		 * @param int|string $ID The ID of the donation form.
620 620
 		 */
621
-		return (bool) apply_filters( 'give_single_price_option_mode', $ret, $this->ID );
621
+		return (bool) apply_filters('give_single_price_option_mode', $ret, $this->ID);
622 622
 
623 623
 	}
624 624
 
@@ -632,10 +632,10 @@  discard block
 block discarded – undo
632 632
 	 */
633 633
 	public function is_custom_price_mode() {
634 634
 
635
-		$option = give_get_meta( $this->ID, '_give_custom_amount', true );
635
+		$option = give_get_meta($this->ID, '_give_custom_amount', true);
636 636
 		$ret    = 0;
637 637
 
638
-		if ( give_is_setting_enabled( $option ) ) {
638
+		if (give_is_setting_enabled($option)) {
639 639
 			$ret = 1;
640 640
 		}
641 641
 
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
 		 * @param bool       $ret Is donation form in custom price mode?
648 648
 		 * @param int|string $ID  The ID of the donation form.
649 649
 		 */
650
-		return (bool) apply_filters( 'give_custom_price_option_mode', $ret, $this->ID );
650
+		return (bool) apply_filters('give_custom_price_option_mode', $ret, $this->ID);
651 651
 
652 652
 	}
653 653
 
@@ -663,10 +663,10 @@  discard block
 block discarded – undo
663 663
 	 */
664 664
 	public function has_variable_prices() {
665 665
 
666
-		$option = give_get_meta( $this->ID, '_give_price_option', true );
666
+		$option = give_get_meta($this->ID, '_give_price_option', true);
667 667
 		$ret    = 0;
668 668
 
669
-		if ( $option === 'multi' ) {
669
+		if ($option === 'multi') {
670 670
 			$ret = 1;
671 671
 		}
672 672
 
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
 		 * @param bool       $ret Does donation form have variable prices?
677 677
 		 * @param int|string $ID  The ID of the donation form.
678 678
 		 */
679
-		return (bool) apply_filters( 'give_has_variable_prices', $ret, $this->ID );
679
+		return (bool) apply_filters('give_has_variable_prices', $ret, $this->ID);
680 680
 
681 681
 	}
682 682
 
@@ -690,17 +690,17 @@  discard block
 block discarded – undo
690 690
 	 */
691 691
 	public function get_type() {
692 692
 
693
-		if ( ! isset( $this->type ) ) {
693
+		if ( ! isset($this->type)) {
694 694
 
695
-			$this->type = give_get_meta( $this->ID, '_give_price_option', true );
695
+			$this->type = give_get_meta($this->ID, '_give_price_option', true);
696 696
 
697
-			if ( empty( $this->type ) ) {
697
+			if (empty($this->type)) {
698 698
 				$this->type = 'set';
699 699
 			}
700 700
 
701 701
 		}
702 702
 
703
-		return apply_filters( 'give_get_form_type', $this->type, $this->ID );
703
+		return apply_filters('give_get_form_type', $this->type, $this->ID);
704 704
 
705 705
 	}
706 706
 
@@ -716,23 +716,23 @@  discard block
 block discarded – undo
716 716
 	 *
717 717
 	 * @return string
718 718
 	 */
719
-	public function get_form_classes( $args ) {
719
+	public function get_form_classes($args) {
720 720
 
721
-		$float_labels_option = give_is_float_labels_enabled( $args )
721
+		$float_labels_option = give_is_float_labels_enabled($args)
722 722
 			? 'float-labels-enabled'
723 723
 			: '';
724 724
 
725
-		$form_classes_array = apply_filters( 'give_form_classes', array(
725
+		$form_classes_array = apply_filters('give_form_classes', array(
726 726
 			'give-form',
727
-			'give-form-' . $this->ID,
728
-			'give-form-type-' . $this->get_type(),
727
+			'give-form-'.$this->ID,
728
+			'give-form-type-'.$this->get_type(),
729 729
 			$float_labels_option,
730
-		), $this->ID, $args );
730
+		), $this->ID, $args);
731 731
 
732 732
 		// Remove empty class names.
733
-		$form_classes_array = array_filter( $form_classes_array );
733
+		$form_classes_array = array_filter($form_classes_array);
734 734
 
735
-		return implode( ' ', $form_classes_array );
735
+		return implode(' ', $form_classes_array);
736 736
 
737 737
 	}
738 738
 
@@ -747,22 +747,22 @@  discard block
 block discarded – undo
747 747
 	 *
748 748
 	 * @return string
749 749
 	 */
750
-	public function get_form_wrap_classes( $args ) {
750
+	public function get_form_wrap_classes($args) {
751 751
 		$custom_class = array(
752 752
 			'give-form-wrap',
753 753
 		);
754 754
 
755
-		if ( $this->is_close_donation_form() ) {
755
+		if ($this->is_close_donation_form()) {
756 756
 			$custom_class[] = 'give-form-closed';
757
-		} else{
758
-			$display_option = ( isset( $args['display_style'] ) && ! empty( $args['display_style'] ) )
757
+		} else {
758
+			$display_option = (isset($args['display_style']) && ! empty($args['display_style']))
759 759
 				? $args['display_style']
760
-				: give_get_meta( $this->ID, '_give_payment_display', true );
760
+				: give_get_meta($this->ID, '_give_payment_display', true);
761 761
 
762 762
 			$custom_class[] = "give-display-{$display_option}";
763 763
 
764 764
 			// If admin want to show only button for form then user inbuilt modal functionality.
765
-			if ( 'button' === $display_option ) {
765
+			if ('button' === $display_option) {
766 766
 				$custom_class[] = 'give-display-button-only';
767 767
 			}
768 768
 		}
@@ -773,10 +773,10 @@  discard block
 block discarded – undo
773 773
 		 *
774 774
 		 * @since 1.0
775 775
 		 */
776
-		$form_wrap_classes_array = (array) apply_filters( 'give_form_wrap_classes', $custom_class, $this->ID, $args );
776
+		$form_wrap_classes_array = (array) apply_filters('give_form_wrap_classes', $custom_class, $this->ID, $args);
777 777
 
778 778
 
779
-		return implode( ' ', $form_wrap_classes_array );
779
+		return implode(' ', $form_wrap_classes_array);
780 780
 
781 781
 	}
782 782
 
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
 	public function is_set_type_donation_form() {
792 792
 		$form_type = $this->get_type();
793 793
 
794
-		return ( 'set' === $form_type ? true : false );
794
+		return ('set' === $form_type ? true : false);
795 795
 	}
796 796
 
797 797
 	/**
@@ -805,7 +805,7 @@  discard block
 block discarded – undo
805 805
 	public function is_multi_type_donation_form() {
806 806
 		$form_type = $this->get_type();
807 807
 
808
-		return ( 'multi' === $form_type ? true : false );
808
+		return ('multi' === $form_type ? true : false);
809 809
 
810 810
 	}
811 811
 
@@ -819,15 +819,15 @@  discard block
 block discarded – undo
819 819
 	 */
820 820
 	public function get_sales() {
821 821
 
822
-		if ( ! isset( $this->sales ) ) {
822
+		if ( ! isset($this->sales)) {
823 823
 
824
-			if ( '' == give_get_meta( $this->ID, '_give_form_sales', true ) ) {
825
-				add_post_meta( $this->ID, '_give_form_sales', 0 );
824
+			if ('' == give_get_meta($this->ID, '_give_form_sales', true)) {
825
+				add_post_meta($this->ID, '_give_form_sales', 0);
826 826
 			} // End if
827 827
 
828
-			$this->sales = give_get_meta( $this->ID, '_give_form_sales', true );
828
+			$this->sales = give_get_meta($this->ID, '_give_form_sales', true);
829 829
 
830
-			if ( $this->sales < 0 ) {
830
+			if ($this->sales < 0) {
831 831
 				// Never let sales be less than zero.
832 832
 				$this->sales = 0;
833 833
 			}
@@ -848,13 +848,13 @@  discard block
 block discarded – undo
848 848
 	 *
849 849
 	 * @return int|false     New number of total sales.
850 850
 	 */
851
-	public function increase_sales( $quantity = 1 ) {
851
+	public function increase_sales($quantity = 1) {
852 852
 
853
-		$sales       = give_get_form_sales_stats( $this->ID );
854
-		$quantity    = absint( $quantity );
853
+		$sales       = give_get_form_sales_stats($this->ID);
854
+		$quantity    = absint($quantity);
855 855
 		$total_sales = $sales + $quantity;
856 856
 
857
-		if ( $this->update_meta( '_give_form_sales', $total_sales ) ) {
857
+		if ($this->update_meta('_give_form_sales', $total_sales)) {
858 858
 
859 859
 			$this->sales = $total_sales;
860 860
 
@@ -875,17 +875,17 @@  discard block
 block discarded – undo
875 875
 	 *
876 876
 	 * @return int|false     New number of total sales.
877 877
 	 */
878
-	public function decrease_sales( $quantity = 1 ) {
878
+	public function decrease_sales($quantity = 1) {
879 879
 
880
-		$sales = give_get_form_sales_stats( $this->ID );
880
+		$sales = give_get_form_sales_stats($this->ID);
881 881
 
882 882
 		// Only decrease if not already zero
883
-		if ( $sales > 0 ) {
883
+		if ($sales > 0) {
884 884
 
885
-			$quantity    = absint( $quantity );
885
+			$quantity    = absint($quantity);
886 886
 			$total_sales = $sales - $quantity;
887 887
 
888
-			if ( $this->update_meta( '_give_form_sales', $total_sales ) ) {
888
+			if ($this->update_meta('_give_form_sales', $total_sales)) {
889 889
 
890 890
 				$this->sales = $sales;
891 891
 
@@ -909,15 +909,15 @@  discard block
 block discarded – undo
909 909
 	 */
910 910
 	public function get_earnings() {
911 911
 
912
-		if ( ! isset( $this->earnings ) ) {
912
+		if ( ! isset($this->earnings)) {
913 913
 
914
-			if ( '' == give_get_meta( $this->ID, '_give_form_earnings', true ) ) {
915
-				add_post_meta( $this->ID, '_give_form_earnings', 0 );
914
+			if ('' == give_get_meta($this->ID, '_give_form_earnings', true)) {
915
+				add_post_meta($this->ID, '_give_form_earnings', 0);
916 916
 			}
917 917
 
918
-			$this->earnings = give_get_meta( $this->ID, '_give_form_earnings', true );
918
+			$this->earnings = give_get_meta($this->ID, '_give_form_earnings', true);
919 919
 
920
-			if ( $this->earnings < 0 ) {
920
+			if ($this->earnings < 0) {
921 921
 				// Never let earnings be less than zero
922 922
 				$this->earnings = 0;
923 923
 			}
@@ -938,12 +938,12 @@  discard block
 block discarded – undo
938 938
 	 *
939 939
 	 * @return float|false
940 940
 	 */
941
-	public function increase_earnings( $amount = 0 ) {
941
+	public function increase_earnings($amount = 0) {
942 942
 
943
-		$earnings   = give_get_form_earnings_stats( $this->ID );
943
+		$earnings   = give_get_form_earnings_stats($this->ID);
944 944
 		$new_amount = $earnings + (float) $amount;
945 945
 
946
-		if ( $this->update_meta( '_give_form_earnings', $new_amount ) ) {
946
+		if ($this->update_meta('_give_form_earnings', $new_amount)) {
947 947
 
948 948
 			$this->earnings = $new_amount;
949 949
 
@@ -965,16 +965,16 @@  discard block
 block discarded – undo
965 965
 	 *
966 966
 	 * @return float|false
967 967
 	 */
968
-	public function decrease_earnings( $amount ) {
968
+	public function decrease_earnings($amount) {
969 969
 
970
-		$earnings = give_get_form_earnings_stats( $this->ID );
970
+		$earnings = give_get_form_earnings_stats($this->ID);
971 971
 
972
-		if ( $earnings > 0 ) {
972
+		if ($earnings > 0) {
973 973
 			// Only decrease if greater than zero
974 974
 			$new_amount = $earnings - (float) $amount;
975 975
 
976 976
 
977
-			if ( $this->update_meta( '_give_form_earnings', $new_amount ) ) {
977
+			if ($this->update_meta('_give_form_earnings', $new_amount)) {
978 978
 
979 979
 				$this->earnings = $new_amount;
980 980
 
@@ -998,22 +998,22 @@  discard block
 block discarded – undo
998 998
 	 *
999 999
 	 * @return bool
1000 1000
 	 */
1001
-	public function is_free( $price_id = false ) {
1001
+	public function is_free($price_id = false) {
1002 1002
 
1003 1003
 		$is_free          = false;
1004
-		$variable_pricing = give_has_variable_prices( $this->ID );
1004
+		$variable_pricing = give_has_variable_prices($this->ID);
1005 1005
 
1006
-		if ( $variable_pricing && ! is_null( $price_id ) && $price_id !== false ) {
1007
-			$price = give_get_price_option_amount( $this->ID, $price_id );
1008
-		} elseif ( ! $variable_pricing ) {
1009
-			$price = give_get_meta( $this->ID, '_give_set_price', true );
1006
+		if ($variable_pricing && ! is_null($price_id) && $price_id !== false) {
1007
+			$price = give_get_price_option_amount($this->ID, $price_id);
1008
+		} elseif ( ! $variable_pricing) {
1009
+			$price = give_get_meta($this->ID, '_give_set_price', true);
1010 1010
 		}
1011 1011
 
1012
-		if ( isset( $price ) && (float) $price == 0 ) {
1012
+		if (isset($price) && (float) $price == 0) {
1013 1013
 			$is_free = true;
1014 1014
 		}
1015 1015
 
1016
-		return (bool) apply_filters( 'give_is_free_donation', $is_free, $this->ID, $price_id );
1016
+		return (bool) apply_filters('give_is_free_donation', $is_free, $this->ID, $price_id);
1017 1017
 
1018 1018
 	}
1019 1019
 
@@ -1040,9 +1040,9 @@  discard block
 block discarded – undo
1040 1040
 		$is_close_form = apply_filters(
1041 1041
 			'give_is_close_donation_form',
1042 1042
 			(
1043
-			give_is_setting_enabled( give_get_meta( $this->ID, '_give_goal_option', true ) ) )
1044
-			&& give_is_setting_enabled( give_get_meta( $this->ID, '_give_close_form_when_goal_achieved', true ) )
1045
-			&& ( $this->get_goal() <= $this->get_earnings()
1043
+			give_is_setting_enabled(give_get_meta($this->ID, '_give_goal_option', true)) )
1044
+			&& give_is_setting_enabled(give_get_meta($this->ID, '_give_close_form_when_goal_achieved', true))
1045
+			&& ($this->get_goal() <= $this->get_earnings()
1046 1046
 			),
1047 1047
 			$this->ID
1048 1048
 		);
@@ -1061,29 +1061,29 @@  discard block
 block discarded – undo
1061 1061
 	 *
1062 1062
 	 * @return bool                            The result of the update query.
1063 1063
 	 */
1064
-	private function update_meta( $meta_key = '', $meta_value = '' ) {
1064
+	private function update_meta($meta_key = '', $meta_value = '') {
1065 1065
 
1066 1066
 		/* @var WPDB $wpdb */
1067 1067
 		global $wpdb;
1068 1068
 
1069
-		if ( empty( $meta_key ) ) {
1069
+		if (empty($meta_key)) {
1070 1070
 			return false;
1071 1071
 		}
1072 1072
 
1073 1073
 		// Make sure if it needs to be serialized, we do
1074
-		$meta_value = maybe_serialize( $meta_value );
1074
+		$meta_value = maybe_serialize($meta_value);
1075 1075
 
1076
-		if ( is_numeric( $meta_value ) ) {
1077
-			$value_type = is_float( $meta_value ) ? '%f' : '%d';
1076
+		if (is_numeric($meta_value)) {
1077
+			$value_type = is_float($meta_value) ? '%f' : '%d';
1078 1078
 		} else {
1079 1079
 			$value_type = "'%s'";
1080 1080
 		}
1081 1081
 
1082
-		$sql = $wpdb->prepare( "UPDATE $wpdb->postmeta SET meta_value = $value_type WHERE post_id = $this->ID AND meta_key = '%s'", $meta_value, $meta_key );
1082
+		$sql = $wpdb->prepare("UPDATE $wpdb->postmeta SET meta_value = $value_type WHERE post_id = $this->ID AND meta_key = '%s'", $meta_value, $meta_key);
1083 1083
 
1084
-		if ( $wpdb->query( $sql ) ) {
1084
+		if ($wpdb->query($sql)) {
1085 1085
 
1086
-			clean_post_cache( $this->ID );
1086
+			clean_post_cache($this->ID);
1087 1087
 
1088 1088
 			return true;
1089 1089
 
Please login to merge, or discard this patch.
includes/gateways/functions.php 1 patch
Spacing   +66 added lines, -66 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
 
@@ -24,16 +24,16 @@  discard block
 block discarded – undo
24 24
 	// Default, built-in gateways
25 25
 	$gateways = array(
26 26
 		'paypal' => array(
27
-			'admin_label'    => __( 'PayPal Standard', 'give' ),
28
-			'checkout_label' => __( 'PayPal', 'give' ),
27
+			'admin_label'    => __('PayPal Standard', 'give'),
28
+			'checkout_label' => __('PayPal', 'give'),
29 29
 		),
30 30
 		'manual' => array(
31
-			'admin_label'    => __( 'Test Donation', 'give' ),
32
-			'checkout_label' => __( 'Test Donation', 'give' )
31
+			'admin_label'    => __('Test Donation', 'give'),
32
+			'checkout_label' => __('Test Donation', 'give')
33 33
 		),
34 34
 	);
35 35
 
36
-	return apply_filters( 'give_payment_gateways', $gateways );
36
+	return apply_filters('give_payment_gateways', $gateways);
37 37
 
38 38
 }
39 39
 
@@ -46,24 +46,24 @@  discard block
 block discarded – undo
46 46
  *
47 47
  * @return array $gateway_list All the available gateways
48 48
  */
49
-function give_get_enabled_payment_gateways( $form_id = 0 ) {
49
+function give_get_enabled_payment_gateways($form_id = 0) {
50 50
 
51 51
 	$gateways = give_get_payment_gateways();
52 52
 
53
-	$enabled = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' );
53
+	$enabled = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways');
54 54
 
55 55
 	$gateway_list = array();
56 56
 
57
-	foreach ( $gateways as $key => $gateway ) {
58
-		if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) {
59
-			$gateway_list[ $key ] = $gateway;
57
+	foreach ($gateways as $key => $gateway) {
58
+		if (isset($enabled[$key]) && $enabled[$key] == 1) {
59
+			$gateway_list[$key] = $gateway;
60 60
 		}
61 61
 	}
62 62
 
63 63
 	// Set order of payment gateway in list.
64
-	$gateway_list = give_get_ordered_payment_gateways( $gateway_list );
64
+	$gateway_list = give_get_ordered_payment_gateways($gateway_list);
65 65
 
66
-	return apply_filters( 'give_enabled_payment_gateways', $gateway_list, $form_id );
66
+	return apply_filters('give_enabled_payment_gateways', $gateway_list, $form_id);
67 67
 }
68 68
 
69 69
 /**
@@ -75,12 +75,12 @@  discard block
 block discarded – undo
75 75
  *
76 76
  * @return boolean true if enabled, false otherwise
77 77
  */
78
-function give_is_gateway_active( $gateway ) {
78
+function give_is_gateway_active($gateway) {
79 79
 	$gateways = give_get_enabled_payment_gateways();
80 80
 
81
-	$ret = array_key_exists( $gateway, $gateways );
81
+	$ret = array_key_exists($gateway, $gateways);
82 82
 
83
-	return apply_filters( 'give_is_gateway_active', $ret, $gateway, $gateways );
83
+	return apply_filters('give_is_gateway_active', $ret, $gateway, $gateways);
84 84
 }
85 85
 
86 86
 /**
@@ -92,23 +92,23 @@  discard block
 block discarded – undo
92 92
  *
93 93
  * @return string Gateway ID
94 94
  */
95
-function give_get_default_gateway( $form_id ) {
95
+function give_get_default_gateway($form_id) {
96 96
 
97 97
 	$give_options = give_get_settings();
98
-	$default      = isset( $give_options['default_gateway'] ) && give_is_gateway_active( $give_options['default_gateway'] ) ? $give_options['default_gateway'] : 'paypal';
99
-	$form_default = give_get_meta( $form_id, '_give_default_gateway', true );
98
+	$default      = isset($give_options['default_gateway']) && give_is_gateway_active($give_options['default_gateway']) ? $give_options['default_gateway'] : 'paypal';
99
+	$form_default = give_get_meta($form_id, '_give_default_gateway', true);
100 100
 
101 101
 	// Single Form settings varies compared to the Global default settings.
102
-	if ( ! empty( $form_default ) &&
102
+	if ( ! empty($form_default) &&
103 103
 		 $form_id !== null &&
104 104
 		 $default !== $form_default &&
105 105
 		 $form_default !== 'global' &&
106
-		 give_is_gateway_active( $form_default )
106
+		 give_is_gateway_active($form_default)
107 107
 	) {
108 108
 		$default = $form_default;
109 109
 	}
110 110
 
111
-	return apply_filters( 'give_default_gateway', $default );
111
+	return apply_filters('give_default_gateway', $default);
112 112
 }
113 113
 
114 114
 /**
@@ -120,18 +120,18 @@  discard block
 block discarded – undo
120 120
  *
121 121
  * @return string Gateway admin label
122 122
  */
123
-function give_get_gateway_admin_label( $gateway ) {
123
+function give_get_gateway_admin_label($gateway) {
124 124
 	$gateways = give_get_payment_gateways();
125
-	$label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway;
126
-	$payment  = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : false;
125
+	$label    = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway;
126
+	$payment  = isset($_GET['id']) ? absint($_GET['id']) : false;
127 127
 
128
-	if ( $gateway == 'manual' && $payment ) {
129
-		if ( give_donation_amount( $payment ) == 0 ) {
130
-			$label = __( 'Test Donation', 'give' );
128
+	if ($gateway == 'manual' && $payment) {
129
+		if (give_donation_amount($payment) == 0) {
130
+			$label = __('Test Donation', 'give');
131 131
 		}
132 132
 	}
133 133
 
134
-	return apply_filters( 'give_gateway_admin_label', $label, $gateway );
134
+	return apply_filters('give_gateway_admin_label', $label, $gateway);
135 135
 }
136 136
 
137 137
 /**
@@ -143,15 +143,15 @@  discard block
 block discarded – undo
143 143
  *
144 144
  * @return string Checkout label for the gateway
145 145
  */
146
-function give_get_gateway_checkout_label( $gateway ) {
146
+function give_get_gateway_checkout_label($gateway) {
147 147
 	$gateways = give_get_payment_gateways();
148
-	$label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway;
148
+	$label    = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway;
149 149
 
150
-	if ( $gateway == 'manual' ) {
151
-		$label = __( 'Test Donation', 'give' );
150
+	if ($gateway == 'manual') {
151
+		$label = __('Test Donation', 'give');
152 152
 	}
153 153
 
154
-	return apply_filters( 'give_gateway_checkout_label', $label, $gateway );
154
+	return apply_filters('give_gateway_checkout_label', $label, $gateway);
155 155
 }
156 156
 
157 157
 /**
@@ -163,11 +163,11 @@  discard block
 block discarded – undo
163 163
  *
164 164
  * @return array Options the gateway supports
165 165
  */
166
-function give_get_gateway_supports( $gateway ) {
166
+function give_get_gateway_supports($gateway) {
167 167
 	$gateways = give_get_enabled_payment_gateways();
168
-	$supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array();
168
+	$supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array();
169 169
 
170
-	return apply_filters( 'give_gateway_supports', $supports, $gateway );
170
+	return apply_filters('give_gateway_supports', $supports, $gateway);
171 171
 }
172 172
 
173 173
 /**
@@ -180,9 +180,9 @@  discard block
 block discarded – undo
180 180
  *
181 181
  * @return void
182 182
  */
183
-function give_send_to_gateway( $gateway, $payment_data ) {
183
+function give_send_to_gateway($gateway, $payment_data) {
184 184
 
185
-	$payment_data['gateway_nonce'] = wp_create_nonce( 'give-gateway' );
185
+	$payment_data['gateway_nonce'] = wp_create_nonce('give-gateway');
186 186
 
187 187
 	/**
188 188
 	 * Fires while loading payment gateway via AJAX.
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	 *
194 194
 	 * @param array $payment_data All the payment data to be sent to the gateway.
195 195
 	 */
196
-	do_action( "give_gateway_{$gateway}", $payment_data );
196
+	do_action("give_gateway_{$gateway}", $payment_data);
197 197
 }
198 198
 
199 199
 
@@ -207,34 +207,34 @@  discard block
 block discarded – undo
207 207
  *
208 208
  * @return string $enabled_gateway The slug of the gateway
209 209
  */
210
-function give_get_chosen_gateway( $form_id ) {
210
+function give_get_chosen_gateway($form_id) {
211 211
 
212
-	$request_form_id = isset( $_REQUEST['give_form_id'] ) ? $_REQUEST['give_form_id'] : 0;
212
+	$request_form_id = isset($_REQUEST['give_form_id']) ? $_REQUEST['give_form_id'] : 0;
213 213
 
214 214
 	// Back to check if 'form-id' is present.
215
-	if ( empty( $request_form_id ) ) {
216
-		$request_form_id = isset( $_REQUEST['form-id'] ) ? $_REQUEST['form-id'] : 0;
215
+	if (empty($request_form_id)) {
216
+		$request_form_id = isset($_REQUEST['form-id']) ? $_REQUEST['form-id'] : 0;
217 217
 	}
218 218
 
219
-	$request_payment_mode = isset( $_REQUEST['payment-mode'] ) ? $_REQUEST['payment-mode'] : '';
219
+	$request_payment_mode = isset($_REQUEST['payment-mode']) ? $_REQUEST['payment-mode'] : '';
220 220
 	$chosen               = false;
221 221
 
222 222
 	// If both 'payment-mode' and 'form-id' then set for only this form.
223
-	if ( ! empty( $request_form_id ) && $form_id == $request_form_id ) {
223
+	if ( ! empty($request_form_id) && $form_id == $request_form_id) {
224 224
 		$chosen = $request_payment_mode;
225
-	} elseif ( empty( $request_form_id ) && $request_payment_mode ) {
225
+	} elseif (empty($request_form_id) && $request_payment_mode) {
226 226
 		// If no 'form-id' but there is 'payment-mode'.
227 227
 		$chosen = $request_payment_mode;
228 228
 	}
229 229
 
230 230
 	// Get the enable gateway based of chosen var.
231
-	if ( $chosen && give_is_gateway_active( $chosen ) ) {
232
-		$enabled_gateway = urldecode( $chosen );
231
+	if ($chosen && give_is_gateway_active($chosen)) {
232
+		$enabled_gateway = urldecode($chosen);
233 233
 	} else {
234
-		$enabled_gateway = give_get_default_gateway( $form_id );
234
+		$enabled_gateway = give_get_default_gateway($form_id);
235 235
 	}
236 236
 
237
-	return apply_filters( 'give_chosen_gateway', $enabled_gateway );
237
+	return apply_filters('give_chosen_gateway', $enabled_gateway);
238 238
 
239 239
 }
240 240
 
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
  *
253 253
  * @return int ID of the new log entry
254 254
  */
255
-function give_record_gateway_error( $title = '', $message = '', $parent = 0 ) {
256
-	return give_record_log( $title, $message, $parent, 'gateway_error' );
255
+function give_record_gateway_error($title = '', $message = '', $parent = 0) {
256
+	return give_record_log($title, $message, $parent, 'gateway_error');
257 257
 }
258 258
 
259 259
 /**
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
  *
267 267
  * @return int
268 268
  */
269
-function give_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) {
269
+function give_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') {
270 270
 
271 271
 	$ret  = 0;
272 272
 	$args = array(
@@ -278,9 +278,9 @@  discard block
 block discarded – undo
278 278
 		'fields'      => 'ids',
279 279
 	);
280 280
 
281
-	$payments = new WP_Query( $args );
281
+	$payments = new WP_Query($args);
282 282
 
283
-	if ( $payments ) {
283
+	if ($payments) {
284 284
 		$ret = $payments->post_count;
285 285
 	}
286 286
 
@@ -297,27 +297,27 @@  discard block
 block discarded – undo
297 297
  *
298 298
  * @return array $gateways All the available gateways
299 299
  */
300
-function give_get_ordered_payment_gateways( $gateways ) {
300
+function give_get_ordered_payment_gateways($gateways) {
301 301
 
302 302
 	// Get gateways setting.
303
-	$gateways_setting = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' );
303
+	$gateways_setting = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways');
304 304
 
305 305
 	// Return from here if we do not have gateways setting.
306
-	if ( empty( $gateways_setting ) ) {
306
+	if (empty($gateways_setting)) {
307 307
 		return $gateways;
308 308
 	}
309 309
 
310 310
 	// Reverse array to order payment gateways.
311
-	$gateways_setting = array_reverse( $gateways_setting );
311
+	$gateways_setting = array_reverse($gateways_setting);
312 312
 
313 313
 	// Reorder gateways array
314
-	foreach ( $gateways_setting as $gateway_key => $value ) {
314
+	foreach ($gateways_setting as $gateway_key => $value) {
315 315
 
316
-		$new_gateway_value = isset( $gateways[ $gateway_key ] ) ? $gateways[ $gateway_key ] : '';
317
-		unset( $gateways[ $gateway_key ] );
316
+		$new_gateway_value = isset($gateways[$gateway_key]) ? $gateways[$gateway_key] : '';
317
+		unset($gateways[$gateway_key]);
318 318
 
319
-		if ( ! empty( $new_gateway_value ) ) {
320
-			$gateways = array_merge( array( $gateway_key => $new_gateway_value ), $gateways );
319
+		if ( ! empty($new_gateway_value)) {
320
+			$gateways = array_merge(array($gateway_key => $new_gateway_value), $gateways);
321 321
 		}
322 322
 	}
323 323
 
@@ -328,5 +328,5 @@  discard block
 block discarded – undo
328 328
 	 *
329 329
 	 * @param array $gateways All the available gateways
330 330
 	 */
331
-	return apply_filters( 'give_payment_gateways_order', $gateways );
331
+	return apply_filters('give_payment_gateways_order', $gateways);
332 332
 }
333 333
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-give-roles.php 1 patch
Spacing   +68 added lines, -68 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
 
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
 	 * @access public
36 36
 	 */
37 37
 	public function __construct() {
38
-		add_filter( 'give_map_meta_cap', array( $this, 'meta_caps' ), 10, 4 );
39
-		add_filter( 'woocommerce_disable_admin_bar', array( $this, 'manage_admin_dashboard' ), 10 );
40
-		add_filter( 'woocommerce_prevent_admin_access', array( $this, 'manage_admin_dashboard'), 10 );
38
+		add_filter('give_map_meta_cap', array($this, 'meta_caps'), 10, 4);
39
+		add_filter('woocommerce_disable_admin_bar', array($this, 'manage_admin_dashboard'), 10);
40
+		add_filter('woocommerce_prevent_admin_access', array($this, 'manage_admin_dashboard'), 10);
41 41
 	}
42 42
 
43 43
 	/**
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 * @return void
52 52
 	 */
53 53
 	public function add_roles() {
54
-		add_role( 'give_manager', __( 'Give Manager', 'give' ), array(
54
+		add_role('give_manager', __('Give Manager', 'give'), array(
55 55
 			'read'                   => true,
56 56
 			'edit_posts'             => true,
57 57
 			'delete_posts'           => true,
@@ -80,25 +80,25 @@  discard block
 block discarded – undo
80 80
 			'publish_posts'          => true,
81 81
 			'read_private_pages'     => true,
82 82
 			'read_private_posts'     => true,
83
-		) );
83
+		));
84 84
 
85
-		add_role( 'give_accountant', __( 'Give Accountant', 'give' ), array(
85
+		add_role('give_accountant', __('Give Accountant', 'give'), array(
86 86
 			'read'         => true,
87 87
 			'edit_posts'   => false,
88 88
 			'delete_posts' => false
89
-		) );
89
+		));
90 90
 
91
-		add_role( 'give_worker', __( 'Give Worker', 'give' ), array(
91
+		add_role('give_worker', __('Give Worker', 'give'), array(
92 92
 			'read'         => true,
93 93
 			'edit_posts'   => true,
94 94
 			'edit_pages'   => true,
95 95
 			'upload_files' => true,
96 96
 			'delete_posts' => false,
97
-		) );
97
+		));
98 98
 
99
-		add_role( 'give_donor', __( 'Give Donor', 'give' ), array(
99
+		add_role('give_donor', __('Give Donor', 'give'), array(
100 100
 			'read' => true,
101
-		) );
101
+		));
102 102
 
103 103
 	}
104 104
 
@@ -117,41 +117,41 @@  discard block
 block discarded – undo
117 117
 	public function add_caps() {
118 118
 		global $wp_roles;
119 119
 
120
-		if ( class_exists( 'WP_Roles' ) ) {
121
-			if ( ! isset( $wp_roles ) ) {
120
+		if (class_exists('WP_Roles')) {
121
+			if ( ! isset($wp_roles)) {
122 122
 				$wp_roles = new WP_Roles();
123 123
 			}
124 124
 		}
125 125
 
126
-		if ( is_object( $wp_roles ) ) {
127
-			$wp_roles->add_cap( 'give_manager', 'view_give_reports' );
128
-			$wp_roles->add_cap( 'give_manager', 'view_give_sensitive_data' );
129
-			$wp_roles->add_cap( 'give_manager', 'export_give_reports' );
130
-			$wp_roles->add_cap( 'give_manager', 'manage_give_settings' );
126
+		if (is_object($wp_roles)) {
127
+			$wp_roles->add_cap('give_manager', 'view_give_reports');
128
+			$wp_roles->add_cap('give_manager', 'view_give_sensitive_data');
129
+			$wp_roles->add_cap('give_manager', 'export_give_reports');
130
+			$wp_roles->add_cap('give_manager', 'manage_give_settings');
131 131
 
132
-			$wp_roles->add_cap( 'administrator', 'view_give_reports' );
133
-			$wp_roles->add_cap( 'administrator', 'view_give_sensitive_data' );
134
-			$wp_roles->add_cap( 'administrator', 'export_give_reports' );
135
-			$wp_roles->add_cap( 'administrator', 'manage_give_settings' );
136
-			$wp_roles->add_cap( 'administrator', 'view_give_payments' );
132
+			$wp_roles->add_cap('administrator', 'view_give_reports');
133
+			$wp_roles->add_cap('administrator', 'view_give_sensitive_data');
134
+			$wp_roles->add_cap('administrator', 'export_give_reports');
135
+			$wp_roles->add_cap('administrator', 'manage_give_settings');
136
+			$wp_roles->add_cap('administrator', 'view_give_payments');
137 137
 
138 138
 			// Add the main post type capabilities.
139 139
 			$capabilities = $this->get_core_caps();
140
-			foreach ( $capabilities as $cap_group ) {
141
-				foreach ( $cap_group as $cap ) {
142
-					$wp_roles->add_cap( 'administrator', $cap );
143
-					$wp_roles->add_cap( 'give_manager', $cap );
144
-					$wp_roles->add_cap( 'give_worker', $cap );
140
+			foreach ($capabilities as $cap_group) {
141
+				foreach ($cap_group as $cap) {
142
+					$wp_roles->add_cap('administrator', $cap);
143
+					$wp_roles->add_cap('give_manager', $cap);
144
+					$wp_roles->add_cap('give_worker', $cap);
145 145
 				}
146 146
 			}
147 147
 
148 148
 			// Add Capabilities to Give Accountant User Role.
149
-			$wp_roles->add_cap( 'give_accountant', 'edit_give_forms' );
150
-			$wp_roles->add_cap( 'give_accountant', 'read_private_give_forms' );
151
-			$wp_roles->add_cap( 'give_accountant', 'view_give_reports' );
152
-			$wp_roles->add_cap( 'give_accountant', 'export_give_reports' );
153
-			$wp_roles->add_cap( 'give_accountant', 'edit_give_payments' );
154
-			$wp_roles->add_cap( 'give_accountant', 'view_give_payments' );
149
+			$wp_roles->add_cap('give_accountant', 'edit_give_forms');
150
+			$wp_roles->add_cap('give_accountant', 'read_private_give_forms');
151
+			$wp_roles->add_cap('give_accountant', 'view_give_reports');
152
+			$wp_roles->add_cap('give_accountant', 'export_give_reports');
153
+			$wp_roles->add_cap('give_accountant', 'edit_give_payments');
154
+			$wp_roles->add_cap('give_accountant', 'view_give_payments');
155 155
 
156 156
 		}
157 157
 	}
@@ -169,10 +169,10 @@  discard block
 block discarded – undo
169 169
 	public function get_core_caps() {
170 170
 		$capabilities = array();
171 171
 
172
-		$capability_types = array( 'give_form', 'give_payment' );
172
+		$capability_types = array('give_form', 'give_payment');
173 173
 
174
-		foreach ( $capability_types as $capability_type ) {
175
-			$capabilities[ $capability_type ] = array(
174
+		foreach ($capability_types as $capability_type) {
175
+			$capabilities[$capability_type] = array(
176 176
 				// Post type.
177 177
 				"edit_{$capability_type}",
178 178
 				"read_{$capability_type}",
@@ -218,22 +218,22 @@  discard block
 block discarded – undo
218 218
 	 *
219 219
 	 * @return array  $caps    Meta capabilities.
220 220
 	 */
221
-	public function meta_caps( $caps, $cap, $user_id, $args ) {
221
+	public function meta_caps($caps, $cap, $user_id, $args) {
222 222
 
223
-		switch ( $cap ) {
223
+		switch ($cap) {
224 224
 
225 225
 			case 'view_give_form_stats' :
226 226
 
227
-				if ( empty( $args[0] ) ) {
227
+				if (empty($args[0])) {
228 228
 					break;
229 229
 				}
230 230
 
231
-				$form = get_post( $args[0] );
232
-				if ( empty( $form ) ) {
231
+				$form = get_post($args[0]);
232
+				if (empty($form)) {
233 233
 					break;
234 234
 				}
235 235
 
236
-				if ( user_can( $user_id, 'view_give_reports' ) || $user_id == $form->post_author ) {
236
+				if (user_can($user_id, 'view_give_reports') || $user_id == $form->post_author) {
237 237
 					$caps = array();
238 238
 				}
239 239
 
@@ -260,44 +260,44 @@  discard block
 block discarded – undo
260 260
 
261 261
 		global $wp_roles;
262 262
 
263
-		if ( class_exists( 'WP_Roles' ) ) {
264
-			if ( ! isset( $wp_roles ) ) {
263
+		if (class_exists('WP_Roles')) {
264
+			if ( ! isset($wp_roles)) {
265 265
 				$wp_roles = new WP_Roles();
266 266
 			}
267 267
 		}
268 268
 
269
-		if ( is_object( $wp_roles ) ) {
269
+		if (is_object($wp_roles)) {
270 270
 			// Give Manager Capabilities.
271
-			$wp_roles->remove_cap( 'give_manager', 'view_give_reports' );
272
-			$wp_roles->remove_cap( 'give_manager', 'view_give_sensitive_data' );
273
-			$wp_roles->remove_cap( 'give_manager', 'export_give_reports' );
274
-			$wp_roles->remove_cap( 'give_manager', 'manage_give_settings' );
271
+			$wp_roles->remove_cap('give_manager', 'view_give_reports');
272
+			$wp_roles->remove_cap('give_manager', 'view_give_sensitive_data');
273
+			$wp_roles->remove_cap('give_manager', 'export_give_reports');
274
+			$wp_roles->remove_cap('give_manager', 'manage_give_settings');
275 275
 
276 276
 			// Site Administrator Capabilities.
277
-			$wp_roles->remove_cap( 'administrator', 'view_give_reports' );
278
-			$wp_roles->remove_cap( 'administrator', 'view_give_sensitive_data' );
279
-			$wp_roles->remove_cap( 'administrator', 'export_give_reports' );
280
-			$wp_roles->remove_cap( 'administrator', 'manage_give_settings' );
281
-			$wp_roles->remove_cap( 'administrator', 'view_give_payments' );
277
+			$wp_roles->remove_cap('administrator', 'view_give_reports');
278
+			$wp_roles->remove_cap('administrator', 'view_give_sensitive_data');
279
+			$wp_roles->remove_cap('administrator', 'export_give_reports');
280
+			$wp_roles->remove_cap('administrator', 'manage_give_settings');
281
+			$wp_roles->remove_cap('administrator', 'view_give_payments');
282 282
 
283 283
 			// Remove the Main Post Type Capabilities.
284 284
 			$capabilities = $this->get_core_caps();
285 285
 
286
-			foreach ( $capabilities as $cap_group ) {
287
-				foreach ( $cap_group as $cap ) {
288
-					$wp_roles->remove_cap( 'give_manager', $cap );
289
-					$wp_roles->remove_cap( 'administrator', $cap );
290
-					$wp_roles->remove_cap( 'give_worker', $cap );
286
+			foreach ($capabilities as $cap_group) {
287
+				foreach ($cap_group as $cap) {
288
+					$wp_roles->remove_cap('give_manager', $cap);
289
+					$wp_roles->remove_cap('administrator', $cap);
290
+					$wp_roles->remove_cap('give_worker', $cap);
291 291
 				}
292 292
 			}
293 293
 
294 294
 			// Remove Capabilities from Give Accountant User Role.
295
-			$wp_roles->remove_cap( 'give_accountant', 'edit_give_forms' );
296
-			$wp_roles->remove_cap( 'give_accountant', 'read_private_give_forms' );
297
-			$wp_roles->remove_cap( 'give_accountant', 'view_give_reports' );
298
-			$wp_roles->remove_cap( 'give_accountant', 'export_give_reports' );
299
-			$wp_roles->remove_cap( 'give_accountant', 'edit_give_payments' );
300
-			$wp_roles->remove_cap( 'give_accountant', 'view_give_payments' );
295
+			$wp_roles->remove_cap('give_accountant', 'edit_give_forms');
296
+			$wp_roles->remove_cap('give_accountant', 'read_private_give_forms');
297
+			$wp_roles->remove_cap('give_accountant', 'view_give_reports');
298
+			$wp_roles->remove_cap('give_accountant', 'export_give_reports');
299
+			$wp_roles->remove_cap('give_accountant', 'edit_give_payments');
300
+			$wp_roles->remove_cap('give_accountant', 'view_give_payments');
301 301
 
302 302
 		}
303 303
 	}
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 		$current_user = wp_get_current_user();
318 318
 
319 319
 		// If user with "Give Accountant" user role is logged-in .
320
-		if ( 0 !== $current_user->ID && in_array( 'give_accountant', (array) $current_user->roles, true ) ) {
320
+		if (0 !== $current_user->ID && in_array('give_accountant', (array) $current_user->roles, true)) {
321 321
 
322 322
 			// Return false, means no prevention.
323 323
 			return false;
Please login to merge, or discard this patch.
includes/class-give-cli-commands.php 1 patch
Spacing   +202 added lines, -202 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 // Exit if accessed directly.
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if ( ! defined('ABSPATH')) {
11 11
 	exit;
12 12
 }
13 13
 
14 14
 // Add give command.
15
-WP_CLI::add_command( 'give', 'GIVE_CLI_COMMAND' );
15
+WP_CLI::add_command('give', 'GIVE_CLI_COMMAND');
16 16
 
17 17
 
18 18
 /**
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
 	 *
77 77
 	 * @subcommand    logo
78 78
 	 */
79
-	public function ascii( $args, $assoc_args ) {
80
-		WP_CLI::log( file_get_contents( GIVE_PLUGIN_DIR . 'assets/images/give-ascii-logo.txt' ) );
79
+	public function ascii($args, $assoc_args) {
80
+		WP_CLI::log(file_get_contents(GIVE_PLUGIN_DIR.'assets/images/give-ascii-logo.txt'));
81 81
 	}
82 82
 
83 83
 
@@ -102,54 +102,54 @@  discard block
 block discarded – undo
102 102
 	 *
103 103
 	 * @subcommand    details
104 104
 	 */
105
-	public function details( $args, $assoc_args ) {
105
+	public function details($args, $assoc_args) {
106 106
 
107 107
 		/**
108 108
 		 * Plugin Information
109 109
 		 */
110
-		WP_CLI::log( $this->color_message( __( 'Give Version: ', 'give' ) ) . GIVE_VERSION );
110
+		WP_CLI::log($this->color_message(__('Give Version: ', 'give')).GIVE_VERSION);
111 111
 
112 112
 		/**
113 113
 		 * General Information.
114 114
 		 */
115
-		WP_CLI::log( "\n####   " . $this->color_message( __( 'General information', 'give' ) ) . '   ####' );
115
+		WP_CLI::log("\n####   ".$this->color_message(__('General information', 'give')).'   ####');
116 116
 
117
-		$success_page = give_get_option( 'success_page' );
118
-		$failure_page = give_get_option( 'failure_page' );
119
-		$history_page = give_get_option( 'history_page' );
117
+		$success_page = give_get_option('success_page');
118
+		$failure_page = give_get_option('failure_page');
119
+		$history_page = give_get_option('history_page');
120 120
 
121
-		WP_CLI::log( $this->color_message( sprintf( __( 'Success Page: ', 'give' ) ) ) . ( $success_page ? "[{$success_page}] " . get_permalink( $success_page ) : __( 'Not Set', 'give' ) ) );
122
-		WP_CLI::log( $this->color_message( __( 'Failed Donation Page: ', 'give' ) ) . ( $failure_page ? "[{$failure_page}] " . get_permalink( $failure_page ) : __( 'Not Set', 'give' ) ) );
123
-		WP_CLI::log( $this->color_message( __( 'Donation History Page: ', 'give' ) ) . ( $history_page ? "[{$history_page}] " . get_permalink( $history_page ) : __( 'Not Set', 'give' ) ) );
124
-		WP_CLI::log( $this->color_message( __( 'Country: ', 'give' ) ) . give_get_country() );
121
+		WP_CLI::log($this->color_message(sprintf(__('Success Page: ', 'give'))).($success_page ? "[{$success_page}] ".get_permalink($success_page) : __('Not Set', 'give')));
122
+		WP_CLI::log($this->color_message(__('Failed Donation Page: ', 'give')).($failure_page ? "[{$failure_page}] ".get_permalink($failure_page) : __('Not Set', 'give')));
123
+		WP_CLI::log($this->color_message(__('Donation History Page: ', 'give')).($history_page ? "[{$history_page}] ".get_permalink($history_page) : __('Not Set', 'give')));
124
+		WP_CLI::log($this->color_message(__('Country: ', 'give')).give_get_country());
125 125
 
126 126
 		/**
127 127
 		 * Currency Information.
128 128
 		 */
129
-		$default_gateway = give_get_option( 'default_gateway' );
129
+		$default_gateway = give_get_option('default_gateway');
130 130
 
131
-		WP_CLI::log( "\n####   " . $this->color_message( __( 'Currency Information', 'give' ) ) . '   ####' );
131
+		WP_CLI::log("\n####   ".$this->color_message(__('Currency Information', 'give')).'   ####');
132 132
 
133
-		WP_CLI::log( $this->color_message( __( 'Currency: ', 'give' ), give_get_currency() ) );
134
-		WP_CLI::log( $this->color_message( __( 'Currency Position: ', 'give' ), give_get_currency_position() ) );
135
-		WP_CLI::log( $this->color_message( __( 'Thousand Separator: ', 'give' ), give_get_price_thousand_separator() ) );
136
-		WP_CLI::log( $this->color_message( __( 'Decimal Separator: ', 'give' ), give_get_price_decimal_separator() ) );
137
-		WP_CLI::log( $this->color_message( __( 'Number of Decimals: ', 'give' ), give_get_price_decimals() ) );
138
-		WP_CLI::log( $this->color_message( __( 'Test Mode: ', 'give' ), ( give_get_option( 'test_mode' ) ? __( 'Yes', 'give' ) : __( 'No', 'give' ) ) ) );
139
-		WP_CLI::log( $this->color_message( __( 'Default Gateway: ', 'give' ), ( $default_gateway ? $default_gateway : __( 'Not Set', 'give' ) ) ) );
133
+		WP_CLI::log($this->color_message(__('Currency: ', 'give'), give_get_currency()));
134
+		WP_CLI::log($this->color_message(__('Currency Position: ', 'give'), give_get_currency_position()));
135
+		WP_CLI::log($this->color_message(__('Thousand Separator: ', 'give'), give_get_price_thousand_separator()));
136
+		WP_CLI::log($this->color_message(__('Decimal Separator: ', 'give'), give_get_price_decimal_separator()));
137
+		WP_CLI::log($this->color_message(__('Number of Decimals: ', 'give'), give_get_price_decimals()));
138
+		WP_CLI::log($this->color_message(__('Test Mode: ', 'give'), (give_get_option('test_mode') ? __('Yes', 'give') : __('No', 'give'))));
139
+		WP_CLI::log($this->color_message(__('Default Gateway: ', 'give'), ($default_gateway ? $default_gateway : __('Not Set', 'give'))));
140 140
 
141 141
 		// Payment gateways Information.
142
-		$gateways = give_get_ordered_payment_gateways( give_get_payment_gateways() );
143
-		WP_CLI::log( $this->color_message( __( 'Enabled Gateways: ', 'give' ) ) );
142
+		$gateways = give_get_ordered_payment_gateways(give_get_payment_gateways());
143
+		WP_CLI::log($this->color_message(__('Enabled Gateways: ', 'give')));
144 144
 
145
-		if ( ! empty( $gateways ) ) {
145
+		if ( ! empty($gateways)) {
146 146
 			self::$counter = 1;
147
-			foreach ( $gateways as $gateway ) {
148
-				WP_CLI::log( '  ' . $this->color_message( self::$counter, $gateway['admin_label'] ) );
149
-				self::$counter ++;
147
+			foreach ($gateways as $gateway) {
148
+				WP_CLI::log('  '.$this->color_message(self::$counter, $gateway['admin_label']));
149
+				self::$counter++;
150 150
 			}
151 151
 		} else {
152
-			WP_CLI::log( __( 'Not any payment gateways found', 'give' ) );
152
+			WP_CLI::log(__('Not any payment gateways found', 'give'));
153 153
 		}
154 154
 	}
155 155
 
@@ -181,15 +181,15 @@  discard block
 block discarded – undo
181 181
 	 *
182 182
 	 * @subcommand    forms
183 183
 	 */
184
-	public function forms( $args, $assoc_args ) {
184
+	public function forms($args, $assoc_args) {
185 185
 		global $wp_query;
186
-		$form_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false;
187
-		$number  = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? absint( $assoc_args['number'] ) : 10;
186
+		$form_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : false;
187
+		$number  = isset($assoc_args) && array_key_exists('number', $assoc_args) ? absint($assoc_args['number']) : 10;
188 188
 		$start   = time();
189 189
 
190 190
 		// Cache previous number query var.
191 191
 		$is_set_number = $cache_per_page = false;
192
-		if ( isset( $wp_query->query_vars['number'] ) ) {
192
+		if (isset($wp_query->query_vars['number'])) {
193 193
 			$cache_per_page = $wp_query->query_vars['number'];
194 194
 			$is_set_number  = true;
195 195
 		}
@@ -198,22 +198,22 @@  discard block
 block discarded – undo
198 198
 		$wp_query->query_vars['number'] = $number;
199 199
 
200 200
 		// Get forms.
201
-		$forms = $form_id ? $this->api->get_forms( $form_id ) : $this->api->get_forms();
201
+		$forms = $form_id ? $this->api->get_forms($form_id) : $this->api->get_forms();
202 202
 
203 203
 		// Reset number query var.
204
-		if ( $is_set_number ) {
204
+		if ($is_set_number) {
205 205
 			$wp_query->query_vars['number'] = $cache_per_page;
206 206
 		}
207 207
 
208 208
 		// Bailout.
209
-		if ( array_key_exists( 'error', $forms ) ) {
209
+		if (array_key_exists('error', $forms)) {
210 210
 
211
-			WP_CLI::warning( $forms['error'] );
211
+			WP_CLI::warning($forms['error']);
212 212
 
213 213
 			return;
214
-		} elseif ( empty( $forms['forms'] ) ) {
214
+		} elseif (empty($forms['forms'])) {
215 215
 
216
-			WP_CLI::error( __( 'No forms found.', 'give' ) );
216
+			WP_CLI::error(__('No forms found.', 'give'));
217 217
 
218 218
 			return;
219 219
 		}
@@ -221,25 +221,25 @@  discard block
 block discarded – undo
221 221
 		// Param to check if form typeis already showed or not.
222 222
 		$is_show_form_type = false;
223 223
 
224
-		if ( 1 === count( $forms ) && $form_id ) {
224
+		if (1 === count($forms) && $form_id) {
225 225
 			// Show single form.
226
-			foreach ( $forms['forms'][0] as $key => $info ) {
227
-				switch ( $key ) {
226
+			foreach ($forms['forms'][0] as $key => $info) {
227
+				switch ($key) {
228 228
 					case 'stats':
229
-						$this->color_main_heading( ucfirst( $key ) );
229
+						$this->color_main_heading(ucfirst($key));
230 230
 
231
-						foreach ( $info as $heading => $data ) {
232
-							$this->color_sub_heading( ucfirst( $heading ) );
233
-							switch ( $heading ) {
231
+						foreach ($info as $heading => $data) {
232
+							$this->color_sub_heading(ucfirst($heading));
233
+							switch ($heading) {
234 234
 								default:
235
-									foreach ( $data as $subheading => $subdata ) {
235
+									foreach ($data as $subheading => $subdata) {
236 236
 
237
-										switch ( $subheading ) {
237
+										switch ($subheading) {
238 238
 											case 'earnings':
239
-												WP_CLI::log( $this->color_message( $subheading . ': ', give_currency_filter( $subdata ) ) );
239
+												WP_CLI::log($this->color_message($subheading.': ', give_currency_filter($subdata)));
240 240
 												break;
241 241
 											default:
242
-												WP_CLI::log( $this->color_message( $subheading . ': ', $subdata ) );
242
+												WP_CLI::log($this->color_message($subheading.': ', $subdata));
243 243
 										}
244 244
 									}
245 245
 							}
@@ -249,26 +249,26 @@  discard block
 block discarded – undo
249 249
 					case 'pricing':
250 250
 					case 'info':
251 251
 					default:
252
-						$this->color_main_heading( ucfirst( $key ) );
252
+						$this->color_main_heading(ucfirst($key));
253 253
 
254 254
 						// Show form type.
255
-						if ( ! $is_show_form_type ) {
256
-							$form              = new Give_Donate_Form( $form_id );
255
+						if ( ! $is_show_form_type) {
256
+							$form              = new Give_Donate_Form($form_id);
257 257
 							$is_show_form_type = true;
258 258
 
259
-							WP_CLI::log( $this->color_message( __( 'form type', 'give' ), $form->get_type() ) );
259
+							WP_CLI::log($this->color_message(__('form type', 'give'), $form->get_type()));
260 260
 						}
261 261
 
262
-						foreach ( $info as $heading => $data ) {
262
+						foreach ($info as $heading => $data) {
263 263
 
264
-							switch ( $heading ) {
264
+							switch ($heading) {
265 265
 								case 'id':
266
-									WP_CLI::log( $this->color_message( $heading, $data ) );
266
+									WP_CLI::log($this->color_message($heading, $data));
267 267
 									break;
268 268
 
269 269
 								default:
270
-									$data = empty( $data ) ? __( 'Not set', 'give' ) : $data;
271
-									WP_CLI::log( $this->color_message( $heading, $data ) );
270
+									$data = empty($data) ? __('Not set', 'give') : $data;
271
+									WP_CLI::log($this->color_message($heading, $data));
272 272
 							}
273 273
 						}
274 274
 				}// End switch().
@@ -279,37 +279,37 @@  discard block
 block discarded – undo
279 279
 			$is_table_first_row_set = false;
280 280
 			$table_column_count     = 0;
281 281
 
282
-			WP_CLI::line( $this->color_message( sprintf( __( '%d donation forms found', 'give' ), count( $forms['forms'] ) ), '', false ) );
282
+			WP_CLI::line($this->color_message(sprintf(__('%d donation forms found', 'give'), count($forms['forms'])), '', false));
283 283
 
284
-			foreach ( $forms['forms'] as $index => $form_data ) {
284
+			foreach ($forms['forms'] as $index => $form_data) {
285 285
 
286 286
 				// Default table data.
287 287
 				$table_first_row = array();
288 288
 				$table_row       = array();
289 289
 
290
-				foreach ( $form_data['info'] as $key => $form ) {
290
+				foreach ($form_data['info'] as $key => $form) {
291 291
 
292 292
 					// Do not show thumbnail, content and link in table.
293
-					if ( in_array( $key, array( 'content', 'thumbnail', 'link' ), true ) ) {
293
+					if (in_array($key, array('content', 'thumbnail', 'link'), true)) {
294 294
 						continue;
295 295
 					}
296 296
 
297
-					if ( ! $is_table_first_row_set ) {
297
+					if ( ! $is_table_first_row_set) {
298 298
 						$table_first_row[] = $key;
299 299
 					}
300 300
 
301 301
 					$table_row[] = $form;
302 302
 
303
-					if ( 'status' === $key ) {
303
+					if ('status' === $key) {
304 304
 						// First array item will be an form id in our case.
305
-						$form = new Give_Donate_Form( absint( $table_row[0] ) );
305
+						$form = new Give_Donate_Form(absint($table_row[0]));
306 306
 
307 307
 						$table_row[] = $form->get_type();
308 308
 					}
309 309
 				}
310 310
 
311 311
 				// Set table first row.
312
-				if ( ! $is_table_first_row_set ) {
312
+				if ( ! $is_table_first_row_set) {
313 313
 
314 314
 					// Add extra column to table.
315 315
 					$table_first_row[] = 'type';
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 				$table_data[] = $table_row;
323 323
 			}// End foreach().
324 324
 
325
-			$this->display_table( $table_data );
325
+			$this->display_table($table_data);
326 326
 		}// End if().
327 327
 	}
328 328
 
@@ -375,59 +375,59 @@  discard block
 block discarded – undo
375 375
 	 *
376 376
 	 * @subcommand    donors
377 377
 	 */
378
-	public function donors( $args, $assoc_args ) {
378
+	public function donors($args, $assoc_args) {
379 379
 		global $wp_query;
380
-		$donor_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false;
381
-		$email    = isset( $assoc_args ) && array_key_exists( 'email', $assoc_args ) ? $assoc_args['email'] : false;
382
-		$name     = isset( $assoc_args ) && array_key_exists( 'name', $assoc_args ) ? $assoc_args['name'] : '';
383
-		$create   = isset( $assoc_args ) && array_key_exists( 'create', $assoc_args ) ? $assoc_args['create'] : false;
384
-		$number   = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10;
385
-		$form_id  = isset( $assoc_args ) && array_key_exists( 'form-id', $assoc_args ) ? $assoc_args['form-id'] : 0;
386
-		$format   = isset( $assoc_args ) && array_key_exists( 'format', $assoc_args ) ? $assoc_args['format'] : 'table';
380
+		$donor_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : false;
381
+		$email    = isset($assoc_args) && array_key_exists('email', $assoc_args) ? $assoc_args['email'] : false;
382
+		$name     = isset($assoc_args) && array_key_exists('name', $assoc_args) ? $assoc_args['name'] : '';
383
+		$create   = isset($assoc_args) && array_key_exists('create', $assoc_args) ? $assoc_args['create'] : false;
384
+		$number   = isset($assoc_args) && array_key_exists('number', $assoc_args) ? $assoc_args['number'] : 10;
385
+		$form_id  = isset($assoc_args) && array_key_exists('form-id', $assoc_args) ? $assoc_args['form-id'] : 0;
386
+		$format   = isset($assoc_args) && array_key_exists('format', $assoc_args) ? $assoc_args['format'] : 'table';
387 387
 		$start    = time();
388 388
 
389
-		if ( $create ) {
390
-			if ( 80 < $create ) {
391
-				WP_CLI::warning( 'Currently we can only generate maximum 80 donors.', 'give' );
389
+		if ($create) {
390
+			if (80 < $create) {
391
+				WP_CLI::warning('Currently we can only generate maximum 80 donors.', 'give');
392 392
 				$create = 80;
393 393
 			}
394 394
 
395 395
 			$number = 1;
396 396
 
397
-			if ( isset( $assoc_args['email'] ) && ! is_email( $email ) ) {
398
-				WP_CLI::warning( 'Wrong email address provided.', 'give' );
397
+			if (isset($assoc_args['email']) && ! is_email($email)) {
398
+				WP_CLI::warning('Wrong email address provided.', 'give');
399 399
 
400 400
 				return;
401 401
 			}
402 402
 
403 403
 			// Create one or more donors.
404
-			if ( ! $email ) {
404
+			if ( ! $email) {
405 405
 				// If no email is specified, look to see if we are generating arbitrary donor accounts.
406
-				$number = is_numeric( $create ) ? absint( $create ) : 1;
406
+				$number = is_numeric($create) ? absint($create) : 1;
407 407
 			}
408 408
 
409
-			for ( $i = 0; $i < $number; $i ++ ) {
409
+			for ($i = 0; $i < $number; $i++) {
410 410
 				$name  = $name ? $name : $this->get_random_name();
411
-				$email = $email ? $email : $this->get_random_email( $name );
411
+				$email = $email ? $email : $this->get_random_email($name);
412 412
 
413 413
 				$args = array(
414 414
 					'email' => $email,
415 415
 					'name'  => $name,
416 416
 				);
417 417
 
418
-				$donor_id = Give()->donors->add( $args );
418
+				$donor_id = Give()->donors->add($args);
419 419
 
420
-				if ( $donor_id ) {
421
-					WP_CLI::line( $this->color_message( sprintf( __( 'Donor #%d created successfully', 'give' ), $donor_id ) ) );
420
+				if ($donor_id) {
421
+					WP_CLI::line($this->color_message(sprintf(__('Donor #%d created successfully', 'give'), $donor_id)));
422 422
 				} else {
423
-					WP_CLI::error( __( 'Failed to create donor', 'give' ) );
423
+					WP_CLI::error(__('Failed to create donor', 'give'));
424 424
 				}
425 425
 
426 426
 				// Reset email and name to false so it is generated on the next loop (if creating donors).
427 427
 				$email = $name = false;
428 428
 			}
429 429
 
430
-			WP_CLI::line( $this->color_message( sprintf( __( '%1$d donors created in %2$d seconds', 'give' ), $number, time() - $start ) ) );
430
+			WP_CLI::line($this->color_message(sprintf(__('%1$d donors created in %2$d seconds', 'give'), $number, time() - $start)));
431 431
 
432 432
 		} else {
433 433
 			// Counter.
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
 			 */
442 442
 			// Cache previous number query var.
443 443
 			$is_set_number = $cache_per_page = false;
444
-			if ( isset( $wp_query->query_vars['number'] ) ) {
444
+			if (isset($wp_query->query_vars['number'])) {
445 445
 				$cache_per_page = $wp_query->query_vars['number'];
446 446
 				$is_set_number  = true;
447 447
 			}
@@ -450,24 +450,24 @@  discard block
 block discarded – undo
450 450
 			$wp_query->query_vars['number'] = $number;
451 451
 
452 452
 			// Get donors.
453
-			if ( $form_id ) {
453
+			if ($form_id) {
454 454
 				// @TODO: Allow user to get a list of donors by donation status.
455
-				$donors = $this->get_donors_by_form_id( $form_id );
455
+				$donors = $this->get_donors_by_form_id($form_id);
456 456
 			} else {
457
-				$donors = $this->api->get_donors( $search );
457
+				$donors = $this->api->get_donors($search);
458 458
 			}
459 459
 
460 460
 			// Reset number query var.
461
-			if ( $is_set_number ) {
461
+			if ($is_set_number) {
462 462
 				$wp_query->query_vars['number'] = $cache_per_page;
463 463
 			}
464 464
 
465
-			if ( isset( $donors['error'] ) ) {
466
-				WP_CLI::error( $donors['error'] );
465
+			if (isset($donors['error'])) {
466
+				WP_CLI::error($donors['error']);
467 467
 			}
468 468
 
469
-			if ( empty( $donors ) ) {
470
-				WP_CLI::error( __( 'No donors found.', 'give' ) );
469
+			if (empty($donors)) {
470
+				WP_CLI::error(__('No donors found.', 'give'));
471 471
 
472 472
 				return;
473 473
 			}
@@ -475,24 +475,24 @@  discard block
 block discarded – undo
475 475
 			$table_data             = array();
476 476
 			$is_table_first_row_set = false;
477 477
 
478
-			foreach ( $donors['donors'] as $donor_data ) {
478
+			foreach ($donors['donors'] as $donor_data) {
479 479
 				// Set default table row data.
480
-				$table_first_row = array( __( 's_no', 'give' ) );
481
-				$table_row       = array( self::$counter );
480
+				$table_first_row = array(__('s_no', 'give'));
481
+				$table_row       = array(self::$counter);
482 482
 
483
-				foreach ( $donor_data as $key => $donor ) {
484
-					switch ( $key ) {
483
+				foreach ($donor_data as $key => $donor) {
484
+					switch ($key) {
485 485
 						case 'stats':
486
-							foreach ( $donor as $heading => $data ) {
486
+							foreach ($donor as $heading => $data) {
487 487
 
488 488
 								// Get first row.
489
-								if ( ! $is_table_first_row_set ) {
489
+								if ( ! $is_table_first_row_set) {
490 490
 									$table_first_row[] = $heading;
491 491
 								}
492 492
 
493
-								switch ( $heading ) {
493
+								switch ($heading) {
494 494
 									case 'total_spent':
495
-										$table_row[] = give_currency_filter( $data );
495
+										$table_row[] = give_currency_filter($data);
496 496
 										break;
497 497
 
498 498
 									default:
@@ -503,10 +503,10 @@  discard block
 block discarded – undo
503 503
 
504 504
 						case 'info':
505 505
 						default:
506
-							foreach ( $donor as $heading => $data ) {
506
+							foreach ($donor as $heading => $data) {
507 507
 
508 508
 								// Get first row.
509
-								if ( ! $is_table_first_row_set ) {
509
+								if ( ! $is_table_first_row_set) {
510 510
 									$table_first_row[] = $heading;
511 511
 								}
512 512
 
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
 				}
517 517
 
518 518
 				// Add first row data to table data.
519
-				if ( ! $is_table_first_row_set ) {
519
+				if ( ! $is_table_first_row_set) {
520 520
 					$table_data[]           = $table_first_row;
521 521
 					$is_table_first_row_set = true;
522 522
 				}
@@ -525,44 +525,44 @@  discard block
 block discarded – undo
525 525
 				$table_data[] = $table_row;
526 526
 
527 527
 				// Increase counter.
528
-				self::$counter ++;
528
+				self::$counter++;
529 529
 			}// End foreach().
530 530
 
531
-			switch ( $format ) {
531
+			switch ($format) {
532 532
 				case 'json':
533 533
 					$table_column_name = $table_data[0];
534
-					unset( $table_data[0] );
534
+					unset($table_data[0]);
535 535
 
536 536
 					$new_table_data = array();
537
-					foreach ( $table_data as $index => $data ) {
538
-						foreach ( $data as $key => $value ) {
539
-							$new_table_data[ $index ][ $table_column_name[ $key ] ] = $value;
537
+					foreach ($table_data as $index => $data) {
538
+						foreach ($data as $key => $value) {
539
+							$new_table_data[$index][$table_column_name[$key]] = $value;
540 540
 						}
541 541
 					}
542 542
 
543
-					WP_CLI::log( json_encode( $new_table_data ) );
543
+					WP_CLI::log(json_encode($new_table_data));
544 544
 					break;
545 545
 
546 546
 				case 'csv':
547
-					$file_path = trailingslashit( WP_CONTENT_DIR ) . 'uploads/give_donors_' . date( 'Y_m_d_s', current_time( 'timestamp' ) ) . '.csv';
548
-					$fp        = fopen( $file_path, 'w' );
547
+					$file_path = trailingslashit(WP_CONTENT_DIR).'uploads/give_donors_'.date('Y_m_d_s', current_time('timestamp')).'.csv';
548
+					$fp        = fopen($file_path, 'w');
549 549
 
550
-					if ( is_writable( $file_path ) ) {
551
-						foreach ( $table_data as $fields ) {
552
-							fputcsv( $fp, $fields );
550
+					if (is_writable($file_path)) {
551
+						foreach ($table_data as $fields) {
552
+							fputcsv($fp, $fields);
553 553
 						}
554 554
 
555
-						fclose( $fp );
555
+						fclose($fp);
556 556
 
557
-						WP_CLI::success( "Donors list csv created successfully: {$file_path}" );
557
+						WP_CLI::success("Donors list csv created successfully: {$file_path}");
558 558
 					} else {
559
-						WP_CLI::warning( "Unable to create donors list csv file: {$file_path} (May folder do not have write permission)" );
559
+						WP_CLI::warning("Unable to create donors list csv file: {$file_path} (May folder do not have write permission)");
560 560
 					}
561 561
 
562 562
 					break;
563 563
 
564 564
 				default:
565
-					$this->display_table( $table_data );
565
+					$this->display_table($table_data);
566 566
 			}// End switch().
567 567
 		}// End if().
568 568
 	}
@@ -592,13 +592,13 @@  discard block
 block discarded – undo
592 592
 	 *
593 593
 	 * @subcommand    donations
594 594
 	 */
595
-	public function donations( $args, $assoc_args ) {
595
+	public function donations($args, $assoc_args) {
596 596
 		global $wp_query;
597
-		$number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10;
597
+		$number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? $assoc_args['number'] : 10;
598 598
 
599 599
 		// Cache previous number query var.
600 600
 		$is_set_number = $cache_per_page = false;
601
-		if ( isset( $wp_query->query_vars['number'] ) ) {
601
+		if (isset($wp_query->query_vars['number'])) {
602 602
 			$cache_per_page = $wp_query->query_vars['number'];
603 603
 			$is_set_number  = true;
604 604
 		}
@@ -610,46 +610,46 @@  discard block
 block discarded – undo
610 610
 		$donations = $this->api->get_recent_donations();
611 611
 
612 612
 		// Reset number query var.
613
-		if ( $is_set_number ) {
613
+		if ($is_set_number) {
614 614
 			$wp_query->query_vars['number'] = $cache_per_page;
615 615
 		}
616 616
 
617
-		if ( empty( $donations ) ) {
618
-			WP_CLI::error( __( 'No donations found.', 'give' ) );
617
+		if (empty($donations)) {
618
+			WP_CLI::error(__('No donations found.', 'give'));
619 619
 
620 620
 			return;
621 621
 		}
622 622
 
623 623
 		self::$counter = 1;
624 624
 
625
-		foreach ( $donations['donations'] as $key => $donation ) {
626
-			$this->color_main_heading( sprintf( __( '%1$s. Donation #%2$s', 'give' ), self::$counter, $donation['ID'] ), 'Y' );
627
-			self::$counter ++;
625
+		foreach ($donations['donations'] as $key => $donation) {
626
+			$this->color_main_heading(sprintf(__('%1$s. Donation #%2$s', 'give'), self::$counter, $donation['ID']), 'Y');
627
+			self::$counter++;
628 628
 
629
-			foreach ( $donation as $column => $data ) {
629
+			foreach ($donation as $column => $data) {
630 630
 
631
-				if ( is_array( $data ) ) {
632
-					$this->color_sub_heading( $column );
633
-					foreach ( $data as $subcolumn => $subdata ) {
631
+				if (is_array($data)) {
632
+					$this->color_sub_heading($column);
633
+					foreach ($data as $subcolumn => $subdata) {
634 634
 
635 635
 						// Decode html codes.
636
-						switch ( $subcolumn ) {
636
+						switch ($subcolumn) {
637 637
 							case 'name':
638
-								$subdata = html_entity_decode( $subdata );
638
+								$subdata = html_entity_decode($subdata);
639 639
 								break;
640 640
 						}
641 641
 
642 642
 						// @TODO Check if multi dimension array information is importent to show or not. For example inside donation array we have array for fees data inside payment meta.
643
-						if ( is_array( $subdata ) ) {
643
+						if (is_array($subdata)) {
644 644
 							continue;
645 645
 						}
646 646
 
647
-						WP_CLI::log( $this->color_message( $subcolumn, $subdata ) );
647
+						WP_CLI::log($this->color_message($subcolumn, $subdata));
648 648
 					}
649 649
 					continue;
650 650
 				}
651 651
 
652
-				WP_CLI::log( $this->color_message( $column, $data ) );
652
+				WP_CLI::log($this->color_message($column, $data));
653 653
 			}
654 654
 		}
655 655
 	}
@@ -689,27 +689,27 @@  discard block
 block discarded – undo
689 689
 	 *
690 690
 	 * @return        void
691 691
 	 */
692
-	public function report( $args, $assoc_args ) {
692
+	public function report($args, $assoc_args) {
693 693
 		$stats      = new Give_Payment_Stats();
694
-		$date       = isset( $assoc_args ) && array_key_exists( 'date', $assoc_args ) ? $assoc_args['date'] : false;
695
-		$start_date = isset( $assoc_args ) && array_key_exists( 'start-date', $assoc_args ) ? $assoc_args['start-date'] : false;
696
-		$end_date   = isset( $assoc_args ) && array_key_exists( 'end-date', $assoc_args ) ? $assoc_args['end-date'] : false;
697
-		$form_id    = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? $assoc_args['id'] : 0;
694
+		$date       = isset($assoc_args) && array_key_exists('date', $assoc_args) ? $assoc_args['date'] : false;
695
+		$start_date = isset($assoc_args) && array_key_exists('start-date', $assoc_args) ? $assoc_args['start-date'] : false;
696
+		$end_date   = isset($assoc_args) && array_key_exists('end-date', $assoc_args) ? $assoc_args['end-date'] : false;
697
+		$form_id    = isset($assoc_args) && array_key_exists('id', $assoc_args) ? $assoc_args['id'] : 0;
698 698
 
699
-		if ( ! empty( $date ) ) {
699
+		if ( ! empty($date)) {
700 700
 			$start_date = $date;
701 701
 			$end_date   = false;
702
-		} elseif ( empty( $date ) && empty( $start_date ) ) {
702
+		} elseif (empty($date) && empty($start_date)) {
703 703
 			$start_date = 'this_month';
704 704
 			$end_date   = false;
705 705
 		}
706 706
 
707 707
 		// Get stats.
708
-		$earnings = $stats->get_earnings( $form_id, $start_date, $end_date );
709
-		$sales    = $stats->get_sales( $form_id, $start_date, $end_date );
708
+		$earnings = $stats->get_earnings($form_id, $start_date, $end_date);
709
+		$sales    = $stats->get_sales($form_id, $start_date, $end_date);
710 710
 
711
-		WP_CLI::line( $this->color_message( __( 'Earnings', 'give' ), give_currency_filter( $earnings ) ) );
712
-		WP_CLI::line( $this->color_message( __( 'Sales', 'give' ), $sales ) );
711
+		WP_CLI::line($this->color_message(__('Earnings', 'give'), give_currency_filter($earnings)));
712
+		WP_CLI::line($this->color_message(__('Sales', 'give'), $sales));
713 713
 	}
714 714
 
715 715
 
@@ -736,27 +736,27 @@  discard block
 block discarded – undo
736 736
 	 *
737 737
 	 * @subcommand    cache
738 738
 	 */
739
-	public function cache( $args, $assoc_args ) {
740
-		$action = isset( $assoc_args ) && array_key_exists( 'action', $assoc_args ) ? $assoc_args['action'] : false;
739
+	public function cache($args, $assoc_args) {
740
+		$action = isset($assoc_args) && array_key_exists('action', $assoc_args) ? $assoc_args['action'] : false;
741 741
 
742 742
 		// Bailout.
743
-		if ( ! $action || ! in_array( $action, array( 'delete' ), true ) ) {
744
-			WP_CLI::warning( __( 'Type wp give cache --action=delete to delete all stat transients', 'give' ) );
743
+		if ( ! $action || ! in_array($action, array('delete'), true)) {
744
+			WP_CLI::warning(__('Type wp give cache --action=delete to delete all stat transients', 'give'));
745 745
 
746 746
 			return;
747 747
 		}
748 748
 
749
-		switch ( $action ) {
749
+		switch ($action) {
750 750
 			case 'delete':
751 751
 				// Reset counter.
752 752
 				self::$counter = 1;
753 753
 
754
-				if ( $this->delete_stats_transients() ) {
754
+				if ($this->delete_stats_transients()) {
755 755
 					// Report .eading.
756
-					WP_CLI::success( 'Give cache deleted.' );
756
+					WP_CLI::success('Give cache deleted.');
757 757
 				} else {
758 758
 					// Report .eading.
759
-					WP_CLI::warning( 'We did not find any Give plugin cache to delete :)' );
759
+					WP_CLI::warning('We did not find any Give plugin cache to delete :)');
760 760
 				}
761 761
 				break;
762 762
 		}
@@ -785,27 +785,27 @@  discard block
 block discarded – undo
785 785
 			ARRAY_A
786 786
 		);
787 787
 
788
-		if ( ! empty( $stat_option_names ) ) {
788
+		if ( ! empty($stat_option_names)) {
789 789
 
790
-			foreach ( $stat_option_names as $option_name ) {
790
+			foreach ($stat_option_names as $option_name) {
791 791
 				$error       = false;
792 792
 				$option_name = $option_name['option_name'];
793 793
 
794
-				switch ( true ) {
795
-					case ( false !== strpos( $option_name, 'transient' ) ):
796
-						$option_name = str_replace( '_transient_', '', $option_name );
797
-						$error       = delete_transient( $option_name );
794
+				switch (true) {
795
+					case (false !== strpos($option_name, 'transient')):
796
+						$option_name = str_replace('_transient_', '', $option_name);
797
+						$error       = delete_transient($option_name);
798 798
 						break;
799 799
 
800 800
 					default:
801
-						$error = delete_option( $option_name );
801
+						$error = delete_option($option_name);
802 802
 				}
803 803
 
804
-				if ( $error ) {
805
-					WP_CLI::log( $this->color_message( self::$counter, $option_name ) );
806
-					self::$counter ++;
804
+				if ($error) {
805
+					WP_CLI::log($this->color_message(self::$counter, $option_name));
806
+					self::$counter++;
807 807
 				} else {
808
-					WP_CLI::log( $this->color_message( __( 'Error while deleting this transient', 'give' ), $option_name ) );
808
+					WP_CLI::log($this->color_message(__('Error while deleting this transient', 'give'), $option_name));
809 809
 				}
810 810
 			}
811 811
 
@@ -826,13 +826,13 @@  discard block
 block discarded – undo
826 826
 	 *
827 827
 	 * @return   string
828 828
 	 */
829
-	private function color_message( $heading, $message = '', $colon = true, $color = 'g' ) {
829
+	private function color_message($heading, $message = '', $colon = true, $color = 'g') {
830 830
 		// Add colon.
831
-		if ( $colon ) {
832
-			$heading = $heading . ': ';
831
+		if ($colon) {
832
+			$heading = $heading.': ';
833 833
 		}
834 834
 
835
-		return WP_CLI::colorize( "%{$color}" . $heading . '%n' ) . $message;
835
+		return WP_CLI::colorize("%{$color}".$heading.'%n').$message;
836 836
 	}
837 837
 
838 838
 
@@ -847,8 +847,8 @@  discard block
 block discarded – undo
847 847
 	 *
848 848
 	 * @return    void
849 849
 	 */
850
-	private function color_main_heading( $heading, $color = 'g' ) {
851
-		WP_CLI::log( "\n######   " . $this->color_message( $heading, '', false, $color ) . '   ######' );
850
+	private function color_main_heading($heading, $color = 'g') {
851
+		WP_CLI::log("\n######   ".$this->color_message($heading, '', false, $color).'   ######');
852 852
 	}
853 853
 
854 854
 	/**
@@ -861,8 +861,8 @@  discard block
 block discarded – undo
861 861
 	 *
862 862
 	 * @return    void
863 863
 	 */
864
-	private function color_sub_heading( $subheading ) {
865
-		WP_CLI::log( "\n--->" . $subheading . '', '', false );
864
+	private function color_sub_heading($subheading) {
865
+		WP_CLI::log("\n--->".$subheading.'', '', false);
866 866
 	}
867 867
 
868 868
 
@@ -876,17 +876,17 @@  discard block
 block discarded – undo
876 876
 	 *
877 877
 	 * @return    void
878 878
 	 */
879
-	private function display_table( $data ) {
879
+	private function display_table($data) {
880 880
 		$table = new \cli\Table();
881 881
 
882 882
 		// Set table header.
883
-		$table->setHeaders( $data[0] );
883
+		$table->setHeaders($data[0]);
884 884
 
885 885
 		// Remove table header.
886
-		unset( $data[0] );
886
+		unset($data[0]);
887 887
 
888 888
 		// Set table data.
889
-		$table->setRows( $data );
889
+		$table->setRows($data);
890 890
 
891 891
 		// Display table.
892 892
 		$table->display();
@@ -903,14 +903,14 @@  discard block
 block discarded – undo
903 903
 	 * @return array
904 904
 	 */
905 905
 
906
-	private function get_donors_by_form_id( $form_id ) {
906
+	private function get_donors_by_form_id($form_id) {
907 907
 		$donors = array();
908 908
 
909 909
 		$donations = new Give_Payments_Query(
910 910
 			array(
911
-				'give_forms' => array( $form_id ),
912
-				'number'     => - 1,
913
-				'status'     => array( 'publish' ),
911
+				'give_forms' => array($form_id),
912
+				'number'     => -1,
913
+				'status'     => array('publish'),
914 914
 			)
915 915
 		);
916 916
 
@@ -918,16 +918,16 @@  discard block
 block discarded – undo
918 918
 		$skip_donors = array();
919 919
 
920 920
 		/* @var Give_Payment|object $donation Payment object. */
921
-		foreach ( $donations as $donation ) {
921
+		foreach ($donations as $donation) {
922 922
 
923
-			if ( in_array( $donation->customer_id, $skip_donors, true ) ) {
923
+			if (in_array($donation->customer_id, $skip_donors, true)) {
924 924
 				continue;
925 925
 			}
926 926
 
927
-			if ( ! empty( $donors ) ) {
928
-				$donors['donors'][] = current( current( $this->api->get_donors( (int) $donation->customer_id ) ) );
927
+			if ( ! empty($donors)) {
928
+				$donors['donors'][] = current(current($this->api->get_donors((int) $donation->customer_id)));
929 929
 			} else {
930
-				$donors = array_merge( $donors, $this->api->get_donors( (int) $donation->customer_id ) );
930
+				$donors = array_merge($donors, $this->api->get_donors((int) $donation->customer_id));
931 931
 			}
932 932
 
933 933
 			$skip_donors[] = $donation->customer_id;
@@ -972,15 +972,15 @@  discard block
 block discarded – undo
972 972
 		);
973 973
 
974 974
 		// Generate a random forename.
975
-		$random_name = $names[ mt_rand( 0, sizeof( $names ) - 1 ) ];
975
+		$random_name = $names[mt_rand(0, sizeof($names) - 1)];
976 976
 
977 977
 		// Generate a random surname.
978
-		$random_surname = $surnames[ mt_rand( 0, sizeof( $surnames ) - 1 ) ];
978
+		$random_surname = $surnames[mt_rand(0, sizeof($surnames) - 1)];
979 979
 
980 980
 		// Generate name.
981 981
 		$name = "{$random_name} {$random_surname}";
982 982
 
983
-		if ( in_array( $name, $this->new_donor_names ) ) {
983
+		if (in_array($name, $this->new_donor_names)) {
984 984
 			$name = $this->get_random_name();
985 985
 		}
986 986
 
@@ -999,7 +999,7 @@  discard block
 block discarded – undo
999 999
 	 *
1000 1000
 	 * @return string
1001 1001
 	 */
1002
-	private function get_random_email( $name ) {
1003
-		return implode( '.', explode( ' ', strtolower( $name ) ) ) . '@test.com';
1002
+	private function get_random_email($name) {
1003
+		return implode('.', explode(' ', strtolower($name))).'@test.com';
1004 1004
 	}
1005 1005
 }
Please login to merge, or discard this patch.
includes/scripts.php 1 patch
Spacing   +173 added lines, -173 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,83 +58,83 @@  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
-		'confirm_email_sent_message'         => __( 'Please check your email and click on the link to access your complete donation history.', 'give' ),
71
-	) );
70
+		'confirm_email_sent_message'         => __('Please check your email and click on the link to access your complete donation history.', 'give'),
71
+	));
72 72
 
73
-	$localize_give_ajax = apply_filters( 'give_global_ajax_vars', array(
73
+	$localize_give_ajax = apply_filters('give_global_ajax_vars', array(
74 74
 		'ajaxurl'         => give_get_ajax_url(),
75
-		'ajaxNonce'       => wp_create_nonce( 'give_ajax_nonce' ),
76
-		'loading'         => __( 'Loading', 'give' ),
75
+		'ajaxNonce'       => wp_create_nonce('give_ajax_nonce'),
76
+		'loading'         => __('Loading', 'give'),
77 77
 		// General loading message.
78
-		'select_option'   => __( 'Please select an option', 'give' ),
78
+		'select_option'   => __('Please select an option', 'give'),
79 79
 		// Variable pricing error with multi-donation option enabled.
80
-		'default_gateway' => give_get_default_gateway( null ),
81
-		'permalinks'      => get_option( 'permalink_structure' ) ? '1' : '0',
80
+		'default_gateway' => give_get_default_gateway(null),
81
+		'permalinks'      => get_option('permalink_structure') ? '1' : '0',
82 82
 		'number_decimals' => give_get_price_decimals(),
83
-	) );
83
+	));
84 84
 
85 85
 	// DEBUG is On.
86
-	if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
86
+	if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) {
87 87
 
88
-		if ( give_is_cc_verify_enabled() ) {
89
-			wp_register_script( 'give-cc-validator', $js_plugins . 'jquery.payment' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
90
-			wp_enqueue_script( 'give-cc-validator' );
88
+		if (give_is_cc_verify_enabled()) {
89
+			wp_register_script('give-cc-validator', $js_plugins.'jquery.payment'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
90
+			wp_enqueue_script('give-cc-validator');
91 91
 		}
92 92
 
93
-		wp_register_script( 'give-float-labels', $js_plugins . 'float-labels' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
94
-		wp_enqueue_script( 'give-float-labels' );
93
+		wp_register_script('give-float-labels', $js_plugins.'float-labels'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
94
+		wp_enqueue_script('give-float-labels');
95 95
 
96
-		wp_register_script( 'give-blockui', $js_plugins . 'jquery.blockUI' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
97
-		wp_enqueue_script( 'give-blockui' );
96
+		wp_register_script('give-blockui', $js_plugins.'jquery.blockUI'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
97
+		wp_enqueue_script('give-blockui');
98 98
 
99
-		wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
100
-		wp_enqueue_script( 'give-qtip' );
99
+		wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
100
+		wp_enqueue_script('give-qtip');
101 101
 
102
-		wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
103
-		wp_enqueue_script( 'give-accounting' );
102
+		wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
103
+		wp_enqueue_script('give-accounting');
104 104
 
105
-		wp_register_script( 'give-magnific', $js_plugins . 'jquery.magnific-popup' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
106
-		wp_enqueue_script( 'give-magnific' );
105
+		wp_register_script('give-magnific', $js_plugins.'jquery.magnific-popup'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
106
+		wp_enqueue_script('give-magnific');
107 107
 
108
-		wp_register_script( 'give-checkout-global', $js_dir . 'give-donations' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
109
-		wp_enqueue_script( 'give-checkout-global' );
108
+		wp_register_script('give-checkout-global', $js_dir.'give-donations'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
109
+		wp_enqueue_script('give-checkout-global');
110 110
 
111 111
 		// General scripts.
112
-		wp_register_script( 'give-scripts', $js_dir . 'give' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
113
-		wp_enqueue_script( 'give-scripts' );
112
+		wp_register_script('give-scripts', $js_dir.'give'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
113
+		wp_enqueue_script('give-scripts');
114 114
 
115 115
 		// Load AJAX scripts, if enabled.
116
-		wp_register_script( 'give-ajax', $js_dir . 'give-ajax' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
117
-		wp_enqueue_script( 'give-ajax' );
116
+		wp_register_script('give-ajax', $js_dir.'give-ajax'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
117
+		wp_enqueue_script('give-ajax');
118 118
 
119 119
 		// Localize / Pass AJAX vars from PHP,
120
-		wp_localize_script( 'give-checkout-global', 'give_global_vars', $localize_give_vars );
121
-		wp_localize_script( 'give-ajax', 'give_scripts', $localize_give_ajax );
120
+		wp_localize_script('give-checkout-global', 'give_global_vars', $localize_give_vars);
121
+		wp_localize_script('give-ajax', 'give_scripts', $localize_give_ajax);
122 122
 
123 123
 	} else {
124 124
 
125 125
 		// DEBUG is OFF (one JS file to rule them all!).
126
-		wp_register_script( 'give', $js_dir . 'give.all.min.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
127
-		wp_enqueue_script( 'give' );
126
+		wp_register_script('give', $js_dir.'give.all.min.js', array('jquery'), GIVE_VERSION, $scripts_footer);
127
+		wp_enqueue_script('give');
128 128
 
129 129
 		// Localize / Pass AJAX vars from PHP.
130
-		wp_localize_script( 'give', 'give_global_vars', $localize_give_vars );
131
-		wp_localize_script( 'give', 'give_scripts', $localize_give_ajax );
130
+		wp_localize_script('give', 'give_global_vars', $localize_give_vars);
131
+		wp_localize_script('give', 'give_scripts', $localize_give_ajax);
132 132
 
133 133
 	}
134 134
 
135 135
 }
136 136
 
137
-add_action( 'wp_enqueue_scripts', 'give_load_scripts' );
137
+add_action('wp_enqueue_scripts', 'give_load_scripts');
138 138
 
139 139
 /**
140 140
  * Register styles.
@@ -147,16 +147,16 @@  discard block
 block discarded – undo
147 147
  */
148 148
 function give_register_styles() {
149 149
 
150
-	if ( ! give_is_setting_enabled( give_get_option( 'css' ) ) ) {
150
+	if ( ! give_is_setting_enabled(give_get_option('css'))) {
151 151
 		return;
152 152
 	}
153 153
 
154
-	wp_register_style( 'give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all' );
155
-	wp_enqueue_style( 'give-styles' );
154
+	wp_register_style('give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all');
155
+	wp_enqueue_style('give-styles');
156 156
 
157 157
 }
158 158
 
159
-add_action( 'wp_enqueue_scripts', 'give_register_styles' );
159
+add_action('wp_enqueue_scripts', 'give_register_styles');
160 160
 
161 161
 
162 162
 /**
@@ -169,19 +169,19 @@  discard block
 block discarded – undo
169 169
 function give_get_stylesheet_uri() {
170 170
 
171 171
 	// Use minified libraries if SCRIPT_DEBUG is turned off.
172
-	$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
172
+	$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
173 173
 
174 174
 	// LTR or RTL files.
175
-	$direction = ( is_rtl() ) ? '-rtl' : '';
175
+	$direction = (is_rtl()) ? '-rtl' : '';
176 176
 
177
-	$file          = 'give' . $direction . $suffix . '.css';
177
+	$file          = 'give'.$direction.$suffix.'.css';
178 178
 	$templates_dir = give_get_theme_template_dir_name();
179 179
 
180
-	$child_theme_style_sheet    = trailingslashit( get_stylesheet_directory() ) . $templates_dir . $file;
181
-	$child_theme_style_sheet_2  = trailingslashit( get_stylesheet_directory() ) . $templates_dir . 'give' . $direction . '.css';
182
-	$parent_theme_style_sheet   = trailingslashit( get_template_directory() ) . $templates_dir . $file;
183
-	$parent_theme_style_sheet_2 = trailingslashit( get_template_directory() ) . $templates_dir . 'give' . $direction . '.css';
184
-	$give_plugin_style_sheet    = trailingslashit( give_get_templates_dir() ) . $file;
180
+	$child_theme_style_sheet    = trailingslashit(get_stylesheet_directory()).$templates_dir.$file;
181
+	$child_theme_style_sheet_2  = trailingslashit(get_stylesheet_directory()).$templates_dir.'give'.$direction.'.css';
182
+	$parent_theme_style_sheet   = trailingslashit(get_template_directory()).$templates_dir.$file;
183
+	$parent_theme_style_sheet_2 = trailingslashit(get_template_directory()).$templates_dir.'give'.$direction.'.css';
184
+	$give_plugin_style_sheet    = trailingslashit(give_get_templates_dir()).$file;
185 185
 
186 186
 	$uri = false;
187 187
 
@@ -191,23 +191,23 @@  discard block
 block discarded – undo
191 191
 	 * followed by non minified version, even if SCRIPT_DEBUG is not enabled.
192 192
 	 * This allows users to copy just give.css to their theme.
193 193
 	 */
194
-	if ( file_exists( $child_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $child_theme_style_sheet_2 ) ) ) ) {
195
-		if ( ! empty( $nonmin ) ) {
196
-			$uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . 'give' . $direction . '.css';
194
+	if (file_exists($child_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($child_theme_style_sheet_2)))) {
195
+		if ( ! empty($nonmin)) {
196
+			$uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.'give'.$direction.'.css';
197 197
 		} else {
198
-			$uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . $file;
198
+			$uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.$file;
199 199
 		}
200
-	} elseif ( file_exists( $parent_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $parent_theme_style_sheet_2 ) ) ) ) {
201
-		if ( ! empty( $nonmin ) ) {
202
-			$uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . 'give' . $direction . '.css';
200
+	} elseif (file_exists($parent_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($parent_theme_style_sheet_2)))) {
201
+		if ( ! empty($nonmin)) {
202
+			$uri = trailingslashit(get_template_directory_uri()).$templates_dir.'give'.$direction.'.css';
203 203
 		} else {
204
-			$uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . $file;
204
+			$uri = trailingslashit(get_template_directory_uri()).$templates_dir.$file;
205 205
 		}
206
-	} elseif ( file_exists( $give_plugin_style_sheet ) || file_exists( $give_plugin_style_sheet ) ) {
207
-		$uri = trailingslashit( give_get_templates_url() ) . $file;
206
+	} elseif (file_exists($give_plugin_style_sheet) || file_exists($give_plugin_style_sheet)) {
207
+		$uri = trailingslashit(give_get_templates_url()).$file;
208 208
 	}
209 209
 
210
-	return apply_filters( 'give_get_stylesheet_uri', $uri );
210
+	return apply_filters('give_get_stylesheet_uri', $uri);
211 211
 
212 212
 }
213 213
 
@@ -224,79 +224,79 @@  discard block
 block discarded – undo
224 224
  *
225 225
  * @return void
226 226
  */
227
-function give_load_admin_scripts( $hook ) {
227
+function give_load_admin_scripts($hook) {
228 228
 
229 229
 	global $post, $post_type;
230 230
 
231 231
 	$give_options = give_get_settings();
232 232
 
233 233
 	// Directories of assets.
234
-	$js_dir     = GIVE_PLUGIN_URL . 'assets/js/admin/';
235
-	$js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/';
236
-	$css_dir    = GIVE_PLUGIN_URL . 'assets/css/';
234
+	$js_dir     = GIVE_PLUGIN_URL.'assets/js/admin/';
235
+	$js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/';
236
+	$css_dir    = GIVE_PLUGIN_URL.'assets/css/';
237 237
 
238 238
 	// Use minified libraries if SCRIPT_DEBUG is turned off.
239
-	$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
239
+	$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
240 240
 
241 241
 	// LTR or RTL files.
242
-	$direction = ( is_rtl() ) ? '-rtl' : '';
242
+	$direction = (is_rtl()) ? '-rtl' : '';
243 243
 
244 244
 	// Global Admin.
245
-	wp_register_style( 'give-admin-bar-notification', $css_dir . 'adminbar-style.css' );
246
-	wp_enqueue_style( 'give-admin-bar-notification' );
245
+	wp_register_style('give-admin-bar-notification', $css_dir.'adminbar-style.css');
246
+	wp_enqueue_style('give-admin-bar-notification');
247 247
 
248 248
 	// Give Admin Only.
249
-	if ( ! apply_filters( 'give_load_admin_scripts', give_is_admin_page(), $hook ) ) {
249
+	if ( ! apply_filters('give_load_admin_scripts', give_is_admin_page(), $hook)) {
250 250
 		return;
251 251
 	}
252 252
 
253 253
 	// CSS.
254
-	wp_register_style( 'jquery-ui-css', $css_dir . 'jquery-ui-fresh' . $suffix . '.css' );
255
-	wp_enqueue_style( 'jquery-ui-css' );
256
-	wp_register_style( 'give-admin', $css_dir . 'give-admin' . $direction . $suffix . '.css', array(), GIVE_VERSION );
257
-	wp_enqueue_style( 'give-admin' );
258
-	wp_register_style( 'jquery-chosen', $css_dir . 'chosen' . $suffix . '.css', array(), GIVE_VERSION );
259
-	wp_enqueue_style( 'jquery-chosen' );
260
-	wp_enqueue_style( 'thickbox' );
261
-	wp_enqueue_style( 'wp-color-picker' );
254
+	wp_register_style('jquery-ui-css', $css_dir.'jquery-ui-fresh'.$suffix.'.css');
255
+	wp_enqueue_style('jquery-ui-css');
256
+	wp_register_style('give-admin', $css_dir.'give-admin'.$direction.$suffix.'.css', array(), GIVE_VERSION);
257
+	wp_enqueue_style('give-admin');
258
+	wp_register_style('jquery-chosen', $css_dir.'chosen'.$suffix.'.css', array(), GIVE_VERSION);
259
+	wp_enqueue_style('jquery-chosen');
260
+	wp_enqueue_style('thickbox');
261
+	wp_enqueue_style('wp-color-picker');
262 262
 
263 263
 
264 264
 	// JS.
265
-	wp_register_script( 'give-selector-cache', $js_plugins . 'selector-cache' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
266
-	wp_enqueue_script( 'give-selector-cache' );
265
+	wp_register_script('give-selector-cache', $js_plugins.'selector-cache'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
266
+	wp_enqueue_script('give-selector-cache');
267 267
 
268
-	wp_register_script( 'jquery-chosen', $js_plugins . 'chosen.jquery' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION );
269
-	wp_enqueue_script( 'jquery-chosen' );
268
+	wp_register_script('jquery-chosen', $js_plugins.'chosen.jquery'.$suffix.'.js', array('jquery'), GIVE_VERSION);
269
+	wp_enqueue_script('jquery-chosen');
270 270
 
271
-	wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
272
-	wp_enqueue_script( 'give-accounting' );
271
+	wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
272
+	wp_enqueue_script('give-accounting');
273 273
 
274
-	wp_enqueue_script( 'wp-color-picker' );
275
-	wp_enqueue_script( 'jquery-ui-datepicker' );
276
-	wp_enqueue_script( 'thickbox' );
274
+	wp_enqueue_script('wp-color-picker');
275
+	wp_enqueue_script('jquery-ui-datepicker');
276
+	wp_enqueue_script('thickbox');
277 277
 
278
-	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 );
279
-	wp_enqueue_script( 'give-admin-scripts' );
278
+	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);
279
+	wp_enqueue_script('give-admin-scripts');
280 280
 
281
-	wp_register_script( 'jquery-flot', $js_plugins . 'jquery.flot' . $suffix . '.js' );
282
-	wp_enqueue_script( 'jquery-flot' );
281
+	wp_register_script('jquery-flot', $js_plugins.'jquery.flot'.$suffix.'.js');
282
+	wp_enqueue_script('jquery-flot');
283 283
 
284
-	wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
285
-	wp_enqueue_script( 'give-qtip' );
284
+	wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
285
+	wp_enqueue_script('give-qtip');
286 286
 
287
-	wp_register_script( 'give-repeatable-fields', $js_plugins . 'repeatable-fields' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
288
-	wp_enqueue_script( 'give-repeatable-fields' );
287
+	wp_register_script('give-repeatable-fields', $js_plugins.'repeatable-fields'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
288
+	wp_enqueue_script('give-repeatable-fields');
289 289
 
290 290
 	// Forms CPT Script.
291
-	if ( $post_type === 'give_forms' ) {
292
-		wp_register_script( 'give-admin-forms-scripts', $js_dir . 'admin-forms' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
293
-		wp_enqueue_script( 'give-admin-forms-scripts' );
291
+	if ($post_type === 'give_forms') {
292
+		wp_register_script('give-admin-forms-scripts', $js_dir.'admin-forms'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
293
+		wp_enqueue_script('give-admin-forms-scripts');
294 294
 	}
295 295
 
296 296
 	// Settings Scripts.
297
-	if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-settings' ) {
298
-		wp_register_script( 'give-admin-settings-scripts', $js_dir . 'admin-settings' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
299
-		wp_enqueue_script( 'give-admin-settings-scripts' );
297
+	if (isset($_GET['page']) && $_GET['page'] == 'give-settings') {
298
+		wp_register_script('give-admin-settings-scripts', $js_dir.'admin-settings'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
299
+		wp_enqueue_script('give-admin-settings-scripts');
300 300
 	}
301 301
 
302 302
 	// Price Separators.
@@ -304,87 +304,87 @@  discard block
 block discarded – undo
304 304
 	$decimal_separator  = give_get_price_decimal_separator();
305 305
 
306 306
 	// Localize strings & variables for JS.
307
-	wp_localize_script( 'give-admin-scripts', 'give_vars', array(
308
-		'post_id'                           => isset( $post->ID ) ? $post->ID : null,
307
+	wp_localize_script('give-admin-scripts', 'give_vars', array(
308
+		'post_id'                           => isset($post->ID) ? $post->ID : null,
309 309
 		'give_version'                      => GIVE_VERSION,
310 310
 		'thousands_separator'               => $thousand_separator,
311 311
 		'decimal_separator'                 => $decimal_separator,
312
-		'quick_edit_warning'                => __( 'Not available for variable priced forms.', 'give' ),
313
-		'delete_payment'                    => __( 'Are you sure you want to delete this payment?', 'give' ),
314
-		'delete_payment_note'               => __( 'Are you sure you want to delete this note?', 'give' ),
315
-		'revoke_api_key'                    => __( 'Are you sure you want to revoke this API key?', 'give' ),
316
-		'regenerate_api_key'                => __( 'Are you sure you want to regenerate this API key?', 'give' ),
317
-		'resend_receipt'                    => __( 'Are you sure you want to resend the donation receipt?', 'give' ),
318
-		'disconnect_user'                   => __( 'Are you sure you want to disconnect the user from this donor?', 'give' ),
319
-		'one_option'                        => __( 'Choose a form', 'give' ),
320
-		'one_or_more_option'                => __( 'Choose one or more forms', 'give' ),
321
-		'currency_sign'                     => give_currency_filter( '' ),
322
-		'currency_pos'                      => isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before',
312
+		'quick_edit_warning'                => __('Not available for variable priced forms.', 'give'),
313
+		'delete_payment'                    => __('Are you sure you want to delete this payment?', 'give'),
314
+		'delete_payment_note'               => __('Are you sure you want to delete this note?', 'give'),
315
+		'revoke_api_key'                    => __('Are you sure you want to revoke this API key?', 'give'),
316
+		'regenerate_api_key'                => __('Are you sure you want to regenerate this API key?', 'give'),
317
+		'resend_receipt'                    => __('Are you sure you want to resend the donation receipt?', 'give'),
318
+		'disconnect_user'                   => __('Are you sure you want to disconnect the user from this donor?', 'give'),
319
+		'one_option'                        => __('Choose a form', 'give'),
320
+		'one_or_more_option'                => __('Choose one or more forms', 'give'),
321
+		'currency_sign'                     => give_currency_filter(''),
322
+		'currency_pos'                      => isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before',
323 323
 		'currency_decimals'                 => give_get_price_decimals(),
324
-		'batch_export_no_class'             => __( 'You must choose a method.', 'give' ),
325
-		'batch_export_no_reqs'              => __( 'Required fields not completed.', 'give' ),
326
-		'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' ),
327
-		'delete_test_donor'                 => __( 'Are you sure you want to delete all the test donors? This process will also delete test donations as well.', 'give' ),
328
-		'delete_import_donor'               => __( 'Are you sure you want to delete all the imported donors? This process will also delete imported donations as well.', 'give' ),
329
-		'price_format_guide'                => sprintf( __( 'Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give' ), $decimal_separator, $thousand_separator ),
324
+		'batch_export_no_class'             => __('You must choose a method.', 'give'),
325
+		'batch_export_no_reqs'              => __('Required fields not completed.', 'give'),
326
+		'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'),
327
+		'delete_test_donor'                 => __('Are you sure you want to delete all the test donors? This process will also delete test donations as well.', 'give'),
328
+		'delete_import_donor'               => __('Are you sure you want to delete all the imported donors? This process will also delete imported donations as well.', 'give'),
329
+		'price_format_guide'                => sprintf(__('Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give'), $decimal_separator, $thousand_separator),
330 330
 		/* translators : %s: Donation form options metabox */
331
-		'confirm_before_remove_row_text'    => __( 'Do you want to delete this level?', 'give' ),
332
-		'matched_success_failure_page'      => __( 'You cannot set the success and failed pages to the same page', 'give' ),
333
-		'dismiss_notice_text'               => __( 'Dismiss this notice.', 'give' ),
334
-		'search_placeholder'                => __( 'Type to search all forms', 'give' ),
335
-		'search_placeholder_donor'          => __( 'Type to search all donors', 'give' ),
336
-		'search_placeholder_country'        => __( 'Type to search all countries', 'give' ),
337
-		'search_placeholder_state'          => __( 'Type to search all states/provinces', 'give' ),
338
-		'remove_from_bulk_delete'           => __( 'Remove from Bulk Delete', 'give' ),
331
+		'confirm_before_remove_row_text'    => __('Do you want to delete this level?', 'give'),
332
+		'matched_success_failure_page'      => __('You cannot set the success and failed pages to the same page', 'give'),
333
+		'dismiss_notice_text'               => __('Dismiss this notice.', 'give'),
334
+		'search_placeholder'                => __('Type to search all forms', 'give'),
335
+		'search_placeholder_donor'          => __('Type to search all donors', 'give'),
336
+		'search_placeholder_country'        => __('Type to search all countries', 'give'),
337
+		'search_placeholder_state'          => __('Type to search all states/provinces', 'give'),
338
+		'remove_from_bulk_delete'           => __('Remove from Bulk Delete', 'give'),
339 339
 		'donors_bulk_action'                => array(
340
-			'no_donor_selected'  => __( 'You must choose at least one or more donors to delete.', 'give' ),
341
-			'no_action_selected' => __( 'You must select a bulk action to proceed.', 'give' ),
340
+			'no_donor_selected'  => __('You must choose at least one or more donors to delete.', 'give'),
341
+			'no_action_selected' => __('You must select a bulk action to proceed.', 'give'),
342 342
 		),
343 343
 		'donations_bulk_action'             => array(
344 344
 			'delete'         => array(
345
-				'zero'     => __( 'You must choose at least one or more donations to delete.', 'give' ),
346
-				'single'   => __( 'Are you sure you want to permanently delete this donation?', 'give' ),
347
-				'multiple' => __( 'Are you sure you want to permanently delete the selected {payment_count} donations?', 'give' ),
345
+				'zero'     => __('You must choose at least one or more donations to delete.', 'give'),
346
+				'single'   => __('Are you sure you want to permanently delete this donation?', 'give'),
347
+				'multiple' => __('Are you sure you want to permanently delete the selected {payment_count} donations?', 'give'),
348 348
 			),
349 349
 			'resend-receipt' => array(
350
-				'zero'     => __( 'You must choose at least one or more recipients to resend the email receipt.', 'give' ),
351
-				'single'   => __( 'Are you sure you want to resend the email receipt to this recipient?', 'give' ),
352
-				'multiple' => __( 'Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give' ),
350
+				'zero'     => __('You must choose at least one or more recipients to resend the email receipt.', 'give'),
351
+				'single'   => __('Are you sure you want to resend the email receipt to this recipient?', 'give'),
352
+				'multiple' => __('Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give'),
353 353
 			),
354 354
 			'set-to-status'  => array(
355
-				'zero'     => __( 'You must choose at least one or more donations to set status to {status}.', 'give' ),
356
-				'single'   => __( 'Are you sure you want to set status of this donation to {status}?', 'give' ),
357
-				'multiple' => __( 'Are you sure you want to set status of {payment_count} donations to {status}?', 'give' ),
355
+				'zero'     => __('You must choose at least one or more donations to set status to {status}.', 'give'),
356
+				'single'   => __('Are you sure you want to set status of this donation to {status}?', 'give'),
357
+				'multiple' => __('Are you sure you want to set status of {payment_count} donations to {status}?', 'give'),
358 358
 			),
359 359
 		),
360 360
 		'metabox_fields'                    => array(
361 361
 			'media' => array(
362
-				'button_title' => __( 'Choose Image', 'give' ),
362
+				'button_title' => __('Choose Image', 'give'),
363 363
 			),
364 364
 			'file'  => array(
365
-				'button_title' => __( 'Choose File', 'give' ),
365
+				'button_title' => __('Choose File', 'give'),
366 366
 			),
367 367
 		),
368 368
 		'chosen'                            => array(
369
-			'no_results_msg'  => __( 'No results match {search_term}', 'give' ),
370
-			'ajax_search_msg' => __( 'Searching results for match {search_term}', 'give' ),
369
+			'no_results_msg'  => __('No results match {search_term}', 'give'),
370
+			'ajax_search_msg' => __('Searching results for match {search_term}', 'give'),
371 371
 		),
372
-		'db_update_confirmation_msg_button' => __( 'Run Updates', 'give' ),
373
-		'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' ),
374
-		'error_message'                     => __( 'Something went wrong kindly try again!', 'give' ),
372
+		'db_update_confirmation_msg_button' => __('Run Updates', 'give'),
373
+		'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'),
374
+		'error_message'                     => __('Something went wrong kindly try again!', 'give'),
375 375
 		'give_donation_import'              => 'give_donation_import',
376 376
 		'core_settings_import'              => 'give_core_settings_import',
377
-		'setting_not_save_message'          => __( 'Changes you made may not be saved.', 'give' ),
378
-	) );
377
+		'setting_not_save_message'          => __('Changes you made may not be saved.', 'give'),
378
+	));
379 379
 
380
-	if ( function_exists( 'wp_enqueue_media' ) && version_compare( get_bloginfo( 'version' ), '3.5', '>=' ) ) {
380
+	if (function_exists('wp_enqueue_media') && version_compare(get_bloginfo('version'), '3.5', '>=')) {
381 381
 		// call for new media manager.
382 382
 		wp_enqueue_media();
383 383
 	}
384 384
 
385 385
 }
386 386
 
387
-add_action( 'admin_enqueue_scripts', 'give_load_admin_scripts', 100 );
387
+add_action('admin_enqueue_scripts', 'give_load_admin_scripts', 100);
388 388
 
389 389
 /**
390 390
  * Admin Give Icon
@@ -399,13 +399,13 @@  discard block
 block discarded – undo
399 399
 	?>
400 400
 	<style type="text/css" media="screen">
401 401
 
402
-		<?php if ( version_compare( get_bloginfo( 'version' ), '3.8-RC', '>=' ) || version_compare( get_bloginfo( 'version' ), '3.8', '>=' ) ) { ?>
402
+		<?php if (version_compare(get_bloginfo('version'), '3.8-RC', '>=') || version_compare(get_bloginfo('version'), '3.8', '>=')) { ?>
403 403
 		@font-face {
404 404
 			font-family: 'give-icomoon';
405
-			src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?ngjl88'; ?>');
406
-			src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?#iefixngjl88'?>') format('embedded-opentype'),
407
-			url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.woff?ngjl88'; ?>') format('woff'),
408
-			url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.svg?ngjl88#icomoon'; ?>') format('svg');
405
+			src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?ngjl88'; ?>');
406
+			src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?#iefixngjl88'?>') format('embedded-opentype'),
407
+			url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.woff?ngjl88'; ?>') format('woff'),
408
+			url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.svg?ngjl88#icomoon'; ?>') format('svg');
409 409
 			font-weight: normal;
410 410
 			font-style: normal;
411 411
 		}
@@ -424,4 +424,4 @@  discard block
 block discarded – undo
424 424
 	<?php
425 425
 }
426 426
 
427
-add_action( 'admin_head', 'give_admin_icon' );
427
+add_action('admin_head', 'give_admin_icon');
Please login to merge, or discard this patch.
includes/actions.php 1 patch
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -25,14 +25,14 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function give_get_actions() {
27 27
 
28
-	$_get_action = ! empty( $_GET['give_action'] ) ? $_GET['give_action'] : null;
28
+	$_get_action = ! empty($_GET['give_action']) ? $_GET['give_action'] : null;
29 29
 
30 30
 	// Add backward compatibility to give-action param ( $_GET )
31
-	if ( empty( $_get_action ) ) {
32
-		$_get_action = ! empty( $_GET['give-action'] ) ? $_GET['give-action'] : null;
31
+	if (empty($_get_action)) {
32
+		$_get_action = ! empty($_GET['give-action']) ? $_GET['give-action'] : null;
33 33
 	}
34 34
 
35
-	if ( isset( $_get_action ) ) {
35
+	if (isset($_get_action)) {
36 36
 		/**
37 37
 		 * Fires in WordPress init or admin init, when give_action is present in $_GET.
38 38
 		 *
@@ -40,12 +40,12 @@  discard block
 block discarded – undo
40 40
 		 *
41 41
 		 * @param array $_GET Array of HTTP GET variables.
42 42
 		 */
43
-		do_action( "give_{$_get_action}", $_GET );
43
+		do_action("give_{$_get_action}", $_GET);
44 44
 	}
45 45
 
46 46
 }
47 47
 
48
-add_action( 'init', 'give_get_actions' );
48
+add_action('init', 'give_get_actions');
49 49
 
50 50
 /**
51 51
  * Hooks Give actions, when present in the $_POST super global. Every give_action
@@ -58,14 +58,14 @@  discard block
 block discarded – undo
58 58
  */
59 59
 function give_post_actions() {
60 60
 
61
-	$_post_action = ! empty( $_POST['give_action'] ) ? $_POST['give_action'] : null;
61
+	$_post_action = ! empty($_POST['give_action']) ? $_POST['give_action'] : null;
62 62
 
63 63
 	// Add backward compatibility to give-action param ( $_POST ).
64
-	if ( empty( $_post_action ) ) {
65
-		$_post_action = ! empty( $_POST['give-action'] ) ? $_POST['give-action'] : null;
64
+	if (empty($_post_action)) {
65
+		$_post_action = ! empty($_POST['give-action']) ? $_POST['give-action'] : null;
66 66
 	}
67 67
 
68
-	if ( isset( $_post_action ) ) {
68
+	if (isset($_post_action)) {
69 69
 		/**
70 70
 		 * Fires in WordPress init or admin init, when give_action is present in $_POST.
71 71
 		 *
@@ -73,12 +73,12 @@  discard block
 block discarded – undo
73 73
 		 *
74 74
 		 * @param array $_POST Array of HTTP POST variables.
75 75
 		 */
76
-		do_action( "give_{$_post_action}", $_POST );
76
+		do_action("give_{$_post_action}", $_POST);
77 77
 	}
78 78
 
79 79
 }
80 80
 
81
-add_action( 'init', 'give_post_actions' );
81
+add_action('init', 'give_post_actions');
82 82
 
83 83
 /**
84 84
  * Connect WordPress user with Donor.
@@ -90,29 +90,29 @@  discard block
 block discarded – undo
90 90
  *
91 91
  * @return void
92 92
  */
93
-function give_connect_donor_to_wpuser( $user_id, $user_data ) {
93
+function give_connect_donor_to_wpuser($user_id, $user_data) {
94 94
 	/* @var Give_Donor $donor */
95
-	$donor = new Give_Donor( $user_data['user_email'] );
95
+	$donor = new Give_Donor($user_data['user_email']);
96 96
 
97 97
 	// Validate donor id and check if do nor is already connect to wp user or not.
98
-	if ( $donor->id && ! $donor->user_id ) {
98
+	if ($donor->id && ! $donor->user_id) {
99 99
 
100 100
 		// Update donor user_id.
101
-		if ( $donor->update( array( 'user_id' => $user_id ) ) ) {
102
-			$donor_note = sprintf( esc_html__( 'WordPress user #%d is connected to #%d', 'give' ), $user_id, $donor->id );
103
-			$donor->add_note( $donor_note );
101
+		if ($donor->update(array('user_id' => $user_id))) {
102
+			$donor_note = sprintf(esc_html__('WordPress user #%d is connected to #%d', 'give'), $user_id, $donor->id);
103
+			$donor->add_note($donor_note);
104 104
 
105 105
 			// Update user_id meta in payments.
106
-			if ( ! empty( $donor->payment_ids ) && ( $donations = explode( ',', $donor->payment_ids ) ) ) {
107
-				foreach ( $donations as $donation ) {
108
-					give_update_meta( $donation, '_give_payment_user_id', $user_id );
106
+			if ( ! empty($donor->payment_ids) && ($donations = explode(',', $donor->payment_ids))) {
107
+				foreach ($donations as $donation) {
108
+					give_update_meta($donation, '_give_payment_user_id', $user_id);
109 109
 				}
110 110
 			}
111 111
 		}
112 112
 	}
113 113
 }
114 114
 
115
-add_action( 'give_insert_user', 'give_connect_donor_to_wpuser', 10, 2 );
115
+add_action('give_insert_user', 'give_connect_donor_to_wpuser', 10, 2);
116 116
 
117 117
 
118 118
 /**
@@ -126,45 +126,45 @@  discard block
 block discarded – undo
126 126
  */
127 127
 function give_validate_license_when_site_migrated() {
128 128
 	// Store current site address if not already stored.
129
-	$home_url_parts              = parse_url( home_url() );
130
-	$home_url                    = isset( $home_url_parts['host'] ) ? $home_url_parts['host'] : false;
131
-	$home_url                    .= isset( $home_url_parts['path'] ) ? $home_url_parts['path'] : '';
132
-	$site_address_before_migrate = get_option( 'give_site_address_before_migrate' );
129
+	$home_url_parts              = parse_url(home_url());
130
+	$home_url                    = isset($home_url_parts['host']) ? $home_url_parts['host'] : false;
131
+	$home_url .= isset($home_url_parts['path']) ? $home_url_parts['path'] : '';
132
+	$site_address_before_migrate = get_option('give_site_address_before_migrate');
133 133
 
134 134
 	// Need $home_url to proceed.
135
-	if ( ! $home_url ) {
135
+	if ( ! $home_url) {
136 136
 		return;
137 137
 	}
138 138
 
139 139
 	// Save site address.
140
-	if ( ! $site_address_before_migrate ) {
140
+	if ( ! $site_address_before_migrate) {
141 141
 		// Update site address.
142
-		update_option( 'give_site_address_before_migrate', $home_url );
142
+		update_option('give_site_address_before_migrate', $home_url);
143 143
 
144 144
 		return;
145 145
 	}
146 146
 
147 147
 	// Backwards compat. for before when we were storing URL scheme.
148
-	if ( strpos( $site_address_before_migrate, 'http' ) ) {
149
-		$site_address_before_migrate = parse_url( $site_address_before_migrate );
150
-		$site_address_before_migrate = isset( $site_address_before_migrate['host'] ) ? $site_address_before_migrate['host'] : false;
148
+	if (strpos($site_address_before_migrate, 'http')) {
149
+		$site_address_before_migrate = parse_url($site_address_before_migrate);
150
+		$site_address_before_migrate = isset($site_address_before_migrate['host']) ? $site_address_before_migrate['host'] : false;
151 151
 
152 152
 		// Add path for multisite installs.
153
-		$site_address_before_migrate .= isset( $site_address_before_migrate['path'] ) ? $site_address_before_migrate['path'] : '';
153
+		$site_address_before_migrate .= isset($site_address_before_migrate['path']) ? $site_address_before_migrate['path'] : '';
154 154
 	}
155 155
 
156 156
 	// If the two URLs don't match run CRON.
157
-	if ( $home_url !== $site_address_before_migrate ) {
157
+	if ($home_url !== $site_address_before_migrate) {
158 158
 		// Immediately run cron.
159
-		wp_schedule_single_event( time(), 'give_validate_license_when_site_migrated' );
159
+		wp_schedule_single_event(time(), 'give_validate_license_when_site_migrated');
160 160
 
161 161
 		// Update site address.
162
-		update_option( 'give_site_address_before_migrate', $home_url );
162
+		update_option('give_site_address_before_migrate', $home_url);
163 163
 	}
164 164
 
165 165
 }
166 166
 
167
-add_action( 'admin_init', 'give_validate_license_when_site_migrated' );
167
+add_action('admin_init', 'give_validate_license_when_site_migrated');
168 168
 
169 169
 
170 170
 /**
@@ -174,19 +174,19 @@  discard block
 block discarded – undo
174 174
  *
175 175
  * @param $data
176 176
  */
177
-function give_donor_batch_export_complete( $data ) {
177
+function give_donor_batch_export_complete($data) {
178 178
 	// Remove donor ids cache.
179 179
 	if (
180
-		isset( $data['class'] )
180
+		isset($data['class'])
181 181
 		&& 'Give_Batch_Donors_Export' === $data['class']
182
-		&& ! empty( $data['forms'] )
183
-		&& isset( $data['give_export_option']['query_id'] )
182
+		&& ! empty($data['forms'])
183
+		&& isset($data['give_export_option']['query_id'])
184 184
 	) {
185
-		Give_Cache::delete( Give_Cache::get_key( $data['give_export_option']['query_id'] ) );
185
+		Give_Cache::delete(Give_Cache::get_key($data['give_export_option']['query_id']));
186 186
 	}
187 187
 }
188 188
 
189
-add_action( 'give_file_export_complete', 'give_donor_batch_export_complete' );
189
+add_action('give_file_export_complete', 'give_donor_batch_export_complete');
190 190
 
191 191
 /**
192 192
  * Print css for wordpress setting pages.
@@ -197,12 +197,12 @@  discard block
 block discarded – undo
197 197
 	/* @var WP_Screen $screen */
198 198
 	$screen = get_current_screen();
199 199
 
200
-	if ( ! ( $screen instanceof WP_Screen ) ) {
200
+	if ( ! ($screen instanceof WP_Screen)) {
201 201
 		return false;
202 202
 	}
203 203
 
204
-	switch ( true ) {
205
-		case ( 'plugins' === $screen->base || 'plugins-network' === $screen->base ):
204
+	switch (true) {
205
+		case ('plugins' === $screen->base || 'plugins-network' === $screen->base):
206 206
 			?>
207 207
 			<style>
208 208
 				tr.active.update + tr.give-addon-notice-tr td {
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 	}
240 240
 }
241 241
 
242
-add_action( 'admin_head', 'give_admin_quick_css' );
242
+add_action('admin_head', 'give_admin_quick_css');
243 243
 
244 244
 
245 245
 /**
@@ -251,28 +251,28 @@  discard block
 block discarded – undo
251 251
  *
252 252
  * @return void
253 253
  */
254
-function give_set_donation_levels_max_min_amount( $form_id ) {
254
+function give_set_donation_levels_max_min_amount($form_id) {
255 255
 	if (
256
-		( 'set' === $_POST['_give_price_option'] ) ||
257
-		( in_array( '_give_donation_levels', $_POST ) && count( $_POST['_give_donation_levels'] ) <= 0 ) ||
258
-		! ( $donation_levels_amounts = wp_list_pluck( $_POST['_give_donation_levels'], '_give_amount' ) )
256
+		('set' === $_POST['_give_price_option']) ||
257
+		(in_array('_give_donation_levels', $_POST) && count($_POST['_give_donation_levels']) <= 0) ||
258
+		! ($donation_levels_amounts = wp_list_pluck($_POST['_give_donation_levels'], '_give_amount'))
259 259
 	) {
260 260
 		// Delete old meta.
261
-		give_delete_meta( $form_id, '_give_levels_minimum_amount' );
262
-		give_delete_meta( $form_id, '_give_levels_maximum_amount' );
261
+		give_delete_meta($form_id, '_give_levels_minimum_amount');
262
+		give_delete_meta($form_id, '_give_levels_maximum_amount');
263 263
 
264 264
 		return;
265 265
 	}
266 266
 
267 267
 	// Sanitize donation level amounts.
268
-	$donation_levels_amounts = array_map( 'give_maybe_sanitize_amount', $donation_levels_amounts );
268
+	$donation_levels_amounts = array_map('give_maybe_sanitize_amount', $donation_levels_amounts);
269 269
 
270
-	$min_amount = min( $donation_levels_amounts );
271
-	$max_amount = max( $donation_levels_amounts );
270
+	$min_amount = min($donation_levels_amounts);
271
+	$max_amount = max($donation_levels_amounts);
272 272
 
273 273
 	// Set Minimum and Maximum amount for Multi Level Donation Forms.
274
-	give_update_meta( $form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount_for_db( $min_amount ) : 0 );
275
-	give_update_meta( $form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount_for_db( $max_amount ) : 0 );
274
+	give_update_meta($form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount_for_db($min_amount) : 0);
275
+	give_update_meta($form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount_for_db($max_amount) : 0);
276 276
 }
277 277
 
278
-add_action( 'give_pre_process_give_forms_meta', 'give_set_donation_levels_max_min_amount', 30 );
279 278
\ No newline at end of file
279
+add_action('give_pre_process_give_forms_meta', 'give_set_donation_levels_max_min_amount', 30);
280 280
\ No newline at end of file
Please login to merge, or discard this patch.
includes/payments/class-payments-query.php 1 patch
Spacing   +102 added lines, -102 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
 
@@ -65,10 +65,10 @@  discard block
 block discarded – undo
65 65
 	 *
66 66
 	 * @param  $args array The array of arguments that can be passed in and used for setting up this payment query.
67 67
 	 */
68
-	public function __construct( $args = array() ) {
68
+	public function __construct($args = array()) {
69 69
 		$defaults = array(
70 70
 			'output'          => 'payments',
71
-			'post_type'       => array( 'give_payment' ),
71
+			'post_type'       => array('give_payment'),
72 72
 			'start_date'      => false,
73 73
 			'end_date'        => false,
74 74
 			'number'          => 20,
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 			'give_forms'      => null,
91 91
 		);
92 92
 
93
-		$this->args = $this->_args = wp_parse_args( $args, $defaults );
93
+		$this->args = $this->_args = wp_parse_args($args, $defaults);
94 94
 
95 95
 		$this->init();
96 96
 	}
@@ -104,11 +104,11 @@  discard block
 block discarded – undo
104 104
 	 * @param $query_var
105 105
 	 * @param $value
106 106
 	 */
107
-	public function __set( $query_var, $value ) {
108
-		if ( in_array( $query_var, array( 'meta_query', 'tax_query' ) ) ) {
109
-			$this->args[ $query_var ][] = $value;
107
+	public function __set($query_var, $value) {
108
+		if (in_array($query_var, array('meta_query', 'tax_query'))) {
109
+			$this->args[$query_var][] = $value;
110 110
 		} else {
111
-			$this->args[ $query_var ] = $value;
111
+			$this->args[$query_var] = $value;
112 112
 		}
113 113
 	}
114 114
 
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
 	 *
121 121
 	 * @param $query_var
122 122
 	 */
123
-	public function __unset( $query_var ) {
124
-		unset( $this->args[ $query_var ] );
123
+	public function __unset($query_var) {
124
+		unset($this->args[$query_var]);
125 125
 	}
126 126
 
127 127
 	/**
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 		$this->give_forms();
162 162
 		$this->gateway_filter();
163 163
 
164
-		add_filter( 'posts_orderby', array( $this, 'custom_orderby' ), 10, 2 );
164
+		add_filter('posts_orderby', array($this, 'custom_orderby'), 10, 2);
165 165
 	}
166 166
 
167 167
 	/**
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 	 */
173 173
 	private function unset_filters() {
174 174
 		$this->date_filter_post();
175
-		remove_filter( 'posts_orderby', array( $this, 'custom_orderby' ) );
175
+		remove_filter('posts_orderby', array($this, 'custom_orderby'));
176 176
 	}
177 177
 
178 178
 
@@ -199,9 +199,9 @@  discard block
 block discarded – undo
199 199
 		 *
200 200
 		 * @param Give_Payments_Query $this Payments query object.
201 201
 		 */
202
-		do_action( 'give_pre_get_payments', $this );
202
+		do_action('give_pre_get_payments', $this);
203 203
 
204
-		$query          = new WP_Query( $this->args );
204
+		$query          = new WP_Query($this->args);
205 205
 		$this->payments = array();
206 206
 
207 207
 		$custom_output = array(
@@ -209,18 +209,18 @@  discard block
 block discarded – undo
209 209
 			'give_payments',
210 210
 		);
211 211
 
212
-		if ( ! in_array( $this->args['output'], $custom_output ) ) {
212
+		if ( ! in_array($this->args['output'], $custom_output)) {
213 213
 			return $query->posts;
214 214
 		}
215 215
 
216
-		if ( $query->have_posts() ) {
217
-			while ( $query->have_posts() ) {
216
+		if ($query->have_posts()) {
217
+			while ($query->have_posts()) {
218 218
 				$query->the_post();
219 219
 
220 220
 				$payment_id = get_post()->ID;
221
-				$payment    = new Give_Payment( $payment_id );
221
+				$payment    = new Give_Payment($payment_id);
222 222
 
223
-				$this->payments[] = apply_filters( 'give_payment', $payment, $payment_id, $this );
223
+				$this->payments[] = apply_filters('give_payment', $payment, $payment_id, $this);
224 224
 			}
225 225
 
226 226
 			wp_reset_postdata();
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 		 *
237 237
 		 * @param Give_Payments_Query $this Payments query object.
238 238
 		 */
239
-		do_action( 'give_post_get_payments', $this );
239
+		do_action('give_post_get_payments', $this);
240 240
 
241 241
 		return $this->payments;
242 242
 	}
@@ -250,13 +250,13 @@  discard block
 block discarded – undo
250 250
 	 * @return void
251 251
 	 */
252 252
 	public function date_filter_pre() {
253
-		if ( ! ( $this->args['start_date'] || $this->args['end_date'] ) ) {
253
+		if ( ! ($this->args['start_date'] || $this->args['end_date'])) {
254 254
 			return;
255 255
 		}
256 256
 
257
-		$this->setup_dates( $this->args['start_date'], $this->args['end_date'] );
257
+		$this->setup_dates($this->args['start_date'], $this->args['end_date']);
258 258
 
259
-		add_filter( 'posts_where', array( $this, 'payments_where' ) );
259
+		add_filter('posts_where', array($this, 'payments_where'));
260 260
 	}
261 261
 
262 262
 	/**
@@ -269,11 +269,11 @@  discard block
 block discarded – undo
269 269
 	 * @return void
270 270
 	 */
271 271
 	public function date_filter_post() {
272
-		if ( ! ( $this->args['start_date'] || $this->args['end_date'] ) ) {
272
+		if ( ! ($this->args['start_date'] || $this->args['end_date'])) {
273 273
 			return;
274 274
 		}
275 275
 
276
-		remove_filter( 'posts_where', array( $this, 'payments_where' ) );
276
+		remove_filter('posts_where', array($this, 'payments_where'));
277 277
 	}
278 278
 
279 279
 	/**
@@ -285,12 +285,12 @@  discard block
 block discarded – undo
285 285
 	 * @return void
286 286
 	 */
287 287
 	public function status() {
288
-		if ( ! isset( $this->args['status'] ) ) {
288
+		if ( ! isset($this->args['status'])) {
289 289
 			return;
290 290
 		}
291 291
 
292
-		$this->__set( 'post_status', $this->args['status'] );
293
-		$this->__unset( 'status' );
292
+		$this->__set('post_status', $this->args['status']);
293
+		$this->__unset('status');
294 294
 	}
295 295
 
296 296
 	/**
@@ -302,12 +302,12 @@  discard block
 block discarded – undo
302 302
 	 * @return void
303 303
 	 */
304 304
 	public function page() {
305
-		if ( ! isset( $this->args['page'] ) ) {
305
+		if ( ! isset($this->args['page'])) {
306 306
 			return;
307 307
 		}
308 308
 
309
-		$this->__set( 'paged', $this->args['page'] );
310
-		$this->__unset( 'page' );
309
+		$this->__set('paged', $this->args['page']);
310
+		$this->__unset('page');
311 311
 	}
312 312
 
313 313
 	/**
@@ -320,17 +320,17 @@  discard block
 block discarded – undo
320 320
 	 */
321 321
 	public function per_page() {
322 322
 
323
-		if ( ! isset( $this->args['number'] ) ) {
323
+		if ( ! isset($this->args['number'])) {
324 324
 			return;
325 325
 		}
326 326
 
327
-		if ( $this->args['number'] == - 1 ) {
328
-			$this->__set( 'nopaging', true );
327
+		if ($this->args['number'] == - 1) {
328
+			$this->__set('nopaging', true);
329 329
 		} else {
330
-			$this->__set( 'posts_per_page', $this->args['number'] );
330
+			$this->__set('posts_per_page', $this->args['number']);
331 331
 		}
332 332
 
333
-		$this->__unset( 'number' );
333
+		$this->__unset('number');
334 334
 	}
335 335
 
336 336
 	/**
@@ -342,12 +342,12 @@  discard block
 block discarded – undo
342 342
 	 * @return void
343 343
 	 */
344 344
 	public function month() {
345
-		if ( ! isset( $this->args['month'] ) ) {
345
+		if ( ! isset($this->args['month'])) {
346 346
 			return;
347 347
 		}
348 348
 
349
-		$this->__set( 'monthnum', $this->args['month'] );
350
-		$this->__unset( 'month' );
349
+		$this->__set('monthnum', $this->args['month']);
350
+		$this->__unset('month');
351 351
 	}
352 352
 
353 353
 	/**
@@ -359,23 +359,23 @@  discard block
 block discarded – undo
359 359
 	 * @return void
360 360
 	 */
361 361
 	public function orderby() {
362
-		switch ( $this->args['orderby'] ) {
362
+		switch ($this->args['orderby']) {
363 363
 			case 'amount':
364
-				$this->__set( 'orderby', 'meta_value_num' );
365
-				$this->__set( 'meta_key', '_give_payment_total' );
364
+				$this->__set('orderby', 'meta_value_num');
365
+				$this->__set('meta_key', '_give_payment_total');
366 366
 				break;
367 367
 
368 368
 			case 'status':
369
-				$this->__set( 'orderby', 'post_status' );
369
+				$this->__set('orderby', 'post_status');
370 370
 				break;
371 371
 
372 372
 			case 'donation_form':
373
-				$this->__set( 'orderby', 'meta_value' );
374
-				$this->__set( 'meta_key', '_give_payment_form_title' );
373
+				$this->__set('orderby', 'meta_value');
374
+				$this->__set('meta_key', '_give_payment_form_title');
375 375
 				break;
376 376
 
377 377
 			default:
378
-				$this->__set( 'orderby', $this->args['orderby'] );
378
+				$this->__set('orderby', $this->args['orderby']);
379 379
 				break;
380 380
 		}
381 381
 	}
@@ -392,19 +392,19 @@  discard block
 block discarded – undo
392 392
 	 *
393 393
 	 * @return mixed
394 394
 	 */
395
-	public function custom_orderby( $order, $query ) {
395
+	public function custom_orderby($order, $query) {
396 396
 
397
-		if ( ! empty( $query->query['post_type'] ) ) {
398
-			$post_types = is_array( $query->query['post_type'] ) ? $query->query['post_type'] : array( $query->query['post_type'] );
397
+		if ( ! empty($query->query['post_type'])) {
398
+			$post_types = is_array($query->query['post_type']) ? $query->query['post_type'] : array($query->query['post_type']);
399 399
 
400
-			if ( ! in_array( 'give_payment', $post_types ) || is_array( $query->query['orderby'] ) ) {
400
+			if ( ! in_array('give_payment', $post_types) || is_array($query->query['orderby'])) {
401 401
 				return $order;
402 402
 			}
403 403
 
404 404
 			global $wpdb;
405
-			switch ( $query->query['orderby'] ) {
405
+			switch ($query->query['orderby']) {
406 406
 				case 'post_status':
407
-					$order = $wpdb->posts . '.post_status ' . strtoupper( $query->query['order'] );
407
+					$order = $wpdb->posts.'.post_status '.strtoupper($query->query['order']);
408 408
 					break;
409 409
 			}
410 410
 		}
@@ -421,11 +421,11 @@  discard block
 block discarded – undo
421 421
 	 * @return void
422 422
 	 */
423 423
 	public function user() {
424
-		if ( is_null( $this->args['user'] ) ) {
424
+		if (is_null($this->args['user'])) {
425 425
 			return;
426 426
 		}
427 427
 
428
-		if ( is_numeric( $this->args['user'] ) ) {
428
+		if (is_numeric($this->args['user'])) {
429 429
 			$user_key = '_give_payment_user_id';
430 430
 		} else {
431 431
 			$user_key = '_give_payment_user_email';
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
 	 * @return  void
448 448
 	 */
449 449
 	public function donor() {
450
-		if ( is_null( $this->args['donor'] ) || ! is_numeric( $this->args['donor'] ) ) {
450
+		if (is_null($this->args['donor']) || ! is_numeric($this->args['donor'])) {
451 451
 			return;
452 452
 		}
453 453
 
@@ -469,33 +469,33 @@  discard block
 block discarded – undo
469 469
 	 */
470 470
 	public function search() {
471 471
 
472
-		if ( ! isset( $this->args['s'] ) ) {
472
+		if ( ! isset($this->args['s'])) {
473 473
 			return;
474 474
 		}
475 475
 
476
-		$search = trim( $this->args['s'] );
476
+		$search = trim($this->args['s']);
477 477
 
478
-		if ( empty( $search ) ) {
478
+		if (empty($search)) {
479 479
 			return;
480 480
 		}
481 481
 
482
-		$is_email = is_email( $search ) || strpos( $search, '@' ) !== false;
483
-		$is_user  = strpos( $search, strtolower( 'user:' ) ) !== false;
482
+		$is_email = is_email($search) || strpos($search, '@') !== false;
483
+		$is_user  = strpos($search, strtolower('user:')) !== false;
484 484
 
485
-		if ( ! empty( $this->args['search_in_notes'] ) ) {
485
+		if ( ! empty($this->args['search_in_notes'])) {
486 486
 
487
-			$notes = give_get_payment_notes( 0, $search );
487
+			$notes = give_get_payment_notes(0, $search);
488 488
 
489
-			if ( ! empty( $notes ) ) {
489
+			if ( ! empty($notes)) {
490 490
 
491
-				$payment_ids = wp_list_pluck( (array) $notes, 'comment_post_ID' );
491
+				$payment_ids = wp_list_pluck((array) $notes, 'comment_post_ID');
492 492
 
493
-				$this->__set( 'post__in', $payment_ids );
493
+				$this->__set('post__in', $payment_ids);
494 494
 			}
495 495
 
496
-			$this->__unset( 's' );
496
+			$this->__unset('s');
497 497
 
498
-		} elseif ( $is_email || strlen( $search ) == 32 ) {
498
+		} elseif ($is_email || strlen($search) == 32) {
499 499
 
500 500
 			$key         = $is_email ? '_give_payment_user_email' : '_give_payment_purchase_key';
501 501
 			$search_meta = array(
@@ -504,19 +504,19 @@  discard block
 block discarded – undo
504 504
 				'compare' => 'LIKE',
505 505
 			);
506 506
 
507
-			$this->__set( 'meta_query', $search_meta );
508
-			$this->__unset( 's' );
507
+			$this->__set('meta_query', $search_meta);
508
+			$this->__unset('s');
509 509
 
510
-		} elseif ( $is_user ) {
510
+		} elseif ($is_user) {
511 511
 
512 512
 			$search_meta = array(
513 513
 				'key'   => '_give_payment_user_id',
514
-				'value' => trim( str_replace( 'user:', '', strtolower( $search ) ) ),
514
+				'value' => trim(str_replace('user:', '', strtolower($search))),
515 515
 			);
516 516
 
517
-			$this->__set( 'meta_query', $search_meta );
517
+			$this->__set('meta_query', $search_meta);
518 518
 
519
-			if ( give_get_option( 'enable_sequential' ) ) {
519
+			if (give_get_option('enable_sequential')) {
520 520
 
521 521
 				$search_meta = array(
522 522
 					'key'     => '_give_payment_number',
@@ -524,19 +524,19 @@  discard block
 block discarded – undo
524 524
 					'compare' => 'LIKE',
525 525
 				);
526 526
 
527
-				$this->__set( 'meta_query', $search_meta );
527
+				$this->__set('meta_query', $search_meta);
528 528
 
529 529
 				$this->args['meta_query']['relation'] = 'OR';
530 530
 
531 531
 			}
532 532
 
533
-			$this->__unset( 's' );
533
+			$this->__unset('s');
534 534
 
535 535
 		} elseif (
536
-			give_get_option( 'enable_sequential' ) &&
536
+			give_get_option('enable_sequential') &&
537 537
 			(
538
-				false !== strpos( $search, give_get_option( 'sequential_prefix' ) ) ||
539
-				false !== strpos( $search, give_get_option( 'sequential_postfix' ) )
538
+				false !== strpos($search, give_get_option('sequential_prefix')) ||
539
+				false !== strpos($search, give_get_option('sequential_postfix'))
540 540
 			)
541 541
 		) {
542 542
 
@@ -546,29 +546,29 @@  discard block
 block discarded – undo
546 546
 				'compare' => 'LIKE',
547 547
 			);
548 548
 
549
-			$this->__set( 'meta_query', $search_meta );
550
-			$this->__unset( 's' );
549
+			$this->__set('meta_query', $search_meta);
550
+			$this->__unset('s');
551 551
 
552
-		} elseif ( is_numeric( $search ) ) {
552
+		} elseif (is_numeric($search)) {
553 553
 
554
-			$post = get_post( $search );
554
+			$post = get_post($search);
555 555
 
556
-			if ( is_object( $post ) && $post->post_type == 'give_payment' ) {
556
+			if (is_object($post) && $post->post_type == 'give_payment') {
557 557
 
558 558
 				$arr   = array();
559 559
 				$arr[] = $search;
560
-				$this->__set( 'post__in', $arr );
561
-				$this->__unset( 's' );
560
+				$this->__set('post__in', $arr);
561
+				$this->__unset('s');
562 562
 			}
563
-		} elseif ( '#' == substr( $search, 0, 1 ) ) {
563
+		} elseif ('#' == substr($search, 0, 1)) {
564 564
 
565
-			$search = str_replace( '#:', '', $search );
566
-			$search = str_replace( '#', '', $search );
567
-			$this->__set( 'give_forms', $search );
568
-			$this->__unset( 's' );
565
+			$search = str_replace('#:', '', $search);
566
+			$search = str_replace('#', '', $search);
567
+			$this->__set('give_forms', $search);
568
+			$this->__unset('s');
569 569
 
570 570
 		} else {
571
-			$this->__set( 's', $search );
571
+			$this->__set('s', $search);
572 572
 
573 573
 		}
574 574
 
@@ -583,8 +583,8 @@  discard block
 block discarded – undo
583 583
 	 * @return void
584 584
 	 */
585 585
 	public function mode() {
586
-		if ( empty( $this->args['mode'] ) || $this->args['mode'] == 'all' ) {
587
-			$this->__unset( 'mode' );
586
+		if (empty($this->args['mode']) || $this->args['mode'] == 'all') {
587
+			$this->__unset('mode');
588 588
 
589 589
 			return;
590 590
 		}
@@ -606,10 +606,10 @@  discard block
 block discarded – undo
606 606
 	 * @return void
607 607
 	 */
608 608
 	public function children() {
609
-		if ( empty( $this->args['children'] ) ) {
610
-			$this->__set( 'post_parent', 0 );
609
+		if (empty($this->args['children'])) {
610
+			$this->__set('post_parent', 0);
611 611
 		}
612
-		$this->__unset( 'children' );
612
+		$this->__unset('children');
613 613
 	}
614 614
 
615 615
 	/**
@@ -622,13 +622,13 @@  discard block
 block discarded – undo
622 622
 	 */
623 623
 	public function give_forms() {
624 624
 
625
-		if ( empty( $this->args['give_forms'] ) ) {
625
+		if (empty($this->args['give_forms'])) {
626 626
 			return;
627 627
 		}
628 628
 
629 629
 		$compare = '=';
630 630
 
631
-		if ( is_array( $this->args['give_forms'] ) ) {
631
+		if (is_array($this->args['give_forms'])) {
632 632
 			$compare = 'IN';
633 633
 		}
634 634
 
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
 			)
643 643
 		);
644 644
 
645
-		$this->__unset( 'give_forms' );
645
+		$this->__unset('give_forms');
646 646
 
647 647
 	}
648 648
 
@@ -656,13 +656,13 @@  discard block
 block discarded – undo
656 656
 	 */
657 657
 	public function gateway_filter() {
658 658
 
659
-		if ( empty( $this->args['gateway'] ) ) {
659
+		if (empty($this->args['gateway'])) {
660 660
 			return;
661 661
 		}
662 662
 
663 663
 		$compare = '=';
664 664
 
665
-		if ( is_array( $this->args['gateway'] ) ) {
665
+		if (is_array($this->args['gateway'])) {
666 666
 			$compare = 'IN';
667 667
 		}
668 668
 
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
 			)
677 677
 		);
678 678
 
679
-		$this->__unset( 'gateway' );
679
+		$this->__unset('gateway');
680 680
 
681 681
 	}
682 682
 
Please login to merge, or discard this patch.
includes/class-notices.php 1 patch
Spacing   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -53,21 +53,21 @@  discard block
 block discarded – undo
53 53
 	 * @since 1.8.9
54 54
 	 */
55 55
 	public function __construct() {
56
-		add_action( 'admin_notices', array( $this, 'render_admin_notices' ), 999 );
57
-		add_action( 'give_dismiss_notices', array( $this, 'dismiss_notices' ) );
56
+		add_action('admin_notices', array($this, 'render_admin_notices'), 999);
57
+		add_action('give_dismiss_notices', array($this, 'dismiss_notices'));
58 58
 
59
-		add_action( 'give_frontend_notices', array( $this, 'render_frontend_notices' ), 999 );
60
-		add_action( 'give_donation_form_before_personal_info', array( $this, 'render_frontend_notices' ) );
61
-		add_action( 'give_ajax_donation_errors', array( $this, 'render_frontend_notices' ) );
59
+		add_action('give_frontend_notices', array($this, 'render_frontend_notices'), 999);
60
+		add_action('give_donation_form_before_personal_info', array($this, 'render_frontend_notices'));
61
+		add_action('give_ajax_donation_errors', array($this, 'render_frontend_notices'));
62 62
 
63 63
 		/**
64 64
 		 * Backward compatibility for deprecated params.
65 65
 		 *
66 66
 		 * @since 1.8.14
67 67
 		 */
68
-		add_filter( 'give_register_notice_args', array( $this, 'bc_deprecated_params' ) );
69
-		add_filter( 'give_frontend_errors_args', array( $this, 'bc_deprecated_params' ) );
70
-		add_filter( 'give_frontend_notice_args', array( $this, 'bc_deprecated_params' ) );
68
+		add_filter('give_register_notice_args', array($this, 'bc_deprecated_params'));
69
+		add_filter('give_frontend_errors_args', array($this, 'bc_deprecated_params'));
70
+		add_filter('give_frontend_notice_args', array($this, 'bc_deprecated_params'));
71 71
 	}
72 72
 
73 73
 	/**
@@ -80,19 +80,19 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @return array
82 82
 	 */
83
-	public function bc_deprecated_params( $args ) {
83
+	public function bc_deprecated_params($args) {
84 84
 		/**
85 85
 		 *  Param: auto_dismissible
86 86
 		 *  deprecated in 1.8.14
87 87
 		 *
88 88
 		 *  Check if auto_dismissible is set and it true then unset and change dismissible parameter value to auto
89 89
 		 */
90
-		if ( isset( $args['auto_dismissible'] ) ) {
91
-			if ( ! empty( $args['auto_dismissible'] ) ) {
90
+		if (isset($args['auto_dismissible'])) {
91
+			if ( ! empty($args['auto_dismissible'])) {
92 92
 				$args['dismissible'] = 'auto';
93 93
 			}
94 94
 			// unset auto_dismissible as it has been deprecated.
95
-			unset( $args['auto_dismissible'] );
95
+			unset($args['auto_dismissible']);
96 96
 		}
97 97
 
98 98
 		return $args;
@@ -108,9 +108,9 @@  discard block
 block discarded – undo
108 108
 	 *
109 109
 	 * @return bool
110 110
 	 */
111
-	public function register_notice( $notice_args ) {
111
+	public function register_notice($notice_args) {
112 112
 		// Bailout.
113
-		if ( empty( $notice_args['id'] ) || array_key_exists( $notice_args['id'], self::$notices ) ) {
113
+		if (empty($notice_args['id']) || array_key_exists($notice_args['id'], self::$notices)) {
114 114
 			return false;
115 115
 		}
116 116
 
@@ -159,39 +159,39 @@  discard block
 block discarded – undo
159 159
 		 *
160 160
 		 * @since 1.8.14
161 161
 		 */
162
-		$notice_args = apply_filters( 'give_register_notice_args', $notice_args );
162
+		$notice_args = apply_filters('give_register_notice_args', $notice_args);
163 163
 
164 164
 		// Set extra dismiss links if any.
165
-		if ( false !== strpos( $notice_args['description'], 'data-dismiss-interval' ) ) {
165
+		if (false !== strpos($notice_args['description'], 'data-dismiss-interval')) {
166 166
 
167
-			preg_match_all( "/data-([^\"]*)=\"([^\"]*)\"/", $notice_args['description'], $extra_notice_dismiss_link );
167
+			preg_match_all("/data-([^\"]*)=\"([^\"]*)\"/", $notice_args['description'], $extra_notice_dismiss_link);
168 168
 
169
-			if ( ! empty( $extra_notice_dismiss_link ) ) {
170
-				$extra_notice_dismiss_links = array_chunk( current( $extra_notice_dismiss_link ), 3 );
171
-				foreach ( $extra_notice_dismiss_links as $extra_notice_dismiss_link ) {
169
+			if ( ! empty($extra_notice_dismiss_link)) {
170
+				$extra_notice_dismiss_links = array_chunk(current($extra_notice_dismiss_link), 3);
171
+				foreach ($extra_notice_dismiss_links as $extra_notice_dismiss_link) {
172 172
 					// Create array og key ==> value by parsing query string created after renaming data attributes.
173
-					$data_attribute_query_str = str_replace( array( 'data-', '-', '"' ), array(
173
+					$data_attribute_query_str = str_replace(array('data-', '-', '"'), array(
174 174
 						'',
175 175
 						'_',
176 176
 						'',
177
-					), implode( '&', $extra_notice_dismiss_link ) );
177
+					), implode('&', $extra_notice_dismiss_link));
178 178
 
179
-					$notice_args['extra_links'][] = wp_parse_args( $data_attribute_query_str );
179
+					$notice_args['extra_links'][] = wp_parse_args($data_attribute_query_str);
180 180
 				}
181 181
 			}
182 182
 		}
183 183
 
184 184
 
185
-		self::$notices[ $notice_args['id'] ] = $notice_args;
185
+		self::$notices[$notice_args['id']] = $notice_args;
186 186
 
187 187
 		// Auto set show param if not already set.
188
-		if ( ! isset( self::$notices[ $notice_args['id'] ]['show'] ) ) {
189
-			self::$notices[ $notice_args['id'] ]['show'] = $this->is_notice_dismissed( $notice_args ) ? false : true;
188
+		if ( ! isset(self::$notices[$notice_args['id']]['show'])) {
189
+			self::$notices[$notice_args['id']]['show'] = $this->is_notice_dismissed($notice_args) ? false : true;
190 190
 		}
191 191
 
192 192
 		// Auto set time interval for shortly.
193
-		if ( 'shortly' === self::$notices[ $notice_args['id'] ]['dismiss_interval'] ) {
194
-			self::$notices[ $notice_args['id'] ]['dismiss_interval_time'] = DAY_IN_SECONDS;
193
+		if ('shortly' === self::$notices[$notice_args['id']]['dismiss_interval']) {
194
+			self::$notices[$notice_args['id']]['dismiss_interval_time'] = DAY_IN_SECONDS;
195 195
 		}
196 196
 
197 197
 		return true;
@@ -205,51 +205,51 @@  discard block
 block discarded – undo
205 205
 	 */
206 206
 	public function render_admin_notices() {
207 207
 		// Bailout.
208
-		if ( empty( self::$notices ) ) {
208
+		if (empty(self::$notices)) {
209 209
 			return;
210 210
 		}
211 211
 
212 212
 		$output = '';
213 213
 
214
-		foreach ( self::$notices as $notice_id => $notice ) {
214
+		foreach (self::$notices as $notice_id => $notice) {
215 215
 			// Check flag set to true to show notice.
216
-			if ( ! $notice['show'] ) {
216
+			if ( ! $notice['show']) {
217 217
 				continue;
218 218
 			}
219 219
 
220 220
 
221 221
 			// Render custom html.
222
-			if( ! empty( $notice['description_html'] ) ) {
222
+			if ( ! empty($notice['description_html'])) {
223 223
 				$output .= "{$notice['description_html']} \n";
224 224
 				continue;
225 225
 			}
226 226
 
227 227
 			// Check if notice dismissible or not.
228
-			if ( ! self::$has_auto_dismissible_notice ) {
229
-				self::$has_auto_dismissible_notice = ( 'auto' === $notice['dismissible'] );
228
+			if ( ! self::$has_auto_dismissible_notice) {
229
+				self::$has_auto_dismissible_notice = ('auto' === $notice['dismissible']);
230 230
 			}
231 231
 
232 232
 			// Check if notice dismissible or not.
233
-			if ( ! self::$has_dismiss_interval_notice ) {
233
+			if ( ! self::$has_dismiss_interval_notice) {
234 234
 				self::$has_dismiss_interval_notice = $notice['dismiss_interval'];
235 235
 			}
236 236
 
237
-			$css_id = ( false === strpos( $notice['id'], 'give' ) ? "give-{$notice['id']}" : $notice['id'] );
237
+			$css_id = (false === strpos($notice['id'], 'give') ? "give-{$notice['id']}" : $notice['id']);
238 238
 
239
-			$css_class = 'give-notice notice ' . ( empty( $notice['dismissible'] ) ? 'non' : 'is' ) . "-dismissible {$notice['type']} notice-{$notice['type']}";
240
-			$output    .= sprintf(
241
-				'<div id="%1$s" class="%2$s" data-dismissible="%3$s" data-dismissible-type="%4$s" data-dismiss-interval="%5$s" data-notice-id="%6$s" data-security="%7$s" data-dismiss-interval-time="%8$s" style="display: none">' . " \n",
239
+			$css_class = 'give-notice notice '.(empty($notice['dismissible']) ? 'non' : 'is')."-dismissible {$notice['type']} notice-{$notice['type']}";
240
+			$output .= sprintf(
241
+				'<div id="%1$s" class="%2$s" data-dismissible="%3$s" data-dismissible-type="%4$s" data-dismiss-interval="%5$s" data-notice-id="%6$s" data-security="%7$s" data-dismiss-interval-time="%8$s" style="display: none">'." \n",
242 242
 				$css_id,
243 243
 				$css_class,
244
-				give_clean( $notice['dismissible'] ),
244
+				give_clean($notice['dismissible']),
245 245
 				$notice['dismissible_type'],
246 246
 				$notice['dismiss_interval'],
247 247
 				$notice['id'],
248
-				empty( $notice['dismissible_type'] ) ? '' : wp_create_nonce( "give_edit_{$notice_id}_notice" ),
248
+				empty($notice['dismissible_type']) ? '' : wp_create_nonce("give_edit_{$notice_id}_notice"),
249 249
 				$notice['dismiss_interval_time']
250 250
 			);
251 251
 
252
-			$output .= ( 0 === strpos( $notice['description'], '<div' ) || 0 === strpos( $notice['description'], '<p' ) ? $notice['description'] : "<p>{$notice['description']}</p>" );
252
+			$output .= (0 === strpos($notice['description'], '<div') || 0 === strpos($notice['description'], '<p') ? $notice['description'] : "<p>{$notice['description']}</p>");
253 253
 			$output .= "</div> \n";
254 254
 		}
255 255
 
@@ -267,18 +267,18 @@  discard block
 block discarded – undo
267 267
 	 *
268 268
 	 * @param int $form_id
269 269
 	 */
270
-	public function render_frontend_notices( $form_id = 0 ) {
270
+	public function render_frontend_notices($form_id = 0) {
271 271
 		$errors = give_get_errors();
272 272
 
273
-		$request_form_id = isset( $_REQUEST['form-id'] ) ? absint( $_REQUEST['form-id'] ) : 0;
273
+		$request_form_id = isset($_REQUEST['form-id']) ? absint($_REQUEST['form-id']) : 0;
274 274
 
275 275
 		// Sanity checks first: Ensure that gateway returned errors display on the appropriate form.
276
-		if ( ! isset( $_POST['give_ajax'] ) && $request_form_id !== $form_id ) {
276
+		if ( ! isset($_POST['give_ajax']) && $request_form_id !== $form_id) {
277 277
 			return;
278 278
 		}
279 279
 
280
-		if ( $errors ) {
281
-			self::print_frontend_errors( $errors );
280
+		if ($errors) {
281
+			self::print_frontend_errors($errors);
282 282
 
283 283
 			give_clear_errors();
284 284
 		}
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 	 * @access private
292 292
 	 */
293 293
 	private function print_js() {
294
-		if ( self::$has_auto_dismissible_notice ) :
294
+		if (self::$has_auto_dismissible_notice) :
295 295
 			?>
296 296
 			<script>
297 297
 				jQuery(document).ready(function () {
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 			<?php
308 308
 		endif;
309 309
 
310
-		if ( self::$has_dismiss_interval_notice ) :
310
+		if (self::$has_dismiss_interval_notice) :
311 311
 			?>
312 312
 			<script>
313 313
 				jQuery(document).ready(function () {
@@ -386,29 +386,29 @@  discard block
 block discarded – undo
386 386
 	 * @access public
387 387
 	 */
388 388
 	public function dismiss_notices() {
389
-		$_post     = give_clean( $_POST );
390
-		$notice_id = esc_attr( $_post['notice_id'] );
389
+		$_post     = give_clean($_POST);
390
+		$notice_id = esc_attr($_post['notice_id']);
391 391
 
392 392
 		// Bailout.
393 393
 		if (
394
-			empty( $notice_id ) ||
395
-			empty( $_post['dismissible_type'] ) ||
396
-			empty( $_post['dismiss_interval'] ) ||
397
-			! check_ajax_referer( "give_edit_{$notice_id}_notice", '_wpnonce' )
394
+			empty($notice_id) ||
395
+			empty($_post['dismissible_type']) ||
396
+			empty($_post['dismiss_interval']) ||
397
+			! check_ajax_referer("give_edit_{$notice_id}_notice", '_wpnonce')
398 398
 		) {
399 399
 			wp_send_json_error();
400 400
 		}
401 401
 
402
-		$notice_key = Give()->notices->get_notice_key( $notice_id, $_post['dismiss_interval'] );
403
-		if ( 'user' === $_post['dismissible_type'] ) {
402
+		$notice_key = Give()->notices->get_notice_key($notice_id, $_post['dismiss_interval']);
403
+		if ('user' === $_post['dismissible_type']) {
404 404
 			$current_user = wp_get_current_user();
405
-			$notice_key   = Give()->notices->get_notice_key( $notice_id, $_post['dismiss_interval'], $current_user->ID );
405
+			$notice_key   = Give()->notices->get_notice_key($notice_id, $_post['dismiss_interval'], $current_user->ID);
406 406
 		}
407 407
 
408
-		$notice_dismiss_time = ! empty( $_post['dismiss_interval_time'] ) ? $_post['dismiss_interval_time'] : null;
408
+		$notice_dismiss_time = ! empty($_post['dismiss_interval_time']) ? $_post['dismiss_interval_time'] : null;
409 409
 
410 410
 		// Save option to hide notice.
411
-		Give_Cache::set( $notice_key, true, $notice_dismiss_time, true );
411
+		Give_Cache::set($notice_key, true, $notice_dismiss_time, true);
412 412
 
413 413
 		wp_send_json_success();
414 414
 	}
@@ -426,18 +426,18 @@  discard block
 block discarded – undo
426 426
 	 *
427 427
 	 * @return string
428 428
 	 */
429
-	public function get_notice_key( $notice_id, $dismiss_interval = null, $user_id = 0 ) {
429
+	public function get_notice_key($notice_id, $dismiss_interval = null, $user_id = 0) {
430 430
 		$notice_key = "_give_notice_{$notice_id}";
431 431
 
432
-		if ( ! empty( $dismiss_interval ) ) {
432
+		if ( ! empty($dismiss_interval)) {
433 433
 			$notice_key .= "_{$dismiss_interval}";
434 434
 		}
435 435
 
436
-		if ( $user_id ) {
436
+		if ($user_id) {
437 437
 			$notice_key .= "_{$user_id}";
438 438
 		}
439 439
 
440
-		$notice_key = sanitize_key( $notice_key );
440
+		$notice_key = sanitize_key($notice_key);
441 441
 
442 442
 		return $notice_key;
443 443
 	}
@@ -450,11 +450,11 @@  discard block
 block discarded – undo
450 450
 	 *
451 451
 	 * @return string
452 452
 	 */
453
-	public function get_dismiss_link( $notice_args ) {
453
+	public function get_dismiss_link($notice_args) {
454 454
 		$notice_args = wp_parse_args(
455 455
 			$notice_args,
456 456
 			array(
457
-				'title'                 => __( 'Click here', 'give' ),
457
+				'title'                 => __('Click here', 'give'),
458 458
 				'dismissible_type'      => '',
459 459
 				'dismiss_interval'      => '',
460 460
 				'dismiss_interval_time' => null,
@@ -481,31 +481,31 @@  discard block
 block discarded – undo
481 481
 	 *
482 482
 	 * @return bool|null
483 483
 	 */
484
-	public function is_notice_dismissed( $notice ) {
485
-		$notice_key          = $this->get_notice_key( $notice['id'], $notice['dismiss_interval'] );
484
+	public function is_notice_dismissed($notice) {
485
+		$notice_key          = $this->get_notice_key($notice['id'], $notice['dismiss_interval']);
486 486
 		$is_notice_dismissed = false;
487 487
 
488
-		if ( 'user' === $notice['dismissible_type'] ) {
488
+		if ('user' === $notice['dismissible_type']) {
489 489
 			$current_user = wp_get_current_user();
490
-			$notice_key   = Give()->notices->get_notice_key( $notice['id'], $notice['dismiss_interval'], $current_user->ID );
490
+			$notice_key   = Give()->notices->get_notice_key($notice['id'], $notice['dismiss_interval'], $current_user->ID);
491 491
 		}
492 492
 
493
-		$notice_data = Give_Cache::get( $notice_key, true );
493
+		$notice_data = Give_Cache::get($notice_key, true);
494 494
 
495 495
 		// Find notice dismiss link status if notice has extra dismissible links.
496
-		if ( ( empty( $notice_data ) || is_wp_error( $notice_data ) ) && ! empty( $notice['extra_links'] ) ) {
496
+		if ((empty($notice_data) || is_wp_error($notice_data)) && ! empty($notice['extra_links'])) {
497 497
 
498
-			foreach ( $notice['extra_links'] as $extra_link ) {
499
-				$new_notice_data = wp_parse_args( $extra_link, $notice );
500
-				unset( $new_notice_data['extra_links'] );
498
+			foreach ($notice['extra_links'] as $extra_link) {
499
+				$new_notice_data = wp_parse_args($extra_link, $notice);
500
+				unset($new_notice_data['extra_links']);
501 501
 
502
-				if ( $is_notice_dismissed = $this->is_notice_dismissed( $new_notice_data ) ) {
502
+				if ($is_notice_dismissed = $this->is_notice_dismissed($new_notice_data)) {
503 503
 					return $is_notice_dismissed;
504 504
 				}
505 505
 			}
506 506
 		}
507 507
 
508
-		$is_notice_dismissed = ! empty( $notice_data ) && ! is_wp_error( $notice_data );
508
+		$is_notice_dismissed = ! empty($notice_data) && ! is_wp_error($notice_data);
509 509
 
510 510
 		return $is_notice_dismissed;
511 511
 	}
@@ -519,9 +519,9 @@  discard block
 block discarded – undo
519 519
 	 *
520 520
 	 * @param array $errors
521 521
 	 */
522
-	public static function print_frontend_errors( $errors ) {
522
+	public static function print_frontend_errors($errors) {
523 523
 		// Bailout.
524
-		if ( ! $errors ) {
524
+		if ( ! $errors) {
525 525
 			return;
526 526
 		}
527 527
 
@@ -536,37 +536,37 @@  discard block
 block discarded – undo
536 536
 		);
537 537
 
538 538
 		// Note: we will remove give_errors class in future.
539
-		$classes = apply_filters( 'give_error_class', array( 'give_notices', 'give_errors' ) );
539
+		$classes = apply_filters('give_error_class', array('give_notices', 'give_errors'));
540 540
 
541
-		echo sprintf( '<div class="%s">', implode( ' ', $classes ) );
541
+		echo sprintf('<div class="%s">', implode(' ', $classes));
542 542
 
543 543
 		// Loop error codes and display errors.
544
-		foreach ( $errors as $error_id => $error ) {
544
+		foreach ($errors as $error_id => $error) {
545 545
 			// Backward compatibility v<1.8.11
546
-			if ( is_string( $error ) ) {
546
+			if (is_string($error)) {
547 547
 				$error = array(
548 548
 					'message'     => $error,
549 549
 					'notice_args' => array(),
550 550
 				);
551 551
 			}
552 552
 
553
-			$notice_args = wp_parse_args( $error['notice_args'], $default_notice_args );
553
+			$notice_args = wp_parse_args($error['notice_args'], $default_notice_args);
554 554
 
555 555
 			/**
556 556
 			 * Filter to modify Frontend Errors args before errors is display.
557 557
 			 *
558 558
 			 * @since 1.8.14
559 559
 			 */
560
-			$notice_args = apply_filters( 'give_frontend_errors_args', $notice_args );
560
+			$notice_args = apply_filters('give_frontend_errors_args', $notice_args);
561 561
 
562 562
 			echo sprintf(
563 563
 				'<div class="give_error give_notice" id="give_error_%1$s" data-dismissible="%2$s" data-dismiss-interval="%3$d">
564 564
 						<p><strong>%4$s</strong>: %5$s</p>
565 565
 					</div>',
566 566
 				$error_id,
567
-				give_clean( $notice_args['dismissible'] ),
568
-				absint( $notice_args['dismiss_interval'] ),
569
-				esc_html__( 'Error', 'give' ),
567
+				give_clean($notice_args['dismissible']),
568
+				absint($notice_args['dismiss_interval']),
569
+				esc_html__('Error', 'give'),
570 570
 				$error['message']
571 571
 			);
572 572
 		}
@@ -588,8 +588,8 @@  discard block
 block discarded – undo
588 588
 	 *
589 589
 	 * @return  string
590 590
 	 */
591
-	public static function print_frontend_notice( $message, $echo = true, $notice_type = 'warning', $notice_args = array() ) {
592
-		if ( empty( $message ) ) {
591
+	public static function print_frontend_notice($message, $echo = true, $notice_type = 'warning', $notice_args = array()) {
592
+		if (empty($message)) {
593 593
 			return '';
594 594
 		}
595 595
 
@@ -603,14 +603,14 @@  discard block
 block discarded – undo
603 603
 			'dismiss_interval' => 5000,
604 604
 		);
605 605
 
606
-		$notice_args = wp_parse_args( $notice_args, $default_notice_args );
606
+		$notice_args = wp_parse_args($notice_args, $default_notice_args);
607 607
 
608 608
 		/**
609 609
 		 * Filter to modify Frontend notice args before notices is display.
610 610
 		 *
611 611
 		 * @since 1.8.14
612 612
 		 */
613
-		$notice_args = apply_filters( 'give_frontend_notice_args', $notice_args );
613
+		$notice_args = apply_filters('give_frontend_notice_args', $notice_args);
614 614
 
615 615
 		// Note: we will remove give_errors class in future.
616 616
 		$error = sprintf(
@@ -620,12 +620,12 @@  discard block
 block discarded – undo
620 620
 				</p>
621 621
 			</div>',
622 622
 			$notice_type,
623
-			give_clean( $notice_args['dismissible'] ),
624
-			absint( $notice_args['dismiss_interval'] ),
623
+			give_clean($notice_args['dismissible']),
624
+			absint($notice_args['dismiss_interval']),
625 625
 			$message
626 626
 		);
627 627
 
628
-		if ( ! $echo ) {
628
+		if ( ! $echo) {
629 629
 			return $error;
630 630
 		}
631 631
 
@@ -645,24 +645,24 @@  discard block
 block discarded – undo
645 645
 	 *
646 646
 	 * @return string
647 647
 	 */
648
-	public function print_admin_notices( $notice_args = array() ) {
648
+	public function print_admin_notices($notice_args = array()) {
649 649
 		// Bailout.
650
-		if ( empty( $notice_args['description'] ) ) {
650
+		if (empty($notice_args['description'])) {
651 651
 			return '';
652 652
 		}
653 653
 
654
-		$defaults    = array(
654
+		$defaults = array(
655 655
 			'id'          => '',
656 656
 			'echo'        => true,
657 657
 			'notice_type' => 'warning',
658 658
 			'dismissible' => true,
659 659
 		);
660
-		$notice_args = wp_parse_args( $notice_args, $defaults );
660
+		$notice_args = wp_parse_args($notice_args, $defaults);
661 661
 
662 662
 		$output    = '';
663
-		$css_id    = ! empty( $notice_args['id'] ) ? $notice_args['id'] : uniqid( 'give-inline-notice-' );
663
+		$css_id    = ! empty($notice_args['id']) ? $notice_args['id'] : uniqid('give-inline-notice-');
664 664
 		$css_class = "notice-{$notice_args['notice_type']} give-notice notice inline";
665
-		$css_class .= ( $notice_args['dismissible'] ) ? ' is-dismissible' : '';
665
+		$css_class .= ($notice_args['dismissible']) ? ' is-dismissible' : '';
666 666
 		$output    .= sprintf(
667 667
 			'<div id="%1$s" class="%2$s"><p>%3$s</p></div>',
668 668
 			$css_id,
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
 			$notice_args['description']
671 671
 		);
672 672
 
673
-		if ( ! $notice_args['echo'] ) {
673
+		if ( ! $notice_args['echo']) {
674 674
 			return $output;
675 675
 		}
676 676
 
Please login to merge, or discard this patch.
includes/shortcodes.php 1 patch
Spacing   +116 added lines, -116 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
 
@@ -23,40 +23,40 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return string|bool
25 25
  */
26
-function give_donation_history( $atts ) {
26
+function give_donation_history($atts) {
27 27
 
28
-	$donation_history_args = shortcode_atts( array(
28
+	$donation_history_args = shortcode_atts(array(
29 29
 		'id'             => true,
30 30
 		'date'           => true,
31 31
 		'donor'          => false,
32 32
 		'amount'         => true,
33 33
 		'status'         => false,
34 34
 		'payment_method' => false,
35
-	), $atts, 'donation_history' );
35
+	), $atts, 'donation_history');
36 36
 
37 37
 	// Always show receipt link.
38 38
 	$donation_history_args['details'] = true;
39 39
 
40 40
 	// Set Donation History Shortcode Arguments in session variable.
41
-	Give()->session->set( 'give_donation_history_args', $donation_history_args );
41
+	Give()->session->set('give_donation_history_args', $donation_history_args);
42 42
 
43 43
 	// If payment_key query arg exists, return receipt instead of donation history.
44
-	if ( isset( $_GET['payment_key'] ) ) {
44
+	if (isset($_GET['payment_key'])) {
45 45
 		ob_start();
46
-		echo give_receipt_shortcode( array() );
46
+		echo give_receipt_shortcode(array());
47 47
 
48 48
 		// Display donation history link only if it is not accessed via Receipt Access Link.
49
-		if ( give_get_receipt_session() ) {
49
+		if (give_get_receipt_session()) {
50 50
 			echo sprintf(
51 51
 				'<a href="%s">%s</a>',
52
-				esc_url( give_get_history_page_uri() ),
53
-				__( '&laquo; Return to All Donations', 'give' )
52
+				esc_url(give_get_history_page_uri()),
53
+				__('&laquo; Return to All Donations', 'give')
54 54
 			);
55 55
 		}
56 56
 		return ob_get_clean();
57 57
 	}
58 58
 
59
-	$email_access = give_get_option( 'email_access' );
59
+	$email_access = give_get_option('email_access');
60 60
 
61 61
 	/**
62 62
 	 * Determine access
@@ -67,31 +67,31 @@  discard block
 block discarded – undo
67 67
 	if (
68 68
 		is_user_logged_in() ||
69 69
 		false !== Give()->session->get_session_expiration() ||
70
-		( give_is_setting_enabled( $email_access ) && Give()->email_access->token_exists ) ||
70
+		(give_is_setting_enabled($email_access) && Give()->email_access->token_exists) ||
71 71
 		true === give_get_history_session()
72 72
 	) {
73 73
 		ob_start();
74
-		give_get_template_part( 'history', 'donations' );
74
+		give_get_template_part('history', 'donations');
75 75
 
76 76
 		return ob_get_clean();
77 77
 
78
-	} elseif ( give_is_setting_enabled( $email_access ) ) {
78
+	} elseif (give_is_setting_enabled($email_access)) {
79 79
 		// Is Email-based access enabled?
80 80
 		ob_start();
81
-		give_get_template_part( 'email', 'login-form' );
81
+		give_get_template_part('email', 'login-form');
82 82
 
83 83
 		return ob_get_clean();
84 84
 
85 85
 	} else {
86 86
 
87
-		$output = apply_filters( 'give_donation_history_nonuser_message', Give()->notices->print_frontend_notice( __( 'You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give' ), false ) );
88
-		$output .= do_shortcode( '[give_login]' );
87
+		$output = apply_filters('give_donation_history_nonuser_message', Give()->notices->print_frontend_notice(__('You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give'), false));
88
+		$output .= do_shortcode('[give_login]');
89 89
 
90 90
 		return $output;
91 91
 	}
92 92
 }
93 93
 
94
-add_shortcode( 'donation_history', 'give_donation_history' );
94
+add_shortcode('donation_history', 'give_donation_history');
95 95
 
96 96
 /**
97 97
  * Donation Form Shortcode
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
  *
105 105
  * @return string
106 106
  */
107
-function give_form_shortcode( $atts ) {
108
-	$atts = shortcode_atts( array(
107
+function give_form_shortcode($atts) {
108
+	$atts = shortcode_atts(array(
109 109
 		'id'                    => '',
110 110
 		'show_title'            => true,
111 111
 		'show_goal'             => true,
@@ -113,21 +113,21 @@  discard block
 block discarded – undo
113 113
 		'float_labels'          => '',
114 114
 		'display_style'         => '',
115 115
 		'continue_button_title' => '',
116
-	), $atts, 'give_form' );
116
+	), $atts, 'give_form');
117 117
 
118 118
 	// Convert string to bool.
119
-	$atts['show_title'] = filter_var( $atts['show_title'], FILTER_VALIDATE_BOOLEAN );
120
-	$atts['show_goal']  = filter_var( $atts['show_goal'], FILTER_VALIDATE_BOOLEAN );
119
+	$atts['show_title'] = filter_var($atts['show_title'], FILTER_VALIDATE_BOOLEAN);
120
+	$atts['show_goal']  = filter_var($atts['show_goal'], FILTER_VALIDATE_BOOLEAN);
121 121
 
122 122
 	//get the Give Form
123 123
 	ob_start();
124
-	give_get_donation_form( $atts );
124
+	give_get_donation_form($atts);
125 125
 	$final_output = ob_get_clean();
126 126
 
127
-	return apply_filters( 'give_donate_form', $final_output, $atts );
127
+	return apply_filters('give_donate_form', $final_output, $atts);
128 128
 }
129 129
 
130
-add_shortcode( 'give_form', 'give_form_shortcode' );
130
+add_shortcode('give_form', 'give_form_shortcode');
131 131
 
132 132
 /**
133 133
  * Donation Form Goal Shortcode.
@@ -140,37 +140,37 @@  discard block
 block discarded – undo
140 140
  *
141 141
  * @return string
142 142
  */
143
-function give_goal_shortcode( $atts ) {
144
-	$atts = shortcode_atts( array(
143
+function give_goal_shortcode($atts) {
144
+	$atts = shortcode_atts(array(
145 145
 		'id'        => '',
146 146
 		'show_text' => true,
147 147
 		'show_bar'  => true,
148
-	), $atts, 'give_goal' );
148
+	), $atts, 'give_goal');
149 149
 
150 150
 
151 151
 	//get the Give Form.
152 152
 	ob_start();
153 153
 
154 154
 	//Sanity check 1: ensure there is an ID Provided.
155
-	if ( empty( $atts['id'] ) ) {
156
-		Give()->notices->print_frontend_notice( __( 'The shortcode is missing Donation Form ID attribute.', 'give' ), true );
155
+	if (empty($atts['id'])) {
156
+		Give()->notices->print_frontend_notice(__('The shortcode is missing Donation Form ID attribute.', 'give'), true);
157 157
 	}
158 158
 
159 159
 	//Sanity check 2: Check the form even has Goals enabled.
160
-	if ( ! give_is_setting_enabled( give_get_meta( $atts['id'], '_give_goal_option', true ) ) ) {
160
+	if ( ! give_is_setting_enabled(give_get_meta($atts['id'], '_give_goal_option', true))) {
161 161
 
162
-		Give()->notices->print_frontend_notice( __( 'The form does not have Goals enabled.', 'give' ), true );
162
+		Give()->notices->print_frontend_notice(__('The form does not have Goals enabled.', 'give'), true);
163 163
 	} else {
164 164
 		//Passed all sanity checks: output Goal.
165
-		give_show_goal_progress( $atts['id'], $atts );
165
+		give_show_goal_progress($atts['id'], $atts);
166 166
 	}
167 167
 
168 168
 	$final_output = ob_get_clean();
169 169
 
170
-	return apply_filters( 'give_goal_shortcode_output', $final_output, $atts );
170
+	return apply_filters('give_goal_shortcode_output', $final_output, $atts);
171 171
 }
172 172
 
173
-add_shortcode( 'give_goal', 'give_goal_shortcode' );
173
+add_shortcode('give_goal', 'give_goal_shortcode');
174 174
 
175 175
 
176 176
 /**
@@ -187,22 +187,22 @@  discard block
 block discarded – undo
187 187
  *
188 188
  * @return string
189 189
  */
190
-function give_login_form_shortcode( $atts ) {
191
-	$atts = shortcode_atts( array(
190
+function give_login_form_shortcode($atts) {
191
+	$atts = shortcode_atts(array(
192 192
 		// Add backward compatibility for redirect attribute.
193 193
 		'redirect' => '',
194 194
 
195 195
 		'login-redirect'  => '',
196 196
 		'logout-redirect' => '',
197
-	), $atts, 'give_login' );
197
+	), $atts, 'give_login');
198 198
 
199 199
 	// Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute.
200
-	$atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect'] ) ? $atts['redirect'] : '' );
200
+	$atts['login-redirect'] = ! empty($atts['login-redirect']) ? $atts['login-redirect'] : ( ! empty($atts['redirect']) ? $atts['redirect'] : '');
201 201
 
202
-	return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] );
202
+	return give_login_form($atts['login-redirect'], $atts['logout-redirect']);
203 203
 }
204 204
 
205
-add_shortcode( 'give_login', 'give_login_form_shortcode' );
205
+add_shortcode('give_login', 'give_login_form_shortcode');
206 206
 
207 207
 /**
208 208
  * Register Shortcode.
@@ -217,15 +217,15 @@  discard block
 block discarded – undo
217 217
  *
218 218
  * @return string
219 219
  */
220
-function give_register_form_shortcode( $atts ) {
221
-	$atts = shortcode_atts( array(
220
+function give_register_form_shortcode($atts) {
221
+	$atts = shortcode_atts(array(
222 222
 		'redirect' => '',
223
-	), $atts, 'give_register' );
223
+	), $atts, 'give_register');
224 224
 
225
-	return give_register_form( $atts['redirect'] );
225
+	return give_register_form($atts['redirect']);
226 226
 }
227 227
 
228
-add_shortcode( 'give_register', 'give_register_form_shortcode' );
228
+add_shortcode('give_register', 'give_register_form_shortcode');
229 229
 
230 230
 /**
231 231
  * Receipt Shortcode.
@@ -238,12 +238,12 @@  discard block
 block discarded – undo
238 238
  *
239 239
  * @return string
240 240
  */
241
-function give_receipt_shortcode( $atts ) {
241
+function give_receipt_shortcode($atts) {
242 242
 
243 243
 	global $give_receipt_args;
244 244
 
245
-	$give_receipt_args = shortcode_atts( array(
246
-		'error'          => __( 'You are missing the payment key to view this donation receipt.', 'give' ),
245
+	$give_receipt_args = shortcode_atts(array(
246
+		'error'          => __('You are missing the payment key to view this donation receipt.', 'give'),
247 247
 		'price'          => true,
248 248
 		'donor'          => true,
249 249
 		'date'           => true,
@@ -252,49 +252,49 @@  discard block
 block discarded – undo
252 252
 		'payment_id'     => true,
253 253
 		'payment_status' => false,
254 254
 		'status_notice'  => true,
255
-	), $atts, 'give_receipt' );
255
+	), $atts, 'give_receipt');
256 256
 
257 257
 	//set $session var
258 258
 	$session = give_get_purchase_session();
259 259
 
260 260
 	//set payment key var
261
-	if ( isset( $_GET['payment_key'] ) ) {
262
-		$payment_key = urldecode( $_GET['payment_key'] );
263
-	} elseif ( $session ) {
261
+	if (isset($_GET['payment_key'])) {
262
+		$payment_key = urldecode($_GET['payment_key']);
263
+	} elseif ($session) {
264 264
 		$payment_key = $session['purchase_key'];
265
-	} elseif ( $give_receipt_args['payment_key'] ) {
265
+	} elseif ($give_receipt_args['payment_key']) {
266 266
 		$payment_key = $give_receipt_args['payment_key'];
267 267
 	}
268 268
 
269
-	$email_access = give_get_option( 'email_access' );
269
+	$email_access = give_get_option('email_access');
270 270
 
271 271
 	// No payment_key found & Email Access is Turned on:
272
-	if ( ! isset( $payment_key ) && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) {
272
+	if ( ! isset($payment_key) && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) {
273 273
 
274 274
 		ob_start();
275 275
 
276
-		give_get_template_part( 'email-login-form' );
276
+		give_get_template_part('email-login-form');
277 277
 
278 278
 		return ob_get_clean();
279 279
 
280
-	} elseif ( ! isset( $payment_key ) ) {
280
+	} elseif ( ! isset($payment_key)) {
281 281
 
282
-		return Give()->notices->print_frontend_notice( $give_receipt_args['error'], false, 'error' );
282
+		return Give()->notices->print_frontend_notice($give_receipt_args['error'], false, 'error');
283 283
 
284 284
 	}
285 285
 
286
-	$user_can_view = give_can_view_receipt( $payment_key );
286
+	$user_can_view = give_can_view_receipt($payment_key);
287 287
 
288 288
 	// Key was provided, but user is logged out. Offer them the ability to login and view the receipt.
289
-	if ( ! $user_can_view && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) {
289
+	if ( ! $user_can_view && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) {
290 290
 
291 291
 		ob_start();
292 292
 
293
-		give_get_template_part( 'email-login-form' );
293
+		give_get_template_part('email-login-form');
294 294
 
295 295
 		return ob_get_clean();
296 296
 
297
-	} elseif ( ! $user_can_view ) {
297
+	} elseif ( ! $user_can_view) {
298 298
 
299 299
 		global $give_login_redirect;
300 300
 
@@ -302,9 +302,9 @@  discard block
 block discarded – undo
302 302
 
303 303
 		ob_start();
304 304
 
305
-		Give()->notices->print_frontend_notice( apply_filters( 'give_must_be_logged_in_error_message', __( 'You must be logged in to view this donation receipt.', 'give' ) ) );
305
+		Give()->notices->print_frontend_notice(apply_filters('give_must_be_logged_in_error_message', __('You must be logged in to view this donation receipt.', 'give')));
306 306
 
307
-		give_get_template_part( 'shortcode', 'login' );
307
+		give_get_template_part('shortcode', 'login');
308 308
 
309 309
 		$login_form = ob_get_clean();
310 310
 
@@ -318,20 +318,20 @@  discard block
 block discarded – undo
318 318
 	 * or if user is logged out and donation was made as a guest, the donation session is checked for
319 319
 	 * or if user is logged in and the user can view sensitive shop data.
320 320
 	 */
321
-	if ( ! apply_filters( 'give_user_can_view_receipt', $user_can_view, $give_receipt_args ) ) {
322
-		return Give()->notices->print_frontend_notice( $give_receipt_args['error'], false, 'error' );
321
+	if ( ! apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) {
322
+		return Give()->notices->print_frontend_notice($give_receipt_args['error'], false, 'error');
323 323
 	}
324 324
 
325 325
 	ob_start();
326 326
 
327
-	give_get_template_part( 'shortcode', 'receipt' );
327
+	give_get_template_part('shortcode', 'receipt');
328 328
 
329 329
 	$display = ob_get_clean();
330 330
 
331 331
 	return $display;
332 332
 }
333 333
 
334
-add_shortcode( 'give_receipt', 'give_receipt_shortcode' );
334
+add_shortcode('give_receipt', 'give_receipt_shortcode');
335 335
 
336 336
 /**
337 337
  * Profile Editor Shortcode.
@@ -350,25 +350,25 @@  discard block
 block discarded – undo
350 350
  *
351 351
  * @return string Output generated from the profile editor
352 352
  */
353
-function give_profile_editor_shortcode( $atts ) {
353
+function give_profile_editor_shortcode($atts) {
354 354
 
355 355
 	ob_start();
356 356
 
357 357
 	// Restrict access to donor profile, if donor and user are disconnected.
358
-	$is_donor_disconnected = get_user_meta( get_current_user_id(), '_give_is_donor_disconnected', true );
359
-	if( is_user_logged_in() && $is_donor_disconnected ) {
360
-		Give()->notices->print_frontend_notice( __( 'Your Donor and User profile are no longer connected. Please contact the site administrator.', 'give' ), true, 'error' );
358
+	$is_donor_disconnected = get_user_meta(get_current_user_id(), '_give_is_donor_disconnected', true);
359
+	if (is_user_logged_in() && $is_donor_disconnected) {
360
+		Give()->notices->print_frontend_notice(__('Your Donor and User profile are no longer connected. Please contact the site administrator.', 'give'), true, 'error');
361 361
 		return false;
362 362
 	}
363 363
 
364
-	give_get_template_part( 'shortcode', 'profile-editor' );
364
+	give_get_template_part('shortcode', 'profile-editor');
365 365
 
366 366
 	$display = ob_get_clean();
367 367
 
368 368
 	return $display;
369 369
 }
370 370
 
371
-add_shortcode( 'give_profile_editor', 'give_profile_editor_shortcode' );
371
+add_shortcode('give_profile_editor', 'give_profile_editor_shortcode');
372 372
 
373 373
 /**
374 374
  * Process Profile Updater Form.
@@ -381,32 +381,32 @@  discard block
 block discarded – undo
381 381
  *
382 382
  * @return bool
383 383
  */
384
-function give_process_profile_editor_updates( $data ) {
384
+function give_process_profile_editor_updates($data) {
385 385
 	// Profile field change request
386
-	if ( empty( $_POST['give_profile_editor_submit'] ) && ! is_user_logged_in() ) {
386
+	if (empty($_POST['give_profile_editor_submit']) && ! is_user_logged_in()) {
387 387
 		return false;
388 388
 	}
389 389
 
390 390
 	// Nonce security
391
-	if ( ! wp_verify_nonce( $data['give_profile_editor_nonce'], 'give-profile-editor-nonce' ) ) {
391
+	if ( ! wp_verify_nonce($data['give_profile_editor_nonce'], 'give-profile-editor-nonce')) {
392 392
 		return false;
393 393
 	}
394 394
 
395 395
 	$user_id       = get_current_user_id();
396
-	$old_user_data = get_userdata( $user_id );
397
-
398
-	$display_name     = isset( $data['give_display_name'] ) ? sanitize_text_field( $data['give_display_name'] ) : $old_user_data->display_name;
399
-	$first_name       = isset( $data['give_first_name'] ) ? sanitize_text_field( $data['give_first_name'] ) : $old_user_data->first_name;
400
-	$last_name        = isset( $data['give_last_name'] ) ? sanitize_text_field( $data['give_last_name'] ) : $old_user_data->last_name;
401
-	$email            = isset( $data['give_email'] ) ? sanitize_email( $data['give_email'] ) : $old_user_data->user_email;
402
-	$line1            = ( isset( $data['give_address_line1'] ) ? sanitize_text_field( $data['give_address_line1'] ) : '' );
403
-	$line2            = ( isset( $data['give_address_line2'] ) ? sanitize_text_field( $data['give_address_line2'] ) : '' );
404
-	$city             = ( isset( $data['give_address_city'] ) ? sanitize_text_field( $data['give_address_city'] ) : '' );
405
-	$state            = ( isset( $data['give_address_state'] ) ? sanitize_text_field( $data['give_address_state'] ) : '' );
406
-	$zip              = ( isset( $data['give_address_zip'] ) ? sanitize_text_field( $data['give_address_zip'] ) : '' );
407
-	$country          = ( isset( $data['give_address_country'] ) ? sanitize_text_field( $data['give_address_country'] ) : '' );
408
-	$password         = ! empty( $data['give_new_user_pass1'] ) ? $data['give_new_user_pass1'] : '';
409
-	$confirm_password = ! empty( $data['give_new_user_pass2'] ) ? $data['give_new_user_pass2'] : '';
396
+	$old_user_data = get_userdata($user_id);
397
+
398
+	$display_name     = isset($data['give_display_name']) ? sanitize_text_field($data['give_display_name']) : $old_user_data->display_name;
399
+	$first_name       = isset($data['give_first_name']) ? sanitize_text_field($data['give_first_name']) : $old_user_data->first_name;
400
+	$last_name        = isset($data['give_last_name']) ? sanitize_text_field($data['give_last_name']) : $old_user_data->last_name;
401
+	$email            = isset($data['give_email']) ? sanitize_email($data['give_email']) : $old_user_data->user_email;
402
+	$line1            = (isset($data['give_address_line1']) ? sanitize_text_field($data['give_address_line1']) : '');
403
+	$line2            = (isset($data['give_address_line2']) ? sanitize_text_field($data['give_address_line2']) : '');
404
+	$city             = (isset($data['give_address_city']) ? sanitize_text_field($data['give_address_city']) : '');
405
+	$state            = (isset($data['give_address_state']) ? sanitize_text_field($data['give_address_state']) : '');
406
+	$zip              = (isset($data['give_address_zip']) ? sanitize_text_field($data['give_address_zip']) : '');
407
+	$country          = (isset($data['give_address_country']) ? sanitize_text_field($data['give_address_country']) : '');
408
+	$password         = ! empty($data['give_new_user_pass1']) ? $data['give_new_user_pass1'] : '';
409
+	$confirm_password = ! empty($data['give_new_user_pass2']) ? $data['give_new_user_pass2'] : '';
410 410
 
411 411
 	$userdata = array(
412 412
 		'ID'           => $user_id,
@@ -417,8 +417,8 @@  discard block
 block discarded – undo
417 417
 		'user_pass'    => $password,
418 418
 	);
419 419
 
420
-	if( empty( $line1 ) || empty( $city ) || empty( $state ) || empty( $zip ) || empty( $country ) ) {
421
-		give_set_error( 'give-empty-address-fields', __( 'Please fill in the required address fields.', 'give' ) );
420
+	if (empty($line1) || empty($city) || empty($state) || empty($zip) || empty($country)) {
421
+		give_set_error('give-empty-address-fields', __('Please fill in the required address fields.', 'give'));
422 422
 	}
423 423
 
424 424
 	$address = array(
@@ -438,48 +438,48 @@  discard block
 block discarded – undo
438 438
 	 * @param int $user_id The ID of the user.
439 439
 	 * @param array $userdata User info, including ID, first name, last name, display name and email.
440 440
 	 */
441
-	do_action( 'give_pre_update_user_profile', $user_id, $userdata );
441
+	do_action('give_pre_update_user_profile', $user_id, $userdata);
442 442
 
443 443
 	// Validate First Name.
444
-	if( empty( $first_name ) ) {
445
-		give_set_error( 'give-empty-first-name', __( 'Please enter first name.', 'give' ) );
444
+	if (empty($first_name)) {
445
+		give_set_error('give-empty-first-name', __('Please enter first name.', 'give'));
446 446
 	}
447 447
 
448 448
 	// Make sure to validate passwords for existing Donors.
449
-	give_validate_user_password( $password, $confirm_password );
449
+	give_validate_user_password($password, $confirm_password);
450 450
 
451
-	if ( empty( $email ) ) {
451
+	if (empty($email)) {
452 452
 		// Make sure email should not be empty.
453
-		give_set_error( 'email_empty', __( 'The email you entered is empty.', 'give' ) );
453
+		give_set_error('email_empty', __('The email you entered is empty.', 'give'));
454 454
 
455
-	} else if ( ! is_email( $email ) ) {
455
+	} else if ( ! is_email($email)) {
456 456
 		// Make sure email should be valid.
457
-		give_set_error( 'email_not_valid', __( 'The email you entered is not valid. Please use another', 'give' ) );
457
+		give_set_error('email_not_valid', __('The email you entered is not valid. Please use another', 'give'));
458 458
 
459
-	} else if ( $email != $old_user_data->user_email ) {
459
+	} else if ($email != $old_user_data->user_email) {
460 460
 		// Make sure the new email doesn't belong to another user
461
-		if ( email_exists( $email ) ) {
462
-			give_set_error( 'user_email_exists', __( 'The email you entered belongs to another user. Please use another.', 'give' ) );
463
-		} elseif ( Give()->donors->get_donor_by( 'email', $email ) ){
461
+		if (email_exists($email)) {
462
+			give_set_error('user_email_exists', __('The email you entered belongs to another user. Please use another.', 'give'));
463
+		} elseif (Give()->donors->get_donor_by('email', $email)) {
464 464
 			// Make sure the new email doesn't belong to another user
465
-			give_set_error( 'donor_email_exists', __( 'The email you entered belongs to another donor. Please use another.', 'give' ) );
465
+			give_set_error('donor_email_exists', __('The email you entered belongs to another donor. Please use another.', 'give'));
466 466
 		}
467 467
 	}
468 468
 
469 469
 	// Check for errors
470 470
 	$errors = give_get_errors();
471 471
 
472
-	if ( $errors ) {
472
+	if ($errors) {
473 473
 		// Send back to the profile editor if there are errors
474
-		wp_redirect( $data['give_redirect'] );
474
+		wp_redirect($data['give_redirect']);
475 475
 		give_die();
476 476
 	}
477 477
 
478 478
 	// Update the user
479
-	$meta    = update_user_meta( $user_id, '_give_user_address', $address );
480
-	$updated = wp_update_user( $userdata );
479
+	$meta    = update_user_meta($user_id, '_give_user_address', $address);
480
+	$updated = wp_update_user($userdata);
481 481
 
482
-	if ( $updated ) {
482
+	if ($updated) {
483 483
 
484 484
 		/**
485 485
 		 * Fires after updating user profile.
@@ -489,12 +489,12 @@  discard block
 block discarded – undo
489 489
 		 * @param int $user_id The ID of the user.
490 490
 		 * @param array $userdata User info, including ID, first name, last name, display name and email.
491 491
 		 */
492
-		do_action( 'give_user_profile_updated', $user_id, $userdata );
493
-		wp_redirect( add_query_arg( 'updated', 'true', $data['give_redirect'] ) );
492
+		do_action('give_user_profile_updated', $user_id, $userdata);
493
+		wp_redirect(add_query_arg('updated', 'true', $data['give_redirect']));
494 494
 		give_die();
495 495
 	}
496 496
 
497 497
 	return false;
498 498
 }
499 499
 
500
-add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' );
500
+add_action('give_edit_user_profile', 'give_process_profile_editor_updates');
Please login to merge, or discard this patch.