Completed
Push — master ( c3016b...628e7f )
by Devin
86:23 queued 66:20
created
includes/misc-functions.php 1 patch
Spacing   +159 added lines, -159 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
 
@@ -24,9 +24,9 @@  discard block
 block discarded – undo
24 24
 function give_is_test_mode() {
25 25
 	global $give_options;
26 26
 
27
-	$ret = ! empty( $give_options['test_mode'] );
27
+	$ret = ! empty($give_options['test_mode']);
28 28
 
29
-	return (bool) apply_filters( 'give_is_test_mode', $ret );
29
+	return (bool) apply_filters('give_is_test_mode', $ret);
30 30
 }
31 31
 
32 32
 /**
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
37 37
  */
38 38
 function give_get_currency() {
39 39
 	global $give_options;
40
-	$currency = isset( $give_options['currency'] ) ? $give_options['currency'] : 'USD';
40
+	$currency = isset($give_options['currency']) ? $give_options['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
 	global $give_options;
54
-	$currency_pos = isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before';
54
+	$currency_pos = isset($give_options['currency_position']) ? $give_options['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
 
@@ -65,36 +65,36 @@  discard block
 block discarded – undo
65 65
  */
66 66
 function give_get_currencies() {
67 67
 	$currencies = array(
68
-		'USD'  => __( 'US Dollars ($)', 'give' ),
69
-		'EUR'  => __( 'Euros (€)', 'give' ),
70
-		'GBP'  => __( 'Pounds Sterling (£)', 'give' ),
71
-		'AUD'  => __( 'Australian Dollars ($)', 'give' ),
72
-		'BRL'  => __( 'Brazilian Real (R$)', 'give' ),
73
-		'CAD'  => __( 'Canadian Dollars ($)', 'give' ),
74
-		'CZK'  => __( 'Czech Koruna (Kč)', 'give' ),
75
-		'DKK'  => __( 'Danish Krone (kr)', 'give' ),
76
-		'HKD'  => __( 'Hong Kong Dollar ($)', 'give' ),
77
-		'HUF'  => __( 'Hungarian Forint (Ft)', 'give' ),
78
-		'ILS'  => __( 'Israeli Shekel (₪)', 'give' ),
79
-		'JPY'  => __( 'Japanese Yen (¥)', 'give' ),
80
-		'MYR'  => __( 'Malaysian Ringgits (RM)', 'give' ),
81
-		'MXN'  => __( 'Mexican Peso ($)', 'give' ),
82
-		'NZD'  => __( 'New Zealand Dollar ($)', 'give' ),
83
-		'NOK'  => __( 'Norwegian Krone (Kr.)', 'give' ),
84
-		'PHP'  => __( 'Philippine Pesos (₱)', 'give' ),
85
-		'PLN'  => __( 'Polish Zloty (zł)', 'give' ),
86
-		'SGD'  => __( 'Singapore Dollar ($)', 'give' ),
87
-		'SEK'  => __( 'Swedish Krona (kr)', 'give' ),
88
-		'CHF'  => __( 'Swiss Franc (CHF)', 'give' ),
89
-		'TWD'  => __( 'Taiwan New Dollars (NT$)', 'give' ),
90
-		'THB'  => __( 'Thai Baht (฿)', 'give' ),
91
-		'INR'  => __( 'Indian Rupee (₹)', 'give' ),
92
-		'TRY'  => __( 'Turkish Lira (₺)', 'give' ),
93
-		'RIAL' => __( 'Iranian Rial (﷼)', 'give' ),
94
-		'RUB'  => __( 'Russian Rubles (руб)', 'give' )
68
+		'USD'  => __('US Dollars ($)', 'give'),
69
+		'EUR'  => __('Euros (€)', 'give'),
70
+		'GBP'  => __('Pounds Sterling (£)', 'give'),
71
+		'AUD'  => __('Australian Dollars ($)', 'give'),
72
+		'BRL'  => __('Brazilian Real (R$)', 'give'),
73
+		'CAD'  => __('Canadian Dollars ($)', 'give'),
74
+		'CZK'  => __('Czech Koruna (Kč)', 'give'),
75
+		'DKK'  => __('Danish Krone (kr)', 'give'),
76
+		'HKD'  => __('Hong Kong Dollar ($)', 'give'),
77
+		'HUF'  => __('Hungarian Forint (Ft)', 'give'),
78
+		'ILS'  => __('Israeli Shekel (₪)', 'give'),
79
+		'JPY'  => __('Japanese Yen (¥)', 'give'),
80
+		'MYR'  => __('Malaysian Ringgits (RM)', 'give'),
81
+		'MXN'  => __('Mexican Peso ($)', 'give'),
82
+		'NZD'  => __('New Zealand Dollar ($)', 'give'),
83
+		'NOK'  => __('Norwegian Krone (Kr.)', 'give'),
84
+		'PHP'  => __('Philippine Pesos (₱)', 'give'),
85
+		'PLN'  => __('Polish Zloty (zł)', 'give'),
86
+		'SGD'  => __('Singapore Dollar ($)', 'give'),
87
+		'SEK'  => __('Swedish Krona (kr)', 'give'),
88
+		'CHF'  => __('Swiss Franc (CHF)', 'give'),
89
+		'TWD'  => __('Taiwan New Dollars (NT$)', 'give'),
90
+		'THB'  => __('Thai Baht (฿)', 'give'),
91
+		'INR'  => __('Indian Rupee (₹)', 'give'),
92
+		'TRY'  => __('Turkish Lira (₺)', 'give'),
93
+		'RIAL' => __('Iranian Rial (﷼)', 'give'),
94
+		'RUB'  => __('Russian Rubles (руб)', 'give')
95 95
 	);
96 96
 
97
-	return apply_filters( 'give_currencies', $currencies );
97
+	return apply_filters('give_currencies', $currencies);
98 98
 }
99 99
 
100 100
 
@@ -109,12 +109,12 @@  discard block
 block discarded – undo
109 109
  *
110 110
  * @return string           The symbol to use for the currency
111 111
  */
112
-function give_currency_symbol( $currency = '' ) {
112
+function give_currency_symbol($currency = '') {
113 113
 
114
-	if ( empty( $currency ) ) {
114
+	if (empty($currency)) {
115 115
 		$currency = give_get_currency();
116 116
 	}
117
-	switch ( $currency ) :
117
+	switch ($currency) :
118 118
 		case 'GBP' :
119 119
 			$symbol = '£';
120 120
 			break;
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 			break;
184 184
 	endswitch;
185 185
 
186
-	return apply_filters( 'give_currency_symbol', $symbol, $currency );
186
+	return apply_filters('give_currency_symbol', $symbol, $currency);
187 187
 }
188 188
 
189 189
 
@@ -195,13 +195,13 @@  discard block
 block discarded – undo
195 195
  */
196 196
 function give_get_current_page_url() {
197 197
 
198
-	if ( is_front_page() ) {
199
-		$current_url = home_url( '/' );
198
+	if (is_front_page()) {
199
+		$current_url = home_url('/');
200 200
 	} else {
201
-		$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
201
+		$current_url = (is_ssl() ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
202 202
 	}
203 203
 
204
-	return apply_filters( 'give_get_current_page_url', esc_url( $current_url ) );
204
+	return apply_filters('give_get_current_page_url', esc_url($current_url));
205 205
 }
206 206
 
207 207
 
@@ -222,15 +222,15 @@  discard block
 block discarded – undo
222 222
 	 */
223 223
 	$gateways = give_get_enabled_payment_gateways();
224 224
 
225
-	if ( count( $gateways ) == 1 && ! isset( $gateways['paypal'] ) && ! isset( $gateways['manual'] ) ) {
225
+	if (count($gateways) == 1 && ! isset($gateways['paypal']) && ! isset($gateways['manual'])) {
226 226
 		$ret = true;
227
-	} else if ( count( $gateways ) == 1 ) {
227
+	} else if (count($gateways) == 1) {
228 228
 		$ret = false;
229
-	} else if ( count( $gateways ) == 2 && isset( $gateways['paypal'] ) && isset( $gateways['manual'] ) ) {
229
+	} else if (count($gateways) == 2 && isset($gateways['paypal']) && isset($gateways['manual'])) {
230 230
 		$ret = false;
231 231
 	}
232 232
 
233
-	return (bool) apply_filters( 'give_verify_credit_cards', $ret );
233
+	return (bool) apply_filters('give_verify_credit_cards', $ret);
234 234
 }
235 235
 
236 236
 /**
@@ -242,26 +242,26 @@  discard block
 block discarded – undo
242 242
 function give_get_timezone_id() {
243 243
 
244 244
 	// if site timezone string exists, return it
245
-	if ( $timezone = get_option( 'timezone_string' ) ) {
245
+	if ($timezone = get_option('timezone_string')) {
246 246
 		return $timezone;
247 247
 	}
248 248
 
249 249
 	// get UTC offset, if it isn't set return UTC
250
-	if ( ! ( $utc_offset = 3600 * get_option( 'gmt_offset', 0 ) ) ) {
250
+	if ( ! ($utc_offset = 3600 * get_option('gmt_offset', 0))) {
251 251
 		return 'UTC';
252 252
 	}
253 253
 
254 254
 	// attempt to guess the timezone string from the UTC offset
255
-	$timezone = timezone_name_from_abbr( '', $utc_offset );
255
+	$timezone = timezone_name_from_abbr('', $utc_offset);
256 256
 
257 257
 	// last try, guess timezone string manually
258
-	if ( $timezone === false ) {
258
+	if ($timezone === false) {
259 259
 
260
-		$is_dst = date( 'I' );
260
+		$is_dst = date('I');
261 261
 
262
-		foreach ( timezone_abbreviations_list() as $abbr ) {
263
-			foreach ( $abbr as $city ) {
264
-				if ( $city['dst'] == $is_dst && $city['offset'] == $utc_offset ) {
262
+		foreach (timezone_abbreviations_list() as $abbr) {
263
+			foreach ($abbr as $city) {
264
+				if ($city['dst'] == $is_dst && $city['offset'] == $utc_offset) {
265 265
 					return $city['timezone_id'];
266 266
 				}
267 267
 			}
@@ -285,17 +285,17 @@  discard block
 block discarded – undo
285 285
 
286 286
 	$ip = '127.0.0.1';
287 287
 
288
-	if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
288
+	if ( ! empty($_SERVER['HTTP_CLIENT_IP'])) {
289 289
 		//check ip from share internet
290 290
 		$ip = $_SERVER['HTTP_CLIENT_IP'];
291
-	} elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
291
+	} elseif ( ! empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
292 292
 		//to check ip is pass from proxy
293 293
 		$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
294
-	} elseif ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) {
294
+	} elseif ( ! empty($_SERVER['REMOTE_ADDR'])) {
295 295
 		$ip = $_SERVER['REMOTE_ADDR'];
296 296
 	}
297 297
 
298
-	return apply_filters( 'give_get_ip', $ip );
298
+	return apply_filters('give_get_ip', $ip);
299 299
 }
300 300
 
301 301
 
@@ -310,9 +310,9 @@  discard block
 block discarded – undo
310 310
  *
311 311
  * @uses  Give()->session->set()
312 312
  */
313
-function give_set_purchase_session( $purchase_data = array() ) {
314
-	Give()->session->set( 'give_purchase', $purchase_data );
315
-	Give()->session->set( 'give_email', $purchase_data['user_email'] );
313
+function give_set_purchase_session($purchase_data = array()) {
314
+	Give()->session->set('give_purchase', $purchase_data);
315
+	Give()->session->set('give_email', $purchase_data['user_email']);
316 316
 }
317 317
 
318 318
 /**
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
  * @return mixed array | false
327 327
  */
328 328
 function give_get_purchase_session() {
329
-	return Give()->session->get( 'give_purchase' );
329
+	return Give()->session->get('give_purchase');
330 330
 }
331 331
 
332 332
 /**
@@ -341,14 +341,14 @@  discard block
 block discarded – undo
341 341
  *
342 342
  * @return string
343 343
  */
344
-function give_get_purchase_summary( $purchase_data, $email = true ) {
344
+function give_get_purchase_summary($purchase_data, $email = true) {
345 345
 	$summary = '';
346 346
 
347
-	if ( $email ) {
348
-		$summary .= $purchase_data['user_email'] . ' - ';
347
+	if ($email) {
348
+		$summary .= $purchase_data['user_email'].' - ';
349 349
 	}
350 350
 
351
-	$summary .= get_the_title( $purchase_data['post_data']['give-form-id'] );
351
+	$summary .= get_the_title($purchase_data['post_data']['give-form-id']);
352 352
 
353 353
 	return $summary;
354 354
 }
@@ -365,31 +365,31 @@  discard block
 block discarded – undo
365 365
 function give_get_host() {
366 366
 	$host = false;
367 367
 
368
-	if ( defined( 'WPE_APIKEY' ) ) {
368
+	if (defined('WPE_APIKEY')) {
369 369
 		$host = 'WP Engine';
370
-	} elseif ( defined( 'PAGELYBIN' ) ) {
370
+	} elseif (defined('PAGELYBIN')) {
371 371
 		$host = 'Pagely';
372
-	} elseif ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) {
372
+	} elseif (DB_HOST == 'localhost:/tmp/mysql5.sock') {
373 373
 		$host = 'ICDSoft';
374
-	} elseif ( DB_HOST == 'mysqlv5' ) {
374
+	} elseif (DB_HOST == 'mysqlv5') {
375 375
 		$host = 'NetworkSolutions';
376
-	} elseif ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) {
376
+	} elseif (strpos(DB_HOST, 'ipagemysql.com') !== false) {
377 377
 		$host = 'iPage';
378
-	} elseif ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) {
378
+	} elseif (strpos(DB_HOST, 'ipowermysql.com') !== false) {
379 379
 		$host = 'IPower';
380
-	} elseif ( strpos( DB_HOST, '.gridserver.com' ) !== false ) {
380
+	} elseif (strpos(DB_HOST, '.gridserver.com') !== false) {
381 381
 		$host = 'MediaTemple Grid';
382
-	} elseif ( strpos( DB_HOST, '.pair.com' ) !== false ) {
382
+	} elseif (strpos(DB_HOST, '.pair.com') !== false) {
383 383
 		$host = 'pair Networks';
384
-	} elseif ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) {
384
+	} elseif (strpos(DB_HOST, '.stabletransit.com') !== false) {
385 385
 		$host = 'Rackspace Cloud';
386
-	} elseif ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) {
386
+	} elseif (strpos(DB_HOST, '.sysfix.eu') !== false) {
387 387
 		$host = 'SysFix.eu Power Hosting';
388
-	} elseif ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) {
388
+	} elseif (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) {
389 389
 		$host = 'Flywheel';
390 390
 	} else {
391 391
 		// Adding a general fallback for data gathering
392
-		$host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME'];
392
+		$host = 'DBH: '.DB_HOST.', SRV: '.$_SERVER['SERVER_NAME'];
393 393
 	}
394 394
 
395 395
 	return $host;
@@ -405,67 +405,67 @@  discard block
 block discarded – undo
405 405
  *
406 406
  * @return bool true if host matches, false if not
407 407
  */
408
-function give_is_host( $host = false ) {
408
+function give_is_host($host = false) {
409 409
 
410 410
 	$return = false;
411 411
 
412
-	if ( $host ) {
413
-		$host = str_replace( ' ', '', strtolower( $host ) );
412
+	if ($host) {
413
+		$host = str_replace(' ', '', strtolower($host));
414 414
 
415
-		switch ( $host ) {
415
+		switch ($host) {
416 416
 			case 'wpengine':
417
-				if ( defined( 'WPE_APIKEY' ) ) {
417
+				if (defined('WPE_APIKEY')) {
418 418
 					$return = true;
419 419
 				}
420 420
 				break;
421 421
 			case 'pagely':
422
-				if ( defined( 'PAGELYBIN' ) ) {
422
+				if (defined('PAGELYBIN')) {
423 423
 					$return = true;
424 424
 				}
425 425
 				break;
426 426
 			case 'icdsoft':
427
-				if ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) {
427
+				if (DB_HOST == 'localhost:/tmp/mysql5.sock') {
428 428
 					$return = true;
429 429
 				}
430 430
 				break;
431 431
 			case 'networksolutions':
432
-				if ( DB_HOST == 'mysqlv5' ) {
432
+				if (DB_HOST == 'mysqlv5') {
433 433
 					$return = true;
434 434
 				}
435 435
 				break;
436 436
 			case 'ipage':
437
-				if ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) {
437
+				if (strpos(DB_HOST, 'ipagemysql.com') !== false) {
438 438
 					$return = true;
439 439
 				}
440 440
 				break;
441 441
 			case 'ipower':
442
-				if ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) {
442
+				if (strpos(DB_HOST, 'ipowermysql.com') !== false) {
443 443
 					$return = true;
444 444
 				}
445 445
 				break;
446 446
 			case 'mediatemplegrid':
447
-				if ( strpos( DB_HOST, '.gridserver.com' ) !== false ) {
447
+				if (strpos(DB_HOST, '.gridserver.com') !== false) {
448 448
 					$return = true;
449 449
 				}
450 450
 				break;
451 451
 			case 'pairnetworks':
452
-				if ( strpos( DB_HOST, '.pair.com' ) !== false ) {
452
+				if (strpos(DB_HOST, '.pair.com') !== false) {
453 453
 					$return = true;
454 454
 				}
455 455
 				break;
456 456
 			case 'rackspacecloud':
457
-				if ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) {
457
+				if (strpos(DB_HOST, '.stabletransit.com') !== false) {
458 458
 					$return = true;
459 459
 				}
460 460
 				break;
461 461
 			case 'sysfix.eu':
462 462
 			case 'sysfix.eupowerhosting':
463
-				if ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) {
463
+				if (strpos(DB_HOST, '.sysfix.eu') !== false) {
464 464
 					$return = true;
465 465
 				}
466 466
 				break;
467 467
 			case 'flywheel':
468
-				if ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) {
468
+				if (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) {
469 469
 					$return = true;
470 470
 				}
471 471
 				break;
@@ -498,20 +498,20 @@  discard block
 block discarded – undo
498 498
  * @param string $replacement Optional. The function that should have been called
499 499
  * @param array $backtrace Optional. Contains stack backtrace of deprecated function
500 500
  */
501
-function _give_deprecated_function( $function, $version, $replacement = null, $backtrace = null ) {
502
-	do_action( 'give_deprecated_function_run', $function, $replacement, $version );
501
+function _give_deprecated_function($function, $version, $replacement = null, $backtrace = null) {
502
+	do_action('give_deprecated_function_run', $function, $replacement, $version);
503 503
 
504
-	$show_errors = current_user_can( 'manage_options' );
504
+	$show_errors = current_user_can('manage_options');
505 505
 
506 506
 	// Allow plugin to filter the output error trigger
507
-	if ( WP_DEBUG && apply_filters( 'give_deprecated_function_trigger_error', $show_errors ) ) {
508
-		if ( ! is_null( $replacement ) ) {
509
-			trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give' ), $function, $version, $replacement ) );
510
-			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.
507
+	if (WP_DEBUG && apply_filters('give_deprecated_function_trigger_error', $show_errors)) {
508
+		if ( ! is_null($replacement)) {
509
+			trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give'), $function, $version, $replacement));
510
+			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.
511 511
 			// Alternatively we could dump this to a file.
512 512
 		} else {
513
-			trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give' ), $function, $version ) );
514
-			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.
513
+			trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give'), $function, $version));
514
+			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.
515 515
 			// Alternatively we could dump this to a file.
516 516
 		}
517 517
 	}
@@ -525,8 +525,8 @@  discard block
 block discarded – undo
525 525
  * @return string $post_id
526 526
  */
527 527
 function give_get_admin_post_id() {
528
-	$post_id = isset( $_GET['post'] ) ? $_GET['post'] : null;
529
-	if ( ! $post_id && isset( $_POST['post_id'] ) ) {
528
+	$post_id = isset($_GET['post']) ? $_GET['post'] : null;
529
+	if ( ! $post_id && isset($_POST['post_id'])) {
530 530
 		$post_id = $_POST['post_id'];
531 531
 	}
532 532
 
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
  * @return string Arg separator output
541 541
  */
542 542
 function give_get_php_arg_separator_output() {
543
-	return ini_get( 'arg_separator.output' );
543
+	return ini_get('arg_separator.output');
544 544
 }
545 545
 
546 546
 
@@ -555,10 +555,10 @@  discard block
 block discarded – undo
555 555
  *
556 556
  * @return string Short month name
557 557
  */
558
-function give_month_num_to_name( $n ) {
559
-	$timestamp = mktime( 0, 0, 0, $n, 1, 2005 );
558
+function give_month_num_to_name($n) {
559
+	$timestamp = mktime(0, 0, 0, $n, 1, 2005);
560 560
 
561
-	return date_i18n( "M", $timestamp );
561
+	return date_i18n("M", $timestamp);
562 562
 }
563 563
 
564 564
 
@@ -571,10 +571,10 @@  discard block
 block discarded – undo
571 571
  *
572 572
  * @return bool Whether or not function is disabled.
573 573
  */
574
-function give_is_func_disabled( $function ) {
575
-	$disabled = explode( ',', ini_get( 'disable_functions' ) );
574
+function give_is_func_disabled($function) {
575
+	$disabled = explode(',', ini_get('disable_functions'));
576 576
 
577
-	return in_array( $function, $disabled );
577
+	return in_array($function, $disabled);
578 578
 }
579 579
 
580 580
 
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
 
590 590
 		<form action="//givewp.us3.list-manage.com/subscribe/post?u=3ccb75d68bda4381e2f45794c&amp;id=12a081aa13" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
591 591
 			<div class="give-newsletter-confirmation">
592
-				<p><?php _e( 'Thanks for Subscribing!', 'give' ); ?> :)</p>
592
+				<p><?php _e('Thanks for Subscribing!', 'give'); ?> :)</p>
593 593
 			</div>
594 594
 
595 595
 			<table class="form-table give-newsletter-form">
@@ -685,7 +685,7 @@  discard block
 block discarded – undo
685 685
  *
686 686
  * @return mixed
687 687
  */
688
-function give_svg_icons( $icon ) {
688
+function give_svg_icons($icon) {
689 689
 
690 690
 	// Store your SVGs in an associative array
691 691
 	$svgs = array(
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
 	);
698 698
 
699 699
 	// Return the chosen icon's SVG string
700
-	return $svgs[ $icon ];
700
+	return $svgs[$icon];
701 701
 }
702 702
 
703 703
 /**
@@ -709,15 +709,15 @@  discard block
 block discarded – undo
709 709
  *
710 710
  * @return mixed
711 711
  */
712
-function modify_nav_menu_meta_box_object( $post_type ) {
713
-	if ( isset( $post_type->name ) && $post_type->name == 'give_forms' ) {
712
+function modify_nav_menu_meta_box_object($post_type) {
713
+	if (isset($post_type->name) && $post_type->name == 'give_forms') {
714 714
 		$post_type->labels->name = 'Donation Forms';
715 715
 	}
716 716
 
717 717
 	return $post_type;
718 718
 }
719 719
 
720
-add_filter( 'nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object' );
720
+add_filter('nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object');
721 721
 
722 722
 
723 723
 /**
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
  * @license    http://opensource.org/licenses/MIT MIT
731 731
  */
732 732
 
733
-if ( ! function_exists( 'array_column' ) ) {
733
+if ( ! function_exists('array_column')) {
734 734
 	/**
735 735
 	 * Returns the values from a single column of the input array, identified by
736 736
 	 * the $columnKey.
@@ -749,56 +749,56 @@  discard block
 block discarded – undo
749 749
 	 *
750 750
 	 * @return array
751 751
 	 */
752
-	function array_column( $input = null, $columnKey = null, $indexKey = null ) {
752
+	function array_column($input = null, $columnKey = null, $indexKey = null) {
753 753
 		// Using func_get_args() in order to check for proper number of
754 754
 		// parameters and trigger errors exactly as the built-in array_column()
755 755
 		// does in PHP 5.5.
756 756
 		$argc   = func_num_args();
757 757
 		$params = func_get_args();
758 758
 
759
-		if ( $argc < 2 ) {
760
-			trigger_error( "array_column() expects at least 2 parameters, {$argc} given", E_USER_WARNING );
759
+		if ($argc < 2) {
760
+			trigger_error("array_column() expects at least 2 parameters, {$argc} given", E_USER_WARNING);
761 761
 
762 762
 			return null;
763 763
 		}
764 764
 
765
-		if ( ! is_array( $params[0] ) ) {
765
+		if ( ! is_array($params[0])) {
766 766
 			trigger_error(
767
-				'array_column() expects parameter 1 to be array, ' . gettype( $params[0] ) . ' given',
767
+				'array_column() expects parameter 1 to be array, '.gettype($params[0]).' given',
768 768
 				E_USER_WARNING
769 769
 			);
770 770
 
771 771
 			return null;
772 772
 		}
773 773
 
774
-		if ( ! is_int( $params[1] )
775
-		     && ! is_float( $params[1] )
776
-		     && ! is_string( $params[1] )
774
+		if ( ! is_int($params[1])
775
+		     && ! is_float($params[1])
776
+		     && ! is_string($params[1])
777 777
 		     && $params[1] !== null
778
-		     && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) )
778
+		     && ! (is_object($params[1]) && method_exists($params[1], '__toString'))
779 779
 		) {
780
-			trigger_error( 'array_column(): The column key should be either a string or an integer', E_USER_WARNING );
780
+			trigger_error('array_column(): The column key should be either a string or an integer', E_USER_WARNING);
781 781
 
782 782
 			return false;
783 783
 		}
784 784
 
785
-		if ( isset( $params[2] )
786
-		     && ! is_int( $params[2] )
787
-		     && ! is_float( $params[2] )
788
-		     && ! is_string( $params[2] )
789
-		     && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) )
785
+		if (isset($params[2])
786
+		     && ! is_int($params[2])
787
+		     && ! is_float($params[2])
788
+		     && ! is_string($params[2])
789
+		     && ! (is_object($params[2]) && method_exists($params[2], '__toString'))
790 790
 		) {
791
-			trigger_error( 'array_column(): The index key should be either a string or an integer', E_USER_WARNING );
791
+			trigger_error('array_column(): The index key should be either a string or an integer', E_USER_WARNING);
792 792
 
793 793
 			return false;
794 794
 		}
795 795
 
796 796
 		$paramsInput     = $params[0];
797
-		$paramsColumnKey = ( $params[1] !== null ) ? (string) $params[1] : null;
797
+		$paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null;
798 798
 
799 799
 		$paramsIndexKey = null;
800
-		if ( isset( $params[2] ) ) {
801
-			if ( is_float( $params[2] ) || is_int( $params[2] ) ) {
800
+		if (isset($params[2])) {
801
+			if (is_float($params[2]) || is_int($params[2])) {
802 802
 				$paramsIndexKey = (int) $params[2];
803 803
 			} else {
804 804
 				$paramsIndexKey = (string) $params[2];
@@ -807,26 +807,26 @@  discard block
 block discarded – undo
807 807
 
808 808
 		$resultArray = array();
809 809
 
810
-		foreach ( $paramsInput as $row ) {
810
+		foreach ($paramsInput as $row) {
811 811
 			$key    = $value = null;
812 812
 			$keySet = $valueSet = false;
813 813
 
814
-			if ( $paramsIndexKey !== null && array_key_exists( $paramsIndexKey, $row ) ) {
814
+			if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) {
815 815
 				$keySet = true;
816
-				$key    = (string) $row[ $paramsIndexKey ];
816
+				$key    = (string) $row[$paramsIndexKey];
817 817
 			}
818 818
 
819
-			if ( $paramsColumnKey === null ) {
819
+			if ($paramsColumnKey === null) {
820 820
 				$valueSet = true;
821 821
 				$value    = $row;
822
-			} elseif ( is_array( $row ) && array_key_exists( $paramsColumnKey, $row ) ) {
822
+			} elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) {
823 823
 				$valueSet = true;
824
-				$value    = $row[ $paramsColumnKey ];
824
+				$value    = $row[$paramsColumnKey];
825 825
 			}
826 826
 
827
-			if ( $valueSet ) {
828
-				if ( $keySet ) {
829
-					$resultArray[ $key ] = $value;
827
+			if ($valueSet) {
828
+				if ($keySet) {
829
+					$resultArray[$key] = $value;
830 830
 				} else {
831 831
 					$resultArray[] = $value;
832 832
 				}
@@ -848,39 +848,39 @@  discard block
 block discarded – undo
848 848
  *
849 849
  * @return bool Whether the receipt is visible or not.
850 850
  */
851
-function give_can_view_receipt( $payment_key = '' ) {
851
+function give_can_view_receipt($payment_key = '') {
852 852
 
853 853
 	$return = false;
854 854
 
855
-	if ( empty( $payment_key ) ) {
855
+	if (empty($payment_key)) {
856 856
 		return $return;
857 857
 	}
858 858
 
859 859
 	global $give_receipt_args;
860 860
 
861
-	$give_receipt_args['id'] = give_get_purchase_id_by_key( $payment_key );
861
+	$give_receipt_args['id'] = give_get_purchase_id_by_key($payment_key);
862 862
 
863
-	$user_id = (int) give_get_payment_user_id( $give_receipt_args['id'] );
863
+	$user_id = (int) give_get_payment_user_id($give_receipt_args['id']);
864 864
 
865
-	$payment_meta = give_get_payment_meta( $give_receipt_args['id'] );
865
+	$payment_meta = give_get_payment_meta($give_receipt_args['id']);
866 866
 
867
-	if ( is_user_logged_in() ) {
868
-		if ( $user_id === (int) get_current_user_id() ) {
867
+	if (is_user_logged_in()) {
868
+		if ($user_id === (int) get_current_user_id()) {
869 869
 			$return = true;
870
-		} elseif ( wp_get_current_user()->user_email === give_get_payment_user_email( $give_receipt_args['id'] ) ) {
870
+		} elseif (wp_get_current_user()->user_email === give_get_payment_user_email($give_receipt_args['id'])) {
871 871
 			$return = true;
872
-		} elseif ( current_user_can( 'view_give_sensitive_data' ) ) {
872
+		} elseif (current_user_can('view_give_sensitive_data')) {
873 873
 			$return = true;
874 874
 		}
875 875
 	}
876 876
 
877 877
 	$session = give_get_purchase_session();
878
-	if ( ! empty( $session ) && ! is_user_logged_in() ) {
879
-		if ( $session['purchase_key'] === $payment_meta['key'] ) {
878
+	if ( ! empty($session) && ! is_user_logged_in()) {
879
+		if ($session['purchase_key'] === $payment_meta['key']) {
880 880
 			$return = true;
881 881
 		}
882 882
 	}
883 883
 
884
-	return (bool) apply_filters( 'give_can_view_receipt', $return, $payment_key );
884
+	return (bool) apply_filters('give_can_view_receipt', $return, $payment_key);
885 885
 
886 886
 }
887 887
\ No newline at end of file
Please login to merge, or discard this patch.
includes/shortcodes.php 1 patch
Spacing   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -25,28 +25,28 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function give_donation_history() {
27 27
 
28
-	$email_access = give_get_option( 'email_access' );
28
+	$email_access = give_get_option('email_access');
29 29
 
30 30
 	//Is user logged in? Does a session exist? Does an email-access token exist?
31
-	if ( is_user_logged_in() || Give()->session->get_session_expiration() || ( $email_access == 'on' && Give()->email_access->token_exists ) ) {
31
+	if (is_user_logged_in() || Give()->session->get_session_expiration() || ($email_access == 'on' && Give()->email_access->token_exists)) {
32 32
 		ob_start();
33
-		give_get_template_part( 'history', 'donations' );
33
+		give_get_template_part('history', 'donations');
34 34
 
35 35
 		return ob_get_clean();
36 36
 	} //Is Email-based access enabled?
37
-	elseif ( $email_access == 'on' ) {
37
+	elseif ($email_access == 'on') {
38 38
 
39 39
 		ob_start();
40
-		give_get_template_part( 'email', 'login-form' );
40
+		give_get_template_part('email', 'login-form');
41 41
 
42 42
 		return ob_get_clean();
43 43
 	} else {
44
-		$message = __( 'You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give' );
45
-		echo apply_filters( 'give_donation_history_nonuser_message', give_output_error( $message, false ), $message );
44
+		$message = __('You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give');
45
+		echo apply_filters('give_donation_history_nonuser_message', give_output_error($message, false), $message);
46 46
 	}
47 47
 }
48 48
 
49
-add_shortcode( 'donation_history', 'give_donation_history' );
49
+add_shortcode('donation_history', 'give_donation_history');
50 50
 
51 51
 /**
52 52
  * Donation Form Shortcode
@@ -60,53 +60,53 @@  discard block
 block discarded – undo
60 60
  *
61 61
  * @return string
62 62
  */
63
-function give_form_shortcode( $atts, $content = null ) {
64
-	$atts = shortcode_atts( array(
63
+function give_form_shortcode($atts, $content = null) {
64
+	$atts = shortcode_atts(array(
65 65
 		'id'            => '',
66 66
 		'show_title'    => true,
67 67
 		'show_goal'     => true,
68 68
 		'show_content'  => '',
69 69
 		'float_labels'  => '',
70 70
 		'display_style' => '',
71
-	), $atts, 'give_form' );
71
+	), $atts, 'give_form');
72 72
 
73
-	foreach ( $atts as $key => $value ) {
73
+	foreach ($atts as $key => $value) {
74 74
 		//convert shortcode_atts values to booleans
75
-		if ( $key == 'show_title' ) {
76
-			$atts[ $key ] = filter_var( $atts[ $key ], FILTER_VALIDATE_BOOLEAN );
77
-		} elseif ( $key == 'show_goal' ) {
78
-			$atts[ $key ] = filter_var( $atts[ $key ], FILTER_VALIDATE_BOOLEAN );
75
+		if ($key == 'show_title') {
76
+			$atts[$key] = filter_var($atts[$key], FILTER_VALIDATE_BOOLEAN);
77
+		} elseif ($key == 'show_goal') {
78
+			$atts[$key] = filter_var($atts[$key], FILTER_VALIDATE_BOOLEAN);
79 79
 		}
80 80
 
81 81
 		//validate show_content value
82
-		if ( $key == 'show_content' ) {
83
-			if ( ! in_array( $value, array( 'none', 'above', 'below' ) ) ) {
84
-				$atts[ $key ] = '';
85
-			} else if ( $value == 'above' ) {
86
-				$atts[ $key ] = 'give_pre_form';
87
-			} else if ( $value == 'below' ) {
88
-				$atts[ $key ] = 'give_post_form';
82
+		if ($key == 'show_content') {
83
+			if ( ! in_array($value, array('none', 'above', 'below'))) {
84
+				$atts[$key] = '';
85
+			} else if ($value == 'above') {
86
+				$atts[$key] = 'give_pre_form';
87
+			} else if ($value == 'below') {
88
+				$atts[$key] = 'give_post_form';
89 89
 			}
90 90
 		}
91 91
 
92 92
 		//validate display_style and float_labels value
93
-		if ( ( $key == 'display_style' && ! in_array( $value, array( 'onpage', 'reveal', 'modal' ) ) )
94
-		     || ( $key == 'float_labels' && ! in_array( $value, array( 'enabled', 'disabled' ) ) )
93
+		if (($key == 'display_style' && ! in_array($value, array('onpage', 'reveal', 'modal')))
94
+		     || ($key == 'float_labels' && ! in_array($value, array('enabled', 'disabled')))
95 95
 		) {
96 96
 
97
-			$atts[ $key ] = '';
97
+			$atts[$key] = '';
98 98
 		}
99 99
 	}
100 100
 
101 101
 	//get the Give Form
102 102
 	ob_start();
103
-	give_get_donation_form( $atts );
103
+	give_get_donation_form($atts);
104 104
 	$final_output = ob_get_clean();
105 105
 
106
-	return apply_filters( 'give_donate_form', $final_output, $atts );
106
+	return apply_filters('give_donate_form', $final_output, $atts);
107 107
 }
108 108
 
109
-add_shortcode( 'give_form', 'give_form_shortcode' );
109
+add_shortcode('give_form', 'give_form_shortcode');
110 110
 
111 111
 /**
112 112
  * Donation Form Goal Shortcode
@@ -120,37 +120,37 @@  discard block
 block discarded – undo
120 120
  *
121 121
  * @return string
122 122
  */
123
-function give_goal_shortcode( $atts, $content = null ) {
124
-	$atts = shortcode_atts( array(
123
+function give_goal_shortcode($atts, $content = null) {
124
+	$atts = shortcode_atts(array(
125 125
 		'id'        => '',
126 126
 		'show_text' => true,
127 127
 		'show_bar'  => true,
128
-	), $atts, 'give_goal' );
128
+	), $atts, 'give_goal');
129 129
 
130 130
 
131 131
 	//get the Give Form
132 132
 	ob_start();
133 133
 
134 134
 	//Sanity check 1: ensure there is an ID Provided
135
-	if ( empty( $atts['id'] ) ) {
136
-		give_output_error( __( 'Error: No Donation form ID for the shortcode provided.', 'give' ), true );
135
+	if (empty($atts['id'])) {
136
+		give_output_error(__('Error: No Donation form ID for the shortcode provided.', 'give'), true);
137 137
 	}
138 138
 
139 139
 	//Sanity check 2: Check that this form even has Goals enabled
140
-	$goal_option = get_post_meta( $atts['id'], '_give_goal_option', true );
141
-	if ( empty( $goal_option ) || $goal_option !== 'yes' ) {
142
-		give_output_error( __( 'Error: This form does not have Goals enabled.', 'give' ), true );
140
+	$goal_option = get_post_meta($atts['id'], '_give_goal_option', true);
141
+	if (empty($goal_option) || $goal_option !== 'yes') {
142
+		give_output_error(__('Error: This form does not have Goals enabled.', 'give'), true);
143 143
 	} else {
144 144
 		//Passed all sanity checks: output Goal
145
-		give_show_goal_progress( $atts['id'], $atts );
145
+		give_show_goal_progress($atts['id'], $atts);
146 146
 	}
147 147
 
148 148
 	$final_output = ob_get_clean();
149 149
 
150
-	return apply_filters( 'give_goal_shortcode_output', $final_output, $atts );
150
+	return apply_filters('give_goal_shortcode_output', $final_output, $atts);
151 151
 }
152 152
 
153
-add_shortcode( 'give_goal', 'give_goal_shortcode' );
153
+add_shortcode('give_goal', 'give_goal_shortcode');
154 154
 
155 155
 
156 156
 /**
@@ -167,15 +167,15 @@  discard block
 block discarded – undo
167 167
  * @uses  give_login_form()
168 168
  * @return string
169 169
  */
170
-function give_login_form_shortcode( $atts, $content = null ) {
171
-	$atts = shortcode_atts( array(
170
+function give_login_form_shortcode($atts, $content = null) {
171
+	$atts = shortcode_atts(array(
172 172
 		'redirect' => '',
173
-	), $atts, 'give_login' );
173
+	), $atts, 'give_login');
174 174
 
175
-	return give_login_form( $atts['redirect'] );
175
+	return give_login_form($atts['redirect']);
176 176
 }
177 177
 
178
-add_shortcode( 'give_login', 'give_login_form_shortcode' );
178
+add_shortcode('give_login', 'give_login_form_shortcode');
179 179
 
180 180
 /**
181 181
  * Register Shortcode
@@ -190,15 +190,15 @@  discard block
 block discarded – undo
190 190
  * @uses  give_register_form()
191 191
  * @return string
192 192
  */
193
-function give_register_form_shortcode( $atts, $content = null ) {
194
-	$atts = shortcode_atts( array(
193
+function give_register_form_shortcode($atts, $content = null) {
194
+	$atts = shortcode_atts(array(
195 195
 		'redirect' => '',
196
-	), $atts, 'give_register' );
196
+	), $atts, 'give_register');
197 197
 
198
-	return give_register_form( $atts['redirect'] );
198
+	return give_register_form($atts['redirect']);
199 199
 }
200 200
 
201
-add_shortcode( 'give_register', 'give_register_form_shortcode' );
201
+add_shortcode('give_register', 'give_register_form_shortcode');
202 202
 
203 203
 
204 204
 /**
@@ -213,61 +213,61 @@  discard block
 block discarded – undo
213 213
  *
214 214
  * @return string
215 215
  */
216
-function give_receipt_shortcode( $atts, $content = null ) {
216
+function give_receipt_shortcode($atts, $content = null) {
217 217
 
218 218
 	global $give_receipt_args, $payment;
219 219
 
220
-	$give_receipt_args = shortcode_atts( array(
221
-		'error'          => esc_html__( 'Sorry, you are missing the payment key to view this donation receipt.', 'give' ),
220
+	$give_receipt_args = shortcode_atts(array(
221
+		'error'          => esc_html__('Sorry, you are missing the payment key to view this donation receipt.', 'give'),
222 222
 		'price'          => true,
223 223
 		'date'           => true,
224 224
 		'payment_key'    => false,
225 225
 		'payment_method' => true,
226 226
 		'payment_id'     => true
227
-	), $atts, 'give_receipt' );
227
+	), $atts, 'give_receipt');
228 228
 
229 229
 	//set $session var
230 230
 	$session = give_get_purchase_session();
231 231
 
232 232
 	//set payment key var
233
-	if ( isset( $_GET['payment_key'] ) ) {
234
-		$payment_key = urldecode( $_GET['payment_key'] );
235
-	} elseif ( $session ) {
233
+	if (isset($_GET['payment_key'])) {
234
+		$payment_key = urldecode($_GET['payment_key']);
235
+	} elseif ($session) {
236 236
 		$payment_key = $session['purchase_key'];
237
-	} elseif ( $give_receipt_args['payment_key'] ) {
237
+	} elseif ($give_receipt_args['payment_key']) {
238 238
 		$payment_key = $give_receipt_args['payment_key'];
239 239
 	}
240 240
 
241
-	$email_access = give_get_option( 'email_access' );
241
+	$email_access = give_get_option('email_access');
242 242
 
243 243
 	// No payment_key found & Email Access is Turned on:
244
-	if ( ! isset( $payment_key ) && $email_access == 'on' && ! Give()->email_access->token_exists ) {
244
+	if ( ! isset($payment_key) && $email_access == 'on' && ! Give()->email_access->token_exists) {
245 245
 
246 246
 		ob_start();
247 247
 
248
-		give_get_template_part( 'email-login-form' );
248
+		give_get_template_part('email-login-form');
249 249
 
250 250
 		return ob_get_clean();
251 251
 
252
-	} elseif ( ! isset( $payment_key ) ) {
252
+	} elseif ( ! isset($payment_key)) {
253 253
 
254
-		return give_output_error( $give_receipt_args['error'], false, 'error' );
254
+		return give_output_error($give_receipt_args['error'], false, 'error');
255 255
 
256 256
 	}
257 257
 
258
-	$payment_id    = give_get_purchase_id_by_key( $payment_key );
259
-	$user_can_view = give_can_view_receipt( $payment_key );
258
+	$payment_id    = give_get_purchase_id_by_key($payment_key);
259
+	$user_can_view = give_can_view_receipt($payment_key);
260 260
 
261 261
 	// Key was provided, but user is logged out. Offer them the ability to login and view the receipt
262
-	if ( ! $user_can_view && $email_access == 'on' && ! Give()->email_access->token_exists ) {
262
+	if ( ! $user_can_view && $email_access == 'on' && ! Give()->email_access->token_exists) {
263 263
 
264 264
 		ob_start();
265 265
 
266
-		give_get_template_part( 'email-login-form' );
266
+		give_get_template_part('email-login-form');
267 267
 
268 268
 		return ob_get_clean();
269 269
 
270
-	} elseif ( ! $user_can_view ) {
270
+	} elseif ( ! $user_can_view) {
271 271
 
272 272
 		global $give_login_redirect;
273 273
 
@@ -275,9 +275,9 @@  discard block
 block discarded – undo
275 275
 
276 276
 		ob_start();
277 277
 
278
-		give_output_error( apply_filters( 'give_must_be_logged_in_error_message', esc_html__( 'You must be logged in to view this donation payment receipt.', 'give' ) ) );
278
+		give_output_error(apply_filters('give_must_be_logged_in_error_message', esc_html__('You must be logged in to view this donation payment receipt.', 'give')));
279 279
 
280
-		give_get_template_part( 'shortcode', 'login' );
280
+		give_get_template_part('shortcode', 'login');
281 281
 
282 282
 		$login_form = ob_get_clean();
283 283
 
@@ -294,13 +294,13 @@  discard block
 block discarded – undo
294 294
 	 * Or if user is logged in and the user can view sensitive shop data
295 295
 	 *
296 296
 	 */
297
-	if ( ! apply_filters( 'give_user_can_view_receipt', $user_can_view, $give_receipt_args ) ) {
298
-		return give_output_error( $give_receipt_args['error'], false, 'error' );
297
+	if ( ! apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) {
298
+		return give_output_error($give_receipt_args['error'], false, 'error');
299 299
 	}
300 300
 
301 301
 	ob_start();
302 302
 
303
-	give_get_template_part( 'shortcode', 'receipt' );
303
+	give_get_template_part('shortcode', 'receipt');
304 304
 
305 305
 	$display = ob_get_clean();
306 306
 
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 
310 310
 }
311 311
 
312
-add_shortcode( 'give_receipt', 'give_receipt_shortcode' );
312
+add_shortcode('give_receipt', 'give_receipt_shortcode');
313 313
 
314 314
 /**
315 315
  * Profile Editor Shortcode
@@ -329,18 +329,18 @@  discard block
 block discarded – undo
329 329
  *
330 330
  * @return string Output generated from the profile editor
331 331
  */
332
-function give_profile_editor_shortcode( $atts, $content = null ) {
332
+function give_profile_editor_shortcode($atts, $content = null) {
333 333
 
334 334
 	ob_start();
335 335
 
336
-	give_get_template_part( 'shortcode', 'profile-editor' );
336
+	give_get_template_part('shortcode', 'profile-editor');
337 337
 
338 338
 	$display = ob_get_clean();
339 339
 
340 340
 	return $display;
341 341
 }
342 342
 
343
-add_shortcode( 'give_profile_editor', 'give_profile_editor_shortcode' );
343
+add_shortcode('give_profile_editor', 'give_profile_editor_shortcode');
344 344
 
345 345
 /**
346 346
  * Process Profile Updater Form
@@ -353,30 +353,30 @@  discard block
 block discarded – undo
353 353
  *
354 354
  * @return false
355 355
  */
356
-function give_process_profile_editor_updates( $data ) {
356
+function give_process_profile_editor_updates($data) {
357 357
 	// Profile field change request
358
-	if ( empty( $_POST['give_profile_editor_submit'] ) && ! is_user_logged_in() ) {
358
+	if (empty($_POST['give_profile_editor_submit']) && ! is_user_logged_in()) {
359 359
 		return false;
360 360
 	}
361 361
 
362 362
 	// Nonce security
363
-	if ( ! wp_verify_nonce( $data['give_profile_editor_nonce'], 'give-profile-editor-nonce' ) ) {
363
+	if ( ! wp_verify_nonce($data['give_profile_editor_nonce'], 'give-profile-editor-nonce')) {
364 364
 		return false;
365 365
 	}
366 366
 
367 367
 	$user_id       = get_current_user_id();
368
-	$old_user_data = get_userdata( $user_id );
369
-
370
-	$display_name = isset( $data['give_display_name'] ) ? sanitize_text_field( $data['give_display_name'] ) : $old_user_data->display_name;
371
-	$first_name   = isset( $data['give_first_name'] ) ? sanitize_text_field( $data['give_first_name'] ) : $old_user_data->first_name;
372
-	$last_name    = isset( $data['give_last_name'] ) ? sanitize_text_field( $data['give_last_name'] ) : $old_user_data->last_name;
373
-	$email        = isset( $data['give_email'] ) ? sanitize_email( $data['give_email'] ) : $old_user_data->user_email;
374
-	$line1        = ( isset( $data['give_address_line1'] ) ? sanitize_text_field( $data['give_address_line1'] ) : '' );
375
-	$line2        = ( isset( $data['give_address_line2'] ) ? sanitize_text_field( $data['give_address_line2'] ) : '' );
376
-	$city         = ( isset( $data['give_address_city'] ) ? sanitize_text_field( $data['give_address_city'] ) : '' );
377
-	$state        = ( isset( $data['give_address_state'] ) ? sanitize_text_field( $data['give_address_state'] ) : '' );
378
-	$zip          = ( isset( $data['give_address_zip'] ) ? sanitize_text_field( $data['give_address_zip'] ) : '' );
379
-	$country      = ( isset( $data['give_address_country'] ) ? sanitize_text_field( $data['give_address_country'] ) : '' );
368
+	$old_user_data = get_userdata($user_id);
369
+
370
+	$display_name = isset($data['give_display_name']) ? sanitize_text_field($data['give_display_name']) : $old_user_data->display_name;
371
+	$first_name   = isset($data['give_first_name']) ? sanitize_text_field($data['give_first_name']) : $old_user_data->first_name;
372
+	$last_name    = isset($data['give_last_name']) ? sanitize_text_field($data['give_last_name']) : $old_user_data->last_name;
373
+	$email        = isset($data['give_email']) ? sanitize_email($data['give_email']) : $old_user_data->user_email;
374
+	$line1        = (isset($data['give_address_line1']) ? sanitize_text_field($data['give_address_line1']) : '');
375
+	$line2        = (isset($data['give_address_line2']) ? sanitize_text_field($data['give_address_line2']) : '');
376
+	$city         = (isset($data['give_address_city']) ? sanitize_text_field($data['give_address_city']) : '');
377
+	$state        = (isset($data['give_address_state']) ? sanitize_text_field($data['give_address_state']) : '');
378
+	$zip          = (isset($data['give_address_zip']) ? sanitize_text_field($data['give_address_zip']) : '');
379
+	$country      = (isset($data['give_address_country']) ? sanitize_text_field($data['give_address_country']) : '');
380 380
 
381 381
 	$userdata = array(
382 382
 		'ID'           => $user_id,
@@ -396,45 +396,45 @@  discard block
 block discarded – undo
396 396
 		'country' => $country
397 397
 	);
398 398
 
399
-	do_action( 'give_pre_update_user_profile', $user_id, $userdata );
399
+	do_action('give_pre_update_user_profile', $user_id, $userdata);
400 400
 
401 401
 	// New password
402
-	if ( ! empty( $data['give_new_user_pass1'] ) ) {
403
-		if ( $data['give_new_user_pass1'] !== $data['give_new_user_pass2'] ) {
404
-			give_set_error( 'password_mismatch', __( 'The passwords you entered do not match. Please try again.', 'give' ) );
402
+	if ( ! empty($data['give_new_user_pass1'])) {
403
+		if ($data['give_new_user_pass1'] !== $data['give_new_user_pass2']) {
404
+			give_set_error('password_mismatch', __('The passwords you entered do not match. Please try again.', 'give'));
405 405
 		} else {
406 406
 			$userdata['user_pass'] = $data['give_new_user_pass1'];
407 407
 		}
408 408
 	}
409 409
 
410 410
 	// Make sure the new email doesn't belong to another user
411
-	if ( $email != $old_user_data->user_email ) {
412
-		if ( email_exists( $email ) ) {
413
-			give_set_error( 'email_exists', __( 'The email you entered belongs to another user. Please use another.', 'give' ) );
411
+	if ($email != $old_user_data->user_email) {
412
+		if (email_exists($email)) {
413
+			give_set_error('email_exists', __('The email you entered belongs to another user. Please use another.', 'give'));
414 414
 		}
415 415
 	}
416 416
 
417 417
 	// Check for errors
418 418
 	$errors = give_get_errors();
419 419
 
420
-	if ( $errors ) {
420
+	if ($errors) {
421 421
 		// Send back to the profile editor if there are errors
422
-		wp_redirect( $data['give_redirect'] );
422
+		wp_redirect($data['give_redirect']);
423 423
 		give_die();
424 424
 	}
425 425
 
426 426
 	// Update the user
427
-	$meta    = update_user_meta( $user_id, '_give_user_address', $address );
428
-	$updated = wp_update_user( $userdata );
427
+	$meta    = update_user_meta($user_id, '_give_user_address', $address);
428
+	$updated = wp_update_user($userdata);
429 429
 
430
-	if ( $updated ) {
431
-		do_action( 'give_user_profile_updated', $user_id, $userdata );
432
-		wp_redirect( add_query_arg( 'updated', 'true', $data['give_redirect'] ) );
430
+	if ($updated) {
431
+		do_action('give_user_profile_updated', $user_id, $userdata);
432
+		wp_redirect(add_query_arg('updated', 'true', $data['give_redirect']));
433 433
 		give_die();
434 434
 	}
435 435
 
436 436
 	return false;
437 437
 }
438 438
 
439
-add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' );
439
+add_action('give_edit_user_profile', 'give_process_profile_editor_updates');
440 440
 
Please login to merge, or discard this patch.