Test Failed
Pull Request — master (#3324)
by Devin
07:59
created
includes/admin/class-blank-slate.php 1 patch
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  * @since       1.8.13
10 10
  */
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit;
14 14
 }
15 15
 
@@ -75,63 +75,63 @@  discard block
 block discarded – undo
75 75
 	 */
76 76
 	public function init() {
77 77
 		// Bail early if screen cannot be detected.
78
-		if ( empty( $this->screen ) ) {
78
+		if (empty($this->screen)) {
79 79
 			return null;
80 80
 		}
81 81
 
82 82
 		$content = array();
83 83
 
84 84
 		// Define content and hook into the appropriate action.
85
-		switch ( $this->screen ) {
85
+		switch ($this->screen) {
86 86
 			// Forms screen.
87 87
 			case 'edit-give_forms':
88
-				$this->form = $this->post_exists( 'give_forms' );
88
+				$this->form = $this->post_exists('give_forms');
89 89
 
90
-				if ( $this->form ) {
90
+				if ($this->form) {
91 91
 					// Form exists. Bail out.
92 92
 					return false;
93 93
 				} else {
94 94
 					// No forms exist.
95
-					$content = $this->get_content( 'no_forms' );
95
+					$content = $this->get_content('no_forms');
96 96
 				}
97 97
 
98
-				add_action( 'manage_posts_extra_tablenav', array( $this, 'render' ) );
98
+				add_action('manage_posts_extra_tablenav', array($this, 'render'));
99 99
 				break;
100 100
 			// Donations screen.
101 101
 			case 'give_forms_page_give-payment-history':
102
-				$this->form     = $this->post_exists( 'give_forms' );
103
-				$this->donation = $this->post_exists( 'give_payment' );
102
+				$this->form     = $this->post_exists('give_forms');
103
+				$this->donation = $this->post_exists('give_payment');
104 104
 
105
-				if ( $this->donation ) {
105
+				if ($this->donation) {
106 106
 					// Donation exists. Bail out.
107 107
 					return false;
108
-				} elseif ( ! $this->form ) {
108
+				} elseif ( ! $this->form) {
109 109
 					// No forms and no donations exist.
110
-					$content = $this->get_content( 'no_donations_or_forms' );
110
+					$content = $this->get_content('no_donations_or_forms');
111 111
 				} else {
112 112
 					// No donations exist but a form does exist.
113
-					$content = $this->get_content( 'no_donations' );
113
+					$content = $this->get_content('no_donations');
114 114
 				}
115 115
 
116
-				add_action( 'give_payments_page_bottom', array( $this, 'render' ) );
116
+				add_action('give_payments_page_bottom', array($this, 'render'));
117 117
 				break;
118 118
 			// Donors screen.
119 119
 			case 'give_forms_page_give-donors':
120
-				$this->form  = $this->post_exists( 'give_forms' );
120
+				$this->form  = $this->post_exists('give_forms');
121 121
 				$this->donor = $this->donor_exists();
122 122
 
123
-				if ( $this->donor ) {
123
+				if ($this->donor) {
124 124
 					// Donor exists. Bail out.
125 125
 					return false;
126
-				} elseif ( ! $this->form ) {
126
+				} elseif ( ! $this->form) {
127 127
 					// No forms and no donors exist.
128
-					$content = $this->get_content( 'no_donors_or_forms' );
128
+					$content = $this->get_content('no_donors_or_forms');
129 129
 				} else {
130 130
 					// No donors exist but a form does exist.
131
-					$content = $this->get_content( 'no_donors' );
131
+					$content = $this->get_content('no_donors');
132 132
 				}
133 133
 
134
-				add_action( 'give_donors_table_bottom', array( $this, 'render' ) );
134
+				add_action('give_donors_table_bottom', array($this, 'render'));
135 135
 				break;
136 136
 			default:
137 137
 				return null;
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 		$this->content = $content;
141 141
 
142 142
 		// Hide non-essential UI elements.
143
-		add_action( 'admin_head', array( $this, 'hide_ui' ) );
143
+		add_action('admin_head', array($this, 'hide_ui'));
144 144
 	}
145 145
 
146 146
 	/**
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
 	 *
151 151
 	 * @param string $which The location of the list table hook: 'top' or 'bottom'.
152 152
 	 */
153
-	public function render( $which = 'bottom' ) {
153
+	public function render($which = 'bottom') {
154 154
 		// Bail out to prevent content from rendering twice.
155
-		if ( 'top' === $which ) {
155
+		if ('top' === $which) {
156 156
 			return null;
157 157
 		}
158 158
 
@@ -177,9 +177,9 @@  discard block
 block discarded – undo
177 177
 		 *
178 178
 		 * @param string $screen The current screen ID.
179 179
 		 */
180
-		$content = apply_filters( 'give_blank_slate_content', $this->content, $screen );
180
+		$content = apply_filters('give_blank_slate_content', $this->content, $screen);
181 181
 
182
-		$template_path = GIVE_PLUGIN_DIR . 'includes/admin/views/blank-slate.php';
182
+		$template_path = GIVE_PLUGIN_DIR.'includes/admin/views/blank-slate.php';
183 183
 
184 184
 		include $template_path;
185 185
 	}
@@ -214,17 +214,17 @@  discard block
 block discarded – undo
214 214
 	 * @param string $post_type Post type used in the query.
215 215
 	 * @return bool True if post exists, otherwise false.
216 216
 	 */
217
-	private function post_exists( $post_type ) {
217
+	private function post_exists($post_type) {
218 218
 		// Attempt to get a single post of the post type.
219
-		$query = new WP_Query( array(
219
+		$query = new WP_Query(array(
220 220
 			'post_type'              => $post_type,
221 221
 			'posts_per_page'         => 1,
222 222
 			'no_found_rows'          => false,
223 223
 			'update_post_meta_cache' => false,
224 224
 			'update_post_term_cache' => false,
225 225
 			'fields'                 => 'ids',
226
-			'post_status'            => array( 'any', 'trash' ),
227
-		) );
226
+			'post_status'            => array('any', 'trash'),
227
+		));
228 228
 
229 229
 		return $query->have_posts();
230 230
 	}
@@ -237,9 +237,9 @@  discard block
 block discarded – undo
237 237
 	 * @return bool True if donor exists, otherwise false.
238 238
 	 */
239 239
 	private function donor_exists() {
240
-		$donors = Give()->donors->get_donors( array( 'number' => 1 ) );
240
+		$donors = Give()->donors->get_donors(array('number' => 1));
241 241
 
242
-		return ! empty( $donors );
242
+		return ! empty($donors);
243 243
 	}
244 244
 
245 245
 	/**
@@ -250,18 +250,18 @@  discard block
 block discarded – undo
250 250
 	 * @param string $context The key used to determine which content is returned.
251 251
 	 * @return array Blank slate content.
252 252
 	 */
253
-	private function get_content( $context ) {
253
+	private function get_content($context) {
254 254
 		// Define default content.
255 255
 		$defaults = array(
256
-			'image_url' => GIVE_PLUGIN_URL . 'assets/dist/images/give-icon-full-circle.svg',
257
-			'image_alt' => __( 'Give Icon', 'give' ),
258
-			'heading'   => __( 'No donation forms  found.', 'give' ),
259
-			'message'   => __( 'The first step towards accepting online donations is to create a form.', 'give' ),
260
-			'cta_text'  => __( 'Create Donation Form', 'give' ),
261
-			'cta_link'  => admin_url( 'post-new.php?post_type=give_forms' ),
256
+			'image_url' => GIVE_PLUGIN_URL.'assets/dist/images/give-icon-full-circle.svg',
257
+			'image_alt' => __('Give Icon', 'give'),
258
+			'heading'   => __('No donation forms  found.', 'give'),
259
+			'message'   => __('The first step towards accepting online donations is to create a form.', 'give'),
260
+			'cta_text'  => __('Create Donation Form', 'give'),
261
+			'cta_link'  => admin_url('post-new.php?post_type=give_forms'),
262 262
 			'help'      => sprintf(
263 263
 				/* translators: 1: Opening anchor tag. 2: Closing anchor tag. */
264
-				__( 'Need help? Get started with %1$sGive 101%2$s.', 'give' ),
264
+				__('Need help? Get started with %1$sGive 101%2$s.', 'give'),
265 265
 				'<a href="http://docs.givewp.com/give101/" target="_blank">',
266 266
 				'</a>'
267 267
 			),
@@ -270,42 +270,42 @@  discard block
 block discarded – undo
270 270
 		// Define contextual content.
271 271
 		$content = array(
272 272
 			'no_donations_or_forms' => array(
273
-				'heading' => __( 'No donations found.', 'give' ),
274
-				'message' => __( 'Your donation history will appear here, but first, you need a donation form!', 'give' ),
273
+				'heading' => __('No donations found.', 'give'),
274
+				'message' => __('Your donation history will appear here, but first, you need a donation form!', 'give'),
275 275
 			),
276 276
 			'no_donations'          => array(
277
-				'heading'  => __( 'No donations found.', 'give' ),
278
-				'message'  => __( 'When your first donation arrives, a record of the donation will appear here.', 'give' ),
279
-				'cta_text' => __( 'View All Forms', 'give' ),
280
-				'cta_link' => admin_url( 'edit.php?post_type=give_forms' ),
277
+				'heading'  => __('No donations found.', 'give'),
278
+				'message'  => __('When your first donation arrives, a record of the donation will appear here.', 'give'),
279
+				'cta_text' => __('View All Forms', 'give'),
280
+				'cta_link' => admin_url('edit.php?post_type=give_forms'),
281 281
 				'help'     => sprintf(
282 282
 					/* translators: 1: Opening anchor tag. 2: Closing anchor tag. */
283
-					__( 'Need help? Learn more about %1$sDonations%2$s.', 'give' ),
283
+					__('Need help? Learn more about %1$sDonations%2$s.', 'give'),
284 284
 					'<a href="http://docs.givewp.com/core-donations/">',
285 285
 					'</a>'
286 286
 				),
287 287
 			),
288 288
 			'no_donors_or_forms'    => array(
289
-				'heading' => __( 'No donors  found.', 'give' ),
290
-				'message' => __( 'Your donor history will appear here, but first, you need a donation form!', 'give' ),
289
+				'heading' => __('No donors  found.', 'give'),
290
+				'message' => __('Your donor history will appear here, but first, you need a donation form!', 'give'),
291 291
 			),
292 292
 			'no_donors'             => array(
293
-				'heading'  => __( 'No donors found.', 'give' ),
294
-				'message'  => __( 'When your first donation arrives, the donor will appear here.', 'give' ),
295
-				'cta_text' => __( 'View All Forms', 'give' ),
296
-				'cta_link' => admin_url( 'edit.php?post_type=give_forms' ),
293
+				'heading'  => __('No donors found.', 'give'),
294
+				'message'  => __('When your first donation arrives, the donor will appear here.', 'give'),
295
+				'cta_text' => __('View All Forms', 'give'),
296
+				'cta_link' => admin_url('edit.php?post_type=give_forms'),
297 297
 				'help'     => sprintf(
298 298
 					/* translators: 1: Opening anchor tag. 2: Closing anchor tag. */
299
-					__( 'Need help? Learn more about %1$sDonors%2$s.', 'give' ),
299
+					__('Need help? Learn more about %1$sDonors%2$s.', 'give'),
300 300
 					'<a href="http://docs.givewp.com/core-donors/">',
301 301
 					'</a>'
302 302
 				),
303 303
 			),
304 304
 		);
305 305
 
306
-		if ( isset( $content[ $context ] ) ) {
306
+		if (isset($content[$context])) {
307 307
 			// Merge contextual content with defaults.
308
-			return wp_parse_args( $content[ $context ], $defaults );
308
+			return wp_parse_args($content[$context], $defaults);
309 309
 		} else {
310 310
 			// Return defaults if context is undefined.
311 311
 			return $defaults;
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-form-stats.php 1 patch
Spacing   +56 added lines, -56 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,8 +53,8 @@  discard block
 block discarded – undo
53 53
 	/**
54 54
 	 * Constructor.
55 55
 	 */
56
-	public function __construct( $_step = 1 ) {
57
-		parent::__construct( $_step );
56
+	public function __construct($_step = 1) {
57
+		parent::__construct($_step);
58 58
 
59 59
 		$this->is_writable = true;
60 60
 	}
@@ -69,43 +69,43 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	public function get_data() {
71 71
 
72
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
72
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
73 73
 
74
-		if ( $this->step == 1 ) {
75
-			$this->delete_data( 'give_temp_recount_form_stats' );
74
+		if ($this->step == 1) {
75
+			$this->delete_data('give_temp_recount_form_stats');
76 76
 		}
77 77
 
78
-		$totals = $this->get_stored_data( 'give_temp_recount_form_stats' );
78
+		$totals = $this->get_stored_data('give_temp_recount_form_stats');
79 79
 
80
-		if ( false === $totals ) {
80
+		if (false === $totals) {
81 81
 			$totals = array(
82 82
 				'earnings' => (float) 0,
83 83
 				'sales'    => 0,
84 84
 			);
85
-			$this->store_data( 'give_temp_recount_form_stats', $totals );
85
+			$this->store_data('give_temp_recount_form_stats', $totals);
86 86
 		}
87 87
 
88
-		$args = apply_filters( 'give_recount_form_stats_args', array(
88
+		$args = apply_filters('give_recount_form_stats_args', array(
89 89
 			'give_forms' => $this->form_id,
90 90
 			'number'     => $this->per_step,
91 91
 			'status'     => $accepted_statuses,
92 92
 			'paged'      => $this->step,
93 93
 			'fields'     => 'ids',
94
-		) );
94
+		));
95 95
 
96
-		$payments = new Give_Payments_Query( $args );
96
+		$payments = new Give_Payments_Query($args);
97 97
 		$payments = $payments->get_payments();
98 98
 
99
-		if ( $payments ) {
100
-			foreach ( $payments as $payment ) {
99
+		if ($payments) {
100
+			foreach ($payments as $payment) {
101 101
 
102 102
 				// Ensure acceptable status only.
103
-				if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
103
+				if ( ! in_array($payment->post_status, $accepted_statuses)) {
104 104
 					continue;
105 105
 				}
106 106
 
107 107
 				// Ensure only payments for this form are counted.
108
-				if ( $payment->form_id != $this->form_id ) {
108
+				if ($payment->form_id != $this->form_id) {
109 109
 					continue;
110 110
 				}
111 111
 
@@ -116,25 +116,25 @@  discard block
 block discarded – undo
116 116
 				 */
117 117
 				$earning_amount = apply_filters(
118 118
 					'give_donation_amount',
119
-					give_format_amount( $payment->total, array( 'donation_id' => $payment->ID ) ),
119
+					give_format_amount($payment->total, array('donation_id' => $payment->ID)),
120 120
 					$payment->total,
121 121
 					$payment->ID,
122
-					array( 'type' => 'stats', 'currency' => false, 'amount' => false )
122
+					array('type' => 'stats', 'currency' => false, 'amount' => false)
123 123
 				);
124 124
 
125
-				$totals['sales'] ++;
126
-				$totals['earnings'] += (float) give_maybe_sanitize_amount( $earning_amount );
125
+				$totals['sales']++;
126
+				$totals['earnings'] += (float) give_maybe_sanitize_amount($earning_amount);
127 127
 
128 128
 			}
129 129
 
130
-			$this->store_data( 'give_temp_recount_form_stats', $totals );
130
+			$this->store_data('give_temp_recount_form_stats', $totals);
131 131
 
132 132
 			return true;
133 133
 		}
134 134
 
135 135
 
136
-		give_update_meta( $this->form_id, '_give_form_sales', $totals['sales'] );
137
-		give_update_meta( $this->form_id, '_give_form_earnings', give_sanitize_amount_for_db( $totals['earnings'] ) );
136
+		give_update_meta($this->form_id, '_give_form_sales', $totals['sales']);
137
+		give_update_meta($this->form_id, '_give_form_earnings', give_sanitize_amount_for_db($totals['earnings']));
138 138
 
139 139
 		return false;
140 140
 	}
@@ -146,35 +146,35 @@  discard block
 block discarded – undo
146 146
 	 * @return int
147 147
 	 */
148 148
 	public function get_percentage_complete() {
149
-		if ( $this->step == 1 ) {
150
-			$this->delete_data( 'give_recount_total_' . $this->form_id );
149
+		if ($this->step == 1) {
150
+			$this->delete_data('give_recount_total_'.$this->form_id);
151 151
 		}
152 152
 
153
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
154
-		$total             = $this->get_stored_data( 'give_recount_total_' . $this->form_id );
153
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
154
+		$total             = $this->get_stored_data('give_recount_total_'.$this->form_id);
155 155
 
156
-		if ( false === $total ) {
156
+		if (false === $total) {
157 157
 			$total = 0;
158
-			$args  = apply_filters( 'give_recount_form_stats_total_args', array(
158
+			$args  = apply_filters('give_recount_form_stats_total_args', array(
159 159
 				'give_forms' => $this->form_id,
160
-				'number'     => - 1,
160
+				'number'     => -1,
161 161
 				'status'     => $accepted_statuses,
162 162
 				'fields'     => 'ids',
163
-			) );
163
+			));
164 164
 
165
-			$payments = new Give_Payments_Query( $args );
166
-			$total    = count( $payments->get_payments() );
167
-			$this->store_data( 'give_recount_total_' . $this->form_id, $total );
165
+			$payments = new Give_Payments_Query($args);
166
+			$total    = count($payments->get_payments());
167
+			$this->store_data('give_recount_total_'.$this->form_id, $total);
168 168
 
169 169
 		}
170 170
 
171 171
 		$percentage = 100;
172 172
 
173
-		if ( $total > 0 ) {
174
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
173
+		if ($total > 0) {
174
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
175 175
 		}
176 176
 
177
-		if ( $percentage > 100 ) {
177
+		if ($percentage > 100) {
178 178
 			$percentage = 100;
179 179
 		}
180 180
 
@@ -188,8 +188,8 @@  discard block
 block discarded – undo
188 188
 	 *
189 189
 	 * @param array $request The Form Data passed into the batch processing
190 190
 	 */
191
-	public function set_properties( $request ) {
192
-		$this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false;
191
+	public function set_properties($request) {
192
+		$this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false;
193 193
 	}
194 194
 
195 195
 	/**
@@ -200,21 +200,21 @@  discard block
 block discarded – undo
200 200
 	 */
201 201
 	public function process_step() {
202 202
 
203
-		if ( ! $this->can_export() ) {
204
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
203
+		if ( ! $this->can_export()) {
204
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
205 205
 		}
206 206
 
207 207
 		$had_data = $this->get_data();
208 208
 
209
-		if ( $had_data ) {
209
+		if ($had_data) {
210 210
 			$this->done = false;
211 211
 
212 212
 			return true;
213 213
 		} else {
214
-			$this->delete_data( 'give_recount_total_' . $this->form_id );
215
-			$this->delete_data( 'give_temp_recount_form_stats' );
214
+			$this->delete_data('give_recount_total_'.$this->form_id);
215
+			$this->delete_data('give_temp_recount_form_stats');
216 216
 			$this->done    = true;
217
-			$this->message = sprintf( esc_html__( 'Donation counts and income amount statistics successfully recounted for "%s".', 'give' ), get_the_title( $this->form_id ) );
217
+			$this->message = sprintf(esc_html__('Donation counts and income amount statistics successfully recounted for "%s".', 'give'), get_the_title($this->form_id));
218 218
 
219 219
 			return false;
220 220
 		}
@@ -248,17 +248,17 @@  discard block
 block discarded – undo
248 248
 	 *
249 249
 	 * @return mixed       Returns the data from the database
250 250
 	 */
251
-	private function get_stored_data( $key ) {
251
+	private function get_stored_data($key) {
252 252
 		global $wpdb;
253
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
253
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
254 254
 
255
-		if ( empty( $value ) ) {
255
+		if (empty($value)) {
256 256
 			return false;
257 257
 		}
258 258
 
259
-		$maybe_json = json_decode( $value );
260
-		if ( ! is_null( $maybe_json ) ) {
261
-			$value = json_decode( $value, true );
259
+		$maybe_json = json_decode($value);
260
+		if ( ! is_null($maybe_json)) {
261
+			$value = json_decode($value, true);
262 262
 		}
263 263
 
264 264
 		return $value;
@@ -274,10 +274,10 @@  discard block
 block discarded – undo
274 274
 	 *
275 275
 	 * @return void
276 276
 	 */
277
-	private function store_data( $key, $value ) {
277
+	private function store_data($key, $value) {
278 278
 		global $wpdb;
279 279
 
280
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
280
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
281 281
 
282 282
 		$data = array(
283 283
 			'option_name'  => $key,
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 			'%s',
292 292
 		);
293 293
 
294
-		$wpdb->replace( $wpdb->options, $data, $formats );
294
+		$wpdb->replace($wpdb->options, $data, $formats);
295 295
 	}
296 296
 
297 297
 	/**
@@ -303,9 +303,9 @@  discard block
 block discarded – undo
303 303
 	 *
304 304
 	 * @return void
305 305
 	 */
306
-	private function delete_data( $key ) {
306
+	private function delete_data($key) {
307 307
 		global $wpdb;
308
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
308
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
309 309
 	}
310 310
 
311 311
 }
312 312
\ 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   +64 added lines, -64 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
 
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
 	/**
50 50
 	 * Constructor.
51 51
 	 */
52
-	public function __construct( $_step = 1 ) {
53
-		parent::__construct( $_step );
52
+	public function __construct($_step = 1) {
53
+		parent::__construct($_step);
54 54
 
55 55
 		$this->is_writable = true;
56 56
 	}
@@ -67,16 +67,16 @@  discard block
 block discarded – undo
67 67
 	public function get_data() {
68 68
 		global $wpdb;
69 69
 
70
-		$items = $this->get_stored_data( 'give_temp_reset_ids' );
70
+		$items = $this->get_stored_data('give_temp_reset_ids');
71 71
 
72
-		if ( ! is_array( $items ) ) {
72
+		if ( ! is_array($items)) {
73 73
 			return false;
74 74
 		}
75 75
 
76
-		$offset     = ( $this->step - 1 ) * $this->per_step;
77
-		$step_items = array_slice( $items, $offset, $this->per_step );
76
+		$offset     = ($this->step - 1) * $this->per_step;
77
+		$step_items = array_slice($items, $offset, $this->per_step);
78 78
 
79
-		if ( $step_items ) {
79
+		if ($step_items) {
80 80
 
81 81
 			$step_ids = array(
82 82
 				'customers' => array(),
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
 				'other'     => array(),
85 85
 			);
86 86
 
87
-			foreach ( $step_items as $item ) {
87
+			foreach ($step_items as $item) {
88 88
 
89
-				switch ( $item['type'] ) {
89
+				switch ($item['type']) {
90 90
 					case 'customer':
91 91
 						$step_ids['customers'][] = $item['id'];
92 92
 						break;
@@ -94,24 +94,24 @@  discard block
 block discarded – undo
94 94
 						$step_ids['give_forms'][] = $item['id'];
95 95
 						break;
96 96
 					default:
97
-						$item_type                = apply_filters( 'give_reset_item_type', 'other', $item );
98
-						$step_ids[ $item_type ][] = $item['id'];
97
+						$item_type                = apply_filters('give_reset_item_type', 'other', $item);
98
+						$step_ids[$item_type][] = $item['id'];
99 99
 						break;
100 100
 				}
101 101
 			}
102 102
 
103 103
 			$sql = array();
104
-			$meta_table = __give_v20_bc_table_details('form' );
104
+			$meta_table = __give_v20_bc_table_details('form');
105 105
 
106
-			foreach ( $step_ids as $type => $ids ) {
106
+			foreach ($step_ids as $type => $ids) {
107 107
 
108
-				if ( empty( $ids ) ) {
108
+				if (empty($ids)) {
109 109
 					continue;
110 110
 				}
111 111
 
112
-				$ids = implode( ',', $ids );
112
+				$ids = implode(',', $ids);
113 113
 
114
-				switch ( $type ) {
114
+				switch ($type) {
115 115
 					case 'customers':
116 116
 						$sql[]           = "DELETE FROM $wpdb->donors WHERE id IN ($ids)";
117 117
 						$table_name      = $wpdb->donors;
@@ -131,16 +131,16 @@  discard block
 block discarded – undo
131 131
 						break;
132 132
 				}
133 133
 
134
-				if ( ! in_array( $type, array( 'customers', 'forms', 'other' ) ) ) {
134
+				if ( ! in_array($type, array('customers', 'forms', 'other'))) {
135 135
 					// Allows other types of custom post types to filter on their own post_type
136 136
 					// and add items to the query list, for the IDs found in their post type.
137
-					$sql = apply_filters( "give_reset_add_queries_{$type}", $sql, $ids );
137
+					$sql = apply_filters("give_reset_add_queries_{$type}", $sql, $ids);
138 138
 				}
139 139
 			}
140 140
 
141
-			if ( ! empty( $sql ) ) {
142
-				foreach ( $sql as $query ) {
143
-					$wpdb->query( $query );
141
+			if ( ! empty($sql)) {
142
+				foreach ($sql as $query) {
143
+					$wpdb->query($query);
144 144
 				}
145 145
 			}
146 146
 
@@ -160,16 +160,16 @@  discard block
 block discarded – undo
160 160
 	 */
161 161
 	public function get_percentage_complete() {
162 162
 
163
-		$items = $this->get_stored_data( 'give_temp_reset_ids' );
164
-		$total = count( $items );
163
+		$items = $this->get_stored_data('give_temp_reset_ids');
164
+		$total = count($items);
165 165
 
166 166
 		$percentage = 100;
167 167
 
168
-		if ( $total > 0 ) {
169
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
168
+		if ($total > 0) {
169
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
170 170
 		}
171 171
 
172
-		if ( $percentage > 100 ) {
172
+		if ($percentage > 100) {
173 173
 			$percentage = 100;
174 174
 		}
175 175
 
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 	 *
184 184
 	 * @param array $request The Form Data passed into the batch processing.
185 185
 	 */
186
-	public function set_properties( $request ) {
186
+	public function set_properties($request) {
187 187
 	}
188 188
 
189 189
 	/**
@@ -194,26 +194,26 @@  discard block
 block discarded – undo
194 194
 	 */
195 195
 	public function process_step() {
196 196
 
197
-		if ( ! $this->can_export() ) {
198
-			wp_die( esc_html__( 'You do not have permission to reset data.', 'give' ), esc_html__( 'Error', 'give' ), array(
197
+		if ( ! $this->can_export()) {
198
+			wp_die(esc_html__('You do not have permission to reset data.', 'give'), esc_html__('Error', 'give'), array(
199 199
 				'response' => 403,
200
-			) );
200
+			));
201 201
 		}
202 202
 
203 203
 		$had_data = $this->get_data();
204 204
 
205
-		if ( $had_data ) {
205
+		if ($had_data) {
206 206
 			$this->done = false;
207 207
 
208 208
 			return true;
209 209
 		} else {
210
-			update_option( 'give_earnings_total', 0 );
211
-			Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) );
210
+			update_option('give_earnings_total', 0);
211
+			Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
212 212
 
213
-			$this->delete_data( 'give_temp_reset_ids' );
213
+			$this->delete_data('give_temp_reset_ids');
214 214
 
215 215
 			$this->done    = true;
216
-			$this->message = esc_html__( 'Donation forms, income, donations counts, and logs successfully reset.', 'give' );
216
+			$this->message = esc_html__('Donation forms, income, donations counts, and logs successfully reset.', 'give');
217 217
 
218 218
 			return false;
219 219
 		}
@@ -246,26 +246,26 @@  discard block
 block discarded – undo
246 246
 	 */
247 247
 	public function pre_fetch() {
248 248
 
249
-		if ( $this->step == 1 ) {
250
-			$this->delete_data( 'give_temp_reset_ids' );
249
+		if ($this->step == 1) {
250
+			$this->delete_data('give_temp_reset_ids');
251 251
 		}
252 252
 
253
-		$items = get_option( 'give_temp_reset_ids', false );
253
+		$items = get_option('give_temp_reset_ids', false);
254 254
 
255
-		if ( false === $items ) {
255
+		if (false === $items) {
256 256
 			$items = array();
257 257
 
258
-			$give_types_for_reset = array( 'give_forms', 'give_payment' );
259
-			$give_types_for_reset = apply_filters( 'give_reset_store_post_types', $give_types_for_reset );
258
+			$give_types_for_reset = array('give_forms', 'give_payment');
259
+			$give_types_for_reset = apply_filters('give_reset_store_post_types', $give_types_for_reset);
260 260
 
261
-			$args = apply_filters( 'give_tools_reset_stats_total_args', array(
261
+			$args = apply_filters('give_tools_reset_stats_total_args', array(
262 262
 				'post_type'      => $give_types_for_reset,
263 263
 				'post_status'    => 'any',
264
-				'posts_per_page' => - 1,
265
-			) );
264
+				'posts_per_page' => -1,
265
+			));
266 266
 
267
-			$posts = get_posts( $args );
268
-			foreach ( $posts as $post ) {
267
+			$posts = get_posts($args);
268
+			foreach ($posts as $post) {
269 269
 				$items[] = array(
270 270
 					'id'   => (int) $post->ID,
271 271
 					'type' => $post->post_type,
@@ -273,10 +273,10 @@  discard block
 block discarded – undo
273 273
 			}
274 274
 
275 275
 			$donor_args = array(
276
-				'number' => - 1,
276
+				'number' => -1,
277 277
 			);
278
-			$donors     = Give()->donors->get_donors( $donor_args );
279
-			foreach ( $donors as $donor ) {
278
+			$donors     = Give()->donors->get_donors($donor_args);
279
+			foreach ($donors as $donor) {
280 280
 				$items[] = array(
281 281
 					'id'   => (int) $donor->id,
282 282
 					'type' => 'customer',
@@ -285,9 +285,9 @@  discard block
 block discarded – undo
285 285
 
286 286
 			// Allow filtering of items to remove with an unassociative array for each item
287 287
 			// The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method
288
-			$items = apply_filters( 'give_reset_items', $items );
288
+			$items = apply_filters('give_reset_items', $items);
289 289
 
290
-			$this->store_data( 'give_temp_reset_ids', $items );
290
+			$this->store_data('give_temp_reset_ids', $items);
291 291
 		}// End if().
292 292
 
293 293
 	}
@@ -301,17 +301,17 @@  discard block
 block discarded – undo
301 301
 	 *
302 302
 	 * @return mixed       Returns the data from the database.
303 303
 	 */
304
-	private function get_stored_data( $key ) {
304
+	private function get_stored_data($key) {
305 305
 		global $wpdb;
306
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
306
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
307 307
 
308
-		if ( empty( $value ) ) {
308
+		if (empty($value)) {
309 309
 			return false;
310 310
 		}
311 311
 
312
-		$maybe_json = json_decode( $value );
313
-		if ( ! is_null( $maybe_json ) ) {
314
-			$value = json_decode( $value, true );
312
+		$maybe_json = json_decode($value);
313
+		if ( ! is_null($maybe_json)) {
314
+			$value = json_decode($value, true);
315 315
 		}
316 316
 
317 317
 		return $value;
@@ -327,10 +327,10 @@  discard block
 block discarded – undo
327 327
 	 *
328 328
 	 * @return void
329 329
 	 */
330
-	private function store_data( $key, $value ) {
330
+	private function store_data($key, $value) {
331 331
 		global $wpdb;
332 332
 
333
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
333
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
334 334
 
335 335
 		$data = array(
336 336
 			'option_name'  => $key,
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 			'%s',
345 345
 		);
346 346
 
347
-		$wpdb->replace( $wpdb->options, $data, $formats );
347
+		$wpdb->replace($wpdb->options, $data, $formats);
348 348
 	}
349 349
 
350 350
 	/**
@@ -356,11 +356,11 @@  discard block
 block discarded – undo
356 356
 	 *
357 357
 	 * @return void
358 358
 	 */
359
-	private function delete_data( $key ) {
359
+	private function delete_data($key) {
360 360
 		global $wpdb;
361
-		$wpdb->delete( $wpdb->options, array(
361
+		$wpdb->delete($wpdb->options, array(
362 362
 			'option_name' => $key,
363
-		) );
363
+		));
364 364
 	}
365 365
 
366 366
 }
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-all-stats.php 1 patch
Spacing   +100 added lines, -102 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
 
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
 	/**
74 74
 	 * Constructor.
75 75
 	 */
76
-	public function __construct( $_step = 1 ) {
77
-		parent::__construct( $_step );
76
+	public function __construct($_step = 1) {
77
+		parent::__construct($_step);
78 78
 
79 79
 		$this->is_writable = true;
80 80
 	}
@@ -89,108 +89,106 @@  discard block
 block discarded – undo
89 89
 	 */
90 90
 	public function get_data() {
91 91
 
92
-		$totals             = $this->get_stored_data( 'give_temp_recount_all_stats' );
93
-		$payment_items      = $this->get_stored_data( 'give_temp_payment_items' );
94
-		$processed_payments = $this->get_stored_data( 'give_temp_processed_payments' );
95
-		$accepted_statuses  = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
92
+		$totals             = $this->get_stored_data('give_temp_recount_all_stats');
93
+		$payment_items      = $this->get_stored_data('give_temp_payment_items');
94
+		$processed_payments = $this->get_stored_data('give_temp_processed_payments');
95
+		$accepted_statuses  = apply_filters('give_recount_accepted_statuses', array('publish'));
96 96
 
97
-		if ( false === $totals ) {
97
+		if (false === $totals) {
98 98
 			$totals = array();
99 99
 		}
100 100
 
101
-		if ( false === $payment_items ) {
101
+		if (false === $payment_items) {
102 102
 			$payment_items = array();
103 103
 		}
104 104
 
105
-		if ( false === $processed_payments ) {
105
+		if (false === $processed_payments) {
106 106
 			$processed_payments = array();
107 107
 		}
108 108
 
109
-		$all_forms = $this->get_stored_data( 'give_temp_form_ids' );
109
+		$all_forms = $this->get_stored_data('give_temp_form_ids');
110 110
 
111
-		$payments = $this->get_stored_data( 'give_temp_all_payments_data' );
111
+		$payments = $this->get_stored_data('give_temp_all_payments_data');
112 112
 
113
-		if ( empty( $payments ) ) {
114
-			$args = apply_filters( 'give_recount_form_stats_args', array(
113
+		if (empty($payments)) {
114
+			$args = apply_filters('give_recount_form_stats_args', array(
115 115
 				'give_forms' => $all_forms,
116 116
 				'number'     => $this->per_step,
117 117
 				'status'     => $accepted_statuses,
118 118
 				'paged'      => $this->step,
119 119
 				'output'     => 'give_payments',
120
-			) );
120
+			));
121 121
 
122
-			$payments_query = new Give_Payments_Query( $args );
122
+			$payments_query = new Give_Payments_Query($args);
123 123
 			$payments       = $payments_query->get_payments();
124 124
 		}
125 125
 
126
-		if ( ! empty( $payments ) ) {
126
+		if ( ! empty($payments)) {
127 127
 
128 128
 			//Loop through payments
129
-			foreach ( $payments as $payment ) {
129
+			foreach ($payments as $payment) {
130 130
 
131
-				$payment_id = ( ! empty( $payment['ID'] ) ? absint( $payment['ID'] ) : ( ! empty( $payment->ID ) ? absint( $payment->ID ) : false ) );
132
-				$payment = new Give_Payment( $payment_id );
131
+				$payment_id = ( ! empty($payment['ID']) ? absint($payment['ID']) : ( ! empty($payment->ID) ? absint($payment->ID) : false));
132
+				$payment = new Give_Payment($payment_id);
133 133
 
134 134
 				// Prevent payments that have all ready been retrieved from a previous sales log from counting again.
135
-				if ( in_array( $payment->ID, $processed_payments ) ) {
135
+				if (in_array($payment->ID, $processed_payments)) {
136 136
 					continue;
137 137
 				}
138 138
 
139 139
 				// Verify accepted status.
140
-				if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
140
+				if ( ! in_array($payment->post_status, $accepted_statuses)) {
141 141
 					$processed_payments[] = $payment->ID;
142 142
 					continue;
143 143
 				}
144 144
 
145
-				$payment_item = $payment_items[ $payment->ID ];
145
+				$payment_item = $payment_items[$payment->ID];
146 146
 
147
-				$form_id = isset( $payment_item['id'] ) ? $payment_item['id'] : '';
147
+				$form_id = isset($payment_item['id']) ? $payment_item['id'] : '';
148 148
 
149 149
 				// Must have a form ID.
150
-				if ( empty( $form_id ) ) {
150
+				if (empty($form_id)) {
151 151
 					continue;
152 152
 				}
153 153
 
154 154
 				// Form ID must be within $all_forms array to be validated.
155
-				if ( ! in_array( $form_id, $all_forms ) ) {
155
+				if ( ! in_array($form_id, $all_forms)) {
156 156
 					continue;
157 157
 				}
158 158
 
159 159
 				// Set Sales count
160
-				$totals[ $form_id ]['sales'] = isset( $totals[ $form_id ]['sales'] ) ?
161
-					++ $totals[ $form_id ]['sales'] :
162
-					1;
160
+				$totals[$form_id]['sales'] = isset($totals[$form_id]['sales']) ?
161
+					++$totals[$form_id]['sales'] : 1;
163 162
 
164 163
 				// Set Total Earnings
165
-				$totals[ $form_id ]['earnings'] = isset( $totals[ $form_id ]['earnings'] ) ?
166
-					( $totals[ $form_id ]['earnings'] + $payment_item['price'] ) :
167
-					$payment_item['price'];
164
+				$totals[$form_id]['earnings'] = isset($totals[$form_id]['earnings']) ?
165
+					($totals[$form_id]['earnings'] + $payment_item['price']) : $payment_item['price'];
168 166
 
169 167
 				$processed_payments[] = $payment->ID;
170 168
 			}
171 169
 
172 170
 			// Get the list of form ids which does not contain any payment record.
173
-			$remaining_form_ids = array_diff( $all_forms, array_keys( $totals ) );
174
-			foreach ( $remaining_form_ids as $form_id ) {
171
+			$remaining_form_ids = array_diff($all_forms, array_keys($totals));
172
+			foreach ($remaining_form_ids as $form_id) {
175 173
 				//If array key doesn't exist, create it
176
-				if ( ! array_key_exists( $form_id, $totals ) ) {
177
-					$totals[ $form_id ] = array(
174
+				if ( ! array_key_exists($form_id, $totals)) {
175
+					$totals[$form_id] = array(
178 176
 						'sales'    => (int) 0,
179 177
 						'earnings' => (float) 0,
180 178
 					);
181 179
 				}
182 180
 			}
183 181
 
184
-			$this->store_data( 'give_temp_processed_payments', $processed_payments );
185
-			$this->store_data( 'give_temp_recount_all_stats', $totals );
182
+			$this->store_data('give_temp_processed_payments', $processed_payments);
183
+			$this->store_data('give_temp_recount_all_stats', $totals);
186 184
 
187 185
 			return true;
188 186
 		}
189 187
 
190 188
 
191
-		foreach ( $totals as $key => $stats ) {
192
-			give_update_meta( $key, '_give_form_sales', $stats['sales'] );
193
-			give_update_meta( $key, '_give_form_earnings', give_sanitize_amount_for_db( $stats['earnings'] ) );
189
+		foreach ($totals as $key => $stats) {
190
+			give_update_meta($key, '_give_form_sales', $stats['sales']);
191
+			give_update_meta($key, '_give_form_earnings', give_sanitize_amount_for_db($stats['earnings']));
194 192
 		}
195 193
 
196 194
 		return false;
@@ -205,20 +203,20 @@  discard block
 block discarded – undo
205 203
 	 */
206 204
 	public function get_percentage_complete() {
207 205
 
208
-		$total = $this->get_stored_data( 'give_recount_all_total' );
206
+		$total = $this->get_stored_data('give_recount_all_total');
209 207
 
210
-		if ( false === $total ) {
208
+		if (false === $total) {
211 209
 			$this->pre_fetch();
212
-			$total = $this->get_stored_data( 'give_recount_all_total' );
210
+			$total = $this->get_stored_data('give_recount_all_total');
213 211
 		}
214 212
 
215 213
 		$percentage = 100;
216 214
 
217
-		if ( $total > 0 ) {
218
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
215
+		if ($total > 0) {
216
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
219 217
 		}
220 218
 
221
-		if ( $percentage > 100 ) {
219
+		if ($percentage > 100) {
222 220
 			$percentage = 100;
223 221
 		}
224 222
 
@@ -232,8 +230,8 @@  discard block
 block discarded – undo
232 230
 	 *
233 231
 	 * @param array $request The Form Data passed into the batch processing
234 232
 	 */
235
-	public function set_properties( $request ) {
236
-		$this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false;
233
+	public function set_properties($request) {
234
+		$this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false;
237 235
 	}
238 236
 
239 237
 	/**
@@ -244,25 +242,25 @@  discard block
 block discarded – undo
244 242
 	 */
245 243
 	public function process_step() {
246 244
 
247
-		if ( ! $this->can_export() ) {
248
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
245
+		if ( ! $this->can_export()) {
246
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
249 247
 		}
250 248
 
251 249
 		$had_data = $this->get_data();
252 250
 
253
-		if ( $had_data ) {
251
+		if ($had_data) {
254 252
 			$this->done = false;
255 253
 
256 254
 			return true;
257 255
 		} else {
258
-			$this->delete_data( 'give_recount_total_' . $this->form_id );
259
-			$this->delete_data( 'give_recount_all_total' );
260
-			$this->delete_data( 'give_temp_recount_all_stats' );
261
-			$this->delete_data( 'give_temp_payment_items' );
262
-			$this->delete_data( 'give_temp_form_ids' );
263
-			$this->delete_data( 'give_temp_processed_payments' );
256
+			$this->delete_data('give_recount_total_'.$this->form_id);
257
+			$this->delete_data('give_recount_all_total');
258
+			$this->delete_data('give_temp_recount_all_stats');
259
+			$this->delete_data('give_temp_payment_items');
260
+			$this->delete_data('give_temp_form_ids');
261
+			$this->delete_data('give_temp_processed_payments');
264 262
 			$this->done    = true;
265
-			$this->message = esc_html__( 'Donation form income amounts and donation counts stats successfully recounted.', 'give' );
263
+			$this->message = esc_html__('Donation form income amounts and donation counts stats successfully recounted.', 'give');
266 264
 
267 265
 			return false;
268 266
 		}
@@ -298,69 +296,69 @@  discard block
 block discarded – undo
298 296
 	 */
299 297
 	public function pre_fetch() {
300 298
 
301
-		if ( 1 == $this->step ) {
302
-			$this->delete_data( 'give_temp_recount_all_total' );
303
-			$this->delete_data( 'give_temp_recount_all_stats' );
304
-			$this->delete_data( 'give_temp_payment_items' );
305
-			$this->delete_data( 'give_temp_processed_payments' );
306
-			$this->delete_data( 'give_temp_all_payments_data' );
299
+		if (1 == $this->step) {
300
+			$this->delete_data('give_temp_recount_all_total');
301
+			$this->delete_data('give_temp_recount_all_stats');
302
+			$this->delete_data('give_temp_payment_items');
303
+			$this->delete_data('give_temp_processed_payments');
304
+			$this->delete_data('give_temp_all_payments_data');
307 305
 		}
308 306
 
309
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
310
-		$total             = $this->get_stored_data( 'give_temp_recount_all_total' );
307
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
308
+		$total             = $this->get_stored_data('give_temp_recount_all_total');
311 309
 
312
-		if ( false === $total ) {
310
+		if (false === $total) {
313 311
 
314
-			$payment_items = $this->get_stored_data( 'give_temp_payment_items' );
312
+			$payment_items = $this->get_stored_data('give_temp_payment_items');
315 313
 
316
-			if ( false === $payment_items ) {
314
+			if (false === $payment_items) {
317 315
 				$payment_items = array();
318
-				$this->store_data( 'give_temp_payment_items', $payment_items );
316
+				$this->store_data('give_temp_payment_items', $payment_items);
319 317
 			}
320 318
 
321 319
 			$args = array(
322 320
 				'post_status'    => 'publish',
323 321
 				'post_type'      => 'give_forms',
324
-				'posts_per_page' => - 1,
322
+				'posts_per_page' => -1,
325 323
 				'fields'         => 'ids',
326 324
 			);
327 325
 
328
-			$all_forms = get_posts( $args );
326
+			$all_forms = get_posts($args);
329 327
 
330
-			$this->store_data( 'give_temp_form_ids', $all_forms );
328
+			$this->store_data('give_temp_form_ids', $all_forms);
331 329
 
332
-			$args = apply_filters( 'give_recount_form_stats_total_args', array(
330
+			$args = apply_filters('give_recount_form_stats_total_args', array(
333 331
 				'give_forms' => $all_forms,
334 332
 				'number'     => $this->per_step,
335 333
 				'status'     => $accepted_statuses,
336 334
 				'page'       => $this->step,
337 335
 				'output'     => 'payments',
338
-			) );
336
+			));
339 337
 
340
-			$payments_query = new Give_Payments_Query( $args );
338
+			$payments_query = new Give_Payments_Query($args);
341 339
 			$payments       = $payments_query->get_payments();
342 340
 
343
-			$total = wp_count_posts( 'give_payment' )->publish;
341
+			$total = wp_count_posts('give_payment')->publish;
344 342
 
345
-			$this->store_data( 'give_temp_all_payments_data', $payments );
343
+			$this->store_data('give_temp_all_payments_data', $payments);
346 344
 
347
-			if ( $payments ) {
345
+			if ($payments) {
348 346
 
349
-				foreach ( $payments as $payment ) {
347
+				foreach ($payments as $payment) {
350 348
 
351 349
 					$form_id = $payment->form_id;
352 350
 
353 351
 					//If for some reason somehow the form_ID isn't set check payment meta
354
-					if ( empty( $payment->form_id ) ) {
352
+					if (empty($payment->form_id)) {
355 353
 						$payment_meta = $payment->get_meta();
356
-						$form_id      = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0;
354
+						$form_id      = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0;
357 355
 					}
358 356
 
359
-					if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
357
+					if ( ! in_array($payment->post_status, $accepted_statuses)) {
360 358
 						continue;
361 359
 					}
362 360
 
363
-					if ( ! array_key_exists( $payment->ID, $payment_items ) ) {
361
+					if ( ! array_key_exists($payment->ID, $payment_items)) {
364 362
 
365 363
 						/**
366 364
 						 * Filter the payment amount.
@@ -369,22 +367,22 @@  discard block
 block discarded – undo
369 367
 						 */
370 368
 						$payment_total = apply_filters(
371 369
 							'give_donation_amount',
372
-							give_format_amount( $payment->total, array( 'donation_id' => $payment->ID ) ),
370
+							give_format_amount($payment->total, array('donation_id' => $payment->ID)),
373 371
 							$payment->total,
374 372
 							$payment->ID,
375
-							array( 'type' => 'stats', 'currency' => false, 'amount' => false )
373
+							array('type' => 'stats', 'currency' => false, 'amount' => false)
376 374
 						);
377 375
 
378
-						$payment_items[ $payment->ID ] = array(
376
+						$payment_items[$payment->ID] = array(
379 377
 							'id'         => $form_id,
380 378
 							'payment_id' => $payment->ID,
381
-							'price'      => (float) give_maybe_sanitize_amount( $payment_total ),
379
+							'price'      => (float) give_maybe_sanitize_amount($payment_total),
382 380
 						);
383 381
 					}
384 382
 				}
385 383
 			}
386
-			$this->store_data( 'give_temp_payment_items', $payment_items );
387
-			$this->store_data( 'give_recount_all_total', $total );
384
+			$this->store_data('give_temp_payment_items', $payment_items);
385
+			$this->store_data('give_recount_all_total', $total);
388 386
 		}
389 387
 
390 388
 	}
@@ -398,17 +396,17 @@  discard block
 block discarded – undo
398 396
 	 *
399 397
 	 * @return mixed       Returns the data from the database
400 398
 	 */
401
-	private function get_stored_data( $key ) {
399
+	private function get_stored_data($key) {
402 400
 		global $wpdb;
403
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
404
-		if ( empty( $value ) ) {
401
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
402
+		if (empty($value)) {
405 403
 			return false;
406 404
 		}
407 405
 
408
-		$maybe_json = json_decode( $value );
406
+		$maybe_json = json_decode($value);
409 407
 
410
-		if ( ! is_null( $maybe_json ) ) {
411
-			$value = json_decode( $value, true );
408
+		if ( ! is_null($maybe_json)) {
409
+			$value = json_decode($value, true);
412 410
 		}
413 411
 
414 412
 		return $value;
@@ -424,10 +422,10 @@  discard block
 block discarded – undo
424 422
 	 *
425 423
 	 * @return void
426 424
 	 */
427
-	private function store_data( $key, $value ) {
425
+	private function store_data($key, $value) {
428 426
 		global $wpdb;
429 427
 
430
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
428
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
431 429
 
432 430
 		$data = array(
433 431
 			'option_name'  => $key,
@@ -441,7 +439,7 @@  discard block
 block discarded – undo
441 439
 			'%s',
442 440
 		);
443 441
 
444
-		$wpdb->replace( $wpdb->options, $data, $formats );
442
+		$wpdb->replace($wpdb->options, $data, $formats);
445 443
 	}
446 444
 
447 445
 	/**
@@ -453,9 +451,9 @@  discard block
 block discarded – undo
453 451
 	 *
454 452
 	 * @return void
455 453
 	 */
456
-	private function delete_data( $key ) {
454
+	private function delete_data($key) {
457 455
 		global $wpdb;
458
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
456
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
459 457
 	}
460 458
 
461 459
 }
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-income.php 1 patch
Spacing   +50 added lines, -50 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
 
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 	/**
47 47
 	 * Constructor.
48 48
 	 */
49
-	public function __construct( $_step = 1 ) {
50
-		parent::__construct( $_step );
49
+	public function __construct($_step = 1) {
50
+		parent::__construct($_step);
51 51
 
52 52
 		$this->is_writable = true;
53 53
 	}
@@ -61,33 +61,33 @@  discard block
 block discarded – undo
61 61
 	 */
62 62
 	public function get_data() {
63 63
 
64
-		if ( $this->step == 1 ) {
65
-			$this->delete_data( 'give_temp_recount_earnings' );
64
+		if ($this->step == 1) {
65
+			$this->delete_data('give_temp_recount_earnings');
66 66
 		}
67 67
 
68
-		$total = get_option( 'give_temp_recount_earnings', false );
68
+		$total = get_option('give_temp_recount_earnings', false);
69 69
 
70
-		if ( false === $total ) {
70
+		if (false === $total) {
71 71
 			$total = (float) 0;
72
-			$this->store_data( 'give_temp_recount_earnings', $total );
72
+			$this->store_data('give_temp_recount_earnings', $total);
73 73
 		}
74 74
 
75
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
75
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
76 76
 
77
-		$args = apply_filters( 'give_recount_earnings_args', array(
77
+		$args = apply_filters('give_recount_earnings_args', array(
78 78
 			'number' => $this->per_step,
79 79
 			'page'   => $this->step,
80 80
 			'status' => $accepted_statuses,
81 81
 			'fields' => 'ids'
82
-		) );
82
+		));
83 83
 
84
-		$payments = give_get_payments( $args );
84
+		$payments = give_get_payments($args);
85 85
 
86
-		if ( ! empty( $payments ) ) {
86
+		if ( ! empty($payments)) {
87 87
 
88
-			foreach ( $payments as $payment ) {
88
+			foreach ($payments as $payment) {
89 89
 				// Get the payment amount.
90
-				$payment_amount = give_get_meta( $payment->ID, '_give_payment_total', true );
90
+				$payment_amount = give_get_meta($payment->ID, '_give_payment_total', true);
91 91
 
92 92
 				/**
93 93
 				 * Filter the payment amount.
@@ -96,28 +96,28 @@  discard block
 block discarded – undo
96 96
 				 */
97 97
 				$donation_amount = apply_filters(
98 98
 					'give_donation_amount',
99
-					give_format_amount( $payment_amount, array( 'donation_id' => $payment->ID ) ),
99
+					give_format_amount($payment_amount, array('donation_id' => $payment->ID)),
100 100
 					$payment->total,
101 101
 					$payment->ID,
102
-					array( 'type' => 'stats', 'currency' => false, 'amount' => false )
102
+					array('type' => 'stats', 'currency' => false, 'amount' => false)
103 103
 				);
104 104
 
105
-				$total += (float) give_maybe_sanitize_amount( $donation_amount );
105
+				$total += (float) give_maybe_sanitize_amount($donation_amount);
106 106
 			}
107 107
 
108
-			if ( $total < 0 ) {
108
+			if ($total < 0) {
109 109
 				$totals = 0;
110 110
 			}
111 111
 
112
-			$total = round( $total, give_get_price_decimals() );
112
+			$total = round($total, give_get_price_decimals());
113 113
 
114
-			$this->store_data( 'give_temp_recount_earnings', $total );
114
+			$this->store_data('give_temp_recount_earnings', $total);
115 115
 
116 116
 			return true;
117 117
 
118 118
 		}
119 119
 
120
-		update_option( 'give_earnings_total', $total );
120
+		update_option('give_earnings_total', $total);
121 121
 
122 122
 		return false;
123 123
 
@@ -131,25 +131,25 @@  discard block
 block discarded – undo
131 131
 	 */
132 132
 	public function get_percentage_complete() {
133 133
 
134
-		$total = $this->get_stored_data( 'give_recount_earnings_total' );
134
+		$total = $this->get_stored_data('give_recount_earnings_total');
135 135
 
136
-		if ( false === $total ) {
137
-			$args = apply_filters( 'give_recount_earnings_total_args', array() );
136
+		if (false === $total) {
137
+			$args = apply_filters('give_recount_earnings_total_args', array());
138 138
 
139
-			$counts = give_count_payments( $args );
140
-			$total  = absint( $counts->publish );
141
-			$total  = apply_filters( 'give_recount_store_earnings_total', $total );
139
+			$counts = give_count_payments($args);
140
+			$total  = absint($counts->publish);
141
+			$total  = apply_filters('give_recount_store_earnings_total', $total);
142 142
 
143
-			$this->store_data( 'give_recount_earnings_total', $total );
143
+			$this->store_data('give_recount_earnings_total', $total);
144 144
 		}
145 145
 
146 146
 		$percentage = 100;
147 147
 
148
-		if ( $total > 0 ) {
149
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
148
+		if ($total > 0) {
149
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
150 150
 		}
151 151
 
152
-		if ( $percentage > 100 ) {
152
+		if ($percentage > 100) {
153 153
 			$percentage = 100;
154 154
 		}
155 155
 
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 	 *
164 164
 	 * @param array $request The Form Data passed into the batch processing
165 165
 	 */
166
-	public function set_properties( $request ) {
166
+	public function set_properties($request) {
167 167
 	}
168 168
 
169 169
 	/**
@@ -174,21 +174,21 @@  discard block
 block discarded – undo
174 174
 	 */
175 175
 	public function process_step() {
176 176
 
177
-		if ( ! $this->can_export() ) {
178
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
177
+		if ( ! $this->can_export()) {
178
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
179 179
 		}
180 180
 
181 181
 		$had_data = $this->get_data();
182 182
 
183
-		if ( $had_data ) {
183
+		if ($had_data) {
184 184
 			$this->done = false;
185 185
 
186 186
 			return true;
187 187
 		} else {
188
-			$this->delete_data( 'give_recount_earnings_total' );
189
-			$this->delete_data( 'give_temp_recount_earnings' );
188
+			$this->delete_data('give_recount_earnings_total');
189
+			$this->delete_data('give_temp_recount_earnings');
190 190
 			$this->done    = true;
191
-			$this->message = esc_html__( 'Income stats have been successfully recounted.', 'give' );
191
+			$this->message = esc_html__('Income stats have been successfully recounted.', 'give');
192 192
 
193 193
 			return false;
194 194
 		}
@@ -225,17 +225,17 @@  discard block
 block discarded – undo
225 225
 	 *
226 226
 	 * @return mixed       Returns the data from the database
227 227
 	 */
228
-	private function get_stored_data( $key ) {
228
+	private function get_stored_data($key) {
229 229
 		global $wpdb;
230
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
230
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
231 231
 
232
-		if ( empty( $value ) ) {
232
+		if (empty($value)) {
233 233
 			return false;
234 234
 		}
235 235
 
236
-		$maybe_json = json_decode( $value );
237
-		if ( ! is_null( $maybe_json ) ) {
238
-			$value = json_decode( $value, true );
236
+		$maybe_json = json_decode($value);
237
+		if ( ! is_null($maybe_json)) {
238
+			$value = json_decode($value, true);
239 239
 		}
240 240
 
241 241
 		return $value;
@@ -251,10 +251,10 @@  discard block
 block discarded – undo
251 251
 	 *
252 252
 	 * @return void
253 253
 	 */
254
-	private function store_data( $key, $value ) {
254
+	private function store_data($key, $value) {
255 255
 		global $wpdb;
256 256
 
257
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
257
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
258 258
 
259 259
 		$data = array(
260 260
 			'option_name'  => $key,
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 			'%s',
269 269
 		);
270 270
 
271
-		$wpdb->replace( $wpdb->options, $data, $formats );
271
+		$wpdb->replace($wpdb->options, $data, $formats);
272 272
 	}
273 273
 
274 274
 	/**
@@ -280,9 +280,9 @@  discard block
 block discarded – undo
280 280
 	 *
281 281
 	 * @return void
282 282
 	 */
283
-	private function delete_data( $key ) {
283
+	private function delete_data($key) {
284 284
 		global $wpdb;
285
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
285
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
286 286
 	}
287 287
 
288 288
 }
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-delete-test-transactions.php 1 patch
Spacing   +46 added lines, -46 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
 
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 	/**
47 47
 	 * Constructor.
48 48
 	 */
49
-	public function __construct( $_step = 1 ) {
50
-		parent::__construct( $_step );
49
+	public function __construct($_step = 1) {
50
+		parent::__construct($_step);
51 51
 
52 52
 		$this->is_writable = true;
53 53
 	}
@@ -62,20 +62,20 @@  discard block
 block discarded – undo
62 62
 	 * @return array|bool $data The data for the CSV file
63 63
 	 */
64 64
 	public function get_data() {
65
-		$items = $this->get_stored_data( 'give_temp_delete_test_ids' );
65
+		$items = $this->get_stored_data('give_temp_delete_test_ids');
66 66
 
67
-		if ( ! is_array( $items ) ) {
67
+		if ( ! is_array($items)) {
68 68
 			return false;
69 69
 		}
70 70
 
71
-		$offset     = ( $this->step - 1 ) * $this->per_step;
72
-		$step_items = array_slice( $items, $offset, $this->per_step );
73
-		$meta_table = __give_v20_bc_table_details( 'payment' );
71
+		$offset     = ($this->step - 1) * $this->per_step;
72
+		$step_items = array_slice($items, $offset, $this->per_step);
73
+		$meta_table = __give_v20_bc_table_details('payment');
74 74
 
75
-		if ( $step_items ) {
76
-			foreach ( $step_items as $item ) {
75
+		if ($step_items) {
76
+			foreach ($step_items as $item) {
77 77
 				// Delete the main payment.
78
-				give_delete_donation( absint( $item['id'] ) );
78
+				give_delete_donation(absint($item['id']));
79 79
 			}
80 80
 			return true;
81 81
 		}
@@ -91,16 +91,16 @@  discard block
 block discarded – undo
91 91
 	 */
92 92
 	public function get_percentage_complete() {
93 93
 
94
-		$items = $this->get_stored_data( 'give_temp_delete_test_ids', false );
95
-		$total = count( $items );
94
+		$items = $this->get_stored_data('give_temp_delete_test_ids', false);
95
+		$total = count($items);
96 96
 
97 97
 		$percentage = 100;
98 98
 
99
-		if ( $total > 0 ) {
100
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
99
+		if ($total > 0) {
100
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
101 101
 		}
102 102
 
103
-		if ( $percentage > 100 ) {
103
+		if ($percentage > 100) {
104 104
 			$percentage = 100;
105 105
 		}
106 106
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 *
115 115
 	 * @param array $request The Form Data passed into the batch processing
116 116
 	 */
117
-	public function set_properties( $request ) {
117
+	public function set_properties($request) {
118 118
 	}
119 119
 
120 120
 	/**
@@ -125,24 +125,24 @@  discard block
 block discarded – undo
125 125
 	 */
126 126
 	public function process_step() {
127 127
 
128
-		if ( ! $this->can_export() ) {
129
-			wp_die( __( 'You do not have permission to delete test transactions.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
128
+		if ( ! $this->can_export()) {
129
+			wp_die(__('You do not have permission to delete test transactions.', 'give'), __('Error', 'give'), array('response' => 403));
130 130
 		}
131 131
 
132 132
 		$had_data = $this->get_data();
133 133
 
134
-		if ( $had_data ) {
134
+		if ($had_data) {
135 135
 			$this->done = false;
136 136
 
137 137
 			return true;
138 138
 		} else {
139
-			update_option( 'give_earnings_total', give_get_total_earnings( true ) );
140
-			Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) );
139
+			update_option('give_earnings_total', give_get_total_earnings(true));
140
+			Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
141 141
 
142
-			$this->delete_data( 'give_temp_delete_test_ids' );
142
+			$this->delete_data('give_temp_delete_test_ids');
143 143
 
144 144
 			$this->done    = true;
145
-			$this->message = __( 'Test transactions successfully deleted.', 'give' );
145
+			$this->message = __('Test transactions successfully deleted.', 'give');
146 146
 
147 147
 			return false;
148 148
 		}
@@ -175,27 +175,27 @@  discard block
 block discarded – undo
175 175
 	 */
176 176
 	public function pre_fetch() {
177 177
 
178
-		if ( $this->step == 1 ) {
179
-			$this->delete_data( 'give_temp_delete_test_ids' );
178
+		if ($this->step == 1) {
179
+			$this->delete_data('give_temp_delete_test_ids');
180 180
 		}
181 181
 
182
-		$items = get_option( 'give_temp_delete_test_ids', false );
182
+		$items = get_option('give_temp_delete_test_ids', false);
183 183
 
184
-		if ( false === $items ) {
184
+		if (false === $items) {
185 185
 			$items = array();
186 186
 
187
-			$args = apply_filters( 'give_tools_reset_stats_total_args', array(
187
+			$args = apply_filters('give_tools_reset_stats_total_args', array(
188 188
 				'post_status' => 'any',
189
-				'number'      => - 1,
189
+				'number'      => -1,
190 190
 				'meta_key'    => '_give_payment_mode',
191 191
 				'meta_value'  => 'test'
192
-			) );
192
+			));
193 193
 
194
-			$posts    = new Give_Payments_Query( $args );
194
+			$posts    = new Give_Payments_Query($args);
195 195
 			$payments = $posts->get_payments();
196 196
 
197 197
 			/* @var Give_Payment $payment */
198
-			foreach ( $payments as $payment ) {
198
+			foreach ($payments as $payment) {
199 199
 				$items[] = array(
200 200
 					'id'   => (int) $payment->ID,
201 201
 					'type' => 'give_payment',
@@ -204,9 +204,9 @@  discard block
 block discarded – undo
204 204
 
205 205
 			// Allow filtering of items to remove with an unassociative array for each item.
206 206
 			// The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method.
207
-			$items = apply_filters( 'give_delete_test_items', $items );
207
+			$items = apply_filters('give_delete_test_items', $items);
208 208
 
209
-			$this->store_data( 'give_temp_delete_test_ids', $items );
209
+			$this->store_data('give_temp_delete_test_ids', $items);
210 210
 		}
211 211
 
212 212
 	}
@@ -220,17 +220,17 @@  discard block
 block discarded – undo
220 220
 	 *
221 221
 	 * @return mixed       Returns the data from the database
222 222
 	 */
223
-	private function get_stored_data( $key ) {
223
+	private function get_stored_data($key) {
224 224
 		global $wpdb;
225
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
225
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
226 226
 
227
-		if ( empty( $value ) ) {
227
+		if (empty($value)) {
228 228
 			return false;
229 229
 		}
230 230
 
231
-		$maybe_json = json_decode( $value );
232
-		if ( ! is_null( $maybe_json ) ) {
233
-			$value = json_decode( $value, true );
231
+		$maybe_json = json_decode($value);
232
+		if ( ! is_null($maybe_json)) {
233
+			$value = json_decode($value, true);
234 234
 		}
235 235
 
236 236
 		return $value;
@@ -246,10 +246,10 @@  discard block
 block discarded – undo
246 246
 	 *
247 247
 	 * @return void
248 248
 	 */
249
-	private function store_data( $key, $value ) {
249
+	private function store_data($key, $value) {
250 250
 		global $wpdb;
251 251
 
252
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
252
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
253 253
 
254 254
 		$data = array(
255 255
 			'option_name'  => $key,
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 			'%s',
264 264
 		);
265 265
 
266
-		$wpdb->replace( $wpdb->options, $data, $formats );
266
+		$wpdb->replace($wpdb->options, $data, $formats);
267 267
 	}
268 268
 
269 269
 	/**
@@ -275,9 +275,9 @@  discard block
 block discarded – undo
275 275
 	 *
276 276
 	 * @return void
277 277
 	 */
278
-	private function delete_data( $key ) {
278
+	private function delete_data($key) {
279 279
 		global $wpdb;
280
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
280
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
281 281
 	}
282 282
 
283 283
 }
Please login to merge, or discard this patch.
includes/admin/tools/logs/class-update-logs-list-table.php 1 patch
Spacing   +40 added lines, -40 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
 	/**
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	 *
64 64
 	 * @return void
65 65
 	 */
66
-	public function search_box( $text, $input_id ) {
66
+	public function search_box($text, $input_id) {
67 67
 	}
68 68
 
69 69
 	/**
@@ -76,9 +76,9 @@  discard block
 block discarded – undo
76 76
 	 */
77 77
 	public function get_columns() {
78 78
 		$columns = array(
79
-			'ID'      => __( 'Log ID', 'give' ),
80
-			'date'    => __( 'Date', 'give' ),
81
-			'details' => __( 'Process Details', 'give' ),
79
+			'ID'      => __('Log ID', 'give'),
80
+			'date'    => __('Date', 'give'),
81
+			'details' => __('Process Details', 'give'),
82 82
 		);
83 83
 
84 84
 		return $columns;
@@ -95,17 +95,17 @@  discard block
 block discarded – undo
95 95
 	 *
96 96
 	 * @return string Column Name
97 97
 	 */
98
-	public function column_default( $item, $column_name ) {
99
-		switch ( $column_name ) {
98
+	public function column_default($item, $column_name) {
99
+		switch ($column_name) {
100 100
 			case 'ID':
101 101
 				return sprintf(
102 102
 					'<span class="give-item-label give-item-label-gray">%1$s</span> %2$s',
103
-					esc_attr( $item[ $column_name ] ),
104
-					esc_attr( $item['title'] )
103
+					esc_attr($item[$column_name]),
104
+					esc_attr($item['title'])
105 105
 				);
106 106
 
107 107
 			default:
108
-				return esc_attr( $item[ $column_name ] );
108
+				return esc_attr($item[$column_name]);
109 109
 		}
110 110
 	}
111 111
 
@@ -119,24 +119,24 @@  discard block
 block discarded – undo
119 119
 	 *
120 120
 	 * @return void
121 121
 	 */
122
-	public function column_details( $item ) {
123
-		echo wp_kses_post( Give()->tooltips->render_link( array(
124
-			'label'       => __( 'View Update Log', 'give' ),
122
+	public function column_details($item) {
123
+		echo wp_kses_post(Give()->tooltips->render_link(array(
124
+			'label'       => __('View Update Log', 'give'),
125 125
 			'tag_content' => '<span class="dashicons dashicons-visibility"></span>',
126 126
 			'link'        => "#TB_inline?width=640&amp;inlineId=log-details-{$item['ID']}",
127 127
 			'attributes'  => array(
128 128
 				'class' => 'thickbox give-error-log-details-link button button-small',
129 129
 			),
130
-		) ) );
130
+		)));
131 131
 		?>
132
-		<div id="log-details-<?php echo esc_attr( $item['ID'] ); ?>" style="display:none;">
132
+		<div id="log-details-<?php echo esc_attr($item['ID']); ?>" style="display:none;">
133 133
 			<?php
134 134
 
135 135
 			// Print Log Content, if not empty.
136
-			if ( ! empty( $item['log_content'] ) ) {
136
+			if ( ! empty($item['log_content'])) {
137 137
 				echo sprintf(
138 138
 					'<p><pre>%1$s</pre></div>',
139
-					esc_html( $item['log_content'] )
139
+					esc_html($item['log_content'])
140 140
 				);
141 141
 			}
142 142
 			?>
@@ -157,19 +157,19 @@  discard block
 block discarded – undo
157 157
 	 *
158 158
 	 * @param string $which
159 159
 	 */
160
-	protected function display_tablenav( $which ) {
161
-		if ( 'top' === $which ) {
162
-			wp_nonce_field( 'bulk-' . $this->_args['plural'] );
160
+	protected function display_tablenav($which) {
161
+		if ('top' === $which) {
162
+			wp_nonce_field('bulk-'.$this->_args['plural']);
163 163
 		}
164 164
 		?>
165
-		<div class="tablenav <?php echo esc_attr( $which ); ?>">
165
+		<div class="tablenav <?php echo esc_attr($which); ?>">
166 166
 
167 167
 			<div class="alignleft actions bulkactions">
168
-				<?php $this->bulk_actions( $which ); ?>
168
+				<?php $this->bulk_actions($which); ?>
169 169
 			</div>
170 170
 			<?php
171
-			$this->extra_tablenav( $which );
172
-			$this->pagination( $which );
171
+			$this->extra_tablenav($which);
172
+			$this->pagination($which);
173 173
 			?>
174 174
 
175 175
 			<br class="clear"/>
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 	 * @return int Current page number
187 187
 	 */
188 188
 	public function get_paged() {
189
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
189
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
190 190
 	}
191 191
 
192 192
 	/**
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 	 *
200 200
 	 * @return void
201 201
 	 */
202
-	function bulk_actions( $which = '' ) {
202
+	function bulk_actions($which = '') {
203 203
 	}
204 204
 
205 205
 	/**
@@ -219,10 +219,10 @@  discard block
 block discarded – undo
219 219
 			'posts_per_page' => $this->per_page,
220 220
 		);
221 221
 
222
-		$logs = Give()->logs->get_connected_logs( $log_query );
222
+		$logs = Give()->logs->get_connected_logs($log_query);
223 223
 
224
-		if ( $logs ) {
225
-			foreach ( $logs as $log ) {
224
+		if ($logs) {
225
+			foreach ($logs as $log) {
226 226
 
227 227
 				$logs_data[] = array(
228 228
 					'ID'          => $log->ID,
@@ -254,14 +254,14 @@  discard block
 block discarded – undo
254 254
 		$columns               = $this->get_columns();
255 255
 		$hidden                = array(); // No hidden columns
256 256
 		$sortable              = $this->get_sortable_columns();
257
-		$this->_column_headers = array( $columns, $hidden, $sortable );
257
+		$this->_column_headers = array($columns, $hidden, $sortable);
258 258
 		$this->items           = $this->get_logs();
259
-		$total_items           = Give()->logs->get_log_count( 0, 'update' );
259
+		$total_items           = Give()->logs->get_log_count(0, 'update');
260 260
 
261
-		$this->set_pagination_args( array(
261
+		$this->set_pagination_args(array(
262 262
 			'total_items' => $total_items,
263 263
 			'per_page'    => $this->per_page,
264
-			'total_pages' => ceil( $total_items / $this->per_page ),
265
-		) );
264
+			'total_pages' => ceil($total_items / $this->per_page),
265
+		));
266 266
 	}
267 267
 }
Please login to merge, or discard this patch.
includes/admin/tools/class-settings-export.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@  discard block
 block discarded – undo
9 9
  * @since       1.8
10 10
  */
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit; // Exit if accessed directly
14 14
 }
15 15
 
16
-if ( ! class_exists( 'Give_Settings_Export' ) ) :
16
+if ( ! class_exists('Give_Settings_Export')) :
17 17
 
18 18
 	/**
19 19
 	 * Give_Settings_Export.
@@ -34,19 +34,19 @@  discard block
 block discarded – undo
34 34
 		 */
35 35
 		public function __construct() {
36 36
 			$this->id    = 'export';
37
-			$this->label = __( 'Export', 'give' );
37
+			$this->label = __('Export', 'give');
38 38
 
39 39
 			parent::__construct();
40 40
 
41
-			add_action( 'give_admin_field_tools_export', array( 'Give_Settings_Export', 'render_export_field' ), 10, 2 );
41
+			add_action('give_admin_field_tools_export', array('Give_Settings_Export', 'render_export_field'), 10, 2);
42 42
 
43 43
 			// Do not use main donor for this tab.
44
-			if( give_get_current_setting_tab() === $this->id ) {
45
-				add_action( 'give-tools_open_form', '__return_empty_string' );
46
-				add_action( 'give-tools_close_form', '__return_empty_string' );
44
+			if (give_get_current_setting_tab() === $this->id) {
45
+				add_action('give-tools_open_form', '__return_empty_string');
46
+				add_action('give-tools_close_form', '__return_empty_string');
47 47
 
48 48
 
49
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-give-export-donations.php';
49
+				require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/class-give-export-donations.php';
50 50
 			}
51 51
 		}
52 52
 
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 			 * @param  array $settings
65 65
 			 */
66 66
 			$settings = apply_filters(
67
-				'give_get_settings_' . $this->id,
67
+				'give_get_settings_'.$this->id,
68 68
 				array(
69 69
 					array(
70 70
 						'id'   => 'give_tools_export',
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 					),
74 74
 					array(
75 75
 						'id'   => 'export',
76
-						'name' => __( 'Export', 'give' ),
76
+						'name' => __('Export', 'give'),
77 77
 						'type' => 'tools_export',
78 78
 					),
79 79
 					array(
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
 		 * @param $field
98 98
 		 * @param $option_value
99 99
 		 */
100
-		public static function render_export_field( $field, $option_value ) {
101
-			include_once( 'views/html-admin-page-exports.php' );
100
+		public static function render_export_field($field, $option_value) {
101
+			include_once('views/html-admin-page-exports.php');
102 102
 		}
103 103
 	}
104 104
 
Please login to merge, or discard this patch.
includes/admin/tools/export/export-actions.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  * @license     https://opensource.org/licenses/gpl-license GNU Public License
11 11
  */
12 12
 
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -22,13 +22,13 @@  discard block
 block discarded – undo
22 22
  */
23 23
 function give_process_batch_export_form() {
24 24
 
25
-	if ( ! wp_verify_nonce( $_REQUEST['nonce'], 'give-batch-export' ) ) {
26
-		wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array(
25
+	if ( ! wp_verify_nonce($_REQUEST['nonce'], 'give-batch-export')) {
26
+		wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array(
27 27
 			'response' => 403,
28
-		) );
28
+		));
29 29
 	}
30 30
 
31
-	require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-batch-export.php';
31
+	require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/class-batch-export.php';
32 32
 
33 33
 	/**
34 34
 	 * Fires before batch export.
@@ -37,14 +37,14 @@  discard block
 block discarded – undo
37 37
 	 *
38 38
 	 * @param string $class Export class.
39 39
 	 */
40
-	do_action( 'give_batch_export_class_include', $_REQUEST['class'] );
40
+	do_action('give_batch_export_class_include', $_REQUEST['class']);
41 41
 
42 42
 	$export = new $_REQUEST['class'];
43 43
 	$export->export();
44 44
 
45 45
 }
46 46
 
47
-add_action( 'give_form_batch_export', 'give_process_batch_export_form' );
47
+add_action('give_form_batch_export', 'give_process_batch_export_form');
48 48
 
49 49
 /**
50 50
  * Exports earnings for a specified time period.
@@ -55,14 +55,14 @@  discard block
 block discarded – undo
55 55
  * @return void
56 56
  */
57 57
 function give_export_earnings() {
58
-	require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-export-earnings.php';
58
+	require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/class-export-earnings.php';
59 59
 
60 60
 	$earnings_export = new Give_Earnings_Export();
61 61
 
62 62
 	$earnings_export->export();
63 63
 }
64 64
 
65
-add_action( 'give_earnings_export', 'give_export_earnings' );
65
+add_action('give_earnings_export', 'give_export_earnings');
66 66
 
67 67
 /**
68 68
  * Exports Give's core settings.
@@ -73,14 +73,14 @@  discard block
 block discarded – undo
73 73
  * @return void
74 74
  */
75 75
 function give_core_settings_export() {
76
-	require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-core-settings-export.php';
76
+	require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/class-core-settings-export.php';
77 77
 
78 78
 	$core_settings = new Give_Core_Settings_Export();
79 79
 
80 80
 	$core_settings->export();
81 81
 }
82 82
 
83
-add_action( 'give_core_settings_export', 'give_core_settings_export' );
83
+add_action('give_core_settings_export', 'give_core_settings_export');
84 84
 
85 85
 
86 86
 /**
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
  * @return void
91 91
  */
92 92
 function give_register_batch_exporters() {
93
-	if ( is_admin() ) {
93
+	if (is_admin()) {
94 94
 		/**
95 95
 		 * Fires in the admin, while plugins loaded.
96 96
 		 *
@@ -100,11 +100,11 @@  discard block
 block discarded – undo
100 100
 		 *
101 101
 		 * @param string $class Export class.
102 102
 		 */
103
-		do_action( 'give_register_batch_exporter' );
103
+		do_action('give_register_batch_exporter');
104 104
 	}
105 105
 }
106 106
 
107
-add_action( 'plugins_loaded', 'give_register_batch_exporters' );
107
+add_action('plugins_loaded', 'give_register_batch_exporters');
108 108
 
109 109
 /**
110 110
  * Register the donors batch exporter.
@@ -112,10 +112,10 @@  discard block
 block discarded – undo
112 112
  * @since  1.5.2
113 113
  */
114 114
 function give_register_donors_batch_export() {
115
-	add_action( 'give_batch_export_class_include', 'give_include_donors_batch_processor', 10, 1 );
115
+	add_action('give_batch_export_class_include', 'give_include_donors_batch_processor', 10, 1);
116 116
 }
117 117
 
118
-add_action( 'give_register_batch_exporter', 'give_register_donors_batch_export', 10 );
118
+add_action('give_register_batch_exporter', 'give_register_donors_batch_export', 10);
119 119
 
120 120
 /**
121 121
  * Loads the donors batch process if needed.
@@ -126,10 +126,10 @@  discard block
 block discarded – undo
126 126
  *
127 127
  * @return void
128 128
  */
129
-function give_include_donors_batch_processor( $class ) {
129
+function give_include_donors_batch_processor($class) {
130 130
 
131
-	if ( 'Give_Batch_Donors_Export' === $class ) {
132
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-batch-export-donors.php';
131
+	if ('Give_Batch_Donors_Export' === $class) {
132
+		require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/class-batch-export-donors.php';
133 133
 	}
134 134
 
135 135
 }
@@ -140,10 +140,10 @@  discard block
 block discarded – undo
140 140
  * @since  1.5
141 141
  */
142 142
 function give_register_forms_batch_export() {
143
-	add_action( 'give_batch_export_class_include', 'give_include_forms_batch_processor', 10, 1 );
143
+	add_action('give_batch_export_class_include', 'give_include_forms_batch_processor', 10, 1);
144 144
 }
145 145
 
146
-add_action( 'give_register_batch_exporter', 'give_register_forms_batch_export', 10 );
146
+add_action('give_register_batch_exporter', 'give_register_forms_batch_export', 10);
147 147
 
148 148
 /**
149 149
  * Loads the file downloads batch process if needed
@@ -154,10 +154,10 @@  discard block
 block discarded – undo
154 154
  *
155 155
  * @return void
156 156
  */
157
-function give_include_forms_batch_processor( $class ) {
157
+function give_include_forms_batch_processor($class) {
158 158
 
159
-	if ( 'Give_Batch_Forms_Export' === $class ) {
160
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-batch-export-forms.php';
159
+	if ('Give_Batch_Forms_Export' === $class) {
160
+		require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/class-batch-export-forms.php';
161 161
 	}
162 162
 
163 163
 }
Please login to merge, or discard this patch.