Test Failed
Push — master ( 1d3b59...426730 )
by Devin
01:16
created
includes/filters.php 1 patch
Spacing   +43 added lines, -45 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -26,34 +26,34 @@  discard block
 block discarded – undo
26 26
  *
27 27
  * @return void
28 28
  */
29
-function give_set_settings_with_disable_prefix( $old_settings, $settings ) {
29
+function give_set_settings_with_disable_prefix($old_settings, $settings) {
30 30
 	// Bailout.
31
-	if ( ! function_exists( 'give_v18_renamed_core_settings' ) ) {
31
+	if ( ! function_exists('give_v18_renamed_core_settings')) {
32 32
 		return;
33 33
 	}
34 34
 
35 35
 	// Get old setting names.
36
-	$old_settings   = array_flip( give_v18_renamed_core_settings() );
36
+	$old_settings   = array_flip(give_v18_renamed_core_settings());
37 37
 	$update_setting = false;
38 38
 
39
-	foreach ( $settings as $key => $value ) {
39
+	foreach ($settings as $key => $value) {
40 40
 
41 41
 		// Check 1. Check if new option is really updated or not.
42 42
 		// Check 2. Continue if key is not renamed.
43
-		if ( ! isset( $old_settings[ $key ] ) ) {
43
+		if ( ! isset($old_settings[$key])) {
44 44
 			continue;
45 45
 		}
46 46
 
47 47
 		// Set old setting.
48
-		$settings[ $old_settings[ $key ] ] = 'on';
48
+		$settings[$old_settings[$key]] = 'on';
49 49
 
50 50
 		// Do not need to set old setting if new setting is not set.
51 51
 		if (
52
-			( give_is_setting_enabled( $value ) && ( false !== strpos( $old_settings[ $key ], 'disable_' ) ) )
53
-			|| ( ! give_is_setting_enabled( $value ) && ( false !== strpos( $old_settings[ $key ], 'enable_' ) ) )
52
+			(give_is_setting_enabled($value) && (false !== strpos($old_settings[$key], 'disable_')))
53
+			|| ( ! give_is_setting_enabled($value) && (false !== strpos($old_settings[$key], 'enable_')))
54 54
 
55 55
 		) {
56
-			unset( $settings[ $old_settings[ $key ] ] );
56
+			unset($settings[$old_settings[$key]]);
57 57
 		}
58 58
 
59 59
 		// Tell bot to update setting.
@@ -61,12 +61,12 @@  discard block
 block discarded – undo
61 61
 	}
62 62
 
63 63
 	// Update setting if any old setting set.
64
-	if ( $update_setting ) {
65
-		update_option( 'give_settings', $settings );
64
+	if ($update_setting) {
65
+		update_option('give_settings', $settings);
66 66
 	}
67 67
 }
68 68
 
69
-add_action( 'update_option_give_settings', 'give_set_settings_with_disable_prefix', 10, 2 );
69
+add_action('update_option_give_settings', 'give_set_settings_with_disable_prefix', 10, 2);
70 70
 
71 71
 /**
72 72
  * Check spam through Akismet.
@@ -80,45 +80,45 @@  discard block
 block discarded – undo
80 80
  *
81 81
  * @return bool|mixed
82 82
  */
83
-function give_akismet( $spam ) {
83
+function give_akismet($spam) {
84 84
 
85 85
 	// Bail out, If spam.
86
-	if ( $spam ) {
86
+	if ($spam) {
87 87
 		return $spam;
88 88
 	}
89 89
 
90 90
 	// Bail out, if Akismet key not exist.
91
-	if ( ! give_check_akismet_key() ) {
91
+	if ( ! give_check_akismet_key()) {
92 92
 		return false;
93 93
 	}
94 94
 
95 95
 	// Build args array.
96 96
 	$args = array();
97 97
 
98
-	$args['comment_author']       = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : '';
99
-	$args['comment_author_email'] = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false;
100
-	$args['blog']                 = get_option( 'home' );
98
+	$args['comment_author']       = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : '';
99
+	$args['comment_author_email'] = isset($_POST['give_email']) ? $_POST['give_email'] : false;
100
+	$args['blog']                 = get_option('home');
101 101
 	$args['blog_lang']            = get_locale();
102
-	$args['blog_charset']         = get_option( 'blog_charset' );
102
+	$args['blog_charset']         = get_option('blog_charset');
103 103
 	$args['user_ip']              = $_SERVER['REMOTE_ADDR'];
104 104
 	$args['user_agent']           = $_SERVER['HTTP_USER_AGENT'];
105 105
 	$args['referrer']             = $_SERVER['HTTP_REFERER'];
106 106
 	$args['comment_type']         = 'contact-form';
107 107
 
108
-	$ignore = array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' );
108
+	$ignore = array('HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW');
109 109
 
110
-	foreach ( $_SERVER as $key => $value ) {
111
-		if ( ! in_array( $key, (array) $ignore ) ) {
110
+	foreach ($_SERVER as $key => $value) {
111
+		if ( ! in_array($key, (array) $ignore)) {
112 112
 			$args["$key"] = $value;
113 113
 		}
114 114
 	}
115 115
 
116 116
 	// It will return Akismet spam detect API response.
117
-	return give_akismet_spam_check( $args );
117
+	return give_akismet_spam_check($args);
118 118
 
119 119
 }
120 120
 
121
-add_filter( 'give_spam', 'give_akismet' );
121
+add_filter('give_spam', 'give_akismet');
122 122
 
123 123
 /**
124 124
  * Check Akismet API Key.
@@ -128,11 +128,11 @@  discard block
 block discarded – undo
128 128
  * @return bool
129 129
  */
130 130
 function give_check_akismet_key() {
131
-	if ( is_callable( array( 'Akismet', 'get_api_key' ) ) ) { // Akismet v3.0+
131
+	if (is_callable(array('Akismet', 'get_api_key'))) { // Akismet v3.0+
132 132
 		return (bool) Akismet::get_api_key();
133 133
 	}
134 134
 
135
-	if ( function_exists( 'akismet_get_key' ) ) {
135
+	if (function_exists('akismet_get_key')) {
136 136
 		return (bool) akismet_get_key();
137 137
 	}
138 138
 
@@ -148,26 +148,26 @@  discard block
 block discarded – undo
148 148
  *
149 149
  * @return bool|mixed
150 150
  */
151
-function give_akismet_spam_check( $args ) {
151
+function give_akismet_spam_check($args) {
152 152
 	global $akismet_api_host, $akismet_api_port;
153 153
 
154 154
 	$spam         = false;
155
-	$query_string = http_build_query( $args );
155
+	$query_string = http_build_query($args);
156 156
 
157
-	if ( is_callable( array( 'Akismet', 'http_post' ) ) ) { // Akismet v3.0+
158
-		$response = Akismet::http_post( $query_string, 'comment-check' );
157
+	if (is_callable(array('Akismet', 'http_post'))) { // Akismet v3.0+
158
+		$response = Akismet::http_post($query_string, 'comment-check');
159 159
 	} else {
160
-		$response = akismet_http_post( $query_string, $akismet_api_host,
161
-			'/1.1/comment-check', $akismet_api_port );
160
+		$response = akismet_http_post($query_string, $akismet_api_host,
161
+			'/1.1/comment-check', $akismet_api_port);
162 162
 	}
163 163
 
164 164
 	// It's spam if response status is true.
165
-	if ( 'true' === $response[1] ) {
165
+	if ('true' === $response[1]) {
166 166
 		$spam = true;
167 167
 	}
168 168
 
169 169
 	// Allow developer to modified Akismet spam detection response.
170
-	return apply_filters( 'give_akismet_spam_check', $spam, $args );
170
+	return apply_filters('give_akismet_spam_check', $spam, $args);
171 171
 }
172 172
 
173 173
 /**
@@ -180,15 +180,15 @@  discard block
 block discarded – undo
180 180
  *
181 181
  * @return array
182 182
  */
183
-function give_bc_v1817_iranian_currency_code( $currencies ) {
184
-	if ( ! give_has_upgrade_completed( 'v1817_update_donation_iranian_currency_code' ) ) {
183
+function give_bc_v1817_iranian_currency_code($currencies) {
184
+	if ( ! give_has_upgrade_completed('v1817_update_donation_iranian_currency_code')) {
185 185
 		$currencies['RIAL'] = $currencies['IRR'];
186 186
 	}
187 187
 
188 188
 	return $currencies;
189 189
 }
190 190
 
191
-add_filter( 'give_currencies', 'give_bc_v1817_iranian_currency_code', 0 );
191
+add_filter('give_currencies', 'give_bc_v1817_iranian_currency_code', 0);
192 192
 
193 193
 
194 194
 /**
@@ -202,22 +202,20 @@  discard block
 block discarded – undo
202 202
  *
203 203
  * @return string
204 204
  */
205
-function give_format_price_for_right_to_left_supported_currency( $formatted_amount, $currency_args, $price ) {
206
-	if ( ! give_is_right_to_left_supported_currency( $currency_args['currency_code'] ) ) {
205
+function give_format_price_for_right_to_left_supported_currency($formatted_amount, $currency_args, $price) {
206
+	if ( ! give_is_right_to_left_supported_currency($currency_args['currency_code'])) {
207 207
 		return $formatted_amount;
208 208
 	}
209 209
 
210 210
 	$formatted_amount = (
211 211
 	'before' === (string) $currency_args['position'] ?
212
-		'‫' . $price . $currency_args['symbol'] . '‬' :
213
-		'‪' . $price . $currency_args['symbol'] . '‬'
212
+		'‫'.$price.$currency_args['symbol'].'‬' : '‪'.$price.$currency_args['symbol'].'‬'
214 213
 	);
215 214
 
216 215
 	$formatted_amount = $currency_args['decode_currency'] ?
217
-		html_entity_decode( $formatted_amount, ENT_COMPAT, 'UTF-8' ) :
218
-		$formatted_amount;
216
+		html_entity_decode($formatted_amount, ENT_COMPAT, 'UTF-8') : $formatted_amount;
219 217
 
220 218
 	return $formatted_amount;
221 219
 }
222 220
 
223
-add_filter( 'give_currency_filter', 'give_format_price_for_right_to_left_supported_currency', 10, 3 );
224 221
\ No newline at end of file
222
+add_filter('give_currency_filter', 'give_format_price_for_right_to_left_supported_currency', 10, 3);
225 223
\ No newline at end of file
Please login to merge, or discard this patch.
templates/history-donations.php 2 patches
Braces   +8 added lines, -3 removed lines patch added patch discarded remove patch
@@ -186,7 +186,8 @@  discard block
 block discarded – undo
186 186
 								__( 'View', 'give' ) . ' ' . give_get_payment_status( $post, true ) . ' »'
187 187
 							);
188 188
 
189
-						else :
189
+						else {
190
+							:
190 191
 							echo sprintf(
191 192
 								'<a href="%1$s">%2$s</a>',
192 193
 								esc_url(
@@ -198,6 +199,7 @@  discard block
 block discarded – undo
198 199
 								),
199 200
 								__( 'View Receipt &raquo;', 'give' )
200 201
 							);
202
+						}
201 203
 
202 204
 						endif;
203 205
 						?>
@@ -242,6 +244,9 @@  discard block
 block discarded – undo
242 244
 		</div>
243 245
 	</div>
244 246
 	<?php wp_reset_postdata(); ?>
245
-<?php else : ?>
246
-	<?php Give()->notices->print_frontend_notice( __( 'It looks like you haven\'t made any donations.', 'give' ), true, 'success' ); ?>
247
+<?php else {
248
+	: ?>
249
+	<?php Give()->notices->print_frontend_notice( __( 'It looks like you haven\'t made any donations.', 'give' ), true, 'success' );
250
+}
251
+?>
247 252
 <?php endif;
248 253
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -4,56 +4,56 @@  discard block
 block discarded – undo
4 4
  */
5 5
 
6 6
 $donations             = array();
7
-$donation_history_args = Give()->session->get( 'give_donation_history_args' );
7
+$donation_history_args = Give()->session->get('give_donation_history_args');
8 8
 
9 9
 // User's Donations.
10
-if ( is_user_logged_in() ) {
11
-	$donations = give_get_users_donations( get_current_user_id(), 20, true, 'any' );
12
-} elseif ( Give()->email_access->token_exists ) {
10
+if (is_user_logged_in()) {
11
+	$donations = give_get_users_donations(get_current_user_id(), 20, true, 'any');
12
+} elseif (Give()->email_access->token_exists) {
13 13
 	// Email Access Token?
14
-	$donations = give_get_users_donations( 0, 20, true, 'any' );
14
+	$donations = give_get_users_donations(0, 20, true, 'any');
15 15
 } elseif (
16 16
 	false !== Give()->session->get_session_expiration() ||
17 17
 	true === give_get_history_session()
18 18
 ) {
19 19
 	// Session active?
20
-	$email           = Give()->session->get( 'give_email' );
21
-	$donor           = Give()->donors->get_donor_by( 'email', $email );
22
-	$donations_count = count( explode( ',', $donor->payment_ids ) );
20
+	$email           = Give()->session->get('give_email');
21
+	$donor           = Give()->donors->get_donor_by('email', $email);
22
+	$donations_count = count(explode(',', $donor->payment_ids));
23 23
 
24
-	if( $donations_count > give_get_limit_display_donations() ) {
24
+	if ($donations_count > give_get_limit_display_donations()) {
25 25
 
26 26
 		// Restrict Security Email Access option, if donation count of a donor is less than or equal to limit.
27
-		if( true !== Give_Cache::get( "give_cache_email_throttle_limit_exhausted_{$donor->id}" ) ) {
28
-			add_action( 'give_donation_history_table_end', 'give_donation_history_table_end' );
27
+		if (true !== Give_Cache::get("give_cache_email_throttle_limit_exhausted_{$donor->id}")) {
28
+			add_action('give_donation_history_table_end', 'give_donation_history_table_end');
29 29
 		} else {
30 30
 			$value = Give()->email_access->verify_throttle / 60;
31 31
 
32
-			give_set_error( 'give-limited-throttle', sprintf(
33
-				__( 'Too many access email requests detected. Please wait %s before requesting a new donation history access link.', 'give' ),
34
-				sprintf( _n( '%s minute', '%s minutes', $value, 'give' ), $value )
35
-			) );
32
+			give_set_error('give-limited-throttle', sprintf(
33
+				__('Too many access email requests detected. Please wait %s before requesting a new donation history access link.', 'give'),
34
+				sprintf(_n('%s minute', '%s minutes', $value, 'give'), $value)
35
+			));
36 36
 
37 37
 		}
38 38
 
39
-		$donations = give_get_users_donations( $email, give_get_limit_display_donations(), true, 'any' );
39
+		$donations = give_get_users_donations($email, give_get_limit_display_donations(), true, 'any');
40 40
 	} else {
41
-		$donations = give_get_users_donations( $email, 20, true, 'any' );
41
+		$donations = give_get_users_donations($email, 20, true, 'any');
42 42
 	}
43 43
 }
44 44
 
45
-Give()->notices->render_frontend_notices( 0 );
45
+Give()->notices->render_frontend_notices(0);
46 46
 
47
-if ( $donations ) : ?>
47
+if ($donations) : ?>
48 48
 	<?php
49 49
 	$table_headings = array(
50
-		'id'             => __( 'ID', 'give' ),
51
-		'date'           => __( 'Date', 'give' ),
52
-		'donor'          => __( 'Donor', 'give' ),
53
-		'amount'         => __( 'Amount', 'give' ),
54
-		'status'         => __( 'Status', 'give' ),
55
-		'payment_method' => __( 'Payment Method', 'give' ),
56
-		'details'        => __( 'Details', 'give' ),
50
+		'id'             => __('ID', 'give'),
51
+		'date'           => __('Date', 'give'),
52
+		'donor'          => __('Donor', 'give'),
53
+		'amount'         => __('Amount', 'give'),
54
+		'status'         => __('Status', 'give'),
55
+		'payment_method' => __('Payment Method', 'give'),
56
+		'details'        => __('Details', 'give'),
57 57
 	);
58 58
 	?>
59 59
 	<div class="give_user_history_main" >
@@ -69,14 +69,14 @@  discard block
 block discarded – undo
69 69
 				 *
70 70
 				 * @since 1.7
71 71
 				 */
72
-				do_action( 'give_donation_history_header_before' );
72
+				do_action('give_donation_history_header_before');
73 73
 
74
-				foreach ( $donation_history_args as $index => $value ) {
75
-					if ( filter_var( $donation_history_args[ $index ], FILTER_VALIDATE_BOOLEAN ) ) :
74
+				foreach ($donation_history_args as $index => $value) {
75
+					if (filter_var($donation_history_args[$index], FILTER_VALIDATE_BOOLEAN)) :
76 76
 						echo sprintf(
77 77
 							'<th scope="col" class="give-donation-%1$s>">%2$s</th>',
78 78
 							$index,
79
-							$table_headings[ $index ]
79
+							$table_headings[$index]
80 80
 						);
81 81
 					endif;
82 82
 				}
@@ -88,13 +88,13 @@  discard block
 block discarded – undo
88 88
 				 *
89 89
 				 * @since 1.7
90 90
 				 */
91
-				do_action( 'give_donation_history_header_after' );
91
+				do_action('give_donation_history_header_after');
92 92
 				?>
93 93
 			</tr>
94 94
 			</thead>
95
-			<?php foreach ( $donations as $post ) :
96
-				setup_postdata( $post );
97
-				$donation_data = give_get_payment_meta( $post->ID ); ?>
95
+			<?php foreach ($donations as $post) :
96
+				setup_postdata($post);
97
+				$donation_data = give_get_payment_meta($post->ID); ?>
98 98
 				<tr class="give-donation-row">
99 99
 					<?php
100 100
 					/**
@@ -107,36 +107,36 @@  discard block
 block discarded – undo
107 107
 					 * @param int   $post_id       The ID of the post.
108 108
 					 * @param mixed $donation_data Payment meta data.
109 109
 					 */
110
-					do_action( 'give_donation_history_row_start', $post->ID, $donation_data );
110
+					do_action('give_donation_history_row_start', $post->ID, $donation_data);
111 111
 
112
-					if ( filter_var( $donation_history_args['id'], FILTER_VALIDATE_BOOLEAN ) ) :
112
+					if (filter_var($donation_history_args['id'], FILTER_VALIDATE_BOOLEAN)) :
113 113
 						echo sprintf(
114 114
 							'<td class="give-donation-id">#%1$s</td>',
115
-							give_get_payment_number( $post->ID )
115
+							give_get_payment_number($post->ID)
116 116
 						);
117 117
 					endif;
118 118
 
119
-					if ( filter_var( $donation_history_args['date'], FILTER_VALIDATE_BOOLEAN ) ) :
119
+					if (filter_var($donation_history_args['date'], FILTER_VALIDATE_BOOLEAN)) :
120 120
 						echo sprintf(
121 121
 							'<td class="give-donation-date">%1$s</td>',
122
-							date_i18n( give_date_format(), strtotime( get_post_field( 'post_date', $post->ID ) ) )
122
+							date_i18n(give_date_format(), strtotime(get_post_field('post_date', $post->ID)))
123 123
 						);
124 124
 					endif;
125 125
 
126
-					if ( filter_var( $donation_history_args['donor'], FILTER_VALIDATE_BOOLEAN ) ) :
126
+					if (filter_var($donation_history_args['donor'], FILTER_VALIDATE_BOOLEAN)) :
127 127
 						echo sprintf(
128 128
 							'<td class="give-donation-donor">%1$s</td>',
129
-							give_get_donor_name_by( $post->ID )
129
+							give_get_donor_name_by($post->ID)
130 130
 						);
131 131
 					endif;
132 132
 					?>
133 133
 
134
-					<?php if ( filter_var( $donation_history_args['amount'], FILTER_VALIDATE_BOOLEAN ) ) : ?>
134
+					<?php if (filter_var($donation_history_args['amount'], FILTER_VALIDATE_BOOLEAN)) : ?>
135 135
 						<td class="give-donation-amount">
136 136
 						<span class="give-donation-amount">
137 137
 							<?php
138
-							$currency_code   = give_get_payment_currency_code( $post->ID );
139
-							$donation_amount = give_donation_amount( $post->ID, true );
138
+							$currency_code   = give_get_payment_currency_code($post->ID);
139
+							$donation_amount = give_donation_amount($post->ID, true);
140 140
 
141 141
 							/**
142 142
 							 * Filters the donation amount on Donation History Page.
@@ -148,42 +148,42 @@  discard block
 block discarded – undo
148 148
 							 *
149 149
 							 * @return int
150 150
 							 */
151
-							echo apply_filters( 'give_donation_history_row_amount', $donation_amount, $post->ID );
151
+							echo apply_filters('give_donation_history_row_amount', $donation_amount, $post->ID);
152 152
 							?>
153 153
 						</span>
154 154
 						</td>
155 155
 					<?php endif; ?>
156 156
 
157 157
 					<?php
158
-					if ( filter_var( $donation_history_args['status'], FILTER_VALIDATE_BOOLEAN ) ) :
158
+					if (filter_var($donation_history_args['status'], FILTER_VALIDATE_BOOLEAN)) :
159 159
 						echo sprintf(
160 160
 							'<td class="give-donation-status">%1$s</td>',
161
-							give_get_payment_status( $post, true )
161
+							give_get_payment_status($post, true)
162 162
 						);
163 163
 					endif;
164 164
 
165
-					if ( filter_var( $donation_history_args['payment_method'], FILTER_VALIDATE_BOOLEAN ) ) :
165
+					if (filter_var($donation_history_args['payment_method'], FILTER_VALIDATE_BOOLEAN)) :
166 166
 						echo sprintf(
167 167
 							'<td class="give-donation-payment-method">%1$s</td>',
168
-							give_get_gateway_checkout_label( give_get_payment_gateway( $post->ID ) )
168
+							give_get_gateway_checkout_label(give_get_payment_gateway($post->ID))
169 169
 						);
170 170
 					endif;
171 171
 					?>
172 172
 					<td class="give-donation-details">
173 173
 						<?php
174 174
 						// Display View Receipt or.
175
-						if ( 'publish' !== $post->post_status && 'subscription' !== $post->post_status ) :
175
+						if ('publish' !== $post->post_status && 'subscription' !== $post->post_status) :
176 176
 							echo sprintf(
177 177
 								'<a href="%1$s"><span class="give-donation-status %2$s">%3$s</span></a>',
178 178
 								esc_url(
179 179
 									add_query_arg(
180 180
 										'payment_key',
181
-										give_get_payment_key( $post->ID ),
181
+										give_get_payment_key($post->ID),
182 182
 										give_get_history_page_uri()
183 183
 									)
184 184
 								),
185 185
 								$post->post_status,
186
-								__( 'View', 'give' ) . ' ' . give_get_payment_status( $post, true ) . ' &raquo;'
186
+								__('View', 'give').' '.give_get_payment_status($post, true).' &raquo;'
187 187
 							);
188 188
 
189 189
 						else :
@@ -192,11 +192,11 @@  discard block
 block discarded – undo
192 192
 								esc_url(
193 193
 									add_query_arg(
194 194
 										'payment_key',
195
-										give_get_payment_key( $post->ID ),
195
+										give_get_payment_key($post->ID),
196 196
 										give_get_history_page_uri()
197 197
 									)
198 198
 								),
199
-								__( 'View Receipt &raquo;', 'give' )
199
+								__('View Receipt &raquo;', 'give')
200 200
 							);
201 201
 
202 202
 						endif;
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 					 * @param int   $post_id       The ID of the post.
214 214
 					 * @param mixed $donation_data Payment meta data.
215 215
 					 */
216
-					do_action( 'give_donation_history_row_end', $post->ID, $donation_data );
216
+					do_action('give_donation_history_row_end', $post->ID, $donation_data);
217 217
 					?>
218 218
 				</tr>
219 219
 			<?php endforeach; ?>
@@ -226,22 +226,22 @@  discard block
 block discarded – undo
226 226
 			 *
227 227
 			 * @since 1.8.17
228 228
 			 */
229
-			do_action( 'give_donation_history_table_end' );
229
+			do_action('give_donation_history_table_end');
230 230
 			?>
231 231
 		</table>
232 232
 		<div id="give-donation-history-pagination" class="give_pagination navigation">
233 233
 			<?php
234 234
 			$big = 999999;
235
-			echo paginate_links( array(
236
-				'base'    => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
235
+			echo paginate_links(array(
236
+				'base'    => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
237 237
 				'format'  => '?paged=%#%',
238
-				'current' => max( 1, get_query_var( 'paged' ) ),
239
-				'total'   => ceil( give_count_donations_of_donor() / 20 ) // 20 items per page
240
-			) );
238
+				'current' => max(1, get_query_var('paged')),
239
+				'total'   => ceil(give_count_donations_of_donor() / 20) // 20 items per page
240
+			));
241 241
 			?>
242 242
 		</div>
243 243
 	</div>
244 244
 	<?php wp_reset_postdata(); ?>
245 245
 <?php else : ?>
246
-	<?php Give()->notices->print_frontend_notice( __( 'It looks like you haven\'t made any donations.', 'give' ), true, 'success' ); ?>
246
+	<?php Give()->notices->print_frontend_notice(__('It looks like you haven\'t made any donations.', 'give'), true, 'success'); ?>
247 247
 <?php endif;
248 248
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/reports/class-gateways-reports-table.php 1 patch
Spacing   +48 added lines, -51 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@  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
 
17 17
 // Load WP_List_Table if not loaded
18
-if ( ! class_exists( 'WP_List_Table' ) ) {
19
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
18
+if ( ! class_exists('WP_List_Table')) {
19
+	require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
20 20
 }
21 21
 
22 22
 /**
@@ -45,11 +45,11 @@  discard block
 block discarded – undo
45 45
 		global $status, $page;
46 46
 
47 47
 		// Set parent defaults
48
-		parent::__construct( array(
49
-			'singular' => give_get_forms_label_singular(),    // Singular name of the listed records
50
-			'plural'   => give_get_forms_label_plural(),        // Plural name of the listed records
48
+		parent::__construct(array(
49
+			'singular' => give_get_forms_label_singular(), // Singular name of the listed records
50
+			'plural'   => give_get_forms_label_plural(), // Plural name of the listed records
51 51
 			'ajax'     => false                        // Does this table support ajax?
52
-		) );
52
+		));
53 53
 
54 54
 	}
55 55
 
@@ -64,12 +64,12 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 * @return string Column Name
66 66
 	 */
67
-	public function column_default( $item, $column_name ) {
68
-		$donation_list_page_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' );
67
+	public function column_default($item, $column_name) {
68
+		$donation_list_page_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history');
69 69
 
70
-		switch ( $column_name ) {
70
+		switch ($column_name) {
71 71
 			case 'complete_sales':
72
-				$value = $item[ $column_name ] ?
72
+				$value = $item[$column_name] ?
73 73
 					sprintf(
74 74
 						'<a href="%s">%s</a>',
75 75
 						add_query_arg(
@@ -79,13 +79,12 @@  discard block
 block discarded – undo
79 79
 							),
80 80
 							$donation_list_page_url
81 81
 						),
82
-						$item[ $column_name ]
83
-					) :
84
-					$item[ $column_name ];
82
+						$item[$column_name]
83
+					) : $item[$column_name];
85 84
 				break;
86 85
 
87 86
 			case 'pending_sales':
88
-				$value = $item[ $column_name ] ?
87
+				$value = $item[$column_name] ?
89 88
 					sprintf(
90 89
 						'<a href="%s">%s</a>',
91 90
 						add_query_arg(
@@ -95,13 +94,12 @@  discard block
 block discarded – undo
95 94
 							),
96 95
 							$donation_list_page_url
97 96
 						),
98
-						$item[ $column_name ]
99
-					) :
100
-					$item[ $column_name ];
97
+						$item[$column_name]
98
+					) : $item[$column_name];
101 99
 				break;
102 100
 
103 101
 			case 'total_sales':
104
-				$value = $item[ $column_name ] ?
102
+				$value = $item[$column_name] ?
105 103
 					sprintf(
106 104
 						'<a href="%s">%s</a>',
107 105
 						add_query_arg(
@@ -110,14 +108,13 @@  discard block
 block discarded – undo
110 108
 							),
111 109
 							$donation_list_page_url
112 110
 						),
113
-						$item[ $column_name ]
114
-					) :
115
-					$item[ $column_name ];
111
+						$item[$column_name]
112
+					) : $item[$column_name];
116 113
 
117 114
 				break;
118 115
 
119 116
 			default:
120
-				$value = $item[ $column_name ];
117
+				$value = $item[$column_name];
121 118
 		}
122 119
 
123 120
 		return $value;
@@ -132,11 +129,11 @@  discard block
 block discarded – undo
132 129
 	 */
133 130
 	public function get_columns() {
134 131
 		$columns = array(
135
-			'label'           => esc_attr__( 'Gateway', 'give' ),
136
-			'complete_sales'  => esc_attr__( 'Complete Payments', 'give' ),
137
-			'pending_sales'   => esc_attr__( 'Pending / Failed Payments', 'give' ),
138
-			'total_sales'     => esc_attr__( 'Total Payments', 'give' ),
139
-			'total_donations' => esc_attr__( 'Total Donated', 'give' )
132
+			'label'           => esc_attr__('Gateway', 'give'),
133
+			'complete_sales'  => esc_attr__('Complete Payments', 'give'),
134
+			'pending_sales'   => esc_attr__('Pending / Failed Payments', 'give'),
135
+			'total_sales'     => esc_attr__('Total Payments', 'give'),
136
+			'total_donations' => esc_attr__('Total Donated', 'give')
140 137
 		);
141 138
 
142 139
 		return $columns;
@@ -151,7 +148,7 @@  discard block
 block discarded – undo
151 148
 	 */
152 149
 	public function get_sortable_columns() {
153 150
 		return array(
154
-			'total_donations' => array( 'total_donations', false )
151
+			'total_donations' => array('total_donations', false)
155 152
 		);
156 153
 	}
157 154
 
@@ -164,7 +161,7 @@  discard block
 block discarded – undo
164 161
 	 * @return int Current page number
165 162
 	 */
166 163
 	public function get_paged() {
167
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
164
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
168 165
 	}
169 166
 
170 167
 
@@ -175,7 +172,7 @@  discard block
 block discarded – undo
175 172
 	 * @since  1.0
176 173
 	 * @return void
177 174
 	 */
178
-	public function bulk_actions( $which = '' ) {
175
+	public function bulk_actions($which = '') {
179 176
 
180 177
 	}
181 178
 
@@ -187,27 +184,27 @@  discard block
 block discarded – undo
187 184
 	 *
188 185
 	 * @param string $which
189 186
 	 */
190
-	protected function display_tablenav( $which ) {
187
+	protected function display_tablenav($which) {
191 188
 
192
-		if ( 'top' === $which ) {
193
-			wp_nonce_field( 'bulk-' . $this->_args['plural'] );
189
+		if ('top' === $which) {
190
+			wp_nonce_field('bulk-'.$this->_args['plural']);
194 191
 		}
195 192
 		?>
196
-		<div class="tablenav gateways-report-tablenav give-clearfix <?php echo esc_attr( $which ); ?>">
193
+		<div class="tablenav gateways-report-tablenav give-clearfix <?php echo esc_attr($which); ?>">
197 194
 
198
-			<?php if ( 'top' === $which ) { ?>
195
+			<?php if ('top' === $which) { ?>
199 196
 				<h2 class="alignleft reports-earnings-title screen-reader-text">
200
-					<?php _e( 'Donation Methods Report', 'give' ); ?>
197
+					<?php _e('Donation Methods Report', 'give'); ?>
201 198
 				</h2>
202 199
 			<?php } ?>
203 200
 
204 201
 			<div class="alignright tablenav-right">
205 202
 				<div class="actions bulkactions">
206
-					<?php $this->bulk_actions( $which ); ?>
203
+					<?php $this->bulk_actions($which); ?>
207 204
 				</div>
208 205
 				<?php
209
-				$this->extra_tablenav( $which );
210
-				$this->pagination( $which );
206
+				$this->extra_tablenav($which);
207
+				$this->pagination($which);
211 208
 				?>
212 209
 			</div>
213 210
 
@@ -229,17 +226,17 @@  discard block
 block discarded – undo
229 226
 	 *
230 227
 	 * @return int
231 228
 	 */
232
-	public function give_sort_total_donations( $old_value, $new_value ) {
229
+	public function give_sort_total_donations($old_value, $new_value) {
233 230
 		// If no sort, default to label.
234
-		$orderby = ( ! empty( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : 'label';
231
+		$orderby = ( ! empty($_REQUEST['orderby'])) ? $_REQUEST['orderby'] : 'label';
235 232
 
236 233
 		//If no order, default to asc.
237
-		$order = ( ! empty( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : 'asc';
234
+		$order = ( ! empty($_REQUEST['order'])) ? $_REQUEST['order'] : 'asc';
238 235
 
239 236
 		//Determine sort order.
240
-		$result = strcmp( $old_value[ $orderby ], $new_value[ $orderby ] );
237
+		$result = strcmp($old_value[$orderby], $new_value[$orderby]);
241 238
 
242
-		return ( $order === 'asc' ) ? $result : -$result;
239
+		return ($order === 'asc') ? $result : -$result;
243 240
 	}
244 241
 
245 242
 
@@ -256,10 +253,10 @@  discard block
 block discarded – undo
256 253
 		$gateways     = give_get_payment_gateways();
257 254
 		$stats        = new Give_Payment_Stats();
258 255
 
259
-		foreach ( $gateways as $gateway_id => $gateway ) {
256
+		foreach ($gateways as $gateway_id => $gateway) {
260 257
 
261
-			$complete_count = give_count_sales_by_gateway( $gateway_id, 'publish' );
262
-			$pending_count  = give_count_sales_by_gateway( $gateway_id, array( 'pending', 'failed' ) );
258
+			$complete_count = give_count_sales_by_gateway($gateway_id, 'publish');
259
+			$pending_count  = give_count_sales_by_gateway($gateway_id, array('pending', 'failed'));
263 260
 
264 261
 			$reports_data[] = array(
265 262
 				'ID'              => $gateway_id,
@@ -267,7 +264,7 @@  discard block
 block discarded – undo
267 264
 				'complete_sales'  => $complete_count,
268 265
 				'pending_sales'   => $pending_count,
269 266
 				'total_sales'     => $complete_count + $pending_count,
270
-				'total_donations' => give_currency_filter( give_format_amount( $stats->get_earnings( 0, strtotime('04/13/2015' ), current_time('timestamp' ), $gateway_id ), array( 'sanitize' => false ) ) ),
267
+				'total_donations' => give_currency_filter(give_format_amount($stats->get_earnings(0, strtotime('04/13/2015'), current_time('timestamp'), $gateway_id), array('sanitize' => false))),
271 268
 			);
272 269
 		}
273 270
 
@@ -288,11 +285,11 @@  discard block
 block discarded – undo
288 285
 		$columns               = $this->get_columns();
289 286
 		$hidden                = array(); // No hidden columns
290 287
 		$sortable              = $this->get_sortable_columns();
291
-		$this->_column_headers = array( $columns, $hidden, $sortable );
288
+		$this->_column_headers = array($columns, $hidden, $sortable);
292 289
 		$this->items           = $this->reports_data();
293 290
 
294 291
 		// Sort Array when we are sorting data in array.
295
-		usort( $this->items, array( $this, 'give_sort_total_donations' ) );
292
+		usort($this->items, array($this, 'give_sort_total_donations'));
296 293
 
297 294
 	}
298 295
 }
Please login to merge, or discard this patch.
includes/admin/upgrades/views/upgrades-complete.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,17 +10,17 @@
 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
 ?>
17 17
 <div class="wrap" id="poststuff">
18 18
 	<div id="give-updates">
19
-		<h1 id="give-updates-h1"><?php esc_html_e( 'Give - Updates Complete', 'give' ); ?></h1>
19
+		<h1 id="give-updates-h1"><?php esc_html_e('Give - Updates Complete', 'give'); ?></h1>
20 20
 		<hr class="wp-header-end">
21 21
 
22 22
 		<div class="give-update-panel-content">
23
-			<p><?php esc_html_e( 'Congratulations! You are running the latest versions of Give and its add-ons.', 'give' ); ?></p>
23
+			<p><?php esc_html_e('Congratulations! You are running the latest versions of Give and its add-ons.', 'give'); ?></p>
24 24
 		</div>
25 25
 
26 26
 	</div>
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-all-stats.php 1 patch
Spacing   +95 added lines, -97 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -80,108 +80,106 @@  discard block
 block discarded – undo
80 80
 	 */
81 81
 	public function get_data() {
82 82
 
83
-		$totals             = $this->get_stored_data( 'give_temp_recount_all_stats' );
84
-		$payment_items      = $this->get_stored_data( 'give_temp_payment_items' );
85
-		$processed_payments = $this->get_stored_data( 'give_temp_processed_payments' );
86
-		$accepted_statuses  = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
83
+		$totals             = $this->get_stored_data('give_temp_recount_all_stats');
84
+		$payment_items      = $this->get_stored_data('give_temp_payment_items');
85
+		$processed_payments = $this->get_stored_data('give_temp_processed_payments');
86
+		$accepted_statuses  = apply_filters('give_recount_accepted_statuses', array('publish'));
87 87
 
88
-		if ( false === $totals ) {
88
+		if (false === $totals) {
89 89
 			$totals = array();
90 90
 		}
91 91
 
92
-		if ( false === $payment_items ) {
92
+		if (false === $payment_items) {
93 93
 			$payment_items = array();
94 94
 		}
95 95
 
96
-		if ( false === $processed_payments ) {
96
+		if (false === $processed_payments) {
97 97
 			$processed_payments = array();
98 98
 		}
99 99
 
100
-		$all_forms = $this->get_stored_data( 'give_temp_form_ids' );
100
+		$all_forms = $this->get_stored_data('give_temp_form_ids');
101 101
 
102
-		$payments = $this->get_stored_data( 'give_temp_all_payments_data' );
102
+		$payments = $this->get_stored_data('give_temp_all_payments_data');
103 103
 
104
-		if ( empty( $payments ) ) {
105
-			$args = apply_filters( 'give_recount_form_stats_args', array(
104
+		if (empty($payments)) {
105
+			$args = apply_filters('give_recount_form_stats_args', array(
106 106
 				'give_forms' => $all_forms,
107 107
 				'number'     => $this->per_step,
108 108
 				'status'     => $accepted_statuses,
109 109
 				'paged'      => $this->step,
110 110
 				'output'     => 'give_payments',
111
-			) );
111
+			));
112 112
 
113
-			$payments_query = new Give_Payments_Query( $args );
113
+			$payments_query = new Give_Payments_Query($args);
114 114
 			$payments       = $payments_query->get_payments();
115 115
 		}
116 116
 
117
-		if ( ! empty( $payments ) ) {
117
+		if ( ! empty($payments)) {
118 118
 
119 119
 			//Loop through payments
120
-			foreach ( $payments as $payment ) {
120
+			foreach ($payments as $payment) {
121 121
 
122
-				$payment_id = ( ! empty( $payment['ID'] ) ? absint( $payment['ID'] ) : ( ! empty( $payment->ID ) ? absint( $payment->ID ) : false ) );
123
-				$payment = new Give_Payment( $payment_id );
122
+				$payment_id = ( ! empty($payment['ID']) ? absint($payment['ID']) : ( ! empty($payment->ID) ? absint($payment->ID) : false));
123
+				$payment = new Give_Payment($payment_id);
124 124
 
125 125
 				// Prevent payments that have all ready been retrieved from a previous sales log from counting again.
126
-				if ( in_array( $payment->ID, $processed_payments ) ) {
126
+				if (in_array($payment->ID, $processed_payments)) {
127 127
 					continue;
128 128
 				}
129 129
 
130 130
 				// Verify accepted status.
131
-				if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
131
+				if ( ! in_array($payment->post_status, $accepted_statuses)) {
132 132
 					$processed_payments[] = $payment->ID;
133 133
 					continue;
134 134
 				}
135 135
 
136
-				$payment_item = $payment_items[ $payment->ID ];
136
+				$payment_item = $payment_items[$payment->ID];
137 137
 
138
-				$form_id = isset( $payment_item['id'] ) ? $payment_item['id'] : '';
138
+				$form_id = isset($payment_item['id']) ? $payment_item['id'] : '';
139 139
 
140 140
 				// Must have a form ID.
141
-				if ( empty( $form_id ) ) {
141
+				if (empty($form_id)) {
142 142
 					continue;
143 143
 				}
144 144
 
145 145
 				// Form ID must be within $all_forms array to be validated.
146
-				if ( ! in_array( $form_id, $all_forms ) ) {
146
+				if ( ! in_array($form_id, $all_forms)) {
147 147
 					continue;
148 148
 				}
149 149
 
150 150
 				// Set Sales count
151
-				$totals[ $form_id ]['sales'] = isset( $totals[ $form_id ]['sales'] ) ?
152
-					++ $totals[ $form_id ]['sales'] :
153
-					1;
151
+				$totals[$form_id]['sales'] = isset($totals[$form_id]['sales']) ?
152
+					++$totals[$form_id]['sales'] : 1;
154 153
 
155 154
 				// Set Total Earnings
156
-				$totals[ $form_id ]['earnings'] = isset( $totals[ $form_id ]['earnings'] ) ?
157
-					( $totals[ $form_id ]['earnings'] + $payment_item['price'] ) :
158
-					$payment_item['price'];
155
+				$totals[$form_id]['earnings'] = isset($totals[$form_id]['earnings']) ?
156
+					($totals[$form_id]['earnings'] + $payment_item['price']) : $payment_item['price'];
159 157
 
160 158
 				$processed_payments[] = $payment->ID;
161 159
 			}
162 160
 
163 161
 			// Get the list of form ids which does not contain any payment record.
164
-			$remaining_form_ids = array_diff( $all_forms, array_keys( $totals ) );
165
-			foreach ( $remaining_form_ids as $form_id ) {
162
+			$remaining_form_ids = array_diff($all_forms, array_keys($totals));
163
+			foreach ($remaining_form_ids as $form_id) {
166 164
 				//If array key doesn't exist, create it
167
-				if ( ! array_key_exists( $form_id, $totals ) ) {
168
-					$totals[ $form_id ] = array(
165
+				if ( ! array_key_exists($form_id, $totals)) {
166
+					$totals[$form_id] = array(
169 167
 						'sales'    => (int) 0,
170 168
 						'earnings' => (float) 0,
171 169
 					);
172 170
 				}
173 171
 			}
174 172
 
175
-			$this->store_data( 'give_temp_processed_payments', $processed_payments );
176
-			$this->store_data( 'give_temp_recount_all_stats', $totals );
173
+			$this->store_data('give_temp_processed_payments', $processed_payments);
174
+			$this->store_data('give_temp_recount_all_stats', $totals);
177 175
 
178 176
 			return true;
179 177
 		}
180 178
 
181 179
 
182
-		foreach ( $totals as $key => $stats ) {
183
-			give_update_meta( $key, '_give_form_sales', $stats['sales'] );
184
-			give_update_meta( $key, '_give_form_earnings', give_sanitize_amount_for_db( $stats['earnings'] ) );
180
+		foreach ($totals as $key => $stats) {
181
+			give_update_meta($key, '_give_form_sales', $stats['sales']);
182
+			give_update_meta($key, '_give_form_earnings', give_sanitize_amount_for_db($stats['earnings']));
185 183
 		}
186 184
 
187 185
 		return false;
@@ -196,20 +194,20 @@  discard block
 block discarded – undo
196 194
 	 */
197 195
 	public function get_percentage_complete() {
198 196
 
199
-		$total = $this->get_stored_data( 'give_recount_all_total' );
197
+		$total = $this->get_stored_data('give_recount_all_total');
200 198
 
201
-		if ( false === $total ) {
199
+		if (false === $total) {
202 200
 			$this->pre_fetch();
203
-			$total = $this->get_stored_data( 'give_recount_all_total' );
201
+			$total = $this->get_stored_data('give_recount_all_total');
204 202
 		}
205 203
 
206 204
 		$percentage = 100;
207 205
 
208
-		if ( $total > 0 ) {
209
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
206
+		if ($total > 0) {
207
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
210 208
 		}
211 209
 
212
-		if ( $percentage > 100 ) {
210
+		if ($percentage > 100) {
213 211
 			$percentage = 100;
214 212
 		}
215 213
 
@@ -223,8 +221,8 @@  discard block
 block discarded – undo
223 221
 	 *
224 222
 	 * @param array $request The Form Data passed into the batch processing
225 223
 	 */
226
-	public function set_properties( $request ) {
227
-		$this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false;
224
+	public function set_properties($request) {
225
+		$this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false;
228 226
 	}
229 227
 
230 228
 	/**
@@ -235,25 +233,25 @@  discard block
 block discarded – undo
235 233
 	 */
236 234
 	public function process_step() {
237 235
 
238
-		if ( ! $this->can_export() ) {
239
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
236
+		if ( ! $this->can_export()) {
237
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
240 238
 		}
241 239
 
242 240
 		$had_data = $this->get_data();
243 241
 
244
-		if ( $had_data ) {
242
+		if ($had_data) {
245 243
 			$this->done = false;
246 244
 
247 245
 			return true;
248 246
 		} else {
249
-			$this->delete_data( 'give_recount_total_' . $this->form_id );
250
-			$this->delete_data( 'give_recount_all_total' );
251
-			$this->delete_data( 'give_temp_recount_all_stats' );
252
-			$this->delete_data( 'give_temp_payment_items' );
253
-			$this->delete_data( 'give_temp_form_ids' );
254
-			$this->delete_data( 'give_temp_processed_payments' );
247
+			$this->delete_data('give_recount_total_'.$this->form_id);
248
+			$this->delete_data('give_recount_all_total');
249
+			$this->delete_data('give_temp_recount_all_stats');
250
+			$this->delete_data('give_temp_payment_items');
251
+			$this->delete_data('give_temp_form_ids');
252
+			$this->delete_data('give_temp_processed_payments');
255 253
 			$this->done    = true;
256
-			$this->message = esc_html__( 'Donation form income amounts and donation counts stats successfully recounted.', 'give' );
254
+			$this->message = esc_html__('Donation form income amounts and donation counts stats successfully recounted.', 'give');
257 255
 
258 256
 			return false;
259 257
 		}
@@ -289,70 +287,70 @@  discard block
 block discarded – undo
289 287
 	 */
290 288
 	public function pre_fetch() {
291 289
 
292
-		if ( 1 == $this->step ) {
293
-			$this->delete_data( 'give_temp_recount_all_total' );
294
-			$this->delete_data( 'give_temp_recount_all_stats' );
295
-			$this->delete_data( 'give_temp_payment_items' );
296
-			$this->delete_data( 'give_temp_processed_payments' );
297
-			$this->delete_data( 'give_temp_all_payments_data' );
290
+		if (1 == $this->step) {
291
+			$this->delete_data('give_temp_recount_all_total');
292
+			$this->delete_data('give_temp_recount_all_stats');
293
+			$this->delete_data('give_temp_payment_items');
294
+			$this->delete_data('give_temp_processed_payments');
295
+			$this->delete_data('give_temp_all_payments_data');
298 296
 		}
299 297
 
300
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
301
-		$total             = $this->get_stored_data( 'give_temp_recount_all_total' );
298
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
299
+		$total             = $this->get_stored_data('give_temp_recount_all_total');
302 300
 
303
-		if ( false === $total ) {
301
+		if (false === $total) {
304 302
 
305
-			$payment_items = $this->get_stored_data( 'give_temp_payment_items' );
303
+			$payment_items = $this->get_stored_data('give_temp_payment_items');
306 304
 
307
-			if ( false === $payment_items ) {
305
+			if (false === $payment_items) {
308 306
 				$payment_items = array();
309
-				$this->store_data( 'give_temp_payment_items', $payment_items );
307
+				$this->store_data('give_temp_payment_items', $payment_items);
310 308
 			}
311 309
 
312 310
 			$args = array(
313 311
 				'post_status'    => 'publish',
314 312
 				'post_type'      => 'give_forms',
315
-				'posts_per_page' => - 1,
313
+				'posts_per_page' => -1,
316 314
 				'fields'         => 'ids',
317 315
 			);
318 316
 
319
-			$all_forms = get_posts( $args );
317
+			$all_forms = get_posts($args);
320 318
 
321
-			$this->store_data( 'give_temp_form_ids', $all_forms );
319
+			$this->store_data('give_temp_form_ids', $all_forms);
322 320
 
323
-			$args = apply_filters( 'give_recount_form_stats_total_args', array(
321
+			$args = apply_filters('give_recount_form_stats_total_args', array(
324 322
 				'give_forms' => $all_forms,
325 323
 				'number'     => $this->per_step,
326 324
 				'status'     => $accepted_statuses,
327 325
 				'page'       => $this->step,
328 326
 				'output'     => 'payments',
329
-			) );
327
+			));
330 328
 
331
-			$payments_query = new Give_Payments_Query( $args );
329
+			$payments_query = new Give_Payments_Query($args);
332 330
 			$payments       = $payments_query->get_payments();
333 331
 
334
-			$total = wp_count_posts( 'give_payment' )->publish;
332
+			$total = wp_count_posts('give_payment')->publish;
335 333
 
336
-			$this->store_data( 'give_temp_all_payments_data', $payments );
334
+			$this->store_data('give_temp_all_payments_data', $payments);
337 335
 
338
-			if ( $payments ) {
336
+			if ($payments) {
339 337
 
340
-				foreach ( $payments as $payment ) {
338
+				foreach ($payments as $payment) {
341 339
 
342 340
 					$form_id = $payment->form_id;
343 341
 
344 342
 					//If for some reason somehow the form_ID isn't set check payment meta
345
-					if ( empty( $payment->form_id ) ) {
343
+					if (empty($payment->form_id)) {
346 344
 						$payment_meta = $payment->get_meta();
347
-						$form_id      = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0;
345
+						$form_id      = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0;
348 346
 					}
349 347
 
350
-					if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
348
+					if ( ! in_array($payment->post_status, $accepted_statuses)) {
351 349
 						continue;
352 350
 					}
353 351
 
354
-					if ( ! array_key_exists( $payment->ID, $payment_items ) ) {
355
-						$payment_items[ $payment->ID ] = array(
352
+					if ( ! array_key_exists($payment->ID, $payment_items)) {
353
+						$payment_items[$payment->ID] = array(
356 354
 							'id'         => $form_id,
357 355
 							'payment_id' => $payment->ID,
358 356
 							'price'      => $payment->total,
@@ -360,8 +358,8 @@  discard block
 block discarded – undo
360 358
 					}
361 359
 				}
362 360
 			}
363
-			$this->store_data( 'give_temp_payment_items', $payment_items );
364
-			$this->store_data( 'give_recount_all_total', $total );
361
+			$this->store_data('give_temp_payment_items', $payment_items);
362
+			$this->store_data('give_recount_all_total', $total);
365 363
 		}
366 364
 
367 365
 	}
@@ -375,17 +373,17 @@  discard block
 block discarded – undo
375 373
 	 *
376 374
 	 * @return mixed       Returns the data from the database
377 375
 	 */
378
-	private function get_stored_data( $key ) {
376
+	private function get_stored_data($key) {
379 377
 		global $wpdb;
380
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
381
-		if ( empty( $value ) ) {
378
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
379
+		if (empty($value)) {
382 380
 			return false;
383 381
 		}
384 382
 
385
-		$maybe_json = json_decode( $value );
383
+		$maybe_json = json_decode($value);
386 384
 
387
-		if ( ! is_null( $maybe_json ) ) {
388
-			$value = json_decode( $value, true );
385
+		if ( ! is_null($maybe_json)) {
386
+			$value = json_decode($value, true);
389 387
 		}
390 388
 
391 389
 		return $value;
@@ -401,10 +399,10 @@  discard block
 block discarded – undo
401 399
 	 *
402 400
 	 * @return void
403 401
 	 */
404
-	private function store_data( $key, $value ) {
402
+	private function store_data($key, $value) {
405 403
 		global $wpdb;
406 404
 
407
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
405
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
408 406
 
409 407
 		$data = array(
410 408
 			'option_name'  => $key,
@@ -418,7 +416,7 @@  discard block
 block discarded – undo
418 416
 			'%s',
419 417
 		);
420 418
 
421
-		$wpdb->replace( $wpdb->options, $data, $formats );
419
+		$wpdb->replace($wpdb->options, $data, $formats);
422 420
 	}
423 421
 
424 422
 	/**
@@ -430,9 +428,9 @@  discard block
 block discarded – undo
430 428
 	 *
431 429
 	 * @return void
432 430
 	 */
433
-	private function delete_data( $key ) {
431
+	private function delete_data($key) {
434 432
 		global $wpdb;
435
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
433
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
436 434
 	}
437 435
 
438 436
 }
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-single-donor-stats.php 1 patch
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -53,40 +53,40 @@  discard block
 block discarded – undo
53 53
 	 */
54 54
 	public function get_data() {
55 55
 
56
-		$donor    = new Give_Donor( $this->customer_id );
57
-		$payments = $this->get_stored_data( 'give_recount_donor_payments_' . $donor->id );
56
+		$donor    = new Give_Donor($this->customer_id);
57
+		$payments = $this->get_stored_data('give_recount_donor_payments_'.$donor->id);
58 58
 
59
-		$offset     = ( $this->step - 1 ) * $this->per_step;
60
-		$step_items = array_slice( $payments, $offset, $this->per_step );
59
+		$offset     = ($this->step - 1) * $this->per_step;
60
+		$step_items = array_slice($payments, $offset, $this->per_step);
61 61
 
62
-		if ( count( $step_items ) > 0 ) {
63
-			$pending_total = (float) $this->get_stored_data( 'give_stats_donor_pending_total' . $donor->id );
62
+		if (count($step_items) > 0) {
63
+			$pending_total = (float) $this->get_stored_data('give_stats_donor_pending_total'.$donor->id);
64 64
 			$step_total    = 0;
65 65
 
66
-			$found_payment_ids = $this->get_stored_data( 'give_stats_found_payments_' . $donor->id );
66
+			$found_payment_ids = $this->get_stored_data('give_stats_found_payments_'.$donor->id);
67 67
 
68
-			foreach ( $step_items as $payment ) {
69
-				$payment = get_post( $payment->ID );
68
+			foreach ($step_items as $payment) {
69
+				$payment = get_post($payment->ID);
70 70
 
71
-				if ( is_null( $payment ) || is_wp_error( $payment ) || 'give_payment' !== $payment->post_type ) {
71
+				if (is_null($payment) || is_wp_error($payment) || 'give_payment' !== $payment->post_type) {
72 72
 
73
-					$missing_payments   = $this->get_stored_data( 'give_stats_missing_payments' . $donor->id );
73
+					$missing_payments   = $this->get_stored_data('give_stats_missing_payments'.$donor->id);
74 74
 					$missing_payments[] = $payment->ID;
75
-					$this->store_data( 'give_stats_missing_payments' . $donor->id, $missing_payments );
75
+					$this->store_data('give_stats_missing_payments'.$donor->id, $missing_payments);
76 76
 
77 77
 					continue;
78 78
 				}
79 79
 
80 80
 				$should_process_payment = 'publish' == $payment->post_status ? true : false;
81
-				$should_process_payment = apply_filters( 'give_donor_recount_should_process_donation', $should_process_payment, $payment );
81
+				$should_process_payment = apply_filters('give_donor_recount_should_process_donation', $should_process_payment, $payment);
82 82
 
83
-				if ( true === $should_process_payment ) {
83
+				if (true === $should_process_payment) {
84 84
 
85 85
 					$found_payment_ids[] = $payment->ID;
86 86
 
87
-					if ( apply_filters( 'give_donor_recount_should_increase_value', true, $payment ) ) {
88
-						$payment_amount = (float) give_donation_amount( $payment->ID, array( 'type' => 'stats' ) );
89
-						$step_total     += $payment_amount;
87
+					if (apply_filters('give_donor_recount_should_increase_value', true, $payment)) {
88
+						$payment_amount = (float) give_donation_amount($payment->ID, array('type' => 'stats'));
89
+						$step_total += $payment_amount;
90 90
 					}
91 91
 
92 92
 				}
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
 			}
95 95
 
96 96
 			$updated_total = $pending_total + $step_total;
97
-			$this->store_data( 'give_stats_donor_pending_total' . $donor->id, $updated_total );
98
-			$this->store_data( 'give_stats_found_payments_' . $donor->id, $found_payment_ids );
97
+			$this->store_data('give_stats_donor_pending_total'.$donor->id, $updated_total);
98
+			$this->store_data('give_stats_found_payments_'.$donor->id, $found_payment_ids);
99 99
 
100 100
 			return true;
101 101
 		}
@@ -112,16 +112,16 @@  discard block
 block discarded – undo
112 112
 	 */
113 113
 	public function get_percentage_complete() {
114 114
 
115
-		$payments = $this->get_stored_data( 'give_recount_donor_payments_' . $this->customer_id );
116
-		$total    = count( $payments );
115
+		$payments = $this->get_stored_data('give_recount_donor_payments_'.$this->customer_id);
116
+		$total    = count($payments);
117 117
 
118 118
 		$percentage = 100;
119 119
 
120
-		if ( $total > 0 ) {
121
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
120
+		if ($total > 0) {
121
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
122 122
 		}
123 123
 
124
-		if ( $percentage > 100 ) {
124
+		if ($percentage > 100) {
125 125
 			$percentage = 100;
126 126
 		}
127 127
 
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
 	 *
136 136
 	 * @param array $request The Form Data passed into the batch processing
137 137
 	 */
138
-	public function set_properties( $request ) {
139
-		$this->customer_id = isset( $request['customer_id'] ) ? sanitize_text_field( $request['customer_id'] ) : false;
138
+	public function set_properties($request) {
139
+		$this->customer_id = isset($request['customer_id']) ? sanitize_text_field($request['customer_id']) : false;
140 140
 	}
141 141
 
142 142
 	/**
@@ -147,53 +147,53 @@  discard block
 block discarded – undo
147 147
 	 */
148 148
 	public function process_step() {
149 149
 
150
-		if ( ! $this->can_export() ) {
151
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
150
+		if ( ! $this->can_export()) {
151
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
152 152
 		}
153 153
 
154 154
 		$had_data = $this->get_data();
155 155
 
156
-		if ( $had_data ) {
156
+		if ($had_data) {
157 157
 			$this->done = false;
158 158
 
159 159
 			return true;
160 160
 		} else {
161
-			$donor       = new Give_Donor( $this->customer_id );
162
-			$payment_ids = get_option( 'give_stats_found_payments_' . $donor->id, array() );
163
-			$this->delete_data( 'give_stats_found_payments_' . $donor->id );
161
+			$donor       = new Give_Donor($this->customer_id);
162
+			$payment_ids = get_option('give_stats_found_payments_'.$donor->id, array());
163
+			$this->delete_data('give_stats_found_payments_'.$donor->id);
164 164
 
165
-			$removed_payments = array_unique( get_option( 'give_stats_missing_payments' . $donor->id, array() ) );
165
+			$removed_payments = array_unique(get_option('give_stats_missing_payments'.$donor->id, array()));
166 166
 
167 167
 			// Find non-existing payments (deleted) and total up the donation count
168 168
 			$purchase_count = 0;
169
-			foreach ( $payment_ids as $key => $payment_id ) {
170
-				if ( in_array( $payment_id, $removed_payments ) ) {
171
-					unset( $payment_ids[ $key ] );
169
+			foreach ($payment_ids as $key => $payment_id) {
170
+				if (in_array($payment_id, $removed_payments)) {
171
+					unset($payment_ids[$key]);
172 172
 					continue;
173 173
 				}
174 174
 
175
-				$payment = get_post( $payment_id );
176
-				if ( apply_filters( 'give_donor_recount_should_increase_count', true, $payment ) ) {
177
-					$purchase_count ++;
175
+				$payment = get_post($payment_id);
176
+				if (apply_filters('give_donor_recount_should_increase_count', true, $payment)) {
177
+					$purchase_count++;
178 178
 				}
179 179
 			}
180 180
 
181
-			$this->delete_data( 'give_stats_missing_payments' . $donor->id );
181
+			$this->delete_data('give_stats_missing_payments'.$donor->id);
182 182
 
183
-			$pending_total = $this->get_stored_data( 'give_stats_donor_pending_total' . $donor->id );
184
-			$this->delete_data( 'give_stats_donor_pending_total' . $donor->id );
185
-			$this->delete_data( 'give_recount_donor_stats_' . $donor->id );
186
-			$this->delete_data( 'give_recount_donor_payments_' . $this->customer_id );
183
+			$pending_total = $this->get_stored_data('give_stats_donor_pending_total'.$donor->id);
184
+			$this->delete_data('give_stats_donor_pending_total'.$donor->id);
185
+			$this->delete_data('give_recount_donor_stats_'.$donor->id);
186
+			$this->delete_data('give_recount_donor_payments_'.$this->customer_id);
187 187
 
188
-			$payment_ids = implode( ',', $payment_ids );
189
-			$donor->update( array(
188
+			$payment_ids = implode(',', $payment_ids);
189
+			$donor->update(array(
190 190
 				'payment_ids'    => $payment_ids,
191 191
 				'purchase_count' => $purchase_count,
192 192
 				'purchase_value' => $pending_total,
193
-			) );
193
+			));
194 194
 
195 195
 			$this->done    = true;
196
-			$this->message = esc_html__( 'Donor stats have been successfully recounted.', 'give' );
196
+			$this->message = esc_html__('Donor stats have been successfully recounted.', 'give');
197 197
 
198 198
 			return false;
199 199
 		}
@@ -226,26 +226,26 @@  discard block
 block discarded – undo
226 226
 	 * @return void
227 227
 	 */
228 228
 	public function pre_fetch() {
229
-		if ( $this->step === 1 ) {
230
-			$allowed_payment_status = apply_filters( 'give_recount_donors_donation_statuses', give_get_payment_status_keys() );
229
+		if ($this->step === 1) {
230
+			$allowed_payment_status = apply_filters('give_recount_donors_donation_statuses', give_get_payment_status_keys());
231 231
 
232 232
 			// Before we start, let's zero out the customer's data
233
-			$donor = new Give_Donor( $this->customer_id );
234
-			$donor->update( array( 'purchase_value' => give_format_amount( 0, array( 'sanitize' => false ) ), 'purchase_count' => 0 ) );
233
+			$donor = new Give_Donor($this->customer_id);
234
+			$donor->update(array('purchase_value' => give_format_amount(0, array('sanitize' => false)), 'purchase_count' => 0));
235 235
 
236
-			$attached_payment_ids = explode( ',', $donor->payment_ids );
236
+			$attached_payment_ids = explode(',', $donor->payment_ids);
237 237
 
238 238
 			$attached_args = array(
239 239
 				'post__in' => $attached_payment_ids,
240
-				'number'   => - 1,
240
+				'number'   => -1,
241 241
 				'status'   => $allowed_payment_status,
242 242
 			);
243 243
 
244
-			$attached_payments = give_get_payments( $attached_args );
244
+			$attached_payments = give_get_payments($attached_args);
245 245
 
246 246
 			$unattached_args = array(
247 247
 				'post__not_in' => $attached_payment_ids,
248
-				'number'       => - 1,
248
+				'number'       => -1,
249 249
 				'status'       => $allowed_payment_status,
250 250
 				'meta_query'   => array(
251 251
 					array(
@@ -255,11 +255,11 @@  discard block
 block discarded – undo
255 255
 				),
256 256
 			);
257 257
 
258
-			$unattached_payments = give_get_payments( $unattached_args );
258
+			$unattached_payments = give_get_payments($unattached_args);
259 259
 
260
-			$payments = array_merge( $attached_payments, $unattached_payments );
260
+			$payments = array_merge($attached_payments, $unattached_payments);
261 261
 
262
-			$this->store_data( 'give_recount_donor_payments_' . $donor->id, $payments );
262
+			$this->store_data('give_recount_donor_payments_'.$donor->id, $payments);
263 263
 		}
264 264
 	}
265 265
 
@@ -272,17 +272,17 @@  discard block
 block discarded – undo
272 272
 	 *
273 273
 	 * @return mixed       Returns the data from the database
274 274
 	 */
275
-	private function get_stored_data( $key ) {
275
+	private function get_stored_data($key) {
276 276
 		global $wpdb;
277
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
277
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
278 278
 
279
-		if ( empty( $value ) ) {
279
+		if (empty($value)) {
280 280
 			return false;
281 281
 		}
282 282
 
283
-		$maybe_json = json_decode( $value );
284
-		if ( ! is_null( $maybe_json ) ) {
285
-			$value = json_decode( $value, true );
283
+		$maybe_json = json_decode($value);
284
+		if ( ! is_null($maybe_json)) {
285
+			$value = json_decode($value, true);
286 286
 		}
287 287
 
288 288
 		return $value;
@@ -298,10 +298,10 @@  discard block
 block discarded – undo
298 298
 	 *
299 299
 	 * @return void
300 300
 	 */
301
-	private function store_data( $key, $value ) {
301
+	private function store_data($key, $value) {
302 302
 		global $wpdb;
303 303
 
304
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
304
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
305 305
 
306 306
 		$data = array(
307 307
 			'option_name'  => $key,
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 			'%s',
316 316
 		);
317 317
 
318
-		$wpdb->replace( $wpdb->options, $data, $formats );
318
+		$wpdb->replace($wpdb->options, $data, $formats);
319 319
 	}
320 320
 
321 321
 	/**
@@ -327,9 +327,9 @@  discard block
 block discarded – undo
327 327
 	 *
328 328
 	 * @return void
329 329
 	 */
330
-	private function delete_data( $key ) {
330
+	private function delete_data($key) {
331 331
 		global $wpdb;
332
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
332
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
333 333
 	}
334 334
 
335 335
 }
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-income.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -53,49 +53,49 @@  discard block
 block discarded – undo
53 53
 	 */
54 54
 	public function get_data() {
55 55
 
56
-		if ( $this->step == 1 ) {
57
-			$this->delete_data( 'give_temp_recount_earnings' );
56
+		if ($this->step == 1) {
57
+			$this->delete_data('give_temp_recount_earnings');
58 58
 		}
59 59
 
60
-		$total = get_option( 'give_temp_recount_earnings', false );
60
+		$total = get_option('give_temp_recount_earnings', false);
61 61
 
62
-		if ( false === $total ) {
62
+		if (false === $total) {
63 63
 			$total = (float) 0;
64
-			$this->store_data( 'give_temp_recount_earnings', $total );
64
+			$this->store_data('give_temp_recount_earnings', $total);
65 65
 		}
66 66
 
67
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
67
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
68 68
 
69
-		$args = apply_filters( 'give_recount_earnings_args', array(
69
+		$args = apply_filters('give_recount_earnings_args', array(
70 70
 			'number' => $this->per_step,
71 71
 			'page'   => $this->step,
72 72
 			'status' => $accepted_statuses,
73 73
 			'fields' => 'ids'
74
-		) );
74
+		));
75 75
 
76
-		$payments = give_get_payments( $args );
76
+		$payments = give_get_payments($args);
77 77
 
78
-		if ( ! empty( $payments ) ) {
78
+		if ( ! empty($payments)) {
79 79
 
80
-			foreach ( $payments as $payment ) {
80
+			foreach ($payments as $payment) {
81 81
 
82
-				$total += (float) give_donation_amount( $payment, array( 'type' => 'stats' ) );
82
+				$total += (float) give_donation_amount($payment, array('type' => 'stats'));
83 83
 
84 84
 			}
85 85
 
86
-			if ( $total < 0 ) {
86
+			if ($total < 0) {
87 87
 				$totals = 0;
88 88
 			}
89 89
 
90
-			$total = round( $total, give_get_price_decimals() );
90
+			$total = round($total, give_get_price_decimals());
91 91
 
92
-			$this->store_data( 'give_temp_recount_earnings', $total );
92
+			$this->store_data('give_temp_recount_earnings', $total);
93 93
 
94 94
 			return true;
95 95
 
96 96
 		}
97 97
 
98
-		update_option( 'give_earnings_total', $total );
98
+		update_option('give_earnings_total', $total);
99 99
 
100 100
 		return false;
101 101
 
@@ -109,25 +109,25 @@  discard block
 block discarded – undo
109 109
 	 */
110 110
 	public function get_percentage_complete() {
111 111
 
112
-		$total = $this->get_stored_data( 'give_recount_earnings_total' );
112
+		$total = $this->get_stored_data('give_recount_earnings_total');
113 113
 
114
-		if ( false === $total ) {
115
-			$args = apply_filters( 'give_recount_earnings_total_args', array() );
114
+		if (false === $total) {
115
+			$args = apply_filters('give_recount_earnings_total_args', array());
116 116
 
117
-			$counts = give_count_payments( $args );
118
-			$total  = absint( $counts->publish );
119
-			$total  = apply_filters( 'give_recount_store_earnings_total', $total );
117
+			$counts = give_count_payments($args);
118
+			$total  = absint($counts->publish);
119
+			$total  = apply_filters('give_recount_store_earnings_total', $total);
120 120
 
121
-			$this->store_data( 'give_recount_earnings_total', $total );
121
+			$this->store_data('give_recount_earnings_total', $total);
122 122
 		}
123 123
 
124 124
 		$percentage = 100;
125 125
 
126
-		if ( $total > 0 ) {
127
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
126
+		if ($total > 0) {
127
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
128 128
 		}
129 129
 
130
-		if ( $percentage > 100 ) {
130
+		if ($percentage > 100) {
131 131
 			$percentage = 100;
132 132
 		}
133 133
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 *
142 142
 	 * @param array $request The Form Data passed into the batch processing
143 143
 	 */
144
-	public function set_properties( $request ) {
144
+	public function set_properties($request) {
145 145
 	}
146 146
 
147 147
 	/**
@@ -152,21 +152,21 @@  discard block
 block discarded – undo
152 152
 	 */
153 153
 	public function process_step() {
154 154
 
155
-		if ( ! $this->can_export() ) {
156
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
155
+		if ( ! $this->can_export()) {
156
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
157 157
 		}
158 158
 
159 159
 		$had_data = $this->get_data();
160 160
 
161
-		if ( $had_data ) {
161
+		if ($had_data) {
162 162
 			$this->done = false;
163 163
 
164 164
 			return true;
165 165
 		} else {
166
-			$this->delete_data( 'give_recount_earnings_total' );
167
-			$this->delete_data( 'give_temp_recount_earnings' );
166
+			$this->delete_data('give_recount_earnings_total');
167
+			$this->delete_data('give_temp_recount_earnings');
168 168
 			$this->done    = true;
169
-			$this->message = esc_html__( 'Income stats have been successfully recounted.', 'give' );
169
+			$this->message = esc_html__('Income stats have been successfully recounted.', 'give');
170 170
 
171 171
 			return false;
172 172
 		}
@@ -203,17 +203,17 @@  discard block
 block discarded – undo
203 203
 	 *
204 204
 	 * @return mixed       Returns the data from the database
205 205
 	 */
206
-	private function get_stored_data( $key ) {
206
+	private function get_stored_data($key) {
207 207
 		global $wpdb;
208
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
208
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
209 209
 
210
-		if ( empty( $value ) ) {
210
+		if (empty($value)) {
211 211
 			return false;
212 212
 		}
213 213
 
214
-		$maybe_json = json_decode( $value );
215
-		if ( ! is_null( $maybe_json ) ) {
216
-			$value = json_decode( $value, true );
214
+		$maybe_json = json_decode($value);
215
+		if ( ! is_null($maybe_json)) {
216
+			$value = json_decode($value, true);
217 217
 		}
218 218
 
219 219
 		return $value;
@@ -229,10 +229,10 @@  discard block
 block discarded – undo
229 229
 	 *
230 230
 	 * @return void
231 231
 	 */
232
-	private function store_data( $key, $value ) {
232
+	private function store_data($key, $value) {
233 233
 		global $wpdb;
234 234
 
235
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
235
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
236 236
 
237 237
 		$data = array(
238 238
 			'option_name'  => $key,
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 			'%s',
247 247
 		);
248 248
 
249
-		$wpdb->replace( $wpdb->options, $data, $formats );
249
+		$wpdb->replace($wpdb->options, $data, $formats);
250 250
 	}
251 251
 
252 252
 	/**
@@ -258,9 +258,9 @@  discard block
 block discarded – undo
258 258
 	 *
259 259
 	 * @return void
260 260
 	 */
261
-	private function delete_data( $key ) {
261
+	private function delete_data($key) {
262 262
 		global $wpdb;
263
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
263
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
264 264
 	}
265 265
 
266 266
 }
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-donor-stats.php 1 patch
Spacing   +35 added lines, -35 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
 
@@ -57,32 +57,32 @@  discard block
 block discarded – undo
57 57
 
58 58
 		$args = array(
59 59
 			'number'  => $this->per_step,
60
-			'offset'  => $this->per_step * ( $this->step - 1 ),
60
+			'offset'  => $this->per_step * ($this->step - 1),
61 61
 			'orderby' => 'id',
62 62
 			'order'   => 'DESC',
63 63
 		);
64 64
 
65
-		$donors = Give()->donors->get_donors( $args );
65
+		$donors = Give()->donors->get_donors($args);
66 66
 
67
-		if ( $donors ) {
67
+		if ($donors) {
68 68
 
69
-			$allowed_payment_status = apply_filters( 'give_recount_donors_donation_statuses', give_get_payment_status_keys() );
69
+			$allowed_payment_status = apply_filters('give_recount_donors_donation_statuses', give_get_payment_status_keys());
70 70
 
71
-			foreach ( $donors as $donor ) {
71
+			foreach ($donors as $donor) {
72 72
 
73
-				$attached_payment_ids = explode( ',', $donor->payment_ids );
73
+				$attached_payment_ids = explode(',', $donor->payment_ids);
74 74
 
75 75
 				$attached_args = array(
76 76
 					'post__in' => $attached_payment_ids,
77
-					'number'   => - 1,
77
+					'number'   => -1,
78 78
 					'status'   => $allowed_payment_status,
79 79
 				);
80 80
 
81
-				$attached_payments = (array) give_get_payments( $attached_args );
81
+				$attached_payments = (array) give_get_payments($attached_args);
82 82
 
83 83
 				$unattached_args = array(
84 84
 					'post__not_in' => $attached_payment_ids,
85
-					'number'       => - 1,
85
+					'number'       => -1,
86 86
 					'status'       => $allowed_payment_status,
87 87
 					'meta_query'   => array(
88 88
 						array(
@@ -93,29 +93,29 @@  discard block
 block discarded – undo
93 93
 					),
94 94
 				);
95 95
 
96
-				$unattached_payments = give_get_payments( $unattached_args );
96
+				$unattached_payments = give_get_payments($unattached_args);
97 97
 
98
-				$payments = array_merge( $attached_payments, $unattached_payments );
98
+				$payments = array_merge($attached_payments, $unattached_payments);
99 99
 
100 100
 				$purchase_value = 0.00;
101 101
 				$purchase_count = 0;
102 102
 				$payment_ids    = array();
103 103
 
104
-				if ( $payments ) {
104
+				if ($payments) {
105 105
 
106
-					foreach ( $payments as $payment ) {
106
+					foreach ($payments as $payment) {
107 107
 
108 108
 						$should_process_payment = 'publish' == $payment->post_status ? true : false;
109
-						$should_process_payment = apply_filters( 'give_donor_recount_should_process_donation', $should_process_payment, $payment );
109
+						$should_process_payment = apply_filters('give_donor_recount_should_process_donation', $should_process_payment, $payment);
110 110
 
111
-						if ( true === $should_process_payment ) {
111
+						if (true === $should_process_payment) {
112 112
 
113
-							if ( apply_filters( 'give_donor_recount_should_increase_value', true, $payment ) ) {
114
-								$purchase_value += (float) give_donation_amount( $payment->ID, array( 'type' => 'stats' ) );
113
+							if (apply_filters('give_donor_recount_should_increase_value', true, $payment)) {
114
+								$purchase_value += (float) give_donation_amount($payment->ID, array('type' => 'stats'));
115 115
 							}
116 116
 
117
-							if ( apply_filters( 'give_donor_recount_should_increase_count', true, $payment ) ) {
118
-								$purchase_count ++;
117
+							if (apply_filters('give_donor_recount_should_increase_count', true, $payment)) {
118
+								$purchase_count++;
119 119
 							}
120 120
 						}
121 121
 
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 					}
124 124
 				}
125 125
 
126
-				$payment_ids = implode( ',', $payment_ids );
126
+				$payment_ids = implode(',', $payment_ids);
127 127
 
128 128
 				$donor_update_data = array(
129 129
 					'purchase_count' => $purchase_count,
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
 					'payment_ids'    => $payment_ids,
132 132
 				);
133 133
 
134
-				$donor_instance = new Give_Donor( $donor->id );
135
-				$donor_instance->update( $donor_update_data );
134
+				$donor_instance = new Give_Donor($donor->id);
135
+				$donor_instance->update($donor_update_data);
136 136
 
137 137
 			}// End foreach().
138 138
 
@@ -152,21 +152,21 @@  discard block
 block discarded – undo
152 152
 	public function get_percentage_complete() {
153 153
 
154 154
 		$args = array(
155
-			'number'  => - 1,
155
+			'number'  => -1,
156 156
 			'orderby' => 'id',
157 157
 			'order'   => 'DESC',
158 158
 		);
159 159
 
160
-		$donors = Give()->donors->get_donors( $args );
161
-		$total     = count( $donors );
160
+		$donors = Give()->donors->get_donors($args);
161
+		$total = count($donors);
162 162
 
163 163
 		$percentage = 100;
164 164
 
165
-		if ( $total > 0 ) {
166
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
165
+		if ($total > 0) {
166
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
167 167
 		}
168 168
 
169
-		if ( $percentage > 100 ) {
169
+		if ($percentage > 100) {
170 170
 			$percentage = 100;
171 171
 		}
172 172
 
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 	 *
181 181
 	 * @param array $request The Form Data passed into the batch processing
182 182
 	 */
183
-	public function set_properties( $request ) {
183
+	public function set_properties($request) {
184 184
 	}
185 185
 
186 186
 	/**
@@ -191,21 +191,21 @@  discard block
 block discarded – undo
191 191
 	 */
192 192
 	public function process_step() {
193 193
 
194
-		if ( ! $this->can_export() ) {
195
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array(
194
+		if ( ! $this->can_export()) {
195
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array(
196 196
 				'response' => 403,
197
-			) );
197
+			));
198 198
 		}
199 199
 
200 200
 		$had_data = $this->get_data();
201 201
 
202
-		if ( $had_data ) {
202
+		if ($had_data) {
203 203
 			$this->done = false;
204 204
 
205 205
 			return true;
206 206
 		} else {
207 207
 			$this->done    = true;
208
-			$this->message = esc_html__( 'Donor stats have been successfully recounted.', 'give' );
208
+			$this->message = esc_html__('Donor stats have been successfully recounted.', 'give');
209 209
 
210 210
 			return false;
211 211
 		}
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-form-stats.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -60,59 +60,59 @@  discard block
 block discarded – undo
60 60
 	 */
61 61
 	public function get_data() {
62 62
 
63
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
63
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
64 64
 
65
-		if ( $this->step == 1 ) {
66
-			$this->delete_data( 'give_temp_recount_form_stats' );
65
+		if ($this->step == 1) {
66
+			$this->delete_data('give_temp_recount_form_stats');
67 67
 		}
68 68
 
69
-		$totals = $this->get_stored_data( 'give_temp_recount_form_stats' );
69
+		$totals = $this->get_stored_data('give_temp_recount_form_stats');
70 70
 
71
-		if ( false === $totals ) {
71
+		if (false === $totals) {
72 72
 			$totals = array(
73 73
 				'earnings' => (float) 0,
74 74
 				'sales'    => 0,
75 75
 			);
76
-			$this->store_data( 'give_temp_recount_form_stats', $totals );
76
+			$this->store_data('give_temp_recount_form_stats', $totals);
77 77
 		}
78 78
 
79
-		$args = apply_filters( 'give_recount_form_stats_args', array(
79
+		$args = apply_filters('give_recount_form_stats_args', array(
80 80
 			'give_forms' => $this->form_id,
81 81
 			'number'     => $this->per_step,
82 82
 			'status'     => $accepted_statuses,
83 83
 			'paged'      => $this->step,
84 84
 			'fields'     => 'ids',
85
-		) );
85
+		));
86 86
 
87
-		$payments = new Give_Payments_Query( $args );
87
+		$payments = new Give_Payments_Query($args);
88 88
 		$payments = $payments->get_payments();
89 89
 
90
-		if ( $payments ) {
91
-			foreach ( $payments as $payment ) {
90
+		if ($payments) {
91
+			foreach ($payments as $payment) {
92 92
 
93 93
 				// Ensure acceptable status only.
94
-				if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
94
+				if ( ! in_array($payment->post_status, $accepted_statuses)) {
95 95
 					continue;
96 96
 				}
97 97
 
98 98
 				// Ensure only payments for this form are counted.
99
-				if ( $payment->form_id != $this->form_id ) {
99
+				if ($payment->form_id != $this->form_id) {
100 100
 					continue;
101 101
 				}
102 102
 
103
-				$totals['sales'] ++;
103
+				$totals['sales']++;
104 104
 				$totals['earnings'] += $payment->total;
105 105
 
106 106
 			}
107 107
 
108
-			$this->store_data( 'give_temp_recount_form_stats', $totals );
108
+			$this->store_data('give_temp_recount_form_stats', $totals);
109 109
 
110 110
 			return true;
111 111
 		}
112 112
 
113 113
 
114
-		give_update_meta( $this->form_id, '_give_form_sales', $totals['sales'] );
115
-		give_update_meta( $this->form_id, '_give_form_earnings', give_sanitize_amount_for_db( $totals['earnings'] ) );
114
+		give_update_meta($this->form_id, '_give_form_sales', $totals['sales']);
115
+		give_update_meta($this->form_id, '_give_form_earnings', give_sanitize_amount_for_db($totals['earnings']));
116 116
 
117 117
 		return false;
118 118
 	}
@@ -124,35 +124,35 @@  discard block
 block discarded – undo
124 124
 	 * @return int
125 125
 	 */
126 126
 	public function get_percentage_complete() {
127
-		if ( $this->step == 1 ) {
128
-			$this->delete_data( 'give_recount_total_' . $this->form_id );
127
+		if ($this->step == 1) {
128
+			$this->delete_data('give_recount_total_'.$this->form_id);
129 129
 		}
130 130
 
131
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
132
-		$total             = $this->get_stored_data( 'give_recount_total_' . $this->form_id );
131
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
132
+		$total             = $this->get_stored_data('give_recount_total_'.$this->form_id);
133 133
 
134
-		if ( false === $total ) {
134
+		if (false === $total) {
135 135
 			$total = 0;
136
-			$args  = apply_filters( 'give_recount_form_stats_total_args', array(
136
+			$args  = apply_filters('give_recount_form_stats_total_args', array(
137 137
 				'give_forms' => $this->form_id,
138
-				'number'     => - 1,
138
+				'number'     => -1,
139 139
 				'status'     => $accepted_statuses,
140 140
 				'fields'     => 'ids',
141
-			) );
141
+			));
142 142
 
143
-			$payments = new Give_Payments_Query( $args );
144
-			$total    = count( $payments->get_payments() );
145
-			$this->store_data( 'give_recount_total_' . $this->form_id, $total );
143
+			$payments = new Give_Payments_Query($args);
144
+			$total    = count($payments->get_payments());
145
+			$this->store_data('give_recount_total_'.$this->form_id, $total);
146 146
 
147 147
 		}
148 148
 
149 149
 		$percentage = 100;
150 150
 
151
-		if ( $total > 0 ) {
152
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
151
+		if ($total > 0) {
152
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
153 153
 		}
154 154
 
155
-		if ( $percentage > 100 ) {
155
+		if ($percentage > 100) {
156 156
 			$percentage = 100;
157 157
 		}
158 158
 
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
 	 *
167 167
 	 * @param array $request The Form Data passed into the batch processing
168 168
 	 */
169
-	public function set_properties( $request ) {
170
-		$this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false;
169
+	public function set_properties($request) {
170
+		$this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false;
171 171
 	}
172 172
 
173 173
 	/**
@@ -178,21 +178,21 @@  discard block
 block discarded – undo
178 178
 	 */
179 179
 	public function process_step() {
180 180
 
181
-		if ( ! $this->can_export() ) {
182
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
181
+		if ( ! $this->can_export()) {
182
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
183 183
 		}
184 184
 
185 185
 		$had_data = $this->get_data();
186 186
 
187
-		if ( $had_data ) {
187
+		if ($had_data) {
188 188
 			$this->done = false;
189 189
 
190 190
 			return true;
191 191
 		} else {
192
-			$this->delete_data( 'give_recount_total_' . $this->form_id );
193
-			$this->delete_data( 'give_temp_recount_form_stats' );
192
+			$this->delete_data('give_recount_total_'.$this->form_id);
193
+			$this->delete_data('give_temp_recount_form_stats');
194 194
 			$this->done    = true;
195
-			$this->message = sprintf( esc_html__( 'Donation counts and income amount statistics successfully recounted for "%s".', 'give' ), get_the_title( $this->form_id ) );
195
+			$this->message = sprintf(esc_html__('Donation counts and income amount statistics successfully recounted for "%s".', 'give'), get_the_title($this->form_id));
196 196
 
197 197
 			return false;
198 198
 		}
@@ -226,17 +226,17 @@  discard block
 block discarded – undo
226 226
 	 *
227 227
 	 * @return mixed       Returns the data from the database
228 228
 	 */
229
-	private function get_stored_data( $key ) {
229
+	private function get_stored_data($key) {
230 230
 		global $wpdb;
231
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
231
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
232 232
 
233
-		if ( empty( $value ) ) {
233
+		if (empty($value)) {
234 234
 			return false;
235 235
 		}
236 236
 
237
-		$maybe_json = json_decode( $value );
238
-		if ( ! is_null( $maybe_json ) ) {
239
-			$value = json_decode( $value, true );
237
+		$maybe_json = json_decode($value);
238
+		if ( ! is_null($maybe_json)) {
239
+			$value = json_decode($value, true);
240 240
 		}
241 241
 
242 242
 		return $value;
@@ -252,10 +252,10 @@  discard block
 block discarded – undo
252 252
 	 *
253 253
 	 * @return void
254 254
 	 */
255
-	private function store_data( $key, $value ) {
255
+	private function store_data($key, $value) {
256 256
 		global $wpdb;
257 257
 
258
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
258
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
259 259
 
260 260
 		$data = array(
261 261
 			'option_name'  => $key,
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 			'%s',
270 270
 		);
271 271
 
272
-		$wpdb->replace( $wpdb->options, $data, $formats );
272
+		$wpdb->replace($wpdb->options, $data, $formats);
273 273
 	}
274 274
 
275 275
 	/**
@@ -281,9 +281,9 @@  discard block
 block discarded – undo
281 281
 	 *
282 282
 	 * @return void
283 283
 	 */
284
-	private function delete_data( $key ) {
284
+	private function delete_data($key) {
285 285
 		global $wpdb;
286
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
286
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
287 287
 	}
288 288
 
289 289
 }
290 290
\ No newline at end of file
Please login to merge, or discard this patch.