Completed
Pull Request — master (#782)
by
unknown
20:41
created
includes/emails/class-give-email-tags.php 1 patch
Spacing   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  */
24 24
 
25 25
 // Exit if accessed directly
26
-if ( ! defined( 'ABSPATH' ) ) {
26
+if ( ! defined('ABSPATH')) {
27 27
 	exit;
28 28
 }
29 29
 
@@ -54,9 +54,9 @@  discard block
 block discarded – undo
54 54
 	 * @param string $tag Email tag to be replace in email
55 55
 	 * @param callable $func Hook to run when email tag is found
56 56
 	 */
57
-	public function add( $tag, $description, $func ) {
58
-		if ( is_callable( $func ) ) {
59
-			$this->tags[ $tag ] = array(
57
+	public function add($tag, $description, $func) {
58
+		if (is_callable($func)) {
59
+			$this->tags[$tag] = array(
60 60
 				'tag'         => $tag,
61 61
 				'description' => $description,
62 62
 				'func'        => $func
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
 	 *
72 72
 	 * @param string $tag Email tag to remove hook from
73 73
 	 */
74
-	public function remove( $tag ) {
75
-		unset( $this->tags[ $tag ] );
74
+	public function remove($tag) {
75
+		unset($this->tags[$tag]);
76 76
 	}
77 77
 
78 78
 	/**
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
 	 *
85 85
 	 * @return bool
86 86
 	 */
87
-	public function email_tag_exists( $tag ) {
88
-		return array_key_exists( $tag, $this->tags );
87
+	public function email_tag_exists($tag) {
88
+		return array_key_exists($tag, $this->tags);
89 89
 	}
90 90
 
91 91
 	/**
@@ -109,16 +109,16 @@  discard block
 block discarded – undo
109 109
 	 *
110 110
 	 * @return string Content with email tags filtered out.
111 111
 	 */
112
-	public function do_tags( $content, $payment_id ) {
112
+	public function do_tags($content, $payment_id) {
113 113
 
114 114
 		// Check if there is atleast one tag added
115
-		if ( empty( $this->tags ) || ! is_array( $this->tags ) ) {
115
+		if (empty($this->tags) || ! is_array($this->tags)) {
116 116
 			return $content;
117 117
 		}
118 118
 
119 119
 		$this->payment_id = $payment_id;
120 120
 
121
-		$new_content = preg_replace_callback( "/{([A-z0-9\-\_]+)}/s", array( $this, 'do_tag' ), $content );
121
+		$new_content = preg_replace_callback("/{([A-z0-9\-\_]+)}/s", array($this, 'do_tag'), $content);
122 122
 
123 123
 		$this->payment_id = null;
124 124
 
@@ -134,17 +134,17 @@  discard block
 block discarded – undo
134 134
 	 *
135 135
 	 * @return mixed
136 136
 	 */
137
-	public function do_tag( $m ) {
137
+	public function do_tag($m) {
138 138
 
139 139
 		// Get tag
140 140
 		$tag = $m[1];
141 141
 
142 142
 		// Return tag if tag not set
143
-		if ( ! $this->email_tag_exists( $tag ) ) {
143
+		if ( ! $this->email_tag_exists($tag)) {
144 144
 			return $m[0];
145 145
 		}
146 146
 
147
-		return call_user_func( $this->tags[ $tag ]['func'], $this->payment_id, $tag );
147
+		return call_user_func($this->tags[$tag]['func'], $this->payment_id, $tag);
148 148
 	}
149 149
 
150 150
 }
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
  * @param string $description Description of the email tag added
159 159
  * @param callable $func Hook to run when email tag is found
160 160
  */
161
-function give_add_email_tag( $tag, $description, $func ) {
162
-	Give()->email_tags->add( $tag, $description, $func );
161
+function give_add_email_tag($tag, $description, $func) {
162
+	Give()->email_tags->add($tag, $description, $func);
163 163
 }
164 164
 
165 165
 /**
@@ -169,8 +169,8 @@  discard block
 block discarded – undo
169 169
  *
170 170
  * @param string $tag Email tag to remove hook from
171 171
  */
172
-function give_remove_email_tag( $tag ) {
173
-	Give()->email_tags->remove( $tag );
172
+function give_remove_email_tag($tag) {
173
+	Give()->email_tags->remove($tag);
174 174
 }
175 175
 
176 176
 /**
@@ -182,8 +182,8 @@  discard block
 block discarded – undo
182 182
  *
183 183
  * @return bool
184 184
  */
185
-function give_email_tag_exists( $tag ) {
186
-	return Give()->email_tags->email_tag_exists( $tag );
185
+function give_email_tag_exists($tag) {
186
+	return Give()->email_tags->email_tag_exists($tag);
187 187
 }
188 188
 
189 189
 /**
@@ -212,13 +212,13 @@  discard block
 block discarded – undo
212 212
 	$email_tags = give_get_email_tags();
213 213
 
214 214
 	// Check
215
-	if ( count( $email_tags ) > 0 ) {
215
+	if (count($email_tags) > 0) {
216 216
 
217 217
 		// Loop
218
-		foreach ( $email_tags as $email_tag ) {
218
+		foreach ($email_tags as $email_tag) {
219 219
 
220 220
 			// Add email tag to list
221
-			$list .= '<code>{' . $email_tag['tag'] . '}</code> - ' . $email_tag['description'] . '<br/>';
221
+			$list .= '<code>{'.$email_tag['tag'].'}</code> - '.$email_tag['description'].'<br/>';
222 222
 
223 223
 		}
224 224
 
@@ -238,13 +238,13 @@  discard block
 block discarded – undo
238 238
  *
239 239
  * @return string Content with email tags filtered out.
240 240
  */
241
-function give_do_email_tags( $content, $payment_id ) {
241
+function give_do_email_tags($content, $payment_id) {
242 242
 
243 243
 	// Replace all tags
244
-	$content = Give()->email_tags->do_tags( $content, $payment_id );
244
+	$content = Give()->email_tags->do_tags($content, $payment_id);
245 245
 
246 246
 	// Maintaining backwards compatibility
247
-	$content = apply_filters( 'give_email_template_tags', $content, give_get_payment_meta( $payment_id ), $payment_id );
247
+	$content = apply_filters('give_email_template_tags', $content, give_get_payment_meta($payment_id), $payment_id);
248 248
 
249 249
 	// Return content
250 250
 	return $content;
@@ -256,10 +256,10 @@  discard block
 block discarded – undo
256 256
  * @since 1.0
257 257
  */
258 258
 function give_load_email_tags() {
259
-	do_action( 'give_add_email_tags' );
259
+	do_action('give_add_email_tags');
260 260
 }
261 261
 
262
-add_action( 'init', 'give_load_email_tags', - 999 );
262
+add_action('init', 'give_load_email_tags', - 999);
263 263
 
264 264
 /**
265 265
  * Add default Give email template tags
@@ -272,82 +272,82 @@  discard block
 block discarded – undo
272 272
 	$email_tags = array(
273 273
 		array(
274 274
 			'tag'         => 'donation',
275
-			'description' => esc_html__( 'The name of completed donation form and the donation level chosen if applicable.', 'give' ),
275
+			'description' => esc_html__('The name of completed donation form and the donation level chosen if applicable.', 'give'),
276 276
 			'function'    => 'give_email_tag_donation'
277 277
 		),
278 278
 		array(
279 279
 			'tag'         => 'name',
280
-			'description' => esc_html__( 'The donor\'s first name.', 'give' ),
280
+			'description' => esc_html__('The donor\'s first name.', 'give'),
281 281
 			'function'    => 'give_email_tag_first_name'
282 282
 		),
283 283
 		array(
284 284
 			'tag'         => 'fullname',
285
-			'description' => esc_html__( 'The donor\'s full name, first and last.', 'give' ),
285
+			'description' => esc_html__('The donor\'s full name, first and last.', 'give'),
286 286
 			'function'    => 'give_email_tag_fullname'
287 287
 		),
288 288
 		array(
289 289
 			'tag'         => 'username',
290
-			'description' => esc_html__( 'The donor\'s user name on the site, if they registered an account.', 'give' ),
290
+			'description' => esc_html__('The donor\'s user name on the site, if they registered an account.', 'give'),
291 291
 			'function'    => 'give_email_tag_username'
292 292
 		),
293 293
 		array(
294 294
 			'tag'         => 'user_email',
295
-			'description' => esc_html__( 'The donor\'s email address.', 'give' ),
295
+			'description' => esc_html__('The donor\'s email address.', 'give'),
296 296
 			'function'    => 'give_email_tag_user_email'
297 297
 		),
298 298
 		array(
299 299
 			'tag'         => 'billing_address',
300
-			'description' => esc_html__( 'The donor\'s billing address.', 'give' ),
300
+			'description' => esc_html__('The donor\'s billing address.', 'give'),
301 301
 			'function'    => 'give_email_tag_billing_address'
302 302
 		),
303 303
 		array(
304 304
 			'tag'         => 'date',
305
-			'description' => esc_html__( 'The date of the donation.', 'give' ),
305
+			'description' => esc_html__('The date of the donation.', 'give'),
306 306
 			'function'    => 'give_email_tag_date'
307 307
 		),
308 308
 		array(
309 309
 			'tag'         => 'price',
310
-			'description' => esc_html__( 'The total price of the donation.', 'give' ),
310
+			'description' => esc_html__('The total price of the donation.', 'give'),
311 311
 			'function'    => 'give_email_tag_price'
312 312
 		),
313 313
 		array(
314 314
 			'tag'         => 'payment_id',
315
-			'description' => esc_html__( 'The unique ID number for this donation.', 'give' ),
315
+			'description' => esc_html__('The unique ID number for this donation.', 'give'),
316 316
 			'function'    => 'give_email_tag_payment_id'
317 317
 		),
318 318
 		array(
319 319
 			'tag'         => 'receipt_id',
320
-			'description' => esc_html__( 'The unique ID number for this donation receipt.', 'give' ),
320
+			'description' => esc_html__('The unique ID number for this donation receipt.', 'give'),
321 321
 			'function'    => 'give_email_tag_receipt_id'
322 322
 		),
323 323
 		array(
324 324
 			'tag'         => 'payment_method',
325
-			'description' => esc_html__( 'The method of payment used for this donation.', 'give' ),
325
+			'description' => esc_html__('The method of payment used for this donation.', 'give'),
326 326
 			'function'    => 'give_email_tag_payment_method'
327 327
 		),
328 328
 		array(
329 329
 			'tag'         => 'sitename',
330
-			'description' => esc_html__( 'Your site name', 'give' ),
330
+			'description' => esc_html__('Your site name', 'give'),
331 331
 			'function'    => 'give_email_tag_sitename'
332 332
 		),
333 333
 		array(
334 334
 			'tag'         => 'receipt_link',
335
-			'description' => esc_html__( 'Adds a link so users can view their receipt directly on your website if they are unable to view it in the browser correctly.', 'give' ),
335
+			'description' => esc_html__('Adds a link so users can view their receipt directly on your website if they are unable to view it in the browser correctly.', 'give'),
336 336
 			'function'    => 'give_email_tag_receipt_link'
337 337
 		),
338 338
 	);
339 339
 
340 340
 	// Apply give_email_tags filter
341
-	$email_tags = apply_filters( 'give_email_tags', $email_tags );
341
+	$email_tags = apply_filters('give_email_tags', $email_tags);
342 342
 
343 343
 	// Add email tags
344
-	foreach ( $email_tags as $email_tag ) {
345
-		give_add_email_tag( $email_tag['tag'], $email_tag['description'], $email_tag['function'] );
344
+	foreach ($email_tags as $email_tag) {
345
+		give_add_email_tag($email_tag['tag'], $email_tag['description'], $email_tag['function']);
346 346
 	}
347 347
 
348 348
 }
349 349
 
350
-add_action( 'give_add_email_tags', 'give_setup_email_tags' );
350
+add_action('give_add_email_tags', 'give_setup_email_tags');
351 351
 
352 352
 
353 353
 /**
@@ -358,15 +358,15 @@  discard block
 block discarded – undo
358 358
  *
359 359
  * @return string name
360 360
  */
361
-function give_email_tag_first_name( $payment_id ) {
362
-	$payment   = new Give_Payment( $payment_id );
361
+function give_email_tag_first_name($payment_id) {
362
+	$payment   = new Give_Payment($payment_id);
363 363
 	$user_info = $payment->user_info;
364 364
 
365
-	if ( empty( $user_info ) ) {
365
+	if (empty($user_info)) {
366 366
 		return '';
367 367
 	}
368 368
 
369
-	$email_name = give_get_email_names( $user_info );
369
+	$email_name = give_get_email_names($user_info);
370 370
 
371 371
 	return $email_name['name'];
372 372
 }
@@ -379,15 +379,15 @@  discard block
 block discarded – undo
379 379
  *
380 380
  * @return string fullname
381 381
  */
382
-function give_email_tag_fullname( $payment_id ) {
383
-	$payment   = new Give_Payment( $payment_id );
382
+function give_email_tag_fullname($payment_id) {
383
+	$payment   = new Give_Payment($payment_id);
384 384
 	$user_info = $payment->user_info;
385 385
 
386
-	if ( empty( $user_info ) ) {
386
+	if (empty($user_info)) {
387 387
 		return '';
388 388
 	}
389 389
 
390
-	$email_name = give_get_email_names( $user_info );
390
+	$email_name = give_get_email_names($user_info);
391 391
 
392 392
 	return $email_name['fullname'];
393 393
 }
@@ -400,15 +400,15 @@  discard block
 block discarded – undo
400 400
  *
401 401
  * @return string username
402 402
  */
403
-function give_email_tag_username( $payment_id ) {
404
-	$payment   = new Give_Payment( $payment_id );
403
+function give_email_tag_username($payment_id) {
404
+	$payment   = new Give_Payment($payment_id);
405 405
 	$user_info = $payment->user_info;
406 406
 
407
-	if ( empty( $user_info ) ) {
407
+	if (empty($user_info)) {
408 408
 		return '';
409 409
 	}
410 410
 
411
-	$email_name = give_get_email_names( $user_info );
411
+	$email_name = give_get_email_names($user_info);
412 412
 
413 413
 	return $email_name['username'];
414 414
 }
@@ -421,8 +421,8 @@  discard block
 block discarded – undo
421 421
  *
422 422
  * @return string user_email
423 423
  */
424
-function give_email_tag_user_email( $payment_id ) {
425
-	$payment = new Give_Payment( $payment_id );
424
+function give_email_tag_user_email($payment_id) {
425
+	$payment = new Give_Payment($payment_id);
426 426
 
427 427
 	return $payment->email;
428 428
 }
@@ -435,10 +435,10 @@  discard block
 block discarded – undo
435 435
  *
436 436
  * @return string billing_address
437 437
  */
438
-function give_email_tag_billing_address( $payment_id ) {
438
+function give_email_tag_billing_address($payment_id) {
439 439
 
440
-	$user_info    = give_get_payment_meta_user_info( $payment_id );
441
-	$user_address = ! empty( $user_info['address'] ) ? $user_info['address'] : array(
440
+	$user_info    = give_get_payment_meta_user_info($payment_id);
441
+	$user_address = ! empty($user_info['address']) ? $user_info['address'] : array(
442 442
 		'line1'   => '',
443 443
 		'line2'   => '',
444 444
 		'city'    => '',
@@ -447,11 +447,11 @@  discard block
 block discarded – undo
447 447
 		'zip'     => ''
448 448
 	);
449 449
 
450
-	$return = $user_address['line1'] . "\n";
451
-	if ( ! empty( $user_address['line2'] ) ) {
452
-		$return .= $user_address['line2'] . "\n";
450
+	$return = $user_address['line1']."\n";
451
+	if ( ! empty($user_address['line2'])) {
452
+		$return .= $user_address['line2']."\n";
453 453
 	}
454
-	$return .= $user_address['city'] . ' ' . $user_address['zip'] . ' ' . $user_address['state'] . "\n";
454
+	$return .= $user_address['city'].' '.$user_address['zip'].' '.$user_address['state']."\n";
455 455
 	$return .= $user_address['country'];
456 456
 
457 457
 	return $return;
@@ -465,10 +465,10 @@  discard block
 block discarded – undo
465 465
  *
466 466
  * @return string date
467 467
  */
468
-function give_email_tag_date( $payment_id ) {
469
-	$payment = new Give_Payment( $payment_id );
468
+function give_email_tag_date($payment_id) {
469
+	$payment = new Give_Payment($payment_id);
470 470
 
471
-	return date_i18n( get_option( 'date_format' ), strtotime( $payment->date ) );
471
+	return date_i18n(get_option('date_format'), strtotime($payment->date));
472 472
 }
473 473
 
474 474
 /**
@@ -479,11 +479,11 @@  discard block
 block discarded – undo
479 479
  *
480 480
  * @return string price
481 481
  */
482
-function give_email_tag_price( $payment_id ) {
483
-	$payment = new Give_Payment( $payment_id );
484
-	$price   = give_currency_filter( give_format_amount( $payment->total ), $payment->currency );
482
+function give_email_tag_price($payment_id) {
483
+	$payment = new Give_Payment($payment_id);
484
+	$price   = give_currency_filter(give_format_amount($payment->total), $payment->currency);
485 485
 
486
-	return html_entity_decode( $price, ENT_COMPAT, 'UTF-8' );
486
+	return html_entity_decode($price, ENT_COMPAT, 'UTF-8');
487 487
 }
488 488
 
489 489
 /**
@@ -494,8 +494,8 @@  discard block
 block discarded – undo
494 494
  *
495 495
  * @return int payment_id
496 496
  */
497
-function give_email_tag_payment_id( $payment_id ) {
498
-	$payment = new Give_Payment( $payment_id );
497
+function give_email_tag_payment_id($payment_id) {
498
+	$payment = new Give_Payment($payment_id);
499 499
 
500 500
 	return $payment->number;
501 501
 }
@@ -508,8 +508,8 @@  discard block
 block discarded – undo
508 508
  *
509 509
  * @return string receipt_id
510 510
  */
511
-function give_email_tag_receipt_id( $payment_id ) {
512
-	$payment = new Give_Payment( $payment_id );
511
+function give_email_tag_receipt_id($payment_id) {
512
+	$payment = new Give_Payment($payment_id);
513 513
 
514 514
 	return $payment->key;
515 515
 }
@@ -523,11 +523,11 @@  discard block
 block discarded – undo
523 523
  *
524 524
  * @return string $form_title
525 525
  */
526
-function give_email_tag_donation( $payment_id ) {
527
-	$payment    = new Give_Payment( $payment_id );
528
-	$form_title = strip_tags( give_get_payment_form_title( $payment->meta, false, '-' ) );
526
+function give_email_tag_donation($payment_id) {
527
+	$payment    = new Give_Payment($payment_id);
528
+	$form_title = strip_tags(give_get_payment_form_title($payment->meta, false, '-'));
529 529
 
530
-	return ! empty( $form_title ) ? $form_title : esc_html__( 'There was an error retrieving this donation title.', 'give' );
530
+	return ! empty($form_title) ? $form_title : esc_html__('There was an error retrieving this donation title.', 'give');
531 531
 
532 532
 }
533 533
 
@@ -539,10 +539,10 @@  discard block
 block discarded – undo
539 539
  *
540 540
  * @return string gateway
541 541
  */
542
-function give_email_tag_payment_method( $payment_id ) {
543
-	$payment = new Give_Payment( $payment_id );
542
+function give_email_tag_payment_method($payment_id) {
543
+	$payment = new Give_Payment($payment_id);
544 544
 
545
-	return give_get_gateway_checkout_label( $payment->gateway );
545
+	return give_get_gateway_checkout_label($payment->gateway);
546 546
 }
547 547
 
548 548
 /**
@@ -553,8 +553,8 @@  discard block
 block discarded – undo
553 553
  *
554 554
  * @return string sitename
555 555
  */
556
-function give_email_tag_sitename( $payment_id ) {
557
-	return wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES );
556
+function give_email_tag_sitename($payment_id) {
557
+	return wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
558 558
 }
559 559
 
560 560
 /**
@@ -566,19 +566,19 @@  discard block
 block discarded – undo
566 566
  *
567 567
  * @return string receipt_link
568 568
  */
569
-function give_email_tag_receipt_link( $payment_id ) {
569
+function give_email_tag_receipt_link($payment_id) {
570 570
 
571
-	$receipt_url = esc_url( add_query_arg( array(
572
-		'payment_key' => give_get_payment_key( $payment_id ),
571
+	$receipt_url = esc_url(add_query_arg(array(
572
+		'payment_key' => give_get_payment_key($payment_id),
573 573
 		'give_action' => 'view_receipt'
574
-	), home_url() ) );
575
-	$formatted   = sprintf(
574
+	), home_url()));
575
+	$formatted = sprintf(
576 576
 		'<a href="%1$s">%2$s</a>',
577 577
 		$receipt_url,
578
-		esc_html__( 'View it in your browser', 'give' )
578
+		esc_html__('View it in your browser', 'give')
579 579
 	);
580 580
 
581
-	if ( give_get_option( 'email_template' ) !== 'none' ) {
581
+	if (give_get_option('email_template') !== 'none') {
582 582
 		return $formatted;
583 583
 	} else {
584 584
 		return $receipt_url;
Please login to merge, or discard this patch.
includes/ajax-functions.php 1 patch
Spacing   +91 added lines, -91 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
 
@@ -25,27 +25,27 @@  discard block
 block discarded – undo
25 25
 function give_test_ajax_works() {
26 26
 
27 27
 	// Check if the Airplane Mode plugin is installed
28
-	if ( class_exists( 'Airplane_Mode_Core' ) ) {
28
+	if (class_exists('Airplane_Mode_Core')) {
29 29
 
30 30
 		$airplane = Airplane_Mode_Core::getInstance();
31 31
 
32
-		if ( method_exists( $airplane, 'enabled' ) ) {
32
+		if (method_exists($airplane, 'enabled')) {
33 33
 
34
-			if ( $airplane->enabled() ) {
34
+			if ($airplane->enabled()) {
35 35
 				return true;
36 36
 			}
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 ( get_transient( '_give_ajax_works' ) ) {
48
+	if (get_transient('_give_ajax_works')) {
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
 	$works = true;
62 62
 
63
-	if ( is_wp_error( $ajax ) ) {
63
+	if (is_wp_error($ajax)) {
64 64
 
65 65
 		$works = false;
66 66
 
67 67
 	} else {
68 68
 
69
-		if ( empty( $ajax['response'] ) ) {
69
+		if (empty($ajax['response'])) {
70 70
 			$works = false;
71 71
 		}
72 72
 
73
-		if ( empty( $ajax['response']['code'] ) || 200 !== (int) $ajax['response']['code'] ) {
73
+		if (empty($ajax['response']['code']) || 200 !== (int) $ajax['response']['code']) {
74 74
 			$works = false;
75 75
 		}
76 76
 
77
-		if ( empty( $ajax['response']['message'] ) || 'OK' !== $ajax['response']['message'] ) {
77
+		if (empty($ajax['response']['message']) || 'OK' !== $ajax['response']['message']) {
78 78
 			$works = false;
79 79
 		}
80 80
 
81
-		if ( ! isset( $ajax['body'] ) || 0 !== (int) $ajax['body'] ) {
81
+		if ( ! isset($ajax['body']) || 0 !== (int) $ajax['body']) {
82 82
 			$works = false;
83 83
 		}
84 84
 
85 85
 	}
86 86
 
87
-	if ( $works ) {
88
-		set_transient( '_give_ajax_works', '1', DAY_IN_SECONDS );
87
+	if ($works) {
88
+		set_transient('_give_ajax_works', '1', DAY_IN_SECONDS);
89 89
 	}
90 90
 
91 91
 	return $works;
@@ -99,16 +99,16 @@  discard block
 block discarded – undo
99 99
  * @return string
100 100
  */
101 101
 function give_get_ajax_url() {
102
-	$scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
102
+	$scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin';
103 103
 
104 104
 	$current_url = give_get_current_page_url();
105
-	$ajax_url    = admin_url( 'admin-ajax.php', $scheme );
105
+	$ajax_url    = admin_url('admin-ajax.php', $scheme);
106 106
 
107
-	if ( preg_match( '/^https/', $current_url ) && ! preg_match( '/^https/', $ajax_url ) ) {
108
-		$ajax_url = preg_replace( '/^http/', 'https', $ajax_url );
107
+	if (preg_match('/^https/', $current_url) && ! preg_match('/^https/', $ajax_url)) {
108
+		$ajax_url = preg_replace('/^http/', 'https', $ajax_url);
109 109
 	}
110 110
 
111
-	return apply_filters( 'give_ajax_url', $ajax_url );
111
+	return apply_filters('give_ajax_url', $ajax_url);
112 112
 }
113 113
 
114 114
 /**
@@ -118,11 +118,11 @@  discard block
 block discarded – undo
118 118
  * @return void
119 119
  */
120 120
 function give_load_checkout_login_fields() {
121
-	do_action( 'give_purchase_form_login_fields' );
121
+	do_action('give_purchase_form_login_fields');
122 122
 	give_die();
123 123
 }
124 124
 
125
-add_action( 'wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields' );
125
+add_action('wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields');
126 126
 
127 127
 /**
128 128
  * Load Checkout Fields
@@ -131,22 +131,22 @@  discard block
 block discarded – undo
131 131
  * @return void
132 132
  */
133 133
 function give_load_checkout_fields() {
134
-	$form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : '';
134
+	$form_id = isset($_POST['form_id']) ? $_POST['form_id'] : '';
135 135
 
136 136
 	ob_start();
137 137
 
138
-	do_action( 'give_purchase_form_register_login_fields', $form_id );
138
+	do_action('give_purchase_form_register_login_fields', $form_id);
139 139
 
140 140
 	$fields = ob_get_clean();
141 141
 
142
-	wp_send_json( array(
143
-		'fields' => wp_json_encode( $fields ),
144
-		'submit' => wp_json_encode( give_checkout_button_purchase( $form_id ) ),
145
-	) );
142
+	wp_send_json(array(
143
+		'fields' => wp_json_encode($fields),
144
+		'submit' => wp_json_encode(give_checkout_button_purchase($form_id)),
145
+	));
146 146
 }
147 147
 
148
-add_action( 'wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields' );
149
-add_action( 'wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields' );
148
+add_action('wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields');
149
+add_action('wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields');
150 150
 
151 151
 /**
152 152
  * Get Form Title via AJAX (used only in WordPress Admin)
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
  * @return void
156 156
  */
157 157
 function give_ajax_get_form_title() {
158
-	if ( isset( $_POST['form_id'] ) ) {
159
-		$title = get_the_title( $_POST['form_id'] );
160
-		if ( $title ) {
158
+	if (isset($_POST['form_id'])) {
159
+		$title = get_the_title($_POST['form_id']);
160
+		if ($title) {
161 161
 			echo $title;
162 162
 		} else {
163 163
 			echo 'fail';
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
 	give_die();
167 167
 }
168 168
 
169
-add_action( 'wp_ajax_give_get_form_title', 'give_ajax_get_form_title' );
170
-add_action( 'wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title' );
169
+add_action('wp_ajax_give_get_form_title', 'give_ajax_get_form_title');
170
+add_action('wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title');
171 171
 
172 172
 /**
173 173
  * Retrieve a states drop down
@@ -177,23 +177,23 @@  discard block
 block discarded – undo
177 177
  */
178 178
 function give_ajax_get_states_field() {
179 179
 
180
-	if ( empty( $_POST['country'] ) ) {
180
+	if (empty($_POST['country'])) {
181 181
 		$_POST['country'] = give_get_country();
182 182
 	}
183
-	$states = give_get_states( $_POST['country'] );
183
+	$states = give_get_states($_POST['country']);
184 184
 
185
-	if ( ! empty( $states ) ) {
185
+	if ( ! empty($states)) {
186 186
 
187 187
 		$args = array(
188 188
 			'name'             => $_POST['field_name'],
189 189
 			'id'               => $_POST['field_name'],
190
-			'class'            => $_POST['field_name'] . '  give-select',
191
-			'options'          => give_get_states( $_POST['country'] ),
190
+			'class'            => $_POST['field_name'].'  give-select',
191
+			'options'          => give_get_states($_POST['country']),
192 192
 			'show_option_all'  => false,
193 193
 			'show_option_none' => false
194 194
 		);
195 195
 
196
-		$response = Give()->html->select( $args );
196
+		$response = Give()->html->select($args);
197 197
 
198 198
 	} else {
199 199
 
@@ -205,8 +205,8 @@  discard block
 block discarded – undo
205 205
 	give_die();
206 206
 }
207 207
 
208
-add_action( 'wp_ajax_give_get_states', 'give_ajax_get_states_field' );
209
-add_action( 'wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field' );
208
+add_action('wp_ajax_give_get_states', 'give_ajax_get_states_field');
209
+add_action('wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field');
210 210
 
211 211
 /**
212 212
  * Retrieve a states drop down
@@ -217,17 +217,17 @@  discard block
 block discarded – undo
217 217
 function give_ajax_form_search() {
218 218
 	global $wpdb;
219 219
 
220
-	$search  = esc_sql( sanitize_text_field( $_GET['s'] ) );
220
+	$search  = esc_sql(sanitize_text_field($_GET['s']));
221 221
 	$results = array();
222
-	if ( current_user_can( 'edit_give_forms' ) ) {
223
-		$items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50" );
222
+	if (current_user_can('edit_give_forms')) {
223
+		$items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50");
224 224
 	} else {
225
-		$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" );
225
+		$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");
226 226
 	}
227 227
 
228
-	if ( $items ) {
228
+	if ($items) {
229 229
 
230
-		foreach ( $items as $item ) {
230
+		foreach ($items as $item) {
231 231
 
232 232
 			$results[] = array(
233 233
 				'id'   => $item->ID,
@@ -239,18 +239,18 @@  discard block
 block discarded – undo
239 239
 
240 240
 		$items[] = array(
241 241
 			'id'   => 0,
242
-			'name' => esc_html__( 'No results found', 'give' )
242
+			'name' => esc_html__('No results found', 'give')
243 243
 		);
244 244
 
245 245
 	}
246 246
 
247
-	echo json_encode( $results );
247
+	echo json_encode($results);
248 248
 
249 249
 	give_die();
250 250
 }
251 251
 
252
-add_action( 'wp_ajax_give_form_search', 'give_ajax_form_search' );
253
-add_action( 'wp_ajax_nopriv_give_form_search', 'give_ajax_form_search' );
252
+add_action('wp_ajax_give_form_search', 'give_ajax_form_search');
253
+add_action('wp_ajax_nopriv_give_form_search', 'give_ajax_form_search');
254 254
 
255 255
 /**
256 256
  * Search the donors database via Ajax
@@ -261,21 +261,21 @@  discard block
 block discarded – undo
261 261
 function give_ajax_donor_search() {
262 262
 	global $wpdb;
263 263
 
264
-	$search  = esc_sql( sanitize_text_field( $_GET['s'] ) );
264
+	$search  = esc_sql(sanitize_text_field($_GET['s']));
265 265
 	$results = array();
266
-	if ( ! current_user_can( 'view_give_reports' ) ) {
266
+	if ( ! current_user_can('view_give_reports')) {
267 267
 		$donors = array();
268 268
 	} else {
269
-		$donors = $wpdb->get_results( "SELECT id,name,email FROM {$wpdb->prefix}give_donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50" );
269
+		$donors = $wpdb->get_results("SELECT id,name,email FROM {$wpdb->prefix}give_donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50");
270 270
 	}
271 271
 
272
-	if ( $donors ) {
272
+	if ($donors) {
273 273
 
274
-		foreach ( $donors as $donor ) {
274
+		foreach ($donors as $donor) {
275 275
 
276 276
 			$results[] = array(
277 277
 				'id'   => $donor->id,
278
-				'name' => $donor->name . '(' . $donor->email . ')'
278
+				'name' => $donor->name.'('.$donor->email.')'
279 279
 			);
280 280
 		}
281 281
 
@@ -283,17 +283,17 @@  discard block
 block discarded – undo
283 283
 
284 284
 		$donors[] = array(
285 285
 			'id'   => 0,
286
-			'name' => esc_html__( 'No results found', 'give' )
286
+			'name' => esc_html__('No results found', 'give')
287 287
 		);
288 288
 
289 289
 	}
290 290
 
291
-	echo json_encode( $results );
291
+	echo json_encode($results);
292 292
 
293 293
 	give_die();
294 294
 }
295 295
 
296
-add_action( 'wp_ajax_give_donor_search', 'give_ajax_donor_search' );
296
+add_action('wp_ajax_give_donor_search', 'give_ajax_donor_search');
297 297
 
298 298
 
299 299
 /**
@@ -304,42 +304,42 @@  discard block
 block discarded – undo
304 304
  */
305 305
 function give_ajax_search_users() {
306 306
 
307
-	if ( current_user_can( 'manage_give_settings' ) ) {
307
+	if (current_user_can('manage_give_settings')) {
308 308
 
309
-		$search_query = trim( $_POST['user_name'] );
310
-		$exclude      = trim( $_POST['exclude'] );
309
+		$search_query = trim($_POST['user_name']);
310
+		$exclude      = trim($_POST['exclude']);
311 311
 
312 312
 		$get_users_args = array(
313 313
 			'number' => 9999,
314
-			'search' => $search_query . '*'
314
+			'search' => $search_query.'*'
315 315
 		);
316 316
 
317
-		if ( ! empty( $exclude ) ) {
318
-			$exclude_array             = explode( ',', $exclude );
317
+		if ( ! empty($exclude)) {
318
+			$exclude_array             = explode(',', $exclude);
319 319
 			$get_users_args['exclude'] = $exclude_array;
320 320
 		}
321 321
 
322
-		$get_users_args = apply_filters( 'give_search_users_args', $get_users_args );
322
+		$get_users_args = apply_filters('give_search_users_args', $get_users_args);
323 323
 
324
-		$found_users = apply_filters( 'give_ajax_found_users', get_users( $get_users_args ), $search_query );
324
+		$found_users = apply_filters('give_ajax_found_users', get_users($get_users_args), $search_query);
325 325
 
326 326
 		$user_list = '<ul>';
327
-		if ( $found_users ) {
328
-			foreach ( $found_users as $user ) {
329
-				$user_list .= '<li><a href="#" data-userid="' . esc_attr__( $user->ID ) . '" data-login="' . esc_attr__( $user->user_login ) . '">' . esc_html__( $user->user_login ) . '</a></li>';
327
+		if ($found_users) {
328
+			foreach ($found_users as $user) {
329
+				$user_list .= '<li><a href="#" data-userid="'.esc_attr__($user->ID).'" data-login="'.esc_attr__($user->user_login).'">'.esc_html__($user->user_login).'</a></li>';
330 330
 			}
331 331
 		} else {
332
-			$user_list .= '<li>' . esc_html__( 'No users found', 'give' ) . '</li>';
332
+			$user_list .= '<li>'.esc_html__('No users found', 'give').'</li>';
333 333
 		}
334 334
 		$user_list .= '</ul>';
335 335
 
336
-		echo json_encode( array( 'results' => $user_list ) );
336
+		echo json_encode(array('results' => $user_list));
337 337
 
338 338
 	}
339 339
 	die();
340 340
 }
341 341
 
342
-add_action( 'wp_ajax_give_search_users', 'give_ajax_search_users' );
342
+add_action('wp_ajax_give_search_users', 'give_ajax_search_users');
343 343
 
344 344
 
345 345
 /**
@@ -350,32 +350,32 @@  discard block
 block discarded – undo
350 350
  */
351 351
 function give_check_for_form_price_variations() {
352 352
 
353
-	if ( ! current_user_can( 'edit_give_forms', get_current_user_id() ) ) {
354
-		die( '-1' );
353
+	if ( ! current_user_can('edit_give_forms', get_current_user_id())) {
354
+		die('-1');
355 355
 	}
356 356
 
357
-	$form_id = intval( $_POST['form_id'] );
358
-	$form    = get_post( $form_id );
357
+	$form_id = intval($_POST['form_id']);
358
+	$form    = get_post($form_id);
359 359
 
360
-	if ( 'give_forms' != $form->post_type ) {
361
-		die( '-2' );
360
+	if ('give_forms' != $form->post_type) {
361
+		die('-2');
362 362
 	}
363 363
 
364
-	if ( give_has_variable_prices( $form_id ) ) {
365
-		$variable_prices = give_get_variable_prices( $form_id );
364
+	if (give_has_variable_prices($form_id)) {
365
+		$variable_prices = give_get_variable_prices($form_id);
366 366
 
367
-		if ( $variable_prices ) {
367
+		if ($variable_prices) {
368 368
 			$ajax_response = '<select class="give_price_options_select give-select give-select" name="give_price_option">';
369 369
 
370
-			if ( isset( $_POST['all_prices'] ) ) {
371
-				$ajax_response .= '<option value="">' . esc_html__( 'All Levels', 'give' ) . '</option>';
370
+			if (isset($_POST['all_prices'])) {
371
+				$ajax_response .= '<option value="">'.esc_html__('All Levels', 'give').'</option>';
372 372
 			}
373 373
 
374
-			foreach ( $variable_prices as $key => $price ) {
374
+			foreach ($variable_prices as $key => $price) {
375 375
 
376
-				$level_text = ! empty( $price['_give_text'] ) ? esc_html__( $price['_give_text'] ) : give_currency_filter( give_format_amount( $price['_give_amount'] ) );
376
+				$level_text = ! empty($price['_give_text']) ? esc_html__($price['_give_text']) : give_currency_filter(give_format_amount($price['_give_amount']));
377 377
 				
378
-				$ajax_response .= '<option value="' . esc_attr__( $price['_give_id']['level_id'] ) . '">' . $level_text . '</option>';
378
+				$ajax_response .= '<option value="'.esc_attr__($price['_give_id']['level_id']).'">'.$level_text.'</option>';
379 379
 			}
380 380
 			$ajax_response .= '</select>';
381 381
 			echo $ajax_response;
@@ -386,4 +386,4 @@  discard block
 block discarded – undo
386 386
 	give_die();
387 387
 }
388 388
 
389
-add_action( 'wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations' );
389
+add_action('wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations');
Please login to merge, or discard this patch.
includes/api/class-give-api.php 1 patch
Spacing   +482 added lines, -482 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -139,27 +139,27 @@  discard block
 block discarded – undo
139 139
 			'v1' => 'GIVE_API_V1',
140 140
 		);
141 141
 
142
-		foreach ( $this->get_versions() as $version => $class ) {
143
-			require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api-' . $version . '.php';
142
+		foreach ($this->get_versions() as $version => $class) {
143
+			require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api-'.$version.'.php';
144 144
 		}
145 145
 
146
-		add_action( 'init', array( $this, 'add_endpoint' ) );
147
-		add_action( 'wp', array( $this, 'process_query' ), - 1 );
148
-		add_filter( 'query_vars', array( $this, 'query_vars' ) );
149
-		add_action( 'show_user_profile', array( $this, 'user_key_field' ) );
150
-		add_action( 'edit_user_profile', array( $this, 'user_key_field' ) );
151
-		add_action( 'personal_options_update', array( $this, 'update_key' ) );
152
-		add_action( 'edit_user_profile_update', array( $this, 'update_key' ) );
153
-		add_action( 'give_process_api_key', array( $this, 'process_api_key' ) );
146
+		add_action('init', array($this, 'add_endpoint'));
147
+		add_action('wp', array($this, 'process_query'), - 1);
148
+		add_filter('query_vars', array($this, 'query_vars'));
149
+		add_action('show_user_profile', array($this, 'user_key_field'));
150
+		add_action('edit_user_profile', array($this, 'user_key_field'));
151
+		add_action('personal_options_update', array($this, 'update_key'));
152
+		add_action('edit_user_profile_update', array($this, 'update_key'));
153
+		add_action('give_process_api_key', array($this, 'process_api_key'));
154 154
 
155 155
 		// Setup a backwards compatibility check for user API Keys
156
-		add_filter( 'get_user_metadata', array( $this, 'api_key_backwards_compat' ), 10, 4 );
156
+		add_filter('get_user_metadata', array($this, 'api_key_backwards_compat'), 10, 4);
157 157
 
158 158
 		// Determine if JSON_PRETTY_PRINT is available
159
-		$this->pretty_print = defined( 'JSON_PRETTY_PRINT' ) ? JSON_PRETTY_PRINT : null;
159
+		$this->pretty_print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : null;
160 160
 
161 161
 		// Allow API request logging to be turned off
162
-		$this->log_requests = apply_filters( 'give_api_log_requests', $this->log_requests );
162
+		$this->log_requests = apply_filters('give_api_log_requests', $this->log_requests);
163 163
 
164 164
 		// Setup Give_Payment_Stats instance
165 165
 		$this->stats = new Give_Payment_Stats;
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
 	 *
176 176
 	 * @since  1.1
177 177
 	 */
178
-	public function add_endpoint( $rewrite_rules ) {
179
-		add_rewrite_endpoint( 'give-api', EP_ALL );
178
+	public function add_endpoint($rewrite_rules) {
179
+		add_rewrite_endpoint('give-api', EP_ALL);
180 180
 	}
181 181
 
182 182
 	/**
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	 *
190 190
 	 * @return string[] $vars New query vars
191 191
 	 */
192
-	public function query_vars( $vars ) {
192
+	public function query_vars($vars) {
193 193
 
194 194
 		$vars[] = 'token';
195 195
 		$vars[] = 'key';
@@ -240,11 +240,11 @@  discard block
 block discarded – undo
240 240
 	 */
241 241
 	public function get_default_version() {
242 242
 
243
-		$version = get_option( 'give_default_api_version' );
243
+		$version = get_option('give_default_api_version');
244 244
 
245
-		if ( defined( 'GIVE_API_VERSION' ) ) {
245
+		if (defined('GIVE_API_VERSION')) {
246 246
 			$version = GIVE_API_VERSION;
247
-		} elseif ( ! $version ) {
247
+		} elseif ( ! $version) {
248 248
 			$version = 'v1';
249 249
 		}
250 250
 
@@ -265,14 +265,14 @@  discard block
 block discarded – undo
265 265
 
266 266
 		$version = $wp_query->query_vars['give-api'];
267 267
 
268
-		if ( strpos( $version, '/' ) ) {
268
+		if (strpos($version, '/')) {
269 269
 
270
-			$version = explode( '/', $version );
271
-			$version = strtolower( $version[0] );
270
+			$version = explode('/', $version);
271
+			$version = strtolower($version[0]);
272 272
 
273
-			$wp_query->query_vars['give-api'] = str_replace( $version . '/', '', $wp_query->query_vars['give-api'] );
273
+			$wp_query->query_vars['give-api'] = str_replace($version.'/', '', $wp_query->query_vars['give-api']);
274 274
 
275
-			if ( array_key_exists( $version, $this->versions ) ) {
275
+			if (array_key_exists($version, $this->versions)) {
276 276
 
277 277
 				$this->queried_version = $version;
278 278
 
@@ -309,32 +309,32 @@  discard block
 block discarded – undo
309 309
 		$this->override = false;
310 310
 
311 311
 		// Make sure we have both user and api key
312
-		if ( ! empty( $wp_query->query_vars['give-api'] ) && ( $wp_query->query_vars['give-api'] != 'forms' || ! empty( $wp_query->query_vars['token'] ) ) ) {
312
+		if ( ! empty($wp_query->query_vars['give-api']) && ($wp_query->query_vars['give-api'] != 'forms' || ! empty($wp_query->query_vars['token']))) {
313 313
 
314
-			if ( empty( $wp_query->query_vars['token'] ) || empty( $wp_query->query_vars['key'] ) ) {
314
+			if (empty($wp_query->query_vars['token']) || empty($wp_query->query_vars['key'])) {
315 315
 				$this->missing_auth();
316 316
 			}
317 317
 
318 318
 			// Retrieve the user by public API key and ensure they exist
319
-			if ( ! ( $user = $this->get_user( $wp_query->query_vars['key'] ) ) ) {
319
+			if ( ! ($user = $this->get_user($wp_query->query_vars['key']))) {
320 320
 
321 321
 				$this->invalid_key();
322 322
 
323 323
 			} else {
324 324
 
325
-				$token  = urldecode( $wp_query->query_vars['token'] );
326
-				$secret = $this->get_user_secret_key( $user );
327
-				$public = urldecode( $wp_query->query_vars['key'] );
325
+				$token  = urldecode($wp_query->query_vars['token']);
326
+				$secret = $this->get_user_secret_key($user);
327
+				$public = urldecode($wp_query->query_vars['key']);
328 328
 
329
-				if ( hash_equals( md5( $secret . $public ), $token ) ) {
329
+				if (hash_equals(md5($secret.$public), $token)) {
330 330
 					$this->is_valid_request = true;
331 331
 				} else {
332 332
 					$this->invalid_auth();
333 333
 				}
334 334
 			}
335
-		} elseif ( ! empty( $wp_query->query_vars['give-api'] ) && $wp_query->query_vars['give-api'] == 'forms' ) {
335
+		} elseif ( ! empty($wp_query->query_vars['give-api']) && $wp_query->query_vars['give-api'] == 'forms') {
336 336
 			$this->is_valid_request = true;
337
-			$wp_query->set( 'key', 'public' );
337
+			$wp_query->set('key', 'public');
338 338
 		}
339 339
 	}
340 340
 
@@ -350,25 +350,25 @@  discard block
 block discarded – undo
350 350
 	 *
351 351
 	 * @return bool if user ID is found, false otherwise
352 352
 	 */
353
-	public function get_user( $key = '' ) {
353
+	public function get_user($key = '') {
354 354
 		global $wpdb, $wp_query;
355 355
 
356
-		if ( empty( $key ) ) {
357
-			$key = urldecode( $wp_query->query_vars['key'] );
356
+		if (empty($key)) {
357
+			$key = urldecode($wp_query->query_vars['key']);
358 358
 		}
359 359
 
360
-		if ( empty( $key ) ) {
360
+		if (empty($key)) {
361 361
 			return false;
362 362
 		}
363 363
 
364
-		$user = get_transient( md5( 'give_api_user_' . $key ) );
364
+		$user = get_transient(md5('give_api_user_'.$key));
365 365
 
366
-		if ( false === $user ) {
367
-			$user = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key ) );
368
-			set_transient( md5( 'give_api_user_' . $key ), $user, DAY_IN_SECONDS );
366
+		if (false === $user) {
367
+			$user = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key));
368
+			set_transient(md5('give_api_user_'.$key), $user, DAY_IN_SECONDS);
369 369
 		}
370 370
 
371
-		if ( $user != null ) {
371
+		if ($user != null) {
372 372
 			$this->user_id = $user;
373 373
 
374 374
 			return $user;
@@ -377,37 +377,37 @@  discard block
 block discarded – undo
377 377
 		return false;
378 378
 	}
379 379
 
380
-	public function get_user_public_key( $user_id = 0 ) {
380
+	public function get_user_public_key($user_id = 0) {
381 381
 		global $wpdb;
382 382
 
383
-		if ( empty( $user_id ) ) {
383
+		if (empty($user_id)) {
384 384
 			return '';
385 385
 		}
386 386
 
387
-		$cache_key       = md5( 'give_api_user_public_key' . $user_id );
388
-		$user_public_key = get_transient( $cache_key );
387
+		$cache_key       = md5('give_api_user_public_key'.$user_id);
388
+		$user_public_key = get_transient($cache_key);
389 389
 
390
-		if ( empty( $user_public_key ) ) {
391
-			$user_public_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id ) );
392
-			set_transient( $cache_key, $user_public_key, HOUR_IN_SECONDS );
390
+		if (empty($user_public_key)) {
391
+			$user_public_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id));
392
+			set_transient($cache_key, $user_public_key, HOUR_IN_SECONDS);
393 393
 		}
394 394
 
395 395
 		return $user_public_key;
396 396
 	}
397 397
 
398
-	public function get_user_secret_key( $user_id = 0 ) {
398
+	public function get_user_secret_key($user_id = 0) {
399 399
 		global $wpdb;
400 400
 
401
-		if ( empty( $user_id ) ) {
401
+		if (empty($user_id)) {
402 402
 			return '';
403 403
 		}
404 404
 
405
-		$cache_key       = md5( 'give_api_user_secret_key' . $user_id );
406
-		$user_secret_key = get_transient( $cache_key );
405
+		$cache_key       = md5('give_api_user_secret_key'.$user_id);
406
+		$user_secret_key = get_transient($cache_key);
407 407
 
408
-		if ( empty( $user_secret_key ) ) {
409
-			$user_secret_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id ) );
410
-			set_transient( $cache_key, $user_secret_key, HOUR_IN_SECONDS );
408
+		if (empty($user_secret_key)) {
409
+			$user_secret_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id));
410
+			set_transient($cache_key, $user_secret_key, HOUR_IN_SECONDS);
411 411
 		}
412 412
 
413 413
 		return $user_secret_key;
@@ -423,10 +423,10 @@  discard block
 block discarded – undo
423 423
 	 */
424 424
 	private function missing_auth() {
425 425
 		$error          = array();
426
-		$error['error'] = esc_html__( 'You must specify both a token and API key!', 'give' );
426
+		$error['error'] = esc_html__('You must specify both a token and API key!', 'give');
427 427
 
428 428
 		$this->data = $error;
429
-		$this->output( 401 );
429
+		$this->output(401);
430 430
 	}
431 431
 
432 432
 	/**
@@ -440,10 +440,10 @@  discard block
 block discarded – undo
440 440
 	 */
441 441
 	private function invalid_auth() {
442 442
 		$error          = array();
443
-		$error['error'] = esc_html__( 'Your request could not be authenticated!', 'give' );
443
+		$error['error'] = esc_html__('Your request could not be authenticated!', 'give');
444 444
 
445 445
 		$this->data = $error;
446
-		$this->output( 403 );
446
+		$this->output(403);
447 447
 	}
448 448
 
449 449
 	/**
@@ -457,10 +457,10 @@  discard block
 block discarded – undo
457 457
 	 */
458 458
 	private function invalid_key() {
459 459
 		$error          = array();
460
-		$error['error'] = esc_html__( 'Invalid API key!', 'give' );
460
+		$error['error'] = esc_html__('Invalid API key!', 'give');
461 461
 
462 462
 		$this->data = $error;
463
-		$this->output( 403 );
463
+		$this->output(403);
464 464
 	}
465 465
 
466 466
 	/**
@@ -473,10 +473,10 @@  discard block
 block discarded – undo
473 473
 	 */
474 474
 	private function invalid_version() {
475 475
 		$error          = array();
476
-		$error['error'] = esc_html__( 'Invalid API version!', 'give' );
476
+		$error['error'] = esc_html__('Invalid API version!', 'give');
477 477
 
478 478
 		$this->data = $error;
479
-		$this->output( 404 );
479
+		$this->output(404);
480 480
 	}
481 481
 
482 482
 	/**
@@ -492,10 +492,10 @@  discard block
 block discarded – undo
492 492
 		global $wp_query;
493 493
 
494 494
 		// Start logging how long the request takes for logging
495
-		$before = microtime( true );
495
+		$before = microtime(true);
496 496
 
497 497
 		// Check for give-api var. Get out if not present
498
-		if ( empty( $wp_query->query_vars['give-api'] ) ) {
498
+		if (empty($wp_query->query_vars['give-api'])) {
499 499
 			return;
500 500
 		}
501 501
 
@@ -509,45 +509,45 @@  discard block
 block discarded – undo
509 509
 		$this->validate_request();
510 510
 
511 511
 		// Only proceed if no errors have been noted
512
-		if ( ! $this->is_valid_request ) {
512
+		if ( ! $this->is_valid_request) {
513 513
 			return;
514 514
 		}
515 515
 
516
-		if ( ! defined( 'GIVE_DOING_API' ) ) {
517
-			define( 'GIVE_DOING_API', true );
516
+		if ( ! defined('GIVE_DOING_API')) {
517
+			define('GIVE_DOING_API', true);
518 518
 		}
519 519
 
520 520
 		$data         = array();
521 521
 		$this->routes = new $this->versions[$this->get_queried_version()];
522 522
 		$this->routes->validate_request();
523 523
 
524
-		switch ( $this->endpoint ) :
524
+		switch ($this->endpoint) :
525 525
 
526 526
 			case 'stats' :
527 527
 
528
-				$data = $this->routes->get_stats( array(
529
-					'type'      => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null,
530
-					'form'      => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null,
531
-					'date'      => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null,
532
-					'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null,
533
-					'enddate'   => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null
534
-				) );
528
+				$data = $this->routes->get_stats(array(
529
+					'type'      => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null,
530
+					'form'      => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null,
531
+					'date'      => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null,
532
+					'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null,
533
+					'enddate'   => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null
534
+				));
535 535
 
536 536
 				break;
537 537
 
538 538
 			case 'forms' :
539 539
 
540
-				$form = isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null;
540
+				$form = isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null;
541 541
 
542
-				$data = $this->routes->get_forms( $form );
542
+				$data = $this->routes->get_forms($form);
543 543
 
544 544
 				break;
545 545
 
546 546
 			case 'donors' :
547 547
 
548
-				$customer = isset( $wp_query->query_vars['donor'] ) ? $wp_query->query_vars['donor'] : null;
548
+				$customer = isset($wp_query->query_vars['donor']) ? $wp_query->query_vars['donor'] : null;
549 549
 
550
-				$data = $this->routes->get_customers( $customer );
550
+				$data = $this->routes->get_customers($customer);
551 551
 
552 552
 				break;
553 553
 
@@ -560,14 +560,14 @@  discard block
 block discarded – undo
560 560
 		endswitch;
561 561
 
562 562
 		// Allow extensions to setup their own return data
563
-		$this->data = apply_filters( 'give_api_output_data', $data, $this->endpoint, $this );
563
+		$this->data = apply_filters('give_api_output_data', $data, $this->endpoint, $this);
564 564
 
565
-		$after                       = microtime( true );
566
-		$request_time                = ( $after - $before );
565
+		$after                       = microtime(true);
566
+		$request_time                = ($after - $before);
567 567
 		$this->data['request_speed'] = $request_time;
568 568
 
569 569
 		// Log this API request, if enabled. We log it here because we have access to errors.
570
-		$this->log_request( $this->data );
570
+		$this->log_request($this->data);
571 571
 
572 572
 		// Send out data to the output function
573 573
 		$this->output();
@@ -597,25 +597,25 @@  discard block
 block discarded – undo
597 597
 		global $wp_query;
598 598
 
599 599
 		// Whitelist our query options
600
-		$accepted = apply_filters( 'give_api_valid_query_modes', array(
600
+		$accepted = apply_filters('give_api_valid_query_modes', array(
601 601
 			'stats',
602 602
 			'forms',
603 603
 			'donors',
604 604
 			'donations'
605
-		) );
605
+		));
606 606
 
607
-		$query = isset( $wp_query->query_vars['give-api'] ) ? $wp_query->query_vars['give-api'] : null;
608
-		$query = str_replace( $this->queried_version . '/', '', $query );
607
+		$query = isset($wp_query->query_vars['give-api']) ? $wp_query->query_vars['give-api'] : null;
608
+		$query = str_replace($this->queried_version.'/', '', $query);
609 609
 
610 610
 		$error = array();
611 611
 
612 612
 		// Make sure our query is valid
613
-		if ( ! in_array( $query, $accepted ) ) {
614
-			$error['error'] = esc_html__( 'Invalid query!', 'give' );
613
+		if ( ! in_array($query, $accepted)) {
614
+			$error['error'] = esc_html__('Invalid query!', 'give');
615 615
 
616 616
 			$this->data = $error;
617 617
 			// 400 is Bad Request
618
-			$this->output( 400 );
618
+			$this->output(400);
619 619
 		}
620 620
 
621 621
 		$this->endpoint = $query;
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
 	public function get_paged() {
633 633
 		global $wp_query;
634 634
 
635
-		return isset( $wp_query->query_vars['page'] ) ? $wp_query->query_vars['page'] : 1;
635
+		return isset($wp_query->query_vars['page']) ? $wp_query->query_vars['page'] : 1;
636 636
 	}
637 637
 
638 638
 
@@ -647,13 +647,13 @@  discard block
 block discarded – undo
647 647
 	public function per_page() {
648 648
 		global $wp_query;
649 649
 
650
-		$per_page = isset( $wp_query->query_vars['number'] ) ? $wp_query->query_vars['number'] : 10;
650
+		$per_page = isset($wp_query->query_vars['number']) ? $wp_query->query_vars['number'] : 10;
651 651
 
652
-		if ( $per_page < 0 && $this->get_query_mode() == 'donors' ) {
652
+		if ($per_page < 0 && $this->get_query_mode() == 'donors') {
653 653
 			$per_page = 99999999;
654 654
 		} // Customers query doesn't support -1
655 655
 
656
-		return apply_filters( 'give_api_results_per_page', $per_page );
656
+		return apply_filters('give_api_results_per_page', $per_page);
657 657
 	}
658 658
 
659 659
 	/**
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
 	 *
667 667
 	 * @return array $dates
668 668
 	 */
669
-	public function get_dates( $args = array() ) {
669
+	public function get_dates($args = array()) {
670 670
 		$dates = array();
671 671
 
672 672
 		$defaults = array(
@@ -677,60 +677,60 @@  discard block
 block discarded – undo
677 677
 			'enddate'   => null
678 678
 		);
679 679
 
680
-		$args = wp_parse_args( $args, $defaults );
680
+		$args = wp_parse_args($args, $defaults);
681 681
 
682
-		$current_time = current_time( 'timestamp' );
682
+		$current_time = current_time('timestamp');
683 683
 
684
-		if ( 'range' === $args['date'] ) {
685
-			$startdate          = strtotime( $args['startdate'] );
686
-			$enddate            = strtotime( $args['enddate'] );
687
-			$dates['day_start'] = date( 'd', $startdate );
688
-			$dates['day_end']   = date( 'd', $enddate );
689
-			$dates['m_start']   = date( 'n', $startdate );
690
-			$dates['m_end']     = date( 'n', $enddate );
691
-			$dates['year']      = date( 'Y', $startdate );
692
-			$dates['year_end']  = date( 'Y', $enddate );
684
+		if ('range' === $args['date']) {
685
+			$startdate          = strtotime($args['startdate']);
686
+			$enddate            = strtotime($args['enddate']);
687
+			$dates['day_start'] = date('d', $startdate);
688
+			$dates['day_end']   = date('d', $enddate);
689
+			$dates['m_start']   = date('n', $startdate);
690
+			$dates['m_end']     = date('n', $enddate);
691
+			$dates['year']      = date('Y', $startdate);
692
+			$dates['year_end']  = date('Y', $enddate);
693 693
 		} else {
694 694
 			// Modify dates based on predefined ranges
695
-			switch ( $args['date'] ) :
695
+			switch ($args['date']) :
696 696
 
697 697
 				case 'this_month' :
698 698
 					$dates['day']     = null;
699
-					$dates['m_start'] = date( 'n', $current_time );
700
-					$dates['m_end']   = date( 'n', $current_time );
701
-					$dates['year']    = date( 'Y', $current_time );
699
+					$dates['m_start'] = date('n', $current_time);
700
+					$dates['m_end']   = date('n', $current_time);
701
+					$dates['year']    = date('Y', $current_time);
702 702
 					break;
703 703
 
704 704
 				case 'last_month' :
705 705
 					$dates['day']     = null;
706
-					$dates['m_start'] = date( 'n', $current_time ) == 1 ? 12 : date( 'n', $current_time ) - 1;
706
+					$dates['m_start'] = date('n', $current_time) == 1 ? 12 : date('n', $current_time) - 1;
707 707
 					$dates['m_end']   = $dates['m_start'];
708
-					$dates['year']    = date( 'n', $current_time ) == 1 ? date( 'Y', $current_time ) - 1 : date( 'Y', $current_time );
708
+					$dates['year']    = date('n', $current_time) == 1 ? date('Y', $current_time) - 1 : date('Y', $current_time);
709 709
 					break;
710 710
 
711 711
 				case 'today' :
712
-					$dates['day']     = date( 'd', $current_time );
713
-					$dates['m_start'] = date( 'n', $current_time );
714
-					$dates['m_end']   = date( 'n', $current_time );
715
-					$dates['year']    = date( 'Y', $current_time );
712
+					$dates['day']     = date('d', $current_time);
713
+					$dates['m_start'] = date('n', $current_time);
714
+					$dates['m_end']   = date('n', $current_time);
715
+					$dates['year']    = date('Y', $current_time);
716 716
 					break;
717 717
 
718 718
 				case 'yesterday' :
719 719
 
720
-					$year  = date( 'Y', $current_time );
721
-					$month = date( 'n', $current_time );
722
-					$day   = date( 'd', $current_time );
720
+					$year  = date('Y', $current_time);
721
+					$month = date('n', $current_time);
722
+					$day   = date('d', $current_time);
723 723
 
724
-					if ( $month == 1 && $day == 1 ) {
724
+					if ($month == 1 && $day == 1) {
725 725
 
726 726
 						$year -= 1;
727 727
 						$month = 12;
728
-						$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
728
+						$day   = cal_days_in_month(CAL_GREGORIAN, $month, $year);
729 729
 
730
-					} elseif ( $month > 1 && $day == 1 ) {
730
+					} elseif ($month > 1 && $day == 1) {
731 731
 
732 732
 						$month -= 1;
733
-						$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
733
+						$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
734 734
 
735 735
 					} else {
736 736
 
@@ -746,65 +746,65 @@  discard block
 block discarded – undo
746 746
 					break;
747 747
 
748 748
 				case 'this_quarter' :
749
-					$month_now = date( 'n', $current_time );
749
+					$month_now = date('n', $current_time);
750 750
 
751 751
 					$dates['day'] = null;
752 752
 
753
-					if ( $month_now <= 3 ) {
753
+					if ($month_now <= 3) {
754 754
 
755 755
 						$dates['m_start'] = 1;
756 756
 						$dates['m_end']   = 3;
757
-						$dates['year']    = date( 'Y', $current_time );
757
+						$dates['year']    = date('Y', $current_time);
758 758
 
759
-					} else if ( $month_now <= 6 ) {
759
+					} else if ($month_now <= 6) {
760 760
 
761 761
 						$dates['m_start'] = 4;
762 762
 						$dates['m_end']   = 6;
763
-						$dates['year']    = date( 'Y', $current_time );
763
+						$dates['year']    = date('Y', $current_time);
764 764
 
765
-					} else if ( $month_now <= 9 ) {
765
+					} else if ($month_now <= 9) {
766 766
 
767 767
 						$dates['m_start'] = 7;
768 768
 						$dates['m_end']   = 9;
769
-						$dates['year']    = date( 'Y', $current_time );
769
+						$dates['year']    = date('Y', $current_time);
770 770
 
771 771
 					} else {
772 772
 
773 773
 						$dates['m_start'] = 10;
774 774
 						$dates['m_end']   = 12;
775
-						$dates['year']    = date( 'Y', $current_time );
775
+						$dates['year']    = date('Y', $current_time);
776 776
 
777 777
 					}
778 778
 					break;
779 779
 
780 780
 				case 'last_quarter' :
781
-					$month_now = date( 'n', $current_time );
781
+					$month_now = date('n', $current_time);
782 782
 
783 783
 					$dates['day'] = null;
784 784
 
785
-					if ( $month_now <= 3 ) {
785
+					if ($month_now <= 3) {
786 786
 
787 787
 						$dates['m_start'] = 10;
788 788
 						$dates['m_end']   = 12;
789
-						$dates['year']    = date( 'Y', $current_time ) - 1; // Previous year
789
+						$dates['year']    = date('Y', $current_time) - 1; // Previous year
790 790
 
791
-					} else if ( $month_now <= 6 ) {
791
+					} else if ($month_now <= 6) {
792 792
 
793 793
 						$dates['m_start'] = 1;
794 794
 						$dates['m_end']   = 3;
795
-						$dates['year']    = date( 'Y', $current_time );
795
+						$dates['year']    = date('Y', $current_time);
796 796
 
797
-					} else if ( $month_now <= 9 ) {
797
+					} else if ($month_now <= 9) {
798 798
 
799 799
 						$dates['m_start'] = 4;
800 800
 						$dates['m_end']   = 6;
801
-						$dates['year']    = date( 'Y', $current_time );
801
+						$dates['year']    = date('Y', $current_time);
802 802
 
803 803
 					} else {
804 804
 
805 805
 						$dates['m_start'] = 7;
806 806
 						$dates['m_end']   = 9;
807
-						$dates['year']    = date( 'Y', $current_time );
807
+						$dates['year']    = date('Y', $current_time);
808 808
 
809 809
 					}
810 810
 					break;
@@ -813,14 +813,14 @@  discard block
 block discarded – undo
813 813
 					$dates['day']     = null;
814 814
 					$dates['m_start'] = null;
815 815
 					$dates['m_end']   = null;
816
-					$dates['year']    = date( 'Y', $current_time );
816
+					$dates['year']    = date('Y', $current_time);
817 817
 					break;
818 818
 
819 819
 				case 'last_year' :
820 820
 					$dates['day']     = null;
821 821
 					$dates['m_start'] = null;
822 822
 					$dates['m_end']   = null;
823
-					$dates['year']    = date( 'Y', $current_time ) - 1;
823
+					$dates['year']    = date('Y', $current_time) - 1;
824 824
 					break;
825 825
 
826 826
 			endswitch;
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
 		 * @param object $dates The dates used for retreiving earnings/donations
835 835
 		 */
836 836
 
837
-		return apply_filters( 'give_api_stat_dates', $dates );
837
+		return apply_filters('give_api_stat_dates', $dates);
838 838
 	}
839 839
 
840 840
 	/**
@@ -849,11 +849,11 @@  discard block
 block discarded – undo
849 849
 	 *
850 850
 	 * @return array $customers Multidimensional array of the customers
851 851
 	 */
852
-	public function get_customers( $customer = null ) {
852
+	public function get_customers($customer = null) {
853 853
 
854 854
 		$customers = array();
855 855
 		$error     = array();
856
-		if ( ! user_can( $this->user_id, 'view_give_sensitive_data' ) && ! $this->override ) {
856
+		if ( ! user_can($this->user_id, 'view_give_sensitive_data') && ! $this->override) {
857 857
 			return $customers;
858 858
 		}
859 859
 
@@ -861,64 +861,64 @@  discard block
 block discarded – undo
861 861
 
862 862
 		$paged    = $this->get_paged();
863 863
 		$per_page = $this->per_page();
864
-		$offset   = $per_page * ( $paged - 1 );
864
+		$offset   = $per_page * ($paged - 1);
865 865
 
866
-		if ( is_numeric( $customer ) ) {
866
+		if (is_numeric($customer)) {
867 867
 			$field = 'id';
868 868
 		} else {
869 869
 			$field = 'email';
870 870
 		}
871 871
 
872
-		$customer_query = Give()->customers->get_customers( array(
872
+		$customer_query = Give()->customers->get_customers(array(
873 873
 			'number' => $per_page,
874 874
 			'offset' => $offset,
875 875
 			$field   => $customer
876
-		) );
876
+		));
877 877
 		$customer_count = 0;
878 878
 
879
-		if ( $customer_query ) {
879
+		if ($customer_query) {
880 880
 
881
-			foreach ( $customer_query as $customer_obj ) {
881
+			foreach ($customer_query as $customer_obj) {
882 882
 
883
-				$names      = explode( ' ', $customer_obj->name );
884
-				$first_name = ! empty( $names[0] ) ? $names[0] : '';
883
+				$names      = explode(' ', $customer_obj->name);
884
+				$first_name = ! empty($names[0]) ? $names[0] : '';
885 885
 				$last_name  = '';
886
-				if ( ! empty( $names[1] ) ) {
887
-					unset( $names[0] );
888
-					$last_name = implode( ' ', $names );
886
+				if ( ! empty($names[1])) {
887
+					unset($names[0]);
888
+					$last_name = implode(' ', $names);
889 889
 				}
890 890
 
891
-				$customers['donors'][ $customer_count ]['info']['user_id']      = '';
892
-				$customers['donors'][ $customer_count ]['info']['username']     = '';
893
-				$customers['donors'][ $customer_count ]['info']['display_name'] = '';
894
-				$customers['donors'][ $customer_count ]['info']['customer_id']  = $customer_obj->id;
895
-				$customers['donors'][ $customer_count ]['info']['first_name']   = $first_name;
896
-				$customers['donors'][ $customer_count ]['info']['last_name']    = $last_name;
897
-				$customers['donors'][ $customer_count ]['info']['email']        = $customer_obj->email;
891
+				$customers['donors'][$customer_count]['info']['user_id']      = '';
892
+				$customers['donors'][$customer_count]['info']['username']     = '';
893
+				$customers['donors'][$customer_count]['info']['display_name'] = '';
894
+				$customers['donors'][$customer_count]['info']['customer_id']  = $customer_obj->id;
895
+				$customers['donors'][$customer_count]['info']['first_name']   = $first_name;
896
+				$customers['donors'][$customer_count]['info']['last_name']    = $last_name;
897
+				$customers['donors'][$customer_count]['info']['email']        = $customer_obj->email;
898 898
 
899
-				if ( ! empty( $customer_obj->user_id ) ) {
899
+				if ( ! empty($customer_obj->user_id)) {
900 900
 
901
-					$user_data = get_userdata( $customer_obj->user_id );
901
+					$user_data = get_userdata($customer_obj->user_id);
902 902
 
903 903
 					// Customer with registered account
904
-					$customers['donors'][ $customer_count ]['info']['user_id']      = $customer_obj->user_id;
905
-					$customers['donors'][ $customer_count ]['info']['username']     = $user_data->user_login;
906
-					$customers['donors'][ $customer_count ]['info']['display_name'] = $user_data->display_name;
904
+					$customers['donors'][$customer_count]['info']['user_id']      = $customer_obj->user_id;
905
+					$customers['donors'][$customer_count]['info']['username']     = $user_data->user_login;
906
+					$customers['donors'][$customer_count]['info']['display_name'] = $user_data->display_name;
907 907
 
908 908
 				}
909 909
 
910
-				$customers['donors'][ $customer_count ]['stats']['total_donations'] = $customer_obj->purchase_count;
911
-				$customers['donors'][ $customer_count ]['stats']['total_spent']     = $customer_obj->purchase_value;
910
+				$customers['donors'][$customer_count]['stats']['total_donations'] = $customer_obj->purchase_count;
911
+				$customers['donors'][$customer_count]['stats']['total_spent']     = $customer_obj->purchase_value;
912 912
 
913
-				$customer_count ++;
913
+				$customer_count++;
914 914
 
915 915
 			}
916 916
 
917
-		} elseif ( $customer ) {
917
+		} elseif ($customer) {
918 918
 
919 919
 			$error['error'] = sprintf(
920 920
 				/* translators: %s: customer */
921
-				esc_html__( 'Donor %s not found!', 'give' ),
921
+				esc_html__('Donor %s not found!', 'give'),
922 922
 				$customer
923 923
 			);
924 924
 
@@ -926,7 +926,7 @@  discard block
 block discarded – undo
926 926
 
927 927
 		} else {
928 928
 
929
-			$error['error'] = esc_html__( 'No donors found!', 'give' );
929
+			$error['error'] = esc_html__('No donors found!', 'give');
930 930
 
931 931
 			return $error;
932 932
 
@@ -945,38 +945,38 @@  discard block
 block discarded – undo
945 945
 	 *
946 946
 	 * @return array $customers Multidimensional array of the forms
947 947
 	 */
948
-	public function get_forms( $form = null ) {
948
+	public function get_forms($form = null) {
949 949
 
950 950
 		$forms = array();
951 951
 		$error = array();
952 952
 
953
-		if ( $form == null ) {
953
+		if ($form == null) {
954 954
 			$forms['forms'] = array();
955 955
 
956
-			$form_list = get_posts( array(
956
+			$form_list = get_posts(array(
957 957
 				'post_type'        => 'give_forms',
958 958
 				'posts_per_page'   => $this->per_page(),
959 959
 				'suppress_filters' => true,
960 960
 				'paged'            => $this->get_paged()
961
-			) );
961
+			));
962 962
 
963
-			if ( $form_list ) {
963
+			if ($form_list) {
964 964
 				$i = 0;
965
-				foreach ( $form_list as $form_info ) {
966
-					$forms['forms'][ $i ] = $this->get_form_data( $form_info );
967
-					$i ++;
965
+				foreach ($form_list as $form_info) {
966
+					$forms['forms'][$i] = $this->get_form_data($form_info);
967
+					$i++;
968 968
 				}
969 969
 			}
970 970
 		} else {
971
-			if ( get_post_type( $form ) == 'give_forms' ) {
972
-				$form_info = get_post( $form );
971
+			if (get_post_type($form) == 'give_forms') {
972
+				$form_info = get_post($form);
973 973
 
974
-				$forms['forms'][0] = $this->get_form_data( $form_info );
974
+				$forms['forms'][0] = $this->get_form_data($form_info);
975 975
 
976 976
 			} else {
977 977
 				$error['error'] = sprintf(
978 978
 					/* translators: %s: form */
979
-					esc_html__( 'Form %s not found!', 'give' ),
979
+					esc_html__('Form %s not found!', 'give'),
980 980
 					$form
981 981
 				);
982 982
 
@@ -996,7 +996,7 @@  discard block
 block discarded – undo
996 996
 	 *
997 997
 	 * @return array                Array of post data to return back in the API
998 998
 	 */
999
-	private function get_form_data( $form_info ) {
999
+	private function get_form_data($form_info) {
1000 1000
 
1001 1001
 		$form = array();
1002 1002
 
@@ -1006,46 +1006,46 @@  discard block
 block discarded – undo
1006 1006
 		$form['info']['create_date']   = $form_info->post_date;
1007 1007
 		$form['info']['modified_date'] = $form_info->post_modified;
1008 1008
 		$form['info']['status']        = $form_info->post_status;
1009
-		$form['info']['link']          = html_entity_decode( $form_info->guid );
1010
-		$form['info']['content']       = get_post_meta( $form_info->ID, '_give_form_content', true );
1011
-		$form['info']['thumbnail']     = wp_get_attachment_url( get_post_thumbnail_id( $form_info->ID ) );
1009
+		$form['info']['link']          = html_entity_decode($form_info->guid);
1010
+		$form['info']['content']       = get_post_meta($form_info->ID, '_give_form_content', true);
1011
+		$form['info']['thumbnail']     = wp_get_attachment_url(get_post_thumbnail_id($form_info->ID));
1012 1012
 
1013
-		if ( give_get_option( 'enable_categories' ) == 'on' ) {
1014
-			$form['info']['category'] = get_the_terms( $form_info, 'give_forms_category' );
1015
-			$form['info']['tags']     = get_the_terms( $form_info, 'give_forms_tag' );
1013
+		if (give_get_option('enable_categories') == 'on') {
1014
+			$form['info']['category'] = get_the_terms($form_info, 'give_forms_category');
1015
+			$form['info']['tags']     = get_the_terms($form_info, 'give_forms_tag');
1016 1016
 		}
1017
-		if ( give_get_option( 'enable_tags' ) == 'on' ) {
1018
-			$form['info']['tags'] = get_the_terms( $form_info, 'give_forms_tag' );
1017
+		if (give_get_option('enable_tags') == 'on') {
1018
+			$form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag');
1019 1019
 		}
1020 1020
 
1021
-		if ( user_can( $this->user_id, 'view_give_reports' ) || $this->override ) {
1022
-			$form['stats']['total']['donations']           = give_get_form_sales_stats( $form_info->ID );
1023
-			$form['stats']['total']['earnings']            = give_get_form_earnings_stats( $form_info->ID );
1024
-			$form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales( $form_info->ID );
1025
-			$form['stats']['monthly_average']['earnings']  = give_get_average_monthly_form_earnings( $form_info->ID );
1021
+		if (user_can($this->user_id, 'view_give_reports') || $this->override) {
1022
+			$form['stats']['total']['donations']           = give_get_form_sales_stats($form_info->ID);
1023
+			$form['stats']['total']['earnings']            = give_get_form_earnings_stats($form_info->ID);
1024
+			$form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales($form_info->ID);
1025
+			$form['stats']['monthly_average']['earnings']  = give_get_average_monthly_form_earnings($form_info->ID);
1026 1026
 		}
1027 1027
 
1028 1028
 		$counter = 0;
1029
-		if ( give_has_variable_prices( $form_info->ID ) ) {
1030
-			foreach ( give_get_variable_prices( $form_info->ID ) as $price ) {
1031
-				$counter ++;
1029
+		if (give_has_variable_prices($form_info->ID)) {
1030
+			foreach (give_get_variable_prices($form_info->ID) as $price) {
1031
+				$counter++;
1032 1032
 				//muli-level item
1033
-				$level                                     = isset( $price['_give_text'] ) ? $price['_give_text'] : 'level-' . $counter;
1034
-				$form['pricing'][ sanitize_key( $level ) ] = $price['_give_amount'];
1033
+				$level                                     = isset($price['_give_text']) ? $price['_give_text'] : 'level-'.$counter;
1034
+				$form['pricing'][sanitize_key($level)] = $price['_give_amount'];
1035 1035
 
1036 1036
 			}
1037 1037
 		} else {
1038
-			$form['pricing']['amount'] = give_get_form_price( $form_info->ID );
1038
+			$form['pricing']['amount'] = give_get_form_price($form_info->ID);
1039 1039
 		}
1040 1040
 
1041
-		if ( user_can( $this->user_id, 'view_give_sensitive_data' ) || $this->override ) {
1041
+		if (user_can($this->user_id, 'view_give_sensitive_data') || $this->override) {
1042 1042
 
1043 1043
 			//Sensitive data here
1044
-			do_action( 'give_api_sensitive_data' );
1044
+			do_action('give_api_sensitive_data');
1045 1045
 
1046 1046
 		}
1047 1047
 
1048
-		return apply_filters( 'give_api_forms_form', $form );
1048
+		return apply_filters('give_api_forms_form', $form);
1049 1049
 
1050 1050
 	}
1051 1051
 
@@ -1060,7 +1060,7 @@  discard block
 block discarded – undo
1060 1060
 	 *
1061 1061
 	 * @return array
1062 1062
 	 */
1063
-	public function get_stats( $args = array() ) {
1063
+	public function get_stats($args = array()) {
1064 1064
 		$defaults = array(
1065 1065
 			'type'      => null,
1066 1066
 			'form'      => null,
@@ -1069,9 +1069,9 @@  discard block
 block discarded – undo
1069 1069
 			'enddate'   => null
1070 1070
 		);
1071 1071
 
1072
-		$args = wp_parse_args( $args, $defaults );
1072
+		$args = wp_parse_args($args, $defaults);
1073 1073
 
1074
-		$dates = $this->get_dates( $args );
1074
+		$dates = $this->get_dates($args);
1075 1075
 
1076 1076
 		$stats    = array();
1077 1077
 		$earnings = array(
@@ -1082,41 +1082,41 @@  discard block
 block discarded – undo
1082 1082
 		);
1083 1083
 		$error    = array();
1084 1084
 
1085
-		if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) {
1085
+		if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) {
1086 1086
 			return $stats;
1087 1087
 		}
1088 1088
 
1089
-		if ( $args['type'] == 'donations' ) {
1089
+		if ($args['type'] == 'donations') {
1090 1090
 
1091
-			if ( $args['form'] == null ) {
1092
-				if ( $args['date'] == null ) {
1091
+			if ($args['form'] == null) {
1092
+				if ($args['date'] == null) {
1093 1093
 					$sales = $this->get_default_sales_stats();
1094
-				} elseif ( $args['date'] === 'range' ) {
1094
+				} elseif ($args['date'] === 'range') {
1095 1095
 					// Return sales for a date range
1096 1096
 
1097 1097
 					// Ensure the end date is later than the start date
1098
-					if ( $args['enddate'] < $args['startdate'] ) {
1099
-						$error['error'] = esc_html__( 'The end date must be later than the start date!', 'give' );
1098
+					if ($args['enddate'] < $args['startdate']) {
1099
+						$error['error'] = esc_html__('The end date must be later than the start date!', 'give');
1100 1100
 					}
1101 1101
 
1102 1102
 					// Ensure both the start and end date are specified
1103
-					if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) {
1104
-						$error['error'] = esc_html__( 'Invalid or no date range specified!', 'give' );
1103
+					if (empty($args['startdate']) || empty($args['enddate'])) {
1104
+						$error['error'] = esc_html__('Invalid or no date range specified!', 'give');
1105 1105
 					}
1106 1106
 
1107 1107
 					$total = 0;
1108 1108
 
1109 1109
 					// Loop through the years
1110 1110
 					$y = $dates['year'];
1111
-					while ( $y <= $dates['year_end'] ) :
1111
+					while ($y <= $dates['year_end']) :
1112 1112
 
1113
-						if ( $dates['year'] == $dates['year_end'] ) {
1113
+						if ($dates['year'] == $dates['year_end']) {
1114 1114
 							$month_start = $dates['m_start'];
1115 1115
 							$month_end   = $dates['m_end'];
1116
-						} elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) {
1116
+						} elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) {
1117 1117
 							$month_start = $dates['m_start'];
1118 1118
 							$month_end   = 12;
1119
-						} elseif ( $y == $dates['year_end'] ) {
1119
+						} elseif ($y == $dates['year_end']) {
1120 1120
 							$month_start = 1;
1121 1121
 							$month_end   = $dates['m_end'];
1122 1122
 						} else {
@@ -1125,113 +1125,113 @@  discard block
 block discarded – undo
1125 1125
 						}
1126 1126
 
1127 1127
 						$i = $month_start;
1128
-						while ( $i <= $month_end ) :
1128
+						while ($i <= $month_end) :
1129 1129
 
1130
-							if ( $i == $dates['m_start'] ) {
1130
+							if ($i == $dates['m_start']) {
1131 1131
 								$d = $dates['day_start'];
1132 1132
 							} else {
1133 1133
 								$d = 1;
1134 1134
 							}
1135 1135
 
1136
-							if ( $i == $dates['m_end'] ) {
1136
+							if ($i == $dates['m_end']) {
1137 1137
 								$num_of_days = $dates['day_end'];
1138 1138
 							} else {
1139
-								$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
1139
+								$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
1140 1140
 							}
1141 1141
 
1142
-							while ( $d <= $num_of_days ) :
1143
-								$sale_count = give_get_sales_by_date( $d, $i, $y );
1144
-								$date_key   = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) );
1145
-								if ( ! isset( $sales['sales'][ $date_key ] ) ) {
1146
-									$sales['sales'][ $date_key ] = 0;
1142
+							while ($d <= $num_of_days) :
1143
+								$sale_count = give_get_sales_by_date($d, $i, $y);
1144
+								$date_key   = date('Ymd', strtotime($y.'/'.$i.'/'.$d));
1145
+								if ( ! isset($sales['sales'][$date_key])) {
1146
+									$sales['sales'][$date_key] = 0;
1147 1147
 								}
1148
-								$sales['sales'][ $date_key ] += $sale_count;
1148
+								$sales['sales'][$date_key] += $sale_count;
1149 1149
 								$total += $sale_count;
1150
-								$d ++;
1150
+								$d++;
1151 1151
 							endwhile;
1152
-							$i ++;
1152
+							$i++;
1153 1153
 						endwhile;
1154 1154
 
1155
-						$y ++;
1155
+						$y++;
1156 1156
 					endwhile;
1157 1157
 
1158 1158
 					$sales['totals'] = $total;
1159 1159
 				} else {
1160
-					if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) {
1160
+					if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') {
1161 1161
 						$sales_count = 0;
1162 1162
 
1163 1163
 						// Loop through the months
1164 1164
 						$month = $dates['m_start'];
1165 1165
 
1166
-						while ( $month <= $dates['m_end'] ) :
1167
-							$sales_count += give_get_sales_by_date( null, $month, $dates['year'] );
1168
-							$month ++;
1166
+						while ($month <= $dates['m_end']) :
1167
+							$sales_count += give_get_sales_by_date(null, $month, $dates['year']);
1168
+							$month++;
1169 1169
 						endwhile;
1170 1170
 
1171
-						$sales['donations'][ $args['date'] ] = $sales_count;
1171
+						$sales['donations'][$args['date']] = $sales_count;
1172 1172
 					} else {
1173
-						$sales['donations'][ $args['date'] ] = give_get_sales_by_date( $dates['day'], $dates['m_start'], $dates['year'] );
1173
+						$sales['donations'][$args['date']] = give_get_sales_by_date($dates['day'], $dates['m_start'], $dates['year']);
1174 1174
 					}
1175 1175
 				}
1176
-			} elseif ( $args['form'] == 'all' ) {
1177
-				$forms = get_posts( array( 'post_type' => 'give_forms', 'nopaging' => true ) );
1176
+			} elseif ($args['form'] == 'all') {
1177
+				$forms = get_posts(array('post_type' => 'give_forms', 'nopaging' => true));
1178 1178
 				$i     = 0;
1179
-				foreach ( $forms as $form_info ) {
1180
-					$sales['donations'][ $i ] = array( $form_info->post_name => give_get_form_sales_stats( $form_info->ID ) );
1181
-					$i ++;
1179
+				foreach ($forms as $form_info) {
1180
+					$sales['donations'][$i] = array($form_info->post_name => give_get_form_sales_stats($form_info->ID));
1181
+					$i++;
1182 1182
 				}
1183 1183
 			} else {
1184
-				if ( get_post_type( $args['form'] ) == 'give_forms' ) {
1185
-					$form_info             = get_post( $args['form'] );
1186
-					$sales['donations'][0] = array( $form_info->post_name => give_get_form_sales_stats( $args['form'] ) );
1184
+				if (get_post_type($args['form']) == 'give_forms') {
1185
+					$form_info             = get_post($args['form']);
1186
+					$sales['donations'][0] = array($form_info->post_name => give_get_form_sales_stats($args['form']));
1187 1187
 				} else {
1188 1188
 					$error['error'] = sprintf(
1189 1189
 						/* translators: %s: form */
1190
-						esc_html__( 'Product %s not found!', 'give' ),
1190
+						esc_html__('Product %s not found!', 'give'),
1191 1191
 						$args['form']
1192 1192
 					);
1193 1193
 				}
1194 1194
 			}
1195 1195
 
1196
-			if ( ! empty( $error ) ) {
1196
+			if ( ! empty($error)) {
1197 1197
 				return $error;
1198 1198
 			}
1199 1199
 
1200 1200
 			return $sales;
1201 1201
 
1202
-		} elseif ( $args['type'] == 'earnings' ) {
1203
-			if ( $args['form'] == null ) {
1204
-				if ( $args['date'] == null ) {
1202
+		} elseif ($args['type'] == 'earnings') {
1203
+			if ($args['form'] == null) {
1204
+				if ($args['date'] == null) {
1205 1205
 					$earnings = $this->get_default_earnings_stats();
1206
-				} elseif ( $args['date'] === 'range' ) {
1206
+				} elseif ($args['date'] === 'range') {
1207 1207
 					// Return sales for a date range
1208 1208
 
1209 1209
 					// Ensure the end date is later than the start date
1210
-					if ( $args['enddate'] < $args['startdate'] ) {
1211
-						$error['error'] = esc_html__( 'The end date must be later than the start date!', 'give' );
1210
+					if ($args['enddate'] < $args['startdate']) {
1211
+						$error['error'] = esc_html__('The end date must be later than the start date!', 'give');
1212 1212
 					}
1213 1213
 
1214 1214
 					// Ensure both the start and end date are specified
1215
-					if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) {
1216
-						$error['error'] = esc_html__( 'Invalid or no date range specified!', 'give' );
1215
+					if (empty($args['startdate']) || empty($args['enddate'])) {
1216
+						$error['error'] = esc_html__('Invalid or no date range specified!', 'give');
1217 1217
 					}
1218 1218
 
1219 1219
 					$total = (float) 0.00;
1220 1220
 
1221 1221
 					// Loop through the years
1222 1222
 					$y = $dates['year'];
1223
-					if ( ! isset( $earnings['earnings'] ) ) {
1223
+					if ( ! isset($earnings['earnings'])) {
1224 1224
 						$earnings['earnings'] = array();
1225 1225
 					}
1226
-					while ( $y <= $dates['year_end'] ) :
1226
+					while ($y <= $dates['year_end']) :
1227 1227
 
1228
-						if ( $dates['year'] == $dates['year_end'] ) {
1228
+						if ($dates['year'] == $dates['year_end']) {
1229 1229
 							$month_start = $dates['m_start'];
1230 1230
 							$month_end   = $dates['m_end'];
1231
-						} elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) {
1231
+						} elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) {
1232 1232
 							$month_start = $dates['m_start'];
1233 1233
 							$month_end   = 12;
1234
-						} elseif ( $y == $dates['year_end'] ) {
1234
+						} elseif ($y == $dates['year_end']) {
1235 1235
 							$month_start = 1;
1236 1236
 							$month_end   = $dates['m_end'];
1237 1237
 						} else {
@@ -1240,92 +1240,92 @@  discard block
 block discarded – undo
1240 1240
 						}
1241 1241
 
1242 1242
 						$i = $month_start;
1243
-						while ( $i <= $month_end ) :
1243
+						while ($i <= $month_end) :
1244 1244
 
1245
-							if ( $i == $dates['m_start'] ) {
1245
+							if ($i == $dates['m_start']) {
1246 1246
 								$d = $dates['day_start'];
1247 1247
 							} else {
1248 1248
 								$d = 1;
1249 1249
 							}
1250 1250
 
1251
-							if ( $i == $dates['m_end'] ) {
1251
+							if ($i == $dates['m_end']) {
1252 1252
 								$num_of_days = $dates['day_end'];
1253 1253
 							} else {
1254
-								$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
1254
+								$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
1255 1255
 							}
1256 1256
 
1257
-							while ( $d <= $num_of_days ) :
1258
-								$earnings_stat = give_get_earnings_by_date( $d, $i, $y );
1259
-								$date_key      = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) );
1260
-								if ( ! isset( $earnings['earnings'][ $date_key ] ) ) {
1261
-									$earnings['earnings'][ $date_key ] = 0;
1257
+							while ($d <= $num_of_days) :
1258
+								$earnings_stat = give_get_earnings_by_date($d, $i, $y);
1259
+								$date_key      = date('Ymd', strtotime($y.'/'.$i.'/'.$d));
1260
+								if ( ! isset($earnings['earnings'][$date_key])) {
1261
+									$earnings['earnings'][$date_key] = 0;
1262 1262
 								}
1263
-								$earnings['earnings'][ $date_key ] += $earnings_stat;
1263
+								$earnings['earnings'][$date_key] += $earnings_stat;
1264 1264
 								$total += $earnings_stat;
1265
-								$d ++;
1265
+								$d++;
1266 1266
 							endwhile;
1267 1267
 
1268
-							$i ++;
1268
+							$i++;
1269 1269
 						endwhile;
1270 1270
 
1271
-						$y ++;
1271
+						$y++;
1272 1272
 					endwhile;
1273 1273
 
1274 1274
 					$earnings['totals'] = $total;
1275 1275
 				} else {
1276
-					if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) {
1276
+					if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') {
1277 1277
 						$earnings_count = (float) 0.00;
1278 1278
 
1279 1279
 						// Loop through the months
1280 1280
 						$month = $dates['m_start'];
1281 1281
 
1282
-						while ( $month <= $dates['m_end'] ) :
1283
-							$earnings_count += give_get_earnings_by_date( null, $month, $dates['year'] );
1284
-							$month ++;
1282
+						while ($month <= $dates['m_end']) :
1283
+							$earnings_count += give_get_earnings_by_date(null, $month, $dates['year']);
1284
+							$month++;
1285 1285
 						endwhile;
1286 1286
 
1287
-						$earnings['earnings'][ $args['date'] ] = $earnings_count;
1287
+						$earnings['earnings'][$args['date']] = $earnings_count;
1288 1288
 					} else {
1289
-						$earnings['earnings'][ $args['date'] ] = give_get_earnings_by_date( $dates['day'], $dates['m_start'], $dates['year'] );
1289
+						$earnings['earnings'][$args['date']] = give_get_earnings_by_date($dates['day'], $dates['m_start'], $dates['year']);
1290 1290
 					}
1291 1291
 				}
1292
-			} elseif ( $args['form'] == 'all' ) {
1293
-				$forms = get_posts( array( 'post_type' => 'give_forms', 'nopaging' => true ) );
1292
+			} elseif ($args['form'] == 'all') {
1293
+				$forms = get_posts(array('post_type' => 'give_forms', 'nopaging' => true));
1294 1294
 
1295 1295
 				$i = 0;
1296
-				foreach ( $forms as $form_info ) {
1297
-					$earnings['earnings'][ $i ] = array( $form_info->post_name => give_get_form_earnings_stats( $form_info->ID ) );
1298
-					$i ++;
1296
+				foreach ($forms as $form_info) {
1297
+					$earnings['earnings'][$i] = array($form_info->post_name => give_get_form_earnings_stats($form_info->ID));
1298
+					$i++;
1299 1299
 				}
1300 1300
 			} else {
1301
-				if ( get_post_type( $args['form'] ) == 'give_forms' ) {
1302
-					$form_info               = get_post( $args['form'] );
1303
-					$earnings['earnings'][0] = array( $form_info->post_name => give_get_form_earnings_stats( $args['form'] ) );
1301
+				if (get_post_type($args['form']) == 'give_forms') {
1302
+					$form_info               = get_post($args['form']);
1303
+					$earnings['earnings'][0] = array($form_info->post_name => give_get_form_earnings_stats($args['form']));
1304 1304
 				} else {
1305 1305
 					$error['error'] = sprintf(
1306 1306
 						/* translators: %s: form */
1307
-						esc_html__( 'Form %s not found!', 'give' ),
1307
+						esc_html__('Form %s not found!', 'give'),
1308 1308
 						$args['form']
1309 1309
 					);
1310 1310
 				}
1311 1311
 			}
1312 1312
 
1313
-			if ( ! empty( $error ) ) {
1313
+			if ( ! empty($error)) {
1314 1314
 				return $error;
1315 1315
 			}
1316 1316
 
1317 1317
 			return $earnings;
1318
-		} elseif ( $args['type'] == 'donors' ) {
1318
+		} elseif ($args['type'] == 'donors') {
1319 1319
 			$customers                          = new Give_DB_Customers();
1320 1320
 			$stats['donations']['total_donors'] = $customers->count();
1321 1321
 
1322 1322
 			return $stats;
1323 1323
 
1324
-		} elseif ( empty( $args['type'] ) ) {
1325
-			$stats = array_merge( $stats, $this->get_default_sales_stats() );
1326
-			$stats = array_merge( $stats, $this->get_default_earnings_stats() );
1324
+		} elseif (empty($args['type'])) {
1325
+			$stats = array_merge($stats, $this->get_default_sales_stats());
1326
+			$stats = array_merge($stats, $this->get_default_earnings_stats());
1327 1327
 
1328
-			return array( 'stats' => $stats );
1328
+			return array('stats' => $stats);
1329 1329
 		}
1330 1330
 	}
1331 1331
 
@@ -1341,18 +1341,18 @@  discard block
 block discarded – undo
1341 1341
 
1342 1342
 		$sales = array();
1343 1343
 
1344
-		if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) {
1344
+		if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) {
1345 1345
 			return $sales;
1346 1346
 		}
1347 1347
 
1348
-		if ( isset( $wp_query->query_vars['id'] ) ) {
1348
+		if (isset($wp_query->query_vars['id'])) {
1349 1349
 			$query   = array();
1350
-			$query[] = new Give_Payment( $wp_query->query_vars['id'] );
1351
-		} elseif ( isset( $wp_query->query_vars['purchasekey'] ) ) {
1350
+			$query[] = new Give_Payment($wp_query->query_vars['id']);
1351
+		} elseif (isset($wp_query->query_vars['purchasekey'])) {
1352 1352
 			$query   = array();
1353
-			$query[] = give_get_payment_by( 'key', $wp_query->query_vars['purchasekey'] );
1354
-		} elseif ( isset( $wp_query->query_vars['email'] ) ) {
1355
-			$args  = array(
1353
+			$query[] = give_get_payment_by('key', $wp_query->query_vars['purchasekey']);
1354
+		} elseif (isset($wp_query->query_vars['email'])) {
1355
+			$args = array(
1356 1356
 				'fields'     => 'ids',
1357 1357
 				'meta_key'   => '_give_payment_user_email',
1358 1358
 				'meta_value' => $wp_query->query_vars['email'],
@@ -1360,7 +1360,7 @@  discard block
 block discarded – undo
1360 1360
 				'page'       => $this->get_paged(),
1361 1361
 				'status'     => 'publish'
1362 1362
 			);
1363
-			$query = give_get_payments( $args );
1363
+			$query = give_get_payments($args);
1364 1364
 		} else {
1365 1365
 			$args  = array(
1366 1366
 				'fields' => 'ids',
@@ -1368,14 +1368,14 @@  discard block
 block discarded – undo
1368 1368
 				'page'   => $this->get_paged(),
1369 1369
 				'status' => 'publish'
1370 1370
 			);
1371
-			$query = give_get_payments( $args );
1371
+			$query = give_get_payments($args);
1372 1372
 		}
1373
-		if ( $query ) {
1373
+		if ($query) {
1374 1374
 			$i = 0;
1375
-			foreach ( $query as $payment ) {
1375
+			foreach ($query as $payment) {
1376 1376
 
1377
-				if ( is_numeric( $payment ) ) {
1378
-					$payment      = new Give_Payment( $payment );
1377
+				if (is_numeric($payment)) {
1378
+					$payment      = new Give_Payment($payment);
1379 1379
 					$payment_meta = $payment->get_meta();
1380 1380
 					$user_info    = $payment->user_info;
1381 1381
 				} else {
@@ -1385,40 +1385,40 @@  discard block
 block discarded – undo
1385 1385
 				$payment_meta = $payment->get_meta();
1386 1386
 				$user_info    = $payment->user_info;
1387 1387
 
1388
-				$first_name = isset( $user_info['first_name'] ) ? $user_info['first_name'] : '';
1389
-				$last_name  = isset( $user_info['last_name'] ) ? $user_info['last_name'] : '';
1390
-
1391
-				$sales['donations'][ $i ]['ID']             = $payment->number;
1392
-				$sales['donations'][ $i ]['transaction_id'] = $payment->transaction_id;
1393
-				$sales['donations'][ $i ]['key']            = $payment->key;
1394
-				$sales['donations'][ $i ]['total']          = $payment->total;
1395
-				$sales['donations'][ $i ]['gateway']        = $payment->gateway;
1396
-				$sales['donations'][ $i ]['name']           = $first_name . ' ' . $last_name;
1397
-				$sales['donations'][ $i ]['fname']          = $first_name;
1398
-				$sales['donations'][ $i ]['lname']          = $last_name;
1399
-				$sales['donations'][ $i ]['email']          = $payment->email;
1400
-				$sales['donations'][ $i ]['date']           = $payment->date;
1401
-
1402
-				$form_id  = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : $payment_meta;
1403
-				$price    = isset( $payment_meta['form_id'] ) ? give_get_form_price( $payment_meta['form_id'] ) : false;
1404
-				$price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null;
1405
-
1406
-				$sales['donations'][ $i ]['form']['id']    = $form_id;
1407
-				$sales['donations'][ $i ]['form']['name']  = get_the_title( $payment_meta['form_id'] );
1408
-				$sales['donations'][ $i ]['form']['price'] = $price;
1409
-
1410
-				if ( give_has_variable_prices( $form_id ) ) {
1411
-					if ( isset( $payment_meta['price_id'] ) ) {
1412
-						$price_name                                     = give_get_price_option_name( $form_id, $payment_meta['price_id'], $payment->ID );
1413
-						$sales['donations'][ $i ]['form']['price_name'] = $price_name;
1414
-						$sales['donations'][ $i ]['form']['price_id']   = $price_id;
1415
-						$sales['donations'][ $i ]['form']['price']      = give_get_price_option_amount( $form_id, $price_id );
1388
+				$first_name = isset($user_info['first_name']) ? $user_info['first_name'] : '';
1389
+				$last_name  = isset($user_info['last_name']) ? $user_info['last_name'] : '';
1390
+
1391
+				$sales['donations'][$i]['ID']             = $payment->number;
1392
+				$sales['donations'][$i]['transaction_id'] = $payment->transaction_id;
1393
+				$sales['donations'][$i]['key']            = $payment->key;
1394
+				$sales['donations'][$i]['total']          = $payment->total;
1395
+				$sales['donations'][$i]['gateway']        = $payment->gateway;
1396
+				$sales['donations'][$i]['name']           = $first_name.' '.$last_name;
1397
+				$sales['donations'][$i]['fname']          = $first_name;
1398
+				$sales['donations'][$i]['lname']          = $last_name;
1399
+				$sales['donations'][$i]['email']          = $payment->email;
1400
+				$sales['donations'][$i]['date']           = $payment->date;
1401
+
1402
+				$form_id  = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : $payment_meta;
1403
+				$price    = isset($payment_meta['form_id']) ? give_get_form_price($payment_meta['form_id']) : false;
1404
+				$price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null;
1405
+
1406
+				$sales['donations'][$i]['form']['id']    = $form_id;
1407
+				$sales['donations'][$i]['form']['name']  = get_the_title($payment_meta['form_id']);
1408
+				$sales['donations'][$i]['form']['price'] = $price;
1409
+
1410
+				if (give_has_variable_prices($form_id)) {
1411
+					if (isset($payment_meta['price_id'])) {
1412
+						$price_name                                     = give_get_price_option_name($form_id, $payment_meta['price_id'], $payment->ID);
1413
+						$sales['donations'][$i]['form']['price_name'] = $price_name;
1414
+						$sales['donations'][$i]['form']['price_id']   = $price_id;
1415
+						$sales['donations'][$i]['form']['price']      = give_get_price_option_amount($form_id, $price_id);
1416 1416
 
1417 1417
 					}
1418 1418
 				}
1419 1419
 
1420 1420
 				//Add custom meta to API
1421
-				foreach ( $payment_meta as $meta_key => $meta_value ) {
1421
+				foreach ($payment_meta as $meta_key => $meta_value) {
1422 1422
 
1423 1423
 					$exceptions = array(
1424 1424
 						'form_title',
@@ -1431,19 +1431,19 @@  discard block
 block discarded – undo
1431 1431
 					);
1432 1432
 
1433 1433
 					//Don't clutter up results with dupes
1434
-					if ( in_array( $meta_key, $exceptions ) ) {
1434
+					if (in_array($meta_key, $exceptions)) {
1435 1435
 						continue;
1436 1436
 					}
1437 1437
 
1438
-					$sales['donations'][ $i ]['payment_meta'][ $meta_key ] = $meta_value;
1438
+					$sales['donations'][$i]['payment_meta'][$meta_key] = $meta_value;
1439 1439
 
1440 1440
 				}
1441 1441
 
1442
-				$i ++;
1442
+				$i++;
1443 1443
 			}
1444 1444
 		}
1445 1445
 
1446
-		return apply_filters( 'give_api_donations_endpoint', $sales );
1446
+		return apply_filters('give_api_donations_endpoint', $sales);
1447 1447
 	}
1448 1448
 
1449 1449
 	/**
@@ -1458,9 +1458,9 @@  discard block
 block discarded – undo
1458 1458
 	public function get_output_format() {
1459 1459
 		global $wp_query;
1460 1460
 
1461
-		$format = isset( $wp_query->query_vars['format'] ) ? $wp_query->query_vars['format'] : 'json';
1461
+		$format = isset($wp_query->query_vars['format']) ? $wp_query->query_vars['format'] : 'json';
1462 1462
 
1463
-		return apply_filters( 'give_api_output_format', $format );
1463
+		return apply_filters('give_api_output_format', $format);
1464 1464
 	}
1465 1465
 
1466 1466
 
@@ -1476,8 +1476,8 @@  discard block
 block discarded – undo
1476 1476
 	 *
1477 1477
 	 * @return void
1478 1478
 	 */
1479
-	private function log_request( $data = array() ) {
1480
-		if ( ! $this->log_requests ) {
1479
+	private function log_request($data = array()) {
1480
+		if ( ! $this->log_requests) {
1481 1481
 			return;
1482 1482
 		}
1483 1483
 
@@ -1485,36 +1485,36 @@  discard block
 block discarded – undo
1485 1485
 
1486 1486
 		$query = array(
1487 1487
 			'give-api'    => $wp_query->query_vars['give-api'],
1488
-			'key'         => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null,
1489
-			'token'       => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null,
1490
-			'query'       => isset( $wp_query->query_vars['query'] ) ? $wp_query->query_vars['query'] : null,
1491
-			'type'        => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null,
1492
-			'form'        => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null,
1493
-			'customer'    => isset( $wp_query->query_vars['customer'] ) ? $wp_query->query_vars['customer'] : null,
1494
-			'date'        => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null,
1495
-			'startdate'   => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null,
1496
-			'enddate'     => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null,
1497
-			'id'          => isset( $wp_query->query_vars['id'] ) ? $wp_query->query_vars['id'] : null,
1498
-			'purchasekey' => isset( $wp_query->query_vars['purchasekey'] ) ? $wp_query->query_vars['purchasekey'] : null,
1499
-			'email'       => isset( $wp_query->query_vars['email'] ) ? $wp_query->query_vars['email'] : null,
1488
+			'key'         => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null,
1489
+			'token'       => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null,
1490
+			'query'       => isset($wp_query->query_vars['query']) ? $wp_query->query_vars['query'] : null,
1491
+			'type'        => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null,
1492
+			'form'        => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null,
1493
+			'customer'    => isset($wp_query->query_vars['customer']) ? $wp_query->query_vars['customer'] : null,
1494
+			'date'        => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null,
1495
+			'startdate'   => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null,
1496
+			'enddate'     => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null,
1497
+			'id'          => isset($wp_query->query_vars['id']) ? $wp_query->query_vars['id'] : null,
1498
+			'purchasekey' => isset($wp_query->query_vars['purchasekey']) ? $wp_query->query_vars['purchasekey'] : null,
1499
+			'email'       => isset($wp_query->query_vars['email']) ? $wp_query->query_vars['email'] : null,
1500 1500
 		);
1501 1501
 
1502 1502
 		$log_data = array(
1503 1503
 			'log_type'     => 'api_request',
1504
-			'post_excerpt' => http_build_query( $query ),
1505
-			'post_content' => ! empty( $data['error'] ) ? $data['error'] : '',
1504
+			'post_excerpt' => http_build_query($query),
1505
+			'post_content' => ! empty($data['error']) ? $data['error'] : '',
1506 1506
 		);
1507 1507
 
1508 1508
 		$log_meta = array(
1509 1509
 			'request_ip' => give_get_ip(),
1510 1510
 			'user'       => $this->user_id,
1511
-			'key'        => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null,
1512
-			'token'      => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null,
1511
+			'key'        => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null,
1512
+			'token'      => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null,
1513 1513
 			'time'       => $data['request_speed'],
1514 1514
 			'version'    => $this->get_queried_version()
1515 1515
 		);
1516 1516
 
1517
-		$give_logs->insert_log( $log_data, $log_meta );
1517
+		$give_logs->insert_log($log_data, $log_meta);
1518 1518
 	}
1519 1519
 
1520 1520
 
@@ -1538,32 +1538,32 @@  discard block
 block discarded – undo
1538 1538
 	 *
1539 1539
 	 * @param int $status_code
1540 1540
 	 */
1541
-	public function output( $status_code = 200 ) {
1541
+	public function output($status_code = 200) {
1542 1542
 		global $wp_query;
1543 1543
 
1544 1544
 		$format = $this->get_output_format();
1545 1545
 
1546
-		status_header( $status_code );
1546
+		status_header($status_code);
1547 1547
 
1548
-		do_action( 'give_api_output_before', $this->data, $this, $format );
1548
+		do_action('give_api_output_before', $this->data, $this, $format);
1549 1549
 
1550
-		switch ( $format ) :
1550
+		switch ($format) :
1551 1551
 
1552 1552
 			case 'xml' :
1553 1553
 
1554
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/array2xml.php';
1555
-				$xml = Array2XML::createXML( 'give', $this->data );
1554
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/array2xml.php';
1555
+				$xml = Array2XML::createXML('give', $this->data);
1556 1556
 				echo $xml->saveXML();
1557 1557
 
1558 1558
 				break;
1559 1559
 
1560 1560
 			case 'json' :
1561 1561
 
1562
-				header( 'Content-Type: application/json' );
1563
-				if ( ! empty( $this->pretty_print ) ) {
1564
-					echo json_encode( $this->data, $this->pretty_print );
1562
+				header('Content-Type: application/json');
1563
+				if ( ! empty($this->pretty_print)) {
1564
+					echo json_encode($this->data, $this->pretty_print);
1565 1565
 				} else {
1566
-					echo json_encode( $this->data );
1566
+					echo json_encode($this->data);
1567 1567
 				}
1568 1568
 
1569 1569
 				break;
@@ -1572,13 +1572,13 @@  discard block
 block discarded – undo
1572 1572
 			default :
1573 1573
 
1574 1574
 				// Allow other formats to be added via extensions
1575
-				do_action( 'give_api_output_' . $format, $this->data, $this );
1575
+				do_action('give_api_output_'.$format, $this->data, $this);
1576 1576
 
1577 1577
 				break;
1578 1578
 
1579 1579
 		endswitch;
1580 1580
 
1581
-		do_action( 'give_api_output_after', $this->data, $this, $format );
1581
+		do_action('give_api_output_after', $this->data, $this, $format);
1582 1582
 
1583 1583
 		give_die();
1584 1584
 	}
@@ -1595,37 +1595,37 @@  discard block
 block discarded – undo
1595 1595
 	 *
1596 1596
 	 * @return void
1597 1597
 	 */
1598
-	function user_key_field( $user ) {
1598
+	function user_key_field($user) {
1599 1599
 
1600
-		if ( ( give_get_option( 'api_allow_user_keys', false ) || current_user_can( 'manage_give_settings' ) ) && current_user_can( 'edit_user', $user->ID ) ) {
1601
-			$user = get_userdata( $user->ID );
1600
+		if ((give_get_option('api_allow_user_keys', false) || current_user_can('manage_give_settings')) && current_user_can('edit_user', $user->ID)) {
1601
+			$user = get_userdata($user->ID);
1602 1602
 			?>
1603 1603
 			<table class="form-table">
1604 1604
 				<tbody>
1605 1605
 				<tr>
1606 1606
 					<th>
1607
-						<?php esc_html_e( 'Give API Keys', 'give' ); ?>
1607
+						<?php esc_html_e('Give API Keys', 'give'); ?>
1608 1608
 					</th>
1609 1609
 					<td>
1610 1610
 						<?php
1611
-						$public_key = $this->get_user_public_key( $user->ID );
1612
-						$secret_key = $this->get_user_secret_key( $user->ID );
1611
+						$public_key = $this->get_user_public_key($user->ID);
1612
+						$secret_key = $this->get_user_secret_key($user->ID);
1613 1613
 						?>
1614
-						<?php if ( empty( $user->give_user_public_key ) ) { ?>
1614
+						<?php if (empty($user->give_user_public_key)) { ?>
1615 1615
 							<input name="give_set_api_key" type="checkbox" id="give_set_api_key" value="0"/>
1616
-							<span class="description"><?php esc_html_e( 'Generate API Key', 'give' ); ?></span>
1616
+							<span class="description"><?php esc_html_e('Generate API Key', 'give'); ?></span>
1617 1617
 						<?php } else { ?>
1618
-							<strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Public key:', 'give' ); ?>&nbsp;</strong>
1619
-							<input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php esc_attr_e( $public_key ); ?>"/>
1618
+							<strong style="display:inline-block; width: 125px;"><?php esc_html_e('Public key:', 'give'); ?>&nbsp;</strong>
1619
+							<input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php esc_attr_e($public_key); ?>"/>
1620 1620
 							<br/>
1621
-							<strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Secret key:', 'give' ); ?>&nbsp;</strong>
1622
-							<input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php esc_attr_e( $secret_key ); ?>"/>
1621
+							<strong style="display:inline-block; width: 125px;"><?php esc_html_e('Secret key:', 'give'); ?>&nbsp;</strong>
1622
+							<input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php esc_attr_e($secret_key); ?>"/>
1623 1623
 							<br/>
1624
-							<strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Token:', 'give' ); ?>&nbsp;</strong>
1625
-							<input type="text" disabled="disabled" class="regular-text" id="token" value="<?php esc_attr_e( $this->get_token( $user->ID ) ); ?>"/>
1624
+							<strong style="display:inline-block; width: 125px;"><?php esc_html_e('Token:', 'give'); ?>&nbsp;</strong>
1625
+							<input type="text" disabled="disabled" class="regular-text" id="token" value="<?php esc_attr_e($this->get_token($user->ID)); ?>"/>
1626 1626
 							<br/>
1627 1627
 							<input name="give_set_api_key" type="checkbox" id="give_set_api_key" value="0"/>
1628
-							<span class="description"><label for="give_set_api_key"><?php esc_html_e( 'Revoke API Keys', 'give' ); ?></label></span>
1628
+							<span class="description"><label for="give_set_api_key"><?php esc_html_e('Revoke API Keys', 'give'); ?></label></span>
1629 1629
 						<?php } ?>
1630 1630
 					</td>
1631 1631
 				</tr>
@@ -1644,69 +1644,69 @@  discard block
 block discarded – undo
1644 1644
 	 *
1645 1645
 	 * @return void
1646 1646
 	 */
1647
-	public function process_api_key( $args ) {
1647
+	public function process_api_key($args) {
1648 1648
 
1649
-		if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'give-api-nonce' ) ) {
1649
+		if ( ! wp_verify_nonce($_REQUEST['_wpnonce'], 'give-api-nonce')) {
1650 1650
 
1651
-			wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
1651
+			wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
1652 1652
 
1653 1653
 		}
1654 1654
 
1655
-		if ( empty( $args['user_id'] ) ) {
1656
-			wp_die( esc_html__( 'User ID Required.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 401 ) );
1655
+		if (empty($args['user_id'])) {
1656
+			wp_die(esc_html__('User ID Required.', 'give'), esc_html__('Error', 'give'), array('response' => 401));
1657 1657
 		}
1658 1658
 
1659
-		if ( is_numeric( $args['user_id'] ) ) {
1660
-			$user_id = isset( $args['user_id'] ) ? absint( $args['user_id'] ) : get_current_user_id();
1659
+		if (is_numeric($args['user_id'])) {
1660
+			$user_id = isset($args['user_id']) ? absint($args['user_id']) : get_current_user_id();
1661 1661
 		} else {
1662
-			$userdata = get_user_by( 'login', $args['user_id'] );
1662
+			$userdata = get_user_by('login', $args['user_id']);
1663 1663
 			$user_id  = $userdata->ID;
1664 1664
 		}
1665
-		$process = isset( $args['give_api_process'] ) ? strtolower( $args['give_api_process'] ) : false;
1665
+		$process = isset($args['give_api_process']) ? strtolower($args['give_api_process']) : false;
1666 1666
 
1667
-		if ( $user_id == get_current_user_id() && ! give_get_option( 'allow_user_api_keys' ) && ! current_user_can( 'manage_give_settings' ) ) {
1667
+		if ($user_id == get_current_user_id() && ! give_get_option('allow_user_api_keys') && ! current_user_can('manage_give_settings')) {
1668 1668
 			wp_die(
1669 1669
 				sprintf(
1670 1670
 					/* translators: %s: process */
1671
-					esc_html__( 'You do not have permission to %s API keys for this user.', 'give' ),
1671
+					esc_html__('You do not have permission to %s API keys for this user.', 'give'),
1672 1672
 					$process
1673 1673
 				),
1674
-				esc_html__( 'Error', 'give' ),
1675
-				array( 'response' => 403 )
1674
+				esc_html__('Error', 'give'),
1675
+				array('response' => 403)
1676 1676
 			);
1677
-		} elseif ( ! current_user_can( 'manage_give_settings' ) ) {
1677
+		} elseif ( ! current_user_can('manage_give_settings')) {
1678 1678
 			wp_die(
1679 1679
 				sprintf(
1680 1680
 					/* translators: %s: process */
1681
-					esc_html__( 'You do not have permission to %s API keys for this user.', 'give' ),
1681
+					esc_html__('You do not have permission to %s API keys for this user.', 'give'),
1682 1682
 					$process
1683 1683
 				),
1684
-				esc_html__( 'Error', 'give' ),
1685
-				array( 'response' => 403 )
1684
+				esc_html__('Error', 'give'),
1685
+				array('response' => 403)
1686 1686
 			);
1687 1687
 		}
1688 1688
 
1689
-		switch ( $process ) {
1689
+		switch ($process) {
1690 1690
 			case 'generate':
1691
-				if ( $this->generate_api_key( $user_id ) ) {
1692
-					delete_transient( 'give-total-api-keys' );
1693
-					wp_redirect( add_query_arg( 'give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) );
1691
+				if ($this->generate_api_key($user_id)) {
1692
+					delete_transient('give-total-api-keys');
1693
+					wp_redirect(add_query_arg('give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-settings&tab=api'));
1694 1694
 					exit();
1695 1695
 				} else {
1696
-					wp_redirect( add_query_arg( 'give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) );
1696
+					wp_redirect(add_query_arg('give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-settings&tab=api'));
1697 1697
 					exit();
1698 1698
 				}
1699 1699
 				break;
1700 1700
 			case 'regenerate':
1701
-				$this->generate_api_key( $user_id, true );
1702
-				delete_transient( 'give-total-api-keys' );
1703
-				wp_redirect( add_query_arg( 'give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) );
1701
+				$this->generate_api_key($user_id, true);
1702
+				delete_transient('give-total-api-keys');
1703
+				wp_redirect(add_query_arg('give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-settings&tab=api'));
1704 1704
 				exit();
1705 1705
 				break;
1706 1706
 			case 'revoke':
1707
-				$this->revoke_api_key( $user_id );
1708
-				delete_transient( 'give-total-api-keys' );
1709
-				wp_redirect( add_query_arg( 'give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) );
1707
+				$this->revoke_api_key($user_id);
1708
+				delete_transient('give-total-api-keys');
1709
+				wp_redirect(add_query_arg('give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-settings&tab=api'));
1710 1710
 				exit();
1711 1711
 				break;
1712 1712
 			default;
@@ -1725,34 +1725,34 @@  discard block
 block discarded – undo
1725 1725
 	 *
1726 1726
 	 * @return boolean True if (re)generated succesfully, false otherwise.
1727 1727
 	 */
1728
-	public function generate_api_key( $user_id = 0, $regenerate = false ) {
1728
+	public function generate_api_key($user_id = 0, $regenerate = false) {
1729 1729
 
1730
-		if ( empty( $user_id ) ) {
1730
+		if (empty($user_id)) {
1731 1731
 			return false;
1732 1732
 		}
1733 1733
 
1734
-		$user = get_userdata( $user_id );
1734
+		$user = get_userdata($user_id);
1735 1735
 
1736
-		if ( ! $user ) {
1736
+		if ( ! $user) {
1737 1737
 			return false;
1738 1738
 		}
1739 1739
 
1740
-		$public_key = $this->get_user_public_key( $user_id );
1741
-		$secret_key = $this->get_user_secret_key( $user_id );
1740
+		$public_key = $this->get_user_public_key($user_id);
1741
+		$secret_key = $this->get_user_secret_key($user_id);
1742 1742
 
1743
-		if ( empty( $public_key ) || $regenerate == true ) {
1744
-			$new_public_key = $this->generate_public_key( $user->user_email );
1745
-			$new_secret_key = $this->generate_private_key( $user->ID );
1743
+		if (empty($public_key) || $regenerate == true) {
1744
+			$new_public_key = $this->generate_public_key($user->user_email);
1745
+			$new_secret_key = $this->generate_private_key($user->ID);
1746 1746
 		} else {
1747 1747
 			return false;
1748 1748
 		}
1749 1749
 
1750
-		if ( $regenerate == true ) {
1751
-			$this->revoke_api_key( $user->ID );
1750
+		if ($regenerate == true) {
1751
+			$this->revoke_api_key($user->ID);
1752 1752
 		}
1753 1753
 
1754
-		update_user_meta( $user_id, $new_public_key, 'give_user_public_key' );
1755
-		update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' );
1754
+		update_user_meta($user_id, $new_public_key, 'give_user_public_key');
1755
+		update_user_meta($user_id, $new_secret_key, 'give_user_secret_key');
1756 1756
 
1757 1757
 		return true;
1758 1758
 	}
@@ -1767,26 +1767,26 @@  discard block
 block discarded – undo
1767 1767
 	 *
1768 1768
 	 * @return string
1769 1769
 	 */
1770
-	public function revoke_api_key( $user_id = 0 ) {
1770
+	public function revoke_api_key($user_id = 0) {
1771 1771
 
1772
-		if ( empty( $user_id ) ) {
1772
+		if (empty($user_id)) {
1773 1773
 			return false;
1774 1774
 		}
1775 1775
 
1776
-		$user = get_userdata( $user_id );
1776
+		$user = get_userdata($user_id);
1777 1777
 
1778
-		if ( ! $user ) {
1778
+		if ( ! $user) {
1779 1779
 			return false;
1780 1780
 		}
1781 1781
 
1782
-		$public_key = $this->get_user_public_key( $user_id );
1783
-		$secret_key = $this->get_user_secret_key( $user_id );
1784
-		if ( ! empty( $public_key ) ) {
1785
-			delete_transient( md5( 'give_api_user_' . $public_key ) );
1786
-			delete_transient( md5( 'give_api_user_public_key' . $user_id ) );
1787
-			delete_transient( md5( 'give_api_user_secret_key' . $user_id ) );
1788
-			delete_user_meta( $user_id, $public_key );
1789
-			delete_user_meta( $user_id, $secret_key );
1782
+		$public_key = $this->get_user_public_key($user_id);
1783
+		$secret_key = $this->get_user_secret_key($user_id);
1784
+		if ( ! empty($public_key)) {
1785
+			delete_transient(md5('give_api_user_'.$public_key));
1786
+			delete_transient(md5('give_api_user_public_key'.$user_id));
1787
+			delete_transient(md5('give_api_user_secret_key'.$user_id));
1788
+			delete_user_meta($user_id, $public_key);
1789
+			delete_user_meta($user_id, $secret_key);
1790 1790
 		} else {
1791 1791
 			return false;
1792 1792
 		}
@@ -1811,22 +1811,22 @@  discard block
 block discarded – undo
1811 1811
 	 *
1812 1812
 	 * @return void
1813 1813
 	 */
1814
-	public function update_key( $user_id ) {
1815
-		if ( current_user_can( 'edit_user', $user_id ) && isset( $_POST['give_set_api_key'] ) ) {
1814
+	public function update_key($user_id) {
1815
+		if (current_user_can('edit_user', $user_id) && isset($_POST['give_set_api_key'])) {
1816 1816
 
1817
-			$user = get_userdata( $user_id );
1817
+			$user = get_userdata($user_id);
1818 1818
 
1819
-			$public_key = $this->get_user_public_key( $user_id );
1820
-			$secret_key = $this->get_user_secret_key( $user_id );
1819
+			$public_key = $this->get_user_public_key($user_id);
1820
+			$secret_key = $this->get_user_secret_key($user_id);
1821 1821
 
1822
-			if ( empty( $public_key ) ) {
1823
-				$new_public_key = $this->generate_public_key( $user->user_email );
1824
-				$new_secret_key = $this->generate_private_key( $user->ID );
1822
+			if (empty($public_key)) {
1823
+				$new_public_key = $this->generate_public_key($user->user_email);
1824
+				$new_secret_key = $this->generate_private_key($user->ID);
1825 1825
 
1826
-				update_user_meta( $user_id, $new_public_key, 'give_user_public_key' );
1827
-				update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' );
1826
+				update_user_meta($user_id, $new_public_key, 'give_user_public_key');
1827
+				update_user_meta($user_id, $new_secret_key, 'give_user_secret_key');
1828 1828
 			} else {
1829
-				$this->revoke_api_key( $user_id );
1829
+				$this->revoke_api_key($user_id);
1830 1830
 			}
1831 1831
 		}
1832 1832
 	}
@@ -1841,9 +1841,9 @@  discard block
 block discarded – undo
1841 1841
 	 *
1842 1842
 	 * @return string
1843 1843
 	 */
1844
-	private function generate_public_key( $user_email = '' ) {
1845
-		$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
1846
-		$public   = hash( 'md5', $user_email . $auth_key . date( 'U' ) );
1844
+	private function generate_public_key($user_email = '') {
1845
+		$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
1846
+		$public   = hash('md5', $user_email.$auth_key.date('U'));
1847 1847
 
1848 1848
 		return $public;
1849 1849
 	}
@@ -1858,9 +1858,9 @@  discard block
 block discarded – undo
1858 1858
 	 *
1859 1859
 	 * @return string
1860 1860
 	 */
1861
-	private function generate_private_key( $user_id = 0 ) {
1862
-		$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
1863
-		$secret   = hash( 'md5', $user_id . $auth_key . date( 'U' ) );
1861
+	private function generate_private_key($user_id = 0) {
1862
+		$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
1863
+		$secret   = hash('md5', $user_id.$auth_key.date('U'));
1864 1864
 
1865 1865
 		return $secret;
1866 1866
 	}
@@ -1875,8 +1875,8 @@  discard block
 block discarded – undo
1875 1875
 	 *
1876 1876
 	 * @return string
1877 1877
 	 */
1878
-	public function get_token( $user_id = 0 ) {
1879
-		return hash( 'md5', $this->get_user_secret_key( $user_id ) . $this->get_user_public_key( $user_id ) );
1878
+	public function get_token($user_id = 0) {
1879
+		return hash('md5', $this->get_user_secret_key($user_id).$this->get_user_public_key($user_id));
1880 1880
 	}
1881 1881
 
1882 1882
 	/**
@@ -1890,9 +1890,9 @@  discard block
 block discarded – undo
1890 1890
 
1891 1891
 		// Default sales return
1892 1892
 		$sales                               = array();
1893
-		$sales['donations']['today']         = $this->stats->get_sales( 0, 'today' );
1894
-		$sales['donations']['current_month'] = $this->stats->get_sales( 0, 'this_month' );
1895
-		$sales['donations']['last_month']    = $this->stats->get_sales( 0, 'last_month' );
1893
+		$sales['donations']['today']         = $this->stats->get_sales(0, 'today');
1894
+		$sales['donations']['current_month'] = $this->stats->get_sales(0, 'this_month');
1895
+		$sales['donations']['last_month']    = $this->stats->get_sales(0, 'last_month');
1896 1896
 		$sales['donations']['totals']        = give_get_total_sales();
1897 1897
 
1898 1898
 		return $sales;
@@ -1909,9 +1909,9 @@  discard block
 block discarded – undo
1909 1909
 
1910 1910
 		// Default earnings return
1911 1911
 		$earnings                              = array();
1912
-		$earnings['earnings']['today']         = $this->stats->get_earnings( 0, 'today' );
1913
-		$earnings['earnings']['current_month'] = $this->stats->get_earnings( 0, 'this_month' );
1914
-		$earnings['earnings']['last_month']    = $this->stats->get_earnings( 0, 'last_month' );
1912
+		$earnings['earnings']['today']         = $this->stats->get_earnings(0, 'today');
1913
+		$earnings['earnings']['current_month'] = $this->stats->get_earnings(0, 'this_month');
1914
+		$earnings['earnings']['last_month']    = $this->stats->get_earnings(0, 'last_month');
1915 1915
 		$earnings['earnings']['totals']        = give_get_total_earnings();
1916 1916
 
1917 1917
 		return $earnings;
@@ -1931,25 +1931,25 @@  discard block
 block discarded – undo
1931 1931
 	 *
1932 1932
 	 * @return string            The API key/secret for the user supplied
1933 1933
 	 */
1934
-	public function api_key_backwards_compat( $check, $object_id, $meta_key, $single ) {
1934
+	public function api_key_backwards_compat($check, $object_id, $meta_key, $single) {
1935 1935
 
1936
-		if ( $meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key' ) {
1936
+		if ($meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key') {
1937 1937
 			return $check;
1938 1938
 		}
1939 1939
 
1940 1940
 		$return = $check;
1941 1941
 
1942
-		switch ( $meta_key ) {
1942
+		switch ($meta_key) {
1943 1943
 			case 'give_user_public_key':
1944
-				$return = Give()->api->get_user_public_key( $object_id );
1944
+				$return = Give()->api->get_user_public_key($object_id);
1945 1945
 				break;
1946 1946
 			case 'give_user_secret_key':
1947
-				$return = Give()->api->get_user_secret_key( $object_id );
1947
+				$return = Give()->api->get_user_secret_key($object_id);
1948 1948
 				break;
1949 1949
 		}
1950 1950
 
1951
-		if ( ! $single ) {
1952
-			$return = array( $return );
1951
+		if ( ! $single) {
1952
+			$return = array($return);
1953 1953
 		}
1954 1954
 
1955 1955
 		return $return;
Please login to merge, or discard this patch.
includes/user-functions.php 1 patch
Spacing   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -30,36 +30,36 @@  discard block
 block discarded – undo
30 30
  *
31 31
  * @return bool|object List of all user purchases
32 32
  */
33
-function give_get_users_purchases( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) {
33
+function give_get_users_purchases($user = 0, $number = 20, $pagination = false, $status = 'complete') {
34 34
 
35
-	if ( empty( $user ) ) {
35
+	if (empty($user)) {
36 36
 		$user = get_current_user_id();
37 37
 	}
38 38
 
39
-	if ( 0 === $user && ! Give()->email_access->token_exists ) {
39
+	if (0 === $user && ! Give()->email_access->token_exists) {
40 40
 		return false;
41 41
 	}
42 42
 
43 43
 	$status = $status === 'complete' ? 'publish' : $status;
44 44
 
45
-	if ( $pagination ) {
46
-		if ( get_query_var( 'paged' ) ) {
47
-			$paged = get_query_var( 'paged' );
48
-		} else if ( get_query_var( 'page' ) ) {
49
-			$paged = get_query_var( 'page' );
45
+	if ($pagination) {
46
+		if (get_query_var('paged')) {
47
+			$paged = get_query_var('paged');
48
+		} else if (get_query_var('page')) {
49
+			$paged = get_query_var('page');
50 50
 		} else {
51 51
 			$paged = 1;
52 52
 		}
53 53
 	}
54 54
 
55
-	$args = apply_filters( 'give_get_users_purchases_args', array(
55
+	$args = apply_filters('give_get_users_purchases_args', array(
56 56
 		'user'    => $user,
57 57
 		'number'  => $number,
58 58
 		'status'  => $status,
59 59
 		'orderby' => 'date'
60
-	) );
60
+	));
61 61
 
62
-	if ( $pagination ) {
62
+	if ($pagination) {
63 63
 
64 64
 		$args['page'] = $paged;
65 65
 
@@ -69,20 +69,20 @@  discard block
 block discarded – undo
69 69
 
70 70
 	}
71 71
 
72
-	$by_user_id = is_numeric( $user ) ? true : false;
73
-	$customer   = new Give_Customer( $user, $by_user_id );
72
+	$by_user_id = is_numeric($user) ? true : false;
73
+	$customer   = new Give_Customer($user, $by_user_id);
74 74
 
75
-	if ( ! empty( $customer->payment_ids ) ) {
75
+	if ( ! empty($customer->payment_ids)) {
76 76
 
77
-		unset( $args['user'] );
78
-		$args['post__in'] = array_map( 'absint', explode( ',', $customer->payment_ids ) );
77
+		unset($args['user']);
78
+		$args['post__in'] = array_map('absint', explode(',', $customer->payment_ids));
79 79
 
80 80
 	}
81 81
 
82
-	$purchases = give_get_payments( apply_filters( 'give_get_users_purchases_args', $args ) );
82
+	$purchases = give_get_payments(apply_filters('give_get_users_purchases_args', $args));
83 83
 
84 84
 	// No purchases
85
-	if ( ! $purchases ) {
85
+	if ( ! $purchases) {
86 86
 		return false;
87 87
 	}
88 88
 
@@ -101,65 +101,65 @@  discard block
 block discarded – undo
101 101
  *
102 102
  * @return bool|object List of unique forms purchased by user
103 103
  */
104
-function give_get_users_completed_donations( $user = 0, $status = 'complete' ) {
105
-	if ( empty( $user ) ) {
104
+function give_get_users_completed_donations($user = 0, $status = 'complete') {
105
+	if (empty($user)) {
106 106
 		$user = get_current_user_id();
107 107
 	}
108 108
 
109
-	if ( empty( $user ) ) {
109
+	if (empty($user)) {
110 110
 		return false;
111 111
 	}
112 112
 
113
-	$by_user_id = is_numeric( $user ) ? true : false;
113
+	$by_user_id = is_numeric($user) ? true : false;
114 114
 
115
-	$customer = new Give_Customer( $user, $by_user_id );
115
+	$customer = new Give_Customer($user, $by_user_id);
116 116
 
117
-	if ( empty( $customer->payment_ids ) ) {
117
+	if (empty($customer->payment_ids)) {
118 118
 		return false;
119 119
 	}
120 120
 
121 121
 	// Get all the items purchased
122
-	$payment_ids    = array_reverse( explode( ',', $customer->payment_ids ) );
123
-	$limit_payments = apply_filters( 'give_users_completed_donations_payments', 50 );
124
-	if ( ! empty( $limit_payments ) ) {
125
-		$payment_ids = array_slice( $payment_ids, 0, $limit_payments );
122
+	$payment_ids    = array_reverse(explode(',', $customer->payment_ids));
123
+	$limit_payments = apply_filters('give_users_completed_donations_payments', 50);
124
+	if ( ! empty($limit_payments)) {
125
+		$payment_ids = array_slice($payment_ids, 0, $limit_payments);
126 126
 	}
127 127
 	$donation_data = array();
128
-	foreach ( $payment_ids as $payment_id ) {
129
-		$donation_data[] = give_get_payment_meta( $payment_id );
128
+	foreach ($payment_ids as $payment_id) {
129
+		$donation_data[] = give_get_payment_meta($payment_id);
130 130
 	}
131 131
 
132
-	if ( empty( $donation_data ) ) {
132
+	if (empty($donation_data)) {
133 133
 		return false;
134 134
 	}
135 135
 
136 136
 	// Grab only the post ids "form_id" of the forms purchased on this order
137 137
 	$completed_donations_ids = array();
138
-	foreach ( $donation_data as $purchase_meta ) {
138
+	foreach ($donation_data as $purchase_meta) {
139 139
 		$completed_donations_ids[] = isset($purchase_meta['form_id']) ? $purchase_meta['form_id'] : '';
140 140
 	}
141 141
 
142
-	if ( empty( $completed_donations_ids ) ) {
142
+	if (empty($completed_donations_ids)) {
143 143
 		return false;
144 144
 	}
145 145
 
146 146
 	// Only include each product purchased once
147
-	$form_ids = array_unique( $completed_donations_ids );
147
+	$form_ids = array_unique($completed_donations_ids);
148 148
 
149 149
 	// Make sure we still have some products and a first item
150
-	if ( empty ( $form_ids ) || ! isset( $form_ids[0] ) ) {
150
+	if (empty ($form_ids) || ! isset($form_ids[0])) {
151 151
 		return false;
152 152
 	}
153 153
 
154
-	$post_type = get_post_type( $form_ids[0] );
154
+	$post_type = get_post_type($form_ids[0]);
155 155
 
156
-	$args = apply_filters( 'give_get_users_completed_donations_args', array(
156
+	$args = apply_filters('give_get_users_completed_donations_args', array(
157 157
 		'include'        => $form_ids,
158 158
 		'post_type'      => $post_type,
159
-		'posts_per_page' => - 1
160
-	) );
159
+		'posts_per_page' => -1
160
+	));
161 161
 
162
-	return apply_filters( 'give_users_completed_donations_list', get_posts( $args ) );
162
+	return apply_filters('give_users_completed_donations_list', get_posts($args));
163 163
 }
164 164
 
165 165
 
@@ -175,12 +175,12 @@  discard block
 block discarded – undo
175 175
  *
176 176
  * @return      bool - true if has purchased, false other wise.
177 177
  */
178
-function give_has_purchases( $user_id = null ) {
179
-	if ( empty( $user_id ) ) {
178
+function give_has_purchases($user_id = null) {
179
+	if (empty($user_id)) {
180 180
 		$user_id = get_current_user_id();
181 181
 	}
182 182
 
183
-	if ( give_get_users_purchases( $user_id, 1 ) ) {
183
+	if (give_get_users_purchases($user_id, 1)) {
184 184
 		return true; // User has at least one purchase
185 185
 	}
186 186
 
@@ -200,32 +200,32 @@  discard block
 block discarded – undo
200 200
  *
201 201
  * @return      array
202 202
  */
203
-function give_get_purchase_stats_by_user( $user = '' ) {
203
+function give_get_purchase_stats_by_user($user = '') {
204 204
 
205
-	if ( is_email( $user ) ) {
205
+	if (is_email($user)) {
206 206
 
207 207
 		$field = 'email';
208 208
 
209
-	} elseif ( is_numeric( $user ) ) {
209
+	} elseif (is_numeric($user)) {
210 210
 
211 211
 		$field = 'user_id';
212 212
 
213 213
 	}
214 214
 
215 215
 	$stats    = array();
216
-	$customer = Give()->customers->get_customer_by( $field, $user );
216
+	$customer = Give()->customers->get_customer_by($field, $user);
217 217
 
218
-	if ( $customer ) {
218
+	if ($customer) {
219 219
 
220
-		$customer = new Give_Customer( $customer->id );
220
+		$customer = new Give_Customer($customer->id);
221 221
 
222
-		$stats['purchases']   = absint( $customer->purchase_count );
223
-		$stats['total_spent'] = give_sanitize_amount( $customer->purchase_value );
222
+		$stats['purchases']   = absint($customer->purchase_count);
223
+		$stats['total_spent'] = give_sanitize_amount($customer->purchase_value);
224 224
 
225 225
 	}
226 226
 
227 227
 
228
-	return (array) apply_filters( 'give_purchase_stats_by_user', $stats, $user );
228
+	return (array) apply_filters('give_purchase_stats_by_user', $stats, $user);
229 229
 }
230 230
 
231 231
 
@@ -241,22 +241,22 @@  discard block
 block discarded – undo
241 241
  *
242 242
  * @return      int - the total number of purchases
243 243
  */
244
-function give_count_purchases_of_customer( $user = null ) {
244
+function give_count_purchases_of_customer($user = null) {
245 245
 
246 246
 	//Logged in?
247
-	if ( empty( $user ) ) {
247
+	if (empty($user)) {
248 248
 		$user = get_current_user_id();
249 249
 	}
250 250
 
251 251
 	//Email access?
252
-	if ( empty( $user ) && Give()->email_access->token_email ) {
252
+	if (empty($user) && Give()->email_access->token_email) {
253 253
 		$user = Give()->email_access->token_email;
254 254
 	}
255 255
 
256 256
 
257
-	$stats = ! empty( $user ) ? give_get_purchase_stats_by_user( $user ) : false;
257
+	$stats = ! empty($user) ? give_get_purchase_stats_by_user($user) : false;
258 258
 
259
-	return isset( $stats['purchases'] ) ? $stats['purchases'] : 0;
259
+	return isset($stats['purchases']) ? $stats['purchases'] : 0;
260 260
 }
261 261
 
262 262
 /**
@@ -269,9 +269,9 @@  discard block
 block discarded – undo
269 269
  *
270 270
  * @return      float - the total amount the user has spent
271 271
  */
272
-function give_purchase_total_of_user( $user = null ) {
272
+function give_purchase_total_of_user($user = null) {
273 273
 
274
-	$stats = give_get_purchase_stats_by_user( $user );
274
+	$stats = give_get_purchase_stats_by_user($user);
275 275
 
276 276
 	return $stats['total_spent'];
277 277
 }
@@ -287,11 +287,11 @@  discard block
 block discarded – undo
287 287
  *
288 288
  * @return      bool
289 289
  */
290
-function give_validate_username( $username ) {
291
-	$sanitized = sanitize_user( $username, false );
292
-	$valid     = ( $sanitized == $username );
290
+function give_validate_username($username) {
291
+	$sanitized = sanitize_user($username, false);
292
+	$valid     = ($sanitized == $username);
293 293
 
294
-	return (bool) apply_filters( 'give_validate_username', $valid, $username );
294
+	return (bool) apply_filters('give_validate_username', $valid, $username);
295 295
 }
296 296
 
297 297
 
@@ -308,32 +308,32 @@  discard block
 block discarded – undo
308 308
  *
309 309
  * @return      void
310 310
  */
311
-function give_add_past_purchases_to_new_user( $user_id ) {
311
+function give_add_past_purchases_to_new_user($user_id) {
312 312
 
313
-	$email = get_the_author_meta( 'user_email', $user_id );
313
+	$email = get_the_author_meta('user_email', $user_id);
314 314
 
315
-	$payments = give_get_payments( array( 's' => $email ) );
315
+	$payments = give_get_payments(array('s' => $email));
316 316
 
317
-	if ( $payments ) {
318
-		foreach ( $payments as $payment ) {
319
-			if ( intval( give_get_payment_user_id( $payment->ID ) ) > 0 ) {
317
+	if ($payments) {
318
+		foreach ($payments as $payment) {
319
+			if (intval(give_get_payment_user_id($payment->ID)) > 0) {
320 320
 				continue;
321 321
 			} // This payment already associated with an account
322 322
 
323
-			$meta                    = give_get_payment_meta( $payment->ID );
324
-			$meta['user_info']       = maybe_unserialize( $meta['user_info'] );
323
+			$meta                    = give_get_payment_meta($payment->ID);
324
+			$meta['user_info']       = maybe_unserialize($meta['user_info']);
325 325
 			$meta['user_info']['id'] = $user_id;
326 326
 			$meta['user_info']       = $meta['user_info'];
327 327
 
328 328
 			// Store the updated user ID in the payment meta
329
-			give_update_payment_meta( $payment->ID, '_give_payment_meta', $meta );
330
-			give_update_payment_meta( $payment->ID, '_give_payment_user_id', $user_id );
329
+			give_update_payment_meta($payment->ID, '_give_payment_meta', $meta);
330
+			give_update_payment_meta($payment->ID, '_give_payment_user_id', $user_id);
331 331
 		}
332 332
 	}
333 333
 
334 334
 }
335 335
 
336
-add_action( 'user_register', 'give_add_past_purchases_to_new_user' );
336
+add_action('user_register', 'give_add_past_purchases_to_new_user');
337 337
 
338 338
 
339 339
 /**
@@ -355,34 +355,34 @@  discard block
 block discarded – undo
355 355
  * @since         1.0
356 356
  * @return        array - The donor's address, if any
357 357
  */
358
-function give_get_donor_address( $user_id = 0 ) {
359
-	if ( empty( $user_id ) ) {
358
+function give_get_donor_address($user_id = 0) {
359
+	if (empty($user_id)) {
360 360
 		$user_id = get_current_user_id();
361 361
 	}
362 362
 
363
-	$address = get_user_meta( $user_id, '_give_user_address', true );
363
+	$address = get_user_meta($user_id, '_give_user_address', true);
364 364
 
365
-	if ( ! isset( $address['line1'] ) ) {
365
+	if ( ! isset($address['line1'])) {
366 366
 		$address['line1'] = '';
367 367
 	}
368 368
 
369
-	if ( ! isset( $address['line2'] ) ) {
369
+	if ( ! isset($address['line2'])) {
370 370
 		$address['line2'] = '';
371 371
 	}
372 372
 
373
-	if ( ! isset( $address['city'] ) ) {
373
+	if ( ! isset($address['city'])) {
374 374
 		$address['city'] = '';
375 375
 	}
376 376
 
377
-	if ( ! isset( $address['zip'] ) ) {
377
+	if ( ! isset($address['zip'])) {
378 378
 		$address['zip'] = '';
379 379
 	}
380 380
 
381
-	if ( ! isset( $address['country'] ) ) {
381
+	if ( ! isset($address['country'])) {
382 382
 		$address['country'] = '';
383 383
 	}
384 384
 
385
-	if ( ! isset( $address['state'] ) ) {
385
+	if ( ! isset($address['state'])) {
386 386
 		$address['state'] = '';
387 387
 	}
388 388
 
@@ -402,42 +402,42 @@  discard block
 block discarded – undo
402 402
  *
403 403
  * @return        void
404 404
  */
405
-function give_new_user_notification( $user_id = 0, $user_data = array() ) {
405
+function give_new_user_notification($user_id = 0, $user_data = array()) {
406 406
 
407
-	if ( empty( $user_id ) || empty( $user_data ) ) {
407
+	if (empty($user_id) || empty($user_data)) {
408 408
 		return;
409 409
 	}
410
-	$blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
410
+	$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
411 411
 
412 412
 	/* translators: %s: site name */
413
-	$message  = sprintf( esc_html__( 'New user registration on your site %s:' ), $blogname ) . "\r\n\r\n";
413
+	$message  = sprintf(esc_html__('New user registration on your site %s:'), $blogname)."\r\n\r\n";
414 414
 	/* translators: %s: user login */
415
-	$message .= sprintf( esc_html__( 'Username: %s' ), $user_data['user_login'] ) . "\r\n\r\n";
415
+	$message .= sprintf(esc_html__('Username: %s'), $user_data['user_login'])."\r\n\r\n";
416 416
 	/* translators: %s: user email */
417
-	$message .= sprintf( esc_html__( 'E-mail: %s' ), $user_data['user_email'] ) . "\r\n";
417
+	$message .= sprintf(esc_html__('E-mail: %s'), $user_data['user_email'])."\r\n";
418 418
 
419 419
 	@wp_mail(
420
-		get_option( 'admin_email' ),
420
+		get_option('admin_email'),
421 421
 		sprintf(
422 422
 			/* translators: %s: site name */
423
-			esc_html__( '[%s] New User Registration' ),
423
+			esc_html__('[%s] New User Registration'),
424 424
 			$blogname
425 425
 		),
426 426
 		$message
427 427
 	);
428 428
 
429 429
 	/* translators: %s: user login */
430
-	$message  = sprintf( esc_html__( 'Username: %s' ), $user_data['user_login'] ) . "\r\n";
430
+	$message  = sprintf(esc_html__('Username: %s'), $user_data['user_login'])."\r\n";
431 431
 	/* translators: %s: paswword */
432
-	$message .= sprintf( esc_html__( 'Password: %s' ), esc_html__( '[Password entered during donation]', 'give' ) ) . "\r\n";
432
+	$message .= sprintf(esc_html__('Password: %s'), esc_html__('[Password entered during donation]', 'give'))."\r\n";
433 433
 
434
-	$message .= '<a href="' . wp_login_url() . '"> ' . esc_html__( 'Click Here to Login', 'give' ) . ' &raquo;</a>' . "\r\n";
434
+	$message .= '<a href="'.wp_login_url().'"> '.esc_html__('Click Here to Login', 'give').' &raquo;</a>'."\r\n";
435 435
 
436 436
 	wp_mail(
437 437
 		$user_data['user_email'],
438 438
 		sprintf(
439 439
 			/* translators: %s: site name */
440
-			esc_html__( '[%s] Your username and password' ),
440
+			esc_html__('[%s] Your username and password'),
441 441
 			$blogname
442 442
 		),
443 443
 		$message
@@ -445,4 +445,4 @@  discard block
 block discarded – undo
445 445
 
446 446
 }
447 447
 
448
-add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 );
448
+add_action('give_insert_user', 'give_new_user_notification', 10, 2);
Please login to merge, or discard this patch.
includes/class-give-donate-form.php 1 patch
Spacing   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -100,12 +100,12 @@  discard block
 block discarded – undo
100 100
 	 * @param bool $_id
101 101
 	 * @param array $_args
102 102
 	 */
103
-	public function __construct( $_id = false, $_args = array() ) {
103
+	public function __construct($_id = false, $_args = array()) {
104 104
 
105 105
 
106
-		$donation_form = WP_Post::get_instance( $_id );
106
+		$donation_form = WP_Post::get_instance($_id);
107 107
 
108
-		return $this->setup_donation_form( $donation_form );
108
+		return $this->setup_donation_form($donation_form);
109 109
 	}
110 110
 
111 111
 	/**
@@ -117,23 +117,23 @@  discard block
 block discarded – undo
117 117
 	 *
118 118
 	 * @return bool             If the setup was successful or not
119 119
 	 */
120
-	private function setup_donation_form( $donation_form ) {
120
+	private function setup_donation_form($donation_form) {
121 121
 
122
-		if ( ! is_object( $donation_form ) ) {
122
+		if ( ! is_object($donation_form)) {
123 123
 			return false;
124 124
 		}
125 125
 
126
-		if ( ! is_a( $donation_form, 'WP_Post' ) ) {
126
+		if ( ! is_a($donation_form, 'WP_Post')) {
127 127
 			return false;
128 128
 		}
129 129
 
130
-		if ( 'give_forms' !== $donation_form->post_type ) {
130
+		if ('give_forms' !== $donation_form->post_type) {
131 131
 			return false;
132 132
 		}
133 133
 
134
-		foreach ( $donation_form as $key => $value ) {
134
+		foreach ($donation_form as $key => $value) {
135 135
 
136
-			switch ( $key ) {
136
+			switch ($key) {
137 137
 
138 138
 				default:
139 139
 					$this->$key = $value;
@@ -157,16 +157,16 @@  discard block
 block discarded – undo
157 157
 	 * @return mixed
158 158
 	 * @throws Exception
159 159
 	 */
160
-	public function __get( $key ) {
160
+	public function __get($key) {
161 161
 
162
-		if ( method_exists( $this, 'get_' . $key ) ) {
162
+		if (method_exists($this, 'get_'.$key)) {
163 163
 
164
-			return call_user_func( array( $this, 'get_' . $key ) );
164
+			return call_user_func(array($this, 'get_'.$key));
165 165
 
166 166
 		} else {
167 167
 
168 168
 			/* translators: %s: property key */
169
-			return new WP_Error( 'give-form-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) );
169
+			return new WP_Error('give-form-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key));
170 170
 
171 171
 		}
172 172
 
@@ -182,30 +182,30 @@  discard block
 block discarded – undo
182 182
 	 *
183 183
 	 * @return mixed  false if data isn't passed and class not instantiated for creation, or New Form ID
184 184
 	 */
185
-	public function create( $data = array() ) {
185
+	public function create($data = array()) {
186 186
 
187
-		if ( $this->id != 0 ) {
187
+		if ($this->id != 0) {
188 188
 			return false;
189 189
 		}
190 190
 
191 191
 		$defaults = array(
192 192
 			'post_type'   => 'give_forms',
193 193
 			'post_status' => 'draft',
194
-			'post_title'  => esc_html__( 'New Donation Form', 'give' )
194
+			'post_title'  => esc_html__('New Donation Form', 'give')
195 195
 		);
196 196
 
197
-		$args = wp_parse_args( $data, $defaults );
197
+		$args = wp_parse_args($data, $defaults);
198 198
 
199 199
 		/**
200 200
 		 * Fired before a donation form is created
201 201
 		 *
202 202
 		 * @param array $args The post object arguments used for creation.
203 203
 		 */
204
-		do_action( 'give_form_pre_create', $args );
204
+		do_action('give_form_pre_create', $args);
205 205
 
206
-		$id = wp_insert_post( $args, true );
206
+		$id = wp_insert_post($args, true);
207 207
 
208
-		$donation_form = WP_Post::get_instance( $id );
208
+		$donation_form = WP_Post::get_instance($id);
209 209
 
210 210
 		/**
211 211
 		 * Fired after a donation form is created
@@ -213,9 +213,9 @@  discard block
 block discarded – undo
213 213
 		 * @param int $id The post ID of the created item.
214 214
 		 * @param array $args The post object arguments used for creation.
215 215
 		 */
216
-		do_action( 'give_form_post_create', $id, $args );
216
+		do_action('give_form_post_create', $id, $args);
217 217
 
218
-		return $this->setup_donation_form( $donation_form );
218
+		return $this->setup_donation_form($donation_form);
219 219
 
220 220
 	}
221 221
 
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 	 * @return string Name of the donation form
239 239
 	 */
240 240
 	public function get_name() {
241
-		return get_the_title( $this->ID );
241
+		return get_the_title($this->ID);
242 242
 	}
243 243
 
244 244
 	/**
@@ -249,13 +249,13 @@  discard block
 block discarded – undo
249 249
 	 */
250 250
 	public function get_price() {
251 251
 
252
-		if ( ! isset( $this->price ) ) {
252
+		if ( ! isset($this->price)) {
253 253
 
254
-			$this->price = get_post_meta( $this->ID, '_give_set_price', true );
254
+			$this->price = get_post_meta($this->ID, '_give_set_price', true);
255 255
 
256
-			if ( $this->price ) {
256
+			if ($this->price) {
257 257
 
258
-				$this->price = give_sanitize_amount( $this->price );
258
+				$this->price = give_sanitize_amount($this->price);
259 259
 
260 260
 			} else {
261 261
 
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 		 * @param string $price The donation form price.
274 274
 		 * @param string|int $id The form ID.
275 275
 		 */
276
-		return apply_filters( 'give_get_set_price', $this->price, $this->ID );
276
+		return apply_filters('give_get_set_price', $this->price, $this->ID);
277 277
 	}
278 278
 
279 279
 	/**
@@ -284,14 +284,14 @@  discard block
 block discarded – undo
284 284
 	 */
285 285
 	public function get_minimum_price() {
286 286
 
287
-		if ( ! isset( $this->minimum_price ) ) {
287
+		if ( ! isset($this->minimum_price)) {
288 288
 
289
-			$allow_custom_amount = get_post_meta( $this->ID, '_give_custom_amount', true );
290
-			$this->minimum_price = get_post_meta( $this->ID, '_give_custom_amount_minimum', true );
289
+			$allow_custom_amount = get_post_meta($this->ID, '_give_custom_amount', true);
290
+			$this->minimum_price = get_post_meta($this->ID, '_give_custom_amount_minimum', true);
291 291
 
292
-			if ( $allow_custom_amount != 'no' && $this->minimum_price ) {
292
+			if ($allow_custom_amount != 'no' && $this->minimum_price) {
293 293
 
294
-				$this->minimum_price = give_sanitize_amount( $this->minimum_price );
294
+				$this->minimum_price = give_sanitize_amount($this->minimum_price);
295 295
 
296 296
 			} else {
297 297
 
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 
302 302
 		}
303 303
 
304
-		return apply_filters( 'give_get_set_minimum_price', $this->minimum_price, $this->ID );
304
+		return apply_filters('give_get_set_minimum_price', $this->minimum_price, $this->ID);
305 305
 	}
306 306
 
307 307
 	/**
@@ -312,9 +312,9 @@  discard block
 block discarded – undo
312 312
 	 */
313 313
 	public function get_prices() {
314 314
 
315
-		if ( ! isset( $this->prices ) ) {
315
+		if ( ! isset($this->prices)) {
316 316
 
317
-			$this->prices = get_post_meta( $this->ID, '_give_donation_levels', true );
317
+			$this->prices = get_post_meta($this->ID, '_give_donation_levels', true);
318 318
 
319 319
 		}
320 320
 
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 		 * @param array $prices The array of mulit-level prices.
327 327
 		 * @param int|string The ID of the form.
328 328
 		 */
329
-		return apply_filters( 'give_get_donation_levels', $this->prices, $this->ID );
329
+		return apply_filters('give_get_donation_levels', $this->prices, $this->ID);
330 330
 
331 331
 	}
332 332
 
@@ -338,13 +338,13 @@  discard block
 block discarded – undo
338 338
 	 */
339 339
 	public function get_goal() {
340 340
 
341
-		if ( ! isset( $this->goal ) ) {
341
+		if ( ! isset($this->goal)) {
342 342
 
343
-			$this->goal = get_post_meta( $this->ID, '_give_set_goal', true );
343
+			$this->goal = get_post_meta($this->ID, '_give_set_goal', true);
344 344
 
345
-			if ( $this->goal ) {
345
+			if ($this->goal) {
346 346
 
347
-				$this->goal = give_sanitize_amount( $this->goal );
347
+				$this->goal = give_sanitize_amount($this->goal);
348 348
 
349 349
 			} else {
350 350
 
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 
355 355
 		}
356 356
 
357
-		return apply_filters( 'give_get_set_goal', $this->goal, $this->ID );
357
+		return apply_filters('give_get_set_goal', $this->goal, $this->ID);
358 358
 
359 359
 	}
360 360
 
@@ -366,10 +366,10 @@  discard block
 block discarded – undo
366 366
 	 */
367 367
 	public function is_single_price_mode() {
368 368
 
369
-		$option = get_post_meta( $this->ID, '_give_price_options_mode', true );
369
+		$option = get_post_meta($this->ID, '_give_price_options_mode', true);
370 370
 		$ret    = 0;
371 371
 
372
-		if ( empty( $option ) || $option === 'set' ) {
372
+		if (empty($option) || $option === 'set') {
373 373
 			$ret = 1;
374 374
 		}
375 375
 		
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
 		 * @param bool $ret Is donation form in single price mode?
382 382
 		 * @param int|string The ID of the donation form.
383 383
 		 */
384
-		return (bool) apply_filters( 'give_single_price_option_mode', $ret, $this->ID );
384
+		return (bool) apply_filters('give_single_price_option_mode', $ret, $this->ID);
385 385
 
386 386
 	}
387 387
 
@@ -395,10 +395,10 @@  discard block
 block discarded – undo
395 395
 	 */
396 396
 	public function has_variable_prices() {
397 397
 
398
-		$option = get_post_meta( $this->ID, '_give_price_option', true );
398
+		$option = get_post_meta($this->ID, '_give_price_option', true);
399 399
 		$ret    = 0;
400 400
 
401
-		if ( $option === 'multi' ) {
401
+		if ($option === 'multi') {
402 402
 			$ret = 1;
403 403
 		}
404 404
 
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
 		 * @param bool $ret Does donation form have variable prices?
409 409
 		 * @param int|string The ID of the donation form.
410 410
 		 */
411
-		return (bool) apply_filters( 'give_has_variable_prices', $ret, $this->ID );
411
+		return (bool) apply_filters('give_has_variable_prices', $ret, $this->ID);
412 412
 
413 413
 	}
414 414
 
@@ -420,17 +420,17 @@  discard block
 block discarded – undo
420 420
 	 */
421 421
 	public function get_type() {
422 422
 
423
-		if ( ! isset( $this->type ) ) {
423
+		if ( ! isset($this->type)) {
424 424
 
425
-			$this->type = get_post_meta( $this->ID, '_give_price_option', true );
425
+			$this->type = get_post_meta($this->ID, '_give_price_option', true);
426 426
 
427
-			if ( empty( $this->type ) ) {
427
+			if (empty($this->type)) {
428 428
 				$this->type = 'set';
429 429
 			}
430 430
 
431 431
 		}
432 432
 
433
-		return apply_filters( 'give_get_form_type', $this->type, $this->ID );
433
+		return apply_filters('give_get_form_type', $this->type, $this->ID);
434 434
 
435 435
 	}
436 436
 
@@ -442,15 +442,15 @@  discard block
 block discarded – undo
442 442
 	 */
443 443
 	public function get_sales() {
444 444
 
445
-		if ( ! isset( $this->sales ) ) {
445
+		if ( ! isset($this->sales)) {
446 446
 
447
-			if ( '' == get_post_meta( $this->ID, '_give_form_sales', true ) ) {
448
-				add_post_meta( $this->ID, '_give_form_sales', 0 );
447
+			if ('' == get_post_meta($this->ID, '_give_form_sales', true)) {
448
+				add_post_meta($this->ID, '_give_form_sales', 0);
449 449
 			} // End if
450 450
 
451
-			$this->sales = get_post_meta( $this->ID, '_give_form_sales', true );
451
+			$this->sales = get_post_meta($this->ID, '_give_form_sales', true);
452 452
 
453
-			if ( $this->sales < 0 ) {
453
+			if ($this->sales < 0) {
454 454
 				// Never let sales be less than zero
455 455
 				$this->sales = 0;
456 456
 			}
@@ -470,13 +470,13 @@  discard block
 block discarded – undo
470 470
 	 *
471 471
 	 * @return int|false  New number of total sales
472 472
 	 */
473
-	public function increase_sales( $quantity = 1 ) {
473
+	public function increase_sales($quantity = 1) {
474 474
 
475
-		$sales       = give_get_form_sales_stats( $this->ID );
476
-		$quantity    = absint( $quantity );
475
+		$sales       = give_get_form_sales_stats($this->ID);
476
+		$quantity    = absint($quantity);
477 477
 		$total_sales = $sales + $quantity;
478 478
 
479
-		if ( $this->update_meta( '_give_form_sales', $total_sales ) ) {
479
+		if ($this->update_meta('_give_form_sales', $total_sales)) {
480 480
 
481 481
 			$this->sales = $total_sales;
482 482
 
@@ -496,17 +496,17 @@  discard block
 block discarded – undo
496 496
 	 *
497 497
 	 * @return int|false  New number of total sales
498 498
 	 */
499
-	public function decrease_sales( $quantity = 1 ) {
499
+	public function decrease_sales($quantity = 1) {
500 500
 
501
-		$sales = give_get_form_sales_stats( $this->ID );
501
+		$sales = give_get_form_sales_stats($this->ID);
502 502
 
503 503
 		// Only decrease if not already zero
504
-		if ( $sales > 0 ) {
504
+		if ($sales > 0) {
505 505
 
506
-			$quantity    = absint( $quantity );
506
+			$quantity    = absint($quantity);
507 507
 			$total_sales = $sales - $quantity;
508 508
 
509
-			if ( $this->update_meta( '_give_form_sales', $total_sales ) ) {
509
+			if ($this->update_meta('_give_form_sales', $total_sales)) {
510 510
 
511 511
 				$this->sales = $sales;
512 512
 
@@ -528,15 +528,15 @@  discard block
 block discarded – undo
528 528
 	 */
529 529
 	public function get_earnings() {
530 530
 
531
-		if ( ! isset( $this->earnings ) ) {
531
+		if ( ! isset($this->earnings)) {
532 532
 
533
-			if ( '' == get_post_meta( $this->ID, '_give_form_earnings', true ) ) {
534
-				add_post_meta( $this->ID, '_give_form_earnings', 0 );
533
+			if ('' == get_post_meta($this->ID, '_give_form_earnings', true)) {
534
+				add_post_meta($this->ID, '_give_form_earnings', 0);
535 535
 			}
536 536
 
537
-			$this->earnings = get_post_meta( $this->ID, '_give_form_earnings', true );
537
+			$this->earnings = get_post_meta($this->ID, '_give_form_earnings', true);
538 538
 
539
-			if ( $this->earnings < 0 ) {
539
+			if ($this->earnings < 0) {
540 540
 				// Never let earnings be less than zero
541 541
 				$this->earnings = 0;
542 542
 			}
@@ -553,12 +553,12 @@  discard block
 block discarded – undo
553 553
 	 * @since 1.0
554 554
 	 * @return float|false
555 555
 	 */
556
-	public function increase_earnings( $amount = 0 ) {
556
+	public function increase_earnings($amount = 0) {
557 557
 
558
-		$earnings   = give_get_form_earnings_stats( $this->ID );
558
+		$earnings   = give_get_form_earnings_stats($this->ID);
559 559
 		$new_amount = $earnings + (float) $amount;
560 560
 
561
-		if ( $this->update_meta( '_give_form_earnings', $new_amount ) ) {
561
+		if ($this->update_meta('_give_form_earnings', $new_amount)) {
562 562
 
563 563
 			$this->earnings = $new_amount;
564 564
 
@@ -576,16 +576,16 @@  discard block
 block discarded – undo
576 576
 	 * @since 1.0
577 577
 	 * @return float|false
578 578
 	 */
579
-	public function decrease_earnings( $amount ) {
579
+	public function decrease_earnings($amount) {
580 580
 
581
-		$earnings = give_get_form_earnings_stats( $this->ID );
581
+		$earnings = give_get_form_earnings_stats($this->ID);
582 582
 
583
-		if ( $earnings > 0 ) {
583
+		if ($earnings > 0) {
584 584
 			// Only decrease if greater than zero
585 585
 			$new_amount = $earnings - (float) $amount;
586 586
 
587 587
 
588
-			if ( $this->update_meta( '_give_form_earnings', $new_amount ) ) {
588
+			if ($this->update_meta('_give_form_earnings', $new_amount)) {
589 589
 
590 590
 				$this->earnings = $new_amount;
591 591
 
@@ -605,22 +605,22 @@  discard block
 block discarded – undo
605 605
 	 * @since 1.0
606 606
 	 * @return bool
607 607
 	 */
608
-	public function is_free( $price_id = false ) {
608
+	public function is_free($price_id = false) {
609 609
 
610 610
 		$is_free          = false;
611
-		$variable_pricing = give_has_variable_prices( $this->ID );
611
+		$variable_pricing = give_has_variable_prices($this->ID);
612 612
 
613
-		if ( $variable_pricing && ! is_null( $price_id ) && $price_id !== false ) {
614
-			$price = give_get_price_option_amount( $this->ID, $price_id );
615
-		} elseif ( ! $variable_pricing ) {
616
-			$price = get_post_meta( $this->ID, '_give_set_price', true );
613
+		if ($variable_pricing && ! is_null($price_id) && $price_id !== false) {
614
+			$price = give_get_price_option_amount($this->ID, $price_id);
615
+		} elseif ( ! $variable_pricing) {
616
+			$price = get_post_meta($this->ID, '_give_set_price', true);
617 617
 		}
618 618
 
619
-		if ( isset( $price ) && (float) $price == 0 ) {
619
+		if (isset($price) && (float) $price == 0) {
620 620
 			$is_free = true;
621 621
 		}
622 622
 
623
-		return (bool) apply_filters( 'give_is_free_donation', $is_free, $this->ID, $price_id );
623
+		return (bool) apply_filters('give_is_free_donation', $is_free, $this->ID, $price_id);
624 624
 
625 625
 	}
626 626
 
@@ -637,9 +637,9 @@  discard block
 block discarded – undo
637 637
 	 */
638 638
 	public function is_close_donation_form() {
639 639
 		return (
640
-				'yes' === get_post_meta( $this->ID, '_give_goal_option', true ) )
641
-				&& ( 'yes' === get_post_meta( $this->ID, '_give_close_form_when_goal_achieved', true ) )
642
-				&& ( $this->get_goal() <= $this->get_earnings()
640
+				'yes' === get_post_meta($this->ID, '_give_goal_option', true) )
641
+				&& ('yes' === get_post_meta($this->ID, '_give_close_form_when_goal_achieved', true))
642
+				&& ($this->get_goal() <= $this->get_earnings()
643 643
 		);
644 644
 	}
645 645
 
@@ -655,28 +655,28 @@  discard block
 block discarded – undo
655 655
 	 *
656 656
 	 * @return bool             The result of the update query
657 657
 	 */
658
-	private function update_meta( $meta_key = '', $meta_value = '' ) {
658
+	private function update_meta($meta_key = '', $meta_value = '') {
659 659
 
660 660
 		global $wpdb;
661 661
 
662
-		if ( empty( $meta_key ) || empty( $meta_value ) ) {
662
+		if (empty($meta_key) || empty($meta_value)) {
663 663
 			return false;
664 664
 		}
665 665
 
666 666
 		// Make sure if it needs to be serialized, we do
667
-		$meta_value = maybe_serialize( $meta_value );
667
+		$meta_value = maybe_serialize($meta_value);
668 668
 
669
-		if ( is_numeric( $meta_value ) ) {
670
-			$value_type = is_float( $meta_value ) ? '%f' : '%d';
669
+		if (is_numeric($meta_value)) {
670
+			$value_type = is_float($meta_value) ? '%f' : '%d';
671 671
 		} else {
672 672
 			$value_type = "'%s'";
673 673
 		}
674 674
 
675
-		$sql = $wpdb->prepare( "UPDATE $wpdb->postmeta SET meta_value = $value_type WHERE post_id = $this->ID AND meta_key = '%s'", $meta_value, $meta_key );
675
+		$sql = $wpdb->prepare("UPDATE $wpdb->postmeta SET meta_value = $value_type WHERE post_id = $this->ID AND meta_key = '%s'", $meta_value, $meta_key);
676 676
 
677
-		if ( $wpdb->query( $sql ) ) {
677
+		if ($wpdb->query($sql)) {
678 678
 
679
-			clean_post_cache( $this->ID );
679
+			clean_post_cache($this->ID);
680 680
 
681 681
 			return true;
682 682
 
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() !== false || ( $email_access == 'on' && Give()->email_access->token_exists ) ) {
31
+	if (is_user_logged_in() || Give()->session->get_session_expiration() !== false || ($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 = esc_html__( '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 = esc_html__('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( esc_html__( 'Error: No Donation form ID for the shortcode provided.', 'give' ), true );
135
+	if (empty($atts['id'])) {
136
+		give_output_error(esc_html__('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( esc_html__( '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(esc_html__('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,62 +213,62 @@  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
 		'donor'          => true,
224 224
 		'date'           => true,
225 225
 		'payment_key'    => false,
226 226
 		'payment_method' => true,
227 227
 		'payment_id'     => true
228
-	), $atts, 'give_receipt' );
228
+	), $atts, 'give_receipt');
229 229
 
230 230
 	//set $session var
231 231
 	$session = give_get_purchase_session();
232 232
 
233 233
 	//set payment key var
234
-	if ( isset( $_GET['payment_key'] ) ) {
235
-		$payment_key = urldecode( $_GET['payment_key'] );
236
-	} elseif ( $session ) {
234
+	if (isset($_GET['payment_key'])) {
235
+		$payment_key = urldecode($_GET['payment_key']);
236
+	} elseif ($session) {
237 237
 		$payment_key = $session['purchase_key'];
238
-	} elseif ( $give_receipt_args['payment_key'] ) {
238
+	} elseif ($give_receipt_args['payment_key']) {
239 239
 		$payment_key = $give_receipt_args['payment_key'];
240 240
 	}
241 241
 
242
-	$email_access = give_get_option( 'email_access' );
242
+	$email_access = give_get_option('email_access');
243 243
 
244 244
 	// No payment_key found & Email Access is Turned on:
245
-	if ( ! isset( $payment_key ) && $email_access == 'on' && ! Give()->email_access->token_exists ) {
245
+	if ( ! isset($payment_key) && $email_access == 'on' && ! Give()->email_access->token_exists) {
246 246
 
247 247
 		ob_start();
248 248
 
249
-		give_get_template_part( 'email-login-form' );
249
+		give_get_template_part('email-login-form');
250 250
 
251 251
 		return ob_get_clean();
252 252
 
253
-	} elseif ( ! isset( $payment_key ) ) {
253
+	} elseif ( ! isset($payment_key)) {
254 254
 
255
-		return give_output_error( $give_receipt_args['error'], false, 'error' );
255
+		return give_output_error($give_receipt_args['error'], false, 'error');
256 256
 
257 257
 	}
258 258
 
259
-	$payment_id    = give_get_purchase_id_by_key( $payment_key );
260
-	$user_can_view = give_can_view_receipt( $payment_key );
259
+	$payment_id    = give_get_purchase_id_by_key($payment_key);
260
+	$user_can_view = give_can_view_receipt($payment_key);
261 261
 
262 262
 	// Key was provided, but user is logged out. Offer them the ability to login and view the receipt
263
-	if ( ! $user_can_view && $email_access == 'on' && ! Give()->email_access->token_exists ) {
263
+	if ( ! $user_can_view && $email_access == 'on' && ! Give()->email_access->token_exists) {
264 264
 
265 265
 		ob_start();
266 266
 
267
-		give_get_template_part( 'email-login-form' );
267
+		give_get_template_part('email-login-form');
268 268
 
269 269
 		return ob_get_clean();
270 270
 
271
-	} elseif ( ! $user_can_view ) {
271
+	} elseif ( ! $user_can_view) {
272 272
 
273 273
 		global $give_login_redirect;
274 274
 
@@ -276,9 +276,9 @@  discard block
 block discarded – undo
276 276
 
277 277
 		ob_start();
278 278
 
279
-		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
+		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')));
280 280
 
281
-		give_get_template_part( 'shortcode', 'login' );
281
+		give_get_template_part('shortcode', 'login');
282 282
 
283 283
 		$login_form = ob_get_clean();
284 284
 
@@ -295,13 +295,13 @@  discard block
 block discarded – undo
295 295
 	 * Or if user is logged in and the user can view sensitive shop data
296 296
 	 *
297 297
 	 */
298
-	if ( ! apply_filters( 'give_user_can_view_receipt', $user_can_view, $give_receipt_args ) ) {
299
-		return give_output_error( $give_receipt_args['error'], false, 'error' );
298
+	if ( ! apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) {
299
+		return give_output_error($give_receipt_args['error'], false, 'error');
300 300
 	}
301 301
 
302 302
 	ob_start();
303 303
 
304
-	give_get_template_part( 'shortcode', 'receipt' );
304
+	give_get_template_part('shortcode', 'receipt');
305 305
 
306 306
 	$display = ob_get_clean();
307 307
 
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 
311 311
 }
312 312
 
313
-add_shortcode( 'give_receipt', 'give_receipt_shortcode' );
313
+add_shortcode('give_receipt', 'give_receipt_shortcode');
314 314
 
315 315
 /**
316 316
  * Profile Editor Shortcode
@@ -330,18 +330,18 @@  discard block
 block discarded – undo
330 330
  *
331 331
  * @return string Output generated from the profile editor
332 332
  */
333
-function give_profile_editor_shortcode( $atts, $content = null ) {
333
+function give_profile_editor_shortcode($atts, $content = null) {
334 334
 
335 335
 	ob_start();
336 336
 
337
-	give_get_template_part( 'shortcode', 'profile-editor' );
337
+	give_get_template_part('shortcode', 'profile-editor');
338 338
 
339 339
 	$display = ob_get_clean();
340 340
 
341 341
 	return $display;
342 342
 }
343 343
 
344
-add_shortcode( 'give_profile_editor', 'give_profile_editor_shortcode' );
344
+add_shortcode('give_profile_editor', 'give_profile_editor_shortcode');
345 345
 
346 346
 /**
347 347
  * Process Profile Updater Form
@@ -354,30 +354,30 @@  discard block
 block discarded – undo
354 354
  *
355 355
  * @return false
356 356
  */
357
-function give_process_profile_editor_updates( $data ) {
357
+function give_process_profile_editor_updates($data) {
358 358
 	// Profile field change request
359
-	if ( empty( $_POST['give_profile_editor_submit'] ) && ! is_user_logged_in() ) {
359
+	if (empty($_POST['give_profile_editor_submit']) && ! is_user_logged_in()) {
360 360
 		return false;
361 361
 	}
362 362
 
363 363
 	// Nonce security
364
-	if ( ! wp_verify_nonce( $data['give_profile_editor_nonce'], 'give-profile-editor-nonce' ) ) {
364
+	if ( ! wp_verify_nonce($data['give_profile_editor_nonce'], 'give-profile-editor-nonce')) {
365 365
 		return false;
366 366
 	}
367 367
 
368 368
 	$user_id       = get_current_user_id();
369
-	$old_user_data = get_userdata( $user_id );
370
-
371
-	$display_name = isset( $data['give_display_name'] ) ? sanitize_text_field( $data['give_display_name'] ) : $old_user_data->display_name;
372
-	$first_name   = isset( $data['give_first_name'] ) ? sanitize_text_field( $data['give_first_name'] ) : $old_user_data->first_name;
373
-	$last_name    = isset( $data['give_last_name'] ) ? sanitize_text_field( $data['give_last_name'] ) : $old_user_data->last_name;
374
-	$email        = isset( $data['give_email'] ) ? sanitize_email( $data['give_email'] ) : $old_user_data->user_email;
375
-	$line1        = ( isset( $data['give_address_line1'] ) ? sanitize_text_field( $data['give_address_line1'] ) : '' );
376
-	$line2        = ( isset( $data['give_address_line2'] ) ? sanitize_text_field( $data['give_address_line2'] ) : '' );
377
-	$city         = ( isset( $data['give_address_city'] ) ? sanitize_text_field( $data['give_address_city'] ) : '' );
378
-	$state        = ( isset( $data['give_address_state'] ) ? sanitize_text_field( $data['give_address_state'] ) : '' );
379
-	$zip          = ( isset( $data['give_address_zip'] ) ? sanitize_text_field( $data['give_address_zip'] ) : '' );
380
-	$country      = ( isset( $data['give_address_country'] ) ? sanitize_text_field( $data['give_address_country'] ) : '' );
369
+	$old_user_data = get_userdata($user_id);
370
+
371
+	$display_name = isset($data['give_display_name']) ? sanitize_text_field($data['give_display_name']) : $old_user_data->display_name;
372
+	$first_name   = isset($data['give_first_name']) ? sanitize_text_field($data['give_first_name']) : $old_user_data->first_name;
373
+	$last_name    = isset($data['give_last_name']) ? sanitize_text_field($data['give_last_name']) : $old_user_data->last_name;
374
+	$email        = isset($data['give_email']) ? sanitize_email($data['give_email']) : $old_user_data->user_email;
375
+	$line1        = (isset($data['give_address_line1']) ? sanitize_text_field($data['give_address_line1']) : '');
376
+	$line2        = (isset($data['give_address_line2']) ? sanitize_text_field($data['give_address_line2']) : '');
377
+	$city         = (isset($data['give_address_city']) ? sanitize_text_field($data['give_address_city']) : '');
378
+	$state        = (isset($data['give_address_state']) ? sanitize_text_field($data['give_address_state']) : '');
379
+	$zip          = (isset($data['give_address_zip']) ? sanitize_text_field($data['give_address_zip']) : '');
380
+	$country      = (isset($data['give_address_country']) ? sanitize_text_field($data['give_address_country']) : '');
381 381
 
382 382
 	$userdata = array(
383 383
 		'ID'           => $user_id,
@@ -397,45 +397,45 @@  discard block
 block discarded – undo
397 397
 		'country' => $country
398 398
 	);
399 399
 
400
-	do_action( 'give_pre_update_user_profile', $user_id, $userdata );
400
+	do_action('give_pre_update_user_profile', $user_id, $userdata);
401 401
 
402 402
 	// New password
403
-	if ( ! empty( $data['give_new_user_pass1'] ) ) {
404
-		if ( $data['give_new_user_pass1'] !== $data['give_new_user_pass2'] ) {
405
-			give_set_error( 'password_mismatch', esc_html__( 'The passwords you entered do not match. Please try again.', 'give' ) );
403
+	if ( ! empty($data['give_new_user_pass1'])) {
404
+		if ($data['give_new_user_pass1'] !== $data['give_new_user_pass2']) {
405
+			give_set_error('password_mismatch', esc_html__('The passwords you entered do not match. Please try again.', 'give'));
406 406
 		} else {
407 407
 			$userdata['user_pass'] = $data['give_new_user_pass1'];
408 408
 		}
409 409
 	}
410 410
 
411 411
 	// Make sure the new email doesn't belong to another user
412
-	if ( $email != $old_user_data->user_email ) {
413
-		if ( email_exists( $email ) ) {
414
-			give_set_error( 'email_exists', esc_html__( 'The email you entered belongs to another user. Please use another.', 'give' ) );
412
+	if ($email != $old_user_data->user_email) {
413
+		if (email_exists($email)) {
414
+			give_set_error('email_exists', esc_html__('The email you entered belongs to another user. Please use another.', 'give'));
415 415
 		}
416 416
 	}
417 417
 
418 418
 	// Check for errors
419 419
 	$errors = give_get_errors();
420 420
 
421
-	if ( $errors ) {
421
+	if ($errors) {
422 422
 		// Send back to the profile editor if there are errors
423
-		wp_redirect( $data['give_redirect'] );
423
+		wp_redirect($data['give_redirect']);
424 424
 		give_die();
425 425
 	}
426 426
 
427 427
 	// Update the user
428
-	$meta    = update_user_meta( $user_id, '_give_user_address', $address );
429
-	$updated = wp_update_user( $userdata );
428
+	$meta    = update_user_meta($user_id, '_give_user_address', $address);
429
+	$updated = wp_update_user($userdata);
430 430
 
431
-	if ( $updated ) {
432
-		do_action( 'give_user_profile_updated', $user_id, $userdata );
433
-		wp_redirect( add_query_arg( 'updated', 'true', $data['give_redirect'] ) );
431
+	if ($updated) {
432
+		do_action('give_user_profile_updated', $user_id, $userdata);
433
+		wp_redirect(add_query_arg('updated', 'true', $data['give_redirect']));
434 434
 		give_die();
435 435
 	}
436 436
 
437 437
 	return false;
438 438
 }
439 439
 
440
-add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' );
440
+add_action('give_edit_user_profile', 'give_process_profile_editor_updates');
441 441
 
Please login to merge, or discard this patch.
includes/post-types.php 1 patch
Spacing   +135 added lines, -135 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,40 +23,40 @@  discard block
 block discarded – undo
23 23
 function give_setup_post_types() {
24 24
 
25 25
 	/** Give Forms Post Type */
26
-	$give_forms_singular = give_get_option( 'disable_forms_singular' ) !== 'on' ? true : false;
26
+	$give_forms_singular = give_get_option('disable_forms_singular') !== 'on' ? true : false;
27 27
 
28
-	$give_forms_archives = give_get_option( 'disable_forms_archives' ) !== 'on' ? true : false;
28
+	$give_forms_archives = give_get_option('disable_forms_archives') !== 'on' ? true : false;
29 29
 
30
-	$give_forms_slug = defined( 'GIVE_SLUG' ) ? GIVE_SLUG : 'donations';
30
+	$give_forms_slug = defined('GIVE_SLUG') ? GIVE_SLUG : 'donations';
31 31
 	//support for old 'GIVE_FORMS_SLUG' constant
32
-	if ( defined( 'GIVE_FORMS_SLUG' ) ) {
32
+	if (defined('GIVE_FORMS_SLUG')) {
33 33
 		$give_forms_slug = GIVE_FORMS_SLUG;
34 34
 	}
35 35
 
36
-	$give_forms_rewrite = defined( 'GIVE_DISABLE_FORMS_REWRITE' ) && GIVE_DISABLE_FORMS_REWRITE ? false : array(
36
+	$give_forms_rewrite = defined('GIVE_DISABLE_FORMS_REWRITE') && GIVE_DISABLE_FORMS_REWRITE ? false : array(
37 37
 		'slug'       => $give_forms_slug,
38 38
 		'with_front' => false
39 39
 	);
40 40
 
41
-	$give_forms_labels = apply_filters( 'give_forms_labels', array(
42
-		'name'               => esc_html__( 'Donation %2$s', 'give' ),
41
+	$give_forms_labels = apply_filters('give_forms_labels', array(
42
+		'name'               => esc_html__('Donation %2$s', 'give'),
43 43
 		'singular_name'      => '%1$s',
44
-		'add_new'            => esc_html__( 'Add %1$s', 'give' ),
45
-		'add_new_item'       => esc_html__( 'Add New Donation %1$s', 'give' ),
46
-		'edit_item'          => esc_html__( 'Edit Donation %1$s', 'give' ),
47
-		'new_item'           => esc_html__( 'New %1$s', 'give' ),
48
-		'all_items'          => esc_html__( 'All %2$s', 'give' ),
49
-		'view_item'          => esc_html__( 'View %1$s', 'give' ),
50
-		'search_items'       => esc_html__( 'Search %2$s', 'give' ),
51
-		'not_found'          => esc_html__( 'No %2$s found', 'give' ),
52
-		'not_found_in_trash' => esc_html__( 'No %2$s found in Trash', 'give' ),
44
+		'add_new'            => esc_html__('Add %1$s', 'give'),
45
+		'add_new_item'       => esc_html__('Add New Donation %1$s', 'give'),
46
+		'edit_item'          => esc_html__('Edit Donation %1$s', 'give'),
47
+		'new_item'           => esc_html__('New %1$s', 'give'),
48
+		'all_items'          => esc_html__('All %2$s', 'give'),
49
+		'view_item'          => esc_html__('View %1$s', 'give'),
50
+		'search_items'       => esc_html__('Search %2$s', 'give'),
51
+		'not_found'          => esc_html__('No %2$s found', 'give'),
52
+		'not_found_in_trash' => esc_html__('No %2$s found in Trash', 'give'),
53 53
 		'parent_item_colon'  => '',
54
-		'menu_name'          => apply_filters( 'give_menu_name', esc_html__( 'Donations', 'give' ) ),
55
-		'name_admin_bar'     => apply_filters( 'give_name_admin_bar_name', esc_html__( 'Donation Form', 'give' ) )
56
-	) );
54
+		'menu_name'          => apply_filters('give_menu_name', esc_html__('Donations', 'give')),
55
+		'name_admin_bar'     => apply_filters('give_name_admin_bar_name', esc_html__('Donation Form', 'give'))
56
+	));
57 57
 
58
-	foreach ( $give_forms_labels as $key => $value ) {
59
-		$give_forms_labels[ $key ] = sprintf( $value, give_get_forms_label_singular(), give_get_forms_label_plural() );
58
+	foreach ($give_forms_labels as $key => $value) {
59
+		$give_forms_labels[$key] = sprintf($value, give_get_forms_label_singular(), give_get_forms_label_plural());
60 60
 	}
61 61
 
62 62
 	//Default give_forms supports
@@ -69,14 +69,14 @@  discard block
 block discarded – undo
69 69
 	);
70 70
 
71 71
 	//Has the user disabled the excerpt
72
-	if ( give_get_option( 'disable_forms_excerpt' ) === 'on' ) {
73
-		unset( $give_form_supports[2] );
72
+	if (give_get_option('disable_forms_excerpt') === 'on') {
73
+		unset($give_form_supports[2]);
74 74
 	}
75 75
 
76 76
 	//Has user disabled the featured image?
77
-	if ( give_get_option( 'disable_form_featured_img' ) === 'on' ) {
78
-		unset( $give_form_supports[1] );
79
-		remove_action( 'give_before_single_form_summary', 'give_show_form_images' );
77
+	if (give_get_option('disable_form_featured_img') === 'on') {
78
+		unset($give_form_supports[1]);
79
+		remove_action('give_before_single_form_summary', 'give_show_form_images');
80 80
 	}
81 81
 
82 82
 	$give_forms_args = array(
@@ -92,42 +92,42 @@  discard block
 block discarded – undo
92 92
 		'has_archive'        => $give_forms_archives,
93 93
 		'menu_icon'          => 'dashicons-give',
94 94
 		'hierarchical'       => false,
95
-		'supports'           => apply_filters( 'give_forms_supports', $give_form_supports ),
95
+		'supports'           => apply_filters('give_forms_supports', $give_form_supports),
96 96
 	);
97
-	register_post_type( 'give_forms', apply_filters( 'give_forms_post_type_args', $give_forms_args ) );
97
+	register_post_type('give_forms', apply_filters('give_forms_post_type_args', $give_forms_args));
98 98
 	
99 99
 	/** Payment Post Type */
100 100
 	$payment_labels = array(
101
-		'name'               => _x( 'Donations', 'post type general name', 'give' ),
102
-		'singular_name'      => _x( 'Donation', 'post type singular name', 'give' ),
103
-		'add_new'            => esc_html__( 'Add New', 'give' ),
104
-		'add_new_item'       => esc_html__( 'Add New Donation', 'give' ),
105
-		'edit_item'          => esc_html__( 'Edit Donation', 'give' ),
106
-		'new_item'           => esc_html__( 'New Donation', 'give' ),
107
-		'all_items'          => esc_html__( 'All Donations', 'give' ),
108
-		'view_item'          => esc_html__( 'View Donation', 'give' ),
109
-		'search_items'       => esc_html__( 'Search Donations', 'give' ),
110
-		'not_found'          => esc_html__( 'No Donations found', 'give' ),
111
-		'not_found_in_trash' => esc_html__( 'No Donations found in Trash', 'give' ),
101
+		'name'               => _x('Donations', 'post type general name', 'give'),
102
+		'singular_name'      => _x('Donation', 'post type singular name', 'give'),
103
+		'add_new'            => esc_html__('Add New', 'give'),
104
+		'add_new_item'       => esc_html__('Add New Donation', 'give'),
105
+		'edit_item'          => esc_html__('Edit Donation', 'give'),
106
+		'new_item'           => esc_html__('New Donation', 'give'),
107
+		'all_items'          => esc_html__('All Donations', 'give'),
108
+		'view_item'          => esc_html__('View Donation', 'give'),
109
+		'search_items'       => esc_html__('Search Donations', 'give'),
110
+		'not_found'          => esc_html__('No Donations found', 'give'),
111
+		'not_found_in_trash' => esc_html__('No Donations found in Trash', 'give'),
112 112
 		'parent_item_colon'  => '',
113
-		'menu_name'          => esc_html__( 'Transactions', 'give' )
113
+		'menu_name'          => esc_html__('Transactions', 'give')
114 114
 	);
115 115
 
116 116
 	$payment_args = array(
117
-		'labels'          => apply_filters( 'give_payment_labels', $payment_labels ),
117
+		'labels'          => apply_filters('give_payment_labels', $payment_labels),
118 118
 		'public'          => false,
119 119
 		'query_var'       => false,
120 120
 		'rewrite'         => false,
121 121
 		'map_meta_cap'    => true,
122 122
 		'capability_type' => 'give_payment',
123
-		'supports'        => array( 'title' ),
123
+		'supports'        => array('title'),
124 124
 		'can_export'      => true
125 125
 	);
126
-	register_post_type( 'give_payment', $payment_args );
126
+	register_post_type('give_payment', $payment_args);
127 127
 
128 128
 }
129 129
 
130
-add_action( 'init', 'give_setup_post_types', 1 );
130
+add_action('init', 'give_setup_post_types', 1);
131 131
 
132 132
 
133 133
 /**
@@ -140,32 +140,32 @@  discard block
 block discarded – undo
140 140
  */
141 141
 function give_setup_taxonomies() {
142 142
 
143
-	$slug = defined( 'GIVE_FORMS_SLUG' ) ? GIVE_FORMS_SLUG : 'donations';
143
+	$slug = defined('GIVE_FORMS_SLUG') ? GIVE_FORMS_SLUG : 'donations';
144 144
 
145 145
 	/** Categories */
146 146
 	$category_labels = array(
147 147
 		/* translators: %s: form singular label */
148
-		'name'              => sprintf( _x( '%s Categories', 'taxonomy general name', 'give' ), give_get_forms_label_singular() ),
149
-		'singular_name'     => _x( 'Category', 'taxonomy singular name', 'give' ),
150
-		'search_items'      => esc_html__( 'Search Categories', 'give' ),
151
-		'all_items'         => esc_html__( 'All Categories', 'give' ),
152
-		'parent_item'       => esc_html__( 'Parent Category', 'give' ),
153
-		'parent_item_colon' => esc_html__( 'Parent Category:', 'give' ),
154
-		'edit_item'         => esc_html__( 'Edit Category', 'give' ),
155
-		'update_item'       => esc_html__( 'Update Category', 'give' ),
148
+		'name'              => sprintf(_x('%s Categories', 'taxonomy general name', 'give'), give_get_forms_label_singular()),
149
+		'singular_name'     => _x('Category', 'taxonomy singular name', 'give'),
150
+		'search_items'      => esc_html__('Search Categories', 'give'),
151
+		'all_items'         => esc_html__('All Categories', 'give'),
152
+		'parent_item'       => esc_html__('Parent Category', 'give'),
153
+		'parent_item_colon' => esc_html__('Parent Category:', 'give'),
154
+		'edit_item'         => esc_html__('Edit Category', 'give'),
155
+		'update_item'       => esc_html__('Update Category', 'give'),
156 156
 		/* translators: %s: form singular label */
157
-		'add_new_item'      => sprintf( esc_html__( 'Add New %s Category', 'give' ), give_get_forms_label_singular() ),
158
-		'new_item_name'     => esc_html__( 'New Category Name', 'give' ),
159
-		'menu_name'         => esc_html__( 'Categories', 'give' ),
157
+		'add_new_item'      => sprintf(esc_html__('Add New %s Category', 'give'), give_get_forms_label_singular()),
158
+		'new_item_name'     => esc_html__('New Category Name', 'give'),
159
+		'menu_name'         => esc_html__('Categories', 'give'),
160 160
 	);
161 161
 
162
-	$category_args = apply_filters( 'give_forms_category_args', array(
162
+	$category_args = apply_filters('give_forms_category_args', array(
163 163
 			'hierarchical' => true,
164
-			'labels'       => apply_filters( 'give_forms_category_labels', $category_labels ),
164
+			'labels'       => apply_filters('give_forms_category_labels', $category_labels),
165 165
 			'show_ui'      => true,
166 166
 			'query_var'    => 'give_forms_category',
167 167
 			'rewrite'      => array(
168
-				'slug'         => $slug . '/category',
168
+				'slug'         => $slug.'/category',
169 169
 				'with_front'   => false,
170 170
 				'hierarchical' => true
171 171
 			),
@@ -179,36 +179,36 @@  discard block
 block discarded – undo
179 179
 	);
180 180
 
181 181
 	//Does the user want categories?
182
-	if ( give_get_option( 'enable_categories' ) == 'on' ) {
183
-		register_taxonomy( 'give_forms_category', array( 'give_forms' ), $category_args );
184
-		register_taxonomy_for_object_type( 'give_forms_category', 'give_forms' );
182
+	if (give_get_option('enable_categories') == 'on') {
183
+		register_taxonomy('give_forms_category', array('give_forms'), $category_args);
184
+		register_taxonomy_for_object_type('give_forms_category', 'give_forms');
185 185
 	}
186 186
 
187 187
 
188 188
 	/** Tags */
189 189
 	$tag_labels = array(
190 190
 		/* translators: %s: form singular label */
191
-		'name'                  => sprintf( _x( '%s Tags', 'taxonomy general name', 'give' ), give_get_forms_label_singular() ),
192
-		'singular_name'         => _x( 'Tag', 'taxonomy singular name', 'give' ),
193
-		'search_items'          => esc_html__( 'Search Tags', 'give' ),
194
-		'all_items'             => esc_html__( 'All Tags', 'give' ),
195
-		'parent_item'           => esc_html__( 'Parent Tag', 'give' ),
196
-		'parent_item_colon'     => esc_html__( 'Parent Tag:', 'give' ),
197
-		'edit_item'             => esc_html__( 'Edit Tag', 'give' ),
198
-		'update_item'           => esc_html__( 'Update Tag', 'give' ),
199
-		'add_new_item'          => esc_html__( 'Add New Tag', 'give' ),
200
-		'new_item_name'         => esc_html__( 'New Tag Name', 'give' ),
201
-		'menu_name'             => esc_html__( 'Tags', 'give' ),
191
+		'name'                  => sprintf(_x('%s Tags', 'taxonomy general name', 'give'), give_get_forms_label_singular()),
192
+		'singular_name'         => _x('Tag', 'taxonomy singular name', 'give'),
193
+		'search_items'          => esc_html__('Search Tags', 'give'),
194
+		'all_items'             => esc_html__('All Tags', 'give'),
195
+		'parent_item'           => esc_html__('Parent Tag', 'give'),
196
+		'parent_item_colon'     => esc_html__('Parent Tag:', 'give'),
197
+		'edit_item'             => esc_html__('Edit Tag', 'give'),
198
+		'update_item'           => esc_html__('Update Tag', 'give'),
199
+		'add_new_item'          => esc_html__('Add New Tag', 'give'),
200
+		'new_item_name'         => esc_html__('New Tag Name', 'give'),
201
+		'menu_name'             => esc_html__('Tags', 'give'),
202 202
 		/* translators: %s: form singular label */
203
-		'choose_from_most_used' => sprintf( esc_html__( 'Choose from most used %s tags.', 'give' ), give_get_forms_label_singular() ),
203
+		'choose_from_most_used' => sprintf(esc_html__('Choose from most used %s tags.', 'give'), give_get_forms_label_singular()),
204 204
 	);
205 205
 
206
-	$tag_args = apply_filters( 'give_forms_tag_args', array(
206
+	$tag_args = apply_filters('give_forms_tag_args', array(
207 207
 			'hierarchical' => false,
208
-			'labels'       => apply_filters( 'give_forms_tag_labels', $tag_labels ),
208
+			'labels'       => apply_filters('give_forms_tag_labels', $tag_labels),
209 209
 			'show_ui'      => true,
210 210
 			'query_var'    => 'give_forms_tag',
211
-			'rewrite'      => array( 'slug' => $slug . '/tag', 'with_front' => false, 'hierarchical' => true ),
211
+			'rewrite'      => array('slug' => $slug.'/tag', 'with_front' => false, 'hierarchical' => true),
212 212
 			'capabilities' => array(
213 213
 				'manage_terms' => 'manage_give_forms_terms',
214 214
 				'edit_terms'   => 'edit_give_forms_terms',
@@ -219,15 +219,15 @@  discard block
 block discarded – undo
219 219
 		)
220 220
 	);
221 221
 
222
-	if ( give_get_option( 'enable_tags' ) == 'on' ) {
223
-		register_taxonomy( 'give_forms_tag', array( 'give_forms' ), $tag_args );
224
-		register_taxonomy_for_object_type( 'give_forms_tag', 'give_forms' );
222
+	if (give_get_option('enable_tags') == 'on') {
223
+		register_taxonomy('give_forms_tag', array('give_forms'), $tag_args);
224
+		register_taxonomy_for_object_type('give_forms_tag', 'give_forms');
225 225
 	}
226 226
 
227 227
 
228 228
 }
229 229
 
230
-add_action( 'init', 'give_setup_taxonomies', 0 );
230
+add_action('init', 'give_setup_taxonomies', 0);
231 231
 
232 232
 
233 233
 /**
@@ -238,11 +238,11 @@  discard block
 block discarded – undo
238 238
  */
239 239
 function give_get_default_form_labels() {
240 240
 	$defaults = array(
241
-		'singular' => esc_html__( 'Form', 'give' ),
242
-		'plural'   => esc_html__( 'Forms', 'give' )
241
+		'singular' => esc_html__('Form', 'give'),
242
+		'plural'   => esc_html__('Forms', 'give')
243 243
 	);
244 244
 
245
-	return apply_filters( 'give_default_form_name', $defaults );
245
+	return apply_filters('give_default_form_name', $defaults);
246 246
 }
247 247
 
248 248
 /**
@@ -254,10 +254,10 @@  discard block
 block discarded – undo
254 254
  *
255 255
  * @return string $defaults['singular'] Singular label
256 256
  */
257
-function give_get_forms_label_singular( $lowercase = false ) {
257
+function give_get_forms_label_singular($lowercase = false) {
258 258
 	$defaults = give_get_default_form_labels();
259 259
 
260
-	return ( $lowercase ) ? strtolower( $defaults['singular'] ) : $defaults['singular'];
260
+	return ($lowercase) ? strtolower($defaults['singular']) : $defaults['singular'];
261 261
 }
262 262
 
263 263
 /**
@@ -266,10 +266,10 @@  discard block
 block discarded – undo
266 266
  * @since 1.0
267 267
  * @return string $defaults['plural'] Plural label
268 268
  */
269
-function give_get_forms_label_plural( $lowercase = false ) {
269
+function give_get_forms_label_plural($lowercase = false) {
270 270
 	$defaults = give_get_default_form_labels();
271 271
 
272
-	return ( $lowercase ) ? strtolower( $defaults['plural'] ) : $defaults['plural'];
272
+	return ($lowercase) ? strtolower($defaults['plural']) : $defaults['plural'];
273 273
 }
274 274
 
275 275
 /**
@@ -281,12 +281,12 @@  discard block
 block discarded – undo
281 281
  *
282 282
  * @return string $title New placeholder text
283 283
  */
284
-function give_change_default_title( $title ) {
284
+function give_change_default_title($title) {
285 285
 	// If a frontend plugin uses this filter (check extensions before changing this function)
286
-	if ( ! is_admin() ) {
286
+	if ( ! is_admin()) {
287 287
 		$title = sprintf(
288 288
 			/* translators: %s: form singular label */
289
-			esc_html__( 'Enter %s title here', 'give' ),
289
+			esc_html__('Enter %s title here', 'give'),
290 290
 			give_get_forms_label_singular()
291 291
 		);
292 292
 
@@ -295,10 +295,10 @@  discard block
 block discarded – undo
295 295
 
296 296
 	$screen = get_current_screen();
297 297
 
298
-	if ( 'give_forms' == $screen->post_type ) {
298
+	if ('give_forms' == $screen->post_type) {
299 299
 		$title = sprintf(
300 300
 			/* translators: %s: form singular label */
301
-			esc_html__( 'Enter %s title here', 'give' ),
301
+			esc_html__('Enter %s title here', 'give'),
302 302
 			give_get_forms_label_singular()
303 303
 		);
304 304
 	}
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 	return $title;
307 307
 }
308 308
 
309
-add_filter( 'enter_title_here', 'give_change_default_title' );
309
+add_filter('enter_title_here', 'give_change_default_title');
310 310
 
311 311
 /**
312 312
  * Registers Custom Post Statuses which are used by the Payments
@@ -316,50 +316,50 @@  discard block
 block discarded – undo
316 316
  */
317 317
 function give_register_post_type_statuses() {
318 318
 	// Payment Statuses
319
-	register_post_status( 'refunded', array(
320
-		'label'                     => _x( 'Refunded', 'Refunded payment status', 'give' ),
319
+	register_post_status('refunded', array(
320
+		'label'                     => _x('Refunded', 'Refunded payment status', 'give'),
321 321
 		'public'                    => true,
322 322
 		'exclude_from_search'       => false,
323 323
 		'show_in_admin_all_list'    => true,
324 324
 		'show_in_admin_status_list' => true,
325
-		'label_count'               => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give' )
326
-	) );
327
-	register_post_status( 'failed', array(
328
-		'label'                     => _x( 'Failed', 'Failed payment status', 'give' ),
325
+		'label_count'               => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give')
326
+	));
327
+	register_post_status('failed', array(
328
+		'label'                     => _x('Failed', 'Failed payment status', 'give'),
329 329
 		'public'                    => true,
330 330
 		'exclude_from_search'       => false,
331 331
 		'show_in_admin_all_list'    => true,
332 332
 		'show_in_admin_status_list' => true,
333
-		'label_count'               => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give' )
334
-	) );
335
-	register_post_status( 'revoked', array(
336
-		'label'                     => _x( 'Revoked', 'Revoked payment status', 'give' ),
333
+		'label_count'               => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give')
334
+	));
335
+	register_post_status('revoked', array(
336
+		'label'                     => _x('Revoked', 'Revoked payment status', 'give'),
337 337
 		'public'                    => true,
338 338
 		'exclude_from_search'       => false,
339 339
 		'show_in_admin_all_list'    => true,
340 340
 		'show_in_admin_status_list' => true,
341
-		'label_count'               => _n_noop( 'Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give' )
342
-	) );
343
-	register_post_status( 'cancelled', array(
344
-		'label'                     => _x( 'Cancelled', 'Cancelled payment status', 'give' ),
341
+		'label_count'               => _n_noop('Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give')
342
+	));
343
+	register_post_status('cancelled', array(
344
+		'label'                     => _x('Cancelled', 'Cancelled payment status', 'give'),
345 345
 		'public'                    => true,
346 346
 		'exclude_from_search'       => false,
347 347
 		'show_in_admin_all_list'    => true,
348 348
 		'show_in_admin_status_list' => true,
349
-		'label_count'               => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give' )
350
-	) );
351
-	register_post_status( 'abandoned', array(
352
-		'label'                     => _x( 'Abandoned', 'Abandoned payment status', 'give' ),
349
+		'label_count'               => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give')
350
+	));
351
+	register_post_status('abandoned', array(
352
+		'label'                     => _x('Abandoned', 'Abandoned payment status', 'give'),
353 353
 		'public'                    => true,
354 354
 		'exclude_from_search'       => false,
355 355
 		'show_in_admin_all_list'    => true,
356 356
 		'show_in_admin_status_list' => true,
357
-		'label_count'               => _n_noop( 'Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give' )
358
-	) );
357
+		'label_count'               => _n_noop('Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give')
358
+	));
359 359
 
360 360
 }
361 361
 
362
-add_action( 'init', 'give_register_post_type_statuses' );
362
+add_action('init', 'give_register_post_type_statuses');
363 363
 
364 364
 /**
365 365
  * Updated Messages
@@ -372,43 +372,43 @@  discard block
 block discarded – undo
372 372
  *
373 373
  * @return array $messages New post updated messages
374 374
  */
375
-function give_updated_messages( $messages ) {
375
+function give_updated_messages($messages) {
376 376
 	global $post, $post_ID;
377 377
 
378
-	$url1 = '<a href="' . get_permalink( $post_ID ) . '">';
378
+	$url1 = '<a href="'.get_permalink($post_ID).'">';
379 379
 	$url2 = give_get_forms_label_singular();
380 380
 	$url3 = '</a>';
381 381
 
382 382
 	$messages['give_forms'] = array(
383
-		1 => sprintf( __( '%2$s updated. %1$sView %2$s%3$s.', 'give' ), $url1, $url2, $url3 ),
384
-		4 => sprintf( __( '%2$s updated. %1$sView %2$s%3$s.', 'give' ), $url1, $url2, $url3 ),
385
-		6 => sprintf( __( '%2$s published. %1$sView %2$s%3$s.', 'give' ), $url1, $url2, $url3 ),
386
-		7 => sprintf( __( '%2$s saved. %1$sView %2$s%3$s.', 'give' ), $url1, $url2, $url3 ),
387
-		8 => sprintf( __( '%2$s submitted. %1$sView %2$s%3$s.', 'give' ), $url1, $url2, $url3 )
383
+		1 => sprintf(__('%2$s updated. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3),
384
+		4 => sprintf(__('%2$s updated. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3),
385
+		6 => sprintf(__('%2$s published. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3),
386
+		7 => sprintf(__('%2$s saved. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3),
387
+		8 => sprintf(__('%2$s submitted. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3)
388 388
 	);
389 389
 
390 390
 	return $messages;
391 391
 }
392 392
 
393
-add_filter( 'post_updated_messages', 'give_updated_messages' );
393
+add_filter('post_updated_messages', 'give_updated_messages');
394 394
 
395 395
 
396 396
 /**
397 397
  * Setup Post Type Images
398 398
  */
399
-add_action( 'after_setup_theme', 'give_add_thumbnail_support', 10 );
399
+add_action('after_setup_theme', 'give_add_thumbnail_support', 10);
400 400
 
401 401
 /**
402 402
  * Ensure post thumbnail support is turned on
403 403
  */
404 404
 function give_add_thumbnail_support() {
405
-	if ( give_get_option( 'disable_form_featured_img' ) === 'on' ) {
405
+	if (give_get_option('disable_form_featured_img') === 'on') {
406 406
 		return;
407 407
 	}
408
-	if ( ! current_theme_supports( 'post-thumbnails' ) ) {
409
-		add_theme_support( 'post-thumbnails' );
408
+	if ( ! current_theme_supports('post-thumbnails')) {
409
+		add_theme_support('post-thumbnails');
410 410
 	}
411
-	add_post_type_support( 'give_forms', 'thumbnail' );
411
+	add_post_type_support('give_forms', 'thumbnail');
412 412
 }
413 413
 
414 414
 /**
@@ -420,19 +420,19 @@  discard block
 block discarded – undo
420 420
 function give_widgets_init() {
421 421
 
422 422
 	//Single Give Forms (disabled if single turned off in settings)
423
-	if ( give_get_option( 'disable_forms_singular' ) !== 'on' && give_get_option( 'disable_form_sidebar' ) !== 'on' ) {
423
+	if (give_get_option('disable_forms_singular') !== 'on' && give_get_option('disable_form_sidebar') !== 'on') {
424 424
 
425
-		register_sidebar( apply_filters( 'give_forms_single_sidebar', array(
426
-			'name'          => esc_html__( 'Give Single Form Sidebar', 'give' ),
425
+		register_sidebar(apply_filters('give_forms_single_sidebar', array(
426
+			'name'          => esc_html__('Give Single Form Sidebar', 'give'),
427 427
 			'id'            => 'give-forms-sidebar',
428
-			'description'   => esc_html__( 'Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give' ),
428
+			'description'   => esc_html__('Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give'),
429 429
 			'before_widget' => '<div id="%1$s" class="widget %2$s">',
430 430
 			'after_widget'  => '</div>',
431 431
 			'before_title'  => '<h3 class="widgettitle widget-title">',
432 432
 			'after_title'   => '</h3>',
433
-		) ) );
433
+		)));
434 434
 
435 435
 	}
436 436
 }
437 437
 
438
-add_action( 'widgets_init', 'give_widgets_init', 999 );
438
+add_action('widgets_init', 'give_widgets_init', 999);
Please login to merge, or discard this patch.
includes/class-give-cron.php 1 patch
Spacing   +9 added lines, -9 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
 
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
 	 * @see   Give_Cron::weekly_events()
30 30
 	 */
31 31
 	public function __construct() {
32
-		add_filter( 'cron_schedules', array( $this, 'add_schedules' ) );
33
-		add_action( 'wp', array( $this, 'schedule_Events' ) );
32
+		add_filter('cron_schedules', array($this, 'add_schedules'));
33
+		add_action('wp', array($this, 'schedule_Events'));
34 34
 	}
35 35
 
36 36
 	/**
@@ -42,11 +42,11 @@  discard block
 block discarded – undo
42 42
 	 *
43 43
 	 * @return array
44 44
 	 */
45
-	public function add_schedules( $schedules = array() ) {
45
+	public function add_schedules($schedules = array()) {
46 46
 		// Adds once weekly to the existing schedules.
47 47
 		$schedules['weekly'] = array(
48 48
 			'interval' => 604800,
49
-			'display'  => esc_html__( 'Once Weekly', 'easy-digital-downloads' )
49
+			'display'  => esc_html__('Once Weekly', 'easy-digital-downloads')
50 50
 		);
51 51
 
52 52
 		return $schedules;
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
 	 * @return void
73 73
 	 */
74 74
 	private function weekly_events() {
75
-		if ( ! wp_next_scheduled( 'give_weekly_scheduled_events' ) ) {
76
-			wp_schedule_event( current_time( 'timestamp' ), 'weekly', 'give_weekly_scheduled_events' );
75
+		if ( ! wp_next_scheduled('give_weekly_scheduled_events')) {
76
+			wp_schedule_event(current_time('timestamp'), 'weekly', 'give_weekly_scheduled_events');
77 77
 		}
78 78
 	}
79 79
 
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 	 * @return void
86 86
 	 */
87 87
 	private function daily_events() {
88
-		if ( ! wp_next_scheduled( 'give_daily_scheduled_events' ) ) {
89
-			wp_schedule_event( current_time( 'timestamp' ), 'daily', 'give_daily_scheduled_events' );
88
+		if ( ! wp_next_scheduled('give_daily_scheduled_events')) {
89
+			wp_schedule_event(current_time('timestamp'), 'daily', 'give_daily_scheduled_events');
90 90
 		}
91 91
 	}
92 92
 
Please login to merge, or discard this patch.
includes/process-purchase.php 1 patch
Spacing   +234 added lines, -234 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -25,27 +25,27 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function give_process_purchase_form() {
27 27
 
28
-	do_action( 'give_pre_process_purchase' );
28
+	do_action('give_pre_process_purchase');
29 29
 
30 30
 	// Validate the form $_POST data
31 31
 	$valid_data = give_purchase_form_validate_fields();
32 32
 
33 33
 	// Allow themes and plugins to hook to errors
34
-	do_action( 'give_checkout_error_checks', $valid_data, $_POST );
34
+	do_action('give_checkout_error_checks', $valid_data, $_POST);
35 35
 
36
-	$is_ajax = isset( $_POST['give_ajax'] );
36
+	$is_ajax = isset($_POST['give_ajax']);
37 37
 
38 38
 	// Process the login form
39
-	if ( isset( $_POST['give_login_submit'] ) ) {
39
+	if (isset($_POST['give_login_submit'])) {
40 40
 		give_process_form_login();
41 41
 	}
42 42
 
43 43
 	// Validate the user
44
-	$user = give_get_purchase_form_user( $valid_data );
44
+	$user = give_get_purchase_form_user($valid_data);
45 45
 
46
-	if ( false === $valid_data || give_get_errors() || ! $user ) {
47
-		if ( $is_ajax ) {
48
-			do_action( 'give_ajax_checkout_errors' );
46
+	if (false === $valid_data || give_get_errors() || ! $user) {
47
+		if ($is_ajax) {
48
+			do_action('give_ajax_checkout_errors');
49 49
 			give_die();
50 50
 		} else {
51 51
 			return false;
@@ -53,17 +53,17 @@  discard block
 block discarded – undo
53 53
 	}
54 54
 
55 55
 	//If AJAX send back success to proceed with form submission
56
-	if ( $is_ajax ) {
56
+	if ($is_ajax) {
57 57
 		echo 'success';
58 58
 		give_die();
59 59
 	}
60 60
 
61 61
 	//After AJAX: Setup session if not using php_sessions
62
-	if ( ! Give()->session->use_php_sessions() ) {
62
+	if ( ! Give()->session->use_php_sessions()) {
63 63
 		//Double-check that set_cookie is publicly accessible;
64 64
 		// we're using a slightly modified class-wp-sessions.php
65
-		$session_reflection = new ReflectionMethod( 'WP_Session', 'set_cookie' );
66
-		if ( $session_reflection->isPublic() ) {
65
+		$session_reflection = new ReflectionMethod('WP_Session', 'set_cookie');
66
+		if ($session_reflection->isPublic()) {
67 67
 			// Manually set the cookie.
68 68
 			Give()->session->init()->set_cookie();
69 69
 		}
@@ -78,18 +78,18 @@  discard block
 block discarded – undo
78 78
 		'address'    => $user['address']
79 79
 	);
80 80
 
81
-	$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
81
+	$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
82 82
 
83
-	$price        = isset( $_POST['give-amount'] ) ? (float) apply_filters( 'give_donation_total', give_sanitize_amount( give_format_amount( $_POST['give-amount'] ) ) ) : '0.00';
84
-	$purchase_key = strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) );
83
+	$price        = isset($_POST['give-amount']) ? (float) apply_filters('give_donation_total', give_sanitize_amount(give_format_amount($_POST['give-amount']))) : '0.00';
84
+	$purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true)));
85 85
 
86 86
 	// Setup purchase information
87 87
 	$purchase_data = array(
88 88
 		'price'        => $price,
89 89
 		'purchase_key' => $purchase_key,
90 90
 		'user_email'   => $user['user_email'],
91
-		'date'         => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ),
92
-		'user_info'    => stripslashes_deep( $user_info ),
91
+		'date'         => date('Y-m-d H:i:s', current_time('timestamp')),
92
+		'user_info'    => stripslashes_deep($user_info),
93 93
 		'post_data'    => $_POST,
94 94
 		'gateway'      => $valid_data['gateway'],
95 95
 		'card_info'    => $valid_data['cc_info']
@@ -99,37 +99,37 @@  discard block
 block discarded – undo
99 99
 	$valid_data['user'] = $user;
100 100
 
101 101
 	// Allow themes and plugins to hook before the gateway
102
-	do_action( 'give_checkout_before_gateway', $_POST, $user_info, $valid_data );
102
+	do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data);
103 103
 
104 104
 	//Sanity check for price
105
-	if ( ! $purchase_data['price'] ) {
105
+	if ( ! $purchase_data['price']) {
106 106
 		// Revert to manual
107 107
 		$purchase_data['gateway'] = 'manual';
108 108
 		$_POST['give-gateway']    = 'manual';
109 109
 	}
110 110
 
111 111
 	// Allow the purchase data to be modified before it is sent to the gateway
112
-	$purchase_data = apply_filters( 'give_purchase_data_before_gateway', $purchase_data, $valid_data );
112
+	$purchase_data = apply_filters('give_purchase_data_before_gateway', $purchase_data, $valid_data);
113 113
 
114 114
 	// Setup the data we're storing in the purchase session
115 115
 	$session_data = $purchase_data;
116 116
 
117 117
 	// Make sure credit card numbers are never stored in sessions
118
-	unset( $session_data['card_info']['card_number'] );
119
-	unset( $session_data['post_data']['card_number'] );
118
+	unset($session_data['card_info']['card_number']);
119
+	unset($session_data['post_data']['card_number']);
120 120
 
121 121
 	// Used for showing data to non logged-in users after purchase, and for other plugins needing purchase data.
122
-	give_set_purchase_session( $session_data );
122
+	give_set_purchase_session($session_data);
123 123
 
124 124
 	// Send info to the gateway for payment processing
125
-	give_send_to_gateway( $purchase_data['gateway'], $purchase_data );
125
+	give_send_to_gateway($purchase_data['gateway'], $purchase_data);
126 126
 	give_die();
127 127
 
128 128
 }
129 129
 
130
-add_action( 'give_purchase', 'give_process_purchase_form' );
131
-add_action( 'wp_ajax_give_process_checkout', 'give_process_purchase_form' );
132
-add_action( 'wp_ajax_nopriv_give_process_checkout', 'give_process_purchase_form' );
130
+add_action('give_purchase', 'give_process_purchase_form');
131
+add_action('wp_ajax_give_process_checkout', 'give_process_purchase_form');
132
+add_action('wp_ajax_nopriv_give_process_checkout', 'give_process_purchase_form');
133 133
 
134 134
 /**
135 135
  * Process the checkout login form
@@ -140,32 +140,32 @@  discard block
 block discarded – undo
140 140
  */
141 141
 function give_process_form_login() {
142 142
 
143
-	$is_ajax = isset( $_POST['give_ajax'] );
143
+	$is_ajax = isset($_POST['give_ajax']);
144 144
 
145 145
 	$user_data = give_purchase_form_validate_user_login();
146 146
 
147
-	if ( give_get_errors() || $user_data['user_id'] < 1 ) {
148
-		if ( $is_ajax ) {
149
-			do_action( 'give_ajax_checkout_errors' );
147
+	if (give_get_errors() || $user_data['user_id'] < 1) {
148
+		if ($is_ajax) {
149
+			do_action('give_ajax_checkout_errors');
150 150
 			give_die();
151 151
 		} else {
152
-			wp_redirect( $_SERVER['HTTP_REFERER'] );
152
+			wp_redirect($_SERVER['HTTP_REFERER']);
153 153
 			exit;
154 154
 		}
155 155
 	}
156 156
 
157
-	give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] );
157
+	give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']);
158 158
 
159
-	if ( $is_ajax ) {
159
+	if ($is_ajax) {
160 160
 		echo 'success';
161 161
 		give_die();
162 162
 	} else {
163
-		wp_redirect( $_SERVER['HTTP_REFERER'] );
163
+		wp_redirect($_SERVER['HTTP_REFERER']);
164 164
 	}
165 165
 }
166 166
 
167
-add_action( 'wp_ajax_give_process_checkout_login', 'give_process_form_login' );
168
-add_action( 'wp_ajax_nopriv_give_process_checkout_login', 'give_process_form_login' );
167
+add_action('wp_ajax_give_process_checkout_login', 'give_process_form_login');
168
+add_action('wp_ajax_nopriv_give_process_checkout_login', 'give_process_form_login');
169 169
 
170 170
 /**
171 171
  * Purchase Form Validate Fields
@@ -177,45 +177,45 @@  discard block
 block discarded – undo
177 177
 function give_purchase_form_validate_fields() {
178 178
 
179 179
 	// Check if there is $_POST
180
-	if ( empty( $_POST ) ) {
180
+	if (empty($_POST)) {
181 181
 		return false;
182 182
 	}
183 183
 
184
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
184
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
185 185
 
186 186
 	// Start an array to collect valid data
187 187
 	$valid_data = array(
188 188
 		'gateway'          => give_purchase_form_validate_gateway(), // Gateway fallback (amount is validated here)
189
-		'need_new_user'    => false,     // New user flag
190
-		'need_user_login'  => false,     // Login user flag
191
-		'logged_user_data' => array(),   // Logged user collected data
192
-		'new_user_data'    => array(),   // New user collected data
193
-		'login_user_data'  => array(),   // Login user collected data
194
-		'guest_user_data'  => array(),   // Guest user collected data
189
+		'need_new_user'    => false, // New user flag
190
+		'need_user_login'  => false, // Login user flag
191
+		'logged_user_data' => array(), // Logged user collected data
192
+		'new_user_data'    => array(), // New user collected data
193
+		'login_user_data'  => array(), // Login user collected data
194
+		'guest_user_data'  => array(), // Guest user collected data
195 195
 		'cc_info'          => give_purchase_form_validate_cc()    // Credit card info
196 196
 	);
197 197
 
198 198
 	//Validate Honeypot First
199
-	if ( ! empty( $_POST['give-honeypot'] ) ) {
200
-		give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) );
199
+	if ( ! empty($_POST['give-honeypot'])) {
200
+		give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give'));
201 201
 	}
202 202
 
203 203
 	// Validate agree to terms
204
-	$terms_option = get_post_meta( $form_id, '_give_terms_option', true );
205
-	if ( isset( $terms_option ) && $terms_option === 'yes' ) {
204
+	$terms_option = get_post_meta($form_id, '_give_terms_option', true);
205
+	if (isset($terms_option) && $terms_option === 'yes') {
206 206
 		give_purchase_form_validate_agree_to_terms();
207 207
 	}
208 208
 
209
-	if ( is_user_logged_in() ) {
209
+	if (is_user_logged_in()) {
210 210
 		// Collect logged in user data
211 211
 		$valid_data['logged_in_user'] = give_purchase_form_validate_logged_in_user();
212
-	} else if ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) {
212
+	} else if (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') {
213 213
 		// Set new user registration as required
214 214
 		$valid_data['need_new_user'] = true;
215 215
 		// Validate new user data
216 216
 		$valid_data['new_user_data'] = give_purchase_form_validate_new_user();
217 217
 		// Check if login validation is needed
218
-	} else if ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) {
218
+	} else if (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') {
219 219
 		// Set user login as required
220 220
 		$valid_data['need_user_login'] = true;
221 221
 		// Validate users login info
@@ -240,41 +240,41 @@  discard block
 block discarded – undo
240 240
  */
241 241
 function give_purchase_form_validate_gateway() {
242 242
 
243
-	$form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
244
-	$amount  = isset( $_REQUEST['give-amount'] ) ? give_sanitize_amount( $_REQUEST['give-amount'] ) : 0;
245
-	$gateway = give_get_default_gateway( $form_id );
243
+	$form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
244
+	$amount  = isset($_REQUEST['give-amount']) ? give_sanitize_amount($_REQUEST['give-amount']) : 0;
245
+	$gateway = give_get_default_gateway($form_id);
246 246
 
247 247
 	// Check if a gateway value is present
248
-	if ( ! empty( $_REQUEST['give-gateway'] ) ) {
248
+	if ( ! empty($_REQUEST['give-gateway'])) {
249 249
 
250
-		$gateway = sanitize_text_field( $_REQUEST['give-gateway'] );
250
+		$gateway = sanitize_text_field($_REQUEST['give-gateway']);
251 251
 
252 252
 		//Is amount being donated in LIVE mode 0.00? If so, error:
253
-		if ( $amount == 0 && ! give_is_test_mode() ) {
253
+		if ($amount == 0 && ! give_is_test_mode()) {
254 254
 
255
-			give_set_error( 'invalid_donation_amount', esc_html__( 'Please insert a valid donation amount.', 'give' ) );
255
+			give_set_error('invalid_donation_amount', esc_html__('Please insert a valid donation amount.', 'give'));
256 256
 
257 257
 		} //Check for a minimum custom amount
258
-		elseif ( ! give_verify_minimum_price() ) {
258
+		elseif ( ! give_verify_minimum_price()) {
259 259
 
260 260
 			give_set_error(
261 261
 				'invalid_donation_minimum',
262 262
 				sprintf(
263 263
 					/* translators: %s: minimum donation amount */
264
-					esc_html__( 'This form has a minimum donation amount of %s.', 'give' ),
265
-					give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ) ) )
264
+					esc_html__('This form has a minimum donation amount of %s.', 'give'),
265
+					give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id)))
266 266
 				)
267 267
 			);
268 268
 
269 269
 		} //Is this test mode zero donation? Let it through but set to manual gateway
270
-		elseif ( $amount == 0 && give_is_test_mode() ) {
270
+		elseif ($amount == 0 && give_is_test_mode()) {
271 271
 
272 272
 			$gateway = 'manual';
273 273
 
274 274
 		} //Check if this gateway is active
275
-		elseif ( ! give_is_gateway_active( $gateway ) ) {
275
+		elseif ( ! give_is_gateway_active($gateway)) {
276 276
 
277
-			give_set_error( 'invalid_gateway', esc_html__( 'The selected payment gateway is not enabled.', 'give' ) );
277
+			give_set_error('invalid_gateway', esc_html__('The selected payment gateway is not enabled.', 'give'));
278 278
 
279 279
 		}
280 280
 
@@ -293,23 +293,23 @@  discard block
 block discarded – undo
293 293
  */
294 294
 function give_verify_minimum_price() {
295 295
 
296
-	$amount          = give_sanitize_amount( $_REQUEST['give-amount'] );
297
-	$form_id         = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
298
-	$price_id        = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : 0;
299
-	$variable_prices = give_has_variable_prices( $form_id );
296
+	$amount          = give_sanitize_amount($_REQUEST['give-amount']);
297
+	$form_id         = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
298
+	$price_id        = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : 0;
299
+	$variable_prices = give_has_variable_prices($form_id);
300 300
 
301
-	if ( $variable_prices && ! empty( $price_id ) ) {
301
+	if ($variable_prices && ! empty($price_id)) {
302 302
 
303
-		$price_level_amount = give_get_price_option_amount( $form_id, $price_id );
303
+		$price_level_amount = give_get_price_option_amount($form_id, $price_id);
304 304
 
305
-		if ( $price_level_amount == $amount ) {
305
+		if ($price_level_amount == $amount) {
306 306
 			return true;
307 307
 		}
308 308
 	}
309 309
 
310
-	$minimum = give_get_form_minimum_price( $form_id );
310
+	$minimum = give_get_form_minimum_price($form_id);
311 311
 
312
-	if ( $minimum > $amount ) {
312
+	if ($minimum > $amount) {
313 313
 		return false;
314 314
 	}
315 315
 
@@ -325,9 +325,9 @@  discard block
 block discarded – undo
325 325
  */
326 326
 function give_purchase_form_validate_agree_to_terms() {
327 327
 	// Validate agree to terms
328
-	if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) {
328
+	if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) {
329 329
 		// User did not agree
330
-		give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', esc_html__( 'You must agree to the terms of use.', 'give' ) ) );
330
+		give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', esc_html__('You must agree to the terms of use.', 'give')));
331 331
 	}
332 332
 }
333 333
 
@@ -341,47 +341,47 @@  discard block
 block discarded – undo
341 341
  *
342 342
  * @return      array
343 343
  */
344
-function give_purchase_form_required_fields( $form_id ) {
344
+function give_purchase_form_required_fields($form_id) {
345 345
 
346
-	$payment_mode = give_get_chosen_gateway( $form_id );
346
+	$payment_mode = give_get_chosen_gateway($form_id);
347 347
 
348 348
 	$required_fields = array(
349 349
 		'give_email' => array(
350 350
 			'error_id'      => 'invalid_email',
351
-			'error_message' => esc_html__( 'Please enter a valid email address.', 'give' )
351
+			'error_message' => esc_html__('Please enter a valid email address.', 'give')
352 352
 		),
353 353
 		'give_first' => array(
354 354
 			'error_id'      => 'invalid_first_name',
355
-			'error_message' => esc_html__( 'Please enter your first name.', 'give' )
355
+			'error_message' => esc_html__('Please enter your first name.', 'give')
356 356
 		)
357 357
 	);
358 358
 
359
-	$require_address = give_require_billing_address( $payment_mode );
359
+	$require_address = give_require_billing_address($payment_mode);
360 360
 
361
-	if ( $require_address ) {
362
-		$required_fields['card_address']    = array(
361
+	if ($require_address) {
362
+		$required_fields['card_address'] = array(
363 363
 			'error_id'      => 'invalid_card_address',
364
-			'error_message' => esc_html__( 'Please enter your primary billing address.', 'give' )
364
+			'error_message' => esc_html__('Please enter your primary billing address.', 'give')
365 365
 		);
366
-		$required_fields['card_zip']        = array(
366
+		$required_fields['card_zip'] = array(
367 367
 			'error_id'      => 'invalid_zip_code',
368
-			'error_message' => esc_html__( 'Please enter your zip / postal code.', 'give' )
368
+			'error_message' => esc_html__('Please enter your zip / postal code.', 'give')
369 369
 		);
370
-		$required_fields['card_city']       = array(
370
+		$required_fields['card_city'] = array(
371 371
 			'error_id'      => 'invalid_city',
372
-			'error_message' => esc_html__( 'Please enter your billing city.', 'give' )
372
+			'error_message' => esc_html__('Please enter your billing city.', 'give')
373 373
 		);
374 374
 		$required_fields['billing_country'] = array(
375 375
 			'error_id'      => 'invalid_country',
376
-			'error_message' => esc_html__( 'Please select your billing country.', 'give' )
376
+			'error_message' => esc_html__('Please select your billing country.', 'give')
377 377
 		);
378
-		$required_fields['card_state']      = array(
378
+		$required_fields['card_state'] = array(
379 379
 			'error_id'      => 'invalid_state',
380
-			'error_message' => esc_html__( 'Please enter billing state / province.', 'give' )
380
+			'error_message' => esc_html__('Please enter billing state / province.', 'give')
381 381
 		);
382 382
 	}
383 383
 
384
-	return apply_filters( 'give_purchase_form_required_fields', $required_fields, $form_id );
384
+	return apply_filters('give_purchase_form_required_fields', $required_fields, $form_id);
385 385
 
386 386
 }
387 387
 
@@ -394,16 +394,16 @@  discard block
 block discarded – undo
394 394
  *
395 395
  * @return mixed|void
396 396
  */
397
-function give_require_billing_address( $payment_mode ) {
397
+function give_require_billing_address($payment_mode) {
398 398
 
399 399
 	$return = false;
400 400
 
401
-	if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) {
401
+	if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) {
402 402
 		$return = true;
403 403
 	}
404 404
 
405 405
 	// Let payment gateways and other extensions determine if address fields should be required
406
-	return apply_filters( 'give_require_billing_address', $return );
406
+	return apply_filters('give_require_billing_address', $return);
407 407
 
408 408
 }
409 409
 
@@ -417,43 +417,43 @@  discard block
 block discarded – undo
417 417
 function give_purchase_form_validate_logged_in_user() {
418 418
 	global $user_ID;
419 419
 
420
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
420
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
421 421
 
422 422
 	// Start empty array to collect valid user data
423 423
 	$valid_user_data = array(
424 424
 		// Assume there will be errors
425
-		'user_id' => - 1
425
+		'user_id' => -1
426 426
 	);
427 427
 
428 428
 	// Verify there is a user_ID
429
-	if ( $user_ID > 0 ) {
429
+	if ($user_ID > 0) {
430 430
 		// Get the logged in user data
431
-		$user_data = get_userdata( $user_ID );
431
+		$user_data = get_userdata($user_ID);
432 432
 
433 433
 		// Loop through required fields and show error messages
434
-		foreach ( give_purchase_form_required_fields( $form_id ) as $field_name => $value ) {
435
-			if ( in_array( $value, give_purchase_form_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
436
-				give_set_error( $value['error_id'], $value['error_message'] );
434
+		foreach (give_purchase_form_required_fields($form_id) as $field_name => $value) {
435
+			if (in_array($value, give_purchase_form_required_fields($form_id)) && empty($_POST[$field_name])) {
436
+				give_set_error($value['error_id'], $value['error_message']);
437 437
 			}
438 438
 		}
439 439
 
440 440
 		// Verify data
441
-		if ( $user_data ) {
441
+		if ($user_data) {
442 442
 			// Collected logged in user data
443 443
 			$valid_user_data = array(
444 444
 				'user_id'    => $user_ID,
445
-				'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email,
446
-				'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name,
447
-				'user_last'  => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name,
445
+				'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email,
446
+				'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name,
447
+				'user_last'  => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name,
448 448
 			);
449 449
 
450
-			if ( ! is_email( $valid_user_data['user_email'] ) ) {
451
-				give_set_error( 'email_invalid', esc_html__( 'Invalid email', 'give' ) );
450
+			if ( ! is_email($valid_user_data['user_email'])) {
451
+				give_set_error('email_invalid', esc_html__('Invalid email', 'give'));
452 452
 			}
453 453
 
454 454
 		} else {
455 455
 			// Set invalid user error
456
-			give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) );
456
+			give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give'));
457 457
 		}
458 458
 	}
459 459
 
@@ -471,90 +471,90 @@  discard block
 block discarded – undo
471 471
 function give_purchase_form_validate_new_user() {
472 472
 
473 473
 	$registering_new_user = false;
474
-	$form_id              = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
474
+	$form_id              = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
475 475
 
476 476
 	// Start an empty array to collect valid user data
477 477
 	$valid_user_data = array(
478 478
 		// Assume there will be errors
479
-		'user_id'    => - 1,
479
+		'user_id'    => -1,
480 480
 		// Get first name
481
-		'user_first' => isset( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : '',
481
+		'user_first' => isset($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : '',
482 482
 		// Get last name
483
-		'user_last'  => isset( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : '',
483
+		'user_last'  => isset($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : '',
484 484
 	);
485 485
 
486 486
 	// Check the new user's credentials against existing ones
487
-	$user_login   = isset( $_POST['give_user_login'] ) ? trim( $_POST['give_user_login'] ) : false;
488
-	$user_email   = isset( $_POST['give_email'] ) ? trim( $_POST['give_email'] ) : false;
489
-	$user_pass    = isset( $_POST['give_user_pass'] ) ? trim( $_POST['give_user_pass'] ) : false;
490
-	$pass_confirm = isset( $_POST['give_user_pass_confirm'] ) ? trim( $_POST['give_user_pass_confirm'] ) : false;
487
+	$user_login   = isset($_POST['give_user_login']) ? trim($_POST['give_user_login']) : false;
488
+	$user_email   = isset($_POST['give_email']) ? trim($_POST['give_email']) : false;
489
+	$user_pass    = isset($_POST['give_user_pass']) ? trim($_POST['give_user_pass']) : false;
490
+	$pass_confirm = isset($_POST['give_user_pass_confirm']) ? trim($_POST['give_user_pass_confirm']) : false;
491 491
 
492 492
 	// Loop through required fields and show error messages
493
-	foreach ( give_purchase_form_required_fields( $form_id ) as $field_name => $value ) {
494
-		if ( in_array( $value, give_purchase_form_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
495
-			give_set_error( $value['error_id'], $value['error_message'] );
493
+	foreach (give_purchase_form_required_fields($form_id) as $field_name => $value) {
494
+		if (in_array($value, give_purchase_form_required_fields($form_id)) && empty($_POST[$field_name])) {
495
+			give_set_error($value['error_id'], $value['error_message']);
496 496
 		}
497 497
 	}
498 498
 
499 499
 	// Check if we have an username to register
500
-	if ( $user_login && strlen( $user_login ) > 0 ) {
500
+	if ($user_login && strlen($user_login) > 0) {
501 501
 		$registering_new_user = true;
502 502
 
503 503
 		// We have an user name, check if it already exists
504
-		if ( username_exists( $user_login ) ) {
504
+		if (username_exists($user_login)) {
505 505
 			// Username already registered
506
-			give_set_error( 'username_unavailable', esc_html__( 'Username already taken.', 'give' ) );
506
+			give_set_error('username_unavailable', esc_html__('Username already taken.', 'give'));
507 507
 			// Check if it's valid
508
-		} else if ( ! give_validate_username( $user_login ) ) {
508
+		} else if ( ! give_validate_username($user_login)) {
509 509
 			// Invalid username
510
-			if ( is_multisite() ) {
511
-				give_set_error( 'username_invalid', esc_html__( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ) );
510
+			if (is_multisite()) {
511
+				give_set_error('username_invalid', esc_html__('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give'));
512 512
 			} else {
513
-				give_set_error( 'username_invalid', esc_html__( 'Invalid username.', 'give' ) );
513
+				give_set_error('username_invalid', esc_html__('Invalid username.', 'give'));
514 514
 			}
515 515
 		} else {
516 516
 			// All the checks have run and it's good to go
517 517
 			$valid_user_data['user_login'] = $user_login;
518 518
 		}
519
-	} elseif ( give_logged_in_only( $form_id ) ) {
520
-		give_set_error( 'registration_required', esc_html__( 'You must register or login to complete your donation.', 'give' ) );
519
+	} elseif (give_logged_in_only($form_id)) {
520
+		give_set_error('registration_required', esc_html__('You must register or login to complete your donation.', 'give'));
521 521
 	}
522 522
 
523 523
 	// Check if we have an email to verify
524
-	if ( $user_email && strlen( $user_email ) > 0 ) {
524
+	if ($user_email && strlen($user_email) > 0) {
525 525
 		// Validate email
526
-		if ( ! is_email( $user_email ) ) {
527
-			give_set_error( 'email_invalid', esc_html__( 'Sorry, that email is invalid.', 'give' ) );
526
+		if ( ! is_email($user_email)) {
527
+			give_set_error('email_invalid', esc_html__('Sorry, that email is invalid.', 'give'));
528 528
 			// Check if email exists
529
-		} else if ( email_exists( $user_email ) && $registering_new_user ) {
530
-			give_set_error( 'email_used', esc_html__( 'Sorry, that email already active for another user.', 'give' ) );
529
+		} else if (email_exists($user_email) && $registering_new_user) {
530
+			give_set_error('email_used', esc_html__('Sorry, that email already active for another user.', 'give'));
531 531
 		} else {
532 532
 			// All the checks have run and it's good to go
533 533
 			$valid_user_data['user_email'] = $user_email;
534 534
 		}
535 535
 	} else {
536 536
 		// No email
537
-		give_set_error( 'email_empty', esc_html__( 'Enter an email.', 'give' ) );
537
+		give_set_error('email_empty', esc_html__('Enter an email.', 'give'));
538 538
 	}
539 539
 
540 540
 	// Check password
541
-	if ( $user_pass && $pass_confirm ) {
541
+	if ($user_pass && $pass_confirm) {
542 542
 		// Verify confirmation matches
543
-		if ( $user_pass != $pass_confirm ) {
543
+		if ($user_pass != $pass_confirm) {
544 544
 			// Passwords do not match
545
-			give_set_error( 'password_mismatch', esc_html__( 'Passwords don\'t match.', 'give' ) );
545
+			give_set_error('password_mismatch', esc_html__('Passwords don\'t match.', 'give'));
546 546
 		} else {
547 547
 			// All is good to go
548 548
 			$valid_user_data['user_pass'] = $user_pass;
549 549
 		}
550 550
 	} else {
551 551
 		// Password or confirmation missing
552
-		if ( ! $user_pass && $registering_new_user ) {
552
+		if ( ! $user_pass && $registering_new_user) {
553 553
 			// The password is invalid
554
-			give_set_error( 'password_empty', esc_html__( 'Enter a password.', 'give' ) );
555
-		} else if ( ! $pass_confirm && $registering_new_user ) {
554
+			give_set_error('password_empty', esc_html__('Enter a password.', 'give'));
555
+		} else if ( ! $pass_confirm && $registering_new_user) {
556 556
 			// Confirmation password is invalid
557
-			give_set_error( 'confirmation_empty', esc_html__( 'Enter the password confirmation.', 'give' ) );
557
+			give_set_error('confirmation_empty', esc_html__('Enter the password confirmation.', 'give'));
558 558
 		}
559 559
 	}
560 560
 
@@ -573,36 +573,36 @@  discard block
 block discarded – undo
573 573
 	// Start an array to collect valid user data
574 574
 	$valid_user_data = array(
575 575
 		// Assume there will be errors
576
-		'user_id' => - 1
576
+		'user_id' => -1
577 577
 	);
578 578
 
579 579
 	// Username
580
-	if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) {
581
-		give_set_error( 'must_log_in', esc_html__( 'You must login or register to complete your donation.', 'give' ) );
580
+	if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') {
581
+		give_set_error('must_log_in', esc_html__('You must login or register to complete your donation.', 'give'));
582 582
 
583 583
 		return $valid_user_data;
584 584
 	}
585 585
 
586 586
 	// Get the user by login
587
-	$user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) );
587
+	$user_data = get_user_by('login', strip_tags($_POST['give_user_login']));
588 588
 
589 589
 	// Check if user exists
590
-	if ( $user_data ) {
590
+	if ($user_data) {
591 591
 		// Get password
592
-		$user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false;
592
+		$user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false;
593 593
 
594 594
 		// Check user_pass
595
-		if ( $user_pass ) {
595
+		if ($user_pass) {
596 596
 			// Check if password is valid
597
-			if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) {
597
+			if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) {
598 598
 				// Incorrect password
599 599
 				give_set_error(
600 600
 					'password_incorrect',
601 601
 					sprintf(
602 602
 						'%1$s <a href="%2$s">%3$s</a>',
603
-						esc_html__( 'The password you entered is incorrect.', 'give' ),
604
-						wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ),
605
-						esc_html__( 'Reset Password', 'give' )
603
+						esc_html__('The password you entered is incorrect.', 'give'),
604
+						wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"),
605
+						esc_html__('Reset Password', 'give')
606 606
 					)
607 607
 				);
608 608
 				// All is correct
@@ -619,11 +619,11 @@  discard block
 block discarded – undo
619 619
 			}
620 620
 		} else {
621 621
 			// Empty password
622
-			give_set_error( 'password_empty', esc_html__( 'Enter a password.', 'give' ) );
622
+			give_set_error('password_empty', esc_html__('Enter a password.', 'give'));
623 623
 		}
624 624
 	} else {
625 625
 		// no username
626
-		give_set_error( 'username_incorrect', esc_html__( 'The username you entered does not exist.', 'give' ) );
626
+		give_set_error('username_incorrect', esc_html__('The username you entered does not exist.', 'give'));
627 627
 	}
628 628
 
629 629
 	return $valid_user_data;
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
  */
639 639
 function give_purchase_form_validate_guest_user() {
640 640
 
641
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
641
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
642 642
 
643 643
 	// Start an array to collect valid user data
644 644
 	$valid_user_data = array(
@@ -647,32 +647,32 @@  discard block
 block discarded – undo
647 647
 	);
648 648
 
649 649
 	// Show error message if user must be logged in
650
-	if ( give_logged_in_only( $form_id ) ) {
651
-		give_set_error( 'logged_in_only', esc_html__( 'You must be logged into to donate.', 'give' ) );
650
+	if (give_logged_in_only($form_id)) {
651
+		give_set_error('logged_in_only', esc_html__('You must be logged into to donate.', 'give'));
652 652
 	}
653 653
 
654 654
 	// Get the guest email
655
-	$guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false;
655
+	$guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false;
656 656
 
657 657
 	// Check email
658
-	if ( $guest_email && strlen( $guest_email ) > 0 ) {
658
+	if ($guest_email && strlen($guest_email) > 0) {
659 659
 		// Validate email
660
-		if ( ! is_email( $guest_email ) ) {
660
+		if ( ! is_email($guest_email)) {
661 661
 			// Invalid email
662
-			give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
662
+			give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
663 663
 		} else {
664 664
 			// All is good to go
665 665
 			$valid_user_data['user_email'] = $guest_email;
666 666
 		}
667 667
 	} else {
668 668
 		// No email
669
-		give_set_error( 'email_empty', esc_html__( 'Enter an email.', 'give' ) );
669
+		give_set_error('email_empty', esc_html__('Enter an email.', 'give'));
670 670
 	}
671 671
 
672 672
 	// Loop through required fields and show error messages
673
-	foreach ( give_purchase_form_required_fields( $form_id ) as $field_name => $value ) {
674
-		if ( in_array( $value, give_purchase_form_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
675
-			give_set_error( $value['error_id'], $value['error_message'] );
673
+	foreach (give_purchase_form_required_fields($form_id) as $field_name => $value) {
674
+		if (in_array($value, give_purchase_form_required_fields($form_id)) && empty($_POST[$field_name])) {
675
+			give_set_error($value['error_id'], $value['error_message']);
676 676
 		}
677 677
 	}
678 678
 
@@ -688,42 +688,42 @@  discard block
 block discarded – undo
688 688
  * @since   1.0
689 689
  * @return  integer
690 690
  */
691
-function give_register_and_login_new_user( $user_data = array() ) {
691
+function give_register_and_login_new_user($user_data = array()) {
692 692
 	// Verify the array
693
-	if ( empty( $user_data ) ) {
694
-		return - 1;
693
+	if (empty($user_data)) {
694
+		return -1;
695 695
 	}
696 696
 
697
-	if ( give_get_errors() ) {
698
-		return - 1;
697
+	if (give_get_errors()) {
698
+		return -1;
699 699
 	}
700 700
 
701
-	$user_args = apply_filters( 'give_insert_user_args', array(
702
-		'user_login'      => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '',
703
-		'user_pass'       => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '',
704
-		'user_email'      => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '',
705
-		'first_name'      => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '',
706
-		'last_name'       => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '',
707
-		'user_registered' => date( 'Y-m-d H:i:s' ),
708
-		'role'            => get_option( 'default_role' )
709
-	), $user_data );
701
+	$user_args = apply_filters('give_insert_user_args', array(
702
+		'user_login'      => isset($user_data['user_login']) ? $user_data['user_login'] : '',
703
+		'user_pass'       => isset($user_data['user_pass']) ? $user_data['user_pass'] : '',
704
+		'user_email'      => isset($user_data['user_email']) ? $user_data['user_email'] : '',
705
+		'first_name'      => isset($user_data['user_first']) ? $user_data['user_first'] : '',
706
+		'last_name'       => isset($user_data['user_last']) ? $user_data['user_last'] : '',
707
+		'user_registered' => date('Y-m-d H:i:s'),
708
+		'role'            => get_option('default_role')
709
+	), $user_data);
710 710
 
711 711
 	// Insert new user
712
-	$user_id = wp_insert_user( $user_args );
712
+	$user_id = wp_insert_user($user_args);
713 713
 
714 714
 	// Validate inserted user
715
-	if ( is_wp_error( $user_id ) ) {
716
-		return - 1;
715
+	if (is_wp_error($user_id)) {
716
+		return -1;
717 717
 	}
718 718
 
719 719
 	// Allow themes and plugins to filter the user data
720
-	$user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args );
720
+	$user_data = apply_filters('give_insert_user_data', $user_data, $user_args);
721 721
 
722 722
 	// Allow themes and plugins to hook
723
-	do_action( 'give_insert_user', $user_id, $user_data );
723
+	do_action('give_insert_user', $user_id, $user_data);
724 724
 
725 725
 	// Login new user
726
-	give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] );
726
+	give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']);
727 727
 
728 728
 	// Return user id
729 729
 	return $user_id;
@@ -738,27 +738,27 @@  discard block
 block discarded – undo
738 738
  * @since   1.0
739 739
  * @return  array
740 740
  */
741
-function give_get_purchase_form_user( $valid_data = array() ) {
741
+function give_get_purchase_form_user($valid_data = array()) {
742 742
 
743 743
 	// Initialize user
744 744
 	$user    = false;
745
-	$is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
745
+	$is_ajax = defined('DOING_AJAX') && DOING_AJAX;
746 746
 
747
-	if ( $is_ajax ) {
747
+	if ($is_ajax) {
748 748
 		// Do not create or login the user during the ajax submission (check for errors only)
749 749
 		return true;
750
-	} else if ( is_user_logged_in() ) {
750
+	} else if (is_user_logged_in()) {
751 751
 		// Set the valid user as the logged in collected data
752 752
 		$user = $valid_data['logged_in_user'];
753
-	} else if ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) {
753
+	} else if ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) {
754 754
 		// New user registration
755
-		if ( $valid_data['need_new_user'] === true ) {
755
+		if ($valid_data['need_new_user'] === true) {
756 756
 			// Set user
757 757
 			$user = $valid_data['new_user_data'];
758 758
 			// Register and login new user
759
-			$user['user_id'] = give_register_and_login_new_user( $user );
759
+			$user['user_id'] = give_register_and_login_new_user($user);
760 760
 			// User login
761
-		} else if ( $valid_data['need_user_login'] === true && ! $is_ajax ) {
761
+		} else if ($valid_data['need_user_login'] === true && ! $is_ajax) {
762 762
 
763 763
 			/*
764 764
 			 * The login form is now processed in the give_process_purchase_login() function.
@@ -773,48 +773,48 @@  discard block
 block discarded – undo
773 773
 			// Set user
774 774
 			$user = $valid_data['login_user_data'];
775 775
 			// Login user
776
-			give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] );
776
+			give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']);
777 777
 		}
778 778
 	}
779 779
 
780 780
 	// Check guest checkout
781
-	if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) {
781
+	if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) {
782 782
 		// Set user
783 783
 		$user = $valid_data['guest_user_data'];
784 784
 	}
785 785
 
786 786
 	// Verify we have an user
787
-	if ( false === $user || empty( $user ) ) {
787
+	if (false === $user || empty($user)) {
788 788
 		// Return false
789 789
 		return false;
790 790
 	}
791 791
 
792 792
 	// Get user first name
793
-	if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) {
794
-		$user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : '';
793
+	if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) {
794
+		$user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : '';
795 795
 	}
796 796
 
797 797
 	// Get user last name
798
-	if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) {
799
-		$user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : '';
798
+	if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) {
799
+		$user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : '';
800 800
 	}
801 801
 
802 802
 	// Get the user's billing address details
803 803
 	$user['address']            = array();
804
-	$user['address']['line1']   = ! empty( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : false;
805
-	$user['address']['line2']   = ! empty( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : false;
806
-	$user['address']['city']    = ! empty( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : false;
807
-	$user['address']['state']   = ! empty( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : false;
808
-	$user['address']['country'] = ! empty( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : false;
809
-	$user['address']['zip']     = ! empty( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : false;
810
-
811
-	if ( empty( $user['address']['country'] ) ) {
804
+	$user['address']['line1']   = ! empty($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : false;
805
+	$user['address']['line2']   = ! empty($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : false;
806
+	$user['address']['city']    = ! empty($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : false;
807
+	$user['address']['state']   = ! empty($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : false;
808
+	$user['address']['country'] = ! empty($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : false;
809
+	$user['address']['zip']     = ! empty($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : false;
810
+
811
+	if (empty($user['address']['country'])) {
812 812
 		$user['address'] = false;
813 813
 	} // Country will always be set if address fields are present
814 814
 
815
-	if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) {
815
+	if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) {
816 816
 		// Store the address in the user's meta so the donation form can be pre-populated with it on return purchases
817
-		update_user_meta( $user['user_id'], '_give_user_address', $user['address'] );
817
+		update_user_meta($user['user_id'], '_give_user_address', $user['address']);
818 818
 	}
819 819
 
820 820
 	// Return valid user
@@ -833,16 +833,16 @@  discard block
 block discarded – undo
833 833
 	$card_data = give_get_purchase_cc_info();
834 834
 
835 835
 	// Validate the card zip
836
-	if ( ! empty( $card_data['card_zip'] ) ) {
837
-		if ( ! give_purchase_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) {
838
-			give_set_error( 'invalid_cc_zip', esc_html__( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) );
836
+	if ( ! empty($card_data['card_zip'])) {
837
+		if ( ! give_purchase_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) {
838
+			give_set_error('invalid_cc_zip', esc_html__('The zip / postal code you entered for your billing address is invalid.', 'give'));
839 839
 		}
840 840
 	}
841 841
 
842 842
 	//Ensure no spaces
843
-	if ( ! empty( $card_data['card_number'] ) ) {
844
-		$card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); //no "+" signs
845
-		$card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces
843
+	if ( ! empty($card_data['card_number'])) {
844
+		$card_data['card_number'] = str_replace('+', '', $card_data['card_number']); //no "+" signs
845
+		$card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces
846 846
 	}
847 847
 
848 848
 	// This should validate card numbers at some point too
@@ -858,17 +858,17 @@  discard block
 block discarded – undo
858 858
  */
859 859
 function give_get_purchase_cc_info() {
860 860
 	$cc_info                   = array();
861
-	$cc_info['card_name']      = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : '';
862
-	$cc_info['card_number']    = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : '';
863
-	$cc_info['card_cvc']       = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : '';
864
-	$cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : '';
865
-	$cc_info['card_exp_year']  = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : '';
866
-	$cc_info['card_address']   = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : '';
867
-	$cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : '';
868
-	$cc_info['card_city']      = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : '';
869
-	$cc_info['card_state']     = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : '';
870
-	$cc_info['card_country']   = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : '';
871
-	$cc_info['card_zip']       = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : '';
861
+	$cc_info['card_name']      = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : '';
862
+	$cc_info['card_number']    = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : '';
863
+	$cc_info['card_cvc']       = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : '';
864
+	$cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : '';
865
+	$cc_info['card_exp_year']  = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : '';
866
+	$cc_info['card_address']   = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : '';
867
+	$cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : '';
868
+	$cc_info['card_city']      = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : '';
869
+	$cc_info['card_state']     = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : '';
870
+	$cc_info['card_country']   = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : '';
871
+	$cc_info['card_zip']       = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : '';
872 872
 
873 873
 	// Return cc info
874 874
 	return $cc_info;
@@ -884,14 +884,14 @@  discard block
 block discarded – undo
884 884
  *
885 885
  * @return bool|mixed|void
886 886
  */
887
-function give_purchase_form_validate_cc_zip( $zip = 0, $country_code = '' ) {
887
+function give_purchase_form_validate_cc_zip($zip = 0, $country_code = '') {
888 888
 	$ret = false;
889 889
 
890
-	if ( empty( $zip ) || empty( $country_code ) ) {
890
+	if (empty($zip) || empty($country_code)) {
891 891
 		return $ret;
892 892
 	}
893 893
 
894
-	$country_code = strtoupper( $country_code );
894
+	$country_code = strtoupper($country_code);
895 895
 
896 896
 	$zip_regex = array(
897 897
 		"AD" => "AD\d{3}",
@@ -1051,9 +1051,9 @@  discard block
 block discarded – undo
1051 1051
 		"ZM" => "\d{5}"
1052 1052
 	);
1053 1053
 
1054
-	if ( ! isset ( $zip_regex[ $country_code ] ) || preg_match( "/" . $zip_regex[ $country_code ] . "/i", $zip ) ) {
1054
+	if ( ! isset ($zip_regex[$country_code]) || preg_match("/".$zip_regex[$country_code]."/i", $zip)) {
1055 1055
 		$ret = true;
1056 1056
 	}
1057 1057
 
1058
-	return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code );
1058
+	return apply_filters('give_is_zip_valid', $ret, $zip, $country_code);
1059 1059
 }
1060 1060
\ No newline at end of file
Please login to merge, or discard this patch.