Test Failed
Push — master ( f098b0...602e9b )
by Devin
10:54 queued 05:19
created
includes/admin/tools/data/class-give-tools-delete-import-donors.php 2 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	 * Return the calculated completion percentage.
217 217
 	 *
218 218
 	 * @since 1.8.12
219
-	 * @return int
219
+	 * @return double
220 220
 	 */
221 221
 	public function get_percentage_complete() {
222 222
 		return ceil( ( 100 * $this->step_completed ) / $this->total_step );
@@ -353,6 +353,9 @@  discard block
 block discarded – undo
353 353
 		return true;
354 354
 	}
355 355
 
356
+	/**
357
+	 * @param integer $page
358
+	 */
356 359
 	public function get_delete_ids( $donation_ids, $page ) {
357 360
 		$index            = $page --;
358 361
 		$count            = count( $donation_ids );
Please login to merge, or discard this patch.
Spacing   +116 added lines, -116 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
 
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
 	/**
106 106
 	 * Constructor.
107 107
 	 */
108
-	public function __construct( $_step = 1 ) {
109
-		parent::__construct( $_step );
108
+	public function __construct($_step = 1) {
109
+		parent::__construct($_step);
110 110
 
111 111
 		$this->is_writable = true;
112 112
 	}
@@ -125,34 +125,34 @@  discard block
 block discarded – undo
125 125
 		$donor_ids    = array();
126 126
 
127 127
 		// Check if the ajax request if running for the first time.
128
-		if ( 1 === (int) $this->step ) {
128
+		if (1 === (int) $this->step) {
129 129
 			// Delete all the form ids.
130
-			$this->delete_option( $this->form_key );
130
+			$this->delete_option($this->form_key);
131 131
 			// Delete all the donation ids.
132
-			$this->delete_option( $this->donation_key );
132
+			$this->delete_option($this->donation_key);
133 133
 			// Delete all the donor ids.
134
-			$this->delete_option( $this->donor_key );
134
+			$this->delete_option($this->donor_key);
135 135
 
136 136
 			// Delete all the step and set to 'count' which if the first step in the process of deleting the donors.
137
-			$this->update_option( $this->step_key, 'count' );
137
+			$this->update_option($this->step_key, 'count');
138 138
 
139 139
 			// Delete tha page count of the step.
140
-			$this->update_option( $this->step_on_key, '0' );
140
+			$this->update_option($this->step_on_key, '0');
141 141
 		} else {
142 142
 			// Get the old donors list.
143
-			$donor_ids = $this->get_option( $this->donor_key );
143
+			$donor_ids = $this->get_option($this->donor_key);
144 144
 
145 145
 			// Get the old donation list.
146
-			$donation_ids = $this->get_option( $this->donation_key );
146
+			$donation_ids = $this->get_option($this->donation_key);
147 147
 		}
148 148
 
149 149
 		// Get the step and check for it if it's on the first step( 'count' ) or not.
150 150
 		$step = (int) $this->get_step();
151
-		if ( 1 === $step ) {
151
+		if (1 === $step) {
152 152
 			/**
153 153
 			 * Will add or update the donation and donor data by running wp query.
154 154
 			 */
155
-			$this->count( $step, $donation_ids, $donor_ids );
155
+			$this->count($step, $donation_ids, $donor_ids);
156 156
 		}
157 157
 	}
158 158
 
@@ -163,17 +163,17 @@  discard block
 block discarded – undo
163 163
 	 * @param array $donation_ids Contain the list of all the donation id's that has being add before this
164 164
 	 * @param array $donor_ids Contain the list of all the donors id's that has being add before this
165 165
 	 */
166
-	private function count( $step, $donation_ids = array(), $donor_ids = array() ) {
166
+	private function count($step, $donation_ids = array(), $donor_ids = array()) {
167 167
 
168 168
 		// Get the Page count by default it's zero.
169 169
 		$paged = (int) $this->get_step_page();
170 170
 		// Incresed the page count by one.
171
-		++ $paged;
171
+		++$paged;
172 172
 
173 173
 		/**
174 174
 		 * Filter add to alter the argument before the wp quest run
175 175
 		 */
176
-		$args = apply_filters( 'give_tools_reset_stats_total_args', array(
176
+		$args = apply_filters('give_tools_reset_stats_total_args', array(
177 177
 			'post_type'      => 'give_payment',
178 178
 			'post_status'    => 'any',
179 179
 			'posts_per_page' => $this->per_step,
@@ -181,40 +181,40 @@  discard block
 block discarded – undo
181 181
 			'meta_key'       => '_give_payment_import',
182 182
 			'meta_value_num' => 1,
183 183
 			'meta_compare'   => '=',
184
-		) );
184
+		));
185 185
 
186 186
 		// Reset the post data.
187 187
 		wp_reset_postdata();
188 188
 		// Getting the new donation.
189
-		$donation_posts = new WP_Query( $args );
189
+		$donation_posts = new WP_Query($args);
190 190
 
191 191
 		// The Loop.
192
-		if ( $donation_posts->have_posts() ) {
193
-			while ( $donation_posts->have_posts() ) {
192
+		if ($donation_posts->have_posts()) {
193
+			while ($donation_posts->have_posts()) {
194 194
 				$add_author = true;
195 195
 				$donation_posts->the_post();
196 196
 				global $post;
197 197
 				// Add the donation id in side the array.
198 198
 				$donation_ids[] = $post->ID;
199 199
 
200
-				$donor_id = (int) give_get_meta( $post->ID, '_give_payment_customer_id', true );
201
-				if ( ! empty( $donor_id ) ) {
202
-					$donor = new Give_Donor( $donor_id );
203
-					if ( ! empty( $donor->id ) ) {
204
-						if ( empty( $donor->user_id ) && ! empty( $donor->payment_ids ) ) {
200
+				$donor_id = (int) give_get_meta($post->ID, '_give_payment_customer_id', true);
201
+				if ( ! empty($donor_id)) {
202
+					$donor = new Give_Donor($donor_id);
203
+					if ( ! empty($donor->id)) {
204
+						if (empty($donor->user_id) && ! empty($donor->payment_ids)) {
205 205
 							$add_author = false;
206
-							$count      = (int) count( $donor->payment_ids );
207
-							if ( 1 === $count ) {
208
-								Give()->donors->delete( $donor->id );
206
+							$count      = (int) count($donor->payment_ids);
207
+							if (1 === $count) {
208
+								Give()->donors->delete($donor->id);
209 209
 							} else {
210
-								$donor->remove_payment( $post->ID );
210
+								$donor->remove_payment($post->ID);
211 211
 								$donor->decrease_donation_count();
212 212
 							}
213 213
 						}
214 214
 					}
215 215
 				}
216 216
 
217
-				if ( ! empty( $add_author ) ) {
217
+				if ( ! empty($add_author)) {
218 218
 					// Add the donor id in side the array.
219 219
 					$donor_ids[] = (int) $post->post_author;
220 220
 				}
@@ -229,23 +229,23 @@  discard block
 block discarded – undo
229 229
 		$max_num_pages = (int) $donation_posts->max_num_pages;
230 230
 
231 231
 		// Check current page is less then max number of page or not
232
-		if ( $paged < $max_num_pages ) {
232
+		if ($paged < $max_num_pages) {
233 233
 			// Update the curretn page virable for the next step
234
-			$this->update_option( $this->step_on_key, $paged );
234
+			$this->update_option($this->step_on_key, $paged);
235 235
 
236 236
 			// Calculating percentage.
237 237
 			$page_remain          = $max_num_pages - $paged;
238
-			$this->total_step     = (int) $max_num_pages + ( $total_donation / $this->per_step ) + ( ( $page_remain * 2 ) * count( $donor_ids ) );
238
+			$this->total_step     = (int) $max_num_pages + ($total_donation / $this->per_step) + (($page_remain * 2) * count($donor_ids));
239 239
 			$this->step_completed = $paged;
240 240
 		} else {
241
-			$donation_ids_count = count( $donor_ids );
242
-			$this->update_option( $this->step_key, 'donation' );
243
-			$this->update_option( $this->step_on_key, '0' );
241
+			$donation_ids_count = count($donor_ids);
242
+			$this->update_option($this->step_key, 'donation');
243
+			$this->update_option($this->step_on_key, '0');
244 244
 		}
245 245
 
246
-		$donor_ids = array_unique( $donor_ids );
247
-		$this->update_option( $this->donor_key, $donor_ids );
248
-		$this->update_option( $this->donation_key, $donation_ids );
246
+		$donor_ids = array_unique($donor_ids);
247
+		$this->update_option($this->donor_key, $donor_ids);
248
+		$this->update_option($this->donation_key, $donation_ids);
249 249
 
250 250
 		wp_reset_postdata();
251 251
 	}
@@ -257,34 +257,34 @@  discard block
 block discarded – undo
257 257
 	 * @return int
258 258
 	 */
259 259
 	public function get_percentage_complete() {
260
-		return ceil( ( 100 * $this->step_completed ) / $this->total_step );
260
+		return ceil((100 * $this->step_completed) / $this->total_step);
261 261
 	}
262 262
 
263 263
 	public function process_step() {
264 264
 
265
-		if ( ! $this->can_export() ) {
266
-			wp_die( __( 'You do not have permission to delete Import transactions.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
265
+		if ( ! $this->can_export()) {
266
+			wp_die(__('You do not have permission to delete Import transactions.', 'give'), __('Error', 'give'), array('response' => 403));
267 267
 		}
268 268
 
269 269
 		$had_data = $this->get_data();
270 270
 
271
-		if ( $had_data ) {
271
+		if ($had_data) {
272 272
 			$this->done = false;
273 273
 
274 274
 			return true;
275 275
 		} else {
276
-			update_option( 'give_earnings_total', give_get_total_earnings( true ) );
277
-			Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) );
276
+			update_option('give_earnings_total', give_get_total_earnings(true));
277
+			Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
278 278
 
279
-			$this->delete_option( $this->donation_key );
279
+			$this->delete_option($this->donation_key);
280 280
 
281 281
 			// Reset the sequential order numbers
282
-			if ( give_get_option( 'enable_sequential' ) ) {
283
-				delete_option( 'give_last_payment_number' );
282
+			if (give_get_option('enable_sequential')) {
283
+				delete_option('give_last_payment_number');
284 284
 			}
285 285
 
286 286
 			$this->done    = true;
287
-			$this->message = __( 'Imported donor and transactions successfully deleted.', 'give' );
287
+			$this->message = __('Imported donor and transactions successfully deleted.', 'give');
288 288
 
289 289
 			return false;
290 290
 		}
@@ -302,12 +302,12 @@  discard block
 block discarded – undo
302 302
 	public function get_data() {
303 303
 
304 304
 		// Get the donation id's.
305
-		$donation_ids = $this->get_option( $this->donation_key );
305
+		$donation_ids = $this->get_option($this->donation_key);
306 306
 
307 307
 		/**
308 308
 		 * Return false id not Import donation is found.
309 309
 		 */
310
-		if ( empty( $donation_ids ) ) {
310
+		if (empty($donation_ids)) {
311 311
 			$this->is_empty   = true;
312 312
 			$this->total_step = 1;
313 313
 
@@ -318,110 +318,110 @@  discard block
 block discarded – undo
318 318
 		$step = (int) $this->get_step();
319 319
 
320 320
 		// get teh donor ids.
321
-		$donor_ids = $this->get_option( $this->donor_key );
321
+		$donor_ids = $this->get_option($this->donor_key);
322 322
 
323 323
 		// In step to we delete all the donation in loop.
324
-		if ( 2 === $step ) {
324
+		if (2 === $step) {
325 325
 			$pass_to_donor = false;
326 326
 			$page          = (int) $this->get_step_page();
327
-			$page ++;
328
-			$count = count( $donation_ids );
327
+			$page++;
328
+			$count = count($donation_ids);
329 329
 
330
-			$this->total_step     = ( ( count( $donation_ids ) / $this->per_step ) * 2 ) + count( $donor_ids );
330
+			$this->total_step     = ((count($donation_ids) / $this->per_step) * 2) + count($donor_ids);
331 331
 			$this->step_completed = $page;
332 332
 
333 333
 
334
-			if ( $count > $this->per_step ) {
334
+			if ($count > $this->per_step) {
335 335
 
336
-				$this->update_option( $this->step_on_key, $page );
337
-				$donation_ids = $this->get_delete_ids( $donation_ids, $page );
338
-				$current_page = (int) ceil( $count / $this->per_step );
336
+				$this->update_option($this->step_on_key, $page);
337
+				$donation_ids = $this->get_delete_ids($donation_ids, $page);
338
+				$current_page = (int) ceil($count / $this->per_step);
339 339
 
340
-				if ( $page === $current_page ) {
340
+				if ($page === $current_page) {
341 341
 					$pass_to_donor = true;
342 342
 				}
343 343
 			} else {
344 344
 				$pass_to_donor = true;
345 345
 			}
346 346
 
347
-			if ( true === $pass_to_donor ) {
348
-				$this->update_option( $this->step_key, 'donor' );
349
-				$this->update_option( $this->step_on_key, '0' );
347
+			if (true === $pass_to_donor) {
348
+				$this->update_option($this->step_key, 'donor');
349
+				$this->update_option($this->step_on_key, '0');
350 350
 			}
351 351
 
352 352
 			// Get the old form list.
353
-			$form_ids = (array) $this->get_option( $this->form_key );
353
+			$form_ids = (array) $this->get_option($this->form_key);
354 354
 
355
-			foreach ( $donation_ids as $item ) {
356
-				$form_ids[] = give_get_meta( $item, '_give_payment_form_id', true );
355
+			foreach ($donation_ids as $item) {
356
+				$form_ids[] = give_get_meta($item, '_give_payment_form_id', true);
357 357
 
358 358
 				// Delete the main payment.
359
-				give_delete_donation( absint( $item ) );
359
+				give_delete_donation(absint($item));
360 360
 			}
361 361
 
362 362
 			// update the new form list.
363
-			$this->update_option( $this->form_key, $form_ids );
363
+			$this->update_option($this->form_key, $form_ids);
364 364
 		}
365 365
 
366 366
 
367 367
 		// Here we delete all the donor
368
-		if ( 3 === $step ) {
368
+		if (3 === $step) {
369 369
 
370 370
 			// Get the old form list.
371
-			$form_ids = (array) $this->get_option( $this->form_key );
372
-			if ( ! empty( $form_ids ) ) {
373
-				$form_ids = array_unique( $form_ids );
374
-				foreach ( $form_ids as $form_id ) {
375
-					give_recount_form_income_donation( (int) $form_id );
371
+			$form_ids = (array) $this->get_option($this->form_key);
372
+			if ( ! empty($form_ids)) {
373
+				$form_ids = array_unique($form_ids);
374
+				foreach ($form_ids as $form_id) {
375
+					give_recount_form_income_donation((int) $form_id);
376 376
 				}
377 377
 			}
378 378
 			// update the new form list.
379
-			$this->update_option( $this->form_key, array() );
379
+			$this->update_option($this->form_key, array());
380 380
 
381 381
 			$page  = (int) $this->get_step_page();
382
-			$count = count( $donor_ids );
382
+			$count = count($donor_ids);
383 383
 
384
-			$this->total_step     = ( ( count( $donation_ids ) / $this->per_step ) * 2 ) + count( $donor_ids );
385
-			$this->step_completed = $page + ( count( $donation_ids ) / $this->per_step );
384
+			$this->total_step     = ((count($donation_ids) / $this->per_step) * 2) + count($donor_ids);
385
+			$this->step_completed = $page + (count($donation_ids) / $this->per_step);
386 386
 
387
-			if ( ! empty( $donor_ids[ $page ] ) ) {
388
-				$args = apply_filters( 'give_tools_reset_stats_total_args', array(
387
+			if ( ! empty($donor_ids[$page])) {
388
+				$args = apply_filters('give_tools_reset_stats_total_args', array(
389 389
 					'post_status'    => 'any',
390 390
 					'posts_per_page' => 1,
391
-					'author'         => $donor_ids[ $page ]
392
-				) );
391
+					'author'         => $donor_ids[$page]
392
+				));
393 393
 
394 394
 				$donations = array();
395
-				$payments  = new Give_Payments_Query( $args );
395
+				$payments  = new Give_Payments_Query($args);
396 396
 				$payments  = $payments->get_payments();
397
-				if ( empty( $payments ) ) {
398
-					Give()->donors->delete_by_user_id( $donor_ids[ $page ] );
397
+				if (empty($payments)) {
398
+					Give()->donors->delete_by_user_id($donor_ids[$page]);
399 399
 
400 400
 					/**
401 401
 					 * If Checked then delete WP user.
402 402
 					 *
403 403
 					 * @since 1.8.14
404 404
 					 */
405
-					if ( 'on' === (string) $_REQUEST['delete-import-donors'] ) {
406
-						wp_delete_user( $donor_ids[ $page ] );
405
+					if ('on' === (string) $_REQUEST['delete-import-donors']) {
406
+						wp_delete_user($donor_ids[$page]);
407 407
 					}
408 408
 				} else {
409
-					foreach ( $payments as $payment ) {
409
+					foreach ($payments as $payment) {
410 410
 						$donations[] = $payment->ID;
411 411
 					}
412 412
 
413
-					$donor          = new Give_Donor( $donor_ids[ $page ], true );
413
+					$donor          = new Give_Donor($donor_ids[$page], true);
414 414
 					$data_to_update = array(
415
-						'purchase_count' => count( $donations ),
416
-						'payment_ids'    => implode( ',', $donations ),
415
+						'purchase_count' => count($donations),
416
+						'payment_ids'    => implode(',', $donations),
417 417
 					);
418
-					$donor->update( $data_to_update );
418
+					$donor->update($data_to_update);
419 419
 				}
420 420
 			}
421 421
 
422
-			$page ++;
423
-			$this->update_option( $this->step_on_key, $page );
424
-			if ( $count === $page ) {
422
+			$page++;
423
+			$this->update_option($this->step_on_key, $page);
424
+			if ($count === $page) {
425 425
 				$this->is_empty = false;
426 426
 
427 427
 				return false;
@@ -433,24 +433,24 @@  discard block
 block discarded – undo
433 433
 		return true;
434 434
 	}
435 435
 
436
-	public function get_delete_ids( $donation_ids, $page ) {
437
-		$index            = $page --;
438
-		$count            = count( $donation_ids );
436
+	public function get_delete_ids($donation_ids, $page) {
437
+		$index            = $page--;
438
+		$count            = count($donation_ids);
439 439
 		$temp             = 0;
440 440
 		$current_page     = 0;
441 441
 		$post_delete      = $this->per_step;
442 442
 		$page_donation_id = array();
443 443
 
444
-		foreach ( $donation_ids as $item ) {
445
-			$temp ++;
446
-			$page_donation_id[ $current_page ][] = $item;
447
-			if ( $temp === $post_delete ) {
448
-				$current_page ++;
444
+		foreach ($donation_ids as $item) {
445
+			$temp++;
446
+			$page_donation_id[$current_page][] = $item;
447
+			if ($temp === $post_delete) {
448
+				$current_page++;
449 449
 				$temp = 0;
450 450
 			}
451 451
 		}
452 452
 
453
-		return $page_donation_id[ $page ];
453
+		return $page_donation_id[$page];
454 454
 	}
455 455
 
456 456
 	/**
@@ -462,8 +462,8 @@  discard block
 block discarded – undo
462 462
 	 *
463 463
 	 * @return mixed       Returns the data from the database
464 464
 	 */
465
-	public function get_option( $key, $defalut_value = false ) {
466
-		return get_option( $key, $defalut_value );
465
+	public function get_option($key, $defalut_value = false) {
466
+		return get_option($key, $defalut_value);
467 467
 	}
468 468
 
469 469
 	/**
@@ -476,8 +476,8 @@  discard block
 block discarded – undo
476 476
 	 *
477 477
 	 * @return void
478 478
 	 */
479
-	public function update_option( $key, $value ) {
480
-		update_option( $key, $value, false );
479
+	public function update_option($key, $value) {
480
+		update_option($key, $value, false);
481 481
 	}
482 482
 
483 483
 	/**
@@ -489,8 +489,8 @@  discard block
 block discarded – undo
489 489
 	 *
490 490
 	 * @return void
491 491
 	 */
492
-	public function delete_option( $key ) {
493
-		delete_option( $key );
492
+	public function delete_option($key) {
493
+		delete_option($key);
494 494
 	}
495 495
 
496 496
 	/**
@@ -501,12 +501,12 @@  discard block
 block discarded – undo
501 501
 	 * @return int|string
502 502
 	 */
503 503
 	private function get_step() {
504
-		$step_key = (string) $this->get_option( $this->step_key, false );
505
-		if ( 'count' === $step_key ) {
504
+		$step_key = (string) $this->get_option($this->step_key, false);
505
+		if ('count' === $step_key) {
506 506
 			return 1;
507
-		} elseif ( 'donation' === $step_key ) {
507
+		} elseif ('donation' === $step_key) {
508 508
 			return 2;
509
-		} elseif ( 'donor' === $step_key ) {
509
+		} elseif ('donor' === $step_key) {
510 510
 			return 3;
511 511
 		} else {
512 512
 			return $step_key;
@@ -517,6 +517,6 @@  discard block
 block discarded – undo
517 517
 	 * Get the current $page value in the ajax.
518 518
 	 */
519 519
 	private function get_step_page() {
520
-		return $this->get_option( $this->step_on_key, false );
520
+		return $this->get_option($this->step_on_key, false);
521 521
 	}
522 522
 }
Please login to merge, or discard this patch.
includes/class-give-donor.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -918,7 +918,7 @@
 block discarded – undo
918 918
 	 * @access public
919 919
 	 *
920 920
 	 * @param  string $meta_key Metadata name. Default is empty.
921
-	 * @param  mixed $meta_value Optional. Metadata value. Default is empty.
921
+	 * @param  string $meta_value Optional. Metadata value. Default is empty.
922 922
 	 *
923 923
 	 * @return bool               False for failure. True for success.
924 924
 	 */
Please login to merge, or discard this patch.
Spacing   +253 added lines, -260 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
 
@@ -149,32 +149,32 @@  discard block
 block discarded – undo
149 149
 	 * @param int|bool $_id_or_email
150 150
 	 * @param bool     $by_user_id
151 151
 	 */
152
-	public function __construct( $_id_or_email = false, $by_user_id = false ) {
152
+	public function __construct($_id_or_email = false, $by_user_id = false) {
153 153
 
154 154
 		$this->db = Give()->donors;
155 155
 
156 156
 		if (
157 157
 			false === $_id_or_email
158
-			|| ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) )
158
+			|| (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email))
159 159
 		) {
160 160
 			return false;
161 161
 		}
162 162
 
163
-		$by_user_id = is_bool( $by_user_id ) ? $by_user_id : false;
163
+		$by_user_id = is_bool($by_user_id) ? $by_user_id : false;
164 164
 
165
-		if ( is_numeric( $_id_or_email ) ) {
165
+		if (is_numeric($_id_or_email)) {
166 166
 			$field = $by_user_id ? 'user_id' : 'id';
167 167
 		} else {
168 168
 			$field = 'email';
169 169
 		}
170 170
 
171
-		$donor = $this->db->get_donor_by( $field, $_id_or_email );
171
+		$donor = $this->db->get_donor_by($field, $_id_or_email);
172 172
 
173
-		if ( empty( $donor ) || ! is_object( $donor ) ) {
173
+		if (empty($donor) || ! is_object($donor)) {
174 174
 			return false;
175 175
 		}
176 176
 
177
-		$this->setup_donor( $donor );
177
+		$this->setup_donor($donor);
178 178
 
179 179
 	}
180 180
 
@@ -190,19 +190,19 @@  discard block
 block discarded – undo
190 190
 	 *
191 191
 	 * @return bool             If the setup was successful or not.
192 192
 	 */
193
-	private function setup_donor( $donor ) {
193
+	private function setup_donor($donor) {
194 194
 
195
-		if ( ! is_object( $donor ) ) {
195
+		if ( ! is_object($donor)) {
196 196
 			return false;
197 197
 		}
198 198
 
199 199
 		// Get cached donors.
200
-		$donor_vars = Give_Cache::get_group( $donor->id, 'give-donors' );
200
+		$donor_vars = Give_Cache::get_group($donor->id, 'give-donors');
201 201
 
202
-		if( is_null( $donor_vars ) ){
203
-			foreach ( $donor as $key => $value ) {
202
+		if (is_null($donor_vars)) {
203
+			foreach ($donor as $key => $value) {
204 204
 
205
-				switch ( $key ) {
205
+				switch ($key) {
206 206
 
207 207
 					case 'notes':
208 208
 						$this->$key = $this->get_notes();
@@ -216,20 +216,20 @@  discard block
 block discarded – undo
216 216
 			}
217 217
 
218 218
 			// Get donor's all email including primary email.
219
-			$this->emails = (array) $this->get_meta( 'additional_email', false );
220
-			$this->emails = array( 'primary' => $this->email ) + $this->emails;
219
+			$this->emails = (array) $this->get_meta('additional_email', false);
220
+			$this->emails = array('primary' => $this->email) + $this->emails;
221 221
 
222 222
 			$this->setup_address();
223 223
 
224
-			Give_Cache::set_group( $donor->id, get_object_vars( $this ), 'give-donors' );
225
-		} else{
226
-			foreach ( $donor_vars as $donor_var => $value ) {
224
+			Give_Cache::set_group($donor->id, get_object_vars($this), 'give-donors');
225
+		} else {
226
+			foreach ($donor_vars as $donor_var => $value) {
227 227
 				$this->$donor_var = $value;
228 228
 			}
229 229
 		}
230 230
 
231 231
 		// Donor ID and email are the only things that are necessary, make sure they exist.
232
-		if ( ! empty( $this->id ) && ! empty( $this->email ) ) {
232
+		if ( ! empty($this->id) && ! empty($this->email)) {
233 233
 			return true;
234 234
 		}
235 235
 
@@ -262,18 +262,18 @@  discard block
 block discarded – undo
262 262
 			ARRAY_N
263 263
 		);
264 264
 
265
-		if ( empty( $addresses ) ) {
265
+		if (empty($addresses)) {
266 266
 			return $this->address;
267 267
 		}
268 268
 
269
-		foreach ( $addresses as $address ) {
270
-			$address[0] = str_replace( '_give_donor_address_', '', $address[0] );
271
-			$address[0] = explode( '_', $address[0] );
269
+		foreach ($addresses as $address) {
270
+			$address[0] = str_replace('_give_donor_address_', '', $address[0]);
271
+			$address[0] = explode('_', $address[0]);
272 272
 
273
-			if ( 3 === count( $address[0] ) ) {
274
-				$this->address[ $address[0][0] ][ $address[0][2] ][ $address[0][1] ] = $address[1];
273
+			if (3 === count($address[0])) {
274
+				$this->address[$address[0][0]][$address[0][2]][$address[0][1]] = $address[1];
275 275
 			} else {
276
-				$this->address[ $address[0][0] ][ $address[0][1] ] = $address[1];
276
+				$this->address[$address[0][0]][$address[0][1]] = $address[1];
277 277
 			}
278 278
 		}
279 279
 	}
@@ -287,16 +287,16 @@  discard block
 block discarded – undo
287 287
 	 *
288 288
 	 * @return mixed|\WP_Error
289 289
 	 */
290
-	public function __get( $key ) {
290
+	public function __get($key) {
291 291
 
292
-		if ( method_exists( $this, 'get_' . $key ) ) {
292
+		if (method_exists($this, 'get_'.$key)) {
293 293
 
294
-			return call_user_func( array( $this, 'get_' . $key ) );
294
+			return call_user_func(array($this, 'get_'.$key));
295 295
 
296 296
 		} else {
297 297
 
298 298
 			/* translators: %s: property key */
299
-			return new WP_Error( 'give-donor-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) );
299
+			return new WP_Error('give-donor-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key));
300 300
 
301 301
 		}
302 302
 
@@ -312,9 +312,9 @@  discard block
 block discarded – undo
312 312
 	 *
313 313
 	 * @return bool|int    False if not a valid creation, donor ID if user is found or valid creation.
314 314
 	 */
315
-	public function create( $data = array() ) {
315
+	public function create($data = array()) {
316 316
 
317
-		if ( $this->id != 0 || empty( $data ) ) {
317
+		if ($this->id != 0 || empty($data)) {
318 318
 			return false;
319 319
 		}
320 320
 
@@ -322,15 +322,15 @@  discard block
 block discarded – undo
322 322
 			'payment_ids' => '',
323 323
 		);
324 324
 
325
-		$args = wp_parse_args( $data, $defaults );
326
-		$args = $this->sanitize_columns( $args );
325
+		$args = wp_parse_args($data, $defaults);
326
+		$args = $this->sanitize_columns($args);
327 327
 
328
-		if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) {
328
+		if (empty($args['email']) || ! is_email($args['email'])) {
329 329
 			return false;
330 330
 		}
331 331
 
332
-		if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) {
333
-			$args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) );
332
+		if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) {
333
+			$args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids'])));
334 334
 		}
335 335
 
336 336
 		/**
@@ -340,18 +340,18 @@  discard block
 block discarded – undo
340 340
 		 *
341 341
 		 * @param array $args Donor attributes.
342 342
 		 */
343
-		do_action( 'give_donor_pre_create', $args );
343
+		do_action('give_donor_pre_create', $args);
344 344
 
345 345
 		$created = false;
346 346
 
347 347
 		// The DB class 'add' implies an update if the donor being asked to be created already exists
348
-		if ( $this->db->add( $data ) ) {
348
+		if ($this->db->add($data)) {
349 349
 
350 350
 			// We've successfully added/updated the donor, reset the class vars with the new data
351
-			$donor = $this->db->get_donor_by( 'email', $args['email'] );
351
+			$donor = $this->db->get_donor_by('email', $args['email']);
352 352
 
353 353
 			// Setup the donor data with the values from DB
354
-			$this->setup_donor( $donor );
354
+			$this->setup_donor($donor);
355 355
 
356 356
 			$created = $this->id;
357 357
 		}
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 		 * @param bool|int $created False if not a valid creation, donor ID if user is found or valid creation.
365 365
 		 * @param array $args Customer attributes.
366 366
 		 */
367
-		do_action( 'give_donor_post_create', $created, $args );
367
+		do_action('give_donor_post_create', $created, $args);
368 368
 
369 369
 		return $created;
370 370
 
@@ -380,13 +380,13 @@  discard block
 block discarded – undo
380 380
 	 *
381 381
 	 * @return bool        If the update was successful or not.
382 382
 	 */
383
-	public function update( $data = array() ) {
383
+	public function update($data = array()) {
384 384
 
385
-		if ( empty( $data ) ) {
385
+		if (empty($data)) {
386 386
 			return false;
387 387
 		}
388 388
 
389
-		$data = $this->sanitize_columns( $data );
389
+		$data = $this->sanitize_columns($data);
390 390
 
391 391
 		/**
392 392
 		 * Fires before updating donors.
@@ -396,15 +396,15 @@  discard block
 block discarded – undo
396 396
 		 * @param int $donor_id Donor id.
397 397
 		 * @param array $data Donor attributes.
398 398
 		 */
399
-		do_action( 'give_donor_pre_update', $this->id, $data );
399
+		do_action('give_donor_pre_update', $this->id, $data);
400 400
 
401 401
 		$updated = false;
402 402
 
403
-		if ( $this->db->update( $this->id, $data ) ) {
403
+		if ($this->db->update($this->id, $data)) {
404 404
 
405
-			$donor = $this->db->get_donor_by( 'id', $this->id );
405
+			$donor = $this->db->get_donor_by('id', $this->id);
406 406
 
407
-			$this->setup_donor( $donor );
407
+			$this->setup_donor($donor);
408 408
 
409 409
 			$updated = true;
410 410
 		}
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 		 * @param int $donor_id Donor id.
419 419
 		 * @param array $data Donor attributes.
420 420
 		 */
421
-		do_action( 'give_donor_post_update', $updated, $this->id, $data );
421
+		do_action('give_donor_post_update', $updated, $this->id, $data);
422 422
 
423 423
 		return $updated;
424 424
 	}
@@ -436,27 +436,27 @@  discard block
 block discarded – undo
436 436
 	 *
437 437
 	 * @return bool            If the attachment was successfully.
438 438
 	 */
439
-	public function attach_payment( $payment_id = 0, $update_stats = true ) {
439
+	public function attach_payment($payment_id = 0, $update_stats = true) {
440 440
 
441
-		if ( empty( $payment_id ) ) {
441
+		if (empty($payment_id)) {
442 442
 			return false;
443 443
 		}
444 444
 
445
-		if ( empty( $this->payment_ids ) ) {
445
+		if (empty($this->payment_ids)) {
446 446
 
447 447
 			$new_payment_ids = $payment_id;
448 448
 
449 449
 		} else {
450 450
 
451
-			$payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) );
451
+			$payment_ids = array_map('absint', explode(',', $this->payment_ids));
452 452
 
453
-			if ( in_array( $payment_id, $payment_ids ) ) {
453
+			if (in_array($payment_id, $payment_ids)) {
454 454
 				$update_stats = false;
455 455
 			}
456 456
 
457 457
 			$payment_ids[] = $payment_id;
458 458
 
459
-			$new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
459
+			$new_payment_ids = implode(',', array_unique(array_values($payment_ids)));
460 460
 
461 461
 		}
462 462
 
@@ -468,20 +468,20 @@  discard block
 block discarded – undo
468 468
 		 * @param int $payment_id Payment id.
469 469
 		 * @param int $donor_id Customer id.
470 470
 		 */
471
-		do_action( 'give_donor_pre_attach_payment', $payment_id, $this->id );
471
+		do_action('give_donor_pre_attach_payment', $payment_id, $this->id);
472 472
 
473
-		$payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) );
473
+		$payment_added = $this->update(array('payment_ids' => $new_payment_ids));
474 474
 
475
-		if ( $payment_added ) {
475
+		if ($payment_added) {
476 476
 
477 477
 			$this->payment_ids = $new_payment_ids;
478 478
 
479 479
 			// We added this payment successfully, increment the stats
480
-			if ( $update_stats ) {
481
-				$payment_amount = give_donation_amount( $payment_id, array( 'type' => 'stats' ) );
480
+			if ($update_stats) {
481
+				$payment_amount = give_donation_amount($payment_id, array('type' => 'stats'));
482 482
 
483
-				if ( ! empty( $payment_amount ) ) {
484
-					$this->increase_value( $payment_amount );
483
+				if ( ! empty($payment_amount)) {
484
+					$this->increase_value($payment_amount);
485 485
 				}
486 486
 
487 487
 				$this->increase_purchase_count();
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
 		 * @param int $payment_id Payment id.
498 498
 		 * @param int $donor_id Donor id.
499 499
 		 */
500
-		do_action( 'give_donor_post_attach_payment', $payment_added, $payment_id, $this->id );
500
+		do_action('give_donor_post_attach_payment', $payment_added, $payment_id, $this->id);
501 501
 
502 502
 		return $payment_added;
503 503
 	}
@@ -515,33 +515,33 @@  discard block
 block discarded – undo
515 515
 	 *
516 516
 	 * @return boolean               If the removal was successful.
517 517
 	 */
518
-	public function remove_payment( $payment_id = 0, $update_stats = true ) {
518
+	public function remove_payment($payment_id = 0, $update_stats = true) {
519 519
 
520
-		if ( empty( $payment_id ) ) {
520
+		if (empty($payment_id)) {
521 521
 			return false;
522 522
 		}
523 523
 
524
-		$payment = new Give_Payment( $payment_id );
524
+		$payment = new Give_Payment($payment_id);
525 525
 
526
-		if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) {
526
+		if ('publish' !== $payment->status && 'revoked' !== $payment->status) {
527 527
 			$update_stats = false;
528 528
 		}
529 529
 
530 530
 		$new_payment_ids = '';
531 531
 
532
-		if ( ! empty( $this->payment_ids ) ) {
532
+		if ( ! empty($this->payment_ids)) {
533 533
 
534
-			$payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) );
534
+			$payment_ids = array_map('absint', explode(',', $this->payment_ids));
535 535
 
536
-			$pos = array_search( $payment_id, $payment_ids );
537
-			if ( false === $pos ) {
536
+			$pos = array_search($payment_id, $payment_ids);
537
+			if (false === $pos) {
538 538
 				return false;
539 539
 			}
540 540
 
541
-			unset( $payment_ids[ $pos ] );
542
-			$payment_ids = array_filter( $payment_ids );
541
+			unset($payment_ids[$pos]);
542
+			$payment_ids = array_filter($payment_ids);
543 543
 
544
-			$new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
544
+			$new_payment_ids = implode(',', array_unique(array_values($payment_ids)));
545 545
 
546 546
 		}
547 547
 
@@ -553,20 +553,20 @@  discard block
 block discarded – undo
553 553
 		 * @param int $payment_id Payment id.
554 554
 		 * @param int $donor_id Customer id.
555 555
 		 */
556
-		do_action( 'give_donor_pre_remove_payment', $payment_id, $this->id );
556
+		do_action('give_donor_pre_remove_payment', $payment_id, $this->id);
557 557
 
558
-		$payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) );
558
+		$payment_removed = $this->update(array('payment_ids' => $new_payment_ids));
559 559
 
560
-		if ( $payment_removed ) {
560
+		if ($payment_removed) {
561 561
 
562 562
 			$this->payment_ids = $new_payment_ids;
563 563
 
564
-			if ( $update_stats ) {
564
+			if ($update_stats) {
565 565
 				// We removed this payment successfully, decrement the stats
566
-				$payment_amount = give_donation_amount( $payment_id );
566
+				$payment_amount = give_donation_amount($payment_id);
567 567
 
568
-				if ( ! empty( $payment_amount ) ) {
569
-					$this->decrease_value( $payment_amount );
568
+				if ( ! empty($payment_amount)) {
569
+					$this->decrease_value($payment_amount);
570 570
 				}
571 571
 
572 572
 				$this->decrease_donation_count();
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
 		 * @param int $payment_id Payment id.
583 583
 		 * @param int $donor_id Donor id.
584 584
 		 */
585
-		do_action( 'give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id );
585
+		do_action('give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id);
586 586
 
587 587
 		return $payment_removed;
588 588
 
@@ -598,10 +598,10 @@  discard block
 block discarded – undo
598 598
 	 *
599 599
 	 * @return int        The donation count.
600 600
 	 */
601
-	public function increase_purchase_count( $count = 1 ) {
601
+	public function increase_purchase_count($count = 1) {
602 602
 
603 603
 		// Make sure it's numeric and not negative.
604
-		if ( ! is_numeric( $count ) || $count != absint( $count ) ) {
604
+		if ( ! is_numeric($count) || $count != absint($count)) {
605 605
 			return false;
606 606
 		}
607 607
 
@@ -615,9 +615,9 @@  discard block
 block discarded – undo
615 615
 		 * @param int $count The number to increase by.
616 616
 		 * @param int $donor_id Donor id.
617 617
 		 */
618
-		do_action( 'give_donor_pre_increase_donation_count', $count, $this->id );
618
+		do_action('give_donor_pre_increase_donation_count', $count, $this->id);
619 619
 
620
-		if ( $this->update( array( 'purchase_count' => $new_total ) ) ) {
620
+		if ($this->update(array('purchase_count' => $new_total))) {
621 621
 			$this->purchase_count = $new_total;
622 622
 		}
623 623
 
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 		 * @param int $count The number increased by.
631 631
 		 * @param int $donor_id Donor id.
632 632
 		 */
633
-		do_action( 'give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id );
633
+		do_action('give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id);
634 634
 
635 635
 		return $this->purchase_count;
636 636
 	}
@@ -645,16 +645,16 @@  discard block
 block discarded – undo
645 645
 	 *
646 646
 	 * @return mixed      If successful, the new count, otherwise false.
647 647
 	 */
648
-	public function decrease_donation_count( $count = 1 ) {
648
+	public function decrease_donation_count($count = 1) {
649 649
 
650 650
 		// Make sure it's numeric and not negative
651
-		if ( ! is_numeric( $count ) || $count != absint( $count ) ) {
651
+		if ( ! is_numeric($count) || $count != absint($count)) {
652 652
 			return false;
653 653
 		}
654 654
 
655 655
 		$new_total = (int) $this->purchase_count - (int) $count;
656 656
 
657
-		if ( $new_total < 0 ) {
657
+		if ($new_total < 0) {
658 658
 			$new_total = 0;
659 659
 		}
660 660
 
@@ -666,9 +666,9 @@  discard block
 block discarded – undo
666 666
 		 * @param int $count The number to decrease by.
667 667
 		 * @param int $donor_id Customer id.
668 668
 		 */
669
-		do_action( 'give_donor_pre_decrease_donation_count', $count, $this->id );
669
+		do_action('give_donor_pre_decrease_donation_count', $count, $this->id);
670 670
 
671
-		if ( $this->update( array( 'purchase_count' => $new_total ) ) ) {
671
+		if ($this->update(array('purchase_count' => $new_total))) {
672 672
 			$this->purchase_count = $new_total;
673 673
 		}
674 674
 
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
 		 * @param int $count The number decreased by.
682 682
 		 * @param int $donor_id Donor id.
683 683
 		 */
684
-		do_action( 'give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id );
684
+		do_action('give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id);
685 685
 
686 686
 		return $this->purchase_count;
687 687
 	}
@@ -696,9 +696,9 @@  discard block
 block discarded – undo
696 696
 	 *
697 697
 	 * @return mixed        If successful, the new value, otherwise false.
698 698
 	 */
699
-	public function increase_value( $value = 0.00 ) {
699
+	public function increase_value($value = 0.00) {
700 700
 
701
-		$new_value = floatval( $this->purchase_value ) + $value;
701
+		$new_value = floatval($this->purchase_value) + $value;
702 702
 
703 703
 		/**
704 704
 		 * Fires before increasing donor lifetime value.
@@ -708,9 +708,9 @@  discard block
 block discarded – undo
708 708
 		 * @param float $value The value to increase by.
709 709
 		 * @param int $donor_id Customer id.
710 710
 		 */
711
-		do_action( 'give_donor_pre_increase_value', $value, $this->id );
711
+		do_action('give_donor_pre_increase_value', $value, $this->id);
712 712
 
713
-		if ( $this->update( array( 'purchase_value' => $new_value ) ) ) {
713
+		if ($this->update(array('purchase_value' => $new_value))) {
714 714
 			$this->purchase_value = $new_value;
715 715
 		}
716 716
 
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 		 * @param float $value The value increased by.
724 724
 		 * @param int $donor_id Donor id.
725 725
 		 */
726
-		do_action( 'give_donor_post_increase_value', $this->purchase_value, $value, $this->id );
726
+		do_action('give_donor_post_increase_value', $this->purchase_value, $value, $this->id);
727 727
 
728 728
 		return $this->purchase_value;
729 729
 	}
@@ -738,11 +738,11 @@  discard block
 block discarded – undo
738 738
 	 *
739 739
 	 * @return mixed        If successful, the new value, otherwise false.
740 740
 	 */
741
-	public function decrease_value( $value = 0.00 ) {
741
+	public function decrease_value($value = 0.00) {
742 742
 
743
-		$new_value = floatval( $this->purchase_value ) - $value;
743
+		$new_value = floatval($this->purchase_value) - $value;
744 744
 
745
-		if ( $new_value < 0 ) {
745
+		if ($new_value < 0) {
746 746
 			$new_value = 0.00;
747 747
 		}
748 748
 
@@ -754,9 +754,9 @@  discard block
 block discarded – undo
754 754
 		 * @param float $value The value to decrease by.
755 755
 		 * @param int $donor_id Donor id.
756 756
 		 */
757
-		do_action( 'give_donor_pre_decrease_value', $value, $this->id );
757
+		do_action('give_donor_pre_decrease_value', $value, $this->id);
758 758
 
759
-		if ( $this->update( array( 'purchase_value' => $new_value ) ) ) {
759
+		if ($this->update(array('purchase_value' => $new_value))) {
760 760
 			$this->purchase_value = $new_value;
761 761
 		}
762 762
 
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
 		 * @param float $value The value decreased by.
770 770
 		 * @param int $donor_id Donor id.
771 771
 		 */
772
-		do_action( 'give_donor_post_decrease_value', $this->purchase_value, $value, $this->id );
772
+		do_action('give_donor_post_decrease_value', $this->purchase_value, $value, $this->id);
773 773
 
774 774
 		return $this->purchase_value;
775 775
 	}
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
 	 *
789 789
 	 * @return mixed              If successful, the new donation stat value, otherwise false.
790 790
 	 */
791
-	public function update_donation_value( $curr_amount, $new_amount ) {
791
+	public function update_donation_value($curr_amount, $new_amount) {
792 792
 		/**
793 793
 		 * Payment total difference value can be:
794 794
 		 *  zero   (in case amount not change)
@@ -798,15 +798,15 @@  discard block
 block discarded – undo
798 798
 		$payment_total_diff = $new_amount - $curr_amount;
799 799
 
800 800
 		// We do not need to update donation stat if donation did not change.
801
-		if ( ! $payment_total_diff ) {
801
+		if ( ! $payment_total_diff) {
802 802
 			return false;
803 803
 		}
804 804
 
805
-		if ( $payment_total_diff > 0 ) {
806
-			$this->increase_value( $payment_total_diff );
805
+		if ($payment_total_diff > 0) {
806
+			$this->increase_value($payment_total_diff);
807 807
 		} else {
808 808
 			// Pass payment total difference as +ve value to decrease amount from user lifetime stat.
809
-			$this->decrease_value( - $payment_total_diff );
809
+			$this->decrease_value( -$payment_total_diff );
810 810
 		}
811 811
 
812 812
 		return $this->purchase_value;
@@ -823,15 +823,15 @@  discard block
 block discarded – undo
823 823
 	 *
824 824
 	 * @return array       The notes requested.
825 825
 	 */
826
-	public function get_notes( $length = 20, $paged = 1 ) {
826
+	public function get_notes($length = 20, $paged = 1) {
827 827
 
828
-		$length = is_numeric( $length ) ? $length : 20;
829
-		$offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0;
828
+		$length = is_numeric($length) ? $length : 20;
829
+		$offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0;
830 830
 
831 831
 		$all_notes   = $this->get_raw_notes();
832
-		$notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) );
832
+		$notes_array = array_reverse(array_filter(explode("\n\n", $all_notes)));
833 833
 
834
-		$desired_notes = array_slice( $notes_array, $offset, $length );
834
+		$desired_notes = array_slice($notes_array, $offset, $length);
835 835
 
836 836
 		return $desired_notes;
837 837
 
@@ -848,9 +848,9 @@  discard block
 block discarded – undo
848 848
 	public function get_notes_count() {
849 849
 
850 850
 		$all_notes   = $this->get_raw_notes();
851
-		$notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) );
851
+		$notes_array = array_reverse(array_filter(explode("\n\n", $all_notes)));
852 852
 
853
-		return count( $notes_array );
853
+		return count($notes_array);
854 854
 
855 855
 	}
856 856
 
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
 	 *
864 864
 	 * @return string|float
865 865
 	 */
866
-	public function get_total_donation_amount( $args = array() ) {
866
+	public function get_total_donation_amount($args = array()) {
867 867
 
868 868
 		/**
869 869
 		 * Filter total donation amount.
@@ -874,7 +874,7 @@  discard block
 block discarded – undo
874 874
 		 * @param integer      $donor_id       Donor ID.
875 875
 		 * @param array        $args           Pass additional data.
876 876
 		 */
877
-		return apply_filters( 'give_get_total_donation_amount', $this->purchase_value, $this->id, $args );
877
+		return apply_filters('give_get_total_donation_amount', $this->purchase_value, $this->id, $args);
878 878
 	}
879 879
 
880 880
 	/**
@@ -887,22 +887,22 @@  discard block
 block discarded – undo
887 887
 	 *
888 888
 	 * @return string|boolean The new note if added successfully, false otherwise.
889 889
 	 */
890
-	public function add_note( $note = '' ) {
890
+	public function add_note($note = '') {
891 891
 
892
-		$note = trim( $note );
893
-		if ( empty( $note ) ) {
892
+		$note = trim($note);
893
+		if (empty($note)) {
894 894
 			return false;
895 895
 		}
896 896
 
897 897
 		$notes = $this->get_raw_notes();
898 898
 
899
-		if ( empty( $notes ) ) {
899
+		if (empty($notes)) {
900 900
 			$notes = '';
901 901
 		}
902 902
 
903
-		$note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note;
904
-		$new_note    = apply_filters( 'give_customer_add_note_string', $note_string );
905
-		$notes       .= "\n\n" . $new_note;
903
+		$note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note;
904
+		$new_note    = apply_filters('give_customer_add_note_string', $note_string);
905
+		$notes .= "\n\n".$new_note;
906 906
 
907 907
 		/**
908 908
 		 * Fires before donor note is added.
@@ -912,11 +912,11 @@  discard block
 block discarded – undo
912 912
 		 * @param string $new_note New note to add.
913 913
 		 * @param int $donor_id Donor id.
914 914
 		 */
915
-		do_action( 'give_donor_pre_add_note', $new_note, $this->id );
915
+		do_action('give_donor_pre_add_note', $new_note, $this->id);
916 916
 
917
-		$updated = $this->update( array( 'notes' => $notes ) );
917
+		$updated = $this->update(array('notes' => $notes));
918 918
 
919
-		if ( $updated ) {
919
+		if ($updated) {
920 920
 			$this->notes = $this->get_notes();
921 921
 		}
922 922
 
@@ -929,7 +929,7 @@  discard block
 block discarded – undo
929 929
 		 * @param string $new_note New note added.
930 930
 		 * @param int $donor_id Donor id.
931 931
 		 */
932
-		do_action( 'give_donor_post_add_note', $this->notes, $new_note, $this->id );
932
+		do_action('give_donor_post_add_note', $this->notes, $new_note, $this->id);
933 933
 
934 934
 		// Return the formatted note, so we can test, as well as update any displays
935 935
 		return $new_note;
@@ -946,7 +946,7 @@  discard block
 block discarded – undo
946 946
 	 */
947 947
 	private function get_raw_notes() {
948 948
 
949
-		$all_notes = $this->db->get_column( 'notes', $this->id );
949
+		$all_notes = $this->db->get_column('notes', $this->id);
950 950
 
951 951
 		return $all_notes;
952 952
 
@@ -963,8 +963,8 @@  discard block
 block discarded – undo
963 963
 	 *
964 964
 	 * @return mixed            Will be an array if $single is false. Will be value of meta data field if $single is true.
965 965
 	 */
966
-	public function get_meta( $meta_key = '', $single = true ) {
967
-		return Give()->donor_meta->get_meta( $this->id, $meta_key, $single );
966
+	public function get_meta($meta_key = '', $single = true) {
967
+		return Give()->donor_meta->get_meta($this->id, $meta_key, $single);
968 968
 	}
969 969
 
970 970
 	/**
@@ -979,8 +979,8 @@  discard block
 block discarded – undo
979 979
 	 *
980 980
 	 * @return bool               False for failure. True for success.
981 981
 	 */
982
-	public function add_meta( $meta_key = '', $meta_value, $unique = false ) {
983
-		return Give()->donor_meta->add_meta( $this->id, $meta_key, $meta_value, $unique );
982
+	public function add_meta($meta_key = '', $meta_value, $unique = false) {
983
+		return Give()->donor_meta->add_meta($this->id, $meta_key, $meta_value, $unique);
984 984
 	}
985 985
 
986 986
 	/**
@@ -995,8 +995,8 @@  discard block
 block discarded – undo
995 995
 	 *
996 996
 	 * @return bool               False on failure, true if success.
997 997
 	 */
998
-	public function update_meta( $meta_key = '', $meta_value, $prev_value = '' ) {
999
-		return Give()->donor_meta->update_meta( $this->id, $meta_key, $meta_value, $prev_value );
998
+	public function update_meta($meta_key = '', $meta_value, $prev_value = '') {
999
+		return Give()->donor_meta->update_meta($this->id, $meta_key, $meta_value, $prev_value);
1000 1000
 	}
1001 1001
 
1002 1002
 	/**
@@ -1010,8 +1010,8 @@  discard block
 block discarded – undo
1010 1010
 	 *
1011 1011
 	 * @return bool               False for failure. True for success.
1012 1012
 	 */
1013
-	public function delete_meta( $meta_key = '', $meta_value = '' ) {
1014
-		return Give()->donor_meta->delete_meta( $this->id, $meta_key, $meta_value );
1013
+	public function delete_meta($meta_key = '', $meta_value = '') {
1014
+		return Give()->donor_meta->delete_meta($this->id, $meta_key, $meta_value);
1015 1015
 	}
1016 1016
 
1017 1017
 	/**
@@ -1024,51 +1024,51 @@  discard block
 block discarded – undo
1024 1024
 	 *
1025 1025
 	 * @return array       The sanitized data, based off column defaults.
1026 1026
 	 */
1027
-	private function sanitize_columns( $data ) {
1027
+	private function sanitize_columns($data) {
1028 1028
 
1029 1029
 		$columns        = $this->db->get_columns();
1030 1030
 		$default_values = $this->db->get_column_defaults();
1031 1031
 
1032
-		foreach ( $columns as $key => $type ) {
1032
+		foreach ($columns as $key => $type) {
1033 1033
 
1034 1034
 			// Only sanitize data that we were provided
1035
-			if ( ! array_key_exists( $key, $data ) ) {
1035
+			if ( ! array_key_exists($key, $data)) {
1036 1036
 				continue;
1037 1037
 			}
1038 1038
 
1039
-			switch ( $type ) {
1039
+			switch ($type) {
1040 1040
 
1041 1041
 				case '%s':
1042
-					if ( 'email' == $key ) {
1043
-						$data[ $key ] = sanitize_email( $data[ $key ] );
1044
-					} elseif ( 'notes' == $key ) {
1045
-						$data[ $key ] = strip_tags( $data[ $key ] );
1042
+					if ('email' == $key) {
1043
+						$data[$key] = sanitize_email($data[$key]);
1044
+					} elseif ('notes' == $key) {
1045
+						$data[$key] = strip_tags($data[$key]);
1046 1046
 					} else {
1047
-						$data[ $key ] = sanitize_text_field( $data[ $key ] );
1047
+						$data[$key] = sanitize_text_field($data[$key]);
1048 1048
 					}
1049 1049
 					break;
1050 1050
 
1051 1051
 				case '%d':
1052
-					if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) {
1053
-						$data[ $key ] = $default_values[ $key ];
1052
+					if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) {
1053
+						$data[$key] = $default_values[$key];
1054 1054
 					} else {
1055
-						$data[ $key ] = absint( $data[ $key ] );
1055
+						$data[$key] = absint($data[$key]);
1056 1056
 					}
1057 1057
 					break;
1058 1058
 
1059 1059
 				case '%f':
1060 1060
 					// Convert what was given to a float
1061
-					$value = floatval( $data[ $key ] );
1061
+					$value = floatval($data[$key]);
1062 1062
 
1063
-					if ( ! is_float( $value ) ) {
1064
-						$data[ $key ] = $default_values[ $key ];
1063
+					if ( ! is_float($value)) {
1064
+						$data[$key] = $default_values[$key];
1065 1065
 					} else {
1066
-						$data[ $key ] = $value;
1066
+						$data[$key] = $value;
1067 1067
 					}
1068 1068
 					break;
1069 1069
 
1070 1070
 				default:
1071
-					$data[ $key ] = sanitize_text_field( $data[ $key ] );
1071
+					$data[$key] = sanitize_text_field($data[$key]);
1072 1072
 					break;
1073 1073
 
1074 1074
 			}
@@ -1088,33 +1088,33 @@  discard block
 block discarded – undo
1088 1088
 	 *
1089 1089
 	 * @return bool            If the email was added successfully
1090 1090
 	 */
1091
-	public function add_email( $email = '', $primary = false ) {
1092
-		if ( ! is_email( $email ) ) {
1091
+	public function add_email($email = '', $primary = false) {
1092
+		if ( ! is_email($email)) {
1093 1093
 			return false;
1094 1094
 		}
1095
-		$existing = new Give_Donor( $email );
1095
+		$existing = new Give_Donor($email);
1096 1096
 
1097
-		if ( $existing->id > 0 ) {
1097
+		if ($existing->id > 0) {
1098 1098
 			// Email address already belongs to another donor
1099 1099
 			return false;
1100 1100
 		}
1101 1101
 
1102
-		if ( email_exists( $email ) ) {
1103
-			$user = get_user_by( 'email', $email );
1104
-			if ( $user->ID != $this->user_id ) {
1102
+		if (email_exists($email)) {
1103
+			$user = get_user_by('email', $email);
1104
+			if ($user->ID != $this->user_id) {
1105 1105
 				return false;
1106 1106
 			}
1107 1107
 		}
1108 1108
 
1109
-		do_action( 'give_donor_pre_add_email', $email, $this->id, $this );
1109
+		do_action('give_donor_pre_add_email', $email, $this->id, $this);
1110 1110
 
1111 1111
 		// Add is used to ensure duplicate emails are not added
1112
-		$ret = (bool) $this->add_meta( 'additional_email', $email );
1112
+		$ret = (bool) $this->add_meta('additional_email', $email);
1113 1113
 
1114
-		do_action( 'give_donor_post_add_email', $email, $this->id, $this );
1114
+		do_action('give_donor_post_add_email', $email, $this->id, $this);
1115 1115
 
1116
-		if ( $ret && true === $primary ) {
1117
-			$this->set_primary_email( $email );
1116
+		if ($ret && true === $primary) {
1117
+			$this->set_primary_email($email);
1118 1118
 		}
1119 1119
 
1120 1120
 		return $ret;
@@ -1130,16 +1130,16 @@  discard block
 block discarded – undo
1130 1130
 	 *
1131 1131
 	 * @return bool          If the email was removed successfully.
1132 1132
 	 */
1133
-	public function remove_email( $email = '' ) {
1134
-		if ( ! is_email( $email ) ) {
1133
+	public function remove_email($email = '') {
1134
+		if ( ! is_email($email)) {
1135 1135
 			return false;
1136 1136
 		}
1137 1137
 
1138
-		do_action( 'give_donor_pre_remove_email', $email, $this->id, $this );
1138
+		do_action('give_donor_pre_remove_email', $email, $this->id, $this);
1139 1139
 
1140
-		$ret = (bool) $this->delete_meta( 'additional_email', $email );
1140
+		$ret = (bool) $this->delete_meta('additional_email', $email);
1141 1141
 
1142
-		do_action( 'give_donor_post_remove_email', $email, $this->id, $this );
1142
+		do_action('give_donor_post_remove_email', $email, $this->id, $this);
1143 1143
 
1144 1144
 		return $ret;
1145 1145
 	}
@@ -1156,16 +1156,16 @@  discard block
 block discarded – undo
1156 1156
 	 *
1157 1157
 	 * @return bool                      If the email was set as primary successfully.
1158 1158
 	 */
1159
-	public function set_primary_email( $new_primary_email = '' ) {
1160
-		if ( ! is_email( $new_primary_email ) ) {
1159
+	public function set_primary_email($new_primary_email = '') {
1160
+		if ( ! is_email($new_primary_email)) {
1161 1161
 			return false;
1162 1162
 		}
1163 1163
 
1164
-		do_action( 'give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this );
1164
+		do_action('give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this);
1165 1165
 
1166
-		$existing = new Give_Donor( $new_primary_email );
1166
+		$existing = new Give_Donor($new_primary_email);
1167 1167
 
1168
-		if ( $existing->id > 0 && (int) $existing->id !== (int) $this->id ) {
1168
+		if ($existing->id > 0 && (int) $existing->id !== (int) $this->id) {
1169 1169
 			// This email belongs to another donor.
1170 1170
 			return false;
1171 1171
 		}
@@ -1173,21 +1173,21 @@  discard block
 block discarded – undo
1173 1173
 		$old_email = $this->email;
1174 1174
 
1175 1175
 		// Update donor record with new email.
1176
-		$update = $this->update( array( 'email' => $new_primary_email ) );
1176
+		$update = $this->update(array('email' => $new_primary_email));
1177 1177
 
1178 1178
 		// Remove new primary from list of additional emails.
1179
-		$remove = $this->remove_email( $new_primary_email );
1179
+		$remove = $this->remove_email($new_primary_email);
1180 1180
 
1181 1181
 		// Add old email to additional emails list.
1182
-		$add = $this->add_email( $old_email );
1182
+		$add = $this->add_email($old_email);
1183 1183
 
1184 1184
 		$ret = $update && $remove && $add;
1185 1185
 
1186
-		if ( $ret ) {
1186
+		if ($ret) {
1187 1187
 			$this->email = $new_primary_email;
1188 1188
 		}
1189 1189
 
1190
-		do_action( 'give_donor_post_set_primary_email', $new_primary_email, $this->id, $this );
1190
+		do_action('give_donor_post_set_primary_email', $new_primary_email, $this->id, $this);
1191 1191
 
1192 1192
 		return $ret;
1193 1193
 	}
@@ -1202,17 +1202,17 @@  discard block
 block discarded – undo
1202 1202
 	 *
1203 1203
 	 * @return bool
1204 1204
 	 */
1205
-	private function is_valid_address( $address ) {
1205
+	private function is_valid_address($address) {
1206 1206
 		$is_valid_address = true;
1207 1207
 		
1208 1208
 		// Address ready to process even if only one value set.
1209
-		foreach ( $address as $address_type => $value ) {
1209
+		foreach ($address as $address_type => $value) {
1210 1210
 			// @todo: Handle state field validation on basis of country.
1211
-			if( in_array( $address_type, array( 'line2', 'state' )) ) {
1211
+			if (in_array($address_type, array('line2', 'state'))) {
1212 1212
 				continue;
1213 1213
 			}
1214 1214
 
1215
-			if ( empty( $value ) ) {
1215
+			if (empty($value)) {
1216 1216
 				$is_valid_address = false;
1217 1217
 				break;
1218 1218
 			}
@@ -1239,30 +1239,27 @@  discard block
 block discarded – undo
1239 1239
 	 *
1240 1240
 	 * @return bool
1241 1241
 	 */
1242
-	public function add_address( $address_type, $address ) {
1242
+	public function add_address($address_type, $address) {
1243 1243
 		// Bailout.
1244
-		if ( empty( $address_type ) || ! $this->is_valid_address( $address ) || ! $this->id ) {
1244
+		if (empty($address_type) || ! $this->is_valid_address($address) || ! $this->id) {
1245 1245
 			return false;
1246 1246
 		}
1247 1247
 
1248 1248
 		// Check if multiple address exist or not and set params.
1249 1249
 		$multi_address_id = null;
1250
-		if( $is_multi_address = ( false !== strpos( $address_type, '[]' ) ) ) {
1251
-			$address_type  = $is_multi_address ?
1252
-				str_replace( '[]', '', $address_type ) :
1253
-				$address_type;
1254
-		} elseif ( $is_multi_address = ( false !== strpos( $address_type, '_' ) ) ){
1255
-			$multi_address_id =  $is_multi_address ?
1256
-				array_pop( explode( '_', $address_type ) ) :
1257
-				$address_type;
1258
-
1259
-			$address_type  = $is_multi_address ?
1260
-				array_shift( explode( '_', $address_type ) ) :
1261
-				$address_type;
1250
+		if ($is_multi_address = (false !== strpos($address_type, '[]'))) {
1251
+			$address_type = $is_multi_address ?
1252
+				str_replace('[]', '', $address_type) : $address_type;
1253
+		} elseif ($is_multi_address = (false !== strpos($address_type, '_'))) {
1254
+			$multi_address_id = $is_multi_address ?
1255
+				array_pop(explode('_', $address_type)) : $address_type;
1256
+
1257
+			$address_type = $is_multi_address ?
1258
+				array_shift(explode('_', $address_type)) : $address_type;
1262 1259
 		}
1263 1260
 
1264 1261
 		// Bailout: do not save duplicate orders
1265
-		if( $this->is_address_exist( $address_type, $address ) ) {
1262
+		if ($this->is_address_exist($address_type, $address)) {
1266 1263
 			return false;
1267 1264
 		}
1268 1265
 
@@ -1284,8 +1281,8 @@  discard block
 block discarded – undo
1284 1281
 		$meta_key_prefix = "_give_donor_address_{$address_type}_{address_name}";
1285 1282
 		$meta_type = Give()->donor_meta->meta_type;
1286 1283
 
1287
-		if ( $is_multi_address ) {
1288
-			if ( is_null( $multi_address_id ) ) {
1284
+		if ($is_multi_address) {
1285
+			if (is_null($multi_address_id)) {
1289 1286
 				// Get latest address key to set multi address id.
1290 1287
 				$multi_address_id = $wpdb->get_var(
1291 1288
 					$wpdb->prepare(
@@ -1302,10 +1299,10 @@  discard block
 block discarded – undo
1302 1299
 					)
1303 1300
 				);
1304 1301
 
1305
-				if( ! empty( $multi_address_id ) ) {
1306
-					$multi_address_id = absint( substr( strrchr( $multi_address_id, '_' ), 1 ) );
1302
+				if ( ! empty($multi_address_id)) {
1303
+					$multi_address_id = absint(substr(strrchr($multi_address_id, '_'), 1));
1307 1304
 					$multi_address_id++;
1308
-				} else{
1305
+				} else {
1309 1306
 					$multi_address_id = 0;
1310 1307
 				}
1311 1308
 			}
@@ -1314,9 +1311,9 @@  discard block
 block discarded – undo
1314 1311
 		}
1315 1312
 
1316 1313
 		// Save donor address.
1317
-		foreach ( $address as $type => $value ) {
1318
-			$meta_key = str_replace( '{address_name}', $type, $meta_key_prefix );
1319
-			Give()->donor_meta->update_meta( $this->id, $meta_key, $value );
1314
+		foreach ($address as $type => $value) {
1315
+			$meta_key = str_replace('{address_name}', $type, $meta_key_prefix);
1316
+			Give()->donor_meta->update_meta($this->id, $meta_key, $value);
1320 1317
 		}
1321 1318
 
1322 1319
 		$this->setup_address();
@@ -1335,23 +1332,21 @@  discard block
 block discarded – undo
1335 1332
 	 *
1336 1333
 	 * @return bool
1337 1334
 	 */
1338
-	public function remove_address( $address_id ) {
1335
+	public function remove_address($address_id) {
1339 1336
 		global $wpdb;
1340 1337
 
1341 1338
 		// Get address type.
1342
-		$is_multi_address = false !== strpos( $address_id, '_' ) ? true : false;
1339
+		$is_multi_address = false !== strpos($address_id, '_') ? true : false;
1343 1340
 
1344
-		$address_type = false !== strpos( $address_id, '_' ) ?
1345
-			array_shift( explode( '_', $address_id ) ) :
1346
-			$address_id;
1341
+		$address_type = false !== strpos($address_id, '_') ?
1342
+			array_shift(explode('_', $address_id)) : $address_id;
1347 1343
 
1348
-		$address_count = false !== strpos( $address_id, '_' ) ?
1349
-			array_pop( explode( '_', $address_id ) ) :
1350
-			null;
1344
+		$address_count = false !== strpos($address_id, '_') ?
1345
+			array_pop(explode('_', $address_id)) : null;
1351 1346
 
1352 1347
 		// Set meta key prefix.
1353 1348
 		$meta_key_prefix = "_give_donor_address_{$address_type}_%";
1354
-		if ( $is_multi_address && is_numeric( $address_count ) ) {
1349
+		if ($is_multi_address && is_numeric($address_count)) {
1355 1350
 			$meta_key_prefix .= "_{$address_count}";
1356 1351
 		}
1357 1352
 
@@ -1388,23 +1383,21 @@  discard block
 block discarded – undo
1388 1383
 	 *
1389 1384
 	 * @return bool
1390 1385
 	 */
1391
-	public function update_address( $address_id, $address ) {
1386
+	public function update_address($address_id, $address) {
1392 1387
 		global $wpdb;
1393 1388
 
1394 1389
 		// Get address type.
1395
-		$is_multi_address = false !== strpos( $address_id, '_' ) ? true : false;
1390
+		$is_multi_address = false !== strpos($address_id, '_') ? true : false;
1396 1391
 
1397
-		$address_type = false !== strpos( $address_id, '_' ) ?
1398
-			array_shift( explode( '_', $address_id ) ) :
1399
-			$address_id;
1392
+		$address_type = false !== strpos($address_id, '_') ?
1393
+			array_shift(explode('_', $address_id)) : $address_id;
1400 1394
 
1401
-		$address_count = false !== strpos( $address_id, '_' ) ?
1402
-			array_pop( explode( '_', $address_id ) ) :
1403
-			null;
1395
+		$address_count = false !== strpos($address_id, '_') ?
1396
+			array_pop(explode('_', $address_id)) : null;
1404 1397
 
1405 1398
 		// Set meta key prefix.
1406 1399
 		$meta_key_prefix = "_give_donor_address_{$address_type}_%";
1407
-		if ( $is_multi_address && is_numeric( $address_count ) ) {
1400
+		if ($is_multi_address && is_numeric($address_count)) {
1408 1401
 			$meta_key_prefix .= "_{$address_count}";
1409 1402
 		}
1410 1403
 
@@ -1425,12 +1418,12 @@  discard block
 block discarded – undo
1425 1418
 		);
1426 1419
 		
1427 1420
 		// Return result.
1428
-		if( ! count( $row_affected ) ) {
1421
+		if ( ! count($row_affected)) {
1429 1422
 			return false;
1430 1423
 		}
1431 1424
 
1432 1425
 		// Update address.
1433
-		if( ! $this->add_address( $address_id, $address ) ) {
1426
+		if ( ! $this->add_address($address_id, $address)) {
1434 1427
 			return false;
1435 1428
 		}
1436 1429
 
@@ -1449,39 +1442,39 @@  discard block
 block discarded – undo
1449 1442
 	 *
1450 1443
 	 * @return bool|null
1451 1444
 	 */
1452
-	public function is_address_exist( $current_address_type, $current_address ) {
1445
+	public function is_address_exist($current_address_type, $current_address) {
1453 1446
 		$status = false;
1454 1447
 
1455 1448
 		// Bailout.
1456
-		if( empty( $current_address_type ) || empty( $current_address ) ) {
1449
+		if (empty($current_address_type) || empty($current_address)) {
1457 1450
 			return null;
1458 1451
 		}
1459 1452
 
1460 1453
 		// Bailout.
1461
-		if( empty( $this->address ) || empty( $this->address[ $current_address_type ] ) ) {
1454
+		if (empty($this->address) || empty($this->address[$current_address_type])) {
1462 1455
 			return $status;
1463 1456
 		}
1464 1457
 
1465 1458
 		// Get address.
1466
-		$address = $this->address[ $current_address_type ];
1459
+		$address = $this->address[$current_address_type];
1467 1460
 
1468
-		switch ( true ){
1461
+		switch (true) {
1469 1462
 
1470 1463
 			// Single address.
1471
-			case is_string( end( $address ) ) :
1472
-				$status = $this->is_address_match( $current_address, $address );
1464
+			case is_string(end($address)) :
1465
+				$status = $this->is_address_match($current_address, $address);
1473 1466
 				break;
1474 1467
 
1475 1468
 			// Multi address.
1476
-			case is_array( end( $address ) ):
1469
+			case is_array(end($address)):
1477 1470
 				// Compare address.
1478
-				foreach ( $address as $saved_address ) {
1479
-					if( empty( $saved_address ) ) {
1471
+				foreach ($address as $saved_address) {
1472
+					if (empty($saved_address)) {
1480 1473
 						continue;
1481 1474
 					}
1482 1475
 
1483 1476
 					// Exit loop immediately if address exist.
1484
-					if( $status = $this->is_address_match( $current_address, $saved_address ) ) {
1477
+					if ($status = $this->is_address_match($current_address, $saved_address)) {
1485 1478
 						break;
1486 1479
 					}
1487 1480
 				}
@@ -1502,10 +1495,10 @@  discard block
 block discarded – undo
1502 1495
 	 *
1503 1496
 	 * @return bool
1504 1497
 	 */
1505
-	private function is_address_match( $address_1, $address_2 ) {
1506
-		$result = array_diff( $address_1, $address_2 );
1498
+	private function is_address_match($address_1, $address_2) {
1499
+		$result = array_diff($address_1, $address_2);
1507 1500
 
1508
-		return empty( $result );
1501
+		return empty($result);
1509 1502
 	}
1510 1503
 
1511 1504
 	/**
@@ -1515,22 +1508,22 @@  discard block
 block discarded – undo
1515 1508
 	 * @since   2.0
1516 1509
 	 * @return  object
1517 1510
 	 */
1518
-	public function split_donor_name( $id ) {
1519
-		$first_name = $last_name  = '';
1520
-		$donor      = new Give_Donor( $id );
1511
+	public function split_donor_name($id) {
1512
+		$first_name = $last_name = '';
1513
+		$donor      = new Give_Donor($id);
1521 1514
 
1522
-		$split_donor_name = explode( ' ', $donor->name, 2 );
1515
+		$split_donor_name = explode(' ', $donor->name, 2);
1523 1516
 
1524 1517
 		// Check for existence of first name after split of donor name.
1525
-		if( is_array( $split_donor_name ) && ! empty( $split_donor_name[0] ) ) {
1518
+		if (is_array($split_donor_name) && ! empty($split_donor_name[0])) {
1526 1519
 			$first_name = $split_donor_name[0];
1527 1520
 		}
1528 1521
 
1529 1522
 		// Check for existence of last name after split of donor name.
1530
-		if( is_array( $split_donor_name ) && ! empty( $split_donor_name[1] ) ) {
1523
+		if (is_array($split_donor_name) && ! empty($split_donor_name[1])) {
1531 1524
 			$last_name = $split_donor_name[1];
1532 1525
 		}
1533
-		return (object) array( 'first_name' => $first_name, 'last_name' => $last_name );
1526
+		return (object) array('first_name' => $first_name, 'last_name' => $last_name);
1534 1527
 	}
1535 1528
 
1536 1529
 	/**
@@ -1540,9 +1533,9 @@  discard block
 block discarded – undo
1540 1533
 	 * @return  string
1541 1534
 	 */
1542 1535
 	public function get_first_name() {
1543
-		$first_name = $this->get_meta( '_give_donor_first_name');
1544
-		if( ! $first_name ) {
1545
-			$first_name = $this->split_donor_name( $this->id )->first_name;
1536
+		$first_name = $this->get_meta('_give_donor_first_name');
1537
+		if ( ! $first_name) {
1538
+			$first_name = $this->split_donor_name($this->id)->first_name;
1546 1539
 		}
1547 1540
 
1548 1541
 		return $first_name;
@@ -1555,14 +1548,14 @@  discard block
 block discarded – undo
1555 1548
 	 * @return  string
1556 1549
 	 */
1557 1550
 	public function get_last_name() {
1558
-		$first_name = $this->get_meta( '_give_donor_first_name');
1559
-		$last_name = $this->get_meta( '_give_donor_last_name');
1551
+		$first_name = $this->get_meta('_give_donor_first_name');
1552
+		$last_name = $this->get_meta('_give_donor_last_name');
1560 1553
 
1561 1554
 		// This condition will prevent unnecessary splitting of donor name to fetch last name.
1562
-		if( ! $first_name && ! $last_name ) {
1563
-			$last_name = $this->split_donor_name( $this->id )->last_name;
1555
+		if ( ! $first_name && ! $last_name) {
1556
+			$last_name = $this->split_donor_name($this->id)->last_name;
1564 1557
 		}
1565 1558
 
1566
-		return ( $last_name ) ? $last_name : '';
1559
+		return ($last_name) ? $last_name : '';
1567 1560
 	}
1568 1561
 }
Please login to merge, or discard this patch.
includes/class-give-session.php 1 patch
Spacing   +76 added lines, -76 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
 
@@ -74,57 +74,57 @@  discard block
 block discarded – undo
74 74
 	public function __construct() {
75 75
 
76 76
 		$this->use_php_sessions = $this->use_php_sessions();
77
-		$this->exp_option       = give_get_option( 'session_lifetime' );
77
+		$this->exp_option       = give_get_option('session_lifetime');
78 78
 
79 79
 		// PHP Sessions.
80
-		if ( $this->use_php_sessions ) {
80
+		if ($this->use_php_sessions) {
81 81
 
82
-			if ( is_multisite() ) {
82
+			if (is_multisite()) {
83 83
 
84
-				$this->prefix = '_' . get_current_blog_id();
84
+				$this->prefix = '_'.get_current_blog_id();
85 85
 
86 86
 			}
87 87
 
88
-			add_action( 'init', array( $this, 'maybe_start_session' ), - 2 );
88
+			add_action('init', array($this, 'maybe_start_session'), - 2);
89 89
 
90 90
 		} else {
91 91
 
92
-			if ( ! $this->should_start_session() ) {
92
+			if ( ! $this->should_start_session()) {
93 93
 				return;
94 94
 			}
95 95
 
96 96
 			// Use WP_Session.
97
-			if ( ! defined( 'WP_SESSION_COOKIE' ) ) {
98
-				define( 'WP_SESSION_COOKIE', 'give_wp_session' );
97
+			if ( ! defined('WP_SESSION_COOKIE')) {
98
+				define('WP_SESSION_COOKIE', 'give_wp_session');
99 99
 			}
100 100
 
101
-			if ( ! class_exists( 'Recursive_ArrayAccess' ) ) {
102
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-recursive-arrayaccess.php';
101
+			if ( ! class_exists('Recursive_ArrayAccess')) {
102
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-recursive-arrayaccess.php';
103 103
 			}
104 104
 
105 105
 			// Include utilities class
106
-			if ( ! class_exists( 'WP_Session_Utils' ) ) {
107
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-wp-session-utils.php';
106
+			if ( ! class_exists('WP_Session_Utils')) {
107
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-wp-session-utils.php';
108 108
 			}
109
-			if ( ! class_exists( 'WP_Session' ) ) {
110
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-wp-session.php';
111
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/wp-session.php';
109
+			if ( ! class_exists('WP_Session')) {
110
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-wp-session.php';
111
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/wp-session.php';
112 112
 			}
113 113
 
114
-			add_filter( 'wp_session_expiration_variant', array( $this, 'set_expiration_variant_time' ), 99999 );
115
-			add_filter( 'wp_session_expiration', array( $this, 'set_expiration_time' ), 99999 );
114
+			add_filter('wp_session_expiration_variant', array($this, 'set_expiration_variant_time'), 99999);
115
+			add_filter('wp_session_expiration', array($this, 'set_expiration_time'), 99999);
116 116
 
117 117
 		}
118 118
 
119 119
 		// Init Session.
120
-		if ( empty( $this->session ) && ! $this->use_php_sessions ) {
121
-			add_action( 'plugins_loaded', array( $this, 'init' ), 9999 );
120
+		if (empty($this->session) && ! $this->use_php_sessions) {
121
+			add_action('plugins_loaded', array($this, 'init'), 9999);
122 122
 		} else {
123
-			add_action( 'init', array( $this, 'init' ), - 1 );
123
+			add_action('init', array($this, 'init'), - 1);
124 124
 		}
125 125
 
126 126
 		// Set cookie on Donation Completion page.
127
-		add_action( 'give_pre_process_donation', array( $this, 'set_session_cookies' ) );
127
+		add_action('give_pre_process_donation', array($this, 'set_session_cookies'));
128 128
 
129 129
 	}
130 130
 
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
 	 */
141 141
 	public function init() {
142 142
 
143
-		if ( $this->use_php_sessions ) {
144
-			$this->session = isset( $_SESSION[ 'give' . $this->prefix ] ) && is_array( $_SESSION[ 'give' . $this->prefix ] ) ? $_SESSION[ 'give' . $this->prefix ] : array();
143
+		if ($this->use_php_sessions) {
144
+			$this->session = isset($_SESSION['give'.$this->prefix]) && is_array($_SESSION['give'.$this->prefix]) ? $_SESSION['give'.$this->prefix] : array();
145 145
 		} else {
146 146
 			$this->session = WP_Session::get_instance();
147 147
 		}
@@ -176,37 +176,37 @@  discard block
 block discarded – undo
176 176
 	 *
177 177
 	 * @return string|array      Session variable.
178 178
 	 */
179
-	public function get( $key ) {
180
-		$key    = sanitize_key( $key );
179
+	public function get($key) {
180
+		$key    = sanitize_key($key);
181 181
 		$return = false;
182 182
 
183
-		if ( isset( $this->session[ $key ] ) && ! empty( $this->session[ $key ] ) ) {
183
+		if (isset($this->session[$key]) && ! empty($this->session[$key])) {
184 184
 
185
-			preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $this->session[ $key ], $matches );
186
-			if ( ! empty( $matches ) ) {
187
-				$this->set( $key, null );
185
+			preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $this->session[$key], $matches);
186
+			if ( ! empty($matches)) {
187
+				$this->set($key, null);
188 188
 
189 189
 				return false;
190 190
 			}
191 191
 
192
-			if ( is_numeric( $this->session[ $key ] ) ) {
193
-				$return = $this->session[ $key ];
192
+			if (is_numeric($this->session[$key])) {
193
+				$return = $this->session[$key];
194 194
 			} else {
195 195
 
196
-				$maybe_json = json_decode( $this->session[ $key ] );
196
+				$maybe_json = json_decode($this->session[$key]);
197 197
 
198 198
 				// Since json_last_error is PHP 5.3+, we have to rely on a `null` value for failing to parse JSON.
199
-				if ( is_null( $maybe_json ) ) {
200
-					$is_serialized = is_serialized( $this->session[ $key ] );
201
-					if ( $is_serialized ) {
202
-						$value = @unserialize( $this->session[ $key ] );
203
-						$this->set( $key, (array) $value );
199
+				if (is_null($maybe_json)) {
200
+					$is_serialized = is_serialized($this->session[$key]);
201
+					if ($is_serialized) {
202
+						$value = @unserialize($this->session[$key]);
203
+						$this->set($key, (array) $value);
204 204
 						$return = $value;
205 205
 					} else {
206
-						$return = $this->session[ $key ];
206
+						$return = $this->session[$key];
207 207
 					}
208 208
 				} else {
209
-					$return = json_decode( $this->session[ $key ], true );
209
+					$return = json_decode($this->session[$key], true);
210 210
 				}
211 211
 
212 212
 			}
@@ -229,21 +229,21 @@  discard block
 block discarded – undo
229 229
 	 *
230 230
 	 * @return string        Session variable.
231 231
 	 */
232
-	public function set( $key, $value ) {
232
+	public function set($key, $value) {
233 233
 
234
-		$key = sanitize_key( $key );
234
+		$key = sanitize_key($key);
235 235
 
236
-		if ( is_array( $value ) ) {
237
-			$this->session[ $key ] = wp_json_encode( $value );
236
+		if (is_array($value)) {
237
+			$this->session[$key] = wp_json_encode($value);
238 238
 		} else {
239
-			$this->session[ $key ] = esc_attr( $value );
239
+			$this->session[$key] = esc_attr($value);
240 240
 		}
241 241
 
242
-		if ( $this->use_php_sessions ) {
243
-			$_SESSION[ 'give' . $this->prefix ] = $this->session;
242
+		if ($this->use_php_sessions) {
243
+			$_SESSION['give'.$this->prefix] = $this->session;
244 244
 		}
245 245
 
246
-		return $this->session[ $key ];
246
+		return $this->session[$key];
247 247
 	}
248 248
 
249 249
 	/**
@@ -258,10 +258,10 @@  discard block
 block discarded – undo
258 258
 	 * @hook
259 259
 	 */
260 260
 	public function set_session_cookies() {
261
-		if ( ! headers_sent() ) {
262
-			$lifetime = current_time( 'timestamp' ) + $this->set_expiration_time();
263
-			@setcookie( session_name(), session_id(), $lifetime, COOKIEPATH, COOKIE_DOMAIN, false );
264
-			@setcookie( session_name() . '_expiration', $lifetime, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false );
261
+		if ( ! headers_sent()) {
262
+			$lifetime = current_time('timestamp') + $this->set_expiration_time();
263
+			@setcookie(session_name(), session_id(), $lifetime, COOKIEPATH, COOKIE_DOMAIN, false);
264
+			@setcookie(session_name().'_expiration', $lifetime, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false);
265 265
 		}
266 266
 	}
267 267
 
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 	 */
278 278
 	public function set_expiration_variant_time() {
279 279
 
280
-		return ( ! empty( $this->exp_option ) ? ( intval( $this->exp_option ) - 3600 ) : 30 * 60 * 23 );
280
+		return ( ! empty($this->exp_option) ? (intval($this->exp_option) - 3600) : 30 * 60 * 23);
281 281
 	}
282 282
 
283 283
 	/**
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 	 */
293 293
 	public function set_expiration_time() {
294 294
 
295
-		return ( ! empty( $this->exp_option ) ? intval( $this->exp_option ) : 30 * 60 * 24 );
295
+		return ( ! empty($this->exp_option) ? intval($this->exp_option) : 30 * 60 * 24);
296 296
 	}
297 297
 
298 298
 	/**
@@ -310,21 +310,21 @@  discard block
 block discarded – undo
310 310
 		$ret = false;
311 311
 
312 312
 		// If the database variable is already set, no need to run auto detection.
313
-		$give_use_php_sessions = (bool) get_option( 'give_use_php_sessions' );
313
+		$give_use_php_sessions = (bool) get_option('give_use_php_sessions');
314 314
 
315
-		if ( ! $give_use_php_sessions ) {
315
+		if ( ! $give_use_php_sessions) {
316 316
 
317 317
 			// Attempt to detect if the server supports PHP sessions.
318
-			if ( function_exists( 'session_start' ) && ! ini_get( 'safe_mode' ) ) {
318
+			if (function_exists('session_start') && ! ini_get('safe_mode')) {
319 319
 
320
-				$this->set( 'give_use_php_sessions', 1 );
320
+				$this->set('give_use_php_sessions', 1);
321 321
 
322
-				if ( $this->get( 'give_use_php_sessions' ) ) {
322
+				if ($this->get('give_use_php_sessions')) {
323 323
 
324 324
 					$ret = true;
325 325
 
326 326
 					// Set the database option.
327
-					update_option( 'give_use_php_sessions', true );
327
+					update_option('give_use_php_sessions', true);
328 328
 
329 329
 				}
330 330
 			}
@@ -334,13 +334,13 @@  discard block
 block discarded – undo
334 334
 		}
335 335
 
336 336
 		// Enable or disable PHP Sessions based on the GIVE_USE_PHP_SESSIONS constant.
337
-		if ( defined( 'GIVE_USE_PHP_SESSIONS' ) && GIVE_USE_PHP_SESSIONS ) {
337
+		if (defined('GIVE_USE_PHP_SESSIONS') && GIVE_USE_PHP_SESSIONS) {
338 338
 			$ret = true;
339
-		} elseif ( defined( 'GIVE_USE_PHP_SESSIONS' ) && ! GIVE_USE_PHP_SESSIONS ) {
339
+		} elseif (defined('GIVE_USE_PHP_SESSIONS') && ! GIVE_USE_PHP_SESSIONS) {
340 340
 			$ret = false;
341 341
 		}
342 342
 
343
-		return (bool) apply_filters( 'give_use_php_sessions', $ret );
343
+		return (bool) apply_filters('give_use_php_sessions', $ret);
344 344
 	}
345 345
 
346 346
 	/**
@@ -357,9 +357,9 @@  discard block
 block discarded – undo
357 357
 
358 358
 		$start_session = true;
359 359
 
360
-		if ( ! empty( $_SERVER['REQUEST_URI'] ) ) {
360
+		if ( ! empty($_SERVER['REQUEST_URI'])) {
361 361
 
362
-			$blacklist = apply_filters( 'give_session_start_uri_blacklist', array(
362
+			$blacklist = apply_filters('give_session_start_uri_blacklist', array(
363 363
 				'feed',
364 364
 				'feed',
365 365
 				'feed/rss',
@@ -367,21 +367,21 @@  discard block
 block discarded – undo
367 367
 				'feed/rdf',
368 368
 				'feed/atom',
369 369
 				'comments/feed/',
370
-			) );
371
-			$uri       = ltrim( $_SERVER['REQUEST_URI'], '/' );
372
-			$uri       = untrailingslashit( $uri );
373
-			if ( in_array( $uri, $blacklist ) ) {
370
+			));
371
+			$uri       = ltrim($_SERVER['REQUEST_URI'], '/');
372
+			$uri       = untrailingslashit($uri);
373
+			if (in_array($uri, $blacklist)) {
374 374
 				$start_session = false;
375 375
 			}
376
-			if ( false !== strpos( $uri, 'feed=' ) ) {
376
+			if (false !== strpos($uri, 'feed=')) {
377 377
 				$start_session = false;
378 378
 			}
379
-			if ( is_admin() ) {
379
+			if (is_admin()) {
380 380
 				$start_session = false;
381 381
 			}
382 382
 		}
383 383
 
384
-		return apply_filters( 'give_start_session', $start_session );
384
+		return apply_filters('give_start_session', $start_session);
385 385
 	}
386 386
 
387 387
 	/**
@@ -397,11 +397,11 @@  discard block
 block discarded – undo
397 397
 	 */
398 398
 	public function maybe_start_session() {
399 399
 
400
-		if ( ! $this->should_start_session() ) {
400
+		if ( ! $this->should_start_session()) {
401 401
 			return;
402 402
 		}
403 403
 
404
-		if ( ! session_id() && ! headers_sent() ) {
404
+		if ( ! session_id() && ! headers_sent()) {
405 405
 			session_start();
406 406
 		}
407 407
 
@@ -420,9 +420,9 @@  discard block
 block discarded – undo
420 420
 
421 421
 		$expiration = false;
422 422
 
423
-		if ( session_id() && isset( $_COOKIE[ session_name() . '_expiration' ] ) ) {
423
+		if (session_id() && isset($_COOKIE[session_name().'_expiration'])) {
424 424
 
425
-			$expiration = date( 'D, d M Y h:i:s', intval( $_COOKIE[ session_name() . '_expiration' ] ) );
425
+			$expiration = date('D, d M Y h:i:s', intval($_COOKIE[session_name().'_expiration']));
426 426
 
427 427
 		}
428 428
 
Please login to merge, or discard this patch.
includes/admin/views/html-admin-settings.php 2 patches
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -95,5 +95,8 @@
 block discarded – undo
95 95
 		<?php endif; ?>
96 96
 		<?php echo $form_close_tag; ?>
97 97
 	</div>
98
-<?php else : echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; ?>
98
+<?php else {
99
+	: echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>';
100
+}
101
+?>
99 102
 <?php endif; ?>
100 103
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -2,12 +2,12 @@  discard block
 block discarded – undo
2 2
 /**
3 3
  * Admin View: Settings
4 4
  */
5
-if ( ! defined( 'ABSPATH' ) ) {
5
+if ( ! defined('ABSPATH')) {
6 6
 	exit;
7 7
 }
8 8
 
9 9
 // Bailout: Do not output anything if setting tab is not defined.
10
-if ( ! empty( $tabs ) && array_key_exists( give_get_current_setting_tab(), $tabs ) ) :
10
+if ( ! empty($tabs) && array_key_exists(give_get_current_setting_tab(), $tabs)) :
11 11
 	/**
12 12
 	 * Filter the form action.
13 13
 	 *
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 	 *
18 18
 	 * @since 1.8
19 19
 	 */
20
-	$form_method = apply_filters( self::$setting_filter_prefix . '_form_method_tab_' . $current_tab, 'post' );
20
+	$form_method = apply_filters(self::$setting_filter_prefix.'_form_method_tab_'.$current_tab, 'post');
21 21
 
22 22
 	/**
23 23
 	 * Filter the main form tab.
@@ -29,14 +29,14 @@  discard block
 block discarded – undo
29 29
 	 *
30 30
 	 * @since 1.8
31 31
 	 */
32
-	$form_open_tag  = apply_filters( self::$setting_filter_prefix . '_open_form', '<form method="' . $form_method . '" id="give-mainform" action="" enctype="multipart/form-data">' );
33
-	$form_close_tag = apply_filters( self::$setting_filter_prefix . '_close_form', '</form>' );
32
+	$form_open_tag  = apply_filters(self::$setting_filter_prefix.'_open_form', '<form method="'.$form_method.'" id="give-mainform" action="" enctype="multipart/form-data">');
33
+	$form_close_tag = apply_filters(self::$setting_filter_prefix.'_close_form', '</form>');
34 34
 
35
-	$wrapper_class = implode( ' ',
35
+	$wrapper_class = implode(' ',
36 36
 		array(
37
-			self::$setting_filter_prefix . '-setting-page',
38
-			self::$setting_filter_prefix . '-' . give_get_current_setting_section() . '-section',
39
-			self::$setting_filter_prefix . '-' . give_get_current_setting_tab() . '-tab',
37
+			self::$setting_filter_prefix.'-setting-page',
38
+			self::$setting_filter_prefix.'-'.give_get_current_setting_section().'-section',
39
+			self::$setting_filter_prefix.'-'.give_get_current_setting_tab().'-tab',
40 40
 		)
41 41
 	);
42 42
 	?>
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 
47 47
 		/* @var Give_Settings_Page $current_setting_obj */
48 48
 		if (
49
-			! empty( $current_setting_obj ) &&
50
-			method_exists( $current_setting_obj, 'get_heading_html' )
49
+			! empty($current_setting_obj) &&
50
+			method_exists($current_setting_obj, 'get_heading_html')
51 51
 		) {
52 52
 			echo $current_setting_obj->get_heading_html();
53 53
 		} else {
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 			// Backward compatibility.
56 56
 			echo sprintf(
57 57
 				'<h1 class="wp-heading-inline">%s</h1><hr class="wp-header-end">',
58
-				esc_html( $tabs[ $current_tab ] )
58
+				esc_html($tabs[$current_tab])
59 59
 			);
60 60
 		}
61 61
 
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
 		?>
64 64
 		<div class="nav-tab-wrapper give-nav-tab-wrapper">
65 65
 			<?php
66
-			foreach ( $tabs as $name => $label ) {
67
-				echo '<a href="' . admin_url( "edit.php?post_type=give_forms&page=" . self::$setting_filter_prefix . "&tab={$name}" ) . '" class="nav-tab ' . ( $current_tab === $name ? 'nav-tab-active' : 'give-mobile-hidden' ) . '">' . $label . '</a>';
66
+			foreach ($tabs as $name => $label) {
67
+				echo '<a href="'.admin_url("edit.php?post_type=give_forms&page=".self::$setting_filter_prefix."&tab={$name}").'" class="nav-tab '.($current_tab === $name ? 'nav-tab-active' : 'give-mobile-hidden').'">'.$label.'</a>';
68 68
 			}
69 69
 
70 70
 			/**
@@ -76,10 +76,10 @@  discard block
 block discarded – undo
76 76
 			 *
77 77
 			 * @since 1.8
78 78
 			 */
79
-			do_action( self::$setting_filter_prefix . '_tabs' );
79
+			do_action(self::$setting_filter_prefix.'_tabs');
80 80
 			?>
81 81
 			<div class="give-sub-nav-tab-wrapper">
82
-				<a href="#" id="give-show-sub-nav" class="nav-tab give-not-tab" title="<?php _e( 'View remaining setting tabs', 'give' ); ?>"><span class="dashicons dashicons-arrow-down-alt2"></span></span>
82
+				<a href="#" id="give-show-sub-nav" class="nav-tab give-not-tab" title="<?php _e('View remaining setting tabs', 'give'); ?>"><span class="dashicons dashicons-arrow-down-alt2"></span></span>
83 83
 				</a>
84 84
 				<nav class="give-sub-nav-tab give-hidden"></nav>
85 85
 			</div>
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 		 *
96 96
 		 * @since 1.8
97 97
 		 */
98
-		do_action( self::$setting_filter_prefix . "_sections_{$current_tab}_page" );
98
+		do_action(self::$setting_filter_prefix."_sections_{$current_tab}_page");
99 99
 
100 100
 		/**
101 101
 		 * Trigger Action.
@@ -106,15 +106,15 @@  discard block
 block discarded – undo
106 106
 		 *
107 107
 		 * @since 1.8
108 108
 		 */
109
-		do_action( self::$setting_filter_prefix . "_settings_{$current_tab}_page" );
109
+		do_action(self::$setting_filter_prefix."_settings_{$current_tab}_page");
110 110
 
111
-		if ( empty( $GLOBALS['give_hide_save_button'] ) ) : ?>
111
+		if (empty($GLOBALS['give_hide_save_button'])) : ?>
112 112
 			<div class="give-submit-wrap">
113
-				<?php wp_nonce_field( 'give-save-settings', '_give-save-settings' ); ?>
114
-				<input name="save" class="button-primary give-save-button" type="submit" value="<?php _e( 'Save changes', 'give' ); ?>"/>
113
+				<?php wp_nonce_field('give-save-settings', '_give-save-settings'); ?>
114
+				<input name="save" class="button-primary give-save-button" type="submit" value="<?php _e('Save changes', 'give'); ?>"/>
115 115
 			</div>
116 116
 		<?php endif; ?>
117 117
 		<?php echo $form_close_tag; ?>
118 118
 	</div>
119
-<?php else : echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; ?>
119
+<?php else : echo '<div class="error"><p>'.__('Oops, this settings page does not exist.', 'give').'</p></div>'; ?>
120 120
 <?php endif; ?>
121 121
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/views/blank-slate.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -17,23 +17,23 @@  discard block
 block discarded – undo
17 17
 ?>
18 18
 
19 19
 <div class="give-blank-slate">
20
-	<?php if ( ! empty( $content['image_url'] ) ) : ?>
21
-		<img class="give-blank-slate__image" src="<?php echo esc_url( $content['image_url'] ); ?>" alt="<?php echo esc_attr( $content['image_alt'] ); ?>">
20
+	<?php if ( ! empty($content['image_url'])) : ?>
21
+		<img class="give-blank-slate__image" src="<?php echo esc_url($content['image_url']); ?>" alt="<?php echo esc_attr($content['image_alt']); ?>">
22 22
 	<?php endif; ?>
23 23
 
24
-	<?php if ( ! empty( $content['heading'] ) ) : ?>
25
-		<h2 class="give-blank-slate__heading"><?php esc_html_e( $content['heading'] ); ?></h2>
24
+	<?php if ( ! empty($content['heading'])) : ?>
25
+		<h2 class="give-blank-slate__heading"><?php esc_html_e($content['heading']); ?></h2>
26 26
 	<?php endif; ?>
27 27
 
28
-	<?php if ( ! empty( $content['message'] ) ) : ?>
29
-		<p class="give-blank-slate__message"><?php esc_html_e( $content['message'] ); ?></p>
28
+	<?php if ( ! empty($content['message'])) : ?>
29
+		<p class="give-blank-slate__message"><?php esc_html_e($content['message']); ?></p>
30 30
 	<?php endif; ?>
31 31
 
32
-	<?php if ( ! empty( $content['cta_text']) && ! empty( $content['cta_link'] ) ) : ?>
33
-		<a class="give-blank-slate__cta button button-primary" href="<?php echo esc_url( $content['cta_link'] ); ?>"><?php esc_html_e( $content['cta_text'] ); ?></a>
32
+	<?php if ( ! empty($content['cta_text']) && ! empty($content['cta_link'])) : ?>
33
+		<a class="give-blank-slate__cta button button-primary" href="<?php echo esc_url($content['cta_link']); ?>"><?php esc_html_e($content['cta_text']); ?></a>
34 34
 	<?php endif; ?>
35 35
 
36
-	<?php if ( ! empty( $content['help'] ) ) : ?>
36
+	<?php if ( ! empty($content['help'])) : ?>
37 37
 		<p class="give-blank-slate__help">
38 38
 			<?php
39 39
 			$allowed_html = array(
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 				'code'   => array(),
48 48
 			);
49 49
 
50
-			echo wp_kses( $content['help'], $allowed_html );
50
+			echo wp_kses($content['help'], $allowed_html);
51 51
 			?>
52 52
 		</p>
53 53
 	<?php endif; ?>
Please login to merge, or discard this patch.
includes/admin/tools/data/tools-actions.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -20,10 +20,10 @@  discard block
 block discarded – undo
20 20
  * @since  1.5
21 21
  */
22 22
 function give_register_batch_recount_export_classes() {
23
-	add_action( 'give_batch_export_class_include', 'give_include_batch_export_class', 10, 1 );
23
+	add_action('give_batch_export_class_include', 'give_include_batch_export_class', 10, 1);
24 24
 }
25 25
 
26
-add_action( 'give_register_batch_exporter', 'give_register_batch_recount_export_classes', 10 );
26
+add_action('give_register_batch_exporter', 'give_register_batch_recount_export_classes', 10);
27 27
 
28 28
 
29 29
 /**
@@ -35,39 +35,39 @@  discard block
 block discarded – undo
35 35
  *
36 36
  * @return void
37 37
  */
38
-function give_include_batch_export_class( $class ) {
39
-	switch ( $class ) {
38
+function give_include_batch_export_class($class) {
39
+	switch ($class) {
40 40
 
41 41
 		case 'Give_Tools_Delete_Donors':
42
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-delete-test-donors.php';
42
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-delete-test-donors.php';
43 43
 			break;
44 44
 
45 45
 		case 'Give_Tools_Import_Donors':
46
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-delete-import-donors.php';
46
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-delete-import-donors.php';
47 47
 			break;
48 48
 
49 49
 		case 'Give_Tools_Delete_Test_Transactions':
50
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-delete-test-transactions.php';
50
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-delete-test-transactions.php';
51 51
 			break;
52 52
 
53 53
 		case 'Give_Tools_Recount_Donor_Stats':
54
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-donor-stats.php';
54
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-donor-stats.php';
55 55
 			break;
56 56
 
57 57
 		case 'Give_Tools_Reset_Stats':
58
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-reset-stats.php';
58
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-reset-stats.php';
59 59
 			break;
60 60
 
61 61
 		case 'Give_Tools_Recount_All_Stats':
62
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-all-stats.php';
62
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-all-stats.php';
63 63
 			break;
64 64
 
65 65
 		case 'Give_Tools_Recount_Form_Stats':
66
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-form-stats.php';
66
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-form-stats.php';
67 67
 			break;
68 68
 
69 69
 		case 'Give_Tools_Recount_Income':
70
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-income.php';
70
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-income.php';
71 71
 			break;
72 72
 	}
73 73
 }
Please login to merge, or discard this patch.
includes/payments/class-give-payment.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1012,7 +1012,7 @@
 block discarded – undo
1012 1012
 					// Find a match between price_id and level_id.
1013 1013
 					// First verify array keys exists THEN make the match.
1014 1014
 					if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) )
1015
-					     && $args['price_id'] == $price['_give_id']['level_id']
1015
+						 && $args['price_id'] == $price['_give_id']['level_id']
1016 1016
 					) {
1017 1017
 						$donation_amount = $price['_give_amount'];
1018 1018
 					}
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 	 *
392 392
 	 * @param  int|bool $payment_id A given payment
393 393
 	 *
394
-	 * @return mixed void|false
394
+	 * @return false|null void|false
395 395
 	 */
396 396
 	public function __construct( $payment_id = false ) {
397 397
 
@@ -1115,7 +1115,7 @@  discard block
 block discarded – undo
1115 1115
 	 *
1116 1116
 	 * @param  string|bool $note The note to add
1117 1117
 	 *
1118
-	 * @return bool           If the note was specified or not
1118
+	 * @return false|null           If the note was specified or not
1119 1119
 	 */
1120 1120
 	public function add_note( $note = false ) {
1121 1121
 		// Bail if no note specified.
Please login to merge, or discard this patch.
Spacing   +268 added lines, -269 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
 
@@ -395,13 +395,13 @@  discard block
 block discarded – undo
395 395
 	 *
396 396
 	 * @return mixed void|false
397 397
 	 */
398
-	public function __construct( $payment_id = false ) {
398
+	public function __construct($payment_id = false) {
399 399
 
400
-		if ( empty( $payment_id ) ) {
400
+		if (empty($payment_id)) {
401 401
 			return false;
402 402
 		}
403 403
 
404
-		$this->setup_payment( $payment_id );
404
+		$this->setup_payment($payment_id);
405 405
 	}
406 406
 
407 407
 	/**
@@ -414,11 +414,11 @@  discard block
 block discarded – undo
414 414
 	 *
415 415
 	 * @return mixed        The value.
416 416
 	 */
417
-	public function __get( $key ) {
417
+	public function __get($key) {
418 418
 
419
-		if ( method_exists( $this, 'get_' . $key ) ) {
419
+		if (method_exists($this, 'get_'.$key)) {
420 420
 
421
-			$value = call_user_func( array( $this, 'get_' . $key ) );
421
+			$value = call_user_func(array($this, 'get_'.$key));
422 422
 
423 423
 		} else {
424 424
 
@@ -440,18 +440,18 @@  discard block
 block discarded – undo
440 440
 	 * @param  string $key   The property name
441 441
 	 * @param  mixed  $value The value of the property
442 442
 	 */
443
-	public function __set( $key, $value ) {
444
-		$ignore = array( '_ID' );
443
+	public function __set($key, $value) {
444
+		$ignore = array('_ID');
445 445
 
446
-		if ( 'status' === $key ) {
446
+		if ('status' === $key) {
447 447
 			$this->old_status = $this->status;
448 448
 		}
449 449
 
450
-		if ( ! in_array( $key, $ignore ) ) {
451
-			$this->pending[ $key ] = $value;
450
+		if ( ! in_array($key, $ignore)) {
451
+			$this->pending[$key] = $value;
452 452
 		}
453 453
 
454
-		if ( '_ID' !== $key ) {
454
+		if ('_ID' !== $key) {
455 455
 			$this->$key = $value;
456 456
 		}
457 457
 	}
@@ -466,9 +466,9 @@  discard block
 block discarded – undo
466 466
 	 *
467 467
 	 * @return boolean|null       If the item is set or not
468 468
 	 */
469
-	public function __isset( $name ) {
470
-		if ( property_exists( $this, $name ) ) {
471
-			return false === empty( $this->$name );
469
+	public function __isset($name) {
470
+		if (property_exists($this, $name)) {
471
+			return false === empty($this->$name);
472 472
 		} else {
473 473
 			return null;
474 474
 		}
@@ -484,20 +484,20 @@  discard block
 block discarded – undo
484 484
 	 *
485 485
 	 * @return bool            If the setup was successful or not
486 486
 	 */
487
-	private function setup_payment( $payment_id ) {
487
+	private function setup_payment($payment_id) {
488 488
 		$this->pending = array();
489 489
 
490
-		if ( empty( $payment_id ) ) {
490
+		if (empty($payment_id)) {
491 491
 			return false;
492 492
 		}
493 493
 
494
-		$payment = get_post( absint( $payment_id ) );
494
+		$payment = get_post(absint($payment_id));
495 495
 
496
-		if ( ! $payment || is_wp_error( $payment ) ) {
496
+		if ( ! $payment || is_wp_error($payment)) {
497 497
 			return false;
498 498
 		}
499 499
 
500
-		if ( 'give_payment' !== $payment->post_type ) {
500
+		if ('give_payment' !== $payment->post_type) {
501 501
 			return false;
502 502
 		}
503 503
 
@@ -511,17 +511,17 @@  discard block
 block discarded – undo
511 511
 		 * @param Give_Payment $this       Payment object.
512 512
 		 * @param int          $payment_id The ID of the payment.
513 513
 		 */
514
-		do_action( 'give_pre_setup_payment', $this, $payment_id );
514
+		do_action('give_pre_setup_payment', $this, $payment_id);
515 515
 
516 516
 		// Get payment from cache.
517
-		$donation_vars = Give_Cache::get_group( $payment_id, 'give-donations' );
517
+		$donation_vars = Give_Cache::get_group($payment_id, 'give-donations');
518 518
 
519
-		if ( is_null( $donation_vars ) ) {
519
+		if (is_null($donation_vars)) {
520 520
 			// Primary Identifier.
521
-			$this->ID = absint( $payment_id );
521
+			$this->ID = absint($payment_id);
522 522
 
523 523
 			// Protected ID that can never be changed.
524
-			$this->_ID = absint( $payment_id );
524
+			$this->_ID = absint($payment_id);
525 525
 
526 526
 			// We have a payment, get the generic payment_meta item to reduce calls to it.
527 527
 			$this->payment_meta = $this->get_meta();
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
 			$this->parent_payment = $payment->post_parent;
538 538
 
539 539
 			$all_payment_statuses  = give_get_payment_statuses();
540
-			$this->status_nicename = array_key_exists( $this->status, $all_payment_statuses ) ? $all_payment_statuses[ $this->status ] : ucfirst( $this->status );
540
+			$this->status_nicename = array_key_exists($this->status, $all_payment_statuses) ? $all_payment_statuses[$this->status] : ucfirst($this->status);
541 541
 
542 542
 			// Currency Based.
543 543
 			$this->total    = $this->setup_total();
@@ -566,10 +566,10 @@  discard block
 block discarded – undo
566 566
 			$this->key        = $this->setup_payment_key();
567 567
 			$this->number     = $this->setup_payment_number();
568 568
 
569
-			Give_Cache::set_group( $this->ID, get_object_vars( $this ), 'give-donations' );
569
+			Give_Cache::set_group($this->ID, get_object_vars($this), 'give-donations');
570 570
 		} else {
571 571
 
572
-			foreach ( $donation_vars as $donation_var => $value ) {
572
+			foreach ($donation_vars as $donation_var => $value) {
573 573
 				$this->$donation_var = $value;
574 574
 			}
575 575
 		}
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
 		 * @param Give_Payment $this       Payment object.
585 585
 		 * @param int          $payment_id The ID of the payment.
586 586
 		 */
587
-		do_action( 'give_setup_payment', $this, $payment_id );
587
+		do_action('give_setup_payment', $this, $payment_id);
588 588
 
589 589
 		return true;
590 590
 	}
@@ -603,11 +603,11 @@  discard block
 block discarded – undo
603 603
 	 *
604 604
 	 * @return void
605 605
 	 */
606
-	public function update_payment_setup( $payment_id ) {
606
+	public function update_payment_setup($payment_id) {
607 607
 		// Delete cache.
608
-		Give_Cache::delete_group( $this->ID,'give-donations' );
608
+		Give_Cache::delete_group($this->ID, 'give-donations');
609 609
 
610
-		$this->setup_payment( $payment_id );
610
+		$this->setup_payment($payment_id);
611 611
 	}
612 612
 
613 613
 	/**
@@ -622,24 +622,24 @@  discard block
 block discarded – undo
622 622
 
623 623
 		// Construct the payment title.
624 624
 		$payment_title = '';
625
-		if ( ! empty( $this->first_name ) && ! empty( $this->last_name ) ) {
626
-			$payment_title = $this->first_name . ' ' . $this->last_name;
627
-		} elseif ( ! empty( $this->first_name ) && empty( $this->last_name ) ) {
625
+		if ( ! empty($this->first_name) && ! empty($this->last_name)) {
626
+			$payment_title = $this->first_name.' '.$this->last_name;
627
+		} elseif ( ! empty($this->first_name) && empty($this->last_name)) {
628 628
 			$payment_title = $this->first_name;
629
-		} elseif ( ! empty( $this->email ) && is_email( $this->email ) ) {
629
+		} elseif ( ! empty($this->email) && is_email($this->email)) {
630 630
 			$payment_title = $this->email;
631 631
 		}
632 632
 
633 633
 		// Set Key.
634
-		if ( empty( $this->key ) ) {
634
+		if (empty($this->key)) {
635 635
 
636
-			$auth_key             = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
637
-			$this->key            = strtolower( md5( $this->email . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) );  // Unique key
636
+			$auth_key             = defined('AUTH_KEY') ? AUTH_KEY : '';
637
+			$this->key            = strtolower(md5($this->email.date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); // Unique key
638 638
 			$this->pending['key'] = $this->key;
639 639
 		}
640 640
 
641 641
 		// Set IP.
642
-		if ( empty( $this->ip ) ) {
642
+		if (empty($this->ip)) {
643 643
 
644 644
 			$this->ip            = give_get_ip();
645 645
 			$this->pending['ip'] = $this->ip;
@@ -668,19 +668,19 @@  discard block
 block discarded – undo
668 668
 			'status'       => $this->status,
669 669
 		);
670 670
 
671
-		$args = apply_filters( 'give_insert_payment_args', array(
671
+		$args = apply_filters('give_insert_payment_args', array(
672 672
 			'post_title'    => $payment_title,
673 673
 			'post_status'   => $this->status,
674 674
 			'post_type'     => 'give_payment',
675
-			'post_date'     => ! empty( $this->date ) ? $this->date : null,
676
-			'post_date_gmt' => ! empty( $this->date ) ? get_gmt_from_date( $this->date ) : null,
675
+			'post_date'     => ! empty($this->date) ? $this->date : null,
676
+			'post_date_gmt' => ! empty($this->date) ? get_gmt_from_date($this->date) : null,
677 677
 			'post_parent'   => $this->parent_payment,
678
-		), $payment_data );
678
+		), $payment_data);
679 679
 
680 680
 		// Create a blank payment
681
-		$payment_id = wp_insert_post( $args );
681
+		$payment_id = wp_insert_post($args);
682 682
 
683
-		if ( ! empty( $payment_id ) ) {
683
+		if ( ! empty($payment_id)) {
684 684
 
685 685
 			$this->ID  = $payment_id;
686 686
 			$this->_ID = $payment_id;
@@ -692,42 +692,42 @@  discard block
 block discarded – undo
692 692
 			 *
693 693
 			 * @since 1.8.13
694 694
 			 */
695
-			$donor = apply_filters( 'give_update_donor_information', $donor, $payment_id, $payment_data, $args );
695
+			$donor = apply_filters('give_update_donor_information', $donor, $payment_id, $payment_data, $args);
696 696
 
697
-			if ( did_action( 'give_pre_process_donation' ) && is_user_logged_in() ) {
698
-				$donor = new Give_Donor( get_current_user_id(), true );
697
+			if (did_action('give_pre_process_donation') && is_user_logged_in()) {
698
+				$donor = new Give_Donor(get_current_user_id(), true);
699 699
 
700 700
 				// Donor is logged in but used a different email to purchase with so assign to their donor record.
701
-				if ( ! empty( $donor->id ) && $this->email !== $donor->email ) {
702
-					$donor->add_email( $this->email );
701
+				if ( ! empty($donor->id) && $this->email !== $donor->email) {
702
+					$donor->add_email($this->email);
703 703
 				}
704 704
 			}
705 705
 
706
-			if ( empty( $donor->id ) ) {
707
-				$donor = new Give_Donor( $this->email );
706
+			if (empty($donor->id)) {
707
+				$donor = new Give_Donor($this->email);
708 708
 			}
709 709
 
710
-			if ( empty( $donor->id ) ) {
710
+			if (empty($donor->id)) {
711 711
 
712 712
 				$donor_data = array(
713
-					'name'    => ! is_email( $payment_title ) ? $this->first_name . ' ' . $this->last_name : '',
713
+					'name'    => ! is_email($payment_title) ? $this->first_name.' '.$this->last_name : '',
714 714
 					'email'   => $this->email,
715 715
 					'user_id' => $this->user_id,
716 716
 				);
717 717
 
718
-				$donor->create( $donor_data );
718
+				$donor->create($donor_data);
719 719
 
720 720
 			}
721 721
 
722 722
 			// Update Donor Meta once donor is created.
723
-			$donor->update_meta( '_give_donor_first_name', $this->first_name );
724
-			$donor->update_meta( '_give_donor_last_name', $this->last_name );
723
+			$donor->update_meta('_give_donor_first_name', $this->first_name);
724
+			$donor->update_meta('_give_donor_last_name', $this->last_name);
725 725
 
726 726
 			$this->customer_id            = $donor->id;
727 727
 			$this->pending['customer_id'] = $this->customer_id;
728
-			$donor->attach_payment( $this->ID, false );
728
+			$donor->attach_payment($this->ID, false);
729 729
 
730
-			$this->payment_meta = apply_filters( 'give_payment_meta', $this->payment_meta, $payment_data );
730
+			$this->payment_meta = apply_filters('give_payment_meta', $this->payment_meta, $payment_data);
731 731
 
732 732
 			/*
733 733
 			 * _give_payment_meta backward compatibility.
@@ -735,14 +735,14 @@  discard block
 block discarded – undo
735 735
 			 * @since 2.0.1
736 736
 			 */
737 737
 			$custom_payment_meta = array_diff(
738
-				array_map( 'maybe_serialize', $this->payment_meta ),
739
-				array_map( 'maybe_serialize', $payment_data )
738
+				array_map('maybe_serialize', $this->payment_meta),
739
+				array_map('maybe_serialize', $payment_data)
740 740
 			);
741 741
 
742
-			if( ! empty( $custom_payment_meta ) ) {
743
-				give_doing_it_wrong( '_give_payment_meta', __( 'This custom meta key deprecated. We are not using this meta key for storing payment meta but your custom meta data will be store because we added backward compatibility. Please change your logic because in future we can remove it.', 'give' ), '2.0.0' );
742
+			if ( ! empty($custom_payment_meta)) {
743
+				give_doing_it_wrong('_give_payment_meta', __('This custom meta key deprecated. We are not using this meta key for storing payment meta but your custom meta data will be store because we added backward compatibility. Please change your logic because in future we can remove it.', 'give'), '2.0.0');
744 744
 
745
-				$this->update_meta( '_give_payment_meta', array_map( 'maybe_unserialize', $custom_payment_meta ) );
745
+				$this->update_meta('_give_payment_meta', array_map('maybe_unserialize', $custom_payment_meta));
746 746
 			}
747 747
 
748 748
 			$this->new = true;
@@ -765,11 +765,11 @@  discard block
 block discarded – undo
765 765
 		$saved = false;
766 766
 
767 767
 		// Must have an ID.
768
-		if ( empty( $this->ID ) ) {
768
+		if (empty($this->ID)) {
769 769
 
770 770
 			$payment_id = $this->insert_payment();
771 771
 
772
-			if ( false === $payment_id ) {
772
+			if (false === $payment_id) {
773 773
 				$saved = false;
774 774
 			} else {
775 775
 				$this->ID = $payment_id;
@@ -777,42 +777,42 @@  discard block
 block discarded – undo
777 777
 		}
778 778
 
779 779
 		// Set ID if not matching.
780
-		if ( $this->ID !== $this->_ID ) {
780
+		if ($this->ID !== $this->_ID) {
781 781
 			$this->ID = $this->_ID;
782 782
 		}
783 783
 
784 784
 		// If we have something pending, let's save it.
785
-		if ( ! empty( $this->pending ) ) {
785
+		if ( ! empty($this->pending)) {
786 786
 
787 787
 			$total_increase = 0;
788 788
 			$total_decrease = 0;
789 789
 
790
-			foreach ( $this->pending as $key => $value ) {
790
+			foreach ($this->pending as $key => $value) {
791 791
 
792
-				switch ( $key ) {
792
+				switch ($key) {
793 793
 
794 794
 					case 'donations':
795 795
 						// Update totals for pending donations.
796
-						foreach ( $this->pending[ $key ] as $item ) {
796
+						foreach ($this->pending[$key] as $item) {
797 797
 
798
-							$quantity = isset( $item['quantity'] ) ? $item['quantity'] : 1;
799
-							$price_id = isset( $item['price_id'] ) ? $item['price_id'] : 0;
798
+							$quantity = isset($item['quantity']) ? $item['quantity'] : 1;
799
+							$price_id = isset($item['price_id']) ? $item['price_id'] : 0;
800 800
 
801
-							switch ( $item['action'] ) {
801
+							switch ($item['action']) {
802 802
 
803 803
 								case 'add':
804 804
 
805 805
 									$price = $item['price'];
806 806
 
807
-									if ( 'publish' === $this->status || 'complete' === $this->status ) {
807
+									if ('publish' === $this->status || 'complete' === $this->status) {
808 808
 
809 809
 										// Add donation to logs.
810
-										$log_date = date_i18n( 'Y-m-d G:i:s', current_time( 'timestamp' ) );
811
-										give_record_donation_in_log( $item['id'], $this->ID, $price_id, $log_date );
810
+										$log_date = date_i18n('Y-m-d G:i:s', current_time('timestamp'));
811
+										give_record_donation_in_log($item['id'], $this->ID, $price_id, $log_date);
812 812
 
813
-										$form = new Give_Donate_Form( $item['id'] );
814
-										$form->increase_sales( $quantity );
815
-										$form->increase_earnings( $price );
813
+										$form = new Give_Donate_Form($item['id']);
814
+										$form->increase_sales($quantity);
815
+										$form->increase_earnings($price);
816 816
 
817 817
 										$total_increase += $price;
818 818
 									}
@@ -820,10 +820,10 @@  discard block
 block discarded – undo
820 820
 
821 821
 								case 'remove':
822 822
 									$this->delete_sales_logs();
823
-									if ( 'publish' === $this->status || 'complete' === $this->status ) {
824
-										$form = new Give_Donate_Form( $item['id'] );
825
-										$form->decrease_sales( $quantity );
826
-										$form->decrease_earnings( $item['amount'] );
823
+									if ('publish' === $this->status || 'complete' === $this->status) {
824
+										$form = new Give_Donate_Form($item['id']);
825
+										$form->decrease_sales($quantity);
826
+										$form->decrease_earnings($item['amount']);
827 827
 
828 828
 										$total_decrease += $item['amount'];
829 829
 									}
@@ -834,27 +834,27 @@  discard block
 block discarded – undo
834 834
 						break;
835 835
 
836 836
 					case 'status':
837
-						$this->update_status( $this->status );
837
+						$this->update_status($this->status);
838 838
 						break;
839 839
 
840 840
 					case 'gateway':
841
-						$this->update_meta( '_give_payment_gateway', $this->gateway );
841
+						$this->update_meta('_give_payment_gateway', $this->gateway);
842 842
 						break;
843 843
 
844 844
 					case 'mode':
845
-						$this->update_meta( '_give_payment_mode', $this->mode );
845
+						$this->update_meta('_give_payment_mode', $this->mode);
846 846
 						break;
847 847
 
848 848
 					case 'transaction_id':
849
-						$this->update_meta( '_give_payment_transaction_id', $this->transaction_id );
849
+						$this->update_meta('_give_payment_transaction_id', $this->transaction_id);
850 850
 						break;
851 851
 
852 852
 					case 'ip':
853
-						$this->update_meta( '_give_payment_donor_ip', $this->ip );
853
+						$this->update_meta('_give_payment_donor_ip', $this->ip);
854 854
 						break;
855 855
 
856 856
 					case 'customer_id':
857
-						$this->update_meta( '_give_payment_donor_id', $this->customer_id );
857
+						$this->update_meta('_give_payment_donor_id', $this->customer_id);
858 858
 						break;
859 859
 
860 860
 					// case 'user_id':
@@ -862,58 +862,58 @@  discard block
 block discarded – undo
862 862
 					// 	break;
863 863
 
864 864
 					case 'form_title':
865
-						$this->update_meta( '_give_payment_form_title', $this->form_title );
865
+						$this->update_meta('_give_payment_form_title', $this->form_title);
866 866
 						break;
867 867
 
868 868
 					case 'form_id':
869
-						$this->update_meta( '_give_payment_form_id', $this->form_id );
869
+						$this->update_meta('_give_payment_form_id', $this->form_id);
870 870
 						break;
871 871
 
872 872
 					case 'price_id':
873
-						$this->update_meta( '_give_payment_price_id', $this->price_id );
873
+						$this->update_meta('_give_payment_price_id', $this->price_id);
874 874
 						break;
875 875
 
876 876
 					case 'first_name':
877
-						$this->update_meta( '_give_donor_billing_first_name', $this->first_name );
877
+						$this->update_meta('_give_donor_billing_first_name', $this->first_name);
878 878
 						break;
879 879
 
880 880
 					case 'last_name':
881
-						$this->update_meta( '_give_donor_billing_last_name', $this->last_name );
881
+						$this->update_meta('_give_donor_billing_last_name', $this->last_name);
882 882
 						break;
883 883
 
884 884
 					case 'currency':
885
-						$this->update_meta( '_give_payment_currency', $this->currency );
885
+						$this->update_meta('_give_payment_currency', $this->currency);
886 886
 						break;
887 887
 
888 888
 					case 'address':
889
-						if ( ! empty( $this->address ) ) {
890
-							foreach ( $this->address as $address_name => $address ) {
891
-								switch ( $address_name ) {
889
+						if ( ! empty($this->address)) {
890
+							foreach ($this->address as $address_name => $address) {
891
+								switch ($address_name) {
892 892
 									case 'line1':
893
-										$this->update_meta( '_give_donor_billing_address1', $address );
893
+										$this->update_meta('_give_donor_billing_address1', $address);
894 894
 										break;
895 895
 
896 896
 									case 'line2':
897
-										$this->update_meta( '_give_donor_billing_address2', $address );
897
+										$this->update_meta('_give_donor_billing_address2', $address);
898 898
 										break;
899 899
 
900 900
 									default:
901
-										$this->update_meta( "_give_donor_billing_{$address_name}", $address );
901
+										$this->update_meta("_give_donor_billing_{$address_name}", $address);
902 902
 								}
903 903
 							}
904 904
 						}
905 905
 						break;
906 906
 
907 907
 					case 'email':
908
-						$this->update_meta( '_give_payment_donor_email', $this->email );
908
+						$this->update_meta('_give_payment_donor_email', $this->email);
909 909
 						break;
910 910
 
911 911
 					case 'key':
912
-						$this->update_meta( '_give_payment_purchase_key', $this->key );
912
+						$this->update_meta('_give_payment_purchase_key', $this->key);
913 913
 						break;
914 914
 
915 915
 					case 'number':
916
-						$this->update_meta( '_give_payment_number', $this->number );
916
+						$this->update_meta('_give_payment_number', $this->number);
917 917
 						break;
918 918
 
919 919
 					case 'date':
@@ -923,11 +923,11 @@  discard block
 block discarded – undo
923 923
 							'edit_date' => true,
924 924
 						);
925 925
 
926
-						wp_update_post( $args );
926
+						wp_update_post($args);
927 927
 						break;
928 928
 
929 929
 					case 'completed_date':
930
-						$this->update_meta( '_give_completed_date', $this->completed_date );
930
+						$this->update_meta('_give_completed_date', $this->completed_date);
931 931
 						break;
932 932
 
933 933
 					case 'parent_payment':
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
 							'post_parent' => $this->parent_payment,
937 937
 						);
938 938
 
939
-						wp_update_post( $args );
939
+						wp_update_post($args);
940 940
 						break;
941 941
 
942 942
 					default:
@@ -947,40 +947,40 @@  discard block
 block discarded – undo
947 947
 						 *
948 948
 						 * @param Give_Payment $this Payment object.
949 949
 						 */
950
-						do_action( 'give_payment_save', $this, $key );
950
+						do_action('give_payment_save', $this, $key);
951 951
 						break;
952 952
 				}// End switch().
953 953
 			}// End foreach().
954 954
 
955
-			if ( 'pending' !== $this->status ) {
955
+			if ('pending' !== $this->status) {
956 956
 
957
-				$donor = new Give_Donor( $this->customer_id );
957
+				$donor = new Give_Donor($this->customer_id);
958 958
 
959 959
 				$total_change = $total_increase - $total_decrease;
960
-				if ( $total_change < 0 ) {
960
+				if ($total_change < 0) {
961 961
 
962
-					$total_change = - ( $total_change );
962
+					$total_change = - ($total_change);
963 963
 					// Decrease the donor's donation stats.
964
-					$donor->decrease_value( $total_change );
965
-					give_decrease_total_earnings( $total_change );
964
+					$donor->decrease_value($total_change);
965
+					give_decrease_total_earnings($total_change);
966 966
 
967
-				} elseif ( $total_change > 0 ) {
967
+				} elseif ($total_change > 0) {
968 968
 
969 969
 					// Increase the donor's donation stats.
970
-					$donor->increase_value( $total_change );
971
-					give_increase_total_earnings( $total_change );
970
+					$donor->increase_value($total_change);
971
+					give_increase_total_earnings($total_change);
972 972
 
973 973
 				}
974 974
 			}
975 975
 
976
-			$this->update_meta( '_give_payment_total', give_sanitize_amount_for_db( $this->total ) );
976
+			$this->update_meta('_give_payment_total', give_sanitize_amount_for_db($this->total));
977 977
 
978 978
 			$this->pending = array();
979 979
 			$saved         = true;
980 980
 		}// End if().
981 981
 
982
-		if ( true === $saved ) {
983
-			$this->setup_payment( $this->ID );
982
+		if (true === $saved) {
983
+			$this->setup_payment($this->ID);
984 984
 		}
985 985
 
986 986
 		return $saved;
@@ -998,12 +998,12 @@  discard block
 block discarded – undo
998 998
 	 *
999 999
 	 * @return bool           True when successful, false otherwise
1000 1000
 	 */
1001
-	public function add_donation( $form_id = 0, $args = array(), $options = array() ) {
1001
+	public function add_donation($form_id = 0, $args = array(), $options = array()) {
1002 1002
 
1003
-		$donation = new Give_Donate_Form( $form_id );
1003
+		$donation = new Give_Donate_Form($form_id);
1004 1004
 
1005 1005
 		// Bail if this post isn't a give donation form.
1006
-		if ( ! $donation || $donation->post_type !== 'give_forms' ) {
1006
+		if ( ! $donation || $donation->post_type !== 'give_forms') {
1007 1007
 			return false;
1008 1008
 		}
1009 1009
 
@@ -1013,59 +1013,59 @@  discard block
 block discarded – undo
1013 1013
 			'price_id' => false,
1014 1014
 		);
1015 1015
 
1016
-		$args = wp_parse_args( apply_filters( 'give_payment_add_donation_args', $args, $donation->ID ), $defaults );
1016
+		$args = wp_parse_args(apply_filters('give_payment_add_donation_args', $args, $donation->ID), $defaults);
1017 1017
 
1018 1018
 		// Allow overriding the price.
1019
-		if ( false !== $args['price'] ) {
1019
+		if (false !== $args['price']) {
1020 1020
 			$donation_amount = $args['price'];
1021 1021
 		} else {
1022 1022
 
1023 1023
 			// Deal with variable pricing.
1024
-			if ( give_has_variable_prices( $donation->ID ) ) {
1025
-				$prices          = give_get_meta( $form_id, '_give_donation_levels', true );
1024
+			if (give_has_variable_prices($donation->ID)) {
1025
+				$prices          = give_get_meta($form_id, '_give_donation_levels', true);
1026 1026
 				$donation_amount = '';
1027 1027
 				// Loop through prices.
1028
-				foreach ( $prices as $price ) {
1028
+				foreach ($prices as $price) {
1029 1029
 					// Find a match between price_id and level_id.
1030 1030
 					// First verify array keys exists THEN make the match.
1031
-					if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) )
1031
+					if ((isset($args['price_id']) && isset($price['_give_id']['level_id']))
1032 1032
 					     && $args['price_id'] == $price['_give_id']['level_id']
1033 1033
 					) {
1034 1034
 						$donation_amount = $price['_give_amount'];
1035 1035
 					}
1036 1036
 				}
1037 1037
 				// Fallback to the lowest price point.
1038
-				if ( $donation_amount == '' ) {
1039
-					$donation_amount  = give_get_lowest_price_option( $donation->ID );
1040
-					$args['price_id'] = give_get_lowest_price_id( $donation->ID );
1038
+				if ($donation_amount == '') {
1039
+					$donation_amount  = give_get_lowest_price_option($donation->ID);
1040
+					$args['price_id'] = give_get_lowest_price_id($donation->ID);
1041 1041
 				}
1042 1042
 			} else {
1043 1043
 				// Simple form price.
1044
-				$donation_amount = give_get_form_price( $donation->ID );
1044
+				$donation_amount = give_get_form_price($donation->ID);
1045 1045
 			}
1046 1046
 		}
1047 1047
 
1048 1048
 		// Sanitizing the price here so we don't have a dozen calls later.
1049
-		$donation_amount = give_maybe_sanitize_amount( $donation_amount );
1050
-		$total           = round( $donation_amount, give_get_price_decimals( $this->ID ) );
1049
+		$donation_amount = give_maybe_sanitize_amount($donation_amount);
1050
+		$total           = round($donation_amount, give_get_price_decimals($this->ID));
1051 1051
 
1052 1052
 		// Add Options.
1053 1053
 		$default_options = array();
1054
-		if ( false !== $args['price_id'] ) {
1054
+		if (false !== $args['price_id']) {
1055 1055
 			$default_options['price_id'] = (int) $args['price_id'];
1056 1056
 		}
1057
-		$options = wp_parse_args( $options, $default_options );
1057
+		$options = wp_parse_args($options, $default_options);
1058 1058
 
1059 1059
 		// Do not allow totals to go negative.
1060
-		if ( $total < 0 ) {
1060
+		if ($total < 0) {
1061 1061
 			$total = 0;
1062 1062
 		}
1063 1063
 
1064 1064
 		$donation = array(
1065 1065
 			'name'     => $donation->post_title,
1066 1066
 			'id'       => $donation->ID,
1067
-			'price'    => round( $total, give_get_price_decimals( $this->ID ) ),
1068
-			'subtotal' => round( $total, give_get_price_decimals( $this->ID ) ),
1067
+			'price'    => round($total, give_get_price_decimals($this->ID)),
1068
+			'subtotal' => round($total, give_get_price_decimals($this->ID)),
1069 1069
 			'price_id' => $args['price_id'],
1070 1070
 			'action'   => 'add',
1071 1071
 			'options'  => $options,
@@ -1073,7 +1073,7 @@  discard block
 block discarded – undo
1073 1073
 
1074 1074
 		$this->pending['donations'][] = $donation;
1075 1075
 
1076
-		$this->increase_subtotal( $total );
1076
+		$this->increase_subtotal($total);
1077 1077
 
1078 1078
 		return true;
1079 1079
 
@@ -1090,7 +1090,7 @@  discard block
 block discarded – undo
1090 1090
 	 *
1091 1091
 	 * @return bool           If the item was removed or not
1092 1092
 	 */
1093
-	public function remove_donation( $form_id, $args = array() ) {
1093
+	public function remove_donation($form_id, $args = array()) {
1094 1094
 
1095 1095
 		// Set some defaults.
1096 1096
 		$defaults = array(
@@ -1098,12 +1098,12 @@  discard block
 block discarded – undo
1098 1098
 			'price'    => false,
1099 1099
 			'price_id' => false,
1100 1100
 		);
1101
-		$args     = wp_parse_args( $args, $defaults );
1101
+		$args = wp_parse_args($args, $defaults);
1102 1102
 
1103
-		$form = new Give_Donate_Form( $form_id );
1103
+		$form = new Give_Donate_Form($form_id);
1104 1104
 
1105 1105
 		// Bail if this post isn't a valid give donation form.
1106
-		if ( ! $form || $form->post_type !== 'give_forms' ) {
1106
+		if ( ! $form || $form->post_type !== 'give_forms') {
1107 1107
 			return false;
1108 1108
 		}
1109 1109
 
@@ -1116,7 +1116,7 @@  discard block
 block discarded – undo
1116 1116
 
1117 1117
 		$this->pending['donations'][] = $pending_args;
1118 1118
 
1119
-		$this->decrease_subtotal( $this->total );
1119
+		$this->decrease_subtotal($this->total);
1120 1120
 
1121 1121
 		return true;
1122 1122
 	}
@@ -1132,13 +1132,13 @@  discard block
 block discarded – undo
1132 1132
 	 *
1133 1133
 	 * @return bool           If the note was specified or not
1134 1134
 	 */
1135
-	public function add_note( $note = false ) {
1135
+	public function add_note($note = false) {
1136 1136
 		// Bail if no note specified.
1137
-		if ( ! $note ) {
1137
+		if ( ! $note) {
1138 1138
 			return false;
1139 1139
 		}
1140 1140
 
1141
-		give_insert_payment_note( $this->ID, $note );
1141
+		give_insert_payment_note($this->ID, $note);
1142 1142
 	}
1143 1143
 
1144 1144
 	/**
@@ -1151,8 +1151,8 @@  discard block
 block discarded – undo
1151 1151
 	 *
1152 1152
 	 * @return void
1153 1153
 	 */
1154
-	private function increase_subtotal( $amount = 0.00 ) {
1155
-		$amount         = (float) $amount;
1154
+	private function increase_subtotal($amount = 0.00) {
1155
+		$amount = (float) $amount;
1156 1156
 		$this->subtotal += $amount;
1157 1157
 
1158 1158
 		$this->recalculate_total();
@@ -1168,11 +1168,11 @@  discard block
 block discarded – undo
1168 1168
 	 *
1169 1169
 	 * @return void
1170 1170
 	 */
1171
-	private function decrease_subtotal( $amount = 0.00 ) {
1172
-		$amount         = (float) $amount;
1171
+	private function decrease_subtotal($amount = 0.00) {
1172
+		$amount = (float) $amount;
1173 1173
 		$this->subtotal -= $amount;
1174 1174
 
1175
-		if ( $this->subtotal < 0 ) {
1175
+		if ($this->subtotal < 0) {
1176 1176
 			$this->subtotal = 0;
1177 1177
 		}
1178 1178
 
@@ -1201,24 +1201,24 @@  discard block
 block discarded – undo
1201 1201
 	 *
1202 1202
 	 * @return bool   $updated Returns if the status was successfully updated.
1203 1203
 	 */
1204
-	public function update_status( $status = false ) {
1204
+	public function update_status($status = false) {
1205 1205
 
1206 1206
 		// standardize the 'complete(d)' status.
1207
-		if ( $status == 'completed' || $status == 'complete' ) {
1207
+		if ($status == 'completed' || $status == 'complete') {
1208 1208
 			$status = 'publish';
1209 1209
 		}
1210 1210
 
1211
-		$old_status = ! empty( $this->old_status ) ? $this->old_status : false;
1211
+		$old_status = ! empty($this->old_status) ? $this->old_status : false;
1212 1212
 
1213
-		if ( $old_status === $status ) {
1213
+		if ($old_status === $status) {
1214 1214
 			return false; // Don't permit status changes that aren't changes.
1215 1215
 		}
1216 1216
 
1217
-		$do_change = apply_filters( 'give_should_update_payment_status', true, $this->ID, $status, $old_status );
1217
+		$do_change = apply_filters('give_should_update_payment_status', true, $this->ID, $status, $old_status);
1218 1218
 
1219 1219
 		$updated = false;
1220 1220
 
1221
-		if ( $do_change ) {
1221
+		if ($do_change) {
1222 1222
 
1223 1223
 			/**
1224 1224
 			 * Fires before changing payment status.
@@ -1229,21 +1229,21 @@  discard block
 block discarded – undo
1229 1229
 			 * @param string $status     The new status.
1230 1230
 			 * @param string $old_status The old status.
1231 1231
 			 */
1232
-			do_action( 'give_before_payment_status_change', $this->ID, $status, $old_status );
1232
+			do_action('give_before_payment_status_change', $this->ID, $status, $old_status);
1233 1233
 
1234 1234
 			$update_fields = array(
1235 1235
 				'ID'          => $this->ID,
1236 1236
 				'post_status' => $status,
1237
-				'edit_date'   => current_time( 'mysql' ),
1237
+				'edit_date'   => current_time('mysql'),
1238 1238
 			);
1239 1239
 
1240
-			$updated = wp_update_post( apply_filters( 'give_update_payment_status_fields', $update_fields ) );
1240
+			$updated = wp_update_post(apply_filters('give_update_payment_status_fields', $update_fields));
1241 1241
 
1242 1242
 			$all_payment_statuses  = give_get_payment_statuses();
1243
-			$this->status_nicename = array_key_exists( $status, $all_payment_statuses ) ? $all_payment_statuses[ $status ] : ucfirst( $status );
1243
+			$this->status_nicename = array_key_exists($status, $all_payment_statuses) ? $all_payment_statuses[$status] : ucfirst($status);
1244 1244
 
1245 1245
 			// Process any specific status functions.
1246
-			$this->process_status( $status );
1246
+			$this->process_status($status);
1247 1247
 
1248 1248
 			/**
1249 1249
 			 * Fires after changing payment status.
@@ -1254,7 +1254,7 @@  discard block
 block discarded – undo
1254 1254
 			 * @param string $status     The new status.
1255 1255
 			 * @param string $old_status The old status.
1256 1256
 			 */
1257
-			do_action( 'give_update_payment_status', $this->ID, $status, $old_status );
1257
+			do_action('give_update_payment_status', $this->ID, $status, $old_status);
1258 1258
 
1259 1259
 		}// End if().
1260 1260
 
@@ -1289,24 +1289,24 @@  discard block
 block discarded – undo
1289 1289
 	 *
1290 1290
 	 * @return mixed             The value from the post meta
1291 1291
 	 */
1292
-	public function get_meta( $meta_key = '_give_payment_meta', $single = true ) {
1293
-		if( ! has_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta' ) && ! doing_filter( 'get_post_metadata' ) ) {
1294
-			add_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4 );
1292
+	public function get_meta($meta_key = '_give_payment_meta', $single = true) {
1293
+		if ( ! has_filter('get_post_metadata', 'give_bc_v20_get_payment_meta') && ! doing_filter('get_post_metadata')) {
1294
+			add_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4);
1295 1295
 		}
1296 1296
 
1297
-		$meta = give_get_meta( $this->ID, $meta_key, $single );
1297
+		$meta = give_get_meta($this->ID, $meta_key, $single);
1298 1298
 
1299 1299
 		/**
1300 1300
 		 * Filter the specific meta key value.
1301 1301
 		 *
1302 1302
 		 * @since 1.5
1303 1303
 		 */
1304
-		$meta = apply_filters( "give_get_payment_meta_{$meta_key}", $meta, $this->ID );
1304
+		$meta = apply_filters("give_get_payment_meta_{$meta_key}", $meta, $this->ID);
1305 1305
 
1306 1306
 		// Security check.
1307
-		if ( is_serialized( $meta ) ) {
1308
-			preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $meta, $matches );
1309
-			if ( ! empty( $matches ) ) {
1307
+		if (is_serialized($meta)) {
1308
+			preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $meta, $matches);
1309
+			if ( ! empty($matches)) {
1310 1310
 				$meta = array();
1311 1311
 			}
1312 1312
 		}
@@ -1316,7 +1316,7 @@  discard block
 block discarded – undo
1316 1316
 		 *
1317 1317
 		 * @since 1.5
1318 1318
 		 */
1319
-		return apply_filters( 'give_get_payment_meta', $meta, $this->ID, $meta_key );
1319
+		return apply_filters('give_get_payment_meta', $meta, $this->ID, $meta_key);
1320 1320
 	}
1321 1321
 
1322 1322
 	/**
@@ -1331,8 +1331,8 @@  discard block
 block discarded – undo
1331 1331
 	 *
1332 1332
 	 * @return int|bool           Meta ID if the key didn't exist, true on successful update, false on failure
1333 1333
 	 */
1334
-	public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) {
1335
-		if ( empty( $meta_key ) ) {
1334
+	public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') {
1335
+		if (empty($meta_key)) {
1336 1336
 			return false;
1337 1337
 		}
1338 1338
 
@@ -1342,9 +1342,9 @@  discard block
 block discarded – undo
1342 1342
 		 *
1343 1343
 		 * @since 1.5
1344 1344
 		 */
1345
-		$meta_value = apply_filters( "give_update_payment_meta_{$meta_key}", $meta_value, $this->ID );
1345
+		$meta_value = apply_filters("give_update_payment_meta_{$meta_key}", $meta_value, $this->ID);
1346 1346
 
1347
-		return give_update_meta( $this->ID, $meta_key, $meta_value, $prev_value );
1347
+		return give_update_meta($this->ID, $meta_key, $meta_value, $prev_value);
1348 1348
 	}
1349 1349
 
1350 1350
 	/**
@@ -1357,7 +1357,7 @@  discard block
 block discarded – undo
1357 1357
 	 *
1358 1358
 	 * @return void
1359 1359
 	 */
1360
-	private function process_status( $status ) {
1360
+	private function process_status($status) {
1361 1361
 		$process = true;
1362 1362
 
1363 1363
 		// Bailout, if changed from completed to preapproval/processing.
@@ -1372,9 +1372,9 @@  discard block
 block discarded – undo
1372 1372
 		}
1373 1373
 
1374 1374
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments.
1375
-		$process = apply_filters( "give_should_process_{$status}", $process, $this );
1375
+		$process = apply_filters("give_should_process_{$status}", $process, $this);
1376 1376
 
1377
-		if ( false === $process ) {
1377
+		if (false === $process) {
1378 1378
 			return;
1379 1379
 		}
1380 1380
 
@@ -1385,13 +1385,13 @@  discard block
 block discarded – undo
1385 1385
 		 *
1386 1386
 		 * @since 1.5
1387 1387
 		 */
1388
-		do_action( "give_pre_{$status}_payment", $this );
1388
+		do_action("give_pre_{$status}_payment", $this);
1389 1389
 
1390
-		$decrease_earnings       = apply_filters( "give_decrease_earnings_on_{$status}", true, $this );
1391
-		$decrease_donor_value    = apply_filters( "give_decrease_donor_value_on_{$status}", true, $this );
1392
-		$decrease_donation_count = apply_filters( "give_decrease_donors_donation_count_on_{$status}", true, $this );
1390
+		$decrease_earnings       = apply_filters("give_decrease_earnings_on_{$status}", true, $this);
1391
+		$decrease_donor_value    = apply_filters("give_decrease_donor_value_on_{$status}", true, $this);
1392
+		$decrease_donation_count = apply_filters("give_decrease_donors_donation_count_on_{$status}", true, $this);
1393 1393
 
1394
-		$this->maybe_alter_stats( $decrease_earnings, $decrease_donor_value, $decrease_donation_count );
1394
+		$this->maybe_alter_stats($decrease_earnings, $decrease_donor_value, $decrease_donation_count);
1395 1395
 		$this->delete_sales_logs();
1396 1396
 
1397 1397
 		// @todo: Refresh only range related stat cache
@@ -1404,7 +1404,7 @@  discard block
 block discarded – undo
1404 1404
 		 *
1405 1405
 		 * @since 1.5
1406 1406
 		 */
1407
-		do_action( "give_post_{$status}_payment", $this );
1407
+		do_action("give_post_{$status}_payment", $this);
1408 1408
 	}
1409 1409
 
1410 1410
 	/**
@@ -1419,25 +1419,25 @@  discard block
 block discarded – undo
1419 1419
 	 *
1420 1420
 	 * @return void
1421 1421
 	 */
1422
-	private function maybe_alter_stats( $alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count ) {
1422
+	private function maybe_alter_stats($alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count) {
1423 1423
 
1424
-		give_undo_donation( $this->ID );
1424
+		give_undo_donation($this->ID);
1425 1425
 
1426 1426
 		// Decrease store earnings.
1427
-		if ( true === $alter_store_earnings ) {
1428
-			give_decrease_total_earnings( $this->total );
1427
+		if (true === $alter_store_earnings) {
1428
+			give_decrease_total_earnings($this->total);
1429 1429
 		}
1430 1430
 
1431 1431
 		// Decrement the stats for the donor.
1432
-		if ( ! empty( $this->customer_id ) ) {
1432
+		if ( ! empty($this->customer_id)) {
1433 1433
 
1434
-			$donor = new Give_Donor( $this->customer_id );
1434
+			$donor = new Give_Donor($this->customer_id);
1435 1435
 
1436
-			if ( true === $alter_customer_value ) {
1437
-				$donor->decrease_value( $this->total );
1436
+			if (true === $alter_customer_value) {
1437
+				$donor->decrease_value($this->total);
1438 1438
 			}
1439 1439
 
1440
-			if ( true === $alter_customer_purchase_count ) {
1440
+			if (true === $alter_customer_purchase_count) {
1441 1441
 				$donor->decrease_donation_count();
1442 1442
 			}
1443 1443
 		}
@@ -1454,7 +1454,7 @@  discard block
 block discarded – undo
1454 1454
 	 */
1455 1455
 	private function delete_sales_logs() {
1456 1456
 		// Remove related sale log entries.
1457
-		Give()->logs->delete_logs( $this->ID );
1457
+		Give()->logs->delete_logs($this->ID);
1458 1458
 	}
1459 1459
 
1460 1460
 	/**
@@ -1475,13 +1475,13 @@  discard block
 block discarded – undo
1475 1475
 	 * @return string The date the payment was completed
1476 1476
 	 */
1477 1477
 	private function setup_completed_date() {
1478
-		$payment = get_post( $this->ID );
1478
+		$payment = get_post($this->ID);
1479 1479
 
1480
-		if ( 'pending' == $payment->post_status || 'preapproved' == $payment->post_status ) {
1480
+		if ('pending' == $payment->post_status || 'preapproved' == $payment->post_status) {
1481 1481
 			return false; // This payment was never completed.
1482 1482
 		}
1483 1483
 
1484
-		$date = ( $date = $this->get_meta( '_give_completed_date', true ) ) ? $date : $payment->modified_date;
1484
+		$date = ($date = $this->get_meta('_give_completed_date', true)) ? $date : $payment->modified_date;
1485 1485
 
1486 1486
 		return $date;
1487 1487
 	}
@@ -1495,7 +1495,7 @@  discard block
 block discarded – undo
1495 1495
 	 * @return string The payment mode
1496 1496
 	 */
1497 1497
 	private function setup_mode() {
1498
-		return $this->get_meta( '_give_payment_mode' );
1498
+		return $this->get_meta('_give_payment_mode');
1499 1499
 	}
1500 1500
 
1501 1501
 	/**
@@ -1507,7 +1507,7 @@  discard block
 block discarded – undo
1507 1507
 	 * @return bool The payment import
1508 1508
 	 */
1509 1509
 	private function setup_import() {
1510
-		return (bool) $this->get_meta( '_give_payment_import' );
1510
+		return (bool) $this->get_meta('_give_payment_import');
1511 1511
 	}
1512 1512
 
1513 1513
 	/**
@@ -1519,9 +1519,9 @@  discard block
 block discarded – undo
1519 1519
 	 * @return float The payment total
1520 1520
 	 */
1521 1521
 	private function setup_total() {
1522
-		$amount = $this->get_meta( '_give_payment_total', true );
1522
+		$amount = $this->get_meta('_give_payment_total', true);
1523 1523
 
1524
-		return round( floatval( $amount ), give_get_price_decimals( $this->ID ) );
1524
+		return round(floatval($amount), give_get_price_decimals($this->ID));
1525 1525
 	}
1526 1526
 
1527 1527
 	/**
@@ -1548,17 +1548,16 @@  discard block
 block discarded – undo
1548 1548
 	 * @return string The currency for the payment
1549 1549
 	 */
1550 1550
 	private function setup_currency() {
1551
-		$currency = $this->get_meta( '_give_payment_currency', true );
1552
-		$currency = ! empty( $currency ) ?
1553
-			$currency :
1554
-			/**
1551
+		$currency = $this->get_meta('_give_payment_currency', true);
1552
+		$currency = ! empty($currency) ?
1553
+			$currency : /**
1555 1554
 			 * Filter the default donation currency
1556 1555
 			 *
1557 1556
 			 * @since 1.5
1558 1557
 			 */
1559 1558
 			apply_filters(
1560 1559
 				'give_payment_currency_default',
1561
-				give_get_currency( $this->form_id, $this ),
1560
+				give_get_currency($this->form_id, $this),
1562 1561
 				$this
1563 1562
 			);
1564 1563
 
@@ -1574,7 +1573,7 @@  discard block
 block discarded – undo
1574 1573
 	 * @return string The gateway
1575 1574
 	 */
1576 1575
 	private function setup_gateway() {
1577
-		$gateway = $this->get_meta( '_give_payment_gateway', true );
1576
+		$gateway = $this->get_meta('_give_payment_gateway', true);
1578 1577
 
1579 1578
 		return $gateway;
1580 1579
 	}
@@ -1588,11 +1587,11 @@  discard block
 block discarded – undo
1588 1587
 	 * @return string The donation ID
1589 1588
 	 */
1590 1589
 	private function setup_transaction_id() {
1591
-		$transaction_id = $this->get_meta( '_give_payment_transaction_id', true );
1590
+		$transaction_id = $this->get_meta('_give_payment_transaction_id', true);
1592 1591
 
1593
-		if ( empty( $transaction_id ) ) {
1592
+		if (empty($transaction_id)) {
1594 1593
 			$gateway        = $this->gateway;
1595
-			$transaction_id = apply_filters( "give_get_payment_transaction_id-{$gateway}", $this->ID );
1594
+			$transaction_id = apply_filters("give_get_payment_transaction_id-{$gateway}", $this->ID);
1596 1595
 		}
1597 1596
 
1598 1597
 		return $transaction_id;
@@ -1608,7 +1607,7 @@  discard block
 block discarded – undo
1608 1607
 	 * @return string The IP address for the payment
1609 1608
 	 */
1610 1609
 	private function setup_ip() {
1611
-		$ip = $this->get_meta( '_give_payment_donor_ip', true );
1610
+		$ip = $this->get_meta('_give_payment_donor_ip', true);
1612 1611
 
1613 1612
 		return $ip;
1614 1613
 	}
@@ -1623,7 +1622,7 @@  discard block
 block discarded – undo
1623 1622
 	 * @return int The Donor ID.
1624 1623
 	 */
1625 1624
 	private function setup_donor_id() {
1626
-		$donor_id = $this->get_meta( '_give_payment_donor_id', true );
1625
+		$donor_id = $this->get_meta('_give_payment_donor_id', true);
1627 1626
 
1628 1627
 		return $donor_id;
1629 1628
 	}
@@ -1640,8 +1639,8 @@  discard block
 block discarded – undo
1640 1639
 	 */
1641 1640
 	private function setup_user_id() {
1642 1641
 
1643
-		$donor   = Give()->customers->get_customer_by( 'id', $this->customer_id );
1644
-		$user_id = $donor ? absint( $donor->user_id ) : 0;
1642
+		$donor   = Give()->customers->get_customer_by('id', $this->customer_id);
1643
+		$user_id = $donor ? absint($donor->user_id) : 0;
1645 1644
 
1646 1645
 
1647 1646
 		return $user_id;
@@ -1658,10 +1657,10 @@  discard block
 block discarded – undo
1658 1657
 	 * @return string The email address for the payment.
1659 1658
 	 */
1660 1659
 	private function setup_email() {
1661
-		$email = $this->get_meta( '_give_payment_donor_email', true );
1660
+		$email = $this->get_meta('_give_payment_donor_email', true);
1662 1661
 
1663
-		if ( empty( $email ) && $this->customer_id ) {
1664
-			$email = Give()->donors->get_column( 'email', $this->customer_id );
1662
+		if (empty($email) && $this->customer_id) {
1663
+			$email = Give()->donors->get_column('email', $this->customer_id);
1665 1664
 		}
1666 1665
 
1667 1666
 		return $email;
@@ -1681,22 +1680,22 @@  discard block
 block discarded – undo
1681 1680
 			'last_name'  => $this->last_name,
1682 1681
 		);
1683 1682
 
1684
-		$user_info = isset( $this->payment_meta['user_info'] ) ? $this->payment_meta['user_info'] : array();
1683
+		$user_info = isset($this->payment_meta['user_info']) ? $this->payment_meta['user_info'] : array();
1685 1684
 
1686
-		if ( is_serialized( $user_info ) ) {
1687
-			preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches );
1688
-			if ( ! empty( $matches ) ) {
1685
+		if (is_serialized($user_info)) {
1686
+			preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches);
1687
+			if ( ! empty($matches)) {
1689 1688
 				$user_info = array();
1690 1689
 			}
1691 1690
 		}
1692 1691
 
1693
-		$user_info = wp_parse_args( $user_info, $defaults );
1692
+		$user_info = wp_parse_args($user_info, $defaults);
1694 1693
 
1695
-		if ( empty( $user_info ) ) {
1694
+		if (empty($user_info)) {
1696 1695
 			// Get the donor, but only if it's been created.
1697
-			$donor = new Give_Donor( $this->customer_id );
1696
+			$donor = new Give_Donor($this->customer_id);
1698 1697
 
1699
-			if ( $donor->id > 0 ) {
1698
+			if ($donor->id > 0) {
1700 1699
 				$user_info = array(
1701 1700
 					'first_name' => $donor->get_first_name(),
1702 1701
 					'last_name'  => $donor->get_last_name(),
@@ -1706,25 +1705,25 @@  discard block
 block discarded – undo
1706 1705
 			}
1707 1706
 		} else {
1708 1707
 			// Get the donor, but only if it's been created.
1709
-			$donor = new Give_Donor( $this->customer_id );
1708
+			$donor = new Give_Donor($this->customer_id);
1710 1709
 
1711
-			if ( $donor->id > 0 ) {
1712
-				foreach ( $user_info as $key => $value ) {
1713
-					if ( ! empty( $value ) ) {
1710
+			if ($donor->id > 0) {
1711
+				foreach ($user_info as $key => $value) {
1712
+					if ( ! empty($value)) {
1714 1713
 						continue;
1715 1714
 					}
1716 1715
 
1717
-					switch ( $key ) {
1716
+					switch ($key) {
1718 1717
 						case 'first_name':
1719
-							$user_info[ $key ] = $donor->get_first_name();
1718
+							$user_info[$key] = $donor->get_first_name();
1720 1719
 							break;
1721 1720
 
1722 1721
 						case 'last_name':
1723
-							$user_info[ $key ] = $donor->get_last_name();
1722
+							$user_info[$key] = $donor->get_last_name();
1724 1723
 							break;
1725 1724
 
1726 1725
 						case 'email':
1727
-							$user_info[ $key ] = $donor->email;
1726
+							$user_info[$key] = $donor->email;
1728 1727
 							break;
1729 1728
 					}
1730 1729
 				}
@@ -1744,12 +1743,12 @@  discard block
 block discarded – undo
1744 1743
 	 * @return array The Address information for the payment.
1745 1744
 	 */
1746 1745
 	private function setup_address() {
1747
-		$address['line1']   = give_get_meta( $this->ID, '_give_donor_billing_address1', true, '' );
1748
-		$address['line2']   = give_get_meta( $this->ID, '_give_donor_billing_address2', true, '' );
1749
-		$address['city']    = give_get_meta( $this->ID, '_give_donor_billing_city', true, '' );
1750
-		$address['state']   = give_get_meta( $this->ID, '_give_donor_billing_state', true, '' );
1751
-		$address['zip']     = give_get_meta( $this->ID, '_give_donor_billing_zip', true, '' );
1752
-		$address['country'] = give_get_meta( $this->ID, '_give_donor_billing_country', true, '' );
1746
+		$address['line1']   = give_get_meta($this->ID, '_give_donor_billing_address1', true, '');
1747
+		$address['line2']   = give_get_meta($this->ID, '_give_donor_billing_address2', true, '');
1748
+		$address['city']    = give_get_meta($this->ID, '_give_donor_billing_city', true, '');
1749
+		$address['state']   = give_get_meta($this->ID, '_give_donor_billing_state', true, '');
1750
+		$address['zip']     = give_get_meta($this->ID, '_give_donor_billing_zip', true, '');
1751
+		$address['country'] = give_get_meta($this->ID, '_give_donor_billing_country', true, '');
1753 1752
 
1754 1753
 		return $address;
1755 1754
 	}
@@ -1764,7 +1763,7 @@  discard block
 block discarded – undo
1764 1763
 	 */
1765 1764
 	private function setup_form_title() {
1766 1765
 
1767
-		$form_id = $this->get_meta( '_give_payment_form_title', true );
1766
+		$form_id = $this->get_meta('_give_payment_form_title', true);
1768 1767
 
1769 1768
 		return $form_id;
1770 1769
 	}
@@ -1779,7 +1778,7 @@  discard block
 block discarded – undo
1779 1778
 	 */
1780 1779
 	private function setup_form_id() {
1781 1780
 
1782
-		$form_id = $this->get_meta( '_give_payment_form_id', true );
1781
+		$form_id = $this->get_meta('_give_payment_form_id', true);
1783 1782
 
1784 1783
 		return $form_id;
1785 1784
 	}
@@ -1793,7 +1792,7 @@  discard block
 block discarded – undo
1793 1792
 	 * @return int The Form Price ID.
1794 1793
 	 */
1795 1794
 	private function setup_price_id() {
1796
-		$price_id = $this->get_meta( '_give_payment_price_id', true );
1795
+		$price_id = $this->get_meta('_give_payment_price_id', true);
1797 1796
 
1798 1797
 		return $price_id;
1799 1798
 	}
@@ -1807,7 +1806,7 @@  discard block
 block discarded – undo
1807 1806
 	 * @return string The Payment Key.
1808 1807
 	 */
1809 1808
 	private function setup_payment_key() {
1810
-		$key = $this->get_meta( '_give_payment_purchase_key', true );
1809
+		$key = $this->get_meta('_give_payment_purchase_key', true);
1811 1810
 
1812 1811
 		return $key;
1813 1812
 	}
@@ -1823,11 +1822,11 @@  discard block
 block discarded – undo
1823 1822
 	private function setup_payment_number() {
1824 1823
 		$number = $this->ID;
1825 1824
 
1826
-		if ( give_get_option( 'enable_sequential' ) ) {
1825
+		if (give_get_option('enable_sequential')) {
1827 1826
 
1828
-			$number = $this->get_meta( '_give_payment_number', true );
1827
+			$number = $this->get_meta('_give_payment_number', true);
1829 1828
 
1830
-			if ( ! $number ) {
1829
+			if ( ! $number) {
1831 1830
 
1832 1831
 				$number = $this->ID;
1833 1832
 
@@ -1845,7 +1844,7 @@  discard block
 block discarded – undo
1845 1844
 	 * @return array The payment object as an array.
1846 1845
 	 */
1847 1846
 	public function array_convert() {
1848
-		return get_object_vars( $this );
1847
+		return get_object_vars($this);
1849 1848
 	}
1850 1849
 
1851 1850
 
@@ -1858,7 +1857,7 @@  discard block
 block discarded – undo
1858 1857
 	 * @return bool
1859 1858
 	 */
1860 1859
 	public function is_completed() {
1861
-		return ( 'publish' === $this->status && $this->completed_date );
1860
+		return ('publish' === $this->status && $this->completed_date);
1862 1861
 	}
1863 1862
 
1864 1863
 	/**
@@ -1870,7 +1869,7 @@  discard block
 block discarded – undo
1870 1869
 	 * @return string Date payment was completed.
1871 1870
 	 */
1872 1871
 	private function get_completed_date() {
1873
-		return apply_filters( 'give_payment_completed_date', $this->completed_date, $this->ID, $this );
1872
+		return apply_filters('give_payment_completed_date', $this->completed_date, $this->ID, $this);
1874 1873
 	}
1875 1874
 
1876 1875
 	/**
@@ -1882,7 +1881,7 @@  discard block
 block discarded – undo
1882 1881
 	 * @return float Payment subtotal.
1883 1882
 	 */
1884 1883
 	private function get_subtotal() {
1885
-		return apply_filters( 'give_get_payment_subtotal', $this->subtotal, $this->ID, $this );
1884
+		return apply_filters('give_get_payment_subtotal', $this->subtotal, $this->ID, $this);
1886 1885
 	}
1887 1886
 
1888 1887
 	/**
@@ -1894,7 +1893,7 @@  discard block
 block discarded – undo
1894 1893
 	 * @return string Payment currency code.
1895 1894
 	 */
1896 1895
 	private function get_currency() {
1897
-		return apply_filters( 'give_payment_currency_code', $this->currency, $this->ID, $this );
1896
+		return apply_filters('give_payment_currency_code', $this->currency, $this->ID, $this);
1898 1897
 	}
1899 1898
 
1900 1899
 	/**
@@ -1906,7 +1905,7 @@  discard block
 block discarded – undo
1906 1905
 	 * @return string Gateway used.
1907 1906
 	 */
1908 1907
 	private function get_gateway() {
1909
-		return apply_filters( 'give_payment_gateway', $this->gateway, $this->ID, $this );
1908
+		return apply_filters('give_payment_gateway', $this->gateway, $this->ID, $this);
1910 1909
 	}
1911 1910
 
1912 1911
 	/**
@@ -1918,7 +1917,7 @@  discard block
 block discarded – undo
1918 1917
 	 * @return string Donation ID from merchant processor.
1919 1918
 	 */
1920 1919
 	private function get_transaction_id() {
1921
-		return apply_filters( 'give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this );
1920
+		return apply_filters('give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this);
1922 1921
 	}
1923 1922
 
1924 1923
 	/**
@@ -1930,7 +1929,7 @@  discard block
 block discarded – undo
1930 1929
 	 * @return string Payment IP address
1931 1930
 	 */
1932 1931
 	private function get_ip() {
1933
-		return apply_filters( 'give_payment_user_ip', $this->ip, $this->ID, $this );
1932
+		return apply_filters('give_payment_user_ip', $this->ip, $this->ID, $this);
1934 1933
 	}
1935 1934
 
1936 1935
 	/**
@@ -1942,7 +1941,7 @@  discard block
 block discarded – undo
1942 1941
 	 * @return int Payment donor ID.
1943 1942
 	 */
1944 1943
 	private function get_donor_id() {
1945
-		return apply_filters( 'give_payment_customer_id', $this->customer_id, $this->ID, $this );
1944
+		return apply_filters('give_payment_customer_id', $this->customer_id, $this->ID, $this);
1946 1945
 	}
1947 1946
 
1948 1947
 	/**
@@ -1954,7 +1953,7 @@  discard block
 block discarded – undo
1954 1953
 	 * @return int Payment user ID.
1955 1954
 	 */
1956 1955
 	private function get_user_id() {
1957
-		return apply_filters( 'give_payment_user_id', $this->user_id, $this->ID, $this );
1956
+		return apply_filters('give_payment_user_id', $this->user_id, $this->ID, $this);
1958 1957
 	}
1959 1958
 
1960 1959
 	/**
@@ -1966,7 +1965,7 @@  discard block
 block discarded – undo
1966 1965
 	 * @return string Payment donor email.
1967 1966
 	 */
1968 1967
 	private function get_email() {
1969
-		return apply_filters( 'give_payment_user_email', $this->email, $this->ID, $this );
1968
+		return apply_filters('give_payment_user_email', $this->email, $this->ID, $this);
1970 1969
 	}
1971 1970
 
1972 1971
 	/**
@@ -1978,7 +1977,7 @@  discard block
 block discarded – undo
1978 1977
 	 * @return array Payment user info.
1979 1978
 	 */
1980 1979
 	private function get_user_info() {
1981
-		return apply_filters( 'give_payment_meta_user_info', $this->user_info, $this->ID, $this );
1980
+		return apply_filters('give_payment_meta_user_info', $this->user_info, $this->ID, $this);
1982 1981
 	}
1983 1982
 
1984 1983
 	/**
@@ -1990,7 +1989,7 @@  discard block
 block discarded – undo
1990 1989
 	 * @return array Payment billing address.
1991 1990
 	 */
1992 1991
 	private function get_address() {
1993
-		return apply_filters( 'give_payment_address', $this->address, $this->ID, $this );
1992
+		return apply_filters('give_payment_address', $this->address, $this->ID, $this);
1994 1993
 	}
1995 1994
 
1996 1995
 	/**
@@ -2002,7 +2001,7 @@  discard block
 block discarded – undo
2002 2001
 	 * @return string Payment key.
2003 2002
 	 */
2004 2003
 	private function get_key() {
2005
-		return apply_filters( 'give_payment_key', $this->key, $this->ID, $this );
2004
+		return apply_filters('give_payment_key', $this->key, $this->ID, $this);
2006 2005
 	}
2007 2006
 
2008 2007
 	/**
@@ -2014,7 +2013,7 @@  discard block
 block discarded – undo
2014 2013
 	 * @return string Payment form id
2015 2014
 	 */
2016 2015
 	private function get_form_id() {
2017
-		return apply_filters( 'give_payment_form_id', $this->form_id, $this->ID, $this );
2016
+		return apply_filters('give_payment_form_id', $this->form_id, $this->ID, $this);
2018 2017
 	}
2019 2018
 
2020 2019
 	/**
@@ -2026,6 +2025,6 @@  discard block
 block discarded – undo
2026 2025
 	 * @return int|string Payment number
2027 2026
 	 */
2028 2027
 	private function get_number() {
2029
-		return apply_filters( 'give_payment_number', $this->number, $this->ID, $this );
2028
+		return apply_filters('give_payment_number', $this->number, $this->ID, $this);
2030 2029
 	}
2031 2030
 }
Please login to merge, or discard this patch.
includes/admin/reports/class-give-graph.php 1 patch
Spacing   +35 added lines, -35 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
 
@@ -81,15 +81,15 @@  discard block
 block discarded – undo
81 81
 	 * @param array $_data
82 82
 	 * @param array $options
83 83
 	 */
84
-	public function __construct( $_data, $options = array() ) {
84
+	public function __construct($_data, $options = array()) {
85 85
 
86
-		$this->data      = $_data;
86
+		$this->data = $_data;
87 87
 
88 88
 		// Generate unique ID
89
-		$this->id = md5( rand() );
89
+		$this->id = md5(rand());
90 90
 
91 91
 		// Setup default options;
92
-		$this->options = apply_filters( 'give_graph_args', array(
92
+		$this->options = apply_filters('give_graph_args', array(
93 93
 			'y_mode'          => null,
94 94
 			'x_mode'          => null,
95 95
 			'y_decimals'      => 0,
@@ -107,9 +107,9 @@  discard block
 block discarded – undo
107 107
 			'lines'           => false,
108 108
 			'points'          => true,
109 109
 			'dataType'        => array()
110
-		) );
110
+		));
111 111
 
112
-		$this->options = wp_parse_args( $options, $this->options );
112
+		$this->options = wp_parse_args($options, $this->options);
113 113
 	}
114 114
 
115 115
 	/**
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
 	 *
121 121
 	 * @since 1.0
122 122
 	 */
123
-	public function set( $key, $value ) {
124
-		$this->options[ $key ] = $value;
123
+	public function set($key, $value) {
124
+		$this->options[$key] = $value;
125 125
 	}
126 126
 
127 127
 	/**
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
 	 *
132 132
 	 * @since 1.0
133 133
 	 */
134
-	public function get( $key ) {
135
-		return isset( $this->options[ $key ] ) ? $this->options[ $key ] : false;
134
+	public function get($key) {
135
+		return isset($this->options[$key]) ? $this->options[$key] : false;
136 136
 	}
137 137
 
138 138
 	/**
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 * @since 1.0
142 142
 	 */
143 143
 	public function get_data() {
144
-		return apply_filters( 'give_get_graph_data', $this->data, $this );
144
+		return apply_filters('give_get_graph_data', $this->data, $this);
145 145
 	}
146 146
 
147 147
 	/**
@@ -151,19 +151,19 @@  discard block
 block discarded – undo
151 151
 	 */
152 152
 	public function load_scripts() {
153 153
 		// Use minified libraries if SCRIPT_DEBUG is turned off
154
-		$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
154
+		$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
155 155
 
156
-		wp_register_script( 'jquery-flot-orderbars', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.orderBars' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION );
157
-		wp_enqueue_script( 'jquery-flot-orderbars' );
156
+		wp_register_script('jquery-flot-orderbars', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot.orderBars'.$suffix.'.js', array('jquery-flot'), GIVE_VERSION);
157
+		wp_enqueue_script('jquery-flot-orderbars');
158 158
 
159
-		wp_register_script( 'jquery-flot-time', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.time' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION );
160
-		wp_enqueue_script( 'jquery-flot-time' );
159
+		wp_register_script('jquery-flot-time', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot.time'.$suffix.'.js', array('jquery-flot'), GIVE_VERSION);
160
+		wp_enqueue_script('jquery-flot-time');
161 161
 
162
-		wp_register_script( 'jquery-flot-resize', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.resize' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION );
163
-		wp_enqueue_script( 'jquery-flot-resize' );
162
+		wp_register_script('jquery-flot-resize', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot.resize'.$suffix.'.js', array('jquery-flot'), GIVE_VERSION);
163
+		wp_enqueue_script('jquery-flot-resize');
164 164
 
165
-		wp_register_script( 'jquery-flot', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot' . $suffix . '.js', false, GIVE_VERSION );
166
-		wp_enqueue_script( 'jquery-flot' );
165
+		wp_register_script('jquery-flot', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot'.$suffix.'.js', false, GIVE_VERSION);
166
+		wp_enqueue_script('jquery-flot');
167 167
 
168 168
 	}
169 169
 
@@ -190,14 +190,14 @@  discard block
 block discarded – undo
190 190
 					[
191 191
 						<?php
192 192
 							$order = 0;
193
-							foreach( $this->get_data() as $label => $data ) :
193
+							foreach ($this->get_data() as $label => $data) :
194 194
 						?>
195 195
 						{
196
-							label : "<?php echo esc_attr( $label ); ?>",
197
-							id    : "<?php echo sanitize_key( $label ); ?>",
198
-							dataType  : '<?php echo ( ! empty( $this->options['dataType'][$order] ) ? $this->options['dataType'][$order] : 'count' ); ?>',
196
+							label : "<?php echo esc_attr($label); ?>",
197
+							id    : "<?php echo sanitize_key($label); ?>",
198
+							dataType  : '<?php echo ( ! empty($this->options['dataType'][$order]) ? $this->options['dataType'][$order] : 'count'); ?>',
199 199
 							// data format is: [ point on x, value on y ]
200
-							data  : [<?php foreach( $data as $point ) { echo '[' . implode( ',', $point ) . '],'; } ?>],
200
+							data  : [<?php foreach ($data as $point) { echo '['.implode(',', $point).'],'; } ?>],
201 201
 							points: {
202 202
 								show: <?php echo $this->options['points'] ? 'true' : 'false'; ?>,
203 203
 							},
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 								fill     : true,
213 213
 								fillColor: {colors: [{opacity: 0.4}, {opacity: 0.1}]}
214 214
 							},
215
-							<?php if( $this->options[ 'multiple_y_axes' ] ) : ?>
215
+							<?php if ($this->options['multiple_y_axes']) : ?>
216 216
 							yaxis : <?php echo $yaxis_count; ?>
217 217
 							<?php endif; ?>
218 218
 
@@ -226,10 +226,10 @@  discard block
 block discarded – undo
226 226
 						grid: {
227 227
 							show           : true,
228 228
 							aboveData      : false,
229
-							color          : "<?php echo $this->options[ 'color' ]; ?>",
230
-							backgroundColor: "<?php echo $this->options[ 'bgcolor' ]; ?>",
231
-							borderColor    : "<?php echo $this->options[ 'bordercolor' ]; ?>",
232
-							borderWidth    : <?php echo absint( $this->options[ 'borderwidth' ] ); ?>,
229
+							color          : "<?php echo $this->options['color']; ?>",
230
+							backgroundColor: "<?php echo $this->options['bgcolor']; ?>",
231
+							borderColor    : "<?php echo $this->options['bordercolor']; ?>",
232
+							borderWidth    : <?php echo absint($this->options['borderwidth']); ?>,
233 233
 							clickable      : false,
234 234
 							hoverable      : true
235 235
 						},
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 							mode        : "<?php echo $this->options['x_mode']; ?>",
241 241
 							timeFormat  : "<?php echo $this->options['x_mode'] == 'time' ? $this->options['time_format'] : ''; ?>",
242 242
 							tickSize    : "<?php echo $this->options['x_mode'] == 'time' ? '' : 1; ?>",
243
-							<?php if( $this->options['x_mode'] != 'time' ) : ?>
243
+							<?php if ($this->options['x_mode'] != 'time') : ?>
244 244
 							tickDecimals: <?php echo $this->options['x_decimals']; ?>
245 245
 							<?php endif; ?>
246 246
 						},
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 							min         : 0,
250 250
 							mode        : "<?php echo $this->options['y_mode']; ?>",
251 251
 							timeFormat  : "<?php echo $this->options['y_mode'] == 'time' ? $this->options['time_format'] : ''; ?>",
252
-							<?php if( $this->options['y_mode'] != 'time' ) : ?>
252
+							<?php if ($this->options['y_mode'] != 'time') : ?>
253 253
 							tickDecimals: <?php echo $this->options['y_decimals']; ?>,
254 254
 							<?php endif; ?>
255 255
 							tickFormatter: function(val) {
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 		 *
324 324
 		 * @param Give_Graph $this Graph object.
325 325
 		 */
326
-		do_action( 'give_before_graph', $this );
326
+		do_action('give_before_graph', $this);
327 327
 
328 328
 		// Build the graph.
329 329
 		echo $this->build_graph();
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
 		 *
336 336
 		 * @param Give_Graph $this Graph object.
337 337
 		 */
338
-		do_action( 'give_after_graph', $this );
338
+		do_action('give_after_graph', $this);
339 339
 	}
340 340
 
341 341
 }
Please login to merge, or discard this patch.
includes/admin/tools/import/class-give-import-donations.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 
455 455
 		/**
456 456
 		 * @param $option_value
457
-		 * @param $value
457
+		 * @param boolean $value
458 458
 		 *
459 459
 		 * @return string
460 460
 		 */
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
 		 *
545 545
 		 * @since 1.8.14
546 546
 		 *
547
-		 * @param $file_id
547
+		 * @param integer $file_id
548 548
 		 *
549 549
 		 * @return bool|int
550 550
 		 */
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -871,8 +871,8 @@
 block discarded – undo
871 871
 		 */
872 872
 		private function is_donations_import_page() {
873 873
 			return 'import' === give_get_current_setting_tab() &&
874
-			       isset( $_GET['importer-type'] ) &&
875
-			       $this->importer_type === give_clean( $_GET['importer-type'] );
874
+				   isset( $_GET['importer-type'] ) &&
875
+				   $this->importer_type === give_clean( $_GET['importer-type'] );
876 876
 		}
877 877
 	}
878 878
 
Please login to merge, or discard this patch.
Spacing   +196 added lines, -202 removed lines patch added patch discarded remove patch
@@ -11,11 +11,11 @@  discard block
 block discarded – undo
11 11
  * @since       1.8.14
12 12
  */
13 13
 
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit; // Exit if accessed directly
16 16
 }
17 17
 
18
-if ( ! class_exists( 'Give_Import_Donations' ) ) {
18
+if ( ! class_exists('Give_Import_Donations')) {
19 19
 
20 20
 	/**
21 21
 	 * Give_Import_Donations.
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		 * @access private
58 58
 		 */
59 59
 		private function __construct() {
60
-			self::$per_page  = ! empty( $_GET['per_page'] ) ? absint( $_GET['per_page'] ) : self::$per_page;
60
+			self::$per_page = ! empty($_GET['per_page']) ? absint($_GET['per_page']) : self::$per_page;
61 61
 		}
62 62
 
63 63
 		/**
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 		 * @return static
70 70
 		 */
71 71
 		public static function get_instance() {
72
-			if ( null === static::$instance ) {
72
+			if (null === static::$instance) {
73 73
 				self::$instance = new static();
74 74
 			}
75 75
 
@@ -96,27 +96,27 @@  discard block
 block discarded – undo
96 96
 		 * @return void
97 97
 		 */
98 98
 		private function setup_hooks() {
99
-			if ( ! $this->is_donations_import_page() ) {
99
+			if ( ! $this->is_donations_import_page()) {
100 100
 				return;
101 101
 			}
102 102
 
103 103
 			// Do not render main import tools page.
104
-			remove_action( 'give_admin_field_tools_import', array( 'Give_Settings_Import', 'render_import_field', ) );
104
+			remove_action('give_admin_field_tools_import', array('Give_Settings_Import', 'render_import_field',));
105 105
 
106 106
 
107 107
 			// Render donation import page
108
-			add_action( 'give_admin_field_tools_import', array( $this, 'render_page' ) );
108
+			add_action('give_admin_field_tools_import', array($this, 'render_page'));
109 109
 
110 110
 			// Print the HTML.
111
-			add_action( 'give_tools_import_donations_form_start', array( $this, 'html' ), 10 );
111
+			add_action('give_tools_import_donations_form_start', array($this, 'html'), 10);
112 112
 
113 113
 			// Run when form submit.
114
-			add_action( 'give-tools_save_import', array( $this, 'save' ) );
114
+			add_action('give-tools_save_import', array($this, 'save'));
115 115
 
116
-			add_action( 'give-tools_update_notices', array( $this, 'update_notices' ), 11, 1 );
116
+			add_action('give-tools_update_notices', array($this, 'update_notices'), 11, 1);
117 117
 
118 118
 			// Used to add submit button.
119
-			add_action( 'give_tools_import_donations_form_end', array( $this, 'submit' ), 10 );
119
+			add_action('give_tools_import_donations_form_end', array($this, 'submit'), 10);
120 120
 		}
121 121
 
122 122
 		/**
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
 		 *
129 129
 		 * @return mixed
130 130
 		 */
131
-		public function update_notices( $messages ) {
132
-			if ( ! empty( $_GET['tab'] ) && 'import' === give_clean( $_GET['tab'] ) ) {
133
-				unset( $messages['give-setting-updated'] );
131
+		public function update_notices($messages) {
132
+			if ( ! empty($_GET['tab']) && 'import' === give_clean($_GET['tab'])) {
133
+				unset($messages['give-setting-updated']);
134 134
 			}
135 135
 
136 136
 			return $messages;
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 		 * @since 1.8.14
143 143
 		 */
144 144
 		public function submit() {
145
-			wp_nonce_field( 'give-save-settings', '_give-save-settings' );
145
+			wp_nonce_field('give-save-settings', '_give-save-settings');
146 146
 			?>
147 147
 			<input type="hidden" class="import-step" id="import-step" name="step" value="<?php echo $this->get_step(); ?>"/>
148 148
 			<input type="hidden" class="importer-type" value="<?php echo $this->importer_type; ?>"/>
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 				<table class="widefat export-options-table give-table <?php echo "step-{$step}"; ?>" id="<?php echo "step-{$step}"; ?>">
165 165
 					<tbody>
166 166
 						<?php
167
-						switch ( $this->get_step() ) {
167
+						switch ($this->get_step()) {
168 168
 							case 1:
169 169
 								$this->render_media_csv();
170 170
 								break;
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 								$this->import_success();
182 182
 						}
183 183
 
184
-						if ( false === $this->check_for_dropdown_or_import() ) {
184
+						if (false === $this->check_for_dropdown_or_import()) {
185 185
 							?>
186 186
 							<tr valign="top">
187 187
 								<th></th>
@@ -189,8 +189,8 @@  discard block
 block discarded – undo
189 189
 									<input type="submit"
190 190
 									       class=" button button-primary button-large button-secondary <?php echo "step-{$step}"; ?>"
191 191
 									       id="recount-stats-submit"
192
-									       <?php echo ( 2 === $step ) ? 'disabled' : ''; ?>
193
-									       value="<?php esc_attr_e( 'Submit', 'give' ); ?>"/>
192
+									       <?php echo (2 === $step) ? 'disabled' : ''; ?>
193
+									       value="<?php esc_attr_e('Submit', 'give'); ?>"/>
194 194
 								</th>
195 195
 							</tr>
196 196
 							<?php
@@ -209,57 +209,57 @@  discard block
 block discarded – undo
209 209
 		 */
210 210
 		public function import_success() {
211 211
 
212
-			$delete_csv = ( ! empty( $_GET['delete_csv'] ) ? absint( $_GET['delete_csv'] ) : false );
213
-			$csv        = ( ! empty( $_GET['csv'] ) ? absint( $_GET['csv'] ) : false );
214
-			if ( ! empty( $delete_csv ) && ! empty( $csv ) ) {
215
-				wp_delete_attachment( $csv, true );
212
+			$delete_csv = ( ! empty($_GET['delete_csv']) ? absint($_GET['delete_csv']) : false);
213
+			$csv        = ( ! empty($_GET['csv']) ? absint($_GET['csv']) : false);
214
+			if ( ! empty($delete_csv) && ! empty($csv)) {
215
+				wp_delete_attachment($csv, true);
216 216
 			}
217 217
 
218 218
 			$report      = give_import_donation_report();
219 219
 
220 220
 			$report_html = array(
221 221
 				'duplicate_donor'    => array(
222
-					__( '%s duplicate %s detected', 'give' ),
223
-					__( 'donor', 'give' ),
224
-					__( 'donors', 'give' ),
222
+					__('%s duplicate %s detected', 'give'),
223
+					__('donor', 'give'),
224
+					__('donors', 'give'),
225 225
 				),
226 226
 				'create_donor'       => array(
227
-					__( '%s %s created', 'give' ),
228
-					__( 'donor', 'give' ),
229
-					__( 'donors', 'give' ),
227
+					__('%s %s created', 'give'),
228
+					__('donor', 'give'),
229
+					__('donors', 'give'),
230 230
 				),
231 231
 				'create_form'        => array(
232
-					__( '%s donation %s created', 'give' ),
233
-					__( 'form', 'give' ),
234
-					__( 'forms', 'give' ),
232
+					__('%s donation %s created', 'give'),
233
+					__('form', 'give'),
234
+					__('forms', 'give'),
235 235
 				),
236 236
 				'duplicate_donation' => array(
237
-					__( '%s duplicate %s detected', 'give' ),
238
-					__( 'donation', 'give' ),
239
-					__( 'donations', 'give' ),
237
+					__('%s duplicate %s detected', 'give'),
238
+					__('donation', 'give'),
239
+					__('donations', 'give'),
240 240
 				),
241 241
 				'create_donation'    => array(
242
-					__( '%s %s imported', 'give' ),
243
-					__( 'donation', 'give' ),
244
-					__( 'donations', 'give' ),
242
+					__('%s %s imported', 'give'),
243
+					__('donation', 'give'),
244
+					__('donations', 'give'),
245 245
 				),
246 246
 			);
247
-			$total       = (int) $_GET['total'];
248
-			-- $total;
247
+			$total = (int) $_GET['total'];
248
+			--$total;
249 249
 			$success = (bool) $_GET['success'];
250 250
 			?>
251 251
 			<tr valign="top" class="give-import-dropdown">
252 252
 				<th colspan="2">
253 253
 					<h2>
254 254
 						<?php
255
-						if ( $success ) {
255
+						if ($success) {
256 256
 							printf(
257
-								_n( 'Import complete! %s donation processed', 'Import complete! %s donations processed', $total, 'give' ),
257
+								_n('Import complete! %s donation processed', 'Import complete! %s donations processed', $total, 'give'),
258 258
 								"<strong>{$total}</strong>"
259 259
 							);
260 260
 						} else {
261 261
 							printf(
262
-								_n( 'Failed to import %s donation', 'Failed to import %s donations', $total, 'give' ),
262
+								_n('Failed to import %s donation', 'Failed to import %s donations', $total, 'give'),
263 263
 								"<strong>{$total}</strong>"
264 264
 							);
265 265
 						}
@@ -267,25 +267,25 @@  discard block
 block discarded – undo
267 267
 					</h2>
268 268
 
269 269
 					<?php
270
-					$text      = __( 'Import Donation', 'give' );
270
+					$text      = __('Import Donation', 'give');
271 271
 					$query_arg = array(
272 272
 						'post_type' => 'give_forms',
273 273
 						'page'      => 'give-tools',
274 274
 						'tab'       => 'import',
275 275
 					);
276
-					if ( $success ) {
276
+					if ($success) {
277 277
 						$query_arg = array(
278 278
 							'post_type' => 'give_forms',
279 279
 							'page'      => 'give-payment-history',
280 280
 						);
281
-						$text      = __( 'View Donations', 'give' );
281
+						$text = __('View Donations', 'give');
282 282
 					}
283 283
 
284
-					foreach ( $report as $key => $value ) {
285
-						if ( array_key_exists( $key, $report_html ) && ! empty( $value ) ) {
284
+					foreach ($report as $key => $value) {
285
+						if (array_key_exists($key, $report_html) && ! empty($value)) {
286 286
 							?>
287 287
 							<p>
288
-								<?php echo esc_html( wp_sprintf( $report_html[ $key ][0], $value, _n( $report_html[ $key ][1], $report_html[ $key ][2], $value, 'give' ) ) ); ?>
288
+								<?php echo esc_html(wp_sprintf($report_html[$key][0], $value, _n($report_html[$key][1], $report_html[$key][2], $value, 'give'))); ?>
289 289
 							</p>
290 290
 							<?php
291 291
 						}
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 					?>
294 294
 
295 295
 					<p>
296
-						<a class="button button-large button-secondary" href="<?php echo add_query_arg( $query_arg, admin_url( 'edit.php' ) ); ?>"><?php echo $text; ?></a>
296
+						<a class="button button-large button-secondary" href="<?php echo add_query_arg($query_arg, admin_url('edit.php')); ?>"><?php echo $text; ?></a>
297 297
 					</p>
298 298
 				</th>
299 299
 			</tr>
@@ -310,26 +310,26 @@  discard block
 block discarded – undo
310 310
 			give_import_donation_report_reset();
311 311
 
312 312
 			$csv         = (int) $_REQUEST['csv'];
313
-			$delimiter   = ( ! empty( $_REQUEST['delimiter'] ) ? give_clean( $_REQUEST['delimiter'] ) : 'csv' );
313
+			$delimiter   = ( ! empty($_REQUEST['delimiter']) ? give_clean($_REQUEST['delimiter']) : 'csv');
314 314
 			$index_start = 1;
315 315
 			$index_end   = 1;
316 316
 			$next        = true;
317
-			$total       = self::get_csv_total( $csv );
318
-			if ( self::$per_page < $total ) {
319
-				$total_ajax = ceil( $total / self::$per_page );
317
+			$total       = self::get_csv_total($csv);
318
+			if (self::$per_page < $total) {
319
+				$total_ajax = ceil($total / self::$per_page);
320 320
 				$index_end  = self::$per_page;
321 321
 			} else {
322 322
 				$total_ajax = 1;
323 323
 				$index_end  = $total;
324 324
 				$next       = false;
325 325
 			}
326
-			$current_percentage = 100 / ( $total_ajax + 1 );
326
+			$current_percentage = 100 / ($total_ajax + 1);
327 327
 
328 328
 			?>
329 329
 			<tr valign="top" class="give-import-dropdown">
330 330
 				<th colspan="2">
331
-					<h2 id="give-import-title"><?php esc_html_e( 'Importing', 'give' ) ?></h2>
332
-					<p class="give-field-description"><?php esc_html_e( 'Your donations are now being imported...', 'give' ) ?></p>
331
+					<h2 id="give-import-title"><?php esc_html_e('Importing', 'give') ?></h2>
332
+					<p class="give-field-description"><?php esc_html_e('Your donations are now being imported...', 'give') ?></p>
333 333
 				</th>
334 334
 			</tr>
335 335
 
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 						<div style="width: <?php echo $current_percentage; ?>%"></div>
349 349
 					</div>
350 350
 					<input type="hidden" value="3" name="step">
351
-					<input type="hidden" value='<?php echo maybe_serialize( $_REQUEST['mapto'] ); ?>' name="mapto"
351
+					<input type="hidden" value='<?php echo maybe_serialize($_REQUEST['mapto']); ?>' name="mapto"
352 352
 						   class="mapto">
353 353
 					<input type="hidden" value="<?php echo $_REQUEST['csv']; ?>" name="csv" class="csv">
354 354
 					<input type="hidden" value="<?php echo $_REQUEST['mode']; ?>" name="mode" class="mode">
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 					<input type="hidden" value="<?php echo $_REQUEST['delete_csv']; ?>" name="delete_csv"
358 358
 						   class="delete_csv">
359 359
 					<input type="hidden" value="<?php echo $delimiter; ?>" name="delimiter">
360
-					<input type="hidden" value='<?php echo maybe_serialize( self::get_importer( $csv, 0, $delimiter ) ); ?>'
360
+					<input type="hidden" value='<?php echo maybe_serialize(self::get_importer($csv, 0, $delimiter)); ?>'
361 361
 						   name="main_key"
362 362
 						   class="main_key">
363 363
 				</th>
@@ -378,20 +378,20 @@  discard block
 block discarded – undo
378 378
 		 */
379 379
 		public function check_for_dropdown_or_import() {
380 380
 			$return = true;
381
-			if ( isset( $_REQUEST['mapto'] ) ) {
381
+			if (isset($_REQUEST['mapto'])) {
382 382
 				$mapto = (array) $_REQUEST['mapto'];
383
-				if ( false === in_array( 'form_title', $mapto ) && false === in_array( 'form_id', $mapto ) ) {
384
-					Give_Admin_Settings::add_error( 'give-import-csv-form', __( 'In order to import donations, a column must be mapped to either the "Donation Form Title" or "Donation Form ID" field. Please map a column to one of those fields.', 'give' ) );
383
+				if (false === in_array('form_title', $mapto) && false === in_array('form_id', $mapto)) {
384
+					Give_Admin_Settings::add_error('give-import-csv-form', __('In order to import donations, a column must be mapped to either the "Donation Form Title" or "Donation Form ID" field. Please map a column to one of those fields.', 'give'));
385 385
 					$return = false;
386 386
 				}
387 387
 
388
-				if ( false === in_array( 'amount', $mapto ) ) {
389
-					Give_Admin_Settings::add_error( 'give-import-csv-amount', __( 'In order to import donations, a column must be mapped to the "Amount" field. Please map a column to that field.', 'give' ) );
388
+				if (false === in_array('amount', $mapto)) {
389
+					Give_Admin_Settings::add_error('give-import-csv-amount', __('In order to import donations, a column must be mapped to the "Amount" field. Please map a column to that field.', 'give'));
390 390
 					$return = false;
391 391
 				}
392 392
 
393
-				if ( false === in_array( 'email', $mapto ) && false === in_array( 'donor_id', $mapto ) ) {
394
-					Give_Admin_Settings::add_error( 'give-import-csv-donor', __( 'In order to import donations, a column must be mapped to either the "Donor Email" or "Donor ID" field. Please map a column to that field.', 'give' ) );
393
+				if (false === in_array('email', $mapto) && false === in_array('donor_id', $mapto)) {
394
+					Give_Admin_Settings::add_error('give-import-csv-donor', __('In order to import donations, a column must be mapped to either the "Donor Email" or "Donor ID" field. Please map a column to that field.', 'give'));
395 395
 					$return = false;
396 396
 				}
397 397
 			} else {
@@ -408,10 +408,10 @@  discard block
 block discarded – undo
408 408
 		 */
409 409
 		public function render_dropdown() {
410 410
 			$csv       = (int) $_GET['csv'];
411
-			$delimiter = ( ! empty( $_GET['delimiter'] ) ? give_clean( $_GET['delimiter'] ) : 'csv' );
411
+			$delimiter = ( ! empty($_GET['delimiter']) ? give_clean($_GET['delimiter']) : 'csv');
412 412
 
413 413
 			// TO check if the CSV files that is being add is valid or not if not then redirect to first step again
414
-			if ( ! $this->is_valid_csv( $csv ) ) {
414
+			if ( ! $this->is_valid_csv($csv)) {
415 415
 				$url = give_import_page_url();
416 416
 				?>
417 417
 				<script type="text/javascript">
@@ -422,18 +422,18 @@  discard block
 block discarded – undo
422 422
 				?>
423 423
 				<tr valign="top" class="give-import-dropdown">
424 424
 					<th colspan="2">
425
-						<h2 id="give-import-title"><?php esc_html_e( 'Map CSV fields to donations', 'give' ) ?></h2>
425
+						<h2 id="give-import-title"><?php esc_html_e('Map CSV fields to donations', 'give') ?></h2>
426 426
 
427
-						<p class="give-import-donation-required-fields-title"><?php _e( 'Required Fields' ); ?></p>
427
+						<p class="give-import-donation-required-fields-title"><?php _e('Required Fields'); ?></p>
428 428
 
429
-						<p class="give-field-description"><?php _e( 'These fields are required for the import to submitted' ); ?></p>
429
+						<p class="give-field-description"><?php _e('These fields are required for the import to submitted'); ?></p>
430 430
 
431 431
 						<ul class="give-import-donation-required-fields">
432 432
 							<li class="give-import-donation-required-email" title="Please configure all required fields to start the import process.">
433 433
 								<span class="give-import-donation-required-symbol dashicons dashicons-no-alt"></span>
434 434
 								<span class="give-import-donation-required-text">
435 435
 									<?php
436
-									_e( 'Email Access', 'give' );
436
+									_e('Email Access', 'give');
437 437
 									?>
438 438
 								</span>
439 439
 							</li>
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 								<span class="give-import-donation-required-symbol dashicons dashicons-no-alt"></span>
443 443
 								<span class="give-import-donation-required-text">
444 444
 									<?php
445
-									_e( 'First Name', 'give' );
445
+									_e('First Name', 'give');
446 446
 									?>
447 447
 								</span>
448 448
 							</li>
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 								<span class="give-import-donation-required-symbol dashicons dashicons-no-alt"></span>
452 452
 								<span class="give-import-donation-required-text">
453 453
 									<?php
454
-									_e( 'Donation Amount', 'give' );
454
+									_e('Donation Amount', 'give');
455 455
 									?>
456 456
 								</span>
457 457
 							</li>
@@ -460,32 +460,32 @@  discard block
 block discarded – undo
460 460
 								<span class="give-import-donation-required-symbol dashicons dashicons-no-alt"></span>
461 461
 								<span class="give-import-donation-required-text">
462 462
 									<?php
463
-									_e( 'Form Title or ID', 'give' );
463
+									_e('Form Title or ID', 'give');
464 464
 									?>
465 465
 								</span>
466 466
 							</li>
467 467
 						</ul>
468 468
 
469
-						<p class="give-field-description"><?php esc_html_e( 'Select fields from your CSV file to map against donations fields or to ignore during import.', 'give' ) ?></p>
469
+						<p class="give-field-description"><?php esc_html_e('Select fields from your CSV file to map against donations fields or to ignore during import.', 'give') ?></p>
470 470
 					</th>
471 471
 				</tr>
472 472
 
473 473
 				<tr valign="top" class="give-import-dropdown">
474
-					<th><b><?php esc_html_e( 'Column name', 'give' ); ?></b></th>
475
-					<th><b><?php esc_html_e( 'Map to field', 'give' ); ?></b></th>
474
+					<th><b><?php esc_html_e('Column name', 'give'); ?></b></th>
475
+					<th><b><?php esc_html_e('Map to field', 'give'); ?></b></th>
476 476
 				</tr>
477 477
 
478 478
 				<?php
479
-				$raw_key   = $this->get_importer( $csv, 0, $delimiter );
480
-				$mapto     = (array) ( isset( $_REQUEST['mapto'] ) ? $_REQUEST['mapto'] : array() );
479
+				$raw_key   = $this->get_importer($csv, 0, $delimiter);
480
+				$mapto     = (array) (isset($_REQUEST['mapto']) ? $_REQUEST['mapto'] : array());
481 481
 
482
-				foreach ( $raw_key as $index => $value ) {
482
+				foreach ($raw_key as $index => $value) {
483 483
 					?>
484 484
 					<tr valign="top" class="give-import-option">
485 485
 						<th><?php echo $value; ?></th>
486 486
 						<th>
487 487
 							<?php
488
-							$this->get_columns( $index, $value, $mapto );
488
+							$this->get_columns($index, $value, $mapto);
489 489
 							?>
490 490
 						</th>
491 491
 					</tr>
@@ -500,14 +500,14 @@  discard block
 block discarded – undo
500 500
 		 *
501 501
 		 * @return string
502 502
 		 */
503
-		public function selected( $option_value, $value ) {
504
-			$option_value = strtolower( $option_value );
505
-			$value = strtolower( $value );
503
+		public function selected($option_value, $value) {
504
+			$option_value = strtolower($option_value);
505
+			$value = strtolower($value);
506 506
 
507 507
 			$selected = '';
508
-			if ( stristr( $value, $option_value ) ) {
508
+			if (stristr($value, $option_value)) {
509 509
 				$selected = 'selected';
510
-			} elseif ( strrpos( $value, '_' ) && stristr( $option_value, __( 'Import as Meta', 'give' ) ) ) {
510
+			} elseif (strrpos($value, '_') && stristr($option_value, __('Import as Meta', 'give'))) {
511 511
 				$selected = 'selected';
512 512
 			}
513 513
 
@@ -526,28 +526,28 @@  discard block
 block discarded – undo
526 526
 		 *
527 527
 		 * @return void
528 528
 		 */
529
-		private function get_columns( $index, $value = false, $mapto = array() ) {
529
+		private function get_columns($index, $value = false, $mapto = array()) {
530 530
 			$default       = give_import_default_options();
531
-			$current_mapto = (string) ( ! empty( $mapto[ $index ] ) ? $mapto[ $index ] : '' );
531
+			$current_mapto = (string) ( ! empty($mapto[$index]) ? $mapto[$index] : '');
532 532
 			?>
533 533
 			<select name="mapto[<?php echo $index; ?>]">
534
-				<?php $this->get_dropdown_option_html( $default, $current_mapto, $value ); ?>
534
+				<?php $this->get_dropdown_option_html($default, $current_mapto, $value); ?>
535 535
 
536
-				<optgroup label="<?php _e( 'Donations', 'give' ); ?>">
536
+				<optgroup label="<?php _e('Donations', 'give'); ?>">
537 537
 					<?php
538
-					$this->get_dropdown_option_html( give_import_donations_options(), $current_mapto, $value );
538
+					$this->get_dropdown_option_html(give_import_donations_options(), $current_mapto, $value);
539 539
 					?>
540 540
 				</optgroup>
541 541
 
542
-				<optgroup label="<?php _e( 'Donors', 'give' ); ?>">
542
+				<optgroup label="<?php _e('Donors', 'give'); ?>">
543 543
 					<?php
544
-					$this->get_dropdown_option_html( give_import_donor_options(), $current_mapto, $value );
544
+					$this->get_dropdown_option_html(give_import_donor_options(), $current_mapto, $value);
545 545
 					?>
546 546
 				</optgroup>
547 547
 
548
-				<optgroup label="<?php _e( 'Forms', 'give' ); ?>">
548
+				<optgroup label="<?php _e('Forms', 'give'); ?>">
549 549
 					<?php
550
-					$this->get_dropdown_option_html( give_import_donation_form_options(), $current_mapto, $value );
550
+					$this->get_dropdown_option_html(give_import_donation_form_options(), $current_mapto, $value);
551 551
 					?>
552 552
 				</optgroup>
553 553
 
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
 				 *
559 559
 				 * @since 1.8.15
560 560
 				 */
561
-				do_action( 'give_import_dropdown_option', $index, $value, $mapto, $current_mapto );
561
+				do_action('give_import_dropdown_option', $index, $value, $mapto, $current_mapto);
562 562
 				?>
563 563
 			</select>
564 564
 			<?php
@@ -576,16 +576,16 @@  discard block
 block discarded – undo
576 576
 		 *
577 577
 		 * @return void
578 578
 		 */
579
-		public function get_dropdown_option_html( $options, $current_mapto, $value = false ) {
580
-			foreach ( $options as $option => $option_value ) {
579
+		public function get_dropdown_option_html($options, $current_mapto, $value = false) {
580
+			foreach ($options as $option => $option_value) {
581 581
 				$option_value_texts = (array) $option_value;
582 582
 				$option_text = $option_value_texts[0];
583 583
 
584
-				$checked = ( ( $current_mapto === $option ) ? 'selected' : false );
585
-				if ( empty( $checked ) ) {
586
-					foreach ( $option_value_texts as $option_value_text ) {
587
-						$checked = $this->selected( $option_value_text, $value );
588
-						if ( $checked ) {
584
+				$checked = (($current_mapto === $option) ? 'selected' : false);
585
+				if (empty($checked)) {
586
+					foreach ($option_value_texts as $option_value_text) {
587
+						$checked = $this->selected($option_value_text, $value);
588
+						if ($checked) {
589 589
 							break;
590 590
 						}
591 591
 					}
@@ -609,13 +609,13 @@  discard block
 block discarded – undo
609 609
 		 *
610 610
 		 * @return bool|int
611 611
 		 */
612
-		public function get_csv_total( $file_id ) {
612
+		public function get_csv_total($file_id) {
613 613
 			$total = false;
614
-			if ( $file_id ) {
615
-				$file_dir = get_attached_file( $file_id );
616
-				if ( $file_dir ) {
617
-					$file = new SplFileObject( $file_dir, 'r' );
618
-					$file->seek( PHP_INT_MAX );
614
+			if ($file_id) {
615
+				$file_dir = get_attached_file($file_id);
616
+				if ($file_dir) {
617
+					$file = new SplFileObject($file_dir, 'r');
618
+					$file->seek(PHP_INT_MAX);
619 619
 					$total = $file->key() + 1;
620 620
 				}
621 621
 			}
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
 		 *
635 635
 		 * @return array|bool $raw_data title of the CSV file fields
636 636
 		 */
637
-		public function get_importer( $file_id, $index = 0, $delimiter = 'csv' ) {
637
+		public function get_importer($file_id, $index = 0, $delimiter = 'csv') {
638 638
 			/**
639 639
 			 * Filter to modify delimiter of Import.
640 640
 			 *
@@ -642,16 +642,16 @@  discard block
 block discarded – undo
642 642
 			 *
643 643
 			 * Return string $delimiter.
644 644
 			 */
645
-			$delimiter = (string) apply_filters( 'give_import_delimiter_set', $delimiter );
645
+			$delimiter = (string) apply_filters('give_import_delimiter_set', $delimiter);
646 646
 
647 647
 			$raw_data = false;
648
-			$file_dir = get_attached_file( $file_id );
649
-			if ( $file_dir ) {
650
-				if ( false !== ( $handle = fopen( $file_dir, 'r' ) ) ) {
651
-					$raw_data = fgetcsv( $handle, $index, $delimiter );
648
+			$file_dir = get_attached_file($file_id);
649
+			if ($file_dir) {
650
+				if (false !== ($handle = fopen($file_dir, 'r'))) {
651
+					$raw_data = fgetcsv($handle, $index, $delimiter);
652 652
 					// Remove BOM signature from the first item.
653
-					if ( isset( $raw_data[0] ) ) {
654
-						$raw_data[0] = $this->remove_utf8_bom( $raw_data[0] );
653
+					if (isset($raw_data[0])) {
654
+						$raw_data[0] = $this->remove_utf8_bom($raw_data[0]);
655 655
 					}
656 656
 				}
657 657
 			}
@@ -668,9 +668,9 @@  discard block
 block discarded – undo
668 668
 		 *
669 669
 		 * @return string
670 670
 		 */
671
-		public function remove_utf8_bom( $string ) {
672
-			if ( 'efbbbf' === substr( bin2hex( $string ), 0, 6 ) ) {
673
-				$string = substr( $string, 3 );
671
+		public function remove_utf8_bom($string) {
672
+			if ('efbbbf' === substr(bin2hex($string), 0, 6)) {
673
+				$string = substr($string, 3);
674 674
 			}
675 675
 
676 676
 			return $string;
@@ -686,17 +686,17 @@  discard block
 block discarded – undo
686 686
 			$step = $this->get_step();
687 687
 			?>
688 688
 			<ol class="give-progress-steps">
689
-				<li class="<?php echo( 1 === $step ? 'active' : '' ); ?>">
690
-					<?php esc_html_e( 'Upload CSV file', 'give' ); ?>
689
+				<li class="<?php echo(1 === $step ? 'active' : ''); ?>">
690
+					<?php esc_html_e('Upload CSV file', 'give'); ?>
691 691
 				</li>
692
-				<li class="<?php echo( 2 === $step ? 'active' : '' ); ?>">
693
-					<?php esc_html_e( 'Column mapping', 'give' ); ?>
692
+				<li class="<?php echo(2 === $step ? 'active' : ''); ?>">
693
+					<?php esc_html_e('Column mapping', 'give'); ?>
694 694
 				</li>
695
-				<li class="<?php echo( 3 === $step ? 'active' : '' ); ?>">
696
-					<?php esc_html_e( 'Import', 'give' ); ?>
695
+				<li class="<?php echo(3 === $step ? 'active' : ''); ?>">
696
+					<?php esc_html_e('Import', 'give'); ?>
697 697
 				</li>
698
-				<li class="<?php echo( 4 === $step ? 'active' : '' ); ?>">
699
-					<?php esc_html_e( 'Done!', 'give' ); ?>
698
+				<li class="<?php echo(4 === $step ? 'active' : ''); ?>">
699
+					<?php esc_html_e('Done!', 'give'); ?>
700 700
 				</li>
701 701
 			</ol>
702 702
 			<?php
@@ -710,16 +710,16 @@  discard block
 block discarded – undo
710 710
 		 * @return int $step on which step doest the import is on.
711 711
 		 */
712 712
 		public function get_step() {
713
-			$step    = (int) ( isset( $_REQUEST['step'] ) ? give_clean( $_REQUEST['step'] ) : 0 );
713
+			$step    = (int) (isset($_REQUEST['step']) ? give_clean($_REQUEST['step']) : 0);
714 714
 			$on_step = 1;
715 715
 
716
-			if ( empty( $step ) || 1 === $step ) {
716
+			if (empty($step) || 1 === $step) {
717 717
 				$on_step = 1;
718
-			} elseif ( $this->check_for_dropdown_or_import() ) {
718
+			} elseif ($this->check_for_dropdown_or_import()) {
719 719
 				$on_step = 3;
720
-			} elseif ( 2 === $step ) {
720
+			} elseif (2 === $step) {
721 721
 				$on_step = 2;
722
-			} elseif ( 4 === $step ) {
722
+			} elseif (4 === $step) {
723 723
 				$on_step = 4;
724 724
 			}
725 725
 
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
 		 * @since 1.8.14
733 733
 		 */
734 734
 		public function render_page() {
735
-			include_once GIVE_PLUGIN_DIR . 'includes/admin/tools/views/html-admin-page-import-donations.php';
735
+			include_once GIVE_PLUGIN_DIR.'includes/admin/tools/views/html-admin-page-import-donations.php';
736 736
 		}
737 737
 
738 738
 		/**
@@ -747,37 +747,34 @@  discard block
 block discarded – undo
747 747
 			?>
748 748
 			<tr valign="top">
749 749
 				<th colspan="2">
750
-					<h2 id="give-import-title"><?php esc_html_e( 'Import donations from a CSV file', 'give' ) ?></h2>
751
-					<p class="give-field-description"><?php esc_html_e( 'This tool allows you to import or add donation data to your give form(s) via a CSV file.', 'give' ) ?></p>
750
+					<h2 id="give-import-title"><?php esc_html_e('Import donations from a CSV file', 'give') ?></h2>
751
+					<p class="give-field-description"><?php esc_html_e('This tool allows you to import or add donation data to your give form(s) via a CSV file.', 'give') ?></p>
752 752
 				</th>
753 753
 			</tr>
754 754
 			<?php
755
-			$csv         = ( isset( $_POST['csv'] ) ? give_clean( $_POST['csv'] ) : '' );
756
-			$csv_id      = ( isset( $_POST['csv_id'] ) ? give_clean( $_POST['csv_id'] ) : '' );
757
-			$delimiter   = ( isset( $_POST['delimiter'] ) ? give_clean( $_POST['delimiter'] ) : 'csv' );
758
-			$mode        = empty( $_POST['mode'] ) ?
759
-				'disabled' :
760
-				( give_is_setting_enabled( give_clean( $_POST['mode'] ) ) ? 'enabled' : 'disabled' );
761
-			$create_user = empty( $_POST['create_user'] ) ?
762
-				'enabled' :
763
-				( give_is_setting_enabled( give_clean( $_POST['create_user'] ) ) ? 'enabled' : 'disabled' );
764
-			$delete_csv  = empty( $_POST['delete_csv'] ) ?
765
-				'enabled' :
766
-				( give_is_setting_enabled( give_clean( $_POST['delete_csv'] ) ) ? 'enabled' : 'disabled' );
755
+			$csv         = (isset($_POST['csv']) ? give_clean($_POST['csv']) : '');
756
+			$csv_id      = (isset($_POST['csv_id']) ? give_clean($_POST['csv_id']) : '');
757
+			$delimiter   = (isset($_POST['delimiter']) ? give_clean($_POST['delimiter']) : 'csv');
758
+			$mode        = empty($_POST['mode']) ?
759
+				'disabled' : (give_is_setting_enabled(give_clean($_POST['mode'])) ? 'enabled' : 'disabled');
760
+			$create_user = empty($_POST['create_user']) ?
761
+				'enabled' : (give_is_setting_enabled(give_clean($_POST['create_user'])) ? 'enabled' : 'disabled');
762
+			$delete_csv  = empty($_POST['delete_csv']) ?
763
+				'enabled' : (give_is_setting_enabled(give_clean($_POST['delete_csv'])) ? 'enabled' : 'disabled');
767 764
 
768 765
 			// Reset csv and csv_id if csv
769
-			if ( empty( $csv_id ) || ! $this->is_valid_csv( $csv_id, $csv ) ) {
766
+			if (empty($csv_id) || ! $this->is_valid_csv($csv_id, $csv)) {
770 767
 				$csv_id = $csv = '';
771 768
 			}
772
-			$per_page = isset( $_POST['per_page'] ) ? absint( $_POST['per_page'] ) : self::$per_page;
769
+			$per_page = isset($_POST['per_page']) ? absint($_POST['per_page']) : self::$per_page;
773 770
 
774 771
 			$settings = array(
775 772
 				array(
776 773
 					'id'          => 'csv',
777
-					'name'        => __( 'Choose a CSV file:', 'give' ),
774
+					'name'        => __('Choose a CSV file:', 'give'),
778 775
 					'type'        => 'file',
779
-					'attributes'  => array( 'editing' => 'false', 'library' => 'text' ),
780
-					'description' => __( 'The file must be a Comma Seperated Version (CSV) file type only.', 'give' ),
776
+					'attributes'  => array('editing' => 'false', 'library' => 'text'),
777
+					'description' => __('The file must be a Comma Seperated Version (CSV) file type only.', 'give'),
781 778
 					'fvalue'      => 'url',
782 779
 					'default'     => $csv,
783 780
 				),
@@ -788,61 +785,61 @@  discard block
 block discarded – undo
788 785
 				),
789 786
 				array(
790 787
 					'id'          => 'delimiter',
791
-					'name'        => __( 'CSV Delimiter:', 'give' ),
792
-					'description' => __( 'In case your CSV file supports a different type of separator (or delimiter) -- like a tab or space -- you can set that here.', 'give' ),
788
+					'name'        => __('CSV Delimiter:', 'give'),
789
+					'description' => __('In case your CSV file supports a different type of separator (or delimiter) -- like a tab or space -- you can set that here.', 'give'),
793 790
 					'default'     => $delimiter,
794 791
 					'type'        => 'select',
795 792
 					'options'     => array(
796
-						'csv'                  => esc_html__( 'Comma', 'give' ),
797
-						'tab-separated-values' => esc_html__( 'Tab', 'give' ),
793
+						'csv'                  => esc_html__('Comma', 'give'),
794
+						'tab-separated-values' => esc_html__('Tab', 'give'),
798 795
 					),
799 796
 				),
800 797
 				array(
801 798
 					'id'          => 'mode',
802
-					'name'        => __( 'Test Mode:', 'give' ),
803
-					'description' => __( 'Test mode allows you to preview what this import would look like without making any actual changes to your site or your database.', 'give' ),
799
+					'name'        => __('Test Mode:', 'give'),
800
+					'description' => __('Test mode allows you to preview what this import would look like without making any actual changes to your site or your database.', 'give'),
804 801
 					'default'     => $mode,
805 802
 					'type'        => 'radio_inline',
806 803
 					'options'     => array(
807
-						'enabled'  => __( 'Enabled', 'give' ),
808
-						'disabled' => __( 'Disabled', 'give' ),
804
+						'enabled'  => __('Enabled', 'give'),
805
+						'disabled' => __('Disabled', 'give'),
809 806
 					),
810 807
 				),
811 808
 				array(
812 809
 					'id'          => 'create_user',
813
-					'name'        => __( 'Create WP users for new donors:', 'give' ),
814
-					'description' => __( 'The importer can create WordPress user accounts based on the names and email addresses of the donations in your CSV file. Enable this option if you\'d like the importer to do that.', 'give' ),
810
+					'name'        => __('Create WP users for new donors:', 'give'),
811
+					'description' => __('The importer can create WordPress user accounts based on the names and email addresses of the donations in your CSV file. Enable this option if you\'d like the importer to do that.', 'give'),
815 812
 					'default'     => $create_user,
816 813
 					'type'        => 'radio_inline',
817 814
 					'options'     => array(
818
-						'enabled'  => __( 'Enabled', 'give' ),
819
-						'disabled' => __( 'Disabled', 'give' ),
815
+						'enabled'  => __('Enabled', 'give'),
816
+						'disabled' => __('Disabled', 'give'),
820 817
 					),
821 818
 				),
822 819
 				array(
823 820
 					'id'          => 'delete_csv',
824
-					'name'        => __( 'Delete CSV after import:', 'give' ),
825
-					'description' => __( 'Your CSV file will be uploaded via the WordPress Media Library. It\'s a good idea to delete it after the import is finished so that your sensitive data is not accessible on the web. Disable this only if you plan to delete the file manually later.', 'give' ),
821
+					'name'        => __('Delete CSV after import:', 'give'),
822
+					'description' => __('Your CSV file will be uploaded via the WordPress Media Library. It\'s a good idea to delete it after the import is finished so that your sensitive data is not accessible on the web. Disable this only if you plan to delete the file manually later.', 'give'),
826 823
 					'default'     => $delete_csv,
827 824
 					'type'        => 'radio_inline',
828 825
 					'options'     => array(
829
-						'enabled'  => __( 'Enabled', 'give' ),
830
-						'disabled' => __( 'Disabled', 'give' ),
826
+						'enabled'  => __('Enabled', 'give'),
827
+						'disabled' => __('Disabled', 'give'),
831 828
 					),
832 829
 				),
833 830
 				array(
834 831
 					'id'          => 'per_page',
835
-					'name'        => __( 'Process Rows Per Batch:', 'give' ),
832
+					'name'        => __('Process Rows Per Batch:', 'give'),
836 833
 					'type'        => 'number',
837
-					'description' => __( 'Determine how many rows you would like to import per cycle.', 'give' ),
834
+					'description' => __('Determine how many rows you would like to import per cycle.', 'give'),
838 835
 					'default'     => $per_page,
839 836
 					'class'       => 'give-text-small',
840 837
 				),
841 838
 			);
842 839
 
843
-			$settings = apply_filters( 'give_import_file_upload_html', $settings );
840
+			$settings = apply_filters('give_import_file_upload_html', $settings);
844 841
 
845
-			Give_Admin_Settings::output_fields( $settings, 'give_settings' );
842
+			Give_Admin_Settings::output_fields($settings, 'give_settings');
846 843
 		}
847 844
 
848 845
 		/**
@@ -855,27 +852,24 @@  discard block
 block discarded – undo
855 852
 			$step = $this->get_step();
856 853
 
857 854
 			// Validation for first step.
858
-			if ( 1 === $step ) {
859
-				$csv_id = absint( $_POST['csv_id'] );
855
+			if (1 === $step) {
856
+				$csv_id = absint($_POST['csv_id']);
860 857
 
861
-				if ( $this->is_valid_csv( $csv_id, esc_url( $_POST['csv'] ) ) ) {
858
+				if ($this->is_valid_csv($csv_id, esc_url($_POST['csv']))) {
862 859
 
863
-					$url = give_import_page_url( (array) apply_filters( 'give_import_step_two_url', array(
860
+					$url = give_import_page_url((array) apply_filters('give_import_step_two_url', array(
864 861
 						'step'          => '2',
865 862
 						'importer-type' => $this->importer_type,
866 863
 						'csv'           => $csv_id,
867
-						'delimiter'     => isset( $_REQUEST['delimiter'] ) ? give_clean( $_REQUEST['delimiter'] ) : 'csv',
868
-						'mode'          => empty( $_POST['mode'] ) ?
869
-							'0' :
870
-							( give_is_setting_enabled( give_clean( $_POST['mode'] ) ) ? '1' : '0' ),
871
-						'create_user'   => empty( $_POST['create_user'] ) ?
872
-							'0' :
873
-							( give_is_setting_enabled( give_clean( $_POST['create_user'] ) ) ? '1' : '0' ),
874
-						'delete_csv'    => empty( $_POST['delete_csv'] ) ?
875
-							'1' :
876
-							( give_is_setting_enabled( give_clean( $_POST['delete_csv'] ) ) ? '1' : '0' ),
877
-						'per_page'      => isset( $_POST['per_page'] ) ? absint( $_POST['per_page'] ) : self::$per_page,
878
-					) ) );
864
+						'delimiter'     => isset($_REQUEST['delimiter']) ? give_clean($_REQUEST['delimiter']) : 'csv',
865
+						'mode'          => empty($_POST['mode']) ?
866
+							'0' : (give_is_setting_enabled(give_clean($_POST['mode'])) ? '1' : '0'),
867
+						'create_user'   => empty($_POST['create_user']) ?
868
+							'0' : (give_is_setting_enabled(give_clean($_POST['create_user'])) ? '1' : '0'),
869
+						'delete_csv'    => empty($_POST['delete_csv']) ?
870
+							'1' : (give_is_setting_enabled(give_clean($_POST['delete_csv'])) ? '1' : '0'),
871
+						'per_page'      => isset($_POST['per_page']) ? absint($_POST['per_page']) : self::$per_page,
872
+					)));
879 873
 					?>
880 874
 					<script type="text/javascript">
881 875
 						window.location = "<?php echo $url; ?>"
@@ -896,25 +890,25 @@  discard block
 block discarded – undo
896 890
 		 *
897 891
 		 * @return bool $has_error CSV is valid or not.
898 892
 		 */
899
-		private function is_valid_csv( $csv = false, $match_url = '' ) {
893
+		private function is_valid_csv($csv = false, $match_url = '') {
900 894
 			$is_valid_csv = true;
901 895
 
902
-			if ( $csv ) {
903
-				$csv_url = wp_get_attachment_url( $csv );
896
+			if ($csv) {
897
+				$csv_url = wp_get_attachment_url($csv);
904 898
 
905
-				$delimiter = ( ! empty( $_REQUEST['delimiter'] ) ? give_clean( $_REQUEST['delimiter'] ) : 'csv' );
899
+				$delimiter = ( ! empty($_REQUEST['delimiter']) ? give_clean($_REQUEST['delimiter']) : 'csv');
906 900
 
907 901
 				if (
908 902
 					! $csv_url ||
909
-					( ! empty( $match_url ) && ( $csv_url !== $match_url ) ) ||
910
-					( ( $mime_type = get_post_mime_type( $csv ) ) && ! strpos( $mime_type, $delimiter ) )
903
+					( ! empty($match_url) && ($csv_url !== $match_url)) ||
904
+					(($mime_type = get_post_mime_type($csv)) && ! strpos($mime_type, $delimiter))
911 905
 				) {
912 906
 					$is_valid_csv = false;
913
-					Give_Admin_Settings::add_error( 'give-import-csv', __( 'Please upload or provide a valid CSV file.', 'give' ) );
907
+					Give_Admin_Settings::add_error('give-import-csv', __('Please upload or provide a valid CSV file.', 'give'));
914 908
 				}
915 909
 			} else {
916 910
 				$is_valid_csv = false;
917
-				Give_Admin_Settings::add_error( 'give-import-csv', __( 'Please upload or provide a valid CSV file.', 'give' ) );
911
+				Give_Admin_Settings::add_error('give-import-csv', __('Please upload or provide a valid CSV file.', 'give'));
918 912
 			}
919 913
 
920 914
 			return $is_valid_csv;
@@ -930,8 +924,8 @@  discard block
 block discarded – undo
930 924
 		 * @param $field
931 925
 		 * @param $option_value
932 926
 		 */
933
-		public function render_import_field( $field, $option_value ) {
934
-			include_once GIVE_PLUGIN_DIR . 'includes/admin/tools/views/html-admin-page-imports.php';
927
+		public function render_import_field($field, $option_value) {
928
+			include_once GIVE_PLUGIN_DIR.'includes/admin/tools/views/html-admin-page-imports.php';
935 929
 		}
936 930
 
937 931
 		/**
@@ -942,8 +936,8 @@  discard block
 block discarded – undo
942 936
 		 */
943 937
 		private function is_donations_import_page() {
944 938
 			return 'import' === give_get_current_setting_tab() &&
945
-			       isset( $_GET['importer-type'] ) &&
946
-			       $this->importer_type === give_clean( $_GET['importer-type'] );
939
+			       isset($_GET['importer-type']) &&
940
+			       $this->importer_type === give_clean($_GET['importer-type']);
947 941
 		}
948 942
 	}
949 943
 
Please login to merge, or discard this patch.