Completed
Push — master ( 4e7b4c...a8a8a5 )
by Matt
37:00 queued 17:02
created
includes/api/class-give-api.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 	 *
212 212
 	 * @access public
213 213
 	 * @since  1.1
214
-	 * @return array
214
+	 * @return string
215 215
 	 */
216 216
 	public function get_versions() {
217 217
 		return $this->versions;
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
 	 *
663 663
 	 * @param array $args Arguments to override defaults
664 664
 	 *
665
-	 * @return array $dates
665
+	 * @return integer|null $dates
666 666
 	 */
667 667
 	public function get_dates( $args = array() ) {
668 668
 		$dates = array();
@@ -1712,7 +1712,7 @@  discard block
 block discarded – undo
1712 1712
 	 *
1713 1713
 	 * @param int $user_id User ID of user to revoke key for
1714 1714
 	 *
1715
-	 * @return string
1715
+	 * @return boolean
1716 1716
 	 */
1717 1717
 	public function revoke_api_key( $user_id = 0 ) {
1718 1718
 
Please login to merge, or discard this patch.
Spacing   +479 added lines, -479 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -139,27 +139,27 @@  discard block
 block discarded – undo
139 139
 			'v1' => 'GIVE_API_V1',
140 140
 		);
141 141
 
142
-		foreach ( $this->get_versions() as $version => $class ) {
143
-			require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api-' . $version . '.php';
142
+		foreach ($this->get_versions() as $version => $class) {
143
+			require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api-'.$version.'.php';
144 144
 		}
145 145
 
146
-		add_action( 'init', array( $this, 'add_endpoint' ) );
147
-		add_action( 'wp', array( $this, 'process_query' ), - 1 );
148
-		add_filter( 'query_vars', array( $this, 'query_vars' ) );
149
-		add_action( 'show_user_profile', array( $this, 'user_key_field' ) );
150
-		add_action( 'edit_user_profile', array( $this, 'user_key_field' ) );
151
-		add_action( 'personal_options_update', array( $this, 'update_key' ) );
152
-		add_action( 'edit_user_profile_update', array( $this, 'update_key' ) );
153
-		add_action( 'give_process_api_key', array( $this, 'process_api_key' ) );
146
+		add_action('init', array($this, 'add_endpoint'));
147
+		add_action('wp', array($this, 'process_query'), - 1);
148
+		add_filter('query_vars', array($this, 'query_vars'));
149
+		add_action('show_user_profile', array($this, 'user_key_field'));
150
+		add_action('edit_user_profile', array($this, 'user_key_field'));
151
+		add_action('personal_options_update', array($this, 'update_key'));
152
+		add_action('edit_user_profile_update', array($this, 'update_key'));
153
+		add_action('give_process_api_key', array($this, 'process_api_key'));
154 154
 
155 155
 		// Setup a backwards compatibility check for user API Keys
156
-		add_filter( 'get_user_metadata', array( $this, 'api_key_backwards_compat' ), 10, 4 );
156
+		add_filter('get_user_metadata', array($this, 'api_key_backwards_compat'), 10, 4);
157 157
 
158 158
 		// Determine if JSON_PRETTY_PRINT is available
159
-		$this->pretty_print = defined( 'JSON_PRETTY_PRINT' ) ? JSON_PRETTY_PRINT : null;
159
+		$this->pretty_print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : null;
160 160
 
161 161
 		// Allow API request logging to be turned off
162
-		$this->log_requests = apply_filters( 'give_api_log_requests', $this->log_requests );
162
+		$this->log_requests = apply_filters('give_api_log_requests', $this->log_requests);
163 163
 
164 164
 		// Setup Give_Payment_Stats instance
165 165
 		$this->stats = new Give_Payment_Stats;
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
 	 *
176 176
 	 * @since  1.1
177 177
 	 */
178
-	public function add_endpoint( $rewrite_rules ) {
179
-		add_rewrite_endpoint( 'give-api', EP_ALL );
178
+	public function add_endpoint($rewrite_rules) {
179
+		add_rewrite_endpoint('give-api', EP_ALL);
180 180
 	}
181 181
 
182 182
 	/**
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	 *
190 190
 	 * @return string[] $vars New query vars
191 191
 	 */
192
-	public function query_vars( $vars ) {
192
+	public function query_vars($vars) {
193 193
 
194 194
 		$vars[] = 'token';
195 195
 		$vars[] = 'key';
@@ -240,11 +240,11 @@  discard block
 block discarded – undo
240 240
 	 */
241 241
 	public function get_default_version() {
242 242
 
243
-		$version = get_option( 'give_default_api_version' );
243
+		$version = get_option('give_default_api_version');
244 244
 
245
-		if ( defined( 'GIVE_API_VERSION' ) ) {
245
+		if (defined('GIVE_API_VERSION')) {
246 246
 			$version = GIVE_API_VERSION;
247
-		} elseif ( ! $version ) {
247
+		} elseif ( ! $version) {
248 248
 			$version = 'v1';
249 249
 		}
250 250
 
@@ -265,14 +265,14 @@  discard block
 block discarded – undo
265 265
 
266 266
 		$version = $wp_query->query_vars['give-api'];
267 267
 
268
-		if ( strpos( $version, '/' ) ) {
268
+		if (strpos($version, '/')) {
269 269
 
270
-			$version = explode( '/', $version );
271
-			$version = strtolower( $version[0] );
270
+			$version = explode('/', $version);
271
+			$version = strtolower($version[0]);
272 272
 
273
-			$wp_query->query_vars['give-api'] = str_replace( $version . '/', '', $wp_query->query_vars['give-api'] );
273
+			$wp_query->query_vars['give-api'] = str_replace($version.'/', '', $wp_query->query_vars['give-api']);
274 274
 
275
-			if ( array_key_exists( $version, $this->versions ) ) {
275
+			if (array_key_exists($version, $this->versions)) {
276 276
 
277 277
 				$this->queried_version = $version;
278 278
 
@@ -309,32 +309,32 @@  discard block
 block discarded – undo
309 309
 		$this->override = false;
310 310
 
311 311
 		// Make sure we have both user and api key
312
-		if ( ! empty( $wp_query->query_vars['give-api'] ) && ( $wp_query->query_vars['give-api'] != 'forms' || ! empty( $wp_query->query_vars['token'] ) ) ) {
312
+		if ( ! empty($wp_query->query_vars['give-api']) && ($wp_query->query_vars['give-api'] != 'forms' || ! empty($wp_query->query_vars['token']))) {
313 313
 
314
-			if ( empty( $wp_query->query_vars['token'] ) || empty( $wp_query->query_vars['key'] ) ) {
314
+			if (empty($wp_query->query_vars['token']) || empty($wp_query->query_vars['key'])) {
315 315
 				$this->missing_auth();
316 316
 			}
317 317
 
318 318
 			// Retrieve the user by public API key and ensure they exist
319
-			if ( ! ( $user = $this->get_user( $wp_query->query_vars['key'] ) ) ) {
319
+			if ( ! ($user = $this->get_user($wp_query->query_vars['key']))) {
320 320
 
321 321
 				$this->invalid_key();
322 322
 
323 323
 			} else {
324 324
 
325
-				$token  = urldecode( $wp_query->query_vars['token'] );
326
-				$secret = $this->get_user_secret_key( $user );
327
-				$public = urldecode( $wp_query->query_vars['key'] );
325
+				$token  = urldecode($wp_query->query_vars['token']);
326
+				$secret = $this->get_user_secret_key($user);
327
+				$public = urldecode($wp_query->query_vars['key']);
328 328
 
329
-				if ( hash_equals( md5( $secret . $public ), $token ) ) {
329
+				if (hash_equals(md5($secret.$public), $token)) {
330 330
 					$this->is_valid_request = true;
331 331
 				} else {
332 332
 					$this->invalid_auth();
333 333
 				}
334 334
 			}
335
-		} elseif ( ! empty( $wp_query->query_vars['give-api'] ) && $wp_query->query_vars['give-api'] == 'forms' ) {
335
+		} elseif ( ! empty($wp_query->query_vars['give-api']) && $wp_query->query_vars['give-api'] == 'forms') {
336 336
 			$this->is_valid_request = true;
337
-			$wp_query->set( 'key', 'public' );
337
+			$wp_query->set('key', 'public');
338 338
 		}
339 339
 	}
340 340
 
@@ -350,25 +350,25 @@  discard block
 block discarded – undo
350 350
 	 *
351 351
 	 * @return bool if user ID is found, false otherwise
352 352
 	 */
353
-	public function get_user( $key = '' ) {
353
+	public function get_user($key = '') {
354 354
 		global $wpdb, $wp_query;
355 355
 
356
-		if ( empty( $key ) ) {
357
-			$key = urldecode( $wp_query->query_vars['key'] );
356
+		if (empty($key)) {
357
+			$key = urldecode($wp_query->query_vars['key']);
358 358
 		}
359 359
 
360
-		if ( empty( $key ) ) {
360
+		if (empty($key)) {
361 361
 			return false;
362 362
 		}
363 363
 
364
-		$user = get_transient( md5( 'give_api_user_' . $key ) );
364
+		$user = get_transient(md5('give_api_user_'.$key));
365 365
 
366
-		if ( false === $user ) {
367
-			$user = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key ) );
368
-			set_transient( md5( 'give_api_user_' . $key ), $user, DAY_IN_SECONDS );
366
+		if (false === $user) {
367
+			$user = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key));
368
+			set_transient(md5('give_api_user_'.$key), $user, DAY_IN_SECONDS);
369 369
 		}
370 370
 
371
-		if ( $user != null ) {
371
+		if ($user != null) {
372 372
 			$this->user_id = $user;
373 373
 
374 374
 			return $user;
@@ -377,37 +377,37 @@  discard block
 block discarded – undo
377 377
 		return false;
378 378
 	}
379 379
 
380
-	public function get_user_public_key( $user_id = 0 ) {
380
+	public function get_user_public_key($user_id = 0) {
381 381
 		global $wpdb;
382 382
 
383
-		if ( empty( $user_id ) ) {
383
+		if (empty($user_id)) {
384 384
 			return '';
385 385
 		}
386 386
 
387
-		$cache_key       = md5( 'give_api_user_public_key' . $user_id );
388
-		$user_public_key = get_transient( $cache_key );
387
+		$cache_key       = md5('give_api_user_public_key'.$user_id);
388
+		$user_public_key = get_transient($cache_key);
389 389
 
390
-		if ( empty( $user_public_key ) ) {
391
-			$user_public_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id ) );
392
-			set_transient( $cache_key, $user_public_key, HOUR_IN_SECONDS );
390
+		if (empty($user_public_key)) {
391
+			$user_public_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id));
392
+			set_transient($cache_key, $user_public_key, HOUR_IN_SECONDS);
393 393
 		}
394 394
 
395 395
 		return $user_public_key;
396 396
 	}
397 397
 
398
-	public function get_user_secret_key( $user_id = 0 ) {
398
+	public function get_user_secret_key($user_id = 0) {
399 399
 		global $wpdb;
400 400
 
401
-		if ( empty( $user_id ) ) {
401
+		if (empty($user_id)) {
402 402
 			return '';
403 403
 		}
404 404
 
405
-		$cache_key       = md5( 'give_api_user_secret_key' . $user_id );
406
-		$user_secret_key = get_transient( $cache_key );
405
+		$cache_key       = md5('give_api_user_secret_key'.$user_id);
406
+		$user_secret_key = get_transient($cache_key);
407 407
 
408
-		if ( empty( $user_secret_key ) ) {
409
-			$user_secret_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id ) );
410
-			set_transient( $cache_key, $user_secret_key, HOUR_IN_SECONDS );
408
+		if (empty($user_secret_key)) {
409
+			$user_secret_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id));
410
+			set_transient($cache_key, $user_secret_key, HOUR_IN_SECONDS);
411 411
 		}
412 412
 
413 413
 		return $user_secret_key;
@@ -423,10 +423,10 @@  discard block
 block discarded – undo
423 423
 	 */
424 424
 	private function missing_auth() {
425 425
 		$error          = array();
426
-		$error['error'] = esc_attr__( 'You must specify both a token and API key!', 'give' );
426
+		$error['error'] = esc_attr__('You must specify both a token and API key!', 'give');
427 427
 
428 428
 		$this->data = $error;
429
-		$this->output( 401 );
429
+		$this->output(401);
430 430
 	}
431 431
 
432 432
 	/**
@@ -440,10 +440,10 @@  discard block
 block discarded – undo
440 440
 	 */
441 441
 	private function invalid_auth() {
442 442
 		$error          = array();
443
-		$error['error'] = esc_attr__( 'Your request could not be authenticated!', 'give' );
443
+		$error['error'] = esc_attr__('Your request could not be authenticated!', 'give');
444 444
 
445 445
 		$this->data = $error;
446
-		$this->output( 403 );
446
+		$this->output(403);
447 447
 	}
448 448
 
449 449
 	/**
@@ -457,10 +457,10 @@  discard block
 block discarded – undo
457 457
 	 */
458 458
 	private function invalid_key() {
459 459
 		$error          = array();
460
-		$error['error'] = esc_attr__( 'Invalid API key!', 'give' );
460
+		$error['error'] = esc_attr__('Invalid API key!', 'give');
461 461
 
462 462
 		$this->data = $error;
463
-		$this->output( 403 );
463
+		$this->output(403);
464 464
 	}
465 465
 
466 466
 	/**
@@ -473,10 +473,10 @@  discard block
 block discarded – undo
473 473
 	 */
474 474
 	private function invalid_version() {
475 475
 		$error          = array();
476
-		$error['error'] = esc_attr__( 'Invalid API version!', 'give' );
476
+		$error['error'] = esc_attr__('Invalid API version!', 'give');
477 477
 
478 478
 		$this->data = $error;
479
-		$this->output( 404 );
479
+		$this->output(404);
480 480
 	}
481 481
 
482 482
 	/**
@@ -492,10 +492,10 @@  discard block
 block discarded – undo
492 492
 		global $wp_query;
493 493
 
494 494
 		// Start logging how long the request takes for logging
495
-		$before = microtime( true );
495
+		$before = microtime(true);
496 496
 
497 497
 		// Check for give-api var. Get out if not present
498
-		if ( empty( $wp_query->query_vars['give-api'] ) ) {
498
+		if (empty($wp_query->query_vars['give-api'])) {
499 499
 			return;
500 500
 		}
501 501
 
@@ -509,45 +509,45 @@  discard block
 block discarded – undo
509 509
 		$this->validate_request();
510 510
 
511 511
 		// Only proceed if no errors have been noted
512
-		if ( ! $this->is_valid_request ) {
512
+		if ( ! $this->is_valid_request) {
513 513
 			return;
514 514
 		}
515 515
 
516
-		if ( ! defined( 'GIVE_DOING_API' ) ) {
517
-			define( 'GIVE_DOING_API', true );
516
+		if ( ! defined('GIVE_DOING_API')) {
517
+			define('GIVE_DOING_API', true);
518 518
 		}
519 519
 
520 520
 		$data         = array();
521 521
 		$this->routes = new $this->versions[$this->get_queried_version()];
522 522
 		$this->routes->validate_request();
523 523
 
524
-		switch ( $this->endpoint ) :
524
+		switch ($this->endpoint) :
525 525
 
526 526
 			case 'stats' :
527 527
 
528
-				$data = $this->routes->get_stats( array(
529
-					'type'      => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null,
530
-					'form'      => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null,
531
-					'date'      => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null,
532
-					'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null,
533
-					'enddate'   => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null
534
-				) );
528
+				$data = $this->routes->get_stats(array(
529
+					'type'      => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null,
530
+					'form'      => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null,
531
+					'date'      => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null,
532
+					'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null,
533
+					'enddate'   => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null
534
+				));
535 535
 
536 536
 				break;
537 537
 
538 538
 			case 'forms' :
539 539
 
540
-				$form = isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null;
540
+				$form = isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null;
541 541
 
542
-				$data = $this->routes->get_forms( $form );
542
+				$data = $this->routes->get_forms($form);
543 543
 
544 544
 				break;
545 545
 
546 546
 			case 'donors' :
547 547
 
548
-				$customer = isset( $wp_query->query_vars['donor'] ) ? $wp_query->query_vars['donor'] : null;
548
+				$customer = isset($wp_query->query_vars['donor']) ? $wp_query->query_vars['donor'] : null;
549 549
 
550
-				$data = $this->routes->get_customers( $customer );
550
+				$data = $this->routes->get_customers($customer);
551 551
 
552 552
 				break;
553 553
 
@@ -560,14 +560,14 @@  discard block
 block discarded – undo
560 560
 		endswitch;
561 561
 
562 562
 		// Allow extensions to setup their own return data
563
-		$this->data = apply_filters( 'give_api_output_data', $data, $this->endpoint, $this );
563
+		$this->data = apply_filters('give_api_output_data', $data, $this->endpoint, $this);
564 564
 
565
-		$after                       = microtime( true );
566
-		$request_time                = ( $after - $before );
565
+		$after                       = microtime(true);
566
+		$request_time                = ($after - $before);
567 567
 		$this->data['request_speed'] = $request_time;
568 568
 
569 569
 		// Log this API request, if enabled. We log it here because we have access to errors.
570
-		$this->log_request( $this->data );
570
+		$this->log_request($this->data);
571 571
 
572 572
 		// Send out data to the output function
573 573
 		$this->output();
@@ -597,21 +597,21 @@  discard block
 block discarded – undo
597 597
 		global $wp_query;
598 598
 
599 599
 		// Whitelist our query options
600
-		$accepted = apply_filters( 'give_api_valid_query_modes', array(
600
+		$accepted = apply_filters('give_api_valid_query_modes', array(
601 601
 			'stats',
602 602
 			'forms',
603 603
 			'donors',
604 604
 			'donations'
605
-		) );
605
+		));
606 606
 
607
-		$query = isset( $wp_query->query_vars['give-api'] ) ? $wp_query->query_vars['give-api'] : null;
608
-		$query = str_replace( $this->queried_version . '/', '', $query );
607
+		$query = isset($wp_query->query_vars['give-api']) ? $wp_query->query_vars['give-api'] : null;
608
+		$query = str_replace($this->queried_version.'/', '', $query);
609 609
 
610 610
 		$error = array();
611 611
 
612 612
 		// Make sure our query is valid
613
-		if ( ! in_array( $query, $accepted ) ) {
614
-			$error['error'] = __( 'Invalid query!', 'give' );
613
+		if ( ! in_array($query, $accepted)) {
614
+			$error['error'] = __('Invalid query!', 'give');
615 615
 
616 616
 			$this->data = $error;
617 617
 			$this->output();
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
 	public function get_paged() {
632 632
 		global $wp_query;
633 633
 
634
-		return isset( $wp_query->query_vars['page'] ) ? $wp_query->query_vars['page'] : 1;
634
+		return isset($wp_query->query_vars['page']) ? $wp_query->query_vars['page'] : 1;
635 635
 	}
636 636
 
637 637
 
@@ -646,13 +646,13 @@  discard block
 block discarded – undo
646 646
 	public function per_page() {
647 647
 		global $wp_query;
648 648
 
649
-		$per_page = isset( $wp_query->query_vars['number'] ) ? $wp_query->query_vars['number'] : 10;
649
+		$per_page = isset($wp_query->query_vars['number']) ? $wp_query->query_vars['number'] : 10;
650 650
 
651
-		if ( $per_page < 0 && $this->get_query_mode() == 'donors' ) {
651
+		if ($per_page < 0 && $this->get_query_mode() == 'donors') {
652 652
 			$per_page = 99999999;
653 653
 		} // Customers query doesn't support -1
654 654
 
655
-		return apply_filters( 'give_api_results_per_page', $per_page );
655
+		return apply_filters('give_api_results_per_page', $per_page);
656 656
 	}
657 657
 
658 658
 	/**
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
 	 *
666 666
 	 * @return array $dates
667 667
 	 */
668
-	public function get_dates( $args = array() ) {
668
+	public function get_dates($args = array()) {
669 669
 		$dates = array();
670 670
 
671 671
 		$defaults = array(
@@ -676,60 +676,60 @@  discard block
 block discarded – undo
676 676
 			'enddate'   => null
677 677
 		);
678 678
 
679
-		$args = wp_parse_args( $args, $defaults );
679
+		$args = wp_parse_args($args, $defaults);
680 680
 
681
-		$current_time = current_time( 'timestamp' );
681
+		$current_time = current_time('timestamp');
682 682
 
683
-		if ( 'range' === $args['date'] ) {
684
-			$startdate          = strtotime( $args['startdate'] );
685
-			$enddate            = strtotime( $args['enddate'] );
686
-			$dates['day_start'] = date( 'd', $startdate );
687
-			$dates['day_end']   = date( 'd', $enddate );
688
-			$dates['m_start']   = date( 'n', $startdate );
689
-			$dates['m_end']     = date( 'n', $enddate );
690
-			$dates['year']      = date( 'Y', $startdate );
691
-			$dates['year_end']  = date( 'Y', $enddate );
683
+		if ('range' === $args['date']) {
684
+			$startdate          = strtotime($args['startdate']);
685
+			$enddate            = strtotime($args['enddate']);
686
+			$dates['day_start'] = date('d', $startdate);
687
+			$dates['day_end']   = date('d', $enddate);
688
+			$dates['m_start']   = date('n', $startdate);
689
+			$dates['m_end']     = date('n', $enddate);
690
+			$dates['year']      = date('Y', $startdate);
691
+			$dates['year_end']  = date('Y', $enddate);
692 692
 		} else {
693 693
 			// Modify dates based on predefined ranges
694
-			switch ( $args['date'] ) :
694
+			switch ($args['date']) :
695 695
 
696 696
 				case 'this_month' :
697 697
 					$dates['day']     = null;
698
-					$dates['m_start'] = date( 'n', $current_time );
699
-					$dates['m_end']   = date( 'n', $current_time );
700
-					$dates['year']    = date( 'Y', $current_time );
698
+					$dates['m_start'] = date('n', $current_time);
699
+					$dates['m_end']   = date('n', $current_time);
700
+					$dates['year']    = date('Y', $current_time);
701 701
 					break;
702 702
 
703 703
 				case 'last_month' :
704 704
 					$dates['day']     = null;
705
-					$dates['m_start'] = date( 'n', $current_time ) == 1 ? 12 : date( 'n', $current_time ) - 1;
705
+					$dates['m_start'] = date('n', $current_time) == 1 ? 12 : date('n', $current_time) - 1;
706 706
 					$dates['m_end']   = $dates['m_start'];
707
-					$dates['year']    = date( 'n', $current_time ) == 1 ? date( 'Y', $current_time ) - 1 : date( 'Y', $current_time );
707
+					$dates['year']    = date('n', $current_time) == 1 ? date('Y', $current_time) - 1 : date('Y', $current_time);
708 708
 					break;
709 709
 
710 710
 				case 'today' :
711
-					$dates['day']     = date( 'd', $current_time );
712
-					$dates['m_start'] = date( 'n', $current_time );
713
-					$dates['m_end']   = date( 'n', $current_time );
714
-					$dates['year']    = date( 'Y', $current_time );
711
+					$dates['day']     = date('d', $current_time);
712
+					$dates['m_start'] = date('n', $current_time);
713
+					$dates['m_end']   = date('n', $current_time);
714
+					$dates['year']    = date('Y', $current_time);
715 715
 					break;
716 716
 
717 717
 				case 'yesterday' :
718 718
 
719
-					$year  = date( 'Y', $current_time );
720
-					$month = date( 'n', $current_time );
721
-					$day   = date( 'd', $current_time );
719
+					$year  = date('Y', $current_time);
720
+					$month = date('n', $current_time);
721
+					$day   = date('d', $current_time);
722 722
 
723
-					if ( $month == 1 && $day == 1 ) {
723
+					if ($month == 1 && $day == 1) {
724 724
 
725 725
 						$year -= 1;
726 726
 						$month = 12;
727
-						$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
727
+						$day   = cal_days_in_month(CAL_GREGORIAN, $month, $year);
728 728
 
729
-					} elseif ( $month > 1 && $day == 1 ) {
729
+					} elseif ($month > 1 && $day == 1) {
730 730
 
731 731
 						$month -= 1;
732
-						$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
732
+						$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
733 733
 
734 734
 					} else {
735 735
 
@@ -745,65 +745,65 @@  discard block
 block discarded – undo
745 745
 					break;
746 746
 
747 747
 				case 'this_quarter' :
748
-					$month_now = date( 'n', $current_time );
748
+					$month_now = date('n', $current_time);
749 749
 
750 750
 					$dates['day'] = null;
751 751
 
752
-					if ( $month_now <= 3 ) {
752
+					if ($month_now <= 3) {
753 753
 
754 754
 						$dates['m_start'] = 1;
755 755
 						$dates['m_end']   = 3;
756
-						$dates['year']    = date( 'Y', $current_time );
756
+						$dates['year']    = date('Y', $current_time);
757 757
 
758
-					} else if ( $month_now <= 6 ) {
758
+					} else if ($month_now <= 6) {
759 759
 
760 760
 						$dates['m_start'] = 4;
761 761
 						$dates['m_end']   = 6;
762
-						$dates['year']    = date( 'Y', $current_time );
762
+						$dates['year']    = date('Y', $current_time);
763 763
 
764
-					} else if ( $month_now <= 9 ) {
764
+					} else if ($month_now <= 9) {
765 765
 
766 766
 						$dates['m_start'] = 7;
767 767
 						$dates['m_end']   = 9;
768
-						$dates['year']    = date( 'Y', $current_time );
768
+						$dates['year']    = date('Y', $current_time);
769 769
 
770 770
 					} else {
771 771
 
772 772
 						$dates['m_start'] = 10;
773 773
 						$dates['m_end']   = 12;
774
-						$dates['year']    = date( 'Y', $current_time );
774
+						$dates['year']    = date('Y', $current_time);
775 775
 
776 776
 					}
777 777
 					break;
778 778
 
779 779
 				case 'last_quarter' :
780
-					$month_now = date( 'n', $current_time );
780
+					$month_now = date('n', $current_time);
781 781
 
782 782
 					$dates['day'] = null;
783 783
 
784
-					if ( $month_now <= 3 ) {
784
+					if ($month_now <= 3) {
785 785
 
786 786
 						$dates['m_start'] = 10;
787 787
 						$dates['m_end']   = 12;
788
-						$dates['year']    = date( 'Y', $current_time ) - 1; // Previous year
788
+						$dates['year']    = date('Y', $current_time) - 1; // Previous year
789 789
 
790
-					} else if ( $month_now <= 6 ) {
790
+					} else if ($month_now <= 6) {
791 791
 
792 792
 						$dates['m_start'] = 1;
793 793
 						$dates['m_end']   = 3;
794
-						$dates['year']    = date( 'Y', $current_time );
794
+						$dates['year']    = date('Y', $current_time);
795 795
 
796
-					} else if ( $month_now <= 9 ) {
796
+					} else if ($month_now <= 9) {
797 797
 
798 798
 						$dates['m_start'] = 4;
799 799
 						$dates['m_end']   = 6;
800
-						$dates['year']    = date( 'Y', $current_time );
800
+						$dates['year']    = date('Y', $current_time);
801 801
 
802 802
 					} else {
803 803
 
804 804
 						$dates['m_start'] = 7;
805 805
 						$dates['m_end']   = 9;
806
-						$dates['year']    = date( 'Y', $current_time );
806
+						$dates['year']    = date('Y', $current_time);
807 807
 
808 808
 					}
809 809
 					break;
@@ -812,14 +812,14 @@  discard block
 block discarded – undo
812 812
 					$dates['day']     = null;
813 813
 					$dates['m_start'] = null;
814 814
 					$dates['m_end']   = null;
815
-					$dates['year']    = date( 'Y', $current_time );
815
+					$dates['year']    = date('Y', $current_time);
816 816
 					break;
817 817
 
818 818
 				case 'last_year' :
819 819
 					$dates['day']     = null;
820 820
 					$dates['m_start'] = null;
821 821
 					$dates['m_end']   = null;
822
-					$dates['year']    = date( 'Y', $current_time ) - 1;
822
+					$dates['year']    = date('Y', $current_time) - 1;
823 823
 					break;
824 824
 
825 825
 			endswitch;
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
 		 * @param object $dates The dates used for retreiving earnings/donations
834 834
 		 */
835 835
 
836
-		return apply_filters( 'give_api_stat_dates', $dates );
836
+		return apply_filters('give_api_stat_dates', $dates);
837 837
 	}
838 838
 
839 839
 	/**
@@ -848,11 +848,11 @@  discard block
 block discarded – undo
848 848
 	 *
849 849
 	 * @return array $customers Multidimensional array of the customers
850 850
 	 */
851
-	public function get_customers( $customer = null ) {
851
+	public function get_customers($customer = null) {
852 852
 
853 853
 		$customers = array();
854 854
 		$error     = array();
855
-		if ( ! user_can( $this->user_id, 'view_give_sensitive_data' ) && ! $this->override ) {
855
+		if ( ! user_can($this->user_id, 'view_give_sensitive_data') && ! $this->override) {
856 856
 			return $customers;
857 857
 		}
858 858
 
@@ -860,68 +860,68 @@  discard block
 block discarded – undo
860 860
 
861 861
 		$paged    = $this->get_paged();
862 862
 		$per_page = $this->per_page();
863
-		$offset   = $per_page * ( $paged - 1 );
863
+		$offset   = $per_page * ($paged - 1);
864 864
 
865
-		if ( is_numeric( $customer ) ) {
865
+		if (is_numeric($customer)) {
866 866
 			$field = 'id';
867 867
 		} else {
868 868
 			$field = 'email';
869 869
 		}
870 870
 
871
-		$customer_query = Give()->customers->get_customers( array(
871
+		$customer_query = Give()->customers->get_customers(array(
872 872
 			'number' => $per_page,
873 873
 			'offset' => $offset,
874 874
 			$field   => $customer
875
-		) );
875
+		));
876 876
 		$customer_count = 0;
877 877
 
878
-		if ( $customer_query ) {
878
+		if ($customer_query) {
879 879
 
880
-			foreach ( $customer_query as $customer_obj ) {
880
+			foreach ($customer_query as $customer_obj) {
881 881
 
882
-				$names      = explode( ' ', $customer_obj->name );
883
-				$first_name = ! empty( $names[0] ) ? $names[0] : '';
882
+				$names      = explode(' ', $customer_obj->name);
883
+				$first_name = ! empty($names[0]) ? $names[0] : '';
884 884
 				$last_name  = '';
885
-				if ( ! empty( $names[1] ) ) {
886
-					unset( $names[0] );
887
-					$last_name = implode( ' ', $names );
885
+				if ( ! empty($names[1])) {
886
+					unset($names[0]);
887
+					$last_name = implode(' ', $names);
888 888
 				}
889 889
 
890
-				$customers['donors'][ $customer_count ]['info']['user_id']      = '';
891
-				$customers['donors'][ $customer_count ]['info']['username']     = '';
892
-				$customers['donors'][ $customer_count ]['info']['display_name'] = '';
893
-				$customers['donors'][ $customer_count ]['info']['customer_id']  = $customer_obj->id;
894
-				$customers['donors'][ $customer_count ]['info']['first_name']   = $first_name;
895
-				$customers['donors'][ $customer_count ]['info']['last_name']    = $last_name;
896
-				$customers['donors'][ $customer_count ]['info']['email']        = $customer_obj->email;
890
+				$customers['donors'][$customer_count]['info']['user_id']      = '';
891
+				$customers['donors'][$customer_count]['info']['username']     = '';
892
+				$customers['donors'][$customer_count]['info']['display_name'] = '';
893
+				$customers['donors'][$customer_count]['info']['customer_id']  = $customer_obj->id;
894
+				$customers['donors'][$customer_count]['info']['first_name']   = $first_name;
895
+				$customers['donors'][$customer_count]['info']['last_name']    = $last_name;
896
+				$customers['donors'][$customer_count]['info']['email']        = $customer_obj->email;
897 897
 
898
-				if ( ! empty( $customer_obj->user_id ) ) {
898
+				if ( ! empty($customer_obj->user_id)) {
899 899
 
900
-					$user_data = get_userdata( $customer_obj->user_id );
900
+					$user_data = get_userdata($customer_obj->user_id);
901 901
 
902 902
 					// Customer with registered account
903
-					$customers['donors'][ $customer_count ]['info']['user_id']      = $customer_obj->user_id;
904
-					$customers['donors'][ $customer_count ]['info']['username']     = $user_data->user_login;
905
-					$customers['donors'][ $customer_count ]['info']['display_name'] = $user_data->display_name;
903
+					$customers['donors'][$customer_count]['info']['user_id']      = $customer_obj->user_id;
904
+					$customers['donors'][$customer_count]['info']['username']     = $user_data->user_login;
905
+					$customers['donors'][$customer_count]['info']['display_name'] = $user_data->display_name;
906 906
 
907 907
 				}
908 908
 
909
-				$customers['donors'][ $customer_count ]['stats']['total_donations'] = $customer_obj->purchase_count;
910
-				$customers['donors'][ $customer_count ]['stats']['total_spent']     = $customer_obj->purchase_value;
909
+				$customers['donors'][$customer_count]['stats']['total_donations'] = $customer_obj->purchase_count;
910
+				$customers['donors'][$customer_count]['stats']['total_spent']     = $customer_obj->purchase_value;
911 911
 
912
-				$customer_count ++;
912
+				$customer_count++;
913 913
 
914 914
 			}
915 915
 
916
-		} elseif ( $customer ) {
916
+		} elseif ($customer) {
917 917
 
918
-			$error['error'] = sprintf( __( 'Donor %s not found!', 'give' ), $customer );
918
+			$error['error'] = sprintf(__('Donor %s not found!', 'give'), $customer);
919 919
 
920 920
 			return $error;
921 921
 
922 922
 		} else {
923 923
 
924
-			$error['error'] = __( 'No donors found!', 'give' );
924
+			$error['error'] = __('No donors found!', 'give');
925 925
 
926 926
 			return $error;
927 927
 
@@ -940,36 +940,36 @@  discard block
 block discarded – undo
940 940
 	 *
941 941
 	 * @return array $customers Multidimensional array of the forms
942 942
 	 */
943
-	public function get_forms( $form = null ) {
943
+	public function get_forms($form = null) {
944 944
 
945 945
 		$forms = array();
946 946
 		$error = array();
947 947
 
948
-		if ( $form == null ) {
948
+		if ($form == null) {
949 949
 			$forms['forms'] = array();
950 950
 
951
-			$form_list = get_posts( array(
951
+			$form_list = get_posts(array(
952 952
 				'post_type'        => 'give_forms',
953 953
 				'posts_per_page'   => $this->per_page(),
954 954
 				'suppress_filters' => true,
955 955
 				'paged'            => $this->get_paged()
956
-			) );
956
+			));
957 957
 
958
-			if ( $form_list ) {
958
+			if ($form_list) {
959 959
 				$i = 0;
960
-				foreach ( $form_list as $form_info ) {
961
-					$forms['forms'][ $i ] = $this->get_form_data( $form_info );
962
-					$i ++;
960
+				foreach ($form_list as $form_info) {
961
+					$forms['forms'][$i] = $this->get_form_data($form_info);
962
+					$i++;
963 963
 				}
964 964
 			}
965 965
 		} else {
966
-			if ( get_post_type( $form ) == 'give_forms' ) {
967
-				$form_info = get_post( $form );
966
+			if (get_post_type($form) == 'give_forms') {
967
+				$form_info = get_post($form);
968 968
 
969
-				$forms['forms'][0] = $this->get_form_data( $form_info );
969
+				$forms['forms'][0] = $this->get_form_data($form_info);
970 970
 
971 971
 			} else {
972
-				$error['error'] = sprintf( __( 'Form %s not found!', 'give' ), $form );
972
+				$error['error'] = sprintf(__('Form %s not found!', 'give'), $form);
973 973
 
974 974
 				return $error;
975 975
 			}
@@ -987,7 +987,7 @@  discard block
 block discarded – undo
987 987
 	 *
988 988
 	 * @return array                Array of post data to return back in the API
989 989
 	 */
990
-	private function get_form_data( $form_info ) {
990
+	private function get_form_data($form_info) {
991 991
 
992 992
 		$form = array();
993 993
 
@@ -997,46 +997,46 @@  discard block
 block discarded – undo
997 997
 		$form['info']['create_date']   = $form_info->post_date;
998 998
 		$form['info']['modified_date'] = $form_info->post_modified;
999 999
 		$form['info']['status']        = $form_info->post_status;
1000
-		$form['info']['link']          = html_entity_decode( $form_info->guid );
1001
-		$form['info']['content']       = get_post_meta( $form_info->ID, '_give_form_content', true );
1002
-		$form['info']['thumbnail']     = wp_get_attachment_url( get_post_thumbnail_id( $form_info->ID ) );
1000
+		$form['info']['link']          = html_entity_decode($form_info->guid);
1001
+		$form['info']['content']       = get_post_meta($form_info->ID, '_give_form_content', true);
1002
+		$form['info']['thumbnail']     = wp_get_attachment_url(get_post_thumbnail_id($form_info->ID));
1003 1003
 
1004
-		if ( give_get_option( 'enable_categories' ) == 'on' ) {
1005
-			$form['info']['category'] = get_the_terms( $form_info, 'give_forms_category' );
1006
-			$form['info']['tags']     = get_the_terms( $form_info, 'give_forms_tag' );
1004
+		if (give_get_option('enable_categories') == 'on') {
1005
+			$form['info']['category'] = get_the_terms($form_info, 'give_forms_category');
1006
+			$form['info']['tags']     = get_the_terms($form_info, 'give_forms_tag');
1007 1007
 		}
1008
-		if ( give_get_option( 'enable_tags' ) == 'on' ) {
1009
-			$form['info']['tags'] = get_the_terms( $form_info, 'give_forms_tag' );
1008
+		if (give_get_option('enable_tags') == 'on') {
1009
+			$form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag');
1010 1010
 		}
1011 1011
 
1012
-		if ( user_can( $this->user_id, 'view_give_reports' ) || $this->override ) {
1013
-			$form['stats']['total']['donations']           = give_get_form_sales_stats( $form_info->ID );
1014
-			$form['stats']['total']['earnings']            = give_get_form_earnings_stats( $form_info->ID );
1015
-			$form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales( $form_info->ID );
1016
-			$form['stats']['monthly_average']['earnings']  = give_get_average_monthly_form_earnings( $form_info->ID );
1012
+		if (user_can($this->user_id, 'view_give_reports') || $this->override) {
1013
+			$form['stats']['total']['donations']           = give_get_form_sales_stats($form_info->ID);
1014
+			$form['stats']['total']['earnings']            = give_get_form_earnings_stats($form_info->ID);
1015
+			$form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales($form_info->ID);
1016
+			$form['stats']['monthly_average']['earnings']  = give_get_average_monthly_form_earnings($form_info->ID);
1017 1017
 		}
1018 1018
 
1019 1019
 		$counter = 0;
1020
-		if ( give_has_variable_prices( $form_info->ID ) ) {
1021
-			foreach ( give_get_variable_prices( $form_info->ID ) as $price ) {
1022
-				$counter ++;
1020
+		if (give_has_variable_prices($form_info->ID)) {
1021
+			foreach (give_get_variable_prices($form_info->ID) as $price) {
1022
+				$counter++;
1023 1023
 				//muli-level item
1024
-				$level                                     = isset( $price['_give_text'] ) ? $price['_give_text'] : 'level-' . $counter;
1025
-				$form['pricing'][ sanitize_key( $level ) ] = $price['_give_amount'];
1024
+				$level                                     = isset($price['_give_text']) ? $price['_give_text'] : 'level-'.$counter;
1025
+				$form['pricing'][sanitize_key($level)] = $price['_give_amount'];
1026 1026
 
1027 1027
 			}
1028 1028
 		} else {
1029
-			$form['pricing']['amount'] = give_get_form_price( $form_info->ID );
1029
+			$form['pricing']['amount'] = give_get_form_price($form_info->ID);
1030 1030
 		}
1031 1031
 
1032
-		if ( user_can( $this->user_id, 'view_give_sensitive_data' ) || $this->override ) {
1032
+		if (user_can($this->user_id, 'view_give_sensitive_data') || $this->override) {
1033 1033
 
1034 1034
 			//Sensitive data here
1035
-			do_action( 'give_api_sensitive_data' );
1035
+			do_action('give_api_sensitive_data');
1036 1036
 
1037 1037
 		}
1038 1038
 
1039
-		return apply_filters( 'give_api_forms_form', $form );
1039
+		return apply_filters('give_api_forms_form', $form);
1040 1040
 
1041 1041
 	}
1042 1042
 
@@ -1051,7 +1051,7 @@  discard block
 block discarded – undo
1051 1051
 	 *
1052 1052
 	 * @return array
1053 1053
 	 */
1054
-	public function get_stats( $args = array() ) {
1054
+	public function get_stats($args = array()) {
1055 1055
 		$defaults = array(
1056 1056
 			'type'      => null,
1057 1057
 			'form'      => null,
@@ -1060,9 +1060,9 @@  discard block
 block discarded – undo
1060 1060
 			'enddate'   => null
1061 1061
 		);
1062 1062
 
1063
-		$args = wp_parse_args( $args, $defaults );
1063
+		$args = wp_parse_args($args, $defaults);
1064 1064
 
1065
-		$dates = $this->get_dates( $args );
1065
+		$dates = $this->get_dates($args);
1066 1066
 
1067 1067
 		$stats     = array();
1068 1068
 		$earnings  = array(
@@ -1071,43 +1071,43 @@  discard block
 block discarded – undo
1071 1071
 		$sales = array(
1072 1072
 			'donations' => array()
1073 1073
 		);
1074
-		$error     = array();
1074
+		$error = array();
1075 1075
 
1076
-		if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) {
1076
+		if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) {
1077 1077
 			return $stats;
1078 1078
 		}
1079 1079
 
1080
-		if ( $args['type'] == 'donations' ) {
1080
+		if ($args['type'] == 'donations') {
1081 1081
 
1082
-			if ( $args['form'] == null ) {
1083
-				if ( $args['date'] == null ) {
1082
+			if ($args['form'] == null) {
1083
+				if ($args['date'] == null) {
1084 1084
 					$sales = $this->get_default_sales_stats();
1085
-				} elseif ( $args['date'] === 'range' ) {
1085
+				} elseif ($args['date'] === 'range') {
1086 1086
 					// Return sales for a date range
1087 1087
 
1088 1088
 					// Ensure the end date is later than the start date
1089
-					if ( $args['enddate'] < $args['startdate'] ) {
1090
-						$error['error'] = __( 'The end date must be later than the start date!', 'give' );
1089
+					if ($args['enddate'] < $args['startdate']) {
1090
+						$error['error'] = __('The end date must be later than the start date!', 'give');
1091 1091
 					}
1092 1092
 
1093 1093
 					// Ensure both the start and end date are specified
1094
-					if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) {
1095
-						$error['error'] = __( 'Invalid or no date range specified!', 'give' );
1094
+					if (empty($args['startdate']) || empty($args['enddate'])) {
1095
+						$error['error'] = __('Invalid or no date range specified!', 'give');
1096 1096
 					}
1097 1097
 
1098 1098
 					$total = 0;
1099 1099
 
1100 1100
 					// Loop through the years
1101 1101
 					$y = $dates['year'];
1102
-					while ( $y <= $dates['year_end'] ) :
1102
+					while ($y <= $dates['year_end']) :
1103 1103
 
1104
-						if ( $dates['year'] == $dates['year_end'] ) {
1104
+						if ($dates['year'] == $dates['year_end']) {
1105 1105
 							$month_start = $dates['m_start'];
1106 1106
 							$month_end   = $dates['m_end'];
1107
-						} elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) {
1107
+						} elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) {
1108 1108
 							$month_start = $dates['m_start'];
1109 1109
 							$month_end   = 12;
1110
-						} elseif ( $y == $dates['year_end'] ) {
1110
+						} elseif ($y == $dates['year_end']) {
1111 1111
 							$month_start = 1;
1112 1112
 							$month_end   = $dates['m_end'];
1113 1113
 						} else {
@@ -1116,109 +1116,109 @@  discard block
 block discarded – undo
1116 1116
 						}
1117 1117
 
1118 1118
 						$i = $month_start;
1119
-						while ( $i <= $month_end ) :
1119
+						while ($i <= $month_end) :
1120 1120
 
1121
-							if ( $i == $dates['m_start'] ) {
1121
+							if ($i == $dates['m_start']) {
1122 1122
 								$d = $dates['day_start'];
1123 1123
 							} else {
1124 1124
 								$d = 1;
1125 1125
 							}
1126 1126
 
1127
-							if ( $i == $dates['m_end'] ) {
1127
+							if ($i == $dates['m_end']) {
1128 1128
 								$num_of_days = $dates['day_end'];
1129 1129
 							} else {
1130
-								$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
1130
+								$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
1131 1131
 							}
1132 1132
 
1133
-							while ( $d <= $num_of_days ) :
1134
-								$sale_count = give_get_sales_by_date( $d, $i, $y );
1135
-								$date_key   = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) );
1136
-								if ( ! isset( $sales['sales'][ $date_key ] ) ) {
1137
-									$sales['sales'][ $date_key ] = 0;
1133
+							while ($d <= $num_of_days) :
1134
+								$sale_count = give_get_sales_by_date($d, $i, $y);
1135
+								$date_key   = date('Ymd', strtotime($y.'/'.$i.'/'.$d));
1136
+								if ( ! isset($sales['sales'][$date_key])) {
1137
+									$sales['sales'][$date_key] = 0;
1138 1138
 								}
1139
-								$sales['sales'][ $date_key ] += $sale_count;
1139
+								$sales['sales'][$date_key] += $sale_count;
1140 1140
 								$total += $sale_count;
1141
-								$d ++;
1141
+								$d++;
1142 1142
 							endwhile;
1143
-							$i ++;
1143
+							$i++;
1144 1144
 						endwhile;
1145 1145
 
1146
-						$y ++;
1146
+						$y++;
1147 1147
 					endwhile;
1148 1148
 
1149 1149
 					$sales['totals'] = $total;
1150 1150
 				} else {
1151
-					if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) {
1151
+					if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') {
1152 1152
 						$sales_count = 0;
1153 1153
 
1154 1154
 						// Loop through the months
1155 1155
 						$month = $dates['m_start'];
1156 1156
 
1157
-						while ( $month <= $dates['m_end'] ) :
1158
-							$sales_count += give_get_sales_by_date( null, $month, $dates['year'] );
1159
-							$month ++;
1157
+						while ($month <= $dates['m_end']) :
1158
+							$sales_count += give_get_sales_by_date(null, $month, $dates['year']);
1159
+							$month++;
1160 1160
 						endwhile;
1161 1161
 
1162
-						$sales['donations'][ $args['date'] ] = $sales_count;
1162
+						$sales['donations'][$args['date']] = $sales_count;
1163 1163
 					} else {
1164
-						$sales['donations'][ $args['date'] ] = give_get_sales_by_date( $dates['day'], $dates['m_start'], $dates['year'] );
1164
+						$sales['donations'][$args['date']] = give_get_sales_by_date($dates['day'], $dates['m_start'], $dates['year']);
1165 1165
 					}
1166 1166
 				}
1167
-			} elseif ( $args['form'] == 'all' ) {
1168
-				$forms = get_posts( array( 'post_type' => 'give_forms', 'nopaging' => true ) );
1167
+			} elseif ($args['form'] == 'all') {
1168
+				$forms = get_posts(array('post_type' => 'give_forms', 'nopaging' => true));
1169 1169
 				$i     = 0;
1170
-				foreach ( $forms as $form_info ) {
1171
-					$sales['donations'][ $i ] = array( $form_info->post_name => give_get_form_sales_stats( $form_info->ID ) );
1172
-					$i ++;
1170
+				foreach ($forms as $form_info) {
1171
+					$sales['donations'][$i] = array($form_info->post_name => give_get_form_sales_stats($form_info->ID));
1172
+					$i++;
1173 1173
 				}
1174 1174
 			} else {
1175
-				if ( get_post_type( $args['form'] ) == 'give_forms' ) {
1176
-					$form_info             = get_post( $args['form'] );
1177
-					$sales['donations'][0] = array( $form_info->post_name => give_get_form_sales_stats( $args['form'] ) );
1175
+				if (get_post_type($args['form']) == 'give_forms') {
1176
+					$form_info             = get_post($args['form']);
1177
+					$sales['donations'][0] = array($form_info->post_name => give_get_form_sales_stats($args['form']));
1178 1178
 				} else {
1179
-					$error['error'] = sprintf( __( 'Product %s not found!', 'give' ), $args['form'] );
1179
+					$error['error'] = sprintf(__('Product %s not found!', 'give'), $args['form']);
1180 1180
 				}
1181 1181
 			}
1182 1182
 
1183
-			if ( ! empty( $error ) ) {
1183
+			if ( ! empty($error)) {
1184 1184
 				return $error;
1185 1185
 			}
1186 1186
 
1187 1187
 			return $sales;
1188 1188
 
1189
-		} elseif ( $args['type'] == 'earnings' ) {
1190
-			if ( $args['form'] == null ) {
1191
-				if ( $args['date'] == null ) {
1189
+		} elseif ($args['type'] == 'earnings') {
1190
+			if ($args['form'] == null) {
1191
+				if ($args['date'] == null) {
1192 1192
 					$earnings = $this->get_default_earnings_stats();
1193
-				} elseif ( $args['date'] === 'range' ) {
1193
+				} elseif ($args['date'] === 'range') {
1194 1194
 					// Return sales for a date range
1195 1195
 
1196 1196
 					// Ensure the end date is later than the start date
1197
-					if ( $args['enddate'] < $args['startdate'] ) {
1198
-						$error['error'] = __( 'The end date must be later than the start date!', 'give' );
1197
+					if ($args['enddate'] < $args['startdate']) {
1198
+						$error['error'] = __('The end date must be later than the start date!', 'give');
1199 1199
 					}
1200 1200
 
1201 1201
 					// Ensure both the start and end date are specified
1202
-					if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) {
1203
-						$error['error'] = __( 'Invalid or no date range specified!', 'give' );
1202
+					if (empty($args['startdate']) || empty($args['enddate'])) {
1203
+						$error['error'] = __('Invalid or no date range specified!', 'give');
1204 1204
 					}
1205 1205
 
1206 1206
 					$total = (float) 0.00;
1207 1207
 
1208 1208
 					// Loop through the years
1209 1209
 					$y = $dates['year'];
1210
-					if ( ! isset( $earnings['earnings'] ) ) {
1210
+					if ( ! isset($earnings['earnings'])) {
1211 1211
 						$earnings['earnings'] = array();
1212 1212
 					}
1213
-					while ( $y <= $dates['year_end'] ) :
1213
+					while ($y <= $dates['year_end']) :
1214 1214
 
1215
-						if ( $dates['year'] == $dates['year_end'] ) {
1215
+						if ($dates['year'] == $dates['year_end']) {
1216 1216
 							$month_start = $dates['m_start'];
1217 1217
 							$month_end   = $dates['m_end'];
1218
-						} elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) {
1218
+						} elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) {
1219 1219
 							$month_start = $dates['m_start'];
1220 1220
 							$month_end   = 12;
1221
-						} elseif ( $y == $dates['year_end'] ) {
1221
+						} elseif ($y == $dates['year_end']) {
1222 1222
 							$month_start = 1;
1223 1223
 							$month_end   = $dates['m_end'];
1224 1224
 						} else {
@@ -1227,88 +1227,88 @@  discard block
 block discarded – undo
1227 1227
 						}
1228 1228
 
1229 1229
 						$i = $month_start;
1230
-						while ( $i <= $month_end ) :
1230
+						while ($i <= $month_end) :
1231 1231
 
1232
-							if ( $i == $dates['m_start'] ) {
1232
+							if ($i == $dates['m_start']) {
1233 1233
 								$d = $dates['day_start'];
1234 1234
 							} else {
1235 1235
 								$d = 1;
1236 1236
 							}
1237 1237
 
1238
-							if ( $i == $dates['m_end'] ) {
1238
+							if ($i == $dates['m_end']) {
1239 1239
 								$num_of_days = $dates['day_end'];
1240 1240
 							} else {
1241
-								$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
1241
+								$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
1242 1242
 							}
1243 1243
 
1244
-							while ( $d <= $num_of_days ) :
1245
-								$earnings_stat = give_get_earnings_by_date( $d, $i, $y );
1246
-								$date_key      = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) );
1247
-								if ( ! isset( $earnings['earnings'][ $date_key ] ) ) {
1248
-									$earnings['earnings'][ $date_key ] = 0;
1244
+							while ($d <= $num_of_days) :
1245
+								$earnings_stat = give_get_earnings_by_date($d, $i, $y);
1246
+								$date_key      = date('Ymd', strtotime($y.'/'.$i.'/'.$d));
1247
+								if ( ! isset($earnings['earnings'][$date_key])) {
1248
+									$earnings['earnings'][$date_key] = 0;
1249 1249
 								}
1250
-								$earnings['earnings'][ $date_key ] += $earnings_stat;
1250
+								$earnings['earnings'][$date_key] += $earnings_stat;
1251 1251
 								$total += $earnings_stat;
1252
-								$d ++;
1252
+								$d++;
1253 1253
 							endwhile;
1254 1254
 
1255
-							$i ++;
1255
+							$i++;
1256 1256
 						endwhile;
1257 1257
 
1258
-						$y ++;
1258
+						$y++;
1259 1259
 					endwhile;
1260 1260
 
1261 1261
 					$earnings['totals'] = $total;
1262 1262
 				} else {
1263
-					if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) {
1263
+					if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') {
1264 1264
 						$earnings_count = (float) 0.00;
1265 1265
 
1266 1266
 						// Loop through the months
1267 1267
 						$month = $dates['m_start'];
1268 1268
 
1269
-						while ( $month <= $dates['m_end'] ) :
1270
-							$earnings_count += give_get_earnings_by_date( null, $month, $dates['year'] );
1271
-							$month ++;
1269
+						while ($month <= $dates['m_end']) :
1270
+							$earnings_count += give_get_earnings_by_date(null, $month, $dates['year']);
1271
+							$month++;
1272 1272
 						endwhile;
1273 1273
 
1274
-						$earnings['earnings'][ $args['date'] ] = $earnings_count;
1274
+						$earnings['earnings'][$args['date']] = $earnings_count;
1275 1275
 					} else {
1276
-						$earnings['earnings'][ $args['date'] ] = give_get_earnings_by_date( $dates['day'], $dates['m_start'], $dates['year'] );
1276
+						$earnings['earnings'][$args['date']] = give_get_earnings_by_date($dates['day'], $dates['m_start'], $dates['year']);
1277 1277
 					}
1278 1278
 				}
1279
-			} elseif ( $args['form'] == 'all' ) {
1280
-				$forms = get_posts( array( 'post_type' => 'give_forms', 'nopaging' => true ) );
1279
+			} elseif ($args['form'] == 'all') {
1280
+				$forms = get_posts(array('post_type' => 'give_forms', 'nopaging' => true));
1281 1281
 
1282 1282
 				$i = 0;
1283
-				foreach ( $forms as $form_info ) {
1284
-					$earnings['earnings'][ $i ] = array( $form_info->post_name => give_get_form_earnings_stats( $form_info->ID ) );
1285
-					$i ++;
1283
+				foreach ($forms as $form_info) {
1284
+					$earnings['earnings'][$i] = array($form_info->post_name => give_get_form_earnings_stats($form_info->ID));
1285
+					$i++;
1286 1286
 				}
1287 1287
 			} else {
1288
-				if ( get_post_type( $args['form'] ) == 'give_forms' ) {
1289
-					$form_info               = get_post( $args['form'] );
1290
-					$earnings['earnings'][0] = array( $form_info->post_name => give_get_form_earnings_stats( $args['form'] ) );
1288
+				if (get_post_type($args['form']) == 'give_forms') {
1289
+					$form_info               = get_post($args['form']);
1290
+					$earnings['earnings'][0] = array($form_info->post_name => give_get_form_earnings_stats($args['form']));
1291 1291
 				} else {
1292
-					$error['error'] = sprintf( __( 'Form %s not found!', 'give' ), $args['form'] );
1292
+					$error['error'] = sprintf(__('Form %s not found!', 'give'), $args['form']);
1293 1293
 				}
1294 1294
 			}
1295 1295
 
1296
-			if ( ! empty( $error ) ) {
1296
+			if ( ! empty($error)) {
1297 1297
 				return $error;
1298 1298
 			}
1299 1299
 
1300 1300
 			return $earnings;
1301
-		} elseif ( $args['type'] == 'donors' ) {
1301
+		} elseif ($args['type'] == 'donors') {
1302 1302
 			$customers                          = new Give_DB_Customers();
1303 1303
 			$stats['donations']['total_donors'] = $customers->count();
1304 1304
 
1305 1305
 			return $stats;
1306 1306
 
1307
-		} elseif ( empty( $args['type'] ) ) {
1308
-			$stats = array_merge( $stats, $this->get_default_sales_stats() );
1309
-			$stats = array_merge( $stats, $this->get_default_earnings_stats() );
1307
+		} elseif (empty($args['type'])) {
1308
+			$stats = array_merge($stats, $this->get_default_sales_stats());
1309
+			$stats = array_merge($stats, $this->get_default_earnings_stats());
1310 1310
 
1311
-			return array( 'stats' => $stats );
1311
+			return array('stats' => $stats);
1312 1312
 		}
1313 1313
 	}
1314 1314
 
@@ -1324,71 +1324,71 @@  discard block
 block discarded – undo
1324 1324
 
1325 1325
 		$sales = array();
1326 1326
 
1327
-		if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) {
1327
+		if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) {
1328 1328
 			return $sales;
1329 1329
 		}
1330 1330
 
1331
-		if ( isset( $wp_query->query_vars['id'] ) ) {
1331
+		if (isset($wp_query->query_vars['id'])) {
1332 1332
 			$query   = array();
1333
-			$query[] = give_get_payment_by( 'id', $wp_query->query_vars['id'] );
1334
-		} elseif ( isset( $wp_query->query_vars['purchasekey'] ) ) {
1333
+			$query[] = give_get_payment_by('id', $wp_query->query_vars['id']);
1334
+		} elseif (isset($wp_query->query_vars['purchasekey'])) {
1335 1335
 			$query   = array();
1336
-			$query[] = give_get_payment_by( 'key', $wp_query->query_vars['purchasekey'] );
1337
-		} elseif ( isset( $wp_query->query_vars['email'] ) ) {
1338
-			$query = give_get_payments( array(
1336
+			$query[] = give_get_payment_by('key', $wp_query->query_vars['purchasekey']);
1337
+		} elseif (isset($wp_query->query_vars['email'])) {
1338
+			$query = give_get_payments(array(
1339 1339
 				'meta_key'   => '_give_payment_user_email',
1340 1340
 				'meta_value' => $wp_query->query_vars['email'],
1341 1341
 				'number'     => $this->per_page(),
1342 1342
 				'page'       => $this->get_paged(),
1343 1343
 				'status'     => 'publish'
1344
-			) );
1344
+			));
1345 1345
 		} else {
1346
-			$query = give_get_payments( array(
1346
+			$query = give_get_payments(array(
1347 1347
 				'number' => $this->per_page(),
1348 1348
 				'page'   => $this->get_paged(),
1349 1349
 				'status' => 'publish'
1350
-			) );
1350
+			));
1351 1351
 		}
1352 1352
 
1353
-		if ( $query ) {
1353
+		if ($query) {
1354 1354
 			$i = 0;
1355
-			foreach ( $query as $payment ) {
1356
-				$payment_meta = give_get_payment_meta( $payment->ID );
1357
-				$user_info    = give_get_payment_meta_user_info( $payment->ID );
1358
-				$first_name   = isset( $user_info['first_name'] ) ? $user_info['first_name'] : '';
1359
-				$last_name    = isset( $user_info['last_name'] ) ? $user_info['last_name'] : '';
1360
-
1361
-				$sales['donations'][ $i ]['ID']             = give_get_payment_number( $payment->ID );
1362
-				$sales['donations'][ $i ]['transaction_id'] = give_get_payment_transaction_id( $payment->ID );
1363
-				$sales['donations'][ $i ]['key']            = give_get_payment_key( $payment->ID );
1364
-				$sales['donations'][ $i ]['total']          = give_get_payment_amount( $payment->ID );
1365
-				$sales['donations'][ $i ]['gateway']        = give_get_payment_gateway( $payment->ID );
1366
-				$sales['donations'][ $i ]['name']           = $first_name . ' ' . $last_name;
1367
-				$sales['donations'][ $i ]['fname']          = $first_name;
1368
-				$sales['donations'][ $i ]['lname']          = $last_name;
1369
-				$sales['donations'][ $i ]['email']          = give_get_payment_user_email( $payment->ID );
1370
-				$sales['donations'][ $i ]['date']           = $payment->post_date;
1371
-
1372
-				$form_id  = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : $payment_meta;
1373
-				$price    = isset( $payment_meta['form_id'] ) ? give_get_form_price( $payment_meta['form_id'] ) : false;
1374
-				$price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null;
1375
-
1376
-				$sales['donations'][ $i ]['form']['id']    = $form_id;
1377
-				$sales['donations'][ $i ]['form']['name']  = get_the_title( $payment_meta['form_id'] );
1378
-				$sales['donations'][ $i ]['form']['price'] = $price;
1379
-
1380
-				if ( give_has_variable_prices( $form_id ) ) {
1381
-					if ( isset( $payment_meta['price_id'] ) ) {
1382
-						$price_name                                     = give_get_price_option_name( $form_id, $payment_meta['price_id'], $payment->ID );
1383
-						$sales['donations'][ $i ]['form']['price_name'] = $price_name;
1384
-						$sales['donations'][ $i ]['form']['price_id']   = $price_id;
1385
-						$sales['donations'][ $i ]['form']['price']      = give_get_price_option_amount( $form_id, $price_id );
1355
+			foreach ($query as $payment) {
1356
+				$payment_meta = give_get_payment_meta($payment->ID);
1357
+				$user_info    = give_get_payment_meta_user_info($payment->ID);
1358
+				$first_name   = isset($user_info['first_name']) ? $user_info['first_name'] : '';
1359
+				$last_name    = isset($user_info['last_name']) ? $user_info['last_name'] : '';
1360
+
1361
+				$sales['donations'][$i]['ID']             = give_get_payment_number($payment->ID);
1362
+				$sales['donations'][$i]['transaction_id'] = give_get_payment_transaction_id($payment->ID);
1363
+				$sales['donations'][$i]['key']            = give_get_payment_key($payment->ID);
1364
+				$sales['donations'][$i]['total']          = give_get_payment_amount($payment->ID);
1365
+				$sales['donations'][$i]['gateway']        = give_get_payment_gateway($payment->ID);
1366
+				$sales['donations'][$i]['name']           = $first_name.' '.$last_name;
1367
+				$sales['donations'][$i]['fname']          = $first_name;
1368
+				$sales['donations'][$i]['lname']          = $last_name;
1369
+				$sales['donations'][$i]['email']          = give_get_payment_user_email($payment->ID);
1370
+				$sales['donations'][$i]['date']           = $payment->post_date;
1371
+
1372
+				$form_id  = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : $payment_meta;
1373
+				$price    = isset($payment_meta['form_id']) ? give_get_form_price($payment_meta['form_id']) : false;
1374
+				$price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null;
1375
+
1376
+				$sales['donations'][$i]['form']['id']    = $form_id;
1377
+				$sales['donations'][$i]['form']['name']  = get_the_title($payment_meta['form_id']);
1378
+				$sales['donations'][$i]['form']['price'] = $price;
1379
+
1380
+				if (give_has_variable_prices($form_id)) {
1381
+					if (isset($payment_meta['price_id'])) {
1382
+						$price_name                                     = give_get_price_option_name($form_id, $payment_meta['price_id'], $payment->ID);
1383
+						$sales['donations'][$i]['form']['price_name'] = $price_name;
1384
+						$sales['donations'][$i]['form']['price_id']   = $price_id;
1385
+						$sales['donations'][$i]['form']['price']      = give_get_price_option_amount($form_id, $price_id);
1386 1386
 
1387 1387
 					}
1388 1388
 				}
1389 1389
 
1390 1390
 				//Add custom meta to API
1391
-				foreach ( $payment_meta as $meta_key => $meta_value ) {
1391
+				foreach ($payment_meta as $meta_key => $meta_value) {
1392 1392
 
1393 1393
 					$exceptions = array(
1394 1394
 						'form_title',
@@ -1401,19 +1401,19 @@  discard block
 block discarded – undo
1401 1401
 					);
1402 1402
 
1403 1403
 					//Don't clutter up results with dupes
1404
-					if ( in_array( $meta_key, $exceptions ) ) {
1404
+					if (in_array($meta_key, $exceptions)) {
1405 1405
 						continue;
1406 1406
 					}
1407 1407
 
1408
-					$sales['donations'][ $i ]['payment_meta'][ $meta_key ] = $meta_value;
1408
+					$sales['donations'][$i]['payment_meta'][$meta_key] = $meta_value;
1409 1409
 
1410 1410
 				}
1411 1411
 
1412
-				$i ++;
1412
+				$i++;
1413 1413
 			}
1414 1414
 		}
1415 1415
 
1416
-		return apply_filters( 'give_api_donations_endpoint', $sales );
1416
+		return apply_filters('give_api_donations_endpoint', $sales);
1417 1417
 	}
1418 1418
 
1419 1419
 	/**
@@ -1428,9 +1428,9 @@  discard block
 block discarded – undo
1428 1428
 	public function get_output_format() {
1429 1429
 		global $wp_query;
1430 1430
 
1431
-		$format = isset( $wp_query->query_vars['format'] ) ? $wp_query->query_vars['format'] : 'json';
1431
+		$format = isset($wp_query->query_vars['format']) ? $wp_query->query_vars['format'] : 'json';
1432 1432
 
1433
-		return apply_filters( 'give_api_output_format', $format );
1433
+		return apply_filters('give_api_output_format', $format);
1434 1434
 	}
1435 1435
 
1436 1436
 
@@ -1446,8 +1446,8 @@  discard block
 block discarded – undo
1446 1446
 	 *
1447 1447
 	 * @return void
1448 1448
 	 */
1449
-	private function log_request( $data = array() ) {
1450
-		if ( ! $this->log_requests ) {
1449
+	private function log_request($data = array()) {
1450
+		if ( ! $this->log_requests) {
1451 1451
 			return;
1452 1452
 		}
1453 1453
 
@@ -1455,36 +1455,36 @@  discard block
 block discarded – undo
1455 1455
 
1456 1456
 		$query = array(
1457 1457
 			'give-api'    => $wp_query->query_vars['give-api'],
1458
-			'key'         => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null,
1459
-			'token'       => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null,
1460
-			'query'       => isset( $wp_query->query_vars['query'] ) ? $wp_query->query_vars['query'] : null,
1461
-			'type'        => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null,
1462
-			'form'        => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null,
1463
-			'customer'    => isset( $wp_query->query_vars['customer'] ) ? $wp_query->query_vars['customer'] : null,
1464
-			'date'        => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null,
1465
-			'startdate'   => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null,
1466
-			'enddate'     => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null,
1467
-			'id'          => isset( $wp_query->query_vars['id'] ) ? $wp_query->query_vars['id'] : null,
1468
-			'purchasekey' => isset( $wp_query->query_vars['purchasekey'] ) ? $wp_query->query_vars['purchasekey'] : null,
1469
-			'email'       => isset( $wp_query->query_vars['email'] ) ? $wp_query->query_vars['email'] : null,
1458
+			'key'         => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null,
1459
+			'token'       => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null,
1460
+			'query'       => isset($wp_query->query_vars['query']) ? $wp_query->query_vars['query'] : null,
1461
+			'type'        => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null,
1462
+			'form'        => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null,
1463
+			'customer'    => isset($wp_query->query_vars['customer']) ? $wp_query->query_vars['customer'] : null,
1464
+			'date'        => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null,
1465
+			'startdate'   => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null,
1466
+			'enddate'     => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null,
1467
+			'id'          => isset($wp_query->query_vars['id']) ? $wp_query->query_vars['id'] : null,
1468
+			'purchasekey' => isset($wp_query->query_vars['purchasekey']) ? $wp_query->query_vars['purchasekey'] : null,
1469
+			'email'       => isset($wp_query->query_vars['email']) ? $wp_query->query_vars['email'] : null,
1470 1470
 		);
1471 1471
 
1472 1472
 		$log_data = array(
1473 1473
 			'log_type'     => 'api_request',
1474
-			'post_excerpt' => http_build_query( $query ),
1475
-			'post_content' => ! empty( $data['error'] ) ? $data['error'] : '',
1474
+			'post_excerpt' => http_build_query($query),
1475
+			'post_content' => ! empty($data['error']) ? $data['error'] : '',
1476 1476
 		);
1477 1477
 
1478 1478
 		$log_meta = array(
1479 1479
 			'request_ip' => give_get_ip(),
1480 1480
 			'user'       => $this->user_id,
1481
-			'key'        => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null,
1482
-			'token'      => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null,
1481
+			'key'        => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null,
1482
+			'token'      => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null,
1483 1483
 			'time'       => $data['request_speed'],
1484 1484
 			'version'    => $this->get_queried_version()
1485 1485
 		);
1486 1486
 
1487
-		$give_logs->insert_log( $log_data, $log_meta );
1487
+		$give_logs->insert_log($log_data, $log_meta);
1488 1488
 	}
1489 1489
 
1490 1490
 
@@ -1508,32 +1508,32 @@  discard block
 block discarded – undo
1508 1508
 	 *
1509 1509
 	 * @param int $status_code
1510 1510
 	 */
1511
-	public function output( $status_code = 200 ) {
1511
+	public function output($status_code = 200) {
1512 1512
 		global $wp_query;
1513 1513
 
1514 1514
 		$format = $this->get_output_format();
1515 1515
 
1516
-		status_header( $status_code );
1516
+		status_header($status_code);
1517 1517
 
1518
-		do_action( 'give_api_output_before', $this->data, $this, $format );
1518
+		do_action('give_api_output_before', $this->data, $this, $format);
1519 1519
 
1520
-		switch ( $format ) :
1520
+		switch ($format) :
1521 1521
 
1522 1522
 			case 'xml' :
1523 1523
 
1524
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/array2xml.php';
1525
-				$xml = Array2XML::createXML( 'give', $this->data );
1524
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/array2xml.php';
1525
+				$xml = Array2XML::createXML('give', $this->data);
1526 1526
 				echo $xml->saveXML();
1527 1527
 
1528 1528
 				break;
1529 1529
 
1530 1530
 			case 'json' :
1531 1531
 
1532
-				header( 'Content-Type: application/json' );
1533
-				if ( ! empty( $this->pretty_print ) ) {
1534
-					echo json_encode( $this->data, $this->pretty_print );
1532
+				header('Content-Type: application/json');
1533
+				if ( ! empty($this->pretty_print)) {
1534
+					echo json_encode($this->data, $this->pretty_print);
1535 1535
 				} else {
1536
-					echo json_encode( $this->data );
1536
+					echo json_encode($this->data);
1537 1537
 				}
1538 1538
 
1539 1539
 				break;
@@ -1542,13 +1542,13 @@  discard block
 block discarded – undo
1542 1542
 			default :
1543 1543
 
1544 1544
 				// Allow other formats to be added via extensions
1545
-				do_action( 'give_api_output_' . $format, $this->data, $this );
1545
+				do_action('give_api_output_'.$format, $this->data, $this);
1546 1546
 
1547 1547
 				break;
1548 1548
 
1549 1549
 		endswitch;
1550 1550
 
1551
-		do_action( 'give_api_output_after', $this->data, $this, $format );
1551
+		do_action('give_api_output_after', $this->data, $this, $format);
1552 1552
 
1553 1553
 		give_die();
1554 1554
 	}
@@ -1565,37 +1565,37 @@  discard block
 block discarded – undo
1565 1565
 	 *
1566 1566
 	 * @return void
1567 1567
 	 */
1568
-	function user_key_field( $user ) {
1568
+	function user_key_field($user) {
1569 1569
 
1570
-		if ( ( give_get_option( 'api_allow_user_keys', false ) || current_user_can( 'manage_give_settings' ) ) && current_user_can( 'edit_user', $user->ID ) ) {
1571
-			$user = get_userdata( $user->ID );
1570
+		if ((give_get_option('api_allow_user_keys', false) || current_user_can('manage_give_settings')) && current_user_can('edit_user', $user->ID)) {
1571
+			$user = get_userdata($user->ID);
1572 1572
 			?>
1573 1573
 			<table class="form-table">
1574 1574
 				<tbody>
1575 1575
 				<tr>
1576 1576
 					<th>
1577
-						<?php esc_attr_e( 'Give API Keys', 'give' ); ?>
1577
+						<?php esc_attr_e('Give API Keys', 'give'); ?>
1578 1578
 					</th>
1579 1579
 					<td>
1580 1580
 						<?php
1581
-						$public_key = $this->get_user_public_key( $user->ID );
1582
-						$secret_key = $this->get_user_secret_key( $user->ID );
1581
+						$public_key = $this->get_user_public_key($user->ID);
1582
+						$secret_key = $this->get_user_secret_key($user->ID);
1583 1583
 						?>
1584
-						<?php if ( empty( $user->give_user_public_key ) ) { ?>
1584
+						<?php if (empty($user->give_user_public_key)) { ?>
1585 1585
 							<input name="give_set_api_key" type="checkbox" id="give_set_api_key" value="0" />
1586
-							<span class="description"><?php esc_attr_e( 'Generate API Key', 'give' ); ?></span>
1586
+							<span class="description"><?php esc_attr_e('Generate API Key', 'give'); ?></span>
1587 1587
 						<?php } else { ?>
1588
-							<strong style="display:inline-block; width: 125px;"><?php _e( 'Public key:', 'give' ); ?>&nbsp;</strong>
1589
-							<input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr( $public_key ); ?>" />
1588
+							<strong style="display:inline-block; width: 125px;"><?php _e('Public key:', 'give'); ?>&nbsp;</strong>
1589
+							<input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr($public_key); ?>" />
1590 1590
 							<br />
1591
-							<strong style="display:inline-block; width: 125px;"><?php esc_attr_e( 'Secret key:', 'give' ); ?>&nbsp;</strong>
1592
-							<input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr( $secret_key ); ?>" />
1591
+							<strong style="display:inline-block; width: 125px;"><?php esc_attr_e('Secret key:', 'give'); ?>&nbsp;</strong>
1592
+							<input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr($secret_key); ?>" />
1593 1593
 							<br />
1594
-							<strong style="display:inline-block; width: 125px;"><?php esc_attr_e( 'Token:', 'give' ); ?>&nbsp;</strong>
1595
-							<input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr( $this->get_token( $user->ID ) ); ?>" />
1594
+							<strong style="display:inline-block; width: 125px;"><?php esc_attr_e('Token:', 'give'); ?>&nbsp;</strong>
1595
+							<input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr($this->get_token($user->ID)); ?>" />
1596 1596
 							<br />
1597 1597
 							<input name="give_set_api_key" type="checkbox" id="give_set_api_key" value="0" />
1598
-							<span class="description"><label for="give_set_api_key"><?php esc_attr_e( 'Revoke API Keys', 'give' ); ?></label></span>
1598
+							<span class="description"><label for="give_set_api_key"><?php esc_attr_e('Revoke API Keys', 'give'); ?></label></span>
1599 1599
 						<?php } ?>
1600 1600
 					</td>
1601 1601
 				</tr>
@@ -1614,53 +1614,53 @@  discard block
 block discarded – undo
1614 1614
 	 *
1615 1615
 	 * @return void
1616 1616
 	 */
1617
-	public function process_api_key( $args ) {
1617
+	public function process_api_key($args) {
1618 1618
 
1619
-		if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'give-api-nonce' ) ) {
1619
+		if ( ! wp_verify_nonce($_REQUEST['_wpnonce'], 'give-api-nonce')) {
1620 1620
 
1621
-			wp_die( esc_attr__( 'Nonce verification failed', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
1621
+			wp_die(esc_attr__('Nonce verification failed', 'give'), __('Error', 'give'), array('response' => 403));
1622 1622
 
1623 1623
 		}
1624 1624
 
1625
-		if ( empty( $args['user_id'] ) ) {
1626
-			wp_die(  esc_attr__( 'User ID Required', 'give' ), esc_attr__( 'Error', 'give' ), array( 'response' => 401 ) );
1625
+		if (empty($args['user_id'])) {
1626
+			wp_die(esc_attr__('User ID Required', 'give'), esc_attr__('Error', 'give'), array('response' => 401));
1627 1627
 		}
1628 1628
 
1629
-		if ( is_numeric( $args['user_id'] ) ) {
1630
-			$user_id = isset( $args['user_id'] ) ? absint( $args['user_id'] ) : get_current_user_id();
1629
+		if (is_numeric($args['user_id'])) {
1630
+			$user_id = isset($args['user_id']) ? absint($args['user_id']) : get_current_user_id();
1631 1631
 		} else {
1632
-			$userdata = get_user_by( 'login', $args['user_id'] );
1632
+			$userdata = get_user_by('login', $args['user_id']);
1633 1633
 			$user_id  = $userdata->ID;
1634 1634
 		}
1635
-		$process = isset( $args['give_api_process'] ) ? strtolower( $args['give_api_process'] ) : false;
1635
+		$process = isset($args['give_api_process']) ? strtolower($args['give_api_process']) : false;
1636 1636
 
1637
-		if ( $user_id == get_current_user_id() && ! give_get_option( 'allow_user_api_keys' ) && ! current_user_can( 'manage_give_settings' ) ) {
1638
-			wp_die( sprintf( __( 'You do not have permission to %s API keys for this user', 'give' ), $process ), __( 'Error', 'give' ), array( 'response' => 403 ) );
1639
-		} elseif ( ! current_user_can( 'manage_give_settings' ) ) {
1640
-			wp_die( sprintf( __( 'You do not have permission to %s API keys for this user', 'give' ), $process ), __( 'Error', 'give' ), array( 'response' => 403 ) );
1637
+		if ($user_id == get_current_user_id() && ! give_get_option('allow_user_api_keys') && ! current_user_can('manage_give_settings')) {
1638
+			wp_die(sprintf(__('You do not have permission to %s API keys for this user', 'give'), $process), __('Error', 'give'), array('response' => 403));
1639
+		} elseif ( ! current_user_can('manage_give_settings')) {
1640
+			wp_die(sprintf(__('You do not have permission to %s API keys for this user', 'give'), $process), __('Error', 'give'), array('response' => 403));
1641 1641
 		}
1642 1642
 
1643
-		switch ( $process ) {
1643
+		switch ($process) {
1644 1644
 			case 'generate':
1645
-				if ( $this->generate_api_key( $user_id ) ) {
1646
-					delete_transient( 'give-total-api-keys' );
1647
-					wp_redirect( add_query_arg( 'give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) );
1645
+				if ($this->generate_api_key($user_id)) {
1646
+					delete_transient('give-total-api-keys');
1647
+					wp_redirect(add_query_arg('give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-settings&tab=api'));
1648 1648
 					exit();
1649 1649
 				} else {
1650
-					wp_redirect( add_query_arg( 'give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) );
1650
+					wp_redirect(add_query_arg('give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-settings&tab=api'));
1651 1651
 					exit();
1652 1652
 				}
1653 1653
 				break;
1654 1654
 			case 'regenerate':
1655
-				$this->generate_api_key( $user_id, true );
1656
-				delete_transient( 'give-total-api-keys' );
1657
-				wp_redirect( add_query_arg( 'give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) );
1655
+				$this->generate_api_key($user_id, true);
1656
+				delete_transient('give-total-api-keys');
1657
+				wp_redirect(add_query_arg('give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-settings&tab=api'));
1658 1658
 				exit();
1659 1659
 				break;
1660 1660
 			case 'revoke':
1661
-				$this->revoke_api_key( $user_id );
1662
-				delete_transient( 'give-total-api-keys' );
1663
-				wp_redirect( add_query_arg( 'give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) );
1661
+				$this->revoke_api_key($user_id);
1662
+				delete_transient('give-total-api-keys');
1663
+				wp_redirect(add_query_arg('give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-settings&tab=api'));
1664 1664
 				exit();
1665 1665
 				break;
1666 1666
 			default;
@@ -1679,34 +1679,34 @@  discard block
 block discarded – undo
1679 1679
 	 *
1680 1680
 	 * @return boolean True if (re)generated succesfully, false otherwise.
1681 1681
 	 */
1682
-	public function generate_api_key( $user_id = 0, $regenerate = false ) {
1682
+	public function generate_api_key($user_id = 0, $regenerate = false) {
1683 1683
 
1684
-		if ( empty( $user_id ) ) {
1684
+		if (empty($user_id)) {
1685 1685
 			return false;
1686 1686
 		}
1687 1687
 
1688
-		$user = get_userdata( $user_id );
1688
+		$user = get_userdata($user_id);
1689 1689
 
1690
-		if ( ! $user ) {
1690
+		if ( ! $user) {
1691 1691
 			return false;
1692 1692
 		}
1693 1693
 
1694
-		$public_key = $this->get_user_public_key( $user_id );
1695
-		$secret_key = $this->get_user_secret_key( $user_id );
1694
+		$public_key = $this->get_user_public_key($user_id);
1695
+		$secret_key = $this->get_user_secret_key($user_id);
1696 1696
 
1697
-		if ( empty( $public_key ) || $regenerate == true ) {
1698
-			$new_public_key = $this->generate_public_key( $user->user_email );
1699
-			$new_secret_key = $this->generate_private_key( $user->ID );
1697
+		if (empty($public_key) || $regenerate == true) {
1698
+			$new_public_key = $this->generate_public_key($user->user_email);
1699
+			$new_secret_key = $this->generate_private_key($user->ID);
1700 1700
 		} else {
1701 1701
 			return false;
1702 1702
 		}
1703 1703
 
1704
-		if ( $regenerate == true ) {
1705
-			$this->revoke_api_key( $user->ID );
1704
+		if ($regenerate == true) {
1705
+			$this->revoke_api_key($user->ID);
1706 1706
 		}
1707 1707
 
1708
-		update_user_meta( $user_id, $new_public_key, 'give_user_public_key' );
1709
-		update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' );
1708
+		update_user_meta($user_id, $new_public_key, 'give_user_public_key');
1709
+		update_user_meta($user_id, $new_secret_key, 'give_user_secret_key');
1710 1710
 
1711 1711
 		return true;
1712 1712
 	}
@@ -1721,26 +1721,26 @@  discard block
 block discarded – undo
1721 1721
 	 *
1722 1722
 	 * @return string
1723 1723
 	 */
1724
-	public function revoke_api_key( $user_id = 0 ) {
1724
+	public function revoke_api_key($user_id = 0) {
1725 1725
 
1726
-		if ( empty( $user_id ) ) {
1726
+		if (empty($user_id)) {
1727 1727
 			return false;
1728 1728
 		}
1729 1729
 
1730
-		$user = get_userdata( $user_id );
1730
+		$user = get_userdata($user_id);
1731 1731
 
1732
-		if ( ! $user ) {
1732
+		if ( ! $user) {
1733 1733
 			return false;
1734 1734
 		}
1735 1735
 
1736
-		$public_key = $this->get_user_public_key( $user_id );
1737
-		$secret_key = $this->get_user_secret_key( $user_id );
1738
-		if ( ! empty( $public_key ) ) {
1739
-			delete_transient( md5( 'give_api_user_' . $public_key ) );
1740
-			delete_transient( md5( 'give_api_user_public_key' . $user_id ) );
1741
-			delete_transient( md5( 'give_api_user_secret_key' . $user_id ) );
1742
-			delete_user_meta( $user_id, $public_key );
1743
-			delete_user_meta( $user_id, $secret_key );
1736
+		$public_key = $this->get_user_public_key($user_id);
1737
+		$secret_key = $this->get_user_secret_key($user_id);
1738
+		if ( ! empty($public_key)) {
1739
+			delete_transient(md5('give_api_user_'.$public_key));
1740
+			delete_transient(md5('give_api_user_public_key'.$user_id));
1741
+			delete_transient(md5('give_api_user_secret_key'.$user_id));
1742
+			delete_user_meta($user_id, $public_key);
1743
+			delete_user_meta($user_id, $secret_key);
1744 1744
 		} else {
1745 1745
 			return false;
1746 1746
 		}
@@ -1765,22 +1765,22 @@  discard block
 block discarded – undo
1765 1765
 	 *
1766 1766
 	 * @return void
1767 1767
 	 */
1768
-	public function update_key( $user_id ) {
1769
-		if ( current_user_can( 'edit_user', $user_id ) && isset( $_POST['give_set_api_key'] ) ) {
1768
+	public function update_key($user_id) {
1769
+		if (current_user_can('edit_user', $user_id) && isset($_POST['give_set_api_key'])) {
1770 1770
 
1771
-			$user = get_userdata( $user_id );
1771
+			$user = get_userdata($user_id);
1772 1772
 
1773
-			$public_key = $this->get_user_public_key( $user_id );
1774
-			$secret_key = $this->get_user_secret_key( $user_id );
1773
+			$public_key = $this->get_user_public_key($user_id);
1774
+			$secret_key = $this->get_user_secret_key($user_id);
1775 1775
 
1776
-			if ( empty( $public_key ) ) {
1777
-				$new_public_key = $this->generate_public_key( $user->user_email );
1778
-				$new_secret_key = $this->generate_private_key( $user->ID );
1776
+			if (empty($public_key)) {
1777
+				$new_public_key = $this->generate_public_key($user->user_email);
1778
+				$new_secret_key = $this->generate_private_key($user->ID);
1779 1779
 
1780
-				update_user_meta( $user_id, $new_public_key, 'give_user_public_key' );
1781
-				update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' );
1780
+				update_user_meta($user_id, $new_public_key, 'give_user_public_key');
1781
+				update_user_meta($user_id, $new_secret_key, 'give_user_secret_key');
1782 1782
 			} else {
1783
-				$this->revoke_api_key( $user_id );
1783
+				$this->revoke_api_key($user_id);
1784 1784
 			}
1785 1785
 		}
1786 1786
 	}
@@ -1795,9 +1795,9 @@  discard block
 block discarded – undo
1795 1795
 	 *
1796 1796
 	 * @return string
1797 1797
 	 */
1798
-	private function generate_public_key( $user_email = '' ) {
1799
-		$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
1800
-		$public   = hash( 'md5', $user_email . $auth_key . date( 'U' ) );
1798
+	private function generate_public_key($user_email = '') {
1799
+		$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
1800
+		$public   = hash('md5', $user_email.$auth_key.date('U'));
1801 1801
 		return $public;
1802 1802
 	}
1803 1803
 
@@ -1811,9 +1811,9 @@  discard block
 block discarded – undo
1811 1811
 	 *
1812 1812
 	 * @return string
1813 1813
 	 */
1814
-	private function generate_private_key( $user_id = 0 ) {
1815
-		$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
1816
-		$secret   = hash( 'md5', $user_id . $auth_key . date( 'U' ) );
1814
+	private function generate_private_key($user_id = 0) {
1815
+		$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
1816
+		$secret   = hash('md5', $user_id.$auth_key.date('U'));
1817 1817
 
1818 1818
 		return $secret;
1819 1819
 	}
@@ -1828,8 +1828,8 @@  discard block
 block discarded – undo
1828 1828
 	 *
1829 1829
 	 * @return string
1830 1830
 	 */
1831
-	public function get_token( $user_id = 0 ) {
1832
-		return hash( 'md5', $this->get_user_secret_key( $user_id ) . $this->get_user_public_key( $user_id ) );
1831
+	public function get_token($user_id = 0) {
1832
+		return hash('md5', $this->get_user_secret_key($user_id).$this->get_user_public_key($user_id));
1833 1833
 	}
1834 1834
 
1835 1835
 	/**
@@ -1843,9 +1843,9 @@  discard block
 block discarded – undo
1843 1843
 
1844 1844
 		// Default sales return
1845 1845
 		$sales                               = array();
1846
-		$sales['donations']['today']         = $this->stats->get_sales( 0, 'today' );
1847
-		$sales['donations']['current_month'] = $this->stats->get_sales( 0, 'this_month' );
1848
-		$sales['donations']['last_month']    = $this->stats->get_sales( 0, 'last_month' );
1846
+		$sales['donations']['today']         = $this->stats->get_sales(0, 'today');
1847
+		$sales['donations']['current_month'] = $this->stats->get_sales(0, 'this_month');
1848
+		$sales['donations']['last_month']    = $this->stats->get_sales(0, 'last_month');
1849 1849
 		$sales['donations']['totals']        = give_get_total_sales();
1850 1850
 
1851 1851
 		return $sales;
@@ -1862,9 +1862,9 @@  discard block
 block discarded – undo
1862 1862
 
1863 1863
 		// Default earnings return
1864 1864
 		$earnings                              = array();
1865
-		$earnings['earnings']['today']         = $this->stats->get_earnings( 0, 'today' );
1866
-		$earnings['earnings']['current_month'] = $this->stats->get_earnings( 0, 'this_month' );
1867
-		$earnings['earnings']['last_month']    = $this->stats->get_earnings( 0, 'last_month' );
1865
+		$earnings['earnings']['today']         = $this->stats->get_earnings(0, 'today');
1866
+		$earnings['earnings']['current_month'] = $this->stats->get_earnings(0, 'this_month');
1867
+		$earnings['earnings']['last_month']    = $this->stats->get_earnings(0, 'last_month');
1868 1868
 		$earnings['earnings']['totals']        = give_get_total_earnings();
1869 1869
 
1870 1870
 		return $earnings;
@@ -1884,25 +1884,25 @@  discard block
 block discarded – undo
1884 1884
 	 *
1885 1885
 	 * @return string            The API key/secret for the user supplied
1886 1886
 	 */
1887
-	public function api_key_backwards_compat( $check, $object_id, $meta_key, $single ) {
1887
+	public function api_key_backwards_compat($check, $object_id, $meta_key, $single) {
1888 1888
 
1889
-		if ( $meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key' ) {
1889
+		if ($meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key') {
1890 1890
 			return $check;
1891 1891
 		}
1892 1892
 
1893 1893
 		$return = $check;
1894 1894
 
1895
-		switch ( $meta_key ) {
1895
+		switch ($meta_key) {
1896 1896
 			case 'give_user_public_key':
1897
-				$return = Give()->api->get_user_public_key( $object_id );
1897
+				$return = Give()->api->get_user_public_key($object_id);
1898 1898
 				break;
1899 1899
 			case 'give_user_secret_key':
1900
-				$return = Give()->api->get_user_secret_key( $object_id );
1900
+				$return = Give()->api->get_user_secret_key($object_id);
1901 1901
 				break;
1902 1902
 		}
1903 1903
 
1904
-		if ( ! $single ) {
1905
-			$return = array( $return );
1904
+		if ( ! $single) {
1905
+			$return = array($return);
1906 1906
 		}
1907 1907
 
1908 1908
 		return $return;
Please login to merge, or discard this patch.
includes/class-give-logging.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 	 * @since 1.0
197 197
 	 * @param array $log_data Log entry data
198 198
 	 * @param array $log_meta Log entry meta
199
-	 * @return bool True if successful, false otherwise
199
+	 * @return boolean|null True if successful, false otherwise
200 200
 	 */
201 201
 	public function update_log( $log_data = array(), $log_meta = array() ) {
202 202
 
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
  * @param string $title
368 368
  * @param string $message
369 369
  * @param int    $parent
370
- * @param null   $type
370
+ * @param string   $type
371 371
  *
372 372
  * @global $give_logs GIVE Logs Object
373 373
  *
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 * @access public
69 69
 	 * @since 1.0
70 70
 	 * @return void
71
-	*/
71
+	 */
72 72
 	public function register_taxonomy() {
73 73
 		register_taxonomy( 'give_log_type', 'give_log', array( 'public' => false ) );
74 74
 	}
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 * @param string $type Log type (default: null)
142 142
 	 * @param int $paged Page number (default: null)
143 143
 	 * @return array Array of the connected logs
144
-	*/
144
+	 */
145 145
 	public function get_logs( $object_id = 0, $type = null, $paged = null ) {
146 146
 		return $this->get_connected_logs( array( 'post_parent' => $object_id, 'paged' => $paged, 'log_type' => $type ) );
147 147
 	}
Please login to merge, or discard this patch.
Spacing   +53 added lines, -53 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' ) ) exit;
13
+if ( ! defined('ABSPATH')) exit;
14 14
 
15 15
 /**
16 16
  * Give_Logging Class
@@ -28,10 +28,10 @@  discard block
 block discarded – undo
28 28
 	 */
29 29
 	public function __construct() {
30 30
 		// Create the log post type
31
-		add_action( 'init', array( $this, 'register_post_type' ), 1 );
31
+		add_action('init', array($this, 'register_post_type'), 1);
32 32
 
33 33
 		// Create types taxonomy and default types
34
-		add_action( 'init', array( $this, 'register_taxonomy' ), 1 );
34
+		add_action('init', array($this, 'register_taxonomy'), 1);
35 35
 
36 36
 	}
37 37
 
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	public function register_post_type() {
46 46
 		/* Logs post type */
47 47
 		$log_args = array(
48
-			'labels'			  => array( 'name' => __( 'Logs', 'give' ) ),
48
+			'labels'			  => array('name' => __('Logs', 'give')),
49 49
 			'public'			  => false,
50 50
 			'exclude_from_search' => true,
51 51
 			'publicly_queryable'  => false,
@@ -53,11 +53,11 @@  discard block
 block discarded – undo
53 53
 			'query_var'			  => false,
54 54
 			'rewrite'			  => false,
55 55
 			'capability_type'	  => 'post',
56
-			'supports'			  => array( 'title', 'editor' ),
56
+			'supports'			  => array('title', 'editor'),
57 57
 			'can_export'		  => true
58 58
 		);
59 59
 
60
-		register_post_type( 'give_log', $log_args );
60
+		register_post_type('give_log', $log_args);
61 61
 	}
62 62
 
63 63
 	/**
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	 * @return void
71 71
 	*/
72 72
 	public function register_taxonomy() {
73
-		register_taxonomy( 'give_log_type', 'give_log', array( 'public' => false ) );
73
+		register_taxonomy('give_log_type', 'give_log', array('public' => false));
74 74
 	}
75 75
 
76 76
 	/**
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 			'sale', 'gateway_error', 'api_request'
88 88
 		);
89 89
 
90
-		return apply_filters( 'give_log_types', $terms );
90
+		return apply_filters('give_log_types', $terms);
91 91
 	}
92 92
 
93 93
 	/**
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 	 * @param string $type Log type
102 102
 	 * @return bool Whether log type is valid
103 103
 	 */
104
-	function valid_type( $type ) {
105
-		return in_array( $type, $this->log_types() );
104
+	function valid_type($type) {
105
+		return in_array($type, $this->log_types());
106 106
 	}
107 107
 
108 108
 	/**
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	 * @param string $type Log type (default: null)
121 121
 	 * @return int Log ID
122 122
 	 */
123
-	public function add( $title = '', $message = '', $parent = 0, $type = null ) {
123
+	public function add($title = '', $message = '', $parent = 0, $type = null) {
124 124
 		$log_data = array(
125 125
 			'post_title' 	=> $title,
126 126
 			'post_content'	=> $message,
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 			'log_type'		=> $type
129 129
 		);
130 130
 
131
-		return $this->insert_log( $log_data );
131
+		return $this->insert_log($log_data);
132 132
 	}
133 133
 
134 134
 	/**
@@ -142,8 +142,8 @@  discard block
 block discarded – undo
142 142
 	 * @param int $paged Page number (default: null)
143 143
 	 * @return array Array of the connected logs
144 144
 	*/
145
-	public function get_logs( $object_id = 0, $type = null, $paged = null ) {
146
-		return $this->get_connected_logs( array( 'post_parent' => $object_id, 'paged' => $paged, 'log_type' => $type ) );
145
+	public function get_logs($object_id = 0, $type = null, $paged = null) {
146
+		return $this->get_connected_logs(array('post_parent' => $object_id, 'paged' => $paged, 'log_type' => $type));
147 147
 	}
148 148
 
149 149
 	/**
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	 * @param array $log_meta Log entry meta
157 157
 	 * @return int The ID of the newly created log item
158 158
 	 */
159
-	function insert_log( $log_data = array(), $log_meta = array() ) {
159
+	function insert_log($log_data = array(), $log_meta = array()) {
160 160
 		$defaults = array(
161 161
 			'post_type' 	=> 'give_log',
162 162
 			'post_status'	=> 'publish',
@@ -165,26 +165,26 @@  discard block
 block discarded – undo
165 165
 			'log_type'		=> false
166 166
 		);
167 167
 
168
-		$args = wp_parse_args( $log_data, $defaults );
168
+		$args = wp_parse_args($log_data, $defaults);
169 169
 
170
-		do_action( 'give_pre_insert_log', $log_data, $log_meta );
170
+		do_action('give_pre_insert_log', $log_data, $log_meta);
171 171
 
172 172
 		// Store the log entry
173
-		$log_id = wp_insert_post( $args );
173
+		$log_id = wp_insert_post($args);
174 174
 
175 175
 		// Set the log type, if any
176
-		if ( $log_data['log_type'] && $this->valid_type( $log_data['log_type'] ) ) {
177
-			wp_set_object_terms( $log_id, $log_data['log_type'], 'give_log_type', false );
176
+		if ($log_data['log_type'] && $this->valid_type($log_data['log_type'])) {
177
+			wp_set_object_terms($log_id, $log_data['log_type'], 'give_log_type', false);
178 178
 		}
179 179
 
180 180
 		// Set log meta, if any
181
-		if ( $log_id && ! empty( $log_meta ) ) {
182
-			foreach ( (array) $log_meta as $key => $meta ) {
183
-				update_post_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta );
181
+		if ($log_id && ! empty($log_meta)) {
182
+			foreach ((array) $log_meta as $key => $meta) {
183
+				update_post_meta($log_id, '_give_log_'.sanitize_key($key), $meta);
184 184
 			}
185 185
 		}
186 186
 
187
-		do_action( 'give_post_insert_log', $log_id, $log_data, $log_meta );
187
+		do_action('give_post_insert_log', $log_id, $log_data, $log_meta);
188 188
 
189 189
 		return $log_id;
190 190
 	}
@@ -198,9 +198,9 @@  discard block
 block discarded – undo
198 198
 	 * @param array $log_meta Log entry meta
199 199
 	 * @return bool True if successful, false otherwise
200 200
 	 */
201
-	public function update_log( $log_data = array(), $log_meta = array() ) {
201
+	public function update_log($log_data = array(), $log_meta = array()) {
202 202
 
203
-		do_action( 'give_pre_update_log', $log_data, $log_meta );
203
+		do_action('give_pre_update_log', $log_data, $log_meta);
204 204
 
205 205
 		$defaults = array(
206 206
 			'post_type' 	=> 'give_log',
@@ -208,19 +208,19 @@  discard block
 block discarded – undo
208 208
 			'post_parent'	=> 0
209 209
 		);
210 210
 
211
-		$args = wp_parse_args( $log_data, $defaults );
211
+		$args = wp_parse_args($log_data, $defaults);
212 212
 
213 213
 		// Store the log entry
214
-		$log_id = wp_update_post( $args );
214
+		$log_id = wp_update_post($args);
215 215
 
216
-		if ( $log_id && ! empty( $log_meta ) ) {
217
-			foreach ( (array) $log_meta as $key => $meta ) {
218
-				if ( ! empty( $meta ) )
219
-					update_post_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta );
216
+		if ($log_id && ! empty($log_meta)) {
217
+			foreach ((array) $log_meta as $key => $meta) {
218
+				if ( ! empty($meta))
219
+					update_post_meta($log_id, '_give_log_'.sanitize_key($key), $meta);
220 220
 			}
221 221
 		}
222 222
 
223
-		do_action( 'give_post_update_log', $log_id, $log_data, $log_meta );
223
+		do_action('give_post_update_log', $log_id, $log_data, $log_meta);
224 224
 	}
225 225
 
226 226
 	/**
@@ -233,18 +233,18 @@  discard block
 block discarded – undo
233 233
 	 * @param array $args Query arguments
234 234
 	 * @return mixed array if logs were found, false otherwise
235 235
 	 */
236
-	public function get_connected_logs( $args = array() ) {
236
+	public function get_connected_logs($args = array()) {
237 237
 		$defaults = array(
238 238
 			'post_type'      => 'give_log',
239 239
 			'posts_per_page' => 20,
240 240
 			'post_status'    => 'publish',
241
-			'paged'          => get_query_var( 'paged' ),
241
+			'paged'          => get_query_var('paged'),
242 242
 			'log_type'       => false
243 243
 		);
244 244
 
245
-		$query_args = wp_parse_args( $args, $defaults );
245
+		$query_args = wp_parse_args($args, $defaults);
246 246
 
247
-		if ( $query_args['log_type'] && $this->valid_type( $query_args['log_type'] ) ) {
247
+		if ($query_args['log_type'] && $this->valid_type($query_args['log_type'])) {
248 248
 			$query_args['tax_query'] = array(
249 249
 				array(
250 250
 					'taxonomy' 	=> 'give_log_type',
@@ -254,9 +254,9 @@  discard block
 block discarded – undo
254 254
 			);
255 255
 		}
256 256
 
257
-		$logs = get_posts( $query_args );
257
+		$logs = get_posts($query_args);
258 258
 
259
-		if ( $logs )
259
+		if ($logs)
260 260
 			return $logs;
261 261
 
262 262
 		// No logs found
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 	 * @param array $date_query Log data query (default: null) (since 1.9)
275 275
 	 * @return int Log count
276 276
 	 */
277
-	public function get_log_count( $object_id = 0, $type = null, $meta_query = null, $date_query = null ) {
277
+	public function get_log_count($object_id = 0, $type = null, $meta_query = null, $date_query = null) {
278 278
 		
279 279
 		global $pagenow, $typenow;
280 280
 
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 			'fields'           => 'ids',
287 287
 		);
288 288
 
289
-		if ( ! empty( $type ) && $this->valid_type( $type ) ) {
289
+		if ( ! empty($type) && $this->valid_type($type)) {
290 290
 			$query_args['tax_query'] = array(
291 291
 				array(
292 292
 					'taxonomy' 	=> 'give_log_type',
@@ -296,15 +296,15 @@  discard block
 block discarded – undo
296 296
 			);
297 297
 		}
298 298
 
299
-		if ( ! empty( $meta_query ) ) {
299
+		if ( ! empty($meta_query)) {
300 300
 			$query_args['meta_query'] = $meta_query;
301 301
 		}
302 302
 
303
-		if ( ! empty( $date_query ) ) {
303
+		if ( ! empty($date_query)) {
304 304
 			$query_args['date_query'] = $date_query;
305 305
 		}
306 306
 
307
-		$logs = new WP_Query( $query_args );
307
+		$logs = new WP_Query($query_args);
308 308
 
309 309
 		return (int) $logs->post_count;
310 310
 	}
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 	 * @param array $meta_query Log meta query (default: null)
321 321
 	 * @return void
322 322
 	 */
323
-	public function delete_logs( $object_id = 0, $type = null, $meta_query = null  ) {
323
+	public function delete_logs($object_id = 0, $type = null, $meta_query = null) {
324 324
 		$query_args = array(
325 325
 			'post_parent' 	=> $object_id,
326 326
 			'post_type'		=> 'give_log',
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 			'fields'        => 'ids'
330 330
 		);
331 331
 
332
-		if ( ! empty( $type ) && $this->valid_type( $type ) ) {
332
+		if ( ! empty($type) && $this->valid_type($type)) {
333 333
 			$query_args['tax_query'] = array(
334 334
 				array(
335 335
 					'taxonomy' 	=> 'give_log_type',
@@ -339,15 +339,15 @@  discard block
 block discarded – undo
339 339
 			);
340 340
 		}
341 341
 
342
-		if ( ! empty( $meta_query ) ) {
342
+		if ( ! empty($meta_query)) {
343 343
 			$query_args['meta_query'] = $meta_query;
344 344
 		}
345 345
 
346
-		$logs = get_posts( $query_args );
346
+		$logs = get_posts($query_args);
347 347
 
348
-		if ( $logs ) {
349
-			foreach ( $logs as $log ) {
350
-				wp_delete_post( $log, true );
348
+		if ($logs) {
349
+			foreach ($logs as $log) {
350
+				wp_delete_post($log, true);
351 351
 			}
352 352
 		}
353 353
 	}
@@ -375,8 +375,8 @@  discard block
 block discarded – undo
375 375
  *
376 376
  * @return mixed ID of the new log entry
377 377
  */
378
-function give_record_log( $title = '', $message = '', $parent = 0, $type = null ) {
378
+function give_record_log($title = '', $message = '', $parent = 0, $type = null) {
379 379
 	global $give_logs;
380
-	$log = $give_logs->add( $title, $message, $parent, $type );
380
+	$log = $give_logs->add($title, $message, $parent, $type);
381 381
 	return $log;
382 382
 }
383 383
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +9 added lines, -5 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) exit;
13
+if ( ! defined( 'ABSPATH' ) ) {
14
+	exit;
15
+}
14 16
 
15 17
 /**
16 18
  * Give_Logging Class
@@ -215,8 +217,9 @@  discard block
 block discarded – undo
215 217
 
216 218
 		if ( $log_id && ! empty( $log_meta ) ) {
217 219
 			foreach ( (array) $log_meta as $key => $meta ) {
218
-				if ( ! empty( $meta ) )
219
-					update_post_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta );
220
+				if ( ! empty( $meta ) ) {
221
+									update_post_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta );
222
+				}
220 223
 			}
221 224
 		}
222 225
 
@@ -256,8 +259,9 @@  discard block
 block discarded – undo
256 259
 
257 260
 		$logs = get_posts( $query_args );
258 261
 
259
-		if ( $logs )
260
-			return $logs;
262
+		if ( $logs ) {
263
+					return $logs;
264
+		}
261 265
 
262 266
 		// No logs found
263 267
 		return false;
Please login to merge, or discard this patch.
includes/class-give-stats.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -121,6 +121,7 @@
 block discarded – undo
121 121
 	 *
122 122
 	 * @access public
123 123
 	 * @since  1.0
124
+	 * @param string|boolean $date
124 125
 	 * @return array|WP_Error If the date is invalid, a WP_Error object will be returned
125 126
 	 */
126 127
 	public function convert_date( $date, $end_date = false ) {
Please login to merge, or discard this patch.
Spacing   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -76,19 +76,19 @@  discard block
 block discarded – undo
76 76
 	 */
77 77
 	public function get_predefined_dates() {
78 78
 		$predefined = array(
79
-			'today'        => __( 'Today', 'give' ),
80
-			'yesterday'    => __( 'Yesterday', 'give' ),
81
-			'this_week'    => __( 'This Week', 'give' ),
82
-			'last_week'    => __( 'Last Week', 'give' ),
83
-			'this_month'   => __( 'This Month', 'give' ),
84
-			'last_month'   => __( 'Last Month', 'give' ),
85
-			'this_quarter' => __( 'This Quarter', 'give' ),
86
-			'last_quarter' => __( 'Last Quarter', 'give' ),
87
-			'this_year'    => __( 'This Year', 'give' ),
88
-			'last_year'    => __( 'Last Year', 'give' )
79
+			'today'        => __('Today', 'give'),
80
+			'yesterday'    => __('Yesterday', 'give'),
81
+			'this_week'    => __('This Week', 'give'),
82
+			'last_week'    => __('Last Week', 'give'),
83
+			'this_month'   => __('This Month', 'give'),
84
+			'last_month'   => __('Last Month', 'give'),
85
+			'this_quarter' => __('This Quarter', 'give'),
86
+			'last_quarter' => __('Last Quarter', 'give'),
87
+			'this_year'    => __('This Year', 'give'),
88
+			'last_year'    => __('Last Year', 'give')
89 89
 		);
90 90
 
91
-		return apply_filters( 'give_stats_predefined_dates', $predefined );
91
+		return apply_filters('give_stats_predefined_dates', $predefined);
92 92
 	}
93 93
 
94 94
 	/**
@@ -104,20 +104,20 @@  discard block
 block discarded – undo
104 104
 	 *
105 105
 	 * @return void
106 106
 	 */
107
-	public function setup_dates( $_start_date = 'this_month', $_end_date = false ) {
107
+	public function setup_dates($_start_date = 'this_month', $_end_date = false) {
108 108
 
109
-		if ( empty( $_start_date ) ) {
109
+		if (empty($_start_date)) {
110 110
 			$this->start_date = 'this_month';
111 111
 		}
112 112
 
113 113
 		$this->start_date = $_start_date;
114 114
 
115
-		if ( empty( $_end_date ) ) {
115
+		if (empty($_end_date)) {
116 116
 			$_end_date = $_start_date;
117 117
 		}
118 118
 
119
-		$this->start_date = $this->convert_date( $_start_date );
120
-		$this->end_date   = $this->convert_date( $_end_date, true );
119
+		$this->start_date = $this->convert_date($_start_date);
120
+		$this->end_date   = $this->convert_date($_end_date, true);
121 121
 	}
122 122
 
123 123
 	/**
@@ -127,26 +127,26 @@  discard block
 block discarded – undo
127 127
 	 * @since  1.0
128 128
 	 * @return array|WP_Error If the date is invalid, a WP_Error object will be returned
129 129
 	 */
130
-	public function convert_date( $date, $end_date = false ) {
130
+	public function convert_date($date, $end_date = false) {
131 131
 
132 132
 		$timestamp = false;
133 133
 		$second    = 0;
134 134
 		$minute    = 0;
135 135
 		$hour      = 0;
136 136
 		$day       = 1;
137
-		$month     = date( 'n', current_time( 'timestamp' ) );
138
-		$year      = date( 'Y', current_time( 'timestamp' ) );
137
+		$month     = date('n', current_time('timestamp'));
138
+		$year      = date('Y', current_time('timestamp'));
139 139
 
140
-		if ( array_key_exists( $date, $this->get_predefined_dates() ) ) {
140
+		if (array_key_exists($date, $this->get_predefined_dates())) {
141 141
 
142 142
 			// This is a predefined date rate, such as last_week
143
-			switch ( $date ) {
143
+			switch ($date) {
144 144
 
145 145
 				case 'this_month' :
146 146
 
147
-					if ( $end_date ) {
147
+					if ($end_date) {
148 148
 
149
-						$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
149
+						$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
150 150
 
151 151
 					}
152 152
 
@@ -154,28 +154,28 @@  discard block
 block discarded – undo
154 154
 
155 155
 				case 'last_month' :
156 156
 
157
-					if ( $month == 1 ) {
157
+					if ($month == 1) {
158 158
 
159 159
 						$month = 12;
160
-						$year --;
160
+						$year--;
161 161
 
162 162
 					} else {
163 163
 
164
-						$month --;
164
+						$month--;
165 165
 
166 166
 					}
167 167
 
168
-					if ( $end_date ) {
169
-						$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
168
+					if ($end_date) {
169
+						$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
170 170
 					}
171 171
 
172 172
 					break;
173 173
 
174 174
 				case 'today' :
175 175
 
176
-					$day = date( 'd', current_time( 'timestamp' ) );
176
+					$day = date('d', current_time('timestamp'));
177 177
 
178
-					if ( $end_date ) {
178
+					if ($end_date) {
179 179
 						$hour   = 11;
180 180
 						$minute = 59;
181 181
 						$second = 59;
@@ -185,23 +185,23 @@  discard block
 block discarded – undo
185 185
 
186 186
 				case 'yesterday' :
187 187
 
188
-					$day = date( 'd', current_time( 'timestamp' ) ) - 1;
188
+					$day = date('d', current_time('timestamp')) - 1;
189 189
 
190 190
 					// Check if Today is the first day of the month (meaning subtracting one will get us 0)
191
-					if ( $day < 1 ) {
191
+					if ($day < 1) {
192 192
 
193 193
 						// If current month is 1
194
-						if ( 1 == $month ) {
194
+						if (1 == $month) {
195 195
 
196 196
 							$year -= 1; // Today is January 1, so skip back to last day of December
197 197
 							$month = 12;
198
-							$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
198
+							$day   = cal_days_in_month(CAL_GREGORIAN, $month, $year);
199 199
 
200 200
 						} else {
201 201
 
202 202
 							// Go back one month and get the last day of the month
203 203
 							$month -= 1;
204
-							$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
204
+							$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
205 205
 
206 206
 						}
207 207
 					}
@@ -210,12 +210,12 @@  discard block
 block discarded – undo
210 210
 
211 211
 				case 'this_week' :
212 212
 
213
-					$days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24;
214
-					$today              = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24;
213
+					$days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24;
214
+					$today              = date('d', current_time('timestamp')) * 60 * 60 * 24;
215 215
 
216
-					if ( $today < $days_to_week_start ) {
216
+					if ($today < $days_to_week_start) {
217 217
 
218
-						if ( $month > 1 ) {
218
+						if ($month > 1) {
219 219
 							$month -= 1;
220 220
 						} else {
221 221
 							$month = 12;
@@ -223,19 +223,19 @@  discard block
 block discarded – undo
223 223
 
224 224
 					}
225 225
 
226
-					if ( ! $end_date ) {
226
+					if ( ! $end_date) {
227 227
 
228 228
 						// Getting the start day
229 229
 
230
-						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1;
231
-						$day += get_option( 'start_of_week' );
230
+						$day = date('d', current_time('timestamp') - $days_to_week_start) - 1;
231
+						$day += get_option('start_of_week');
232 232
 
233 233
 					} else {
234 234
 
235 235
 						// Getting the end day
236 236
 
237
-						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1;
238
-						$day += get_option( 'start_of_week' ) + 6;
237
+						$day = date('d', current_time('timestamp') - $days_to_week_start) - 1;
238
+						$day += get_option('start_of_week') + 6;
239 239
 
240 240
 					}
241 241
 
@@ -243,12 +243,12 @@  discard block
 block discarded – undo
243 243
 
244 244
 				case 'last_week' :
245 245
 
246
-					$days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24;
247
-					$today              = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24;
246
+					$days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24;
247
+					$today              = date('d', current_time('timestamp')) * 60 * 60 * 24;
248 248
 
249
-					if ( $today < $days_to_week_start ) {
249
+					if ($today < $days_to_week_start) {
250 250
 
251
-						if ( $month > 1 ) {
251
+						if ($month > 1) {
252 252
 							$month -= 1;
253 253
 						} else {
254 254
 							$month = 12;
@@ -256,19 +256,19 @@  discard block
 block discarded – undo
256 256
 
257 257
 					}
258 258
 
259
-					if ( ! $end_date ) {
259
+					if ( ! $end_date) {
260 260
 
261 261
 						// Getting the start day
262 262
 
263
-						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8;
264
-						$day += get_option( 'start_of_week' );
263
+						$day = date('d', current_time('timestamp') - $days_to_week_start) - 8;
264
+						$day += get_option('start_of_week');
265 265
 
266 266
 					} else {
267 267
 
268 268
 						// Getting the end day
269 269
 
270
-						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8;
271
-						$day += get_option( 'start_of_week' ) + 6;
270
+						$day = date('d', current_time('timestamp') - $days_to_week_start) - 8;
271
+						$day += get_option('start_of_week') + 6;
272 272
 
273 273
 					}
274 274
 
@@ -276,39 +276,39 @@  discard block
 block discarded – undo
276 276
 
277 277
 				case 'this_quarter' :
278 278
 
279
-					$month_now = date( 'n', current_time( 'timestamp' ) );
279
+					$month_now = date('n', current_time('timestamp'));
280 280
 
281
-					if ( $month_now <= 3 ) {
281
+					if ($month_now <= 3) {
282 282
 
283
-						if ( ! $end_date ) {
283
+						if ( ! $end_date) {
284 284
 							$month = 1;
285 285
 						} else {
286 286
 							$month  = 3;
287
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
287
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
288 288
 							$hour   = 11;
289 289
 							$minute = 59;
290 290
 							$second = 59;
291 291
 						}
292 292
 
293
-					} else if ( $month_now <= 6 ) {
293
+					} else if ($month_now <= 6) {
294 294
 
295
-						if ( ! $end_date ) {
295
+						if ( ! $end_date) {
296 296
 							$month = 4;
297 297
 						} else {
298 298
 							$month  = 6;
299
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
299
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
300 300
 							$hour   = 11;
301 301
 							$minute = 59;
302 302
 							$second = 59;
303 303
 						}
304 304
 
305
-					} else if ( $month_now <= 9 ) {
305
+					} else if ($month_now <= 9) {
306 306
 
307
-						if ( ! $end_date ) {
307
+						if ( ! $end_date) {
308 308
 							$month = 7;
309 309
 						} else {
310 310
 							$month  = 9;
311
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
311
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
312 312
 							$hour   = 11;
313 313
 							$minute = 59;
314 314
 							$second = 59;
@@ -316,11 +316,11 @@  discard block
 block discarded – undo
316 316
 
317 317
 					} else {
318 318
 
319
-						if ( ! $end_date ) {
319
+						if ( ! $end_date) {
320 320
 							$month = 10;
321 321
 						} else {
322 322
 							$month  = 12;
323
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
323
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
324 324
 							$hour   = 11;
325 325
 							$minute = 59;
326 326
 							$second = 59;
@@ -332,40 +332,40 @@  discard block
 block discarded – undo
332 332
 
333 333
 				case 'last_quarter' :
334 334
 
335
-					$month_now = date( 'n', current_time( 'timestamp' ) );
335
+					$month_now = date('n', current_time('timestamp'));
336 336
 
337
-					if ( $month_now <= 3 ) {
337
+					if ($month_now <= 3) {
338 338
 
339
-						if ( ! $end_date ) {
339
+						if ( ! $end_date) {
340 340
 							$month = 10;
341 341
 						} else {
342 342
 							$year -= 1;
343 343
 							$month  = 12;
344
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
344
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
345 345
 							$hour   = 11;
346 346
 							$minute = 59;
347 347
 							$second = 59;
348 348
 						}
349 349
 
350
-					} else if ( $month_now <= 6 ) {
350
+					} else if ($month_now <= 6) {
351 351
 
352
-						if ( ! $end_date ) {
352
+						if ( ! $end_date) {
353 353
 							$month = 1;
354 354
 						} else {
355 355
 							$month  = 3;
356
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
356
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
357 357
 							$hour   = 11;
358 358
 							$minute = 59;
359 359
 							$second = 59;
360 360
 						}
361 361
 
362
-					} else if ( $month_now <= 9 ) {
362
+					} else if ($month_now <= 9) {
363 363
 
364
-						if ( ! $end_date ) {
364
+						if ( ! $end_date) {
365 365
 							$month = 4;
366 366
 						} else {
367 367
 							$month  = 6;
368
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
368
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
369 369
 							$hour   = 11;
370 370
 							$minute = 59;
371 371
 							$second = 59;
@@ -373,11 +373,11 @@  discard block
 block discarded – undo
373 373
 
374 374
 					} else {
375 375
 
376
-						if ( ! $end_date ) {
376
+						if ( ! $end_date) {
377 377
 							$month = 7;
378 378
 						} else {
379 379
 							$month  = 9;
380
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
380
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
381 381
 							$hour   = 11;
382 382
 							$minute = 59;
383 383
 							$second = 59;
@@ -389,11 +389,11 @@  discard block
 block discarded – undo
389 389
 
390 390
 				case 'this_year' :
391 391
 
392
-					if ( ! $end_date ) {
392
+					if ( ! $end_date) {
393 393
 						$month = 1;
394 394
 					} else {
395 395
 						$month  = 12;
396
-						$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
396
+						$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
397 397
 						$hour   = 11;
398 398
 						$minute = 59;
399 399
 						$second = 59;
@@ -404,11 +404,11 @@  discard block
 block discarded – undo
404 404
 				case 'last_year' :
405 405
 
406 406
 					$year -= 1;
407
-					if ( ! $end_date ) {
407
+					if ( ! $end_date) {
408 408
 						$month = 1;
409 409
 					} else {
410 410
 						$month  = 12;
411
-						$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
411
+						$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
412 412
 						$hour   = 11;
413 413
 						$minute = 59;
414 414
 						$second = 59;
@@ -419,30 +419,30 @@  discard block
 block discarded – undo
419 419
 			}
420 420
 
421 421
 
422
-		} else if ( is_numeric( $date ) ) {
422
+		} else if (is_numeric($date)) {
423 423
 
424 424
 			// return $date unchanged since it is a timestamp
425 425
 			$this->timestamp = true;
426 426
 
427
-		} else if ( false !== strtotime( $date ) ) {
427
+		} else if (false !== strtotime($date)) {
428 428
 
429 429
 			$this->timestamp = true;
430
-			$date            = strtotime( $date, current_time( 'timestamp' ) );
430
+			$date            = strtotime($date, current_time('timestamp'));
431 431
 
432 432
 		} else {
433 433
 
434
-			return new WP_Error( 'invalid_date', __( 'Improper date provided.', 'give' ) );
434
+			return new WP_Error('invalid_date', __('Improper date provided.', 'give'));
435 435
 
436 436
 		}
437 437
 
438
-		if ( ! is_wp_error( $date ) && ! $this->timestamp ) {
438
+		if ( ! is_wp_error($date) && ! $this->timestamp) {
439 439
 
440 440
 			// Create an exact timestamp
441
-			$date = mktime( $hour, $minute, $second, $month, $day, $year );
441
+			$date = mktime($hour, $minute, $second, $month, $day, $year);
442 442
 
443 443
 		}
444 444
 
445
-		return apply_filters( 'give_stats_date', $date, $end_date, $this );
445
+		return apply_filters('give_stats_date', $date, $end_date, $this);
446 446
 
447 447
 	}
448 448
 
@@ -453,33 +453,33 @@  discard block
 block discarded – undo
453 453
 	 * @since  1.0
454 454
 	 * @return string
455 455
 	 */
456
-	public function count_where( $where = '' ) {
456
+	public function count_where($where = '') {
457 457
 		// Only get payments in our date range
458 458
 
459 459
 		$start_where = '';
460 460
 		$end_where   = '';
461 461
 
462
-		if ( $this->start_date ) {
462
+		if ($this->start_date) {
463 463
 
464
-			if ( $this->timestamp ) {
464
+			if ($this->timestamp) {
465 465
 				$format = 'Y-m-d H:i:s';
466 466
 			} else {
467 467
 				$format = 'Y-m-d 00:00:00';
468 468
 			}
469 469
 
470
-			$start_date  = date( $format, $this->start_date );
470
+			$start_date  = date($format, $this->start_date);
471 471
 			$start_where = " AND p.post_date >= '{$start_date}'";
472 472
 		}
473 473
 
474
-		if ( $this->end_date ) {
474
+		if ($this->end_date) {
475 475
 
476
-			if ( $this->timestamp ) {
476
+			if ($this->timestamp) {
477 477
 				$format = 'Y-m-d H:i:s';
478 478
 			} else {
479 479
 				$format = 'Y-m-d 23:59:59';
480 480
 			}
481 481
 
482
-			$end_date = date( $format, $this->end_date );
482
+			$end_date = date($format, $this->end_date);
483 483
 
484 484
 			$end_where = " AND p.post_date <= '{$end_date}'";
485 485
 		}
@@ -499,34 +499,34 @@  discard block
 block discarded – undo
499 499
 	 *
500 500
 	 * @return string
501 501
 	 */
502
-	public function payments_where( $where = '' ) {
502
+	public function payments_where($where = '') {
503 503
 
504 504
 		global $wpdb;
505 505
 
506 506
 		$start_where = '';
507 507
 		$end_where   = '';
508 508
 
509
-		if ( $this->start_date ) {
509
+		if ($this->start_date) {
510 510
 
511
-			if ( $this->timestamp ) {
511
+			if ($this->timestamp) {
512 512
 				$format = 'Y-m-d H:i:s';
513 513
 			} else {
514 514
 				$format = 'Y-m-d 00:00:00';
515 515
 			}
516 516
 
517
-			$start_date  = date( $format, $this->start_date );
517
+			$start_date  = date($format, $this->start_date);
518 518
 			$start_where = " AND $wpdb->posts.post_date >= '{$start_date}'";
519 519
 		}
520 520
 
521
-		if ( $this->end_date ) {
521
+		if ($this->end_date) {
522 522
 
523
-			if ( $this->timestamp ) {
523
+			if ($this->timestamp) {
524 524
 				$format = 'Y-m-d H:i:s';
525 525
 			} else {
526 526
 				$format = 'Y-m-d 23:59:59';
527 527
 			}
528 528
 
529
-			$end_date = date( $format, $this->end_date );
529
+			$end_date = date($format, $this->end_date);
530 530
 
531 531
 			$end_where = " AND $wpdb->posts.post_date <= '{$end_date}'";
532 532
 		}
Please login to merge, or discard this patch.
includes/forms/template.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * @param array $args Arguments for display
23 23
  *
24
- * @return string $purchase_form
24
+ * @return false|null $purchase_form
25 25
  */
26 26
 function give_get_donation_form( $args = array() ) {
27 27
 
@@ -1150,7 +1150,7 @@  discard block
 block discarded – undo
1150 1150
  * @param int   $form_id
1151 1151
  * @param array $args
1152 1152
  *
1153
- * @return mixed
1153
+ * @return boolean
1154 1154
  */
1155 1155
 
1156 1156
 function give_show_goal_progress( $form_id, $args ) {
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1170,9 +1170,9 @@
 block discarded – undo
1170 1170
 
1171 1171
 	//Sanity check - ensure form has goal set to output
1172 1172
 	if ( empty( $form->ID )
1173
-	     || ( is_singular( 'give_forms' ) && $goal_option !== 'yes' )
1174
-	     || $goal_option !== 'yes'
1175
-	     || $goal == 0
1173
+		 || ( is_singular( 'give_forms' ) && $goal_option !== 'yes' )
1174
+		 || $goal_option !== 'yes'
1175
+		 || $goal == 0
1176 1176
 	) {
1177 1177
 		//not this form, bail
1178 1178
 		return false;
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -740,8 +740,11 @@
 block discarded – undo
740 740
 					}
741 741
 					?>
742 742
 				</select>
743
-			<?php else : ?>
744
-				<input type="text" size="6" name="card_state" id="card_state" class="card_state give-input" placeholder="<?php _e( 'State / Province', 'give' ); ?>"/>
743
+			<?php else {
744
+	: ?>
745
+				<input type="text" size="6" name="card_state" id="card_state" class="card_state give-input" placeholder="<?php _e( 'State / Province', 'give' );
746
+}
747
+?>"/>
745 748
 			<?php endif; ?>
746 749
 		</p>
747 750
 		<?php do_action( 'give_cc_billing_bottom' ); ?>
Please login to merge, or discard this patch.
Spacing   +390 added lines, -390 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -23,64 +23,64 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return string $purchase_form
25 25
  */
26
-function give_get_donation_form( $args = array() ) {
26
+function give_get_donation_form($args = array()) {
27 27
 
28 28
 	global $post;
29 29
 
30
-	$form_id = is_object( $post ) ? $post->ID : 0;
30
+	$form_id = is_object($post) ? $post->ID : 0;
31 31
 
32
-	if ( isset( $args['id'] ) ) {
32
+	if (isset($args['id'])) {
33 33
 		$form_id = $args['id'];
34 34
 	}
35 35
 
36
-	$defaults = apply_filters( 'give_form_args_defaults', array(
36
+	$defaults = apply_filters('give_form_args_defaults', array(
37 37
 		'form_id' => $form_id
38
-	) );
38
+	));
39 39
 
40
-	$args = wp_parse_args( $args, $defaults );
40
+	$args = wp_parse_args($args, $defaults);
41 41
 
42
-	$form = new Give_Donate_Form( $args['form_id'] );
42
+	$form = new Give_Donate_Form($args['form_id']);
43 43
 
44 44
 	//bail if no form ID
45
-	if ( empty( $form->ID ) ) {
45
+	if (empty($form->ID)) {
46 46
 		return false;
47 47
 	}
48 48
 
49
-	$payment_mode = give_get_chosen_gateway( $form->ID );
49
+	$payment_mode = give_get_chosen_gateway($form->ID);
50 50
 
51
-	$form_action = esc_url( add_query_arg( apply_filters( 'give_form_action_args', array(
51
+	$form_action = esc_url(add_query_arg(apply_filters('give_form_action_args', array(
52 52
 		'payment-mode' => $payment_mode,
53
-	) ),
53
+	)),
54 54
 		give_get_current_page_url()
55
-	) );
55
+	));
56 56
 
57 57
 	//Sanity Check: Donation form not published or user doesn't have permission to view drafts
58
-	if ( 'publish' !== $form->post_status && ! current_user_can( 'edit_give_forms', $form->ID ) ) {
58
+	if ('publish' !== $form->post_status && ! current_user_can('edit_give_forms', $form->ID)) {
59 59
 		return false;
60 60
 	}
61 61
 
62
-	$display_option = ( isset( $args['display_style'] ) && ! empty( $args['display_style'] ) )
62
+	$display_option = (isset($args['display_style']) && ! empty($args['display_style']))
63 63
 		? $args['display_style']
64
-		: get_post_meta( $form->ID, '_give_payment_display', true );
64
+		: get_post_meta($form->ID, '_give_payment_display', true);
65 65
 
66
-	$float_labels_option = give_is_float_labels_enabled( $args )
66
+	$float_labels_option = give_is_float_labels_enabled($args)
67 67
 		? ' float-labels-enabled'
68 68
 		: '';
69 69
 
70 70
 	//Form Wrap Classes
71
-	$form_wrap_classes_array = apply_filters( 'give_form_wrap_classes', array(
71
+	$form_wrap_classes_array = apply_filters('give_form_wrap_classes', array(
72 72
 		'give-form-wrap',
73
-		'give-display-' . $display_option
74
-	), $form->ID, $args );
75
-	$form_wrap_classes       = implode( ' ', $form_wrap_classes_array );
73
+		'give-display-'.$display_option
74
+	), $form->ID, $args);
75
+	$form_wrap_classes = implode(' ', $form_wrap_classes_array);
76 76
 
77 77
 	//Form Classes
78
-	$form_classes_array = apply_filters( 'give_form_classes', array(
78
+	$form_classes_array = apply_filters('give_form_classes', array(
79 79
 		'give-form',
80
-		'give-form-' . $form->ID,
80
+		'give-form-'.$form->ID,
81 81
 		$float_labels_option
82
-	), $form->ID, $args );
83
-	$form_classes       = implode( ' ', $form_classes_array );
82
+	), $form->ID, $args);
83
+	$form_classes = implode(' ', $form_classes_array);
84 84
 
85 85
 
86 86
 	ob_start();
@@ -93,35 +93,35 @@  discard block
 block discarded – undo
93 93
 	 * @param int $form ->ID The current form ID
94 94
 	 * @param array $args An array of form args
95 95
 	 */
96
-	do_action( 'give_pre_form_output', $form->ID, $args ); ?>
96
+	do_action('give_pre_form_output', $form->ID, $args); ?>
97 97
 
98 98
 	<div id="give-form-<?php echo $form->ID; ?>-wrap" class="<?php echo $form_wrap_classes; ?>">
99 99
 
100 100
 		<?php
101
-		if ( isset( $args['show_title'] ) && $args['show_title'] == true ) {
101
+		if (isset($args['show_title']) && $args['show_title'] == true) {
102 102
 
103
-			echo apply_filters( 'give_form_title', '<h2 class="give-form-title">' . get_the_title( $form_id ) . '</h2>' );
103
+			echo apply_filters('give_form_title', '<h2 class="give-form-title">'.get_the_title($form_id).'</h2>');
104 104
 
105 105
 		} ?>
106 106
 
107
-		<?php do_action( 'give_pre_form', $form->ID, $args ); ?>
107
+		<?php do_action('give_pre_form', $form->ID, $args); ?>
108 108
 
109 109
 		<form id="give-form-<?php echo $form_id; ?>" class="<?php echo $form_classes; ?>" action="<?php echo $form_action; ?>" method="post">
110 110
 			<input type="hidden" name="give-form-id" value="<?php echo $form->ID; ?>"/>
111
-			<input type="hidden" name="give-form-title" value="<?php echo htmlentities( $form->post_title ); ?>"/>
112
-			<input type="hidden" name="give-current-url" value="<?php echo htmlspecialchars( give_get_current_page_url() ); ?>"/>
113
-			<input type="hidden" name="give-form-url" value="<?php echo htmlspecialchars( give_get_current_page_url() ); ?>"/>
114
-			<input type="hidden" name="give-form-minimum" value="<?php echo give_format_amount( give_get_form_minimum_price( $form->ID ) ); ?>"/>
111
+			<input type="hidden" name="give-form-title" value="<?php echo htmlentities($form->post_title); ?>"/>
112
+			<input type="hidden" name="give-current-url" value="<?php echo htmlspecialchars(give_get_current_page_url()); ?>"/>
113
+			<input type="hidden" name="give-form-url" value="<?php echo htmlspecialchars(give_get_current_page_url()); ?>"/>
114
+			<input type="hidden" name="give-form-minimum" value="<?php echo give_format_amount(give_get_form_minimum_price($form->ID)); ?>"/>
115 115
 			<?php
116 116
 
117 117
 			//Price ID hidden field for variable (mult-level) donation forms
118
-			if ( give_has_variable_prices( $form_id ) ) {
118
+			if (give_has_variable_prices($form_id)) {
119 119
 				//get default selected price ID
120
-				$prices   = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id );
120
+				$prices   = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id);
121 121
 				$price_id = 0;
122 122
 				//loop through prices
123
-				foreach ( $prices as $price ) {
124
-					if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) {
123
+				foreach ($prices as $price) {
124
+					if (isset($price['_give_default']) && $price['_give_default'] === 'default') {
125 125
 						$price_id = $price['_give_id']['level_id'];
126 126
 					};
127 127
 				}
@@ -129,19 +129,19 @@  discard block
 block discarded – undo
129 129
 				<input type="hidden" name="give-price-id" value="<?php echo $price_id; ?>"/>
130 130
 			<?php }
131 131
 
132
-			do_action( 'give_checkout_form_top', $form->ID, $args );
132
+			do_action('give_checkout_form_top', $form->ID, $args);
133 133
 
134
-			do_action( 'give_payment_mode_select', $form->ID, $args );
134
+			do_action('give_payment_mode_select', $form->ID, $args);
135 135
 
136
-			do_action( 'give_checkout_form_bottom', $form->ID, $args );
136
+			do_action('give_checkout_form_bottom', $form->ID, $args);
137 137
 
138 138
 			?>
139 139
 
140 140
 		</form>
141 141
 
142
-		<?php do_action( 'give_post_form', $form->ID, $args ); ?>
142
+		<?php do_action('give_post_form', $form->ID, $args); ?>
143 143
 
144
-		<!--end #give-form-<?php echo absint( $form->ID ); ?>--></div>
144
+		<!--end #give-form-<?php echo absint($form->ID); ?>--></div>
145 145
 	<?php
146 146
 
147 147
 	/**
@@ -152,11 +152,11 @@  discard block
 block discarded – undo
152 152
 	 * @param int $form ->ID The current form ID
153 153
 	 * @param array $args An array of form args
154 154
 	 */
155
-	do_action( 'give_post_form_output', $form->ID, $args );
155
+	do_action('give_post_form_output', $form->ID, $args);
156 156
 
157 157
 	$final_output = ob_get_clean();
158 158
 
159
-	echo apply_filters( 'give_donate_form', $final_output, $args );
159
+	echo apply_filters('give_donate_form', $final_output, $args);
160 160
 }
161 161
 
162 162
 
@@ -176,43 +176,43 @@  discard block
 block discarded – undo
176 176
  * @global    $give_options Array of all the Give options
177 177
  * @return string
178 178
  */
179
-function give_show_purchase_form( $form_id ) {
179
+function give_show_purchase_form($form_id) {
180 180
 
181
-	$payment_mode = give_get_chosen_gateway( $form_id );
181
+	$payment_mode = give_get_chosen_gateway($form_id);
182 182
 
183
-	if ( ! isset( $form_id ) && isset( $_POST['give_form_id'] ) ) {
183
+	if ( ! isset($form_id) && isset($_POST['give_form_id'])) {
184 184
 		$form_id = $_POST['give_form_id'];
185 185
 	}
186 186
 
187
-	do_action( 'give_purchase_form_top', $form_id );
187
+	do_action('give_purchase_form_top', $form_id);
188 188
 
189
-	if ( give_can_checkout() && isset( $form_id ) ) {
189
+	if (give_can_checkout() && isset($form_id)) {
190 190
 
191
-		do_action( 'give_purchase_form_before_register_login', $form_id );
191
+		do_action('give_purchase_form_before_register_login', $form_id);
192 192
 
193
-		do_action( 'give_purchase_form_register_login_fields', $form_id );
193
+		do_action('give_purchase_form_register_login_fields', $form_id);
194 194
 
195
-		do_action( 'give_purchase_form_before_cc_form', $form_id );
195
+		do_action('give_purchase_form_before_cc_form', $form_id);
196 196
 
197 197
 		// Load the credit card form and allow gateways to load their own if they wish
198
-		if ( has_action( 'give_' . $payment_mode . '_cc_form' ) ) {
199
-			do_action( 'give_' . $payment_mode . '_cc_form', $form_id );
198
+		if (has_action('give_'.$payment_mode.'_cc_form')) {
199
+			do_action('give_'.$payment_mode.'_cc_form', $form_id);
200 200
 		} else {
201
-			do_action( 'give_cc_form', $form_id );
201
+			do_action('give_cc_form', $form_id);
202 202
 		}
203 203
 
204
-		do_action( 'give_purchase_form_after_cc_form', $form_id );
204
+		do_action('give_purchase_form_after_cc_form', $form_id);
205 205
 
206 206
 	} else {
207 207
 		// Can't checkout
208
-		do_action( 'give_purchase_form_no_access', $form_id );
208
+		do_action('give_purchase_form_no_access', $form_id);
209 209
 
210 210
 	}
211 211
 
212
-	do_action( 'give_purchase_form_bottom', $form_id );
212
+	do_action('give_purchase_form_bottom', $form_id);
213 213
 }
214 214
 
215
-add_action( 'give_purchase_form', 'give_show_purchase_form' );
215
+add_action('give_purchase_form', 'give_show_purchase_form');
216 216
 
217 217
 /**
218 218
  *
@@ -224,26 +224,26 @@  discard block
 block discarded – undo
224 224
  *
225 225
  * @return void
226 226
  */
227
-function give_show_register_login_fields( $form_id ) {
227
+function give_show_register_login_fields($form_id) {
228 228
 
229
-	$show_register_form = give_show_login_register_option( $form_id );
229
+	$show_register_form = give_show_login_register_option($form_id);
230 230
 
231
-	if ( ( $show_register_form === 'registration' || ( $show_register_form === 'both' && ! isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : ?>
231
+	if (($show_register_form === 'registration' || ($show_register_form === 'both' && ! isset($_GET['login']))) && ! is_user_logged_in()) : ?>
232 232
 		<div id="give-checkout-login-register-<?php echo $form_id; ?>">
233
-			<?php do_action( 'give_purchase_form_register_fields', $form_id ); ?>
233
+			<?php do_action('give_purchase_form_register_fields', $form_id); ?>
234 234
 		</div>
235
-	<?php elseif ( ( $show_register_form === 'login' || ( $show_register_form === 'both' && isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : ?>
235
+	<?php elseif (($show_register_form === 'login' || ($show_register_form === 'both' && isset($_GET['login']))) && ! is_user_logged_in()) : ?>
236 236
 		<div id="give-checkout-login-register-<?php echo $form_id; ?>">
237
-			<?php do_action( 'give_purchase_form_login_fields', $form_id ); ?>
237
+			<?php do_action('give_purchase_form_login_fields', $form_id); ?>
238 238
 		</div>
239 239
 	<?php endif; ?>
240 240
 
241
-	<?php if ( ( ! isset( $_GET['login'] ) && is_user_logged_in() ) || ! isset( $show_register_form ) || 'none' === $show_register_form || 'login' === $show_register_form ) {
242
-		do_action( 'give_purchase_form_after_user_info', $form_id );
241
+	<?php if (( ! isset($_GET['login']) && is_user_logged_in()) || ! isset($show_register_form) || 'none' === $show_register_form || 'login' === $show_register_form) {
242
+		do_action('give_purchase_form_after_user_info', $form_id);
243 243
 	}
244 244
 }
245 245
 
246
-add_action( 'give_purchase_form_register_login_fields', 'give_show_register_login_fields' );
246
+add_action('give_purchase_form_register_login_fields', 'give_show_register_login_fields');
247 247
 
248 248
 /**
249 249
  * Donation Amount Field
@@ -257,33 +257,33 @@  discard block
 block discarded – undo
257 257
  *
258 258
  * @return void
259 259
  */
260
-function give_output_donation_amount_top( $form_id = 0, $args = array() ) {
260
+function give_output_donation_amount_top($form_id = 0, $args = array()) {
261 261
 
262 262
 	global $give_options;
263 263
 
264
-	$variable_pricing    = give_has_variable_prices( $form_id );
265
-	$allow_custom_amount = get_post_meta( $form_id, '_give_custom_amount', true );
266
-	$currency_position   = isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before';
267
-	$symbol              = give_currency_symbol( give_get_currency() );
268
-	$currency_output     = '<span class="give-currency-symbol give-currency-position-' . $currency_position . '">' . $symbol . '</span>';
269
-	$default_amount      = give_format_amount( give_get_default_form_amount( $form_id ) );
270
-	$custom_amount_text  = get_post_meta( $form_id, '_give_custom_amount_text', true );
264
+	$variable_pricing    = give_has_variable_prices($form_id);
265
+	$allow_custom_amount = get_post_meta($form_id, '_give_custom_amount', true);
266
+	$currency_position   = isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before';
267
+	$symbol              = give_currency_symbol(give_get_currency());
268
+	$currency_output     = '<span class="give-currency-symbol give-currency-position-'.$currency_position.'">'.$symbol.'</span>';
269
+	$default_amount      = give_format_amount(give_get_default_form_amount($form_id));
270
+	$custom_amount_text  = get_post_meta($form_id, '_give_custom_amount_text', true);
271 271
 
272
-	do_action( 'give_before_donation_levels', $form_id );
272
+	do_action('give_before_donation_levels', $form_id);
273 273
 
274 274
 	//Set Price, No Custom Amount Allowed means hidden price field
275
-	if ( $allow_custom_amount == 'no' ) {
275
+	if ($allow_custom_amount == 'no') {
276 276
 		?>
277 277
 
278
-		<label class="give-hidden" for="give-amount-hidden"><?php echo __( 'Donation Amount:', 'give' ); ?></label>
278
+		<label class="give-hidden" for="give-amount-hidden"><?php echo __('Donation Amount:', 'give'); ?></label>
279 279
 		<input id="give-amount" class="give-amount-hidden" type="hidden" name="give-amount"
280 280
 		       value="<?php echo $default_amount; ?>" required>
281 281
 		<div class="set-price give-donation-amount form-row-wide">
282
-			<?php if ( $currency_position == 'before' ) {
282
+			<?php if ($currency_position == 'before') {
283 283
 				echo $currency_output;
284 284
 			} ?>
285 285
 			<span id="give-amount-text" class="give-text-input give-amount-top"><?php echo $default_amount; ?></span>
286
-			<?php if ( $currency_position == 'after' ) {
286
+			<?php if ($currency_position == 'after') {
287 287
 				echo $currency_output;
288 288
 			} ?>
289 289
 		</div>
@@ -293,34 +293,34 @@  discard block
 block discarded – undo
293 293
 		?>
294 294
 		<div class="give-total-wrap">
295 295
 			<div class="give-donation-amount form-row-wide">
296
-				<?php if ( $currency_position == 'before' ) {
296
+				<?php if ($currency_position == 'before') {
297 297
 					echo $currency_output;
298 298
 				} ?>
299
-				<label class="give-hidden" for="give-amount"><?php echo __( 'Donation Amount:', 'give' ); ?></label>
299
+				<label class="give-hidden" for="give-amount"><?php echo __('Donation Amount:', 'give'); ?></label>
300 300
 				<input class="give-text-input give-amount-top" id="give-amount" name="give-amount" type="tel" placeholder="" value="<?php echo $default_amount; ?>" autocomplete="off">
301
-				<?php if ( $currency_position == 'after' ) {
301
+				<?php if ($currency_position == 'after') {
302 302
 					echo $currency_output;
303 303
 				} ?>
304 304
 			</div>
305 305
 		</div>
306 306
 	<?php }
307 307
 
308
-	do_action( 'give_after_donation_amount', $form_id, $args );
308
+	do_action('give_after_donation_amount', $form_id, $args);
309 309
 
310 310
 	//Custom Amount Text
311
-	if ( ! $variable_pricing && $allow_custom_amount == 'yes' && ! empty( $custom_amount_text ) ) { ?>
311
+	if ( ! $variable_pricing && $allow_custom_amount == 'yes' && ! empty($custom_amount_text)) { ?>
312 312
 		<p class="give-custom-amount-text"><?php echo $custom_amount_text; ?></p>
313 313
 	<?php }
314 314
 
315 315
 	//Output Variable Pricing Levels
316
-	if ( $variable_pricing ) {
317
-		give_output_levels( $form_id );
316
+	if ($variable_pricing) {
317
+		give_output_levels($form_id);
318 318
 	}
319 319
 
320
-	do_action( 'give_after_donation_levels', $form_id, $args );
320
+	do_action('give_after_donation_levels', $form_id, $args);
321 321
 }
322 322
 
323
-add_action( 'give_checkout_form_top', 'give_output_donation_amount_top', 10, 2 );
323
+add_action('give_checkout_form_top', 'give_output_donation_amount_top', 10, 2);
324 324
 
325 325
 
326 326
 /**
@@ -332,32 +332,32 @@  discard block
 block discarded – undo
332 332
  *
333 333
  * @return string
334 334
  */
335
-function give_output_levels( $form_id ) {
335
+function give_output_levels($form_id) {
336 336
 
337 337
 	//Get variable pricing
338
-	$prices             = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id );
339
-	$display_style      = get_post_meta( $form_id, '_give_display_style', true );
340
-	$custom_amount      = get_post_meta( $form_id, '_give_custom_amount', true );
341
-	$custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true );
342
-	if ( empty( $custom_amount_text ) ) {
343
-		$custom_amount_text = __( 'Give a Custom Amount', 'give' );
338
+	$prices             = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id);
339
+	$display_style      = get_post_meta($form_id, '_give_display_style', true);
340
+	$custom_amount      = get_post_meta($form_id, '_give_custom_amount', true);
341
+	$custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true);
342
+	if (empty($custom_amount_text)) {
343
+		$custom_amount_text = __('Give a Custom Amount', 'give');
344 344
 	}
345 345
 
346 346
 	$output  = '';
347 347
 	$counter = 0;
348 348
 
349
-	switch ( $display_style ) {
349
+	switch ($display_style) {
350 350
 		case 'buttons':
351 351
 
352 352
 			$output .= '<ul id="give-donation-level-button-wrap" class="give-donation-levels-wrap give-list-inline">';
353 353
 
354
-			foreach ( $prices as $price ) {
355
-				$counter ++;
356
-				$level_text    = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'] ) ), $form_id, $price );
357
-				$level_classes = apply_filters( 'give_form_level_classes', 'give-donation-level-btn give-btn give-btn-level-' . $counter . ' ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'give-default-level' : '' ), $form_id, $price );
354
+			foreach ($prices as $price) {
355
+				$counter++;
356
+				$level_text    = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'])), $form_id, $price);
357
+				$level_classes = apply_filters('give_form_level_classes', 'give-donation-level-btn give-btn give-btn-level-'.$counter.' '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'give-default-level' : ''), $form_id, $price);
358 358
 
359 359
 				$output .= '<li>';
360
-				$output .= '<button type="button" data-price-id="' . $price['_give_id']['level_id'] . '" class=" ' . $level_classes . '" value="' . give_format_amount( $price['_give_amount'] ) . '">';
360
+				$output .= '<button type="button" data-price-id="'.$price['_give_id']['level_id'].'" class=" '.$level_classes.'" value="'.give_format_amount($price['_give_amount']).'">';
361 361
 				$output .= $level_text;
362 362
 				$output .= '</button>';
363 363
 				$output .= '</li>';
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 			}
366 366
 
367 367
 			//Custom Amount
368
-			if ( $custom_amount === 'yes' && ! empty( $custom_amount_text ) ) {
368
+			if ($custom_amount === 'yes' && ! empty($custom_amount_text)) {
369 369
 				$output .= '<li>';
370 370
 				$output .= '<button type="button" data-price-id="custom" class="give-donation-level-btn give-btn give-btn-level-custom" value="custom">';
371 371
 				$output .= $custom_amount_text;
@@ -381,23 +381,23 @@  discard block
 block discarded – undo
381 381
 
382 382
 			$output .= '<ul id="give-donation-level-radio-list" class="give-donation-levels-wrap">';
383 383
 
384
-			foreach ( $prices as $price ) {
385
-				$counter ++;
386
-				$level_text    = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'] ) ), $form_id, $price );
387
-				$level_classes = apply_filters( 'give_form_level_classes', 'give-radio-input give-radio-input-level give-radio-level-' . $counter . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? ' give-default-level' : '' ), $form_id, $price );
384
+			foreach ($prices as $price) {
385
+				$counter++;
386
+				$level_text    = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'])), $form_id, $price);
387
+				$level_classes = apply_filters('give_form_level_classes', 'give-radio-input give-radio-input-level give-radio-level-'.$counter.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? ' give-default-level' : ''), $form_id, $price);
388 388
 
389 389
 				$output .= '<li>';
390
-				$output .= '<input type="radio" data-price-id="' . $price['_give_id']['level_id'] . '" class="' . $level_classes . '" name="give-radio-donation-level" id="give-radio-level-' . $counter . '" ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'checked="checked"' : '' ) . ' value="' . give_format_amount( $price['_give_amount'] ) . '">';
391
-				$output .= '<label for="give-radio-level-' . $counter . '">' . $level_text . '</label>';
390
+				$output .= '<input type="radio" data-price-id="'.$price['_give_id']['level_id'].'" class="'.$level_classes.'" name="give-radio-donation-level" id="give-radio-level-'.$counter.'" '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'checked="checked"' : '').' value="'.give_format_amount($price['_give_amount']).'">';
391
+				$output .= '<label for="give-radio-level-'.$counter.'">'.$level_text.'</label>';
392 392
 				$output .= '</li>';
393 393
 
394 394
 			}
395 395
 
396 396
 			//Custom Amount
397
-			if ( $custom_amount === 'yes' && ! empty( $custom_amount_text ) ) {
397
+			if ($custom_amount === 'yes' && ! empty($custom_amount_text)) {
398 398
 				$output .= '<li>';
399 399
 				$output .= '<input type="radio" data-price-id="custom" class="give-radio-input give-radio-input-level give-radio-level-custom" name="give-radio-donation-level" id="give-radio-level-custom" value="custom">';
400
-				$output .= '<label for="give-radio-level-custom">' . $custom_amount_text . '</label>';
400
+				$output .= '<label for="give-radio-level-custom">'.$custom_amount_text.'</label>';
401 401
 				$output .= '</li>';
402 402
 			}
403 403
 
@@ -407,23 +407,23 @@  discard block
 block discarded – undo
407 407
 
408 408
 		case 'dropdown':
409 409
 
410
-			$output .= '<label for="give-donation-level" class="give-hidden">' . __( 'Choose Your Donation Amount', 'give' ) . ':</label>';
411
-			$output .= '<select id="give-donation-level-' . $form_id . '" class="give-select give-select-level">';
410
+			$output .= '<label for="give-donation-level" class="give-hidden">'.__('Choose Your Donation Amount', 'give').':</label>';
411
+			$output .= '<select id="give-donation-level-'.$form_id.'" class="give-select give-select-level">';
412 412
 
413 413
 			//first loop through prices
414
-			foreach ( $prices as $price ) {
415
-				$level_text    = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'] ) ), $form_id, $price );
416
-				$level_classes = apply_filters( 'give_form_level_classes', 'give-donation-level-' . $form_id . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? ' give-default-level' : '' ), $form_id, $price );
414
+			foreach ($prices as $price) {
415
+				$level_text    = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'])), $form_id, $price);
416
+				$level_classes = apply_filters('give_form_level_classes', 'give-donation-level-'.$form_id.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? ' give-default-level' : ''), $form_id, $price);
417 417
 
418
-				$output .= '<option data-price-id="' . $price['_give_id']['level_id'] . '" class="' . $level_classes . '" ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'selected="selected"' : '' ) . ' value="' . give_format_amount( $price['_give_amount'] ) . '">';
418
+				$output .= '<option data-price-id="'.$price['_give_id']['level_id'].'" class="'.$level_classes.'" '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'selected="selected"' : '').' value="'.give_format_amount($price['_give_amount']).'">';
419 419
 				$output .= $level_text;
420 420
 				$output .= '</option>';
421 421
 
422 422
 			}
423 423
 
424 424
 			//Custom Amount
425
-			if ( $custom_amount === 'yes' && ! empty( $custom_amount_text ) ) {
426
-				$output .= '<option data-price-id="custom" class="give-donation-level-custom" value="custom">' . $custom_amount_text . '</option>';
425
+			if ($custom_amount === 'yes' && ! empty($custom_amount_text)) {
426
+				$output .= '<option data-price-id="custom" class="give-donation-level-custom" value="custom">'.$custom_amount_text.'</option>';
427 427
 			}
428 428
 
429 429
 			$output .= '</select>';
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 			break;
432 432
 	}
433 433
 
434
-	echo apply_filters( 'give_form_level_output', $output, $form_id );
434
+	echo apply_filters('give_form_level_output', $output, $form_id);
435 435
 }
436 436
 
437 437
 /**
@@ -443,26 +443,26 @@  discard block
 block discarded – undo
443 443
  * @param array $args
444 444
  *
445 445
  */
446
-function give_display_checkout_button( $form_id, $args ) {
446
+function give_display_checkout_button($form_id, $args) {
447 447
 
448
-	$display_option = ( isset( $args['display_style'] ) && ! empty( $args['display_style'] ) )
448
+	$display_option = (isset($args['display_style']) && ! empty($args['display_style']))
449 449
 		? $args['display_style']
450
-		: get_post_meta( $form_id, '_give_payment_display', true );
450
+		: get_post_meta($form_id, '_give_payment_display', true);
451 451
 
452 452
 	//no btn for onpage
453
-	if ( $display_option === 'onpage' ) {
453
+	if ($display_option === 'onpage') {
454 454
 		return;
455 455
 	}
456 456
 
457
-	$display_label_field = get_post_meta( $form_id, '_give_reveal_label', true );
458
-	$display_label       = ( ! empty( $display_label_field ) ? $display_label_field : __( 'Donate Now', 'give' ) );
457
+	$display_label_field = get_post_meta($form_id, '_give_reveal_label', true);
458
+	$display_label       = ( ! empty($display_label_field) ? $display_label_field : __('Donate Now', 'give'));
459 459
 
460
-	$output = '<button type="button" class="give-btn give-btn-' . $display_option . '">' . $display_label . '</button>';
460
+	$output = '<button type="button" class="give-btn give-btn-'.$display_option.'">'.$display_label.'</button>';
461 461
 
462
-	echo apply_filters( 'give_display_checkout_button', $output );
462
+	echo apply_filters('give_display_checkout_button', $output);
463 463
 }
464 464
 
465
-add_action( 'give_after_donation_levels', 'give_display_checkout_button', 10, 2 );
465
+add_action('give_after_donation_levels', 'give_display_checkout_button', 10, 2);
466 466
 
467 467
 /**
468 468
  * Shows the User Info fields in the Personal Info box, more fields can be added via the hooks provided.
@@ -473,71 +473,71 @@  discard block
 block discarded – undo
473 473
  *
474 474
  * @return void
475 475
  */
476
-function give_user_info_fields( $form_id ) {
476
+function give_user_info_fields($form_id) {
477 477
 
478
-	if ( is_user_logged_in() ) :
479
-		$user_data = get_userdata( get_current_user_id() );
478
+	if (is_user_logged_in()) :
479
+		$user_data = get_userdata(get_current_user_id());
480 480
 	endif;
481 481
 
482
-	do_action( 'give_purchase_form_before_personal_info', $form_id );
482
+	do_action('give_purchase_form_before_personal_info', $form_id);
483 483
 	?>
484 484
 	<fieldset id="give_checkout_user_info">
485
-		<legend><?php echo apply_filters( 'give_checkout_personal_info_text', __( 'Personal Info', 'give' ) ); ?></legend>
485
+		<legend><?php echo apply_filters('give_checkout_personal_info_text', __('Personal Info', 'give')); ?></legend>
486 486
 		<p id="give-first-name-wrap" class="form-row form-row-first">
487 487
 			<label class="give-label" for="give-first">
488
-				<?php _e( 'First Name', 'give' ); ?>
489
-				<?php if ( give_field_is_required( 'give_first', $form_id ) ) { ?>
488
+				<?php _e('First Name', 'give'); ?>
489
+				<?php if (give_field_is_required('give_first', $form_id)) { ?>
490 490
 					<span class="give-required-indicator">*</span>
491 491
 				<?php } ?>
492
-				<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e( 'We will use this to personalize your account experience.', 'give' ); ?>"></span>
492
+				<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e('We will use this to personalize your account experience.', 'give'); ?>"></span>
493 493
 			</label>
494
-			<input class="give-input required" type="text" name="give_first" placeholder="<?php _e( 'First name', 'give' ); ?>" id="give-first" value="<?php echo is_user_logged_in() ? $user_data->first_name : ''; ?>"<?php if ( give_field_is_required( 'give_first', $form_id ) ) {
494
+			<input class="give-input required" type="text" name="give_first" placeholder="<?php _e('First name', 'give'); ?>" id="give-first" value="<?php echo is_user_logged_in() ? $user_data->first_name : ''; ?>"<?php if (give_field_is_required('give_first', $form_id)) {
495 495
 				echo ' required ';
496 496
 			} ?>/>
497 497
 		</p>
498 498
 
499 499
 		<p id="give-last-name-wrap" class="form-row form-row-last">
500 500
 			<label class="give-label" for="give-last">
501
-				<?php _e( 'Last Name', 'give' ); ?>
502
-				<?php if ( give_field_is_required( 'give_last', $form_id ) ) { ?>
501
+				<?php _e('Last Name', 'give'); ?>
502
+				<?php if (give_field_is_required('give_last', $form_id)) { ?>
503 503
 					<span class="give-required-indicator">*</span>
504 504
 				<?php } ?>
505
-				<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e( 'We will use this as well to personalize your account experience.', 'give' ); ?>"></span>
505
+				<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e('We will use this as well to personalize your account experience.', 'give'); ?>"></span>
506 506
 			</label>
507 507
 
508
-			<input class="give-input<?php if ( give_field_is_required( 'give_last', $form_id ) ) {
508
+			<input class="give-input<?php if (give_field_is_required('give_last', $form_id)) {
509 509
 				echo ' required';
510
-			} ?>" type="text" name="give_last" id="give-last" placeholder="<?php _e( 'Last name', 'give' ); ?>" value="<?php echo is_user_logged_in() ? $user_data->last_name : ''; ?>"<?php if ( give_field_is_required( 'give_last', $form_id ) ) {
510
+			} ?>" type="text" name="give_last" id="give-last" placeholder="<?php _e('Last name', 'give'); ?>" value="<?php echo is_user_logged_in() ? $user_data->last_name : ''; ?>"<?php if (give_field_is_required('give_last', $form_id)) {
511 511
 				echo ' required ';
512 512
 			} ?> />
513 513
 		</p>
514 514
 
515
-		<?php do_action( 'give_purchase_form_before_email', $form_id ); ?>
515
+		<?php do_action('give_purchase_form_before_email', $form_id); ?>
516 516
 		<p id="give-email-wrap" class="form-row form-row-wide">
517 517
 			<label class="give-label" for="give-email">
518
-				<?php _e( 'Email Address', 'give' ); ?>
519
-				<?php if ( give_field_is_required( 'give_email', $form_id ) ) { ?>
518
+				<?php _e('Email Address', 'give'); ?>
519
+				<?php if (give_field_is_required('give_email', $form_id)) { ?>
520 520
 					<span class="give-required-indicator">*</span>
521 521
 				<?php } ?>
522
-				<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e( 'We will send the purchase receipt to this address.', 'give' ); ?>"></span>
522
+				<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e('We will send the purchase receipt to this address.', 'give'); ?>"></span>
523 523
 			</label>
524 524
 
525
-			<input class="give-input required" type="email" name="give_email" placeholder="<?php _e( 'Email address', 'give' ); ?>" id="give-email" value="<?php echo is_user_logged_in() ? $user_data->user_email : ''; ?>"<?php if ( give_field_is_required( 'give_email', $form_id ) ) {
525
+			<input class="give-input required" type="email" name="give_email" placeholder="<?php _e('Email address', 'give'); ?>" id="give-email" value="<?php echo is_user_logged_in() ? $user_data->user_email : ''; ?>"<?php if (give_field_is_required('give_email', $form_id)) {
526 526
 				echo ' required ';
527 527
 			} ?>/>
528 528
 
529 529
 		</p>
530
-		<?php do_action( 'give_purchase_form_after_email', $form_id ); ?>
530
+		<?php do_action('give_purchase_form_after_email', $form_id); ?>
531 531
 
532
-		<?php do_action( 'give_purchase_form_user_info', $form_id ); ?>
532
+		<?php do_action('give_purchase_form_user_info', $form_id); ?>
533 533
 	</fieldset>
534 534
 	<?php
535
-	do_action( 'give_purchase_form_after_personal_info', $form_id );
535
+	do_action('give_purchase_form_after_personal_info', $form_id);
536 536
 
537 537
 }
538 538
 
539
-add_action( 'give_purchase_form_after_user_info', 'give_user_info_fields' );
540
-add_action( 'give_register_fields_before', 'give_user_info_fields' );
539
+add_action('give_purchase_form_after_user_info', 'give_user_info_fields');
540
+add_action('give_register_fields_before', 'give_user_info_fields');
541 541
 
542 542
 /**
543 543
  * Renders the credit card info form.
@@ -548,73 +548,73 @@  discard block
 block discarded – undo
548 548
  *
549 549
  * @return void
550 550
  */
551
-function give_get_cc_form( $form_id ) {
551
+function give_get_cc_form($form_id) {
552 552
 
553 553
 	ob_start();
554 554
 
555
-	do_action( 'give_before_cc_fields', $form_id ); ?>
555
+	do_action('give_before_cc_fields', $form_id); ?>
556 556
 
557 557
 	<fieldset id="give_cc_fields-<?php echo $form_id ?>" class="give-do-validate">
558
-		<legend><?php echo apply_filters( 'give_credit_card_fieldset_heading', __( 'Credit Card Info', 'give' ) ); ?></legend>
559
-		<?php if ( is_ssl() ) : ?>
558
+		<legend><?php echo apply_filters('give_credit_card_fieldset_heading', __('Credit Card Info', 'give')); ?></legend>
559
+		<?php if (is_ssl()) : ?>
560 560
 			<div id="give_secure_site_wrapper-<?php echo $form_id ?>">
561 561
 				<span class="give-icon padlock"></span>
562
-				<span><?php _e( 'This is a secure SSL encrypted payment.', 'give' ); ?></span>
562
+				<span><?php _e('This is a secure SSL encrypted payment.', 'give'); ?></span>
563 563
 			</div>
564 564
 		<?php endif; ?>
565 565
 		<p id="give-card-number-wrap-<?php echo $form_id ?>" class="form-row form-row-two-thirds">
566 566
 			<label for="card_number-<?php echo $form_id ?>" class="give-label">
567
-				<?php _e( 'Card Number', 'give' ); ?>
567
+				<?php _e('Card Number', 'give'); ?>
568 568
 				<span class="give-required-indicator">*</span>
569
-				<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e( 'The (typically) 16 digits on the front of your credit card.', 'give' ); ?>"></span>
569
+				<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e('The (typically) 16 digits on the front of your credit card.', 'give'); ?>"></span>
570 570
 				<span class="card-type"></span>
571 571
 			</label>
572 572
 
573
-			<input type="tel" autocomplete="off" name="card_number" id="card_number-<?php echo $form_id ?>" class="card-number give-input required" placeholder="<?php _e( 'Card number', 'give' ); ?>" required/>
573
+			<input type="tel" autocomplete="off" name="card_number" id="card_number-<?php echo $form_id ?>" class="card-number give-input required" placeholder="<?php _e('Card number', 'give'); ?>" required/>
574 574
 		</p>
575 575
 
576 576
 		<p id="give-card-cvc-wrap-<?php echo $form_id ?>" class="form-row form-row-one-third">
577 577
 			<label for="card_cvc-<?php echo $form_id ?>" class="give-label">
578
-				<?php _e( 'CVC', 'give' ); ?>
578
+				<?php _e('CVC', 'give'); ?>
579 579
 				<span class="give-required-indicator">*</span>
580
-				<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e( 'The 3 digit (back) or 4 digit (front) value on your card.', 'give' ); ?>"></span>
580
+				<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e('The 3 digit (back) or 4 digit (front) value on your card.', 'give'); ?>"></span>
581 581
 			</label>
582 582
 
583
-			<input type="tel" size="4" autocomplete="off" name="card_cvc" id="card_cvc-<?php echo $form_id ?>" class="card-cvc give-input required" placeholder="<?php _e( 'Security code', 'give' ); ?>" required/>
583
+			<input type="tel" size="4" autocomplete="off" name="card_cvc" id="card_cvc-<?php echo $form_id ?>" class="card-cvc give-input required" placeholder="<?php _e('Security code', 'give'); ?>" required/>
584 584
 		</p>
585 585
 
586 586
 		<p id="give-card-name-wrap-<?php echo $form_id ?>" class="form-row form-row-two-thirds">
587 587
 			<label for="card_name-<?php echo $form_id ?>" class="give-label">
588
-				<?php _e( 'Name on the Card', 'give' ); ?>
588
+				<?php _e('Name on the Card', 'give'); ?>
589 589
 				<span class="give-required-indicator">*</span>
590
-				<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e( 'The name printed on the front of your credit card.', 'give' ); ?>"></span>
590
+				<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e('The name printed on the front of your credit card.', 'give'); ?>"></span>
591 591
 			</label>
592 592
 
593
-			<input type="text" autocomplete="off" name="card_name" id="card_name-<?php echo $form_id ?>" class="card-name give-input required" placeholder="<?php _e( 'Card name', 'give' ); ?>" required/>
593
+			<input type="text" autocomplete="off" name="card_name" id="card_name-<?php echo $form_id ?>" class="card-name give-input required" placeholder="<?php _e('Card name', 'give'); ?>" required/>
594 594
 		</p>
595
-		<?php do_action( 'give_before_cc_expiration' ); ?>
595
+		<?php do_action('give_before_cc_expiration'); ?>
596 596
 		<p class="card-expiration form-row form-row-one-third">
597 597
 			<label for="card_expiry-<?php echo $form_id ?>" class="give-label">
598
-				<?php _e( 'Expiration', 'give' ); ?>
598
+				<?php _e('Expiration', 'give'); ?>
599 599
 				<span class="give-required-indicator">*</span>
600
-				<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e( 'The date your credit card expires, typically on the front of the card.', 'give' ); ?>"></span>
600
+				<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e('The date your credit card expires, typically on the front of the card.', 'give'); ?>"></span>
601 601
 			</label>
602 602
 
603 603
 			<input type="hidden" id="card_exp_month-<?php echo $form_id ?>" name="card_exp_month" class="card-expiry-month"/>
604 604
 			<input type="hidden" id="card_exp_year-<?php echo $form_id ?>" name="card_exp_year" class="card-expiry-year"/>
605 605
 
606
-			<input type="tel" autocomplete="off" name="card_expiry" id="card_expiry-<?php echo $form_id ?>" class="card-expiry give-input required" placeholder="<?php _e( 'MM / YY', 'give' ); ?>" required/>
606
+			<input type="tel" autocomplete="off" name="card_expiry" id="card_expiry-<?php echo $form_id ?>" class="card-expiry give-input required" placeholder="<?php _e('MM / YY', 'give'); ?>" required/>
607 607
 		</p>
608
-		<?php do_action( 'give_after_cc_expiration', $form_id ); ?>
608
+		<?php do_action('give_after_cc_expiration', $form_id); ?>
609 609
 
610 610
 	</fieldset>
611 611
 	<?php
612
-	do_action( 'give_after_cc_fields', $form_id );
612
+	do_action('give_after_cc_fields', $form_id);
613 613
 
614 614
 	echo ob_get_clean();
615 615
 }
616 616
 
617
-add_action( 'give_cc_form', 'give_get_cc_form' );
617
+add_action('give_cc_form', 'give_get_cc_form');
618 618
 
619 619
 /**
620 620
  * Outputs the default credit card address fields
@@ -625,110 +625,110 @@  discard block
 block discarded – undo
625 625
  *
626 626
  * @return void
627 627
  */
628
-function give_default_cc_address_fields( $form_id ) {
628
+function give_default_cc_address_fields($form_id) {
629 629
 
630 630
 	$logged_in = is_user_logged_in();
631 631
 
632
-	if ( $logged_in ) {
633
-		$user_address = get_user_meta( get_current_user_id(), '_give_user_address', true );
632
+	if ($logged_in) {
633
+		$user_address = get_user_meta(get_current_user_id(), '_give_user_address', true);
634 634
 	}
635
-	$line1 = $logged_in && ! empty( $user_address['line1'] ) ? $user_address['line1'] : '';
636
-	$line2 = $logged_in && ! empty( $user_address['line2'] ) ? $user_address['line2'] : '';
637
-	$city  = $logged_in && ! empty( $user_address['city'] ) ? $user_address['city'] : '';
638
-	$zip   = $logged_in && ! empty( $user_address['zip'] ) ? $user_address['zip'] : '';
635
+	$line1 = $logged_in && ! empty($user_address['line1']) ? $user_address['line1'] : '';
636
+	$line2 = $logged_in && ! empty($user_address['line2']) ? $user_address['line2'] : '';
637
+	$city  = $logged_in && ! empty($user_address['city']) ? $user_address['city'] : '';
638
+	$zip   = $logged_in && ! empty($user_address['zip']) ? $user_address['zip'] : '';
639 639
 	ob_start(); ?>
640 640
 	<fieldset id="give_cc_address" class="cc-address">
641
-		<legend><?php echo apply_filters( 'give_billing_details_fieldset_heading', __( 'Billing Details', 'give' ) ); ?></legend>
642
-		<?php do_action( 'give_cc_billing_top' ); ?>
641
+		<legend><?php echo apply_filters('give_billing_details_fieldset_heading', __('Billing Details', 'give')); ?></legend>
642
+		<?php do_action('give_cc_billing_top'); ?>
643 643
 		<p id="give-card-address-wrap" class="form-row form-row-two-thirds">
644 644
 			<label for="card_address" class="give-label">
645
-				<?php _e( 'Address', 'give' ); ?>
645
+				<?php _e('Address', 'give'); ?>
646 646
 				<?php
647
-				if ( give_field_is_required( 'card_address', $form_id ) ) { ?>
647
+				if (give_field_is_required('card_address', $form_id)) { ?>
648 648
 					<span class="give-required-indicator">*</span>
649 649
 				<?php } ?>
650
-				<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e( 'The primary billing address for your credit card.', 'give' ); ?>"></span>
650
+				<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e('The primary billing address for your credit card.', 'give'); ?>"></span>
651 651
 			</label>
652 652
 
653
-			<input type="text" id="card_address" name="card_address" class="card-address give-input<?php if ( give_field_is_required( 'card_address', $form_id ) ) {
653
+			<input type="text" id="card_address" name="card_address" class="card-address give-input<?php if (give_field_is_required('card_address', $form_id)) {
654 654
 				echo ' required';
655
-			} ?>" placeholder="<?php _e( 'Address line 1', 'give' ); ?>" value="<?php echo $line1; ?>"<?php if ( give_field_is_required( 'card_address', $form_id ) ) {
655
+			} ?>" placeholder="<?php _e('Address line 1', 'give'); ?>" value="<?php echo $line1; ?>"<?php if (give_field_is_required('card_address', $form_id)) {
656 656
 				echo '  required ';
657 657
 			} ?>/>
658 658
 		</p>
659 659
 
660 660
 		<p id="give-card-address-2-wrap" class="form-row form-row-one-third">
661 661
 			<label for="card_address_2" class="give-label">
662
-				<?php _e( 'Address Line 2', 'give' ); ?>
663
-				<?php if ( give_field_is_required( 'card_address_2', $form_id ) ) { ?>
662
+				<?php _e('Address Line 2', 'give'); ?>
663
+				<?php if (give_field_is_required('card_address_2', $form_id)) { ?>
664 664
 					<span class="give-required-indicator">*</span>
665 665
 				<?php } ?>
666
-				<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e( '(optional) The suite, apt no, PO box, etc, associated with your billing address.', 'give' ); ?>"></span>
666
+				<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e('(optional) The suite, apt no, PO box, etc, associated with your billing address.', 'give'); ?>"></span>
667 667
 			</label>
668 668
 
669
-			<input type="text" id="card_address_2" name="card_address_2" class="card-address-2 give-input<?php if ( give_field_is_required( 'card_address_2', $form_id ) ) {
669
+			<input type="text" id="card_address_2" name="card_address_2" class="card-address-2 give-input<?php if (give_field_is_required('card_address_2', $form_id)) {
670 670
 				echo ' required';
671
-			} ?>" placeholder="<?php _e( 'Address line 2', 'give' ); ?>" value="<?php echo $line2; ?>"<?php if ( give_field_is_required( 'card_address_2', $form_id ) ) {
671
+			} ?>" placeholder="<?php _e('Address line 2', 'give'); ?>" value="<?php echo $line2; ?>"<?php if (give_field_is_required('card_address_2', $form_id)) {
672 672
 				echo ' required ';
673 673
 			} ?>/>
674 674
 		</p>
675 675
 
676 676
 		<p id="give-card-city-wrap" class="form-row form-row-two-thirds">
677 677
 			<label for="card_city" class="give-label">
678
-				<?php _e( 'City', 'give' ); ?>
679
-				<?php if ( give_field_is_required( 'card_city', $form_id ) ) { ?>
678
+				<?php _e('City', 'give'); ?>
679
+				<?php if (give_field_is_required('card_city', $form_id)) { ?>
680 680
 					<span class="give-required-indicator">*</span>
681 681
 				<?php } ?>
682
-				<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e( 'The city for your billing address.', 'give' ); ?>"></span>
682
+				<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e('The city for your billing address.', 'give'); ?>"></span>
683 683
 			</label>
684
-			<input type="text" id="card_city" name="card_city" class="card-city give-input<?php if ( give_field_is_required( 'card_city', $form_id ) ) {
684
+			<input type="text" id="card_city" name="card_city" class="card-city give-input<?php if (give_field_is_required('card_city', $form_id)) {
685 685
 				echo ' required';
686
-			} ?>" placeholder="<?php _e( 'City', 'give' ); ?>" value="<?php echo $city; ?>"<?php if ( give_field_is_required( 'card_city', $form_id ) ) {
686
+			} ?>" placeholder="<?php _e('City', 'give'); ?>" value="<?php echo $city; ?>"<?php if (give_field_is_required('card_city', $form_id)) {
687 687
 				echo ' required ';
688 688
 			} ?>/>
689 689
 		</p>
690 690
 
691 691
 		<p id="give-card-zip-wrap" class="form-row form-row-one-third">
692 692
 			<label for="card_zip" class="give-label">
693
-				<?php _e( 'Zip / Postal Code', 'give' ); ?>
694
-				<?php if ( give_field_is_required( 'card_zip', $form_id ) ) { ?>
693
+				<?php _e('Zip / Postal Code', 'give'); ?>
694
+				<?php if (give_field_is_required('card_zip', $form_id)) { ?>
695 695
 					<span class="give-required-indicator">*</span>
696 696
 				<?php } ?>
697
-				<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e( 'The zip or postal code for your billing address.', 'give' ); ?>"></span>
697
+				<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e('The zip or postal code for your billing address.', 'give'); ?>"></span>
698 698
 			</label>
699 699
 
700
-			<input type="text" size="4" id="card_zip" name="card_zip" class="card-zip give-input<?php if ( give_field_is_required( 'card_zip', $form_id ) ) {
700
+			<input type="text" size="4" id="card_zip" name="card_zip" class="card-zip give-input<?php if (give_field_is_required('card_zip', $form_id)) {
701 701
 				echo ' required';
702
-			} ?>" placeholder="<?php _e( 'Zip / Postal code', 'give' ); ?>" value="<?php echo $zip; ?>" <?php if ( give_field_is_required( 'card_zip', $form_id ) ) {
702
+			} ?>" placeholder="<?php _e('Zip / Postal code', 'give'); ?>" value="<?php echo $zip; ?>" <?php if (give_field_is_required('card_zip', $form_id)) {
703 703
 				echo ' required ';
704 704
 			} ?>/>
705 705
 		</p>
706 706
 
707 707
 		<p id="give-card-country-wrap" class="form-row form-row-first">
708 708
 			<label for="billing_country" class="give-label">
709
-				<?php _e( 'Country', 'give' ); ?>
710
-				<?php if ( give_field_is_required( 'billing_country', $form_id ) ) { ?>
709
+				<?php _e('Country', 'give'); ?>
710
+				<?php if (give_field_is_required('billing_country', $form_id)) { ?>
711 711
 					<span class="give-required-indicator">*</span>
712 712
 				<?php } ?>
713
-				<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e( 'The country for your billing address.', 'give' ); ?>"></span>
713
+				<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e('The country for your billing address.', 'give'); ?>"></span>
714 714
 			</label>
715 715
 
716
-			<select name="billing_country" id="billing_country" class="billing-country billing_country give-select<?php if ( give_field_is_required( 'billing_country', $form_id ) ) {
716
+			<select name="billing_country" id="billing_country" class="billing-country billing_country give-select<?php if (give_field_is_required('billing_country', $form_id)) {
717 717
 				echo ' required';
718
-			} ?>"<?php if ( give_field_is_required( 'billing_country', $form_id ) ) {
718
+			} ?>"<?php if (give_field_is_required('billing_country', $form_id)) {
719 719
 				echo ' required ';
720 720
 			} ?>>
721 721
 				<?php
722 722
 
723 723
 				$selected_country = give_get_country();
724 724
 
725
-				if ( $logged_in && ! empty( $user_address['country'] ) && '*' !== $user_address['country'] ) {
725
+				if ($logged_in && ! empty($user_address['country']) && '*' !== $user_address['country']) {
726 726
 					$selected_country = $user_address['country'];
727 727
 				}
728 728
 
729 729
 				$countries = give_get_country_list();
730
-				foreach ( $countries as $country_code => $country ) {
731
-					echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>';
730
+				foreach ($countries as $country_code => $country) {
731
+					echo '<option value="'.esc_attr($country_code).'"'.selected($country_code, $selected_country, false).'>'.$country.'</option>';
732 732
 				}
733 733
 				?>
734 734
 			</select>
@@ -736,44 +736,44 @@  discard block
 block discarded – undo
736 736
 
737 737
 		<p id="give-card-state-wrap" class="form-row form-row-last">
738 738
 			<label for="card_state" class="give-label">
739
-				<?php _e( 'State / Province', 'give' ); ?>
740
-				<?php if ( give_field_is_required( 'card_state', $form_id ) ) { ?>
739
+				<?php _e('State / Province', 'give'); ?>
740
+				<?php if (give_field_is_required('card_state', $form_id)) { ?>
741 741
 					<span class="give-required-indicator">*</span>
742 742
 				<?php } ?>
743
-				<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e( 'The state or province for your billing address.', 'give' ); ?>"></span>
743
+				<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e('The state or province for your billing address.', 'give'); ?>"></span>
744 744
 			</label>
745 745
 
746 746
 			<?php
747 747
 			$selected_state = give_get_state();
748
-			$states         = give_get_states( $selected_country );
748
+			$states         = give_get_states($selected_country);
749 749
 
750
-			if ( $logged_in && ! empty( $user_address['state'] ) ) {
750
+			if ($logged_in && ! empty($user_address['state'])) {
751 751
 				$selected_state = $user_address['state'];
752 752
 			}
753 753
 
754
-			if ( ! empty( $states ) ) : ?>
755
-				<select name="card_state" id="card_state" class="card_state give-select<?php if ( give_field_is_required( 'card_state', $form_id ) ) {
754
+			if ( ! empty($states)) : ?>
755
+				<select name="card_state" id="card_state" class="card_state give-select<?php if (give_field_is_required('card_state', $form_id)) {
756 756
 					echo ' required';
757
-				} ?>"<?php if ( give_field_is_required( 'card_state', $form_id ) ) {
757
+				} ?>"<?php if (give_field_is_required('card_state', $form_id)) {
758 758
 					echo ' required ';
759 759
 				} ?>>
760 760
 					<?php
761
-					foreach ( $states as $state_code => $state ) {
762
-						echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>';
761
+					foreach ($states as $state_code => $state) {
762
+						echo '<option value="'.$state_code.'"'.selected($state_code, $selected_state, false).'>'.$state.'</option>';
763 763
 					}
764 764
 					?>
765 765
 				</select>
766 766
 			<?php else : ?>
767
-				<input type="text" size="6" name="card_state" id="card_state" class="card_state give-input" placeholder="<?php _e( 'State / Province', 'give' ); ?>"/>
767
+				<input type="text" size="6" name="card_state" id="card_state" class="card_state give-input" placeholder="<?php _e('State / Province', 'give'); ?>"/>
768 768
 			<?php endif; ?>
769 769
 		</p>
770
-		<?php do_action( 'give_cc_billing_bottom' ); ?>
770
+		<?php do_action('give_cc_billing_bottom'); ?>
771 771
 	</fieldset>
772 772
 	<?php
773 773
 	echo ob_get_clean();
774 774
 }
775 775
 
776
-add_action( 'give_after_cc_fields', 'give_default_cc_address_fields' );
776
+add_action('give_after_cc_fields', 'give_default_cc_address_fields');
777 777
 
778 778
 
779 779
 /**
@@ -785,93 +785,93 @@  discard block
 block discarded – undo
785 785
  *
786 786
  * @return string
787 787
  */
788
-function give_get_register_fields( $form_id ) {
788
+function give_get_register_fields($form_id) {
789 789
 
790 790
 	global $user_ID;
791 791
 
792
-	if ( is_user_logged_in() ) {
793
-		$user_data = get_userdata( $user_ID );
792
+	if (is_user_logged_in()) {
793
+		$user_data = get_userdata($user_ID);
794 794
 	}
795 795
 
796
-	$show_register_form = give_show_login_register_option( $form_id );
796
+	$show_register_form = give_show_login_register_option($form_id);
797 797
 
798 798
 	ob_start(); ?>
799 799
 	<fieldset id="give-register-fields-<?php echo $form_id; ?>">
800 800
 
801
-		<?php if ( $show_register_form == 'both' ) { ?>
801
+		<?php if ($show_register_form == 'both') { ?>
802 802
 			<div class="give-login-account-wrap">
803
-				<p class="give-login-message"><?php _e( 'Already have an account?', 'give' ); ?>&nbsp;
804
-					<a href="<?php echo esc_url( add_query_arg( 'login', 1 ) ); ?>" class="give-checkout-login" data-action="give_checkout_login"><?php _e( 'Login', 'give' ); ?></a>
803
+				<p class="give-login-message"><?php _e('Already have an account?', 'give'); ?>&nbsp;
804
+					<a href="<?php echo esc_url(add_query_arg('login', 1)); ?>" class="give-checkout-login" data-action="give_checkout_login"><?php _e('Login', 'give'); ?></a>
805 805
 				</p>
806 806
 				<p class="give-loading-text">
807
-					<span class="give-loading-animation"></span> <?php _e( 'Loading...', 'give' ); ?></p>
807
+					<span class="give-loading-animation"></span> <?php _e('Loading...', 'give'); ?></p>
808 808
 			</div>
809 809
 		<?php } ?>
810 810
 
811
-		<?php do_action( 'give_register_fields_before', $form_id ); ?>
811
+		<?php do_action('give_register_fields_before', $form_id); ?>
812 812
 
813 813
 		<fieldset id="give-register-account-fields-<?php echo $form_id; ?>">
814
-			<legend><?php echo apply_filters( 'give_create_account_fieldset_heading', __( 'Create an account', 'give' ) );
815
-				if ( ! give_logged_in_only( $form_id ) ) {
816
-					echo ' <span class="sub-text">' . __( '(optional)', 'give' ) . '</span>';
814
+			<legend><?php echo apply_filters('give_create_account_fieldset_heading', __('Create an account', 'give'));
815
+				if ( ! give_logged_in_only($form_id)) {
816
+					echo ' <span class="sub-text">'.__('(optional)', 'give').'</span>';
817 817
 				} ?></legend>
818
-			<?php do_action( 'give_register_account_fields_before', $form_id ); ?>
818
+			<?php do_action('give_register_account_fields_before', $form_id); ?>
819 819
 			<div id="give-user-login-wrap-<?php echo $form_id; ?>" class="form-row form-row-one-third form-row-first">
820 820
 				<label for="give-user-login-<?php echo $form_id; ?>">
821
-					<?php _e( 'Username', 'give' ); ?>
822
-					<?php if ( give_logged_in_only( $form_id ) ) { ?>
821
+					<?php _e('Username', 'give'); ?>
822
+					<?php if (give_logged_in_only($form_id)) { ?>
823 823
 						<span class="give-required-indicator">*</span>
824 824
 					<?php } ?>
825
-					<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e( 'The username you will use to log into your account.', 'give' ); ?>"></span>
825
+					<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e('The username you will use to log into your account.', 'give'); ?>"></span>
826 826
 				</label>
827 827
 
828
-				<input name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" class="<?php if ( give_logged_in_only( $form_id ) ) {
828
+				<input name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" class="<?php if (give_logged_in_only($form_id)) {
829 829
 					echo 'required ';
830
-				} ?>give-input" type="text" placeholder="<?php _e( 'Username', 'give' ); ?>" title="<?php _e( 'Username', 'give' ); ?>"/>
830
+				} ?>give-input" type="text" placeholder="<?php _e('Username', 'give'); ?>" title="<?php _e('Username', 'give'); ?>"/>
831 831
 			</div>
832 832
 
833 833
 			<div id="give-user-pass-wrap-<?php echo $form_id; ?>" class="form-row form-row-one-third">
834 834
 				<label for="give-user-pass-<?php echo $form_id; ?>">
835
-					<?php _e( 'Password', 'give' ); ?>
836
-					<?php if ( give_logged_in_only( $form_id ) ) { ?>
835
+					<?php _e('Password', 'give'); ?>
836
+					<?php if (give_logged_in_only($form_id)) { ?>
837 837
 						<span class="give-required-indicator">*</span>
838 838
 					<?php } ?>
839
-					<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e( 'The password used to access your account.', 'give' ); ?>"></span>
839
+					<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e('The password used to access your account.', 'give'); ?>"></span>
840 840
 				</label>
841 841
 
842
-				<input name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" class="<?php if ( give_logged_in_only( $form_id ) ) {
842
+				<input name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" class="<?php if (give_logged_in_only($form_id)) {
843 843
 					echo 'required ';
844
-				} ?>give-input" placeholder="<?php _e( 'Password', 'give' ); ?>" type="password"/>
844
+				} ?>give-input" placeholder="<?php _e('Password', 'give'); ?>" type="password"/>
845 845
 			</div>
846 846
 
847 847
 			<div id="give-user-pass-confirm-wrap-<?php echo $form_id; ?>" class="give-register-password form-row form-row-one-third">
848 848
 				<label for="give-user-pass-confirm-<?php echo $form_id; ?>">
849
-					<?php _e( 'Confirm PW', 'give' ); ?>
850
-					<?php if ( give_logged_in_only( $form_id ) ) { ?>
849
+					<?php _e('Confirm PW', 'give'); ?>
850
+					<?php if (give_logged_in_only($form_id)) { ?>
851 851
 						<span class="give-required-indicator">*</span>
852 852
 					<?php } ?>
853
-					<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e( 'Please retype your password to confirm.', 'give' ); ?>"></span>
853
+					<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e('Please retype your password to confirm.', 'give'); ?>"></span>
854 854
 				</label>
855 855
 
856
-				<input name="give_user_pass_confirm" id="give-user-pass-confirm-<?php echo $form_id; ?>" class="<?php if ( give_logged_in_only( $form_id ) ) {
856
+				<input name="give_user_pass_confirm" id="give-user-pass-confirm-<?php echo $form_id; ?>" class="<?php if (give_logged_in_only($form_id)) {
857 857
 					echo 'required ';
858
-				} ?>give-input" placeholder="<?php _e( 'Confirm password', 'give' ); ?>" type="password"/>
858
+				} ?>give-input" placeholder="<?php _e('Confirm password', 'give'); ?>" type="password"/>
859 859
 			</div>
860
-			<?php do_action( 'give_register_account_fields_after', $form_id ); ?>
860
+			<?php do_action('give_register_account_fields_after', $form_id); ?>
861 861
 		</fieldset>
862 862
 
863
-		<?php do_action( 'give_register_fields_after', $form_id ); ?>
863
+		<?php do_action('give_register_fields_after', $form_id); ?>
864 864
 
865 865
 		<input type="hidden" name="give-purchase-var" value="needs-to-register"/>
866 866
 
867
-		<?php do_action( 'give_purchase_form_user_info', $form_id ); ?>
867
+		<?php do_action('give_purchase_form_user_info', $form_id); ?>
868 868
 
869 869
 	</fieldset>
870 870
 	<?php
871 871
 	echo ob_get_clean();
872 872
 }
873 873
 
874
-add_action( 'give_purchase_form_register_fields', 'give_get_register_fields' );
874
+add_action('give_purchase_form_register_fields', 'give_get_register_fields');
875 875
 
876 876
 /**
877 877
  * Gets the login fields for the login form on the checkout. This function hooks
@@ -884,73 +884,73 @@  discard block
 block discarded – undo
884 884
  *
885 885
  * @return string
886 886
  */
887
-function give_get_login_fields( $form_id ) {
887
+function give_get_login_fields($form_id) {
888 888
 
889
-	$form_id            = isset( $_POST['form_id'] ) ? $_POST['form_id'] : $form_id;
890
-	$show_register_form = give_show_login_register_option( $form_id );
889
+	$form_id            = isset($_POST['form_id']) ? $_POST['form_id'] : $form_id;
890
+	$show_register_form = give_show_login_register_option($form_id);
891 891
 
892 892
 	ob_start();
893 893
 	?>
894 894
 	<fieldset id="give-login-fields-<?php echo $form_id; ?>">
895
-		<legend><?php echo apply_filters( 'give_account_login_fieldset_heading', __( 'Login to Your Account', 'give' ) );
896
-			if ( ! give_logged_in_only( $form_id ) ) {
897
-				echo ' <span class="sub-text">' . __( '(optional)', 'give' ) . '</span>';
895
+		<legend><?php echo apply_filters('give_account_login_fieldset_heading', __('Login to Your Account', 'give'));
896
+			if ( ! give_logged_in_only($form_id)) {
897
+				echo ' <span class="sub-text">'.__('(optional)', 'give').'</span>';
898 898
 			} ?>
899 899
 		</legend>
900
-		<?php if ( $show_register_form == 'both' ) { ?>
900
+		<?php if ($show_register_form == 'both') { ?>
901 901
 			<p class="give-new-account-link">
902
-				<?php _e( 'Need to create an account?', 'give' ); ?>&nbsp;
903
-				<a href="<?php echo remove_query_arg( 'login' ); ?>" class="give-checkout-register-cancel" data-action="give_checkout_register">
904
-					<?php _e( 'Register', 'give' );
905
-					if ( ! give_logged_in_only( $form_id ) ) {
906
-						echo ' ' . __( 'or checkout as a guest.', 'give' );
902
+				<?php _e('Need to create an account?', 'give'); ?>&nbsp;
903
+				<a href="<?php echo remove_query_arg('login'); ?>" class="give-checkout-register-cancel" data-action="give_checkout_register">
904
+					<?php _e('Register', 'give');
905
+					if ( ! give_logged_in_only($form_id)) {
906
+						echo ' '.__('or checkout as a guest.', 'give');
907 907
 					} ?>
908 908
 				</a>
909 909
 			</p>
910 910
 			<p class="give-loading-text">
911
-				<span class="give-loading-animation"></span> <?php _e( 'Loading...', 'give' ); ?> </p>
911
+				<span class="give-loading-animation"></span> <?php _e('Loading...', 'give'); ?> </p>
912 912
 		<?php } ?>
913
-		<?php do_action( 'give_checkout_login_fields_before', $form_id ); ?>
913
+		<?php do_action('give_checkout_login_fields_before', $form_id); ?>
914 914
 		<div id="give-user-login-wrap-<?php echo $form_id; ?>" class="form-row form-row-first">
915 915
 			<label class="give-label" for="give-user-login-<?php echo $form_id; ?>">
916
-				<?php _e( 'Username', 'give' ); ?>
917
-				<?php if ( give_logged_in_only( $form_id ) ) { ?>
916
+				<?php _e('Username', 'give'); ?>
917
+				<?php if (give_logged_in_only($form_id)) { ?>
918 918
 					<span class="give-required-indicator">*</span>
919 919
 				<?php } ?>
920 920
 			</label>
921 921
 
922
-			<input class="<?php if ( give_logged_in_only( $form_id ) ) {
922
+			<input class="<?php if (give_logged_in_only($form_id)) {
923 923
 				echo 'required ';
924
-			} ?>give-input" type="text" name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" value="" placeholder="<?php _e( 'Your username', 'give' ); ?>"/>
924
+			} ?>give-input" type="text" name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" value="" placeholder="<?php _e('Your username', 'give'); ?>"/>
925 925
 		</div>
926 926
 
927 927
 		<div id="give-user-pass-wrap-<?php echo $form_id; ?>" class="give_login_password form-row form-row-last">
928 928
 			<label class="give-label" for="give-user-pass-<?php echo $form_id; ?>">
929
-				<?php _e( 'Password', 'give' ); ?>
930
-				<?php if ( give_logged_in_only( $form_id ) ) { ?>
929
+				<?php _e('Password', 'give'); ?>
930
+				<?php if (give_logged_in_only($form_id)) { ?>
931 931
 					<span class="give-required-indicator">*</span>
932 932
 				<?php } ?>
933 933
 			</label>
934
-			<input class="<?php if ( give_logged_in_only( $form_id ) ) {
934
+			<input class="<?php if (give_logged_in_only($form_id)) {
935 935
 				echo 'required ';
936
-			} ?>give-input" type="password" name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" placeholder="<?php _e( 'Your password', 'give' ); ?>"/>
936
+			} ?>give-input" type="password" name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" placeholder="<?php _e('Your password', 'give'); ?>"/>
937 937
 			<input type="hidden" name="give-purchase-var" value="needs-to-login"/>
938 938
 		</div>
939 939
 
940 940
 		<div id="give-user-login-submit-<?php echo $form_id; ?>" class="give-clearfix">
941
-			<input type="submit" class="give-submit give-btn button" name="give_login_submit" value="<?php _e( 'Login', 'give' ); ?>"/>
942
-			<?php if ( $show_register_form !== 'login' ) { ?>
943
-				<input type="button" data-action="give_cancel_login" class="give-cancel-login give-checkout-register-cancel give-btn button" name="give_login_cancel" value="<?php _e( 'Cancel', 'give' ); ?>"/>
941
+			<input type="submit" class="give-submit give-btn button" name="give_login_submit" value="<?php _e('Login', 'give'); ?>"/>
942
+			<?php if ($show_register_form !== 'login') { ?>
943
+				<input type="button" data-action="give_cancel_login" class="give-cancel-login give-checkout-register-cancel give-btn button" name="give_login_cancel" value="<?php _e('Cancel', 'give'); ?>"/>
944 944
 			<?php } ?>
945 945
 			<span class="give-loading-animation"></span>
946 946
 		</div>
947
-		<?php do_action( 'give_checkout_login_fields_after', $form_id ); ?>
947
+		<?php do_action('give_checkout_login_fields_after', $form_id); ?>
948 948
 	</fieldset><!--end #give-login-fields-->
949 949
 	<?php
950 950
 	echo ob_get_clean();
951 951
 }
952 952
 
953
-add_action( 'give_purchase_form_login_fields', 'give_get_login_fields', 10, 1 );
953
+add_action('give_purchase_form_login_fields', 'give_get_login_fields', 10, 1);
954 954
 
955 955
 /**
956 956
  * Payment Mode Select
@@ -966,49 +966,49 @@  discard block
 block discarded – undo
966 966
  *
967 967
  * @return void
968 968
  */
969
-function give_payment_mode_select( $form_id ) {
969
+function give_payment_mode_select($form_id) {
970 970
 
971 971
 	$gateways = give_get_enabled_payment_gateways();
972 972
 
973
-	do_action( 'give_payment_mode_top', $form_id ); ?>
973
+	do_action('give_payment_mode_top', $form_id); ?>
974 974
 
975 975
 	<fieldset id="give-payment-mode-select">
976
-		<?php do_action( 'give_payment_mode_before_gateways_wrap' ); ?>
976
+		<?php do_action('give_payment_mode_before_gateways_wrap'); ?>
977 977
 		<div id="give-payment-mode-wrap">
978
-			<legend class="give-payment-mode-label"><?php echo apply_filters( 'give_checkout_payment_method_text', __( 'Select Payment Method', 'give' ) ); ?>
979
-				<span class="give-loading-text"><span class="give-loading-animation"></span> <?php _e( 'Loading...', 'give' ); ?></span>
978
+			<legend class="give-payment-mode-label"><?php echo apply_filters('give_checkout_payment_method_text', __('Select Payment Method', 'give')); ?>
979
+				<span class="give-loading-text"><span class="give-loading-animation"></span> <?php _e('Loading...', 'give'); ?></span>
980 980
 			</legend>
981 981
 			<?php
982 982
 
983
-			do_action( 'give_payment_mode_before_gateways' ) ?>
983
+			do_action('give_payment_mode_before_gateways') ?>
984 984
 
985 985
 			<ul id="give-gateway-radio-list">
986
-				<?php foreach ( $gateways as $gateway_id => $gateway ) :
987
-					$checked       = checked( $gateway_id, give_get_default_gateway( $form_id ), false );
986
+				<?php foreach ($gateways as $gateway_id => $gateway) :
987
+					$checked       = checked($gateway_id, give_get_default_gateway($form_id), false);
988 988
 					$checked_class = $checked ? ' give-gateway-option-selected' : '';
989
-					echo '<li><label for="give-gateway-' . esc_attr( $gateway_id ) . '-' . $form_id . '" class="give-gateway-option' . $checked_class . '" id="give-gateway-option-' . esc_attr( $gateway_id ) . '">';
990
-					echo '<input type="radio" name="payment-mode" class="give-gateway" id="give-gateway-' . esc_attr( $gateway_id ) . '-' . $form_id . '" value="' . esc_attr( $gateway_id ) . '"' . $checked . '>' . esc_html( $gateway['checkout_label'] );
989
+					echo '<li><label for="give-gateway-'.esc_attr($gateway_id).'-'.$form_id.'" class="give-gateway-option'.$checked_class.'" id="give-gateway-option-'.esc_attr($gateway_id).'">';
990
+					echo '<input type="radio" name="payment-mode" class="give-gateway" id="give-gateway-'.esc_attr($gateway_id).'-'.$form_id.'" value="'.esc_attr($gateway_id).'"'.$checked.'>'.esc_html($gateway['checkout_label']);
991 991
 					echo '</label></li>';
992 992
 				endforeach; ?>
993 993
 			</ul>
994
-			<?php do_action( 'give_payment_mode_after_gateways' ); ?>
994
+			<?php do_action('give_payment_mode_after_gateways'); ?>
995 995
 		</div>
996
-		<?php do_action( 'give_payment_mode_after_gateways_wrap' ); ?>
996
+		<?php do_action('give_payment_mode_after_gateways_wrap'); ?>
997 997
 	</fieldset>
998 998
 
999
-	<?php do_action( 'give_payment_mode_bottom', $form_id ); ?>
999
+	<?php do_action('give_payment_mode_bottom', $form_id); ?>
1000 1000
 
1001 1001
 	<div id="give_purchase_form_wrap">
1002 1002
 
1003
-		<?php do_action( 'give_purchase_form', $form_id ); ?>
1003
+		<?php do_action('give_purchase_form', $form_id); ?>
1004 1004
 
1005 1005
 	</div><!-- the checkout fields are loaded into this-->
1006 1006
 
1007
-	<?php do_action( 'give_purchase_form_wrap_bottom', $form_id );
1007
+	<?php do_action('give_purchase_form_wrap_bottom', $form_id);
1008 1008
 
1009 1009
 }
1010 1010
 
1011
-add_action( 'give_payment_mode_select', 'give_payment_mode_select' );
1011
+add_action('give_payment_mode_select', 'give_payment_mode_select');
1012 1012
 
1013 1013
 
1014 1014
 /**
@@ -1023,35 +1023,35 @@  discard block
 block discarded – undo
1023 1023
  *
1024 1024
  * @return void
1025 1025
  */
1026
-function give_terms_agreement( $form_id ) {
1026
+function give_terms_agreement($form_id) {
1027 1027
 
1028
-	$form_option = get_post_meta( $form_id, '_give_terms_option', true );
1029
-	$label       = get_post_meta( $form_id, '_give_agree_label', true );
1030
-	$terms       = get_post_meta( $form_id, '_give_agree_text', true );
1028
+	$form_option = get_post_meta($form_id, '_give_terms_option', true);
1029
+	$label       = get_post_meta($form_id, '_give_agree_label', true);
1030
+	$terms       = get_post_meta($form_id, '_give_agree_text', true);
1031 1031
 
1032
-	if ( $form_option === 'yes' && ! empty( $terms ) ) { ?>
1032
+	if ($form_option === 'yes' && ! empty($terms)) { ?>
1033 1033
 		<fieldset id="give_terms_agreement">
1034 1034
 			<div id="give_terms" style="display:none;">
1035 1035
 				<?php
1036
-				do_action( 'give_before_terms' );
1037
-				echo wpautop( stripslashes( $terms ) );
1038
-				do_action( 'give_after_terms' );
1036
+				do_action('give_before_terms');
1037
+				echo wpautop(stripslashes($terms));
1038
+				do_action('give_after_terms');
1039 1039
 				?>
1040 1040
 			</div>
1041 1041
 			<div id="give_show_terms">
1042
-				<a href="#" class="give_terms_links"><?php _e( 'Show Terms', 'give' ); ?></a>
1043
-				<a href="#" class="give_terms_links" style="display:none;"><?php _e( 'Hide Terms', 'give' ); ?></a>
1042
+				<a href="#" class="give_terms_links"><?php _e('Show Terms', 'give'); ?></a>
1043
+				<a href="#" class="give_terms_links" style="display:none;"><?php _e('Hide Terms', 'give'); ?></a>
1044 1044
 			</div>
1045 1045
 
1046 1046
 			<label
1047
-				for="give_agree_to_terms"><?php echo ! empty( $label ) ? stripslashes( $label ) : __( 'Agree to Terms?', 'give' ); ?></label>
1047
+				for="give_agree_to_terms"><?php echo ! empty($label) ? stripslashes($label) : __('Agree to Terms?', 'give'); ?></label>
1048 1048
 			<input name="give_agree_to_terms" class="required" type="checkbox" id="give_agree_to_terms" value="1"/>
1049 1049
 		</fieldset>
1050 1050
 		<?php
1051 1051
 	}
1052 1052
 }
1053 1053
 
1054
-add_action( 'give_purchase_form_before_submit', 'give_terms_agreement', 10, 1 );
1054
+add_action('give_purchase_form_before_submit', 'give_terms_agreement', 10, 1);
1055 1055
 
1056 1056
 /**
1057 1057
  * Checkout Final Total
@@ -1063,27 +1063,27 @@  discard block
 block discarded – undo
1063 1063
  * @since      1.0
1064 1064
  * @return void
1065 1065
  */
1066
-function give_checkout_final_total( $form_id ) {
1066
+function give_checkout_final_total($form_id) {
1067 1067
 
1068
-	if ( isset( $_POST['give_total'] ) ) {
1069
-		$total = apply_filters( 'give_donation_total', $_POST['give_total'] );
1068
+	if (isset($_POST['give_total'])) {
1069
+		$total = apply_filters('give_donation_total', $_POST['give_total']);
1070 1070
 	} else {
1071 1071
 		//default total
1072
-		$total = give_get_default_form_amount( $form_id );
1072
+		$total = give_get_default_form_amount($form_id);
1073 1073
 	}
1074 1074
 	//Only proceed if give_total available
1075
-	if ( empty( $total ) ) {
1075
+	if (empty($total)) {
1076 1076
 		return;
1077 1077
 	}
1078 1078
 	?>
1079 1079
 	<p id="give-final-total-wrap" class="form-wrap ">
1080
-		<span class="give-donation-total-label"><?php echo apply_filters( 'give_donation_total_label', esc_attr__( 'Donation Total:', 'give' ) ); ?></span>
1081
-		<span class="give-final-total-amount" data-total="<?php echo give_format_amount( $total ); ?>"><?php echo give_currency_filter( give_format_amount( $total ) ); ?></span>
1080
+		<span class="give-donation-total-label"><?php echo apply_filters('give_donation_total_label', esc_attr__('Donation Total:', 'give')); ?></span>
1081
+		<span class="give-final-total-amount" data-total="<?php echo give_format_amount($total); ?>"><?php echo give_currency_filter(give_format_amount($total)); ?></span>
1082 1082
 	</p>
1083 1083
 	<?php
1084 1084
 }
1085 1085
 
1086
-add_action( 'give_purchase_form_before_submit', 'give_checkout_final_total', 999 );
1086
+add_action('give_purchase_form_before_submit', 'give_checkout_final_total', 999);
1087 1087
 
1088 1088
 
1089 1089
 /**
@@ -1095,22 +1095,22 @@  discard block
 block discarded – undo
1095 1095
  *
1096 1096
  * @return void
1097 1097
  */
1098
-function give_checkout_submit( $form_id ) {
1098
+function give_checkout_submit($form_id) {
1099 1099
 	?>
1100 1100
 	<fieldset id="give_purchase_submit">
1101
-		<?php do_action( 'give_purchase_form_before_submit', $form_id ); ?>
1101
+		<?php do_action('give_purchase_form_before_submit', $form_id); ?>
1102 1102
 
1103
-		<?php give_checkout_hidden_fields( $form_id ); ?>
1103
+		<?php give_checkout_hidden_fields($form_id); ?>
1104 1104
 
1105
-		<?php echo give_checkout_button_purchase( $form_id ); ?>
1105
+		<?php echo give_checkout_button_purchase($form_id); ?>
1106 1106
 
1107
-		<?php do_action( 'give_purchase_form_after_submit', $form_id ); ?>
1107
+		<?php do_action('give_purchase_form_after_submit', $form_id); ?>
1108 1108
 
1109 1109
 	</fieldset>
1110 1110
 	<?php
1111 1111
 }
1112 1112
 
1113
-add_action( 'give_purchase_form_after_cc_form', 'give_checkout_submit', 9999 );
1113
+add_action('give_purchase_form_after_cc_form', 'give_checkout_submit', 9999);
1114 1114
 
1115 1115
 
1116 1116
 /**
@@ -1123,10 +1123,10 @@  discard block
 block discarded – undo
1123 1123
  *
1124 1124
  * @return string
1125 1125
  */
1126
-function give_checkout_button_purchase( $form_id ) {
1126
+function give_checkout_button_purchase($form_id) {
1127 1127
 
1128
-	$display_label_field = get_post_meta( $form_id, '_give_checkout_label', true );
1129
-	$display_label       = ( ! empty( $display_label_field ) ? $display_label_field : __( 'Donate Now', 'give' ) );
1128
+	$display_label_field = get_post_meta($form_id, '_give_checkout_label', true);
1129
+	$display_label       = ( ! empty($display_label_field) ? $display_label_field : __('Donate Now', 'give'));
1130 1130
 
1131 1131
 	ob_start();
1132 1132
 
@@ -1137,7 +1137,7 @@  discard block
 block discarded – undo
1137 1137
 		<span class="give-loading-animation"></span>
1138 1138
 	</div>
1139 1139
 	<?php
1140
-	return apply_filters( 'give_checkout_button_purchase', ob_get_clean(), $form_id );
1140
+	return apply_filters('give_checkout_button_purchase', ob_get_clean(), $form_id);
1141 1141
 }
1142 1142
 
1143 1143
 /**
@@ -1150,11 +1150,11 @@  discard block
 block discarded – undo
1150 1150
  *
1151 1151
  * @return void
1152 1152
  */
1153
-function give_agree_to_terms_js( $form_id ) {
1153
+function give_agree_to_terms_js($form_id) {
1154 1154
 
1155
-	$form_option = get_post_meta( $form_id, '_give_terms_option', true );
1155
+	$form_option = get_post_meta($form_id, '_give_terms_option', true);
1156 1156
 
1157
-	if ( $form_option === 'yes' ) {
1157
+	if ($form_option === 'yes') {
1158 1158
 		?>
1159 1159
 		<script type="text/javascript">
1160 1160
 			jQuery(document).ready(function ($) {
@@ -1170,7 +1170,7 @@  discard block
 block discarded – undo
1170 1170
 	}
1171 1171
 }
1172 1172
 
1173
-add_action( 'give_checkout_form_top', 'give_agree_to_terms_js', 10, 2 );
1173
+add_action('give_checkout_form_top', 'give_agree_to_terms_js', 10, 2);
1174 1174
 
1175 1175
 
1176 1176
 /**
@@ -1183,19 +1183,19 @@  discard block
 block discarded – undo
1183 1183
  *
1184 1184
  * @return void
1185 1185
  */
1186
-function give_form_content( $form_id, $args ) {
1186
+function give_form_content($form_id, $args) {
1187 1187
 
1188
-	$show_content = ( isset( $args['show_content'] ) && ! empty( $args['show_content'] ) )
1188
+	$show_content = (isset($args['show_content']) && ! empty($args['show_content']))
1189 1189
 		? $args['show_content']
1190
-		: get_post_meta( $form_id, '_give_content_option', true );
1190
+		: get_post_meta($form_id, '_give_content_option', true);
1191 1191
 
1192
-	if ( $show_content !== 'none' ) {
1192
+	if ($show_content !== 'none') {
1193 1193
 		//add action according to value
1194
-		add_action( $show_content, 'give_form_display_content' );
1194
+		add_action($show_content, 'give_form_display_content');
1195 1195
 	}
1196 1196
 }
1197 1197
 
1198
-add_action( 'give_pre_form_output', 'give_form_content', 10, 2 );
1198
+add_action('give_pre_form_output', 'give_form_content', 10, 2);
1199 1199
 
1200 1200
 /**
1201 1201
  * Show Give Goals
@@ -1208,25 +1208,25 @@  discard block
 block discarded – undo
1208 1208
  * @return mixed
1209 1209
  */
1210 1210
 
1211
-function give_show_goal_progress( $form_id, $args ) {
1211
+function give_show_goal_progress($form_id, $args) {
1212 1212
 
1213
-	$goal_option = get_post_meta( $form_id, '_give_goal_option', true );
1214
-	$form        = new Give_Donate_Form( $form_id );
1213
+	$goal_option = get_post_meta($form_id, '_give_goal_option', true);
1214
+	$form        = new Give_Donate_Form($form_id);
1215 1215
 	$goal        = $form->goal;
1216
-	$goal_format = get_post_meta( $form_id, '_give_goal_format', true );
1216
+	$goal_format = get_post_meta($form_id, '_give_goal_format', true);
1217 1217
 	$income      = $form->get_earnings();
1218
-	$color       = get_post_meta( $form_id, '_give_goal_color', true );
1219
-	$show_text   = (bool) isset( $args['show_text'] ) ? filter_var( $args['show_text'], FILTER_VALIDATE_BOOLEAN ) : true;
1220
-	$show_bar    = (bool) isset( $args['show_bar'] ) ? filter_var( $args['show_bar'], FILTER_VALIDATE_BOOLEAN ) : true;
1218
+	$color       = get_post_meta($form_id, '_give_goal_color', true);
1219
+	$show_text   = (bool) isset($args['show_text']) ? filter_var($args['show_text'], FILTER_VALIDATE_BOOLEAN) : true;
1220
+	$show_bar    = (bool) isset($args['show_bar']) ? filter_var($args['show_bar'], FILTER_VALIDATE_BOOLEAN) : true;
1221 1221
 
1222 1222
 	//Sanity check - respect shortcode args
1223
-	if ( isset( $args['show_goal'] ) && $args['show_goal'] === false ) {
1223
+	if (isset($args['show_goal']) && $args['show_goal'] === false) {
1224 1224
 		return false;
1225 1225
 	}
1226 1226
 
1227 1227
 	//Sanity check - ensure form has goal set to output
1228
-	if ( empty( $form->ID )
1229
-	     || ( is_singular( 'give_forms' ) && $goal_option !== 'yes' )
1228
+	if (empty($form->ID)
1229
+	     || (is_singular('give_forms') && $goal_option !== 'yes')
1230 1230
 	     || $goal_option !== 'yes'
1231 1231
 	     || $goal == 0
1232 1232
 	) {
@@ -1234,26 +1234,26 @@  discard block
 block discarded – undo
1234 1234
 		return false;
1235 1235
 	}
1236 1236
 
1237
-	$progress = round( ( $income / $goal ) * 100, 2 );
1237
+	$progress = round(($income / $goal) * 100, 2);
1238 1238
 
1239
-	if ( $income > $goal ) {
1239
+	if ($income > $goal) {
1240 1240
 		$progress = 100;
1241 1241
 	}
1242 1242
 
1243 1243
 	$output = '<div class="give-goal-progress">';
1244 1244
 
1245 1245
 	//Goal Progress Text
1246
-	if ( ! empty( $show_text ) ) {
1246
+	if ( ! empty($show_text)) {
1247 1247
 
1248 1248
 		$output .= '<div class="raised">';
1249 1249
 
1250
-		if ( $goal_format !== 'percentage' ) {
1250
+		if ($goal_format !== 'percentage') {
1251 1251
 
1252
-			$output .= sprintf( _x( '%s of %s raised', 'This text displays the amount of income raised compared to the goal.', 'give' ), '<span class="income">' . apply_filters( 'give_goal_amount_raised_output', give_currency_filter( give_format_amount( $income ) ) ) . '</span>', '<span class="goal-text">' . apply_filters( 'give_goal_amount_target_output', give_currency_filter( give_format_amount( $goal ) ) ) ) . '</span>';
1252
+			$output .= sprintf(_x('%s of %s raised', 'This text displays the amount of income raised compared to the goal.', 'give'), '<span class="income">'.apply_filters('give_goal_amount_raised_output', give_currency_filter(give_format_amount($income))).'</span>', '<span class="goal-text">'.apply_filters('give_goal_amount_target_output', give_currency_filter(give_format_amount($goal)))).'</span>';
1253 1253
 
1254
-		} elseif ( $goal_format == 'percentage' ) {
1254
+		} elseif ($goal_format == 'percentage') {
1255 1255
 
1256
-			$output .= sprintf( _x( '%s%% funded', 'This text displays the percentage amount of income raised compared to the goal target.', 'give' ), '<span class="give-percentage">' . apply_filters( 'give_goal_amount_funded_percentage_output', round( $progress ) ) . '</span>' ) . '</span>';
1256
+			$output .= sprintf(_x('%s%% funded', 'This text displays the percentage amount of income raised compared to the goal target.', 'give'), '<span class="give-percentage">'.apply_filters('give_goal_amount_funded_percentage_output', round($progress)).'</span>').'</span>';
1257 1257
 
1258 1258
 		}
1259 1259
 
@@ -1262,11 +1262,11 @@  discard block
 block discarded – undo
1262 1262
 	}
1263 1263
 
1264 1264
 	//Goal Progress Bar
1265
-	if ( ! empty( $show_bar ) ) {
1265
+	if ( ! empty($show_bar)) {
1266 1266
 		$output .= '<div class="give-progress-bar">';
1267
-		$output .= '<span style="width: ' . esc_attr( $progress ) . '%;';
1268
-		if ( ! empty( $color ) ) {
1269
-			$output .= 'background-color:' . $color;
1267
+		$output .= '<span style="width: '.esc_attr($progress).'%;';
1268
+		if ( ! empty($color)) {
1269
+			$output .= 'background-color:'.$color;
1270 1270
 		}
1271 1271
 		$output .= '"></span>';
1272 1272
 		$output .= '</div><!-- /.give-progress-bar -->';
@@ -1274,13 +1274,13 @@  discard block
 block discarded – undo
1274 1274
 
1275 1275
 	$output .= '</div><!-- /.goal-progress -->';
1276 1276
 
1277
-	echo apply_filters( 'give_goal_output', $output );
1277
+	echo apply_filters('give_goal_output', $output);
1278 1278
 
1279 1279
 	return false;
1280 1280
 
1281 1281
 }
1282 1282
 
1283
-add_action( 'give_pre_form', 'give_show_goal_progress', 10, 2 );
1283
+add_action('give_pre_form', 'give_show_goal_progress', 10, 2);
1284 1284
 
1285 1285
 /**
1286 1286
  * Renders Post Form Content
@@ -1292,17 +1292,17 @@  discard block
 block discarded – undo
1292 1292
  * @return void
1293 1293
  * @since      1.0
1294 1294
  */
1295
-function give_form_display_content( $form_id ) {
1295
+function give_form_display_content($form_id) {
1296 1296
 
1297
-	$content = wpautop( get_post_meta( $form_id, '_give_form_content', true ) );
1297
+	$content = wpautop(get_post_meta($form_id, '_give_form_content', true));
1298 1298
 
1299
-	if ( give_get_option( 'disable_the_content_filter' ) !== 'on' ) {
1300
-		$content = apply_filters( 'the_content', $content );
1299
+	if (give_get_option('disable_the_content_filter') !== 'on') {
1300
+		$content = apply_filters('the_content', $content);
1301 1301
 	}
1302 1302
 
1303
-	$output = '<div id="give-form-content-' . $form_id . '" class="give-form-content-wrap" >' . $content . '</div>';
1303
+	$output = '<div id="give-form-content-'.$form_id.'" class="give-form-content-wrap" >'.$content.'</div>';
1304 1304
 
1305
-	echo apply_filters( 'give_form_content_output', $output );
1305
+	echo apply_filters('give_form_content_output', $output);
1306 1306
 }
1307 1307
 
1308 1308
 
@@ -1315,16 +1315,16 @@  discard block
 block discarded – undo
1315 1315
  *
1316 1316
  * @return void
1317 1317
  */
1318
-function give_checkout_hidden_fields( $form_id ) {
1318
+function give_checkout_hidden_fields($form_id) {
1319 1319
 
1320
-	do_action( 'give_hidden_fields_before', $form_id );
1321
-	if ( is_user_logged_in() ) { ?>
1320
+	do_action('give_hidden_fields_before', $form_id);
1321
+	if (is_user_logged_in()) { ?>
1322 1322
 		<input type="hidden" name="give-user-id" value="<?php echo get_current_user_id(); ?>"/>
1323 1323
 	<?php } ?>
1324 1324
 	<input type="hidden" name="give_action" value="purchase"/>
1325
-	<input type="hidden" name="give-gateway" value="<?php echo give_get_chosen_gateway( $form_id ); ?>"/>
1325
+	<input type="hidden" name="give-gateway" value="<?php echo give_get_chosen_gateway($form_id); ?>"/>
1326 1326
 	<?php
1327
-	do_action( 'give_hidden_fields_after', $form_id );
1327
+	do_action('give_hidden_fields_after', $form_id);
1328 1328
 
1329 1329
 }
1330 1330
 
@@ -1339,20 +1339,20 @@  discard block
 block discarded – undo
1339 1339
  *
1340 1340
  * @return string $content Filtered content
1341 1341
  */
1342
-function give_filter_success_page_content( $content ) {
1342
+function give_filter_success_page_content($content) {
1343 1343
 
1344 1344
 	global $give_options;
1345 1345
 
1346
-	if ( isset( $give_options['success_page'] ) && isset( $_GET['payment-confirmation'] ) && is_page( $give_options['success_page'] ) ) {
1347
-		if ( has_filter( 'give_payment_confirm_' . $_GET['payment-confirmation'] ) ) {
1348
-			$content = apply_filters( 'give_payment_confirm_' . $_GET['payment-confirmation'], $content );
1346
+	if (isset($give_options['success_page']) && isset($_GET['payment-confirmation']) && is_page($give_options['success_page'])) {
1347
+		if (has_filter('give_payment_confirm_'.$_GET['payment-confirmation'])) {
1348
+			$content = apply_filters('give_payment_confirm_'.$_GET['payment-confirmation'], $content);
1349 1349
 		}
1350 1350
 	}
1351 1351
 
1352 1352
 	return $content;
1353 1353
 }
1354 1354
 
1355
-add_filter( 'the_content', 'give_filter_success_page_content' );
1355
+add_filter('the_content', 'give_filter_success_page_content');
1356 1356
 
1357 1357
 
1358 1358
 /**
@@ -1364,14 +1364,14 @@  discard block
 block discarded – undo
1364 1364
 
1365 1365
 function give_test_mode_frontend_warning() {
1366 1366
 
1367
-	$test_mode = give_get_option( 'test_mode' );
1367
+	$test_mode = give_get_option('test_mode');
1368 1368
 
1369
-	if ( $test_mode == 'on' ) {
1370
-		echo '<div class="give_error give_warning" id="give_error_test_mode"><p><strong>' . __( 'Notice', 'give' ) . '</strong>: ' . esc_attr__( 'Test mode is enabled. While in test mode no live transactions are processed.', 'give' ) . '</p></div>';
1369
+	if ($test_mode == 'on') {
1370
+		echo '<div class="give_error give_warning" id="give_error_test_mode"><p><strong>'.__('Notice', 'give').'</strong>: '.esc_attr__('Test mode is enabled. While in test mode no live transactions are processed.', 'give').'</p></div>';
1371 1371
 	}
1372 1372
 }
1373 1373
 
1374
-add_action( 'give_pre_form', 'give_test_mode_frontend_warning', 10 );
1374
+add_action('give_pre_form', 'give_test_mode_frontend_warning', 10);
1375 1375
 
1376 1376
 
1377 1377
 /**
@@ -1381,21 +1381,21 @@  discard block
 block discarded – undo
1381 1381
  * @since       1.4.1
1382 1382
  */
1383 1383
 
1384
-function give_members_only_form( $final_output, $args ) {
1384
+function give_members_only_form($final_output, $args) {
1385 1385
 
1386
-	$form_id = isset( $args['form_id'] ) ? $args['form_id'] : 0;
1386
+	$form_id = isset($args['form_id']) ? $args['form_id'] : 0;
1387 1387
 
1388 1388
 	//Sanity Check: Must have form_id & not be logged in
1389
-	if ( empty( $form_id ) || is_user_logged_in() ) {
1389
+	if (empty($form_id) || is_user_logged_in()) {
1390 1390
 		return $final_output;
1391 1391
 	}
1392 1392
 
1393 1393
 	//Logged in only and Register / Login set to none
1394
-	if ( give_logged_in_only( $form_id ) && give_show_login_register_option( $form_id ) == 'none' ) {
1394
+	if (give_logged_in_only($form_id) && give_show_login_register_option($form_id) == 'none') {
1395 1395
 
1396
-		$final_output = give_output_error( __( 'Please login in order to complete your donation.', 'give' ), false );
1396
+		$final_output = give_output_error(__('Please login in order to complete your donation.', 'give'), false);
1397 1397
 
1398
-		return apply_filters( 'give_members_only_output', $final_output, $form_id );
1398
+		return apply_filters('give_members_only_output', $final_output, $form_id);
1399 1399
 
1400 1400
 	}
1401 1401
 
@@ -1403,4 +1403,4 @@  discard block
 block discarded – undo
1403 1403
 
1404 1404
 }
1405 1405
 
1406
-add_filter( 'give_donate_form', 'give_members_only_form', 10, 2 );
1407 1406
\ No newline at end of file
1407
+add_filter('give_donate_form', 'give_members_only_form', 10, 2);
1408 1408
\ No newline at end of file
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
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
  * @param int $year      Year
625 625
  * @param int $hour      Hour
626 626
  *
627
- * @return int $earnings Earnings
627
+ * @return double $earnings Earnings
628 628
  */
629 629
 function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) {
630 630
 
@@ -946,7 +946,7 @@  discard block
 block discarded – undo
946 946
  *
947 947
  * @param int $payment_id Payment ID
948 948
  *
949
- * @return array $user_info User Info Meta Values
949
+ * @return string $user_info User Info Meta Values
950 950
  */
951 951
 function give_get_payment_meta_user_info( $payment_id ) {
952 952
 	$payment_meta = give_get_payment_meta( $payment_id );
@@ -1639,7 +1639,7 @@  discard block
 block discarded – undo
1639 1639
  * @param array $where
1640 1640
  * @param obj   $wp_comment_query WordPress Comment Query Object
1641 1641
  *
1642
- * @return array $where
1642
+ * @return string $where
1643 1643
  */
1644 1644
 function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) {
1645 1645
 	global $wpdb;
Please login to merge, or discard this patch.
Spacing   +425 added lines, -425 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
 
@@ -32,15 +32,15 @@  discard block
 block discarded – undo
32 32
  *
33 33
  * @return object $payments Payments retrieved from the database
34 34
  */
35
-function give_get_payments( $args = array() ) {
35
+function give_get_payments($args = array()) {
36 36
 
37 37
 	// Fallback to post objects to ensure backwards compatibility
38
-	if ( ! isset( $args['output'] ) ) {
38
+	if ( ! isset($args['output'])) {
39 39
 		$args['output'] = 'posts';
40 40
 	}
41 41
 
42
-	$args     = apply_filters( 'give_get_payments_args', $args );
43
-	$payments = new Give_Payments_Query( $args );
42
+	$args     = apply_filters('give_get_payments_args', $args);
43
+	$payments = new Give_Payments_Query($args);
44 44
 
45 45
 	return $payments->get_payments();
46 46
 }
@@ -55,44 +55,44 @@  discard block
 block discarded – undo
55 55
  *
56 56
  * @return      mixed
57 57
  */
58
-function give_get_payment_by( $field = '', $value = '' ) {
58
+function give_get_payment_by($field = '', $value = '') {
59 59
 
60
-	if ( empty( $field ) || empty( $value ) ) {
60
+	if (empty($field) || empty($value)) {
61 61
 		return false;
62 62
 	}
63 63
 
64
-	switch ( strtolower( $field ) ) {
64
+	switch (strtolower($field)) {
65 65
 
66 66
 		case 'id':
67
-			$payment = get_post( $value );
67
+			$payment = get_post($value);
68 68
 
69
-			if ( get_post_type( $payment ) != 'give_payment' ) {
69
+			if (get_post_type($payment) != 'give_payment') {
70 70
 				return false;
71 71
 			}
72 72
 
73 73
 			break;
74 74
 
75 75
 		case 'key':
76
-			$payment = give_get_payments( array(
76
+			$payment = give_get_payments(array(
77 77
 				'meta_key'       => '_give_payment_purchase_key',
78 78
 				'meta_value'     => $value,
79 79
 				'posts_per_page' => 1
80
-			) );
80
+			));
81 81
 
82
-			if ( $payment ) {
82
+			if ($payment) {
83 83
 				$payment = $payment[0];
84 84
 			}
85 85
 
86 86
 			break;
87 87
 
88 88
 		case 'payment_number':
89
-			$payment = give_get_payments( array(
89
+			$payment = give_get_payments(array(
90 90
 				'meta_key'       => '_give_payment_number',
91 91
 				'meta_value'     => $value,
92 92
 				'posts_per_page' => 1
93
-			) );
93
+			));
94 94
 
95
-			if ( $payment ) {
95
+			if ($payment) {
96 96
 				$payment = $payment[0];
97 97
 			}
98 98
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 			return false;
103 103
 	}
104 104
 
105
-	if ( $payment ) {
105
+	if ($payment) {
106 106
 		return $payment;
107 107
 	}
108 108
 
@@ -118,97 +118,97 @@  discard block
 block discarded – undo
118 118
  *
119 119
  * @return int|bool Payment ID if payment is inserted, false otherwise
120 120
  */
121
-function give_insert_payment( $payment_data = array() ) {
122
-	if ( empty( $payment_data ) ) {
121
+function give_insert_payment($payment_data = array()) {
122
+	if (empty($payment_data)) {
123 123
 		return false;
124 124
 	}
125 125
 
126 126
 	// Make sure the payment is inserted with the correct timezone
127
-	date_default_timezone_set( give_get_timezone_id() );
127
+	date_default_timezone_set(give_get_timezone_id());
128 128
 
129 129
 	// Construct the payment title
130
-	if ( isset( $payment_data['user_info']['first_name'] ) || isset( $payment_data['user_info']['last_name'] ) ) {
131
-		$payment_title = $payment_data['user_info']['first_name'] . ' ' . $payment_data['user_info']['last_name'];
130
+	if (isset($payment_data['user_info']['first_name']) || isset($payment_data['user_info']['last_name'])) {
131
+		$payment_title = $payment_data['user_info']['first_name'].' '.$payment_data['user_info']['last_name'];
132 132
 	} else {
133 133
 		$payment_title = $payment_data['user_email'];
134 134
 	}
135 135
 
136 136
 	// Find the next payment number, if enabled
137
-	if ( give_get_option( 'enable_sequential' ) ) {
137
+	if (give_get_option('enable_sequential')) {
138 138
 		$number = give_get_next_payment_number();
139 139
 	}
140 140
 
141
-	$args = apply_filters( 'give_insert_payment_args', array(
141
+	$args = apply_filters('give_insert_payment_args', array(
142 142
 		'post_title'    => $payment_title,
143
-		'post_status'   => isset( $payment_data['status'] ) ? $payment_data['status'] : 'pending',
143
+		'post_status'   => isset($payment_data['status']) ? $payment_data['status'] : 'pending',
144 144
 		'post_type'     => 'give_payment',
145
-		'post_parent'   => isset( $payment_data['parent'] ) ? $payment_data['parent'] : null,
146
-		'post_date'     => isset( $payment_data['post_date'] ) ? $payment_data['post_date'] : null,
147
-		'post_date_gmt' => isset( $payment_data['post_date'] ) ? get_gmt_from_date( $payment_data['post_date'] ) : null
148
-	), $payment_data );
145
+		'post_parent'   => isset($payment_data['parent']) ? $payment_data['parent'] : null,
146
+		'post_date'     => isset($payment_data['post_date']) ? $payment_data['post_date'] : null,
147
+		'post_date_gmt' => isset($payment_data['post_date']) ? get_gmt_from_date($payment_data['post_date']) : null
148
+	), $payment_data);
149 149
 
150 150
 	// Create a blank payment
151
-	$payment = wp_insert_post( $args );
151
+	$payment = wp_insert_post($args);
152 152
 
153
-	if ( $payment ) {
153
+	if ($payment) {
154 154
 
155 155
 		$payment_meta = array(
156 156
 			'currency'   => $payment_data['currency'],
157 157
 			'form_title' => $payment_data['give_form_title'],
158 158
 			'form_id'    => $payment_data['give_form_id'],
159
-			'price_id'   => give_get_price_id( $payment_data['give_form_id'], $payment_data['price'] ),
159
+			'price_id'   => give_get_price_id($payment_data['give_form_id'], $payment_data['price']),
160 160
 			'user_info'  => $payment_data['user_info'],
161 161
 		);
162 162
 
163 163
 		$mode    = give_is_test_mode() ? 'test' : 'live';
164
-		$gateway = ! empty( $payment_data['gateway'] ) ? $payment_data['gateway'] : '';
165
-		$gateway = empty( $gateway ) && isset( $_POST['give-gateway'] ) ? $_POST['give-gateway'] : $gateway;
164
+		$gateway = ! empty($payment_data['gateway']) ? $payment_data['gateway'] : '';
165
+		$gateway = empty($gateway) && isset($_POST['give-gateway']) ? $_POST['give-gateway'] : $gateway;
166 166
 
167
-		if ( ! $payment_data['price'] ) {
167
+		if ( ! $payment_data['price']) {
168 168
 			// Ensures the _give_payment_total meta key is created for donations with an amount of 0
169 169
 			$payment_data['price'] = '0.00';
170 170
 		}
171 171
 
172 172
 		// Create or update a customer
173
-		$customer = new Give_Customer( $payment_data['user_email'] );
173
+		$customer = new Give_Customer($payment_data['user_email']);
174 174
 
175 175
 		// If we didn't find a customer and the user is logged in, check by user_id #437
176
-		if ( empty( $customer->id ) && is_user_logged_in() ) {
177
-			$customer = new Give_Customer( get_current_user_id(), true );
176
+		if (empty($customer->id) && is_user_logged_in()) {
177
+			$customer = new Give_Customer(get_current_user_id(), true);
178 178
 		}
179 179
 
180 180
 		$customer_data = array(
181
-			'name'    => $payment_data['user_info']['first_name'] . ' ' . $payment_data['user_info']['last_name'],
181
+			'name'    => $payment_data['user_info']['first_name'].' '.$payment_data['user_info']['last_name'],
182 182
 			'email'   => $payment_data['user_email'],
183 183
 			'user_id' => $payment_data['user_info']['id']
184 184
 		);
185 185
 
186
-		if ( empty( $customer->id ) ) {
187
-			$customer->create( $customer_data );
186
+		if (empty($customer->id)) {
187
+			$customer->create($customer_data);
188 188
 		}
189 189
 
190
-		$customer->attach_payment( $payment, false );
190
+		$customer->attach_payment($payment, false);
191 191
 
192 192
 		// Record the payment details
193
-		give_update_payment_meta( $payment, '_give_payment_meta', apply_filters( 'give_payment_meta', $payment_meta, $payment_data ) );
194
-		give_update_payment_meta( $payment, '_give_payment_user_id', $payment_data['user_info']['id'] );
195
-		give_update_payment_meta( $payment, '_give_payment_customer_id', $customer->id );
196
-		give_update_payment_meta( $payment, '_give_payment_user_email', $payment_data['user_email'] );
197
-		give_update_payment_meta( $payment, '_give_payment_user_ip', give_get_ip() );
198
-		give_update_payment_meta( $payment, '_give_payment_purchase_key', $payment_data['purchase_key'] );
199
-		give_update_payment_meta( $payment, '_give_payment_total', $payment_data['price'] );
200
-		give_update_payment_meta( $payment, '_give_payment_mode', $mode );
201
-		give_update_payment_meta( $payment, '_give_payment_gateway', $gateway );
202
-
203
-		if ( give_get_option( 'enable_sequential' ) ) {
204
-			give_update_payment_meta( $payment, '_give_payment_number', give_format_payment_number( $number ) );
205
-			update_option( 'give_last_payment_number', $number );
193
+		give_update_payment_meta($payment, '_give_payment_meta', apply_filters('give_payment_meta', $payment_meta, $payment_data));
194
+		give_update_payment_meta($payment, '_give_payment_user_id', $payment_data['user_info']['id']);
195
+		give_update_payment_meta($payment, '_give_payment_customer_id', $customer->id);
196
+		give_update_payment_meta($payment, '_give_payment_user_email', $payment_data['user_email']);
197
+		give_update_payment_meta($payment, '_give_payment_user_ip', give_get_ip());
198
+		give_update_payment_meta($payment, '_give_payment_purchase_key', $payment_data['purchase_key']);
199
+		give_update_payment_meta($payment, '_give_payment_total', $payment_data['price']);
200
+		give_update_payment_meta($payment, '_give_payment_mode', $mode);
201
+		give_update_payment_meta($payment, '_give_payment_gateway', $gateway);
202
+
203
+		if (give_get_option('enable_sequential')) {
204
+			give_update_payment_meta($payment, '_give_payment_number', give_format_payment_number($number));
205
+			update_option('give_last_payment_number', $number);
206 206
 		}
207 207
 
208 208
 		// Clear the user's purchased cache
209
-		delete_transient( 'give_user_' . $payment_data['user_info']['id'] . '_purchases' );
209
+		delete_transient('give_user_'.$payment_data['user_info']['id'].'_purchases');
210 210
 
211
-		do_action( 'give_insert_payment', $payment, $payment_data );
211
+		do_action('give_insert_payment', $payment, $payment_data);
212 212
 
213 213
 		return $payment; // Return the ID
214 214
 
@@ -228,43 +228,43 @@  discard block
 block discarded – undo
228 228
  *
229 229
  * @return void
230 230
  */
231
-function give_update_payment_status( $payment_id, $new_status = 'publish' ) {
231
+function give_update_payment_status($payment_id, $new_status = 'publish') {
232 232
 
233
-	if ( $new_status == 'completed' || $new_status == 'complete' ) {
233
+	if ($new_status == 'completed' || $new_status == 'complete') {
234 234
 		$new_status = 'publish';
235 235
 	}
236 236
 
237
-	if ( empty( $payment_id ) ) {
237
+	if (empty($payment_id)) {
238 238
 		return;
239 239
 	}
240 240
 
241
-	$payment = get_post( $payment_id );
241
+	$payment = get_post($payment_id);
242 242
 
243
-	if ( is_wp_error( $payment ) || ! is_object( $payment ) ) {
243
+	if (is_wp_error($payment) || ! is_object($payment)) {
244 244
 		return;
245 245
 	}
246 246
 
247 247
 	$old_status = $payment->post_status;
248 248
 
249
-	if ( $old_status === $new_status ) {
249
+	if ($old_status === $new_status) {
250 250
 		return; // Don't permit status changes that aren't changes
251 251
 	}
252 252
 
253
-	$do_change = apply_filters( 'give_should_update_payment_status', true, $payment_id, $new_status, $old_status );
253
+	$do_change = apply_filters('give_should_update_payment_status', true, $payment_id, $new_status, $old_status);
254 254
 
255
-	if ( $do_change ) {
255
+	if ($do_change) {
256 256
 
257
-		do_action( 'give_before_payment_status_change', $payment_id, $new_status, $old_status );
257
+		do_action('give_before_payment_status_change', $payment_id, $new_status, $old_status);
258 258
 
259 259
 		$update_fields = array(
260 260
 			'ID'          => $payment_id,
261 261
 			'post_status' => $new_status,
262
-			'edit_date'   => current_time( 'mysql' )
262
+			'edit_date'   => current_time('mysql')
263 263
 		);
264 264
 
265
-		wp_update_post( apply_filters( 'give_update_payment_status_fields', $update_fields ) );
265
+		wp_update_post(apply_filters('give_update_payment_status_fields', $update_fields));
266 266
 
267
-		do_action( 'give_update_payment_status', $payment_id, $new_status, $old_status );
267
+		do_action('give_update_payment_status', $payment_id, $new_status, $old_status);
268 268
 
269 269
 	}
270 270
 }
@@ -280,48 +280,48 @@  discard block
 block discarded – undo
280 280
  *
281 281
  * @return void
282 282
  */
283
-function give_delete_purchase( $payment_id = 0 ) {
283
+function give_delete_purchase($payment_id = 0) {
284 284
 	global $give_logs;
285 285
 
286
-	$post = get_post( $payment_id );
286
+	$post = get_post($payment_id);
287 287
 
288
-	if ( ! $post ) {
288
+	if ( ! $post) {
289 289
 		return;
290 290
 	}
291 291
 
292
-	$form_id = give_get_payment_form_id( $payment_id );
292
+	$form_id = give_get_payment_form_id($payment_id);
293 293
 
294
-	give_undo_purchase( $form_id, $payment_id );
294
+	give_undo_purchase($form_id, $payment_id);
295 295
 
296
-	$amount   = give_get_payment_amount( $payment_id );
296
+	$amount   = give_get_payment_amount($payment_id);
297 297
 	$status   = $post->post_status;
298
-	$donor_id = give_get_payment_customer_id( $payment_id );
298
+	$donor_id = give_get_payment_customer_id($payment_id);
299 299
 
300
-	if ( $status == 'revoked' || $status == 'publish' ) {
300
+	if ($status == 'revoked' || $status == 'publish') {
301 301
 		// Only decrease earnings if they haven't already been decreased (or were never increased for this payment)
302
-		give_decrease_total_earnings( $amount );
302
+		give_decrease_total_earnings($amount);
303 303
 		// Clear the This Month earnings (this_monththis_month is NOT a typo)
304
-		delete_transient( md5( 'give_earnings_this_monththis_month' ) );
304
+		delete_transient(md5('give_earnings_this_monththis_month'));
305 305
 
306
-		if ( $donor_id ) {
306
+		if ($donor_id) {
307 307
 
308 308
 			// Decrement the stats for the donor
309
-			Give()->customers->decrement_stats( $donor_id, $amount );
309
+			Give()->customers->decrement_stats($donor_id, $amount);
310 310
 
311 311
 		}
312 312
 	}
313 313
 
314
-	do_action( 'give_payment_delete', $payment_id );
314
+	do_action('give_payment_delete', $payment_id);
315 315
 
316
-	if ( $donor_id ) {
316
+	if ($donor_id) {
317 317
 
318 318
 		// Remove the payment ID from the donor
319
-		Give()->customers->remove_payment( $donor_id, $payment_id );
319
+		Give()->customers->remove_payment($donor_id, $payment_id);
320 320
 
321 321
 	}
322 322
 
323 323
 	// Remove the payment
324
-	wp_delete_post( $payment_id, true );
324
+	wp_delete_post($payment_id, true);
325 325
 
326 326
 	// Remove related sale log entries
327 327
 	$give_logs->delete_logs(
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
 		)
336 336
 	);
337 337
 
338
-	do_action( 'give_payment_deleted', $payment_id );
338
+	do_action('give_payment_deleted', $payment_id);
339 339
 }
340 340
 
341 341
 /**
@@ -348,19 +348,19 @@  discard block
 block discarded – undo
348 348
  *
349 349
  * @return void
350 350
  */
351
-function give_undo_purchase( $form_id, $payment_id ) {
351
+function give_undo_purchase($form_id, $payment_id) {
352 352
 
353
-	if ( give_is_test_mode() ) {
353
+	if (give_is_test_mode()) {
354 354
 		return;
355 355
 	}
356 356
 
357
-	$amount = give_get_payment_amount( $payment_id );
357
+	$amount = give_get_payment_amount($payment_id);
358 358
 
359 359
 	// decrease earnings
360
-	give_decrease_earnings( $form_id, $amount );
360
+	give_decrease_earnings($form_id, $amount);
361 361
 
362 362
 	// decrease purchase count
363
-	give_decrease_purchase_count( $form_id );
363
+	give_decrease_purchase_count($form_id);
364 364
 
365 365
 
366 366
 }
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
  *
378 378
  * @return array $count Number of payments sorted by payment status
379 379
  */
380
-function give_count_payments( $args = array() ) {
380
+function give_count_payments($args = array()) {
381 381
 
382 382
 	global $wpdb;
383 383
 
@@ -388,17 +388,17 @@  discard block
 block discarded – undo
388 388
 		'end-date'   => null,
389 389
 	);
390 390
 
391
-	$args = wp_parse_args( $args, $defaults );
391
+	$args = wp_parse_args($args, $defaults);
392 392
 
393 393
 	$join  = '';
394 394
 	$where = "WHERE p.post_type = 'give_payment'";
395 395
 
396 396
 	// Count payments for a specific user
397
-	if ( ! empty( $args['user'] ) ) {
397
+	if ( ! empty($args['user'])) {
398 398
 
399
-		if ( is_email( $args['user'] ) ) {
399
+		if (is_email($args['user'])) {
400 400
 			$field = 'email';
401
-		} elseif ( is_numeric( $args['user'] ) ) {
401
+		} elseif (is_numeric($args['user'])) {
402 402
 			$field = 'id';
403 403
 		} else {
404 404
 			$field = '';
@@ -406,18 +406,18 @@  discard block
 block discarded – undo
406 406
 
407 407
 		$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
408 408
 
409
-		if ( ! empty( $field ) ) {
409
+		if ( ! empty($field)) {
410 410
 			$where .= "
411 411
 				AND m.meta_key = '_give_payment_user_{$field}'
412 412
 				AND m.meta_value = '{$args['user']}'";
413 413
 		}
414 414
 
415 415
 		// Count payments for a search
416
-	} elseif ( ! empty( $args['s'] ) ) {
416
+	} elseif ( ! empty($args['s'])) {
417 417
 
418
-		if ( is_email( $args['s'] ) || strlen( $args['s'] ) == 32 ) {
418
+		if (is_email($args['s']) || strlen($args['s']) == 32) {
419 419
 
420
-			if ( is_email( $args['s'] ) ) {
420
+			if (is_email($args['s'])) {
421 421
 				$field = '_give_payment_user_email';
422 422
 			} else {
423 423
 				$field = '_give_payment_purchase_key';
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 				AND m.meta_key = '{$field}'
430 430
 				AND m.meta_value = '{$args['s']}'";
431 431
 
432
-		} elseif ( is_numeric( $args['s'] ) ) {
432
+		} elseif (is_numeric($args['s'])) {
433 433
 
434 434
 			$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
435 435
 			$where .= "
@@ -443,48 +443,48 @@  discard block
 block discarded – undo
443 443
 	}
444 444
 
445 445
 	// Limit payments count by date
446
-	if ( ! empty( $args['start-date'] ) && false !== strpos( $args['start-date'], '/' ) ) {
446
+	if ( ! empty($args['start-date']) && false !== strpos($args['start-date'], '/')) {
447 447
 
448
-		$date_parts = explode( '/', $args['start-date'] );
449
-		$month      = ! empty( $date_parts[0] ) && is_numeric( $date_parts[0] ) ? $date_parts[0] : 0;
450
-		$day        = ! empty( $date_parts[1] ) && is_numeric( $date_parts[1] ) ? $date_parts[1] : 0;
451
-		$year       = ! empty( $date_parts[2] ) && is_numeric( $date_parts[2] ) ? $date_parts[2] : 0;
448
+		$date_parts = explode('/', $args['start-date']);
449
+		$month      = ! empty($date_parts[0]) && is_numeric($date_parts[0]) ? $date_parts[0] : 0;
450
+		$day        = ! empty($date_parts[1]) && is_numeric($date_parts[1]) ? $date_parts[1] : 0;
451
+		$year       = ! empty($date_parts[2]) && is_numeric($date_parts[2]) ? $date_parts[2] : 0;
452 452
 
453
-		$is_date = checkdate( $month, $day, $year );
454
-		if ( false !== $is_date ) {
453
+		$is_date = checkdate($month, $day, $year);
454
+		if (false !== $is_date) {
455 455
 
456
-			$date = new DateTime( $args['start-date'] );
457
-			$where .= $wpdb->prepare( " AND p.post_date >= '%s'", $date->format( 'Y-m-d' ) );
456
+			$date = new DateTime($args['start-date']);
457
+			$where .= $wpdb->prepare(" AND p.post_date >= '%s'", $date->format('Y-m-d'));
458 458
 
459 459
 		}
460 460
 
461 461
 		// Fixes an issue with the payments list table counts when no end date is specified (partiy with stats class)
462
-		if ( empty( $args['end-date'] ) ) {
462
+		if (empty($args['end-date'])) {
463 463
 			$args['end-date'] = $args['start-date'];
464 464
 		}
465 465
 
466 466
 	}
467 467
 
468
-	if ( ! empty ( $args['end-date'] ) && false !== strpos( $args['end-date'], '/' ) ) {
468
+	if ( ! empty ($args['end-date']) && false !== strpos($args['end-date'], '/')) {
469 469
 
470
-		$date_parts = explode( '/', $args['end-date'] );
470
+		$date_parts = explode('/', $args['end-date']);
471 471
 
472
-		$month = ! empty( $date_parts[0] ) ? $date_parts[0] : 0;
473
-		$day   = ! empty( $date_parts[1] ) ? $date_parts[1] : 0;
474
-		$year  = ! empty( $date_parts[2] ) ? $date_parts[2] : 0;
472
+		$month = ! empty($date_parts[0]) ? $date_parts[0] : 0;
473
+		$day   = ! empty($date_parts[1]) ? $date_parts[1] : 0;
474
+		$year  = ! empty($date_parts[2]) ? $date_parts[2] : 0;
475 475
 
476
-		$is_date = checkdate( $month, $day, $year );
477
-		if ( false !== $is_date ) {
476
+		$is_date = checkdate($month, $day, $year);
477
+		if (false !== $is_date) {
478 478
 
479
-			$date = new DateTime( $args['end-date'] );
480
-			$where .= $wpdb->prepare( " AND p.post_date <= '%s'", $date->format( 'Y-m-d' ) );
479
+			$date = new DateTime($args['end-date']);
480
+			$where .= $wpdb->prepare(" AND p.post_date <= '%s'", $date->format('Y-m-d'));
481 481
 
482 482
 		}
483 483
 
484 484
 	}
485 485
 
486
-	$where = apply_filters( 'give_count_payments_where', $where );
487
-	$join  = apply_filters( 'give_count_payments_join', $join );
486
+	$where = apply_filters('give_count_payments_where', $where);
487
+	$join  = apply_filters('give_count_payments_join', $join);
488 488
 
489 489
 	$query = "SELECT p.post_status,count( * ) AS num_posts
490 490
 		FROM $wpdb->posts p
@@ -493,35 +493,35 @@  discard block
 block discarded – undo
493 493
 		GROUP BY p.post_status
494 494
 	";
495 495
 
496
-	$cache_key = md5( implode( '|', $args ) . $where );
496
+	$cache_key = md5(implode('|', $args).$where);
497 497
 
498
-	$count = wp_cache_get( $cache_key, 'counts' );
499
-	if ( false !== $count ) {
498
+	$count = wp_cache_get($cache_key, 'counts');
499
+	if (false !== $count) {
500 500
 		return $count;
501 501
 	}
502 502
 
503
-	$count = $wpdb->get_results( $query, ARRAY_A );
503
+	$count = $wpdb->get_results($query, ARRAY_A);
504 504
 
505 505
 	$stats    = array();
506 506
 	$statuses = get_post_stati();
507
-	if ( isset( $statuses['private'] ) && empty( $args['s'] ) ) {
508
-		unset( $statuses['private'] );
507
+	if (isset($statuses['private']) && empty($args['s'])) {
508
+		unset($statuses['private']);
509 509
 	}
510 510
 
511
-	foreach ( $statuses as $state ) {
512
-		$stats[ $state ] = 0;
511
+	foreach ($statuses as $state) {
512
+		$stats[$state] = 0;
513 513
 	}
514 514
 
515
-	foreach ( (array) $count as $row ) {
516
-		if ( 'private' == $row['post_status'] && empty( $args['s'] ) ) {
515
+	foreach ((array) $count as $row) {
516
+		if ('private' == $row['post_status'] && empty($args['s'])) {
517 517
 			continue;
518 518
 		}
519 519
 
520
-		$stats[ $row['post_status'] ] = $row['num_posts'];
520
+		$stats[$row['post_status']] = $row['num_posts'];
521 521
 	}
522 522
 
523 523
 	$stats = (object) $stats;
524
-	wp_cache_set( $cache_key, $stats, 'counts' );
524
+	wp_cache_set($cache_key, $stats, 'counts');
525 525
 
526 526
 	return $stats;
527 527
 }
@@ -536,10 +536,10 @@  discard block
 block discarded – undo
536 536
  *
537 537
  * @return bool true if payment exists, false otherwise
538 538
  */
539
-function give_check_for_existing_payment( $payment_id ) {
540
-	$payment = get_post( $payment_id );
539
+function give_check_for_existing_payment($payment_id) {
540
+	$payment = get_post($payment_id);
541 541
 
542
-	if ( $payment && $payment->post_status == 'publish' ) {
542
+	if ($payment && $payment->post_status == 'publish') {
543 543
 		return true; // Payment exists
544 544
 	}
545 545
 
@@ -556,21 +556,21 @@  discard block
 block discarded – undo
556 556
  *
557 557
  * @return bool|mixed if payment status exists, false otherwise
558 558
  */
559
-function give_get_payment_status( $payment, $return_label = false ) {
560
-	if ( ! is_object( $payment ) || ! isset( $payment->post_status ) ) {
559
+function give_get_payment_status($payment, $return_label = false) {
560
+	if ( ! is_object($payment) || ! isset($payment->post_status)) {
561 561
 		return false;
562 562
 	}
563 563
 
564 564
 	$statuses = give_get_payment_statuses();
565
-	if ( ! is_array( $statuses ) || empty( $statuses ) ) {
565
+	if ( ! is_array($statuses) || empty($statuses)) {
566 566
 		return false;
567 567
 	}
568 568
 
569
-	if ( array_key_exists( $payment->post_status, $statuses ) ) {
570
-		if ( true === $return_label ) {
571
-			return $statuses[ $payment->post_status ];
569
+	if (array_key_exists($payment->post_status, $statuses)) {
570
+		if (true === $return_label) {
571
+			return $statuses[$payment->post_status];
572 572
 		} else {
573
-			return array_search( $payment->post_status, $statuses );
573
+			return array_search($payment->post_status, $statuses);
574 574
 		}
575 575
 	}
576 576
 
@@ -585,17 +585,17 @@  discard block
 block discarded – undo
585 585
  */
586 586
 function give_get_payment_statuses() {
587 587
 	$payment_statuses = array(
588
-		'pending'     => __( 'Pending', 'give' ),
589
-		'publish'     => __( 'Complete', 'give' ),
590
-		'refunded'    => __( 'Refunded', 'give' ),
591
-		'failed'      => __( 'Failed', 'give' ),
592
-		'cancelled'   => __( 'Cancelled', 'give' ),
593
-		'abandoned'   => __( 'Abandoned', 'give' ),
594
-		'preapproval' => __( 'Pre-Approved', 'give' ),
595
-		'revoked'     => __( 'Revoked', 'give' )
588
+		'pending'     => __('Pending', 'give'),
589
+		'publish'     => __('Complete', 'give'),
590
+		'refunded'    => __('Refunded', 'give'),
591
+		'failed'      => __('Failed', 'give'),
592
+		'cancelled'   => __('Cancelled', 'give'),
593
+		'abandoned'   => __('Abandoned', 'give'),
594
+		'preapproval' => __('Pre-Approved', 'give'),
595
+		'revoked'     => __('Revoked', 'give')
596 596
 	);
597 597
 
598
-	return apply_filters( 'give_payment_statuses', $payment_statuses );
598
+	return apply_filters('give_payment_statuses', $payment_statuses);
599 599
 }
600 600
 
601 601
 /**
@@ -607,10 +607,10 @@  discard block
 block discarded – undo
607 607
  * @return array $payment_status All the available payment statuses
608 608
  */
609 609
 function give_get_payment_status_keys() {
610
-	$statuses = array_keys( give_get_payment_statuses() );
611
-	asort( $statuses );
610
+	$statuses = array_keys(give_get_payment_statuses());
611
+	asort($statuses);
612 612
 
613
-	return array_values( $statuses );
613
+	return array_values($statuses);
614 614
 }
615 615
 
616 616
 /**
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
  *
626 626
  * @return int $earnings Earnings
627 627
  */
628
-function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) {
628
+function give_get_earnings_by_date($day = null, $month_num, $year = null, $hour = null) {
629 629
 
630 630
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead
631 631
 
@@ -636,40 +636,40 @@  discard block
 block discarded – undo
636 636
 		'nopaging'               => true,
637 637
 		'year'                   => $year,
638 638
 		'monthnum'               => $month_num,
639
-		'post_status'            => array( 'publish', 'revoked' ),
639
+		'post_status'            => array('publish', 'revoked'),
640 640
 		'fields'                 => 'ids',
641 641
 		'update_post_term_cache' => false
642 642
 	);
643
-	if ( ! empty( $day ) ) {
643
+	if ( ! empty($day)) {
644 644
 		$args['day'] = $day;
645 645
 	}
646 646
 
647
-	if ( ! empty( $hour ) ) {
647
+	if ( ! empty($hour)) {
648 648
 		$args['hour'] = $hour;
649 649
 	}
650 650
 
651
-	$args = apply_filters( 'give_get_earnings_by_date_args', $args );
652
-	$key  = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 );
651
+	$args = apply_filters('give_get_earnings_by_date_args', $args);
652
+	$key  = 'give_stats_'.substr(md5(serialize($args)), 0, 15);
653 653
 
654
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
654
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
655 655
 		$earnings = false;
656 656
 	} else {
657
-		$earnings = get_transient( $key );
657
+		$earnings = get_transient($key);
658 658
 	}
659 659
 
660
-	if ( false === $earnings ) {
661
-		$sales    = get_posts( $args );
660
+	if (false === $earnings) {
661
+		$sales    = get_posts($args);
662 662
 		$earnings = 0;
663
-		if ( $sales ) {
664
-			$sales = implode( ',', $sales );
665
-			$earnings += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$sales})" );
663
+		if ($sales) {
664
+			$sales = implode(',', $sales);
665
+			$earnings += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$sales})");
666 666
 
667 667
 		}
668 668
 		// Cache the results for one hour
669
-		set_transient( $key, $earnings, HOUR_IN_SECONDS );
669
+		set_transient($key, $earnings, HOUR_IN_SECONDS);
670 670
 	}
671 671
 
672
-	return round( $earnings, 2 );
672
+	return round($earnings, 2);
673 673
 }
674 674
 
675 675
 /**
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
  *
685 685
  * @return int $count Sales
686 686
  */
687
-function give_get_sales_by_date( $day = null, $month_num = null, $year = null, $hour = null ) {
687
+function give_get_sales_by_date($day = null, $month_num = null, $year = null, $hour = null) {
688 688
 
689 689
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_sales() method instead
690 690
 	$args = array(
@@ -692,37 +692,37 @@  discard block
 block discarded – undo
692 692
 		'nopaging'               => true,
693 693
 		'year'                   => $year,
694 694
 		'fields'                 => 'ids',
695
-		'post_status'            => array( 'publish', 'revoked' ),
695
+		'post_status'            => array('publish', 'revoked'),
696 696
 		'update_post_meta_cache' => false,
697 697
 		'update_post_term_cache' => false
698 698
 	);
699 699
 
700
-	if ( ! empty( $month_num ) ) {
700
+	if ( ! empty($month_num)) {
701 701
 		$args['monthnum'] = $month_num;
702 702
 	}
703 703
 
704
-	if ( ! empty( $day ) ) {
704
+	if ( ! empty($day)) {
705 705
 		$args['day'] = $day;
706 706
 	}
707 707
 
708
-	if ( ! empty( $hour ) ) {
708
+	if ( ! empty($hour)) {
709 709
 		$args['hour'] = $hour;
710 710
 	}
711 711
 
712
-	$args = apply_filters( 'give_get_sales_by_date_args', $args );
713
-	$key  = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 );
712
+	$args = apply_filters('give_get_sales_by_date_args', $args);
713
+	$key  = 'give_stats_'.substr(md5(serialize($args)), 0, 15);
714 714
 
715
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
715
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
716 716
 		$count = false;
717 717
 	} else {
718
-		$count = get_transient( $key );
718
+		$count = get_transient($key);
719 719
 	}
720 720
 
721
-	if ( false === $count ) {
722
-		$sales = new WP_Query( $args );
721
+	if (false === $count) {
722
+		$sales = new WP_Query($args);
723 723
 		$count = (int) $sales->post_count;
724 724
 		// Cache the results for one hour
725
-		set_transient( $key, $count, HOUR_IN_SECONDS );
725
+		set_transient($key, $count, HOUR_IN_SECONDS);
726 726
 	}
727 727
 
728 728
 	return $count;
@@ -737,14 +737,14 @@  discard block
 block discarded – undo
737 737
  *
738 738
  * @return bool true if complete, false otherwise
739 739
  */
740
-function give_is_payment_complete( $payment_id ) {
741
-	$payment = get_post( $payment_id );
740
+function give_is_payment_complete($payment_id) {
741
+	$payment = get_post($payment_id);
742 742
 	$ret     = false;
743
-	if ( $payment && $payment->post_status == 'publish' ) {
743
+	if ($payment && $payment->post_status == 'publish') {
744 744
 		$ret = true;
745 745
 	}
746 746
 
747
-	return apply_filters( 'give_is_payment_complete', $ret, $payment_id, $payment->post_status );
747
+	return apply_filters('give_is_payment_complete', $ret, $payment_id, $payment->post_status);
748 748
 }
749 749
 
750 750
 /**
@@ -768,29 +768,29 @@  discard block
 block discarded – undo
768 768
  */
769 769
 function give_get_total_earnings() {
770 770
 
771
-	$total = get_option( 'give_earnings_total', 0 );
771
+	$total = get_option('give_earnings_total', 0);
772 772
 
773 773
 	// If no total stored in DB, use old method of calculating total earnings
774
-	if ( ! $total ) {
774
+	if ( ! $total) {
775 775
 
776 776
 		global $wpdb;
777 777
 
778
-		$total = get_transient( 'give_earnings_total' );
778
+		$total = get_transient('give_earnings_total');
779 779
 
780
-		if ( false === $total ) {
780
+		if (false === $total) {
781 781
 
782 782
 			$total = (float) 0;
783 783
 
784
-			$args = apply_filters( 'give_get_total_earnings_args', array(
784
+			$args = apply_filters('give_get_total_earnings_args', array(
785 785
 				'offset' => 0,
786
-				'number' => - 1,
787
-				'status' => array( 'publish', 'revoked' ),
786
+				'number' => -1,
787
+				'status' => array('publish', 'revoked'),
788 788
 				'fields' => 'ids'
789
-			) );
789
+			));
790 790
 
791 791
 
792
-			$payments = give_get_payments( $args );
793
-			if ( $payments ) {
792
+			$payments = give_get_payments($args);
793
+			if ($payments) {
794 794
 
795 795
 				/*
796 796
 				 * If performing a purchase, we need to skip the very last payment in the database, since it calls
@@ -798,30 +798,30 @@  discard block
 block discarded – undo
798 798
 				 * first purchase
799 799
 				 */
800 800
 
801
-				if ( did_action( 'give_update_payment_status' ) ) {
802
-					array_pop( $payments );
801
+				if (did_action('give_update_payment_status')) {
802
+					array_pop($payments);
803 803
 				}
804 804
 
805
-				if ( ! empty( $payments ) ) {
806
-					$payments = implode( ',', $payments );
807
-					$total += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})" );
805
+				if ( ! empty($payments)) {
806
+					$payments = implode(',', $payments);
807
+					$total += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})");
808 808
 				}
809 809
 
810 810
 			}
811 811
 
812 812
 			// Cache results for 1 day. This cache is cleared automatically when a payment is made
813
-			set_transient( 'give_earnings_total', $total, 86400 );
813
+			set_transient('give_earnings_total', $total, 86400);
814 814
 
815 815
 			// Store the total for the first time
816
-			update_option( 'give_earnings_total', $total );
816
+			update_option('give_earnings_total', $total);
817 817
 		}
818 818
 	}
819 819
 
820
-	if ( $total < 0 ) {
820
+	if ($total < 0) {
821 821
 		$total = 0; // Don't ever show negative earnings
822 822
 	}
823 823
 
824
-	return apply_filters( 'give_total_earnings', round( $total, give_currency_decimal_filter() ) );
824
+	return apply_filters('give_total_earnings', round($total, give_currency_decimal_filter()));
825 825
 }
826 826
 
827 827
 /**
@@ -833,10 +833,10 @@  discard block
 block discarded – undo
833 833
  *
834 834
  * @return float $total Total earnings
835 835
  */
836
-function give_increase_total_earnings( $amount = 0 ) {
836
+function give_increase_total_earnings($amount = 0) {
837 837
 	$total = give_get_total_earnings();
838 838
 	$total += $amount;
839
-	update_option( 'give_earnings_total', $total );
839
+	update_option('give_earnings_total', $total);
840 840
 
841 841
 	return $total;
842 842
 }
@@ -850,13 +850,13 @@  discard block
 block discarded – undo
850 850
  *
851 851
  * @return float $total Total earnings
852 852
  */
853
-function give_decrease_total_earnings( $amount = 0 ) {
853
+function give_decrease_total_earnings($amount = 0) {
854 854
 	$total = give_get_total_earnings();
855 855
 	$total -= $amount;
856
-	if ( $total < 0 ) {
856
+	if ($total < 0) {
857 857
 		$total = 0;
858 858
 	}
859
-	update_option( 'give_earnings_total', $total );
859
+	update_option('give_earnings_total', $total);
860 860
 
861 861
 	return $total;
862 862
 }
@@ -872,28 +872,28 @@  discard block
 block discarded – undo
872 872
  *
873 873
  * @return mixed $meta Payment Meta
874 874
  */
875
-function give_get_payment_meta( $payment_id = 0, $meta_key = '_give_payment_meta', $single = true ) {
875
+function give_get_payment_meta($payment_id = 0, $meta_key = '_give_payment_meta', $single = true) {
876 876
 
877
-	$meta = get_post_meta( $payment_id, $meta_key, $single );
877
+	$meta = get_post_meta($payment_id, $meta_key, $single);
878 878
 
879
-	if ( $meta_key === '_give_payment_meta' ) {
879
+	if ($meta_key === '_give_payment_meta') {
880 880
 
881
-		if ( empty( $meta['key'] ) ) {
882
-			$meta['key'] = give_get_payment_key( $payment_id );
881
+		if (empty($meta['key'])) {
882
+			$meta['key'] = give_get_payment_key($payment_id);
883 883
 		}
884 884
 
885
-		if ( empty( $meta['email'] ) ) {
886
-			$meta['email'] = give_get_payment_user_email( $payment_id );
885
+		if (empty($meta['email'])) {
886
+			$meta['email'] = give_get_payment_user_email($payment_id);
887 887
 		}
888 888
 
889
-		if ( empty( $meta['date'] ) ) {
890
-			$meta['date'] = get_post_field( 'post_date', $payment_id );
889
+		if (empty($meta['date'])) {
890
+			$meta['date'] = get_post_field('post_date', $payment_id);
891 891
 		}
892 892
 	}
893 893
 
894
-	$meta = apply_filters( 'give_get_payment_meta_' . $meta_key, $meta, $payment_id );
894
+	$meta = apply_filters('give_get_payment_meta_'.$meta_key, $meta, $payment_id);
895 895
 
896
-	return apply_filters( 'give_get_payment_meta', $meta, $payment_id, $meta_key );
896
+	return apply_filters('give_get_payment_meta', $meta, $payment_id, $meta_key);
897 897
 }
898 898
 
899 899
 /**
@@ -906,26 +906,26 @@  discard block
 block discarded – undo
906 906
  *
907 907
  * @return mixed               Meta ID if successful, false if unsuccessful
908 908
  */
909
-function give_update_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) {
909
+function give_update_payment_meta($payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') {
910 910
 
911
-	if ( empty( $payment_id ) || empty( $meta_key ) ) {
911
+	if (empty($payment_id) || empty($meta_key)) {
912 912
 		return;
913 913
 	}
914 914
 
915
-	if ( $meta_key == 'key' || $meta_key == 'date' ) {
915
+	if ($meta_key == 'key' || $meta_key == 'date') {
916 916
 
917
-		$current_meta              = give_get_payment_meta( $payment_id );
918
-		$current_meta[ $meta_key ] = $meta_value;
917
+		$current_meta              = give_get_payment_meta($payment_id);
918
+		$current_meta[$meta_key] = $meta_value;
919 919
 
920 920
 		$meta_key   = '_give_payment_meta';
921 921
 		$meta_value = $current_meta;
922 922
 
923
-	} else if ( $meta_key == 'email' || $meta_key == '_give_payment_user_email' ) {
923
+	} else if ($meta_key == 'email' || $meta_key == '_give_payment_user_email') {
924 924
 
925
-		$meta_value = apply_filters( 'give_give_update_payment_meta_' . $meta_key, $meta_value, $payment_id );
926
-		update_post_meta( $payment_id, '_give_payment_user_email', $meta_value );
925
+		$meta_value = apply_filters('give_give_update_payment_meta_'.$meta_key, $meta_value, $payment_id);
926
+		update_post_meta($payment_id, '_give_payment_user_email', $meta_value);
927 927
 
928
-		$current_meta                       = give_get_payment_meta( $payment_id );
928
+		$current_meta                       = give_get_payment_meta($payment_id);
929 929
 		$current_meta['user_info']['email'] = $meta_value;
930 930
 
931 931
 		$meta_key   = '_give_payment_meta';
@@ -933,9 +933,9 @@  discard block
 block discarded – undo
933 933
 
934 934
 	}
935 935
 
936
-	$meta_value = apply_filters( 'give_give_update_payment_meta_' . $meta_key, $meta_value, $payment_id );
936
+	$meta_value = apply_filters('give_give_update_payment_meta_'.$meta_key, $meta_value, $payment_id);
937 937
 
938
-	return update_post_meta( $payment_id, $meta_key, $meta_value, $prev_value );
938
+	return update_post_meta($payment_id, $meta_key, $meta_value, $prev_value);
939 939
 }
940 940
 
941 941
 /**
@@ -947,11 +947,11 @@  discard block
 block discarded – undo
947 947
  *
948 948
  * @return array $user_info User Info Meta Values
949 949
  */
950
-function give_get_payment_meta_user_info( $payment_id ) {
951
-	$payment_meta = give_get_payment_meta( $payment_id );
952
-	$user_info    = isset( $payment_meta['user_info'] ) ? maybe_unserialize( $payment_meta['user_info'] ) : false;
950
+function give_get_payment_meta_user_info($payment_id) {
951
+	$payment_meta = give_get_payment_meta($payment_id);
952
+	$user_info    = isset($payment_meta['user_info']) ? maybe_unserialize($payment_meta['user_info']) : false;
953 953
 
954
-	return apply_filters( 'give_payment_meta_user_info', $user_info );
954
+	return apply_filters('give_payment_meta_user_info', $user_info);
955 955
 }
956 956
 
957 957
 /**
@@ -964,12 +964,12 @@  discard block
 block discarded – undo
964 964
  *
965 965
  * @return int $form_id
966 966
  */
967
-function give_get_payment_form_id( $payment_id ) {
968
-	$payment_meta = give_get_payment_meta( $payment_id );
967
+function give_get_payment_form_id($payment_id) {
968
+	$payment_meta = give_get_payment_meta($payment_id);
969 969
 
970
-	$form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0;
970
+	$form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0;
971 971
 
972
-	return apply_filters( 'give_get_payment_form_id', $form_id );
972
+	return apply_filters('give_get_payment_form_id', $form_id);
973 973
 }
974 974
 
975 975
 /**
@@ -981,10 +981,10 @@  discard block
 block discarded – undo
981 981
  *
982 982
  * @return string $email User Email
983 983
  */
984
-function give_get_payment_user_email( $payment_id ) {
985
-	$email = give_get_payment_meta( $payment_id, '_give_payment_user_email', true );
984
+function give_get_payment_user_email($payment_id) {
985
+	$email = give_get_payment_meta($payment_id, '_give_payment_user_email', true);
986 986
 
987
-	return apply_filters( 'give_payment_user_email', $email );
987
+	return apply_filters('give_payment_user_email', $email);
988 988
 }
989 989
 
990 990
 /**
@@ -996,11 +996,11 @@  discard block
 block discarded – undo
996 996
  *
997 997
  * @return bool            If the payment is associted with a user (false) or not (true)
998 998
  */
999
-function give_is_guest_payment( $payment_id ) {
1000
-	$payment_user_id  = give_get_payment_user_id( $payment_id );
1001
-	$is_guest_payment = ! empty( $payment_user_id ) && $payment_user_id > 0 ? false : true;
999
+function give_is_guest_payment($payment_id) {
1000
+	$payment_user_id  = give_get_payment_user_id($payment_id);
1001
+	$is_guest_payment = ! empty($payment_user_id) && $payment_user_id > 0 ? false : true;
1002 1002
 
1003
-	return (bool) apply_filters( 'give_is_guest_payment', $is_guest_payment, $payment_id );
1003
+	return (bool) apply_filters('give_is_guest_payment', $is_guest_payment, $payment_id);
1004 1004
 }
1005 1005
 
1006 1006
 /**
@@ -1012,38 +1012,38 @@  discard block
 block discarded – undo
1012 1012
  *
1013 1013
  * @return string $user_id User ID
1014 1014
  */
1015
-function give_get_payment_user_id( $payment_id ) {
1015
+function give_get_payment_user_id($payment_id) {
1016 1016
 
1017 1017
 	$user_id = - 1;
1018 1018
 
1019 1019
 	// check the customer record first
1020
-	$customer_id = give_get_payment_customer_id( $payment_id );
1021
-	$customer    = new Give_Customer( $customer_id );
1020
+	$customer_id = give_get_payment_customer_id($payment_id);
1021
+	$customer    = new Give_Customer($customer_id);
1022 1022
 
1023
-	if ( ! empty( $customer->user_id ) && $customer->user_id > 0 ) {
1023
+	if ( ! empty($customer->user_id) && $customer->user_id > 0) {
1024 1024
 		$user_id = $customer->user_id;
1025 1025
 	}
1026 1026
 
1027 1027
 	// check the payment meta if we're still not finding a user with the customer record
1028
-	if ( empty( $user_id ) || $user_id < 1 ) {
1029
-		$payment_meta_user_id = give_get_payment_meta( $payment_id, '_give_payment_user_id', true );
1028
+	if (empty($user_id) || $user_id < 1) {
1029
+		$payment_meta_user_id = give_get_payment_meta($payment_id, '_give_payment_user_id', true);
1030 1030
 
1031
-		if ( ! empty( $payment_meta_user_id ) ) {
1031
+		if ( ! empty($payment_meta_user_id)) {
1032 1032
 			$user_id = $payment_meta_user_id;
1033 1033
 		}
1034 1034
 	}
1035 1035
 
1036 1036
 	// Last ditch effort is to connect payment email with a user in the user table
1037
-	if ( empty( $user_id ) || $user_id < 1 ) {
1038
-		$payment_email = give_get_payment_user_email( $payment_id );
1039
-		$user          = get_user_by( 'email', $payment_email );
1037
+	if (empty($user_id) || $user_id < 1) {
1038
+		$payment_email = give_get_payment_user_email($payment_id);
1039
+		$user          = get_user_by('email', $payment_email);
1040 1040
 
1041
-		if ( false !== $user ) {
1041
+		if (false !== $user) {
1042 1042
 			$user_id = $user->ID;
1043 1043
 		}
1044 1044
 	}
1045 1045
 
1046
-	return apply_filters( 'give_payment_user_id', (int) $user_id );
1046
+	return apply_filters('give_payment_user_id', (int) $user_id);
1047 1047
 }
1048 1048
 
1049 1049
 /**
@@ -1055,10 +1055,10 @@  discard block
 block discarded – undo
1055 1055
  *
1056 1056
  * @return string $donor_id Donor ID
1057 1057
  */
1058
-function give_get_payment_customer_id( $payment_id ) {
1059
-	$customer_id = get_post_meta( $payment_id, '_give_payment_customer_id', true );
1058
+function give_get_payment_customer_id($payment_id) {
1059
+	$customer_id = get_post_meta($payment_id, '_give_payment_customer_id', true);
1060 1060
 
1061
-	return apply_filters( '_give_payment_customer_id', $customer_id );
1061
+	return apply_filters('_give_payment_customer_id', $customer_id);
1062 1062
 }
1063 1063
 
1064 1064
 /**
@@ -1070,10 +1070,10 @@  discard block
 block discarded – undo
1070 1070
  *
1071 1071
  * @return string $ip User IP
1072 1072
  */
1073
-function give_get_payment_user_ip( $payment_id ) {
1074
-	$ip = give_get_payment_meta( $payment_id, '_give_payment_user_ip', true );
1073
+function give_get_payment_user_ip($payment_id) {
1074
+	$ip = give_get_payment_meta($payment_id, '_give_payment_user_ip', true);
1075 1075
 
1076
-	return apply_filters( 'give_payment_user_ip', $ip );
1076
+	return apply_filters('give_payment_user_ip', $ip);
1077 1077
 }
1078 1078
 
1079 1079
 /**
@@ -1085,17 +1085,17 @@  discard block
 block discarded – undo
1085 1085
  *
1086 1086
  * @return string $date The date the payment was completed
1087 1087
  */
1088
-function give_get_payment_completed_date( $payment_id = 0 ) {
1088
+function give_get_payment_completed_date($payment_id = 0) {
1089 1089
 
1090
-	$payment = get_post( $payment_id );
1090
+	$payment = get_post($payment_id);
1091 1091
 
1092
-	if ( 'pending' == $payment->post_status || 'preapproved' == $payment->post_status ) {
1092
+	if ('pending' == $payment->post_status || 'preapproved' == $payment->post_status) {
1093 1093
 		return false; // This payment was never completed
1094 1094
 	}
1095 1095
 
1096
-	$date = ( $date = give_get_payment_meta( $payment_id, '_give_completed_date', true ) ) ? $date : $payment->modified_date;
1096
+	$date = ($date = give_get_payment_meta($payment_id, '_give_completed_date', true)) ? $date : $payment->modified_date;
1097 1097
 
1098
-	return apply_filters( 'give_payment_completed_date', $date, $payment_id );
1098
+	return apply_filters('give_payment_completed_date', $date, $payment_id);
1099 1099
 }
1100 1100
 
1101 1101
 /**
@@ -1107,10 +1107,10 @@  discard block
 block discarded – undo
1107 1107
  *
1108 1108
  * @return string $gateway Gateway
1109 1109
  */
1110
-function give_get_payment_gateway( $payment_id ) {
1111
-	$gateway = give_get_payment_meta( $payment_id, '_give_payment_gateway', true );
1110
+function give_get_payment_gateway($payment_id) {
1111
+	$gateway = give_get_payment_meta($payment_id, '_give_payment_gateway', true);
1112 1112
 
1113
-	return apply_filters( 'give_payment_gateway', $gateway );
1113
+	return apply_filters('give_payment_gateway', $gateway);
1114 1114
 }
1115 1115
 
1116 1116
 /**
@@ -1122,11 +1122,11 @@  discard block
 block discarded – undo
1122 1122
  *
1123 1123
  * @return string $currency The currency code
1124 1124
  */
1125
-function give_get_payment_currency_code( $payment_id = 0 ) {
1126
-	$meta     = give_get_payment_meta( $payment_id );
1127
-	$currency = isset( $meta['currency'] ) ? $meta['currency'] : give_get_currency();
1125
+function give_get_payment_currency_code($payment_id = 0) {
1126
+	$meta     = give_get_payment_meta($payment_id);
1127
+	$currency = isset($meta['currency']) ? $meta['currency'] : give_get_currency();
1128 1128
 
1129
-	return apply_filters( 'give_payment_currency_code', $currency, $payment_id );
1129
+	return apply_filters('give_payment_currency_code', $currency, $payment_id);
1130 1130
 }
1131 1131
 
1132 1132
 /**
@@ -1138,10 +1138,10 @@  discard block
 block discarded – undo
1138 1138
  *
1139 1139
  * @return string $currency The currency name
1140 1140
  */
1141
-function give_get_payment_currency( $payment_id = 0 ) {
1142
-	$currency = give_get_payment_currency_code( $payment_id );
1141
+function give_get_payment_currency($payment_id = 0) {
1142
+	$currency = give_get_payment_currency_code($payment_id);
1143 1143
 
1144
-	return apply_filters( 'give_payment_currency', give_get_currency_name( $currency ), $payment_id );
1144
+	return apply_filters('give_payment_currency', give_get_currency_name($currency), $payment_id);
1145 1145
 }
1146 1146
 
1147 1147
 /**
@@ -1153,10 +1153,10 @@  discard block
 block discarded – undo
1153 1153
  *
1154 1154
  * @return string $key Purchase key
1155 1155
  */
1156
-function give_get_payment_key( $payment_id = 0 ) {
1157
-	$key = give_get_payment_meta( $payment_id, '_give_payment_purchase_key', true );
1156
+function give_get_payment_key($payment_id = 0) {
1157
+	$key = give_get_payment_meta($payment_id, '_give_payment_purchase_key', true);
1158 1158
 
1159
-	return apply_filters( 'give_payment_key', $key, $payment_id );
1159
+	return apply_filters('give_payment_key', $key, $payment_id);
1160 1160
 }
1161 1161
 
1162 1162
 /**
@@ -1170,15 +1170,15 @@  discard block
 block discarded – undo
1170 1170
  *
1171 1171
  * @return string $number Payment order number
1172 1172
  */
1173
-function give_get_payment_number( $payment_id = 0 ) {
1173
+function give_get_payment_number($payment_id = 0) {
1174 1174
 
1175 1175
 	$number = $payment_id;
1176 1176
 
1177
-	if ( give_get_option( 'enable_sequential' ) ) {
1177
+	if (give_get_option('enable_sequential')) {
1178 1178
 
1179
-		$number = give_get_payment_meta( $payment_id, '_give_payment_number', true );
1179
+		$number = give_get_payment_meta($payment_id, '_give_payment_number', true);
1180 1180
 
1181
-		if ( ! $number ) {
1181
+		if ( ! $number) {
1182 1182
 
1183 1183
 			$number = $payment_id;
1184 1184
 
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
 
1187 1187
 	}
1188 1188
 
1189
-	return apply_filters( 'give_payment_number', $number, $payment_id );
1189
+	return apply_filters('give_payment_number', $number, $payment_id);
1190 1190
 }
1191 1191
 
1192 1192
 /**
@@ -1198,23 +1198,23 @@  discard block
 block discarded – undo
1198 1198
  *
1199 1199
  * @return string      The formatted payment number
1200 1200
  */
1201
-function give_format_payment_number( $number ) {
1201
+function give_format_payment_number($number) {
1202 1202
 
1203
-	if ( ! give_get_option( 'enable_sequential' ) ) {
1203
+	if ( ! give_get_option('enable_sequential')) {
1204 1204
 		return $number;
1205 1205
 	}
1206 1206
 
1207
-	if ( ! is_numeric( $number ) ) {
1207
+	if ( ! is_numeric($number)) {
1208 1208
 		return $number;
1209 1209
 	}
1210 1210
 
1211
-	$prefix  = give_get_option( 'sequential_prefix' );
1212
-	$number  = absint( $number );
1213
-	$postfix = give_get_option( 'sequential_postfix' );
1211
+	$prefix  = give_get_option('sequential_prefix');
1212
+	$number  = absint($number);
1213
+	$postfix = give_get_option('sequential_postfix');
1214 1214
 
1215
-	$formatted_number = $prefix . $number . $postfix;
1215
+	$formatted_number = $prefix.$number.$postfix;
1216 1216
 
1217
-	return apply_filters( 'give_format_payment_number', $formatted_number, $prefix, $number, $postfix );
1217
+	return apply_filters('give_format_payment_number', $formatted_number, $prefix, $number, $postfix);
1218 1218
 }
1219 1219
 
1220 1220
 /**
@@ -1227,17 +1227,17 @@  discard block
 block discarded – undo
1227 1227
  */
1228 1228
 function give_get_next_payment_number() {
1229 1229
 
1230
-	if ( ! give_get_option( 'enable_sequential' ) ) {
1230
+	if ( ! give_get_option('enable_sequential')) {
1231 1231
 		return false;
1232 1232
 	}
1233 1233
 
1234
-	$number           = get_option( 'give_last_payment_number' );
1235
-	$start            = give_get_option( 'sequential_start', 1 );
1234
+	$number           = get_option('give_last_payment_number');
1235
+	$start            = give_get_option('sequential_start', 1);
1236 1236
 	$increment_number = true;
1237 1237
 
1238
-	if ( false !== $number ) {
1238
+	if (false !== $number) {
1239 1239
 
1240
-		if ( empty( $number ) ) {
1240
+		if (empty($number)) {
1241 1241
 
1242 1242
 			$number           = $start;
1243 1243
 			$increment_number = false;
@@ -1247,24 +1247,24 @@  discard block
 block discarded – undo
1247 1247
 	} else {
1248 1248
 
1249 1249
 		// This case handles the first addition of the new option, as well as if it get's deleted for any reason
1250
-		$payments     = new Give_Payments_Query( array(
1250
+		$payments = new Give_Payments_Query(array(
1251 1251
 			'number'  => 1,
1252 1252
 			'order'   => 'DESC',
1253 1253
 			'orderby' => 'ID',
1254 1254
 			'output'  => 'posts',
1255 1255
 			'fields'  => 'ids'
1256
-		) );
1256
+		));
1257 1257
 		$last_payment = $payments->get_payments();
1258 1258
 
1259
-		if ( $last_payment ) {
1259
+		if ($last_payment) {
1260 1260
 
1261
-			$number = give_get_payment_number( $last_payment[0] );
1261
+			$number = give_get_payment_number($last_payment[0]);
1262 1262
 
1263 1263
 		}
1264 1264
 
1265
-		if ( ! empty( $number ) && $number !== $last_payment[0] ) {
1265
+		if ( ! empty($number) && $number !== $last_payment[0]) {
1266 1266
 
1267
-			$number = give_remove_payment_prefix_postfix( $number );
1267
+			$number = give_remove_payment_prefix_postfix($number);
1268 1268
 
1269 1269
 		} else {
1270 1270
 
@@ -1274,13 +1274,13 @@  discard block
 block discarded – undo
1274 1274
 
1275 1275
 	}
1276 1276
 
1277
-	$increment_number = apply_filters( 'give_increment_payment_number', $increment_number, $number );
1277
+	$increment_number = apply_filters('give_increment_payment_number', $increment_number, $number);
1278 1278
 
1279
-	if ( $increment_number ) {
1280
-		$number ++;
1279
+	if ($increment_number) {
1280
+		$number++;
1281 1281
 	}
1282 1282
 
1283
-	return apply_filters( 'give_get_next_payment_number', $number );
1283
+	return apply_filters('give_get_next_payment_number', $number);
1284 1284
 }
1285 1285
 
1286 1286
 /**
@@ -1292,25 +1292,25 @@  discard block
 block discarded – undo
1292 1292
  *
1293 1293
  * @return string          The new Payment number without prefix and postfix
1294 1294
  */
1295
-function give_remove_payment_prefix_postfix( $number ) {
1295
+function give_remove_payment_prefix_postfix($number) {
1296 1296
 
1297
-	$prefix  = give_get_option( 'sequential_prefix' );
1298
-	$postfix = give_get_option( 'sequential_postfix' );
1297
+	$prefix  = give_get_option('sequential_prefix');
1298
+	$postfix = give_get_option('sequential_postfix');
1299 1299
 
1300 1300
 	// Remove prefix
1301
-	$number = preg_replace( '/' . $prefix . '/', '', $number, 1 );
1301
+	$number = preg_replace('/'.$prefix.'/', '', $number, 1);
1302 1302
 
1303 1303
 	// Remove the postfix
1304
-	$length      = strlen( $number );
1305
-	$postfix_pos = strrpos( $number, $postfix );
1306
-	if ( false !== $postfix_pos ) {
1307
-		$number = substr_replace( $number, '', $postfix_pos, $length );
1304
+	$length      = strlen($number);
1305
+	$postfix_pos = strrpos($number, $postfix);
1306
+	if (false !== $postfix_pos) {
1307
+		$number = substr_replace($number, '', $postfix_pos, $length);
1308 1308
 	}
1309 1309
 
1310 1310
 	// Ensure it's a whole number
1311
-	$number = intval( $number );
1311
+	$number = intval($number);
1312 1312
 
1313
-	return apply_filters( 'give_remove_payment_prefix_postfix', $number, $prefix, $postfix );
1313
+	return apply_filters('give_remove_payment_prefix_postfix', $number, $prefix, $postfix);
1314 1314
 
1315 1315
 }
1316 1316
 
@@ -1326,10 +1326,10 @@  discard block
 block discarded – undo
1326 1326
  *
1327 1327
  * @return string $amount Fully formatted payment amount
1328 1328
  */
1329
-function give_payment_amount( $payment_id = 0 ) {
1330
-	$amount = give_get_payment_amount( $payment_id );
1329
+function give_payment_amount($payment_id = 0) {
1330
+	$amount = give_get_payment_amount($payment_id);
1331 1331
 
1332
-	return give_currency_filter( give_format_amount( $amount ), give_get_payment_currency_code( $payment_id ) );
1332
+	return give_currency_filter(give_format_amount($amount), give_get_payment_currency_code($payment_id));
1333 1333
 }
1334 1334
 
1335 1335
 /**
@@ -1342,20 +1342,20 @@  discard block
 block discarded – undo
1342 1342
  *
1343 1343
  * @return mixed|void
1344 1344
  */
1345
-function give_get_payment_amount( $payment_id ) {
1345
+function give_get_payment_amount($payment_id) {
1346 1346
 
1347
-	$amount = give_get_payment_meta( $payment_id, '_give_payment_total', true );
1347
+	$amount = give_get_payment_meta($payment_id, '_give_payment_total', true);
1348 1348
 
1349
-	if ( empty( $amount ) && '0.00' != $amount ) {
1350
-		$meta = give_get_payment_meta( $payment_id, '_give_payment_meta', true );
1351
-		$meta = maybe_unserialize( $meta );
1349
+	if (empty($amount) && '0.00' != $amount) {
1350
+		$meta = give_get_payment_meta($payment_id, '_give_payment_meta', true);
1351
+		$meta = maybe_unserialize($meta);
1352 1352
 
1353
-		if ( isset( $meta['amount'] ) ) {
1353
+		if (isset($meta['amount'])) {
1354 1354
 			$amount = $meta['amount'];
1355 1355
 		}
1356 1356
 	}
1357 1357
 
1358
-	return apply_filters( 'give_payment_amount', floatval( $amount ), $payment_id );
1358
+	return apply_filters('give_payment_amount', floatval($amount), $payment_id);
1359 1359
 }
1360 1360
 
1361 1361
 
@@ -1368,19 +1368,19 @@  discard block
 block discarded – undo
1368 1368
  *
1369 1369
  * @return string The Transaction ID
1370 1370
  */
1371
-function give_get_payment_transaction_id( $payment_id = 0 ) {
1371
+function give_get_payment_transaction_id($payment_id = 0) {
1372 1372
 
1373 1373
 	$transaction_id = false;
1374
-	$transaction_id = give_get_payment_meta( $payment_id, '_give_payment_transaction_id', true );
1374
+	$transaction_id = give_get_payment_meta($payment_id, '_give_payment_transaction_id', true);
1375 1375
 
1376
-	if ( empty( $transaction_id ) ) {
1376
+	if (empty($transaction_id)) {
1377 1377
 
1378
-		$gateway        = give_get_payment_gateway( $payment_id );
1379
-		$transaction_id = apply_filters( 'give_get_payment_transaction_id-' . $gateway, $payment_id );
1378
+		$gateway        = give_get_payment_gateway($payment_id);
1379
+		$transaction_id = apply_filters('give_get_payment_transaction_id-'.$gateway, $payment_id);
1380 1380
 
1381 1381
 	}
1382 1382
 
1383
-	return apply_filters( 'give_get_payment_transaction_id', $transaction_id, $payment_id );
1383
+	return apply_filters('give_get_payment_transaction_id', $transaction_id, $payment_id);
1384 1384
 }
1385 1385
 
1386 1386
 /**
@@ -1393,15 +1393,15 @@  discard block
 block discarded – undo
1393 1393
  *
1394 1394
  * @return bool|mixed
1395 1395
  */
1396
-function give_set_payment_transaction_id( $payment_id = 0, $transaction_id = '' ) {
1396
+function give_set_payment_transaction_id($payment_id = 0, $transaction_id = '') {
1397 1397
 
1398
-	if ( empty( $payment_id ) || empty( $transaction_id ) ) {
1398
+	if (empty($payment_id) || empty($transaction_id)) {
1399 1399
 		return false;
1400 1400
 	}
1401 1401
 
1402
-	$transaction_id = apply_filters( 'give_set_payment_transaction_id', $transaction_id, $payment_id );
1402
+	$transaction_id = apply_filters('give_set_payment_transaction_id', $transaction_id, $payment_id);
1403 1403
 
1404
-	return give_update_payment_meta( $payment_id, '_give_payment_transaction_id', $transaction_id );
1404
+	return give_update_payment_meta($payment_id, '_give_payment_transaction_id', $transaction_id);
1405 1405
 }
1406 1406
 
1407 1407
 /**
@@ -1415,12 +1415,12 @@  discard block
 block discarded – undo
1415 1415
  *
1416 1416
  * @return int $purchase Purchase ID
1417 1417
  */
1418
-function give_get_purchase_id_by_key( $key ) {
1418
+function give_get_purchase_id_by_key($key) {
1419 1419
 	global $wpdb;
1420 1420
 
1421
-	$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 ) );
1421
+	$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));
1422 1422
 
1423
-	if ( $purchase != null ) {
1423
+	if ($purchase != null) {
1424 1424
 		return $purchase;
1425 1425
 	}
1426 1426
 
@@ -1439,12 +1439,12 @@  discard block
 block discarded – undo
1439 1439
  *
1440 1440
  * @return int $purchase Purchase ID
1441 1441
  */
1442
-function give_get_purchase_id_by_transaction_id( $key ) {
1442
+function give_get_purchase_id_by_transaction_id($key) {
1443 1443
 	global $wpdb;
1444 1444
 
1445
-	$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 ) );
1445
+	$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));
1446 1446
 
1447
-	if ( $purchase != null ) {
1447
+	if ($purchase != null) {
1448 1448
 		return $purchase;
1449 1449
 	}
1450 1450
 
@@ -1461,19 +1461,19 @@  discard block
 block discarded – undo
1461 1461
  *
1462 1462
  * @return array $notes Payment Notes
1463 1463
  */
1464
-function give_get_payment_notes( $payment_id = 0, $search = '' ) {
1464
+function give_get_payment_notes($payment_id = 0, $search = '') {
1465 1465
 
1466
-	if ( empty( $payment_id ) && empty( $search ) ) {
1466
+	if (empty($payment_id) && empty($search)) {
1467 1467
 		return false;
1468 1468
 	}
1469 1469
 
1470
-	remove_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1471
-	remove_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 );
1470
+	remove_action('pre_get_comments', 'give_hide_payment_notes', 10);
1471
+	remove_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2);
1472 1472
 
1473
-	$notes = get_comments( array( 'post_id' => $payment_id, 'order' => 'ASC', 'search' => $search ) );
1473
+	$notes = get_comments(array('post_id' => $payment_id, 'order' => 'ASC', 'search' => $search));
1474 1474
 
1475
-	add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1476
-	add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 );
1475
+	add_action('pre_get_comments', 'give_hide_payment_notes', 10);
1476
+	add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2);
1477 1477
 
1478 1478
 	return $notes;
1479 1479
 }
@@ -1489,19 +1489,19 @@  discard block
 block discarded – undo
1489 1489
  *
1490 1490
  * @return int The new note ID
1491 1491
  */
1492
-function give_insert_payment_note( $payment_id = 0, $note = '' ) {
1493
-	if ( empty( $payment_id ) ) {
1492
+function give_insert_payment_note($payment_id = 0, $note = '') {
1493
+	if (empty($payment_id)) {
1494 1494
 		return false;
1495 1495
 	}
1496 1496
 
1497
-	do_action( 'give_pre_insert_payment_note', $payment_id, $note );
1497
+	do_action('give_pre_insert_payment_note', $payment_id, $note);
1498 1498
 
1499
-	$note_id = wp_insert_comment( wp_filter_comment( array(
1499
+	$note_id = wp_insert_comment(wp_filter_comment(array(
1500 1500
 		'comment_post_ID'      => $payment_id,
1501 1501
 		'comment_content'      => $note,
1502 1502
 		'user_id'              => is_admin() ? get_current_user_id() : 0,
1503
-		'comment_date'         => current_time( 'mysql' ),
1504
-		'comment_date_gmt'     => current_time( 'mysql', 1 ),
1503
+		'comment_date'         => current_time('mysql'),
1504
+		'comment_date_gmt'     => current_time('mysql', 1),
1505 1505
 		'comment_approved'     => 1,
1506 1506
 		'comment_parent'       => 0,
1507 1507
 		'comment_author'       => '',
@@ -1510,9 +1510,9 @@  discard block
 block discarded – undo
1510 1510
 		'comment_author_email' => '',
1511 1511
 		'comment_type'         => 'give_payment_note'
1512 1512
 
1513
-	) ) );
1513
+	)));
1514 1514
 
1515
-	do_action( 'give_insert_payment_note', $note_id, $payment_id, $note );
1515
+	do_action('give_insert_payment_note', $note_id, $payment_id, $note);
1516 1516
 
1517 1517
 	return $note_id;
1518 1518
 }
@@ -1527,14 +1527,14 @@  discard block
 block discarded – undo
1527 1527
  *
1528 1528
  * @return bool True on success, false otherwise
1529 1529
  */
1530
-function give_delete_payment_note( $comment_id = 0, $payment_id = 0 ) {
1531
-	if ( empty( $comment_id ) ) {
1530
+function give_delete_payment_note($comment_id = 0, $payment_id = 0) {
1531
+	if (empty($comment_id)) {
1532 1532
 		return false;
1533 1533
 	}
1534 1534
 
1535
-	do_action( 'give_pre_delete_payment_note', $comment_id, $payment_id );
1536
-	$ret = wp_delete_comment( $comment_id, true );
1537
-	do_action( 'give_post_delete_payment_note', $comment_id, $payment_id );
1535
+	do_action('give_pre_delete_payment_note', $comment_id, $payment_id);
1536
+	$ret = wp_delete_comment($comment_id, true);
1537
+	do_action('give_post_delete_payment_note', $comment_id, $payment_id);
1538 1538
 
1539 1539
 	return $ret;
1540 1540
 }
@@ -1549,32 +1549,32 @@  discard block
 block discarded – undo
1549 1549
  *
1550 1550
  * @return string
1551 1551
  */
1552
-function give_get_payment_note_html( $note, $payment_id = 0 ) {
1552
+function give_get_payment_note_html($note, $payment_id = 0) {
1553 1553
 
1554
-	if ( is_numeric( $note ) ) {
1555
-		$note = get_comment( $note );
1554
+	if (is_numeric($note)) {
1555
+		$note = get_comment($note);
1556 1556
 	}
1557 1557
 
1558
-	if ( ! empty( $note->user_id ) ) {
1559
-		$user = get_userdata( $note->user_id );
1558
+	if ( ! empty($note->user_id)) {
1559
+		$user = get_userdata($note->user_id);
1560 1560
 		$user = $user->display_name;
1561 1561
 	} else {
1562
-		$user = __( 'System', 'give' );
1562
+		$user = __('System', 'give');
1563 1563
 	}
1564 1564
 
1565
-	$date_format = get_option( 'date_format' ) . ', ' . get_option( 'time_format' );
1565
+	$date_format = get_option('date_format').', '.get_option('time_format');
1566 1566
 
1567
-	$delete_note_url = wp_nonce_url( add_query_arg( array(
1567
+	$delete_note_url = wp_nonce_url(add_query_arg(array(
1568 1568
 		'give-action' => 'delete_payment_note',
1569 1569
 		'note_id'     => $note->comment_ID,
1570 1570
 		'payment_id'  => $payment_id
1571
-	) ), 'give_delete_payment_note_' . $note->comment_ID );
1571
+	)), 'give_delete_payment_note_'.$note->comment_ID);
1572 1572
 
1573
-	$note_html = '<div class="give-payment-note" id="give-payment-note-' . $note->comment_ID . '">';
1573
+	$note_html = '<div class="give-payment-note" id="give-payment-note-'.$note->comment_ID.'">';
1574 1574
 	$note_html .= '<p>';
1575
-	$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/>';
1575
+	$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/>';
1576 1576
 	$note_html .= $note->comment_content;
1577
-	$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 ) . '" title="' . __( 'Delete this payment note', 'give' ) . '">' . __( 'Delete', 'give' ) . '</a>';
1577
+	$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).'" title="'.__('Delete this payment note', 'give').'">'.__('Delete', 'give').'</a>';
1578 1578
 	$note_html .= '</p>';
1579 1579
 	$note_html .= '</div>';
1580 1580
 
@@ -1592,20 +1592,20 @@  discard block
 block discarded – undo
1592 1592
  *
1593 1593
  * @return void
1594 1594
  */
1595
-function give_hide_payment_notes( $query ) {
1595
+function give_hide_payment_notes($query) {
1596 1596
 	global $wp_version;
1597 1597
 
1598
-	if ( version_compare( floatval( $wp_version ), '4.1', '>=' ) ) {
1599
-		$types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array();
1600
-		if ( ! is_array( $types ) ) {
1601
-			$types = array( $types );
1598
+	if (version_compare(floatval($wp_version), '4.1', '>=')) {
1599
+		$types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array();
1600
+		if ( ! is_array($types)) {
1601
+			$types = array($types);
1602 1602
 		}
1603 1603
 		$types[]                           = 'give_payment_note';
1604 1604
 		$query->query_vars['type__not_in'] = $types;
1605 1605
 	}
1606 1606
 }
1607 1607
 
1608
-add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1608
+add_action('pre_get_comments', 'give_hide_payment_notes', 10);
1609 1609
 
1610 1610
 /**
1611 1611
  * Exclude notes (comments) on give_payment post type from showing in Recent Comments widgets
@@ -1617,17 +1617,17 @@  discard block
 block discarded – undo
1617 1617
  *
1618 1618
  * @return array $clauses Updated comment clauses
1619 1619
  */
1620
-function give_hide_payment_notes_pre_41( $clauses, $wp_comment_query ) {
1620
+function give_hide_payment_notes_pre_41($clauses, $wp_comment_query) {
1621 1621
 	global $wpdb, $wp_version;
1622 1622
 
1623
-	if ( version_compare( floatval( $wp_version ), '4.1', '<' ) ) {
1623
+	if (version_compare(floatval($wp_version), '4.1', '<')) {
1624 1624
 		$clauses['where'] .= ' AND comment_type != "give_payment_note"';
1625 1625
 	}
1626 1626
 
1627 1627
 	return $clauses;
1628 1628
 }
1629 1629
 
1630
-add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 );
1630
+add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2);
1631 1631
 
1632 1632
 
1633 1633
 /**
@@ -1640,15 +1640,15 @@  discard block
 block discarded – undo
1640 1640
  *
1641 1641
  * @return array $where
1642 1642
  */
1643
-function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) {
1643
+function give_hide_payment_notes_from_feeds($where, $wp_comment_query) {
1644 1644
 	global $wpdb;
1645 1645
 
1646
-	$where .= $wpdb->prepare( " AND comment_type != %s", 'give_payment_note' );
1646
+	$where .= $wpdb->prepare(" AND comment_type != %s", 'give_payment_note');
1647 1647
 
1648 1648
 	return $where;
1649 1649
 }
1650 1650
 
1651
-add_filter( 'comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2 );
1651
+add_filter('comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2);
1652 1652
 
1653 1653
 
1654 1654
 /**
@@ -1662,32 +1662,32 @@  discard block
 block discarded – undo
1662 1662
  *
1663 1663
  * @return array Array of comment counts
1664 1664
  */
1665
-function give_remove_payment_notes_in_comment_counts( $stats, $post_id ) {
1665
+function give_remove_payment_notes_in_comment_counts($stats, $post_id) {
1666 1666
 	global $wpdb, $pagenow;
1667 1667
 
1668
-	if ( 'index.php' != $pagenow ) {
1668
+	if ('index.php' != $pagenow) {
1669 1669
 		return $stats;
1670 1670
 	}
1671 1671
 
1672 1672
 	$post_id = (int) $post_id;
1673 1673
 
1674
-	if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) {
1674
+	if (apply_filters('give_count_payment_notes_in_comments', false)) {
1675 1675
 		return $stats;
1676 1676
 	}
1677 1677
 
1678
-	$stats = wp_cache_get( "comments-{$post_id}", 'counts' );
1678
+	$stats = wp_cache_get("comments-{$post_id}", 'counts');
1679 1679
 
1680
-	if ( false !== $stats ) {
1680
+	if (false !== $stats) {
1681 1681
 		return $stats;
1682 1682
 	}
1683 1683
 
1684 1684
 	$where = 'WHERE comment_type != "give_payment_note"';
1685 1685
 
1686
-	if ( $post_id > 0 ) {
1687
-		$where .= $wpdb->prepare( " AND comment_post_ID = %d", $post_id );
1686
+	if ($post_id > 0) {
1687
+		$where .= $wpdb->prepare(" AND comment_post_ID = %d", $post_id);
1688 1688
 	}
1689 1689
 
1690
-	$count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A );
1690
+	$count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A);
1691 1691
 
1692 1692
 	$total    = 0;
1693 1693
 	$approved = array(
@@ -1697,30 +1697,30 @@  discard block
 block discarded – undo
1697 1697
 		'trash'        => 'trash',
1698 1698
 		'post-trashed' => 'post-trashed'
1699 1699
 	);
1700
-	foreach ( (array) $count as $row ) {
1700
+	foreach ((array) $count as $row) {
1701 1701
 		// Don't count post-trashed toward totals
1702
-		if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) {
1702
+		if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) {
1703 1703
 			$total += $row['num_comments'];
1704 1704
 		}
1705
-		if ( isset( $approved[ $row['comment_approved'] ] ) ) {
1706
-			$stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments'];
1705
+		if (isset($approved[$row['comment_approved']])) {
1706
+			$stats[$approved[$row['comment_approved']]] = $row['num_comments'];
1707 1707
 		}
1708 1708
 	}
1709 1709
 
1710 1710
 	$stats['total_comments'] = $total;
1711
-	foreach ( $approved as $key ) {
1712
-		if ( empty( $stats[ $key ] ) ) {
1713
-			$stats[ $key ] = 0;
1711
+	foreach ($approved as $key) {
1712
+		if (empty($stats[$key])) {
1713
+			$stats[$key] = 0;
1714 1714
 		}
1715 1715
 	}
1716 1716
 
1717 1717
 	$stats = (object) $stats;
1718
-	wp_cache_set( "comments-{$post_id}", $stats, 'counts' );
1718
+	wp_cache_set("comments-{$post_id}", $stats, 'counts');
1719 1719
 
1720 1720
 	return $stats;
1721 1721
 }
1722 1722
 
1723
-add_filter( 'wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2 );
1723
+add_filter('wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2);
1724 1724
 
1725 1725
 
1726 1726
 /**
@@ -1733,9 +1733,9 @@  discard block
 block discarded – undo
1733 1733
  *
1734 1734
  * @return string $where Modified where clause
1735 1735
  */
1736
-function give_filter_where_older_than_week( $where = '' ) {
1736
+function give_filter_where_older_than_week($where = '') {
1737 1737
 	// Payments older than one week
1738
-	$start = date( 'Y-m-d', strtotime( '-7 days' ) );
1738
+	$start = date('Y-m-d', strtotime('-7 days'));
1739 1739
 	$where .= " AND post_date <= '{$start}'";
1740 1740
 
1741 1741
 	return $where;
@@ -1752,20 +1752,20 @@  discard block
 block discarded – undo
1752 1752
  *
1753 1753
  * @return string $price_id
1754 1754
  */
1755
-function give_get_price_id( $form_id, $price ) {
1755
+function give_get_price_id($form_id, $price) {
1756 1756
 
1757 1757
 	$price_id = 0;
1758 1758
 
1759
-	if ( give_has_variable_prices( $form_id ) ) {
1759
+	if (give_has_variable_prices($form_id)) {
1760 1760
 
1761
-		$levels = maybe_unserialize( get_post_meta( $form_id, '_give_donation_levels', true ) );
1761
+		$levels = maybe_unserialize(get_post_meta($form_id, '_give_donation_levels', true));
1762 1762
 
1763
-		foreach ( $levels as $level ) {
1763
+		foreach ($levels as $level) {
1764 1764
 
1765
-			$level_amount = (float) give_sanitize_amount( $level['_give_amount'] );
1765
+			$level_amount = (float) give_sanitize_amount($level['_give_amount']);
1766 1766
 
1767 1767
 			//check that this indeed the recurring price
1768
-			if ( $level_amount == $price ) {
1768
+			if ($level_amount == $price) {
1769 1769
 
1770 1770
 				$price_id = $level['_give_id']['level_id'];
1771 1771
 
@@ -1789,14 +1789,14 @@  discard block
 block discarded – undo
1789 1789
  *
1790 1790
  * @return mixed array if payment fees found, false otherwise
1791 1791
  */
1792
-function give_get_payment_fees( $payment_id = 0, $type = 'all' ) {
1793
-	$payment_meta = give_get_payment_meta( $payment_id );
1792
+function give_get_payment_fees($payment_id = 0, $type = 'all') {
1793
+	$payment_meta = give_get_payment_meta($payment_id);
1794 1794
 	$fees         = array();
1795
-	$payment_fees = isset( $payment_meta['fees'] ) ? $payment_meta['fees'] : false;
1796
-	if ( ! empty( $payment_fees ) && is_array( $payment_fees ) ) {
1797
-		foreach ( $payment_fees as $fee_id => $fee ) {
1798
-			if ( 'all' != $type && ! empty( $fee['type'] ) && $type != $fee['type'] ) {
1799
-				unset( $payment_fees[ $fee_id ] );
1795
+	$payment_fees = isset($payment_meta['fees']) ? $payment_meta['fees'] : false;
1796
+	if ( ! empty($payment_fees) && is_array($payment_fees)) {
1797
+		foreach ($payment_fees as $fee_id => $fee) {
1798
+			if ('all' != $type && ! empty($fee['type']) && $type != $fee['type']) {
1799
+				unset($payment_fees[$fee_id]);
1800 1800
 			} else {
1801 1801
 				$fees[] = array(
1802 1802
 					'id'     => $fee_id,
@@ -1807,5 +1807,5 @@  discard block
 block discarded – undo
1807 1807
 		}
1808 1808
 	}
1809 1809
 
1810
-	return apply_filters( 'give_get_payment_fees', $fees, $payment_id );
1810
+	return apply_filters('give_get_payment_fees', $fees, $payment_id);
1811 1811
 }
1812 1812
\ No newline at end of file
Please login to merge, or discard this patch.
includes/process-purchase.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * @access      private
23 23
  * @since       1.0
24
- * @return      void
24
+ * @return      false|null
25 25
  */
26 26
 function give_process_purchase_form() {
27 27
 
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
  *
327 327
  * @since  1.0.1
328 328
  *
329
- * @param $payment_mode
329
+ * @param string $payment_mode
330 330
  *
331 331
  * @return mixed|void
332 332
  */
Please login to merge, or discard this patch.
Spacing   +245 added lines, -245 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
 
@@ -25,27 +25,27 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function give_process_purchase_form() {
27 27
 
28
-	do_action( 'give_pre_process_purchase' );
28
+	do_action('give_pre_process_purchase');
29 29
 
30 30
 	// Validate the form $_POST data
31 31
 	$valid_data = give_purchase_form_validate_fields();
32 32
 
33 33
 	// Allow themes and plugins to hook to errors
34
-	do_action( 'give_checkout_error_checks', $valid_data, $_POST );
34
+	do_action('give_checkout_error_checks', $valid_data, $_POST);
35 35
 
36
-	$is_ajax = isset( $_POST['give_ajax'] );
36
+	$is_ajax = isset($_POST['give_ajax']);
37 37
 
38 38
 	// Process the login form
39
-	if ( isset( $_POST['give_login_submit'] ) ) {
39
+	if (isset($_POST['give_login_submit'])) {
40 40
 		give_process_form_login();
41 41
 	}
42 42
 
43 43
 	// Validate the user
44
-	$user = give_get_purchase_form_user( $valid_data );
44
+	$user = give_get_purchase_form_user($valid_data);
45 45
 
46
-	if ( give_get_errors() || ! $user ) {
47
-		if ( $is_ajax ) {
48
-			do_action( 'give_ajax_checkout_errors' );
46
+	if (give_get_errors() || ! $user) {
47
+		if ($is_ajax) {
48
+			do_action('give_ajax_checkout_errors');
49 49
 			give_die();
50 50
 		} else {
51 51
 			return false;
@@ -53,17 +53,17 @@  discard block
 block discarded – undo
53 53
 	}
54 54
 
55 55
 	//If AJAX send back success to proceed with form submission
56
-	if ( $is_ajax ) {
56
+	if ($is_ajax) {
57 57
 		echo 'success';
58 58
 		give_die();
59 59
 	}
60 60
 
61 61
 	//After AJAX: Setup session if not using php_sessions
62
-	if ( ! Give()->session->use_php_sessions() ) {
62
+	if ( ! Give()->session->use_php_sessions()) {
63 63
 		//Double-check that set_cookie is publicly accessible;
64 64
 		// we're using a slightly modified class-wp-sessions.php
65
-		$session_reflection = new ReflectionMethod( 'WP_Session', 'set_cookie' );
66
-		if ( $session_reflection->isPublic() ) {
65
+		$session_reflection = new ReflectionMethod('WP_Session', 'set_cookie');
66
+		if ($session_reflection->isPublic()) {
67 67
 			// Manually set the cookie.
68 68
 			Give()->session->init()->set_cookie();
69 69
 		}
@@ -78,15 +78,15 @@  discard block
 block discarded – undo
78 78
 		'address'    => $user['address']
79 79
 	);
80 80
 
81
-	$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
81
+	$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
82 82
 
83 83
 	// Setup purchase information
84 84
 	$purchase_data = array(
85
-		'price'        => ( isset( $_POST['give-amount'] ) ? (float) apply_filters( 'give_donation_total', give_sanitize_amount( give_format_amount( $_POST['give-amount'] ) ) ) : '0.00' ),
86
-		'purchase_key' => strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) ),
85
+		'price'        => (isset($_POST['give-amount']) ? (float) apply_filters('give_donation_total', give_sanitize_amount(give_format_amount($_POST['give-amount']))) : '0.00'),
86
+		'purchase_key' => strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true))),
87 87
 		'user_email'   => $user['user_email'],
88
-		'date'         => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ),
89
-		'user_info'    => stripslashes_deep( $user_info ),
88
+		'date'         => date('Y-m-d H:i:s', current_time('timestamp')),
89
+		'user_info'    => stripslashes_deep($user_info),
90 90
 		'post_data'    => $_POST,
91 91
 		'gateway'      => $valid_data['gateway'],
92 92
 		'card_info'    => $valid_data['cc_info']
@@ -96,37 +96,37 @@  discard block
 block discarded – undo
96 96
 	$valid_data['user'] = $user;
97 97
 
98 98
 	// Allow themes and plugins to hook before the gateway
99
-	do_action( 'give_checkout_before_gateway', $_POST, $user_info, $valid_data );
99
+	do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data);
100 100
 
101 101
 	//Sanity check for price
102
-	if ( ! $purchase_data['price'] ) {
102
+	if ( ! $purchase_data['price']) {
103 103
 		// Revert to manual
104 104
 		$purchase_data['gateway'] = 'manual';
105 105
 		$_POST['give-gateway']    = 'manual';
106 106
 	}
107 107
 
108 108
 	// Allow the purchase data to be modified before it is sent to the gateway
109
-	$purchase_data = apply_filters( 'give_purchase_data_before_gateway', $purchase_data, $valid_data );
109
+	$purchase_data = apply_filters('give_purchase_data_before_gateway', $purchase_data, $valid_data);
110 110
 
111 111
 	// Setup the data we're storing in the purchase session
112 112
 	$session_data = $purchase_data;
113 113
 
114 114
 	// Make sure credit card numbers are never stored in sessions
115
-	unset( $session_data['card_info']['card_number'] );
116
-	unset( $session_data['post_data']['card_number'] );
115
+	unset($session_data['card_info']['card_number']);
116
+	unset($session_data['post_data']['card_number']);
117 117
 
118 118
 	// Used for showing data to non logged-in users after purchase, and for other plugins needing purchase data.
119
-	give_set_purchase_session( $session_data );
119
+	give_set_purchase_session($session_data);
120 120
 
121 121
 	// Send info to the gateway for payment processing
122
-	give_send_to_gateway( $purchase_data['gateway'], $purchase_data );
122
+	give_send_to_gateway($purchase_data['gateway'], $purchase_data);
123 123
 	give_die();
124 124
 
125 125
 }
126 126
 
127
-add_action( 'give_purchase', 'give_process_purchase_form' );
128
-add_action( 'wp_ajax_give_process_checkout', 'give_process_purchase_form' );
129
-add_action( 'wp_ajax_nopriv_give_process_checkout', 'give_process_purchase_form' );
127
+add_action('give_purchase', 'give_process_purchase_form');
128
+add_action('wp_ajax_give_process_checkout', 'give_process_purchase_form');
129
+add_action('wp_ajax_nopriv_give_process_checkout', 'give_process_purchase_form');
130 130
 
131 131
 /**
132 132
  * Process the checkout login form
@@ -137,32 +137,32 @@  discard block
 block discarded – undo
137 137
  */
138 138
 function give_process_form_login() {
139 139
 
140
-	$is_ajax = isset( $_POST['give_ajax'] );
140
+	$is_ajax = isset($_POST['give_ajax']);
141 141
 
142 142
 	$user_data = give_purchase_form_validate_user_login();
143 143
 
144
-	if ( give_get_errors() || $user_data['user_id'] < 1 ) {
145
-		if ( $is_ajax ) {
146
-			do_action( 'give_ajax_checkout_errors' );
144
+	if (give_get_errors() || $user_data['user_id'] < 1) {
145
+		if ($is_ajax) {
146
+			do_action('give_ajax_checkout_errors');
147 147
 			give_die();
148 148
 		} else {
149
-			wp_redirect( $_SERVER['HTTP_REFERER'] );
149
+			wp_redirect($_SERVER['HTTP_REFERER']);
150 150
 			exit;
151 151
 		}
152 152
 	}
153 153
 
154
-	give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] );
154
+	give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']);
155 155
 
156
-	if ( $is_ajax ) {
156
+	if ($is_ajax) {
157 157
 		echo 'success';
158 158
 		give_die();
159 159
 	} else {
160
-		wp_redirect( $_SERVER['HTTP_REFERER'] );
160
+		wp_redirect($_SERVER['HTTP_REFERER']);
161 161
 	}
162 162
 }
163 163
 
164
-add_action( 'wp_ajax_give_process_checkout_login', 'give_process_form_login' );
165
-add_action( 'wp_ajax_nopriv_give_process_checkout_login', 'give_process_form_login' );
164
+add_action('wp_ajax_give_process_checkout_login', 'give_process_form_login');
165
+add_action('wp_ajax_nopriv_give_process_checkout_login', 'give_process_form_login');
166 166
 
167 167
 /**
168 168
  * Purchase Form Validate Fields
@@ -174,40 +174,40 @@  discard block
 block discarded – undo
174 174
 function give_purchase_form_validate_fields() {
175 175
 
176 176
 	// Check if there is $_POST
177
-	if ( empty( $_POST ) ) {
177
+	if (empty($_POST)) {
178 178
 		return false;
179 179
 	}
180 180
 
181
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
181
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
182 182
 
183 183
 	// Start an array to collect valid data
184 184
 	$valid_data = array(
185 185
 		'gateway'          => give_purchase_form_validate_gateway(), // Gateway fallback (amount is validated here)
186
-		'need_new_user'    => false,     // New user flag
187
-		'need_user_login'  => false,     // Login user flag
188
-		'logged_user_data' => array(),   // Logged user collected data
189
-		'new_user_data'    => array(),   // New user collected data
190
-		'login_user_data'  => array(),   // Login user collected data
191
-		'guest_user_data'  => array(),   // Guest user collected data
186
+		'need_new_user'    => false, // New user flag
187
+		'need_user_login'  => false, // Login user flag
188
+		'logged_user_data' => array(), // Logged user collected data
189
+		'new_user_data'    => array(), // New user collected data
190
+		'login_user_data'  => array(), // Login user collected data
191
+		'guest_user_data'  => array(), // Guest user collected data
192 192
 		'cc_info'          => give_purchase_form_validate_cc()    // Credit card info
193 193
 	);
194 194
 
195 195
 	// Validate agree to terms
196
-	$terms_option = get_post_meta( $form_id, '_give_terms_option', true );
197
-	if ( isset( $terms_option ) && $terms_option === 'yes' ) {
196
+	$terms_option = get_post_meta($form_id, '_give_terms_option', true);
197
+	if (isset($terms_option) && $terms_option === 'yes') {
198 198
 		give_purchase_form_validate_agree_to_terms();
199 199
 	}
200 200
 
201
-	if ( is_user_logged_in() ) {
201
+	if (is_user_logged_in()) {
202 202
 		// Collect logged in user data
203 203
 		$valid_data['logged_in_user'] = give_purchase_form_validate_logged_in_user();
204
-	} else if ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) {
204
+	} else if (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') {
205 205
 		// Set new user registration as required
206 206
 		$valid_data['need_new_user'] = true;
207 207
 		// Validate new user data
208 208
 		$valid_data['new_user_data'] = give_purchase_form_validate_new_user();
209 209
 		// Check if login validation is needed
210
-	} else if ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) {
210
+	} else if (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') {
211 211
 		// Set user login as required
212 212
 		$valid_data['need_user_login'] = true;
213 213
 		// Validate users login info
@@ -232,37 +232,37 @@  discard block
 block discarded – undo
232 232
  */
233 233
 function give_purchase_form_validate_gateway() {
234 234
 
235
-	$form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
236
-	$amount  = isset( $_REQUEST['give-amount'] ) ? give_format_amount( give_get_form_minimum_price( $_REQUEST['give-amount'] ) ) : 0;
237
-	$gateway = give_get_default_gateway( $form_id );
235
+	$form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
236
+	$amount  = isset($_REQUEST['give-amount']) ? give_format_amount(give_get_form_minimum_price($_REQUEST['give-amount'])) : 0;
237
+	$gateway = give_get_default_gateway($form_id);
238 238
 
239 239
 	// Check if a gateway value is present
240
-	if ( ! empty( $_REQUEST['give-gateway'] ) ) {
240
+	if ( ! empty($_REQUEST['give-gateway'])) {
241 241
 
242
-		$gateway = sanitize_text_field( $_REQUEST['give-gateway'] );
242
+		$gateway = sanitize_text_field($_REQUEST['give-gateway']);
243 243
 
244 244
 		//Is amount being donated in LIVE mode 0.00? If so, error:
245
-		if ( $amount == 0 && ! give_is_test_mode() ) {
245
+		if ($amount == 0 && ! give_is_test_mode()) {
246 246
 
247
-			give_set_error( 'invalid_donation_amount', __( 'Please insert a valid donation amount.', 'give' ) );
247
+			give_set_error('invalid_donation_amount', __('Please insert a valid donation amount.', 'give'));
248 248
 
249 249
 		} //Check for a minimum custom amount
250
-		elseif ( ! give_verify_minimum_price() ) {
250
+		elseif ( ! give_verify_minimum_price()) {
251 251
 
252
-			$minimum       = give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ) ) );
253
-			$error_message = __( 'This form has a minimum donation amount of %s', 'give' );
252
+			$minimum       = give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id)));
253
+			$error_message = __('This form has a minimum donation amount of %s', 'give');
254 254
 
255
-			give_set_error( 'invalid_donation_minimum', sprintf( $error_message, $minimum ) );
255
+			give_set_error('invalid_donation_minimum', sprintf($error_message, $minimum));
256 256
 
257 257
 		} //Is this test mode zero donation? Let it through but set to manual gateway
258
-		elseif ( $amount == 0 && give_is_test_mode() ) {
258
+		elseif ($amount == 0 && give_is_test_mode()) {
259 259
 
260 260
 			$gateway = 'manual';
261 261
 
262 262
 		} //Check if this gateway is active
263
-		elseif ( ! give_is_gateway_active( $gateway ) ) {
263
+		elseif ( ! give_is_gateway_active($gateway)) {
264 264
 
265
-			give_set_error( 'invalid_gateway', __( 'The selected payment gateway is not enabled', 'give' ) );
265
+			give_set_error('invalid_gateway', __('The selected payment gateway is not enabled', 'give'));
266 266
 
267 267
 		}
268 268
 
@@ -281,23 +281,23 @@  discard block
 block discarded – undo
281 281
  */
282 282
 function give_verify_minimum_price() {
283 283
 
284
-	$amount          = give_sanitize_amount( $_REQUEST['give-amount'] );
285
-	$form_id         = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
286
-	$price_id        = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : 0;
287
-	$variable_prices = give_has_variable_prices( $form_id );
284
+	$amount          = give_sanitize_amount($_REQUEST['give-amount']);
285
+	$form_id         = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
286
+	$price_id        = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : 0;
287
+	$variable_prices = give_has_variable_prices($form_id);
288 288
 
289
-	if ( $variable_prices && ! empty( $price_id ) ) {
289
+	if ($variable_prices && ! empty($price_id)) {
290 290
 
291
-		$price_level_amount = give_get_price_option_amount( $form_id, $price_id );
291
+		$price_level_amount = give_get_price_option_amount($form_id, $price_id);
292 292
 
293
-		if ( $price_level_amount == $amount ) {
293
+		if ($price_level_amount == $amount) {
294 294
 			return true;
295 295
 		}
296 296
 	}
297 297
 
298
-	$minimum = give_get_form_minimum_price( $form_id );
298
+	$minimum = give_get_form_minimum_price($form_id);
299 299
 
300
-	if ( $minimum > $amount ) {
300
+	if ($minimum > $amount) {
301 301
 		return false;
302 302
 	}
303 303
 
@@ -313,9 +313,9 @@  discard block
 block discarded – undo
313 313
  */
314 314
 function give_purchase_form_validate_agree_to_terms() {
315 315
 	// Validate agree to terms
316
-	if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) {
316
+	if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) {
317 317
 		// User did not agree
318
-		give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', __( 'You must agree to the terms of use', 'give' ) ) );
318
+		give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', __('You must agree to the terms of use', 'give')));
319 319
 	}
320 320
 }
321 321
 
@@ -329,47 +329,47 @@  discard block
 block discarded – undo
329 329
  *
330 330
  * @return      array
331 331
  */
332
-function give_purchase_form_required_fields( $form_id ) {
332
+function give_purchase_form_required_fields($form_id) {
333 333
 
334
-	$payment_mode = give_get_chosen_gateway( $form_id );
334
+	$payment_mode = give_get_chosen_gateway($form_id);
335 335
 
336 336
 	$required_fields = array(
337 337
 		'give_email' => array(
338 338
 			'error_id'      => 'invalid_email',
339
-			'error_message' => __( 'Please enter a valid email address', 'give' )
339
+			'error_message' => __('Please enter a valid email address', 'give')
340 340
 		),
341 341
 		'give_first' => array(
342 342
 			'error_id'      => 'invalid_first_name',
343
-			'error_message' => __( 'Please enter your first name', 'give' )
343
+			'error_message' => __('Please enter your first name', 'give')
344 344
 		)
345 345
 	);
346 346
 
347
-	$require_address = give_require_billing_address( $payment_mode );
347
+	$require_address = give_require_billing_address($payment_mode);
348 348
 
349
-	if ( $require_address ) {
350
-		$required_fields['card_address']    = array(
349
+	if ($require_address) {
350
+		$required_fields['card_address'] = array(
351 351
 			'error_id'      => 'invalid_card_address',
352
-			'error_message' => __( 'Please enter your primary billing address', 'give' )
352
+			'error_message' => __('Please enter your primary billing address', 'give')
353 353
 		);
354
-		$required_fields['card_zip']        = array(
354
+		$required_fields['card_zip'] = array(
355 355
 			'error_id'      => 'invalid_zip_code',
356
-			'error_message' => __( 'Please enter your zip / postal code', 'give' )
356
+			'error_message' => __('Please enter your zip / postal code', 'give')
357 357
 		);
358
-		$required_fields['card_city']       = array(
358
+		$required_fields['card_city'] = array(
359 359
 			'error_id'      => 'invalid_city',
360
-			'error_message' => __( 'Please enter your billing city', 'give' )
360
+			'error_message' => __('Please enter your billing city', 'give')
361 361
 		);
362 362
 		$required_fields['billing_country'] = array(
363 363
 			'error_id'      => 'invalid_country',
364
-			'error_message' => __( 'Please select your billing country', 'give' )
364
+			'error_message' => __('Please select your billing country', 'give')
365 365
 		);
366
-		$required_fields['card_state']      = array(
366
+		$required_fields['card_state'] = array(
367 367
 			'error_id'      => 'invalid_state',
368
-			'error_message' => __( 'Please enter billing state / province', 'give' )
368
+			'error_message' => __('Please enter billing state / province', 'give')
369 369
 		);
370 370
 	}
371 371
 
372
-	return apply_filters( 'give_purchase_form_required_fields', $required_fields, $form_id );
372
+	return apply_filters('give_purchase_form_required_fields', $required_fields, $form_id);
373 373
 
374 374
 }
375 375
 
@@ -382,16 +382,16 @@  discard block
 block discarded – undo
382 382
  *
383 383
  * @return mixed|void
384 384
  */
385
-function give_require_billing_address( $payment_mode ) {
385
+function give_require_billing_address($payment_mode) {
386 386
 
387 387
 	$return = false;
388 388
 
389
-	if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) {
389
+	if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) {
390 390
 		$return = true;
391 391
 	}
392 392
 
393 393
 	// Let payment gateways and other extensions determine if address fields should be required
394
-	return apply_filters( 'give_require_billing_address', $return );
394
+	return apply_filters('give_require_billing_address', $return);
395 395
 
396 396
 }
397 397
 
@@ -405,43 +405,43 @@  discard block
 block discarded – undo
405 405
 function give_purchase_form_validate_logged_in_user() {
406 406
 	global $user_ID;
407 407
 
408
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
408
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
409 409
 
410 410
 	// Start empty array to collect valid user data
411 411
 	$valid_user_data = array(
412 412
 		// Assume there will be errors
413
-		'user_id' => - 1
413
+		'user_id' => -1
414 414
 	);
415 415
 
416 416
 	// Verify there is a user_ID
417
-	if ( $user_ID > 0 ) {
417
+	if ($user_ID > 0) {
418 418
 		// Get the logged in user data
419
-		$user_data = get_userdata( $user_ID );
419
+		$user_data = get_userdata($user_ID);
420 420
 
421 421
 		// Loop through required fields and show error messages
422
-		foreach ( give_purchase_form_required_fields( $form_id ) as $field_name => $value ) {
423
-			if ( in_array( $value, give_purchase_form_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
424
-				give_set_error( $value['error_id'], $value['error_message'] );
422
+		foreach (give_purchase_form_required_fields($form_id) as $field_name => $value) {
423
+			if (in_array($value, give_purchase_form_required_fields($form_id)) && empty($_POST[$field_name])) {
424
+				give_set_error($value['error_id'], $value['error_message']);
425 425
 			}
426 426
 		}
427 427
 
428 428
 		// Verify data
429
-		if ( $user_data ) {
429
+		if ($user_data) {
430 430
 			// Collected logged in user data
431 431
 			$valid_user_data = array(
432 432
 				'user_id'    => $user_ID,
433
-				'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email,
434
-				'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name,
435
-				'user_last'  => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name,
433
+				'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email,
434
+				'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name,
435
+				'user_last'  => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name,
436 436
 			);
437 437
 
438
-			if ( ! is_email( $valid_user_data['user_email'] ) ) {
439
-				give_set_error( 'email_invalid', __( 'Invalid email', 'give' ) );
438
+			if ( ! is_email($valid_user_data['user_email'])) {
439
+				give_set_error('email_invalid', __('Invalid email', 'give'));
440 440
 			}
441 441
 
442 442
 		} else {
443 443
 			// Set invalid user error
444
-			give_set_error( 'invalid_user', __( 'The user information is invalid', 'give' ) );
444
+			give_set_error('invalid_user', __('The user information is invalid', 'give'));
445 445
 		}
446 446
 	}
447 447
 
@@ -459,90 +459,90 @@  discard block
 block discarded – undo
459 459
 function give_purchase_form_validate_new_user() {
460 460
 
461 461
 	$registering_new_user = false;
462
-	$form_id              = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
462
+	$form_id              = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
463 463
 
464 464
 	// Start an empty array to collect valid user data
465 465
 	$valid_user_data = array(
466 466
 		// Assume there will be errors
467
-		'user_id'    => - 1,
467
+		'user_id'    => -1,
468 468
 		// Get first name
469
-		'user_first' => isset( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : '',
469
+		'user_first' => isset($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : '',
470 470
 		// Get last name
471
-		'user_last'  => isset( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : '',
471
+		'user_last'  => isset($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : '',
472 472
 	);
473 473
 
474 474
 	// Check the new user's credentials against existing ones
475
-	$user_login   = isset( $_POST['give_user_login'] ) ? trim( $_POST['give_user_login'] ) : false;
476
-	$user_email   = isset( $_POST['give_email'] ) ? trim( $_POST['give_email'] ) : false;
477
-	$user_pass    = isset( $_POST['give_user_pass'] ) ? trim( $_POST['give_user_pass'] ) : false;
478
-	$pass_confirm = isset( $_POST['give_user_pass_confirm'] ) ? trim( $_POST['give_user_pass_confirm'] ) : false;
475
+	$user_login   = isset($_POST['give_user_login']) ? trim($_POST['give_user_login']) : false;
476
+	$user_email   = isset($_POST['give_email']) ? trim($_POST['give_email']) : false;
477
+	$user_pass    = isset($_POST['give_user_pass']) ? trim($_POST['give_user_pass']) : false;
478
+	$pass_confirm = isset($_POST['give_user_pass_confirm']) ? trim($_POST['give_user_pass_confirm']) : false;
479 479
 
480 480
 	// Loop through required fields and show error messages
481
-	foreach ( give_purchase_form_required_fields( $form_id ) as $field_name => $value ) {
482
-		if ( in_array( $value, give_purchase_form_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
483
-			give_set_error( $value['error_id'], $value['error_message'] );
481
+	foreach (give_purchase_form_required_fields($form_id) as $field_name => $value) {
482
+		if (in_array($value, give_purchase_form_required_fields($form_id)) && empty($_POST[$field_name])) {
483
+			give_set_error($value['error_id'], $value['error_message']);
484 484
 		}
485 485
 	}
486 486
 
487 487
 	// Check if we have an username to register
488
-	if ( $user_login && strlen( $user_login ) > 0 ) {
488
+	if ($user_login && strlen($user_login) > 0) {
489 489
 		$registering_new_user = true;
490 490
 
491 491
 		// We have an user name, check if it already exists
492
-		if ( username_exists( $user_login ) ) {
492
+		if (username_exists($user_login)) {
493 493
 			// Username already registered
494
-			give_set_error( 'username_unavailable', __( 'Username already taken', 'give' ) );
494
+			give_set_error('username_unavailable', __('Username already taken', 'give'));
495 495
 			// Check if it's valid
496
-		} else if ( ! give_validate_username( $user_login ) ) {
496
+		} else if ( ! give_validate_username($user_login)) {
497 497
 			// Invalid username
498
-			if ( is_multisite() ) {
499
-				give_set_error( 'username_invalid', __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed', 'give' ) );
498
+			if (is_multisite()) {
499
+				give_set_error('username_invalid', __('Invalid username. Only lowercase letters (a-z) and numbers are allowed', 'give'));
500 500
 			} else {
501
-				give_set_error( 'username_invalid', __( 'Invalid username', 'give' ) );
501
+				give_set_error('username_invalid', __('Invalid username', 'give'));
502 502
 			}
503 503
 		} else {
504 504
 			// All the checks have run and it's good to go
505 505
 			$valid_user_data['user_login'] = $user_login;
506 506
 		}
507
-	} elseif ( give_logged_in_only( $form_id ) ) {
508
-		give_set_error( 'registration_required', esc_html__( 'You must register or login to complete your donation', 'give' ) );
507
+	} elseif (give_logged_in_only($form_id)) {
508
+		give_set_error('registration_required', esc_html__('You must register or login to complete your donation', 'give'));
509 509
 	}
510 510
 
511 511
 	// Check if we have an email to verify
512
-	if ( $user_email && strlen( $user_email ) > 0 ) {
512
+	if ($user_email && strlen($user_email) > 0) {
513 513
 		// Validate email
514
-		if ( ! is_email( $user_email ) ) {
515
-			give_set_error( 'email_invalid', __( 'Sorry, that email is invalid', 'give' ) );
514
+		if ( ! is_email($user_email)) {
515
+			give_set_error('email_invalid', __('Sorry, that email is invalid', 'give'));
516 516
 			// Check if email exists
517
-		} else if ( email_exists( $user_email ) && $registering_new_user ) {
518
-			give_set_error( 'email_used', __( 'Sorry, that email already active for another user', 'give' ) );
517
+		} else if (email_exists($user_email) && $registering_new_user) {
518
+			give_set_error('email_used', __('Sorry, that email already active for another user', 'give'));
519 519
 		} else {
520 520
 			// All the checks have run and it's good to go
521 521
 			$valid_user_data['user_email'] = $user_email;
522 522
 		}
523 523
 	} else {
524 524
 		// No email
525
-		give_set_error( 'email_empty', __( 'Enter an email', 'give' ) );
525
+		give_set_error('email_empty', __('Enter an email', 'give'));
526 526
 	}
527 527
 
528 528
 	// Check password
529
-	if ( $user_pass && $pass_confirm ) {
529
+	if ($user_pass && $pass_confirm) {
530 530
 		// Verify confirmation matches
531
-		if ( $user_pass != $pass_confirm ) {
531
+		if ($user_pass != $pass_confirm) {
532 532
 			// Passwords do not match
533
-			give_set_error( 'password_mismatch', __( 'Passwords don\'t match', 'give' ) );
533
+			give_set_error('password_mismatch', __('Passwords don\'t match', 'give'));
534 534
 		} else {
535 535
 			// All is good to go
536 536
 			$valid_user_data['user_pass'] = $user_pass;
537 537
 		}
538 538
 	} else {
539 539
 		// Password or confirmation missing
540
-		if ( ! $user_pass && $registering_new_user ) {
540
+		if ( ! $user_pass && $registering_new_user) {
541 541
 			// The password is invalid
542
-			give_set_error( 'password_empty', __( 'Enter a password', 'give' ) );
543
-		} else if ( ! $pass_confirm && $registering_new_user ) {
542
+			give_set_error('password_empty', __('Enter a password', 'give'));
543
+		} else if ( ! $pass_confirm && $registering_new_user) {
544 544
 			// Confirmation password is invalid
545
-			give_set_error( 'confirmation_empty', __( 'Enter the password confirmation', 'give' ) );
545
+			give_set_error('confirmation_empty', __('Enter the password confirmation', 'give'));
546 546
 		}
547 547
 	}
548 548
 
@@ -561,34 +561,34 @@  discard block
 block discarded – undo
561 561
 	// Start an array to collect valid user data
562 562
 	$valid_user_data = array(
563 563
 		// Assume there will be errors
564
-		'user_id' => - 1
564
+		'user_id' => -1
565 565
 	);
566 566
 
567 567
 	// Username
568
-	if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) {
569
-		give_set_error( 'must_log_in', __( 'You must login or register to complete your donation', 'give' ) );
568
+	if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') {
569
+		give_set_error('must_log_in', __('You must login or register to complete your donation', 'give'));
570 570
 
571 571
 		return $valid_user_data;
572 572
 	}
573 573
 
574 574
 	// Get the user by login
575
-	$user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) );
575
+	$user_data = get_user_by('login', strip_tags($_POST['give_user_login']));
576 576
 
577 577
 	// Check if user exists
578
-	if ( $user_data ) {
578
+	if ($user_data) {
579 579
 		// Get password
580
-		$user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false;
580
+		$user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false;
581 581
 
582 582
 		// Check user_pass
583
-		if ( $user_pass ) {
583
+		if ($user_pass) {
584 584
 			// Check if password is valid
585
-			if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) {
585
+			if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) {
586 586
 				// Incorrect password
587 587
 				give_set_error(
588 588
 					'password_incorrect',
589 589
 					sprintf(
590
-						__( 'The password you entered is incorrect. %sReset Password%s', 'give' ),
591
-						'<a href="' . wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ) . '" title="' . __( 'Lost Password', 'give' ) . '">',
590
+						__('The password you entered is incorrect. %sReset Password%s', 'give'),
591
+						'<a href="'.wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]").'" title="'.__('Lost Password', 'give').'">',
592 592
 						'</a>'
593 593
 					)
594 594
 				);
@@ -606,11 +606,11 @@  discard block
 block discarded – undo
606 606
 			}
607 607
 		} else {
608 608
 			// Empty password
609
-			give_set_error( 'password_empty', __( 'Enter a password', 'give' ) );
609
+			give_set_error('password_empty', __('Enter a password', 'give'));
610 610
 		}
611 611
 	} else {
612 612
 		// no username
613
-		give_set_error( 'username_incorrect', __( 'The username you entered does not exist', 'give' ) );
613
+		give_set_error('username_incorrect', __('The username you entered does not exist', 'give'));
614 614
 	}
615 615
 
616 616
 	return $valid_user_data;
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
  */
626 626
 function give_purchase_form_validate_guest_user() {
627 627
 
628
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
628
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
629 629
 
630 630
 	// Start an array to collect valid user data
631 631
 	$valid_user_data = array(
@@ -634,32 +634,32 @@  discard block
 block discarded – undo
634 634
 	);
635 635
 
636 636
 	// Show error message if user must be logged in
637
-	if ( give_logged_in_only( $form_id ) ) {
638
-		give_set_error( 'logged_in_only', __( 'You must be logged into to donate', 'give' ) );
637
+	if (give_logged_in_only($form_id)) {
638
+		give_set_error('logged_in_only', __('You must be logged into to donate', 'give'));
639 639
 	}
640 640
 
641 641
 	// Get the guest email
642
-	$guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false;
642
+	$guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false;
643 643
 
644 644
 	// Check email
645
-	if ( $guest_email && strlen( $guest_email ) > 0 ) {
645
+	if ($guest_email && strlen($guest_email) > 0) {
646 646
 		// Validate email
647
-		if ( ! is_email( $guest_email ) ) {
647
+		if ( ! is_email($guest_email)) {
648 648
 			// Invalid email
649
-			give_set_error( 'email_invalid', __( 'Invalid email', 'give' ) );
649
+			give_set_error('email_invalid', __('Invalid email', 'give'));
650 650
 		} else {
651 651
 			// All is good to go
652 652
 			$valid_user_data['user_email'] = $guest_email;
653 653
 		}
654 654
 	} else {
655 655
 		// No email
656
-		give_set_error( 'email_empty', __( 'Enter an email', 'give' ) );
656
+		give_set_error('email_empty', __('Enter an email', 'give'));
657 657
 	}
658 658
 
659 659
 	// Loop through required fields and show error messages
660
-	foreach ( give_purchase_form_required_fields( $form_id ) as $field_name => $value ) {
661
-		if ( in_array( $value, give_purchase_form_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
662
-			give_set_error( $value['error_id'], $value['error_message'] );
660
+	foreach (give_purchase_form_required_fields($form_id) as $field_name => $value) {
661
+		if (in_array($value, give_purchase_form_required_fields($form_id)) && empty($_POST[$field_name])) {
662
+			give_set_error($value['error_id'], $value['error_message']);
663 663
 		}
664 664
 	}
665 665
 
@@ -675,42 +675,42 @@  discard block
 block discarded – undo
675 675
  * @since   1.0
676 676
  * @return  integer
677 677
  */
678
-function give_register_and_login_new_user( $user_data = array() ) {
678
+function give_register_and_login_new_user($user_data = array()) {
679 679
 	// Verify the array
680
-	if ( empty( $user_data ) ) {
681
-		return - 1;
680
+	if (empty($user_data)) {
681
+		return -1;
682 682
 	}
683 683
 
684
-	if ( give_get_errors() ) {
685
-		return - 1;
684
+	if (give_get_errors()) {
685
+		return -1;
686 686
 	}
687 687
 
688
-	$user_args = apply_filters( 'give_insert_user_args', array(
689
-		'user_login'      => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '',
690
-		'user_pass'       => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '',
691
-		'user_email'      => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '',
692
-		'first_name'      => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '',
693
-		'last_name'       => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '',
694
-		'user_registered' => date( 'Y-m-d H:i:s' ),
695
-		'role'            => get_option( 'default_role' )
696
-	), $user_data );
688
+	$user_args = apply_filters('give_insert_user_args', array(
689
+		'user_login'      => isset($user_data['user_login']) ? $user_data['user_login'] : '',
690
+		'user_pass'       => isset($user_data['user_pass']) ? $user_data['user_pass'] : '',
691
+		'user_email'      => isset($user_data['user_email']) ? $user_data['user_email'] : '',
692
+		'first_name'      => isset($user_data['user_first']) ? $user_data['user_first'] : '',
693
+		'last_name'       => isset($user_data['user_last']) ? $user_data['user_last'] : '',
694
+		'user_registered' => date('Y-m-d H:i:s'),
695
+		'role'            => get_option('default_role')
696
+	), $user_data);
697 697
 
698 698
 	// Insert new user
699
-	$user_id = wp_insert_user( $user_args );
699
+	$user_id = wp_insert_user($user_args);
700 700
 
701 701
 	// Validate inserted user
702
-	if ( is_wp_error( $user_id ) ) {
703
-		return - 1;
702
+	if (is_wp_error($user_id)) {
703
+		return -1;
704 704
 	}
705 705
 
706 706
 	// Allow themes and plugins to filter the user data
707
-	$user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args );
707
+	$user_data = apply_filters('give_insert_user_data', $user_data, $user_args);
708 708
 
709 709
 	// Allow themes and plugins to hook
710
-	do_action( 'give_insert_user', $user_id, $user_data );
710
+	do_action('give_insert_user', $user_id, $user_data);
711 711
 
712 712
 	// Login new user
713
-	give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] );
713
+	give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']);
714 714
 
715 715
 	// Return user id
716 716
 	return $user_id;
@@ -725,27 +725,27 @@  discard block
 block discarded – undo
725 725
  * @since   1.0
726 726
  * @return  array
727 727
  */
728
-function give_get_purchase_form_user( $valid_data = array() ) {
728
+function give_get_purchase_form_user($valid_data = array()) {
729 729
 
730 730
 	// Initialize user
731 731
 	$user    = false;
732
-	$is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
732
+	$is_ajax = defined('DOING_AJAX') && DOING_AJAX;
733 733
 
734
-	if ( $is_ajax ) {
734
+	if ($is_ajax) {
735 735
 		// Do not create or login the user during the ajax submission (check for errors only)
736 736
 		return true;
737
-	} else if ( is_user_logged_in() ) {
737
+	} else if (is_user_logged_in()) {
738 738
 		// Set the valid user as the logged in collected data
739 739
 		$user = $valid_data['logged_in_user'];
740
-	} else if ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) {
740
+	} else if ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) {
741 741
 		// New user registration
742
-		if ( $valid_data['need_new_user'] === true ) {
742
+		if ($valid_data['need_new_user'] === true) {
743 743
 			// Set user
744 744
 			$user = $valid_data['new_user_data'];
745 745
 			// Register and login new user
746
-			$user['user_id'] = give_register_and_login_new_user( $user );
746
+			$user['user_id'] = give_register_and_login_new_user($user);
747 747
 			// User login
748
-		} else if ( $valid_data['need_user_login'] === true && ! $is_ajax ) {
748
+		} else if ($valid_data['need_user_login'] === true && ! $is_ajax) {
749 749
 
750 750
 			/*
751 751
 			 * The login form is now processed in the give_process_purchase_login() function.
@@ -760,48 +760,48 @@  discard block
 block discarded – undo
760 760
 			// Set user
761 761
 			$user = $valid_data['login_user_data'];
762 762
 			// Login user
763
-			give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] );
763
+			give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']);
764 764
 		}
765 765
 	}
766 766
 
767 767
 	// Check guest checkout
768
-	if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) {
768
+	if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) {
769 769
 		// Set user
770 770
 		$user = $valid_data['guest_user_data'];
771 771
 	}
772 772
 
773 773
 	// Verify we have an user
774
-	if ( false === $user || empty( $user ) ) {
774
+	if (false === $user || empty($user)) {
775 775
 		// Return false
776 776
 		return false;
777 777
 	}
778 778
 
779 779
 	// Get user first name
780
-	if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) {
781
-		$user['user_first'] = isset( $_POST["give_first"] ) ? strip_tags( trim( $_POST["give_first"] ) ) : '';
780
+	if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) {
781
+		$user['user_first'] = isset($_POST["give_first"]) ? strip_tags(trim($_POST["give_first"])) : '';
782 782
 	}
783 783
 
784 784
 	// Get user last name
785
-	if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) {
786
-		$user['user_last'] = isset( $_POST["give_last"] ) ? strip_tags( trim( $_POST["give_last"] ) ) : '';
785
+	if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) {
786
+		$user['user_last'] = isset($_POST["give_last"]) ? strip_tags(trim($_POST["give_last"])) : '';
787 787
 	}
788 788
 
789 789
 	// Get the user's billing address details
790 790
 	$user['address']            = array();
791
-	$user['address']['line1']   = ! empty( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : false;
792
-	$user['address']['line2']   = ! empty( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : false;
793
-	$user['address']['city']    = ! empty( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : false;
794
-	$user['address']['state']   = ! empty( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : false;
795
-	$user['address']['country'] = ! empty( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : false;
796
-	$user['address']['zip']     = ! empty( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : false;
797
-
798
-	if ( empty( $user['address']['country'] ) ) {
791
+	$user['address']['line1']   = ! empty($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : false;
792
+	$user['address']['line2']   = ! empty($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : false;
793
+	$user['address']['city']    = ! empty($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : false;
794
+	$user['address']['state']   = ! empty($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : false;
795
+	$user['address']['country'] = ! empty($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : false;
796
+	$user['address']['zip']     = ! empty($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : false;
797
+
798
+	if (empty($user['address']['country'])) {
799 799
 		$user['address'] = false;
800 800
 	} // Country will always be set if address fields are present
801 801
 
802
-	if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) {
802
+	if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) {
803 803
 		// Store the address in the user's meta so the donation form can be pre-populated with it on return purchases
804
-		update_user_meta( $user['user_id'], '_give_user_address', $user['address'] );
804
+		update_user_meta($user['user_id'], '_give_user_address', $user['address']);
805 805
 	}
806 806
 
807 807
 	// Return valid user
@@ -820,16 +820,16 @@  discard block
 block discarded – undo
820 820
 	$card_data = give_get_purchase_cc_info();
821 821
 
822 822
 	// Validate the card zip
823
-	if ( ! empty( $card_data['card_zip'] ) ) {
824
-		if ( ! give_purchase_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) {
825
-			give_set_error( 'invalid_cc_zip', __( 'The zip / postal code you entered for your billing address is invalid', 'give' ) );
823
+	if ( ! empty($card_data['card_zip'])) {
824
+		if ( ! give_purchase_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) {
825
+			give_set_error('invalid_cc_zip', __('The zip / postal code you entered for your billing address is invalid', 'give'));
826 826
 		}
827 827
 	}
828 828
 
829 829
 	//Ensure no spaces
830
-	if ( ! empty( $card_data['card_number'] ) ) {
831
-		$card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); //no "+" signs
832
-		$card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces
830
+	if ( ! empty($card_data['card_number'])) {
831
+		$card_data['card_number'] = str_replace('+', '', $card_data['card_number']); //no "+" signs
832
+		$card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces
833 833
 	}
834 834
 
835 835
 	// This should validate card numbers at some point too
@@ -845,17 +845,17 @@  discard block
 block discarded – undo
845 845
  */
846 846
 function give_get_purchase_cc_info() {
847 847
 	$cc_info                   = array();
848
-	$cc_info['card_name']      = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : '';
849
-	$cc_info['card_number']    = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : '';
850
-	$cc_info['card_cvc']       = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : '';
851
-	$cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : '';
852
-	$cc_info['card_exp_year']  = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : '';
853
-	$cc_info['card_address']   = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : '';
854
-	$cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : '';
855
-	$cc_info['card_city']      = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : '';
856
-	$cc_info['card_state']     = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : '';
857
-	$cc_info['card_country']   = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : '';
858
-	$cc_info['card_zip']       = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : '';
848
+	$cc_info['card_name']      = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : '';
849
+	$cc_info['card_number']    = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : '';
850
+	$cc_info['card_cvc']       = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : '';
851
+	$cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : '';
852
+	$cc_info['card_exp_year']  = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : '';
853
+	$cc_info['card_address']   = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : '';
854
+	$cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : '';
855
+	$cc_info['card_city']      = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : '';
856
+	$cc_info['card_state']     = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : '';
857
+	$cc_info['card_country']   = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : '';
858
+	$cc_info['card_zip']       = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : '';
859 859
 
860 860
 	// Return cc info
861 861
 	return $cc_info;
@@ -871,14 +871,14 @@  discard block
 block discarded – undo
871 871
  *
872 872
  * @return bool|mixed|void
873 873
  */
874
-function give_purchase_form_validate_cc_zip( $zip = 0, $country_code = '' ) {
874
+function give_purchase_form_validate_cc_zip($zip = 0, $country_code = '') {
875 875
 	$ret = false;
876 876
 
877
-	if ( empty( $zip ) || empty( $country_code ) ) {
877
+	if (empty($zip) || empty($country_code)) {
878 878
 		return $ret;
879 879
 	}
880 880
 
881
-	$country_code = strtoupper( $country_code );
881
+	$country_code = strtoupper($country_code);
882 882
 
883 883
 	$zip_regex = array(
884 884
 		"AD" => "AD\d{3}",
@@ -1038,11 +1038,11 @@  discard block
 block discarded – undo
1038 1038
 		"ZM" => "\d{5}"
1039 1039
 	);
1040 1040
 
1041
-	if ( ! isset ( $zip_regex[ $country_code ] ) || preg_match( "/" . $zip_regex[ $country_code ] . "/i", $zip ) ) {
1041
+	if ( ! isset ($zip_regex[$country_code]) || preg_match("/".$zip_regex[$country_code]."/i", $zip)) {
1042 1042
 		$ret = true;
1043 1043
 	}
1044 1044
 
1045
-	return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code );
1045
+	return apply_filters('give_is_zip_valid', $ret, $zip, $country_code);
1046 1046
 }
1047 1047
 
1048 1048
 
@@ -1052,48 +1052,48 @@  discard block
 block discarded – undo
1052 1052
  * @since       1.0
1053 1053
  * @return      void
1054 1054
  */
1055
-function give_check_purchase_email( $valid_data, $posted ) {
1055
+function give_check_purchase_email($valid_data, $posted) {
1056 1056
 	$is_banned = false;
1057 1057
 	$banned    = give_get_banned_emails();
1058 1058
 
1059
-	if ( empty( $banned ) ) {
1059
+	if (empty($banned)) {
1060 1060
 		return;
1061 1061
 	}
1062 1062
 
1063
-	if ( is_user_logged_in() ) {
1063
+	if (is_user_logged_in()) {
1064 1064
 
1065 1065
 		// The user is logged in, check that their account email is not banned
1066
-		$user_data = get_userdata( get_current_user_id() );
1067
-		if ( give_is_email_banned( $user_data->user_email ) ) {
1066
+		$user_data = get_userdata(get_current_user_id());
1067
+		if (give_is_email_banned($user_data->user_email)) {
1068 1068
 
1069 1069
 			$is_banned = true;
1070 1070
 		}
1071 1071
 
1072
-		if ( give_is_email_banned( $posted['give_email'] ) ) {
1072
+		if (give_is_email_banned($posted['give_email'])) {
1073 1073
 			$is_banned = true;
1074 1074
 		}
1075 1075
 
1076
-	} elseif ( isset( $posted['give-purchase-var'] ) && $posted['give-purchase-var'] == 'needs-to-login' ) {
1076
+	} elseif (isset($posted['give-purchase-var']) && $posted['give-purchase-var'] == 'needs-to-login') {
1077 1077
 
1078 1078
 		// The user is logging in, check that their email is not banned
1079
-		$user_data = get_user_by( 'login', $posted['give_user_login'] );
1080
-		if ( $user_data && give_is_email_banned( $user_data->user_email ) ) {
1079
+		$user_data = get_user_by('login', $posted['give_user_login']);
1080
+		if ($user_data && give_is_email_banned($user_data->user_email)) {
1081 1081
 			$is_banned = true;
1082 1082
 		}
1083 1083
 
1084 1084
 	} else {
1085 1085
 
1086 1086
 		// Guest purchase, check that the email is not banned
1087
-		if ( give_is_email_banned( $posted['give_email'] ) ) {
1087
+		if (give_is_email_banned($posted['give_email'])) {
1088 1088
 			$is_banned = true;
1089 1089
 		}
1090 1090
 
1091 1091
 	}
1092 1092
 
1093
-	if ( $is_banned ) {
1093
+	if ($is_banned) {
1094 1094
 		// Set an error and give the donor a general error (don't alert them that they were banned)
1095
-		give_set_error( 'email_banned', __( 'An internal error has occurred, please try again or contact support.', 'give' ) );
1095
+		give_set_error('email_banned', __('An internal error has occurred, please try again or contact support.', 'give'));
1096 1096
 	}
1097 1097
 }
1098 1098
 
1099
-add_action( 'give_checkout_error_checks', 'give_check_purchase_email', 10, 2 );
1099
+add_action('give_checkout_error_checks', 'give_check_purchase_email', 10, 2);
Please login to merge, or discard this patch.
includes/user-functions.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -270,7 +270,7 @@
 block discarded – undo
270 270
  * @access      public
271 271
  * @since       1.0
272 272
  *
273
- * @param       $username string - the username to validate
273
+ * @param       string $username string - the username to validate
274 274
  *
275 275
  * @return      bool
276 276
  */
Please login to merge, or discard this patch.
Spacing   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -30,36 +30,36 @@  discard block
 block discarded – undo
30 30
  *
31 31
  * @return bool|object List of all user purchases
32 32
  */
33
-function give_get_users_purchases( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) {
33
+function give_get_users_purchases($user = 0, $number = 20, $pagination = false, $status = 'complete') {
34 34
 
35
-	if ( empty( $user ) ) {
35
+	if (empty($user)) {
36 36
 		$user = get_current_user_id();
37 37
 	}
38 38
 
39
-	if ( 0 === $user && ! Give()->email_access->token_exists ) {
39
+	if (0 === $user && ! Give()->email_access->token_exists) {
40 40
 		return false;
41 41
 	}
42 42
 
43 43
 	$status = $status === 'complete' ? 'publish' : $status;
44 44
 
45
-	if ( $pagination ) {
46
-		if ( get_query_var( 'paged' ) ) {
47
-			$paged = get_query_var( 'paged' );
48
-		} else if ( get_query_var( 'page' ) ) {
49
-			$paged = get_query_var( 'page' );
45
+	if ($pagination) {
46
+		if (get_query_var('paged')) {
47
+			$paged = get_query_var('paged');
48
+		} else if (get_query_var('page')) {
49
+			$paged = get_query_var('page');
50 50
 		} else {
51 51
 			$paged = 1;
52 52
 		}
53 53
 	}
54 54
 
55
-	$args = apply_filters( 'give_get_users_purchases_args', array(
55
+	$args = apply_filters('give_get_users_purchases_args', array(
56 56
 		'user'    => $user,
57 57
 		'number'  => $number,
58 58
 		'status'  => $status,
59 59
 		'orderby' => 'date'
60
-	) );
60
+	));
61 61
 
62
-	if ( $pagination ) {
62
+	if ($pagination) {
63 63
 
64 64
 		$args['page'] = $paged;
65 65
 
@@ -69,20 +69,20 @@  discard block
 block discarded – undo
69 69
 
70 70
 	}
71 71
 
72
-	$by_user_id = is_numeric( $user ) ? true : false;
73
-	$customer   = new Give_Customer( $user, $by_user_id );
72
+	$by_user_id = is_numeric($user) ? true : false;
73
+	$customer   = new Give_Customer($user, $by_user_id);
74 74
 
75
-	if ( ! empty( $customer->payment_ids ) ) {
75
+	if ( ! empty($customer->payment_ids)) {
76 76
 
77
-		unset( $args['user'] );
78
-		$args['post__in'] = array_map( 'absint', explode( ',', $customer->payment_ids ) );
77
+		unset($args['user']);
78
+		$args['post__in'] = array_map('absint', explode(',', $customer->payment_ids));
79 79
 
80 80
 	}
81 81
 
82
-	$purchases = give_get_payments( apply_filters( 'give_get_users_purchases_args', $args ) );
82
+	$purchases = give_get_payments(apply_filters('give_get_users_purchases_args', $args));
83 83
 
84 84
 	// No purchases
85
-	if ( ! $purchases ) {
85
+	if ( ! $purchases) {
86 86
 		return false;
87 87
 	}
88 88
 
@@ -101,64 +101,64 @@  discard block
 block discarded – undo
101 101
  *
102 102
  * @return bool|object List of unique forms purchased by user
103 103
  */
104
-function give_get_users_completed_donations( $user = 0, $status = 'complete' ) {
105
-	if ( empty( $user ) ) {
104
+function give_get_users_completed_donations($user = 0, $status = 'complete') {
105
+	if (empty($user)) {
106 106
 		$user = get_current_user_id();
107 107
 	}
108 108
 
109
-	if ( empty( $user ) ) {
109
+	if (empty($user)) {
110 110
 		return false;
111 111
 	}
112 112
 
113
-	$by_user_id = is_numeric( $user ) ? true : false;
113
+	$by_user_id = is_numeric($user) ? true : false;
114 114
 
115
-	$customer = new Give_Customer( $user, $by_user_id );
115
+	$customer = new Give_Customer($user, $by_user_id);
116 116
 
117
-	if ( empty( $customer->payment_ids ) ) {
117
+	if (empty($customer->payment_ids)) {
118 118
 		return false;
119 119
 	}
120 120
 
121 121
 	// Get all the items purchased
122
-	$payment_ids    = array_reverse( explode( ',', $customer->payment_ids ) );
123
-	$limit_payments = apply_filters( 'give_users_completed_donations_payments', 50 );
124
-	if ( ! empty( $limit_payments ) ) {
125
-		$payment_ids = array_slice( $payment_ids, 0, $limit_payments );
122
+	$payment_ids    = array_reverse(explode(',', $customer->payment_ids));
123
+	$limit_payments = apply_filters('give_users_completed_donations_payments', 50);
124
+	if ( ! empty($limit_payments)) {
125
+		$payment_ids = array_slice($payment_ids, 0, $limit_payments);
126 126
 	}
127 127
 	$donation_data = array();
128
-	foreach ( $payment_ids as $payment_id ) {
129
-		$donation_data[] = give_get_payment_meta( $payment_id );
128
+	foreach ($payment_ids as $payment_id) {
129
+		$donation_data[] = give_get_payment_meta($payment_id);
130 130
 	}
131 131
 
132
-	if ( empty( $donation_data ) ) {
132
+	if (empty($donation_data)) {
133 133
 		return false;
134 134
 	}
135 135
 
136 136
 	// Grab only the post ids "form_id" of the forms purchased on this order
137 137
 	$completed_donations_ids = array();
138
-	foreach ( $donation_data as $purchase_meta ) {
138
+	foreach ($donation_data as $purchase_meta) {
139 139
 		$completed_donations_ids[] = $purchase_meta['form_id'];
140 140
 	}
141
-	if ( empty( $completed_donations_ids ) ) {
141
+	if (empty($completed_donations_ids)) {
142 142
 		return false;
143 143
 	}
144 144
 
145 145
 	// Only include each product purchased once
146
-	$form_ids = array_unique( $completed_donations_ids );
146
+	$form_ids = array_unique($completed_donations_ids);
147 147
 
148 148
 	// Make sure we still have some products and a first item
149
-	if ( empty ( $form_ids ) || ! isset( $form_ids[0] ) ) {
149
+	if (empty ($form_ids) || ! isset($form_ids[0])) {
150 150
 		return false;
151 151
 	}
152 152
 
153
-	$post_type = get_post_type( $form_ids[0] );
153
+	$post_type = get_post_type($form_ids[0]);
154 154
 
155
-	$args = apply_filters( 'give_get_users_completed_donations_args', array(
155
+	$args = apply_filters('give_get_users_completed_donations_args', array(
156 156
 		'include'        => $form_ids,
157 157
 		'post_type'      => $post_type,
158
-		'posts_per_page' => - 1
159
-	) );
158
+		'posts_per_page' => -1
159
+	));
160 160
 
161
-	return apply_filters( 'give_users_completed_donations_list', get_posts( $args ) );
161
+	return apply_filters('give_users_completed_donations_list', get_posts($args));
162 162
 }
163 163
 
164 164
 
@@ -174,12 +174,12 @@  discard block
 block discarded – undo
174 174
  *
175 175
  * @return      bool - true if has purchased, false other wise.
176 176
  */
177
-function give_has_purchases( $user_id = null ) {
178
-	if ( empty( $user_id ) ) {
177
+function give_has_purchases($user_id = null) {
178
+	if (empty($user_id)) {
179 179
 		$user_id = get_current_user_id();
180 180
 	}
181 181
 
182
-	if ( give_get_users_purchases( $user_id, 1 ) ) {
182
+	if (give_get_users_purchases($user_id, 1)) {
183 183
 		return true; // User has at least one purchase
184 184
 	}
185 185
 
@@ -199,32 +199,32 @@  discard block
 block discarded – undo
199 199
  *
200 200
  * @return      array
201 201
  */
202
-function give_get_purchase_stats_by_user( $user = '' ) {
202
+function give_get_purchase_stats_by_user($user = '') {
203 203
 
204
-	if ( is_email( $user ) ) {
204
+	if (is_email($user)) {
205 205
 
206 206
 		$field = 'email';
207 207
 
208
-	} elseif ( is_numeric( $user ) ) {
208
+	} elseif (is_numeric($user)) {
209 209
 
210 210
 		$field = 'user_id';
211 211
 
212 212
 	}
213 213
 
214 214
 	$stats    = array();
215
-	$customer = Give()->customers->get_customer_by( $field, $user );
215
+	$customer = Give()->customers->get_customer_by($field, $user);
216 216
 
217
-	if ( $customer ) {
217
+	if ($customer) {
218 218
 
219
-		$customer = new Give_Customer( $customer->id );
219
+		$customer = new Give_Customer($customer->id);
220 220
 
221
-		$stats['purchases']   = absint( $customer->purchase_count );
222
-		$stats['total_spent'] = give_sanitize_amount( $customer->purchase_value );
221
+		$stats['purchases']   = absint($customer->purchase_count);
222
+		$stats['total_spent'] = give_sanitize_amount($customer->purchase_value);
223 223
 
224 224
 	}
225 225
 
226 226
 
227
-	return (array) apply_filters( 'give_purchase_stats_by_user', $stats, $user );
227
+	return (array) apply_filters('give_purchase_stats_by_user', $stats, $user);
228 228
 }
229 229
 
230 230
 
@@ -240,22 +240,22 @@  discard block
 block discarded – undo
240 240
  *
241 241
  * @return      int - the total number of purchases
242 242
  */
243
-function give_count_purchases_of_customer( $user = null ) {
243
+function give_count_purchases_of_customer($user = null) {
244 244
 
245 245
 	//Logged in?
246
-	if ( empty( $user ) ) {
246
+	if (empty($user)) {
247 247
 		$user = get_current_user_id();
248 248
 	}
249 249
 
250 250
 	//Email access?
251
-	if ( empty( $user ) && Give()->email_access->token_email ) {
251
+	if (empty($user) && Give()->email_access->token_email) {
252 252
 		$user = Give()->email_access->token_email;
253 253
 	}
254 254
 
255 255
 
256
-	$stats = ! empty( $user ) ? give_get_purchase_stats_by_user( $user ) : false;
256
+	$stats = ! empty($user) ? give_get_purchase_stats_by_user($user) : false;
257 257
 
258
-	return isset( $stats['purchases'] ) ? $stats['purchases'] : 0;
258
+	return isset($stats['purchases']) ? $stats['purchases'] : 0;
259 259
 }
260 260
 
261 261
 /**
@@ -268,9 +268,9 @@  discard block
 block discarded – undo
268 268
  *
269 269
  * @return      float - the total amount the user has spent
270 270
  */
271
-function give_purchase_total_of_user( $user = null ) {
271
+function give_purchase_total_of_user($user = null) {
272 272
 
273
-	$stats = give_get_purchase_stats_by_user( $user );
273
+	$stats = give_get_purchase_stats_by_user($user);
274 274
 
275 275
 	return $stats['total_spent'];
276 276
 }
@@ -286,11 +286,11 @@  discard block
 block discarded – undo
286 286
  *
287 287
  * @return      bool
288 288
  */
289
-function give_validate_username( $username ) {
290
-	$sanitized = sanitize_user( $username, false );
291
-	$valid     = ( $sanitized == $username );
289
+function give_validate_username($username) {
290
+	$sanitized = sanitize_user($username, false);
291
+	$valid     = ($sanitized == $username);
292 292
 
293
-	return (bool) apply_filters( 'give_validate_username', $valid, $username );
293
+	return (bool) apply_filters('give_validate_username', $valid, $username);
294 294
 }
295 295
 
296 296
 
@@ -307,32 +307,32 @@  discard block
 block discarded – undo
307 307
  *
308 308
  * @return      void
309 309
  */
310
-function give_add_past_purchases_to_new_user( $user_id ) {
310
+function give_add_past_purchases_to_new_user($user_id) {
311 311
 
312
-	$email = get_the_author_meta( 'user_email', $user_id );
312
+	$email = get_the_author_meta('user_email', $user_id);
313 313
 
314
-	$payments = give_get_payments( array( 's' => $email ) );
314
+	$payments = give_get_payments(array('s' => $email));
315 315
 
316
-	if ( $payments ) {
317
-		foreach ( $payments as $payment ) {
318
-			if ( intval( give_get_payment_user_id( $payment->ID ) ) > 0 ) {
316
+	if ($payments) {
317
+		foreach ($payments as $payment) {
318
+			if (intval(give_get_payment_user_id($payment->ID)) > 0) {
319 319
 				continue;
320 320
 			} // This payment already associated with an account
321 321
 
322
-			$meta                    = give_get_payment_meta( $payment->ID );
323
-			$meta['user_info']       = maybe_unserialize( $meta['user_info'] );
322
+			$meta                    = give_get_payment_meta($payment->ID);
323
+			$meta['user_info']       = maybe_unserialize($meta['user_info']);
324 324
 			$meta['user_info']['id'] = $user_id;
325 325
 			$meta['user_info']       = $meta['user_info'];
326 326
 
327 327
 			// Store the updated user ID in the payment meta
328
-			give_update_payment_meta( $payment->ID, '_give_payment_meta', $meta );
329
-			give_update_payment_meta( $payment->ID, '_give_payment_user_id', $user_id );
328
+			give_update_payment_meta($payment->ID, '_give_payment_meta', $meta);
329
+			give_update_payment_meta($payment->ID, '_give_payment_user_id', $user_id);
330 330
 		}
331 331
 	}
332 332
 
333 333
 }
334 334
 
335
-add_action( 'user_register', 'give_add_past_purchases_to_new_user' );
335
+add_action('user_register', 'give_add_past_purchases_to_new_user');
336 336
 
337 337
 
338 338
 /**
@@ -354,34 +354,34 @@  discard block
 block discarded – undo
354 354
  * @since         1.0
355 355
  * @return        array - The donor's address, if any
356 356
  */
357
-function give_get_donor_address( $user_id = 0 ) {
358
-	if ( empty( $user_id ) ) {
357
+function give_get_donor_address($user_id = 0) {
358
+	if (empty($user_id)) {
359 359
 		$user_id = get_current_user_id();
360 360
 	}
361 361
 
362
-	$address = get_user_meta( $user_id, '_give_user_address', true );
362
+	$address = get_user_meta($user_id, '_give_user_address', true);
363 363
 
364
-	if ( ! isset( $address['line1'] ) ) {
364
+	if ( ! isset($address['line1'])) {
365 365
 		$address['line1'] = '';
366 366
 	}
367 367
 
368
-	if ( ! isset( $address['line2'] ) ) {
368
+	if ( ! isset($address['line2'])) {
369 369
 		$address['line2'] = '';
370 370
 	}
371 371
 
372
-	if ( ! isset( $address['city'] ) ) {
372
+	if ( ! isset($address['city'])) {
373 373
 		$address['city'] = '';
374 374
 	}
375 375
 
376
-	if ( ! isset( $address['zip'] ) ) {
376
+	if ( ! isset($address['zip'])) {
377 377
 		$address['zip'] = '';
378 378
 	}
379 379
 
380
-	if ( ! isset( $address['country'] ) ) {
380
+	if ( ! isset($address['country'])) {
381 381
 		$address['country'] = '';
382 382
 	}
383 383
 
384
-	if ( ! isset( $address['state'] ) ) {
384
+	if ( ! isset($address['state'])) {
385 385
 		$address['state'] = '';
386 386
 	}
387 387
 
@@ -401,25 +401,25 @@  discard block
 block discarded – undo
401 401
  *
402 402
  * @return        void
403 403
  */
404
-function give_new_user_notification( $user_id = 0, $user_data = array() ) {
404
+function give_new_user_notification($user_id = 0, $user_data = array()) {
405 405
 
406
-	if ( empty( $user_id ) || empty( $user_data ) ) {
406
+	if (empty($user_id) || empty($user_data)) {
407 407
 		return;
408 408
 	}
409
-	$blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
410
-	$message  = sprintf( esc_attr__( 'New user registration on your site %s:' ), $blogname ) . "\r\n\r\n";
411
-	$message .= sprintf( esc_attr__( 'Username: %s' ), $user_data['user_login'] ) . "\r\n\r\n";
412
-	$message .= sprintf( esc_attr__( 'E-mail: %s' ), $user_data['user_email'] ) . "\r\n";
409
+	$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
410
+	$message  = sprintf(esc_attr__('New user registration on your site %s:'), $blogname)."\r\n\r\n";
411
+	$message .= sprintf(esc_attr__('Username: %s'), $user_data['user_login'])."\r\n\r\n";
412
+	$message .= sprintf(esc_attr__('E-mail: %s'), $user_data['user_email'])."\r\n";
413 413
 
414
-	@wp_mail( get_option( 'admin_email' ), sprintf( esc_attr__( '[%s] New User Registration' ), $blogname ), $message );
414
+	@wp_mail(get_option('admin_email'), sprintf(esc_attr__('[%s] New User Registration'), $blogname), $message);
415 415
 
416
-	$message = sprintf( esc_attr__( 'Username: %s' ), $user_data['user_login'] ) . "\r\n";
417
-	$message .= sprintf( esc_attr__( 'Password: %s' ), esc_attr__( '[Password entered during donation]', 'give' ) ) . "\r\n";
416
+	$message = sprintf(esc_attr__('Username: %s'), $user_data['user_login'])."\r\n";
417
+	$message .= sprintf(esc_attr__('Password: %s'), esc_attr__('[Password entered during donation]', 'give'))."\r\n";
418 418
 
419
-	$message .= '<a href="' . wp_login_url() . '"> ' . esc_attr__( 'Click Here to Login', 'give' ) . ' &raquo;</a>' . "\r\n";
419
+	$message .= '<a href="'.wp_login_url().'"> '.esc_attr__('Click Here to Login', 'give').' &raquo;</a>'."\r\n";
420 420
 
421
-	wp_mail( $user_data['user_email'], sprintf( esc_attr__( '[%s] Your username and password' ), $blogname ), $message );
421
+	wp_mail($user_data['user_email'], sprintf(esc_attr__('[%s] Your username and password'), $blogname), $message);
422 422
 
423 423
 }
424 424
 
425
-add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 );
425
+add_action('give_insert_user', 'give_new_user_notification', 10, 2);
Please login to merge, or discard this patch.
includes/actions.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -23,12 +23,12 @@  discard block
 block discarded – undo
23 23
  * @return void
24 24
  */
25 25
 function give_get_actions() {
26
-	if ( isset( $_GET['give_action'] ) ) {
27
-		do_action( 'give_' . $_GET['give_action'], $_GET );
26
+	if (isset($_GET['give_action'])) {
27
+		do_action('give_'.$_GET['give_action'], $_GET);
28 28
 	}
29 29
 }
30 30
 
31
-add_action( 'init', 'give_get_actions' );
31
+add_action('init', 'give_get_actions');
32 32
 
33 33
 /**
34 34
  * Hooks Give actions, when present in the $_POST superglobal. Every give_action
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
  * @return void
40 40
  */
41 41
 function give_post_actions() {
42
-	if ( isset( $_POST['give_action'] ) ) {
43
-		do_action( 'give_' . $_POST['give_action'], $_POST );
42
+	if (isset($_POST['give_action'])) {
43
+		do_action('give_'.$_POST['give_action'], $_POST);
44 44
 	}
45 45
 }
46 46
 
47
-add_action( 'init', 'give_post_actions' );
48 47
\ No newline at end of file
48
+add_action('init', 'give_post_actions');
49 49
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/admin-actions.php 1 patch
Spacing   +6 added lines, -6 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
 
@@ -22,13 +22,13 @@  discard block
 block discarded – undo
22 22
  * @return void
23 23
  */
24 24
 function give_process_actions() {
25
-	if ( isset( $_POST['give-action'] ) ) {
26
-		do_action( 'give_' . $_POST['give-action'], $_POST );
25
+	if (isset($_POST['give-action'])) {
26
+		do_action('give_'.$_POST['give-action'], $_POST);
27 27
 	}
28 28
 
29
-	if ( isset( $_GET['give-action'] ) ) {
30
-		do_action( 'give_' . $_GET['give-action'], $_GET );
29
+	if (isset($_GET['give-action'])) {
30
+		do_action('give_'.$_GET['give-action'], $_GET);
31 31
 	}
32 32
 }
33 33
 
34
-add_action( 'admin_init', 'give_process_actions' );
35 34
\ No newline at end of file
35
+add_action('admin_init', 'give_process_actions');
36 36
\ No newline at end of file
Please login to merge, or discard this patch.