Completed
Pull Request — master (#1832)
by Devin
04:50
created
includes/class-give-cli-commands.php 1 patch
Spacing   +196 added lines, -196 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 // Exit if accessed directly.
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if ( ! defined('ABSPATH')) {
11 11
 	exit;
12 12
 }
13 13
 
14 14
 // Add give command.
15
-WP_CLI::add_command( 'give', 'GIVE_CLI_COMMAND' );
15
+WP_CLI::add_command('give', 'GIVE_CLI_COMMAND');
16 16
 
17 17
 
18 18
 /**
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
 	 *
69 69
 	 * @subcommand    logo
70 70
 	 */
71
-	public function ascii( $args, $assoc_args ) {
72
-		WP_CLI::log( file_get_contents( GIVE_PLUGIN_DIR . 'assets/images/give-ascii-logo.txt' ) );
71
+	public function ascii($args, $assoc_args) {
72
+		WP_CLI::log(file_get_contents(GIVE_PLUGIN_DIR.'assets/images/give-ascii-logo.txt'));
73 73
 	}
74 74
 
75 75
 
@@ -94,54 +94,54 @@  discard block
 block discarded – undo
94 94
 	 *
95 95
 	 * @subcommand    details
96 96
 	 */
97
-	public function details( $args, $assoc_args ) {
97
+	public function details($args, $assoc_args) {
98 98
 
99 99
 		/**
100 100
 		 * Plugin Information
101 101
 		 */
102
-		WP_CLI::log( $this->color_message( __( 'Give Version: ', 'give' ) ) . GIVE_VERSION );
102
+		WP_CLI::log($this->color_message(__('Give Version: ', 'give')).GIVE_VERSION);
103 103
 
104 104
 		/**
105 105
 		 * General Information.
106 106
 		 */
107
-		WP_CLI::log( "\n####   " . $this->color_message( __( 'General information', 'give' ) ) . '   ####' );
107
+		WP_CLI::log("\n####   ".$this->color_message(__('General information', 'give')).'   ####');
108 108
 
109
-		$success_page = give_get_option( 'success_page' );
110
-		$failure_page = give_get_option( 'failure_page' );
111
-		$history_page = give_get_option( 'history_page' );
109
+		$success_page = give_get_option('success_page');
110
+		$failure_page = give_get_option('failure_page');
111
+		$history_page = give_get_option('history_page');
112 112
 
113
-		WP_CLI::log( $this->color_message( sprintf( __( 'Success Page: ', 'give' ) ) ) . ( $success_page ? "[{$success_page}] " . get_permalink( $success_page ) : __( 'Not Set', 'give' ) ) );
114
-		WP_CLI::log( $this->color_message( __( 'Failed Donation Page: ', 'give' ) ) . ( $failure_page ? "[{$failure_page}] " . get_permalink( $failure_page ) : __( 'Not Set', 'give' ) ) );
115
-		WP_CLI::log( $this->color_message( __( 'Donation History Page: ', 'give' ) ) . ( $history_page ? "[{$history_page}] " . get_permalink( $history_page ) : __( 'Not Set', 'give' ) ) );
116
-		WP_CLI::log( $this->color_message( __( 'Country: ', 'give' ) ) . give_get_country() );
113
+		WP_CLI::log($this->color_message(sprintf(__('Success Page: ', 'give'))).($success_page ? "[{$success_page}] ".get_permalink($success_page) : __('Not Set', 'give')));
114
+		WP_CLI::log($this->color_message(__('Failed Donation Page: ', 'give')).($failure_page ? "[{$failure_page}] ".get_permalink($failure_page) : __('Not Set', 'give')));
115
+		WP_CLI::log($this->color_message(__('Donation History Page: ', 'give')).($history_page ? "[{$history_page}] ".get_permalink($history_page) : __('Not Set', 'give')));
116
+		WP_CLI::log($this->color_message(__('Country: ', 'give')).give_get_country());
117 117
 
118 118
 		/**
119 119
 		 * Currency Information.
120 120
 		 */
121
-		$default_gateway = give_get_option( 'default_gateway' );
121
+		$default_gateway = give_get_option('default_gateway');
122 122
 
123
-		WP_CLI::log( "\n####   " . $this->color_message( __( 'Currency Information', 'give' ) ) . '   ####' );
123
+		WP_CLI::log("\n####   ".$this->color_message(__('Currency Information', 'give')).'   ####');
124 124
 
125
-		WP_CLI::log( $this->color_message( __( 'Currency: ', 'give' ), give_get_currency() ) );
126
-		WP_CLI::log( $this->color_message( __( 'Currency Position: ', 'give' ), give_get_currency_position() ) );
127
-		WP_CLI::log( $this->color_message( __( 'Thousand Separator: ', 'give' ), give_get_price_thousand_separator() ) );
128
-		WP_CLI::log( $this->color_message( __( 'Decimal Separator: ', 'give' ), give_get_price_decimal_separator() ) );
129
-		WP_CLI::log( $this->color_message( __( 'Number of Decimals: ', 'give' ), give_get_price_decimals() ) );
130
-		WP_CLI::log( $this->color_message( __( 'Test Mode: ', 'give' ), ( give_get_option( 'test_mode' ) ? __( 'Yes', 'give' ) : __( 'No', 'give' ) ) ) );
131
-		WP_CLI::log( $this->color_message( __( 'Default Gateway: ', 'give' ), ( $default_gateway ? $default_gateway : __( 'Not Set', 'give' ) ) ) );
125
+		WP_CLI::log($this->color_message(__('Currency: ', 'give'), give_get_currency()));
126
+		WP_CLI::log($this->color_message(__('Currency Position: ', 'give'), give_get_currency_position()));
127
+		WP_CLI::log($this->color_message(__('Thousand Separator: ', 'give'), give_get_price_thousand_separator()));
128
+		WP_CLI::log($this->color_message(__('Decimal Separator: ', 'give'), give_get_price_decimal_separator()));
129
+		WP_CLI::log($this->color_message(__('Number of Decimals: ', 'give'), give_get_price_decimals()));
130
+		WP_CLI::log($this->color_message(__('Test Mode: ', 'give'), (give_get_option('test_mode') ? __('Yes', 'give') : __('No', 'give'))));
131
+		WP_CLI::log($this->color_message(__('Default Gateway: ', 'give'), ($default_gateway ? $default_gateway : __('Not Set', 'give'))));
132 132
 
133 133
 		// Payment gateways Information.
134
-		$gateways = give_get_ordered_payment_gateways( give_get_payment_gateways() );
135
-		WP_CLI::log( $this->color_message( __( 'Enabled Gateways: ', 'give' ) ) );
134
+		$gateways = give_get_ordered_payment_gateways(give_get_payment_gateways());
135
+		WP_CLI::log($this->color_message(__('Enabled Gateways: ', 'give')));
136 136
 
137
-		if ( ! empty( $gateways ) ) {
137
+		if ( ! empty($gateways)) {
138 138
 			self::$counter = 1;
139
-			foreach ( $gateways as $gateway ) {
140
-				WP_CLI::log( '  ' . $this->color_message( self::$counter, $gateway['admin_label'] ) );
141
-				self::$counter ++;
139
+			foreach ($gateways as $gateway) {
140
+				WP_CLI::log('  '.$this->color_message(self::$counter, $gateway['admin_label']));
141
+				self::$counter++;
142 142
 			}
143 143
 		} else {
144
-			WP_CLI::log( __( 'Not any payment gateways found', 'give' ) );
144
+			WP_CLI::log(__('Not any payment gateways found', 'give'));
145 145
 		}
146 146
 	}
147 147
 
@@ -173,15 +173,15 @@  discard block
 block discarded – undo
173 173
 	 *
174 174
 	 * @subcommand    forms
175 175
 	 */
176
-	public function forms( $args, $assoc_args ) {
176
+	public function forms($args, $assoc_args) {
177 177
 		global $wp_query;
178
-		$form_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false;
179
-		$number  = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? absint( $assoc_args['number'] ) : 10;
178
+		$form_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : false;
179
+		$number  = isset($assoc_args) && array_key_exists('number', $assoc_args) ? absint($assoc_args['number']) : 10;
180 180
 		$start   = time();
181 181
 
182 182
 		// Cache previous number query var.
183 183
 		$is_set_number = $cache_per_page = false;
184
-		if ( isset( $wp_query->query_vars['number'] ) ) {
184
+		if (isset($wp_query->query_vars['number'])) {
185 185
 			$cache_per_page = $wp_query->query_vars['number'];
186 186
 			$is_set_number  = true;
187 187
 		}
@@ -190,22 +190,22 @@  discard block
 block discarded – undo
190 190
 		$wp_query->query_vars['number'] = $number;
191 191
 
192 192
 		// Get forms.
193
-		$forms = $form_id ? $this->api->get_forms( $form_id ) : $this->api->get_forms();
193
+		$forms = $form_id ? $this->api->get_forms($form_id) : $this->api->get_forms();
194 194
 
195 195
 		// Reset number query var.
196
-		if ( $is_set_number ) {
196
+		if ($is_set_number) {
197 197
 			$wp_query->query_vars['number'] = $cache_per_page;
198 198
 		}
199 199
 
200 200
 		// Bailout.
201
-		if ( array_key_exists( 'error', $forms ) ) {
201
+		if (array_key_exists('error', $forms)) {
202 202
 
203
-			WP_CLI::warning( $forms['error'] );
203
+			WP_CLI::warning($forms['error']);
204 204
 
205 205
 			return;
206
-		} elseif ( empty( $forms['forms'] ) ) {
206
+		} elseif (empty($forms['forms'])) {
207 207
 
208
-			WP_CLI::error( __( 'No forms found.', 'give' ) );
208
+			WP_CLI::error(__('No forms found.', 'give'));
209 209
 
210 210
 			return;
211 211
 		}
@@ -213,25 +213,25 @@  discard block
 block discarded – undo
213 213
 		// Param to check if form typeis already showed or not.
214 214
 		$is_show_form_type = false;
215 215
 
216
-		if ( 1 === count( $forms ) && $form_id ) {
216
+		if (1 === count($forms) && $form_id) {
217 217
 			// Show single form.
218
-			foreach ( $forms['forms'][0] as $key => $info ) {
219
-				switch ( $key ) {
218
+			foreach ($forms['forms'][0] as $key => $info) {
219
+				switch ($key) {
220 220
 					case 'stats':
221
-						$this->color_main_heading( ucfirst( $key ) );
221
+						$this->color_main_heading(ucfirst($key));
222 222
 
223
-						foreach ( $info as $heading => $data ) {
224
-							$this->color_sub_heading( ucfirst( $heading ) );
225
-							switch ( $heading ) {
223
+						foreach ($info as $heading => $data) {
224
+							$this->color_sub_heading(ucfirst($heading));
225
+							switch ($heading) {
226 226
 								default:
227
-									foreach ( $data as $subheading => $subdata ) {
227
+									foreach ($data as $subheading => $subdata) {
228 228
 
229
-										switch ( $subheading ) {
229
+										switch ($subheading) {
230 230
 											case 'earnings':
231
-												WP_CLI::log( $this->color_message( $subheading . ': ', give_currency_filter( $subdata ) ) );
231
+												WP_CLI::log($this->color_message($subheading.': ', give_currency_filter($subdata)));
232 232
 												break;
233 233
 											default:
234
-												WP_CLI::log( $this->color_message( $subheading . ': ', $subdata ) );
234
+												WP_CLI::log($this->color_message($subheading.': ', $subdata));
235 235
 										}
236 236
 									}
237 237
 							}
@@ -241,26 +241,26 @@  discard block
 block discarded – undo
241 241
 					case 'pricing':
242 242
 					case 'info':
243 243
 					default:
244
-						$this->color_main_heading( ucfirst( $key ) );
244
+						$this->color_main_heading(ucfirst($key));
245 245
 
246 246
 						// Show form type.
247
-						if ( ! $is_show_form_type ) {
248
-							$form              = new Give_Donate_Form( $form_id );
247
+						if ( ! $is_show_form_type) {
248
+							$form              = new Give_Donate_Form($form_id);
249 249
 							$is_show_form_type = true;
250 250
 
251
-							WP_CLI::log( $this->color_message( __( 'form type', 'give' ), $form->get_type() ) );
251
+							WP_CLI::log($this->color_message(__('form type', 'give'), $form->get_type()));
252 252
 						}
253 253
 
254
-						foreach ( $info as $heading => $data ) {
254
+						foreach ($info as $heading => $data) {
255 255
 
256
-							switch ( $heading ) {
256
+							switch ($heading) {
257 257
 								case 'id':
258
-									WP_CLI::log( $this->color_message( $heading, $data ) );
258
+									WP_CLI::log($this->color_message($heading, $data));
259 259
 									break;
260 260
 
261 261
 								default:
262
-									$data = empty( $data ) ? __( 'Not set', 'give' ) : $data;
263
-									WP_CLI::log( $this->color_message( $heading, $data ) );
262
+									$data = empty($data) ? __('Not set', 'give') : $data;
263
+									WP_CLI::log($this->color_message($heading, $data));
264 264
 							}
265 265
 						}
266 266
 				}// End switch().
@@ -271,37 +271,37 @@  discard block
 block discarded – undo
271 271
 			$is_table_first_row_set = false;
272 272
 			$table_column_count     = 0;
273 273
 
274
-			WP_CLI::line( $this->color_message( sprintf( __( '%d donation forms found', 'give' ), count( $forms['forms'] ) ), '', false ) );
274
+			WP_CLI::line($this->color_message(sprintf(__('%d donation forms found', 'give'), count($forms['forms'])), '', false));
275 275
 
276
-			foreach ( $forms['forms'] as $index => $form_data ) {
276
+			foreach ($forms['forms'] as $index => $form_data) {
277 277
 
278 278
 				// Default table data.
279 279
 				$table_first_row = array();
280 280
 				$table_row       = array();
281 281
 
282
-				foreach ( $form_data['info'] as $key => $form ) {
282
+				foreach ($form_data['info'] as $key => $form) {
283 283
 
284 284
 					// Do not show thumbnail, content and link in table.
285
-					if ( in_array( $key, array( 'content', 'thumbnail', 'link' ), true ) ) {
285
+					if (in_array($key, array('content', 'thumbnail', 'link'), true)) {
286 286
 						continue;
287 287
 					}
288 288
 
289
-					if ( ! $is_table_first_row_set ) {
289
+					if ( ! $is_table_first_row_set) {
290 290
 						$table_first_row[] = $key;
291 291
 					}
292 292
 
293 293
 					$table_row[] = $form;
294 294
 
295
-					if ( 'status' === $key ) {
295
+					if ('status' === $key) {
296 296
 						// First array item will be an form id in our case.
297
-						$form = new Give_Donate_Form( absint( $table_row[0] ) );
297
+						$form = new Give_Donate_Form(absint($table_row[0]));
298 298
 
299 299
 						$table_row[] = $form->get_type();
300 300
 					}
301 301
 				}
302 302
 
303 303
 				// Set table first row.
304
-				if ( ! $is_table_first_row_set ) {
304
+				if ( ! $is_table_first_row_set) {
305 305
 
306 306
 					// Add extra column to table.
307 307
 					$table_first_row[] = 'type';
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 				$table_data[] = $table_row;
315 315
 			}// End foreach().
316 316
 
317
-			$this->display_table( $table_data );
317
+			$this->display_table($table_data);
318 318
 		}// End if().
319 319
 	}
320 320
 
@@ -366,37 +366,37 @@  discard block
 block discarded – undo
366 366
 	 *
367 367
 	 * @subcommand    donors
368 368
 	 */
369
-	public function donors( $args, $assoc_args ) {
369
+	public function donors($args, $assoc_args) {
370 370
 		global $wp_query;
371
-		$donor_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false;
372
-		$email    = isset( $assoc_args ) && array_key_exists( 'email', $assoc_args ) ? $assoc_args['email'] : false;
373
-		$name     = isset( $assoc_args ) && array_key_exists( 'name', $assoc_args ) ? $assoc_args['name'] : '';
374
-		$create   = isset( $assoc_args ) && array_key_exists( 'create', $assoc_args ) ? $assoc_args['create'] : false;
375
-		$number   = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10;
376
-		$form_id  = isset( $assoc_args ) && array_key_exists( 'form-id', $assoc_args ) ? $assoc_args['form-id'] : 0;
377
-		$format   = isset( $assoc_args ) && array_key_exists( 'format', $assoc_args ) ? $assoc_args['format'] : 'table';
371
+		$donor_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : false;
372
+		$email    = isset($assoc_args) && array_key_exists('email', $assoc_args) ? $assoc_args['email'] : false;
373
+		$name     = isset($assoc_args) && array_key_exists('name', $assoc_args) ? $assoc_args['name'] : '';
374
+		$create   = isset($assoc_args) && array_key_exists('create', $assoc_args) ? $assoc_args['create'] : false;
375
+		$number   = isset($assoc_args) && array_key_exists('number', $assoc_args) ? $assoc_args['number'] : 10;
376
+		$form_id  = isset($assoc_args) && array_key_exists('form-id', $assoc_args) ? $assoc_args['form-id'] : 0;
377
+		$format   = isset($assoc_args) && array_key_exists('format', $assoc_args) ? $assoc_args['format'] : 'table';
378 378
 		$start    = time();
379 379
 
380
-		if ( $create ) {
380
+		if ($create) {
381 381
 			$number = 1;
382 382
 
383
-			if ( isset( $assoc_args['email'] ) && ! is_email( $email ) ) {
384
-				WP_CLI::warning( 'Wrong email address provided.', 'give' );
383
+			if (isset($assoc_args['email']) && ! is_email($email)) {
384
+				WP_CLI::warning('Wrong email address provided.', 'give');
385 385
 
386 386
 				return;
387 387
 			}
388 388
 
389 389
 			// Create one or more donors.
390
-			if ( ! $email ) {
390
+			if ( ! $email) {
391 391
 				// If no email is specified, look to see if we are generating arbitrary donor accounts.
392
-				$number = is_numeric( $create ) ? absint( $create ) : 1;
392
+				$number = is_numeric($create) ? absint($create) : 1;
393 393
 			}
394 394
 
395
-			for ( $i = 0; $i < $number; $i ++ ) {
396
-				if ( ! $email ) {
395
+			for ($i = 0; $i < $number; $i++) {
396
+				if ( ! $email) {
397 397
 
398 398
 					// Generate fake email.
399
-					$email = 'customer-' . uniqid() . '@test.com';
399
+					$email = 'customer-'.uniqid().'@test.com';
400 400
 				}
401 401
 
402 402
 				$args = array(
@@ -404,19 +404,19 @@  discard block
 block discarded – undo
404 404
 					'name'  => $name,
405 405
 				);
406 406
 
407
-				$donor_id = Give()->donors->add( $args );
407
+				$donor_id = Give()->donors->add($args);
408 408
 
409
-				if ( $donor_id ) {
410
-					WP_CLI::line( $this->color_message( sprintf( __( 'Donor #%d created successfully', 'give' ), $donor_id ) ) );
409
+				if ($donor_id) {
410
+					WP_CLI::line($this->color_message(sprintf(__('Donor #%d created successfully', 'give'), $donor_id)));
411 411
 				} else {
412
-					WP_CLI::error( __( 'Failed to create donor', 'give' ) );
412
+					WP_CLI::error(__('Failed to create donor', 'give'));
413 413
 				}
414 414
 
415 415
 				// Reset email to false so it is generated on the next loop (if creating donors).
416 416
 				$email = false;
417 417
 			}
418 418
 
419
-			WP_CLI::line( $this->color_message( sprintf( __( '%1$d donors created in %2$d seconds', 'give' ), $number, time() - $start ) ) );
419
+			WP_CLI::line($this->color_message(sprintf(__('%1$d donors created in %2$d seconds', 'give'), $number, time() - $start)));
420 420
 
421 421
 		} else {
422 422
 			// Counter.
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
 			 */
431 431
 			// Cache previous number query var.
432 432
 			$is_set_number = $cache_per_page = false;
433
-			if ( isset( $wp_query->query_vars['number'] ) ) {
433
+			if (isset($wp_query->query_vars['number'])) {
434 434
 				$cache_per_page = $wp_query->query_vars['number'];
435 435
 				$is_set_number  = true;
436 436
 			}
@@ -439,24 +439,24 @@  discard block
 block discarded – undo
439 439
 			$wp_query->query_vars['number'] = $number;
440 440
 
441 441
 			// Get donors.
442
-			if ( $form_id ) {
442
+			if ($form_id) {
443 443
 				// @TODO: Allow user to get a list of donors by donation status.
444
-				$donors = $this->get_donors_by_form_id( $form_id );
444
+				$donors = $this->get_donors_by_form_id($form_id);
445 445
 			} else {
446
-				$donors = $this->api->get_donors( $search );
446
+				$donors = $this->api->get_donors($search);
447 447
 			}
448 448
 
449 449
 			// Reset number query var.
450
-			if ( $is_set_number ) {
450
+			if ($is_set_number) {
451 451
 				$wp_query->query_vars['number'] = $cache_per_page;
452 452
 			}
453 453
 
454
-			if ( isset( $donors['error'] ) ) {
455
-				WP_CLI::error( $donors['error'] );
454
+			if (isset($donors['error'])) {
455
+				WP_CLI::error($donors['error']);
456 456
 			}
457 457
 
458
-			if ( empty( $donors ) ) {
459
-				WP_CLI::error( __( 'No donors found.', 'give' ) );
458
+			if (empty($donors)) {
459
+				WP_CLI::error(__('No donors found.', 'give'));
460 460
 
461 461
 				return;
462 462
 			}
@@ -464,24 +464,24 @@  discard block
 block discarded – undo
464 464
 			$table_data             = array();
465 465
 			$is_table_first_row_set = false;
466 466
 
467
-			foreach ( $donors['donors'] as $donor_data ) {
467
+			foreach ($donors['donors'] as $donor_data) {
468 468
 				// Set default table row data.
469
-				$table_first_row = array( __( 's_no', 'give' ) );
470
-				$table_row       = array( self::$counter );
469
+				$table_first_row = array(__('s_no', 'give'));
470
+				$table_row       = array(self::$counter);
471 471
 
472
-				foreach ( $donor_data as $key => $donor ) {
473
-					switch ( $key ) {
472
+				foreach ($donor_data as $key => $donor) {
473
+					switch ($key) {
474 474
 						case 'stats':
475
-							foreach ( $donor as $heading => $data ) {
475
+							foreach ($donor as $heading => $data) {
476 476
 
477 477
 								// Get first row.
478
-								if ( ! $is_table_first_row_set ) {
478
+								if ( ! $is_table_first_row_set) {
479 479
 									$table_first_row[] = $heading;
480 480
 								}
481 481
 
482
-								switch ( $heading ) {
482
+								switch ($heading) {
483 483
 									case 'total_spent':
484
-										$table_row[] = give_currency_filter( $data );
484
+										$table_row[] = give_currency_filter($data);
485 485
 										break;
486 486
 
487 487
 									default:
@@ -492,10 +492,10 @@  discard block
 block discarded – undo
492 492
 
493 493
 						case 'info':
494 494
 						default:
495
-							foreach ( $donor as $heading => $data ) {
495
+							foreach ($donor as $heading => $data) {
496 496
 
497 497
 								// Get first row.
498
-								if ( ! $is_table_first_row_set ) {
498
+								if ( ! $is_table_first_row_set) {
499 499
 									$table_first_row[] = $heading;
500 500
 								}
501 501
 
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 				}
506 506
 
507 507
 				// Add first row data to table data.
508
-				if ( ! $is_table_first_row_set ) {
508
+				if ( ! $is_table_first_row_set) {
509 509
 					$table_data[]           = $table_first_row;
510 510
 					$is_table_first_row_set = true;
511 511
 				}
@@ -514,44 +514,44 @@  discard block
 block discarded – undo
514 514
 				$table_data[] = $table_row;
515 515
 
516 516
 				// Increase counter.
517
-				self::$counter ++;
517
+				self::$counter++;
518 518
 			}// End foreach().
519 519
 
520
-			switch ( $format ) {
520
+			switch ($format) {
521 521
 				case 'json':
522 522
 					$table_column_name = $table_data[0];
523
-					unset( $table_data[0] );
523
+					unset($table_data[0]);
524 524
 
525 525
 					$new_table_data = array();
526
-					foreach ( $table_data as $index => $data ) {
527
-						foreach ( $data as $key => $value ) {
528
-							$new_table_data[ $index ][ $table_column_name[ $key ] ] = $value;
526
+					foreach ($table_data as $index => $data) {
527
+						foreach ($data as $key => $value) {
528
+							$new_table_data[$index][$table_column_name[$key]] = $value;
529 529
 						}
530 530
 					}
531 531
 
532
-					WP_CLI::log( json_encode( $new_table_data ) );
532
+					WP_CLI::log(json_encode($new_table_data));
533 533
 					break;
534 534
 
535 535
 				case 'csv':
536
-					$file_path = trailingslashit( WP_CONTENT_DIR ) . 'uploads/give_donors_' . date( 'Y_m_d_s', current_time( 'timestamp' ) ) . '.csv';
537
-					$fp        = fopen( $file_path, 'w' );
536
+					$file_path = trailingslashit(WP_CONTENT_DIR).'uploads/give_donors_'.date('Y_m_d_s', current_time('timestamp')).'.csv';
537
+					$fp        = fopen($file_path, 'w');
538 538
 
539
-					if ( is_writable( $file_path ) ) {
540
-						foreach ( $table_data as $fields ) {
541
-							fputcsv( $fp, $fields );
539
+					if (is_writable($file_path)) {
540
+						foreach ($table_data as $fields) {
541
+							fputcsv($fp, $fields);
542 542
 						}
543 543
 
544
-						fclose( $fp );
544
+						fclose($fp);
545 545
 
546
-						WP_CLI::success( "Donors list csv created successfully: {$file_path}" );
546
+						WP_CLI::success("Donors list csv created successfully: {$file_path}");
547 547
 					} else {
548
-						WP_CLI::warning( "Unable to create donors list csv file: {$file_path} (May folder do not have write permission)" );
548
+						WP_CLI::warning("Unable to create donors list csv file: {$file_path} (May folder do not have write permission)");
549 549
 					}
550 550
 
551 551
 					break;
552 552
 
553 553
 				default:
554
-					$this->display_table( $table_data );
554
+					$this->display_table($table_data);
555 555
 			}// End switch().
556 556
 		}// End if().
557 557
 	}
@@ -581,13 +581,13 @@  discard block
 block discarded – undo
581 581
 	 *
582 582
 	 * @subcommand    donations
583 583
 	 */
584
-	public function donations( $args, $assoc_args ) {
584
+	public function donations($args, $assoc_args) {
585 585
 		global $wp_query;
586
-		$number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10;
586
+		$number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? $assoc_args['number'] : 10;
587 587
 
588 588
 		// Cache previous number query var.
589 589
 		$is_set_number = $cache_per_page = false;
590
-		if ( isset( $wp_query->query_vars['number'] ) ) {
590
+		if (isset($wp_query->query_vars['number'])) {
591 591
 			$cache_per_page = $wp_query->query_vars['number'];
592 592
 			$is_set_number  = true;
593 593
 		}
@@ -599,46 +599,46 @@  discard block
 block discarded – undo
599 599
 		$donations = $this->api->get_recent_donations();
600 600
 
601 601
 		// Reset number query var.
602
-		if ( $is_set_number ) {
602
+		if ($is_set_number) {
603 603
 			$wp_query->query_vars['number'] = $cache_per_page;
604 604
 		}
605 605
 
606
-		if ( empty( $donations ) ) {
607
-			WP_CLI::error( __( 'No donations found.', 'give' ) );
606
+		if (empty($donations)) {
607
+			WP_CLI::error(__('No donations found.', 'give'));
608 608
 
609 609
 			return;
610 610
 		}
611 611
 
612 612
 		self::$counter = 1;
613 613
 
614
-		foreach ( $donations['donations'] as $key => $donation ) {
615
-			$this->color_main_heading( sprintf( __( '%1$s. Donation #%2$s', 'give' ), self::$counter, $donation['ID'] ), 'Y' );
616
-			self::$counter ++;
614
+		foreach ($donations['donations'] as $key => $donation) {
615
+			$this->color_main_heading(sprintf(__('%1$s. Donation #%2$s', 'give'), self::$counter, $donation['ID']), 'Y');
616
+			self::$counter++;
617 617
 
618
-			foreach ( $donation as $column => $data ) {
618
+			foreach ($donation as $column => $data) {
619 619
 
620
-				if ( is_array( $data ) ) {
621
-					$this->color_sub_heading( $column );
622
-					foreach ( $data as $subcolumn => $subdata ) {
620
+				if (is_array($data)) {
621
+					$this->color_sub_heading($column);
622
+					foreach ($data as $subcolumn => $subdata) {
623 623
 
624 624
 						// Decode html codes.
625
-						switch ( $subcolumn ) {
625
+						switch ($subcolumn) {
626 626
 							case 'name':
627
-								$subdata = html_entity_decode( $subdata );
627
+								$subdata = html_entity_decode($subdata);
628 628
 								break;
629 629
 						}
630 630
 
631 631
 						// @TODO Check if multi dimension array information is importent to show or not. For example inside donation array we have array for fees data inside payment meta.
632
-						if ( is_array( $subdata ) ) {
632
+						if (is_array($subdata)) {
633 633
 							continue;
634 634
 						}
635 635
 
636
-						WP_CLI::log( $this->color_message( $subcolumn, $subdata ) );
636
+						WP_CLI::log($this->color_message($subcolumn, $subdata));
637 637
 					}
638 638
 					continue;
639 639
 				}
640 640
 
641
-				WP_CLI::log( $this->color_message( $column, $data ) );
641
+				WP_CLI::log($this->color_message($column, $data));
642 642
 			}
643 643
 		}
644 644
 	}
@@ -677,27 +677,27 @@  discard block
 block discarded – undo
677 677
 	 *
678 678
 	 * @return        void
679 679
 	 */
680
-	public function report( $args, $assoc_args ) {
680
+	public function report($args, $assoc_args) {
681 681
 		$stats      = new Give_Payment_Stats();
682
-		$date       = isset( $assoc_args ) && array_key_exists( 'date', $assoc_args ) ? $assoc_args['date'] : false;
683
-		$start_date = isset( $assoc_args ) && array_key_exists( 'start-date', $assoc_args ) ? $assoc_args['start-date'] : false;
684
-		$end_date   = isset( $assoc_args ) && array_key_exists( 'end-date', $assoc_args ) ? $assoc_args['end-date'] : false;
685
-		$form_id    = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? $assoc_args['id'] : 0;
682
+		$date       = isset($assoc_args) && array_key_exists('date', $assoc_args) ? $assoc_args['date'] : false;
683
+		$start_date = isset($assoc_args) && array_key_exists('start-date', $assoc_args) ? $assoc_args['start-date'] : false;
684
+		$end_date   = isset($assoc_args) && array_key_exists('end-date', $assoc_args) ? $assoc_args['end-date'] : false;
685
+		$form_id    = isset($assoc_args) && array_key_exists('id', $assoc_args) ? $assoc_args['id'] : 0;
686 686
 
687
-		if ( ! empty( $date ) ) {
687
+		if ( ! empty($date)) {
688 688
 			$start_date = $date;
689 689
 			$end_date   = false;
690
-		} elseif ( empty( $date ) && empty( $start_date ) ) {
690
+		} elseif (empty($date) && empty($start_date)) {
691 691
 			$start_date = 'this_month';
692 692
 			$end_date   = false;
693 693
 		}
694 694
 
695 695
 		// Get stats.
696
-		$earnings = $stats->get_earnings( $form_id, $start_date, $end_date );
697
-		$sales    = $stats->get_sales( $form_id, $start_date, $end_date );
696
+		$earnings = $stats->get_earnings($form_id, $start_date, $end_date);
697
+		$sales    = $stats->get_sales($form_id, $start_date, $end_date);
698 698
 
699
-		WP_CLI::line( $this->color_message( __( 'Earnings', 'give' ), give_currency_filter( $earnings ) ) );
700
-		WP_CLI::line( $this->color_message( __( 'Sales', 'give' ), $sales ) );
699
+		WP_CLI::line($this->color_message(__('Earnings', 'give'), give_currency_filter($earnings)));
700
+		WP_CLI::line($this->color_message(__('Sales', 'give'), $sales));
701 701
 	}
702 702
 
703 703
 
@@ -724,27 +724,27 @@  discard block
 block discarded – undo
724 724
 	 *
725 725
 	 * @subcommand    cache
726 726
 	 */
727
-	public function cache( $args, $assoc_args ) {
728
-		$action = isset( $assoc_args ) && array_key_exists( 'action', $assoc_args ) ? $assoc_args['action'] : false;
727
+	public function cache($args, $assoc_args) {
728
+		$action = isset($assoc_args) && array_key_exists('action', $assoc_args) ? $assoc_args['action'] : false;
729 729
 
730 730
 		// Bailout.
731
-		if ( ! $action || ! in_array( $action, array( 'delete' ), true ) ) {
732
-			WP_CLI::warning( __( 'Type wp give cache --action=delete to delete all stat transients', 'give' ) );
731
+		if ( ! $action || ! in_array($action, array('delete'), true)) {
732
+			WP_CLI::warning(__('Type wp give cache --action=delete to delete all stat transients', 'give'));
733 733
 
734 734
 			return;
735 735
 		}
736 736
 
737
-		switch ( $action ) {
737
+		switch ($action) {
738 738
 			case 'delete' :
739 739
 				// Reset counter.
740 740
 				self::$counter = 1;
741 741
 
742
-				if ( $this->delete_stats_transients() ) {
742
+				if ($this->delete_stats_transients()) {
743 743
 					// Report .eading.
744
-					WP_CLI::success( 'Give cache deleted.' );
744
+					WP_CLI::success('Give cache deleted.');
745 745
 				} else {
746 746
 					// Report .eading.
747
-					WP_CLI::warning( 'We did not find any Give plugin cache to delete :)' );
747
+					WP_CLI::warning('We did not find any Give plugin cache to delete :)');
748 748
 				}
749 749
 				break;
750 750
 		}
@@ -773,27 +773,27 @@  discard block
 block discarded – undo
773 773
 			ARRAY_A
774 774
 		);
775 775
 
776
-		if ( ! empty( $stat_option_names ) ) {
776
+		if ( ! empty($stat_option_names)) {
777 777
 
778
-			foreach ( $stat_option_names as $option_name ) {
778
+			foreach ($stat_option_names as $option_name) {
779 779
 				$error       = false;
780 780
 				$option_name = $option_name['option_name'];
781 781
 
782
-				switch ( true ) {
783
-					case ( false !== strpos( $option_name, 'transient' ) ):
784
-						$option_name = str_replace( '_transient_', '', $option_name );
785
-						$error       = delete_transient( $option_name );
782
+				switch (true) {
783
+					case (false !== strpos($option_name, 'transient')):
784
+						$option_name = str_replace('_transient_', '', $option_name);
785
+						$error       = delete_transient($option_name);
786 786
 						break;
787 787
 
788 788
 					default:
789
-						$error = delete_option( $option_name );
789
+						$error = delete_option($option_name);
790 790
 				}
791 791
 
792
-				if ( $error ) {
793
-					WP_CLI::log( $this->color_message( self::$counter, $option_name ) );
794
-					self::$counter ++;
792
+				if ($error) {
793
+					WP_CLI::log($this->color_message(self::$counter, $option_name));
794
+					self::$counter++;
795 795
 				} else {
796
-					WP_CLI::log( $this->color_message( __( 'Error while deleting this transient', 'give' ), $option_name ) );
796
+					WP_CLI::log($this->color_message(__('Error while deleting this transient', 'give'), $option_name));
797 797
 				}
798 798
 			}
799 799
 
@@ -814,13 +814,13 @@  discard block
 block discarded – undo
814 814
 	 *
815 815
 	 * @return   string
816 816
 	 */
817
-	private function color_message( $heading, $message = '', $colon = true, $color = 'g' ) {
817
+	private function color_message($heading, $message = '', $colon = true, $color = 'g') {
818 818
 		// Add colon.
819
-		if ( $colon ) {
820
-			$heading = $heading . ': ';
819
+		if ($colon) {
820
+			$heading = $heading.': ';
821 821
 		}
822 822
 
823
-		return WP_CLI::colorize( "%{$color}" . $heading . '%n' ) . $message;
823
+		return WP_CLI::colorize("%{$color}".$heading.'%n').$message;
824 824
 	}
825 825
 
826 826
 
@@ -835,8 +835,8 @@  discard block
 block discarded – undo
835 835
 	 *
836 836
 	 * @return    void
837 837
 	 */
838
-	private function color_main_heading( $heading, $color = 'g' ) {
839
-		WP_CLI::log( "\n######   " . $this->color_message( $heading, '', false, $color ) . '   ######' );
838
+	private function color_main_heading($heading, $color = 'g') {
839
+		WP_CLI::log("\n######   ".$this->color_message($heading, '', false, $color).'   ######');
840 840
 	}
841 841
 
842 842
 	/**
@@ -849,8 +849,8 @@  discard block
 block discarded – undo
849 849
 	 *
850 850
 	 * @return    void
851 851
 	 */
852
-	private function color_sub_heading( $subheading ) {
853
-		WP_CLI::log( "\n--->" . $subheading . '', '', false );
852
+	private function color_sub_heading($subheading) {
853
+		WP_CLI::log("\n--->".$subheading.'', '', false);
854 854
 	}
855 855
 
856 856
 
@@ -864,17 +864,17 @@  discard block
 block discarded – undo
864 864
 	 *
865 865
 	 * @return    void
866 866
 	 */
867
-	private function display_table( $data ) {
867
+	private function display_table($data) {
868 868
 		$table = new \cli\Table();
869 869
 
870 870
 		// Set table header.
871
-		$table->setHeaders( $data[0] );
871
+		$table->setHeaders($data[0]);
872 872
 
873 873
 		// Remove table header.
874
-		unset( $data[0] );
874
+		unset($data[0]);
875 875
 
876 876
 		// Set table data.
877
-		$table->setRows( $data );
877
+		$table->setRows($data);
878 878
 
879 879
 		// Display table.
880 880
 		$table->display();
@@ -891,14 +891,14 @@  discard block
 block discarded – undo
891 891
 	 * @return array
892 892
 	 */
893 893
 
894
-	private function get_donors_by_form_id( $form_id ) {
894
+	private function get_donors_by_form_id($form_id) {
895 895
 		$donors = array();
896 896
 
897 897
 		$donations = new Give_Payments_Query(
898 898
 			array(
899
-				'give_forms' => array( $form_id ),
900
-				'number'     => - 1,
901
-				'status'     => array( 'publish' ),
899
+				'give_forms' => array($form_id),
900
+				'number'     => -1,
901
+				'status'     => array('publish'),
902 902
 			)
903 903
 		);
904 904
 
@@ -906,16 +906,16 @@  discard block
 block discarded – undo
906 906
 		$skip_donors = array();
907 907
 
908 908
 		/* @var Give_Payment|object $donation Payment object. */
909
-		foreach ( $donations as $donation ) {
909
+		foreach ($donations as $donation) {
910 910
 
911
-			if ( in_array( $donation->customer_id, $skip_donors ) ) {
911
+			if (in_array($donation->customer_id, $skip_donors)) {
912 912
 				continue;
913 913
 			}
914 914
 
915
-			if ( ! empty( $donors ) ) {
916
-				$donors['donors'][] = current( current( $this->api->get_donors( (int) $donation->customer_id ) ) );
915
+			if ( ! empty($donors)) {
916
+				$donors['donors'][] = current(current($this->api->get_donors((int) $donation->customer_id)));
917 917
 			} else {
918
-				$donors = array_merge( $donors, $this->api->get_donors( (int) $donation->customer_id ) );
918
+				$donors = array_merge($donors, $this->api->get_donors((int) $donation->customer_id));
919 919
 			}
920 920
 
921 921
 			$skip_donors[] = $donation->customer_id;
Please login to merge, or discard this patch.
includes/misc-functions.php 1 patch
Spacing   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -23,9 +23,9 @@  discard block
 block discarded – undo
23 23
  */
24 24
 function give_is_test_mode() {
25 25
 
26
-	$ret = give_is_setting_enabled( give_get_option( 'test_mode' ) );
26
+	$ret = give_is_setting_enabled(give_get_option('test_mode'));
27 27
 
28
-	return (bool) apply_filters( 'give_is_test_mode', $ret );
28
+	return (bool) apply_filters('give_is_test_mode', $ret);
29 29
 
30 30
 }
31 31
 
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
37 37
  */
38 38
 function give_get_currency() {
39 39
 
40
-	$currency = give_get_option( 'currency', 'USD' );
40
+	$currency = give_get_option('currency', 'USD');
41 41
 
42
-	return apply_filters( 'give_currency', $currency );
42
+	return apply_filters('give_currency', $currency);
43 43
 }
44 44
 
45 45
 /**
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
  */
52 52
 function give_get_currency_position() {
53 53
 
54
-	$currency_pos = give_get_option( 'currency_position', 'before' );
54
+	$currency_pos = give_get_option('currency_position', 'before');
55 55
 
56
-	return apply_filters( 'give_currency_position', $currency_pos );
56
+	return apply_filters('give_currency_position', $currency_pos);
57 57
 }
58 58
 
59 59
 
@@ -66,39 +66,39 @@  discard block
 block discarded – undo
66 66
 
67 67
 function give_get_currencies() {
68 68
 	$currencies = array(
69
-		'USD'  => __( 'US Dollars ($)', 'give' ),
70
-		'EUR'  => __( 'Euros (€)', 'give' ),
71
-		'GBP'  => __( 'Pounds Sterling (£)', 'give' ),
72
-		'AUD'  => __( 'Australian Dollars ($)', 'give' ),
73
-		'BRL'  => __( 'Brazilian Real (R$)', 'give' ),
74
-		'CAD'  => __( 'Canadian Dollars ($)', 'give' ),
75
-		'CZK'  => __( 'Czech Koruna (Kč)', 'give' ),
76
-		'DKK'  => __( 'Danish Krone (kr.)', 'give' ),
77
-		'HKD'  => __( 'Hong Kong Dollar ($)', 'give' ),
78
-		'HUF'  => __( 'Hungarian Forint (Ft)', 'give' ),
79
-		'ILS'  => __( 'Israeli Shekel (₪)', 'give' ),
80
-		'JPY'  => __( 'Japanese Yen (¥)', 'give' ),
81
-		'MYR'  => __( 'Malaysian Ringgits (RM)', 'give' ),
82
-		'MXN'  => __( 'Mexican Peso ($)', 'give' ),
83
-		'MAD'  => __( 'Moroccan Dirham (&#x2e;&#x62f;&#x2e;&#x645;)', 'give' ),
84
-		'NZD'  => __( 'New Zealand Dollar ($)', 'give' ),
85
-		'NOK'  => __( 'Norwegian Krone (Kr.)', 'give' ),
86
-		'PHP'  => __( 'Philippine Pesos (₱)', 'give' ),
87
-		'PLN'  => __( 'Polish Zloty (zł)', 'give' ),
88
-		'SGD'  => __( 'Singapore Dollar ($)', 'give' ),
89
-		'KRW'  => __( 'South Korean Won (₩)', 'give' ),
90
-		'ZAR'  => __( 'South African Rand (R)', 'give' ),
91
-		'SEK'  => __( 'Swedish Krona (kr)', 'give' ),
92
-		'CHF'  => __( 'Swiss Franc (CHF)', 'give' ),
93
-		'TWD'  => __( 'Taiwan New Dollars (NT$)', 'give' ),
94
-		'THB'  => __( 'Thai Baht (฿)', 'give' ),
95
-		'INR'  => __( 'Indian Rupee (₹)', 'give' ),
96
-		'TRY'  => __( 'Turkish Lira (₺)', 'give' ),
97
-		'RIAL' => __( 'Iranian Rial (﷼)', 'give' ),
98
-		'RUB'  => __( 'Russian Rubles (руб)', 'give' ),
69
+		'USD'  => __('US Dollars ($)', 'give'),
70
+		'EUR'  => __('Euros (€)', 'give'),
71
+		'GBP'  => __('Pounds Sterling (£)', 'give'),
72
+		'AUD'  => __('Australian Dollars ($)', 'give'),
73
+		'BRL'  => __('Brazilian Real (R$)', 'give'),
74
+		'CAD'  => __('Canadian Dollars ($)', 'give'),
75
+		'CZK'  => __('Czech Koruna (Kč)', 'give'),
76
+		'DKK'  => __('Danish Krone (kr.)', 'give'),
77
+		'HKD'  => __('Hong Kong Dollar ($)', 'give'),
78
+		'HUF'  => __('Hungarian Forint (Ft)', 'give'),
79
+		'ILS'  => __('Israeli Shekel (₪)', 'give'),
80
+		'JPY'  => __('Japanese Yen (¥)', 'give'),
81
+		'MYR'  => __('Malaysian Ringgits (RM)', 'give'),
82
+		'MXN'  => __('Mexican Peso ($)', 'give'),
83
+		'MAD'  => __('Moroccan Dirham (&#x2e;&#x62f;&#x2e;&#x645;)', 'give'),
84
+		'NZD'  => __('New Zealand Dollar ($)', 'give'),
85
+		'NOK'  => __('Norwegian Krone (Kr.)', 'give'),
86
+		'PHP'  => __('Philippine Pesos (₱)', 'give'),
87
+		'PLN'  => __('Polish Zloty (zł)', 'give'),
88
+		'SGD'  => __('Singapore Dollar ($)', 'give'),
89
+		'KRW'  => __('South Korean Won (₩)', 'give'),
90
+		'ZAR'  => __('South African Rand (R)', 'give'),
91
+		'SEK'  => __('Swedish Krona (kr)', 'give'),
92
+		'CHF'  => __('Swiss Franc (CHF)', 'give'),
93
+		'TWD'  => __('Taiwan New Dollars (NT$)', 'give'),
94
+		'THB'  => __('Thai Baht (฿)', 'give'),
95
+		'INR'  => __('Indian Rupee (₹)', 'give'),
96
+		'TRY'  => __('Turkish Lira (₺)', 'give'),
97
+		'RIAL' => __('Iranian Rial (﷼)', 'give'),
98
+		'RUB'  => __('Russian Rubles (руб)', 'give'),
99 99
 	);
100 100
 
101
-	return apply_filters( 'give_currencies', $currencies );
101
+	return apply_filters('give_currencies', $currencies);
102 102
 }
103 103
 
104 104
 
@@ -115,12 +115,12 @@  discard block
 block discarded – undo
115 115
  *
116 116
  * @return string           The symbol to use for the currency
117 117
  */
118
-function give_currency_symbol( $currency = '', $decode_currency = false ) {
118
+function give_currency_symbol($currency = '', $decode_currency = false) {
119 119
 
120
-	if ( empty( $currency ) ) {
120
+	if (empty($currency)) {
121 121
 		$currency = give_get_currency();
122 122
 	}
123
-	switch ( $currency ) :
123
+	switch ($currency) :
124 124
 		case 'GBP' :
125 125
 			$symbol = '&pound;';
126 126
 			break;
@@ -198,9 +198,9 @@  discard block
 block discarded – undo
198 198
 			break;
199 199
 	endswitch;
200 200
 
201
-	$symbol = ( ! $decode_currency ? $symbol : html_entity_decode( $symbol ) );
201
+	$symbol = ( ! $decode_currency ? $symbol : html_entity_decode($symbol));
202 202
 
203
-	return apply_filters( 'give_currency_symbol', $symbol, $currency );
203
+	return apply_filters('give_currency_symbol', $symbol, $currency);
204 204
 }
205 205
 
206 206
 
@@ -213,16 +213,16 @@  discard block
 block discarded – undo
213 213
  *
214 214
  * @return string
215 215
  */
216
-function give_get_currency_name( $currency_code ) {
216
+function give_get_currency_name($currency_code) {
217 217
 	$currency_name = '';
218 218
 	$currency_names = give_get_currencies();
219 219
 
220
-	if ( $currency_code && array_key_exists( $currency_code, $currency_names ) ) {
221
-		$currency_name = explode( '(',  $currency_names[ $currency_code ] );
222
-		$currency_name = trim( current( $currency_name ) );
220
+	if ($currency_code && array_key_exists($currency_code, $currency_names)) {
221
+		$currency_name = explode('(', $currency_names[$currency_code]);
222
+		$currency_name = trim(current($currency_name));
223 223
 	}
224 224
 
225
-	return apply_filters( 'give_currency_name', $currency_name, $currency_code );
225
+	return apply_filters('give_currency_name', $currency_name, $currency_code);
226 226
 }
227 227
 
228 228
 
@@ -236,21 +236,21 @@  discard block
 block discarded – undo
236 236
 
237 237
 	global $wp;
238 238
 
239
-	if ( get_option( 'permalink_structure' ) ) {
240
-		$base = trailingslashit( home_url( $wp->request ) );
239
+	if (get_option('permalink_structure')) {
240
+		$base = trailingslashit(home_url($wp->request));
241 241
 	} else {
242
-		$base = add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) );
243
-		$base = remove_query_arg( array( 'post_type', 'name' ), $base );
242
+		$base = add_query_arg($wp->query_string, '', trailingslashit(home_url($wp->request)));
243
+		$base = remove_query_arg(array('post_type', 'name'), $base);
244 244
 	}
245 245
 
246 246
 	$scheme      = is_ssl() ? 'https' : 'http';
247
-	$current_uri = set_url_scheme( $base, $scheme );
247
+	$current_uri = set_url_scheme($base, $scheme);
248 248
 
249
-	if ( is_front_page() ) {
250
-		$current_uri = home_url( '/' );
249
+	if (is_front_page()) {
250
+		$current_uri = home_url('/');
251 251
 	}
252 252
 
253
-	return apply_filters( 'give_get_current_page_url', $current_uri );
253
+	return apply_filters('give_get_current_page_url', $current_uri);
254 254
 
255 255
 }
256 256
 
@@ -272,15 +272,15 @@  discard block
 block discarded – undo
272 272
 	 */
273 273
 	$gateways = give_get_enabled_payment_gateways();
274 274
 
275
-	if ( count( $gateways ) == 1 && ! isset( $gateways['paypal'] ) && ! isset( $gateways['manual'] ) ) {
275
+	if (count($gateways) == 1 && ! isset($gateways['paypal']) && ! isset($gateways['manual'])) {
276 276
 		$ret = true;
277
-	} elseif ( count( $gateways ) == 1 ) {
277
+	} elseif (count($gateways) == 1) {
278 278
 		$ret = false;
279
-	} elseif ( count( $gateways ) == 2 && isset( $gateways['paypal'] ) && isset( $gateways['manual'] ) ) {
279
+	} elseif (count($gateways) == 2 && isset($gateways['paypal']) && isset($gateways['manual'])) {
280 280
 		$ret = false;
281 281
 	}
282 282
 
283
-	return (bool) apply_filters( 'give_verify_credit_cards', $ret );
283
+	return (bool) apply_filters('give_verify_credit_cards', $ret);
284 284
 }
285 285
 
286 286
 /**
@@ -292,26 +292,26 @@  discard block
 block discarded – undo
292 292
 function give_get_timezone_id() {
293 293
 
294 294
 	// if site timezone string exists, return it.
295
-	if ( $timezone = get_option( 'timezone_string' ) ) {
295
+	if ($timezone = get_option('timezone_string')) {
296 296
 		return $timezone;
297 297
 	}
298 298
 
299 299
 	// get UTC offset, if it isn't set return UTC.
300
-	if ( ! ( $utc_offset = 3600 * get_option( 'gmt_offset', 0 ) ) ) {
300
+	if ( ! ($utc_offset = 3600 * get_option('gmt_offset', 0))) {
301 301
 		return 'UTC';
302 302
 	}
303 303
 
304 304
 	// attempt to guess the timezone string from the UTC offset.
305
-	$timezone = timezone_name_from_abbr( '', $utc_offset );
305
+	$timezone = timezone_name_from_abbr('', $utc_offset);
306 306
 
307 307
 	// last try, guess timezone string manually.
308
-	if ( $timezone === false ) {
308
+	if ($timezone === false) {
309 309
 
310
-		$is_dst = date( 'I' );
310
+		$is_dst = date('I');
311 311
 
312
-		foreach ( timezone_abbreviations_list() as $abbr ) {
313
-			foreach ( $abbr as $city ) {
314
-				if ( $city['dst'] == $is_dst && $city['offset'] == $utc_offset ) {
312
+		foreach (timezone_abbreviations_list() as $abbr) {
313
+			foreach ($abbr as $city) {
314
+				if ($city['dst'] == $is_dst && $city['offset'] == $utc_offset) {
315 315
 					return $city['timezone_id'];
316 316
 				}
317 317
 			}
@@ -335,17 +335,17 @@  discard block
 block discarded – undo
335 335
 
336 336
 	$ip = '127.0.0.1';
337 337
 
338
-	if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
338
+	if ( ! empty($_SERVER['HTTP_CLIENT_IP'])) {
339 339
 		// check ip from share internet
340 340
 		$ip = $_SERVER['HTTP_CLIENT_IP'];
341
-	} elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
341
+	} elseif ( ! empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
342 342
 		// to check ip is pass from proxy
343 343
 		$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
344
-	} elseif ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) {
344
+	} elseif ( ! empty($_SERVER['REMOTE_ADDR'])) {
345 345
 		$ip = $_SERVER['REMOTE_ADDR'];
346 346
 	}
347 347
 
348
-	return apply_filters( 'give_get_ip', $ip );
348
+	return apply_filters('give_get_ip', $ip);
349 349
 }
350 350
 
351 351
 
@@ -360,9 +360,9 @@  discard block
 block discarded – undo
360 360
  *
361 361
  * @uses  Give()->session->set()
362 362
  */
363
-function give_set_purchase_session( $purchase_data = array() ) {
364
-	Give()->session->set( 'give_purchase', $purchase_data );
365
-	Give()->session->set( 'give_email', $purchase_data['user_email'] );
363
+function give_set_purchase_session($purchase_data = array()) {
364
+	Give()->session->set('give_purchase', $purchase_data);
365
+	Give()->session->set('give_email', $purchase_data['user_email']);
366 366
 }
367 367
 
368 368
 /**
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
  * @return mixed array | false
377 377
  */
378 378
 function give_get_purchase_session() {
379
-	return Give()->session->get( 'give_purchase' );
379
+	return Give()->session->get('give_purchase');
380 380
 }
381 381
 
382 382
 /**
@@ -391,14 +391,14 @@  discard block
 block discarded – undo
391 391
  *
392 392
  * @return string
393 393
  */
394
-function give_get_purchase_summary( $purchase_data, $email = true ) {
394
+function give_get_purchase_summary($purchase_data, $email = true) {
395 395
 	$summary = '';
396 396
 
397
-	if ( $email ) {
398
-		$summary .= $purchase_data['user_email'] . ' - ';
397
+	if ($email) {
398
+		$summary .= $purchase_data['user_email'].' - ';
399 399
 	}
400 400
 
401
-	$summary .= get_the_title( $purchase_data['post_data']['give-form-id'] );
401
+	$summary .= get_the_title($purchase_data['post_data']['give-form-id']);
402 402
 
403 403
 	return $summary;
404 404
 }
@@ -415,31 +415,31 @@  discard block
 block discarded – undo
415 415
 function give_get_host() {
416 416
 	$host = false;
417 417
 
418
-	if ( defined( 'WPE_APIKEY' ) ) {
418
+	if (defined('WPE_APIKEY')) {
419 419
 		$host = 'WP Engine';
420
-	} elseif ( defined( 'PAGELYBIN' ) ) {
420
+	} elseif (defined('PAGELYBIN')) {
421 421
 		$host = 'Pagely';
422
-	} elseif ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) {
422
+	} elseif (DB_HOST == 'localhost:/tmp/mysql5.sock') {
423 423
 		$host = 'ICDSoft';
424
-	} elseif ( DB_HOST == 'mysqlv5' ) {
424
+	} elseif (DB_HOST == 'mysqlv5') {
425 425
 		$host = 'NetworkSolutions';
426
-	} elseif ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) {
426
+	} elseif (strpos(DB_HOST, 'ipagemysql.com') !== false) {
427 427
 		$host = 'iPage';
428
-	} elseif ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) {
428
+	} elseif (strpos(DB_HOST, 'ipowermysql.com') !== false) {
429 429
 		$host = 'IPower';
430
-	} elseif ( strpos( DB_HOST, '.gridserver.com' ) !== false ) {
430
+	} elseif (strpos(DB_HOST, '.gridserver.com') !== false) {
431 431
 		$host = 'MediaTemple Grid';
432
-	} elseif ( strpos( DB_HOST, '.pair.com' ) !== false ) {
432
+	} elseif (strpos(DB_HOST, '.pair.com') !== false) {
433 433
 		$host = 'pair Networks';
434
-	} elseif ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) {
434
+	} elseif (strpos(DB_HOST, '.stabletransit.com') !== false) {
435 435
 		$host = 'Rackspace Cloud';
436
-	} elseif ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) {
436
+	} elseif (strpos(DB_HOST, '.sysfix.eu') !== false) {
437 437
 		$host = 'SysFix.eu Power Hosting';
438
-	} elseif ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) {
438
+	} elseif (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) {
439 439
 		$host = 'Flywheel';
440 440
 	} else {
441 441
 		// Adding a general fallback for data gathering
442
-		$host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME'];
442
+		$host = 'DBH: '.DB_HOST.', SRV: '.$_SERVER['SERVER_NAME'];
443 443
 	}
444 444
 
445 445
 	return $host;
@@ -455,67 +455,67 @@  discard block
 block discarded – undo
455 455
  *
456 456
  * @return bool true if host matches, false if not
457 457
  */
458
-function give_is_host( $host = false ) {
458
+function give_is_host($host = false) {
459 459
 
460 460
 	$return = false;
461 461
 
462
-	if ( $host ) {
463
-		$host = str_replace( ' ', '', strtolower( $host ) );
462
+	if ($host) {
463
+		$host = str_replace(' ', '', strtolower($host));
464 464
 
465
-		switch ( $host ) {
465
+		switch ($host) {
466 466
 			case 'wpengine':
467
-				if ( defined( 'WPE_APIKEY' ) ) {
467
+				if (defined('WPE_APIKEY')) {
468 468
 					$return = true;
469 469
 				}
470 470
 				break;
471 471
 			case 'pagely':
472
-				if ( defined( 'PAGELYBIN' ) ) {
472
+				if (defined('PAGELYBIN')) {
473 473
 					$return = true;
474 474
 				}
475 475
 				break;
476 476
 			case 'icdsoft':
477
-				if ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) {
477
+				if (DB_HOST == 'localhost:/tmp/mysql5.sock') {
478 478
 					$return = true;
479 479
 				}
480 480
 				break;
481 481
 			case 'networksolutions':
482
-				if ( DB_HOST == 'mysqlv5' ) {
482
+				if (DB_HOST == 'mysqlv5') {
483 483
 					$return = true;
484 484
 				}
485 485
 				break;
486 486
 			case 'ipage':
487
-				if ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) {
487
+				if (strpos(DB_HOST, 'ipagemysql.com') !== false) {
488 488
 					$return = true;
489 489
 				}
490 490
 				break;
491 491
 			case 'ipower':
492
-				if ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) {
492
+				if (strpos(DB_HOST, 'ipowermysql.com') !== false) {
493 493
 					$return = true;
494 494
 				}
495 495
 				break;
496 496
 			case 'mediatemplegrid':
497
-				if ( strpos( DB_HOST, '.gridserver.com' ) !== false ) {
497
+				if (strpos(DB_HOST, '.gridserver.com') !== false) {
498 498
 					$return = true;
499 499
 				}
500 500
 				break;
501 501
 			case 'pairnetworks':
502
-				if ( strpos( DB_HOST, '.pair.com' ) !== false ) {
502
+				if (strpos(DB_HOST, '.pair.com') !== false) {
503 503
 					$return = true;
504 504
 				}
505 505
 				break;
506 506
 			case 'rackspacecloud':
507
-				if ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) {
507
+				if (strpos(DB_HOST, '.stabletransit.com') !== false) {
508 508
 					$return = true;
509 509
 				}
510 510
 				break;
511 511
 			case 'sysfix.eu':
512 512
 			case 'sysfix.eupowerhosting':
513
-				if ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) {
513
+				if (strpos(DB_HOST, '.sysfix.eu') !== false) {
514 514
 					$return = true;
515 515
 				}
516 516
 				break;
517 517
 			case 'flywheel':
518
-				if ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) {
518
+				if (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) {
519 519
 					$return = true;
520 520
 				}
521 521
 				break;
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
  * @param string $replacement Optional. The function that should have been called.
549 549
  * @param array  $backtrace   Optional. Contains stack backtrace of deprecated function.
550 550
  */
551
-function _give_deprecated_function( $function, $version, $replacement = null, $backtrace = null ) {
551
+function _give_deprecated_function($function, $version, $replacement = null, $backtrace = null) {
552 552
 
553 553
 	/**
554 554
 	 * Fires while give deprecated function call occurs.
@@ -561,19 +561,19 @@  discard block
 block discarded – undo
561 561
 	 * @param string $replacement Optional. The function that should have been called.
562 562
 	 * @param string $version     The plugin version that deprecated the function.
563 563
 	 */
564
-	do_action( 'give_deprecated_function_run', $function, $replacement, $version );
564
+	do_action('give_deprecated_function_run', $function, $replacement, $version);
565 565
 
566
-	$show_errors = current_user_can( 'manage_options' );
566
+	$show_errors = current_user_can('manage_options');
567 567
 
568 568
 	// Allow plugin to filter the output error trigger.
569
-	if ( WP_DEBUG && apply_filters( 'give_deprecated_function_trigger_error', $show_errors ) ) {
570
-		if ( ! is_null( $replacement ) ) {
571
-			trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give' ), $function, $version, $replacement ) );
572
-			trigger_error( print_r( $backtrace, 1 ) ); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine.
569
+	if (WP_DEBUG && apply_filters('give_deprecated_function_trigger_error', $show_errors)) {
570
+		if ( ! is_null($replacement)) {
571
+			trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give'), $function, $version, $replacement));
572
+			trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine.
573 573
 			// Alternatively we could dump this to a file.
574 574
 		} else {
575
-			trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give' ), $function, $version ) );
576
-			trigger_error( print_r( $backtrace, 1 ) );// Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine.
575
+			trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give'), $function, $version));
576
+			trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine.
577 577
 			// Alternatively we could dump this to a file.
578 578
 		}
579 579
 	}
@@ -587,8 +587,8 @@  discard block
 block discarded – undo
587 587
  * @return string $post_id
588 588
  */
589 589
 function give_get_admin_post_id() {
590
-	$post_id = isset( $_GET['post'] ) ? $_GET['post'] : null;
591
-	if ( ! $post_id && isset( $_POST['post_id'] ) ) {
590
+	$post_id = isset($_GET['post']) ? $_GET['post'] : null;
591
+	if ( ! $post_id && isset($_POST['post_id'])) {
592 592
 		$post_id = $_POST['post_id'];
593 593
 	}
594 594
 
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
  * @return string Arg separator output
603 603
  */
604 604
 function give_get_php_arg_separator_output() {
605
-	return ini_get( 'arg_separator.output' );
605
+	return ini_get('arg_separator.output');
606 606
 }
607 607
 
608 608
 
@@ -617,10 +617,10 @@  discard block
 block discarded – undo
617 617
  *
618 618
  * @return string Short month name
619 619
  */
620
-function give_month_num_to_name( $n ) {
621
-	$timestamp = mktime( 0, 0, 0, $n, 1, 2005 );
620
+function give_month_num_to_name($n) {
621
+	$timestamp = mktime(0, 0, 0, $n, 1, 2005);
622 622
 
623
-	return date_i18n( 'M', $timestamp );
623
+	return date_i18n('M', $timestamp);
624 624
 }
625 625
 
626 626
 
@@ -633,10 +633,10 @@  discard block
 block discarded – undo
633 633
  *
634 634
  * @return bool Whether or not function is disabled.
635 635
  */
636
-function give_is_func_disabled( $function ) {
637
-	$disabled = explode( ',', ini_get( 'disable_functions' ) );
636
+function give_is_func_disabled($function) {
637
+	$disabled = explode(',', ini_get('disable_functions'));
638 638
 
639
-	return in_array( $function, $disabled );
639
+	return in_array($function, $disabled);
640 640
 }
641 641
 
642 642
 
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
 function give_get_newsletter() {
649 649
 	?>
650 650
 
651
-	<p class="newsletter-intro"><?php esc_html_e( 'Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give' ); ?></p>
651
+	<p class="newsletter-intro"><?php esc_html_e('Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give'); ?></p>
652 652
 
653 653
 	<div class="give-newsletter-form-wrap">
654 654
 
@@ -656,33 +656,33 @@  discard block
 block discarded – undo
656 656
 			  method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate"
657 657
 			  target="_blank" novalidate>
658 658
 			<div class="give-newsletter-confirmation">
659
-				<p><?php esc_html_e( 'Thanks for Subscribing!', 'give' ); ?> :)</p>
659
+				<p><?php esc_html_e('Thanks for Subscribing!', 'give'); ?> :)</p>
660 660
 			</div>
661 661
 
662 662
 			<table class="form-table give-newsletter-form">
663 663
 				<tr valign="middle">
664 664
 					<td>
665 665
 						<label for="mce-EMAIL"
666
-							   class="screen-reader-text"><?php esc_html_e( 'Email Address (required)', 'give' ); ?></label>
666
+							   class="screen-reader-text"><?php esc_html_e('Email Address (required)', 'give'); ?></label>
667 667
 						<input type="email" name="EMAIL" id="mce-EMAIL"
668
-							   placeholder="<?php esc_attr_e( 'Email Address (required)', 'give' ); ?>"
668
+							   placeholder="<?php esc_attr_e('Email Address (required)', 'give'); ?>"
669 669
 							   class="required email" value="">
670 670
 					</td>
671 671
 					<td>
672 672
 						<label for="mce-FNAME"
673
-							   class="screen-reader-text"><?php esc_html_e( 'First Name', 'give' ); ?></label>
673
+							   class="screen-reader-text"><?php esc_html_e('First Name', 'give'); ?></label>
674 674
 						<input type="text" name="FNAME" id="mce-FNAME"
675
-							   placeholder="<?php esc_attr_e( 'First Name', 'give' ); ?>" class="" value="">
675
+							   placeholder="<?php esc_attr_e('First Name', 'give'); ?>" class="" value="">
676 676
 					</td>
677 677
 					<td>
678 678
 						<label for="mce-LNAME"
679
-							   class="screen-reader-text"><?php esc_html_e( 'Last Name', 'give' ); ?></label>
679
+							   class="screen-reader-text"><?php esc_html_e('Last Name', 'give'); ?></label>
680 680
 						<input type="text" name="LNAME" id="mce-LNAME"
681
-							   placeholder="<?php esc_attr_e( 'Last Name', 'give' ); ?>" class="" value="">
681
+							   placeholder="<?php esc_attr_e('Last Name', 'give'); ?>" class="" value="">
682 682
 					</td>
683 683
 					<td>
684 684
 						<input type="submit" name="subscribe" id="mc-embedded-subscribe" class="button"
685
-							   value="<?php esc_attr_e( 'Subscribe', 'give' ); ?>">
685
+							   value="<?php esc_attr_e('Subscribe', 'give'); ?>">
686 686
 					</td>
687 687
 				</tr>
688 688
 			</table>
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
  *
736 736
  * @return string
737 737
  */
738
-function give_svg_icons( $icon ) {
738
+function give_svg_icons($icon) {
739 739
 
740 740
 	// Store your SVGs in an associative array
741 741
 	$svgs = array(
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
 	);
748 748
 
749 749
 	// Return the chosen icon's SVG string
750
-	return $svgs[ $icon ];
750
+	return $svgs[$icon];
751 751
 }
752 752
 
753 753
 /**
@@ -759,15 +759,15 @@  discard block
 block discarded – undo
759 759
  *
760 760
  * @return mixed
761 761
  */
762
-function modify_nav_menu_meta_box_object( $post_type ) {
763
-	if ( isset( $post_type->name ) && $post_type->name == 'give_forms' ) {
764
-		$post_type->labels->name = esc_html__( 'Donation Forms', 'give' );
762
+function modify_nav_menu_meta_box_object($post_type) {
763
+	if (isset($post_type->name) && $post_type->name == 'give_forms') {
764
+		$post_type->labels->name = esc_html__('Donation Forms', 'give');
765 765
 	}
766 766
 
767 767
 	return $post_type;
768 768
 }
769 769
 
770
-add_filter( 'nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object' );
770
+add_filter('nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object');
771 771
 
772 772
 /**
773 773
  * Enable 'Donation Form' meta enabled by default on Menu page.
@@ -777,22 +777,22 @@  discard block
 block discarded – undo
777 777
 function give_nav_donation_metabox_enabled() {
778 778
 
779 779
 	// Return false, if it fails to retrieve hidden meta box list and is not admin.
780
-	if ( ( ! $hidden_meta_boxes = get_user_option( 'metaboxhidden_nav-menus' ) ) || ! is_admin() ) {
780
+	if (( ! $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus')) || ! is_admin()) {
781 781
 		return false;
782 782
 	}
783 783
 
784 784
 	// Return false, In case, we don't find 'Donation Form' in hidden meta box list.
785
-	if ( ! in_array( 'add-post-type-give_forms', $hidden_meta_boxes, true ) ) {
785
+	if ( ! in_array('add-post-type-give_forms', $hidden_meta_boxes, true)) {
786 786
 		return false;
787 787
 	}
788 788
 
789 789
 	// Exclude 'Donation Form' value from hidden meta box's list.
790
-	$hidden_meta_boxes = array_diff( $hidden_meta_boxes, array( 'add-post-type-give_forms' ) );
790
+	$hidden_meta_boxes = array_diff($hidden_meta_boxes, array('add-post-type-give_forms'));
791 791
 
792 792
 	// Get current user ID.
793 793
 	$user = wp_get_current_user();
794 794
 
795
-	update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true );
795
+	update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true);
796 796
 }
797 797
 
798 798
 /**
@@ -806,7 +806,7 @@  discard block
 block discarded – undo
806 806
  * @license    https://opensource.org/licenses/MIT MIT
807 807
  */
808 808
 
809
-if ( ! function_exists( 'array_column' ) ) {
809
+if ( ! function_exists('array_column')) {
810 810
 	/**
811 811
 	 * Returns the values from a single column of the input array, identified by
812 812
 	 * the $columnKey.
@@ -825,53 +825,53 @@  discard block
 block discarded – undo
825 825
 	 *
826 826
 	 * @return array
827 827
 	 */
828
-	function array_column( $input = null, $columnKey = null, $indexKey = null ) {
828
+	function array_column($input = null, $columnKey = null, $indexKey = null) {
829 829
 		// Using func_get_args() in order to check for proper number of
830 830
 		// parameters and trigger errors exactly as the built-in array_column()
831 831
 		// does in PHP 5.5.
832 832
 		$argc   = func_num_args();
833 833
 		$params = func_get_args();
834 834
 
835
-		if ( $argc < 2 ) {
836
-			trigger_error( sprintf( esc_html__( 'array_column() expects at least 2 parameters, %s given.', 'give' ), $argc ), E_USER_WARNING );
835
+		if ($argc < 2) {
836
+			trigger_error(sprintf(esc_html__('array_column() expects at least 2 parameters, %s given.', 'give'), $argc), E_USER_WARNING);
837 837
 
838 838
 			return null;
839 839
 		}
840 840
 
841
-		if ( ! is_array( $params[0] ) ) {
842
-			trigger_error( sprintf( esc_html__( 'array_column() expects parameter 1 to be array, %s given.', 'give' ), gettype( $params[0] ) ), E_USER_WARNING );
841
+		if ( ! is_array($params[0])) {
842
+			trigger_error(sprintf(esc_html__('array_column() expects parameter 1 to be array, %s given.', 'give'), gettype($params[0])), E_USER_WARNING);
843 843
 
844 844
 			return null;
845 845
 		}
846 846
 
847
-		if ( ! is_int( $params[1] )
848
-		     && ! is_float( $params[1] )
849
-		     && ! is_string( $params[1] )
847
+		if ( ! is_int($params[1])
848
+		     && ! is_float($params[1])
849
+		     && ! is_string($params[1])
850 850
 		     && $params[1] !== null
851
-		     && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) )
851
+		     && ! (is_object($params[1]) && method_exists($params[1], '__toString'))
852 852
 		) {
853
-			trigger_error( esc_html__( 'array_column(): The column key should be either a string or an integer.', 'give' ), E_USER_WARNING );
853
+			trigger_error(esc_html__('array_column(): The column key should be either a string or an integer.', 'give'), E_USER_WARNING);
854 854
 
855 855
 			return false;
856 856
 		}
857 857
 
858
-		if ( isset( $params[2] )
859
-		     && ! is_int( $params[2] )
860
-		     && ! is_float( $params[2] )
861
-		     && ! is_string( $params[2] )
862
-		     && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) )
858
+		if (isset($params[2])
859
+		     && ! is_int($params[2])
860
+		     && ! is_float($params[2])
861
+		     && ! is_string($params[2])
862
+		     && ! (is_object($params[2]) && method_exists($params[2], '__toString'))
863 863
 		) {
864
-			trigger_error( esc_html__( 'array_column(): The index key should be either a string or an integer.', 'give' ), E_USER_WARNING );
864
+			trigger_error(esc_html__('array_column(): The index key should be either a string or an integer.', 'give'), E_USER_WARNING);
865 865
 
866 866
 			return false;
867 867
 		}
868 868
 
869 869
 		$paramsInput     = $params[0];
870
-		$paramsColumnKey = ( $params[1] !== null ) ? (string) $params[1] : null;
870
+		$paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null;
871 871
 
872 872
 		$paramsIndexKey = null;
873
-		if ( isset( $params[2] ) ) {
874
-			if ( is_float( $params[2] ) || is_int( $params[2] ) ) {
873
+		if (isset($params[2])) {
874
+			if (is_float($params[2]) || is_int($params[2])) {
875 875
 				$paramsIndexKey = (int) $params[2];
876 876
 			} else {
877 877
 				$paramsIndexKey = (string) $params[2];
@@ -880,26 +880,26 @@  discard block
 block discarded – undo
880 880
 
881 881
 		$resultArray = array();
882 882
 
883
-		foreach ( $paramsInput as $row ) {
883
+		foreach ($paramsInput as $row) {
884 884
 			$key    = $value = null;
885 885
 			$keySet = $valueSet = false;
886 886
 
887
-			if ( $paramsIndexKey !== null && array_key_exists( $paramsIndexKey, $row ) ) {
887
+			if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) {
888 888
 				$keySet = true;
889
-				$key    = (string) $row[ $paramsIndexKey ];
889
+				$key    = (string) $row[$paramsIndexKey];
890 890
 			}
891 891
 
892
-			if ( $paramsColumnKey === null ) {
892
+			if ($paramsColumnKey === null) {
893 893
 				$valueSet = true;
894 894
 				$value    = $row;
895
-			} elseif ( is_array( $row ) && array_key_exists( $paramsColumnKey, $row ) ) {
895
+			} elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) {
896 896
 				$valueSet = true;
897
-				$value    = $row[ $paramsColumnKey ];
897
+				$value    = $row[$paramsColumnKey];
898 898
 			}
899 899
 
900
-			if ( $valueSet ) {
901
-				if ( $keySet ) {
902
-					$resultArray[ $key ] = $value;
900
+			if ($valueSet) {
901
+				if ($keySet) {
902
+					$resultArray[$key] = $value;
903 903
 				} else {
904 904
 					$resultArray[] = $value;
905 905
 				}
@@ -919,40 +919,40 @@  discard block
 block discarded – undo
919 919
  *
920 920
  * @return bool Whether the receipt is visible or not.
921 921
  */
922
-function give_can_view_receipt( $payment_key = '' ) {
922
+function give_can_view_receipt($payment_key = '') {
923 923
 
924 924
 	$return = false;
925 925
 
926
-	if ( empty( $payment_key ) ) {
926
+	if (empty($payment_key)) {
927 927
 		return $return;
928 928
 	}
929 929
 
930 930
 	global $give_receipt_args;
931 931
 
932
-	$give_receipt_args['id'] = give_get_purchase_id_by_key( $payment_key );
932
+	$give_receipt_args['id'] = give_get_purchase_id_by_key($payment_key);
933 933
 
934
-	$user_id = (int) give_get_payment_user_id( $give_receipt_args['id'] );
934
+	$user_id = (int) give_get_payment_user_id($give_receipt_args['id']);
935 935
 
936
-	$payment_meta = give_get_payment_meta( $give_receipt_args['id'] );
936
+	$payment_meta = give_get_payment_meta($give_receipt_args['id']);
937 937
 
938
-	if ( is_user_logged_in() ) {
939
-		if ( $user_id === (int) get_current_user_id() ) {
938
+	if (is_user_logged_in()) {
939
+		if ($user_id === (int) get_current_user_id()) {
940 940
 			$return = true;
941
-		} elseif ( wp_get_current_user()->user_email === give_get_payment_user_email( $give_receipt_args['id'] ) ) {
941
+		} elseif (wp_get_current_user()->user_email === give_get_payment_user_email($give_receipt_args['id'])) {
942 942
 			$return = true;
943
-		} elseif ( current_user_can( 'view_give_sensitive_data' ) ) {
943
+		} elseif (current_user_can('view_give_sensitive_data')) {
944 944
 			$return = true;
945 945
 		}
946 946
 	}
947 947
 
948 948
 	$session = give_get_purchase_session();
949
-	if ( ! empty( $session ) && ! is_user_logged_in() ) {
950
-		if ( $session['purchase_key'] === $payment_meta['key'] ) {
949
+	if ( ! empty($session) && ! is_user_logged_in()) {
950
+		if ($session['purchase_key'] === $payment_meta['key']) {
951 951
 			$return = true;
952 952
 		}
953 953
 	}
954 954
 
955
-	return (bool) apply_filters( 'give_can_view_receipt', $return, $payment_key );
955
+	return (bool) apply_filters('give_can_view_receipt', $return, $payment_key);
956 956
 
957 957
 }
958 958
 
@@ -961,7 +961,7 @@  discard block
 block discarded – undo
961 961
  *
962 962
  * Fallback in case the calendar extension is not loaded in PHP; Only supports Gregorian calendar
963 963
  */
964
-if ( ! function_exists( 'cal_days_in_month' ) ) {
964
+if ( ! function_exists('cal_days_in_month')) {
965 965
 	/**
966 966
 	 * cal_days_in_month
967 967
 	 *
@@ -971,8 +971,8 @@  discard block
 block discarded – undo
971 971
 	 *
972 972
 	 * @return bool|string
973 973
 	 */
974
-	function cal_days_in_month( $calendar, $month, $year ) {
975
-		return date( 't', mktime( 0, 0, 0, $month, 1, $year ) );
974
+	function cal_days_in_month($calendar, $month, $year) {
975
+		return date('t', mktime(0, 0, 0, $month, 1, $year));
976 976
 	}
977 977
 }
978 978
 
@@ -991,42 +991,42 @@  discard block
 block discarded – undo
991 991
  */
992 992
 function give_get_plugins() {
993 993
 	$plugins             = get_plugins();
994
-	$active_plugin_paths = (array) get_option( 'active_plugins', array() );
994
+	$active_plugin_paths = (array) get_option('active_plugins', array());
995 995
 
996
-	if ( is_multisite() ) {
997
-		$network_activated_plugin_paths = array_keys( get_site_option( 'active_sitewide_plugins', array() ) );
998
-		$active_plugin_paths            = array_merge( $active_plugin_paths, $network_activated_plugin_paths );
996
+	if (is_multisite()) {
997
+		$network_activated_plugin_paths = array_keys(get_site_option('active_sitewide_plugins', array()));
998
+		$active_plugin_paths            = array_merge($active_plugin_paths, $network_activated_plugin_paths);
999 999
 	}
1000 1000
 
1001
-	foreach ( $plugins as $plugin_path => $plugin_data ) {
1001
+	foreach ($plugins as $plugin_path => $plugin_data) {
1002 1002
 		// Is plugin active?
1003
-		if ( in_array( $plugin_path, $active_plugin_paths ) ) {
1004
-			$plugins[ $plugin_path ]['Status'] = 'active';
1003
+		if (in_array($plugin_path, $active_plugin_paths)) {
1004
+			$plugins[$plugin_path]['Status'] = 'active';
1005 1005
 		} else {
1006
-			$plugins[ $plugin_path ]['Status'] = 'inactive';
1006
+			$plugins[$plugin_path]['Status'] = 'inactive';
1007 1007
 		}
1008 1008
 
1009
-		$dirname = strtolower( dirname( $plugin_path ) );
1009
+		$dirname = strtolower(dirname($plugin_path));
1010 1010
 
1011 1011
 		// Is plugin a Give add-on by WordImpress?
1012
-		if ( strstr( $dirname, 'give-' ) && strstr( $plugin_data['AuthorURI'], 'wordimpress.com' ) ) {
1012
+		if (strstr($dirname, 'give-') && strstr($plugin_data['AuthorURI'], 'wordimpress.com')) {
1013 1013
 			// Plugin is a Give-addon.
1014
-			$plugins[ $plugin_path ]['Type'] = 'add-on';
1014
+			$plugins[$plugin_path]['Type'] = 'add-on';
1015 1015
 
1016 1016
 			// Get license info from database.
1017
-			$plugin_name    = str_replace( 'Give - ', '', $plugin_data['Name'] );
1018
-			$db_option      = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $plugin_name ) ) ) . '_license_active';
1019
-			$license_active = get_option( $db_option );
1017
+			$plugin_name    = str_replace('Give - ', '', $plugin_data['Name']);
1018
+			$db_option      = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($plugin_name))).'_license_active';
1019
+			$license_active = get_option($db_option);
1020 1020
 
1021 1021
 			// Does a valid license exist?
1022
-			if ( ! empty( $license_active ) && 'valid' === $license_active->license ) {
1023
-				$plugins[ $plugin_path ]['License'] = true;
1022
+			if ( ! empty($license_active) && 'valid' === $license_active->license) {
1023
+				$plugins[$plugin_path]['License'] = true;
1024 1024
 			} else {
1025
-				$plugins[ $plugin_path ]['License'] = false;
1025
+				$plugins[$plugin_path]['License'] = false;
1026 1026
 			}
1027 1027
 		} else {
1028 1028
 			// Plugin is not a Give add-on.
1029
-			$plugins[ $plugin_path ]['Type'] = 'other';
1029
+			$plugins[$plugin_path]['Type'] = 'other';
1030 1030
 		}
1031 1031
 	}
1032 1032
 
@@ -1043,16 +1043,16 @@  discard block
 block discarded – undo
1043 1043
  *
1044 1044
  * @return bool
1045 1045
  */
1046
-function give_is_terms_enabled( $form_id ) {
1047
-	$form_option = give_get_meta( $form_id, '_give_terms_option', true );
1046
+function give_is_terms_enabled($form_id) {
1047
+	$form_option = give_get_meta($form_id, '_give_terms_option', true);
1048 1048
 
1049 1049
 	if (
1050
-		give_is_setting_enabled( $form_option, 'global' )
1051
-		&& give_is_setting_enabled( give_get_option( 'terms' ) )
1050
+		give_is_setting_enabled($form_option, 'global')
1051
+		&& give_is_setting_enabled(give_get_option('terms'))
1052 1052
 	) {
1053 1053
 		return true;
1054 1054
 
1055
-	} elseif ( give_is_setting_enabled( $form_option ) ) {
1055
+	} elseif (give_is_setting_enabled($form_option)) {
1056 1056
 		return true;
1057 1057
 
1058 1058
 	} else {
@@ -1076,9 +1076,9 @@  discard block
 block discarded – undo
1076 1076
  *
1077 1077
  * @return WP_Error|bool
1078 1078
  */
1079
-function give_delete_donation_stats( $date_range = '', $args = array() ) {
1079
+function give_delete_donation_stats($date_range = '', $args = array()) {
1080 1080
 	// Delete all cache.
1081
-	$status = Give_Cache::delete( Give_Cache::get_options_like( 'give_stats' ) );
1081
+	$status = Give_Cache::delete(Give_Cache::get_options_like('give_stats'));
1082 1082
 
1083 1083
 	/**
1084 1084
 	 * Fire the action when donation stats delete.
@@ -1088,7 +1088,7 @@  discard block
 block discarded – undo
1088 1088
 	 * @param string|array $date_range
1089 1089
 	 * @param array  $args
1090 1090
 	 */
1091
-	do_action( 'give_delete_donation_stats', $status, $date_range, $args );
1091
+	do_action('give_delete_donation_stats', $status, $date_range, $args);
1092 1092
 
1093 1093
 	return $status;
1094 1094
 }
@@ -1106,7 +1106,7 @@  discard block
 block discarded – undo
1106 1106
  *
1107 1107
  * @return mixed
1108 1108
  */
1109
-function give_get_meta( $id, $meta_key, $single = false, $default = false ) {
1109
+function give_get_meta($id, $meta_key, $single = false, $default = false) {
1110 1110
 	/**
1111 1111
 	 * Filter the meta value
1112 1112
 	 *
@@ -1114,14 +1114,14 @@  discard block
 block discarded – undo
1114 1114
 	 */
1115 1115
 	$meta_value = apply_filters(
1116 1116
 			'give_get_meta',
1117
-			get_post_meta( $id, $meta_key, $single ),
1117
+			get_post_meta($id, $meta_key, $single),
1118 1118
 			$id,
1119 1119
 			$meta_key,
1120 1120
 			$default
1121 1121
 	);
1122 1122
 
1123 1123
 	if (
1124
-		( empty( $meta_key ) || empty( $meta_value ) )
1124
+		(empty($meta_key) || empty($meta_value))
1125 1125
 		&& $default
1126 1126
 	) {
1127 1127
 		$meta_value = $default;
@@ -1142,15 +1142,15 @@  discard block
 block discarded – undo
1142 1142
  *
1143 1143
  * @return mixed
1144 1144
  */
1145
-function give_update_meta( $id, $meta_key, $meta_value, $prev_value = '' ) {
1146
-	$status = update_post_meta( $id, $meta_key, $meta_value, $prev_value );
1145
+function give_update_meta($id, $meta_key, $meta_value, $prev_value = '') {
1146
+	$status = update_post_meta($id, $meta_key, $meta_value, $prev_value);
1147 1147
 
1148 1148
 	/**
1149 1149
 	 * Filter the meta value update status
1150 1150
 	 *
1151 1151
 	 * @since 1.8.8
1152 1152
 	 */
1153
-	return apply_filters( 'give_update_meta', $status, $id, $meta_key, $meta_value );
1153
+	return apply_filters('give_update_meta', $status, $id, $meta_key, $meta_value);
1154 1154
 }
1155 1155
 
1156 1156
 /**
@@ -1164,13 +1164,13 @@  discard block
 block discarded – undo
1164 1164
  *
1165 1165
  * @return mixed
1166 1166
  */
1167
-function give_delete_meta( $id, $meta_key, $meta_value = '' ) {
1168
-	$status = delete_post_meta( $id, $meta_key, $meta_value );
1167
+function give_delete_meta($id, $meta_key, $meta_value = '') {
1168
+	$status = delete_post_meta($id, $meta_key, $meta_value);
1169 1169
 
1170 1170
 	/**
1171 1171
 	 * Filter the meta value delete status
1172 1172
 	 *
1173 1173
 	 * @since 1.8.8
1174 1174
 	 */
1175
-	return apply_filters( 'give_delete_meta', $status, $id, $meta_key, $meta_value );
1175
+	return apply_filters('give_delete_meta', $status, $id, $meta_key, $meta_value);
1176 1176
 }
Please login to merge, or discard this patch.
includes/class-give-donor.php 1 patch
Spacing   +170 added lines, -170 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -139,32 +139,32 @@  discard block
 block discarded – undo
139 139
 	 * @param bool $_id_or_email
140 140
 	 * @param bool $by_user_id
141 141
 	 */
142
-	public function __construct( $_id_or_email = false, $by_user_id = false ) {
142
+	public function __construct($_id_or_email = false, $by_user_id = false) {
143 143
 
144 144
 		$this->db = new Give_DB_Donors();
145 145
 
146 146
 		if (
147 147
 			false === $_id_or_email
148
-			|| ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) )
148
+			|| (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email))
149 149
 		) {
150 150
 			return false;
151 151
 		}
152 152
 
153
-		$by_user_id = is_bool( $by_user_id ) ? $by_user_id : false;
153
+		$by_user_id = is_bool($by_user_id) ? $by_user_id : false;
154 154
 
155
-		if ( is_numeric( $_id_or_email ) ) {
155
+		if (is_numeric($_id_or_email)) {
156 156
 			$field = $by_user_id ? 'user_id' : 'id';
157 157
 		} else {
158 158
 			$field = 'email';
159 159
 		}
160 160
 
161
-		$donor = $this->db->get_donor_by( $field, $_id_or_email );
161
+		$donor = $this->db->get_donor_by($field, $_id_or_email);
162 162
 
163
-		if ( empty( $donor ) || ! is_object( $donor ) ) {
163
+		if (empty($donor) || ! is_object($donor)) {
164 164
 			return false;
165 165
 		}
166 166
 
167
-		$this->setup_donor( $donor );
167
+		$this->setup_donor($donor);
168 168
 
169 169
 	}
170 170
 
@@ -180,15 +180,15 @@  discard block
 block discarded – undo
180 180
 	 *
181 181
 	 * @return bool             If the setup was successful or not.
182 182
 	 */
183
-	private function setup_donor( $donor ) {
183
+	private function setup_donor($donor) {
184 184
 
185
-		if ( ! is_object( $donor ) ) {
185
+		if ( ! is_object($donor)) {
186 186
 			return false;
187 187
 		}
188 188
 
189
-		foreach ( $donor as $key => $value ) {
189
+		foreach ($donor as $key => $value) {
190 190
 
191
-			switch ( $key ) {
191
+			switch ($key) {
192 192
 
193 193
 				case 'notes':
194 194
 					$this->$key = $this->get_notes();
@@ -202,11 +202,11 @@  discard block
 block discarded – undo
202 202
 		}
203 203
 
204 204
 		// Get donor's all email including primary email.
205
-		$this->emails = (array) $this->get_meta( 'additional_email', false );
206
-		$this->emails = array( 'primary' => $this->email ) + $this->emails;
205
+		$this->emails = (array) $this->get_meta('additional_email', false);
206
+		$this->emails = array('primary' => $this->email) + $this->emails;
207 207
 
208 208
 		// Donor ID and email are the only things that are necessary, make sure they exist.
209
-		if ( ! empty( $this->id ) && ! empty( $this->email ) ) {
209
+		if ( ! empty($this->id) && ! empty($this->email)) {
210 210
 			return true;
211 211
 		}
212 212
 
@@ -223,16 +223,16 @@  discard block
 block discarded – undo
223 223
 	 *
224 224
 	 * @return mixed|\WP_Error
225 225
 	 */
226
-	public function __get( $key ) {
226
+	public function __get($key) {
227 227
 
228
-		if ( method_exists( $this, 'get_' . $key ) ) {
228
+		if (method_exists($this, 'get_'.$key)) {
229 229
 
230
-			return call_user_func( array( $this, 'get_' . $key ) );
230
+			return call_user_func(array($this, 'get_'.$key));
231 231
 
232 232
 		} else {
233 233
 
234 234
 			/* translators: %s: property key */
235
-			return new WP_Error( 'give-donor-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) );
235
+			return new WP_Error('give-donor-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key));
236 236
 
237 237
 		}
238 238
 
@@ -248,9 +248,9 @@  discard block
 block discarded – undo
248 248
 	 *
249 249
 	 * @return bool|int    False if not a valid creation, donor ID if user is found or valid creation.
250 250
 	 */
251
-	public function create( $data = array() ) {
251
+	public function create($data = array()) {
252 252
 
253
-		if ( $this->id != 0 || empty( $data ) ) {
253
+		if ($this->id != 0 || empty($data)) {
254 254
 			return false;
255 255
 		}
256 256
 
@@ -258,15 +258,15 @@  discard block
 block discarded – undo
258 258
 			'payment_ids' => '',
259 259
 		);
260 260
 
261
-		$args = wp_parse_args( $data, $defaults );
262
-		$args = $this->sanitize_columns( $args );
261
+		$args = wp_parse_args($data, $defaults);
262
+		$args = $this->sanitize_columns($args);
263 263
 
264
-		if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) {
264
+		if (empty($args['email']) || ! is_email($args['email'])) {
265 265
 			return false;
266 266
 		}
267 267
 
268
-		if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) {
269
-			$args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) );
268
+		if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) {
269
+			$args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids'])));
270 270
 		}
271 271
 
272 272
 		/**
@@ -276,18 +276,18 @@  discard block
 block discarded – undo
276 276
 		 *
277 277
 		 * @param array $args Donor attributes.
278 278
 		 */
279
-		do_action( 'give_donor_pre_create', $args );
279
+		do_action('give_donor_pre_create', $args);
280 280
 
281 281
 		$created = false;
282 282
 
283 283
 		// The DB class 'add' implies an update if the donor being asked to be created already exists
284
-		if ( $this->db->add( $data ) ) {
284
+		if ($this->db->add($data)) {
285 285
 
286 286
 			// We've successfully added/updated the donor, reset the class vars with the new data
287
-			$donor = $this->db->get_donor_by( 'email', $args['email'] );
287
+			$donor = $this->db->get_donor_by('email', $args['email']);
288 288
 
289 289
 			// Setup the donor data with the values from DB
290
-			$this->setup_donor( $donor );
290
+			$this->setup_donor($donor);
291 291
 
292 292
 			$created = $this->id;
293 293
 		}
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 		 * @param bool|int $created False if not a valid creation, donor ID if user is found or valid creation.
301 301
 		 * @param array $args Customer attributes.
302 302
 		 */
303
-		do_action( 'give_donor_post_create', $created, $args );
303
+		do_action('give_donor_post_create', $created, $args);
304 304
 
305 305
 		return $created;
306 306
 
@@ -316,13 +316,13 @@  discard block
 block discarded – undo
316 316
 	 *
317 317
 	 * @return bool        If the update was successful or not.
318 318
 	 */
319
-	public function update( $data = array() ) {
319
+	public function update($data = array()) {
320 320
 
321
-		if ( empty( $data ) ) {
321
+		if (empty($data)) {
322 322
 			return false;
323 323
 		}
324 324
 
325
-		$data = $this->sanitize_columns( $data );
325
+		$data = $this->sanitize_columns($data);
326 326
 
327 327
 		/**
328 328
 		 * Fires before updating donors.
@@ -332,14 +332,14 @@  discard block
 block discarded – undo
332 332
 		 * @param int $donor_id Donor id.
333 333
 		 * @param array $data Donor attributes.
334 334
 		 */
335
-		do_action( 'give_donor_pre_update', $this->id, $data );
335
+		do_action('give_donor_pre_update', $this->id, $data);
336 336
 
337 337
 		$updated = false;
338 338
 
339
-		if ( $this->db->update( $this->id, $data ) ) {
339
+		if ($this->db->update($this->id, $data)) {
340 340
 
341
-			$donor = $this->db->get_donor_by( 'id', $this->id );
342
-			$this->setup_donor( $donor );
341
+			$donor = $this->db->get_donor_by('id', $this->id);
342
+			$this->setup_donor($donor);
343 343
 
344 344
 			$updated = true;
345 345
 		}
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 		 * @param int $donor_id Donor id.
354 354
 		 * @param array $data Donor attributes.
355 355
 		 */
356
-		do_action( 'give_donor_post_update', $updated, $this->id, $data );
356
+		do_action('give_donor_post_update', $updated, $this->id, $data);
357 357
 
358 358
 		return $updated;
359 359
 	}
@@ -371,27 +371,27 @@  discard block
 block discarded – undo
371 371
 	 *
372 372
 	 * @return bool            If the attachment was successfully.
373 373
 	 */
374
-	public function attach_payment( $payment_id = 0, $update_stats = true ) {
374
+	public function attach_payment($payment_id = 0, $update_stats = true) {
375 375
 
376
-		if ( empty( $payment_id ) ) {
376
+		if (empty($payment_id)) {
377 377
 			return false;
378 378
 		}
379 379
 
380
-		if ( empty( $this->payment_ids ) ) {
380
+		if (empty($this->payment_ids)) {
381 381
 
382 382
 			$new_payment_ids = $payment_id;
383 383
 
384 384
 		} else {
385 385
 
386
-			$payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) );
386
+			$payment_ids = array_map('absint', explode(',', $this->payment_ids));
387 387
 
388
-			if ( in_array( $payment_id, $payment_ids ) ) {
388
+			if (in_array($payment_id, $payment_ids)) {
389 389
 				$update_stats = false;
390 390
 			}
391 391
 
392 392
 			$payment_ids[] = $payment_id;
393 393
 
394
-			$new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
394
+			$new_payment_ids = implode(',', array_unique(array_values($payment_ids)));
395 395
 
396 396
 		}
397 397
 
@@ -403,20 +403,20 @@  discard block
 block discarded – undo
403 403
 		 * @param int $payment_id Payment id.
404 404
 		 * @param int $donor_id Customer id.
405 405
 		 */
406
-		do_action( 'give_donor_pre_attach_payment', $payment_id, $this->id );
406
+		do_action('give_donor_pre_attach_payment', $payment_id, $this->id);
407 407
 
408
-		$payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) );
408
+		$payment_added = $this->update(array('payment_ids' => $new_payment_ids));
409 409
 
410
-		if ( $payment_added ) {
410
+		if ($payment_added) {
411 411
 
412 412
 			$this->payment_ids = $new_payment_ids;
413 413
 
414 414
 			// We added this payment successfully, increment the stats
415
-			if ( $update_stats ) {
416
-				$payment_amount = give_get_payment_amount( $payment_id );
415
+			if ($update_stats) {
416
+				$payment_amount = give_get_payment_amount($payment_id);
417 417
 
418
-				if ( ! empty( $payment_amount ) ) {
419
-					$this->increase_value( $payment_amount );
418
+				if ( ! empty($payment_amount)) {
419
+					$this->increase_value($payment_amount);
420 420
 				}
421 421
 
422 422
 				$this->increase_purchase_count();
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 		 * @param int $payment_id Payment id.
433 433
 		 * @param int $donor_id Donor id.
434 434
 		 */
435
-		do_action( 'give_donor_post_attach_payment', $payment_added, $payment_id, $this->id );
435
+		do_action('give_donor_post_attach_payment', $payment_added, $payment_id, $this->id);
436 436
 
437 437
 		return $payment_added;
438 438
 	}
@@ -450,33 +450,33 @@  discard block
 block discarded – undo
450 450
 	 *
451 451
 	 * @return boolean               If the removal was successful.
452 452
 	 */
453
-	public function remove_payment( $payment_id = 0, $update_stats = true ) {
453
+	public function remove_payment($payment_id = 0, $update_stats = true) {
454 454
 
455
-		if ( empty( $payment_id ) ) {
455
+		if (empty($payment_id)) {
456 456
 			return false;
457 457
 		}
458 458
 
459
-		$payment = new Give_Payment( $payment_id );
459
+		$payment = new Give_Payment($payment_id);
460 460
 
461
-		if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) {
461
+		if ('publish' !== $payment->status && 'revoked' !== $payment->status) {
462 462
 			$update_stats = false;
463 463
 		}
464 464
 
465 465
 		$new_payment_ids = '';
466 466
 
467
-		if ( ! empty( $this->payment_ids ) ) {
467
+		if ( ! empty($this->payment_ids)) {
468 468
 
469
-			$payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) );
469
+			$payment_ids = array_map('absint', explode(',', $this->payment_ids));
470 470
 
471
-			$pos = array_search( $payment_id, $payment_ids );
472
-			if ( false === $pos ) {
471
+			$pos = array_search($payment_id, $payment_ids);
472
+			if (false === $pos) {
473 473
 				return false;
474 474
 			}
475 475
 
476
-			unset( $payment_ids[ $pos ] );
477
-			$payment_ids = array_filter( $payment_ids );
476
+			unset($payment_ids[$pos]);
477
+			$payment_ids = array_filter($payment_ids);
478 478
 
479
-			$new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
479
+			$new_payment_ids = implode(',', array_unique(array_values($payment_ids)));
480 480
 
481 481
 		}
482 482
 
@@ -488,20 +488,20 @@  discard block
 block discarded – undo
488 488
 		 * @param int $payment_id Payment id.
489 489
 		 * @param int $donor_id Customer id.
490 490
 		 */
491
-		do_action( 'give_donor_pre_remove_payment', $payment_id, $this->id );
491
+		do_action('give_donor_pre_remove_payment', $payment_id, $this->id);
492 492
 
493
-		$payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) );
493
+		$payment_removed = $this->update(array('payment_ids' => $new_payment_ids));
494 494
 
495
-		if ( $payment_removed ) {
495
+		if ($payment_removed) {
496 496
 
497 497
 			$this->payment_ids = $new_payment_ids;
498 498
 
499
-			if ( $update_stats ) {
499
+			if ($update_stats) {
500 500
 				// We removed this payment successfully, decrement the stats
501
-				$payment_amount = give_get_payment_amount( $payment_id );
501
+				$payment_amount = give_get_payment_amount($payment_id);
502 502
 
503
-				if ( ! empty( $payment_amount ) ) {
504
-					$this->decrease_value( $payment_amount );
503
+				if ( ! empty($payment_amount)) {
504
+					$this->decrease_value($payment_amount);
505 505
 				}
506 506
 
507 507
 				$this->decrease_donation_count();
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 		 * @param int $payment_id Payment id.
518 518
 		 * @param int $donor_id Donor id.
519 519
 		 */
520
-		do_action( 'give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id );
520
+		do_action('give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id);
521 521
 
522 522
 		return $payment_removed;
523 523
 
@@ -533,10 +533,10 @@  discard block
 block discarded – undo
533 533
 	 *
534 534
 	 * @return int        The donation count.
535 535
 	 */
536
-	public function increase_purchase_count( $count = 1 ) {
536
+	public function increase_purchase_count($count = 1) {
537 537
 
538 538
 		// Make sure it's numeric and not negative.
539
-		if ( ! is_numeric( $count ) || $count != absint( $count ) ) {
539
+		if ( ! is_numeric($count) || $count != absint($count)) {
540 540
 			return false;
541 541
 		}
542 542
 
@@ -550,9 +550,9 @@  discard block
 block discarded – undo
550 550
 		 * @param int $count The number to increase by.
551 551
 		 * @param int $donor_id Donor id.
552 552
 		 */
553
-		do_action( 'give_donor_pre_increase_donation_count', $count, $this->id );
553
+		do_action('give_donor_pre_increase_donation_count', $count, $this->id);
554 554
 
555
-		if ( $this->update( array( 'purchase_count' => $new_total ) ) ) {
555
+		if ($this->update(array('purchase_count' => $new_total))) {
556 556
 			$this->purchase_count = $new_total;
557 557
 		}
558 558
 
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
 		 * @param int $count The number increased by.
566 566
 		 * @param int $donor_id Donor id.
567 567
 		 */
568
-		do_action( 'give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id );
568
+		do_action('give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id);
569 569
 
570 570
 		return $this->purchase_count;
571 571
 	}
@@ -580,16 +580,16 @@  discard block
 block discarded – undo
580 580
 	 *
581 581
 	 * @return mixed      If successful, the new count, otherwise false.
582 582
 	 */
583
-	public function decrease_donation_count( $count = 1 ) {
583
+	public function decrease_donation_count($count = 1) {
584 584
 
585 585
 		// Make sure it's numeric and not negative
586
-		if ( ! is_numeric( $count ) || $count != absint( $count ) ) {
586
+		if ( ! is_numeric($count) || $count != absint($count)) {
587 587
 			return false;
588 588
 		}
589 589
 
590 590
 		$new_total = (int) $this->purchase_count - (int) $count;
591 591
 
592
-		if ( $new_total < 0 ) {
592
+		if ($new_total < 0) {
593 593
 			$new_total = 0;
594 594
 		}
595 595
 
@@ -601,9 +601,9 @@  discard block
 block discarded – undo
601 601
 		 * @param int $count The number to decrease by.
602 602
 		 * @param int $donor_id Customer id.
603 603
 		 */
604
-		do_action( 'give_donor_pre_decrease_donation_count', $count, $this->id );
604
+		do_action('give_donor_pre_decrease_donation_count', $count, $this->id);
605 605
 
606
-		if ( $this->update( array( 'purchase_count' => $new_total ) ) ) {
606
+		if ($this->update(array('purchase_count' => $new_total))) {
607 607
 			$this->purchase_count = $new_total;
608 608
 		}
609 609
 
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
 		 * @param int $count The number decreased by.
617 617
 		 * @param int $donor_id Donor id.
618 618
 		 */
619
-		do_action( 'give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id );
619
+		do_action('give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id);
620 620
 
621 621
 		return $this->purchase_count;
622 622
 	}
@@ -631,9 +631,9 @@  discard block
 block discarded – undo
631 631
 	 *
632 632
 	 * @return mixed        If successful, the new value, otherwise false.
633 633
 	 */
634
-	public function increase_value( $value = 0.00 ) {
634
+	public function increase_value($value = 0.00) {
635 635
 
636
-		$new_value = floatval( $this->purchase_value ) + $value;
636
+		$new_value = floatval($this->purchase_value) + $value;
637 637
 
638 638
 		/**
639 639
 		 * Fires before increasing donor lifetime value.
@@ -643,9 +643,9 @@  discard block
 block discarded – undo
643 643
 		 * @param float $value The value to increase by.
644 644
 		 * @param int $donor_id Customer id.
645 645
 		 */
646
-		do_action( 'give_donor_pre_increase_value', $value, $this->id );
646
+		do_action('give_donor_pre_increase_value', $value, $this->id);
647 647
 
648
-		if ( $this->update( array( 'purchase_value' => $new_value ) ) ) {
648
+		if ($this->update(array('purchase_value' => $new_value))) {
649 649
 			$this->purchase_value = $new_value;
650 650
 		}
651 651
 
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
 		 * @param float $value The value increased by.
659 659
 		 * @param int $donor_id Donor id.
660 660
 		 */
661
-		do_action( 'give_donor_post_increase_value', $this->purchase_value, $value, $this->id );
661
+		do_action('give_donor_post_increase_value', $this->purchase_value, $value, $this->id);
662 662
 
663 663
 		return $this->purchase_value;
664 664
 	}
@@ -673,11 +673,11 @@  discard block
 block discarded – undo
673 673
 	 *
674 674
 	 * @return mixed        If successful, the new value, otherwise false.
675 675
 	 */
676
-	public function decrease_value( $value = 0.00 ) {
676
+	public function decrease_value($value = 0.00) {
677 677
 
678
-		$new_value = floatval( $this->purchase_value ) - $value;
678
+		$new_value = floatval($this->purchase_value) - $value;
679 679
 
680
-		if ( $new_value < 0 ) {
680
+		if ($new_value < 0) {
681 681
 			$new_value = 0.00;
682 682
 		}
683 683
 
@@ -689,9 +689,9 @@  discard block
 block discarded – undo
689 689
 		 * @param float $value The value to decrease by.
690 690
 		 * @param int $donor_id Donor id.
691 691
 		 */
692
-		do_action( 'give_donor_pre_decrease_value', $value, $this->id );
692
+		do_action('give_donor_pre_decrease_value', $value, $this->id);
693 693
 
694
-		if ( $this->update( array( 'purchase_value' => $new_value ) ) ) {
694
+		if ($this->update(array('purchase_value' => $new_value))) {
695 695
 			$this->purchase_value = $new_value;
696 696
 		}
697 697
 
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 		 * @param float $value The value decreased by.
705 705
 		 * @param int $donor_id Donor id.
706 706
 		 */
707
-		do_action( 'give_donor_post_decrease_value', $this->purchase_value, $value, $this->id );
707
+		do_action('give_donor_post_decrease_value', $this->purchase_value, $value, $this->id);
708 708
 
709 709
 		return $this->purchase_value;
710 710
 	}
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 	 *
724 724
 	 * @return mixed              If successful, the new donation stat value, otherwise false.
725 725
 	 */
726
-	public function update_donation_value( $curr_amount, $new_amount ) {
726
+	public function update_donation_value($curr_amount, $new_amount) {
727 727
 		/**
728 728
 		 * Payment total difference value can be:
729 729
 		 *  zero   (in case amount not change)
@@ -733,15 +733,15 @@  discard block
 block discarded – undo
733 733
 		$payment_total_diff = $new_amount - $curr_amount;
734 734
 
735 735
 		// We do not need to update donation stat if donation did not change.
736
-		if ( ! $payment_total_diff ) {
736
+		if ( ! $payment_total_diff) {
737 737
 			return false;
738 738
 		}
739 739
 
740
-		if ( $payment_total_diff > 0 ) {
741
-			$this->increase_value( $payment_total_diff );
740
+		if ($payment_total_diff > 0) {
741
+			$this->increase_value($payment_total_diff);
742 742
 		} else {
743 743
 			// Pass payment total difference as +ve value to decrease amount from user lifetime stat.
744
-			$this->decrease_value( - $payment_total_diff );
744
+			$this->decrease_value( -$payment_total_diff );
745 745
 		}
746 746
 
747 747
 		return $this->purchase_value;
@@ -758,15 +758,15 @@  discard block
 block discarded – undo
758 758
 	 *
759 759
 	 * @return array       The notes requested.
760 760
 	 */
761
-	public function get_notes( $length = 20, $paged = 1 ) {
761
+	public function get_notes($length = 20, $paged = 1) {
762 762
 
763
-		$length = is_numeric( $length ) ? $length : 20;
764
-		$offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0;
763
+		$length = is_numeric($length) ? $length : 20;
764
+		$offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0;
765 765
 
766 766
 		$all_notes   = $this->get_raw_notes();
767
-		$notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) );
767
+		$notes_array = array_reverse(array_filter(explode("\n\n", $all_notes)));
768 768
 
769
-		$desired_notes = array_slice( $notes_array, $offset, $length );
769
+		$desired_notes = array_slice($notes_array, $offset, $length);
770 770
 
771 771
 		return $desired_notes;
772 772
 
@@ -783,9 +783,9 @@  discard block
 block discarded – undo
783 783
 	public function get_notes_count() {
784 784
 
785 785
 		$all_notes   = $this->get_raw_notes();
786
-		$notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) );
786
+		$notes_array = array_reverse(array_filter(explode("\n\n", $all_notes)));
787 787
 
788
-		return count( $notes_array );
788
+		return count($notes_array);
789 789
 
790 790
 	}
791 791
 
@@ -799,22 +799,22 @@  discard block
 block discarded – undo
799 799
 	 *
800 800
 	 * @return string|boolean The new note if added successfully, false otherwise.
801 801
 	 */
802
-	public function add_note( $note = '' ) {
802
+	public function add_note($note = '') {
803 803
 
804
-		$note = trim( $note );
805
-		if ( empty( $note ) ) {
804
+		$note = trim($note);
805
+		if (empty($note)) {
806 806
 			return false;
807 807
 		}
808 808
 
809 809
 		$notes = $this->get_raw_notes();
810 810
 
811
-		if ( empty( $notes ) ) {
811
+		if (empty($notes)) {
812 812
 			$notes = '';
813 813
 		}
814 814
 
815
-		$note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note;
816
-		$new_note    = apply_filters( 'give_customer_add_note_string', $note_string );
817
-		$notes       .= "\n\n" . $new_note;
815
+		$note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note;
816
+		$new_note    = apply_filters('give_customer_add_note_string', $note_string);
817
+		$notes .= "\n\n".$new_note;
818 818
 
819 819
 		/**
820 820
 		 * Fires before donor note is added.
@@ -824,11 +824,11 @@  discard block
 block discarded – undo
824 824
 		 * @param string $new_note New note to add.
825 825
 		 * @param int $donor_id Donor id.
826 826
 		 */
827
-		do_action( 'give_donor_pre_add_note', $new_note, $this->id );
827
+		do_action('give_donor_pre_add_note', $new_note, $this->id);
828 828
 
829
-		$updated = $this->update( array( 'notes' => $notes ) );
829
+		$updated = $this->update(array('notes' => $notes));
830 830
 
831
-		if ( $updated ) {
831
+		if ($updated) {
832 832
 			$this->notes = $this->get_notes();
833 833
 		}
834 834
 
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
 		 * @param string $new_note New note added.
842 842
 		 * @param int $donor_id Donor id.
843 843
 		 */
844
-		do_action( 'give_donor_post_add_note', $this->notes, $new_note, $this->id );
844
+		do_action('give_donor_post_add_note', $this->notes, $new_note, $this->id);
845 845
 
846 846
 		// Return the formatted note, so we can test, as well as update any displays
847 847
 		return $new_note;
@@ -858,7 +858,7 @@  discard block
 block discarded – undo
858 858
 	 */
859 859
 	private function get_raw_notes() {
860 860
 
861
-		$all_notes = $this->db->get_column( 'notes', $this->id );
861
+		$all_notes = $this->db->get_column('notes', $this->id);
862 862
 
863 863
 		return $all_notes;
864 864
 
@@ -875,8 +875,8 @@  discard block
 block discarded – undo
875 875
 	 *
876 876
 	 * @return mixed            Will be an array if $single is false. Will be value of meta data field if $single is true.
877 877
 	 */
878
-	public function get_meta( $meta_key = '', $single = true ) {
879
-		return Give()->donor_meta->get_meta( $this->id, $meta_key, $single );
878
+	public function get_meta($meta_key = '', $single = true) {
879
+		return Give()->donor_meta->get_meta($this->id, $meta_key, $single);
880 880
 	}
881 881
 
882 882
 	/**
@@ -891,8 +891,8 @@  discard block
 block discarded – undo
891 891
 	 *
892 892
 	 * @return bool               False for failure. True for success.
893 893
 	 */
894
-	public function add_meta( $meta_key = '', $meta_value, $unique = false ) {
895
-		return Give()->donor_meta->add_meta( $this->id, $meta_key, $meta_value, $unique );
894
+	public function add_meta($meta_key = '', $meta_value, $unique = false) {
895
+		return Give()->donor_meta->add_meta($this->id, $meta_key, $meta_value, $unique);
896 896
 	}
897 897
 
898 898
 	/**
@@ -907,8 +907,8 @@  discard block
 block discarded – undo
907 907
 	 *
908 908
 	 * @return bool               False on failure, true if success.
909 909
 	 */
910
-	public function update_meta( $meta_key = '', $meta_value, $prev_value = '' ) {
911
-		return Give()->donor_meta->update_meta( $this->id, $meta_key, $meta_value, $prev_value );
910
+	public function update_meta($meta_key = '', $meta_value, $prev_value = '') {
911
+		return Give()->donor_meta->update_meta($this->id, $meta_key, $meta_value, $prev_value);
912 912
 	}
913 913
 
914 914
 	/**
@@ -922,8 +922,8 @@  discard block
 block discarded – undo
922 922
 	 *
923 923
 	 * @return bool               False for failure. True for success.
924 924
 	 */
925
-	public function delete_meta( $meta_key = '', $meta_value = '' ) {
926
-		return Give()->donor_meta->delete_meta( $this->id, $meta_key, $meta_value );
925
+	public function delete_meta($meta_key = '', $meta_value = '') {
926
+		return Give()->donor_meta->delete_meta($this->id, $meta_key, $meta_value);
927 927
 	}
928 928
 
929 929
 	/**
@@ -936,51 +936,51 @@  discard block
 block discarded – undo
936 936
 	 *
937 937
 	 * @return array       The sanitized data, based off column defaults.
938 938
 	 */
939
-	private function sanitize_columns( $data ) {
939
+	private function sanitize_columns($data) {
940 940
 
941 941
 		$columns        = $this->db->get_columns();
942 942
 		$default_values = $this->db->get_column_defaults();
943 943
 
944
-		foreach ( $columns as $key => $type ) {
944
+		foreach ($columns as $key => $type) {
945 945
 
946 946
 			// Only sanitize data that we were provided
947
-			if ( ! array_key_exists( $key, $data ) ) {
947
+			if ( ! array_key_exists($key, $data)) {
948 948
 				continue;
949 949
 			}
950 950
 
951
-			switch ( $type ) {
951
+			switch ($type) {
952 952
 
953 953
 				case '%s':
954
-					if ( 'email' == $key ) {
955
-						$data[ $key ] = sanitize_email( $data[ $key ] );
956
-					} elseif ( 'notes' == $key ) {
957
-						$data[ $key ] = strip_tags( $data[ $key ] );
954
+					if ('email' == $key) {
955
+						$data[$key] = sanitize_email($data[$key]);
956
+					} elseif ('notes' == $key) {
957
+						$data[$key] = strip_tags($data[$key]);
958 958
 					} else {
959
-						$data[ $key ] = sanitize_text_field( $data[ $key ] );
959
+						$data[$key] = sanitize_text_field($data[$key]);
960 960
 					}
961 961
 					break;
962 962
 
963 963
 				case '%d':
964
-					if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) {
965
-						$data[ $key ] = $default_values[ $key ];
964
+					if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) {
965
+						$data[$key] = $default_values[$key];
966 966
 					} else {
967
-						$data[ $key ] = absint( $data[ $key ] );
967
+						$data[$key] = absint($data[$key]);
968 968
 					}
969 969
 					break;
970 970
 
971 971
 				case '%f':
972 972
 					// Convert what was given to a float
973
-					$value = floatval( $data[ $key ] );
973
+					$value = floatval($data[$key]);
974 974
 
975
-					if ( ! is_float( $value ) ) {
976
-						$data[ $key ] = $default_values[ $key ];
975
+					if ( ! is_float($value)) {
976
+						$data[$key] = $default_values[$key];
977 977
 					} else {
978
-						$data[ $key ] = $value;
978
+						$data[$key] = $value;
979 979
 					}
980 980
 					break;
981 981
 
982 982
 				default:
983
-					$data[ $key ] = sanitize_text_field( $data[ $key ] );
983
+					$data[$key] = sanitize_text_field($data[$key]);
984 984
 					break;
985 985
 
986 986
 			}
@@ -1000,33 +1000,33 @@  discard block
 block discarded – undo
1000 1000
 	 *
1001 1001
 	 * @return bool            If the email was added successfully
1002 1002
 	 */
1003
-	public function add_email( $email = '', $primary = false ) {
1004
-		if ( ! is_email( $email ) ) {
1003
+	public function add_email($email = '', $primary = false) {
1004
+		if ( ! is_email($email)) {
1005 1005
 			return false;
1006 1006
 		}
1007
-		$existing = new Give_Donor( $email );
1007
+		$existing = new Give_Donor($email);
1008 1008
 
1009
-		if ( $existing->id > 0 ) {
1009
+		if ($existing->id > 0) {
1010 1010
 			// Email address already belongs to another donor
1011 1011
 			return false;
1012 1012
 		}
1013 1013
 
1014
-		if ( email_exists( $email ) ) {
1015
-			$user = get_user_by( 'email', $email );
1016
-			if ( $user->ID != $this->user_id ) {
1014
+		if (email_exists($email)) {
1015
+			$user = get_user_by('email', $email);
1016
+			if ($user->ID != $this->user_id) {
1017 1017
 				return false;
1018 1018
 			}
1019 1019
 		}
1020 1020
 
1021
-		do_action( 'give_donor_pre_add_email', $email, $this->id, $this );
1021
+		do_action('give_donor_pre_add_email', $email, $this->id, $this);
1022 1022
 
1023 1023
 		// Add is used to ensure duplicate emails are not added
1024
-		$ret = (bool) $this->add_meta( 'additional_email', $email );
1024
+		$ret = (bool) $this->add_meta('additional_email', $email);
1025 1025
 
1026
-		do_action( 'give_donor_post_add_email', $email, $this->id, $this );
1026
+		do_action('give_donor_post_add_email', $email, $this->id, $this);
1027 1027
 
1028
-		if ( $ret && true === $primary ) {
1029
-			$this->set_primary_email( $email );
1028
+		if ($ret && true === $primary) {
1029
+			$this->set_primary_email($email);
1030 1030
 		}
1031 1031
 
1032 1032
 		return $ret;
@@ -1042,16 +1042,16 @@  discard block
 block discarded – undo
1042 1042
 	 *
1043 1043
 	 * @return bool          If the email was removed successfully.
1044 1044
 	 */
1045
-	public function remove_email( $email = '' ) {
1046
-		if ( ! is_email( $email ) ) {
1045
+	public function remove_email($email = '') {
1046
+		if ( ! is_email($email)) {
1047 1047
 			return false;
1048 1048
 		}
1049 1049
 
1050
-		do_action( 'give_donor_pre_remove_email', $email, $this->id, $this );
1050
+		do_action('give_donor_pre_remove_email', $email, $this->id, $this);
1051 1051
 
1052
-		$ret = (bool) $this->delete_meta( 'additional_email', $email );
1052
+		$ret = (bool) $this->delete_meta('additional_email', $email);
1053 1053
 
1054
-		do_action( 'give_donor_post_remove_email', $email, $this->id, $this );
1054
+		do_action('give_donor_post_remove_email', $email, $this->id, $this);
1055 1055
 
1056 1056
 		return $ret;
1057 1057
 	}
@@ -1068,16 +1068,16 @@  discard block
 block discarded – undo
1068 1068
 	 *
1069 1069
 	 * @return bool                      If the email was set as primary successfully.
1070 1070
 	 */
1071
-	public function set_primary_email( $new_primary_email = '' ) {
1072
-		if ( ! is_email( $new_primary_email ) ) {
1071
+	public function set_primary_email($new_primary_email = '') {
1072
+		if ( ! is_email($new_primary_email)) {
1073 1073
 			return false;
1074 1074
 		}
1075 1075
 
1076
-		do_action( 'give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this );
1076
+		do_action('give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this);
1077 1077
 
1078
-		$existing = new Give_Donor( $new_primary_email );
1078
+		$existing = new Give_Donor($new_primary_email);
1079 1079
 
1080
-		if ( $existing->id > 0 && (int) $existing->id !== (int) $this->id ) {
1080
+		if ($existing->id > 0 && (int) $existing->id !== (int) $this->id) {
1081 1081
 			// This email belongs to another donor.
1082 1082
 			return false;
1083 1083
 		}
@@ -1085,21 +1085,21 @@  discard block
 block discarded – undo
1085 1085
 		$old_email = $this->email;
1086 1086
 
1087 1087
 		// Update donor record with new email.
1088
-		$update = $this->update( array( 'email' => $new_primary_email ) );
1088
+		$update = $this->update(array('email' => $new_primary_email));
1089 1089
 
1090 1090
 		// Remove new primary from list of additional emails.
1091
-		$remove = $this->remove_email( $new_primary_email );
1091
+		$remove = $this->remove_email($new_primary_email);
1092 1092
 
1093 1093
 		// Add old email to additional emails list.
1094
-		$add = $this->add_email( $old_email );
1094
+		$add = $this->add_email($old_email);
1095 1095
 
1096 1096
 		$ret = $update && $remove && $add;
1097 1097
 
1098
-		if ( $ret ) {
1098
+		if ($ret) {
1099 1099
 			$this->email = $new_primary_email;
1100 1100
 		}
1101 1101
 
1102
-		do_action( 'give_donor_post_set_primary_email', $new_primary_email, $this->id, $this );
1102
+		do_action('give_donor_post_set_primary_email', $new_primary_email, $this->id, $this);
1103 1103
 
1104 1104
 		return $ret;
1105 1105
 	}
Please login to merge, or discard this patch.
includes/ajax-functions.php 1 patch
Spacing   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly.
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -26,26 +26,26 @@  discard block
 block discarded – undo
26 26
 function give_test_ajax_works() {
27 27
 
28 28
 	// Check if the Airplane Mode plugin is installed.
29
-	if ( class_exists( 'Airplane_Mode_Core' ) ) {
29
+	if (class_exists('Airplane_Mode_Core')) {
30 30
 
31 31
 		$airplane = Airplane_Mode_Core::getInstance();
32 32
 
33
-		if ( method_exists( $airplane, 'enabled' ) ) {
33
+		if (method_exists($airplane, 'enabled')) {
34 34
 
35
-			if ( $airplane->enabled() ) {
35
+			if ($airplane->enabled()) {
36 36
 				return true;
37 37
 			}
38 38
 		} else {
39 39
 
40
-			if ( 'on' === $airplane->check_status()  ) {
40
+			if ('on' === $airplane->check_status()) {
41 41
 				return true;
42 42
 			}
43 43
 		}
44 44
 	}
45 45
 
46
-	add_filter( 'block_local_requests', '__return_false' );
46
+	add_filter('block_local_requests', '__return_false');
47 47
 
48
-	if ( Give_Cache::get( '_give_ajax_works', true ) ) {
48
+	if (Give_Cache::get('_give_ajax_works', true)) {
49 49
 		return true;
50 50
 	}
51 51
 
@@ -57,35 +57,35 @@  discard block
 block discarded – undo
57 57
 		),
58 58
 	);
59 59
 
60
-	$ajax = wp_remote_post( give_get_ajax_url(), $params );
60
+	$ajax = wp_remote_post(give_get_ajax_url(), $params);
61 61
 
62 62
 	$works = true;
63 63
 
64
-	if ( is_wp_error( $ajax ) ) {
64
+	if (is_wp_error($ajax)) {
65 65
 
66 66
 		$works = false;
67 67
 
68 68
 	} else {
69 69
 
70
-		if ( empty( $ajax['response'] ) ) {
70
+		if (empty($ajax['response'])) {
71 71
 			$works = false;
72 72
 		}
73 73
 
74
-		if ( empty( $ajax['response']['code'] ) || 200 !== (int) $ajax['response']['code'] ) {
74
+		if (empty($ajax['response']['code']) || 200 !== (int) $ajax['response']['code']) {
75 75
 			$works = false;
76 76
 		}
77 77
 
78
-		if ( empty( $ajax['response']['message'] ) || 'OK' !== $ajax['response']['message'] ) {
78
+		if (empty($ajax['response']['message']) || 'OK' !== $ajax['response']['message']) {
79 79
 			$works = false;
80 80
 		}
81 81
 
82
-		if ( ! isset( $ajax['body'] ) || 0 !== (int) $ajax['body'] ) {
82
+		if ( ! isset($ajax['body']) || 0 !== (int) $ajax['body']) {
83 83
 			$works = false;
84 84
 		}
85 85
 	}
86 86
 
87
-	if ( $works ) {
88
-		Give_Cache::set( '_give_ajax_works', '1', DAY_IN_SECONDS, true );
87
+	if ($works) {
88
+		Give_Cache::set('_give_ajax_works', '1', DAY_IN_SECONDS, true);
89 89
 	}
90 90
 
91 91
 	return $works;
@@ -100,16 +100,16 @@  discard block
 block discarded – undo
100 100
  * @return string
101 101
  */
102 102
 function give_get_ajax_url() {
103
-	$scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
103
+	$scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin';
104 104
 
105 105
 	$current_url = give_get_current_page_url();
106
-	$ajax_url    = admin_url( 'admin-ajax.php', $scheme );
106
+	$ajax_url    = admin_url('admin-ajax.php', $scheme);
107 107
 
108
-	if ( preg_match( '/^https/', $current_url ) && ! preg_match( '/^https/', $ajax_url ) ) {
109
-		$ajax_url = preg_replace( '/^http/', 'https', $ajax_url );
108
+	if (preg_match('/^https/', $current_url) && ! preg_match('/^https/', $ajax_url)) {
109
+		$ajax_url = preg_replace('/^http/', 'https', $ajax_url);
110 110
 	}
111 111
 
112
-	return apply_filters( 'give_ajax_url', $ajax_url );
112
+	return apply_filters('give_ajax_url', $ajax_url);
113 113
 }
114 114
 
115 115
 /**
@@ -125,12 +125,12 @@  discard block
 block discarded – undo
125 125
 	 *
126 126
 	 * @since 1.7
127 127
 	 */
128
-	do_action( 'give_donation_form_login_fields' );
128
+	do_action('give_donation_form_login_fields');
129 129
 
130 130
 	give_die();
131 131
 }
132 132
 
133
-add_action( 'wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields' );
133
+add_action('wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields');
134 134
 
135 135
 /**
136 136
  * Load Checkout Fields
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
  * @return void
141 141
  */
142 142
 function give_load_checkout_fields() {
143
-	$form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : '';
143
+	$form_id = isset($_POST['form_id']) ? $_POST['form_id'] : '';
144 144
 
145 145
 	ob_start();
146 146
 
@@ -149,18 +149,18 @@  discard block
 block discarded – undo
149 149
 	 *
150 150
 	 * @since 1.7
151 151
 	 */
152
-	do_action( 'give_donation_form_register_login_fields', $form_id );
152
+	do_action('give_donation_form_register_login_fields', $form_id);
153 153
 
154 154
 	$fields = ob_get_clean();
155 155
 
156
-	wp_send_json( array(
157
-		'fields' => wp_json_encode( $fields ),
158
-		'submit' => wp_json_encode( give_get_donation_form_submit_button( $form_id ) ),
159
-	) );
156
+	wp_send_json(array(
157
+		'fields' => wp_json_encode($fields),
158
+		'submit' => wp_json_encode(give_get_donation_form_submit_button($form_id)),
159
+	));
160 160
 }
161 161
 
162
-add_action( 'wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields' );
163
-add_action( 'wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields' );
162
+add_action('wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields');
163
+add_action('wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields');
164 164
 
165 165
 /**
166 166
  * Get Form Title via AJAX (used only in WordPress Admin)
@@ -170,9 +170,9 @@  discard block
 block discarded – undo
170 170
  * @return void
171 171
  */
172 172
 function give_ajax_get_form_title() {
173
-	if ( isset( $_POST['form_id'] ) ) {
174
-		$title = get_the_title( $_POST['form_id'] );
175
-		if ( $title ) {
173
+	if (isset($_POST['form_id'])) {
174
+		$title = get_the_title($_POST['form_id']);
175
+		if ($title) {
176 176
 			echo $title;
177 177
 		} else {
178 178
 			echo 'fail';
@@ -181,8 +181,8 @@  discard block
 block discarded – undo
181 181
 	give_die();
182 182
 }
183 183
 
184
-add_action( 'wp_ajax_give_get_form_title', 'give_ajax_get_form_title' );
185
-add_action( 'wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title' );
184
+add_action('wp_ajax_give_get_form_title', 'give_ajax_get_form_title');
185
+add_action('wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title');
186 186
 
187 187
 /**
188 188
  * Retrieve a states drop down
@@ -193,23 +193,23 @@  discard block
 block discarded – undo
193 193
  */
194 194
 function give_ajax_get_states_field() {
195 195
 
196
-	if ( empty( $_POST['country'] ) ) {
196
+	if (empty($_POST['country'])) {
197 197
 		$_POST['country'] = give_get_country();
198 198
 	}
199
-	$states = give_get_states( $_POST['country'] );
199
+	$states = give_get_states($_POST['country']);
200 200
 
201
-	if ( ! empty( $states ) ) {
201
+	if ( ! empty($states)) {
202 202
 
203 203
 		$args = array(
204 204
 			'name'             => $_POST['field_name'],
205 205
 			'id'               => $_POST['field_name'],
206
-			'class'            => $_POST['field_name'] . '  give-select',
207
-			'options'          => give_get_states( $_POST['country'] ),
206
+			'class'            => $_POST['field_name'].'  give-select',
207
+			'options'          => give_get_states($_POST['country']),
208 208
 			'show_option_all'  => false,
209 209
 			'show_option_none' => false,
210 210
 		);
211 211
 
212
-		$response = Give()->html->select( $args );
212
+		$response = Give()->html->select($args);
213 213
 
214 214
 	} else {
215 215
 
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 	give_die();
222 222
 }
223 223
 
224
-add_action( 'wp_ajax_give_get_states', 'give_ajax_get_states_field' );
225
-add_action( 'wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field' );
224
+add_action('wp_ajax_give_get_states', 'give_ajax_get_states_field');
225
+add_action('wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field');
226 226
 
227 227
 /**
228 228
  * Retrieve donation forms via AJAX for chosen dropdown search field.
@@ -234,19 +234,19 @@  discard block
 block discarded – undo
234 234
 function give_ajax_form_search() {
235 235
 	global $wpdb;
236 236
 
237
-	$search   = esc_sql( sanitize_text_field( $_GET['s'] ) );
238
-	$excludes = ( isset( $_GET['current_id'] ) ? (array) $_GET['current_id'] : array() );
237
+	$search   = esc_sql(sanitize_text_field($_GET['s']));
238
+	$excludes = (isset($_GET['current_id']) ? (array) $_GET['current_id'] : array());
239 239
 
240 240
 	$results = array();
241
-	if ( current_user_can( 'edit_give_forms' ) ) {
242
-		$items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50" );
241
+	if (current_user_can('edit_give_forms')) {
242
+		$items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50");
243 243
 	} else {
244
-		$items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50" );
244
+		$items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50");
245 245
 	}
246 246
 
247
-	if ( $items ) {
247
+	if ($items) {
248 248
 
249
-		foreach ( $items as $item ) {
249
+		foreach ($items as $item) {
250 250
 
251 251
 			$results[] = array(
252 252
 				'id'   => $item->ID,
@@ -257,18 +257,18 @@  discard block
 block discarded – undo
257 257
 
258 258
 		$items[] = array(
259 259
 			'id'   => 0,
260
-			'name' => __( 'No forms found.', 'give' ),
260
+			'name' => __('No forms found.', 'give'),
261 261
 		);
262 262
 
263 263
 	}
264 264
 
265
-	echo json_encode( $results );
265
+	echo json_encode($results);
266 266
 
267 267
 	give_die();
268 268
 }
269 269
 
270
-add_action( 'wp_ajax_give_form_search', 'give_ajax_form_search' );
271
-add_action( 'wp_ajax_nopriv_give_form_search', 'give_ajax_form_search' );
270
+add_action('wp_ajax_give_form_search', 'give_ajax_form_search');
271
+add_action('wp_ajax_nopriv_give_form_search', 'give_ajax_form_search');
272 272
 
273 273
 /**
274 274
  * Search the donors database via Ajax
@@ -280,38 +280,38 @@  discard block
 block discarded – undo
280 280
 function give_ajax_donor_search() {
281 281
 	global $wpdb;
282 282
 
283
-	$search  = esc_sql( sanitize_text_field( $_GET['s'] ) );
283
+	$search  = esc_sql(sanitize_text_field($_GET['s']));
284 284
 	$results = array();
285
-	if ( ! current_user_can( 'view_give_reports' ) ) {
285
+	if ( ! current_user_can('view_give_reports')) {
286 286
 		$donors = array();
287 287
 	} else {
288
-		$donors = $wpdb->get_results( "SELECT id,name,email FROM {$wpdb->prefix}give_customers WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50" );
288
+		$donors = $wpdb->get_results("SELECT id,name,email FROM {$wpdb->prefix}give_customers WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50");
289 289
 	}
290 290
 
291
-	if ( $donors ) {
291
+	if ($donors) {
292 292
 
293
-		foreach ( $donors as $donor ) {
293
+		foreach ($donors as $donor) {
294 294
 
295 295
 			$results[] = array(
296 296
 				'id'   => $donor->id,
297
-				'name' => $donor->name . ' (' . $donor->email . ')',
297
+				'name' => $donor->name.' ('.$donor->email.')',
298 298
 			);
299 299
 		}
300 300
 	} else {
301 301
 
302 302
 		$donors[] = array(
303 303
 			'id'   => 0,
304
-			'name' => __( 'No donors found.', 'give' ),
304
+			'name' => __('No donors found.', 'give'),
305 305
 		);
306 306
 
307 307
 	}
308 308
 
309
-	echo json_encode( $results );
309
+	echo json_encode($results);
310 310
 
311 311
 	give_die();
312 312
 }
313 313
 
314
-add_action( 'wp_ajax_give_donor_search', 'give_ajax_donor_search' );
314
+add_action('wp_ajax_give_donor_search', 'give_ajax_donor_search');
315 315
 
316 316
 
317 317
 /**
@@ -323,39 +323,39 @@  discard block
 block discarded – undo
323 323
  */
324 324
 function give_ajax_search_users() {
325 325
 
326
-	if ( current_user_can( 'manage_give_settings' ) ) {
326
+	if (current_user_can('manage_give_settings')) {
327 327
 
328
-		$search   = esc_sql( sanitize_text_field( $_GET['s'] ) );
328
+		$search = esc_sql(sanitize_text_field($_GET['s']));
329 329
 
330 330
 		$get_users_args = array(
331 331
 			'number' => 9999,
332
-			'search' => $search . '*',
332
+			'search' => $search.'*',
333 333
 		);
334 334
 
335
-		$get_users_args = apply_filters( 'give_search_users_args', $get_users_args );
335
+		$get_users_args = apply_filters('give_search_users_args', $get_users_args);
336 336
 
337
-		$found_users = apply_filters( 'give_ajax_found_users', get_users( $get_users_args ), $search );
337
+		$found_users = apply_filters('give_ajax_found_users', get_users($get_users_args), $search);
338 338
 		$results     = array();
339 339
 
340
-		if ( $found_users ) {
340
+		if ($found_users) {
341 341
 
342
-			foreach ( $found_users as $user ) {
342
+			foreach ($found_users as $user) {
343 343
 
344 344
 				$results[] = array(
345 345
 					'id'   => $user->ID,
346
-					'name' => esc_html( $user->user_login . ' (' . $user->user_email . ')' ),
346
+					'name' => esc_html($user->user_login.' ('.$user->user_email.')'),
347 347
 				);
348 348
 			}
349 349
 		} else {
350 350
 
351 351
 			$results[] = array(
352 352
 				'id'   => 0,
353
-				'name' => __( 'No users found.', 'give' ),
353
+				'name' => __('No users found.', 'give'),
354 354
 			);
355 355
 
356 356
 		}
357 357
 
358
-		echo json_encode( $results );
358
+		echo json_encode($results);
359 359
 
360 360
 	}// End if().
361 361
 
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 
364 364
 }
365 365
 
366
-add_action( 'wp_ajax_give_user_search', 'give_ajax_search_users' );
366
+add_action('wp_ajax_give_user_search', 'give_ajax_search_users');
367 367
 
368 368
 
369 369
 /**
@@ -375,32 +375,32 @@  discard block
 block discarded – undo
375 375
  */
376 376
 function give_check_for_form_price_variations() {
377 377
 
378
-	if ( ! current_user_can( 'edit_give_forms', get_current_user_id() ) ) {
379
-		die( '-1' );
378
+	if ( ! current_user_can('edit_give_forms', get_current_user_id())) {
379
+		die('-1');
380 380
 	}
381 381
 
382
-	$form_id = intval( $_POST['form_id'] );
383
-	$form    = get_post( $form_id );
382
+	$form_id = intval($_POST['form_id']);
383
+	$form    = get_post($form_id);
384 384
 
385
-	if ( 'give_forms' != $form->post_type ) {
386
-		die( '-2' );
385
+	if ('give_forms' != $form->post_type) {
386
+		die('-2');
387 387
 	}
388 388
 
389
-	if ( give_has_variable_prices( $form_id ) ) {
390
-		$variable_prices = give_get_variable_prices( $form_id );
389
+	if (give_has_variable_prices($form_id)) {
390
+		$variable_prices = give_get_variable_prices($form_id);
391 391
 
392
-		if ( $variable_prices ) {
392
+		if ($variable_prices) {
393 393
 			$ajax_response = '<select class="give_price_options_select give-select give-select" name="give_price_option">';
394 394
 
395
-			if ( isset( $_POST['all_prices'] ) ) {
396
-				$ajax_response .= '<option value="all">' . esc_html__( 'All Levels', 'give' ) . '</option>';
395
+			if (isset($_POST['all_prices'])) {
396
+				$ajax_response .= '<option value="all">'.esc_html__('All Levels', 'give').'</option>';
397 397
 			}
398 398
 
399
-			foreach ( $variable_prices as $key => $price ) {
399
+			foreach ($variable_prices as $key => $price) {
400 400
 
401
-				$level_text = ! empty( $price['_give_text'] ) ? esc_html( $price['_give_text'] ) : give_currency_filter( give_format_amount( $price['_give_amount'] ) );
401
+				$level_text = ! empty($price['_give_text']) ? esc_html($price['_give_text']) : give_currency_filter(give_format_amount($price['_give_amount']));
402 402
 
403
-				$ajax_response .= '<option value="' . esc_attr( $price['_give_id']['level_id'] ) . '">' . $level_text . '</option>';
403
+				$ajax_response .= '<option value="'.esc_attr($price['_give_id']['level_id']).'">'.$level_text.'</option>';
404 404
 			}
405 405
 			$ajax_response .= '</select>';
406 406
 			echo $ajax_response;
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 	give_die();
411 411
 }
412 412
 
413
-add_action( 'wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations' );
413
+add_action('wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations');
414 414
 
415 415
 
416 416
 /**
@@ -421,25 +421,25 @@  discard block
 block discarded – undo
421 421
  * @return void
422 422
  */
423 423
 function give_check_for_form_price_variations_html() {
424
-	if ( ! current_user_can( 'edit_give_payments', get_current_user_id() ) ) {
424
+	if ( ! current_user_can('edit_give_payments', get_current_user_id())) {
425 425
 		wp_die();
426 426
 	}
427 427
 
428
-	$form_id    = ! empty( $_POST['form_id'] ) ? intval( $_POST['form_id'] ) : 0;
429
-	$payment_id = ! empty( $_POST['payment_id'] ) ? intval( $_POST['payment_id'] ) : 0;
430
-	$form       = get_post( $form_id );
428
+	$form_id    = ! empty($_POST['form_id']) ? intval($_POST['form_id']) : 0;
429
+	$payment_id = ! empty($_POST['payment_id']) ? intval($_POST['payment_id']) : 0;
430
+	$form       = get_post($form_id);
431 431
 
432
-	if ( 'give_forms' != $form->post_type ) {
432
+	if ('give_forms' != $form->post_type) {
433 433
 		wp_die();
434 434
 	}
435 435
 
436
-	if ( ! give_has_variable_prices( $form_id ) || ! $form_id ) {
437
-		esc_html_e( 'n/a', 'give' );
436
+	if ( ! give_has_variable_prices($form_id) || ! $form_id) {
437
+		esc_html_e('n/a', 'give');
438 438
 	} else {
439 439
 		$prices_atts = '';
440
-		if ( $variable_prices = give_get_variable_prices( $form_id ) ) {
441
-			foreach ( $variable_prices as $variable_price ) {
442
-				$prices_atts[ $variable_price['_give_id']['level_id'] ] = give_format_amount( $variable_price['_give_amount'] );
440
+		if ($variable_prices = give_get_variable_prices($form_id)) {
441
+			foreach ($variable_prices as $variable_price) {
442
+				$prices_atts[$variable_price['_give_id']['level_id']] = give_format_amount($variable_price['_give_amount']);
443 443
 			}
444 444
 		}
445 445
 
@@ -450,12 +450,12 @@  discard block
 block discarded – undo
450 450
 			'chosen'           => true,
451 451
 			'show_option_all'  => '',
452 452
 			'show_option_none' => '',
453
-			'select_atts'      => 'data-prices=' . esc_attr( json_encode( $prices_atts ) ),
453
+			'select_atts'      => 'data-prices='.esc_attr(json_encode($prices_atts)),
454 454
 		);
455 455
 
456
-		if ( $payment_id ) {
456
+		if ($payment_id) {
457 457
 			// Payment object.
458
-			$payment = new Give_Payment( $payment_id );
458
+			$payment = new Give_Payment($payment_id);
459 459
 
460 460
 			// Payment meta.
461 461
 			$payment_meta                               = $payment->get_meta();
@@ -463,10 +463,10 @@  discard block
 block discarded – undo
463 463
 		}
464 464
 
465 465
 		// Render variable prices select tag html.
466
-		give_get_form_variable_price_dropdown( $variable_price_dropdown_option, true );
466
+		give_get_form_variable_price_dropdown($variable_price_dropdown_option, true);
467 467
 	}
468 468
 
469 469
 	give_die();
470 470
 }
471 471
 
472
-add_action( 'wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html' );
472
+add_action('wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html');
Please login to merge, or discard this patch.
includes/admin/class-i18n-module.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -65,18 +65,18 @@  discard block
 block discarded – undo
65 65
 	 *
66 66
 	 * @param $args
67 67
 	 */
68
-	public function __construct( $args ) {
68
+	public function __construct($args) {
69 69
 
70 70
 		// Only for admins.
71
-		if ( ! is_admin() ) {
71
+		if ( ! is_admin()) {
72 72
 			return;
73 73
 		}
74 74
 
75
-		foreach ( $args as $key => $arg ) {
75
+		foreach ($args as $key => $arg) {
76 76
 			$this->$key = $arg;
77 77
 		}
78 78
 
79
-		add_action( 'admin_init', array( $this, 'init' ) );
79
+		add_action('admin_init', array($this, 'init'));
80 80
 
81 81
 
82 82
 	}
@@ -87,15 +87,15 @@  discard block
 block discarded – undo
87 87
 	function init() {
88 88
 
89 89
 		// First get user's locale (4.7+).
90
-		$this->locale = function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
90
+		$this->locale = function_exists('get_user_locale') ? get_user_locale() : get_locale();
91 91
 
92 92
 		// This plugin is en_US native.
93
-		if ( 'en_US' === $this->locale ) {
93
+		if ('en_US' === $this->locale) {
94 94
 			return;
95 95
 		}
96 96
 
97
-		if ( ! $this->hide_promo() ) {
98
-			add_action( $this->hook, array( $this, 'promo' ) );
97
+		if ( ! $this->hide_promo()) {
98
+			add_action($this->hook, array($this, 'promo'));
99 99
 		}
100 100
 	}
101 101
 
@@ -108,11 +108,11 @@  discard block
 block discarded – undo
108 108
 	 * @return bool
109 109
 	 */
110 110
 	private function hide_promo() {
111
-		$hide_promo = Give_Cache::get( 'give_i18n_give_promo_hide', true );
112
-		if ( ! $hide_promo ) {
113
-			if ( filter_input( INPUT_GET, 'remove_i18n_promo', FILTER_VALIDATE_INT ) === 1 ) {
111
+		$hide_promo = Give_Cache::get('give_i18n_give_promo_hide', true);
112
+		if ( ! $hide_promo) {
113
+			if (filter_input(INPUT_GET, 'remove_i18n_promo', FILTER_VALIDATE_INT) === 1) {
114 114
 				// No expiration time, so this would normally not expire, but it wouldn't be copied to other sites etc.
115
-				Give_Cache::set( 'give_i18n_give_promo_hide', true, null, true );
115
+				Give_Cache::set('give_i18n_give_promo_hide', true, null, true);
116 116
 				$hide_promo = true;
117 117
 			}
118 118
 		}
@@ -131,20 +131,20 @@  discard block
 block discarded – undo
131 131
 		$message = false;
132 132
 
133 133
 		// Using a translation less than 90% complete.
134
-		if ( $this->translation_exists && $this->translation_loaded && $this->percent_translated < 90 ) {
135
-			$message = __( 'As you can see, there is a translation of this plugin in %1$s. This translation is currently %3$d%% complete. We need your help to make it complete and to fix any errors. Please register at %4$s to help %5$s to %1$s!', 'give' );
136
-		} elseif ( ! $this->translation_loaded && $this->translation_exists ) {
137
-			$message = __( 'You\'re using WordPress in %1$s. While %2$s has been %3$d%% translated to %1$s, it has not been shipped with the plugin yet. You can help! Register at %4$s to help complete the translation to %1$s!', 'give' );
138
-		} elseif ( ! $this->translation_exists ) {
139
-			$message = __( 'You\'re using WordPress in a language we don\'t support yet. We\'d love for %2$s to be translated in that language too, but unfortunately, it isn\'t right now. You can change that! Register at %4$s to help translate it!', 'give' );
134
+		if ($this->translation_exists && $this->translation_loaded && $this->percent_translated < 90) {
135
+			$message = __('As you can see, there is a translation of this plugin in %1$s. This translation is currently %3$d%% complete. We need your help to make it complete and to fix any errors. Please register at %4$s to help %5$s to %1$s!', 'give');
136
+		} elseif ( ! $this->translation_loaded && $this->translation_exists) {
137
+			$message = __('You\'re using WordPress in %1$s. While %2$s has been %3$d%% translated to %1$s, it has not been shipped with the plugin yet. You can help! Register at %4$s to help complete the translation to %1$s!', 'give');
138
+		} elseif ( ! $this->translation_exists) {
139
+			$message = __('You\'re using WordPress in a language we don\'t support yet. We\'d love for %2$s to be translated in that language too, but unfortunately, it isn\'t right now. You can change that! Register at %4$s to help translate it!', 'give');
140 140
 		}
141 141
 
142 142
 		// Links.
143
-		$registration_link = sprintf( '<a href="%1$s" target="_blank">%2$s</a>', 'https://wordpress.org/support/register.php', esc_html__( 'WordPress.org', 'give' ) );
144
-		$translations_link = sprintf( '<a href="%1$s" target="_blank">%2$s</a>', 'https://translate.wordpress.org/projects/wp-plugins/give', esc_html__( 'complete the translation', 'give' ) );
143
+		$registration_link = sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://wordpress.org/support/register.php', esc_html__('WordPress.org', 'give'));
144
+		$translations_link = sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://translate.wordpress.org/projects/wp-plugins/give', esc_html__('complete the translation', 'give'));
145 145
 
146 146
 		// Message.
147
-		$message = sprintf( $message, $this->locale_name, 'Give', $this->percent_translated, $registration_link, $translations_link );
147
+		$message = sprintf($message, $this->locale_name, 'Give', $this->percent_translated, $registration_link, $translations_link);
148 148
 
149 149
 		return $message;
150 150
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 		$this->translation_details();
159 159
 		$message = $this->promo_message();
160 160
 
161
-		if ( $message ) { ?>
161
+		if ($message) { ?>
162 162
 
163 163
 			<style>
164 164
 				/* Banner specific styles */
@@ -223,12 +223,12 @@  discard block
 block discarded – undo
223 223
 				                                                                                                                             style="font-size: 110px; text-decoration: none;"></span></a>
224 224
 
225 225
 				<div class="give-i18n-notice-content">
226
-					<a href="<?php echo esc_url( add_query_arg( array( 'remove_i18n_promo' => '1' ) ) ); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a>
226
+					<a href="<?php echo esc_url(add_query_arg(array('remove_i18n_promo' => '1'))); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a>
227 227
 
228
-					<h2 style="margin: 10px 0;"><?php printf( esc_html__( 'Help Translate Give to %s', 'give' ), $this->locale_name ); ?></h2>
228
+					<h2 style="margin: 10px 0;"><?php printf(esc_html__('Help Translate Give to %s', 'give'), $this->locale_name); ?></h2>
229 229
 					<p><?php echo $message; ?></p>
230 230
 					<p>
231
-						<a href="https://wordpress.org/support/register.php" target="_blank"><?php _e( 'Register now &raquo;', 'give' ); ?></a>
231
+						<a href="https://wordpress.org/support/register.php" target="_blank"><?php _e('Register now &raquo;', 'give'); ?></a>
232 232
 					</p>
233 233
 				</div>
234 234
 			</div>
@@ -245,11 +245,11 @@  discard block
 block discarded – undo
245 245
 	 */
246 246
 	private function find_or_initialize_translation_details() {
247 247
 
248
-		$set = Give_Cache::get( "give_i18n_give_{$this->locale}", true );
248
+		$set = Give_Cache::get("give_i18n_give_{$this->locale}", true);
249 249
 
250
-		if ( ! $set ) {
250
+		if ( ! $set) {
251 251
 			$set = $this->retrieve_translation_details();
252
-			Give_Cache::set( "give_i18n_give_{$this->locale}", $set, DAY_IN_SECONDS, true );
252
+			Give_Cache::set("give_i18n_give_{$this->locale}", $set, DAY_IN_SECONDS, true);
253 253
 		}
254 254
 
255 255
 		return $set;
@@ -263,10 +263,10 @@  discard block
 block discarded – undo
263 263
 	private function translation_details() {
264 264
 		$set = $this->find_or_initialize_translation_details();
265 265
 
266
-		$this->translation_exists = ! is_null( $set );
267
-		$this->translation_loaded = is_textdomain_loaded( 'give' );
266
+		$this->translation_exists = ! is_null($set);
267
+		$this->translation_loaded = is_textdomain_loaded('give');
268 268
 
269
-		$this->parse_translation_set( $set );
269
+		$this->parse_translation_set($set);
270 270
 	}
271 271
 
272 272
 	/**
@@ -278,26 +278,26 @@  discard block
 block discarded – undo
278 278
 	 */
279 279
 	private function retrieve_translation_details() {
280 280
 
281
-		$api_url = trailingslashit( $this->glotpress_url );
281
+		$api_url = trailingslashit($this->glotpress_url);
282 282
 
283
-		$resp = wp_remote_get( $api_url );
283
+		$resp = wp_remote_get($api_url);
284 284
 
285
-		if ( is_wp_error( $resp ) || wp_remote_retrieve_response_code( $resp ) === '404' ) {
285
+		if (is_wp_error($resp) || wp_remote_retrieve_response_code($resp) === '404') {
286 286
 			return null;
287 287
 		}
288 288
 
289
-		$body = wp_remote_retrieve_body( $resp );
290
-		unset( $resp );
289
+		$body = wp_remote_retrieve_body($resp);
290
+		unset($resp);
291 291
 
292
-		if ( $body ) {
293
-			$body = json_decode( $body );
292
+		if ($body) {
293
+			$body = json_decode($body);
294 294
 
295
-			foreach ( $body->translation_sets as $set ) {
296
-				if ( ! property_exists( $set, 'wp_locale' ) ) {
295
+			foreach ($body->translation_sets as $set) {
296
+				if ( ! property_exists($set, 'wp_locale')) {
297 297
 					continue;
298 298
 				}
299 299
 
300
-				if ( $this->locale == $set->wp_locale ) {
300
+				if ($this->locale == $set->wp_locale) {
301 301
 					return $set;
302 302
 				}
303 303
 			}
@@ -313,8 +313,8 @@  discard block
 block discarded – undo
313 313
 	 *
314 314
 	 * @access private
315 315
 	 */
316
-	private function parse_translation_set( $set ) {
317
-		if ( $this->translation_exists && is_object( $set ) ) {
316
+	private function parse_translation_set($set) {
317
+		if ($this->translation_exists && is_object($set)) {
318 318
 			$this->locale_name        = $set->name;
319 319
 			$this->percent_translated = $set->percent_translated;
320 320
 		} else {
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 	}
325 325
 }
326 326
 
327
-$give_i18n = new Give_i18n_Banner( array(
327
+$give_i18n = new Give_i18n_Banner(array(
328 328
 		'hook'          => 'give_forms_page_give-settings',
329 329
 		'glotpress_url' => 'https://translate.wordpress.org/api/projects/wp-plugins/give/stable/',
330
-	) );
330
+	));
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-form-stats.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -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', $totals['earnings'] );
112
+		give_update_meta($this->form_id, '_give_form_sales', $totals['sales']);
113
+		give_update_meta($this->form_id, '_give_form_earnings', $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,11 +228,11 @@  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
-		return empty( $value ) ? false : maybe_unserialize( $value );
235
+		return empty($value) ? false : maybe_unserialize($value);
236 236
 	}
237 237
 
238 238
 	/**
@@ -245,10 +245,10 @@  discard block
 block discarded – undo
245 245
 	 *
246 246
 	 * @return void
247 247
 	 */
248
-	private function store_data( $key, $value ) {
248
+	private function store_data($key, $value) {
249 249
 		global $wpdb;
250 250
 
251
-		$value = maybe_serialize( $value );
251
+		$value = maybe_serialize($value);
252 252
 
253 253
 		$data = array(
254 254
 			'option_name'  => $key,
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 			'%s',
263 263
 		);
264 264
 
265
-		$wpdb->replace( $wpdb->options, $data, $formats );
265
+		$wpdb->replace($wpdb->options, $data, $formats);
266 266
 	}
267 267
 
268 268
 	/**
@@ -274,9 +274,9 @@  discard block
 block discarded – undo
274 274
 	 *
275 275
 	 * @return void
276 276
 	 */
277
-	private function delete_data( $key ) {
277
+	private function delete_data($key) {
278 278
 		global $wpdb;
279
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
279
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
280 280
 	}
281 281
 
282 282
 }
283 283
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/tools/data/tools-actions.php 1 patch
Spacing   +11 added lines, -11 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,31 +35,31 @@  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_Test_Transactions':
42
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-delete-test-transactions.php';
42
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-delete-test-transactions.php';
43 43
 			break;
44 44
 
45 45
 		case 'Give_Tools_Recount_Donor_Stats':
46
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-donor-stats.php';
46
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-donor-stats.php';
47 47
 			break;
48 48
 
49 49
 		case 'Give_Tools_Reset_Stats':
50
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-reset-stats.php';
50
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-reset-stats.php';
51 51
 			break;
52 52
 
53 53
 		case 'Give_Tools_Recount_All_Stats':
54
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-all-stats.php';
54
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-all-stats.php';
55 55
 			break;
56 56
 
57 57
 		case 'Give_Tools_Recount_Form_Stats':
58
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-form-stats.php';
58
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-form-stats.php';
59 59
 			break;
60 60
 
61 61
 		case 'Give_Tools_Recount_Income':
62
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-income.php';
62
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-income.php';
63 63
 			break;
64 64
 	}
65 65
 }
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
 
@@ -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,25 +85,25 @@  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';
106
+						$table_name = $wpdb->prefix.'give_customers';
107 107
 						$sql[]      = "DELETE FROM $table_name WHERE id IN ($ids)";
108 108
 						break;
109 109
 					case 'forms':
@@ -118,16 +118,16 @@  discard block
 block discarded – undo
118 118
 						break;
119 119
 				}
120 120
 
121
-				if ( ! in_array( $type, array( 'customers', 'forms', 'other' ) ) ) {
121
+				if ( ! in_array($type, array('customers', 'forms', 'other'))) {
122 122
 					// Allows other types of custom post types to filter on their own post_type
123 123
 					// and add items to the query list, for the IDs found in their post type.
124
-					$sql = apply_filters( "give_reset_add_queries_{$type}", $sql, $ids );
124
+					$sql = apply_filters("give_reset_add_queries_{$type}", $sql, $ids);
125 125
 				}
126 126
 			}
127 127
 
128
-			if ( ! empty( $sql ) ) {
129
-				foreach ( $sql as $query ) {
130
-					$wpdb->query( $query );
128
+			if ( ! empty($sql)) {
129
+				foreach ($sql as $query) {
130
+					$wpdb->query($query);
131 131
 				}
132 132
 			}
133 133
 
@@ -147,16 +147,16 @@  discard block
 block discarded – undo
147 147
 	 */
148 148
 	public function get_percentage_complete() {
149 149
 
150
-		$items = $this->get_stored_data( 'give_temp_reset_ids' );
151
-		$total = count( $items );
150
+		$items = $this->get_stored_data('give_temp_reset_ids');
151
+		$total = count($items);
152 152
 
153 153
 		$percentage = 100;
154 154
 
155
-		if ( $total > 0 ) {
156
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
155
+		if ($total > 0) {
156
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
157 157
 		}
158 158
 
159
-		if ( $percentage > 100 ) {
159
+		if ($percentage > 100) {
160 160
 			$percentage = 100;
161 161
 		}
162 162
 
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 	 *
171 171
 	 * @param array $request The Form Data passed into the batch processing.
172 172
 	 */
173
-	public function set_properties( $request ) {
173
+	public function set_properties($request) {
174 174
 	}
175 175
 
176 176
 	/**
@@ -181,31 +181,31 @@  discard block
 block discarded – undo
181 181
 	 */
182 182
 	public function process_step() {
183 183
 
184
-		if ( ! $this->can_export() ) {
185
-			wp_die( esc_html__( 'You do not have permission to reset data.', 'give' ), esc_html__( 'Error', 'give' ), array(
184
+		if ( ! $this->can_export()) {
185
+			wp_die(esc_html__('You do not have permission to reset data.', 'give'), esc_html__('Error', 'give'), array(
186 186
 				'response' => 403,
187
-			) );
187
+			));
188 188
 		}
189 189
 
190 190
 		$had_data = $this->get_data();
191 191
 
192
-		if ( $had_data ) {
192
+		if ($had_data) {
193 193
 			$this->done = false;
194 194
 
195 195
 			return true;
196 196
 		} else {
197
-			update_option( 'give_earnings_total', 0 );
198
-			Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) );
197
+			update_option('give_earnings_total', 0);
198
+			Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
199 199
 
200
-			$this->delete_data( 'give_temp_reset_ids' );
200
+			$this->delete_data('give_temp_reset_ids');
201 201
 
202 202
 			// Reset the sequential order numbers
203
-			if ( give_get_option( 'enable_sequential' ) ) {
204
-				delete_option( 'give_last_payment_number' );
203
+			if (give_get_option('enable_sequential')) {
204
+				delete_option('give_last_payment_number');
205 205
 			}
206 206
 
207 207
 			$this->done    = true;
208
-			$this->message = esc_html__( 'Donation forms, income, donations counts, and logs successfully reset.', 'give' );
208
+			$this->message = esc_html__('Donation forms, income, donations counts, and logs successfully reset.', 'give');
209 209
 
210 210
 			return false;
211 211
 		}
@@ -215,10 +215,10 @@  discard block
 block discarded – undo
215 215
 	 * Headers
216 216
 	 */
217 217
 	public function headers() {
218
-		ignore_user_abort( true );
218
+		ignore_user_abort(true);
219 219
 
220
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
221
-			set_time_limit( 0 );
220
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
221
+			set_time_limit(0);
222 222
 		}
223 223
 	}
224 224
 
@@ -242,26 +242,26 @@  discard block
 block discarded – undo
242 242
 	 */
243 243
 	public function pre_fetch() {
244 244
 
245
-		if ( $this->step == 1 ) {
246
-			$this->delete_data( 'give_temp_reset_ids' );
245
+		if ($this->step == 1) {
246
+			$this->delete_data('give_temp_reset_ids');
247 247
 		}
248 248
 
249
-		$items = get_option( 'give_temp_reset_ids', false );
249
+		$items = get_option('give_temp_reset_ids', false);
250 250
 
251
-		if ( false === $items ) {
251
+		if (false === $items) {
252 252
 			$items = array();
253 253
 
254
-			$give_types_for_reset = array( 'give_forms', 'give_payment' );
255
-			$give_types_for_reset = apply_filters( 'give_reset_store_post_types', $give_types_for_reset );
254
+			$give_types_for_reset = array('give_forms', 'give_payment');
255
+			$give_types_for_reset = apply_filters('give_reset_store_post_types', $give_types_for_reset);
256 256
 
257
-			$args = apply_filters( 'give_tools_reset_stats_total_args', array(
257
+			$args = apply_filters('give_tools_reset_stats_total_args', array(
258 258
 				'post_type'      => $give_types_for_reset,
259 259
 				'post_status'    => 'any',
260
-				'posts_per_page' => - 1,
261
-			) );
260
+				'posts_per_page' => -1,
261
+			));
262 262
 
263
-			$posts = get_posts( $args );
264
-			foreach ( $posts as $post ) {
263
+			$posts = get_posts($args);
264
+			foreach ($posts as $post) {
265 265
 				$items[] = array(
266 266
 					'id'   => (int) $post->ID,
267 267
 					'type' => $post->post_type,
@@ -269,10 +269,10 @@  discard block
 block discarded – undo
269 269
 			}
270 270
 
271 271
 			$donor_args = array(
272
-				'number' => - 1,
272
+				'number' => -1,
273 273
 			);
274
-			$donors     = Give()->donors->get_donors( $donor_args );
275
-			foreach ( $donors as $donor ) {
274
+			$donors     = Give()->donors->get_donors($donor_args);
275
+			foreach ($donors as $donor) {
276 276
 				$items[] = array(
277 277
 					'id'   => (int) $donor->id,
278 278
 					'type' => 'customer',
@@ -281,9 +281,9 @@  discard block
 block discarded – undo
281 281
 
282 282
 			// Allow filtering of items to remove with an unassociative array for each item
283 283
 			// The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method
284
-			$items = apply_filters( 'give_reset_items', $items );
284
+			$items = apply_filters('give_reset_items', $items);
285 285
 
286
-			$this->store_data( 'give_temp_reset_ids', $items );
286
+			$this->store_data('give_temp_reset_ids', $items);
287 287
 		}// End if().
288 288
 
289 289
 	}
@@ -297,11 +297,11 @@  discard block
 block discarded – undo
297 297
 	 *
298 298
 	 * @return mixed       Returns the data from the database.
299 299
 	 */
300
-	private function get_stored_data( $key ) {
300
+	private function get_stored_data($key) {
301 301
 		global $wpdb;
302
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
302
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
303 303
 
304
-		return empty( $value ) ? false : maybe_unserialize( $value );
304
+		return empty($value) ? false : maybe_unserialize($value);
305 305
 	}
306 306
 
307 307
 	/**
@@ -314,10 +314,10 @@  discard block
 block discarded – undo
314 314
 	 *
315 315
 	 * @return void
316 316
 	 */
317
-	private function store_data( $key, $value ) {
317
+	private function store_data($key, $value) {
318 318
 		global $wpdb;
319 319
 
320
-		$value = maybe_serialize( $value );
320
+		$value = maybe_serialize($value);
321 321
 
322 322
 		$data = array(
323 323
 			'option_name'  => $key,
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 			'%s',
332 332
 		);
333 333
 
334
-		$wpdb->replace( $wpdb->options, $data, $formats );
334
+		$wpdb->replace($wpdb->options, $data, $formats);
335 335
 	}
336 336
 
337 337
 	/**
@@ -343,11 +343,11 @@  discard block
 block discarded – undo
343 343
 	 *
344 344
 	 * @return void
345 345
 	 */
346
-	private function delete_data( $key ) {
346
+	private function delete_data($key) {
347 347
 		global $wpdb;
348
-		$wpdb->delete( $wpdb->options, array(
348
+		$wpdb->delete($wpdb->options, array(
349 349
 			'option_name' => $key,
350
-		) );
350
+		));
351 351
 	}
352 352
 
353 353
 }
354 354
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-single-donor-stats.php 1 patch
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -53,40 +53,40 @@  discard block
 block discarded – undo
53 53
 	 */
54 54
 	public function get_data() {
55 55
 
56
-		$donor    = new Give_Donor( $this->customer_id );
57
-		$payments = $this->get_stored_data( 'give_recount_donor_payments_' . $donor->id );
56
+		$donor    = new Give_Donor($this->customer_id);
57
+		$payments = $this->get_stored_data('give_recount_donor_payments_'.$donor->id);
58 58
 
59
-		$offset     = ( $this->step - 1 ) * $this->per_step;
60
-		$step_items = array_slice( $payments, $offset, $this->per_step );
59
+		$offset     = ($this->step - 1) * $this->per_step;
60
+		$step_items = array_slice($payments, $offset, $this->per_step);
61 61
 
62
-		if ( count( $step_items ) > 0 ) {
63
-			$pending_total = (float) $this->get_stored_data( 'give_stats_donor_pending_total' . $donor->id );
62
+		if (count($step_items) > 0) {
63
+			$pending_total = (float) $this->get_stored_data('give_stats_donor_pending_total'.$donor->id);
64 64
 			$step_total    = 0;
65 65
 
66
-			$found_payment_ids = $this->get_stored_data( 'give_stats_found_payments_' . $donor->id );
66
+			$found_payment_ids = $this->get_stored_data('give_stats_found_payments_'.$donor->id);
67 67
 
68
-			foreach ( $step_items as $payment ) {
69
-				$payment = get_post( $payment->ID );
68
+			foreach ($step_items as $payment) {
69
+				$payment = get_post($payment->ID);
70 70
 
71
-				if ( is_null( $payment ) || is_wp_error( $payment ) || 'give_payment' !== $payment->post_type ) {
71
+				if (is_null($payment) || is_wp_error($payment) || 'give_payment' !== $payment->post_type) {
72 72
 
73
-					$missing_payments   = $this->get_stored_data( 'give_stats_missing_payments' . $donor->id );
73
+					$missing_payments   = $this->get_stored_data('give_stats_missing_payments'.$donor->id);
74 74
 					$missing_payments[] = $payment->ID;
75
-					$this->store_data( 'give_stats_missing_payments' . $donor->id, $missing_payments );
75
+					$this->store_data('give_stats_missing_payments'.$donor->id, $missing_payments);
76 76
 
77 77
 					continue;
78 78
 				}
79 79
 
80 80
 				$should_process_payment = 'publish' == $payment->post_status ? true : false;
81
-				$should_process_payment = apply_filters( 'give_donor_recount_should_process_donation', $should_process_payment, $payment );
81
+				$should_process_payment = apply_filters('give_donor_recount_should_process_donation', $should_process_payment, $payment);
82 82
 
83
-				if ( true === $should_process_payment ) {
83
+				if (true === $should_process_payment) {
84 84
 
85 85
 					$found_payment_ids[] = $payment->ID;
86 86
 
87
-					if ( apply_filters( 'give_donor_recount_should_increase_value', true, $payment ) ) {
88
-						$payment_amount = 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 ), 'purchase_count' => 0 ) );
237
+			$donor = new Give_Donor($this->customer_id);
238
+			$donor->update(array('purchase_value' => give_format_amount(0), '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,11 +276,11 @@  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
-		return empty( $value ) ? false : maybe_unserialize( $value );
283
+		return empty($value) ? false : maybe_unserialize($value);
284 284
 	}
285 285
 
286 286
 	/**
@@ -293,10 +293,10 @@  discard block
 block discarded – undo
293 293
 	 *
294 294
 	 * @return void
295 295
 	 */
296
-	private function store_data( $key, $value ) {
296
+	private function store_data($key, $value) {
297 297
 		global $wpdb;
298 298
 
299
-		$value = maybe_serialize( $value );
299
+		$value = maybe_serialize($value);
300 300
 
301 301
 		$data = array(
302 302
 			'option_name'  => $key,
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 			'%s',
311 311
 		);
312 312
 
313
-		$wpdb->replace( $wpdb->options, $data, $formats );
313
+		$wpdb->replace($wpdb->options, $data, $formats);
314 314
 	}
315 315
 
316 316
 	/**
@@ -322,9 +322,9 @@  discard block
 block discarded – undo
322 322
 	 *
323 323
 	 * @return void
324 324
 	 */
325
-	private function delete_data( $key ) {
325
+	private function delete_data($key) {
326 326
 		global $wpdb;
327
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
327
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
328 328
 	}
329 329
 
330 330
 }
Please login to merge, or discard this patch.