Test Failed
Push — master ( 25adfe...70178c )
by Devin
01:46
created
includes/admin/views/html-admin-settings.php 2 patches
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -95,5 +95,8 @@
 block discarded – undo
95 95
 		<?php endif; ?>
96 96
 		<?php echo $form_close_tag; ?>
97 97
 	</div>
98
-<?php else : echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; ?>
98
+<?php else {
99
+	: echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>';
100
+}
101
+?>
99 102
 <?php endif; ?>
100 103
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -2,13 +2,13 @@  discard block
 block discarded – undo
2 2
 /**
3 3
  * Admin View: Settings
4 4
  */
5
-if ( ! defined( 'ABSPATH' ) ) {
5
+if ( ! defined('ABSPATH')) {
6 6
 	exit;
7 7
 }
8 8
 
9 9
 
10 10
 // Bailout: Do not output anything if setting tab is not defined.
11
-if( ! empty( $tabs ) && array_key_exists( give_get_current_setting_tab(), $tabs ) ) :
11
+if ( ! empty($tabs) && array_key_exists(give_get_current_setting_tab(), $tabs)) :
12 12
 	/**
13 13
 	 * Filter the form action.
14 14
 	 *
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	 *
19 19
 	 * @since 1.8
20 20
 	 */
21
-	$form_method    = apply_filters( self::$setting_filter_prefix . '_form_method_tab_' . $current_tab, 'post' );
21
+	$form_method = apply_filters(self::$setting_filter_prefix.'_form_method_tab_'.$current_tab, 'post');
22 22
 
23 23
 	/**
24 24
 	 * Filter the main form tab.
@@ -30,12 +30,12 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @since 1.8
32 32
 	 */
33
-	$form_open_tag  = apply_filters( self::$setting_filter_prefix . '_open_form', '<form method="' . $form_method  . '" id="give-mainform" action="" enctype="multipart/form-data">' );
34
-	$form_close_tag = apply_filters( self::$setting_filter_prefix . '_close_form', '</form>' );
33
+	$form_open_tag  = apply_filters(self::$setting_filter_prefix.'_open_form', '<form method="'.$form_method.'" id="give-mainform" action="" enctype="multipart/form-data">');
34
+	$form_close_tag = apply_filters(self::$setting_filter_prefix.'_close_form', '</form>');
35 35
 	?>
36
-	<div class="wrap give-settings-page <?php echo self::$setting_filter_prefix . '-setting-page'; ?>">
36
+	<div class="wrap give-settings-page <?php echo self::$setting_filter_prefix.'-setting-page'; ?>">
37 37
 		<?php echo $form_open_tag; ?>
38
-		<h1 class="wp-heading-inline"><?php echo esc_html( $tabs[ $current_tab ] ); ?></h1>
38
+		<h1 class="wp-heading-inline"><?php echo esc_html($tabs[$current_tab]); ?></h1>
39 39
 		<?php
40 40
 		// Show messages.
41 41
 		self::show_messages();
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
 
46 46
 		<div class="nav-tab-wrapper give-nav-tab-wrapper">
47 47
 			<?php
48
-			foreach ( $tabs as $name => $label ) {
49
-				echo '<a href="' . admin_url( "edit.php?post_type=give_forms&page=" . self::$setting_filter_prefix . "&tab={$name}" ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . $label . '</a>';
48
+			foreach ($tabs as $name => $label) {
49
+				echo '<a href="'.admin_url("edit.php?post_type=give_forms&page=".self::$setting_filter_prefix."&tab={$name}").'" class="nav-tab '.($current_tab == $name ? 'nav-tab-active' : '').'">'.$label.'</a>';
50 50
 			}
51 51
 
52 52
 			/**
@@ -58,11 +58,11 @@  discard block
 block discarded – undo
58 58
 			 *
59 59
 			 * @since 1.8
60 60
 			 */
61
-			do_action( self::$setting_filter_prefix . '_tabs' );
61
+			do_action(self::$setting_filter_prefix.'_tabs');
62 62
 			?>
63 63
 		</div>
64 64
 		<div class="give-sub-nav-tab-wrapper">
65
-			<a href="#" id="give-show-sub-nav" class="nav-tab give-not-tab" title="<?php _e( 'View remaining setting tabs', 'give' ); ?>"><span class="dashicons dashicons-arrow-down-alt2"></span></span></a>
65
+			<a href="#" id="give-show-sub-nav" class="nav-tab give-not-tab" title="<?php _e('View remaining setting tabs', 'give'); ?>"><span class="dashicons dashicons-arrow-down-alt2"></span></span></a>
66 66
 			<nav class="give-sub-nav-tab give-hidden"></nav>
67 67
 		</div>
68 68
 		<?php
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 		 *
77 77
 		 * @since 1.8
78 78
 		 */
79
-		do_action( self::$setting_filter_prefix . "_sections_{$current_tab}_page" );
79
+		do_action(self::$setting_filter_prefix."_sections_{$current_tab}_page");
80 80
 
81 81
 		/**
82 82
 		 * Trigger Action.
@@ -87,15 +87,15 @@  discard block
 block discarded – undo
87 87
 		 *
88 88
 		 * @since 1.8
89 89
 		 */
90
-		do_action( self::$setting_filter_prefix . "_settings_{$current_tab}_page" );
90
+		do_action(self::$setting_filter_prefix."_settings_{$current_tab}_page");
91 91
 
92
-		if ( empty( $GLOBALS['give_hide_save_button'] ) ) : ?>
92
+		if (empty($GLOBALS['give_hide_save_button'])) : ?>
93 93
 			<div class="give-submit-wrap">
94
-				<?php wp_nonce_field( 'give-save-settings', '_give-save-settings' ); ?>
95
-				<input name="save" class="button-primary give-save-button" type="submit" value="<?php esc_attr_e( 'Save changes', 'give' ); ?>" />
94
+				<?php wp_nonce_field('give-save-settings', '_give-save-settings'); ?>
95
+				<input name="save" class="button-primary give-save-button" type="submit" value="<?php esc_attr_e('Save changes', 'give'); ?>" />
96 96
 			</div>
97 97
 		<?php endif; ?>
98 98
 		<?php echo $form_close_tag; ?>
99 99
 	</div>
100
-<?php else : echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; ?>
100
+<?php else : echo '<div class="error"><p>'.__('Oops, this settings page does not exist.', 'give').'</p></div>'; ?>
101 101
 <?php endif; ?>
102 102
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/views/blank-slate.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -17,23 +17,23 @@  discard block
 block discarded – undo
17 17
 ?>
18 18
 
19 19
 <div class="give-blank-slate">
20
-	<?php if ( ! empty( $content['image_url'] ) ) : ?>
21
-		<img class="give-blank-slate__image" src="<?php echo esc_url( $content['image_url'] ); ?>" alt="<?php echo esc_attr( $content['image_alt'] ); ?>">
20
+	<?php if ( ! empty($content['image_url'])) : ?>
21
+		<img class="give-blank-slate__image" src="<?php echo esc_url($content['image_url']); ?>" alt="<?php echo esc_attr($content['image_alt']); ?>">
22 22
 	<?php endif; ?>
23 23
 
24
-	<?php if ( ! empty( $content['heading'] ) ) : ?>
25
-		<h2 class="give-blank-slate__heading"><?php esc_html_e( $content['heading'] ); ?></h2>
24
+	<?php if ( ! empty($content['heading'])) : ?>
25
+		<h2 class="give-blank-slate__heading"><?php esc_html_e($content['heading']); ?></h2>
26 26
 	<?php endif; ?>
27 27
 
28
-	<?php if ( ! empty( $content['message'] ) ) : ?>
29
-		<p class="give-blank-slate__message"><?php esc_html_e( $content['message'] ); ?></p>
28
+	<?php if ( ! empty($content['message'])) : ?>
29
+		<p class="give-blank-slate__message"><?php esc_html_e($content['message']); ?></p>
30 30
 	<?php endif; ?>
31 31
 
32
-	<?php if ( ! empty( $content['cta_text']) && ! empty( $content['cta_link'] ) ) : ?>
33
-		<a class="give-blank-slate__cta button button-primary" href="<?php echo esc_url( $content['cta_link'] ); ?>"><?php esc_html_e( $content['cta_text'] ); ?></a>
32
+	<?php if ( ! empty($content['cta_text']) && ! empty($content['cta_link'])) : ?>
33
+		<a class="give-blank-slate__cta button button-primary" href="<?php echo esc_url($content['cta_link']); ?>"><?php esc_html_e($content['cta_text']); ?></a>
34 34
 	<?php endif; ?>
35 35
 
36
-	<?php if ( ! empty( $content['help'] ) ) : ?>
36
+	<?php if ( ! empty($content['help'])) : ?>
37 37
 		<p class="give-blank-slate__help">
38 38
 			<?php
39 39
 			$allowed_html = array(
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 				'code'   => array(),
48 48
 			);
49 49
 
50
-			echo wp_kses( $content['help'], $allowed_html );
50
+			echo wp_kses($content['help'], $allowed_html);
51 51
 			?>
52 52
 		</p>
53 53
 	<?php endif; ?>
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-all-stats.php 1 patch
Spacing   +97 added lines, -99 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,104 +80,102 @@  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 ( false === $payments ) {
105
-			$args = apply_filters( 'give_recount_form_stats_args', array(
104
+		if (false === $payments) {
105
+			$args = apply_filters('give_recount_form_stats_args', array(
106 106
 				'post_parent__in' => $all_forms,
107 107
 				'number'          => $this->per_step,
108 108
 				'status'          => 'publish',
109 109
 				'paged'           => $this->step,
110 110
 				'output'          => '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 ( $payments ) {
117
+		if ($payments) {
118 118
 
119 119
 			//Loop through payments
120
-			foreach ( $payments as $payment ) {
120
+			foreach ($payments as $payment) {
121 121
 
122 122
 				// Prevent payments that have all ready been retrieved from a previous sales log from counting again.
123
-				if ( in_array( $payment->ID, $processed_payments ) ) {
123
+				if (in_array($payment->ID, $processed_payments)) {
124 124
 					continue;
125 125
 				}
126 126
 
127 127
 				// Verify accepted status
128
-				if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
128
+				if ( ! in_array($payment->post_status, $accepted_statuses)) {
129 129
 					$processed_payments[] = $payment->ID;
130 130
 					continue;
131 131
 				}
132 132
 
133
-				$payment_item = $payment_items[ $payment->ID ];
133
+				$payment_item = $payment_items[$payment->ID];
134 134
 
135
-				$form_id = isset( $payment_item['id'] ) ? $payment_item['id'] : '';
135
+				$form_id = isset($payment_item['id']) ? $payment_item['id'] : '';
136 136
 
137 137
 				//Must have a form ID
138
-				if ( empty( $form_id ) ) {
138
+				if (empty($form_id)) {
139 139
 					continue;
140 140
 				}
141 141
 
142 142
 				//Form ID must be within $all_forms array to be validated
143
-				if ( ! in_array( $form_id, $all_forms ) ) {
143
+				if ( ! in_array($form_id, $all_forms)) {
144 144
 					continue;
145 145
 				}
146 146
 
147 147
 				// Set Sales count
148
-				$totals[ $form_id ]['sales'] = isset( $totals[ $form_id ]['sales'] ) ?
149
-					++ $totals[ $form_id ]['sales'] :
150
-					1;
148
+				$totals[$form_id]['sales'] = isset($totals[$form_id]['sales']) ?
149
+					++$totals[$form_id]['sales'] : 1;
151 150
 
152 151
 				// Set Total Earnings
153
-				$totals[ $form_id ]['earnings'] = isset( $totals[ $form_id ]['earnings'] ) ?
154
-					( $totals[ $form_id ]['earnings'] + $payment_item['price'] ) :
155
-					$payment_item['price'];
152
+				$totals[$form_id]['earnings'] = isset($totals[$form_id]['earnings']) ?
153
+					($totals[$form_id]['earnings'] + $payment_item['price']) : $payment_item['price'];
156 154
 
157 155
 				$processed_payments[] = $payment->ID;
158 156
 			}
159 157
 
160 158
 			// Get the list of form ids which does not contain any payment record.
161
-			$remaining_form_ids = array_diff( $all_forms, array_keys( $totals ) );
162
-			foreach ( $remaining_form_ids as $form_id ) {
159
+			$remaining_form_ids = array_diff($all_forms, array_keys($totals));
160
+			foreach ($remaining_form_ids as $form_id) {
163 161
 				//If array key doesn't exist, create it
164
-				if ( ! array_key_exists( $form_id, $totals ) ) {
165
-					$totals[ $form_id ] = array(
162
+				if ( ! array_key_exists($form_id, $totals)) {
163
+					$totals[$form_id] = array(
166 164
 						'sales'    => (int) 0,
167 165
 						'earnings' => (float) 0,
168 166
 					);
169 167
 				}
170 168
 			}
171 169
 
172
-			$this->store_data( 'give_temp_processed_payments', $processed_payments );
173
-			$this->store_data( 'give_temp_recount_all_stats', $totals );
170
+			$this->store_data('give_temp_processed_payments', $processed_payments);
171
+			$this->store_data('give_temp_recount_all_stats', $totals);
174 172
 
175 173
 			return true;
176 174
 		}
177 175
 
178
-		foreach ( $totals as $key => $stats ) {
179
-			give_update_meta( $key, '_give_form_sales', $stats['sales'] );
180
-			give_update_meta( $key, '_give_form_earnings', give_sanitize_amount_for_db( $stats['earnings'] ) );
176
+		foreach ($totals as $key => $stats) {
177
+			give_update_meta($key, '_give_form_sales', $stats['sales']);
178
+			give_update_meta($key, '_give_form_earnings', give_sanitize_amount_for_db($stats['earnings']));
181 179
 		}
182 180
 
183 181
 		return false;
@@ -192,20 +190,20 @@  discard block
 block discarded – undo
192 190
 	 */
193 191
 	public function get_percentage_complete() {
194 192
 
195
-		$total = $this->get_stored_data( 'give_recount_all_total' );
193
+		$total = $this->get_stored_data('give_recount_all_total');
196 194
 
197
-		if ( false === $total ) {
195
+		if (false === $total) {
198 196
 			$this->pre_fetch();
199
-			$total = $this->get_stored_data( 'give_recount_all_total' );
197
+			$total = $this->get_stored_data('give_recount_all_total');
200 198
 		}
201 199
 
202 200
 		$percentage = 100;
203 201
 
204
-		if ( $total > 0 ) {
205
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
202
+		if ($total > 0) {
203
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
206 204
 		}
207 205
 
208
-		if ( $percentage > 100 ) {
206
+		if ($percentage > 100) {
209 207
 			$percentage = 100;
210 208
 		}
211 209
 
@@ -219,8 +217,8 @@  discard block
 block discarded – undo
219 217
 	 *
220 218
 	 * @param array $request The Form Data passed into the batch processing
221 219
 	 */
222
-	public function set_properties( $request ) {
223
-		$this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false;
220
+	public function set_properties($request) {
221
+		$this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false;
224 222
 	}
225 223
 
226 224
 	/**
@@ -231,35 +229,35 @@  discard block
 block discarded – undo
231 229
 	 */
232 230
 	public function process_step() {
233 231
 
234
-		if ( ! $this->can_export() ) {
235
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
232
+		if ( ! $this->can_export()) {
233
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
236 234
 		}
237 235
 
238 236
 		$had_data = $this->get_data();
239 237
 
240
-		if ( $had_data ) {
238
+		if ($had_data) {
241 239
 			$this->done = false;
242 240
 
243 241
 			return true;
244 242
 		} else {
245
-			$this->delete_data( 'give_recount_total_' . $this->form_id );
246
-			$this->delete_data( 'give_recount_all_total' );
247
-			$this->delete_data( 'give_temp_recount_all_stats' );
248
-			$this->delete_data( 'give_temp_payment_items' );
249
-			$this->delete_data( 'give_temp_form_ids' );
250
-			$this->delete_data( 'give_temp_processed_payments' );
243
+			$this->delete_data('give_recount_total_'.$this->form_id);
244
+			$this->delete_data('give_recount_all_total');
245
+			$this->delete_data('give_temp_recount_all_stats');
246
+			$this->delete_data('give_temp_payment_items');
247
+			$this->delete_data('give_temp_form_ids');
248
+			$this->delete_data('give_temp_processed_payments');
251 249
 			$this->done    = true;
252
-			$this->message = esc_html__( 'Donation form income amounts and donation counts stats successfully recounted.', 'give' );
250
+			$this->message = esc_html__('Donation form income amounts and donation counts stats successfully recounted.', 'give');
253 251
 
254 252
 			return false;
255 253
 		}
256 254
 	}
257 255
 
258 256
 	public function headers() {
259
-		ignore_user_abort( true );
257
+		ignore_user_abort(true);
260 258
 
261
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
262
-			set_time_limit( 0 );
259
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
260
+			set_time_limit(0);
263 261
 		}
264 262
 	}
265 263
 
@@ -286,69 +284,69 @@  discard block
 block discarded – undo
286 284
 	 */
287 285
 	public function pre_fetch() {
288 286
 
289
-		if ( $this->step == 1 ) {
290
-			$this->delete_data( 'give_temp_recount_all_total' );
291
-			$this->delete_data( 'give_temp_recount_all_stats' );
292
-			$this->delete_data( 'give_temp_payment_items' );
293
-			$this->delete_data( 'give_temp_processed_payments' );
294
-			$this->delete_data( 'give_temp_all_payments_data' );
287
+		if ($this->step == 1) {
288
+			$this->delete_data('give_temp_recount_all_total');
289
+			$this->delete_data('give_temp_recount_all_stats');
290
+			$this->delete_data('give_temp_payment_items');
291
+			$this->delete_data('give_temp_processed_payments');
292
+			$this->delete_data('give_temp_all_payments_data');
295 293
 		}
296 294
 
297
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
298
-		$total             = $this->get_stored_data( 'give_temp_recount_all_total' );
295
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
296
+		$total             = $this->get_stored_data('give_temp_recount_all_total');
299 297
 
300
-		if ( false === $total ) {
298
+		if (false === $total) {
301 299
 			$total         = 0;
302
-			$payment_items = $this->get_stored_data( 'give_temp_payment_items' );
300
+			$payment_items = $this->get_stored_data('give_temp_payment_items');
303 301
 
304
-			if ( false === $payment_items ) {
302
+			if (false === $payment_items) {
305 303
 				$payment_items = array();
306
-				$this->store_data( 'give_temp_payment_items', $payment_items );
304
+				$this->store_data('give_temp_payment_items', $payment_items);
307 305
 			}
308 306
 
309 307
 			$args = array(
310 308
 				'post_status'    => 'publish',
311 309
 				'post_type'      => 'give_forms',
312
-				'posts_per_page' => - 1,
310
+				'posts_per_page' => -1,
313 311
 				'fields'         => 'ids',
314 312
 			);
315 313
 
316
-			$all_forms = get_posts( $args );
317
-			$this->store_data( 'give_temp_form_ids', $all_forms );
314
+			$all_forms = get_posts($args);
315
+			$this->store_data('give_temp_form_ids', $all_forms);
318 316
 
319
-			$args = apply_filters( 'give_recount_form_stats_total_args', array(
317
+			$args = apply_filters('give_recount_form_stats_total_args', array(
320 318
 				'post_parent__in' => $all_forms,
321 319
 				'number'          => $this->per_step,
322 320
 				'status'          => 'publish',
323 321
 				'page'            => $this->step,
324 322
 				'output'          => 'payments',
325
-			) );
323
+			));
326 324
 
327
-			$payments_query = new Give_Payments_Query( $args );
325
+			$payments_query = new Give_Payments_Query($args);
328 326
 			$payments       = $payments_query->get_payments();
329
-			$total          = wp_count_posts( 'give_payment' )->publish;
327
+			$total          = wp_count_posts('give_payment')->publish;
330 328
 
331
-			$this->store_data( 'give_temp_all_payments_data', $payments );
329
+			$this->store_data('give_temp_all_payments_data', $payments);
332 330
 
333
-			if ( $payments ) {
331
+			if ($payments) {
334 332
 
335
-				foreach ( $payments as $payment ) {
333
+				foreach ($payments as $payment) {
336 334
 
337
-					$payment = new Give_Payment( $payment->ID );
335
+					$payment = new Give_Payment($payment->ID);
338 336
 					$form_id = $payment->form_id;
339 337
 
340 338
 					//If for some reason somehow the form_ID isn't set check payment meta
341
-					if ( empty( $payment->form_id ) ) {
339
+					if (empty($payment->form_id)) {
342 340
 						$payment_meta = $payment->get_meta();
343
-						$form_id      = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0;
341
+						$form_id      = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0;
344 342
 					}
345 343
 
346
-					if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
344
+					if ( ! in_array($payment->post_status, $accepted_statuses)) {
347 345
 						continue;
348 346
 					}
349 347
 
350
-					if ( ! array_key_exists( $payment->ID, $payment_items ) ) {
351
-						$payment_items[ $payment->ID ] = array(
348
+					if ( ! array_key_exists($payment->ID, $payment_items)) {
349
+						$payment_items[$payment->ID] = array(
352 350
 							'id'         => $form_id,
353 351
 							'payment_id' => $payment->ID,
354 352
 							'price'      => $payment->total,
@@ -359,8 +357,8 @@  discard block
 block discarded – undo
359 357
 
360 358
 			}
361 359
 
362
-			$this->store_data( 'give_temp_payment_items', $payment_items );
363
-			$this->store_data( 'give_recount_all_total', $total );
360
+			$this->store_data('give_temp_payment_items', $payment_items);
361
+			$this->store_data('give_recount_all_total', $total);
364 362
 		}
365 363
 
366 364
 	}
@@ -374,17 +372,17 @@  discard block
 block discarded – undo
374 372
 	 *
375 373
 	 * @return mixed       Returns the data from the database
376 374
 	 */
377
-	private function get_stored_data( $key ) {
375
+	private function get_stored_data($key) {
378 376
 		global $wpdb;
379
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
377
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
380 378
 
381
-		if ( empty( $value ) ) {
379
+		if (empty($value)) {
382 380
 			return false;
383 381
 		}
384 382
 
385
-		$maybe_json = json_decode( $value );
386
-		if ( ! is_null( $maybe_json ) ) {
387
-			$value = json_decode( $value, true );
383
+		$maybe_json = json_decode($value);
384
+		if ( ! is_null($maybe_json)) {
385
+			$value = json_decode($value, true);
388 386
 		}
389 387
 
390 388
 		return $value;
@@ -400,10 +398,10 @@  discard block
 block discarded – undo
400 398
 	 *
401 399
 	 * @return void
402 400
 	 */
403
-	private function store_data( $key, $value ) {
401
+	private function store_data($key, $value) {
404 402
 		global $wpdb;
405 403
 
406
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
404
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
407 405
 
408 406
 		$data = array(
409 407
 			'option_name'  => $key,
@@ -417,7 +415,7 @@  discard block
 block discarded – undo
417 415
 			'%s',
418 416
 		);
419 417
 
420
-		$wpdb->replace( $wpdb->options, $data, $formats );
418
+		$wpdb->replace($wpdb->options, $data, $formats);
421 419
 	}
422 420
 
423 421
 	/**
@@ -429,9 +427,9 @@  discard block
 block discarded – undo
429 427
 	 *
430 428
 	 * @return void
431 429
 	 */
432
-	private function delete_data( $key ) {
430
+	private function delete_data($key) {
433 431
 		global $wpdb;
434
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
432
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
435 433
 	}
436 434
 
437 435
 }
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-single-donor-stats.php 1 patch
Spacing   +74 added lines, -74 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 = give_get_payment_amount( $payment->ID );
89
-						$step_total     += $payment_amount;
87
+					if (apply_filters('give_donor_recount_should_increase_value', true, $payment)) {
88
+						$payment_amount = give_get_payment_amount($payment->ID);
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,63 +147,63 @@  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
 		}
200 200
 	}
201 201
 
202 202
 	public function headers() {
203
-		ignore_user_abort( true );
203
+		ignore_user_abort(true);
204 204
 
205
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
206
-			set_time_limit( 0 );
205
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
206
+			set_time_limit(0);
207 207
 		}
208 208
 	}
209 209
 
@@ -230,26 +230,26 @@  discard block
 block discarded – undo
230 230
 	 * @return void
231 231
 	 */
232 232
 	public function pre_fetch() {
233
-		if ( $this->step === 1 ) {
234
-			$allowed_payment_status = apply_filters( 'give_recount_donors_donation_statuses', give_get_payment_status_keys() );
233
+		if ($this->step === 1) {
234
+			$allowed_payment_status = apply_filters('give_recount_donors_donation_statuses', give_get_payment_status_keys());
235 235
 
236 236
 			// Before we start, let's zero out the customer's data
237
-			$donor = new Give_Donor( $this->customer_id );
238
-			$donor->update( array( 'purchase_value' => give_format_amount( 0, array( 'sanitize' => false ) ), 'purchase_count' => 0 ) );
237
+			$donor = new Give_Donor($this->customer_id);
238
+			$donor->update(array('purchase_value' => give_format_amount(0, array('sanitize' => false)), 'purchase_count' => 0));
239 239
 
240
-			$attached_payment_ids = explode( ',', $donor->payment_ids );
240
+			$attached_payment_ids = explode(',', $donor->payment_ids);
241 241
 
242 242
 			$attached_args = array(
243 243
 				'post__in' => $attached_payment_ids,
244
-				'number'   => - 1,
244
+				'number'   => -1,
245 245
 				'status'   => $allowed_payment_status,
246 246
 			);
247 247
 
248
-			$attached_payments = give_get_payments( $attached_args );
248
+			$attached_payments = give_get_payments($attached_args);
249 249
 
250 250
 			$unattached_args = array(
251 251
 				'post__not_in' => $attached_payment_ids,
252
-				'number'       => - 1,
252
+				'number'       => -1,
253 253
 				'status'       => $allowed_payment_status,
254 254
 				'meta_query'   => array(
255 255
 					array(
@@ -259,11 +259,11 @@  discard block
 block discarded – undo
259 259
 				),
260 260
 			);
261 261
 
262
-			$unattached_payments = give_get_payments( $unattached_args );
262
+			$unattached_payments = give_get_payments($unattached_args);
263 263
 
264
-			$payments = array_merge( $attached_payments, $unattached_payments );
264
+			$payments = array_merge($attached_payments, $unattached_payments);
265 265
 
266
-			$this->store_data( 'give_recount_donor_payments_' . $donor->id, $payments );
266
+			$this->store_data('give_recount_donor_payments_'.$donor->id, $payments);
267 267
 		}
268 268
 	}
269 269
 
@@ -276,17 +276,17 @@  discard block
 block discarded – undo
276 276
 	 *
277 277
 	 * @return mixed       Returns the data from the database
278 278
 	 */
279
-	private function get_stored_data( $key ) {
279
+	private function get_stored_data($key) {
280 280
 		global $wpdb;
281
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
281
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
282 282
 
283
-		if ( empty( $value ) ) {
283
+		if (empty($value)) {
284 284
 			return false;
285 285
 		}
286 286
 
287
-		$maybe_json = json_decode( $value );
288
-		if ( ! is_null( $maybe_json ) ) {
289
-			$value = json_decode( $value, true );
287
+		$maybe_json = json_decode($value);
288
+		if ( ! is_null($maybe_json)) {
289
+			$value = json_decode($value, true);
290 290
 		}
291 291
 
292 292
 		return $value;
@@ -302,10 +302,10 @@  discard block
 block discarded – undo
302 302
 	 *
303 303
 	 * @return void
304 304
 	 */
305
-	private function store_data( $key, $value ) {
305
+	private function store_data($key, $value) {
306 306
 		global $wpdb;
307 307
 
308
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
308
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
309 309
 
310 310
 		$data = array(
311 311
 			'option_name'  => $key,
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 			'%s',
320 320
 		);
321 321
 
322
-		$wpdb->replace( $wpdb->options, $data, $formats );
322
+		$wpdb->replace($wpdb->options, $data, $formats);
323 323
 	}
324 324
 
325 325
 	/**
@@ -331,9 +331,9 @@  discard block
 block discarded – undo
331 331
 	 *
332 332
 	 * @return void
333 333
 	 */
334
-	private function delete_data( $key ) {
334
+	private function delete_data($key) {
335 335
 		global $wpdb;
336
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
336
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
337 337
 	}
338 338
 
339 339
 }
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-form-stats.php 1 patch
Spacing   +54 added lines, -54 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
 
@@ -59,58 +59,58 @@  discard block
 block discarded – undo
59 59
 	 * @return bool
60 60
 	 */
61 61
 	public function get_data() {
62
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
62
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
63 63
 
64
-		if ( $this->step == 1 ) {
65
-			$this->delete_data( 'give_temp_recount_form_stats' );
64
+		if ($this->step == 1) {
65
+			$this->delete_data('give_temp_recount_form_stats');
66 66
 		}
67 67
 
68
-		$totals = $this->get_stored_data( 'give_temp_recount_form_stats' );
68
+		$totals = $this->get_stored_data('give_temp_recount_form_stats');
69 69
 
70
-		if ( false === $totals ) {
70
+		if (false === $totals) {
71 71
 			$totals = array(
72 72
 				'earnings' => (float) 0,
73 73
 				'sales'    => 0,
74 74
 			);
75
-			$this->store_data( 'give_temp_recount_form_stats', $totals );
75
+			$this->store_data('give_temp_recount_form_stats', $totals);
76 76
 		}
77 77
 
78
-		$args = apply_filters( 'give_recount_form_stats_args', array(
78
+		$args = apply_filters('give_recount_form_stats_args', array(
79 79
 			'give_forms' => $this->form_id,
80 80
 			'number'     => $this->per_step,
81 81
 			'status'     => $accepted_statuses,
82 82
 			'paged'      => $this->step,
83 83
 			'fields'     => 'ids',
84
-		) );
84
+		));
85 85
 
86
-		$payments = new Give_Payments_Query( $args );
86
+		$payments = new Give_Payments_Query($args);
87 87
 		$payments = $payments->get_payments();
88 88
 
89
-		if ( $payments ) {
90
-			foreach ( $payments as $payment ) {
89
+		if ($payments) {
90
+			foreach ($payments as $payment) {
91 91
 				//Ensure acceptible status only
92
-				if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
92
+				if ( ! in_array($payment->post_status, $accepted_statuses)) {
93 93
 					continue;
94 94
 				}
95 95
 
96 96
 				//Ensure only payments for this form are counted
97
-				if ( $payment->form_id != $this->form_id ) {
97
+				if ($payment->form_id != $this->form_id) {
98 98
 					continue;
99 99
 				}
100 100
 
101
-				$totals['sales'] ++;
101
+				$totals['sales']++;
102 102
 				$totals['earnings'] += $payment->total;
103 103
 
104 104
 			}
105 105
 
106
-			$this->store_data( 'give_temp_recount_form_stats', $totals );
106
+			$this->store_data('give_temp_recount_form_stats', $totals);
107 107
 
108 108
 			return true;
109 109
 		}
110 110
 
111 111
 
112
-		give_update_meta( $this->form_id, '_give_form_sales', $totals['sales'] );
113
-		give_update_meta( $this->form_id, '_give_form_earnings', give_sanitize_amount_for_db( $totals['earnings'] ) );
112
+		give_update_meta($this->form_id, '_give_form_sales', $totals['sales']);
113
+		give_update_meta($this->form_id, '_give_form_earnings', give_sanitize_amount_for_db($totals['earnings']));
114 114
 
115 115
 		return false;
116 116
 	}
@@ -122,35 +122,35 @@  discard block
 block discarded – undo
122 122
 	 * @return int
123 123
 	 */
124 124
 	public function get_percentage_complete() {
125
-		if ( $this->step == 1 ) {
126
-			$this->delete_data( 'give_recount_total_' . $this->form_id );
125
+		if ($this->step == 1) {
126
+			$this->delete_data('give_recount_total_'.$this->form_id);
127 127
 		}
128 128
 
129
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
130
-		$total             = $this->get_stored_data( 'give_recount_total_' . $this->form_id );
129
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
130
+		$total             = $this->get_stored_data('give_recount_total_'.$this->form_id);
131 131
 
132
-		if ( false === $total ) {
132
+		if (false === $total) {
133 133
 			$total = 0;
134
-			$args  = apply_filters( 'give_recount_form_stats_total_args', array(
134
+			$args  = apply_filters('give_recount_form_stats_total_args', array(
135 135
 				'give_forms' => $this->form_id,
136
-				'number'     => - 1,
136
+				'number'     => -1,
137 137
 				'status'     => $accepted_statuses,
138 138
 				'fields'     => 'ids',
139
-			) );
139
+			));
140 140
 
141
-			$payments = new Give_Payments_Query( $args );
142
-			$total    = count( $payments->get_payments() );
143
-			$this->store_data( 'give_recount_total_' . $this->form_id, $total );
141
+			$payments = new Give_Payments_Query($args);
142
+			$total    = count($payments->get_payments());
143
+			$this->store_data('give_recount_total_'.$this->form_id, $total);
144 144
 
145 145
 		}
146 146
 
147 147
 		$percentage = 100;
148 148
 
149
-		if ( $total > 0 ) {
150
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
149
+		if ($total > 0) {
150
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
151 151
 		}
152 152
 
153
-		if ( $percentage > 100 ) {
153
+		if ($percentage > 100) {
154 154
 			$percentage = 100;
155 155
 		}
156 156
 
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
 	 *
165 165
 	 * @param array $request The Form Data passed into the batch processing
166 166
 	 */
167
-	public function set_properties( $request ) {
168
-		$this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false;
167
+	public function set_properties($request) {
168
+		$this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false;
169 169
 	}
170 170
 
171 171
 	/**
@@ -176,31 +176,31 @@  discard block
 block discarded – undo
176 176
 	 */
177 177
 	public function process_step() {
178 178
 
179
-		if ( ! $this->can_export() ) {
180
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
179
+		if ( ! $this->can_export()) {
180
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
181 181
 		}
182 182
 
183 183
 		$had_data = $this->get_data();
184 184
 
185
-		if ( $had_data ) {
185
+		if ($had_data) {
186 186
 			$this->done = false;
187 187
 
188 188
 			return true;
189 189
 		} else {
190
-			$this->delete_data( 'give_recount_total_' . $this->form_id );
191
-			$this->delete_data( 'give_temp_recount_form_stats' );
190
+			$this->delete_data('give_recount_total_'.$this->form_id);
191
+			$this->delete_data('give_temp_recount_form_stats');
192 192
 			$this->done    = true;
193
-			$this->message = sprintf( esc_html__( 'Donation counts and income amount statistics successfully recounted for "%s".', 'give' ), get_the_title( $this->form_id ) );
193
+			$this->message = sprintf(esc_html__('Donation counts and income amount statistics successfully recounted for "%s".', 'give'), get_the_title($this->form_id));
194 194
 
195 195
 			return false;
196 196
 		}
197 197
 	}
198 198
 
199 199
 	public function headers() {
200
-		ignore_user_abort( true );
200
+		ignore_user_abort(true);
201 201
 
202
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
203
-			set_time_limit( 0 );
202
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
203
+			set_time_limit(0);
204 204
 		}
205 205
 	}
206 206
 
@@ -228,17 +228,17 @@  discard block
 block discarded – undo
228 228
 	 *
229 229
 	 * @return mixed       Returns the data from the database
230 230
 	 */
231
-	private function get_stored_data( $key ) {
231
+	private function get_stored_data($key) {
232 232
 		global $wpdb;
233
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
233
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
234 234
 
235
-		if ( empty( $value ) ) {
235
+		if (empty($value)) {
236 236
 			return false;
237 237
 		}
238 238
 
239
-		$maybe_json = json_decode( $value );
240
-		if ( ! is_null( $maybe_json ) ) {
241
-			$value = json_decode( $value, true );
239
+		$maybe_json = json_decode($value);
240
+		if ( ! is_null($maybe_json)) {
241
+			$value = json_decode($value, true);
242 242
 		}
243 243
 
244 244
 		return $value;
@@ -254,10 +254,10 @@  discard block
 block discarded – undo
254 254
 	 *
255 255
 	 * @return void
256 256
 	 */
257
-	private function store_data( $key, $value ) {
257
+	private function store_data($key, $value) {
258 258
 		global $wpdb;
259 259
 
260
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
260
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
261 261
 
262 262
 		$data = array(
263 263
 			'option_name'  => $key,
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 			'%s',
272 272
 		);
273 273
 
274
-		$wpdb->replace( $wpdb->options, $data, $formats );
274
+		$wpdb->replace($wpdb->options, $data, $formats);
275 275
 	}
276 276
 
277 277
 	/**
@@ -283,9 +283,9 @@  discard block
 block discarded – undo
283 283
 	 *
284 284
 	 * @return void
285 285
 	 */
286
-	private function delete_data( $key ) {
286
+	private function delete_data($key) {
287 287
 		global $wpdb;
288
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
288
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
289 289
 	}
290 290
 
291 291
 }
292 292
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-reset-stats.php 1 patch
Spacing   +68 added lines, -68 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
 
@@ -58,16 +58,16 @@  discard block
 block discarded – undo
58 58
 	public function get_data() {
59 59
 		global $wpdb;
60 60
 
61
-		$items = $this->get_stored_data( 'give_temp_reset_ids' );
61
+		$items = $this->get_stored_data('give_temp_reset_ids');
62 62
 
63
-		if ( ! is_array( $items ) ) {
63
+		if ( ! is_array($items)) {
64 64
 			return false;
65 65
 		}
66 66
 
67
-		$offset     = ( $this->step - 1 ) * $this->per_step;
68
-		$step_items = array_slice( $items, $offset, $this->per_step );
67
+		$offset     = ($this->step - 1) * $this->per_step;
68
+		$step_items = array_slice($items, $offset, $this->per_step);
69 69
 
70
-		if ( $step_items ) {
70
+		if ($step_items) {
71 71
 
72 72
 			$step_ids = array(
73 73
 				'customers' => array(),
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
 				'other'     => array(),
76 76
 			);
77 77
 
78
-			foreach ( $step_items as $item ) {
78
+			foreach ($step_items as $item) {
79 79
 
80
-				switch ( $item['type'] ) {
80
+				switch ($item['type']) {
81 81
 					case 'customer':
82 82
 						$step_ids['customers'][] = $item['id'];
83 83
 						break;
@@ -85,26 +85,26 @@  discard block
 block discarded – undo
85 85
 						$step_ids['give_forms'][] = $item['id'];
86 86
 						break;
87 87
 					default:
88
-						$item_type                = apply_filters( 'give_reset_item_type', 'other', $item );
89
-						$step_ids[ $item_type ][] = $item['id'];
88
+						$item_type                = apply_filters('give_reset_item_type', 'other', $item);
89
+						$step_ids[$item_type][] = $item['id'];
90 90
 						break;
91 91
 				}
92 92
 			}
93 93
 
94 94
 			$sql = array();
95 95
 
96
-			foreach ( $step_ids as $type => $ids ) {
96
+			foreach ($step_ids as $type => $ids) {
97 97
 
98
-				if ( empty( $ids ) ) {
98
+				if (empty($ids)) {
99 99
 					continue;
100 100
 				}
101 101
 
102
-				$ids = implode( ',', $ids );
102
+				$ids = implode(',', $ids);
103 103
 
104
-				switch ( $type ) {
104
+				switch ($type) {
105 105
 					case 'customers':
106
-						$table_name = $wpdb->prefix . 'give_customers';
107
-						$meta_table_name = $wpdb->prefix . 'give_customermeta';
106
+						$table_name = $wpdb->prefix.'give_customers';
107
+						$meta_table_name = $wpdb->prefix.'give_customermeta';
108 108
 						$sql[]      = "DELETE FROM $table_name WHERE id IN ($ids)";
109 109
 						$sql[]      = "DELETE FROM $meta_table_name WHERE customer_id IN ($ids)";
110 110
 						break;
@@ -120,16 +120,16 @@  discard block
 block discarded – undo
120 120
 						break;
121 121
 				}
122 122
 
123
-				if ( ! in_array( $type, array( 'customers', 'forms', 'other' ) ) ) {
123
+				if ( ! in_array($type, array('customers', 'forms', 'other'))) {
124 124
 					// Allows other types of custom post types to filter on their own post_type
125 125
 					// and add items to the query list, for the IDs found in their post type.
126
-					$sql = apply_filters( "give_reset_add_queries_{$type}", $sql, $ids );
126
+					$sql = apply_filters("give_reset_add_queries_{$type}", $sql, $ids);
127 127
 				}
128 128
 			}
129 129
 
130
-			if ( ! empty( $sql ) ) {
131
-				foreach ( $sql as $query ) {
132
-					$wpdb->query( $query );
130
+			if ( ! empty($sql)) {
131
+				foreach ($sql as $query) {
132
+					$wpdb->query($query);
133 133
 				}
134 134
 			}
135 135
 
@@ -149,16 +149,16 @@  discard block
 block discarded – undo
149 149
 	 */
150 150
 	public function get_percentage_complete() {
151 151
 
152
-		$items = $this->get_stored_data( 'give_temp_reset_ids' );
153
-		$total = count( $items );
152
+		$items = $this->get_stored_data('give_temp_reset_ids');
153
+		$total = count($items);
154 154
 
155 155
 		$percentage = 100;
156 156
 
157
-		if ( $total > 0 ) {
158
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
157
+		if ($total > 0) {
158
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
159 159
 		}
160 160
 
161
-		if ( $percentage > 100 ) {
161
+		if ($percentage > 100) {
162 162
 			$percentage = 100;
163 163
 		}
164 164
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 	 *
173 173
 	 * @param array $request The Form Data passed into the batch processing.
174 174
 	 */
175
-	public function set_properties( $request ) {
175
+	public function set_properties($request) {
176 176
 	}
177 177
 
178 178
 	/**
@@ -183,31 +183,31 @@  discard block
 block discarded – undo
183 183
 	 */
184 184
 	public function process_step() {
185 185
 
186
-		if ( ! $this->can_export() ) {
187
-			wp_die( esc_html__( 'You do not have permission to reset data.', 'give' ), esc_html__( 'Error', 'give' ), array(
186
+		if ( ! $this->can_export()) {
187
+			wp_die(esc_html__('You do not have permission to reset data.', 'give'), esc_html__('Error', 'give'), array(
188 188
 				'response' => 403,
189
-			) );
189
+			));
190 190
 		}
191 191
 
192 192
 		$had_data = $this->get_data();
193 193
 
194
-		if ( $had_data ) {
194
+		if ($had_data) {
195 195
 			$this->done = false;
196 196
 
197 197
 			return true;
198 198
 		} else {
199
-			update_option( 'give_earnings_total', 0 );
200
-			Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) );
199
+			update_option('give_earnings_total', 0);
200
+			Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
201 201
 
202
-			$this->delete_data( 'give_temp_reset_ids' );
202
+			$this->delete_data('give_temp_reset_ids');
203 203
 
204 204
 			// Reset the sequential order numbers
205
-			if ( give_get_option( 'enable_sequential' ) ) {
206
-				delete_option( 'give_last_payment_number' );
205
+			if (give_get_option('enable_sequential')) {
206
+				delete_option('give_last_payment_number');
207 207
 			}
208 208
 
209 209
 			$this->done    = true;
210
-			$this->message = esc_html__( 'Donation forms, income, donations counts, and logs successfully reset.', 'give' );
210
+			$this->message = esc_html__('Donation forms, income, donations counts, and logs successfully reset.', 'give');
211 211
 
212 212
 			return false;
213 213
 		}
@@ -217,10 +217,10 @@  discard block
 block discarded – undo
217 217
 	 * Headers
218 218
 	 */
219 219
 	public function headers() {
220
-		ignore_user_abort( true );
220
+		ignore_user_abort(true);
221 221
 
222
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
223
-			set_time_limit( 0 );
222
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
223
+			set_time_limit(0);
224 224
 		}
225 225
 	}
226 226
 
@@ -244,26 +244,26 @@  discard block
 block discarded – undo
244 244
 	 */
245 245
 	public function pre_fetch() {
246 246
 
247
-		if ( $this->step == 1 ) {
248
-			$this->delete_data( 'give_temp_reset_ids' );
247
+		if ($this->step == 1) {
248
+			$this->delete_data('give_temp_reset_ids');
249 249
 		}
250 250
 
251
-		$items = get_option( 'give_temp_reset_ids', false );
251
+		$items = get_option('give_temp_reset_ids', false);
252 252
 
253
-		if ( false === $items ) {
253
+		if (false === $items) {
254 254
 			$items = array();
255 255
 
256
-			$give_types_for_reset = array( 'give_forms', 'give_payment' );
257
-			$give_types_for_reset = apply_filters( 'give_reset_store_post_types', $give_types_for_reset );
256
+			$give_types_for_reset = array('give_forms', 'give_payment');
257
+			$give_types_for_reset = apply_filters('give_reset_store_post_types', $give_types_for_reset);
258 258
 
259
-			$args = apply_filters( 'give_tools_reset_stats_total_args', array(
259
+			$args = apply_filters('give_tools_reset_stats_total_args', array(
260 260
 				'post_type'      => $give_types_for_reset,
261 261
 				'post_status'    => 'any',
262
-				'posts_per_page' => - 1,
263
-			) );
262
+				'posts_per_page' => -1,
263
+			));
264 264
 
265
-			$posts = get_posts( $args );
266
-			foreach ( $posts as $post ) {
265
+			$posts = get_posts($args);
266
+			foreach ($posts as $post) {
267 267
 				$items[] = array(
268 268
 					'id'   => (int) $post->ID,
269 269
 					'type' => $post->post_type,
@@ -271,10 +271,10 @@  discard block
 block discarded – undo
271 271
 			}
272 272
 
273 273
 			$donor_args = array(
274
-				'number' => - 1,
274
+				'number' => -1,
275 275
 			);
276
-			$donors     = Give()->donors->get_donors( $donor_args );
277
-			foreach ( $donors as $donor ) {
276
+			$donors     = Give()->donors->get_donors($donor_args);
277
+			foreach ($donors as $donor) {
278 278
 				$items[] = array(
279 279
 					'id'   => (int) $donor->id,
280 280
 					'type' => 'customer',
@@ -283,9 +283,9 @@  discard block
 block discarded – undo
283 283
 
284 284
 			// Allow filtering of items to remove with an unassociative array for each item
285 285
 			// The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method
286
-			$items = apply_filters( 'give_reset_items', $items );
286
+			$items = apply_filters('give_reset_items', $items);
287 287
 
288
-			$this->store_data( 'give_temp_reset_ids', $items );
288
+			$this->store_data('give_temp_reset_ids', $items);
289 289
 		}// End if().
290 290
 
291 291
 	}
@@ -299,17 +299,17 @@  discard block
 block discarded – undo
299 299
 	 *
300 300
 	 * @return mixed       Returns the data from the database.
301 301
 	 */
302
-	private function get_stored_data( $key ) {
302
+	private function get_stored_data($key) {
303 303
 		global $wpdb;
304
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
304
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
305 305
 
306
-		if ( empty( $value ) ) {
306
+		if (empty($value)) {
307 307
 			return false;
308 308
 		}
309 309
 
310
-		$maybe_json = json_decode( $value );
311
-		if ( ! is_null( $maybe_json ) ) {
312
-			$value = json_decode( $value, true );
310
+		$maybe_json = json_decode($value);
311
+		if ( ! is_null($maybe_json)) {
312
+			$value = json_decode($value, true);
313 313
 		}
314 314
 
315 315
 		return $value;
@@ -325,10 +325,10 @@  discard block
 block discarded – undo
325 325
 	 *
326 326
 	 * @return void
327 327
 	 */
328
-	private function store_data( $key, $value ) {
328
+	private function store_data($key, $value) {
329 329
 		global $wpdb;
330 330
 
331
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
331
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
332 332
 
333 333
 		$data = array(
334 334
 			'option_name'  => $key,
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 			'%s',
343 343
 		);
344 344
 
345
-		$wpdb->replace( $wpdb->options, $data, $formats );
345
+		$wpdb->replace($wpdb->options, $data, $formats);
346 346
 	}
347 347
 
348 348
 	/**
@@ -354,11 +354,11 @@  discard block
 block discarded – undo
354 354
 	 *
355 355
 	 * @return void
356 356
 	 */
357
-	private function delete_data( $key ) {
357
+	private function delete_data($key) {
358 358
 		global $wpdb;
359
-		$wpdb->delete( $wpdb->options, array(
359
+		$wpdb->delete($wpdb->options, array(
360 360
 			'option_name' => $key,
361
-		) );
361
+		));
362 362
 	}
363 363
 
364 364
 }
365 365
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/tools/data/tools-actions.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -20,10 +20,10 @@  discard block
 block discarded – undo
20 20
  * @since  1.5
21 21
  */
22 22
 function give_register_batch_recount_export_classes() {
23
-	add_action( 'give_batch_export_class_include', 'give_include_batch_export_class', 10, 1 );
23
+	add_action('give_batch_export_class_include', 'give_include_batch_export_class', 10, 1);
24 24
 }
25 25
 
26
-add_action( 'give_register_batch_exporter', 'give_register_batch_recount_export_classes', 10 );
26
+add_action('give_register_batch_exporter', 'give_register_batch_recount_export_classes', 10);
27 27
 
28 28
 
29 29
 /**
@@ -35,39 +35,39 @@  discard block
 block discarded – undo
35 35
  *
36 36
  * @return void
37 37
  */
38
-function give_include_batch_export_class( $class ) {
39
-	switch ( $class ) {
38
+function give_include_batch_export_class($class) {
39
+	switch ($class) {
40 40
 
41 41
 		case 'Give_Tools_Delete_Donors':
42
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-delete-test-donors.php';
42
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-delete-test-donors.php';
43 43
 			break;
44 44
 
45 45
 		case 'Give_Tools_Import_Donors':
46
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-delete-import-donors.php';
46
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-delete-import-donors.php';
47 47
 			break;
48 48
 
49 49
 		case 'Give_Tools_Delete_Test_Transactions':
50
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-delete-test-transactions.php';
50
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-delete-test-transactions.php';
51 51
 			break;
52 52
 
53 53
 		case 'Give_Tools_Recount_Donor_Stats':
54
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-donor-stats.php';
54
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-donor-stats.php';
55 55
 			break;
56 56
 
57 57
 		case 'Give_Tools_Reset_Stats':
58
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-reset-stats.php';
58
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-reset-stats.php';
59 59
 			break;
60 60
 
61 61
 		case 'Give_Tools_Recount_All_Stats':
62
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-all-stats.php';
62
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-all-stats.php';
63 63
 			break;
64 64
 
65 65
 		case 'Give_Tools_Recount_Form_Stats':
66
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-form-stats.php';
66
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-form-stats.php';
67 67
 			break;
68 68
 
69 69
 		case 'Give_Tools_Recount_Income':
70
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-income.php';
70
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-income.php';
71 71
 			break;
72 72
 	}
73 73
 }
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-income.php 1 patch
Spacing   +48 added lines, -48 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 += give_get_payment_amount( $payment );
82
+				$total += give_get_payment_amount($payment);
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_currency_decimal_filter() );
90
+			$total = round($total, give_currency_decimal_filter());
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
 		}
@@ -176,10 +176,10 @@  discard block
 block discarded – undo
176 176
 	 * Headers.
177 177
 	 */
178 178
 	public function headers() {
179
-		ignore_user_abort( true );
179
+		ignore_user_abort(true);
180 180
 
181
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
182
-			set_time_limit( 0 );
181
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
182
+			set_time_limit(0);
183 183
 		}
184 184
 	}
185 185
 
@@ -207,17 +207,17 @@  discard block
 block discarded – undo
207 207
 	 *
208 208
 	 * @return mixed       Returns the data from the database
209 209
 	 */
210
-	private function get_stored_data( $key ) {
210
+	private function get_stored_data($key) {
211 211
 		global $wpdb;
212
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
212
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
213 213
 
214
-		if ( empty( $value ) ) {
214
+		if (empty($value)) {
215 215
 			return false;
216 216
 		}
217 217
 
218
-		$maybe_json = json_decode( $value );
219
-		if ( ! is_null( $maybe_json ) ) {
220
-			$value = json_decode( $value, true );
218
+		$maybe_json = json_decode($value);
219
+		if ( ! is_null($maybe_json)) {
220
+			$value = json_decode($value, true);
221 221
 		}
222 222
 
223 223
 		return $value;
@@ -233,10 +233,10 @@  discard block
 block discarded – undo
233 233
 	 *
234 234
 	 * @return void
235 235
 	 */
236
-	private function store_data( $key, $value ) {
236
+	private function store_data($key, $value) {
237 237
 		global $wpdb;
238 238
 
239
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
239
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
240 240
 
241 241
 		$data = array(
242 242
 			'option_name'  => $key,
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 			'%s',
251 251
 		);
252 252
 
253
-		$wpdb->replace( $wpdb->options, $data, $formats );
253
+		$wpdb->replace($wpdb->options, $data, $formats);
254 254
 	}
255 255
 
256 256
 	/**
@@ -262,9 +262,9 @@  discard block
 block discarded – undo
262 262
 	 *
263 263
 	 * @return void
264 264
 	 */
265
-	private function delete_data( $key ) {
265
+	private function delete_data($key) {
266 266
 		global $wpdb;
267
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
267
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
268 268
 	}
269 269
 
270 270
 }
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-delete-test-transactions.php 1 patch
Spacing   +59 added lines, -59 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
 
@@ -55,22 +55,22 @@  discard block
 block discarded – undo
55 55
 	public function get_data() {
56 56
 		global $wpdb;
57 57
 
58
-		$items = $this->get_stored_data( 'give_temp_delete_test_ids' );
58
+		$items = $this->get_stored_data('give_temp_delete_test_ids');
59 59
 
60
-		if ( ! is_array( $items ) ) {
60
+		if ( ! is_array($items)) {
61 61
 			return false;
62 62
 		}
63 63
 
64
-		$offset     = ( $this->step - 1 ) * $this->per_step;
65
-		$step_items = array_slice( $items, $offset, $this->per_step );
64
+		$offset     = ($this->step - 1) * $this->per_step;
65
+		$step_items = array_slice($items, $offset, $this->per_step);
66 66
 
67
-		if ( $step_items ) {
67
+		if ($step_items) {
68 68
 
69 69
 			$step_ids = array(
70 70
 				'other' => array(),
71 71
 			);
72 72
 
73
-			foreach ( $step_items as $item ) {
73
+			foreach ($step_items as $item) {
74 74
 
75 75
 				$step_ids['other'][] = $item['id'];
76 76
 
@@ -78,31 +78,31 @@  discard block
 block discarded – undo
78 78
 
79 79
 			$sql = array();
80 80
 
81
-			foreach ( $step_ids as $type => $ids ) {
81
+			foreach ($step_ids as $type => $ids) {
82 82
 
83
-				if ( empty( $ids ) ) {
83
+				if (empty($ids)) {
84 84
 					continue;
85 85
 				}
86 86
 
87 87
 				$parent_query = '';
88 88
 
89
-				switch ( $type ) {
89
+				switch ($type) {
90 90
 					case 'other':
91 91
 
92
-						$temp_ids = implode( ',', $ids );
92
+						$temp_ids = implode(',', $ids);
93 93
 
94 94
 						// Get all the test logs of the donations ids.
95 95
 						$parent_query = "SELECT DISTINCT post_id as id FROM $wpdb->postmeta WHERE meta_key = '_give_log_payment_id' AND meta_value IN ( $temp_ids )";
96
-						$parent_ids   = $wpdb->get_results( $parent_query, 'ARRAY_A' );
96
+						$parent_ids   = $wpdb->get_results($parent_query, 'ARRAY_A');
97 97
 
98 98
 						// List of all test logs.
99
-						if ( $parent_ids ) {
100
-							foreach ( $parent_ids as $parent_id ) {
99
+						if ($parent_ids) {
100
+							foreach ($parent_ids as $parent_id) {
101 101
 								// Adding all the test log in post ids that are going to get deleted.
102 102
 								$ids[] = $parent_id['id'];
103 103
 							}
104 104
 						}
105
-						$ids = implode( ',', $ids );
105
+						$ids = implode(',', $ids);
106 106
 
107 107
 						$sql[] = "DELETE FROM $wpdb->posts WHERE id IN ($ids)";
108 108
 						$sql[] = "DELETE FROM $wpdb->postmeta WHERE post_id IN ($ids)";
@@ -113,11 +113,11 @@  discard block
 block discarded – undo
113 113
 
114 114
 			}
115 115
 
116
-			if ( ! empty( $sql ) ) {
117
-				foreach ( $sql as $query ) {
118
-					$wpdb->query( $query );
116
+			if ( ! empty($sql)) {
117
+				foreach ($sql as $query) {
118
+					$wpdb->query($query);
119 119
 				}
120
-				do_action( 'give_delete_log_cache' );
120
+				do_action('give_delete_log_cache');
121 121
 			}
122 122
 
123 123
 			return true;
@@ -134,16 +134,16 @@  discard block
 block discarded – undo
134 134
 	 */
135 135
 	public function get_percentage_complete() {
136 136
 
137
-		$items = $this->get_stored_data( 'give_temp_delete_test_ids', false );
138
-		$total = count( $items );
137
+		$items = $this->get_stored_data('give_temp_delete_test_ids', false);
138
+		$total = count($items);
139 139
 
140 140
 		$percentage = 100;
141 141
 
142
-		if ( $total > 0 ) {
143
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
142
+		if ($total > 0) {
143
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
144 144
 		}
145 145
 
146
-		if ( $percentage > 100 ) {
146
+		if ($percentage > 100) {
147 147
 			$percentage = 100;
148 148
 		}
149 149
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	 *
158 158
 	 * @param array $request The Form Data passed into the batch processing
159 159
 	 */
160
-	public function set_properties( $request ) {
160
+	public function set_properties($request) {
161 161
 	}
162 162
 
163 163
 	/**
@@ -168,29 +168,29 @@  discard block
 block discarded – undo
168 168
 	 */
169 169
 	public function process_step() {
170 170
 
171
-		if ( ! $this->can_export() ) {
172
-			wp_die( __( 'You do not have permission to delete test transactions.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
171
+		if ( ! $this->can_export()) {
172
+			wp_die(__('You do not have permission to delete test transactions.', 'give'), __('Error', 'give'), array('response' => 403));
173 173
 		}
174 174
 
175 175
 		$had_data = $this->get_data();
176 176
 
177
-		if ( $had_data ) {
177
+		if ($had_data) {
178 178
 			$this->done = false;
179 179
 
180 180
 			return true;
181 181
 		} else {
182
-			update_option( 'give_earnings_total', give_get_total_earnings( true ) );
183
-			Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) );
182
+			update_option('give_earnings_total', give_get_total_earnings(true));
183
+			Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
184 184
 
185
-			$this->delete_data( 'give_temp_delete_test_ids' );
185
+			$this->delete_data('give_temp_delete_test_ids');
186 186
 
187 187
 			// Reset the sequential order numbers
188
-			if ( give_get_option( 'enable_sequential' ) ) {
189
-				delete_option( 'give_last_payment_number' );
188
+			if (give_get_option('enable_sequential')) {
189
+				delete_option('give_last_payment_number');
190 190
 			}
191 191
 
192 192
 			$this->done    = true;
193
-			$this->message = __( 'Test transactions successfully deleted.', 'give' );
193
+			$this->message = __('Test transactions successfully deleted.', 'give');
194 194
 
195 195
 			return false;
196 196
 		}
@@ -200,10 +200,10 @@  discard block
 block discarded – undo
200 200
 	 * Headers
201 201
 	 */
202 202
 	public function headers() {
203
-		ignore_user_abort( true );
203
+		ignore_user_abort(true);
204 204
 
205
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
206
-			set_time_limit( 0 );
205
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
206
+			set_time_limit(0);
207 207
 		}
208 208
 	}
209 209
 
@@ -227,27 +227,27 @@  discard block
 block discarded – undo
227 227
 	 */
228 228
 	public function pre_fetch() {
229 229
 
230
-		if ( $this->step == 1 ) {
231
-			$this->delete_data( 'give_temp_delete_test_ids' );
230
+		if ($this->step == 1) {
231
+			$this->delete_data('give_temp_delete_test_ids');
232 232
 		}
233 233
 
234
-		$items = get_option( 'give_temp_delete_test_ids', false );
234
+		$items = get_option('give_temp_delete_test_ids', false);
235 235
 
236
-		if ( false === $items ) {
236
+		if (false === $items) {
237 237
 			$items = array();
238 238
 
239
-			$args = apply_filters( 'give_tools_reset_stats_total_args', array(
239
+			$args = apply_filters('give_tools_reset_stats_total_args', array(
240 240
 				'post_status' => 'any',
241
-				'number'      => - 1,
241
+				'number'      => -1,
242 242
 				'meta_key'    => '_give_payment_mode',
243 243
 				'meta_value'  => 'test'
244
-			) );
244
+			));
245 245
 
246
-			$posts    = new Give_Payments_Query( $args );
246
+			$posts    = new Give_Payments_Query($args);
247 247
 			$payments = $posts->get_payments();
248 248
 
249 249
 			/* @var Give_Payment $payment */
250
-			foreach ( $payments as $payment ) {
250
+			foreach ($payments as $payment) {
251 251
 				$items[] = array(
252 252
 					'id'   => (int) $payment->ID,
253 253
 					'type' => 'give_payment',
@@ -256,9 +256,9 @@  discard block
 block discarded – undo
256 256
 			
257 257
 			// Allow filtering of items to remove with an unassociative array for each item.
258 258
 			// The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method.
259
-			$items = apply_filters( 'give_delete_test_items', $items );
259
+			$items = apply_filters('give_delete_test_items', $items);
260 260
 
261
-			$this->store_data( 'give_temp_delete_test_ids', $items );
261
+			$this->store_data('give_temp_delete_test_ids', $items);
262 262
 		}
263 263
 
264 264
 	}
@@ -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.