Completed
Push — master ( a1f8b1...a764cd )
by Devin
07:39 queued 04:38
created
includes/class-give-donor.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -889,7 +889,7 @@  discard block
 block discarded – undo
889 889
 	 * @access public
890 890
 	 *
891 891
 	 * @param  string $meta_key Metadata name. Default is empty.
892
-	 * @param  mixed $meta_value Metadata value.
892
+	 * @param  string $meta_value Metadata value.
893 893
 	 * @param  bool $unique Optional. Whether the same key should not be added. Default is false.
894 894
 	 *
895 895
 	 * @return bool               False for failure. True for success.
@@ -921,7 +921,7 @@  discard block
 block discarded – undo
921 921
 	 * @access public
922 922
 	 *
923 923
 	 * @param  string $meta_key Metadata name. Default is empty.
924
-	 * @param  mixed $meta_value Optional. Metadata value. Default is empty.
924
+	 * @param  string $meta_value Optional. Metadata value. Default is empty.
925 925
 	 *
926 926
 	 * @return bool               False for failure. True for success.
927 927
 	 */
Please login to merge, or discard this patch.
Spacing   +170 added lines, -170 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -139,32 +139,32 @@  discard block
 block discarded – undo
139 139
 	 * @param bool $_id_or_email
140 140
 	 * @param bool $by_user_id
141 141
 	 */
142
-	public function __construct( $_id_or_email = false, $by_user_id = false ) {
142
+	public function __construct($_id_or_email = false, $by_user_id = false) {
143 143
 
144 144
 		$this->db = new Give_DB_Donors();
145 145
 
146 146
 		if (
147 147
 			false === $_id_or_email
148
-			|| ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) )
148
+			|| (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email))
149 149
 		) {
150 150
 			return false;
151 151
 		}
152 152
 
153
-		$by_user_id = is_bool( $by_user_id ) ? $by_user_id : false;
153
+		$by_user_id = is_bool($by_user_id) ? $by_user_id : false;
154 154
 
155
-		if ( is_numeric( $_id_or_email ) ) {
155
+		if (is_numeric($_id_or_email)) {
156 156
 			$field = $by_user_id ? 'user_id' : 'id';
157 157
 		} else {
158 158
 			$field = 'email';
159 159
 		}
160 160
 
161
-		$donor = $this->db->get_donor_by( $field, $_id_or_email );
161
+		$donor = $this->db->get_donor_by($field, $_id_or_email);
162 162
 
163
-		if ( empty( $donor ) || ! is_object( $donor ) ) {
163
+		if (empty($donor) || ! is_object($donor)) {
164 164
 			return false;
165 165
 		}
166 166
 
167
-		$this->setup_donor( $donor );
167
+		$this->setup_donor($donor);
168 168
 
169 169
 	}
170 170
 
@@ -180,15 +180,15 @@  discard block
 block discarded – undo
180 180
 	 *
181 181
 	 * @return bool             If the setup was successful or not.
182 182
 	 */
183
-	private function setup_donor( $donor ) {
183
+	private function setup_donor($donor) {
184 184
 
185
-		if ( ! is_object( $donor ) ) {
185
+		if ( ! is_object($donor)) {
186 186
 			return false;
187 187
 		}
188 188
 
189
-		foreach ( $donor as $key => $value ) {
189
+		foreach ($donor as $key => $value) {
190 190
 
191
-			switch ( $key ) {
191
+			switch ($key) {
192 192
 
193 193
 				case 'notes':
194 194
 					$this->$key = $this->get_notes();
@@ -202,11 +202,11 @@  discard block
 block discarded – undo
202 202
 		}
203 203
 
204 204
 		// Get donor's all email including primary email.
205
-		$this->emails = (array) $this->get_meta( 'additional_email', false );
206
-		$this->emails = array( 'primary' => $this->email ) + $this->emails;
205
+		$this->emails = (array) $this->get_meta('additional_email', false);
206
+		$this->emails = array('primary' => $this->email) + $this->emails;
207 207
 
208 208
 		// Donor ID and email are the only things that are necessary, make sure they exist.
209
-		if ( ! empty( $this->id ) && ! empty( $this->email ) ) {
209
+		if ( ! empty($this->id) && ! empty($this->email)) {
210 210
 			return true;
211 211
 		}
212 212
 
@@ -223,16 +223,16 @@  discard block
 block discarded – undo
223 223
 	 *
224 224
 	 * @return mixed|\WP_Error
225 225
 	 */
226
-	public function __get( $key ) {
226
+	public function __get($key) {
227 227
 
228
-		if ( method_exists( $this, 'get_' . $key ) ) {
228
+		if (method_exists($this, 'get_'.$key)) {
229 229
 
230
-			return call_user_func( array( $this, 'get_' . $key ) );
230
+			return call_user_func(array($this, 'get_'.$key));
231 231
 
232 232
 		} else {
233 233
 
234 234
 			/* translators: %s: property key */
235
-			return new WP_Error( 'give-donor-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) );
235
+			return new WP_Error('give-donor-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key));
236 236
 
237 237
 		}
238 238
 
@@ -248,9 +248,9 @@  discard block
 block discarded – undo
248 248
 	 *
249 249
 	 * @return bool|int    False if not a valid creation, donor ID if user is found or valid creation.
250 250
 	 */
251
-	public function create( $data = array() ) {
251
+	public function create($data = array()) {
252 252
 
253
-		if ( $this->id != 0 || empty( $data ) ) {
253
+		if ($this->id != 0 || empty($data)) {
254 254
 			return false;
255 255
 		}
256 256
 
@@ -258,15 +258,15 @@  discard block
 block discarded – undo
258 258
 			'payment_ids' => '',
259 259
 		);
260 260
 
261
-		$args = wp_parse_args( $data, $defaults );
262
-		$args = $this->sanitize_columns( $args );
261
+		$args = wp_parse_args($data, $defaults);
262
+		$args = $this->sanitize_columns($args);
263 263
 
264
-		if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) {
264
+		if (empty($args['email']) || ! is_email($args['email'])) {
265 265
 			return false;
266 266
 		}
267 267
 
268
-		if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) {
269
-			$args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) );
268
+		if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) {
269
+			$args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids'])));
270 270
 		}
271 271
 
272 272
 		/**
@@ -276,18 +276,18 @@  discard block
 block discarded – undo
276 276
 		 *
277 277
 		 * @param array $args Donor attributes.
278 278
 		 */
279
-		do_action( 'give_donor_pre_create', $args );
279
+		do_action('give_donor_pre_create', $args);
280 280
 
281 281
 		$created = false;
282 282
 
283 283
 		// The DB class 'add' implies an update if the donor being asked to be created already exists
284
-		if ( $this->db->add( $data ) ) {
284
+		if ($this->db->add($data)) {
285 285
 
286 286
 			// We've successfully added/updated the donor, reset the class vars with the new data
287
-			$donor = $this->db->get_donor_by( 'email', $args['email'] );
287
+			$donor = $this->db->get_donor_by('email', $args['email']);
288 288
 
289 289
 			// Setup the donor data with the values from DB
290
-			$this->setup_donor( $donor );
290
+			$this->setup_donor($donor);
291 291
 
292 292
 			$created = $this->id;
293 293
 		}
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 		 * @param bool|int $created False if not a valid creation, donor ID if user is found or valid creation.
301 301
 		 * @param array $args Customer attributes.
302 302
 		 */
303
-		do_action( 'give_donor_post_create', $created, $args );
303
+		do_action('give_donor_post_create', $created, $args);
304 304
 
305 305
 		return $created;
306 306
 
@@ -316,13 +316,13 @@  discard block
 block discarded – undo
316 316
 	 *
317 317
 	 * @return bool        If the update was successful or not.
318 318
 	 */
319
-	public function update( $data = array() ) {
319
+	public function update($data = array()) {
320 320
 
321
-		if ( empty( $data ) ) {
321
+		if (empty($data)) {
322 322
 			return false;
323 323
 		}
324 324
 
325
-		$data = $this->sanitize_columns( $data );
325
+		$data = $this->sanitize_columns($data);
326 326
 
327 327
 		/**
328 328
 		 * Fires before updating donors.
@@ -332,14 +332,14 @@  discard block
 block discarded – undo
332 332
 		 * @param int $donor_id Donor id.
333 333
 		 * @param array $data Donor attributes.
334 334
 		 */
335
-		do_action( 'give_donor_pre_update', $this->id, $data );
335
+		do_action('give_donor_pre_update', $this->id, $data);
336 336
 
337 337
 		$updated = false;
338 338
 
339
-		if ( $this->db->update( $this->id, $data ) ) {
339
+		if ($this->db->update($this->id, $data)) {
340 340
 
341
-			$donor = $this->db->get_donor_by( 'id', $this->id );
342
-			$this->setup_donor( $donor );
341
+			$donor = $this->db->get_donor_by('id', $this->id);
342
+			$this->setup_donor($donor);
343 343
 
344 344
 			$updated = true;
345 345
 		}
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 		 * @param int $donor_id Donor id.
354 354
 		 * @param array $data Donor attributes.
355 355
 		 */
356
-		do_action( 'give_donor_post_update', $updated, $this->id, $data );
356
+		do_action('give_donor_post_update', $updated, $this->id, $data);
357 357
 
358 358
 		return $updated;
359 359
 	}
@@ -371,27 +371,27 @@  discard block
 block discarded – undo
371 371
 	 *
372 372
 	 * @return bool            If the attachment was successfully.
373 373
 	 */
374
-	public function attach_payment( $payment_id = 0, $update_stats = true ) {
374
+	public function attach_payment($payment_id = 0, $update_stats = true) {
375 375
 
376
-		if ( empty( $payment_id ) ) {
376
+		if (empty($payment_id)) {
377 377
 			return false;
378 378
 		}
379 379
 
380
-		if ( empty( $this->payment_ids ) ) {
380
+		if (empty($this->payment_ids)) {
381 381
 
382 382
 			$new_payment_ids = $payment_id;
383 383
 
384 384
 		} else {
385 385
 
386
-			$payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) );
386
+			$payment_ids = array_map('absint', explode(',', $this->payment_ids));
387 387
 
388
-			if ( in_array( $payment_id, $payment_ids ) ) {
388
+			if (in_array($payment_id, $payment_ids)) {
389 389
 				$update_stats = false;
390 390
 			}
391 391
 
392 392
 			$payment_ids[] = $payment_id;
393 393
 
394
-			$new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
394
+			$new_payment_ids = implode(',', array_unique(array_values($payment_ids)));
395 395
 
396 396
 		}
397 397
 
@@ -403,20 +403,20 @@  discard block
 block discarded – undo
403 403
 		 * @param int $payment_id Payment id.
404 404
 		 * @param int $donor_id Customer id.
405 405
 		 */
406
-		do_action( 'give_donor_pre_attach_payment', $payment_id, $this->id );
406
+		do_action('give_donor_pre_attach_payment', $payment_id, $this->id);
407 407
 
408
-		$payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) );
408
+		$payment_added = $this->update(array('payment_ids' => $new_payment_ids));
409 409
 
410
-		if ( $payment_added ) {
410
+		if ($payment_added) {
411 411
 
412 412
 			$this->payment_ids = $new_payment_ids;
413 413
 
414 414
 			// We added this payment successfully, increment the stats
415
-			if ( $update_stats ) {
416
-				$payment_amount = give_get_payment_amount( $payment_id );
415
+			if ($update_stats) {
416
+				$payment_amount = give_get_payment_amount($payment_id);
417 417
 
418
-				if ( ! empty( $payment_amount ) ) {
419
-					$this->increase_value( $payment_amount );
418
+				if ( ! empty($payment_amount)) {
419
+					$this->increase_value($payment_amount);
420 420
 				}
421 421
 
422 422
 				$this->increase_purchase_count();
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 		 * @param int $payment_id Payment id.
433 433
 		 * @param int $donor_id Donor id.
434 434
 		 */
435
-		do_action( 'give_donor_post_attach_payment', $payment_added, $payment_id, $this->id );
435
+		do_action('give_donor_post_attach_payment', $payment_added, $payment_id, $this->id);
436 436
 
437 437
 		return $payment_added;
438 438
 	}
@@ -450,33 +450,33 @@  discard block
 block discarded – undo
450 450
 	 *
451 451
 	 * @return boolean               If the removal was successful.
452 452
 	 */
453
-	public function remove_payment( $payment_id = 0, $update_stats = true ) {
453
+	public function remove_payment($payment_id = 0, $update_stats = true) {
454 454
 
455
-		if ( empty( $payment_id ) ) {
455
+		if (empty($payment_id)) {
456 456
 			return false;
457 457
 		}
458 458
 
459
-		$payment = new Give_Payment( $payment_id );
459
+		$payment = new Give_Payment($payment_id);
460 460
 
461
-		if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) {
461
+		if ('publish' !== $payment->status && 'revoked' !== $payment->status) {
462 462
 			$update_stats = false;
463 463
 		}
464 464
 
465 465
 		$new_payment_ids = '';
466 466
 
467
-		if ( ! empty( $this->payment_ids ) ) {
467
+		if ( ! empty($this->payment_ids)) {
468 468
 
469
-			$payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) );
469
+			$payment_ids = array_map('absint', explode(',', $this->payment_ids));
470 470
 
471
-			$pos = array_search( $payment_id, $payment_ids );
472
-			if ( false === $pos ) {
471
+			$pos = array_search($payment_id, $payment_ids);
472
+			if (false === $pos) {
473 473
 				return false;
474 474
 			}
475 475
 
476
-			unset( $payment_ids[ $pos ] );
477
-			$payment_ids = array_filter( $payment_ids );
476
+			unset($payment_ids[$pos]);
477
+			$payment_ids = array_filter($payment_ids);
478 478
 
479
-			$new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
479
+			$new_payment_ids = implode(',', array_unique(array_values($payment_ids)));
480 480
 
481 481
 		}
482 482
 
@@ -488,20 +488,20 @@  discard block
 block discarded – undo
488 488
 		 * @param int $payment_id Payment id.
489 489
 		 * @param int $donor_id Customer id.
490 490
 		 */
491
-		do_action( 'give_donor_pre_remove_payment', $payment_id, $this->id );
491
+		do_action('give_donor_pre_remove_payment', $payment_id, $this->id);
492 492
 
493
-		$payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) );
493
+		$payment_removed = $this->update(array('payment_ids' => $new_payment_ids));
494 494
 
495
-		if ( $payment_removed ) {
495
+		if ($payment_removed) {
496 496
 
497 497
 			$this->payment_ids = $new_payment_ids;
498 498
 
499
-			if ( $update_stats ) {
499
+			if ($update_stats) {
500 500
 				// We removed this payment successfully, decrement the stats
501
-				$payment_amount = give_get_payment_amount( $payment_id );
501
+				$payment_amount = give_get_payment_amount($payment_id);
502 502
 
503
-				if ( ! empty( $payment_amount ) ) {
504
-					$this->decrease_value( $payment_amount );
503
+				if ( ! empty($payment_amount)) {
504
+					$this->decrease_value($payment_amount);
505 505
 				}
506 506
 
507 507
 				$this->decrease_donation_count();
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 		 * @param int $payment_id Payment id.
518 518
 		 * @param int $donor_id Donor id.
519 519
 		 */
520
-		do_action( 'give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id );
520
+		do_action('give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id);
521 521
 
522 522
 		return $payment_removed;
523 523
 
@@ -533,10 +533,10 @@  discard block
 block discarded – undo
533 533
 	 *
534 534
 	 * @return int        The donation count.
535 535
 	 */
536
-	public function increase_purchase_count( $count = 1 ) {
536
+	public function increase_purchase_count($count = 1) {
537 537
 
538 538
 		// Make sure it's numeric and not negative.
539
-		if ( ! is_numeric( $count ) || $count != absint( $count ) ) {
539
+		if ( ! is_numeric($count) || $count != absint($count)) {
540 540
 			return false;
541 541
 		}
542 542
 
@@ -550,9 +550,9 @@  discard block
 block discarded – undo
550 550
 		 * @param int $count The number to increase by.
551 551
 		 * @param int $donor_id Donor id.
552 552
 		 */
553
-		do_action( 'give_donor_pre_increase_donation_count', $count, $this->id );
553
+		do_action('give_donor_pre_increase_donation_count', $count, $this->id);
554 554
 
555
-		if ( $this->update( array( 'purchase_count' => $new_total ) ) ) {
555
+		if ($this->update(array('purchase_count' => $new_total))) {
556 556
 			$this->purchase_count = $new_total;
557 557
 		}
558 558
 
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
 		 * @param int $count The number increased by.
566 566
 		 * @param int $donor_id Donor id.
567 567
 		 */
568
-		do_action( 'give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id );
568
+		do_action('give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id);
569 569
 
570 570
 		return $this->purchase_count;
571 571
 	}
@@ -580,16 +580,16 @@  discard block
 block discarded – undo
580 580
 	 *
581 581
 	 * @return mixed      If successful, the new count, otherwise false.
582 582
 	 */
583
-	public function decrease_donation_count( $count = 1 ) {
583
+	public function decrease_donation_count($count = 1) {
584 584
 
585 585
 		// Make sure it's numeric and not negative
586
-		if ( ! is_numeric( $count ) || $count != absint( $count ) ) {
586
+		if ( ! is_numeric($count) || $count != absint($count)) {
587 587
 			return false;
588 588
 		}
589 589
 
590 590
 		$new_total = (int) $this->purchase_count - (int) $count;
591 591
 
592
-		if ( $new_total < 0 ) {
592
+		if ($new_total < 0) {
593 593
 			$new_total = 0;
594 594
 		}
595 595
 
@@ -601,9 +601,9 @@  discard block
 block discarded – undo
601 601
 		 * @param int $count The number to decrease by.
602 602
 		 * @param int $donor_id Customer id.
603 603
 		 */
604
-		do_action( 'give_donor_pre_decrease_donation_count', $count, $this->id );
604
+		do_action('give_donor_pre_decrease_donation_count', $count, $this->id);
605 605
 
606
-		if ( $this->update( array( 'purchase_count' => $new_total ) ) ) {
606
+		if ($this->update(array('purchase_count' => $new_total))) {
607 607
 			$this->purchase_count = $new_total;
608 608
 		}
609 609
 
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
 		 * @param int $count The number decreased by.
617 617
 		 * @param int $donor_id Donor id.
618 618
 		 */
619
-		do_action( 'give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id );
619
+		do_action('give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id);
620 620
 
621 621
 		return $this->purchase_count;
622 622
 	}
@@ -631,9 +631,9 @@  discard block
 block discarded – undo
631 631
 	 *
632 632
 	 * @return mixed        If successful, the new value, otherwise false.
633 633
 	 */
634
-	public function increase_value( $value = 0.00 ) {
634
+	public function increase_value($value = 0.00) {
635 635
 
636
-		$new_value = floatval( $this->purchase_value ) + $value;
636
+		$new_value = floatval($this->purchase_value) + $value;
637 637
 
638 638
 		/**
639 639
 		 * Fires before increasing donor lifetime value.
@@ -643,9 +643,9 @@  discard block
 block discarded – undo
643 643
 		 * @param float $value The value to increase by.
644 644
 		 * @param int $donor_id Customer id.
645 645
 		 */
646
-		do_action( 'give_donor_pre_increase_value', $value, $this->id );
646
+		do_action('give_donor_pre_increase_value', $value, $this->id);
647 647
 
648
-		if ( $this->update( array( 'purchase_value' => $new_value ) ) ) {
648
+		if ($this->update(array('purchase_value' => $new_value))) {
649 649
 			$this->purchase_value = $new_value;
650 650
 		}
651 651
 
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
 		 * @param float $value The value increased by.
659 659
 		 * @param int $donor_id Donor id.
660 660
 		 */
661
-		do_action( 'give_donor_post_increase_value', $this->purchase_value, $value, $this->id );
661
+		do_action('give_donor_post_increase_value', $this->purchase_value, $value, $this->id);
662 662
 
663 663
 		return $this->purchase_value;
664 664
 	}
@@ -673,11 +673,11 @@  discard block
 block discarded – undo
673 673
 	 *
674 674
 	 * @return mixed        If successful, the new value, otherwise false.
675 675
 	 */
676
-	public function decrease_value( $value = 0.00 ) {
676
+	public function decrease_value($value = 0.00) {
677 677
 
678
-		$new_value = floatval( $this->purchase_value ) - $value;
678
+		$new_value = floatval($this->purchase_value) - $value;
679 679
 
680
-		if ( $new_value < 0 ) {
680
+		if ($new_value < 0) {
681 681
 			$new_value = 0.00;
682 682
 		}
683 683
 
@@ -689,9 +689,9 @@  discard block
 block discarded – undo
689 689
 		 * @param float $value The value to decrease by.
690 690
 		 * @param int $donor_id Donor id.
691 691
 		 */
692
-		do_action( 'give_donor_pre_decrease_value', $value, $this->id );
692
+		do_action('give_donor_pre_decrease_value', $value, $this->id);
693 693
 
694
-		if ( $this->update( array( 'purchase_value' => $new_value ) ) ) {
694
+		if ($this->update(array('purchase_value' => $new_value))) {
695 695
 			$this->purchase_value = $new_value;
696 696
 		}
697 697
 
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 		 * @param float $value The value decreased by.
705 705
 		 * @param int $donor_id Donor id.
706 706
 		 */
707
-		do_action( 'give_donor_post_decrease_value', $this->purchase_value, $value, $this->id );
707
+		do_action('give_donor_post_decrease_value', $this->purchase_value, $value, $this->id);
708 708
 
709 709
 		return $this->purchase_value;
710 710
 	}
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 	 *
724 724
 	 * @return mixed              If successful, the new donation stat value, otherwise false.
725 725
 	 */
726
-	public function update_donation_value( $curr_amount, $new_amount ) {
726
+	public function update_donation_value($curr_amount, $new_amount) {
727 727
 		/**
728 728
 		 * Payment total difference value can be:
729 729
 		 *  zero   (in case amount not change)
@@ -733,15 +733,15 @@  discard block
 block discarded – undo
733 733
 		$payment_total_diff = $new_amount - $curr_amount;
734 734
 
735 735
 		// We do not need to update donation stat if donation did not change.
736
-		if ( ! $payment_total_diff ) {
736
+		if ( ! $payment_total_diff) {
737 737
 			return false;
738 738
 		}
739 739
 
740
-		if ( $payment_total_diff > 0 ) {
741
-			$this->increase_value( $payment_total_diff );
740
+		if ($payment_total_diff > 0) {
741
+			$this->increase_value($payment_total_diff);
742 742
 		} else {
743 743
 			// Pass payment total difference as +ve value to decrease amount from user lifetime stat.
744
-			$this->decrease_value( - $payment_total_diff );
744
+			$this->decrease_value( -$payment_total_diff );
745 745
 		}
746 746
 
747 747
 		return $this->purchase_value;
@@ -758,15 +758,15 @@  discard block
 block discarded – undo
758 758
 	 *
759 759
 	 * @return array       The notes requested.
760 760
 	 */
761
-	public function get_notes( $length = 20, $paged = 1 ) {
761
+	public function get_notes($length = 20, $paged = 1) {
762 762
 
763
-		$length = is_numeric( $length ) ? $length : 20;
764
-		$offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0;
763
+		$length = is_numeric($length) ? $length : 20;
764
+		$offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0;
765 765
 
766 766
 		$all_notes   = $this->get_raw_notes();
767
-		$notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) );
767
+		$notes_array = array_reverse(array_filter(explode("\n\n", $all_notes)));
768 768
 
769
-		$desired_notes = array_slice( $notes_array, $offset, $length );
769
+		$desired_notes = array_slice($notes_array, $offset, $length);
770 770
 
771 771
 		return $desired_notes;
772 772
 
@@ -783,9 +783,9 @@  discard block
 block discarded – undo
783 783
 	public function get_notes_count() {
784 784
 
785 785
 		$all_notes   = $this->get_raw_notes();
786
-		$notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) );
786
+		$notes_array = array_reverse(array_filter(explode("\n\n", $all_notes)));
787 787
 
788
-		return count( $notes_array );
788
+		return count($notes_array);
789 789
 
790 790
 	}
791 791
 
@@ -799,22 +799,22 @@  discard block
 block discarded – undo
799 799
 	 *
800 800
 	 * @return string|boolean The new note if added successfully, false otherwise.
801 801
 	 */
802
-	public function add_note( $note = '' ) {
802
+	public function add_note($note = '') {
803 803
 
804
-		$note = trim( $note );
805
-		if ( empty( $note ) ) {
804
+		$note = trim($note);
805
+		if (empty($note)) {
806 806
 			return false;
807 807
 		}
808 808
 
809 809
 		$notes = $this->get_raw_notes();
810 810
 
811
-		if ( empty( $notes ) ) {
811
+		if (empty($notes)) {
812 812
 			$notes = '';
813 813
 		}
814 814
 
815
-		$note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note;
816
-		$new_note    = apply_filters( 'give_customer_add_note_string', $note_string );
817
-		$notes       .= "\n\n" . $new_note;
815
+		$note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note;
816
+		$new_note    = apply_filters('give_customer_add_note_string', $note_string);
817
+		$notes .= "\n\n".$new_note;
818 818
 
819 819
 		/**
820 820
 		 * Fires before donor note is added.
@@ -824,11 +824,11 @@  discard block
 block discarded – undo
824 824
 		 * @param string $new_note New note to add.
825 825
 		 * @param int $donor_id Donor id.
826 826
 		 */
827
-		do_action( 'give_donor_pre_add_note', $new_note, $this->id );
827
+		do_action('give_donor_pre_add_note', $new_note, $this->id);
828 828
 
829
-		$updated = $this->update( array( 'notes' => $notes ) );
829
+		$updated = $this->update(array('notes' => $notes));
830 830
 
831
-		if ( $updated ) {
831
+		if ($updated) {
832 832
 			$this->notes = $this->get_notes();
833 833
 		}
834 834
 
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
 		 * @param string $new_note New note added.
842 842
 		 * @param int $donor_id Donor id.
843 843
 		 */
844
-		do_action( 'give_donor_post_add_note', $this->notes, $new_note, $this->id );
844
+		do_action('give_donor_post_add_note', $this->notes, $new_note, $this->id);
845 845
 
846 846
 		// Return the formatted note, so we can test, as well as update any displays
847 847
 		return $new_note;
@@ -858,7 +858,7 @@  discard block
 block discarded – undo
858 858
 	 */
859 859
 	private function get_raw_notes() {
860 860
 
861
-		$all_notes = $this->db->get_column( 'notes', $this->id );
861
+		$all_notes = $this->db->get_column('notes', $this->id);
862 862
 
863 863
 		return $all_notes;
864 864
 
@@ -875,8 +875,8 @@  discard block
 block discarded – undo
875 875
 	 *
876 876
 	 * @return mixed            Will be an array if $single is false. Will be value of meta data field if $single is true.
877 877
 	 */
878
-	public function get_meta( $meta_key = '', $single = true ) {
879
-		return Give()->donor_meta->get_meta( $this->id, $meta_key, $single );
878
+	public function get_meta($meta_key = '', $single = true) {
879
+		return Give()->donor_meta->get_meta($this->id, $meta_key, $single);
880 880
 	}
881 881
 
882 882
 	/**
@@ -891,8 +891,8 @@  discard block
 block discarded – undo
891 891
 	 *
892 892
 	 * @return bool               False for failure. True for success.
893 893
 	 */
894
-	public function add_meta( $meta_key = '', $meta_value, $unique = false ) {
895
-		return Give()->donor_meta->add_meta( $this->id, $meta_key, $meta_value, $unique );
894
+	public function add_meta($meta_key = '', $meta_value, $unique = false) {
895
+		return Give()->donor_meta->add_meta($this->id, $meta_key, $meta_value, $unique);
896 896
 	}
897 897
 
898 898
 	/**
@@ -907,8 +907,8 @@  discard block
 block discarded – undo
907 907
 	 *
908 908
 	 * @return bool               False on failure, true if success.
909 909
 	 */
910
-	public function update_meta( $meta_key = '', $meta_value, $prev_value = '' ) {
911
-		return Give()->donor_meta->update_meta( $this->id, $meta_key, $meta_value, $prev_value );
910
+	public function update_meta($meta_key = '', $meta_value, $prev_value = '') {
911
+		return Give()->donor_meta->update_meta($this->id, $meta_key, $meta_value, $prev_value);
912 912
 	}
913 913
 
914 914
 	/**
@@ -922,8 +922,8 @@  discard block
 block discarded – undo
922 922
 	 *
923 923
 	 * @return bool               False for failure. True for success.
924 924
 	 */
925
-	public function delete_meta( $meta_key = '', $meta_value = '' ) {
926
-		return Give()->donor_meta->delete_meta( $this->id, $meta_key, $meta_value );
925
+	public function delete_meta($meta_key = '', $meta_value = '') {
926
+		return Give()->donor_meta->delete_meta($this->id, $meta_key, $meta_value);
927 927
 	}
928 928
 
929 929
 	/**
@@ -936,51 +936,51 @@  discard block
 block discarded – undo
936 936
 	 *
937 937
 	 * @return array       The sanitized data, based off column defaults.
938 938
 	 */
939
-	private function sanitize_columns( $data ) {
939
+	private function sanitize_columns($data) {
940 940
 
941 941
 		$columns        = $this->db->get_columns();
942 942
 		$default_values = $this->db->get_column_defaults();
943 943
 
944
-		foreach ( $columns as $key => $type ) {
944
+		foreach ($columns as $key => $type) {
945 945
 
946 946
 			// Only sanitize data that we were provided
947
-			if ( ! array_key_exists( $key, $data ) ) {
947
+			if ( ! array_key_exists($key, $data)) {
948 948
 				continue;
949 949
 			}
950 950
 
951
-			switch ( $type ) {
951
+			switch ($type) {
952 952
 
953 953
 				case '%s':
954
-					if ( 'email' == $key ) {
955
-						$data[ $key ] = sanitize_email( $data[ $key ] );
956
-					} elseif ( 'notes' == $key ) {
957
-						$data[ $key ] = strip_tags( $data[ $key ] );
954
+					if ('email' == $key) {
955
+						$data[$key] = sanitize_email($data[$key]);
956
+					} elseif ('notes' == $key) {
957
+						$data[$key] = strip_tags($data[$key]);
958 958
 					} else {
959
-						$data[ $key ] = sanitize_text_field( $data[ $key ] );
959
+						$data[$key] = sanitize_text_field($data[$key]);
960 960
 					}
961 961
 					break;
962 962
 
963 963
 				case '%d':
964
-					if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) {
965
-						$data[ $key ] = $default_values[ $key ];
964
+					if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) {
965
+						$data[$key] = $default_values[$key];
966 966
 					} else {
967
-						$data[ $key ] = absint( $data[ $key ] );
967
+						$data[$key] = absint($data[$key]);
968 968
 					}
969 969
 					break;
970 970
 
971 971
 				case '%f':
972 972
 					// Convert what was given to a float
973
-					$value = floatval( $data[ $key ] );
973
+					$value = floatval($data[$key]);
974 974
 
975
-					if ( ! is_float( $value ) ) {
976
-						$data[ $key ] = $default_values[ $key ];
975
+					if ( ! is_float($value)) {
976
+						$data[$key] = $default_values[$key];
977 977
 					} else {
978
-						$data[ $key ] = $value;
978
+						$data[$key] = $value;
979 979
 					}
980 980
 					break;
981 981
 
982 982
 				default:
983
-					$data[ $key ] = sanitize_text_field( $data[ $key ] );
983
+					$data[$key] = sanitize_text_field($data[$key]);
984 984
 					break;
985 985
 
986 986
 			}
@@ -1000,33 +1000,33 @@  discard block
 block discarded – undo
1000 1000
 	 *
1001 1001
 	 * @return bool            If the email was added successfully
1002 1002
 	 */
1003
-	public function add_email( $email = '', $primary = false ) {
1004
-		if ( ! is_email( $email ) ) {
1003
+	public function add_email($email = '', $primary = false) {
1004
+		if ( ! is_email($email)) {
1005 1005
 			return false;
1006 1006
 		}
1007
-		$existing = new Give_Donor( $email );
1007
+		$existing = new Give_Donor($email);
1008 1008
 
1009
-		if ( $existing->id > 0 ) {
1009
+		if ($existing->id > 0) {
1010 1010
 			// Email address already belongs to another donor
1011 1011
 			return false;
1012 1012
 		}
1013 1013
 
1014
-		if ( email_exists( $email ) ) {
1015
-			$user = get_user_by( 'email', $email );
1016
-			if ( $user->ID != $this->user_id ) {
1014
+		if (email_exists($email)) {
1015
+			$user = get_user_by('email', $email);
1016
+			if ($user->ID != $this->user_id) {
1017 1017
 				return false;
1018 1018
 			}
1019 1019
 		}
1020 1020
 
1021
-		do_action( 'give_donor_pre_add_email', $email, $this->id, $this );
1021
+		do_action('give_donor_pre_add_email', $email, $this->id, $this);
1022 1022
 
1023 1023
 		// Add is used to ensure duplicate emails are not added
1024
-		$ret = (bool) $this->add_meta( 'additional_email', $email );
1024
+		$ret = (bool) $this->add_meta('additional_email', $email);
1025 1025
 
1026
-		do_action( 'give_donor_post_add_email', $email, $this->id, $this );
1026
+		do_action('give_donor_post_add_email', $email, $this->id, $this);
1027 1027
 
1028
-		if ( $ret && true === $primary ) {
1029
-			$this->set_primary_email( $email );
1028
+		if ($ret && true === $primary) {
1029
+			$this->set_primary_email($email);
1030 1030
 		}
1031 1031
 
1032 1032
 		return $ret;
@@ -1042,16 +1042,16 @@  discard block
 block discarded – undo
1042 1042
 	 *
1043 1043
 	 * @return bool          If the email was removed successfully.
1044 1044
 	 */
1045
-	public function remove_email( $email = '' ) {
1046
-		if ( ! is_email( $email ) ) {
1045
+	public function remove_email($email = '') {
1046
+		if ( ! is_email($email)) {
1047 1047
 			return false;
1048 1048
 		}
1049 1049
 
1050
-		do_action( 'give_donor_pre_remove_email', $email, $this->id, $this );
1050
+		do_action('give_donor_pre_remove_email', $email, $this->id, $this);
1051 1051
 
1052
-		$ret = (bool) $this->delete_meta( 'additional_email', $email );
1052
+		$ret = (bool) $this->delete_meta('additional_email', $email);
1053 1053
 
1054
-		do_action( 'give_donor_post_remove_email', $email, $this->id, $this );
1054
+		do_action('give_donor_post_remove_email', $email, $this->id, $this);
1055 1055
 
1056 1056
 		return $ret;
1057 1057
 	}
@@ -1068,16 +1068,16 @@  discard block
 block discarded – undo
1068 1068
 	 *
1069 1069
 	 * @return bool                      If the email was set as primary successfully.
1070 1070
 	 */
1071
-	public function set_primary_email( $new_primary_email = '' ) {
1072
-		if ( ! is_email( $new_primary_email ) ) {
1071
+	public function set_primary_email($new_primary_email = '') {
1072
+		if ( ! is_email($new_primary_email)) {
1073 1073
 			return false;
1074 1074
 		}
1075 1075
 
1076
-		do_action( 'give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this );
1076
+		do_action('give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this);
1077 1077
 
1078
-		$existing = new Give_Donor( $new_primary_email );
1078
+		$existing = new Give_Donor($new_primary_email);
1079 1079
 
1080
-		if ( $existing->id > 0 && (int) $existing->id !== (int) $this->id ) {
1080
+		if ($existing->id > 0 && (int) $existing->id !== (int) $this->id) {
1081 1081
 			// This email belongs to another donor.
1082 1082
 			return false;
1083 1083
 		}
@@ -1085,21 +1085,21 @@  discard block
 block discarded – undo
1085 1085
 		$old_email = $this->email;
1086 1086
 
1087 1087
 		// Update donor record with new email.
1088
-		$update = $this->update( array( 'email' => $new_primary_email ) );
1088
+		$update = $this->update(array('email' => $new_primary_email));
1089 1089
 
1090 1090
 		// Remove new primary from list of additional emails.
1091
-		$remove = $this->remove_email( $new_primary_email );
1091
+		$remove = $this->remove_email($new_primary_email);
1092 1092
 
1093 1093
 		// Add old email to additional emails list.
1094
-		$add = $this->add_email( $old_email );
1094
+		$add = $this->add_email($old_email);
1095 1095
 
1096 1096
 		$ret = $update && $remove && $add;
1097 1097
 
1098
-		if ( $ret ) {
1098
+		if ($ret) {
1099 1099
 			$this->email = $new_primary_email;
1100 1100
 		}
1101 1101
 
1102
-		do_action( 'give_donor_post_set_primary_email', $new_primary_email, $this->id, $this );
1102
+		do_action('give_donor_post_set_primary_email', $new_primary_email, $this->id, $this);
1103 1103
 
1104 1104
 		return $ret;
1105 1105
 	}
Please login to merge, or discard this patch.
includes/class-give-license-handler.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
 		 * @access private
704 704
 		 * @since  1.7
705 705
 		 *
706
-		 * @return bool
706
+		 * @return false|null
707 707
 		 */
708 708
 		private function __remove_license_key_from_subscriptions() {
709 709
 			$subscriptions = get_option( 'give_subscriptions', array() );
@@ -736,7 +736,7 @@  discard block
 block discarded – undo
736 736
 		 * @param $plugin_data
737 737
 		 * @param $status
738 738
 		 *
739
-		 * @return bool
739
+		 * @return false|null
740 740
 		 */
741 741
 		public function plugin_page_notices( $plugin_file, $plugin_data, $status ) {
742 742
 			// Bailout.
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
 		 *
759 759
 		 * @since  1.8.7
760 760
 		 * @access public
761
-		 * @return array
761
+		 * @return string
762 762
 		 */
763 763
 		public function license_state_message() {
764 764
 			$message_data = array();
Please login to merge, or discard this patch.
Spacing   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
17
-if ( ! class_exists( 'Give_License' ) ) :
17
+if ( ! class_exists('Give_License')) :
18 18
 
19 19
 	/**
20 20
 	 * Give_License Class
@@ -142,20 +142,20 @@  discard block
 block discarded – undo
142 142
 		 * @param string $_checkout_url
143 143
 		 * @param string $_account_url
144 144
 		 */
145
-		public function __construct( $_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null ) {
145
+		public function __construct($_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null) {
146 146
 
147 147
 			$give_options = give_get_settings();
148 148
 
149 149
 			$this->file             = $_file;
150 150
 			$this->item_name        = $_item_name;
151
-			$this->item_shortname   = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $this->item_name ) ) );
151
+			$this->item_shortname   = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($this->item_name)));
152 152
 			$this->version          = $_version;
153
-			$this->license          = isset( $give_options[ $this->item_shortname . '_license_key' ] ) ? trim( $give_options[ $this->item_shortname . '_license_key' ] ) : '';
154
-			$this->license_data     = get_option( $this->item_shortname . '_license_active' );
153
+			$this->license          = isset($give_options[$this->item_shortname.'_license_key']) ? trim($give_options[$this->item_shortname.'_license_key']) : '';
154
+			$this->license_data     = get_option($this->item_shortname.'_license_active');
155 155
 			$this->author           = $_author;
156
-			$this->api_url          = is_null( $_api_url ) ? $this->api_url : $_api_url;
157
-			$this->checkout_url     = is_null( $_checkout_url ) ? $this->checkout_url : $_checkout_url;
158
-			$this->account_url      = is_null( $_account_url ) ? $this->account_url : $_account_url;
156
+			$this->api_url          = is_null($_api_url) ? $this->api_url : $_api_url;
157
+			$this->checkout_url     = is_null($_checkout_url) ? $this->checkout_url : $_checkout_url;
158
+			$this->account_url      = is_null($_account_url) ? $this->account_url : $_account_url;
159 159
 			$this->auto_updater_obj = null;
160 160
 
161 161
 			// Setup hooks
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 		 */
177 177
 		private function includes() {
178 178
 
179
-			if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) {
179
+			if ( ! class_exists('EDD_SL_Plugin_Updater')) {
180 180
 				require_once 'admin/EDD_SL_Plugin_Updater.php';
181 181
 			}
182 182
 		}
@@ -194,30 +194,30 @@  discard block
 block discarded – undo
194 194
 		private function hooks() {
195 195
 
196 196
 			// Register settings
197
-			add_filter( 'give_settings_licenses', array( $this, 'settings' ), 1 );
197
+			add_filter('give_settings_licenses', array($this, 'settings'), 1);
198 198
 
199 199
 			// Activate license key on settings save
200
-			add_action( 'admin_init', array( $this, 'activate_license' ) );
200
+			add_action('admin_init', array($this, 'activate_license'));
201 201
 
202 202
 			// Deactivate license key
203
-			add_action( 'admin_init', array( $this, 'deactivate_license' ) );
203
+			add_action('admin_init', array($this, 'deactivate_license'));
204 204
 
205 205
 			// Updater
206
-			add_action( 'admin_init', array( $this, 'auto_updater' ), 0 );
207
-			add_action( 'admin_notices', array( $this, 'notices' ) );
206
+			add_action('admin_init', array($this, 'auto_updater'), 0);
207
+			add_action('admin_notices', array($this, 'notices'));
208 208
 
209 209
 			// Check license weekly.
210
-			add_action( 'give_weekly_scheduled_events', array( $this, 'weekly_license_check' ) );
211
-			add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_license_check' ) );
210
+			add_action('give_weekly_scheduled_events', array($this, 'weekly_license_check'));
211
+			add_action('give_validate_license_when_site_migrated', array($this, 'weekly_license_check'));
212 212
 
213 213
 			// Check subscription weekly.
214
-			add_action( 'give_weekly_scheduled_events', array( $this, 'weekly_subscription_check' ) );
215
-			add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_subscription_check' ) );
214
+			add_action('give_weekly_scheduled_events', array($this, 'weekly_subscription_check'));
215
+			add_action('give_validate_license_when_site_migrated', array($this, 'weekly_subscription_check'));
216 216
 
217 217
 			// Show addon notice on plugin page.
218
-			$plugin_name = explode( 'plugins/', $this->file );
219
-			$plugin_name = end( $plugin_name );
220
-			add_action( "after_plugin_row_{$plugin_name}", array( $this, 'plugin_page_notices' ), 10, 3 );
218
+			$plugin_name = explode('plugins/', $this->file);
219
+			$plugin_name = end($plugin_name);
220
+			add_action("after_plugin_row_{$plugin_name}", array($this, 'plugin_page_notices'), 10, 3);
221 221
 
222 222
 		}
223 223
 
@@ -257,16 +257,16 @@  discard block
 block discarded – undo
257 257
 		 *
258 258
 		 * @return array           License settings.
259 259
 		 */
260
-		public function settings( $settings ) {
260
+		public function settings($settings) {
261 261
 
262 262
 			$give_license_settings = array(
263 263
 				array(
264 264
 					'name'    => $this->item_name,
265
-					'id'      => $this->item_shortname . '_license_key',
265
+					'id'      => $this->item_shortname.'_license_key',
266 266
 					'desc'    => '',
267 267
 					'type'    => 'license_key',
268 268
 					'options' => array(
269
-						'license'      => get_option( $this->item_shortname . '_license_active' ),
269
+						'license'      => get_option($this->item_shortname.'_license_active'),
270 270
 						'shortname'    => $this->item_shortname,
271 271
 						'item_name'    => $this->item_name,
272 272
 						'api_url'      => $this->api_url,
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 				),
278 278
 			);
279 279
 
280
-			return array_merge( $settings, $give_license_settings );
280
+			return array_merge($settings, $give_license_settings);
281 281
 		}
282 282
 
283 283
 		/**
@@ -292,18 +292,18 @@  discard block
 block discarded – undo
292 292
 		 *
293 293
 		 * @return array           License settings content.
294 294
 		 */
295
-		public function license_settings_content( $settings ) {
295
+		public function license_settings_content($settings) {
296 296
 
297 297
 			$give_license_settings = array(
298 298
 				array(
299
-					'name' => __( 'Add-on Licenses', 'give' ),
299
+					'name' => __('Add-on Licenses', 'give'),
300 300
 					'desc' => '<hr>',
301 301
 					'type' => 'give_title',
302 302
 					'id'   => 'give_title',
303 303
 				),
304 304
 			);
305 305
 
306
-			return array_merge( $settings, $give_license_settings );
306
+			return array_merge($settings, $give_license_settings);
307 307
 		}
308 308
 
309 309
 		/**
@@ -318,56 +318,56 @@  discard block
 block discarded – undo
318 318
 		 */
319 319
 		public function activate_license() {
320 320
 			// Bailout.
321
-			if( ! $this->__is_user_can_edit_license() ) {
321
+			if ( ! $this->__is_user_can_edit_license()) {
322 322
 				return;
323 323
 			}
324 324
 
325 325
 			// Allow third party addon developers to handle license activation.
326
-			if ( $this->__is_third_party_addon() ) {
327
-				do_action( 'give_activate_license', $this );
326
+			if ($this->__is_third_party_addon()) {
327
+				do_action('give_activate_license', $this);
328 328
 
329 329
 				return;
330 330
 			}
331 331
 
332 332
 			// Delete previous license setting if a empty license key submitted.
333
-			if ( empty( $_POST[ $this->item_shortname . '_license_key' ] ) ) {
334
-				delete_option( $this->item_shortname . '_license_active' );
333
+			if (empty($_POST[$this->item_shortname.'_license_key'])) {
334
+				delete_option($this->item_shortname.'_license_active');
335 335
 
336 336
 				return;
337 337
 			}
338 338
 
339 339
 			// Do not simultaneously activate add-ons if the user want to deactivate a specific add-on.
340
-			foreach ( $_POST as $key => $value ) {
341
-				if ( false !== strpos( $key, 'license_key_deactivate' ) ) {
340
+			foreach ($_POST as $key => $value) {
341
+				if (false !== strpos($key, 'license_key_deactivate')) {
342 342
 					// Don't activate a key when deactivating a different key
343 343
 					return;
344 344
 				}
345 345
 			}
346 346
 
347 347
 			// Check if plugin previously installed.
348
-			if ( $this->is_valid_license() ) {
348
+			if ($this->is_valid_license()) {
349 349
 				return;
350 350
 			}
351 351
 
352 352
 			// Get license key.
353
-			$this->license = sanitize_text_field( $_POST[ $this->item_shortname . '_license_key' ] );
353
+			$this->license = sanitize_text_field($_POST[$this->item_shortname.'_license_key']);
354 354
 
355 355
 			// Delete previous license key from subscription if previously added.
356 356
 			$this->__remove_license_key_from_subscriptions();
357 357
 
358 358
 			// Make sure there are no api errors
359
-			if ( ! ( $license_data = $this->get_license_info( 'activate_license' ) ) ) {
359
+			if ( ! ($license_data = $this->get_license_info('activate_license'))) {
360 360
 				return;
361 361
 			}
362 362
 
363 363
 			// Tell WordPress to look for updates
364
-			set_site_transient( 'update_plugins', null );
364
+			set_site_transient('update_plugins', null);
365 365
 
366 366
 			// Add license data.
367
-			update_option( $this->item_shortname . '_license_active', $license_data );
367
+			update_option($this->item_shortname.'_license_active', $license_data);
368 368
 
369 369
 			// Add license key.
370
-			give_update_option( "{$this->item_shortname}_license_key", $this->license );
370
+			give_update_option("{$this->item_shortname}_license_key", $this->license);
371 371
 
372 372
 			// Check subscription for license key and store this to db (if any).
373 373
 			$this->__single_subscription_check();
@@ -385,33 +385,33 @@  discard block
 block discarded – undo
385 385
 		 */
386 386
 		public function deactivate_license() {
387 387
 			// Bailout.
388
-			if( ! $this->__is_user_can_edit_license() ) {
388
+			if ( ! $this->__is_user_can_edit_license()) {
389 389
 				return;
390 390
 			}
391 391
 
392 392
 			// Allow third party add-on developers to handle license deactivation.
393
-			if ( $this->__is_third_party_addon() ) {
394
-				do_action( 'give_deactivate_license', $this );
393
+			if ($this->__is_third_party_addon()) {
394
+				do_action('give_deactivate_license', $this);
395 395
 
396 396
 				return;
397 397
 			}
398 398
 
399 399
 			// Run on deactivate button press
400
-			if ( isset( $_POST[ $this->item_shortname . '_license_key_deactivate' ] ) ) {
400
+			if (isset($_POST[$this->item_shortname.'_license_key_deactivate'])) {
401 401
 
402 402
 				// Make sure there are no api errors
403
-				if ( ! ( $license_data = $this->get_license_info( 'deactivate_license' ) ) ) {
403
+				if ( ! ($license_data = $this->get_license_info('deactivate_license'))) {
404 404
 					return;
405 405
 				}
406 406
 
407 407
 				// Ensure deactivated successfully.
408
-				if ( isset( $license_data->success ) ) {
408
+				if (isset($license_data->success)) {
409 409
 
410 410
 					// Remove license data.
411
-					delete_option( $this->item_shortname . '_license_active' );
411
+					delete_option($this->item_shortname.'_license_active');
412 412
 
413 413
 					// Delete licence data.
414
-					give_delete_option( $this->item_shortname . '_license_key' );
414
+					give_delete_option($this->item_shortname.'_license_key');
415 415
 
416 416
 					// Remove license key from subscriptions if exist.
417 417
 					$this->__remove_license_key_from_subscriptions();
@@ -431,25 +431,25 @@  discard block
 block discarded – undo
431 431
 		public function weekly_license_check() {
432 432
 
433 433
 			if (
434
-				! empty( $_POST['give_settings'] ) ||
435
-				empty( $this->license )
434
+				! empty($_POST['give_settings']) ||
435
+				empty($this->license)
436 436
 			) {
437 437
 				return;
438 438
 			}
439 439
 
440 440
 			// Allow third party add-on developers to handle their license check.
441
-			if ( $this->__is_third_party_addon() ) {
442
-				do_action( 'give_weekly_license_check', $this );
441
+			if ($this->__is_third_party_addon()) {
442
+				do_action('give_weekly_license_check', $this);
443 443
 
444 444
 				return;
445 445
 			}
446 446
 
447 447
 			// Make sure there are no api errors
448
-			if ( ! ( $license_data = $this->get_license_info( 'check_license' ) ) ) {
448
+			if ( ! ($license_data = $this->get_license_info('check_license'))) {
449 449
 				return;
450 450
 			}
451 451
 
452
-			update_option( $this->item_shortname . '_license_active', $license_data );
452
+			update_option($this->item_shortname.'_license_active', $license_data);
453 453
 
454 454
 			return;
455 455
 		}
@@ -465,21 +465,21 @@  discard block
 block discarded – undo
465 465
 		public function weekly_subscription_check() {
466 466
 			// Bailout.
467 467
 			if (
468
-				! empty( $_POST['give_settings'] ) ||
469
-				empty( $this->license )
468
+				! empty($_POST['give_settings']) ||
469
+				empty($this->license)
470 470
 			) {
471 471
 				return;
472 472
 			}
473 473
 
474 474
 			// Remove old subscription data.
475
-			if ( absint( get_option( '_give_subscriptions_edit_last', true ) ) < current_time( 'timestamp', 1 ) ) {
476
-				delete_option( 'give_subscriptions' );
477
-				update_option( '_give_subscriptions_edit_last', strtotime( '+ 1 day', current_time( 'timestamp', 1 ) ) );
475
+			if (absint(get_option('_give_subscriptions_edit_last', true)) < current_time('timestamp', 1)) {
476
+				delete_option('give_subscriptions');
477
+				update_option('_give_subscriptions_edit_last', strtotime('+ 1 day', current_time('timestamp', 1)));
478 478
 			}
479 479
 
480 480
 			// Allow third party add-on developers to handle their subscription check.
481
-			if ( $this->__is_third_party_addon() ) {
482
-				do_action( 'give_weekly_subscription_check', $this );
481
+			if ($this->__is_third_party_addon()) {
482
+				do_action('give_weekly_subscription_check', $this);
483 483
 
484 484
 				return;
485 485
 			}
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
 		 * @return void
497 497
 		 */
498 498
 		private function __single_subscription_check() {
499
-			if ( empty( $this->license ) ) {
499
+			if (empty($this->license)) {
500 500
 				return;
501 501
 			}
502 502
 
@@ -504,29 +504,29 @@  discard block
 block discarded – undo
504 504
 			// Do not get confused with edd_action check_subscription.
505 505
 			// By default edd software licensing api does not have api to check subscription.
506 506
 			// This is a custom feature to check subscriptions.
507
-			if ( ! ( $subscription_data = $this->get_license_info( 'check_subscription', true ) ) ) {
507
+			if ( ! ($subscription_data = $this->get_license_info('check_subscription', true))) {
508 508
 				return;
509 509
 			}
510 510
 
511 511
 
512
-			if ( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) {
513
-				$subscriptions = get_option( 'give_subscriptions', array() );
512
+			if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) {
513
+				$subscriptions = get_option('give_subscriptions', array());
514 514
 
515 515
 				// Update subscription data only if subscription does not exist already.
516
-				$subscriptions[ $subscription_data['id'] ]            = $subscription_data;
516
+				$subscriptions[$subscription_data['id']] = $subscription_data;
517 517
 
518 518
 
519 519
 				// Initiate default set of license for subscription.
520
-				if( ! isset( $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) {
521
-					$subscriptions[ $subscription_data['id']]['licenses'] = array();
520
+				if ( ! isset($subscriptions[$subscription_data['id']]['licenses'])) {
521
+					$subscriptions[$subscription_data['id']]['licenses'] = array();
522 522
 				}
523 523
 
524 524
 				// Store licenses for subscription.
525
-				if ( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) {
526
-					$subscriptions[ $subscription_data['id']]['licenses'][] = $this->license;
525
+				if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) {
526
+					$subscriptions[$subscription_data['id']]['licenses'][] = $this->license;
527 527
 				}
528 528
 
529
-				update_option( 'give_subscriptions', $subscriptions );
529
+				update_option('give_subscriptions', $subscriptions);
530 530
 			}
531 531
 		}
532 532
 
@@ -540,12 +540,12 @@  discard block
 block discarded – undo
540 540
 		 */
541 541
 		public function notices() {
542 542
 
543
-			if ( ! current_user_can( 'manage_give_settings' ) ) {
543
+			if ( ! current_user_can('manage_give_settings')) {
544 544
 				return;
545 545
 			}
546 546
 
547 547
 			// Do not show licenses notices on license tab.
548
-			if ( 'licenses' === give_get_current_setting_tab() ) {
548
+			if ('licenses' === give_get_current_setting_tab()) {
549 549
 				return;
550 550
 			}
551 551
 
@@ -554,112 +554,112 @@  discard block
 block discarded – undo
554 554
 			static $addon_license_key_in_subscriptions;
555 555
 
556 556
 			// Set default value.
557
-			$addon_license_key_in_subscriptions = ! empty( $addon_license_key_in_subscriptions ) ? $addon_license_key_in_subscriptions : array();
557
+			$addon_license_key_in_subscriptions = ! empty($addon_license_key_in_subscriptions) ? $addon_license_key_in_subscriptions : array();
558 558
 			$messages                           = array();
559 559
 
560 560
 			if (
561
-				empty( $this->license )
562
-				&& empty( $showed_invalid_message )
561
+				empty($this->license)
562
+				&& empty($showed_invalid_message)
563 563
 			) {
564 564
 
565
-				Give()->notices->register_notice( array(
565
+				Give()->notices->register_notice(array(
566 566
 					'id'               => 'give-invalid-license',
567 567
 					'type'             => 'error',
568 568
 					'description'      => sprintf(
569
-						__( 'You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ),
570
-						admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' )
569
+						__('You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give'),
570
+						admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')
571 571
 					),
572 572
 					'dismissible_type' => 'user',
573 573
 					'dismiss_interval' => 'shortly',
574
-				) );
574
+				));
575 575
 
576 576
 				$showed_invalid_message = true;
577 577
 
578 578
 			}
579 579
 
580 580
 			// Get subscriptions.
581
-			$subscriptions = get_option( 'give_subscriptions' );
581
+			$subscriptions = get_option('give_subscriptions');
582 582
 
583 583
 			// Show subscription messages.
584
-			if ( ! empty( $subscriptions ) && ! $showed_subscriptions_message ) {
584
+			if ( ! empty($subscriptions) && ! $showed_subscriptions_message) {
585 585
 
586
-				foreach ( $subscriptions as $subscription ) {
586
+				foreach ($subscriptions as $subscription) {
587 587
 					// Subscription expires timestamp.
588
-					$subscription_expires = strtotime( $subscription['expires'] );
588
+					$subscription_expires = strtotime($subscription['expires']);
589 589
 
590 590
 					// Start showing subscriptions message before one week of renewal date.
591
-					if ( strtotime( '- 7 days', $subscription_expires ) > current_time( 'timestamp', 1 ) ) {
591
+					if (strtotime('- 7 days', $subscription_expires) > current_time('timestamp', 1)) {
592 592
 						continue;
593 593
 					}
594 594
 
595 595
 					// Check if subscription message already exist in messages.
596
-					if ( array_key_exists( $subscription['id'], $messages ) ) {
596
+					if (array_key_exists($subscription['id'], $messages)) {
597 597
 						continue;
598 598
 					}
599 599
 
600 600
 					// Check if license already expired.
601
-					if ( strtotime( $subscription['expires'] ) < current_time( 'timestamp', 1 ) ) {
602
-						Give()->notices->register_notice( array(
601
+					if (strtotime($subscription['expires']) < current_time('timestamp', 1)) {
602
+						Give()->notices->register_notice(array(
603 603
 							'id'               => "give-expired-subscription-{$subscription['id']}",
604 604
 							'type'             => 'error',
605 605
 							'description'      => sprintf(
606
-								__( 'Your Give add-on license expired for payment <a href="%1$s" target="_blank">#%2$d</a>. <a href="%3$s" target="_blank">Click to renew an existing license</a> or %4$s.', 'give' ),
607
-								urldecode( $subscription['invoice_url'] ),
606
+								__('Your Give add-on license expired for payment <a href="%1$s" target="_blank">#%2$d</a>. <a href="%3$s" target="_blank">Click to renew an existing license</a> or %4$s.', 'give'),
607
+								urldecode($subscription['invoice_url']),
608 608
 								$subscription['payment_id'],
609 609
 								"{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired",
610 610
 								Give()->notices->get_dismiss_link(array(
611
-									'title' => __( 'Click here if already renewed', 'give' ),
611
+									'title' => __('Click here if already renewed', 'give'),
612 612
 									'dismissible_type'      => 'user',
613 613
 									'dismiss_interval'      => 'permanent',
614 614
 								))
615 615
 							),
616 616
 							'dismissible_type' => 'user',
617 617
 							'dismiss_interval' => 'shortly',
618
-						) );
618
+						));
619 619
 					} else {
620
-						Give()->notices->register_notice( array(
620
+						Give()->notices->register_notice(array(
621 621
 							'id'               => "give-expires-subscription-{$subscription['id']}",
622 622
 							'type'             => 'error',
623 623
 							'description'      => sprintf(
624
-								__( 'Your Give add-on license will expire in %1$s for payment <a href="%2$s" target="_blank">#%3$d</a>. <a href="%4$s" target="_blank">Click to renew an existing license</a> or %5$s.', 'give' ),
625
-								human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscription['expires'] ) ),
626
-								urldecode( $subscription['invoice_url'] ),
624
+								__('Your Give add-on license will expire in %1$s for payment <a href="%2$s" target="_blank">#%3$d</a>. <a href="%4$s" target="_blank">Click to renew an existing license</a> or %5$s.', 'give'),
625
+								human_time_diff(current_time('timestamp', 1), strtotime($subscription['expires'])),
626
+								urldecode($subscription['invoice_url']),
627 627
 								$subscription['payment_id'],
628 628
 								"{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired",
629 629
 								Give()->notices->get_dismiss_link(array(
630
-									'title' => __( 'Click here if already renewed', 'give' ),
630
+									'title' => __('Click here if already renewed', 'give'),
631 631
 									'dismissible_type'      => 'user',
632 632
 									'dismiss_interval'      => 'permanent',
633 633
 								))
634 634
 							),
635 635
 							'dismissible_type' => 'user',
636 636
 							'dismiss_interval' => 'shortly',
637
-						) );
637
+						));
638 638
 					}
639 639
 
640 640
 					// Stop validation for these license keys.
641
-					$addon_license_key_in_subscriptions = array_merge( $addon_license_key_in_subscriptions, $subscription['licenses'] );
641
+					$addon_license_key_in_subscriptions = array_merge($addon_license_key_in_subscriptions, $subscription['licenses']);
642 642
 				}// End foreach().
643 643
 				$showed_subscriptions_message = true;
644 644
 			}// End if().
645 645
 
646 646
 			// Show non subscription addon messages.
647 647
 			if (
648
-				! in_array( $this->license, $addon_license_key_in_subscriptions )
648
+				! in_array($this->license, $addon_license_key_in_subscriptions)
649 649
 				&& ! $this->is_valid_license()
650
-				&& empty( $showed_invalid_message )
650
+				&& empty($showed_invalid_message)
651 651
 			) {
652 652
 
653
-				Give()->notices->register_notice( array(
653
+				Give()->notices->register_notice(array(
654 654
 					'id'               => 'give-invalid-license',
655 655
 					'type'             => 'error',
656 656
 					'description'      => sprintf(
657
-						__( 'You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ),
658
-						admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' )
657
+						__('You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give'),
658
+						admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')
659 659
 					),
660 660
 					'dismissible_type' => 'user',
661 661
 					'dismiss_interval' => 'shortly',
662
-				) );
662
+				));
663 663
 
664 664
 				$showed_invalid_message = true;
665 665
 
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
 		 * @return bool
676 676
 		 */
677 677
 		public function is_valid_license() {
678
-			if ( apply_filters( 'give_is_valid_license', ( is_object( $this->license_data ) && ! empty( $this->license_data ) && property_exists( $this->license_data, 'license' ) && 'valid' === $this->license_data->license ) ) ) {
678
+			if (apply_filters('give_is_valid_license', (is_object($this->license_data) && ! empty($this->license_data) && property_exists($this->license_data, 'license') && 'valid' === $this->license_data->license))) {
679 679
 				return true;
680 680
 			}
681 681
 
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
 		 * @return bool
692 692
 		 */
693 693
 		private function __is_third_party_addon() {
694
-			return ( false === strpos( $this->api_url, 'givewp.com/' ) );
694
+			return (false === strpos($this->api_url, 'givewp.com/'));
695 695
 		}
696 696
 
697 697
 		/**
@@ -706,25 +706,25 @@  discard block
 block discarded – undo
706 706
 		 * @return bool
707 707
 		 */
708 708
 		private function __remove_license_key_from_subscriptions() {
709
-			$subscriptions = get_option( 'give_subscriptions', array() );
709
+			$subscriptions = get_option('give_subscriptions', array());
710 710
 
711 711
 			// Bailout.
712
-			if ( empty( $this->license ) ) {
712
+			if (empty($this->license)) {
713 713
 				return false;
714 714
 			}
715 715
 
716
-			if ( ! empty( $subscriptions ) ) {
717
-				foreach ( $subscriptions as $subscription_id => $subscription ) {
718
-					$license_index = array_search( $this->license, $subscription['licenses'] );
719
-					if ( false !== $license_index ) {
716
+			if ( ! empty($subscriptions)) {
717
+				foreach ($subscriptions as $subscription_id => $subscription) {
718
+					$license_index = array_search($this->license, $subscription['licenses']);
719
+					if (false !== $license_index) {
720 720
 						// Remove license key.
721
-						unset( $subscriptions[ $subscription_id ]['licenses'][ $license_index ] );
721
+						unset($subscriptions[$subscription_id]['licenses'][$license_index]);
722 722
 
723 723
 						// Rearrange license keys.
724
-						$subscriptions[ $subscription_id ]['licenses'] = array_values( $subscriptions[ $subscription_id ]['licenses'] );
724
+						$subscriptions[$subscription_id]['licenses'] = array_values($subscriptions[$subscription_id]['licenses']);
725 725
 
726 726
 						// Update subscription information.
727
-						update_option( 'give_subscriptions', $subscriptions );
727
+						update_option('give_subscriptions', $subscriptions);
728 728
 						break;
729 729
 					}
730 730
 				}
@@ -738,17 +738,17 @@  discard block
 block discarded – undo
738 738
 		 *
739 739
 		 * @return bool
740 740
 		 */
741
-		public function plugin_page_notices( $plugin_file, $plugin_data, $status ) {
741
+		public function plugin_page_notices($plugin_file, $plugin_data, $status) {
742 742
 			// Bailout.
743
-			if ( $this->is_valid_license() ) {
743
+			if ($this->is_valid_license()) {
744 744
 				return false;
745 745
 			}
746 746
 
747 747
 			$update_notice_wrap = '<tr class="give-addon-notice-tr active"><td colspan="3" class="colspanchange"><div class="notice inline notice-warning notice-alt give-invalid-license"><p><span class="dashicons dashicons-info"></span> %s</p></div></td></tr>';
748 748
 			$message            = $this->license_state_message();
749 749
 
750
-			if ( ! empty( $message['message'] ) ) {
751
-				echo sprintf( $update_notice_wrap, $message['message'] );
750
+			if ( ! empty($message['message'])) {
751
+				echo sprintf($update_notice_wrap, $message['message']);
752 752
 			}
753 753
 		}
754 754
 
@@ -763,11 +763,11 @@  discard block
 block discarded – undo
763 763
 		public function license_state_message() {
764 764
 			$message_data = array();
765 765
 
766
-			if ( ! $this->is_valid_license() ) {
766
+			if ( ! $this->is_valid_license()) {
767 767
 
768 768
 				$message_data['message'] = sprintf(
769 769
 					'Please <a href="%1$s">activate your license</a> to receive updates and support for the %2$s add-on.',
770
-					esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' ) ),
770
+					esc_url(admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')),
771 771
 					$this->item_name
772 772
 				);
773 773
 			}
@@ -782,18 +782,18 @@  discard block
 block discarded – undo
782 782
 		 * @since 1.8.9
783 783
 		 * @access private
784 784
 		 */
785
-		private function __is_user_can_edit_license(){
785
+		private function __is_user_can_edit_license() {
786 786
 			// Bailout.
787 787
 			if (
788
-				empty( $_POST[ $this->item_shortname . '_license_key' ] ) ||
789
-				! current_user_can( 'manage_give_settings' )
788
+				empty($_POST[$this->item_shortname.'_license_key']) ||
789
+				! current_user_can('manage_give_settings')
790 790
 			) {
791 791
 				return false;
792 792
 			}
793 793
 
794 794
 			// Security check.
795
-			if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) {
796
-				wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
795
+			if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) {
796
+				wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array('response' => 403));
797 797
 			}
798 798
 
799 799
 			return true;
@@ -811,8 +811,8 @@  discard block
 block discarded – undo
811 811
 		 *
812 812
 		 * @return mixed
813 813
 		 */
814
-		public function get_license_info( $edd_action = '', $response_in_array = false ) {
815
-			if( empty( $edd_action ) ) {
814
+		public function get_license_info($edd_action = '', $response_in_array = false) {
815
+			if (empty($edd_action)) {
816 816
 				return false;
817 817
 			}
818 818
 
@@ -820,7 +820,7 @@  discard block
 block discarded – undo
820 820
 			$api_params = array(
821 821
 				'edd_action' => $edd_action, // never change from "edd_" to "give_"!
822 822
 				'license'    => $this->license,
823
-				'item_name'  => urlencode( $this->item_name ),
823
+				'item_name'  => urlencode($this->item_name),
824 824
 				'url'        => home_url(),
825 825
 			);
826 826
 
@@ -835,11 +835,11 @@  discard block
 block discarded – undo
835 835
 			);
836 836
 
837 837
 			// Make sure there are no errors
838
-			if ( is_wp_error( $response ) ) {
838
+			if (is_wp_error($response)) {
839 839
 				return false;
840 840
 			}
841 841
 
842
-			return json_decode( wp_remote_retrieve_body( $response ), $response_in_array );
842
+			return json_decode(wp_remote_retrieve_body($response), $response_in_array);
843 843
 		}
844 844
 	}
845 845
 
Please login to merge, or discard this patch.
includes/class-notices.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -435,7 +435,7 @@
 block discarded – undo
435 435
 	 * @since  1.8.9
436 436
 	 * @access public
437 437
 	 *
438
-	 * @param $errors
438
+	 * @param string $errors
439 439
 	 */
440 440
 	static function print_frontend_errors( $errors ) {
441 441
 		if ( ! $errors ) {
Please login to merge, or discard this 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
 
@@ -53,12 +53,12 @@  discard block
 block discarded – undo
53 53
 	 * @since 1.0
54 54
 	 */
55 55
 	public function __construct() {
56
-		add_action( 'admin_notices', array( $this, 'render_admin_notices' ), 999 );
57
-		add_action( 'give_dismiss_notices', array( $this, 'dismiss_notices' ) );
56
+		add_action('admin_notices', array($this, 'render_admin_notices'), 999);
57
+		add_action('give_dismiss_notices', array($this, 'dismiss_notices'));
58 58
 
59
-		add_action( 'give_frontend_notices', array( $this, 'render_frontend_notices' ), 999 );
60
-		add_action( 'give_donation_form_before_personal_info', array( $this, 'render_frontend_notices' ) );
61
-		add_action( 'give_ajax_donation_errors', array( $this, 'render_frontend_notices' ) );
59
+		add_action('give_frontend_notices', array($this, 'render_frontend_notices'), 999);
60
+		add_action('give_donation_form_before_personal_info', array($this, 'render_frontend_notices'));
61
+		add_action('give_ajax_donation_errors', array($this, 'render_frontend_notices'));
62 62
 	}
63 63
 
64 64
 	/**
@@ -71,9 +71,9 @@  discard block
 block discarded – undo
71 71
 	 *
72 72
 	 * @return bool
73 73
 	 */
74
-	public function register_notice( $notice_args ) {
74
+	public function register_notice($notice_args) {
75 75
 		// Bailout.
76
-		if ( empty( $notice_args['id'] ) || array_key_exists( $notice_args['id'], self::$notices ) ) {
76
+		if (empty($notice_args['id']) || array_key_exists($notice_args['id'], self::$notices)) {
77 77
 			return false;
78 78
 		}
79 79
 
@@ -100,36 +100,36 @@  discard block
 block discarded – undo
100 100
 		);
101 101
 
102 102
 		// Set extra dismiss links if any.
103
-		if ( false !== strpos( $notice_args['description'], 'data-dismiss-interval' ) ) {
103
+		if (false !== strpos($notice_args['description'], 'data-dismiss-interval')) {
104 104
 
105
-			preg_match_all( "/data-([^\"]*)=\"([^\"]*)\"/", $notice_args['description'], $extra_notice_dismiss_link );
105
+			preg_match_all("/data-([^\"]*)=\"([^\"]*)\"/", $notice_args['description'], $extra_notice_dismiss_link);
106 106
 
107
-			if ( ! empty( $extra_notice_dismiss_link ) ) {
108
-				$extra_notice_dismiss_links = array_chunk( current( $extra_notice_dismiss_link ), 3 );
109
-				foreach ( $extra_notice_dismiss_links as $extra_notice_dismiss_link ) {
107
+			if ( ! empty($extra_notice_dismiss_link)) {
108
+				$extra_notice_dismiss_links = array_chunk(current($extra_notice_dismiss_link), 3);
109
+				foreach ($extra_notice_dismiss_links as $extra_notice_dismiss_link) {
110 110
 					// Create array og key ==> value by parsing query string created after renaming data attributes.
111
-					$data_attribute_query_str = str_replace( array( 'data-', '-', '"' ), array(
111
+					$data_attribute_query_str = str_replace(array('data-', '-', '"'), array(
112 112
 						'',
113 113
 						'_',
114 114
 						'',
115
-					), implode( '&', $extra_notice_dismiss_link ) );
115
+					), implode('&', $extra_notice_dismiss_link));
116 116
 
117
-					$notice_args['extra_links'][] = wp_parse_args( $data_attribute_query_str );
117
+					$notice_args['extra_links'][] = wp_parse_args($data_attribute_query_str);
118 118
 				}
119 119
 			}
120 120
 		}
121 121
 
122 122
 
123
-		self::$notices[ $notice_args['id'] ] = $notice_args;
123
+		self::$notices[$notice_args['id']] = $notice_args;
124 124
 
125 125
 		// Auto set show param if not already set.
126
-		if ( ! isset( self::$notices[ $notice_args['id'] ]['show'] ) ) {
127
-			self::$notices[ $notice_args['id'] ]['show'] = $this->is_notice_dismissed( $notice_args ) ? false : true;
126
+		if ( ! isset(self::$notices[$notice_args['id']]['show'])) {
127
+			self::$notices[$notice_args['id']]['show'] = $this->is_notice_dismissed($notice_args) ? false : true;
128 128
 		}
129 129
 
130 130
 		// Auto set time interval for shortly.
131
-		if ( 'shortly' === self::$notices[ $notice_args['id'] ]['dismiss_interval'] ) {
132
-			self::$notices[ $notice_args['id'] ]['dismiss_interval_time'] = DAY_IN_SECONDS;
131
+		if ('shortly' === self::$notices[$notice_args['id']]['dismiss_interval']) {
132
+			self::$notices[$notice_args['id']]['dismiss_interval_time'] = DAY_IN_SECONDS;
133 133
 		}
134 134
 
135 135
 		return true;
@@ -143,44 +143,44 @@  discard block
 block discarded – undo
143 143
 	 */
144 144
 	public function render_admin_notices() {
145 145
 		// Bailout.
146
-		if ( empty( self::$notices ) ) {
146
+		if (empty(self::$notices)) {
147 147
 			return;
148 148
 		}
149 149
 
150 150
 		$output = '';
151 151
 
152
-		foreach ( self::$notices as $notice_id => $notice ) {
152
+		foreach (self::$notices as $notice_id => $notice) {
153 153
 			// Check flag set to true to show notice.
154
-			if ( ! $notice['show'] ) {
154
+			if ( ! $notice['show']) {
155 155
 				continue;
156 156
 			}
157 157
 
158 158
 			// Check if notice dismissible or not.
159
-			if ( ! self::$has_auto_dismissible_notice ) {
159
+			if ( ! self::$has_auto_dismissible_notice) {
160 160
 				self::$has_auto_dismissible_notice = $notice['auto_dismissible'];
161 161
 			}
162 162
 
163 163
 			// Check if notice dismissible or not.
164
-			if ( ! self::$has_dismiss_interval_notice ) {
164
+			if ( ! self::$has_dismiss_interval_notice) {
165 165
 				self::$has_dismiss_interval_notice = $notice['dismiss_interval'];
166 166
 			}
167 167
 
168
-			$css_id = ( false === strpos( $notice['id'], 'give' ) ? "give-{$notice['id']}" : $notice['id'] );
168
+			$css_id = (false === strpos($notice['id'], 'give') ? "give-{$notice['id']}" : $notice['id']);
169 169
 
170 170
 			$css_class = "give-notice notice is-dismissible {$notice['type']} notice-{$notice['type']}";
171
-			$output    .= sprintf(
172
-				'<div id="%1$s" class="%2$s" data-auto-dismissible="%3$s" data-dismissible-type="%4$s" data-dismiss-interval="%5$s" data-notice-id="%6$s" data-security="%7$s" data-dismiss-interval-time="%8$s">' . " \n",
171
+			$output .= sprintf(
172
+				'<div id="%1$s" class="%2$s" data-auto-dismissible="%3$s" data-dismissible-type="%4$s" data-dismiss-interval="%5$s" data-notice-id="%6$s" data-security="%7$s" data-dismiss-interval-time="%8$s">'." \n",
173 173
 				$css_id,
174 174
 				$css_class,
175 175
 				$notice['auto_dismissible'],
176 176
 				$notice['dismissible_type'],
177 177
 				$notice['dismiss_interval'],
178 178
 				$notice['id'],
179
-				empty( $notice['dismissible_type'] ) ? '' : wp_create_nonce( "give_edit_{$notice_id}_notice" ),
179
+				empty($notice['dismissible_type']) ? '' : wp_create_nonce("give_edit_{$notice_id}_notice"),
180 180
 				$notice['dismiss_interval_time']
181 181
 			);
182 182
 
183
-			$output .= ( 0 === strpos( $notice['description'], '<div' ) || 0 === strpos( $notice['description'], '<p' ) ? $notice['description'] : "<p>{$notice['description']}</p>" );
183
+			$output .= (0 === strpos($notice['description'], '<div') || 0 === strpos($notice['description'], '<p') ? $notice['description'] : "<p>{$notice['description']}</p>");
184 184
 			$output .= "</div> \n";
185 185
 		}
186 186
 
@@ -198,18 +198,18 @@  discard block
 block discarded – undo
198 198
 	 *
199 199
 	 * @param int $form_id
200 200
 	 */
201
-	public function render_frontend_notices( $form_id = 0 ) {
201
+	public function render_frontend_notices($form_id = 0) {
202 202
 		$errors = give_get_errors();
203 203
 
204
-		$request_form_id = isset( $_REQUEST['form-id'] ) ? intval( $_REQUEST['form-id'] ) : 0;
204
+		$request_form_id = isset($_REQUEST['form-id']) ? intval($_REQUEST['form-id']) : 0;
205 205
 
206 206
 		// Sanity checks first: Ensure that gateway returned errors display on the appropriate form.
207
-		if ( ! isset( $_POST['give_ajax'] ) && $request_form_id !== $form_id ) {
207
+		if ( ! isset($_POST['give_ajax']) && $request_form_id !== $form_id) {
208 208
 			return;
209 209
 		}
210 210
 
211
-		if ( $errors ) {
212
-			self::print_frontend_errors( $errors );
211
+		if ($errors) {
212
+			self::print_frontend_errors($errors);
213 213
 
214 214
 			give_clear_errors();
215 215
 		}
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 	 * @access private
223 223
 	 */
224 224
 	private function print_js() {
225
-		if ( self::$has_auto_dismissible_notice ) :
225
+		if (self::$has_auto_dismissible_notice) :
226 226
 			?>
227 227
 			<script>
228 228
 				jQuery(document).ready(function () {
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 			<?php
239 239
 		endif;
240 240
 
241
-		if ( self::$has_dismiss_interval_notice ) :
241
+		if (self::$has_dismiss_interval_notice) :
242 242
 			?>
243 243
 			<script>
244 244
 				jQuery(document).ready(function () {
@@ -304,29 +304,29 @@  discard block
 block discarded – undo
304 304
 	 * @access public
305 305
 	 */
306 306
 	public function dismiss_notices() {
307
-		$_post     = give_clean( $_POST );
308
-		$notice_id = esc_attr( $_post['notice_id'] );
307
+		$_post     = give_clean($_POST);
308
+		$notice_id = esc_attr($_post['notice_id']);
309 309
 
310 310
 		// Bailout.
311 311
 		if (
312
-			empty( $notice_id ) ||
313
-			empty( $_post['dismissible_type'] ) ||
314
-			empty( $_post['dismiss_interval'] ) ||
315
-			! check_ajax_referer( "give_edit_{$notice_id}_notice", '_wpnonce' )
312
+			empty($notice_id) ||
313
+			empty($_post['dismissible_type']) ||
314
+			empty($_post['dismiss_interval']) ||
315
+			! check_ajax_referer("give_edit_{$notice_id}_notice", '_wpnonce')
316 316
 		) {
317 317
 			wp_send_json_error();
318 318
 		}
319 319
 
320
-		$notice_key = Give()->notices->get_notice_key( $notice_id, $_post['dismiss_interval'] );
321
-		if ( 'user' === $_post['dismissible_type'] ) {
320
+		$notice_key = Give()->notices->get_notice_key($notice_id, $_post['dismiss_interval']);
321
+		if ('user' === $_post['dismissible_type']) {
322 322
 			$current_user = wp_get_current_user();
323
-			$notice_key   = Give()->notices->get_notice_key( $notice_id, $_post['dismiss_interval'], $current_user->ID );
323
+			$notice_key   = Give()->notices->get_notice_key($notice_id, $_post['dismiss_interval'], $current_user->ID);
324 324
 		}
325 325
 
326
-		$notice_dismiss_time = ! empty( $_post['dismiss_interval_time'] ) ? $_post['dismiss_interval_time'] : null;
326
+		$notice_dismiss_time = ! empty($_post['dismiss_interval_time']) ? $_post['dismiss_interval_time'] : null;
327 327
 
328 328
 		// Save option to hide notice.
329
-		Give_Cache::set( $notice_key, true, $notice_dismiss_time, true );
329
+		Give_Cache::set($notice_key, true, $notice_dismiss_time, true);
330 330
 
331 331
 		wp_send_json_success();
332 332
 	}
@@ -344,18 +344,18 @@  discard block
 block discarded – undo
344 344
 	 *
345 345
 	 * @return string
346 346
 	 */
347
-	public function get_notice_key( $notice_id, $dismiss_interval = null, $user_id = 0 ) {
347
+	public function get_notice_key($notice_id, $dismiss_interval = null, $user_id = 0) {
348 348
 		$notice_key = "_give_notice_{$notice_id}";
349 349
 
350
-		if ( ! empty( $dismiss_interval ) ) {
350
+		if ( ! empty($dismiss_interval)) {
351 351
 			$notice_key .= "_{$dismiss_interval}";
352 352
 		}
353 353
 
354
-		if ( $user_id ) {
354
+		if ($user_id) {
355 355
 			$notice_key .= "_{$user_id}";
356 356
 		}
357 357
 
358
-		$notice_key = sanitize_key( $notice_key );
358
+		$notice_key = sanitize_key($notice_key);
359 359
 
360 360
 		return $notice_key;
361 361
 	}
@@ -368,11 +368,11 @@  discard block
 block discarded – undo
368 368
 	 *
369 369
 	 * @return string
370 370
 	 */
371
-	public function get_dismiss_link( $notice_args ) {
371
+	public function get_dismiss_link($notice_args) {
372 372
 		$notice_args = wp_parse_args(
373 373
 			$notice_args,
374 374
 			array(
375
-				'title'                 => __( 'Click here', 'give' ),
375
+				'title'                 => __('Click here', 'give'),
376 376
 				'dismissible_type'      => '',
377 377
 				'dismiss_interval'      => '',
378 378
 				'dismiss_interval_time' => null,
@@ -399,31 +399,31 @@  discard block
 block discarded – undo
399 399
 	 *
400 400
 	 * @return bool|null
401 401
 	 */
402
-	public function is_notice_dismissed( $notice ) {
403
-		$notice_key          = $this->get_notice_key( $notice['id'], $notice['dismiss_interval'] );
402
+	public function is_notice_dismissed($notice) {
403
+		$notice_key          = $this->get_notice_key($notice['id'], $notice['dismiss_interval']);
404 404
 		$is_notice_dismissed = false;
405 405
 
406
-		if ( 'user' === $notice['dismissible_type'] ) {
406
+		if ('user' === $notice['dismissible_type']) {
407 407
 			$current_user = wp_get_current_user();
408
-			$notice_key   = Give()->notices->get_notice_key( $notice['id'], $notice['dismiss_interval'], $current_user->ID );
408
+			$notice_key   = Give()->notices->get_notice_key($notice['id'], $notice['dismiss_interval'], $current_user->ID);
409 409
 		}
410 410
 
411
-		$notice_data = Give_Cache::get( $notice_key, true );
411
+		$notice_data = Give_Cache::get($notice_key, true);
412 412
 
413 413
 		// Find notice dismiss link status if notice has extra dismissible links.
414
-		if ( ( empty( $notice_data ) || is_wp_error( $notice_data ) ) && ! empty( $notice['extra_links'] ) ) {
414
+		if ((empty($notice_data) || is_wp_error($notice_data)) && ! empty($notice['extra_links'])) {
415 415
 
416
-			foreach ( $notice['extra_links'] as $extra_link ) {
417
-				$new_notice_data = wp_parse_args( $extra_link, $notice );
418
-				unset( $new_notice_data['extra_links'] );
416
+			foreach ($notice['extra_links'] as $extra_link) {
417
+				$new_notice_data = wp_parse_args($extra_link, $notice);
418
+				unset($new_notice_data['extra_links']);
419 419
 
420
-				if ( $is_notice_dismissed = $this->is_notice_dismissed( $new_notice_data ) ) {
420
+				if ($is_notice_dismissed = $this->is_notice_dismissed($new_notice_data)) {
421 421
 					return $is_notice_dismissed;
422 422
 				}
423 423
 			}
424 424
 		}
425 425
 
426
-		$is_notice_dismissed = ! empty( $notice_data ) && ! is_wp_error( $notice_data );
426
+		$is_notice_dismissed = ! empty($notice_data) && ! is_wp_error($notice_data);
427 427
 
428 428
 		return $is_notice_dismissed;
429 429
 	}
@@ -437,21 +437,21 @@  discard block
 block discarded – undo
437 437
 	 *
438 438
 	 * @param $errors
439 439
 	 */
440
-	static function print_frontend_errors( $errors ) {
441
-		if ( ! $errors ) {
440
+	static function print_frontend_errors($errors) {
441
+		if ( ! $errors) {
442 442
 			return;
443 443
 		}
444 444
 
445 445
 		// Note: we will remove give_errors class in future.
446
-		$classes = apply_filters( 'give_error_class', array( 'give_notices', 'give_errors' ) );
446
+		$classes = apply_filters('give_error_class', array('give_notices', 'give_errors'));
447 447
 
448
-		echo sprintf( '<div class="%s">', implode( ' ', $classes ) );
448
+		echo sprintf('<div class="%s">', implode(' ', $classes));
449 449
 
450 450
 		// Loop error codes and display errors.
451
-		foreach ( $errors as $error_id => $error ) {
452
-			echo sprintf( '<div class="give_error" id="give_error_%1$s"><p><strong>%2$s</strong>: %3$s</p></div>',
451
+		foreach ($errors as $error_id => $error) {
452
+			echo sprintf('<div class="give_error" id="give_error_%1$s"><p><strong>%2$s</strong>: %3$s</p></div>',
453 453
 				$error_id,
454
-				esc_html__( 'Error', 'give' ),
454
+				esc_html__('Error', 'give'),
455 455
 				$error
456 456
 			);
457 457
 		}
@@ -472,8 +472,8 @@  discard block
 block discarded – undo
472 472
 	 *
473 473
 	 * @return  string
474 474
 	 */
475
-	static function print_frontend_notice( $message, $echo = true, $notice_type = 'warning' ) {
476
-		if ( empty( $message ) ) {
475
+	static function print_frontend_notice($message, $echo = true, $notice_type = 'warning') {
476
+		if (empty($message)) {
477 477
 			return '';
478 478
 		}
479 479
 
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 			$message
485 485
 		);
486 486
 
487
-		if ( ! $echo ) {
487
+		if ( ! $echo) {
488 488
 			return $error;
489 489
 		}
490 490
 
Please login to merge, or discard this patch.
includes/login-register.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
  * @param string $user_login Username
175 175
  * @param string $user_pass  Password
176 176
  *
177
- * @return bool
177
+ * @return false|null
178 178
  */
179 179
 function give_log_user_in( $user_id, $user_login, $user_pass ) {
180 180
 
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
  *
216 216
  * @param array $data Data sent from the register form
217 217
  *
218
- * @return bool
218
+ * @return false|null
219 219
  */
220 220
 function give_process_register_form( $data ) {
221 221
 
Please login to merge, or discard this patch.
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -26,23 +26,23 @@  discard block
 block discarded – undo
26 26
  *
27 27
  * @return string Login form
28 28
  */
29
-function give_login_form( $login_redirect = '', $logout_redirect = '' ) {
30
-	if ( empty( $login_redirect ) ) {
31
-		$login_redirect = add_query_arg( 'give-login-success', 'true', give_get_current_page_url() );
29
+function give_login_form($login_redirect = '', $logout_redirect = '') {
30
+	if (empty($login_redirect)) {
31
+		$login_redirect = add_query_arg('give-login-success', 'true', give_get_current_page_url());
32 32
 	}
33 33
 
34
-	if ( empty( $logout_redirect ) ) {
35
-		$logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() );
34
+	if (empty($logout_redirect)) {
35
+		$logout_redirect = add_query_arg('give-logout-success', 'true', give_get_current_page_url());
36 36
 	}
37 37
 
38 38
 	// Add user_logout action to logout url.
39 39
 	$logout_redirect = add_query_arg(
40 40
 		array(
41 41
 			'give_action'          => 'user_logout',
42
-			'give_logout_nonce'    => wp_create_nonce( 'give-logout-nonce' ),
43
-			'give_logout_redirect' => urlencode( $logout_redirect ),
42
+			'give_logout_nonce'    => wp_create_nonce('give-logout-nonce'),
43
+			'give_logout_redirect' => urlencode($logout_redirect),
44 44
 		),
45
-		home_url( '/' )
45
+		home_url('/')
46 46
 	);
47 47
 
48 48
 	ob_start();
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 		)
56 56
 	);
57 57
 
58
-	return apply_filters( 'give_login_form', ob_get_clean() );
58
+	return apply_filters('give_login_form', ob_get_clean());
59 59
 }
60 60
 
61 61
 /**
@@ -68,14 +68,14 @@  discard block
 block discarded – undo
68 68
  *
69 69
  * @return string Register form
70 70
  */
71
-function give_register_form( $redirect = '' ) {
72
-	if ( empty( $redirect ) ) {
71
+function give_register_form($redirect = '') {
72
+	if (empty($redirect)) {
73 73
 		$redirect = give_get_current_page_url();
74 74
 	}
75 75
 
76 76
 	ob_start();
77 77
 
78
-	if ( ! is_user_logged_in() ) {
78
+	if ( ! is_user_logged_in()) {
79 79
 		give_get_template(
80 80
 			'shortcode-register',
81 81
 			array(
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 		);
85 85
 	}
86 86
 
87
-	return apply_filters( 'give_register_form', ob_get_clean() );
87
+	return apply_filters('give_register_form', ob_get_clean());
88 88
 }
89 89
 
90 90
 /**
@@ -96,34 +96,34 @@  discard block
 block discarded – undo
96 96
  *
97 97
  * @return void
98 98
  */
99
-function give_process_login_form( $data ) {
100
-	if ( wp_verify_nonce( $data['give_login_nonce'], 'give-login-nonce' ) ) {
101
-		$user_data = get_user_by( 'login', $data['give_user_login'] );
102
-		if ( ! $user_data ) {
103
-			$user_data = get_user_by( 'email', $data['give_user_login'] );
99
+function give_process_login_form($data) {
100
+	if (wp_verify_nonce($data['give_login_nonce'], 'give-login-nonce')) {
101
+		$user_data = get_user_by('login', $data['give_user_login']);
102
+		if ( ! $user_data) {
103
+			$user_data = get_user_by('email', $data['give_user_login']);
104 104
 		}
105
-		if ( $user_data ) {
105
+		if ($user_data) {
106 106
 			$user_ID    = $user_data->ID;
107 107
 			$user_email = $user_data->user_email;
108
-			if ( wp_check_password( $data['give_user_pass'], $user_data->user_pass, $user_ID ) ) {
109
-				give_log_user_in( $user_data->ID, $data['give_user_login'], $data['give_user_pass'] );
108
+			if (wp_check_password($data['give_user_pass'], $user_data->user_pass, $user_ID)) {
109
+				give_log_user_in($user_data->ID, $data['give_user_login'], $data['give_user_pass']);
110 110
 			} else {
111
-				give_set_error( 'password_incorrect', __( 'The password you entered is incorrect.', 'give' ) );
111
+				give_set_error('password_incorrect', __('The password you entered is incorrect.', 'give'));
112 112
 			}
113 113
 		} else {
114
-			give_set_error( 'username_incorrect', __( 'The username you entered does not exist.', 'give' ) );
114
+			give_set_error('username_incorrect', __('The username you entered does not exist.', 'give'));
115 115
 		}
116 116
 		// Check for errors and redirect if none present
117 117
 		$errors = give_get_errors();
118
-		if ( ! $errors ) {
119
-			$redirect = apply_filters( 'give_login_redirect', $data['give_login_redirect'], $user_ID );
120
-			wp_redirect( $redirect );
118
+		if ( ! $errors) {
119
+			$redirect = apply_filters('give_login_redirect', $data['give_login_redirect'], $user_ID);
120
+			wp_redirect($redirect);
121 121
 			give_die();
122 122
 		}
123 123
 	}
124 124
 }
125 125
 
126
-add_action( 'give_user_login', 'give_process_login_form' );
126
+add_action('give_user_login', 'give_process_login_form');
127 127
 
128 128
 
129 129
 /**
@@ -135,18 +135,18 @@  discard block
 block discarded – undo
135 135
  *
136 136
  * @return void
137 137
  */
138
-function give_process_user_logout( $data ) {
139
-	if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) {
138
+function give_process_user_logout($data) {
139
+	if (wp_verify_nonce($data['give_logout_nonce'], 'give-logout-nonce') && is_user_logged_in()) {
140 140
 
141 141
 		// Prevent occurring of any custom action on wp_logout.
142
-		remove_all_actions( 'wp_logout' );
142
+		remove_all_actions('wp_logout');
143 143
 
144 144
 		/**
145 145
 		 * Fires before processing user logout.
146 146
 		 *
147 147
 		 * @since 1.0
148 148
 		 */
149
-		do_action( 'give_before_user_logout' );
149
+		do_action('give_before_user_logout');
150 150
 
151 151
 		// Logout user.
152 152
 		wp_logout();
@@ -156,14 +156,14 @@  discard block
 block discarded – undo
156 156
 		 *
157 157
 		 * @since 1.0
158 158
 		 */
159
-		do_action( 'give_after_user_logout' );
159
+		do_action('give_after_user_logout');
160 160
 
161
-		wp_redirect( $data['give_logout_redirect'] );
161
+		wp_redirect($data['give_logout_redirect']);
162 162
 		give_die();
163 163
 	}
164 164
 }
165 165
 
166
-add_action( 'give_user_logout', 'give_process_user_logout' );
166
+add_action('give_user_logout', 'give_process_user_logout');
167 167
 
168 168
 /**
169 169
  * Log User In
@@ -176,14 +176,14 @@  discard block
 block discarded – undo
176 176
  *
177 177
  * @return bool
178 178
  */
179
-function give_log_user_in( $user_id, $user_login, $user_pass ) {
179
+function give_log_user_in($user_id, $user_login, $user_pass) {
180 180
 
181
-	if ( $user_id < 1 ) {
181
+	if ($user_id < 1) {
182 182
 		return false;
183 183
 	}
184 184
 
185
-	wp_set_auth_cookie( $user_id );
186
-	wp_set_current_user( $user_id, $user_login );
185
+	wp_set_auth_cookie($user_id);
186
+	wp_set_current_user($user_id, $user_login);
187 187
 
188 188
 	/**
189 189
 	 * Fires after the user has successfully logged in.
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	 * @param string  $user_login Username.
194 194
 	 * @param WP_User $$user      WP_User object of the logged-in user.
195 195
 	 */
196
-	do_action( 'wp_login', $user_login, get_userdata( $user_id ) );
196
+	do_action('wp_login', $user_login, get_userdata($user_id));
197 197
 
198 198
 	/**
199 199
 	 * Fires after give user has successfully logged in.
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 	 * @param string $user_login Username.
205 205
 	 * @param string $user_pass  User password.
206 206
 	 */
207
-	do_action( 'give_log_user_in', $user_id, $user_login, $user_pass );
207
+	do_action('give_log_user_in', $user_id, $user_login, $user_pass);
208 208
 }
209 209
 
210 210
 
@@ -217,13 +217,13 @@  discard block
 block discarded – undo
217 217
  *
218 218
  * @return bool
219 219
  */
220
-function give_process_register_form( $data ) {
220
+function give_process_register_form($data) {
221 221
 
222
-	if ( is_user_logged_in() ) {
222
+	if (is_user_logged_in()) {
223 223
 		return false;
224 224
 	}
225 225
 
226
-	if ( empty( $_POST['give_register_submit'] ) ) {
226
+	if (empty($_POST['give_register_submit'])) {
227 227
 		return false;
228 228
 	}
229 229
 
@@ -232,38 +232,38 @@  discard block
 block discarded – undo
232 232
 	 *
233 233
 	 * @since 1.0
234 234
 	 */
235
-	do_action( 'give_pre_process_register_form' );
235
+	do_action('give_pre_process_register_form');
236 236
 
237
-	if ( empty( $data['give_user_login'] ) ) {
238
-		give_set_error( 'empty_username', esc_html__( 'Invalid username.', 'give' ) );
237
+	if (empty($data['give_user_login'])) {
238
+		give_set_error('empty_username', esc_html__('Invalid username.', 'give'));
239 239
 	}
240 240
 
241
-	if ( username_exists( $data['give_user_login'] ) ) {
242
-		give_set_error( 'username_unavailable', esc_html__( 'Username already taken.', 'give' ) );
241
+	if (username_exists($data['give_user_login'])) {
242
+		give_set_error('username_unavailable', esc_html__('Username already taken.', 'give'));
243 243
 	}
244 244
 
245
-	if ( ! validate_username( $data['give_user_login'] ) ) {
246
-		give_set_error( 'username_invalid', esc_html__( 'Invalid username.', 'give' ) );
245
+	if ( ! validate_username($data['give_user_login'])) {
246
+		give_set_error('username_invalid', esc_html__('Invalid username.', 'give'));
247 247
 	}
248 248
 
249
-	if ( email_exists( $data['give_user_email'] ) ) {
250
-		give_set_error( 'email_unavailable', esc_html__( 'Email address already taken.', 'give' ) );
249
+	if (email_exists($data['give_user_email'])) {
250
+		give_set_error('email_unavailable', esc_html__('Email address already taken.', 'give'));
251 251
 	}
252 252
 
253
-	if ( empty( $data['give_user_email'] ) || ! is_email( $data['give_user_email'] ) ) {
254
-		give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
253
+	if (empty($data['give_user_email']) || ! is_email($data['give_user_email'])) {
254
+		give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
255 255
 	}
256 256
 
257
-	if ( ! empty( $data['give_payment_email'] ) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email( $data['give_payment_email'] ) ) {
258
-		give_set_error( 'payment_email_invalid', esc_html__( 'Invalid payment email.', 'give' ) );
257
+	if ( ! empty($data['give_payment_email']) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email($data['give_payment_email'])) {
258
+		give_set_error('payment_email_invalid', esc_html__('Invalid payment email.', 'give'));
259 259
 	}
260 260
 
261
-	if ( empty( $_POST['give_user_pass'] ) ) {
262
-		give_set_error( 'empty_password', esc_html__( 'Please enter a password.', 'give' ) );
261
+	if (empty($_POST['give_user_pass'])) {
262
+		give_set_error('empty_password', esc_html__('Please enter a password.', 'give'));
263 263
 	}
264 264
 
265
-	if ( ( ! empty( $_POST['give_user_pass'] ) && empty( $_POST['give_user_pass2'] ) ) || ( $_POST['give_user_pass'] !== $_POST['give_user_pass2'] ) ) {
266
-		give_set_error( 'password_mismatch', esc_html__( 'Passwords don\'t match.', 'give' ) );
265
+	if (( ! empty($_POST['give_user_pass']) && empty($_POST['give_user_pass2'])) || ($_POST['give_user_pass'] !== $_POST['give_user_pass2'])) {
266
+		give_set_error('password_mismatch', esc_html__('Passwords don\'t match.', 'give'));
267 267
 	}
268 268
 
269 269
 	/**
@@ -271,26 +271,26 @@  discard block
 block discarded – undo
271 271
 	 *
272 272
 	 * @since 1.0
273 273
 	 */
274
-	do_action( 'give_process_register_form' );
274
+	do_action('give_process_register_form');
275 275
 
276 276
 	// Check for errors and redirect if none present
277 277
 	$errors = give_get_errors();
278 278
 
279
-	if ( empty( $errors ) ) {
279
+	if (empty($errors)) {
280 280
 
281
-		$redirect = apply_filters( 'give_register_redirect', $data['give_redirect'] );
281
+		$redirect = apply_filters('give_register_redirect', $data['give_redirect']);
282 282
 
283
-		give_register_and_login_new_user( array(
283
+		give_register_and_login_new_user(array(
284 284
 			'user_login'      => $data['give_user_login'],
285 285
 			'user_pass'       => $data['give_user_pass'],
286 286
 			'user_email'      => $data['give_user_email'],
287
-			'user_registered' => date( 'Y-m-d H:i:s' ),
288
-			'role'            => get_option( 'default_role' ),
289
-		) );
287
+			'user_registered' => date('Y-m-d H:i:s'),
288
+			'role'            => get_option('default_role'),
289
+		));
290 290
 
291
-		wp_redirect( $redirect );
291
+		wp_redirect($redirect);
292 292
 		give_die();
293 293
 	}
294 294
 }
295 295
 
296
-add_action( 'give_user_register', 'give_process_register_form' );
296
+add_action('give_user_register', 'give_process_register_form');
Please login to merge, or discard this patch.
includes/payments/class-payment-stats.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	 * @param  $end_date   string|bool  The end date for which we'd like to filter our sale stats. If false, we'll use the default end date of `this_month`
37 37
 	 * @param  $status     string|array The sale status(es) to count. Only valid when retrieving global stats
38 38
 	 *
39
-	 * @return float|int                Total amount of donations based on the passed arguments.
39
+	 * @return string                Total amount of donations based on the passed arguments.
40 40
 	 */
41 41
 	public function get_sales( $form_id = 0, $start_date = false, $end_date = false, $status = 'publish' ) {
42 42
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 * @param  $end_date    string|bool The end date for which we'd like to filter the donations stats. If false, method will use the default end date of `this_month`.
84 84
 	 * @param  $gateway_id  string|bool The gateway to get earnings for such as 'paypal' or 'stripe'.
85 85
 	 *
86
-	 * @return float|int                Total amount of donations based on the passed arguments.
86
+	 * @return string                Total amount of donations based on the passed arguments.
87 87
 	 */
88 88
 	public function get_earnings( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) {
89 89
 		$this->setup_dates( $start_date, $end_date );
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 	 * @param  $end_date    string|bool The end date for which we'd like to filter our sale stats. If false, we'll use the default end date of `this_month`
169 169
 	 * @param  $gateway_id  string|bool The gateway to get earnings for such as 'paypal' or 'stripe'
170 170
 	 *
171
-	 * @return float|int                Total amount of donations based on the passed arguments.
171
+	 * @return string                Total amount of donations based on the passed arguments.
172 172
 	 */
173 173
 	public function get_earnings_cache_key( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) {
174 174
 
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 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
 
@@ -38,17 +38,17 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @return float|int                Total amount of donations based on the passed arguments.
40 40
 	 */
41
-	public function get_sales( $form_id = 0, $start_date = false, $end_date = false, $status = 'publish' ) {
41
+	public function get_sales($form_id = 0, $start_date = false, $end_date = false, $status = 'publish') {
42 42
 
43
-		$this->setup_dates( $start_date, $end_date );
43
+		$this->setup_dates($start_date, $end_date);
44 44
 
45 45
 		// Make sure start date is valid
46
-		if ( is_wp_error( $this->start_date ) ) {
46
+		if (is_wp_error($this->start_date)) {
47 47
 			return $this->start_date;
48 48
 		}
49 49
 
50 50
 		// Make sure end date is valid
51
-		if ( is_wp_error( $this->end_date ) ) {
51
+		if (is_wp_error($this->end_date)) {
52 52
 			return $this->end_date;
53 53
 		}
54 54
 
@@ -57,18 +57,18 @@  discard block
 block discarded – undo
57 57
 			'start_date' => $this->start_date,
58 58
 			'end_date'   => $this->end_date,
59 59
 			'fields'     => 'ids',
60
-			'number'     => - 1,
60
+			'number'     => -1,
61 61
 		);
62 62
 
63
-		if ( ! empty( $form_id ) ) {
63
+		if ( ! empty($form_id)) {
64 64
 			$args['give_forms'] = $form_id;
65 65
 		}
66 66
 
67 67
 		/* @var Give_Payments_Query $payments */
68
-		$payments = new Give_Payments_Query( $args );
68
+		$payments = new Give_Payments_Query($args);
69 69
 		$payments = $payments->get_payments();
70 70
 
71
-		return count( $payments );
71
+		return count($payments);
72 72
 	}
73 73
 
74 74
 
@@ -85,16 +85,16 @@  discard block
 block discarded – undo
85 85
 	 *
86 86
 	 * @return float|int                Total amount of donations based on the passed arguments.
87 87
 	 */
88
-	public function get_earnings( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) {
89
-		$this->setup_dates( $start_date, $end_date );
88
+	public function get_earnings($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) {
89
+		$this->setup_dates($start_date, $end_date);
90 90
 
91 91
 		// Make sure start date is valid
92
-		if ( is_wp_error( $this->start_date ) ) {
92
+		if (is_wp_error($this->start_date)) {
93 93
 			return $this->start_date;
94 94
 		}
95 95
 
96 96
 		// Make sure end date is valid
97
-		if ( is_wp_error( $this->end_date ) ) {
97
+		if (is_wp_error($this->end_date)) {
98 98
 			return $this->end_date;
99 99
 		}
100 100
 
@@ -104,12 +104,12 @@  discard block
 block discarded – undo
104 104
 			'start_date' => $this->start_date,
105 105
 			'end_date'   => $this->end_date,
106 106
 			'fields'     => 'ids',
107
-			'number'     => - 1,
107
+			'number'     => -1,
108 108
 		);
109 109
 
110 110
 
111 111
 		// Filter by Gateway ID meta_key
112
-		if ( $gateway_id ) {
112
+		if ($gateway_id) {
113 113
 			$args['meta_query'][] = array(
114 114
 				'key'   => '_give_payment_gateway',
115 115
 				'value' => $gateway_id,
@@ -117,43 +117,43 @@  discard block
 block discarded – undo
117 117
 		}
118 118
 
119 119
 		// Filter by Gateway ID meta_key
120
-		if ( $form_id ) {
120
+		if ($form_id) {
121 121
 			$args['meta_query'][] = array(
122 122
 				'key'   => '_give_payment_form_id',
123 123
 				'value' => $form_id,
124 124
 			);
125 125
 		}
126 126
 
127
-		if ( ! empty( $args['meta_query'] ) && 1 < count( $args['meta_query'] ) ) {
127
+		if ( ! empty($args['meta_query']) && 1 < count($args['meta_query'])) {
128 128
 			$args['meta_query']['relation'] = 'AND';
129 129
 		}
130 130
 
131
-		$args = apply_filters( 'give_stats_earnings_args', $args );
132
-		$key  = Give_Cache::get_key( 'give_stats', $args );
131
+		$args = apply_filters('give_stats_earnings_args', $args);
132
+		$key  = Give_Cache::get_key('give_stats', $args);
133 133
 
134 134
 		//Set transient for faster stats
135
-		$earnings = Give_Cache::get( $key );
135
+		$earnings = Give_Cache::get($key);
136 136
 
137
-		if ( false === $earnings ) {
137
+		if (false === $earnings) {
138 138
 
139 139
 			$this->timestamp = false;
140
-			$payments        = new Give_Payments_Query( $args );
140
+			$payments        = new Give_Payments_Query($args);
141 141
 			$payments        = $payments->get_payments();
142 142
 			$earnings        = 0;
143 143
 
144
-			if ( ! empty( $payments ) ) {
145
-				foreach ( $payments as $payment ) {
146
-					$earnings += give_get_payment_amount( $payment->ID );
144
+			if ( ! empty($payments)) {
145
+				foreach ($payments as $payment) {
146
+					$earnings += give_get_payment_amount($payment->ID);
147 147
 				}
148 148
 
149 149
 			}
150 150
 
151 151
 			// Cache the results for one hour
152
-			Give_Cache::set( $key, $earnings, 60 * 60 );
152
+			Give_Cache::set($key, $earnings, 60 * 60);
153 153
 		}
154 154
 
155 155
 		//return earnings
156
-		return round( $earnings, give_currency_decimal_filter() );
156
+		return round($earnings, give_currency_decimal_filter());
157 157
 
158 158
 	}
159 159
 
@@ -170,17 +170,17 @@  discard block
 block discarded – undo
170 170
 	 *
171 171
 	 * @return float|int                Total amount of donations based on the passed arguments.
172 172
 	 */
173
-	public function get_earnings_cache_key( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) {
173
+	public function get_earnings_cache_key($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) {
174 174
 
175
-		$this->setup_dates( $start_date, $end_date );
175
+		$this->setup_dates($start_date, $end_date);
176 176
 
177 177
 		// Make sure start date is valid
178
-		if ( is_wp_error( $this->start_date ) ) {
178
+		if (is_wp_error($this->start_date)) {
179 179
 			return $this->start_date;
180 180
 		}
181 181
 
182 182
 		// Make sure end date is valid
183
-		if ( is_wp_error( $this->end_date ) ) {
183
+		if (is_wp_error($this->end_date)) {
184 184
 			return $this->end_date;
185 185
 		}
186 186
 
@@ -190,12 +190,12 @@  discard block
 block discarded – undo
190 190
 			'start_date' => $this->start_date,
191 191
 			'end_date'   => $this->end_date,
192 192
 			'fields'     => 'ids',
193
-			'number'     => - 1,
193
+			'number'     => -1,
194 194
 		);
195 195
 
196 196
 
197 197
 		// Filter by Gateway ID meta_key
198
-		if ( $gateway_id ) {
198
+		if ($gateway_id) {
199 199
 			$args['meta_query'][] = array(
200 200
 				'key'   => '_give_payment_gateway',
201 201
 				'value' => $gateway_id,
@@ -203,19 +203,19 @@  discard block
 block discarded – undo
203 203
 		}
204 204
 
205 205
 		// Filter by Gateway ID meta_key
206
-		if ( $form_id ) {
206
+		if ($form_id) {
207 207
 			$args['meta_query'][] = array(
208 208
 				'key'   => '_give_payment_form_id',
209 209
 				'value' => $form_id,
210 210
 			);
211 211
 		}
212 212
 
213
-		if ( ! empty( $args['meta_query'] ) && 1 < count( $args['meta_query'] ) ) {
213
+		if ( ! empty($args['meta_query']) && 1 < count($args['meta_query'])) {
214 214
 			$args['meta_query']['relation'] = 'AND';
215 215
 		}
216 216
 
217
-		$args = apply_filters( 'give_stats_earnings_args', $args );
218
-		$key  = Give_Cache::get_key( 'give_stats', $args );
217
+		$args = apply_filters('give_stats_earnings_args', $args);
218
+		$key  = Give_Cache::get_key('give_stats', $args);
219 219
 
220 220
 		//return earnings
221 221
 		return $key;
@@ -232,16 +232,16 @@  discard block
 block discarded – undo
232 232
 	 *
233 233
 	 * @return array       Best selling forms
234 234
 	 */
235
-	public function get_best_selling( $number = 10 ) {
235
+	public function get_best_selling($number = 10) {
236 236
 
237 237
 		global $wpdb;
238 238
 
239
-		$give_forms = $wpdb->get_results( $wpdb->prepare(
239
+		$give_forms = $wpdb->get_results($wpdb->prepare(
240 240
 			"SELECT post_id as form_id, max(meta_value) as sales
241 241
 				FROM $wpdb->postmeta WHERE meta_key='_give_form_sales' AND meta_value > 0
242 242
 				GROUP BY meta_value+0
243 243
 				DESC LIMIT %d;", $number
244
-		) );
244
+		));
245 245
 
246 246
 		return $give_forms;
247 247
 	}
Please login to merge, or discard this patch.
includes/payments/functions.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
  * @param  int $year      Year number. Default is null.
682 682
  * @param  int $hour      Hour number. Default is null.
683 683
  *
684
- * @return int $earnings  Earnings
684
+ * @return double $earnings  Earnings
685 685
  */
686 686
 function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) {
687 687
 
@@ -970,7 +970,7 @@  discard block
 block discarded – undo
970 970
  *
971 971
  * @param int $payment_id Payment ID.
972 972
  *
973
- * @return array $user_info User Info Meta Values.
973
+ * @return string $user_info User Info Meta Values.
974 974
  */
975 975
 function give_get_payment_meta_user_info( $payment_id ) {
976 976
 	$payment = new Give_Payment( $payment_id );
@@ -987,7 +987,7 @@  discard block
 block discarded – undo
987 987
  *
988 988
  * @param int $payment_id Payment ID.
989 989
  *
990
- * @return int $form_id Form ID.
990
+ * @return string $form_id Form ID.
991 991
  */
992 992
 function give_get_payment_form_id( $payment_id ) {
993 993
 	$payment = new Give_Payment( $payment_id );
Please login to merge, or discard this patch.
Spacing   +404 added lines, -404 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
 
@@ -43,15 +43,15 @@  discard block
 block discarded – undo
43 43
  *
44 44
  * @return array $payments Payments retrieved from the database
45 45
  */
46
-function give_get_payments( $args = array() ) {
46
+function give_get_payments($args = array()) {
47 47
 
48 48
 	// Fallback to post objects to ensure backwards compatibility.
49
-	if ( ! isset( $args['output'] ) ) {
49
+	if ( ! isset($args['output'])) {
50 50
 		$args['output'] = 'posts';
51 51
 	}
52 52
 
53
-	$args     = apply_filters( 'give_get_payments_args', $args );
54
-	$payments = new Give_Payments_Query( $args );
53
+	$args     = apply_filters('give_get_payments_args', $args);
54
+	$payments = new Give_Payments_Query($args);
55 55
 
56 56
 	return $payments->get_payments();
57 57
 }
@@ -66,48 +66,48 @@  discard block
 block discarded – undo
66 66
  *
67 67
  * @return mixed
68 68
  */
69
-function give_get_payment_by( $field = '', $value = '' ) {
69
+function give_get_payment_by($field = '', $value = '') {
70 70
 
71
-	if ( empty( $field ) || empty( $value ) ) {
71
+	if (empty($field) || empty($value)) {
72 72
 		return false;
73 73
 	}
74 74
 
75
-	switch ( strtolower( $field ) ) {
75
+	switch (strtolower($field)) {
76 76
 
77 77
 		case 'id':
78
-			$payment = new Give_Payment( $value );
78
+			$payment = new Give_Payment($value);
79 79
 			$id      = $payment->ID;
80 80
 
81
-			if ( empty( $id ) ) {
81
+			if (empty($id)) {
82 82
 				return false;
83 83
 			}
84 84
 
85 85
 			break;
86 86
 
87 87
 		case 'key':
88
-			$payment = give_get_payments( array(
88
+			$payment = give_get_payments(array(
89 89
 				'meta_key'       => '_give_payment_purchase_key',
90 90
 				'meta_value'     => $value,
91 91
 				'posts_per_page' => 1,
92 92
 				'fields'         => 'ids',
93
-			) );
93
+			));
94 94
 
95
-			if ( $payment ) {
96
-				$payment = new Give_Payment( $payment[0] );
95
+			if ($payment) {
96
+				$payment = new Give_Payment($payment[0]);
97 97
 			}
98 98
 
99 99
 			break;
100 100
 
101 101
 		case 'payment_number':
102
-			$payment = give_get_payments( array(
102
+			$payment = give_get_payments(array(
103 103
 				'meta_key'       => '_give_payment_number',
104 104
 				'meta_value'     => $value,
105 105
 				'posts_per_page' => 1,
106 106
 				'fields'         => 'ids',
107
-			) );
107
+			));
108 108
 
109
-			if ( $payment ) {
110
-				$payment = new Give_Payment( $payment[0] );
109
+			if ($payment) {
110
+				$payment = new Give_Payment($payment[0]);
111 111
 			}
112 112
 
113 113
 			break;
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 			return false;
117 117
 	}
118 118
 
119
-	if ( $payment ) {
119
+	if ($payment) {
120 120
 		return $payment;
121 121
 	}
122 122
 
@@ -132,23 +132,23 @@  discard block
 block discarded – undo
132 132
  *
133 133
  * @return int|bool Payment ID if payment is inserted, false otherwise.
134 134
  */
135
-function give_insert_payment( $payment_data = array() ) {
135
+function give_insert_payment($payment_data = array()) {
136 136
 
137
-	if ( empty( $payment_data ) ) {
137
+	if (empty($payment_data)) {
138 138
 		return false;
139 139
 	}
140 140
 
141 141
 	$payment    = new Give_Payment();
142
-	$gateway    = ! empty( $payment_data['gateway'] ) ? $payment_data['gateway'] : '';
143
-	$gateway    = empty( $gateway ) && isset( $_POST['give-gateway'] ) ? $_POST['give-gateway'] : $gateway;
144
-	$form_id    = isset( $payment_data['give_form_id'] ) ? $payment_data['give_form_id'] : 0;
145
-	$price_id   = give_get_payment_meta_price_id( $payment_data );
146
-	$form_title = isset( $payment_data['give_form_title'] ) ? $payment_data['give_form_title'] : get_the_title( $form_id );
142
+	$gateway    = ! empty($payment_data['gateway']) ? $payment_data['gateway'] : '';
143
+	$gateway    = empty($gateway) && isset($_POST['give-gateway']) ? $_POST['give-gateway'] : $gateway;
144
+	$form_id    = isset($payment_data['give_form_id']) ? $payment_data['give_form_id'] : 0;
145
+	$price_id   = give_get_payment_meta_price_id($payment_data);
146
+	$form_title = isset($payment_data['give_form_title']) ? $payment_data['give_form_title'] : get_the_title($form_id);
147 147
 
148 148
 	// Set properties.
149 149
 	$payment->total          = $payment_data['price'];
150
-	$payment->status         = ! empty( $payment_data['status'] ) ? $payment_data['status'] : 'pending';
151
-	$payment->currency       = ! empty( $payment_data['currency'] ) ? $payment_data['currency'] : give_get_currency();
150
+	$payment->status         = ! empty($payment_data['status']) ? $payment_data['status'] : 'pending';
151
+	$payment->currency       = ! empty($payment_data['currency']) ? $payment_data['currency'] : give_get_currency();
152 152
 	$payment->user_info      = $payment_data['user_info'];
153 153
 	$payment->gateway        = $gateway;
154 154
 	$payment->form_title     = $form_title;
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	$payment->ip             = give_get_ip();
163 163
 	$payment->key            = $payment_data['purchase_key'];
164 164
 	$payment->mode           = give_is_test_mode() ? 'test' : 'live';
165
-	$payment->parent_payment = ! empty( $payment_data['parent'] ) ? absint( $payment_data['parent'] ) : '';
165
+	$payment->parent_payment = ! empty($payment_data['parent']) ? absint($payment_data['parent']) : '';
166 166
 
167 167
 	// Add the donation.
168 168
 	$args = array(
@@ -170,22 +170,22 @@  discard block
 block discarded – undo
170 170
 		'price_id' => $payment->price_id,
171 171
 	);
172 172
 
173
-	$payment->add_donation( $payment->form_id, $args );
173
+	$payment->add_donation($payment->form_id, $args);
174 174
 
175 175
 	// Set date if present.
176
-	if ( isset( $payment_data['post_date'] ) ) {
176
+	if (isset($payment_data['post_date'])) {
177 177
 		$payment->date = $payment_data['post_date'];
178 178
 	}
179 179
 
180 180
 	// Handle sequential payments.
181
-	if ( give_get_option( 'enable_sequential' ) ) {
181
+	if (give_get_option('enable_sequential')) {
182 182
 		$number          = give_get_next_payment_number();
183
-		$payment->number = give_format_payment_number( $number );
184
-		update_option( 'give_last_payment_number', $number );
183
+		$payment->number = give_format_payment_number($number);
184
+		update_option('give_last_payment_number', $number);
185 185
 	}
186 186
 
187 187
 	// Clear the user's donation cache.
188
-	delete_transient( 'give_user_' . $payment_data['user_info']['id'] . '_purchases' );
188
+	delete_transient('give_user_'.$payment_data['user_info']['id'].'_purchases');
189 189
 
190 190
 	// Save payment.
191 191
 	$payment->save();
@@ -198,10 +198,10 @@  discard block
 block discarded – undo
198 198
 	 * @param int   $payment_id   The payment ID.
199 199
 	 * @param array $payment_data Arguments passed.
200 200
 	 */
201
-	do_action( 'give_insert_payment', $payment->ID, $payment_data );
201
+	do_action('give_insert_payment', $payment->ID, $payment_data);
202 202
 
203 203
 	// Return payment ID upon success.
204
-	if ( ! empty( $payment->ID ) ) {
204
+	if ( ! empty($payment->ID)) {
205 205
 		return $payment->ID;
206 206
 	}
207 207
 
@@ -217,10 +217,10 @@  discard block
 block discarded – undo
217 217
  *
218 218
  * @return bool|int
219 219
  */
220
-function give_create_payment( $payment_data ) {
220
+function give_create_payment($payment_data) {
221 221
 
222
-	$form_id  = intval( $payment_data['post_data']['give-form-id'] );
223
-	$price_id = isset( $payment_data['post_data']['give-price-id'] ) ? $payment_data['post_data']['give-price-id'] : '';
222
+	$form_id  = intval($payment_data['post_data']['give-form-id']);
223
+	$price_id = isset($payment_data['post_data']['give-price-id']) ? $payment_data['post_data']['give-price-id'] : '';
224 224
 
225 225
 	// Collect payment data.
226 226
 	$insert_payment_data = array(
@@ -244,10 +244,10 @@  discard block
 block discarded – undo
244 244
 	 *
245 245
 	 * @param array $insert_payment_data
246 246
 	 */
247
-	$insert_payment_data = apply_filters( 'give_create_payment', $insert_payment_data );
247
+	$insert_payment_data = apply_filters('give_create_payment', $insert_payment_data);
248 248
 
249 249
 	// Record the pending payment.
250
-	return give_insert_payment( $insert_payment_data );
250
+	return give_insert_payment($insert_payment_data);
251 251
 }
252 252
 
253 253
 /**
@@ -260,9 +260,9 @@  discard block
 block discarded – undo
260 260
  *
261 261
  * @return bool
262 262
  */
263
-function give_update_payment_status( $payment_id, $new_status = 'publish' ) {
263
+function give_update_payment_status($payment_id, $new_status = 'publish') {
264 264
 
265
-	$payment         = new Give_Payment( $payment_id );
265
+	$payment         = new Give_Payment($payment_id);
266 266
 	$payment->status = $new_status;
267 267
 	$updated         = $payment->save();
268 268
 
@@ -281,38 +281,38 @@  discard block
 block discarded – undo
281 281
  *
282 282
  * @return void
283 283
  */
284
-function give_delete_donation( $payment_id = 0, $update_donor = true ) {
284
+function give_delete_donation($payment_id = 0, $update_donor = true) {
285 285
 	global $give_logs;
286 286
 
287
-	$payment  = new Give_Payment( $payment_id );
288
-	$amount   = give_get_payment_amount( $payment_id );
287
+	$payment  = new Give_Payment($payment_id);
288
+	$amount   = give_get_payment_amount($payment_id);
289 289
 	$status   = $payment->post_status;
290
-	$donor_id = give_get_payment_donor_id( $payment_id );
291
-	$donor    = new Give_Donor( $donor_id );
290
+	$donor_id = give_get_payment_donor_id($payment_id);
291
+	$donor    = new Give_Donor($donor_id);
292 292
 
293 293
 	// Only undo donations that aren't these statuses.
294
-	$dont_undo_statuses = apply_filters( 'give_undo_donation_statuses', array(
294
+	$dont_undo_statuses = apply_filters('give_undo_donation_statuses', array(
295 295
 		'pending',
296 296
 		'cancelled',
297
-	) );
297
+	));
298 298
 
299
-	if ( ! in_array( $status, $dont_undo_statuses ) ) {
300
-		give_undo_donation( $payment_id );
299
+	if ( ! in_array($status, $dont_undo_statuses)) {
300
+		give_undo_donation($payment_id);
301 301
 	}
302 302
 
303
-	if ( $status == 'publish' ) {
303
+	if ($status == 'publish') {
304 304
 
305 305
 		// Only decrease earnings if they haven't already been decreased (or were never increased for this payment).
306
-		give_decrease_total_earnings( $amount );
306
+		give_decrease_total_earnings($amount);
307 307
 
308 308
 		// @todo: Refresh only range related stat cache
309 309
 		give_delete_donation_stats();
310 310
 
311
-		if ( $donor->id && $update_donor ) {
311
+		if ($donor->id && $update_donor) {
312 312
 
313 313
 			// Decrement the stats for the donor.
314 314
 			$donor->decrease_donation_count();
315
-			$donor->decrease_value( $amount );
315
+			$donor->decrease_value($amount);
316 316
 
317 317
 		}
318 318
 	}
@@ -324,25 +324,25 @@  discard block
 block discarded – undo
324 324
 	 *
325 325
 	 * @param int $payment_id Payment ID.
326 326
 	 */
327
-	do_action( 'give_payment_delete', $payment_id );
327
+	do_action('give_payment_delete', $payment_id);
328 328
 
329
-	if ( $donor->id && $update_donor ) {
329
+	if ($donor->id && $update_donor) {
330 330
 
331 331
 		// Remove the payment ID from the donor.
332
-		$donor->remove_payment( $payment_id );
332
+		$donor->remove_payment($payment_id);
333 333
 
334 334
 	}
335 335
 
336 336
 	// Remove the payment.
337
-	wp_delete_post( $payment_id, true );
337
+	wp_delete_post($payment_id, true);
338 338
 
339 339
 	// Remove related sale log entries.
340
-	$give_logs->delete_logs( null, 'sale', array(
340
+	$give_logs->delete_logs(null, 'sale', array(
341 341
 		array(
342 342
 			'key'   => '_give_log_payment_id',
343 343
 			'value' => $payment_id,
344 344
 		),
345
-	) );
345
+	));
346 346
 
347 347
 	/**
348 348
 	 * Fires after payment deleted.
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 	 *
352 352
 	 * @param int $payment_id Payment ID.
353 353
 	 */
354
-	do_action( 'give_payment_deleted', $payment_id );
354
+	do_action('give_payment_deleted', $payment_id);
355 355
 }
356 356
 
357 357
 /**
@@ -366,20 +366,20 @@  discard block
 block discarded – undo
366 366
  *
367 367
  * @return void
368 368
  */
369
-function give_undo_donation( $payment_id ) {
369
+function give_undo_donation($payment_id) {
370 370
 
371
-	$payment = new Give_Payment( $payment_id );
371
+	$payment = new Give_Payment($payment_id);
372 372
 
373
-	$maybe_decrease_earnings = apply_filters( 'give_decrease_earnings_on_undo', true, $payment, $payment->form_id );
374
-	if ( true === $maybe_decrease_earnings ) {
373
+	$maybe_decrease_earnings = apply_filters('give_decrease_earnings_on_undo', true, $payment, $payment->form_id);
374
+	if (true === $maybe_decrease_earnings) {
375 375
 		// Decrease earnings.
376
-		give_decrease_earnings( $payment->form_id, $payment->total );
376
+		give_decrease_earnings($payment->form_id, $payment->total);
377 377
 	}
378 378
 
379
-	$maybe_decrease_donations = apply_filters( 'give_decrease_donations_on_undo', true, $payment, $payment->form_id );
380
-	if ( true === $maybe_decrease_donations ) {
379
+	$maybe_decrease_donations = apply_filters('give_decrease_donations_on_undo', true, $payment, $payment->form_id);
380
+	if (true === $maybe_decrease_donations) {
381 381
 		// Decrease donation count.
382
-		give_decrease_donation_count( $payment->form_id );
382
+		give_decrease_donation_count($payment->form_id);
383 383
 	}
384 384
 
385 385
 }
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
  *
397 397
  * @return object $stats Contains the number of payments per payment status.
398 398
  */
399
-function give_count_payments( $args = array() ) {
399
+function give_count_payments($args = array()) {
400 400
 
401 401
 	global $wpdb;
402 402
 
@@ -408,18 +408,18 @@  discard block
 block discarded – undo
408 408
 		'form_id'    => null,
409 409
 	);
410 410
 
411
-	$args = wp_parse_args( $args, $defaults );
411
+	$args = wp_parse_args($args, $defaults);
412 412
 
413 413
 	$select = 'SELECT p.post_status,count( * ) AS num_posts';
414 414
 	$join   = '';
415 415
 	$where  = "WHERE p.post_type = 'give_payment'";
416 416
 
417 417
 	// Count payments for a specific user.
418
-	if ( ! empty( $args['user'] ) ) {
418
+	if ( ! empty($args['user'])) {
419 419
 
420
-		if ( is_email( $args['user'] ) ) {
420
+		if (is_email($args['user'])) {
421 421
 			$field = 'email';
422
-		} elseif ( is_numeric( $args['user'] ) ) {
422
+		} elseif (is_numeric($args['user'])) {
423 423
 			$field = 'id';
424 424
 		} else {
425 425
 			$field = '';
@@ -427,106 +427,106 @@  discard block
 block discarded – undo
427 427
 
428 428
 		$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
429 429
 
430
-		if ( ! empty( $field ) ) {
430
+		if ( ! empty($field)) {
431 431
 			$where .= "
432 432
 				AND m.meta_key = '_give_payment_user_{$field}'
433 433
 				AND m.meta_value = '{$args['user']}'";
434 434
 		}
435 435
 
436 436
 
437
-	} elseif ( ! empty( $args['donor'] ) ) {
437
+	} elseif ( ! empty($args['donor'])) {
438 438
 
439
-		$join  = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
439
+		$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
440 440
 		$where .= "
441 441
 			AND m.meta_key = '_give_payment_customer_id'
442 442
 			AND m.meta_value = '{$args['donor']}'";
443 443
 
444 444
 		// Count payments for a search.
445
-	} elseif ( ! empty( $args['s'] ) ) {
445
+	} elseif ( ! empty($args['s'])) {
446 446
 
447
-		if ( is_email( $args['s'] ) || strlen( $args['s'] ) == 32 ) {
447
+		if (is_email($args['s']) || strlen($args['s']) == 32) {
448 448
 
449
-			if ( is_email( $args['s'] ) ) {
449
+			if (is_email($args['s'])) {
450 450
 				$field = '_give_payment_user_email';
451 451
 			} else {
452 452
 				$field = '_give_payment_purchase_key';
453 453
 			}
454 454
 
455
-			$join  = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
456
-			$where .= $wpdb->prepare( '
455
+			$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
456
+			$where .= $wpdb->prepare('
457 457
                 AND m.meta_key = %s
458
-                AND m.meta_value = %s', $field, $args['s'] );
458
+                AND m.meta_value = %s', $field, $args['s']);
459 459
 
460
-		} elseif ( '#' == substr( $args['s'], 0, 1 ) ) {
460
+		} elseif ('#' == substr($args['s'], 0, 1)) {
461 461
 
462
-			$search = str_replace( '#:', '', $args['s'] );
463
-			$search = str_replace( '#', '', $search );
462
+			$search = str_replace('#:', '', $args['s']);
463
+			$search = str_replace('#', '', $search);
464 464
 
465 465
 			$select = 'SELECT p.post_status,count( * ) AS num_posts ';
466 466
 			$join   = '';
467
-			$where  = $wpdb->prepare( 'WHERE p.post_type=%s  AND p.ID = %d ', 'give_payment', $search );
467
+			$where  = $wpdb->prepare('WHERE p.post_type=%s  AND p.ID = %d ', 'give_payment', $search);
468 468
 
469 469
 
470
-		} elseif ( is_numeric( $args['s'] ) ) {
470
+		} elseif (is_numeric($args['s'])) {
471 471
 
472
-			$join  = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
473
-			$where .= $wpdb->prepare( "
472
+			$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
473
+			$where .= $wpdb->prepare("
474 474
 				AND m.meta_key = '_give_payment_user_id'
475
-				AND m.meta_value = %d", $args['s'] );
475
+				AND m.meta_value = %d", $args['s']);
476 476
 
477 477
 		} else {
478
-			$search = $wpdb->esc_like( $args['s'] );
479
-			$search = '%' . $search . '%';
478
+			$search = $wpdb->esc_like($args['s']);
479
+			$search = '%'.$search.'%';
480 480
 
481
-			$where .= $wpdb->prepare( 'AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search );
481
+			$where .= $wpdb->prepare('AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search);
482 482
 		}
483 483
 	}
484 484
 
485
-	if ( ! empty( $args['form_id'] ) && is_numeric( $args['form_id'] ) ) {
486
-		$where .= $wpdb->prepare( ' AND p.post_parent = %d', $args['form_id'] );
485
+	if ( ! empty($args['form_id']) && is_numeric($args['form_id'])) {
486
+		$where .= $wpdb->prepare(' AND p.post_parent = %d', $args['form_id']);
487 487
 	}
488 488
 
489 489
 	// Limit payments count by date.
490
-	if ( ! empty( $args['start-date'] ) && false !== strpos( $args['start-date'], '/' ) ) {
490
+	if ( ! empty($args['start-date']) && false !== strpos($args['start-date'], '/')) {
491 491
 
492
-		$date_parts = explode( '/', $args['start-date'] );
493
-		$month      = ! empty( $date_parts[0] ) && is_numeric( $date_parts[0] ) ? $date_parts[0] : 0;
494
-		$day        = ! empty( $date_parts[1] ) && is_numeric( $date_parts[1] ) ? $date_parts[1] : 0;
495
-		$year       = ! empty( $date_parts[2] ) && is_numeric( $date_parts[2] ) ? $date_parts[2] : 0;
492
+		$date_parts = explode('/', $args['start-date']);
493
+		$month      = ! empty($date_parts[0]) && is_numeric($date_parts[0]) ? $date_parts[0] : 0;
494
+		$day        = ! empty($date_parts[1]) && is_numeric($date_parts[1]) ? $date_parts[1] : 0;
495
+		$year       = ! empty($date_parts[2]) && is_numeric($date_parts[2]) ? $date_parts[2] : 0;
496 496
 
497
-		$is_date = checkdate( $month, $day, $year );
498
-		if ( false !== $is_date ) {
497
+		$is_date = checkdate($month, $day, $year);
498
+		if (false !== $is_date) {
499 499
 
500
-			$date  = new DateTime( $args['start-date'] );
501
-			$where .= $wpdb->prepare( " AND p.post_date >= '%s'", $date->format( 'Y-m-d' ) );
500
+			$date = new DateTime($args['start-date']);
501
+			$where .= $wpdb->prepare(" AND p.post_date >= '%s'", $date->format('Y-m-d'));
502 502
 
503 503
 		}
504 504
 
505 505
 		// Fixes an issue with the payments list table counts when no end date is specified (with stats class).
506
-		if ( empty( $args['end-date'] ) ) {
506
+		if (empty($args['end-date'])) {
507 507
 			$args['end-date'] = $args['start-date'];
508 508
 		}
509 509
 	}
510 510
 
511
-	if ( ! empty( $args['end-date'] ) && false !== strpos( $args['end-date'], '/' ) ) {
511
+	if ( ! empty($args['end-date']) && false !== strpos($args['end-date'], '/')) {
512 512
 
513
-		$date_parts = explode( '/', $args['end-date'] );
513
+		$date_parts = explode('/', $args['end-date']);
514 514
 
515
-		$month = ! empty( $date_parts[0] ) ? $date_parts[0] : 0;
516
-		$day   = ! empty( $date_parts[1] ) ? $date_parts[1] : 0;
517
-		$year  = ! empty( $date_parts[2] ) ? $date_parts[2] : 0;
515
+		$month = ! empty($date_parts[0]) ? $date_parts[0] : 0;
516
+		$day   = ! empty($date_parts[1]) ? $date_parts[1] : 0;
517
+		$year  = ! empty($date_parts[2]) ? $date_parts[2] : 0;
518 518
 
519
-		$is_date = checkdate( $month, $day, $year );
520
-		if ( false !== $is_date ) {
519
+		$is_date = checkdate($month, $day, $year);
520
+		if (false !== $is_date) {
521 521
 
522
-			$date  = new DateTime( $args['end-date'] );
523
-			$where .= $wpdb->prepare( " AND p.post_date <= '%s'", $date->format( 'Y-m-d' ) );
522
+			$date = new DateTime($args['end-date']);
523
+			$where .= $wpdb->prepare(" AND p.post_date <= '%s'", $date->format('Y-m-d'));
524 524
 
525 525
 		}
526 526
 	}
527 527
 
528
-	$where = apply_filters( 'give_count_payments_where', $where );
529
-	$join  = apply_filters( 'give_count_payments_join', $join );
528
+	$where = apply_filters('give_count_payments_where', $where);
529
+	$join  = apply_filters('give_count_payments_join', $join);
530 530
 
531 531
 	$query = "$select
532 532
 		FROM $wpdb->posts p
@@ -535,36 +535,36 @@  discard block
 block discarded – undo
535 535
 		GROUP BY p.post_status
536 536
 	";
537 537
 
538
-	$cache_key = md5( $query );
538
+	$cache_key = md5($query);
539 539
 
540
-	$count = wp_cache_get( $cache_key, 'counts' );
541
-	if ( false !== $count ) {
540
+	$count = wp_cache_get($cache_key, 'counts');
541
+	if (false !== $count) {
542 542
 		return $count;
543 543
 	}
544 544
 
545
-	$count = $wpdb->get_results( $query, ARRAY_A );
545
+	$count = $wpdb->get_results($query, ARRAY_A);
546 546
 
547 547
 	$stats    = array();
548 548
 	$statuses = get_post_stati();
549
-	if ( isset( $statuses['private'] ) && empty( $args['s'] ) ) {
550
-		unset( $statuses['private'] );
549
+	if (isset($statuses['private']) && empty($args['s'])) {
550
+		unset($statuses['private']);
551 551
 	}
552 552
 
553
-	foreach ( $statuses as $state ) {
554
-		$stats[ $state ] = 0;
553
+	foreach ($statuses as $state) {
554
+		$stats[$state] = 0;
555 555
 	}
556 556
 
557
-	foreach ( (array) $count as $row ) {
557
+	foreach ((array) $count as $row) {
558 558
 
559
-		if ( 'private' == $row['post_status'] && empty( $args['s'] ) ) {
559
+		if ('private' == $row['post_status'] && empty($args['s'])) {
560 560
 			continue;
561 561
 		}
562 562
 
563
-		$stats[ $row['post_status'] ] = $row['num_posts'];
563
+		$stats[$row['post_status']] = $row['num_posts'];
564 564
 	}
565 565
 
566 566
 	$stats = (object) $stats;
567
-	wp_cache_set( $cache_key, $stats, 'counts' );
567
+	wp_cache_set($cache_key, $stats, 'counts');
568 568
 
569 569
 	return $stats;
570 570
 }
@@ -579,11 +579,11 @@  discard block
 block discarded – undo
579 579
  *
580 580
  * @return bool $exists True if payment exists, false otherwise.
581 581
  */
582
-function give_check_for_existing_payment( $payment_id ) {
582
+function give_check_for_existing_payment($payment_id) {
583 583
 	$exists  = false;
584
-	$payment = new Give_Payment( $payment_id );
584
+	$payment = new Give_Payment($payment_id);
585 585
 
586
-	if ( $payment_id === $payment->ID && 'publish' === $payment->status ) {
586
+	if ($payment_id === $payment->ID && 'publish' === $payment->status) {
587 587
 		$exists = true;
588 588
 	}
589 589
 
@@ -601,31 +601,31 @@  discard block
 block discarded – undo
601 601
  *
602 602
  * @return bool|mixed True if payment status exists, false otherwise.
603 603
  */
604
-function give_get_payment_status( $payment, $return_label = false ) {
604
+function give_get_payment_status($payment, $return_label = false) {
605 605
 
606
-	if ( ! is_object( $payment ) || ! isset( $payment->post_status ) ) {
606
+	if ( ! is_object($payment) || ! isset($payment->post_status)) {
607 607
 		return false;
608 608
 	}
609 609
 
610 610
 	$statuses = give_get_payment_statuses();
611 611
 
612
-	if ( ! is_array( $statuses ) || empty( $statuses ) ) {
612
+	if ( ! is_array($statuses) || empty($statuses)) {
613 613
 		return false;
614 614
 	}
615 615
 
616 616
 	// Get payment object if no already given.
617
-	$payment = $payment instanceof Give_Payment ? $payment : new Give_Payment( $payment->ID );
617
+	$payment = $payment instanceof Give_Payment ? $payment : new Give_Payment($payment->ID);
618 618
 
619
-	if ( array_key_exists( $payment->status, $statuses ) ) {
620
-		if ( true === $return_label ) {
619
+	if (array_key_exists($payment->status, $statuses)) {
620
+		if (true === $return_label) {
621 621
 			// Return translated status label.
622
-			return $statuses[ $payment->status ];
622
+			return $statuses[$payment->status];
623 623
 		} else {
624 624
 			// Account that our 'publish' status is labeled 'Complete'
625 625
 			$post_status = 'publish' == $payment->status ? 'Complete' : $payment->post_status;
626 626
 
627 627
 			// Make sure we're matching cases, since they matter
628
-			return array_search( strtolower( $post_status ), array_map( 'strtolower', $statuses ) );
628
+			return array_search(strtolower($post_status), array_map('strtolower', $statuses));
629 629
 		}
630 630
 	}
631 631
 
@@ -641,18 +641,18 @@  discard block
 block discarded – undo
641 641
  */
642 642
 function give_get_payment_statuses() {
643 643
 	$payment_statuses = array(
644
-		'pending'     => __( 'Pending', 'give' ),
645
-		'publish'     => __( 'Complete', 'give' ),
646
-		'refunded'    => __( 'Refunded', 'give' ),
647
-		'failed'      => __( 'Failed', 'give' ),
648
-		'cancelled'   => __( 'Cancelled', 'give' ),
649
-		'abandoned'   => __( 'Abandoned', 'give' ),
650
-		'preapproval' => __( 'Pre-Approved', 'give' ),
651
-		'processing'  => __( 'Processing', 'give' ),
652
-		'revoked'     => __( 'Revoked', 'give' ),
644
+		'pending'     => __('Pending', 'give'),
645
+		'publish'     => __('Complete', 'give'),
646
+		'refunded'    => __('Refunded', 'give'),
647
+		'failed'      => __('Failed', 'give'),
648
+		'cancelled'   => __('Cancelled', 'give'),
649
+		'abandoned'   => __('Abandoned', 'give'),
650
+		'preapproval' => __('Pre-Approved', 'give'),
651
+		'processing'  => __('Processing', 'give'),
652
+		'revoked'     => __('Revoked', 'give'),
653 653
 	);
654 654
 
655
-	return apply_filters( 'give_payment_statuses', $payment_statuses );
655
+	return apply_filters('give_payment_statuses', $payment_statuses);
656 656
 }
657 657
 
658 658
 /**
@@ -665,10 +665,10 @@  discard block
 block discarded – undo
665 665
  * @return array $payment_status All the available payment statuses.
666 666
  */
667 667
 function give_get_payment_status_keys() {
668
-	$statuses = array_keys( give_get_payment_statuses() );
669
-	asort( $statuses );
668
+	$statuses = array_keys(give_get_payment_statuses());
669
+	asort($statuses);
670 670
 
671
-	return array_values( $statuses );
671
+	return array_values($statuses);
672 672
 }
673 673
 
674 674
 /**
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
  *
684 684
  * @return int $earnings  Earnings
685 685
  */
686
-function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) {
686
+function give_get_earnings_by_date($day = null, $month_num, $year = null, $hour = null) {
687 687
 
688 688
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead.
689 689
 	global $wpdb;
@@ -693,41 +693,41 @@  discard block
 block discarded – undo
693 693
 		'nopaging'               => true,
694 694
 		'year'                   => $year,
695 695
 		'monthnum'               => $month_num,
696
-		'post_status'            => array( 'publish' ),
696
+		'post_status'            => array('publish'),
697 697
 		'fields'                 => 'ids',
698 698
 		'update_post_term_cache' => false,
699 699
 	);
700
-	if ( ! empty( $day ) ) {
700
+	if ( ! empty($day)) {
701 701
 		$args['day'] = $day;
702 702
 	}
703 703
 
704
-	if ( ! empty( $hour ) ) {
704
+	if ( ! empty($hour)) {
705 705
 		$args['hour'] = $hour;
706 706
 	}
707 707
 
708
-	$args = apply_filters( 'give_get_earnings_by_date_args', $args );
709
-	$key  = Give_Cache::get_key( 'give_stats', $args );
708
+	$args = apply_filters('give_get_earnings_by_date_args', $args);
709
+	$key  = Give_Cache::get_key('give_stats', $args);
710 710
 
711
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
711
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
712 712
 		$earnings = false;
713 713
 	} else {
714
-		$earnings = Give_Cache::get( $key );
714
+		$earnings = Give_Cache::get($key);
715 715
 	}
716 716
 
717
-	if ( false === $earnings ) {
718
-		$donations = get_posts( $args );
717
+	if (false === $earnings) {
718
+		$donations = get_posts($args);
719 719
 		$earnings  = 0;
720
-		if ( $donations ) {
721
-			$donations = implode( ',', $donations );
720
+		if ($donations) {
721
+			$donations = implode(',', $donations);
722 722
 
723
-			$earnings = $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$donations})" );
723
+			$earnings = $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$donations})");
724 724
 
725 725
 		}
726 726
 		// Cache the results for one hour.
727
-		Give_Cache::set( $key, $earnings, HOUR_IN_SECONDS );
727
+		Give_Cache::set($key, $earnings, HOUR_IN_SECONDS);
728 728
 	}
729 729
 
730
-	return round( $earnings, 2 );
730
+	return round($earnings, 2);
731 731
 }
732 732
 
733 733
 /**
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
  *
743 743
  * @return int $count     Sales
744 744
  */
745
-function give_get_sales_by_date( $day = null, $month_num = null, $year = null, $hour = null ) {
745
+function give_get_sales_by_date($day = null, $month_num = null, $year = null, $hour = null) {
746 746
 
747 747
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_sales() method instead.
748 748
 	$args = array(
@@ -750,14 +750,14 @@  discard block
 block discarded – undo
750 750
 		'nopaging'               => true,
751 751
 		'year'                   => $year,
752 752
 		'fields'                 => 'ids',
753
-		'post_status'            => array( 'publish' ),
753
+		'post_status'            => array('publish'),
754 754
 		'update_post_meta_cache' => false,
755 755
 		'update_post_term_cache' => false,
756 756
 	);
757 757
 
758
-	$show_free = apply_filters( 'give_sales_by_date_show_free', true, $args );
758
+	$show_free = apply_filters('give_sales_by_date_show_free', true, $args);
759 759
 
760
-	if ( false === $show_free ) {
760
+	if (false === $show_free) {
761 761
 		$args['meta_query'] = array(
762 762
 			array(
763 763
 				'key'     => '_give_payment_total',
@@ -768,33 +768,33 @@  discard block
 block discarded – undo
768 768
 		);
769 769
 	}
770 770
 
771
-	if ( ! empty( $month_num ) ) {
771
+	if ( ! empty($month_num)) {
772 772
 		$args['monthnum'] = $month_num;
773 773
 	}
774 774
 
775
-	if ( ! empty( $day ) ) {
775
+	if ( ! empty($day)) {
776 776
 		$args['day'] = $day;
777 777
 	}
778 778
 
779
-	if ( ! empty( $hour ) ) {
779
+	if ( ! empty($hour)) {
780 780
 		$args['hour'] = $hour;
781 781
 	}
782 782
 
783
-	$args = apply_filters( 'give_get_sales_by_date_args', $args );
783
+	$args = apply_filters('give_get_sales_by_date_args', $args);
784 784
 
785
-	$key = Give_Cache::get_key( 'give_stats', $args );
785
+	$key = Give_Cache::get_key('give_stats', $args);
786 786
 
787
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
787
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
788 788
 		$count = false;
789 789
 	} else {
790
-		$count = Give_Cache::get( $key );
790
+		$count = Give_Cache::get($key);
791 791
 	}
792 792
 
793
-	if ( false === $count ) {
794
-		$donations = new WP_Query( $args );
793
+	if (false === $count) {
794
+		$donations = new WP_Query($args);
795 795
 		$count     = (int) $donations->post_count;
796 796
 		// Cache the results for one hour.
797
-		Give_Cache::set( $key, $count, HOUR_IN_SECONDS );
797
+		Give_Cache::set($key, $count, HOUR_IN_SECONDS);
798 798
 	}
799 799
 
800 800
 	return $count;
@@ -809,19 +809,19 @@  discard block
 block discarded – undo
809 809
  *
810 810
  * @return bool $ret True if complete, false otherwise.
811 811
  */
812
-function give_is_payment_complete( $payment_id ) {
813
-	$payment = new Give_Payment( $payment_id );
812
+function give_is_payment_complete($payment_id) {
813
+	$payment = new Give_Payment($payment_id);
814 814
 
815 815
 	$ret = false;
816 816
 
817
-	if ( $payment->ID > 0 ) {
817
+	if ($payment->ID > 0) {
818 818
 
819
-		if ( (int) $payment_id === (int) $payment->ID && 'publish' == $payment->status ) {
819
+		if ((int) $payment_id === (int) $payment->ID && 'publish' == $payment->status) {
820 820
 			$ret = true;
821 821
 		}
822 822
 	}
823 823
 
824
-	return apply_filters( 'give_is_payment_complete', $ret, $payment_id, $payment->post_status );
824
+	return apply_filters('give_is_payment_complete', $ret, $payment_id, $payment->post_status);
825 825
 }
826 826
 
827 827
 /**
@@ -847,49 +847,49 @@  discard block
 block discarded – undo
847 847
  *
848 848
  * @return float $total Total earnings.
849 849
  */
850
-function give_get_total_earnings( $recalculate = false ) {
850
+function give_get_total_earnings($recalculate = false) {
851 851
 
852
-	$total = get_option( 'give_earnings_total', 0 );
852
+	$total = get_option('give_earnings_total', 0);
853 853
 
854 854
 	// Calculate total earnings.
855
-	if ( ! $total || $recalculate ) {
855
+	if ( ! $total || $recalculate) {
856 856
 		global $wpdb;
857 857
 
858 858
 		$total = (float) 0;
859 859
 
860
-		$args = apply_filters( 'give_get_total_earnings_args', array(
860
+		$args = apply_filters('give_get_total_earnings_args', array(
861 861
 			'offset' => 0,
862
-			'number' => - 1,
863
-			'status' => array( 'publish' ),
862
+			'number' => -1,
863
+			'status' => array('publish'),
864 864
 			'fields' => 'ids',
865
-		) );
865
+		));
866 866
 
867
-		$payments = give_get_payments( $args );
868
-		if ( $payments ) {
867
+		$payments = give_get_payments($args);
868
+		if ($payments) {
869 869
 
870 870
 			/**
871 871
 			 * If performing a donation, we need to skip the very last payment in the database,
872 872
 			 * since it calls give_increase_total_earnings() on completion,
873 873
 			 * which results in duplicated earnings for the very first donation.
874 874
 			 */
875
-			if ( did_action( 'give_update_payment_status' ) ) {
876
-				array_pop( $payments );
875
+			if (did_action('give_update_payment_status')) {
876
+				array_pop($payments);
877 877
 			}
878 878
 
879
-			if ( ! empty( $payments ) ) {
880
-				$payments = implode( ',', $payments );
881
-				$total    += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})" );
879
+			if ( ! empty($payments)) {
880
+				$payments = implode(',', $payments);
881
+				$total += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})");
882 882
 			}
883 883
 		}
884 884
 
885
-		update_option( 'give_earnings_total', $total, 'no' );
885
+		update_option('give_earnings_total', $total, 'no');
886 886
 	}
887 887
 
888
-	if ( $total < 0 ) {
888
+	if ($total < 0) {
889 889
 		$total = 0; // Don't ever show negative earnings.
890 890
 	}
891 891
 
892
-	return apply_filters( 'give_total_earnings', round( $total, give_currency_decimal_filter() ) );
892
+	return apply_filters('give_total_earnings', round($total, give_currency_decimal_filter()));
893 893
 }
894 894
 
895 895
 /**
@@ -902,10 +902,10 @@  discard block
 block discarded – undo
902 902
  *
903 903
  * @return float $total  Total earnings.
904 904
  */
905
-function give_increase_total_earnings( $amount = 0 ) {
905
+function give_increase_total_earnings($amount = 0) {
906 906
 	$total = give_get_total_earnings();
907 907
 	$total += $amount;
908
-	update_option( 'give_earnings_total', $total );
908
+	update_option('give_earnings_total', $total);
909 909
 
910 910
 	return $total;
911 911
 }
@@ -919,13 +919,13 @@  discard block
 block discarded – undo
919 919
  *
920 920
  * @return float $total Total earnings.
921 921
  */
922
-function give_decrease_total_earnings( $amount = 0 ) {
922
+function give_decrease_total_earnings($amount = 0) {
923 923
 	$total = give_get_total_earnings();
924 924
 	$total -= $amount;
925
-	if ( $total < 0 ) {
925
+	if ($total < 0) {
926 926
 		$total = 0;
927 927
 	}
928
-	update_option( 'give_earnings_total', $total );
928
+	update_option('give_earnings_total', $total);
929 929
 
930 930
 	return $total;
931 931
 }
@@ -941,10 +941,10 @@  discard block
 block discarded – undo
941 941
  *
942 942
  * @return mixed $meta Payment Meta.
943 943
  */
944
-function give_get_payment_meta( $payment_id = 0, $meta_key = '_give_payment_meta', $single = true ) {
945
-	$payment = new Give_Payment( $payment_id );
944
+function give_get_payment_meta($payment_id = 0, $meta_key = '_give_payment_meta', $single = true) {
945
+	$payment = new Give_Payment($payment_id);
946 946
 
947
-	return $payment->get_meta( $meta_key, $single );
947
+	return $payment->get_meta($meta_key, $single);
948 948
 }
949 949
 
950 950
 /**
@@ -957,10 +957,10 @@  discard block
 block discarded – undo
957 957
  *
958 958
  * @return mixed Meta ID if successful, false if unsuccessful.
959 959
  */
960
-function give_update_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) {
961
-	$payment = new Give_Payment( $payment_id );
960
+function give_update_payment_meta($payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') {
961
+	$payment = new Give_Payment($payment_id);
962 962
 
963
-	return $payment->update_meta( $meta_key, $meta_value, $prev_value );
963
+	return $payment->update_meta($meta_key, $meta_value, $prev_value);
964 964
 }
965 965
 
966 966
 /**
@@ -972,8 +972,8 @@  discard block
 block discarded – undo
972 972
  *
973 973
  * @return array $user_info User Info Meta Values.
974 974
  */
975
-function give_get_payment_meta_user_info( $payment_id ) {
976
-	$payment = new Give_Payment( $payment_id );
975
+function give_get_payment_meta_user_info($payment_id) {
976
+	$payment = new Give_Payment($payment_id);
977 977
 
978 978
 	return $payment->user_info;
979 979
 }
@@ -989,8 +989,8 @@  discard block
 block discarded – undo
989 989
  *
990 990
  * @return int $form_id Form ID.
991 991
  */
992
-function give_get_payment_form_id( $payment_id ) {
993
-	$payment = new Give_Payment( $payment_id );
992
+function give_get_payment_form_id($payment_id) {
993
+	$payment = new Give_Payment($payment_id);
994 994
 
995 995
 	return $payment->form_id;
996 996
 }
@@ -1004,8 +1004,8 @@  discard block
 block discarded – undo
1004 1004
  *
1005 1005
  * @return string $email User email.
1006 1006
  */
1007
-function give_get_payment_user_email( $payment_id ) {
1008
-	$payment = new Give_Payment( $payment_id );
1007
+function give_get_payment_user_email($payment_id) {
1008
+	$payment = new Give_Payment($payment_id);
1009 1009
 
1010 1010
 	return $payment->email;
1011 1011
 }
@@ -1019,11 +1019,11 @@  discard block
 block discarded – undo
1019 1019
  *
1020 1020
  * @return bool $is_guest_payment If the payment is associated with a user (false) or not (true)
1021 1021
  */
1022
-function give_is_guest_payment( $payment_id ) {
1023
-	$payment_user_id  = give_get_payment_user_id( $payment_id );
1024
-	$is_guest_payment = ! empty( $payment_user_id ) && $payment_user_id > 0 ? false : true;
1022
+function give_is_guest_payment($payment_id) {
1023
+	$payment_user_id  = give_get_payment_user_id($payment_id);
1024
+	$is_guest_payment = ! empty($payment_user_id) && $payment_user_id > 0 ? false : true;
1025 1025
 
1026
-	return (bool) apply_filters( 'give_is_guest_payment', $is_guest_payment, $payment_id );
1026
+	return (bool) apply_filters('give_is_guest_payment', $is_guest_payment, $payment_id);
1027 1027
 }
1028 1028
 
1029 1029
 /**
@@ -1035,8 +1035,8 @@  discard block
 block discarded – undo
1035 1035
  *
1036 1036
  * @return int $user_id User ID.
1037 1037
  */
1038
-function give_get_payment_user_id( $payment_id ) {
1039
-	$payment = new Give_Payment( $payment_id );
1038
+function give_get_payment_user_id($payment_id) {
1039
+	$payment = new Give_Payment($payment_id);
1040 1040
 
1041 1041
 	return $payment->user_id;
1042 1042
 }
@@ -1050,8 +1050,8 @@  discard block
 block discarded – undo
1050 1050
  *
1051 1051
  * @return int $payment->customer_id Donor ID.
1052 1052
  */
1053
-function give_get_payment_donor_id( $payment_id ) {
1054
-	$payment = new Give_Payment( $payment_id );
1053
+function give_get_payment_donor_id($payment_id) {
1054
+	$payment = new Give_Payment($payment_id);
1055 1055
 
1056 1056
 	return $payment->customer_id;
1057 1057
 }
@@ -1065,8 +1065,8 @@  discard block
 block discarded – undo
1065 1065
  *
1066 1066
  * @return string $ip User IP.
1067 1067
  */
1068
-function give_get_payment_user_ip( $payment_id ) {
1069
-	$payment = new Give_Payment( $payment_id );
1068
+function give_get_payment_user_ip($payment_id) {
1069
+	$payment = new Give_Payment($payment_id);
1070 1070
 
1071 1071
 	return $payment->ip;
1072 1072
 }
@@ -1080,8 +1080,8 @@  discard block
 block discarded – undo
1080 1080
  *
1081 1081
  * @return string $date The date the payment was completed.
1082 1082
  */
1083
-function give_get_payment_completed_date( $payment_id = 0 ) {
1084
-	$payment = new Give_Payment( $payment_id );
1083
+function give_get_payment_completed_date($payment_id = 0) {
1084
+	$payment = new Give_Payment($payment_id);
1085 1085
 
1086 1086
 	return $payment->completed_date;
1087 1087
 }
@@ -1095,8 +1095,8 @@  discard block
 block discarded – undo
1095 1095
  *
1096 1096
  * @return string $gateway Gateway.
1097 1097
  */
1098
-function give_get_payment_gateway( $payment_id ) {
1099
-	$payment = new Give_Payment( $payment_id );
1098
+function give_get_payment_gateway($payment_id) {
1099
+	$payment = new Give_Payment($payment_id);
1100 1100
 
1101 1101
 	return $payment->gateway;
1102 1102
 }
@@ -1110,8 +1110,8 @@  discard block
 block discarded – undo
1110 1110
  *
1111 1111
  * @return string $currency The currency code.
1112 1112
  */
1113
-function give_get_payment_currency_code( $payment_id = 0 ) {
1114
-	$payment = new Give_Payment( $payment_id );
1113
+function give_get_payment_currency_code($payment_id = 0) {
1114
+	$payment = new Give_Payment($payment_id);
1115 1115
 
1116 1116
 	return $payment->currency;
1117 1117
 }
@@ -1125,10 +1125,10 @@  discard block
 block discarded – undo
1125 1125
  *
1126 1126
  * @return string $currency The currency name.
1127 1127
  */
1128
-function give_get_payment_currency( $payment_id = 0 ) {
1129
-	$currency = give_get_payment_currency_code( $payment_id );
1128
+function give_get_payment_currency($payment_id = 0) {
1129
+	$currency = give_get_payment_currency_code($payment_id);
1130 1130
 
1131
-	return apply_filters( 'give_payment_currency', give_get_currency_name( $currency ), $payment_id );
1131
+	return apply_filters('give_payment_currency', give_get_currency_name($currency), $payment_id);
1132 1132
 }
1133 1133
 
1134 1134
 /**
@@ -1140,8 +1140,8 @@  discard block
 block discarded – undo
1140 1140
  *
1141 1141
  * @return string $key Donation key.
1142 1142
  */
1143
-function give_get_payment_key( $payment_id = 0 ) {
1144
-	$payment = new Give_Payment( $payment_id );
1143
+function give_get_payment_key($payment_id = 0) {
1144
+	$payment = new Give_Payment($payment_id);
1145 1145
 
1146 1146
 	return $payment->key;
1147 1147
 }
@@ -1157,8 +1157,8 @@  discard block
 block discarded – undo
1157 1157
  *
1158 1158
  * @return string $number Payment order number.
1159 1159
  */
1160
-function give_get_payment_number( $payment_id = 0 ) {
1161
-	$payment = new Give_Payment( $payment_id );
1160
+function give_get_payment_number($payment_id = 0) {
1161
+	$payment = new Give_Payment($payment_id);
1162 1162
 
1163 1163
 	return $payment->number;
1164 1164
 }
@@ -1172,23 +1172,23 @@  discard block
 block discarded – undo
1172 1172
  *
1173 1173
  * @return string      The formatted payment number.
1174 1174
  */
1175
-function give_format_payment_number( $number ) {
1175
+function give_format_payment_number($number) {
1176 1176
 
1177
-	if ( ! give_get_option( 'enable_sequential' ) ) {
1177
+	if ( ! give_get_option('enable_sequential')) {
1178 1178
 		return $number;
1179 1179
 	}
1180 1180
 
1181
-	if ( ! is_numeric( $number ) ) {
1181
+	if ( ! is_numeric($number)) {
1182 1182
 		return $number;
1183 1183
 	}
1184 1184
 
1185
-	$prefix  = give_get_option( 'sequential_prefix' );
1186
-	$number  = absint( $number );
1187
-	$postfix = give_get_option( 'sequential_postfix' );
1185
+	$prefix  = give_get_option('sequential_prefix');
1186
+	$number  = absint($number);
1187
+	$postfix = give_get_option('sequential_postfix');
1188 1188
 
1189
-	$formatted_number = $prefix . $number . $postfix;
1189
+	$formatted_number = $prefix.$number.$postfix;
1190 1190
 
1191
-	return apply_filters( 'give_format_payment_number', $formatted_number, $prefix, $number, $postfix );
1191
+	return apply_filters('give_format_payment_number', $formatted_number, $prefix, $number, $postfix);
1192 1192
 }
1193 1193
 
1194 1194
 /**
@@ -1201,17 +1201,17 @@  discard block
 block discarded – undo
1201 1201
  */
1202 1202
 function give_get_next_payment_number() {
1203 1203
 
1204
-	if ( ! give_get_option( 'enable_sequential' ) ) {
1204
+	if ( ! give_get_option('enable_sequential')) {
1205 1205
 		return false;
1206 1206
 	}
1207 1207
 
1208
-	$number           = get_option( 'give_last_payment_number' );
1209
-	$start            = give_get_option( 'sequential_start', 1 );
1208
+	$number           = get_option('give_last_payment_number');
1209
+	$start            = give_get_option('sequential_start', 1);
1210 1210
 	$increment_number = true;
1211 1211
 
1212
-	if ( false !== $number ) {
1212
+	if (false !== $number) {
1213 1213
 
1214
-		if ( empty( $number ) ) {
1214
+		if (empty($number)) {
1215 1215
 
1216 1216
 			$number           = $start;
1217 1217
 			$increment_number = false;
@@ -1220,24 +1220,24 @@  discard block
 block discarded – undo
1220 1220
 	} else {
1221 1221
 
1222 1222
 		// This case handles the first addition of the new option, as well as if it get's deleted for any reason.
1223
-		$payments     = new Give_Payments_Query( array(
1223
+		$payments = new Give_Payments_Query(array(
1224 1224
 			'number'  => 1,
1225 1225
 			'order'   => 'DESC',
1226 1226
 			'orderby' => 'ID',
1227 1227
 			'output'  => 'posts',
1228 1228
 			'fields'  => 'ids',
1229
-		) );
1229
+		));
1230 1230
 		$last_payment = $payments->get_payments();
1231 1231
 
1232
-		if ( ! empty( $last_payment ) ) {
1232
+		if ( ! empty($last_payment)) {
1233 1233
 
1234
-			$number = give_get_payment_number( $last_payment[0] );
1234
+			$number = give_get_payment_number($last_payment[0]);
1235 1235
 
1236 1236
 		}
1237 1237
 
1238
-		if ( ! empty( $number ) && $number !== (int) $last_payment[0] ) {
1238
+		if ( ! empty($number) && $number !== (int) $last_payment[0]) {
1239 1239
 
1240
-			$number = give_remove_payment_prefix_postfix( $number );
1240
+			$number = give_remove_payment_prefix_postfix($number);
1241 1241
 
1242 1242
 		} else {
1243 1243
 
@@ -1246,13 +1246,13 @@  discard block
 block discarded – undo
1246 1246
 		}
1247 1247
 	}
1248 1248
 
1249
-	$increment_number = apply_filters( 'give_increment_payment_number', $increment_number, $number );
1249
+	$increment_number = apply_filters('give_increment_payment_number', $increment_number, $number);
1250 1250
 
1251
-	if ( $increment_number ) {
1252
-		$number ++;
1251
+	if ($increment_number) {
1252
+		$number++;
1253 1253
 	}
1254 1254
 
1255
-	return apply_filters( 'give_get_next_payment_number', $number );
1255
+	return apply_filters('give_get_next_payment_number', $number);
1256 1256
 }
1257 1257
 
1258 1258
 /**
@@ -1264,25 +1264,25 @@  discard block
 block discarded – undo
1264 1264
  *
1265 1265
  * @return string The new Payment number without prefix and postfix.
1266 1266
  */
1267
-function give_remove_payment_prefix_postfix( $number ) {
1267
+function give_remove_payment_prefix_postfix($number) {
1268 1268
 
1269
-	$prefix  = give_get_option( 'sequential_prefix' );
1270
-	$postfix = give_get_option( 'sequential_postfix' );
1269
+	$prefix  = give_get_option('sequential_prefix');
1270
+	$postfix = give_get_option('sequential_postfix');
1271 1271
 
1272 1272
 	// Remove prefix.
1273
-	$number = preg_replace( '/' . $prefix . '/', '', $number, 1 );
1273
+	$number = preg_replace('/'.$prefix.'/', '', $number, 1);
1274 1274
 
1275 1275
 	// Remove the postfix.
1276
-	$length      = strlen( $number );
1277
-	$postfix_pos = strrpos( $number, $postfix );
1278
-	if ( false !== $postfix_pos ) {
1279
-		$number = substr_replace( $number, '', $postfix_pos, $length );
1276
+	$length      = strlen($number);
1277
+	$postfix_pos = strrpos($number, $postfix);
1278
+	if (false !== $postfix_pos) {
1279
+		$number = substr_replace($number, '', $postfix_pos, $length);
1280 1280
 	}
1281 1281
 
1282 1282
 	// Ensure it's a whole number.
1283
-	$number = intval( $number );
1283
+	$number = intval($number);
1284 1284
 
1285
-	return apply_filters( 'give_remove_payment_prefix_postfix', $number, $prefix, $postfix );
1285
+	return apply_filters('give_remove_payment_prefix_postfix', $number, $prefix, $postfix);
1286 1286
 
1287 1287
 }
1288 1288
 
@@ -1299,10 +1299,10 @@  discard block
 block discarded – undo
1299 1299
  *
1300 1300
  * @return string $amount Fully formatted payment amount.
1301 1301
  */
1302
-function give_payment_amount( $payment_id = 0 ) {
1303
-	$amount = give_get_payment_amount( $payment_id );
1302
+function give_payment_amount($payment_id = 0) {
1303
+	$amount = give_get_payment_amount($payment_id);
1304 1304
 
1305
-	return give_currency_filter( give_format_amount( $amount ), give_get_payment_currency_code( $payment_id ) );
1305
+	return give_currency_filter(give_format_amount($amount), give_get_payment_currency_code($payment_id));
1306 1306
 }
1307 1307
 
1308 1308
 /**
@@ -1315,11 +1315,11 @@  discard block
 block discarded – undo
1315 1315
  *
1316 1316
  * @return mixed
1317 1317
  */
1318
-function give_get_payment_amount( $payment_id ) {
1318
+function give_get_payment_amount($payment_id) {
1319 1319
 
1320
-	$payment = new Give_Payment( $payment_id );
1320
+	$payment = new Give_Payment($payment_id);
1321 1321
 
1322
-	return apply_filters( 'give_payment_amount', floatval( $payment->total ), $payment_id );
1322
+	return apply_filters('give_payment_amount', floatval($payment->total), $payment_id);
1323 1323
 }
1324 1324
 
1325 1325
 /**
@@ -1336,10 +1336,10 @@  discard block
 block discarded – undo
1336 1336
  *
1337 1337
  * @return array Fully formatted payment subtotal.
1338 1338
  */
1339
-function give_payment_subtotal( $payment_id = 0 ) {
1340
-	$subtotal = give_get_payment_subtotal( $payment_id );
1339
+function give_payment_subtotal($payment_id = 0) {
1340
+	$subtotal = give_get_payment_subtotal($payment_id);
1341 1341
 
1342
-	return give_currency_filter( give_format_amount( $subtotal ), give_get_payment_currency_code( $payment_id ) );
1342
+	return give_currency_filter(give_format_amount($subtotal), give_get_payment_currency_code($payment_id));
1343 1343
 }
1344 1344
 
1345 1345
 /**
@@ -1353,8 +1353,8 @@  discard block
 block discarded – undo
1353 1353
  *
1354 1354
  * @return float $subtotal Subtotal for payment (non formatted).
1355 1355
  */
1356
-function give_get_payment_subtotal( $payment_id = 0 ) {
1357
-	$payment = new Give_Payment( $payment_id );
1356
+function give_get_payment_subtotal($payment_id = 0) {
1357
+	$payment = new Give_Payment($payment_id);
1358 1358
 
1359 1359
 	return $payment->subtotal;
1360 1360
 }
@@ -1368,8 +1368,8 @@  discard block
 block discarded – undo
1368 1368
  *
1369 1369
  * @return string The donation ID.
1370 1370
  */
1371
-function give_get_payment_transaction_id( $payment_id = 0 ) {
1372
-	$payment = new Give_Payment( $payment_id );
1371
+function give_get_payment_transaction_id($payment_id = 0) {
1372
+	$payment = new Give_Payment($payment_id);
1373 1373
 
1374 1374
 	return $payment->transaction_id;
1375 1375
 }
@@ -1384,15 +1384,15 @@  discard block
 block discarded – undo
1384 1384
  *
1385 1385
  * @return bool|mixed
1386 1386
  */
1387
-function give_set_payment_transaction_id( $payment_id = 0, $transaction_id = '' ) {
1387
+function give_set_payment_transaction_id($payment_id = 0, $transaction_id = '') {
1388 1388
 
1389
-	if ( empty( $payment_id ) || empty( $transaction_id ) ) {
1389
+	if (empty($payment_id) || empty($transaction_id)) {
1390 1390
 		return false;
1391 1391
 	}
1392 1392
 
1393
-	$transaction_id = apply_filters( 'give_set_payment_transaction_id', $transaction_id, $payment_id );
1393
+	$transaction_id = apply_filters('give_set_payment_transaction_id', $transaction_id, $payment_id);
1394 1394
 
1395
-	return give_update_payment_meta( $payment_id, '_give_payment_transaction_id', $transaction_id );
1395
+	return give_update_payment_meta($payment_id, '_give_payment_transaction_id', $transaction_id);
1396 1396
 }
1397 1397
 
1398 1398
 /**
@@ -1405,12 +1405,12 @@  discard block
 block discarded – undo
1405 1405
  *
1406 1406
  * @return int $purchase Donation ID.
1407 1407
  */
1408
-function give_get_purchase_id_by_key( $key ) {
1408
+function give_get_purchase_id_by_key($key) {
1409 1409
 	global $wpdb;
1410 1410
 
1411
-	$purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key ) );
1411
+	$purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key));
1412 1412
 
1413
-	if ( $purchase != null ) {
1413
+	if ($purchase != null) {
1414 1414
 		return $purchase;
1415 1415
 	}
1416 1416
 
@@ -1428,12 +1428,12 @@  discard block
 block discarded – undo
1428 1428
  *
1429 1429
  * @return int $purchase Donation ID.
1430 1430
  */
1431
-function give_get_purchase_id_by_transaction_id( $key ) {
1431
+function give_get_purchase_id_by_transaction_id($key) {
1432 1432
 	global $wpdb;
1433 1433
 
1434
-	$purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key ) );
1434
+	$purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key));
1435 1435
 
1436
-	if ( $purchase != null ) {
1436
+	if ($purchase != null) {
1437 1437
 		return $purchase;
1438 1438
 	}
1439 1439
 
@@ -1450,19 +1450,19 @@  discard block
 block discarded – undo
1450 1450
  *
1451 1451
  * @return array $notes Donation Notes
1452 1452
  */
1453
-function give_get_payment_notes( $payment_id = 0, $search = '' ) {
1453
+function give_get_payment_notes($payment_id = 0, $search = '') {
1454 1454
 
1455
-	if ( empty( $payment_id ) && empty( $search ) ) {
1455
+	if (empty($payment_id) && empty($search)) {
1456 1456
 		return false;
1457 1457
 	}
1458 1458
 
1459
-	remove_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1460
-	remove_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10 );
1459
+	remove_action('pre_get_comments', 'give_hide_payment_notes', 10);
1460
+	remove_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10);
1461 1461
 
1462
-	$notes = get_comments( array( 'post_id' => $payment_id, 'order' => 'ASC', 'search' => $search ) );
1462
+	$notes = get_comments(array('post_id' => $payment_id, 'order' => 'ASC', 'search' => $search));
1463 1463
 
1464
-	add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1465
-	add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 );
1464
+	add_action('pre_get_comments', 'give_hide_payment_notes', 10);
1465
+	add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2);
1466 1466
 
1467 1467
 	return $notes;
1468 1468
 }
@@ -1478,8 +1478,8 @@  discard block
 block discarded – undo
1478 1478
  *
1479 1479
  * @return int The new note ID
1480 1480
  */
1481
-function give_insert_payment_note( $payment_id = 0, $note = '' ) {
1482
-	if ( empty( $payment_id ) ) {
1481
+function give_insert_payment_note($payment_id = 0, $note = '') {
1482
+	if (empty($payment_id)) {
1483 1483
 		return false;
1484 1484
 	}
1485 1485
 
@@ -1491,14 +1491,14 @@  discard block
 block discarded – undo
1491 1491
 	 * @param int    $payment_id Payment ID.
1492 1492
 	 * @param string $note       The note.
1493 1493
 	 */
1494
-	do_action( 'give_pre_insert_payment_note', $payment_id, $note );
1494
+	do_action('give_pre_insert_payment_note', $payment_id, $note);
1495 1495
 
1496
-	$note_id = wp_insert_comment( wp_filter_comment( array(
1496
+	$note_id = wp_insert_comment(wp_filter_comment(array(
1497 1497
 		'comment_post_ID'      => $payment_id,
1498 1498
 		'comment_content'      => $note,
1499 1499
 		'user_id'              => is_admin() ? get_current_user_id() : 0,
1500
-		'comment_date'         => current_time( 'mysql' ),
1501
-		'comment_date_gmt'     => current_time( 'mysql', 1 ),
1500
+		'comment_date'         => current_time('mysql'),
1501
+		'comment_date_gmt'     => current_time('mysql', 1),
1502 1502
 		'comment_approved'     => 1,
1503 1503
 		'comment_parent'       => 0,
1504 1504
 		'comment_author'       => '',
@@ -1507,7 +1507,7 @@  discard block
 block discarded – undo
1507 1507
 		'comment_author_email' => '',
1508 1508
 		'comment_type'         => 'give_payment_note',
1509 1509
 
1510
-	) ) );
1510
+	)));
1511 1511
 
1512 1512
 	/**
1513 1513
 	 * Fires after payment note inserted.
@@ -1518,7 +1518,7 @@  discard block
 block discarded – undo
1518 1518
 	 * @param int    $payment_id Payment ID.
1519 1519
 	 * @param string $note       The note.
1520 1520
 	 */
1521
-	do_action( 'give_insert_payment_note', $note_id, $payment_id, $note );
1521
+	do_action('give_insert_payment_note', $note_id, $payment_id, $note);
1522 1522
 
1523 1523
 	return $note_id;
1524 1524
 }
@@ -1533,8 +1533,8 @@  discard block
 block discarded – undo
1533 1533
  *
1534 1534
  * @return bool True on success, false otherwise.
1535 1535
  */
1536
-function give_delete_payment_note( $comment_id = 0, $payment_id = 0 ) {
1537
-	if ( empty( $comment_id ) ) {
1536
+function give_delete_payment_note($comment_id = 0, $payment_id = 0) {
1537
+	if (empty($comment_id)) {
1538 1538
 		return false;
1539 1539
 	}
1540 1540
 
@@ -1546,9 +1546,9 @@  discard block
 block discarded – undo
1546 1546
 	 * @param int $comment_id Note ID.
1547 1547
 	 * @param int $payment_id Payment ID.
1548 1548
 	 */
1549
-	do_action( 'give_pre_delete_payment_note', $comment_id, $payment_id );
1549
+	do_action('give_pre_delete_payment_note', $comment_id, $payment_id);
1550 1550
 
1551
-	$ret = wp_delete_comment( $comment_id, true );
1551
+	$ret = wp_delete_comment($comment_id, true);
1552 1552
 
1553 1553
 	/**
1554 1554
 	 * Fires after donation note deleted.
@@ -1558,7 +1558,7 @@  discard block
 block discarded – undo
1558 1558
 	 * @param int $comment_id Note ID.
1559 1559
 	 * @param int $payment_id Payment ID.
1560 1560
 	 */
1561
-	do_action( 'give_post_delete_payment_note', $comment_id, $payment_id );
1561
+	do_action('give_post_delete_payment_note', $comment_id, $payment_id);
1562 1562
 
1563 1563
 	return $ret;
1564 1564
 }
@@ -1573,32 +1573,32 @@  discard block
 block discarded – undo
1573 1573
  *
1574 1574
  * @return string
1575 1575
  */
1576
-function give_get_payment_note_html( $note, $payment_id = 0 ) {
1576
+function give_get_payment_note_html($note, $payment_id = 0) {
1577 1577
 
1578
-	if ( is_numeric( $note ) ) {
1579
-		$note = get_comment( $note );
1578
+	if (is_numeric($note)) {
1579
+		$note = get_comment($note);
1580 1580
 	}
1581 1581
 
1582
-	if ( ! empty( $note->user_id ) ) {
1583
-		$user = get_userdata( $note->user_id );
1582
+	if ( ! empty($note->user_id)) {
1583
+		$user = get_userdata($note->user_id);
1584 1584
 		$user = $user->display_name;
1585 1585
 	} else {
1586
-		$user = esc_html__( 'System', 'give' );
1586
+		$user = esc_html__('System', 'give');
1587 1587
 	}
1588 1588
 
1589
-	$date_format = give_date_format() . ', ' . get_option( 'time_format' );
1589
+	$date_format = give_date_format().', '.get_option('time_format');
1590 1590
 
1591
-	$delete_note_url = wp_nonce_url( add_query_arg( array(
1591
+	$delete_note_url = wp_nonce_url(add_query_arg(array(
1592 1592
 		'give-action' => 'delete_payment_note',
1593 1593
 		'note_id'     => $note->comment_ID,
1594 1594
 		'payment_id'  => $payment_id,
1595
-	) ), 'give_delete_payment_note_' . $note->comment_ID );
1595
+	)), 'give_delete_payment_note_'.$note->comment_ID);
1596 1596
 
1597
-	$note_html = '<div class="give-payment-note" id="give-payment-note-' . $note->comment_ID . '">';
1597
+	$note_html = '<div class="give-payment-note" id="give-payment-note-'.$note->comment_ID.'">';
1598 1598
 	$note_html .= '<p>';
1599
-	$note_html .= '<strong>' . $user . '</strong>&nbsp;&ndash;&nbsp;<span style="color:#aaa;font-style:italic;">' . date_i18n( $date_format, strtotime( $note->comment_date ) ) . '</span><br/>';
1599
+	$note_html .= '<strong>'.$user.'</strong>&nbsp;&ndash;&nbsp;<span style="color:#aaa;font-style:italic;">'.date_i18n($date_format, strtotime($note->comment_date)).'</span><br/>';
1600 1600
 	$note_html .= $note->comment_content;
1601
-	$note_html .= '&nbsp;&ndash;&nbsp;<a href="' . esc_url( $delete_note_url ) . '" class="give-delete-payment-note" data-note-id="' . absint( $note->comment_ID ) . '" data-payment-id="' . absint( $payment_id ) . '" aria-label="' . esc_attr__( 'Delete this donation note.', 'give' ) . '">' . esc_html__( 'Delete', 'give' ) . '</a>';
1601
+	$note_html .= '&nbsp;&ndash;&nbsp;<a href="'.esc_url($delete_note_url).'" class="give-delete-payment-note" data-note-id="'.absint($note->comment_ID).'" data-payment-id="'.absint($payment_id).'" aria-label="'.esc_attr__('Delete this donation note.', 'give').'">'.esc_html__('Delete', 'give').'</a>';
1602 1602
 	$note_html .= '</p>';
1603 1603
 	$note_html .= '</div>';
1604 1604
 
@@ -1616,18 +1616,18 @@  discard block
 block discarded – undo
1616 1616
  *
1617 1617
  * @return void
1618 1618
  */
1619
-function give_hide_payment_notes( $query ) {
1620
-	if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '>=' ) ) {
1621
-		$types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array();
1622
-		if ( ! is_array( $types ) ) {
1623
-			$types = array( $types );
1619
+function give_hide_payment_notes($query) {
1620
+	if (version_compare(floatval(get_bloginfo('version')), '4.1', '>=')) {
1621
+		$types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array();
1622
+		if ( ! is_array($types)) {
1623
+			$types = array($types);
1624 1624
 		}
1625 1625
 		$types[]                           = 'give_payment_note';
1626 1626
 		$query->query_vars['type__not_in'] = $types;
1627 1627
 	}
1628 1628
 }
1629 1629
 
1630
-add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1630
+add_action('pre_get_comments', 'give_hide_payment_notes', 10);
1631 1631
 
1632 1632
 /**
1633 1633
  * Exclude notes (comments) on give_payment post type from showing in Recent Comments widgets
@@ -1639,15 +1639,15 @@  discard block
 block discarded – undo
1639 1639
  *
1640 1640
  * @return array $clauses Updated comment clauses.
1641 1641
  */
1642
-function give_hide_payment_notes_pre_41( $clauses, $wp_comment_query ) {
1643
-	if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '<' ) ) {
1642
+function give_hide_payment_notes_pre_41($clauses, $wp_comment_query) {
1643
+	if (version_compare(floatval(get_bloginfo('version')), '4.1', '<')) {
1644 1644
 		$clauses['where'] .= ' AND comment_type != "give_payment_note"';
1645 1645
 	}
1646 1646
 
1647 1647
 	return $clauses;
1648 1648
 }
1649 1649
 
1650
-add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 );
1650
+add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2);
1651 1651
 
1652 1652
 
1653 1653
 /**
@@ -1660,15 +1660,15 @@  discard block
 block discarded – undo
1660 1660
  *
1661 1661
  * @return string $where
1662 1662
  */
1663
-function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) {
1663
+function give_hide_payment_notes_from_feeds($where, $wp_comment_query) {
1664 1664
 	global $wpdb;
1665 1665
 
1666
-	$where .= $wpdb->prepare( ' AND comment_type != %s', 'give_payment_note' );
1666
+	$where .= $wpdb->prepare(' AND comment_type != %s', 'give_payment_note');
1667 1667
 
1668 1668
 	return $where;
1669 1669
 }
1670 1670
 
1671
-add_filter( 'comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2 );
1671
+add_filter('comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2);
1672 1672
 
1673 1673
 
1674 1674
 /**
@@ -1682,32 +1682,32 @@  discard block
 block discarded – undo
1682 1682
  *
1683 1683
  * @return array Array of comment counts.
1684 1684
  */
1685
-function give_remove_payment_notes_in_comment_counts( $stats, $post_id ) {
1685
+function give_remove_payment_notes_in_comment_counts($stats, $post_id) {
1686 1686
 	global $wpdb, $pagenow;
1687 1687
 
1688
-	if ( 'index.php' != $pagenow ) {
1688
+	if ('index.php' != $pagenow) {
1689 1689
 		return $stats;
1690 1690
 	}
1691 1691
 
1692 1692
 	$post_id = (int) $post_id;
1693 1693
 
1694
-	if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) {
1694
+	if (apply_filters('give_count_payment_notes_in_comments', false)) {
1695 1695
 		return $stats;
1696 1696
 	}
1697 1697
 
1698
-	$stats = wp_cache_get( "comments-{$post_id}", 'counts' );
1698
+	$stats = wp_cache_get("comments-{$post_id}", 'counts');
1699 1699
 
1700
-	if ( false !== $stats ) {
1700
+	if (false !== $stats) {
1701 1701
 		return $stats;
1702 1702
 	}
1703 1703
 
1704 1704
 	$where = 'WHERE comment_type != "give_payment_note"';
1705 1705
 
1706
-	if ( $post_id > 0 ) {
1707
-		$where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id );
1706
+	if ($post_id > 0) {
1707
+		$where .= $wpdb->prepare(' AND comment_post_ID = %d', $post_id);
1708 1708
 	}
1709 1709
 
1710
-	$count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A );
1710
+	$count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A);
1711 1711
 
1712 1712
 	$total    = 0;
1713 1713
 	$approved = array(
@@ -1717,30 +1717,30 @@  discard block
 block discarded – undo
1717 1717
 		'trash'        => 'trash',
1718 1718
 		'post-trashed' => 'post-trashed',
1719 1719
 	);
1720
-	foreach ( (array) $count as $row ) {
1720
+	foreach ((array) $count as $row) {
1721 1721
 		// Don't count post-trashed toward totals.
1722
-		if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) {
1722
+		if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) {
1723 1723
 			$total += $row['num_comments'];
1724 1724
 		}
1725
-		if ( isset( $approved[ $row['comment_approved'] ] ) ) {
1726
-			$stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments'];
1725
+		if (isset($approved[$row['comment_approved']])) {
1726
+			$stats[$approved[$row['comment_approved']]] = $row['num_comments'];
1727 1727
 		}
1728 1728
 	}
1729 1729
 
1730 1730
 	$stats['total_comments'] = $total;
1731
-	foreach ( $approved as $key ) {
1732
-		if ( empty( $stats[ $key ] ) ) {
1733
-			$stats[ $key ] = 0;
1731
+	foreach ($approved as $key) {
1732
+		if (empty($stats[$key])) {
1733
+			$stats[$key] = 0;
1734 1734
 		}
1735 1735
 	}
1736 1736
 
1737 1737
 	$stats = (object) $stats;
1738
-	wp_cache_set( "comments-{$post_id}", $stats, 'counts' );
1738
+	wp_cache_set("comments-{$post_id}", $stats, 'counts');
1739 1739
 
1740 1740
 	return $stats;
1741 1741
 }
1742 1742
 
1743
-add_filter( 'wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2 );
1743
+add_filter('wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2);
1744 1744
 
1745 1745
 
1746 1746
 /**
@@ -1753,9 +1753,9 @@  discard block
 block discarded – undo
1753 1753
  *
1754 1754
  * @return string $where Modified where clause.
1755 1755
  */
1756
-function give_filter_where_older_than_week( $where = '' ) {
1756
+function give_filter_where_older_than_week($where = '') {
1757 1757
 	// Payments older than one week.
1758
-	$start = date( 'Y-m-d', strtotime( '-7 days' ) );
1758
+	$start = date('Y-m-d', strtotime('-7 days'));
1759 1759
 	$where .= " AND post_date <= '{$start}'";
1760 1760
 
1761 1761
 	return $where;
@@ -1775,38 +1775,38 @@  discard block
 block discarded – undo
1775 1775
  *
1776 1776
  * @return string $form_title Returns the full title if $only_level is false, otherwise returns the levels title.
1777 1777
  */
1778
-function give_get_payment_form_title( $payment_meta, $only_level = false, $separator = '' ) {
1778
+function give_get_payment_form_title($payment_meta, $only_level = false, $separator = '') {
1779 1779
 
1780
-	$form_id    = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0;
1781
-	$price_id   = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null;
1782
-	$form_title = isset( $payment_meta['form_title'] ) ? $payment_meta['form_title'] : '';
1780
+	$form_id    = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0;
1781
+	$price_id   = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null;
1782
+	$form_title = isset($payment_meta['form_title']) ? $payment_meta['form_title'] : '';
1783 1783
 
1784
-	if ( $only_level == true ) {
1784
+	if ($only_level == true) {
1785 1785
 		$form_title = '';
1786 1786
 	}
1787 1787
 
1788 1788
 	//If multi-level, append to the form title.
1789
-	if ( give_has_variable_prices( $form_id ) ) {
1789
+	if (give_has_variable_prices($form_id)) {
1790 1790
 
1791 1791
 		//Only add separator if there is a form title.
1792
-		if ( ! empty( $form_title ) ) {
1793
-			$form_title .= ' ' . $separator . ' ';
1792
+		if ( ! empty($form_title)) {
1793
+			$form_title .= ' '.$separator.' ';
1794 1794
 		}
1795 1795
 
1796 1796
 		$form_title .= '<span class="donation-level-text-wrap">';
1797 1797
 
1798
-		if ( $price_id == 'custom' ) {
1799
-			$custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true );
1800
-			$form_title         .= ! empty( $custom_amount_text ) ? $custom_amount_text : __( 'Custom Amount', 'give' );
1798
+		if ($price_id == 'custom') {
1799
+			$custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true);
1800
+			$form_title .= ! empty($custom_amount_text) ? $custom_amount_text : __('Custom Amount', 'give');
1801 1801
 		} else {
1802
-			$form_title .= give_get_price_option_name( $form_id, $price_id );
1802
+			$form_title .= give_get_price_option_name($form_id, $price_id);
1803 1803
 		}
1804 1804
 
1805 1805
 		$form_title .= '</span>';
1806 1806
 
1807 1807
 	}
1808 1808
 
1809
-	return apply_filters( 'give_get_payment_form_title', $form_title, $payment_meta );
1809
+	return apply_filters('give_get_payment_form_title', $form_title, $payment_meta);
1810 1810
 
1811 1811
 }
1812 1812
 
@@ -1820,20 +1820,20 @@  discard block
 block discarded – undo
1820 1820
  *
1821 1821
  * @return string $price_id
1822 1822
  */
1823
-function give_get_price_id( $form_id, $price ) {
1823
+function give_get_price_id($form_id, $price) {
1824 1824
 
1825 1825
 	$price_id = 0;
1826 1826
 
1827
-	if ( give_has_variable_prices( $form_id ) ) {
1827
+	if (give_has_variable_prices($form_id)) {
1828 1828
 
1829
-		$levels = maybe_unserialize( give_get_meta( $form_id, '_give_donation_levels', true ) );
1829
+		$levels = maybe_unserialize(give_get_meta($form_id, '_give_donation_levels', true));
1830 1830
 
1831
-		foreach ( $levels as $level ) {
1831
+		foreach ($levels as $level) {
1832 1832
 
1833
-			$level_amount = (float) give_sanitize_amount( $level['_give_amount'] );
1833
+			$level_amount = (float) give_sanitize_amount($level['_give_amount']);
1834 1834
 
1835 1835
 			// Check that this indeed the recurring price.
1836
-			if ( $level_amount == $price ) {
1836
+			if ($level_amount == $price) {
1837 1837
 
1838 1838
 				$price_id = $level['_give_id']['level_id'];
1839 1839
 
@@ -1858,10 +1858,10 @@  discard block
 block discarded – undo
1858 1858
  *
1859 1859
  * @return string
1860 1860
  */
1861
-function give_get_form_dropdown( $args = array(), $echo = false ) {
1862
-	$form_dropdown_html = Give()->html->forms_dropdown( $args );
1861
+function give_get_form_dropdown($args = array(), $echo = false) {
1862
+	$form_dropdown_html = Give()->html->forms_dropdown($args);
1863 1863
 
1864
-	if ( ! $echo ) {
1864
+	if ( ! $echo) {
1865 1865
 		return $form_dropdown_html;
1866 1866
 	}
1867 1867
 
@@ -1878,17 +1878,17 @@  discard block
 block discarded – undo
1878 1878
  *
1879 1879
  * @return string|bool
1880 1880
  */
1881
-function give_get_form_variable_price_dropdown( $args = array(), $echo = false ) {
1881
+function give_get_form_variable_price_dropdown($args = array(), $echo = false) {
1882 1882
 
1883 1883
 	// Check for give form id.
1884
-	if ( empty( $args['id'] ) ) {
1884
+	if (empty($args['id'])) {
1885 1885
 		return false;
1886 1886
 	}
1887 1887
 
1888
-	$form = new Give_Donate_Form( $args['id'] );
1888
+	$form = new Give_Donate_Form($args['id']);
1889 1889
 
1890 1890
 	// Check if form has variable prices or not.
1891
-	if ( ! $form->ID || ! $form->has_variable_prices() ) {
1891
+	if ( ! $form->ID || ! $form->has_variable_prices()) {
1892 1892
 		return false;
1893 1893
 	}
1894 1894
 
@@ -1896,22 +1896,22 @@  discard block
 block discarded – undo
1896 1896
 	$variable_price_options = array();
1897 1897
 
1898 1898
 	// Check if multi donation form support custom donation or not.
1899
-	if ( $form->is_custom_price_mode() ) {
1900
-		$variable_price_options['custom'] = _x( 'Custom', 'custom donation dropdown item', 'give' );
1899
+	if ($form->is_custom_price_mode()) {
1900
+		$variable_price_options['custom'] = _x('Custom', 'custom donation dropdown item', 'give');
1901 1901
 	}
1902 1902
 
1903 1903
 	// Get variable price and ID from variable price array.
1904
-	foreach ( $variable_prices as $variable_price ) {
1905
-		$variable_price_options[ $variable_price['_give_id']['level_id'] ] = ! empty( $variable_price['_give_text'] ) ? $variable_price['_give_text'] : give_currency_filter( give_format_amount( $variable_price['_give_amount'] ) );
1904
+	foreach ($variable_prices as $variable_price) {
1905
+		$variable_price_options[$variable_price['_give_id']['level_id']] = ! empty($variable_price['_give_text']) ? $variable_price['_give_text'] : give_currency_filter(give_format_amount($variable_price['_give_amount']));
1906 1906
 	}
1907 1907
 
1908 1908
 	// Update options.
1909
-	$args = array_merge( $args, array( 'options' => $variable_price_options ) );
1909
+	$args = array_merge($args, array('options' => $variable_price_options));
1910 1910
 
1911 1911
 	// Generate select html.
1912
-	$form_dropdown_html = Give()->html->select( $args );
1912
+	$form_dropdown_html = Give()->html->select($args);
1913 1913
 
1914
-	if ( ! $echo ) {
1914
+	if ( ! $echo) {
1915 1915
 		return $form_dropdown_html;
1916 1916
 	}
1917 1917
 
@@ -1930,16 +1930,16 @@  discard block
 block discarded – undo
1930 1930
  *
1931 1931
  * @return string
1932 1932
  */
1933
-function give_get_payment_meta_price_id( $payment_meta ) {
1933
+function give_get_payment_meta_price_id($payment_meta) {
1934 1934
 
1935
-	if ( isset( $payment_meta['give_price_id'] ) ) {
1935
+	if (isset($payment_meta['give_price_id'])) {
1936 1936
 		$price_id = $payment_meta['give_price_id'];
1937
-	} elseif ( isset( $payment_meta['price_id'] ) ) {
1937
+	} elseif (isset($payment_meta['price_id'])) {
1938 1938
 		$price_id = $payment_meta['price_id'];
1939 1939
 	} else {
1940
-		$price_id = give_get_price_id( $payment_meta['give_form_id'], $payment_meta['price'] );
1940
+		$price_id = give_get_price_id($payment_meta['give_form_id'], $payment_meta['price']);
1941 1941
 	}
1942 1942
 
1943
-	return apply_filters( 'give_get_payment_meta_price_id', $price_id );
1943
+	return apply_filters('give_get_payment_meta_price_id', $price_id);
1944 1944
 
1945 1945
 }
1946 1946
\ No newline at end of file
Please login to merge, or discard this patch.
give.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -178,7 +178,7 @@
 block discarded – undo
178 178
 		public $email_access;
179 179
 
180 180
 		/**
181
-		* Give notices Object
181
+		 * Give notices Object
182 182
 		 *
183 183
 		 * @since  2.0
184 184
 		 * @access public
Please login to merge, or discard this patch.
Spacing   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -40,11 +40,11 @@  discard block
 block discarded – undo
40 40
  */
41 41
 
42 42
 // Exit if accessed directly.
43
-if ( ! defined( 'ABSPATH' ) ) {
43
+if ( ! defined('ABSPATH')) {
44 44
 	exit;
45 45
 }
46 46
 
47
-if ( ! class_exists( 'Give' ) ) :
47
+if ( ! class_exists('Give')) :
48 48
 
49 49
 	/**
50 50
 	 * Main Give Class
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 		 * @return    Give
203 203
 		 */
204 204
 		public static function instance() {
205
-			if ( is_null( self::$_instance ) ) {
205
+			if (is_null(self::$_instance)) {
206 206
 				self::$_instance = new self();
207 207
 			}
208 208
 
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 			$this->includes();
218 218
 			$this->init_hooks();
219 219
 
220
-			do_action( 'give_loaded' );
220
+			do_action('give_loaded');
221 221
 		}
222 222
 
223 223
 		/**
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
 		 * @since  1.8.9
227 227
 		 */
228 228
 		private function init_hooks() {
229
-			register_activation_hook( __FILE__, 'give_install' );
230
-			add_action( 'plugins_loaded', array( $this, 'init' ), 0 );
229
+			register_activation_hook(__FILE__, 'give_install');
230
+			add_action('plugins_loaded', array($this, 'init'), 0);
231 231
 		}
232 232
 		/**
233 233
 		 * Init Give when WordPress Initializes.
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 			 *
242 242
 			 * @since 1.8.9
243 243
 			 */
244
-			do_action( 'before_give_init' );
244
+			do_action('before_give_init');
245 245
 
246 246
 			// Set up localization.
247 247
 			$this->load_textdomain();
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 			 *
267 267
 			 * @since 1.8.7
268 268
 			 */
269
-			do_action( 'give_init', $this );
269
+			do_action('give_init', $this);
270 270
 
271 271
 		}
272 272
 
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 		 */
284 284
 		public function __clone() {
285 285
 			// Cloning instances of the class is forbidden.
286
-			_doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'give' ), '1.0' );
286
+			_doing_it_wrong(__FUNCTION__, __('Cheatin&#8217; huh?', 'give'), '1.0');
287 287
 		}
288 288
 
289 289
 		/**
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 		 */
297 297
 		public function __wakeup() {
298 298
 			// Unserializing instances of the class is forbidden.
299
-			_doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'give' ), '1.0' );
299
+			_doing_it_wrong(__FUNCTION__, __('Cheatin&#8217; huh?', 'give'), '1.0');
300 300
 		}
301 301
 
302 302
 		/**
@@ -310,38 +310,38 @@  discard block
 block discarded – undo
310 310
 		private function setup_constants() {
311 311
 
312 312
 			// Plugin version
313
-			if ( ! defined( 'GIVE_VERSION' ) ) {
314
-				define( 'GIVE_VERSION', '1.8.9' );
313
+			if ( ! defined('GIVE_VERSION')) {
314
+				define('GIVE_VERSION', '1.8.9');
315 315
 			}
316 316
 
317 317
 			// Plugin Folder Path
318
-			if ( ! defined( 'GIVE_PLUGIN_DIR' ) ) {
319
-				define( 'GIVE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
318
+			if ( ! defined('GIVE_PLUGIN_DIR')) {
319
+				define('GIVE_PLUGIN_DIR', plugin_dir_path(__FILE__));
320 320
 			}
321 321
 
322 322
 			// Plugin Folder URL
323
-			if ( ! defined( 'GIVE_PLUGIN_URL' ) ) {
324
-				define( 'GIVE_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
323
+			if ( ! defined('GIVE_PLUGIN_URL')) {
324
+				define('GIVE_PLUGIN_URL', plugin_dir_url(__FILE__));
325 325
 			}
326 326
 
327 327
 			// Plugin Basename aka: "give/give.php"
328
-			if ( ! defined( 'GIVE_PLUGIN_BASENAME' ) ) {
329
-				define( 'GIVE_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
328
+			if ( ! defined('GIVE_PLUGIN_BASENAME')) {
329
+				define('GIVE_PLUGIN_BASENAME', plugin_basename(__FILE__));
330 330
 			}
331 331
 
332 332
 			// Plugin Root File
333
-			if ( ! defined( 'GIVE_PLUGIN_FILE' ) ) {
334
-				define( 'GIVE_PLUGIN_FILE', __FILE__ );
333
+			if ( ! defined('GIVE_PLUGIN_FILE')) {
334
+				define('GIVE_PLUGIN_FILE', __FILE__);
335 335
 			}
336 336
 
337 337
 			// Make sure CAL_GREGORIAN is defined
338
-			if ( ! defined( 'CAL_GREGORIAN' ) ) {
339
-				define( 'CAL_GREGORIAN', 1 );
338
+			if ( ! defined('CAL_GREGORIAN')) {
339
+				define('CAL_GREGORIAN', 1);
340 340
 			}
341 341
 
342 342
 			// PHP version
343
-			if ( ! defined( 'GIVE_REQUIRED_PHP_VERSION' ) ) {
344
-				define( 'GIVE_REQUIRED_PHP_VERSION', '5.3' );
343
+			if ( ! defined('GIVE_REQUIRED_PHP_VERSION')) {
344
+				define('GIVE_REQUIRED_PHP_VERSION', '5.3');
345 345
 			}
346 346
 		}
347 347
 
@@ -356,128 +356,128 @@  discard block
 block discarded – undo
356 356
 		private function includes() {
357 357
 			global $give_options;
358 358
 
359
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/class-admin-settings.php';
360
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/class-give-settings.php';
359
+			require_once GIVE_PLUGIN_DIR.'includes/admin/class-admin-settings.php';
360
+			require_once GIVE_PLUGIN_DIR.'includes/admin/class-give-settings.php';
361 361
 			$give_options = give_get_settings();
362 362
 
363
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/give-metabox-functions.php';
364
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-cache.php';
365
-			require_once GIVE_PLUGIN_DIR . 'includes/post-types.php';
366
-			require_once GIVE_PLUGIN_DIR . 'includes/scripts.php';
367
-			require_once GIVE_PLUGIN_DIR . 'includes/ajax-functions.php';
368
-			require_once GIVE_PLUGIN_DIR . 'includes/actions.php';
369
-			require_once GIVE_PLUGIN_DIR . 'includes/filters.php';
370
-			require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api.php';
371
-			require_once GIVE_PLUGIN_DIR . 'includes/class-notices.php';
372
-
373
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-roles.php';
374
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-template-loader.php';
375
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-donate-form.php';
376
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-db.php';
377
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-donors.php';
378
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-donor-meta.php';
379
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-donor.php';
380
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-stats.php';
381
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-session.php';
382
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-html-elements.php';
383
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-logging.php';
384
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-license-handler.php';
385
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-cron.php';
386
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-email-access.php';
387
-
388
-			require_once GIVE_PLUGIN_DIR . 'includes/country-functions.php';
389
-			require_once GIVE_PLUGIN_DIR . 'includes/template-functions.php';
390
-			require_once GIVE_PLUGIN_DIR . 'includes/misc-functions.php';
391
-			require_once GIVE_PLUGIN_DIR . 'includes/forms/functions.php';
392
-			require_once GIVE_PLUGIN_DIR . 'includes/forms/template.php';
393
-			require_once GIVE_PLUGIN_DIR . 'includes/forms/widget.php';
394
-			require_once GIVE_PLUGIN_DIR . 'includes/shortcodes.php';
395
-			require_once GIVE_PLUGIN_DIR . 'includes/formatting.php';
396
-			require_once GIVE_PLUGIN_DIR . 'includes/price-functions.php';
397
-			require_once GIVE_PLUGIN_DIR . 'includes/error-tracking.php';
398
-			require_once GIVE_PLUGIN_DIR . 'includes/process-donation.php';
399
-			require_once GIVE_PLUGIN_DIR . 'includes/login-register.php';
400
-			require_once GIVE_PLUGIN_DIR . 'includes/user-functions.php';
401
-			require_once GIVE_PLUGIN_DIR . 'includes/plugin-compatibility.php';
402
-			require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-classes.php';
403
-			require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-functions.php';
404
-			require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-actions.php';
405
-			require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-filters.php';
406
-
407
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/functions.php';
408
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/actions.php';
409
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payment-stats.php';
410
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payments-query.php';
411
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/class-give-payment.php';
412
-
413
-			require_once GIVE_PLUGIN_DIR . 'includes/gateways/functions.php';
414
-			require_once GIVE_PLUGIN_DIR . 'includes/gateways/actions.php';
415
-			require_once GIVE_PLUGIN_DIR . 'includes/gateways/paypal-standard.php';
416
-			require_once GIVE_PLUGIN_DIR . 'includes/gateways/offline-donations.php';
417
-			require_once GIVE_PLUGIN_DIR . 'includes/gateways/manual.php';
418
-
419
-			require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-emails.php';
420
-			require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-email-tags.php';
421
-			require_once GIVE_PLUGIN_DIR . 'includes/emails/functions.php';
422
-			require_once GIVE_PLUGIN_DIR . 'includes/emails/template.php';
423
-			require_once GIVE_PLUGIN_DIR . 'includes/emails/actions.php';
424
-
425
-			if ( defined( 'WP_CLI' ) && WP_CLI ) {
426
-				require_once GIVE_PLUGIN_DIR . 'includes/class-give-cli-commands.php';
363
+			require_once GIVE_PLUGIN_DIR.'includes/admin/give-metabox-functions.php';
364
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-cache.php';
365
+			require_once GIVE_PLUGIN_DIR.'includes/post-types.php';
366
+			require_once GIVE_PLUGIN_DIR.'includes/scripts.php';
367
+			require_once GIVE_PLUGIN_DIR.'includes/ajax-functions.php';
368
+			require_once GIVE_PLUGIN_DIR.'includes/actions.php';
369
+			require_once GIVE_PLUGIN_DIR.'includes/filters.php';
370
+			require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api.php';
371
+			require_once GIVE_PLUGIN_DIR.'includes/class-notices.php';
372
+
373
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-roles.php';
374
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-template-loader.php';
375
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-donate-form.php';
376
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-db.php';
377
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-db-donors.php';
378
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-db-donor-meta.php';
379
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-donor.php';
380
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-stats.php';
381
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-session.php';
382
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-html-elements.php';
383
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-logging.php';
384
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-license-handler.php';
385
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-cron.php';
386
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-email-access.php';
387
+
388
+			require_once GIVE_PLUGIN_DIR.'includes/country-functions.php';
389
+			require_once GIVE_PLUGIN_DIR.'includes/template-functions.php';
390
+			require_once GIVE_PLUGIN_DIR.'includes/misc-functions.php';
391
+			require_once GIVE_PLUGIN_DIR.'includes/forms/functions.php';
392
+			require_once GIVE_PLUGIN_DIR.'includes/forms/template.php';
393
+			require_once GIVE_PLUGIN_DIR.'includes/forms/widget.php';
394
+			require_once GIVE_PLUGIN_DIR.'includes/shortcodes.php';
395
+			require_once GIVE_PLUGIN_DIR.'includes/formatting.php';
396
+			require_once GIVE_PLUGIN_DIR.'includes/price-functions.php';
397
+			require_once GIVE_PLUGIN_DIR.'includes/error-tracking.php';
398
+			require_once GIVE_PLUGIN_DIR.'includes/process-donation.php';
399
+			require_once GIVE_PLUGIN_DIR.'includes/login-register.php';
400
+			require_once GIVE_PLUGIN_DIR.'includes/user-functions.php';
401
+			require_once GIVE_PLUGIN_DIR.'includes/plugin-compatibility.php';
402
+			require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-classes.php';
403
+			require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-functions.php';
404
+			require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-actions.php';
405
+			require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-filters.php';
406
+
407
+			require_once GIVE_PLUGIN_DIR.'includes/payments/functions.php';
408
+			require_once GIVE_PLUGIN_DIR.'includes/payments/actions.php';
409
+			require_once GIVE_PLUGIN_DIR.'includes/payments/class-payment-stats.php';
410
+			require_once GIVE_PLUGIN_DIR.'includes/payments/class-payments-query.php';
411
+			require_once GIVE_PLUGIN_DIR.'includes/payments/class-give-payment.php';
412
+
413
+			require_once GIVE_PLUGIN_DIR.'includes/gateways/functions.php';
414
+			require_once GIVE_PLUGIN_DIR.'includes/gateways/actions.php';
415
+			require_once GIVE_PLUGIN_DIR.'includes/gateways/paypal-standard.php';
416
+			require_once GIVE_PLUGIN_DIR.'includes/gateways/offline-donations.php';
417
+			require_once GIVE_PLUGIN_DIR.'includes/gateways/manual.php';
418
+
419
+			require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-emails.php';
420
+			require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-email-tags.php';
421
+			require_once GIVE_PLUGIN_DIR.'includes/emails/functions.php';
422
+			require_once GIVE_PLUGIN_DIR.'includes/emails/template.php';
423
+			require_once GIVE_PLUGIN_DIR.'includes/emails/actions.php';
424
+
425
+			if (defined('WP_CLI') && WP_CLI) {
426
+				require_once GIVE_PLUGIN_DIR.'includes/class-give-cli-commands.php';
427 427
 			}
428 428
 
429
-			if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
430
-
431
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-footer.php';
432
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/welcome.php';
433
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-pages.php';
434
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/class-api-keys-table.php';
435
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/class-i18n-module.php';
436
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-actions.php';
437
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-filters.php';
438
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/system-info.php';
439
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/add-ons.php';
440
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/plugins.php';
441
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/dashboard-widgets.php';
442
-
443
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/actions.php';
444
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/payments-history.php';
445
-
446
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donors.php';
447
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donor-functions.php';
448
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donor-actions.php';
449
-
450
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/metabox.php';
451
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/class-metabox-form-data.php';
452
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/dashboard-columns.php';
453
-
454
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/export-functions.php';
455
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-export.php';
456
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/export-actions.php';
457
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/pdf-reports.php';
458
-
459
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/reports.php';
460
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-give-graph.php';
461
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/graphing.php';
462
-
463
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/tools-actions.php';
464
-
465
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/abstract-shortcode-generator.php';
466
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/class-shortcode-button.php';
467
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-form.php';
468
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-goal.php';
469
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-login.php';
470
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-register.php';
471
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-profile-editor.php';
472
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-donation-history.php';
473
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-receipt.php';
474
-
475
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php';
476
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrades.php';
429
+			if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
430
+
431
+				require_once GIVE_PLUGIN_DIR.'includes/admin/admin-footer.php';
432
+				require_once GIVE_PLUGIN_DIR.'includes/admin/welcome.php';
433
+				require_once GIVE_PLUGIN_DIR.'includes/admin/admin-pages.php';
434
+				require_once GIVE_PLUGIN_DIR.'includes/admin/class-api-keys-table.php';
435
+				require_once GIVE_PLUGIN_DIR.'includes/admin/class-i18n-module.php';
436
+				require_once GIVE_PLUGIN_DIR.'includes/admin/admin-actions.php';
437
+				require_once GIVE_PLUGIN_DIR.'includes/admin/admin-filters.php';
438
+				require_once GIVE_PLUGIN_DIR.'includes/admin/system-info.php';
439
+				require_once GIVE_PLUGIN_DIR.'includes/admin/add-ons.php';
440
+				require_once GIVE_PLUGIN_DIR.'includes/admin/plugins.php';
441
+				require_once GIVE_PLUGIN_DIR.'includes/admin/dashboard-widgets.php';
442
+
443
+				require_once GIVE_PLUGIN_DIR.'includes/admin/payments/actions.php';
444
+				require_once GIVE_PLUGIN_DIR.'includes/admin/payments/payments-history.php';
445
+
446
+				require_once GIVE_PLUGIN_DIR.'includes/admin/donors/donors.php';
447
+				require_once GIVE_PLUGIN_DIR.'includes/admin/donors/donor-functions.php';
448
+				require_once GIVE_PLUGIN_DIR.'includes/admin/donors/donor-actions.php';
449
+
450
+				require_once GIVE_PLUGIN_DIR.'includes/admin/forms/metabox.php';
451
+				require_once GIVE_PLUGIN_DIR.'includes/admin/forms/class-metabox-form-data.php';
452
+				require_once GIVE_PLUGIN_DIR.'includes/admin/forms/dashboard-columns.php';
453
+
454
+				require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/export-functions.php';
455
+				require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/class-export.php';
456
+				require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/export-actions.php';
457
+				require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/pdf-reports.php';
458
+
459
+				require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/reports.php';
460
+				require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-give-graph.php';
461
+				require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/graphing.php';
462
+
463
+				require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/tools-actions.php';
464
+
465
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/abstract-shortcode-generator.php';
466
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/class-shortcode-button.php';
467
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-form.php';
468
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-goal.php';
469
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-login.php';
470
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-register.php';
471
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-profile-editor.php';
472
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-donation-history.php';
473
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-receipt.php';
474
+
475
+				require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php';
476
+				require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrades.php';
477 477
 
478 478
 			}// End if().
479 479
 
480
-			require_once GIVE_PLUGIN_DIR . 'includes/install.php';
480
+			require_once GIVE_PLUGIN_DIR.'includes/install.php';
481 481
 
482 482
 		}
483 483
 
@@ -492,16 +492,16 @@  discard block
 block discarded – undo
492 492
 		public function load_textdomain() {
493 493
 
494 494
 			// Set filter for Give's languages directory
495
-			$give_lang_dir = dirname( plugin_basename( GIVE_PLUGIN_FILE ) ) . '/languages/';
496
-			$give_lang_dir = apply_filters( 'give_languages_directory', $give_lang_dir );
495
+			$give_lang_dir = dirname(plugin_basename(GIVE_PLUGIN_FILE)).'/languages/';
496
+			$give_lang_dir = apply_filters('give_languages_directory', $give_lang_dir);
497 497
 
498 498
 			// Traditional WordPress plugin locale filter.
499
-			$locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
500
-			$locale = apply_filters( 'plugin_locale', $locale, 'give' );
499
+			$locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale();
500
+			$locale = apply_filters('plugin_locale', $locale, 'give');
501 501
 
502
-			unload_textdomain( 'give' );
503
-			load_textdomain( 'give', WP_LANG_DIR . '/give/give-' . $locale . '.mo' );
504
-			load_plugin_textdomain( 'give', false, $give_lang_dir );
502
+			unload_textdomain('give');
503
+			load_textdomain('give', WP_LANG_DIR.'/give/give-'.$locale.'.mo');
504
+			load_plugin_textdomain('give', false, $give_lang_dir);
505 505
 
506 506
 		}
507 507
 
Please login to merge, or discard this patch.
includes/process-donation.php 1 patch
Spacing   +239 added lines, -239 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
 
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @since 1.0
32 32
 	 */
33
-	do_action( 'give_pre_process_donation' );
33
+	do_action('give_pre_process_donation');
34 34
 
35 35
 	// Validate the form $_POST data
36 36
 	$valid_data = give_donation_form_validate_fields();
@@ -45,26 +45,26 @@  discard block
 block discarded – undo
45 45
 	 * @param bool|array $valid_data Validate fields.
46 46
 	 * @param array $_POST Array of variables passed via the HTTP POST.
47 47
 	 */
48
-	do_action( 'give_checkout_error_checks', $valid_data, $_POST );
48
+	do_action('give_checkout_error_checks', $valid_data, $_POST);
49 49
 
50
-	$is_ajax = isset( $_POST['give_ajax'] );
50
+	$is_ajax = isset($_POST['give_ajax']);
51 51
 
52 52
 	// Process the login form
53
-	if ( isset( $_POST['give_login_submit'] ) ) {
53
+	if (isset($_POST['give_login_submit'])) {
54 54
 		give_process_form_login();
55 55
 	}
56 56
 
57 57
 	// Validate the user
58
-	$user = give_get_donation_form_user( $valid_data );
58
+	$user = give_get_donation_form_user($valid_data);
59 59
 
60
-	if ( false === $valid_data || give_get_errors() || ! $user ) {
61
-		if ( $is_ajax ) {
60
+	if (false === $valid_data || give_get_errors() || ! $user) {
61
+		if ($is_ajax) {
62 62
 			/**
63 63
 			 * Fires when AJAX sends back errors from the donation form.
64 64
 			 *
65 65
 			 * @since 1.0
66 66
 			 */
67
-			do_action( 'give_ajax_donation_errors' );
67
+			do_action('give_ajax_donation_errors');
68 68
 			give_die();
69 69
 		} else {
70 70
 			return false;
@@ -72,17 +72,17 @@  discard block
 block discarded – undo
72 72
 	}
73 73
 
74 74
 	// If AJAX send back success to proceed with form submission
75
-	if ( $is_ajax ) {
75
+	if ($is_ajax) {
76 76
 		echo 'success';
77 77
 		give_die();
78 78
 	}
79 79
 
80 80
 	// After AJAX: Setup session if not using php_sessions
81
-	if ( ! Give()->session->use_php_sessions() ) {
81
+	if ( ! Give()->session->use_php_sessions()) {
82 82
 		// Double-check that set_cookie is publicly accessible;
83 83
 		// we're using a slightly modified class-wp-sessions.php
84
-		$session_reflection = new ReflectionMethod( 'WP_Session', 'set_cookie' );
85
-		if ( $session_reflection->isPublic() ) {
84
+		$session_reflection = new ReflectionMethod('WP_Session', 'set_cookie');
85
+		if ($session_reflection->isPublic()) {
86 86
 			// Manually set the cookie.
87 87
 			Give()->session->init()->set_cookie();
88 88
 		}
@@ -97,18 +97,18 @@  discard block
 block discarded – undo
97 97
 		'address'    => $user['address'],
98 98
 	);
99 99
 
100
-	$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
100
+	$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
101 101
 
102
-	$price        = isset( $_POST['give-amount'] ) ? (float) apply_filters( 'give_donation_total', give_sanitize_amount( give_format_amount( $_POST['give-amount'] ) ) ) : '0.00';
103
-	$purchase_key = strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) );
102
+	$price        = isset($_POST['give-amount']) ? (float) apply_filters('give_donation_total', give_sanitize_amount(give_format_amount($_POST['give-amount']))) : '0.00';
103
+	$purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true)));
104 104
 
105 105
 	// Setup donation information
106 106
 	$donation_data = array(
107 107
 		'price'        => $price,
108 108
 		'purchase_key' => $purchase_key,
109 109
 		'user_email'   => $user['user_email'],
110
-		'date'         => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ),
111
-		'user_info'    => stripslashes_deep( $user_info ),
110
+		'date'         => date('Y-m-d H:i:s', current_time('timestamp')),
111
+		'user_info'    => stripslashes_deep($user_info),
112 112
 		'post_data'    => $_POST,
113 113
 		'gateway'      => $valid_data['gateway'],
114 114
 		'card_info'    => $valid_data['cc_info'],
@@ -128,10 +128,10 @@  discard block
 block discarded – undo
128 128
 	 * @param array $user_info Array containing basic user information.
129 129
 	 * @param bool|array $valid_data Validate fields.
130 130
 	 */
131
-	do_action( 'give_checkout_before_gateway', $_POST, $user_info, $valid_data );
131
+	do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data);
132 132
 
133 133
 	// Sanity check for price
134
-	if ( ! $donation_data['price'] ) {
134
+	if ( ! $donation_data['price']) {
135 135
 		// Revert to manual
136 136
 		$donation_data['gateway'] = 'manual';
137 137
 		$_POST['give-gateway']    = 'manual';
@@ -142,27 +142,27 @@  discard block
 block discarded – undo
142 142
 	 *
143 143
 	 * @since 1.7
144 144
 	 */
145
-	$donation_data = apply_filters( 'give_donation_data_before_gateway', $donation_data, $valid_data );
145
+	$donation_data = apply_filters('give_donation_data_before_gateway', $donation_data, $valid_data);
146 146
 
147 147
 	// Setup the data we're storing in the donation session
148 148
 	$session_data = $donation_data;
149 149
 
150 150
 	// Make sure credit card numbers are never stored in sessions
151
-	unset( $session_data['card_info']['card_number'] );
152
-	unset( $session_data['post_data']['card_number'] );
151
+	unset($session_data['card_info']['card_number']);
152
+	unset($session_data['post_data']['card_number']);
153 153
 
154 154
 	// Used for showing data to non logged-in users after donation, and for other plugins needing donation data.
155
-	give_set_purchase_session( $session_data );
155
+	give_set_purchase_session($session_data);
156 156
 
157 157
 	// Send info to the gateway for payment processing
158
-	give_send_to_gateway( $donation_data['gateway'], $donation_data );
158
+	give_send_to_gateway($donation_data['gateway'], $donation_data);
159 159
 	give_die();
160 160
 
161 161
 }
162 162
 
163
-add_action( 'give_purchase', 'give_process_donation_form' );
164
-add_action( 'wp_ajax_give_process_donation', 'give_process_donation_form' );
165
-add_action( 'wp_ajax_nopriv_give_process_donation', 'give_process_donation_form' );
163
+add_action('give_purchase', 'give_process_donation_form');
164
+add_action('wp_ajax_give_process_donation', 'give_process_donation_form');
165
+add_action('wp_ajax_nopriv_give_process_donation', 'give_process_donation_form');
166 166
 
167 167
 
168 168
 /**
@@ -175,29 +175,29 @@  discard block
 block discarded – undo
175 175
  *
176 176
  * @return void
177 177
  */
178
-function give_check_logged_in_user_for_existing_email( $valid_data, $post ) {
178
+function give_check_logged_in_user_for_existing_email($valid_data, $post) {
179 179
 
180 180
 	// Verify that the email address belongs to this customer.
181
-	if ( is_user_logged_in() ) {
181
+	if (is_user_logged_in()) {
182 182
 
183
-		$submitted_email    = $valid_data['logged_in_user']['user_email'];
184
-		$customer = new Give_Donor( get_current_user_id(), true );
183
+		$submitted_email = $valid_data['logged_in_user']['user_email'];
184
+		$customer = new Give_Donor(get_current_user_id(), true);
185 185
 
186 186
 		// If this email address is not registered with this customer, see if it belongs to any other customer
187 187
 		if (
188 188
 			$submitted_email !== $customer->email
189
-			&& ( is_array( $customer->emails ) && ! in_array( $submitted_email, $customer->emails ) )
189
+			&& (is_array($customer->emails) && ! in_array($submitted_email, $customer->emails))
190 190
 		) {
191
-			$found_customer = new Give_Donor( $submitted_email );
191
+			$found_customer = new Give_Donor($submitted_email);
192 192
 
193
-			if ( $found_customer->id > 0 ) {
194
-				give_set_error( 'give-customer-email-exists', sprintf( __( 'You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.' ,'give' ), $customer->email, $submitted_email ) );
193
+			if ($found_customer->id > 0) {
194
+				give_set_error('give-customer-email-exists', sprintf(__('You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.', 'give'), $customer->email, $submitted_email));
195 195
 			}
196 196
 		}
197 197
 	}
198 198
 }
199 199
 
200
-add_action( 'give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2 );
200
+add_action('give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2);
201 201
 
202 202
 /**
203 203
  * Process the checkout login form
@@ -208,37 +208,37 @@  discard block
 block discarded – undo
208 208
  */
209 209
 function give_process_form_login() {
210 210
 
211
-	$is_ajax = isset( $_POST['give_ajax'] );
211
+	$is_ajax = isset($_POST['give_ajax']);
212 212
 
213 213
 	$user_data = give_donation_form_validate_user_login();
214 214
 
215
-	if ( give_get_errors() || $user_data['user_id'] < 1 ) {
216
-		if ( $is_ajax ) {
215
+	if (give_get_errors() || $user_data['user_id'] < 1) {
216
+		if ($is_ajax) {
217 217
 			/**
218 218
 			 * Fires when AJAX sends back errors from the donation form.
219 219
 			 *
220 220
 			 * @since 1.0
221 221
 			 */
222
-			do_action( 'give_ajax_donation_errors' );
222
+			do_action('give_ajax_donation_errors');
223 223
 			give_die();
224 224
 		} else {
225
-			wp_redirect( $_SERVER['HTTP_REFERER'] );
225
+			wp_redirect($_SERVER['HTTP_REFERER']);
226 226
 			exit;
227 227
 		}
228 228
 	}
229 229
 
230
-	give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] );
230
+	give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']);
231 231
 
232
-	if ( $is_ajax ) {
232
+	if ($is_ajax) {
233 233
 		echo 'success';
234 234
 		give_die();
235 235
 	} else {
236
-		wp_redirect( $_SERVER['HTTP_REFERER'] );
236
+		wp_redirect($_SERVER['HTTP_REFERER']);
237 237
 	}
238 238
 }
239 239
 
240
-add_action( 'wp_ajax_give_process_donation_login', 'give_process_form_login' );
241
-add_action( 'wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login' );
240
+add_action('wp_ajax_give_process_donation_login', 'give_process_form_login');
241
+add_action('wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login');
242 242
 
243 243
 /**
244 244
  * Donation Form Validate Fields.
@@ -250,55 +250,55 @@  discard block
 block discarded – undo
250 250
 function give_donation_form_validate_fields() {
251 251
 
252 252
 	// Check if there is $_POST
253
-	if ( empty( $_POST ) ) {
253
+	if (empty($_POST)) {
254 254
 		return false;
255 255
 	}
256 256
 
257
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
257
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
258 258
 
259 259
 	// Start an array to collect valid data
260 260
 	$valid_data = array(
261 261
 		'gateway'          => give_donation_form_validate_gateway(), // Gateway fallback (amount is validated here)
262
-		'need_new_user'    => false,     // New user flag
263
-		'need_user_login'  => false,     // Login user flag
264
-		'logged_user_data' => array(),   // Logged user collected data
265
-		'new_user_data'    => array(),   // New user collected data
266
-		'login_user_data'  => array(),   // Login user collected data
267
-		'guest_user_data'  => array(),   // Guest user collected data
268
-		'cc_info'          => give_donation_form_validate_cc(),// Credit card info
262
+		'need_new_user'    => false, // New user flag
263
+		'need_user_login'  => false, // Login user flag
264
+		'logged_user_data' => array(), // Logged user collected data
265
+		'new_user_data'    => array(), // New user collected data
266
+		'login_user_data'  => array(), // Login user collected data
267
+		'guest_user_data'  => array(), // Guest user collected data
268
+		'cc_info'          => give_donation_form_validate_cc(), // Credit card info
269 269
 	);
270 270
 
271 271
 	// Validate Honeypot First
272
-	if ( ! empty( $_POST['give-honeypot'] ) ) {
273
-		give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) );
272
+	if ( ! empty($_POST['give-honeypot'])) {
273
+		give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give'));
274 274
 	}
275 275
 
276 276
 	// Validate agree to terms
277
-	if ( give_is_terms_enabled( $form_id ) ) {
277
+	if (give_is_terms_enabled($form_id)) {
278 278
 		give_donation_form_validate_agree_to_terms();
279 279
 	}
280 280
 
281 281
 	// Stop processing donor registration, if donor registration is optional and donor can do guest checkout.
282 282
 	// If registration form username field is empty that means donor do not want to registration instead want guest checkout.
283 283
 	if (
284
-		! give_logged_in_only( $form_id )
285
-		&& isset( $_POST['give-purchase-var'] )
284
+		! give_logged_in_only($form_id)
285
+		&& isset($_POST['give-purchase-var'])
286 286
 		&& $_POST['give-purchase-var'] == 'needs-to-register'
287
-		&& empty( $_POST['give_user_login'] )
287
+		&& empty($_POST['give_user_login'])
288 288
 	) {
289
-		unset( $_POST['give-purchase-var'] );
289
+		unset($_POST['give-purchase-var']);
290 290
 	}
291 291
 
292
-	if ( is_user_logged_in() ) {
292
+	if (is_user_logged_in()) {
293 293
 		// Collect logged in user data.
294 294
 		$valid_data['logged_in_user'] = give_donation_form_validate_logged_in_user();
295
-	} elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) {
295
+	} elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') {
296 296
 		// Set new user registration as required.
297 297
 		$valid_data['need_new_user'] = true;
298 298
 		// Validate new user data.
299 299
 		$valid_data['new_user_data'] = give_donation_form_validate_new_user();
300 300
 		// Check if login validation is needed.
301
-	} elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) {
301
+	} elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') {
302 302
 		// Set user login as required.
303 303
 		$valid_data['need_user_login'] = true;
304 304
 		// Validate users login info.
@@ -323,41 +323,41 @@  discard block
 block discarded – undo
323 323
  */
324 324
 function give_donation_form_validate_gateway() {
325 325
 
326
-	$form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
327
-	$amount  = isset( $_REQUEST['give-amount'] ) ? give_sanitize_amount( $_REQUEST['give-amount'] ) : 0;
328
-	$gateway = give_get_default_gateway( $form_id );
326
+	$form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
327
+	$amount  = isset($_REQUEST['give-amount']) ? give_sanitize_amount($_REQUEST['give-amount']) : 0;
328
+	$gateway = give_get_default_gateway($form_id);
329 329
 
330 330
 	// Check if a gateway value is present.
331
-	if ( ! empty( $_REQUEST['give-gateway'] ) ) {
331
+	if ( ! empty($_REQUEST['give-gateway'])) {
332 332
 
333
-		$gateway = sanitize_text_field( $_REQUEST['give-gateway'] );
333
+		$gateway = sanitize_text_field($_REQUEST['give-gateway']);
334 334
 
335 335
 		// Is amount being donated in LIVE mode 0.00? If so, error:
336
-		if ( $amount == 0 && ! give_is_test_mode() ) {
336
+		if ($amount == 0 && ! give_is_test_mode()) {
337 337
 
338
-			give_set_error( 'invalid_donation_amount', __( 'Please insert a valid donation amount.', 'give' ) );
338
+			give_set_error('invalid_donation_amount', __('Please insert a valid donation amount.', 'give'));
339 339
 
340 340
 		} // End if().
341
-		elseif ( ! give_verify_minimum_price() ) {
341
+		elseif ( ! give_verify_minimum_price()) {
342 342
 			// translators: %s: minimum donation amount.
343 343
 			give_set_error(
344 344
 				'invalid_donation_minimum',
345 345
 				sprintf(
346 346
 					/* translators: %s: minimum donation amount */
347
-					__( 'This form has a minimum donation amount of %s.', 'give' ),
348
-					give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ) ) )
347
+					__('This form has a minimum donation amount of %s.', 'give'),
348
+					give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id)))
349 349
 				)
350 350
 			);
351 351
 
352 352
 		} //Is this test mode zero donation? Let it through but set to manual gateway.
353
-		elseif ( $amount == 0 && give_is_test_mode() ) {
353
+		elseif ($amount == 0 && give_is_test_mode()) {
354 354
 
355 355
 			$gateway = 'manual';
356 356
 
357 357
 		} //Check if this gateway is active.
358
-		elseif ( ! give_is_gateway_active( $gateway ) ) {
358
+		elseif ( ! give_is_gateway_active($gateway)) {
359 359
 
360
-			give_set_error( 'invalid_gateway', __( 'The selected payment gateway is not enabled.', 'give' ) );
360
+			give_set_error('invalid_gateway', __('The selected payment gateway is not enabled.', 'give'));
361 361
 
362 362
 		}
363 363
 	}
@@ -375,21 +375,21 @@  discard block
 block discarded – undo
375 375
  */
376 376
 function give_verify_minimum_price() {
377 377
 
378
-	$amount          = give_sanitize_amount( $_REQUEST['give-amount'] );
379
-	$form_id         = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
380
-	$price_id        = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : null;
381
-	$variable_prices = give_has_variable_prices( $form_id );
378
+	$amount          = give_sanitize_amount($_REQUEST['give-amount']);
379
+	$form_id         = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
380
+	$price_id        = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : null;
381
+	$variable_prices = give_has_variable_prices($form_id);
382 382
 
383
-	if ( $variable_prices && in_array( $price_id, give_get_variable_price_ids( $form_id ) ) ) {
383
+	if ($variable_prices && in_array($price_id, give_get_variable_price_ids($form_id))) {
384 384
 
385
-		$price_level_amount = give_get_price_option_amount( $form_id, $price_id );
385
+		$price_level_amount = give_get_price_option_amount($form_id, $price_id);
386 386
 
387
-		if ( $price_level_amount == $amount ) {
387
+		if ($price_level_amount == $amount) {
388 388
 			return true;
389 389
 		}
390 390
 	}
391 391
 
392
-	if ( give_get_form_minimum_price( $form_id ) > $amount ) {
392
+	if (give_get_form_minimum_price($form_id) > $amount) {
393 393
 		return false;
394 394
 	}
395 395
 
@@ -405,9 +405,9 @@  discard block
 block discarded – undo
405 405
  */
406 406
 function give_donation_form_validate_agree_to_terms() {
407 407
 	// Validate agree to terms.
408
-	if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) {
408
+	if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) {
409 409
 		// User did not agree.
410
-		give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', __( 'You must agree to the terms and conditions.', 'give' ) ) );
410
+		give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', __('You must agree to the terms and conditions.', 'give')));
411 411
 	}
412 412
 }
413 413
 
@@ -421,43 +421,43 @@  discard block
 block discarded – undo
421 421
  *
422 422
  * @return      array
423 423
  */
424
-function give_get_required_fields( $form_id ) {
424
+function give_get_required_fields($form_id) {
425 425
 
426
-	$payment_mode = give_get_chosen_gateway( $form_id );
426
+	$payment_mode = give_get_chosen_gateway($form_id);
427 427
 
428 428
 	$required_fields = array(
429 429
 		'give_email' => array(
430 430
 			'error_id'      => 'invalid_email',
431
-			'error_message' => __( 'Please enter a valid email address.', 'give' ),
431
+			'error_message' => __('Please enter a valid email address.', 'give'),
432 432
 		),
433 433
 		'give_first' => array(
434 434
 			'error_id'      => 'invalid_first_name',
435
-			'error_message' => __( 'Please enter your first name.', 'give' ),
435
+			'error_message' => __('Please enter your first name.', 'give'),
436 436
 		),
437 437
 	);
438 438
 
439
-	$require_address = give_require_billing_address( $payment_mode );
439
+	$require_address = give_require_billing_address($payment_mode);
440 440
 
441
-	if ( $require_address ) {
442
-		$required_fields['card_address']    = array(
441
+	if ($require_address) {
442
+		$required_fields['card_address'] = array(
443 443
 			'error_id'      => 'invalid_card_address',
444
-			'error_message' => __( 'Please enter your primary billing address.', 'give' ),
444
+			'error_message' => __('Please enter your primary billing address.', 'give'),
445 445
 		);
446
-		$required_fields['card_zip']        = array(
446
+		$required_fields['card_zip'] = array(
447 447
 			'error_id'      => 'invalid_zip_code',
448
-			'error_message' => __( 'Please enter your zip / postal code.', 'give' ),
448
+			'error_message' => __('Please enter your zip / postal code.', 'give'),
449 449
 		);
450
-		$required_fields['card_city']       = array(
450
+		$required_fields['card_city'] = array(
451 451
 			'error_id'      => 'invalid_city',
452
-			'error_message' => __( 'Please enter your billing city.', 'give' ),
452
+			'error_message' => __('Please enter your billing city.', 'give'),
453 453
 		);
454 454
 		$required_fields['billing_country'] = array(
455 455
 			'error_id'      => 'invalid_country',
456
-			'error_message' => __( 'Please select your billing country.', 'give' ),
456
+			'error_message' => __('Please select your billing country.', 'give'),
457 457
 		);
458
-		$required_fields['card_state']      = array(
458
+		$required_fields['card_state'] = array(
459 459
 			'error_id'      => 'invalid_state',
460
-			'error_message' => __( 'Please enter billing state / province.', 'give' ),
460
+			'error_message' => __('Please enter billing state / province.', 'give'),
461 461
 		);
462 462
 	}
463 463
 
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 	 *
467 467
 	 * @since 1.7
468 468
 	 */
469
-	$required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id );
469
+	$required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id);
470 470
 
471 471
 	return $required_fields;
472 472
 
@@ -481,16 +481,16 @@  discard block
 block discarded – undo
481 481
  *
482 482
  * @return bool
483 483
  */
484
-function give_require_billing_address( $payment_mode ) {
484
+function give_require_billing_address($payment_mode) {
485 485
 
486 486
 	$return = false;
487 487
 
488
-	if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) {
488
+	if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) {
489 489
 		$return = true;
490 490
 	}
491 491
 
492 492
 	// Let payment gateways and other extensions determine if address fields should be required.
493
-	return apply_filters( 'give_require_billing_address', $return );
493
+	return apply_filters('give_require_billing_address', $return);
494 494
 
495 495
 }
496 496
 
@@ -504,42 +504,42 @@  discard block
 block discarded – undo
504 504
 function give_donation_form_validate_logged_in_user() {
505 505
 	global $user_ID;
506 506
 
507
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
507
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
508 508
 
509 509
 	// Start empty array to collect valid user data.
510 510
 	$valid_user_data = array(
511 511
 		// Assume there will be errors.
512
-		'user_id' => - 1,
512
+		'user_id' => -1,
513 513
 	);
514 514
 
515 515
 	// Verify there is a user_ID.
516
-	if ( $user_ID > 0 ) {
516
+	if ($user_ID > 0) {
517 517
 		// Get the logged in user data.
518
-		$user_data = get_userdata( $user_ID );
518
+		$user_data = get_userdata($user_ID);
519 519
 
520 520
 		// Loop through required fields and show error messages.
521
-		foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
522
-			if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
523
-				give_set_error( $value['error_id'], $value['error_message'] );
521
+		foreach (give_get_required_fields($form_id) as $field_name => $value) {
522
+			if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
523
+				give_set_error($value['error_id'], $value['error_message']);
524 524
 			}
525 525
 		}
526 526
 
527 527
 		// Verify data.
528
-		if ( $user_data ) {
528
+		if ($user_data) {
529 529
 			// Collected logged in user data.
530 530
 			$valid_user_data = array(
531 531
 				'user_id'    => $user_ID,
532
-				'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email,
533
-				'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name,
534
-				'user_last'  => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name,
532
+				'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email,
533
+				'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name,
534
+				'user_last'  => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name,
535 535
 			);
536 536
 
537
-			if ( ! is_email( $valid_user_data['user_email'] ) ) {
538
-				give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
537
+			if ( ! is_email($valid_user_data['user_email'])) {
538
+				give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
539 539
 			}
540 540
 		} else {
541 541
 			// Set invalid user error.
542
-			give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) );
542
+			give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give'));
543 543
 		}
544 544
 	}
545 545
 
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
 	// Default user data.
559 559
 	$default_user_data = array(
560 560
 		'give-form-id'           => '',
561
-		'user_id'                => - 1, // Assume there will be errors.
561
+		'user_id'                => -1, // Assume there will be errors.
562 562
 		'user_first'             => '',
563 563
 		'user_last'              => '',
564 564
 		'give_user_login'        => false,
@@ -568,14 +568,14 @@  discard block
 block discarded – undo
568 568
 	);
569 569
 
570 570
 	// Get user data.
571
-	$user_data            = wp_parse_args( array_map( 'trim', give_clean( $_POST ) ), $default_user_data );
571
+	$user_data            = wp_parse_args(array_map('trim', give_clean($_POST)), $default_user_data);
572 572
 	$registering_new_user = false;
573
-	$form_id              = absint( $user_data['give-form-id'] );
573
+	$form_id              = absint($user_data['give-form-id']);
574 574
 
575 575
 	// Start an empty array to collect valid user data.
576 576
 	$valid_user_data = array(
577 577
 		// Assume there will be errors.
578
-		'user_id'    => - 1,
578
+		'user_id'    => -1,
579 579
 
580 580
 		// Get first name.
581 581
 		'user_first' => $user_data['give_first'],
@@ -585,25 +585,25 @@  discard block
 block discarded – undo
585 585
 	);
586 586
 
587 587
 	// Loop through required fields and show error messages.
588
-	foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
589
-		if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
590
-			give_set_error( $value['error_id'], $value['error_message'] );
588
+	foreach (give_get_required_fields($form_id) as $field_name => $value) {
589
+		if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
590
+			give_set_error($value['error_id'], $value['error_message']);
591 591
 		}
592 592
 	}
593 593
 
594 594
 	// Check if we have an username to register.
595
-	if ( give_validate_username( $user_data['give_user_login'] ) ) {
595
+	if (give_validate_username($user_data['give_user_login'])) {
596 596
 		$registering_new_user          = true;
597 597
 		$valid_user_data['user_login'] = $user_data['give_user_login'];
598 598
 	}
599 599
 
600 600
 	// Check if we have an email to verify.
601
-	if ( give_validate_user_email( $user_data['give_email'], $registering_new_user ) ) {
601
+	if (give_validate_user_email($user_data['give_email'], $registering_new_user)) {
602 602
 		$valid_user_data['user_email'] = $user_data['give_email'];
603 603
 	}
604 604
 
605 605
 	// Check password.
606
-	if ( give_validate_user_password( $user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user ) ) {
606
+	if (give_validate_user_password($user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user)) {
607 607
 		// All is good to go.
608 608
 		$valid_user_data['user_pass'] = $user_data['give_user_pass'];
609 609
 	}
@@ -623,36 +623,36 @@  discard block
 block discarded – undo
623 623
 	// Start an array to collect valid user data.
624 624
 	$valid_user_data = array(
625 625
 		// Assume there will be errors.
626
-		'user_id' => - 1,
626
+		'user_id' => -1,
627 627
 	);
628 628
 
629 629
 	// Username.
630
-	if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) {
631
-		give_set_error( 'must_log_in', __( 'You must register or login to complete your donation.', 'give' ) );
630
+	if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') {
631
+		give_set_error('must_log_in', __('You must register or login to complete your donation.', 'give'));
632 632
 
633 633
 		return $valid_user_data;
634 634
 	}
635 635
 
636 636
 	// Get the user by login.
637
-	$user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) );
637
+	$user_data = get_user_by('login', strip_tags($_POST['give_user_login']));
638 638
 
639 639
 	// Check if user exists.
640
-	if ( $user_data ) {
640
+	if ($user_data) {
641 641
 		// Get password.
642
-		$user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false;
642
+		$user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false;
643 643
 
644 644
 		// Check user_pass.
645
-		if ( $user_pass ) {
645
+		if ($user_pass) {
646 646
 			// Check if password is valid.
647
-			if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) {
647
+			if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) {
648 648
 				// Incorrect password.
649 649
 				give_set_error(
650 650
 					'password_incorrect',
651 651
 					sprintf(
652 652
 						'%1$s <a href="%2$s">%3$s</a>',
653
-						__( 'The password you entered is incorrect.', 'give' ),
654
-						wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ),
655
-						__( 'Reset Password', 'give' )
653
+						__('The password you entered is incorrect.', 'give'),
654
+						wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"),
655
+						__('Reset Password', 'give')
656 656
 					)
657 657
 				);
658 658
 				// All is correct.
@@ -669,11 +669,11 @@  discard block
 block discarded – undo
669 669
 			}
670 670
 		} else {
671 671
 			// Empty password.
672
-			give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) );
672
+			give_set_error('password_empty', __('Enter a password.', 'give'));
673 673
 		}
674 674
 	} else {
675 675
 		// No username.
676
-		give_set_error( 'username_incorrect', __( 'The username you entered does not exist.', 'give' ) );
676
+		give_set_error('username_incorrect', __('The username you entered does not exist.', 'give'));
677 677
 	}// End if().
678 678
 
679 679
 	return $valid_user_data;
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
  */
689 689
 function give_donation_form_validate_guest_user() {
690 690
 
691
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
691
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
692 692
 
693 693
 	// Start an array to collect valid user data.
694 694
 	$valid_user_data = array(
@@ -697,38 +697,38 @@  discard block
 block discarded – undo
697 697
 	);
698 698
 
699 699
 	// Show error message if user must be logged in.
700
-	if ( give_logged_in_only( $form_id ) ) {
701
-		give_set_error( 'logged_in_only', __( 'You must be logged in to donate.', 'give' ) );
700
+	if (give_logged_in_only($form_id)) {
701
+		give_set_error('logged_in_only', __('You must be logged in to donate.', 'give'));
702 702
 	}
703 703
 
704 704
 	// Get the guest email.
705
-	$guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false;
705
+	$guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false;
706 706
 
707 707
 	// Check email.
708
-	if ( $guest_email && strlen( $guest_email ) > 0 ) {
708
+	if ($guest_email && strlen($guest_email) > 0) {
709 709
 		// Validate email.
710
-		if ( ! is_email( $guest_email ) ) {
710
+		if ( ! is_email($guest_email)) {
711 711
 			// Invalid email.
712
-			give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) );
712
+			give_set_error('email_invalid', __('Invalid email.', 'give'));
713 713
 		} else {
714 714
 			// All is good to go.
715 715
 			$valid_user_data['user_email'] = $guest_email;
716 716
 
717 717
 			// Get user_id from donor if exist.
718
-			$donor = new Give_Donor( $guest_email );
719
-			if ( $donor->id && $donor->user_id ) {
718
+			$donor = new Give_Donor($guest_email);
719
+			if ($donor->id && $donor->user_id) {
720 720
 				$valid_user_data['user_id'] = $donor->user_id;
721 721
 			}
722 722
 		}
723 723
 	} else {
724 724
 		// No email.
725
-		give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) );
725
+		give_set_error('email_empty', __('Enter an email.', 'give'));
726 726
 	}
727 727
 
728 728
 	// Loop through required fields and show error messages.
729
-	foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
730
-		if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
731
-			give_set_error( $value['error_id'], $value['error_message'] );
729
+	foreach (give_get_required_fields($form_id) as $field_name => $value) {
730
+		if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
731
+			give_set_error($value['error_id'], $value['error_message']);
732 732
 		}
733 733
 	}
734 734
 
@@ -744,36 +744,36 @@  discard block
 block discarded – undo
744 744
  * @since   1.0
745 745
  * @return  integer
746 746
  */
747
-function give_register_and_login_new_user( $user_data = array() ) {
747
+function give_register_and_login_new_user($user_data = array()) {
748 748
 	// Verify the array.
749
-	if ( empty( $user_data ) ) {
750
-		return - 1;
749
+	if (empty($user_data)) {
750
+		return -1;
751 751
 	}
752 752
 
753
-	if ( give_get_errors() ) {
754
-		return - 1;
753
+	if (give_get_errors()) {
754
+		return -1;
755 755
 	}
756 756
 
757
-	$user_args = apply_filters( 'give_insert_user_args', array(
758
-		'user_login'      => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '',
759
-		'user_pass'       => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '',
760
-		'user_email'      => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '',
761
-		'first_name'      => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '',
762
-		'last_name'       => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '',
763
-		'user_registered' => date( 'Y-m-d H:i:s' ),
764
-		'role'            => get_option( 'default_role' ),
765
-	), $user_data );
757
+	$user_args = apply_filters('give_insert_user_args', array(
758
+		'user_login'      => isset($user_data['user_login']) ? $user_data['user_login'] : '',
759
+		'user_pass'       => isset($user_data['user_pass']) ? $user_data['user_pass'] : '',
760
+		'user_email'      => isset($user_data['user_email']) ? $user_data['user_email'] : '',
761
+		'first_name'      => isset($user_data['user_first']) ? $user_data['user_first'] : '',
762
+		'last_name'       => isset($user_data['user_last']) ? $user_data['user_last'] : '',
763
+		'user_registered' => date('Y-m-d H:i:s'),
764
+		'role'            => get_option('default_role'),
765
+	), $user_data);
766 766
 
767 767
 	// Insert new user.
768
-	$user_id = wp_insert_user( $user_args );
768
+	$user_id = wp_insert_user($user_args);
769 769
 
770 770
 	// Validate inserted user.
771
-	if ( is_wp_error( $user_id ) ) {
772
-		return - 1;
771
+	if (is_wp_error($user_id)) {
772
+		return -1;
773 773
 	}
774 774
 
775 775
 	// Allow themes and plugins to filter the user data.
776
-	$user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args );
776
+	$user_data = apply_filters('give_insert_user_data', $user_data, $user_args);
777 777
 
778 778
 	/**
779 779
 	 * Fires after inserting user.
@@ -783,10 +783,10 @@  discard block
 block discarded – undo
783 783
 	 * @param int $user_id User id.
784 784
 	 * @param array $user_data Array containing user data.
785 785
 	 */
786
-	do_action( 'give_insert_user', $user_id, $user_data );
786
+	do_action('give_insert_user', $user_id, $user_data);
787 787
 
788 788
 	// Login new user.
789
-	give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] );
789
+	give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']);
790 790
 
791 791
 	// Return user id.
792 792
 	return $user_id;
@@ -801,27 +801,27 @@  discard block
 block discarded – undo
801 801
  * @since   1.0
802 802
  * @return  array|bool
803 803
  */
804
-function give_get_donation_form_user( $valid_data = array() ) {
804
+function give_get_donation_form_user($valid_data = array()) {
805 805
 
806 806
 	// Initialize user.
807 807
 	$user    = false;
808
-	$is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
808
+	$is_ajax = defined('DOING_AJAX') && DOING_AJAX;
809 809
 
810
-	if ( $is_ajax ) {
810
+	if ($is_ajax) {
811 811
 		// Do not create or login the user during the ajax submission (check for errors only).
812 812
 		return true;
813
-	} elseif ( is_user_logged_in() ) {
813
+	} elseif (is_user_logged_in()) {
814 814
 		// Set the valid user as the logged in collected data.
815 815
 		$user = $valid_data['logged_in_user'];
816
-	} elseif ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) {
816
+	} elseif ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) {
817 817
 		// New user registration.
818
-		if ( $valid_data['need_new_user'] === true ) {
818
+		if ($valid_data['need_new_user'] === true) {
819 819
 			// Set user.
820 820
 			$user = $valid_data['new_user_data'];
821 821
 			// Register and login new user.
822
-			$user['user_id'] = give_register_and_login_new_user( $user );
822
+			$user['user_id'] = give_register_and_login_new_user($user);
823 823
 			// User login
824
-		} elseif ( $valid_data['need_user_login'] === true && ! $is_ajax ) {
824
+		} elseif ($valid_data['need_user_login'] === true && ! $is_ajax) {
825 825
 
826 826
 			/**
827 827
 			 * The login form is now processed in the give_process_donation_login() function.
@@ -833,48 +833,48 @@  discard block
 block discarded – undo
833 833
 			// Set user.
834 834
 			$user = $valid_data['login_user_data'];
835 835
 			// Login user.
836
-			give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] );
836
+			give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']);
837 837
 		}
838 838
 	}
839 839
 
840 840
 	// Check guest checkout.
841
-	if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) {
841
+	if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) {
842 842
 		// Set user
843 843
 		$user = $valid_data['guest_user_data'];
844 844
 	}
845 845
 
846 846
 	// Verify we have an user.
847
-	if ( false === $user || empty( $user ) ) {
847
+	if (false === $user || empty($user)) {
848 848
 		// Return false.
849 849
 		return false;
850 850
 	}
851 851
 
852 852
 	// Get user first name.
853
-	if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) {
854
-		$user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : '';
853
+	if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) {
854
+		$user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : '';
855 855
 	}
856 856
 
857 857
 	// Get user last name.
858
-	if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) {
859
-		$user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : '';
858
+	if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) {
859
+		$user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : '';
860 860
 	}
861 861
 
862 862
 	// Get the user's billing address details.
863 863
 	$user['address']            = array();
864
-	$user['address']['line1']   = ! empty( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : false;
865
-	$user['address']['line2']   = ! empty( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : false;
866
-	$user['address']['city']    = ! empty( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : false;
867
-	$user['address']['state']   = ! empty( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : false;
868
-	$user['address']['country'] = ! empty( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : false;
869
-	$user['address']['zip']     = ! empty( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : false;
870
-
871
-	if ( empty( $user['address']['country'] ) ) {
864
+	$user['address']['line1']   = ! empty($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : false;
865
+	$user['address']['line2']   = ! empty($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : false;
866
+	$user['address']['city']    = ! empty($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : false;
867
+	$user['address']['state']   = ! empty($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : false;
868
+	$user['address']['country'] = ! empty($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : false;
869
+	$user['address']['zip']     = ! empty($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : false;
870
+
871
+	if (empty($user['address']['country'])) {
872 872
 		$user['address'] = false;
873 873
 	} // End if().
874 874
 
875
-	if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) {
875
+	if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) {
876 876
 		// Store the address in the user's meta so the donation form can be pre-populated with it on return donation.
877
-		update_user_meta( $user['user_id'], '_give_user_address', $user['address'] );
877
+		update_user_meta($user['user_id'], '_give_user_address', $user['address']);
878 878
 	}
879 879
 
880 880
 	// Return valid user.
@@ -893,16 +893,16 @@  discard block
 block discarded – undo
893 893
 	$card_data = give_get_donation_cc_info();
894 894
 
895 895
 	// Validate the card zip.
896
-	if ( ! empty( $card_data['card_zip'] ) ) {
897
-		if ( ! give_donation_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) {
898
-			give_set_error( 'invalid_cc_zip', __( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) );
896
+	if ( ! empty($card_data['card_zip'])) {
897
+		if ( ! give_donation_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) {
898
+			give_set_error('invalid_cc_zip', __('The zip / postal code you entered for your billing address is invalid.', 'give'));
899 899
 		}
900 900
 	}
901 901
 
902 902
 	// Ensure no spaces.
903
-	if ( ! empty( $card_data['card_number'] ) ) {
904
-		$card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs
905
-		$card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces
903
+	if ( ! empty($card_data['card_number'])) {
904
+		$card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs
905
+		$card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces
906 906
 	}
907 907
 
908 908
 	// This should validate card numbers at some point too.
@@ -919,17 +919,17 @@  discard block
 block discarded – undo
919 919
 function give_get_donation_cc_info() {
920 920
 
921 921
 	$cc_info                   = array();
922
-	$cc_info['card_name']      = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : '';
923
-	$cc_info['card_number']    = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : '';
924
-	$cc_info['card_cvc']       = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : '';
925
-	$cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : '';
926
-	$cc_info['card_exp_year']  = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : '';
927
-	$cc_info['card_address']   = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : '';
928
-	$cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : '';
929
-	$cc_info['card_city']      = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : '';
930
-	$cc_info['card_state']     = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : '';
931
-	$cc_info['card_country']   = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : '';
932
-	$cc_info['card_zip']       = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : '';
922
+	$cc_info['card_name']      = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : '';
923
+	$cc_info['card_number']    = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : '';
924
+	$cc_info['card_cvc']       = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : '';
925
+	$cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : '';
926
+	$cc_info['card_exp_year']  = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : '';
927
+	$cc_info['card_address']   = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : '';
928
+	$cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : '';
929
+	$cc_info['card_city']      = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : '';
930
+	$cc_info['card_state']     = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : '';
931
+	$cc_info['card_country']   = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : '';
932
+	$cc_info['card_zip']       = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : '';
933 933
 
934 934
 	// Return cc info.
935 935
 	return $cc_info;
@@ -945,14 +945,14 @@  discard block
 block discarded – undo
945 945
  *
946 946
  * @return bool|mixed
947 947
  */
948
-function give_donation_form_validate_cc_zip( $zip = 0, $country_code = '' ) {
948
+function give_donation_form_validate_cc_zip($zip = 0, $country_code = '') {
949 949
 	$ret = false;
950 950
 
951
-	if ( empty( $zip ) || empty( $country_code ) ) {
951
+	if (empty($zip) || empty($country_code)) {
952 952
 		return $ret;
953 953
 	}
954 954
 
955
-	$country_code = strtoupper( $country_code );
955
+	$country_code = strtoupper($country_code);
956 956
 
957 957
 	$zip_regex = array(
958 958
 		'AD' => 'AD\d{3}',
@@ -1112,11 +1112,11 @@  discard block
 block discarded – undo
1112 1112
 		'ZM' => '\d{5}',
1113 1113
 	);
1114 1114
 
1115
-	if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) {
1115
+	if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) {
1116 1116
 		$ret = true;
1117 1117
 	}
1118 1118
 
1119
-	return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code );
1119
+	return apply_filters('give_is_zip_valid', $ret, $zip, $country_code);
1120 1120
 }
1121 1121
 
1122 1122
 
@@ -1130,36 +1130,36 @@  discard block
 block discarded – undo
1130 1130
  *
1131 1131
  * @return bool
1132 1132
  */
1133
-function give_validate_multi_donation_form_level( $valid_data, $data ) {
1133
+function give_validate_multi_donation_form_level($valid_data, $data) {
1134 1134
 	/* @var Give_Donate_Form $form */
1135
-	$form = new Give_Donate_Form( $data['give-form-id'] );
1135
+	$form = new Give_Donate_Form($data['give-form-id']);
1136 1136
 
1137 1137
 	$donation_level_matched = false;
1138 1138
 
1139
-	if ( $form->is_multi_type_donation_form() ) {
1139
+	if ($form->is_multi_type_donation_form()) {
1140 1140
 
1141 1141
 		// Bailout.
1142
-		if ( ! ( $variable_prices = $form->get_prices() ) ) {
1142
+		if ( ! ($variable_prices = $form->get_prices())) {
1143 1143
 			return false;
1144 1144
 		}
1145 1145
 
1146 1146
 		// Sanitize donation amount.
1147
-		$data['give-amount'] = give_sanitize_amount( $data['give-amount'] );
1147
+		$data['give-amount'] = give_sanitize_amount($data['give-amount']);
1148 1148
 
1149 1149
 		// Get number of decimals.
1150 1150
 		$default_decimals = give_get_price_decimals();
1151 1151
 
1152
-		if ( $data['give-amount'] === give_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ), $default_decimals ) ) {
1152
+		if ($data['give-amount'] === give_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']), $default_decimals)) {
1153 1153
 			return true;
1154 1154
 		}
1155 1155
 
1156 1156
 		// Find correct donation level from all donation levels.
1157
-		foreach ( $variable_prices as $variable_price ) {
1157
+		foreach ($variable_prices as $variable_price) {
1158 1158
 			// Sanitize level amount.
1159
-			$variable_price['_give_amount'] = give_sanitize_amount( $variable_price['_give_amount'], $default_decimals );
1159
+			$variable_price['_give_amount'] = give_sanitize_amount($variable_price['_give_amount'], $default_decimals);
1160 1160
 
1161 1161
 			// Set first match donation level ID.
1162
-			if ( $data['give-amount'] === $variable_price['_give_amount'] ) {
1162
+			if ($data['give-amount'] === $variable_price['_give_amount']) {
1163 1163
 				$_POST['give-price-id'] = $variable_price['_give_id']['level_id'];
1164 1164
 				$donation_level_matched = true;
1165 1165
 				break;
@@ -1170,19 +1170,19 @@  discard block
 block discarded – undo
1170 1170
 		// If yes then set price id to custom if amount is greater then custom minimum amount (if any).
1171 1171
 		if (
1172 1172
 			! $donation_level_matched
1173
-			&& ( give_is_setting_enabled( give_get_meta( $data['give-form-id'], '_give_custom_amount', true ) ) )
1173
+			&& (give_is_setting_enabled(give_get_meta($data['give-form-id'], '_give_custom_amount', true)))
1174 1174
 		) {
1175 1175
 			// Sanitize custom minimum amount.
1176
-			$custom_minimum_amount = give_sanitize_amount( give_get_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ), $default_decimals );
1176
+			$custom_minimum_amount = give_sanitize_amount(give_get_meta($data['give-form-id'], '_give_custom_amount_minimum', true), $default_decimals);
1177 1177
 
1178
-			if ( $data['give-amount'] >= $custom_minimum_amount ) {
1178
+			if ($data['give-amount'] >= $custom_minimum_amount) {
1179 1179
 				$_POST['give-price-id'] = 'custom';
1180 1180
 				$donation_level_matched = true;
1181 1181
 			}
1182 1182
 		}
1183 1183
 	}// End if().
1184 1184
 
1185
-	return ( $donation_level_matched ? true : false );
1185
+	return ($donation_level_matched ? true : false);
1186 1186
 }
1187 1187
 
1188
-add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 );
1188
+add_action('give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2);
Please login to merge, or discard this patch.
includes/install.php 1 patch
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -26,15 +26,15 @@  discard block
 block discarded – undo
26 26
  * @global     $wpdb
27 27
  * @return void
28 28
  */
29
-function give_install( $network_wide = false ) {
29
+function give_install($network_wide = false) {
30 30
 
31 31
 	global $wpdb;
32 32
 
33
-	if ( is_multisite() && $network_wide ) {
33
+	if (is_multisite() && $network_wide) {
34 34
 
35
-		foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) {
35
+		foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) {
36 36
 
37
-			switch_to_blog( $blog_id );
37
+			switch_to_blog($blog_id);
38 38
 			give_run_install();
39 39
 			restore_current_blog();
40 40
 
@@ -62,24 +62,24 @@  discard block
 block discarded – undo
62 62
 	give_setup_post_types();
63 63
 
64 64
 	// Clear the permalinks.
65
-	flush_rewrite_rules( false );
65
+	flush_rewrite_rules(false);
66 66
 
67 67
 	// Add Upgraded From Option.
68
-	$current_version = get_option( 'give_version' );
69
-	if ( $current_version ) {
70
-		update_option( 'give_version_upgraded_from', $current_version );
68
+	$current_version = get_option('give_version');
69
+	if ($current_version) {
70
+		update_option('give_version_upgraded_from', $current_version);
71 71
 	}
72 72
 
73 73
 	// Setup some default options.
74 74
 	$options = array();
75 75
 
76 76
 	// Checks if the Success Page option exists AND that the page exists.
77
-	if ( ! get_post( give_get_option( 'success_page' ) ) ) {
77
+	if ( ! get_post(give_get_option('success_page'))) {
78 78
 
79 79
 		// Donation Confirmation (Success) Page
80 80
 		$success = wp_insert_post(
81 81
 			array(
82
-				'post_title'     => esc_html__( 'Donation Confirmation', 'give' ),
82
+				'post_title'     => esc_html__('Donation Confirmation', 'give'),
83 83
 				'post_content'   => '[give_receipt]',
84 84
 				'post_status'    => 'publish',
85 85
 				'post_author'    => 1,
@@ -93,13 +93,13 @@  discard block
 block discarded – undo
93 93
 	}
94 94
 
95 95
 	// Checks if the Failure Page option exists AND that the page exists.
96
-	if ( ! get_post( give_get_option( 'failure_page' ) ) ) {
96
+	if ( ! get_post(give_get_option('failure_page'))) {
97 97
 
98 98
 		// Failed Donation Page
99 99
 		$failed = wp_insert_post(
100 100
 			array(
101
-				'post_title'     => esc_html__( 'Donation Failed', 'give' ),
102
-				'post_content'   => esc_html__( 'We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give' ),
101
+				'post_title'     => esc_html__('Donation Failed', 'give'),
102
+				'post_content'   => esc_html__('We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give'),
103 103
 				'post_status'    => 'publish',
104 104
 				'post_author'    => 1,
105 105
 				'post_type'      => 'page',
@@ -111,11 +111,11 @@  discard block
 block discarded – undo
111 111
 	}
112 112
 
113 113
 	// Checks if the History Page option exists AND that the page exists.
114
-	if ( ! get_post( give_get_option( 'history_page' ) ) ) {
114
+	if ( ! get_post(give_get_option('history_page'))) {
115 115
 		// Donation History Page
116 116
 		$history = wp_insert_post(
117 117
 			array(
118
-				'post_title'     => esc_html__( 'Donation History', 'give' ),
118
+				'post_title'     => esc_html__('Donation History', 'give'),
119 119
 				'post_content'   => '[donation_history]',
120 120
 				'post_status'    => 'publish',
121 121
 				'post_author'    => 1,
@@ -128,22 +128,22 @@  discard block
 block discarded – undo
128 128
 	}
129 129
 
130 130
 	//Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency.
131
-	if ( empty( $current_version ) ) {
132
-		$options = array_merge( $options, give_get_default_settings() );
131
+	if (empty($current_version)) {
132
+		$options = array_merge($options, give_get_default_settings());
133 133
 	}
134 134
 
135 135
 	// Populate the default values.
136
-	update_option( 'give_settings', array_merge( $give_options, $options ) );
136
+	update_option('give_settings', array_merge($give_options, $options));
137 137
 
138 138
 	/**
139 139
 	 * Run plugin upgrades.
140 140
 	 *
141 141
 	 * @since 1.8
142 142
 	 */
143
-	do_action( 'give_upgrades' );
143
+	do_action('give_upgrades');
144 144
 
145
-	if ( GIVE_VERSION !== get_option( 'give_version' ) ) {
146
-		update_option( 'give_version', GIVE_VERSION );
145
+	if (GIVE_VERSION !== get_option('give_version')) {
146
+		update_option('give_version', GIVE_VERSION);
147 147
 	}
148 148
 
149 149
 	// Create Give roles.
@@ -152,18 +152,18 @@  discard block
 block discarded – undo
152 152
 	$roles->add_caps();
153 153
 
154 154
 	$api = new Give_API();
155
-	update_option( 'give_default_api_version', 'v' . $api->get_version() );
155
+	update_option('give_default_api_version', 'v'.$api->get_version());
156 156
 
157 157
 	// Check for PHP Session support, and enable if available.
158 158
 	$give_sessions = new Give_Session();
159 159
 	$give_sessions->use_php_sessions();
160 160
 
161 161
 	// Add a temporary option to note that Give pages have been created.
162
-	Give_Cache::set( '_give_installed', $options, 30, true );
162
+	Give_Cache::set('_give_installed', $options, 30, true);
163 163
 
164
-	if ( ! $current_version ) {
164
+	if ( ! $current_version) {
165 165
 
166
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php';
166
+		require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php';
167 167
 
168 168
 		// When new upgrade routines are added, mark them as complete on fresh install.
169 169
 		$upgrade_routines = array(
@@ -175,18 +175,18 @@  discard block
 block discarded – undo
175 175
 			'v189_upgrades_levels_post_meta'
176 176
 		);
177 177
 
178
-		foreach ( $upgrade_routines as $upgrade ) {
179
-			give_set_upgrade_complete( $upgrade );
178
+		foreach ($upgrade_routines as $upgrade) {
179
+			give_set_upgrade_complete($upgrade);
180 180
 		}
181 181
 	}
182 182
 
183 183
 	// Bail if activating from network, or bulk.
184
-	if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
184
+	if (is_network_admin() || isset($_GET['activate-multi'])) {
185 185
 		return;
186 186
 	}
187 187
 
188 188
 	// Add the transient to redirect.
189
-	Give_Cache::set( '_give_activation_redirect', true, 30, true );
189
+	Give_Cache::set('_give_activation_redirect', true, 30, true);
190 190
 
191 191
 	// Set 'Donation Form' meta box enabled by default.
192 192
 	give_nav_donation_metabox_enabled();
@@ -206,11 +206,11 @@  discard block
 block discarded – undo
206 206
  * @param  int $site_id The Site ID.
207 207
  * @param  array $meta Blog Meta.
208 208
  */
209
-function give_on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
209
+function give_on_create_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) {
210 210
 
211
-	if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) {
211
+	if (is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)) {
212 212
 
213
-		switch_to_blog( $blog_id );
213
+		switch_to_blog($blog_id);
214 214
 		give_install();
215 215
 		restore_current_blog();
216 216
 
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 
219 219
 }
220 220
 
221
-add_action( 'wpmu_new_blog', 'give_on_create_blog', 10, 6 );
221
+add_action('wpmu_new_blog', 'give_on_create_blog', 10, 6);
222 222
 
223 223
 
224 224
 /**
@@ -231,13 +231,13 @@  discard block
 block discarded – undo
231 231
  *
232 232
  * @return array          The tables to drop.
233 233
  */
234
-function give_wpmu_drop_tables( $tables, $blog_id ) {
234
+function give_wpmu_drop_tables($tables, $blog_id) {
235 235
 
236
-	switch_to_blog( $blog_id );
236
+	switch_to_blog($blog_id);
237 237
 	$donors_db     = new Give_DB_Donors();
238 238
 	$donor_meta_db = new Give_DB_Donor_Meta();
239 239
 
240
-	if ( $donors_db->installed() ) {
240
+	if ($donors_db->installed()) {
241 241
 		$tables[] = $donors_db->table_name;
242 242
 		$tables[] = $donor_meta_db->table_name;
243 243
 	}
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 
248 248
 }
249 249
 
250
-add_filter( 'wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2 );
250
+add_filter('wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2);
251 251
 
252 252
 /**
253 253
  * Post-installation
@@ -259,16 +259,16 @@  discard block
 block discarded – undo
259 259
  */
260 260
 function give_after_install() {
261 261
 
262
-	if ( ! is_admin() ) {
262
+	if ( ! is_admin()) {
263 263
 		return;
264 264
 	}
265 265
 
266
-	$give_options     = Give_Cache::get( '_give_installed', true );
267
-	$give_table_check = get_option( '_give_table_check', false );
266
+	$give_options     = Give_Cache::get('_give_installed', true);
267
+	$give_table_check = get_option('_give_table_check', false);
268 268
 
269
-	if ( false === $give_table_check || current_time( 'timestamp' ) > $give_table_check ) {
269
+	if (false === $give_table_check || current_time('timestamp') > $give_table_check) {
270 270
 
271
-		if ( ! @Give()->donor_meta->installed() ) {
271
+		if ( ! @Give()->donor_meta->installed()) {
272 272
 
273 273
 			// Create the donor meta database.
274 274
 			// (this ensures it creates it on multisite instances where it is network activated).
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 
277 277
 		}
278 278
 
279
-		if ( ! @Give()->donors->installed() ) {
279
+		if ( ! @Give()->donors->installed()) {
280 280
 			// Create the donor database.
281 281
 			// (this ensures it creates it on multisite instances where it is network activated).
282 282
 			@Give()->donors->create_table();
@@ -288,22 +288,22 @@  discard block
 block discarded – undo
288 288
 			 *
289 289
 			 * @param array $give_options Give plugin options.
290 290
 			 */
291
-			do_action( 'give_after_install', $give_options );
291
+			do_action('give_after_install', $give_options);
292 292
 		}
293 293
 
294
-		update_option( '_give_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ) );
294
+		update_option('_give_table_check', (current_time('timestamp') + WEEK_IN_SECONDS));
295 295
 
296 296
 	}
297 297
 
298 298
 	// Delete the transient
299
-	if ( false !== $give_options ) {
300
-		Give_Cache::delete( Give_Cache::get_key( '_give_installed' ) );
299
+	if (false !== $give_options) {
300
+		Give_Cache::delete(Give_Cache::get_key('_give_installed'));
301 301
 	}
302 302
 
303 303
 
304 304
 }
305 305
 
306
-add_action( 'admin_init', 'give_after_install' );
306
+add_action('admin_init', 'give_after_install');
307 307
 
308 308
 
309 309
 /**
@@ -318,11 +318,11 @@  discard block
 block discarded – undo
318 318
 
319 319
 	global $wp_roles;
320 320
 
321
-	if ( ! is_object( $wp_roles ) ) {
321
+	if ( ! is_object($wp_roles)) {
322 322
 		return;
323 323
 	}
324 324
 
325
-	if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) {
325
+	if ( ! array_key_exists('give_manager', $wp_roles->roles)) {
326 326
 
327 327
 		// Create Give plugin roles
328 328
 		$roles = new Give_Roles();
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 
334 334
 }
335 335
 
336
-add_action( 'admin_init', 'give_install_roles_on_network' );
336
+add_action('admin_init', 'give_install_roles_on_network');
337 337
 
338 338
 /**
339 339
  * Default core setting values.
@@ -369,14 +369,14 @@  discard block
 block discarded – undo
369 369
 		'uninstall_on_delete'                         => 'disabled',
370 370
 		'the_content_filter'                          => 'enabled',
371 371
 		'scripts_footer'                              => 'disabled',
372
-		'agree_to_terms_label'                        => __( 'Agree to Terms?', 'give' ),
372
+		'agree_to_terms_label'                        => __('Agree to Terms?', 'give'),
373 373
 		'agreement_text'                              => give_get_default_agreement_text(),
374 374
 
375 375
 		// Paypal IPN verification.
376 376
 		'paypal_verification'                         => 'enabled',
377 377
 
378 378
 		// Default is manual gateway.
379
-		'gateways'                                    => array( 'manual' => 1, 'offline' => 1 ),
379
+		'gateways'                                    => array('manual' => 1, 'offline' => 1),
380 380
 		'default_gateway'                             => 'manual',
381 381
 
382 382
 		// Offline gateway setup.
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
  */
402 402
 function give_get_default_agreement_text() {
403 403
 
404
-	$org_name = get_bloginfo( 'name' );
404
+	$org_name = get_bloginfo('name');
405 405
 
406 406
 	$agreement = sprintf(
407 407
 		'<p>Acceptance of any contribution, gift or grant is at the discretion of the %1$s. The  %1$s will not accept any gift unless it can be used or expended consistently with the purpose and mission of the  %1$s.</p>
@@ -415,5 +415,5 @@  discard block
 block discarded – undo
415 415
 		$org_name
416 416
 	);
417 417
 
418
-	return apply_filters( 'give_get_default_agreement_text', $agreement, $org_name );
418
+	return apply_filters('give_get_default_agreement_text', $agreement, $org_name);
419 419
 }
Please login to merge, or discard this patch.