Test Failed
Push — master ( 9a7225...07651e )
by Ravinder
05:42
created
templates/shortcode-goal.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -8,9 +8,9 @@  discard block
 block discarded – undo
8 8
 
9 9
 // Sanity check - ensure form has pass all condition to show goal.
10 10
 if ( ( isset( $args['show_goal'] ) && ! filter_var( $args['show_goal'], FILTER_VALIDATE_BOOLEAN ) )
11
-     || empty( $form->ID )
12
-     || ( is_singular( 'give_forms' ) && ! give_is_setting_enabled( $goal_option ) )
13
-     || ! give_is_setting_enabled( $goal_option ) || 0 === $form->goal ) {
11
+	 || empty( $form->ID )
12
+	 || ( is_singular( 'give_forms' ) && ! give_is_setting_enabled( $goal_option ) )
13
+	 || ! give_is_setting_enabled( $goal_option ) || 0 === $form->goal ) {
14 14
 	return false;
15 15
 }
16 16
 
@@ -97,17 +97,17 @@  discard block
 block discarded – undo
97 97
 				echo sprintf( /* translators: 1: amount of income raised 2: goal target amount. */
98 98
 					__( '<span class="income">%1$s</span> of <span class="goal-text">%2$s</span> raised', 'give' ), give_currency_filter( $income, array( 'form_id' => $form_id ) ), give_currency_filter( $goal, array( 'form_id' => $form_id ) ) );
99 99
 
100
-            elseif ( 'percentage' === $goal_format ) :
100
+			elseif ( 'percentage' === $goal_format ) :
101 101
 
102 102
 				echo sprintf( /* translators: %s: percentage of the amount raised compared to the goal target */
103 103
 					__( '<span class="give-percentage">%s%%</span> funded', 'give' ), round( $progress ) );
104 104
 
105
-            elseif ( 'donation' === $goal_format ) :
105
+			elseif ( 'donation' === $goal_format ) :
106 106
 
107 107
 				echo sprintf( /* translators: 1: total number of donations completed 2: total number of donations set as goal */
108 108
 					_n( '<span class="income">%1$s</span> of <span class="goal-text">%2$s</span> donation', '<span class="income">%1$s</span> of <span class="goal-text">%2$s</span> donations', $goal, 'give' ), $income, $goal );
109 109
 
110
-            elseif ( 'donors' === $goal_format ) :
110
+			elseif ( 'donors' === $goal_format ) :
111 111
 
112 112
 				echo sprintf( /* translators: 1: total number of donors completed 2: total number of donors set as goal */
113 113
 					_n( '<span class="income">%1$s</span> of <span class="goal-text">%2$s</span> donation', '<span class="income">%1$s</span> of <span class="goal-text">%2$s</span> donors', $goal, 'give' ), $income, $goal );
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -3,46 +3,46 @@  discard block
 block discarded – undo
3 3
  * This template is used to display the goal with [give_goal]
4 4
  */
5 5
 
6
-$form        = new Give_Donate_Form( $form_id );
7
-$goal_option = give_get_meta( $form->ID, '_give_goal_option', true );
6
+$form        = new Give_Donate_Form($form_id);
7
+$goal_option = give_get_meta($form->ID, '_give_goal_option', true);
8 8
 
9 9
 // Sanity check - ensure form has pass all condition to show goal.
10
-if ( ( isset( $args['show_goal'] ) && ! filter_var( $args['show_goal'], FILTER_VALIDATE_BOOLEAN ) )
11
-     || empty( $form->ID )
12
-     || ( is_singular( 'give_forms' ) && ! give_is_setting_enabled( $goal_option ) )
13
-     || ! give_is_setting_enabled( $goal_option ) || 0 === $form->goal ) {
10
+if ((isset($args['show_goal']) && ! filter_var($args['show_goal'], FILTER_VALIDATE_BOOLEAN))
11
+     || empty($form->ID)
12
+     || (is_singular('give_forms') && ! give_is_setting_enabled($goal_option))
13
+     || ! give_is_setting_enabled($goal_option) || 0 === $form->goal) {
14 14
 	return false;
15 15
 }
16 16
 
17
-$goal_format         = give_get_form_goal_format( $form_id );
18
-$price               = give_get_meta( $form_id, '_give_set_price', true );
19
-$color               = give_get_meta( $form_id, '_give_goal_color', true );
20
-$show_text           = isset( $args['show_text'] ) ? filter_var( $args['show_text'], FILTER_VALIDATE_BOOLEAN ) : true;
21
-$show_bar            = isset( $args['show_bar'] ) ? filter_var( $args['show_bar'], FILTER_VALIDATE_BOOLEAN ) : true;
22
-$goal_progress_stats = give_goal_progress_stats( $form );
17
+$goal_format         = give_get_form_goal_format($form_id);
18
+$price               = give_get_meta($form_id, '_give_set_price', true);
19
+$color               = give_get_meta($form_id, '_give_goal_color', true);
20
+$show_text           = isset($args['show_text']) ? filter_var($args['show_text'], FILTER_VALIDATE_BOOLEAN) : true;
21
+$show_bar            = isset($args['show_bar']) ? filter_var($args['show_bar'], FILTER_VALIDATE_BOOLEAN) : true;
22
+$goal_progress_stats = give_goal_progress_stats($form);
23 23
 
24 24
 $income = $goal_progress_stats['raw_actual'];
25 25
 $goal   = $goal_progress_stats['raw_goal'];
26 26
 
27
-switch ( $goal_format ) {
27
+switch ($goal_format) {
28 28
 
29 29
 	case 'donation':
30
-		$progress           = $goal ? round( ( $income / $goal ) * 100, 2 ) : 0;
30
+		$progress           = $goal ? round(($income / $goal) * 100, 2) : 0;
31 31
 		$progress_bar_value = $income >= $goal ? 100 : $progress;
32 32
 		break;
33 33
 
34 34
 	case 'donors':
35
-		$progress_bar_value = $goal ? round( ( $income / $goal ) * 100, 2 ) : 0;
35
+		$progress_bar_value = $goal ? round(($income / $goal) * 100, 2) : 0;
36 36
 		$progress           = $progress_bar_value;
37 37
 		break;
38 38
 
39 39
 	case 'percentage':
40
-		$progress           = $goal ? round( ( $income / $goal ) * 100, 2 ) : 0;
40
+		$progress           = $goal ? round(($income / $goal) * 100, 2) : 0;
41 41
 		$progress_bar_value = $income >= $goal ? 100 : $progress;
42 42
 		break;
43 43
 
44 44
 	default:
45
-		$progress           = $goal ? round( ( $income / $goal ) * 100, 2 ) : 0;
45
+		$progress           = $goal ? round(($income / $goal) * 100, 2) : 0;
46 46
 		$progress_bar_value = $income >= $goal ? 100 : $progress;
47 47
 		break;
48 48
 
@@ -53,64 +53,64 @@  discard block
 block discarded – undo
53 53
  *
54 54
  * @since 1.8.8
55 55
  */
56
-$progress = apply_filters( 'give_goal_amount_funded_percentage_output', $progress, $form_id, $form );
56
+$progress = apply_filters('give_goal_amount_funded_percentage_output', $progress, $form_id, $form);
57 57
 ?>
58 58
 <div class="give-goal-progress">
59
-	<?php if ( ! empty( $show_text ) ) : ?>
59
+	<?php if ( ! empty($show_text)) : ?>
60 60
         <div class="raised">
61 61
 			<?php
62
-			if ( 'amount' === $goal_format ) :
62
+			if ('amount' === $goal_format) :
63 63
 
64 64
 				/**
65 65
 				 * Filter the give currency.
66 66
 				 *
67 67
 				 * @since 1.8.17
68 68
 				 */
69
-				$form_currency = apply_filters( 'give_goal_form_currency', give_get_currency( $form_id ), $form_id );
69
+				$form_currency = apply_filters('give_goal_form_currency', give_get_currency($form_id), $form_id);
70 70
 
71 71
 				/**
72 72
 				 * Filter the income formatting arguments.
73 73
 				 *
74 74
 				 * @since 1.8.17
75 75
 				 */
76
-				$income_format_args = apply_filters( 'give_goal_income_format_args', array(
76
+				$income_format_args = apply_filters('give_goal_income_format_args', array(
77 77
 					'sanitize' => false,
78 78
 					'currency' => $form_currency,
79 79
 					'decimal'  => false,
80
-				), $form_id );
80
+				), $form_id);
81 81
 
82 82
 				/**
83 83
 				 * Filter the goal formatting arguments.
84 84
 				 *
85 85
 				 * @since 1.8.17
86 86
 				 */
87
-				$goal_format_args = apply_filters( 'give_goal_amount_format_args', array(
87
+				$goal_format_args = apply_filters('give_goal_amount_format_args', array(
88 88
 					'sanitize' => false,
89 89
 					'currency' => $form_currency,
90 90
 					'decimal'  => false,
91
-				), $form_id );
91
+				), $form_id);
92 92
 
93 93
 				// Get formatted amount.
94
-				$income = give_human_format_large_amount( give_format_amount( $income, $income_format_args ), array( 'currency' => $form_currency ) );
95
-				$goal   = give_human_format_large_amount( give_format_amount( $goal, $goal_format_args ), array( 'currency' => $form_currency ) );
94
+				$income = give_human_format_large_amount(give_format_amount($income, $income_format_args), array('currency' => $form_currency));
95
+				$goal   = give_human_format_large_amount(give_format_amount($goal, $goal_format_args), array('currency' => $form_currency));
96 96
 
97 97
 				echo sprintf( /* translators: 1: amount of income raised 2: goal target amount. */
98
-					__( '<span class="income">%1$s</span> of <span class="goal-text">%2$s</span> raised', 'give' ), give_currency_filter( $income, array( 'form_id' => $form_id ) ), give_currency_filter( $goal, array( 'form_id' => $form_id ) ) );
98
+					__('<span class="income">%1$s</span> of <span class="goal-text">%2$s</span> raised', 'give'), give_currency_filter($income, array('form_id' => $form_id)), give_currency_filter($goal, array('form_id' => $form_id)) );
99 99
 
100
-            elseif ( 'percentage' === $goal_format ) :
100
+            elseif ('percentage' === $goal_format) :
101 101
 
102 102
 				echo sprintf( /* translators: %s: percentage of the amount raised compared to the goal target */
103
-					__( '<span class="give-percentage">%s%%</span> funded', 'give' ), round( $progress ) );
103
+					__('<span class="give-percentage">%s%%</span> funded', 'give'), round($progress) );
104 104
 
105
-            elseif ( 'donation' === $goal_format ) :
105
+            elseif ('donation' === $goal_format) :
106 106
 
107 107
 				echo sprintf( /* translators: 1: total number of donations completed 2: total number of donations set as goal */
108
-					_n( '<span class="income">%1$s</span> of <span class="goal-text">%2$s</span> donation', '<span class="income">%1$s</span> of <span class="goal-text">%2$s</span> donations', $goal, 'give' ), $income, $goal );
108
+					_n('<span class="income">%1$s</span> of <span class="goal-text">%2$s</span> donation', '<span class="income">%1$s</span> of <span class="goal-text">%2$s</span> donations', $goal, 'give'), $income, $goal );
109 109
 
110
-            elseif ( 'donors' === $goal_format ) :
110
+            elseif ('donors' === $goal_format) :
111 111
 
112 112
 				echo sprintf( /* translators: 1: total number of donors completed 2: total number of donors set as goal */
113
-					_n( '<span class="income">%1$s</span> of <span class="goal-text">%2$s</span> donation', '<span class="income">%1$s</span> of <span class="goal-text">%2$s</span> donors', $goal, 'give' ), $income, $goal );
113
+					_n('<span class="income">%1$s</span> of <span class="goal-text">%2$s</span> donation', '<span class="income">%1$s</span> of <span class="goal-text">%2$s</span> donors', $goal, 'give'), $income, $goal );
114 114
 
115 115
 			endif;
116 116
 			?>
@@ -118,11 +118,11 @@  discard block
 block discarded – undo
118 118
 	<?php endif; ?>
119 119
 
120 120
 
121
-	<?php if ( ! empty( $show_bar ) ) : ?>
121
+	<?php if ( ! empty($show_bar)) : ?>
122 122
         <div class="give-progress-bar" role="progressbar" aria-valuemin="0" aria-valuemax="100"
123
-             aria-valuenow="<?php echo esc_attr( $progress_bar_value ); ?>">
124
-			<span style="width: <?php echo esc_attr( $progress_bar_value ); ?>%;<?php if ( ! empty( $color ) ) {
125
-				echo 'background-color:' . $color;
123
+             aria-valuenow="<?php echo esc_attr($progress_bar_value); ?>">
124
+			<span style="width: <?php echo esc_attr($progress_bar_value); ?>%;<?php if ( ! empty($color)) {
125
+				echo 'background-color:'.$color;
126 126
 			} ?>"></span>
127 127
         </div><!-- /.give-progress-bar -->
128 128
 	<?php endif; ?>
Please login to merge, or discard this patch.
templates/email-login-form.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -9,17 +9,17 @@  discard block
 block discarded – undo
9 9
 global $give_access_form_outputted;
10 10
 
11 11
 // Only output the form once.
12
-if ( $give_access_form_outputted ) {
12
+if ($give_access_form_outputted) {
13 13
 	return;
14 14
 }
15 15
 
16
-$recaptcha_key    = give_get_option( 'recaptcha_key' );
17
-$recaptcha_secret = give_get_option( 'recaptcha_secret' );
16
+$recaptcha_key    = give_get_option('recaptcha_key');
17
+$recaptcha_secret = give_get_option('recaptcha_secret');
18 18
 
19
-$enable_recaptcha = ( give_is_setting_enabled( give_get_option( 'enable_recaptcha' ) ) ) && ! empty( $recaptcha_key ) && ! empty( $recaptcha_secret ) ? true : false;
19
+$enable_recaptcha = (give_is_setting_enabled(give_get_option('enable_recaptcha'))) && ! empty($recaptcha_key) && ! empty($recaptcha_secret) ? true : false;
20 20
 
21 21
 // Email already sent?
22
-if ( isset( $_POST['email-access-sent'] ) ) {
22
+if (isset($_POST['email-access-sent'])) {
23 23
 
24 24
 	/**
25 25
 	 * Filter to modify access mail send notice
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @return  string $message Send notice message for email access.
32 32
 	 */
33
-	$message = (string) apply_filters( 'give_email_access_mail_send_notice', __( 'Please check your email and click on the link to access your complete donation history.', 'give' ) );
33
+	$message = (string) apply_filters('give_email_access_mail_send_notice', __('Please check your email and click on the link to access your complete donation history.', 'give'));
34 34
 
35 35
 	Give()->notices->print_frontend_notice(
36 36
 		$message,
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	);
40 40
 
41 41
 	return;
42
-} elseif ( isset( $_POST['email-access-exhausted'] ) ) {
42
+} elseif (isset($_POST['email-access-exhausted'])) {
43 43
 
44 44
 	$value = Give()->email_access->verify_throttle / 60;
45 45
 
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
 	$message = (string) apply_filters(
57 57
 		'give_email_access_requests_exceed_notice',
58 58
 		sprintf(
59
-			__( 'Too many access email requests detected. Please wait %s before requesting a new donation history access link.', 'give' ),
60
-			sprintf( _n( '%s minute', '%s minutes', $value, 'give' ), $value )
59
+			__('Too many access email requests detected. Please wait %s before requesting a new donation history access link.', 'give'),
60
+			sprintf(_n('%s minute', '%s minutes', $value, 'give'), $value)
61 61
 		),
62 62
 		$value
63 63
 	);
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
  *
79 79
  * @since 1.8.17
80 80
  */
81
-do_action( 'give_email_access_form_login' );
81
+do_action('give_email_access_form_login');
82 82
 
83 83
 // Print any other messages & errors.
84 84
 Give()->notices->render_frontend_notices();
@@ -97,20 +97,20 @@  discard block
 block discarded – undo
97 97
 				 *
98 98
 				 * @return string $message email access welcome message
99 99
 				 */
100
-				echo esc_html( apply_filters( 'give_email_access_welcome_message', __( 'Please verify your email to access your donation history.', 'give' ) ) );
100
+				echo esc_html(apply_filters('give_email_access_welcome_message', __('Please verify your email to access your donation history.', 'give')));
101 101
 				?>
102 102
             </p>
103 103
 
104
-            <label for="give-email"><?php esc_attr_e( 'Donation Email:', 'give' ); ?></label>
104
+            <label for="give-email"><?php esc_attr_e('Donation Email:', 'give'); ?></label>
105 105
             <input id="give-email" type="email" name="give_email" value=""
106
-                   placeholder="<?php esc_attr_e( 'Email Address', 'give' ); ?>"/>
107
-            <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'give' ); ?>"/>
106
+                   placeholder="<?php esc_attr_e('Email Address', 'give'); ?>"/>
107
+            <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('give'); ?>"/>
108 108
             <input type="hidden" name="give_action" value="email_access_form_login"/>
109 109
             <input type="hidden" name="give_access_page" value="<?php the_ID(); ?>"/>
110 110
 
111 111
 			<?php
112 112
 			// Enable reCAPTCHA?
113
-			if ( $enable_recaptcha ) :
113
+			if ($enable_recaptcha) :
114 114
 				?>
115 115
                 <script>
116 116
                     // IP verify for reCAPTCHA.
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
                 <input type="hidden" name="give_ip" class="give_ip" value=""/>
129 129
 			<?php endif; ?>
130 130
 
131
-            <input type="submit" class="give-submit" value="<?php esc_attr_e( 'Verify Email', 'give' ); ?>"/>
131
+            <input type="submit" class="give-submit" value="<?php esc_attr_e('Verify Email', 'give'); ?>"/>
132 132
         </form>
133 133
     </div>
134 134
 <?php
Please login to merge, or discard this patch.
includes/process-donation.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  *
25 25
  * @throws ReflectionException Exception Handling.
26 26
  *
27
- * @return mixed
27
+ * @return false|null
28 28
  */
29 29
 function give_process_donation_form() {
30 30
 
@@ -1319,7 +1319,7 @@  discard block
 block discarded – undo
1319 1319
  *
1320 1320
  * @param array $valid_data List of Valid Data.
1321 1321
  *
1322
- * @return bool
1322
+ * @return boolean|null
1323 1323
  */
1324 1324
 function give_validate_donation_amount( $valid_data ) {
1325 1325
 
Please login to merge, or discard this patch.
Spacing   +296 added lines, -297 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
 
@@ -29,20 +29,20 @@  discard block
 block discarded – undo
29 29
 function give_process_donation_form() {
30 30
 
31 31
 	// Sanitize Posted Data.
32
-	$post_data  = give_clean( $_POST ); // WPCS: input var ok, CSRF ok.
32
+	$post_data = give_clean($_POST); // WPCS: input var ok, CSRF ok.
33 33
 
34 34
 	// Check whether the form submitted via AJAX or not.
35
-	$is_ajax = isset( $post_data['give_ajax'] );
35
+	$is_ajax = isset($post_data['give_ajax']);
36 36
 
37 37
 	// Verify donation form nonce.
38
-	if ( ! give_verify_donation_form_nonce( $post_data['give-form-hash'], $post_data['give-form-id'] ) ) {
39
-		if ( $is_ajax ) {
38
+	if ( ! give_verify_donation_form_nonce($post_data['give-form-hash'], $post_data['give-form-id'])) {
39
+		if ($is_ajax) {
40 40
 			/**
41 41
 			 * Fires when AJAX sends back errors from the donation form.
42 42
 			 *
43 43
 			 * @since 1.0
44 44
 			 */
45
-			do_action( 'give_ajax_donation_errors' );
45
+			do_action('give_ajax_donation_errors');
46 46
 			give_die();
47 47
 		} else {
48 48
 			give_send_back_to_checkout();
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 * @since 1.0
56 56
 	 */
57
-	do_action( 'give_pre_process_donation' );
57
+	do_action('give_pre_process_donation');
58 58
 
59 59
 	// Validate the form $_POST data.
60 60
 	$valid_data = give_donation_form_validate_fields();
@@ -70,24 +70,24 @@  discard block
 block discarded – undo
70 70
 	 * @param array $deprecated Deprecated Since 2.0.2. Use $_POST instead.
71 71
 	 */
72 72
 	$deprecated = $post_data;
73
-	do_action( 'give_checkout_error_checks', $valid_data, $deprecated );
73
+	do_action('give_checkout_error_checks', $valid_data, $deprecated);
74 74
 
75 75
 	// Process the login form.
76
-	if ( isset( $post_data['give_login_submit'] ) ) {
76
+	if (isset($post_data['give_login_submit'])) {
77 77
 		give_process_form_login();
78 78
 	}
79 79
 
80 80
 	// Validate the user.
81
-	$user = give_get_donation_form_user( $valid_data );
81
+	$user = give_get_donation_form_user($valid_data);
82 82
 
83
-	if ( false === $valid_data || give_get_errors() || ! $user ) {
84
-		if ( $is_ajax ) {
83
+	if (false === $valid_data || give_get_errors() || ! $user) {
84
+		if ($is_ajax) {
85 85
 			/**
86 86
 			 * Fires when AJAX sends back errors from the donation form.
87 87
 			 *
88 88
 			 * @since 1.0
89 89
 			 */
90
-			do_action( 'give_ajax_donation_errors' );
90
+			do_action('give_ajax_donation_errors');
91 91
 			give_die();
92 92
 		} else {
93 93
 			return false;
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	}
96 96
 
97 97
 	// If AJAX send back success to proceed with form submission.
98
-	if ( $is_ajax ) {
98
+	if ($is_ajax) {
99 99
 		echo 'success';
100 100
 		give_die();
101 101
 	}
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 *
106 106
 	 * @since 2.2.0
107 107
 	 */
108
-	do_action( 'give_process_donation_after_validation' );
108
+	do_action('give_process_donation_after_validation');
109 109
 
110 110
 	// Setup user information.
111 111
 	$user_info = array(
@@ -117,23 +117,22 @@  discard block
 block discarded – undo
117 117
 		'address'    => $user['address'],
118 118
 	);
119 119
 
120
-	$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
120
+	$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
121 121
 
122 122
 	// Donation form ID.
123
-	$form_id = isset( $post_data['give-form-id'] ) ? absint( $post_data['give-form-id'] ) : 0;
123
+	$form_id = isset($post_data['give-form-id']) ? absint($post_data['give-form-id']) : 0;
124 124
 
125
-	$price = isset( $post_data['give-amount'] ) ?
126
-		(float) apply_filters( 'give_donation_total', give_maybe_sanitize_amount( $post_data['give-amount'], array( 'currency' => give_get_currency( $form_id ) ) ) ) :
127
-		'0.00';
128
-	$purchase_key = strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) );
125
+	$price = isset($post_data['give-amount']) ?
126
+		(float) apply_filters('give_donation_total', give_maybe_sanitize_amount($post_data['give-amount'], array('currency' => give_get_currency($form_id)))) : '0.00';
127
+	$purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true)));
129 128
 
130 129
 	// Setup donation information.
131 130
 	$donation_data = array(
132 131
 		'price'         => $price,
133 132
 		'purchase_key'  => $purchase_key,
134 133
 		'user_email'    => $user['user_email'],
135
-		'date'          => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ),
136
-		'user_info'     => stripslashes_deep( $user_info ),
134
+		'date'          => date('Y-m-d H:i:s', current_time('timestamp')),
135
+		'user_info'     => stripslashes_deep($user_info),
137 136
 		'post_data'     => $post_data,
138 137
 		'gateway'       => $valid_data['gateway'],
139 138
 		'card_info'     => $valid_data['cc_info'],
@@ -153,10 +152,10 @@  discard block
 block discarded – undo
153 152
 	 * @param array      $user_info  Array containing basic user information.
154 153
 	 * @param bool|array $valid_data Validate fields.
155 154
 	 */
156
-	do_action( 'give_checkout_before_gateway', $post_data, $user_info, $valid_data );
155
+	do_action('give_checkout_before_gateway', $post_data, $user_info, $valid_data);
157 156
 
158 157
 	// Sanity check for price.
159
-	if ( ! $donation_data['price'] ) {
158
+	if ( ! $donation_data['price']) {
160 159
 		// Revert to manual.
161 160
 		$donation_data['gateway'] = 'manual';
162 161
 		$_POST['give-gateway']    = 'manual';
@@ -167,26 +166,26 @@  discard block
 block discarded – undo
167 166
 	 *
168 167
 	 * @since 1.7
169 168
 	 */
170
-	$donation_data = apply_filters( 'give_donation_data_before_gateway', $donation_data, $valid_data );
169
+	$donation_data = apply_filters('give_donation_data_before_gateway', $donation_data, $valid_data);
171 170
 
172 171
 	// Setup the data we're storing in the donation session.
173 172
 	$session_data = $donation_data;
174 173
 
175 174
 	// Make sure credit card numbers are never stored in sessions.
176
-	unset( $session_data['card_info']['card_number'] );
177
-	unset( $session_data['post_data']['card_number'] );
175
+	unset($session_data['card_info']['card_number']);
176
+	unset($session_data['post_data']['card_number']);
178 177
 
179 178
 	// Used for showing data to non logged-in users after donation, and for other plugins needing donation data.
180
-	give_set_purchase_session( $session_data );
179
+	give_set_purchase_session($session_data);
181 180
 
182 181
 	// Send info to the gateway for payment processing.
183
-	give_send_to_gateway( $donation_data['gateway'], $donation_data );
182
+	give_send_to_gateway($donation_data['gateway'], $donation_data);
184 183
 	give_die();
185 184
 }
186 185
 
187
-add_action( 'give_purchase', 'give_process_donation_form' );
188
-add_action( 'wp_ajax_give_process_donation', 'give_process_donation_form' );
189
-add_action( 'wp_ajax_nopriv_give_process_donation', 'give_process_donation_form' );
186
+add_action('give_purchase', 'give_process_donation_form');
187
+add_action('wp_ajax_give_process_donation', 'give_process_donation_form');
188
+add_action('wp_ajax_nopriv_give_process_donation', 'give_process_donation_form');
190 189
 
191 190
 /**
192 191
  * Verify that when a logged in user makes a donation that the email address used doesn't belong to a different customer.
@@ -197,27 +196,27 @@  discard block
 block discarded – undo
197 196
  *
198 197
  * @return void
199 198
  */
200
-function give_check_logged_in_user_for_existing_email( $valid_data ) {
199
+function give_check_logged_in_user_for_existing_email($valid_data) {
201 200
 
202 201
 	// Verify that the email address belongs to this customer.
203
-	if ( is_user_logged_in() ) {
202
+	if (is_user_logged_in()) {
204 203
 
205 204
 		$submitted_email = $valid_data['logged_in_user']['user_email'];
206
-		$donor           = new Give_Donor( get_current_user_id(), true );
205
+		$donor           = new Give_Donor(get_current_user_id(), true);
207 206
 
208 207
 		// If this email address is not registered with this customer, see if it belongs to any other customer.
209 208
 		if (
210 209
 			$submitted_email !== $donor->email
211
-			&& ( is_array( $donor->emails ) && ! in_array( $submitted_email, $donor->emails, true ) )
210
+			&& (is_array($donor->emails) && ! in_array($submitted_email, $donor->emails, true))
212 211
 		) {
213
-			$found_donor = new Give_Donor( $submitted_email );
212
+			$found_donor = new Give_Donor($submitted_email);
214 213
 
215
-			if ( $found_donor->id > 0 ) {
214
+			if ($found_donor->id > 0) {
216 215
 				give_set_error(
217 216
 					'give-customer-email-exists',
218 217
 					sprintf(
219 218
 						/* translators: 1. Donor Email, 2. Submitted Email */
220
-						__( 'You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.', 'give' ),
219
+						__('You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.', 'give'),
221 220
 						$donor->email,
222 221
 						$submitted_email
223 222
 					)
@@ -227,7 +226,7 @@  discard block
 block discarded – undo
227 226
 	}
228 227
 }
229 228
 
230
-add_action( 'give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 1 );
229
+add_action('give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 1);
231 230
 
232 231
 /**
233 232
  * Process the checkout login form
@@ -239,49 +238,49 @@  discard block
 block discarded – undo
239 238
  */
240 239
 function give_process_form_login() {
241 240
 
242
-	$is_ajax   = ! empty( $_POST['give_ajax'] ) ? give_clean( $_POST['give_ajax'] ) : 0; // WPCS: input var ok, sanitization ok, CSRF ok.
241
+	$is_ajax   = ! empty($_POST['give_ajax']) ? give_clean($_POST['give_ajax']) : 0; // WPCS: input var ok, sanitization ok, CSRF ok.
243 242
 	$referrer  = wp_get_referer();
244 243
 	$user_data = give_donation_form_validate_user_login();
245 244
 
246
-	if ( give_get_errors() || $user_data['user_id'] < 1 ) {
247
-		if ( $is_ajax ) {
245
+	if (give_get_errors() || $user_data['user_id'] < 1) {
246
+		if ($is_ajax) {
248 247
 			/**
249 248
 			 * Fires when AJAX sends back errors from the donation form.
250 249
 			 *
251 250
 			 * @since 1.0
252 251
 			 */
253 252
 			ob_start();
254
-			do_action( 'give_ajax_donation_errors' );
253
+			do_action('give_ajax_donation_errors');
255 254
 			$message = ob_get_contents();
256 255
 			ob_end_clean();
257
-			wp_send_json_error( $message );
256
+			wp_send_json_error($message);
258 257
 		} else {
259
-			wp_safe_redirect( $referrer );
258
+			wp_safe_redirect($referrer);
260 259
 			exit;
261 260
 		}
262 261
 	}
263 262
 
264
-	give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] );
263
+	give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']);
265 264
 
266
-	if ( $is_ajax ) {
265
+	if ($is_ajax) {
267 266
 		$message = Give()->notices->print_frontend_notice(
268 267
 			sprintf(
269 268
 				/* translators: %s: user first name */
270
-				esc_html__( 'Welcome %s! You have successfully logged into your account.', 'give' ),
271
-				( ! empty( $user_data['user_first'] ) ) ? $user_data['user_first'] : $user_data['user_login']
269
+				esc_html__('Welcome %s! You have successfully logged into your account.', 'give'),
270
+				( ! empty($user_data['user_first'])) ? $user_data['user_first'] : $user_data['user_login']
272 271
 			),
273 272
 			false,
274 273
 			'success'
275 274
 		);
276 275
 
277
-		wp_send_json_success( $message );
276
+		wp_send_json_success($message);
278 277
 	} else {
279
-		wp_safe_redirect( $referrer );
278
+		wp_safe_redirect($referrer);
280 279
 	}
281 280
 }
282 281
 
283
-add_action( 'wp_ajax_give_process_donation_login', 'give_process_form_login' );
284
-add_action( 'wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login' );
282
+add_action('wp_ajax_give_process_donation_login', 'give_process_form_login');
283
+add_action('wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login');
285 284
 
286 285
 /**
287 286
  * Donation Form Validate Fields.
@@ -293,49 +292,49 @@  discard block
 block discarded – undo
293 292
  */
294 293
 function give_donation_form_validate_fields() {
295 294
 
296
-	$post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok.
295
+	$post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok.
297 296
 
298 297
 	// Validate Honeypot First.
299
-	if ( ! empty( $post_data['give-honeypot'] ) ) {
300
-		give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) );
298
+	if ( ! empty($post_data['give-honeypot'])) {
299
+		give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give'));
301 300
 	}
302 301
 
303 302
 	// Check spam detect.
304 303
 	if (
305
-		isset( $post_data['action'] ) &&
306
-		give_is_setting_enabled( give_get_option( 'akismet_spam_protection' ) ) &&
304
+		isset($post_data['action']) &&
305
+		give_is_setting_enabled(give_get_option('akismet_spam_protection')) &&
307 306
 		give_is_spam_donation()
308 307
 	) {
309
-		give_set_error( 'spam_donation', __( 'This donation has been flagged as spam. Please try again.', 'give' ) );
308
+		give_set_error('spam_donation', __('This donation has been flagged as spam. Please try again.', 'give'));
310 309
 	}
311 310
 
312 311
 	// Start an array to collect valid data.
313 312
 	$valid_data = array(
314 313
 		'gateway'          => give_donation_form_validate_gateway(), // Gateway fallback (amount is validated here).
315
-		'need_new_user'    => false,     // New user flag.
316
-		'need_user_login'  => false,     // Login user flag.
317
-		'logged_user_data' => array(),   // Logged user collected data.
318
-		'new_user_data'    => array(),   // New user collected data.
319
-		'login_user_data'  => array(),   // Login user collected data.
320
-		'guest_user_data'  => array(),   // Guest user collected data.
314
+		'need_new_user'    => false, // New user flag.
315
+		'need_user_login'  => false, // Login user flag.
316
+		'logged_user_data' => array(), // Logged user collected data.
317
+		'new_user_data'    => array(), // New user collected data.
318
+		'login_user_data'  => array(), // Login user collected data.
319
+		'guest_user_data'  => array(), // Guest user collected data.
321 320
 		'cc_info'          => give_donation_form_validate_cc(), // Credit card info.
322 321
 	);
323 322
 
324
-	$form_id = intval( $post_data['give-form-id'] );
323
+	$form_id = intval($post_data['give-form-id']);
325 324
 
326 325
 	// Validate agree to terms.
327
-	if ( give_is_terms_enabled( $form_id ) ) {
326
+	if (give_is_terms_enabled($form_id)) {
328 327
 		give_donation_form_validate_agree_to_terms();
329 328
 	}
330 329
 
331
-	if ( is_user_logged_in() ) {
330
+	if (is_user_logged_in()) {
332 331
 
333 332
 		// Collect logged in user data.
334 333
 		$valid_data['logged_in_user'] = give_donation_form_validate_logged_in_user();
335 334
 	} elseif (
336
-		isset( $post_data['give-purchase-var'] ) &&
335
+		isset($post_data['give-purchase-var']) &&
337 336
 		'needs-to-register' === $post_data['give-purchase-var'] &&
338
-		! empty( $post_data['give_create_account'] )
337
+		! empty($post_data['give_create_account'])
339 338
 	) {
340 339
 
341 340
 		// Set new user registration as required.
@@ -344,7 +343,7 @@  discard block
 block discarded – undo
344 343
 		// Validate new user data.
345 344
 		$valid_data['new_user_data'] = give_donation_form_validate_new_user();
346 345
 	} elseif (
347
-		isset( $post_data['give-purchase-var'] ) &&
346
+		isset($post_data['give-purchase-var']) &&
348 347
 		'needs-to-login' === $post_data['give-purchase-var']
349 348
 	) {
350 349
 
@@ -373,14 +372,14 @@  discard block
 block discarded – undo
373 372
 function give_is_spam_donation() {
374 373
 	$spam = false;
375 374
 
376
-	$user_agent = (string) isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : '';
375
+	$user_agent = (string) isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
377 376
 
378
-	if ( strlen( $user_agent ) < 2 ) {
377
+	if (strlen($user_agent) < 2) {
379 378
 		$spam = true;
380 379
 	}
381 380
 
382 381
 	// Allow developer to customized Akismet spam detect API call and it's response.
383
-	return apply_filters( 'give_spam', $spam );
382
+	return apply_filters('give_spam', $spam);
384 383
 }
385 384
 
386 385
 /**
@@ -395,33 +394,33 @@  discard block
 block discarded – undo
395 394
  */
396 395
 function give_donation_form_validate_gateway() {
397 396
 
398
-	$post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok.
399
-	$form_id   = ! empty( $post_data['give-form-id'] ) ? $post_data['give-form-id'] : 0;
400
-	$amount    = ! empty( $post_data['give-amount'] ) ? give_maybe_sanitize_amount( $post_data['give-amount'] ) : 0;
401
-	$gateway   = ! empty( $post_data['give-gateway'] ) ? $post_data['give-gateway'] : 0;
397
+	$post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok.
398
+	$form_id   = ! empty($post_data['give-form-id']) ? $post_data['give-form-id'] : 0;
399
+	$amount    = ! empty($post_data['give-amount']) ? give_maybe_sanitize_amount($post_data['give-amount']) : 0;
400
+	$gateway   = ! empty($post_data['give-gateway']) ? $post_data['give-gateway'] : 0;
402 401
 
403 402
 	// Bailout, if payment gateway is not submitted with donation form data.
404
-	if ( empty( $gateway ) ) {
403
+	if (empty($gateway)) {
405 404
 
406
-		give_set_error( 'empty_gateway', __( 'The donation form will process with a valid payment gateway.', 'give' ) );
405
+		give_set_error('empty_gateway', __('The donation form will process with a valid payment gateway.', 'give'));
407 406
 
408
-	} elseif ( ! give_is_gateway_active( $gateway ) ) {
407
+	} elseif ( ! give_is_gateway_active($gateway)) {
409 408
 
410
-		give_set_error( 'invalid_gateway', __( 'The selected payment gateway is not enabled.', 'give' ) );
409
+		give_set_error('invalid_gateway', __('The selected payment gateway is not enabled.', 'give'));
411 410
 
412
-	} elseif ( empty( $amount ) ) {
411
+	} elseif (empty($amount)) {
413 412
 
414
-		give_set_error( 'invalid_donation_amount', __( 'Please insert a valid donation amount.', 'give' ) );
413
+		give_set_error('invalid_donation_amount', __('Please insert a valid donation amount.', 'give'));
415 414
 
416
-	} elseif ( ! give_verify_minimum_price( 'minimum' ) ) {
415
+	} elseif ( ! give_verify_minimum_price('minimum')) {
417 416
 
418 417
 		give_set_error(
419 418
 			'invalid_donation_minimum',
420 419
 			sprintf(
421 420
 				/* translators: %s: minimum donation amount */
422
-				__( 'This form has a minimum donation amount of %s.', 'give' ),
421
+				__('This form has a minimum donation amount of %s.', 'give'),
423 422
 				give_currency_filter(
424
-					give_format_amount( give_get_form_minimum_price( $form_id ),
423
+					give_format_amount(give_get_form_minimum_price($form_id),
425 424
 						array(
426 425
 							'sanitize' => false,
427 426
 						)
@@ -429,15 +428,15 @@  discard block
 block discarded – undo
429 428
 				)
430 429
 			)
431 430
 		);
432
-	} elseif ( ! give_verify_minimum_price( 'maximum' ) ) {
431
+	} elseif ( ! give_verify_minimum_price('maximum')) {
433 432
 
434 433
 		give_set_error(
435 434
 			'invalid_donation_maximum',
436 435
 			sprintf(
437 436
 				/* translators: %s: Maximum donation amount */
438
-				__( 'This form has a maximum donation amount of %s.', 'give' ),
437
+				__('This form has a maximum donation amount of %s.', 'give'),
439 438
 				give_currency_filter(
440
-					give_format_amount( give_get_form_maximum_price( $form_id ),
439
+					give_format_amount(give_get_form_maximum_price($form_id),
441 440
 						array(
442 441
 							'sanitize' => false,
443 442
 						)
@@ -463,33 +462,33 @@  discard block
 block discarded – undo
463 462
  *
464 463
  * @return bool
465 464
  */
466
-function give_verify_minimum_price( $amount_range = 'minimum' ) {
465
+function give_verify_minimum_price($amount_range = 'minimum') {
467 466
 
468
-	$post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok.
469
-	$form_id   = ! empty( $post_data['give-form-id'] ) ? $post_data['give-form-id'] : 0;
470
-	$amount    = ! empty( $post_data['give-amount'] ) ? give_maybe_sanitize_amount( $post_data['give-amount'], array( 'currency' => give_get_currency( $form_id ) ) ) : 0;
471
-	$price_id  = isset( $post_data['give-price-id'] ) ? absint( $post_data['give-price-id'] ) : '';
467
+	$post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok.
468
+	$form_id   = ! empty($post_data['give-form-id']) ? $post_data['give-form-id'] : 0;
469
+	$amount    = ! empty($post_data['give-amount']) ? give_maybe_sanitize_amount($post_data['give-amount'], array('currency' => give_get_currency($form_id))) : 0;
470
+	$price_id  = isset($post_data['give-price-id']) ? absint($post_data['give-price-id']) : '';
472 471
 
473
-	$variable_prices = give_has_variable_prices( $form_id );
474
-	$price_ids       = array_map( 'absint', give_get_variable_price_ids( $form_id ) );
472
+	$variable_prices = give_has_variable_prices($form_id);
473
+	$price_ids       = array_map('absint', give_get_variable_price_ids($form_id));
475 474
 	$verified_stat   = false;
476 475
 
477
-	if ( $variable_prices && in_array( $price_id, $price_ids, true ) ) {
476
+	if ($variable_prices && in_array($price_id, $price_ids, true)) {
478 477
 
479
-		$price_level_amount = give_get_price_option_amount( $form_id, $price_id );
478
+		$price_level_amount = give_get_price_option_amount($form_id, $price_id);
480 479
 
481
-		if ( $price_level_amount == $amount ) {
480
+		if ($price_level_amount == $amount) {
482 481
 			$verified_stat = true;
483 482
 		}
484 483
 	}
485 484
 
486
-	if ( ! $verified_stat ) {
487
-		switch ( $amount_range ) {
485
+	if ( ! $verified_stat) {
486
+		switch ($amount_range) {
488 487
 			case 'minimum' :
489
-				$verified_stat = ( give_get_form_minimum_price( $form_id ) > $amount ) ? false : true;
488
+				$verified_stat = (give_get_form_minimum_price($form_id) > $amount) ? false : true;
490 489
 				break;
491 490
 			case 'maximum' :
492
-				$verified_stat = ( give_get_form_maximum_price( $form_id ) < $amount ) ? false : true;
491
+				$verified_stat = (give_get_form_maximum_price($form_id) < $amount) ? false : true;
493 492
 				break;
494 493
 		}
495 494
 	}
@@ -503,7 +502,7 @@  discard block
 block discarded – undo
503 502
 	 * @param string  $amount_range  Type of the amount.
504 503
 	 * @param integer $form_id       Give Donation Form ID.
505 504
 	 */
506
-	return apply_filters( 'give_verify_minimum_maximum_price', $verified_stat, $amount_range, $form_id );
505
+	return apply_filters('give_verify_minimum_maximum_price', $verified_stat, $amount_range, $form_id);
507 506
 }
508 507
 
509 508
 /**
@@ -516,13 +515,13 @@  discard block
 block discarded – undo
516 515
  */
517 516
 function give_donation_form_validate_agree_to_terms() {
518 517
 
519
-	$agree_to_terms = ! empty( $_POST['give_agree_to_terms'] ) ? give_clean( $_POST['give_agree_to_terms'] ) : 0; // WPCS: input var ok, sanitization ok, CSRF ok.
518
+	$agree_to_terms = ! empty($_POST['give_agree_to_terms']) ? give_clean($_POST['give_agree_to_terms']) : 0; // WPCS: input var ok, sanitization ok, CSRF ok.
520 519
 
521 520
 	// Proceed only, if donor agreed to terms.
522
-	if ( ! $agree_to_terms ) {
521
+	if ( ! $agree_to_terms) {
523 522
 
524 523
 		// User did not agree.
525
-		give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', __( 'You must agree to the terms and conditions.', 'give' ) ) );
524
+		give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', __('You must agree to the terms and conditions.', 'give')));
526 525
 	}
527 526
 }
528 527
 
@@ -536,92 +535,92 @@  discard block
 block discarded – undo
536 535
  *
537 536
  * @return array
538 537
  */
539
-function give_get_required_fields( $form_id ) {
538
+function give_get_required_fields($form_id) {
540 539
 
541
-	$payment_mode = give_get_chosen_gateway( $form_id );
540
+	$payment_mode = give_get_chosen_gateway($form_id);
542 541
 
543 542
 	$required_fields = array(
544 543
 		'give_email' => array(
545 544
 			'error_id'      => 'invalid_email',
546
-			'error_message' => __( 'Please enter a valid email address.', 'give' ),
545
+			'error_message' => __('Please enter a valid email address.', 'give'),
547 546
 		),
548 547
 		'give_first' => array(
549 548
 			'error_id'      => 'invalid_first_name',
550
-			'error_message' => __( 'Please enter your first name.', 'give' ),
549
+			'error_message' => __('Please enter your first name.', 'give'),
551 550
 		),
552 551
 	);
553 552
 
554
-	$name_title_prefix = give_is_name_title_prefix_required( $form_id );
555
-	if ( $name_title_prefix ) {
553
+	$name_title_prefix = give_is_name_title_prefix_required($form_id);
554
+	if ($name_title_prefix) {
556 555
 		$required_fields['give_title'] = array(
557 556
 			'error_id'      => 'invalid_title',
558
-			'error_message' => __( 'Please enter your title.', 'give' ),
557
+			'error_message' => __('Please enter your title.', 'give'),
559 558
 		);
560 559
 	}
561 560
 
562
-	$require_address = give_require_billing_address( $payment_mode );
561
+	$require_address = give_require_billing_address($payment_mode);
563 562
 
564
-	if ( $require_address ) {
565
-		$required_fields['card_address']    = array(
563
+	if ($require_address) {
564
+		$required_fields['card_address'] = array(
566 565
 			'error_id'      => 'invalid_card_address',
567
-			'error_message' => __( 'Please enter your primary billing address.', 'give' ),
566
+			'error_message' => __('Please enter your primary billing address.', 'give'),
568 567
 		);
569
-		$required_fields['card_zip']        = array(
568
+		$required_fields['card_zip'] = array(
570 569
 			'error_id'      => 'invalid_zip_code',
571
-			'error_message' => __( 'Please enter your zip / postal code.', 'give' ),
570
+			'error_message' => __('Please enter your zip / postal code.', 'give'),
572 571
 		);
573
-		$required_fields['card_city']       = array(
572
+		$required_fields['card_city'] = array(
574 573
 			'error_id'      => 'invalid_city',
575
-			'error_message' => __( 'Please enter your billing city.', 'give' ),
574
+			'error_message' => __('Please enter your billing city.', 'give'),
576 575
 		);
577 576
 		$required_fields['billing_country'] = array(
578 577
 			'error_id'      => 'invalid_country',
579
-			'error_message' => __( 'Please select your billing country.', 'give' ),
578
+			'error_message' => __('Please select your billing country.', 'give'),
580 579
 		);
581 580
 
582 581
 
583 582
 		$required_fields['card_state'] = array(
584 583
 			'error_id'      => 'invalid_state',
585
-			'error_message' => __( 'Please enter billing state / province / County.', 'give' ),
584
+			'error_message' => __('Please enter billing state / province / County.', 'give'),
586 585
 		);
587 586
 
588
-		$country = ! empty( $_POST['billing_country'] ) ? give_clean( $_POST['billing_country'] ) : 0; // WPCS: input var ok, sanitization ok, CSRF ok.
587
+		$country = ! empty($_POST['billing_country']) ? give_clean($_POST['billing_country']) : 0; // WPCS: input var ok, sanitization ok, CSRF ok.
589 588
 
590 589
 		// Check if billing country already exists.
591
-		if ( $country ) {
590
+		if ($country) {
592 591
 
593 592
 			// Get the country list that does not required any states init.
594 593
 			$states_country = give_states_not_required_country_list();
595 594
 
596 595
 			// Check if states is empty or not.
597
-			if ( array_key_exists( $country, $states_country ) ) {
596
+			if (array_key_exists($country, $states_country)) {
598 597
 				// If states is empty remove the required fields of state in billing cart.
599
-				unset( $required_fields['card_state'] );
598
+				unset($required_fields['card_state']);
600 599
 			}
601 600
 		}
602 601
 	} // End if().
603 602
 
604
-	if ( give_is_company_field_enabled( $form_id ) ) {
605
-		$form_option    = give_get_meta( $form_id, '_give_company_field', true );
606
-		$global_setting = give_get_option( 'company_field' );
603
+	if (give_is_company_field_enabled($form_id)) {
604
+		$form_option    = give_get_meta($form_id, '_give_company_field', true);
605
+		$global_setting = give_get_option('company_field');
607 606
 
608 607
 		$is_company_field_required = false;
609 608
 
610
-		if ( ! empty( $form_option ) && give_is_setting_enabled( $form_option, array( 'required' ) ) ) {
609
+		if ( ! empty($form_option) && give_is_setting_enabled($form_option, array('required'))) {
611 610
 			$is_company_field_required = true;
612 611
 
613
-		} elseif ( 'global' === $form_option && give_is_setting_enabled( $global_setting, array( 'required' ) ) ) {
612
+		} elseif ('global' === $form_option && give_is_setting_enabled($global_setting, array('required'))) {
614 613
 			$is_company_field_required = true;
615 614
 
616
-		} elseif ( empty( $form_option ) && give_is_setting_enabled( $global_setting, array( 'required' ) ) ) {
615
+		} elseif (empty($form_option) && give_is_setting_enabled($global_setting, array('required'))) {
617 616
 			$is_company_field_required = true;
618 617
 
619 618
 		}
620 619
 
621
-		if ( $is_company_field_required ) {
620
+		if ($is_company_field_required) {
622 621
 			$required_fields['give_company_name'] = array(
623 622
 				'error_id'      => 'invalid_company',
624
-				'error_message' => __( 'Please enter Company Name.', 'give' ),
623
+				'error_message' => __('Please enter Company Name.', 'give'),
625 624
 			);
626 625
 		}
627 626
 	}
@@ -631,7 +630,7 @@  discard block
 block discarded – undo
631 630
 	 *
632 631
 	 * @since 1.7
633 632
 	 */
634
-	$required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id );
633
+	$required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id);
635 634
 
636 635
 	return $required_fields;
637 636
 
@@ -646,17 +645,17 @@  discard block
 block discarded – undo
646 645
  *
647 646
  * @return bool
648 647
  */
649
-function give_require_billing_address( $payment_mode ) {
648
+function give_require_billing_address($payment_mode) {
650 649
 
651 650
 	$return          = false;
652
-	$billing_country = ! empty( $_POST['billing_country'] ) ? give_clean( $_POST['billing_country'] ) : 0; // WPCS: input var ok, sanitization ok, CSRF ok.
651
+	$billing_country = ! empty($_POST['billing_country']) ? give_clean($_POST['billing_country']) : 0; // WPCS: input var ok, sanitization ok, CSRF ok.
653 652
 
654
-	if ( $billing_country || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) {
653
+	if ($billing_country || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) {
655 654
 		$return = true;
656 655
 	}
657 656
 
658 657
 	// Let payment gateways and other extensions determine if address fields should be required.
659
-	return apply_filters( 'give_require_billing_address', $return );
658
+	return apply_filters('give_require_billing_address', $return);
660 659
 
661 660
 }
662 661
 
@@ -670,47 +669,47 @@  discard block
 block discarded – undo
670 669
  */
671 670
 function give_donation_form_validate_logged_in_user() {
672 671
 
673
-	$post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok.
672
+	$post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok.
674 673
 	$user_id   = get_current_user_id();
675
-	$form_id   = ! empty( $post_data['give-form-id'] ) ? $post_data['give-form-id'] : 0;
674
+	$form_id   = ! empty($post_data['give-form-id']) ? $post_data['give-form-id'] : 0;
676 675
 
677 676
 	// Start empty array to collect valid user data.
678 677
 	$valid_user_data = array(
679 678
 
680 679
 		// Assume there will be errors.
681
-		'user_id' => - 1,
680
+		'user_id' => -1,
682 681
 	);
683 682
 
684 683
 	// Proceed on;y, if valid $user_id found.
685
-	if ( $user_id > 0 ) {
684
+	if ($user_id > 0) {
686 685
 
687 686
 		// Get the logged in user data.
688
-		$user_data = get_userdata( $user_id );
687
+		$user_data = get_userdata($user_id);
689 688
 
690 689
 		// Validate Required Form Fields.
691
-		give_validate_required_form_fields( $form_id );
690
+		give_validate_required_form_fields($form_id);
692 691
 
693 692
 		// Verify data.
694
-		if ( is_object( $user_data ) && $user_data->ID > 0 ) {
693
+		if (is_object($user_data) && $user_data->ID > 0) {
695 694
 
696 695
 			// Collected logged in user data.
697 696
 			$valid_user_data = array(
698 697
 				'user_id'    => $user_id,
699
-				'user_email' => ! empty( $post_data['give_email'] ) ? sanitize_email( $post_data['give_email'] ) : $user_data->user_email,
700
-				'user_first' => ! empty( $post_data['give_first'] ) ? $post_data['give_first'] : $user_data->first_name,
701
-				'user_last'  => ! empty( $post_data['give_last'] ) ? $post_data['give_last'] : $user_data->last_name,
698
+				'user_email' => ! empty($post_data['give_email']) ? sanitize_email($post_data['give_email']) : $user_data->user_email,
699
+				'user_first' => ! empty($post_data['give_first']) ? $post_data['give_first'] : $user_data->first_name,
700
+				'user_last'  => ! empty($post_data['give_last']) ? $post_data['give_last'] : $user_data->last_name,
702 701
 			);
703 702
 
704 703
 			// Validate essential form fields.
705
-			give_donation_form_validate_name_fields( $post_data );
704
+			give_donation_form_validate_name_fields($post_data);
706 705
 
707
-			if ( ! is_email( $valid_user_data['user_email'] ) ) {
708
-				give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
706
+			if ( ! is_email($valid_user_data['user_email'])) {
707
+				give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
709 708
 			}
710 709
 		} else {
711 710
 
712 711
 			// Set invalid user information error.
713
-			give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) );
712
+			give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give'));
714 713
 		}
715 714
 	}
716 715
 
@@ -731,7 +730,7 @@  discard block
 block discarded – undo
731 730
 	$auto_generated_password = wp_generate_password();
732 731
 	$default_user_data       = array(
733 732
 		'give-form-id'           => '',
734
-		'user_id'                => - 1, // Assume there will be errors.
733
+		'user_id'                => -1, // Assume there will be errors.
735 734
 		'user_first'             => '',
736 735
 		'user_last'              => '',
737 736
 		'give_user_login'        => false,
@@ -741,26 +740,26 @@  discard block
 block discarded – undo
741 740
 	);
742 741
 
743 742
 	// Get data.
744
-	$post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok.
745
-	$user_data = wp_parse_args( $post_data, $default_user_data );
743
+	$post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok.
744
+	$user_data = wp_parse_args($post_data, $default_user_data);
746 745
 
747
-	$form_id = absint( $user_data['give-form-id'] );
748
-	$nonce   = ! empty( $post_data['give-form-user-register-hash'] ) ? $post_data['give-form-user-register-hash'] : '';
746
+	$form_id = absint($user_data['give-form-id']);
747
+	$nonce   = ! empty($post_data['give-form-user-register-hash']) ? $post_data['give-form-user-register-hash'] : '';
749 748
 
750 749
 	// Validate user creation nonce.
751
-	if ( ! wp_verify_nonce( $nonce, "give_form_create_user_nonce_{$form_id}" ) ) {
752
-		give_set_error( 'invalid_nonce', __( 'Nonce verification has failed.', 'give' ) );
750
+	if ( ! wp_verify_nonce($nonce, "give_form_create_user_nonce_{$form_id}")) {
751
+		give_set_error('invalid_nonce', __('Nonce verification has failed.', 'give'));
753 752
 	}
754 753
 
755 754
 	$registering_new_user = false;
756 755
 
757
-	give_donation_form_validate_name_fields( $user_data );
756
+	give_donation_form_validate_name_fields($user_data);
758 757
 
759 758
 	// Start an empty array to collect valid user data.
760 759
 	$valid_user_data = array(
761 760
 
762 761
 		// Assume there will be errors.
763
-		'user_id'    => - 1,
762
+		'user_id'    => -1,
764 763
 
765 764
 		// Get first name.
766 765
 		'user_first' => $user_data['give_first'],
@@ -773,13 +772,13 @@  discard block
 block discarded – undo
773 772
 	);
774 773
 
775 774
 	// Validate Required Form Fields.
776
-	give_validate_required_form_fields( $form_id );
775
+	give_validate_required_form_fields($form_id);
777 776
 
778 777
 	// Set Email as Username.
779 778
 	$valid_user_data['user_login'] = $user_data['give_email'];
780 779
 
781 780
 	// Check if we have an email to verify.
782
-	if ( give_validate_user_email( $user_data['give_email'], $registering_new_user ) ) {
781
+	if (give_validate_user_email($user_data['give_email'], $registering_new_user)) {
783 782
 		$valid_user_data['user_email'] = $user_data['give_email'];
784 783
 	}
785 784
 
@@ -796,47 +795,47 @@  discard block
 block discarded – undo
796 795
  */
797 796
 function give_donation_form_validate_user_login() {
798 797
 
799
-	$post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok.
798
+	$post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok.
800 799
 
801 800
 	// Start an array to collect valid user data.
802 801
 	$valid_user_data = array(
803 802
 
804 803
 		// Assume there will be errors.
805
-		'user_id' => - 1,
804
+		'user_id' => -1,
806 805
 	);
807 806
 
808 807
 	// Bailout, if Username is empty.
809
-	if ( empty( $post_data['give_user_login'] ) ) {
810
-		give_set_error( 'must_log_in', __( 'You must register or login to complete your donation.', 'give' ) );
808
+	if (empty($post_data['give_user_login'])) {
809
+		give_set_error('must_log_in', __('You must register or login to complete your donation.', 'give'));
811 810
 
812 811
 		return $valid_user_data;
813 812
 	}
814 813
 
815 814
 	// Get the user by login.
816
-	$user_data = get_user_by( 'login', strip_tags( $post_data['give_user_login'] ) );
815
+	$user_data = get_user_by('login', strip_tags($post_data['give_user_login']));
817 816
 
818 817
 	// Check if user exists.
819
-	if ( $user_data ) {
818
+	if ($user_data) {
820 819
 
821 820
 		// Get password.
822
-		$user_pass = ! empty( $post_data['give_user_pass'] ) ? $post_data['give_user_pass'] : false;
821
+		$user_pass = ! empty($post_data['give_user_pass']) ? $post_data['give_user_pass'] : false;
823 822
 
824 823
 		// Check user_pass.
825
-		if ( $user_pass ) {
824
+		if ($user_pass) {
826 825
 
827 826
 			// Check if password is valid.
828
-			if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) {
827
+			if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) {
829 828
 
830
-				$current_page_url = site_url() . '/' . get_page_uri();
829
+				$current_page_url = site_url().'/'.get_page_uri();
831 830
 
832 831
 				// Incorrect password.
833 832
 				give_set_error(
834 833
 					'password_incorrect',
835 834
 					sprintf(
836 835
 						'%1$s <a href="%2$s">%3$s</a>',
837
-						__( 'The password you entered is incorrect.', 'give' ),
838
-						wp_lostpassword_url( $current_page_url ),
839
-						__( 'Reset Password', 'give' )
836
+						__('The password you entered is incorrect.', 'give'),
837
+						wp_lostpassword_url($current_page_url),
838
+						__('Reset Password', 'give')
840 839
 					)
841 840
 				);
842 841
 
@@ -854,11 +853,11 @@  discard block
 block discarded – undo
854 853
 			}
855 854
 		} else {
856 855
 			// Empty password.
857
-			give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) );
856
+			give_set_error('password_empty', __('Enter a password.', 'give'));
858 857
 		}
859 858
 	} else {
860 859
 		// No username.
861
-		give_set_error( 'username_incorrect', __( 'The username you entered does not exist.', 'give' ) );
860
+		give_set_error('username_incorrect', __('The username you entered does not exist.', 'give'));
862 861
 	} // End if().
863 862
 
864 863
 	return $valid_user_data;
@@ -874,8 +873,8 @@  discard block
 block discarded – undo
874 873
  */
875 874
 function give_donation_form_validate_guest_user() {
876 875
 
877
-	$post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok.
878
-	$form_id   = ! empty( $post_data['give-form-id'] ) ? $post_data['give-form-id'] : 0;
876
+	$post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok.
877
+	$form_id   = ! empty($post_data['give-form-id']) ? $post_data['give-form-id'] : 0;
879 878
 
880 879
 	// Start an array to collect valid user data.
881 880
 	$valid_user_data = array(
@@ -884,22 +883,22 @@  discard block
 block discarded – undo
884 883
 	);
885 884
 
886 885
 	// Validate name fields.
887
-	give_donation_form_validate_name_fields( $post_data );
886
+	give_donation_form_validate_name_fields($post_data);
888 887
 
889 888
 	// Validate Required Form Fields.
890
-	give_validate_required_form_fields( $form_id );
889
+	give_validate_required_form_fields($form_id);
891 890
 
892 891
 	// Get the guest email.
893
-	$guest_email = ! empty( $post_data['give_email'] ) ? $post_data['give_email'] : false;
892
+	$guest_email = ! empty($post_data['give_email']) ? $post_data['give_email'] : false;
894 893
 
895 894
 	// Check email.
896
-	if ( $guest_email && strlen( $guest_email ) > 0 ) {
895
+	if ($guest_email && strlen($guest_email) > 0) {
897 896
 
898 897
 		// Validate email.
899
-		if ( ! is_email( $guest_email ) ) {
898
+		if ( ! is_email($guest_email)) {
900 899
 
901 900
 			// Invalid email.
902
-			give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) );
901
+			give_set_error('email_invalid', __('Invalid email.', 'give'));
903 902
 
904 903
 		} else {
905 904
 
@@ -907,15 +906,15 @@  discard block
 block discarded – undo
907 906
 			$valid_user_data['user_email'] = $guest_email;
908 907
 
909 908
 			// Get user_id from donor if exist.
910
-			$donor = new Give_Donor( $guest_email );
909
+			$donor = new Give_Donor($guest_email);
911 910
 
912
-			if ( $donor->id && $donor->user_id ) {
911
+			if ($donor->id && $donor->user_id) {
913 912
 				$valid_user_data['user_id'] = $donor->user_id;
914 913
 			}
915 914
 		}
916 915
 	} else {
917 916
 		// No email.
918
-		give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) );
917
+		give_set_error('email_empty', __('Enter an email.', 'give'));
919 918
 	}
920 919
 
921 920
 	return $valid_user_data;
@@ -931,36 +930,36 @@  discard block
 block discarded – undo
931 930
  *
932 931
  * @return  integer
933 932
  */
934
-function give_register_and_login_new_user( $user_data = array() ) {
933
+function give_register_and_login_new_user($user_data = array()) {
935 934
 	// Verify the array.
936
-	if ( empty( $user_data ) ) {
937
-		return - 1;
935
+	if (empty($user_data)) {
936
+		return -1;
938 937
 	}
939 938
 
940
-	if ( give_get_errors() ) {
941
-		return - 1;
939
+	if (give_get_errors()) {
940
+		return -1;
942 941
 	}
943 942
 
944
-	$user_args = apply_filters( 'give_insert_user_args', array(
945
-		'user_login'      => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '',
946
-		'user_pass'       => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '',
947
-		'user_email'      => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '',
948
-		'first_name'      => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '',
949
-		'last_name'       => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '',
950
-		'user_registered' => date( 'Y-m-d H:i:s' ),
951
-		'role'            => give_get_option( 'donor_default_user_role', 'give_donor' ),
952
-	), $user_data );
943
+	$user_args = apply_filters('give_insert_user_args', array(
944
+		'user_login'      => isset($user_data['user_login']) ? $user_data['user_login'] : '',
945
+		'user_pass'       => isset($user_data['user_pass']) ? $user_data['user_pass'] : '',
946
+		'user_email'      => isset($user_data['user_email']) ? $user_data['user_email'] : '',
947
+		'first_name'      => isset($user_data['user_first']) ? $user_data['user_first'] : '',
948
+		'last_name'       => isset($user_data['user_last']) ? $user_data['user_last'] : '',
949
+		'user_registered' => date('Y-m-d H:i:s'),
950
+		'role'            => give_get_option('donor_default_user_role', 'give_donor'),
951
+	), $user_data);
953 952
 
954 953
 	// Insert new user.
955
-	$user_id = wp_insert_user( $user_args );
954
+	$user_id = wp_insert_user($user_args);
956 955
 
957 956
 	// Validate inserted user.
958
-	if ( is_wp_error( $user_id ) ) {
959
-		return - 1;
957
+	if (is_wp_error($user_id)) {
958
+		return -1;
960 959
 	}
961 960
 
962 961
 	// Allow themes and plugins to filter the user data.
963
-	$user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args );
962
+	$user_data = apply_filters('give_insert_user_data', $user_data, $user_args);
964 963
 
965 964
 	/**
966 965
 	 * Fires after inserting user.
@@ -970,7 +969,7 @@  discard block
 block discarded – undo
970 969
 	 * @param int $user_id User id.
971 970
 	 * @param array $user_data Array containing user data.
972 971
 	 */
973
-	do_action( 'give_insert_user', $user_id, $user_data );
972
+	do_action('give_insert_user', $user_id, $user_data);
974 973
 
975 974
 	/**
976 975
 	 * Filter allow user to alter if user when to login or not when user is register for the first time.
@@ -979,9 +978,9 @@  discard block
 block discarded – undo
979 978
 	 *
980 979
 	 * return bool True if login with registration and False if only want to register.
981 980
 	 */
982
-	if ( true === (bool) apply_filters( 'give_log_user_in_on_register', true ) ) {
981
+	if (true === (bool) apply_filters('give_log_user_in_on_register', true)) {
983 982
 		// Login new user.
984
-		give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] );
983
+		give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']);
985 984
 	}
986 985
 
987 986
 	// Return user id.
@@ -998,33 +997,33 @@  discard block
 block discarded – undo
998 997
  *
999 998
  * @return  array|bool
1000 999
  */
1001
-function give_get_donation_form_user( $valid_data = array() ) {
1000
+function give_get_donation_form_user($valid_data = array()) {
1002 1001
 
1003 1002
 	// Initialize user.
1004 1003
 	$user      = false;
1005
-	$is_ajax   = defined( 'DOING_AJAX' ) && DOING_AJAX;
1006
-	$post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok.
1004
+	$is_ajax   = defined('DOING_AJAX') && DOING_AJAX;
1005
+	$post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok.
1007 1006
 
1008
-	if ( $is_ajax ) {
1007
+	if ($is_ajax) {
1009 1008
 
1010 1009
 		// Do not create or login the user during the ajax submission (check for errors only).
1011 1010
 		return true;
1012
-	} elseif ( is_user_logged_in() ) {
1011
+	} elseif (is_user_logged_in()) {
1013 1012
 
1014 1013
 		// Set the valid user as the logged in collected data.
1015 1014
 		$user = $valid_data['logged_in_user'];
1016
-	} elseif ( true === $valid_data['need_new_user'] || true === $valid_data['need_user_login'] ) {
1015
+	} elseif (true === $valid_data['need_new_user'] || true === $valid_data['need_user_login']) {
1017 1016
 
1018 1017
 		// New user registration.
1019
-		if ( true === $valid_data['need_new_user'] ) {
1018
+		if (true === $valid_data['need_new_user']) {
1020 1019
 
1021 1020
 			// Set user.
1022 1021
 			$user = $valid_data['new_user_data'];
1023 1022
 
1024 1023
 			// Register and login new user.
1025
-			$user['user_id'] = give_register_and_login_new_user( $user );
1024
+			$user['user_id'] = give_register_and_login_new_user($user);
1026 1025
 
1027
-		} elseif ( true === $valid_data['need_user_login'] && ! $is_ajax ) {
1026
+		} elseif (true === $valid_data['need_user_login'] && ! $is_ajax) {
1028 1027
 
1029 1028
 			/**
1030 1029
 			 * The login form is now processed in the give_process_donation_login() function.
@@ -1036,47 +1035,47 @@  discard block
 block discarded – undo
1036 1035
 			$user = $valid_data['login_user_data'];
1037 1036
 
1038 1037
 			// Login user.
1039
-			give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] );
1038
+			give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']);
1040 1039
 		}
1041 1040
 	} // End if().
1042 1041
 
1043 1042
 	// Check guest checkout.
1044
-	if ( false === $user && false === give_logged_in_only( $post_data['give-form-id'] ) ) {
1043
+	if (false === $user && false === give_logged_in_only($post_data['give-form-id'])) {
1045 1044
 
1046 1045
 		// Set user.
1047 1046
 		$user = $valid_data['guest_user_data'];
1048 1047
 	}
1049 1048
 
1050 1049
 	// Verify we have an user.
1051
-	if ( false === $user || empty( $user ) ) {
1050
+	if (false === $user || empty($user)) {
1052 1051
 		return false;
1053 1052
 	}
1054 1053
 
1055 1054
 	// Get user first name.
1056
-	if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) {
1057
-		$user['user_first'] = isset( $post_data['give_first'] ) ? strip_tags( trim( $post_data['give_first'] ) ) : '';
1055
+	if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) {
1056
+		$user['user_first'] = isset($post_data['give_first']) ? strip_tags(trim($post_data['give_first'])) : '';
1058 1057
 	}
1059 1058
 
1060 1059
 	// Get user last name.
1061
-	if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) {
1062
-		$user['user_last'] = isset( $post_data['give_last'] ) ? strip_tags( trim( $post_data['give_last'] ) ) : '';
1060
+	if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) {
1061
+		$user['user_last'] = isset($post_data['give_last']) ? strip_tags(trim($post_data['give_last'])) : '';
1063 1062
 	}
1064 1063
 
1065 1064
 	// Add Title Prefix to user information.
1066
-	if ( empty( $user['user_title'] ) || strlen( trim( $user['user_title'] ) ) < 1 ) {
1067
-		$user['user_title'] = ! empty( $post_data['give_title'] ) ? strip_tags( trim( $post_data['give_title'] ) ) : '';
1065
+	if (empty($user['user_title']) || strlen(trim($user['user_title'])) < 1) {
1066
+		$user['user_title'] = ! empty($post_data['give_title']) ? strip_tags(trim($post_data['give_title'])) : '';
1068 1067
 	}
1069 1068
 
1070 1069
 	// Get the user's billing address details.
1071 1070
 	$user['address']            = array();
1072
-	$user['address']['line1']   = ! empty( $post_data['card_address'] ) ? $post_data['card_address'] : false;
1073
-	$user['address']['line2']   = ! empty( $post_data['card_address_2'] ) ? $post_data['card_address_2'] : false;
1074
-	$user['address']['city']    = ! empty( $post_data['card_city'] ) ? $post_data['card_city'] : false;
1075
-	$user['address']['state']   = ! empty( $post_data['card_state'] ) ? $post_data['card_state'] : false;
1076
-	$user['address']['zip']     = ! empty( $post_data['card_zip'] ) ? $post_data['card_zip'] : false;
1077
-	$user['address']['country'] = ! empty( $post_data['billing_country'] ) ? $post_data['billing_country'] : false;
1078
-
1079
-	if ( empty( $user['address']['country'] ) ) {
1071
+	$user['address']['line1']   = ! empty($post_data['card_address']) ? $post_data['card_address'] : false;
1072
+	$user['address']['line2']   = ! empty($post_data['card_address_2']) ? $post_data['card_address_2'] : false;
1073
+	$user['address']['city']    = ! empty($post_data['card_city']) ? $post_data['card_city'] : false;
1074
+	$user['address']['state']   = ! empty($post_data['card_state']) ? $post_data['card_state'] : false;
1075
+	$user['address']['zip']     = ! empty($post_data['card_zip']) ? $post_data['card_zip'] : false;
1076
+	$user['address']['country'] = ! empty($post_data['billing_country']) ? $post_data['billing_country'] : false;
1077
+
1078
+	if (empty($user['address']['country'])) {
1080 1079
 		$user['address'] = false;
1081 1080
 	} // End if().
1082 1081
 
@@ -1097,16 +1096,16 @@  discard block
 block discarded – undo
1097 1096
 	$card_data = give_get_donation_cc_info();
1098 1097
 
1099 1098
 	// Validate the card zip.
1100
-	if ( ! empty( $card_data['card_zip'] ) ) {
1101
-		if ( ! give_donation_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) {
1102
-			give_set_error( 'invalid_cc_zip', __( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) );
1099
+	if ( ! empty($card_data['card_zip'])) {
1100
+		if ( ! give_donation_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) {
1101
+			give_set_error('invalid_cc_zip', __('The zip / postal code you entered for your billing address is invalid.', 'give'));
1103 1102
 		}
1104 1103
 	}
1105 1104
 
1106 1105
 	// Ensure no spaces.
1107
-	if ( ! empty( $card_data['card_number'] ) ) {
1108
-		$card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs.
1109
-		$card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces.
1106
+	if ( ! empty($card_data['card_number'])) {
1107
+		$card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs.
1108
+		$card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces.
1110 1109
 	}
1111 1110
 
1112 1111
 	// This should validate card numbers at some point too.
@@ -1124,20 +1123,20 @@  discard block
 block discarded – undo
1124 1123
 function give_get_donation_cc_info() {
1125 1124
 
1126 1125
 	// Sanitize the values submitted with donation form.
1127
-	$post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok.
1126
+	$post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok.
1128 1127
 
1129 1128
 	$cc_info                   = array();
1130
-	$cc_info['card_name']      = ! empty( $post_data['card_name'] ) ? $post_data['card_name'] : '';
1131
-	$cc_info['card_number']    = ! empty( $post_data['card_number'] ) ? $post_data['card_number'] : '';
1132
-	$cc_info['card_cvc']       = ! empty( $post_data['card_cvc'] ) ? $post_data['card_cvc'] : '';
1133
-	$cc_info['card_exp_month'] = ! empty( $post_data['card_exp_month'] ) ? $post_data['card_exp_month'] : '';
1134
-	$cc_info['card_exp_year']  = ! empty( $post_data['card_exp_year'] ) ? $post_data['card_exp_year'] : '';
1135
-	$cc_info['card_address']   = ! empty( $post_data['card_address'] ) ? $post_data['card_address'] : '';
1136
-	$cc_info['card_address_2'] = ! empty( $post_data['card_address_2'] ) ? $post_data['card_address_2'] : '';
1137
-	$cc_info['card_city']      = ! empty( $post_data['card_city'] ) ? $post_data['card_city'] : '';
1138
-	$cc_info['card_state']     = ! empty( $post_data['card_state'] ) ? $post_data['card_state'] : '';
1139
-	$cc_info['card_country']   = ! empty( $post_data['billing_country'] ) ? $post_data['billing_country'] : '';
1140
-	$cc_info['card_zip']       = ! empty( $post_data['card_zip'] ) ? $post_data['card_zip'] : '';
1129
+	$cc_info['card_name']      = ! empty($post_data['card_name']) ? $post_data['card_name'] : '';
1130
+	$cc_info['card_number']    = ! empty($post_data['card_number']) ? $post_data['card_number'] : '';
1131
+	$cc_info['card_cvc']       = ! empty($post_data['card_cvc']) ? $post_data['card_cvc'] : '';
1132
+	$cc_info['card_exp_month'] = ! empty($post_data['card_exp_month']) ? $post_data['card_exp_month'] : '';
1133
+	$cc_info['card_exp_year']  = ! empty($post_data['card_exp_year']) ? $post_data['card_exp_year'] : '';
1134
+	$cc_info['card_address']   = ! empty($post_data['card_address']) ? $post_data['card_address'] : '';
1135
+	$cc_info['card_address_2'] = ! empty($post_data['card_address_2']) ? $post_data['card_address_2'] : '';
1136
+	$cc_info['card_city']      = ! empty($post_data['card_city']) ? $post_data['card_city'] : '';
1137
+	$cc_info['card_state']     = ! empty($post_data['card_state']) ? $post_data['card_state'] : '';
1138
+	$cc_info['card_country']   = ! empty($post_data['billing_country']) ? $post_data['billing_country'] : '';
1139
+	$cc_info['card_zip']       = ! empty($post_data['card_zip']) ? $post_data['card_zip'] : '';
1141 1140
 
1142 1141
 	// Return cc info.
1143 1142
 	return $cc_info;
@@ -1153,14 +1152,14 @@  discard block
 block discarded – undo
1153 1152
  *
1154 1153
  * @return bool|mixed
1155 1154
  */
1156
-function give_donation_form_validate_cc_zip( $zip = 0, $country_code = '' ) {
1155
+function give_donation_form_validate_cc_zip($zip = 0, $country_code = '') {
1157 1156
 	$ret = false;
1158 1157
 
1159
-	if ( empty( $zip ) || empty( $country_code ) ) {
1158
+	if (empty($zip) || empty($country_code)) {
1160 1159
 		return $ret;
1161 1160
 	}
1162 1161
 
1163
-	$country_code = strtoupper( $country_code );
1162
+	$country_code = strtoupper($country_code);
1164 1163
 
1165 1164
 	$zip_regex = array(
1166 1165
 		'AD' => 'AD\d{3}',
@@ -1320,11 +1319,11 @@  discard block
 block discarded – undo
1320 1319
 		'ZM' => '\d{5}',
1321 1320
 	);
1322 1321
 
1323
-	if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) {
1322
+	if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) {
1324 1323
 		$ret = true;
1325 1324
 	}
1326 1325
 
1327
-	return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code );
1326
+	return apply_filters('give_is_zip_valid', $ret, $zip, $country_code);
1328 1327
 }
1329 1328
 
1330 1329
 /**
@@ -1336,60 +1335,60 @@  discard block
 block discarded – undo
1336 1335
  *
1337 1336
  * @return bool
1338 1337
  */
1339
-function give_validate_donation_amount( $valid_data ) {
1338
+function give_validate_donation_amount($valid_data) {
1340 1339
 
1341
-	$post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok.
1340
+	$post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok.
1342 1341
 
1343 1342
 	/* @var Give_Donate_Form $form */
1344
-	$form = new Give_Donate_Form( $post_data['give-form-id'] );
1343
+	$form = new Give_Donate_Form($post_data['give-form-id']);
1345 1344
 
1346 1345
 	// Get the form currency.
1347
-	$form_currency = give_get_currency( $post_data['give-form-id'] );
1346
+	$form_currency = give_get_currency($post_data['give-form-id']);
1348 1347
 
1349 1348
 	$donation_level_matched = false;
1350 1349
 
1351
-	if ( $form->is_set_type_donation_form() ) {
1350
+	if ($form->is_set_type_donation_form()) {
1352 1351
 
1353 1352
 		// Sanitize donation amount.
1354
-		$post_data['give-amount'] = give_maybe_sanitize_amount( $post_data['give-amount'], array( 'currency' => $form_currency ) );
1353
+		$post_data['give-amount'] = give_maybe_sanitize_amount($post_data['give-amount'], array('currency' => $form_currency));
1355 1354
 
1356 1355
 		// Backward compatibility.
1357
-		if ( $form->is_custom_price( $post_data['give-amount'] ) ) {
1356
+		if ($form->is_custom_price($post_data['give-amount'])) {
1358 1357
 			$post_data['give-price-id'] = 'custom';
1359 1358
 		}
1360 1359
 
1361 1360
 		$donation_level_matched = true;
1362 1361
 
1363
-	} elseif ( $form->is_multi_type_donation_form() ) {
1362
+	} elseif ($form->is_multi_type_donation_form()) {
1364 1363
 
1365 1364
 		$variable_prices = $form->get_prices();
1366 1365
 
1367 1366
 		// Bailout.
1368
-		if ( ! $variable_prices ) {
1367
+		if ( ! $variable_prices) {
1369 1368
 			return false;
1370 1369
 		}
1371 1370
 
1372 1371
 		// Sanitize donation amount.
1373
-		$post_data['give-amount']     = give_maybe_sanitize_amount( $post_data['give-amount'], array( 'currency' => $form_currency ) );
1374
-		$variable_price_option_amount = give_maybe_sanitize_amount( give_get_price_option_amount( $post_data['give-form-id'], $post_data['give-price-id'] ), array( 'currency' => $form_currency ) );
1372
+		$post_data['give-amount']     = give_maybe_sanitize_amount($post_data['give-amount'], array('currency' => $form_currency));
1373
+		$variable_price_option_amount = give_maybe_sanitize_amount(give_get_price_option_amount($post_data['give-form-id'], $post_data['give-price-id']), array('currency' => $form_currency));
1375 1374
 		$new_price_id                 = '';
1376 1375
 
1377
-		if ( $post_data['give-amount'] === $variable_price_option_amount ) {
1376
+		if ($post_data['give-amount'] === $variable_price_option_amount) {
1378 1377
 			return true;
1379 1378
 		}
1380 1379
 
1381
-		if ( $form->is_custom_price( $post_data['give-amount'] ) ) {
1380
+		if ($form->is_custom_price($post_data['give-amount'])) {
1382 1381
 			$new_price_id = 'custom';
1383 1382
 		} else {
1384 1383
 
1385 1384
 			// Find correct donation level from all donation levels.
1386
-			foreach ( $variable_prices as $variable_price ) {
1385
+			foreach ($variable_prices as $variable_price) {
1387 1386
 
1388 1387
 				// Sanitize level amount.
1389
-				$variable_price['_give_amount'] = give_maybe_sanitize_amount( $variable_price['_give_amount'] );
1388
+				$variable_price['_give_amount'] = give_maybe_sanitize_amount($variable_price['_give_amount']);
1390 1389
 
1391 1390
 				// Set first match donation level ID.
1392
-				if ( $post_data['give-amount'] === $variable_price['_give_amount'] ) {
1391
+				if ($post_data['give-amount'] === $variable_price['_give_amount']) {
1393 1392
 					$new_price_id = $variable_price['_give_id']['level_id'];
1394 1393
 					break;
1395 1394
 				}
@@ -1398,26 +1397,26 @@  discard block
 block discarded – undo
1398 1397
 
1399 1398
 		// If donation amount is not find in donation levels then check if form has custom donation feature enable or not.
1400 1399
 		// If yes then set price id to custom if amount is greater then custom minimum amount (if any).
1401
-		if ( $post_data['give-price-id'] === $new_price_id ) {
1400
+		if ($post_data['give-price-id'] === $new_price_id) {
1402 1401
 			$donation_level_matched = true;
1403 1402
 		}
1404 1403
 	} // End if().
1405 1404
 
1406
-	if ( ! $donation_level_matched ) {
1405
+	if ( ! $donation_level_matched) {
1407 1406
 		give_set_error(
1408 1407
 			'invalid_donation_amount',
1409 1408
 			sprintf(
1410 1409
 			/* translators: %s: invalid donation amount */
1411
-				__( 'Donation amount %s is invalid.', 'give' ),
1410
+				__('Donation amount %s is invalid.', 'give'),
1412 1411
 				give_currency_filter(
1413
-					give_format_amount( $post_data['give-amount'], array( 'sanitize' => false, ) )
1412
+					give_format_amount($post_data['give-amount'], array('sanitize' => false,))
1414 1413
 				)
1415 1414
 			)
1416 1415
 		);
1417 1416
 	}
1418 1417
 }
1419 1418
 
1420
-add_action( 'give_checkout_error_checks', 'give_validate_donation_amount', 10, 1 );
1419
+add_action('give_checkout_error_checks', 'give_validate_donation_amount', 10, 1);
1421 1420
 
1422 1421
 /**
1423 1422
  * Validate Required Form Fields.
@@ -1426,20 +1425,20 @@  discard block
 block discarded – undo
1426 1425
  *
1427 1426
  * @since 2.0
1428 1427
  */
1429
-function give_validate_required_form_fields( $form_id ) {
1428
+function give_validate_required_form_fields($form_id) {
1430 1429
 
1431 1430
 	// Sanitize values submitted with donation form.
1432
-	$post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok.
1431
+	$post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok.
1433 1432
 
1434 1433
 	// Loop through required fields and show error messages.
1435
-	foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
1434
+	foreach (give_get_required_fields($form_id) as $field_name => $value) {
1436 1435
 
1437 1436
 		// Clean Up Data of the input fields.
1438
-		$field_value = $post_data[ $field_name ];
1437
+		$field_value = $post_data[$field_name];
1439 1438
 
1440 1439
 		// Check whether the required field is empty, then show the error message.
1441
-		if ( in_array( $value, give_get_required_fields( $form_id ), true ) && empty( $field_value ) ) {
1442
-			give_set_error( $value['error_id'], $value['error_message'] );
1440
+		if (in_array($value, give_get_required_fields($form_id), true) && empty($field_value)) {
1441
+			give_set_error($value['error_id'], $value['error_message']);
1443 1442
 		}
1444 1443
 	}
1445 1444
 }
@@ -1453,12 +1452,12 @@  discard block
 block discarded – undo
1453 1452
  *
1454 1453
  * @return void
1455 1454
  */
1456
-function give_donation_form_validate_name_fields( $post_data ) {
1455
+function give_donation_form_validate_name_fields($post_data) {
1457 1456
 
1458
-	$is_alpha_first_name = ( ! is_email( $post_data['give_first'] ) && ! preg_match( '~[0-9]~', $post_data['give_first'] ) );
1459
-	$is_alpha_last_name  = ( ! is_email( $post_data['give_last'] ) && ! preg_match( '~[0-9]~', $post_data['give_last'] ) );
1457
+	$is_alpha_first_name = ( ! is_email($post_data['give_first']) && ! preg_match('~[0-9]~', $post_data['give_first']));
1458
+	$is_alpha_last_name  = ( ! is_email($post_data['give_last']) && ! preg_match('~[0-9]~', $post_data['give_last']));
1460 1459
 
1461
-	if ( ! $is_alpha_first_name || ( ! empty( $post_data['give_last'] ) && ! $is_alpha_last_name ) ) {
1462
-		give_set_error( 'invalid_name', esc_html__( 'The First Name and Last Name fields cannot contain an email address or numbers.', 'give' ) );
1460
+	if ( ! $is_alpha_first_name || ( ! empty($post_data['give_last']) && ! $is_alpha_last_name)) {
1461
+		give_set_error('invalid_name', esc_html__('The First Name and Last Name fields cannot contain an email address or numbers.', 'give'));
1463 1462
 	}
1464 1463
 }
Please login to merge, or discard this patch.
includes/class-give-readme-parser.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @license     https://opensource.org/licenses/gpl-license GNU Public License
9 9
  * @since       2.1.4
10 10
  */
11
-class Give_Readme_Parser{
11
+class Give_Readme_Parser {
12 12
 	/**
13 13
 	 * Readme file url
14 14
 	 *
@@ -32,9 +32,9 @@  discard block
 block discarded – undo
32 32
 	 *
33 33
 	 * @param string $file_url
34 34
 	 */
35
-	function __construct( $file_url ) {
35
+	function __construct($file_url) {
36 36
 		$this->file_url     = $file_url;
37
-		$this->file_content = wp_remote_retrieve_body( wp_remote_get( $this->file_url ) );
37
+		$this->file_content = wp_remote_retrieve_body(wp_remote_get($this->file_url));
38 38
 	}
39 39
 
40 40
 	/**
@@ -47,11 +47,11 @@  discard block
 block discarded – undo
47 47
 	 */
48 48
 	public function requires_at_least() {
49 49
 		// Regex to extract Give core minimum version from the readme.txt file.
50
-		preg_match('|Requires Give:(.*)|i', $this->file_content, $_requires_at_least );
50
+		preg_match('|Requires Give:(.*)|i', $this->file_content, $_requires_at_least);
51 51
 
52
-		if( is_array( $_requires_at_least ) && 1 < count( $_requires_at_least ) ) {
53
-			$_requires_at_least = trim( $_requires_at_least[1] );
54
-		}else{
52
+		if (is_array($_requires_at_least) && 1 < count($_requires_at_least)) {
53
+			$_requires_at_least = trim($_requires_at_least[1]);
54
+		} else {
55 55
 			$_requires_at_least = null;
56 56
 		}
57 57
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
 
52 52
 		if( is_array( $_requires_at_least ) && 1 < count( $_requires_at_least ) ) {
53 53
 			$_requires_at_least = trim( $_requires_at_least[1] );
54
-		}else{
54
+		} else{
55 55
 			$_requires_at_least = null;
56 56
 		}
57 57
 
Please login to merge, or discard this patch.
includes/emails/template.php 1 patch
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
  *
43 43
  * @return string $message Fully formatted message
44 44
  */
45
-function give_email_template_tags( $message, $payment_data, $payment_id, $admin_notice = false ) {
46
-	return give_do_email_tags( $message, $payment_id );
45
+function give_email_template_tags($message, $payment_data, $payment_id, $admin_notice = false) {
46
+	return give_do_email_tags($message, $payment_id);
47 47
 }
48 48
 
49 49
 /**
@@ -57,45 +57,45 @@  discard block
 block discarded – undo
57 57
  *
58 58
  * @return string $message Fully formatted message
59 59
  */
60
-function give_email_preview_template_tags( $message ) {
60
+function give_email_preview_template_tags($message) {
61 61
 
62
-	$price = give_currency_filter( give_format_amount( 10.50, array( 'sanitize' => false ) ) );
62
+	$price = give_currency_filter(give_format_amount(10.50, array('sanitize' => false)));
63 63
 
64 64
 	$gateway = 'PayPal';
65 65
 
66
-	$receipt_id = strtolower( md5( uniqid() ) );
66
+	$receipt_id = strtolower(md5(uniqid()));
67 67
 
68
-	$payment_id = rand( 1, 100 );
69
-	$receipt_link_url = esc_url( add_query_arg( array( 'payment_key' => $receipt_id ), give_get_history_page_uri() ) );
68
+	$payment_id = rand(1, 100);
69
+	$receipt_link_url = esc_url(add_query_arg(array('payment_key' => $receipt_id), give_get_history_page_uri()));
70 70
 
71 71
 	$receipt_link     = sprintf(
72 72
 		'<a href="%1$s">%2$s</a>',
73 73
 		$receipt_link_url,
74
-		esc_html__( 'View the receipt in your browser &raquo;', 'give' )
74
+		esc_html__('View the receipt in your browser &raquo;', 'give')
75 75
 	);
76 76
 
77 77
 	// Set user.
78 78
 	$user = wp_get_current_user();
79 79
 
80
-	$message = str_replace( '{name}', $user->display_name, $message );
81
-	$message = str_replace( '{fullname}', $user->display_name, $message );
82
-	$message = str_replace( '{username}', $user->user_login, $message );
83
-	$message = str_replace( '{user_email}', $user->user_email, $message );
84
-	$message = str_replace( '{billing_address}', "123 Test Street, Unit 222\nSomewhere Town, CA, 92101", $message );
85
-	$message = str_replace( '{date}', date( give_date_format(), current_time( 'timestamp' ) ), $message );
86
-	$message = str_replace( '{amount}', $price, $message );
87
-	$message = str_replace( '{price}', $price, $message );
88
-	$message = str_replace( '{donation}', esc_html__( 'Sample Donation Form Title', 'give' ), $message );
89
-	$message = str_replace( '{form_title}', esc_html__( 'Sample Donation Form Title - Sample Donation Level', 'give' ), $message );
90
-	$message = str_replace( '{receipt_id}', $receipt_id, $message );
91
-	$message = str_replace( '{payment_method}', $gateway, $message );
92
-	$message = str_replace( '{sitename}', get_bloginfo( 'name' ), $message );
93
-	$message = str_replace( '{payment_id}', $payment_id, $message );
94
-	$message = str_replace( '{receipt_link}', $receipt_link, $message );
95
-	$message = str_replace( '{receipt_link_url}', $receipt_link_url, $message );
96
-	$message = str_replace( '{pdf_receipt}', '<a href="#">Download Receipt</a>', $message );
97
-
98
-	return wpautop( apply_filters( 'give_email_preview_template_tags', $message ) );
80
+	$message = str_replace('{name}', $user->display_name, $message);
81
+	$message = str_replace('{fullname}', $user->display_name, $message);
82
+	$message = str_replace('{username}', $user->user_login, $message);
83
+	$message = str_replace('{user_email}', $user->user_email, $message);
84
+	$message = str_replace('{billing_address}', "123 Test Street, Unit 222\nSomewhere Town, CA, 92101", $message);
85
+	$message = str_replace('{date}', date(give_date_format(), current_time('timestamp')), $message);
86
+	$message = str_replace('{amount}', $price, $message);
87
+	$message = str_replace('{price}', $price, $message);
88
+	$message = str_replace('{donation}', esc_html__('Sample Donation Form Title', 'give'), $message);
89
+	$message = str_replace('{form_title}', esc_html__('Sample Donation Form Title - Sample Donation Level', 'give'), $message);
90
+	$message = str_replace('{receipt_id}', $receipt_id, $message);
91
+	$message = str_replace('{payment_method}', $gateway, $message);
92
+	$message = str_replace('{sitename}', get_bloginfo('name'), $message);
93
+	$message = str_replace('{payment_id}', $payment_id, $message);
94
+	$message = str_replace('{receipt_link}', $receipt_link, $message);
95
+	$message = str_replace('{receipt_link_url}', $receipt_link_url, $message);
96
+	$message = str_replace('{pdf_receipt}', '<a href="#">Download Receipt</a>', $message);
97
+
98
+	return wpautop(apply_filters('give_email_preview_template_tags', $message));
99 99
 }
100 100
 
101 101
 
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
  *
112 112
  * @return array
113 113
  */
114
-function give_email_preview_buttons_callback( $field ) {
115
-	$field_id = str_replace( '_preview_buttons', '', $field['id'] );
114
+function give_email_preview_buttons_callback($field) {
115
+	$field_id = str_replace('_preview_buttons', '', $field['id']);
116 116
 
117 117
 	ob_start();
118 118
 
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 		'<a href="%1$s" class="button-secondary" target="_blank">%2$s</a>',
121 121
 		wp_nonce_url(
122 122
 			add_query_arg(
123
-				array( 'give_action' => 'preview_email', 'email_type' => $field_id ),
123
+				array('give_action' => 'preview_email', 'email_type' => $field_id),
124 124
 				home_url()
125 125
 			), 'give-preview-email'
126 126
 		),
@@ -130,13 +130,13 @@  discard block
 block discarded – undo
130 130
 	echo sprintf(
131 131
 		' <a href="%1$s" aria-label="%2$s" class="button-secondary">%3$s</a>',
132 132
 		wp_nonce_url(
133
-				add_query_arg( array(
133
+				add_query_arg(array(
134 134
 			'give_action'  => 'send_preview_email',
135 135
 			'email_type' => $field_id,
136 136
 			'give-messages[]' => 'sent-test-email',
137
-		) ), 'give-send-preview-email' ),
138
-		esc_attr__( 'Send Test Email.', 'give' ),
139
-		esc_html__( 'Send Test Email', 'give' )
137
+		)), 'give-send-preview-email' ),
138
+		esc_attr__('Send Test Email.', 'give'),
139
+		esc_html__('Send Test Email', 'give')
140 140
 	);
141 141
 
142 142
 	echo ob_get_clean();
@@ -155,34 +155,34 @@  discard block
 block discarded – undo
155 155
 
156 156
 	//Payment receipt switcher
157 157
 	$payment_count = give_count_payments()->publish;
158
-	$payment_id    = give_check_variable( give_clean( $_GET ), 'isset', 0, 'preview_id' );
158
+	$payment_id    = give_check_variable(give_clean($_GET), 'isset', 0, 'preview_id');
159 159
 
160
-	if ( $payment_count <= 0 ) {
160
+	if ($payment_count <= 0) {
161 161
 		return false;
162 162
 	}
163 163
 
164 164
 	//Get payments.
165
-	$donations = new Give_Payments_Query( array(
165
+	$donations = new Give_Payments_Query(array(
166 166
 		'number' => 100,
167 167
 		'output' => '',
168 168
 		'fields' => 'ids'
169
-	) );
169
+	));
170 170
 	$donations = $donations->get_payments();
171
-	$options  = array();
171
+	$options = array();
172 172
 
173 173
 	// Default option.
174
-	$options[0] = esc_html__( 'No donations found.', 'give' );
174
+	$options[0] = esc_html__('No donations found.', 'give');
175 175
 
176 176
 	//Provide nice human readable options.
177
-	if ( $donations ) {
178
-		$options[0] = esc_html__( '- Select a donation -', 'give' );
179
-		foreach ( $donations as $donation_id ) {
177
+	if ($donations) {
178
+		$options[0] = esc_html__('- Select a donation -', 'give');
179
+		foreach ($donations as $donation_id) {
180 180
 
181
-			$options[ $donation_id ] = sprintf(
181
+			$options[$donation_id] = sprintf(
182 182
 				'#%1$s - %2$s - %3$s',
183 183
 				$donation_id,
184
-				give_get_donation_donor_email( $donation_id ),
185
-				get_the_title( $donation_id )
184
+				give_get_donation_donor_email($donation_id),
185
+				get_the_title($donation_id)
186 186
 			);
187 187
 		}
188 188
 	}
@@ -191,27 +191,27 @@  discard block
 block discarded – undo
191 191
 	$transaction_header = '<div style="margin:0;padding:10px 0;width:100%;background-color:#FFF;border-bottom:1px solid #eee; text-align:center;">';
192 192
 
193 193
 	// Remove payment id query param if set from request url.
194
-	$request_url_data = wp_parse_url( $_SERVER['REQUEST_URI'] );
194
+	$request_url_data = wp_parse_url($_SERVER['REQUEST_URI']);
195 195
 	$query            = $request_url_data['query'];
196
-	$query            = remove_query_arg( array( 'preview_id' ), $query );
196
+	$query            = remove_query_arg(array('preview_id'), $query);
197 197
 
198
-	$request_url = home_url( '/?' . str_replace( '', '', $query ) );
198
+	$request_url = home_url('/?'.str_replace('', '', $query));
199 199
 
200 200
 	$transaction_header .= '<script>
201 201
 				 function change_preview(){
202 202
 				  var transactions = document.getElementById("give_preview_email_payment_id");
203 203
 			        var selected_trans = transactions.options[transactions.selectedIndex];
204 204
 				        if (selected_trans){
205
-				            var url_string = "' . $request_url . '&preview_id=" + selected_trans.value;
205
+				            var url_string = "' . $request_url.'&preview_id=" + selected_trans.value;
206 206
 				                window.location = url_string;
207 207
 				        }
208 208
 				    }
209 209
 			    </script>';
210 210
 
211
-	$transaction_header .= '<label for="give_preview_email_payment_id" style="font-size:12px;color:#333;margin:0 4px 0 0;">' . esc_html__( 'Preview email with a donation:', 'give' ) . '</label>';
211
+	$transaction_header .= '<label for="give_preview_email_payment_id" style="font-size:12px;color:#333;margin:0 4px 0 0;">'.esc_html__('Preview email with a donation:', 'give').'</label>';
212 212
 
213 213
 	//The select field with 100 latest transactions
214
-	$transaction_header .= Give()->html->select( array(
214
+	$transaction_header .= Give()->html->select(array(
215 215
 		'name'             => 'preview_email_payment_id',
216 216
 		'selected'         => $payment_id,
217 217
 		'id'               => 'give_preview_email_payment_id',
@@ -221,11 +221,11 @@  discard block
 block discarded – undo
221 221
 		'select_atts'      => 'onchange="change_preview()"',
222 222
 		'show_option_all'  => false,
223 223
 		'show_option_none' => false,
224
-	) );
224
+	));
225 225
 
226 226
 	//Closing tag
227 227
 	$transaction_header .= '</div>';
228 228
 
229
-	return apply_filters( 'give_preview_email_receipt_header', $transaction_header );
229
+	return apply_filters('give_preview_email_receipt_header', $transaction_header);
230 230
 
231 231
 }
Please login to merge, or discard this patch.
includes/admin/reports/graphing.php 1 patch
Spacing   +246 added lines, -246 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
 
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	$dates          = give_get_report_dates();
27 27
 
28 28
 	// Determine graph options.
29
-	switch ( $dates['range'] ) :
29
+	switch ($dates['range']) :
30 30
 		case 'today' :
31 31
 		case 'yesterday' :
32 32
 			$day_by_day = true;
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 			$day_by_day = false;
39 39
 			break;
40 40
 		case 'other' :
41
-			if ( $dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] && ( $dates['m_start'] != '12' && $dates['m_end'] != '1' ) ) {
41
+			if ($dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] && ($dates['m_start'] != '12' && $dates['m_end'] != '1')) {
42 42
 				$day_by_day = false;
43 43
 			} else {
44 44
 				$day_by_day = true;
@@ -55,60 +55,60 @@  discard block
 block discarded – undo
55 55
 	$earnings_data = array();
56 56
 	$sales_data    = array();
57 57
 
58
-	if ( 'today' === $dates['range'] || 'yesterday' === $dates['range'] ) {
58
+	if ('today' === $dates['range'] || 'yesterday' === $dates['range']) {
59 59
 
60 60
 		// Hour by hour.
61 61
 		$hour  = 0;
62
-		$month = date( 'n', current_time( 'timestamp' ) );
63
-		while ( $hour <= 23 ) :
62
+		$month = date('n', current_time('timestamp'));
63
+		while ($hour <= 23) :
64 64
 
65
-			$start_date = mktime( $hour, 0, 0, $month, $dates['day'], $dates['year'] );
66
-			$end_date   = mktime( $hour, 59, 59, $month, $dates['day'], $dates['year'] );
67
-			$sales      = $donation_stats->get_sales( 0, $start_date, $end_date );
68
-			$earnings   = $donation_stats->get_earnings( 0, $start_date, $end_date );
65
+			$start_date = mktime($hour, 0, 0, $month, $dates['day'], $dates['year']);
66
+			$end_date   = mktime($hour, 59, 59, $month, $dates['day'], $dates['year']);
67
+			$sales      = $donation_stats->get_sales(0, $start_date, $end_date);
68
+			$earnings   = $donation_stats->get_earnings(0, $start_date, $end_date);
69 69
 
70 70
 			$sales_totals    += $sales;
71 71
 			$earnings_totals += $earnings;
72 72
 
73
-			$sales_data[]    = array( $start_date * 1000, $sales );
74
-			$earnings_data[] = array( $start_date * 1000, $earnings );
73
+			$sales_data[]    = array($start_date * 1000, $sales);
74
+			$earnings_data[] = array($start_date * 1000, $earnings);
75 75
 
76
-			$hour ++;
76
+			$hour++;
77 77
 		endwhile;
78 78
 
79
-	} elseif ( 'this_week' === $dates['range'] || 'last_week' === $dates['range'] ) {
79
+	} elseif ('this_week' === $dates['range'] || 'last_week' === $dates['range']) {
80 80
 
81 81
 		// Day by day.
82 82
 		$day     = $dates['day'];
83 83
 		$day_end = $dates['day_end'];
84 84
 		$month   = $dates['m_start'];
85
-		while ( $day <= $day_end ) :
85
+		while ($day <= $day_end) :
86 86
 
87
-			$start_date = mktime( 0, 0, 0, $month, $day, $dates['year'] );
88
-			$end_date   = mktime( 23, 59, 59, $month, $day, $dates['year'] );
89
-			$sales      = $donation_stats->get_sales( 0, $start_date, $end_date );
90
-			$earnings   = $donation_stats->get_earnings( 0, $start_date, $end_date );
87
+			$start_date = mktime(0, 0, 0, $month, $day, $dates['year']);
88
+			$end_date   = mktime(23, 59, 59, $month, $day, $dates['year']);
89
+			$sales      = $donation_stats->get_sales(0, $start_date, $end_date);
90
+			$earnings   = $donation_stats->get_earnings(0, $start_date, $end_date);
91 91
 
92 92
 			$sales_totals    += $sales;
93 93
 			$earnings_totals += $earnings;
94 94
 
95
-			$sales_data[]    = array( $start_date * 1000, $sales );
96
-			$earnings_data[] = array( $start_date * 1000, $earnings );
97
-			$day ++;
95
+			$sales_data[]    = array($start_date * 1000, $sales);
96
+			$earnings_data[] = array($start_date * 1000, $earnings);
97
+			$day++;
98 98
 		endwhile;
99 99
 
100 100
 	} else {
101 101
 
102 102
 		$y = $dates['year'];
103
-		while ( $y <= $dates['year_end'] ) :
103
+		while ($y <= $dates['year_end']) :
104 104
 
105
-			if ( $dates['year'] === $dates['year_end'] ) {
105
+			if ($dates['year'] === $dates['year_end']) {
106 106
 				$month_start = $dates['m_start'];
107 107
 				$month_end   = $dates['m_end'];
108
-			} elseif ( $y === $dates['year'] ) {
108
+			} elseif ($y === $dates['year']) {
109 109
 				$month_start = $dates['m_start'];
110 110
 				$month_end   = 12;
111
-			} elseif ( $y === $dates['year_end'] ) {
111
+			} elseif ($y === $dates['year_end']) {
112 112
 				$month_start = 1;
113 113
 				$month_end   = $dates['m_end'];
114 114
 			} else {
@@ -117,67 +117,67 @@  discard block
 block discarded – undo
117 117
 			}
118 118
 
119 119
 			$i = $month_start;
120
-			while ( $i <= $month_end ) :
120
+			while ($i <= $month_end) :
121 121
 
122
-				if ( $day_by_day ) {
122
+				if ($day_by_day) {
123 123
 
124
-					if ( $i === $month_end ) {
124
+					if ($i === $month_end) {
125 125
 
126 126
 						$num_of_days = $dates['day_end'];
127 127
 
128 128
 					} else {
129 129
 
130
-						$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
130
+						$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
131 131
 
132 132
 					}
133 133
 
134 134
 					$d = $dates['day'];
135 135
 
136
-					while ( $d <= $num_of_days ) :
136
+					while ($d <= $num_of_days) :
137 137
 
138
-						$start_date = mktime( 0, 0, 0, $i, $d, $y );
139
-						$end_date   = mktime( 23, 59, 59, $i, $d, $y );
140
-						$sales      = $donation_stats->get_sales( 0, $start_date, $end_date );
141
-						$earnings   = $donation_stats->get_earnings( 0, $start_date, $end_date );
138
+						$start_date = mktime(0, 0, 0, $i, $d, $y);
139
+						$end_date   = mktime(23, 59, 59, $i, $d, $y);
140
+						$sales      = $donation_stats->get_sales(0, $start_date, $end_date);
141
+						$earnings   = $donation_stats->get_earnings(0, $start_date, $end_date);
142 142
 
143 143
 						$sales_totals    += $sales;
144 144
 						$earnings_totals += $earnings;
145 145
 
146
-						$sales_data[]    = array( $start_date * 1000, $sales );
147
-						$earnings_data[] = array( $start_date * 1000, $earnings );
146
+						$sales_data[]    = array($start_date * 1000, $sales);
147
+						$earnings_data[] = array($start_date * 1000, $earnings);
148 148
 
149
-						$d ++;
149
+						$d++;
150 150
 
151 151
 					endwhile;
152 152
 
153 153
 				} else {
154 154
 
155 155
 					// This Quarter, Last Quarter, This Year, Last Year.
156
-					$start_date = mktime( 0, 0, 0, $i, 1, $y );
157
-					$end_date   = mktime( 23, 59, 59, $i + 1, 0, $y );
158
-					$sales      = $donation_stats->get_sales( 0, $start_date, $end_date );
159
-					$earnings   = $donation_stats->get_earnings( 0, $start_date, $end_date );
156
+					$start_date = mktime(0, 0, 0, $i, 1, $y);
157
+					$end_date   = mktime(23, 59, 59, $i + 1, 0, $y);
158
+					$sales      = $donation_stats->get_sales(0, $start_date, $end_date);
159
+					$earnings   = $donation_stats->get_earnings(0, $start_date, $end_date);
160 160
 
161 161
 					$sales_totals    += $sales;
162 162
 					$earnings_totals += $earnings;
163 163
 
164
-					$sales_data[]    = array( $start_date * 1000, $sales );
165
-					$earnings_data[] = array( $start_date * 1000, $earnings );
164
+					$sales_data[]    = array($start_date * 1000, $sales);
165
+					$earnings_data[] = array($start_date * 1000, $earnings);
166 166
 
167 167
 				}
168 168
 
169
-				$i ++;
169
+				$i++;
170 170
 
171 171
 			endwhile;
172 172
 
173
-			$y ++;
173
+			$y++;
174 174
 		endwhile;
175 175
 
176 176
 	}
177 177
 
178 178
 	$data = array(
179
-		__( 'Income', 'give' )    => $earnings_data,
180
-		__( 'Donations', 'give' ) => $sales_data
179
+		__('Income', 'give')    => $earnings_data,
180
+		__('Donations', 'give') => $sales_data
181 181
 	);
182 182
 
183 183
 	// start our own output buffer.
@@ -190,12 +190,12 @@  discard block
 block discarded – undo
190 190
 				<div class="inside">
191 191
 					<?php give_reports_graph_controls(); ?>
192 192
 					<?php
193
-					$graph = new Give_Graph( $data, array( 'dataType' => array( 'amount', 'count' ) ) );
194
-					$graph->set( 'x_mode', 'time' );
195
-					$graph->set( 'multiple_y_axes', true );
193
+					$graph = new Give_Graph($data, array('dataType' => array('amount', 'count')));
194
+					$graph->set('x_mode', 'time');
195
+					$graph->set('multiple_y_axes', true);
196 196
 					$graph->display();
197 197
 
198
-					if ( 'this_month' === $dates['range'] ) {
198
+					if ('this_month' === $dates['range']) {
199 199
 						$estimated = give_estimated_monthly_stats();
200 200
 					}
201 201
 					?>
@@ -204,21 +204,21 @@  discard block
 block discarded – undo
204 204
 			<table class="widefat reports-table alignleft" style="max-width:450px">
205 205
 				<tbody>
206 206
 				<tr>
207
-					<th scope="row"><strong><?php _e( 'Total income for period:', 'give' ); ?></strong></th>
208
-					<td><?php echo give_currency_filter( give_format_amount( $earnings_totals, array( 'sanitize' => false ) ) ); ?></td>
207
+					<th scope="row"><strong><?php _e('Total income for period:', 'give'); ?></strong></th>
208
+					<td><?php echo give_currency_filter(give_format_amount($earnings_totals, array('sanitize' => false))); ?></td>
209 209
 				</tr>
210 210
 				<tr class="alternate">
211
-					<th scope="row"><strong><?php _e( 'Total donations for period:', 'give' ); ?><strong></th>
211
+					<th scope="row"><strong><?php _e('Total donations for period:', 'give'); ?><strong></th>
212 212
 					<td><?php echo $sales_totals; ?></td>
213 213
 				</tr>
214
-				<?php if ( 'this_month' === $dates['range'] ) : ?>
214
+				<?php if ('this_month' === $dates['range']) : ?>
215 215
 					<tr>
216
-						<th scope="row"><strong><?php _e( 'Estimated monthly income:', 'give' ); ?></strong></th>
217
-						<td><?php echo give_currency_filter( give_format_amount( $estimated['earnings'], array( 'sanitize' => false ) ) ); ?></td>
216
+						<th scope="row"><strong><?php _e('Estimated monthly income:', 'give'); ?></strong></th>
217
+						<td><?php echo give_currency_filter(give_format_amount($estimated['earnings'], array('sanitize' => false))); ?></td>
218 218
 					</tr>
219 219
 					<tr class="alternate">
220
-						<th scope="row"><strong><?php _e( 'Estimated monthly donations:', 'give' ); ?></strong></th>
221
-						<td><?php echo floor( $estimated['sales'] ); ?></td>
220
+						<th scope="row"><strong><?php _e('Estimated monthly donations:', 'give'); ?></strong></th>
221
+						<td><?php echo floor($estimated['sales']); ?></td>
222 222
 					</tr>
223 223
 				<?php endif; ?>
224 224
 			</table>
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 			 *
232 232
 			 * @since 1.0
233 233
 			 */
234
-			do_action( 'give_reports_graph_additional_stats' );
234
+			do_action('give_reports_graph_additional_stats');
235 235
 			?>
236 236
 
237 237
 		</div>
@@ -251,12 +251,12 @@  discard block
 block discarded – undo
251 251
  *
252 252
  * @return void
253 253
  */
254
-function give_reports_graph_of_form( $form_id = 0 ) {
254
+function give_reports_graph_of_form($form_id = 0) {
255 255
 	// Retrieve the queried dates.
256 256
 	$dates = give_get_report_dates();
257 257
 
258 258
 	// Determine graph options.
259
-	switch ( $dates['range'] ) :
259
+	switch ($dates['range']) :
260 260
 		case 'today' :
261 261
 		case 'yesterday' :
262 262
 			$day_by_day = true;
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 			$day_by_day = false;
275 275
 			break;
276 276
 		case 'other' :
277
-			if ( $dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] ) {
277
+			if ($dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year']) {
278 278
 				$day_by_day = false;
279 279
 			} else {
280 280
 				$day_by_day = true;
@@ -286,75 +286,75 @@  discard block
 block discarded – undo
286 286
 	endswitch;
287 287
 
288 288
 	$earnings_totals = (float) 0.00; // Total earnings for time period shown.
289
-	$sales_totals    = 0;            // Total sales for time period shown.
289
+	$sales_totals    = 0; // Total sales for time period shown.
290 290
 
291 291
 	$earnings_data = array();
292 292
 	$sales_data    = array();
293 293
 	$stats         = new Give_Payment_Stats;
294 294
 
295
-	if ( $dates['range'] == 'today' || $dates['range'] == 'yesterday' ) {
295
+	if ($dates['range'] == 'today' || $dates['range'] == 'yesterday') {
296 296
 
297 297
 		// Hour by hour
298 298
 		$month  = $dates['m_start'];
299 299
 		$hour   = 0;
300 300
 		$minute = 0;
301 301
 		$second = 0;
302
-		while ( $hour <= 23 ) :
302
+		while ($hour <= 23) :
303 303
 
304
-			if ( $hour == 23 ) {
304
+			if ($hour == 23) {
305 305
 				$minute = $second = 59;
306 306
 			}
307 307
 
308
-			$date     = mktime( $hour, $minute, $second, $month, $dates['day'], $dates['year'] );
309
-			$date_end = mktime( $hour + 1, $minute, $second, $month, $dates['day'], $dates['year'] );
308
+			$date     = mktime($hour, $minute, $second, $month, $dates['day'], $dates['year']);
309
+			$date_end = mktime($hour + 1, $minute, $second, $month, $dates['day'], $dates['year']);
310 310
 
311
-			$sales = $stats->get_sales( $form_id, $date, $date_end );
311
+			$sales = $stats->get_sales($form_id, $date, $date_end);
312 312
 			$sales_totals += $sales;
313 313
 
314
-			$earnings = $stats->get_earnings( $form_id, $date, $date_end );
314
+			$earnings = $stats->get_earnings($form_id, $date, $date_end);
315 315
 			$earnings_totals += $earnings;
316 316
 
317
-			$sales_data[]    = array( $date * 1000, $sales );
318
-			$earnings_data[] = array( $date * 1000, $earnings );
317
+			$sales_data[]    = array($date * 1000, $sales);
318
+			$earnings_data[] = array($date * 1000, $earnings);
319 319
 
320
-			$hour ++;
320
+			$hour++;
321 321
 		endwhile;
322 322
 
323
-	} elseif ( $dates['range'] == 'this_week' || $dates['range'] == 'last_week' ) {
323
+	} elseif ($dates['range'] == 'this_week' || $dates['range'] == 'last_week') {
324 324
 
325 325
 		//Day by day.
326 326
 		$day     = $dates['day'];
327 327
 		$day_end = $dates['day_end'];
328 328
 		$month   = $dates['m_start'];
329
-		while ( $day <= $day_end ) :
329
+		while ($day <= $day_end) :
330 330
 
331
-			$date     = mktime( 0, 0, 0, $month, $day, $dates['year'] );
332
-			$date_end = mktime( 0, 0, 0, $month, $day + 1, $dates['year'] );
333
-			$sales    = $stats->get_sales( $form_id, $date, $date_end );
331
+			$date     = mktime(0, 0, 0, $month, $day, $dates['year']);
332
+			$date_end = mktime(0, 0, 0, $month, $day + 1, $dates['year']);
333
+			$sales    = $stats->get_sales($form_id, $date, $date_end);
334 334
 			$sales_totals += $sales;
335 335
 
336
-			$earnings = $stats->get_earnings( $form_id, $date, $date_end );
336
+			$earnings = $stats->get_earnings($form_id, $date, $date_end);
337 337
 			$earnings_totals += $earnings;
338 338
 
339
-			$sales_data[]    = array( $date * 1000, $sales );
340
-			$earnings_data[] = array( $date * 1000, $earnings );
339
+			$sales_data[]    = array($date * 1000, $sales);
340
+			$earnings_data[] = array($date * 1000, $earnings);
341 341
 
342
-			$day ++;
342
+			$day++;
343 343
 		endwhile;
344 344
 
345 345
 	} else {
346 346
 
347 347
 		$y = $dates['year'];
348 348
 
349
-		while ( $y <= $dates['year_end'] ) :
349
+		while ($y <= $dates['year_end']) :
350 350
 
351 351
 			$last_year = false;
352 352
 
353
-			if ( $dates['year'] == $dates['year_end'] ) {
353
+			if ($dates['year'] == $dates['year_end']) {
354 354
 				$month_start = $dates['m_start'];
355 355
 				$month_end   = $dates['m_end'];
356 356
 				$last_year   = true;
357
-			} elseif ( $y == $dates['year'] ) {
357
+			} elseif ($y == $dates['year']) {
358 358
 				$month_start = $dates['m_start'];
359 359
 				$month_end   = 12;
360 360
 			} else {
@@ -363,76 +363,76 @@  discard block
 block discarded – undo
363 363
 			}
364 364
 
365 365
 			$i = $month_start;
366
-			while ( $i <= $month_end ) :
366
+			while ($i <= $month_end) :
367 367
 
368
-				if ( $day_by_day ) {
368
+				if ($day_by_day) {
369 369
 
370
-					if ( $i == $month_end && $last_year ) {
370
+					if ($i == $month_end && $last_year) {
371 371
 
372 372
 						$num_of_days = $dates['day_end'];
373 373
 
374 374
 					} else {
375 375
 
376
-						$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
376
+						$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
377 377
 
378 378
 					}
379 379
 
380 380
 					$d = $dates['day'];
381
-					while ( $d <= $num_of_days ) :
381
+					while ($d <= $num_of_days) :
382 382
 
383
-						$date     = mktime( 0, 0, 0, $i, $d, $y );
384
-						$end_date = mktime( 23, 59, 59, $i, $d, $y );
383
+						$date     = mktime(0, 0, 0, $i, $d, $y);
384
+						$end_date = mktime(23, 59, 59, $i, $d, $y);
385 385
 
386
-						$sales = $stats->get_sales( $form_id, $date, $end_date );
386
+						$sales = $stats->get_sales($form_id, $date, $end_date);
387 387
 						$sales_totals += $sales;
388 388
 
389
-						$earnings = $stats->get_earnings( $form_id, $date, $end_date );
389
+						$earnings = $stats->get_earnings($form_id, $date, $end_date);
390 390
 						$earnings_totals += $earnings;
391 391
 
392
-						$sales_data[]    = array( $date * 1000, $sales );
393
-						$earnings_data[] = array( $date * 1000, $earnings );
394
-						$d ++;
392
+						$sales_data[]    = array($date * 1000, $sales);
393
+						$earnings_data[] = array($date * 1000, $earnings);
394
+						$d++;
395 395
 
396 396
 					endwhile;
397 397
 
398 398
 				} else {
399 399
 
400
-					$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
400
+					$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
401 401
 
402
-					$date     = mktime( 0, 0, 0, $i, 1, $y );
403
-					$end_date = mktime( 23, 59, 59, $i, $num_of_days, $y );
402
+					$date     = mktime(0, 0, 0, $i, 1, $y);
403
+					$end_date = mktime(23, 59, 59, $i, $num_of_days, $y);
404 404
 
405
-					$sales = $stats->get_sales( $form_id, $date, $end_date );
405
+					$sales = $stats->get_sales($form_id, $date, $end_date);
406 406
 					$sales_totals += $sales;
407 407
 
408
-					$earnings = $stats->get_earnings( $form_id, $date, $end_date );
408
+					$earnings = $stats->get_earnings($form_id, $date, $end_date);
409 409
 					$earnings_totals += $earnings;
410 410
 
411
-					$sales_data[]    = array( $date * 1000, $sales );
412
-					$earnings_data[] = array( $date * 1000, $earnings );
411
+					$sales_data[]    = array($date * 1000, $sales);
412
+					$earnings_data[] = array($date * 1000, $earnings);
413 413
 
414 414
 				}
415 415
 
416
-				$i ++;
416
+				$i++;
417 417
 
418 418
 			endwhile;
419 419
 
420
-			$y ++;
420
+			$y++;
421 421
 		endwhile;
422 422
 
423 423
 	}
424 424
 
425 425
 	$data = array(
426
-		__( 'Income', 'give' )    => $earnings_data,
427
-		__( 'Donations', 'give' ) => $sales_data
426
+		__('Income', 'give')    => $earnings_data,
427
+		__('Donations', 'give') => $sales_data
428 428
 	);
429 429
 
430 430
 	?>
431 431
 	<h3><span><?php
432 432
 			printf(
433 433
 			/* translators: %s: form title */
434
-				esc_html__( 'Income Report for %s', 'give' ),
435
-				get_the_title( $form_id )
434
+				esc_html__('Income Report for %s', 'give'),
435
+				get_the_title($form_id)
436 436
 			);
437 437
 			?></span></h3>
438 438
 	<div id="give-dashboard-widgets-wrap">
@@ -441,9 +441,9 @@  discard block
 block discarded – undo
441 441
 				<div class="inside">
442 442
 					<?php give_reports_graph_controls(); ?>
443 443
 					<?php
444
-					$graph = new Give_Graph( $data, array( 'dataType' => array( 'amount', 'count' ) ) );
445
-					$graph->set( 'x_mode', 'time' );
446
-					$graph->set( 'multiple_y_axes', true );
444
+					$graph = new Give_Graph($data, array('dataType' => array('amount', 'count')));
445
+					$graph->set('x_mode', 'time');
446
+					$graph->set('multiple_y_axes', true);
447 447
 					$graph->display();
448 448
 					?>
449 449
 				</div>
@@ -452,20 +452,20 @@  discard block
 block discarded – undo
452 452
 			<table class="widefat reports-table alignleft" style="max-width:450px">
453 453
 				<tbody>
454 454
 				<tr>
455
-					<th scope="row"><strong><?php _e( 'Total income for period:', 'give' ); ?></strong></th>
456
-					<td><?php echo give_currency_filter( give_format_amount( $earnings_totals, array( 'sanitize' => false ) ) ); ?></td>
455
+					<th scope="row"><strong><?php _e('Total income for period:', 'give'); ?></strong></th>
456
+					<td><?php echo give_currency_filter(give_format_amount($earnings_totals, array('sanitize' => false))); ?></td>
457 457
 				</tr>
458 458
 				<tr class="alternate">
459
-					<th scope="row"><strong><?php _e( 'Total donations for period:', 'give' ); ?></strong></th>
459
+					<th scope="row"><strong><?php _e('Total donations for period:', 'give'); ?></strong></th>
460 460
 					<td><?php echo $sales_totals; ?></td>
461 461
 				</tr>
462 462
 				<tr>
463
-					<th scope="row"><strong><?php _e( 'Average monthly income:', 'give' ); ?></strong></th>
464
-					<td><?php echo give_currency_filter( give_format_amount( give_get_average_monthly_form_earnings( $form_id ), array( 'sanitize' => false ) ) ); ?></td>
463
+					<th scope="row"><strong><?php _e('Average monthly income:', 'give'); ?></strong></th>
464
+					<td><?php echo give_currency_filter(give_format_amount(give_get_average_monthly_form_earnings($form_id), array('sanitize' => false))); ?></td>
465 465
 				</tr>
466 466
 				<tr class="alternate">
467
-					<th scope="row"><strong><?php _e( 'Average monthly donations:', 'give' ); ?></strong></th>
468
-					<td><?php echo number_format( give_get_average_monthly_form_sales( $form_id ), 0 ); ?></td>
467
+					<th scope="row"><strong><?php _e('Average monthly donations:', 'give'); ?></strong></th>
468
+					<td><?php echo number_format(give_get_average_monthly_form_sales($form_id), 0); ?></td>
469 469
 				</tr>
470 470
 				</tbody>
471 471
 			</table>
@@ -484,26 +484,26 @@  discard block
 block discarded – undo
484 484
  * @return void
485 485
  */
486 486
 function give_reports_graph_controls() {
487
-	$date_options = apply_filters( 'give_report_date_options', array(
488
-		'today'        => __( 'Today', 'give' ),
489
-		'yesterday'    => __( 'Yesterday', 'give' ),
490
-		'this_week'    => __( 'This Week', 'give' ),
491
-		'last_week'    => __( 'Last Week', 'give' ),
492
-		'this_month'   => __( 'This Month', 'give' ),
493
-		'last_month'   => __( 'Last Month', 'give' ),
494
-		'this_quarter' => __( 'This Quarter', 'give' ),
495
-		'last_quarter' => __( 'Last Quarter', 'give' ),
496
-		'this_year'    => __( 'This Year', 'give' ),
497
-		'last_year'    => __( 'Last Year', 'give' ),
498
-		'other'        => __( 'Custom', 'give' )
499
-	) );
487
+	$date_options = apply_filters('give_report_date_options', array(
488
+		'today'        => __('Today', 'give'),
489
+		'yesterday'    => __('Yesterday', 'give'),
490
+		'this_week'    => __('This Week', 'give'),
491
+		'last_week'    => __('Last Week', 'give'),
492
+		'this_month'   => __('This Month', 'give'),
493
+		'last_month'   => __('Last Month', 'give'),
494
+		'this_quarter' => __('This Quarter', 'give'),
495
+		'last_quarter' => __('Last Quarter', 'give'),
496
+		'this_year'    => __('This Year', 'give'),
497
+		'last_year'    => __('Last Year', 'give'),
498
+		'other'        => __('Custom', 'give')
499
+	));
500 500
 
501 501
 	$dates   = give_get_report_dates();
502 502
 	$display = $dates['range'] == 'other' ? '' : 'display: none;';
503
-	$tab     = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'earnings';
503
+	$tab     = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'earnings';
504 504
 
505
-	if ( empty( $dates['day_end'] ) ) {
506
-		$dates['day_end'] = cal_days_in_month( CAL_GREGORIAN, date( 'n' ), date( 'Y' ) );
505
+	if (empty($dates['day_end'])) {
506
+		$dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, date('n'), date('Y'));
507 507
 	}
508 508
 
509 509
 	/**
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
 	 *
512 512
 	 * @since 1.0
513 513
 	 */
514
-	do_action( 'give_report_graph_controls_before' );
514
+	do_action('give_report_graph_controls_before');
515 515
 	?>
516 516
 	<form id="give-graphs-filter" method="get">
517 517
 		<div class="tablenav top">
@@ -519,56 +519,56 @@  discard block
 block discarded – undo
519 519
 
520 520
 				<input type="hidden" name="post_type" value="give_forms" />
521 521
 				<input type="hidden" name="page" value="give-reports" />
522
-				<input type="hidden" name="tab" value="<?php echo esc_attr( $tab ); ?>" />
522
+				<input type="hidden" name="tab" value="<?php echo esc_attr($tab); ?>" />
523 523
 
524
-				<?php if ( isset( $_GET['form-id'] ) ) : ?>
525
-					<input type="hidden" name="form-id" value="<?php echo absint( $_GET['form-id'] ); ?>" />
524
+				<?php if (isset($_GET['form-id'])) : ?>
525
+					<input type="hidden" name="form-id" value="<?php echo absint($_GET['form-id']); ?>" />
526 526
 				<?php endif; ?>
527 527
 
528 528
 				<div id="give-graphs-date-options-wrap">
529 529
 					<select id="give-graphs-date-options" name="range">
530
-						<?php foreach ( $date_options as $key => $option ) : ?>
531
-							<option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $dates['range'] ); ?>><?php echo esc_html( $option ); ?></option>
530
+						<?php foreach ($date_options as $key => $option) : ?>
531
+							<option value="<?php echo esc_attr($key); ?>"<?php selected($key, $dates['range']); ?>><?php echo esc_html($option); ?></option>
532 532
 						<?php endforeach; ?>
533 533
 					</select>
534 534
 
535
-					<div id="give-date-range-options" style="<?php echo esc_attr( $display ); ?>">
536
-						<span class="screen-reader-text"><?php _e( 'From', 'give' ); ?>&nbsp;</span>
535
+					<div id="give-date-range-options" style="<?php echo esc_attr($display); ?>">
536
+						<span class="screen-reader-text"><?php _e('From', 'give'); ?>&nbsp;</span>
537 537
 						<select id="give-graphs-month-start" name="m_start" aria-label="Start Month">
538
-							<?php for ( $i = 1; $i <= 12; $i ++ ) : ?>
539
-								<option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['m_start'] ) ); ?>><?php echo esc_html( give_month_num_to_name( $i ) ); ?></option>
538
+							<?php for ($i = 1; $i <= 12; $i++) : ?>
539
+								<option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['m_start'])); ?>><?php echo esc_html(give_month_num_to_name($i)); ?></option>
540 540
 							<?php endfor; ?>
541 541
 						</select>
542 542
 						<select id="give-graphs-day-start" name="day" aria-label="Start Day">
543
-							<?php for ( $i = 1; $i <= 31; $i ++ ) : ?>
544
-								<option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['day'] ) ); ?>><?php echo esc_html( $i ); ?></option>
543
+							<?php for ($i = 1; $i <= 31; $i++) : ?>
544
+								<option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['day'])); ?>><?php echo esc_html($i); ?></option>
545 545
 							<?php endfor; ?>
546 546
 						</select>
547 547
 						<select id="give-graphs-year-start" name="year" aria-label="Start Year">
548
-							<?php for ( $i = 2007; $i <= date( 'Y' ); $i ++ ) : ?>
549
-								<option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['year'] ) ); ?>><?php echo esc_html( $i ); ?></option>
548
+							<?php for ($i = 2007; $i <= date('Y'); $i++) : ?>
549
+								<option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['year'])); ?>><?php echo esc_html($i); ?></option>
550 550
 							<?php endfor; ?>
551 551
 						</select>
552
-						<span class="screen-reader-text"><?php esc_html_e( 'To', 'give' ); ?>&nbsp;</span>
552
+						<span class="screen-reader-text"><?php esc_html_e('To', 'give'); ?>&nbsp;</span>
553 553
 						<span>&ndash;</span>
554 554
 						<select id="give-graphs-month-end" name="m_end" aria-label="End Month">
555
-							<?php for ( $i = 1; $i <= 12; $i ++ ) : ?>
556
-								<option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['m_end'] ) ); ?>><?php echo esc_html( give_month_num_to_name( $i ) ); ?></option>
555
+							<?php for ($i = 1; $i <= 12; $i++) : ?>
556
+								<option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['m_end'])); ?>><?php echo esc_html(give_month_num_to_name($i)); ?></option>
557 557
 							<?php endfor; ?>
558 558
 						</select>
559 559
 						<select id="give-graphs-day-end" name="day_end" aria-label="End Day">
560
-							<?php for ( $i = 1; $i <= 31; $i ++ ) : ?>
561
-								<option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['day_end'] ) ); ?>><?php echo esc_html( $i ); ?></option>
560
+							<?php for ($i = 1; $i <= 31; $i++) : ?>
561
+								<option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['day_end'])); ?>><?php echo esc_html($i); ?></option>
562 562
 							<?php endfor; ?>
563 563
 						</select>
564 564
 						<select id="give-graphs-year-end" name="year_end" aria-label="End Year">
565
-							<?php for ( $i = 2007; $i <= date( 'Y' ); $i ++ ) : ?>
566
-								<option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['year_end'] ) ); ?>><?php echo esc_html( $i ); ?></option>
565
+							<?php for ($i = 2007; $i <= date('Y'); $i++) : ?>
566
+								<option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['year_end'])); ?>><?php echo esc_html($i); ?></option>
567 567
 							<?php endfor; ?>
568 568
 						</select>
569 569
 					</div>
570 570
 
571
-					<input type="submit" class="button-secondary" value="<?php _e( 'Filter', 'give' ); ?>" />
571
+					<input type="submit" class="button-secondary" value="<?php _e('Filter', 'give'); ?>" />
572 572
 				</div>
573 573
 
574 574
 				<input type="hidden" name="give_action" value="filter_reports" />
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
 	 *
582 582
 	 * @since 1.0
583 583
 	 */
584
-	do_action( 'give_report_graph_controls_after' );
584
+	do_action('give_report_graph_controls_after');
585 585
 }
586 586
 
587 587
 /**
@@ -597,67 +597,67 @@  discard block
 block discarded – undo
597 597
 function give_get_report_dates() {
598 598
 	$dates = array();
599 599
 
600
-	$current_time = current_time( 'timestamp' );
600
+	$current_time = current_time('timestamp');
601 601
 
602
-	$dates['range']    = isset( $_GET['range'] ) ? $_GET['range'] : 'this_month';
603
-	$dates['year']     = isset( $_GET['year'] ) ? $_GET['year'] : date( 'Y' );
604
-	$dates['year_end'] = isset( $_GET['year_end'] ) ? $_GET['year_end'] : date( 'Y' );
605
-	$dates['m_start']  = isset( $_GET['m_start'] ) ? $_GET['m_start'] : 1;
606
-	$dates['m_end']    = isset( $_GET['m_end'] ) ? $_GET['m_end'] : 12;
607
-	$dates['day']      = isset( $_GET['day'] ) ? $_GET['day'] : 1;
608
-	$dates['day_end']  = isset( $_GET['day_end'] ) ? $_GET['day_end'] : cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] );
602
+	$dates['range']    = isset($_GET['range']) ? $_GET['range'] : 'this_month';
603
+	$dates['year']     = isset($_GET['year']) ? $_GET['year'] : date('Y');
604
+	$dates['year_end'] = isset($_GET['year_end']) ? $_GET['year_end'] : date('Y');
605
+	$dates['m_start']  = isset($_GET['m_start']) ? $_GET['m_start'] : 1;
606
+	$dates['m_end']    = isset($_GET['m_end']) ? $_GET['m_end'] : 12;
607
+	$dates['day']      = isset($_GET['day']) ? $_GET['day'] : 1;
608
+	$dates['day_end']  = isset($_GET['day_end']) ? $_GET['day_end'] : cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']);
609 609
 
610 610
 	// Modify dates based on predefined ranges.
611
-	switch ( $dates['range'] ) :
611
+	switch ($dates['range']) :
612 612
 
613 613
 		case 'this_month' :
614
-			$dates['m_start']  = date( 'n', $current_time );
615
-			$dates['m_end']    = date( 'n', $current_time );
614
+			$dates['m_start']  = date('n', $current_time);
615
+			$dates['m_end']    = date('n', $current_time);
616 616
 			$dates['day']      = 1;
617
-			$dates['day_end']  = cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] );
618
-			$dates['year']     = date( 'Y' );
619
-			$dates['year_end'] = date( 'Y' );
617
+			$dates['day_end']  = cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']);
618
+			$dates['year']     = date('Y');
619
+			$dates['year_end'] = date('Y');
620 620
 			break;
621 621
 
622 622
 		case 'last_month' :
623
-			if ( date( 'n' ) == 1 ) {
623
+			if (date('n') == 1) {
624 624
 				$dates['m_start']  = 12;
625 625
 				$dates['m_end']    = 12;
626
-				$dates['year']     = date( 'Y', $current_time ) - 1;
627
-				$dates['year_end'] = date( 'Y', $current_time ) - 1;
626
+				$dates['year']     = date('Y', $current_time) - 1;
627
+				$dates['year_end'] = date('Y', $current_time) - 1;
628 628
 			} else {
629
-				$dates['m_start']  = date( 'n' ) - 1;
630
-				$dates['m_end']    = date( 'n' ) - 1;
629
+				$dates['m_start']  = date('n') - 1;
630
+				$dates['m_end']    = date('n') - 1;
631 631
 				$dates['year_end'] = $dates['year'];
632 632
 			}
633
-			$dates['day_end'] = cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] );
633
+			$dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']);
634 634
 			break;
635 635
 
636 636
 		case 'today' :
637
-			$dates['day']      = date( 'd', $current_time );
638
-			$dates['day_end']  = date( 'd', $current_time );
639
-			$dates['m_start']  = date( 'n', $current_time );
640
-			$dates['m_end']    = date( 'n', $current_time );
641
-			$dates['year']     = date( 'Y', $current_time );
642
-			$dates['year_end'] = date( 'Y', $current_time );
637
+			$dates['day']      = date('d', $current_time);
638
+			$dates['day_end']  = date('d', $current_time);
639
+			$dates['m_start']  = date('n', $current_time);
640
+			$dates['m_end']    = date('n', $current_time);
641
+			$dates['year']     = date('Y', $current_time);
642
+			$dates['year_end'] = date('Y', $current_time);
643 643
 			break;
644 644
 
645 645
 		case 'yesterday' :
646 646
 
647
-			$year  = date( 'Y', $current_time );
648
-			$month = date( 'n', $current_time );
649
-			$day   = date( 'd', $current_time );
647
+			$year  = date('Y', $current_time);
648
+			$month = date('n', $current_time);
649
+			$day   = date('d', $current_time);
650 650
 
651
-			if ( $month == 1 && $day == 1 ) {
651
+			if ($month == 1 && $day == 1) {
652 652
 
653 653
 				$year -= 1;
654 654
 				$month = 12;
655
-				$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
655
+				$day   = cal_days_in_month(CAL_GREGORIAN, $month, $year);
656 656
 
657
-			} elseif ( $month > 1 && $day == 1 ) {
657
+			} elseif ($month > 1 && $day == 1) {
658 658
 
659 659
 				$month -= 1;
660
-				$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
660
+				$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
661 661
 
662 662
 			} else {
663 663
 
@@ -673,48 +673,48 @@  discard block
 block discarded – undo
673 673
 			break;
674 674
 
675 675
 		case 'this_week' :
676
-			$dates['day'] = date( 'd', $current_time - ( date( 'w', $current_time ) - 1 ) * 60 * 60 * 24 ) - 1;
677
-			$dates['day'] += get_option( 'start_of_week' );
676
+			$dates['day'] = date('d', $current_time - (date('w', $current_time) - 1) * 60 * 60 * 24) - 1;
677
+			$dates['day'] += get_option('start_of_week');
678 678
 			$dates['day_end'] = $dates['day'] + 6;
679
-			$dates['m_start'] = date( 'n', $current_time );
680
-			$dates['m_end']   = date( 'n', $current_time );
681
-			$dates['year']    = date( 'Y', $current_time );
679
+			$dates['m_start'] = date('n', $current_time);
680
+			$dates['m_end']   = date('n', $current_time);
681
+			$dates['year']    = date('Y', $current_time);
682 682
 			break;
683 683
 
684 684
 		case 'last_week' :
685
-			$dates['day'] = date( 'd', $current_time - ( date( 'w' ) - 1 ) * 60 * 60 * 24 ) - 8;
686
-			$dates['day'] += get_option( 'start_of_week' );
685
+			$dates['day'] = date('d', $current_time - (date('w') - 1) * 60 * 60 * 24) - 8;
686
+			$dates['day'] += get_option('start_of_week');
687 687
 			$dates['day_end'] = $dates['day'] + 6;
688
-			$dates['year']    = date( 'Y' );
689
-
690
-			if ( date( 'j', $current_time ) <= 7 ) {
691
-				$dates['m_start'] = date( 'n', $current_time ) - 1;
692
-				$dates['m_end']   = date( 'n', $current_time ) - 1;
693
-				if ( $dates['m_start'] <= 1 ) {
694
-					$dates['year']     = date( 'Y', $current_time ) - 1;
695
-					$dates['year_end'] = date( 'Y', $current_time ) - 1;
688
+			$dates['year']    = date('Y');
689
+
690
+			if (date('j', $current_time) <= 7) {
691
+				$dates['m_start'] = date('n', $current_time) - 1;
692
+				$dates['m_end']   = date('n', $current_time) - 1;
693
+				if ($dates['m_start'] <= 1) {
694
+					$dates['year']     = date('Y', $current_time) - 1;
695
+					$dates['year_end'] = date('Y', $current_time) - 1;
696 696
 				}
697 697
 			} else {
698
-				$dates['m_start'] = date( 'n', $current_time );
699
-				$dates['m_end']   = date( 'n', $current_time );
698
+				$dates['m_start'] = date('n', $current_time);
699
+				$dates['m_end']   = date('n', $current_time);
700 700
 			}
701 701
 			break;
702 702
 
703 703
 		case 'this_quarter' :
704
-			$month_now     = date( 'n', $current_time );
705
-			$dates['year'] = date( 'Y', $current_time );
704
+			$month_now     = date('n', $current_time);
705
+			$dates['year'] = date('Y', $current_time);
706 706
 
707
-			if ( $month_now <= 3 ) {
707
+			if ($month_now <= 3) {
708 708
 
709 709
 				$dates['m_start'] = 1;
710 710
 				$dates['m_end']   = 4;
711 711
 
712
-			} else if ( $month_now <= 6 ) {
712
+			} else if ($month_now <= 6) {
713 713
 
714 714
 				$dates['m_start'] = 4;
715 715
 				$dates['m_end']   = 7;
716 716
 
717
-			} else if ( $month_now <= 9 ) {
717
+			} else if ($month_now <= 9) {
718 718
 
719 719
 				$dates['m_start'] = 7;
720 720
 				$dates['m_end']   = 10;
@@ -723,28 +723,28 @@  discard block
 block discarded – undo
723 723
 
724 724
 				$dates['m_start']  = 10;
725 725
 				$dates['m_end']    = 1;
726
-				$dates['year_end'] = date( 'Y', $current_time ) + 1;
726
+				$dates['year_end'] = date('Y', $current_time) + 1;
727 727
 
728 728
 			}
729 729
 			break;
730 730
 
731 731
 		case 'last_quarter' :
732
-			$month_now         = date( 'n', $current_time );
733
-			$dates['year']     = date( 'Y', $current_time );
734
-			$dates['year_end'] = date( 'Y', $current_time );
732
+			$month_now         = date('n', $current_time);
733
+			$dates['year']     = date('Y', $current_time);
734
+			$dates['year_end'] = date('Y', $current_time);
735 735
 
736
-			if ( $month_now <= 3 ) {
736
+			if ($month_now <= 3) {
737 737
 
738 738
 				$dates['m_start'] = 10;
739 739
 				$dates['m_end']   = 1;
740
-				$dates['year']    = date( 'Y', $current_time ) - 1; // Previous year.
740
+				$dates['year']    = date('Y', $current_time) - 1; // Previous year.
741 741
 
742
-			} else if ( $month_now <= 6 ) {
742
+			} else if ($month_now <= 6) {
743 743
 
744 744
 				$dates['m_start'] = 1;
745 745
 				$dates['m_end']   = 4;
746 746
 
747
-			} else if ( $month_now <= 9 ) {
747
+			} else if ($month_now <= 9) {
748 748
 
749 749
 				$dates['m_start'] = 4;
750 750
 				$dates['m_end']   = 7;
@@ -760,20 +760,20 @@  discard block
 block discarded – undo
760 760
 		case 'this_year' :
761 761
 			$dates['m_start']  = 1;
762 762
 			$dates['m_end']    = 12;
763
-			$dates['year']     = date( 'Y', $current_time );
764
-			$dates['year_end'] = date( 'Y', $current_time );
763
+			$dates['year']     = date('Y', $current_time);
764
+			$dates['year_end'] = date('Y', $current_time);
765 765
 			break;
766 766
 
767 767
 		case 'last_year' :
768 768
 			$dates['m_start']  = 1;
769 769
 			$dates['m_end']    = 12;
770
-			$dates['year']     = date( 'Y', $current_time ) - 1;
771
-			$dates['year_end'] = date( 'Y', $current_time ) - 1;
770
+			$dates['year']     = date('Y', $current_time) - 1;
771
+			$dates['year_end'] = date('Y', $current_time) - 1;
772 772
 			break;
773 773
 
774 774
 	endswitch;
775 775
 
776
-	return apply_filters( 'give_report_dates', $dates );
776
+	return apply_filters('give_report_dates', $dates);
777 777
 }
778 778
 
779 779
 /**
@@ -784,18 +784,18 @@  discard block
 block discarded – undo
784 784
  *
785 785
  * @param $data
786 786
  */
787
-function give_parse_report_dates( $data ) {
787
+function give_parse_report_dates($data) {
788 788
 	$dates = give_get_report_dates();
789 789
 
790 790
 	$view = give_get_reporting_view();
791
-	$tab  = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'earnings';
792
-	$id   = isset( $_GET['form-id'] ) ? $_GET['form-id'] : null;
791
+	$tab  = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'earnings';
792
+	$id   = isset($_GET['form-id']) ? $_GET['form-id'] : null;
793 793
 
794
-	wp_redirect( add_query_arg( $dates, admin_url( 'edit.php?post_type=give_forms&page=give-reports&tab=' . esc_attr( $tab ) . '&view=' . esc_attr( $view ) . '&form-id=' . absint( $id ) ) ) );
794
+	wp_redirect(add_query_arg($dates, admin_url('edit.php?post_type=give_forms&page=give-reports&tab='.esc_attr($tab).'&view='.esc_attr($view).'&form-id='.absint($id))));
795 795
 	give_die();
796 796
 }
797 797
 
798
-add_action( 'give_filter_reports', 'give_parse_report_dates' );
798
+add_action('give_filter_reports', 'give_parse_report_dates');
799 799
 
800 800
 
801 801
 /**
@@ -807,23 +807,23 @@  discard block
 block discarded – undo
807 807
  */
808 808
 function give_reports_refresh_button() {
809 809
 
810
-	$url = wp_nonce_url( add_query_arg( array(
810
+	$url = wp_nonce_url(add_query_arg(array(
811 811
 		'give_action'  => 'refresh_reports_transients',
812 812
 		'give-messages[]' => 'refreshed-reports'
813
-	) ), 'give-refresh-reports' );
813
+	)), 'give-refresh-reports');
814 814
 
815
-	echo Give()->tooltips->render_link( array(
816
-		'label'       => esc_attr__( 'Clicking this will clear the reports cache.', 'give' ),
817
-		'tag_content' => '<span class="give-admin-button-icon give-admin-button-icon-update"></span>' . esc_html__( 'Refresh Report Data', 'give' ),
815
+	echo Give()->tooltips->render_link(array(
816
+		'label'       => esc_attr__('Clicking this will clear the reports cache.', 'give'),
817
+		'tag_content' => '<span class="give-admin-button-icon give-admin-button-icon-update"></span>'.esc_html__('Refresh Report Data', 'give'),
818 818
 		'link'        => $url,
819 819
 		'position'    => 'left',
820 820
 		'attributes'  => array(
821 821
 			'class' => 'button alignright give-admin-button'
822 822
 		)
823
-	) );
823
+	));
824 824
 }
825 825
 
826
-add_action( 'give_reports_graph_additional_stats', 'give_reports_refresh_button' );
826
+add_action('give_reports_graph_additional_stats', 'give_reports_refresh_button');
827 827
 
828 828
 /**
829 829
  * Trigger the refresh of reports transients
@@ -834,20 +834,20 @@  discard block
 block discarded – undo
834 834
  *
835 835
  * @return void
836 836
  */
837
-function give_run_refresh_reports_transients( $data ) {
837
+function give_run_refresh_reports_transients($data) {
838 838
 
839
-	if ( ! wp_verify_nonce( $data['_wpnonce'], 'give-refresh-reports' ) ) {
839
+	if ( ! wp_verify_nonce($data['_wpnonce'], 'give-refresh-reports')) {
840 840
 		return;
841 841
 	}
842 842
 
843 843
 	// Monthly stats.
844
-	Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) );
844
+	Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
845 845
 
846 846
 	// Total earning.
847
-	delete_option( 'give_earnings_total' );
847
+	delete_option('give_earnings_total');
848 848
 
849 849
 	// @todo: Refresh only range related stat cache
850 850
 	give_delete_donation_stats();
851 851
 }
852 852
 
853
-add_action( 'give_refresh_reports_transients', 'give_run_refresh_reports_transients' );
854 853
\ No newline at end of file
854
+add_action('give_refresh_reports_transients', 'give_run_refresh_reports_transients');
855 855
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/shortcodes/shortcode-give-totals.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  */
10 10
 
11 11
 // Exit if accessed directly.
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit;
14 14
 }
15 15
 
@@ -23,10 +23,10 @@  discard block
 block discarded – undo
23 23
 	 */
24 24
 	public function __construct() {
25 25
 
26
-		$this->shortcode['title'] = __( 'Give Totals', 'give' );
27
-		$this->shortcode['label'] = __( 'Give Totals', 'give' );
26
+		$this->shortcode['title'] = __('Give Totals', 'give');
27
+		$this->shortcode['label'] = __('Give Totals', 'give');
28 28
 
29
-		parent::__construct( 'give_totals' );
29
+		parent::__construct('give_totals');
30 30
 	}
31 31
 
32 32
 	/**
@@ -39,69 +39,69 @@  discard block
 block discarded – undo
39 39
 
40 40
 		$category_options = array();
41 41
 		$category_lists   = array();
42
-		$categories       = get_terms( 'give_forms_category', apply_filters( 'give_forms_category_dropdown', array() ) );
43
-		if ( give_is_setting_enabled( give_get_option( 'categories' ) ) && ! is_wp_error( $categories ) ) {
44
-			foreach ( $categories as $category ) {
45
-				$category_options[ absint( $category->term_id ) ] = esc_html( $category->name );
42
+		$categories       = get_terms('give_forms_category', apply_filters('give_forms_category_dropdown', array()));
43
+		if (give_is_setting_enabled(give_get_option('categories')) && ! is_wp_error($categories)) {
44
+			foreach ($categories as $category) {
45
+				$category_options[absint($category->term_id)] = esc_html($category->name);
46 46
 			}
47 47
 
48 48
 			$category_lists['type']    = 'listbox';
49 49
 			$category_lists['name']    = 'cats';
50
-			$category_lists['label']   = __( 'Select a Donation Form Category:', 'give' );
51
-			$category_lists['tooltip'] = __( 'Select a Donation Form Category', 'give' );
50
+			$category_lists['label']   = __('Select a Donation Form Category:', 'give');
51
+			$category_lists['tooltip'] = __('Select a Donation Form Category', 'give');
52 52
 			$category_lists['options'] = $category_options;
53 53
 		}
54 54
 
55 55
 		$tag_options = array();
56 56
 		$tag_lists   = array();
57
-		$tags        = get_terms( 'give_forms_tag', apply_filters( 'give_forms_tag_dropdown', array() ) );
58
-		if ( give_is_setting_enabled( give_get_option( 'tags' ) ) && ! is_wp_error( $tags ) ) {
59
-			$tags = get_terms( 'give_forms_tag', apply_filters( 'give_forms_tag_dropdown', array() ) );
60
-			foreach ( $tags as $tag ) {
61
-				$tag_options[ absint( $tag->term_id ) ] = esc_html( $tag->name );
57
+		$tags        = get_terms('give_forms_tag', apply_filters('give_forms_tag_dropdown', array()));
58
+		if (give_is_setting_enabled(give_get_option('tags')) && ! is_wp_error($tags)) {
59
+			$tags = get_terms('give_forms_tag', apply_filters('give_forms_tag_dropdown', array()));
60
+			foreach ($tags as $tag) {
61
+				$tag_options[absint($tag->term_id)] = esc_html($tag->name);
62 62
 			}
63 63
 
64 64
 			$tag_lists['type']    = 'listbox';
65 65
 			$tag_lists['name']    = 'tags';
66
-			$tag_lists['label']   = __( 'Select a Donation Form Tag:', 'give' );
67
-			$tag_lists['tooltip'] = __( 'Select a Donation Form Tag', 'give' );
66
+			$tag_lists['label']   = __('Select a Donation Form Tag:', 'give');
67
+			$tag_lists['tooltip'] = __('Select a Donation Form Tag', 'give');
68 68
 			$tag_lists['options'] = $tag_options;
69 69
 		}
70 70
 
71 71
 		return array(
72 72
 			array(
73 73
 				'type' => 'container',
74
-				'html' => sprintf( '<p class="give-totals-shortcode-container-message">%s</p>',
75
-					__( 'This shortcode shows the total amount raised towards a custom goal for one or several forms regardless of whether they have goals enabled or not.', 'give' )
74
+				'html' => sprintf('<p class="give-totals-shortcode-container-message">%s</p>',
75
+					__('This shortcode shows the total amount raised towards a custom goal for one or several forms regardless of whether they have goals enabled or not.', 'give')
76 76
 				),
77 77
 			),
78 78
 			array(
79 79
 				'type' => 'container',
80
-				'html' => sprintf( '<p class="strong margin-top">%s</p>', __( 'Shortcode Configuration', 'give' ) ),
80
+				'html' => sprintf('<p class="strong margin-top">%s</p>', __('Shortcode Configuration', 'give')),
81 81
 			),
82 82
 			array(
83 83
 				'type'    => 'textbox',
84 84
 				'name'    => 'ids',
85
-				'label'   => __( 'Donation Form IDs:', 'give' ),
86
-				'tooltip' => __( 'Enter the IDs separated by commas for the donation forms you would like to combine within the totals.', 'give' ),
85
+				'label'   => __('Donation Form IDs:', 'give'),
86
+				'tooltip' => __('Enter the IDs separated by commas for the donation forms you would like to combine within the totals.', 'give'),
87 87
 			),
88 88
 			$category_lists,
89 89
 			$tag_lists,
90 90
 			array(
91 91
 				'type'     => 'textbox',
92 92
 				'name'     => 'total_goal',
93
-				'label'    => __( 'Total Goal:', 'give' ),
94
-				'tooltip'  => __( 'Enter the total goal amount that you would like to display.', 'give' ),
93
+				'label'    => __('Total Goal:', 'give'),
94
+				'tooltip'  => __('Enter the total goal amount that you would like to display.', 'give'),
95 95
 				'required' => array(
96
-					'alert' => esc_html__( 'Please enter a valid total goal amount.', 'give' ),
96
+					'alert' => esc_html__('Please enter a valid total goal amount.', 'give'),
97 97
 				),
98 98
 			),
99 99
 			array(
100 100
 				'type'      => 'textbox',
101 101
 				'name'      => 'message',
102
-				'label'     => __( 'Message:', 'give' ),
103
-				'tooltip'   => __( 'Enter a message to display encouraging donors to support the goal.', 'give' ),
104
-				'value'     => apply_filters( 'give_totals_message', __( 'Hey! We\'ve raised {total} of the {total_goal} we are trying to raise for this campaign!', 'give' ) ),
102
+				'label'     => __('Message:', 'give'),
103
+				'tooltip'   => __('Enter a message to display encouraging donors to support the goal.', 'give'),
104
+				'value'     => apply_filters('give_totals_message', __('Hey! We\'ve raised {total} of the {total_goal} we are trying to raise for this campaign!', 'give')),
105 105
 				'multiline' => true,
106 106
 				'minWidth'  => 300,
107 107
 				'minHeight' => 60,
@@ -109,24 +109,24 @@  discard block
 block discarded – undo
109 109
 			array(
110 110
 				'type'    => 'textbox',
111 111
 				'name'    => 'link',
112
-				'label'   => __( 'Link:', 'give' ),
113
-				'tooltip' => __( 'Enter a link to the main campaign donation form.', 'give' ),
112
+				'label'   => __('Link:', 'give'),
113
+				'tooltip' => __('Enter a link to the main campaign donation form.', 'give'),
114 114
 			),
115 115
 			array(
116 116
 				'type'    => 'textbox',
117 117
 				'name'    => 'link_text',
118
-				'label'   => __( 'Link Text:', 'give' ),
119
-				'tooltip' => __( 'Enter hyperlink text for the link to the main campaign donation form.', 'give' ),
120
-				'value'   => __( 'Donate!', 'give' ),
118
+				'label'   => __('Link Text:', 'give'),
119
+				'tooltip' => __('Enter hyperlink text for the link to the main campaign donation form.', 'give'),
120
+				'value'   => __('Donate!', 'give'),
121 121
 			),
122 122
 			array(
123 123
 				'type'    => 'listbox',
124 124
 				'name'    => 'progress_bar',
125
-				'label'   => __( 'Show Progress Bar:', 'give' ),
126
-				'tooltip' => __( 'Select whether you would like to show a goal progress bar.', 'give' ),
125
+				'label'   => __('Show Progress Bar:', 'give'),
126
+				'tooltip' => __('Select whether you would like to show a goal progress bar.', 'give'),
127 127
 				'options' => array(
128
-					'true'  => __( 'Show', 'give' ),
129
-					'false' => __( 'Hide', 'give' ),
128
+					'true'  => __('Show', 'give'),
129
+					'false' => __('Hide', 'give'),
130 130
 				),
131 131
 				'value'   => 'true',
132 132
 			),
Please login to merge, or discard this patch.
includes/admin/forms/dashboard-columns.php 1 patch
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -27,34 +27,34 @@  discard block
 block discarded – undo
27 27
  * @return array $form_columns Updated array of forms columns
28 28
  *  Post Type List Table
29 29
  */
30
-function give_form_columns( $give_form_columns ) {
30
+function give_form_columns($give_form_columns) {
31 31
 
32 32
 	// Standard columns
33 33
 	$give_form_columns = array(
34 34
 		'cb'            => '<input type="checkbox"/>',
35
-		'title'         => __( 'Name', 'give' ),
36
-		'form_category' => __( 'Categories', 'give' ),
37
-		'form_tag'      => __( 'Tags', 'give' ),
38
-		'price'         => __( 'Amount', 'give' ),
39
-		'goal'          => __( 'Goal', 'give' ),
40
-		'donations'     => __( 'Donations', 'give' ),
41
-		'earnings'      => __( 'Income', 'give' ),
42
-		'shortcode'     => __( 'Shortcode', 'give' ),
43
-		'date'          => __( 'Date', 'give' ),
35
+		'title'         => __('Name', 'give'),
36
+		'form_category' => __('Categories', 'give'),
37
+		'form_tag'      => __('Tags', 'give'),
38
+		'price'         => __('Amount', 'give'),
39
+		'goal'          => __('Goal', 'give'),
40
+		'donations'     => __('Donations', 'give'),
41
+		'earnings'      => __('Income', 'give'),
42
+		'shortcode'     => __('Shortcode', 'give'),
43
+		'date'          => __('Date', 'give'),
44 44
 	);
45 45
 
46 46
 	// Does the user want categories / tags?
47
-	if ( ! give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ) ) {
48
-		unset( $give_form_columns['form_category'] );
47
+	if ( ! give_is_setting_enabled(give_get_option('categories', 'disabled'))) {
48
+		unset($give_form_columns['form_category']);
49 49
 	}
50
-	if ( ! give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ) ) {
51
-		unset( $give_form_columns['form_tag'] );
50
+	if ( ! give_is_setting_enabled(give_get_option('tags', 'disabled'))) {
51
+		unset($give_form_columns['form_tag']);
52 52
 	}
53 53
 
54
-	return apply_filters( 'give_forms_columns', $give_form_columns );
54
+	return apply_filters('give_forms_columns', $give_form_columns);
55 55
 }
56 56
 
57
-add_filter( 'manage_edit-give_forms_columns', 'give_form_columns' );
57
+add_filter('manage_edit-give_forms_columns', 'give_form_columns');
58 58
 
59 59
 /**
60 60
  * Render Give Form Columns
@@ -66,70 +66,70 @@  discard block
 block discarded – undo
66 66
  *
67 67
  * @return void
68 68
  */
69
-function give_render_form_columns( $column_name, $post_id ) {
70
-	if ( get_post_type( $post_id ) == 'give_forms' ) {
69
+function give_render_form_columns($column_name, $post_id) {
70
+	if (get_post_type($post_id) == 'give_forms') {
71 71
 
72
-		switch ( $column_name ) {
72
+		switch ($column_name) {
73 73
 			case 'form_category':
74
-				echo get_the_term_list( $post_id, 'give_forms_category', '', ', ', '' );
74
+				echo get_the_term_list($post_id, 'give_forms_category', '', ', ', '');
75 75
 				break;
76 76
 			case 'form_tag':
77
-				echo get_the_term_list( $post_id, 'give_forms_tag', '', ', ', '' );
77
+				echo get_the_term_list($post_id, 'give_forms_tag', '', ', ', '');
78 78
 				break;
79 79
 			case 'price':
80
-				if ( give_has_variable_prices( $post_id ) ) {
81
-					echo give_price_range( $post_id );
80
+				if (give_has_variable_prices($post_id)) {
81
+					echo give_price_range($post_id);
82 82
 				} else {
83
-					echo give_price( $post_id, false );
84
-					printf( '<input type="hidden" class="formprice-%1$s" value="%2$s" />', esc_attr( $post_id ), esc_attr( give_get_form_price( $post_id ) ) );
83
+					echo give_price($post_id, false);
84
+					printf('<input type="hidden" class="formprice-%1$s" value="%2$s" />', esc_attr($post_id), esc_attr(give_get_form_price($post_id)));
85 85
 				}
86 86
 				break;
87 87
 			case 'goal':
88
-				if ( give_is_setting_enabled( give_get_meta( $post_id, '_give_goal_option', true ) ) ) {
88
+				if (give_is_setting_enabled(give_get_meta($post_id, '_give_goal_option', true))) {
89 89
 
90
-					echo give_admin_form_goal_stats( $post_id );
90
+					echo give_admin_form_goal_stats($post_id);
91 91
 
92 92
 				} else {
93
-					_e( 'No Goal Set', 'give' );
93
+					_e('No Goal Set', 'give');
94 94
 				}
95 95
 
96 96
 				printf(
97 97
 					'<input type="hidden" class="formgoal-%1$s" value="%2$s" />',
98
-					esc_attr( $post_id ),
99
-					give_get_form_goal( $post_id )
98
+					esc_attr($post_id),
99
+					give_get_form_goal($post_id)
100 100
 				);
101 101
 
102 102
 				break;
103 103
 			case 'donations':
104
-				if ( current_user_can( 'view_give_form_stats', $post_id ) ) {
104
+				if (current_user_can('view_give_form_stats', $post_id)) {
105 105
 					printf(
106 106
 						'<a href="%1$s">%2$s</a>',
107
-						esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&form_id=' . $post_id ) ),
108
-						give_get_form_sales_stats( $post_id )
107
+						esc_url(admin_url('edit.php?post_type=give_forms&page=give-payment-history&form_id='.$post_id)),
108
+						give_get_form_sales_stats($post_id)
109 109
 					);
110 110
 				} else {
111 111
 					echo '-';
112 112
 				}
113 113
 				break;
114 114
 			case 'earnings':
115
-				if ( current_user_can( 'view_give_form_stats', $post_id ) ) {
115
+				if (current_user_can('view_give_form_stats', $post_id)) {
116 116
 					printf(
117 117
 						'<a href="%1$s">%2$s</a>',
118
-						esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-reports&tab=forms&form-id=' . $post_id ) ),
119
-						give_currency_filter( give_format_amount( give_get_form_earnings_stats( $post_id ), array( 'sanitize' => false ) ) )
118
+						esc_url(admin_url('edit.php?post_type=give_forms&page=give-reports&tab=forms&form-id='.$post_id)),
119
+						give_currency_filter(give_format_amount(give_get_form_earnings_stats($post_id), array('sanitize' => false)))
120 120
 					);
121 121
 				} else {
122 122
 					echo '-';
123 123
 				}
124 124
 				break;
125 125
 			case 'shortcode':
126
-				printf( '<input onclick="this.setSelectionRange(0, this.value.length)" type="text" class="shortcode-input" readonly="" value="[give_form id=&#34;%s&#34;]"', absint( $post_id ) );
126
+				printf('<input onclick="this.setSelectionRange(0, this.value.length)" type="text" class="shortcode-input" readonly="" value="[give_form id=&#34;%s&#34;]"', absint($post_id));
127 127
 				break;
128 128
 		}// End switch().
129 129
 	}// End if().
130 130
 }
131 131
 
132
-add_action( 'manage_posts_custom_column', 'give_render_form_columns', 10, 2 );
132
+add_action('manage_posts_custom_column', 'give_render_form_columns', 10, 2);
133 133
 
134 134
 /**
135 135
  * Registers the sortable columns in the list table
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
  *
141 141
  * @return array $columns Array of sortable columns
142 142
  */
143
-function give_sortable_form_columns( $columns ) {
143
+function give_sortable_form_columns($columns) {
144 144
 	$columns['price']     = 'amount';
145 145
 	$columns['sales']     = 'sales';
146 146
 	$columns['earnings']  = 'earnings';
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	return $columns;
151 151
 }
152 152
 
153
-add_filter( 'manage_edit-give_forms_sortable_columns', 'give_sortable_form_columns' );
153
+add_filter('manage_edit-give_forms_sortable_columns', 'give_sortable_form_columns');
154 154
 
155 155
 /**
156 156
  * Sorts Columns in the Forms List Table
@@ -161,13 +161,13 @@  discard block
 block discarded – undo
161 161
  *
162 162
  * @return array $vars Array of all the sort variables.
163 163
  */
164
-function give_sort_forms( $vars ) {
164
+function give_sort_forms($vars) {
165 165
 	// Check if we're viewing the "give_forms" post type.
166
-	if ( ! isset( $vars['post_type'] ) || ! isset( $vars['orderby'] ) || 'give_forms' !== $vars['post_type'] ) {
166
+	if ( ! isset($vars['post_type']) || ! isset($vars['orderby']) || 'give_forms' !== $vars['post_type']) {
167 167
 		return $vars;
168 168
 	}
169 169
 
170
-	switch ( $vars['orderby'] ) {
170
+	switch ($vars['orderby']) {
171 171
 		// Check if 'orderby' is set to "sales".
172 172
 		case 'sales':
173 173
 			$vars = array_merge(
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 
193 193
 		// Check if "orderby" is set to "price/amount".
194 194
 		case 'amount':
195
-			$multi_level_meta_key = ( 'asc' === $vars['order'] ) ? '_give_levels_minimum_amount' : '_give_levels_maximum_amount';
195
+			$multi_level_meta_key = ('asc' === $vars['order']) ? '_give_levels_minimum_amount' : '_give_levels_maximum_amount';
196 196
 
197 197
 			$vars['orderby']    = 'meta_value_num';
198 198
 			$vars['meta_query'] = array(
@@ -244,17 +244,17 @@  discard block
 block discarded – undo
244 244
  *
245 245
  * @return array       Array of all sort variables.
246 246
  */
247
-function give_filter_forms( $vars ) {
248
-	if ( isset( $vars['post_type'] ) && 'give_forms' == $vars['post_type'] ) {
247
+function give_filter_forms($vars) {
248
+	if (isset($vars['post_type']) && 'give_forms' == $vars['post_type']) {
249 249
 
250 250
 		// If an author ID was passed, use it
251
-		if ( isset( $_REQUEST['author'] ) && ! current_user_can( 'view_give_reports' ) ) {
251
+		if (isset($_REQUEST['author']) && ! current_user_can('view_give_reports')) {
252 252
 
253 253
 			$author_id = $_REQUEST['author'];
254
-			if ( (int) $author_id !== get_current_user_id() ) {
255
-				wp_die( esc_html__( 'You do not have permission to view this data.', 'give' ), esc_html__( 'Error', 'give' ), array(
254
+			if ((int) $author_id !== get_current_user_id()) {
255
+				wp_die(esc_html__('You do not have permission to view this data.', 'give'), esc_html__('Error', 'give'), array(
256 256
 					'response' => 403,
257
-				) );
257
+				));
258 258
 			}
259 259
 			$vars = array_merge(
260 260
 				$vars,
@@ -278,11 +278,11 @@  discard block
 block discarded – undo
278 278
  * @return void
279 279
  */
280 280
 function give_forms_load() {
281
-	add_filter( 'request', 'give_sort_forms' );
282
-	add_filter( 'request', 'give_filter_forms' );
281
+	add_filter('request', 'give_sort_forms');
282
+	add_filter('request', 'give_filter_forms');
283 283
 }
284 284
 
285
-add_action( 'load-edit.php', 'give_forms_load', 9999 );
285
+add_action('load-edit.php', 'give_forms_load', 9999);
286 286
 
287 287
 /**
288 288
  * Remove Forms Month Filter
@@ -296,17 +296,17 @@  discard block
 block discarded – undo
296 296
  * @global      $typenow The post type we are viewing.
297 297
  * @return array Empty array disables the dropdown.
298 298
  */
299
-function give_remove_month_filter( $dates ) {
299
+function give_remove_month_filter($dates) {
300 300
 	global $typenow;
301 301
 
302
-	if ( $typenow == 'give_forms' ) {
302
+	if ($typenow == 'give_forms') {
303 303
 		$dates = array();
304 304
 	}
305 305
 
306 306
 	return $dates;
307 307
 }
308 308
 
309
-add_filter( 'months_dropdown_results', 'give_remove_month_filter', 99 );
309
+add_filter('months_dropdown_results', 'give_remove_month_filter', 99);
310 310
 
311 311
 /**
312 312
  * Updates price when saving post
@@ -318,33 +318,33 @@  discard block
 block discarded – undo
318 318
  *
319 319
  * @return int|null
320 320
  */
321
-function give_price_save_quick_edit( $post_id ) {
322
-	if ( ! isset( $_POST['post_type'] ) || 'give_forms' !== $_POST['post_type'] ) {
321
+function give_price_save_quick_edit($post_id) {
322
+	if ( ! isset($_POST['post_type']) || 'give_forms' !== $_POST['post_type']) {
323 323
 		return;
324 324
 	}
325
-	if ( ! current_user_can( 'edit_post', $post_id ) ) {
325
+	if ( ! current_user_can('edit_post', $post_id)) {
326 326
 		return $post_id;
327 327
 	}
328
-	if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
328
+	if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
329 329
 		return $post_id;
330 330
 	}
331 331
 
332
-	if ( isset( $_REQUEST['_give_regprice'] ) ) {
333
-		give_update_meta( $post_id, '_give_set_price', give_sanitize_amount_for_db( strip_tags( stripslashes( $_REQUEST['_give_regprice'] ) ) ) );
332
+	if (isset($_REQUEST['_give_regprice'])) {
333
+		give_update_meta($post_id, '_give_set_price', give_sanitize_amount_for_db(strip_tags(stripslashes($_REQUEST['_give_regprice']))));
334 334
 	}
335 335
 
336 336
 	// Override the Donation minimum amount.
337 337
 	if (
338
-		isset( $_REQUEST['_give_custom_amount'], $_REQUEST['_give_set_price'], $_REQUEST['_give_price_option'], $_REQUEST['_give_custom_amount_range'] )
338
+		isset($_REQUEST['_give_custom_amount'], $_REQUEST['_give_set_price'], $_REQUEST['_give_price_option'], $_REQUEST['_give_custom_amount_range'])
339 339
 		&& 'set' === $_REQUEST['_give_price_option']
340
-		&& give_is_setting_enabled( $_REQUEST['_give_custom_amount'] )
341
-		&& give_maybe_sanitize_amount( $_REQUEST['_give_set_price'] ) < give_maybe_sanitize_amount( $_REQUEST['_give_custom_amount_range']['minimum'] )
340
+		&& give_is_setting_enabled($_REQUEST['_give_custom_amount'])
341
+		&& give_maybe_sanitize_amount($_REQUEST['_give_set_price']) < give_maybe_sanitize_amount($_REQUEST['_give_custom_amount_range']['minimum'])
342 342
 	) {
343
-		give_update_meta( $post_id, '_give_custom_amount_range_minimum', give_sanitize_amount_for_db( $_REQUEST['_give_set_price'] ) );
343
+		give_update_meta($post_id, '_give_custom_amount_range_minimum', give_sanitize_amount_for_db($_REQUEST['_give_set_price']));
344 344
 	}
345 345
 }
346 346
 
347
-add_action( 'save_post', 'give_price_save_quick_edit' );
347
+add_action('save_post', 'give_price_save_quick_edit');
348 348
 
349 349
 /**
350 350
  * Process bulk edit actions via AJAX
@@ -354,18 +354,18 @@  discard block
 block discarded – undo
354 354
  */
355 355
 function give_save_bulk_edit() {
356 356
 
357
-	$post_ids = ( isset( $_POST['post_ids'] ) && ! empty( $_POST['post_ids'] ) ) ? $_POST['post_ids'] : array();
357
+	$post_ids = (isset($_POST['post_ids']) && ! empty($_POST['post_ids'])) ? $_POST['post_ids'] : array();
358 358
 
359
-	if ( ! empty( $post_ids ) && is_array( $post_ids ) ) {
360
-		$price = isset( $_POST['price'] ) ? strip_tags( stripslashes( $_POST['price'] ) ) : 0;
361
-		foreach ( $post_ids as $post_id ) {
359
+	if ( ! empty($post_ids) && is_array($post_ids)) {
360
+		$price = isset($_POST['price']) ? strip_tags(stripslashes($_POST['price'])) : 0;
361
+		foreach ($post_ids as $post_id) {
362 362
 
363
-			if ( ! current_user_can( 'edit_post', $post_id ) ) {
363
+			if ( ! current_user_can('edit_post', $post_id)) {
364 364
 				continue;
365 365
 			}
366 366
 
367
-			if ( ! empty( $price ) ) {
368
-				give_update_meta( $post_id, '_give_set_price', give_sanitize_amount_for_db( $price ) );
367
+			if ( ! empty($price)) {
368
+				give_update_meta($post_id, '_give_set_price', give_sanitize_amount_for_db($price));
369 369
 			}
370 370
 		}
371 371
 	}
@@ -373,4 +373,4 @@  discard block
 block discarded – undo
373 373
 	die();
374 374
 }
375 375
 
376
-add_action( 'wp_ajax_give_save_bulk_edit', 'give_save_bulk_edit' );
376
+add_action('wp_ajax_give_save_bulk_edit', 'give_save_bulk_edit');
Please login to merge, or discard this patch.
includes/admin/abstract-admin-settings-page.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@  discard block
 block discarded – undo
9 9
  * @since       1.8
10 10
  */
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit; // Exit if accessed directly
14 14
 }
15 15
 
16
-if ( ! class_exists( 'Give_Settings_Page' ) ) :
16
+if ( ! class_exists('Give_Settings_Page')) :
17 17
 
18 18
 	/**
19 19
 	 * Give_Settings_Page.
@@ -70,25 +70,25 @@  discard block
 block discarded – undo
70 70
 			// Get current setting page.
71 71
 			$this->current_setting_page = give_get_current_setting_page();
72 72
 
73
-			add_filter( "give_default_setting_tab_section_{$this->id}", array( $this, 'set_default_setting_tab' ), 10 );
74
-			add_filter( "{$this->current_setting_page}_tabs_array", array( $this, 'add_settings_page' ), 20 );
75
-			add_action( "{$this->current_setting_page}_settings_{$this->id}_page", array( $this, 'output' ) );
73
+			add_filter("give_default_setting_tab_section_{$this->id}", array($this, 'set_default_setting_tab'), 10);
74
+			add_filter("{$this->current_setting_page}_tabs_array", array($this, 'add_settings_page'), 20);
75
+			add_action("{$this->current_setting_page}_settings_{$this->id}_page", array($this, 'output'));
76 76
 
77 77
 			// Output section only if exist.
78 78
 			$sections = $this->get_sections();
79
-			if ( ! empty( $sections ) ) {
80
-				add_action( "{$this->current_setting_page}_sections_{$this->id}_page", array(
79
+			if ( ! empty($sections)) {
80
+				add_action("{$this->current_setting_page}_sections_{$this->id}_page", array(
81 81
 					$this,
82 82
 					'output_sections',
83
-				) );
83
+				));
84 84
 			}
85 85
 
86 86
 			// Save hide button by default.
87 87
 			$GLOBALS['give_hide_save_button'] = true;
88 88
 
89 89
 			// Enable saving feature.
90
-			if ( $this->enable_save ) {
91
-				add_action( "{$this->current_setting_page}_save_{$this->id}", array( $this, 'save' ) );
90
+			if ($this->enable_save) {
91
+				add_action("{$this->current_setting_page}_save_{$this->id}", array($this, 'save'));
92 92
 			}
93 93
 		}
94 94
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 		 *
114 114
 		 * @return string
115 115
 		 */
116
-		function set_default_setting_tab( $setting_tab ) {
116
+		function set_default_setting_tab($setting_tab) {
117 117
 			return $this->default_tab;
118 118
 		}
119 119
 
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
 		 *
127 127
 		 * @return array
128 128
 		 */
129
-		public function add_settings_page( $pages ) {
130
-			$pages[ $this->id ] = $this->label;
129
+		public function add_settings_page($pages) {
130
+			$pages[$this->id] = $this->label;
131 131
 
132 132
 			return $pages;
133 133
 		}
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 			 *
147 147
 			 * @param  array $settings
148 148
 			 */
149
-			$settings = apply_filters( 'give_get_settings_' . $this->id, array() );
149
+			$settings = apply_filters('give_get_settings_'.$this->id, array());
150 150
 
151 151
 			// Output.
152 152
 			return $settings;
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 		 * @return array
160 160
 		 */
161 161
 		public function get_sections() {
162
-			return apply_filters( 'give_get_sections_' . $this->id, array() );
162
+			return apply_filters('give_get_sections_'.$this->id, array());
163 163
 		}
164 164
 
165 165
 		/**
@@ -176,40 +176,40 @@  discard block
 block discarded – undo
176 176
 			$sections = $this->get_sections();
177 177
 
178 178
 			// Bailout.
179
-			if ( empty( $sections ) ) {
179
+			if (empty($sections)) {
180 180
 				return;
181 181
 			}
182 182
 
183 183
 			// Show section settings only if setting section exist.
184
-			if ( $current_section && ! in_array( $current_section, array_keys( $sections ), true ) ) {
185
-				echo wp_kses_post( '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>' );
184
+			if ($current_section && ! in_array($current_section, array_keys($sections), true)) {
185
+				echo wp_kses_post('<div class="error"><p>'.__('Oops, this settings page does not exist.', 'give').'</p></div>');
186 186
 				$GLOBALS['give_hide_save_button'] = true;
187 187
 
188 188
 				return;
189 189
 			}
190 190
 
191
-			if ( is_null( $this->current_setting_page ) ) {
191
+			if (is_null($this->current_setting_page)) {
192 192
 				$this->current_setting_page = give_get_current_setting_page();
193 193
 			}
194 194
 
195 195
 			$section_list = array();
196
-			foreach ( $sections as $id => $label ) {
196
+			foreach ($sections as $id => $label) {
197 197
 				/**
198 198
 				 * Fire the filter to hide particular section on tab.
199 199
 				 *
200 200
 				 * @since 2.0
201 201
 				 */
202
-				if ( apply_filters( "give_hide_section_{$id}_on_{$this->id}_page", false, $sections, $this->id ) ) {
202
+				if (apply_filters("give_hide_section_{$id}_on_{$this->id}_page", false, $sections, $this->id)) {
203 203
 					continue;
204 204
 				}
205 205
 
206
-				$section_list[] = '<li><a href="' . admin_url( 'edit.php?post_type=give_forms&page=' . $this->current_setting_page . '&tab=' . $this->id . '&section=' . sanitize_title( $id ) ) . '" class="' . ( $current_section === $id ? 'current' : '' ) . '">' . $label . '</a>';
206
+				$section_list[] = '<li><a href="'.admin_url('edit.php?post_type=give_forms&page='.$this->current_setting_page.'&tab='.$this->id.'&section='.sanitize_title($id)).'" class="'.($current_section === $id ? 'current' : '').'">'.$label.'</a>';
207 207
 			}
208 208
 
209
-			echo wp_kses_post( sprintf(
209
+			echo wp_kses_post(sprintf(
210 210
 				'<ul class="give-subsubsub">%s</ul><br class="clear" /><hr>',
211
-				implode( ' | </li>', $section_list )
212
-			) );
211
+				implode(' | </li>', $section_list)
212
+			));
213 213
 		}
214 214
 
215 215
 		/**
@@ -221,13 +221,13 @@  discard block
 block discarded – undo
221 221
 		 * @return void
222 222
 		 */
223 223
 		public function output() {
224
-			if ( $this->enable_save ) {
224
+			if ($this->enable_save) {
225 225
 				$GLOBALS['give_hide_save_button'] = false;
226 226
 			}
227 227
 
228 228
 			$settings = $this->get_settings();
229 229
 
230
-			Give_Admin_Settings::output_fields( $settings, 'give_settings' );
230
+			Give_Admin_Settings::output_fields($settings, 'give_settings');
231 231
 		}
232 232
 
233 233
 		/**
@@ -245,8 +245,8 @@  discard block
 block discarded – undo
245 245
 			 *
246 246
 			 * @since 2.1
247 247
 			 */
248
-			if ( apply_filters( "give_save_options_{$this->id}_{$current_section}", true ) ) {
249
-				Give_Admin_Settings::save_fields( $settings, 'give_settings' );
248
+			if (apply_filters("give_save_options_{$this->id}_{$current_section}", true)) {
249
+				Give_Admin_Settings::save_fields($settings, 'give_settings');
250 250
 			}
251 251
 
252 252
 			/**
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 			 *
255 255
 			 * @since 1.8
256 256
 			 */
257
-			do_action( 'give_update_options_' . $this->id . '_' . $current_section );
257
+			do_action('give_update_options_'.$this->id.'_'.$current_section);
258 258
 		}
259 259
 
260 260
 		/**
@@ -271,11 +271,11 @@  discard block
 block discarded – undo
271 271
 			$section         = $this->get_sections();
272 272
 			$current_section = give_get_current_setting_section();
273 273
 
274
-			if ( array_key_exists( $current_section, $section ) ) {
275
-				$heading[] = $section[ $current_section ];
274
+			if (array_key_exists($current_section, $section)) {
275
+				$heading[] = $section[$current_section];
276 276
 			}
277 277
 
278
-			return array_unique( $heading );
278
+			return array_unique($heading);
279 279
 		}
280 280
 
281 281
 		/**
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 		public function get_heading_html() {
290 290
 			return sprintf(
291 291
 				'<h1 class="wp-heading-inline">%s</h1><hr class="wp-header-end">',
292
-				implode( ' <span class="give-settings-heading-sep dashicons dashicons-arrow-right-alt2"></span> ', $this->get_heading() )
292
+				implode(' <span class="give-settings-heading-sep dashicons dashicons-arrow-right-alt2"></span> ', $this->get_heading())
293 293
 			);
294 294
 		}
295 295
 	}
Please login to merge, or discard this patch.