Completed
Pull Request — master (#1749)
by Devin
06:21
created
includes/misc-functions.php 1 patch
Spacing   +219 added lines, -219 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -23,9 +23,9 @@  discard block
 block discarded – undo
23 23
  */
24 24
 function give_is_test_mode() {
25 25
 
26
-	$ret = give_is_setting_enabled( give_get_option( 'test_mode' ) );
26
+	$ret = give_is_setting_enabled(give_get_option('test_mode'));
27 27
 
28
-	return (bool) apply_filters( 'give_is_test_mode', $ret );
28
+	return (bool) apply_filters('give_is_test_mode', $ret);
29 29
 
30 30
 }
31 31
 
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
37 37
  */
38 38
 function give_get_currency() {
39 39
 
40
-	$currency = give_get_option( 'currency', 'USD' );
40
+	$currency = give_get_option('currency', 'USD');
41 41
 
42
-	return apply_filters( 'give_currency', $currency );
42
+	return apply_filters('give_currency', $currency);
43 43
 }
44 44
 
45 45
 /**
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
  */
52 52
 function give_get_currency_position() {
53 53
 
54
-	$currency_pos = give_get_option( 'currency_position', 'before' );
54
+	$currency_pos = give_get_option('currency_position', 'before');
55 55
 
56
-	return apply_filters( 'give_currency_position', $currency_pos );
56
+	return apply_filters('give_currency_position', $currency_pos);
57 57
 }
58 58
 
59 59
 
@@ -66,39 +66,39 @@  discard block
 block discarded – undo
66 66
 
67 67
 function give_get_currencies() {
68 68
 	$currencies = array(
69
-		'USD'  => __( 'US Dollars ($)', 'give' ),
70
-		'EUR'  => __( 'Euros (€)', 'give' ),
71
-		'GBP'  => __( 'Pounds Sterling (£)', 'give' ),
72
-		'AUD'  => __( 'Australian Dollars ($)', 'give' ),
73
-		'BRL'  => __( 'Brazilian Real (R$)', 'give' ),
74
-		'CAD'  => __( 'Canadian Dollars ($)', 'give' ),
75
-		'CZK'  => __( 'Czech Koruna (Kč)', 'give' ),
76
-		'DKK'  => __( 'Danish Krone (kr.)', 'give' ),
77
-		'HKD'  => __( 'Hong Kong Dollar ($)', 'give' ),
78
-		'HUF'  => __( 'Hungarian Forint (Ft)', 'give' ),
79
-		'ILS'  => __( 'Israeli Shekel (₪)', 'give' ),
80
-		'JPY'  => __( 'Japanese Yen (¥)', 'give' ),
81
-		'MYR'  => __( 'Malaysian Ringgits (RM)', 'give' ),
82
-		'MXN'  => __( 'Mexican Peso ($)', 'give' ),
83
-		'MAD'  => __( 'Moroccan Dirham (.د.م)', 'give' ),
84
-		'NZD'  => __( 'New Zealand Dollar ($)', 'give' ),
85
-		'NOK'  => __( 'Norwegian Krone (Kr.)', 'give' ),
86
-		'PHP'  => __( 'Philippine Pesos (₱)', 'give' ),
87
-		'PLN'  => __( 'Polish Zloty (zł)', 'give' ),
88
-		'SGD'  => __( 'Singapore Dollar ($)', 'give' ),
89
-		'KRW'  => __( 'South Korean Won (₩)', 'give' ),
90
-		'ZAR'  => __( 'South African Rand (R)', 'give' ),
91
-		'SEK'  => __( 'Swedish Krona (kr)', 'give' ),
92
-		'CHF'  => __( 'Swiss Franc (CHF)', 'give' ),
93
-		'TWD'  => __( 'Taiwan New Dollars (NT$)', 'give' ),
94
-		'THB'  => __( 'Thai Baht (฿)', 'give' ),
95
-		'INR'  => __( 'Indian Rupee (₹)', 'give' ),
96
-		'TRY'  => __( 'Turkish Lira (₺)', 'give' ),
97
-		'RIAL' => __( 'Iranian Rial (﷼)', 'give' ),
98
-		'RUB'  => __( 'Russian Rubles (руб)', 'give' ),
69
+		'USD'  => __('US Dollars ($)', 'give'),
70
+		'EUR'  => __('Euros (€)', 'give'),
71
+		'GBP'  => __('Pounds Sterling (£)', 'give'),
72
+		'AUD'  => __('Australian Dollars ($)', 'give'),
73
+		'BRL'  => __('Brazilian Real (R$)', 'give'),
74
+		'CAD'  => __('Canadian Dollars ($)', 'give'),
75
+		'CZK'  => __('Czech Koruna (Kč)', 'give'),
76
+		'DKK'  => __('Danish Krone (kr.)', 'give'),
77
+		'HKD'  => __('Hong Kong Dollar ($)', 'give'),
78
+		'HUF'  => __('Hungarian Forint (Ft)', 'give'),
79
+		'ILS'  => __('Israeli Shekel (₪)', 'give'),
80
+		'JPY'  => __('Japanese Yen (¥)', 'give'),
81
+		'MYR'  => __('Malaysian Ringgits (RM)', 'give'),
82
+		'MXN'  => __('Mexican Peso ($)', 'give'),
83
+		'MAD'  => __('Moroccan Dirham (.د.م)', 'give'),
84
+		'NZD'  => __('New Zealand Dollar ($)', 'give'),
85
+		'NOK'  => __('Norwegian Krone (Kr.)', 'give'),
86
+		'PHP'  => __('Philippine Pesos (₱)', 'give'),
87
+		'PLN'  => __('Polish Zloty (zł)', 'give'),
88
+		'SGD'  => __('Singapore Dollar ($)', 'give'),
89
+		'KRW'  => __('South Korean Won (₩)', 'give'),
90
+		'ZAR'  => __('South African Rand (R)', 'give'),
91
+		'SEK'  => __('Swedish Krona (kr)', 'give'),
92
+		'CHF'  => __('Swiss Franc (CHF)', 'give'),
93
+		'TWD'  => __('Taiwan New Dollars (NT$)', 'give'),
94
+		'THB'  => __('Thai Baht (฿)', 'give'),
95
+		'INR'  => __('Indian Rupee (₹)', 'give'),
96
+		'TRY'  => __('Turkish Lira (₺)', 'give'),
97
+		'RIAL' => __('Iranian Rial (﷼)', 'give'),
98
+		'RUB'  => __('Russian Rubles (руб)', 'give'),
99 99
 	);
100 100
 
101
-	return apply_filters( 'give_currencies', $currencies );
101
+	return apply_filters('give_currencies', $currencies);
102 102
 }
103 103
 
104 104
 
@@ -115,12 +115,12 @@  discard block
 block discarded – undo
115 115
  *
116 116
  * @return string           The symbol to use for the currency
117 117
  */
118
-function give_currency_symbol( $currency = '', $decode_currency = false ) {
118
+function give_currency_symbol($currency = '', $decode_currency = false) {
119 119
 
120
-	if ( empty( $currency ) ) {
120
+	if (empty($currency)) {
121 121
 		$currency = give_get_currency();
122 122
 	}
123
-	switch ( $currency ) :
123
+	switch ($currency) :
124 124
 		case 'GBP' :
125 125
 			$symbol = '£';
126 126
 			break;
@@ -198,9 +198,9 @@  discard block
 block discarded – undo
198 198
 			break;
199 199
 	endswitch;
200 200
 
201
-	$symbol = ( ! $decode_currency ? $symbol : html_entity_decode( $symbol ) );
201
+	$symbol = ( ! $decode_currency ? $symbol : html_entity_decode($symbol));
202 202
 
203
-	return apply_filters( 'give_currency_symbol', $symbol, $currency );
203
+	return apply_filters('give_currency_symbol', $symbol, $currency);
204 204
 }
205 205
 
206 206
 
@@ -213,16 +213,16 @@  discard block
 block discarded – undo
213 213
  *
214 214
  * @return string
215 215
  */
216
-function give_get_currency_name( $currency_code ) {
216
+function give_get_currency_name($currency_code) {
217 217
 	$currency_name = '';
218 218
 	$currency_names = give_get_currencies();
219 219
 
220
-	if ( $currency_code && array_key_exists( $currency_code, $currency_names ) ) {
221
-		$currency_name = explode( '(',  $currency_names[ $currency_code ] );
222
-		$currency_name = trim( current( $currency_name ) );
220
+	if ($currency_code && array_key_exists($currency_code, $currency_names)) {
221
+		$currency_name = explode('(', $currency_names[$currency_code]);
222
+		$currency_name = trim(current($currency_name));
223 223
 	}
224 224
 
225
-	return apply_filters( 'give_currency_name', $currency_name, $currency_code );
225
+	return apply_filters('give_currency_name', $currency_name, $currency_code);
226 226
 }
227 227
 
228 228
 
@@ -236,21 +236,21 @@  discard block
 block discarded – undo
236 236
 
237 237
 	global $wp;
238 238
 
239
-	if ( get_option( 'permalink_structure' ) ) {
240
-		$base = trailingslashit( home_url( $wp->request ) );
239
+	if (get_option('permalink_structure')) {
240
+		$base = trailingslashit(home_url($wp->request));
241 241
 	} else {
242
-		$base = add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) );
243
-		$base = remove_query_arg( array( 'post_type', 'name' ), $base );
242
+		$base = add_query_arg($wp->query_string, '', trailingslashit(home_url($wp->request)));
243
+		$base = remove_query_arg(array('post_type', 'name'), $base);
244 244
 	}
245 245
 
246 246
 	$scheme      = is_ssl() ? 'https' : 'http';
247
-	$current_uri = set_url_scheme( $base, $scheme );
247
+	$current_uri = set_url_scheme($base, $scheme);
248 248
 
249
-	if ( is_front_page() ) {
250
-		$current_uri = home_url( '/' );
249
+	if (is_front_page()) {
250
+		$current_uri = home_url('/');
251 251
 	}
252 252
 
253
-	return apply_filters( 'give_get_current_page_url', $current_uri );
253
+	return apply_filters('give_get_current_page_url', $current_uri);
254 254
 
255 255
 }
256 256
 
@@ -272,15 +272,15 @@  discard block
 block discarded – undo
272 272
 	 */
273 273
 	$gateways = give_get_enabled_payment_gateways();
274 274
 
275
-	if ( count( $gateways ) == 1 && ! isset( $gateways['paypal'] ) && ! isset( $gateways['manual'] ) ) {
275
+	if (count($gateways) == 1 && ! isset($gateways['paypal']) && ! isset($gateways['manual'])) {
276 276
 		$ret = true;
277
-	} elseif ( count( $gateways ) == 1 ) {
277
+	} elseif (count($gateways) == 1) {
278 278
 		$ret = false;
279
-	} elseif ( count( $gateways ) == 2 && isset( $gateways['paypal'] ) && isset( $gateways['manual'] ) ) {
279
+	} elseif (count($gateways) == 2 && isset($gateways['paypal']) && isset($gateways['manual'])) {
280 280
 		$ret = false;
281 281
 	}
282 282
 
283
-	return (bool) apply_filters( 'give_verify_credit_cards', $ret );
283
+	return (bool) apply_filters('give_verify_credit_cards', $ret);
284 284
 }
285 285
 
286 286
 /**
@@ -292,26 +292,26 @@  discard block
 block discarded – undo
292 292
 function give_get_timezone_id() {
293 293
 
294 294
 	// if site timezone string exists, return it.
295
-	if ( $timezone = get_option( 'timezone_string' ) ) {
295
+	if ($timezone = get_option('timezone_string')) {
296 296
 		return $timezone;
297 297
 	}
298 298
 
299 299
 	// get UTC offset, if it isn't set return UTC.
300
-	if ( ! ( $utc_offset = 3600 * get_option( 'gmt_offset', 0 ) ) ) {
300
+	if ( ! ($utc_offset = 3600 * get_option('gmt_offset', 0))) {
301 301
 		return 'UTC';
302 302
 	}
303 303
 
304 304
 	// attempt to guess the timezone string from the UTC offset.
305
-	$timezone = timezone_name_from_abbr( '', $utc_offset );
305
+	$timezone = timezone_name_from_abbr('', $utc_offset);
306 306
 
307 307
 	// last try, guess timezone string manually.
308
-	if ( $timezone === false ) {
308
+	if ($timezone === false) {
309 309
 
310
-		$is_dst = date( 'I' );
310
+		$is_dst = date('I');
311 311
 
312
-		foreach ( timezone_abbreviations_list() as $abbr ) {
313
-			foreach ( $abbr as $city ) {
314
-				if ( $city['dst'] == $is_dst && $city['offset'] == $utc_offset ) {
312
+		foreach (timezone_abbreviations_list() as $abbr) {
313
+			foreach ($abbr as $city) {
314
+				if ($city['dst'] == $is_dst && $city['offset'] == $utc_offset) {
315 315
 					return $city['timezone_id'];
316 316
 				}
317 317
 			}
@@ -335,17 +335,17 @@  discard block
 block discarded – undo
335 335
 
336 336
 	$ip = '127.0.0.1';
337 337
 
338
-	if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
338
+	if ( ! empty($_SERVER['HTTP_CLIENT_IP'])) {
339 339
 		// check ip from share internet
340 340
 		$ip = $_SERVER['HTTP_CLIENT_IP'];
341
-	} elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
341
+	} elseif ( ! empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
342 342
 		// to check ip is pass from proxy
343 343
 		$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
344
-	} elseif ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) {
344
+	} elseif ( ! empty($_SERVER['REMOTE_ADDR'])) {
345 345
 		$ip = $_SERVER['REMOTE_ADDR'];
346 346
 	}
347 347
 
348
-	return apply_filters( 'give_get_ip', $ip );
348
+	return apply_filters('give_get_ip', $ip);
349 349
 }
350 350
 
351 351
 
@@ -360,9 +360,9 @@  discard block
 block discarded – undo
360 360
  *
361 361
  * @uses  Give()->session->set()
362 362
  */
363
-function give_set_purchase_session( $purchase_data = array() ) {
364
-	Give()->session->set( 'give_purchase', $purchase_data );
365
-	Give()->session->set( 'give_email', $purchase_data['user_email'] );
363
+function give_set_purchase_session($purchase_data = array()) {
364
+	Give()->session->set('give_purchase', $purchase_data);
365
+	Give()->session->set('give_email', $purchase_data['user_email']);
366 366
 }
367 367
 
368 368
 /**
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
  * @return mixed array | false
377 377
  */
378 378
 function give_get_purchase_session() {
379
-	return Give()->session->get( 'give_purchase' );
379
+	return Give()->session->get('give_purchase');
380 380
 }
381 381
 
382 382
 /**
@@ -391,14 +391,14 @@  discard block
 block discarded – undo
391 391
  *
392 392
  * @return string
393 393
  */
394
-function give_get_purchase_summary( $purchase_data, $email = true ) {
394
+function give_get_purchase_summary($purchase_data, $email = true) {
395 395
 	$summary = '';
396 396
 
397
-	if ( $email ) {
398
-		$summary .= $purchase_data['user_email'] . ' - ';
397
+	if ($email) {
398
+		$summary .= $purchase_data['user_email'].' - ';
399 399
 	}
400 400
 
401
-	$summary .= get_the_title( $purchase_data['post_data']['give-form-id'] );
401
+	$summary .= get_the_title($purchase_data['post_data']['give-form-id']);
402 402
 
403 403
 	return $summary;
404 404
 }
@@ -415,31 +415,31 @@  discard block
 block discarded – undo
415 415
 function give_get_host() {
416 416
 	$host = false;
417 417
 
418
-	if ( defined( 'WPE_APIKEY' ) ) {
418
+	if (defined('WPE_APIKEY')) {
419 419
 		$host = 'WP Engine';
420
-	} elseif ( defined( 'PAGELYBIN' ) ) {
420
+	} elseif (defined('PAGELYBIN')) {
421 421
 		$host = 'Pagely';
422
-	} elseif ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) {
422
+	} elseif (DB_HOST == 'localhost:/tmp/mysql5.sock') {
423 423
 		$host = 'ICDSoft';
424
-	} elseif ( DB_HOST == 'mysqlv5' ) {
424
+	} elseif (DB_HOST == 'mysqlv5') {
425 425
 		$host = 'NetworkSolutions';
426
-	} elseif ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) {
426
+	} elseif (strpos(DB_HOST, 'ipagemysql.com') !== false) {
427 427
 		$host = 'iPage';
428
-	} elseif ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) {
428
+	} elseif (strpos(DB_HOST, 'ipowermysql.com') !== false) {
429 429
 		$host = 'IPower';
430
-	} elseif ( strpos( DB_HOST, '.gridserver.com' ) !== false ) {
430
+	} elseif (strpos(DB_HOST, '.gridserver.com') !== false) {
431 431
 		$host = 'MediaTemple Grid';
432
-	} elseif ( strpos( DB_HOST, '.pair.com' ) !== false ) {
432
+	} elseif (strpos(DB_HOST, '.pair.com') !== false) {
433 433
 		$host = 'pair Networks';
434
-	} elseif ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) {
434
+	} elseif (strpos(DB_HOST, '.stabletransit.com') !== false) {
435 435
 		$host = 'Rackspace Cloud';
436
-	} elseif ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) {
436
+	} elseif (strpos(DB_HOST, '.sysfix.eu') !== false) {
437 437
 		$host = 'SysFix.eu Power Hosting';
438
-	} elseif ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) {
438
+	} elseif (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) {
439 439
 		$host = 'Flywheel';
440 440
 	} else {
441 441
 		// Adding a general fallback for data gathering
442
-		$host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME'];
442
+		$host = 'DBH: '.DB_HOST.', SRV: '.$_SERVER['SERVER_NAME'];
443 443
 	}
444 444
 
445 445
 	return $host;
@@ -455,67 +455,67 @@  discard block
 block discarded – undo
455 455
  *
456 456
  * @return bool true if host matches, false if not
457 457
  */
458
-function give_is_host( $host = false ) {
458
+function give_is_host($host = false) {
459 459
 
460 460
 	$return = false;
461 461
 
462
-	if ( $host ) {
463
-		$host = str_replace( ' ', '', strtolower( $host ) );
462
+	if ($host) {
463
+		$host = str_replace(' ', '', strtolower($host));
464 464
 
465
-		switch ( $host ) {
465
+		switch ($host) {
466 466
 			case 'wpengine':
467
-				if ( defined( 'WPE_APIKEY' ) ) {
467
+				if (defined('WPE_APIKEY')) {
468 468
 					$return = true;
469 469
 				}
470 470
 				break;
471 471
 			case 'pagely':
472
-				if ( defined( 'PAGELYBIN' ) ) {
472
+				if (defined('PAGELYBIN')) {
473 473
 					$return = true;
474 474
 				}
475 475
 				break;
476 476
 			case 'icdsoft':
477
-				if ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) {
477
+				if (DB_HOST == 'localhost:/tmp/mysql5.sock') {
478 478
 					$return = true;
479 479
 				}
480 480
 				break;
481 481
 			case 'networksolutions':
482
-				if ( DB_HOST == 'mysqlv5' ) {
482
+				if (DB_HOST == 'mysqlv5') {
483 483
 					$return = true;
484 484
 				}
485 485
 				break;
486 486
 			case 'ipage':
487
-				if ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) {
487
+				if (strpos(DB_HOST, 'ipagemysql.com') !== false) {
488 488
 					$return = true;
489 489
 				}
490 490
 				break;
491 491
 			case 'ipower':
492
-				if ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) {
492
+				if (strpos(DB_HOST, 'ipowermysql.com') !== false) {
493 493
 					$return = true;
494 494
 				}
495 495
 				break;
496 496
 			case 'mediatemplegrid':
497
-				if ( strpos( DB_HOST, '.gridserver.com' ) !== false ) {
497
+				if (strpos(DB_HOST, '.gridserver.com') !== false) {
498 498
 					$return = true;
499 499
 				}
500 500
 				break;
501 501
 			case 'pairnetworks':
502
-				if ( strpos( DB_HOST, '.pair.com' ) !== false ) {
502
+				if (strpos(DB_HOST, '.pair.com') !== false) {
503 503
 					$return = true;
504 504
 				}
505 505
 				break;
506 506
 			case 'rackspacecloud':
507
-				if ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) {
507
+				if (strpos(DB_HOST, '.stabletransit.com') !== false) {
508 508
 					$return = true;
509 509
 				}
510 510
 				break;
511 511
 			case 'sysfix.eu':
512 512
 			case 'sysfix.eupowerhosting':
513
-				if ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) {
513
+				if (strpos(DB_HOST, '.sysfix.eu') !== false) {
514 514
 					$return = true;
515 515
 				}
516 516
 				break;
517 517
 			case 'flywheel':
518
-				if ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) {
518
+				if (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) {
519 519
 					$return = true;
520 520
 				}
521 521
 				break;
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
  * @param string $replacement Optional. The function that should have been called.
549 549
  * @param array  $backtrace   Optional. Contains stack backtrace of deprecated function.
550 550
  */
551
-function _give_deprecated_function( $function, $version, $replacement = null, $backtrace = null ) {
551
+function _give_deprecated_function($function, $version, $replacement = null, $backtrace = null) {
552 552
 
553 553
 	/**
554 554
 	 * Fires while give deprecated function call occurs.
@@ -561,19 +561,19 @@  discard block
 block discarded – undo
561 561
 	 * @param string $replacement Optional. The function that should have been called.
562 562
 	 * @param string $version     The plugin version that deprecated the function.
563 563
 	 */
564
-	do_action( 'give_deprecated_function_run', $function, $replacement, $version );
564
+	do_action('give_deprecated_function_run', $function, $replacement, $version);
565 565
 
566
-	$show_errors = current_user_can( 'manage_options' );
566
+	$show_errors = current_user_can('manage_options');
567 567
 
568 568
 	// Allow plugin to filter the output error trigger.
569
-	if ( WP_DEBUG && apply_filters( 'give_deprecated_function_trigger_error', $show_errors ) ) {
570
-		if ( ! is_null( $replacement ) ) {
571
-			trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give' ), $function, $version, $replacement ) );
572
-			trigger_error( print_r( $backtrace, 1 ) ); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine.
569
+	if (WP_DEBUG && apply_filters('give_deprecated_function_trigger_error', $show_errors)) {
570
+		if ( ! is_null($replacement)) {
571
+			trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give'), $function, $version, $replacement));
572
+			trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine.
573 573
 			// Alternatively we could dump this to a file.
574 574
 		} else {
575
-			trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give' ), $function, $version ) );
576
-			trigger_error( print_r( $backtrace, 1 ) );// Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine.
575
+			trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give'), $function, $version));
576
+			trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine.
577 577
 			// Alternatively we could dump this to a file.
578 578
 		}
579 579
 	}
@@ -587,8 +587,8 @@  discard block
 block discarded – undo
587 587
  * @return string $post_id
588 588
  */
589 589
 function give_get_admin_post_id() {
590
-	$post_id = isset( $_GET['post'] ) ? $_GET['post'] : null;
591
-	if ( ! $post_id && isset( $_POST['post_id'] ) ) {
590
+	$post_id = isset($_GET['post']) ? $_GET['post'] : null;
591
+	if ( ! $post_id && isset($_POST['post_id'])) {
592 592
 		$post_id = $_POST['post_id'];
593 593
 	}
594 594
 
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
  * @return string Arg separator output
603 603
  */
604 604
 function give_get_php_arg_separator_output() {
605
-	return ini_get( 'arg_separator.output' );
605
+	return ini_get('arg_separator.output');
606 606
 }
607 607
 
608 608
 
@@ -617,10 +617,10 @@  discard block
 block discarded – undo
617 617
  *
618 618
  * @return string Short month name
619 619
  */
620
-function give_month_num_to_name( $n ) {
621
-	$timestamp = mktime( 0, 0, 0, $n, 1, 2005 );
620
+function give_month_num_to_name($n) {
621
+	$timestamp = mktime(0, 0, 0, $n, 1, 2005);
622 622
 
623
-	return date_i18n( 'M', $timestamp );
623
+	return date_i18n('M', $timestamp);
624 624
 }
625 625
 
626 626
 
@@ -633,10 +633,10 @@  discard block
 block discarded – undo
633 633
  *
634 634
  * @return bool Whether or not function is disabled.
635 635
  */
636
-function give_is_func_disabled( $function ) {
637
-	$disabled = explode( ',', ini_get( 'disable_functions' ) );
636
+function give_is_func_disabled($function) {
637
+	$disabled = explode(',', ini_get('disable_functions'));
638 638
 
639
-	return in_array( $function, $disabled );
639
+	return in_array($function, $disabled);
640 640
 }
641 641
 
642 642
 
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
 function give_get_newsletter() {
649 649
 	?>
650 650
 
651
-	<p class="newsletter-intro"><?php esc_html_e( 'Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give' ); ?></p>
651
+	<p class="newsletter-intro"><?php esc_html_e('Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give'); ?></p>
652 652
 
653 653
 	<div class="give-newsletter-form-wrap">
654 654
 
@@ -656,33 +656,33 @@  discard block
 block discarded – undo
656 656
 			  method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate"
657 657
 			  target="_blank" novalidate>
658 658
 			<div class="give-newsletter-confirmation">
659
-				<p><?php esc_html_e( 'Thanks for Subscribing!', 'give' ); ?> :)</p>
659
+				<p><?php esc_html_e('Thanks for Subscribing!', 'give'); ?> :)</p>
660 660
 			</div>
661 661
 
662 662
 			<table class="form-table give-newsletter-form">
663 663
 				<tr valign="middle">
664 664
 					<td>
665 665
 						<label for="mce-EMAIL"
666
-							   class="screen-reader-text"><?php esc_html_e( 'Email Address (required)', 'give' ); ?></label>
666
+							   class="screen-reader-text"><?php esc_html_e('Email Address (required)', 'give'); ?></label>
667 667
 						<input type="email" name="EMAIL" id="mce-EMAIL"
668
-							   placeholder="<?php esc_attr_e( 'Email Address (required)', 'give' ); ?>"
668
+							   placeholder="<?php esc_attr_e('Email Address (required)', 'give'); ?>"
669 669
 							   class="required email" value="">
670 670
 					</td>
671 671
 					<td>
672 672
 						<label for="mce-FNAME"
673
-							   class="screen-reader-text"><?php esc_html_e( 'First Name', 'give' ); ?></label>
673
+							   class="screen-reader-text"><?php esc_html_e('First Name', 'give'); ?></label>
674 674
 						<input type="text" name="FNAME" id="mce-FNAME"
675
-							   placeholder="<?php esc_attr_e( 'First Name', 'give' ); ?>" class="" value="">
675
+							   placeholder="<?php esc_attr_e('First Name', 'give'); ?>" class="" value="">
676 676
 					</td>
677 677
 					<td>
678 678
 						<label for="mce-LNAME"
679
-							   class="screen-reader-text"><?php esc_html_e( 'Last Name', 'give' ); ?></label>
679
+							   class="screen-reader-text"><?php esc_html_e('Last Name', 'give'); ?></label>
680 680
 						<input type="text" name="LNAME" id="mce-LNAME"
681
-							   placeholder="<?php esc_attr_e( 'Last Name', 'give' ); ?>" class="" value="">
681
+							   placeholder="<?php esc_attr_e('Last Name', 'give'); ?>" class="" value="">
682 682
 					</td>
683 683
 					<td>
684 684
 						<input type="submit" name="subscribe" id="mc-embedded-subscribe" class="button"
685
-							   value="<?php esc_attr_e( 'Subscribe', 'give' ); ?>">
685
+							   value="<?php esc_attr_e('Subscribe', 'give'); ?>">
686 686
 					</td>
687 687
 				</tr>
688 688
 			</table>
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
  *
736 736
  * @return string
737 737
  */
738
-function give_svg_icons( $icon ) {
738
+function give_svg_icons($icon) {
739 739
 
740 740
 	// Store your SVGs in an associative array
741 741
 	$svgs = array(
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
 	);
748 748
 
749 749
 	// Return the chosen icon's SVG string
750
-	return $svgs[ $icon ];
750
+	return $svgs[$icon];
751 751
 }
752 752
 
753 753
 /**
@@ -759,15 +759,15 @@  discard block
 block discarded – undo
759 759
  *
760 760
  * @return mixed
761 761
  */
762
-function modify_nav_menu_meta_box_object( $post_type ) {
763
-	if ( isset( $post_type->name ) && $post_type->name == 'give_forms' ) {
764
-		$post_type->labels->name = esc_html__( 'Donation Forms', 'give' );
762
+function modify_nav_menu_meta_box_object($post_type) {
763
+	if (isset($post_type->name) && $post_type->name == 'give_forms') {
764
+		$post_type->labels->name = esc_html__('Donation Forms', 'give');
765 765
 	}
766 766
 
767 767
 	return $post_type;
768 768
 }
769 769
 
770
-add_filter( 'nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object' );
770
+add_filter('nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object');
771 771
 
772 772
 
773 773
 /**
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
  * @license    https://opensource.org/licenses/MIT MIT
782 782
  */
783 783
 
784
-if ( ! function_exists( 'array_column' ) ) {
784
+if ( ! function_exists('array_column')) {
785 785
 	/**
786 786
 	 * Returns the values from a single column of the input array, identified by
787 787
 	 * the $columnKey.
@@ -800,53 +800,53 @@  discard block
 block discarded – undo
800 800
 	 *
801 801
 	 * @return array
802 802
 	 */
803
-	function array_column( $input = null, $columnKey = null, $indexKey = null ) {
803
+	function array_column($input = null, $columnKey = null, $indexKey = null) {
804 804
 		// Using func_get_args() in order to check for proper number of
805 805
 		// parameters and trigger errors exactly as the built-in array_column()
806 806
 		// does in PHP 5.5.
807 807
 		$argc   = func_num_args();
808 808
 		$params = func_get_args();
809 809
 
810
-		if ( $argc < 2 ) {
811
-			trigger_error( sprintf( esc_html__( 'array_column() expects at least 2 parameters, %s given.', 'give' ), $argc ), E_USER_WARNING );
810
+		if ($argc < 2) {
811
+			trigger_error(sprintf(esc_html__('array_column() expects at least 2 parameters, %s given.', 'give'), $argc), E_USER_WARNING);
812 812
 
813 813
 			return null;
814 814
 		}
815 815
 
816
-		if ( ! is_array( $params[0] ) ) {
817
-			trigger_error( sprintf( esc_html__( 'array_column() expects parameter 1 to be array, %s given.', 'give' ), gettype( $params[0] ) ), E_USER_WARNING );
816
+		if ( ! is_array($params[0])) {
817
+			trigger_error(sprintf(esc_html__('array_column() expects parameter 1 to be array, %s given.', 'give'), gettype($params[0])), E_USER_WARNING);
818 818
 
819 819
 			return null;
820 820
 		}
821 821
 
822
-		if ( ! is_int( $params[1] )
823
-		     && ! is_float( $params[1] )
824
-		     && ! is_string( $params[1] )
822
+		if ( ! is_int($params[1])
823
+		     && ! is_float($params[1])
824
+		     && ! is_string($params[1])
825 825
 		     && $params[1] !== null
826
-		     && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) )
826
+		     && ! (is_object($params[1]) && method_exists($params[1], '__toString'))
827 827
 		) {
828
-			trigger_error( esc_html__( 'array_column(): The column key should be either a string or an integer.', 'give' ), E_USER_WARNING );
828
+			trigger_error(esc_html__('array_column(): The column key should be either a string or an integer.', 'give'), E_USER_WARNING);
829 829
 
830 830
 			return false;
831 831
 		}
832 832
 
833
-		if ( isset( $params[2] )
834
-		     && ! is_int( $params[2] )
835
-		     && ! is_float( $params[2] )
836
-		     && ! is_string( $params[2] )
837
-		     && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) )
833
+		if (isset($params[2])
834
+		     && ! is_int($params[2])
835
+		     && ! is_float($params[2])
836
+		     && ! is_string($params[2])
837
+		     && ! (is_object($params[2]) && method_exists($params[2], '__toString'))
838 838
 		) {
839
-			trigger_error( esc_html__( 'array_column(): The index key should be either a string or an integer.', 'give' ), E_USER_WARNING );
839
+			trigger_error(esc_html__('array_column(): The index key should be either a string or an integer.', 'give'), E_USER_WARNING);
840 840
 
841 841
 			return false;
842 842
 		}
843 843
 
844 844
 		$paramsInput     = $params[0];
845
-		$paramsColumnKey = ( $params[1] !== null ) ? (string) $params[1] : null;
845
+		$paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null;
846 846
 
847 847
 		$paramsIndexKey = null;
848
-		if ( isset( $params[2] ) ) {
849
-			if ( is_float( $params[2] ) || is_int( $params[2] ) ) {
848
+		if (isset($params[2])) {
849
+			if (is_float($params[2]) || is_int($params[2])) {
850 850
 				$paramsIndexKey = (int) $params[2];
851 851
 			} else {
852 852
 				$paramsIndexKey = (string) $params[2];
@@ -855,26 +855,26 @@  discard block
 block discarded – undo
855 855
 
856 856
 		$resultArray = array();
857 857
 
858
-		foreach ( $paramsInput as $row ) {
858
+		foreach ($paramsInput as $row) {
859 859
 			$key    = $value = null;
860 860
 			$keySet = $valueSet = false;
861 861
 
862
-			if ( $paramsIndexKey !== null && array_key_exists( $paramsIndexKey, $row ) ) {
862
+			if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) {
863 863
 				$keySet = true;
864
-				$key    = (string) $row[ $paramsIndexKey ];
864
+				$key    = (string) $row[$paramsIndexKey];
865 865
 			}
866 866
 
867
-			if ( $paramsColumnKey === null ) {
867
+			if ($paramsColumnKey === null) {
868 868
 				$valueSet = true;
869 869
 				$value    = $row;
870
-			} elseif ( is_array( $row ) && array_key_exists( $paramsColumnKey, $row ) ) {
870
+			} elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) {
871 871
 				$valueSet = true;
872
-				$value    = $row[ $paramsColumnKey ];
872
+				$value    = $row[$paramsColumnKey];
873 873
 			}
874 874
 
875
-			if ( $valueSet ) {
876
-				if ( $keySet ) {
877
-					$resultArray[ $key ] = $value;
875
+			if ($valueSet) {
876
+				if ($keySet) {
877
+					$resultArray[$key] = $value;
878 878
 				} else {
879 879
 					$resultArray[] = $value;
880 880
 				}
@@ -894,40 +894,40 @@  discard block
 block discarded – undo
894 894
  *
895 895
  * @return bool Whether the receipt is visible or not.
896 896
  */
897
-function give_can_view_receipt( $payment_key = '' ) {
897
+function give_can_view_receipt($payment_key = '') {
898 898
 
899 899
 	$return = false;
900 900
 
901
-	if ( empty( $payment_key ) ) {
901
+	if (empty($payment_key)) {
902 902
 		return $return;
903 903
 	}
904 904
 
905 905
 	global $give_receipt_args;
906 906
 
907
-	$give_receipt_args['id'] = give_get_purchase_id_by_key( $payment_key );
907
+	$give_receipt_args['id'] = give_get_purchase_id_by_key($payment_key);
908 908
 
909
-	$user_id = (int) give_get_payment_user_id( $give_receipt_args['id'] );
909
+	$user_id = (int) give_get_payment_user_id($give_receipt_args['id']);
910 910
 
911
-	$payment_meta = give_get_payment_meta( $give_receipt_args['id'] );
911
+	$payment_meta = give_get_payment_meta($give_receipt_args['id']);
912 912
 
913
-	if ( is_user_logged_in() ) {
914
-		if ( $user_id === (int) get_current_user_id() ) {
913
+	if (is_user_logged_in()) {
914
+		if ($user_id === (int) get_current_user_id()) {
915 915
 			$return = true;
916
-		} elseif ( wp_get_current_user()->user_email === give_get_payment_user_email( $give_receipt_args['id'] ) ) {
916
+		} elseif (wp_get_current_user()->user_email === give_get_payment_user_email($give_receipt_args['id'])) {
917 917
 			$return = true;
918
-		} elseif ( current_user_can( 'view_give_sensitive_data' ) ) {
918
+		} elseif (current_user_can('view_give_sensitive_data')) {
919 919
 			$return = true;
920 920
 		}
921 921
 	}
922 922
 
923 923
 	$session = give_get_purchase_session();
924
-	if ( ! empty( $session ) && ! is_user_logged_in() ) {
925
-		if ( $session['purchase_key'] === $payment_meta['key'] ) {
924
+	if ( ! empty($session) && ! is_user_logged_in()) {
925
+		if ($session['purchase_key'] === $payment_meta['key']) {
926 926
 			$return = true;
927 927
 		}
928 928
 	}
929 929
 
930
-	return (bool) apply_filters( 'give_can_view_receipt', $return, $payment_key );
930
+	return (bool) apply_filters('give_can_view_receipt', $return, $payment_key);
931 931
 
932 932
 }
933 933
 
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
  *
937 937
  * Fallback in case the calendar extension is not loaded in PHP; Only supports Gregorian calendar
938 938
  */
939
-if ( ! function_exists( 'cal_days_in_month' ) ) {
939
+if ( ! function_exists('cal_days_in_month')) {
940 940
 	/**
941 941
 	 * cal_days_in_month
942 942
 	 *
@@ -946,8 +946,8 @@  discard block
 block discarded – undo
946 946
 	 *
947 947
 	 * @return bool|string
948 948
 	 */
949
-	function cal_days_in_month( $calendar, $month, $year ) {
950
-		return date( 't', mktime( 0, 0, 0, $month, 1, $year ) );
949
+	function cal_days_in_month($calendar, $month, $year) {
950
+		return date('t', mktime(0, 0, 0, $month, 1, $year));
951 951
 	}
952 952
 }
953 953
 
@@ -966,42 +966,42 @@  discard block
 block discarded – undo
966 966
  */
967 967
 function give_get_plugins() {
968 968
 	$plugins             = get_plugins();
969
-	$active_plugin_paths = (array) get_option( 'active_plugins', array() );
969
+	$active_plugin_paths = (array) get_option('active_plugins', array());
970 970
 
971
-	if ( is_multisite() ) {
972
-		$network_activated_plugin_paths = array_keys( get_site_option( 'active_sitewide_plugins', array() ) );
973
-		$active_plugin_paths            = array_merge( $active_plugin_paths, $network_activated_plugin_paths );
971
+	if (is_multisite()) {
972
+		$network_activated_plugin_paths = array_keys(get_site_option('active_sitewide_plugins', array()));
973
+		$active_plugin_paths            = array_merge($active_plugin_paths, $network_activated_plugin_paths);
974 974
 	}
975 975
 
976
-	foreach ( $plugins as $plugin_path => $plugin_data ) {
976
+	foreach ($plugins as $plugin_path => $plugin_data) {
977 977
 		// Is plugin active?
978
-		if ( in_array( $plugin_path, $active_plugin_paths ) ) {
979
-			$plugins[ $plugin_path ]['Status'] = 'active';
978
+		if (in_array($plugin_path, $active_plugin_paths)) {
979
+			$plugins[$plugin_path]['Status'] = 'active';
980 980
 		} else {
981
-			$plugins[ $plugin_path ]['Status'] = 'inactive';
981
+			$plugins[$plugin_path]['Status'] = 'inactive';
982 982
 		}
983 983
 
984
-		$dirname = strtolower( dirname( $plugin_path ) );
984
+		$dirname = strtolower(dirname($plugin_path));
985 985
 
986 986
 		// Is plugin a Give add-on by WordImpress?
987
-		if ( strstr( $dirname, 'give-' ) && strstr( $plugin_data['AuthorURI'], 'wordimpress.com' ) ) {
987
+		if (strstr($dirname, 'give-') && strstr($plugin_data['AuthorURI'], 'wordimpress.com')) {
988 988
 			// Plugin is a Give-addon.
989
-			$plugins[ $plugin_path ]['Type'] = 'add-on';
989
+			$plugins[$plugin_path]['Type'] = 'add-on';
990 990
 
991 991
 			// Get license info from database.
992
-			$plugin_name    = str_replace( 'Give - ', '', $plugin_data['Name'] );
993
-			$db_option      = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $plugin_name ) ) ) . '_license_active';
994
-			$license_active = get_option( $db_option );
992
+			$plugin_name    = str_replace('Give - ', '', $plugin_data['Name']);
993
+			$db_option      = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($plugin_name))).'_license_active';
994
+			$license_active = get_option($db_option);
995 995
 
996 996
 			// Does a valid license exist?
997
-			if ( ! empty( $license_active ) && 'valid' === $license_active->license ) {
998
-				$plugins[ $plugin_path ]['License'] = true;
997
+			if ( ! empty($license_active) && 'valid' === $license_active->license) {
998
+				$plugins[$plugin_path]['License'] = true;
999 999
 			} else {
1000
-				$plugins[ $plugin_path ]['License'] = false;
1000
+				$plugins[$plugin_path]['License'] = false;
1001 1001
 			}
1002 1002
 		} else {
1003 1003
 			// Plugin is not a Give add-on.
1004
-			$plugins[ $plugin_path ]['Type'] = 'other';
1004
+			$plugins[$plugin_path]['Type'] = 'other';
1005 1005
 		}
1006 1006
 	}
1007 1007
 
@@ -1018,16 +1018,16 @@  discard block
 block discarded – undo
1018 1018
  *
1019 1019
  * @return bool
1020 1020
  */
1021
-function give_is_terms_enabled( $form_id ) {
1022
-	$form_option = give_get_meta( $form_id, '_give_terms_option', true );
1021
+function give_is_terms_enabled($form_id) {
1022
+	$form_option = give_get_meta($form_id, '_give_terms_option', true);
1023 1023
 
1024 1024
 	if (
1025
-		give_is_setting_enabled( $form_option, 'global' )
1026
-		&& give_is_setting_enabled( give_get_option( 'terms' ) )
1025
+		give_is_setting_enabled($form_option, 'global')
1026
+		&& give_is_setting_enabled(give_get_option('terms'))
1027 1027
 	) {
1028 1028
 		return true;
1029 1029
 
1030
-	} elseif ( give_is_setting_enabled( $form_option ) ) {
1030
+	} elseif (give_is_setting_enabled($form_option)) {
1031 1031
 		return true;
1032 1032
 
1033 1033
 	} else {
@@ -1051,9 +1051,9 @@  discard block
 block discarded – undo
1051 1051
  *
1052 1052
  * @return WP_Error|bool
1053 1053
  */
1054
-function give_delete_donation_stats( $date_range = '', $args = array() ) {
1054
+function give_delete_donation_stats($date_range = '', $args = array()) {
1055 1055
 	// Delete all cache.
1056
-	$status = Give_Cache::delete( Give_Cache::get_options_like( 'give_stats' ) );
1056
+	$status = Give_Cache::delete(Give_Cache::get_options_like('give_stats'));
1057 1057
 
1058 1058
 	/**
1059 1059
 	 * Fire the action when donation stats delete.
@@ -1063,7 +1063,7 @@  discard block
 block discarded – undo
1063 1063
 	 * @param string|array $date_range
1064 1064
 	 * @param array  $args
1065 1065
 	 */
1066
-	do_action( 'give_delete_donation_stats', $status, $date_range, $args );
1066
+	do_action('give_delete_donation_stats', $status, $date_range, $args);
1067 1067
 
1068 1068
 	return $status;
1069 1069
 }
@@ -1081,7 +1081,7 @@  discard block
 block discarded – undo
1081 1081
  *
1082 1082
  * @return mixed
1083 1083
  */
1084
-function give_get_meta( $id, $meta_key, $single = false, $default = false ) {
1084
+function give_get_meta($id, $meta_key, $single = false, $default = false) {
1085 1085
 	/**
1086 1086
 	 * Filter the meta value
1087 1087
 	 *
@@ -1089,14 +1089,14 @@  discard block
 block discarded – undo
1089 1089
 	 */
1090 1090
 	$meta_value = apply_filters(
1091 1091
 			'give_get_meta',
1092
-			get_post_meta( $id, $meta_key, $single ),
1092
+			get_post_meta($id, $meta_key, $single),
1093 1093
 			$id,
1094 1094
 			$meta_key,
1095 1095
 			$default
1096 1096
 	);
1097 1097
 
1098 1098
 	if (
1099
-		( empty( $meta_key ) || empty( $meta_value ) )
1099
+		(empty($meta_key) || empty($meta_value))
1100 1100
 		&& $default
1101 1101
 	) {
1102 1102
 		$meta_value = $default;
@@ -1117,15 +1117,15 @@  discard block
 block discarded – undo
1117 1117
  *
1118 1118
  * @return mixed
1119 1119
  */
1120
-function give_update_meta( $id, $meta_key, $meta_value, $prev_value = '' ) {
1121
-	$status = update_post_meta( $id, $meta_key, $meta_value, $prev_value );
1120
+function give_update_meta($id, $meta_key, $meta_value, $prev_value = '') {
1121
+	$status = update_post_meta($id, $meta_key, $meta_value, $prev_value);
1122 1122
 
1123 1123
 	/**
1124 1124
 	 * Filter the meta value update status
1125 1125
 	 *
1126 1126
 	 * @since 1.8.8
1127 1127
 	 */
1128
-	return apply_filters( 'give_update_meta', $status, $id, $meta_key, $meta_value );
1128
+	return apply_filters('give_update_meta', $status, $id, $meta_key, $meta_value);
1129 1129
 }
1130 1130
 
1131 1131
 /**
@@ -1139,13 +1139,13 @@  discard block
 block discarded – undo
1139 1139
  *
1140 1140
  * @return mixed
1141 1141
  */
1142
-function give_delete_meta( $id, $meta_key, $meta_value = '' ) {
1143
-	$status = delete_post_meta( $id, $meta_key, $meta_value );
1142
+function give_delete_meta($id, $meta_key, $meta_value = '') {
1143
+	$status = delete_post_meta($id, $meta_key, $meta_value);
1144 1144
 
1145 1145
 	/**
1146 1146
 	 * Filter the meta value delete status
1147 1147
 	 *
1148 1148
 	 * @since 1.8.8
1149 1149
 	 */
1150
-	return apply_filters( 'give_delete_meta', $status, $id, $meta_key, $meta_value );
1150
+	return apply_filters('give_delete_meta', $status, $id, $meta_key, $meta_value);
1151 1151
 }
Please login to merge, or discard this patch.
includes/deprecated/deprecated-functions.php 1 patch
Spacing   +28 added lines, -28 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
 
@@ -27,15 +27,15 @@  discard block
 block discarded – undo
27 27
  *
28 28
  * @return bool $ret True if guest checkout is enabled, false otherwise
29 29
  */
30
-function give_no_guest_checkout( $form_id ) {
30
+function give_no_guest_checkout($form_id) {
31 31
 
32 32
 	$backtrace = debug_backtrace();
33 33
 
34
-	_give_deprecated_function( __FUNCTION__, '1.4.1', null, $backtrace );
34
+	_give_deprecated_function(__FUNCTION__, '1.4.1', null, $backtrace);
35 35
 
36
-	$ret = give_get_meta( $form_id, '_give_logged_in_only', true );
36
+	$ret = give_get_meta($form_id, '_give_logged_in_only', true);
37 37
 
38
-	return (bool) apply_filters( 'give_no_guest_checkout', give_is_setting_enabled( $ret ) );
38
+	return (bool) apply_filters('give_no_guest_checkout', give_is_setting_enabled($ret));
39 39
 }
40 40
 
41 41
 
@@ -50,15 +50,15 @@  discard block
 block discarded – undo
50 50
 
51 51
 	$backtrace = debug_backtrace();
52 52
 
53
-	_give_deprecated_function( __FUNCTION__, '1.8', null, $backtrace );
53
+	_give_deprecated_function(__FUNCTION__, '1.8', null, $backtrace);
54 54
 
55 55
 	$views = array(
56
-		'sales'          => __( 'Donations', 'give' ),
57
-		'gateway_errors' => __( 'Payment Errors', 'give' ),
58
-		'api_requests'   => __( 'API Requests', 'give' ),
56
+		'sales'          => __('Donations', 'give'),
57
+		'gateway_errors' => __('Payment Errors', 'give'),
58
+		'api_requests'   => __('API Requests', 'give'),
59 59
 	);
60 60
 
61
-	$views = apply_filters( 'give_log_views', $views );
61
+	$views = apply_filters('give_log_views', $views);
62 62
 
63 63
 	return $views;
64 64
 }
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 
74 74
 	$backtrace = debug_backtrace();
75 75
 
76
-	_give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_agree_to_terms', $backtrace );
76
+	_give_deprecated_function(__FUNCTION__, '1.8.8', 'give_donation_form_validate_agree_to_terms', $backtrace);
77 77
 
78 78
 	// Call new renamed function.
79 79
 	give_donation_form_validate_agree_to_terms();
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 
91 91
 	$backtrace = debug_backtrace();
92 92
 
93
-	_give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_logged_in_user', $backtrace );
93
+	_give_deprecated_function(__FUNCTION__, '1.8.8', 'give_donation_form_validate_logged_in_user', $backtrace);
94 94
 
95 95
 	// Call new renamed function.
96 96
 	give_donation_form_validate_logged_in_user();
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 
108 108
 	$backtrace = debug_backtrace();
109 109
 
110
-	_give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_gateway', $backtrace );
110
+	_give_deprecated_function(__FUNCTION__, '1.8.8', 'give_donation_form_validate_gateway', $backtrace);
111 111
 
112 112
 	// Call new renamed function.
113 113
 	give_donation_form_validate_gateway();
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 
125 125
 	$backtrace = debug_backtrace();
126 126
 
127
-	_give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_fields', $backtrace );
127
+	_give_deprecated_function(__FUNCTION__, '1.8.8', 'give_donation_form_validate_fields', $backtrace);
128 128
 
129 129
 	// Call new renamed function.
130 130
 	give_donation_form_validate_fields();
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 
142 142
 	$backtrace = debug_backtrace();
143 143
 
144
-	_give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_cc', $backtrace );
144
+	_give_deprecated_function(__FUNCTION__, '1.8.8', 'give_donation_form_validate_cc', $backtrace);
145 145
 
146 146
 	// Call new renamed function.
147 147
 	give_donation_form_validate_cc();
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 
159 159
 	$backtrace = debug_backtrace();
160 160
 
161
-	_give_deprecated_function( __FUNCTION__, '1.8.8', 'give_get_donation_cc_info', $backtrace );
161
+	_give_deprecated_function(__FUNCTION__, '1.8.8', 'give_get_donation_cc_info', $backtrace);
162 162
 
163 163
 	// Call new renamed function.
164 164
 	give_get_donation_cc_info();
@@ -175,14 +175,14 @@  discard block
 block discarded – undo
175 175
  * @param int $zip
176 176
  * @param string $country_code
177 177
  */
178
-function give_purchase_form_validate_cc_zip( $zip = 0, $country_code = '' ) {
178
+function give_purchase_form_validate_cc_zip($zip = 0, $country_code = '') {
179 179
 
180 180
 	$backtrace = debug_backtrace();
181 181
 
182
-	_give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_cc_zip', $backtrace );
182
+	_give_deprecated_function(__FUNCTION__, '1.8.8', 'give_donation_form_validate_cc_zip', $backtrace);
183 183
 
184 184
 	// Call new renamed function.
185
-	give_donation_form_validate_cc_zip( $zip, $country_code );
185
+	give_donation_form_validate_cc_zip($zip, $country_code);
186 186
 
187 187
 }
188 188
 
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 
197 197
 	$backtrace = debug_backtrace();
198 198
 
199
-	_give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_user_login', $backtrace );
199
+	_give_deprecated_function(__FUNCTION__, '1.8.8', 'give_donation_form_validate_user_login', $backtrace);
200 200
 
201 201
 	// Call new renamed function.
202 202
 	give_donation_form_validate_user_login();
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 
214 214
 	$backtrace = debug_backtrace();
215 215
 
216
-	_give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_guest_user', $backtrace );
216
+	_give_deprecated_function(__FUNCTION__, '1.8.8', 'give_donation_form_validate_guest_user', $backtrace);
217 217
 
218 218
 	// Call new renamed function.
219 219
 	give_donation_form_validate_guest_user();
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 
231 231
 	$backtrace = debug_backtrace();
232 232
 
233
-	_give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_new_user', $backtrace );
233
+	_give_deprecated_function(__FUNCTION__, '1.8.8', 'give_donation_form_validate_new_user', $backtrace);
234 234
 
235 235
 	// Call new renamed function.
236 236
 	give_donation_form_validate_new_user();
@@ -246,14 +246,14 @@  discard block
 block discarded – undo
246 246
  *
247 247
  * @param array $valid_data
248 248
  */
249
-function give_get_purchase_form_user( $valid_data = array() ) {
249
+function give_get_purchase_form_user($valid_data = array()) {
250 250
 
251 251
 	$backtrace = debug_backtrace();
252 252
 
253
-	_give_deprecated_function( __FUNCTION__, '1.8.8', 'give_get_donation_form_user', $backtrace );
253
+	_give_deprecated_function(__FUNCTION__, '1.8.8', 'give_get_donation_form_user', $backtrace);
254 254
 
255 255
 	// Call new renamed function.
256
-	give_get_donation_form_user( $valid_data );
256
+	give_get_donation_form_user($valid_data);
257 257
 
258 258
 }
259 259
 
@@ -269,11 +269,11 @@  discard block
 block discarded – undo
269 269
  *
270 270
  * @return string
271 271
  */
272
-function give_checkout_button_purchase( $form_id ) {
272
+function give_checkout_button_purchase($form_id) {
273 273
 	$backtrace = debug_backtrace();
274 274
 
275
-	_give_deprecated_function( __FUNCTION__, '1.8.8', 'give_get_donation_form_submit_button', $backtrace );
275
+	_give_deprecated_function(__FUNCTION__, '1.8.8', 'give_get_donation_form_submit_button', $backtrace);
276 276
 
277
-	return give_get_donation_form_submit_button( $form_id );
277
+	return give_get_donation_form_submit_button($form_id);
278 278
 
279 279
 }
Please login to merge, or discard this patch.
includes/deprecated/deprecated-filters.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
 
8 8
 $give_map_deprecated_filters = give_deprecated_filters();
9 9
 
10
-foreach ( $give_map_deprecated_filters as $new => $old ) {
11
-	add_filter( $new, 'give_deprecated_filter_mapping', 10, 4 );
10
+foreach ($give_map_deprecated_filters as $new => $old) {
11
+	add_filter($new, 'give_deprecated_filter_mapping', 10, 4);
12 12
 }
13 13
 
14 14
 /**
@@ -57,20 +57,20 @@  discard block
 block discarded – undo
57 57
  *
58 58
  * @return mixed
59 59
  */
60
-function give_deprecated_filter_mapping( $data, $arg_1 = '', $arg_2 = '', $arg_3 = '' ) {
60
+function give_deprecated_filter_mapping($data, $arg_1 = '', $arg_2 = '', $arg_3 = '') {
61 61
 	$give_map_deprecated_filters = give_deprecated_filters();
62 62
 	$filter                      = current_filter();
63 63
 
64
-	if ( isset( $give_map_deprecated_filters[ $filter ] ) ) {
65
-		if ( has_filter( $give_map_deprecated_filters[ $filter ] ) ) {
66
-			$data = apply_filters( $give_map_deprecated_filters[ $filter ], $data, $arg_1, $arg_2, $arg_3 );
64
+	if (isset($give_map_deprecated_filters[$filter])) {
65
+		if (has_filter($give_map_deprecated_filters[$filter])) {
66
+			$data = apply_filters($give_map_deprecated_filters[$filter], $data, $arg_1, $arg_2, $arg_3);
67 67
 
68
-			if ( ! defined( 'DOING_AJAX' ) ) {
68
+			if ( ! defined('DOING_AJAX')) {
69 69
 				_give_deprecated_function(
70 70
 					sprintf(
71 71
 					/* translators: %s: filter name */
72
-						__( 'The %s filter' ),
73
-						$give_map_deprecated_filters[ $filter ]
72
+						__('The %s filter'),
73
+						$give_map_deprecated_filters[$filter]
74 74
 					),
75 75
 					'1.7',
76 76
 					$filter
Please login to merge, or discard this patch.
includes/process-donation.php 1 patch
Spacing   +239 added lines, -239 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @since 1.0
32 32
 	 */
33
-	do_action( 'give_pre_process_donation' );
33
+	do_action('give_pre_process_donation');
34 34
 
35 35
 	// Validate the form $_POST data
36 36
 	$valid_data = give_donation_form_validate_fields();
@@ -45,26 +45,26 @@  discard block
 block discarded – undo
45 45
 	 * @param bool|array $valid_data Validate fields.
46 46
 	 * @param array $_POST Array of variables passed via the HTTP POST.
47 47
 	 */
48
-	do_action( 'give_checkout_error_checks', $valid_data, $_POST );
48
+	do_action('give_checkout_error_checks', $valid_data, $_POST);
49 49
 
50
-	$is_ajax = isset( $_POST['give_ajax'] );
50
+	$is_ajax = isset($_POST['give_ajax']);
51 51
 
52 52
 	// Process the login form
53
-	if ( isset( $_POST['give_login_submit'] ) ) {
53
+	if (isset($_POST['give_login_submit'])) {
54 54
 		give_process_form_login();
55 55
 	}
56 56
 
57 57
 	// Validate the user
58
-	$user = give_get_donation_form_user( $valid_data );
58
+	$user = give_get_donation_form_user($valid_data);
59 59
 
60
-	if ( false === $valid_data || give_get_errors() || ! $user ) {
61
-		if ( $is_ajax ) {
60
+	if (false === $valid_data || give_get_errors() || ! $user) {
61
+		if ($is_ajax) {
62 62
 			/**
63 63
 			 * Fires when AJAX sends back errors from the donation form.
64 64
 			 *
65 65
 			 * @since 1.0
66 66
 			 */
67
-			do_action( 'give_ajax_donation_errors' );
67
+			do_action('give_ajax_donation_errors');
68 68
 			give_die();
69 69
 		} else {
70 70
 			return false;
@@ -72,17 +72,17 @@  discard block
 block discarded – undo
72 72
 	}
73 73
 
74 74
 	// If AJAX send back success to proceed with form submission
75
-	if ( $is_ajax ) {
75
+	if ($is_ajax) {
76 76
 		echo 'success';
77 77
 		give_die();
78 78
 	}
79 79
 
80 80
 	// After AJAX: Setup session if not using php_sessions
81
-	if ( ! Give()->session->use_php_sessions() ) {
81
+	if ( ! Give()->session->use_php_sessions()) {
82 82
 		// Double-check that set_cookie is publicly accessible;
83 83
 		// we're using a slightly modified class-wp-sessions.php
84
-		$session_reflection = new ReflectionMethod( 'WP_Session', 'set_cookie' );
85
-		if ( $session_reflection->isPublic() ) {
84
+		$session_reflection = new ReflectionMethod('WP_Session', 'set_cookie');
85
+		if ($session_reflection->isPublic()) {
86 86
 			// Manually set the cookie.
87 87
 			Give()->session->init()->set_cookie();
88 88
 		}
@@ -97,18 +97,18 @@  discard block
 block discarded – undo
97 97
 		'address'    => $user['address'],
98 98
 	);
99 99
 
100
-	$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
100
+	$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
101 101
 
102
-	$price        = isset( $_POST['give-amount'] ) ? (float) apply_filters( 'give_donation_total', give_sanitize_amount( give_format_amount( $_POST['give-amount'] ) ) ) : '0.00';
103
-	$purchase_key = strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) );
102
+	$price        = isset($_POST['give-amount']) ? (float) apply_filters('give_donation_total', give_sanitize_amount(give_format_amount($_POST['give-amount']))) : '0.00';
103
+	$purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true)));
104 104
 
105 105
 	// Setup donation information
106 106
 	$donation_data = array(
107 107
 		'price'        => $price,
108 108
 		'purchase_key' => $purchase_key,
109 109
 		'user_email'   => $user['user_email'],
110
-		'date'         => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ),
111
-		'user_info'    => stripslashes_deep( $user_info ),
110
+		'date'         => date('Y-m-d H:i:s', current_time('timestamp')),
111
+		'user_info'    => stripslashes_deep($user_info),
112 112
 		'post_data'    => $_POST,
113 113
 		'gateway'      => $valid_data['gateway'],
114 114
 		'card_info'    => $valid_data['cc_info'],
@@ -128,10 +128,10 @@  discard block
 block discarded – undo
128 128
 	 * @param array $user_info Array containing basic user information.
129 129
 	 * @param bool|array $valid_data Validate fields.
130 130
 	 */
131
-	do_action( 'give_checkout_before_gateway', $_POST, $user_info, $valid_data );
131
+	do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data);
132 132
 
133 133
 	// Sanity check for price
134
-	if ( ! $donation_data['price'] ) {
134
+	if ( ! $donation_data['price']) {
135 135
 		// Revert to manual
136 136
 		$donation_data['gateway'] = 'manual';
137 137
 		$_POST['give-gateway']    = 'manual';
@@ -142,27 +142,27 @@  discard block
 block discarded – undo
142 142
 	 *
143 143
 	 * @since 1.7
144 144
 	 */
145
-	$donation_data = apply_filters( 'give_donation_data_before_gateway', $donation_data, $valid_data );
145
+	$donation_data = apply_filters('give_donation_data_before_gateway', $donation_data, $valid_data);
146 146
 
147 147
 	// Setup the data we're storing in the donation session
148 148
 	$session_data = $donation_data;
149 149
 
150 150
 	// Make sure credit card numbers are never stored in sessions
151
-	unset( $session_data['card_info']['card_number'] );
152
-	unset( $session_data['post_data']['card_number'] );
151
+	unset($session_data['card_info']['card_number']);
152
+	unset($session_data['post_data']['card_number']);
153 153
 
154 154
 	// Used for showing data to non logged-in users after donation, and for other plugins needing donation data.
155
-	give_set_purchase_session( $session_data );
155
+	give_set_purchase_session($session_data);
156 156
 
157 157
 	// Send info to the gateway for payment processing
158
-	give_send_to_gateway( $donation_data['gateway'], $donation_data );
158
+	give_send_to_gateway($donation_data['gateway'], $donation_data);
159 159
 	give_die();
160 160
 
161 161
 }
162 162
 
163
-add_action( 'give_purchase', 'give_process_donation_form' );
164
-add_action( 'wp_ajax_give_process_donation', 'give_process_donation_form' );
165
-add_action( 'wp_ajax_nopriv_give_process_donation', 'give_process_donation_form' );
163
+add_action('give_purchase', 'give_process_donation_form');
164
+add_action('wp_ajax_give_process_donation', 'give_process_donation_form');
165
+add_action('wp_ajax_nopriv_give_process_donation', 'give_process_donation_form');
166 166
 
167 167
 
168 168
 /**
@@ -175,29 +175,29 @@  discard block
 block discarded – undo
175 175
  *
176 176
  * @return void
177 177
  */
178
-function give_check_logged_in_user_for_existing_email( $valid_data, $post ) {
178
+function give_check_logged_in_user_for_existing_email($valid_data, $post) {
179 179
 
180 180
 	// Verify that the email address belongs to this customer.
181
-	if ( is_user_logged_in() ) {
181
+	if (is_user_logged_in()) {
182 182
 
183
-		$submitted_email    = $valid_data['logged_in_user']['user_email'];
184
-		$customer = new Give_Customer( get_current_user_id(), true );
183
+		$submitted_email = $valid_data['logged_in_user']['user_email'];
184
+		$customer = new Give_Customer(get_current_user_id(), true);
185 185
 
186 186
 		// If this email address is not registered with this customer, see if it belongs to any other customer
187 187
 		if (
188 188
 			$submitted_email !== $customer->email
189
-			&& ( is_array( $customer->emails ) && ! in_array( $submitted_email, $customer->emails ) )
189
+			&& (is_array($customer->emails) && ! in_array($submitted_email, $customer->emails))
190 190
 		) {
191
-			$found_customer = new Give_Customer( $submitted_email );
191
+			$found_customer = new Give_Customer($submitted_email);
192 192
 
193
-			if ( $found_customer->id > 0 ) {
194
-				give_set_error( 'give-customer-email-exists', sprintf( __( 'You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.' ), $customer->email, $submitted_email ) );
193
+			if ($found_customer->id > 0) {
194
+				give_set_error('give-customer-email-exists', sprintf(__('You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.'), $customer->email, $submitted_email));
195 195
 			}
196 196
 		}
197 197
 	}
198 198
 }
199 199
 
200
-add_action( 'give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2 );
200
+add_action('give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2);
201 201
 
202 202
 /**
203 203
  * Process the checkout login form
@@ -208,37 +208,37 @@  discard block
 block discarded – undo
208 208
  */
209 209
 function give_process_form_login() {
210 210
 
211
-	$is_ajax = isset( $_POST['give_ajax'] );
211
+	$is_ajax = isset($_POST['give_ajax']);
212 212
 
213 213
 	$user_data = give_donation_form_validate_user_login();
214 214
 
215
-	if ( give_get_errors() || $user_data['user_id'] < 1 ) {
216
-		if ( $is_ajax ) {
215
+	if (give_get_errors() || $user_data['user_id'] < 1) {
216
+		if ($is_ajax) {
217 217
 			/**
218 218
 			 * Fires when AJAX sends back errors from the donation form.
219 219
 			 *
220 220
 			 * @since 1.0
221 221
 			 */
222
-			do_action( 'give_ajax_donation_errors' );
222
+			do_action('give_ajax_donation_errors');
223 223
 			give_die();
224 224
 		} else {
225
-			wp_redirect( $_SERVER['HTTP_REFERER'] );
225
+			wp_redirect($_SERVER['HTTP_REFERER']);
226 226
 			exit;
227 227
 		}
228 228
 	}
229 229
 
230
-	give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] );
230
+	give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']);
231 231
 
232
-	if ( $is_ajax ) {
232
+	if ($is_ajax) {
233 233
 		echo 'success';
234 234
 		give_die();
235 235
 	} else {
236
-		wp_redirect( $_SERVER['HTTP_REFERER'] );
236
+		wp_redirect($_SERVER['HTTP_REFERER']);
237 237
 	}
238 238
 }
239 239
 
240
-add_action( 'wp_ajax_give_process_donation_login', 'give_process_form_login' );
241
-add_action( 'wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login' );
240
+add_action('wp_ajax_give_process_donation_login', 'give_process_form_login');
241
+add_action('wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login');
242 242
 
243 243
 /**
244 244
  * Donation Form Validate Fields.
@@ -250,55 +250,55 @@  discard block
 block discarded – undo
250 250
 function give_donation_form_validate_fields() {
251 251
 
252 252
 	// Check if there is $_POST
253
-	if ( empty( $_POST ) ) {
253
+	if (empty($_POST)) {
254 254
 		return false;
255 255
 	}
256 256
 
257
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
257
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
258 258
 
259 259
 	// Start an array to collect valid data
260 260
 	$valid_data = array(
261 261
 		'gateway'          => give_donation_form_validate_gateway(), // Gateway fallback (amount is validated here)
262
-		'need_new_user'    => false,     // New user flag
263
-		'need_user_login'  => false,     // Login user flag
264
-		'logged_user_data' => array(),   // Logged user collected data
265
-		'new_user_data'    => array(),   // New user collected data
266
-		'login_user_data'  => array(),   // Login user collected data
267
-		'guest_user_data'  => array(),   // Guest user collected data
268
-		'cc_info'          => give_donation_form_validate_cc(),// Credit card info
262
+		'need_new_user'    => false, // New user flag
263
+		'need_user_login'  => false, // Login user flag
264
+		'logged_user_data' => array(), // Logged user collected data
265
+		'new_user_data'    => array(), // New user collected data
266
+		'login_user_data'  => array(), // Login user collected data
267
+		'guest_user_data'  => array(), // Guest user collected data
268
+		'cc_info'          => give_donation_form_validate_cc(), // Credit card info
269 269
 	);
270 270
 
271 271
 	// Validate Honeypot First
272
-	if ( ! empty( $_POST['give-honeypot'] ) ) {
273
-		give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) );
272
+	if ( ! empty($_POST['give-honeypot'])) {
273
+		give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give'));
274 274
 	}
275 275
 
276 276
 	// Validate agree to terms
277
-	if ( give_is_terms_enabled( $form_id ) ) {
277
+	if (give_is_terms_enabled($form_id)) {
278 278
 		give_donation_form_validate_agree_to_terms();
279 279
 	}
280 280
 
281 281
 	// Stop processing donor registration, if donor registration is optional and donor can do guest checkout.
282 282
 	// If registration form username field is empty that means donor do not want to registration instead want guest checkout.
283 283
 	if (
284
-		! give_logged_in_only( $form_id )
285
-		&& isset( $_POST['give-purchase-var'] )
284
+		! give_logged_in_only($form_id)
285
+		&& isset($_POST['give-purchase-var'])
286 286
 		&& $_POST['give-purchase-var'] == 'needs-to-register'
287
-		&& empty( $_POST['give_user_login'] )
287
+		&& empty($_POST['give_user_login'])
288 288
 	) {
289
-		unset( $_POST['give-purchase-var'] );
289
+		unset($_POST['give-purchase-var']);
290 290
 	}
291 291
 
292
-	if ( is_user_logged_in() ) {
292
+	if (is_user_logged_in()) {
293 293
 		// Collect logged in user data.
294 294
 		$valid_data['logged_in_user'] = give_donation_form_validate_logged_in_user();
295
-	} elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) {
295
+	} elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') {
296 296
 		// Set new user registration as required.
297 297
 		$valid_data['need_new_user'] = true;
298 298
 		// Validate new user data.
299 299
 		$valid_data['new_user_data'] = give_donation_form_validate_new_user();
300 300
 		// Check if login validation is needed.
301
-	} elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) {
301
+	} elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') {
302 302
 		// Set user login as required.
303 303
 		$valid_data['need_user_login'] = true;
304 304
 		// Validate users login info.
@@ -323,41 +323,41 @@  discard block
 block discarded – undo
323 323
  */
324 324
 function give_donation_form_validate_gateway() {
325 325
 
326
-	$form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
327
-	$amount  = isset( $_REQUEST['give-amount'] ) ? give_sanitize_amount( $_REQUEST['give-amount'] ) : 0;
328
-	$gateway = give_get_default_gateway( $form_id );
326
+	$form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
327
+	$amount  = isset($_REQUEST['give-amount']) ? give_sanitize_amount($_REQUEST['give-amount']) : 0;
328
+	$gateway = give_get_default_gateway($form_id);
329 329
 
330 330
 	// Check if a gateway value is present.
331
-	if ( ! empty( $_REQUEST['give-gateway'] ) ) {
331
+	if ( ! empty($_REQUEST['give-gateway'])) {
332 332
 
333
-		$gateway = sanitize_text_field( $_REQUEST['give-gateway'] );
333
+		$gateway = sanitize_text_field($_REQUEST['give-gateway']);
334 334
 
335 335
 		// Is amount being donated in LIVE mode 0.00? If so, error:
336
-		if ( $amount == 0 && ! give_is_test_mode() ) {
336
+		if ($amount == 0 && ! give_is_test_mode()) {
337 337
 
338
-			give_set_error( 'invalid_donation_amount', __( 'Please insert a valid donation amount.', 'give' ) );
338
+			give_set_error('invalid_donation_amount', __('Please insert a valid donation amount.', 'give'));
339 339
 
340 340
 		} // End if().
341
-		elseif ( ! give_verify_minimum_price() ) {
341
+		elseif ( ! give_verify_minimum_price()) {
342 342
 			// translators: %s: minimum donation amount.
343 343
 			give_set_error(
344 344
 				'invalid_donation_minimum',
345 345
 				sprintf(
346 346
 					/* translators: %s: minimum donation amount */
347
-					__( 'This form has a minimum donation amount of %s.', 'give' ),
348
-					give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ) ) )
347
+					__('This form has a minimum donation amount of %s.', 'give'),
348
+					give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id)))
349 349
 				)
350 350
 			);
351 351
 
352 352
 		} //Is this test mode zero donation? Let it through but set to manual gateway.
353
-		elseif ( $amount == 0 && give_is_test_mode() ) {
353
+		elseif ($amount == 0 && give_is_test_mode()) {
354 354
 
355 355
 			$gateway = 'manual';
356 356
 
357 357
 		} //Check if this gateway is active.
358
-		elseif ( ! give_is_gateway_active( $gateway ) ) {
358
+		elseif ( ! give_is_gateway_active($gateway)) {
359 359
 
360
-			give_set_error( 'invalid_gateway', __( 'The selected payment gateway is not enabled.', 'give' ) );
360
+			give_set_error('invalid_gateway', __('The selected payment gateway is not enabled.', 'give'));
361 361
 
362 362
 		}
363 363
 	}
@@ -375,21 +375,21 @@  discard block
 block discarded – undo
375 375
  */
376 376
 function give_verify_minimum_price() {
377 377
 
378
-	$amount          = give_sanitize_amount( $_REQUEST['give-amount'] );
379
-	$form_id         = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
380
-	$price_id        = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : null;
381
-	$variable_prices = give_has_variable_prices( $form_id );
378
+	$amount          = give_sanitize_amount($_REQUEST['give-amount']);
379
+	$form_id         = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
380
+	$price_id        = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : null;
381
+	$variable_prices = give_has_variable_prices($form_id);
382 382
 
383
-	if ( $variable_prices && in_array( $price_id, give_get_variable_price_ids( $form_id ) ) ) {
383
+	if ($variable_prices && in_array($price_id, give_get_variable_price_ids($form_id))) {
384 384
 
385
-		$price_level_amount = give_get_price_option_amount( $form_id, $price_id );
385
+		$price_level_amount = give_get_price_option_amount($form_id, $price_id);
386 386
 
387
-		if ( $price_level_amount == $amount ) {
387
+		if ($price_level_amount == $amount) {
388 388
 			return true;
389 389
 		}
390 390
 	}
391 391
 
392
-	if ( give_get_form_minimum_price( $form_id ) > $amount ) {
392
+	if (give_get_form_minimum_price($form_id) > $amount) {
393 393
 		return false;
394 394
 	}
395 395
 
@@ -405,9 +405,9 @@  discard block
 block discarded – undo
405 405
  */
406 406
 function give_donation_form_validate_agree_to_terms() {
407 407
 	// Validate agree to terms.
408
-	if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) {
408
+	if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) {
409 409
 		// User did not agree.
410
-		give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', __( 'You must agree to the terms and conditions.', 'give' ) ) );
410
+		give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', __('You must agree to the terms and conditions.', 'give')));
411 411
 	}
412 412
 }
413 413
 
@@ -421,43 +421,43 @@  discard block
 block discarded – undo
421 421
  *
422 422
  * @return      array
423 423
  */
424
-function give_get_required_fields( $form_id ) {
424
+function give_get_required_fields($form_id) {
425 425
 
426
-	$payment_mode = give_get_chosen_gateway( $form_id );
426
+	$payment_mode = give_get_chosen_gateway($form_id);
427 427
 
428 428
 	$required_fields = array(
429 429
 		'give_email' => array(
430 430
 			'error_id'      => 'invalid_email',
431
-			'error_message' => __( 'Please enter a valid email address.', 'give' ),
431
+			'error_message' => __('Please enter a valid email address.', 'give'),
432 432
 		),
433 433
 		'give_first' => array(
434 434
 			'error_id'      => 'invalid_first_name',
435
-			'error_message' => __( 'Please enter your first name.', 'give' ),
435
+			'error_message' => __('Please enter your first name.', 'give'),
436 436
 		),
437 437
 	);
438 438
 
439
-	$require_address = give_require_billing_address( $payment_mode );
439
+	$require_address = give_require_billing_address($payment_mode);
440 440
 
441
-	if ( $require_address ) {
442
-		$required_fields['card_address']    = array(
441
+	if ($require_address) {
442
+		$required_fields['card_address'] = array(
443 443
 			'error_id'      => 'invalid_card_address',
444
-			'error_message' => __( 'Please enter your primary billing address.', 'give' ),
444
+			'error_message' => __('Please enter your primary billing address.', 'give'),
445 445
 		);
446
-		$required_fields['card_zip']        = array(
446
+		$required_fields['card_zip'] = array(
447 447
 			'error_id'      => 'invalid_zip_code',
448
-			'error_message' => __( 'Please enter your zip / postal code.', 'give' ),
448
+			'error_message' => __('Please enter your zip / postal code.', 'give'),
449 449
 		);
450
-		$required_fields['card_city']       = array(
450
+		$required_fields['card_city'] = array(
451 451
 			'error_id'      => 'invalid_city',
452
-			'error_message' => __( 'Please enter your billing city.', 'give' ),
452
+			'error_message' => __('Please enter your billing city.', 'give'),
453 453
 		);
454 454
 		$required_fields['billing_country'] = array(
455 455
 			'error_id'      => 'invalid_country',
456
-			'error_message' => __( 'Please select your billing country.', 'give' ),
456
+			'error_message' => __('Please select your billing country.', 'give'),
457 457
 		);
458
-		$required_fields['card_state']      = array(
458
+		$required_fields['card_state'] = array(
459 459
 			'error_id'      => 'invalid_state',
460
-			'error_message' => __( 'Please enter billing state / province.', 'give' ),
460
+			'error_message' => __('Please enter billing state / province.', 'give'),
461 461
 		);
462 462
 	}
463 463
 
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 	 *
467 467
 	 * @since 1.7
468 468
 	 */
469
-	$required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id );
469
+	$required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id);
470 470
 
471 471
 	return $required_fields;
472 472
 
@@ -481,16 +481,16 @@  discard block
 block discarded – undo
481 481
  *
482 482
  * @return bool
483 483
  */
484
-function give_require_billing_address( $payment_mode ) {
484
+function give_require_billing_address($payment_mode) {
485 485
 
486 486
 	$return = false;
487 487
 
488
-	if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) {
488
+	if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) {
489 489
 		$return = true;
490 490
 	}
491 491
 
492 492
 	// Let payment gateways and other extensions determine if address fields should be required.
493
-	return apply_filters( 'give_require_billing_address', $return );
493
+	return apply_filters('give_require_billing_address', $return);
494 494
 
495 495
 }
496 496
 
@@ -504,42 +504,42 @@  discard block
 block discarded – undo
504 504
 function give_donation_form_validate_logged_in_user() {
505 505
 	global $user_ID;
506 506
 
507
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
507
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
508 508
 
509 509
 	// Start empty array to collect valid user data.
510 510
 	$valid_user_data = array(
511 511
 		// Assume there will be errors.
512
-		'user_id' => - 1,
512
+		'user_id' => -1,
513 513
 	);
514 514
 
515 515
 	// Verify there is a user_ID.
516
-	if ( $user_ID > 0 ) {
516
+	if ($user_ID > 0) {
517 517
 		// Get the logged in user data.
518
-		$user_data = get_userdata( $user_ID );
518
+		$user_data = get_userdata($user_ID);
519 519
 
520 520
 		// Loop through required fields and show error messages.
521
-		foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
522
-			if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
523
-				give_set_error( $value['error_id'], $value['error_message'] );
521
+		foreach (give_get_required_fields($form_id) as $field_name => $value) {
522
+			if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
523
+				give_set_error($value['error_id'], $value['error_message']);
524 524
 			}
525 525
 		}
526 526
 
527 527
 		// Verify data.
528
-		if ( $user_data ) {
528
+		if ($user_data) {
529 529
 			// Collected logged in user data.
530 530
 			$valid_user_data = array(
531 531
 				'user_id'    => $user_ID,
532
-				'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email,
533
-				'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name,
534
-				'user_last'  => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name,
532
+				'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email,
533
+				'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name,
534
+				'user_last'  => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name,
535 535
 			);
536 536
 
537
-			if ( ! is_email( $valid_user_data['user_email'] ) ) {
538
-				give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
537
+			if ( ! is_email($valid_user_data['user_email'])) {
538
+				give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
539 539
 			}
540 540
 		} else {
541 541
 			// Set invalid user error.
542
-			give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) );
542
+			give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give'));
543 543
 		}
544 544
 	}
545 545
 
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
 	// Default user data.
559 559
 	$default_user_data = array(
560 560
 		'give-form-id'           => '',
561
-		'user_id'                => - 1, // Assume there will be errors.
561
+		'user_id'                => -1, // Assume there will be errors.
562 562
 		'user_first'             => '',
563 563
 		'user_last'              => '',
564 564
 		'give_user_login'        => false,
@@ -568,14 +568,14 @@  discard block
 block discarded – undo
568 568
 	);
569 569
 
570 570
 	// Get user data.
571
-	$user_data            = wp_parse_args( array_map( 'trim', give_clean( $_POST ) ), $default_user_data );
571
+	$user_data            = wp_parse_args(array_map('trim', give_clean($_POST)), $default_user_data);
572 572
 	$registering_new_user = false;
573
-	$form_id              = absint( $user_data['give-form-id'] );
573
+	$form_id              = absint($user_data['give-form-id']);
574 574
 
575 575
 	// Start an empty array to collect valid user data.
576 576
 	$valid_user_data = array(
577 577
 		// Assume there will be errors.
578
-		'user_id'    => - 1,
578
+		'user_id'    => -1,
579 579
 
580 580
 		// Get first name.
581 581
 		'user_first' => $user_data['give_first'],
@@ -585,25 +585,25 @@  discard block
 block discarded – undo
585 585
 	);
586 586
 
587 587
 	// Loop through required fields and show error messages.
588
-	foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
589
-		if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
590
-			give_set_error( $value['error_id'], $value['error_message'] );
588
+	foreach (give_get_required_fields($form_id) as $field_name => $value) {
589
+		if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
590
+			give_set_error($value['error_id'], $value['error_message']);
591 591
 		}
592 592
 	}
593 593
 
594 594
 	// Check if we have an username to register.
595
-	if ( give_validate_username( $user_data['give_user_login'] ) ) {
595
+	if (give_validate_username($user_data['give_user_login'])) {
596 596
 		$registering_new_user          = true;
597 597
 		$valid_user_data['user_login'] = $user_data['give_user_login'];
598 598
 	}
599 599
 
600 600
 	// Check if we have an email to verify.
601
-	if ( give_validate_user_email( $user_data['give_email'], $registering_new_user ) ) {
601
+	if (give_validate_user_email($user_data['give_email'], $registering_new_user)) {
602 602
 		$valid_user_data['user_email'] = $user_data['give_email'];
603 603
 	}
604 604
 
605 605
 	// Check password.
606
-	if ( give_validate_user_password( $user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user ) ) {
606
+	if (give_validate_user_password($user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user)) {
607 607
 		// All is good to go.
608 608
 		$valid_user_data['user_pass'] = $user_data['give_user_pass'];
609 609
 	}
@@ -623,36 +623,36 @@  discard block
 block discarded – undo
623 623
 	// Start an array to collect valid user data.
624 624
 	$valid_user_data = array(
625 625
 		// Assume there will be errors.
626
-		'user_id' => - 1,
626
+		'user_id' => -1,
627 627
 	);
628 628
 
629 629
 	// Username.
630
-	if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) {
631
-		give_set_error( 'must_log_in', __( 'You must register or login to complete your donation.', 'give' ) );
630
+	if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') {
631
+		give_set_error('must_log_in', __('You must register or login to complete your donation.', 'give'));
632 632
 
633 633
 		return $valid_user_data;
634 634
 	}
635 635
 
636 636
 	// Get the user by login.
637
-	$user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) );
637
+	$user_data = get_user_by('login', strip_tags($_POST['give_user_login']));
638 638
 
639 639
 	// Check if user exists.
640
-	if ( $user_data ) {
640
+	if ($user_data) {
641 641
 		// Get password.
642
-		$user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false;
642
+		$user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false;
643 643
 
644 644
 		// Check user_pass.
645
-		if ( $user_pass ) {
645
+		if ($user_pass) {
646 646
 			// Check if password is valid.
647
-			if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) {
647
+			if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) {
648 648
 				// Incorrect password.
649 649
 				give_set_error(
650 650
 					'password_incorrect',
651 651
 					sprintf(
652 652
 						'%1$s <a href="%2$s">%3$s</a>',
653
-						__( 'The password you entered is incorrect.', 'give' ),
654
-						wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ),
655
-						__( 'Reset Password', 'give' )
653
+						__('The password you entered is incorrect.', 'give'),
654
+						wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"),
655
+						__('Reset Password', 'give')
656 656
 					)
657 657
 				);
658 658
 				// All is correct.
@@ -669,11 +669,11 @@  discard block
 block discarded – undo
669 669
 			}
670 670
 		} else {
671 671
 			// Empty password.
672
-			give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) );
672
+			give_set_error('password_empty', __('Enter a password.', 'give'));
673 673
 		}
674 674
 	} else {
675 675
 		// No username.
676
-		give_set_error( 'username_incorrect', __( 'The username you entered does not exist.', 'give' ) );
676
+		give_set_error('username_incorrect', __('The username you entered does not exist.', 'give'));
677 677
 	}// End if().
678 678
 
679 679
 	return $valid_user_data;
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
  */
689 689
 function give_donation_form_validate_guest_user() {
690 690
 
691
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
691
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
692 692
 
693 693
 	// Start an array to collect valid user data.
694 694
 	$valid_user_data = array(
@@ -697,38 +697,38 @@  discard block
 block discarded – undo
697 697
 	);
698 698
 
699 699
 	// Show error message if user must be logged in.
700
-	if ( give_logged_in_only( $form_id ) ) {
701
-		give_set_error( 'logged_in_only', __( 'You must be logged in to donate.', 'give' ) );
700
+	if (give_logged_in_only($form_id)) {
701
+		give_set_error('logged_in_only', __('You must be logged in to donate.', 'give'));
702 702
 	}
703 703
 
704 704
 	// Get the guest email.
705
-	$guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false;
705
+	$guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false;
706 706
 
707 707
 	// Check email.
708
-	if ( $guest_email && strlen( $guest_email ) > 0 ) {
708
+	if ($guest_email && strlen($guest_email) > 0) {
709 709
 		// Validate email.
710
-		if ( ! is_email( $guest_email ) ) {
710
+		if ( ! is_email($guest_email)) {
711 711
 			// Invalid email.
712
-			give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) );
712
+			give_set_error('email_invalid', __('Invalid email.', 'give'));
713 713
 		} else {
714 714
 			// All is good to go.
715 715
 			$valid_user_data['user_email'] = $guest_email;
716 716
 
717 717
 			// Get user_id from donor if exist.
718
-			$donor = new Give_Customer( $guest_email );
719
-			if ( $donor->id && $donor->user_id ) {
718
+			$donor = new Give_Customer($guest_email);
719
+			if ($donor->id && $donor->user_id) {
720 720
 				$valid_user_data['user_id'] = $donor->user_id;
721 721
 			}
722 722
 		}
723 723
 	} else {
724 724
 		// No email.
725
-		give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) );
725
+		give_set_error('email_empty', __('Enter an email.', 'give'));
726 726
 	}
727 727
 
728 728
 	// Loop through required fields and show error messages.
729
-	foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
730
-		if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
731
-			give_set_error( $value['error_id'], $value['error_message'] );
729
+	foreach (give_get_required_fields($form_id) as $field_name => $value) {
730
+		if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
731
+			give_set_error($value['error_id'], $value['error_message']);
732 732
 		}
733 733
 	}
734 734
 
@@ -744,36 +744,36 @@  discard block
 block discarded – undo
744 744
  * @since   1.0
745 745
  * @return  integer
746 746
  */
747
-function give_register_and_login_new_user( $user_data = array() ) {
747
+function give_register_and_login_new_user($user_data = array()) {
748 748
 	// Verify the array.
749
-	if ( empty( $user_data ) ) {
750
-		return - 1;
749
+	if (empty($user_data)) {
750
+		return -1;
751 751
 	}
752 752
 
753
-	if ( give_get_errors() ) {
754
-		return - 1;
753
+	if (give_get_errors()) {
754
+		return -1;
755 755
 	}
756 756
 
757
-	$user_args = apply_filters( 'give_insert_user_args', array(
758
-		'user_login'      => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '',
759
-		'user_pass'       => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '',
760
-		'user_email'      => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '',
761
-		'first_name'      => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '',
762
-		'last_name'       => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '',
763
-		'user_registered' => date( 'Y-m-d H:i:s' ),
764
-		'role'            => get_option( 'default_role' ),
765
-	), $user_data );
757
+	$user_args = apply_filters('give_insert_user_args', array(
758
+		'user_login'      => isset($user_data['user_login']) ? $user_data['user_login'] : '',
759
+		'user_pass'       => isset($user_data['user_pass']) ? $user_data['user_pass'] : '',
760
+		'user_email'      => isset($user_data['user_email']) ? $user_data['user_email'] : '',
761
+		'first_name'      => isset($user_data['user_first']) ? $user_data['user_first'] : '',
762
+		'last_name'       => isset($user_data['user_last']) ? $user_data['user_last'] : '',
763
+		'user_registered' => date('Y-m-d H:i:s'),
764
+		'role'            => get_option('default_role'),
765
+	), $user_data);
766 766
 
767 767
 	// Insert new user.
768
-	$user_id = wp_insert_user( $user_args );
768
+	$user_id = wp_insert_user($user_args);
769 769
 
770 770
 	// Validate inserted user.
771
-	if ( is_wp_error( $user_id ) ) {
772
-		return - 1;
771
+	if (is_wp_error($user_id)) {
772
+		return -1;
773 773
 	}
774 774
 
775 775
 	// Allow themes and plugins to filter the user data.
776
-	$user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args );
776
+	$user_data = apply_filters('give_insert_user_data', $user_data, $user_args);
777 777
 
778 778
 	/**
779 779
 	 * Fires after inserting user.
@@ -783,10 +783,10 @@  discard block
 block discarded – undo
783 783
 	 * @param int $user_id User id.
784 784
 	 * @param array $user_data Array containing user data.
785 785
 	 */
786
-	do_action( 'give_insert_user', $user_id, $user_data );
786
+	do_action('give_insert_user', $user_id, $user_data);
787 787
 
788 788
 	// Login new user.
789
-	give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] );
789
+	give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']);
790 790
 
791 791
 	// Return user id.
792 792
 	return $user_id;
@@ -801,27 +801,27 @@  discard block
 block discarded – undo
801 801
  * @since   1.0
802 802
  * @return  array|bool
803 803
  */
804
-function give_get_donation_form_user( $valid_data = array() ) {
804
+function give_get_donation_form_user($valid_data = array()) {
805 805
 
806 806
 	// Initialize user.
807 807
 	$user    = false;
808
-	$is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
808
+	$is_ajax = defined('DOING_AJAX') && DOING_AJAX;
809 809
 
810
-	if ( $is_ajax ) {
810
+	if ($is_ajax) {
811 811
 		// Do not create or login the user during the ajax submission (check for errors only).
812 812
 		return true;
813
-	} elseif ( is_user_logged_in() ) {
813
+	} elseif (is_user_logged_in()) {
814 814
 		// Set the valid user as the logged in collected data.
815 815
 		$user = $valid_data['logged_in_user'];
816
-	} elseif ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) {
816
+	} elseif ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) {
817 817
 		// New user registration.
818
-		if ( $valid_data['need_new_user'] === true ) {
818
+		if ($valid_data['need_new_user'] === true) {
819 819
 			// Set user.
820 820
 			$user = $valid_data['new_user_data'];
821 821
 			// Register and login new user.
822
-			$user['user_id'] = give_register_and_login_new_user( $user );
822
+			$user['user_id'] = give_register_and_login_new_user($user);
823 823
 			// User login
824
-		} elseif ( $valid_data['need_user_login'] === true && ! $is_ajax ) {
824
+		} elseif ($valid_data['need_user_login'] === true && ! $is_ajax) {
825 825
 
826 826
 			/**
827 827
 			 * The login form is now processed in the give_process_donation_login() function.
@@ -833,48 +833,48 @@  discard block
 block discarded – undo
833 833
 			// Set user.
834 834
 			$user = $valid_data['login_user_data'];
835 835
 			// Login user.
836
-			give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] );
836
+			give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']);
837 837
 		}
838 838
 	}
839 839
 
840 840
 	// Check guest checkout.
841
-	if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) {
841
+	if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) {
842 842
 		// Set user
843 843
 		$user = $valid_data['guest_user_data'];
844 844
 	}
845 845
 
846 846
 	// Verify we have an user.
847
-	if ( false === $user || empty( $user ) ) {
847
+	if (false === $user || empty($user)) {
848 848
 		// Return false.
849 849
 		return false;
850 850
 	}
851 851
 
852 852
 	// Get user first name.
853
-	if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) {
854
-		$user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : '';
853
+	if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) {
854
+		$user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : '';
855 855
 	}
856 856
 
857 857
 	// Get user last name.
858
-	if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) {
859
-		$user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : '';
858
+	if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) {
859
+		$user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : '';
860 860
 	}
861 861
 
862 862
 	// Get the user's billing address details.
863 863
 	$user['address']            = array();
864
-	$user['address']['line1']   = ! empty( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : false;
865
-	$user['address']['line2']   = ! empty( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : false;
866
-	$user['address']['city']    = ! empty( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : false;
867
-	$user['address']['state']   = ! empty( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : false;
868
-	$user['address']['country'] = ! empty( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : false;
869
-	$user['address']['zip']     = ! empty( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : false;
870
-
871
-	if ( empty( $user['address']['country'] ) ) {
864
+	$user['address']['line1']   = ! empty($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : false;
865
+	$user['address']['line2']   = ! empty($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : false;
866
+	$user['address']['city']    = ! empty($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : false;
867
+	$user['address']['state']   = ! empty($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : false;
868
+	$user['address']['country'] = ! empty($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : false;
869
+	$user['address']['zip']     = ! empty($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : false;
870
+
871
+	if (empty($user['address']['country'])) {
872 872
 		$user['address'] = false;
873 873
 	} // End if().
874 874
 
875
-	if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) {
875
+	if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) {
876 876
 		// Store the address in the user's meta so the donation form can be pre-populated with it on return donation.
877
-		update_user_meta( $user['user_id'], '_give_user_address', $user['address'] );
877
+		update_user_meta($user['user_id'], '_give_user_address', $user['address']);
878 878
 	}
879 879
 
880 880
 	// Return valid user.
@@ -893,16 +893,16 @@  discard block
 block discarded – undo
893 893
 	$card_data = give_get_donation_cc_info();
894 894
 
895 895
 	// Validate the card zip.
896
-	if ( ! empty( $card_data['card_zip'] ) ) {
897
-		if ( ! give_donation_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) {
898
-			give_set_error( 'invalid_cc_zip', __( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) );
896
+	if ( ! empty($card_data['card_zip'])) {
897
+		if ( ! give_donation_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) {
898
+			give_set_error('invalid_cc_zip', __('The zip / postal code you entered for your billing address is invalid.', 'give'));
899 899
 		}
900 900
 	}
901 901
 
902 902
 	// Ensure no spaces.
903
-	if ( ! empty( $card_data['card_number'] ) ) {
904
-		$card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs
905
-		$card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces
903
+	if ( ! empty($card_data['card_number'])) {
904
+		$card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs
905
+		$card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces
906 906
 	}
907 907
 
908 908
 	// This should validate card numbers at some point too.
@@ -919,17 +919,17 @@  discard block
 block discarded – undo
919 919
 function give_get_donation_cc_info() {
920 920
 
921 921
 	$cc_info                   = array();
922
-	$cc_info['card_name']      = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : '';
923
-	$cc_info['card_number']    = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : '';
924
-	$cc_info['card_cvc']       = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : '';
925
-	$cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : '';
926
-	$cc_info['card_exp_year']  = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : '';
927
-	$cc_info['card_address']   = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : '';
928
-	$cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : '';
929
-	$cc_info['card_city']      = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : '';
930
-	$cc_info['card_state']     = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : '';
931
-	$cc_info['card_country']   = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : '';
932
-	$cc_info['card_zip']       = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : '';
922
+	$cc_info['card_name']      = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : '';
923
+	$cc_info['card_number']    = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : '';
924
+	$cc_info['card_cvc']       = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : '';
925
+	$cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : '';
926
+	$cc_info['card_exp_year']  = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : '';
927
+	$cc_info['card_address']   = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : '';
928
+	$cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : '';
929
+	$cc_info['card_city']      = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : '';
930
+	$cc_info['card_state']     = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : '';
931
+	$cc_info['card_country']   = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : '';
932
+	$cc_info['card_zip']       = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : '';
933 933
 
934 934
 	// Return cc info.
935 935
 	return $cc_info;
@@ -945,14 +945,14 @@  discard block
 block discarded – undo
945 945
  *
946 946
  * @return bool|mixed
947 947
  */
948
-function give_donation_form_validate_cc_zip( $zip = 0, $country_code = '' ) {
948
+function give_donation_form_validate_cc_zip($zip = 0, $country_code = '') {
949 949
 	$ret = false;
950 950
 
951
-	if ( empty( $zip ) || empty( $country_code ) ) {
951
+	if (empty($zip) || empty($country_code)) {
952 952
 		return $ret;
953 953
 	}
954 954
 
955
-	$country_code = strtoupper( $country_code );
955
+	$country_code = strtoupper($country_code);
956 956
 
957 957
 	$zip_regex = array(
958 958
 		'AD' => 'AD\d{3}',
@@ -1112,11 +1112,11 @@  discard block
 block discarded – undo
1112 1112
 		'ZM' => '\d{5}',
1113 1113
 	);
1114 1114
 
1115
-	if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) {
1115
+	if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) {
1116 1116
 		$ret = true;
1117 1117
 	}
1118 1118
 
1119
-	return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code );
1119
+	return apply_filters('give_is_zip_valid', $ret, $zip, $country_code);
1120 1120
 }
1121 1121
 
1122 1122
 
@@ -1130,36 +1130,36 @@  discard block
 block discarded – undo
1130 1130
  *
1131 1131
  * @return bool
1132 1132
  */
1133
-function give_validate_multi_donation_form_level( $valid_data, $data ) {
1133
+function give_validate_multi_donation_form_level($valid_data, $data) {
1134 1134
 	/* @var Give_Donate_Form $form */
1135
-	$form = new Give_Donate_Form( $data['give-form-id'] );
1135
+	$form = new Give_Donate_Form($data['give-form-id']);
1136 1136
 
1137 1137
 	$donation_level_matched = false;
1138 1138
 
1139
-	if ( $form->is_multi_type_donation_form() ) {
1139
+	if ($form->is_multi_type_donation_form()) {
1140 1140
 
1141 1141
 		// Bailout.
1142
-		if ( ! ( $variable_prices = $form->get_prices() ) ) {
1142
+		if ( ! ($variable_prices = $form->get_prices())) {
1143 1143
 			return false;
1144 1144
 		}
1145 1145
 
1146 1146
 		// Sanitize donation amount.
1147
-		$data['give-amount'] = give_sanitize_amount( $data['give-amount'] );
1147
+		$data['give-amount'] = give_sanitize_amount($data['give-amount']);
1148 1148
 
1149 1149
 		// Get number of decimals.
1150 1150
 		$default_decimals = give_get_price_decimals();
1151 1151
 
1152
-		if ( $data['give-amount'] === give_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ), $default_decimals ) ) {
1152
+		if ($data['give-amount'] === give_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']), $default_decimals)) {
1153 1153
 			return true;
1154 1154
 		}
1155 1155
 
1156 1156
 		// Find correct donation level from all donation levels.
1157
-		foreach ( $variable_prices as $variable_price ) {
1157
+		foreach ($variable_prices as $variable_price) {
1158 1158
 			// Sanitize level amount.
1159
-			$variable_price['_give_amount'] = give_sanitize_amount( $variable_price['_give_amount'], $default_decimals );
1159
+			$variable_price['_give_amount'] = give_sanitize_amount($variable_price['_give_amount'], $default_decimals);
1160 1160
 
1161 1161
 			// Set first match donation level ID.
1162
-			if ( $data['give-amount'] === $variable_price['_give_amount'] ) {
1162
+			if ($data['give-amount'] === $variable_price['_give_amount']) {
1163 1163
 				$_POST['give-price-id'] = $variable_price['_give_id']['level_id'];
1164 1164
 				$donation_level_matched = true;
1165 1165
 				break;
@@ -1170,19 +1170,19 @@  discard block
 block discarded – undo
1170 1170
 		// If yes then set price id to custom if amount is greater then custom minimum amount (if any).
1171 1171
 		if (
1172 1172
 			! $donation_level_matched
1173
-			&& ( give_is_setting_enabled( give_get_meta( $data['give-form-id'], '_give_custom_amount', true ) ) )
1173
+			&& (give_is_setting_enabled(give_get_meta($data['give-form-id'], '_give_custom_amount', true)))
1174 1174
 		) {
1175 1175
 			// Sanitize custom minimum amount.
1176
-			$custom_minimum_amount = give_sanitize_amount( give_get_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ), $default_decimals );
1176
+			$custom_minimum_amount = give_sanitize_amount(give_get_meta($data['give-form-id'], '_give_custom_amount_minimum', true), $default_decimals);
1177 1177
 
1178
-			if ( $data['give-amount'] >= $custom_minimum_amount ) {
1178
+			if ($data['give-amount'] >= $custom_minimum_amount) {
1179 1179
 				$_POST['give-price-id'] = 'custom';
1180 1180
 				$donation_level_matched = true;
1181 1181
 			}
1182 1182
 		}
1183 1183
 	}// End if().
1184 1184
 
1185
-	return ( $donation_level_matched ? true : false );
1185
+	return ($donation_level_matched ? true : false);
1186 1186
 }
1187 1187
 
1188
-add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 );
1188
+add_action('give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2);
Please login to merge, or discard this patch.
includes/formatting.php 1 patch
Spacing   +99 added lines, -99 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,7 +23,7 @@  discard block
 block discarded – undo
23 23
  * @return mixed
24 24
  */
25 25
 function give_get_price_decimals() {
26
-	return apply_filters( 'give_sanitize_amount_decimals', give_get_option( 'number_decimals', 0 ) );
26
+	return apply_filters('give_sanitize_amount_decimals', give_get_option('number_decimals', 0));
27 27
 }
28 28
 
29 29
 /**
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
  * @return mixed
35 35
  */
36 36
 function give_get_price_thousand_separator() {
37
-	return give_get_option( 'thousands_separator', ',' );
37
+	return give_get_option('thousands_separator', ',');
38 38
 }
39 39
 
40 40
 /**
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
  * @return mixed
46 46
  */
47 47
 function give_get_price_decimal_separator() {
48
-	return give_get_option( 'decimal_separator', '.' );
48
+	return give_get_option('decimal_separator', '.');
49 49
 }
50 50
 
51 51
 /**
@@ -61,67 +61,67 @@  discard block
 block discarded – undo
61 61
  *
62 62
  * @return string $amount Newly sanitized amount
63 63
  */
64
-function give_sanitize_amount( $number, $dp = false, $trim_zeros = false ) {
64
+function give_sanitize_amount($number, $dp = false, $trim_zeros = false) {
65 65
 
66 66
 	// Bailout.
67
-	if ( empty( $number ) ) {
67
+	if (empty($number)) {
68 68
 		return $number;
69 69
 	}
70 70
 
71 71
 	// Remove slash from amount.
72 72
 	// If thousand or decimal separator is set to ' then in $_POST or $_GET param we will get an escaped number.
73 73
 	// To prevent notices and warning remove slash from amount/number.
74
-	$number = wp_unslash( $number );
74
+	$number = wp_unslash($number);
75 75
 
76 76
 	$thousand_separator = give_get_price_thousand_separator();
77 77
 
78 78
 	$locale   = localeconv();
79
-	$decimals = array( give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point'] );
79
+	$decimals = array(give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point']);
80 80
 
81 81
 	// Remove locale from string
82
-	if ( ! is_float( $number ) ) {
83
-		$number = str_replace( $decimals, '.', $number );
82
+	if ( ! is_float($number)) {
83
+		$number = str_replace($decimals, '.', $number);
84 84
 	}
85 85
 
86 86
 	// Remove thousand amount formatting if amount has.
87 87
 	// This condition use to add backward compatibility to version before 1.6, because before version 1.6 we were saving formatted amount to db.
88 88
 	// Do not replace thousand separator from price if it is same as decimal separator, because it will be already replace by above code.
89
-	if ( ! in_array( $thousand_separator, $decimals ) && ( false !== strpos( $number, $thousand_separator ) ) ) {
90
-		$number = str_replace( $thousand_separator, '', $number );
91
-	} elseif ( in_array( $thousand_separator, $decimals ) ) {
92
-		$number = preg_replace( '/\.(?=.*\.)/', '', $number );
89
+	if ( ! in_array($thousand_separator, $decimals) && (false !== strpos($number, $thousand_separator))) {
90
+		$number = str_replace($thousand_separator, '', $number);
91
+	} elseif (in_array($thousand_separator, $decimals)) {
92
+		$number = preg_replace('/\.(?=.*\.)/', '', $number);
93 93
 	}
94 94
 
95 95
 	// Remove non numeric entity before decimal separator.
96
-	$number     = preg_replace( '/[^0-9\.]/', '', $number );
96
+	$number     = preg_replace('/[^0-9\.]/', '', $number);
97 97
 	$default_dp = give_get_price_decimals();
98 98
 
99 99
 	// Reset negative amount to zero.
100
-	if ( 0 > $number ) {
101
-		$number = number_format( 0, $default_dp, '.' );
100
+	if (0 > $number) {
101
+		$number = number_format(0, $default_dp, '.');
102 102
 	}
103 103
 
104 104
 	// If number does not have decimal then add number of decimals to it.
105 105
 	if (
106
-		false === strpos( $number, '.' )
107
-		|| ( $default_dp > strlen( substr( $number, strpos( $number, '.' ) + 1 ) ) )
106
+		false === strpos($number, '.')
107
+		|| ($default_dp > strlen(substr($number, strpos($number, '.') + 1)))
108 108
 	) {
109
-		$number = number_format( $number, $default_dp, '.', '' );
109
+		$number = number_format($number, $default_dp, '.', '');
110 110
 	}
111 111
 
112 112
 	// Format number by custom number of decimals.
113
-	if ( false !== $dp ) {
114
-		$dp     = intval( is_bool( $dp ) ? $default_dp : $dp );
115
-		$dp     = apply_filters( 'give_sanitize_amount_decimals', $dp, $number );
116
-		$number = number_format( floatval( $number ), $dp, '.', '' );
113
+	if (false !== $dp) {
114
+		$dp     = intval(is_bool($dp) ? $default_dp : $dp);
115
+		$dp     = apply_filters('give_sanitize_amount_decimals', $dp, $number);
116
+		$number = number_format(floatval($number), $dp, '.', '');
117 117
 	}
118 118
 
119 119
 	// Trim zeros.
120
-	if ( $trim_zeros && strstr( $number, '.' ) ) {
121
-		$number = rtrim( rtrim( $number, '0' ), '.' );
120
+	if ($trim_zeros && strstr($number, '.')) {
121
+		$number = rtrim(rtrim($number, '0'), '.');
122 122
 	}
123 123
 
124
-	return apply_filters( 'give_sanitize_amount', $number );
124
+	return apply_filters('give_sanitize_amount', $number);
125 125
 }
126 126
 
127 127
 /**
@@ -134,22 +134,22 @@  discard block
 block discarded – undo
134 134
  *
135 135
  * @return string $amount   Newly formatted amount or Price Not Available
136 136
  */
137
-function give_format_amount( $amount, $decimals = true ) {
138
-	$thousands_sep = give_get_option( 'thousands_separator', ',' );
139
-	$decimal_sep   = give_get_option( 'decimal_separator', '.' );
137
+function give_format_amount($amount, $decimals = true) {
138
+	$thousands_sep = give_get_option('thousands_separator', ',');
139
+	$decimal_sep   = give_get_option('decimal_separator', '.');
140 140
 
141
-	if ( empty( $amount ) ) {
141
+	if (empty($amount)) {
142 142
 		$amount = 0;
143 143
 	} else {
144 144
 		// Sanitize amount before formatting.
145
-		$amount = give_sanitize_amount( $amount );
145
+		$amount = give_sanitize_amount($amount);
146 146
 	}
147 147
 
148 148
 	$decimals = $decimals ? give_get_price_decimals() : 0;
149 149
 
150
-	$formatted = number_format( $amount, $decimals, $decimal_sep, $thousands_sep );
150
+	$formatted = number_format($amount, $decimals, $decimal_sep, $thousands_sep);
151 151
 
152
-	return apply_filters( 'give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep );
152
+	return apply_filters('give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep);
153 153
 }
154 154
 
155 155
 
@@ -166,33 +166,33 @@  discard block
 block discarded – undo
166 166
  *
167 167
  * @return float|string  formatted amount number with large number names.
168 168
  */
169
-function give_human_format_large_amount( $amount ) {
169
+function give_human_format_large_amount($amount) {
170 170
 
171 171
 	// Get thousand separator.
172 172
 	$thousands_sep = give_get_price_thousand_separator();
173 173
 
174 174
 	// Sanitize amount.
175
-	$sanitize_amount = give_sanitize_amount( $amount );
175
+	$sanitize_amount = give_sanitize_amount($amount);
176 176
 
177 177
 	// Explode amount to calculate name of large numbers.
178
-	$amount_array = explode( $thousands_sep, $amount );
178
+	$amount_array = explode($thousands_sep, $amount);
179 179
 
180 180
 	// Calculate amount parts count.
181
-	$amount_count_parts = count( $amount_array );
181
+	$amount_count_parts = count($amount_array);
182 182
 
183 183
 	// Human format amount (default).
184 184
 	$human_format_amount = $amount;
185 185
 
186 186
 	// Calculate large number formatted amount.
187
-	if ( 4 < $amount_count_parts ) {
188
-		$human_format_amount = sprintf( esc_html__( '%s trillion', 'give' ), round( ( $sanitize_amount / 1000000000000 ), 2 ) );
189
-	} elseif ( 3 < $amount_count_parts ) {
190
-		$human_format_amount = sprintf( esc_html__( '%s billion', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 ) );
191
-	} elseif ( 2 < $amount_count_parts ) {
192
-		$human_format_amount = sprintf( esc_html__( '%s million', 'give' ), round( ( $sanitize_amount / 1000000 ), 2 ) );
187
+	if (4 < $amount_count_parts) {
188
+		$human_format_amount = sprintf(esc_html__('%s trillion', 'give'), round(($sanitize_amount / 1000000000000), 2));
189
+	} elseif (3 < $amount_count_parts) {
190
+		$human_format_amount = sprintf(esc_html__('%s billion', 'give'), round(($sanitize_amount / 1000000000), 2));
191
+	} elseif (2 < $amount_count_parts) {
192
+		$human_format_amount = sprintf(esc_html__('%s million', 'give'), round(($sanitize_amount / 1000000), 2));
193 193
 	}
194 194
 
195
-	return apply_filters( 'give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount );
195
+	return apply_filters('give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount);
196 196
 }
197 197
 
198 198
 /**
@@ -205,15 +205,15 @@  discard block
 block discarded – undo
205 205
  *
206 206
  * @return string $amount Newly formatted amount or Price Not Available
207 207
  */
208
-function give_format_decimal( $amount, $dp = false ) {
208
+function give_format_decimal($amount, $dp = false) {
209 209
 	$decimal_separator = give_get_price_decimal_separator();
210
-	$formatted_amount  = give_sanitize_amount( $amount, $dp );
210
+	$formatted_amount  = give_sanitize_amount($amount, $dp);
211 211
 
212
-	if ( false !== strpos( $formatted_amount, '.' ) ) {
213
-		$formatted_amount = str_replace( '.', $decimal_separator, $formatted_amount );
212
+	if (false !== strpos($formatted_amount, '.')) {
213
+		$formatted_amount = str_replace('.', $decimal_separator, $formatted_amount);
214 214
 	}
215 215
 
216
-	return apply_filters( 'give_format_decimal', $formatted_amount, $amount, $decimal_separator );
216
+	return apply_filters('give_format_decimal', $formatted_amount, $amount, $decimal_separator);
217 217
 }
218 218
 
219 219
 /**
@@ -227,24 +227,24 @@  discard block
 block discarded – undo
227 227
  *
228 228
  * @return mixed|string
229 229
  */
230
-function give_currency_filter( $price = '', $currency = '', $decode_currency = false ) {
230
+function give_currency_filter($price = '', $currency = '', $decode_currency = false) {
231 231
 
232
-	if ( empty( $currency ) ) {
232
+	if (empty($currency)) {
233 233
 		$currency = give_get_currency();
234 234
 	}
235 235
 
236
-	$position = give_get_option( 'currency_position', 'before' );
236
+	$position = give_get_option('currency_position', 'before');
237 237
 
238 238
 	$negative = $price < 0;
239 239
 
240
-	if ( $negative ) {
240
+	if ($negative) {
241 241
 		// Remove proceeding "-".
242
-		$price = substr( $price, 1 );
242
+		$price = substr($price, 1);
243 243
 	}
244 244
 
245
-	$symbol = give_currency_symbol( $currency, $decode_currency );
245
+	$symbol = give_currency_symbol($currency, $decode_currency);
246 246
 
247
-	switch ( $currency ) :
247
+	switch ($currency) :
248 248
 		case 'GBP' :
249 249
 		case 'BRL' :
250 250
 		case 'EUR' :
@@ -273,13 +273,13 @@  discard block
 block discarded – undo
273 273
 		case 'MAD' :
274 274
 		case 'KRW' :
275 275
 		case 'ZAR' :
276
-			$formatted = ( 'before' === $position ? $symbol . $price : $price . $symbol );
276
+			$formatted = ('before' === $position ? $symbol.$price : $price.$symbol);
277 277
 			break;
278 278
 		case 'NOK' :
279
-			$formatted = ( 'before' === $position ? $symbol . ' ' . $price : $price . ' ' . $symbol );
279
+			$formatted = ('before' === $position ? $symbol.' '.$price : $price.' '.$symbol);
280 280
 			break;
281 281
 		default :
282
-			$formatted = ( 'before' === $position ? $currency . ' ' . $price : $price . ' ' . $currency );
282
+			$formatted = ('before' === $position ? $currency.' '.$price : $price.' '.$currency);
283 283
 			break;
284 284
 	endswitch;
285 285
 
@@ -294,11 +294,11 @@  discard block
 block discarded – undo
294 294
 	 *           and if currency is USD and currency position is after then
295 295
 	 *           filter name will be give_usd_currency_filter_after
296 296
 	 */
297
-	$formatted = apply_filters( 'give_' . strtolower( $currency ) . "_currency_filter_{$position}", $formatted, $currency, $price );
297
+	$formatted = apply_filters('give_'.strtolower($currency)."_currency_filter_{$position}", $formatted, $currency, $price);
298 298
 
299
-	if ( $negative ) {
299
+	if ($negative) {
300 300
 		// Prepend the minus sign before the currency sign.
301
-		$formatted = '-' . $formatted;
301
+		$formatted = '-'.$formatted;
302 302
 	}
303 303
 
304 304
 	return $formatted;
@@ -314,21 +314,21 @@  discard block
 block discarded – undo
314 314
  */
315 315
 function give_currency_decimal_filter() {
316 316
 
317
-	remove_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' );
317
+	remove_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter');
318 318
 
319 319
 	// Set default number of decimals.
320 320
 	$decimals = give_get_price_decimals();
321 321
 
322
-	add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' );
322
+	add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter');
323 323
 
324 324
 	// Get number of decimals with backward compatibility ( version < 1.6 )
325
-	if ( 1 <= func_num_args() ) {
326
-		$decimals = ( false === func_get_arg( 0 ) ? $decimals : absint( func_get_arg( 0 ) ) );
325
+	if (1 <= func_num_args()) {
326
+		$decimals = (false === func_get_arg(0) ? $decimals : absint(func_get_arg(0)));
327 327
 	}
328 328
 
329 329
 	$currency = give_get_currency();
330 330
 
331
-	switch ( $currency ) {
331
+	switch ($currency) {
332 332
 		case 'RIAL' :
333 333
 		case 'JPY' :
334 334
 		case 'TWD' :
@@ -338,11 +338,11 @@  discard block
 block discarded – undo
338 338
 			break;
339 339
 	}
340 340
 
341
-	return apply_filters( 'give_currency_decimal_count', $decimals, $currency );
341
+	return apply_filters('give_currency_decimal_count', $decimals, $currency);
342 342
 }
343 343
 
344
-add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' );
345
-add_filter( 'give_format_amount_decimals', 'give_currency_decimal_filter' );
344
+add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter');
345
+add_filter('give_format_amount_decimals', 'give_currency_decimal_filter');
346 346
 
347 347
 
348 348
 /**
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
  *
355 355
  * @return string                  Date format string
356 356
  */
357
-function give_date_format( $date_context = '' ) {
357
+function give_date_format($date_context = '') {
358 358
 	/**
359 359
 	 * Filter the date context
360 360
 	 *
@@ -375,19 +375,19 @@  discard block
 block discarded – undo
375 375
 	 *
376 376
 	 *    }
377 377
 	 */
378
-	$date_format_contexts = apply_filters( 'give_date_format_contexts', array() );
378
+	$date_format_contexts = apply_filters('give_date_format_contexts', array());
379 379
 
380 380
 	// Set date format to default date format.
381
-	$date_format = get_option( 'date_format' );
381
+	$date_format = get_option('date_format');
382 382
 
383 383
 	// Update date format if we have non empty date format context array and non empty date format string for that context.
384
-	if ( $date_context && ! empty( $date_format_contexts ) && array_key_exists( $date_context, $date_format_contexts ) ) {
385
-		$date_format = ! empty( $date_format_contexts[ $date_context ] )
386
-			? $date_format_contexts[ $date_context ]
384
+	if ($date_context && ! empty($date_format_contexts) && array_key_exists($date_context, $date_format_contexts)) {
385
+		$date_format = ! empty($date_format_contexts[$date_context])
386
+			? $date_format_contexts[$date_context]
387 387
 			: $date_format;
388 388
 	}
389 389
 
390
-	return apply_filters( 'give_date_format', $date_format );
390
+	return apply_filters('give_date_format', $date_format);
391 391
 }
392 392
 
393 393
 /**
@@ -401,8 +401,8 @@  discard block
 block discarded – undo
401 401
  *
402 402
  * @return string
403 403
  */
404
-function give_get_cache_key( $action, $query_args ) {
405
-	return Give_Cache::get_key( $action, $query_args );
404
+function give_get_cache_key($action, $query_args) {
405
+	return Give_Cache::get_key($action, $query_args);
406 406
 }
407 407
 
408 408
 /**
@@ -415,11 +415,11 @@  discard block
 block discarded – undo
415 415
  *
416 416
  * @return string|array
417 417
  */
418
-function give_clean( $var ) {
419
-	if ( is_array( $var ) ) {
420
-		return array_map( 'give_clean', $var );
418
+function give_clean($var) {
419
+	if (is_array($var)) {
420
+		return array_map('give_clean', $var);
421 421
 	} else {
422
-		return is_scalar( $var ) ? sanitize_text_field( $var ) : $var;
422
+		return is_scalar($var) ? sanitize_text_field($var) : $var;
423 423
 	}
424 424
 }
425 425
 
@@ -432,10 +432,10 @@  discard block
 block discarded – undo
432 432
  *
433 433
  * @return int
434 434
  */
435
-function give_let_to_num( $size ) {
436
-	$l   = substr( $size, - 1 );
437
-	$ret = substr( $size, 0, - 1 );
438
-	switch ( strtoupper( $l ) ) {
435
+function give_let_to_num($size) {
436
+	$l   = substr($size, - 1);
437
+	$ret = substr($size, 0, - 1);
438
+	switch (strtoupper($l)) {
439 439
 		case 'P':
440 440
 			$ret *= 1024;
441 441
 		case 'T':
@@ -460,19 +460,19 @@  discard block
 block discarded – undo
460 460
  * @param int   $action
461 461
  * @param array $wp_die_args
462 462
  */
463
-function give_validate_nonce( $nonce, $action = - 1, $wp_die_args = array() ) {
463
+function give_validate_nonce($nonce, $action = - 1, $wp_die_args = array()) {
464 464
 
465 465
 	$default_wp_die_args = array(
466
-		'message' => esc_html__( 'Nonce verification has failed.', 'give' ),
467
-		'title'   => esc_html__( 'Error', 'give' ),
466
+		'message' => esc_html__('Nonce verification has failed.', 'give'),
467
+		'title'   => esc_html__('Error', 'give'),
468 468
 		'args'    => array(
469 469
 			'response' => 403,
470 470
 		),
471 471
 	);
472 472
 
473
-	$wp_die_args = wp_parse_args( $wp_die_args, $default_wp_die_args );
473
+	$wp_die_args = wp_parse_args($wp_die_args, $default_wp_die_args);
474 474
 
475
-	if ( ! wp_verify_nonce( $nonce, $action ) ) {
475
+	if ( ! wp_verify_nonce($nonce, $action)) {
476 476
 		wp_die(
477 477
 			$wp_die_args['message'],
478 478
 			$wp_die_args['title'],
@@ -494,23 +494,23 @@  discard block
 block discarded – undo
494 494
  *
495 495
  * @return mixed
496 496
  */
497
-function give_check_variable( $variable, $conditional = '', $default = false ) {
497
+function give_check_variable($variable, $conditional = '', $default = false) {
498 498
 
499
-	switch ( $conditional ) {
499
+	switch ($conditional) {
500 500
 		case 'isset_empty':
501
-			$variable = ( isset( $variable ) && ! empty( $variable ) ) ? $variable : $default;
501
+			$variable = (isset($variable) && ! empty($variable)) ? $variable : $default;
502 502
 			break;
503 503
 
504 504
 		case 'empty':
505
-			$variable = ! empty( $variable ) ? $variable : $default;
505
+			$variable = ! empty($variable) ? $variable : $default;
506 506
 			break;
507 507
 
508 508
 		case 'null':
509
-			$variable = ! is_null( $variable ) ? $variable : $default;
509
+			$variable = ! is_null($variable) ? $variable : $default;
510 510
 			break;
511 511
 
512 512
 		default:
513
-			$variable = isset( $variable ) ? $variable : $default;
513
+			$variable = isset($variable) ? $variable : $default;
514 514
 
515 515
 	}
516 516
 
Please login to merge, or discard this patch.
includes/class-give-html-elements.php 1 patch
Spacing   +150 added lines, -150 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
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @return string       Donations dropdown.
37 37
 	 */
38
-	public function donations_dropdown( $args = array() ) {
38
+	public function donations_dropdown($args = array()) {
39 39
 
40 40
 		$defaults = array(
41 41
 			'name'        => 'donations',
@@ -45,33 +45,33 @@  discard block
 block discarded – undo
45 45
 			'selected'    => 0,
46 46
 			'chosen'      => false,
47 47
 			'number'      => 30,
48
-			'placeholder' => __( 'Select a donation', 'give' )
48
+			'placeholder' => __('Select a donation', 'give')
49 49
 		);
50 50
 
51
-		$args = wp_parse_args( $args, $defaults );
51
+		$args = wp_parse_args($args, $defaults);
52 52
 
53
-		$payments = new Give_Payments_Query( array(
53
+		$payments = new Give_Payments_Query(array(
54 54
 			'number' => $args['number']
55
-		) );
55
+		));
56 56
 
57 57
 		$payments = $payments->get_payments();
58 58
 
59 59
 		$options = array();
60 60
 
61 61
 		//Provide nice human readable options.
62
-		if ( $payments ) {
62
+		if ($payments) {
63 63
 			$options[0] = $args['placeholder'];
64
-			foreach ( $payments as $payment ) {
64
+			foreach ($payments as $payment) {
65 65
 
66
-				$options[ absint( $payment->ID ) ] = esc_html( '#' . $payment->ID . ' - ' . $payment->email . ' - ' . $payment->form_title );
66
+				$options[absint($payment->ID)] = esc_html('#'.$payment->ID.' - '.$payment->email.' - '.$payment->form_title);
67 67
 
68 68
 			}
69 69
 		} else {
70
-			$options[0] = __( 'No donations found.', 'give' );
70
+			$options[0] = __('No donations found.', 'give');
71 71
 		}
72 72
 
73 73
 
74
-		$output = $this->select( array(
74
+		$output = $this->select(array(
75 75
 			'name'             => $args['name'],
76 76
 			'selected'         => $args['selected'],
77 77
 			'id'               => $args['id'],
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 			'select_atts'      => $args['select_atts'],
84 84
 			'show_option_all'  => false,
85 85
 			'show_option_none' => false
86
-		) );
86
+		));
87 87
 
88 88
 		return $output;
89 89
 	}
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	 *
101 101
 	 * @return string      Give forms dropdown.
102 102
 	 */
103
-	public function forms_dropdown( $args = array() ) {
103
+	public function forms_dropdown($args = array()) {
104 104
 
105 105
 		$defaults = array(
106 106
 			'name'        => 'forms',
@@ -110,38 +110,38 @@  discard block
 block discarded – undo
110 110
 			'selected'    => 0,
111 111
 			'chosen'      => false,
112 112
 			'number'      => 30,
113
-			'placeholder' => esc_attr__( 'Select a Donation Form', 'give' ),
114
-			'data'        => array( 'search-type' => 'form' ),
113
+			'placeholder' => esc_attr__('Select a Donation Form', 'give'),
114
+			'data'        => array('search-type' => 'form'),
115 115
 		);
116 116
 
117
-		$args = wp_parse_args( $args, $defaults );
117
+		$args = wp_parse_args($args, $defaults);
118 118
 
119
-		$forms = get_posts( array(
119
+		$forms = get_posts(array(
120 120
 			'post_type'      => 'give_forms',
121 121
 			'orderby'        => 'title',
122 122
 			'order'          => 'ASC',
123 123
 			'posts_per_page' => $args['number']
124
-		) );
124
+		));
125 125
 
126 126
 		$options = array();
127 127
 
128 128
 		// Ensure the selected.
129
-		if ( false !== $args['selected'] && $args['selected'] !== 0 ) {
130
-			$options[ $args['selected'] ] = get_the_title( $args['selected'] );
129
+		if (false !== $args['selected'] && $args['selected'] !== 0) {
130
+			$options[$args['selected']] = get_the_title($args['selected']);
131 131
 		}
132 132
 
133 133
 
134
-		if ( $forms ) {
134
+		if ($forms) {
135 135
 			$options[0] = $args['placeholder'];
136
-			foreach ( $forms as $form ) {
137
-				$form_title                     = empty( $form->post_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $form->ID ) : $form->post_title;
138
-				$options[ absint( $form->ID ) ] = esc_html( $form_title );
136
+			foreach ($forms as $form) {
137
+				$form_title                     = empty($form->post_title) ? sprintf(__('Untitled (#%s)', 'give'), $form->ID) : $form->post_title;
138
+				$options[absint($form->ID)] = esc_html($form_title);
139 139
 			}
140 140
 		} else {
141
-			$options[0] = esc_html__( 'No forms found.', 'give' );
141
+			$options[0] = esc_html__('No forms found.', 'give');
142 142
 		}
143 143
 
144
-		$output = $this->select( array(
144
+		$output = $this->select(array(
145 145
 			'name'             => $args['name'],
146 146
 			'selected'         => $args['selected'],
147 147
 			'id'               => $args['id'],
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 			'show_option_all'  => false,
154 154
 			'show_option_none' => false,
155 155
 			'data'             => $args['data'],
156
-		) );
156
+		));
157 157
 
158 158
 		return $output;
159 159
 	}
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 	 *
171 171
 	 * @return string      Donors dropdown.
172 172
 	 */
173
-	public function donor_dropdown( $args = array() ) {
173
+	public function donor_dropdown($args = array()) {
174 174
 
175 175
 		$defaults = array(
176 176
 			'name'        => 'donors',
@@ -179,39 +179,39 @@  discard block
 block discarded – undo
179 179
 			'multiple'    => false,
180 180
 			'selected'    => 0,
181 181
 			'chosen'      => true,
182
-			'placeholder' => esc_attr__( 'Select a Donor', 'give' ),
182
+			'placeholder' => esc_attr__('Select a Donor', 'give'),
183 183
 			'number'      => 30,
184
-			'data'        => array( 'search-type' => 'donor' )
184
+			'data'        => array('search-type' => 'donor')
185 185
 		);
186 186
 
187
-		$args = wp_parse_args( $args, $defaults );
187
+		$args = wp_parse_args($args, $defaults);
188 188
 
189
-		$customers = Give()->customers->get_customers( array(
189
+		$customers = Give()->customers->get_customers(array(
190 190
 			'number' => $args['number']
191
-		) );
191
+		));
192 192
 
193 193
 		$options = array();
194 194
 
195
-		if ( $customers ) {
196
-			$options[0] = esc_html__( 'No donor attached', 'give' );
197
-			foreach ( $customers as $customer ) {
198
-				$options[ absint( $customer->id ) ] = esc_html( $customer->name . ' (' . $customer->email . ')' );
195
+		if ($customers) {
196
+			$options[0] = esc_html__('No donor attached', 'give');
197
+			foreach ($customers as $customer) {
198
+				$options[absint($customer->id)] = esc_html($customer->name.' ('.$customer->email.')');
199 199
 			}
200 200
 		} else {
201
-			$options[0] = esc_html__( 'No donors found.', 'give' );
201
+			$options[0] = esc_html__('No donors found.', 'give');
202 202
 		}
203 203
 
204
-		if ( ! empty( $args['selected'] ) ) {
204
+		if ( ! empty($args['selected'])) {
205 205
 
206 206
 			// If a selected customer has been specified, we need to ensure it's in the initial list of customers displayed.
207 207
 
208
-			if ( ! array_key_exists( $args['selected'], $options ) ) {
208
+			if ( ! array_key_exists($args['selected'], $options)) {
209 209
 
210
-				$customer = new Give_Customer( $args['selected'] );
210
+				$customer = new Give_Customer($args['selected']);
211 211
 
212
-				if ( $customer ) {
212
+				if ($customer) {
213 213
 
214
-					$options[ absint( $args['selected'] ) ] = esc_html( $customer->name . ' (' . $customer->email . ')' );
214
+					$options[absint($args['selected'])] = esc_html($customer->name.' ('.$customer->email.')');
215 215
 
216 216
 				}
217 217
 
@@ -219,18 +219,18 @@  discard block
 block discarded – undo
219 219
 
220 220
 		}
221 221
 
222
-		$output = $this->select( array(
222
+		$output = $this->select(array(
223 223
 			'name'             => $args['name'],
224 224
 			'selected'         => $args['selected'],
225 225
 			'id'               => $args['id'],
226
-			'class'            => $args['class'] . ' give-customer-select',
226
+			'class'            => $args['class'].' give-customer-select',
227 227
 			'options'          => $options,
228 228
 			'multiple'         => $args['multiple'],
229 229
 			'chosen'           => $args['chosen'],
230 230
 			'show_option_all'  => false,
231 231
 			'show_option_none' => false,
232 232
 			'data'             => $args['data'],
233
-		) );
233
+		));
234 234
 
235 235
 		return $output;
236 236
 	}
@@ -249,24 +249,24 @@  discard block
 block discarded – undo
249 249
 	 *
250 250
 	 * @return string           Categories dropdown.
251 251
 	 */
252
-	public function category_dropdown( $name = 'give_forms_categories', $selected = 0, $args = array() ) {
253
-		$categories = get_terms( 'give_forms_category', apply_filters( 'give_forms_category_dropdown', array() ) );
252
+	public function category_dropdown($name = 'give_forms_categories', $selected = 0, $args = array()) {
253
+		$categories = get_terms('give_forms_category', apply_filters('give_forms_category_dropdown', array()));
254 254
 		$options    = array();
255 255
 
256
-		foreach ( $categories as $category ) {
257
-			$options[ absint( $category->term_id ) ] = esc_html( $category->name );
256
+		foreach ($categories as $category) {
257
+			$options[absint($category->term_id)] = esc_html($category->name);
258 258
 		}
259 259
 
260
-		$output = $this->select( wp_parse_args(
260
+		$output = $this->select(wp_parse_args(
261 261
 			$args,
262 262
 			array(
263 263
 				'name'             => $name,
264 264
 				'selected'         => $selected,
265 265
 				'options'          => $options,
266
-				'show_option_all'  => esc_html__( 'All Categories', 'give' ),
266
+				'show_option_all'  => esc_html__('All Categories', 'give'),
267 267
 				'show_option_none' => false
268 268
 			)
269
-		) );
269
+		));
270 270
 
271 271
 		return $output;
272 272
 	}
@@ -285,24 +285,24 @@  discard block
 block discarded – undo
285 285
 	 *
286 286
 	 * @return string           Tags dropdown.
287 287
 	 */
288
-	public function tags_dropdown( $name = 'give_forms_tags', $selected = 0, $args = array() ) {
289
-		$tags    = get_terms( 'give_forms_tag', apply_filters( 'give_forms_tag_dropdown', array() ) );
288
+	public function tags_dropdown($name = 'give_forms_tags', $selected = 0, $args = array()) {
289
+		$tags    = get_terms('give_forms_tag', apply_filters('give_forms_tag_dropdown', array()));
290 290
 		$options = array();
291 291
 
292
-		foreach ( $tags as $tag ) {
293
-			$options[ absint( $tag->term_id ) ] = esc_html( $tag->name );
292
+		foreach ($tags as $tag) {
293
+			$options[absint($tag->term_id)] = esc_html($tag->name);
294 294
 		}
295 295
 
296
-		$output = $this->select( wp_parse_args(
296
+		$output = $this->select(wp_parse_args(
297 297
 			$args,
298 298
 			array(
299 299
 				'name'             => $name,
300 300
 				'selected'         => $selected,
301 301
 				'options'          => $options,
302
-				'show_option_all'  => esc_html__( 'All Tags', 'give' ),
302
+				'show_option_all'  => esc_html__('All Tags', 'give'),
303 303
 				'show_option_none' => false,
304 304
 			)
305
-		) );
305
+		));
306 306
 
307 307
 		return $output;
308 308
 	}
@@ -322,25 +322,25 @@  discard block
 block discarded – undo
322 322
 	 *
323 323
 	 * @return string               Years dropdown.
324 324
 	 */
325
-	public function year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) {
326
-		$current    = date( 'Y' );
327
-		$start_year = $current - absint( $years_before );
328
-		$end_year   = $current + absint( $years_after );
329
-		$selected   = empty( $selected ) ? date( 'Y' ) : $selected;
325
+	public function year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) {
326
+		$current    = date('Y');
327
+		$start_year = $current - absint($years_before);
328
+		$end_year   = $current + absint($years_after);
329
+		$selected   = empty($selected) ? date('Y') : $selected;
330 330
 		$options    = array();
331 331
 
332
-		while ( $start_year <= $end_year ) {
333
-			$options[ absint( $start_year ) ] = $start_year;
334
-			$start_year ++;
332
+		while ($start_year <= $end_year) {
333
+			$options[absint($start_year)] = $start_year;
334
+			$start_year++;
335 335
 		}
336 336
 
337
-		$output = $this->select( array(
337
+		$output = $this->select(array(
338 338
 			'name'             => $name,
339 339
 			'selected'         => $selected,
340 340
 			'options'          => $options,
341 341
 			'show_option_all'  => false,
342 342
 			'show_option_none' => false
343
-		) );
343
+		));
344 344
 
345 345
 		return $output;
346 346
 	}
@@ -358,23 +358,23 @@  discard block
 block discarded – undo
358 358
 	 *
359 359
 	 * @return string           Months dropdown.
360 360
 	 */
361
-	public function month_dropdown( $name = 'month', $selected = 0 ) {
361
+	public function month_dropdown($name = 'month', $selected = 0) {
362 362
 		$month    = 1;
363 363
 		$options  = array();
364
-		$selected = empty( $selected ) ? date( 'n' ) : $selected;
364
+		$selected = empty($selected) ? date('n') : $selected;
365 365
 
366
-		while ( $month <= 12 ) {
367
-			$options[ absint( $month ) ] = give_month_num_to_name( $month );
368
-			$month ++;
366
+		while ($month <= 12) {
367
+			$options[absint($month)] = give_month_num_to_name($month);
368
+			$month++;
369 369
 		}
370 370
 
371
-		$output = $this->select( array(
371
+		$output = $this->select(array(
372 372
 			'name'             => $name,
373 373
 			'selected'         => $selected,
374 374
 			'options'          => $options,
375 375
 			'show_option_all'  => false,
376 376
 			'show_option_none' => false
377
-		) );
377
+		));
378 378
 
379 379
 		return $output;
380 380
 	}
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 	 *
392 392
 	 * @return string      The dropdown.
393 393
 	 */
394
-	public function select( $args = array() ) {
394
+	public function select($args = array()) {
395 395
 		$defaults = array(
396 396
 			'options'          => array(),
397 397
 			'name'             => null,
@@ -402,68 +402,68 @@  discard block
 block discarded – undo
402 402
 			'placeholder'      => null,
403 403
 			'multiple'         => false,
404 404
 			'select_atts'      => false,
405
-			'show_option_all'  => __( 'All', 'give' ),
406
-			'show_option_none' => __( 'None', 'give' ),
405
+			'show_option_all'  => __('All', 'give'),
406
+			'show_option_none' => __('None', 'give'),
407 407
 			'data'             => array(),
408 408
 			'readonly'         => false,
409 409
 			'disabled'         => false,
410 410
 		);
411 411
 
412
-		$args = wp_parse_args( $args, $defaults );
412
+		$args = wp_parse_args($args, $defaults);
413 413
 
414 414
 		$data_elements = '';
415
-		foreach ( $args['data'] as $key => $value ) {
416
-			$data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
415
+		foreach ($args['data'] as $key => $value) {
416
+			$data_elements .= ' data-'.esc_attr($key).'="'.esc_attr($value).'"';
417 417
 		}
418 418
 
419
-		if ( $args['multiple'] ) {
419
+		if ($args['multiple']) {
420 420
 			$multiple = ' MULTIPLE';
421 421
 		} else {
422 422
 			$multiple = '';
423 423
 		}
424 424
 
425
-		if ( $args['chosen'] ) {
425
+		if ($args['chosen']) {
426 426
 			$args['class'] .= ' give-select-chosen';
427 427
 		}
428 428
 
429
-		if ( $args['placeholder'] ) {
429
+		if ($args['placeholder']) {
430 430
 			$placeholder = $args['placeholder'];
431 431
 		} else {
432 432
 			$placeholder = '';
433 433
 		}
434 434
 
435 435
 
436
-		$output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( sanitize_key( str_replace( '-', '_', $args['id'] ) ) ) . '" class="give-select ' . esc_attr( $args['class'] ) . '"' . $multiple . ' ' . $args['select_atts'] . ' data-placeholder="' . $placeholder . '"' . $data_elements . '>';
436
+		$output = '<select name="'.esc_attr($args['name']).'" id="'.esc_attr(sanitize_key(str_replace('-', '_', $args['id']))).'" class="give-select '.esc_attr($args['class']).'"'.$multiple.' '.$args['select_atts'].' data-placeholder="'.$placeholder.'"'.$data_elements.'>';
437 437
 
438
-		if ( $args['show_option_all'] ) {
439
-			if ( $args['multiple'] ) {
440
-				$selected = selected( true, in_array( 0, $args['selected'] ), false );
438
+		if ($args['show_option_all']) {
439
+			if ($args['multiple']) {
440
+				$selected = selected(true, in_array(0, $args['selected']), false);
441 441
 			} else {
442
-				$selected = selected( $args['selected'], 0, false );
442
+				$selected = selected($args['selected'], 0, false);
443 443
 			}
444
-			$output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>';
444
+			$output .= '<option value="all"'.$selected.'>'.esc_html($args['show_option_all']).'</option>';
445 445
 		}
446 446
 
447
-		if ( ! empty( $args['options'] ) ) {
447
+		if ( ! empty($args['options'])) {
448 448
 
449
-			if ( $args['show_option_none'] ) {
450
-				if ( $args['multiple'] ) {
451
-					$selected = selected( true, in_array( - 1, $args['selected'] ), false );
449
+			if ($args['show_option_none']) {
450
+				if ($args['multiple']) {
451
+					$selected = selected(true, in_array( -1, $args['selected'] ), false);
452 452
 				} else {
453
-					$selected = selected( $args['selected'], - 1, false );
453
+					$selected = selected($args['selected'], - 1, false);
454 454
 				}
455
-				$output .= '<option value="-1"' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>';
455
+				$output .= '<option value="-1"'.$selected.'>'.esc_html($args['show_option_none']).'</option>';
456 456
 			}
457 457
 
458
-			foreach ( $args['options'] as $key => $option ) {
458
+			foreach ($args['options'] as $key => $option) {
459 459
 
460
-				if ( $args['multiple'] && is_array( $args['selected'] ) ) {
461
-					$selected = selected( true, in_array( $key, $args['selected'] ), false );
460
+				if ($args['multiple'] && is_array($args['selected'])) {
461
+					$selected = selected(true, in_array($key, $args['selected']), false);
462 462
 				} else {
463
-					$selected = selected( $args['selected'], $key, false );
463
+					$selected = selected($args['selected'], $key, false);
464 464
 				}
465 465
 
466
-				$output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>';
466
+				$output .= '<option value="'.esc_attr($key).'"'.$selected.'>'.esc_html($option).'</option>';
467 467
 			}
468 468
 		}
469 469
 
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 	 *
485 485
 	 * @return string      The checkbox.
486 486
 	 */
487
-	public function checkbox( $args = array() ) {
487
+	public function checkbox($args = array()) {
488 488
 		$defaults = array(
489 489
 			'name'    => null,
490 490
 			'current' => null,
@@ -495,16 +495,16 @@  discard block
 block discarded – undo
495 495
 			)
496 496
 		);
497 497
 
498
-		$args = wp_parse_args( $args, $defaults );
498
+		$args = wp_parse_args($args, $defaults);
499 499
 
500 500
 		$options = '';
501
-		if ( ! empty( $args['options']['disabled'] ) ) {
501
+		if ( ! empty($args['options']['disabled'])) {
502 502
 			$options .= ' disabled="disabled"';
503
-		} elseif ( ! empty( $args['options']['readonly'] ) ) {
503
+		} elseif ( ! empty($args['options']['readonly'])) {
504 504
 			$options .= ' readonly';
505 505
 		}
506 506
 
507
-		$output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />';
507
+		$output = '<input type="checkbox"'.$options.' name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].' '.esc_attr($args['name']).'" '.checked(1, $args['current'], false).' />';
508 508
 
509 509
 		return $output;
510 510
 	}
@@ -521,22 +521,22 @@  discard block
 block discarded – undo
521 521
 	 *
522 522
 	 * @return string      The text field.
523 523
 	 */
524
-	public function text( $args = array() ) {
524
+	public function text($args = array()) {
525 525
 		// Backwards compatibility.
526
-		if ( func_num_args() > 1 ) {
526
+		if (func_num_args() > 1) {
527 527
 			$args = func_get_args();
528 528
 
529 529
 			$name  = $args[0];
530
-			$value = isset( $args[1] ) ? $args[1] : '';
531
-			$label = isset( $args[2] ) ? $args[2] : '';
532
-			$desc  = isset( $args[3] ) ? $args[3] : '';
530
+			$value = isset($args[1]) ? $args[1] : '';
531
+			$label = isset($args[2]) ? $args[2] : '';
532
+			$desc  = isset($args[3]) ? $args[3] : '';
533 533
 		}
534 534
 
535 535
 		$defaults = array(
536
-			'name'         => isset( $name ) ? $name : 'text',
537
-			'value'        => isset( $value ) ? $value : null,
538
-			'label'        => isset( $label ) ? $label : null,
539
-			'desc'         => isset( $desc ) ? $desc : null,
536
+			'name'         => isset($name) ? $name : 'text',
537
+			'value'        => isset($value) ? $value : null,
538
+			'label'        => isset($label) ? $label : null,
539
+			'desc'         => isset($desc) ? $desc : null,
540 540
 			'placeholder'  => '',
541 541
 			'class'        => 'regular-text',
542 542
 			'disabled'     => false,
@@ -544,29 +544,29 @@  discard block
 block discarded – undo
544 544
 			'data'         => false
545 545
 		);
546 546
 
547
-		$args = wp_parse_args( $args, $defaults );
547
+		$args = wp_parse_args($args, $defaults);
548 548
 
549 549
 		$disabled = '';
550
-		if ( $args['disabled'] ) {
550
+		if ($args['disabled']) {
551 551
 			$disabled = ' disabled="disabled"';
552 552
 		}
553 553
 
554 554
 		$data = '';
555
-		if ( ! empty( $args['data'] ) ) {
556
-			foreach ( $args['data'] as $key => $value ) {
557
-				$data .= 'data-' . $key . '="' . $value . '" ';
555
+		if ( ! empty($args['data'])) {
556
+			foreach ($args['data'] as $key => $value) {
557
+				$data .= 'data-'.$key.'="'.$value.'" ';
558 558
 			}
559 559
 		}
560 560
 
561
-		$output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">';
561
+		$output = '<span id="give-'.sanitize_key($args['name']).'-wrap">';
562 562
 
563
-		$output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
563
+		$output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>';
564 564
 
565
-		if ( ! empty( $args['desc'] ) ) {
566
-			$output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>';
565
+		if ( ! empty($args['desc'])) {
566
+			$output .= '<span class="give-description">'.esc_html($args['desc']).'</span>';
567 567
 		}
568 568
 
569
-		$output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $args['class'] . '" ' . $data . '' . $disabled . '/>';
569
+		$output .= '<input type="text" name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" autocomplete="'.esc_attr($args['autocomplete']).'" value="'.esc_attr($args['value']).'" placeholder="'.esc_attr($args['placeholder']).'" class="'.$args['class'].'" '.$data.''.$disabled.'/>';
570 570
 
571 571
 		$output .= '</span>';
572 572
 
@@ -585,15 +585,15 @@  discard block
 block discarded – undo
585 585
 	 *
586 586
 	 * @return string      The date picker.
587 587
 	 */
588
-	public function date_field( $args = array() ) {
588
+	public function date_field($args = array()) {
589 589
 
590
-		if ( empty( $args['class'] ) ) {
590
+		if (empty($args['class'])) {
591 591
 			$args['class'] = 'give_datepicker';
592
-		} elseif ( ! strpos( $args['class'], 'give_datepicker' ) ) {
592
+		} elseif ( ! strpos($args['class'], 'give_datepicker')) {
593 593
 			$args['class'] .= ' give_datepicker';
594 594
 		}
595 595
 
596
-		return $this->text( $args );
596
+		return $this->text($args);
597 597
 	}
598 598
 
599 599
 	/**
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
 	 *
609 609
 	 * @return string      The textarea.
610 610
 	 */
611
-	public function textarea( $args = array() ) {
611
+	public function textarea($args = array()) {
612 612
 		$defaults = array(
613 613
 			'name'     => 'textarea',
614 614
 			'value'    => null,
@@ -618,21 +618,21 @@  discard block
 block discarded – undo
618 618
 			'disabled' => false
619 619
 		);
620 620
 
621
-		$args = wp_parse_args( $args, $defaults );
621
+		$args = wp_parse_args($args, $defaults);
622 622
 
623 623
 		$disabled = '';
624
-		if ( $args['disabled'] ) {
624
+		if ($args['disabled']) {
625 625
 			$disabled = ' disabled="disabled"';
626 626
 		}
627 627
 
628
-		$output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">';
628
+		$output = '<span id="give-'.sanitize_key($args['name']).'-wrap">';
629 629
 
630
-		$output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
630
+		$output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>';
631 631
 
632
-		$output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>';
632
+		$output .= '<textarea name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].'"'.$disabled.'>'.esc_attr($args['value']).'</textarea>';
633 633
 
634
-		if ( ! empty( $args['desc'] ) ) {
635
-			$output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>';
634
+		if ( ! empty($args['desc'])) {
635
+			$output .= '<span class="give-description">'.esc_html($args['desc']).'</span>';
636 636
 		}
637 637
 
638 638
 		$output .= '</span>';
@@ -652,7 +652,7 @@  discard block
 block discarded – undo
652 652
 	 *
653 653
 	 * @return string      The text field with ajax search.
654 654
 	 */
655
-	public function ajax_user_search( $args = array() ) {
655
+	public function ajax_user_search($args = array()) {
656 656
 
657 657
 		$defaults = array(
658 658
 			'name'        => 'users',
@@ -663,30 +663,30 @@  discard block
 block discarded – undo
663 663
 			'chosen'      => true,
664 664
 			'number'      => 30,
665 665
 			'select_atts' => '',
666
-			'placeholder' => __( 'Select a user', 'give' ),
667
-			'data'        => array( 'search-type' => 'user' ),
666
+			'placeholder' => __('Select a user', 'give'),
667
+			'data'        => array('search-type' => 'user'),
668 668
 		);
669 669
 
670 670
 
671
-		$args = wp_parse_args( $args, $defaults );
671
+		$args = wp_parse_args($args, $defaults);
672 672
 
673 673
 		$get_users_args = array(
674 674
 			'number' => $args['number'],
675 675
 		);
676 676
 
677
-		$users = apply_filters( 'give_ajax_user_search_initial_results', get_users( $get_users_args ), $args );
677
+		$users = apply_filters('give_ajax_user_search_initial_results', get_users($get_users_args), $args);
678 678
 		$options = array();
679 679
 
680
-		if ( $users ) {
680
+		if ($users) {
681 681
 			$options[0] = $args['placeholder'];
682
-			foreach ( $users as $user ) {
683
-				$options[ absint( $user->id ) ] = esc_html( $user->user_login . ' (' . $user->user_email . ')' );
682
+			foreach ($users as $user) {
683
+				$options[absint($user->id)] = esc_html($user->user_login.' ('.$user->user_email.')');
684 684
 			}
685 685
 		} else {
686
-			$options[0] = esc_html__( 'No users found.', 'give' );
686
+			$options[0] = esc_html__('No users found.', 'give');
687 687
 		}
688 688
 
689
-		$output = $this->select( array(
689
+		$output = $this->select(array(
690 690
 			'name'             => $args['name'],
691 691
 			'selected'         => $args['selected'],
692 692
 			'id'               => $args['id'],
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
 			'show_option_all'  => false,
700 700
 			'show_option_none' => false,
701 701
 			'data'             => $args['data'],
702
-		) );
702
+		));
703 703
 
704 704
 		return $output;
705 705
 
Please login to merge, or discard this patch.
includes/payments/functions.php 1 patch
Spacing   +405 added lines, -405 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -43,15 +43,15 @@  discard block
 block discarded – undo
43 43
  *
44 44
  * @return array $payments Payments retrieved from the database
45 45
  */
46
-function give_get_payments( $args = array() ) {
46
+function give_get_payments($args = array()) {
47 47
 
48 48
 	// Fallback to post objects to ensure backwards compatibility.
49
-	if ( ! isset( $args['output'] ) ) {
49
+	if ( ! isset($args['output'])) {
50 50
 		$args['output'] = 'posts';
51 51
 	}
52 52
 
53
-	$args     = apply_filters( 'give_get_payments_args', $args );
54
-	$payments = new Give_Payments_Query( $args );
53
+	$args     = apply_filters('give_get_payments_args', $args);
54
+	$payments = new Give_Payments_Query($args);
55 55
 
56 56
 	return $payments->get_payments();
57 57
 }
@@ -66,48 +66,48 @@  discard block
 block discarded – undo
66 66
  *
67 67
  * @return mixed
68 68
  */
69
-function give_get_payment_by( $field = '', $value = '' ) {
69
+function give_get_payment_by($field = '', $value = '') {
70 70
 
71
-	if ( empty( $field ) || empty( $value ) ) {
71
+	if (empty($field) || empty($value)) {
72 72
 		return false;
73 73
 	}
74 74
 
75
-	switch ( strtolower( $field ) ) {
75
+	switch (strtolower($field)) {
76 76
 
77 77
 		case 'id':
78
-			$payment = new Give_Payment( $value );
78
+			$payment = new Give_Payment($value);
79 79
 			$id      = $payment->ID;
80 80
 
81
-			if ( empty( $id ) ) {
81
+			if (empty($id)) {
82 82
 				return false;
83 83
 			}
84 84
 
85 85
 			break;
86 86
 
87 87
 		case 'key':
88
-			$payment = give_get_payments( array(
88
+			$payment = give_get_payments(array(
89 89
 				'meta_key'       => '_give_payment_purchase_key',
90 90
 				'meta_value'     => $value,
91 91
 				'posts_per_page' => 1,
92 92
 				'fields'         => 'ids',
93
-			) );
93
+			));
94 94
 
95
-			if ( $payment ) {
96
-				$payment = new Give_Payment( $payment[0] );
95
+			if ($payment) {
96
+				$payment = new Give_Payment($payment[0]);
97 97
 			}
98 98
 
99 99
 			break;
100 100
 
101 101
 		case 'payment_number':
102
-			$payment = give_get_payments( array(
102
+			$payment = give_get_payments(array(
103 103
 				'meta_key'       => '_give_payment_number',
104 104
 				'meta_value'     => $value,
105 105
 				'posts_per_page' => 1,
106 106
 				'fields'         => 'ids',
107
-			) );
107
+			));
108 108
 
109
-			if ( $payment ) {
110
-				$payment = new Give_Payment( $payment[0] );
109
+			if ($payment) {
110
+				$payment = new Give_Payment($payment[0]);
111 111
 			}
112 112
 
113 113
 			break;
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 			return false;
117 117
 	}
118 118
 
119
-	if ( $payment ) {
119
+	if ($payment) {
120 120
 		return $payment;
121 121
 	}
122 122
 
@@ -132,23 +132,23 @@  discard block
 block discarded – undo
132 132
  *
133 133
  * @return int|bool Payment ID if payment is inserted, false otherwise.
134 134
  */
135
-function give_insert_payment( $payment_data = array() ) {
135
+function give_insert_payment($payment_data = array()) {
136 136
 
137
-	if ( empty( $payment_data ) ) {
137
+	if (empty($payment_data)) {
138 138
 		return false;
139 139
 	}
140 140
 
141 141
 	$payment    = new Give_Payment();
142
-	$gateway    = ! empty( $payment_data['gateway'] ) ? $payment_data['gateway'] : '';
143
-	$gateway    = empty( $gateway ) && isset( $_POST['give-gateway'] ) ? $_POST['give-gateway'] : $gateway;
144
-	$form_id    = isset( $payment_data['give_form_id'] ) ? $payment_data['give_form_id'] : 0;
145
-	$price_id   = give_get_payment_meta_price_id( $payment_data );
146
-	$form_title = isset( $payment_data['give_form_title'] ) ? $payment_data['give_form_title'] : get_the_title( $form_id );
142
+	$gateway    = ! empty($payment_data['gateway']) ? $payment_data['gateway'] : '';
143
+	$gateway    = empty($gateway) && isset($_POST['give-gateway']) ? $_POST['give-gateway'] : $gateway;
144
+	$form_id    = isset($payment_data['give_form_id']) ? $payment_data['give_form_id'] : 0;
145
+	$price_id   = give_get_payment_meta_price_id($payment_data);
146
+	$form_title = isset($payment_data['give_form_title']) ? $payment_data['give_form_title'] : get_the_title($form_id);
147 147
 
148 148
 	// Set properties.
149 149
 	$payment->total          = $payment_data['price'];
150
-	$payment->status         = ! empty( $payment_data['status'] ) ? $payment_data['status'] : 'pending';
151
-	$payment->currency       = ! empty( $payment_data['currency'] ) ? $payment_data['currency'] : give_get_currency();
150
+	$payment->status         = ! empty($payment_data['status']) ? $payment_data['status'] : 'pending';
151
+	$payment->currency       = ! empty($payment_data['currency']) ? $payment_data['currency'] : give_get_currency();
152 152
 	$payment->user_info      = $payment_data['user_info'];
153 153
 	$payment->gateway        = $gateway;
154 154
 	$payment->form_title     = $form_title;
@@ -162,31 +162,31 @@  discard block
 block discarded – undo
162 162
 	$payment->ip             = give_get_ip();
163 163
 	$payment->key            = $payment_data['purchase_key'];
164 164
 	$payment->mode           = give_is_test_mode() ? 'test' : 'live';
165
-	$payment->parent_payment = ! empty( $payment_data['parent'] ) ? absint( $payment_data['parent'] ) : '';
165
+	$payment->parent_payment = ! empty($payment_data['parent']) ? absint($payment_data['parent']) : '';
166 166
 
167 167
 	// Add the donation.
168 168
 	$args = array(
169 169
 		'price'    => $payment->total,
170 170
 		'price_id' => $payment->price_id,
171
-		'fees'     => isset( $payment_data['fees'] ) ? $payment_data['fees'] : array(),
171
+		'fees'     => isset($payment_data['fees']) ? $payment_data['fees'] : array(),
172 172
 	);
173 173
 
174
-	$payment->add_donation( $payment->form_id, $args );
174
+	$payment->add_donation($payment->form_id, $args);
175 175
 
176 176
 	// Set date if present.
177
-	if ( isset( $payment_data['post_date'] ) ) {
177
+	if (isset($payment_data['post_date'])) {
178 178
 		$payment->date = $payment_data['post_date'];
179 179
 	}
180 180
 
181 181
 	// Handle sequential payments.
182
-	if ( give_get_option( 'enable_sequential' ) ) {
182
+	if (give_get_option('enable_sequential')) {
183 183
 		$number          = give_get_next_payment_number();
184
-		$payment->number = give_format_payment_number( $number );
185
-		update_option( 'give_last_payment_number', $number );
184
+		$payment->number = give_format_payment_number($number);
185
+		update_option('give_last_payment_number', $number);
186 186
 	}
187 187
 
188 188
 	// Clear the user's donation cache.
189
-	delete_transient( 'give_user_' . $payment_data['user_info']['id'] . '_purchases' );
189
+	delete_transient('give_user_'.$payment_data['user_info']['id'].'_purchases');
190 190
 
191 191
 	// Save payment.
192 192
 	$payment->save();
@@ -199,10 +199,10 @@  discard block
 block discarded – undo
199 199
 	 * @param int $payment_id The payment ID.
200 200
 	 * @param array $payment_data Arguments passed.
201 201
 	 */
202
-	do_action( 'give_insert_payment', $payment->ID, $payment_data );
202
+	do_action('give_insert_payment', $payment->ID, $payment_data);
203 203
 
204 204
 	// Return payment ID upon success.
205
-	if ( ! empty( $payment->ID ) ) {
205
+	if ( ! empty($payment->ID)) {
206 206
 		return $payment->ID;
207 207
 	}
208 208
 
@@ -218,10 +218,10 @@  discard block
 block discarded – undo
218 218
  *
219 219
  * @return bool|int
220 220
  */
221
-function give_create_payment( $payment_data ) {
221
+function give_create_payment($payment_data) {
222 222
 
223
-	$form_id  = intval( $payment_data['post_data']['give-form-id'] );
224
-	$price_id = isset( $payment_data['post_data']['give-price-id'] ) ? $payment_data['post_data']['give-price-id'] : '';
223
+	$form_id  = intval($payment_data['post_data']['give-form-id']);
224
+	$price_id = isset($payment_data['post_data']['give-price-id']) ? $payment_data['post_data']['give-price-id'] : '';
225 225
 
226 226
 	// Collect payment data.
227 227
 	$insert_payment_data = array(
@@ -245,10 +245,10 @@  discard block
 block discarded – undo
245 245
 	 *
246 246
 	 * @param array $insert_payment_data
247 247
 	 */
248
-	$insert_payment_data = apply_filters( 'give_create_payment', $insert_payment_data );
248
+	$insert_payment_data = apply_filters('give_create_payment', $insert_payment_data);
249 249
 
250 250
 	// Record the pending payment.
251
-	return give_insert_payment( $insert_payment_data );
251
+	return give_insert_payment($insert_payment_data);
252 252
 }
253 253
 
254 254
 /**
@@ -261,9 +261,9 @@  discard block
 block discarded – undo
261 261
  *
262 262
  * @return bool
263 263
  */
264
-function give_update_payment_status( $payment_id, $new_status = 'publish' ) {
264
+function give_update_payment_status($payment_id, $new_status = 'publish') {
265 265
 
266
-	$payment         = new Give_Payment( $payment_id );
266
+	$payment         = new Give_Payment($payment_id);
267 267
 	$payment->status = $new_status;
268 268
 	$updated         = $payment->save();
269 269
 
@@ -282,38 +282,38 @@  discard block
 block discarded – undo
282 282
  *
283 283
  * @return void
284 284
  */
285
-function give_delete_purchase( $payment_id = 0, $update_customer = true ) {
285
+function give_delete_purchase($payment_id = 0, $update_customer = true) {
286 286
 	global $give_logs;
287 287
 
288
-	$payment     = new Give_Payment( $payment_id );
289
-	$amount      = give_get_payment_amount( $payment_id );
288
+	$payment     = new Give_Payment($payment_id);
289
+	$amount      = give_get_payment_amount($payment_id);
290 290
 	$status      = $payment->post_status;
291
-	$customer_id = give_get_payment_customer_id( $payment_id );
292
-	$customer    = new Give_Customer( $customer_id );
291
+	$customer_id = give_get_payment_customer_id($payment_id);
292
+	$customer    = new Give_Customer($customer_id);
293 293
 
294 294
 	// Only undo donations that aren't these statuses.
295
-	$dont_undo_statuses = apply_filters( 'give_undo_purchase_statuses', array(
295
+	$dont_undo_statuses = apply_filters('give_undo_purchase_statuses', array(
296 296
 		'pending',
297 297
 		'cancelled',
298
-	) );
298
+	));
299 299
 
300
-	if ( ! in_array( $status, $dont_undo_statuses ) ) {
301
-		give_undo_purchase( false, $payment_id );
300
+	if ( ! in_array($status, $dont_undo_statuses)) {
301
+		give_undo_purchase(false, $payment_id);
302 302
 	}
303 303
 
304
-	if ( $status == 'publish' ) {
304
+	if ($status == 'publish') {
305 305
 
306 306
 		// Only decrease earnings if they haven't already been decreased (or were never increased for this payment).
307
-		give_decrease_total_earnings( $amount );
307
+		give_decrease_total_earnings($amount);
308 308
 
309 309
 		// @todo: Refresh only range related stat cache
310 310
 		give_delete_donation_stats();
311 311
 
312
-		if ( $customer->id && $update_customer ) {
312
+		if ($customer->id && $update_customer) {
313 313
 
314 314
 			// Decrement the stats for the donor.
315 315
 			$customer->decrease_purchase_count();
316
-			$customer->decrease_value( $amount );
316
+			$customer->decrease_value($amount);
317 317
 
318 318
 		}
319 319
 	}
@@ -325,17 +325,17 @@  discard block
 block discarded – undo
325 325
 	 *
326 326
 	 * @param int $payment_id Payment ID.
327 327
 	 */
328
-	do_action( 'give_payment_delete', $payment_id );
328
+	do_action('give_payment_delete', $payment_id);
329 329
 
330
-	if ( $customer->id && $update_customer ) {
330
+	if ($customer->id && $update_customer) {
331 331
 
332 332
 		// Remove the payment ID from the donor.
333
-		$customer->remove_payment( $payment_id );
333
+		$customer->remove_payment($payment_id);
334 334
 
335 335
 	}
336 336
 
337 337
 	// Remove the payment.
338
-	wp_delete_post( $payment_id, true );
338
+	wp_delete_post($payment_id, true);
339 339
 
340 340
 	// Remove related sale log entries.
341 341
 	$give_logs->delete_logs(
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 	 *
357 357
 	 * @param int $payment_id Payment ID.
358 358
 	 */
359
-	do_action( 'give_payment_deleted', $payment_id );
359
+	do_action('give_payment_deleted', $payment_id);
360 360
 }
361 361
 
362 362
 /**
@@ -372,25 +372,25 @@  discard block
 block discarded – undo
372 372
  *
373 373
  * @return void
374 374
  */
375
-function give_undo_purchase( $form_id = false, $payment_id ) {
375
+function give_undo_purchase($form_id = false, $payment_id) {
376 376
 
377
-	if ( ! empty( $form_id ) ) {
377
+	if ( ! empty($form_id)) {
378 378
 		$form_id = false;
379
-		_give_deprected_argument( 'form_id', 'give_undo_purchase', '1.5' );
379
+		_give_deprected_argument('form_id', 'give_undo_purchase', '1.5');
380 380
 	}
381 381
 
382
-	$payment = new Give_Payment( $payment_id );
382
+	$payment = new Give_Payment($payment_id);
383 383
 
384
-	$maybe_decrease_earnings = apply_filters( 'give_decrease_earnings_on_undo', true, $payment, $payment->form_id );
385
-	if ( true === $maybe_decrease_earnings ) {
384
+	$maybe_decrease_earnings = apply_filters('give_decrease_earnings_on_undo', true, $payment, $payment->form_id);
385
+	if (true === $maybe_decrease_earnings) {
386 386
 		// Decrease earnings.
387
-		give_decrease_earnings( $payment->form_id, $payment->total );
387
+		give_decrease_earnings($payment->form_id, $payment->total);
388 388
 	}
389 389
 
390
-	$maybe_decrease_sales = apply_filters( 'give_decrease_donation_on_undo', true, $payment, $payment->form_id );
391
-	if ( true === $maybe_decrease_sales ) {
390
+	$maybe_decrease_sales = apply_filters('give_decrease_donation_on_undo', true, $payment, $payment->form_id);
391
+	if (true === $maybe_decrease_sales) {
392 392
 		// Decrease donation count.
393
-		give_decrease_purchase_count( $payment->form_id );
393
+		give_decrease_purchase_count($payment->form_id);
394 394
 	}
395 395
 
396 396
 }
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
  *
408 408
  * @return object $stats Contains the number of payments per payment status.
409 409
  */
410
-function give_count_payments( $args = array() ) {
410
+function give_count_payments($args = array()) {
411 411
 
412 412
 	global $wpdb;
413 413
 
@@ -419,18 +419,18 @@  discard block
 block discarded – undo
419 419
 		'form_id'    => null,
420 420
 	);
421 421
 
422
-	$args = wp_parse_args( $args, $defaults );
422
+	$args = wp_parse_args($args, $defaults);
423 423
 
424 424
 	$select = 'SELECT p.post_status,count( * ) AS num_posts';
425 425
 	$join   = '';
426 426
 	$where  = "WHERE p.post_type = 'give_payment'";
427 427
 
428 428
 	// Count payments for a specific user.
429
-	if ( ! empty( $args['user'] ) ) {
429
+	if ( ! empty($args['user'])) {
430 430
 
431
-		if ( is_email( $args['user'] ) ) {
431
+		if (is_email($args['user'])) {
432 432
 			$field = 'email';
433
-		} elseif ( is_numeric( $args['user'] ) ) {
433
+		} elseif (is_numeric($args['user'])) {
434 434
 			$field = 'id';
435 435
 		} else {
436 436
 			$field = '';
@@ -438,105 +438,105 @@  discard block
 block discarded – undo
438 438
 
439 439
 		$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
440 440
 
441
-		if ( ! empty( $field ) ) {
441
+		if ( ! empty($field)) {
442 442
 			$where .= "
443 443
 				AND m.meta_key = '_give_payment_user_{$field}'
444 444
 				AND m.meta_value = '{$args['user']}'";
445 445
 		}
446 446
 
447 447
 		// Count payments for a search.
448
-	} elseif ( ! empty( $args['s'] ) ) {
448
+	} elseif ( ! empty($args['s'])) {
449 449
 
450
-		if ( is_email( $args['s'] ) || strlen( $args['s'] ) == 32 ) {
450
+		if (is_email($args['s']) || strlen($args['s']) == 32) {
451 451
 
452
-			if ( is_email( $args['s'] ) ) {
452
+			if (is_email($args['s'])) {
453 453
 				$field = '_give_payment_user_email';
454 454
 			} else {
455 455
 				$field = '_give_payment_purchase_key';
456 456
 			}
457 457
 
458
-			$join  = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
459
-			$where .= $wpdb->prepare( '
458
+			$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
459
+			$where .= $wpdb->prepare('
460 460
                 AND m.meta_key = %s
461 461
                 AND m.meta_value = %s',
462 462
 				$field,
463 463
 				$args['s']
464 464
 			);
465 465
 
466
-		} elseif ( '#' == substr( $args['s'], 0, 1 ) ) {
466
+		} elseif ('#' == substr($args['s'], 0, 1)) {
467 467
 
468
-			$search = str_replace( '#:', '', $args['s'] );
469
-			$search = str_replace( '#', '', $search );
468
+			$search = str_replace('#:', '', $args['s']);
469
+			$search = str_replace('#', '', $search);
470 470
 
471 471
 			$select = 'SELECT p2.post_status,count( * ) AS num_posts ';
472 472
 			$join   = "LEFT JOIN $wpdb->postmeta m ON m.meta_key = '_give_log_payment_id' AND m.post_id = p.ID ";
473 473
 			$join   .= "INNER JOIN $wpdb->posts p2 ON m.meta_value = p2.ID ";
474 474
 			$where  = "WHERE p.post_type = 'give_log' ";
475
-			$where  .= $wpdb->prepare( 'AND p.post_parent = %d} ', $search );
475
+			$where  .= $wpdb->prepare('AND p.post_parent = %d} ', $search);
476 476
 
477
-		} elseif ( is_numeric( $args['s'] ) ) {
477
+		} elseif (is_numeric($args['s'])) {
478 478
 
479
-			$join  = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
480
-			$where .= $wpdb->prepare( "
479
+			$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
480
+			$where .= $wpdb->prepare("
481 481
 				AND m.meta_key = '_give_payment_user_id'
482 482
 				AND m.meta_value = %d",
483 483
 				$args['s']
484 484
 			);
485 485
 
486 486
 		} else {
487
-			$search = $wpdb->esc_like( $args['s'] );
488
-			$search = '%' . $search . '%';
487
+			$search = $wpdb->esc_like($args['s']);
488
+			$search = '%'.$search.'%';
489 489
 
490
-			$where .= $wpdb->prepare( 'AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search );
490
+			$where .= $wpdb->prepare('AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search);
491 491
 		}
492 492
 	}
493 493
 
494
-	if ( ! empty( $args['form_id'] ) && is_numeric( $args['form_id'] ) ) {
494
+	if ( ! empty($args['form_id']) && is_numeric($args['form_id'])) {
495 495
 
496
-		$where .= $wpdb->prepare( ' AND p.post_parent = %d', $args['form_id'] );
496
+		$where .= $wpdb->prepare(' AND p.post_parent = %d', $args['form_id']);
497 497
 
498 498
 	}
499 499
 	// Limit payments count by date.
500
-	if ( ! empty( $args['start-date'] ) && false !== strpos( $args['start-date'], '/' ) ) {
500
+	if ( ! empty($args['start-date']) && false !== strpos($args['start-date'], '/')) {
501 501
 
502
-		$date_parts = explode( '/', $args['start-date'] );
503
-		$month      = ! empty( $date_parts[0] ) && is_numeric( $date_parts[0] ) ? $date_parts[0] : 0;
504
-		$day        = ! empty( $date_parts[1] ) && is_numeric( $date_parts[1] ) ? $date_parts[1] : 0;
505
-		$year       = ! empty( $date_parts[2] ) && is_numeric( $date_parts[2] ) ? $date_parts[2] : 0;
502
+		$date_parts = explode('/', $args['start-date']);
503
+		$month      = ! empty($date_parts[0]) && is_numeric($date_parts[0]) ? $date_parts[0] : 0;
504
+		$day        = ! empty($date_parts[1]) && is_numeric($date_parts[1]) ? $date_parts[1] : 0;
505
+		$year       = ! empty($date_parts[2]) && is_numeric($date_parts[2]) ? $date_parts[2] : 0;
506 506
 
507
-		$is_date = checkdate( $month, $day, $year );
508
-		if ( false !== $is_date ) {
507
+		$is_date = checkdate($month, $day, $year);
508
+		if (false !== $is_date) {
509 509
 
510
-			$date  = new DateTime( $args['start-date'] );
511
-			$where .= $wpdb->prepare( " AND p.post_date >= '%s'", $date->format( 'Y-m-d' ) );
510
+			$date = new DateTime($args['start-date']);
511
+			$where .= $wpdb->prepare(" AND p.post_date >= '%s'", $date->format('Y-m-d'));
512 512
 
513 513
 		}
514 514
 
515 515
 		// Fixes an issue with the payments list table counts when no end date is specified (partiy with stats class).
516
-		if ( empty( $args['end-date'] ) ) {
516
+		if (empty($args['end-date'])) {
517 517
 			$args['end-date'] = $args['start-date'];
518 518
 		}
519 519
 	}
520 520
 
521
-	if ( ! empty( $args['end-date'] ) && false !== strpos( $args['end-date'], '/' ) ) {
521
+	if ( ! empty($args['end-date']) && false !== strpos($args['end-date'], '/')) {
522 522
 
523
-		$date_parts = explode( '/', $args['end-date'] );
523
+		$date_parts = explode('/', $args['end-date']);
524 524
 
525
-		$month = ! empty( $date_parts[0] ) ? $date_parts[0] : 0;
526
-		$day   = ! empty( $date_parts[1] ) ? $date_parts[1] : 0;
527
-		$year  = ! empty( $date_parts[2] ) ? $date_parts[2] : 0;
525
+		$month = ! empty($date_parts[0]) ? $date_parts[0] : 0;
526
+		$day   = ! empty($date_parts[1]) ? $date_parts[1] : 0;
527
+		$year  = ! empty($date_parts[2]) ? $date_parts[2] : 0;
528 528
 
529
-		$is_date = checkdate( $month, $day, $year );
530
-		if ( false !== $is_date ) {
529
+		$is_date = checkdate($month, $day, $year);
530
+		if (false !== $is_date) {
531 531
 
532
-			$date  = new DateTime( $args['end-date'] );
533
-			$where .= $wpdb->prepare( " AND p.post_date <= '%s'", $date->format( 'Y-m-d' ) );
532
+			$date = new DateTime($args['end-date']);
533
+			$where .= $wpdb->prepare(" AND p.post_date <= '%s'", $date->format('Y-m-d'));
534 534
 
535 535
 		}
536 536
 	}
537 537
 
538
-	$where = apply_filters( 'give_count_payments_where', $where );
539
-	$join  = apply_filters( 'give_count_payments_join', $join );
538
+	$where = apply_filters('give_count_payments_where', $where);
539
+	$join  = apply_filters('give_count_payments_join', $join);
540 540
 
541 541
 	$query = "$select
542 542
 		FROM $wpdb->posts p
@@ -545,36 +545,36 @@  discard block
 block discarded – undo
545 545
 		GROUP BY p.post_status
546 546
 	";
547 547
 
548
-	$cache_key = md5( $query );
548
+	$cache_key = md5($query);
549 549
 
550
-	$count = wp_cache_get( $cache_key, 'counts' );
551
-	if ( false !== $count ) {
550
+	$count = wp_cache_get($cache_key, 'counts');
551
+	if (false !== $count) {
552 552
 		return $count;
553 553
 	}
554 554
 
555
-	$count = $wpdb->get_results( $query, ARRAY_A );
555
+	$count = $wpdb->get_results($query, ARRAY_A);
556 556
 
557 557
 	$stats    = array();
558 558
 	$statuses = get_post_stati();
559
-	if ( isset( $statuses['private'] ) && empty( $args['s'] ) ) {
560
-		unset( $statuses['private'] );
559
+	if (isset($statuses['private']) && empty($args['s'])) {
560
+		unset($statuses['private']);
561 561
 	}
562 562
 
563
-	foreach ( $statuses as $state ) {
564
-		$stats[ $state ] = 0;
563
+	foreach ($statuses as $state) {
564
+		$stats[$state] = 0;
565 565
 	}
566 566
 
567
-	foreach ( (array) $count as $row ) {
567
+	foreach ((array) $count as $row) {
568 568
 
569
-		if ( 'private' == $row['post_status'] && empty( $args['s'] ) ) {
569
+		if ('private' == $row['post_status'] && empty($args['s'])) {
570 570
 			continue;
571 571
 		}
572 572
 
573
-		$stats[ $row['post_status'] ] = $row['num_posts'];
573
+		$stats[$row['post_status']] = $row['num_posts'];
574 574
 	}
575 575
 
576 576
 	$stats = (object) $stats;
577
-	wp_cache_set( $cache_key, $stats, 'counts' );
577
+	wp_cache_set($cache_key, $stats, 'counts');
578 578
 
579 579
 	return $stats;
580 580
 }
@@ -589,11 +589,11 @@  discard block
 block discarded – undo
589 589
  *
590 590
  * @return bool $exists True if payment exists, false otherwise.
591 591
  */
592
-function give_check_for_existing_payment( $payment_id ) {
592
+function give_check_for_existing_payment($payment_id) {
593 593
 	$exists  = false;
594
-	$payment = new Give_Payment( $payment_id );
594
+	$payment = new Give_Payment($payment_id);
595 595
 
596
-	if ( $payment_id === $payment->ID && 'publish' === $payment->status ) {
596
+	if ($payment_id === $payment->ID && 'publish' === $payment->status) {
597 597
 		$exists = true;
598 598
 	}
599 599
 
@@ -611,31 +611,31 @@  discard block
 block discarded – undo
611 611
  *
612 612
  * @return bool|mixed True if payment status exists, false otherwise.
613 613
  */
614
-function give_get_payment_status( $payment, $return_label = false ) {
614
+function give_get_payment_status($payment, $return_label = false) {
615 615
 
616
-	if ( ! is_object( $payment ) || ! isset( $payment->post_status ) ) {
616
+	if ( ! is_object($payment) || ! isset($payment->post_status)) {
617 617
 		return false;
618 618
 	}
619 619
 
620 620
 	$statuses = give_get_payment_statuses();
621 621
 
622
-	if ( ! is_array( $statuses ) || empty( $statuses ) ) {
622
+	if ( ! is_array($statuses) || empty($statuses)) {
623 623
 		return false;
624 624
 	}
625 625
 
626 626
 	// Get payment object if no already given.
627
-	$payment = $payment instanceof Give_Payment ? $payment : new Give_Payment( $payment->ID );
627
+	$payment = $payment instanceof Give_Payment ? $payment : new Give_Payment($payment->ID);
628 628
 
629
-	if ( array_key_exists( $payment->status, $statuses ) ) {
630
-		if ( true === $return_label ) {
629
+	if (array_key_exists($payment->status, $statuses)) {
630
+		if (true === $return_label) {
631 631
 			// Return translated status label.
632
-			return $statuses[ $payment->status ];
632
+			return $statuses[$payment->status];
633 633
 		} else {
634 634
 			// Account that our 'publish' status is labeled 'Complete'
635 635
 			$post_status = 'publish' == $payment->status ? 'Complete' : $payment->post_status;
636 636
 
637 637
 			// Make sure we're matching cases, since they matter
638
-			return array_search( strtolower( $post_status ), array_map( 'strtolower', $statuses ) );
638
+			return array_search(strtolower($post_status), array_map('strtolower', $statuses));
639 639
 		}
640 640
 	}
641 641
 
@@ -651,18 +651,18 @@  discard block
 block discarded – undo
651 651
  */
652 652
 function give_get_payment_statuses() {
653 653
 	$payment_statuses = array(
654
-		'pending'     => __( 'Pending', 'give' ),
655
-		'publish'     => __( 'Complete', 'give' ),
656
-		'refunded'    => __( 'Refunded', 'give' ),
657
-		'failed'      => __( 'Failed', 'give' ),
658
-		'cancelled'   => __( 'Cancelled', 'give' ),
659
-		'abandoned'   => __( 'Abandoned', 'give' ),
660
-		'preapproval' => __( 'Pre-Approved', 'give' ),
661
-		'processing'  => __( 'Processing', 'give' ),
662
-		'revoked'     => __( 'Revoked', 'give' ),
654
+		'pending'     => __('Pending', 'give'),
655
+		'publish'     => __('Complete', 'give'),
656
+		'refunded'    => __('Refunded', 'give'),
657
+		'failed'      => __('Failed', 'give'),
658
+		'cancelled'   => __('Cancelled', 'give'),
659
+		'abandoned'   => __('Abandoned', 'give'),
660
+		'preapproval' => __('Pre-Approved', 'give'),
661
+		'processing'  => __('Processing', 'give'),
662
+		'revoked'     => __('Revoked', 'give'),
663 663
 	);
664 664
 
665
-	return apply_filters( 'give_payment_statuses', $payment_statuses );
665
+	return apply_filters('give_payment_statuses', $payment_statuses);
666 666
 }
667 667
 
668 668
 /**
@@ -675,10 +675,10 @@  discard block
 block discarded – undo
675 675
  * @return array $payment_status All the available payment statuses.
676 676
  */
677 677
 function give_get_payment_status_keys() {
678
-	$statuses = array_keys( give_get_payment_statuses() );
679
-	asort( $statuses );
678
+	$statuses = array_keys(give_get_payment_statuses());
679
+	asort($statuses);
680 680
 
681
-	return array_values( $statuses );
681
+	return array_values($statuses);
682 682
 }
683 683
 
684 684
 /**
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
  *
694 694
  * @return int $earnings  Earnings
695 695
  */
696
-function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) {
696
+function give_get_earnings_by_date($day = null, $month_num, $year = null, $hour = null) {
697 697
 
698 698
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead.
699 699
 	global $wpdb;
@@ -703,41 +703,41 @@  discard block
 block discarded – undo
703 703
 		'nopaging'               => true,
704 704
 		'year'                   => $year,
705 705
 		'monthnum'               => $month_num,
706
-		'post_status'            => array( 'publish' ),
706
+		'post_status'            => array('publish'),
707 707
 		'fields'                 => 'ids',
708 708
 		'update_post_term_cache' => false,
709 709
 	);
710
-	if ( ! empty( $day ) ) {
710
+	if ( ! empty($day)) {
711 711
 		$args['day'] = $day;
712 712
 	}
713 713
 
714
-	if ( ! empty( $hour ) ) {
714
+	if ( ! empty($hour)) {
715 715
 		$args['hour'] = $hour;
716 716
 	}
717 717
 
718
-	$args = apply_filters( 'give_get_earnings_by_date_args', $args );
719
-	$key  = Give_Cache::get_key( 'give_stats', $args );
718
+	$args = apply_filters('give_get_earnings_by_date_args', $args);
719
+	$key  = Give_Cache::get_key('give_stats', $args);
720 720
 
721
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
721
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
722 722
 		$earnings = false;
723 723
 	} else {
724
-		$earnings = Give_Cache::get( $key );
724
+		$earnings = Give_Cache::get($key);
725 725
 	}
726 726
 
727
-	if ( false === $earnings ) {
728
-		$sales    = get_posts( $args );
727
+	if (false === $earnings) {
728
+		$sales    = get_posts($args);
729 729
 		$earnings = 0;
730
-		if ( $sales ) {
731
-			$sales = implode( ',', $sales );
730
+		if ($sales) {
731
+			$sales = implode(',', $sales);
732 732
 
733
-			$earnings = $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$sales})" );
733
+			$earnings = $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$sales})");
734 734
 
735 735
 		}
736 736
 		// Cache the results for one hour.
737
-		Give_Cache::set( $key, $earnings, HOUR_IN_SECONDS );
737
+		Give_Cache::set($key, $earnings, HOUR_IN_SECONDS);
738 738
 	}
739 739
 
740
-	return round( $earnings, 2 );
740
+	return round($earnings, 2);
741 741
 }
742 742
 
743 743
 /**
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
  *
753 753
  * @return int $count     Sales
754 754
  */
755
-function give_get_sales_by_date( $day = null, $month_num = null, $year = null, $hour = null ) {
755
+function give_get_sales_by_date($day = null, $month_num = null, $year = null, $hour = null) {
756 756
 
757 757
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_sales() method instead.
758 758
 	$args = array(
@@ -760,14 +760,14 @@  discard block
 block discarded – undo
760 760
 		'nopaging'               => true,
761 761
 		'year'                   => $year,
762 762
 		'fields'                 => 'ids',
763
-		'post_status'            => array( 'publish' ),
763
+		'post_status'            => array('publish'),
764 764
 		'update_post_meta_cache' => false,
765 765
 		'update_post_term_cache' => false,
766 766
 	);
767 767
 
768
-	$show_free = apply_filters( 'give_sales_by_date_show_free', true, $args );
768
+	$show_free = apply_filters('give_sales_by_date_show_free', true, $args);
769 769
 
770
-	if ( false === $show_free ) {
770
+	if (false === $show_free) {
771 771
 		$args['meta_query'] = array(
772 772
 			array(
773 773
 				'key'     => '_give_payment_total',
@@ -778,33 +778,33 @@  discard block
 block discarded – undo
778 778
 		);
779 779
 	}
780 780
 
781
-	if ( ! empty( $month_num ) ) {
781
+	if ( ! empty($month_num)) {
782 782
 		$args['monthnum'] = $month_num;
783 783
 	}
784 784
 
785
-	if ( ! empty( $day ) ) {
785
+	if ( ! empty($day)) {
786 786
 		$args['day'] = $day;
787 787
 	}
788 788
 
789
-	if ( ! empty( $hour ) ) {
789
+	if ( ! empty($hour)) {
790 790
 		$args['hour'] = $hour;
791 791
 	}
792 792
 
793
-	$args = apply_filters( 'give_get_sales_by_date_args', $args );
793
+	$args = apply_filters('give_get_sales_by_date_args', $args);
794 794
 
795
-	$key = Give_Cache::get_key( 'give_stats', $args );
795
+	$key = Give_Cache::get_key('give_stats', $args);
796 796
 
797
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
797
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
798 798
 		$count = false;
799 799
 	} else {
800
-		$count = Give_Cache::get( $key );
800
+		$count = Give_Cache::get($key);
801 801
 	}
802 802
 
803
-	if ( false === $count ) {
804
-		$sales = new WP_Query( $args );
803
+	if (false === $count) {
804
+		$sales = new WP_Query($args);
805 805
 		$count = (int) $sales->post_count;
806 806
 		// Cache the results for one hour.
807
-		Give_Cache::set( $key, $count, HOUR_IN_SECONDS );
807
+		Give_Cache::set($key, $count, HOUR_IN_SECONDS);
808 808
 	}
809 809
 
810 810
 	return $count;
@@ -819,19 +819,19 @@  discard block
 block discarded – undo
819 819
  *
820 820
  * @return bool $ret True if complete, false otherwise.
821 821
  */
822
-function give_is_payment_complete( $payment_id ) {
823
-	$payment = new Give_Payment( $payment_id );
822
+function give_is_payment_complete($payment_id) {
823
+	$payment = new Give_Payment($payment_id);
824 824
 
825 825
 	$ret = false;
826 826
 
827
-	if ( $payment->ID > 0 ) {
827
+	if ($payment->ID > 0) {
828 828
 
829
-		if ( (int) $payment_id === (int) $payment->ID && 'publish' == $payment->status ) {
829
+		if ((int) $payment_id === (int) $payment->ID && 'publish' == $payment->status) {
830 830
 			$ret = true;
831 831
 		}
832 832
 	}
833 833
 
834
-	return apply_filters( 'give_is_payment_complete', $ret, $payment_id, $payment->post_status );
834
+	return apply_filters('give_is_payment_complete', $ret, $payment_id, $payment->post_status);
835 835
 }
836 836
 
837 837
 /**
@@ -857,49 +857,49 @@  discard block
 block discarded – undo
857 857
  *
858 858
  * @return float $total Total earnings.
859 859
  */
860
-function give_get_total_earnings( $recalculate = false ) {
860
+function give_get_total_earnings($recalculate = false) {
861 861
 
862
-	$total = get_option( 'give_earnings_total', 0 );
862
+	$total = get_option('give_earnings_total', 0);
863 863
 
864 864
 	// Calculate total earnings.
865
-	if ( ! $total || $recalculate ) {
865
+	if ( ! $total || $recalculate) {
866 866
 		global $wpdb;
867 867
 
868 868
 		$total = (float) 0;
869 869
 
870
-		$args = apply_filters( 'give_get_total_earnings_args', array(
870
+		$args = apply_filters('give_get_total_earnings_args', array(
871 871
 			'offset' => 0,
872
-			'number' => - 1,
873
-			'status' => array( 'publish' ),
872
+			'number' => -1,
873
+			'status' => array('publish'),
874 874
 			'fields' => 'ids',
875
-		) );
875
+		));
876 876
 
877
-		$payments = give_get_payments( $args );
878
-		if ( $payments ) {
877
+		$payments = give_get_payments($args);
878
+		if ($payments) {
879 879
 
880 880
 			/**
881 881
 			 * If performing a donation, we need to skip the very last payment in the database,
882 882
 			 * since it calls give_increase_total_earnings() on completion,
883 883
 			 * which results in duplicated earnings for the very first donation.
884 884
 			 */
885
-			if ( did_action( 'give_update_payment_status' ) ) {
886
-				array_pop( $payments );
885
+			if (did_action('give_update_payment_status')) {
886
+				array_pop($payments);
887 887
 			}
888 888
 
889
-			if ( ! empty( $payments ) ) {
890
-				$payments = implode( ',', $payments );
891
-				$total    += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})" );
889
+			if ( ! empty($payments)) {
890
+				$payments = implode(',', $payments);
891
+				$total += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})");
892 892
 			}
893 893
 		}
894 894
 
895
-		update_option( 'give_earnings_total', $total, 'no' );
895
+		update_option('give_earnings_total', $total, 'no');
896 896
 	}
897 897
 
898
-	if ( $total < 0 ) {
898
+	if ($total < 0) {
899 899
 		$total = 0; // Don't ever show negative earnings.
900 900
 	}
901 901
 
902
-	return apply_filters( 'give_total_earnings', round( $total, give_currency_decimal_filter() ) );
902
+	return apply_filters('give_total_earnings', round($total, give_currency_decimal_filter()));
903 903
 }
904 904
 
905 905
 /**
@@ -912,10 +912,10 @@  discard block
 block discarded – undo
912 912
  *
913 913
  * @return float $total  Total earnings.
914 914
  */
915
-function give_increase_total_earnings( $amount = 0 ) {
915
+function give_increase_total_earnings($amount = 0) {
916 916
 	$total = give_get_total_earnings();
917 917
 	$total += $amount;
918
-	update_option( 'give_earnings_total', $total );
918
+	update_option('give_earnings_total', $total);
919 919
 
920 920
 	return $total;
921 921
 }
@@ -929,13 +929,13 @@  discard block
 block discarded – undo
929 929
  *
930 930
  * @return float $total Total earnings.
931 931
  */
932
-function give_decrease_total_earnings( $amount = 0 ) {
932
+function give_decrease_total_earnings($amount = 0) {
933 933
 	$total = give_get_total_earnings();
934 934
 	$total -= $amount;
935
-	if ( $total < 0 ) {
935
+	if ($total < 0) {
936 936
 		$total = 0;
937 937
 	}
938
-	update_option( 'give_earnings_total', $total );
938
+	update_option('give_earnings_total', $total);
939 939
 
940 940
 	return $total;
941 941
 }
@@ -951,10 +951,10 @@  discard block
 block discarded – undo
951 951
  *
952 952
  * @return mixed $meta Payment Meta.
953 953
  */
954
-function give_get_payment_meta( $payment_id = 0, $meta_key = '_give_payment_meta', $single = true ) {
955
-	$payment = new Give_Payment( $payment_id );
954
+function give_get_payment_meta($payment_id = 0, $meta_key = '_give_payment_meta', $single = true) {
955
+	$payment = new Give_Payment($payment_id);
956 956
 
957
-	return $payment->get_meta( $meta_key, $single );
957
+	return $payment->get_meta($meta_key, $single);
958 958
 }
959 959
 
960 960
 /**
@@ -967,10 +967,10 @@  discard block
 block discarded – undo
967 967
  *
968 968
  * @return mixed Meta ID if successful, false if unsuccessful.
969 969
  */
970
-function give_update_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) {
971
-	$payment = new Give_Payment( $payment_id );
970
+function give_update_payment_meta($payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') {
971
+	$payment = new Give_Payment($payment_id);
972 972
 
973
-	return $payment->update_meta( $meta_key, $meta_value, $prev_value );
973
+	return $payment->update_meta($meta_key, $meta_value, $prev_value);
974 974
 }
975 975
 
976 976
 /**
@@ -982,8 +982,8 @@  discard block
 block discarded – undo
982 982
  *
983 983
  * @return string $user_info User Info Meta Values.
984 984
  */
985
-function give_get_payment_meta_user_info( $payment_id ) {
986
-	$payment = new Give_Payment( $payment_id );
985
+function give_get_payment_meta_user_info($payment_id) {
986
+	$payment = new Give_Payment($payment_id);
987 987
 
988 988
 	return $payment->user_info;
989 989
 }
@@ -999,8 +999,8 @@  discard block
 block discarded – undo
999 999
  *
1000 1000
  * @return int $form_id Form ID.
1001 1001
  */
1002
-function give_get_payment_form_id( $payment_id ) {
1003
-	$payment = new Give_Payment( $payment_id );
1002
+function give_get_payment_form_id($payment_id) {
1003
+	$payment = new Give_Payment($payment_id);
1004 1004
 
1005 1005
 	return $payment->form_id;
1006 1006
 }
@@ -1014,8 +1014,8 @@  discard block
 block discarded – undo
1014 1014
  *
1015 1015
  * @return string $email User email.
1016 1016
  */
1017
-function give_get_payment_user_email( $payment_id ) {
1018
-	$payment = new Give_Payment( $payment_id );
1017
+function give_get_payment_user_email($payment_id) {
1018
+	$payment = new Give_Payment($payment_id);
1019 1019
 
1020 1020
 	return $payment->email;
1021 1021
 }
@@ -1029,11 +1029,11 @@  discard block
 block discarded – undo
1029 1029
  *
1030 1030
  * @return bool $is_guest_payment If the payment is associated with a user (false) or not (true)
1031 1031
  */
1032
-function give_is_guest_payment( $payment_id ) {
1033
-	$payment_user_id  = give_get_payment_user_id( $payment_id );
1034
-	$is_guest_payment = ! empty( $payment_user_id ) && $payment_user_id > 0 ? false : true;
1032
+function give_is_guest_payment($payment_id) {
1033
+	$payment_user_id  = give_get_payment_user_id($payment_id);
1034
+	$is_guest_payment = ! empty($payment_user_id) && $payment_user_id > 0 ? false : true;
1035 1035
 
1036
-	return (bool) apply_filters( 'give_is_guest_payment', $is_guest_payment, $payment_id );
1036
+	return (bool) apply_filters('give_is_guest_payment', $is_guest_payment, $payment_id);
1037 1037
 }
1038 1038
 
1039 1039
 /**
@@ -1045,8 +1045,8 @@  discard block
 block discarded – undo
1045 1045
  *
1046 1046
  * @return int $user_id User ID.
1047 1047
  */
1048
-function give_get_payment_user_id( $payment_id ) {
1049
-	$payment = new Give_Payment( $payment_id );
1048
+function give_get_payment_user_id($payment_id) {
1049
+	$payment = new Give_Payment($payment_id);
1050 1050
 
1051 1051
 	return $payment->user_id;
1052 1052
 }
@@ -1060,8 +1060,8 @@  discard block
 block discarded – undo
1060 1060
  *
1061 1061
  * @return int $customer_id Customer ID.
1062 1062
  */
1063
-function give_get_payment_customer_id( $payment_id ) {
1064
-	$payment = new Give_Payment( $payment_id );
1063
+function give_get_payment_customer_id($payment_id) {
1064
+	$payment = new Give_Payment($payment_id);
1065 1065
 
1066 1066
 	return $payment->customer_id;
1067 1067
 }
@@ -1075,8 +1075,8 @@  discard block
 block discarded – undo
1075 1075
  *
1076 1076
  * @return string $ip User IP.
1077 1077
  */
1078
-function give_get_payment_user_ip( $payment_id ) {
1079
-	$payment = new Give_Payment( $payment_id );
1078
+function give_get_payment_user_ip($payment_id) {
1079
+	$payment = new Give_Payment($payment_id);
1080 1080
 
1081 1081
 	return $payment->ip;
1082 1082
 }
@@ -1090,8 +1090,8 @@  discard block
 block discarded – undo
1090 1090
  *
1091 1091
  * @return string $date The date the payment was completed.
1092 1092
  */
1093
-function give_get_payment_completed_date( $payment_id = 0 ) {
1094
-	$payment = new Give_Payment( $payment_id );
1093
+function give_get_payment_completed_date($payment_id = 0) {
1094
+	$payment = new Give_Payment($payment_id);
1095 1095
 
1096 1096
 	return $payment->completed_date;
1097 1097
 }
@@ -1105,8 +1105,8 @@  discard block
 block discarded – undo
1105 1105
  *
1106 1106
  * @return string $gateway Gateway.
1107 1107
  */
1108
-function give_get_payment_gateway( $payment_id ) {
1109
-	$payment = new Give_Payment( $payment_id );
1108
+function give_get_payment_gateway($payment_id) {
1109
+	$payment = new Give_Payment($payment_id);
1110 1110
 
1111 1111
 	return $payment->gateway;
1112 1112
 }
@@ -1120,8 +1120,8 @@  discard block
 block discarded – undo
1120 1120
  *
1121 1121
  * @return string $currency The currency code.
1122 1122
  */
1123
-function give_get_payment_currency_code( $payment_id = 0 ) {
1124
-	$payment = new Give_Payment( $payment_id );
1123
+function give_get_payment_currency_code($payment_id = 0) {
1124
+	$payment = new Give_Payment($payment_id);
1125 1125
 
1126 1126
 	return $payment->currency;
1127 1127
 }
@@ -1135,10 +1135,10 @@  discard block
 block discarded – undo
1135 1135
  *
1136 1136
  * @return string $currency The currency name.
1137 1137
  */
1138
-function give_get_payment_currency( $payment_id = 0 ) {
1139
-	$currency = give_get_payment_currency_code( $payment_id );
1138
+function give_get_payment_currency($payment_id = 0) {
1139
+	$currency = give_get_payment_currency_code($payment_id);
1140 1140
 
1141
-	return apply_filters( 'give_payment_currency', give_get_currency_name( $currency ), $payment_id );
1141
+	return apply_filters('give_payment_currency', give_get_currency_name($currency), $payment_id);
1142 1142
 }
1143 1143
 
1144 1144
 /**
@@ -1150,8 +1150,8 @@  discard block
 block discarded – undo
1150 1150
  *
1151 1151
  * @return string $key Donation key.
1152 1152
  */
1153
-function give_get_payment_key( $payment_id = 0 ) {
1154
-	$payment = new Give_Payment( $payment_id );
1153
+function give_get_payment_key($payment_id = 0) {
1154
+	$payment = new Give_Payment($payment_id);
1155 1155
 
1156 1156
 	return $payment->key;
1157 1157
 }
@@ -1167,8 +1167,8 @@  discard block
 block discarded – undo
1167 1167
  *
1168 1168
  * @return string $number Payment order number.
1169 1169
  */
1170
-function give_get_payment_number( $payment_id = 0 ) {
1171
-	$payment = new Give_Payment( $payment_id );
1170
+function give_get_payment_number($payment_id = 0) {
1171
+	$payment = new Give_Payment($payment_id);
1172 1172
 
1173 1173
 	return $payment->number;
1174 1174
 }
@@ -1182,23 +1182,23 @@  discard block
 block discarded – undo
1182 1182
  *
1183 1183
  * @return string      The formatted payment number.
1184 1184
  */
1185
-function give_format_payment_number( $number ) {
1185
+function give_format_payment_number($number) {
1186 1186
 
1187
-	if ( ! give_get_option( 'enable_sequential' ) ) {
1187
+	if ( ! give_get_option('enable_sequential')) {
1188 1188
 		return $number;
1189 1189
 	}
1190 1190
 
1191
-	if ( ! is_numeric( $number ) ) {
1191
+	if ( ! is_numeric($number)) {
1192 1192
 		return $number;
1193 1193
 	}
1194 1194
 
1195
-	$prefix  = give_get_option( 'sequential_prefix' );
1196
-	$number  = absint( $number );
1197
-	$postfix = give_get_option( 'sequential_postfix' );
1195
+	$prefix  = give_get_option('sequential_prefix');
1196
+	$number  = absint($number);
1197
+	$postfix = give_get_option('sequential_postfix');
1198 1198
 
1199
-	$formatted_number = $prefix . $number . $postfix;
1199
+	$formatted_number = $prefix.$number.$postfix;
1200 1200
 
1201
-	return apply_filters( 'give_format_payment_number', $formatted_number, $prefix, $number, $postfix );
1201
+	return apply_filters('give_format_payment_number', $formatted_number, $prefix, $number, $postfix);
1202 1202
 }
1203 1203
 
1204 1204
 /**
@@ -1211,17 +1211,17 @@  discard block
 block discarded – undo
1211 1211
  */
1212 1212
 function give_get_next_payment_number() {
1213 1213
 
1214
-	if ( ! give_get_option( 'enable_sequential' ) ) {
1214
+	if ( ! give_get_option('enable_sequential')) {
1215 1215
 		return false;
1216 1216
 	}
1217 1217
 
1218
-	$number           = get_option( 'give_last_payment_number' );
1219
-	$start            = give_get_option( 'sequential_start', 1 );
1218
+	$number           = get_option('give_last_payment_number');
1219
+	$start            = give_get_option('sequential_start', 1);
1220 1220
 	$increment_number = true;
1221 1221
 
1222
-	if ( false !== $number ) {
1222
+	if (false !== $number) {
1223 1223
 
1224
-		if ( empty( $number ) ) {
1224
+		if (empty($number)) {
1225 1225
 
1226 1226
 			$number           = $start;
1227 1227
 			$increment_number = false;
@@ -1230,24 +1230,24 @@  discard block
 block discarded – undo
1230 1230
 	} else {
1231 1231
 
1232 1232
 		// This case handles the first addition of the new option, as well as if it get's deleted for any reason.
1233
-		$payments     = new Give_Payments_Query( array(
1233
+		$payments = new Give_Payments_Query(array(
1234 1234
 			'number'  => 1,
1235 1235
 			'order'   => 'DESC',
1236 1236
 			'orderby' => 'ID',
1237 1237
 			'output'  => 'posts',
1238 1238
 			'fields'  => 'ids',
1239
-		) );
1239
+		));
1240 1240
 		$last_payment = $payments->get_payments();
1241 1241
 
1242
-		if ( ! empty( $last_payment ) ) {
1242
+		if ( ! empty($last_payment)) {
1243 1243
 
1244
-			$number = give_get_payment_number( $last_payment[0] );
1244
+			$number = give_get_payment_number($last_payment[0]);
1245 1245
 
1246 1246
 		}
1247 1247
 
1248
-		if ( ! empty( $number ) && $number !== (int) $last_payment[0] ) {
1248
+		if ( ! empty($number) && $number !== (int) $last_payment[0]) {
1249 1249
 
1250
-			$number = give_remove_payment_prefix_postfix( $number );
1250
+			$number = give_remove_payment_prefix_postfix($number);
1251 1251
 
1252 1252
 		} else {
1253 1253
 
@@ -1256,13 +1256,13 @@  discard block
 block discarded – undo
1256 1256
 		}
1257 1257
 	}
1258 1258
 
1259
-	$increment_number = apply_filters( 'give_increment_payment_number', $increment_number, $number );
1259
+	$increment_number = apply_filters('give_increment_payment_number', $increment_number, $number);
1260 1260
 
1261
-	if ( $increment_number ) {
1262
-		$number ++;
1261
+	if ($increment_number) {
1262
+		$number++;
1263 1263
 	}
1264 1264
 
1265
-	return apply_filters( 'give_get_next_payment_number', $number );
1265
+	return apply_filters('give_get_next_payment_number', $number);
1266 1266
 }
1267 1267
 
1268 1268
 /**
@@ -1274,25 +1274,25 @@  discard block
 block discarded – undo
1274 1274
  *
1275 1275
  * @return string The new Payment number without prefix and postfix.
1276 1276
  */
1277
-function give_remove_payment_prefix_postfix( $number ) {
1277
+function give_remove_payment_prefix_postfix($number) {
1278 1278
 
1279
-	$prefix  = give_get_option( 'sequential_prefix' );
1280
-	$postfix = give_get_option( 'sequential_postfix' );
1279
+	$prefix  = give_get_option('sequential_prefix');
1280
+	$postfix = give_get_option('sequential_postfix');
1281 1281
 
1282 1282
 	// Remove prefix.
1283
-	$number = preg_replace( '/' . $prefix . '/', '', $number, 1 );
1283
+	$number = preg_replace('/'.$prefix.'/', '', $number, 1);
1284 1284
 
1285 1285
 	// Remove the postfix.
1286
-	$length      = strlen( $number );
1287
-	$postfix_pos = strrpos( $number, $postfix );
1288
-	if ( false !== $postfix_pos ) {
1289
-		$number = substr_replace( $number, '', $postfix_pos, $length );
1286
+	$length      = strlen($number);
1287
+	$postfix_pos = strrpos($number, $postfix);
1288
+	if (false !== $postfix_pos) {
1289
+		$number = substr_replace($number, '', $postfix_pos, $length);
1290 1290
 	}
1291 1291
 
1292 1292
 	// Ensure it's a whole number.
1293
-	$number = intval( $number );
1293
+	$number = intval($number);
1294 1294
 
1295
-	return apply_filters( 'give_remove_payment_prefix_postfix', $number, $prefix, $postfix );
1295
+	return apply_filters('give_remove_payment_prefix_postfix', $number, $prefix, $postfix);
1296 1296
 
1297 1297
 }
1298 1298
 
@@ -1309,10 +1309,10 @@  discard block
 block discarded – undo
1309 1309
  *
1310 1310
  * @return string $amount Fully formatted payment amount.
1311 1311
  */
1312
-function give_payment_amount( $payment_id = 0 ) {
1313
-	$amount = give_get_payment_amount( $payment_id );
1312
+function give_payment_amount($payment_id = 0) {
1313
+	$amount = give_get_payment_amount($payment_id);
1314 1314
 
1315
-	return give_currency_filter( give_format_amount( $amount ), give_get_payment_currency_code( $payment_id ) );
1315
+	return give_currency_filter(give_format_amount($amount), give_get_payment_currency_code($payment_id));
1316 1316
 }
1317 1317
 
1318 1318
 /**
@@ -1325,11 +1325,11 @@  discard block
 block discarded – undo
1325 1325
  *
1326 1326
  * @return mixed|void
1327 1327
  */
1328
-function give_get_payment_amount( $payment_id ) {
1328
+function give_get_payment_amount($payment_id) {
1329 1329
 
1330
-	$payment = new Give_Payment( $payment_id );
1330
+	$payment = new Give_Payment($payment_id);
1331 1331
 
1332
-	return apply_filters( 'give_payment_amount', floatval( $payment->total ), $payment_id );
1332
+	return apply_filters('give_payment_amount', floatval($payment->total), $payment_id);
1333 1333
 }
1334 1334
 
1335 1335
 /**
@@ -1346,10 +1346,10 @@  discard block
 block discarded – undo
1346 1346
  *
1347 1347
  * @return array Fully formatted payment subtotal.
1348 1348
  */
1349
-function give_payment_subtotal( $payment_id = 0 ) {
1350
-	$subtotal = give_get_payment_subtotal( $payment_id );
1349
+function give_payment_subtotal($payment_id = 0) {
1350
+	$subtotal = give_get_payment_subtotal($payment_id);
1351 1351
 
1352
-	return give_currency_filter( give_format_amount( $subtotal ), give_get_payment_currency_code( $payment_id ) );
1352
+	return give_currency_filter(give_format_amount($subtotal), give_get_payment_currency_code($payment_id));
1353 1353
 }
1354 1354
 
1355 1355
 /**
@@ -1363,8 +1363,8 @@  discard block
 block discarded – undo
1363 1363
  *
1364 1364
  * @return float $subtotal Subtotal for payment (non formatted).
1365 1365
  */
1366
-function give_get_payment_subtotal( $payment_id = 0 ) {
1367
-	$payment = new G_Payment( $payment_id );
1366
+function give_get_payment_subtotal($payment_id = 0) {
1367
+	$payment = new G_Payment($payment_id);
1368 1368
 
1369 1369
 	return $payment->subtotal;
1370 1370
 }
@@ -1379,10 +1379,10 @@  discard block
 block discarded – undo
1379 1379
  *
1380 1380
  * @return mixed array if payment fees found, false otherwise.
1381 1381
  */
1382
-function give_get_payment_fees( $payment_id = 0, $type = 'all' ) {
1383
-	$payment = new Give_Payment( $payment_id );
1382
+function give_get_payment_fees($payment_id = 0, $type = 'all') {
1383
+	$payment = new Give_Payment($payment_id);
1384 1384
 
1385
-	return $payment->get_fees( $type );
1385
+	return $payment->get_fees($type);
1386 1386
 }
1387 1387
 
1388 1388
 /**
@@ -1394,8 +1394,8 @@  discard block
 block discarded – undo
1394 1394
  *
1395 1395
  * @return string The donation ID.
1396 1396
  */
1397
-function give_get_payment_transaction_id( $payment_id = 0 ) {
1398
-	$payment = new Give_Payment( $payment_id );
1397
+function give_get_payment_transaction_id($payment_id = 0) {
1398
+	$payment = new Give_Payment($payment_id);
1399 1399
 
1400 1400
 	return $payment->transaction_id;
1401 1401
 }
@@ -1410,15 +1410,15 @@  discard block
 block discarded – undo
1410 1410
  *
1411 1411
  * @return bool|mixed
1412 1412
  */
1413
-function give_set_payment_transaction_id( $payment_id = 0, $transaction_id = '' ) {
1413
+function give_set_payment_transaction_id($payment_id = 0, $transaction_id = '') {
1414 1414
 
1415
-	if ( empty( $payment_id ) || empty( $transaction_id ) ) {
1415
+	if (empty($payment_id) || empty($transaction_id)) {
1416 1416
 		return false;
1417 1417
 	}
1418 1418
 
1419
-	$transaction_id = apply_filters( 'give_set_payment_transaction_id', $transaction_id, $payment_id );
1419
+	$transaction_id = apply_filters('give_set_payment_transaction_id', $transaction_id, $payment_id);
1420 1420
 
1421
-	return give_update_payment_meta( $payment_id, '_give_payment_transaction_id', $transaction_id );
1421
+	return give_update_payment_meta($payment_id, '_give_payment_transaction_id', $transaction_id);
1422 1422
 }
1423 1423
 
1424 1424
 /**
@@ -1431,12 +1431,12 @@  discard block
 block discarded – undo
1431 1431
  *
1432 1432
  * @return int $purchase Donation ID.
1433 1433
  */
1434
-function give_get_purchase_id_by_key( $key ) {
1434
+function give_get_purchase_id_by_key($key) {
1435 1435
 	global $wpdb;
1436 1436
 
1437
-	$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 ) );
1437
+	$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));
1438 1438
 
1439
-	if ( $purchase != null ) {
1439
+	if ($purchase != null) {
1440 1440
 		return $purchase;
1441 1441
 	}
1442 1442
 
@@ -1454,12 +1454,12 @@  discard block
 block discarded – undo
1454 1454
  *
1455 1455
  * @return int $purchase Donation ID.
1456 1456
  */
1457
-function give_get_purchase_id_by_transaction_id( $key ) {
1457
+function give_get_purchase_id_by_transaction_id($key) {
1458 1458
 	global $wpdb;
1459 1459
 
1460
-	$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 ) );
1460
+	$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));
1461 1461
 
1462
-	if ( $purchase != null ) {
1462
+	if ($purchase != null) {
1463 1463
 		return $purchase;
1464 1464
 	}
1465 1465
 
@@ -1476,19 +1476,19 @@  discard block
 block discarded – undo
1476 1476
  *
1477 1477
  * @return array $notes Donation Notes
1478 1478
  */
1479
-function give_get_payment_notes( $payment_id = 0, $search = '' ) {
1479
+function give_get_payment_notes($payment_id = 0, $search = '') {
1480 1480
 
1481
-	if ( empty( $payment_id ) && empty( $search ) ) {
1481
+	if (empty($payment_id) && empty($search)) {
1482 1482
 		return false;
1483 1483
 	}
1484 1484
 
1485
-	remove_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1486
-	remove_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10 );
1485
+	remove_action('pre_get_comments', 'give_hide_payment_notes', 10);
1486
+	remove_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10);
1487 1487
 
1488
-	$notes = get_comments( array( 'post_id' => $payment_id, 'order' => 'ASC', 'search' => $search ) );
1488
+	$notes = get_comments(array('post_id' => $payment_id, 'order' => 'ASC', 'search' => $search));
1489 1489
 
1490
-	add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1491
-	add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 );
1490
+	add_action('pre_get_comments', 'give_hide_payment_notes', 10);
1491
+	add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2);
1492 1492
 
1493 1493
 	return $notes;
1494 1494
 }
@@ -1504,8 +1504,8 @@  discard block
 block discarded – undo
1504 1504
  *
1505 1505
  * @return int The new note ID
1506 1506
  */
1507
-function give_insert_payment_note( $payment_id = 0, $note = '' ) {
1508
-	if ( empty( $payment_id ) ) {
1507
+function give_insert_payment_note($payment_id = 0, $note = '') {
1508
+	if (empty($payment_id)) {
1509 1509
 		return false;
1510 1510
 	}
1511 1511
 
@@ -1517,14 +1517,14 @@  discard block
 block discarded – undo
1517 1517
 	 * @param int $payment_id Payment ID.
1518 1518
 	 * @param string $note The note.
1519 1519
 	 */
1520
-	do_action( 'give_pre_insert_payment_note', $payment_id, $note );
1520
+	do_action('give_pre_insert_payment_note', $payment_id, $note);
1521 1521
 
1522
-	$note_id = wp_insert_comment( wp_filter_comment( array(
1522
+	$note_id = wp_insert_comment(wp_filter_comment(array(
1523 1523
 		'comment_post_ID'      => $payment_id,
1524 1524
 		'comment_content'      => $note,
1525 1525
 		'user_id'              => is_admin() ? get_current_user_id() : 0,
1526
-		'comment_date'         => current_time( 'mysql' ),
1527
-		'comment_date_gmt'     => current_time( 'mysql', 1 ),
1526
+		'comment_date'         => current_time('mysql'),
1527
+		'comment_date_gmt'     => current_time('mysql', 1),
1528 1528
 		'comment_approved'     => 1,
1529 1529
 		'comment_parent'       => 0,
1530 1530
 		'comment_author'       => '',
@@ -1533,7 +1533,7 @@  discard block
 block discarded – undo
1533 1533
 		'comment_author_email' => '',
1534 1534
 		'comment_type'         => 'give_payment_note',
1535 1535
 
1536
-	) ) );
1536
+	)));
1537 1537
 
1538 1538
 	/**
1539 1539
 	 * Fires after payment note inserted.
@@ -1544,7 +1544,7 @@  discard block
 block discarded – undo
1544 1544
 	 * @param int $payment_id Payment ID.
1545 1545
 	 * @param string $note The note.
1546 1546
 	 */
1547
-	do_action( 'give_insert_payment_note', $note_id, $payment_id, $note );
1547
+	do_action('give_insert_payment_note', $note_id, $payment_id, $note);
1548 1548
 
1549 1549
 	return $note_id;
1550 1550
 }
@@ -1559,8 +1559,8 @@  discard block
 block discarded – undo
1559 1559
  *
1560 1560
  * @return bool True on success, false otherwise.
1561 1561
  */
1562
-function give_delete_payment_note( $comment_id = 0, $payment_id = 0 ) {
1563
-	if ( empty( $comment_id ) ) {
1562
+function give_delete_payment_note($comment_id = 0, $payment_id = 0) {
1563
+	if (empty($comment_id)) {
1564 1564
 		return false;
1565 1565
 	}
1566 1566
 
@@ -1572,9 +1572,9 @@  discard block
 block discarded – undo
1572 1572
 	 * @param int $comment_id Note ID.
1573 1573
 	 * @param int $payment_id Payment ID.
1574 1574
 	 */
1575
-	do_action( 'give_pre_delete_payment_note', $comment_id, $payment_id );
1575
+	do_action('give_pre_delete_payment_note', $comment_id, $payment_id);
1576 1576
 
1577
-	$ret = wp_delete_comment( $comment_id, true );
1577
+	$ret = wp_delete_comment($comment_id, true);
1578 1578
 
1579 1579
 	/**
1580 1580
 	 * Fires after donation note deleted.
@@ -1584,7 +1584,7 @@  discard block
 block discarded – undo
1584 1584
 	 * @param int $comment_id Note ID.
1585 1585
 	 * @param int $payment_id Payment ID.
1586 1586
 	 */
1587
-	do_action( 'give_post_delete_payment_note', $comment_id, $payment_id );
1587
+	do_action('give_post_delete_payment_note', $comment_id, $payment_id);
1588 1588
 
1589 1589
 	return $ret;
1590 1590
 }
@@ -1599,34 +1599,34 @@  discard block
 block discarded – undo
1599 1599
  *
1600 1600
  * @return string
1601 1601
  */
1602
-function give_get_payment_note_html( $note, $payment_id = 0 ) {
1602
+function give_get_payment_note_html($note, $payment_id = 0) {
1603 1603
 
1604
-	if ( is_numeric( $note ) ) {
1605
-		$note = get_comment( $note );
1604
+	if (is_numeric($note)) {
1605
+		$note = get_comment($note);
1606 1606
 	}
1607 1607
 
1608
-	if ( ! empty( $note->user_id ) ) {
1609
-		$user = get_userdata( $note->user_id );
1608
+	if ( ! empty($note->user_id)) {
1609
+		$user = get_userdata($note->user_id);
1610 1610
 		$user = $user->display_name;
1611 1611
 	} else {
1612
-		$user = esc_html__( 'System', 'give' );
1612
+		$user = esc_html__('System', 'give');
1613 1613
 	}
1614 1614
 
1615
-	$date_format = give_date_format() . ', ' . get_option( 'time_format' );
1615
+	$date_format = give_date_format().', '.get_option('time_format');
1616 1616
 
1617
-	$delete_note_url = wp_nonce_url( add_query_arg( array(
1617
+	$delete_note_url = wp_nonce_url(add_query_arg(array(
1618 1618
 		'give-action' => 'delete_payment_note',
1619 1619
 		'note_id'     => $note->comment_ID,
1620 1620
 		'payment_id'  => $payment_id,
1621
-	) ),
1622
-		'give_delete_payment_note_' . $note->comment_ID
1621
+	)),
1622
+		'give_delete_payment_note_'.$note->comment_ID
1623 1623
 	);
1624 1624
 
1625
-	$note_html = '<div class="give-payment-note" id="give-payment-note-' . $note->comment_ID . '">';
1625
+	$note_html = '<div class="give-payment-note" id="give-payment-note-'.$note->comment_ID.'">';
1626 1626
 	$note_html .= '<p>';
1627
-	$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/>';
1627
+	$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/>';
1628 1628
 	$note_html .= $note->comment_content;
1629
-	$note_html .= '&nbsp;&ndash;&nbsp;<a href="' . esc_url( $delete_note_url ) . '" class="give-delete-payment-note" data-note-id="' . absint( $note->comment_ID ) . '" data-payment-id="' . absint( $payment_id ) . '" aria-label="' . esc_attr__( 'Delete this donation note.', 'give' ) . '">' . esc_html__( 'Delete', 'give' ) . '</a>';
1629
+	$note_html .= '&nbsp;&ndash;&nbsp;<a href="'.esc_url($delete_note_url).'" class="give-delete-payment-note" data-note-id="'.absint($note->comment_ID).'" data-payment-id="'.absint($payment_id).'" aria-label="'.esc_attr__('Delete this donation note.', 'give').'">'.esc_html__('Delete', 'give').'</a>';
1630 1630
 	$note_html .= '</p>';
1631 1631
 	$note_html .= '</div>';
1632 1632
 
@@ -1644,18 +1644,18 @@  discard block
 block discarded – undo
1644 1644
  *
1645 1645
  * @return void
1646 1646
  */
1647
-function give_hide_payment_notes( $query ) {
1648
-	if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '>=' ) ) {
1649
-		$types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array();
1650
-		if ( ! is_array( $types ) ) {
1651
-			$types = array( $types );
1647
+function give_hide_payment_notes($query) {
1648
+	if (version_compare(floatval(get_bloginfo('version')), '4.1', '>=')) {
1649
+		$types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array();
1650
+		if ( ! is_array($types)) {
1651
+			$types = array($types);
1652 1652
 		}
1653 1653
 		$types[]                           = 'give_payment_note';
1654 1654
 		$query->query_vars['type__not_in'] = $types;
1655 1655
 	}
1656 1656
 }
1657 1657
 
1658
-add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1658
+add_action('pre_get_comments', 'give_hide_payment_notes', 10);
1659 1659
 
1660 1660
 /**
1661 1661
  * Exclude notes (comments) on give_payment post type from showing in Recent Comments widgets
@@ -1667,15 +1667,15 @@  discard block
 block discarded – undo
1667 1667
  *
1668 1668
  * @return array $clauses Updated comment clauses.
1669 1669
  */
1670
-function give_hide_payment_notes_pre_41( $clauses, $wp_comment_query ) {
1671
-	if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '<' ) ) {
1670
+function give_hide_payment_notes_pre_41($clauses, $wp_comment_query) {
1671
+	if (version_compare(floatval(get_bloginfo('version')), '4.1', '<')) {
1672 1672
 		$clauses['where'] .= ' AND comment_type != "give_payment_note"';
1673 1673
 	}
1674 1674
 
1675 1675
 	return $clauses;
1676 1676
 }
1677 1677
 
1678
-add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 );
1678
+add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2);
1679 1679
 
1680 1680
 
1681 1681
 /**
@@ -1688,15 +1688,15 @@  discard block
 block discarded – undo
1688 1688
  *
1689 1689
  * @return string $where
1690 1690
  */
1691
-function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) {
1691
+function give_hide_payment_notes_from_feeds($where, $wp_comment_query) {
1692 1692
 	global $wpdb;
1693 1693
 
1694
-	$where .= $wpdb->prepare( ' AND comment_type != %s', 'give_payment_note' );
1694
+	$where .= $wpdb->prepare(' AND comment_type != %s', 'give_payment_note');
1695 1695
 
1696 1696
 	return $where;
1697 1697
 }
1698 1698
 
1699
-add_filter( 'comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2 );
1699
+add_filter('comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2);
1700 1700
 
1701 1701
 
1702 1702
 /**
@@ -1710,32 +1710,32 @@  discard block
 block discarded – undo
1710 1710
  *
1711 1711
  * @return array Array of comment counts.
1712 1712
  */
1713
-function give_remove_payment_notes_in_comment_counts( $stats, $post_id ) {
1713
+function give_remove_payment_notes_in_comment_counts($stats, $post_id) {
1714 1714
 	global $wpdb, $pagenow;
1715 1715
 
1716
-	if ( 'index.php' != $pagenow ) {
1716
+	if ('index.php' != $pagenow) {
1717 1717
 		return $stats;
1718 1718
 	}
1719 1719
 
1720 1720
 	$post_id = (int) $post_id;
1721 1721
 
1722
-	if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) {
1722
+	if (apply_filters('give_count_payment_notes_in_comments', false)) {
1723 1723
 		return $stats;
1724 1724
 	}
1725 1725
 
1726
-	$stats = wp_cache_get( "comments-{$post_id}", 'counts' );
1726
+	$stats = wp_cache_get("comments-{$post_id}", 'counts');
1727 1727
 
1728
-	if ( false !== $stats ) {
1728
+	if (false !== $stats) {
1729 1729
 		return $stats;
1730 1730
 	}
1731 1731
 
1732 1732
 	$where = 'WHERE comment_type != "give_payment_note"';
1733 1733
 
1734
-	if ( $post_id > 0 ) {
1735
-		$where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id );
1734
+	if ($post_id > 0) {
1735
+		$where .= $wpdb->prepare(' AND comment_post_ID = %d', $post_id);
1736 1736
 	}
1737 1737
 
1738
-	$count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A );
1738
+	$count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A);
1739 1739
 
1740 1740
 	$total    = 0;
1741 1741
 	$approved = array(
@@ -1745,30 +1745,30 @@  discard block
 block discarded – undo
1745 1745
 		'trash'        => 'trash',
1746 1746
 		'post-trashed' => 'post-trashed',
1747 1747
 	);
1748
-	foreach ( (array) $count as $row ) {
1748
+	foreach ((array) $count as $row) {
1749 1749
 		// Don't count post-trashed toward totals.
1750
-		if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) {
1750
+		if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) {
1751 1751
 			$total += $row['num_comments'];
1752 1752
 		}
1753
-		if ( isset( $approved[ $row['comment_approved'] ] ) ) {
1754
-			$stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments'];
1753
+		if (isset($approved[$row['comment_approved']])) {
1754
+			$stats[$approved[$row['comment_approved']]] = $row['num_comments'];
1755 1755
 		}
1756 1756
 	}
1757 1757
 
1758 1758
 	$stats['total_comments'] = $total;
1759
-	foreach ( $approved as $key ) {
1760
-		if ( empty( $stats[ $key ] ) ) {
1761
-			$stats[ $key ] = 0;
1759
+	foreach ($approved as $key) {
1760
+		if (empty($stats[$key])) {
1761
+			$stats[$key] = 0;
1762 1762
 		}
1763 1763
 	}
1764 1764
 
1765 1765
 	$stats = (object) $stats;
1766
-	wp_cache_set( "comments-{$post_id}", $stats, 'counts' );
1766
+	wp_cache_set("comments-{$post_id}", $stats, 'counts');
1767 1767
 
1768 1768
 	return $stats;
1769 1769
 }
1770 1770
 
1771
-add_filter( 'wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2 );
1771
+add_filter('wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2);
1772 1772
 
1773 1773
 
1774 1774
 /**
@@ -1781,9 +1781,9 @@  discard block
 block discarded – undo
1781 1781
  *
1782 1782
  * @return string $where Modified where clause.
1783 1783
  */
1784
-function give_filter_where_older_than_week( $where = '' ) {
1784
+function give_filter_where_older_than_week($where = '') {
1785 1785
 	// Payments older than one week.
1786
-	$start = date( 'Y-m-d', strtotime( '-7 days' ) );
1786
+	$start = date('Y-m-d', strtotime('-7 days'));
1787 1787
 	$where .= " AND post_date <= '{$start}'";
1788 1788
 
1789 1789
 	return $where;
@@ -1803,38 +1803,38 @@  discard block
 block discarded – undo
1803 1803
  *
1804 1804
  * @return string $form_title Returns the full title if $only_level is false, otherwise returns the levels title.
1805 1805
  */
1806
-function give_get_payment_form_title( $payment_meta, $only_level = false, $separator = '' ) {
1806
+function give_get_payment_form_title($payment_meta, $only_level = false, $separator = '') {
1807 1807
 
1808
-	$form_id    = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0;
1809
-	$price_id   = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null;
1810
-	$form_title = isset( $payment_meta['form_title'] ) ? $payment_meta['form_title'] : '';
1808
+	$form_id    = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0;
1809
+	$price_id   = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null;
1810
+	$form_title = isset($payment_meta['form_title']) ? $payment_meta['form_title'] : '';
1811 1811
 
1812
-	if ( $only_level == true ) {
1812
+	if ($only_level == true) {
1813 1813
 		$form_title = '';
1814 1814
 	}
1815 1815
 
1816 1816
 	//If multi-level, append to the form title.
1817
-	if ( give_has_variable_prices( $form_id ) ) {
1817
+	if (give_has_variable_prices($form_id)) {
1818 1818
 
1819 1819
 		//Only add separator if there is a form title.
1820
-		if ( ! empty( $form_title ) ) {
1821
-			$form_title .= ' ' . $separator . ' ';
1820
+		if ( ! empty($form_title)) {
1821
+			$form_title .= ' '.$separator.' ';
1822 1822
 		}
1823 1823
 
1824 1824
 		$form_title .= '<span class="donation-level-text-wrap">';
1825 1825
 
1826
-		if ( $price_id == 'custom' ) {
1827
-			$custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true );
1828
-			$form_title         .= ! empty( $custom_amount_text ) ? $custom_amount_text : __( 'Custom Amount', 'give' );
1826
+		if ($price_id == 'custom') {
1827
+			$custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true);
1828
+			$form_title .= ! empty($custom_amount_text) ? $custom_amount_text : __('Custom Amount', 'give');
1829 1829
 		} else {
1830
-			$form_title .= give_get_price_option_name( $form_id, $price_id );
1830
+			$form_title .= give_get_price_option_name($form_id, $price_id);
1831 1831
 		}
1832 1832
 
1833 1833
 		$form_title .= '</span>';
1834 1834
 
1835 1835
 	}
1836 1836
 
1837
-	return apply_filters( 'give_get_payment_form_title', $form_title, $payment_meta );
1837
+	return apply_filters('give_get_payment_form_title', $form_title, $payment_meta);
1838 1838
 
1839 1839
 }
1840 1840
 
@@ -1848,20 +1848,20 @@  discard block
 block discarded – undo
1848 1848
  *
1849 1849
  * @return string $price_id
1850 1850
  */
1851
-function give_get_price_id( $form_id, $price ) {
1851
+function give_get_price_id($form_id, $price) {
1852 1852
 
1853 1853
 	$price_id = 0;
1854 1854
 
1855
-	if ( give_has_variable_prices( $form_id ) ) {
1855
+	if (give_has_variable_prices($form_id)) {
1856 1856
 
1857
-		$levels = maybe_unserialize( give_get_meta( $form_id, '_give_donation_levels', true ) );
1857
+		$levels = maybe_unserialize(give_get_meta($form_id, '_give_donation_levels', true));
1858 1858
 
1859
-		foreach ( $levels as $level ) {
1859
+		foreach ($levels as $level) {
1860 1860
 
1861
-			$level_amount = (float) give_sanitize_amount( $level['_give_amount'] );
1861
+			$level_amount = (float) give_sanitize_amount($level['_give_amount']);
1862 1862
 
1863 1863
 			// Check that this indeed the recurring price.
1864
-			if ( $level_amount == $price ) {
1864
+			if ($level_amount == $price) {
1865 1865
 
1866 1866
 				$price_id = $level['_give_id']['level_id'];
1867 1867
 
@@ -1886,10 +1886,10 @@  discard block
 block discarded – undo
1886 1886
  *
1887 1887
  * @return string
1888 1888
  */
1889
-function give_get_form_dropdown( $args = array(), $echo = false ) {
1890
-	$form_dropdown_html = Give()->html->forms_dropdown( $args );
1889
+function give_get_form_dropdown($args = array(), $echo = false) {
1890
+	$form_dropdown_html = Give()->html->forms_dropdown($args);
1891 1891
 
1892
-	if ( ! $echo ) {
1892
+	if ( ! $echo) {
1893 1893
 		return $form_dropdown_html;
1894 1894
 	}
1895 1895
 
@@ -1906,17 +1906,17 @@  discard block
 block discarded – undo
1906 1906
  *
1907 1907
  * @return string|bool
1908 1908
  */
1909
-function give_get_form_variable_price_dropdown( $args = array(), $echo = false ) {
1909
+function give_get_form_variable_price_dropdown($args = array(), $echo = false) {
1910 1910
 
1911 1911
 	// Check for give form id.
1912
-	if ( empty( $args['id'] ) ) {
1912
+	if (empty($args['id'])) {
1913 1913
 		return false;
1914 1914
 	}
1915 1915
 
1916
-	$form = new Give_Donate_Form( $args['id'] );
1916
+	$form = new Give_Donate_Form($args['id']);
1917 1917
 
1918 1918
 	// Check if form has variable prices or not.
1919
-	if ( ! $form->ID || ! $form->has_variable_prices() ) {
1919
+	if ( ! $form->ID || ! $form->has_variable_prices()) {
1920 1920
 		return false;
1921 1921
 	}
1922 1922
 
@@ -1924,22 +1924,22 @@  discard block
 block discarded – undo
1924 1924
 	$variable_price_options = array();
1925 1925
 
1926 1926
 	// Check if multi donation form support custom donation or not.
1927
-	if ( $form->is_custom_price_mode() ) {
1928
-		$variable_price_options['custom'] = _x( 'Custom', 'custom donation dropdown item', 'give' );
1927
+	if ($form->is_custom_price_mode()) {
1928
+		$variable_price_options['custom'] = _x('Custom', 'custom donation dropdown item', 'give');
1929 1929
 	}
1930 1930
 
1931 1931
 	// Get variable price and ID from variable price array.
1932
-	foreach ( $variable_prices as $variable_price ) {
1933
-		$variable_price_options[ $variable_price['_give_id']['level_id'] ] = ! empty( $variable_price['_give_text'] ) ? $variable_price['_give_text'] : give_currency_filter( give_format_amount( $variable_price['_give_amount'] ) );
1932
+	foreach ($variable_prices as $variable_price) {
1933
+		$variable_price_options[$variable_price['_give_id']['level_id']] = ! empty($variable_price['_give_text']) ? $variable_price['_give_text'] : give_currency_filter(give_format_amount($variable_price['_give_amount']));
1934 1934
 	}
1935 1935
 
1936 1936
 	// Update options.
1937
-	$args = array_merge( $args, array( 'options' => $variable_price_options ) );
1937
+	$args = array_merge($args, array('options' => $variable_price_options));
1938 1938
 
1939 1939
 	// Generate select html.
1940
-	$form_dropdown_html = Give()->html->select( $args );
1940
+	$form_dropdown_html = Give()->html->select($args);
1941 1941
 
1942
-	if ( ! $echo ) {
1942
+	if ( ! $echo) {
1943 1943
 		return $form_dropdown_html;
1944 1944
 	}
1945 1945
 
@@ -1958,16 +1958,16 @@  discard block
 block discarded – undo
1958 1958
  *
1959 1959
  * @return string
1960 1960
  */
1961
-function give_get_payment_meta_price_id( $payment_meta ) {
1961
+function give_get_payment_meta_price_id($payment_meta) {
1962 1962
 
1963
-	if ( isset( $payment_meta['give_price_id'] ) ) {
1963
+	if (isset($payment_meta['give_price_id'])) {
1964 1964
 		$price_id = $payment_meta['give_price_id'];
1965
-	} elseif ( isset( $payment_meta['price_id'] ) ) {
1965
+	} elseif (isset($payment_meta['price_id'])) {
1966 1966
 		$price_id = $payment_meta['price_id'];
1967 1967
 	} else {
1968
-		$price_id = give_get_price_id( $payment_meta['give_form_id'], $payment_meta['price'] );
1968
+		$price_id = give_get_price_id($payment_meta['give_form_id'], $payment_meta['price']);
1969 1969
 	}
1970 1970
 
1971
-	return apply_filters( 'give_get_payment_meta_price_id', $price_id );
1971
+	return apply_filters('give_get_payment_meta_price_id', $price_id);
1972 1972
 
1973 1973
 }
1974 1974
\ No newline at end of file
Please login to merge, or discard this patch.
includes/payments/class-give-payment.php 1 patch
Spacing   +326 added lines, -326 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
 
@@ -394,13 +394,13 @@  discard block
 block discarded – undo
394 394
 	 *
395 395
 	 * @return mixed void|false
396 396
 	 */
397
-	public function __construct( $payment_id = false ) {
397
+	public function __construct($payment_id = false) {
398 398
 
399
-		if ( empty( $payment_id ) ) {
399
+		if (empty($payment_id)) {
400 400
 			return false;
401 401
 		}
402 402
 
403
-		$this->setup_payment( $payment_id );
403
+		$this->setup_payment($payment_id);
404 404
 	}
405 405
 
406 406
 	/**
@@ -413,11 +413,11 @@  discard block
 block discarded – undo
413 413
 	 *
414 414
 	 * @return mixed        The value.
415 415
 	 */
416
-	public function __get( $key ) {
416
+	public function __get($key) {
417 417
 
418
-		if ( method_exists( $this, 'get_' . $key ) ) {
418
+		if (method_exists($this, 'get_'.$key)) {
419 419
 
420
-			$value = call_user_func( array( $this, 'get_' . $key ) );
420
+			$value = call_user_func(array($this, 'get_'.$key));
421 421
 
422 422
 		} else {
423 423
 
@@ -439,18 +439,18 @@  discard block
 block discarded – undo
439 439
 	 * @param  string $key The property name
440 440
 	 * @param  mixed $value The value of the property
441 441
 	 */
442
-	public function __set( $key, $value ) {
443
-		$ignore = array( '_ID' );
442
+	public function __set($key, $value) {
443
+		$ignore = array('_ID');
444 444
 
445
-		if ( $key === 'status' ) {
445
+		if ($key === 'status') {
446 446
 			$this->old_status = $this->status;
447 447
 		}
448 448
 
449
-		if ( ! in_array( $key, $ignore ) ) {
450
-			$this->pending[ $key ] = $value;
449
+		if ( ! in_array($key, $ignore)) {
450
+			$this->pending[$key] = $value;
451 451
 		}
452 452
 
453
-		if ( '_ID' !== $key ) {
453
+		if ('_ID' !== $key) {
454 454
 			$this->$key = $value;
455 455
 		}
456 456
 	}
@@ -465,9 +465,9 @@  discard block
 block discarded – undo
465 465
 	 *
466 466
 	 * @return boolean       If the item is set or not
467 467
 	 */
468
-	public function __isset( $name ) {
469
-		if ( property_exists( $this, $name ) ) {
470
-			return false === empty( $this->$name );
468
+	public function __isset($name) {
469
+		if (property_exists($this, $name)) {
470
+			return false === empty($this->$name);
471 471
 		} else {
472 472
 			return null;
473 473
 		}
@@ -483,20 +483,20 @@  discard block
 block discarded – undo
483 483
 	 *
484 484
 	 * @return bool            If the setup was successful or not
485 485
 	 */
486
-	private function setup_payment( $payment_id ) {
486
+	private function setup_payment($payment_id) {
487 487
 		$this->pending = array();
488 488
 
489
-		if ( empty( $payment_id ) ) {
489
+		if (empty($payment_id)) {
490 490
 			return false;
491 491
 		}
492 492
 
493
-		$payment = get_post( $payment_id );
493
+		$payment = get_post($payment_id);
494 494
 
495
-		if ( ! $payment || is_wp_error( $payment ) ) {
495
+		if ( ! $payment || is_wp_error($payment)) {
496 496
 			return false;
497 497
 		}
498 498
 
499
-		if ( 'give_payment' !== $payment->post_type ) {
499
+		if ('give_payment' !== $payment->post_type) {
500 500
 			return false;
501 501
 		}
502 502
 
@@ -510,13 +510,13 @@  discard block
 block discarded – undo
510 510
 		 * @param Give_Payment $this Payment object.
511 511
 		 * @param int $payment_id The ID of the payment.
512 512
 		 */
513
-		do_action( 'give_pre_setup_payment', $this, $payment_id );
513
+		do_action('give_pre_setup_payment', $this, $payment_id);
514 514
 
515 515
 		// Primary Identifier.
516
-		$this->ID = absint( $payment_id );
516
+		$this->ID = absint($payment_id);
517 517
 
518 518
 		// Protected ID that can never be changed.
519
-		$this->_ID = absint( $payment_id );
519
+		$this->_ID = absint($payment_id);
520 520
 
521 521
 		// We have a payment, get the generic payment_meta item to reduce calls to it.
522 522
 		$this->payment_meta = $this->get_meta();
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
 		$this->parent_payment = $payment->post_parent;
532 532
 
533 533
 		$all_payment_statuses  = give_get_payment_statuses();
534
-		$this->status_nicename = array_key_exists( $this->status, $all_payment_statuses ) ? $all_payment_statuses[ $this->status ] : ucfirst( $this->status );
534
+		$this->status_nicename = array_key_exists($this->status, $all_payment_statuses) ? $all_payment_statuses[$this->status] : ucfirst($this->status);
535 535
 
536 536
 		// Items.
537 537
 		$this->fees = $this->setup_fees();
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
 		 * @param Give_Payment $this Payment object.
574 574
 		 * @param int $payment_id The ID of the payment.
575 575
 		 */
576
-		do_action( 'give_setup_payment', $this, $payment_id );
576
+		do_action('give_setup_payment', $this, $payment_id);
577 577
 
578 578
 		return true;
579 579
 	}
@@ -591,8 +591,8 @@  discard block
 block discarded – undo
591 591
 	 *
592 592
 	 * @return void
593 593
 	 */
594
-	public function update_payment_setup( $payment_id ) {
595
-		$this->setup_payment( $payment_id );
594
+	public function update_payment_setup($payment_id) {
595
+		$this->setup_payment($payment_id);
596 596
 	}
597 597
 
598 598
 	/**
@@ -607,24 +607,24 @@  discard block
 block discarded – undo
607 607
 
608 608
 		// Construct the payment title.
609 609
 		$payment_title = '';
610
-		if ( ! empty( $this->first_name ) && ! empty( $this->last_name ) ) {
611
-			$payment_title = $this->first_name . ' ' . $this->last_name;
612
-		} elseif ( ! empty( $this->first_name ) && empty( $this->last_name ) ) {
610
+		if ( ! empty($this->first_name) && ! empty($this->last_name)) {
611
+			$payment_title = $this->first_name.' '.$this->last_name;
612
+		} elseif ( ! empty($this->first_name) && empty($this->last_name)) {
613 613
 			$payment_title = $this->first_name;
614
-		} elseif ( ! empty( $this->email ) && is_email( $this->email ) ) {
614
+		} elseif ( ! empty($this->email) && is_email($this->email)) {
615 615
 			$payment_title = $this->email;
616 616
 		}
617 617
 
618 618
 		// Set Key.
619
-		if ( empty( $this->key ) ) {
619
+		if (empty($this->key)) {
620 620
 
621
-			$auth_key             = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
622
-			$this->key            = strtolower( md5( $this->email . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) );  // Unique key
621
+			$auth_key             = defined('AUTH_KEY') ? AUTH_KEY : '';
622
+			$this->key            = strtolower(md5($this->email.date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); // Unique key
623 623
 			$this->pending['key'] = $this->key;
624 624
 		}
625 625
 
626 626
 		// Set IP.
627
-		if ( empty( $this->ip ) ) {
627
+		if (empty($this->ip)) {
628 628
 
629 629
 			$this->ip            = give_get_ip();
630 630
 			$this->pending['ip'] = $this->ip;
@@ -651,63 +651,63 @@  discard block
 block discarded – undo
651 651
 			'fees'         => $this->fees,
652 652
 		);
653 653
 
654
-		$args = apply_filters( 'give_insert_payment_args', array(
654
+		$args = apply_filters('give_insert_payment_args', array(
655 655
 			'post_title'    => $payment_title,
656 656
 			'post_status'   => $this->status,
657 657
 			'post_type'     => 'give_payment',
658
-			'post_date'     => ! empty( $this->date ) ? $this->date : null,
659
-			'post_date_gmt' => ! empty( $this->date ) ? get_gmt_from_date( $this->date ) : null,
658
+			'post_date'     => ! empty($this->date) ? $this->date : null,
659
+			'post_date_gmt' => ! empty($this->date) ? get_gmt_from_date($this->date) : null,
660 660
 			'post_parent'   => $this->parent_payment,
661
-		), $payment_data );
661
+		), $payment_data);
662 662
 
663 663
 		// Create a blank payment
664
-		$payment_id = wp_insert_post( $args );
664
+		$payment_id = wp_insert_post($args);
665 665
 
666
-		if ( ! empty( $payment_id ) ) {
666
+		if ( ! empty($payment_id)) {
667 667
 
668 668
 			$this->ID  = $payment_id;
669 669
 			$this->_ID = $payment_id;
670 670
 
671 671
 			$customer = new stdClass;
672 672
 
673
-			if ( did_action( 'give_pre_process_donation' ) && is_user_logged_in() ) {
674
-				$customer = new Give_Customer( get_current_user_id(), true );
673
+			if (did_action('give_pre_process_donation') && is_user_logged_in()) {
674
+				$customer = new Give_Customer(get_current_user_id(), true);
675 675
 
676 676
 				// Customer is logged in but used a different email to purchase with so assign to their customer record
677
-				if ( ! empty( $customer->id ) && $this->email != $customer->email ) {
678
-					$customer->add_email( $this->email );
677
+				if ( ! empty($customer->id) && $this->email != $customer->email) {
678
+					$customer->add_email($this->email);
679 679
 				}
680 680
 			}
681 681
 
682
-			if ( empty( $customer->id ) ) {
683
-				$customer = new Give_Customer( $this->email );
682
+			if (empty($customer->id)) {
683
+				$customer = new Give_Customer($this->email);
684 684
 			}
685 685
 
686
-			if ( empty( $customer->id ) ) {
686
+			if (empty($customer->id)) {
687 687
 
688 688
 				$customer_data = array(
689
-					'name'    => ! is_email( $payment_title ) ? $this->first_name . ' ' . $this->last_name : '',
689
+					'name'    => ! is_email($payment_title) ? $this->first_name.' '.$this->last_name : '',
690 690
 					'email'   => $this->email,
691 691
 					'user_id' => $this->user_id,
692 692
 				);
693 693
 
694
-				$customer->create( $customer_data );
694
+				$customer->create($customer_data);
695 695
 
696 696
 			}
697 697
 
698 698
 			$this->customer_id            = $customer->id;
699 699
 			$this->pending['customer_id'] = $this->customer_id;
700
-			$customer->attach_payment( $this->ID, false );
700
+			$customer->attach_payment($this->ID, false);
701 701
 
702
-			$this->payment_meta = apply_filters( 'give_payment_meta', $this->payment_meta, $payment_data );
703
-			if ( ! empty( $this->payment_meta['fees'] ) ) {
704
-				$this->fees = array_merge( $this->fees, $this->payment_meta['fees'] );
705
-				foreach ( $this->fees as $fee ) {
706
-					$this->increase_fees( $fee['amount'] );
702
+			$this->payment_meta = apply_filters('give_payment_meta', $this->payment_meta, $payment_data);
703
+			if ( ! empty($this->payment_meta['fees'])) {
704
+				$this->fees = array_merge($this->fees, $this->payment_meta['fees']);
705
+				foreach ($this->fees as $fee) {
706
+					$this->increase_fees($fee['amount']);
707 707
 				}
708 708
 			}
709 709
 
710
-			$this->update_meta( '_give_payment_meta', $this->payment_meta );
710
+			$this->update_meta('_give_payment_meta', $this->payment_meta);
711 711
 			$this->new = true;
712 712
 		}// End if().
713 713
 
@@ -729,11 +729,11 @@  discard block
 block discarded – undo
729 729
 		$saved = false;
730 730
 
731 731
 		// Must have an ID.
732
-		if ( empty( $this->ID ) ) {
732
+		if (empty($this->ID)) {
733 733
 
734 734
 			$payment_id = $this->insert_payment();
735 735
 
736
-			if ( false === $payment_id ) {
736
+			if (false === $payment_id) {
737 737
 				$saved = false;
738 738
 			} else {
739 739
 				$this->ID = $payment_id;
@@ -741,48 +741,48 @@  discard block
 block discarded – undo
741 741
 		}
742 742
 
743 743
 		// Set ID if not matching.
744
-		if ( $this->ID !== $this->_ID ) {
744
+		if ($this->ID !== $this->_ID) {
745 745
 			$this->ID = $this->_ID;
746 746
 		}
747 747
 
748 748
 		// If we have something pending, let's save it.
749
-		if ( ! empty( $this->pending ) ) {
749
+		if ( ! empty($this->pending)) {
750 750
 
751 751
 			$total_increase = 0;
752 752
 			$total_decrease = 0;
753 753
 
754
-			foreach ( $this->pending as $key => $value ) {
754
+			foreach ($this->pending as $key => $value) {
755 755
 
756
-				switch ( $key ) {
756
+				switch ($key) {
757 757
 
758 758
 					case 'donations':
759 759
 						// Update totals for pending donations.
760
-						foreach ( $this->pending[ $key ] as $item ) {
760
+						foreach ($this->pending[$key] as $item) {
761 761
 
762
-							$quantity = isset( $item['quantity'] ) ? $item['quantity'] : 1;
763
-							$price_id = isset( $item['price_id'] ) ? $item['price_id'] : 0;
762
+							$quantity = isset($item['quantity']) ? $item['quantity'] : 1;
763
+							$price_id = isset($item['price_id']) ? $item['price_id'] : 0;
764 764
 
765
-							switch ( $item['action'] ) {
765
+							switch ($item['action']) {
766 766
 
767 767
 								case 'add':
768 768
 
769 769
 									$price = $item['price'];
770 770
 
771
-									if ( 'publish' === $this->status || 'complete' === $this->status ) {
771
+									if ('publish' === $this->status || 'complete' === $this->status) {
772 772
 
773 773
 										// Add sales logs.
774
-										$log_date = date_i18n( 'Y-m-d G:i:s', current_time( 'timestamp' ) );
774
+										$log_date = date_i18n('Y-m-d G:i:s', current_time('timestamp'));
775 775
 
776 776
 										$y = 0;
777
-										while ( $y < $quantity ) {
777
+										while ($y < $quantity) {
778 778
 
779
-											give_record_sale_in_log( $item['id'], $this->ID, $price_id, $log_date );
780
-											$y ++;
779
+											give_record_sale_in_log($item['id'], $this->ID, $price_id, $log_date);
780
+											$y++;
781 781
 										}
782 782
 
783
-										$form = new Give_Donate_Form( $item['id'] );
784
-										$form->increase_sales( $quantity );
785
-										$form->increase_earnings( $price );
783
+										$form = new Give_Donate_Form($item['id']);
784
+										$form->increase_sales($quantity);
785
+										$form->increase_earnings($price);
786 786
 
787 787
 										$total_increase += $price;
788 788
 									}
@@ -807,15 +807,15 @@  discard block
 block discarded – undo
807 807
 										),
808 808
 									);
809 809
 
810
-									$found_logs = get_posts( $log_args );
811
-									foreach ( $found_logs as $log ) {
812
-										wp_delete_post( $log->ID, true );
810
+									$found_logs = get_posts($log_args);
811
+									foreach ($found_logs as $log) {
812
+										wp_delete_post($log->ID, true);
813 813
 									}
814 814
 
815
-									if ( 'publish' === $this->status || 'complete' === $this->status ) {
816
-										$form = new Give_Donate_Form( $item['id'] );
817
-										$form->decrease_sales( $quantity );
818
-										$form->decrease_earnings( $item['amount'] );
815
+									if ('publish' === $this->status || 'complete' === $this->status) {
816
+										$form = new Give_Donate_Form($item['id']);
817
+										$form->decrease_sales($quantity);
818
+										$form->decrease_earnings($item['amount']);
819 819
 
820 820
 										$total_decrease += $item['amount'];
821 821
 									}
@@ -827,17 +827,17 @@  discard block
 block discarded – undo
827 827
 
828 828
 					case 'fees':
829 829
 
830
-						if ( 'publish' !== $this->status && 'complete' !== $this->status ) {
830
+						if ('publish' !== $this->status && 'complete' !== $this->status) {
831 831
 							break;
832 832
 						}
833 833
 
834
-						if ( empty( $this->pending[ $key ] ) ) {
834
+						if (empty($this->pending[$key])) {
835 835
 							break;
836 836
 						}
837 837
 
838
-						foreach ( $this->pending[ $key ] as $fee ) {
838
+						foreach ($this->pending[$key] as $fee) {
839 839
 
840
-							switch ( $fee['action'] ) {
840
+							switch ($fee['action']) {
841 841
 
842 842
 								case 'add':
843 843
 									$total_increase += $fee['amount'];
@@ -853,43 +853,43 @@  discard block
 block discarded – undo
853 853
 						break;
854 854
 
855 855
 					case 'status':
856
-						$this->update_status( $this->status );
856
+						$this->update_status($this->status);
857 857
 						break;
858 858
 
859 859
 					case 'gateway':
860
-						$this->update_meta( '_give_payment_gateway', $this->gateway );
860
+						$this->update_meta('_give_payment_gateway', $this->gateway);
861 861
 						break;
862 862
 
863 863
 					case 'mode':
864
-						$this->update_meta( '_give_payment_mode', $this->mode );
864
+						$this->update_meta('_give_payment_mode', $this->mode);
865 865
 						break;
866 866
 
867 867
 					case 'transaction_id':
868
-						$this->update_meta( '_give_payment_transaction_id', $this->transaction_id );
868
+						$this->update_meta('_give_payment_transaction_id', $this->transaction_id);
869 869
 						break;
870 870
 
871 871
 					case 'ip':
872
-						$this->update_meta( '_give_payment_user_ip', $this->ip );
872
+						$this->update_meta('_give_payment_user_ip', $this->ip);
873 873
 						break;
874 874
 
875 875
 					case 'customer_id':
876
-						$this->update_meta( '_give_payment_customer_id', $this->customer_id );
876
+						$this->update_meta('_give_payment_customer_id', $this->customer_id);
877 877
 						break;
878 878
 
879 879
 					case 'user_id':
880
-						$this->update_meta( '_give_payment_user_id', $this->user_id );
880
+						$this->update_meta('_give_payment_user_id', $this->user_id);
881 881
 						break;
882 882
 
883 883
 					case 'form_title':
884
-						$this->update_meta( '_give_payment_form_title', $this->form_title );
884
+						$this->update_meta('_give_payment_form_title', $this->form_title);
885 885
 						break;
886 886
 
887 887
 					case 'form_id':
888
-						$this->update_meta( '_give_payment_form_id', $this->form_id );
888
+						$this->update_meta('_give_payment_form_id', $this->form_id);
889 889
 						break;
890 890
 
891 891
 					case 'price_id':
892
-						$this->update_meta( '_give_payment_price_id', $this->price_id );
892
+						$this->update_meta('_give_payment_price_id', $this->price_id);
893 893
 						break;
894 894
 
895 895
 					case 'first_name':
@@ -905,15 +905,15 @@  discard block
 block discarded – undo
905 905
 						break;
906 906
 
907 907
 					case 'email':
908
-						$this->update_meta( '_give_payment_user_email', $this->email );
908
+						$this->update_meta('_give_payment_user_email', $this->email);
909 909
 						break;
910 910
 
911 911
 					case 'key':
912
-						$this->update_meta( '_give_payment_purchase_key', $this->key );
912
+						$this->update_meta('_give_payment_purchase_key', $this->key);
913 913
 						break;
914 914
 
915 915
 					case 'number':
916
-						$this->update_meta( '_give_payment_number', $this->number );
916
+						$this->update_meta('_give_payment_number', $this->number);
917 917
 						break;
918 918
 
919 919
 					case 'date':
@@ -923,11 +923,11 @@  discard block
 block discarded – undo
923 923
 							'edit_date' => true,
924 924
 						);
925 925
 
926
-						wp_update_post( $args );
926
+						wp_update_post($args);
927 927
 						break;
928 928
 
929 929
 					case 'completed_date':
930
-						$this->update_meta( '_give_completed_date', $this->completed_date );
930
+						$this->update_meta('_give_completed_date', $this->completed_date);
931 931
 						break;
932 932
 
933 933
 					case 'parent_payment':
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
 							'post_parent' => $this->parent_payment,
937 937
 						);
938 938
 
939
-						wp_update_post( $args );
939
+						wp_update_post($args);
940 940
 						break;
941 941
 
942 942
 					default:
@@ -947,33 +947,33 @@  discard block
 block discarded – undo
947 947
 						 *
948 948
 						 * @param Give_Payment $this Payment object.
949 949
 						 */
950
-						do_action( 'give_payment_save', $this, $key );
950
+						do_action('give_payment_save', $this, $key);
951 951
 						break;
952 952
 				}// End switch().
953 953
 			}// End foreach().
954 954
 
955
-			if ( 'pending' !== $this->status ) {
955
+			if ('pending' !== $this->status) {
956 956
 
957
-				$customer = new Give_Customer( $this->customer_id );
957
+				$customer = new Give_Customer($this->customer_id);
958 958
 
959 959
 				$total_change = $total_increase - $total_decrease;
960
-				if ( $total_change < 0 ) {
960
+				if ($total_change < 0) {
961 961
 
962
-					$total_change = - ( $total_change );
962
+					$total_change = - ($total_change);
963 963
 					// Decrease the customer's donation stats.
964
-					$customer->decrease_value( $total_change );
965
-					give_decrease_total_earnings( $total_change );
964
+					$customer->decrease_value($total_change);
965
+					give_decrease_total_earnings($total_change);
966 966
 
967
-				} elseif ( $total_change > 0 ) {
967
+				} elseif ($total_change > 0) {
968 968
 
969 969
 					// Increase the customer's donation stats.
970
-					$customer->increase_value( $total_change );
971
-					give_increase_total_earnings( $total_change );
970
+					$customer->increase_value($total_change);
971
+					give_increase_total_earnings($total_change);
972 972
 
973 973
 				}
974 974
 			}
975 975
 
976
-			$this->update_meta( '_give_payment_total', $this->total );
976
+			$this->update_meta('_give_payment_total', $this->total);
977 977
 
978 978
 			$new_meta = array(
979 979
 				'form_title' => $this->form_title,
@@ -985,12 +985,12 @@  discard block
 block discarded – undo
985 985
 			);
986 986
 
987 987
 			$meta        = $this->get_meta();
988
-			$merged_meta = array_merge( $meta, $new_meta );
988
+			$merged_meta = array_merge($meta, $new_meta);
989 989
 
990 990
 			// Only save the payment meta if it's changed.
991
-			if ( md5( serialize( $meta ) ) !== md5( serialize( $merged_meta ) ) ) {
992
-				$updated = $this->update_meta( '_give_payment_meta', $merged_meta );
993
-				if ( false !== $updated ) {
991
+			if (md5(serialize($meta)) !== md5(serialize($merged_meta))) {
992
+				$updated = $this->update_meta('_give_payment_meta', $merged_meta);
993
+				if (false !== $updated) {
994 994
 					$saved = true;
995 995
 				}
996 996
 			}
@@ -999,8 +999,8 @@  discard block
 block discarded – undo
999 999
 			$saved         = true;
1000 1000
 		}// End if().
1001 1001
 
1002
-		if ( true === $saved ) {
1003
-			$this->setup_payment( $this->ID );
1002
+		if (true === $saved) {
1003
+			$this->setup_payment($this->ID);
1004 1004
 		}
1005 1005
 
1006 1006
 		return $saved;
@@ -1018,12 +1018,12 @@  discard block
 block discarded – undo
1018 1018
 	 *
1019 1019
 	 * @return bool           True when successful, false otherwise
1020 1020
 	 */
1021
-	public function add_donation( $form_id = 0, $args = array(), $options = array() ) {
1021
+	public function add_donation($form_id = 0, $args = array(), $options = array()) {
1022 1022
 
1023
-		$donation = new Give_Donate_Form( $form_id );
1023
+		$donation = new Give_Donate_Form($form_id);
1024 1024
 
1025 1025
 		// Bail if this post isn't a give donation form.
1026
-		if ( ! $donation || $donation->post_type !== 'give_forms' ) {
1026
+		if ( ! $donation || $donation->post_type !== 'give_forms') {
1027 1027
 			return false;
1028 1028
 		}
1029 1029
 
@@ -1034,59 +1034,59 @@  discard block
 block discarded – undo
1034 1034
 			'fees'     => array(),
1035 1035
 		);
1036 1036
 
1037
-		$args = wp_parse_args( apply_filters( 'give_payment_add_donation_args', $args, $donation->ID ), $defaults );
1037
+		$args = wp_parse_args(apply_filters('give_payment_add_donation_args', $args, $donation->ID), $defaults);
1038 1038
 
1039 1039
 		// Allow overriding the price.
1040
-		if ( false !== $args['price'] ) {
1040
+		if (false !== $args['price']) {
1041 1041
 			$item_price = $args['price'];
1042 1042
 		} else {
1043 1043
 
1044 1044
 			// Deal with variable pricing.
1045
-			if ( give_has_variable_prices( $donation->ID ) ) {
1046
-				$prices     = maybe_unserialize( give_get_meta( $form_id, '_give_donation_levels', true ) );
1045
+			if (give_has_variable_prices($donation->ID)) {
1046
+				$prices     = maybe_unserialize(give_get_meta($form_id, '_give_donation_levels', true));
1047 1047
 				$item_price = '';
1048 1048
 				// Loop through prices.
1049
-				foreach ( $prices as $price ) {
1049
+				foreach ($prices as $price) {
1050 1050
 					// Find a match between price_id and level_id.
1051 1051
 					// First verify array keys exists THEN make the match.
1052
-					if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) )
1052
+					if ((isset($args['price_id']) && isset($price['_give_id']['level_id']))
1053 1053
 					     && $args['price_id'] == $price['_give_id']['level_id']
1054 1054
 					) {
1055 1055
 						$item_price = $price['_give_amount'];
1056 1056
 					}
1057 1057
 				}
1058 1058
 				// Fallback to the lowest price point.
1059
-				if ( $item_price == '' ) {
1060
-					$item_price       = give_get_lowest_price_option( $donation->ID );
1061
-					$args['price_id'] = give_get_lowest_price_id( $donation->ID );
1059
+				if ($item_price == '') {
1060
+					$item_price       = give_get_lowest_price_option($donation->ID);
1061
+					$args['price_id'] = give_get_lowest_price_id($donation->ID);
1062 1062
 				}
1063 1063
 			} else {
1064 1064
 				// Simple form price.
1065
-				$item_price = give_get_form_price( $donation->ID );
1065
+				$item_price = give_get_form_price($donation->ID);
1066 1066
 			}
1067 1067
 		}
1068 1068
 
1069 1069
 		// Sanitizing the price here so we don't have a dozen calls later.
1070
-		$item_price = give_sanitize_amount( $item_price );
1071
-		$total      = round( $item_price, give_currency_decimal_filter() );
1070
+		$item_price = give_sanitize_amount($item_price);
1071
+		$total      = round($item_price, give_currency_decimal_filter());
1072 1072
 
1073 1073
 		// Add Options.
1074 1074
 		$default_options = array();
1075
-		if ( false !== $args['price_id'] ) {
1075
+		if (false !== $args['price_id']) {
1076 1076
 			$default_options['price_id'] = (int) $args['price_id'];
1077 1077
 		}
1078
-		$options = wp_parse_args( $options, $default_options );
1078
+		$options = wp_parse_args($options, $default_options);
1079 1079
 
1080 1080
 		// Do not allow totals to go negative.
1081
-		if ( $total < 0 ) {
1081
+		if ($total < 0) {
1082 1082
 			$total = 0;
1083 1083
 		}
1084 1084
 
1085 1085
 		$donation = array(
1086 1086
 			'name'     => $donation->post_title,
1087 1087
 			'id'       => $donation->ID,
1088
-			'price'    => round( $total, give_currency_decimal_filter() ),
1089
-			'subtotal' => round( $total, give_currency_decimal_filter() ),
1088
+			'price'    => round($total, give_currency_decimal_filter()),
1089
+			'subtotal' => round($total, give_currency_decimal_filter()),
1090 1090
 			'fees'     => $args['fees'],
1091 1091
 			'price_id' => $args['price_id'],
1092 1092
 			'action'   => 'add',
@@ -1095,7 +1095,7 @@  discard block
 block discarded – undo
1095 1095
 
1096 1096
 		$this->pending['donations'][] = $donation;
1097 1097
 
1098
-		$this->increase_subtotal( $total );
1098
+		$this->increase_subtotal($total);
1099 1099
 
1100 1100
 		return true;
1101 1101
 
@@ -1112,7 +1112,7 @@  discard block
 block discarded – undo
1112 1112
 	 *
1113 1113
 	 * @return bool           If the item was removed or not
1114 1114
 	 */
1115
-	public function remove_donation( $form_id, $args = array() ) {
1115
+	public function remove_donation($form_id, $args = array()) {
1116 1116
 
1117 1117
 		// Set some defaults.
1118 1118
 		$defaults = array(
@@ -1120,12 +1120,12 @@  discard block
 block discarded – undo
1120 1120
 			'price'    => false,
1121 1121
 			'price_id' => false,
1122 1122
 		);
1123
-		$args     = wp_parse_args( $args, $defaults );
1123
+		$args = wp_parse_args($args, $defaults);
1124 1124
 
1125
-		$form = new Give_Donate_Form( $form_id );
1125
+		$form = new Give_Donate_Form($form_id);
1126 1126
 
1127 1127
 		// Bail if this post isn't a valid give donation form.
1128
-		if ( ! $form || $form->post_type !== 'give_forms' ) {
1128
+		if ( ! $form || $form->post_type !== 'give_forms') {
1129 1129
 			return false;
1130 1130
 		}
1131 1131
 
@@ -1138,7 +1138,7 @@  discard block
 block discarded – undo
1138 1138
 
1139 1139
 		$this->pending['donations'][] = $pending_args;
1140 1140
 
1141
-		$this->decrease_subtotal( $this->total );
1141
+		$this->decrease_subtotal($this->total);
1142 1142
 
1143 1143
 		return true;
1144 1144
 	}
@@ -1154,7 +1154,7 @@  discard block
 block discarded – undo
1154 1154
 	 *
1155 1155
 	 * @return bool          If the fee was added
1156 1156
 	 */
1157
-	public function add_fee( $args, $global = true ) {
1157
+	public function add_fee($args, $global = true) {
1158 1158
 
1159 1159
 		$default_args = array(
1160 1160
 			'label'    => '',
@@ -1164,15 +1164,15 @@  discard block
 block discarded – undo
1164 1164
 			'price_id' => 0,
1165 1165
 		);
1166 1166
 
1167
-		$fee          = wp_parse_args( $args, $default_args );
1167
+		$fee          = wp_parse_args($args, $default_args);
1168 1168
 		$this->fees[] = $fee;
1169 1169
 
1170 1170
 		$added_fee               = $fee;
1171 1171
 		$added_fee['action']     = 'add';
1172 1172
 		$this->pending['fees'][] = $added_fee;
1173
-		reset( $this->fees );
1173
+		reset($this->fees);
1174 1174
 
1175
-		$this->increase_fees( $fee['amount'] );
1175
+		$this->increase_fees($fee['amount']);
1176 1176
 
1177 1177
 		return true;
1178 1178
 	}
@@ -1187,11 +1187,11 @@  discard block
 block discarded – undo
1187 1187
 	 *
1188 1188
 	 * @return bool     If the fee was removed successfully
1189 1189
 	 */
1190
-	public function remove_fee( $key ) {
1190
+	public function remove_fee($key) {
1191 1191
 		$removed = false;
1192 1192
 
1193
-		if ( is_numeric( $key ) ) {
1194
-			$removed = $this->remove_fee_by( 'index', $key );
1193
+		if (is_numeric($key)) {
1194
+			$removed = $this->remove_fee_by('index', $key);
1195 1195
 		}
1196 1196
 
1197 1197
 		return $removed;
@@ -1210,55 +1210,55 @@  discard block
 block discarded – undo
1210 1210
 	 *
1211 1211
 	 * @return boolean            If the item is removed
1212 1212
 	 */
1213
-	public function remove_fee_by( $key, $value, $global = false ) {
1213
+	public function remove_fee_by($key, $value, $global = false) {
1214 1214
 
1215
-		$allowed_fee_keys = apply_filters( 'give_payment_fee_keys', array(
1215
+		$allowed_fee_keys = apply_filters('give_payment_fee_keys', array(
1216 1216
 			'index',
1217 1217
 			'label',
1218 1218
 			'amount',
1219 1219
 			'type',
1220
-		) );
1220
+		));
1221 1221
 
1222
-		if ( ! in_array( $key, $allowed_fee_keys ) ) {
1222
+		if ( ! in_array($key, $allowed_fee_keys)) {
1223 1223
 			return false;
1224 1224
 		}
1225 1225
 
1226 1226
 		$removed = false;
1227
-		if ( 'index' === $key && array_key_exists( $value, $this->fees ) ) {
1227
+		if ('index' === $key && array_key_exists($value, $this->fees)) {
1228 1228
 
1229
-			$removed_fee             = $this->fees[ $value ];
1229
+			$removed_fee             = $this->fees[$value];
1230 1230
 			$removed_fee['action']   = 'remove';
1231 1231
 			$this->pending['fees'][] = $removed_fee;
1232 1232
 
1233
-			$this->decrease_fees( $removed_fee['amount'] );
1233
+			$this->decrease_fees($removed_fee['amount']);
1234 1234
 
1235
-			unset( $this->fees[ $value ] );
1235
+			unset($this->fees[$value]);
1236 1236
 			$removed = true;
1237 1237
 
1238
-		} elseif ( 'index' !== $key ) {
1238
+		} elseif ('index' !== $key) {
1239 1239
 
1240
-			foreach ( $this->fees as $index => $fee ) {
1240
+			foreach ($this->fees as $index => $fee) {
1241 1241
 
1242
-				if ( isset( $fee[ $key ] ) && $fee[ $key ] == $value ) {
1242
+				if (isset($fee[$key]) && $fee[$key] == $value) {
1243 1243
 
1244 1244
 					$removed_fee             = $fee;
1245 1245
 					$removed_fee['action']   = 'remove';
1246 1246
 					$this->pending['fees'][] = $removed_fee;
1247 1247
 
1248
-					$this->decrease_fees( $removed_fee['amount'] );
1248
+					$this->decrease_fees($removed_fee['amount']);
1249 1249
 
1250
-					unset( $this->fees[ $index ] );
1250
+					unset($this->fees[$index]);
1251 1251
 					$removed = true;
1252 1252
 
1253
-					if ( false === $global ) {
1253
+					if (false === $global) {
1254 1254
 						break;
1255 1255
 					}
1256 1256
 				}
1257 1257
 			}
1258 1258
 		}
1259 1259
 
1260
-		if ( true === $removed ) {
1261
-			$this->fees = array_values( $this->fees );
1260
+		if (true === $removed) {
1261
+			$this->fees = array_values($this->fees);
1262 1262
 		}
1263 1263
 
1264 1264
 		return $removed;
@@ -1274,14 +1274,14 @@  discard block
 block discarded – undo
1274 1274
 	 *
1275 1275
 	 * @return array        The Fees for the type specified
1276 1276
 	 */
1277
-	public function get_fees( $type = 'all' ) {
1277
+	public function get_fees($type = 'all') {
1278 1278
 		$fees = array();
1279 1279
 
1280
-		if ( ! empty( $this->fees ) && is_array( $this->fees ) ) {
1280
+		if ( ! empty($this->fees) && is_array($this->fees)) {
1281 1281
 
1282
-			foreach ( $this->fees as $fee_id => $fee ) {
1282
+			foreach ($this->fees as $fee_id => $fee) {
1283 1283
 
1284
-				if ( 'all' != $type && ! empty( $fee['type'] ) && $type != $fee['type'] ) {
1284
+				if ('all' != $type && ! empty($fee['type']) && $type != $fee['type']) {
1285 1285
 					continue;
1286 1286
 				}
1287 1287
 
@@ -1291,7 +1291,7 @@  discard block
 block discarded – undo
1291 1291
 			}
1292 1292
 		}
1293 1293
 
1294
-		return apply_filters( 'give_get_payment_fees', $fees, $this->ID, $this );
1294
+		return apply_filters('give_get_payment_fees', $fees, $this->ID, $this);
1295 1295
 	}
1296 1296
 
1297 1297
 	/**
@@ -1304,13 +1304,13 @@  discard block
 block discarded – undo
1304 1304
 	 *
1305 1305
 	 * @return void
1306 1306
 	 */
1307
-	public function add_note( $note = false ) {
1307
+	public function add_note($note = false) {
1308 1308
 		// Bail if no note specified.
1309
-		if ( ! $note ) {
1309
+		if ( ! $note) {
1310 1310
 			return false;
1311 1311
 		}
1312 1312
 
1313
-		give_insert_payment_note( $this->ID, $note );
1313
+		give_insert_payment_note($this->ID, $note);
1314 1314
 	}
1315 1315
 
1316 1316
 	/**
@@ -1323,8 +1323,8 @@  discard block
 block discarded – undo
1323 1323
 	 *
1324 1324
 	 * @return void
1325 1325
 	 */
1326
-	private function increase_subtotal( $amount = 0.00 ) {
1327
-		$amount         = (float) $amount;
1326
+	private function increase_subtotal($amount = 0.00) {
1327
+		$amount = (float) $amount;
1328 1328
 		$this->subtotal += $amount;
1329 1329
 
1330 1330
 		$this->recalculate_total();
@@ -1340,11 +1340,11 @@  discard block
 block discarded – undo
1340 1340
 	 *
1341 1341
 	 * @return void
1342 1342
 	 */
1343
-	private function decrease_subtotal( $amount = 0.00 ) {
1344
-		$amount         = (float) $amount;
1343
+	private function decrease_subtotal($amount = 0.00) {
1344
+		$amount = (float) $amount;
1345 1345
 		$this->subtotal -= $amount;
1346 1346
 
1347
-		if ( $this->subtotal < 0 ) {
1347
+		if ($this->subtotal < 0) {
1348 1348
 			$this->subtotal = 0;
1349 1349
 		}
1350 1350
 
@@ -1361,8 +1361,8 @@  discard block
 block discarded – undo
1361 1361
 	 *
1362 1362
 	 * @return void
1363 1363
 	 */
1364
-	private function increase_fees( $amount = 0.00 ) {
1365
-		$amount           = (float) $amount;
1364
+	private function increase_fees($amount = 0.00) {
1365
+		$amount = (float) $amount;
1366 1366
 		$this->fees_total += $amount;
1367 1367
 
1368 1368
 		$this->recalculate_total();
@@ -1378,11 +1378,11 @@  discard block
 block discarded – undo
1378 1378
 	 *
1379 1379
 	 * @return void
1380 1380
 	 */
1381
-	private function decrease_fees( $amount = 0.00 ) {
1382
-		$amount           = (float) $amount;
1381
+	private function decrease_fees($amount = 0.00) {
1382
+		$amount = (float) $amount;
1383 1383
 		$this->fees_total -= $amount;
1384 1384
 
1385
-		if ( $this->fees_total < 0 ) {
1385
+		if ($this->fees_total < 0) {
1386 1386
 			$this->fees_total = 0;
1387 1387
 		}
1388 1388
 
@@ -1411,24 +1411,24 @@  discard block
 block discarded – undo
1411 1411
 	 *
1412 1412
 	 * @return bool   $updated Returns if the status was successfully updated.
1413 1413
 	 */
1414
-	public function update_status( $status = false ) {
1414
+	public function update_status($status = false) {
1415 1415
 
1416 1416
 		// standardize the 'complete(d)' status.
1417
-		if ( $status == 'completed' || $status == 'complete' ) {
1417
+		if ($status == 'completed' || $status == 'complete') {
1418 1418
 			$status = 'publish';
1419 1419
 		}
1420 1420
 
1421
-		$old_status = ! empty( $this->old_status ) ? $this->old_status : false;
1421
+		$old_status = ! empty($this->old_status) ? $this->old_status : false;
1422 1422
 
1423
-		if ( $old_status === $status ) {
1423
+		if ($old_status === $status) {
1424 1424
 			return false; // Don't permit status changes that aren't changes.
1425 1425
 		}
1426 1426
 
1427
-		$do_change = apply_filters( 'give_should_update_payment_status', true, $this->ID, $status, $old_status );
1427
+		$do_change = apply_filters('give_should_update_payment_status', true, $this->ID, $status, $old_status);
1428 1428
 
1429 1429
 		$updated = false;
1430 1430
 
1431
-		if ( $do_change ) {
1431
+		if ($do_change) {
1432 1432
 
1433 1433
 			/**
1434 1434
 			 * Fires before changing payment status.
@@ -1439,21 +1439,21 @@  discard block
 block discarded – undo
1439 1439
 			 * @param string $status The new status.
1440 1440
 			 * @param string $old_status The old status.
1441 1441
 			 */
1442
-			do_action( 'give_before_payment_status_change', $this->ID, $status, $old_status );
1442
+			do_action('give_before_payment_status_change', $this->ID, $status, $old_status);
1443 1443
 
1444 1444
 			$update_fields = array(
1445 1445
 				'ID'          => $this->ID,
1446 1446
 				'post_status' => $status,
1447
-				'edit_date'   => current_time( 'mysql' ),
1447
+				'edit_date'   => current_time('mysql'),
1448 1448
 			);
1449 1449
 
1450
-			$updated = wp_update_post( apply_filters( 'give_update_payment_status_fields', $update_fields ) );
1450
+			$updated = wp_update_post(apply_filters('give_update_payment_status_fields', $update_fields));
1451 1451
 
1452 1452
 			$all_payment_statuses  = give_get_payment_statuses();
1453
-			$this->status_nicename = array_key_exists( $status, $all_payment_statuses ) ? $all_payment_statuses[ $status ] : ucfirst( $status );
1453
+			$this->status_nicename = array_key_exists($status, $all_payment_statuses) ? $all_payment_statuses[$status] : ucfirst($status);
1454 1454
 
1455 1455
 			// Process any specific status functions.
1456
-			switch ( $status ) {
1456
+			switch ($status) {
1457 1457
 				case 'refunded':
1458 1458
 					$this->process_refund();
1459 1459
 					break;
@@ -1480,7 +1480,7 @@  discard block
 block discarded – undo
1480 1480
 			 * @param string $status The new status.
1481 1481
 			 * @param string $old_status The old status.
1482 1482
 			 */
1483
-			do_action( 'give_update_payment_status', $this->ID, $status, $old_status );
1483
+			do_action('give_update_payment_status', $this->ID, $status, $old_status);
1484 1484
 
1485 1485
 		}// End if().
1486 1486
 
@@ -1515,33 +1515,33 @@  discard block
 block discarded – undo
1515 1515
 	 *
1516 1516
 	 * @return mixed             The value from the post meta
1517 1517
 	 */
1518
-	public function get_meta( $meta_key = '_give_payment_meta', $single = true ) {
1518
+	public function get_meta($meta_key = '_give_payment_meta', $single = true) {
1519 1519
 
1520
-		$meta = give_get_meta( $this->ID, $meta_key, $single );
1520
+		$meta = give_get_meta($this->ID, $meta_key, $single);
1521 1521
 
1522
-		if ( $meta_key === '_give_payment_meta' ) {
1522
+		if ($meta_key === '_give_payment_meta') {
1523 1523
 			$meta = (array) $meta;
1524 1524
 
1525
-			if ( empty( $meta['key'] ) ) {
1525
+			if (empty($meta['key'])) {
1526 1526
 				$meta['key'] = $this->setup_payment_key();
1527 1527
 			}
1528 1528
 
1529
-			if ( empty( $meta['form_title'] ) ) {
1529
+			if (empty($meta['form_title'])) {
1530 1530
 				$meta['form_title'] = $this->setup_form_title();
1531 1531
 			}
1532 1532
 
1533
-			if ( empty( $meta['email'] ) ) {
1533
+			if (empty($meta['email'])) {
1534 1534
 				$meta['email'] = $this->setup_email();
1535 1535
 			}
1536 1536
 
1537
-			if ( empty( $meta['date'] ) ) {
1538
-				$meta['date'] = get_post_field( 'post_date', $this->ID );
1537
+			if (empty($meta['date'])) {
1538
+				$meta['date'] = get_post_field('post_date', $this->ID);
1539 1539
 			}
1540 1540
 		}
1541 1541
 
1542
-		$meta = apply_filters( "give_get_payment_meta_{$meta_key}", $meta, $this->ID );
1542
+		$meta = apply_filters("give_get_payment_meta_{$meta_key}", $meta, $this->ID);
1543 1543
 
1544
-		return apply_filters( 'give_get_payment_meta', $meta, $this->ID, $meta_key );
1544
+		return apply_filters('give_get_payment_meta', $meta, $this->ID, $meta_key);
1545 1545
 	}
1546 1546
 
1547 1547
 	/**
@@ -1556,23 +1556,23 @@  discard block
 block discarded – undo
1556 1556
 	 *
1557 1557
 	 * @return int|bool           Meta ID if the key didn't exist, true on successful update, false on failure
1558 1558
 	 */
1559
-	public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) {
1560
-		if ( empty( $meta_key ) ) {
1559
+	public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') {
1560
+		if (empty($meta_key)) {
1561 1561
 			return false;
1562 1562
 		}
1563 1563
 
1564
-		if ( $meta_key == 'key' || $meta_key == 'date' ) {
1564
+		if ($meta_key == 'key' || $meta_key == 'date') {
1565 1565
 
1566 1566
 			$current_meta              = $this->get_meta();
1567
-			$current_meta[ $meta_key ] = $meta_value;
1567
+			$current_meta[$meta_key] = $meta_value;
1568 1568
 
1569 1569
 			$meta_key   = '_give_payment_meta';
1570 1570
 			$meta_value = $current_meta;
1571 1571
 
1572
-		} elseif ( $meta_key == 'email' || $meta_key == '_give_payment_user_email' ) {
1572
+		} elseif ($meta_key == 'email' || $meta_key == '_give_payment_user_email') {
1573 1573
 
1574
-			$meta_value = apply_filters( "give_update_payment_meta_{$meta_key}", $meta_value, $this->ID );
1575
-			give_update_meta( $this->ID, '_give_payment_user_email', $meta_value );
1574
+			$meta_value = apply_filters("give_update_payment_meta_{$meta_key}", $meta_value, $this->ID);
1575
+			give_update_meta($this->ID, '_give_payment_user_email', $meta_value);
1576 1576
 
1577 1577
 			$current_meta                       = $this->get_meta();
1578 1578
 			$current_meta['user_info']['email'] = $meta_value;
@@ -1582,9 +1582,9 @@  discard block
 block discarded – undo
1582 1582
 
1583 1583
 		}
1584 1584
 
1585
-		$meta_value = apply_filters( "give_update_payment_meta_{$meta_key}", $meta_value, $this->ID );
1585
+		$meta_value = apply_filters("give_update_payment_meta_{$meta_key}", $meta_value, $this->ID);
1586 1586
 
1587
-		return give_update_meta( $this->ID, $meta_key, $meta_value, $prev_value );
1587
+		return give_update_meta($this->ID, $meta_key, $meta_value, $prev_value);
1588 1588
 	}
1589 1589
 
1590 1590
 	/**
@@ -1599,14 +1599,14 @@  discard block
 block discarded – undo
1599 1599
 		$process_refund = true;
1600 1600
 
1601 1601
 		// If the payment was not in publish or revoked status, don't decrement stats as they were never incremented.
1602
-		if ( 'publish' != $this->old_status || 'refunded' != $this->status ) {
1602
+		if ('publish' != $this->old_status || 'refunded' != $this->status) {
1603 1603
 			$process_refund = false;
1604 1604
 		}
1605 1605
 
1606 1606
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments.
1607
-		$process_refund = apply_filters( 'give_should_process_refund', $process_refund, $this );
1607
+		$process_refund = apply_filters('give_should_process_refund', $process_refund, $this);
1608 1608
 
1609
-		if ( false === $process_refund ) {
1609
+		if (false === $process_refund) {
1610 1610
 			return;
1611 1611
 		}
1612 1612
 
@@ -1617,13 +1617,13 @@  discard block
 block discarded – undo
1617 1617
 		 *
1618 1618
 		 * @param Give_Payment $this Payment object.
1619 1619
 		 */
1620
-		do_action( 'give_pre_refund_payment', $this );
1620
+		do_action('give_pre_refund_payment', $this);
1621 1621
 
1622
-		$decrease_earnings       = apply_filters( 'give_decrease_store_earnings_on_refund', true, $this );
1623
-		$decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_refund', true, $this );
1624
-		$decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_refund', true, $this );
1622
+		$decrease_earnings       = apply_filters('give_decrease_store_earnings_on_refund', true, $this);
1623
+		$decrease_customer_value = apply_filters('give_decrease_customer_value_on_refund', true, $this);
1624
+		$decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_refund', true, $this);
1625 1625
 
1626
-		$this->maybe_alter_stats( $decrease_earnings, $decrease_customer_value, $decrease_purchase_count );
1626
+		$this->maybe_alter_stats($decrease_earnings, $decrease_customer_value, $decrease_purchase_count);
1627 1627
 		$this->delete_sales_logs();
1628 1628
 
1629 1629
 		// @todo: Refresh only range related stat cache
@@ -1636,7 +1636,7 @@  discard block
 block discarded – undo
1636 1636
 		 *
1637 1637
 		 * @param Give_Payment $this Payment object.
1638 1638
 		 */
1639
-		do_action( 'give_post_refund_payment', $this );
1639
+		do_action('give_post_refund_payment', $this);
1640 1640
 	}
1641 1641
 
1642 1642
 	/**
@@ -1663,26 +1663,26 @@  discard block
 block discarded – undo
1663 1663
 		$process_pending = true;
1664 1664
 
1665 1665
 		// If the payment was not in publish or revoked status, don't decrement stats as they were never incremented.
1666
-		if ( 'publish' != $this->old_status || 'pending' != $this->status ) {
1666
+		if ('publish' != $this->old_status || 'pending' != $this->status) {
1667 1667
 			$process_pending = false;
1668 1668
 		}
1669 1669
 
1670 1670
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments.
1671
-		$process_pending = apply_filters( 'give_should_process_pending', $process_pending, $this );
1671
+		$process_pending = apply_filters('give_should_process_pending', $process_pending, $this);
1672 1672
 
1673
-		if ( false === $process_pending ) {
1673
+		if (false === $process_pending) {
1674 1674
 			return;
1675 1675
 		}
1676 1676
 
1677
-		$decrease_earnings       = apply_filters( 'give_decrease_earnings_on_pending', true, $this );
1678
-		$decrease_donor_value    = apply_filters( 'give_decrease_donor_value_on_pending', true, $this );
1679
-		$decrease_donation_count = apply_filters( 'give_decrease_donors_donation_count_on_pending', true, $this );
1677
+		$decrease_earnings       = apply_filters('give_decrease_earnings_on_pending', true, $this);
1678
+		$decrease_donor_value    = apply_filters('give_decrease_donor_value_on_pending', true, $this);
1679
+		$decrease_donation_count = apply_filters('give_decrease_donors_donation_count_on_pending', true, $this);
1680 1680
 
1681
-		$this->maybe_alter_stats( $decrease_earnings, $decrease_donor_value, $decrease_donation_count );
1681
+		$this->maybe_alter_stats($decrease_earnings, $decrease_donor_value, $decrease_donation_count);
1682 1682
 		$this->delete_sales_logs();
1683 1683
 
1684 1684
 		$this->completed_date = false;
1685
-		$this->update_meta( '_give_completed_date', '' );
1685
+		$this->update_meta('_give_completed_date', '');
1686 1686
 
1687 1687
 		// @todo: Refresh only range related stat cache
1688 1688
 		give_delete_donation_stats();
@@ -1700,26 +1700,26 @@  discard block
 block discarded – undo
1700 1700
 		$process_cancelled = true;
1701 1701
 
1702 1702
 		// If the payment was not in publish or revoked status, don't decrement stats as they were never incremented.
1703
-		if ( 'publish' != $this->old_status || 'cancelled' != $this->status ) {
1703
+		if ('publish' != $this->old_status || 'cancelled' != $this->status) {
1704 1704
 			$process_cancelled = false;
1705 1705
 		}
1706 1706
 
1707 1707
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments.
1708
-		$process_cancelled = apply_filters( 'give_should_process_cancelled', $process_cancelled, $this );
1708
+		$process_cancelled = apply_filters('give_should_process_cancelled', $process_cancelled, $this);
1709 1709
 
1710
-		if ( false === $process_cancelled ) {
1710
+		if (false === $process_cancelled) {
1711 1711
 			return;
1712 1712
 		}
1713 1713
 
1714
-		$decrease_earnings       = apply_filters( 'give_decrease_earnings_on_cancelled', true, $this );
1715
-		$decrease_donor_value    = apply_filters( 'give_decrease_donor_value_on_cancelled', true, $this );
1716
-		$decrease_donation_count = apply_filters( 'give_decrease_donors_donation_count_on_cancelled', true, $this );
1714
+		$decrease_earnings       = apply_filters('give_decrease_earnings_on_cancelled', true, $this);
1715
+		$decrease_donor_value    = apply_filters('give_decrease_donor_value_on_cancelled', true, $this);
1716
+		$decrease_donation_count = apply_filters('give_decrease_donors_donation_count_on_cancelled', true, $this);
1717 1717
 
1718
-		$this->maybe_alter_stats( $decrease_earnings, $decrease_donor_value, $decrease_donation_count );
1718
+		$this->maybe_alter_stats($decrease_earnings, $decrease_donor_value, $decrease_donation_count);
1719 1719
 		$this->delete_sales_logs();
1720 1720
 
1721 1721
 		$this->completed_date = false;
1722
-		$this->update_meta( '_give_completed_date', '' );
1722
+		$this->update_meta('_give_completed_date', '');
1723 1723
 
1724 1724
 		// @todo: Refresh only range related stat cache
1725 1725
 		give_delete_donation_stats();
@@ -1735,26 +1735,26 @@  discard block
 block discarded – undo
1735 1735
 		$process_revoked = true;
1736 1736
 
1737 1737
 		// If the payment was not in publish, don't decrement stats as they were never incremented.
1738
-		if ( 'publish' != $this->old_status || 'revoked' != $this->status ) {
1738
+		if ('publish' != $this->old_status || 'revoked' != $this->status) {
1739 1739
 			$process_revoked = false;
1740 1740
 		}
1741 1741
 
1742 1742
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments.
1743
-		$process_revoked = apply_filters( 'give_should_process_revoked', $process_revoked, $this );
1743
+		$process_revoked = apply_filters('give_should_process_revoked', $process_revoked, $this);
1744 1744
 
1745
-		if ( false === $process_revoked ) {
1745
+		if (false === $process_revoked) {
1746 1746
 			return;
1747 1747
 		}
1748 1748
 
1749
-		$decrease_earnings       = apply_filters( 'give_decrease_earnings_on_revoked', true, $this );
1750
-		$decrease_donor_value    = apply_filters( 'give_decrease_donor_value_on_revoked', true, $this );
1751
-		$decrease_donation_count = apply_filters( 'give_decrease_donors_donation_count_on_revoked', true, $this );
1749
+		$decrease_earnings       = apply_filters('give_decrease_earnings_on_revoked', true, $this);
1750
+		$decrease_donor_value    = apply_filters('give_decrease_donor_value_on_revoked', true, $this);
1751
+		$decrease_donation_count = apply_filters('give_decrease_donors_donation_count_on_revoked', true, $this);
1752 1752
 
1753
-		$this->maybe_alter_stats( $decrease_earnings, $decrease_donor_value, $decrease_donation_count );
1753
+		$this->maybe_alter_stats($decrease_earnings, $decrease_donor_value, $decrease_donation_count);
1754 1754
 		$this->delete_sales_logs();
1755 1755
 
1756 1756
 		$this->completed_date = false;
1757
-		$this->update_meta( '_give_completed_date', '' );
1757
+		$this->update_meta('_give_completed_date', '');
1758 1758
 
1759 1759
 		// @todo: Refresh only range related stat cache
1760 1760
 		give_delete_donation_stats();
@@ -1772,25 +1772,25 @@  discard block
 block discarded – undo
1772 1772
 	 *
1773 1773
 	 * @return void
1774 1774
 	 */
1775
-	private function maybe_alter_stats( $alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count ) {
1775
+	private function maybe_alter_stats($alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count) {
1776 1776
 
1777
-		give_undo_purchase( false, $this->ID );
1777
+		give_undo_purchase(false, $this->ID);
1778 1778
 
1779 1779
 		// Decrease store earnings.
1780
-		if ( true === $alter_store_earnings ) {
1781
-			give_decrease_total_earnings( $this->total );
1780
+		if (true === $alter_store_earnings) {
1781
+			give_decrease_total_earnings($this->total);
1782 1782
 		}
1783 1783
 
1784 1784
 		// Decrement the stats for the customer.
1785
-		if ( ! empty( $this->customer_id ) ) {
1785
+		if ( ! empty($this->customer_id)) {
1786 1786
 
1787
-			$customer = new Give_Customer( $this->customer_id );
1787
+			$customer = new Give_Customer($this->customer_id);
1788 1788
 
1789
-			if ( true === $alter_customer_value ) {
1790
-				$customer->decrease_value( $this->total );
1789
+			if (true === $alter_customer_value) {
1790
+				$customer->decrease_value($this->total);
1791 1791
 			}
1792 1792
 
1793
-			if ( true === $alter_customer_purchase_count ) {
1793
+			if (true === $alter_customer_purchase_count) {
1794 1794
 				$customer->decrease_purchase_count();
1795 1795
 			}
1796 1796
 		}
@@ -1839,13 +1839,13 @@  discard block
 block discarded – undo
1839 1839
 	 * @return string The date the payment was completed
1840 1840
 	 */
1841 1841
 	private function setup_completed_date() {
1842
-		$payment = get_post( $this->ID );
1842
+		$payment = get_post($this->ID);
1843 1843
 
1844
-		if ( 'pending' == $payment->post_status || 'preapproved' == $payment->post_status ) {
1844
+		if ('pending' == $payment->post_status || 'preapproved' == $payment->post_status) {
1845 1845
 			return false; // This payment was never completed.
1846 1846
 		}
1847 1847
 
1848
-		$date = ( $date = $this->get_meta( '_give_completed_date', true ) ) ? $date : $payment->modified_date;
1848
+		$date = ($date = $this->get_meta('_give_completed_date', true)) ? $date : $payment->modified_date;
1849 1849
 
1850 1850
 		return $date;
1851 1851
 	}
@@ -1859,7 +1859,7 @@  discard block
 block discarded – undo
1859 1859
 	 * @return string The payment mode
1860 1860
 	 */
1861 1861
 	private function setup_mode() {
1862
-		return $this->get_meta( '_give_payment_mode' );
1862
+		return $this->get_meta('_give_payment_mode');
1863 1863
 	}
1864 1864
 
1865 1865
 	/**
@@ -1871,18 +1871,18 @@  discard block
 block discarded – undo
1871 1871
 	 * @return float The payment total
1872 1872
 	 */
1873 1873
 	private function setup_total() {
1874
-		$amount = $this->get_meta( '_give_payment_total', true );
1874
+		$amount = $this->get_meta('_give_payment_total', true);
1875 1875
 
1876
-		if ( empty( $amount ) && '0.00' != $amount ) {
1877
-			$meta = $this->get_meta( '_give_payment_meta', true );
1878
-			$meta = maybe_unserialize( $meta );
1876
+		if (empty($amount) && '0.00' != $amount) {
1877
+			$meta = $this->get_meta('_give_payment_meta', true);
1878
+			$meta = maybe_unserialize($meta);
1879 1879
 
1880
-			if ( isset( $meta['amount'] ) ) {
1880
+			if (isset($meta['amount'])) {
1881 1881
 				$amount = $meta['amount'];
1882 1882
 			}
1883 1883
 		}
1884 1884
 
1885
-		return round( floatval( $amount ), give_currency_decimal_filter() );
1885
+		return round(floatval($amount), give_currency_decimal_filter());
1886 1886
 	}
1887 1887
 
1888 1888
 	/**
@@ -1910,9 +1910,9 @@  discard block
 block discarded – undo
1910 1910
 	private function setup_fees_total() {
1911 1911
 		$fees_total = (float) 0.00;
1912 1912
 
1913
-		$payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array();
1914
-		if ( ! empty( $payment_fees ) ) {
1915
-			foreach ( $payment_fees as $fee ) {
1913
+		$payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array();
1914
+		if ( ! empty($payment_fees)) {
1915
+			foreach ($payment_fees as $fee) {
1916 1916
 				$fees_total += (float) $fee['amount'];
1917 1917
 			}
1918 1918
 		}
@@ -1930,7 +1930,7 @@  discard block
 block discarded – undo
1930 1930
 	 * @return string The currency for the payment
1931 1931
 	 */
1932 1932
 	private function setup_currency() {
1933
-		$currency = isset( $this->payment_meta['currency'] ) ? $this->payment_meta['currency'] : apply_filters( 'give_payment_currency_default', give_get_currency(), $this );
1933
+		$currency = isset($this->payment_meta['currency']) ? $this->payment_meta['currency'] : apply_filters('give_payment_currency_default', give_get_currency(), $this);
1934 1934
 
1935 1935
 		return $currency;
1936 1936
 	}
@@ -1944,7 +1944,7 @@  discard block
 block discarded – undo
1944 1944
 	 * @return array The Fees
1945 1945
 	 */
1946 1946
 	private function setup_fees() {
1947
-		$payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array();
1947
+		$payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array();
1948 1948
 
1949 1949
 		return $payment_fees;
1950 1950
 	}
@@ -1958,7 +1958,7 @@  discard block
 block discarded – undo
1958 1958
 	 * @return string The gateway
1959 1959
 	 */
1960 1960
 	private function setup_gateway() {
1961
-		$gateway = $this->get_meta( '_give_payment_gateway', true );
1961
+		$gateway = $this->get_meta('_give_payment_gateway', true);
1962 1962
 
1963 1963
 		return $gateway;
1964 1964
 	}
@@ -1972,11 +1972,11 @@  discard block
 block discarded – undo
1972 1972
 	 * @return string The donation ID
1973 1973
 	 */
1974 1974
 	private function setup_transaction_id() {
1975
-		$transaction_id = $this->get_meta( '_give_payment_transaction_id', true );
1975
+		$transaction_id = $this->get_meta('_give_payment_transaction_id', true);
1976 1976
 
1977
-		if ( empty( $transaction_id ) ) {
1977
+		if (empty($transaction_id)) {
1978 1978
 			$gateway        = $this->gateway;
1979
-			$transaction_id = apply_filters( "give_get_payment_transaction_id-{$gateway}", $this->ID );
1979
+			$transaction_id = apply_filters("give_get_payment_transaction_id-{$gateway}", $this->ID);
1980 1980
 		}
1981 1981
 
1982 1982
 		return $transaction_id;
@@ -1991,7 +1991,7 @@  discard block
 block discarded – undo
1991 1991
 	 * @return string The IP address for the payment
1992 1992
 	 */
1993 1993
 	private function setup_ip() {
1994
-		$ip = $this->get_meta( '_give_payment_user_ip', true );
1994
+		$ip = $this->get_meta('_give_payment_user_ip', true);
1995 1995
 
1996 1996
 		return $ip;
1997 1997
 	}
@@ -2005,7 +2005,7 @@  discard block
 block discarded – undo
2005 2005
 	 * @return int The Customer ID
2006 2006
 	 */
2007 2007
 	private function setup_customer_id() {
2008
-		$customer_id = $this->get_meta( '_give_payment_customer_id', true );
2008
+		$customer_id = $this->get_meta('_give_payment_customer_id', true);
2009 2009
 
2010 2010
 		return $customer_id;
2011 2011
 	}
@@ -2019,7 +2019,7 @@  discard block
 block discarded – undo
2019 2019
 	 * @return int The User ID
2020 2020
 	 */
2021 2021
 	private function setup_user_id() {
2022
-		$user_id = $this->get_meta( '_give_payment_user_id', true );
2022
+		$user_id = $this->get_meta('_give_payment_user_id', true);
2023 2023
 
2024 2024
 		return $user_id;
2025 2025
 	}
@@ -2033,10 +2033,10 @@  discard block
 block discarded – undo
2033 2033
 	 * @return string The email address for the payment
2034 2034
 	 */
2035 2035
 	private function setup_email() {
2036
-		$email = $this->get_meta( '_give_payment_user_email', true );
2036
+		$email = $this->get_meta('_give_payment_user_email', true);
2037 2037
 
2038
-		if ( empty( $email ) ) {
2039
-			$email = Give()->customers->get_column( 'email', $this->customer_id );
2038
+		if (empty($email)) {
2039
+			$email = Give()->customers->get_column('email', $this->customer_id);
2040 2040
 		}
2041 2041
 
2042 2042
 		return $email;
@@ -2056,15 +2056,15 @@  discard block
 block discarded – undo
2056 2056
 			'last_name'  => $this->last_name,
2057 2057
 		);
2058 2058
 
2059
-		$user_info = isset( $this->payment_meta['user_info'] ) ? maybe_unserialize( $this->payment_meta['user_info'] ) : array();
2060
-		$user_info = wp_parse_args( $user_info, $defaults );
2059
+		$user_info = isset($this->payment_meta['user_info']) ? maybe_unserialize($this->payment_meta['user_info']) : array();
2060
+		$user_info = wp_parse_args($user_info, $defaults);
2061 2061
 
2062
-		if ( empty( $user_info ) ) {
2062
+		if (empty($user_info)) {
2063 2063
 			// Get the customer, but only if it's been created.
2064
-			$customer = new Give_Customer( $this->customer_id );
2064
+			$customer = new Give_Customer($this->customer_id);
2065 2065
 
2066
-			if ( $customer->id > 0 ) {
2067
-				$name      = explode( ' ', $customer->name, 2 );
2066
+			if ($customer->id > 0) {
2067
+				$name      = explode(' ', $customer->name, 2);
2068 2068
 				$user_info = array(
2069 2069
 					'first_name' => $name[0],
2070 2070
 					'last_name'  => $name[1],
@@ -2074,29 +2074,29 @@  discard block
 block discarded – undo
2074 2074
 			}
2075 2075
 		} else {
2076 2076
 			// Get the customer, but only if it's been created.
2077
-			$customer = new Give_Customer( $this->customer_id );
2078
-			if ( $customer->id > 0 ) {
2079
-				foreach ( $user_info as $key => $value ) {
2080
-					if ( ! empty( $value ) ) {
2077
+			$customer = new Give_Customer($this->customer_id);
2078
+			if ($customer->id > 0) {
2079
+				foreach ($user_info as $key => $value) {
2080
+					if ( ! empty($value)) {
2081 2081
 						continue;
2082 2082
 					}
2083 2083
 
2084
-					switch ( $key ) {
2084
+					switch ($key) {
2085 2085
 						case 'first_name':
2086
-							$name = explode( ' ', $customer->name, 2 );
2086
+							$name = explode(' ', $customer->name, 2);
2087 2087
 
2088
-							$user_info[ $key ] = $name[0];
2088
+							$user_info[$key] = $name[0];
2089 2089
 							break;
2090 2090
 
2091 2091
 						case 'last_name':
2092
-							$name      = explode( ' ', $customer->name, 2 );
2093
-							$last_name = ! empty( $name[1] ) ? $name[1] : '';
2092
+							$name      = explode(' ', $customer->name, 2);
2093
+							$last_name = ! empty($name[1]) ? $name[1] : '';
2094 2094
 
2095
-							$user_info[ $key ] = $last_name;
2095
+							$user_info[$key] = $last_name;
2096 2096
 							break;
2097 2097
 
2098 2098
 						case 'email':
2099
-							$user_info[ $key ] = $customer->email;
2099
+							$user_info[$key] = $customer->email;
2100 2100
 							break;
2101 2101
 					}
2102 2102
 				}
@@ -2117,7 +2117,7 @@  discard block
 block discarded – undo
2117 2117
 	 */
2118 2118
 	private function setup_address() {
2119 2119
 
2120
-		$address = ! empty( $this->payment_meta['user_info']['address'] ) ? $this->payment_meta['user_info']['address'] : array(
2120
+		$address = ! empty($this->payment_meta['user_info']['address']) ? $this->payment_meta['user_info']['address'] : array(
2121 2121
 			'line1'   => '',
2122 2122
 			'line2'   => '',
2123 2123
 			'city'    => '',
@@ -2139,7 +2139,7 @@  discard block
 block discarded – undo
2139 2139
 	 */
2140 2140
 	private function setup_form_title() {
2141 2141
 
2142
-		$form_id = $this->get_meta( '_give_payment_form_title', true );
2142
+		$form_id = $this->get_meta('_give_payment_form_title', true);
2143 2143
 
2144 2144
 		return $form_id;
2145 2145
 	}
@@ -2154,7 +2154,7 @@  discard block
 block discarded – undo
2154 2154
 	 */
2155 2155
 	private function setup_form_id() {
2156 2156
 
2157
-		$form_id = $this->get_meta( '_give_payment_form_id', true );
2157
+		$form_id = $this->get_meta('_give_payment_form_id', true);
2158 2158
 
2159 2159
 		return $form_id;
2160 2160
 	}
@@ -2168,7 +2168,7 @@  discard block
 block discarded – undo
2168 2168
 	 * @return int The Form Price ID
2169 2169
 	 */
2170 2170
 	private function setup_price_id() {
2171
-		$price_id = $this->get_meta( '_give_payment_price_id', true );
2171
+		$price_id = $this->get_meta('_give_payment_price_id', true);
2172 2172
 
2173 2173
 		return $price_id;
2174 2174
 	}
@@ -2182,7 +2182,7 @@  discard block
 block discarded – undo
2182 2182
 	 * @return string The Payment Key
2183 2183
 	 */
2184 2184
 	private function setup_payment_key() {
2185
-		$key = $this->get_meta( '_give_payment_purchase_key', true );
2185
+		$key = $this->get_meta('_give_payment_purchase_key', true);
2186 2186
 
2187 2187
 		return $key;
2188 2188
 	}
@@ -2198,11 +2198,11 @@  discard block
 block discarded – undo
2198 2198
 	private function setup_payment_number() {
2199 2199
 		$number = $this->ID;
2200 2200
 
2201
-		if ( give_get_option( 'enable_sequential' ) ) {
2201
+		if (give_get_option('enable_sequential')) {
2202 2202
 
2203
-			$number = $this->get_meta( '_give_payment_number', true );
2203
+			$number = $this->get_meta('_give_payment_number', true);
2204 2204
 
2205
-			if ( ! $number ) {
2205
+			if ( ! $number) {
2206 2206
 
2207 2207
 				$number = $this->ID;
2208 2208
 
@@ -2220,7 +2220,7 @@  discard block
 block discarded – undo
2220 2220
 	 * @return array The payment object as an array
2221 2221
 	 */
2222 2222
 	public function array_convert() {
2223
-		return get_object_vars( $this );
2223
+		return get_object_vars($this);
2224 2224
 	}
2225 2225
 
2226 2226
 
@@ -2233,7 +2233,7 @@  discard block
 block discarded – undo
2233 2233
 	 * @return bool
2234 2234
 	 */
2235 2235
 	public function is_completed() {
2236
-		return ( 'publish' === $this->status && $this->completed_date );
2236
+		return ('publish' === $this->status && $this->completed_date);
2237 2237
 	}
2238 2238
 
2239 2239
 	/**
@@ -2245,7 +2245,7 @@  discard block
 block discarded – undo
2245 2245
 	 * @return string Date payment was completed
2246 2246
 	 */
2247 2247
 	private function get_completed_date() {
2248
-		return apply_filters( 'give_payment_completed_date', $this->completed_date, $this->ID, $this );
2248
+		return apply_filters('give_payment_completed_date', $this->completed_date, $this->ID, $this);
2249 2249
 	}
2250 2250
 
2251 2251
 	/**
@@ -2257,7 +2257,7 @@  discard block
 block discarded – undo
2257 2257
 	 * @return float Payment subtotal
2258 2258
 	 */
2259 2259
 	private function get_subtotal() {
2260
-		return apply_filters( 'give_get_payment_subtotal', $this->subtotal, $this->ID, $this );
2260
+		return apply_filters('give_get_payment_subtotal', $this->subtotal, $this->ID, $this);
2261 2261
 	}
2262 2262
 
2263 2263
 	/**
@@ -2269,7 +2269,7 @@  discard block
 block discarded – undo
2269 2269
 	 * @return string Payment currency code
2270 2270
 	 */
2271 2271
 	private function get_currency() {
2272
-		return apply_filters( 'give_payment_currency_code', $this->currency, $this->ID, $this );
2272
+		return apply_filters('give_payment_currency_code', $this->currency, $this->ID, $this);
2273 2273
 	}
2274 2274
 
2275 2275
 	/**
@@ -2281,7 +2281,7 @@  discard block
 block discarded – undo
2281 2281
 	 * @return string Gateway used
2282 2282
 	 */
2283 2283
 	private function get_gateway() {
2284
-		return apply_filters( 'give_payment_gateway', $this->gateway, $this->ID, $this );
2284
+		return apply_filters('give_payment_gateway', $this->gateway, $this->ID, $this);
2285 2285
 	}
2286 2286
 
2287 2287
 	/**
@@ -2293,7 +2293,7 @@  discard block
 block discarded – undo
2293 2293
 	 * @return string Donation ID from merchant processor
2294 2294
 	 */
2295 2295
 	private function get_transaction_id() {
2296
-		return apply_filters( 'give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this );
2296
+		return apply_filters('give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this);
2297 2297
 	}
2298 2298
 
2299 2299
 	/**
@@ -2305,7 +2305,7 @@  discard block
 block discarded – undo
2305 2305
 	 * @return string Payment IP address
2306 2306
 	 */
2307 2307
 	private function get_ip() {
2308
-		return apply_filters( 'give_payment_user_ip', $this->ip, $this->ID, $this );
2308
+		return apply_filters('give_payment_user_ip', $this->ip, $this->ID, $this);
2309 2309
 	}
2310 2310
 
2311 2311
 	/**
@@ -2317,7 +2317,7 @@  discard block
 block discarded – undo
2317 2317
 	 * @return int Payment customer ID
2318 2318
 	 */
2319 2319
 	private function get_customer_id() {
2320
-		return apply_filters( 'give_payment_customer_id', $this->customer_id, $this->ID, $this );
2320
+		return apply_filters('give_payment_customer_id', $this->customer_id, $this->ID, $this);
2321 2321
 	}
2322 2322
 
2323 2323
 	/**
@@ -2329,7 +2329,7 @@  discard block
 block discarded – undo
2329 2329
 	 * @return int Payment user ID
2330 2330
 	 */
2331 2331
 	private function get_user_id() {
2332
-		return apply_filters( 'give_payment_user_id', $this->user_id, $this->ID, $this );
2332
+		return apply_filters('give_payment_user_id', $this->user_id, $this->ID, $this);
2333 2333
 	}
2334 2334
 
2335 2335
 	/**
@@ -2341,7 +2341,7 @@  discard block
 block discarded – undo
2341 2341
 	 * @return string Payment customer email
2342 2342
 	 */
2343 2343
 	private function get_email() {
2344
-		return apply_filters( 'give_payment_user_email', $this->email, $this->ID, $this );
2344
+		return apply_filters('give_payment_user_email', $this->email, $this->ID, $this);
2345 2345
 	}
2346 2346
 
2347 2347
 	/**
@@ -2353,7 +2353,7 @@  discard block
 block discarded – undo
2353 2353
 	 * @return array Payment user info
2354 2354
 	 */
2355 2355
 	private function get_user_info() {
2356
-		return apply_filters( 'give_payment_meta_user_info', $this->user_info, $this->ID, $this );
2356
+		return apply_filters('give_payment_meta_user_info', $this->user_info, $this->ID, $this);
2357 2357
 	}
2358 2358
 
2359 2359
 	/**
@@ -2365,7 +2365,7 @@  discard block
 block discarded – undo
2365 2365
 	 * @return array Payment billing address
2366 2366
 	 */
2367 2367
 	private function get_address() {
2368
-		return apply_filters( 'give_payment_address', $this->address, $this->ID, $this );
2368
+		return apply_filters('give_payment_address', $this->address, $this->ID, $this);
2369 2369
 	}
2370 2370
 
2371 2371
 	/**
@@ -2377,7 +2377,7 @@  discard block
 block discarded – undo
2377 2377
 	 * @return string Payment key
2378 2378
 	 */
2379 2379
 	private function get_key() {
2380
-		return apply_filters( 'give_payment_key', $this->key, $this->ID, $this );
2380
+		return apply_filters('give_payment_key', $this->key, $this->ID, $this);
2381 2381
 	}
2382 2382
 
2383 2383
 	/**
@@ -2389,7 +2389,7 @@  discard block
 block discarded – undo
2389 2389
 	 * @return string Payment form id
2390 2390
 	 */
2391 2391
 	private function get_form_id() {
2392
-		return apply_filters( 'give_payment_form_id', $this->form_id, $this->ID, $this );
2392
+		return apply_filters('give_payment_form_id', $this->form_id, $this->ID, $this);
2393 2393
 	}
2394 2394
 
2395 2395
 	/**
@@ -2401,7 +2401,7 @@  discard block
 block discarded – undo
2401 2401
 	 * @return int|string Payment number
2402 2402
 	 */
2403 2403
 	private function get_number() {
2404
-		return apply_filters( 'give_payment_number', $this->number, $this->ID, $this );
2404
+		return apply_filters('give_payment_number', $this->number, $this->ID, $this);
2405 2405
 	}
2406 2406
 
2407 2407
 }
Please login to merge, or discard this patch.
includes/ajax-functions.php 1 patch
Spacing   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly.
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -26,26 +26,26 @@  discard block
 block discarded – undo
26 26
 function give_test_ajax_works() {
27 27
 
28 28
 	// Check if the Airplane Mode plugin is installed
29
-	if ( class_exists( 'Airplane_Mode_Core' ) ) {
29
+	if (class_exists('Airplane_Mode_Core')) {
30 30
 
31 31
 		$airplane = Airplane_Mode_Core::getInstance();
32 32
 
33
-		if ( method_exists( $airplane, 'enabled' ) ) {
33
+		if (method_exists($airplane, 'enabled')) {
34 34
 
35
-			if ( $airplane->enabled() ) {
35
+			if ($airplane->enabled()) {
36 36
 				return true;
37 37
 			}
38 38
 		} else {
39 39
 
40
-			if ( $airplane->check_status() == 'on' ) {
40
+			if ($airplane->check_status() == 'on') {
41 41
 				return true;
42 42
 			}
43 43
 		}
44 44
 	}
45 45
 
46
-	add_filter( 'block_local_requests', '__return_false' );
46
+	add_filter('block_local_requests', '__return_false');
47 47
 
48
-	if ( Give_Cache::get( '_give_ajax_works', true ) ) {
48
+	if (Give_Cache::get('_give_ajax_works', true)) {
49 49
 		return true;
50 50
 	}
51 51
 
@@ -57,35 +57,35 @@  discard block
 block discarded – undo
57 57
 		),
58 58
 	);
59 59
 
60
-	$ajax = wp_remote_post( give_get_ajax_url(), $params );
60
+	$ajax = wp_remote_post(give_get_ajax_url(), $params);
61 61
 
62 62
 	$works = true;
63 63
 
64
-	if ( is_wp_error( $ajax ) ) {
64
+	if (is_wp_error($ajax)) {
65 65
 
66 66
 		$works = false;
67 67
 
68 68
 	} else {
69 69
 
70
-		if ( empty( $ajax['response'] ) ) {
70
+		if (empty($ajax['response'])) {
71 71
 			$works = false;
72 72
 		}
73 73
 
74
-		if ( empty( $ajax['response']['code'] ) || 200 !== (int) $ajax['response']['code'] ) {
74
+		if (empty($ajax['response']['code']) || 200 !== (int) $ajax['response']['code']) {
75 75
 			$works = false;
76 76
 		}
77 77
 
78
-		if ( empty( $ajax['response']['message'] ) || 'OK' !== $ajax['response']['message'] ) {
78
+		if (empty($ajax['response']['message']) || 'OK' !== $ajax['response']['message']) {
79 79
 			$works = false;
80 80
 		}
81 81
 
82
-		if ( ! isset( $ajax['body'] ) || 0 !== (int) $ajax['body'] ) {
82
+		if ( ! isset($ajax['body']) || 0 !== (int) $ajax['body']) {
83 83
 			$works = false;
84 84
 		}
85 85
 	}
86 86
 
87
-	if ( $works ) {
88
-		Give_Cache::set( '_give_ajax_works', '1', DAY_IN_SECONDS, true );
87
+	if ($works) {
88
+		Give_Cache::set('_give_ajax_works', '1', DAY_IN_SECONDS, true);
89 89
 	}
90 90
 
91 91
 	return $works;
@@ -100,16 +100,16 @@  discard block
 block discarded – undo
100 100
  * @return string
101 101
  */
102 102
 function give_get_ajax_url() {
103
-	$scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
103
+	$scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin';
104 104
 
105 105
 	$current_url = give_get_current_page_url();
106
-	$ajax_url    = admin_url( 'admin-ajax.php', $scheme );
106
+	$ajax_url    = admin_url('admin-ajax.php', $scheme);
107 107
 
108
-	if ( preg_match( '/^https/', $current_url ) && ! preg_match( '/^https/', $ajax_url ) ) {
109
-		$ajax_url = preg_replace( '/^http/', 'https', $ajax_url );
108
+	if (preg_match('/^https/', $current_url) && ! preg_match('/^https/', $ajax_url)) {
109
+		$ajax_url = preg_replace('/^http/', 'https', $ajax_url);
110 110
 	}
111 111
 
112
-	return apply_filters( 'give_ajax_url', $ajax_url );
112
+	return apply_filters('give_ajax_url', $ajax_url);
113 113
 }
114 114
 
115 115
 /**
@@ -125,12 +125,12 @@  discard block
 block discarded – undo
125 125
 	 *
126 126
 	 * @since 1.7
127 127
 	 */
128
-	do_action( 'give_donation_form_login_fields' );
128
+	do_action('give_donation_form_login_fields');
129 129
 
130 130
 	give_die();
131 131
 }
132 132
 
133
-add_action( 'wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields' );
133
+add_action('wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields');
134 134
 
135 135
 /**
136 136
  * Load Checkout Fields
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
  * @return void
141 141
  */
142 142
 function give_load_checkout_fields() {
143
-	$form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : '';
143
+	$form_id = isset($_POST['form_id']) ? $_POST['form_id'] : '';
144 144
 
145 145
 	ob_start();
146 146
 
@@ -149,18 +149,18 @@  discard block
 block discarded – undo
149 149
 	 *
150 150
 	 * @since 1.7
151 151
 	 */
152
-	do_action( 'give_donation_form_register_login_fields', $form_id );
152
+	do_action('give_donation_form_register_login_fields', $form_id);
153 153
 
154 154
 	$fields = ob_get_clean();
155 155
 
156
-	wp_send_json( array(
157
-		'fields' => wp_json_encode( $fields ),
158
-		'submit' => wp_json_encode( give_get_donation_form_submit_button( $form_id ) ),
159
-	) );
156
+	wp_send_json(array(
157
+		'fields' => wp_json_encode($fields),
158
+		'submit' => wp_json_encode(give_get_donation_form_submit_button($form_id)),
159
+	));
160 160
 }
161 161
 
162
-add_action( 'wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields' );
163
-add_action( 'wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields' );
162
+add_action('wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields');
163
+add_action('wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields');
164 164
 
165 165
 /**
166 166
  * Get Form Title via AJAX (used only in WordPress Admin)
@@ -170,9 +170,9 @@  discard block
 block discarded – undo
170 170
  * @return void
171 171
  */
172 172
 function give_ajax_get_form_title() {
173
-	if ( isset( $_POST['form_id'] ) ) {
174
-		$title = get_the_title( $_POST['form_id'] );
175
-		if ( $title ) {
173
+	if (isset($_POST['form_id'])) {
174
+		$title = get_the_title($_POST['form_id']);
175
+		if ($title) {
176 176
 			echo $title;
177 177
 		} else {
178 178
 			echo 'fail';
@@ -181,8 +181,8 @@  discard block
 block discarded – undo
181 181
 	give_die();
182 182
 }
183 183
 
184
-add_action( 'wp_ajax_give_get_form_title', 'give_ajax_get_form_title' );
185
-add_action( 'wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title' );
184
+add_action('wp_ajax_give_get_form_title', 'give_ajax_get_form_title');
185
+add_action('wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title');
186 186
 
187 187
 /**
188 188
  * Retrieve a states drop down
@@ -193,23 +193,23 @@  discard block
 block discarded – undo
193 193
  */
194 194
 function give_ajax_get_states_field() {
195 195
 
196
-	if ( empty( $_POST['country'] ) ) {
196
+	if (empty($_POST['country'])) {
197 197
 		$_POST['country'] = give_get_country();
198 198
 	}
199
-	$states = give_get_states( $_POST['country'] );
199
+	$states = give_get_states($_POST['country']);
200 200
 
201
-	if ( ! empty( $states ) ) {
201
+	if ( ! empty($states)) {
202 202
 
203 203
 		$args = array(
204 204
 			'name'             => $_POST['field_name'],
205 205
 			'id'               => $_POST['field_name'],
206
-			'class'            => $_POST['field_name'] . '  give-select',
207
-			'options'          => give_get_states( $_POST['country'] ),
206
+			'class'            => $_POST['field_name'].'  give-select',
207
+			'options'          => give_get_states($_POST['country']),
208 208
 			'show_option_all'  => false,
209 209
 			'show_option_none' => false,
210 210
 		);
211 211
 
212
-		$response = Give()->html->select( $args );
212
+		$response = Give()->html->select($args);
213 213
 
214 214
 	} else {
215 215
 
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 	give_die();
222 222
 }
223 223
 
224
-add_action( 'wp_ajax_give_get_states', 'give_ajax_get_states_field' );
225
-add_action( 'wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field' );
224
+add_action('wp_ajax_give_get_states', 'give_ajax_get_states_field');
225
+add_action('wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field');
226 226
 
227 227
 /**
228 228
  * Retrieve donation forms via AJAX for chosen dropdown search field.
@@ -234,19 +234,19 @@  discard block
 block discarded – undo
234 234
 function give_ajax_form_search() {
235 235
 	global $wpdb;
236 236
 
237
-	$search   = esc_sql( sanitize_text_field( $_GET['s'] ) );
238
-	$excludes = ( isset( $_GET['current_id'] ) ? (array) $_GET['current_id'] : array() );
237
+	$search   = esc_sql(sanitize_text_field($_GET['s']));
238
+	$excludes = (isset($_GET['current_id']) ? (array) $_GET['current_id'] : array());
239 239
 
240 240
 	$results = array();
241
-	if ( current_user_can( 'edit_give_forms' ) ) {
242
-		$items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50" );
241
+	if (current_user_can('edit_give_forms')) {
242
+		$items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50");
243 243
 	} else {
244
-		$items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50" );
244
+		$items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50");
245 245
 	}
246 246
 
247
-	if ( $items ) {
247
+	if ($items) {
248 248
 
249
-		foreach ( $items as $item ) {
249
+		foreach ($items as $item) {
250 250
 
251 251
 			$results[] = array(
252 252
 				'id'   => $item->ID,
@@ -257,18 +257,18 @@  discard block
 block discarded – undo
257 257
 
258 258
 		$items[] = array(
259 259
 			'id'   => 0,
260
-			'name' => __( 'No forms found.', 'give' ),
260
+			'name' => __('No forms found.', 'give'),
261 261
 		);
262 262
 
263 263
 	}
264 264
 
265
-	echo json_encode( $results );
265
+	echo json_encode($results);
266 266
 
267 267
 	give_die();
268 268
 }
269 269
 
270
-add_action( 'wp_ajax_give_form_search', 'give_ajax_form_search' );
271
-add_action( 'wp_ajax_nopriv_give_form_search', 'give_ajax_form_search' );
270
+add_action('wp_ajax_give_form_search', 'give_ajax_form_search');
271
+add_action('wp_ajax_nopriv_give_form_search', 'give_ajax_form_search');
272 272
 
273 273
 /**
274 274
  * Search the donors database via Ajax
@@ -280,38 +280,38 @@  discard block
 block discarded – undo
280 280
 function give_ajax_donor_search() {
281 281
 	global $wpdb;
282 282
 
283
-	$search  = esc_sql( sanitize_text_field( $_GET['s'] ) );
283
+	$search  = esc_sql(sanitize_text_field($_GET['s']));
284 284
 	$results = array();
285
-	if ( ! current_user_can( 'view_give_reports' ) ) {
285
+	if ( ! current_user_can('view_give_reports')) {
286 286
 		$donors = array();
287 287
 	} else {
288
-		$donors = $wpdb->get_results( "SELECT id,name,email FROM {$wpdb->prefix}give_customers WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50" );
288
+		$donors = $wpdb->get_results("SELECT id,name,email FROM {$wpdb->prefix}give_customers WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50");
289 289
 	}
290 290
 
291
-	if ( $donors ) {
291
+	if ($donors) {
292 292
 
293
-		foreach ( $donors as $donor ) {
293
+		foreach ($donors as $donor) {
294 294
 
295 295
 			$results[] = array(
296 296
 				'id'   => $donor->id,
297
-				'name' => $donor->name . ' (' . $donor->email . ')',
297
+				'name' => $donor->name.' ('.$donor->email.')',
298 298
 			);
299 299
 		}
300 300
 	} else {
301 301
 
302 302
 		$donors[] = array(
303 303
 			'id'   => 0,
304
-			'name' => __( 'No donors found.', 'give' ),
304
+			'name' => __('No donors found.', 'give'),
305 305
 		);
306 306
 
307 307
 	}
308 308
 
309
-	echo json_encode( $results );
309
+	echo json_encode($results);
310 310
 
311 311
 	give_die();
312 312
 }
313 313
 
314
-add_action( 'wp_ajax_give_donor_search', 'give_ajax_donor_search' );
314
+add_action('wp_ajax_give_donor_search', 'give_ajax_donor_search');
315 315
 
316 316
 
317 317
 /**
@@ -323,39 +323,39 @@  discard block
 block discarded – undo
323 323
  */
324 324
 function give_ajax_search_users() {
325 325
 
326
-	if ( current_user_can( 'manage_give_settings' ) ) {
326
+	if (current_user_can('manage_give_settings')) {
327 327
 
328
-		$search   = esc_sql( sanitize_text_field( $_GET['s'] ) );
328
+		$search = esc_sql(sanitize_text_field($_GET['s']));
329 329
 
330 330
 		$get_users_args = array(
331 331
 			'number' => 9999,
332
-			'search' => $search . '*',
332
+			'search' => $search.'*',
333 333
 		);
334 334
 
335
-		$get_users_args = apply_filters( 'give_search_users_args', $get_users_args );
335
+		$get_users_args = apply_filters('give_search_users_args', $get_users_args);
336 336
 
337
-		$found_users = apply_filters( 'give_ajax_found_users', get_users( $get_users_args ), $search );
337
+		$found_users = apply_filters('give_ajax_found_users', get_users($get_users_args), $search);
338 338
 		$results     = array();
339 339
 
340
-		if ( $found_users ) {
340
+		if ($found_users) {
341 341
 
342
-			foreach ( $found_users as $user ) {
342
+			foreach ($found_users as $user) {
343 343
 
344 344
 				$results[] = array(
345 345
 					'id'   => $user->ID,
346
-					'name' =>  esc_html( $user->user_login . ' (' . $user->user_email . ')' ),
346
+					'name' =>  esc_html($user->user_login.' ('.$user->user_email.')'),
347 347
 				);
348 348
 			}
349 349
 		} else {
350 350
 
351 351
 			$results[] = array(
352 352
 				'id'   => 0,
353
-				'name' => __( 'No users found.', 'give' ),
353
+				'name' => __('No users found.', 'give'),
354 354
 			);
355 355
 
356 356
 		}
357 357
 
358
-		echo json_encode( $results );
358
+		echo json_encode($results);
359 359
 
360 360
 	}// End if().
361 361
 
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 
364 364
 }
365 365
 
366
-add_action( 'wp_ajax_give_user_search', 'give_ajax_search_users' );
366
+add_action('wp_ajax_give_user_search', 'give_ajax_search_users');
367 367
 
368 368
 
369 369
 /**
@@ -375,32 +375,32 @@  discard block
 block discarded – undo
375 375
  */
376 376
 function give_check_for_form_price_variations() {
377 377
 
378
-	if ( ! current_user_can( 'edit_give_forms', get_current_user_id() ) ) {
379
-		die( '-1' );
378
+	if ( ! current_user_can('edit_give_forms', get_current_user_id())) {
379
+		die('-1');
380 380
 	}
381 381
 
382
-	$form_id = intval( $_POST['form_id'] );
383
-	$form    = get_post( $form_id );
382
+	$form_id = intval($_POST['form_id']);
383
+	$form    = get_post($form_id);
384 384
 
385
-	if ( 'give_forms' != $form->post_type ) {
386
-		die( '-2' );
385
+	if ('give_forms' != $form->post_type) {
386
+		die('-2');
387 387
 	}
388 388
 
389
-	if ( give_has_variable_prices( $form_id ) ) {
390
-		$variable_prices = give_get_variable_prices( $form_id );
389
+	if (give_has_variable_prices($form_id)) {
390
+		$variable_prices = give_get_variable_prices($form_id);
391 391
 
392
-		if ( $variable_prices ) {
392
+		if ($variable_prices) {
393 393
 			$ajax_response = '<select class="give_price_options_select give-select give-select" name="give_price_option">';
394 394
 
395
-			if ( isset( $_POST['all_prices'] ) ) {
396
-				$ajax_response .= '<option value="all">' . esc_html__( 'All Levels', 'give' ) . '</option>';
395
+			if (isset($_POST['all_prices'])) {
396
+				$ajax_response .= '<option value="all">'.esc_html__('All Levels', 'give').'</option>';
397 397
 			}
398 398
 
399
-			foreach ( $variable_prices as $key => $price ) {
399
+			foreach ($variable_prices as $key => $price) {
400 400
 
401
-				$level_text = ! empty( $price['_give_text'] ) ? esc_html( $price['_give_text'] ) : give_currency_filter( give_format_amount( $price['_give_amount'] ) );
401
+				$level_text = ! empty($price['_give_text']) ? esc_html($price['_give_text']) : give_currency_filter(give_format_amount($price['_give_amount']));
402 402
 
403
-				$ajax_response .= '<option value="' . esc_attr( $price['_give_id']['level_id'] ) . '">' . $level_text . '</option>';
403
+				$ajax_response .= '<option value="'.esc_attr($price['_give_id']['level_id']).'">'.$level_text.'</option>';
404 404
 			}
405 405
 			$ajax_response .= '</select>';
406 406
 			echo $ajax_response;
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 	give_die();
411 411
 }
412 412
 
413
-add_action( 'wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations' );
413
+add_action('wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations');
414 414
 
415 415
 
416 416
 /**
@@ -421,25 +421,25 @@  discard block
 block discarded – undo
421 421
  * @return void
422 422
  */
423 423
 function give_check_for_form_price_variations_html() {
424
-	if ( ! current_user_can( 'edit_give_payments', get_current_user_id() ) ) {
424
+	if ( ! current_user_can('edit_give_payments', get_current_user_id())) {
425 425
 		wp_die();
426 426
 	}
427 427
 
428
-	$form_id    = ! empty( $_POST['form_id'] ) ? intval( $_POST['form_id'] ) : 0;
429
-	$payment_id = ! empty( $_POST['payment_id'] ) ? intval( $_POST['payment_id'] ) : 0;
430
-	$form       = get_post( $form_id );
428
+	$form_id    = ! empty($_POST['form_id']) ? intval($_POST['form_id']) : 0;
429
+	$payment_id = ! empty($_POST['payment_id']) ? intval($_POST['payment_id']) : 0;
430
+	$form       = get_post($form_id);
431 431
 
432
-	if ( 'give_forms' != $form->post_type ) {
432
+	if ('give_forms' != $form->post_type) {
433 433
 		wp_die();
434 434
 	}
435 435
 
436
-	if ( ! give_has_variable_prices( $form_id ) || ! $form_id ) {
437
-		esc_html_e( 'n/a', 'give' );
436
+	if ( ! give_has_variable_prices($form_id) || ! $form_id) {
437
+		esc_html_e('n/a', 'give');
438 438
 	} else {
439 439
 		$prices_atts = '';
440
-		if ( $variable_prices = give_get_variable_prices( $form_id ) ) {
441
-			foreach ( $variable_prices as $variable_price ) {
442
-				$prices_atts[ $variable_price['_give_id']['level_id'] ] = give_format_amount( $variable_price['_give_amount'] );
440
+		if ($variable_prices = give_get_variable_prices($form_id)) {
441
+			foreach ($variable_prices as $variable_price) {
442
+				$prices_atts[$variable_price['_give_id']['level_id']] = give_format_amount($variable_price['_give_amount']);
443 443
 			}
444 444
 		}
445 445
 
@@ -450,12 +450,12 @@  discard block
 block discarded – undo
450 450
 			'chosen'           => true,
451 451
 			'show_option_all'  => '',
452 452
 			'show_option_none' => '',
453
-			'select_atts'      => 'data-prices=' . esc_attr( json_encode( $prices_atts ) ),
453
+			'select_atts'      => 'data-prices='.esc_attr(json_encode($prices_atts)),
454 454
 		);
455 455
 
456
-		if ( $payment_id ) {
456
+		if ($payment_id) {
457 457
 			// Payment object.
458
-			$payment = new Give_Payment( $payment_id );
458
+			$payment = new Give_Payment($payment_id);
459 459
 
460 460
 			// Payment meta.
461 461
 			$payment_meta                               = $payment->get_meta();
@@ -463,10 +463,10 @@  discard block
 block discarded – undo
463 463
 		}
464 464
 
465 465
 		// Render variable prices select tag html.
466
-		give_get_form_variable_price_dropdown( $variable_price_dropdown_option, true );
466
+		give_get_form_variable_price_dropdown($variable_price_dropdown_option, true);
467 467
 	}
468 468
 
469 469
 	give_die();
470 470
 }
471 471
 
472
-add_action( 'wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html' );
472
+add_action('wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html');
Please login to merge, or discard this patch.