Test Failed
Push — master ( f098b0...602e9b )
by Devin
10:54 queued 05:19
created
templates/shortcode-goal.php 1 patch
Spacing   +36 added lines, -37 removed lines patch added patch discarded remove patch
@@ -3,27 +3,27 @@  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 10
 if (
11
-	( isset( $args['show_goal'] ) && ! filter_var( $args['show_goal'], FILTER_VALIDATE_BOOLEAN ) )
12
-	|| empty( $form->ID )
13
-	|| ( is_singular( 'give_forms' ) && ! give_is_setting_enabled( $goal_option ) )
14
-	|| ! give_is_setting_enabled( $goal_option )
11
+	(isset($args['show_goal']) && ! filter_var($args['show_goal'], FILTER_VALIDATE_BOOLEAN))
12
+	|| empty($form->ID)
13
+	|| (is_singular('give_forms') && ! give_is_setting_enabled($goal_option))
14
+	|| ! give_is_setting_enabled($goal_option)
15 15
 	|| 0 === $form->goal
16 16
 ) {
17 17
 	return false;
18 18
 }
19 19
 
20
-$goal_format         = give_get_meta( $form_id, '_give_goal_format', true );
21
-$price               = give_get_meta( $form_id, '_give_set_price', true );
22
-$color               = give_get_meta( $form_id, '_give_goal_color', true );
23
-$show_text           = isset( $args['show_text'] ) ? filter_var( $args['show_text'], FILTER_VALIDATE_BOOLEAN ) : true;
24
-$show_bar            = isset( $args['show_bar'] ) ? filter_var( $args['show_bar'], FILTER_VALIDATE_BOOLEAN ) : true;
25
-$donations_goal      = give_get_meta( $form_id, '_give_number_of_donation_goal', true );
26
-$donations_completed = give_get_form_sales_stats( $form_id );
20
+$goal_format         = give_get_meta($form_id, '_give_goal_format', true);
21
+$price               = give_get_meta($form_id, '_give_set_price', true);
22
+$color               = give_get_meta($form_id, '_give_goal_color', true);
23
+$show_text           = isset($args['show_text']) ? filter_var($args['show_text'], FILTER_VALIDATE_BOOLEAN) : true;
24
+$show_bar            = isset($args['show_bar']) ? filter_var($args['show_bar'], FILTER_VALIDATE_BOOLEAN) : true;
25
+$donations_goal      = give_get_meta($form_id, '_give_number_of_donation_goal', true);
26
+$donations_completed = give_get_form_sales_stats($form_id);
27 27
 
28 28
 
29 29
 /**
@@ -31,14 +31,14 @@  discard block
 block discarded – undo
31 31
  *
32 32
  * @since 1.8.8
33 33
  */
34
-$income = apply_filters( 'give_goal_amount_raised_output', $form->get_earnings(), $form_id, $form );
34
+$income = apply_filters('give_goal_amount_raised_output', $form->get_earnings(), $form_id, $form);
35 35
 
36 36
 /**
37 37
  * Filter the form
38 38
  *
39 39
  * @since 1.8.8
40 40
  */
41
-$goal = apply_filters( 'give_goal_amount_target_output', $form->goal, $form_id, $form );
41
+$goal = apply_filters('give_goal_amount_target_output', $form->goal, $form_id, $form);
42 42
 
43 43
 
44 44
 /**
@@ -47,10 +47,9 @@  discard block
 block discarded – undo
47 47
  * @since 1.8.8
48 48
  */
49 49
 $progress = 'donation' !== $goal_format ?
50
-	round( ( $income / $goal ) * 100, 2 ) :
51
-	round( ( $donations_completed / $donations_goal ) * 100, 2 );
50
+	round(($income / $goal) * 100, 2) : round(($donations_completed / $donations_goal) * 100, 2);
52 51
 
53
-$progress = apply_filters( 'give_goal_amount_funded_percentage_output', $progress, $form_id, $form );
52
+$progress = apply_filters('give_goal_amount_funded_percentage_output', $progress, $form_id, $form);
54 53
 
55 54
 
56 55
 /**
@@ -58,55 +57,55 @@  discard block
 block discarded – undo
58 57
  *
59 58
  * @since 1.8.17
60 59
  */
61
-$form_currency = apply_filters( 'give_goal_form_currency', give_get_currency( $form_id ), $form_id );
60
+$form_currency = apply_filters('give_goal_form_currency', give_get_currency($form_id), $form_id);
62 61
 
63 62
 // Set progress to 100 percentage if income > goal or completed donations > donation goal count.
64
-if ( 'donation' === $goal_format ) {
63
+if ('donation' === $goal_format) {
65 64
 	$progress = $donations_completed >= $donations_goal ? 100 : $progress;
66 65
 } else {
67 66
 	$progress = $income >= $goal ? 100 : $progress;
68 67
 }
69 68
 ?>
70 69
 <div class="give-goal-progress">
71
-	<?php if ( ! empty( $show_text ) ) : ?>
70
+	<?php if ( ! empty($show_text)) : ?>
72 71
 		<div class="raised">
73 72
 			<?php
74
-			if ( 'amount' === $goal_format ) :
73
+			if ('amount' === $goal_format) :
75 74
 
76 75
 				/**
77 76
 				 * Filter the income formatting arguments.
78 77
 				 *
79 78
 				 * @since 1.8.17
80 79
 				 */
81
-				$income_format_args = apply_filters( 'give_goal_income_format_args', array( 'sanitize' => false, 'currency' => $form_currency, 'decimal' => false ), $form_id );
80
+				$income_format_args = apply_filters('give_goal_income_format_args', array('sanitize' => false, 'currency' => $form_currency, 'decimal' => false), $form_id);
82 81
 
83 82
 				/**
84 83
 				 * Filter the goal formatting arguments.
85 84
 				 *
86 85
 				 * @since 1.8.17
87 86
 				 */
88
-				$goal_format_args   = apply_filters( 'give_goal_amount_format_args', array( 'sanitize' => false, 'currency' => $form_currency, 'decimal' => false ), $form_id );
87
+				$goal_format_args = apply_filters('give_goal_amount_format_args', array('sanitize' => false, 'currency' => $form_currency, 'decimal' => false), $form_id);
89 88
 
90 89
 				// Get formatted amount.
91
-				$income = give_human_format_large_amount( give_format_amount( $income, $income_format_args ), array( 'currency' => $form_currency ) );
92
-				$goal   = give_human_format_large_amount( give_format_amount( $goal, $goal_format_args ), array( 'currency' => $form_currency ) );
90
+				$income = give_human_format_large_amount(give_format_amount($income, $income_format_args), array('currency' => $form_currency));
91
+				$goal   = give_human_format_large_amount(give_format_amount($goal, $goal_format_args), array('currency' => $form_currency));
93 92
 
94 93
 				echo sprintf(
95 94
 				/* translators: 1: amount of income raised 2: goal target amount. */
96
-					__( '<span class="income">%1$s</span> of <span class="goal-text">%2$s</span> raised', 'give' ),
97
-					give_currency_filter( $income, array( 'form_id' => $form_id ) ),
98
-					give_currency_filter( $goal, array( 'form_id' => $form_id ) )
95
+					__('<span class="income">%1$s</span> of <span class="goal-text">%2$s</span> raised', 'give'),
96
+					give_currency_filter($income, array('form_id' => $form_id)),
97
+					give_currency_filter($goal, array('form_id' => $form_id))
99 98
 				);
100 99
 
101
-			elseif ( 'percentage' === $goal_format ) :
100
+			elseif ('percentage' === $goal_format) :
102 101
 
103 102
 				echo sprintf(
104 103
 				/* translators: %s: percentage of the amount raised compared to the goal target */
105
-					__( '<span class="give-percentage">%s%%</span> funded', 'give' ),
106
-					round( $progress )
104
+					__('<span class="give-percentage">%s%%</span> funded', 'give'),
105
+					round($progress)
107 106
 				);
108 107
 
109
-			elseif ( 'donation' === $goal_format ) :
108
+			elseif ('donation' === $goal_format) :
110 109
 
111 110
 				echo sprintf(
112 111
 				/* translators: 1: total number of donations completed 2: total number of donations set as goal */
@@ -126,11 +125,11 @@  discard block
 block discarded – undo
126 125
 	<?php endif; ?>
127 126
 
128 127
 
129
-	<?php if ( ! empty( $show_bar ) ) : ?>
128
+	<?php if ( ! empty($show_bar)) : ?>
130 129
 		<div class="give-progress-bar" role="progressbar" aria-valuemin="0" aria-valuemax="100"
131
-		     aria-valuenow="<?php echo esc_attr( $progress ); ?>">
132
-			<span style="width: <?php echo esc_attr( $progress ); ?>%;<?php if ( ! empty( $color ) ) {
133
-				echo 'background-color:' . $color;
130
+		     aria-valuenow="<?php echo esc_attr($progress); ?>">
131
+			<span style="width: <?php echo esc_attr($progress); ?>%;<?php if ( ! empty($color)) {
132
+				echo 'background-color:'.$color;
134 133
 			} ?>"></span>
135 134
 		</div><!-- /.give-progress-bar -->
136 135
 	<?php endif; ?>
Please login to merge, or discard this patch.
templates/shortcode-login.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -4,17 +4,17 @@  discard block
 block discarded – undo
4 4
  */
5 5
 
6 6
 
7
-if ( ! is_user_logged_in() ) {
7
+if ( ! is_user_logged_in()) {
8 8
 
9
-	if ( ! empty( $_GET['payment_key'] ) ) {
10
-		$give_login_redirect = add_query_arg( 'payment_key', give_clean( $_GET['payment_key'] ) , give_get_history_page_uri() );
9
+	if ( ! empty($_GET['payment_key'])) {
10
+		$give_login_redirect = add_query_arg('payment_key', give_clean($_GET['payment_key']), give_get_history_page_uri());
11 11
 	}
12 12
 
13 13
 	// Show any error messages after form submission
14
-	Give()->notices->render_frontend_notices( 0 ); ?>
14
+	Give()->notices->render_frontend_notices(0); ?>
15 15
 	<form id="give-login-form" class="give-form" action="" method="post">
16 16
 		<fieldset>
17
-			<legend><?php _e( 'Log into Your Account', 'give' ); ?></legend>
17
+			<legend><?php _e('Log into Your Account', 'give'); ?></legend>
18 18
 			<?php
19 19
 			/**
20 20
 			 * Fires in the login shortcode, before the login fields.
@@ -23,27 +23,27 @@  discard block
 block discarded – undo
23 23
 			 *
24 24
 			 * @since 1.0
25 25
 			 */
26
-			do_action( 'give_login_fields_before' );
26
+			do_action('give_login_fields_before');
27 27
 			?>
28 28
 			<div class="give-login-username give-login">
29
-				<label for="give_user_login"><?php _e( 'Username', 'give' ); ?></label>
29
+				<label for="give_user_login"><?php _e('Username', 'give'); ?></label>
30 30
 				<input name="give_user_login" id="give_user_login" class="give-required give-input" type="text" required aria-required="true" />
31 31
 			</div>
32 32
 
33 33
 			<div class="give-login-password give-login">
34
-				<label for="give_user_pass"><?php _e( 'Password', 'give' ); ?></label>
34
+				<label for="give_user_pass"><?php _e('Password', 'give'); ?></label>
35 35
 				<input name="give_user_pass" id="give_user_pass" class="give-password give-required give-input" type="password" required aria-required="true" />
36 36
 			</div>
37 37
 
38 38
 			<div class="give-login-submit give-login">
39
-				<input type="hidden" name="give_login_redirect" value="<?php echo esc_url( $give_login_redirect ); ?>" />
40
-				<input type="hidden" name="give_login_nonce" value="<?php echo wp_create_nonce( 'give-login-nonce' ); ?>" />
39
+				<input type="hidden" name="give_login_redirect" value="<?php echo esc_url($give_login_redirect); ?>" />
40
+				<input type="hidden" name="give_login_nonce" value="<?php echo wp_create_nonce('give-login-nonce'); ?>" />
41 41
 				<input type="hidden" name="give_action" value="user_login" />
42
-				<input id="give_login_submit" type="submit" class="give_submit" value="<?php _e( 'Log In', 'give' ); ?>" />
42
+				<input id="give_login_submit" type="submit" class="give_submit" value="<?php _e('Log In', 'give'); ?>" />
43 43
 			</div>
44 44
 
45 45
 			<div class="give-lost-password give-login">
46
-				<a href="<?php echo wp_lostpassword_url(); ?>"><?php _e( 'Reset Password', 'give' ); ?></a>
46
+				<a href="<?php echo wp_lostpassword_url(); ?>"><?php _e('Reset Password', 'give'); ?></a>
47 47
 			</div>
48 48
 			<?php
49 49
 			/**
@@ -53,12 +53,12 @@  discard block
 block discarded – undo
53 53
 			 *
54 54
 			 * @since 1.0
55 55
 			 */
56
-			do_action( 'give_login_fields_after' );
56
+			do_action('give_login_fields_after');
57 57
 			?>
58 58
 		</fieldset>
59 59
 	</form>
60
-<?php } elseif( isset( $_GET['give-login-success'] ) && true === (bool) $_GET['give-login-success'] ) { ?>
61
-	<?php Give()->notices->print_frontend_notice( apply_filters('give_successful_login_message', __( 'Login successful. Welcome!', 'give' )), true, 'success' ); ?>
60
+<?php } elseif (isset($_GET['give-login-success']) && true === (bool) $_GET['give-login-success']) { ?>
61
+	<?php Give()->notices->print_frontend_notice(apply_filters('give_successful_login_message', __('Login successful. Welcome!', 'give')), true, 'success'); ?>
62 62
 <?php } else { ?>
63
-	<?php Give()->notices->print_frontend_notice( apply_filters('give_already_logged_in_message', sprintf( __( 'You are already logged in to the site. <a href="%s">Click here</a> to logout.', 'give' ), esc_url( $give_logout_redirect ) ) ), true, 'warning' ); ?>
63
+	<?php Give()->notices->print_frontend_notice(apply_filters('give_already_logged_in_message', sprintf(__('You are already logged in to the site. <a href="%s">Click here</a> to logout.', 'give'), esc_url($give_logout_redirect))), true, 'warning'); ?>
64 64
 <?php } ?>
65 65
\ No newline at end of file
Please login to merge, or discard this patch.
templates/shortcode-receipt.php 1 patch
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -6,25 +6,25 @@  discard block
 block discarded – undo
6 6
 global $give_receipt_args, $payment;
7 7
 
8 8
 // Validation: Ensure $payment var is set.
9
-if ( empty( $payment ) ) {
10
-	$payment = ! empty( $give_receipt_args['id'] ) ? get_post( $give_receipt_args['id'] ) : 0;
9
+if (empty($payment)) {
10
+	$payment = ! empty($give_receipt_args['id']) ? get_post($give_receipt_args['id']) : 0;
11 11
 }
12 12
 
13 13
 // Double-Validation: Check for $payment global.
14
-if ( empty( $payment ) ) {
15
-	Give()->notices->print_frontend_notice( __( 'The specified receipt ID appears to be invalid.', 'give' ) );
14
+if (empty($payment)) {
15
+	Give()->notices->print_frontend_notice(__('The specified receipt ID appears to be invalid.', 'give'));
16 16
 
17 17
 	return;
18 18
 }
19 19
 
20 20
 $donation_id  = $payment->ID;
21
-$form_id      = give_get_payment_meta( $donation_id, '_give_payment_form_id', true );
22
-$meta         = give_get_payment_meta( $donation_id );
23
-$donation     = give_get_donation_form_title( $donation_id );
24
-$user         = give_get_payment_meta_user_info( $donation_id );
25
-$email        = give_get_payment_user_email( $donation_id );
21
+$form_id      = give_get_payment_meta($donation_id, '_give_payment_form_id', true);
22
+$meta         = give_get_payment_meta($donation_id);
23
+$donation     = give_get_donation_form_title($donation_id);
24
+$user         = give_get_payment_meta_user_info($donation_id);
25
+$email        = give_get_payment_user_email($donation_id);
26 26
 $status       = $payment->post_status;
27
-$status_label = give_get_payment_status( $payment, true );
27
+$status_label = give_get_payment_status($payment, true);
28 28
 
29 29
 /**
30 30
  * Generate Donation Receipt Arguments.
@@ -35,50 +35,50 @@  discard block
 block discarded – undo
35 35
  * @since 1.8.8
36 36
  */
37 37
 $give_receipt_args['donation_receipt']['donor'] = array(
38
-	'name'    => __( 'Donor', 'give' ),
39
-	'value'   => $user['first_name'] . ' ' . $user['last_name'],
38
+	'name'    => __('Donor', 'give'),
39
+	'value'   => $user['first_name'].' '.$user['last_name'],
40 40
 	'display' => $give_receipt_args['donor'],
41 41
 );
42 42
 
43 43
 $give_receipt_args['donation_receipt']['date'] = array(
44
-	'name'    => __( 'Date', 'give' ),
45
-	'value'   => date_i18n( give_date_format(), strtotime( $meta['date'] ) ),
44
+	'name'    => __('Date', 'give'),
45
+	'value'   => date_i18n(give_date_format(), strtotime($meta['date'])),
46 46
 	'display' => $give_receipt_args['date'],
47 47
 );
48 48
 
49 49
 $give_receipt_args['donation_receipt']['total_donation'] = array(
50
-	'name'    => __( 'Total Donation', 'give' ),
51
-	'value'   => give_donation_amount( $donation_id, array( 'currency' => true, 'amount' => true, 'type' => 'receipt' ) ),
50
+	'name'    => __('Total Donation', 'give'),
51
+	'value'   => give_donation_amount($donation_id, array('currency' => true, 'amount' => true, 'type' => 'receipt')),
52 52
 	'display' => $give_receipt_args['price'],
53 53
 );
54 54
 
55 55
 $give_receipt_args['donation_receipt']['donation'] = array(
56
-	'name'    => __( 'Donation', 'give' ),
56
+	'name'    => __('Donation', 'give'),
57 57
 	'value'   => $donation,
58 58
 	'display' => true,
59 59
 );
60 60
 
61 61
 $give_receipt_args['donation_receipt']['donation_status'] = array(
62
-	'name'    => __( 'Donation Status', 'give' ),
63
-	'value'   => esc_attr( $status_label ),
62
+	'name'    => __('Donation Status', 'give'),
63
+	'value'   => esc_attr($status_label),
64 64
 	'display' => $give_receipt_args['payment_status'],
65 65
 );
66 66
 
67 67
 $give_receipt_args['donation_receipt']['donation_id'] = array(
68
-	'name'    => __( 'Donation ID', 'give' ),
68
+	'name'    => __('Donation ID', 'give'),
69 69
 	'value'   => $donation_id,
70 70
 	'display' => $give_receipt_args['payment_id'],
71 71
 );
72 72
 
73 73
 $give_receipt_args['donation_receipt']['payment_key'] = array(
74
-	'name'    => __( 'Payment Key', 'give' ),
75
-	'value'   => get_post_meta( $donation_id, '_give_payment_purchase_key', true ),
74
+	'name'    => __('Payment Key', 'give'),
75
+	'value'   => get_post_meta($donation_id, '_give_payment_purchase_key', true),
76 76
 	'display' => $give_receipt_args['payment_key'],
77 77
 );
78 78
 
79 79
 $give_receipt_args['donation_receipt']['payment_method'] = array(
80
-	'name'    => __( 'Payment Method', 'give' ),
81
-	'value'   => give_get_gateway_checkout_label( give_get_payment_gateway( $donation_id ) ),
80
+	'name'    => __('Payment Method', 'give'),
81
+	'value'   => give_get_gateway_checkout_label(give_get_payment_gateway($donation_id)),
82 82
 	'display' => $give_receipt_args['payment_method'],
83 83
 );
84 84
 
@@ -93,10 +93,10 @@  discard block
 block discarded – undo
93 93
  *
94 94
  * @since 1.8.8
95 95
  */
96
-$give_receipt_args['donation_receipt'] = apply_filters( 'give_donation_receipt_args', $give_receipt_args['donation_receipt'], $donation_id, $form_id );
96
+$give_receipt_args['donation_receipt'] = apply_filters('give_donation_receipt_args', $give_receipt_args['donation_receipt'], $donation_id, $form_id);
97 97
 
98 98
 // When the donation were made through offline donation, We won't show receipt and payment status though.
99
-if ( 'offline' === give_get_payment_gateway( $payment->ID ) && 'pending' === $status ) {
99
+if ('offline' === give_get_payment_gateway($payment->ID) && 'pending' === $status) {
100 100
 
101 101
 	/**
102 102
 	 * Before the offline donation receipt content starts.
@@ -106,13 +106,13 @@  discard block
 block discarded – undo
106 106
 	 * @param Give_Payment $payment           Donation payment object.
107 107
 	 * @param array        $give_receipt_args Receipt Arguments.
108 108
 	 */
109
-	do_action( 'give_receipt_before_offline_payment', $payment, $give_receipt_args );
109
+	do_action('give_receipt_before_offline_payment', $payment, $give_receipt_args);
110 110
 	?>
111
-	<h2><?php echo apply_filters( 'give_receipt_offline_payment_heading', __( 'Your Donation is Almost Complete!', 'give' ) ); ?></h2>
112
-	<div id="give_donation_receipt" class="<?php echo esc_attr( apply_filters( 'give_receipt_offline_payment_classes', 'give_receipt_offline_payment' ) ); ?>">
111
+	<h2><?php echo apply_filters('give_receipt_offline_payment_heading', __('Your Donation is Almost Complete!', 'give')); ?></h2>
112
+	<div id="give_donation_receipt" class="<?php echo esc_attr(apply_filters('give_receipt_offline_payment_classes', 'give_receipt_offline_payment')); ?>">
113 113
 		<?php
114 114
 		// Instruction for offline donation.
115
-		$offline_instruction = give_get_offline_payment_instruction( $form_id, true );
115
+		$offline_instruction = give_get_offline_payment_instruction($form_id, true);
116 116
 
117 117
 		/**
118 118
 		 * Instruction for the offline donation.
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 		 * @param Give_Payment $payment             Payment object.
124 124
 		 * @param integer      $form_id             Donation form id.
125 125
 		 */
126
-		echo apply_filters( 'give_receipt_offline_payment_instruction', $offline_instruction, $payment, $form_id );
126
+		echo apply_filters('give_receipt_offline_payment_instruction', $offline_instruction, $payment, $form_id);
127 127
 		?>
128 128
 	</div>
129 129
 	<?php
@@ -135,52 +135,52 @@  discard block
 block discarded – undo
135 135
 	 * @param Give_Payment $payment           Donation payment object.
136 136
 	 * @param array        $give_receipt_args Receipt Arguments.
137 137
 	 */
138
-	do_action( 'give_receipt_after_offline_payment', $payment, $give_receipt_args );
138
+	do_action('give_receipt_after_offline_payment', $payment, $give_receipt_args);
139 139
 
140 140
 	return;
141 141
 }
142 142
 
143 143
 // Show payment status notice based on shortcode attribute.
144
-if ( filter_var( $give_receipt_args['status_notice'], FILTER_VALIDATE_BOOLEAN ) ) {
144
+if (filter_var($give_receipt_args['status_notice'], FILTER_VALIDATE_BOOLEAN)) {
145 145
 	$notice_message = '';
146 146
 	$notice_type    = 'warning';
147 147
 
148
-	switch ( $status ) {
148
+	switch ($status) {
149 149
 		case 'publish':
150
-			$notice_message = __( 'Payment Complete: Thank you for your donation.', 'give' );
150
+			$notice_message = __('Payment Complete: Thank you for your donation.', 'give');
151 151
 			$notice_type    = 'success';
152 152
 			break;
153 153
 		case 'pending':
154
-			$notice_message = __( 'Payment Pending: Your donation is currently processing.', 'give' );
154
+			$notice_message = __('Payment Pending: Your donation is currently processing.', 'give');
155 155
 			$notice_type    = 'warning';
156 156
 			break;
157 157
 		case 'refunded':
158
-			$notice_message = __( 'Payment Refunded: Your donation has been refunded.', 'give' );
158
+			$notice_message = __('Payment Refunded: Your donation has been refunded.', 'give');
159 159
 			$notice_type    = 'warning';
160 160
 			break;
161 161
 		case 'preapproval':
162
-			$notice_message = __( 'Payment Preapproved: Thank you for your donation.', 'give' );
162
+			$notice_message = __('Payment Preapproved: Thank you for your donation.', 'give');
163 163
 			$notice_type    = 'warning';
164 164
 			break;
165 165
 		case 'failed':
166
-			$notice_message = __( 'Payment Failed: Please contact the site owner for assistance.', 'give' );
166
+			$notice_message = __('Payment Failed: Please contact the site owner for assistance.', 'give');
167 167
 			$notice_type    = 'error';
168 168
 			break;
169 169
 		case 'cancelled':
170
-			$notice_message = __( 'Payment Cancelled: Your donation has been cancelled.', 'give' );
170
+			$notice_message = __('Payment Cancelled: Your donation has been cancelled.', 'give');
171 171
 			$notice_type    = 'error';
172 172
 			break;
173 173
 		case 'abandoned':
174
-			$notice_message = __( 'Payment Abandoned: This donation has not been completed.', 'give' );
174
+			$notice_message = __('Payment Abandoned: This donation has not been completed.', 'give');
175 175
 			$notice_type    = 'error';
176 176
 			break;
177 177
 		case 'revoked':
178
-			$notice_message = __( 'Payment Revoked: Please contact the site owner for assistance.', 'give' );
178
+			$notice_message = __('Payment Revoked: Please contact the site owner for assistance.', 'give');
179 179
 			$notice_type    = 'error';
180 180
 			break;
181 181
 	}
182 182
 
183
-	if ( ! empty( $notice_message ) ) {
183
+	if ( ! empty($notice_message)) {
184 184
 		/**
185 185
 		 * Filters payment status notice for receipts.
186 186
 		 *
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 		 * @param string $status Payment status.
196 196
 		 * @param array  $meta   Array of meta data related to the payment.
197 197
 		 */
198
-		echo apply_filters( 'give_receipt_status_notice', Give()->notices->print_frontend_notice( $notice_message, false, $notice_type ), $id, $status, $meta );
198
+		echo apply_filters('give_receipt_status_notice', Give()->notices->print_frontend_notice($notice_message, false, $notice_type), $id, $status, $meta);
199 199
 	}
200 200
 }// End if().
201 201
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
  * @param object $payment           The payment object.
210 210
  * @param array  $give_receipt_args Receipt_argument.
211 211
  */
212
-do_action( 'give_payment_receipt_before_table', $payment, $give_receipt_args );
212
+do_action('give_payment_receipt_before_table', $payment, $give_receipt_args);
213 213
 ?>
214 214
 
215 215
 <table id="give_donation_receipt" class="give-table">
@@ -225,11 +225,11 @@  discard block
 block discarded – undo
225 225
 	 * @param object $payment           The payment object.
226 226
 	 * @param array  $give_receipt_args Receipt_argument.
227 227
 	 */
228
-	do_action( 'give_payment_receipt_header_before', $payment, $give_receipt_args );
228
+	do_action('give_payment_receipt_header_before', $payment, $give_receipt_args);
229 229
 	?>
230 230
 	<tr>
231 231
 		<th scope="colgroup" colspan="2">
232
-			<span class="give-receipt-thead-text"><?php esc_html_e( 'Donation Receipt', 'give' ) ?></span>
232
+			<span class="give-receipt-thead-text"><?php esc_html_e('Donation Receipt', 'give') ?></span>
233 233
 		</th>
234 234
 	</tr>
235 235
 	<?php
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	 * @param object $payment           The payment object.
244 244
 	 * @param array  $give_receipt_args Receipt_argument.
245 245
 	 */
246
-	do_action( 'give_payment_receipt_header_after', $payment, $give_receipt_args );
246
+	do_action('give_payment_receipt_header_after', $payment, $give_receipt_args);
247 247
 	?>
248 248
 	</thead>
249 249
 
@@ -259,11 +259,11 @@  discard block
 block discarded – undo
259 259
 	 * @param object $payment           The payment object.
260 260
 	 * @param array  $give_receipt_args Receipt_argument.
261 261
 	 */
262
-	do_action( 'give_payment_receipt_before', $payment, $give_receipt_args );
262
+	do_action('give_payment_receipt_before', $payment, $give_receipt_args);
263 263
 	?>
264 264
 
265
-	<?php foreach ( $give_receipt_args['donation_receipt'] as $receipt_item ) { ?>
266
-		<?php if ( filter_var( $receipt_item['display'], FILTER_VALIDATE_BOOLEAN ) ) : ?>
265
+	<?php foreach ($give_receipt_args['donation_receipt'] as $receipt_item) { ?>
266
+		<?php if (filter_var($receipt_item['display'], FILTER_VALIDATE_BOOLEAN)) : ?>
267 267
 			<tr>
268 268
 				<td scope="row"><strong><?php echo $receipt_item['name']; ?></strong></td>
269 269
 				<td><?php echo $receipt_item['value']; ?></td>
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 	 * @param object $payment           The payment object.
283 283
 	 * @param array  $give_receipt_args Receipt_argument.
284 284
 	 */
285
-	do_action( 'give_payment_receipt_after', $payment, $give_receipt_args );
285
+	do_action('give_payment_receipt_after', $payment, $give_receipt_args);
286 286
 	?>
287 287
 	</tbody>
288 288
 </table>
@@ -298,5 +298,5 @@  discard block
 block discarded – undo
298 298
  * @param object $payment           The payment object.
299 299
  * @param array  $give_receipt_args Receipt_argument.
300 300
  */
301
-do_action( 'give_payment_receipt_after_table', $payment, $give_receipt_args );
301
+do_action('give_payment_receipt_after_table', $payment, $give_receipt_args);
302 302
 ?>
Please login to merge, or discard this patch.
uninstall.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -10,61 +10,61 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
13
+if ( ! defined('WP_UNINSTALL_PLUGIN')) {
14 14
 	exit;
15 15
 }
16 16
 
17 17
 // Load Give file.
18
-include_once( 'give.php' );
18
+include_once('give.php');
19 19
 
20 20
 global $wpdb, $wp_roles;
21 21
 
22 22
 
23
-if ( give_is_setting_enabled( give_get_option( 'uninstall_on_delete' ) ) ) {
23
+if (give_is_setting_enabled(give_get_option('uninstall_on_delete'))) {
24 24
 
25 25
 	// Delete All the Custom Post Types.
26
-	$give_taxonomies = array( 'form_category', 'form_tag' );
27
-	$give_post_types = array( 'give_forms', 'give_payment' );
28
-	foreach ( $give_post_types as $post_type ) {
26
+	$give_taxonomies = array('form_category', 'form_tag');
27
+	$give_post_types = array('give_forms', 'give_payment');
28
+	foreach ($give_post_types as $post_type) {
29 29
 
30
-		$give_taxonomies = array_merge( $give_taxonomies, get_object_taxonomies( $post_type ) );
31
-		$items           = get_posts( array(
30
+		$give_taxonomies = array_merge($give_taxonomies, get_object_taxonomies($post_type));
31
+		$items           = get_posts(array(
32 32
 			'post_type'   => $post_type,
33 33
 			'post_status' => 'any',
34
-			'numberposts' => - 1,
34
+			'numberposts' => -1,
35 35
 			'fields'      => 'ids',
36
-		) );
36
+		));
37 37
 
38
-		if ( $items ) {
39
-			foreach ( $items as $item ) {
40
-				wp_delete_post( $item, true );
38
+		if ($items) {
39
+			foreach ($items as $item) {
40
+				wp_delete_post($item, true);
41 41
 			}
42 42
 		}
43 43
 	}
44 44
 
45 45
 	// Delete All the Terms & Taxonomies.
46
-	foreach ( array_unique( array_filter( $give_taxonomies ) ) as $taxonomy ) {
46
+	foreach (array_unique(array_filter($give_taxonomies)) as $taxonomy) {
47 47
 
48
-		$terms = $wpdb->get_results( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s') ORDER BY t.name ASC", $taxonomy ) );
48
+		$terms = $wpdb->get_results($wpdb->prepare("SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s') ORDER BY t.name ASC", $taxonomy));
49 49
 
50 50
 		// Delete Terms.
51
-		if ( $terms ) {
52
-			foreach ( $terms as $term ) {
53
-				$wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => $term->term_taxonomy_id ) );
54
-				$wpdb->delete( $wpdb->terms, array( 'term_id' => $term->term_id ) );
51
+		if ($terms) {
52
+			foreach ($terms as $term) {
53
+				$wpdb->delete($wpdb->term_taxonomy, array('term_taxonomy_id' => $term->term_taxonomy_id));
54
+				$wpdb->delete($wpdb->terms, array('term_id' => $term->term_id));
55 55
 			}
56 56
 		}
57 57
 
58 58
 		// Delete Taxonomies.
59
-		$wpdb->delete( $wpdb->term_taxonomy, array( 'taxonomy' => $taxonomy ), array( '%s' ) );
59
+		$wpdb->delete($wpdb->term_taxonomy, array('taxonomy' => $taxonomy), array('%s'));
60 60
 	}
61 61
 
62 62
 	// Delete the Plugin Pages.
63
-	$give_created_pages = array( 'success_page', 'failure_page', 'history_page' );
64
-	foreach ( $give_created_pages as $p ) {
65
-		$page = give_get_option( $p, false );
66
-		if ( $page ) {
67
-			wp_delete_post( $page, true );
63
+	$give_created_pages = array('success_page', 'failure_page', 'history_page');
64
+	foreach ($give_created_pages as $p) {
65
+		$page = give_get_option($p, false);
66
+		if ($page) {
67
+			wp_delete_post($page, true);
68 68
 		}
69 69
 	}
70 70
 
@@ -73,26 +73,26 @@  discard block
 block discarded – undo
73 73
 	Give()->roles->remove_caps();
74 74
 
75 75
 	// Delete the Roles.
76
-	$give_roles = array( 'give_manager', 'give_accountant', 'give_worker', 'give_donor' );
77
-	foreach ( $give_roles as $role ) {
78
-		remove_role( $role );
76
+	$give_roles = array('give_manager', 'give_accountant', 'give_worker', 'give_donor');
77
+	foreach ($give_roles as $role) {
78
+		remove_role($role);
79 79
 	}
80 80
 
81 81
 	// Remove all database tables.
82
-	$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_donors' );
83
-	$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_donormeta' );
84
-	$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_customers' );
85
-	$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_customermeta' );
86
-	$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_paymentmeta' );
87
-	$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_formmeta' );
88
-	$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_logs' );
89
-	$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_logmeta' );
82
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_donors');
83
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_donormeta');
84
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_customers');
85
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_customermeta');
86
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_paymentmeta');
87
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_formmeta');
88
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_logs');
89
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_logmeta');
90 90
 
91 91
 	// Cleanup Cron Events.
92
-	wp_clear_scheduled_hook( 'give_daily_scheduled_events' );
93
-	wp_clear_scheduled_hook( 'give_weekly_scheduled_events' );
94
-	wp_clear_scheduled_hook( 'give_daily_cron' );
95
-	wp_clear_scheduled_hook( 'give_weekly_cron' );
92
+	wp_clear_scheduled_hook('give_daily_scheduled_events');
93
+	wp_clear_scheduled_hook('give_weekly_scheduled_events');
94
+	wp_clear_scheduled_hook('give_daily_cron');
95
+	wp_clear_scheduled_hook('give_weekly_cron');
96 96
 
97 97
 	// Get all options.
98 98
 	$give_option_names = $wpdb->get_col(
@@ -102,16 +102,16 @@  discard block
 block discarded – undo
102 102
 		)
103 103
 	);
104 104
 
105
-	if ( ! empty( $give_option_names ) ) {
105
+	if ( ! empty($give_option_names)) {
106 106
 		// Convert option name to transient or option name.
107 107
 		$new_give_option_names = array();
108 108
 
109 109
 		// Delete all the Plugin Options.
110
-		foreach ( $give_option_names as $option ) {
111
-			if ( false !== strpos( $option, 'give_cache' ) ) {
112
-				Give_Cache::delete( $option );
110
+		foreach ($give_option_names as $option) {
111
+			if (false !== strpos($option, 'give_cache')) {
112
+				Give_Cache::delete($option);
113 113
 			} else {
114
-				delete_option( $option );
114
+				delete_option($option);
115 115
 			}
116 116
 		}
117 117
 	}
Please login to merge, or discard this patch.
includes/admin/emails/class-new-donor-register-email.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if access directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
17
-if ( ! class_exists( 'Give_New_Donor_Register_Email' ) ) :
17
+if ( ! class_exists('Give_New_Donor_Register_Email')) :
18 18
 
19 19
 	/**
20 20
 	 * Give_New_Donor_Register_Email
@@ -31,34 +31,34 @@  discard block
 block discarded – undo
31 31
 		 * @since   2.0
32 32
 		 */
33 33
 		public function init() {
34
-			$this->load( array(
34
+			$this->load(array(
35 35
 				'id'                    => 'new-donor-register',
36
-				'label'                 => __( 'New User Registration', 'give' ),
37
-				'description'           => __( 'Sent to designated recipient(s) when a new user registers on the site via a donation form.', 'give' ),
36
+				'label'                 => __('New User Registration', 'give'),
37
+				'description'           => __('Sent to designated recipient(s) when a new user registers on the site via a donation form.', 'give'),
38 38
 				'has_recipient_field'   => true,
39 39
 				'notification_status'   => 'enabled',
40 40
 				'has_preview_header'    => true,
41
-				'email_tag_context'     => array( 'donor', 'general' ),
41
+				'email_tag_context'     => array('donor', 'general'),
42 42
 				'form_metabox_setting'  => false,
43 43
 				'default_email_subject' => sprintf(
44 44
 					/* translators: %s: site name */
45
-					esc_attr__( '[%s] New User Registration', 'give' ),
46
-					get_bloginfo( 'name' )
45
+					esc_attr__('[%s] New User Registration', 'give'),
46
+					get_bloginfo('name')
47 47
 				),
48 48
 				'default_email_message' => $this->get_default_email_message(),
49
-			) );
49
+			));
50 50
 
51 51
 			// Setup action hook.
52 52
 			add_action(
53 53
 				"give_{$this->config['id']}_email_notification",
54
-				array( $this, 'setup_email_notification' ),
54
+				array($this, 'setup_email_notification'),
55 55
 				10,
56 56
 				2
57 57
 			);
58 58
 
59 59
 			add_filter(
60 60
 				'give_email_preview_header',
61
-				array( $this, 'email_preview_header' ),
61
+				array($this, 'email_preview_header'),
62 62
 				10,
63 63
 				2
64 64
 			);
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
 		 * @return string
74 74
 		 */
75 75
 		function get_default_email_message() {
76
-			$message = esc_attr__( 'New user registration on your site {sitename}:', 'give' ) . "\r\n\r\n";
77
-			$message .= esc_attr__( 'Username: {username}', 'give' ) . "\r\n\r\n";
78
-			$message .= esc_attr__( 'Email: {user_email}', 'give' ) . "\r\n";
76
+			$message = esc_attr__('New user registration on your site {sitename}:', 'give')."\r\n\r\n";
77
+			$message .= esc_attr__('Username: {username}', 'give')."\r\n\r\n";
78
+			$message .= esc_attr__('Email: {user_email}', 'give')."\r\n";
79 79
 
80 80
 			/**
81 81
 			 * Filter the default email message
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 		 * @since 2.0
96 96
 		 */
97 97
 		public function setup_email_data() {
98
-			Give()->emails->__set( 'heading', esc_html__( 'New User Registration', 'give' ) );
98
+			Give()->emails->__set('heading', esc_html__('New User Registration', 'give'));
99 99
 		}
100 100
 
101 101
 
@@ -110,12 +110,12 @@  discard block
 block discarded – undo
110 110
 		 *
111 111
 		 * @return string
112 112
 		 */
113
-		public function setup_email_notification( $user_id, $user_data ) {
113
+		public function setup_email_notification($user_id, $user_data) {
114 114
 			$this->setup_email_data();
115 115
 
116
-			$this->send_email_notification( array(
116
+			$this->send_email_notification(array(
117 117
 				'user_id' => $user_id,
118
-			) );
118
+			));
119 119
 		}
120 120
 
121 121
 
@@ -129,42 +129,42 @@  discard block
 block discarded – undo
129 129
 		 * @param Give_New_Donor_Register_Email $email
130 130
 		 * @return string
131 131
 		 */
132
-		public function email_preview_header( $email_preview_header, $email ) {
132
+		public function email_preview_header($email_preview_header, $email) {
133 133
 			// Bailout.
134
-			if ( $this->config['id'] !== $email->config['id'] ) {
134
+			if ($this->config['id'] !== $email->config['id']) {
135 135
 				return $email_preview_header;
136 136
 			}
137 137
 
138 138
 			// Payment receipt switcher
139
-			$user_id = give_check_variable( give_clean( $_GET ), 'isset', 0, 'user_id' );
139
+			$user_id = give_check_variable(give_clean($_GET), 'isset', 0, 'user_id');
140 140
 
141 141
 			// Get payments.
142 142
 			$donors  = new Give_API();
143
-			$donors  = give_check_variable( $donors->get_donors(), 'empty', array(), 'donors' );
143
+			$donors  = give_check_variable($donors->get_donors(), 'empty', array(), 'donors');
144 144
 			$options = array();
145 145
 
146 146
 			// Default option.
147
-			$options[0] = esc_html__( 'No donor(s) found.', 'give' );
147
+			$options[0] = esc_html__('No donor(s) found.', 'give');
148 148
 
149 149
 			// Provide nice human readable options.
150
-			if ( $donors ) {
151
-				$options[0] = esc_html__( '- Select a donor -', 'give' );
152
-				foreach ( $donors as $donor ) {
150
+			if ($donors) {
151
+				$options[0] = esc_html__('- Select a donor -', 'give');
152
+				foreach ($donors as $donor) {
153 153
 					// Exclude customers for which wp user not exist.
154
-					if ( ! $donor['info']['user_id'] ) {
154
+					if ( ! $donor['info']['user_id']) {
155 155
 						continue;
156 156
 					}
157
-					$options[ $donor['info']['user_id'] ] = esc_html( '#' . $donor['info']['donor_id'] . ' - ' . $donor['info']['email'] );
157
+					$options[$donor['info']['user_id']] = esc_html('#'.$donor['info']['donor_id'].' - '.$donor['info']['email']);
158 158
 				}
159 159
 			}
160 160
 
161
-			$request_url_data = wp_parse_url( $_SERVER['REQUEST_URI'] );
161
+			$request_url_data = wp_parse_url($_SERVER['REQUEST_URI']);
162 162
 			$query            = $request_url_data['query'];
163 163
 
164 164
 			// Remove user id query param if set from request url.
165
-			$query = remove_query_arg( array( 'user_id' ), $query );
165
+			$query = remove_query_arg(array('user_id'), $query);
166 166
 
167
-			$request_url = home_url( '/?' . str_replace( '', '', $query ) );
167
+			$request_url = home_url('/?'.str_replace('', '', $query));
168 168
 			?>
169 169
 			<script type="text/javascript">
170 170
 				function change_preview() {
@@ -198,12 +198,12 @@  discard block
 block discarded – undo
198 198
 			<div class="give_preview_email_user_id_main">
199 199
 
200 200
 				<label for="give_preview_email_user_id" class="give_preview_email_user_id_label">
201
-					<?php echo esc_html__( 'Preview email with a donor:', 'give' ); ?>
201
+					<?php echo esc_html__('Preview email with a donor:', 'give'); ?>
202 202
 				</label>
203 203
 
204 204
 				<?php
205 205
 				// The select field with 100 latest transactions
206
-				echo Give()->html->select( array(
206
+				echo Give()->html->select(array(
207 207
 					'name'             => 'preview_email_user_id',
208 208
 					'selected'         => $user_id,
209 209
 					'id'               => 'give_preview_email_user_id',
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 					'select_atts'      => 'onchange="change_preview()"',
214 214
 					'show_option_all'  => false,
215 215
 					'show_option_none' => false,
216
-				) );
216
+				));
217 217
 				?>
218 218
 				<!-- Closing tag-->
219 219
 			</div>
Please login to merge, or discard this patch.
includes/class-give-db-logs.php 1 patch
Spacing   +71 added lines, -73 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 		/* @var WPDB $wpdb */
36 36
 		global $wpdb;
37 37
 
38
-		$this->table_name  = $wpdb->prefix . 'give_logs';
38
+		$this->table_name  = $wpdb->prefix.'give_logs';
39 39
 		$this->primary_key = 'ID';
40 40
 		$this->version     = '1.0';
41 41
 
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
 	 * @return array  Default column values.
74 74
 	 */
75 75
 	public function get_column_defaults() {
76
-		$log_create_date     = current_time( 'mysql', 0 );
77
-		$log_create_date_gmt = get_gmt_from_date( $log_create_date );
76
+		$log_create_date     = current_time('mysql', 0);
77
+		$log_create_date_gmt = get_gmt_from_date($log_create_date);
78 78
 
79 79
 		return array(
80 80
 			'ID'           => 0,
@@ -97,39 +97,39 @@  discard block
 block discarded – undo
97 97
 	 *
98 98
 	 * @return bool|int
99 99
 	 */
100
-	public function add( $data = array() ) {
100
+	public function add($data = array()) {
101 101
 		// Valid table columns.
102
-		$table_columns = array_keys( $this->get_columns() );
102
+		$table_columns = array_keys($this->get_columns());
103 103
 
104 104
 		// Filter data.
105
-		foreach ( $data as $table_column => $column_data ) {
106
-			if ( ! in_array( $table_column, $table_columns ) ) {
107
-				unset( $data[ $table_column ] );
105
+		foreach ($data as $table_column => $column_data) {
106
+			if ( ! in_array($table_column, $table_columns)) {
107
+				unset($data[$table_column]);
108 108
 			}
109 109
 		}
110 110
 
111 111
 		// Set default values.
112
-		$current_log_data = wp_parse_args( $data, $this->get_column_defaults() );
112
+		$current_log_data = wp_parse_args($data, $this->get_column_defaults());
113 113
 
114 114
 		// Log parent should be an int.
115
-		$current_log_data['log_parent'] = absint( $current_log_data['log_parent'] );
115
+		$current_log_data['log_parent'] = absint($current_log_data['log_parent']);
116 116
 
117 117
 		// Get log.
118
-		$existing_log = $this->get_log_by( $current_log_data['ID'] );
118
+		$existing_log = $this->get_log_by($current_log_data['ID']);
119 119
 
120 120
 		// Update an existing log.
121
-		if ( $existing_log ) {
121
+		if ($existing_log) {
122 122
 
123 123
 			// Create new log data from existing and new log data.
124
-			$current_log_data = array_merge( $current_log_data, $existing_log );
124
+			$current_log_data = array_merge($current_log_data, $existing_log);
125 125
 
126 126
 			// Update log data.
127
-			$this->update( $current_log_data['ID'], $current_log_data );
127
+			$this->update($current_log_data['ID'], $current_log_data);
128 128
 
129 129
 			$log_id = $current_log_data['ID'];
130 130
 
131 131
 		} else {
132
-			$log_id = $this->insert( $current_log_data, 'log' );
132
+			$log_id = $this->insert($current_log_data, 'log');
133 133
 		}
134 134
 
135 135
 		return $log_id;
@@ -147,20 +147,20 @@  discard block
 block discarded – undo
147 147
 	 *
148 148
 	 * @return bool|null|array
149 149
 	 */
150
-	public function get_log_by( $log_id = 0, $by = 'id' ) {
150
+	public function get_log_by($log_id = 0, $by = 'id') {
151 151
 		/* @var WPDB $wpdb */
152 152
 		global $wpdb;
153 153
 		$log = null;
154 154
 
155 155
 		// Make sure $log_id is int.
156
-		$log_id = absint( $log_id );
156
+		$log_id = absint($log_id);
157 157
 
158 158
 		// Bailout.
159
-		if ( empty( $log_id ) ) {
159
+		if (empty($log_id)) {
160 160
 			return null;
161 161
 		}
162 162
 
163
-		switch ( $by ) {
163
+		switch ($by) {
164 164
 			case 'id':
165 165
 				$log = $wpdb->get_row(
166 166
 					$wpdb->prepare(
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 				break;
173 173
 
174 174
 			default:
175
-				$log = apply_filters( "give_get_log_by_{$by}", $log, $log_id );
175
+				$log = apply_filters("give_get_log_by_{$by}", $log, $log_id);
176 176
 		}
177 177
 
178 178
 		return $log;
@@ -188,14 +188,14 @@  discard block
 block discarded – undo
188 188
 	 *
189 189
 	 * @return mixed
190 190
 	 */
191
-	public function get_logs( $args = array() ) {
191
+	public function get_logs($args = array()) {
192 192
 		global $wpdb;
193
-		$sql_query = $this->get_sql( $args );
193
+		$sql_query = $this->get_sql($args);
194 194
 		
195 195
 		// Get log.
196
-		if ( ! ( $logs = Give_Cache::get( 'give_logs', true, $sql_query ) ) ) {
197
-			$logs = $wpdb->get_results( $sql_query );
198
-			Give_Cache::set( 'give_logs', $logs, 3600, true, $sql_query );
196
+		if ( ! ($logs = Give_Cache::get('give_logs', true, $sql_query))) {
197
+			$logs = $wpdb->get_results($sql_query);
198
+			Give_Cache::set('give_logs', $logs, 3600, true, $sql_query);
199 199
 		}
200 200
 
201 201
 		return $logs;
@@ -212,21 +212,21 @@  discard block
 block discarded – undo
212 212
 	 *
213 213
 	 * @return int
214 214
 	 */
215
-	public function count( $args = array() ) {
215
+	public function count($args = array()) {
216 216
 		/* @var WPDB $wpdb */
217 217
 		global $wpdb;
218 218
 		$args['number'] = - 1;
219 219
 		$args['fields'] = 'ID';
220 220
 		$args['count']  = true;
221 221
 
222
-		$sql_query = $this->get_sql( $args );
222
+		$sql_query = $this->get_sql($args);
223 223
 
224
-		if ( ! ( $count = Give_Cache::get( 'give_logs_count', true, $sql_query ) ) ) {
225
-			$count = $wpdb->get_var( $sql_query );
226
-			Give_Cache::set( 'give_logs_count', $count, 3600, true, $args );
224
+		if ( ! ($count = Give_Cache::get('give_logs_count', true, $sql_query))) {
225
+			$count = $wpdb->get_var($sql_query);
226
+			Give_Cache::set('give_logs_count', $count, 3600, true, $args);
227 227
 		}
228 228
 		
229
-		return absint( $count );
229
+		return absint($count);
230 230
 	}
231 231
 
232 232
 	/**
@@ -252,10 +252,10 @@  discard block
 block discarded – undo
252 252
         PRIMARY KEY  (ID)
253 253
         ) {$charset_collate};";
254 254
 
255
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
256
-		dbDelta( $sql );
255
+		require_once(ABSPATH.'wp-admin/includes/upgrade.php');
256
+		dbDelta($sql);
257 257
 
258
-		update_option( $this->table_name . '_db_version', $this->version );
258
+		update_option($this->table_name.'_db_version', $this->version);
259 259
 	}
260 260
 
261 261
 
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	 *
270 270
 	 * @return string
271 271
 	 */
272
-	public function get_sql( $args = array() ) {
272
+	public function get_sql($args = array()) {
273 273
 		/* @var WPDB $wpdb */
274 274
 		global $wpdb;
275 275
 
@@ -283,12 +283,12 @@  discard block
 block discarded – undo
283 283
 			'count'   => false,
284 284
 		);
285 285
 
286
-		$args = wp_parse_args( $args, $defaults );
286
+		$args = wp_parse_args($args, $defaults);
287 287
 
288 288
 		// validate params.
289
-		$this->validate_params( $args );
289
+		$this->validate_params($args);
290 290
 
291
-		if ( $args['number'] < 1 ) {
291
+		if ($args['number'] < 1) {
292 292
 			$args['number'] = 99999999999;
293 293
 		}
294 294
 
@@ -296,78 +296,78 @@  discard block
 block discarded – undo
296 296
 		$where = '';
297 297
 
298 298
 		// Get sql query for meta.
299
-		if ( ! empty( $args['meta_query'] ) ) {
300
-			$meta_query_object = new WP_Meta_Query( $args['meta_query'] );
301
-			$meta_query        = $meta_query_object->get_sql( 'log', $this->table_name, 'id' );
302
-			$where             = implode( '', $meta_query );
299
+		if ( ! empty($args['meta_query'])) {
300
+			$meta_query_object = new WP_Meta_Query($args['meta_query']);
301
+			$meta_query        = $meta_query_object->get_sql('log', $this->table_name, 'id');
302
+			$where             = implode('', $meta_query);
303 303
 		}
304 304
 
305 305
 		$where .= ' WHERE 1=1 ';
306 306
 
307 307
 		// Set offset.
308
-		if ( empty( $args['offset'] ) && ( 0 < $args['paged'] ) ) {
309
-			$args['offset'] = $args['number'] * ( $args['paged'] - 1 );
308
+		if (empty($args['offset']) && (0 < $args['paged'])) {
309
+			$args['offset'] = $args['number'] * ($args['paged'] - 1);
310 310
 		}
311 311
 
312 312
 		// Set fields.
313 313
 		$fields = "{$this->table_name}.*";
314
-		if ( is_string( $args['fields'] ) && ( 'all' !== $args['fields'] ) ) {
314
+		if (is_string($args['fields']) && ('all' !== $args['fields'])) {
315 315
 			$fields = "{$this->table_name}.{$args['fields']}";
316 316
 		}
317 317
 
318 318
 		// Set count.
319
-		if ( $args['count'] ) {
319
+		if ($args['count']) {
320 320
 			$fields = "COUNT({$fields})";
321 321
 		}
322 322
 
323 323
 		// Specific logs.
324
-		if ( ! empty( $args['ID'] ) ) {
324
+		if ( ! empty($args['ID'])) {
325 325
 
326
-			if ( ! is_array( $args['ID'] ) ) {
327
-				$args['ID'] = explode( ',', $args['ID'] );
326
+			if ( ! is_array($args['ID'])) {
327
+				$args['ID'] = explode(',', $args['ID']);
328 328
 			}
329
-			$log_ids = implode( ',', array_map( 'intval', $args['ID'] ) );
329
+			$log_ids = implode(',', array_map('intval', $args['ID']));
330 330
 
331 331
 			$where .= " AND {$this->table_name}.ID IN( {$log_ids} ) ";
332 332
 		}
333 333
 
334 334
 		// Logs created for a specific date or in a date range
335
-		if ( ! empty( $args['date_query'] ) ) {
336
-			$date_query_object = new WP_Date_Query( $args['date_query'], "{$this->table_name}.log_date" );
337
-			$where             .= $date_query_object->get_sql();
335
+		if ( ! empty($args['date_query'])) {
336
+			$date_query_object = new WP_Date_Query($args['date_query'], "{$this->table_name}.log_date");
337
+			$where .= $date_query_object->get_sql();
338 338
 		}
339 339
 
340 340
 		// Logs create for specific parent.
341
-		if ( ! empty( $args['log_parent'] ) ) {
342
-			if ( ! is_array( $args['log_parent'] ) ) {
343
-				$args['log_parent'] = explode( ',', $args['log_parent'] );
341
+		if ( ! empty($args['log_parent'])) {
342
+			if ( ! is_array($args['log_parent'])) {
343
+				$args['log_parent'] = explode(',', $args['log_parent']);
344 344
 			}
345
-			$parent_ids = implode( ',', array_map( 'intval', $args['log_parent'] ) );
345
+			$parent_ids = implode(',', array_map('intval', $args['log_parent']));
346 346
 
347 347
 			$where .= " AND {$this->table_name}.log_parent IN( {$parent_ids} ) ";
348 348
 		}
349 349
 
350 350
 		// Logs create for specific type.
351 351
 		// is_array check is for backward compatibility.
352
-		if ( ! empty( $args['log_type'] ) && ! is_array( $args['log_type'] ) ) {
353
-			if ( ! is_array( $args['log_type'] ) ) {
354
-				$args['log_type'] = explode( ',', $args['log_type'] );
352
+		if ( ! empty($args['log_type']) && ! is_array($args['log_type'])) {
353
+			if ( ! is_array($args['log_type'])) {
354
+				$args['log_type'] = explode(',', $args['log_type']);
355 355
 			}
356 356
 
357
-			$log_types = implode( '\',\'', array_map( 'trim', $args['log_type'] ) );
357
+			$log_types = implode('\',\'', array_map('trim', $args['log_type']));
358 358
 
359 359
 			$where .= " AND {$this->table_name}.log_type IN( '{$log_types}' ) ";
360 360
 		}
361 361
 
362
-		$args['orderby'] = ! array_key_exists( $args['orderby'], $this->get_columns() ) ? 'log_date' : $args['orderby'];
362
+		$args['orderby'] = ! array_key_exists($args['orderby'], $this->get_columns()) ? 'log_date' : $args['orderby'];
363 363
 
364
-		$args['orderby'] = esc_sql( $args['orderby'] );
365
-		$args['order']   = esc_sql( $args['order'] );
364
+		$args['orderby'] = esc_sql($args['orderby']);
365
+		$args['order']   = esc_sql($args['order']);
366 366
 
367 367
 		return $wpdb->prepare(
368 368
 			"SELECT {$fields} FROM {$this->table_name} {$where} ORDER BY {$this->table_name}.{$args['orderby']} {$args['order']} LIMIT %d,%d;",
369
-			absint( $args['offset'] ),
370
-			absint( $args['number'] )
369
+			absint($args['offset']),
370
+			absint($args['number'])
371 371
 		);
372 372
 	}
373 373
 
@@ -382,13 +382,11 @@  discard block
 block discarded – undo
382 382
 	 *
383 383
 	 * @return mixed
384 384
 	 */
385
-	private function validate_params( &$args ) {
385
+	private function validate_params(&$args) {
386 386
 		// fields params
387 387
 		$args['fields'] = 'ids' === $args['fields'] ?
388
-			'ID' :
389
-			$args['fields'];
390
-		$args['fields'] = array_key_exists( $args['fields'], $this->get_columns() ) ?
391
-			$args['fields'] :
392
-			'all';
388
+			'ID' : $args['fields'];
389
+		$args['fields'] = array_key_exists($args['fields'], $this->get_columns()) ?
390
+			$args['fields'] : 'all';
393 391
 	}
394 392
 }
Please login to merge, or discard this patch.
includes/donors/class-give-donors-query.php 1 patch
Spacing   +53 added lines, -54 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
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	 *
87 87
 	 * @param  $args array The array of arguments that can be passed in and used for setting up this payment query.
88 88
 	 */
89
-	public function __construct( $args = array() ) {
89
+	public function __construct($args = array()) {
90 90
 		$defaults = array(
91 91
 			'number'     => 20,
92 92
 			'offset'     => 0,
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 			// 'form'       => array(),
105 105
 		);
106 106
 
107
-		$this->args = wp_parse_args( $args, $defaults );
107
+		$this->args = wp_parse_args($args, $defaults);
108 108
 		$this->table_name      = Give()->donors->table_name;
109 109
 		$this->meta_table_name = Give()->donor_meta->table_name;
110 110
 		$this->meta_type       = Give()->donor_meta->meta_type;
@@ -146,21 +146,21 @@  discard block
 block discarded – undo
146 146
 		 *
147 147
 		 * @param Give_Donors_Query $this Donors query object.
148 148
 		 */
149
-		do_action( 'give_pre_get_donors', $this );
149
+		do_action('give_pre_get_donors', $this);
150 150
 
151
-		$cache_key        = Give_Cache::get_key( 'give_donor', $this->get_sql(), false );
151
+		$cache_key = Give_Cache::get_key('give_donor', $this->get_sql(), false);
152 152
 
153 153
 		// Get donors from cache.
154
-		$this->donors = Give_Cache::get_db_query( $cache_key );
154
+		$this->donors = Give_Cache::get_db_query($cache_key);
155 155
 
156
-		if ( is_null( $this->donors  ) ) {
157
-			if ( empty( $this->args['count'] ) ) {
158
-				$this->donors = $wpdb->get_results( $this->get_sql() );
156
+		if (is_null($this->donors)) {
157
+			if (empty($this->args['count'])) {
158
+				$this->donors = $wpdb->get_results($this->get_sql());
159 159
 			} else {
160
-				$this->donors = $wpdb->get_var( $this->get_sql() );
160
+				$this->donors = $wpdb->get_var($this->get_sql());
161 161
 			}
162 162
 
163
-			Give_Cache::set_db_query( $cache_key, $this->donors );
163
+			Give_Cache::set_db_query($cache_key, $this->donors);
164 164
 		}
165 165
 
166 166
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 		 *
172 172
 		 * @param Give_Donors_Query $this Donors query object.
173 173
 		 */
174
-		do_action( 'give_post_get_donors', $this );
174
+		do_action('give_post_get_donors', $this);
175 175
 
176 176
 		return $this->donors;
177 177
 	}
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	public function get_sql() {
189 189
 		global $wpdb;
190 190
 
191
-		if ( $this->args['number'] < 1 ) {
191
+		if ($this->args['number'] < 1) {
192 192
 			$this->args['number'] = 99999999999;
193 193
 		}
194 194
 
@@ -196,22 +196,22 @@  discard block
 block discarded – undo
196 196
 
197 197
 
198 198
 		// Set offset.
199
-		if ( empty( $this->args['offset'] ) && ( 0 < $this->args['paged'] ) ) {
200
-			$this->args['offset'] = $this->args['number'] * ( $this->args['paged'] - 1 );
199
+		if (empty($this->args['offset']) && (0 < $this->args['paged'])) {
200
+			$this->args['offset'] = $this->args['number'] * ($this->args['paged'] - 1);
201 201
 		}
202 202
 
203 203
 		// Set fields.
204 204
 		$fields = "{$this->table_name}.*";
205
-		if ( ! empty( $this->args['fields'] ) && 'all' !== $this->args['fields'] ) {
206
-			if ( is_string( $this->args['fields'] ) ) {
205
+		if ( ! empty($this->args['fields']) && 'all' !== $this->args['fields']) {
206
+			if (is_string($this->args['fields'])) {
207 207
 				$fields = "{$this->table_name}.{$this->args['fields']}";
208
-			} elseif ( is_array( $this->args['fields'] ) ) {
209
-				$fields = "{$this->table_name}." . implode( " , {$this->table_name}.", $this->args['fields'] );
208
+			} elseif (is_array($this->args['fields'])) {
209
+				$fields = "{$this->table_name}.".implode(" , {$this->table_name}.", $this->args['fields']);
210 210
 			}
211 211
 		}
212 212
 
213 213
 		// Set count.
214
-		if ( ! empty( $this->args['count'] ) ) {
214
+		if ( ! empty($this->args['count'])) {
215 215
 			$fields = "COUNT({$this->table_name}.id)";
216 216
 		}
217 217
 
@@ -219,13 +219,13 @@  discard block
 block discarded – undo
219 219
 
220 220
 		$sql = $wpdb->prepare(
221 221
 			"SELECT {$fields} FROM {$this->table_name} LIMIT %d,%d;",
222
-			absint( $this->args['offset'] ),
223
-			absint( $this->args['number'] )
222
+			absint($this->args['offset']),
223
+			absint($this->args['number'])
224 224
 		);
225 225
 
226 226
 		// $where, $orderby and order already prepared query they can generate notice if you re prepare them in above.
227 227
 		// WordPress consider LIKE condition as placeholder if start with s,f, or d.
228
-		$sql = str_replace( 'LIMIT', "{$where} {$orderby} {$this->args['order']} LIMIT", $sql );
228
+		$sql = str_replace('LIMIT', "{$where} {$orderby} {$this->args['order']} LIMIT", $sql);
229 229
 
230 230
 		return $sql;
231 231
 	}
@@ -243,15 +243,15 @@  discard block
 block discarded – undo
243 243
 		$where = '';
244 244
 
245 245
 		// Get sql query for meta.
246
-		if ( ! empty( $this->args['meta_query'] ) ) {
247
-			$meta_query_object = new WP_Meta_Query( $this->args['meta_query'] );
246
+		if ( ! empty($this->args['meta_query'])) {
247
+			$meta_query_object = new WP_Meta_Query($this->args['meta_query']);
248 248
 			$meta_query        = $meta_query_object->get_sql(
249 249
 				$this->meta_type,
250 250
 				$this->table_name,
251 251
 				'id'
252 252
 			);
253 253
 
254
-			$where = implode( '', $meta_query );
254
+			$where = implode('', $meta_query);
255 255
 		}
256 256
 
257 257
 		$where .= 'WHERE 1=1 ';
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 		$where .= $this->get_where_user();
262 262
 		$where .= $this->get_where_date();
263 263
 
264
-		return trim( $where );
264
+		return trim($where);
265 265
 		
266 266
 	}
267 267
 
@@ -279,17 +279,17 @@  discard block
 block discarded – undo
279 279
 
280 280
 		$where = '';
281 281
 
282
-		if ( ! empty( $this->args['email'] ) ) {
282
+		if ( ! empty($this->args['email'])) {
283 283
 
284
-			if ( is_array( $this->args['email'] ) ) {
284
+			if (is_array($this->args['email'])) {
285 285
 
286
-				$emails_count       = count( $this->args['email'] );
287
-				$emails_placeholder = array_fill( 0, $emails_count, '%s' );
288
-				$emails             = implode( ', ', $emails_placeholder );
286
+				$emails_count       = count($this->args['email']);
287
+				$emails_placeholder = array_fill(0, $emails_count, '%s');
288
+				$emails             = implode(', ', $emails_placeholder);
289 289
 
290
-				$where .= $wpdb->prepare( "AND {$this->table_name}.email IN( $emails )", $this->args['email'] );
290
+				$where .= $wpdb->prepare("AND {$this->table_name}.email IN( $emails )", $this->args['email']);
291 291
 			} else {
292
-				$where .= $wpdb->prepare( "AND {$this->table_name}.email = %s", $this->args['email'] );
292
+				$where .= $wpdb->prepare("AND {$this->table_name}.email = %s", $this->args['email']);
293 293
 			}
294 294
 		}
295 295
 
@@ -309,11 +309,11 @@  discard block
 block discarded – undo
309 309
 		$where = '';
310 310
 
311 311
 		// Specific donors.
312
-		if ( ! empty( $this->args['donor'] ) ) {
313
-			if ( ! is_array( $this->args['donor'] ) ) {
314
-				$this->args['donor'] = explode( ',', $this->args['donor'] );
312
+		if ( ! empty($this->args['donor'])) {
313
+			if ( ! is_array($this->args['donor'])) {
314
+				$this->args['donor'] = explode(',', $this->args['donor']);
315 315
 			}
316
-			$donor_ids = implode( ',', array_map( 'intval', $this->args['donor'] ) );
316
+			$donor_ids = implode(',', array_map('intval', $this->args['donor']));
317 317
 
318 318
 			$where .= "AND {$this->table_name}.id IN( {$donor_ids} )";
319 319
 		}
@@ -334,9 +334,9 @@  discard block
 block discarded – undo
334 334
 		$where = '';
335 335
 
336 336
 		// Donors created for a specific date or in a date range
337
-		if ( ! empty( $this->args['date_query'] ) ) {
337
+		if ( ! empty($this->args['date_query'])) {
338 338
 			$date_query_object = new WP_Date_Query(
339
-				is_array( $this->args['date_query'] ) ? $this->args['date_query'] : wp_parse_args( $this->args['date_query'] ),
339
+				is_array($this->args['date_query']) ? $this->args['date_query'] : wp_parse_args($this->args['date_query']),
340 340
 				"{$this->table_name}.date_created"
341 341
 			);
342 342
 
@@ -371,11 +371,11 @@  discard block
 block discarded – undo
371 371
 		$where = '';
372 372
 
373 373
 		// Donors created for a specific date or in a date range
374
-		if ( ! empty( $this->args['s'] ) && false !== strpos( $this->args['s'], ':' ) ) {
375
-			$search_parts = explode( ':', $this->args['s'] );
374
+		if ( ! empty($this->args['s']) && false !== strpos($this->args['s'], ':')) {
375
+			$search_parts = explode(':', $this->args['s']);
376 376
 
377
-			if ( ! empty( $search_parts[0] ) ) {
378
-				switch ( $search_parts[0] ) {
377
+			if ( ! empty($search_parts[0])) {
378
+				switch ($search_parts[0]) {
379 379
 					case 'name':
380 380
 						$where = "AND {$this->table_name}.name LIKE '%{$search_parts[1]}%'";
381 381
 						break;
@@ -403,11 +403,11 @@  discard block
 block discarded – undo
403 403
 		$where = '';
404 404
 
405 405
 		// Donors create for specific wp user.
406
-		if ( ! empty( $this->args['user'] ) ) {
407
-			if ( ! is_array( $this->args['user'] ) ) {
408
-				$this->args['user'] = explode( ',', $this->args['user'] );
406
+		if ( ! empty($this->args['user'])) {
407
+			if ( ! is_array($this->args['user'])) {
408
+				$this->args['user'] = explode(',', $this->args['user']);
409 409
 			}
410
-			$user_ids = implode( ',', array_map( 'intval', $this->args['user'] ) );
410
+			$user_ids = implode(',', array_map('intval', $this->args['user']));
411 411
 
412 412
 			$where .= "AND {$this->table_name}.user_id IN( {$user_ids} )";
413 413
 		}
@@ -426,14 +426,13 @@  discard block
 block discarded – undo
426 426
 	private function get_order_query() {
427 427
 		$table_columns = Give()->donors->get_columns();
428 428
 
429
-		$this->args['orderby'] = ! array_key_exists( $this->args['orderby'], $table_columns ) ?
430
-			'id' :
431
-			$this->args['orderby'];
429
+		$this->args['orderby'] = ! array_key_exists($this->args['orderby'], $table_columns) ?
430
+			'id' : $this->args['orderby'];
432 431
 
433
-		$this->args['orderby'] = esc_sql( $this->args['orderby'] );
434
-		$this->args['order']   = esc_sql( $this->args['order'] );
432
+		$this->args['orderby'] = esc_sql($this->args['orderby']);
433
+		$this->args['order']   = esc_sql($this->args['order']);
435 434
 
436
-		switch ( $table_columns[ $this->args['orderby'] ] ) {
435
+		switch ($table_columns[$this->args['orderby']]) {
437 436
 			case '%d':
438 437
 			case '%f':
439 438
 				$query = "ORDER BY {$this->table_name}.{$this->args['orderby']}+0";
Please login to merge, or discard this patch.
includes/payments/functions.php 2 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
  *
566 566
  * @since 1.0
567 567
  *
568
- * @return int $earnings Earnings
568
+ * @return double $earnings Earnings
569 569
  */
570 570
 function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) {
571 571
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead.
@@ -864,7 +864,7 @@  discard block
 block discarded – undo
864 864
  *
865 865
  * @since 1.0
866 866
  *
867
- * @return array $user_info User Info Meta Values.
867
+ * @return string $user_info User Info Meta Values.
868 868
  */
869 869
 function give_get_payment_meta_user_info( $payment_id ) {
870 870
 	$payment = new Give_Payment( $payment_id );
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
  *
882 882
  * @since 1.0
883 883
  *
884
- * @return int $form_id Form ID.
884
+ * @return string $form_id Form ID.
885 885
  */
886 886
 function give_get_payment_form_id( $payment_id ) {
887 887
 	$payment = new Give_Payment( $payment_id );
@@ -1729,7 +1729,7 @@  discard block
 block discarded – undo
1729 1729
  *
1730 1730
  * Retrieves the form title and appends the level name if present.
1731 1731
  *
1732
- * @param int|Give_Payment $donation Donation Data Object.
1732
+ * @param Give_Payment $donation Donation Data Object.
1733 1733
  * @param array            $args     a. only_level = If set to true will only return the level name if multi-level enabled.
1734 1734
  *                                   b. separator  = The separator between the Form Title and the Donation Level.
1735 1735
  *
Please login to merge, or discard this patch.
Spacing   +381 added lines, -383 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -44,15 +44,15 @@  discard block
 block discarded – undo
44 44
  *
45 45
  * @return array $payments Payments retrieved from the database
46 46
  */
47
-function give_get_payments( $args = array() ) {
47
+function give_get_payments($args = array()) {
48 48
 
49 49
 	// Fallback to post objects to ensure backwards compatibility.
50
-	if ( ! isset( $args['output'] ) ) {
50
+	if ( ! isset($args['output'])) {
51 51
 		$args['output'] = 'posts';
52 52
 	}
53 53
 
54
-	$args     = apply_filters( 'give_get_payments_args', $args );
55
-	$payments = new Give_Payments_Query( $args );
54
+	$args     = apply_filters('give_get_payments_args', $args);
55
+	$payments = new Give_Payments_Query($args);
56 56
 
57 57
 	return $payments->get_payments();
58 58
 }
@@ -67,48 +67,48 @@  discard block
 block discarded – undo
67 67
  *
68 68
  * @return mixed
69 69
  */
70
-function give_get_payment_by( $field = '', $value = '' ) {
70
+function give_get_payment_by($field = '', $value = '') {
71 71
 
72
-	if ( empty( $field ) || empty( $value ) ) {
72
+	if (empty($field) || empty($value)) {
73 73
 		return false;
74 74
 	}
75 75
 
76
-	switch ( strtolower( $field ) ) {
76
+	switch (strtolower($field)) {
77 77
 
78 78
 		case 'id':
79
-			$payment = new Give_Payment( $value );
79
+			$payment = new Give_Payment($value);
80 80
 			$id      = $payment->ID;
81 81
 
82
-			if ( empty( $id ) ) {
82
+			if (empty($id)) {
83 83
 				return false;
84 84
 			}
85 85
 
86 86
 			break;
87 87
 
88 88
 		case 'key':
89
-			$payment = give_get_payments( array(
89
+			$payment = give_get_payments(array(
90 90
 				'meta_key'       => '_give_payment_purchase_key',
91 91
 				'meta_value'     => $value,
92 92
 				'posts_per_page' => 1,
93 93
 				'fields'         => 'ids',
94
-			) );
94
+			));
95 95
 
96
-			if ( $payment ) {
97
-				$payment = new Give_Payment( $payment[0] );
96
+			if ($payment) {
97
+				$payment = new Give_Payment($payment[0]);
98 98
 			}
99 99
 
100 100
 			break;
101 101
 
102 102
 		case 'payment_number':
103
-			$payment = give_get_payments( array(
103
+			$payment = give_get_payments(array(
104 104
 				'meta_key'       => '_give_payment_number',
105 105
 				'meta_value'     => $value,
106 106
 				'posts_per_page' => 1,
107 107
 				'fields'         => 'ids',
108
-			) );
108
+			));
109 109
 
110
-			if ( $payment ) {
111
-				$payment = new Give_Payment( $payment[0] );
110
+			if ($payment) {
111
+				$payment = new Give_Payment($payment[0]);
112 112
 			}
113 113
 
114 114
 			break;
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 			return false;
118 118
 	}// End switch().
119 119
 
120
-	if ( $payment ) {
120
+	if ($payment) {
121 121
 		return $payment;
122 122
 	}
123 123
 
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
  *
134 134
  * @return int|bool Payment ID if payment is inserted, false otherwise.
135 135
  */
136
-function give_insert_payment( $payment_data = array() ) {
136
+function give_insert_payment($payment_data = array()) {
137 137
 
138
-	if ( empty( $payment_data ) ) {
138
+	if (empty($payment_data)) {
139 139
 		return false;
140 140
 	}
141 141
 
@@ -146,25 +146,25 @@  discard block
 block discarded – undo
146 146
 	 *
147 147
 	 * @param array $payment_data Arguments passed.
148 148
 	 */
149
-	$payment_data = apply_filters( 'give_pre_insert_payment', $payment_data );
149
+	$payment_data = apply_filters('give_pre_insert_payment', $payment_data);
150 150
 
151 151
 	$payment    = new Give_Payment();
152
-	$gateway    = ! empty( $payment_data['gateway'] ) ? $payment_data['gateway'] : '';
153
-	$gateway    = empty( $gateway ) && isset( $_POST['give-gateway'] ) ? $_POST['give-gateway'] : $gateway;
154
-	$form_id    = isset( $payment_data['give_form_id'] ) ? $payment_data['give_form_id'] : 0;
155
-	$price_id   = give_get_payment_meta_price_id( $payment_data );
156
-	$form_title = isset( $payment_data['give_form_title'] ) ? $payment_data['give_form_title'] : get_the_title( $form_id );
152
+	$gateway    = ! empty($payment_data['gateway']) ? $payment_data['gateway'] : '';
153
+	$gateway    = empty($gateway) && isset($_POST['give-gateway']) ? $_POST['give-gateway'] : $gateway;
154
+	$form_id    = isset($payment_data['give_form_id']) ? $payment_data['give_form_id'] : 0;
155
+	$price_id   = give_get_payment_meta_price_id($payment_data);
156
+	$form_title = isset($payment_data['give_form_title']) ? $payment_data['give_form_title'] : get_the_title($form_id);
157 157
 
158 158
 	// Set properties.
159 159
 	$payment->total          = $payment_data['price'];
160
-	$payment->status         = ! empty( $payment_data['status'] ) ? $payment_data['status'] : 'pending';
161
-	$payment->currency       = ! empty( $payment_data['currency'] ) ? $payment_data['currency'] : give_get_currency( $payment_data['give_form_id'], $payment_data );
160
+	$payment->status         = ! empty($payment_data['status']) ? $payment_data['status'] : 'pending';
161
+	$payment->currency       = ! empty($payment_data['currency']) ? $payment_data['currency'] : give_get_currency($payment_data['give_form_id'], $payment_data);
162 162
 	$payment->user_info      = $payment_data['user_info'];
163 163
 	$payment->gateway        = $gateway;
164 164
 	$payment->form_title     = $form_title;
165 165
 	$payment->form_id        = $form_id;
166 166
 	$payment->price_id       = $price_id;
167
-	$payment->donor_id       = ( ! empty( $payment_data['donor_id'] ) ? $payment_data['donor_id'] : '' );
167
+	$payment->donor_id       = ( ! empty($payment_data['donor_id']) ? $payment_data['donor_id'] : '');
168 168
 	$payment->user_id        = $payment_data['user_info']['id'];
169 169
 	$payment->email          = $payment_data['user_email'];
170 170
 	$payment->first_name     = $payment_data['user_info']['first_name'];
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
 	$payment->email          = $payment_data['user_info']['email'];
173 173
 	$payment->ip             = give_get_ip();
174 174
 	$payment->key            = $payment_data['purchase_key'];
175
-	$payment->mode           = ( ! empty( $payment_data['mode'] ) ? (string) $payment_data['mode'] : ( give_is_test_mode() ? 'test' : 'live' ) );
176
-	$payment->parent_payment = ! empty( $payment_data['parent'] ) ? absint( $payment_data['parent'] ) : '';
175
+	$payment->mode           = ( ! empty($payment_data['mode']) ? (string) $payment_data['mode'] : (give_is_test_mode() ? 'test' : 'live'));
176
+	$payment->parent_payment = ! empty($payment_data['parent']) ? absint($payment_data['parent']) : '';
177 177
 
178 178
 	// Add the donation.
179 179
 	$args = array(
@@ -181,19 +181,19 @@  discard block
 block discarded – undo
181 181
 		'price_id' => $payment->price_id,
182 182
 	);
183 183
 
184
-	$payment->add_donation( $payment->form_id, $args );
184
+	$payment->add_donation($payment->form_id, $args);
185 185
 
186 186
 
187 187
 	// Set date if present.
188
-	if ( isset( $payment_data['post_date'] ) ) {
188
+	if (isset($payment_data['post_date'])) {
189 189
 		$payment->date = $payment_data['post_date'];
190 190
 	}
191 191
 
192 192
 	// Handle sequential payments.
193
-	if ( give_get_option( 'enable_sequential' ) ) {
193
+	if (give_get_option('enable_sequential')) {
194 194
 		$number          = give_get_next_payment_number();
195
-		$payment->number = give_format_payment_number( $number );
196
-		update_option( 'give_last_payment_number', $number );
195
+		$payment->number = give_format_payment_number($number);
196
+		update_option('give_last_payment_number', $number);
197 197
 	}
198 198
 
199 199
 	// Save payment.
@@ -207,10 +207,10 @@  discard block
 block discarded – undo
207 207
 	 * @param int   $payment_id   The payment ID.
208 208
 	 * @param array $payment_data Arguments passed.
209 209
 	 */
210
-	do_action( 'give_insert_payment', $payment->ID, $payment_data );
210
+	do_action('give_insert_payment', $payment->ID, $payment_data);
211 211
 
212 212
 	// Return payment ID upon success.
213
-	if ( ! empty( $payment->ID ) ) {
213
+	if ( ! empty($payment->ID)) {
214 214
 		return $payment->ID;
215 215
 	}
216 216
 
@@ -226,10 +226,10 @@  discard block
 block discarded – undo
226 226
  *
227 227
  * @return bool|int
228 228
  */
229
-function give_create_payment( $payment_data ) {
229
+function give_create_payment($payment_data) {
230 230
 
231
-	$form_id  = intval( $payment_data['post_data']['give-form-id'] );
232
-	$price_id = isset( $payment_data['post_data']['give-price-id'] ) ? $payment_data['post_data']['give-price-id'] : '';
231
+	$form_id  = intval($payment_data['post_data']['give-form-id']);
232
+	$price_id = isset($payment_data['post_data']['give-price-id']) ? $payment_data['post_data']['give-price-id'] : '';
233 233
 
234 234
 	// Collect payment data.
235 235
 	$insert_payment_data = array(
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 		'date'            => $payment_data['date'],
241 241
 		'user_email'      => $payment_data['user_email'],
242 242
 		'purchase_key'    => $payment_data['purchase_key'],
243
-		'currency'        => give_get_currency( $form_id, $payment_data ),
243
+		'currency'        => give_get_currency($form_id, $payment_data),
244 244
 		'user_info'       => $payment_data['user_info'],
245 245
 		'status'          => 'pending',
246 246
 		'gateway'         => 'paypal',
@@ -253,10 +253,10 @@  discard block
 block discarded – undo
253 253
 	 *
254 254
 	 * @param array $insert_payment_data
255 255
 	 */
256
-	$insert_payment_data = apply_filters( 'give_create_payment', $insert_payment_data );
256
+	$insert_payment_data = apply_filters('give_create_payment', $insert_payment_data);
257 257
 
258 258
 	// Record the pending payment.
259
-	return give_insert_payment( $insert_payment_data );
259
+	return give_insert_payment($insert_payment_data);
260 260
 }
261 261
 
262 262
 /**
@@ -269,12 +269,12 @@  discard block
 block discarded – undo
269 269
  *
270 270
  * @return bool
271 271
  */
272
-function give_update_payment_status( $payment_id, $new_status = 'publish' ) {
272
+function give_update_payment_status($payment_id, $new_status = 'publish') {
273 273
 
274 274
 	$updated = false;
275
-	$payment = new Give_Payment( $payment_id );
275
+	$payment = new Give_Payment($payment_id);
276 276
 
277
-	if ( $payment && $payment->ID > 0 ) {
277
+	if ($payment && $payment->ID > 0) {
278 278
 
279 279
 		$payment->status = $new_status;
280 280
 		$updated         = $payment->save();
@@ -295,45 +295,45 @@  discard block
 block discarded – undo
295 295
  *
296 296
  * @return void
297 297
  */
298
-function give_delete_donation( $payment_id = 0, $update_donor = true ) {
299
-	$payment = new Give_Payment( $payment_id );
298
+function give_delete_donation($payment_id = 0, $update_donor = true) {
299
+	$payment = new Give_Payment($payment_id);
300 300
 
301 301
 	// Bailout.
302
-	if ( ! $payment->ID ) {
302
+	if ( ! $payment->ID) {
303 303
 		return;
304 304
 	}
305 305
 
306
-	$amount   = give_donation_amount( $payment_id );
306
+	$amount   = give_donation_amount($payment_id);
307 307
 	$status   = $payment->post_status;
308
-	$donor_id = give_get_payment_donor_id( $payment_id );
309
-	$donor    = new Give_Donor( $donor_id );
308
+	$donor_id = give_get_payment_donor_id($payment_id);
309
+	$donor    = new Give_Donor($donor_id);
310 310
 
311 311
 	// Only undo donations that aren't these statuses.
312
-	$dont_undo_statuses = apply_filters( 'give_undo_donation_statuses', array(
312
+	$dont_undo_statuses = apply_filters('give_undo_donation_statuses', array(
313 313
 		'pending',
314 314
 		'cancelled',
315
-	) );
315
+	));
316 316
 
317
-	if ( ! in_array( $status, $dont_undo_statuses ) ) {
318
-		give_undo_donation( $payment_id );
317
+	if ( ! in_array($status, $dont_undo_statuses)) {
318
+		give_undo_donation($payment_id);
319 319
 	}
320 320
 
321 321
 	// Only undo donations that aren't these statuses.
322
-	$status_to_decrease_stats = apply_filters( 'give_decrease_donor_statuses', array( 'publish' ) );
322
+	$status_to_decrease_stats = apply_filters('give_decrease_donor_statuses', array('publish'));
323 323
 
324
-	if ( in_array( $status, $status_to_decrease_stats ) ) {
324
+	if (in_array($status, $status_to_decrease_stats)) {
325 325
 
326 326
 		// Only decrease earnings if they haven't already been decreased (or were never increased for this payment).
327
-		give_decrease_total_earnings( $amount );
327
+		give_decrease_total_earnings($amount);
328 328
 
329 329
 		// @todo: Refresh only range related stat cache
330 330
 		give_delete_donation_stats();
331 331
 
332
-		if ( $donor->id && $update_donor ) {
332
+		if ($donor->id && $update_donor) {
333 333
 
334 334
 			// Decrement the stats for the donor.
335 335
 			$donor->decrease_donation_count();
336
-			$donor->decrease_value( $amount );
336
+			$donor->decrease_value($amount);
337 337
 
338 338
 		}
339 339
 	}
@@ -345,18 +345,18 @@  discard block
 block discarded – undo
345 345
 	 *
346 346
 	 * @since 1.0
347 347
 	 */
348
-	do_action( 'give_payment_delete', $payment_id );
348
+	do_action('give_payment_delete', $payment_id);
349 349
 
350
-	if ( $donor->id && $update_donor ) {
350
+	if ($donor->id && $update_donor) {
351 351
 		// Remove the payment ID from the donor.
352
-		$donor->remove_payment( $payment_id );
352
+		$donor->remove_payment($payment_id);
353 353
 	}
354 354
 
355 355
 	// Remove the payment.
356
-	wp_delete_post( $payment_id, true );
356
+	wp_delete_post($payment_id, true);
357 357
 
358 358
 	// Remove related sale log entries.
359
-	Give()->logs->delete_logs( $payment_id );
359
+	Give()->logs->delete_logs($payment_id);
360 360
 
361 361
 	/**
362 362
 	 * Fires after payment deleted.
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 	 *
366 366
 	 * @since 1.0
367 367
 	 */
368
-	do_action( 'give_payment_deleted', $payment_id );
368
+	do_action('give_payment_deleted', $payment_id);
369 369
 }
370 370
 
371 371
 /**
@@ -380,20 +380,20 @@  discard block
 block discarded – undo
380 380
  *
381 381
  * @return void
382 382
  */
383
-function give_undo_donation( $payment_id ) {
383
+function give_undo_donation($payment_id) {
384 384
 
385
-	$payment = new Give_Payment( $payment_id );
385
+	$payment = new Give_Payment($payment_id);
386 386
 
387
-	$maybe_decrease_earnings = apply_filters( 'give_decrease_earnings_on_undo', true, $payment, $payment->form_id );
388
-	if ( true === $maybe_decrease_earnings ) {
387
+	$maybe_decrease_earnings = apply_filters('give_decrease_earnings_on_undo', true, $payment, $payment->form_id);
388
+	if (true === $maybe_decrease_earnings) {
389 389
 		// Decrease earnings.
390
-		give_decrease_form_earnings( $payment->form_id, $payment->total );
390
+		give_decrease_form_earnings($payment->form_id, $payment->total);
391 391
 	}
392 392
 
393
-	$maybe_decrease_donations = apply_filters( 'give_decrease_donations_on_undo', true, $payment, $payment->form_id );
394
-	if ( true === $maybe_decrease_donations ) {
393
+	$maybe_decrease_donations = apply_filters('give_decrease_donations_on_undo', true, $payment, $payment->form_id);
394
+	if (true === $maybe_decrease_donations) {
395 395
 		// Decrease donation count.
396
-		give_decrease_donation_count( $payment->form_id );
396
+		give_decrease_donation_count($payment->form_id);
397 397
 	}
398 398
 
399 399
 }
@@ -410,21 +410,21 @@  discard block
 block discarded – undo
410 410
  *
411 411
  * @return object $stats Contains the number of payments per payment status.
412 412
  */
413
-function give_count_payments( $args = array() ) {
413
+function give_count_payments($args = array()) {
414 414
 	// Backward compatibility.
415
-	if ( ! empty( $args['start-date'] ) ) {
415
+	if ( ! empty($args['start-date'])) {
416 416
 		$args['start_date'] = $args['start-date'];
417
-		unset( $args['start-date'] );
417
+		unset($args['start-date']);
418 418
 	}
419 419
 
420
-	if ( ! empty( $args['end-date'] ) ) {
420
+	if ( ! empty($args['end-date'])) {
421 421
 		$args['end_date'] = $args['end-date'];
422
-		unset( $args['end-date'] );
422
+		unset($args['end-date']);
423 423
 	}
424 424
 
425
-	if ( ! empty( $args['form_id'] ) ) {
425
+	if ( ! empty($args['form_id'])) {
426 426
 		$args['give_forms'] = $args['form_id'];
427
-		unset( $args['form_id'] );
427
+		unset($args['form_id']);
428 428
 	}
429 429
 
430 430
 	// Extract all donations
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 	$args['group_by']    = 'post_status';
433 433
 	$args['count']       = 'true';
434 434
 
435
-	$donations_obj   = new Give_Payments_Query( $args );
435
+	$donations_obj   = new Give_Payments_Query($args);
436 436
 	$donations_count = $donations_obj->get_payment_by_group();
437 437
 
438 438
 	/**
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
 	 *
441 441
 	 * @since 1.0
442 442
 	 */
443
-	return (object) apply_filters( 'give_count_payments', $donations_count, $args, $donations_obj );
443
+	return (object) apply_filters('give_count_payments', $donations_count, $args, $donations_obj);
444 444
 }
445 445
 
446 446
 
@@ -453,11 +453,11 @@  discard block
 block discarded – undo
453 453
  *
454 454
  * @return bool $exists True if payment exists, false otherwise.
455 455
  */
456
-function give_check_for_existing_payment( $payment_id ) {
456
+function give_check_for_existing_payment($payment_id) {
457 457
 	$exists  = false;
458
-	$payment = new Give_Payment( $payment_id );
458
+	$payment = new Give_Payment($payment_id);
459 459
 
460
-	if ( $payment_id === $payment->ID && 'publish' === $payment->status ) {
460
+	if ($payment_id === $payment->ID && 'publish' === $payment->status) {
461 461
 		$exists = true;
462 462
 	}
463 463
 
@@ -475,41 +475,41 @@  discard block
 block discarded – undo
475 475
  *
476 476
  * @return bool|mixed True if payment status exists, false otherwise.
477 477
  */
478
-function give_get_payment_status( $payment, $return_label = false ) {
478
+function give_get_payment_status($payment, $return_label = false) {
479 479
 
480
-	if ( is_numeric( $payment ) ) {
480
+	if (is_numeric($payment)) {
481 481
 
482
-		$payment = new Give_Payment( $payment );
482
+		$payment = new Give_Payment($payment);
483 483
 
484
-		if ( ! $payment->ID > 0 ) {
484
+		if ( ! $payment->ID > 0) {
485 485
 			return false;
486 486
 		}
487 487
 
488 488
 	}
489 489
 
490
-	if ( ! is_object( $payment ) || ! isset( $payment->post_status ) ) {
490
+	if ( ! is_object($payment) || ! isset($payment->post_status)) {
491 491
 		return false;
492 492
 	}
493 493
 
494 494
 	$statuses = give_get_payment_statuses();
495 495
 
496
-	if ( ! is_array( $statuses ) || empty( $statuses ) ) {
496
+	if ( ! is_array($statuses) || empty($statuses)) {
497 497
 		return false;
498 498
 	}
499 499
 
500 500
 	// Get payment object if not already given.
501
-	$payment = $payment instanceof Give_Payment ? $payment : new Give_Payment( $payment->ID );
501
+	$payment = $payment instanceof Give_Payment ? $payment : new Give_Payment($payment->ID);
502 502
 
503
-	if ( array_key_exists( $payment->status, $statuses ) ) {
504
-		if ( true === $return_label ) {
503
+	if (array_key_exists($payment->status, $statuses)) {
504
+		if (true === $return_label) {
505 505
 			// Return translated status label.
506
-			return $statuses[ $payment->status ];
506
+			return $statuses[$payment->status];
507 507
 		} else {
508 508
 			// Account that our 'publish' status is labeled 'Complete'
509 509
 			$post_status = 'publish' === $payment->status ? 'Complete' : $payment->post_status;
510 510
 
511 511
 			// Make sure we're matching cases, since they matter
512
-			return array_search( strtolower( $post_status ), array_map( 'strtolower', $statuses ) );
512
+			return array_search(strtolower($post_status), array_map('strtolower', $statuses));
513 513
 		}
514 514
 	}
515 515
 
@@ -525,18 +525,18 @@  discard block
 block discarded – undo
525 525
  */
526 526
 function give_get_payment_statuses() {
527 527
 	$payment_statuses = array(
528
-		'pending'     => __( 'Pending', 'give' ),
529
-		'publish'     => __( 'Complete', 'give' ),
530
-		'refunded'    => __( 'Refunded', 'give' ),
531
-		'failed'      => __( 'Failed', 'give' ),
532
-		'cancelled'   => __( 'Cancelled', 'give' ),
533
-		'abandoned'   => __( 'Abandoned', 'give' ),
534
-		'preapproval' => __( 'Pre-Approved', 'give' ),
535
-		'processing'  => __( 'Processing', 'give' ),
536
-		'revoked'     => __( 'Revoked', 'give' ),
528
+		'pending'     => __('Pending', 'give'),
529
+		'publish'     => __('Complete', 'give'),
530
+		'refunded'    => __('Refunded', 'give'),
531
+		'failed'      => __('Failed', 'give'),
532
+		'cancelled'   => __('Cancelled', 'give'),
533
+		'abandoned'   => __('Abandoned', 'give'),
534
+		'preapproval' => __('Pre-Approved', 'give'),
535
+		'processing'  => __('Processing', 'give'),
536
+		'revoked'     => __('Revoked', 'give'),
537 537
 	);
538 538
 
539
-	return apply_filters( 'give_payment_statuses', $payment_statuses );
539
+	return apply_filters('give_payment_statuses', $payment_statuses);
540 540
 }
541 541
 
542 542
 /**
@@ -549,10 +549,10 @@  discard block
 block discarded – undo
549 549
  * @return array $payment_status All the available payment statuses.
550 550
  */
551 551
 function give_get_payment_status_keys() {
552
-	$statuses = array_keys( give_get_payment_statuses() );
553
-	asort( $statuses );
552
+	$statuses = array_keys(give_get_payment_statuses());
553
+	asort($statuses);
554 554
 
555
-	return array_values( $statuses );
555
+	return array_values($statuses);
556 556
 }
557 557
 
558 558
 /**
@@ -567,44 +567,44 @@  discard block
 block discarded – undo
567 567
  *
568 568
  * @return int $earnings Earnings
569 569
  */
570
-function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) {
570
+function give_get_earnings_by_date($day = null, $month_num, $year = null, $hour = null) {
571 571
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead.
572 572
 
573 573
 	global $wpdb;
574
-	$meta_table = __give_v20_bc_table_details( 'payment' );
574
+	$meta_table = __give_v20_bc_table_details('payment');
575 575
 
576 576
 	$args = array(
577 577
 		'post_type'              => 'give_payment',
578 578
 		'nopaging'               => true,
579 579
 		'year'                   => $year,
580 580
 		'monthnum'               => $month_num,
581
-		'post_status'            => array( 'publish' ),
581
+		'post_status'            => array('publish'),
582 582
 		'fields'                 => 'ids',
583 583
 		'update_post_term_cache' => false,
584 584
 	);
585
-	if ( ! empty( $day ) ) {
585
+	if ( ! empty($day)) {
586 586
 		$args['day'] = $day;
587 587
 	}
588 588
 
589
-	if ( isset( $hour ) ) {
589
+	if (isset($hour)) {
590 590
 		$args['hour'] = $hour;
591 591
 	}
592 592
 
593
-	$args = apply_filters( 'give_get_earnings_by_date_args', $args );
594
-	$key  = Give_Cache::get_key( 'give_stats', $args );
593
+	$args = apply_filters('give_get_earnings_by_date_args', $args);
594
+	$key  = Give_Cache::get_key('give_stats', $args);
595 595
 
596
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
596
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
597 597
 		$earnings = false;
598 598
 	} else {
599
-		$earnings = Give_Cache::get( $key );
599
+		$earnings = Give_Cache::get($key);
600 600
 	}
601 601
 
602
-	if ( false === $earnings ) {
603
-		$donations = get_posts( $args );
602
+	if (false === $earnings) {
603
+		$donations = get_posts($args);
604 604
 		$earnings  = 0;
605
-		if ( $donations ) {
606
-			$donations      = implode( ',', $donations );
607
-			$earning_totals = $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$donations})" );
605
+		if ($donations) {
606
+			$donations      = implode(',', $donations);
607
+			$earning_totals = $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$donations})");
608 608
 
609 609
 			/**
610 610
 			 * Filter The earnings by dates.
@@ -615,13 +615,13 @@  discard block
 block discarded – undo
615 615
 			 * @param array $donations      Donations lists.
616 616
 			 * @param array $args           Donation query args.
617 617
 			 */
618
-			$earnings = apply_filters( 'give_get_earnings_by_date', $earning_totals, $donations, $args );
618
+			$earnings = apply_filters('give_get_earnings_by_date', $earning_totals, $donations, $args);
619 619
 		}
620 620
 		// Cache the results for one hour.
621
-		Give_Cache::set( $key, $earnings, HOUR_IN_SECONDS );
621
+		Give_Cache::set($key, $earnings, HOUR_IN_SECONDS);
622 622
 	}
623 623
 
624
-	return round( $earnings, 2 );
624
+	return round($earnings, 2);
625 625
 }
626 626
 
627 627
 /**
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
  *
637 637
  * @return int $count Sales
638 638
  */
639
-function give_get_sales_by_date( $day = null, $month_num = null, $year = null, $hour = null ) {
639
+function give_get_sales_by_date($day = null, $month_num = null, $year = null, $hour = null) {
640 640
 
641 641
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_sales() method instead.
642 642
 	$args = array(
@@ -644,14 +644,14 @@  discard block
 block discarded – undo
644 644
 		'nopaging'               => true,
645 645
 		'year'                   => $year,
646 646
 		'fields'                 => 'ids',
647
-		'post_status'            => array( 'publish' ),
647
+		'post_status'            => array('publish'),
648 648
 		'update_post_meta_cache' => false,
649 649
 		'update_post_term_cache' => false,
650 650
 	);
651 651
 
652
-	$show_free = apply_filters( 'give_sales_by_date_show_free', true, $args );
652
+	$show_free = apply_filters('give_sales_by_date_show_free', true, $args);
653 653
 
654
-	if ( false === $show_free ) {
654
+	if (false === $show_free) {
655 655
 		$args['meta_query'] = array(
656 656
 			array(
657 657
 				'key'     => '_give_payment_total',
@@ -662,33 +662,33 @@  discard block
 block discarded – undo
662 662
 		);
663 663
 	}
664 664
 
665
-	if ( ! empty( $month_num ) ) {
665
+	if ( ! empty($month_num)) {
666 666
 		$args['monthnum'] = $month_num;
667 667
 	}
668 668
 
669
-	if ( ! empty( $day ) ) {
669
+	if ( ! empty($day)) {
670 670
 		$args['day'] = $day;
671 671
 	}
672 672
 
673
-	if ( isset( $hour ) ) {
673
+	if (isset($hour)) {
674 674
 		$args['hour'] = $hour;
675 675
 	}
676 676
 
677
-	$args = apply_filters( 'give_get_sales_by_date_args', $args );
677
+	$args = apply_filters('give_get_sales_by_date_args', $args);
678 678
 
679
-	$key = Give_Cache::get_key( 'give_stats', $args );
679
+	$key = Give_Cache::get_key('give_stats', $args);
680 680
 
681
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
681
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
682 682
 		$count = false;
683 683
 	} else {
684
-		$count = Give_Cache::get( $key );
684
+		$count = Give_Cache::get($key);
685 685
 	}
686 686
 
687
-	if ( false === $count ) {
688
-		$donations = new WP_Query( $args );
687
+	if (false === $count) {
688
+		$donations = new WP_Query($args);
689 689
 		$count     = (int) $donations->post_count;
690 690
 		// Cache the results for one hour.
691
-		Give_Cache::set( $key, $count, HOUR_IN_SECONDS );
691
+		Give_Cache::set($key, $count, HOUR_IN_SECONDS);
692 692
 	}
693 693
 
694 694
 	return $count;
@@ -703,19 +703,19 @@  discard block
 block discarded – undo
703 703
  *
704 704
  * @return bool $ret True if complete, false otherwise.
705 705
  */
706
-function give_is_payment_complete( $payment_id ) {
707
-	$payment = new Give_Payment( $payment_id );
706
+function give_is_payment_complete($payment_id) {
707
+	$payment = new Give_Payment($payment_id);
708 708
 
709 709
 	$ret = false;
710 710
 
711
-	if ( $payment->ID > 0 ) {
711
+	if ($payment->ID > 0) {
712 712
 
713
-		if ( (int) $payment_id === (int) $payment->ID && 'publish' == $payment->status ) {
713
+		if ((int) $payment_id === (int) $payment->ID && 'publish' == $payment->status) {
714 714
 			$ret = true;
715 715
 		}
716 716
 	}
717 717
 
718
-	return apply_filters( 'give_is_payment_complete', $ret, $payment_id, $payment->post_status );
718
+	return apply_filters('give_is_payment_complete', $ret, $payment_id, $payment->post_status);
719 719
 }
720 720
 
721 721
 /**
@@ -741,50 +741,50 @@  discard block
 block discarded – undo
741 741
  *
742 742
  * @return float $total Total earnings.
743 743
  */
744
-function give_get_total_earnings( $recalculate = false ) {
744
+function give_get_total_earnings($recalculate = false) {
745 745
 
746
-	$total      = get_option( 'give_earnings_total', 0 );
747
-	$meta_table = __give_v20_bc_table_details( 'payment' );
746
+	$total      = get_option('give_earnings_total', 0);
747
+	$meta_table = __give_v20_bc_table_details('payment');
748 748
 
749 749
 	// Calculate total earnings.
750
-	if ( ! $total || $recalculate ) {
750
+	if ( ! $total || $recalculate) {
751 751
 		global $wpdb;
752 752
 
753 753
 		$total = (float) 0;
754 754
 
755
-		$args = apply_filters( 'give_get_total_earnings_args', array(
755
+		$args = apply_filters('give_get_total_earnings_args', array(
756 756
 			'offset' => 0,
757
-			'number' => - 1,
758
-			'status' => array( 'publish' ),
757
+			'number' => -1,
758
+			'status' => array('publish'),
759 759
 			'fields' => 'ids',
760
-		) );
760
+		));
761 761
 
762
-		$payments = give_get_payments( $args );
763
-		if ( $payments ) {
762
+		$payments = give_get_payments($args);
763
+		if ($payments) {
764 764
 
765 765
 			/**
766 766
 			 * If performing a donation, we need to skip the very last payment in the database,
767 767
 			 * since it calls give_increase_total_earnings() on completion,
768 768
 			 * which results in duplicated earnings for the very first donation.
769 769
 			 */
770
-			if ( did_action( 'give_update_payment_status' ) ) {
771
-				array_pop( $payments );
770
+			if (did_action('give_update_payment_status')) {
771
+				array_pop($payments);
772 772
 			}
773 773
 
774
-			if ( ! empty( $payments ) ) {
775
-				$payments = implode( ',', $payments );
776
-				$total    += $wpdb->get_var( "SELECT SUM(meta_value) FROM {$meta_table['name']} WHERE meta_key = '_give_payment_total' AND {$meta_table['column']['id']} IN({$payments})" );
774
+			if ( ! empty($payments)) {
775
+				$payments = implode(',', $payments);
776
+				$total += $wpdb->get_var("SELECT SUM(meta_value) FROM {$meta_table['name']} WHERE meta_key = '_give_payment_total' AND {$meta_table['column']['id']} IN({$payments})");
777 777
 			}
778 778
 		}
779 779
 
780
-		update_option( 'give_earnings_total', $total, 'no' );
780
+		update_option('give_earnings_total', $total, 'no');
781 781
 	}
782 782
 
783
-	if ( $total < 0 ) {
783
+	if ($total < 0) {
784 784
 		$total = 0; // Don't ever show negative earnings.
785 785
 	}
786 786
 
787
-	return apply_filters( 'give_total_earnings', round( $total, give_get_price_decimals() ), $total );
787
+	return apply_filters('give_total_earnings', round($total, give_get_price_decimals()), $total);
788 788
 }
789 789
 
790 790
 /**
@@ -796,10 +796,10 @@  discard block
 block discarded – undo
796 796
  *
797 797
  * @return float $total Total earnings.
798 798
  */
799
-function give_increase_total_earnings( $amount = 0 ) {
799
+function give_increase_total_earnings($amount = 0) {
800 800
 	$total = give_get_total_earnings();
801 801
 	$total += $amount;
802
-	update_option( 'give_earnings_total', $total );
802
+	update_option('give_earnings_total', $total);
803 803
 
804 804
 	return $total;
805 805
 }
@@ -813,13 +813,13 @@  discard block
 block discarded – undo
813 813
  *
814 814
  * @return float $total Total earnings.
815 815
  */
816
-function give_decrease_total_earnings( $amount = 0 ) {
816
+function give_decrease_total_earnings($amount = 0) {
817 817
 	$total = give_get_total_earnings();
818 818
 	$total -= $amount;
819
-	if ( $total < 0 ) {
819
+	if ($total < 0) {
820 820
 		$total = 0;
821 821
 	}
822
-	update_option( 'give_earnings_total', $total );
822
+	update_option('give_earnings_total', $total);
823 823
 
824 824
 	return $total;
825 825
 }
@@ -835,10 +835,10 @@  discard block
 block discarded – undo
835 835
  *
836 836
  * @return mixed $meta Payment Meta.
837 837
  */
838
-function give_get_payment_meta( $payment_id = 0, $meta_key = '_give_payment_meta', $single = true ) {
839
-	$payment = new Give_Payment( $payment_id );
838
+function give_get_payment_meta($payment_id = 0, $meta_key = '_give_payment_meta', $single = true) {
839
+	$payment = new Give_Payment($payment_id);
840 840
 
841
-	return $payment->get_meta( $meta_key, $single );
841
+	return $payment->get_meta($meta_key, $single);
842 842
 }
843 843
 
844 844
 /**
@@ -851,10 +851,10 @@  discard block
 block discarded – undo
851 851
  *
852 852
  * @return mixed Meta ID if successful, false if unsuccessful.
853 853
  */
854
-function give_update_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) {
855
-	$payment = new Give_Payment( $payment_id );
854
+function give_update_payment_meta($payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') {
855
+	$payment = new Give_Payment($payment_id);
856 856
 
857
-	return $payment->update_meta( $meta_key, $meta_value, $prev_value );
857
+	return $payment->update_meta($meta_key, $meta_value, $prev_value);
858 858
 }
859 859
 
860 860
 /**
@@ -866,8 +866,8 @@  discard block
 block discarded – undo
866 866
  *
867 867
  * @return array $user_info User Info Meta Values.
868 868
  */
869
-function give_get_payment_meta_user_info( $payment_id ) {
870
-	$payment = new Give_Payment( $payment_id );
869
+function give_get_payment_meta_user_info($payment_id) {
870
+	$payment = new Give_Payment($payment_id);
871 871
 
872 872
 	return $payment->user_info;
873 873
 }
@@ -883,8 +883,8 @@  discard block
 block discarded – undo
883 883
  *
884 884
  * @return int $form_id Form ID.
885 885
  */
886
-function give_get_payment_form_id( $payment_id ) {
887
-	$payment = new Give_Payment( $payment_id );
886
+function give_get_payment_form_id($payment_id) {
887
+	$payment = new Give_Payment($payment_id);
888 888
 
889 889
 	return $payment->form_id;
890 890
 }
@@ -898,8 +898,8 @@  discard block
 block discarded – undo
898 898
  *
899 899
  * @return string $email User email.
900 900
  */
901
-function give_get_payment_user_email( $payment_id ) {
902
-	$payment = new Give_Payment( $payment_id );
901
+function give_get_payment_user_email($payment_id) {
902
+	$payment = new Give_Payment($payment_id);
903 903
 
904 904
 	return $payment->email;
905 905
 }
@@ -913,11 +913,11 @@  discard block
 block discarded – undo
913 913
  *
914 914
  * @return bool $is_guest_payment If the payment is associated with a user (false) or not (true)
915 915
  */
916
-function give_is_guest_payment( $payment_id ) {
917
-	$payment_user_id  = give_get_payment_user_id( $payment_id );
918
-	$is_guest_payment = ! empty( $payment_user_id ) && $payment_user_id > 0 ? false : true;
916
+function give_is_guest_payment($payment_id) {
917
+	$payment_user_id  = give_get_payment_user_id($payment_id);
918
+	$is_guest_payment = ! empty($payment_user_id) && $payment_user_id > 0 ? false : true;
919 919
 
920
-	return (bool) apply_filters( 'give_is_guest_payment', $is_guest_payment, $payment_id );
920
+	return (bool) apply_filters('give_is_guest_payment', $is_guest_payment, $payment_id);
921 921
 }
922 922
 
923 923
 /**
@@ -929,8 +929,8 @@  discard block
 block discarded – undo
929 929
  *
930 930
  * @return int $user_id User ID.
931 931
  */
932
-function give_get_payment_user_id( $payment_id ) {
933
-	$payment = new Give_Payment( $payment_id );
932
+function give_get_payment_user_id($payment_id) {
933
+	$payment = new Give_Payment($payment_id);
934 934
 
935 935
 	return $payment->user_id;
936 936
 }
@@ -944,8 +944,8 @@  discard block
 block discarded – undo
944 944
  *
945 945
  * @return int $payment->customer_id Donor ID.
946 946
  */
947
-function give_get_payment_donor_id( $payment_id ) {
948
-	$payment = new Give_Payment( $payment_id );
947
+function give_get_payment_donor_id($payment_id) {
948
+	$payment = new Give_Payment($payment_id);
949 949
 
950 950
 	return $payment->customer_id;
951 951
 }
@@ -959,8 +959,8 @@  discard block
 block discarded – undo
959 959
  *
960 960
  * @return string $ip User IP.
961 961
  */
962
-function give_get_payment_user_ip( $payment_id ) {
963
-	$payment = new Give_Payment( $payment_id );
962
+function give_get_payment_user_ip($payment_id) {
963
+	$payment = new Give_Payment($payment_id);
964 964
 
965 965
 	return $payment->ip;
966 966
 }
@@ -974,8 +974,8 @@  discard block
 block discarded – undo
974 974
  *
975 975
  * @return string $date The date the payment was completed.
976 976
  */
977
-function give_get_payment_completed_date( $payment_id = 0 ) {
978
-	$payment = new Give_Payment( $payment_id );
977
+function give_get_payment_completed_date($payment_id = 0) {
978
+	$payment = new Give_Payment($payment_id);
979 979
 
980 980
 	return $payment->completed_date;
981 981
 }
@@ -989,8 +989,8 @@  discard block
 block discarded – undo
989 989
  *
990 990
  * @return string $gateway Gateway.
991 991
  */
992
-function give_get_payment_gateway( $payment_id ) {
993
-	$payment = new Give_Payment( $payment_id );
992
+function give_get_payment_gateway($payment_id) {
993
+	$payment = new Give_Payment($payment_id);
994 994
 
995 995
 	return $payment->gateway;
996 996
 }
@@ -1004,8 +1004,8 @@  discard block
 block discarded – undo
1004 1004
  *
1005 1005
  * @return string $currency The currency code.
1006 1006
  */
1007
-function give_get_payment_currency_code( $payment_id = 0 ) {
1008
-	$payment = new Give_Payment( $payment_id );
1007
+function give_get_payment_currency_code($payment_id = 0) {
1008
+	$payment = new Give_Payment($payment_id);
1009 1009
 
1010 1010
 	return $payment->currency;
1011 1011
 }
@@ -1019,10 +1019,10 @@  discard block
 block discarded – undo
1019 1019
  *
1020 1020
  * @return string $currency The currency name.
1021 1021
  */
1022
-function give_get_payment_currency( $payment_id = 0 ) {
1023
-	$currency = give_get_payment_currency_code( $payment_id );
1022
+function give_get_payment_currency($payment_id = 0) {
1023
+	$currency = give_get_payment_currency_code($payment_id);
1024 1024
 
1025
-	return apply_filters( 'give_payment_currency', give_get_currency_name( $currency ), $payment_id );
1025
+	return apply_filters('give_payment_currency', give_get_currency_name($currency), $payment_id);
1026 1026
 }
1027 1027
 
1028 1028
 /**
@@ -1034,8 +1034,8 @@  discard block
 block discarded – undo
1034 1034
  *
1035 1035
  * @return string $key Donation key.
1036 1036
  */
1037
-function give_get_payment_key( $payment_id = 0 ) {
1038
-	$payment = new Give_Payment( $payment_id );
1037
+function give_get_payment_key($payment_id = 0) {
1038
+	$payment = new Give_Payment($payment_id);
1039 1039
 
1040 1040
 	return $payment->key;
1041 1041
 }
@@ -1051,8 +1051,8 @@  discard block
 block discarded – undo
1051 1051
  *
1052 1052
  * @return string $number Payment order number.
1053 1053
  */
1054
-function give_get_payment_number( $payment_id = 0 ) {
1055
-	$payment = new Give_Payment( $payment_id );
1054
+function give_get_payment_number($payment_id = 0) {
1055
+	$payment = new Give_Payment($payment_id);
1056 1056
 
1057 1057
 	return $payment->number;
1058 1058
 }
@@ -1066,23 +1066,23 @@  discard block
 block discarded – undo
1066 1066
  *
1067 1067
  * @return string      The formatted payment number.
1068 1068
  */
1069
-function give_format_payment_number( $number ) {
1069
+function give_format_payment_number($number) {
1070 1070
 
1071
-	if ( ! give_get_option( 'enable_sequential' ) ) {
1071
+	if ( ! give_get_option('enable_sequential')) {
1072 1072
 		return $number;
1073 1073
 	}
1074 1074
 
1075
-	if ( ! is_numeric( $number ) ) {
1075
+	if ( ! is_numeric($number)) {
1076 1076
 		return $number;
1077 1077
 	}
1078 1078
 
1079
-	$prefix  = give_get_option( 'sequential_prefix' );
1080
-	$number  = absint( $number );
1081
-	$postfix = give_get_option( 'sequential_postfix' );
1079
+	$prefix  = give_get_option('sequential_prefix');
1080
+	$number  = absint($number);
1081
+	$postfix = give_get_option('sequential_postfix');
1082 1082
 
1083
-	$formatted_number = $prefix . $number . $postfix;
1083
+	$formatted_number = $prefix.$number.$postfix;
1084 1084
 
1085
-	return apply_filters( 'give_format_payment_number', $formatted_number, $prefix, $number, $postfix );
1085
+	return apply_filters('give_format_payment_number', $formatted_number, $prefix, $number, $postfix);
1086 1086
 }
1087 1087
 
1088 1088
 /**
@@ -1096,17 +1096,17 @@  discard block
 block discarded – undo
1096 1096
  */
1097 1097
 function give_get_next_payment_number() {
1098 1098
 
1099
-	if ( ! give_get_option( 'enable_sequential' ) ) {
1099
+	if ( ! give_get_option('enable_sequential')) {
1100 1100
 		return false;
1101 1101
 	}
1102 1102
 
1103
-	$number           = get_option( 'give_last_payment_number' );
1104
-	$start            = give_get_option( 'sequential_start', 1 );
1103
+	$number           = get_option('give_last_payment_number');
1104
+	$start            = give_get_option('sequential_start', 1);
1105 1105
 	$increment_number = true;
1106 1106
 
1107
-	if ( false !== $number ) {
1107
+	if (false !== $number) {
1108 1108
 
1109
-		if ( empty( $number ) ) {
1109
+		if (empty($number)) {
1110 1110
 
1111 1111
 			$number           = $start;
1112 1112
 			$increment_number = false;
@@ -1115,24 +1115,24 @@  discard block
 block discarded – undo
1115 1115
 	} else {
1116 1116
 
1117 1117
 		// This case handles the first addition of the new option, as well as if it get's deleted for any reason.
1118
-		$payments     = new Give_Payments_Query( array(
1118
+		$payments = new Give_Payments_Query(array(
1119 1119
 			'number'  => 1,
1120 1120
 			'order'   => 'DESC',
1121 1121
 			'orderby' => 'ID',
1122 1122
 			'output'  => 'posts',
1123 1123
 			'fields'  => 'ids',
1124
-		) );
1124
+		));
1125 1125
 		$last_payment = $payments->get_payments();
1126 1126
 
1127
-		if ( ! empty( $last_payment ) ) {
1127
+		if ( ! empty($last_payment)) {
1128 1128
 
1129
-			$number = give_get_payment_number( $last_payment[0] );
1129
+			$number = give_get_payment_number($last_payment[0]);
1130 1130
 
1131 1131
 		}
1132 1132
 
1133
-		if ( ! empty( $number ) && $number !== (int) $last_payment[0] ) {
1133
+		if ( ! empty($number) && $number !== (int) $last_payment[0]) {
1134 1134
 
1135
-			$number = give_remove_payment_prefix_postfix( $number );
1135
+			$number = give_remove_payment_prefix_postfix($number);
1136 1136
 
1137 1137
 		} else {
1138 1138
 
@@ -1141,13 +1141,13 @@  discard block
 block discarded – undo
1141 1141
 		}
1142 1142
 	}// End if().
1143 1143
 
1144
-	$increment_number = apply_filters( 'give_increment_payment_number', $increment_number, $number );
1144
+	$increment_number = apply_filters('give_increment_payment_number', $increment_number, $number);
1145 1145
 
1146
-	if ( $increment_number ) {
1147
-		$number ++;
1146
+	if ($increment_number) {
1147
+		$number++;
1148 1148
 	}
1149 1149
 
1150
-	return apply_filters( 'give_get_next_payment_number', $number );
1150
+	return apply_filters('give_get_next_payment_number', $number);
1151 1151
 }
1152 1152
 
1153 1153
 /**
@@ -1159,25 +1159,25 @@  discard block
 block discarded – undo
1159 1159
  *
1160 1160
  * @return string The new Payment number without prefix and postfix.
1161 1161
  */
1162
-function give_remove_payment_prefix_postfix( $number ) {
1162
+function give_remove_payment_prefix_postfix($number) {
1163 1163
 
1164
-	$prefix  = give_get_option( 'sequential_prefix' );
1165
-	$postfix = give_get_option( 'sequential_postfix' );
1164
+	$prefix  = give_get_option('sequential_prefix');
1165
+	$postfix = give_get_option('sequential_postfix');
1166 1166
 
1167 1167
 	// Remove prefix.
1168
-	$number = preg_replace( '/' . $prefix . '/', '', $number, 1 );
1168
+	$number = preg_replace('/'.$prefix.'/', '', $number, 1);
1169 1169
 
1170 1170
 	// Remove the postfix.
1171
-	$length      = strlen( $number );
1172
-	$postfix_pos = strrpos( $number, $postfix );
1173
-	if ( false !== $postfix_pos ) {
1174
-		$number = substr_replace( $number, '', $postfix_pos, $length );
1171
+	$length      = strlen($number);
1172
+	$postfix_pos = strrpos($number, $postfix);
1173
+	if (false !== $postfix_pos) {
1174
+		$number = substr_replace($number, '', $postfix_pos, $length);
1175 1175
 	}
1176 1176
 
1177 1177
 	// Ensure it's a whole number.
1178
-	$number = intval( $number );
1178
+	$number = intval($number);
1179 1179
 
1180
-	return apply_filters( 'give_remove_payment_prefix_postfix', $number, $prefix, $postfix );
1180
+	return apply_filters('give_remove_payment_prefix_postfix', $number, $prefix, $postfix);
1181 1181
 
1182 1182
 }
1183 1183
 
@@ -1195,16 +1195,16 @@  discard block
 block discarded – undo
1195 1195
  *
1196 1196
  * @return string $amount Fully formatted donation amount.
1197 1197
  */
1198
-function give_donation_amount( $donation, $format_args = array() ) {
1198
+function give_donation_amount($donation, $format_args = array()) {
1199 1199
 	/* @var Give_Payment $donation */
1200
-	if ( ! ( $donation instanceof Give_Payment ) ) {
1201
-		$donation = new Give_Payment( absint( $donation ) );
1200
+	if ( ! ($donation instanceof Give_Payment)) {
1201
+		$donation = new Give_Payment(absint($donation));
1202 1202
 	}
1203 1203
 
1204 1204
 	$amount           = $donation->total;
1205 1205
 	$formatted_amount = $amount;
1206 1206
 
1207
-	if ( is_bool( $format_args ) ) {
1207
+	if (is_bool($format_args)) {
1208 1208
 		$format_args = array(
1209 1209
 			'currency' => (bool) $format_args,
1210 1210
 			'amount'   => (bool) $format_args,
@@ -1227,27 +1227,25 @@  discard block
 block discarded – undo
1227 1227
 		)
1228 1228
 	);
1229 1229
 
1230
-	if ( $format_args['amount'] || $format_args['currency'] ) {
1230
+	if ($format_args['amount'] || $format_args['currency']) {
1231 1231
 
1232
-		if ( $format_args['amount'] ) {
1232
+		if ($format_args['amount']) {
1233 1233
 
1234 1234
 			$formatted_amount = give_format_amount(
1235 1235
 				$amount,
1236
-				! is_array( $format_args['amount'] ) ?
1236
+				! is_array($format_args['amount']) ?
1237 1237
 					array(
1238 1238
 						'sanitize' => false,
1239 1239
 						'currency' => $donation->currency,
1240
-					) :
1241
-					$format_args['amount']
1240
+					) : $format_args['amount']
1242 1241
 			);
1243 1242
 		}
1244 1243
 
1245
-		if ( $format_args['currency'] ) {
1244
+		if ($format_args['currency']) {
1246 1245
 			$formatted_amount = give_currency_filter(
1247 1246
 				$formatted_amount,
1248
-				! is_array( $format_args['currency'] ) ?
1249
-					array( 'currency_code' => $donation->currency ) :
1250
-					$format_args['currency']
1247
+				! is_array($format_args['currency']) ?
1248
+					array('currency_code' => $donation->currency) : $format_args['currency']
1251 1249
 			);
1252 1250
 		}
1253 1251
 	}
@@ -1262,7 +1260,7 @@  discard block
 block discarded – undo
1262 1260
 	 * @param int    $donation_id      Donation ID.
1263 1261
 	 * @param string $type             Donation amount type.
1264 1262
 	 */
1265
-	return apply_filters( 'give_donation_amount', (string) $formatted_amount, $amount, $donation, $format_args );
1263
+	return apply_filters('give_donation_amount', (string) $formatted_amount, $amount, $donation, $format_args);
1266 1264
 }
1267 1265
 
1268 1266
 /**
@@ -1279,10 +1277,10 @@  discard block
 block discarded – undo
1279 1277
  *
1280 1278
  * @return array Fully formatted payment subtotal.
1281 1279
  */
1282
-function give_payment_subtotal( $payment_id = 0 ) {
1283
-	$subtotal = give_get_payment_subtotal( $payment_id );
1280
+function give_payment_subtotal($payment_id = 0) {
1281
+	$subtotal = give_get_payment_subtotal($payment_id);
1284 1282
 
1285
-	return give_currency_filter( give_format_amount( $subtotal, array( 'sanitize' => false ) ), array( 'currency_code' => give_get_payment_currency_code( $payment_id ) ) );
1283
+	return give_currency_filter(give_format_amount($subtotal, array('sanitize' => false)), array('currency_code' => give_get_payment_currency_code($payment_id)));
1286 1284
 }
1287 1285
 
1288 1286
 /**
@@ -1296,8 +1294,8 @@  discard block
 block discarded – undo
1296 1294
  *
1297 1295
  * @return float $subtotal Subtotal for payment (non formatted).
1298 1296
  */
1299
-function give_get_payment_subtotal( $payment_id = 0 ) {
1300
-	$payment = new Give_Payment( $payment_id );
1297
+function give_get_payment_subtotal($payment_id = 0) {
1298
+	$payment = new Give_Payment($payment_id);
1301 1299
 
1302 1300
 	return $payment->subtotal;
1303 1301
 }
@@ -1311,8 +1309,8 @@  discard block
 block discarded – undo
1311 1309
  *
1312 1310
  * @return string The donation ID.
1313 1311
  */
1314
-function give_get_payment_transaction_id( $payment_id = 0 ) {
1315
-	$payment = new Give_Payment( $payment_id );
1312
+function give_get_payment_transaction_id($payment_id = 0) {
1313
+	$payment = new Give_Payment($payment_id);
1316 1314
 
1317 1315
 	return $payment->transaction_id;
1318 1316
 }
@@ -1327,15 +1325,15 @@  discard block
 block discarded – undo
1327 1325
  *
1328 1326
  * @return bool|mixed
1329 1327
  */
1330
-function give_set_payment_transaction_id( $payment_id = 0, $transaction_id = '' ) {
1328
+function give_set_payment_transaction_id($payment_id = 0, $transaction_id = '') {
1331 1329
 
1332
-	if ( empty( $payment_id ) || empty( $transaction_id ) ) {
1330
+	if (empty($payment_id) || empty($transaction_id)) {
1333 1331
 		return false;
1334 1332
 	}
1335 1333
 
1336
-	$transaction_id = apply_filters( 'give_set_payment_transaction_id', $transaction_id, $payment_id );
1334
+	$transaction_id = apply_filters('give_set_payment_transaction_id', $transaction_id, $payment_id);
1337 1335
 
1338
-	return give_update_payment_meta( $payment_id, '_give_payment_transaction_id', $transaction_id );
1336
+	return give_update_payment_meta($payment_id, '_give_payment_transaction_id', $transaction_id);
1339 1337
 }
1340 1338
 
1341 1339
 /**
@@ -1348,10 +1346,10 @@  discard block
 block discarded – undo
1348 1346
  *
1349 1347
  * @return int $purchase Donation ID.
1350 1348
  */
1351
-function give_get_donation_id_by_key( $key ) {
1349
+function give_get_donation_id_by_key($key) {
1352 1350
 	global $wpdb;
1353 1351
 
1354
-	$meta_table = __give_v20_bc_table_details( 'payment' );
1352
+	$meta_table = __give_v20_bc_table_details('payment');
1355 1353
 
1356 1354
 	$purchase = $wpdb->get_var(
1357 1355
 		$wpdb->prepare(
@@ -1367,7 +1365,7 @@  discard block
 block discarded – undo
1367 1365
 		)
1368 1366
 	);
1369 1367
 
1370
-	if ( $purchase != null ) {
1368
+	if ($purchase != null) {
1371 1369
 		return $purchase;
1372 1370
 	}
1373 1371
 
@@ -1385,13 +1383,13 @@  discard block
 block discarded – undo
1385 1383
  *
1386 1384
  * @return int $purchase Donation ID.
1387 1385
  */
1388
-function give_get_purchase_id_by_transaction_id( $key ) {
1386
+function give_get_purchase_id_by_transaction_id($key) {
1389 1387
 	global $wpdb;
1390
-	$meta_table = __give_v20_bc_table_details( 'payment' );
1388
+	$meta_table = __give_v20_bc_table_details('payment');
1391 1389
 
1392
-	$purchase = $wpdb->get_var( $wpdb->prepare( "SELECT {$meta_table['column']['id']} FROM {$meta_table['name']} WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key ) );
1390
+	$purchase = $wpdb->get_var($wpdb->prepare("SELECT {$meta_table['column']['id']} FROM {$meta_table['name']} WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key));
1393 1391
 
1394
-	if ( $purchase != null ) {
1392
+	if ($purchase != null) {
1395 1393
 		return $purchase;
1396 1394
 	}
1397 1395
 
@@ -1408,23 +1406,23 @@  discard block
 block discarded – undo
1408 1406
  *
1409 1407
  * @return array $notes Donation Notes
1410 1408
  */
1411
-function give_get_payment_notes( $payment_id = 0, $search = '' ) {
1409
+function give_get_payment_notes($payment_id = 0, $search = '') {
1412 1410
 
1413
-	if ( empty( $payment_id ) && empty( $search ) ) {
1411
+	if (empty($payment_id) && empty($search)) {
1414 1412
 		return false;
1415 1413
 	}
1416 1414
 
1417
-	remove_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1418
-	remove_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10 );
1415
+	remove_action('pre_get_comments', 'give_hide_payment_notes', 10);
1416
+	remove_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10);
1419 1417
 
1420
-	$notes = get_comments( array(
1418
+	$notes = get_comments(array(
1421 1419
 		'post_id' => $payment_id,
1422 1420
 		'order'   => 'ASC',
1423 1421
 		'search'  => $search,
1424
-	) );
1422
+	));
1425 1423
 
1426
-	add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1427
-	add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 );
1424
+	add_action('pre_get_comments', 'give_hide_payment_notes', 10);
1425
+	add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2);
1428 1426
 
1429 1427
 	return $notes;
1430 1428
 }
@@ -1440,8 +1438,8 @@  discard block
 block discarded – undo
1440 1438
  *
1441 1439
  * @return int The new note ID
1442 1440
  */
1443
-function give_insert_payment_note( $payment_id = 0, $note = '' ) {
1444
-	if ( empty( $payment_id ) ) {
1441
+function give_insert_payment_note($payment_id = 0, $note = '') {
1442
+	if (empty($payment_id)) {
1445 1443
 		return false;
1446 1444
 	}
1447 1445
 
@@ -1453,14 +1451,14 @@  discard block
 block discarded – undo
1453 1451
 	 *
1454 1452
 	 * @since 1.0
1455 1453
 	 */
1456
-	do_action( 'give_pre_insert_payment_note', $payment_id, $note );
1454
+	do_action('give_pre_insert_payment_note', $payment_id, $note);
1457 1455
 
1458
-	$note_id = wp_insert_comment( wp_filter_comment( array(
1456
+	$note_id = wp_insert_comment(wp_filter_comment(array(
1459 1457
 		'comment_post_ID'      => $payment_id,
1460 1458
 		'comment_content'      => $note,
1461 1459
 		'user_id'              => is_admin() ? get_current_user_id() : 0,
1462
-		'comment_date'         => current_time( 'mysql' ),
1463
-		'comment_date_gmt'     => current_time( 'mysql', 1 ),
1460
+		'comment_date'         => current_time('mysql'),
1461
+		'comment_date_gmt'     => current_time('mysql', 1),
1464 1462
 		'comment_approved'     => 1,
1465 1463
 		'comment_parent'       => 0,
1466 1464
 		'comment_author'       => '',
@@ -1469,7 +1467,7 @@  discard block
 block discarded – undo
1469 1467
 		'comment_author_email' => '',
1470 1468
 		'comment_type'         => 'give_payment_note',
1471 1469
 
1472
-	) ) );
1470
+	)));
1473 1471
 
1474 1472
 	/**
1475 1473
 	 * Fires after payment note inserted.
@@ -1480,7 +1478,7 @@  discard block
 block discarded – undo
1480 1478
 	 *
1481 1479
 	 * @since 1.0
1482 1480
 	 */
1483
-	do_action( 'give_insert_payment_note', $note_id, $payment_id, $note );
1481
+	do_action('give_insert_payment_note', $note_id, $payment_id, $note);
1484 1482
 
1485 1483
 	return $note_id;
1486 1484
 }
@@ -1495,8 +1493,8 @@  discard block
 block discarded – undo
1495 1493
  *
1496 1494
  * @return bool True on success, false otherwise.
1497 1495
  */
1498
-function give_delete_payment_note( $comment_id = 0, $payment_id = 0 ) {
1499
-	if ( empty( $comment_id ) ) {
1496
+function give_delete_payment_note($comment_id = 0, $payment_id = 0) {
1497
+	if (empty($comment_id)) {
1500 1498
 		return false;
1501 1499
 	}
1502 1500
 
@@ -1508,9 +1506,9 @@  discard block
 block discarded – undo
1508 1506
 	 *
1509 1507
 	 * @since 1.0
1510 1508
 	 */
1511
-	do_action( 'give_pre_delete_payment_note', $comment_id, $payment_id );
1509
+	do_action('give_pre_delete_payment_note', $comment_id, $payment_id);
1512 1510
 
1513
-	$ret = wp_delete_comment( $comment_id, true );
1511
+	$ret = wp_delete_comment($comment_id, true);
1514 1512
 
1515 1513
 	/**
1516 1514
 	 * Fires after donation note deleted.
@@ -1520,7 +1518,7 @@  discard block
 block discarded – undo
1520 1518
 	 *
1521 1519
 	 * @since 1.0
1522 1520
 	 */
1523
-	do_action( 'give_post_delete_payment_note', $comment_id, $payment_id );
1521
+	do_action('give_post_delete_payment_note', $comment_id, $payment_id);
1524 1522
 
1525 1523
 	return $ret;
1526 1524
 }
@@ -1535,32 +1533,32 @@  discard block
 block discarded – undo
1535 1533
  *
1536 1534
  * @return string
1537 1535
  */
1538
-function give_get_payment_note_html( $note, $payment_id = 0 ) {
1536
+function give_get_payment_note_html($note, $payment_id = 0) {
1539 1537
 
1540
-	if ( is_numeric( $note ) ) {
1541
-		$note = get_comment( $note );
1538
+	if (is_numeric($note)) {
1539
+		$note = get_comment($note);
1542 1540
 	}
1543 1541
 
1544
-	if ( ! empty( $note->user_id ) ) {
1545
-		$user = get_userdata( $note->user_id );
1542
+	if ( ! empty($note->user_id)) {
1543
+		$user = get_userdata($note->user_id);
1546 1544
 		$user = $user->display_name;
1547 1545
 	} else {
1548
-		$user = __( 'System', 'give' );
1546
+		$user = __('System', 'give');
1549 1547
 	}
1550 1548
 
1551
-	$date_format = give_date_format() . ', ' . get_option( 'time_format' );
1549
+	$date_format = give_date_format().', '.get_option('time_format');
1552 1550
 
1553
-	$delete_note_url = wp_nonce_url( add_query_arg( array(
1551
+	$delete_note_url = wp_nonce_url(add_query_arg(array(
1554 1552
 		'give-action' => 'delete_payment_note',
1555 1553
 		'note_id'     => $note->comment_ID,
1556 1554
 		'payment_id'  => $payment_id,
1557
-	) ), 'give_delete_payment_note_' . $note->comment_ID );
1555
+	)), 'give_delete_payment_note_'.$note->comment_ID);
1558 1556
 
1559
-	$note_html = '<div class="give-payment-note" id="give-payment-note-' . $note->comment_ID . '">';
1557
+	$note_html = '<div class="give-payment-note" id="give-payment-note-'.$note->comment_ID.'">';
1560 1558
 	$note_html .= '<p>';
1561
-	$note_html .= '<strong>' . $user . '</strong>&nbsp;&ndash;&nbsp;<span style="color:#aaa;font-style:italic;">' . date_i18n( $date_format, strtotime( $note->comment_date ) ) . '</span><br/>';
1559
+	$note_html .= '<strong>'.$user.'</strong>&nbsp;&ndash;&nbsp;<span style="color:#aaa;font-style:italic;">'.date_i18n($date_format, strtotime($note->comment_date)).'</span><br/>';
1562 1560
 	$note_html .= $note->comment_content;
1563
-	$note_html .= '&nbsp;&ndash;&nbsp;<a href="' . esc_url( $delete_note_url ) . '" class="give-delete-payment-note" data-note-id="' . absint( $note->comment_ID ) . '" data-payment-id="' . absint( $payment_id ) . '" aria-label="' . __( 'Delete this donation note.', 'give' ) . '">' . __( 'Delete', 'give' ) . '</a>';
1561
+	$note_html .= '&nbsp;&ndash;&nbsp;<a href="'.esc_url($delete_note_url).'" class="give-delete-payment-note" data-note-id="'.absint($note->comment_ID).'" data-payment-id="'.absint($payment_id).'" aria-label="'.__('Delete this donation note.', 'give').'">'.__('Delete', 'give').'</a>';
1564 1562
 	$note_html .= '</p>';
1565 1563
 	$note_html .= '</div>';
1566 1564
 
@@ -1578,18 +1576,18 @@  discard block
 block discarded – undo
1578 1576
  *
1579 1577
  * @return void
1580 1578
  */
1581
-function give_hide_payment_notes( $query ) {
1582
-	if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '>=' ) ) {
1583
-		$types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array();
1584
-		if ( ! is_array( $types ) ) {
1585
-			$types = array( $types );
1579
+function give_hide_payment_notes($query) {
1580
+	if (version_compare(floatval(get_bloginfo('version')), '4.1', '>=')) {
1581
+		$types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array();
1582
+		if ( ! is_array($types)) {
1583
+			$types = array($types);
1586 1584
 		}
1587 1585
 		$types[]                           = 'give_payment_note';
1588 1586
 		$query->query_vars['type__not_in'] = $types;
1589 1587
 	}
1590 1588
 }
1591 1589
 
1592
-add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1590
+add_action('pre_get_comments', 'give_hide_payment_notes', 10);
1593 1591
 
1594 1592
 /**
1595 1593
  * Exclude notes (comments) on give_payment post type from showing in Recent Comments widgets
@@ -1601,15 +1599,15 @@  discard block
 block discarded – undo
1601 1599
  *
1602 1600
  * @return array $clauses Updated comment clauses.
1603 1601
  */
1604
-function give_hide_payment_notes_pre_41( $clauses, $wp_comment_query ) {
1605
-	if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '<' ) ) {
1602
+function give_hide_payment_notes_pre_41($clauses, $wp_comment_query) {
1603
+	if (version_compare(floatval(get_bloginfo('version')), '4.1', '<')) {
1606 1604
 		$clauses['where'] .= ' AND comment_type != "give_payment_note"';
1607 1605
 	}
1608 1606
 
1609 1607
 	return $clauses;
1610 1608
 }
1611 1609
 
1612
-add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 );
1610
+add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2);
1613 1611
 
1614 1612
 
1615 1613
 /**
@@ -1622,15 +1620,15 @@  discard block
 block discarded – undo
1622 1620
  *
1623 1621
  * @return string $where
1624 1622
  */
1625
-function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) {
1623
+function give_hide_payment_notes_from_feeds($where, $wp_comment_query) {
1626 1624
 	global $wpdb;
1627 1625
 
1628
-	$where .= $wpdb->prepare( ' AND comment_type != %s', 'give_payment_note' );
1626
+	$where .= $wpdb->prepare(' AND comment_type != %s', 'give_payment_note');
1629 1627
 
1630 1628
 	return $where;
1631 1629
 }
1632 1630
 
1633
-add_filter( 'comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2 );
1631
+add_filter('comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2);
1634 1632
 
1635 1633
 
1636 1634
 /**
@@ -1644,32 +1642,32 @@  discard block
 block discarded – undo
1644 1642
  *
1645 1643
  * @return array|object Array of comment counts.
1646 1644
  */
1647
-function give_remove_payment_notes_in_comment_counts( $stats, $post_id ) {
1645
+function give_remove_payment_notes_in_comment_counts($stats, $post_id) {
1648 1646
 	global $wpdb, $pagenow;
1649 1647
 
1650
-	if ( 'index.php' != $pagenow ) {
1648
+	if ('index.php' != $pagenow) {
1651 1649
 		return $stats;
1652 1650
 	}
1653 1651
 
1654 1652
 	$post_id = (int) $post_id;
1655 1653
 
1656
-	if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) {
1654
+	if (apply_filters('give_count_payment_notes_in_comments', false)) {
1657 1655
 		return $stats;
1658 1656
 	}
1659 1657
 
1660
-	$stats = Give_Cache::get_group( "comments-{$post_id}", 'counts' );
1658
+	$stats = Give_Cache::get_group("comments-{$post_id}", 'counts');
1661 1659
 
1662
-	if ( ! is_null( $stats ) ) {
1660
+	if ( ! is_null($stats)) {
1663 1661
 		return $stats;
1664 1662
 	}
1665 1663
 
1666 1664
 	$where = 'WHERE comment_type != "give_payment_note"';
1667 1665
 
1668
-	if ( $post_id > 0 ) {
1669
-		$where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id );
1666
+	if ($post_id > 0) {
1667
+		$where .= $wpdb->prepare(' AND comment_post_ID = %d', $post_id);
1670 1668
 	}
1671 1669
 
1672
-	$count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A );
1670
+	$count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A);
1673 1671
 
1674 1672
 	$total    = 0;
1675 1673
 	$approved = array(
@@ -1679,30 +1677,30 @@  discard block
 block discarded – undo
1679 1677
 		'trash'        => 'trash',
1680 1678
 		'post-trashed' => 'post-trashed',
1681 1679
 	);
1682
-	foreach ( (array) $count as $row ) {
1680
+	foreach ((array) $count as $row) {
1683 1681
 		// Don't count post-trashed toward totals.
1684
-		if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) {
1682
+		if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) {
1685 1683
 			$total += $row['num_comments'];
1686 1684
 		}
1687
-		if ( isset( $approved[ $row['comment_approved'] ] ) ) {
1688
-			$stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments'];
1685
+		if (isset($approved[$row['comment_approved']])) {
1686
+			$stats[$approved[$row['comment_approved']]] = $row['num_comments'];
1689 1687
 		}
1690 1688
 	}
1691 1689
 
1692 1690
 	$stats['total_comments'] = $total;
1693
-	foreach ( $approved as $key ) {
1694
-		if ( empty( $stats[ $key ] ) ) {
1695
-			$stats[ $key ] = 0;
1691
+	foreach ($approved as $key) {
1692
+		if (empty($stats[$key])) {
1693
+			$stats[$key] = 0;
1696 1694
 		}
1697 1695
 	}
1698 1696
 
1699 1697
 	$stats = (object) $stats;
1700
-	Give_Cache::set_group( "comments-{$post_id}", $stats, 'counts' );
1698
+	Give_Cache::set_group("comments-{$post_id}", $stats, 'counts');
1701 1699
 
1702 1700
 	return $stats;
1703 1701
 }
1704 1702
 
1705
-add_filter( 'wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2 );
1703
+add_filter('wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2);
1706 1704
 
1707 1705
 
1708 1706
 /**
@@ -1715,9 +1713,9 @@  discard block
 block discarded – undo
1715 1713
  *
1716 1714
  * @return string $where Modified where clause.
1717 1715
  */
1718
-function give_filter_where_older_than_week( $where = '' ) {
1716
+function give_filter_where_older_than_week($where = '') {
1719 1717
 	// Payments older than one week.
1720
-	$start = date( 'Y-m-d', strtotime( '-7 days' ) );
1718
+	$start = date('Y-m-d', strtotime('-7 days'));
1721 1719
 	$where .= " AND post_date <= '{$start}'";
1722 1720
 
1723 1721
 	return $where;
@@ -1737,13 +1735,13 @@  discard block
 block discarded – undo
1737 1735
  *
1738 1736
  * @return string $form_title Returns the full title if $only_level is false, otherwise returns the levels title.
1739 1737
  */
1740
-function give_get_donation_form_title( $donation, $args = array() ) {
1738
+function give_get_donation_form_title($donation, $args = array()) {
1741 1739
 
1742
-	if ( ! $donation instanceof Give_Payment ) {
1743
-		$donation = new Give_Payment( $donation );
1740
+	if ( ! $donation instanceof Give_Payment) {
1741
+		$donation = new Give_Payment($donation);
1744 1742
 	}
1745 1743
 
1746
-	if( ! $donation->ID ) {
1744
+	if ( ! $donation->ID) {
1747 1745
 		return '';
1748 1746
 	}
1749 1747
 
@@ -1752,7 +1750,7 @@  discard block
 block discarded – undo
1752 1750
 		'separator'  => '',
1753 1751
 	);
1754 1752
 
1755
-	$args = wp_parse_args( $args, $defaults );
1753
+	$args = wp_parse_args($args, $defaults);
1756 1754
 
1757 1755
 	$form_id     = $donation->form_id;
1758 1756
 	$price_id    = $donation->price_id;
@@ -1773,39 +1771,39 @@  discard block
 block discarded – undo
1773 1771
 		, false
1774 1772
 	);
1775 1773
 
1776
-	$form_title_html = Give_Cache::get_db_query( $cache_key );
1774
+	$form_title_html = Give_Cache::get_db_query($cache_key);
1777 1775
 
1778
-	if ( is_null( $form_title_html ) ) {
1779
-		if ( true === $only_level ) {
1776
+	if (is_null($form_title_html)) {
1777
+		if (true === $only_level) {
1780 1778
 			$form_title = '';
1781 1779
 		}
1782 1780
 
1783 1781
 		$form_title_html = $form_title;
1784 1782
 
1785
-		if ( 'custom' === $price_id ) {
1783
+		if ('custom' === $price_id) {
1786 1784
 
1787
-			$custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true );
1788
-			$level_label        = ! empty( $custom_amount_text ) ? $custom_amount_text : __( 'Custom Amount', 'give' );
1785
+			$custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true);
1786
+			$level_label        = ! empty($custom_amount_text) ? $custom_amount_text : __('Custom Amount', 'give');
1789 1787
 
1790 1788
 			// Show custom amount level only in backend otherwise hide it.
1791
-			if( 'set' === give_get_meta( $form_id, '_give_price_option', true ) && ! is_admin()  ) {
1789
+			if ('set' === give_get_meta($form_id, '_give_price_option', true) && ! is_admin()) {
1792 1790
 				$level_label = '';
1793 1791
 			}
1794 1792
 
1795
-		} elseif ( give_has_variable_prices( $form_id ) ) {
1796
-			$level_label = give_get_price_option_name( $form_id, $price_id, $donation->ID, false );
1793
+		} elseif (give_has_variable_prices($form_id)) {
1794
+			$level_label = give_get_price_option_name($form_id, $price_id, $donation->ID, false);
1797 1795
 		}
1798 1796
 
1799 1797
 		// Only add separator if there is a form title.
1800 1798
 		if (
1801
-			! empty( $form_title_html ) &&
1802
-			! empty( $level_label )
1799
+			! empty($form_title_html) &&
1800
+			! empty($level_label)
1803 1801
 		) {
1804 1802
 			$form_title_html .= " {$separator} ";
1805 1803
 		}
1806 1804
 
1807 1805
 		$form_title_html .= "<span class=\"donation-level-text-wrap\">{$level_label}</span>";
1808
-		Give_Cache::set_db_query( $cache_key, $form_title_html );
1806
+		Give_Cache::set_db_query($cache_key, $form_title_html);
1809 1807
 	}
1810 1808
 
1811 1809
 	/**
@@ -1813,7 +1811,7 @@  discard block
 block discarded – undo
1813 1811
 	 *
1814 1812
 	 * @since 1.0
1815 1813
 	 */
1816
-	return apply_filters( 'give_get_donation_form_title', $form_title_html, $donation->payment_meta, $donation );
1814
+	return apply_filters('give_get_donation_form_title', $form_title_html, $donation->payment_meta, $donation);
1817 1815
 }
1818 1816
 
1819 1817
 /**
@@ -1826,19 +1824,19 @@  discard block
 block discarded – undo
1826 1824
  *
1827 1825
  * @return string $price_id
1828 1826
  */
1829
-function give_get_price_id( $form_id, $price ) {
1827
+function give_get_price_id($form_id, $price) {
1830 1828
 	$price_id = null;
1831 1829
 
1832
-	if ( give_has_variable_prices( $form_id ) ) {
1830
+	if (give_has_variable_prices($form_id)) {
1833 1831
 
1834
-		$levels = give_get_meta( $form_id, '_give_donation_levels', true );
1832
+		$levels = give_get_meta($form_id, '_give_donation_levels', true);
1835 1833
 
1836
-		foreach ( $levels as $level ) {
1834
+		foreach ($levels as $level) {
1837 1835
 
1838
-			$level_amount = give_maybe_sanitize_amount( $level['_give_amount'] );
1836
+			$level_amount = give_maybe_sanitize_amount($level['_give_amount']);
1839 1837
 
1840 1838
 			// Check that this indeed the recurring price.
1841
-			if ( $level_amount == $price ) {
1839
+			if ($level_amount == $price) {
1842 1840
 
1843 1841
 				$price_id = $level['_give_id']['level_id'];
1844 1842
 				break;
@@ -1846,13 +1844,13 @@  discard block
 block discarded – undo
1846 1844
 			}
1847 1845
 		}
1848 1846
 
1849
-		if ( is_null( $price_id ) && give_is_custom_price_mode( $form_id ) ) {
1847
+		if (is_null($price_id) && give_is_custom_price_mode($form_id)) {
1850 1848
 			$price_id = 'custom';
1851 1849
 		}
1852 1850
 	}
1853 1851
 
1854 1852
 	// Price ID must be numeric or string.
1855
-	$price_id = ! is_numeric( $price_id ) && ! is_string( $price_id ) ? 0 : $price_id;
1853
+	$price_id = ! is_numeric($price_id) && ! is_string($price_id) ? 0 : $price_id;
1856 1854
 
1857 1855
 	/**
1858 1856
 	 * Filter the price id
@@ -1862,7 +1860,7 @@  discard block
 block discarded – undo
1862 1860
 	 * @param string $price_id
1863 1861
 	 * @param int    $form_id
1864 1862
 	 */
1865
-	return apply_filters( 'give_get_price_id', $price_id, $form_id );
1863
+	return apply_filters('give_get_price_id', $price_id, $form_id);
1866 1864
 }
1867 1865
 
1868 1866
 /**
@@ -1878,10 +1876,10 @@  discard block
 block discarded – undo
1878 1876
  *
1879 1877
  * @return string
1880 1878
  */
1881
-function give_get_form_dropdown( $args = array(), $echo = false ) {
1882
-	$form_dropdown_html = Give()->html->forms_dropdown( $args );
1879
+function give_get_form_dropdown($args = array(), $echo = false) {
1880
+	$form_dropdown_html = Give()->html->forms_dropdown($args);
1883 1881
 
1884
-	if ( ! $echo ) {
1882
+	if ( ! $echo) {
1885 1883
 		return $form_dropdown_html;
1886 1884
 	}
1887 1885
 
@@ -1898,17 +1896,17 @@  discard block
 block discarded – undo
1898 1896
  *
1899 1897
  * @return string|bool
1900 1898
  */
1901
-function give_get_form_variable_price_dropdown( $args = array(), $echo = false ) {
1899
+function give_get_form_variable_price_dropdown($args = array(), $echo = false) {
1902 1900
 
1903 1901
 	// Check for give form id.
1904
-	if ( empty( $args['id'] ) ) {
1902
+	if (empty($args['id'])) {
1905 1903
 		return false;
1906 1904
 	}
1907 1905
 
1908
-	$form = new Give_Donate_Form( $args['id'] );
1906
+	$form = new Give_Donate_Form($args['id']);
1909 1907
 
1910 1908
 	// Check if form has variable prices or not.
1911
-	if ( ! $form->ID || ! $form->has_variable_prices() ) {
1909
+	if ( ! $form->ID || ! $form->has_variable_prices()) {
1912 1910
 		return false;
1913 1911
 	}
1914 1912
 
@@ -1916,24 +1914,24 @@  discard block
 block discarded – undo
1916 1914
 	$variable_price_options = array();
1917 1915
 
1918 1916
 	// Check if multi donation form support custom donation or not.
1919
-	if ( $form->is_custom_price_mode() ) {
1920
-		$variable_price_options['custom'] = _x( 'Custom', 'custom donation dropdown item', 'give' );
1917
+	if ($form->is_custom_price_mode()) {
1918
+		$variable_price_options['custom'] = _x('Custom', 'custom donation dropdown item', 'give');
1921 1919
 	}
1922 1920
 
1923 1921
 	// Get variable price and ID from variable price array.
1924
-	foreach ( $variable_prices as $variable_price ) {
1925
-		$variable_price_options[ $variable_price['_give_id']['level_id'] ] = ! empty( $variable_price['_give_text'] ) ? $variable_price['_give_text'] : give_currency_filter( give_format_amount( $variable_price['_give_amount'], array( 'sanitize' => false ) ) );
1922
+	foreach ($variable_prices as $variable_price) {
1923
+		$variable_price_options[$variable_price['_give_id']['level_id']] = ! empty($variable_price['_give_text']) ? $variable_price['_give_text'] : give_currency_filter(give_format_amount($variable_price['_give_amount'], array('sanitize' => false)));
1926 1924
 	}
1927 1925
 
1928 1926
 	// Update options.
1929
-	$args = array_merge( $args, array(
1927
+	$args = array_merge($args, array(
1930 1928
 		'options' => $variable_price_options,
1931
-	) );
1929
+	));
1932 1930
 
1933 1931
 	// Generate select html.
1934
-	$form_dropdown_html = Give()->html->select( $args );
1932
+	$form_dropdown_html = Give()->html->select($args);
1935 1933
 
1936
-	if ( ! $echo ) {
1934
+	if ( ! $echo) {
1937 1935
 		return $form_dropdown_html;
1938 1936
 	}
1939 1937
 
@@ -1952,14 +1950,14 @@  discard block
 block discarded – undo
1952 1950
  *
1953 1951
  * @return string
1954 1952
  */
1955
-function give_get_payment_meta_price_id( $payment_meta ) {
1953
+function give_get_payment_meta_price_id($payment_meta) {
1956 1954
 
1957
-	if ( isset( $payment_meta['give_price_id'] ) ) {
1955
+	if (isset($payment_meta['give_price_id'])) {
1958 1956
 		$price_id = $payment_meta['give_price_id'];
1959
-	} elseif ( isset( $payment_meta['price_id'] ) ) {
1957
+	} elseif (isset($payment_meta['price_id'])) {
1960 1958
 		$price_id = $payment_meta['price_id'];
1961 1959
 	} else {
1962
-		$price_id = give_get_price_id( $payment_meta['give_form_id'], $payment_meta['price'] );
1960
+		$price_id = give_get_price_id($payment_meta['give_form_id'], $payment_meta['price']);
1963 1961
 	}
1964 1962
 
1965 1963
 	/**
@@ -1970,6 +1968,6 @@  discard block
 block discarded – undo
1970 1968
 	 * @param string $price_id
1971 1969
 	 * @param array  $payment_meta
1972 1970
 	 */
1973
-	return apply_filters( 'give_get_payment_meta_price_id', $price_id, $payment_meta );
1971
+	return apply_filters('give_get_payment_meta_price_id', $price_id, $payment_meta);
1974 1972
 
1975 1973
 }
Please login to merge, or discard this patch.
includes/class-give-db-form-meta.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 		/* @var WPDB $wpdb */
51 51
 		global $wpdb;
52 52
 
53
-		$wpdb->formmeta    = $this->table_name = $wpdb->prefix . 'give_formmeta';
53
+		$wpdb->formmeta    = $this->table_name = $wpdb->prefix.'give_formmeta';
54 54
 		$this->primary_key = 'meta_id';
55 55
 		$this->version     = '1.0';
56 56
 
@@ -84,6 +84,6 @@  discard block
 block discarded – undo
84 84
 	 * @return bool
85 85
 	 */
86 86
 	protected function is_custom_meta_table_active() {
87
-		return give_has_upgrade_completed( 'v20_move_metadata_into_new_table' );
87
+		return give_has_upgrade_completed('v20_move_metadata_into_new_table');
88 88
 	}
89 89
 }
Please login to merge, or discard this patch.